monomind 2.1.9 → 2.3.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/package.json +2 -2
- package/packages/@monomind/cli/.claude/commands/mastermind/createorg.md +24 -16
- package/packages/@monomind/cli/.claude/commands/mastermind/master.md +23 -7
- package/packages/@monomind/cli/.claude/commands/mastermind/runorg.md +3 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/stoporg.md +6 -3
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/code-quality-reviewer-prompt.md +3 -3
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/createorg.md +19 -24
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/debug.md +49 -4
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/design.md +11 -10
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/final-reviewer-prompt.md +144 -0
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/implementer-prompt.md +9 -4
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/org-settings.md +20 -2
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/orgs.md +40 -19
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/orgstatus.md +90 -41
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/plan.md +19 -0
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/skill-builder.md +171 -0
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/spec-reviewer-prompt.md +19 -2
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/stoporg.md +7 -5
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/taskdev.md +83 -15
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/tdd.md +30 -0
- package/packages/@monomind/cli/dist/src/autopilot-state.js +6 -4
- package/packages/@monomind/cli/dist/src/browser/dashboard/server.js +4 -1
- package/packages/@monomind/cli/dist/src/capabilities/manager.js +3 -1
- package/packages/@monomind/cli/dist/src/commands/agent-lifecycle.js +26 -0
- package/packages/@monomind/cli/dist/src/commands/agent-ops.js +28 -46
- package/packages/@monomind/cli/dist/src/commands/cleanup.d.ts +18 -0
- package/packages/@monomind/cli/dist/src/commands/cleanup.js +120 -0
- package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.js +13 -4
- package/packages/@monomind/cli/dist/src/commands/hooks-routing-commands.js +34 -18
- package/packages/@monomind/cli/dist/src/commands/hooks-workers.js +8 -2
- package/packages/@monomind/cli/dist/src/commands/hooks.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/init-wizard.js +2 -2
- package/packages/@monomind/cli/dist/src/commands/init.js +54 -10
- package/packages/@monomind/cli/dist/src/commands/mcp.js +4 -1
- package/packages/@monomind/cli/dist/src/commands/memory-admin.js +7 -1
- package/packages/@monomind/cli/dist/src/commands/org-observe.d.ts +18 -0
- package/packages/@monomind/cli/dist/src/commands/org-observe.js +295 -0
- package/packages/@monomind/cli/dist/src/commands/org.d.ts +9 -1
- package/packages/@monomind/cli/dist/src/commands/org.js +191 -9
- package/packages/@monomind/cli/dist/src/commands/performance.js +4 -1
- package/packages/@monomind/cli/dist/src/commands/platforms.js +4 -1
- package/packages/@monomind/cli/dist/src/commands/security-scan.js +8 -2
- package/packages/@monomind/cli/dist/src/commands/start.js +4 -1
- package/packages/@monomind/cli/dist/src/commands/swarm.js +5 -4
- package/packages/@monomind/cli/dist/src/index.js +13 -3
- package/packages/@monomind/cli/dist/src/init/executor.js +19 -5
- package/packages/@monomind/cli/dist/src/init/settings-generator.js +8 -1
- package/packages/@monomind/cli/dist/src/knowledge/document-pipeline.js +3 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.d.ts +1 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.js +63 -20
- package/packages/@monomind/cli/dist/src/mcp-tools/claims-tools.js +3 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/config-tools.js +3 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/daa-tools.js +3 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/embeddings-tools.js +6 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/github-tools.js +35 -10
- package/packages/@monomind/cli/dist/src/mcp-tools/hive-mind-tools.js +24 -7
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-embedding.js +13 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-intelligence.js +9 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-routing.d.ts +1 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-routing.js +112 -10
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-tools.js +2 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +8 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/performance-tools.js +3 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/session-tools.js +15 -5
- package/packages/@monomind/cli/dist/src/mcp-tools/swarm-tools.js +4 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/system-tools.js +6 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/task-tools.d.ts +20 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/task-tools.js +38 -16
- package/packages/@monomind/cli/dist/src/mcp-tools/terminal-tools.d.ts +2 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/terminal-tools.js +68 -24
- package/packages/@monomind/cli/dist/src/memory/ewc-consolidation.js +6 -2
- package/packages/@monomind/cli/dist/src/memory/intelligence.js +32 -10
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +16 -4
- package/packages/@monomind/cli/dist/src/memory/memory-crud.js +26 -2
- package/packages/@monomind/cli/dist/src/memory/memory-initializer.js +3 -2
- package/packages/@monomind/cli/dist/src/memory/memory-migrations.js +2 -0
- package/packages/@monomind/cli/dist/src/monovector/command-outcomes.js +4 -1
- package/packages/@monomind/cli/dist/src/orgrt/bus.js +4 -1
- package/packages/@monomind/cli/dist/src/orgrt/daemon.js +74 -19
- package/packages/@monomind/cli/dist/src/orgrt/inbox.js +3 -1
- package/packages/@monomind/cli/dist/src/orgrt/reporting.d.ts +40 -0
- package/packages/@monomind/cli/dist/src/orgrt/reporting.js +127 -0
- package/packages/@monomind/cli/dist/src/orgrt/session.d.ts +2 -0
- package/packages/@monomind/cli/dist/src/orgrt/session.js +10 -2
- package/packages/@monomind/cli/dist/src/orgrt/templates.d.ts +16 -0
- package/packages/@monomind/cli/dist/src/orgrt/templates.js +57 -0
- package/packages/@monomind/cli/dist/src/services/config-file-manager.js +10 -1
- package/packages/@monomind/cli/dist/src/transfer/storage/gcs.js +6 -2
- package/packages/@monomind/cli/dist/src/ui/orgs.html +32 -0
- package/packages/@monomind/cli/dist/src/ui/server.mjs +25 -0
- package/packages/@monomind/cli/dist/src/update/executor.js +3 -1
- package/packages/@monomind/cli/dist/src/update/rate-limiter.js +3 -1
- package/packages/@monomind/cli/package.json +2 -2
|
@@ -30,21 +30,35 @@ const MAX_AGENT_STORE_BYTES = 50 * 1024 * 1024;
|
|
|
30
30
|
// (e.g. hive-mind-tools.ts) can reuse this hardened loader instead of
|
|
31
31
|
// maintaining their own weaker copy (missing the size cap / __proto__ guard).
|
|
32
32
|
export function loadAgentStore() {
|
|
33
|
+
return loadAgentStoreOrNull() ?? { agents: {}, version: '3.0.0' };
|
|
34
|
+
}
|
|
35
|
+
// Like loadAgentStore(), but distinguishes "file doesn't exist yet" (returns
|
|
36
|
+
// the empty default store — safe to build on and save) from "file exists but
|
|
37
|
+
// failed to read/parse, or is corrupt/oversized" (returns null). Handlers
|
|
38
|
+
// that are about to mutate-and-save MUST use this instead of loadAgentStore()
|
|
39
|
+
// and bail out on null, or a transient read failure silently wipes every
|
|
40
|
+
// previously-spawned agent on the next save (the exact bug found and fixed
|
|
41
|
+
// in task-tools.ts's task_assign earlier this session — same pattern here).
|
|
42
|
+
// Exported for other tool modules with their own mutate-and-save paths
|
|
43
|
+
// against the same agent store file — see hive-mind-tools.ts.
|
|
44
|
+
export function loadAgentStoreOrNull() {
|
|
33
45
|
try {
|
|
34
46
|
const path = getAgentPath();
|
|
35
47
|
migrateLegacyStoreFile(path, join(AGENT_DIR, AGENT_FILE));
|
|
36
48
|
if (existsSync(path)) {
|
|
37
49
|
if (statSync(path).size > MAX_AGENT_STORE_BYTES)
|
|
38
|
-
return
|
|
50
|
+
return null;
|
|
39
51
|
const data = readFileSync(path, 'utf-8');
|
|
40
52
|
const parsed = JSON.parse(data);
|
|
41
53
|
if (parsed && typeof parsed === 'object' && Object.prototype.hasOwnProperty.call(parsed, '__proto__'))
|
|
42
|
-
return
|
|
54
|
+
return null;
|
|
43
55
|
return parsed;
|
|
44
56
|
}
|
|
45
57
|
}
|
|
46
|
-
catch {
|
|
47
|
-
|
|
58
|
+
catch (e) {
|
|
59
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
60
|
+
console.error('[loadAgentStore] failed to read/parse agent store — refusing to proceed to avoid overwriting it with an empty one:', e);
|
|
61
|
+
return null;
|
|
48
62
|
}
|
|
49
63
|
return { agents: {}, version: '3.0.0' };
|
|
50
64
|
}
|
|
@@ -126,7 +140,10 @@ export const agentTools = [
|
|
|
126
140
|
required: ['agentType'],
|
|
127
141
|
},
|
|
128
142
|
handler: async (input) => {
|
|
129
|
-
const store =
|
|
143
|
+
const store = loadAgentStoreOrNull();
|
|
144
|
+
if (!store) {
|
|
145
|
+
return { success: false, error: 'Agent store is unreadable/corrupt — refusing to spawn to avoid overwriting real agent data. Retry, or check the store file if this persists.' };
|
|
146
|
+
}
|
|
130
147
|
// Cap agentId: used as the JSON object key in store.agents[agentId].
|
|
131
148
|
// An oversized key inflates the on-disk store for every spawned agent.
|
|
132
149
|
// Cap agentType/domain: persisted as AgentRecord field values.
|
|
@@ -215,7 +232,10 @@ export const agentTools = [
|
|
|
215
232
|
if (!agentId || typeof agentId !== 'string' || ['__proto__', 'constructor', 'prototype'].includes(agentId)) {
|
|
216
233
|
return { success: false, agentId, error: 'Invalid agent ID' };
|
|
217
234
|
}
|
|
218
|
-
const store =
|
|
235
|
+
const store = loadAgentStoreOrNull();
|
|
236
|
+
if (!store) {
|
|
237
|
+
return { success: false, agentId, error: 'Agent store is unreadable/corrupt — refusing to terminate to avoid overwriting real agent data.' };
|
|
238
|
+
}
|
|
219
239
|
if (Object.hasOwn(store.agents, agentId)) {
|
|
220
240
|
store.agents[agentId].status = 'terminated';
|
|
221
241
|
saveAgentStore(store);
|
|
@@ -277,25 +297,35 @@ export const agentTools = [
|
|
|
277
297
|
inputSchema: {
|
|
278
298
|
type: 'object',
|
|
279
299
|
properties: {
|
|
280
|
-
status: { type: 'string', description: 'Filter by status' },
|
|
300
|
+
status: { type: 'string', description: 'Filter by status (pass "all" or omit to include every status)' },
|
|
281
301
|
domain: { type: 'string', description: 'Filter by domain' },
|
|
302
|
+
agentType: { type: 'string', description: 'Filter by agent type' },
|
|
282
303
|
includeTerminated: { type: 'boolean', description: 'Include terminated agents' },
|
|
283
304
|
},
|
|
284
305
|
},
|
|
285
306
|
handler: async (input) => {
|
|
286
307
|
const store = loadAgentStore();
|
|
287
308
|
let agents = Object.values(store.agents);
|
|
288
|
-
// Filter by status
|
|
289
|
-
|
|
309
|
+
// Filter by status. 'all' (the CLI's `--all` flag sends this literal
|
|
310
|
+
// string) means "no status filter" — it used to be treated as a real
|
|
311
|
+
// status value to match against, which no agent ever has, so `--all`
|
|
312
|
+
// silently returned zero agents instead of every agent.
|
|
313
|
+
if (input.status && input.status !== 'all') {
|
|
290
314
|
agents = agents.filter(a => a.status === input.status);
|
|
291
315
|
}
|
|
292
|
-
else if (!input.includeTerminated) {
|
|
316
|
+
else if (input.status !== 'all' && !input.includeTerminated) {
|
|
293
317
|
agents = agents.filter(a => a.status !== 'terminated');
|
|
294
318
|
}
|
|
295
319
|
// Filter by domain
|
|
296
320
|
if (input.domain) {
|
|
297
321
|
agents = agents.filter(a => a.domain === input.domain);
|
|
298
322
|
}
|
|
323
|
+
// Filter by agent type — the CLI's `--type` flag has sent this since
|
|
324
|
+
// it was added, but this handler never read it, so `--type` was a
|
|
325
|
+
// silent no-op that returned every agent regardless of the filter.
|
|
326
|
+
if (input.agentType) {
|
|
327
|
+
agents = agents.filter(a => a.agentType === input.agentType);
|
|
328
|
+
}
|
|
299
329
|
return {
|
|
300
330
|
agents: agents.map(a => ({
|
|
301
331
|
agentId: a.agentId,
|
|
@@ -310,6 +340,7 @@ export const agentTools = [
|
|
|
310
340
|
filters: {
|
|
311
341
|
status: input.status,
|
|
312
342
|
domain: input.domain,
|
|
343
|
+
agentType: input.agentType,
|
|
313
344
|
includeTerminated: input.includeTerminated,
|
|
314
345
|
},
|
|
315
346
|
};
|
|
@@ -329,9 +360,15 @@ export const agentTools = [
|
|
|
329
360
|
required: ['action'],
|
|
330
361
|
},
|
|
331
362
|
handler: async (input) => {
|
|
332
|
-
const store = loadAgentStore();
|
|
333
|
-
const agents = Object.values(store.agents).filter(a => a.status !== 'terminated');
|
|
334
363
|
const action = input.action || 'status'; // Default to status
|
|
364
|
+
const store = loadAgentStoreOrNull();
|
|
365
|
+
if (!store) {
|
|
366
|
+
// 'scale'/'drain' would otherwise build on an empty store and save it,
|
|
367
|
+
// wiping every real agent; 'status' reporting all-zeros on a corrupt
|
|
368
|
+
// store would also be misleading, so all three branches bail here.
|
|
369
|
+
return { action, error: 'Agent store is unreadable/corrupt — refusing to proceed to avoid overwriting real agent data.' };
|
|
370
|
+
}
|
|
371
|
+
const agents = Object.values(store.agents).filter(a => a.status !== 'terminated');
|
|
335
372
|
if (action === 'status') {
|
|
336
373
|
const byType = {};
|
|
337
374
|
const byStatus = {};
|
|
@@ -404,13 +441,16 @@ export const agentTools = [
|
|
|
404
441
|
}
|
|
405
442
|
if (action === 'drain') {
|
|
406
443
|
const agentType = input.agentType;
|
|
444
|
+
// Scope "remaining" to the same population drain operated over — when
|
|
445
|
+
// filtered by agentType, agents.length (all non-terminated agents,
|
|
446
|
+
// any type) minus drained (only that type's count) mixed two
|
|
447
|
+
// different populations and produced a meaningless total.
|
|
448
|
+
const scoped = agentType ? agents.filter(a => a.agentType === agentType) : agents;
|
|
407
449
|
let drained = 0;
|
|
408
|
-
for (const agent of
|
|
409
|
-
if (
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
drained++;
|
|
413
|
-
}
|
|
450
|
+
for (const agent of scoped) {
|
|
451
|
+
if (agent.status === 'idle') {
|
|
452
|
+
store.agents[agent.agentId].status = 'terminated';
|
|
453
|
+
drained++;
|
|
414
454
|
}
|
|
415
455
|
}
|
|
416
456
|
saveAgentStore(store);
|
|
@@ -418,7 +458,7 @@ export const agentTools = [
|
|
|
418
458
|
action,
|
|
419
459
|
agentType: agentType || 'all',
|
|
420
460
|
drained,
|
|
421
|
-
remaining:
|
|
461
|
+
remaining: scoped.length - drained,
|
|
422
462
|
};
|
|
423
463
|
}
|
|
424
464
|
return { action, error: 'Unknown action' };
|
|
@@ -521,7 +561,10 @@ export const agentTools = [
|
|
|
521
561
|
if (!agentId || typeof agentId !== 'string' || ['__proto__', 'constructor', 'prototype'].includes(agentId)) {
|
|
522
562
|
return { success: false, agentId, error: 'Invalid agent ID' };
|
|
523
563
|
}
|
|
524
|
-
const store =
|
|
564
|
+
const store = loadAgentStoreOrNull();
|
|
565
|
+
if (!store) {
|
|
566
|
+
return { success: false, agentId, error: 'Agent store is unreadable/corrupt — refusing to update to avoid overwriting real agent data.' };
|
|
567
|
+
}
|
|
525
568
|
const agent = Object.hasOwn(store.agents, agentId) ? store.agents[agentId] : undefined;
|
|
526
569
|
if (agent) {
|
|
527
570
|
if (input.status)
|
|
@@ -28,8 +28,10 @@ function loadClaims() {
|
|
|
28
28
|
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
catch {
|
|
31
|
+
catch (e) {
|
|
32
32
|
// Return empty store on error
|
|
33
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
34
|
+
console.error('[claims-tools] failed to load claims.json, starting fresh:', e);
|
|
33
35
|
}
|
|
34
36
|
return { claims: {}, stealable: {}, contests: {} };
|
|
35
37
|
}
|
|
@@ -52,8 +52,9 @@ function loadConfigStore() {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
catch {
|
|
56
|
-
|
|
55
|
+
catch (e) {
|
|
56
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
57
|
+
console.error('[config-tools] failed to load config store, using defaults:', e);
|
|
57
58
|
}
|
|
58
59
|
return {
|
|
59
60
|
values: { ...DEFAULT_CONFIG },
|
|
@@ -40,8 +40,9 @@ function loadDAAStore() {
|
|
|
40
40
|
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
catch {
|
|
44
|
-
|
|
43
|
+
catch (e) {
|
|
44
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
45
|
+
console.error('[daa-tools] failed to load DAA store, using empty store:', e);
|
|
45
46
|
}
|
|
46
47
|
return { agents: {}, workflows: {}, knowledge: {}, version: '3.0.0' };
|
|
47
48
|
}
|
|
@@ -54,8 +54,10 @@ function loadConfig() {
|
|
|
54
54
|
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
catch {
|
|
57
|
+
catch (e) {
|
|
58
58
|
// Return null on error
|
|
59
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
60
|
+
console.error('[embeddings-tools] config read/parse failed:', e);
|
|
59
61
|
}
|
|
60
62
|
return null;
|
|
61
63
|
}
|
|
@@ -457,8 +459,10 @@ export const embeddingsTools = [
|
|
|
457
459
|
},
|
|
458
460
|
};
|
|
459
461
|
}
|
|
460
|
-
catch {
|
|
462
|
+
catch (e) {
|
|
461
463
|
// Database not available - return empty but truthful
|
|
464
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
465
|
+
console.error('[embeddings-tools] search failed:', e);
|
|
462
466
|
const searchTime = (performance.now() - startTime).toFixed(2);
|
|
463
467
|
return {
|
|
464
468
|
success: true,
|
|
@@ -31,8 +31,9 @@ function loadGitHubStore() {
|
|
|
31
31
|
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
catch {
|
|
35
|
-
|
|
34
|
+
catch (e) {
|
|
35
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
36
|
+
console.error('[github-tools] failed to parse store.json, using empty store:', e);
|
|
36
37
|
}
|
|
37
38
|
return { repos: {}, prs: {}, issues: {}, version: '3.0.0' };
|
|
38
39
|
}
|
|
@@ -199,7 +200,10 @@ export const githubTools = [
|
|
|
199
200
|
const prs = JSON.parse(raw);
|
|
200
201
|
return { success: true, _real: true, source: 'gh-cli', pullRequests: prs, total: prs.length };
|
|
201
202
|
}
|
|
202
|
-
catch {
|
|
203
|
+
catch (e) {
|
|
204
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
205
|
+
console.error('[github-tools] failed to parse gh pr list output:', e);
|
|
206
|
+
}
|
|
203
207
|
}
|
|
204
208
|
}
|
|
205
209
|
const prs = Object.values(store.prs);
|
|
@@ -247,7 +251,10 @@ export const githubTools = [
|
|
|
247
251
|
try {
|
|
248
252
|
return { success: true, _real: true, action: 'review', pullRequest: JSON.parse(raw) };
|
|
249
253
|
}
|
|
250
|
-
catch {
|
|
254
|
+
catch (e) {
|
|
255
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
256
|
+
console.error('[github-tools] failed to parse gh pr view output:', e);
|
|
257
|
+
}
|
|
251
258
|
}
|
|
252
259
|
}
|
|
253
260
|
return { success: false, error: 'gh CLI not available or PR not found. Install gh: https://cli.github.com' };
|
|
@@ -325,7 +332,10 @@ export const githubTools = [
|
|
|
325
332
|
const issues = JSON.parse(raw);
|
|
326
333
|
return { success: true, _real: true, source: 'gh-cli', issues, total: issues.length };
|
|
327
334
|
}
|
|
328
|
-
catch {
|
|
335
|
+
catch (e) {
|
|
336
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
337
|
+
console.error('[github-tools] failed to parse gh issue list output:', e);
|
|
338
|
+
}
|
|
329
339
|
}
|
|
330
340
|
}
|
|
331
341
|
const issues = Object.values(store.issues);
|
|
@@ -436,14 +446,20 @@ export const githubTools = [
|
|
|
436
446
|
try {
|
|
437
447
|
return { success: true, _real: true, runs: JSON.parse(raw) };
|
|
438
448
|
}
|
|
439
|
-
catch {
|
|
449
|
+
catch (e) {
|
|
450
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
451
|
+
console.error('[github-tools] failed to parse gh run list output:', e);
|
|
452
|
+
}
|
|
440
453
|
}
|
|
441
454
|
const workflows = run('gh workflow list --json id,name,state');
|
|
442
455
|
if (workflows) {
|
|
443
456
|
try {
|
|
444
457
|
return { success: true, _real: true, workflows: JSON.parse(workflows) };
|
|
445
458
|
}
|
|
446
|
-
catch {
|
|
459
|
+
catch (e) {
|
|
460
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
461
|
+
console.error('[github-tools] failed to parse gh workflow list output:', e);
|
|
462
|
+
}
|
|
447
463
|
}
|
|
448
464
|
}
|
|
449
465
|
if (action === 'status') {
|
|
@@ -454,7 +470,10 @@ export const githubTools = [
|
|
|
454
470
|
try {
|
|
455
471
|
return { success: true, _real: true, run: JSON.parse(raw) };
|
|
456
472
|
}
|
|
457
|
-
catch {
|
|
473
|
+
catch (e) {
|
|
474
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
475
|
+
console.error('[github-tools] failed to parse gh run view output:', e);
|
|
476
|
+
}
|
|
458
477
|
}
|
|
459
478
|
}
|
|
460
479
|
// List recent runs as fallback
|
|
@@ -463,7 +482,10 @@ export const githubTools = [
|
|
|
463
482
|
try {
|
|
464
483
|
return { success: true, _real: true, recentRuns: JSON.parse(recent) };
|
|
465
484
|
}
|
|
466
|
-
catch {
|
|
485
|
+
catch (e) {
|
|
486
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
487
|
+
console.error('[github-tools] failed to parse gh run list (recent) output:', e);
|
|
488
|
+
}
|
|
467
489
|
}
|
|
468
490
|
}
|
|
469
491
|
if (action === 'trigger') {
|
|
@@ -538,7 +560,10 @@ export const githubTools = [
|
|
|
538
560
|
try {
|
|
539
561
|
result.releases = JSON.parse(raw);
|
|
540
562
|
}
|
|
541
|
-
catch {
|
|
563
|
+
catch (e) {
|
|
564
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
565
|
+
console.error('[github-tools] failed to parse gh release list output:', e);
|
|
566
|
+
}
|
|
542
567
|
}
|
|
543
568
|
}
|
|
544
569
|
if (!result.releases) {
|
|
@@ -18,7 +18,7 @@ import { weightedTally } from '../consensus/tally.js';
|
|
|
18
18
|
// Reuse agent-tools.ts's hardened store loader (50MB size cap + __proto__
|
|
19
19
|
// rejection) instead of maintaining a second, weaker copy that reads the
|
|
20
20
|
// same physical file — see loadAgentStore export note there.
|
|
21
|
-
import { loadAgentStore } from './agent-tools.js';
|
|
21
|
+
import { loadAgentStore, loadAgentStoreOrNull } from './agent-tools.js';
|
|
22
22
|
// Storage paths
|
|
23
23
|
const STORAGE_DIR = '.monomind';
|
|
24
24
|
const HIVE_DIR = 'hive-mind';
|
|
@@ -117,8 +117,9 @@ function loadHiveState() {
|
|
|
117
117
|
return JSON.parse(data);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
catch {
|
|
121
|
-
|
|
120
|
+
catch (e) {
|
|
121
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
122
|
+
console.error('[hive-mind-tools] failed to parse hive state.json — resetting to default state:', e);
|
|
122
123
|
}
|
|
123
124
|
return {
|
|
124
125
|
initialized: false,
|
|
@@ -226,7 +227,13 @@ export const hiveMindTools = [
|
|
|
226
227
|
const rawPrefix = input.prefix || 'hive-worker';
|
|
227
228
|
const prefix = typeof rawPrefix === 'string' && rawPrefix.length > MAX_HIVE_PREFIX_LEN
|
|
228
229
|
? rawPrefix.slice(0, MAX_HIVE_PREFIX_LEN) : rawPrefix;
|
|
229
|
-
|
|
230
|
+
// Must use the null-aware loader here (this handler mutates and saves)
|
|
231
|
+
// — loadAgentStore() on a corrupt/oversized store.json now returns the
|
|
232
|
+
// empty default, and saving that back would wipe every real agent.
|
|
233
|
+
const agentStore = loadAgentStoreOrNull();
|
|
234
|
+
if (!agentStore) {
|
|
235
|
+
return { success: false, error: 'Agent store is unreadable/corrupt — refusing to spawn hive workers to avoid overwriting real agent data.' };
|
|
236
|
+
}
|
|
230
237
|
const spawnedWorkers = [];
|
|
231
238
|
for (let i = 0; i < count; i++) {
|
|
232
239
|
const agentId = `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
@@ -375,7 +382,10 @@ export const hiveMindTools = [
|
|
|
375
382
|
}
|
|
376
383
|
}
|
|
377
384
|
}
|
|
378
|
-
catch {
|
|
385
|
+
catch (e) {
|
|
386
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
387
|
+
console.error('[hive-mind-tools] failed to parse task store — task counts default to 0:', e);
|
|
388
|
+
}
|
|
379
389
|
const workerCount = Math.max(1, state.workers.length);
|
|
380
390
|
const realLoad = activeTaskCount / workerCount;
|
|
381
391
|
const status = {
|
|
@@ -1000,8 +1010,15 @@ export const hiveMindTools = [
|
|
|
1000
1010
|
workerCount,
|
|
1001
1011
|
};
|
|
1002
1012
|
}
|
|
1003
|
-
// Clear workers from agent store
|
|
1004
|
-
|
|
1013
|
+
// Clear workers from agent store. Must use the null-aware loader here
|
|
1014
|
+
// (this handler mutates and saves) — loadAgentStore() on a corrupt/
|
|
1015
|
+
// oversized store.json now returns the empty default, and deleting
|
|
1016
|
+
// from + saving that back would wipe every real agent, not just the
|
|
1017
|
+
// hive workers being shut down.
|
|
1018
|
+
const agentStore = loadAgentStoreOrNull();
|
|
1019
|
+
if (!agentStore) {
|
|
1020
|
+
return { success: false, error: 'Agent store is unreadable/corrupt — refusing to shut down to avoid overwriting real agent data.', pendingConsensus, workerCount };
|
|
1021
|
+
}
|
|
1005
1022
|
for (const workerId of state.workers) {
|
|
1006
1023
|
if (agentStore.agents[workerId]) {
|
|
1007
1024
|
delete agentStore.agents[workerId];
|
|
@@ -141,7 +141,11 @@ export function loadRoutingOutcomes() {
|
|
|
141
141
|
return data.outcomes || [];
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
catch {
|
|
144
|
+
catch (e) {
|
|
145
|
+
/* corrupt file, start fresh */
|
|
146
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
147
|
+
console.error('[hooks-embedding] routing-outcomes.json read/parse failed:', e);
|
|
148
|
+
}
|
|
145
149
|
return [];
|
|
146
150
|
}
|
|
147
151
|
export function saveRoutingOutcomes(outcomes) {
|
|
@@ -155,7 +159,11 @@ export function saveRoutingOutcomes(outcomes) {
|
|
|
155
159
|
writeFileSync(tmp, JSON.stringify({ outcomes: capped }, null, 2));
|
|
156
160
|
renameSync(tmp, getRoutingOutcomesPath());
|
|
157
161
|
}
|
|
158
|
-
catch {
|
|
162
|
+
catch (e) {
|
|
163
|
+
/* non-critical */
|
|
164
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
165
|
+
console.error('[hooks-embedding] routing-outcomes.json write failed:', e);
|
|
166
|
+
}
|
|
159
167
|
}
|
|
160
168
|
/**
|
|
161
169
|
* Build learned routing patterns from successful task outcomes.
|
|
@@ -265,8 +273,10 @@ export function loadMemoryStore() {
|
|
|
265
273
|
return JSON.parse(data);
|
|
266
274
|
}
|
|
267
275
|
}
|
|
268
|
-
catch {
|
|
276
|
+
catch (e) {
|
|
269
277
|
// Return empty store on error
|
|
278
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
279
|
+
console.error('[hooks-embedding] memory store.json read/parse failed:', e);
|
|
270
280
|
}
|
|
271
281
|
return { entries: {}, version: '3.0.0' };
|
|
272
282
|
}
|
|
@@ -260,9 +260,11 @@ export const hooksTrajectoryEnd = {
|
|
|
260
260
|
},
|
|
261
261
|
});
|
|
262
262
|
}
|
|
263
|
-
catch {
|
|
263
|
+
catch (e) {
|
|
264
264
|
// Non-fatal: intelligence bridge unavailable, trajectory is still
|
|
265
265
|
// persisted via the legacy store above.
|
|
266
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
267
|
+
console.error('[hooks-intelligence] intelligence bridge recordStep failed:', e);
|
|
266
268
|
}
|
|
267
269
|
}
|
|
268
270
|
// SONA Learning - process trajectory outcome for routing optimization
|
|
@@ -295,8 +297,10 @@ export const hooksTrajectoryEnd = {
|
|
|
295
297
|
confidence: result.confidence,
|
|
296
298
|
};
|
|
297
299
|
}
|
|
298
|
-
catch {
|
|
300
|
+
catch (e) {
|
|
299
301
|
// SONA learning failed, continue without it
|
|
302
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
303
|
+
console.error('[hooks-intelligence] SONA processTrajectoryOutcome failed:', e);
|
|
300
304
|
}
|
|
301
305
|
}
|
|
302
306
|
// Try EWC++ consolidation on successful trajectories
|
|
@@ -314,8 +318,10 @@ export const hooksTrajectoryEnd = {
|
|
|
314
318
|
penalty: stats.avgPenalty,
|
|
315
319
|
};
|
|
316
320
|
}
|
|
317
|
-
catch {
|
|
321
|
+
catch (e) {
|
|
318
322
|
// EWC consolidation failed, continue without it
|
|
323
|
+
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
324
|
+
console.error('[hooks-intelligence] EWC consolidation failed:', e);
|
|
319
325
|
}
|
|
320
326
|
}
|
|
321
327
|
}
|
|
@@ -20,6 +20,7 @@ export declare const hooksPretrain: MCPTool;
|
|
|
20
20
|
export declare const hooksBuildAgents: MCPTool;
|
|
21
21
|
export declare const hooksTransfer: MCPTool;
|
|
22
22
|
export declare const hooksSessionStart: MCPTool;
|
|
23
|
+
export declare const hooksSessionRestore: MCPTool;
|
|
23
24
|
export declare const hooksSessionEnd: MCPTool;
|
|
24
25
|
export declare const hooksIntelligence: MCPTool;
|
|
25
26
|
//# sourceMappingURL=hooks-routing.d.ts.map
|