monomind 1.10.56 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/.claude/agents/core/coordinator.md +71 -0
  2. package/.claude/agents/generated/case-analyst.md +50 -0
  3. package/.claude/agents/generated/copy-editor.md +45 -0
  4. package/.claude/agents/generated/court-reporter.md +50 -0
  5. package/.claude/agents/generated/defender.md +51 -0
  6. package/.claude/agents/generated/editor-in-chief.md +45 -0
  7. package/.claude/agents/generated/fact-checker.md +45 -0
  8. package/.claude/agents/generated/judge.md +51 -0
  9. package/.claude/agents/generated/prosecutor.md +51 -0
  10. package/.claude/agents/generated/reporter.md +45 -0
  11. package/.claude/commands/hooks/README.md +1 -1
  12. package/.claude/commands/hooks/overview.md +1 -1
  13. package/.claude/commands/mastermind/_repeat.md +1 -1
  14. package/.claude/commands/mastermind/do.md +3 -1
  15. package/.claude/commands/mastermind/help.md +2 -2
  16. package/.claude/commands/mastermind/master.md +39 -6
  17. package/.claude/commands/mastermind/memory.md +1 -1
  18. package/.claude/commands/memory/memory-search.md +2 -2
  19. package/.claude/commands/monitoring/status.md +1 -1
  20. package/.claude/commands/{browse.md → monobrowse.md} +2 -2
  21. package/.claude/commands/sparc.md +1 -1
  22. package/.claude/helpers/handlers/graph-status-handler.cjs +1 -1
  23. package/.claude/helpers/loop-tracker.cjs +1 -1
  24. package/.claude/scheduled_tasks.lock +1 -1
  25. package/.claude/skills/agent-browser-testing/SKILL.md +1 -1
  26. package/.claude/skills/hooks-automation/SKILL.md +0 -3
  27. package/.claude/skills/mastermind/build.md +1 -1
  28. package/.claude/skills/mastermind/code-quality-reviewer-prompt.md +60 -0
  29. package/.claude/skills/mastermind/content.md +1 -1
  30. package/.claude/skills/mastermind/createorg.md +79 -2
  31. package/.claude/skills/mastermind/design.md +3 -1
  32. package/.claude/skills/mastermind/finance.md +1 -1
  33. package/.claude/skills/mastermind/implementer-prompt.md +109 -0
  34. package/.claude/skills/mastermind/marketing.md +1 -1
  35. package/.claude/skills/mastermind/ops.md +1 -1
  36. package/.claude/skills/mastermind/plan.md +20 -2
  37. package/.claude/skills/mastermind/release.md +1 -1
  38. package/.claude/skills/mastermind/research.md +1 -1
  39. package/.claude/skills/mastermind/review.md +1 -1
  40. package/.claude/skills/mastermind/sales.md +1 -1
  41. package/.claude/skills/mastermind/spec-reviewer-prompt.md +63 -0
  42. package/.claude/skills/sparc-methodology/SKILL.md +3 -3
  43. package/.claude/skills/swarm-advanced/SKILL.md +1 -4
  44. package/.claude-plugin/README.md +1 -2
  45. package/.claude-plugin/docs/PLUGIN_SUMMARY.md +0 -1
  46. package/README.md +18 -32
  47. package/package.json +1 -1
  48. package/packages/@monomind/cli/README.md +18 -32
  49. package/packages/@monomind/cli/dist/src/agents/registry-builder.d.ts +1 -7
  50. package/packages/@monomind/cli/dist/src/agents/registry-builder.js +10 -6
  51. package/packages/@monomind/cli/dist/src/benchmarks/benchmark-runner.d.ts +59 -12
  52. package/packages/@monomind/cli/dist/src/benchmarks/benchmark-runner.js +67 -13
  53. package/packages/@monomind/cli/dist/src/benchmarks/pretrain/index.d.ts +0 -13
  54. package/packages/@monomind/cli/dist/src/commands/agent-wasm.d.ts +2 -2
  55. package/packages/@monomind/cli/dist/src/commands/agent-wasm.js +5 -5
  56. package/packages/@monomind/cli/dist/src/commands/agent.js +1 -6
  57. package/packages/@monomind/cli/dist/src/commands/analyze.d.ts +1 -1
  58. package/packages/@monomind/cli/dist/src/commands/analyze.js +8 -18
  59. package/packages/@monomind/cli/dist/src/commands/doctor.js +53 -3
  60. package/packages/@monomind/cli/dist/src/commands/embeddings.js +9 -33
  61. package/packages/@monomind/cli/dist/src/commands/hooks.js +24 -76
  62. package/packages/@monomind/cli/dist/src/commands/index.d.ts +4 -6
  63. package/packages/@monomind/cli/dist/src/commands/index.js +8 -15
  64. package/packages/@monomind/cli/dist/src/commands/init.js +2 -2
  65. package/packages/@monomind/cli/dist/src/commands/issues.js +16 -11
  66. package/packages/@monomind/cli/dist/src/commands/mcp.d.ts +1 -1
  67. package/packages/@monomind/cli/dist/src/commands/memory.js +6 -6
  68. package/packages/@monomind/cli/dist/src/commands/migrate.js +1 -2
  69. package/packages/@monomind/cli/dist/src/commands/monograph.js +18 -11
  70. package/packages/@monomind/cli/dist/src/commands/monovector/backup.d.ts +11 -0
  71. package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/backup.js +25 -25
  72. package/packages/@monomind/cli/dist/src/commands/monovector/benchmark.d.ts +11 -0
  73. package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/benchmark.js +14 -14
  74. package/packages/@monomind/cli/dist/src/commands/monovector/import.d.ts +18 -0
  75. package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/import.js +21 -21
  76. package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/index.d.ts +6 -6
  77. package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/index.js +22 -22
  78. package/packages/@monomind/cli/dist/src/commands/monovector/init.d.ts +11 -0
  79. package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/init.js +36 -36
  80. package/packages/@monomind/cli/dist/src/commands/monovector/migrate.d.ts +11 -0
  81. package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/migrate.js +16 -16
  82. package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/optimize.d.ts +2 -2
  83. package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/optimize.js +10 -10
  84. package/packages/@monomind/cli/dist/src/commands/monovector/setup.d.ts +18 -0
  85. package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/setup.js +77 -77
  86. package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/status.d.ts +2 -2
  87. package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/status.js +34 -34
  88. package/packages/@monomind/cli/dist/src/commands/neural.d.ts +1 -1
  89. package/packages/@monomind/cli/dist/src/commands/neural.js +31 -608
  90. package/packages/@monomind/cli/dist/src/commands/performance.js +7 -10
  91. package/packages/@monomind/cli/dist/src/commands/plugins.js +3 -4
  92. package/packages/@monomind/cli/dist/src/commands/process.js +5 -12
  93. package/packages/@monomind/cli/dist/src/commands/progress.js +16 -16
  94. package/packages/@monomind/cli/dist/src/commands/route.d.ts +2 -2
  95. package/packages/@monomind/cli/dist/src/commands/route.js +23 -23
  96. package/packages/@monomind/cli/dist/src/commands/status.js +0 -3
  97. package/packages/@monomind/cli/dist/src/commands/swarm.js +2 -3
  98. package/packages/@monomind/cli/dist/src/commands/update.d.ts +1 -1
  99. package/packages/@monomind/cli/dist/src/config-adapter.js +27 -0
  100. package/packages/@monomind/cli/dist/src/consensus/audit-writer.d.ts +44 -17
  101. package/packages/@monomind/cli/dist/src/dlq/dlq-replayer.d.ts +1 -1
  102. package/packages/@monomind/cli/dist/src/index.d.ts +1 -1
  103. package/packages/@monomind/cli/dist/src/index.js +5 -5
  104. package/packages/@monomind/cli/dist/src/init/claudemd-generator.js +10 -14
  105. package/packages/@monomind/cli/dist/src/init/executor.js +17 -27
  106. package/packages/@monomind/cli/dist/src/init/helpers-generator.d.ts +1 -1
  107. package/packages/@monomind/cli/dist/src/init/helpers-generator.js +2 -2
  108. package/packages/@monomind/cli/dist/src/init/types.d.ts +1 -1
  109. package/packages/@monomind/cli/dist/src/mcp-client.js +1 -7
  110. package/packages/@monomind/cli/dist/src/mcp-server.js +9 -1
  111. package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.js +1 -52
  112. package/packages/@monomind/cli/dist/src/mcp-tools/analyze-tools.js +5 -5
  113. package/packages/@monomind/cli/dist/src/mcp-tools/auto-install.d.ts +4 -4
  114. package/packages/@monomind/cli/dist/src/mcp-tools/autopilot-tools.d.ts +1 -1
  115. package/packages/@monomind/cli/dist/src/mcp-tools/browser-tools.d.ts +1 -1
  116. package/packages/@monomind/cli/dist/src/mcp-tools/browser-tools.js +6 -5
  117. package/packages/@monomind/cli/dist/src/mcp-tools/claims-tools.d.ts +1 -1
  118. package/packages/@monomind/cli/dist/src/mcp-tools/coordination-tools.d.ts +1 -1
  119. package/packages/@monomind/cli/dist/src/mcp-tools/coordination-tools.js +51 -54
  120. package/packages/@monomind/cli/dist/src/mcp-tools/daa-tools.d.ts +1 -1
  121. package/packages/@monomind/cli/dist/src/mcp-tools/embeddings-tools.js +10 -10
  122. package/packages/@monomind/cli/dist/src/mcp-tools/guidance-tools.d.ts +1 -1
  123. package/packages/@monomind/cli/dist/src/mcp-tools/guidance-tools.js +0 -24
  124. package/packages/@monomind/cli/dist/src/mcp-tools/hooks-tools.js +189 -446
  125. package/packages/@monomind/cli/dist/src/mcp-tools/index.d.ts +0 -2
  126. package/packages/@monomind/cli/dist/src/mcp-tools/index.js +0 -2
  127. package/packages/@monomind/cli/dist/src/mcp-tools/monograph-compat.d.ts +334 -0
  128. package/packages/@monomind/cli/dist/src/mcp-tools/monograph-compat.js +1108 -0
  129. package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +76 -34
  130. package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.d.ts +2 -2
  131. package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.js +2 -2
  132. package/packages/@monomind/cli/dist/src/mcp-tools/progress-tools.d.ts +1 -1
  133. package/packages/@monomind/cli/dist/src/mcp-tools/ruvllm-tools.d.ts +2 -2
  134. package/packages/@monomind/cli/dist/src/mcp-tools/ruvllm-tools.js +3 -3
  135. package/packages/@monomind/cli/dist/src/mcp-tools/terminal-tools.d.ts +1 -1
  136. package/packages/@monomind/cli/dist/src/mcp-tools/terminal-tools.js +29 -19
  137. package/packages/@monomind/cli/dist/src/mcp-tools/transfer-tools.d.ts +1 -1
  138. package/packages/@monomind/cli/dist/src/mcp-tools/wasm-agent-tools.d.ts +1 -1
  139. package/packages/@monomind/cli/dist/src/mcp-tools/wasm-agent-tools.js +2 -2
  140. package/packages/@monomind/cli/dist/src/memory/intelligence.js +14 -8
  141. package/packages/@monomind/cli/dist/src/memory/memory-bridge.d.ts +17 -2
  142. package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +76 -23
  143. package/packages/@monomind/cli/dist/src/memory/memory-initializer.d.ts +2 -2
  144. package/packages/@monomind/cli/dist/src/memory/memory-initializer.js +37 -39
  145. package/packages/@monomind/cli/dist/src/monovector/capabilities.d.ts +34 -0
  146. package/packages/@monomind/cli/dist/src/monovector/capabilities.js +37 -0
  147. package/packages/@monomind/cli/dist/src/monovector/command-outcomes.d.ts +37 -0
  148. package/packages/@monomind/cli/dist/src/monovector/command-outcomes.js +87 -0
  149. package/packages/@monomind/cli/dist/src/monovector/coverage-router.d.ts +103 -0
  150. package/packages/@monomind/cli/dist/src/monovector/coverage-router.js +337 -0
  151. package/packages/@monomind/cli/dist/src/monovector/coverage-tools.d.ts +14 -0
  152. package/packages/@monomind/cli/dist/src/monovector/coverage-tools.js +112 -0
  153. package/packages/@monomind/cli/dist/src/{ruvector → monovector}/diff-classifier.d.ts +2 -2
  154. package/packages/@monomind/cli/dist/src/monovector/index.d.ts +61 -0
  155. package/packages/@monomind/cli/dist/src/monovector/index.js +67 -0
  156. package/packages/@monomind/cli/dist/src/monovector/init-state.d.ts +35 -0
  157. package/packages/@monomind/cli/dist/src/monovector/init-state.js +36 -0
  158. package/packages/@monomind/cli/dist/src/monovector/route-outcomes.d.ts +55 -0
  159. package/packages/@monomind/cli/dist/src/monovector/route-outcomes.js +137 -0
  160. package/packages/@monomind/cli/dist/src/parser.js +3 -3
  161. package/packages/@monomind/cli/dist/src/plugins/store/discovery.js +0 -31
  162. package/packages/@monomind/cli/dist/src/production/circuit-breaker.d.ts +26 -6
  163. package/packages/@monomind/cli/dist/src/production/error-handler.d.ts +55 -30
  164. package/packages/@monomind/cli/dist/src/production/index.d.ts +3 -20
  165. package/packages/@monomind/cli/dist/src/production/index.js +3 -15
  166. package/packages/@monomind/cli/dist/src/production/monitoring.d.ts +54 -34
  167. package/packages/@monomind/cli/dist/src/production/monitoring.js +12 -14
  168. package/packages/@monomind/cli/dist/src/production/rate-limiter.d.ts +64 -19
  169. package/packages/@monomind/cli/dist/src/production/rate-limiter.js +5 -5
  170. package/packages/@monomind/cli/dist/src/production/retry.js +4 -2
  171. package/packages/@monomind/cli/dist/src/runtime/headless.d.ts +3 -3
  172. package/packages/@monomind/cli/dist/src/services/claim-service.d.ts +50 -59
  173. package/packages/@monomind/cli/dist/src/services/claim-service.js +83 -50
  174. package/packages/@monomind/cli/dist/src/services/config-file-manager.js +8 -1
  175. package/packages/@monomind/cli/dist/src/services/worker-daemon.js +4 -0
  176. package/packages/@monomind/cli/dist/src/transfer/ipfs/upload.d.ts +1 -1
  177. package/packages/@monomind/cli/dist/src/transfer/storage/gcs.d.ts +1 -1
  178. package/packages/@monomind/cli/dist/src/types.d.ts +13 -0
  179. package/packages/@monomind/cli/dist/src/update/checker.d.ts +1 -1
  180. package/packages/@monomind/cli/dist/src/update/index.d.ts +1 -1
  181. package/packages/@monomind/cli/package.json +13 -13
  182. package/packages/@monomind/guidance/dist/index.d.ts +1 -1
  183. package/packages/@monomind/guidance/dist/index.js +1 -1
  184. package/packages/@monomind/guidance/package.json +1 -2
  185. package/scripts/build-monovector.sh +10 -0
  186. package/scripts/publish-monovector.sh +20 -0
  187. package/.claude/commands/monomind/adr.md +0 -11
  188. package/.claude/commands/monomind/budget.md +0 -7
  189. package/.claude/commands/monomind/createtask.md +0 -277
  190. package/.claude/commands/monomind/do.md +0 -498
  191. package/.claude/commands/monomind/graph-status.md +0 -7
  192. package/.claude/commands/monomind/help.md +0 -118
  193. package/.claude/commands/monomind/idea.md +0 -273
  194. package/.claude/commands/monomind/improve.md +0 -352
  195. package/.claude/commands/monomind/loops.md +0 -7
  196. package/.claude/commands/monomind/memory.md +0 -230
  197. package/.claude/commands/monomind/repeat.md +0 -257
  198. package/.claude/commands/monomind/review.md +0 -317
  199. package/.claude/commands/monomind/specialagents.md +0 -125
  200. package/.claude/commands/monomind/swarm.md +0 -161
  201. package/.claude/commands/monomind/understand.md +0 -139
  202. package/.claude/commands/training/README.md +0 -39
  203. package/.claude/commands/training/neural-patterns.md +0 -73
  204. package/.claude/commands/training/neural-train.md +0 -79
  205. package/packages/@monomind/cli/dist/src/commands/appliance-advanced.d.ts +0 -9
  206. package/packages/@monomind/cli/dist/src/commands/appliance-advanced.js +0 -238
  207. package/packages/@monomind/cli/dist/src/commands/appliance.d.ts +0 -8
  208. package/packages/@monomind/cli/dist/src/commands/appliance.js +0 -406
  209. package/packages/@monomind/cli/dist/src/commands/ruvector/backup.d.ts +0 -11
  210. package/packages/@monomind/cli/dist/src/commands/ruvector/benchmark.d.ts +0 -11
  211. package/packages/@monomind/cli/dist/src/commands/ruvector/import.d.ts +0 -18
  212. package/packages/@monomind/cli/dist/src/commands/ruvector/init.d.ts +0 -11
  213. package/packages/@monomind/cli/dist/src/commands/ruvector/migrate.d.ts +0 -11
  214. package/packages/@monomind/cli/dist/src/commands/ruvector/setup.d.ts +0 -18
  215. package/packages/@monomind/cli/dist/src/ruvector/agent-wasm.d.ts +0 -182
  216. package/packages/@monomind/cli/dist/src/ruvector/agent-wasm.js +0 -316
  217. package/packages/@monomind/cli/dist/src/ruvector/ast-analyzer.d.ts +0 -67
  218. package/packages/@monomind/cli/dist/src/ruvector/ast-analyzer.js +0 -277
  219. package/packages/@monomind/cli/dist/src/ruvector/coverage-router.d.ts +0 -160
  220. package/packages/@monomind/cli/dist/src/ruvector/coverage-router.js +0 -539
  221. package/packages/@monomind/cli/dist/src/ruvector/coverage-tools.d.ts +0 -33
  222. package/packages/@monomind/cli/dist/src/ruvector/coverage-tools.js +0 -157
  223. package/packages/@monomind/cli/dist/src/ruvector/enhanced-model-router.d.ts +0 -146
  224. package/packages/@monomind/cli/dist/src/ruvector/enhanced-model-router.js +0 -551
  225. package/packages/@monomind/cli/dist/src/ruvector/flash-attention.d.ts +0 -195
  226. package/packages/@monomind/cli/dist/src/ruvector/flash-attention.js +0 -643
  227. package/packages/@monomind/cli/dist/src/ruvector/graph-analyzer.d.ts +0 -187
  228. package/packages/@monomind/cli/dist/src/ruvector/graph-analyzer.js +0 -929
  229. package/packages/@monomind/cli/dist/src/ruvector/index.d.ts +0 -56
  230. package/packages/@monomind/cli/dist/src/ruvector/index.js +0 -58
  231. package/packages/@monomind/cli/dist/src/ruvector/lora-adapter.d.ts +0 -218
  232. package/packages/@monomind/cli/dist/src/ruvector/lora-adapter.js +0 -455
  233. package/packages/@monomind/cli/dist/src/ruvector/model-router.d.ts +0 -222
  234. package/packages/@monomind/cli/dist/src/ruvector/model-router.js +0 -512
  235. package/packages/@monomind/cli/dist/src/ruvector/moe-router.d.ts +0 -213
  236. package/packages/@monomind/cli/dist/src/ruvector/moe-router.js +0 -649
  237. package/packages/@monomind/cli/dist/src/ruvector/q-learning-router.d.ts +0 -217
  238. package/packages/@monomind/cli/dist/src/ruvector/q-learning-router.js +0 -712
  239. package/packages/@monomind/cli/dist/src/ruvector/ruvllm-wasm.d.ts +0 -179
  240. package/packages/@monomind/cli/dist/src/ruvector/ruvllm-wasm.js +0 -363
  241. package/packages/@monomind/cli/dist/src/ruvector/semantic-router.d.ts +0 -77
  242. package/packages/@monomind/cli/dist/src/ruvector/semantic-router.js +0 -178
  243. package/packages/@monomind/cli/dist/src/ruvector/vector-db.d.ts +0 -69
  244. package/packages/@monomind/cli/dist/src/ruvector/vector-db.js +0 -243
  245. package/packages/@monomind/cli/dist/src/services/ruvector-training.d.ts +0 -222
  246. package/packages/@monomind/cli/dist/src/services/ruvector-training.js +0 -696
  247. /package/packages/@monomind/cli/dist/src/{ruvector → monovector}/diff-classifier.js +0 -0
