Documentation
¶
Overview ¶
Package acp provides types and utilities for working with the Agent Client Protocol.
Index ¶
- type ACPAgent
- type ACPAgentConfig
- type ACPCapabilities
- type ACPClientCallbacks
- type ACPClientConnection
- func (c *ACPClientConnection) CreateTerminal(ctx context.Context, command string, args []string, cwd string) (string, error)
- func (c *ACPClientConnection) GetSessionID() acpsdk.SessionId
- func (c *ACPClientConnection) GetWorkDir() string
- func (c *ACPClientConnection) KillTerminal(ctx context.Context, terminalID string) error
- func (c *ACPClientConnection) ReadTextFile(ctx context.Context, path string) (string, error)
- func (c *ACPClientConnection) ReleaseTerminal(ctx context.Context, terminalID string) error
- func (c *ACPClientConnection) TerminalOutput(ctx context.Context, terminalID string) (string, error)
- func (c *ACPClientConnection) WaitForTerminalExit(ctx context.Context, terminalID string) (*int, error)
- func (c *ACPClientConnection) WriteTextFile(ctx context.Context, path string, content string) error
- type ACPModelInfo
- type ACPPermissionBridge
- type ACPServerSession
- func (s *ACPServerSession) Cancel()
- func (s *ACPServerSession) Context() context.Context
- func (s *ACPServerSession) HasAgentConnection() bool
- func (s *ACPServerSession) Mode() string
- func (s *ACPServerSession) Model() string
- func (s *ACPServerSession) PandoSessionID() string
- func (s *ACPServerSession) Persona() string
- func (s *ACPServerSession) SendUpdate(update acpsdk.SessionUpdate) error
- func (s *ACPServerSession) SetAgentConnection(conn *acpsdk.AgentSideConnection)
- func (s *ACPServerSession) SetMode(mode string)
- func (s *ACPServerSession) SetModel(model string)
- func (s *ACPServerSession) SetPersona(persona string)
- func (s *ACPServerSession) SetVariant(variant string)
- func (s *ACPServerSession) SetWorkDir(workDir string)
- func (s *ACPServerSession) Variant() string
- type ACPSession
- type ACPSessionInfo
- type ACPToolInfo
- type AgentEvent
- type AgentEventType
- type AgentService
- type HTTPTransport
- func (t *HTTPTransport) ActiveSessions() int
- func (t *HTTPTransport) Cleanup(ctx context.Context)
- func (t *HTTPTransport) CloseSession(sessionID string) error
- func (t *HTTPTransport) GetSessionInfo(sessionID string) (*SessionInfo, error)
- func (t *HTTPTransport) GetStats() TransportStats
- func (t *HTTPTransport) HandleHealth(w http.ResponseWriter, r *http.Request)
- func (t *HTTPTransport) HandleRequest(w http.ResponseWriter, r *http.Request)
- func (t *HTTPTransport) HandleSSE(w http.ResponseWriter, r *http.Request)
- func (t *HTTPTransport) ListSessions() []SessionInfo
- type HTTPTransportConfig
- type McpServerConfig
- type MesnadaACPClient
- func (c *MesnadaACPClient) CreateTerminal(ctx context.Context, params acpsdk.CreateTerminalRequest) (acpsdk.CreateTerminalResponse, error)
- func (c *MesnadaACPClient) ExtractDiffsFromContent(content []acpsdk.ToolCallContent) map[string]string
- func (c *MesnadaACPClient) GetOutput() string
- func (c *MesnadaACPClient) GetPermissionQueue() *PermissionQueue
- func (c *MesnadaACPClient) GetProgress() (int, string)
- func (c *MesnadaACPClient) GetToolCallCount() int
- func (c *MesnadaACPClient) KillTerminalCommand(ctx context.Context, params acpsdk.KillTerminalCommandRequest) (acpsdk.KillTerminalCommandResponse, error)
- func (c *MesnadaACPClient) ReadTextFile(ctx context.Context, params acpsdk.ReadTextFileRequest) (acpsdk.ReadTextFileResponse, error)
- func (c *MesnadaACPClient) ReleaseTerminal(ctx context.Context, params acpsdk.ReleaseTerminalRequest) (acpsdk.ReleaseTerminalResponse, error)
- func (c *MesnadaACPClient) RequestPermission(ctx context.Context, params acpsdk.RequestPermissionRequest) (acpsdk.RequestPermissionResponse, error)
- func (c *MesnadaACPClient) SessionUpdate(ctx context.Context, params acpsdk.SessionNotification) error
- func (c *MesnadaACPClient) SetAutoPermission(auto bool)
- func (c *MesnadaACPClient) SetCapabilities(caps ACPCapabilities)
- func (c *MesnadaACPClient) TerminalOutput(ctx context.Context, params acpsdk.TerminalOutputRequest) (acpsdk.TerminalOutputResponse, error)
- func (c *MesnadaACPClient) WaitForTerminalExit(ctx context.Context, params acpsdk.WaitForTerminalExitRequest) (acpsdk.WaitForTerminalExitResponse, error)
- func (c *MesnadaACPClient) WriteTextFile(ctx context.Context, params acpsdk.WriteTextFileRequest) (acpsdk.WriteTextFileResponse, error)
- type PandoACPAgent
- func (a *PandoACPAgent) Authenticate(ctx context.Context, req acpsdk.AuthenticateRequest) (acpsdk.AuthenticateResponse, error)
- func (a *PandoACPAgent) Cancel(ctx context.Context, params acpsdk.CancelNotification) error
- func (a *PandoACPAgent) GetCapabilities() acpsdk.AgentCapabilities
- func (a *PandoACPAgent) GetVersion() string
- func (a *PandoACPAgent) Initialize(ctx context.Context, req acpsdk.InitializeRequest) (acpsdk.InitializeResponse, error)
- func (a *PandoACPAgent) ListSessions(ctx context.Context) ([]ACPSessionInfo, error)
- func (a *PandoACPAgent) LoadSession(ctx context.Context, req acpsdk.LoadSessionRequest) (acpsdk.LoadSessionResponse, error)
- func (a *PandoACPAgent) NewSession(ctx context.Context, req acpsdk.NewSessionRequest) (acpsdk.NewSessionResponse, error)
- func (a *PandoACPAgent) Prompt(ctx context.Context, req acpsdk.PromptRequest) (acpsdk.PromptResponse, error)
- func (a *PandoACPAgent) SetConnection(conn *acpsdk.AgentSideConnection)
- func (a *PandoACPAgent) SetSessionMode(ctx context.Context, req acpsdk.SetSessionModeRequest) (acpsdk.SetSessionModeResponse, error)
- func (a *PandoACPAgent) SetSessionModel(ctx context.Context, req acpsdk.SetSessionModelRequest) (acpsdk.SetSessionModelResponse, error)
- func (a *PandoACPAgent) SetSessionPersona(ctx context.Context, sessionID acpsdk.SessionId, personaName string) error
- type PendingPermission
- type PermissionQueue
- func (q *PermissionQueue) CleanupResolved(maxAge time.Duration) int
- func (q *PermissionQueue) GetAllPending() []*PendingPermission
- func (q *PermissionQueue) GetPending(taskID string) []*PendingPermission
- func (q *PermissionQueue) GetPermission(requestID string) (*PendingPermission, bool)
- func (q *PermissionQueue) QueuePermission(taskID string, sessionID acpsdk.SessionId, req acpsdk.RequestPermissionRequest) string
- func (q *PermissionQueue) ResolvePermission(requestID string, outcome acpsdk.RequestPermissionOutcome) error
- func (q *PermissionQueue) WaitForResolution(ctx context.Context, requestID string) (acpsdk.RequestPermissionOutcome, error)
- type PermissionRequestData
- type PermissionService
- type PersonaInfo
- type SessionInfo
- type SessionPersonaState
- type SessionService
- type SessionUpdateInfo
- type SimpleACPAgent
- func (a *SimpleACPAgent) Authenticate(ctx context.Context, req acpsdk.AuthenticateRequest) (acpsdk.AuthenticateResponse, error)
- func (a *SimpleACPAgent) Cancel(ctx context.Context, params acpsdk.CancelNotification) error
- func (a *SimpleACPAgent) GetCapabilities() acpsdk.AgentCapabilities
- func (a *SimpleACPAgent) GetVersion() string
- func (a *SimpleACPAgent) Initialize(ctx context.Context, req acpsdk.InitializeRequest) (acpsdk.InitializeResponse, error)
- func (a *SimpleACPAgent) LoadSession(ctx context.Context, req acpsdk.LoadSessionRequest) (acpsdk.LoadSessionResponse, error)
- func (a *SimpleACPAgent) NewSession(ctx context.Context, req acpsdk.NewSessionRequest) (acpsdk.NewSessionResponse, error)
- func (a *SimpleACPAgent) Prompt(ctx context.Context, req acpsdk.PromptRequest) (acpsdk.PromptResponse, error)
- func (a *SimpleACPAgent) SetSessionMode(ctx context.Context, req acpsdk.SetSessionModeRequest) (acpsdk.SetSessionModeResponse, error)
- func (a *SimpleACPAgent) SetSessionModel(ctx context.Context, req acpsdk.SetSessionModelRequest) (acpsdk.SetSessionModelResponse, error)
- type StdioTransport
- type ToolCallInfo
- type TransportStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ACPAgent ¶ added in v0.7.0
type ACPAgent interface {
acpsdk.Agent // Embeds the core SDK Agent interface
acpsdk.AgentLoader // Embeds the optional LoadSession capability
acpsdk.AgentExperimental // Embeds the experimental SetSessionModel capability
// GetVersion returns the agent version
GetVersion() string
// GetCapabilities returns the agent capabilities
GetCapabilities() acpsdk.AgentCapabilities
}
ACPAgent is the interface that ACP agents must implement. This allows the HTTP transport to work with different agent implementations.
type ACPAgentConfig ¶
type ACPAgentConfig struct {
// Name is the unique identifier for this agent configuration
Name string `json:"name" yaml:"name"`
// Title is a human-readable name for the agent
Title string `json:"title" yaml:"title"`
// Command is the binary to execute (e.g., "claude-code", "zed-acp")
Command string `json:"command" yaml:"command"`
// Args are the command-line arguments to pass to the agent
Args []string `json:"args" yaml:"args"`
// Env is a map of environment variables to set for the agent
Env map[string]string `json:"env" yaml:"env"`
// WorkDir is the default working directory for spawned tasks
WorkDir string `json:"work_dir" yaml:"work_dir"`
// Mode is the default operation mode: "code", "ask", or "architect"
Mode string `json:"mode" yaml:"mode"`
// McpServers is a list of MCP servers to pass to the agent
McpServers []McpServerConfig `json:"mcp_servers" yaml:"mcp_servers"`
}
ACPAgentConfig represents the configuration of an ACP agent in config.yaml.
type ACPCapabilities ¶
ACPCapabilities defines what an ACP agent is allowed to do.
type ACPClientCallbacks ¶ added in v0.7.0
type ACPClientCallbacks interface {
ReadTextFile(ctx context.Context, req acpsdk.ReadTextFileRequest) (acpsdk.ReadTextFileResponse, error)
WriteTextFile(ctx context.Context, req acpsdk.WriteTextFileRequest) (acpsdk.WriteTextFileResponse, error)
CreateTerminal(ctx context.Context, req acpsdk.CreateTerminalRequest) (acpsdk.CreateTerminalResponse, error)
TerminalOutput(ctx context.Context, req acpsdk.TerminalOutputRequest) (acpsdk.TerminalOutputResponse, error)
WaitForTerminalExit(ctx context.Context, req acpsdk.WaitForTerminalExitRequest) (acpsdk.WaitForTerminalExitResponse, error)
KillTerminalCommand(ctx context.Context, req acpsdk.KillTerminalCommandRequest) (acpsdk.KillTerminalCommandResponse, error)
ReleaseTerminal(ctx context.Context, req acpsdk.ReleaseTerminalRequest) (acpsdk.ReleaseTerminalResponse, error)
}
ACPClientCallbacks defines the interface for calling back to the client.
type ACPClientConnection ¶ added in v0.7.0
type ACPClientConnection struct {
// contains filtered or unexported fields
}
ACPClientConnection wraps a client connection and provides methods to call back to the client for file operations and terminal execution. This is the INVERSE of MesnadaACPClient - it's used by Pando when acting as an ACP server to call methods on the connected client.
func NewACPClientConnection ¶ added in v0.7.0
func NewACPClientConnection(sessionID acpsdk.SessionId, conn ACPClientCallbacks, workDir string, logFile *os.File) *ACPClientConnection
NewACPClientConnection creates a new client connection wrapper.
func (*ACPClientConnection) CreateTerminal ¶ added in v0.7.0
func (c *ACPClientConnection) CreateTerminal(ctx context.Context, command string, args []string, cwd string) (string, error)
CreateTerminal calls the client to create a terminal and execute a command.
func (*ACPClientConnection) GetSessionID ¶ added in v0.7.0
func (c *ACPClientConnection) GetSessionID() acpsdk.SessionId
GetSessionID returns the session ID for this connection.
func (*ACPClientConnection) GetWorkDir ¶ added in v0.7.0
func (c *ACPClientConnection) GetWorkDir() string
GetWorkDir returns the working directory for this connection.
func (*ACPClientConnection) KillTerminal ¶ added in v0.7.0
func (c *ACPClientConnection) KillTerminal(ctx context.Context, terminalID string) error
KillTerminal calls the client to kill a running terminal.
func (*ACPClientConnection) ReadTextFile ¶ added in v0.7.0
ReadTextFile calls the client to read a file from their filesystem.
func (*ACPClientConnection) ReleaseTerminal ¶ added in v0.7.0
func (c *ACPClientConnection) ReleaseTerminal(ctx context.Context, terminalID string) error
ReleaseTerminal calls the client to release a terminal without waiting for it to exit.
func (*ACPClientConnection) TerminalOutput ¶ added in v0.7.0
func (c *ACPClientConnection) TerminalOutput(ctx context.Context, terminalID string) (string, error)
TerminalOutput calls the client to get the current output from a terminal.
func (*ACPClientConnection) WaitForTerminalExit ¶ added in v0.7.0
func (c *ACPClientConnection) WaitForTerminalExit(ctx context.Context, terminalID string) (*int, error)
WaitForTerminalExit calls the client to wait for a terminal to exit.
func (*ACPClientConnection) WriteTextFile ¶ added in v0.7.0
WriteTextFile calls the client to write a file to their filesystem.
type ACPModelInfo ¶ added in v0.100.0
ACPModelInfo holds minimal model metadata for ACP responses. Defined here to avoid importing internal/llm/models from this package.
type ACPPermissionBridge ¶ added in v0.120.0
type ACPPermissionBridge struct {
// contains filtered or unexported fields
}
ACPPermissionBridge translates Pando tool permission requests into ACP requestPermission calls to the connected editor. It is installed as a session handler when the session mode is "ask".
func NewACPPermissionBridge ¶ added in v0.120.0
func NewACPPermissionBridge(conn *acpsdk.AgentSideConnection, sessionID acpsdk.SessionId, logger *log.Logger) *ACPPermissionBridge
NewACPPermissionBridge creates a new bridge for the given session.
func (*ACPPermissionBridge) Handle ¶ added in v0.120.0
func (b *ACPPermissionBridge) Handle(req PermissionRequestData) bool
Handle processes a permission request by asking the connected editor via ACP. Returns true if approved, false if rejected. Signature matches what RegisterSessionHandler expects: func(req PermissionRequestData) bool
type ACPServerSession ¶ added in v0.100.0
type ACPServerSession struct {
// ID is the unique session identifier
ID acpsdk.SessionId
// WorkDir is the working directory for this session
WorkDir string
// CreatedAt is when the session was created
CreatedAt time.Time
// contains filtered or unexported fields
}
ACPServerSession represents an active ACP session on the server side. Each session manages a conversation between a client and the Pando LLM agent.
func NewACPServerSession ¶ added in v0.100.0
func NewACPServerSession( sessionID acpsdk.SessionId, workDir string, agentConn *acpsdk.AgentSideConnection, pandoSessionID string, ) *ACPServerSession
NewACPServerSession creates a new ACP server session.
func (*ACPServerSession) Cancel ¶ added in v0.100.0
func (s *ACPServerSession) Cancel()
Cancel cancels the session context.
func (*ACPServerSession) Context ¶ added in v0.100.0
func (s *ACPServerSession) Context() context.Context
Context returns the session's context.
func (*ACPServerSession) HasAgentConnection ¶ added in v0.110.0
func (s *ACPServerSession) HasAgentConnection() bool
HasAgentConnection reports whether the session has an attached agent connection.
func (*ACPServerSession) Mode ¶ added in v0.100.0
func (s *ACPServerSession) Mode() string
Mode returns the current session mode.
func (*ACPServerSession) Model ¶ added in v0.100.0
func (s *ACPServerSession) Model() string
Model returns the current model ID.
func (*ACPServerSession) PandoSessionID ¶ added in v0.100.0
func (s *ACPServerSession) PandoSessionID() string
PandoSessionID returns the internal Pando session ID.
func (*ACPServerSession) Persona ¶ added in v0.204.0
func (s *ACPServerSession) Persona() string
Persona returns the current persona name.
func (*ACPServerSession) SendUpdate ¶ added in v0.100.0
func (s *ACPServerSession) SendUpdate(update acpsdk.SessionUpdate) error
SendUpdate sends a SessionUpdate notification to the client via the AgentSideConnection.
func (*ACPServerSession) SetAgentConnection ¶ added in v0.110.0
func (s *ACPServerSession) SetAgentConnection(conn *acpsdk.AgentSideConnection)
SetAgentConnection updates the agent-side connection used to stream updates.
func (*ACPServerSession) SetMode ¶ added in v0.100.0
func (s *ACPServerSession) SetMode(mode string)
SetMode stores the session mode.
func (*ACPServerSession) SetModel ¶ added in v0.100.0
func (s *ACPServerSession) SetModel(model string)
SetModel stores the requested model ID.
func (*ACPServerSession) SetPersona ¶ added in v0.204.0
func (s *ACPServerSession) SetPersona(persona string)
SetPersona stores the requested persona name.
func (*ACPServerSession) SetVariant ¶ added in v0.100.0
func (s *ACPServerSession) SetVariant(variant string)
SetVariant stores the session variant.
func (*ACPServerSession) SetWorkDir ¶ added in v0.110.0
func (s *ACPServerSession) SetWorkDir(workDir string)
SetWorkDir updates the working directory associated with this session.
func (*ACPServerSession) Variant ¶ added in v0.100.0
func (s *ACPServerSession) Variant() string
Variant returns the session variant.
type ACPSession ¶
type ACPSession struct {
// TaskID is the mesnada task identifier
TaskID string
// SessionID is the ACP session identifier returned by the agent
SessionID acpsdk.SessionId
// Conn is the client-side connection to the ACP agent
Conn *acpsdk.ClientSideConnection
// Cmd is the os/exec.Cmd for the running agent process
Cmd *exec.Cmd
// Cancel is the context cancellation function for this session
Cancel context.CancelFunc
}
ACPSession represents an active session with an ACP agent.
type ACPSessionInfo ¶ added in v0.100.0
ACPSessionInfo is a minimal session descriptor used by the ACP layer. Using a local struct avoids importing the session package and breaking the session→llm/tools→acp import cycle.
type ACPToolInfo ¶ added in v0.210.0
ACPToolInfo holds minimal tool metadata for ACP available_commands_update. Defined here to avoid importing internal/llm/tools from this package.
type AgentEvent ¶ added in v0.100.0
type AgentEvent struct {
Type AgentEventType
Message message.Message
Error error
Delta string
ToolCall *message.ToolCall
ToolResult *message.ToolResult
}
AgentEvent represents an event from the agent service
type AgentEventType ¶ added in v0.100.0
type AgentEventType string
AgentEventType represents the type of agent event
const ( AgentEventTypeError AgentEventType = "error" AgentEventTypeResponse AgentEventType = "response" AgentEventTypeSummarize AgentEventType = "summarize" AgentEventTypeContentDelta AgentEventType = "content_delta" AgentEventTypeThinkingDelta AgentEventType = "thinking_delta" AgentEventTypeToolCall AgentEventType = "tool_call" AgentEventTypeToolResult AgentEventType = "tool_result" )
type AgentService ¶ added in v0.100.0
type AgentService interface {
Run(ctx context.Context, sessionID string, content string, attachments ...message.Attachment) (<-chan AgentEvent, error)
Cancel(sessionID string)
// CurrentModelID returns the ID of the currently active model.
CurrentModelID() string
// AvailableModels returns the list of available models with name metadata.
AvailableModels() []ACPModelInfo
// SetModelOverride temporarily changes the active model (in-memory only).
// Pass empty string to clear any previous override.
SetModelOverride(modelID string) error
// ListPersonas returns the names of all available personas.
ListPersonas() []string
// GetActivePersona returns the currently active persona name (empty = none).
GetActivePersona() string
// SetActivePersona sets the active persona by name. Pass empty string to clear.
SetActivePersona(name string) error
// ListAvailableTools returns the name and description of all tools available to the agent.
ListAvailableTools() []ACPToolInfo
}
AgentService defines the interface for interacting with Pando's LLM agent. This is intentionally minimal to avoid import cycles.
type HTTPTransport ¶ added in v0.7.0
type HTTPTransport struct {
// contains filtered or unexported fields
}
HTTPTransport implements HTTP/SSE transport for ACP. It manages multiple client sessions and routes requests to the ACP agent.
func NewHTTPTransport ¶ added in v0.7.0
func NewHTTPTransport(agent ACPAgent, logger *log.Logger, config HTTPTransportConfig) *HTTPTransport
NewHTTPTransport creates a new HTTP transport for the ACP agent.
func (*HTTPTransport) ActiveSessions ¶ added in v0.7.0
func (t *HTTPTransport) ActiveSessions() int
ActiveSessions returns the number of active sessions.
func (*HTTPTransport) Cleanup ¶ added in v0.7.0
func (t *HTTPTransport) Cleanup(ctx context.Context)
Cleanup removes idle sessions.
func (*HTTPTransport) CloseSession ¶ added in v0.7.0
func (t *HTTPTransport) CloseSession(sessionID string) error
CloseSession closes a session and cleans up resources.
func (*HTTPTransport) GetSessionInfo ¶ added in v0.7.0
func (t *HTTPTransport) GetSessionInfo(sessionID string) (*SessionInfo, error)
GetSessionInfo returns information about a specific session.
func (*HTTPTransport) GetStats ¶ added in v0.7.0
func (t *HTTPTransport) GetStats() TransportStats
GetStats returns current transport statistics.
func (*HTTPTransport) HandleHealth ¶ added in v0.7.0
func (t *HTTPTransport) HandleHealth(w http.ResponseWriter, r *http.Request)
HandleHealth handles health check requests.
func (*HTTPTransport) HandleRequest ¶ added in v0.7.0
func (t *HTTPTransport) HandleRequest(w http.ResponseWriter, r *http.Request)
HandleRequest handles HTTP POST requests for ACP JSON-RPC.
func (*HTTPTransport) HandleSSE ¶ added in v0.7.0
func (t *HTTPTransport) HandleSSE(w http.ResponseWriter, r *http.Request)
HandleSSE handles Server-Sent Events for notifications.
func (*HTTPTransport) ListSessions ¶ added in v0.7.0
func (t *HTTPTransport) ListSessions() []SessionInfo
ListSessions returns information about all active sessions.
type HTTPTransportConfig ¶ added in v0.7.0
HTTPTransportConfig holds configuration for the HTTP transport.
func DefaultHTTPTransportConfig ¶ added in v0.7.0
func DefaultHTTPTransportConfig() HTTPTransportConfig
DefaultHTTPTransportConfig returns default configuration.
type McpServerConfig ¶
type McpServerConfig struct {
// Name is the unique identifier for this MCP server
Name string `json:"name" yaml:"name"`
// Command is the binary to execute for stdio-based MCP servers
Command string `json:"command" yaml:"command"`
// Args are the command-line arguments for the MCP server
Args []string `json:"args" yaml:"args"`
// Env is a map of environment variables for the MCP server
Env map[string]string `json:"env" yaml:"env"`
// Type is the transport type: "stdio", "http", or "sse"
Type string `json:"type,omitempty" yaml:"type,omitempty"`
// URL is the endpoint URL for http or sse transports
URL string `json:"url,omitempty" yaml:"url,omitempty"`
// Headers are additional HTTP headers for http/sse transports
Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"`
}
McpServerConfig represents the configuration of an MCP server to pass to an ACP agent.
type MesnadaACPClient ¶
type MesnadaACPClient struct {
// contains filtered or unexported fields
}
MesnadaACPClient implements the ACP client interface required by the SDK. It handles callbacks from ACP agents, managing file operations, terminal sessions, and session state updates for mesnada tasks.
func NewMesnadaACPClient ¶
func NewMesnadaACPClient(taskID string, workDir string, logFile *os.File, onUpdate func(SessionUpdateInfo)) *MesnadaACPClient
NewMesnadaACPClient creates a new MesnadaACPClient.
func (*MesnadaACPClient) CreateTerminal ¶
func (c *MesnadaACPClient) CreateTerminal(ctx context.Context, params acpsdk.CreateTerminalRequest) (acpsdk.CreateTerminalResponse, error)
CreateTerminal creates a new terminal session for executing commands.
func (*MesnadaACPClient) ExtractDiffsFromContent ¶ added in v0.210.0
func (c *MesnadaACPClient) ExtractDiffsFromContent(content []acpsdk.ToolCallContent) map[string]string
ExtractDiffsFromContent extracts file modification diffs from a slice of ToolCallContent.
func (*MesnadaACPClient) GetOutput ¶
func (c *MesnadaACPClient) GetOutput() string
GetOutput returns the accumulated output from the agent session.
func (*MesnadaACPClient) GetPermissionQueue ¶
func (c *MesnadaACPClient) GetPermissionQueue() *PermissionQueue
GetPermissionQueue returns the permission queue for manual approval.
func (*MesnadaACPClient) GetProgress ¶
func (c *MesnadaACPClient) GetProgress() (int, string)
GetProgress returns the current progress percentage and description.
func (*MesnadaACPClient) GetToolCallCount ¶
func (c *MesnadaACPClient) GetToolCallCount() int
GetToolCallCount returns the number of tool calls made during the session.
func (*MesnadaACPClient) KillTerminalCommand ¶
func (c *MesnadaACPClient) KillTerminalCommand(ctx context.Context, params acpsdk.KillTerminalCommandRequest) (acpsdk.KillTerminalCommandResponse, error)
KillTerminalCommand kills a running terminal command.
func (*MesnadaACPClient) ReadTextFile ¶
func (c *MesnadaACPClient) ReadTextFile(ctx context.Context, params acpsdk.ReadTextFileRequest) (acpsdk.ReadTextFileResponse, error)
ReadTextFile reads a file from the task's workspace. This implements strict security: the file must be within the task's workDir.
func (*MesnadaACPClient) ReleaseTerminal ¶
func (c *MesnadaACPClient) ReleaseTerminal(ctx context.Context, params acpsdk.ReleaseTerminalRequest) (acpsdk.ReleaseTerminalResponse, error)
ReleaseTerminal releases a terminal session without waiting for it to complete. The terminal continues running but we stop tracking it.
func (*MesnadaACPClient) RequestPermission ¶
func (c *MesnadaACPClient) RequestPermission(ctx context.Context, params acpsdk.RequestPermissionRequest) (acpsdk.RequestPermissionResponse, error)
RequestPermission handles permission requests from the ACP agent. In auto-permission mode (CI/batch), this auto-approves all requests. In manual mode, this queues the request for approval via API endpoints.
func (*MesnadaACPClient) SessionUpdate ¶
func (c *MesnadaACPClient) SessionUpdate(ctx context.Context, params acpsdk.SessionNotification) error
SessionUpdate handles session updates from the ACP agent. This is called when the agent sends new messages, tool calls, or state changes.
func (*MesnadaACPClient) SetAutoPermission ¶
func (c *MesnadaACPClient) SetAutoPermission(auto bool)
SetAutoPermission sets whether to auto-approve all permission requests.
func (*MesnadaACPClient) SetCapabilities ¶
func (c *MesnadaACPClient) SetCapabilities(caps ACPCapabilities)
SetCapabilities sets the capabilities for this client.
func (*MesnadaACPClient) TerminalOutput ¶
func (c *MesnadaACPClient) TerminalOutput(ctx context.Context, params acpsdk.TerminalOutputRequest) (acpsdk.TerminalOutputResponse, error)
TerminalOutput retrieves the current output from a terminal session.
func (*MesnadaACPClient) WaitForTerminalExit ¶
func (c *MesnadaACPClient) WaitForTerminalExit(ctx context.Context, params acpsdk.WaitForTerminalExitRequest) (acpsdk.WaitForTerminalExitResponse, error)
WaitForTerminalExit waits for a terminal session to complete and returns its exit code.
func (*MesnadaACPClient) WriteTextFile ¶
func (c *MesnadaACPClient) WriteTextFile(ctx context.Context, params acpsdk.WriteTextFileRequest) (acpsdk.WriteTextFileResponse, error)
WriteTextFile writes a file to the task's workspace. This implements strict security: the file must be within the task's workDir.
type PandoACPAgent ¶ added in v0.100.0
type PandoACPAgent struct {
// contains filtered or unexported fields
}
PandoACPAgent implements the ACP Agent interface. It allows external ACP clients to connect to Pando and use its capabilities.
func NewPandoACPAgent ¶ added in v0.100.0
func NewPandoACPAgent( version string, workDir string, logger *log.Logger, agentService AgentService, sessionService SessionService, permSvc PermissionService, ) *PandoACPAgent
NewPandoACPAgent creates a new ACP agent instance.
func (*PandoACPAgent) Authenticate ¶ added in v0.100.0
func (a *PandoACPAgent) Authenticate(ctx context.Context, req acpsdk.AuthenticateRequest) (acpsdk.AuthenticateResponse, error)
Authenticate handles authentication requests (not implemented yet).
func (*PandoACPAgent) Cancel ¶ added in v0.100.0
func (a *PandoACPAgent) Cancel(ctx context.Context, params acpsdk.CancelNotification) error
Cancel handles cancellation notifications.
func (*PandoACPAgent) GetCapabilities ¶ added in v0.100.0
func (a *PandoACPAgent) GetCapabilities() acpsdk.AgentCapabilities
GetCapabilities returns the agent capabilities.
func (*PandoACPAgent) GetVersion ¶ added in v0.100.0
func (a *PandoACPAgent) GetVersion() string
GetVersion returns the agent version.
func (*PandoACPAgent) Initialize ¶ added in v0.100.0
func (a *PandoACPAgent) Initialize(ctx context.Context, req acpsdk.InitializeRequest) (acpsdk.InitializeResponse, error)
Initialize handles the initialization handshake from an ACP client. This is the first method called when a client connects.
func (*PandoACPAgent) ListSessions ¶ added in v0.140.0
func (a *PandoACPAgent) ListSessions(ctx context.Context) ([]ACPSessionInfo, error)
ListSessions returns the historical sessions known by Pando. ACP v0.6.3 doesn't define a session/list request, so this helper is exposed for HTTP/API adapters that need to provide discovery endpoints.
func (*PandoACPAgent) LoadSession ¶ added in v0.100.0
func (a *PandoACPAgent) LoadSession(ctx context.Context, req acpsdk.LoadSessionRequest) (acpsdk.LoadSessionResponse, error)
LoadSession implements AgentLoader. It validates the requested session exists in Pando and registers an ACP session mapping so subsequent Prompt calls can find it.
func (*PandoACPAgent) NewSession ¶ added in v0.100.0
func (a *PandoACPAgent) NewSession(ctx context.Context, req acpsdk.NewSessionRequest) (acpsdk.NewSessionResponse, error)
NewSession handles new session creation requests.
func (*PandoACPAgent) Prompt ¶ added in v0.100.0
func (a *PandoACPAgent) Prompt(ctx context.Context, req acpsdk.PromptRequest) (acpsdk.PromptResponse, error)
Prompt handles prompt requests from the client.
func (*PandoACPAgent) SetConnection ¶ added in v0.100.0
func (a *PandoACPAgent) SetConnection(conn *acpsdk.AgentSideConnection)
SetConnection stores a reference to the AgentSideConnection so the agent can stream session updates back to the client. Called by transport_stdio.go immediately after NewAgentSideConnection() returns.
func (*PandoACPAgent) SetSessionMode ¶ added in v0.100.0
func (a *PandoACPAgent) SetSessionMode(ctx context.Context, req acpsdk.SetSessionModeRequest) (acpsdk.SetSessionModeResponse, error)
SetSessionMode handles session mode changes. The updated mode is applied when the next Prompt call begins.
func (*PandoACPAgent) SetSessionModel ¶ added in v0.100.0
func (a *PandoACPAgent) SetSessionModel(ctx context.Context, req acpsdk.SetSessionModelRequest) (acpsdk.SetSessionModelResponse, error)
SetSessionModel implements AgentExperimental. It stores the requested model on the ACP session for use in future prompts.
func (*PandoACPAgent) SetSessionPersona ¶ added in v0.204.0
func (a *PandoACPAgent) SetSessionPersona(ctx context.Context, sessionID acpsdk.SessionId, personaName string) error
SetSessionPersona stores the requested persona on the ACP session for use in future prompts. This is a Pando-specific extension, not part of the standard ACP protocol.
type PendingPermission ¶
type PendingPermission struct {
TaskID string `json:"task_id"`
SessionID acpsdk.SessionId `json:"session_id"`
RequestID string `json:"request_id"`
ToolCall acpsdk.RequestPermissionToolCall `json:"tool_call"`
Options []acpsdk.PermissionOption `json:"options"`
Outcome *acpsdk.RequestPermissionOutcome `json:"outcome,omitempty"` // nil = pending, non-nil = resolved
CreatedAt time.Time `json:"created_at"`
ResolvedAt *time.Time `json:"resolved_at,omitempty"`
// contains filtered or unexported fields
}
PendingPermission represents a permission request awaiting resolution.
type PermissionQueue ¶
type PermissionQueue struct {
// contains filtered or unexported fields
}
PermissionQueue manages permission requests from ACP agents. It queues requests that need manual approval and allows resolution via API endpoints or automatic policies.
func NewPermissionQueue ¶
func NewPermissionQueue() *PermissionQueue
NewPermissionQueue creates a new permission queue.
func (*PermissionQueue) CleanupResolved ¶
func (q *PermissionQueue) CleanupResolved(maxAge time.Duration) int
CleanupResolved removes resolved permission requests older than the specified duration.
func (*PermissionQueue) GetAllPending ¶
func (q *PermissionQueue) GetAllPending() []*PendingPermission
GetAllPending returns all pending permission requests across all tasks.
func (*PermissionQueue) GetPending ¶
func (q *PermissionQueue) GetPending(taskID string) []*PendingPermission
GetPending returns all pending permission requests for a task.
func (*PermissionQueue) GetPermission ¶
func (q *PermissionQueue) GetPermission(requestID string) (*PendingPermission, bool)
GetPermission returns a specific permission request by ID.
func (*PermissionQueue) QueuePermission ¶
func (q *PermissionQueue) QueuePermission(taskID string, sessionID acpsdk.SessionId, req acpsdk.RequestPermissionRequest) string
QueuePermission adds a permission request to the queue for manual approval. Returns the request ID that can be used to resolve it later.
func (*PermissionQueue) ResolvePermission ¶
func (q *PermissionQueue) ResolvePermission(requestID string, outcome acpsdk.RequestPermissionOutcome) error
ResolvePermission resolves a pending permission request. outcome contains the selected option or denial.
func (*PermissionQueue) WaitForResolution ¶
func (q *PermissionQueue) WaitForResolution(ctx context.Context, requestID string) (acpsdk.RequestPermissionOutcome, error)
WaitForResolution waits for a permission request to be resolved. Returns the outcome or an error if the context is cancelled. Uses a per-request channel (closed on resolution) instead of polling, so it wakes up instantly with zero CPU overhead while waiting.
type PermissionRequestData ¶ added in v0.200.0
type PermissionRequestData struct {
SessionID string
ToolName string
Description string
Action string
Path string
Params any
}
PermissionRequestData carries the full details of a tool permission request. This mirrors permission.CreatePermissionRequest but is defined here to avoid importing the permission package and breaking the tool→acp import graph.
type PermissionService ¶ added in v0.120.0
type PermissionService interface {
AutoApproveSession(sessionID string)
RemoveAutoApproveSession(sessionID string)
RegisterSessionHandler(sessionID string, handler func(req PermissionRequestData) bool)
UnregisterSessionHandler(sessionID string)
}
PermissionService is a minimal interface for configuring tool permissions per session. This avoids import cycles with the permission package.
type PersonaInfo ¶ added in v0.204.0
type PersonaInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
}
PersonaInfo describes a single available persona for ACP responses.
type SessionInfo ¶ added in v0.7.0
type SessionInfo struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
LastUsed time.Time `json:"last_used"`
IdleTime time.Duration `json:"idle_time"`
}
SessionInfo contains information about a specific session.
type SessionPersonaState ¶ added in v0.204.0
type SessionPersonaState struct {
AvailablePersonas []PersonaInfo `json:"availablePersonas"`
CurrentPersonaId string `json:"currentPersonaId"`
}
SessionPersonaState represents the persona selection state for a session, analogous to SessionModelState. It is carried via the _meta extension field in ACP responses since the ACP spec does not yet define a native persona type.
type SessionService ¶ added in v0.100.0
type SessionService interface {
CreateSession(ctx context.Context, title string) (string, error)
GetSession(ctx context.Context, id string) (ACPSessionInfo, error)
ListSessions(ctx context.Context) ([]ACPSessionInfo, error)
}
SessionService defines the minimal interface needed by the ACP agent. Using a narrow interface avoids the session→llm/tools→acp import cycle.
type SessionUpdateInfo ¶
type SessionUpdateInfo struct {
// TaskID is the mesnada task identifier
TaskID string
// MessageText is the text content from the agent (for text blocks)
MessageText string
// ToolCall contains information about tool calls made by the agent
ToolCall *ToolCallInfo
// Plan contains planning information from the agent
Plan string
// StopReason indicates why the agent stopped (if applicable)
StopReason string
// Error contains any error message
Error string
}
SessionUpdateInfo represents information about a session update from the ACP agent. This is used to communicate agent state changes to the mesnada orchestrator.
type SimpleACPAgent ¶ added in v0.7.0
type SimpleACPAgent struct {
// contains filtered or unexported fields
}
SimpleACPAgent is a minimal ACP agent for testing HTTP transport. This is used when the full PandoACPAgent is not available due to import cycles.
func NewSimpleACPAgent ¶ added in v0.7.0
func NewSimpleACPAgent(version string, logger *log.Logger) *SimpleACPAgent
NewSimpleACPAgent creates a simple ACP agent for testing.
func (*SimpleACPAgent) Authenticate ¶ added in v0.7.0
func (a *SimpleACPAgent) Authenticate(ctx context.Context, req acpsdk.AuthenticateRequest) (acpsdk.AuthenticateResponse, error)
Authenticate is not implemented.
func (*SimpleACPAgent) Cancel ¶ added in v0.7.0
func (a *SimpleACPAgent) Cancel(ctx context.Context, params acpsdk.CancelNotification) error
Cancel handles cancellation.
func (*SimpleACPAgent) GetCapabilities ¶ added in v0.7.0
func (a *SimpleACPAgent) GetCapabilities() acpsdk.AgentCapabilities
GetCapabilities returns the agent capabilities.
func (*SimpleACPAgent) GetVersion ¶ added in v0.7.0
func (a *SimpleACPAgent) GetVersion() string
GetVersion returns the agent version.
func (*SimpleACPAgent) Initialize ¶ added in v0.7.0
func (a *SimpleACPAgent) Initialize(ctx context.Context, req acpsdk.InitializeRequest) (acpsdk.InitializeResponse, error)
Initialize handles the initialization handshake.
func (*SimpleACPAgent) LoadSession ¶ added in v0.100.0
func (a *SimpleACPAgent) LoadSession(ctx context.Context, req acpsdk.LoadSessionRequest) (acpsdk.LoadSessionResponse, error)
LoadSession implements AgentLoader (stub).
func (*SimpleACPAgent) NewSession ¶ added in v0.7.0
func (a *SimpleACPAgent) NewSession(ctx context.Context, req acpsdk.NewSessionRequest) (acpsdk.NewSessionResponse, error)
NewSession is not implemented.
func (*SimpleACPAgent) Prompt ¶ added in v0.7.0
func (a *SimpleACPAgent) Prompt(ctx context.Context, req acpsdk.PromptRequest) (acpsdk.PromptResponse, error)
Prompt is not implemented.
func (*SimpleACPAgent) SetSessionMode ¶ added in v0.7.0
func (a *SimpleACPAgent) SetSessionMode(ctx context.Context, req acpsdk.SetSessionModeRequest) (acpsdk.SetSessionModeResponse, error)
SetSessionMode is not implemented.
func (*SimpleACPAgent) SetSessionModel ¶ added in v0.100.0
func (a *SimpleACPAgent) SetSessionModel(ctx context.Context, req acpsdk.SetSessionModelRequest) (acpsdk.SetSessionModelResponse, error)
SetSessionModel implements AgentExperimental (stub).
type StdioTransport ¶ added in v0.100.0
type StdioTransport struct {
// contains filtered or unexported fields
}
StdioTransport wraps the SDK's AgentSideConnection for stdio transport.
func NewStdioTransport ¶ added in v0.100.0
func NewStdioTransport(agent *PandoACPAgent, logger *log.Logger) *StdioTransport
NewStdioTransport creates a new stdio transport for the ACP agent. A thin interceptor layer sits between raw stdin and the SDK connection to handle protocol methods that the Go SDK v0.6.3 does not yet implement (e.g. "session/list", which the TypeScript SDK v0.14+ clients send).
type ToolCallInfo ¶
type ToolCallInfo struct {
// ID is the unique identifier for this tool call
ID string
// Name is the name of the tool being called
Name string
// Kind is the ACP tool kind used by clients for rendering
Kind string
// Arguments are the arguments passed to the tool
Arguments map[string]interface{}
// Locations references files or paths associated with the tool call
Locations []string
// Status is the status of the tool call: "started", "progress", "completed", "failed"
Status string
// Result is the result of the tool call (if completed)
Result string
// Title is the rendered title shown by ACP clients
Title string
// Content contains rich content blocks for the tool call (e.g. diffs, text)
Content []acpsdk.ToolCallContent
// Diffs contains extracted file modification diffs for quick access
Diffs map[string]string
// RawInput is the original input to the tool
RawInput interface{}
// RawOutput is the original output from the tool
RawOutput interface{}
}
ToolCallInfo represents information about a tool call from the ACP agent.
type TransportStats ¶ added in v0.7.0
type TransportStats struct {
ActiveSessions int `json:"active_sessions"`
TotalSessions int `json:"total_sessions"`
RequestsProcessed int `json:"requests_processed"`
MaxSessions int `json:"max_sessions"`
Uptime time.Duration `json:"uptime"`
IdleTimeout time.Duration `json:"idle_timeout"`
}
TransportStats holds statistics about the HTTP transport.