schema

package
v0.14.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package schema converts AILANG type signatures to JSON Schema objects.

This is the shared foundation for OpenAPI, MCP, and A2A protocol support. It parses type strings like "int -> string -> bool" and produces JSON Schema representations for request parameters and return values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FunctionSchema

type FunctionSchema struct {
	// Parameters is the list of parameter schemas (one per function argument).
	Parameters []JSONSchema
	// Return is the schema for the return type.
	Return JSONSchema
	// Arity is the number of parameters.
	Arity int
}

FunctionSchema holds the decomposed JSON Schema for a function type.

func FromTypeString

func FromTypeString(typeStr string) *FunctionSchema

FromTypeString converts an AILANG type signature string to a FunctionSchema. For non-function types (no "->"), it returns a FunctionSchema with zero parameters and the type itself as the return schema.

Examples:

"int -> string -> bool"  → params: [integer, string], return: boolean
"int"                    → params: [], return: integer
"[int]"                  → params: [], return: array of integer

type JSONSchema

type JSONSchema = map[string]any

JSONSchema represents a JSON Schema object. We use a simple map rather than a struct to support arbitrary schema shapes.

func RequestSchema

func RequestSchema(fs *FunctionSchema) JSONSchema

RequestSchema creates the JSON Schema for a function call request body. This matches the apiserver's FunctionCallRequest format: {"args": [...]}.

func ResponseSchema

func ResponseSchema(fs *FunctionSchema) JSONSchema

ResponseSchema creates the JSON Schema for a function call response body. This matches the apiserver's FunctionCallResponse format.

func TypeToSchema

func TypeToSchema(typeStr string) JSONSchema

TypeToSchema converts a single AILANG type string to a JSON Schema object.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL