Skip to main content

contracts.go (package eai)

Source: sdks/go/contracts.go. Back to the Go SDK reference index.

note

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:

NameTypeRequiredDescription
Contract (contract)stringyesName of the contract used, unknown when the manifest kind could not be resolved.
Valid (valid)boolyestrue when the document matches the contract.
Errors (errors)[]stringyesValidation 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.

NameTypeDefaultRequiredDescription
namestringyesContract 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.

NameTypeDefaultRequiredDescription
kindstringyesManifest 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.

NameTypeDefaultRequiredDescription
langstringyesLanguage of the SDK messages, en or fr.
namestringyesContract name, one of ContractNames.
docanyyesDocument 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.

NameTypeDefaultRequiredDescription
langstringyesLanguage of the SDK messages, en or fr.
manifestanyyesManifest 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.