claudecode

package
v0.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2026 License: AGPL-3.0 Imports: 41 Imported by: 0

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

View Source
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.

View Source
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.

View Source
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) Commands

func (*Driver) Commands(_ context.Context, input external.PromptInput) ([]external.Command, error)

func (*Driver) Compact

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) Modes

func (*Driver) PlanMode

func (*Driver) Prompt

Prompt implements external.Driver: one CLI process serves one turn, resumed from the session id in runtime metadata.

func (*Driver) ReadCommand

func (*Driver) RequiredDependency

func (*Driver) RequiredDependency() string

RequiredDependency implements external.DependencyRequirer.

func (*Driver) RuntimeType

func (*Driver) RuntimeType() string

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) SetMode

func (*Driver) SetPlanMode

func (*Driver) SetPlanMode(_ context.Context, _ external.PromptInput, mode string) (external.ModeState, error)

func (*Driver) SetUserInputService

func (d *Driver) SetUserInputService(service userinput.FlowService)

Directories

Path Synopsis
Package claudecfg holds the Bot Agent configuration contract for the direct Claude Code runtime.
Package claudecfg holds the Bot Agent configuration contract for the direct Claude Code runtime.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL