driver

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package driver defines the TermmuxDriverAdapter interface and canonical conversation types for bidirectional session log conversion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConversationEntry

type ConversationEntry struct {
	Timestamp time.Time        `json:"timestamp"`
	Role      ConversationRole `json:"role"`
	Content   string           `json:"content"`
	ToolCall  *ToolCallRecord  `json:"tool_call,omitempty"`
	Thinking  *ThinkingBlock   `json:"thinking,omitempty"`
	Usage     *TokenUsage      `json:"usage,omitempty"`
}

ConversationEntry is the canonical conversation format for session log round-tripping between the runtime and driver-native formats.

type ConversationRole

type ConversationRole string

ConversationRole identifies the role of a conversation entry.

const (
	RoleUser       ConversationRole = "user"
	RoleAssistant  ConversationRole = "assistant"
	RoleToolUse    ConversationRole = "tool_use"
	RoleToolResult ConversationRole = "tool_result"
)

type LaunchConfig

type LaunchConfig struct {
	OtelEndpoint string
	ExtraEnv     map[string]string
}

LaunchConfig is the result of PrepareForLaunch.

type TermmuxDriverAdapter

type TermmuxDriverAdapter interface {
	// Identity
	Name() string
	Command() string

	// Launch configuration
	BuildCommandArgs(prependArgs, extraArgs []string) []string
	BuildCommandEnvVars(runtimeDir string) map[string]string
	PrepareForLaunch(dryRun bool) (LaunchConfig, error)

	// Capabilities
	SupportsHooks() bool
	SupportsResume() bool
	NativeSessionLogPath(configDir, cwd, sessionID string) string

	// Session log conversion
	ParseSessionLog(reader io.Reader) ([]ConversationEntry, error)
	WriteSessionLog(entries []ConversationEntry, writer io.Writer) error

	// Lifecycle
	Start(ctx context.Context, events chan<- monitor.AgentEvent) error
	HandleHookEvent(eventName string, payload json.RawMessage) bool
	HandleInterrupt() bool
	Stop()
}

TermmuxDriverAdapter abstracts a 3rd party agent CLI for termmux session control. Name intentionally differs from internal/agent.AgentDriver to avoid ambiguity.

type ThinkingBlock

type ThinkingBlock struct {
	Content string `json:"content"`
}

ThinkingBlock holds extended thinking content.

type TokenUsage

type TokenUsage struct {
	InputTokens  int64 `json:"input_tokens"`
	OutputTokens int64 `json:"output_tokens"`
	CachedTokens int64 `json:"cached_tokens,omitempty"`
}

TokenUsage holds token usage metrics.

type ToolCallRecord

type ToolCallRecord struct {
	Name   string          `json:"name"`
	Args   json.RawMessage `json:"args"`
	Result string          `json:"result,omitempty"`
	CallID string          `json:"call_id"`
}

ToolCallRecord holds tool invocation details.

Directories

Path Synopsis
Package claudecode implements the TermmuxDriverAdapter for Claude Code CLI.
Package claudecode implements the TermmuxDriverAdapter for Claude Code CLI.
Package codex implements the TermmuxDriverAdapter for the Codex CLI.
Package codex implements the TermmuxDriverAdapter for the Codex CLI.

Jump to

Keyboard shortcuts

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