@zanii/connectors
v0.1.0
Published
One-call proof recording for OpenAI function calls and Anthropic tool_use, plus a toolbox wrapper. Platform-shaped glue over the SDK's wrapTool. Zero dependencies.
Readme
@zanii/connectors
One-call proof recording for the two dominant LLM tool-calling formats —
OpenAI function calls and Anthropic tool_use — plus a toolbox wrapper.
It's the platform-shaped glue over the SDK's generic wrapTool, so you don't
hand-map each provider's payload. Zero dependencies; the agent is duck-typed.
npm install @zanii/connectors @zanii/sdkUsage
import { wrapToolbox, runToolCalls } from '@zanii/connectors';
import { ZaniiAgent } from '@zanii/sdk';
const agent = new ZaniiAgent({ /* … */ });
// 1. Wrap a whole toolbox — every call is recorded to tools.<name>:
const tools = wrapToolbox(agent, {
lookupCustomer: (id: string) => db.get(id),
sendEmail: (to: string, body: string) => mailer.send(to, body),
});
await tools.sendEmail('[email protected]', 'hi'); // recorded automatically
// 2. Or dispatch a model's tool calls and receipt each (OpenAI or Anthropic):
const outcomes = await runToolCalls(agent, message.tool_calls, async (name, args) => {
return myDispatcher[name](args);
});
// each outcome: { name, arguments, result | error, hash }normalizeToolCall handles both shapes (OpenAI function.arguments JSON strings
are parsed; Anthropic input is passed through). runToolCalls records both
successes and failures and keeps going.
Changelog
- 0.1.0 — initial release:
wrapToolbox,normalizeToolCall,recordToolCall,runToolCalls.
License
Apache-2.0.
