adapter

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 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 adapter knows how to launch each supported agent with conch's integration wired in.

Index

Constants

View Source
const (
	TierSupported = proto.TierSupported
	TierRunsHere  = proto.TierRunsHere
)

Two tiers of agent, said plainly rather than implied.

Supported is the contract AGENTS.md sets: an adapter written here, detection rules read off the real agent, sessions that list, resume and delete, a setup inspector, labels and docs. Five agents meet it, and writing fifteen more to that bar stalls on session formats nobody documents.

Runs here is a manifest anybody can drop in: conch starts the agent, detects it in a pane and gives it a first message. What it does not claim, it says — sessions and the setup view answer "not read for this agent" rather than pretending to read a format nobody has written down. That honesty is the point of having a tier at all: the wider catalogs *detect* an agent, and conch is not going to say it supports one it cannot resume. The tiers themselves live in the protocol, which is where a client reads them from; these are the names this package uses for them.

Variables

View Source
var ClaudeHookEvents = []string{
	"SessionStart", "SessionEnd",
	"UserPromptSubmit", "PreToolUse", "PostToolUse", "PostToolUseFailure",
	"PermissionRequest", "PermissionDenied", "Notification",
	"SubagentStart", "SubagentStop", "PreCompact",
	"Stop", "StopFailure",
}

ClaudeHookEvents are the Claude Code hook events conch listens to.

View Source
var CodexHookEvents = []string{
	"SessionStart", "SessionEnd", "UserPromptSubmit",
	"PreToolUse", "PostToolUse", "PermissionRequest",
	"Stop", "Interrupt",
}

CodexHookEvents are the Codex hook events conch listens to: the ones that say whether it is working, waiting on the person or done. Model requests, compaction and subagents are left out, as they are for Claude: they fire inside a turn that tool events already report.

View Source
var GeminiHookEvents = []string{
	"SessionStart", "SessionEnd", "BeforeAgent", "AfterAgent",
	"BeforeTool", "AfterTool", "Notification", "PreCompress",
}

GeminiHookEvents are the Gemini CLI hook events conch listens to.

View Source
var ManifestProblem = func(err error) {}

ManifestProblem is told about a manifest that could not be read, so the server can log it where somebody will see it. A problem with one agent's file is not a reason to fail the others, or the server.

Functions

func CleanTitle

func CleanTitle(title string) string

CleanTitle turns a terminal title into a task label: activity prefixes, status symbols (spinners, ✳) and OpenCode's "OC | " are dropped, and titles that only name the agent become "".

func CodexTaskSandbox added in v0.2.1

func CodexTaskSandbox(home string, env func(string) string) string

CodexTaskSandbox is the sandbox a task's Codex is started in so it can write in every worktree it is given: workspace-write, or danger-full-access when the person's config.toml ($CODEX_HOME, else ~/.codex) already chose that — a task asks for what it needs and never takes away what was given. A profile's setting applies when that profile is picked (`profile = "NAME"` at the top), over the top-level one, as in Codex; a profile nobody picked changes nothing.

func DirArgs added in v0.2.0

func DirArgs(agent string, dirs []string) string

DirArgs are the words that give an agent more folders than the one it starts in — a task across several repos gives it every repo's worktree — for the agents that take them: Claude Code's and Codex's --add-dir, Gemini CLI's --include-directories. Any other gets nothing and works from where it starts, which holds the worktrees anyway.

Codex takes them only where its sandbox may write — in read-only, its default in a folder it has not been told to trust, it refuses them and exits (#190) — so it is asked for workspace-write with them; TaskDirArgs keeps a mode the person's own config gives instead.

func ManifestDir added in v0.1.7

func ManifestDir(configDir string) string

ManifestDir is where agents of the "runs here" tier are described. It is detect's directory: one file an agent, holding how to run it and how to recognise it.

func SanitizeEnv

func SanitizeEnv(env []string) []string

SanitizeEnv drops agent session variables from env.

func SessionIDOK added in v0.2.0

func SessionIDOK(id string) bool

SessionIDOK says whether id can name a saved session to resume: it is passed to the agent after its resume option, where one beginning with "-" would be read as an option of its own ("resume --yolo"). No agent's session ids begin with one.

func ShellQuote

func ShellQuote(s string) string

ShellQuote quotes s for POSIX shells.

func TaskDirArgs added in v0.2.1

func TaskDirArgs(agent string, dirs []string, codexSandbox string) string

TaskDirArgs is DirArgs with the sandbox Codex is started in (CodexTaskSandbox); other agents ignore it.

Types

type Adapter

type Adapter interface {
	// Name is the agent name used in manifests and the protocol.
	Name() string
	// Label is the name people know it by, e.g. "Claude Code".
	Label() string
	// Command returns the argv that starts the agent through shell, with
	// args (shell words typed by the user) appended.
	Command(shell, args string) []string
	// PromptArgs are the shell words that give the agent a first message
	// in its interactive session.
	PromptArgs(prompt string) string
	// ResumeArgs are the shell words that reopen a saved session; with id
	// "" the most recent one in the working directory.
	ResumeArgs(id string) string
	// Env is extra environment for the agent: conch's integration.
	Env() []string
	// Detect reports whether the agent is installed, as the user's login
	// shell would find it.
	Detect(ctx context.Context, shell string) Availability
	// InstallScript is a shell script that installs the agent for the
	// current user, run visibly in a pane.
	InstallScript() string
	// Tier is how far conch's support for this agent goes: TierSupported
	// for the ones with an adapter, detection taken from the real agent
	// and sessions that list and resume; TierRunsHere for one described by
	// a manifest, which conch starts and detects and no more. Said rather
	// than implied, so nothing has to pretend it can read a session format
	// nobody has written down.
	Tier() string
}

Adapter launches one kind of agent.

type Availability

type Availability struct {
	Installed bool
	Path      string
	Version   string
}

Availability is whether an agent is installed on this machine.

type Preparer added in v0.1.5

type Preparer interface {
	Ensure() error
}

Preparer is an adapter that writes files an agent is launched with, and can write them again. The server asks before every launch: the folder they live in can disappear between one and the next.

type Registry

type Registry []Adapter

Registry holds the adapters available on this server, in display order.

func New

func New(exe, dir string) (Registry, error)

New prepares every adapter. exe is the conch binary integrations call back into; dir is conch's config directory, where integration files are written.

func (Registry) Get

func (r Registry) Get(name string) (Adapter, bool)

Get finds an adapter by name.

Jump to

Keyboard shortcuts

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