contracts.go (package eai)
Source: sdks/go/contracts.go. Back to the Go SDK reference index.
This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.
Model ValidationResult
ValidationResult is the outcome of a contract validation.
Fields:
| Name | Type | Required | Description |
|---|---|---|---|
Contract (contract) | string | yes | Name of the contract used, unknown when the manifest kind could not be resolved. |
Valid (valid) | bool | yes | true when the document matches the contract. |
Errors (errors) | []string | yes | Validation errors, each as /json/pointer: message; empty when valid. |
Functions
ContractNames
ContractNames() []string
ContractNames lists the embedded contracts (common definitions excluded).
This element takes no parameter.
Returns: []string. Sorted copy of the names of the embedded contracts/v1 schemas, without common.
ContractSchema
ContractSchema(name string) (json.RawMessage, error)
ContractSchema returns the embedded JSON Schema of a contract.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
name | string | yes | Contract name as listed by ContractNames, without .schema.json. |
Returns: (json.RawMessage, error). Raw JSON of the schema; the error is set when no embedded schema has that name.
Raises: error.
ContractForKind
ContractForKind(kind string) (string, bool)
ContractForKind maps a manifest kind (Agent, Model, Tool...) to its contract name.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
kind | string | yes | Manifest kind: Agent, Model, Tool, Skill, Plugin, Connector, Channel or ManagedComponent. |
Returns: (string, bool). The contract name (for example agent-manifest) and true, or an empty string and false for an unknown kind.
ValidateContract
ValidateContract(lang string, name string, doc any) (ValidationResult, error)
ValidateContract validates doc ([]byte, json.RawMessage, string or any JSON serializable value) against the named contract. lang selects the language of SDK level messages.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
lang | string | yes | Language of the SDK messages, en or fr. | |
name | string | yes | Contract name, one of ContractNames. | |
doc | any | yes | Document to validate: []byte, json.RawMessage, string or any value json.Marshal accepts. |
Returns: (ValidationResult, error). A ValidationResult: ValidationResult is the outcome of a contract validation. The error is a typed error of the SDK, nil on success.
Raises: error.
ValidateManifest
ValidateManifest(lang string, manifest any) (ValidationResult, error)
ValidateManifest picks the contract from the manifest kind.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
lang | string | yes | Language of the SDK messages, en or fr. | |
manifest | any | yes | Manifest to validate, in the same forms as ValidateContract; its kind field selects the contract. |
Returns: (ValidationResult, error). A ValidationResult: ValidationResult is the outcome of a contract validation. The error is a typed error of the SDK, nil on success.
Raises: error.