claudecode

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0 Imports: 36 Imported by: 0

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

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

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

func (*Driver) Caps() external.Caps

Caps implements external.Driver.

func (*Driver) Commands

func (d *Driver) Commands(ctx 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. 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) RuntimeType

func (*Driver) RuntimeType() string

RuntimeType implements external.Driver.

func (*Driver) SetMode

func (*Driver) SetPlanMode

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

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