@@ -8,9 +8,15 @@
8
8
  * - Health checks
9
9
  * - Alerting
10
10
  *
11
- * @module @monoes/cli/production/monitoring
11
+ * @module @monomind/cli/production/monitoring
12
12
  */
13
- export type MetricType = 'counter' | 'gauge' | 'histogram' | 'summary';
13
+ /** Metric type discriminator. */
14
+ export type MetricType = 'counter' | 'gauge' | 'histogram';
15
+ /** Alert severity level. */
16
+ export type AlertLevel = 'warning' | 'critical';
17
+ /** Health check status discriminator. */
18
+ export type HealthCheckStatus = 'healthy' | 'unhealthy';
19
+ /** A single recorded metric event. */
14
20
  export interface MetricEvent {
15
21
  name: string;
16
22
  type: MetricType;
@@ -18,29 +24,53 @@ export interface MetricEvent {
18
24
  labels: Record<string, string>;
19
25
  timestamp: number;
20
26
  }
27
+ /** Warning/critical thresholds for a single metric. */
28
+ export interface AlertThreshold {
29
+ warning: number;
30
+ critical: number;
31
+ }
32
+ /** Configuration for the monitoring hooks. */
21
33
  export interface MonitorConfig {
22
34
  enabled: boolean;
23
35
  retentionMs: number;
24
36
  maxMetrics: number;
25
37
  samplingRate: number;
26
- alertThresholds: Record<string, {
27
- warning: number;
28
- critical: number;
29
- }>;
38
+ alertThresholds: Record<string, AlertThreshold>;
30
39
  healthCheckIntervalMs: number;
31
- reportingEndpoint?: string;
32
40
  globalLabels: Record<string, string>;
33
41
  }
42
+ /** An active or acknowledged alert. */
43
+ export interface Alert {
44
+ id: string;
45
+ level: AlertLevel;
46
+ metric: string;
47
+ message: string;
48
+ value: number;
49
+ threshold: number;
50
+ timestamp: number;
51
+ acknowledged: boolean;
52
+ }
53
+ /** Result returned by a registered health check function. */
54
+ export interface HealthCheckResult {
55
+ healthy: boolean;
56
+ message?: string;
57
+ }
58
+ /** A user-supplied health check. */
59
+ export type HealthCheck = () => Promise<HealthCheckResult>;
60
+ /** Per-check entry within an aggregated health status. */
61
+ export interface HealthCheckEntry {
62
+ status: HealthCheckStatus;
63
+ message?: string;
64
+ lastCheck: number;
65
+ responseTimeMs: number;
66
+ }
67
+ /** Aggregated health status across all registered checks. */
34
68
  export interface HealthStatus {
35
69
  healthy: boolean;
36
- checks: Record<string, {
37
- status: 'healthy' | 'degraded' | 'unhealthy';
38
- message?: string;
39
- lastCheck: number;
40
- responseTimeMs?: number;
41
- }>;
70
+ checks: Record<string, HealthCheckEntry>;
42
71
  timestamp: number;
43
72
  }
73
+ /** Snapshot of performance metrics derived from recorded data. */
44
74
  export interface PerformanceMetrics {
45
75
  requestCount: number;
46
76
  errorCount: number;
@@ -52,17 +82,14 @@ export interface PerformanceMetrics {
52
82
  activeRequests: number;
53
83
  uptime: number;
54
84
  }
55
- type AlertLevel = 'info' | 'warning' | 'critical';
56
- interface Alert {
57
- id: string;
58
- level: AlertLevel;
59
- metric: string;
60
- message: string;
61
- value: number;
62
- threshold: number;
63
- timestamp: number;
64
- acknowledged: boolean;
85
+ /** Aggregated summary entry for a single metric name. */
86
+ export interface MetricSummaryEntry {
87
+ count: number;
88
+ lastValue: number;
89
+ avgValue: number;
65
90
  }
91
+ /** Function returned by {@link MonitoringHooks.startRequest} to end tracking. */
92
+ export type EndRequest = () => void;
66
93
  export declare class MonitoringHooks {
67
94
  private config;
68
95
  private metrics;
@@ -90,11 +117,11 @@ export declare class MonitoringHooks {
90
117
  /**
91
118
  * Record a metric event
92
119
  */
93
- private recordMetric;
120
+ recordMetric(name: string, type: MetricType, value: number, labels: Record<string, string>): void;
94
121
  /**
95
122
  * Start tracking a request
96
123
  */
97
- startRequest(requestId: string): () => void;
124
+ startRequest(requestId?: string): EndRequest;
98
125
  /**
99
126
  * Record an error
100
127
  */
@@ -102,10 +129,7 @@ export declare class MonitoringHooks {
102
129
  /**
103
130
  * Register a health check
104
131
  */
105
- registerHealthCheck(name: string, check: () => Promise<{
106
- healthy: boolean;
107
- message?: string;
108
- }>): void;
132
+ registerHealthCheck(name: string, check: HealthCheck): void;
109
133
  /**
110
134
  * Run all health checks
111
135
  */
@@ -137,11 +161,7 @@ export declare class MonitoringHooks {
137
161
  /**
138
162
  * Get all metrics summary
139
163
  */
140
- getMetricsSummary(): Record<string, {
141
- count: number;
142
- lastValue: number;
143
- avgValue: number;
144
- }>;
164
+ getMetricsSummary(): Record<string, MetricSummaryEntry>;
145
165
  /**
146
166
  * Reset all metrics
147
167
  */
@@ -19,9 +19,9 @@ const DEFAULT_CONFIG = {
19
19
  maxMetrics: 100000,
20
20
  samplingRate: 1.0,
21
21
  alertThresholds: {
22
- 'error_rate': { warning: 0.05, critical: 0.1 },
23
- 'response_time_ms': { warning: 1000, critical: 5000 },
24
- 'active_requests': { warning: 100, critical: 500 },
22
+ error_rate: { warning: 0.05, critical: 0.1 },
23
+ response_time_ms: { warning: 1000, critical: 5000 },
24
+ active_requests: { warning: 100, critical: 500 },
25
25
  },
26
26
  healthCheckIntervalMs: 30000,
27
27
  globalLabels: {},
@@ -190,9 +190,7 @@ export class MonitoringHooks {
190
190
  const index = Math.ceil(count * p) - 1;
191
191
  return sortedTimes[Math.min(index, count - 1)];
192
192
  };
193
- const avgResponseTime = count > 0
194
- ? sortedTimes.reduce((a, b) => a + b, 0) / count
195
- : 0;
193
+ const avgResponseTime = count > 0 ? sortedTimes.reduce((a, b) => a + b, 0) / count : 0;
196
194
  return {
197
195
  requestCount: this.requestCount,
198
196
  errorCount: this.errorCount,
@@ -212,9 +210,9 @@ export class MonitoringHooks {
212
210
  * Get active alerts
213
211
  */
214
212
  getAlerts(level) {
215
- let filtered = this.alerts.filter(a => !a.acknowledged);
213
+ let filtered = this.alerts.filter((a) => !a.acknowledged);
216
214
  if (level) {
217
- filtered = filtered.filter(a => a.level === level);
215
+ filtered = filtered.filter((a) => a.level === level);
218
216
  }
219
217
  return filtered;
220
218
  }
@@ -222,7 +220,7 @@ export class MonitoringHooks {
222
220
  * Acknowledge an alert
223
221
  */
224
222
  acknowledgeAlert(alertId) {
225
- const alert = this.alerts.find(a => a.id === alertId);
223
+ const alert = this.alerts.find((a) => a.id === alertId);
226
224
  if (alert) {
227
225
  alert.acknowledged = true;
228
226
  return true;
@@ -242,9 +240,9 @@ export class MonitoringHooks {
242
240
  * Get metrics for a specific name
243
241
  */
244
242
  getMetrics(name, since) {
245
- let filtered = this.metrics.filter(m => m.name === name);
243
+ let filtered = this.metrics.filter((m) => m.name === name);
246
244
  if (since) {
247
- filtered = filtered.filter(m => m.timestamp >= since);
245
+ filtered = filtered.filter((m) => m.timestamp >= since);
248
246
  }
249
247
  return filtered;
250
248
  }
@@ -302,7 +300,7 @@ export class MonitoringHooks {
302
300
  }
303
301
  if (level) {
304
302
  // Check if we already have a recent alert for this metric
305
- const recentAlert = this.alerts.find(a => a.metric === name &&
303
+ const recentAlert = this.alerts.find((a) => a.metric === name &&
306
304
  !a.acknowledged &&
307
305
  Date.now() - a.timestamp < 60000);
308
306
  if (!recentAlert) {
@@ -323,13 +321,13 @@ export class MonitoringHooks {
323
321
  const now = Date.now();
324
322
  const cutoff = now - this.config.retentionMs;
325
323
  // Remove old metrics
326
- this.metrics = this.metrics.filter(m => m.timestamp > cutoff);
324
+ this.metrics = this.metrics.filter((m) => m.timestamp > cutoff);
327
325
  // Limit total metrics
328
326
  if (this.metrics.length > this.config.maxMetrics) {
329
327
  this.metrics = this.metrics.slice(-this.config.maxMetrics);
330
328
  }
331
329
  // Remove old acknowledged alerts
332
- this.alerts = this.alerts.filter(a => !a.acknowledged || Date.now() - a.timestamp < 300000);
330
+ this.alerts = this.alerts.filter((a) => !a.acknowledged || Date.now() - a.timestamp < 300000);
333
331
  // Cap total alerts to prevent unbounded growth
334
332
  const MAX_ALERTS = 500;
335
333
  if (this.alerts.length > MAX_ALERTS) {
@@ -7,26 +7,83 @@
7
7
  * - Burst allowance
8
8
  * - Sliding window tracking
9
9
  *
10
- * @module @monoes/cli/production/rate-limiter
10
+ * @module @monomind/cli/production/rate-limiter
11
+ */
12
+ /**
13
+ * Per-operation rate limit override.
14
+ */
15
+ export interface OperationLimit {
16
+ /** Maximum number of requests allowed within the window. */
17
+ maxRequests: number;
18
+ /** Window size in milliseconds. */
19
+ windowMs: number;
20
+ }
21
+ /**
22
+ * Rate limiter configuration. All fields are optional when constructing —
23
+ * unspecified values fall back to {@link DEFAULT_CONFIG}.
11
24
  */
12
25
  export interface RateLimiterConfig {
26
+ /** Default maximum requests per window. */
13
27
  maxRequests: number;
28
+ /** Default window size in milliseconds. */
14
29
  windowMs: number;
30
+ /** Multiplier applied for burst allowance. */
15
31
  burstMultiplier: number;
32
+ /** Operations that bypass rate limiting entirely. */
16
33
  whitelist: string[];
17
- operationLimits: Record<string, {
18
- maxRequests: number;
19
- windowMs: number;
20
- }>;
34
+ /** Per-operation limit overrides keyed by operation name. */
35
+ operationLimits: Record<string, OperationLimit>;
36
+ /** Whether to track limits per user/agent in addition to per operation. */
21
37
  perUserLimits: boolean;
38
+ /** Maximum number of distinct buckets to retain before eviction. */
22
39
  maxTrackedUsers: number;
23
40
  }
41
+ /**
42
+ * Result of a rate limit check.
43
+ */
24
44
  export interface RateLimitResult {
45
+ /** Whether the request is permitted. */
25
46
  allowed: boolean;
47
+ /** Remaining requests in the current window. */
26
48
  remaining: number;
49
+ /** Epoch timestamp (ms) at which the window resets. */
27
50
  resetAt: number;
51
+ /** When rate limited, milliseconds to wait before retrying. */
28
52
  retryAfterMs?: number;
29
53
  }
54
+ /**
55
+ * Snapshot of the current rate limit state for a key.
56
+ */
57
+ export interface RateLimitStatus {
58
+ /** Number of requests counted in the current window. */
59
+ current: number;
60
+ /** Configured limit for the operation. */
61
+ limit: number;
62
+ /** Remaining requests in the current window. */
63
+ remaining: number;
64
+ /** Epoch timestamp (ms) at which the window resets. */
65
+ resetAt: number;
66
+ }
67
+ /**
68
+ * Aggregate operation usage entry used in statistics.
69
+ */
70
+ export interface OperationStat {
71
+ /** Operation name. */
72
+ operation: string;
73
+ /** Total requests counted across buckets for the operation. */
74
+ requests: number;
75
+ }
76
+ /**
77
+ * Aggregate rate limiter statistics.
78
+ */
79
+ export interface RateLimiterStats {
80
+ /** Total number of active buckets. */
81
+ totalBuckets: number;
82
+ /** Number of distinct users currently tracked. */
83
+ activeUsers: number;
84
+ /** Top operations by request volume. */
85
+ mostLimitedOperations: OperationStat[];
86
+ }
30
87
  export declare class RateLimiter {
31
88
  private config;
32
89
  private buckets;
@@ -43,12 +100,7 @@ export declare class RateLimiter {
43
100
  /**
44
101
  * Get current rate limit status
45
102
  */
46
- getStatus(operation: string, userId?: string): {
47
- current: number;
48
- limit: number;
49
- remaining: number;
50
- resetAt: number;
51
- };
103
+ getStatus(operation: string, userId?: string): RateLimitStatus;
52
104
  /**
53
105
  * Reset limits for a specific key
54
106
  */
@@ -60,14 +112,7 @@ export declare class RateLimiter {
60
112
  /**
61
113
  * Get statistics
62
114
  */
63
- getStats(): {
64
- totalBuckets: number;
65
- activeUsers: number;
66
- mostLimitedOperations: Array<{
67
- operation: string;
68
- requests: number;
69
- }>;
70
- };
115
+ getStats(): RateLimiterStats;
71
116
  private getLimits;
72
117
  private createBucket;
73
118
  private cleanupBuckets;
@@ -51,7 +51,7 @@ export class RateLimiter {
51
51
  this.cleanupBuckets();
52
52
  }
53
53
  // Clean old requests from sliding window
54
- bucket.requests = bucket.requests.filter(t => t > now - limits.windowMs);
54
+ bucket.requests = bucket.requests.filter((t) => t > now - limits.windowMs);
55
55
  // Calculate remaining — uses base maxRequests (consistent with getStatus())
56
56
  const remaining = limits.maxRequests - bucket.requests.length;
57
57
  if (remaining <= 0) {
@@ -100,7 +100,7 @@ export class RateLimiter {
100
100
  };
101
101
  }
102
102
  // Clean old requests
103
- const validRequests = bucket.requests.filter(t => t > now - limits.windowMs);
103
+ const validRequests = bucket.requests.filter((t) => t > now - limits.windowMs);
104
104
  return {
105
105
  current: validRequests.length,
106
106
  limit: limits.maxRequests,
@@ -157,10 +157,10 @@ export class RateLimiter {
157
157
  // Private Methods
158
158
  // ============================================================================
159
159
  getLimits(operation) {
160
- return this.config.operationLimits[operation] || {
160
+ return (this.config.operationLimits[operation] || {
161
161
  maxRequests: this.config.maxRequests,
162
162
  windowMs: this.config.windowMs,
163
- };
163
+ });
164
164
  }
165
165
  createBucket() {
166
166
  return {
@@ -178,7 +178,7 @@ export class RateLimiter {
178
178
  for (const [key, bucket] of this.buckets) {
179
179
  if (this.buckets.size <= target)
180
180
  break;
181
- const recent = bucket.requests.filter(t => t > now - this.config.windowMs * 2);
181
+ const recent = bucket.requests.filter((t) => t > now - this.config.windowMs * 2);
182
182
  if (recent.length === 0)
183
183
  this.buckets.delete(key);
184
184
  }
@@ -45,7 +45,9 @@ function calculateDelay(attempt, config, strategy = 'exponential') {
45
45
  break;
46
46
  case 'exponential':
47
47
  default:
48
- delay = config.initialDelayMs * Math.pow(config.backoffMultiplier, attempt - 1);
48
+ delay =
49
+ config.initialDelayMs *
50
+ Math.pow(config.backoffMultiplier, attempt - 1);
49
51
  }
50
52
  // Apply max delay cap
51
53
  delay = Math.min(delay, config.maxDelayMs);
@@ -90,7 +92,7 @@ function shouldRetryError(error, attempt, config) {
90
92
  * Sleep for a given number of milliseconds
91
93
  */
92
94
  function sleep(ms) {
93
- return new Promise(resolve => setTimeout(resolve, ms));
95
+ return new Promise((resolve) => setTimeout(resolve, ms));
94
96
  }
95
97
  /**
96
98
  * Execute a function with retry logic
@@ -4,9 +4,9 @@
4
4
  * Runs without TTY for daemon processes and scheduled tasks
5
5
  *
6
6
  * Usage:
7
- * npx @monoes/cli headless --worker <type>
8
- * npx @monoes/cli headless --daemon
9
- * npx @monoes/cli headless --benchmark
7
+ * npx @monomind/cli headless --worker <type>
8
+ * npx @monomind/cli headless --daemon
9
+ * npx @monomind/cli headless --benchmark
10
10
  *
11
11
  * Environment:
12
12
  * MONOMIND_HEADLESS=true
@@ -12,19 +12,20 @@
12
12
  *
13
13
  * @see /packages/implementation/adrs/ADR-016-collaborative-issue-claims.md
14
14
  */
15
- import { EventEmitter } from 'events';
16
- export type Claimant = {
15
+ import { EventEmitter } from 'node:events';
16
+ export type ClaimStatus = 'active' | 'paused' | 'handoff-pending' | 'review-requested' | 'blocked' | 'stealable' | 'completed';
17
+ export interface HumanClaimant {
17
18
  type: 'human';
18
19
  userId: string;
19
20
  name: string;
20
- } | {
21
+ }
22
+ export interface AgentClaimant {
21
23
  type: 'agent';
22
24
  agentId: string;
23
25
  agentType: string;
24
- };
25
- export type ClaimStatus = 'active' | 'paused' | 'handoff-pending' | 'review-requested' | 'blocked' | 'stealable' | 'completed';
26
- export type StealReason = 'overloaded' | 'stale' | 'blocked-timeout' | 'voluntary';
27
- export interface IssueClaim {
26
+ }
27
+ export type Claimant = HumanClaimant | AgentClaimant;
28
+ export interface Claim {
28
29
  issueId: string;
29
30
  claimant: Claimant;
30
31
  claimedAt: Date;
@@ -38,48 +39,53 @@ export interface IssueClaim {
38
39
  context?: string;
39
40
  }
40
41
  export interface StealableInfo {
41
- reason: StealReason;
42
+ reason: string;
42
43
  stealableAt: Date;
43
- preferredTypes?: string[];
44
44
  progress: number;
45
45
  context?: string;
46
+ preferredTypes?: string[];
46
47
  }
47
48
  export interface ClaimResult {
48
49
  success: boolean;
49
- claim?: IssueClaim;
50
+ claim?: Claim;
50
51
  error?: string;
51
52
  }
52
53
  export interface StealResult {
53
54
  success: boolean;
54
- claim?: IssueClaim;
55
+ claim?: Claim;
55
56
  previousOwner?: Claimant;
56
57
  context?: StealableInfo;
57
58
  error?: string;
58
59
  }
59
- export interface AgentLoadInfo {
60
+ export interface AgentLoad {
60
61
  agentId: string;
61
62
  agentType: string;
62
63
  claimCount: number;
63
64
  maxClaims: number;
64
65
  utilization: number;
65
- claims: IssueClaim[];
66
+ claims: Claim[];
66
67
  avgCompletionTime: number;
67
68
  currentBlockedCount: number;
68
69
  }
70
+ export interface RebalanceSuggestion {
71
+ issueId: string;
72
+ currentOwner: Claimant;
73
+ suggestedOwner: Claimant;
74
+ reason: string;
75
+ }
69
76
  export interface RebalanceResult {
70
- moved: Array<{
71
- issueId: string;
72
- from: Claimant;
73
- to: Claimant;
74
- }>;
75
- suggested: Array<{
76
- issueId: string;
77
- currentOwner: Claimant;
78
- suggestedOwner: Claimant;
79
- reason: string;
80
- }>;
81
- }
82
- export interface WorkStealingConfig {
77
+ moved: string[];
78
+ suggested: RebalanceSuggestion[];
79
+ }
80
+ export interface ClaimEvent {
81
+ type: string;
82
+ timestamp: Date;
83
+ issueId: string;
84
+ claimant?: Claimant;
85
+ previousClaimant?: Claimant;
86
+ data?: Record<string, unknown>;
87
+ }
88
+ export interface ClaimServiceConfig {
83
89
  staleThresholdMinutes: number;
84
90
  blockedThresholdMinutes: number;
85
91
  overloadThreshold: number;
@@ -89,12 +95,6 @@ export interface WorkStealingConfig {
89
95
  requireSameType: boolean;
90
96
  allowCrossTypeSteal: string[][];
91
97
  }
92
- export interface IssueFilters {
93
- status?: ClaimStatus[];
94
- labels?: string[];
95
- agentTypes?: string[];
96
- priority?: string[];
97
- }
98
98
  export interface GitHubIssue {
99
99
  number: number;
100
100
  title: string;
@@ -108,35 +108,26 @@ export interface GitHubIssue {
108
108
  }
109
109
  export interface GitHubSyncConfig {
110
110
  enabled: boolean;
111
- repo?: string;
112
111
  syncLabels: boolean;
113
112
  claimLabel: string;
114
113
  autoAssign: boolean;
115
114
  commentOnClaim: boolean;
116
115
  commentOnRelease: boolean;
116
+ repo?: string;
117
117
  }
118
- export interface GitHubSyncResult {
118
+ export interface SyncResult {
119
119
  success: boolean;
120
120
  synced: number;
121
121
  errors: string[];
122
122
  issues?: GitHubIssue[];
123
123
  }
124
- export type ClaimEventType = 'issue:claimed' | 'issue:released' | 'issue:handoff:requested' | 'issue:handoff:accepted' | 'issue:handoff:rejected' | 'issue:status:changed' | 'issue:review:requested' | 'issue:expired' | 'issue:stealable' | 'issue:stolen' | 'issue:steal:contested' | 'issue:steal:resolved' | 'swarm:rebalanced' | 'agent:overloaded' | 'agent:underloaded';
125
- export interface ClaimEvent {
126
- type: ClaimEventType;
127
- timestamp: Date;
128
- issueId?: string;
129
- claimant?: Claimant;
130
- previousClaimant?: Claimant;
131
- data?: Record<string, unknown>;
132
- }
133
124
  export declare class ClaimService extends EventEmitter {
134
125
  private claims;
135
126
  private stealableInfo;
136
127
  private storagePath;
137
128
  private config;
138
129
  private eventLog;
139
- constructor(projectRoot: string, config?: Partial<WorkStealingConfig>);
130
+ constructor(projectRoot: string, config?: Partial<ClaimServiceConfig>);
140
131
  initialize(): Promise<void>;
141
132
  private loadClaims;
142
133
  private _saveQueue;
@@ -149,19 +140,19 @@ export declare class ClaimService extends EventEmitter {
149
140
  rejectHandoff(issueId: string, claimant: Claimant, reason: string): Promise<void>;
150
141
  updateStatus(issueId: string, status: ClaimStatus, note?: string): Promise<void>;
151
142
  updateProgress(issueId: string, progress: number): Promise<void>;
152
- requestReview(issueId: string, reviewers: Claimant[]): Promise<void>;
143
+ requestReview(issueId: string, reviewers: string[]): Promise<void>;
153
144
  markStealable(issueId: string, info: StealableInfo, claimant?: Claimant): Promise<void>;
154
145
  steal(issueId: string, stealer: Claimant): Promise<StealResult>;
155
- getStealable(agentType?: string): Promise<IssueClaim[]>;
146
+ getStealable(agentType?: string): Promise<Claim[]>;
156
147
  contestSteal(issueId: string, originalClaimant: Claimant, reason: string): Promise<void>;
157
- getAgentLoad(agentId: string): Promise<AgentLoadInfo>;
158
- rebalance(swarmId: string): Promise<RebalanceResult>;
159
- getClaimedBy(claimant: Claimant): Promise<IssueClaim[]>;
160
- getAvailableIssues(_filters?: IssueFilters): Promise<string[]>;
161
- getIssueStatus(issueId: string): Promise<IssueClaim | null>;
162
- getAllClaims(): Promise<IssueClaim[]>;
163
- getByStatus(status: ClaimStatus): Promise<IssueClaim[]>;
164
- expireStale(maxAgeMinutes?: number): Promise<IssueClaim[]>;
148
+ getAgentLoad(agentId: string): Promise<AgentLoad>;
149
+ rebalance(_swarmId: string): Promise<RebalanceResult>;
150
+ getClaimedBy(claimant: Claimant): Promise<Claim[]>;
151
+ getAvailableIssues(_filters?: unknown): Promise<GitHubIssue[]>;
152
+ getIssueStatus(issueId: string): Promise<Claim | null>;
153
+ getAllClaims(): Promise<Claim[]>;
154
+ getByStatus(status: ClaimStatus): Promise<Claim[]>;
155
+ expireStale(maxAgeMinutes?: number): Promise<Claim[]>;
165
156
  private formatClaimant;
166
157
  private isSameClaimant;
167
158
  private emitEvent;
@@ -182,25 +173,25 @@ export declare class GitHubSync {
182
173
  /**
183
174
  * Sync issues from GitHub
184
175
  */
185
- syncIssues(state?: 'open' | 'closed' | 'all'): Promise<GitHubSyncResult>;
176
+ syncIssues(state?: 'open' | 'closed' | 'all'): Promise<SyncResult>;
186
177
  /**
187
178
  * Sync a local claim to GitHub (add label/assignee/comment)
188
179
  */
189
- claimOnGitHub(issueNumber: number, claimant: Claimant): Promise<GitHubSyncResult>;
180
+ claimOnGitHub(issueNumber: number, claimant: Claimant): Promise<SyncResult>;
190
181
  /**
191
182
  * Release claim on GitHub (remove label/assignee/comment)
192
183
  */
193
- releaseOnGitHub(issueNumber: number, claimant: Claimant): Promise<GitHubSyncResult>;
184
+ releaseOnGitHub(issueNumber: number, claimant: Claimant): Promise<SyncResult>;
194
185
  /**
195
186
  * Bulk sync all local claims to GitHub
196
187
  */
197
- syncAllClaimsToGitHub(): Promise<GitHubSyncResult>;
188
+ syncAllClaimsToGitHub(): Promise<SyncResult>;
198
189
  /**
199
190
  * Get GitHub issues that are claimed locally
200
191
  */
201
192
  getClaimedGitHubIssues(): Promise<GitHubIssue[]>;
202
193
  }
203
- export declare function createClaimService(projectRoot: string, config?: Partial<WorkStealingConfig>): ClaimService;
194
+ export declare function createClaimService(projectRoot: string, config?: Partial<ClaimServiceConfig>): ClaimService;
204
195
  export declare function createGitHubSync(claimService: ClaimService, config?: Partial<GitHubSyncConfig>): GitHubSync;
205
196
  export default ClaimService;
206
197
  //# sourceMappingURL=claim-service.d.ts.map