Runs a local Helix Foundry install's Assistant on the Claude Code or Codex you're signed in to on this computer: its turns count against your own Claude or ChatGPT plan's limits (or your own API account, if that's how your CLI signs in), not the install's AI provider. Foundry runs in Docker, which can't reach your Keychain or your CLIs' logins, so this helper runs beside it, on the computer itself.
With Node 24, Claude Code (claude, then /login) or Codex 0.169.0 or later (codex login, with ChatGPT) installed and signed in, or both, and Foundry running here:
npx -y @helixdb/foundry-agent-host@0.1.0 pair hxp_… # the code Foundry's Settings › AI models shows
npx -y @helixdb/foundry-agent-host@0.1.0 install # keep it running (launchd on macOS, systemd on Linux)
npx -y @helixdb/foundry-agent-host@0.1.0 doctor # what stands in the way, if anythingrun runs it in a terminal instead of install; --claude <path> and --codex <path> name your claude and codex when they aren't on PATH (each command takes them; install keeps them, and your CODEX_HOME when you set one). The helper runs each CLI it finds, and pairs offering those. pair --foundry <url> names Foundry when it isn't at http://127.0.0.1:8081 (the pair command Foundry shows names it when FOUNDRY_MCP_PORT moved it). Pairing only pairs: Foundry counts the helper as running once run or install starts it.
Nothing but run the Assistant's turns, with Foundry deciding everything else.
- Its token. A pairing code is good once, for ten minutes. It is spent for the helper's
hxh_token, kept in~/.config/helix-foundry/agent-host.json(mode 600); Foundry keeps only its SHA-256. That token only claims turns and reports on them (/agent-host/…): it reaches neither Foundry's API nor its MCP. - A turn's token. Each turn Foundry leases the helper comes with an
hxr_token for that turn alone: Foundry's MCP takes it for the Assistant's tools only, in the turn's workspace, as you, at most 25 calls, until the lease or the turn ends. Revoking the helper in Foundry stops both at once. It never goes in a CLI's arguments or the helper's log. - Claude Code. It drives your own
claudethrough the Claude Agent SDK, as t3code does, unmodified, signed in as Claude Code always is, by whichever method you set up (the Keychain,~/.claude/.credentials.json,CLAUDE_CODE_OAUTH_TOKEN, or your ownANTHROPIC_API_KEYorANTHROPIC_AUTH_TOKEN; whichever the helper's environment holds is passed on as it is, andHOMEandCLAUDE_CONFIG_DIRare left as they are too).runhas your shell's environment; aninstalled helper's service has onlyPATH(andCODEX_HOME), so it signs in by the Keychain or~/.claude/.credentials.json. The helper never reads, keeps or forwards a credential. Each turn runs with no built-in tool (tools: []: no shell, files or web), Foundry's MCP server alone (sent over Claude Code's control channel, never its arguments or environment;strictMcpConfig, no claude.ai connectors), none of your settings, CLAUDE.md, hooks or plugins (settingSources: []),allowedTools: ["mcp__foundry__*"]indontAskmode with acanUseToolthat denies anything else, Claude Code's own system prompt with Foundry's appended (theclaude_codepreset, as t3code appends its own), and an empty directory of the thread's own (~/.local/state/helix-foundry/agent-host/threads/<workspace>/<thread>), under which Claude Code keeps the session the thread's next turn resumes (in~/.claude/projects/). If Claude Code signs in with an API key (one in its environment outranks your subscription login, as anywhere you run it), its turns bill that API account, and Settings › AI models says so; likewise anANTHROPIC_BASE_URLsends them where it points. Claude Code's own prompt goes with every model call, so a turn uses somewhat more of your plan than Foundry's prompt alone would. - Codex. It drives your own
codex app-server, as t3code does: one per turn, over stdio, signed in as Codex always is (yourCODEX_HOME's login, which the helper never reads, copies or refreshes), with your own Codex setup (below). - What Foundry is told of your sign-in. Whether each CLI is signed in, and the plan of its subscription (
pro,max, … for Claude;plus,pro,team, … for ChatGPT), and Codex's version: never your email or a token. The helper asks as it starts and every 10 minutes, and Settings › AI models shows it beside the helper. - What stays on this computer. A thread's CLI session holds what Foundry's tools answered in it (graph reads, document text, reviews): Claude Code's under
~/.claude/projects/, Codex's in itsCODEX_HOME(itscodex resumelists them). The helper asks Foundry which of its threads were deleted as it starts and every hour, and deletes those sessions and directories (Codex's through its app-server'sthread/delete, every thread under the directory, archived or not, of any source); revoked, it deletes every one. A CLI that fails to (Codex not starting, say) doesn't stop the others: that thread's directory stays, and the next sweep tries it again. - What you see. Foundry, not the helper, records each tool call and draws each card; the helper reports only the text the model writes and how the turn ended. Anything that changes your workspace is a card you run, or not, with a click.
A turn counts against your own plan's limits, not the install's AI provider or Founder budget, and counts toward the Assistant's hourly messages, steps and wall time (Codex's steps are its model calls, as its items show them). If the helper stops mid-turn, Foundry runs the turn again, within the wall time left from its first start, unless it had shown you something of it, in which case it says it was interrupted. A turn no helper takes within 3 minutes, while none is running, fails and says so.
Each turn is yours: it runs on this computer, in your own CLI, signed in to your own account, for messages you send (an install has one owner, and automations never run here). Whether your plan's terms let you use your subscription this way is still yours to check: Anthropic's and OpenAI's.
Codex runs with your own Codex setup: its app-server merges your ~/.codex/config.toml (your MCP servers, plugins, apps, profiles), managed and MDM configuration and what a ChatGPT workspace pushes into every thread, and has no option to leave them out. That is your choice to make, and Settings › AI models asks you once: choosing "My ChatGPT subscription (Codex)" shows what it runs with, and Foundry won't run new threads on Codex until you confirm (FOUNDRY_AGENT_CODEX_UNCONFIRMED; the Assistant's cards can't confirm it for you).
The Assistant reads untrusted data (documents, synced rows) through Foundry's tools, and a document could carry instructions meant to mislead it. So, over your setup, each turn's app-server runs with:
- No shell, no sub-agents.
features.shell_toolandfeatures.unified_execoff: Codex offers no command tool at all, so nothing runs unasked, "known safe" or not (untrustedwould auto-run those). Sub-agents are off as Codex 0.169.0 says to turn them off (agents.enabled = false,features.multi_agent = false,features.multi_agent_v2 = false): nospawn_agentor othercollaborationtool is offered. The image viewer (features.view_image), web search (web_search = "disabled"), image generation, browser and computer use, goals, memories, hooks, tool suggestions and sleep are off too. These go as-coverrides, none secret. - Read back, or nothing runs. A managed configuration (
/etc/codex/managed_config.toml, MDM on macOS) outranks-cand a thread's own settings: tested on 0.169.0, one can turn the shell back on, or setapproval_policy = "never"over the thread's. So before the model is called, each turn reads back what Codex will run with (config/read, and the settingsthread/startorthread/resumeanswer with), and fails, saying which setting didn't hold, unless every override above,untrusted,read-onlyand theuserreviewer all do.doctorruns the same check. - Read-only, every action asking this helper.
thread/start(andthread/resume) setsandbox: read-only,approvalPolicy: untrustedandapprovalsReviewer: user, over yours (an auto reviewer of yours would approve on its own). The helper, as the app-server's client, declines every approval Codex asks for: command executions, file changes (Codex'sapply_patch, which no configuration removes, asks and is declined, inside the thread's directory or out of it), permission escalations, and any MCP server's tool call that asks (your servers' writing tools, by their annotations). It answers no question for you (request_user_input). - Foundry's tools, unasked. Foundry's MCP server is added as
foundry_assistant_turn(a name unlikely to be one of yours: Codex merges a server of the same name), withbearer_token_env_var = "HELIX_FOUNDRY_TURN_TOKEN": the turn's token is in the app-server's environment only, never an argument, and its stdio MCP servers get Codex's default environment, not it.default_tools_approval_mode = "approve": Foundry's tools never ask (should a managed configuration make one ask, the helper accepts Foundry's alone). They are whatever Foundry's MCP server lists; the helper names none. Anything that changes your workspace is still a card you run, or not, with a click. - Foundry's system prompt in place of Codex's (
baseInstructions), telling the model to use Foundry's tools alone; an empty directory of the thread's own as its working directory; and the thread's Codex thread resumed.
What still runs, and is yours: a tool of your MCP servers, plugins or apps that doesn't ask for approval (one marked read-only, say) can be called in the Assistant's turns, including when a document tells the model to, and can read or send whatever it reaches. Codex's own request_user_input tools are offered and refused. The app-server ends with the turn. Your OpenAI API key in the environment (OPENAI_API_KEY, CODEX_API_KEY) isn't passed on, so turns bill your ChatGPT plan; a Codex signed in with an API key says so in Settings.
Version. The helper and Foundry run Codex 0.169.0 or later (MIN_CODEX, agent.MinCodexVersion), the version the isolation above was tested on: its configuration keys and approvals change between versions. A helper with an older Codex still pairs and says its version; Foundry runs no turn on it (Settings and the Assistant say to update it), and doctor says so too. Each turn checks the version of the app-server it started, too, so a Codex downgraded since the helper last told Foundry runs nothing. While its Codex is too old, or didn't say its version, the helper asks it again every 30 seconds, so an update shows within a minute.
test/real-codex.test.ts checks all of this against the real codex app-server (REAL_CODEX; CI runs the 0.169.0 pinned as a dev dependency), signed in with codex login --with-api-key and a fake key in a throwaway CODEX_HOME whose own config.toml points Codex at a stand-in Responses API (openai_base_url), sets approval_policy = "never", a full-access sandbox, an auto reviewer, the shell and sub-agents on, allows touch by an exec rule, and adds MCP servers of the person's (one named foundry, one with a writing and a reading tool). It proves, in code mode (the default models' exec tool) and with direct tools (gpt-5.5): no shell, exec or sub-agent tool is offered, and one the model calls anyway is unsupported; Foundry's tools are called with the turn's token, unasked, and answered; apply_patch and the person's writing tool are declined and nothing is written; the token is in no argument and nothing under CODEX_HOME; the next turn resumes the Codex thread; and the helper deletes it. Where /etc/codex is writable (CI makes it so), it plants a managed_config.toml that turns the shell and sub-agents back on, then one that sets approval_policy = "never", and proves the turn fails before the model is called, and doctor's check names them. A ChatGPT plan's account/read is the fake app-server's (test/fake-codex.mjs): no ChatGPT login exists on CI.
pnpm install
pnpm typecheck
pnpm test # against test/fake-claude.mjs, test/fake-codex.mjs and a fake Foundry: no login needed
pnpm build # dist/, which the package shipsbackend/cmd/foundry's TestFrontWithTheHelper runs the built helper against Foundry's real front end, with FOUNDRY_HELPER_E2E set to this directory.
test/real-codex.test.ts (above) and test/real-claude.test.ts check the isolation against the real CLIs. real-claude runs against a real Claude Code, REAL_CLAUDE (CI uses the one the pinned Agent SDK bundles), talking to a stand-in for Anthropic's API with your own MCP server, hooks and permissions planted in its HOME: the model is offered Foundry's tools alone (and Claude Code's inert DeferredToolPlaceholder), and Bash and Read are refused. Run them when you bump the SDK or Codex.