monomind 1.11.13 → 1.11.14

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.
Files changed (231) hide show
  1. package/.claude/commands/mastermind/idea.md +1 -1
  2. package/.claude/commands/mastermind/master.md +1 -1
  3. package/.claude/scheduled_tasks.lock +1 -1
  4. package/.claude/skills/mastermind/_protocol.md +4 -4
  5. package/.claude/skills/mastermind/architect.md +4 -7
  6. package/.claude/skills/mastermind/autodev.md +2 -4
  7. package/.claude/skills/mastermind/build.md +3 -3
  8. package/.claude/skills/mastermind/content.md +3 -3
  9. package/.claude/skills/mastermind/createorg.md +2 -2
  10. package/.claude/skills/mastermind/finance.md +3 -3
  11. package/.claude/skills/mastermind/idea.md +0 -8
  12. package/.claude/skills/mastermind/marketing.md +3 -3
  13. package/.claude/skills/mastermind/monitor.md +2 -2
  14. package/.claude/skills/mastermind/ops.md +3 -3
  15. package/.claude/skills/mastermind/release.md +3 -3
  16. package/.claude/skills/mastermind/research.md +3 -3
  17. package/.claude/skills/mastermind/review.md +3 -3
  18. package/.claude/skills/mastermind/sales.md +3 -3
  19. package/README.md +286 -129
  20. package/package.json +2 -2
  21. package/packages/@monomind/cli/README.md +286 -129
  22. package/packages/@monomind/cli/bundled-graph/dist/src/build.js +73 -0
  23. package/packages/@monomind/cli/bundled-graph/dist/src/cluster.js +120 -0
  24. package/packages/@monomind/cli/bundled-graph/package.json +57 -0
  25. package/packages/@monomind/cli/dist/src/agents/halt-signal.d.ts +25 -0
  26. package/packages/@monomind/cli/dist/src/agents/halt-signal.js +76 -0
  27. package/packages/@monomind/cli/dist/src/agents/index.d.ts +18 -0
  28. package/packages/@monomind/cli/dist/src/agents/index.js +13 -0
  29. package/packages/@monomind/cli/dist/src/agents/managed-agent.d.ts +41 -0
  30. package/packages/@monomind/cli/dist/src/agents/managed-agent.js +69 -0
  31. package/packages/@monomind/cli/dist/src/agents/prompt-experiment.d.ts +23 -0
  32. package/packages/@monomind/cli/dist/src/agents/prompt-experiment.js +49 -0
  33. package/packages/@monomind/cli/dist/src/agents/prompt-version-manager.d.ts +22 -0
  34. package/packages/@monomind/cli/dist/src/agents/prompt-version-manager.js +80 -0
  35. package/packages/@monomind/cli/dist/src/agents/registry-query.d.ts +71 -0
  36. package/packages/@monomind/cli/dist/src/agents/registry-query.js +125 -0
  37. package/packages/@monomind/cli/dist/src/agents/score-decay.d.ts +19 -0
  38. package/packages/@monomind/cli/dist/src/agents/score-decay.js +22 -0
  39. package/packages/@monomind/cli/dist/src/agents/shared-instructions-loader.d.ts +13 -0
  40. package/packages/@monomind/cli/dist/src/agents/shared-instructions-loader.js +40 -0
  41. package/packages/@monomind/cli/dist/src/agents/specialization-scorer.d.ts +54 -0
  42. package/packages/@monomind/cli/dist/src/agents/specialization-scorer.js +212 -0
  43. package/packages/@monomind/cli/dist/src/agents/termination-watcher.d.ts +30 -0
  44. package/packages/@monomind/cli/dist/src/agents/termination-watcher.js +84 -0
  45. package/packages/@monomind/cli/dist/src/agents/trigger-index.d.ts +20 -0
  46. package/packages/@monomind/cli/dist/src/agents/trigger-index.js +38 -0
  47. package/packages/@monomind/cli/dist/src/agents/trigger-scanner.d.ts +64 -0
  48. package/packages/@monomind/cli/dist/src/agents/trigger-scanner.js +308 -0
  49. package/packages/@monomind/cli/dist/src/agents/version-diff.d.ts +18 -0
  50. package/packages/@monomind/cli/dist/src/agents/version-diff.js +64 -0
  51. package/packages/@monomind/cli/dist/src/agents/version-store.d.ts +60 -0
  52. package/packages/@monomind/cli/dist/src/agents/version-store.js +235 -0
  53. package/packages/@monomind/cli/dist/src/benchmarks/pretrain/index.d.ts +45 -0
  54. package/packages/@monomind/cli/dist/src/benchmarks/pretrain/index.js +404 -0
  55. package/packages/@monomind/cli/dist/src/commands/agent-wasm.d.ts +14 -0
  56. package/packages/@monomind/cli/dist/src/commands/agent-wasm.js +333 -0
  57. package/packages/@monomind/cli/dist/src/commands/doctor.js +55 -1
  58. package/packages/@monomind/cli/dist/src/commands/ui.js +68 -0
  59. package/packages/@monomind/cli/dist/src/consensus/index.d.ts +7 -0
  60. package/packages/@monomind/cli/dist/src/consensus/index.js +6 -0
  61. package/packages/@monomind/cli/dist/src/context/context-provider.d.ts +44 -0
  62. package/packages/@monomind/cli/dist/src/context/context-provider.js +25 -0
  63. package/packages/@monomind/cli/dist/src/context/git-state-provider.d.ts +12 -0
  64. package/packages/@monomind/cli/dist/src/context/git-state-provider.js +34 -0
  65. package/packages/@monomind/cli/dist/src/context/index.d.ts +12 -0
  66. package/packages/@monomind/cli/dist/src/context/index.js +12 -0
  67. package/packages/@monomind/cli/dist/src/context/project-conventions-provider.d.ts +15 -0
  68. package/packages/@monomind/cli/dist/src/context/project-conventions-provider.js +19 -0
  69. package/packages/@monomind/cli/dist/src/context/prompt-assembler.d.ts +26 -0
  70. package/packages/@monomind/cli/dist/src/context/prompt-assembler.js +93 -0
  71. package/packages/@monomind/cli/dist/src/context/task-history-provider.d.ts +24 -0
  72. package/packages/@monomind/cli/dist/src/context/task-history-provider.js +32 -0
  73. package/packages/@monomind/cli/dist/src/context/user-preferences-provider.d.ts +14 -0
  74. package/packages/@monomind/cli/dist/src/context/user-preferences-provider.js +27 -0
  75. package/packages/@monomind/cli/dist/src/dlq/dlq-reader.d.ts +31 -0
  76. package/packages/@monomind/cli/dist/src/dlq/dlq-reader.js +81 -0
  77. package/packages/@monomind/cli/dist/src/dlq/dlq-writer.d.ts +24 -0
  78. package/packages/@monomind/cli/dist/src/dlq/dlq-writer.js +65 -0
  79. package/packages/@monomind/cli/dist/src/dlq/index.d.ts +10 -0
  80. package/packages/@monomind/cli/dist/src/dlq/index.js +7 -0
  81. package/packages/@monomind/cli/dist/src/eval/dataset-manager.d.ts +33 -0
  82. package/packages/@monomind/cli/dist/src/eval/dataset-manager.js +107 -0
  83. package/packages/@monomind/cli/dist/src/eval/dataset-runner.d.ts +23 -0
  84. package/packages/@monomind/cli/dist/src/eval/dataset-runner.js +59 -0
  85. package/packages/@monomind/cli/dist/src/eval/index.d.ts +10 -0
  86. package/packages/@monomind/cli/dist/src/eval/index.js +7 -0
  87. package/packages/@monomind/cli/dist/src/eval/trace-collector.d.ts +40 -0
  88. package/packages/@monomind/cli/dist/src/eval/trace-collector.js +102 -0
  89. package/packages/@monomind/cli/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
  90. package/packages/@monomind/cli/dist/src/infrastructure/in-memory-repositories.js +264 -0
  91. package/packages/@monomind/cli/dist/src/init/statusline-generator.js +3 -3
  92. package/packages/@monomind/cli/dist/src/interactive/interrupt.d.ts +22 -0
  93. package/packages/@monomind/cli/dist/src/interactive/interrupt.js +71 -0
  94. package/packages/@monomind/cli/dist/src/mcp/deprecation-injector.d.ts +25 -0
  95. package/packages/@monomind/cli/dist/src/mcp/deprecation-injector.js +48 -0
  96. package/packages/@monomind/cli/dist/src/mcp/tool-registry.d.ts +61 -0
  97. package/packages/@monomind/cli/dist/src/mcp/tool-registry.js +246 -0
  98. package/packages/@monomind/cli/dist/src/mcp-tools/wasm-agent-tools.d.ts +9 -0
  99. package/packages/@monomind/cli/dist/src/mcp-tools/wasm-agent-tools.js +230 -0
  100. package/packages/@monomind/cli/dist/src/model/complexity-scorer.d.ts +21 -0
  101. package/packages/@monomind/cli/dist/src/model/complexity-scorer.js +106 -0
  102. package/packages/@monomind/cli/dist/src/model/index.d.ts +4 -0
  103. package/packages/@monomind/cli/dist/src/model/index.js +4 -0
  104. package/packages/@monomind/cli/dist/src/model/model-settings.d.ts +22 -0
  105. package/packages/@monomind/cli/dist/src/model/model-settings.js +33 -0
  106. package/packages/@monomind/cli/dist/src/model/model-tier-resolver.d.ts +24 -0
  107. package/packages/@monomind/cli/dist/src/model/model-tier-resolver.js +65 -0
  108. package/packages/@monomind/cli/dist/src/monovector/capabilities.d.ts +34 -0
  109. package/packages/@monomind/cli/dist/src/monovector/capabilities.js +37 -0
  110. package/packages/@monomind/cli/dist/src/observability/replay-reader.d.ts +1 -1
  111. package/packages/@monomind/cli/dist/src/orchestration/index.d.ts +7 -0
  112. package/packages/@monomind/cli/dist/src/orchestration/index.js +6 -0
  113. package/packages/@monomind/cli/dist/src/orchestration/mode-dispatcher.d.ts +11 -0
  114. package/packages/@monomind/cli/dist/src/orchestration/mode-dispatcher.js +31 -0
  115. package/packages/@monomind/cli/dist/src/orchestration/routing-modes.d.ts +68 -0
  116. package/packages/@monomind/cli/dist/src/orchestration/routing-modes.js +180 -0
  117. package/packages/@monomind/cli/dist/src/plugins/tests/demo-plugin-store.d.ts +7 -0
  118. package/packages/@monomind/cli/dist/src/plugins/tests/demo-plugin-store.js +126 -0
  119. package/packages/@monomind/cli/dist/src/plugins/tests/standalone-test.d.ts +12 -0
  120. package/packages/@monomind/cli/dist/src/plugins/tests/standalone-test.js +188 -0
  121. package/packages/@monomind/cli/dist/src/plugins/tests/test-plugin-store.d.ts +7 -0
  122. package/packages/@monomind/cli/dist/src/plugins/tests/test-plugin-store.js +206 -0
  123. package/packages/@monomind/cli/dist/src/runtime/headless.d.ts +60 -0
  124. package/packages/@monomind/cli/dist/src/runtime/headless.js +284 -0
  125. package/packages/@monomind/cli/dist/src/services/agentic-flow-bridge.d.ts +50 -0
  126. package/packages/@monomind/cli/dist/src/services/agentic-flow-bridge.js +95 -0
  127. package/packages/@monomind/cli/dist/src/services/container-worker-pool.d.ts +197 -0
  128. package/packages/@monomind/cli/dist/src/services/container-worker-pool.js +623 -0
  129. package/packages/@monomind/cli/dist/src/services/index.d.ts +13 -0
  130. package/packages/@monomind/cli/dist/src/services/index.js +11 -0
  131. package/packages/@monomind/cli/dist/src/services/worker-queue.d.ts +201 -0
  132. package/packages/@monomind/cli/dist/src/services/worker-queue.js +594 -0
  133. package/packages/@monomind/cli/dist/src/swarm/communication-graph.d.ts +25 -0
  134. package/packages/@monomind/cli/dist/src/swarm/communication-graph.js +77 -0
  135. package/packages/@monomind/cli/dist/src/swarm/flow-enforcer.d.ts +31 -0
  136. package/packages/@monomind/cli/dist/src/swarm/flow-enforcer.js +61 -0
  137. package/packages/@monomind/cli/dist/src/swarm/flow-visualizer.d.ts +19 -0
  138. package/packages/@monomind/cli/dist/src/swarm/flow-visualizer.js +68 -0
  139. package/packages/@monomind/cli/dist/src/transfer/deploy-seraphine.d.ts +13 -0
  140. package/packages/@monomind/cli/dist/src/transfer/deploy-seraphine.js +205 -0
  141. package/packages/@monomind/cli/dist/src/transfer/store/tests/standalone-test.d.ts +12 -0
  142. package/packages/@monomind/cli/dist/src/transfer/store/tests/standalone-test.js +190 -0
  143. package/packages/@monomind/cli/dist/src/transfer/test-seraphine.d.ts +6 -0
  144. package/packages/@monomind/cli/dist/src/transfer/test-seraphine.js +105 -0
  145. package/packages/@monomind/cli/dist/src/transfer/tests/test-store.d.ts +7 -0
  146. package/packages/@monomind/cli/dist/src/transfer/tests/test-store.js +214 -0
  147. package/packages/@monomind/cli/dist/src/workflow/condition-evaluator.d.ts +10 -0
  148. package/packages/@monomind/cli/dist/src/workflow/condition-evaluator.js +82 -0
  149. package/packages/@monomind/cli/dist/src/workflow/context-resolver.d.ts +12 -0
  150. package/packages/@monomind/cli/dist/src/workflow/context-resolver.js +23 -0
  151. package/packages/@monomind/cli/dist/src/workflow/dag-builder.d.ts +17 -0
  152. package/packages/@monomind/cli/dist/src/workflow/dag-builder.js +129 -0
  153. package/packages/@monomind/cli/dist/src/workflow/dag-executor.d.ts +9 -0
  154. package/packages/@monomind/cli/dist/src/workflow/dag-executor.js +116 -0
  155. package/packages/@monomind/cli/dist/src/workflow/dag-types.d.ts +41 -0
  156. package/packages/@monomind/cli/dist/src/workflow/dag-types.js +8 -0
  157. package/packages/@monomind/cli/dist/src/workflow/dsl-parser.d.ts +12 -0
  158. package/packages/@monomind/cli/dist/src/workflow/dsl-parser.js +20 -0
  159. package/packages/@monomind/cli/dist/src/workflow/dsl-schema.d.ts +165 -0
  160. package/packages/@monomind/cli/dist/src/workflow/dsl-schema.js +82 -0
  161. package/packages/@monomind/cli/dist/src/workflow/index.d.ts +13 -0
  162. package/packages/@monomind/cli/dist/src/workflow/index.js +11 -0
  163. package/packages/@monomind/cli/dist/src/workflow/template-engine.d.ts +11 -0
  164. package/packages/@monomind/cli/dist/src/workflow/template-engine.js +40 -0
  165. package/packages/@monomind/cli/dist/src/workflow/workflow-executor.d.ts +29 -0
  166. package/packages/@monomind/cli/dist/src/workflow/workflow-executor.js +227 -0
  167. package/packages/@monomind/cli/package.json +9 -9
  168. package/packages/@monomind/guidance/dist/adversarial.d.ts +284 -0
  169. package/packages/@monomind/guidance/dist/adversarial.js +572 -0
  170. package/packages/@monomind/guidance/dist/analyzer.d.ts +530 -0
  171. package/packages/@monomind/guidance/dist/analyzer.js +2518 -0
  172. package/packages/@monomind/guidance/dist/artifacts.d.ts +283 -0
  173. package/packages/@monomind/guidance/dist/artifacts.js +356 -0
  174. package/packages/@monomind/guidance/dist/authority.d.ts +290 -0
  175. package/packages/@monomind/guidance/dist/authority.js +558 -0
  176. package/packages/@monomind/guidance/dist/capabilities.d.ts +209 -0
  177. package/packages/@monomind/guidance/dist/capabilities.js +485 -0
  178. package/packages/@monomind/guidance/dist/coherence.d.ts +233 -0
  179. package/packages/@monomind/guidance/dist/coherence.js +372 -0
  180. package/packages/@monomind/guidance/dist/compiler.d.ts +87 -0
  181. package/packages/@monomind/guidance/dist/compiler.js +419 -0
  182. package/packages/@monomind/guidance/dist/conformance-kit.d.ts +225 -0
  183. package/packages/@monomind/guidance/dist/conformance-kit.js +629 -0
  184. package/packages/@monomind/guidance/dist/continue-gate.d.ts +214 -0
  185. package/packages/@monomind/guidance/dist/continue-gate.js +353 -0
  186. package/packages/@monomind/guidance/dist/crypto-utils.d.ts +17 -0
  187. package/packages/@monomind/guidance/dist/crypto-utils.js +24 -0
  188. package/packages/@monomind/guidance/dist/evolution.d.ts +282 -0
  189. package/packages/@monomind/guidance/dist/evolution.js +500 -0
  190. package/packages/@monomind/guidance/dist/gates.d.ts +79 -0
  191. package/packages/@monomind/guidance/dist/gates.js +302 -0
  192. package/packages/@monomind/guidance/dist/gateway.d.ts +206 -0
  193. package/packages/@monomind/guidance/dist/gateway.js +452 -0
  194. package/packages/@monomind/guidance/dist/generators.d.ts +153 -0
  195. package/packages/@monomind/guidance/dist/generators.js +682 -0
  196. package/packages/@monomind/guidance/dist/headless.d.ts +177 -0
  197. package/packages/@monomind/guidance/dist/headless.js +342 -0
  198. package/packages/@monomind/guidance/dist/hooks.d.ts +109 -0
  199. package/packages/@monomind/guidance/dist/hooks.js +347 -0
  200. package/packages/@monomind/guidance/dist/index.d.ts +205 -0
  201. package/packages/@monomind/guidance/dist/index.js +321 -0
  202. package/packages/@monomind/guidance/dist/ledger.d.ts +162 -0
  203. package/packages/@monomind/guidance/dist/ledger.js +375 -0
  204. package/packages/@monomind/guidance/dist/manifest-validator.d.ts +289 -0
  205. package/packages/@monomind/guidance/dist/manifest-validator.js +838 -0
  206. package/packages/@monomind/guidance/dist/memory-gate.d.ts +222 -0
  207. package/packages/@monomind/guidance/dist/memory-gate.js +382 -0
  208. package/packages/@monomind/guidance/dist/meta-governance.d.ts +265 -0
  209. package/packages/@monomind/guidance/dist/meta-governance.js +348 -0
  210. package/packages/@monomind/guidance/dist/optimizer.d.ts +104 -0
  211. package/packages/@monomind/guidance/dist/optimizer.js +329 -0
  212. package/packages/@monomind/guidance/dist/persistence.d.ts +189 -0
  213. package/packages/@monomind/guidance/dist/persistence.js +464 -0
  214. package/packages/@monomind/guidance/dist/proof.d.ts +185 -0
  215. package/packages/@monomind/guidance/dist/proof.js +238 -0
  216. package/packages/@monomind/guidance/dist/retriever.d.ts +116 -0
  217. package/packages/@monomind/guidance/dist/retriever.js +394 -0
  218. package/packages/@monomind/guidance/dist/ruvbot-integration.d.ts +370 -0
  219. package/packages/@monomind/guidance/dist/ruvbot-integration.js +738 -0
  220. package/packages/@monomind/guidance/dist/temporal.d.ts +426 -0
  221. package/packages/@monomind/guidance/dist/temporal.js +658 -0
  222. package/packages/@monomind/guidance/dist/trust.d.ts +283 -0
  223. package/packages/@monomind/guidance/dist/trust.js +473 -0
  224. package/packages/@monomind/guidance/dist/truth-anchors.d.ts +276 -0
  225. package/packages/@monomind/guidance/dist/truth-anchors.js +488 -0
  226. package/packages/@monomind/guidance/dist/types.d.ts +378 -0
  227. package/packages/@monomind/guidance/dist/types.js +10 -0
  228. package/packages/@monomind/guidance/dist/uncertainty.d.ts +372 -0
  229. package/packages/@monomind/guidance/dist/uncertainty.js +619 -0
  230. package/packages/@monomind/guidance/dist/wasm-kernel.d.ts +48 -0
  231. package/packages/@monomind/guidance/dist/wasm-kernel.js +158 -0
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Deprecation Injector (Task 31)
3
+ *
4
+ * Injects deprecation warnings into MCP tool responses when the
5
+ * invoked tool has been marked as deprecated in the ToolRegistry.
6
+ */
7
+ /**
8
+ * Injects deprecation metadata into MCP responses.
9
+ */
10
+ export class DeprecationInjector {
11
+ registry;
12
+ constructor(registry) {
13
+ this.registry = registry;
14
+ }
15
+ /**
16
+ * If `toolName` is deprecated, augment the response with a warning.
17
+ *
18
+ * Returns the original response unmodified when the tool is not
19
+ * deprecated. When deprecated, adds `_deprecation` metadata.
20
+ *
21
+ * Warning format:
22
+ * [DEPRECATED] Tool "<name>" is deprecated. <message>. Use "<successor>" instead.
23
+ */
24
+ inject(response, toolName) {
25
+ const tool = this.registry.getVersion(toolName);
26
+ if (!tool || !tool.deprecated) {
27
+ return response;
28
+ }
29
+ const parts = [`[DEPRECATED] Tool "${toolName}" is deprecated.`];
30
+ if (tool.deprecationMessage) {
31
+ parts.push(tool.deprecationMessage + '.');
32
+ }
33
+ if (tool.successor) {
34
+ parts.push(`Use "${tool.successor}" instead.`);
35
+ }
36
+ const warning = parts.join(' ');
37
+ return {
38
+ ...response,
39
+ _deprecation: {
40
+ warning,
41
+ deprecated: true,
42
+ successor: tool.successor ?? null,
43
+ deprecatedAt: tool.deprecatedAt ?? null,
44
+ },
45
+ };
46
+ }
47
+ }
48
+ //# sourceMappingURL=deprecation-injector.js.map
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Tool Registry (Task 31)
3
+ *
4
+ * Manages semver versioning for MCP tools with deprecation tracking
5
+ * and tool-to-agent impact analysis. Uses JSONL file storage.
6
+ */
7
+ import type { VersionedMCPTool, ToolVersionEntry } from '../../../shared/src/types/tool-version.js';
8
+ /**
9
+ * Registry for versioned MCP tools.
10
+ *
11
+ * Stores tool metadata and version history in a JSONL file.
12
+ * Supports deprecation marking and agent impact analysis.
13
+ */
14
+ export declare class ToolRegistry {
15
+ private tools;
16
+ private history;
17
+ private readonly storagePath;
18
+ constructor(storagePath?: string);
19
+ /**
20
+ * Register a new tool or update an existing one.
21
+ */
22
+ register(tool: VersionedMCPTool): void;
23
+ /**
24
+ * Mark a tool as deprecated with an optional successor.
25
+ */
26
+ deprecate(toolName: string, message: string, successor?: string): void;
27
+ /**
28
+ * Get the current version info for a tool.
29
+ * Returns null if the tool is not registered.
30
+ */
31
+ getVersion(toolName: string): VersionedMCPTool | null;
32
+ /**
33
+ * List all deprecated tools.
34
+ */
35
+ listDeprecated(): VersionedMCPTool[];
36
+ /**
37
+ * Find agents that reference the given tool.
38
+ *
39
+ * Scans agent markdown files under the provided agents directory
40
+ * and returns slugs of agents whose `tools:` frontmatter or body
41
+ * mention the tool name.
42
+ */
43
+ getImpactedAgents(toolName: string, agentsDir?: string): string[];
44
+ /**
45
+ * Get the full version history for a tool, or all tools if no name given.
46
+ */
47
+ getHistory(toolName?: string): ToolVersionEntry[];
48
+ /**
49
+ * Get all registered tools.
50
+ */
51
+ listAll(): VersionedMCPTool[];
52
+ /**
53
+ * Load existing entries from the JSONL file on disk.
54
+ */
55
+ private loadFromDisk;
56
+ /**
57
+ * Append a version history entry and the current tool state to disk.
58
+ */
59
+ private appendEntry;
60
+ }
61
+ //# sourceMappingURL=tool-registry.d.ts.map
@@ -0,0 +1,246 @@
1
+ /**
2
+ * Tool Registry (Task 31)
3
+ *
4
+ * Manages semver versioning for MCP tools with deprecation tracking
5
+ * and tool-to-agent impact analysis. Uses JSONL file storage.
6
+ */
7
+ import { appendFileSync, readFileSync, existsSync, mkdirSync, readdirSync, lstatSync, } from 'fs';
8
+ import { join, dirname, extname, resolve, sep } from 'path';
9
+ /** Default JSONL storage path relative to project root. */
10
+ const DEFAULT_STORAGE_PATH = '.monomind/tool-versions.jsonl';
11
+ /**
12
+ * Registry for versioned MCP tools.
13
+ *
14
+ * Stores tool metadata and version history in a JSONL file.
15
+ * Supports deprecation marking and agent impact analysis.
16
+ */
17
+ export class ToolRegistry {
18
+ tools = new Map();
19
+ history = [];
20
+ storagePath;
21
+ constructor(storagePath = DEFAULT_STORAGE_PATH) {
22
+ const resolvedPath = resolve(storagePath);
23
+ const allowedRoot = process.env.MONOMIND_DATA_DIR
24
+ ? resolve(process.env.MONOMIND_DATA_DIR)
25
+ : resolve(process.cwd());
26
+ if (resolvedPath !== allowedRoot && !resolvedPath.startsWith(allowedRoot + sep)) {
27
+ throw new Error(`Tool registry storagePath escapes allowed root: ${resolvedPath}`);
28
+ }
29
+ this.storagePath = resolvedPath;
30
+ this.loadFromDisk();
31
+ }
32
+ /**
33
+ * Register a new tool or update an existing one.
34
+ */
35
+ register(tool) {
36
+ const existing = this.tools.get(tool.toolName);
37
+ const changeType = existing
38
+ ? 'updated'
39
+ : 'added';
40
+ this.tools.set(tool.toolName, { ...tool });
41
+ const entry = {
42
+ toolName: tool.toolName,
43
+ version: tool.version,
44
+ changeType,
45
+ changedAt: new Date().toISOString(),
46
+ description: changeType === 'added'
47
+ ? `Registered tool ${tool.toolName} v${tool.version}`
48
+ : `Updated tool ${tool.toolName} to v${tool.version}`,
49
+ };
50
+ this.history.push(entry);
51
+ this.appendEntry(entry);
52
+ }
53
+ /**
54
+ * Mark a tool as deprecated with an optional successor.
55
+ */
56
+ deprecate(toolName, message, successor) {
57
+ const tool = this.tools.get(toolName);
58
+ if (!tool) {
59
+ throw new Error(`Tool "${toolName}" not found in registry`);
60
+ }
61
+ tool.deprecated = true;
62
+ tool.deprecationMessage = message;
63
+ tool.deprecatedAt = new Date().toISOString();
64
+ if (successor) {
65
+ tool.successor = successor;
66
+ }
67
+ const entry = {
68
+ toolName,
69
+ version: tool.version,
70
+ changeType: 'deprecated',
71
+ changedAt: tool.deprecatedAt,
72
+ description: message,
73
+ };
74
+ this.history.push(entry);
75
+ this.appendEntry(entry);
76
+ }
77
+ /**
78
+ * Get the current version info for a tool.
79
+ * Returns null if the tool is not registered.
80
+ */
81
+ getVersion(toolName) {
82
+ return this.tools.get(toolName) ?? null;
83
+ }
84
+ /**
85
+ * List all deprecated tools.
86
+ */
87
+ listDeprecated() {
88
+ const result = [];
89
+ for (const tool of this.tools.values()) {
90
+ if (tool.deprecated) {
91
+ result.push({ ...tool });
92
+ }
93
+ }
94
+ return result;
95
+ }
96
+ /**
97
+ * Find agents that reference the given tool.
98
+ *
99
+ * Scans agent markdown files under the provided agents directory
100
+ * and returns slugs of agents whose `tools:` frontmatter or body
101
+ * mention the tool name.
102
+ */
103
+ getImpactedAgents(toolName, agentsDir = 'agents') {
104
+ // Reject empty or short tool names — `content.includes('')` returns true
105
+ // for every file, turning the registry into a directory enumerator.
106
+ if (typeof toolName !== 'string' || toolName.length < 2 || !/^[a-zA-Z0-9_.-]+$/.test(toolName)) {
107
+ return [];
108
+ }
109
+ const impacted = [];
110
+ const mdFiles = collectMdFiles(agentsDir);
111
+ for (const filePath of mdFiles) {
112
+ let content;
113
+ try {
114
+ content = readFileSync(filePath, 'utf-8');
115
+ }
116
+ catch {
117
+ continue;
118
+ }
119
+ if (content.includes(toolName)) {
120
+ // Derive slug from filename (strip .md extension)
121
+ const parts = filePath.split('/');
122
+ const filename = parts[parts.length - 1];
123
+ const slug = filename.replace(/\.md$/, '');
124
+ impacted.push(slug);
125
+ }
126
+ }
127
+ return impacted;
128
+ }
129
+ /**
130
+ * Get the full version history for a tool, or all tools if no name given.
131
+ */
132
+ getHistory(toolName) {
133
+ if (!toolName) {
134
+ return [...this.history];
135
+ }
136
+ return this.history.filter((e) => e.toolName === toolName);
137
+ }
138
+ /**
139
+ * Get all registered tools.
140
+ */
141
+ listAll() {
142
+ return Array.from(this.tools.values()).map((t) => ({ ...t }));
143
+ }
144
+ // ---- Private helpers ----
145
+ /**
146
+ * Load existing entries from the JSONL file on disk.
147
+ */
148
+ loadFromDisk() {
149
+ if (!existsSync(this.storagePath)) {
150
+ return;
151
+ }
152
+ let raw;
153
+ try {
154
+ raw = readFileSync(this.storagePath, 'utf-8');
155
+ }
156
+ catch {
157
+ return;
158
+ }
159
+ const NAME_RE = /^[a-zA-Z0-9_.-]{1,128}$/;
160
+ const STR_MAX = 500;
161
+ for (const line of raw.split('\n')) {
162
+ const trimmed = line.trim();
163
+ if (!trimmed)
164
+ continue;
165
+ try {
166
+ const record = JSON.parse(trimmed);
167
+ if (!record || typeof record !== 'object')
168
+ continue;
169
+ // Validate fields before storage. The JSONL file lives on disk; an
170
+ // attacker with local write access could otherwise plant attacker-controlled
171
+ // strings (e.g. malicious deprecationMessage with markup) that reach
172
+ // downstream renderers (DOT visualizer, deprecation-injector warnings).
173
+ if (record._type === 'tool') {
174
+ if (typeof record.toolName !== 'string' || !NAME_RE.test(record.toolName))
175
+ continue;
176
+ if (record.successor !== undefined && (typeof record.successor !== 'string' || !NAME_RE.test(record.successor)))
177
+ continue;
178
+ if (record.deprecationMessage !== undefined && (typeof record.deprecationMessage !== 'string' || record.deprecationMessage.length > STR_MAX))
179
+ continue;
180
+ this.tools.set(record.toolName, record);
181
+ }
182
+ else if (record._type === 'history') {
183
+ if (typeof record.toolName !== 'string' || !NAME_RE.test(record.toolName))
184
+ continue;
185
+ this.history.push(record);
186
+ }
187
+ }
188
+ catch {
189
+ // Skip malformed lines
190
+ }
191
+ }
192
+ }
193
+ /**
194
+ * Append a version history entry and the current tool state to disk.
195
+ */
196
+ appendEntry(entry) {
197
+ const dir = dirname(this.storagePath);
198
+ if (!existsSync(dir)) {
199
+ mkdirSync(dir, { recursive: true });
200
+ }
201
+ const tool = this.tools.get(entry.toolName);
202
+ const lines = [];
203
+ if (tool) {
204
+ lines.push(JSON.stringify({ _type: 'tool', ...tool }));
205
+ }
206
+ lines.push(JSON.stringify({ _type: 'history', ...entry }));
207
+ appendFileSync(this.storagePath, lines.join('\n') + '\n', 'utf-8');
208
+ }
209
+ }
210
+ /**
211
+ * Recursively collect all `.md` files under a directory.
212
+ */
213
+ function collectMdFiles(root) {
214
+ const results = [];
215
+ let entries;
216
+ try {
217
+ entries = readdirSync(root);
218
+ }
219
+ catch {
220
+ return results;
221
+ }
222
+ for (const entry of entries) {
223
+ const full = join(root, entry);
224
+ let stat;
225
+ try {
226
+ // Use lstatSync so symlinks aren't followed — otherwise a symlink under
227
+ // `agentsDir` could redirect this scan into arbitrary filesystem
228
+ // locations, which combined with `getImpactedAgents` becomes a content
229
+ // oracle that fingerprints arbitrary text files outside the project.
230
+ stat = lstatSync(full);
231
+ }
232
+ catch {
233
+ continue;
234
+ }
235
+ if (stat.isSymbolicLink())
236
+ continue;
237
+ if (stat.isDirectory()) {
238
+ results.push(...collectMdFiles(full));
239
+ }
240
+ else if (stat.isFile() && extname(entry) === '.md') {
241
+ results.push(full);
242
+ }
243
+ }
244
+ return results;
245
+ }
246
+ //# sourceMappingURL=tool-registry.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * WASM Agent MCP Tools
3
+ *
4
+ * Exposes @monoes/rvagent-wasm operations via MCP protocol.
5
+ * All tools gracefully degrade when the WASM package is not installed.
6
+ */
7
+ import type { MCPTool } from './types.js';
8
+ export declare const wasmAgentTools: MCPTool[];
9
+ //# sourceMappingURL=wasm-agent-tools.d.ts.map
@@ -0,0 +1,230 @@
1
+ /**
2
+ * WASM Agent MCP Tools
3
+ *
4
+ * Exposes @monoes/rvagent-wasm operations via MCP protocol.
5
+ * All tools gracefully degrade when the WASM package is not installed.
6
+ */
7
+ async function loadAgentWasm() {
8
+ const mod = await import('../monovector/agent-wasm.js');
9
+ return mod;
10
+ }
11
+ export const wasmAgentTools = [
12
+ {
13
+ name: 'wasm_agent_create',
14
+ description: 'Create a sandboxed WASM agent with virtual filesystem (no OS access). Optionally use a gallery template.',
15
+ inputSchema: {
16
+ type: 'object',
17
+ properties: {
18
+ template: { type: 'string', description: 'Gallery template name (coder, researcher, tester, reviewer, security, swarm)' },
19
+ model: { type: 'string', description: 'Model identifier (default: anthropic:claude-sonnet-4-20250514)' },
20
+ instructions: { type: 'string', description: 'System instructions for the agent' },
21
+ maxTurns: { type: 'number', description: 'Max conversation turns (default: 50)' },
22
+ },
23
+ },
24
+ handler: async (args) => {
25
+ try {
26
+ const wasm = await loadAgentWasm();
27
+ if (args.template) {
28
+ const info = await wasm.createAgentFromTemplate(args.template);
29
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, agent: info, source: 'gallery' }, null, 2) }] };
30
+ }
31
+ const info = await wasm.createWasmAgent({
32
+ model: args.model,
33
+ instructions: args.instructions,
34
+ maxTurns: args.maxTurns,
35
+ });
36
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, agent: info }, null, 2) }] };
37
+ }
38
+ catch (err) {
39
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
40
+ }
41
+ },
42
+ },
43
+ {
44
+ name: 'wasm_agent_prompt',
45
+ description: 'Send a prompt to a WASM agent and get a response.',
46
+ inputSchema: {
47
+ type: 'object',
48
+ properties: {
49
+ agentId: { type: 'string', description: 'WASM agent ID' },
50
+ input: { type: 'string', description: 'User prompt to send' },
51
+ },
52
+ required: ['agentId', 'input'],
53
+ },
54
+ handler: async (args) => {
55
+ try {
56
+ const wasm = await loadAgentWasm();
57
+ const result = await wasm.promptWasmAgent(args.agentId, args.input);
58
+ return { content: [{ type: 'text', text: result }] };
59
+ }
60
+ catch (err) {
61
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
62
+ }
63
+ },
64
+ },
65
+ {
66
+ name: 'wasm_agent_tool',
67
+ description: 'Execute a tool on a WASM agent sandbox. Tools: read_file, write_file, edit_file, write_todos, list_files. Use flat format: {tool, path, content, ...}.',
68
+ inputSchema: {
69
+ type: 'object',
70
+ properties: {
71
+ agentId: { type: 'string', description: 'WASM agent ID' },
72
+ toolName: { type: 'string', description: 'Tool name (read_file, write_file, edit_file, write_todos, list_files)' },
73
+ toolInput: { type: 'object', description: 'Tool parameters (flat: {path, content, old_string, new_string, todos})' },
74
+ },
75
+ required: ['agentId', 'toolName'],
76
+ },
77
+ handler: async (args) => {
78
+ try {
79
+ const wasm = await loadAgentWasm();
80
+ // Flat format: {tool: 'write_file', path: '...', content: '...'}
81
+ const toolCall = {
82
+ tool: args.toolName,
83
+ ...(args.toolInput ?? {}),
84
+ };
85
+ const result = await wasm.executeWasmTool(args.agentId, toolCall);
86
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
87
+ }
88
+ catch (err) {
89
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
90
+ }
91
+ },
92
+ },
93
+ {
94
+ name: 'wasm_agent_list',
95
+ description: 'List all active WASM agents.',
96
+ inputSchema: { type: 'object', properties: {} },
97
+ handler: async () => {
98
+ try {
99
+ const wasm = await loadAgentWasm();
100
+ const agents = wasm.listWasmAgents();
101
+ return { content: [{ type: 'text', text: JSON.stringify({ agents, count: agents.length }, null, 2) }] };
102
+ }
103
+ catch (err) {
104
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
105
+ }
106
+ },
107
+ },
108
+ {
109
+ name: 'wasm_agent_terminate',
110
+ description: 'Terminate a WASM agent and free resources.',
111
+ inputSchema: {
112
+ type: 'object',
113
+ properties: {
114
+ agentId: { type: 'string', description: 'WASM agent ID' },
115
+ },
116
+ required: ['agentId'],
117
+ },
118
+ handler: async (args) => {
119
+ try {
120
+ const wasm = await loadAgentWasm();
121
+ const ok = wasm.terminateWasmAgent(args.agentId);
122
+ return { content: [{ type: 'text', text: JSON.stringify({ success: ok }) }] };
123
+ }
124
+ catch (err) {
125
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
126
+ }
127
+ },
128
+ },
129
+ {
130
+ name: 'wasm_agent_files',
131
+ description: 'Get a WASM agent\'s available tools and info.',
132
+ inputSchema: {
133
+ type: 'object',
134
+ properties: {
135
+ agentId: { type: 'string', description: 'WASM agent ID' },
136
+ },
137
+ required: ['agentId'],
138
+ },
139
+ handler: async (args) => {
140
+ try {
141
+ const wasm = await loadAgentWasm();
142
+ const tools = wasm.getWasmAgentTools(args.agentId);
143
+ const info = wasm.getWasmAgent(args.agentId);
144
+ return { content: [{ type: 'text', text: JSON.stringify({ tools, fileCount: info?.fileCount ?? 0, turnCount: info?.turnCount ?? 0 }, null, 2) }] };
145
+ }
146
+ catch (err) {
147
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
148
+ }
149
+ },
150
+ },
151
+ {
152
+ name: 'wasm_agent_export',
153
+ description: 'Export a WASM agent\'s full state (config, filesystem, conversation) as JSON.',
154
+ inputSchema: {
155
+ type: 'object',
156
+ properties: {
157
+ agentId: { type: 'string', description: 'WASM agent ID' },
158
+ },
159
+ required: ['agentId'],
160
+ },
161
+ handler: async (args) => {
162
+ try {
163
+ const wasm = await loadAgentWasm();
164
+ const state = wasm.exportWasmState(args.agentId);
165
+ return { content: [{ type: 'text', text: state }] };
166
+ }
167
+ catch (err) {
168
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
169
+ }
170
+ },
171
+ },
172
+ {
173
+ name: 'wasm_gallery_list',
174
+ description: 'List all available WASM agent gallery templates (Coder, Researcher, Tester, Reviewer, Security, Swarm).',
175
+ inputSchema: { type: 'object', properties: {} },
176
+ handler: async () => {
177
+ try {
178
+ const wasm = await loadAgentWasm();
179
+ const templates = await wasm.listGalleryTemplates();
180
+ return { content: [{ type: 'text', text: JSON.stringify({ templates, count: templates.length }, null, 2) }] };
181
+ }
182
+ catch (err) {
183
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
184
+ }
185
+ },
186
+ },
187
+ {
188
+ name: 'wasm_gallery_search',
189
+ description: 'Search WASM agent gallery templates by query.',
190
+ inputSchema: {
191
+ type: 'object',
192
+ properties: {
193
+ query: { type: 'string', description: 'Search query' },
194
+ },
195
+ required: ['query'],
196
+ },
197
+ handler: async (args) => {
198
+ try {
199
+ const wasm = await loadAgentWasm();
200
+ const results = await wasm.searchGalleryTemplates(args.query);
201
+ return { content: [{ type: 'text', text: JSON.stringify({ results, count: results.length }, null, 2) }] };
202
+ }
203
+ catch (err) {
204
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
205
+ }
206
+ },
207
+ },
208
+ {
209
+ name: 'wasm_gallery_create',
210
+ description: 'Create a WASM agent from a gallery template.',
211
+ inputSchema: {
212
+ type: 'object',
213
+ properties: {
214
+ template: { type: 'string', description: 'Template name (coder, researcher, tester, reviewer, security, swarm)' },
215
+ },
216
+ required: ['template'],
217
+ },
218
+ handler: async (args) => {
219
+ try {
220
+ const wasm = await loadAgentWasm();
221
+ const info = await wasm.createAgentFromTemplate(args.template);
222
+ return { content: [{ type: 'text', text: JSON.stringify({ success: true, agent: info, template: args.template }, null, 2) }] };
223
+ }
224
+ catch (err) {
225
+ return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
226
+ }
227
+ },
228
+ },
229
+ ];
230
+ //# sourceMappingURL=wasm-agent-tools.js.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Heuristic complexity scorer for task descriptions.
3
+ *
4
+ * Returns a score in [0, 100] that drives automatic model-tier selection.
5
+ * Higher scores indicate tasks that benefit from more capable (and costly)
6
+ * models.
7
+ */
8
+ /**
9
+ * Agent slugs that inherently deal with high-complexity work.
10
+ * When one of these agents is involved the score gets a +20 bonus.
11
+ */
12
+ export declare const HIGH_COMPLEXITY_AGENTS: ReadonlySet<string>;
13
+ /**
14
+ * Score the complexity of a task description.
15
+ *
16
+ * @param taskDescription - Free-text description of the task.
17
+ * @param agentSlug - Optional agent identifier; certain agents boost the score.
18
+ * @returns A number in [0, 100].
19
+ */
20
+ export declare function scoreComplexity(taskDescription: string, agentSlug?: string): number;
21
+ //# sourceMappingURL=complexity-scorer.d.ts.map