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,105 @@
1
+ /**
2
+ * Test Seraphine Genesis Model
3
+ * Quick validation of the transfer pipeline
4
+ */
5
+ import * as fs from 'fs';
6
+ import * as path from 'path';
7
+ import { fileURLToPath } from 'url';
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+ // Simple test without complex imports
11
+ async function test() {
12
+ console.log('');
13
+ console.log('╔══════════════════════════════════════════════════════════╗');
14
+ console.log('║ SERAPHINE GENESIS TEST SUITE ║');
15
+ console.log('╚══════════════════════════════════════════════════════════╝');
16
+ console.log('');
17
+ let passed = 0;
18
+ let failed = 0;
19
+ // Test 1: Types file exists
20
+ const typesPath = path.join(__dirname, 'types.ts');
21
+ if (fs.existsSync(typesPath)) {
22
+ console.log('✅ Test 1: Types module exists');
23
+ passed++;
24
+ }
25
+ else {
26
+ console.log('❌ Test 1: Types module missing');
27
+ failed++;
28
+ }
29
+ // Test 2: Seraphine model exists
30
+ const seraphPath = path.join(__dirname, 'models', 'seraphine.ts');
31
+ if (fs.existsSync(seraphPath)) {
32
+ console.log('✅ Test 2: Seraphine model exists');
33
+ passed++;
34
+ }
35
+ else {
36
+ console.log('❌ Test 2: Seraphine model missing');
37
+ failed++;
38
+ }
39
+ // Test 3: CFP serializer exists
40
+ const cfpPath = path.join(__dirname, 'serialization', 'cfp.ts');
41
+ if (fs.existsSync(cfpPath)) {
42
+ console.log('✅ Test 3: CFP serializer exists');
43
+ passed++;
44
+ }
45
+ else {
46
+ console.log('❌ Test 3: CFP serializer missing');
47
+ failed++;
48
+ }
49
+ // Test 4: Anonymization module exists
50
+ const anonPath = path.join(__dirname, 'anonymization', 'index.ts');
51
+ if (fs.existsSync(anonPath)) {
52
+ console.log('✅ Test 4: Anonymization module exists');
53
+ passed++;
54
+ }
55
+ else {
56
+ console.log('❌ Test 4: Anonymization module missing');
57
+ failed++;
58
+ }
59
+ // Test 5: IPFS upload module exists
60
+ const ipfsPath = path.join(__dirname, 'ipfs', 'upload.ts');
61
+ if (fs.existsSync(ipfsPath)) {
62
+ console.log('✅ Test 5: IPFS upload module exists');
63
+ passed++;
64
+ }
65
+ else {
66
+ console.log('❌ Test 5: IPFS upload module missing');
67
+ failed++;
68
+ }
69
+ // Test 6: Export module exists
70
+ const exportPath = path.join(__dirname, 'export.ts');
71
+ if (fs.existsSync(exportPath)) {
72
+ console.log('✅ Test 6: Export module exists');
73
+ passed++;
74
+ }
75
+ else {
76
+ console.log('❌ Test 6: Export module missing');
77
+ failed++;
78
+ }
79
+ // Test 7: Index module exists
80
+ const indexPath = path.join(__dirname, 'index.ts');
81
+ if (fs.existsSync(indexPath)) {
82
+ console.log('✅ Test 7: Index module exists');
83
+ passed++;
84
+ }
85
+ else {
86
+ console.log('❌ Test 7: Index module missing');
87
+ failed++;
88
+ }
89
+ console.log('');
90
+ console.log('═══════════════════════════════════════════════════════════');
91
+ console.log(` Results: ${passed} passed, ${failed} failed`);
92
+ console.log('═══════════════════════════════════════════════════════════');
93
+ console.log('');
94
+ if (failed === 0) {
95
+ console.log('🎉 All module tests passed!');
96
+ console.log('');
97
+ console.log('Next steps:');
98
+ console.log(' 1. Compile TypeScript: cd packages/@monoes/cli && npm run build');
99
+ console.log(' 2. Run deployment: npx ts-node src/transfer/deploy-seraphine.ts --to-ipfs');
100
+ console.log('');
101
+ }
102
+ process.exit(failed > 0 ? 1 : 0);
103
+ }
104
+ test().catch(console.error);
105
+ //# sourceMappingURL=test-seraphine.js.map
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env npx tsx
2
+ /**
3
+ * Pattern Store Test Suite
4
+ * Tests list, search, download, and publish functionality
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=test-store.d.ts.map
@@ -0,0 +1,214 @@
1
+ #!/usr/bin/env npx tsx
2
+ /**
3
+ * Pattern Store Test Suite
4
+ * Tests list, search, download, and publish functionality
5
+ */
6
+ import { createDiscoveryService } from '../store/discovery.js';
7
+ import { searchPatterns, getSearchSuggestions, getTagCloud } from '../store/search.js';
8
+ import { createDownloader } from '../store/download.js';
9
+ import { createPublisher } from '../store/publish.js';
10
+ import { createSeraphineGenesis } from '../models/seraphine.js';
11
+ // Test results tracking
12
+ const results = [];
13
+ function logTest(name, passed, details) {
14
+ results.push({ test: name, passed, details });
15
+ const icon = passed ? '✅' : '❌';
16
+ console.log(`${icon} ${name}${details ? `: ${details}` : ''}`);
17
+ }
18
+ async function runTests() {
19
+ console.log('');
20
+ console.log('╔══════════════════════════════════════════════════════════╗');
21
+ console.log('║ PATTERN STORE TEST SUITE ║');
22
+ console.log('║ Testing List, Search, Download, Publish ║');
23
+ console.log('╚══════════════════════════════════════════════════════════╝');
24
+ console.log('');
25
+ // ==========================================================================
26
+ // 1. DISCOVERY TESTS
27
+ // ==========================================================================
28
+ console.log('─── Discovery Tests ───────────────────────────────────────');
29
+ try {
30
+ const discovery = createDiscoveryService();
31
+ logTest('Discovery service created', true);
32
+ // List registries
33
+ const registries = discovery.listRegistries();
34
+ logTest('List registries', registries.length > 0, `Found ${registries.length} registries`);
35
+ // Discover registry
36
+ const result = await discovery.discoverRegistry();
37
+ logTest('Discover registry', result.success, result.success
38
+ ? `Loaded ${result.registry?.patterns.length || 0} patterns`
39
+ : result.error);
40
+ // Cache test
41
+ if (result.success) {
42
+ const cachedResult = await discovery.discoverRegistry();
43
+ logTest('Cache hit', cachedResult.fromCache, 'Second request from cache');
44
+ }
45
+ console.log('');
46
+ // ==========================================================================
47
+ // 2. SEARCH TESTS
48
+ // ==========================================================================
49
+ console.log('─── Search Tests ──────────────────────────────────────────');
50
+ if (result.success && result.registry) {
51
+ const registry = result.registry;
52
+ // Basic search
53
+ const basicSearch = searchPatterns(registry);
54
+ logTest('Basic search', basicSearch.patterns.length > 0, `Found ${basicSearch.total} patterns`);
55
+ // Query search
56
+ const querySearch = searchPatterns(registry, { query: 'routing' });
57
+ logTest('Query search', true, `Query "routing" found ${querySearch.patterns.length} patterns`);
58
+ // Category filter
59
+ const categorySearch = searchPatterns(registry, { category: 'routing' });
60
+ logTest('Category filter', true, `Category "routing" found ${categorySearch.patterns.length} patterns`);
61
+ // Tag search
62
+ const tagSearch = searchPatterns(registry, { tags: ['genesis'] });
63
+ logTest('Tag search', true, `Tag "genesis" found ${tagSearch.patterns.length} patterns`);
64
+ // Verified filter
65
+ const verifiedSearch = searchPatterns(registry, { verified: true });
66
+ logTest('Verified filter', true, `Verified patterns: ${verifiedSearch.patterns.length}`);
67
+ // Sort by downloads
68
+ const sortedSearch = searchPatterns(registry, {
69
+ sortBy: 'downloads',
70
+ sortOrder: 'desc',
71
+ });
72
+ logTest('Sort by downloads', true, `Top pattern: ${sortedSearch.patterns[0]?.displayName || 'none'}`);
73
+ // Pagination
74
+ const page1 = searchPatterns(registry, { limit: 5, offset: 0 });
75
+ logTest('Pagination', page1.pageSize === 5, `Page 1 with ${page1.patterns.length} patterns, hasMore: ${page1.hasMore}`);
76
+ // Search suggestions
77
+ const suggestions = getSearchSuggestions(registry, 'rou');
78
+ logTest('Search suggestions', suggestions.length >= 0, `Suggestions for "rou": ${suggestions.slice(0, 3).join(', ')}`);
79
+ // Tag cloud
80
+ const tagCloud = getTagCloud(registry);
81
+ logTest('Tag cloud', tagCloud.size > 0, `${tagCloud.size} unique tags`);
82
+ }
83
+ console.log('');
84
+ // ==========================================================================
85
+ // 3. DOWNLOAD TESTS
86
+ // ==========================================================================
87
+ console.log('─── Download Tests ────────────────────────────────────────');
88
+ if (result.success && result.registry && result.registry.patterns.length > 0) {
89
+ const pattern = result.registry.patterns[0];
90
+ const downloader = createDownloader();
91
+ logTest('Downloader created', true);
92
+ // Download with progress
93
+ let progressCalled = false;
94
+ const downloadResult = await downloader.downloadPattern(pattern, {
95
+ verify: true,
96
+ }, (progress) => {
97
+ progressCalled = true;
98
+ });
99
+ logTest('Download pattern', downloadResult.success, downloadResult.success
100
+ ? `Downloaded ${downloadResult.size} bytes`
101
+ : 'Failed');
102
+ logTest('Progress callback', progressCalled, progressCalled ? 'Progress events received' : 'No progress events');
103
+ logTest('Checksum verification', downloadResult.verified !== undefined, `Verified: ${downloadResult.verified}`);
104
+ // Cache stats
105
+ const cacheStats = downloader.getCacheStats();
106
+ logTest('Cache statistics', cacheStats.count >= 0, `${cacheStats.count} items, ${cacheStats.totalSize} bytes`);
107
+ }
108
+ console.log('');
109
+ // ==========================================================================
110
+ // 4. PUBLISH TESTS
111
+ // ==========================================================================
112
+ console.log('─── Publish Tests ─────────────────────────────────────────');
113
+ const cfp = createSeraphineGenesis();
114
+ const publisher = createPublisher();
115
+ logTest('Publisher created', true);
116
+ // Validation
117
+ const validation = publisher.validateForPublish(cfp, {
118
+ name: 'test-pattern',
119
+ displayName: 'Test Pattern',
120
+ description: 'A test pattern for validation',
121
+ categories: ['testing'],
122
+ tags: ['test', 'validation', 'demo'],
123
+ license: 'MIT',
124
+ anonymize: 'standard',
125
+ });
126
+ logTest('Publish validation', validation.length === 0, validation.length === 0 ? 'All validations passed' : validation.join(', '));
127
+ // Preview
128
+ const preview = publisher.createPreview(cfp, {
129
+ name: 'seraphine-genesis',
130
+ displayName: 'Seraphine Genesis',
131
+ description: 'The foundational pattern model',
132
+ categories: ['routing', 'coordination'],
133
+ tags: ['genesis', 'foundational'],
134
+ license: 'MIT',
135
+ anonymize: 'standard',
136
+ });
137
+ logTest('Publish preview', preview !== null, `Preview created for ${preview.name}`);
138
+ // Publish (mock)
139
+ const publishResult = await publisher.publishPattern(cfp, {
140
+ name: 'test-pattern',
141
+ displayName: 'Test Pattern',
142
+ description: 'A test pattern published to IPFS',
143
+ categories: ['testing'],
144
+ tags: ['test', 'demo', 'hello-world'],
145
+ license: 'MIT',
146
+ anonymize: 'standard',
147
+ });
148
+ logTest('Publish to IPFS', publishResult.success, publishResult.success
149
+ ? `CID: ${publishResult.cid.slice(0, 20)}...`
150
+ : publishResult.message);
151
+ console.log('');
152
+ // ==========================================================================
153
+ // 5. INTEGRATION TEST
154
+ // ==========================================================================
155
+ console.log('─── Integration Test ──────────────────────────────────────');
156
+ // Full workflow: discover -> search -> download
157
+ const store = createDiscoveryService();
158
+ const discoverResult = await store.discoverRegistry();
159
+ if (discoverResult.success && discoverResult.registry) {
160
+ const searchResult = searchPatterns(discoverResult.registry, {
161
+ query: 'seraphine',
162
+ });
163
+ if (searchResult.patterns.length > 0) {
164
+ const dl = createDownloader();
165
+ const dlResult = await dl.downloadPattern(searchResult.patterns[0], {
166
+ verify: true,
167
+ });
168
+ logTest('Full workflow', dlResult.success, 'Discover → Search → Download completed');
169
+ }
170
+ else {
171
+ logTest('Full workflow', true, 'Discover → Search completed (no download)');
172
+ }
173
+ }
174
+ }
175
+ catch (error) {
176
+ console.error('Test error:', error);
177
+ logTest('Test suite', false, `Error: ${error}`);
178
+ }
179
+ // ==========================================================================
180
+ // SUMMARY
181
+ // ==========================================================================
182
+ console.log('');
183
+ console.log('═══════════════════════════════════════════════════════════');
184
+ console.log(' TEST SUMMARY ');
185
+ console.log('═══════════════════════════════════════════════════════════');
186
+ console.log('');
187
+ const passed = results.filter(r => r.passed).length;
188
+ const failed = results.filter(r => !r.passed).length;
189
+ const total = results.length;
190
+ console.log(` Total Tests: ${total}`);
191
+ console.log(` ✅ Passed: ${passed}`);
192
+ console.log(` ❌ Failed: ${failed}`);
193
+ console.log('');
194
+ if (failed === 0) {
195
+ console.log(' 🎉 All tests passed!');
196
+ console.log('');
197
+ console.log(' 📦 Store Features Verified:');
198
+ console.log(' - Registry discovery via IPNS');
199
+ console.log(' - Pattern search with filters');
200
+ console.log(' - Download with verification');
201
+ console.log(' - Publish with anonymization');
202
+ console.log('');
203
+ }
204
+ else {
205
+ console.log(' ⚠️ Some tests failed. Please review the output above.');
206
+ }
207
+ process.exit(failed > 0 ? 1 : 0);
208
+ }
209
+ // Run tests
210
+ runTests().catch(error => {
211
+ console.error('Fatal error:', error);
212
+ process.exit(1);
213
+ });
214
+ //# sourceMappingURL=test-store.js.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Evaluate a simple boolean expression with variable substitution.
3
+ *
4
+ * 1. Replace `{{variable}}` references using the provided context.
5
+ * 2. Reject any expression containing dangerous patterns.
6
+ * 3. Validate that all remaining tokens are safe.
7
+ * 4. Evaluate using `new Function` with strict mode.
8
+ */
9
+ export declare function evaluateCondition(expression: string, context: Record<string, unknown>): boolean;
10
+ //# sourceMappingURL=condition-evaluator.d.ts.map
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Substitute context values into a condition expression, JSON-encoding string
3
+ * values to prevent quote injection via user-controlled context data.
4
+ */
5
+ function substituteCondition(expression, context) {
6
+ return expression.replace(/\{\{([\w./-]+)\}\}/g, (_match, path) => {
7
+ const segments = path.split('.');
8
+ let current = context;
9
+ for (const seg of segments) {
10
+ if (current === null || current === undefined || typeof current !== 'object') {
11
+ current = undefined;
12
+ break;
13
+ }
14
+ if (seg === '__proto__' || seg === 'constructor' || seg === 'prototype') {
15
+ current = undefined;
16
+ break;
17
+ }
18
+ current = current[seg];
19
+ }
20
+ if (current === undefined)
21
+ return `{{${path}}}`;
22
+ if (typeof current === 'string')
23
+ return JSON.stringify(current);
24
+ if (typeof current === 'number' || typeof current === 'boolean')
25
+ return String(current);
26
+ return JSON.stringify(current);
27
+ });
28
+ }
29
+ /**
30
+ * Dangerous patterns that must never appear in condition expressions.
31
+ */
32
+ const DANGEROUS_PATTERNS = [
33
+ /\beval\b/,
34
+ /\brequire\b/,
35
+ /\bimport\b/,
36
+ /\bprocess\b/,
37
+ /\bglobal\b/,
38
+ /\bglobalThis\b/,
39
+ /\bFunction\b/,
40
+ /\b__proto__\b/,
41
+ /\bconstructor\b/,
42
+ /\bprototype\b/,
43
+ ];
44
+ /**
45
+ * Allowed token pattern — only permits strings, numbers, booleans,
46
+ * comparison/logical operators, parentheses, and whitespace.
47
+ */
48
+ const SAFE_TOKEN = /^(\s*('([^']*)'|"([^"]*)"|-?\d+(\.\d+)?|true|false|null|undefined|===|!==|==|!=|>=|<=|>|<|&&|\|\||!|\(|\)|\s+))+\s*$/;
49
+ /**
50
+ * Evaluate a simple boolean expression with variable substitution.
51
+ *
52
+ * 1. Replace `{{variable}}` references using the provided context.
53
+ * 2. Reject any expression containing dangerous patterns.
54
+ * 3. Validate that all remaining tokens are safe.
55
+ * 4. Evaluate using `new Function` with strict mode.
56
+ */
57
+ export function evaluateCondition(expression, context) {
58
+ if (expression.length > 500) {
59
+ throw new Error('Condition expression too long (max 500 characters)');
60
+ }
61
+ // Step 1: substitute variables (string values JSON-encoded to prevent quote injection)
62
+ const resolved = substituteCondition(expression, context);
63
+ // Re-check length after substitution — injected values can expand the expression
64
+ if (resolved.length > 500) {
65
+ throw new Error('Condition expression too long after variable substitution (max 500 characters)');
66
+ }
67
+ // Step 2: reject dangerous patterns
68
+ for (const pattern of DANGEROUS_PATTERNS) {
69
+ if (pattern.test(resolved)) {
70
+ throw new Error(`Unsafe expression rejected: contains forbidden pattern "${pattern.source}"`);
71
+ }
72
+ }
73
+ // Step 3: validate tokens
74
+ if (!SAFE_TOKEN.test(resolved)) {
75
+ throw new Error(`Unsafe expression rejected: contains disallowed tokens in "${resolved}"`);
76
+ }
77
+ // Step 4: evaluate safely
78
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval
79
+ const fn = new Function(`"use strict"; return (${resolved});`);
80
+ return Boolean(fn());
81
+ }
82
+ //# sourceMappingURL=condition-evaluator.js.map
@@ -0,0 +1,12 @@
1
+ import type { DAGTask, TaskResult } from './dag-types.js';
2
+ export declare class ContextResolutionError extends Error {
3
+ readonly taskId: string;
4
+ readonly missingDeps: string[];
5
+ constructor(taskId: string, missingDeps: string[]);
6
+ }
7
+ /**
8
+ * Resolves upstream context for a task by collecting results from its dependencies.
9
+ * Throws ContextResolutionError if any dependency result is missing.
10
+ */
11
+ export declare function resolveContext(task: DAGTask, results: Map<string, TaskResult>): TaskResult[];
12
+ //# sourceMappingURL=context-resolver.d.ts.map
@@ -0,0 +1,23 @@
1
+ export class ContextResolutionError extends Error {
2
+ taskId;
3
+ missingDeps;
4
+ constructor(taskId, missingDeps) {
5
+ super(`Task "${taskId}" has unresolved dependencies: ${missingDeps.join(', ')}`);
6
+ this.taskId = taskId;
7
+ this.missingDeps = missingDeps;
8
+ this.name = 'ContextResolutionError';
9
+ }
10
+ }
11
+ /**
12
+ * Resolves upstream context for a task by collecting results from its dependencies.
13
+ * Throws ContextResolutionError if any dependency result is missing.
14
+ */
15
+ export function resolveContext(task, results) {
16
+ const deps = task.contextDeps ?? [];
17
+ const missing = deps.filter((dep) => !results.has(dep));
18
+ if (missing.length > 0) {
19
+ throw new ContextResolutionError(task.id, missing);
20
+ }
21
+ return deps.map((dep) => results.get(dep));
22
+ }
23
+ //# sourceMappingURL=context-resolver.js.map
@@ -0,0 +1,17 @@
1
+ import type { DAG, DAGTask, DAGLevel } from './dag-types.js';
2
+ /**
3
+ * Builds a DAG from an array of tasks using their contextDeps.
4
+ * Throws if any task references a dependency that doesn't exist.
5
+ */
6
+ export declare function buildDAG(tasks: DAGTask[]): DAG;
7
+ /**
8
+ * Detects cycles in the DAG using DFS.
9
+ * Returns an array of cycles, where each cycle is an array of task IDs.
10
+ */
11
+ export declare function detectCycles(dag: DAG): string[][];
12
+ /**
13
+ * Performs topological sort using Kahn's algorithm.
14
+ * Returns levels (arrays of tasks that can execute in parallel).
15
+ */
16
+ export declare function topologicalSort(dag: DAG): DAGLevel[];
17
+ //# sourceMappingURL=dag-builder.d.ts.map
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Builds a DAG from an array of tasks using their contextDeps.
3
+ * Throws if any task references a dependency that doesn't exist.
4
+ */
5
+ export function buildDAG(tasks) {
6
+ const taskMap = new Map();
7
+ const edges = new Map();
8
+ const reverseEdges = new Map();
9
+ // Register all tasks
10
+ for (const task of tasks) {
11
+ taskMap.set(task.id, task);
12
+ edges.set(task.id, new Set());
13
+ reverseEdges.set(task.id, new Set());
14
+ }
15
+ // Build edges from contextDeps
16
+ for (const task of tasks) {
17
+ const deps = task.contextDeps ?? [];
18
+ for (const dep of deps) {
19
+ if (!taskMap.has(dep)) {
20
+ throw new Error(`Task "${task.id}" depends on "${dep}" which does not exist in the task list`);
21
+ }
22
+ // dep → task (dep is upstream, task is downstream)
23
+ edges.get(dep).add(task.id);
24
+ reverseEdges.get(task.id).add(dep);
25
+ }
26
+ }
27
+ return { tasks: taskMap, edges, reverseEdges };
28
+ }
29
+ /**
30
+ * Detects cycles in the DAG using DFS.
31
+ * Returns an array of cycles, where each cycle is an array of task IDs.
32
+ */
33
+ export function detectCycles(dag) {
34
+ const WHITE = 0; // unvisited
35
+ const GRAY = 1; // in current DFS path
36
+ const BLACK = 2; // fully processed
37
+ const color = new Map();
38
+ const parent = new Map();
39
+ const cycles = [];
40
+ for (const id of dag.tasks.keys()) {
41
+ color.set(id, WHITE);
42
+ parent.set(id, null);
43
+ }
44
+ // Iterative DFS to avoid call-stack overflow on deep linear DAGs
45
+ function dfs(start) {
46
+ const stack = [
47
+ { u: start, neighbors: (dag.edges.get(start) ?? new Set()).values(), entered: false },
48
+ ];
49
+ while (stack.length > 0) {
50
+ const frame = stack[stack.length - 1];
51
+ if (!frame.entered) {
52
+ frame.entered = true;
53
+ color.set(frame.u, GRAY);
54
+ }
55
+ const { value: v, done } = frame.neighbors.next();
56
+ if (done) {
57
+ color.set(frame.u, BLACK);
58
+ stack.pop();
59
+ continue;
60
+ }
61
+ const vColor = color.get(v);
62
+ if (vColor === GRAY) {
63
+ // Found a cycle — reconstruct it
64
+ const cycle = [v];
65
+ let curr = frame.u;
66
+ while (curr !== v) {
67
+ cycle.push(curr);
68
+ const next = parent.get(curr);
69
+ if (next == null)
70
+ break;
71
+ curr = next;
72
+ }
73
+ cycle.push(v);
74
+ cycle.reverse();
75
+ cycles.push(cycle);
76
+ }
77
+ else if (vColor === WHITE) {
78
+ parent.set(v, frame.u);
79
+ stack.push({ u: v, neighbors: (dag.edges.get(v) ?? new Set()).values(), entered: false });
80
+ }
81
+ }
82
+ }
83
+ for (const id of dag.tasks.keys()) {
84
+ if (color.get(id) === WHITE) {
85
+ dfs(id);
86
+ }
87
+ }
88
+ return cycles;
89
+ }
90
+ /**
91
+ * Performs topological sort using Kahn's algorithm.
92
+ * Returns levels (arrays of tasks that can execute in parallel).
93
+ */
94
+ export function topologicalSort(dag) {
95
+ if (dag.tasks.size === 0)
96
+ return [];
97
+ // Compute in-degree for each node
98
+ const inDegree = new Map();
99
+ for (const id of dag.tasks.keys()) {
100
+ inDegree.set(id, (dag.reverseEdges.get(id) ?? new Set()).size);
101
+ }
102
+ // Start with nodes that have no dependencies
103
+ let currentLevel = [];
104
+ for (const [id, deg] of inDegree) {
105
+ if (deg === 0) {
106
+ currentLevel.push(id);
107
+ }
108
+ }
109
+ const levels = [];
110
+ while (currentLevel.length > 0) {
111
+ // Resolve current level tasks
112
+ const levelTasks = currentLevel.map(id => dag.tasks.get(id));
113
+ levels.push(levelTasks);
114
+ const nextLevel = [];
115
+ for (const id of currentLevel) {
116
+ const dependents = dag.edges.get(id) ?? new Set();
117
+ for (const dep of dependents) {
118
+ const newDeg = inDegree.get(dep) - 1;
119
+ inDegree.set(dep, newDeg);
120
+ if (newDeg === 0) {
121
+ nextLevel.push(dep);
122
+ }
123
+ }
124
+ }
125
+ currentLevel = nextLevel;
126
+ }
127
+ return levels;
128
+ }
129
+ //# sourceMappingURL=dag-builder.js.map
@@ -0,0 +1,9 @@
1
+ import type { DAGTask, TaskResult } from './dag-types.js';
2
+ export type TaskRunner = (task: DAGTask, upstreamContext: TaskResult[]) => Promise<TaskResult>;
3
+ export declare class DAGExecutor {
4
+ private readonly runner;
5
+ constructor(runner: TaskRunner);
6
+ execute(tasks: DAGTask[]): Promise<Map<string, TaskResult>>;
7
+ private runWithRetry;
8
+ }
9
+ //# sourceMappingURL=dag-executor.d.ts.map