@lssm/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.

Define & register

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

const SupportBot = defineAgent({
  meta: { name: 'support.bot', version: 1 },
  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 { AgentRunner, ToolExecutor, ApprovalWorkflow } from '@lssm/lib.ai-agent';

const runner = new AgentRunner({
  registry,
  llm: mistralProvider,
  toolExecutor: new ToolExecutor({ tools: supportTools }),
  approvalWorkflow: new ApprovalWorkflow(),
});

const result = await runner.run({ agent: 'support.bot', input: ticket.body });
if (result.approvalRequestId) {
  // show in ApprovalQueue UI
}

What's inside

  • defineAgent, AgentRegistry, AgentRunner
  • ToolExecutor with schema-enforced tool definitions
  • InMemoryAgentMemory plus interfaces for custom stores
  • ApprovalWorkflow + ApprovalStore for human-in-the-loop reviews