kynjal-cli 3.1.3 → 4.0.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 (566) hide show
  1. package/.claude/agents/core/coder.md +1 -1
  2. package/.claude/agents/core/planner.md +2 -2
  3. package/.claude/agents/core/researcher.md +1 -1
  4. package/.claude/agents/core/reviewer.md +1 -1
  5. package/.claude/agents/core/tester.md +1 -1
  6. package/.claude/agents/data/data-ml-model.md +4 -4
  7. package/.claude/agents/development/dev-backend-api.md +4 -4
  8. package/.claude/agents/documentation/docs-api-openapi.md +4 -4
  9. package/.claude/agents/github/code-review-swarm.md +2 -2
  10. package/.claude/agents/github/issue-tracker.md +2 -2
  11. package/.claude/agents/github/pr-manager.md +2 -2
  12. package/.claude/agents/github/release-manager.md +2 -2
  13. package/.claude/agents/github/workflow-automation.md +2 -2
  14. package/.claude/agents/sparc/architecture.md +3 -3
  15. package/.claude/agents/sparc/pseudocode.md +2 -2
  16. package/.claude/agents/sparc/refinement.md +3 -3
  17. package/.claude/agents/sparc/specification.md +2 -2
  18. package/.claude/agents/swarm/adaptive-coordinator.md +1 -1
  19. package/.claude/agents/swarm/hierarchical-coordinator.md +1 -1
  20. package/.claude/agents/swarm/mesh-coordinator.md +1 -1
  21. package/.claude/agents/templates/base-template-generator.md +25 -4
  22. package/.claude/agents/templates/sparc-coordinator.md +3 -3
  23. package/.claude/helpers/auto-commit.sh +1 -1
  24. package/.claude/helpers/auto-memory-hook.mjs +27 -9
  25. package/.claude/helpers/hook-handler.cjs +58 -18
  26. package/.claude/helpers/statusline.cjs +14 -33
  27. package/.claude/helpers/statusline.js +3 -3
  28. package/.claude/settings.json +9 -9
  29. package/.claude/skills/reasoningbank-intelligence/SKILL.md +2 -2
  30. package/.claude/skills/swarm-orchestration/SKILL.md +1 -1
  31. package/README.md +383 -170
  32. package/bin/cli.js +6 -6
  33. package/bin/mcp-server.js +1 -1
  34. package/bin/preinstall.cjs +2 -0
  35. package/dist/src/appliance/gguf-engine.js +664 -0
  36. package/dist/src/appliance/gguf-engine.js.map +1 -0
  37. package/dist/src/appliance/ruvllm-bridge.js +492 -0
  38. package/dist/src/appliance/ruvllm-bridge.js.map +1 -0
  39. package/dist/src/appliance/rvfa-builder.js +383 -0
  40. package/dist/src/appliance/rvfa-builder.js.map +1 -0
  41. package/dist/src/appliance/rvfa-distribution.js +533 -0
  42. package/dist/src/appliance/rvfa-distribution.js.map +1 -0
  43. package/dist/src/appliance/rvfa-format.js +465 -0
  44. package/dist/src/appliance/rvfa-format.js.map +1 -0
  45. package/dist/src/appliance/rvfa-runner.js +373 -0
  46. package/dist/src/appliance/rvfa-runner.js.map +1 -0
  47. package/dist/src/appliance/rvfa-signing.js +469 -0
  48. package/dist/src/appliance/rvfa-signing.js.map +1 -0
  49. package/dist/src/benchmarks/pretrain/index.js +542 -331
  50. package/dist/src/benchmarks/pretrain/index.js.map +1 -1
  51. package/dist/src/commands/agent.d.ts.map +1 -1
  52. package/dist/src/commands/agent.js +725 -502
  53. package/dist/src/commands/agent.js.map +1 -1
  54. package/dist/src/commands/analyze.js +1548 -1218
  55. package/dist/src/commands/analyze.js.map +1 -1
  56. package/dist/src/commands/appliance-advanced.d.ts +9 -0
  57. package/dist/src/commands/appliance-advanced.d.ts.map +1 -0
  58. package/dist/src/commands/appliance-advanced.js +324 -0
  59. package/dist/src/commands/appliance-advanced.js.map +1 -0
  60. package/dist/src/commands/appliance.d.ts +8 -0
  61. package/dist/src/commands/appliance.d.ts.map +1 -0
  62. package/dist/src/commands/appliance.js +581 -0
  63. package/dist/src/commands/appliance.js.map +1 -0
  64. package/dist/src/commands/benchmark.js +523 -372
  65. package/dist/src/commands/benchmark.js.map +1 -1
  66. package/dist/src/commands/claims.js +364 -274
  67. package/dist/src/commands/claims.js.map +1 -1
  68. package/dist/src/commands/cleanup.d.ts +13 -0
  69. package/dist/src/commands/cleanup.d.ts.map +1 -0
  70. package/dist/src/commands/cleanup.js +262 -0
  71. package/dist/src/commands/cleanup.js.map +1 -0
  72. package/dist/src/commands/completions.js +118 -477
  73. package/dist/src/commands/completions.js.map +1 -1
  74. package/dist/src/commands/config.js +303 -237
  75. package/dist/src/commands/config.js.map +1 -1
  76. package/dist/src/commands/daemon.d.ts.map +1 -1
  77. package/dist/src/commands/daemon.js +597 -425
  78. package/dist/src/commands/daemon.js.map +1 -1
  79. package/dist/src/commands/deployment.js +275 -194
  80. package/dist/src/commands/deployment.js.map +1 -1
  81. package/dist/src/commands/doctor.d.ts.map +1 -1
  82. package/dist/src/commands/doctor.js +690 -460
  83. package/dist/src/commands/doctor.js.map +1 -1
  84. package/dist/src/commands/embeddings.js +1543 -1293
  85. package/dist/src/commands/embeddings.js.map +1 -1
  86. package/dist/src/commands/guidance.js +596 -449
  87. package/dist/src/commands/guidance.js.map +1 -1
  88. package/dist/src/commands/hive-mind.js +938 -854
  89. package/dist/src/commands/hive-mind.js.map +1 -1
  90. package/dist/src/commands/hooks.d.ts.map +1 -1
  91. package/dist/src/commands/hooks.js +3677 -2570
  92. package/dist/src/commands/hooks.js.map +1 -1
  93. package/dist/src/commands/index.js +322 -122
  94. package/dist/src/commands/index.js.map +1 -1
  95. package/dist/src/commands/init.d.ts +1 -1
  96. package/dist/src/commands/init.d.ts.map +1 -1
  97. package/dist/src/commands/init.js +943 -787
  98. package/dist/src/commands/init.js.map +1 -1
  99. package/dist/src/commands/issues.js +558 -383
  100. package/dist/src/commands/issues.js.map +1 -1
  101. package/dist/src/commands/mcp.d.ts.map +1 -1
  102. package/dist/src/commands/mcp.js +605 -475
  103. package/dist/src/commands/mcp.js.map +1 -1
  104. package/dist/src/commands/memory.d.ts.map +1 -1
  105. package/dist/src/commands/memory.js +1031 -814
  106. package/dist/src/commands/memory.js.map +1 -1
  107. package/dist/src/commands/migrate.js +347 -282
  108. package/dist/src/commands/migrate.js.map +1 -1
  109. package/dist/src/commands/neural.d.ts.map +1 -1
  110. package/dist/src/commands/neural.js +1563 -1283
  111. package/dist/src/commands/neural.js.map +1 -1
  112. package/dist/src/commands/performance.js +643 -497
  113. package/dist/src/commands/performance.js.map +1 -1
  114. package/dist/src/commands/plugins.js +841 -668
  115. package/dist/src/commands/plugins.js.map +1 -1
  116. package/dist/src/commands/process.js +447 -392
  117. package/dist/src/commands/process.js.map +1 -1
  118. package/dist/src/commands/progress.js +256 -162
  119. package/dist/src/commands/progress.js.map +1 -1
  120. package/dist/src/commands/providers.js +220 -150
  121. package/dist/src/commands/providers.js.map +1 -1
  122. package/dist/src/commands/route.js +665 -520
  123. package/dist/src/commands/route.js.map +1 -1
  124. package/dist/src/commands/ruvector/backup.js +651 -505
  125. package/dist/src/commands/ruvector/backup.js.map +1 -1
  126. package/dist/src/commands/ruvector/benchmark.js +401 -349
  127. package/dist/src/commands/ruvector/benchmark.js.map +1 -1
  128. package/dist/src/commands/ruvector/import.js +267 -225
  129. package/dist/src/commands/ruvector/import.js.map +1 -1
  130. package/dist/src/commands/ruvector/index.js +75 -37
  131. package/dist/src/commands/ruvector/index.js.map +1 -1
  132. package/dist/src/commands/ruvector/init.js +359 -336
  133. package/dist/src/commands/ruvector/init.js.map +1 -1
  134. package/dist/src/commands/ruvector/migrate.js +322 -335
  135. package/dist/src/commands/ruvector/migrate.js.map +1 -1
  136. package/dist/src/commands/ruvector/optimize.js +431 -375
  137. package/dist/src/commands/ruvector/optimize.js.map +1 -1
  138. package/dist/src/commands/ruvector/setup.js +117 -703
  139. package/dist/src/commands/ruvector/setup.js.map +1 -1
  140. package/dist/src/commands/ruvector/status.js +419 -364
  141. package/dist/src/commands/ruvector/status.js.map +1 -1
  142. package/dist/src/commands/security.d.ts.map +1 -1
  143. package/dist/src/commands/security.js +610 -456
  144. package/dist/src/commands/security.js.map +1 -1
  145. package/dist/src/commands/session.d.ts +1 -1
  146. package/dist/src/commands/session.js +627 -505
  147. package/dist/src/commands/session.js.map +1 -1
  148. package/dist/src/commands/start.d.ts +1 -1
  149. package/dist/src/commands/start.js +368 -271
  150. package/dist/src/commands/start.js.map +1 -1
  151. package/dist/src/commands/status.d.ts +1 -1
  152. package/dist/src/commands/status.d.ts.map +1 -1
  153. package/dist/src/commands/status.js +492 -379
  154. package/dist/src/commands/status.js.map +1 -1
  155. package/dist/src/commands/swarm.js +488 -408
  156. package/dist/src/commands/swarm.js.map +1 -1
  157. package/dist/src/commands/task.d.ts +1 -1
  158. package/dist/src/commands/task.js +539 -424
  159. package/dist/src/commands/task.js.map +1 -1
  160. package/dist/src/commands/transfer-store.js +412 -322
  161. package/dist/src/commands/transfer-store.js.map +1 -1
  162. package/dist/src/commands/update.js +291 -196
  163. package/dist/src/commands/update.js.map +1 -1
  164. package/dist/src/commands/workflow.js +486 -386
  165. package/dist/src/commands/workflow.js.map +1 -1
  166. package/dist/src/config-adapter.js +40 -39
  167. package/dist/src/config-adapter.js.map +1 -1
  168. package/dist/src/index.js +416 -312
  169. package/dist/src/index.js.map +1 -1
  170. package/dist/src/infrastructure/in-memory-repositories.js +507 -246
  171. package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
  172. package/dist/src/init/claudemd-generator.js +78 -368
  173. package/dist/src/init/claudemd-generator.js.map +1 -1
  174. package/dist/src/init/executor.js +1019 -1345
  175. package/dist/src/init/executor.js.map +1 -1
  176. package/dist/src/init/helpers-generator.js +60 -635
  177. package/dist/src/init/helpers-generator.js.map +1 -1
  178. package/dist/src/init/index.d.ts +1 -1
  179. package/dist/src/init/index.d.ts.map +1 -1
  180. package/dist/src/init/index.js +1 -1
  181. package/dist/src/init/index.js.map +1 -1
  182. package/dist/src/init/mcp-generator.d.ts +0 -1
  183. package/dist/src/init/mcp-generator.d.ts.map +1 -1
  184. package/dist/src/init/mcp-generator.js +62 -42
  185. package/dist/src/init/mcp-generator.js.map +1 -1
  186. package/dist/src/init/settings-generator.d.ts.map +1 -1
  187. package/dist/src/init/settings-generator.js +167 -100
  188. package/dist/src/init/settings-generator.js.map +1 -1
  189. package/dist/src/init/statusline-generator.d.ts +16 -8
  190. package/dist/src/init/statusline-generator.d.ts.map +1 -1
  191. package/dist/src/init/statusline-generator.js +20 -1300
  192. package/dist/src/init/statusline-generator.js.map +1 -1
  193. package/dist/src/init/types.d.ts +15 -5
  194. package/dist/src/init/types.d.ts.map +1 -1
  195. package/dist/src/init/types.js +66 -76
  196. package/dist/src/init/types.js.map +1 -1
  197. package/dist/src/mcp-client.js +130 -76
  198. package/dist/src/mcp-client.js.map +1 -1
  199. package/dist/src/mcp-server.js +758 -445
  200. package/dist/src/mcp-server.js.map +1 -1
  201. package/dist/src/mcp-tools/agent-tools.js +492 -391
  202. package/dist/src/mcp-tools/agent-tools.js.map +1 -1
  203. package/dist/src/mcp-tools/agentdb-tools.d.ts +30 -0
  204. package/dist/src/mcp-tools/agentdb-tools.d.ts.map +1 -0
  205. package/dist/src/mcp-tools/agentdb-tools.js +758 -0
  206. package/dist/src/mcp-tools/agentdb-tools.js.map +1 -0
  207. package/dist/src/mcp-tools/analyze-tools.js +236 -172
  208. package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
  209. package/dist/src/mcp-tools/auto-install.js +142 -80
  210. package/dist/src/mcp-tools/auto-install.js.map +1 -1
  211. package/dist/src/mcp-tools/browser-tools.js +375 -252
  212. package/dist/src/mcp-tools/browser-tools.js.map +1 -1
  213. package/dist/src/mcp-tools/claims-tools.js +565 -473
  214. package/dist/src/mcp-tools/claims-tools.js.map +1 -1
  215. package/dist/src/mcp-tools/config-tools.d.ts.map +1 -1
  216. package/dist/src/mcp-tools/config-tools.js +284 -190
  217. package/dist/src/mcp-tools/config-tools.js.map +1 -1
  218. package/dist/src/mcp-tools/coordination-tools.d.ts.map +1 -1
  219. package/dist/src/mcp-tools/coordination-tools.js +600 -349
  220. package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
  221. package/dist/src/mcp-tools/daa-tools.js +367 -289
  222. package/dist/src/mcp-tools/daa-tools.js.map +1 -1
  223. package/dist/src/mcp-tools/embeddings-tools.js +693 -582
  224. package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
  225. package/dist/src/mcp-tools/github-tools.js +312 -261
  226. package/dist/src/mcp-tools/github-tools.js.map +1 -1
  227. package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -1
  228. package/dist/src/mcp-tools/hive-mind-tools.js +718 -423
  229. package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
  230. package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
  231. package/dist/src/mcp-tools/hooks-tools.js +2726 -1978
  232. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  233. package/dist/src/mcp-tools/index.d.ts +2 -0
  234. package/dist/src/mcp-tools/index.d.ts.map +1 -1
  235. package/dist/src/mcp-tools/index.js +2 -0
  236. package/dist/src/mcp-tools/index.js.map +1 -1
  237. package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
  238. package/dist/src/mcp-tools/memory-tools.js +514 -329
  239. package/dist/src/mcp-tools/memory-tools.js.map +1 -1
  240. package/dist/src/mcp-tools/neural-tools.d.ts.map +1 -1
  241. package/dist/src/mcp-tools/neural-tools.js +428 -326
  242. package/dist/src/mcp-tools/neural-tools.js.map +1 -1
  243. package/dist/src/mcp-tools/performance-tools.js +480 -420
  244. package/dist/src/mcp-tools/performance-tools.js.map +1 -1
  245. package/dist/src/mcp-tools/progress-tools.js +278 -204
  246. package/dist/src/mcp-tools/progress-tools.js.map +1 -1
  247. package/dist/src/mcp-tools/ruvllm-tools.d.ts +9 -0
  248. package/dist/src/mcp-tools/ruvllm-tools.d.ts.map +1 -0
  249. package/dist/src/mcp-tools/ruvllm-tools.js +399 -0
  250. package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -0
  251. package/dist/src/mcp-tools/security-tools.js +429 -297
  252. package/dist/src/mcp-tools/security-tools.js.map +1 -1
  253. package/dist/src/mcp-tools/session-tools.js +234 -185
  254. package/dist/src/mcp-tools/session-tools.js.map +1 -1
  255. package/dist/src/mcp-tools/swarm-tools.d.ts +2 -1
  256. package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -1
  257. package/dist/src/mcp-tools/swarm-tools.js +303 -64
  258. package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
  259. package/dist/src/mcp-tools/system-tools.d.ts.map +1 -1
  260. package/dist/src/mcp-tools/system-tools.js +352 -200
  261. package/dist/src/mcp-tools/system-tools.js.map +1 -1
  262. package/dist/src/mcp-tools/task-tools.d.ts.map +1 -1
  263. package/dist/src/mcp-tools/task-tools.js +357 -189
  264. package/dist/src/mcp-tools/task-tools.js.map +1 -1
  265. package/dist/src/mcp-tools/terminal-tools.js +196 -148
  266. package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
  267. package/dist/src/mcp-tools/transfer-tools.js +333 -186
  268. package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
  269. package/dist/src/mcp-tools/wasm-agent-tools.d.ts +9 -0
  270. package/dist/src/mcp-tools/wasm-agent-tools.d.ts.map +1 -0
  271. package/dist/src/mcp-tools/wasm-agent-tools.js +377 -0
  272. package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -0
  273. package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -1
  274. package/dist/src/mcp-tools/workflow-tools.js +471 -335
  275. package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
  276. package/dist/src/memory/ewc-consolidation.js +345 -173
  277. package/dist/src/memory/ewc-consolidation.js.map +1 -1
  278. package/dist/src/memory/intelligence.js +841 -359
  279. package/dist/src/memory/intelligence.js.map +1 -1
  280. package/dist/src/memory/memory-bridge.js +1964 -0
  281. package/dist/src/memory/memory-bridge.js.map +1 -0
  282. package/dist/src/memory/memory-initializer.js +1895 -1602
  283. package/dist/src/memory/memory-initializer.js.map +1 -1
  284. package/dist/src/memory/sona-optimizer.js +329 -199
  285. package/dist/src/memory/sona-optimizer.js.map +1 -1
  286. package/dist/src/output.d.ts +2 -2
  287. package/dist/src/output.d.ts.map +1 -1
  288. package/dist/src/output.js +273 -242
  289. package/dist/src/output.js.map +1 -1
  290. package/dist/src/parser.js +217 -124
  291. package/dist/src/parser.js.map +1 -1
  292. package/dist/src/plugins/manager.js +531 -278
  293. package/dist/src/plugins/manager.js.map +1 -1
  294. package/dist/src/plugins/store/discovery.js +362 -275
  295. package/dist/src/plugins/store/discovery.js.map +1 -1
  296. package/dist/src/plugins/store/index.js +105 -48
  297. package/dist/src/plugins/store/index.js.map +1 -1
  298. package/dist/src/plugins/store/search.js +107 -69
  299. package/dist/src/plugins/store/search.js.map +1 -1
  300. package/dist/src/plugins/tests/demo-plugin-store.js +160 -113
  301. package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
  302. package/dist/src/plugins/tests/standalone-test.js +223 -172
  303. package/dist/src/plugins/tests/standalone-test.js.map +1 -1
  304. package/dist/src/plugins/tests/test-plugin-store.js +228 -190
  305. package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
  306. package/dist/src/production/circuit-breaker.js +126 -62
  307. package/dist/src/production/circuit-breaker.js.map +1 -1
  308. package/dist/src/production/error-handler.js +156 -86
  309. package/dist/src/production/error-handler.js.map +1 -1
  310. package/dist/src/production/monitoring.js +220 -139
  311. package/dist/src/production/monitoring.js.map +1 -1
  312. package/dist/src/production/rate-limiter.js +93 -74
  313. package/dist/src/production/rate-limiter.js.map +1 -1
  314. package/dist/src/production/retry.js +167 -75
  315. package/dist/src/production/retry.js.map +1 -1
  316. package/dist/src/prompt.js +560 -436
  317. package/dist/src/prompt.js.map +1 -1
  318. package/dist/src/runtime/headless.js +289 -200
  319. package/dist/src/runtime/headless.js.map +1 -1
  320. package/dist/src/ruvector/agent-wasm.js +511 -0
  321. package/dist/src/ruvector/agent-wasm.js.map +1 -0
  322. package/dist/src/ruvector/ast-analyzer.js +232 -145
  323. package/dist/src/ruvector/ast-analyzer.js.map +1 -1
  324. package/dist/src/ruvector/coverage-router.js +419 -287
  325. package/dist/src/ruvector/coverage-router.js.map +1 -1
  326. package/dist/src/ruvector/coverage-tools.js +101 -56
  327. package/dist/src/ruvector/coverage-tools.js.map +1 -1
  328. package/dist/src/ruvector/diff-classifier.js +451 -324
  329. package/dist/src/ruvector/diff-classifier.js.map +1 -1
  330. package/dist/src/ruvector/enhanced-model-router.js +337 -251
  331. package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
  332. package/dist/src/ruvector/flash-attention.js +254 -223
  333. package/dist/src/ruvector/flash-attention.js.map +1 -1
  334. package/dist/src/ruvector/graph-analyzer.js +680 -486
  335. package/dist/src/ruvector/graph-analyzer.js.map +1 -1
  336. package/dist/src/ruvector/index.js +113 -27
  337. package/dist/src/ruvector/index.js.map +1 -1
  338. package/dist/src/ruvector/lora-adapter.js +248 -155
  339. package/dist/src/ruvector/lora-adapter.js.map +1 -1
  340. package/dist/src/ruvector/model-router.js +248 -175
  341. package/dist/src/ruvector/model-router.js.map +1 -1
  342. package/dist/src/ruvector/moe-router.js +286 -228
  343. package/dist/src/ruvector/moe-router.js.map +1 -1
  344. package/dist/src/ruvector/q-learning-router.js +338 -257
  345. package/dist/src/ruvector/q-learning-router.js.map +1 -1
  346. package/dist/src/ruvector/ruvllm-wasm.js +527 -0
  347. package/dist/src/ruvector/ruvllm-wasm.js.map +1 -0
  348. package/dist/src/ruvector/semantic-router.js +67 -60
  349. package/dist/src/ruvector/semantic-router.js.map +1 -1
  350. package/dist/src/ruvector/vector-db.js +205 -119
  351. package/dist/src/ruvector/vector-db.js.map +1 -1
  352. package/dist/src/services/agentic-flow-bridge.js +168 -0
  353. package/dist/src/services/agentic-flow-bridge.js.map +1 -0
  354. package/dist/src/services/claim-service.js +940 -615
  355. package/dist/src/services/claim-service.js.map +1 -1
  356. package/dist/src/services/container-worker-pool.js +669 -399
  357. package/dist/src/services/container-worker-pool.js.map +1 -1
  358. package/dist/src/services/headless-worker-executor.js +467 -441
  359. package/dist/src/services/headless-worker-executor.js.map +1 -1
  360. package/dist/src/services/index.d.ts +5 -5
  361. package/dist/src/services/index.d.ts.map +1 -1
  362. package/dist/src/services/index.js +4 -4
  363. package/dist/src/services/index.js.map +1 -1
  364. package/dist/src/services/registry-api.js +201 -93
  365. package/dist/src/services/registry-api.js.map +1 -1
  366. package/dist/src/services/ruvector-training.js +414 -144
  367. package/dist/src/services/ruvector-training.js.map +1 -1
  368. package/dist/src/services/worker-daemon.js +928 -531
  369. package/dist/src/services/worker-daemon.js.map +1 -1
  370. package/dist/src/services/worker-queue.js +550 -331
  371. package/dist/src/services/worker-queue.js.map +1 -1
  372. package/dist/src/suggest.js +55 -45
  373. package/dist/src/suggest.js.map +1 -1
  374. package/dist/src/transfer/anonymization/index.js +37 -29
  375. package/dist/src/transfer/anonymization/index.js.map +1 -1
  376. package/dist/src/transfer/deploy-seraphine.d.ts +1 -1
  377. package/dist/src/transfer/deploy-seraphine.js +156 -129
  378. package/dist/src/transfer/deploy-seraphine.js.map +1 -1
  379. package/dist/src/transfer/export.js +142 -84
  380. package/dist/src/transfer/export.js.map +1 -1
  381. package/dist/src/transfer/index.d.ts +1 -1
  382. package/dist/src/transfer/index.d.ts.map +1 -1
  383. package/dist/src/transfer/index.js +2 -0
  384. package/dist/src/transfer/index.js.map +1 -1
  385. package/dist/src/transfer/ipfs/client.js +337 -179
  386. package/dist/src/transfer/ipfs/client.js.map +1 -1
  387. package/dist/src/transfer/ipfs/upload.js +434 -290
  388. package/dist/src/transfer/ipfs/upload.js.map +1 -1
  389. package/dist/src/transfer/models/seraphine.js +58 -58
  390. package/dist/src/transfer/models/seraphine.js.map +1 -1
  391. package/dist/src/transfer/serialization/cfp.js +37 -33
  392. package/dist/src/transfer/serialization/cfp.js.map +1 -1
  393. package/dist/src/transfer/storage/gcs.js +248 -139
  394. package/dist/src/transfer/storage/gcs.js.map +1 -1
  395. package/dist/src/transfer/store/discovery.js +353 -243
  396. package/dist/src/transfer/store/discovery.js.map +1 -1
  397. package/dist/src/transfer/store/download.js +365 -243
  398. package/dist/src/transfer/store/download.js.map +1 -1
  399. package/dist/src/transfer/store/index.js +130 -63
  400. package/dist/src/transfer/store/index.js.map +1 -1
  401. package/dist/src/transfer/store/publish.js +258 -184
  402. package/dist/src/transfer/store/publish.js.map +1 -1
  403. package/dist/src/transfer/store/registry.js +73 -51
  404. package/dist/src/transfer/store/registry.js.map +1 -1
  405. package/dist/src/transfer/store/search.js +96 -64
  406. package/dist/src/transfer/store/search.js.map +1 -1
  407. package/dist/src/transfer/store/tests/standalone-test.js +231 -174
  408. package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
  409. package/dist/src/transfer/test-seraphine.js +130 -95
  410. package/dist/src/transfer/test-seraphine.js.map +1 -1
  411. package/dist/src/transfer/tests/test-store.js +239 -194
  412. package/dist/src/transfer/tests/test-store.js.map +1 -1
  413. package/dist/src/types.js +56 -27
  414. package/dist/src/types.js.map +1 -1
  415. package/dist/src/update/checker.js +183 -106
  416. package/dist/src/update/checker.js.map +1 -1
  417. package/dist/src/update/executor.js +198 -135
  418. package/dist/src/update/executor.js.map +1 -1
  419. package/dist/src/update/index.js +85 -38
  420. package/dist/src/update/index.js.map +1 -1
  421. package/dist/src/update/rate-limiter.js +31 -19
  422. package/dist/src/update/rate-limiter.js.map +1 -1
  423. package/dist/src/update/validator.js +64 -38
  424. package/dist/src/update/validator.js.map +1 -1
  425. package/dist/tsconfig.tsbuildinfo +1 -1
  426. package/package.json +13 -10
  427. package/.claude/agents/custom/accessibility-auditor.yaml +0 -56
  428. package/.claude/agents/custom/design-architect.yaml +0 -48
  429. package/.claude/agents/custom/ui-developer.yaml +0 -46
  430. package/.claude/agents/custom/ux-researcher.yaml +0 -60
  431. package/dist/src/benchmarks/pretrain/index.d.ts +0 -58
  432. package/dist/src/benchmarks/pretrain/index.d.ts.map +0 -1
  433. package/dist/src/commands/index.d.ts +0 -108
  434. package/dist/src/commands/index.d.ts.map +0 -1
  435. package/dist/src/config-adapter.d.ts +0 -15
  436. package/dist/src/config-adapter.d.ts.map +0 -1
  437. package/dist/src/index.d.ts +0 -76
  438. package/dist/src/index.d.ts.map +0 -1
  439. package/dist/src/infrastructure/in-memory-repositories.d.ts +0 -68
  440. package/dist/src/infrastructure/in-memory-repositories.d.ts.map +0 -1
  441. package/dist/src/init/claudemd-generator.d.ts +0 -25
  442. package/dist/src/init/claudemd-generator.d.ts.map +0 -1
  443. package/dist/src/init/executor.d.ts +0 -41
  444. package/dist/src/init/executor.d.ts.map +0 -1
  445. package/dist/src/init/helpers-generator.d.ts +0 -60
  446. package/dist/src/init/helpers-generator.d.ts.map +0 -1
  447. package/dist/src/mcp-client.d.ts +0 -92
  448. package/dist/src/mcp-client.d.ts.map +0 -1
  449. package/dist/src/mcp-server.d.ts +0 -161
  450. package/dist/src/mcp-server.d.ts.map +0 -1
  451. package/dist/src/mcp-tools/auto-install.d.ts +0 -83
  452. package/dist/src/mcp-tools/auto-install.d.ts.map +0 -1
  453. package/dist/src/mcp-tools/types.d.ts +0 -31
  454. package/dist/src/mcp-tools/types.d.ts.map +0 -1
  455. package/dist/src/memory/ewc-consolidation.d.ts +0 -271
  456. package/dist/src/memory/ewc-consolidation.d.ts.map +0 -1
  457. package/dist/src/memory/intelligence.d.ts +0 -285
  458. package/dist/src/memory/intelligence.d.ts.map +0 -1
  459. package/dist/src/memory/memory-initializer.d.ts +0 -396
  460. package/dist/src/memory/memory-initializer.d.ts.map +0 -1
  461. package/dist/src/memory/sona-optimizer.d.ts +0 -227
  462. package/dist/src/memory/sona-optimizer.d.ts.map +0 -1
  463. package/dist/src/parser.d.ts +0 -41
  464. package/dist/src/parser.d.ts.map +0 -1
  465. package/dist/src/plugins/manager.d.ts +0 -133
  466. package/dist/src/plugins/manager.d.ts.map +0 -1
  467. package/dist/src/plugins/store/discovery.d.ts +0 -88
  468. package/dist/src/plugins/store/discovery.d.ts.map +0 -1
  469. package/dist/src/plugins/store/index.d.ts +0 -76
  470. package/dist/src/plugins/store/index.d.ts.map +0 -1
  471. package/dist/src/plugins/store/search.d.ts +0 -46
  472. package/dist/src/plugins/store/search.d.ts.map +0 -1
  473. package/dist/src/plugins/store/types.d.ts +0 -274
  474. package/dist/src/plugins/store/types.d.ts.map +0 -1
  475. package/dist/src/production/circuit-breaker.d.ts +0 -101
  476. package/dist/src/production/circuit-breaker.d.ts.map +0 -1
  477. package/dist/src/production/error-handler.d.ts +0 -92
  478. package/dist/src/production/error-handler.d.ts.map +0 -1
  479. package/dist/src/production/monitoring.d.ts +0 -161
  480. package/dist/src/production/monitoring.d.ts.map +0 -1
  481. package/dist/src/production/rate-limiter.d.ts +0 -80
  482. package/dist/src/production/rate-limiter.d.ts.map +0 -1
  483. package/dist/src/production/retry.d.ts +0 -48
  484. package/dist/src/production/retry.d.ts.map +0 -1
  485. package/dist/src/prompt.d.ts +0 -44
  486. package/dist/src/prompt.d.ts.map +0 -1
  487. package/dist/src/runtime/headless.d.ts +0 -60
  488. package/dist/src/runtime/headless.d.ts.map +0 -1
  489. package/dist/src/ruvector/ast-analyzer.d.ts +0 -67
  490. package/dist/src/ruvector/ast-analyzer.d.ts.map +0 -1
  491. package/dist/src/ruvector/coverage-router.d.ts +0 -160
  492. package/dist/src/ruvector/coverage-router.d.ts.map +0 -1
  493. package/dist/src/ruvector/diff-classifier.d.ts +0 -175
  494. package/dist/src/ruvector/diff-classifier.d.ts.map +0 -1
  495. package/dist/src/ruvector/enhanced-model-router.d.ts +0 -146
  496. package/dist/src/ruvector/enhanced-model-router.d.ts.map +0 -1
  497. package/dist/src/ruvector/flash-attention.d.ts +0 -195
  498. package/dist/src/ruvector/flash-attention.d.ts.map +0 -1
  499. package/dist/src/ruvector/graph-analyzer.d.ts +0 -187
  500. package/dist/src/ruvector/graph-analyzer.d.ts.map +0 -1
  501. package/dist/src/ruvector/index.d.ts +0 -34
  502. package/dist/src/ruvector/index.d.ts.map +0 -1
  503. package/dist/src/ruvector/lora-adapter.d.ts +0 -218
  504. package/dist/src/ruvector/lora-adapter.d.ts.map +0 -1
  505. package/dist/src/ruvector/model-router.d.ts +0 -220
  506. package/dist/src/ruvector/model-router.d.ts.map +0 -1
  507. package/dist/src/ruvector/moe-router.d.ts +0 -206
  508. package/dist/src/ruvector/moe-router.d.ts.map +0 -1
  509. package/dist/src/ruvector/q-learning-router.d.ts +0 -211
  510. package/dist/src/ruvector/q-learning-router.d.ts.map +0 -1
  511. package/dist/src/ruvector/semantic-router.d.ts +0 -77
  512. package/dist/src/ruvector/semantic-router.d.ts.map +0 -1
  513. package/dist/src/ruvector/vector-db.d.ts +0 -69
  514. package/dist/src/ruvector/vector-db.d.ts.map +0 -1
  515. package/dist/src/services/claim-service.d.ts +0 -204
  516. package/dist/src/services/claim-service.d.ts.map +0 -1
  517. package/dist/src/services/container-worker-pool.d.ts +0 -197
  518. package/dist/src/services/container-worker-pool.d.ts.map +0 -1
  519. package/dist/src/services/headless-worker-executor.d.ts +0 -304
  520. package/dist/src/services/headless-worker-executor.d.ts.map +0 -1
  521. package/dist/src/services/registry-api.d.ts +0 -58
  522. package/dist/src/services/registry-api.d.ts.map +0 -1
  523. package/dist/src/services/ruvector-training.d.ts +0 -213
  524. package/dist/src/services/ruvector-training.d.ts.map +0 -1
  525. package/dist/src/services/worker-daemon.d.ts +0 -203
  526. package/dist/src/services/worker-daemon.d.ts.map +0 -1
  527. package/dist/src/services/worker-queue.d.ts +0 -194
  528. package/dist/src/services/worker-queue.d.ts.map +0 -1
  529. package/dist/src/suggest.d.ts +0 -53
  530. package/dist/src/suggest.d.ts.map +0 -1
  531. package/dist/src/transfer/export.d.ts +0 -25
  532. package/dist/src/transfer/export.d.ts.map +0 -1
  533. package/dist/src/transfer/ipfs/client.d.ts +0 -109
  534. package/dist/src/transfer/ipfs/client.d.ts.map +0 -1
  535. package/dist/src/transfer/ipfs/upload.d.ts +0 -95
  536. package/dist/src/transfer/ipfs/upload.d.ts.map +0 -1
  537. package/dist/src/transfer/models/seraphine.d.ts +0 -72
  538. package/dist/src/transfer/models/seraphine.d.ts.map +0 -1
  539. package/dist/src/transfer/serialization/cfp.d.ts +0 -49
  540. package/dist/src/transfer/serialization/cfp.d.ts.map +0 -1
  541. package/dist/src/transfer/storage/gcs.d.ts +0 -82
  542. package/dist/src/transfer/storage/gcs.d.ts.map +0 -1
  543. package/dist/src/transfer/store/discovery.d.ts +0 -84
  544. package/dist/src/transfer/store/discovery.d.ts.map +0 -1
  545. package/dist/src/transfer/store/download.d.ts +0 -70
  546. package/dist/src/transfer/store/download.d.ts.map +0 -1
  547. package/dist/src/transfer/store/index.d.ts +0 -84
  548. package/dist/src/transfer/store/index.d.ts.map +0 -1
  549. package/dist/src/transfer/store/publish.d.ts +0 -76
  550. package/dist/src/transfer/store/publish.d.ts.map +0 -1
  551. package/dist/src/transfer/store/search.d.ts +0 -54
  552. package/dist/src/transfer/store/search.d.ts.map +0 -1
  553. package/dist/src/transfer/types.d.ts +0 -245
  554. package/dist/src/transfer/types.d.ts.map +0 -1
  555. package/dist/src/types.d.ts +0 -198
  556. package/dist/src/types.d.ts.map +0 -1
  557. package/dist/src/update/checker.d.ts +0 -34
  558. package/dist/src/update/checker.d.ts.map +0 -1
  559. package/dist/src/update/executor.d.ts +0 -32
  560. package/dist/src/update/executor.d.ts.map +0 -1
  561. package/dist/src/update/index.d.ts +0 -33
  562. package/dist/src/update/index.d.ts.map +0 -1
  563. package/dist/src/update/rate-limiter.d.ts +0 -20
  564. package/dist/src/update/rate-limiter.d.ts.map +0 -1
  565. package/dist/src/update/validator.d.ts +0 -17
  566. package/dist/src/update/validator.d.ts.map +0 -1
