Documentation
¶
Overview ¶
Package claudecode implements the direct Claude Code runtime driver: it drives a Claude Code CLI inside the bot workspace over the stream-json wire protocol (NDJSON stdio plus the bidirectional control channel), with no ACP adapter and no Node sidecar in between.
The wire contract is checked against @anthropic-ai/claude-agent-sdk 0.3.316 and CLI 2.1.316. Only the protocol surface used by this driver is modeled; optional fields and unconsumed events do not require version-specific adapters. Unsupported inbound control requests receive an error response.
One process serves a conversation's turns one after another and stays between them until it idles out; it resumes the durable native session when it starts. Steering may start several native turns within one Memoh run. Token usage belongs to each native result and is summed across distinct result UUIDs.
Memoh tool-gateway injection for Claude Code. Each CLI process gets its own reverse-HTTP route into the workspace tools proxy via --mcp-config; the route lives exactly as long as the process.
Index ¶
- Constants
- Variables
- type ApprovalService
- type Driver
- func (*Driver) Caps() external.Caps
- func (d *Driver) Commands(ctx context.Context, input external.PromptInput) ([]external.Command, error)
- func (d *Driver) Compact(ctx context.Context, input external.PromptInput) (external.CompactionResult, error)
- func (d *Driver) ModelCatalog(ctx context.Context, request external.ModelCatalogRequest) (external.ModelCatalog, error)
- func (d *Driver) Modes(ctx context.Context, input external.PromptInput) (external.ModeState, error)
- func (*Driver) PlanMode(_ context.Context, input external.PromptInput) (external.ModeState, error)
- func (d *Driver) Prompt(ctx context.Context, input external.PromptInput) (external.PromptResult, error)
- func (*Driver) ReadCommand(_ context.Context, input external.PromptInput) (external.CommandResult, error)
- func (*Driver) RuntimeType() string
- func (*Driver) SetMode(_ context.Context, _ external.PromptInput, mode string) (external.ModeState, error)
- func (*Driver) SetPlanMode(_ context.Context, _ external.PromptInput, mode string) (external.ModeState, error)
Constants ¶
const MemohToolTimeoutMillis = 900_000
MemohToolTimeoutMillis caps one Memoh gateway tool call on the claude side (milliseconds, per the pinned SDK contract). Memoh tools can legitimately block on a human decision (approval cards, ask_user) for up to their wait windows; the toolmount timeout-ladder guard test pins this above them.
const PinnedCLIVersion = "2.1.316"
PinnedCLIVersion is the CLI version this driver was last run against. A different installed version logs a warning. The workspace dependency manager owns CLI installation; changing this baseline does not install it.
const ( // RuntimeType is the thread runtime type this driver serves. RuntimeType = string(runtimekind.ClaudeCode) )
Variables ¶
var Capabilities = external.Caps{ Dependency: dependencyID, Command: "claude", ForkNeedsRuntime: true, }
Capabilities is what Claude Code declares (external.Caps).
Functions ¶
This section is empty.
Types ¶
type ApprovalService ¶
type ApprovalService interface {
approval.FlowService
RegisterWaiter(approvalID string) func()
}
ApprovalService is the decision flow the driver routes approvals through.
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver runs Claude Code turns over the stream-json wire protocol.
func NewDriver ¶
func NewDriver( workspaces external.Workspaces, agents *botagents.Service, credentials *agentcredential.Service, approvalSvc ApprovalService, userInput userinput.FlowService, toolGateway toolmount.Gateway, launchers external.LauncherResolver, procs *agentproc.Supervisor, logger *slog.Logger, ) *Driver
NewDriver constructs the Claude Code runtime driver.
func (*Driver) Compact ¶
func (d *Driver) Compact(ctx context.Context, input external.PromptInput) (external.CompactionResult, error)
func (*Driver) ModelCatalog ¶
func (d *Driver) ModelCatalog(ctx context.Context, request external.ModelCatalogRequest) (external.ModelCatalog, error)
ModelCatalog returns the model vocabulary advertised by Claude Code's control-channel initialize response under this Agent's actual configuration.
func (*Driver) Prompt ¶
func (d *Driver) Prompt(ctx context.Context, input external.PromptInput) (external.PromptResult, error)
Prompt implements external.Driver. The conversation's CLI process stays between turns and serves this one; a process holding another native session, or none to resume, is replaced first.
func (*Driver) ReadCommand ¶
func (*Driver) ReadCommand(_ context.Context, input external.PromptInput) (external.CommandResult, error)
func (*Driver) RuntimeType ¶
RuntimeType implements external.Driver.