botinabox 2.1.3 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +54 -51
  2. package/package.json +4 -3
package/README.md CHANGED
@@ -4,26 +4,28 @@ A modular TypeScript framework for building multi-agent bots with LLM orchestrat
4
4
 
5
5
  ## Features
6
6
 
7
+ - **Execution engine** -- Generic task executor with 22 built-in tools and a tool loop (up to 5 iterations). Agents can read files, send documents, dispatch tasks, search conversations, and more. Apps register tools declaratively.
8
+ - **22 built-in tools** -- File ops (send, read, list, register), task ops (dispatch, cancel, reassign), system status (task, agent, system, active tasks), entity lookup (agents, projects, agent detail), messaging (send message, task comment, read/search conversation), management (create agent, create project). All channel-agnostic.
9
+ - **Chat pipeline** -- Configurable 6-layer chat orchestration: dedup, storage, fast ack (<2s via Haiku), async interpretation, task dispatch, and completion response. Apps provide system prompt and routing rules; framework handles everything else.
10
+ - **Slack integration** -- `SlackBoltAdapter` handles Bolt Socket Mode, message parsing, response delivery, and file uploads. One import, one `start()` call.
11
+ - **Unified config** -- All settings in one `botinabox.config.yml`: models, execution, chat, routing, safety, budget. YAML with env var interpolation. Auto-initializes with sensible defaults.
12
+ - **Message store** -- Store-before-respond guarantee. Inbound messages and attachments stored before any bot response. Channel history for conversation context.
13
+ - **Message interpretation** -- Async structured extraction from messages into tasks, memories, files, and user context. Pluggable extractors for custom data types. Programmatic task creation (no LLM dependency).
14
+ - **Triage routing** -- Content-aware message routing with keyword/regex matching, priority rules, and LLM fallback. Ownership chain logging for every routing decision.
7
15
  - **Multi-agent orchestration** -- Define agents with different models, roles, and execution adapters. Task queue with priority scheduling, retry policies, and followup chains.
