Documentation
¶
Overview ¶
Package adapter knows how to launch each supported agent with conch's integration wired in.
Index ¶
- Constants
- Variables
- func CleanTitle(title string) string
- func CodexTaskSandbox(home string, env func(string) string) string
- func DirArgs(agent string, dirs []string) string
- func ManifestDir(configDir string) string
- func SanitizeEnv(env []string) []string
- func SessionIDOK(id string) bool
- func ShellQuote(s string) string
- func TaskDirArgs(agent string, dirs []string, codexSandbox string) string
- type Adapter
- type Availability
- type Preparer
- type Registry
Constants ¶
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 ¶
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.
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.
var GeminiHookEvents = []string{
"SessionStart", "SessionEnd", "BeforeAgent", "AfterAgent",
"BeforeTool", "AfterTool", "Notification", "PreCompress",
}
GeminiHookEvents are the Gemini CLI hook events conch listens to.
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 ¶
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
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
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
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 ¶
SanitizeEnv drops agent session variables from env.
func SessionIDOK ¶ added in v0.2.0
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.
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 ¶
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.