harness

package
v0.6.76 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0, Apache-2.0, MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package harness builds the launch configuration for each agent harness (DBX-46, DBX-57): the ACP command, environment pointing model traffic at the console AI proxy with a placeholder key (or at the owner's plan), CA trust, home instruction files and the per-harness model boot flags used when an adapter has no ACP model control. Models are set over ACP; config files only get the defaults and model lists harnesses can't take any other way (Claude's availableModels, Codex's provider, catalog and default model).

Index

Constants

View Source
const ClaudeOAuthPlaceholder = "sk-ant-oat01-plural-devbox-placeholder"

ClaudeOAuthPlaceholder has the real `sk-ant-oat01-` prefix, so Claude Code accepts it; egress swaps in the owner's token for api.anthropic.com (section 4.11).

View Source
const PlaceholderKey = "plural-devbox-placeholder"

PlaceholderKey is the API key harnesses send; atenet-egress replaces the auth header with the instance's AI proxy token, so the real token never enters the sandbox.

Variables

AllAgents lists the supported harnesses.

Functions

func AgentName

func AgentName(t devboxv1.AgentType) string

AgentName is the lowercase name used in image.json and CRDs.

func Binary

func Binary(t devboxv1.AgentType) string

Binary returns the harness CLI for an agent (claude, codex, ...).

func EnvValue

func EnvValue(env []string, k string) (string, bool)

EnvValue returns the value of k in env.

func ModelIDs

func ModelIDs(t devboxv1.AgentType, model string) []string

ModelIDs are the IDs an agent's picker may list a console model under, most specific first: the ID itself, a bare model under the agent's proxy provider, the `plural/` provider OpenCode and Pi register the proxy models under, and Gemini CLI's bare names.

func ParseAgent

func ParseAgent(s string) (devboxv1.AgentType, bool)

ParseAgent parses an agent name ("claude", "AGENT_TYPE_CLAUDE").

func ProxyModel

func ProxyModel(t devboxv1.AgentType, model string) string

ProxyModel prefixes a bare model with the AI proxy provider, as the agent-run harness does.

Types

type Command

type Command struct {
	Path string
	Args []string
	Env  []string
}

Command overrides an agent's ACP command (tests and custom images).

type Config

type Config struct {
	Home string
	// StateDir is ~/.plural; daemon-managed harness config lives under StateDir/harness.
	StateDir string
	Image    *ImageInfo
	// AgentAuthDir is the tmpfs for subscription credentials (/run/plural/agent-auth).
	AgentAuthDir string
	// BaseEnv returns the environment every child process gets (CA trust, identity, PATH, ...).
	BaseEnv func() []string
	// Overrides replace the ACP command per agent.
	Overrides map[devboxv1.AgentType]Command
	// CodexBundledModels returns Codex's bundled model catalog; it defaults to `codex debug models --bundled`.
	CodexBundledModels func() ([]byte, error)
	// PiSubagentExtension overrides where pi's subagent extension is (PiSubagentDir).
	PiSubagentExtension string
}

Config is the harness configuration shared by every agent.

func (*Config) AdapterVersion

func (c *Config) AdapterVersion(t devboxv1.AgentType) string

AdapterVersion is the pinned adapter version from image.json, if known.

func (*Config) CodexAuthDir

func (c *Config) CodexAuthDir() string

CodexAuthDir is the tmpfs CODEX_HOME holding auth.json for subscription billing.

func (*Config) CodexHome

func (c *Config) CodexHome() string

CodexHome is where Codex keeps its state (sessions, config) on the workspace volume.

func (*Config) Headless

func (c *Config) Headless(t devboxv1.AgentType, prompt, lastMessage string) (path string, args, env []string, err error)

Headless is the command line for a one-off, non-interactive prompt to a subscription agent's CLI, run with the credentials its ACP process gets. The CLI may read the working directory but not change it. lastMessage is a file Codex writes its final answer to; Claude prints a JSON result instead.

func (c *Config) InstructionLinks() map[string]string

InstructionLinks are each harness's global instruction file, symlinked to ~/AGENTS.md so the devbox conventions apply whatever the session's cwd.

func (*Config) LinkInstructions

func (c *Config) LinkInstructions() error

LinkInstructions creates the global instruction symlinks that don't exist yet.

func (*Config) PiSubagentDir

func (c *Config) PiSubagentDir() string

PiSubagentDir is the image's copy of pi's subagent extension, under the global node_modules.

func (*Config) Present

func (c *Config) Present(t devboxv1.AgentType) (string, bool)

Present reports whether the agent's ACP command is on PATH.

func (*Config) Spec

func (c *Config) Spec(launch *devboxv1.AgentLaunch, endpoints *devboxv1.HarnessEndpoints, bootModel string) (*Spec, error)

Spec builds the launch spec for one agent connection.

type ImageAgent

type ImageAgent struct {
	Command string `json:"command"`
	Version string `json:"version"`
	ACP     struct {
		Command string   `json:"command"`
		Args    []string `json:"args"`
		Version string   `json:"version"`
	} `json:"acp"`
}

ImageAgent is one agent entry in /etc/devbox/image.json, written by the devbox image build (DBX-49).

type ImageInfo

type ImageInfo struct {
	Contract      string                `json:"contract"`
	Flavor        string                `json:"flavor"`
	DaemonVersion string                `json:"daemonVersion"`
	PlaywrightMCP string                `json:"playwrightMcp"`
	Agents        map[string]ImageAgent `json:"agents"`
}

ImageInfo is /etc/devbox/image.json.

func LoadImageInfo

func LoadImageInfo(path string) (*ImageInfo, error)

LoadImageInfo reads the image description. A missing file yields built-in defaults.

type OpenCodeServer

type OpenCodeServer struct {
	URL      string
	Username string
	Password string
}

OpenCodeServer is where `opencode acp` serves OpenCode's own API, and its basic-auth credentials.

type Spec

type Spec struct {
	Agent   devboxv1.AgentType
	Path    string
	Args    []string
	Env     []string
	Dir     string
	Lineage acp.LineageExtractor
	// RequestV2 asks for protocol version 2 at initialize (acpV2 flag and adapter support).
	RequestV2 bool
	// NativeSubagents advertises the subagents client capability at initialize.
	NativeSubagents bool
	// TranscriptTool is a tool whose output streams its subagents' transcripts (acp.TranscriptTool).
	TranscriptTool string
	// BootModel is the model passed through flags/env, for adapters without ACP model control.
	BootModel string
	Billing   devboxv1.BillingMode
	// AuthMethodID, when set, is sent with `authenticate` after initialize.
	AuthMethodID string
	// OpenCodeServer is the HTTP server `opencode acp` runs its sessions on, whose event stream names the child
	// sessions of `task` subagents.
	OpenCodeServer *OpenCodeServer
}

Spec is everything needed to start one agent's ACP process.

Jump to

Keyboard shortcuts

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