neurohive 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AdelElo13
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,256 @@
1
+ # neurohive
2
+
3
+ Multi-agent memory intelligence — shared knowledge, expertise tracking, and conflict detection for AI agent teams.
4
+
5
+ ![npm version](https://img.shields.io/npm/v/neurohive)
6
+ ![license](https://img.shields.io/npm/l/neurohive)
7
+ ![node](https://img.shields.io/node/v/neurohive)
8
+
9
+ ## Why
10
+
11
+ AI agents in teams forget everything and don't share knowledge. Multiple agents working on the same project re-discover the same facts, contradict each other, and have no collective memory. One agent learns the API timeout is 30 seconds; another assumes 60. Both conclusions sit in separate sessions, never compared.
12
+
13
+ **neurohive** wraps neuromcp with a shared intelligence layer. Every memory stored by any agent becomes visible to the team. Searches come back annotated with who discovered what and when. New agents onboard with the team's existing knowledge already loaded. Contradictions get flagged before they cause incidents.
14
+
15
+ ## Before & After
16
+
17
+ | | neuromcp alone | With neurohive |
18
+ |---|---|---|
19
+ | Agent knowledge | Isolated per session | Shared across team, attributed |
20
+ | Search results | Raw results | Annotated with "discovered by Agent-X, 3 min ago" |
21
+ | New agent onboarding | Starts from zero | Primed with team's top knowledge |
22
+ | Expertise | Unknown who knows what | Tracked: "Agent-Backend: API (31), Auth (22)" |
23
+ | Contradictions | Silently coexist | Flagged: "Backend says 30s timeout, DevOps says 60s" |
24
+ | Team overview | None | Dashboard with knowledge map, gaps, activity |
25
+
26
+ ## Quick Start
27
+
28
+ ```
29
+ npx neurohive
30
+ ```
31
+
32
+ Drop-in replacement for `npx neuromcp`. Use the same MCP config — just swap the command. All neuromcp tools and resources are available unchanged, plus three new neurohive tools, five new resources, and automatic cross-agent annotation.
33
+
34
+ ## Features
35
+
36
+ ### Cross-Agent Annotations
37
+
38
+ Every search result is annotated with provenance: which agent stored it, how long ago, and how many times it's been retrieved. Agents can see at a glance whether a memory came from a trusted teammate or an unknown source.
39
+
40
+ ### Agent Priming
41
+
42
+ When an agent starts up, it reads the `hivemind://priming` resource to load the team's top knowledge, recent activity, and known gaps. No cold starts.
43
+
44
+ ### Expertise Tracking
45
+
46
+ Every time an agent stores a memory, neurohive updates that agent's expertise profile — tracking which categories they contribute to most. Use `hivemind_expertise` to route questions: "who knows the most about authentication?"
47
+
48
+ ### Conflict Detection
49
+
50
+ When two agents store contradictory claims about the same fact, neurohive flags it as a conflict. Conflicts surface in `hivemind_conflicts` and in the dashboard so the team can resolve them explicitly rather than letting stale data propagate silently.
51
+
52
+ ### Dashboard
53
+
54
+ A single command gives a live view of the collective knowledge base: total memories, active agents, top categories, recent activity, unresolved conflicts, and knowledge gaps.
55
+
56
+ ## Installation
57
+
58
+ ### Claude Code
59
+
60
+ ```json
61
+ {
62
+ "mcpServers": {
63
+ "neurohive": {
64
+ "command": "npx",
65
+ "args": ["neurohive"],
66
+ "env": {
67
+ "HIVEMIND_COMPANY": "my-project",
68
+ "HIVEMIND_AGENT": "Agent-Backend",
69
+ "HIVEMIND_AGENT_ROLE": "backend"
70
+ }
71
+ }
72
+ }
73
+ }
74
+ ```
75
+
76
+ ### Claude Desktop
77
+
78
+ ```json
79
+ {
80
+ "mcpServers": {
81
+ "neurohive": {
82
+ "command": "npx",
83
+ "args": ["-y", "neurohive"],
84
+ "env": {
85
+ "HIVEMIND_COMPANY": "my-project",
86
+ "HIVEMIND_AGENT": "Agent-Frontend"
87
+ }
88
+ }
89
+ }
90
+ }
91
+ ```
92
+
93
+ ### Cursor
94
+
95
+ ```json
96
+ {
97
+ "mcpServers": {
98
+ "neurohive": {
99
+ "command": "npx",
100
+ "args": ["neurohive"],
101
+ "env": {
102
+ "HIVEMIND_COMPANY": "my-project",
103
+ "HIVEMIND_AGENT": "Cursor-Agent"
104
+ }
105
+ }
106
+ }
107
+ }
108
+ ```
109
+
110
+ ### Paperclip Mode
111
+
112
+ When [Paperclip](https://github.com/paperclipai/paperclip) is running locally, neurohive detects it automatically and reads the company, agent, and role from the Paperclip API. No extra env vars needed — the company namespace is set from the active Paperclip company, and each agent is identified by its Paperclip identity.
113
+
114
+ Manual fallback (when Paperclip is not running):
115
+
116
+ ```
117
+ HIVEMIND_PAPERCLIP_URL=http://localhost:3100 # default
118
+ HIVEMIND_COMPANY=my-project
119
+ HIVEMIND_AGENT=Agent-Backend
120
+ HIVEMIND_AGENT_ROLE=backend
121
+ ```
122
+
123
+ ## CLI Commands
124
+
125
+ | Command | Description |
126
+ |---------|-------------|
127
+ | `neurohive` | Start as MCP server (stdio) |
128
+ | `neurohive dashboard` | Print team knowledge dashboard |
129
+ | `neurohive expertise [topic\|agent_id]` | Show expertise map or look up a topic/agent |
130
+ | `neurohive conflicts [--all]` | List unresolved conflicts (--all includes resolved) |
131
+ | `neurohive doctor` | Health check: DB path, agent config, Paperclip status |
132
+
133
+ ## Configuration
134
+
135
+ ### neurohive variables
136
+
137
+ | Variable | Default | Description |
138
+ |----------|---------|-------------|
139
+ | `HIVEMIND_COMPANY` | `""` | Company/project name. Sets the shared namespace to `company-<name>` |
140
+ | `HIVEMIND_AGENT` | `""` | Agent identifier (e.g. `Agent-Backend`, `Agent-DevOps`) |
141
+ | `HIVEMIND_AGENT_ROLE` | `""` | Agent role label for priming context |
142
+ | `HIVEMIND_PAPERCLIP_URL` | `http://localhost:3100` | Paperclip API URL for auto-detection |
143
+ | `HIVEMIND_PRIMING_COUNT` | `10` | Number of top memories to include in priming context |
144
+ | `HIVEMIND_PRIMING_CATEGORIES` | `""` | Comma-separated categories to prioritize in priming |
145
+
146
+ ### neuromcp pass-through
147
+
148
+ All `NEUROMCP_*` environment variables pass through unchanged. Key ones:
149
+
150
+ | Variable | Default | Description |
151
+ |----------|---------|-------------|
152
+ | `NEUROMCP_DB_PATH` | `~/.neuromcp/memory.db` | SQLite database path |
153
+ | `NEUROMCP_LOG_LEVEL` | `info` | Log level: `debug`, `info`, `warn`, `error` |
154
+ | `NEUROMCP_EMBEDDING_PROVIDER` | `local` | Embedding provider: `local`, `openai`, `ollama` |
155
+ | `OPENAI_API_KEY` | — | Required when using OpenAI embeddings |
156
+
157
+ ## MCP Surface
158
+
159
+ neurohive exposes 16 tools, 18 resources, and 3 prompts.
160
+
161
+ ### Tools
162
+
163
+ **13 neuromcp tools (unchanged):**
164
+
165
+ | Tool | Description |
166
+ |------|-------------|
167
+ | `store_memory` | Store memory with hive annotations |
168
+ | `search_memory` | Hybrid search with cross-agent attribution |
169
+ | `recall_memory` | Recall by ID, namespace, category, or tags |
170
+ | `forget_memory` | Soft-delete memories by filter |
171
+ | `consolidate` | Merge duplicates, decay stale, prune low-value |
172
+ | `memory_stats` | Count, category, and trust-level statistics |
173
+ | `export_memories` | Export as JSONL or JSON |
174
+ | `import_memories` | Import with deduplication |
175
+ | `backfill_embeddings` | Recompute missing embeddings |
176
+ | `create_entity` | Create/update knowledge graph entity |
177
+ | `create_relation` | Link entities in knowledge graph |
178
+ | `query_graph` | Traverse knowledge graph |
179
+ | `search_claims` | Search atomic extracted claims |
180
+
181
+ **3 neurohive tools:**
182
+
183
+ | Tool | Description |
184
+ |------|-------------|
185
+ | `hivemind_status` | Team dashboard: agents, categories, conflicts, activity |
186
+ | `hivemind_expertise` | Query who knows what; get agent expertise profiles |
187
+ | `hivemind_conflicts` | List/resolve inter-agent contradictions |
188
+
189
+ ### Resources
190
+
191
+ **13 neuromcp resources** (memory, graph, priming, stats) plus **5 neurohive resources:**
192
+
193
+ | Resource URI | Description |
194
+ |---|---|
195
+ | `hivemind://priming` | Startup context: dashboard + top knowledge for onboarding |
196
+ | `hivemind://expertise` | All agent expertise data as JSON |
197
+ | `hivemind://conflicts` | Unresolved conflicts as JSON |
198
+ | `hivemind://dashboard` | Full dashboard data as JSON |
199
+ | `hivemind://agent/{agentId}` | Expertise profile for a specific agent |
200
+
201
+ ### Prompts
202
+
203
+ 3 neuromcp prompts: `store_memory_prompt`, `search_memory_prompt`, `session_summary_prompt`.
204
+
205
+ ## Paperclip Integration
206
+
207
+ neurohive probes `HIVEMIND_PAPERCLIP_URL` on startup. If the Paperclip API responds:
208
+
209
+ 1. **Namespace** is set to `company-<companyId>` — all agents on the same Paperclip company share one knowledge base.
210
+ 2. **Agent identity** is read from the Paperclip agent record, so each agent in a fleet is automatically identified.
211
+ 3. **Role** is pulled from the agent definition, used to enrich priming context ("you are the backend agent; here's what your team knows").
212
+
213
+ If Paperclip is not running, neurohive falls back to `HIVEMIND_COMPANY` / `HIVEMIND_AGENT` env vars with no loss of functionality.
214
+
215
+ ## Requirements
216
+
217
+ | Requirement | Required | Notes |
218
+ |-------------|----------|-------|
219
+ | Node.js >= 18 | Yes | ESM runtime |
220
+ | neuromcp | Yes | Installed automatically as a dependency |
221
+ | Paperclip | No | Auto-detected when running at the configured URL |
222
+ | OpenAI API key | No | Only if using OpenAI embeddings |
223
+
224
+ ## Platform Support
225
+
226
+ | Platform | Status |
227
+ |----------|--------|
228
+ | macOS | Full support |
229
+ | Linux | Full support |
230
+ | WSL2 | Supported |
231
+ | Windows (native) | Not supported |
232
+
233
+ ## FAQ
234
+
235
+ **Is this a replacement for neuromcp?**
236
+ Yes and no. neurohive runs on top of neuromcp and re-exports all its tools, resources, and prompts. If you run a single agent, it's functionally identical to neuromcp with a few extra tools. The value emerges with two or more agents sharing the same `HIVEMIND_COMPANY` namespace.
237
+
238
+ **Do all agents share one database?**
239
+ Yes — agents in the same company namespace share a database via the shared filesystem path (`NEUROMCP_DB_PATH`). This works naturally in multi-agent setups on the same machine (Paperclip, dmux, parallel Claude Code sessions). For distributed setups, point all agents to a shared NFS or networked path.
240
+
241
+ **What counts as a conflict?**
242
+ When two memories from different agents make contradictory claims about the same subject. Conflict detection runs at store time using the cognitive claims extracted from memory content. You can tune sensitivity or disable it via the neuromcp config.
243
+
244
+ **Will it break my existing neuromcp setup?**
245
+ No. neurohive passes all existing `NEUROMCP_*` env vars through unchanged and writes to the same database. Switching back to `npx neuromcp` works at any time.
246
+
247
+ **How does priming work?**
248
+ At startup, agents that read `hivemind://priming` receive a formatted summary: team size, top categories, most active agents, recent memories, and any open conflicts. This is designed to be included in a system prompt or read via a hook on session start.
249
+
250
+ ## Contributing
251
+
252
+ See [CONTRIBUTING.md](./CONTRIBUTING.md).
253
+
254
+ ## License
255
+
256
+ MIT — see [LICENSE](./LICENSE).
package/bin/cli.mjs ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import { main } from '../dist/index.js';
3
+
4
+ main(process.argv.slice(2)).catch((error) => {
5
+ const message = error instanceof Error ? error.message : String(error);
6
+ const stack = error instanceof Error ? error.stack : undefined;
7
+ process.stderr.write(`Fatal error: ${message}\n`);
8
+ if (stack !== undefined) {
9
+ process.stderr.write(`${stack}\n`);
10
+ }
11
+ process.exit(1);
12
+ });
@@ -0,0 +1,45 @@
1
+ import { NeuromcpConfig } from 'neuromcp/config';
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { ServerDeps } from 'neuromcp/server';
4
+ import { StoreInput, StoreDeps } from 'neuromcp/tools/store';
5
+ import { SearchInput, SearchDeps } from 'neuromcp/tools/search';
6
+ import { MemoryWithScore, StoreResultExtended } from 'neuromcp/types';
7
+
8
+ interface HiveConfig extends NeuromcpConfig {
9
+ readonly paperclipUrl: string;
10
+ readonly hiveCompany: string;
11
+ readonly hiveAgent: string;
12
+ readonly hiveAgentRole: string;
13
+ readonly primingCount: number;
14
+ readonly primingCategories: readonly string[];
15
+ }
16
+ declare function loadHiveConfig(): HiveConfig;
17
+
18
+ declare function createHiveServer(deps: ServerDeps, hiveConfig: HiveConfig): McpServer;
19
+
20
+ interface HiveStoreResult extends StoreResultExtended {
21
+ readonly _hivemind: {
22
+ readonly agent_id: string;
23
+ readonly expertise_updated: boolean;
24
+ readonly conflicts_recorded: number;
25
+ };
26
+ }
27
+ interface HiveSearchResult extends MemoryWithScore {
28
+ readonly _hivemind: {
29
+ readonly stored_by: string | null;
30
+ readonly stored_at: string;
31
+ readonly is_recent: boolean;
32
+ };
33
+ }
34
+ /**
35
+ * Wraps neuromcp's storeMemory with expertise tracking and conflict recording.
36
+ */
37
+ declare function hiveStore(input: StoreInput, deps: StoreDeps, agentId: string): Promise<HiveStoreResult>;
38
+ /**
39
+ * Wraps neuromcp's searchMemory with neurohive annotations.
40
+ */
41
+ declare function hiveSearch(input: SearchInput, deps: SearchDeps): Promise<readonly HiveSearchResult[]>;
42
+
43
+ declare function main(args: string[]): Promise<void>;
44
+
45
+ export { createHiveServer, hiveSearch, hiveStore, loadHiveConfig, main };