wicked-crew 0.7.40 → 0.7.46

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 (361) hide show
  1. package/dist/api/audit.d.ts +3 -0
  2. package/dist/api/audit.d.ts.map +1 -1
  3. package/dist/api/audit.js +2 -0
  4. package/dist/api/audit.js.map +1 -1
  5. package/dist/api/capture.d.ts +149 -0
  6. package/dist/api/capture.d.ts.map +1 -0
  7. package/dist/api/capture.js +330 -0
  8. package/dist/api/capture.js.map +1 -0
  9. package/dist/api/chat-citations.d.ts +174 -0
  10. package/dist/api/chat-citations.d.ts.map +1 -0
  11. package/dist/api/chat-citations.js +528 -0
  12. package/dist/api/chat-citations.js.map +1 -0
  13. package/dist/api/chat-transcripts.d.ts +20 -1
  14. package/dist/api/chat-transcripts.d.ts.map +1 -1
  15. package/dist/api/chat-transcripts.js +29 -0
  16. package/dist/api/chat-transcripts.js.map +1 -1
  17. package/dist/api/delivery-cache.d.ts +2 -2
  18. package/dist/api/delivery-freeze.d.ts +66 -0
  19. package/dist/api/delivery-freeze.d.ts.map +1 -0
  20. package/dist/api/delivery-freeze.js +104 -0
  21. package/dist/api/delivery-freeze.js.map +1 -0
  22. package/dist/api/delivery-index.d.ts +53 -9
  23. package/dist/api/delivery-index.d.ts.map +1 -1
  24. package/dist/api/delivery-index.js +115 -22
  25. package/dist/api/delivery-index.js.map +1 -1
  26. package/dist/api/demo.d.ts +90 -0
  27. package/dist/api/demo.d.ts.map +1 -0
  28. package/dist/api/demo.js +492 -0
  29. package/dist/api/demo.js.map +1 -0
  30. package/dist/api/diagnostics.d.ts +64 -1
  31. package/dist/api/diagnostics.d.ts.map +1 -1
  32. package/dist/api/diagnostics.js +129 -1
  33. package/dist/api/diagnostics.js.map +1 -1
  34. package/dist/api/eval-sample.d.ts +6 -6
  35. package/dist/api/governance-steering.d.ts +2 -2
  36. package/dist/api/mcp.d.ts +282 -0
  37. package/dist/api/mcp.d.ts.map +1 -0
  38. package/dist/api/mcp.js +521 -0
  39. package/dist/api/mcp.js.map +1 -0
  40. package/dist/api/plan-schema.d.ts +56 -0
  41. package/dist/api/plan-schema.d.ts.map +1 -0
  42. package/dist/api/plan-schema.js +26 -0
  43. package/dist/api/plan-schema.js.map +1 -0
  44. package/dist/api/roster-standing.d.ts +15 -2
  45. package/dist/api/roster-standing.d.ts.map +1 -1
  46. package/dist/api/roster-standing.js +59 -3
  47. package/dist/api/roster-standing.js.map +1 -1
  48. package/dist/api/routes.d.ts +630 -51
  49. package/dist/api/routes.d.ts.map +1 -1
  50. package/dist/api/routes.js +738 -127
  51. package/dist/api/routes.js.map +1 -1
  52. package/dist/api/run-files.d.ts.map +1 -1
  53. package/dist/api/run-files.js +31 -2
  54. package/dist/api/run-files.js.map +1 -1
  55. package/dist/api/run-liveness.d.ts +41 -0
  56. package/dist/api/run-liveness.d.ts.map +1 -0
  57. package/dist/api/run-liveness.js +166 -0
  58. package/dist/api/run-liveness.js.map +1 -0
  59. package/dist/api/seat-health.d.ts +35 -0
  60. package/dist/api/seat-health.d.ts.map +1 -1
  61. package/dist/api/seat-health.js +92 -4
  62. package/dist/api/seat-health.js.map +1 -1
  63. package/dist/api/seat-probe.d.ts +141 -0
  64. package/dist/api/seat-probe.d.ts.map +1 -0
  65. package/dist/api/seat-probe.js +257 -0
  66. package/dist/api/seat-probe.js.map +1 -0
  67. package/dist/api/seat-record.d.ts +40 -0
  68. package/dist/api/seat-record.d.ts.map +1 -0
  69. package/dist/api/seat-record.js +218 -0
  70. package/dist/api/seat-record.js.map +1 -0
  71. package/dist/api/seat-signin.d.ts.map +1 -1
  72. package/dist/api/seat-signin.js +3 -1
  73. package/dist/api/seat-signin.js.map +1 -1
  74. package/dist/api/seat-standing.d.ts +25 -5
  75. package/dist/api/seat-standing.d.ts.map +1 -1
  76. package/dist/api/seat-standing.js +76 -9
  77. package/dist/api/seat-standing.js.map +1 -1
  78. package/dist/api/server.d.ts +34 -48
  79. package/dist/api/server.d.ts.map +1 -1
  80. package/dist/api/server.js +283 -107
  81. package/dist/api/server.js.map +1 -1
  82. package/dist/api/skills.d.ts +3 -1
  83. package/dist/api/skills.d.ts.map +1 -1
  84. package/dist/api/skills.js +7 -2
  85. package/dist/api/skills.js.map +1 -1
  86. package/dist/api/stall-watchdog.d.ts +34 -3
  87. package/dist/api/stall-watchdog.d.ts.map +1 -1
  88. package/dist/api/stall-watchdog.js +107 -8
  89. package/dist/api/stall-watchdog.js.map +1 -1
  90. package/dist/api/steering-landing.d.ts +6 -6
  91. package/dist/api/steering-landing.d.ts.map +1 -1
  92. package/dist/api/steering-landing.js +7 -9
  93. package/dist/api/steering-landing.js.map +1 -1
  94. package/dist/api/testing.d.ts +6 -4
  95. package/dist/api/testing.d.ts.map +1 -1
  96. package/dist/api/testing.js +82 -47
  97. package/dist/api/testing.js.map +1 -1
  98. package/dist/campaign/boot-resume.d.ts +34 -0
  99. package/dist/campaign/boot-resume.d.ts.map +1 -0
  100. package/dist/campaign/boot-resume.js +45 -0
  101. package/dist/campaign/boot-resume.js.map +1 -0
  102. package/dist/campaigns/rollup.d.ts +4 -1
  103. package/dist/campaigns/rollup.d.ts.map +1 -1
  104. package/dist/campaigns/rollup.js +6 -1
  105. package/dist/campaigns/rollup.js.map +1 -1
  106. package/dist/campaigns/routes.d.ts +2 -2
  107. package/dist/cli/bearer.d.ts +27 -1
  108. package/dist/cli/bearer.d.ts.map +1 -1
  109. package/dist/cli/bearer.js +62 -2
  110. package/dist/cli/bearer.js.map +1 -1
  111. package/dist/cli/governance.d.ts +11 -0
  112. package/dist/cli/governance.d.ts.map +1 -1
  113. package/dist/cli/governance.js +8 -2
  114. package/dist/cli/governance.js.map +1 -1
  115. package/dist/cli/index.d.ts.map +1 -1
  116. package/dist/cli/index.js +140 -75
  117. package/dist/cli/index.js.map +1 -1
  118. package/dist/cli/mcp.d.ts +11 -0
  119. package/dist/cli/mcp.d.ts.map +1 -1
  120. package/dist/cli/mcp.js +40 -9
  121. package/dist/cli/mcp.js.map +1 -1
  122. package/dist/cli/service.d.ts +78 -0
  123. package/dist/cli/service.d.ts.map +1 -0
  124. package/dist/cli/service.js +334 -0
  125. package/dist/cli/service.js.map +1 -0
  126. package/dist/core/adapter.d.ts +238 -12
  127. package/dist/core/adapter.d.ts.map +1 -1
  128. package/dist/core/adapter.js +619 -157
  129. package/dist/core/adapter.js.map +1 -1
  130. package/dist/core/bridge-reaper.d.ts +4 -1
  131. package/dist/core/bridge-reaper.d.ts.map +1 -1
  132. package/dist/core/bridge-reaper.js +15 -1
  133. package/dist/core/bridge-reaper.js.map +1 -1
  134. package/dist/core/bus-notice.d.ts +27 -0
  135. package/dist/core/bus-notice.d.ts.map +1 -0
  136. package/dist/core/bus-notice.js +24 -0
  137. package/dist/core/bus-notice.js.map +1 -0
  138. package/dist/core/bus.d.ts +99 -0
  139. package/dist/core/bus.d.ts.map +1 -0
  140. package/dist/core/bus.js +176 -0
  141. package/dist/core/bus.js.map +1 -0
  142. package/dist/core/deliver-exclusions.d.ts +71 -0
  143. package/dist/core/deliver-exclusions.d.ts.map +1 -0
  144. package/dist/core/deliver-exclusions.js +110 -0
  145. package/dist/core/deliver-exclusions.js.map +1 -0
  146. package/dist/core/deliver-text.d.ts +61 -14
  147. package/dist/core/deliver-text.d.ts.map +1 -1
  148. package/dist/core/deliver-text.js +178 -30
  149. package/dist/core/deliver-text.js.map +1 -1
  150. package/dist/core/deliver-triage.d.ts +11 -2
  151. package/dist/core/deliver-triage.d.ts.map +1 -1
  152. package/dist/core/deliver-triage.js +19 -1
  153. package/dist/core/deliver-triage.js.map +1 -1
  154. package/dist/core/deliver.d.ts +161 -3
  155. package/dist/core/deliver.d.ts.map +1 -1
  156. package/dist/core/deliver.js +463 -25
  157. package/dist/core/deliver.js.map +1 -1
  158. package/dist/core/deliverable-floor.d.ts.map +1 -1
  159. package/dist/core/deliverable-floor.js +5 -7
  160. package/dist/core/deliverable-floor.js.map +1 -1
  161. package/dist/core/engine-bus.d.ts +40 -0
  162. package/dist/core/engine-bus.d.ts.map +1 -0
  163. package/dist/core/engine-bus.js +27 -0
  164. package/dist/core/engine-bus.js.map +1 -0
  165. package/dist/core/estate-mcp-client.d.ts +87 -5
  166. package/dist/core/estate-mcp-client.d.ts.map +1 -1
  167. package/dist/core/estate-mcp-client.js +90 -11
  168. package/dist/core/estate-mcp-client.js.map +1 -1
  169. package/dist/core/linked-issues.d.ts +46 -0
  170. package/dist/core/linked-issues.d.ts.map +1 -0
  171. package/dist/core/linked-issues.js +123 -0
  172. package/dist/core/linked-issues.js.map +1 -0
  173. package/dist/core/run-identity.d.ts +100 -0
  174. package/dist/core/run-identity.d.ts.map +1 -0
  175. package/dist/core/run-identity.js +178 -0
  176. package/dist/core/run-identity.js.map +1 -0
  177. package/dist/core/shutdown.d.ts +16 -0
  178. package/dist/core/shutdown.d.ts.map +1 -0
  179. package/dist/core/shutdown.js +39 -0
  180. package/dist/core/shutdown.js.map +1 -0
  181. package/dist/core/types.d.ts +15 -1
  182. package/dist/core/types.d.ts.map +1 -1
  183. package/dist/core/types.js +4 -0
  184. package/dist/core/types.js.map +1 -1
  185. package/dist/interactive/bridge-pool.d.ts +67 -3
  186. package/dist/interactive/bridge-pool.d.ts.map +1 -1
  187. package/dist/interactive/bridge-pool.js +129 -13
  188. package/dist/interactive/bridge-pool.js.map +1 -1
  189. package/dist/interactive/bridge-root.d.ts +9 -0
  190. package/dist/interactive/bridge-root.d.ts.map +1 -1
  191. package/dist/interactive/bridge-root.js +11 -4
  192. package/dist/interactive/bridge-root.js.map +1 -1
  193. package/dist/interactive/chat-events.d.ts +14 -9
  194. package/dist/interactive/chat-events.d.ts.map +1 -1
  195. package/dist/interactive/chat-events.js +55 -57
  196. package/dist/interactive/chat-events.js.map +1 -1
  197. package/dist/interactive/council-outcome.d.ts +1 -0
  198. package/dist/interactive/council-outcome.d.ts.map +1 -1
  199. package/dist/interactive/council-outcome.js +33 -0
  200. package/dist/interactive/council-outcome.js.map +1 -1
  201. package/dist/interactive/draft-events.d.ts +36 -17
  202. package/dist/interactive/draft-events.d.ts.map +1 -1
  203. package/dist/interactive/draft-events.js +121 -92
  204. package/dist/interactive/draft-events.js.map +1 -1
  205. package/dist/interactive/draft-skill.d.ts +59 -0
  206. package/dist/interactive/draft-skill.d.ts.map +1 -1
  207. package/dist/interactive/draft-skill.js +233 -0
  208. package/dist/interactive/draft-skill.js.map +1 -1
  209. package/dist/interactive/edit-events.d.ts +1 -14
  210. package/dist/interactive/edit-events.d.ts.map +1 -1
  211. package/dist/interactive/edit-events.js +37 -70
  212. package/dist/interactive/edit-events.js.map +1 -1
  213. package/dist/interactive/proxy-routes.d.ts +2 -2
  214. package/dist/interactive/proxy-routes.d.ts.map +1 -1
  215. package/dist/interactive/proxy-routes.js +4 -13
  216. package/dist/interactive/proxy-routes.js.map +1 -1
  217. package/dist/interactive/ws-relay.d.ts +9 -10
  218. package/dist/interactive/ws-relay.d.ts.map +1 -1
  219. package/dist/interactive/ws-relay.js +23 -50
  220. package/dist/interactive/ws-relay.js.map +1 -1
  221. package/dist/mcp/broker.d.ts +88 -0
  222. package/dist/mcp/broker.d.ts.map +1 -0
  223. package/dist/mcp/broker.js +307 -0
  224. package/dist/mcp/broker.js.map +1 -0
  225. package/dist/mcp/call-records.d.ts +61 -0
  226. package/dist/mcp/call-records.d.ts.map +1 -0
  227. package/dist/mcp/call-records.js +135 -0
  228. package/dist/mcp/call-records.js.map +1 -0
  229. package/dist/mcp/classify.d.ts +45 -0
  230. package/dist/mcp/classify.d.ts.map +1 -0
  231. package/dist/mcp/classify.js +83 -0
  232. package/dist/mcp/classify.js.map +1 -0
  233. package/dist/mcp/discovery.d.ts +24 -0
  234. package/dist/mcp/discovery.d.ts.map +1 -0
  235. package/dist/mcp/discovery.js +78 -0
  236. package/dist/mcp/discovery.js.map +1 -0
  237. package/dist/mcp/invoke.d.ts +36 -0
  238. package/dist/mcp/invoke.d.ts.map +1 -0
  239. package/dist/mcp/invoke.js +80 -0
  240. package/dist/mcp/invoke.js.map +1 -0
  241. package/dist/mcp/policies.d.ts +110 -0
  242. package/dist/mcp/policies.d.ts.map +1 -0
  243. package/dist/mcp/policies.js +400 -0
  244. package/dist/mcp/policies.js.map +1 -0
  245. package/dist/mcp/probe.d.ts +66 -0
  246. package/dist/mcp/probe.d.ts.map +1 -0
  247. package/dist/mcp/probe.js +116 -0
  248. package/dist/mcp/probe.js.map +1 -0
  249. package/dist/mcp/redact.d.ts +34 -0
  250. package/dist/mcp/redact.d.ts.map +1 -0
  251. package/dist/mcp/redact.js +84 -0
  252. package/dist/mcp/redact.js.map +1 -0
  253. package/dist/mcp/registry-store.d.ts +69 -0
  254. package/dist/mcp/registry-store.d.ts.map +1 -0
  255. package/dist/mcp/registry-store.js +82 -0
  256. package/dist/mcp/registry-store.js.map +1 -0
  257. package/dist/mcp/registry.d.ts +147 -0
  258. package/dist/mcp/registry.d.ts.map +1 -0
  259. package/dist/mcp/registry.js +509 -0
  260. package/dist/mcp/registry.js.map +1 -0
  261. package/dist/mcp/rest.d.ts +111 -0
  262. package/dist/mcp/rest.d.ts.map +1 -0
  263. package/dist/mcp/rest.js +606 -0
  264. package/dist/mcp/rest.js.map +1 -0
  265. package/dist/mcp/secrets.d.ts +66 -0
  266. package/dist/mcp/secrets.d.ts.map +1 -0
  267. package/dist/mcp/secrets.js +180 -0
  268. package/dist/mcp/secrets.js.map +1 -0
  269. package/dist/mcp/tool-list.d.ts +25 -0
  270. package/dist/mcp/tool-list.d.ts.map +1 -0
  271. package/dist/mcp/tool-list.js +62 -0
  272. package/dist/mcp/tool-list.js.map +1 -0
  273. package/dist/mcp/upstream-error.d.ts +12 -0
  274. package/dist/mcp/upstream-error.d.ts.map +1 -0
  275. package/dist/mcp/upstream-error.js +14 -0
  276. package/dist/mcp/upstream-error.js.map +1 -0
  277. package/dist/mcp/usage.d.ts +31 -0
  278. package/dist/mcp/usage.d.ts.map +1 -0
  279. package/dist/mcp/usage.js +159 -0
  280. package/dist/mcp/usage.js.map +1 -0
  281. package/dist/presets/routes.d.ts +53 -0
  282. package/dist/presets/routes.d.ts.map +1 -0
  283. package/dist/presets/routes.js +115 -0
  284. package/dist/presets/routes.js.map +1 -0
  285. package/dist/projects/activity.d.ts +6 -18
  286. package/dist/projects/activity.d.ts.map +1 -1
  287. package/dist/projects/activity.js +17 -60
  288. package/dist/projects/activity.js.map +1 -1
  289. package/dist/projects/events.d.ts +6 -5
  290. package/dist/projects/events.d.ts.map +1 -1
  291. package/dist/projects/events.js +33 -58
  292. package/dist/projects/events.js.map +1 -1
  293. package/dist/projects/routes.d.ts.map +1 -1
  294. package/dist/projects/routes.js +19 -0
  295. package/dist/projects/routes.js.map +1 -1
  296. package/dist/projects/state-home-preflight.d.ts.map +1 -1
  297. package/dist/projects/state-home-preflight.js +7 -0
  298. package/dist/projects/state-home-preflight.js.map +1 -1
  299. package/dist/projects/state-home-registry.d.ts.map +1 -1
  300. package/dist/projects/state-home-registry.js +9 -1
  301. package/dist/projects/state-home-registry.js.map +1 -1
  302. package/dist/qe/acceptance.d.ts +28 -28
  303. package/dist/qe/acceptance.d.ts.map +1 -1
  304. package/dist/qe/acceptance.js +60 -61
  305. package/dist/qe/acceptance.js.map +1 -1
  306. package/dist/qe/test-sets.d.ts +3 -5
  307. package/dist/qe/test-sets.d.ts.map +1 -1
  308. package/dist/qe/test-sets.js +5 -7
  309. package/dist/qe/test-sets.js.map +1 -1
  310. package/dist/skills/installed.d.ts +51 -0
  311. package/dist/skills/installed.d.ts.map +1 -0
  312. package/dist/skills/installed.js +46 -0
  313. package/dist/skills/installed.js.map +1 -0
  314. package/dist/standing-orders/evaluator.d.ts +113 -0
  315. package/dist/standing-orders/evaluator.d.ts.map +1 -0
  316. package/dist/standing-orders/evaluator.js +225 -0
  317. package/dist/standing-orders/evaluator.js.map +1 -0
  318. package/dist/standing-orders/history.d.ts +58 -0
  319. package/dist/standing-orders/history.d.ts.map +1 -0
  320. package/dist/standing-orders/history.js +117 -0
  321. package/dist/standing-orders/history.js.map +1 -0
  322. package/dist/standing-orders/parse.d.ts +19 -0
  323. package/dist/standing-orders/parse.d.ts.map +1 -0
  324. package/dist/standing-orders/parse.js +75 -0
  325. package/dist/standing-orders/parse.js.map +1 -0
  326. package/dist/standing-orders/routes.d.ts +180 -0
  327. package/dist/standing-orders/routes.d.ts.map +1 -0
  328. package/dist/standing-orders/routes.js +95 -0
  329. package/dist/standing-orders/routes.js.map +1 -0
  330. package/dist/standing-orders/store.d.ts +154 -0
  331. package/dist/standing-orders/store.d.ts.map +1 -0
  332. package/dist/standing-orders/store.js +189 -0
  333. package/dist/standing-orders/store.js.map +1 -0
  334. package/dist/studio/assets/index-CvV5qITf.css +32 -0
  335. package/dist/studio/assets/index-jCOy6Ns7.js +568 -0
  336. package/dist/studio/index.html +3 -3
  337. package/dist/studio/testid-inventory.json +3274 -894
  338. package/dist/team/key.d.ts +5 -0
  339. package/dist/team/key.d.ts.map +1 -0
  340. package/dist/team/key.js +21 -0
  341. package/dist/team/key.js.map +1 -0
  342. package/dist/team/routes.d.ts +196 -0
  343. package/dist/team/routes.d.ts.map +1 -0
  344. package/dist/team/routes.js +274 -0
  345. package/dist/team/routes.js.map +1 -0
  346. package/dist/team/ws-relay.d.ts +39 -0
  347. package/dist/team/ws-relay.d.ts.map +1 -0
  348. package/dist/team/ws-relay.js +63 -0
  349. package/dist/team/ws-relay.js.map +1 -0
  350. package/endpoint-manifest.json +502 -6
  351. package/package.json +6 -6
  352. package/dist/interactive/demo-events.d.ts +0 -367
  353. package/dist/interactive/demo-events.d.ts.map +0 -1
  354. package/dist/interactive/demo-events.js +0 -1293
  355. package/dist/interactive/demo-events.js.map +0 -1
  356. package/dist/qe/gate-events.d.ts +0 -113
  357. package/dist/qe/gate-events.d.ts.map +0 -1
  358. package/dist/qe/gate-events.js +0 -172
  359. package/dist/qe/gate-events.js.map +0 -1
  360. package/dist/studio/assets/index-Bg7Z3BR-.css +0 -32
  361. package/dist/studio/assets/index-BvOFMjf9.js +0 -554
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Launch-time resolution of the issues a run's intent links (crew#627).
3
+ *
4
+ * A governed worker cannot read GitHub: its environment carries no `gh` login (the daemon's own is
5
+ * deliberately not inherited, and the engine's fence refuses `gh api` and the token variables), so
6
+ * `gh issue view <n>` exits 4 and the worker guesses, or reads the public page through WebFetch
7
+ * (nothing on a private repository, no comments beyond the page). The daemon CAN read them, under
8
+ * its own identity, before the run starts. So at launch every `#N` / `owner/repo#N` / issue URL the
9
+ * intent names is read with `gh issue view --json` and its title, state, body and comments are
10
+ * appended to the problem the engine plans from, inside one marked block. What could not be read
11
+ * is said in that block and in the launch answer, never skipped silently.
12
+ *
13
+ * The block is fenced by {@link LINKED_ISSUES_OPEN} / {@link LINKED_ISSUES_CLOSE} so the deliver
14
+ * text can take it back out ({@link stripLinkedIssues}): a PR body names the intent, not the issue
15
+ * text the daemon attached to it.
16
+ */
17
+ import { issueRefs } from './deliver-text.js';
18
+ import { defaultGhExec } from './deliver.js';
19
+ export const LINKED_ISSUES_OPEN = '<!-- wicked-crew:linked-issues -->';
20
+ export const LINKED_ISSUES_CLOSE = '<!-- /wicked-crew:linked-issues -->';
21
+ /** At most this many issues are read per launch; the rest are named as not read. */
22
+ export const MAX_LINKED_ISSUES = 5;
23
+ /** Per-issue `gh` bound — the launch answer waits on these, in parallel. */
24
+ export const LINKED_ISSUE_TIMEOUT_MS = 5_000;
25
+ const BODY_CAP = 6_000;
26
+ const COMMENT_CAP = 1_500;
27
+ const MAX_COMMENTS = 10;
28
+ function capped(text, max) {
29
+ const t = text.replace(/\r\n?/g, '\n').trim();
30
+ return t.length <= max ? t : `${t.slice(0, max).trimEnd()}\n_(cut at ${max} characters)_`;
31
+ }
32
+ /** `#N` → `[N]`; `owner/repo#N` → `[N, '-R', owner/repo]`; an owner-less `repo#N` → null. */
33
+ function ghTarget(ref) {
34
+ const m = /^(?:([\w.-]+\/[\w.-]+))?#(\d+)$/.exec(ref);
35
+ if (m === null)
36
+ return null;
37
+ return m[1] === undefined ? [m[2]] : [m[2], '-R', m[1]];
38
+ }
39
+ async function readOne(ref, cwd, exec) {
40
+ const target = ghTarget(ref);
41
+ const fail = (error) => ({
42
+ issue: { ref, resolved: false, error },
43
+ text: `### ${ref}: could not be read (${error})`,
44
+ });
45
+ if (target === null)
46
+ return fail('no owner/repo to read it from');
47
+ if (target.length === 1 && cwd === undefined)
48
+ return fail('the run has no repository to read it from');
49
+ let out;
50
+ try {
51
+ out = await exec(['issue', 'view', ...target, '--json', 'title,state,body,url,comments'], {
52
+ cwd: cwd ?? process.cwd(),
53
+ timeoutMs: LINKED_ISSUE_TIMEOUT_MS,
54
+ });
55
+ }
56
+ catch (err) {
57
+ return fail(`gh: ${err instanceof Error ? err.message : String(err)}`);
58
+ }
59
+ if (out.code !== 0) {
60
+ const why = (out.stderr || out.stdout).trim().split('\n').slice(-1)[0]?.slice(0, 200) ?? '';
61
+ return fail(`gh ${out.code === null ? 'timed out or could not be spawned' : `exit ${out.code}`}${why !== '' ? `: ${why}` : ''}`);
62
+ }
63
+ let parsed;
64
+ try {
65
+ parsed = JSON.parse(out.stdout);
66
+ }
67
+ catch {
68
+ return fail('gh did not answer the JSON asked for');
69
+ }
70
+ const title = typeof parsed.title === 'string' ? parsed.title.replace(/\s+/g, ' ').trim() : '';
71
+ if (title === '')
72
+ return fail('gh answered no title');
73
+ const state = typeof parsed.state === 'string' ? ` (${parsed.state})` : '';
74
+ const body = typeof parsed.body === 'string' && parsed.body.trim() !== '' ? capped(parsed.body, BODY_CAP) : '_(no description)_';
75
+ const lines = [`### ${ref}: ${title}${state}`, '', body];
76
+ const comments = Array.isArray(parsed.comments) ? parsed.comments : [];
77
+ if (comments.length > 0) {
78
+ lines.push('', `Comments (${comments.length}${comments.length > MAX_COMMENTS ? `, the last ${MAX_COMMENTS} shown` : ''}):`);
79
+ for (const c of comments.slice(-MAX_COMMENTS)) {
80
+ const who = typeof c?.author?.login === 'string' ? c.author.login : 'unknown';
81
+ const text = typeof c?.body === 'string' ? capped(c.body, COMMENT_CAP) : '';
82
+ lines.push('', `- ${who}: ${text.replace(/\n/g, '\n ')}`);
83
+ }
84
+ }
85
+ return { issue: { ref, resolved: true, title }, text: lines.join('\n') };
86
+ }
87
+ /**
88
+ * Read every issue `problem` names (at most {@link MAX_LINKED_ISSUES}) through `gh`, in `repoRoot`
89
+ * for a same-repository `#N`. Never throws: an unreadable issue is a `resolved: false` entry.
90
+ */
91
+ export async function resolveLinkedIssues(problem, repoRoot, repoRef, exec = defaultGhExec) {
92
+ const { fixes, refs } = issueRefs(stripLinkedIssues(problem), repoRef ?? null);
93
+ const all = [...fixes, ...refs];
94
+ if (all.length === 0)
95
+ return { issues: [], block: null };
96
+ const read = await Promise.all(all.slice(0, MAX_LINKED_ISSUES).map((ref) => readOne(ref, repoRoot, exec)));
97
+ const skipped = all.slice(MAX_LINKED_ISSUES).map((ref) => ({
98
+ ref,
99
+ resolved: false,
100
+ error: `not read: a launch reads at most ${MAX_LINKED_ISSUES} issues`,
101
+ }));
102
+ const sections = read.map((r) => r.text);
103
+ if (skipped.length > 0)
104
+ sections.push(`Not read (a launch reads at most ${MAX_LINKED_ISSUES} issues): ${skipped.map((s) => s.ref).join(', ')}`);
105
+ const block = [
106
+ LINKED_ISSUES_OPEN,
107
+ '## Linked issues (read by the daemon at launch)',
108
+ '',
109
+ sections.join('\n\n'),
110
+ LINKED_ISSUES_CLOSE,
111
+ ].join('\n');
112
+ return { issues: [...read.map((r) => r.issue), ...skipped], block };
113
+ }
114
+ /** `problem` with the daemon's linked-issues block (if any) taken back out. */
115
+ export function stripLinkedIssues(problem) {
116
+ const at = problem.indexOf(LINKED_ISSUES_OPEN);
117
+ if (at === -1)
118
+ return problem;
119
+ const end = problem.indexOf(LINKED_ISSUES_CLOSE, at);
120
+ const tail = end === -1 ? '' : problem.slice(end + LINKED_ISSUES_CLOSE.length);
121
+ return `${problem.slice(0, at)}${tail}`.trimEnd();
122
+ }
123
+ //# sourceMappingURL=linked-iss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CAAC,IAAI,CAAC,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC;AACtE,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC/C,IAAI,EAAE,KAAK,CAAC,CAAC;QAAE,OAAO,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC/E,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;AACpD,CAAC"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * "What is this run?" — the ONE resolver (seam X2), read from the engine's own record.
3
+ *
4
+ * The engine stores a synthetic `workflow_id` on every run it launches (`wf-<run>`), so the name a
5
+ * run was launched under is not on the session's `workflow_id`. Crew used to recover it by matching
6
+ * the run's unit sequence against its mirrors of the built-in defs — which stops matching the moment
7
+ * the engine's floor adds a step to a preset run, never matched a user plan (`<run>:plan-<rev>`),
8
+ * and cannot survive the mirrors being deleted. This module replaces that guess with what the
9
+ * engine RECORDED:
10
+ *
11
+ * 1. `AgentSession.team_plan` (wicked-core `TeamPlanState`, DES-TEAMING-002 §8.4) — present on a
12
+ * run launched from a plan or a preset. `team_plan.preset` names the preset; absent, the run
13
+ * is a USER PLAN.
14
+ * 2. The launch's `sessionStarted` frame in the engine's durable run event log (`workflowId`):
15
+ * the preset name, the registered def id, the per-run plan def (`<run>:plan-<rev>`) or `null`
16
+ * for a free-text run. The adapter reads it once per run and memoizes it (`launched` below);
17
+ * this is the only record of a NON-team run's def, because the session keeps only `wf-<run>`.
18
+ * 3. A session whose `workflow_id` is not synthetic already names its def.
19
+ *
20
+ * Each unit's catalog id (`WorkUnit.catalog`, stamped by the engine on a catalog-composed plan) is
21
+ * carried as-is. Nothing here reads unit ids or phase sequences.
22
+ *
23
+ * SYSTEM classification lives here too, in ONE list keyed by preset/workflow name: the runs studio
24
+ * keeps off its delivery surfaces (chat, onboarding, the interactive seams, …). The served run
25
+ * carries it as `run_identity.system`, and `listWorkflows()` stamps the defs' `is_system` from the
26
+ * same list, so the two can no longer disagree.
27
+ */
28
+ import type { RunIdentity, SessionView, WorkflowDef } from './types.js';
29
+ /**
30
+ * The machine-owned workflows and presets — keyed by NAME, so a preset and the def it replaces
31
+ * classify alike (`chat` and `onboarding` are engine built-in presets since DES-TEAMING-002
32
+ * M3/M4). Studio hides these from its delivery surfaces and its work-mode selector;
33
+ * `GET /workflows` serves `is_system: true` for exactly these ids, and `GET /presets` serves
34
+ * `system: true` for a preset of one of these names.
35
+ */
36
+ export declare const SYSTEM_WORKFLOWS: ReadonlySet<string>;
37
+ /** Whether a preset/workflow name is a system one ({@link SYSTEM_WORKFLOWS}). */
38
+ export declare function isSystemWorkflow(name: string | null | undefined): boolean;
39
+ /**
40
+ * A def with its `is_system` flag set from {@link SYSTEM_WORKFLOWS} — the ONE source of the flag.
41
+ * Returns the same object when it already agrees (a registered def's own `is_system` is not a
42
+ * second source: it is overwritten either way).
43
+ */
44
+ export declare function withSystemFlag<T extends WorkflowDef>(def: T): T;
45
+ /**
46
+ * A preset with its `system` flag set from {@link SYSTEM_WORKFLOWS} — the preset's half of the one
47
+ * classification (DES-TEAMING-002 §11.3: delivery classification reads the preset's system flag
48
+ * where it read the def's `is_system`).
49
+ */
50
+ export declare function withPresetSystemFlag<T extends {
51
+ name: string;
52
+ }>(preset: T): T & {
53
+ system: boolean;
54
+ };
55
+ /**
56
+ * The run a per-run plan def id belongs to — `<run>:plan-<rev>`, `rev` a positive decimal
57
+ * (wicked-core `plan::per_run_def_run_id`, the same reserved shape). `null` for any other id.
58
+ */
59
+ export declare function perRunPlanRunId(defId: string): string | null;
60
+ /** The engine's synthetic instance id — a session that carries it does not name its def. */
61
+ export declare function isSyntheticWorkflowId(workflowId: string): boolean;
62
+ /** What the resolver answers: the wire identity plus each unit's catalog id, in `ord` order. */
63
+ export interface ResolvedRun extends RunIdentity {
64
+ /** `WorkUnit.catalog` per unit, ordered by `ord` — `null` for a unit not planned from the catalog. */
65
+ catalog: Array<string | null>;
66
+ }
67
+ /**
68
+ * Resolve a run from its record.
69
+ *
70
+ * `launched` is the launch's `sessionStarted.workflowId` from the engine's event log: `undefined`
71
+ * when it is not known (no log binding, a run predating the log, or a caller that has none),
72
+ * `null` when the launch named nothing (a free-text run). Pure.
73
+ */
74
+ export declare function resolveRunIdentity(view: SessionView, launched?: string | null): ResolvedRun;
75
+ /** The wire half of a resolution (`AgentSession.run_identity`): the identity without the catalog. */
76
+ export declare function wireIdentity(resolved: ResolvedRun): RunIdentity;
77
+ /**
78
+ * The identity of a served run view: the one the adapter attached (`session.run_identity`, which
79
+ * the event-log read informed), else resolved from the record alone. Every caller asking "what is
80
+ * this run?" goes through here.
81
+ */
82
+ export declare function runIdentityOf(view: SessionView): ResolvedRun;
83
+ /** The run's preset or workflow NAME (`null` for a user plan, a free-text run, or an unknown one). */
84
+ export declare function runNameOf(view: SessionView): string | null;
85
+ /**
86
+ * The registered def carrying the run's name, for callers that read def fields (acceptance,
87
+ * delivery candidacy, the deliver text). `null` when the run has no name or the registry holds no
88
+ * def under it. A lookup BY NAME — never by phase sequence.
89
+ */
90
+ export declare function runWorkflowDef(view: SessionView, workflows: WorkflowDef[]): WorkflowDef | null;
91
+ /**
92
+ * The catalog ids whose entry declares `verified_evidence`, from `Core.catalog()`'s entries —
93
+ * `null` when the catalog does not carry the flag (an older engine), so no caller mistakes "not
94
+ * said" for "none".
95
+ */
96
+ export declare function verifiedEvidenceCatalog(entries: ReadonlyArray<{
97
+ id: string;
98
+ verified_evidence?: boolean;
99
+ }>): ReadonlySet<string> | null;
100
+ //# sourceMappingURL=run-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-identity.d.ts","sourceRoot":"","sources":["../../src/core/run-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGxE;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAY/C,CAAC;AAEH,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,WAAW,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAO/D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAEnG;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK5D;AAED,4FAA4F;AAC5F,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED,gGAAgG;AAChG,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C,sGAAsG;IACtG,OAAO,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC/B;AAgBD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,CAK3F;AA2BD,qGAAqG;AACrG,wBAAgB,YAAY,CAAC,QAAQ,EAAE,WAAW,GAAG,WAAW,CAE/D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW,CAK5D;AAED,sGAAsG;AACtG,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAE1D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,WAAW,GAAG,IAAI,CAI9F;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,aAAa,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAGvI"}
@@ -0,0 +1,178 @@
1
+ /**
2
+ * "What is this run?" — the ONE resolver (seam X2), read from the engine's own record.
3
+ *
4
+ * The engine stores a synthetic `workflow_id` on every run it launches (`wf-<run>`), so the name a
5
+ * run was launched under is not on the session's `workflow_id`. Crew used to recover it by matching
6
+ * the run's unit sequence against its mirrors of the built-in defs — which stops matching the moment
7
+ * the engine's floor adds a step to a preset run, never matched a user plan (`<run>:plan-<rev>`),
8
+ * and cannot survive the mirrors being deleted. This module replaces that guess with what the
9
+ * engine RECORDED:
10
+ *
11
+ * 1. `AgentSession.team_plan` (wicked-core `TeamPlanState`, DES-TEAMING-002 §8.4) — present on a
12
+ * run launched from a plan or a preset. `team_plan.preset` names the preset; absent, the run
13
+ * is a USER PLAN.
14
+ * 2. The launch's `sessionStarted` frame in the engine's durable run event log (`workflowId`):
15
+ * the preset name, the registered def id, the per-run plan def (`<run>:plan-<rev>`) or `null`
16
+ * for a free-text run. The adapter reads it once per run and memoizes it (`launched` below);
17
+ * this is the only record of a NON-team run's def, because the session keeps only `wf-<run>`.
18
+ * 3. A session whose `workflow_id` is not synthetic already names its def.
19
+ *
20
+ * Each unit's catalog id (`WorkUnit.catalog`, stamped by the engine on a catalog-composed plan) is
21
+ * carried as-is. Nothing here reads unit ids or phase sequences.
22
+ *
23
+ * SYSTEM classification lives here too, in ONE list keyed by preset/workflow name: the runs studio
24
+ * keeps off its delivery surfaces (chat, onboarding, the interactive seams, …). The served run
25
+ * carries it as `run_identity.system`, and `listWorkflows()` stamps the defs' `is_system` from the
26
+ * same list, so the two can no longer disagree.
27
+ */
28
+ import { baseWorkflowId } from './deliver-text.js';
29
+ /**
30
+ * The machine-owned workflows and presets — keyed by NAME, so a preset and the def it replaces
31
+ * classify alike (`chat` and `onboarding` are engine built-in presets since DES-TEAMING-002
32
+ * M3/M4). Studio hides these from its delivery surfaces and its work-mode selector;
33
+ * `GET /workflows` serves `is_system: true` for exactly these ids, and `GET /presets` serves
34
+ * `system: true` for a preset of one of these names.
35
+ */
36
+ export const SYSTEM_WORKFLOWS = new Set([
37
+ 'chat',
38
+ 'onboarding',
39
+ 'capture-learnings',
40
+ 'steering-author',
41
+ // The Demo experience's preset (api/demo.ts, studio#373): launched from Demo mode with its demo
42
+ // root, never from a general preset picker; it delivers nothing.
43
+ 'demo',
44
+ // The interactive document seams (`interactive/*-events.ts`).
45
+ 'interactive-chat',
46
+ 'interactive-draft',
47
+ 'interactive-edit',
48
+ ]);
49
+ /** Whether a preset/workflow name is a system one ({@link SYSTEM_WORKFLOWS}). */
50
+ export function isSystemWorkflow(name) {
51
+ return typeof name === 'string' && SYSTEM_WORKFLOWS.has(name);
52
+ }
53
+ /**
54
+ * A def with its `is_system` flag set from {@link SYSTEM_WORKFLOWS} — the ONE source of the flag.
55
+ * Returns the same object when it already agrees (a registered def's own `is_system` is not a
56
+ * second source: it is overwritten either way).
57
+ */
58
+ export function withSystemFlag(def) {
59
+ const system = SYSTEM_WORKFLOWS.has(def.id);
60
+ if (system)
61
+ return def.is_system === true ? def : { ...def, is_system: true };
62
+ if (!('is_system' in def))
63
+ return def;
64
+ const rest = { ...def };
65
+ delete rest.is_system;
66
+ return rest;
67
+ }
68
+ /**
69
+ * A preset with its `system` flag set from {@link SYSTEM_WORKFLOWS} — the preset's half of the one
70
+ * classification (DES-TEAMING-002 §11.3: delivery classification reads the preset's system flag
71
+ * where it read the def's `is_system`).
72
+ */
73
+ export function withPresetSystemFlag(preset) {
74
+ return { ...preset, system: isSystemWorkflow(preset.name) };
75
+ }
76
+ /**
77
+ * The run a per-run plan def id belongs to — `<run>:plan-<rev>`, `rev` a positive decimal
78
+ * (wicked-core `plan::per_run_def_run_id`, the same reserved shape). `null` for any other id.
79
+ */
80
+ export function perRunPlanRunId(defId) {
81
+ const at = defId.lastIndexOf(':plan-');
82
+ if (at <= 0)
83
+ return null;
84
+ const rev = defId.slice(at + ':plan-'.length);
85
+ return /^[1-9]\d*$/.test(rev) ? defId.slice(0, at) : null;
86
+ }
87
+ /** The engine's synthetic instance id — a session that carries it does not name its def. */
88
+ export function isSyntheticWorkflowId(workflowId) {
89
+ return workflowId.startsWith('wf-');
90
+ }
91
+ function teamPlanOf(view) {
92
+ const plan = view.session.team_plan;
93
+ return plan !== null && typeof plan === 'object' ? plan : null;
94
+ }
95
+ function identity(kind, name) {
96
+ return { kind, name, user_plan: kind === 'user_plan', system: isSystemWorkflow(name) };
97
+ }
98
+ /**
99
+ * Resolve a run from its record.
100
+ *
101
+ * `launched` is the launch's `sessionStarted.workflowId` from the engine's event log: `undefined`
102
+ * when it is not known (no log binding, a run predating the log, or a caller that has none),
103
+ * `null` when the launch named nothing (a free-text run). Pure.
104
+ */
105
+ export function resolveRunIdentity(view, launched) {
106
+ const catalog = [...(view.units ?? [])]
107
+ .sort((a, b) => a.ord - b.ord)
108
+ .map((u) => (typeof u.catalog === 'string' && u.catalog !== '' ? u.catalog : null));
109
+ return { ...identityOf(view, launched), catalog };
110
+ }
111
+ function identityOf(view, launched) {
112
+ const s = view.session;
113
+ const plan = teamPlanOf(view);
114
+ if (plan !== null) {
115
+ return typeof plan.preset === 'string' && plan.preset !== ''
116
+ ? identity('preset', plan.preset)
117
+ : identity('user_plan', null);
118
+ }
119
+ const recorded = typeof s.workflow_id === 'string' ? s.workflow_id : '';
120
+ if (recorded !== '' && perRunPlanRunId(recorded) !== null)
121
+ return identity('user_plan', null);
122
+ if (recorded !== '' && !isSyntheticWorkflowId(recorded)) {
123
+ return identity('workflow', baseWorkflowId(recorded, s.id));
124
+ }
125
+ if (launched === undefined)
126
+ return identity('unknown', null);
127
+ if (launched === null || launched === '')
128
+ return identity('free_text', null);
129
+ if (perRunPlanRunId(launched) !== null)
130
+ return identity('user_plan', null);
131
+ // A preset launch whose plan state is not written yet (the planning stub) names its preset here
132
+ // too; its units, once planned, carry catalog ids. Either way the NAME is what callers read.
133
+ const catalogPlanned = (view.units ?? []).some((u) => typeof u.catalog === 'string' || u.team_run === true);
134
+ // A crew-composed per-run def (`<base>-deliver-<run>`, `<base>-verified-<run>`) reads as its base.
135
+ return identity(catalogPlanned ? 'preset' : 'workflow', baseWorkflowId(launched, s.id));
136
+ }
137
+ /** The wire half of a resolution (`AgentSession.run_identity`): the identity without the catalog. */
138
+ export function wireIdentity(resolved) {
139
+ return { kind: resolved.kind, name: resolved.name, user_plan: resolved.user_plan, system: resolved.system };
140
+ }
141
+ /**
142
+ * The identity of a served run view: the one the adapter attached (`session.run_identity`, which
143
+ * the event-log read informed), else resolved from the record alone. Every caller asking "what is
144
+ * this run?" goes through here.
145
+ */
146
+ export function runIdentityOf(view) {
147
+ const attached = view.session.run_identity;
148
+ const resolved = resolveRunIdentity(view);
149
+ if (attached === undefined || attached === null)
150
+ return resolved;
151
+ return { ...attached, catalog: resolved.catalog };
152
+ }
153
+ /** The run's preset or workflow NAME (`null` for a user plan, a free-text run, or an unknown one). */
154
+ export function runNameOf(view) {
155
+ return runIdentityOf(view).name;
156
+ }
157
+ /**
158
+ * The registered def carrying the run's name, for callers that read def fields (acceptance,
159
+ * delivery candidacy, the deliver text). `null` when the run has no name or the registry holds no
160
+ * def under it. A lookup BY NAME — never by phase sequence.
161
+ */
162
+ export function runWorkflowDef(view, workflows) {
163
+ const name = runNameOf(view);
164
+ if (name === null)
165
+ return null;
166
+ return workflows.find((w) => w.id === name) ?? null;
167
+ }
168
+ /**
169
+ * The catalog ids whose entry declares `verified_evidence`, from `Core.catalog()`'s entries —
170
+ * `null` when the catalog does not carry the flag (an older engine), so no caller mistakes "not
171
+ * said" for "none".
172
+ */
173
+ export function verifiedEvidenceCatalog(entries) {
174
+ if (entries.length === 0 || entries.some((e) => typeof e.verified_evidence !== 'boolean'))
175
+ return null;
176
+ return new Set(entries.filter((e) => e.verified_evidence === true).map((e) => e.id));
177
+ }
178
+ //# sourceMappingURL=run-identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-identity.js","sourceRoot":"","sources":["../../src/core/run-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC;IAC3D,MAAM;IACN,YAAY;IACZ,mBAAmB;IACnB,iBAAiB;IACjB,gGAAgG;IAChG,iEAAiE;IACjE,MAAM;IACN,8DAA8D;IAC9D,kBAAkB;IAClB,mBAAmB;IACnB,kBAAkB;CACnB,CAAC,CAAC;AAEH,iFAAiF;AACjF,MAAM,UAAU,gBAAgB,CAAC,IAA+B;IAC9D,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAwB,GAAM;IAC1D,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC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AAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvF,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The daemon's shutdown sequence with a DEADLINE (crew#471).
3
+ *
4
+ * `wicked-crew serve` answered SIGTERM by reaping its bridge children and closing the engine
5
+ * subscription, then exiting. While the engine's actor was busy planning a large launch those
6
+ * steps never finished, so the daemon ignored `pkill` and needed SIGKILL. The steps still run
7
+ * first, best-effort; when they have not finished within the deadline the process exits anyway.
8
+ */
9
+ /** How long the graceful half of a shutdown may take before the process exits regardless. */
10
+ export declare const SHUTDOWN_DEADLINE_MS = 5000;
11
+ /**
12
+ * Run `steps`, then `exit(0)`, and `exit(0)` at `deadlineMs` if the steps are still running.
13
+ * A step that throws never blocks the exit. `exit` is called exactly once.
14
+ */
15
+ export declare function shutdownWithDeadline(steps: () => Promise<void>, exit: (code: number) => void, deadlineMs?: number, warn?: (message: string) => void): void;
16
+ //# sourceMappingURL=shutdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["../../src/core/shutdown.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,6FAA6F;AAC7F,eAAO,MAAM,oBAAoB,OAAQ,CAAC;AAE1C;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAC1B,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAC5B,UAAU,GAAE,MAA6B,EACzC,IAAI,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAA6B,GACvD,IAAI,CAqBN"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The daemon's shutdown sequence with a DEADLINE (crew#471).
3
+ *
4
+ * `wicked-crew serve` answered SIGTERM by reaping its bridge children and closing the engine
5
+ * subscription, then exiting. While the engine's actor was busy planning a large launch those
6
+ * steps never finished, so the daemon ignored `pkill` and needed SIGKILL. The steps still run
7
+ * first, best-effort; when they have not finished within the deadline the process exits anyway.
8
+ */
9
+ /** How long the graceful half of a shutdown may take before the process exits regardless. */
10
+ export const SHUTDOWN_DEADLINE_MS = 5_000;
11
+ /**
12
+ * Run `steps`, then `exit(0)`, and `exit(0)` at `deadlineMs` if the steps are still running.
13
+ * A step that throws never blocks the exit. `exit` is called exactly once.
14
+ */
15
+ export function shutdownWithDeadline(steps, exit, deadlineMs = SHUTDOWN_DEADLINE_MS, warn = (m) => console.warn(m)) {
16
+ let exited = false;
17
+ const done = () => {
18
+ if (exited)
19
+ return;
20
+ exited = true;
21
+ exit(0);
22
+ };
23
+ const timer = setTimeout(() => {
24
+ warn(`[daemon] shutdown steps still running after ${deadlineMs} ms — exiting anyway (crew#471)`);
25
+ done();
26
+ }, deadlineMs);
27
+ timer.unref?.();
28
+ void (async () => {
29
+ try {
30
+ await steps();
31
+ }
32
+ catch {
33
+ /* best-effort: a failed step never blocks the exit */
34
+ }
35
+ clearTimeout(timer);
36
+ done();
37
+ })();
38
+ }
39
+ //# sourceMappingURL=shutdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shutdown.js","sourceRoot":"","sources":["../../src/core/shutdown.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,6FAA6F;AAC7F,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAA0B,EAC1B,IAA4B,EAC5B,aAAqB,oBAAoB,EACzC,OAAkC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAExD,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,MAAM,IAAI,GAAG,GAAS,EAAE;QACtB,IAAI,MAAM;YAAE,OAAO;QACnB,MAAM,GAAG,IAAI,CAAC;QACd,IAAI,CAAC,CAAC,CAAC,CAAC;IACV,CAAC,CAAC;IACF,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;QAC5B,IAAI,CAAC,+CAA+C,UAAU,iCAAiC,CAAC,CAAC;QACjG,IAAI,EAAE,CAAC;IACT,CAAC,EAAE,UAAU,CAAC,CAAC;IACf,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;IAChB,KAAK,CAAC,KAAK,IAAI,EAAE;QACf,IAAI,CAAC;YACH,MAAM,KAAK,EAAE,CAAC;QAChB,CAAC;QAAC,MAAM,CAAC;YACP,sDAAsD;QACxD,CAAC;QACD,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,IAAI,EAAE,CAAC;IACT,CAAC,CAAC,EAAE,CAAC;AACP,CAAC"}
@@ -19,7 +19,13 @@
19
19
  * FINALIZING core-ts `subscribe` seam to a single file (DES-STUDIO-001 §5.2).
20
20
  */
21
21
  export type * from 'wicked-crew-api-types';
22
- import type { SystemSettings } from 'wicked-crew-api-types';
22
+ import type { RunTeamResponse, RunTeamUnit, SystemSettings } from 'wicked-crew-api-types';
23
+ /** `Core.runTeam`'s JSON (DES-TEAMING-002 P1): the persisted half of `GET /runs/:id/team`, before
24
+ * crew joins the bus rows and the folded ledger onto it. */
25
+ export type RunTeamView = Omit<RunTeamResponse, 'units' | 'rows' | 'teamed' | 'transport'> & {
26
+ transport: NonNullable<RunTeamResponse['transport']>;
27
+ units: Array<Omit<RunTeamUnit, 'rows' | 'ledger'>>;
28
+ };
23
29
  import { type BaseSkillPolicy } from '../skills/base-skill.js';
24
30
  /** The run id of the onboarding run started when a repo was registered. */
25
31
  export interface RepoOnboardRef {
@@ -71,6 +77,14 @@ export interface LaunchRunInput {
71
77
  };
72
78
  /** Workflow def id to drive (e.g. `domain-extraction`). Omit ⇒ free-text planning. */
73
79
  workflow?: string;
80
+ /**
81
+ * A USER-COMPOSED plan (DES-TEAMING-002 §8.4, seam T3; `LaunchRunBody.plan`), handed to the
82
+ * engine as `LaunchOptions.planJson`. The engine owns every fact about it (`plan.proposed`, the
83
+ * score, the floor, the approval matrix); crew only forwards the command. Mutually exclusive
84
+ * with `workflow`. The adapter fails CLOSED on an addon without `Core.supportsPlanLaunch` — napi
85
+ * ignores an undeclared field, so an older engine would run the launch unplanned and ungated.
86
+ */
87
+ plan?: import('wicked-crew-api-types').LaunchPlan;
74
88
  /**
75
89
  * Project to file this run into (DES-PROJECT-001 §2.2). The engine attaches the `crew.run`
76
90
  * membership atomically with the launch record; unknown/archived ⇒ the launch fails with no
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mBAAmB,uBAAuB,CAAC;AAE3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEvF,2EAA2E;AAC3E,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,8FAA8F;AAC9F,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE;QAAE,MAAM,EAAE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CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,YAAY,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtD;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,EAAE,IAAI,CAAC;IACf;;;;;;;;;;;;;;OAcG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;CAChC;AAED,+FAA+F;AAC/F,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAE/C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qCAAqC,KAAK,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,oCAAoC,EAAG,UAAmB,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,oCAAoC,IAAI,CAAC;AAEtD;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD;;;;;;;;;OASG;IACH,CAAC,GAAG,EAAE,UAAU,MAAM,EAAE,GAAG,OAAO,CAAC;IACnC;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED,eAAO,MAAM,gBAAgB,EAAE,kBAqB9B,CAAC"}
@@ -64,5 +64,9 @@ export const DEFAULT_SETTINGS = {
64
64
  // shim, signalled only by a /health warning). `baseSkillRef: ''` is the one OFF switch.
65
65
  baseSkillRef: DEFAULT_BASE_SKILL_REF,
66
66
  baseSkillPolicy: 'require',
67
+ // crew#549 — the deliver identity is UNSET by default: no login is baked into crew, and an
68
+ // operator who configures none keeps today's behaviour (the phase pushes as whatever login gh
69
+ // holds, and refuses when gh and git's credential disagree with each other).
70
+ deliverIdentityLogin: '',
67
71
  };
68
72
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;A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