runtime

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatSkillInvocation

func FormatSkillInvocation(rt Runtime, skillName string) string

FormatSkillInvocation returns the skill invocation string for the given runtime. Examples:

CC:    "/triage"
OC:    "/triage"
Codex: "$triage"

func FormatSkillMessage

func FormatSkillMessage(rt Runtime, skillName, message string) string

FormatSkillMessage prepends the runtime-appropriate skill invocation to the message.

func Validate

func Validate(s string) error

Validate checks that a string is a valid runtime value.

func Values

func Values() []string

Values returns all valid runtime strings (for ent schema enum).

Types

type Adapter

type Adapter interface {
	// Start launches the runtime process and establishes connection.
	Start(ctx context.Context) error

	// Stop gracefully shuts down the runtime.
	Stop(ctx context.Context) error

	// SendMessage delivers text to the agent.
	SendMessage(ctx context.Context, text string) error

	// Events returns a channel that receives agent output events.
	// Channel is closed when the adapter stops or the context is cancelled.
	Events() <-chan Event

	// CreateSession starts a new conversation. Returns session ID.
	CreateSession(ctx context.Context) (string, error)

	// ResumeSession resumes an existing conversation by ID.
	ResumeSession(ctx context.Context, sessionID string) error

	// IsHealthy returns true if the runtime is responsive.
	IsHealthy(ctx context.Context) bool

	// Runtime returns the runtime type.
	Runtime() Runtime
}

Adapter abstracts the transport for communicating with a coding agent runtime. Each runtime (CC, OpenCode, Codex) implements this interface.

type AdapterConfig

type AdapterConfig struct {
	AgentName  string
	WorkDir    string   // Agent workspace directory
	Port       int      // API server port (0 = not applicable for CC)
	Model      string   // Model override
	Yolo       bool     // Skip permission prompts
	Env        []string // Additional env vars (TTAL_AGENT_NAME, TTAL_TEAM, etc.)
	GatewayURL string   // OpenClaw Gateway URL (for openclaw runtime)
	HooksToken string   // OpenClaw hooks auth token (for openclaw runtime)
}

AdapterConfig holds common configuration for all adapters.

type Event

type Event struct {
	Type  EventType
	Agent string
	Text  string // assistant output text (for EventText/EventError)

	// Status fields (for EventStatus).
	ContextUsedPct      float64
	ContextRemainingPct float64
	ModelID             string
	SessionID           string

	// Question fields (for EventQuestion).
	CorrelationID string     // tool_use_id / requestID / call_id
	Questions     []Question // 1-4 questions per event
}

Event represents an output event from any runtime.

type EventType

type EventType string

EventType classifies runtime events.

const (
	EventText     EventType = "text"     // Assistant text output → bridge to Telegram
	EventStatus   EventType = "status"   // Context/model status update
	EventError    EventType = "error"    // Runtime error
	EventIdle     EventType = "idle"     // Agent finished processing, waiting for input
	EventQuestion EventType = "question" // Agent needs human input
)

type Question

type Question struct {
	ID          string           // Per-question ID (empty for CC, Codex uses for answer mapping)
	Header      string           // Short label (e.g. "Database", "Approach")
	Text        string           // Full question text
	Options     []QuestionOption // Available choices
	MultiSelect bool             // Allow multiple selections
	AllowCustom bool             // Allow free-form text input
	IsSecret    bool             // Mask input (Codex only)
}

Question represents a single question from any runtime, normalized to a common format.

type QuestionAnswer

type QuestionAnswer struct {
	QuestionID string
	Answer     string
}

QuestionAnswer pairs a question ID with the user's answer (used for Codex response routing).

type QuestionOption

type QuestionOption struct {
	Label       string
	Description string
}

QuestionOption is one selectable choice for a Question.

type Runtime

type Runtime string

Runtime identifies which coding agent backend to use.

const (
	ClaudeCode Runtime = "claude-code"
	OpenCode   Runtime = "opencode"
	Codex      Runtime = "codex"
	OpenClaw   Runtime = "openclaw"
)

func All

func All() []Runtime

All returns all valid runtime values.

func Parse

func Parse(s string) (Runtime, error)

Parse converts a string to a Runtime, defaulting to ClaudeCode. Accepts aliases: "cc" for claude-code, "oc" for opencode.

func (Runtime) IsWorkerRuntime

func (r Runtime) IsWorkerRuntime() bool

IsWorkerRuntime returns true if the runtime can be used for workers. OpenClaw is agent-only — workers always use CC/OC/Codex.

func (Runtime) NeedsPort

func (r Runtime) NeedsPort() bool

NeedsPort returns true if the runtime requires an explicit port for its HTTP server. OpenCode and Codex run HTTP serve processes; CC and OpenClaw do not.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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