8
- - **Chat response layer** -- Fast (<2s) conversational responses via cheap LLM. Rolling context window, LLM-filtered readability, redundancy suppression. Store-before-respond guarantee for all messages.
9
- - **Message interpretation** -- Async structured extraction from messages into tasks, memories, files, and user context. Pluggable extractors for custom data types.
10
- - **Two-tier agents** -- Deterministic adapter for tasks that don't need LLM reasoning (routing, validation, data fetching). API and CLI adapters for LLM-driven tasks.
11
- - **Triage routing** -- Content-aware message routing with keyword/regex matching, priority rules, and LLM fallback for ambiguous messages. Ownership chain logging for every routing decision.
12
- - **Loop detection and circuit breakers** -- Pattern-based loop detection (self-loops, ping-pong, blocked re-entry) plus circuit breakers with automatic human escalation when agents fail repeatedly.
13
- - **Learning pipeline** -- Structured feedback capture with auto-promotion: 3+ similar feedback records become a playbook, playbooks used by 3+ agents become reusable skills. Two-axis scoring (accuracy + efficiency).
14
- - **Governance gates** -- Independent QA, quality, and drift gates that validate agent output and report to the human operator. Gates run independently and cannot override each other.
15
- - **Permission relay** -- Remote approval for unattended agents via messaging platforms (Slack, Discord, Telegram). Dual approval: local terminal and remote, first response wins.
16
- - **LLM provider abstraction** -- Swap between Anthropic, OpenAI, and Ollama with a unified interface. Model aliasing, purpose-based routing, and fallback chains.
17
- - **Channel adapters** -- Connect to Slack, Discord, and webhooks. Auto-discovery, session management, and notification queuing.
18
- - **Workflow engine** -- Define multi-step workflows with dependency resolution, parallel execution, and conditional branching.
19
- - **SQLite data layer** -- Schema-driven tables, migrations, entity context rendering, and query builder via [latticesql](https://github.com/automated-industries/lattice). WAL mode for concurrent reads.
20
- - **Event-driven hooks** -- Priority-ordered, filter-based event bus for decoupled inter-layer communication.
16
+ - **Loop detection and circuit breakers** -- Pattern-based loop detection (self-loops, ping-pong, blocked re-entry) plus circuit breakers with automatic human escalation.
17
+ - **Learning pipeline** -- Structured feedback capture with auto-promotion: 3+ similar records become a playbook, 3+ agents become a reusable skill.
18
+ - **Governance gates** -- Independent QA, quality, and drift gates that validate agent output and report to the human operator.
19
+ - **Permission relay** -- Remote approval via messaging platforms (Slack, Discord, Telegram). Dual approval: local + remote, first wins.
20
+ - **LLM provider abstraction** -- Swap between Anthropic, OpenAI, and Ollama. Model aliasing, purpose-based routing, fallback chains. Default LLM call wrapper included.
21
+ - **Channel adapters** -- Slack (Bolt Socket Mode), Discord, and webhooks. Auto-discovery, session management, notification queuing.
22
+ - **Workflow engine** -- Multi-step workflows with dependency resolution, parallel execution, and conditional branching.
23
+ - **SQLite data layer** -- 27 core tables, migrations, entity context rendering via [latticesql](https://github.com/automated-industries/lattice). WAL mode.
24
+ - **Event-driven hooks** -- Priority-ordered, filter-based event bus for decoupled communication.
21
25
  - **Budget controls** -- Per-agent and global cost tracking with warning thresholds and hard stops.
22
- - **Scheduling** -- Database-backed cron and one-time schedules that fire hook events.
23
- - **Connectors** -- Generic `Connector<T>` interface for external service integrations. Ships with Google Gmail and Calendar implementations (OAuth2 and service account auth).
24
- - **Domain tables** -- `defineDomainTables()` and `defineDomainEntityContexts()` for standard multi-agent app schemas (org, project, client, invoice, repository, and more).
25
- - **Auto-update** -- `autoUpdate()` checks npm for newer versions and installs them at startup.
26
- - **Security** -- Input sanitization, field length enforcement, audit logging, and HMAC webhook verification.
26
+ - **Scheduling** -- Database-backed cron and one-time schedules.
27
+ - **Connectors** -- Google Gmail and Calendar via OAuth2 and service account.
28
+ - **Security** -- Input sanitization, field length enforcement, audit logging, HMAC webhook verification.
27
29
 
28
30
  ## Install
29
31
 
@@ -48,59 +50,60 @@ npm install googleapis
48
50
 
49
51
  ```typescript
50
52
  import {
51
- HookBus,
52
- DataStore,
53
- defineCoreTables,
54
- AgentRegistry,
55
- TaskQueue,
56
- RunManager,
53
+ HookBus, DataStore, defineCoreTables, initConfig,
54
+ TaskQueue, RunManager, WakeupQueue, ChatPipeline,
55
+ registerExecutionEngine, createDefaultLLMCall,
56
+ sendFileTool, readFileTool, listAgentsTool, getTaskStatusTool,
57
57
  } from 'botinabox';
58
+ import { SlackBoltAdapter } from 'botinabox/slack';
59
+ import Anthropic from '@anthropic-ai/sdk';
58
60
 
59
- // 1. Create core services
61
+ // 1. Config (auto-loads botinabox.config.yml or uses defaults)
62
+ initConfig({});
60
63
  const hooks = new HookBus();
61
64
  const db = new DataStore({ dbPath: './data/bot.db', wal: true, hooks });
62
-
63
- // 2. Define tables and initialize
64
65
  defineCoreTables(db);
65
66
  await db.init();
66
67
 
67
- // 3. Set up orchestration
68
- const agents = new AgentRegistry(db, hooks);
68
+ // 2. Orchestration
69
69
  const tasks = new TaskQueue(db, hooks);
70
70
  const runs = new RunManager(db, hooks);
71
-
72
- // 4. Register an agent
73
- const agentId = await agents.register({
74
- slug: 'assistant',
75
- name: 'Assistant',
76
- adapter: 'api',
77
- role: 'general',
78
- });
79
-
80
- // 5. Listen for task creation
81
- hooks.register('task.created', async (ctx) => {
82
- console.log(`Task created: ${ctx.taskId}`);
71
+ const wakeups = new WakeupQueue(db);
72
+
73
+ // 3. Execution engine with built-in tools
74
+ const client = new Anthropic();
75
+ await registerExecutionEngine({
76
+ db, hooks, runs,
77
+ config: {
78
+ client,
79
+ tools: [sendFileTool, readFileTool, listAgentsTool, getTaskStatusTool],
80
+ },
83
81
  });
84
82
 
85
- // 6. Create a task
86
- const taskId = await tasks.create({
87
- title: 'Summarize the quarterly report',
88
- description: 'Read the Q4 report and produce a 3-paragraph summary.',
89
- assignee_id: agentId,
90
- priority: 3,
83
+ // 4. Chat pipeline (6-layer: dedup → ack → interpret → dispatch → execute → respond)
84
+ const llmCall = createDefaultLLMCall(client);
85
+ const pipeline = new ChatPipeline(db, hooks, {
86
+ llmCall, tasks, wakeups,
87
+ systemPrompt: 'You are a helpful AI assistant.',
88
+ routingRules: [{ agentSlug: 'assistant', keywords: ['help'] }],
89
+ fallbackAgent: 'assistant',
91
90
  });
92
91
 
93
- // 7. Wire up task completion hooks
94
- hooks.register('run.completed', async (ctx) => {
95
- console.log(`Run finished for task ${ctx.taskId}, exit code: ${ctx.exitCode}`);
92
+ // 5. Slack (one import, one start)
93
+ const slack = new SlackBoltAdapter({
94
+ botToken: process.env.SLACK_BOT_TOKEN!,
95
+ appToken: process.env.SLACK_APP_TOKEN!,
96
+ hooks, pipeline,
96
97
  });
98
+ await slack.start();
99
+ tasks.startPolling();
97
100
  ```
98
101
 
99
102
  ## Subpath Exports
100
103
 
101
104
  | Import path | Description |
102
105
  |---|---|
103
- | `botinabox` | Core framework -- HookBus, DataStore, AgentRegistry, TaskQueue, RunManager, ChannelRegistry, MessagePipeline, Scheduler, config, security, and all shared types |
106
+ | `botinabox` | Core framework -- HookBus, DataStore, ChatPipeline, ExecutionEngine, 22 built-in tools, config (loadConfig/getConfig), AgentRegistry, TaskQueue, RunManager, Scheduler, MessageStore, ChatResponder, MessageInterpreter, TriageRouter, createDefaultLLMCall, buildSystemContext, and all shared types |
104
107
  | `botinabox/anthropic` | Anthropic Claude provider (`createAnthropicProvider`) |
105
108
  | `botinabox/openai` | OpenAI GPT provider (`createOpenAIProvider`) |
106
109
  | `botinabox/ollama` | Ollama local model provider (`createOllamaProvider`) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "botinabox",
3
- "version": "2.1.3",
3
+ "version": "2.2.0",
4
4
  "description": "Bot in a Box — framework for building multi-agent bots",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -53,13 +53,14 @@
53
53
  "build": "tsup",
54
54
  "test": "vitest run",
55
55
  "typecheck": "tsc --noEmit",
56
- "prepublishOnly": "npm run build && npm run typecheck && npm test"
56
+ "check-docs": "bash scripts/check-docs.sh",
57
+ "prepublishOnly": "npm run build && npm run typecheck && npm test && npm run check-docs"
57
58
  },
58
59
  "dependencies": {
59
60
  "@types/uuid": "^10.0.0",
60
61
  "ajv": "^8.17.1",
61
62
  "cron-parser": "^4.9.0",
62
- "latticesql": "^1.3.1",
63
+ "latticesql": "^1.4.0",
63
64
  "uuid": "^13.0.0",
64
65
  "yaml": "^2.7.0"
65
66
  },