Documentation
¶
Overview ¶
Package agentbin resolves the executable of a coding agent — claude, codex, opencode or pi — before a session runs it, and keeps a test binary from ever running a real one.
Every test that runs a session fakes its agent, with a script under the test's temporary directory or with the test binary itself (see CONTRIBUTING.md). A test that forgets to, or a test binary re-executed as a command of its own (a caller command), would otherwise find the real claude on PATH and run it: for real, unwatched, and as many times as the scheduler it started asks. Resolve refuses that. In a binary built by `go test` the executable must be one of those two fakes, and anything else is ErrRealAgent, however the binary was invoked: testing.Testing reports the build, not the command line.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRealAgent = errors.New("refusing to run a real coding agent from a test binary")
ErrRealAgent is the error Resolve wraps when a test binary would run an agent that is not one of the fakes tests make.
Functions ¶
func CommandContext ¶
CommandContext applies the fake-executable guard to helper processes as well as agents, notably the container engine, the Docker Sandboxes CLI and the caller-owned host MCP server.
func Resolve ¶
Resolve returns the executable exec would run for bin: bin itself when it names a path, else the first match on PATH. A bin that cannot be found is returned as it is, so the caller fails the way exec does when it starts it. In a test binary the executable must be a fake, the test binary itself or a file under the temporary directory, or the error wraps ErrRealAgent.
Types ¶
This section is empty.