Dependency inversion by default
Core APIs define contracts. Applications inject adapters, tools, storage, and presets explicitly.
Compose agents with explicit LLM, storage, tool, event, and channel dependencies.
npm install duclaw-cliFor TypeScript projects, add a tsconfig.json that can resolve the SDK subpath export:
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"skipLibCheck": true,
"types": ["node"]
}
}Continue with the SDK overview or jump to the core API reference.
import {
anthropic,
createAgent,
memoryStorage,
tool,
} from "duclaw-cli/sdk";
const agent = createAgent({
model: anthropic({ apiKey: process.env.ANTHROPIC_API_KEY! }),
storage: memoryStorage(),
tools: [
tool({
name: "lookup_account",
description: "Look up an account by id.",
inputSchema: {
type: "object",
properties: {
accountId: { type: "string" },
},
required: ["accountId"],
},
async run({ accountId }) {
return { id: accountId, plan: "pro" };
},
}),
],
system: "You are a precise SDK example agent.",
});
const result = await agent.run({
input: "Check account acc_123.",
context: { userId: "developer" },
});