Documentation
¶
Index ¶
- func ResolveCommand(ctx context.Context, rt Runtime, userInput string) string
- func UnwrapMCPToolset(toolset tools.ToolSet) *mcptools.Toolset
- type AgentChoiceEvent
- type AgentChoiceReasoningEvent
- type AgentContext
- type AgentDetails
- type AgentInfoEvent
- type AgentSwitchingEvent
- 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 latest.Config) (*api.EditAgentConfigResponse, error)
- func (c *Client) ExportAgents(ctx context.Context) (*api.ExportAgentsResponse, error)
- func (c *Client) GetAgent(ctx context.Context, id string) (*latest.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) ResumeElicitation(ctx context.Context, sessionID string, action tools.ElicitationAction, ...) error
- func (c *Client) ResumeSession(ctx context.Context, id, confirmation string) 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 ConnectRPCClient
- func (c *ConnectRPCClient) CreateSession(ctx context.Context, sessTemplate *session.Session) (*session.Session, error)
- func (c *ConnectRPCClient) DeleteSession(ctx context.Context, id string) error
- func (c *ConnectRPCClient) GetAgent(ctx context.Context, id string) (*latest.Config, error)
- func (c *ConnectRPCClient) GetAgents(ctx context.Context) ([]api.Agent, error)
- func (c *ConnectRPCClient) GetSession(ctx context.Context, id string) (*api.SessionResponse, error)
- func (c *ConnectRPCClient) GetSessions(ctx context.Context) ([]api.SessionsResponse, error)
- func (c *ConnectRPCClient) Ping(ctx context.Context) error
- func (c *ConnectRPCClient) ResumeElicitation(ctx context.Context, sessionID string, action tools.ElicitationAction, ...) error
- func (c *ConnectRPCClient) ResumeSession(ctx context.Context, id, confirmation string) error
- func (c *ConnectRPCClient) RunAgent(ctx context.Context, sessionID, agent string, messages []api.Message) (<-chan Event, error)
- func (c *ConnectRPCClient) RunAgentWithAgentName(ctx context.Context, sessionID, agent, agentName string, ...) (<-chan Event, error)
- func (c *ConnectRPCClient) ToggleToolApproval(ctx context.Context, sessionID string) error
- type ConnectRPCClientOption
- 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 AgentInfo(agentName, model, description, welcomeMessage string) Event
- func AgentSwitching(switching bool, fromAgent, toAgent string) Event
- func Authorization(confirmation tools.ElicitationAction, agentName string) Event
- func ElicitationRequest(message string, schema any, meta map[string]any, agentName string) Event
- func Error(msg string) Event
- func HookBlocked(toolCall tools.ToolCall, toolDefinition tools.Tool, message, agentName string) Event
- func MCPInitFinished(agentName string) Event
- func MCPInitStarted(agentName string) Event
- func MaxIterationsReached(maxIterations int) Event
- func PartialToolCall(toolCall tools.ToolCall, toolDefinition tools.Tool, agentName string) Event
- func RAGIndexingCompleted(ragName, strategyName, agentName string) Event
- func RAGIndexingProgress(ragName, strategyName string, current, total int, agentName string) Event
- func RAGIndexingStarted(ragName, strategyName, agentName string) Event
- func SessionCompaction(sessionID, status, agentName string) Event
- func SessionSummary(sessionID, summary, agentName string) Event
- func SessionTitle(sessionID, title string) Event
- func ShellOutput(output string) Event
- func StreamStarted(sessionID, agentName string) Event
- func StreamStopped(sessionID, agentName string) Event
- func TeamInfo(availableAgents []AgentDetails, currentAgent string) Event
- func TokenUsage(sessionID, agentName string, ...) 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, toolDefinition tools.Tool, ...) Event
- func ToolsetInfo(availableTools int, loading bool, agentName string) Event
- func UserMessage(message string) Event
- func Warning(message, agentName string) Event
- type HookBlockedEvent
- type LocalRuntime
- func (r *LocalRuntime) CurrentAgent() *agent.Agent
- func (r *LocalRuntime) CurrentAgentCommands(context.Context) types.Commands
- func (r *LocalRuntime) CurrentAgentName() string
- func (r *LocalRuntime) CurrentAgentTools(ctx context.Context) ([]tools.Tool, error)
- func (r *LocalRuntime) CurrentMCPPrompts(ctx context.Context) map[string]mcptools.PromptInfo
- func (r *LocalRuntime) EmitStartupInfo(ctx context.Context, events chan Event)
- func (r *LocalRuntime) InitializeRAG(ctx context.Context, events chan Event)
- func (r *LocalRuntime) ResetStartupInfo()
- func (r *LocalRuntime) Resume(_ context.Context, confirmationType ResumeType)
- func (r *LocalRuntime) ResumeElicitation(ctx context.Context, action tools.ElicitationAction, content map[string]any) error
- func (r *LocalRuntime) Run(ctx context.Context, sess *session.Session) ([]session.Message, error)
- func (r *LocalRuntime) RunStream(ctx context.Context, sess *session.Session) <-chan Event
- func (r *LocalRuntime) SessionStore() session.Store
- func (r *LocalRuntime) SetCurrentAgent(agentName string) error
- func (r *LocalRuntime) StartBackgroundRAGInit(ctx context.Context, sendEvent func(Event))
- func (r *LocalRuntime) Summarize(ctx context.Context, sess *session.Session, additionalPrompt string, ...)
- type MCPInitFinishedEvent
- type MCPInitStartedEvent
- type MaxIterationsReachedEvent
- type ModelStore
- type Opt
- func WithCurrentAgent(agentName string) Opt
- func WithEnv(env []string) Opt
- func WithManagedOAuth(managed bool) Opt
- func WithModelStore(store ModelStore) Opt
- func WithSessionCompaction(sessionCompaction bool) Opt
- func WithSessionStore(store session.Store) Opt
- func WithTracer(t trace.Tracer) Opt
- func WithWorkingDir(dir string) Opt
- type PartialToolCallEvent
- type RAGIndexingCompletedEvent
- type RAGIndexingProgressEvent
- type RAGIndexingStartedEvent
- type RAGInitializer
- type RemoteClient
- type RemoteRuntime
- func (r *RemoteRuntime) CurrentAgentCommands(ctx context.Context) types.Commands
- func (r *RemoteRuntime) CurrentAgentName() string
- func (r *RemoteRuntime) CurrentAgentTools(_ context.Context) ([]tools.Tool, error)
- func (r *RemoteRuntime) EmitStartupInfo(ctx context.Context, events chan Event)
- func (r *RemoteRuntime) ResetStartupInfo()
- func (r *RemoteRuntime) Resume(ctx context.Context, confirmationType ResumeType)
- func (r *RemoteRuntime) ResumeElicitation(ctx context.Context, action tools.ElicitationAction, content map[string]any) error
- 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) SessionStore() session.Store
- func (r *RemoteRuntime) SetCurrentAgent(agentName string) error
- func (r *RemoteRuntime) Summarize(_ context.Context, sess *session.Session, _ string, events chan Event)
- type RemoteRuntimeOption
- type ResumeType
- type Runtime
- type SessionCompactionEvent
- type SessionSummaryEvent
- type SessionTitleEvent
- type ShellOutputEvent
- type StreamStartedEvent
- type StreamStoppedEvent
- type TeamInfoEvent
- type TokenUsageEvent
- type ToolCallConfirmationEvent
- type ToolCallEvent
- type ToolCallResponseEvent
- type ToolHandler
- type ToolHandlerFunc
- type ToolsetInfoEvent
- type Usage
- type UserMessageEvent
- type WarningEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResolveCommand ¶ added in v1.8.2
ResolveCommand transforms a /command into its expanded instruction text. It processes: 1. Command lookup from agent commands 2. Tool command execution (!tool_name(arg=value)) - tools executed and output inserted 3. JavaScript expressions (${...}) - evaluated with access to all agent tools and args array
- ${args[0]}, ${args[1]}, etc. for positional arguments
- ${args} or ${args.join(" ")} for all arguments
- ${tool({...})} for tool calls
Types ¶
type AgentChoiceEvent ¶
type AgentChoiceEvent struct {
Type string `json:"type"`
Content string `json:"content"`
AgentContext
}
type AgentChoiceReasoningEvent ¶ added in v1.0.5
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 AgentDetails ¶ added in v1.8.2
type AgentDetails struct {
Name string `json:"name"`
Description string `json:"description"`
Provider string `json:"provider"`
Model string `json:"model"`
}
AgentDetails contains information about an agent for display in the sidebar
type AgentInfoEvent ¶ added in v1.8.2
type AgentInfoEvent struct {
Type string `json:"type"`
AgentName string `json:"agent_name"`
Model string `json:"model"`
Description string `json:"description"`
WelcomeMessage string `json:"welcome_message,omitempty"`
AgentContext
}
AgentInfoEvent is sent when agent information is available or changes
type AgentSwitchingEvent ¶ added in v1.8.2
type AgentSwitchingEvent struct {
Type string `json:"type"`
Switching bool `json:"switching"`
FromAgent string `json:"from_agent,omitempty"`
ToAgent string `json:"to_agent,omitempty"`
AgentContext
}
AgentSwitchingEvent is sent when agent switching starts or stops
type AuthorizationEvent ¶ added in v1.7.0
type AuthorizationEvent struct {
Type string `json:"type"`
Confirmation tools.ElicitationAction `json:"confirmation"`
AgentContext
}
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 latest.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) ResumeElicitation ¶ added in v1.7.0
func (*Client) ResumeSession ¶ added in v1.3.1
ResumeSession resumes a session by ID
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 ConnectRPCClient ¶ added in v1.8.2
type ConnectRPCClient struct {
// contains filtered or unexported fields
}
ConnectRPCClient is a Connect-RPC client for the cagent server API
func NewConnectRPCClient ¶ added in v1.8.2
func NewConnectRPCClient(baseURL string, opts ...ConnectRPCClientOption) (*ConnectRPCClient, error)
NewConnectRPCClient creates a new Connect-RPC client for the cagent server
func (*ConnectRPCClient) CreateSession ¶ added in v1.8.2
func (c *ConnectRPCClient) CreateSession(ctx context.Context, sessTemplate *session.Session) (*session.Session, error)
CreateSession creates a new session
func (*ConnectRPCClient) DeleteSession ¶ added in v1.8.2
func (c *ConnectRPCClient) DeleteSession(ctx context.Context, id string) error
DeleteSession deletes a session by ID
func (*ConnectRPCClient) GetSession ¶ added in v1.8.2
func (c *ConnectRPCClient) GetSession(ctx context.Context, id string) (*api.SessionResponse, error)
GetSession retrieves a session by ID
func (*ConnectRPCClient) GetSessions ¶ added in v1.8.2
func (c *ConnectRPCClient) GetSessions(ctx context.Context) ([]api.SessionsResponse, error)
GetSessions retrieves all sessions
func (*ConnectRPCClient) Ping ¶ added in v1.8.2
func (c *ConnectRPCClient) Ping(ctx context.Context) error
Ping checks if the server is healthy
func (*ConnectRPCClient) ResumeElicitation ¶ added in v1.8.2
func (c *ConnectRPCClient) ResumeElicitation(ctx context.Context, sessionID string, action tools.ElicitationAction, content map[string]any) error
ResumeElicitation sends an elicitation response
func (*ConnectRPCClient) ResumeSession ¶ added in v1.8.2
func (c *ConnectRPCClient) ResumeSession(ctx context.Context, id, confirmation string) error
ResumeSession resumes a session by ID
func (*ConnectRPCClient) RunAgent ¶ added in v1.8.2
func (c *ConnectRPCClient) 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 (*ConnectRPCClient) RunAgentWithAgentName ¶ added in v1.8.2
func (c *ConnectRPCClient) RunAgentWithAgentName(ctx context.Context, sessionID, agent, agentName string, messages []api.Message) (<-chan Event, error)
RunAgentWithAgentName executes an agent with a specific agent name
func (*ConnectRPCClient) ToggleToolApproval ¶ added in v1.8.2
func (c *ConnectRPCClient) ToggleToolApproval(ctx context.Context, sessionID string) error
ToggleToolApproval toggles tool approval for a session
type ConnectRPCClientOption ¶ added in v1.8.2
type ConnectRPCClientOption func(*connectRPCClientOptions)
ConnectRPCClientOption is a function for configuring the ConnectRPCClient
func WithConnectRPCHTTPClient ¶ added in v1.8.2
func WithConnectRPCHTTPClient(client *http.Client) ConnectRPCClientOption
WithConnectRPCHTTPClient sets a custom HTTP client
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
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 tools.ElicitationAction
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.0.5
func AgentSwitching ¶ added in v1.8.2
func Authorization ¶ added in v1.7.0
func Authorization(confirmation tools.ElicitationAction, agentName string) Event
func ElicitationRequest ¶ added in v1.7.0
func HookBlocked ¶ added in v1.8.2
func MCPInitFinished ¶ added in v1.7.3
func MCPInitStarted ¶ added in v1.7.3
func MaxIterationsReached ¶ added in v1.3.5
func PartialToolCall ¶
func RAGIndexingCompleted ¶ added in v1.8.2
func RAGIndexingProgress ¶ added in v1.8.2
func RAGIndexingStarted ¶ added in v1.8.2
func SessionCompaction ¶
func SessionSummary ¶
func SessionTitle ¶
func ShellOutput ¶ added in v1.0.0
func StreamStarted ¶
func StreamStopped ¶
func TeamInfo ¶ added in v1.8.2
func TeamInfo(availableAgents []AgentDetails, currentAgent string) Event
func TokenUsage ¶
func ToolCallConfirmation ¶
func ToolCallResponse ¶
func ToolsetInfo ¶ added in v1.8.2
func UserMessage ¶
type HookBlockedEvent ¶ added in v1.8.2
type HookBlockedEvent struct {
Type string `json:"type"`
ToolCall tools.ToolCall `json:"tool_call"`
ToolDefinition tools.Tool `json:"tool_definition"`
Message string `json:"message"`
AgentContext
}
HookBlockedEvent is sent when a pre-tool hook blocks a tool call
type LocalRuntime ¶ added in v1.8.2
type LocalRuntime struct {
// contains filtered or unexported fields
}
LocalRuntime manages the execution of agents
func New ¶
func New(agents *team.Team, opts ...Opt) (*LocalRuntime, error)
New creates a new runtime for an agent and its team
func (*LocalRuntime) CurrentAgent ¶ added in v1.8.2
func (r *LocalRuntime) CurrentAgent() *agent.Agent
CurrentAgent returns the current agent
func (*LocalRuntime) CurrentAgentCommands ¶ added in v1.8.2
func (r *LocalRuntime) CurrentAgentCommands(context.Context) types.Commands
func (*LocalRuntime) CurrentAgentName ¶ added in v1.8.2
func (r *LocalRuntime) CurrentAgentName() string
func (*LocalRuntime) CurrentAgentTools ¶ added in v1.8.2
CurrentAgentTools returns the tools available to the current agent. This starts the toolsets if needed and returns all available tools.
func (*LocalRuntime) CurrentMCPPrompts ¶ added in v1.8.2
func (r *LocalRuntime) CurrentMCPPrompts(ctx context.Context) map[string]mcptools.PromptInfo
CurrentMCPPrompts returns the available MCP prompts from all active MCP toolsets for the current agent. It discovers prompts by calling ListPrompts on each MCP toolset and aggregates the results into a map keyed by prompt name.
func (*LocalRuntime) EmitStartupInfo ¶ added in v1.8.2
func (r *LocalRuntime) EmitStartupInfo(ctx context.Context, events chan Event)
EmitStartupInfo emits initial agent, team, and toolset information for immediate sidebar display
func (*LocalRuntime) InitializeRAG ¶ added in v1.8.2
func (r *LocalRuntime) InitializeRAG(ctx context.Context, events chan Event)
InitializeRAG is called within RunStream as a fallback when background init wasn't used (e.g., for exec command or API mode where there's no App)
func (*LocalRuntime) ResetStartupInfo ¶ added in v1.8.2
func (r *LocalRuntime) ResetStartupInfo()
ResetStartupInfo resets the startup info emission flag. This should be called when replacing a session to allow re-emission of agent, team, and toolset info to the UI.
func (*LocalRuntime) Resume ¶ added in v1.8.2
func (r *LocalRuntime) Resume(_ context.Context, confirmationType ResumeType)
func (*LocalRuntime) ResumeElicitation ¶ added in v1.8.2
func (r *LocalRuntime) ResumeElicitation(ctx context.Context, action tools.ElicitationAction, content map[string]any) error
ResumeElicitation sends an elicitation response back to a waiting elicitation request
func (*LocalRuntime) RunStream ¶ added in v1.8.2
RunStream starts the agent's interaction loop and returns a channel of events
func (*LocalRuntime) SessionStore ¶ added in v1.8.2
func (r *LocalRuntime) SessionStore() session.Store
SessionStore returns the session store for browsing/loading past sessions.
func (*LocalRuntime) SetCurrentAgent ¶ added in v1.8.2
func (r *LocalRuntime) SetCurrentAgent(agentName string) error
func (*LocalRuntime) StartBackgroundRAGInit ¶ added in v1.8.2
func (r *LocalRuntime) StartBackgroundRAGInit(ctx context.Context, sendEvent func(Event))
StartBackgroundRAGInit initializes RAG in background and forwards events Should be called early (e.g., by App) to start indexing before RunStream
func (*LocalRuntime) Summarize ¶ added in v1.8.2
func (r *LocalRuntime) Summarize(ctx context.Context, sess *session.Session, additionalPrompt string, events chan Event)
Summarize generates a summary for the session based on the conversation history. The additionalPrompt parameter allows users to provide additional instructions for the summarization (e.g., "focus on code changes" or "include action items").
type MCPInitFinishedEvent ¶ added in v1.7.3
type MCPInitFinishedEvent struct {
Type string `json:"type"`
AgentContext
}
type MCPInitStartedEvent ¶ added in v1.7.3
type MCPInitStartedEvent struct {
Type string `json:"type"`
AgentContext
}
MCPInitStartedEvent is for MCP initialization lifecycle events
type MaxIterationsReachedEvent ¶ added in v1.3.5
type MaxIterationsReachedEvent struct {
Type string `json:"type"`
MaxIterations int `json:"max_iterations"`
AgentContext
}
type ModelStore ¶ added in v1.8.2
type Opt ¶
type Opt func(*LocalRuntime)
func WithCurrentAgent ¶
func WithManagedOAuth ¶ added in v1.5.10
func WithModelStore ¶ added in v1.5.4
func WithModelStore(store ModelStore) Opt
func WithSessionCompaction ¶
func WithSessionStore ¶ added in v1.8.2
func WithTracer ¶
WithTracer sets a custom OpenTelemetry tracer; if not provided, tracing is disabled (no-op).
func WithWorkingDir ¶ added in v1.8.2
WithWorkingDir sets the working directory for hooks execution
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 RAGIndexingCompletedEvent ¶ added in v1.8.2
type RAGIndexingCompletedEvent struct {
Type string `json:"type"`
RAGName string `json:"rag_name"`
StrategyName string `json:"strategy_name"`
AgentContext
}
type RAGIndexingProgressEvent ¶ added in v1.8.2
type RAGIndexingStartedEvent ¶ added in v1.8.2
type RAGIndexingStartedEvent struct {
Type string `json:"type"`
RAGName string `json:"rag_name"`
StrategyName string `json:"strategy_name"`
AgentContext
}
RAGIndexingStartedEvent is for RAG lifecycle events
type RAGInitializer ¶ added in v1.8.2
type RAGInitializer interface {
StartBackgroundRAGInit(ctx context.Context, sendEvent func(Event))
}
RAGInitializer is implemented by runtimes that support background RAG initialization. Local runtimes use this to start indexing early; remote runtimes typically do not.
type RemoteClient ¶ added in v1.8.2
type RemoteClient interface {
// GetAgent retrieves an agent configuration by ID
GetAgent(ctx context.Context, id string) (*latest.Config, error)
// CreateSession creates a new session
CreateSession(ctx context.Context, sessTemplate *session.Session) (*session.Session, error)
// ResumeSession resumes a paused session
ResumeSession(ctx context.Context, id, confirmation string) error
// ResumeElicitation sends an elicitation response
ResumeElicitation(ctx context.Context, sessionID string, action tools.ElicitationAction, content map[string]any) error
// RunAgent executes an agent and returns a channel of streaming events
RunAgent(ctx context.Context, sessionID, agent string, messages []api.Message) (<-chan Event, error)
// RunAgentWithAgentName executes an agent with a specific agent name
RunAgentWithAgentName(ctx context.Context, sessionID, agent, agentName string, messages []api.Message) (<-chan Event, error)
}
RemoteClient is the interface that both HTTP and Connect-RPC clients implement for communicating with a remote cagent server.
type RemoteRuntime ¶ added in v1.3.1
type RemoteRuntime struct {
// contains filtered or unexported fields
}
RemoteRuntime implements the Runtime interface using a remote client. It works with any client that implements the RemoteClient interface, including both HTTP (Client) and Connect-RPC (ConnectRPCClient) clients.
func NewRemoteRuntime ¶ added in v1.3.1
func NewRemoteRuntime(client RemoteClient, opts ...RemoteRuntimeOption) (*RemoteRuntime, error)
NewRemoteRuntime creates a new remote runtime that implements the Runtime interface. It accepts any client that implements the RemoteClient interface.
func (*RemoteRuntime) CurrentAgentCommands ¶ added in v1.8.2
func (r *RemoteRuntime) CurrentAgentCommands(ctx context.Context) types.Commands
CurrentAgentCommands returns the commands for the current agent
func (*RemoteRuntime) CurrentAgentName ¶ added in v1.8.2
func (r *RemoteRuntime) CurrentAgentName() string
CurrentAgentName returns the name of the currently active agent
func (*RemoteRuntime) CurrentAgentTools ¶ added in v1.8.2
CurrentAgentTools returns the tools for the current agent. For remote runtime, this returns nil as tools are managed server-side.
func (*RemoteRuntime) EmitStartupInfo ¶ added in v1.8.2
func (r *RemoteRuntime) EmitStartupInfo(ctx context.Context, events chan Event)
EmitStartupInfo emits initial agent, team, and toolset information
func (*RemoteRuntime) ResetStartupInfo ¶ added in v1.8.2
func (r *RemoteRuntime) ResetStartupInfo()
ResetStartupInfo is a no-op for remote runtime.
func (*RemoteRuntime) Resume ¶ added in v1.3.1
func (r *RemoteRuntime) Resume(ctx context.Context, confirmationType ResumeType)
Resume allows resuming execution after user confirmation
func (*RemoteRuntime) ResumeElicitation ¶ added in v1.7.0
func (r *RemoteRuntime) ResumeElicitation(ctx context.Context, action tools.ElicitationAction, content map[string]any) error
ResumeElicitation sends an elicitation response back to a waiting elicitation request
func (*RemoteRuntime) Run ¶ added in v1.3.1
Run starts the agent's interaction loop and returns the final messages
func (*RemoteRuntime) RunStream ¶ added in v1.3.1
RunStream starts the agent's interaction loop and returns a channel of events
func (*RemoteRuntime) SessionStore ¶ added in v1.8.2
func (r *RemoteRuntime) SessionStore() session.Store
SessionStore returns nil for remote runtime since session storage is handled server-side.
func (*RemoteRuntime) SetCurrentAgent ¶ added in v1.8.2
func (r *RemoteRuntime) SetCurrentAgent(agentName string) error
SetCurrentAgent sets the currently active agent for subsequent user 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 {
// CurrentAgentName returns the name of the currently active agent
CurrentAgentName() string
// SetCurrentAgent sets the currently active agent for subsequent user messages
SetCurrentAgent(agentName string) error
// CurrentAgentCommands returns the commands for the active agent
CurrentAgentCommands(ctx context.Context) types.Commands
// CurrentAgentTools returns the tools for the active agent
CurrentAgentTools(ctx context.Context) ([]tools.Tool, error)
// EmitStartupInfo emits initial agent, team, and toolset information for immediate display
EmitStartupInfo(ctx context.Context, events chan Event)
// ResetStartupInfo resets the startup info emission flag, allowing re-emission
ResetStartupInfo()
// 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 ResumeType)
// ResumeElicitation sends an elicitation response back to a waiting elicitation request
ResumeElicitation(_ context.Context, action tools.ElicitationAction, content map[string]any) error
// SessionStore returns the session store for browsing/loading past sessions.
// Returns nil if no persistent session store is configured.
SessionStore() session.Store
// Summarize generates a summary for the session
Summarize(ctx context.Context, sess *session.Session, additionalPrompt string, events chan Event)
}
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.0
func (*ShellOutputEvent) GetAgentName ¶ added in v1.0.0
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 TeamInfoEvent ¶ added in v1.8.2
type TeamInfoEvent struct {
Type string `json:"type"`
AvailableAgents []AgentDetails `json:"available_agents"`
CurrentAgent string `json:"current_agent"`
AgentContext
}
TeamInfoEvent is sent when team information is available
type TokenUsageEvent ¶
type TokenUsageEvent struct {
Type string `json:"type"`
SessionID string `json:"session_id"`
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"`
ToolDefinition tools.Tool `json:"tool_definition"`
Response string `json:"response"`
Result *tools.ToolCallResult `json:"result,omitempty"`
AgentContext
}
type ToolHandler ¶
type ToolHandler struct {
// contains filtered or unexported fields
}
type ToolHandlerFunc ¶ added in v1.8.2
type ToolHandlerFunc func(ctx context.Context, sess *session.Session, toolCall tools.ToolCall, events chan Event) (*tools.ToolCallResult, error)
ToolHandlerFunc is a function type for handling tool calls
type ToolsetInfoEvent ¶ added in v1.8.2
type ToolsetInfoEvent struct {
Type string `json:"type"`
AvailableTools int `json:"available_tools"`
Loading bool `json:"loading"`
AgentContext
}
ToolsetInfoEvent is sent when toolset information is available When Loading is true, more tools may still be loading (e.g., MCP servers starting)
type UserMessageEvent ¶
UserMessageEvent is sent when a user message is received
func (*UserMessageEvent) GetAgentName ¶
func (e *UserMessageEvent) GetAgentName() string
type WarningEvent ¶ added in v1.8.2
type WarningEvent struct {
Type string `json:"type"`
Message string `json:"message"`
AgentContext
}