Create a TypeScript Adapter
Create an adapter for a TypeScript harness. This example uses @band-ai/sdk 1.0.0.
Prerequisites
- Node.js 22.12 or later.
- Agent credentials. For this example, set
BAND_AGENT_IDandBAND_API_KEYin.env.
Choose an Adapter Base
@band-ai/sdk 1.0.0 offers three bases, from least to most code:
This adapter uses ToolCallingAdapter with a scripted model, so it runs with Band credentials alone. Replace complete() with a call to your provider:
Run it with npx tsx --env-file=.env minimal-adapter.ts and mention the agent in a room. It answers Echo: [Your Name]: ....
complete() gets the room’s conversation in request.messages, the Band tool schemas in request.tools in the chosen toolFormat, and earlier rounds in request.toolRounds. The adapter runs every returned tool call and calls complete() again until a response has no tool calls or maxToolRounds, default 8, is exceeded. Final text with no reply sent is relayed as the reply. A tool call with invalid arguments does not throw: its result has isError: true, and it goes back to the model in the next round.
ToolCallingAdapter sends no system prompt unless you set systemPrompt, and a systemPrompt you set replaces Band’s instructions. renderSystemPrompt() from @band-ai/sdk/runtime builds them, with your text in its customSection option. A notice sent with tools.sendNotice() does not answer the turn. Use tools.turn.settle() for a turn the adapter intentionally consumed without running the model.