schema

package
v0.4.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	EventAssistant = "assistant" // Streamed text chunk from the assistant
	EventThinking  = "thinking"  // Streamed thinking/reasoning chunk
	EventTool      = "tool"      // Tool call feedback (name, description)
	EventUsage     = "usage"     // Token usage update
	EventError     = "error"     // Error during processing
	EventResult    = "result"    // Final complete response
	EventProgress  = "progress"  // Download progress update
)
View Source
const (
	RoleUser              = "user"
	RoleAssistant         = "assistant"
	RoleSystem            = "system"
	RoleThinking          = "thinking"
	RoleTool              = "tool"
	MessageListMax uint64 = 100
)

Message role constants

View Source
const (
	Gemini    = "gemini"
	Anthropic = "anthropic"
	Mistral   = "mistral"
	Eliza     = "eliza"
	Ollama    = "ollama"
	OpenAI    = "openai"
)

Provider name constants

View Source
const (
	DefaultSchema        = "llm"
	DefaultAuthSchema    = "auth"
	DefaultNotifyChannel = "channel_notify"
)
View Source
const BuiltinNamespace = "builtin"

BuiltinNamespace is the namespace used for locally-implemented (builtin) tools.

View Source
const (
	ConnectorListMax uint64 = 100
)
View Source
const DefaultMaxIterations = 10

DefaultMaxIterations is the default maximum number of tool-calling iterations per chat turn.

View Source
const (
	EmbeddingTaskTypeDefault = "DEFAULT"
)
View Source
const (
	ProviderListMax uint64 = 100
)
View Source
const ResultOK = ResultStop

ResultOK is an alias for ResultStop (normal completion).

View Source
const (
	SessionListMax uint64 = 100
)

Variables

View Source
var ConnectorURLSchemes = []string{"http", "https"}

ConnectorURLSchemes lists the URL schemes that are accepted for connector registration. Connectors must use one of these schemes.

View Source
var Objects string
View Source
var Queries string

Functions

func ApplyGeneratorMeta

func ApplyGeneratorMeta(values url.Values, meta GeneratorMeta) url.Values

ApplyGeneratorMeta replaces generator-related keys in values with the encoded contents of meta while preserving unrelated keys.

func CanonicalNamespace

func CanonicalNamespace(ns string) string

CanonicalNamespace normalises a namespace string by lowercasing it, removing spaces and replacing "-" and "." characters with underscores.

func CanonicalURL

func CanonicalURL(rawURL string) (string, error)

CanonicalURL validates rawURL and returns a canonical form consisting of scheme://host[:port]/path with a lowercased scheme, host, and path. The URL must be absolute, use a supported scheme (http or https), have a non-empty host, and — if a port is present — a valid port in 1–65535. Any userinfo, query string, or fragment is stripped.

func HTTPErr

func HTTPErr(err error) error

func MetaForKey

func MetaForKey(meta []MetaValue, key string) any

MetaForKey returns the last value for the given key from a slice of MetaValue, or nil if not found. Returning the last match is consistent with MetaMap, where later entries override earlier ones.

func MetaMap

func MetaMap(meta []MetaValue) map[string]any

MetaMap converts a slice of MetaValue into a map[string]any

func WithAttachment

func WithAttachment(r io.Reader) opt.Opt

WithAttachmentURL creates an attachment from data read from the provided reader The MIME type is detected from the data. This is suitable for small attachments the caller is responsible for closing the reader after the data is read.

func WithAttachmentURL

func WithAttachmentURL(u string, mimetype string) opt.Opt

WithAttachmentURL creates an attachment from a URL and explicit MIME type

Types

type Agent

type Agent struct {
	ID      string    `json:"id"`
	Created time.Time `json:"created"`
	Version uint      `json:"version"`
	AgentMeta
}

Agent is a versioned, stored agent definition.

func (Agent) String

func (a Agent) String() string

type AgentList

type AgentList struct {
	AgentListRequest
	Count uint         `json:"count" help:"Total number of matching agents" example:"2"`
	Body  []*AgentMeta `` /* 141-byte string literal not displayed */
}

AgentList represents a response containing a list of externally exposed agents.

func (AgentList) String

func (r AgentList) String() string

type AgentListRequest

type AgentListRequest struct {
	pg.OffsetLimit

	// Namespace restricts results to a single namespace.
	// Use BuiltinNamespace for locally-implemented agents, a connector namespace
	// for remote agents, or leave empty to include all namespaces.
	Namespace string `json:"namespace,omitempty" help:"Restrict results to a single namespace" example:"builtin"`

	// Name restricts results to agents whose names appear in this list.
	// An empty slice means no name filter.
	Name []string `` /* 128-byte string literal not displayed */
}

AgentListRequest represents a request to list externally exposed agents, which are backed by toolkit prompts.

func (AgentListRequest) Query

func (r AgentListRequest) Query() url.Values

func (AgentListRequest) String

func (r AgentListRequest) String() string

type AgentMeta

type AgentMeta struct {
	GeneratorMeta `yaml:",inline"`
	Name          string     `json:"name" yaml:"name" help:"Unique agent name"`
	Title         string     `json:"title,omitempty" yaml:"title" help:"Human-readable title" optional:""`
	Description   string     `json:"description,omitempty" yaml:"description" help:"Agent description" optional:""`
	Template      string     `json:"template,omitempty" yaml:"-" help:"Go template for the user message" optional:""`
	Input         JSONSchema `json:"input,omitempty" yaml:"input" help:"JSON schema for agent input" optional:""`
	Tools         []string   `json:"tools,omitzero" yaml:"tools" help:"Tool names the agent is allowed to use" optional:""`
}

AgentMeta describes the definition of an agent, including which model and provider to use and the schemas that govern its input and output.

func (AgentMeta) Cell

func (a AgentMeta) Cell(i int) string

func (AgentMeta) Header

func (AgentMeta) Header() []string

func (AgentMeta) String

func (a AgentMeta) String() string

func (AgentMeta) Width

func (AgentMeta) Width(i int) int

type AgentStore

type AgentStore interface {
	// CreateAgent creates a new agent from the given metadata,
	// returning the agent with a unique ID and version 1.
	CreateAgent(ctx context.Context, meta AgentMeta) (*Agent, error)

	// GetAgent retrieves an existing agent by ID or name.
	// Returns an error if the agent does not exist.
	GetAgent(ctx context.Context, id string) (*Agent, error)

	// ListAgents returns agents matching the request, with pagination support.
	// Returns offset, limit and total count in the response.
	ListAgents(ctx context.Context, req ListAgentRequest) (*ListAgentResponse, error)

	// DeleteAgent removes an agent by ID or name. When a name is provided,
	// all versions of the agent are deleted. Returns an error if no matching
	// agent exists.
	DeleteAgent(ctx context.Context, id string) error

	// UpdateAgent applies non-zero fields from the given metadata to an existing
	// agent and increments the version. Returns the updated agent.
	UpdateAgent(ctx context.Context, id string, meta AgentMeta) (*Agent, error)
}

AgentStore is the interface for agent storage backends.

type AskRequest

