@keepur/hive 0.1.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.
package/README.md ADDED
@@ -0,0 +1,344 @@
1
+ # Hive
2
+
3
+ A multi-agent AI framework that runs your business operations through Slack. Hive deploys a team of Claude-powered agents — each with its own role, memory, and tools — that collaborate to handle real work: customer emails, CRM updates, task management, scheduling, SMS, and more.
4
+
5
+ ## Why Hive
6
+
7
+ Most AI agent frameworks give you a chatbot. Hive gives you a team.
8
+
9
+ ### The problem with single-agent tools
10
+
11
+ Tools like OpenClaw, CrewAI, and AutoGen are great for demos — chain a few LLM calls together, get a result. But they fall apart when you try to run actual business operations:
12
+
13
+ - **No identity** — every request starts from zero. There's no persistent memory, no role specialization, no sense of "who" is handling what.
14
+ - **No channels** — they live in a notebook or CLI. Your team can't interact with them naturally.
15
+ - **No tools** — connecting to real systems (CRM, email, calendars, project management) requires custom glue code for every integration.
16
+ - **No cost control** — every query hits the most expensive model, even simple ones.
17
+
18
+ ### What Hive does differently
19
+
20
+ | Capability | Hive | Typical agent framework |
21
+ |-----------|------|------------------------|
22
+ | **Agent identity** | Each agent has a name, personality, role, persistent memory, and dedicated Slack channel | Anonymous function chains |
23
+ | **Channel-native** | Lives in Slack — your team @mentions agents like coworkers. Also supports SMS, WebSocket (mobile), and email. | CLI or API-only |
24
+ | **Tool ecosystem** | 20+ MCP servers out of the box — Gmail, Calendar, CRM, GitHub, task management, vector search, SMS, email, browser automation | BYO everything |
25
+ | **Smart routing** | Triage classifies messages, model router picks Haiku/Sonnet/Opus per-turn based on complexity. Simple questions cost pennies. | One model for everything |
26
+ | **Persistent memory** | MongoDB-backed per-agent memory with hot/warm/cold tiers, version history, and semantic recall | Stateless or basic RAG |
27
+ | **Multi-agent coordination** | Flat org with channel-based routing — agents delegate to specialists, no central bottleneck | Sequential chains or rigid DAGs |
28
+ | **Production-ready** | LaunchAgent service, hot-reload, concurrency limits, deduplication, retry queues, structured logging | "Just run the script" |
29
+ | **Plugin system** | Drop in business-specific integrations (CRM, catalog, manufacturing) without touching core | Monolithic |
30
+
31
+ ### Architecture at a glance
32
+
33
+ ```
34
+ Message (Slack / SMS / WebSocket / Scheduler)
35
+ → Channel Adapter
36
+ → Dispatcher (routing, dedup, thread continuity)
37
+ → Triage (fast Haiku: done or continue?)
38
+ → Model Router (Haiku/Sonnet/Opus based on complexity)
39
+ → Agent Runner (Claude session + per-agent MCP servers + memory)
40
+ → Response → Channel Adapter → delivery
41
+ ```
42
+
43
+ ### Who it's for
44
+
45
+ Hive is built for small-to-medium businesses that want AI teammates, not AI toys. If you have a Slack workspace and real operational workflows (sales, support, marketing, ops), Hive turns Claude into a team that works alongside yours.
46
+
47
+ **Requirements**: Mac (tested on Mac Mini M-series), MongoDB, Node.js 22+, a Slack workspace, and an Anthropic API key or Claude Max subscription.
48
+
49
+ ---
50
+
51
+ ## Quick Start
52
+
53
+ ```bash
54
+ # 1. Install prerequisites
55
+ npm run setup:prereqs
56
+
57
+ # 2. Install dependencies and run the setup wizard
58
+ npm install
59
+ npm run setup
60
+
61
+ # 3. Start Hive
62
+ npm start
63
+ ```
64
+
65
+ The setup wizard walks you through everything: Slack app creation, API keys, business context, and service installation. It seeds a **chief-of-staff** agent to start — additional agents are created through it as your needs evolve.
66
+
67
+ ## Prerequisites
68
+
69
+ Mac (tested on Mac Mini M-series) with:
70
+
71
+ - **Node.js 22+** — JavaScript runtime
72
+ - **MongoDB** — database for agent memory, definitions, contacts, and state
73
+ - **Git** — version control
74
+
75
+ The prereqs script installs all of these via Homebrew:
76
+
77
+ ```bash
78
+ npm run setup:prereqs
79
+ ```
80
+
81
+ If you already have them, the script skips what's installed.
82
+
83
+ ## What You'll Need
84
+
85
+ Before running `npm run setup`, have these ready:
86
+
87
+ ### Required
88
+
89
+ - **Slack workspace** you can install apps into
90
+ - **Anthropic API key** or **Claude Max subscription** — if using Max, the SDK authenticates via OAuth automatically (no API key needed)
91
+
92
+ ### Optional (enable as you grow)
93
+
94
+ - **Resend API key** — outbound email per agent
95
+ - **Quo (OpenPhone) API key** — SMS integration
96
+ - **Google account(s)** — Gmail and Calendar access (via `gog` CLI)
97
+ - **HubSpot API key** — CRM read/write
98
+ - **GitHub repo** — issue tracking integration
99
+ - **Brave Search API key** — web search for agents
100
+ - **Gemini API key** — vision/OCR for file attachments
101
+ - **ClickUp / Linear API key** — project management
102
+
103
+ ## Setup Guide
104
+
105
+ ### 1. Create Your Slack App
106
+
107
+ The setup wizard displays a complete app manifest. Here's the short version:
108
+
109
+ 1. Go to https://api.slack.com/apps
110
+ 2. **Create New App** > **From a manifest**
111
+ 3. Select your workspace, choose **YAML** format
112
+ 4. Paste the manifest the wizard shows you
113
+ 5. **Create**, then **Install App** > **Install to workspace**
114
+
115
+ You'll need two tokens:
116
+
117
+ | Token | Where to find it | Looks like |
118
+ |-------|-----------------|------------|
119
+ | App-Level Token | Basic Information > App-Level Tokens > Generate (add `connections:write` scope) | `xapp-...` |
120
+ | Bot Token | OAuth & Permissions > Bot User OAuth Token | `xoxb-...` |
121
+
122
+ **Optional:** For Slack search, grab a User Token (`xoxp-...`) from the same OAuth page.
123
+
124
+ ### 2. Anthropic API Key (or Claude Max)
125
+
126
+ **API key**: Get one from https://console.anthropic.com/settings/keys (starts with `sk-ant-`).
127
+
128
+ **Claude Max**: Leave `ANTHROPIC_API_KEY` blank in `.env`. The Claude Agent SDK authenticates via your logged-in CLI session.
129
+
130
+ ### 3. SMS via Quo (Optional)
131
+
132
+ 1. Get your API key from Quo workspace settings > API tab
133
+ 2. Get your Phone Number ID(s) — they look like `PNxxxxx`
134
+ 3. The wizard will ask you to configure named phone lines
135
+
136
+ ### 4. Google Gmail/Calendar (Optional)
137
+
138
+ Install the [`gog`](https://github.com/jcfisher/gog) CLI:
139
+
140
+ ```bash
141
+ brew install gog
142
+ ```
143
+
144
+ Add accounts:
145
+
146
+ ```bash
147
+ gog auth add you@gmail.com
148
+ # Opens a browser for OAuth — authenticate once, tokens stored locally
149
+
150
+ # Multiple accounts:
151
+ gog auth add work@company.com
152
+ gog auth add sales@company.com
153
+ ```
154
+
155
+ Verify:
156
+
157
+ ```bash
158
+ gog gmail search "is:unread" -a you@gmail.com
159
+ gog cal events --today -a you@gmail.com
160
+ ```
161
+
162
+ ### 5. Email via Resend (Optional)
163
+
164
+ Get an API key from https://resend.com. Configure your sending domain and per-agent from addresses in `hive.yaml`.
165
+
166
+ ## Configuration
167
+
168
+ Hive uses two config files (both generated by the setup wizard, both gitignored):
169
+
170
+ ### `.env` — secrets
171
+
172
+ ```bash
173
+ SLACK_APP_TOKEN=xapp-...
174
+ SLACK_BOT_TOKEN=xoxb-...
175
+ # ANTHROPIC_API_KEY=sk-ant-... # Leave blank if using Claude Max
176
+ # Plus optional: QUO_API_KEY, RESEND_API_KEY, HUBSPOT_API_KEY, etc.
177
+ ```
178
+
179
+ ### `hive.yaml` — instance config
180
+
181
+ ```yaml
182
+ business:
183
+ name: "Your Business Name"
184
+ description: "what your business does"
185
+ location: "City, State"
186
+ owner:
187
+ name: "Your Name"
188
+ role: "CEO"
189
+
190
+ # plugins:
191
+ # - your-plugin # Business-specific integrations
192
+ ```
193
+
194
+ See `hive.yaml.example` for all options including SMS lines, email, and Google Workspace.
195
+
196
+ ## Agents
197
+
198
+ Hive starts with a single **chief-of-staff** agent. More agents are created as your needs evolve — no need to configure them all upfront.
199
+
200
+ Agent definitions live in **MongoDB** (not the filesystem). Each agent definition contains:
201
+
202
+ | Field | Purpose |
203
+ |-------|---------|
204
+ | `model` | Model ceiling (haiku, sonnet, opus) |
205
+ | `channels` | Which Slack channels this agent responds in |
206
+ | `servers` | Which MCP tool servers this agent can use |
207
+ | `soul` | Personality, values, voice |
208
+ | `systemPrompt` | Role definition, guidelines, tool instructions |
209
+ | `schedule` | Cron expressions for recurring tasks |
210
+
211
+ Manage agents via the admin MCP tools or the REST API. Changes take effect on hot-reload (SIGUSR1) — no restart needed.
212
+
213
+ ## Memory
214
+
215
+ Agent memory is stored in **MongoDB** with version history and semantic recall:
216
+
217
+ | Collection | Purpose |
218
+ |-----------|---------|
219
+ | `memory` | Current memory records (hot/warm/cold tiers) |
220
+ | `memory_versions` | Full version history of every change |
221
+ | `agent_definitions` | Agent configs, prompts, personality |
222
+ | `agent_sessions` | Active session state |
223
+
224
+ Agents read and write memory through the memory MCP server. Memory is structured with tiered lifecycle management — frequently accessed records stay hot (injected into prompts), less-used records drop to warm (semantic recall on demand), and stale records are summarized and archived.
225
+
226
+ ## MCP Tool Servers
227
+
228
+ Each agent gets a tailored set of MCP servers based on its role. Available servers:
229
+
230
+ | Server | What it does |
231
+ |--------|-------------|
232
+ | **memory** | Read/write/recall agent memory (MongoDB) |
233
+ | **slack** | Slack API (official HTTP MCP server) |
234
+ | **google** | Gmail + Calendar via `gog` CLI |
235
+ | **contacts** | Contact lookups |
236
+ | **github-issues** | GitHub issue tracking via `gh` CLI |
237
+ | **crm-search** | Semantic search over CRM data (Qdrant) |
238
+ | **resend** | Outbound email |
239
+ | **quo** | SMS via OpenPhone |
240
+ | **schedule** | Self-service schedule management |
241
+ | **callback** | Timer-based delayed responses |
242
+ | **background** | Spawn long-running tasks |
243
+ | **admin** | Agent CRUD + version history |
244
+ | **keychain** | macOS Keychain read-only |
245
+ | **brave-search** | Web search |
246
+ | **recall** | Meeting participation via Recall.ai |
247
+ | **code-task** | Delegate coding to Claude Code CLI |
248
+
249
+ Plugins can add more (e.g., HubSpot CRM, product catalog, permit management).
250
+
251
+ ## Running Hive
252
+
253
+ ```bash
254
+ # Production (compiled)
255
+ npm start
256
+
257
+ # Development (live reload)
258
+ npm run dev
259
+
260
+ # View logs
261
+ tail -f logs/hive.log
262
+ ```
263
+
264
+ ### Run as a LaunchAgent (starts on login)
265
+
266
+ The setup wizard offers to install as a LaunchAgent. Manually:
267
+
268
+ ```bash
269
+ bash service/install.sh
270
+ ```
271
+
272
+ Manage the service:
273
+
274
+ ```bash
275
+ # Restart
276
+ launchctl kickstart -k gui/$(id -u)/com.hive.agent
277
+
278
+ # Stop
279
+ launchctl bootout gui/$(id -u)/com.hive.agent
280
+
281
+ # Start
282
+ launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.hive.agent.plist
283
+ ```
284
+
285
+ ## Plugins
286
+
287
+ Business-specific integrations live in `plugins/<name>/`. A plugin can include:
288
+
289
+ - **MCP servers** — domain-specific tools (CRM, catalog, manufacturing)
290
+ - **Agent seeds** — starter agent definitions imported via `npm run setup:seeds`
291
+
292
+ Enable plugins in `hive.yaml`:
293
+
294
+ ```yaml
295
+ plugins:
296
+ - your-plugin
297
+ ```
298
+
299
+ ## Dev vs Deploy
300
+
301
+ | | Dev | Deploy |
302
+ |---|-----|--------|
303
+ | **Path** | `~/github/hive` | `~/services/hive` |
304
+ | **Purpose** | Edit, test, commit, push | Compiled JS, launchd runs here |
305
+ | **Deploy** | — | `deploy.sh` pulls, builds, syncs, restarts |
306
+
307
+ Editing source in dev does **not** affect the running service.
308
+
309
+ ## Updating
310
+
311
+ ```bash
312
+ npm run update
313
+ ```
314
+
315
+ Pulls latest code, installs dependencies, and rebuilds. Your `hive.yaml`, `.env`, and agent definitions (in MongoDB) are preserved.
316
+
317
+ ## npm Scripts
318
+
319
+ | Script | What it does |
320
+ |--------|-------------|
321
+ | `npm start` | Start Hive (production, compiled) |
322
+ | `npm run dev` | Start Hive (development, live reload) |
323
+ | `npm run build` | Compile TypeScript (core + plugins) |
324
+ | `npm run setup` | Interactive setup wizard |
325
+ | `npm run setup:prereqs` | Install Homebrew, Node.js, MongoDB, Git |
326
+ | `npm run setup:seeds` | Import plugin agent seeds → MongoDB |
327
+ | `npm run setup:constitution` | Render shared constitution → MongoDB |
328
+ | `npm run setup:plist` | Regenerate the launchd plist |
329
+ | `npm run update` | Pull latest, install deps, rebuild |
330
+ | `npm run check` | All checks (typecheck + lint + format + test) |
331
+
332
+ ## Troubleshooting
333
+
334
+ | Problem | Fix |
335
+ |---------|-----|
336
+ | Agent not responding | Check `logs/hive.log` for errors. Verify Slack tokens in `.env`. |
337
+ | MCP server changes not taking effect | Run `npm run build` AND restart Hive — MCP servers run from compiled `dist/`. |
338
+ | Agent config changes not taking effect | Send SIGUSR1 to hot-reload: `kill -USR1 $(pgrep -f "node dist/index")` |
339
+ | Slack connection drops | Check `SLACK_APP_TOKEN` has `connections:write` scope. Socket Mode must be enabled. |
340
+ | MongoDB connection refused | Ensure MongoDB is running: `brew services start mongodb-community` |
341
+
342
+ ## License
343
+
344
+ Private — access by invitation only.
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "@keepur/hive",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "bin": {
6
+ "hive": "pkg/cli.min.js"
7
+ },
8
+ "files": [
9
+ "pkg/",
10
+ "seeds/",
11
+ "templates/"
12
+ ],
13
+ "engines": {
14
+ "node": ">=22.0.0"
15
+ },
16
+ "scripts": {
17
+ "build": "tsc && tsc -p tsconfig.plugins.json",
18
+ "build:plugins": "tsc -p tsconfig.plugins.json",
19
+ "start": "node dist/index.js",
20
+ "dev": "npx tsx src/index.ts",
21
+ "setup": "npx tsx src/setup/wizard.ts",
22
+ "setup:instance": "npx tsx setup/setup-instance.ts",
23
+ "setup:prereqs": "bash setup/install-prereqs.sh",
24
+ "setup:constitution": "npx tsx setup/setup-constitution.ts",
25
+ "setup:seeds": "npx tsx setup/setup-seeds.ts",
26
+ "setup:plugins": "npx tsx setup/sync-plugins.ts",
27
+ "migrate:agents:legacy": "npx tsx setup/migrate-agents.ts",
28
+ "setup:plist": "npx tsx setup/generate-plist.ts",
29
+ "update": "git pull && npm install && npm run build",
30
+ "embed:hubspot": "npx tsx scripts/hubspot-embed.ts",
31
+ "embed:dodi": "npx tsx scripts/dodi-embed.ts",
32
+ "lint": "eslint src/ plugins/ setup/",
33
+ "lint:fix": "eslint --fix src/ plugins/ setup/",
34
+ "format": "prettier --write \"src/**/*.ts\" \"plugins/**/*.ts\" \"setup/**/*.ts\"",
35
+ "format:check": "prettier --check \"src/**/*.ts\" \"plugins/**/*.ts\" \"setup/**/*.ts\"",
36
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.plugins.json",
37
+ "test": "vitest run",
38
+ "test:watch": "vitest",
39
+ "test:coverage": "vitest run --coverage",
40
+ "check": "npm run typecheck && npm run lint && npm run format:check && npm run test",
41
+ "bundle": "npm run build && npx tsx build/bundle.ts",
42
+ "prepublishOnly": "npm run bundle"
43
+ },
44
+ "lint-staged": {
45
+ "*.ts": [
46
+ "eslint --fix",
47
+ "prettier --write"
48
+ ]
49
+ },
50
+ "dependencies": {
51
+ "@anthropic-ai/claude-agent-sdk": "^0.2.63",
52
+ "@anthropic-ai/sdk": "^0.82.0",
53
+ "@dodi-hq/fsm-persistence": "^0.1.1",
54
+ "@dodi-hq/task-core": "^0.1.1",
55
+ "@dodi-hq/workflow-core": "^0.1.1",
56
+ "@linear/sdk": "^76.0.0",
57
+ "@modelcontextprotocol/sdk": "^1.27.1",
58
+ "@qdrant/js-client-rest": "^1.17.0",
59
+ "@slack/socket-mode": "^2.0.5",
60
+ "@slack/web-api": "^7.14.1",
61
+ "better-sqlite3": "^12.8.0",
62
+ "brave-search-mcp": "^2.0.1",
63
+ "csv-parse": "^6.1.0",
64
+ "dotenv": "^17.3.1",
65
+ "jsonwebtoken": "^9.0.3",
66
+ "mammoth": "^1.11.0",
67
+ "mongodb": "^7.1.0",
68
+ "pdf-parse": "^2.4.5",
69
+ "ws": "^8.19.0",
70
+ "xlsx": "^0.18.5",
71
+ "yaml": "^2.8.2"
72
+ },
73
+ "devDependencies": {
74
+ "@eslint/js": "^9.0.0",
75
+ "@types/better-sqlite3": "^7.6.13",
76
+ "@types/jsonwebtoken": "^9.0.10",
77
+ "@types/node": "^22.0.0",
78
+ "@types/ws": "^8.18.1",
79
+ "esbuild": "^0.28.0",
80
+ "eslint": "^9.0.0",
81
+ "eslint-config-prettier": "^10.0.0",
82
+ "husky": "^9.0.0",
83
+ "lint-staged": "^15.0.0",
84
+ "prettier": "^3.0.0",
85
+ "tsx": "^4.19.0",
86
+ "typescript": "^5.7.0",
87
+ "typescript-eslint": "^8.0.0",
88
+ "vitest": "^3.0.0"
89
+ }
90
+ }