monomind 2.0.3 → 2.1.3
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 +74 -92
- package/package.json +11 -7
- package/packages/@monomind/cli/.claude/helpers/control-start.cjs +13 -20
- package/packages/@monomind/cli/.claude/helpers/event-logger.cjs +109 -6
- package/packages/@monomind/cli/.claude/helpers/graphify-freshen.cjs +19 -17
- package/packages/@monomind/cli/.claude/helpers/handlers/agent-start-handler.cjs +60 -28
- package/packages/@monomind/cli/.claude/helpers/handlers/capture-handler.cjs +99 -28
- package/packages/@monomind/cli/.claude/helpers/handlers/edit-handler.cjs +27 -9
- package/packages/@monomind/cli/.claude/helpers/handlers/gates-handler.cjs +18 -9
- package/packages/@monomind/cli/.claude/helpers/handlers/loops-status-handler.cjs +1 -1
- package/packages/@monomind/cli/.claude/helpers/handlers/route-handler.cjs +33 -4
- package/packages/@monomind/cli/.claude/helpers/handlers/session-handler.cjs +75 -45
- package/packages/@monomind/cli/.claude/helpers/handlers/session-restore-handler.cjs +0 -12
- package/packages/@monomind/cli/.claude/helpers/handlers/task-handler.cjs +53 -22
- package/packages/@monomind/cli/.claude/helpers/hook-handler.cjs +75 -4
- package/packages/@monomind/cli/.claude/helpers/intelligence.cjs +94 -15
- package/packages/@monomind/cli/.claude/helpers/session.cjs +6 -1
- package/packages/@monomind/cli/.claude/helpers/statusline.cjs +10 -10
- package/packages/@monomind/cli/.claude/helpers/token-tracker.cjs +3 -3
- package/packages/@monomind/cli/.claude/helpers/utils/agent-registrations.cjs +41 -0
- package/packages/@monomind/cli/.claude/helpers/utils/fs-helpers.cjs +183 -0
- package/packages/@monomind/cli/.claude/helpers/utils/micro-agents.cjs +10 -6
- package/packages/@monomind/cli/.claude/helpers/utils/monograph.cjs +73 -2
- package/packages/@monomind/cli/.claude/helpers/utils/telemetry.cjs +35 -19
- package/packages/@monomind/cli/README.md +74 -92
- package/packages/@monomind/cli/bin/cli.js +10 -1
- package/packages/@monomind/cli/dist/src/browser/workflow/store.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/commands/agent-ops.js +9 -15
- package/packages/@monomind/cli/dist/src/commands/browse.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/cleanup.js +20 -4
- package/packages/@monomind/cli/dist/src/commands/completions.js +66 -261
- package/packages/@monomind/cli/dist/src/commands/doctor-env-checks.js +5 -0
- package/packages/@monomind/cli/dist/src/commands/doctor.js +7 -2
- package/packages/@monomind/cli/dist/src/commands/hooks-workers.js +7 -0
- package/packages/@monomind/cli/dist/src/commands/index.js +3 -0
- package/packages/@monomind/cli/dist/src/commands/mcp.js +11 -6
- package/packages/@monomind/cli/dist/src/commands/memory-admin.js +12 -6
- package/packages/@monomind/cli/dist/src/commands/memory-transfer.js +6 -13
- package/packages/@monomind/cli/dist/src/commands/monograph.js +3 -3
- package/packages/@monomind/cli/dist/src/commands/org.d.ts +3 -1
- package/packages/@monomind/cli/dist/src/commands/org.js +321 -127
- package/packages/@monomind/cli/dist/src/commands/platforms.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/start.js +142 -37
- package/packages/@monomind/cli/dist/src/commands/tokens.js +21 -3
- package/packages/@monomind/cli/dist/src/config-adapter.js +37 -17
- package/packages/@monomind/cli/dist/src/index.js +64 -28
- package/packages/@monomind/cli/dist/src/init/claudemd-generator.js +44 -11
- package/packages/@monomind/cli/dist/src/init/executor.js +93 -55
- package/packages/@monomind/cli/dist/src/mcp-client.d.ts +8 -3
- package/packages/@monomind/cli/dist/src/mcp-client.js +37 -3
- package/packages/@monomind/cli/dist/src/mcp-server.js +8 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.d.ts +20 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.js +10 -5
- package/packages/@monomind/cli/dist/src/mcp-tools/auto-install.d.ts +8 -8
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/types.d.ts +31 -31
- package/packages/@monomind/cli/dist/src/mcp-tools/github-tools.js +30 -8
- package/packages/@monomind/cli/dist/src/mcp-tools/graphify-tools.js +11 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/hive-mind-tools.js +56 -35
- package/packages/@monomind/cli/dist/src/mcp-tools/knowledge-tools.js +9 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-compat.js +56 -14
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +88 -41
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.d.ts +36 -36
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts +4 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/swarm-tools.js +6 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/system-tools.js +4 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/types.d.ts +20 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/types.js +36 -1
- package/packages/@monomind/cli/dist/src/memory/ewc-consolidation.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/memory/hnsw-operations.d.ts +13 -1
- package/packages/@monomind/cli/dist/src/memory/hnsw-operations.js +66 -14
- package/packages/@monomind/cli/dist/src/memory/intelligence.js +99 -3
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +20 -0
- package/packages/@monomind/cli/dist/src/memory/sona-optimizer.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/orgrt/broker.d.ts +26 -0
- package/packages/@monomind/cli/dist/src/orgrt/broker.js +73 -0
- package/packages/@monomind/cli/dist/src/orgrt/bus.d.ts +5 -1
- package/packages/@monomind/cli/dist/src/orgrt/bus.js +5 -1
- package/packages/@monomind/cli/dist/src/orgrt/daemon.d.ts +46 -0
- package/packages/@monomind/cli/dist/src/orgrt/daemon.js +201 -18
- package/packages/@monomind/cli/dist/src/orgrt/forwarder.d.ts +10 -5
- package/packages/@monomind/cli/dist/src/orgrt/forwarder.js +138 -8
- package/packages/@monomind/cli/dist/src/orgrt/inbox.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/orgrt/inbox.js +56 -0
- package/packages/@monomind/cli/dist/src/orgrt/policy.d.ts +5 -1
- package/packages/@monomind/cli/dist/src/orgrt/policy.js +58 -5
- package/packages/@monomind/cli/dist/src/orgrt/provider.js +1 -0
- package/packages/@monomind/cli/dist/src/orgrt/scheduler.d.ts +13 -0
- package/packages/@monomind/cli/dist/src/orgrt/scheduler.js +48 -0
- package/packages/@monomind/cli/dist/src/orgrt/server.d.ts +9 -0
- package/packages/@monomind/cli/dist/src/orgrt/server.js +39 -0
- package/packages/@monomind/cli/dist/src/orgrt/session.d.ts +10 -1
- package/packages/@monomind/cli/dist/src/orgrt/session.js +24 -1
- package/packages/@monomind/cli/dist/src/orgrt/test-loop.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/orgrt/test-loop.js +108 -0
- package/packages/@monomind/cli/dist/src/orgrt/types.d.ts +52 -52
- package/packages/@monomind/cli/dist/src/output.d.ts +29 -29
- package/packages/@monomind/cli/dist/src/output.js +22 -7
- package/packages/@monomind/cli/dist/src/parser.d.ts +32 -0
- package/packages/@monomind/cli/dist/src/parser.js +130 -5
- package/packages/@monomind/cli/dist/src/routing/embed-worker.js +13 -1
- package/packages/@monomind/cli/dist/src/routing/route-layer-factory.js +31 -0
- package/packages/@monomind/cli/dist/src/services/config-file-manager.d.ts +21 -0
- package/packages/@monomind/cli/dist/src/services/config-file-manager.js +60 -7
- package/packages/@monomind/cli/dist/src/services/crash-reporter.js +2 -1
- package/packages/@monomind/cli/dist/src/types.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/ui/dashboard.html +243 -49
- package/packages/@monomind/cli/dist/src/ui/orgs-files.js +192 -0
- package/packages/@monomind/cli/dist/src/ui/orgs.html +79 -11
- package/packages/@monomind/cli/dist/src/ui/server.mjs +346 -139
- package/packages/@monomind/cli/dist/src/utils/input-guards.d.ts +9 -0
- package/packages/@monomind/cli/dist/src/utils/input-guards.js +39 -5
- package/packages/@monomind/cli/package.json +15 -15
|
@@ -11,6 +11,22 @@ import { dirname } from 'path';
|
|
|
11
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
12
12
|
const __dirname = dirname(__filename);
|
|
13
13
|
const MAX_EXEC_FILE_BYTES = 10 * 1024 * 1024; // 10 MB
|
|
14
|
+
/**
|
|
15
|
+
* Probe whether an optionalDependency actually resolved in this install
|
|
16
|
+
* (npm silently skips optionalDependencies it can't satisfy — see
|
|
17
|
+
* docs/AUDIT-BACKLOG.md P1-1/P1-23). Used to caveat generated docs instead
|
|
18
|
+
* of presenting these features as unconditionally working.
|
|
19
|
+
*/
|
|
20
|
+
function _isOptionalPackageResolvable(pkg) {
|
|
21
|
+
try {
|
|
22
|
+
const req = createRequire(import.meta.url);
|
|
23
|
+
req.resolve(pkg);
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
14
30
|
/**
|
|
15
31
|
* Atomic write helper — writes to a sibling .tmp file then renames into place.
|
|
16
32
|
* SIGINT or crash during a partial write would otherwise corrupt user-critical
|
|
@@ -559,6 +575,13 @@ export async function executeUpgrade(targetDir, upgradeSettings = false) {
|
|
|
559
575
|
const destHelpersDir = path.join(targetDir, '.claude', 'helpers');
|
|
560
576
|
// Copy top-level critical files atomically
|
|
561
577
|
const criticalHelpers = ['auto-memory-hook.mjs', 'hook-handler.cjs', 'intelligence.cjs', 'statusline.cjs', 'graphify-freshen.cjs'];
|
|
578
|
+
// Generated fallback for any critical helper missing from the source dir itself
|
|
579
|
+
// (e.g. the published npm template lacking auto-memory-hook.mjs).
|
|
580
|
+
const criticalGenerators = {
|
|
581
|
+
'hook-handler.cjs': generateHookHandler,
|
|
582
|
+
'intelligence.cjs': generateIntelligenceStub,
|
|
583
|
+
'auto-memory-hook.mjs': generateAutoMemoryHook,
|
|
584
|
+
};
|
|
562
585
|
for (const helperName of criticalHelpers) {
|
|
563
586
|
const targetPath = path.join(destHelpersDir, helperName);
|
|
564
587
|
const sourcePath = path.join(sourceHelpersForUpgrade, helperName);
|
|
@@ -578,6 +601,17 @@ export async function executeUpgrade(targetDir, upgradeSettings = false) {
|
|
|
578
601
|
catch { }
|
|
579
602
|
fs.renameSync(tmp, targetPath);
|
|
580
603
|
}
|
|
604
|
+
else if (!fs.existsSync(targetPath) && criticalGenerators[helperName]) {
|
|
605
|
+
const content = criticalGenerators[helperName]();
|
|
606
|
+
const tmp = `${targetPath}.${process.pid}.tmp`;
|
|
607
|
+
fs.writeFileSync(tmp, content, 'utf-8');
|
|
608
|
+
try {
|
|
609
|
+
fs.chmodSync(tmp, 0o755);
|
|
610
|
+
}
|
|
611
|
+
catch { }
|
|
612
|
+
fs.renameSync(tmp, targetPath);
|
|
613
|
+
result.created.push(`.claude/helpers/${helperName}`);
|
|
614
|
+
}
|
|
581
615
|
}
|
|
582
616
|
// Always recursively sync subdirectories (utils/, handlers/) — required by hook-handler.cjs.
|
|
583
617
|
// Uses recursive copy so any future nested subdirs are also covered.
|
|
@@ -1180,13 +1214,15 @@ function findSourceHelpersDir(sourceBaseDir) {
|
|
|
1180
1214
|
possiblePaths.push(helpersPath);
|
|
1181
1215
|
currentDir = parentDir;
|
|
1182
1216
|
}
|
|
1183
|
-
//
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1217
|
+
// NOTE: deliberately no cwd-ancestor-search fallback here (removed — see
|
|
1218
|
+
// docs/AUDIT-BACKLOG.md P3-25). Searching process.cwd() and its parents for
|
|
1219
|
+
// ".claude/helpers" could pick up an unrelated project's own helper scripts
|
|
1220
|
+
// (stale, customized, or untrusted) when `monomind init` is run from a
|
|
1221
|
+
// nested subdirectory of some other checkout. Helper source resolution is
|
|
1222
|
+
// restricted to the package's own bundled location(s) above; if none of
|
|
1223
|
+
// those are found, callers should treat it as a corrupt install rather than
|
|
1224
|
+
// silently falling back to scanning ancestor directories for someone else's
|
|
1225
|
+
// files.
|
|
1190
1226
|
// Return first path that exists AND contains ALL sentinel files
|
|
1191
1227
|
for (const p of possiblePaths) {
|
|
1192
1228
|
if (fs.existsSync(p) && SENTINEL_FILES.every(f => fs.existsSync(path.join(p, f)))) {
|
|
@@ -1204,10 +1240,12 @@ async function writeHelpers(targetDir, options, result) {
|
|
|
1204
1240
|
const sourceHelpersDir = findSourceHelpersDir(options.sourceBaseDir);
|
|
1205
1241
|
// Try to copy existing helpers from source first (recursive — includes utils/ and handlers/)
|
|
1206
1242
|
if (sourceHelpersDir && fs.existsSync(sourceHelpersDir)) {
|
|
1207
|
-
let copiedCount = 0;
|
|
1208
1243
|
const copyRecursive = (srcDir, destDir, relBase) => {
|
|
1209
1244
|
fs.mkdirSync(destDir, { recursive: true });
|
|
1210
1245
|
for (const entry of fs.readdirSync(srcDir, { withFileTypes: true })) {
|
|
1246
|
+
// Skip exFAT/macOS AppleDouble junk files (e.g. "._foo.cjs").
|
|
1247
|
+
if (entry.name.startsWith('._'))
|
|
1248
|
+
continue;
|
|
1211
1249
|
const srcPath = path.join(srcDir, entry.name);
|
|
1212
1250
|
const destPath = path.join(destDir, entry.name);
|
|
1213
1251
|
const relPath = relBase ? `${relBase}/${entry.name}` : entry.name;
|
|
@@ -1221,7 +1259,6 @@ async function writeHelpers(targetDir, options, result) {
|
|
|
1221
1259
|
fs.chmodSync(destPath, '755');
|
|
1222
1260
|
}
|
|
1223
1261
|
result.created.files.push(`.claude/helpers/${relPath}`);
|
|
1224
|
-
copiedCount++;
|
|
1225
1262
|
}
|
|
1226
1263
|
else {
|
|
1227
1264
|
result.skipped.push(`.claude/helpers/${relPath}`);
|
|
@@ -1230,11 +1267,12 @@ async function writeHelpers(targetDir, options, result) {
|
|
|
1230
1267
|
}
|
|
1231
1268
|
};
|
|
1232
1269
|
copyRecursive(sourceHelpersDir, helpersDir, '');
|
|
1233
|
-
if (copiedCount > 0) {
|
|
1234
|
-
return; // Skip generating if we copied from source
|
|
1235
|
-
}
|
|
1236
1270
|
}
|
|
1237
|
-
//
|
|
1271
|
+
// Always run the fallback generator too — it only fills in files still missing
|
|
1272
|
+
// after the source copy above (it no-ops on anything the copy already wrote).
|
|
1273
|
+
// Without this, a source dir that's present but incomplete (e.g. missing
|
|
1274
|
+
// auto-memory-hook.mjs) silently ships a project wired to hooks that reference
|
|
1275
|
+
// a file that was never installed.
|
|
1238
1276
|
const helpers = {
|
|
1239
1277
|
'pre-commit': generatePreCommitHook(),
|
|
1240
1278
|
'post-commit': generatePostCommitHook(),
|
|
@@ -1247,6 +1285,13 @@ async function writeHelpers(targetDir, options, result) {
|
|
|
1247
1285
|
};
|
|
1248
1286
|
for (const [name, content] of Object.entries(helpers)) {
|
|
1249
1287
|
const filePath = path.join(helpersDir, name);
|
|
1288
|
+
// If the source dir has this file, copyRecursive above already applied
|
|
1289
|
+
// the correct (force-aware) copy — never let this generated fallback
|
|
1290
|
+
// clobber it with a bare-bones stub. Only step in when source truly
|
|
1291
|
+
// doesn't have the file, regardless of `force`.
|
|
1292
|
+
const inSource = !!(sourceHelpersDir && fs.existsSync(path.join(sourceHelpersDir, name)));
|
|
1293
|
+
if (inSource)
|
|
1294
|
+
continue;
|
|
1250
1295
|
if (!fs.existsSync(filePath) || options.force) {
|
|
1251
1296
|
atomicWriteFile(filePath, content);
|
|
1252
1297
|
// Make shell scripts executable
|
|
@@ -1549,6 +1594,7 @@ async function writeCapabilitiesDoc(targetDir, options, result) {
|
|
|
1549
1594
|
result.skipped.push('.monomind/CAPABILITIES.md');
|
|
1550
1595
|
return;
|
|
1551
1596
|
}
|
|
1597
|
+
const hooksAvailable = _isOptionalPackageResolvable('@monomind/hooks');
|
|
1552
1598
|
const capabilities = `# Monomind - Complete Capabilities Reference
|
|
1553
1599
|
> Generated: ${new Date().toISOString()}
|
|
1554
1600
|
> Full documentation: https://github.com/monoes/monomind
|
|
@@ -1558,8 +1604,8 @@ async function writeCapabilitiesDoc(targetDir, options, result) {
|
|
|
1558
1604
|
1. [Overview](#overview)
|
|
1559
1605
|
2. [Swarm Orchestration](#swarm-orchestration)
|
|
1560
1606
|
3. [Available Agents (60+)](#available-agents)
|
|
1561
|
-
4. [CLI Commands
|
|
1562
|
-
5. [Hooks System (
|
|
1607
|
+
4. [CLI Commands](#cli-commands)
|
|
1608
|
+
5. [Hooks System (29 Hook Subcommands + 15 Background Workers)](#hooks-system)
|
|
1563
1609
|
6. [Memory & Intelligence](#memory--intelligence)
|
|
1564
1610
|
7. [Hive-Mind Consensus](#hive-mind-consensus)
|
|
1565
1611
|
8. [Performance Targets](#performance-targets)
|
|
@@ -1661,33 +1707,31 @@ npx monomind@latest swarm monitor
|
|
|
1661
1707
|
|
|
1662
1708
|
## CLI Commands
|
|
1663
1709
|
|
|
1664
|
-
### Core Commands
|
|
1710
|
+
### Core Commands
|
|
1665
1711
|
| Command | Subcommands | Description |
|
|
1666
1712
|
|---------|-------------|-------------|
|
|
1667
|
-
| \`init\` |
|
|
1668
|
-
| \`agent\` |
|
|
1713
|
+
| \`init\` | 5 | Project initialization |
|
|
1714
|
+
| \`agent\` | 7 | Agent lifecycle management |
|
|
1669
1715
|
| \`swarm\` | 6 | Multi-agent coordination |
|
|
1670
|
-
| \`memory\` |
|
|
1716
|
+
| \`memory\` | 12 | LanceDB with ANN vector search |
|
|
1671
1717
|
| \`mcp\` | 9 | MCP server management |
|
|
1672
|
-
| \`task\` |
|
|
1673
|
-
| \`session\` |
|
|
1718
|
+
| \`task\` | 5 | Task assignment |
|
|
1719
|
+
| \`session\` | 6 | Session persistence |
|
|
1674
1720
|
| \`config\` | 7 | Configuration |
|
|
1675
1721
|
| \`status\` | 3 | System monitoring |
|
|
1676
|
-
| \`
|
|
1677
|
-
|
|
1678
|
-
|
|
1722
|
+
| \`hooks\` | 29 | Self-learning hooks + 15 background workers${hooksAvailable ? '' : ' (background workers unavailable in this install)'} |
|
|
1723
|
+
|
|
1724
|
+
> Note: there is no \`hive-mind\`, \`workflow\`, \`neural\`, \`embeddings\`, \`claims\`, \`migrate\`, or \`process\` CLI command.
|
|
1725
|
+
> Hive-Mind consensus (byzantine/raft/quorum) is available exclusively via MCP tools, not the CLI.
|
|
1726
|
+
> Neural pattern learning was merged into \`hooks intelligence\`.
|
|
1679
1727
|
|
|
1680
|
-
### Advanced Commands
|
|
1728
|
+
### Advanced Commands
|
|
1681
1729
|
| Command | Subcommands | Description |
|
|
1682
1730
|
|---------|-------------|-------------|
|
|
1683
|
-
| \`neural\` | 5 | Pattern training |
|
|
1684
1731
|
| \`security\` | 6 | Security scanning |
|
|
1685
|
-
| \`performance\` |
|
|
1686
|
-
| \`providers\` |
|
|
1687
|
-
| \`
|
|
1688
|
-
| \`claims\` | 4 | Authorization |
|
|
1689
|
-
| \`migrate\` | 5 | V2→V1 migration |
|
|
1690
|
-
| \`process\` | 4 | Process management |
|
|
1732
|
+
| \`performance\` | 4 | Profiling & benchmarks |
|
|
1733
|
+
| \`providers\` | 4 | AI provider config |
|
|
1734
|
+
| \`guidance\` | 1 | Governance gate setup |
|
|
1691
1735
|
| \`doctor\` | 1 | Health diagnostics |
|
|
1692
1736
|
| \`completions\` | 4 | Shell completions |
|
|
1693
1737
|
|
|
@@ -1711,7 +1755,7 @@ npx monomind@latest doctor --fix
|
|
|
1711
1755
|
|
|
1712
1756
|
## Hooks System
|
|
1713
1757
|
|
|
1714
|
-
###
|
|
1758
|
+
### 29 Available Hook Subcommands${hooksAvailable ? '' : ' — background workers unavailable in this install (@monomind/hooks did not resolve)'}
|
|
1715
1759
|
|
|
1716
1760
|
#### Core Hooks (6)
|
|
1717
1761
|
| Hook | Description |
|
|
@@ -1818,6 +1862,11 @@ npx monomind@latest memory init --force
|
|
|
1818
1862
|
|
|
1819
1863
|
## Hive-Mind Consensus
|
|
1820
1864
|
|
|
1865
|
+
> **Experimental, MCP-only.** There is no \`hive-mind\` CLI command — this is
|
|
1866
|
+
> single-process vote counting exposed exclusively via MCP tools
|
|
1867
|
+
> (\`hive-mind-tools.ts\`), not distributed networking. Reach it through the
|
|
1868
|
+
> MCP server (\`npx monomind@latest mcp start\`) once connected to an MCP client.
|
|
1869
|
+
|
|
1821
1870
|
### Queen Types
|
|
1822
1871
|
| Type | Role |
|
|
1823
1872
|
|------|------|
|
|
@@ -1829,28 +1878,13 @@ npx monomind@latest memory init --force
|
|
|
1829
1878
|
\`researcher\`, \`coder\`, \`analyst\`, \`tester\`, \`architect\`, \`reviewer\`, \`optimizer\`, \`documenter\`
|
|
1830
1879
|
|
|
1831
1880
|
### Consensus Mechanisms
|
|
1832
|
-
| Mechanism | Fault Tolerance |
|
|
1833
|
-
|
|
1834
|
-
| \`byzantine\` | f < n/3 faulty |
|
|
1835
|
-
| \`raft\` | f < n/2 failed |
|
|
1836
|
-
| \`
|
|
1837
|
-
| \`
|
|
1838
|
-
| \`
|
|
1839
|
-
|
|
1840
|
-
### Hive-Mind Commands
|
|
1841
|
-
\`\`\`bash
|
|
1842
|
-
# Initialize
|
|
1843
|
-
npx monomind@latest hive-mind init --queen-type strategic
|
|
1844
|
-
|
|
1845
|
-
# Status
|
|
1846
|
-
npx monomind@latest hive-mind status
|
|
1847
|
-
|
|
1848
|
-
# Spawn workers
|
|
1849
|
-
npx monomind@latest hive-mind spawn --count 5 --type worker
|
|
1850
|
-
|
|
1851
|
-
# Consensus
|
|
1852
|
-
npx monomind@latest hive-mind consensus --propose "task"
|
|
1853
|
-
\`\`\`
|
|
1881
|
+
| Mechanism | Fault Tolerance | Status |
|
|
1882
|
+
|-----------|-----------------|--------|
|
|
1883
|
+
| \`byzantine\` / \`bft\` | f < n/3 faulty | Implemented (vote counting) |
|
|
1884
|
+
| \`raft\` | f < n/2 failed | Implemented (vote counting) |
|
|
1885
|
+
| \`quorum\` | Configurable | Implemented |
|
|
1886
|
+
| \`gossip\` | Eventually consistent | Planned — not implemented, rejected by \`hive_mind_init\` |
|
|
1887
|
+
| \`crdt\` | Conflict-free | Planned — not implemented, rejected by \`hive_mind_init\` |
|
|
1854
1888
|
|
|
1855
1889
|
---
|
|
1856
1890
|
|
|
@@ -2074,6 +2108,10 @@ function copyDirRecursive(src, dest) {
|
|
|
2074
2108
|
fs.mkdirSync(dest, { recursive: true });
|
|
2075
2109
|
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
2076
2110
|
for (const entry of entries) {
|
|
2111
|
+
// Skip exFAT/macOS AppleDouble junk files (e.g. "._foo.js") so they don't
|
|
2112
|
+
// get perpetuated into every newly-initialized project.
|
|
2113
|
+
if (entry.name.startsWith('._'))
|
|
2114
|
+
continue;
|
|
2077
2115
|
const srcPath = path.join(src, entry.name);
|
|
2078
2116
|
const destPath = path.join(dest, entry.name);
|
|
2079
2117
|
if (entry.isDirectory()) {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* containing hardcoded business logic. All business logic lives in MCP tool handlers.
|
|
9
9
|
*/
|
|
10
10
|
import type { MCPTool } from './mcp-tools/types.js';
|
|
11
|
+
export declare function isToolDisabled(toolName: string, cwd?: string): boolean;
|
|
11
12
|
/**
|
|
12
13
|
* MCP Client Error
|
|
13
14
|
*/
|
|
@@ -54,10 +55,14 @@ export declare function getToolMetadata(toolName: string): Omit<MCPTool, 'handle
|
|
|
54
55
|
* @param category - Optional category filter
|
|
55
56
|
* @returns Array of tool metadata
|
|
56
57
|
*/
|
|
57
|
-
export declare function listMCPTools(category?: string): Array<Omit<MCPTool, 'handler'
|
|
58
|
+
export declare function listMCPTools(category?: string): Array<Omit<MCPTool, 'handler'> & {
|
|
59
|
+
enabled: boolean;
|
|
60
|
+
}>;
|
|
58
61
|
/**
|
|
59
|
-
* Return all registered tools including their handler functions
|
|
60
|
-
* Used by startHttpServer() to register tools
|
|
62
|
+
* Return all registered tools including their handler functions, excluding
|
|
63
|
+
* any disabled via `mcp toggle`. Used by startHttpServer() to register tools
|
|
64
|
+
* with the HTTP/WS MCP server, so a disabled tool is never exposed to
|
|
65
|
+
* external MCP clients after the next server start.
|
|
61
66
|
*/
|
|
62
67
|
export declare function getAllMCPTools(): MCPTool[];
|
|
63
68
|
/**
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* This provides a simple interface for CLI commands to call MCP tools without
|
|
8
8
|
* containing hardcoded business logic. All business logic lives in MCP tool handlers.
|
|
9
9
|
*/
|
|
10
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
11
|
+
import { join } from 'node:path';
|
|
10
12
|
// Import MCP tool handlers from local package
|
|
11
13
|
import { agentTools } from './mcp-tools/agent-tools.js';
|
|
12
14
|
import { swarmTools } from './mcp-tools/swarm-tools.js';
|
|
@@ -95,6 +97,30 @@ registerTools([
|
|
|
95
97
|
// Second Brain knowledge tools
|
|
96
98
|
...knowledgeTools,
|
|
97
99
|
]);
|
|
100
|
+
/**
|
|
101
|
+
* Disabled-tools registry (`mcp toggle`)
|
|
102
|
+
*
|
|
103
|
+
* Read fresh on every check (the file is tiny and toggles are infrequent) so a
|
|
104
|
+
* `mcp toggle` run in another process/session takes effect without restarting
|
|
105
|
+
* this one. Filters both direct invocation (callMCPTool) and MCP server
|
|
106
|
+
* registration (getAllMCPTools) so a disabled tool is actually excluded, not
|
|
107
|
+
* just cosmetically hidden.
|
|
108
|
+
*/
|
|
109
|
+
function loadDisabledTools(cwd = process.cwd()) {
|
|
110
|
+
const stateFile = join(cwd, '.monomind', 'mcp-disabled-tools.json');
|
|
111
|
+
if (!existsSync(stateFile))
|
|
112
|
+
return new Set();
|
|
113
|
+
try {
|
|
114
|
+
const parsed = JSON.parse(readFileSync(stateFile, 'utf8'));
|
|
115
|
+
return Array.isArray(parsed) ? new Set(parsed) : new Set();
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return new Set();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export function isToolDisabled(toolName, cwd) {
|
|
122
|
+
return loadDisabledTools(cwd).has(toolName);
|
|
123
|
+
}
|
|
98
124
|
/**
|
|
99
125
|
* MCP Client Error
|
|
100
126
|
*/
|
|
@@ -138,6 +164,9 @@ export async function callMCPTool(toolName, input = {}, context) {
|
|
|
138
164
|
if (!tool) {
|
|
139
165
|
throw new MCPClientError(`MCP tool not found: ${toolName}`, toolName);
|
|
140
166
|
}
|
|
167
|
+
if (isToolDisabled(toolName)) {
|
|
168
|
+
throw new MCPClientError(`MCP tool '${toolName}' is disabled. Re-enable with: mcp toggle --enable ${toolName}`, toolName);
|
|
169
|
+
}
|
|
141
170
|
try {
|
|
142
171
|
// Call the tool handler
|
|
143
172
|
const result = await tool.handler(input, context);
|
|
@@ -179,6 +208,7 @@ export function getToolMetadata(toolName) {
|
|
|
179
208
|
*/
|
|
180
209
|
export function listMCPTools(category) {
|
|
181
210
|
const tools = Array.from(TOOL_REGISTRY.values());
|
|
211
|
+
const disabled = loadDisabledTools();
|
|
182
212
|
const filtered = category
|
|
183
213
|
? tools.filter(t => t.category === category)
|
|
184
214
|
: tools;
|
|
@@ -191,14 +221,18 @@ export function listMCPTools(category) {
|
|
|
191
221
|
version: tool.version,
|
|
192
222
|
cacheable: tool.cacheable,
|
|
193
223
|
cacheTTL: tool.cacheTTL,
|
|
224
|
+
enabled: !disabled.has(tool.name),
|
|
194
225
|
}));
|
|
195
226
|
}
|
|
196
227
|
/**
|
|
197
|
-
* Return all registered tools including their handler functions
|
|
198
|
-
* Used by startHttpServer() to register tools
|
|
228
|
+
* Return all registered tools including their handler functions, excluding
|
|
229
|
+
* any disabled via `mcp toggle`. Used by startHttpServer() to register tools
|
|
230
|
+
* with the HTTP/WS MCP server, so a disabled tool is never exposed to
|
|
231
|
+
* external MCP clients after the next server start.
|
|
199
232
|
*/
|
|
200
233
|
export function getAllMCPTools() {
|
|
201
|
-
|
|
234
|
+
const disabled = loadDisabledTools();
|
|
235
|
+
return Array.from(TOOL_REGISTRY.values()).filter(t => !disabled.has(t.name));
|
|
202
236
|
}
|
|
203
237
|
/**
|
|
204
238
|
* Check if an MCP tool exists
|
|
@@ -190,9 +190,15 @@ export class MCPServerManager extends EventEmitter {
|
|
|
190
190
|
if (!pid) {
|
|
191
191
|
// No PID file found. Detect if we are running in stdio mode
|
|
192
192
|
// (e.g., launched by Claude Code via `claude mcp add`).
|
|
193
|
-
|
|
193
|
+
//
|
|
194
|
+
// SECURITY/CORRECTNESS: this must NOT fall back to a TTY heuristic
|
|
195
|
+
// (`!process.stdin.isTTY`) — that is true for ANY non-interactive
|
|
196
|
+
// invocation (piped, in CI, in a script), so it falsely reported
|
|
197
|
+
// "running" even when no server was actually started. Only trust
|
|
198
|
+
// real state: the explicit stdio-transport env var, or the
|
|
199
|
+
// `_stdioServerStarted` flag that tracks an actually-started server.
|
|
194
200
|
const envTransport = process.env.MONOMIND_MCP_TRANSPORT;
|
|
195
|
-
if (
|
|
201
|
+
if (envTransport === 'stdio' || this._stdioServerStarted) {
|
|
196
202
|
return {
|
|
197
203
|
running: true,
|
|
198
204
|
pid: process.pid,
|
|
@@ -5,5 +5,25 @@
|
|
|
5
5
|
* Includes model routing integration for intelligent model selection.
|
|
6
6
|
*/
|
|
7
7
|
import { type MCPTool } from './types.js';
|
|
8
|
+
type ClaudeModel = 'haiku' | 'sonnet' | 'opus' | 'inherit';
|
|
9
|
+
interface AgentRecord {
|
|
10
|
+
agentId: string;
|
|
11
|
+
agentType: string;
|
|
12
|
+
status: 'idle' | 'busy' | 'terminated';
|
|
13
|
+
health: number;
|
|
14
|
+
taskCount: number;
|
|
15
|
+
config: Record<string, unknown>;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
domain?: string;
|
|
18
|
+
model?: ClaudeModel;
|
|
19
|
+
modelRoutedBy?: 'explicit' | 'router' | 'agent-booster' | 'default';
|
|
20
|
+
lastResult?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
interface AgentStore {
|
|
23
|
+
agents: Record<string, AgentRecord>;
|
|
24
|
+
version: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function loadAgentStore(): AgentStore;
|
|
8
27
|
export declare const agentTools: MCPTool[];
|
|
28
|
+
export {};
|
|
9
29
|
//# sourceMappingURL=agent-tools.d.ts.map
|
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
import { existsSync, readFileSync, writeFileSync, renameSync, mkdirSync, statSync } from 'node:fs';
|
|
8
8
|
import { join } from 'node:path';
|
|
9
9
|
import { randomBytes } from 'node:crypto';
|
|
10
|
-
import {
|
|
11
|
-
// Storage paths
|
|
12
|
-
|
|
10
|
+
import { getMonomindDataRoot, migrateLegacyStoreFile } from './types.js';
|
|
11
|
+
// Storage paths — relative to the git-safe data root (see getMonomindDataRoot()).
|
|
12
|
+
// Canonical location matches task-tools.ts/session-tools.ts/hive-mind-tools.ts/
|
|
13
|
+
// swarm-tools.ts so the agent store is a single physical file across all tools.
|
|
13
14
|
const AGENT_DIR = 'agents';
|
|
14
15
|
const AGENT_FILE = 'store.json';
|
|
15
16
|
function getAgentDir() {
|
|
16
|
-
return join(
|
|
17
|
+
return join(getMonomindDataRoot(), AGENT_DIR);
|
|
17
18
|
}
|
|
18
19
|
function getAgentPath() {
|
|
19
20
|
return join(getAgentDir(), AGENT_FILE);
|
|
@@ -25,9 +26,13 @@ function ensureAgentDir() {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
const MAX_AGENT_STORE_BYTES = 50 * 1024 * 1024;
|
|
28
|
-
|
|
29
|
+
// Exported so other tool modules reading the same physical store file
|
|
30
|
+
// (e.g. hive-mind-tools.ts) can reuse this hardened loader instead of
|
|
31
|
+
// maintaining their own weaker copy (missing the size cap / __proto__ guard).
|
|
32
|
+
export function loadAgentStore() {
|
|
29
33
|
try {
|
|
30
34
|
const path = getAgentPath();
|
|
35
|
+
migrateLegacyStoreFile(path, join(AGENT_DIR, AGENT_FILE));
|
|
31
36
|
if (existsSync(path)) {
|
|
32
37
|
if (statSync(path).size > MAX_AGENT_STORE_BYTES)
|
|
33
38
|
return { agents: {}, version: '3.0.0' };
|
|
@@ -47,12 +47,12 @@ export declare function resetInstallAttempts(): void;
|
|
|
47
47
|
*/
|
|
48
48
|
export declare const OPTIONAL_PACKAGES: {
|
|
49
49
|
readonly 'monofence-ai': {
|
|
50
|
-
readonly description:
|
|
51
|
-
readonly tools: readonly [
|
|
50
|
+
readonly description: 'AI manipulation defense (prompt injection, PII detection)';
|
|
51
|
+
readonly tools: readonly ['aidefence_scan', 'aidefence_analyze', 'aidefence_stats', 'aidefence_learn'];
|
|
52
52
|
};
|
|
53
53
|
readonly 'onnxruntime-node': {
|
|
54
|
-
readonly description:
|
|
55
|
-
readonly tools: readonly [
|
|
54
|
+
readonly description: 'ONNX runtime for neural network inference';
|
|
55
|
+
readonly tools: readonly ['neural_*'];
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
58
|
declare const _default: {
|
|
@@ -62,12 +62,12 @@ declare const _default: {
|
|
|
62
62
|
resetInstallAttempts: typeof resetInstallAttempts;
|
|
63
63
|
OPTIONAL_PACKAGES: {
|
|
64
64
|
readonly 'monofence-ai': {
|
|
65
|
-
readonly description:
|
|
66
|
-
readonly tools: readonly [
|
|
65
|
+
readonly description: 'AI manipulation defense (prompt injection, PII detection)';
|
|
66
|
+
readonly tools: readonly ['aidefence_scan', 'aidefence_analyze', 'aidefence_stats', 'aidefence_learn'];
|
|
67
67
|
};
|
|
68
68
|
readonly 'onnxruntime-node': {
|
|
69
|
-
readonly description:
|
|
70
|
-
readonly tools: readonly [
|
|
69
|
+
readonly description: 'ONNX runtime for neural network inference';
|
|
70
|
+
readonly tools: readonly ['neural_*'];
|
|
71
71
|
};
|
|
72
72
|
};
|
|
73
73
|
};
|