agent

package
v0.0.0-...-89936ef Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ProxyPort = 2376
View Source
const SkillName = "clampdown"

SkillName is the directory name for the clampdown skill.

Variables

View Source
var Home = os.Getenv("HOME")

Home is the user's home directory, resolved once at startup.

Functions

func Available

func Available() []string

Available returns registered agent names.

func EnsureClaudeOnboarding

func EnsureClaudeOnboarding(homeDir string)

EnsureClaudeOnboarding makes sure .claude.json has hasCompletedOnboarding: true. Reads existing file if present, sets the key if missing, writes back.

func PrepareCodexHome

func PrepareCodexHome(homeDir string, route *ProxyRoute) error

PrepareCodexHome seeds the Codex auth/config files inside the agent's persistent HOME directory. In subscription mode the host's ~/.codex/auth.json is copied in once per session (or refreshed when newer), never bind-mounted. The source path is fixed — not configurable — to eliminate a project-.clampdownrc exfiltration primitive.

func SandboxPrompt

func SandboxPrompt(agentName string) string

SandboxPrompt returns the common sandbox instructions with the agent name substituted into agent-specific paths.

func SandboxSkill

func SandboxSkill(agentName string) string

SandboxSkill returns the skill content with agent name substituted.

func SkillDirs

func SkillDirs() []string

SkillDirs returns the directories where skills should be written. Both .claude/skills/ (Claude Code) and .agents/skills/ (cross-platform).

Types

type Agent

type Agent interface {
	Name() string
	Image() string
	EgressDomains() []string
	Mounts() []Mount
	ConfigOverlays() []Mount
	Env() map[string]string
	Args(passthrough []string) []string
	PromptFile() string
	ProxyRoutes() []ProxyRoute
	ProxyEnvOverride(routes []ProxyRoute) map[string]string
}

Agent describes an AI tool that runs inside the sandbox.

func Get

func Get(name string) (Agent, error)

Get returns the agent registered under name.

type Claude

type Claude struct{}

Claude implements Agent for the Claude Code CLI.

func (*Claude) Args

func (c *Claude) Args(passthrough []string) []string

func (*Claude) ConfigOverlays

func (c *Claude) ConfigOverlays() []Mount

func (*Claude) EgressDomains

func (c *Claude) EgressDomains() []string

func (*Claude) Env

func (c *Claude) Env() map[string]string

func (*Claude) Image

func (c *Claude) Image() string

func (*Claude) Mounts

func (c *Claude) Mounts() []Mount

func (*Claude) Name

func (c *Claude) Name() string

func (*Claude) PromptFile

func (c *Claude) PromptFile() string

func (*Claude) ProxyEnvOverride

func (c *Claude) ProxyEnvOverride(_ []ProxyRoute) map[string]string

func (*Claude) ProxyRoutes

func (c *Claude) ProxyRoutes() []ProxyRoute

type Codex

type Codex struct{}

Codex implements Agent for the OpenAI Codex CLI.

func (*Codex) Args

func (c *Codex) Args(passthrough []string) []string

func (*Codex) ConfigOverlays

func (c *Codex) ConfigOverlays() []Mount

func (*Codex) EgressDomains

func (c *Codex) EgressDomains() []string

func (*Codex) Env

func (c *Codex) Env() map[string]string

func (*Codex) Image

func (c *Codex) Image() string

func (*Codex) Mounts

func (c *Codex) Mounts() []Mount

func (*Codex) Name

func (c *Codex) Name() string

func (*Codex) PromptFile

func (c *Codex) PromptFile() string

func (*Codex) ProxyEnvOverride

func (c *Codex) ProxyEnvOverride(_ []ProxyRoute) map[string]string

func (*Codex) ProxyRoutes

func (c *Codex) ProxyRoutes() []ProxyRoute

type MaskedPath

type MaskedPath struct {
	Path  string
	IsDir bool
}

MaskedPath is a workdir-relative path whose content is hidden from the agent. Files are replaced with /dev/null; directories with empty read-only tmpfs. Unlike ProtectedPath (which preserves content as read-only), masked paths show the path exists but reads return nothing.

type Mount

type Mount struct {
	Src string
	Dst string
	RW  bool
}

Mount describes a bind mount from host to container.

type OpenCode

type OpenCode struct{}

OpenCode implements Agent for the OpenCode CLI (anomalyco/opencode).

func (*OpenCode) Args

func (o *OpenCode) Args(passthrough []string) []string

func (*OpenCode) ConfigOverlays

func (o *OpenCode) ConfigOverlays() []Mount

func (*OpenCode) EgressDomains

func (o *OpenCode) EgressDomains() []string

func (*OpenCode) Env

func (o *OpenCode) Env() map[string]string

Env redirects TMPDIR because Bun-compiled binaries extract and dlopen native .so files at startup. Default /tmp is mounted noexec, causing a silent hang.

func (*OpenCode) Image

func (o *OpenCode) Image() string

func (*OpenCode) Mounts

func (o *OpenCode) Mounts() []Mount

func (*OpenCode) Name

func (o *OpenCode) Name() string

func (*OpenCode) PromptFile

func (o *OpenCode) PromptFile() string

PromptFile returns ~/.config/opencode/AGENTS.md — OpenCode auto-discovers AGENTS.md from ~/.config/opencode/ as global rules.

func (*OpenCode) ProxyEnvOverride

func (o *OpenCode) ProxyEnvOverride(routes []ProxyRoute) map[string]string

ProxyEnvOverride builds OPENCODE_CONFIG_CONTENT for providers whose SDK doesn't read a *_BASE_URL env var. The JSON is deep-merged by OpenCode at highest precedence — no clobbering of user config.

func (*OpenCode) ProxyRoutes

func (o *OpenCode) ProxyRoutes() []ProxyRoute

ProxyRoutes returns upstream API routes for all supported providers.

type ProtectedPath

type ProtectedPath struct {
	Path       string
	IsDir      bool
	GlobalPath bool // false = workdir-relative (default), true = HOME-relative
}

ProtectedPath is a path that must be read-only inside the agent container. GlobalPath paths are resolved against the agent's persistent HOME directory; workdir-relative paths (GlobalPath: false, the default) are resolved against the working directory.

type ProxyRoute

type ProxyRoute struct {
	Port           uint16
	Upstream       string
	KeyEnv         string
	KeyEnvFallback string
	HeaderName     string
	HeaderPrefix   string
	BaseURLEnv     string
	ProviderID     string
	OAuth          bool
}

ProxyRoute describes a single upstream API that the auth proxy handles.

Jump to

Keyboard shortcuts

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