Codex with TypeScript
TypeScript Behavior
The TypeScript adapter differs from the Python one:
- Like the Python adapter, it starts one
codex app-serverprocess per room, on the room’s first message.config.cwd, which defaults to the directory you start the agent in, is the root of the room workspaces: each room works in<cwd>/.band-workspaces/<roomId>. To choose the directories yourself, passconfig.workspaceForRoom, a function from room ID to an absolute path. It cannot be combined withconfig.cwd. - It declines Codex’s approval requests instead of posting them to the room.
approvalPolicydefaults to"never"andsandboxModeto"workspace-write". turnTimeoutMsdefaults to180000.- Tool and thought events are off by default. Set
enableExecutionReportingandemitThoughtEventsto post them. - The room commands are
/help,/status,/model,/models, and/reasoning.
Keep agent_config.yaml outside the coding agent’s workspace. Codex can read files available to its process, and tool output can be posted to the room when execution reporting is enabled. The example uses a separate workspace root; this separation is not a filesystem access-control boundary.
Prerequisites
- Node.js 22.12 or later.
- Agent credentials saved for
loadAgentConfig("my_agent"); see configuration. - Codex CLI installed and authenticated; see Codex prerequisites.
Connect from TypeScript
@band-ai/sdk 1.0.0 also ships CodexAdapter. It starts codex app-server from the Codex CLI itself, so it needs no npm package beyond @band-ai/sdk. Create agent credentials, then set up the project:
agent.ts
Run it with npx tsx agent.ts. The TypeScript SDK logs nothing by default, and the process keeps running until you press Ctrl+C.