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,15 @@
1
+ /**
2
+ * ProjectConventionsProvider — loads project-level conventions (e.g. from
3
+ * CLAUDE.md or a config file) and injects them as a required context section.
4
+ */
5
+ import { BaseContextProvider, type RunContext } from './context-provider.js';
6
+ export type ConventionsLoader = () => string;
7
+ export declare class ProjectConventionsProvider extends BaseContextProvider {
8
+ private readonly loader;
9
+ readonly name: "project-conventions";
10
+ readonly priority = 100;
11
+ readonly required = true;
12
+ constructor(loader: ConventionsLoader);
13
+ provide(_ctx: RunContext): Promise<string>;
14
+ }
15
+ //# sourceMappingURL=project-conventions-provider.d.ts.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * ProjectConventionsProvider — loads project-level conventions (e.g. from
3
+ * CLAUDE.md or a config file) and injects them as a required context section.
4
+ */
5
+ import { BaseContextProvider } from './context-provider.js';
6
+ export class ProjectConventionsProvider extends BaseContextProvider {
7
+ loader;
8
+ name = 'project-conventions';
9
+ priority = 100;
10
+ required = true;
11
+ constructor(loader) {
12
+ super();
13
+ this.loader = loader;
14
+ }
15
+ async provide(_ctx) {
16
+ return this.loader();
17
+ }
18
+ }
19
+ //# sourceMappingURL=project-conventions-provider.js.map
@@ -0,0 +1,26 @@
1
+ /**
2
+ * PromptAssembler — collects context sections from multiple providers,
3
+ * prioritises them within a token budget, and concatenates the result
4
+ * with the base prompt.
5
+ */
6
+ import type { ContextProvider, RunContext } from './context-provider.js';
7
+ export interface AssemblyConfig {
8
+ maxTotalTokens?: number;
9
+ basePromptTokens: number;
10
+ providers: ContextProvider[];
11
+ }
12
+ export interface AssembledPrompt {
13
+ content: string;
14
+ sectionsIncluded: string[];
15
+ sectionsTruncated: string[];
16
+ sectionsDropped: string[];
17
+ totalTokenEstimate: number;
18
+ }
19
+ export declare class PromptAssembler {
20
+ private readonly maxTotalTokens;
21
+ private readonly basePromptTokens;
22
+ private readonly providers;
23
+ constructor(config: AssemblyConfig);
24
+ assemble(basePrompt: string, ctx: RunContext): Promise<AssembledPrompt>;
25
+ }
26
+ //# sourceMappingURL=prompt-assembler.d.ts.map
@@ -0,0 +1,93 @@
1
+ /**
2
+ * PromptAssembler — collects context sections from multiple providers,
3
+ * prioritises them within a token budget, and concatenates the result
4
+ * with the base prompt.
5
+ */
6
+ const DEFAULT_MAX_TOTAL_TOKENS = 6000;
7
+ const CHARS_PER_TOKEN = 4;
8
+ const SECTION_SEPARATOR = '\n\n---\n\n';
9
+ function estimateTokens(text) {
10
+ return Math.ceil(text.length / CHARS_PER_TOKEN);
11
+ }
12
+ function truncateToTokens(text, maxTokens) {
13
+ const maxChars = maxTokens * CHARS_PER_TOKEN;
14
+ if (text.length <= maxChars) {
15
+ return text;
16
+ }
17
+ return text.slice(0, maxChars);
18
+ }
19
+ export class PromptAssembler {
20
+ maxTotalTokens;
21
+ basePromptTokens;
22
+ providers;
23
+ constructor(config) {
24
+ this.maxTotalTokens = config.maxTotalTokens ?? DEFAULT_MAX_TOTAL_TOKENS;
25
+ this.basePromptTokens = config.basePromptTokens;
26
+ this.providers = config.providers;
27
+ }
28
+ async assemble(basePrompt, ctx) {
29
+ // 1. Call all providers concurrently
30
+ const settled = await Promise.allSettled(this.providers.map(async (p) => {
31
+ const content = await p.provide(ctx);
32
+ return {
33
+ name: p.name,
34
+ content,
35
+ tokens: estimateTokens(content),
36
+ priority: p.priority,
37
+ required: p.required,
38
+ };
39
+ }));
40
+ // 2. Filter out rejected / empty results
41
+ const sections = [];
42
+ for (const result of settled) {
43
+ if (result.status === 'fulfilled' && result.value.content.length > 0) {
44
+ sections.push(result.value);
45
+ }
46
+ }
47
+ // 3. Sort by priority descending
48
+ sections.sort((a, b) => b.priority - a.priority);
49
+ // 4. Fit within budget
50
+ const budget = this.maxTotalTokens - this.basePromptTokens;
51
+ let remaining = budget;
52
+ const included = [];
53
+ const truncated = [];
54
+ const dropped = [];
55
+ for (const section of sections) {
56
+ if (section.tokens <= remaining) {
57
+ // Fits entirely
58
+ included.push(section);
59
+ remaining -= section.tokens;
60
+ }
61
+ else if (section.required) {
62
+ // Required but exceeds remaining — truncate to fit
63
+ const truncatedContent = truncateToTokens(section.content, remaining);
64
+ included.push({
65
+ ...section,
66
+ content: truncatedContent,
67
+ tokens: estimateTokens(truncatedContent),
68
+ });
69
+ truncated.push(section.name);
70
+ remaining -= estimateTokens(truncatedContent);
71
+ }
72
+ else {
73
+ // Optional and doesn't fit — drop
74
+ dropped.push(section.name);
75
+ }
76
+ }
77
+ // 5. Build final prompt: context sections first, then base prompt
78
+ const contextParts = included.map((s) => s.content);
79
+ const assembled = contextParts.length > 0
80
+ ? contextParts.join(SECTION_SEPARATOR) +
81
+ SECTION_SEPARATOR +
82
+ basePrompt
83
+ : basePrompt;
84
+ return {
85
+ content: assembled,
86
+ sectionsIncluded: included.map((s) => s.name),
87
+ sectionsTruncated: truncated,
88
+ sectionsDropped: dropped,
89
+ totalTokenEstimate: estimateTokens(assembled),
90
+ };
91
+ }
92
+ }
93
+ //# sourceMappingURL=prompt-assembler.js.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * TaskHistoryProvider — searches memory for previously completed tasks that
3
+ * are similar to the current one and formats them as markdown context.
4
+ */
5
+ import { BaseContextProvider, type RunContext } from './context-provider.js';
6
+ export interface SearchResult {
7
+ metadata: Record<string, unknown>;
8
+ value: string;
9
+ score: number;
10
+ }
11
+ export type SearchFn = (query: string, options: {
12
+ namespace: string;
13
+ limit: number;
14
+ minScore: number;
15
+ }) => Promise<SearchResult[]>;
16
+ export declare class TaskHistoryProvider extends BaseContextProvider {
17
+ private readonly search;
18
+ readonly name: "task-history";
19
+ readonly priority = 50;
20
+ readonly maxTokens = 600;
21
+ constructor(search: SearchFn);
22
+ provide(ctx: RunContext): Promise<string>;
23
+ }
24
+ //# sourceMappingURL=task-history-provider.d.ts.map
@@ -0,0 +1,32 @@
1
+ /**
2
+ * TaskHistoryProvider — searches memory for previously completed tasks that
3
+ * are similar to the current one and formats them as markdown context.
4
+ */
5
+ import { BaseContextProvider } from './context-provider.js';
6
+ export class TaskHistoryProvider extends BaseContextProvider {
7
+ search;
8
+ name = 'task-history';
9
+ priority = 50;
10
+ maxTokens = 600;
11
+ constructor(search) {
12
+ super();
13
+ this.search = search;
14
+ }
15
+ async provide(ctx) {
16
+ const results = await this.search(ctx.taskDescription, {
17
+ namespace: 'tasks',
18
+ limit: 5,
19
+ minScore: 0.6,
20
+ });
21
+ if (!results || results.length === 0) {
22
+ return '';
23
+ }
24
+ const lines = ['**Similar past tasks:**'];
25
+ for (const r of results) {
26
+ const label = r.metadata?.['title'] ?? r.value.slice(0, 80);
27
+ lines.push(`- (${(r.score * 100).toFixed(0)}%) ${label}`);
28
+ }
29
+ return this.truncateToTokens(lines.join('\n'), this.maxTokens);
30
+ }
31
+ }
32
+ //# sourceMappingURL=task-history-provider.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * UserPreferencesProvider — fetches user-level preferences for the active
3
+ * session and formats them as a bullet list for injection into the prompt.
4
+ */
5
+ import { BaseContextProvider, type RunContext } from './context-provider.js';
6
+ export type PreferencesGetter = (sessionId: string) => Promise<Record<string, string>>;
7
+ export declare class UserPreferencesProvider extends BaseContextProvider {
8
+ private readonly getter;
9
+ readonly name: "user-preferences";
10
+ readonly priority = 90;
11
+ constructor(getter: PreferencesGetter);
12
+ provide(ctx: RunContext): Promise<string>;
13
+ }
14
+ //# sourceMappingURL=user-preferences-provider.d.ts.map
@@ -0,0 +1,27 @@
1
+ /**
2
+ * UserPreferencesProvider — fetches user-level preferences for the active
3
+ * session and formats them as a bullet list for injection into the prompt.
4
+ */
5
+ import { BaseContextProvider } from './context-provider.js';
6
+ export class UserPreferencesProvider extends BaseContextProvider {
7
+ getter;
8
+ name = 'user-preferences';
9
+ priority = 90;
10
+ constructor(getter) {
11
+ super();
12
+ this.getter = getter;
13
+ }
14
+ async provide(ctx) {
15
+ const prefs = await this.getter(ctx.sessionId);
16
+ const entries = Object.entries(prefs);
17
+ if (entries.length === 0) {
18
+ return '';
19
+ }
20
+ const lines = ['**User preferences:**'];
21
+ for (const [key, value] of entries) {
22
+ lines.push(`- ${key}: ${value}`);
23
+ }
24
+ return this.truncateToTokens(lines.join('\n'), this.maxTokens);
25
+ }
26
+ }
27
+ //# sourceMappingURL=user-preferences-provider.js.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * DLQ Reader (Task 37)
3
+ *
4
+ * Reads, filters, and purges DLQ entries from JSONL storage.
5
+ */
6
+ import type { DLQEntry, DLQEntryStatus } from '../../../shared/src/types/dlq.js';
7
+ /** Options for listing DLQ entries */
8
+ export interface DLQListOptions {
9
+ status?: DLQEntryStatus;
10
+ toolName?: string;
11
+ agentId?: string;
12
+ olderThanDays?: number;
13
+ limit?: number;
14
+ }
15
+ export declare class DLQReader {
16
+ private readonly filePath;
17
+ constructor(filePath: string);
18
+ /** Read all entries from the JSONL file with a hard size cap.
19
+ * The DLQ is append-only with no rotation — without this guard a long-running
20
+ * process can grow the file to GBs and OOM on every list/get/purge call. */
21
+ private readAll;
22
+ /** Write all entries back (used for purge) — uses unique tmp filename to avoid concurrent writer collisions */
23
+ private writeAll;
24
+ /** List entries with optional filters (defaults to status='pending') */
25
+ list(opts?: DLQListOptions): DLQEntry[];
26
+ /** Get a single entry by messageId */
27
+ get(messageId: string): DLQEntry | null;
28
+ /** Purge old pending entries (mark as 'purged') */
29
+ purge(olderThanDays: number): number;
30
+ }
31
+ //# sourceMappingURL=dlq-reader.d.ts.map
@@ -0,0 +1,81 @@
1
+ /**
2
+ * DLQ Reader (Task 37)
3
+ *
4
+ * Reads, filters, and purges DLQ entries from JSONL storage.
5
+ */
6
+ import { randomUUID } from 'crypto';
7
+ import { existsSync, readFileSync, writeFileSync, renameSync, statSync, unlinkSync } from 'fs';
8
+ import { parseJsonl } from '../utils/parse-jsonl.js';
9
+ export class DLQReader {
10
+ filePath;
11
+ constructor(filePath) {
12
+ this.filePath = filePath;
13
+ }
14
+ /** Read all entries from the JSONL file with a hard size cap.
15
+ * The DLQ is append-only with no rotation — without this guard a long-running
16
+ * process can grow the file to GBs and OOM on every list/get/purge call. */
17
+ readAll() {
18
+ if (!existsSync(this.filePath))
19
+ return [];
20
+ const stat = statSync(this.filePath);
21
+ if (stat.size > 256 * 1024 * 1024) {
22
+ throw new Error(`DLQ file exceeds 256MB (${stat.size} bytes). Run rotation/cleanup.`);
23
+ }
24
+ const raw = readFileSync(this.filePath, 'utf-8');
25
+ return parseJsonl(raw);
26
+ }
27
+ /** Write all entries back (used for purge) — uses unique tmp filename to avoid concurrent writer collisions */
28
+ writeAll(entries) {
29
+ const content = entries.map((e) => JSON.stringify(e)).join('\n') + (entries.length ? '\n' : '');
30
+ const tmp = `${this.filePath}.${randomUUID()}.tmp`;
31
+ try {
32
+ writeFileSync(tmp, content, 'utf-8');
33
+ renameSync(tmp, this.filePath);
34
+ }
35
+ catch (err) {
36
+ try {
37
+ unlinkSync(tmp);
38
+ }
39
+ catch { /* ignore cleanup failure */ }
40
+ throw err;
41
+ }
42
+ }
43
+ /** List entries with optional filters (defaults to status='pending') */
44
+ list(opts = {}) {
45
+ const status = opts.status ?? 'pending';
46
+ let entries = this.readAll().filter((e) => e.status === status);
47
+ if (opts.toolName) {
48
+ entries = entries.filter((e) => e.toolName === opts.toolName);
49
+ }
50
+ if (opts.agentId) {
51
+ entries = entries.filter((e) => e.agentId === opts.agentId);
52
+ }
53
+ if (opts.olderThanDays !== undefined) {
54
+ const cutoff = Date.now() - opts.olderThanDays * 24 * 60 * 60 * 1000;
55
+ entries = entries.filter((e) => new Date(e.createdAt).getTime() < cutoff);
56
+ }
57
+ if (opts.limit !== undefined) {
58
+ entries = entries.slice(0, opts.limit);
59
+ }
60
+ return entries;
61
+ }
62
+ /** Get a single entry by messageId */
63
+ get(messageId) {
64
+ return this.readAll().find((e) => e.messageId === messageId) ?? null;
65
+ }
66
+ /** Purge old pending entries (mark as 'purged') */
67
+ purge(olderThanDays) {
68
+ const entries = this.readAll();
69
+ const cutoff = Date.now() - olderThanDays * 24 * 60 * 60 * 1000;
70
+ let count = 0;
71
+ for (const entry of entries) {
72
+ if (entry.status === 'pending' && new Date(entry.createdAt).getTime() < cutoff) {
73
+ entry.status = 'purged';
74
+ count++;
75
+ }
76
+ }
77
+ this.writeAll(entries);
78
+ return count;
79
+ }
80
+ }
81
+ //# sourceMappingURL=dlq-reader.js.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * DLQ Writer (Task 37)
3
+ *
4
+ * JSONL append-only storage for dead-letter queue entries.
5
+ */
6
+ import type { DLQEntry, DeliveryAttempt } from '../../../shared/src/types/dlq.js';
7
+ /** Input for enqueue — caller provides these fields */
8
+ export interface EnqueueInput {
9
+ toolName: string;
10
+ originalPayload: unknown;
11
+ deliveryAttempts: DeliveryAttempt[];
12
+ agentId?: string;
13
+ swarmId?: string;
14
+ tags?: string[];
15
+ }
16
+ export declare class DLQWriter {
17
+ private readonly filePath;
18
+ constructor(dataDir: string);
19
+ /** Enqueue a failed message into the DLQ */
20
+ enqueue(input: EnqueueInput): DLQEntry;
21
+ /** Get the file path (for reader/replayer) */
22
+ getFilePath(): string;
23
+ }
24
+ //# sourceMappingURL=dlq-writer.d.ts.map
@@ -0,0 +1,65 @@
1
+ /**
2
+ * DLQ Writer (Task 37)
3
+ *
4
+ * JSONL append-only storage for dead-letter queue entries.
5
+ */
6
+ import { randomUUID } from 'crypto';
7
+ import { existsSync, mkdirSync, appendFileSync } from 'fs';
8
+ import { join, resolve, sep } from 'path';
9
+ export class DLQWriter {
10
+ filePath;
11
+ constructor(dataDir) {
12
+ const resolvedDataDir = resolve(dataDir);
13
+ const allowedRoot = resolve(process.env.MONOMIND_DATA_DIR ?? process.cwd());
14
+ if (resolvedDataDir !== allowedRoot && !resolvedDataDir.startsWith(allowedRoot + sep)) {
15
+ throw new Error(`DLQ dataDir escapes allowed root: ${resolvedDataDir}`);
16
+ }
17
+ if (!existsSync(resolvedDataDir)) {
18
+ mkdirSync(resolvedDataDir, { recursive: true });
19
+ }
20
+ this.filePath = join(resolvedDataDir, 'dead-letter-queue.jsonl');
21
+ }
22
+ /** Enqueue a failed message into the DLQ */
23
+ enqueue(input) {
24
+ const lastAttempt = input.deliveryAttempts[input.deliveryAttempts.length - 1];
25
+ const firstAttempt = input.deliveryAttempts[0];
26
+ const entry = {
27
+ messageId: randomUUID(),
28
+ toolName: input.toolName,
29
+ originalPayload: input.originalPayload,
30
+ deliveryAttempts: input.deliveryAttempts,
31
+ finalError: lastAttempt?.errorMessage ?? 'unknown',
32
+ finalErrorType: lastAttempt?.errorType ?? 'unknown',
33
+ agentId: input.agentId,
34
+ swarmId: input.swarmId,
35
+ createdAt: firstAttempt?.attemptedAt ?? new Date().toISOString(),
36
+ archivedAt: new Date().toISOString(),
37
+ status: 'pending',
38
+ tags: input.tags ?? [],
39
+ };
40
+ // JSON.stringify can throw on circular references, BigInt, and non-serializable
41
+ // values. originalPayload is `unknown` (caller-controlled), so a malicious or
42
+ // malformed input could otherwise crash the writer mid-flight. Fall back to
43
+ // a sanitized record so the audit trail is preserved.
44
+ let serialized;
45
+ try {
46
+ serialized = JSON.stringify(entry);
47
+ }
48
+ catch {
49
+ serialized = JSON.stringify({
50
+ messageId: entry.messageId,
51
+ toolName: entry.toolName,
52
+ archivedAt: entry.archivedAt,
53
+ status: 'pending',
54
+ finalError: 'serialize_failed',
55
+ });
56
+ }
57
+ appendFileSync(this.filePath, serialized + '\n', 'utf-8');
58
+ return entry;
59
+ }
60
+ /** Get the file path (for reader/replayer) */
61
+ getFilePath() {
62
+ return this.filePath;
63
+ }
64
+ }
65
+ //# sourceMappingURL=dlq-writer.js.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * DLQ Module Barrel (Task 37)
3
+ */
4
+ export { DLQWriter } from './dlq-writer.js';
5
+ export type { EnqueueInput } from './dlq-writer.js';
6
+ export { DLQReader } from './dlq-reader.js';
7
+ export type { DLQListOptions } from './dlq-reader.js';
8
+ export { DLQReplayer } from './dlq-replayer.js';
9
+ export type { ToolCaller } from './dlq-replayer.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * DLQ Module Barrel (Task 37)
3
+ */
4
+ export { DLQWriter } from './dlq-writer.js';
5
+ export { DLQReader } from './dlq-reader.js';
6
+ export { DLQReplayer } from './dlq-replayer.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,33 @@
1
+ import type { EvalDataset, EvalDatasetEntry, EvalTrace } from '../../../shared/src/types/eval.js';
2
+ export interface CreateFromTracesOpts {
3
+ name: string;
4
+ description: string;
5
+ traces: EvalTrace[];
6
+ agentSlugs?: string[];
7
+ }
8
+ export declare class DatasetManager {
9
+ private datasetsPath;
10
+ private entriesPath;
11
+ constructor(datasetsPath: string, entriesPath: string);
12
+ /**
13
+ * Create a dataset from a set of filtered traces.
14
+ */
15
+ createFromTraces(opts: CreateFromTracesOpts): EvalDataset;
16
+ /**
17
+ * List all datasets.
18
+ */
19
+ listDatasets(): EvalDataset[];
20
+ /**
21
+ * Get entries for a specific dataset.
22
+ */
23
+ getEntries(datasetId: string): EvalDatasetEntry[];
24
+ /**
25
+ * Add a single trace to an existing dataset.
26
+ */
27
+ addTraceToDataset(datasetId: string, traceId: string): EvalDatasetEntry;
28
+ /**
29
+ * Export a dataset to a JSON file. Output path must be within `allowedRoot`.
30
+ */
31
+ exportToFile(datasetId: string, outputPath: string, allowedRoot?: string): void;
32
+ }
33
+ //# sourceMappingURL=dataset-manager.d.ts.map
@@ -0,0 +1,107 @@
1
+ /**
2
+ * DatasetManager - JSONL-based eval dataset management (Task 33)
3
+ */
4
+ import { randomUUID } from 'crypto';
5
+ import { appendFileSync, readFileSync, writeFileSync, renameSync, existsSync, statSync } from 'fs';
6
+ import { resolve, sep } from 'path';
7
+ import { parseJsonl } from '../utils/parse-jsonl.js';
8
+ export class DatasetManager {
9
+ datasetsPath;
10
+ entriesPath;
11
+ constructor(datasetsPath, entriesPath) {
12
+ this.datasetsPath = datasetsPath;
13
+ this.entriesPath = entriesPath;
14
+ }
15
+ /**
16
+ * Create a dataset from a set of filtered traces.
17
+ */
18
+ createFromTraces(opts) {
19
+ const now = new Date().toISOString();
20
+ const agentSlugs = opts.agentSlugs ?? [...new Set(opts.traces.map((t) => t.agentSlug))];
21
+ const dataset = {
22
+ datasetId: randomUUID(),
23
+ name: opts.name,
24
+ description: opts.description,
25
+ agentSlugs,
26
+ createdAt: now,
27
+ updatedAt: now,
28
+ entryCount: opts.traces.length,
29
+ };
30
+ appendFileSync(this.datasetsPath, JSON.stringify(dataset) + '\n', 'utf-8');
31
+ for (const trace of opts.traces) {
32
+ const entry = {
33
+ entryId: randomUUID(),
34
+ datasetId: dataset.datasetId,
35
+ traceId: trace.traceId,
36
+ addedAt: now,
37
+ };
38
+ appendFileSync(this.entriesPath, JSON.stringify(entry) + '\n', 'utf-8');
39
+ }
40
+ return dataset;
41
+ }
42
+ /**
43
+ * List all datasets.
44
+ */
45
+ listDatasets() {
46
+ if (!existsSync(this.datasetsPath))
47
+ return [];
48
+ if (statSync(this.datasetsPath).size > 50 * 1024 * 1024) {
49
+ throw new Error('Dataset file exceeds 50MB — run cleanup');
50
+ }
51
+ const content = readFileSync(this.datasetsPath, 'utf-8');
52
+ return parseJsonl(content);
53
+ }
54
+ /**
55
+ * Get entries for a specific dataset.
56
+ */
57
+ getEntries(datasetId) {
58
+ if (!existsSync(this.entriesPath))
59
+ return [];
60
+ if (statSync(this.entriesPath).size > 50 * 1024 * 1024) {
61
+ throw new Error('Entries file exceeds 50MB — run cleanup');
62
+ }
63
+ const content = readFileSync(this.entriesPath, 'utf-8');
64
+ return parseJsonl(content).filter((e) => e.datasetId === datasetId);
65
+ }
66
+ /**
67
+ * Add a single trace to an existing dataset.
68
+ */
69
+ addTraceToDataset(datasetId, traceId) {
70
+ const entry = {
71
+ entryId: randomUUID(),
72
+ datasetId,
73
+ traceId,
74
+ addedAt: new Date().toISOString(),
75
+ };
76
+ appendFileSync(this.entriesPath, JSON.stringify(entry) + '\n', 'utf-8');
77
+ // Update dataset entryCount via atomic write
78
+ const datasets = this.listDatasets();
79
+ const updated = datasets.map((d) => {
80
+ if (d.datasetId === datasetId) {
81
+ return { ...d, entryCount: d.entryCount + 1, updatedAt: new Date().toISOString() };
82
+ }
83
+ return d;
84
+ });
85
+ const tmp = `${this.datasetsPath}.${randomUUID()}.tmp`;
86
+ writeFileSync(tmp, updated.map((d) => JSON.stringify(d)).join('\n') + '\n', 'utf-8');
87
+ renameSync(tmp, this.datasetsPath);
88
+ return entry;
89
+ }
90
+ /**
91
+ * Export a dataset to a JSON file. Output path must be within `allowedRoot`.
92
+ */
93
+ exportToFile(datasetId, outputPath, allowedRoot) {
94
+ if (allowedRoot) {
95
+ const resolvedOut = resolve(outputPath);
96
+ const resolvedRoot = resolve(allowedRoot);
97
+ if (!resolvedOut.startsWith(resolvedRoot + sep) && resolvedOut !== resolvedRoot) {
98
+ throw new Error(`Export path escapes allowed root: ${resolvedOut}`);
99
+ }
100
+ }
101
+ const datasets = this.listDatasets();
102
+ const dataset = datasets.find((d) => d.datasetId === datasetId);
103
+ const entries = this.getEntries(datasetId);
104
+ writeFileSync(outputPath, JSON.stringify({ dataset, entries }, null, 2), 'utf-8');
105
+ }
106
+ }
107
+ //# sourceMappingURL=dataset-manager.js.map
@@ -0,0 +1,23 @@
1
+ import type { EvalRunResult, EvalTrace } from '../../../shared/src/types/eval.js';
2
+ export interface AgentRunnerResult {
3
+ agentOutput: string;
4
+ outcome: 'success' | 'failure' | 'timeout';
5
+ qualityScore: number;
6
+ latencyMs: number;
7
+ }
8
+ export interface DatasetRunOpts {
9
+ datasetId: string;
10
+ agentVersion: string;
11
+ traces: EvalTrace[];
12
+ agentRunner: (trace: EvalTrace) => Promise<AgentRunnerResult>;
13
+ baselineResult?: EvalRunResult;
14
+ regressionThreshold?: number;
15
+ }
16
+ export declare class DatasetRunner {
17
+ /**
18
+ * Run all traces through the agent runner and compute stats.
19
+ * Optionally compare against a baseline to detect regressions.
20
+ */
21
+ run(opts: DatasetRunOpts): Promise<EvalRunResult>;
22
+ }
23
+ //# sourceMappingURL=dataset-runner.d.ts.map