ContractSpec docs

OSS-first docs

These docs teach the open system first: contracts, generated surfaces, runtimes, governance, and incremental adoption. Studio shows up as the operating layer on top, not as the source of truth.

AI index

@lssm-tech/lib.ai-agent

Define AI agents in TypeScript, run them with deterministic tool calling, capture working memory, and route low-confidence decisions to human reviewers.

Explore the agent ecosystem

This page is the package API reference. For end-to-end guidance on multi-agent collaboration, governed self-improvement, durable runtimes, deployment, and production qualification, use the Agent Ecosystem guide.

Installation

bun add @lssm-tech/lib.ai-agent

Define & register

import { defineAgent, AgentRegistry } from '@lssm-tech/lib.contracts-spec/agent';

const SupportBot = defineAgent({
  meta: {
    key: 'support.bot',
    version: '1.0.0',
    description: 'Resolve tickets and escalate low-confidence decisions.',
    owners: ['support'],
    tags: ['support'],
    stability: 'experimental',
  },
  instructions: 'Resolve tickets. Escalate when confidence < 0.75.',
  tools: [{ name: 'support_resolve_ticket' }],
  policy: {
    confidence: { min: 0.7, default: 0.6 },
    escalation: { confidenceThreshold: 0.75 },
  },
});

const registry = new AgentRegistry().register(SupportBot);

Run with approvals

import { createUnifiedAgent, ApprovalWorkflow } from '@lssm-tech/lib.ai-agent';

const approvals = new ApprovalWorkflow();
const agent = createUnifiedAgent(SupportBot, {
  backend: 'ai-sdk',
  tools: new Map([['support_resolve_ticket', async (input) => resolveTicket(input)]]),
});

const result = await agent.run(ticket.body);
// Route low-confidence or manual-review flows through approvals when needed.

What's inside

  • createUnifiedAgent

    ,

    ContractSpecAgent

    ,

    UnifiedAgent

  • MCP, operation-backed, memory, and subagent tool adapters

  • InMemoryAgentMemory

    plus interfaces for custom stores

  • ApprovalWorkflow

    +

    ApprovalStore

    for human-in-the-loop reviews

OSS docsbuildStart with OSS. Adopt Studio when you want the operating layer.

Why ContractSpec

Keep educational and comparison content reachable without letting it define the primary OSS learning path.