type AskRequest struct {
	AskRequestCore
	Attachments []Attachment `` /* 143-byte string literal not displayed */
}

AskRequest represents a stateless request to generate content.

func (AskRequest) String

func (r AskRequest) String() string

type AskRequestCore

type AskRequestCore struct {
	GeneratorMeta
	Text string `json:"text" arg:"" help:"User input text" example:"Summarize the benefits of unit testing in one sentence."`
}

AskRequestCore contains the core fields of an ask request without attachments.

func (AskRequestCore) String

func (r AskRequestCore) String() string

type AskResponse

type AskResponse struct {
	CompletionResponse
	Usage *UsageMeta `` /* 138-byte string literal not displayed */
}

AskResponse represents the response from an ask request.

func (AskResponse) String

func (r AskResponse) String() string

type Attachment

type Attachment struct {
	ContentType string   `json:"type" help:"Attachment MIME type, for example image/png or application/pdf" example:"image/png"`
	Data        []byte   `json:"data,omitempty" help:"Inline attachment payload encoded as a byte string" example:"iVBORw0KGgo="`
	URL         *url.URL `json:"url,omitempty" help:"Attachment URL reference, for example https, gs, or file" example:"https://example.com/image.png"`
}

Attachment represents binary or URI-referenced media (images, documents, etc.)

func (Attachment) Description

func (a Attachment) Description() string

Description returns an empty string. Satisfies llm.Resource.

func (Attachment) IsText

func (a Attachment) IsText() bool

IsText returns true if the attachment has a text/* MIME type (e.g. text/plain, text/html, text/csv). Handles MIME parameters like charset gracefully. Such attachments can be converted to text blocks when providers don't support them as media uploads.

func (Attachment) MarshalJSON

func (a Attachment) MarshalJSON() ([]byte, error)

func (Attachment) Name

func (a Attachment) Name() string

Name returns the last path segment of the attachment URL, or an empty string for inline data. Satisfies llm.Resource.

func (Attachment) Read

func (a Attachment) Read(ctx context.Context) ([]byte, error)

Read returns the attachment's raw bytes. If Data is non-empty it is returned directly. If URL is set and has a supported scheme (http, https, file) the content is fetched. Satisfies llm.Resource.

func (Attachment) TextContent

func (a Attachment) TextContent() string

TextContent returns the attachment's data as a string, optionally prefixed with the filename and content type for context. Only meaningful when IsText() returns true.

func (Attachment) Type

func (a Attachment) Type() string

Type returns the MIME type of the attachment. Satisfies llm.Resource.

func (Attachment) URI

func (a Attachment) URI() string

URI returns the URL of the attachment as a string, or an empty string if the attachment is inline data only. Satisfies llm.Resource.

func (*Attachment) UnmarshalJSON

func (a *Attachment) UnmarshalJSON(data []byte) error

type CallAgentRequest

type CallAgentRequest struct {
	CallToolRequest
	Attachments []interface {
		URI() string
		Name() string
		Description() string
		Type() string
		Read(context.Context) ([]byte, error)
	} `json:"attachments,omitempty" help:"Additional resources attached to the agent call" optional:""`
}

CallAgentRequest represents a request to call an agent directly.

func (CallAgentRequest) String

func (r CallAgentRequest) String() string

type CallToolRequest

type CallToolRequest struct {
	Input json.RawMessage `json:"input,omitempty" help:"JSON-encoded arguments passed to the tool" example:"{\"query\":\"authentication flow\"}"`
}

CallToolRequest represents a request to call a tool directly.

func (CallToolRequest) String

func (r CallToolRequest) String() string

type CallToolResponse

type CallToolResponse struct {
	Tool   string          `json:"tool"`
	Result json.RawMessage `json:"result"`
}

CallToolResponse represents the result of calling a tool

func (CallToolResponse) String

func (r CallToolResponse) String() string

type ChatRequest

type ChatRequest struct {
	Session       uuid.UUID `json:"session" help:"Session ID"`
	Text          string    `json:"text" arg:"" help:"User input text"`
	Tools         []string  `json:"tools,omitzero" help:"Tool names to include (nil means all, empty means none)" optional:""`
	MaxIterations uint      `json:"max_iterations,omitempty" help:"Maximum tool-calling iterations (0 uses default)" optional:""`
	SystemPrompt  string    `json:"system_prompt,omitempty" help:"Per-request system prompt appended to the session prompt" optional:""`
}

ChatRequest contains the core fields of a chat request without attachments.

func (ChatRequest) String

func (r ChatRequest) String() string

type ChatResponse

type ChatResponse struct {
	ID      uint64    `json:"id,omitempty" help:"Persisted message row ID for the final reply when available" example:"42"`
	Session uuid.UUID `json:"session,omitzero" help:"Session owning the final reply when available" optional:""`
	CompletionResponse
	Usage *UsageMeta `json:"usage,omitempty"`
}

ChatResponse represents the response from a chat request.

func (ChatResponse) String

func (r ChatResponse) String() string

type CompletionResponse

type CompletionResponse struct {
	Role    string         `json:"role" help:"Role of the generated response, typically assistant" example:"assistant"`
	Content []ContentBlock `` /* 168-byte string literal not displayed */
	Result  ResultType     `json:"result" help:"Completion result status" example:"\"stop\""`
}

CompletionResponse represents a response from a completion request.

func (CompletionResponse) String

func (r CompletionResponse) String() string

type Connector

type Connector struct {
	// Mutable fields
	ConnectorInsert

	// CreatedAt is the time the connector was first registered.
	CreatedAt time.Time `json:"created_at"`

	// ModifiedAt is the time the connector metadata was last updated.
	ModifiedAt *time.Time `json:"modified_at,omitempty"`

	// Current Connector State
	ConnectorState
}

Connector combines persisted metadata with runtime state for an MCP server.

func (Connector) Cell

func (c Connector) Cell(i int) string

func (Connector) Header

func (Connector) Header() []string

func (*Connector) Scan

func (c *Connector) Scan(row pg.Row) error

Expected column order: url, namespace, enabled, name, title, description, meta, groups, created_at, modified_at, connected_at.

func (Connector) String

func (c Connector) String() string

func (Connector) Width

func (Connector) Width(i int) int

type ConnectorCapability

type ConnectorCapability string

ConnectorCapability represents a named capability advertised by an MCP server.

const (
	// CapabilityTools indicates the server advertises callable tools.
	CapabilityTools ConnectorCapability = "tools"

	// CapabilityResources indicates the server can serve resources.
	CapabilityResources ConnectorCapability = "resources"

	// CapabilityPrompts indicates the server provides reusable prompt templates.
	CapabilityPrompts ConnectorCapability = "prompts"

	// CapabilityLogging indicates the server emits log notifications.
	CapabilityLogging ConnectorCapability = "logging"

	// CapabilityCompletions indicates the server supports argument/prompt completion.
	CapabilityCompletions ConnectorCapability = "completions"
)

type ConnectorGroupList

type ConnectorGroupList []string

ConnectorGroupList is a list of auth group identifiers associated with a connector.

func (*ConnectorGroupList) Scan

