// @bun
import{CodeBlock as o,InstallCommand as a}from"@contractspec/lib.design-system";import i from"@contractspec/lib.ui-link";import{ChevronRight as n}from"lucide-react";import{jsx as e,jsxs as t}from"react/jsx-runtime";function s(){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(a,{package:"@contractspec/lib.ai-agent"})]}),t("div",{className:"space-y-3",children:[e("h2",{className:"font-bold text-2xl",children:"Define & register"}),e(o,{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(o,{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(i,{href:"/docs/libraries",className:"btn-ghost",children:"Back to Libraries"}),t(i,{href:"/docs/libraries/support-bot",className:"btn-primary",children:["Next: Support Bot ",e(n,{size:16})]})]})]})}export{s as LibrariesAiAgentPage};
