@kya-os/cli 1.8.1 → 1.8.3

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 (385) hide show
  1. package/dist/commands/agent.d.ts +35 -0
  2. package/dist/commands/agent.d.ts.map +1 -0
  3. package/dist/commands/agent.js +321 -0
  4. package/dist/commands/agent.js.map +1 -0
  5. package/dist/commands/build.js +2 -2
  6. package/dist/commands/build.js.map +1 -1
  7. package/dist/commands/check.js +3 -3
  8. package/dist/commands/check.js.map +1 -1
  9. package/dist/commands/checkpoint-init.d.ts +1 -1
  10. package/dist/commands/checkpoint-init.d.ts.map +1 -1
  11. package/dist/commands/checkpoint-init.js +8 -41
  12. package/dist/commands/checkpoint-init.js.map +1 -1
  13. package/dist/commands/claim.js +2 -2
  14. package/dist/commands/claim.js.map +1 -1
  15. package/dist/commands/dco.d.ts +59 -0
  16. package/dist/commands/dco.d.ts.map +1 -1
  17. package/dist/commands/dco.js +280 -5
  18. package/dist/commands/dco.js.map +1 -1
  19. package/dist/commands/dev.js +1 -1
  20. package/dist/commands/dev.js.map +1 -1
  21. package/dist/commands/doctor.d.ts.map +1 -1
  22. package/dist/commands/doctor.js +18 -24
  23. package/dist/commands/doctor.js.map +1 -1
  24. package/dist/commands/env.js +6 -6
  25. package/dist/commands/env.js.map +1 -1
  26. package/dist/commands/identity.js +3 -3
  27. package/dist/commands/identity.js.map +1 -1
  28. package/dist/commands/init-stages.d.ts +141 -0
  29. package/dist/commands/init-stages.d.ts.map +1 -0
  30. package/dist/commands/init-stages.js +684 -0
  31. package/dist/commands/init-stages.js.map +1 -0
  32. package/dist/commands/init.d.ts +46 -16
  33. package/dist/commands/init.d.ts.map +1 -1
  34. package/dist/commands/init.js +229 -279
  35. package/dist/commands/init.js.map +1 -1
  36. package/dist/commands/orchestrator.d.ts +18 -0
  37. package/dist/commands/orchestrator.d.ts.map +1 -0
  38. package/dist/commands/orchestrator.js +251 -0
  39. package/dist/commands/orchestrator.js.map +1 -0
  40. package/dist/commands/register.d.ts +1 -1
  41. package/dist/commands/register.d.ts.map +1 -1
  42. package/dist/commands/register.js +35 -7
  43. package/dist/commands/register.js.map +1 -1
  44. package/dist/commands/review.d.ts +48 -0
  45. package/dist/commands/review.d.ts.map +1 -0
  46. package/dist/commands/review.js +220 -0
  47. package/dist/commands/review.js.map +1 -0
  48. package/dist/commands/rotate.js +4 -4
  49. package/dist/commands/rotate.js.map +1 -1
  50. package/dist/commands/score.d.ts +15 -0
  51. package/dist/commands/score.d.ts.map +1 -0
  52. package/dist/commands/score.js +471 -0
  53. package/dist/commands/score.js.map +1 -0
  54. package/dist/commands/start.js +3 -3
  55. package/dist/commands/start.js.map +1 -1
  56. package/dist/commands/status.js +1 -1
  57. package/dist/commands/status.js.map +1 -1
  58. package/dist/commands/verify.js +6 -6
  59. package/dist/commands/verify.js.map +1 -1
  60. package/dist/dco.d.ts +4 -0
  61. package/dist/dco.d.ts.map +1 -0
  62. package/dist/dco.js +23 -0
  63. package/dist/dco.js.map +1 -0
  64. package/dist/index.js +52 -9
  65. package/dist/orchestrator/daemon.d.ts +137 -0
  66. package/dist/orchestrator/daemon.d.ts.map +1 -0
  67. package/dist/orchestrator/daemon.js +242 -0
  68. package/dist/orchestrator/daemon.js.map +1 -0
  69. package/dist/orchestrator/db/dispatches.d.ts +108 -0
  70. package/dist/orchestrator/db/dispatches.d.ts.map +1 -0
  71. package/dist/orchestrator/db/dispatches.js +122 -0
  72. package/dist/orchestrator/db/dispatches.js.map +1 -0
  73. package/dist/orchestrator/db/index.d.ts +50 -0
  74. package/dist/orchestrator/db/index.d.ts.map +1 -0
  75. package/dist/orchestrator/db/index.js +116 -0
  76. package/dist/orchestrator/db/index.js.map +1 -0
  77. package/dist/orchestrator/db/journal.d.ts +93 -0
  78. package/dist/orchestrator/db/journal.d.ts.map +1 -0
  79. package/dist/orchestrator/db/journal.js +91 -0
  80. package/dist/orchestrator/db/journal.js.map +1 -0
  81. package/dist/orchestrator/db/liveness.d.ts +97 -0
  82. package/dist/orchestrator/db/liveness.d.ts.map +1 -0
  83. package/dist/orchestrator/db/liveness.js +105 -0
  84. package/dist/orchestrator/db/liveness.js.map +1 -0
  85. package/dist/orchestrator/db/mission.d.ts +78 -0
  86. package/dist/orchestrator/db/mission.d.ts.map +1 -0
  87. package/dist/orchestrator/db/mission.js +99 -0
  88. package/dist/orchestrator/db/mission.js.map +1 -0
  89. package/dist/orchestrator/db/schema.d.ts +14 -0
  90. package/dist/orchestrator/db/schema.d.ts.map +1 -0
  91. package/dist/orchestrator/db/schema.js +169 -0
  92. package/dist/orchestrator/db/schema.js.map +1 -0
  93. package/dist/orchestrator/db/tickets.d.ts +147 -0
  94. package/dist/orchestrator/db/tickets.d.ts.map +1 -0
  95. package/dist/orchestrator/db/tickets.js +238 -0
  96. package/dist/orchestrator/db/tickets.js.map +1 -0
  97. package/dist/orchestrator/db/verdicts.d.ts +187 -0
  98. package/dist/orchestrator/db/verdicts.d.ts.map +1 -0
  99. package/dist/orchestrator/db/verdicts.js +197 -0
  100. package/dist/orchestrator/db/verdicts.js.map +1 -0
  101. package/dist/orchestrator/events.d.ts +69 -0
  102. package/dist/orchestrator/events.d.ts.map +1 -0
  103. package/dist/orchestrator/events.js +20 -0
  104. package/dist/orchestrator/events.js.map +1 -0
  105. package/dist/orchestrator/github-credential-anchor-sender.d.ts +159 -0
  106. package/dist/orchestrator/github-credential-anchor-sender.d.ts.map +1 -0
  107. package/dist/orchestrator/github-credential-anchor-sender.js +313 -0
  108. package/dist/orchestrator/github-credential-anchor-sender.js.map +1 -0
  109. package/dist/orchestrator/hub-dispatch.d.ts +120 -0
  110. package/dist/orchestrator/hub-dispatch.d.ts.map +1 -0
  111. package/dist/orchestrator/hub-dispatch.js +257 -0
  112. package/dist/orchestrator/hub-dispatch.js.map +1 -0
  113. package/dist/orchestrator/hub-observer.d.ts +201 -0
  114. package/dist/orchestrator/hub-observer.d.ts.map +1 -0
  115. package/dist/orchestrator/hub-observer.js +474 -0
  116. package/dist/orchestrator/hub-observer.js.map +1 -0
  117. package/dist/orchestrator/journal-writer.d.ts +80 -0
  118. package/dist/orchestrator/journal-writer.d.ts.map +1 -0
  119. package/dist/orchestrator/journal-writer.js +113 -0
  120. package/dist/orchestrator/journal-writer.js.map +1 -0
  121. package/dist/orchestrator/mcp/server.d.ts +136 -0
  122. package/dist/orchestrator/mcp/server.d.ts.map +1 -0
  123. package/dist/orchestrator/mcp/server.js +582 -0
  124. package/dist/orchestrator/mcp/server.js.map +1 -0
  125. package/dist/orchestrator/mcp/stdio.d.ts +22 -0
  126. package/dist/orchestrator/mcp/stdio.d.ts.map +1 -0
  127. package/dist/orchestrator/mcp/stdio.js +51 -0
  128. package/dist/orchestrator/mcp/stdio.js.map +1 -0
  129. package/dist/orchestrator/review.d.ts +131 -0
  130. package/dist/orchestrator/review.d.ts.map +1 -0
  131. package/dist/orchestrator/review.js +322 -0
  132. package/dist/orchestrator/review.js.map +1 -0
  133. package/dist/tui/app.d.ts +33 -0
  134. package/dist/tui/app.d.ts.map +1 -0
  135. package/dist/tui/app.js +71 -0
  136. package/dist/tui/app.js.map +1 -0
  137. package/dist/tui/components.d.ts +110 -0
  138. package/dist/tui/components.d.ts.map +1 -0
  139. package/dist/tui/components.js +118 -0
  140. package/dist/tui/components.js.map +1 -0
  141. package/dist/tui/index.d.ts +30 -0
  142. package/dist/tui/index.d.ts.map +1 -0
  143. package/dist/tui/index.js +95 -0
  144. package/dist/tui/index.js.map +1 -0
  145. package/dist/tui/keymap.d.ts +33 -0
  146. package/dist/tui/keymap.d.ts.map +1 -0
  147. package/dist/tui/keymap.js +49 -0
  148. package/dist/tui/keymap.js.map +1 -0
  149. package/dist/tui/nav.d.ts +29 -0
  150. package/dist/tui/nav.d.ts.map +1 -0
  151. package/dist/tui/nav.js +39 -0
  152. package/dist/tui/nav.js.map +1 -0
  153. package/dist/tui/sanitize.d.ts +25 -0
  154. package/dist/tui/sanitize.d.ts.map +1 -0
  155. package/dist/tui/sanitize.js +36 -0
  156. package/dist/tui/sanitize.js.map +1 -0
  157. package/dist/tui/theme.d.ts +32 -0
  158. package/dist/tui/theme.d.ts.map +1 -0
  159. package/dist/tui/theme.js +63 -0
  160. package/dist/tui/theme.js.map +1 -0
  161. package/dist/tui/views/agents.d.ts +67 -0
  162. package/dist/tui/views/agents.d.ts.map +1 -0
  163. package/dist/tui/views/agents.js +231 -0
  164. package/dist/tui/views/agents.js.map +1 -0
  165. package/dist/tui/views/index.d.ts +93 -0
  166. package/dist/tui/views/index.d.ts.map +1 -0
  167. package/dist/tui/views/index.js +150 -0
  168. package/dist/tui/views/index.js.map +1 -0
  169. package/dist/tui/views/registry.d.ts +22 -0
  170. package/dist/tui/views/registry.d.ts.map +1 -0
  171. package/dist/tui/views/registry.js +110 -0
  172. package/dist/tui/views/registry.js.map +1 -0
  173. package/dist/utils/agent/backoff.d.ts +31 -0
  174. package/dist/utils/agent/backoff.d.ts.map +1 -0
  175. package/dist/utils/agent/backoff.js +51 -0
  176. package/dist/utils/agent/backoff.js.map +1 -0
  177. package/dist/utils/agent/markers.d.ts +87 -0
  178. package/dist/utils/agent/markers.d.ts.map +1 -0
  179. package/dist/utils/agent/markers.js +147 -0
  180. package/dist/utils/agent/markers.js.map +1 -0
  181. package/dist/utils/agent/review.d.ts +67 -0
  182. package/dist/utils/agent/review.d.ts.map +1 -0
  183. package/dist/utils/agent/review.js +305 -0
  184. package/dist/utils/agent/review.js.map +1 -0
  185. package/dist/utils/agent/spawn-agent.d.ts +117 -0
  186. package/dist/utils/agent/spawn-agent.d.ts.map +1 -0
  187. package/dist/utils/agent/spawn-agent.js +177 -0
  188. package/dist/utils/agent/spawn-agent.js.map +1 -0
  189. package/dist/utils/agent/task.d.ts +101 -0
  190. package/dist/utils/agent/task.d.ts.map +1 -0
  191. package/dist/utils/agent/task.js +357 -0
  192. package/dist/utils/agent/task.js.map +1 -0
  193. package/dist/utils/agent/verify.d.ts +47 -0
  194. package/dist/utils/agent/verify.d.ts.map +1 -0
  195. package/dist/utils/agent/verify.js +144 -0
  196. package/dist/utils/agent/verify.js.map +1 -0
  197. package/dist/utils/agent-detector.d.ts +48 -0
  198. package/dist/utils/agent-detector.d.ts.map +1 -0
  199. package/dist/utils/agent-detector.js +74 -0
  200. package/dist/utils/agent-detector.js.map +1 -0
  201. package/dist/utils/agent-profile-stage.d.ts +70 -0
  202. package/dist/utils/agent-profile-stage.d.ts.map +1 -0
  203. package/dist/utils/agent-profile-stage.js +153 -0
  204. package/dist/utils/agent-profile-stage.js.map +1 -0
  205. package/dist/utils/agent-profiles.d.ts +27 -0
  206. package/dist/utils/agent-profiles.d.ts.map +1 -0
  207. package/dist/utils/agent-profiles.js +61 -0
  208. package/dist/utils/agent-profiles.js.map +1 -0
  209. package/dist/utils/checkpoint-api.d.ts +1 -1
  210. package/dist/utils/checkpoint-api.js +1 -1
  211. package/dist/utils/checkpoint-env.d.ts +1 -1
  212. package/dist/utils/checkpoint-env.js +2 -2
  213. package/dist/utils/checkpoint-env.js.map +1 -1
  214. package/dist/utils/checkpoint-scaffold.d.ts +1 -1
  215. package/dist/utils/checkpoint-scaffold.js +1 -1
  216. package/dist/utils/cli-kit/browser.d.ts +24 -0
  217. package/dist/utils/cli-kit/browser.d.ts.map +1 -0
  218. package/dist/utils/cli-kit/browser.js +58 -0
  219. package/dist/utils/cli-kit/browser.js.map +1 -0
  220. package/dist/utils/cli-kit/claim-polling.d.ts +18 -0
  221. package/dist/utils/cli-kit/claim-polling.d.ts.map +1 -0
  222. package/dist/utils/{claim-polling.js → cli-kit/claim-polling.js} +19 -26
  223. package/dist/utils/cli-kit/claim-polling.js.map +1 -0
  224. package/dist/utils/cli-kit/diagnostics.d.ts +9 -0
  225. package/dist/utils/cli-kit/diagnostics.d.ts.map +1 -0
  226. package/dist/utils/cli-kit/diagnostics.js +11 -0
  227. package/dist/utils/cli-kit/diagnostics.js.map +1 -0
  228. package/dist/utils/cli-kit/fs-safe.d.ts +14 -0
  229. package/dist/utils/cli-kit/fs-safe.d.ts.map +1 -0
  230. package/dist/utils/cli-kit/fs-safe.js +20 -0
  231. package/dist/utils/cli-kit/fs-safe.js.map +1 -0
  232. package/dist/utils/cli-kit/index.d.ts +15 -0
  233. package/dist/utils/cli-kit/index.d.ts.map +1 -0
  234. package/dist/utils/cli-kit/index.js +10 -0
  235. package/dist/utils/cli-kit/index.js.map +1 -0
  236. package/dist/utils/cli-kit/json-file.d.ts +21 -0
  237. package/dist/utils/cli-kit/json-file.d.ts.map +1 -0
  238. package/dist/utils/cli-kit/json-file.js +51 -0
  239. package/dist/utils/cli-kit/json-file.js.map +1 -0
  240. package/dist/utils/cli-kit/marker-block.d.ts +26 -0
  241. package/dist/utils/cli-kit/marker-block.d.ts.map +1 -0
  242. package/dist/utils/cli-kit/marker-block.js +61 -0
  243. package/dist/utils/cli-kit/marker-block.js.map +1 -0
  244. package/dist/utils/cli-kit/paths.d.ts +15 -0
  245. package/dist/utils/cli-kit/paths.d.ts.map +1 -0
  246. package/dist/utils/cli-kit/paths.js +21 -0
  247. package/dist/utils/cli-kit/paths.js.map +1 -0
  248. package/dist/utils/cli-kit/secure-storage.d.ts +14 -0
  249. package/dist/utils/cli-kit/secure-storage.d.ts.map +1 -0
  250. package/dist/utils/cli-kit/secure-storage.js +20 -0
  251. package/dist/utils/cli-kit/secure-storage.js.map +1 -0
  252. package/dist/utils/cli-kit/step-report.d.ts +16 -0
  253. package/dist/utils/cli-kit/step-report.d.ts.map +1 -0
  254. package/dist/utils/cli-kit/step-report.js +36 -0
  255. package/dist/utils/cli-kit/step-report.js.map +1 -0
  256. package/dist/utils/dco/agent-metadata.d.ts +1 -1
  257. package/dist/utils/dco/agent-metadata.js +1 -1
  258. package/dist/utils/dco/agent-metadata.js.map +1 -1
  259. package/dist/utils/dco/claude-config.d.ts +18 -14
  260. package/dist/utils/dco/claude-config.d.ts.map +1 -1
  261. package/dist/utils/dco/claude-config.js +31 -97
  262. package/dist/utils/dco/claude-config.js.map +1 -1
  263. package/dist/utils/dco/dispatch.d.ts +134 -0
  264. package/dist/utils/dco/dispatch.d.ts.map +1 -0
  265. package/dist/utils/dco/dispatch.js +399 -0
  266. package/dist/utils/dco/dispatch.js.map +1 -0
  267. package/dist/utils/dco/fix.d.ts +122 -0
  268. package/dist/utils/dco/fix.d.ts.map +1 -0
  269. package/dist/utils/dco/fix.js +560 -0
  270. package/dist/utils/dco/fix.js.map +1 -0
  271. package/dist/utils/dco/git-config.d.ts.map +1 -1
  272. package/dist/utils/dco/git-config.js +5 -3
  273. package/dist/utils/dco/git-config.js.map +1 -1
  274. package/dist/utils/dco/github.d.ts +101 -0
  275. package/dist/utils/dco/github.d.ts.map +1 -1
  276. package/dist/utils/dco/github.js +133 -0
  277. package/dist/utils/dco/github.js.map +1 -1
  278. package/dist/utils/dco/paths.d.ts +1 -8
  279. package/dist/utils/dco/paths.d.ts.map +1 -1
  280. package/dist/utils/dco/paths.js +3 -12
  281. package/dist/utils/dco/paths.js.map +1 -1
  282. package/dist/utils/dco/render.d.ts +1 -1
  283. package/dist/utils/dco/render.d.ts.map +1 -1
  284. package/dist/utils/dco/render.js +4 -21
  285. package/dist/utils/dco/render.js.map +1 -1
  286. package/dist/utils/dco/resolve-agent.d.ts +54 -0
  287. package/dist/utils/dco/resolve-agent.d.ts.map +1 -0
  288. package/dist/utils/dco/resolve-agent.js +164 -0
  289. package/dist/utils/dco/resolve-agent.js.map +1 -0
  290. package/dist/utils/dco/setup.d.ts +10 -7
  291. package/dist/utils/dco/setup.d.ts.map +1 -1
  292. package/dist/utils/dco/setup.js +264 -200
  293. package/dist/utils/dco/setup.js.map +1 -1
  294. package/dist/utils/dco/signing-key-writer.d.ts +40 -0
  295. package/dist/utils/dco/signing-key-writer.d.ts.map +1 -0
  296. package/dist/utils/dco/signing-key-writer.js +76 -0
  297. package/dist/utils/dco/signing-key-writer.js.map +1 -0
  298. package/dist/utils/dco/ssh-key.d.ts +50 -0
  299. package/dist/utils/dco/ssh-key.d.ts.map +1 -1
  300. package/dist/utils/dco/ssh-key.js +129 -8
  301. package/dist/utils/dco/ssh-key.js.map +1 -1
  302. package/dist/utils/dco/status.d.ts +1 -1
  303. package/dist/utils/dco/status.d.ts.map +1 -1
  304. package/dist/utils/dco/status.js +3 -3
  305. package/dist/utils/dco/status.js.map +1 -1
  306. package/dist/utils/dco/verify.d.ts +170 -0
  307. package/dist/utils/dco/verify.d.ts.map +1 -0
  308. package/dist/utils/dco/verify.js +550 -0
  309. package/dist/utils/dco/verify.js.map +1 -0
  310. package/dist/utils/dependency-installer.d.ts +37 -0
  311. package/dist/utils/dependency-installer.d.ts.map +1 -0
  312. package/dist/utils/dependency-installer.js +32 -0
  313. package/dist/utils/dependency-installer.js.map +1 -0
  314. package/dist/utils/github-credential-stage.d.ts +87 -0
  315. package/dist/utils/github-credential-stage.d.ts.map +1 -0
  316. package/dist/utils/github-credential-stage.js +168 -0
  317. package/dist/utils/github-credential-stage.js.map +1 -0
  318. package/dist/utils/github-credential.d.ts +160 -0
  319. package/dist/utils/github-credential.d.ts.map +1 -0
  320. package/dist/utils/github-credential.js +308 -0
  321. package/dist/utils/github-credential.js.map +1 -0
  322. package/dist/utils/gitignore.d.ts +17 -0
  323. package/dist/utils/gitignore.d.ts.map +1 -0
  324. package/dist/utils/gitignore.js +40 -0
  325. package/dist/utils/gitignore.js.map +1 -0
  326. package/dist/utils/hub-config.d.ts +21 -0
  327. package/dist/utils/hub-config.d.ts.map +1 -0
  328. package/dist/utils/hub-config.js +28 -0
  329. package/dist/utils/hub-config.js.map +1 -0
  330. package/dist/utils/identity-heal.d.ts +16 -0
  331. package/dist/utils/identity-heal.d.ts.map +1 -0
  332. package/dist/utils/identity-heal.js +37 -0
  333. package/dist/utils/identity-heal.js.map +1 -0
  334. package/dist/utils/init/pipeline.d.ts +74 -0
  335. package/dist/utils/init/pipeline.d.ts.map +1 -0
  336. package/dist/utils/init/pipeline.js +96 -0
  337. package/dist/utils/init/pipeline.js.map +1 -0
  338. package/dist/utils/poll.d.ts +15 -1
  339. package/dist/utils/poll.d.ts.map +1 -1
  340. package/dist/utils/poll.js +6 -3
  341. package/dist/utils/poll.js.map +1 -1
  342. package/dist/utils/register-agent-identity.d.ts +67 -0
  343. package/dist/utils/register-agent-identity.d.ts.map +1 -0
  344. package/dist/utils/register-agent-identity.js +34 -0
  345. package/dist/utils/register-agent-identity.js.map +1 -0
  346. package/dist/utils/review/did-web-key.d.ts +34 -0
  347. package/dist/utils/review/did-web-key.d.ts.map +1 -0
  348. package/dist/utils/review/did-web-key.js +104 -0
  349. package/dist/utils/review/did-web-key.js.map +1 -0
  350. package/dist/utils/review/load-registry.d.ts +33 -0
  351. package/dist/utils/review/load-registry.d.ts.map +1 -0
  352. package/dist/utils/review/load-registry.js +62 -0
  353. package/dist/utils/review/load-registry.js.map +1 -0
  354. package/dist/utils/review/verdict-verify.d.ts +43 -0
  355. package/dist/utils/review/verdict-verify.d.ts.map +1 -0
  356. package/dist/utils/review/verdict-verify.js +53 -0
  357. package/dist/utils/review/verdict-verify.js.map +1 -0
  358. package/dist/utils/review-registry-writer.d.ts +52 -0
  359. package/dist/utils/review-registry-writer.d.ts.map +1 -0
  360. package/dist/utils/review-registry-writer.js +79 -0
  361. package/dist/utils/review-registry-writer.js.map +1 -0
  362. package/dist/utils/should-install-dependency.d.ts +17 -0
  363. package/dist/utils/should-install-dependency.d.ts.map +1 -0
  364. package/dist/utils/should-install-dependency.js +25 -0
  365. package/dist/utils/should-install-dependency.js.map +1 -0
  366. package/dist/utils/tool-readiness.d.ts +57 -0
  367. package/dist/utils/tool-readiness.d.ts.map +1 -0
  368. package/dist/utils/tool-readiness.js +114 -0
  369. package/dist/utils/tool-readiness.js.map +1 -0
  370. package/dist/utils/which.d.ts +2 -0
  371. package/dist/utils/which.d.ts.map +1 -0
  372. package/dist/utils/which.js +22 -0
  373. package/dist/utils/which.js.map +1 -0
  374. package/dist/version.d.ts +15 -0
  375. package/dist/version.d.ts.map +1 -0
  376. package/dist/version.js +29 -0
  377. package/dist/version.js.map +1 -0
  378. package/package.json +19 -6
  379. package/dist/utils/claim-polling.d.ts +0 -21
  380. package/dist/utils/claim-polling.d.ts.map +0 -1
  381. package/dist/utils/claim-polling.js.map +0 -1
  382. package/dist/utils/dco/fs-safe.d.ts +0 -14
  383. package/dist/utils/dco/fs-safe.d.ts.map +0 -1
  384. package/dist/utils/dco/fs-safe.js +0 -20
  385. package/dist/utils/dco/fs-safe.js.map +0 -1
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Journal writer (ORC-W1 PR-2).
3
+ *
4
+ * Turns hub events into ledger rows. This is the piece that makes the journal
5
+ * evidence rather than narration: rows land because a verified protocol event
6
+ * arrived, not because a model chose to record one.
7
+ *
8
+ * @module orchestrator/journal-writer
9
+ */
10
+ import { appendJournal } from "./db/journal.js";
11
+ import { findTicketIdByTaskId, findTicketIdByPr } from "./db/dispatches.js";
12
+ /**
13
+ * Pull a task id out of an event's untyped `data` bag.
14
+ *
15
+ * `data` is `Record<string, unknown>` on the wire, so this narrows rather than
16
+ * casting. Anything that is not a non-empty string is treated as absent, which
17
+ * is the honest reading: a malformed taskId must not be used to look up a
18
+ * ticket and silently attach an observation to the wrong one.
19
+ */
20
+ export function taskIdOf(event) {
21
+ const raw = (event.data ?? {})["taskId"];
22
+ return typeof raw === "string" && raw.length > 0 ? raw : null;
23
+ }
24
+ /**
25
+ * Persist one event.
26
+ *
27
+ * Correlates to a ticket through `dispatches` when the event names a task this
28
+ * orchestrator dispatched. When it does not, the row is still written with a
29
+ * null ticket, because an uncorrelated observation is worth more than no
30
+ * observation and guessing at a ticket would be worse than either.
31
+ *
32
+ * Returns true when the row was new (false means it was a replay).
33
+ */
34
+ export function writeEvent(db, event) {
35
+ return appendJournal(db, { event, ticketId: ticketIdForEvent(db, event) });
36
+ }
37
+ /**
38
+ * Read a review event's subject out of its untyped `data` bag.
39
+ *
40
+ * All three fields or nothing. A verdict missing part of its subject cannot be
41
+ * attributed, and attributing it to the wrong ticket is worse than leaving the
42
+ * row uncorrelated.
43
+ */
44
+ export function reviewSubjectOf(event) {
45
+ const data = event.data ?? {};
46
+ const repo = data["repo"];
47
+ const prNumber = data["prNumber"];
48
+ const headSha = data["headSha"];
49
+ if (typeof repo !== "string" || repo.length === 0)
50
+ return null;
51
+ // Number.isInteger rejects NaN, Infinity and floats. A bad PR number would
52
+ // match no dispatch, which reads as "not ours" rather than as bad input.
53
+ if (typeof prNumber !== "number" || !Number.isInteger(prNumber) || prNumber <= 0)
54
+ return null;
55
+ if (typeof headSha !== "string" || headSha.length === 0)
56
+ return null;
57
+ return { repo, prNumber, headSha };
58
+ }
59
+ /**
60
+ * Resolve the ticket an event concerns: task id first, pull request second.
61
+ *
62
+ * Task id is exact where present. PR correlation is the fallback and the ONLY
63
+ * option for `pr_quorum_reached`, which carries no task id -- so before this
64
+ * existed every quorum event journalled with a null ticket, and the Review lens
65
+ * could show that something reached quorum but never which ticket it was for.
66
+ */
67
+ export function ticketIdForEvent(db, event) {
68
+ const taskId = taskIdOf(event);
69
+ if (taskId) {
70
+ const byTask = findTicketIdByTaskId(db, taskId);
71
+ if (byTask)
72
+ return byTask;
73
+ }
74
+ const subject = reviewSubjectOf(event);
75
+ return subject ? findTicketIdByPr(db, subject.repo, subject.prNumber) : null;
76
+ }
77
+ /**
78
+ * Subscribe to the hub and journal everything it emits.
79
+ *
80
+ * Returns the unsubscribe, matching the hub's own `onEvent` contract, so the
81
+ * daemon can detach cleanly on shutdown instead of leaking a handler that
82
+ * writes to a closed database.
83
+ *
84
+ * Deliberately does NOT catch a write failure here. Every real dispatcher
85
+ * this attaches to -- the hub's own emit loop, `HubObserver.dispatch()` --
86
+ * already isolates one handler's failure from its siblings and from itself,
87
+ * so catching AGAIN in here just hides the failure from that dispatcher: a
88
+ * reconnect's replay retries a write only if it can tell the write failed,
89
+ * and a handler that always reports success by swallowing its own errors
90
+ * makes that retry permanently dead code (review finding on #686).
91
+ */
92
+ export function registerJournalWriter(db, hub) {
93
+ return hub.onEvent((event) => {
94
+ writeEvent(db, event);
95
+ });
96
+ }
97
+ /**
98
+ * Replay the hub's recent-event window into the journal.
99
+ *
100
+ * Called once on boot so a daemon restart recovers what it slept through.
101
+ * Idempotent by construction: journal ids are derived from event content, so
102
+ * an event already recorded live is ignored rather than duplicated. Returns
103
+ * how many rows were genuinely new.
104
+ */
105
+ export function reconcileRecentEvents(db, hub, limit = 50) {
106
+ let added = 0;
107
+ for (const event of hub.getRecentEvents(limit)) {
108
+ if (writeEvent(db, event))
109
+ added += 1;
110
+ }
111
+ return added;
112
+ }
113
+ //# sourceMappingURL=journal-writer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journal-writer.js","sourceRoot":"","sources":["../../src/orchestrator/journal-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG5E;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAmB;IAC1C,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;IACzC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,EAAU,EAAE,KAAmB;IACxD,OAAO,aAAa,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;AAC7E,CAAC;AASD;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAmB;IACjD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;IAC9B,MAAM,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C,EAAE,EAAE,KAAK,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,EAAU,EAAE,GAAgB,EAAE,KAAK,GAAG,EAAE;IAC5E,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/C,IAAI,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC;YAAE,KAAK,IAAI,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Ledger MCP server.
3
+ *
4
+ * The orchestrator session's tool surface. This is the boundary that makes
5
+ * approach C work: the daemon owns anything whose correctness a test can
6
+ * check, and the session owns anything whose correctness requires an opinion.
7
+ * Every tool here enforces its invariant in SQL, so a model cannot reason its
8
+ * way past one.
9
+ *
10
+ * Two absences are load-bearing:
11
+ *
12
+ * - There is NO tool that creates a Linear issue, and none by which the
13
+ * SESSION can create a ticket. That is about the session specifically: the
14
+ * ledger does hold agent-native tickets (linear_id NULL), and the daemon
15
+ * writes those deterministically from protocol events. What must not exist
16
+ * is a path by which a model decides, on its own reading of a situation,
17
+ * that some new work exists. A finding it wants to raise goes in the
18
+ * journal, and a human promotes it. Without this absence that policy would
19
+ * be a sentence in a prompt instead of a property of the surface.
20
+ * - There is NO tool that sets the mission note. Reading it is the point;
21
+ * writing it is the operator's. A session that can rewrite its own standing
22
+ * objective is not following one, and would drift toward whatever it last
23
+ * found interesting.
24
+ * - There is NO delete tool, for the same reason the store has no delete
25
+ * path: a bad autonomous close and a clean backlog are indistinguishable
26
+ * once the row is gone.
27
+ *
28
+ * JSON-RPC 2.0 is hand-rolled rather than pulled from the MCP SDK, matching
29
+ * `fleet-mcp.ts` in @kya-os/compute. It keeps a dependency out of a published
30
+ * CLI for what amounts to a switch statement.
31
+ *
32
+ * @module cli/orchestrator/mcp/server
33
+ */
34
+ import type { Ledger } from "../db/index.js";
35
+ import { SettableTicketStatusSchema, SETTABLE_TICKET_STATUSES, type SettableTicketStatus } from "../db/tickets.js";
36
+ export interface JsonRpcRequest {
37
+ jsonrpc: "2.0";
38
+ id?: string | number | null;
39
+ method: string;
40
+ params?: Record<string, unknown>;
41
+ }
42
+ export interface JsonRpcResponse {
43
+ jsonrpc: "2.0";
44
+ id?: string | number | null;
45
+ result?: unknown;
46
+ error?: {
47
+ code: number;
48
+ message: string;
49
+ };
50
+ }
51
+ interface ToolDefinition {
52
+ name: string;
53
+ description: string;
54
+ inputSchema: Record<string, unknown>;
55
+ }
56
+ /**
57
+ * The MCP revision this server speaks.
58
+ *
59
+ * Named rather than inlined in the handshake response, so the version this
60
+ * server actually implements is greppable and changes in one place. Deliberately
61
+ * NOT echoed back from the client's request: the handshake exists for the client
62
+ * to discover what the server supports, and reflecting whatever it asked for
63
+ * would claim support for revisions this code has never been tested against,
64
+ * turning the one honest signal in the exchange into a mirror.
65
+ */
66
+ export declare const MCP_PROTOCOL_VERSION = "2025-03-26";
67
+ /**
68
+ * Row cap shared by every list tool.
69
+ *
70
+ * journal.list capped and the others did not, which contradicted this file's own
71
+ * reason for capping: a model must not be able to ask for the whole table. The
72
+ * cap is uniform so the reason applies uniformly.
73
+ */
74
+ export declare const MAX_ROWS = 500;
75
+ /** Serialised size limit for a session-written journal payload. */
76
+ export declare const MAX_EVENT_DATA_BYTES = 8000;
77
+ /** Size limit for a session-written event type. */
78
+ export declare const MAX_EVENT_TYPE_BYTES = 120;
79
+ /**
80
+ * Length limit for a ticket id arriving from the session.
81
+ *
82
+ * Generous next to the ids this ledger mints (a UUID is 36 characters), because
83
+ * its job is to refuse the absurd, not to second-guess the id format.
84
+ */
85
+ export declare const MAX_TICKET_ID_LENGTH = 200;
86
+ /**
87
+ * Force a session-authored event into its own namespace.
88
+ *
89
+ * Idempotent, so a caller that already prefixes does not end up with
90
+ * `session.session.x`.
91
+ */
92
+ export declare function sessionEventType(raw: string): string;
93
+ /**
94
+ * The statuses this surface may SET.
95
+ *
96
+ * `claimed` and `closed` each have a dedicated tool that carries something a
97
+ * bare status write cannot: an atomic claim, and a recorded close reason.
98
+ *
99
+ * The definition itself now lives in the store, which is the layer that has to
100
+ * hold the line for callers that never pass through this file. Re-exported here
101
+ * so the advertised JSON Schema, the Zod enforcement and the store's own guard
102
+ * are provably the same list -- they used to be written twice, with Zod holding
103
+ * the real enum while the advertised schema said `{ type: "string" }`, so the
104
+ * model learned the actual constraint only by guessing and reading the error
105
+ * back.
106
+ */
107
+ export { SettableTicketStatusSchema, SETTABLE_TICKET_STATUSES, type SettableTicketStatus };
108
+ export declare const TICKET_STATUSES: ["open", "claimed", "in-progress", "in-review", "blocked", "ready", "closed"];
109
+ /** Namespace for anything the orchestrator session writes to the journal. */
110
+ export declare const SESSION_EVENT_PREFIX = "session.";
111
+ /**
112
+ * The payload a session-authored journal row actually stores.
113
+ *
114
+ * One definition, shared by the schema that bounds it and the handler that
115
+ * writes it. Two copies of this composition is precisely how the size limit
116
+ * came to guard a value that was not the one being written.
117
+ */
118
+ export declare function sessionEventPayload(data: Record<string, unknown>, note?: string): Record<string, unknown>;
119
+ export declare const LEDGER_TOOLS: ToolDefinition[];
120
+ /**
121
+ * Run one tool against the ledger.
122
+ *
123
+ * Exported separately from the RPC plumbing so tests exercise the tool
124
+ * semantics without speaking JSON-RPC, and so the invariants are testable in
125
+ * isolation from the transport.
126
+ */
127
+ export declare function callLedgerTool(db: Ledger, name: string, rawArgs: unknown): unknown;
128
+ /**
129
+ * Handle one JSON-RPC request.
130
+ *
131
+ * Errors become JSON-RPC errors rather than thrown exceptions, because a
132
+ * thrown error here kills the stdio loop and takes every subsequent tool call
133
+ * with it. A tool that fails should fail one call.
134
+ */
135
+ export declare function handleLedgerRpc(db: Ledger, req: JsonRpcRequest): JsonRpcResponse | null;
136
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
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