func (list *ConnectorGroupList) Scan(row pg.Row) error

type ConnectorGroupRef

type ConnectorGroupRef struct {
	Connector string
	Group     string
}

ConnectorGroupRef represents a single connector-to-group link.

func (ConnectorGroupRef) Insert

func (c ConnectorGroupRef) Insert(bind *pg.Bind) (string, error)

func (ConnectorGroupRef) Update

func (c ConnectorGroupRef) Update(_ *pg.Bind) error

type ConnectorGroupSelector

type ConnectorGroupSelector struct {
	Connector string
	Group     *string
}

ConnectorGroupSelector selects connector_group rows for a connector, optionally scoped to a single group.

func (ConnectorGroupSelector) Select

func (c ConnectorGroupSelector) Select(bind *pg.Bind, op pg.Op) (string, error)

type ConnectorInsert

type ConnectorInsert struct {
	URL string `json:"url" name:"url" help:"MCP server endpoint URL"`
	ConnectorMeta
}

ConnectorInsert contains the fields required to insert a new connector row.

func (ConnectorInsert) Insert

func (c ConnectorInsert) Insert(bind *pg.Bind) (string, error)

func (ConnectorInsert) String

func (c ConnectorInsert) String() string

func (ConnectorInsert) Update

func (c ConnectorInsert) Update(_ *pg.Bind) error

type ConnectorList

type ConnectorList struct {
	ConnectorListRequest
	Count uint         `json:"count"`
	Body  []*Connector `json:"body,omitzero"`
}

ConnectorList represents a response containing a list of MCP connectors.

func (*ConnectorList) Scan

func (list *ConnectorList) Scan(row pg.Row) error

func (*ConnectorList) ScanCount

func (list *ConnectorList) ScanCount(row pg.Row) error

func (ConnectorList) String

func (r ConnectorList) String() string

type ConnectorListRequest

type ConnectorListRequest struct {
	pg.OffsetLimit
	Namespace string `json:"namespace,omitempty" help:"Filter by namespace" optional:""`
	Enabled   *bool  `json:"enabled,omitempty" help:"Filter by enabled state" negatable:""`
}

ConnectorListRequest represents a request to list registered MCP connectors.

func (ConnectorListRequest) Query

func (req ConnectorListRequest) Query() url.Values

func (ConnectorListRequest) Select

func (req ConnectorListRequest) Select(bind *pg.Bind, op pg.Op) (string, error)

func (ConnectorListRequest) String

func (r ConnectorListRequest) String() string

type ConnectorMeta

type ConnectorMeta struct {
	// Enabled controls whether the server is active. Disabled servers are
	// retained in the registry but not connected on startup.
	// A nil value in a patch request means "preserve the existing value".
	Enabled *bool `` /* 147-byte string literal not displayed */

	// Namespace is an optional prefix used to disambiguate tools from this
	// connector when multiple connectors expose tools with the same name.
	// A nil value in a patch request means "preserve the existing value".
	Namespace *string `` /* 141-byte string literal not displayed */

	// Groups holds auth group identifiers that are allowed to access this
	// connector.
	Groups []string `` /* 157-byte string literal not displayed */

	// Meta holds arbitrary user-managed connector metadata.
	// A nil value in a patch request means "preserve the existing value".
	// An empty object clears the metadata.
	Meta ProviderMetaMap `json:"meta,omitempty" jsonschema:"Arbitrary user-managed connector metadata as a JSON object."`
}

ConnectorMeta holds the user-configurable settings for a registered MCP server.

func (ConnectorMeta) HasTableUpdates

func (c ConnectorMeta) HasTableUpdates() bool

func (ConnectorMeta) Insert

func (c ConnectorMeta) Insert(_ *pg.Bind) (string, error)

func (ConnectorMeta) String

func (c ConnectorMeta) String() string

func (ConnectorMeta) Update

func (c ConnectorMeta) Update(bind *pg.Bind) error

type ConnectorState

type ConnectorState struct {
	// ConnectedAt is the time of the most recent successful connection.
	ConnectedAt *time.Time `json:"connected_at,omitempty"`

	// Name is the programmatic identifier reported by the server.
	Name *string `json:"name,omitempty"`

	// Title is a human-readable display name reported by the server.
	Title *string `json:"title,omitempty"`

	// Description is the server-reported description.
	Description *string `json:"description,omitempty"`

	// Version is the server-reported version string.
	Version *string `json:"version,omitempty"`

	// Capabilities is the set of capabilities declared at initialization.
	Capabilities []ConnectorCapability `json:"capabilities,omitempty"`
}

ConnectorState carries the server-reported runtime state of a connector. All fields are pointers so callers can update a subset without overwriting fields they did not observe.

func (ConnectorState) HasTableUpdates

func (c ConnectorState) HasTableUpdates() bool

func (ConnectorState) Insert

func (c ConnectorState) Insert(_ *pg.Bind) (string, error)

func (ConnectorState) String

func (c ConnectorState) String() string

func (ConnectorState) Update

func (c ConnectorState) Update(bind *pg.Bind) error

type ConnectorStateSelector

type ConnectorStateSelector string

ConnectorStateSelector selects a connector by canonical URL for runtime state updates.

func (ConnectorStateSelector) Select

func (c ConnectorStateSelector) Select(bind *pg.Bind, op pg.Op) (string, error)

type ConnectorURLSelector

type ConnectorURLSelector string

ConnectorURLSelector selects a connector by canonical URL.

func (ConnectorURLSelector) Select

func (c ConnectorURLSelector) Select(bind *pg.Bind, op pg.Op) (string, error)

type ContentBlock

type ContentBlock struct {
	Text       *string     `` /* 141-byte string literal not displayed */
	Thinking   *string     `` /* 136-byte string literal not displayed */
	Attachment *Attachment `` /* 173-byte string literal not displayed */
	ToolCall   *ToolCall   `` /* 161-byte string literal not displayed */
	ToolResult *ToolResult `` /* 190-byte string literal not displayed */
}

ContentBlock represents a single piece of content within a message. Exactly one of the fields should be non-nil/non-empty.

func NewToolError

func NewToolError(id, name string, err error) ContentBlock

NewToolError creates a content block containing a tool error result

func NewToolResult

func NewToolResult(id, name string, v any) ContentBlock

NewToolResult creates a content block containing a successful tool result

type Conversation

type Conversation []*Message

Conversation is a sequence of messages exchanged with an LLM

func (*Conversation) Append

func (s *Conversation) Append(message Message)

Append adds a message to the conversation

func (*Conversation) AppendWithOuput

func (s *Conversation) AppendWithOuput(message Message, input, output uint)

AppendWithOutput adds a message to the conversation, attributing token counts to individual messages. The last message in the conversation (typically the just-appended user message) receives an estimated token count based on its content rather than absorbing overhead such as tool schemas and system prompts. The response message receives the actual output token count from the provider.

func (Conversation) Last

func (c Conversation) Last(n int) *Message

func (Conversation) Len

func (c Conversation) Len() int

func (Conversation) String

func (c Conversation) String() string

func (Conversation) Tokens

