Documentation
¶
Index ¶
- type AgentChoiceEvent
- type AgentChoiceReasoningEvent
- type AgentContext
- type AuthorizationEvent
- type Client
- func (c *Client) CreateAgent(ctx context.Context, prompt string) (*api.CreateAgentResponse, error)
- func (c *Client) CreateAgentConfig(ctx context.Context, filename, model, description, instruction string) (*api.CreateAgentConfigResponse, error)
- func (c *Client) CreateSession(ctx context.Context, sessTemplate *session.Session) (*session.Session, error)
- func (c *Client) DeleteAgent(ctx context.Context, filePath string) (*api.DeleteAgentResponse, error)
- func (c *Client) DeleteSession(ctx context.Context, id string) error
- func (c *Client) EditAgentConfig(ctx context.Context, filename string, config v2.Config) (*api.EditAgentConfigResponse, error)
- func (c *Client) ExportAgents(ctx context.Context) (*api.ExportAgentsResponse, error)
- func (c *Client) GetAgent(ctx context.Context, id string) (*v2.Config, error)
- func (c *Client) GetAgents(ctx context.Context) ([]api.Agent, error)
- func (c *Client) GetDesktopToken(ctx context.Context) (*api.DesktopTokenResponse, error)
- func (c *Client) GetSession(ctx context.Context, id string) (*api.SessionResponse, error)
- func (c *Client) GetSessions(ctx context.Context) ([]api.SessionsResponse, error)
- func (c *Client) ImportAgent(ctx context.Context, filePath string) (*api.ImportAgentResponse, error)
- func (c *Client) PullAgent(ctx context.Context, name string) (*api.PullAgentResponse, error)
- func (c *Client) PushAgent(ctx context.Context, filepath, tag string) (*api.PushAgentResponse, error)
- func (c *Client) ResumeCodeReceived(ctx context.Context, code, state string) error
- func (c *Client) ResumeElicitation(ctx context.Context, action string, content map[string]any) error
- func (c *Client) ResumeSession(ctx context.Context, id, confirmation string) error
- func (c *Client) ResumeStartAuthorizationFlow(ctx context.Context, id string, confirmation bool) error
- func (c *Client) RunAgent(ctx context.Context, sessionID, agent string, messages []api.Message) (<-chan Event, error)
- func (c *Client) RunAgentWithAgentName(ctx context.Context, sessionID, agent, agentName string, ...) (<-chan Event, error)
- type ClientOption
- type ElicitationError
- type ElicitationRequestEvent
- type ElicitationRequestHandler
- type ElicitationResult
- type ErrorEvent
- type ErrorResponse
- type Event
- func AgentChoice(agentName, content string) Event
- func AgentChoiceReasoning(agentName, content string) Event
- func Authorization(confirmation, agentName string) Event
- func ElicitationRequest(message string, schema any, meta map[string]any, agentName string) Event
- func Error(msg string) Event
- func MaxIterationsReached(maxIterations int) Event
- func PartialToolCall(toolCall tools.ToolCall, toolDefinition tools.Tool, agentName string) Event
- func SessionCompaction(sessionID, status, agentName string) Event
- func SessionSummary(sessionID, summary, agentName string) Event
- func SessionTitle(sessionID, title, agentName string) Event
- func ShellOutput(output string) Event
- func StreamStarted(sessionID, agentName string) Event
- func StreamStopped(sessionID, agentName string) Event
- func TokenUsage(inputTokens, outputTokens, contextLength, contextLimit int, cost float64) Event
- func ToolCall(toolCall tools.ToolCall, toolDefinition tools.Tool, agentName string) Event
- func ToolCallConfirmation(toolCall tools.ToolCall, toolDefinition tools.Tool, agentName string) Event
- func ToolCallResponse(toolCall tools.ToolCall, response, agentName string) Event
- func UserMessage(message string) Event
- type MaxIterationsReachedEvent
- type Opt
- type PartialToolCallEvent
- type RemoteRuntime
- func (r *RemoteRuntime) CurrentAgent() *agent.Agent
- func (r *RemoteRuntime) Resume(ctx context.Context, confirmationType string)
- func (r *RemoteRuntime) ResumeCodeReceived(ctx context.Context, code, state string) error
- func (r *RemoteRuntime) ResumeElicitation(ctx context.Context, action string, content map[string]any) error
- func (r *RemoteRuntime) ResumeStartAuthorizationFlow(ctx context.Context, confirmationType bool)
- func (r *RemoteRuntime) Run(ctx context.Context, sess *session.Session) ([]session.Message, error)
- func (r *RemoteRuntime) RunStream(ctx context.Context, sess *session.Session) <-chan Event
- func (r *RemoteRuntime) Summarize(ctx context.Context, sess *session.Session, events chan Event)
- type RemoteRuntimeOption
- type ResumeType
- type Runtime
- type SessionCompactionEvent
- type SessionSummaryEvent
- type SessionTitleEvent
- type ShellOutputEvent
- type StreamStartedEvent
- type StreamStoppedEvent
- type TokenUsageEvent
- type ToolCallConfirmationEvent
- type ToolCallEvent
- type ToolCallResponseEvent
- type ToolHandler
- type Usage
- type UserMessageEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentChoiceEvent ¶
type AgentChoiceEvent struct {
Type string `json:"type"`
Content string `json:"content"`
AgentContext
}
type AgentChoiceReasoningEvent ¶ added in v1.1.0
type AgentChoiceReasoningEvent struct {
Type string `json:"type"`
Content string `json:"content"`
AgentContext
}
type AgentContext ¶
type AgentContext struct {
AgentName string `json:"agent_name,omitempty"`
}
AgentContext carries optional agent attribution for an event.
func (AgentContext) GetAgentName ¶
func (a AgentContext) GetAgentName() string
GetAgentName returns the agent name for events embedding AgentContext.
type AuthorizationEvent ¶ added in v1.7.0
type AuthorizationEvent struct {
Type string `json:"type"`
Confirmation string `json:"confirmation"` // only "confirmed"
AgentContext
}
func (*AuthorizationEvent) GetAgentName ¶ added in v1.7.0
func (e *AuthorizationEvent) GetAgentName() string
type Client ¶ added in v1.3.1
type Client struct {
// contains filtered or unexported fields
}
Client is an HTTP client for the cagent server API
func NewClient ¶ added in v1.3.1
func NewClient(baseURL string, opts ...ClientOption) (*Client, error)
NewClient creates a new HTTP client for the cagent server
func (*Client) CreateAgent ¶ added in v1.3.1
CreateAgent creates a new agent using a prompt
func (*Client) CreateAgentConfig ¶ added in v1.3.1
func (c *Client) CreateAgentConfig(ctx context.Context, filename, model, description, instruction string) (*api.CreateAgentConfigResponse, error)
CreateAgentConfig creates a new agent manually with YAML configuration
func (*Client) CreateSession ¶ added in v1.3.1
func (c *Client) CreateSession(ctx context.Context, sessTemplate *session.Session) (*session.Session, error)
CreateSession creates a new session
func (*Client) DeleteAgent ¶ added in v1.3.1
func (c *Client) DeleteAgent(ctx context.Context, filePath string) (*api.DeleteAgentResponse, error)
DeleteAgent deletes an agent by file path
func (*Client) DeleteSession ¶ added in v1.3.1
DeleteSession deletes a session by ID
func (*Client) EditAgentConfig ¶ added in v1.3.1
func (c *Client) EditAgentConfig(ctx context.Context, filename string, config v2.Config) (*api.EditAgentConfigResponse, error)
EditAgentConfig edits an agent configuration
func (*Client) ExportAgents ¶ added in v1.3.1
ExportAgents exports multiple agents as a zip file
func (*Client) GetDesktopToken ¶ added in v1.3.1
GetDesktopToken retrieves a desktop authentication token
func (*Client) GetSession ¶ added in v1.3.1
GetSession retrieves a session by ID
func (*Client) GetSessions ¶ added in v1.3.1
GetSessions retrieves all sessions
func (*Client) ImportAgent ¶ added in v1.3.1
func (c *Client) ImportAgent(ctx context.Context, filePath string) (*api.ImportAgentResponse, error)
ImportAgent imports an agent from a file path
func (*Client) PushAgent ¶ added in v1.3.1
func (c *Client) PushAgent(ctx context.Context, filepath, tag string) (*api.PushAgentResponse, error)
PushAgent pushes an agent to a remote registry
func (*Client) ResumeCodeReceived ¶ added in v1.3.1
func (*Client) ResumeElicitation ¶ added in v1.7.0
func (*Client) ResumeSession ¶ added in v1.3.1
ResumeSession resumes a session by ID
func (*Client) ResumeStartAuthorizationFlow ¶ added in v1.3.1
func (*Client) RunAgent ¶ added in v1.3.1
func (c *Client) RunAgent(ctx context.Context, sessionID, agent string, messages []api.Message) (<-chan Event, error)
RunAgent executes an agent and returns a channel of streaming events
func (*Client) RunAgentWithAgentName ¶ added in v1.3.1
func (c *Client) RunAgentWithAgentName(ctx context.Context, sessionID, agent, agentName string, messages []api.Message) (<-chan Event, error)
RunAgentWithAgentName executes an agent with a specific agent name and returns a channel of streaming events
type ClientOption ¶ added in v1.3.1
type ClientOption func(*Client)
ClientOption is a function for configuring the Client
func WithHTTPClient ¶ added in v1.3.1
func WithHTTPClient(client *http.Client) ClientOption
WithHTTPClient sets a custom HTTP client
func WithTimeout ¶ added in v1.3.1
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout sets the HTTP client timeout
type ElicitationError ¶ added in v1.7.0
ElicitationError represents an error from a declined/cancelled elicitation
func (*ElicitationError) Error ¶ added in v1.7.0
func (e *ElicitationError) Error() string
type ElicitationRequestEvent ¶ added in v1.7.0
type ElicitationRequestEvent struct {
Type string `json:"type"`
Message string `json:"message"`
Schema any `json:"schema"`
Meta map[string]any `json:"meta,omitempty"`
AgentContext
}
ElicitationRequestEvent is sent when an elicitation request is received from an MCP server
func (*ElicitationRequestEvent) GetAgentName ¶ added in v1.7.0
func (e *ElicitationRequestEvent) GetAgentName() string
type ElicitationRequestHandler ¶ added in v1.7.0
type ElicitationRequestHandler func(ctx context.Context, message string, schema map[string]any) (map[string]any, error)
ElicitationRequestHandler is a function type for handling elicitation requests
type ElicitationResult ¶ added in v1.7.0
type ElicitationResult struct {
Action string // "accept", "decline", or "cancel"
Content map[string]any // The submitted form data (only present when action is "accept")
}
ElicitationResult represents the result of an elicitation request
type ErrorEvent ¶
type ErrorEvent struct {
Type string `json:"type"`
Error string `json:"error"`
AgentContext
}
type ErrorResponse ¶ added in v1.3.1
type ErrorResponse struct {
Error string `json:"error"`
}
ErrorResponse represents an error response from the API
type Event ¶
type Event interface {
GetAgentName() string
}
func AgentChoice ¶
func AgentChoiceReasoning ¶ added in v1.1.0
func Authorization ¶ added in v1.7.0
func ElicitationRequest ¶ added in v1.7.0
func MaxIterationsReached ¶ added in v1.3.6
func PartialToolCall ¶
func SessionCompaction ¶
func SessionSummary ¶
func SessionTitle ¶
func ShellOutput ¶ added in v1.0.1
func StreamStarted ¶
func StreamStopped ¶
func TokenUsage ¶
func ToolCallConfirmation ¶
func ToolCallResponse ¶
func UserMessage ¶
type MaxIterationsReachedEvent ¶ added in v1.3.6
type MaxIterationsReachedEvent struct {
Type string `json:"type"`
MaxIterations int `json:"max_iterations"`
AgentContext
}
func (*MaxIterationsReachedEvent) GetAgentName ¶ added in v1.3.6
func (e *MaxIterationsReachedEvent) GetAgentName() string
type Opt ¶
type Opt func(*runtime)
func WithCurrentAgent ¶
func WithManagedOAuth ¶ added in v1.5.10
func WithModelStore ¶ added in v1.5.4
func WithModelStore(store modelStore) Opt
func WithRootSessionID ¶ added in v1.6.1
func WithSessionCompaction ¶
func WithTracer ¶
WithTracer sets a custom OpenTelemetry tracer; if not provided, tracing is disabled (no-op).
type PartialToolCallEvent ¶
type PartialToolCallEvent struct {
Type string `json:"type"`
ToolCall tools.ToolCall `json:"tool_call"`
ToolDefinition tools.Tool `json:"tool_definition"`
AgentContext
}
PartialToolCallEvent is sent when a tool call is first received (partial/complete)
type RemoteRuntime ¶ added in v1.3.1
type RemoteRuntime struct {
// contains filtered or unexported fields
}
RemoteRuntime implements the Interface using a remote client
func NewRemoteRuntime ¶ added in v1.3.1
func NewRemoteRuntime(client *Client, opts ...RemoteRuntimeOption) (*RemoteRuntime, error)
NewRemoteRuntime creates a new remote runtime that implements the Interface
func (*RemoteRuntime) CurrentAgent ¶ added in v1.3.1
func (r *RemoteRuntime) CurrentAgent() *agent.Agent
CurrentAgent returns the currently active agent
func (*RemoteRuntime) Resume ¶ added in v1.3.1
func (r *RemoteRuntime) Resume(ctx context.Context, confirmationType string)
Resume allows resuming execution after user confirmation
func (*RemoteRuntime) ResumeCodeReceived ¶ added in v1.3.1
func (r *RemoteRuntime) ResumeCodeReceived(ctx context.Context, code, state string) error
Resume allows resuming execution after user confirmation
func (*RemoteRuntime) ResumeElicitation ¶ added in v1.7.0
func (r *RemoteRuntime) ResumeElicitation(ctx context.Context, action string, content map[string]any) error
ResumeElicitation sends an elicitation response back to a waiting elicitation request
func (*RemoteRuntime) ResumeStartAuthorizationFlow ¶ added in v1.3.1
func (r *RemoteRuntime) ResumeStartAuthorizationFlow(ctx context.Context, confirmationType bool)
Resume allows resuming execution after user confirmation
func (*RemoteRuntime) Run ¶ added in v1.3.1
Run starts the agent's interaction loop and returns the final messages
type RemoteRuntimeOption ¶ added in v1.3.1
type RemoteRuntimeOption func(*RemoteRuntime)
RemoteRuntimeOption is a function for configuring the RemoteRuntime
func WithRemoteAgentFilename ¶ added in v1.3.1
func WithRemoteAgentFilename(filename string) RemoteRuntimeOption
WithRemoteAgentFilename sets the agent filename to use with the remote API
func WithRemoteCurrentAgent ¶ added in v1.3.1
func WithRemoteCurrentAgent(agentName string) RemoteRuntimeOption
WithRemoteCurrentAgent sets the current agent name
type ResumeType ¶
type ResumeType string
const ( ResumeTypeApprove ResumeType = "approve" ResumeTypeApproveSession ResumeType = "approve-session" ResumeTypeReject ResumeType = "reject" )
type Runtime ¶
type Runtime interface {
// CurrentAgent returns the currently active agent
CurrentAgent() *agent.Agent
// RunStream starts the agent's interaction loop and returns a channel of events
RunStream(ctx context.Context, sess *session.Session) <-chan Event
// Run starts the agent's interaction loop and returns the final messages
Run(ctx context.Context, sess *session.Session) ([]session.Message, error)
// Resume allows resuming execution after user confirmation
Resume(ctx context.Context, confirmationType string)
// Summarize generates a summary for the session
Summarize(ctx context.Context, sess *session.Session, events chan Event)
// ResumeElicitation sends an elicitation response back to a waiting elicitation request
ResumeElicitation(_ context.Context, action string, content map[string]any) error
}
Runtime defines the contract for runtime execution
type SessionCompactionEvent ¶
type SessionCompactionEvent struct {
Type string `json:"type"`
SessionID string `json:"session_id"`
Status string `json:"status"`
AgentContext
}
type SessionSummaryEvent ¶
type SessionSummaryEvent struct {
Type string `json:"type"`
SessionID string `json:"session_id"`
Summary string `json:"summary"`
AgentContext
}
type SessionTitleEvent ¶
type SessionTitleEvent struct {
Type string `json:"type"`
SessionID string `json:"session_id"`
Title string `json:"title"`
AgentContext
}
type ShellOutputEvent ¶ added in v1.0.1
func (*ShellOutputEvent) GetAgentName ¶ added in v1.0.1
func (e *ShellOutputEvent) GetAgentName() string
type StreamStartedEvent ¶
type StreamStartedEvent struct {
Type string `json:"type"`
SessionID string `json:"session_id,omitempty"`
AgentContext
}
type StreamStoppedEvent ¶
type StreamStoppedEvent struct {
Type string `json:"type"`
SessionID string `json:"session_id,omitempty"`
AgentContext
}
type TokenUsageEvent ¶
type TokenUsageEvent struct {
Type string `json:"type"`
Usage *Usage `json:"usage"`
AgentContext
}
type ToolCallEvent ¶
type ToolCallEvent struct {
Type string `json:"type"`
ToolCall tools.ToolCall `json:"tool_call"`
ToolDefinition tools.Tool `json:"tool_definition"`
AgentContext
}
ToolCallEvent is sent when a tool call is received
type ToolCallResponseEvent ¶
type ToolCallResponseEvent struct {
Type string `json:"type"`
ToolCall tools.ToolCall `json:"tool_call"`
Response string `json:"response"`
AgentContext
}
type ToolHandler ¶
type ToolHandler func(ctx context.Context, sess *session.Session, toolCall tools.ToolCall, events chan Event) (*tools.ToolCallResult, error)
ToolHandler is a function type for handling tool calls
type UserMessageEvent ¶
UserMessageEvent is sent when a user message is received
func (*UserMessageEvent) GetAgentName ¶
func (e *UserMessageEvent) GetAgentName() string