Skip to content

Getting Started

Install the published package:

sh
npm install duclaw-cli

For a TypeScript project, install the compiler/runtime helpers and use a resolver that understands package subpath exports:

sh
npm install -D typescript tsx @types/node
json
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "strict": true,
    "skipLibCheck": true,
    "types": ["node"]
  }
}

If you use Vite or another bundler, moduleResolution: "Bundler" is also valid. Legacy node resolution can report Cannot find module 'duclaw-cli/sdk' because it does not read the SDK subpath export map.

Use the SDK entrypoint for generic agent composition:

ts
import {
  anthropic,
  createAgent,
  memoryStorage,
  tool,
} from "duclaw-cli/sdk";

Create an Agent

ts
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",
            description: "Account id, for example acc_123.",
          },
        },
        required: ["accountId"],
        additionalProperties: false,
      },
      async run({ accountId }) {
        return { id: accountId, plan: "pro" };
      },
    }),
  ],
  system: "You are a precise SDK example agent.",
});

Run a Request

ts
const result = await agent.run({
  input: "Check account acc_123.",
  context: {
    userId: "developer",
    requestId: "request-001",
  },
});

console.log(result.output);

Required Dependencies

The public SDK facade requires these dependencies:

FieldPurpose
systemRuntime instruction for the agent
modelImplementation of the model contract
storageMessage history storage
toolsTool definitions available to the agent

The SDK does not create Duclaw product defaults unless you import the preset subpath.

Released as part of the duclaw-cli package.