func (s Conversation) Tokens() uint

Return the total number of tokens in the conversation

type CreateAgentSessionRequest

type CreateAgentSessionRequest struct {
	Parent string          `json:"parent,omitempty" help:"Parent session ID for traceability" optional:""`
	Input  json.RawMessage `json:"input,omitempty" help:"Input data for the agent template" optional:""`
}

CreateAgentSessionRequest represents the body of a request to create a session from an agent definition. The agent is identified by path/query parameters (agent ID or name, optional version) — not included here. The agent's template is executed with Input, and a new session is created with the merged GeneratorMeta and agent labels. If Parent is set, the parent session's GeneratorMeta is used as defaults (agent fields take precedence). The caller can then use the returned text and tools with the Chat endpoint.

func (CreateAgentSessionRequest) String

func (r CreateAgentSessionRequest) String() string

type CreateAgentSessionResponse

type CreateAgentSessionResponse struct {
	Session string   `json:"session"`         // Created session ID
	Text    string   `json:"text"`            // Rendered template text (first user message)
	Tools   []string `json:"tools,omitempty"` // Tool names the agent is allowed to use
}

CreateAgentSessionResponse is the result of creating a session from an agent. It contains the session ID plus the prepared text and tools, which can be passed directly to a ChatRequest.

func (CreateAgentSessionResponse) String

type CreateConnectorUnauthorizedResponse

type CreateConnectorUnauthorizedResponse struct {
	CodeFlow *oidc.BaseConfiguration `json:"codeflow,omitempty"`
	Scopes   []string                `json:"scopes,omitempty"`
}

CreateConnectorUnauthorizedResponse is placed in the HTTP error detail when connector authorization is required before registration can complete.

func (CreateConnectorUnauthorizedResponse) String

type Credential

type Credential struct {
	CredentialKey
	CreatedAt time.Time `json:"created_at" help:"Creation timestamp" readonly:""`
}

Credential is the public credential row returned from the database. Secret material and passphrase version are intentionally excluded.

func (*Credential) Scan

func (c *Credential) Scan(row pg.Row) error

Expected column order: url, user, created_at.

func (Credential) String

func (c Credential) String() string

type CredentialInsert

type CredentialInsert struct {
	CredentialKey
	Credentials []byte `json:"credentials" help:"Encrypted credential payload"`
}

CredentialInsert contains the values required to insert a credential row. The returned Credential omits PV and Credentials.

func (CredentialInsert) Insert

func (c CredentialInsert) Insert(bind *pg.Bind) (string, error)

func (CredentialInsert) RedactedString

func (c CredentialInsert) RedactedString() string

func (CredentialInsert) String

func (c CredentialInsert) String() string

func (CredentialInsert) Update

func (c CredentialInsert) Update(_ *pg.Bind) error

type CredentialKey

type CredentialKey struct {
	URL  string     `json:"url" help:"Credential URL"`
	User *uuid.UUID `json:"user,omitempty" help:"Credential owner" optional:""`
}

type DeleteModelRequest

type DeleteModelRequest struct {
	Provider string `json:"provider,omitempty" help:"Provider name" optional:""`
	Name     string `json:"name" help:"Model name to delete"`
}

DeleteModelRequest represents a request to delete a model

func (DeleteModelRequest) String

func (r DeleteModelRequest) String() string

type DownloadModelRequest

type DownloadModelRequest struct {
	Provider string `json:"provider,omitempty" help:"Provider name" optional:""`
	Name     string `json:"name" help:"Model name to download"`
}

DownloadModelRequest represents a request to download a model

func (DownloadModelRequest) String

func (r DownloadModelRequest) String() string

type EmbeddingRequest

type EmbeddingRequest struct {
	Provider             string   `json:"provider,omitempty" help:"Provider name" optional:""`
	Model                string   `json:"model,omitempty" help:"Model name" optional:""`
	Input                []string `json:"input,omitempty" arg:"" help:"Text inputs to embed" optional:""`
	TaskType             string   `` /* 244-byte string literal not displayed */
	Title                string   `json:"title,omitempty" help:"Document title, used with RETRIEVAL_DOCUMENT task type (Google-specific)"`
	OutputDimensionality uint     `json:"output_dimensionality,omitempty" help:"Truncate embedding to this many dimensions (Google-specific)"`
}

EmbeddingRequest represents a request to embed text

func (EmbeddingRequest) String

func (r EmbeddingRequest) String() string

type EmbeddingResponse

type EmbeddingResponse struct {
	EmbeddingRequest
	Output [][]float64 `json:"output,omitempty"`
	Usage  *UsageMeta  `` /* 127-byte string literal not displayed */
}

EmbeddingResponse represents a response from an embedding request

func (EmbeddingResponse) String

func (r EmbeddingResponse) String() string

type Err

type Err int

Errors

const (
	ErrSuccess Err = iota
	ErrNotFound
	ErrBadParameter
	ErrNotImplemented
	ErrConflict
	ErrInternalServerError
	ErrMaxTokens
	ErrRefusal
	ErrPauseTurn
	ErrServiceUnavailable
)

func (Err) Error

func (e Err) Error() string

func (Err) HTTP

func (e Err) HTTP() httpresponse.Err

func (Err) With

func (e Err) With(args ...any) error

func (Err) Withf

func (e Err) Withf(format string, args ...any) error

type GeneratorMeta

type GeneratorMeta struct {
	Provider       *string    `json:"provider,omitempty" yaml:"provider" help:"Provider name" optional:"" example:"ollama"`
	Model          *string    `json:"model,omitempty" yaml:"model" help:"Model name" optional:"" example:"llama3.2"`
	SystemPrompt   *string    `` /* 133-byte string literal not displayed */
	MaxTokens      *uint      `json:"max_tokens,omitempty" yaml:"max_tokens" help:"Maximum output tokens to generate" optional:"" example:"4096"`
	Format         JSONSchema `` /* 173-byte string literal not displayed */
	Thinking       *bool      `json:"thinking,omitempty" yaml:"thinking" help:"Enable thinking/reasoning" optional:"" negatable:"" example:"true"`
	ThinkingBudget *uint      `` /* 157-byte string literal not displayed */
}

GeneratorMeta represents generator settings which are persisted on a session as URL-style values within the session meta object.

func GeneratorMetaFromValues

func GeneratorMetaFromValues(values url.Values) GeneratorMeta

GeneratorMetaFromValues decodes generator settings from session meta values.

func MergeGeneratorMeta

func MergeGeneratorMeta(primary, fallback GeneratorMeta) GeneratorMeta

MergeGeneratorMeta fills nil fields in primary from fallback.

func (GeneratorMeta) IsZero

func (g GeneratorMeta) IsZero() bool

IsZero reports whether all generator fields are unset.

func (GeneratorMeta) MergeFrom

func (g GeneratorMeta) MergeFrom(override GeneratorMeta) GeneratorMeta

MergeFrom returns a new GeneratorMeta using the receiver as the base and filling in any non-blank fields from override.

func (GeneratorMeta) String

func (g GeneratorMeta) String() string

func (GeneratorMeta) Values

