runtime

package
v1.10.0 Latest Latest
Warning

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

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

Documentation

Overview

Package runtime defines the coding agent runtime abstraction layer.

It declares the Runtime type (claude-code, codex) with parsing and validation helpers, and the Adapter interface that each runtime backend implements to provide a uniform API for starting, stopping, sending messages, receiving structured events, creating/resuming sessions, and health checks — enabling the daemon to resume interrupted conversations seamlessly.

Plane: shared

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.

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.
	// Returns the session ID on success.
	ResumeSession(ctx context.Context, sessionID string) (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, Codex) implements this interface.

type AdapterConfig

type AdapterConfig struct {
	AgentName string
	WorkDir   string   // Agent workspace directory
	Model     string   // Model override
	Env       []string // Additional env vars (TTAL_AGENT_NAME, TASKRC, etc.)
}

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

	// Tool fields (for EventTool).
	ToolName string
}

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
	EventTool   EventType = "tool"   // Tool invocation detected
)

type Runtime

type Runtime string

Runtime identifies which coding agent backend to use.

const (
	ClaudeCode Runtime = "claude-code"
	Codex      Runtime = "codex"
)

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, "cx" for codex.

func (Runtime) IsWorkerRuntime

func (r Runtime) IsWorkerRuntime() bool

IsWorkerRuntime returns true if the runtime can be used for workers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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