Connect terminal agents with the CallPact shell¶
callpact-sh is the stable shell entry point installed by callpact env --enable.
Hosts that allow a custom shell path can use it directly. Hosts that do not can
use PATH shims, a pre-tool hook, or an MCP-only deployment.
This guide covers Claude Code, Antigravity, OpenCode, Codex and pi. It records the tested versions; host behavior changes between releases, so re-run the verification steps after upgrading.
How it works¶
agent -> callpact-sh -c "<command>"
| execve(real shell, PATH with shim directory first)
v
/bin/zsh -c "<command>"
| external command resolved to an installed shim
v
command shim -> shared executor -> configured ACL, approval, audit
callpact-sh does not parse the command string and does not stay in the process
tree. It prepares the environment and replaces itself with the real shell.
Shell builtins, functions, pipelines and redirections keep their normal
semantics.
Only commands with an installed shim are governed. Absolute paths, builtins,
functions, sudo, interpreter-internal execution and commands without a shim
are not. This is not a sandbox.
One-time setup¶
After a binary-only install, run callpact setup to initialize bindings, create
a strict starter ACL on fresh installations, bind the policy to the shims,
and offer to configure detected hosts. Review the summary and ACL. For Codex,
follow the login-shell step below.
These commands prepare and inspect the components individually.
callpact sh --check reports the real shell, the entry point, the manifest, ACL
state, verified and scanned routes, and host configuration snippets. For one
host, callpact agent opencode (or pi, codex, claude, antigravity) prints
the supported configuration, and callpact agent --check <host> checks launcher
and host readiness without writing files. The entry point is normally:
Use its absolute path in host configuration.
OpenCode¶
Tested with OpenCode 1.19.5.
Set shell in the project opencode.json or in
~/.config/opencode/opencode.json:
Restart OpenCode after changing the file. Its shell tool invokes
callpact-sh -c "<command>".
Verify inside OpenCode by asking it to run:
command -v ls should print ~/.callpact/bin/ls, and ~/.callpact/audit.jsonl
should contain an execution record.
pi¶
Tested with pi-coding-agent 1.1.0.
Set shellPath in ~/.pi/agent/settings.json:
Restart pi. Its bash tool invokes callpact-sh -c "<command>" and exports
CALLPACT_SHELL_DEPTH=1 to nested shells.
If pi's default shell should be bash rather than the inherited $SHELL, set:
Verified behavior includes shim resolution for ls/cat/head, ACL allow and
execution audit records, fail-closed syntax refusals, exit 7 passthrough and
nested-shell governance.
Codex¶
Tested with Codex CLI 0.145.0.
Codex does not accept callpact-sh as its shell. It starts commands with its real
login shell (for example /bin/zsh -lc), so the supported integration is PATH
activation:
The managed block is written to .zshrc and .zprofile. The .zprofile block
runs after macOS path_helper resets PATH, so the shim directory is restored
for non-interactive login shells. For bash, use --shell bash; for sh, use the
login profile.
Do not set SHELL=callpact-sh for Codex. Verify inside Codex:
It should print ~/.callpact/bin/ls.
Claude Code¶
Tested with Claude Code 2.1.318.
Claude Code rejects callpact-sh as SHELL or CLAUDE_CODE_SHELL and falls back
to /bin/zsh. Use one of the two supported paths.
PreToolUse hook (recommended)¶
Add a PreToolUse hook matching Bash in .claude/settings.json (project) or
~/.claude/settings.json (user):
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "/Users/you/.local/bin/callpact hook claude",
"timeout": 30
}
]
}
]
}
}
Use the full path to callpact, not callpact-sh: callpact-sh forwards its
arguments to the shell, while callpact hook is a normal subcommand.
The hook rewrites simple external commands to
<callpact> sh -c '<command>' through updatedInput and returns
permissionDecision: "allow". Claude Code still evaluates its own deny/ask
rules against the rewritten command. Commands already routed through
callpact, the legacy apexe executable or callpact-sh are left unchanged, so the hook does not recurse.
Stateful builtins (cd, export, set, alias, echo, …), pipelines,
redirections, command substitution, compound commands and sudo are left
unchanged. They continue to rely on PATH shims. A missing shim manifest makes
the hook deny the call with a remedy instead of pretending it is governed.
PATH shims¶
Start Claude Code from a terminal whose PATH already contains the shim
directory:
Claude Code's shell snapshot copies the launch environment's PATH; editing
.zshrc alone is not enough. This governs external commands that resolve
through PATH shims, but does not cover absolute paths or compound commands the
same way the hook does.
Antigravity¶
Antigravity (Desktop, IDE and agy CLI) supports lifecycle PreToolUse hooks
and Stdio MCP servers. It does not require installing gemini CLI.
PreToolUse hook (recommended)¶
Add a callpact hook entry matching run_command in .agents/hooks.json
(project) or ~/.gemini/config/hooks.json (user):
{
"CallPact": {
"PreToolUse": [
{
"matcher": "run_command",
"hooks": [
{
"type": "command",
"command": "/Users/you/.local/bin/callpact hook antigravity",
"timeout": 30
}
]
}
]
}
}
Use the full path to callpact, not callpact-sh. The hook reads
Antigravity's camelCase PreToolUse JSON payload (toolCall.name ==
"run_command", toolCall.args.CommandLine) and rewrites simple external
commands to <callpact> sh -c '<command>' through overwrite.CommandLine with
decision: "allow". Commands already routed through callpact, the legacy apexe executable or callpact-sh,
stateful builtins, pipelines, redirections, command substitution, compound
commands and sudo exit 0 with empty stdout so Antigravity leaves them
unchanged and PATH shims govern eligible external commands (returning {}
without a decision is treated as a denial by Antigravity). A missing shim
manifest makes the hook return decision: "deny" with a remedy.
Verified on Antigravity Desktop (macOS arm64, 2026-11-25): simple run_command
calls (ls README.md) were rewritten through overwrite.CommandLine, resolved
to ~/.callpact/bin/ls and recorded both ACL allow and execution entries in
~/.callpact/audit.jsonl; compound commands and already-routed callpact commands
passed through unchanged; a missing shim manifest denied run_command with the
hook's remedy text. Note that Antigravity's Terminal Sandbox blocks
run_command from reading or writing ~/.callpact outside the workspace (os
error 1), so disable Terminal Sandbox for the project or allow access to
~/.callpact when using the local hook integration.
callpact setup and callpact agent --check antigravity detect Antigravity through
agy/antigravity on PATH or an existing ~/.gemini/antigravity*
directory (covering Antigravity Desktop and IDE installations that do not put a
CLI binary on PATH).
Automatic host configuration¶
callpact agent <host> --write merges the supported configuration into the host's
JSON file without replacing unrelated keys:
callpact agent opencode --write
callpact agent claude --write
callpact agent antigravity --write
callpact agent pi --write
callpact agent codex --write
- OpenCode writes
shellto the projectopencode.json; use--scope userfor~/.config/opencode/opencode.json. - pi writes
shellPathto~/.pi/agent/settings.json. - Claude Code writes a
PreToolUsehook to.claude/settings.json; use--scope userfor~/.claude/settings.json. - Antigravity writes a
PreToolUsehook to.agents/hooks.json; use--scope userfor~/.gemini/config/hooks.json. - Codex has no CallPact-specific shell file;
--writereloads startup files for the resolved real shell (CALLPACT_REAL_SHELL, thenSHELL, then the launcher fallback), preserving the selected shim directory. The check reads that shell's noninteractive login startup file rather than accepting a block from an unrelated shell or an interactive-only.bashrc/.zshrc. Restart Codex afterwards. If Codex explicitly selects a different shell, configure that shell withcallpact env --reload --shell <shell>instead.
The writer refuses invalid JSON and OpenCode refuses when opencode.jsonc
already exists. OpenCode, pi and Claude hook installation also refuse an
incomplete launcher installation: a missing entry point breaks shell-path
hosts, and a missing manifest makes the Claude hook deny Bash calls. Invalid
Claude hook container types are refused without changing the file. Shell
configuration writes and callpact agent --check also require a loadable ACL
recorded in the shim manifest. For an older installation with an implicit
default ACL, run callpact env --reload to bind it. Use the installed --shim-dir
if you chose a custom directory. Review the host file after writing.
Repair stale integration without bypassing policy¶
Run the checks from the terminal that will launch the agent:
callpact sh --check
callpact env --reload
callpact agent <host> --write
callpact agent --check <host> --format json
Reload preserves the recorded bindings, ACL and filters when the manifest is
valid. If the manifest is missing or corrupt, restore with callpact env --enable
and the original --shim-dir, --bindings-dir, --acl and policy options;
do not substitute a default policy for a previously selected one.
Use the same --scope user or project scope as the original installation,
then restart the agent. OpenCode/pi checks compare the selected launcher path
with the active installation; an unrelated or removed callpact-sh is not ready.
An explicit OpenCode project shell overrides the user setting, even when it
is invalid or points elsewhere. A project file with no shell inherits the
user selection; unreadable or malformed project JSON cannot establish readiness.
pi's supported leading ~/ is expanded before comparison, including when
checking for host settings that depend on shims being uninstalled.
Claude --write updates recognized callpact hook commands to the current binary
without adding another hook, including quoted paths and --persistent. Other
hooks and permission rules are preserved. A stale hook is reported even when
PATH already contains shims, because PATH cannot repair a hook executable.
Do not repair an installation by filling callpact-sh with a hand-written shell
wrapper. Do not clear an ACL or ignore a governance refusal. Plain callpact sh
continues to run a real shell without an installation; that is not evidence of
governed execution, and the hook retains its fail-closed prerequisite check.
Existing MCP-only tools.bash: false or permissions.deny: ["Bash"] settings
are not removed by shell configuration; explicitly review them if restoring
ordinary shell access is intended.
Experimental persistent session¶
The Claude Code hook normally rewrites only simple external commands, because a
one-shot callpact sh -c does not preserve shell state. --persistent keeps a
governed shell alive across calls:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "/Users/you/.local/bin/callpact hook claude --persistent",
"timeout": 30
}
]
}
]
}
}
The first call starts a detached session over a Unix socket (mode 0600). The
session preserves cwd, shell variables, functions and aliases, and accepts
compound commands, pipelines and redirections. It is scoped to the host session
id and project directory, exits after 30 minutes idle by default
(CALLPACT_SESSION_IDLE_SECONDS), and can be stopped with:
Limitations: commands that read stdin are not supported; output is text; one request is served at a time; the daemon runs with the user's privileges. Treat this as experimental until it has run across your host versions.
MCP-only deployment¶
MCP-only configures access to CallPact tools and requests that the host disable its shell tool. Verify the effective permission in the running host after reload before relying on it as a boundary. It is not suitable for agents that must do arbitrary coding.
callpact agent opencode --mcp-only --write
callpact agent claude --mcp-only --write
callpact agent antigravity --mcp-only --write --scope user
callpact agent codex --mcp-only
- OpenCode: merges
mcp.servers.apexeand a V2shelldeny rule. Automatic edits require OpenCode 2.3.0. CallPact checks discovered permission sources and previews the proposed rule through the host's effective agent diagnostics. A conflict or an inconclusive preview stops publication. In user scope, this preview covers the current project context. For other versions or conflicts, omit--writefor a snippet and review permissions manually. - Claude Code: project scope merges
mcpServers.apexein.mcp.jsonand addsBashtopermissions.denyin.claude/settings.json. Both files' shapes are checked before either write. If publishing the second file fails, the diagnostic reports the completed write; correct the error and retry the same command. User scope updates~/.claude/settings.jsonand prints theclaude mcp add --scope usercommand you must run to register the server. In project scope, approve the server if Claude Code prompts. The acceptance fixture verified MCP invocation and Bash refusal after restart in both scopes with Claude Code 2.1.318 on macOS in non-interactivedontAskmode. - Antigravity: user scope merges
mcpServers.apexeinto~/.gemini/config/mcp_config.json. Antigravity keeps its terminal tool (run_command), so restrict it in Antigravity Settings (Permission Grants / Command Denylist) if you require strict MCP-only access. - Codex: prints a
[mcp_servers.apexe]TOML block. Codex keeps its shell, so this is not strict MCP-only; combine it with a sandbox. - pi: no stable MCP-only profile in the tested version.
The generator validates and includes the selected ACL via --acl. It uses a
policy recorded in the local shim manifest when present and otherwise uses
the default ACL, including on installations without shims. When a manifest
exists, the generator also uses its binding directory via --bindings-dir.
A manifest whose binding pattern differs from the active apcore configuration
stops generation. MCP applies its own tool filters and the selected ACL.
A missing or malformed policy stops generation before host files are changed.
The generator also stops if that policy requires human approval. Configure an
elicitation-capable MCP client with callpact serve --enable-approval to use
that policy.
Regenerate older MCP configurations to include the selected ACL and bindings.
Verify any host¶
For a shell or hook deployment, check the host configuration and selected ACL before starting a fresh agent session.
Confirm that the host is configured and the report lists the intended ACL and
shim route. For PATH-based integration, confirm in the actual agent terminal
that command -v ls points to the installed shim. The Claude Code hook can
route a simple command even when its original shell resolves the native binary.
Ask the agent for a normal detailed directory listing, including hidden entries.
In the terminal tool request, check for ls -la with ordinary command syntax.
Use an equivalent CLI operation if this installation covers a different tool.
Check the CallPact audit log (default ~/.callpact/audit.jsonl) for a new
"event":"execution" record with the expected module ID. Confirm the
corresponding ACL decision as well. Scanned routes carry "tier":"scanned".
To test denial, use a harmless command with an installed shim and an explicit
deny in a disposable test policy. Check for an ACL deny record and confirm
that the child command did not run.
Boundaries and troubleshooting¶
callpact env --enablemust have run; without the manifest the launcher still starts a shell, but no command is governed.callpact sh --checkfails when the entry point or manifest is missing and warns when no ACL is loaded.callpact env --disablewarns when OpenCode/pi still selectscallpact-sh, or a Claude/Antigravity hook remains and would refuse shell tool calls without its manifest. Re-enable the installation, or explicitly remove the corresponding host setting/hook. Uninstall does not silently edit another application's configuration.- Login shells may reset
PATH; keep the managed startup block afterpath_helperor use the hook. - A host upgrade can change config discovery or shell behavior. Re-run the verification steps and record the new version.
- On Windows,
callpact shis not available; use MCP-only or PATH integration per host.