var r=Object.defineProperty;var l=(o)=>o;function s(o,i){this[o]=l.bind(null,i)}var m=(o,i)=>{for(var a in i)r(o,a,{get:i[a],enumerable:!0,configurable:!0,set:s.bind(i,a)})};var g=(o,i)=>()=>(o&&(i=o(o=0)),i);import{CodeBlock as n,InstallCommand as p}from"@contractspec/lib.design-system";import c from"@contractspec/lib.ui-link";import{ChevronRight as d}from"lucide-react";import{jsx as e,jsxs as t}from"react/jsx-runtime";function y(){return t("div",{className:"space-y-8",children:[t("div",{className:"space-y-4",children:[e("h1",{className:"font-bold text-4xl",children:"@contractspec/lib.ai-agent"}),e("p",{className:"text-lg text-muted-foreground",children:"Define AI agents in TypeScript, run them with deterministic tool calling, capture working memory, and route low-confidence decisions to human reviewers."})]}),t("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Installation"}),e(p,{package:"@contractspec/lib.ai-agent"})]}),t("div",{className:"space-y-3",children:[e("h2",{className:"font-bold text-2xl",children:"Define & register"}),e(n,{language:"typescript",code:`import { defineAgent, AgentRegistry } from '@contractspec/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);`})]}),t("div",{className:"space-y-3",children:[e("h2",{className:"font-bold text-2xl",children:"Run with approvals"}),e(n,{language:"typescript",code:`import { createUnifiedAgent, ApprovalWorkflow } from '@contractspec/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.
`})]}),t("div",{className:"space-y-3",children:[e("h2",{className:"font-bold text-2xl",children:"What's inside"}),t("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[t("li",{children:[e("code",{children:"createUnifiedAgent"}),", ",e("code",{children:"ContractSpecAgent"}),","," ",e("code",{children:"UnifiedAgent"})]}),e("li",{children:"MCP, operation-backed, memory, and subagent tool adapters"}),t("li",{children:[e("code",{children:"InMemoryAgentMemory"})," plus interfaces for custom stores"]}),t("li",{children:[e("code",{children:"ApprovalWorkflow"})," + ",e("code",{children:"ApprovalStore"})," for human-in-the-loop reviews"]})]})]}),t("div",{className:"flex items-center gap-4 pt-4",children:[e(c,{href:"/docs/libraries",className:"btn-ghost",children:"Back to Libraries"}),t(c,{href:"/docs/libraries/support-bot",className:"btn-primary",children:["Next: Support Bot ",e(d,{size:16})]})]})]})}export{y as LibrariesAiAgentPage};
