@sesamespace/hivemind 0.8.9 → 0.8.11
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/MEMORY-ENHANCEMENT-PLAN.md +211 -0
- package/README.md +2 -0
- package/dist/{chunk-AC6ETJUC.js → chunk-A5LMEJIN.js} +2 -2
- package/dist/{chunk-DDFWLDFN.js → chunk-F6EMICWP.js} +3 -3
- package/dist/{chunk-CMPDA2UR.js → chunk-OG6GPQDK.js} +12 -1
- package/dist/chunk-OG6GPQDK.js.map +1 -0
- package/dist/{chunk-5LQLPBE2.js → chunk-OVRYYS5I.js} +2 -2
- package/dist/{chunk-JLLGBVBX.js → chunk-SMUG64N7.js} +2 -2
- package/dist/{chunk-MOCTUHCJ.js → chunk-XBJGLZ7V.js} +2 -2
- package/dist/commands/fleet.js +3 -3
- package/dist/commands/init.js +3 -3
- package/dist/commands/start.js +3 -3
- package/dist/commands/watchdog.js +3 -3
- package/dist/index.js +2 -2
- package/dist/main.js +6 -6
- package/dist/start.js +1 -1
- package/package.json +4 -2
- package/src/memory/dashboard-integration.ts +295 -0
- package/src/memory/index.ts +187 -0
- package/src/memory/performance-test.ts +208 -0
- package/src/memory/processors/agent-sync.ts +312 -0
- package/src/memory/processors/command-learner.ts +298 -0
- package/src/memory/processors/memory-api-client.ts +105 -0
- package/src/memory/processors/message-flow-integration.ts +168 -0
- package/src/memory/processors/research-digester.ts +204 -0
- package/test-caitlin-access.md +11 -0
- package/dist/chunk-CMPDA2UR.js.map +0 -1
- /package/dist/{chunk-AC6ETJUC.js.map → chunk-A5LMEJIN.js.map} +0 -0
- /package/dist/{chunk-DDFWLDFN.js.map → chunk-F6EMICWP.js.map} +0 -0
- /package/dist/{chunk-5LQLPBE2.js.map → chunk-OVRYYS5I.js.map} +0 -0
- /package/dist/{chunk-JLLGBVBX.js.map → chunk-SMUG64N7.js.map} +0 -0
- /package/dist/{chunk-MOCTUHCJ.js.map → chunk-XBJGLZ7V.js.map} +0 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# Memory Enhancement Plan — Automatic Context Management
|
|
2
|
+
|
|
3
|
+
## Vision
|
|
4
|
+
Transform Hivemind's memory system from passive storage to active context management. Background processes continuously organize, index, and surface relevant information without agent intervention.
|
|
5
|
+
|
|
6
|
+
## Core Enhancements
|
|
7
|
+
|
|
8
|
+
### 1. Code Context Tracking
|
|
9
|
+
**Background Process:** `code-indexer`
|
|
10
|
+
- Monitors file access patterns (which files the agent reads/writes)
|
|
11
|
+
- Extracts key structures: functions, classes, interfaces, schemas
|
|
12
|
+
- Maintains a "working set" of active code elements
|
|
13
|
+
- Updates git commit context automatically
|
|
14
|
+
- Indexes by: project, language, purpose, last-accessed
|
|
15
|
+
|
|
16
|
+
**Data Structure:**
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"type": "code_context",
|
|
20
|
+
"project": "hivemind",
|
|
21
|
+
"file": "packages/runtime/src/agent.ts",
|
|
22
|
+
"elements": [
|
|
23
|
+
{
|
|
24
|
+
"name": "processMessage",
|
|
25
|
+
"type": "function",
|
|
26
|
+
"signature": "(msg: Message): Promise<Response>",
|
|
27
|
+
"purpose": "Core message processing loop",
|
|
28
|
+
"dependencies": ["memory-client", "router"]
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"last_accessed": "2024-01-15T10:30:00Z",
|
|
32
|
+
"access_count": 15,
|
|
33
|
+
"git_context": {
|
|
34
|
+
"branch": "feature/memory-enhancement",
|
|
35
|
+
"last_commit": "abc123",
|
|
36
|
+
"modified": true
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 2. Web Research Digestion
|
|
42
|
+
**Background Process:** `research-digester`
|
|
43
|
+
- Monitors web fetch/browse operations
|
|
44
|
+
- Extracts key concepts, APIs, solutions
|
|
45
|
+
- Links research to active tasks/projects
|
|
46
|
+
- Builds knowledge graph of related concepts
|
|
47
|
+
- Identifies patterns across multiple sources
|
|
48
|
+
|
|
49
|
+
**Data Structure:**
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"type": "research_insight",
|
|
53
|
+
"url": "https://docs.example.com/api",
|
|
54
|
+
"project": "sesame-integration",
|
|
55
|
+
"extracted": {
|
|
56
|
+
"key_concepts": ["OAuth flow", "webhook endpoints"],
|
|
57
|
+
"code_examples": ["const auth = await getToken()..."],
|
|
58
|
+
"warnings": ["Rate limit: 100 req/min"],
|
|
59
|
+
"related_to": ["auth-implementation", "rate-limiting"]
|
|
60
|
+
},
|
|
61
|
+
"timestamp": "2024-01-15T09:00:00Z",
|
|
62
|
+
"referenced_count": 3
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 3. Task State Management
|
|
67
|
+
**Background Process:** `task-tracker`
|
|
68
|
+
- Monitors agent actions and maps to task progress
|
|
69
|
+
- Detects task transitions (started, blocked, completed)
|
|
70
|
+
- Tracks dependencies and blockers
|
|
71
|
+
- Identifies patterns in task completion
|
|
72
|
+
- Surfaces relevant context when returning to a task
|
|
73
|
+
|
|
74
|
+
**Data Structure:**
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"type": "task_state",
|
|
78
|
+
"id": "implement-dashboard",
|
|
79
|
+
"project": "hivemind",
|
|
80
|
+
"status": "in_progress",
|
|
81
|
+
"progress": {
|
|
82
|
+
"completed": ["setup routes", "basic UI"],
|
|
83
|
+
"current": "implement request filtering",
|
|
84
|
+
"next": ["add export functionality", "write tests"]
|
|
85
|
+
},
|
|
86
|
+
"context": {
|
|
87
|
+
"key_files": ["src/dashboard/server.js", "src/dashboard/index.html"],
|
|
88
|
+
"recent_decisions": ["use server-sent events for real-time updates"],
|
|
89
|
+
"blockers": [],
|
|
90
|
+
"time_spent": "3.5 hours"
|
|
91
|
+
},
|
|
92
|
+
"last_updated": "2024-01-15T11:00:00Z"
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 4. Tool Usage Patterns
|
|
97
|
+
**Background Process:** `command-learner`
|
|
98
|
+
- Tracks successful command sequences
|
|
99
|
+
- Identifies common patterns and workflows
|
|
100
|
+
- Builds "recipes" for common tasks
|
|
101
|
+
- Learns from failures and corrections
|
|
102
|
+
- Suggests optimizations
|
|
103
|
+
|
|
104
|
+
**Data Structure:**
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"type": "tool_pattern",
|
|
108
|
+
"name": "github-push-workflow",
|
|
109
|
+
"triggers": ["git push", "push changes"],
|
|
110
|
+
"sequence": [
|
|
111
|
+
{"tool": "git_status", "check": "has_changes"},
|
|
112
|
+
{"tool": "git_add", "params": {"files": "."}}
|
|
113
|
+
{"tool": "git_commit", "params": {"message": "<generated>"}},
|
|
114
|
+
{"tool": "git_push", "params": {"remote": "origin"}}
|
|
115
|
+
],
|
|
116
|
+
"success_rate": 0.95,
|
|
117
|
+
"last_used": "2024-01-15T10:00:00Z",
|
|
118
|
+
"variations": ["with-specific-files", "force-push"]
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 5. Cross-Agent Awareness
|
|
123
|
+
**Background Process:** `agent-sync`
|
|
124
|
+
- Monitors Sesame channels for other agent activity
|
|
125
|
+
- Extracts "public knowledge" from agent interactions
|
|
126
|
+
- Tracks handoff points and collaboration patterns
|
|
127
|
+
- Maintains agent capability registry
|
|
128
|
+
- Identifies complementary skills
|
|
129
|
+
|
|
130
|
+
**Data Structure:**
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"type": "agent_knowledge",
|
|
134
|
+
"agent": "bailey",
|
|
135
|
+
"capabilities": ["rust development", "system architecture"],
|
|
136
|
+
"current_focus": ["hivemind dashboard", "memory optimization"],
|
|
137
|
+
"collaboration_points": [
|
|
138
|
+
{
|
|
139
|
+
"task": "dashboard-implementation",
|
|
140
|
+
"status": "bailey-implementing",
|
|
141
|
+
"handoff_ready": "2024-01-16"
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
"last_seen": "2024-01-15T11:30:00Z"
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Implementation Architecture
|
|
149
|
+
|
|
150
|
+
### Background Process Framework
|
|
151
|
+
```typescript
|
|
152
|
+
interface BackgroundProcess {
|
|
153
|
+
name: string;
|
|
154
|
+
interval: number; // milliseconds
|
|
155
|
+
async run(context: ProcessContext): Promise<void>;
|
|
156
|
+
async shouldRun(context: ProcessContext): Promise<boolean>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
class ProcessManager {
|
|
160
|
+
private processes: Map<string, BackgroundProcess>;
|
|
161
|
+
private memory: MemoryClient;
|
|
162
|
+
|
|
163
|
+
async start() {
|
|
164
|
+
for (const [name, process] of this.processes) {
|
|
165
|
+
setInterval(async () => {
|
|
166
|
+
if (await process.shouldRun(this.context)) {
|
|
167
|
+
await process.run(this.context);
|
|
168
|
+
}
|
|
169
|
+
}, process.interval);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Memory Indexing Strategy
|
|
176
|
+
1. **Write-through cache**: All observations written immediately to L2
|
|
177
|
+
2. **Background indexing**: Processes run every 30s-5min depending on type
|
|
178
|
+
3. **Smart batching**: Group related updates to minimize memory churn
|
|
179
|
+
4. **Relevance scoring**: Continuously update scores based on access patterns
|
|
180
|
+
5. **Compression**: Older entries compressed/summarized, recent kept detailed
|
|
181
|
+
|
|
182
|
+
### Context Injection
|
|
183
|
+
When building LLM prompts, the system will:
|
|
184
|
+
1. Query active task state
|
|
185
|
+
2. Include relevant code context (files, functions being worked on)
|
|
186
|
+
3. Add recent research/documentation insights
|
|
187
|
+
4. Include tool patterns for likely next actions
|
|
188
|
+
5. Add cross-agent awareness if collaborating
|
|
189
|
+
|
|
190
|
+
### Local Processing Power Usage
|
|
191
|
+
- **Embedding generation**: Ollama with local models (no API calls)
|
|
192
|
+
- **Pattern matching**: Rust-based processors for speed
|
|
193
|
+
- **Index management**: LanceDB for vector operations
|
|
194
|
+
- **File watching**: Native OS APIs for efficiency
|
|
195
|
+
- **Git operations**: libgit2 bindings for speed
|
|
196
|
+
|
|
197
|
+
## Benefits
|
|
198
|
+
1. **Zero cognitive load**: Agents don't think about memory management
|
|
199
|
+
2. **Rich context**: Every request includes highly relevant information
|
|
200
|
+
3. **Learning system**: Gets better at predicting needed context over time
|
|
201
|
+
4. **Collaborative**: Agents automatically aware of each other's work
|
|
202
|
+
5. **Efficient**: Background processing keeps LLM calls focused
|
|
203
|
+
|
|
204
|
+
## Next Steps
|
|
205
|
+
1. Implement the background process framework in TypeScript
|
|
206
|
+
2. Create the first processor: `code-indexer`
|
|
207
|
+
3. Test with real agent workflows
|
|
208
|
+
4. Add remaining processors incrementally
|
|
209
|
+
5. Optimize based on dashboard metrics
|
|
210
|
+
|
|
211
|
+
This system will make every Hivemind agent dramatically more capable without any changes to their prompts or behavior.
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
PRIMARY_ROUTES,
|
|
7
7
|
SesameClient2 as SesameClient,
|
|
8
8
|
WORKER_ROUTES
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OG6GPQDK.js";
|
|
10
10
|
|
|
11
11
|
// packages/runtime/src/watchdog.ts
|
|
12
12
|
import { execSync } from "child_process";
|
|
@@ -1048,4 +1048,4 @@ export {
|
|
|
1048
1048
|
WorkerMemorySync,
|
|
1049
1049
|
PrimaryMemorySync
|
|
1050
1050
|
};
|
|
1051
|
-
//# sourceMappingURL=chunk-
|
|
1051
|
+
//# sourceMappingURL=chunk-A5LMEJIN.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Watchdog
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-A5LMEJIN.js";
|
|
4
4
|
import {
|
|
5
5
|
defaultSentinelConfig,
|
|
6
6
|
loadConfig
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-OG6GPQDK.js";
|
|
8
8
|
|
|
9
9
|
// packages/cli/src/commands/watchdog.ts
|
|
10
10
|
import { resolve } from "path";
|
|
@@ -76,4 +76,4 @@ Options:
|
|
|
76
76
|
export {
|
|
77
77
|
runWatchdogCommand
|
|
78
78
|
};
|
|
79
|
-
//# sourceMappingURL=chunk-
|
|
79
|
+
//# sourceMappingURL=chunk-F6EMICWP.js.map
|
|
@@ -6611,6 +6611,17 @@ function startHealthServer(port) {
|
|
|
6611
6611
|
res.end();
|
|
6612
6612
|
}
|
|
6613
6613
|
});
|
|
6614
|
+
server.on("error", (err) => {
|
|
6615
|
+
if (err.code === "EADDRINUSE") {
|
|
6616
|
+
console.warn(`[hivemind] Health port ${port} in use \u2014 retrying in 2s`);
|
|
6617
|
+
setTimeout(() => {
|
|
6618
|
+
server.close();
|
|
6619
|
+
server.listen(port, "127.0.0.1");
|
|
6620
|
+
}, 2e3);
|
|
6621
|
+
} else {
|
|
6622
|
+
console.error("[hivemind] Health server error:", err.message);
|
|
6623
|
+
}
|
|
6624
|
+
});
|
|
6614
6625
|
server.listen(port, "127.0.0.1", () => {
|
|
6615
6626
|
console.log(`[hivemind] Health endpoint listening on http://127.0.0.1:${port}${HEALTH_PATH}`);
|
|
6616
6627
|
});
|
|
@@ -7400,4 +7411,4 @@ smol-toml/dist/index.js:
|
|
|
7400
7411
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
7401
7412
|
*)
|
|
7402
7413
|
*/
|
|
7403
|
-
//# sourceMappingURL=chunk-
|
|
7414
|
+
//# sourceMappingURL=chunk-OG6GPQDK.js.map
|