func (g GeneratorMeta) Values() url.Values

Values encodes generator settings as URL values so they can be stored in a session meta JSON object.

type GetModelRequest

type GetModelRequest struct {
	Provider string `json:"provider,omitempty" help:"Filter by provider name" optional:""`
	Name     string `json:"name,omitempty" help:"Model name"`
}

GetModelRequest represents a request to get a model

func (GetModelRequest) String

func (r GetModelRequest) String() string

type JSONSchema

type JSONSchema json.RawMessage

JSONSchema is a JSON-encoded schema that supports unmarshalling from both JSON and YAML sources. When unmarshalling from YAML, the YAML node is first decoded to a native Go value and then marshalled to JSON bytes.

func NewJSONSchema

func NewJSONSchema(data json.RawMessage) JSONSchema

NewJSONSchema creates a JSONSchema from raw JSON bytes.

func (JSONSchema) Bytes

func (s JSONSchema) Bytes() []byte

Bytes returns the underlying JSON bytes.

func (JSONSchema) MarshalJSON

func (s JSONSchema) MarshalJSON() ([]byte, error)

func (*JSONSchema) UnmarshalJSON

func (s *JSONSchema) UnmarshalJSON(data []byte) error

func (*JSONSchema) UnmarshalYAML

func (s *JSONSchema) UnmarshalYAML(node *yaml.Node) error

type ListAgentRequest

type ListAgentRequest struct {
	Name    string `json:"name,omitempty" help:"Filter by agent name" optional:""`
	Version *uint  `json:"version,omitempty" help:"Filter by version number (requires name)" optional:""`
	Limit   *uint  `json:"limit,omitempty" help:"Maximum number of agents to return" default:"100"`
	Offset  uint   `json:"offset,omitempty" help:"Offset for pagination" default:"0"`
}

ListAgentRequest represents a request to list agents

func (ListAgentRequest) String

func (r ListAgentRequest) String() string

type ListAgentResponse

type ListAgentResponse struct {
	Count  uint     `json:"count"`
	Offset uint     `json:"offset,omitzero"`
	Limit  *uint    `json:"limit,omitzero"`
	Body   []*Agent `json:"body,omitzero"`
}

ListAgentResponse represents a response containing a list of agents

func (ListAgentResponse) String

func (r ListAgentResponse) String() string

type ListModelsRequest added in v0.4.5

type ListModelsRequest struct {
	pg.OffsetLimit
}

List models request and response

type ListModelsResponse added in v0.4.5

type ListModelsResponse struct {
	ListModelsRequest
	Count uint     `json:"count"`
	Body  []*Model `json:"models"`
}

func (ListModelsResponse) String added in v0.4.5

func (m ListModelsResponse) String() string

type Message

type Message struct {
	ID      uint64         `json:"id,omitempty" help:"Monotonic message row ID" example:"42"`
	Session uuid.UUID      `json:"session,omitzero" help:"Session owning the message" optional:""`
	Role    string         `json:"role" help:"Message role" enum:"user,assistant,system,thinking,tool" example:"assistant"`
	Content []ContentBlock `` /* 162-byte string literal not displayed */
	Tokens  uint           `json:"tokens,omitempty" help:"Token count attributed to this message" example:"12"`
	Result  ResultType     `` /* 153-byte string literal not displayed */
	Meta    map[string]any `` /* 129-byte string literal not displayed */
}

Message represents a message in a conversation with an LLM. It uses a universal content block representation that can be marshaled to any provider's format.

func NewMessage

func NewMessage(role string, text string, opts ...opt.Opt) (*Message, error)

Create a new message with the given role and text content

func (Message) Cell

func (m Message) Cell(i int) string

func (Message) EstimateTokens

func (m Message) EstimateTokens() uint

EstimateTokens returns a rough token count for the message content. It estimates ~4 characters per token for text, plus a fixed cost per non-text block (attachments, tool calls/results). This is useful for attributing per-message token costs without a provider-specific tokeniser.

func (Message) Header

func (Message) Header() []string

func (*Message) Scan

func (m *Message) Scan(row pg.Row) error

func (Message) String

func (m Message) String() string

func (Message) Text

func (m Message) Text() string

Text returns the concatenated text content from all text blocks in the message

func (Message) ToolCalls

func (m Message) ToolCalls() []ToolCall

ToolCalls returns all tool call blocks in the message

func (Message) Width

func (Message) Width(i int) int

type MessageInsert

type MessageInsert struct {
	Session uuid.UUID `json:"session" help:"Session ID"`
	Message `embed:""`
}

MessageInsert persists a message within a session conversation.

func (MessageInsert) Insert

func (m MessageInsert) Insert(bind *pg.Bind) (string, error)

func (*MessageInsert) Scan

func (m *MessageInsert) Scan(row pg.Row) error

func (MessageInsert) Update

func (m MessageInsert) Update(_ *pg.Bind) error

type MessageList

type MessageList struct {
	MessageListRequest
	Count uint       `json:"count" help:"Total number of matching messages" example:"2"`
	Body  []*Message `` /* 184-byte string literal not displayed */
}

MessageList represents a paginated list of stored messages.

func (*MessageList) Scan

func (list *MessageList) Scan(row pg.Row) error

func (*MessageList) ScanCount

func (list *MessageList) ScanCount(row pg.Row) error

func (MessageList) String

func (r MessageList) String() string

type MessageListRequest

type MessageListRequest struct {
	pg.OffsetLimit
	Sessions []uuid.UUID `json:"-"`
	Last     uint64      `json:"-"`
	Until    uint64      `json:"-"`
	Role     string      `json:"role,omitempty" help:"Filter by exact message role" optional:""`
	Text     string      `json:"text,omitempty" help:"Case-insensitive text search over message content" optional:""`
}

MessageListRequest represents a request to list stored messages.

func (MessageListRequest) Query

func (req MessageListRequest) Query() url.Values

func (MessageListRequest) Select

func (req MessageListRequest) Select(bind *pg.Bind, op pg.Op) (string, error)

func (MessageListRequest) String

func (r MessageListRequest) String() string

type MetaValue

type MetaValue struct {
	Key   string
	Value any
}

MetaValue is a single key/value pair for the MCP _meta field.

func Meta

func Meta(key string, value any) MetaValue

Meta returns a MetaValue that can be passed to CallTool to populate the protocol-level _meta object sent with the request.

type Model

type Model struct {
	Name             string         `json:"name,omitzero"`
	Description      string         `json:"description,omitzero"`
	Created          time.Time      `json:"created,omitzero"`
	OwnedBy          string         `json:"owned_by,omitzero"`           // Model provider
	Aliases          []string       `json:"aliases,omitzero"`            // Model aliases
	Meta             map[string]any `json:"meta,omitzero"`               // Provider-specific metadata
	InputTokenLimit  *uint          `json:"input_token_limit,omitzero"`  // Input token limit (optional)
	OutputTokenLimit *uint          `json:"output_token_limit,omitzero"` // Output token limit (optional)
	Cap              ModelCap       `json:"capabilities,omitzero"`       // Model capabilities (optional)
}

Represents an LLM model

