Documentation
¶
Overview ¶
Package acp provides types and utilities for working with the Agent Client Protocol.
Index ¶
- type ACPAgentConfig
- type ACPCapabilities
- type ACPSession
- type McpServerConfig
- type MesnadaACPClient
- func (c *MesnadaACPClient) CreateTerminal(ctx context.Context, params acpsdk.CreateTerminalRequest) (acpsdk.CreateTerminalResponse, error)
- 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 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 SessionUpdateInfo
- type ToolCallInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 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 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) 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 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"`
}
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.
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 ToolCallInfo ¶
type ToolCallInfo struct {
// Name is the name of the tool being called
Name string
// Arguments are the arguments passed to the tool
Arguments map[string]interface{}
// 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
}
ToolCallInfo represents information about a tool call from the ACP agent.