Files
kandev/backend/internal/agent/api/requests.go
T
jcfs aebb0c0c76 Implement bidirectional ACP communication with agents
- Add ACP session manager for JSON-RPC 2.0 over stdin/stdout
- Create jsonrpc package with Client for bidirectional communication
- Update agent.sh to run auggie --acp mode
- Add Docker client methods for container stdin/stdout attachment
- Update lifecycle manager to use ACP instead of log streaming
- Add new API endpoints: POST /prompt, POST /cancel, GET /session
- Update AGENTS.md with ACP protocol documentation
- Update OpenAPI spec with new endpoints and schemas

This enables:
- Sending prompts to running agents
- Cancelling agent operations
- Session management (create, load, resume)
- Real-time progress updates via session/update notifications
2026-01-10 10:51:11 +00:00

108 lines
3.4 KiB
Go

// Package api provides HTTP handlers for the agent manager API.
package api
import "time"
// LaunchAgentRequest for launching an agent
type LaunchAgentRequest struct {
TaskID string `json:"task_id" binding:"required"`
AgentType string `json:"agent_type" binding:"required"`
WorkspacePath string `json:"workspace_path" binding:"required"`
Env map[string]string `json:"env,omitempty"`
Priority int `json:"priority"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
// StopAgentRequest for stopping an agent
type StopAgentRequest struct {
Force bool `json:"force"`
Reason string `json:"reason,omitempty"`
}
// AgentInstanceResponse for agent status
type AgentInstanceResponse struct {
ID string `json:"id"`
TaskID string `json:"task_id"`
AgentType string `json:"agent_type"`
ContainerID string `json:"container_id"`
Status string `json:"status"`
Progress int `json:"progress"`
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
ExitCode *int `json:"exit_code,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
// AgentTypeResponse for agent type listing
type AgentTypeResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Image string `json:"image"`
Capabilities []string `json:"capabilities"`
Enabled bool `json:"enabled"`
}
// AgentsListResponse for listing agents
type AgentsListResponse struct {
Agents []AgentInstanceResponse `json:"agents"`
Total int `json:"total"`
}
// AgentTypesListResponse for listing agent types
type AgentTypesListResponse struct {
Types []AgentTypeResponse `json:"types"`
Total int `json:"total"`
}
// LogEntry represents a single log entry
type LogEntry struct {
Timestamp time.Time `json:"timestamp"`
Message string `json:"message"`
Stream string `json:"stream"` // stdout or stderr
}
// LogsResponse for agent logs
type LogsResponse struct {
Logs []LogEntry `json:"logs"`
Total int `json:"total"`
}
// HealthResponse for health check
type HealthResponse struct {
Status string `json:"status"`
Timestamp time.Time `json:"timestamp"`
}
// SendPromptRequest for sending a prompt to an agent
type SendPromptRequest struct {
Message string `json:"message" binding:"required"`
}
// SendPromptResponse for prompt acknowledgment
type SendPromptResponse struct {
Success bool `json:"success"`
SessionID string `json:"session_id,omitempty"`
Message string `json:"message,omitempty"`
}
// CancelAgentRequest for cancelling agent operation
type CancelAgentRequest struct {
Reason string `json:"reason,omitempty"`
}
// CancelAgentResponse for cancel acknowledgment
type CancelAgentResponse struct {
Success bool `json:"success"`
Message string `json:"message,omitempty"`
}
// GetSessionResponse for getting session info
type GetSessionResponse struct {
InstanceID string `json:"instance_id"`
SessionID string `json:"session_id"`
Status string `json:"status"`
}