func (Model) Cell

func (m Model) Cell(i int) string

func (Model) Header

func (Model) Header() []string

func (Model) String

func (m Model) String() string

func (Model) Width

func (Model) Width(i int) int

type ModelCap

type ModelCap uint32

Model Capabilities

const (
	ModelCapEmbeddings ModelCap = 1 << iota
	ModelCapCompletion
	ModelCapThinking
	ModelCapTools
	ModelCapVision
	ModelCapTranscription
	ModelCapTranslation
)

func (ModelCap) String

func (c ModelCap) String() string

type ModelList

type ModelList struct {
	ModelListRequest
	Provider []string `json:"provider,omitempty"`
	Count    uint     `json:"count"`
	Body     []Model  `json:"body,omitzero"`
}

ModelList represents a response containing a list of models and providers

func (ModelList) String

func (r ModelList) String() string

type ModelListRequest

type ModelListRequest struct {
	pg.OffsetLimit
	Provider string `json:"provider,omitempty" help:"Filter by provider name" optional:""`
}

ModelListRequest represents a request to list models

func (ModelListRequest) Query

func (r ModelListRequest) Query() url.Values

func (ModelListRequest) String

func (r ModelListRequest) String() string

type ModelNameSelector

type ModelNameSelector struct {
	Name string `json:"name" help:"Model name"`
}

ModelNameSelector selects a model by name for path-based GET operations.

type ModelProviderSelector

type ModelProviderSelector struct {
	Provider string `json:"provider" help:"Provider name"`
	Name     string `json:"name" help:"Model name"`
}

ModelProviderSelector selects a model by provider and name for path-based GET operations.

type MultipartAskRequest

type MultipartAskRequest struct {
	AskRequest
	File types.File `json:"file,omitempty" help:"File attachment (multipart upload)" optional:""`
}

MultipartAskRequest is the HTTP-layer request type supporting both JSON (with base64 attachments) and multipart/form-data file uploads.

func (*MultipartAskRequest) FileAttachment

func (r *MultipartAskRequest) FileAttachment() (*Attachment, error)

FileAttachment reads the multipart file (if present) and returns it as an Attachment with auto-detected MIME type. Returns nil if no file was uploaded.

type OAuthCredentials

type OAuthCredentials struct {
	*oauth2.Token

	// ClientID is the OAuth client ID used to obtain this token.
	ClientID string `json:"client_id"`

	// ClientSecret is the OAuth client secret, if any (for confidential clients).
	// Needed for token refresh with servers that require client authentication.
	ClientSecret string `json:"client_secret,omitempty"`

	// Endpoint is the MCP/OAuth server endpoint (used for discovery).
	Endpoint string `json:"endpoint"`

	// TokenURL is the OAuth token endpoint URL (used for refresh without re-discovery).
	TokenURL string `json:"token_url"`
}

OAuthCredentials bundles an OAuth token with the metadata needed to refresh or reuse it later without re-discovering or re-registering.

type ProgressEvent

type ProgressEvent struct {
	Status  string  `json:"status"`
	Percent float64 `json:"percent"`
}

ProgressEvent is sent during a streaming model download.

type Provider

type Provider struct {
	Name       string     `json:"name" help:"Unique provider name"`
	Provider   string     `json:"provider" help:"Provider identifier"`
	CreatedAt  time.Time  `json:"created_at" help:"Creation timestamp"`
	ModifiedAt *time.Time `json:"modified_at,omitempty" help:"Last modification timestamp" optional:""`
	ProviderMeta
}

Provider is the persisted representation of a provider row.

func (Provider) Cell

func (t Provider) Cell(i int) string

func (Provider) Header

func (t Provider) Header() []string

func (*Provider) Scan

func (p *Provider) Scan(row pg.Row) error

Scan reads a provider row into the receiver. Expected column order: name, provider, url, enabled, include, exclude, created_at, modified_at, meta, groups.

func (Provider) String

func (p Provider) String() string

func (Provider) Width

func (t Provider) Width(i int) int

type ProviderCredentials

type ProviderCredentials struct {
	APIKey string `json:"api_key,omitempty" name:"api-key" help:"Provider API key" optional:"" env:"LLM_PROVIDER_API_KEY"`
}

ProviderCredentials contains the secret material used to access a provider.

func (ProviderCredentials) String

func (p ProviderCredentials) String() string

type ProviderGroupList

type ProviderGroupList []string

ProviderGroupList is a list of auth group identifiers associated with a provider.

func (*ProviderGroupList) Scan

func (list *ProviderGroupList) Scan(row pg.Row) error

type ProviderGroupRef

type ProviderGroupRef struct {
	Provider string
	Group    string
}

ProviderGroupRef represents a single provider-to-group link.

func (ProviderGroupRef) Insert

func (p ProviderGroupRef) Insert(bind *pg.Bind) (string, error)

Insert binds a provider_group insert.

func (ProviderGroupRef) Update

func (p ProviderGroupRef) Update(_ *pg.Bind) error

Update is not supported for ProviderGroupRef.

type ProviderGroupSelector

type ProviderGroupSelector struct {
	Provider string
	Group    *string
}

ProviderGroupSelector selects provider_group rows for a provider, optionally scoped to a single group.

func (ProviderGroupSelector) Select

func (p ProviderGroupSelector) Select(bind *pg.Bind, op pg.Op) (string, error)

Select binds a provider_group query.

type ProviderInsert

type ProviderInsert struct {
	Name     string `json:"name" arg:"" name:"name" help:"Unique provider name"`
	Provider string `json:"provider" name:"provider" help:"Provider identifier"`
	ProviderMeta
	ProviderCredentials
}

ProviderInsert contains the fields required to insert a new provider row.

func (ProviderInsert) Insert

func (p ProviderInsert) Insert(bind *pg.Bind) (string, error)

Insert binds all required provider fields for an INSERT and returns the named query.

func (ProviderInsert) String

func (p ProviderInsert) String() string

func (ProviderInsert) Update

func (p ProviderInsert) Update(_ *pg.Bind) error

Update is not supported for ProviderInsert.

type ProviderList

type ProviderList struct {
	ProviderListRequest
	Count uint64      `json:"count" readonly:""`
	Body  []*Provider `json:"body,omitempty"`
}

ProviderList represents a paginated list of providers.

func (*ProviderList) Scan

func (list *ProviderList) Scan(row pg.Row) error

func (*ProviderList) ScanCount

func (list *ProviderList) ScanCount(row pg.Row) error

func (ProviderList) String

func (p ProviderList) String() string

type ProviderListRequest

type ProviderListRequest struct {
	pg.OffsetLimit
	Name     string   `json:"name,omitempty" name:"name" help:"Filter by provider name" optional:""`
	Provider string   `json:"provider,omitempty" name:"provider" help:"Filter by provider identifier" optional:""`
	Enabled  *bool    `json:"enabled,omitempty" name:"enabled" help:"Filter by enabled state" negatable:""`
	Groups   []string `json:"groups,omitempty" name:"groups" help:"Filter by accessible groups" optional:""`
}

ProviderListRequest contains pagination for listing providers.

