Skip to navigation

Codex with TypeScript

TypeScript Behavior

The TypeScript adapter differs from the Python one:

  • Like the Python adapter, it starts one codex app-server process 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, pass config.workspaceForRoom, a function from room ID to an absolute path. It cannot be combined with config.cwd.
  • It declines Codex’s approval requests instead of posting them to the room. approvalPolicy defaults to "never" and sandboxMode to "workspace-write".
  • turnTimeoutMs defaults to 180000.
  • Tool and thought events are off by default. Set enableExecutionReporting and emitThoughtEvents to 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

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:

mkdir codex-agent && cd codex-agent
npm init -y && npm pkg set type=module
npm install @band-ai/sdk@1.0.0
npm install -D tsx
agent.ts
import { Agent, CodexAdapter, loadAgentConfig } from "@band-ai/sdk";
const adapter = new CodexAdapter({
config: {
cwd: "../codex-work",
customSection: "You are a coding agent. Keep replies short and name every file you change.",
enableExecutionReporting: true,
},
});
const agent = Agent.create({
adapter,
config: loadAgentConfig("my_agent"),
});
await agent.run();

Run it with npx tsx agent.ts. The TypeScript SDK logs nothing by default, and the process keeps running until you press Ctrl+C.

Next Steps

TypeScript adapter reference.