|
| 1 | +# API Reference |
| 2 | + |
| 3 | +## Package `agent` |
| 4 | + |
| 5 | +### Interfaces |
| 6 | + |
| 7 | +#### `Agent` |
| 8 | +Core interface for all CLI agents. |
| 9 | + |
| 10 | +| Method | Signature | Description | |
| 11 | +|--------|-----------|-------------| |
| 12 | +| `ID` | `() string` | Unique instance identifier | |
| 13 | +| `Name` | `() string` | Agent type name | |
| 14 | +| `Start` | `(ctx context.Context) error` | Launch agent process | |
| 15 | +| `Stop` | `(ctx context.Context) error` | Graceful shutdown | |
| 16 | +| `IsRunning` | `() bool` | Process active status | |
| 17 | +| `Health` | `(ctx context.Context) HealthStatus` | Health check | |
| 18 | +| `Send` | `(ctx context.Context, prompt string) (Response, error)` | Send prompt, get response | |
| 19 | +| `SendStream` | `(ctx context.Context, prompt string) (<-chan StreamChunk, error)` | Streaming response | |
| 20 | +| `SendWithAttachments` | `(ctx context.Context, prompt string, attachments []Attachment) (Response, error)` | Send with files | |
| 21 | +| `OutputDir` | `() string` | Artifact output directory | |
| 22 | +| `Capabilities` | `() AgentCapabilities` | Agent capabilities | |
| 23 | +| `SupportsVision` | `() bool` | Vision support | |
| 24 | +| `ModelInfo` | `() ModelInfo` | Model information | |
| 25 | + |
| 26 | +#### `AgentPool` |
| 27 | +Thread-safe pool with capability matching. |
| 28 | + |
| 29 | +| Method | Signature | Description | |
| 30 | +|--------|-----------|-------------| |
| 31 | +| `Register` | `(agent Agent) error` | Add agent to pool | |
| 32 | +| `Acquire` | `(ctx context.Context, requirements AgentRequirements) (Agent, error)` | Get matching agent (blocks) | |
| 33 | +| `Release` | `(agent Agent)` | Return agent to pool | |
| 34 | +| `Available` | `() []Agent` | List available agents | |
| 35 | +| `HealthCheck` | `(ctx context.Context) []HealthStatus` | Check all agents | |
| 36 | +| `Shutdown` | `(ctx context.Context) error` | Stop all agents | |
| 37 | + |
| 38 | +### Types |
| 39 | + |
| 40 | +- `Response` - Parsed result from Send() |
| 41 | +- `StreamChunk` - Individual streaming chunk |
| 42 | +- `Attachment` - File attachment |
| 43 | +- `AgentCapabilities` - Agent feature flags |
| 44 | +- `AgentRequirements` - Caller requirements |
| 45 | +- `HealthStatus` - Health check result |
| 46 | +- `Action` - Structured action (click, type, scroll, etc.) |
| 47 | +- `ParsedResponse` - Fully parsed response |
| 48 | +- `Issue` - Detected problem |
| 49 | +- `ModelInfo` - LLM model information |
| 50 | + |
| 51 | +### Functions |
| 52 | + |
| 53 | +- `NewPool() AgentPool` - Create thread-safe agent pool |
| 54 | +- `NewCircuitBreaker() *CircuitBreaker` - Create circuit breaker (default config) |
| 55 | +- `NewCircuitBreakerWithConfig(threshold int, timeout time.Duration) *CircuitBreaker` - Custom config |
| 56 | +- `NewHealthMonitor() *HealthMonitor` - Create health monitor |
| 57 | + |
| 58 | +## Package `adapter` |
| 59 | + |
| 60 | +### Constructors |
| 61 | + |
| 62 | +| Function | Description | |
| 63 | +|----------|-------------| |
| 64 | +| `NewOpenCodeAgent(id string, config AdapterConfig) *OpenCodeAgent` | OpenCode adapter | |
| 65 | +| `NewClaudeCodeAgent(id string, config AdapterConfig) *ClaudeCodeAgent` | Claude Code adapter | |
| 66 | +| `NewGeminiAgent(id string, config AdapterConfig) *GeminiAgent` | Gemini adapter | |
| 67 | +| `NewJunieAgent(id string, config AdapterConfig) *JunieAgent` | Junie adapter | |
| 68 | +| `NewQwenCodeAgent(id string, config AdapterConfig) *QwenCodeAgent` | Qwen Code adapter | |
| 69 | +| `NewBaseAdapter(id, name string, config AdapterConfig, caps AgentCapabilities, modelInfo ModelInfo) *BaseAdapter` | Base adapter | |
| 70 | + |
| 71 | +### `AdapterConfig` |
| 72 | + |
| 73 | +```go |
| 74 | +type AdapterConfig struct { |
| 75 | + BinaryPath string |
| 76 | + Args []string |
| 77 | + Env []string |
| 78 | + WorkDir string |
| 79 | + OutputDir string |
| 80 | + Timeout time.Duration |
| 81 | + MaxRetries int |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +## Package `protocol` |
| 86 | + |
| 87 | +### `PipeTransport` |
| 88 | + |
| 89 | +| Method | Description | |
| 90 | +|--------|-------------| |
| 91 | +| `NewPipeTransport(reader io.Reader, writer io.Writer) *PipeTransport` | Create transport | |
| 92 | +| `Send(ctx, msg PipeMessage) error` | Write JSON-line | |
| 93 | +| `Receive(ctx) (PipeMessage, error)` | Read JSON-line | |
| 94 | +| `SendPrompt(ctx, requestID, content, imagePath string) error` | Convenience prompt | |
| 95 | +| `SendShutdown(ctx) error` | Send shutdown signal | |
| 96 | +| `Close() error` | Mark closed | |
| 97 | + |
| 98 | +### `FileTransport` |
| 99 | + |
| 100 | +| Method | Description | |
| 101 | +|--------|-------------| |
| 102 | +| `NewFileTransport(sessionDir string) (*FileTransport, error)` | Create with inbox/outbox/shared | |
| 103 | +| `WriteToInbox(msg FileMessage) error` | Write to inbox | |
| 104 | +| `WriteToOutbox(msg FileMessage) error` | Write to outbox | |
| 105 | +| `ReadFromInbox() ([]FileMessage, error)` | Read inbox messages | |
| 106 | +| `ReadFromOutbox() ([]FileMessage, error)` | Read outbox messages | |
| 107 | +| `WriteSharedFile(name string, data []byte) error` | Write shared artifact | |
| 108 | +| `ReadSharedFile(name string) ([]byte, error)` | Read shared artifact | |
| 109 | +| `Cleanup() error` | Remove session directory | |
| 110 | + |
| 111 | +## Package `parser` |
| 112 | + |
| 113 | +### `ResponseParser` Interface |
| 114 | + |
| 115 | +| Method | Description | |
| 116 | +|--------|-------------| |
| 117 | +| `Parse(raw string) (ParsedResponse, error)` | Full parse | |
| 118 | +| `ExtractJSON(raw string) (map[string]any, error)` | Extract JSON | |
| 119 | +| `ExtractActions(raw string) ([]Action, error)` | Extract actions | |
| 120 | +| `ExtractIssues(raw string) ([]Issue, error)` | Extract issues | |
| 121 | + |
| 122 | +### Functions |
| 123 | + |
| 124 | +- `NewParser() ResponseParser` - Create default parser |
| 125 | + |
| 126 | +## Package `config` |
| 127 | + |
| 128 | +### Functions |
| 129 | + |
| 130 | +| Function | Description | |
| 131 | +|----------|-------------| |
| 132 | +| `DefaultConfig() *Config` | Sane defaults | |
| 133 | +| `LoadFromEnv(path string) (*Config, error)` | Load from .env file | |
| 134 | +| `LoadFromEnvironment() *Config` | Load from OS env | |
| 135 | +| `MaskAPIKey(key string) string` | Mask key for logging | |
| 136 | + |
| 137 | +### `Config` Methods |
| 138 | + |
| 139 | +| Method | Description | |
| 140 | +|--------|-------------| |
| 141 | +| `AgentBinaryPath(name string) (string, error)` | Resolve binary path | |
| 142 | +| `IsAgentEnabled(name string) bool` | Check if enabled | |
| 143 | +| `SessionDir(sessionID string) string` | Get session directory | |
| 144 | +| `Validate() error` | Validate configuration | |
0 commit comments