func (ProviderListRequest) Query

func (req ProviderListRequest) Query() url.Values

func (ProviderListRequest) Select

func (req ProviderListRequest) Select(bind *pg.Bind, op pg.Op) (string, error)

func (ProviderListRequest) String

func (p ProviderListRequest) String() string

type ProviderMeta

type ProviderMeta struct {
	URL     *string         `json:"url,omitempty" name:"url" help:"Provider endpoint URL" optional:""`
	Enabled *bool           `json:"enabled,omitempty" name:"enabled" help:"Enable the provider" negatable:""`
	Include []string        `json:"include,omitempty" name:"include" help:"List of models to include (regular expressions)" optional:""`
	Exclude []string        `json:"exclude,omitempty" name:"exclude" help:"List of models to exclude (regular expressions)" optional:""`
	Groups  []string        `json:"groups,omitempty" name:"groups" help:"Groups with access to this provider" optional:""`
	Meta    ProviderMetaMap `json:"meta,omitempty" name:"meta" help:"Provider metadata as a JSON object" optional:""`
}

ProviderMeta contains the user-writable fields for an existing provider row. The provider kind itself is immutable after creation and is stored on Provider.

func (ProviderMeta) HasTableUpdates

func (p ProviderMeta) HasTableUpdates() bool

HasTableUpdates reports whether ProviderMeta includes fields stored on the provider table itself.

func (ProviderMeta) Insert

func (p ProviderMeta) Insert(_ *pg.Bind) (string, error)

Insert is not supported for ProviderMeta.

func (ProviderMeta) String

func (p ProviderMeta) String() string

func (ProviderMeta) Update

func (p ProviderMeta) Update(bind *pg.Bind) error

Update binds mutable provider fields for an UPDATE.

type ProviderMetaMap

type ProviderMetaMap map[string]any

func (*ProviderMetaMap) UnmarshalJSON

func (m *ProviderMetaMap) UnmarshalJSON(data []byte) error

func (*ProviderMetaMap) UnmarshalText

func (m *ProviderMetaMap) UnmarshalText(text []byte) error

type ProviderNameSelector

type ProviderNameSelector string

ProviderNameSelector selects a provider by name for get, update, and delete operations.

func (ProviderNameSelector) Select

func (p ProviderNameSelector) Select(bind *pg.Bind, op pg.Op) (string, error)

type ResultType

type ResultType uint

The result of generating a message (stopped, error, etc.)

const (
	ResultStop          ResultType = iota // Normal completion
	ResultMaxTokens                       // Truncated due to max tokens
	ResultBlocked                         // Blocked by safety, recitation, or content filter
	ResultToolCall                        // Model requested a tool call
	ResultError                           // Generation error
	ResultOther                           // Other/unknown finish reason
	ResultMaxIterations                   // Tool-calling loop exhausted max iterations
)

func (ResultType) MarshalJSON

func (r ResultType) MarshalJSON() ([]byte, error)

func (ResultType) String

func (r ResultType) String() string

func (*ResultType) UnmarshalJSON

func (r *ResultType) UnmarshalJSON(data []byte) error

type Session

type Session struct {
	ID   uuid.UUID `json:"id"`
	User uuid.UUID `json:"user" help:"User owning the session"`
	SessionInsert
	Input      uint       `json:"input,omitempty" help:"Cumulative input message tokens for the session"`
	Output     uint       `json:"output,omitempty" help:"Cumulative output message tokens for the session"`
	Overhead   uint       `json:"overhead,omitempty" help:"Cumulative non-message input token cost observed across the session"`
	CreatedAt  time.Time  `json:"created_at" help:"Creation timestamp"`
	ModifiedAt *time.Time `json:"modified_at,omitempty" help:"Last modification timestamp" optional:""`
}

Session represents a stored conversation with an LLM.

func (Session) Cell

func (s Session) Cell(i int) string

func (Session) Generator

func (s Session) Generator() GeneratorMeta

Generator returns the session generator settings.

func (Session) Header

func (Session) Header() []string

func (Session) MarshalJSON

func (s Session) MarshalJSON() ([]byte, error)

MarshalJSON omits User and Parent when they are the zero UUID.

func (*Session) Scan

func (s *Session) Scan(row pg.Row) error

Expected column order: id, parent, user, title, input, output, overhead, meta, tags, created_at, modified_at.

func (Session) String

func (s Session) String() string

func (*Session) Validate

func (s *Session) Validate() error

Validate returns an error if the session is missing required fields.

func (Session) Width

func (Session) Width(i int) int

type SessionChannelRequest

type SessionChannelRequest struct {
	Text          string   `json:"text" arg:"" help:"User input text"`
	Tools         []string `json:"tools,omitzero" help:"Tool names to include (nil means all, empty means none)" optional:""`
	MaxIterations uint     `json:"max_iterations,omitempty" help:"Maximum tool-calling iterations (0 uses default)" optional:""`
	SystemPrompt  string   `json:"system_prompt,omitempty" help:"Per-request system prompt appended to the session prompt" optional:""`
}

SessionChannelRequest represents one inbound channel frame for a session. The session is selected by the path parameter, not the frame body.

func (SessionChannelRequest) String

func (r SessionChannelRequest) String() string

type SessionIDSelector

type SessionIDSelector uuid.UUID

SessionIDSelector selects a session by ID for get, update, and delete operations.

func (SessionIDSelector) Select

func (s SessionIDSelector) Select(bind *pg.Bind, op pg.Op) (string, error)

type SessionInsert

type SessionInsert struct {
	Parent uuid.UUID `json:"parent,omitempty" help:"Parent session for threading" optional:""`
	SessionMeta
}

func (SessionInsert) Insert

func (s SessionInsert) Insert(bind *pg.Bind) (string, error)

func (SessionInsert) String

func (s SessionInsert) String() string

func (SessionInsert) Update

func (s SessionInsert) Update(_ *pg.Bind) error

type SessionList

type SessionList struct {
	SessionListRequest
	Count uint       `json:"count"`
	Body  []*Session `json:"body,omitzero"`
}

SessionList represents a response containing a list of sessions.

func (*SessionList) Scan

func (list *SessionList) Scan(row pg.Row) error

func (*SessionList) ScanCount

func (list *SessionList) ScanCount(row pg.Row) error

func (SessionList) String

func (s SessionList) String() string

type SessionListRequest

type SessionListRequest struct {
	pg.OffsetLimit
	Parent *uuid.UUID `json:"parent,omitzero" help:"Filter by parent session ID" optional:""`
	User   *uuid.UUID `json:"user,omitzero" help:"Filter by user ID" optional:""`
	Title  *string    `json:"title,omitempty" help:"Filter by session title (partial match)" optional:""`
	Tags   []string   `json:"tags,omitempty" help:"Filter by tags (sessions must contain all specified tags)" optional:""`
}

SessionListRequest represents a request to list sessions.

func (SessionListRequest) Query

func (req SessionListRequest) Query() url.Values

func (SessionListRequest) Select

func (req SessionListRequest) Select(bind *pg.Bind, op pg.Op) (string, error)

func (SessionListRequest) String