@@ -12,6 +12,68 @@
12
12
  *
13
13
  * @see /v3/implementation/adrs/ADR-016-collaborative-issue-claims.md
14
14
  */
15
+ var __extends = (this && this.__extends) || (function () {
16
+ var extendStatics = function (d, b) {
17
+ extendStatics = Object.setPrototypeOf ||
18
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
20
+ return extendStatics(d, b);
21
+ };
22
+ return function (d, b) {
23
+ if (typeof b !== "function" && b !== null)
24
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
25
+ extendStatics(d, b);
26
+ function __() { this.constructor = d; }
27
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
28
+ };
29
+ })();
30
+ var __assign = (this && this.__assign) || function () {
31
+ __assign = Object.assign || function(t) {
32
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
33
+ s = arguments[i];
34
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
35
+ t[p] = s[p];
36
+ }
37
+ return t;
38
+ };
39
+ return __assign.apply(this, arguments);
40
+ };
41
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
42
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
43
+ return new (P || (P = Promise))(function (resolve, reject) {
44
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
45
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
46
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
47
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
48
+ });
49
+ };
50
+ var __generator = (this && this.__generator) || function (thisArg, body) {
51
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
52
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
53
+ function verb(n) { return function (v) { return step([n, v]); }; }
54
+ function step(op) {
55
+ if (f) throw new TypeError("Generator is already executing.");
56
+ while (_) try {
57
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
58
+ if (y = 0, t) op = [op[0] & 2, t.value];
59
+ switch (op[0]) {
60
+ case 0: case 1: t = op; break;
61
+ case 4: _.label++; return { value: op[1], done: false };
62
+ case 5: _.label++; y = op[1]; op = [0]; continue;
63
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
64
+ default:
65
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
66
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
67
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
68
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
69
+ if (t[2]) _.ops.pop();
70
+ _.trys.pop(); continue;
71
+ }
72
+ op = body.call(thisArg, _);
73
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
74
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
75
+ }
76
+ };
15
77
  import { EventEmitter } from 'events';
16
78
  import * as fs from 'fs';
17
79
  import * as path from 'path';
@@ -19,7 +81,7 @@ import { execFileSync } from 'child_process';
19
81
  // ============================================================================
20
82
  // Default Configuration
21
83
  // ============================================================================
22
- const DEFAULT_CONFIG = {
84
+ var DEFAULT_CONFIG = {
23
85
  staleThresholdMinutes: 30,
24
86
  blockedThresholdMinutes: 60,
25
87
  overloadThreshold: 5,
@@ -30,435 +92,647 @@ const DEFAULT_CONFIG = {
30
92
  allowCrossTypeSteal: [
31
93
  ['coder', 'debugger'],
32
94
  ['tester', 'reviewer'],
33
- ],
95
+ ]
34
96
  };
35
97
  // ============================================================================
36
98
  // Claim Service Implementation
37
99
  // ============================================================================
38
- export class ClaimService extends EventEmitter {
39
- claims = new Map();
40
- stealableInfo = new Map();
41
- storagePath;
42
- config;
43
- eventLog = [];
44
- constructor(projectRoot, config) {
45
- super();
46
- this.storagePath = path.join(projectRoot, '.claude-flow', 'claims');
47
- this.config = { ...DEFAULT_CONFIG, ...config };
100
+ var ClaimService = /** @class */ (function (_super) {
101
+ __extends(ClaimService, _super);
102
+ function ClaimService(projectRoot, config) {
103
+ var _this = _super.call(this) || this;
104
+ _this.claims = new Map();
105
+ _this.stealableInfo = new Map();
106
+ _this.eventLog = [];
107
+ _this.storagePath = path.join(projectRoot, '.claude-flow', 'claims');
108
+ _this.config = __assign(__assign({}, DEFAULT_CONFIG), config);
109
+ return _this;
48
110
  }
49
111
  // ==========================================================================
50
112
  // Initialization
51
113
  // ==========================================================================
52
- async initialize() {
53
- // Ensure storage directory exists
54
- if (!fs.existsSync(this.storagePath)) {
55
- fs.mkdirSync(this.storagePath, { recursive: true });
56
- }
57
- // Load existing claims
58
- await this.loadClaims();
59
- }
60
- async loadClaims() {
61
- const claimsFile = path.join(this.storagePath, 'claims.json');
62
- if (fs.existsSync(claimsFile)) {
63
- try {
64
- const data = JSON.parse(fs.readFileSync(claimsFile, 'utf-8'));
65
- for (const claim of data.claims || []) {
66
- claim.claimedAt = new Date(claim.claimedAt);
67
- claim.statusChangedAt = new Date(claim.statusChangedAt);
68
- if (claim.expiresAt)
69
- claim.expiresAt = new Date(claim.expiresAt);
70
- this.claims.set(claim.issueId, claim);
114
+ ClaimService.prototype.initialize = function () {
115
+ return __awaiter(this, void 0, Promise, function () {
116
+ return __generator(this, function (_a) {
117
+ switch (_a.label) {
118
+ case 0:
119
+ // Ensure storage directory exists
120
+ if (!fs.existsSync(this.storagePath)) {
121
+ fs.mkdirSync(this.storagePath, { recursive: true });
122
+ }
123
+ // Load existing claims
124
+ return [4 /*yield*/, this.loadClaims()];
125
+ case 1:
126
+ // Load existing claims
127
+ _a.sent();
128
+ return [2 /*return*/];
71
129
  }
72
- }
73
- catch {
74
- // Start fresh if file is corrupted
75
- }
76
- }
77
- }
78
- async saveClaims() {
79
- const claimsFile = path.join(this.storagePath, 'claims.json');
80
- const data = {
81
- claims: Array.from(this.claims.values()),
82
- savedAt: new Date().toISOString(),
83
- };
84
- fs.writeFileSync(claimsFile, JSON.stringify(data, null, 2));
85
- }
130
+ });
131
+ });
132
+ };
133
+ ClaimService.prototype.loadClaims = function () {
134
+ return __awaiter(this, void 0, Promise, function () {
135
+ var claimsFile, data, _i, _a, claim;
136
+ return __generator(this, function (_b) {
137
+ claimsFile = path.join(this.storagePath, 'claims.json');
138
+ if (fs.existsSync(claimsFile)) {
139
+ try {
140
+ data = JSON.parse(fs.readFileSync(claimsFile, 'utf-8'));
141
+ for (_i = 0, _a = data.claims || []; _i < _a.length; _i++) {
142
+ claim = _a[_i];
143
+ claim.claimedAt = new Date(claim.claimedAt);
144
+ claim.statusChangedAt = new Date(claim.statusChangedAt);
145
+ if (claim.expiresAt)
146
+ claim.expiresAt = new Date(claim.expiresAt);
147
+ this.claims.set(claim.issueId, claim);
148
+ }
149
+ }
150
+ catch (_c) {
151
+ // Start fresh if file is corrupted
152
+ }
153
+ }
154
+ return [2 /*return*/];
155
+ });
156
+ });
157
+ };
158
+ ClaimService.prototype.saveClaims = function () {
159
+ return __awaiter(this, void 0, Promise, function () {
160
+ var claimsFile, data;
161
+ return __generator(this, function (_a) {
162
+ claimsFile = path.join(this.storagePath, 'claims.json');
163
+ data = {
164
+ claims: Array.from(this.claims.values()),
165
+ savedAt: new Date().toISOString()
166
+ };
167
+ fs.writeFileSync(claimsFile, JSON.stringify(data, null, 2));
168
+ return [2 /*return*/];
169
+ });
170
+ });
171
+ };
86
172
  // ==========================================================================
87
173
  // Core Claiming
88
174
  // ==========================================================================
89
- async claim(issueId, claimant) {
90
- // Check if already claimed
91
- const existing = this.claims.get(issueId);
92
- if (existing && existing.status !== 'stealable') {
93
- return {
94
- success: false,
95
- error: `Issue ${issueId} is already claimed by ${this.formatClaimant(existing.claimant)}`,
96
- };
97
- }
98
- const now = new Date();
99
- const claim = {
100
- issueId,
101
- claimant,
102
- claimedAt: now,
103
- status: 'active',
104
- statusChangedAt: now,
105
- progress: 0,
106
- };
107
- this.claims.set(issueId, claim);
108
- await this.saveClaims();
109
- this.emitEvent({
110
- type: 'issue:claimed',
111
- timestamp: now,
112
- issueId,
113
- claimant,
114
- previousClaimant: existing?.claimant,
175
+ ClaimService.prototype.claim = function (issueId, claimant) {
176
+ return __awaiter(this, void 0, Promise, function () {
177
+ var existing, now, claim;
178
+ return __generator(this, function (_a) {
179
+ switch (_a.label) {
180
+ case 0:
181
+ existing = this.claims.get(issueId);
182
+ if (existing && existing.status !== 'stealable') {
183
+ return [2 /*return*/, {
184
+ success: false,
185
+ error: "Issue " + issueId + " is already claimed by " + this.formatClaimant(existing.claimant)
186
+ }];
187
+ }
188
+ now = new Date();
189
+ claim = {
190
+ issueId: issueId,
191
+ claimant: claimant,
192
+ claimedAt: now,
193
+ status: 'active',
194
+ statusChangedAt: now,
195
+ progress: 0
196
+ };
197
+ this.claims.set(issueId, claim);
198
+ return [4 /*yield*/, this.saveClaims()];
199
+ case 1:
200
+ _a.sent();
201
+ this.emitEvent({
202
+ type: 'issue:claimed',
203
+ timestamp: now,
204
+ issueId: issueId,
205
+ claimant: claimant,
206
+ previousClaimant: existing === null || existing === void 0 ? void 0 : existing.claimant
207
+ });
208
+ return [2 /*return*/, { success: true, claim: claim }];
209
+ }
210
+ });
115
211
  });
116
- return { success: true, claim };
117
- }
118
- async release(issueId, claimant) {
119
- const claim = this.claims.get(issueId);
120
- if (!claim) {
121
- throw new Error(`Issue ${issueId} is not claimed`);
122
- }
123
- if (!this.isSameClaimant(claim.claimant, claimant)) {
124
- throw new Error(`Issue ${issueId} is not claimed by ${this.formatClaimant(claimant)}`);
125
- }
126
- this.claims.delete(issueId);
127
- this.stealableInfo.delete(issueId);
128
- await this.saveClaims();
129
- this.emitEvent({
130
- type: 'issue:released',
131
- timestamp: new Date(),
132
- issueId,
133
- claimant,
212
+ };
213
+ ClaimService.prototype.release = function (issueId, claimant) {
214
+ return __awaiter(this, void 0, Promise, function () {
215
+ var claim;
216
+ return __generator(this, function (_a) {
217
+ switch (_a.label) {
218
+ case 0:
219
+ claim = this.claims.get(issueId);
220
+ if (!claim) {
221
+ throw new Error("Issue " + issueId + " is not claimed");
222
+ }
223
+ if (!this.isSameClaimant(claim.claimant, claimant)) {
224
+ throw new Error("Issue " + issueId + " is not claimed by " + this.formatClaimant(claimant));
225
+ }
226
+ this.claims["delete"](issueId);
227
+ this.stealableInfo["delete"](issueId);
228
+ return [4 /*yield*/, this.saveClaims()];
229
+ case 1:
230
+ _a.sent();
231
+ this.emitEvent({
232
+ type: 'issue:released',
233
+ timestamp: new Date(),
234
+ issueId: issueId,
235
+ claimant: claimant
236
+ });
237
+ return [2 /*return*/];
238
+ }
239
+ });
134
240
  });
135
- }
241
+ };
136
242
  // ==========================================================================
137
243
  // Handoffs
138
244
  // ==========================================================================
139
- async requestHandoff(issueId, from, to, reason) {
140
- const claim = this.claims.get(issueId);
141
- if (!claim) {
142
- throw new Error(`Issue ${issueId} is not claimed`);
143
- }
144
- if (!this.isSameClaimant(claim.claimant, from)) {
145
- throw new Error(`Issue ${issueId} is not claimed by ${this.formatClaimant(from)}`);
146
- }
147
- claim.status = 'handoff-pending';
148
- claim.statusChangedAt = new Date();
149
- claim.handoffTo = to;
150
- claim.handoffReason = reason;
151
- await this.saveClaims();
152
- this.emitEvent({
153
- type: 'issue:handoff:requested',
154
- timestamp: new Date(),
155
- issueId,
156
- claimant: from,
157
- data: { to, reason },
245
+ ClaimService.prototype.requestHandoff = function (issueId, from, to, reason) {
246
+ return __awaiter(this, void 0, Promise, function () {
247
+ var claim;
248
+ return __generator(this, function (_a) {
249
+ switch (_a.label) {
250
+ case 0:
251
+ claim = this.claims.get(issueId);
252
+ if (!claim) {
253
+ throw new Error("Issue " + issueId + " is not claimed");
254
+ }
255
+ if (!this.isSameClaimant(claim.claimant, from)) {
256
+ throw new Error("Issue " + issueId + " is not claimed by " + this.formatClaimant(from));
257
+ }
258
+ claim.status = 'handoff-pending';
259
+ claim.statusChangedAt = new Date();
260
+ claim.handoffTo = to;
261
+ claim.handoffReason = reason;
262
+ return [4 /*yield*/, this.saveClaims()];
263
+ case 1:
264
+ _a.sent();
265
+ this.emitEvent({
266
+ type: 'issue:handoff:requested',
267
+ timestamp: new Date(),
268
+ issueId: issueId,
269
+ claimant: from,
270
+ data: { to: to, reason: reason }
271
+ });
272
+ return [2 /*return*/];
273
+ }
274
+ });
158
275
  });
159
- }
160
- async acceptHandoff(issueId, claimant) {
161
- const claim = this.claims.get(issueId);
162
- if (!claim || claim.status !== 'handoff-pending') {
163
- throw new Error(`No pending handoff for issue ${issueId}`);
164
- }
165
- if (!claim.handoffTo || !this.isSameClaimant(claim.handoffTo, claimant)) {
166
- throw new Error(`Handoff not addressed to ${this.formatClaimant(claimant)}`);
167
- }
168
- const previousClaimant = claim.claimant;
169
- claim.claimant = claimant;
170
- claim.status = 'active';
171
- claim.statusChangedAt = new Date();
172
- delete claim.handoffTo;
173
- delete claim.handoffReason;
174
- await this.saveClaims();
175
- this.emitEvent({
176
- type: 'issue:handoff:accepted',
177
- timestamp: new Date(),
178
- issueId,
179
- claimant,
180
- previousClaimant,
276
+ };
277
+ ClaimService.prototype.acceptHandoff = function (issueId, claimant) {
278
+ return __awaiter(this, void 0, Promise, function () {
279
+ var claim, previousClaimant;
280
+ return __generator(this, function (_a) {
281
+ switch (_a.label) {
282
+ case 0:
283
+ claim = this.claims.get(issueId);
284
+ if (!claim || claim.status !== 'handoff-pending') {
285
+ throw new Error("No pending handoff for issue " + issueId);
286
+ }
287
+ if (!claim.handoffTo || !this.isSameClaimant(claim.handoffTo, claimant)) {
288
+ throw new Error("Handoff not addressed to " + this.formatClaimant(claimant));
289
+ }
290
+ previousClaimant = claim.claimant;
291
+ claim.claimant = claimant;
292
+ claim.status = 'active';
293
+ claim.statusChangedAt = new Date();
294
+ delete claim.handoffTo;
295
+ delete claim.handoffReason;
296
+ return [4 /*yield*/, this.saveClaims()];
297
+ case 1:
298
+ _a.sent();
299
+ this.emitEvent({
300
+ type: 'issue:handoff:accepted',
301
+ timestamp: new Date(),
302
+ issueId: issueId,
303
+ claimant: claimant,
304
+ previousClaimant: previousClaimant
305
+ });
306
+ return [2 /*return*/];
307
+ }
308
+ });
181
309
  });
182
- }
183
- async rejectHandoff(issueId, claimant, reason) {
184
- const claim = this.claims.get(issueId);
185
- if (!claim || claim.status !== 'handoff-pending') {
186
- throw new Error(`No pending handoff for issue ${issueId}`);
187
- }
188
- if (!claim.handoffTo || !this.isSameClaimant(claim.handoffTo, claimant)) {
189
- throw new Error(`Handoff not addressed to ${this.formatClaimant(claimant)}`);
190
- }
191
- claim.status = 'active';
192
- claim.statusChangedAt = new Date();
193
- delete claim.handoffTo;
194
- delete claim.handoffReason;
195
- await this.saveClaims();
196
- this.emitEvent({
197
- type: 'issue:handoff:rejected',
198
- timestamp: new Date(),
199
- issueId,
200
- claimant,
201
- data: { reason },
310
+ };
311
+ ClaimService.prototype.rejectHandoff = function (issueId, claimant, reason) {
312
+ return __awaiter(this, void 0, Promise, function () {
313
+ var claim;
314
+ return __generator(this, function (_a) {
315
+ switch (_a.label) {
316
+ case 0:
317
+ claim = this.claims.get(issueId);
318
+ if (!claim || claim.status !== 'handoff-pending') {
319
+ throw new Error("No pending handoff for issue " + issueId);
320
+ }
321
+ if (!claim.handoffTo || !this.isSameClaimant(claim.handoffTo, claimant)) {
322
+ throw new Error("Handoff not addressed to " + this.formatClaimant(claimant));
323
+ }
324
+ claim.status = 'active';
325
+ claim.statusChangedAt = new Date();
326
+ delete claim.handoffTo;
327
+ delete claim.handoffReason;
328
+ return [4 /*yield*/, this.saveClaims()];
329
+ case 1:
330
+ _a.sent();
331
+ this.emitEvent({
332
+ type: 'issue:handoff:rejected',
333
+ timestamp: new Date(),
334
+ issueId: issueId,
335
+ claimant: claimant,
336
+ data: { reason: reason }
337
+ });
338
+ return [2 /*return*/];
339
+ }
340
+ });
202
341
  });
203
- }
342
+ };
204
343
  // ==========================================================================
205
344
  // Status Updates
206
345
  // ==========================================================================
207
- async updateStatus(issueId, status, note) {
208
- const claim = this.claims.get(issueId);
209
- if (!claim) {
210
- throw new Error(`Issue ${issueId} is not claimed`);
211
- }
212
- const previousStatus = claim.status;
213
- claim.status = status;
214
- claim.statusChangedAt = new Date();
215
- if (status === 'blocked' && note) {
216
- claim.blockReason = note;
217
- }
218
- if (status === 'completed') {
219
- claim.progress = 100;
220
- }
221
- await this.saveClaims();
222
- this.emitEvent({
223
- type: 'issue:status:changed',
224
- timestamp: new Date(),
225
- issueId,
226
- data: { previousStatus, newStatus: status, note },
346
+ ClaimService.prototype.updateStatus = function (issueId, status, note) {
347
+ return __awaiter(this, void 0, Promise, function () {
348
+ var claim, previousStatus;
349
+ return __generator(this, function (_a) {
350
+ switch (_a.label) {
351
+ case 0:
352
+ claim = this.claims.get(issueId);
353
+ if (!claim) {
354
+ throw new Error("Issue " + issueId + " is not claimed");
355
+ }
356
+ previousStatus = claim.status;
357
+ claim.status = status;
358
+ claim.statusChangedAt = new Date();
359
+ if (status === 'blocked' && note) {
360
+ claim.blockReason = note;
361
+ }
362
+ if (status === 'completed') {
363
+ claim.progress = 100;
364
+ }
365
+ return [4 /*yield*/, this.saveClaims()];
366
+ case 1:
367
+ _a.sent();
368
+ this.emitEvent({
369
+ type: 'issue:status:changed',
370
+ timestamp: new Date(),
371
+ issueId: issueId,
372
+ data: { previousStatus: previousStatus, newStatus: status, note: note }
373
+ });
374
+ return [2 /*return*/];
375
+ }
376
+ });
227
377
  });
228
- }
229
- async updateProgress(issueId, progress) {
230
- const claim = this.claims.get(issueId);
231
- if (!claim) {
232
- throw new Error(`Issue ${issueId} is not claimed`);
233
- }
234
- claim.progress = Math.min(100, Math.max(0, progress));
235
- await this.saveClaims();
236
- }
237
- async requestReview(issueId, reviewers) {
238
- const claim = this.claims.get(issueId);
239
- if (!claim) {
240
- throw new Error(`Issue ${issueId} is not claimed`);
241
- }
242
- claim.status = 'review-requested';
243
- claim.statusChangedAt = new Date();
244
- await this.saveClaims();
245
- this.emitEvent({
246
- type: 'issue:review:requested',
247
- timestamp: new Date(),
248
- issueId,
249
- claimant: claim.claimant,
250
- data: { reviewers },
378
+ };
379
+ ClaimService.prototype.updateProgress = function (issueId, progress) {
380
+ return __awaiter(this, void 0, Promise, function () {
381
+ var claim;
382
+ return __generator(this, function (_a) {
383
+ switch (_a.label) {
384
+ case 0:
385
+ claim = this.claims.get(issueId);
386
+ if (!claim) {
387
+ throw new Error("Issue " + issueId + " is not claimed");
388
+ }
389
+ claim.progress = Math.min(100, Math.max(0, progress));
390
+ return [4 /*yield*/, this.saveClaims()];
391
+ case 1:
392
+ _a.sent();
393
+ return [2 /*return*/];
394
+ }
395
+ });
251
396
  });
252
- }
397
+ };
398
+ ClaimService.prototype.requestReview = function (issueId, reviewers) {
399
+ return __awaiter(this, void 0, Promise, function () {
400
+ var claim;
401
+ return __generator(this, function (_a) {
402
+ switch (_a.label) {
403
+ case 0:
404
+ claim = this.claims.get(issueId);
405
+ if (!claim) {
406
+ throw new Error("Issue " + issueId + " is not claimed");
407
+ }
408
+ claim.status = 'review-requested';
409
+ claim.statusChangedAt = new Date();
410
+ return [4 /*yield*/, this.saveClaims()];
411
+ case 1:
412
+ _a.sent();
413
+ this.emitEvent({
414
+ type: 'issue:review:requested',
415
+ timestamp: new Date(),
416
+ issueId: issueId,
417
+ claimant: claim.claimant,
418
+ data: { reviewers: reviewers }
419
+ });
420
+ return [2 /*return*/];
421
+ }
422
+ });
423
+ });
424
+ };
253
425
  // ==========================================================================
254
426
  // Work Stealing
255
427
  // ==========================================================================
256
- async markStealable(issueId, info) {
257
- const claim = this.claims.get(issueId);
258
- if (!claim) {
259
- throw new Error(`Issue ${issueId} is not claimed`);
260
- }
261
- claim.status = 'stealable';
262
- claim.statusChangedAt = new Date();
263
- claim.context = info.context;
264
- claim.progress = info.progress;
265
- this.stealableInfo.set(issueId, info);
266
- await this.saveClaims();
267
- this.emitEvent({
268
- type: 'issue:stealable',
269
- timestamp: new Date(),
270
- issueId,
271
- claimant: claim.claimant,
272
- data: { info },
428
+ ClaimService.prototype.markStealable = function (issueId, info) {
429
+ return __awaiter(this, void 0, Promise, function () {
430
+ var claim;
431
+ return __generator(this, function (_a) {
432
+ switch (_a.label) {
433
+ case 0:
434
+ claim = this.claims.get(issueId);
435
+ if (!claim) {
436
+ throw new Error("Issue " + issueId + " is not claimed");
437
+ }
438
+ claim.status = 'stealable';
439
+ claim.statusChangedAt = new Date();
440
+ claim.context = info.context;
441
+ claim.progress = info.progress;
442
+ this.stealableInfo.set(issueId, info);
443
+ return [4 /*yield*/, this.saveClaims()];
444
+ case 1:
445
+ _a.sent();
446
+ this.emitEvent({
447
+ type: 'issue:stealable',
448
+ timestamp: new Date(),
449
+ issueId: issueId,
450
+ claimant: claim.claimant,
451
+ data: { info: info }
452
+ });
453
+ return [2 /*return*/];
454
+ }
455
+ });
273
456
  });
274
- }
275
- async steal(issueId, stealer) {
276
- const claim = this.claims.get(issueId);
277
- if (!claim) {
278
- return { success: false, error: `Issue ${issueId} is not claimed` };
279
- }
280
- if (claim.status !== 'stealable') {
281
- return { success: false, error: `Issue ${issueId} is not stealable` };
282
- }
283
- const info = this.stealableInfo.get(issueId);
284
- const previousOwner = claim.claimant;
285
- // Check if steal is allowed
286
- if (this.config.requireSameType && stealer.type === 'agent' && previousOwner.type === 'agent') {
287
- if (stealer.agentType !== previousOwner.agentType) {
288
- const allowed = this.config.allowCrossTypeSteal.some(pair => pair.includes(stealer.agentType) && pair.includes(previousOwner.agentType));
289
- if (!allowed) {
290
- return { success: false, error: `Cross-type steal not allowed` };
457
+ };
458
+ ClaimService.prototype.steal = function (issueId, stealer) {
459
+ return __awaiter(this, void 0, Promise, function () {
460
+ var claim, info, previousOwner, allowed;
461
+ return __generator(this, function (_a) {
462
+ switch (_a.label) {
463
+ case 0:
464
+ claim = this.claims.get(issueId);
465
+ if (!claim) {
466
+ return [2 /*return*/, { success: false, error: "Issue " + issueId + " is not claimed" }];
467
+ }
468
+ if (claim.status !== 'stealable') {
469
+ return [2 /*return*/, { success: false, error: "Issue " + issueId + " is not stealable" }];
470
+ }
471
+ info = this.stealableInfo.get(issueId);
472
+ previousOwner = claim.claimant;
473
+ // Check if steal is allowed
474
+ if (this.config.requireSameType && stealer.type === 'agent' && previousOwner.type === 'agent') {
475
+ if (stealer.agentType !== previousOwner.agentType) {
476
+ allowed = this.config.allowCrossTypeSteal.some(function (pair) { return pair.includes(stealer.agentType) && pair.includes(previousOwner.agentType); });
477
+ if (!allowed) {
478
+ return [2 /*return*/, { success: false, error: "Cross-type steal not allowed" }];
479
+ }
480
+ }
481
+ }
482
+ // Execute steal
483
+ claim.claimant = stealer;
484
+ claim.status = 'active';
485
+ claim.statusChangedAt = new Date();
486
+ claim.claimedAt = new Date();
487
+ this.stealableInfo["delete"](issueId);
488
+ return [4 /*yield*/, this.saveClaims()];
489
+ case 1:
490
+ _a.sent();
491
+ this.emitEvent({
492
+ type: 'issue:stolen',
493
+ timestamp: new Date(),
494
+ issueId: issueId,
495
+ claimant: stealer,
496
+ previousClaimant: previousOwner,
497
+ data: { context: info }
498
+ });
499
+ return [2 /*return*/, { success: true, claim: claim, previousOwner: previousOwner, context: info }];
291
500
  }
292
- }
293
- }
294
- // Execute steal
295
- claim.claimant = stealer;
296
- claim.status = 'active';
297
- claim.statusChangedAt = new Date();
298
- claim.claimedAt = new Date();
299
- this.stealableInfo.delete(issueId);
300
- await this.saveClaims();
301
- this.emitEvent({
302
- type: 'issue:stolen',
303
- timestamp: new Date(),
304
- issueId,
305
- claimant: stealer,
306
- previousClaimant: previousOwner,
307
- data: { context: info },
501
+ });
308
502
  });
309
- return { success: true, claim, previousOwner, context: info };
310
- }
311
- async getStealable(agentType) {
312
- const stealable = [];
313
- for (const claim of this.claims.values()) {
314
- if (claim.status !== 'stealable')
315
- continue;
316
- const info = this.stealableInfo.get(claim.issueId);
317
- if (agentType && info?.preferredTypes?.length) {
318
- if (!info.preferredTypes.includes(agentType))
319
- continue;
320
- }
321
- stealable.push(claim);
322
- }
323
- return stealable;
324
- }
325
- async contestSteal(issueId, originalClaimant, reason) {
326
- const claim = this.claims.get(issueId);
327
- if (!claim) {
328
- throw new Error(`Issue ${issueId} is not claimed`);
329
- }
330
- this.emitEvent({
331
- type: 'issue:steal:contested',
332
- timestamp: new Date(),
333
- issueId,
334
- claimant: originalClaimant,
335
- data: { reason, currentOwner: claim.claimant },
503
+ };
504
+ ClaimService.prototype.getStealable = function (agentType) {
505
+ var _a;
506
+ return __awaiter(this, void 0, Promise, function () {
507
+ var stealable, _i, _b, claim, info;
508
+ return __generator(this, function (_c) {
509
+ stealable = [];
510
+ for (_i = 0, _b = this.claims.values(); _i < _b.length; _i++) {
511
+ claim = _b[_i];
512
+ if (claim.status !== 'stealable')
513
+ continue;
514
+ info = this.stealableInfo.get(claim.issueId);
515
+ if (agentType && ((_a = info === null || info === void 0 ? void 0 : info.preferredTypes) === null || _a === void 0 ? void 0 : _a.length)) {
516
+ if (!info.preferredTypes.includes(agentType))
517
+ continue;
518
+ }
519
+ stealable.push(claim);
520
+ }
521
+ return [2 /*return*/, stealable];
522
+ });
336
523
  });
337
- // Contest resolution would typically be handled by a coordinator or human
338
- }
524
+ };
525
+ ClaimService.prototype.contestSteal = function (issueId, originalClaimant, reason) {
526
+ return __awaiter(this, void 0, Promise, function () {
527
+ var claim;
528
+ return __generator(this, function (_a) {
529
+ claim = this.claims.get(issueId);
530
+ if (!claim) {
531
+ throw new Error("Issue " + issueId + " is not claimed");
532
+ }
533
+ this.emitEvent({
534
+ type: 'issue:steal:contested',
535
+ timestamp: new Date(),
536
+ issueId: issueId,
537
+ claimant: originalClaimant,
538
+ data: { reason: reason, currentOwner: claim.claimant }
539
+ });
540
+ return [2 /*return*/];
541
+ });
542
+ });
543
+ };
339
544
  // ==========================================================================
340
545
  // Load Balancing
341
546
  // ==========================================================================
342
- async getAgentLoad(agentId) {
343
- const claims = [];
344
- let blockedCount = 0;
345
- for (const claim of this.claims.values()) {
346
- if (claim.claimant.type === 'agent' && claim.claimant.agentId === agentId) {
347
- claims.push(claim);
348
- if (claim.status === 'blocked')
349
- blockedCount++;
350
- }
351
- }
352
- const agentType = claims[0]?.claimant.type === 'agent' ? claims[0].claimant.agentType : 'unknown';
353
- return {
354
- agentId,
355
- agentType,
356
- claimCount: claims.length,
357
- maxClaims: this.config.overloadThreshold,
358
- utilization: claims.length / this.config.overloadThreshold,
359
- claims,
360
- avgCompletionTime: 0, // Would need historical data
361
- currentBlockedCount: blockedCount,
362
- };
363
- }
364
- async rebalance(swarmId) {
365
- const result = { moved: [], suggested: [] };
366
- // Get all agent loads
367
- const agentLoads = new Map();
368
- const agentTypes = new Set();
369
- for (const claim of this.claims.values()) {
370
- if (claim.claimant.type !== 'agent')
371
- continue;
372
- const agentId = claim.claimant.agentId;
373
- if (!agentLoads.has(agentId)) {
374
- const load = await this.getAgentLoad(agentId);
375
- agentLoads.set(agentId, load);
376
- agentTypes.add(load.agentType);
377
- }
378
- }
379
- // For each agent type, calculate average load
380
- for (const agentType of agentTypes) {
381
- const typeLoads = Array.from(agentLoads.values()).filter(l => l.agentType === agentType);
382
- const avgLoad = typeLoads.reduce((sum, l) => sum + l.utilization, 0) / typeLoads.length;
383
- const overloaded = typeLoads.filter(l => l.utilization > avgLoad * 1.5);
384
- const underloaded = typeLoads.filter(l => l.utilization < avgLoad * 0.5);
385
- // Generate suggestions
386
- for (const over of overloaded) {
387
- const lowProgressClaims = over.claims
388
- .filter(c => c.progress < 25)
389
- .sort((a, b) => a.progress - b.progress);
390
- for (const claim of lowProgressClaims) {
391
- const target = underloaded.find(u => u.claimCount < u.maxClaims);
392
- if (target) {
393
- result.suggested.push({
394
- issueId: claim.issueId,
395
- currentOwner: claim.claimant,
396
- suggestedOwner: {
397
- type: 'agent',
398
- agentId: target.agentId,
399
- agentType: target.agentType,
400
- },
401
- reason: 'Load balancing: redistributing work across swarm',
402
- });
547
+ ClaimService.prototype.getAgentLoad = function (agentId) {
548
+ var _a;
549
+ return __awaiter(this, void 0, Promise, function () {
550
+ var claims, blockedCount, _i, _b, claim, agentType;
551
+ return __generator(this, function (_c) {
552
+ claims = [];
553
+ blockedCount = 0;
554
+ for (_i = 0, _b = this.claims.values(); _i < _b.length; _i++) {
555
+ claim = _b[_i];
556
+ if (claim.claimant.type === 'agent' && claim.claimant.agentId === agentId) {
557
+ claims.push(claim);
558
+ if (claim.status === 'blocked')
559
+ blockedCount++;
403
560
  }
404
561
  }
405
- }
406
- }
407
- return result;
408
- }
562
+ agentType = ((_a = claims[0]) === null || _a === void 0 ? void 0 : _a.claimant.type) === 'agent' ? claims[0].claimant.agentType : 'unknown';
563
+ return [2 /*return*/, {
564
+ agentId: agentId,
565
+ agentType: agentType,
566
+ claimCount: claims.length,
567
+ maxClaims: this.config.overloadThreshold,
568
+ utilization: claims.length / this.config.overloadThreshold,
569
+ claims: claims,
570
+ avgCompletionTime: 0,
571
+ currentBlockedCount: blockedCount
572
+ }];
573
+ });
574
+ });
575
+ };
576
+ ClaimService.prototype.rebalance = function (swarmId) {
577
+ return __awaiter(this, void 0, Promise, function () {
578
+ var result, agentLoads, agentTypes, _i, _a, claim, agentId, load, _loop_1, _b, agentTypes_1, agentType;
579
+ return __generator(this, function (_c) {
580
+ switch (_c.label) {
581
+ case 0:
582
+ result = { moved: [], suggested: [] };
583
+ agentLoads = new Map();
584
+ agentTypes = new Set();
585
+ _i = 0, _a = this.claims.values();
586
+ _c.label = 1;
587
+ case 1:
588
+ if (!(_i < _a.length)) return [3 /*break*/, 4];
589
+ claim = _a[_i];
590
+ if (claim.claimant.type !== 'agent')
591
+ return [3 /*break*/, 3];
592
+ agentId = claim.claimant.agentId;
593
+ if (!!agentLoads.has(agentId)) return [3 /*break*/, 3];
594
+ return [4 /*yield*/, this.getAgentLoad(agentId)];
595
+ case 2:
596
+ load = _c.sent();
597
+ agentLoads.set(agentId, load);
598
+ agentTypes.add(load.agentType);
599
+ _c.label = 3;
600
+ case 3:
601
+ _i++;
602
+ return [3 /*break*/, 1];
603
+ case 4:
604
+ _loop_1 = function (agentType) {
605
+ var typeLoads = Array.from(agentLoads.values()).filter(function (l) { return l.agentType === agentType; });
606
+ var avgLoad = typeLoads.reduce(function (sum, l) { return sum + l.utilization; }, 0) / typeLoads.length;
607
+ var overloaded = typeLoads.filter(function (l) { return l.utilization > avgLoad * 1.5; });
608
+ var underloaded = typeLoads.filter(function (l) { return l.utilization < avgLoad * 0.5; });
609
+ // Generate suggestions
610
+ for (var _d = 0, overloaded_1 = overloaded; _d < overloaded_1.length; _d++) {
611
+ var over = overloaded_1[_d];
612
+ var lowProgressClaims = over.claims
613
+ .filter(function (c) { return c.progress < 25; })
614
+ .sort(function (a, b) { return a.progress - b.progress; });
615
+ for (var _e = 0, lowProgressClaims_1 = lowProgressClaims; _e < lowProgressClaims_1.length; _e++) {
616
+ var claim = lowProgressClaims_1[_e];
617
+ var target = underloaded.find(function (u) { return u.claimCount < u.maxClaims; });
618
+ if (target) {
619
+ result.suggested.push({
620
+ issueId: claim.issueId,
621
+ currentOwner: claim.claimant,
622
+ suggestedOwner: {
623
+ type: 'agent',
624
+ agentId: target.agentId,
625
+ agentType: target.agentType
626
+ },
627
+ reason: 'Load balancing: redistributing work across swarm'
628
+ });
629
+ }
630
+ }
631
+ }
632
+ };
633
+ // For each agent type, calculate average load
634
+ for (_b = 0, agentTypes_1 = agentTypes; _b < agentTypes_1.length; _b++) {
635
+ agentType = agentTypes_1[_b];
636
+ _loop_1(agentType);
637
+ }
638
+ return [2 /*return*/, result];
639
+ }
640
+ });
641
+ });
642
+ };
409
643
  // ==========================================================================
410
644
  // Queries
411
645
  // ==========================================================================
412
- async getClaimedBy(claimant) {
413
- return Array.from(this.claims.values()).filter(c => this.isSameClaimant(c.claimant, claimant));
414
- }
415
- async getAvailableIssues(_filters) {
416
- // This would integrate with GitHub API
417
- // For now, return issues that are not claimed
418
- return [];
419
- }
420
- async getIssueStatus(issueId) {
421
- return this.claims.get(issueId) || null;
422
- }
423
- async getAllClaims() {
424
- return Array.from(this.claims.values());
425
- }
426
- async getByStatus(status) {
427
- return Array.from(this.claims.values()).filter(c => c.status === status);
428
- }
646
+ ClaimService.prototype.getClaimedBy = function (claimant) {
647
+ return __awaiter(this, void 0, Promise, function () {
648
+ var _this = this;
649
+ return __generator(this, function (_a) {
650
+ return [2 /*return*/, Array.from(this.claims.values()).filter(function (c) {
651
+ return _this.isSameClaimant(c.claimant, claimant);
652
+ })];
653
+ });
654
+ });
655
+ };
656
+ ClaimService.prototype.getAvailableIssues = function (_filters) {
657
+ return __awaiter(this, void 0, Promise, function () {
658
+ return __generator(this, function (_a) {
659
+ // This would integrate with GitHub API
660
+ // For now, return issues that are not claimed
661
+ return [2 /*return*/, []];
662
+ });
663
+ });
664
+ };
665
+ ClaimService.prototype.getIssueStatus = function (issueId) {
666
+ return __awaiter(this, void 0, Promise, function () {
667
+ return __generator(this, function (_a) {
668
+ return [2 /*return*/, this.claims.get(issueId) || null];
669
+ });
670
+ });
671
+ };
672
+ ClaimService.prototype.getAllClaims = function () {
673
+ return __awaiter(this, void 0, Promise, function () {
674
+ return __generator(this, function (_a) {
675
+ return [2 /*return*/, Array.from(this.claims.values())];
676
+ });
677
+ });
678
+ };
679
+ ClaimService.prototype.getByStatus = function (status) {
680
+ return __awaiter(this, void 0, Promise, function () {
681
+ return __generator(this, function (_a) {
682
+ return [2 /*return*/, Array.from(this.claims.values()).filter(function (c) { return c.status === status; })];
683
+ });
684
+ });
685
+ };
429
686
  // ==========================================================================
430
687
  // Auto-Management
431
688
  // ==========================================================================
432
- async expireStale(maxAgeMinutes) {
433
- const threshold = maxAgeMinutes ?? this.config.staleThresholdMinutes;
434
- const now = Date.now();
435
- const expired = [];
436
- for (const claim of this.claims.values()) {
437
- if (claim.status === 'stealable' || claim.status === 'completed')
438
- continue;
439
- const age = (now - claim.statusChangedAt.getTime()) / 60000;
440
- if (age > threshold) {
441
- // Mark as stealable
442
- await this.markStealable(claim.issueId, {
443
- reason: 'stale',
444
- stealableAt: new Date(),
445
- progress: claim.progress,
446
- context: `Stale: No activity for ${Math.round(age)} minutes`,
447
- });
448
- expired.push(claim);
449
- }
450
- }
451
- return expired;
452
- }
689
+ ClaimService.prototype.expireStale = function (maxAgeMinutes) {
690
+ return __awaiter(this, void 0, Promise, function () {
691
+ var threshold, now, expired, _i, _a, claim, age;
692
+ return __generator(this, function (_b) {
693
+ switch (_b.label) {
694
+ case 0:
695
+ threshold = maxAgeMinutes !== null && maxAgeMinutes !== void 0 ? maxAgeMinutes : this.config.staleThresholdMinutes;
696
+ now = Date.now();
697
+ expired = [];
698
+ _i = 0, _a = this.claims.values();
699
+ _b.label = 1;
700
+ case 1:
701
+ if (!(_i < _a.length)) return [3 /*break*/, 4];
702
+ claim = _a[_i];
703
+ if (claim.status === 'stealable' || claim.status === 'completed')
704
+ return [3 /*break*/, 3];
705
+ age = (now - claim.statusChangedAt.getTime()) / 60000;
706
+ if (!(age > threshold)) return [3 /*break*/, 3];
707
+ // Mark as stealable
708
+ return [4 /*yield*/, this.markStealable(claim.issueId, {
709
+ reason: 'stale',
710
+ stealableAt: new Date(),
711
+ progress: claim.progress,
712
+ context: "Stale: No activity for " + Math.round(age) + " minutes"
713
+ })];
714
+ case 2:
715
+ // Mark as stealable
716
+ _b.sent();
717
+ expired.push(claim);
718
+ _b.label = 3;
719
+ case 3:
720
+ _i++;
721
+ return [3 /*break*/, 1];
722
+ case 4: return [2 /*return*/, expired];
723
+ }
724
+ });
725
+ });
726
+ };
453
727
  // ==========================================================================
454
728
  // Helpers
455
729
  // ==========================================================================
456
- formatClaimant(claimant) {
730
+ ClaimService.prototype.formatClaimant = function (claimant) {
457
731
  return claimant.type === 'human'
458
- ? `human:${claimant.name}`
459
- : `agent:${claimant.agentType}:${claimant.agentId}`;
460
- }
461
- isSameClaimant(a, b) {
732
+ ? "human:" + claimant.name
733
+ : "agent:" + claimant.agentType + ":" + claimant.agentId;
734
+ };
735
+ ClaimService.prototype.isSameClaimant = function (a, b) {
462
736
  if (a.type !== b.type)
463
737
  return false;
464
738
  if (a.type === 'human' && b.type === 'human') {
@@ -468,28 +742,31 @@ export class ClaimService extends EventEmitter {
468
742
  return a.agentId === b.agentId;
469
743
  }
470
744
  return false;
471
- }
472
- emitEvent(event) {
745
+ };
746
+ ClaimService.prototype.emitEvent = function (event) {
473
747
  this.eventLog.push(event);
474
748
  if (this.eventLog.length > 1000) {
475
749
  this.eventLog = this.eventLog.slice(-500);
476
750
  }
477
751
  this.emit(event.type, event);
478
- }
479
- getEventLog(limit = 100) {
752
+ };
753
+ ClaimService.prototype.getEventLog = function (limit) {
754
+ if (limit === void 0) { limit = 100; }
480
755
  return this.eventLog.slice(-limit);
481
- }
482
- }
756
+ };
757
+ return ClaimService;
758
+ }(EventEmitter));
759
+ export { ClaimService };
483
760
  // ============================================================================
484
761
  // GitHub Sync Implementation
485
762
  // ============================================================================
486
- const DEFAULT_GITHUB_CONFIG = {
763
+ var DEFAULT_GITHUB_CONFIG = {
487
764
  enabled: false,
488
765
  syncLabels: true,
489
766
  claimLabel: 'claimed',
490
767
  autoAssign: true,
491
768
  commentOnClaim: true,
492
- commentOnRelease: true,
769
+ commentOnRelease: true
493
770
  };
494
771
  // ============================================================================
495
772
  // Input Validation (Security)
@@ -528,283 +805,331 @@ function isValidLabel(label) {
528
805
  * Sanitize error messages to prevent information disclosure
529
806
  */
530
807
  function sanitizeError(error) {
531
- const msg = error.message || 'Unknown error';
808
+ var msg = error.message || 'Unknown error';
532
809
  // Remove paths and sensitive details
533
810
  return msg.replace(/\/[\w./-]+/g, '[path]').substring(0, 200);
534
811
  }
535
- export class GitHubSync {
536
- config;
537
- claimService;
538
- constructor(claimService, config) {
812
+ var GitHubSync = /** @class */ (function () {
813
+ function GitHubSync(claimService, config) {
539
814
  this.claimService = claimService;
540
- this.config = { ...DEFAULT_GITHUB_CONFIG, ...config };
815
+ this.config = __assign(__assign({}, DEFAULT_GITHUB_CONFIG), config);
541
816
  }
542
817
  /**
543
818
  * Check if GitHub CLI is available
544
819
  */
545
- isGhAvailable() {
820
+ GitHubSync.prototype.isGhAvailable = function () {
546
821
  try {
547
822
  execFileSync('gh', ['--version'], { stdio: 'ignore' });
548
823
  return true;
549
824
  }
550
- catch {
825
+ catch (_a) {
551
826
  return false;
552
827
  }
553
- }
828
+ };
554
829
  /**
555
830
  * Get the current repository from git remote
556
831
  */
557
- getRepo() {
832
+ GitHubSync.prototype.getRepo = function () {
558
833
  if (this.config.repo) {
559
834
  return isValidRepo(this.config.repo) ? this.config.repo : null;
560
835
  }
561
836
  try {
562
- const remote = execFileSync('git', ['remote', 'get-url', 'origin'], { encoding: 'utf-8' }).trim();
563
- const match = remote.match(/github\.com[/:]([\w.-]+\/[\w.-]+)/);
564
- const repo = match ? match[1].replace('.git', '') : null;
837
+ var remote = execFileSync('git', ['remote', 'get-url', 'origin'], { encoding: 'utf-8' }).trim();
838
+ var match = remote.match(/github\.com[/:]([\w.-]+\/[\w.-]+)/);
839
+ var repo = match ? match[1].replace('.git', '') : null;
565
840
  return repo && isValidRepo(repo) ? repo : null;
566
841
  }
567
- catch {
842
+ catch (_a) {
568
843
  return null;
569
844
  }
570
- }
845
+ };
571
846
  /**
572
847
  * Sync issues from GitHub
573
848
  */
574
- async syncIssues(state = 'open') {
575
- const errors = [];
576
- const issues = [];
577
- if (!this.isGhAvailable()) {
578
- return { success: false, synced: 0, errors: ['GitHub CLI (gh) not installed'] };
579
- }
580
- const repo = this.getRepo();
581
- if (!repo) {
582
- return { success: false, synced: 0, errors: ['Could not determine GitHub repository'] };
583
- }
584
- // Validate state parameter (whitelist)
585
- const validStates = ['open', 'closed', 'all'];
586
- if (!validStates.includes(state)) {
587
- return { success: false, synced: 0, errors: ['Invalid state parameter'] };
588
- }
589
- try {
590
- const issuesJson = execFileSync('gh', [
591
- 'issue', 'list',
592
- '--repo', repo,
593
- '--state', state,
594
- '--json', 'number,title,body,state,labels,assignees,url,createdAt,updatedAt',
595
- '--limit', '100'
596
- ], { encoding: 'utf-8' });
597
- const rawIssues = JSON.parse(issuesJson);
598
- for (const raw of rawIssues) {
599
- issues.push({
600
- number: raw.number,
601
- title: raw.title,
602
- body: raw.body || '',
603
- state: raw.state === 'OPEN' ? 'open' : 'closed',
604
- labels: raw.labels?.map((l) => l.name) || [],
605
- assignees: raw.assignees?.map((a) => a.login) || [],
606
- url: raw.url,
607
- createdAt: new Date(raw.createdAt),
608
- updatedAt: new Date(raw.updatedAt),
609
- });
610
- }
611
- return { success: true, synced: issues.length, errors, issues };
612
- }
613
- catch (error) {
614
- errors.push(`Failed to fetch issues: ${sanitizeError(error)}`);
615
- return { success: false, synced: 0, errors };
616
- }
617
- }
849
+ GitHubSync.prototype.syncIssues = function (state) {
850
+ var _a, _b;
851
+ if (state === void 0) { state = 'open'; }
852
+ return __awaiter(this, void 0, Promise, function () {
853
+ var errors, issues, repo, validStates, issuesJson, rawIssues, _i, rawIssues_1, raw;
854
+ return __generator(this, function (_c) {
855
+ errors = [];
856
+ issues = [];
857
+ if (!this.isGhAvailable()) {
858
+ return [2 /*return*/, { success: false, synced: 0, errors: ['GitHub CLI (gh) not installed'] }];
859
+ }
860
+ repo = this.getRepo();
861
+ if (!repo) {
862
+ return [2 /*return*/, { success: false, synced: 0, errors: ['Could not determine GitHub repository'] }];
863
+ }
864
+ validStates = ['open', 'closed', 'all'];
865
+ if (!validStates.includes(state)) {
866
+ return [2 /*return*/, { success: false, synced: 0, errors: ['Invalid state parameter'] }];
867
+ }
868
+ try {
869
+ issuesJson = execFileSync('gh', [
870
+ 'issue', 'list',
871
+ '--repo', repo,
872
+ '--state', state,
873
+ '--json', 'number,title,body,state,labels,assignees,url,createdAt,updatedAt',
874
+ '--limit', '100'
875
+ ], { encoding: 'utf-8' });
876
+ rawIssues = JSON.parse(issuesJson);
877
+ for (_i = 0, rawIssues_1 = rawIssues; _i < rawIssues_1.length; _i++) {
878
+ raw = rawIssues_1[_i];
879
+ issues.push({
880
+ number: raw.number,
881
+ title: raw.title,
882
+ body: raw.body || '',
883
+ state: raw.state === 'OPEN' ? 'open' : 'closed',
884
+ labels: ((_a = raw.labels) === null || _a === void 0 ? void 0 : _a.map(function (l) { return l.name; })) || [],
885
+ assignees: ((_b = raw.assignees) === null || _b === void 0 ? void 0 : _b.map(function (a) { return a.login; })) || [],
886
+ url: raw.url,
887
+ createdAt: new Date(raw.createdAt),
888
+ updatedAt: new Date(raw.updatedAt)
889
+ });
890
+ }
891
+ return [2 /*return*/, { success: true, synced: issues.length, errors: errors, issues: issues }];
892
+ }
893
+ catch (error) {
894
+ errors.push("Failed to fetch issues: " + sanitizeError(error));
895
+ return [2 /*return*/, { success: false, synced: 0, errors: errors }];
896
+ }
897
+ return [2 /*return*/];
898
+ });
899
+ });
900
+ };
618
901
  /**
619
902
  * Sync a local claim to GitHub (add label/assignee/comment)
620
903
  */
621
- async claimOnGitHub(issueNumber, claimant) {
622
- const errors = [];
623
- if (!this.config.enabled) {
624
- return { success: true, synced: 0, errors: ['GitHub sync not enabled'] };
625
- }
626
- if (!this.isGhAvailable()) {
627
- return { success: false, synced: 0, errors: ['GitHub CLI (gh) not installed'] };
628
- }
629
- // Validate issue number
630
- if (!isValidIssueNumber(issueNumber)) {
631
- return { success: false, synced: 0, errors: ['Invalid issue number'] };
632
- }
633
- const repo = this.getRepo();
634
- if (!repo) {
635
- return { success: false, synced: 0, errors: ['Could not determine repository'] };
636
- }
637
- // Validate claim label
638
- if (!isValidLabel(this.config.claimLabel)) {
639
- return { success: false, synced: 0, errors: ['Invalid claim label configuration'] };
640
- }
641
- try {
642
- // Add claim label
643
- if (this.config.syncLabels) {
644
- try {
645
- execFileSync('gh', [
646
- 'issue', 'edit', String(issueNumber),
647
- '--repo', repo,
648
- '--add-label', this.config.claimLabel
649
- ], { stdio: 'ignore' });
904
+ GitHubSync.prototype.claimOnGitHub = function (issueNumber, claimant) {
905
+ return __awaiter(this, void 0, Promise, function () {
906
+ var errors, repo, claimantStr, comment;
907
+ return __generator(this, function (_a) {
908
+ errors = [];
909
+ if (!this.config.enabled) {
910
+ return [2 /*return*/, { success: true, synced: 0, errors: ['GitHub sync not enabled'] }];
650
911
  }
651
- catch {
652
- errors.push('Failed to add claim label (label may not exist)');
912
+ if (!this.isGhAvailable()) {
913
+ return [2 /*return*/, { success: false, synced: 0, errors: ['GitHub CLI (gh) not installed'] }];
653
914
  }
654
- }
655
- // Auto-assign if human claimant
656
- if (this.config.autoAssign && claimant.type === 'human') {
657
- if (!isValidClaimantName(claimant.name)) {
658
- errors.push('Invalid claimant name format');
915
+ // Validate issue number
916
+ if (!isValidIssueNumber(issueNumber)) {
917
+ return [2 /*return*/, { success: false, synced: 0, errors: ['Invalid issue number'] }];
659
918
  }
660
- else {
661
- try {
662
- execFileSync('gh', [
663
- 'issue', 'edit', String(issueNumber),
664
- '--repo', repo,
665
- '--add-assignee', claimant.name
666
- ], { stdio: 'ignore' });
667
- }
668
- catch {
669
- errors.push('Failed to assign issue');
670
- }
919
+ repo = this.getRepo();
920
+ if (!repo) {
921
+ return [2 /*return*/, { success: false, synced: 0, errors: ['Could not determine repository'] }];
922
+ }
923
+ // Validate claim label
924
+ if (!isValidLabel(this.config.claimLabel)) {
925
+ return [2 /*return*/, { success: false, synced: 0, errors: ['Invalid claim label configuration'] }];
671
926
  }
672
- }
673
- // Add comment
674
- if (this.config.commentOnClaim) {
675
- const claimantStr = claimant.type === 'human'
676
- ? `@${claimant.name.replace(/[^a-zA-Z0-9_-]/g, '')}`
677
- : `Agent: ${(claimant.agentType || 'unknown').replace(/[^a-zA-Z0-9_-]/g, '')}`;
678
- const comment = `🤖 **Issue claimed** by ${claimantStr}\n\n_Coordinated by KynjalFlow V3_`;
679
927
  try {
680
- execFileSync('gh', [
681
- 'issue', 'comment', String(issueNumber),
682
- '--repo', repo,
683
- '--body', comment
684
- ], { stdio: 'ignore' });
928
+ // Add claim label
929
+ if (this.config.syncLabels) {
930
+ try {
931
+ execFileSync('gh', [
932
+ 'issue', 'edit', String(issueNumber),
933
+ '--repo', repo,
934
+ '--add-label', this.config.claimLabel
935
+ ], { stdio: 'ignore' });
936
+ }
937
+ catch (_b) {
938
+ errors.push('Failed to add claim label (label may not exist)');
939
+ }
940
+ }
941
+ // Auto-assign if human claimant
942
+ if (this.config.autoAssign && claimant.type === 'human') {
943
+ if (!isValidClaimantName(claimant.name)) {
944
+ errors.push('Invalid claimant name format');
945
+ }
946
+ else {
947
+ try {
948
+ execFileSync('gh', [
949
+ 'issue', 'edit', String(issueNumber),
950
+ '--repo', repo,
951
+ '--add-assignee', claimant.name
952
+ ], { stdio: 'ignore' });
953
+ }
954
+ catch (_c) {
955
+ errors.push('Failed to assign issue');
956
+ }
957
+ }
958
+ }
959
+ // Add comment
960
+ if (this.config.commentOnClaim) {
961
+ claimantStr = claimant.type === 'human'
962
+ ? "@" + claimant.name.replace(/[^a-zA-Z0-9_-]/g, '')
963
+ : "Agent: " + (claimant.agentType || 'unknown').replace(/[^a-zA-Z0-9_-]/g, '');
964
+ comment = "\uD83E\uDD16 **Issue claimed** by " + claimantStr + "\n\n_Coordinated by RuFlo V3_";
965
+ try {
966
+ execFileSync('gh', [
967
+ 'issue', 'comment', String(issueNumber),
968
+ '--repo', repo,
969
+ '--body', comment
970
+ ], { stdio: 'ignore' });
971
+ }
972
+ catch (_d) {
973
+ errors.push('Failed to add comment');
974
+ }
975
+ }
976
+ return [2 /*return*/, { success: errors.length === 0, synced: 1, errors: errors }];
685
977
  }
686
- catch {
687
- errors.push('Failed to add comment');
978
+ catch (error) {
979
+ errors.push("GitHub sync failed: " + sanitizeError(error));
980
+ return [2 /*return*/, { success: false, synced: 0, errors: errors }];
688
981
  }
689
- }
690
- return { success: errors.length === 0, synced: 1, errors };
691
- }
692
- catch (error) {
693
- errors.push(`GitHub sync failed: ${sanitizeError(error)}`);
694
- return { success: false, synced: 0, errors };
695
- }
696
- }
982
+ return [2 /*return*/];
983
+ });
984
+ });
985
+ };
697
986
  /**
698
987
  * Release claim on GitHub (remove label/assignee/comment)
699
988
  */
700
- async releaseOnGitHub(issueNumber, claimant) {
701
- const errors = [];
702
- if (!this.config.enabled) {
703
- return { success: true, synced: 0, errors: ['GitHub sync not enabled'] };
704
- }
705
- if (!this.isGhAvailable()) {
706
- return { success: false, synced: 0, errors: ['GitHub CLI (gh) not installed'] };
707
- }
708
- // Validate issue number
709
- if (!isValidIssueNumber(issueNumber)) {
710
- return { success: false, synced: 0, errors: ['Invalid issue number'] };
711
- }
712
- const repo = this.getRepo();
713
- if (!repo) {
714
- return { success: false, synced: 0, errors: ['Could not determine repository'] };
715
- }
716
- // Validate claim label
717
- if (!isValidLabel(this.config.claimLabel)) {
718
- return { success: false, synced: 0, errors: ['Invalid claim label configuration'] };
719
- }
720
- try {
721
- // Remove claim label
722
- if (this.config.syncLabels) {
723
- try {
724
- execFileSync('gh', [
725
- 'issue', 'edit', String(issueNumber),
726
- '--repo', repo,
727
- '--remove-label', this.config.claimLabel
728
- ], { stdio: 'ignore' });
989
+ GitHubSync.prototype.releaseOnGitHub = function (issueNumber, claimant) {
990
+ return __awaiter(this, void 0, Promise, function () {
991
+ var errors, repo, claimantStr, comment;
992
+ return __generator(this, function (_a) {
993
+ errors = [];
994
+ if (!this.config.enabled) {
995
+ return [2 /*return*/, { success: true, synced: 0, errors: ['GitHub sync not enabled'] }];
729
996
  }
730
- catch {
731
- // Label might not exist
997
+ if (!this.isGhAvailable()) {
998
+ return [2 /*return*/, { success: false, synced: 0, errors: ['GitHub CLI (gh) not installed'] }];
732
999
  }
733
- }
734
- // Remove assignee if human claimant
735
- if (this.config.autoAssign && claimant.type === 'human') {
736
- if (isValidClaimantName(claimant.name)) {
737
- try {
738
- execFileSync('gh', [
739
- 'issue', 'edit', String(issueNumber),
740
- '--repo', repo,
741
- '--remove-assignee', claimant.name
742
- ], { stdio: 'ignore' });
743
- }
744
- catch {
745
- errors.push('Failed to remove assignee');
746
- }
1000
+ // Validate issue number
1001
+ if (!isValidIssueNumber(issueNumber)) {
1002
+ return [2 /*return*/, { success: false, synced: 0, errors: ['Invalid issue number'] }];
1003
+ }
1004
+ repo = this.getRepo();
1005
+ if (!repo) {
1006
+ return [2 /*return*/, { success: false, synced: 0, errors: ['Could not determine repository'] }];
1007
+ }
1008
+ // Validate claim label
1009
+ if (!isValidLabel(this.config.claimLabel)) {
1010
+ return [2 /*return*/, { success: false, synced: 0, errors: ['Invalid claim label configuration'] }];
747
1011
  }
748
- }
749
- // Add release comment
750
- if (this.config.commentOnRelease) {
751
- const claimantStr = claimant.type === 'human'
752
- ? `@${claimant.name.replace(/[^a-zA-Z0-9_-]/g, '')}`
753
- : `Agent: ${(claimant.agentType || 'unknown').replace(/[^a-zA-Z0-9_-]/g, '')}`;
754
- const comment = `🔓 **Issue released** by ${claimantStr}\n\n_This issue is now available for others to claim._`;
755
1012
  try {
756
- execFileSync('gh', [
757
- 'issue', 'comment', String(issueNumber),
758
- '--repo', repo,
759
- '--body', comment
760
- ], { stdio: 'ignore' });
1013
+ // Remove claim label
1014
+ if (this.config.syncLabels) {
1015
+ try {
1016
+ execFileSync('gh', [
1017
+ 'issue', 'edit', String(issueNumber),
1018
+ '--repo', repo,
1019
+ '--remove-label', this.config.claimLabel
1020
+ ], { stdio: 'ignore' });
1021
+ }
1022
+ catch (_b) {
1023
+ // Label might not exist
1024
+ }
1025
+ }
1026
+ // Remove assignee if human claimant
1027
+ if (this.config.autoAssign && claimant.type === 'human') {
1028
+ if (isValidClaimantName(claimant.name)) {
1029
+ try {
1030
+ execFileSync('gh', [
1031
+ 'issue', 'edit', String(issueNumber),
1032
+ '--repo', repo,
1033
+ '--remove-assignee', claimant.name
1034
+ ], { stdio: 'ignore' });
1035
+ }
1036
+ catch (_c) {
1037
+ errors.push('Failed to remove assignee');
1038
+ }
1039
+ }
1040
+ }
1041
+ // Add release comment
1042
+ if (this.config.commentOnRelease) {
1043
+ claimantStr = claimant.type === 'human'
1044
+ ? "@" + claimant.name.replace(/[^a-zA-Z0-9_-]/g, '')
1045
+ : "Agent: " + (claimant.agentType || 'unknown').replace(/[^a-zA-Z0-9_-]/g, '');
1046
+ comment = "\uD83D\uDD13 **Issue released** by " + claimantStr + "\n\n_This issue is now available for others to claim._";
1047
+ try {
1048
+ execFileSync('gh', [
1049
+ 'issue', 'comment', String(issueNumber),
1050
+ '--repo', repo,
1051
+ '--body', comment
1052
+ ], { stdio: 'ignore' });
1053
+ }
1054
+ catch (_d) {
1055
+ errors.push('Failed to add release comment');
1056
+ }
1057
+ }
1058
+ return [2 /*return*/, { success: errors.length === 0, synced: 1, errors: errors }];
761
1059
  }
762
- catch {
763
- errors.push('Failed to add release comment');
1060
+ catch (error) {
1061
+ errors.push("GitHub release sync failed: " + sanitizeError(error));
1062
+ return [2 /*return*/, { success: false, synced: 0, errors: errors }];
764
1063
  }
765
- }
766
- return { success: errors.length === 0, synced: 1, errors };
767
- }
768
- catch (error) {
769
- errors.push(`GitHub release sync failed: ${sanitizeError(error)}`);
770
- return { success: false, synced: 0, errors };
771
- }
772
- }
1064
+ return [2 /*return*/];
1065
+ });
1066
+ });
1067
+ };
773
1068
  /**
774
1069
  * Bulk sync all local claims to GitHub
775
1070
  */
776
- async syncAllClaimsToGitHub() {
777
- const errors = [];
778
- let synced = 0;
779
- const claims = await this.claimService.getAllClaims();
780
- for (const claim of claims) {
781
- // Extract issue number from issueId (assumes format like "123" or "issue-123")
782
- const issueMatch = claim.issueId.match(/(\d+)/);
783
- if (issueMatch) {
784
- const result = await this.claimOnGitHub(parseInt(issueMatch[1], 10), claim.claimant);
785
- if (result.success)
786
- synced++;
787
- else
788
- errors.push(...result.errors);
789
- }
790
- }
791
- return { success: errors.length === 0, synced, errors };
792
- }
1071
+ GitHubSync.prototype.syncAllClaimsToGitHub = function () {
1072
+ return __awaiter(this, void 0, Promise, function () {
1073
+ var errors, synced, claims, _i, claims_1, claim, issueMatch, result;
1074
+ return __generator(this, function (_a) {
1075
+ switch (_a.label) {
1076
+ case 0:
1077
+ errors = [];
1078
+ synced = 0;
1079
+ return [4 /*yield*/, this.claimService.getAllClaims()];
1080
+ case 1:
1081
+ claims = _a.sent();
1082
+ _i = 0, claims_1 = claims;
1083
+ _a.label = 2;
1084
+ case 2:
1085
+ if (!(_i < claims_1.length)) return [3 /*break*/, 5];
1086
+ claim = claims_1[_i];
1087
+ issueMatch = claim.issueId.match(/(\d+)/);
1088
+ if (!issueMatch) return [3 /*break*/, 4];
1089
+ return [4 /*yield*/, this.claimOnGitHub(parseInt(issueMatch[1], 10), claim.claimant)];
1090
+ case 3:
1091
+ result = _a.sent();
1092
+ if (result.success)
1093
+ synced++;
1094
+ else
1095
+ errors.push.apply(errors, result.errors);
1096
+ _a.label = 4;
1097
+ case 4:
1098
+ _i++;
1099
+ return [3 /*break*/, 2];
1100
+ case 5: return [2 /*return*/, { success: errors.length === 0, synced: synced, errors: errors }];
1101
+ }
1102
+ });
1103
+ });
1104
+ };
793
1105
  /**
794
1106
  * Get GitHub issues that are claimed locally
795
1107
  */
796
- async getClaimedGitHubIssues() {
797
- const syncResult = await this.syncIssues('open');
798
- if (!syncResult.success || !syncResult.issues)
799
- return [];
800
- const localClaims = await this.claimService.getAllClaims();
801
- const claimedIds = new Set(localClaims.map(c => {
802
- const match = c.issueId.match(/(\d+)/);
803
- return match ? parseInt(match[1], 10) : null;
804
- }).filter(Boolean));
805
- return syncResult.issues.filter(issue => claimedIds.has(issue.number));
806
- }
807
- }
1108
+ GitHubSync.prototype.getClaimedGitHubIssues = function () {
1109
+ return __awaiter(this, void 0, Promise, function () {
1110
+ var syncResult, localClaims, claimedIds;
1111
+ return __generator(this, function (_a) {
1112
+ switch (_a.label) {
1113
+ case 0: return [4 /*yield*/, this.syncIssues('open')];
1114
+ case 1:
1115
+ syncResult = _a.sent();
1116
+ if (!syncResult.success || !syncResult.issues)
1117
+ return [2 /*return*/, []];
1118
+ return [4 /*yield*/, this.claimService.getAllClaims()];
1119
+ case 2:
1120
+ localClaims = _a.sent();
1121
+ claimedIds = new Set(localClaims.map(function (c) {
1122
+ var match = c.issueId.match(/(\d+)/);
1123
+ return match ? parseInt(match[1], 10) : null;
1124
+ }).filter(Boolean));
1125
+ return [2 /*return*/, syncResult.issues.filter(function (issue) { return claimedIds.has(issue.number); })];
1126
+ }
1127
+ });
1128
+ });
1129
+ };
1130
+ return GitHubSync;
1131
+ }());
1132
+ export { GitHubSync };
808
1133
  // ============================================================================
809
1134
  // Factory
810
1135
  // ============================================================================