Documentation
¶
Overview ¶
Database checkpointing for Claude Code sessions. The CLI keeps its durable session transcript under CLAUDE_CONFIG_DIR/projects on the bot volume; staging a copy into the generalized runtime session store lets a session survive the volume being reset or the bot moving hosts. Capture streams the transcript twice (shape pass, record pass) so no whole-file allocation is ever held, and the store's validators arbitrate divergence.
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.269 and CLI 2.1.269 (see protocolref/VERSION.json). 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 one Memoh run and resumes its durable native session. Steering may start several native turns before stdin closes. Token usage belongs to each native result and is summed across distinct result UUIDs.
Memoh tool-gateway injection for Claude Code turns. Each turn's CLI process gets its own reverse-HTTP route into the workspace tools proxy via --mcp-config; the route lives exactly as long as the turn.
Index ¶
- Constants
- type ApprovalService
- type BridgeSource
- type Driver
- func (*Driver) Commands(_ 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) RequiredDependency() string
- func (*Driver) RuntimeType() string
- func (d *Driver) SetLauncherResolver(resolver external.LauncherResolver)
- func (*Driver) SetMode(_ context.Context, _ external.PromptInput, mode string) (external.ModeState, error)
- func (*Driver) SetPlanMode(_ context.Context, _ external.PromptInput, mode string) (external.ModeState, error)
- func (d *Driver) SetUserInputService(service userinput.FlowService)
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.269"
PinnedCLIVersion is the CLI version verified by the protocol fixtures. 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 ¶
This section is empty.
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 BridgeSource ¶
type BridgeSource interface {
MCPClient(ctx context.Context, botID string) (*bridge.Client, error)
WorkspaceInfo(ctx context.Context, botID string) (bridge.WorkspaceInfo, error)
}
BridgeSource resolves the workspace bridge client for a bot.
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( bridges BridgeSource, agents *botagents.Service, credentials *agentcredential.Service, approvalSvc ApprovalService, stateStore agentstate.SessionStateStore, toolGateway toolmount.Gateway, 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: one CLI process serves one turn, resumed from the session id in runtime metadata.
func (*Driver) ReadCommand ¶
func (*Driver) ReadCommand(_ context.Context, input external.PromptInput) (external.CommandResult, error)
func (*Driver) RequiredDependency ¶
RequiredDependency implements external.DependencyRequirer.
func (*Driver) RuntimeType ¶
RuntimeType implements external.Driver.
func (*Driver) SetLauncherResolver ¶
func (d *Driver) SetLauncherResolver(resolver external.LauncherResolver)
SetLauncherResolver installs the resolver that picks which CLI copy a turn executes. Without one the driver runs the toolkit launcher unconditionally. Call it during assembly, before the driver serves turns.
func (*Driver) SetPlanMode ¶
func (*Driver) SetUserInputService ¶
func (d *Driver) SetUserInputService(service userinput.FlowService)