func (s SessionListRequest) String() string

type SessionMeta

type SessionMeta struct {
	GeneratorMeta
	Title *string  `json:"title,omitempty" help:"Session title" optional:""`
	Tags  []string `json:"tags,omitempty" help:"User-defined tags" optional:""`
}

SessionMeta represents the metadata for a session.

func (SessionMeta) Generator

func (s SessionMeta) Generator() GeneratorMeta

Generator returns the session generator settings.

func (SessionMeta) Insert

func (s SessionMeta) Insert(_ *pg.Bind) (string, error)

func (SessionMeta) String

func (s SessionMeta) String() string

func (SessionMeta) Update

func (s SessionMeta) Update(bind *pg.Bind) error

type SessionOverheadSelector

type SessionOverheadSelector uuid.UUID

SessionOverheadSelector selects a session row for overhead-only updates.

func (SessionOverheadSelector) Select

func (s SessionOverheadSelector) Select(bind *pg.Bind, op pg.Op) (string, error)

type SessionOverheadUpdate

type SessionOverheadUpdate struct {
	Increment uint `json:"increment,omitempty"`
}

SessionOverheadUpdate increments the cumulative session overhead.

func (SessionOverheadUpdate) Insert

func (s SessionOverheadUpdate) Insert(_ *pg.Bind) (string, error)

func (SessionOverheadUpdate) Update

func (s SessionOverheadUpdate) Update(bind *pg.Bind) error

type StreamDelta

type StreamDelta struct {
	Role string `json:"role"`
	Text string `json:"text"`
}

StreamDelta represents a single streamed text chunk in an SSE stream.

type StreamError

type StreamError struct {
	Error string `json:"error"`
}

StreamError represents an error event in an SSE stream.

type ToolCall

type ToolCall struct {
	ID    string          `json:"id,omitempty" help:"Provider-assigned tool call identifier" example:"call_123"`
	Name  string          `json:"name" help:"Tool name to invoke" example:"get_weather"`
	Input json.RawMessage `json:"input,omitempty" help:"JSON-encoded arguments passed to the tool" example:"{\"city\":\"London\"}"`
	Meta  map[string]any  `json:"meta,omitempty" help:"Provider-specific metadata associated with the tool call" example:"{\"provider\":\"demo\"}"`
}

ToolCall represents a tool invocation requested by the model

type ToolList

type ToolList struct {
	ToolListRequest
	Count uint        `json:"count" help:"Total number of matching tools" example:"2"`
	Body  []*ToolMeta `` /* 144-byte string literal not displayed */
}

ToolList represents a response containing a list of tools.

func (ToolList) String

func (r ToolList) String() string

type ToolListRequest

type ToolListRequest struct {
	pg.OffsetLimit

	// Namespace restricts results to a single namespace.
	// Use BuiltinNamespace for locally-implemented tools, a connector URL for
	// remote tools, or leave empty to include all namespaces.
	Namespace string `json:"namespace,omitempty" help:"Restrict results to a single namespace" example:"builtin"`

	// Name restricts results to tools whose names appear in this list.
	// An empty slice means no name filter — all names are included.
	Name []string `` /* 128-byte string literal not displayed */
}

ToolListRequest represents a request to list tools

func (ToolListRequest) Query

func (r ToolListRequest) Query() url.Values

func (ToolListRequest) String

func (r ToolListRequest) String() string

type ToolMeta

type ToolMeta struct {
	Name        string     `json:"name" help:"Fully-qualified tool name" example:"builtin.search_docs"`
	Title       string     `json:"title,omitempty" help:"Human-readable tool title" example:"Search Docs"`
	Description string     `` /* 126-byte string literal not displayed */
	Input       JSONSchema `` /* 148-byte string literal not displayed */
	Output      JSONSchema `` /* 151-byte string literal not displayed */
	Hints       []string   `json:"hints,omitempty" help:"Additional usage hints for the tool" example:"[\"read_only\"]"`
}

ToolMeta represents a tool's metadata.

func (ToolMeta) Cell

func (t ToolMeta) Cell(i int) string

func (ToolMeta) Header

func (ToolMeta) Header() []string

func (ToolMeta) String

func (r ToolMeta) String() string

func (ToolMeta) Width

func (ToolMeta) Width(i int) int

type ToolResult

type ToolResult struct {
	ID      string          `json:"id,omitempty" help:"Tool call identifier this result belongs to" example:"call_123"`
	Name    string          `json:"name,omitempty" help:"Tool name that produced this result" example:"get_weather"`
	Content json.RawMessage `json:"content,omitempty" help:"JSON-encoded tool output content" example:"{\"temperature_c\":18}"`
	IsError bool            `json:"is_error,omitempty" help:"Whether the tool result represents an error" example:"false"`
}

ToolResult represents the result of running a tool

type Usage

type Usage struct {
	ID          uint64 `json:"id,omitempty" help:"Usage record identifier" readonly:""`
	UsageInsert `embed:""`
	CreatedAt   time.Time `json:"created_at,omitempty" help:"Creation timestamp" readonly:""`
}

func (*Usage) Scan

func (u *Usage) Scan(row pg.Row) error

type UsageInsert

type UsageInsert struct {
	Type      UsageType `json:"type,omitempty" help:"Usage category" example:"ask"`
	Batch     *string   `json:"batch,omitempty" help:"Optional batch identifier for batch operations" optional:""`
	User      uuid.UUID `json:"user,omitempty" help:"Optional user ID for attribution" optional:""`
	Session   uuid.UUID `json:"session,omitempty" help:"Optional session ID for chat interactions" optional:""`
	Provider  *string   `json:"provider,omitempty" help:"Optional provider name for attribution" optional:""`
	Model     string    `json:"model,omitempty" help:"Model name associated with the usage record" example:"gemini-2.5-pro"`
	UsageMeta `embed:""`
}

func (UsageInsert) Insert

func (u UsageInsert) Insert(bind *pg.Bind) (string, error)

func (UsageInsert) Update

func (u UsageInsert) Update(_ *pg.Bind) error

type UsageMeta

type UsageMeta struct {
	InputTokens      uint            `json:"input_tokens,omitempty" help:"Number of input tokens consumed by the request" example:"18"`
	OutputTokens     uint            `json:"output_tokens,omitempty" help:"Number of output tokens generated by the model" example:"12"`
	CacheReadTokens  uint            `json:"cache_read_tokens,omitempty" help:"Number of tokens read from cache" example:"5"`
	CacheWriteTokens uint            `json:"cache_write_tokens,omitempty" help:"Number of tokens written to cache" example:"3"`
	ReasoningTokens  uint            `json:"reasoning_tokens,omitempty" help:"Number of tokens used for reasoning" example:"2"`
	Meta             ProviderMetaMap `json:"meta,omitempty" help:"Optional provider-specific metadata for usage records" optional:""`
}

type UsageType

type UsageType string
const (
	UsageTypeEmbedding UsageType = "embedding"
	UsageTypeAsk       UsageType = "ask"
	UsageTypeChat      UsageType = "chat"
)

Jump to

Keyboard shortcuts

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