Documentation
¶
Overview ¶
Package bridge translates between the ACP client and an agentapi-compatible HTTP interface (compatible with takutakahashi/claude-agentapi).
Index ¶
- type ActionRequest
- type ActionType
- type AgentErrorData
- type AgentStatus
- type Bridge
- func (b *Bridge) GetMessages() []Message
- func (b *Bridge) GetPendingActions() PendingActionsResponse
- func (b *Bridge) GetStatus() StatusResponse
- func (b *Bridge) Run(ctx context.Context)
- func (b *Bridge) SendMessage(ctx context.Context, content string) error
- func (b *Bridge) StopAgent(ctx context.Context) error
- func (b *Bridge) SubmitAction(ctx context.Context, req ActionRequest) error
- func (b *Bridge) Subscribe() (<-chan Event, func())
- type Event
- type EventType
- type Message
- type MessageRole
- type MessageType
- type MessageUpdateData
- type PendingAction
- type PendingActionsResponse
- type Server
- type StatusChangeData
- type StatusResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionRequest ¶
type ActionRequest struct {
Type ActionType `json:"type"`
Answers map[string]string `json:"answers,omitempty"` // answer_question
Approved *bool `json:"approved,omitempty"` // approve_plan
}
ActionRequest is the body for POST /action.
type ActionType ¶
type ActionType string
ActionType names a pending action.
const ( ActionTypeAnswerQuestion ActionType = "answer_question" ActionTypeApprovePlan ActionType = "approve_plan" ActionTypeStopAgent ActionType = "stop_agent" )
type AgentErrorData ¶
type AgentErrorData struct {
Level string `json:"level"`
Message string `json:"message"`
Time time.Time `json:"time"`
}
AgentErrorData is the data for agent_error events.
type AgentStatus ¶
type AgentStatus string
AgentStatus mirrors coder/agentapi status values.
const ( AgentStatusRunning AgentStatus = "running" AgentStatusStable AgentStatus = "stable" )
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge holds all state for bridging an ACP client to the agentapi HTTP interface.
func (*Bridge) GetMessages ¶
GetMessages returns the current conversation history.
func (*Bridge) GetPendingActions ¶
func (b *Bridge) GetPendingActions() PendingActionsResponse
GetPendingActions returns the list of actions waiting for a user response.
func (*Bridge) GetStatus ¶
func (b *Bridge) GetStatus() StatusResponse
GetStatus returns the current agent status. AgentType is reported as "claude" so the frontend routes stop_agent via the /action endpoint (which the ACP bridge supports) rather than sending a raw Ctrl-C character (which the ACP bridge does not support).
func (*Bridge) Run ¶
Run starts the background goroutines that consume ACP notifications and feed the bridge state. Call this in a goroutine; it blocks until ctx is done. The ctx is stored as the server context for use in background operations (e.g., ACP Prompt calls that outlive the HTTP request that triggered them).
func (*Bridge) SendMessage ¶
SendMessage posts a user message to the ACP agent. It sets status to "running" immediately and returns; the status reverts to "stable" when the agent finishes (via a goroutine watching the Prompt call).
func (*Bridge) SubmitAction ¶
func (b *Bridge) SubmitAction(ctx context.Context, req ActionRequest) error
SubmitAction processes a user response to a pending action.
type Message ¶
type Message struct {
ID int64 `json:"id"`
Role MessageRole `json:"role"`
Content string `json:"content"`
Time time.Time `json:"time"`
Type MessageType `json:"type"`
ToolUseId string `json:"toolUseId,omitempty"`
ParentToolUseId string `json:"parentToolUseId,omitempty"`
Status string `json:"status,omitempty"` // "success"|"error"
Error string `json:"error,omitempty"` // present when status=="error"
}
Message is an agentapi-compatible message entry.
type MessageRole ¶
type MessageRole string
MessageRole mirrors takutakahashi/claude-agentapi message roles.
const ( MessageRoleUser MessageRole = "user" MessageRoleAssistant MessageRole = "assistant" MessageRoleAgent MessageRole = "agent" MessageRoleToolResult MessageRole = "tool_result" )
type MessageType ¶
type MessageType string
MessageType mirrors takutakahashi/claude-agentapi message types.
const ( MessageTypeNormal MessageType = "normal" MessageTypeQuestion MessageType = "question" MessageTypePlan MessageType = "plan" )
type MessageUpdateData ¶
type MessageUpdateData = Message
MessageUpdateData is the data for message_update events. It sends the full Message object (matching takutakahashi/claude-agentapi format). The content key is "content" (not "message") as expected by the frontend.
type PendingAction ¶
type PendingAction struct {
Type ActionType `json:"type"`
ToolUseId string `json:"tool_use_id,omitempty"`
Content interface{} `json:"content,omitempty"`
}
PendingAction is an action waiting for the HTTP client to respond.
type PendingActionsResponse ¶
type PendingActionsResponse struct {
PendingActions []PendingAction `json:"pending_actions"`
}
PendingActionsResponse is the body for GET /action.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an agentapi-compatible HTTP server backed by a Bridge. It exposes the following endpoints (compatible with takutakahashi/claude-agentapi):
GET /health GET /status GET /messages POST /message GET /events (SSE) GET /action POST /action
type StatusChangeData ¶
type StatusChangeData struct {
Status AgentStatus `json:"status"`
AgentType string `json:"agent_type"`
}
StatusChangeData is the data for status_change events.
type StatusResponse ¶
type StatusResponse struct {
AgentType string `json:"agent_type"`
Status AgentStatus `json:"status"`
Transport string `json:"transport"`
}
StatusResponse mirrors coder/agentapi /status response.