Constal SDK

Author executable Agent, Channel, Auth Provider, Policy, Credential Provider, Tool, and runtime integration contracts in TypeScript.

@constal/sdk defines code that Constal builds and executes. It is not a tenant-administration client: deployment, configuration, Run control, and inspection belong to the Console, CLI, or Platform API.

A complete native Agent

ts
import { agent, type HistoryView } from "@constal/sdk";

export default agent({
  id: "support", version: "1.0.0", model: "model",
  async onMessage(message, ctx) {
    const history = await ctx.ledger.view<HistoryView>("history");
    const turn = await ctx.turn({
      system: "Resolve the request accurately.",
      objective: message,
      context: { priorFacts: history.facts },
    });
    return { answer: turn.message.content };
  },
});

The returned value becomes durable Run output. model is a logical Resource binding accepted at deployment, not a provider name supplied by the caller.

The seven primitives in code

ts
const turn = await ctx.turn({ system: "Decide.", objective: input });
const history = await ctx.ledger.view("history");
const fact = await ctx.commit({ decision: turn.message.content });
const answer = await ctx.await("approval", { timeout: 86_400_000, onTimeout: { approved: false } });
const child = await ctx.spawn(registeredTask, input, { retries: 2 });
const mapped = await ctx.map(registeredPartitionFn, rows, { partition: { rows: 100 } });
const reduced = await ctx.reduce(registeredFoldFn, mapped, { scope: "global" });

Resources, Tools, Policy, Channels, and Credentials support this language without adding more primitives. Each focused guide below supplies a complete definition rather than a prose-only contract.

Product SDK guides

BuildingFocused guide
Agent behavior and ResourcesAgents SDK guide
Durable work inside a RunRuns SDK guide
Resources and ToolsResources SDK guide
Memory operationsMemory SDK guide
Channels and Auth ProvidersChannels SDK guide
Executable PolicyPolicies SDK guide
Custom analyticsAnalytics SDK guide
Credential Provider lifecycleCredentials SDK guide

Start with Set up an SDK project, then choose Agents, Resources and Tools, Channels and Auth Providers, Policies and analytics, or Credential Providers. Read The seven Agent primitives for the runtime contract behind the examples.