Documentation
¶
Overview ¶
Package clienttool carries request-scoped frontend tools without modifying a backend registry. The protocol layer persists definitions and pending calls.
Index ¶
- Constants
- func ContentText(items []llm.ContentItem) string
- func FormatDependencyResult(dependency Dependency, result ChildResult) (string, string, error)
- func MapContent(raw json.RawMessage) ([]llm.ContentItem, error)
- func WithContinuationDependency(ctx context.Context, dependency Dependency) context.Context
- func WithDetachedContinuation(ctx context.Context, continuation DetachedContinuation) context.Context
- func WithExecutingCall(ctx context.Context, call PendingCall) context.Context
- func WithSession(ctx context.Context, session *Session) context.Context
- type ChildResult
- type Dependency
- type DetachedContinuation
- type PendingCall
- type ResultAdapter
- type Session
- func (s *Session) Defer(id, name string, args map[string]interface{}, ...) (PendingCall, error)
- func (s *Session) DeferForTurn(conversationID, turnID, id, name string, args map[string]interface{}, ...) (PendingCall, error)
- func (s *Session) Definitions() []llm.ToolDefinition
- func (s *Session) Error() error
- func (s *Session) ErrorForTurn(conversationID, turnID string) error
- func (s *Session) Lookup(name string) (llm.ToolDefinition, bool)
- func (s *Session) MarkDependencyWaiting(id string) error
- func (s *Session) Metadata(name string) json.RawMessage
- func (s *Session) Pending() []PendingCall
- func (s *Session) PendingForSubtree(conversationID, turnID string) []PendingCall
- func (s *Session) PendingForTurn(conversationID, turnID string) []PendingCall
- func (s *Session) RecordError(err error)
- func (s *Session) RecordErrorForTurn(conversationID, turnID string, err error)
- func (s *Session) RegisterDependency(dependency Dependency) error
- func (s *Session) RestrictManaged(managed, allowed map[string]bool)
- func (s *Session) SetMetadata(name string, metadata json.RawMessage) error
- func (s *Session) ValidateBackend(definitions []llm.ToolDefinition) error
- func (s *Session) WaitingDependencies(conversationID, turnID string) []Dependency
- func (s *Session) WaitingOnCall(conversationID, turnID, callID string) bool
Constants ¶
const ContentMIME = "application/vnd.ag-ui.content+json"
const ItemsMIME = "application/vnd.ag-ui.llm-items+json"
const ToolErrorMIME = "application/vnd.ag-ui.tool-error"
Variables ¶
This section is empty.
Functions ¶
func ContentText ¶
func ContentText(items []llm.ContentItem) string
func FormatDependencyResult ¶
func FormatDependencyResult(dependency Dependency, result ChildResult) (string, string, error)
FormatDependencyResult mirrors the public agents:run result shape, never the QueryOutput agent/config/auth/render data. Waiting children cannot complete it.
func MapContent ¶
func MapContent(raw json.RawMessage) ([]llm.ContentItem, error)
MapContent preserves part order and source semantics without fetching URLs or resolving provider-owned file handles. Providers decide which assets they can consume; raw protocol metadata remains carried in each mapped item's metadata.
func WithContinuationDependency ¶
func WithContinuationDependency(ctx context.Context, dependency Dependency) context.Context
WithContinuationDependency carries a trusted dependency loaded from durable protocol state. HTTP forwarded properties must never directly populate it.
func WithDetachedContinuation ¶
func WithDetachedContinuation(ctx context.Context, continuation DetachedContinuation) context.Context
func WithExecutingCall ¶
func WithExecutingCall(ctx context.Context, call PendingCall) context.Context
Types ¶
type ChildResult ¶
type Dependency ¶
type Dependency struct {
ID string `json:"id"`
ParentCall PendingCall `json:"parentCall"`
ChildConversationID string `json:"childConversationId"`
ChildTurnID string `json:"childTurnId"`
ChildAgentID string `json:"childAgentId,omitempty"`
ExecutionMode string `json:"executionMode,omitempty"`
ResultAdapter ResultAdapter `json:"resultAdapter"`
Waiting bool `json:"waiting"`
}
Dependency is a causal waiting edge. ParentCall is the existing backend tool call to complete after the child turn succeeds; it is never a frontend tool.
func ContinuationDependencyFromContext ¶
func ContinuationDependencyFromContext(ctx context.Context) (Dependency, bool)
type DetachedContinuation ¶
type DetachedContinuation struct {
ChildConversationID string
ChildTurnID string
ParentConversationID string
ParentTurnID string
ParentProtocolRunID string
ExecutionMode string
}
DetachedContinuation is trusted host authority loaded from a principal-scoped internal detached protocol admission. A native conversation link alone does not prove that a child was detached.
func DetachedContinuationFromContext ¶
func DetachedContinuationFromContext(ctx context.Context) (DetachedContinuation, bool)
type PendingCall ¶
type PendingCall struct {
// DeadlineAt is assigned by the server at deferral, or by the explicit
// legacy recovery policy below. It is never extended by reconnect.
// RecoveryObservedAt marks legacy grace; it is not the original admission time.
RecoveryObservedAt string `json:"recoveryObservedAt,omitempty"`
DeadlineAt string `json:"deadlineAt,omitempty"`
Metadata json.RawMessage `json:"metadata,omitempty"`
ProtocolID string `json:"protocolId,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
Arguments map[string]interface{} `json:"arguments"`
ToolMessageID string `json:"toolMessageId"`
AssistantMessageID string `json:"assistantMessageId"`
ConversationID string `json:"conversationId"`
TurnID string `json:"turnId"`
Iteration int `json:"iteration"`
}
func ExecutingCallFromContext ¶
func ExecutingCallFromContext(ctx context.Context) (PendingCall, bool)
type ResultAdapter ¶
type ResultAdapter string
const AgentRunResultV1 ResultAdapter = "agently.agents.run.v1"
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func FromContext ¶
func NewSession ¶
func NewSession(definitions []llm.ToolDefinition) (*Session, error)
func (*Session) Defer ¶
func (s *Session) Defer(id, name string, args map[string]interface{}, persist func() (PendingCall, error)) (PendingCall, error)
Defer reserves a call id and serializes persistence. Duplicate identical calls reuse the original records; conflicting calls and persistence errors poison this session so the agent loop cannot treat a swallowed executor error as success.
func (*Session) DeferForTurn ¶
func (s *Session) DeferForTurn(conversationID, turnID, id, name string, args map[string]interface{}, persist func() (PendingCall, error)) (PendingCall, error)
func (*Session) Definitions ¶
func (s *Session) Definitions() []llm.ToolDefinition
func (*Session) ErrorForTurn ¶
func (*Session) MarkDependencyWaiting ¶
func (*Session) Pending ¶
func (s *Session) Pending() []PendingCall
func (*Session) PendingForSubtree ¶
func (s *Session) PendingForSubtree(conversationID, turnID string) []PendingCall
func (*Session) PendingForTurn ¶
func (s *Session) PendingForTurn(conversationID, turnID string) []PendingCall
func (*Session) RecordError ¶
func (*Session) RecordErrorForTurn ¶
func (*Session) RegisterDependency ¶
func (s *Session) RegisterDependency(dependency Dependency) error
func (*Session) RestrictManaged ¶
RestrictManaged applies server-resolved tool/bundle selection before the model sees managed frontend tools. It cannot be invoked by browser wire metadata.
func (*Session) SetMetadata ¶
func (s *Session) SetMetadata(name string, metadata json.RawMessage) error
Definition metadata is presentation/routing data, never backend authority or provider instruction. Keep it lossless alongside request-scoped definitions.
func (*Session) ValidateBackend ¶
func (s *Session) ValidateBackend(definitions []llm.ToolDefinition) error
func (*Session) WaitingDependencies ¶
func (s *Session) WaitingDependencies(conversationID, turnID string) []Dependency