wicked-crew 0.16.13 → 0.17.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 (677) hide show
  1. package/README.md +1 -1
  2. package/dist/api/audit-view.d.ts +24 -0
  3. package/dist/api/audit-view.d.ts.map +1 -0
  4. package/dist/api/audit-view.js +70 -0
  5. package/dist/api/audit-view.js.map +1 -0
  6. package/dist/api/auth.d.ts +42 -2
  7. package/dist/api/auth.d.ts.map +1 -1
  8. package/dist/api/auth.js +157 -18
  9. package/dist/api/auth.js.map +1 -1
  10. package/dist/api/capture.d.ts +12 -59
  11. package/dist/api/capture.d.ts.map +1 -1
  12. package/dist/api/capture.js +9 -17
  13. package/dist/api/capture.js.map +1 -1
  14. package/dist/api/chat-context.d.ts +6 -62
  15. package/dist/api/chat-context.d.ts.map +1 -1
  16. package/dist/api/chat-context.js +6 -12
  17. package/dist/api/chat-context.js.map +1 -1
  18. package/dist/api/chat-mcp.d.ts +37 -0
  19. package/dist/api/chat-mcp.d.ts.map +1 -1
  20. package/dist/api/chat-mcp.js +118 -2
  21. package/dist/api/chat-mcp.js.map +1 -1
  22. package/dist/api/chat-proposals.d.ts +21 -149
  23. package/dist/api/chat-proposals.d.ts.map +1 -1
  24. package/dist/api/chat-proposals.js +2 -4
  25. package/dist/api/chat-proposals.js.map +1 -1
  26. package/dist/api/delivery-assurance.d.ts +3 -1
  27. package/dist/api/delivery-assurance.d.ts.map +1 -1
  28. package/dist/api/delivery-assurance.js +17 -0
  29. package/dist/api/delivery-assurance.js.map +1 -1
  30. package/dist/api/delivery-freeze.d.ts +2 -8
  31. package/dist/api/delivery-freeze.d.ts.map +1 -1
  32. package/dist/api/delivery-freeze.js +2 -4
  33. package/dist/api/delivery-freeze.js.map +1 -1
  34. package/dist/api/eval-sample.d.ts +18 -114
  35. package/dist/api/eval-sample.d.ts.map +1 -1
  36. package/dist/api/eval-sample.js +7 -13
  37. package/dist/api/eval-sample.js.map +1 -1
  38. package/dist/api/governance-steering.d.ts +27 -71
  39. package/dist/api/governance-steering.d.ts.map +1 -1
  40. package/dist/api/governance-steering.js +11 -19
  41. package/dist/api/governance-steering.js.map +1 -1
  42. package/dist/api/mcp.d.ts +159 -199
  43. package/dist/api/mcp.d.ts.map +1 -1
  44. package/dist/api/mcp.js +433 -68
  45. package/dist/api/mcp.js.map +1 -1
  46. package/dist/api/needs.d.ts +10 -0
  47. package/dist/api/needs.d.ts.map +1 -1
  48. package/dist/api/needs.js +77 -0
  49. package/dist/api/needs.js.map +1 -1
  50. package/dist/api/open-path.d.ts +10 -0
  51. package/dist/api/open-path.d.ts.map +1 -1
  52. package/dist/api/open-path.js +58 -1
  53. package/dist/api/open-path.js.map +1 -1
  54. package/dist/api/plan-schema.d.ts +8 -51
  55. package/dist/api/plan-schema.d.ts.map +1 -1
  56. package/dist/api/plan-schema.js +6 -6
  57. package/dist/api/plan-schema.js.map +1 -1
  58. package/dist/api/product.d.ts +3 -22
  59. package/dist/api/product.d.ts.map +1 -1
  60. package/dist/api/product.js +4 -6
  61. package/dist/api/product.js.map +1 -1
  62. package/dist/api/project-aggregates.d.ts +12 -20
  63. package/dist/api/project-aggregates.d.ts.map +1 -1
  64. package/dist/api/project-aggregates.js +3 -3
  65. package/dist/api/project-aggregates.js.map +1 -1
  66. package/dist/api/recording.d.ts +10 -37
  67. package/dist/api/recording.d.ts.map +1 -1
  68. package/dist/api/recording.js +9 -11
  69. package/dist/api/recording.js.map +1 -1
  70. package/dist/api/routes.d.ts +159 -1505
  71. package/dist/api/routes.d.ts.map +1 -1
  72. package/dist/api/routes.js +541 -130
  73. package/dist/api/routes.js.map +1 -1
  74. package/dist/api/seat-images.d.ts +10 -0
  75. package/dist/api/seat-images.d.ts.map +1 -1
  76. package/dist/api/seat-images.js +16 -3
  77. package/dist/api/seat-images.js.map +1 -1
  78. package/dist/api/server-error-body.d.ts +44 -0
  79. package/dist/api/server-error-body.d.ts.map +1 -0
  80. package/dist/api/server-error-body.js +206 -0
  81. package/dist/api/server-error-body.js.map +1 -0
  82. package/dist/api/server.d.ts.map +1 -1
  83. package/dist/api/server.js +176 -3
  84. package/dist/api/server.js.map +1 -1
  85. package/dist/api/skills.d.ts +12 -36
  86. package/dist/api/skills.d.ts.map +1 -1
  87. package/dist/api/skills.js +12 -15
  88. package/dist/api/skills.js.map +1 -1
  89. package/dist/api/system-snapshot.d.ts +1 -5
  90. package/dist/api/system-snapshot.d.ts.map +1 -1
  91. package/dist/api/system-snapshot.js +7 -15
  92. package/dist/api/system-snapshot.js.map +1 -1
  93. package/dist/api/testing.d.ts +29 -50
  94. package/dist/api/testing.d.ts.map +1 -1
  95. package/dist/api/testing.js +7 -13
  96. package/dist/api/testing.js.map +1 -1
  97. package/dist/apps/actions/api-action.d.ts +47 -0
  98. package/dist/apps/actions/api-action.d.ts.map +1 -0
  99. package/dist/apps/actions/api-action.js +135 -0
  100. package/dist/apps/actions/api-action.js.map +1 -0
  101. package/dist/apps/actions/pg-fit.d.ts +27 -0
  102. package/dist/apps/actions/pg-fit.d.ts.map +1 -0
  103. package/dist/apps/actions/pg-fit.js +35 -0
  104. package/dist/apps/actions/pg-fit.js.map +1 -0
  105. package/dist/apps/actions/pg-write.d.ts +84 -0
  106. package/dist/apps/actions/pg-write.d.ts.map +1 -0
  107. package/dist/apps/actions/pg-write.js +161 -0
  108. package/dist/apps/actions/pg-write.js.map +1 -0
  109. package/dist/apps/actions/store.d.ts +109 -0
  110. package/dist/apps/actions/store.d.ts.map +1 -0
  111. package/dist/apps/actions/store.js +182 -0
  112. package/dist/apps/actions/store.js.map +1 -0
  113. package/dist/apps/actions/values.d.ts +59 -0
  114. package/dist/apps/actions/values.d.ts.map +1 -0
  115. package/dist/apps/actions/values.js +315 -0
  116. package/dist/apps/actions/values.js.map +1 -0
  117. package/dist/apps/actions/write-path.d.ts +103 -0
  118. package/dist/apps/actions/write-path.d.ts.map +1 -0
  119. package/dist/apps/actions/write-path.js +576 -0
  120. package/dist/apps/actions/write-path.js.map +1 -0
  121. package/dist/apps/check.d.ts +112 -0
  122. package/dist/apps/check.d.ts.map +1 -0
  123. package/dist/apps/check.js +358 -0
  124. package/dist/apps/check.js.map +1 -0
  125. package/dist/apps/exec/arg-types.d.ts +56 -0
  126. package/dist/apps/exec/arg-types.d.ts.map +1 -0
  127. package/dist/apps/exec/arg-types.js +234 -0
  128. package/dist/apps/exec/arg-types.js.map +1 -0
  129. package/dist/apps/exec/cache.d.ts +46 -0
  130. package/dist/apps/exec/cache.d.ts.map +1 -0
  131. package/dist/apps/exec/cache.js +93 -0
  132. package/dist/apps/exec/cache.js.map +1 -0
  133. package/dist/apps/exec/contract.d.ts +83 -0
  134. package/dist/apps/exec/contract.d.ts.map +1 -0
  135. package/dist/apps/exec/contract.js +220 -0
  136. package/dist/apps/exec/contract.js.map +1 -0
  137. package/dist/apps/exec/executor.d.ts +122 -0
  138. package/dist/apps/exec/executor.d.ts.map +1 -0
  139. package/dist/apps/exec/executor.js +455 -0
  140. package/dist/apps/exec/executor.js.map +1 -0
  141. package/dist/apps/exec/limits.d.ts +25 -0
  142. package/dist/apps/exec/limits.d.ts.map +1 -0
  143. package/dist/apps/exec/limits.js +71 -0
  144. package/dist/apps/exec/limits.js.map +1 -0
  145. package/dist/apps/exec/params.d.ts +34 -0
  146. package/dist/apps/exec/params.d.ts.map +1 -0
  147. package/dist/apps/exec/params.js +97 -0
  148. package/dist/apps/exec/params.js.map +1 -0
  149. package/dist/apps/exec/project.d.ts +67 -0
  150. package/dist/apps/exec/project.d.ts.map +1 -0
  151. package/dist/apps/exec/project.js +299 -0
  152. package/dist/apps/exec/project.js.map +1 -0
  153. package/dist/apps/exec/recall.d.ts +88 -0
  154. package/dist/apps/exec/recall.d.ts.map +1 -0
  155. package/dist/apps/exec/recall.js +301 -0
  156. package/dist/apps/exec/recall.js.map +1 -0
  157. package/dist/apps/exec/source-stage.d.ts +61 -0
  158. package/dist/apps/exec/source-stage.d.ts.map +1 -0
  159. package/dist/apps/exec/source-stage.js +540 -0
  160. package/dist/apps/exec/source-stage.js.map +1 -0
  161. package/dist/apps/exec/sources.d.ts +65 -0
  162. package/dist/apps/exec/sources.d.ts.map +1 -0
  163. package/dist/apps/exec/sources.js +77 -0
  164. package/dist/apps/exec/sources.js.map +1 -0
  165. package/dist/apps/exec/texts.d.ts +140 -0
  166. package/dist/apps/exec/texts.d.ts.map +1 -0
  167. package/dist/apps/exec/texts.js +76 -0
  168. package/dist/apps/exec/texts.js.map +1 -0
  169. package/dist/apps/exec/viewer.d.ts +11 -0
  170. package/dist/apps/exec/viewer.d.ts.map +1 -0
  171. package/dist/apps/exec/viewer.js +26 -0
  172. package/dist/apps/exec/viewer.js.map +1 -0
  173. package/dist/apps/git.d.ts +109 -0
  174. package/dist/apps/git.d.ts.map +1 -0
  175. package/dist/apps/git.js +361 -0
  176. package/dist/apps/git.js.map +1 -0
  177. package/dist/apps/publish/image.d.ts +25 -0
  178. package/dist/apps/publish/image.d.ts.map +1 -0
  179. package/dist/apps/publish/image.js +86 -0
  180. package/dist/apps/publish/image.js.map +1 -0
  181. package/dist/apps/publish/layout.d.ts +41 -0
  182. package/dist/apps/publish/layout.d.ts.map +1 -0
  183. package/dist/apps/publish/layout.js +31 -0
  184. package/dist/apps/publish/layout.js.map +1 -0
  185. package/dist/apps/publish/manifest.d.ts +64 -0
  186. package/dist/apps/publish/manifest.d.ts.map +1 -0
  187. package/dist/apps/publish/manifest.js +282 -0
  188. package/dist/apps/publish/manifest.js.map +1 -0
  189. package/dist/apps/publish/pack.d.ts +40 -0
  190. package/dist/apps/publish/pack.d.ts.map +1 -0
  191. package/dist/apps/publish/pack.js +78 -0
  192. package/dist/apps/publish/pack.js.map +1 -0
  193. package/dist/apps/routes.d.ts +103 -0
  194. package/dist/apps/routes.d.ts.map +1 -0
  195. package/dist/apps/routes.js +440 -0
  196. package/dist/apps/routes.js.map +1 -0
  197. package/dist/apps/spec.d.ts +322 -2640
  198. package/dist/apps/spec.d.ts.map +1 -1
  199. package/dist/apps/spec.js +89 -120
  200. package/dist/apps/spec.js.map +1 -1
  201. package/dist/apps/store.d.ts +341 -0
  202. package/dist/apps/store.d.ts.map +1 -0
  203. package/dist/apps/store.js +905 -0
  204. package/dist/apps/store.js.map +1 -0
  205. package/dist/apps/turns.d.ts +169 -0
  206. package/dist/apps/turns.d.ts.map +1 -0
  207. package/dist/apps/turns.js +556 -0
  208. package/dist/apps/turns.js.map +1 -0
  209. package/dist/apps/views.d.ts +44 -0
  210. package/dist/apps/views.d.ts.map +1 -0
  211. package/dist/apps/views.js +53 -0
  212. package/dist/apps/views.js.map +1 -0
  213. package/dist/campaigns/routes.d.ts +22 -94
  214. package/dist/campaigns/routes.d.ts.map +1 -1
  215. package/dist/campaigns/routes.js +8 -14
  216. package/dist/campaigns/routes.js.map +1 -1
  217. package/dist/cli/apps-check.d.ts +43 -0
  218. package/dist/cli/apps-check.d.ts.map +1 -0
  219. package/dist/cli/apps-check.js +166 -0
  220. package/dist/cli/apps-check.js.map +1 -0
  221. package/dist/cli/index.d.ts.map +1 -1
  222. package/dist/cli/index.js +6 -1
  223. package/dist/cli/index.js.map +1 -1
  224. package/dist/cli/mcp.js +2 -2
  225. package/dist/cli/mcp.js.map +1 -1
  226. package/dist/core/adapter.d.ts +23 -0
  227. package/dist/core/adapter.d.ts.map +1 -1
  228. package/dist/core/adapter.js +49 -1
  229. package/dist/core/adapter.js.map +1 -1
  230. package/dist/core/deliver-text.d.ts +25 -0
  231. package/dist/core/deliver-text.d.ts.map +1 -1
  232. package/dist/core/deliver-text.js +50 -5
  233. package/dist/core/deliver-text.js.map +1 -1
  234. package/dist/core/deliver.d.ts.map +1 -1
  235. package/dist/core/deliver.js +6 -0
  236. package/dist/core/deliver.js.map +1 -1
  237. package/dist/core/estate-mcp-client.d.ts +9 -0
  238. package/dist/core/estate-mcp-client.d.ts.map +1 -1
  239. package/dist/core/estate-mcp-client.js +31 -3
  240. package/dist/core/estate-mcp-client.js.map +1 -1
  241. package/dist/core/linked-issues.d.ts +51 -3
  242. package/dist/core/linked-issues.d.ts.map +1 -1
  243. package/dist/core/linked-issues.js +59 -14
  244. package/dist/core/linked-issues.js.map +1 -1
  245. package/dist/decisions/chat-recorder.js +1 -1
  246. package/dist/decisions/chat-recorder.js.map +1 -1
  247. package/dist/decisions/routes.d.ts.map +1 -1
  248. package/dist/decisions/routes.js +5 -9
  249. package/dist/decisions/routes.js.map +1 -1
  250. package/dist/decisions/rules-brief.d.ts +76 -0
  251. package/dist/decisions/rules-brief.d.ts.map +1 -0
  252. package/dist/decisions/rules-brief.js +179 -0
  253. package/dist/decisions/rules-brief.js.map +1 -0
  254. package/dist/editors/registry.d.ts +97 -258
  255. package/dist/editors/registry.d.ts.map +1 -1
  256. package/dist/editors/registry.js +11 -11
  257. package/dist/editors/registry.js.map +1 -1
  258. package/dist/editors/routes.js +3 -3
  259. package/dist/editors/routes.js.map +1 -1
  260. package/dist/evals/routes.d.ts.map +1 -1
  261. package/dist/evals/routes.js +3 -5
  262. package/dist/evals/routes.js.map +1 -1
  263. package/dist/insights/routes.js +2 -2
  264. package/dist/insights/routes.js.map +1 -1
  265. package/dist/interactive/proxy-routes.d.ts.map +1 -1
  266. package/dist/interactive/proxy-routes.js +76 -7
  267. package/dist/interactive/proxy-routes.js.map +1 -1
  268. package/dist/interactive/ws-relay.d.ts +3 -9
  269. package/dist/interactive/ws-relay.d.ts.map +1 -1
  270. package/dist/interactive/ws-relay.js +4 -6
  271. package/dist/interactive/ws-relay.js.map +1 -1
  272. package/dist/knowledge/adapters/native.d.ts +44 -0
  273. package/dist/knowledge/adapters/native.d.ts.map +1 -0
  274. package/dist/knowledge/adapters/native.js +60 -0
  275. package/dist/knowledge/adapters/native.js.map +1 -0
  276. package/dist/knowledge/adapters/toolbox/binary.d.ts +48 -0
  277. package/dist/knowledge/adapters/toolbox/binary.d.ts.map +1 -0
  278. package/dist/knowledge/adapters/toolbox/binary.js +145 -0
  279. package/dist/knowledge/adapters/toolbox/binary.js.map +1 -0
  280. package/dist/knowledge/adapters/toolbox/catalog.d.ts +22 -0
  281. package/dist/knowledge/adapters/toolbox/catalog.d.ts.map +1 -0
  282. package/dist/knowledge/adapters/toolbox/catalog.js +87 -0
  283. package/dist/knowledge/adapters/toolbox/catalog.js.map +1 -0
  284. package/dist/knowledge/adapters/toolbox/document.d.ts +71 -0
  285. package/dist/knowledge/adapters/toolbox/document.d.ts.map +1 -0
  286. package/dist/knowledge/adapters/toolbox/document.js +165 -0
  287. package/dist/knowledge/adapters/toolbox/document.js.map +1 -0
  288. package/dist/knowledge/adapters/toolbox/supervisor.d.ts +142 -0
  289. package/dist/knowledge/adapters/toolbox/supervisor.d.ts.map +1 -0
  290. package/dist/knowledge/adapters/toolbox/supervisor.js +438 -0
  291. package/dist/knowledge/adapters/toolbox/supervisor.js.map +1 -0
  292. package/dist/knowledge/gate/access.d.ts +36 -0
  293. package/dist/knowledge/gate/access.d.ts.map +1 -0
  294. package/dist/knowledge/gate/access.js +46 -0
  295. package/dist/knowledge/gate/access.js.map +1 -0
  296. package/dist/knowledge/gate/envelope.d.ts +67 -0
  297. package/dist/knowledge/gate/envelope.d.ts.map +1 -0
  298. package/dist/knowledge/gate/envelope.js +96 -0
  299. package/dist/knowledge/gate/envelope.js.map +1 -0
  300. package/dist/knowledge/gate/gate.d.ts +238 -0
  301. package/dist/knowledge/gate/gate.d.ts.map +1 -0
  302. package/dist/knowledge/gate/gate.js +782 -0
  303. package/dist/knowledge/gate/gate.js.map +1 -0
  304. package/dist/knowledge/gate/pg.d.ts +57 -0
  305. package/dist/knowledge/gate/pg.d.ts.map +1 -0
  306. package/dist/knowledge/gate/pg.js +94 -0
  307. package/dist/knowledge/gate/pg.js.map +1 -0
  308. package/dist/knowledge/gate/record.d.ts +77 -0
  309. package/dist/knowledge/gate/record.d.ts.map +1 -0
  310. package/dist/knowledge/gate/record.js +205 -0
  311. package/dist/knowledge/gate/record.js.map +1 -0
  312. package/dist/knowledge/gate/routes.d.ts +38 -0
  313. package/dist/knowledge/gate/routes.d.ts.map +1 -0
  314. package/dist/knowledge/gate/routes.js +102 -0
  315. package/dist/knowledge/gate/routes.js.map +1 -0
  316. package/dist/knowledge/gate/scheduler.d.ts +90 -0
  317. package/dist/knowledge/gate/scheduler.d.ts.map +1 -0
  318. package/dist/knowledge/gate/scheduler.js +224 -0
  319. package/dist/knowledge/gate/scheduler.js.map +1 -0
  320. package/dist/knowledge/gate/sources.d.ts +69 -0
  321. package/dist/knowledge/gate/sources.d.ts.map +1 -0
  322. package/dist/knowledge/gate/sources.js +135 -0
  323. package/dist/knowledge/gate/sources.js.map +1 -0
  324. package/dist/knowledge/package.d.ts +136 -0
  325. package/dist/knowledge/package.d.ts.map +1 -0
  326. package/dist/knowledge/package.js +148 -0
  327. package/dist/knowledge/package.js.map +1 -0
  328. package/dist/knowledge/projector.d.ts +144 -0
  329. package/dist/knowledge/projector.d.ts.map +1 -0
  330. package/dist/knowledge/projector.js +287 -0
  331. package/dist/knowledge/projector.js.map +1 -0
  332. package/dist/knowledge/registry/entry.d.ts +177 -0
  333. package/dist/knowledge/registry/entry.d.ts.map +1 -0
  334. package/dist/knowledge/registry/entry.js +126 -0
  335. package/dist/knowledge/registry/entry.js.map +1 -0
  336. package/dist/knowledge/registry/policy.d.ts +79 -0
  337. package/dist/knowledge/registry/policy.d.ts.map +1 -0
  338. package/dist/knowledge/registry/policy.js +139 -0
  339. package/dist/knowledge/registry/policy.js.map +1 -0
  340. package/dist/knowledge/shapes/code-search.d.ts +55 -0
  341. package/dist/knowledge/shapes/code-search.d.ts.map +1 -0
  342. package/dist/knowledge/shapes/code-search.js +88 -0
  343. package/dist/knowledge/shapes/code-search.js.map +1 -0
  344. package/dist/knowledge/shapes/map.d.ts +25 -0
  345. package/dist/knowledge/shapes/map.d.ts.map +1 -0
  346. package/dist/knowledge/shapes/map.js +187 -0
  347. package/dist/knowledge/shapes/map.js.map +1 -0
  348. package/dist/knowledge/shapes/profile.d.ts +117 -0
  349. package/dist/knowledge/shapes/profile.d.ts.map +1 -0
  350. package/dist/knowledge/shapes/profile.js +264 -0
  351. package/dist/knowledge/shapes/profile.js.map +1 -0
  352. package/dist/knowledge/shapes/routes.d.ts +69 -0
  353. package/dist/knowledge/shapes/routes.d.ts.map +1 -0
  354. package/dist/knowledge/shapes/routes.js +270 -0
  355. package/dist/knowledge/shapes/routes.js.map +1 -0
  356. package/dist/knowledge/shapes/shapes.d.ts +144 -0
  357. package/dist/knowledge/shapes/shapes.d.ts.map +1 -0
  358. package/dist/knowledge/shapes/shapes.js +280 -0
  359. package/dist/knowledge/shapes/shapes.js.map +1 -0
  360. package/dist/knowledge/shapes/verified.d.ts +36 -0
  361. package/dist/knowledge/shapes/verified.d.ts.map +1 -0
  362. package/dist/knowledge/shapes/verified.js +73 -0
  363. package/dist/knowledge/shapes/verified.js.map +1 -0
  364. package/dist/knowledge/summary.d.ts +45 -0
  365. package/dist/knowledge/summary.d.ts.map +1 -0
  366. package/dist/knowledge/summary.js +119 -0
  367. package/dist/knowledge/summary.js.map +1 -0
  368. package/dist/knowledge/trackers/actions.d.ts +55 -0
  369. package/dist/knowledge/trackers/actions.d.ts.map +1 -0
  370. package/dist/knowledge/trackers/actions.js +327 -0
  371. package/dist/knowledge/trackers/actions.js.map +1 -0
  372. package/dist/knowledge/trackers/addresses.d.ts +45 -0
  373. package/dist/knowledge/trackers/addresses.d.ts.map +1 -0
  374. package/dist/knowledge/trackers/addresses.js +59 -0
  375. package/dist/knowledge/trackers/addresses.js.map +1 -0
  376. package/dist/knowledge/trackers/bindings.d.ts +190 -0
  377. package/dist/knowledge/trackers/bindings.d.ts.map +1 -0
  378. package/dist/knowledge/trackers/bindings.js +970 -0
  379. package/dist/knowledge/trackers/bindings.js.map +1 -0
  380. package/dist/knowledge/trackers/gate-pm.d.ts +160 -0
  381. package/dist/knowledge/trackers/gate-pm.d.ts.map +1 -0
  382. package/dist/knowledge/trackers/gate-pm.js +427 -0
  383. package/dist/knowledge/trackers/gate-pm.js.map +1 -0
  384. package/dist/knowledge/trackers/issues.d.ts +69 -0
  385. package/dist/knowledge/trackers/issues.d.ts.map +1 -0
  386. package/dist/knowledge/trackers/issues.js +193 -0
  387. package/dist/knowledge/trackers/issues.js.map +1 -0
  388. package/dist/knowledge/trackers/map.d.ts +23 -0
  389. package/dist/knowledge/trackers/map.d.ts.map +1 -0
  390. package/dist/knowledge/trackers/map.js +130 -0
  391. package/dist/knowledge/trackers/map.js.map +1 -0
  392. package/dist/knowledge/trackers/projector.d.ts +113 -0
  393. package/dist/knowledge/trackers/projector.d.ts.map +1 -0
  394. package/dist/knowledge/trackers/projector.js +274 -0
  395. package/dist/knowledge/trackers/projector.js.map +1 -0
  396. package/dist/knowledge/trackers/routes.d.ts +107 -0
  397. package/dist/knowledge/trackers/routes.d.ts.map +1 -0
  398. package/dist/knowledge/trackers/routes.js +563 -0
  399. package/dist/knowledge/trackers/routes.js.map +1 -0
  400. package/dist/knowledge/trackers/set.d.ts +61 -0
  401. package/dist/knowledge/trackers/set.d.ts.map +1 -0
  402. package/dist/knowledge/trackers/set.js +77 -0
  403. package/dist/knowledge/trackers/set.js.map +1 -0
  404. package/dist/knowledge/trackers/view.d.ts +22 -0
  405. package/dist/knowledge/trackers/view.d.ts.map +1 -0
  406. package/dist/knowledge/trackers/view.js +31 -0
  407. package/dist/knowledge/trackers/view.js.map +1 -0
  408. package/dist/knowledge/trackers/visible.d.ts +9 -0
  409. package/dist/knowledge/trackers/visible.d.ts.map +1 -0
  410. package/dist/knowledge/trackers/visible.js +10 -0
  411. package/dist/knowledge/trackers/visible.js.map +1 -0
  412. package/dist/learn/routes.d.ts +3 -17
  413. package/dist/learn/routes.d.ts.map +1 -1
  414. package/dist/learn/routes.js +4 -6
  415. package/dist/learn/routes.js.map +1 -1
  416. package/dist/mcp/ask-server.d.ts +6 -0
  417. package/dist/mcp/ask-server.d.ts.map +1 -1
  418. package/dist/mcp/ask-server.js +15 -9
  419. package/dist/mcp/ask-server.js.map +1 -1
  420. package/dist/mcp/broker.d.ts +16 -0
  421. package/dist/mcp/broker.d.ts.map +1 -1
  422. package/dist/mcp/broker.js +137 -3
  423. package/dist/mcp/broker.js.map +1 -1
  424. package/dist/mcp/estate-relay.d.ts +50 -2
  425. package/dist/mcp/estate-relay.d.ts.map +1 -1
  426. package/dist/mcp/estate-relay.js +126 -4
  427. package/dist/mcp/estate-relay.js.map +1 -1
  428. package/dist/mcp/invoke.d.ts +12 -1
  429. package/dist/mcp/invoke.d.ts.map +1 -1
  430. package/dist/mcp/invoke.js +5 -2
  431. package/dist/mcp/invoke.js.map +1 -1
  432. package/dist/mcp/probe.d.ts +34 -2
  433. package/dist/mcp/probe.d.ts.map +1 -1
  434. package/dist/mcp/probe.js +51 -9
  435. package/dist/mcp/probe.js.map +1 -1
  436. package/dist/mcp/registry-store.d.ts +91 -0
  437. package/dist/mcp/registry-store.d.ts.map +1 -1
  438. package/dist/mcp/registry-store.js +116 -9
  439. package/dist/mcp/registry-store.js.map +1 -1
  440. package/dist/mcp/registry.d.ts +249 -6
  441. package/dist/mcp/registry.d.ts.map +1 -1
  442. package/dist/mcp/registry.js +735 -35
  443. package/dist/mcp/registry.js.map +1 -1
  444. package/dist/mcp/rest.d.ts +36 -10
  445. package/dist/mcp/rest.d.ts.map +1 -1
  446. package/dist/mcp/rest.js +71 -73
  447. package/dist/mcp/rest.js.map +1 -1
  448. package/dist/mcp/tool-list.d.ts +7 -0
  449. package/dist/mcp/tool-list.d.ts.map +1 -1
  450. package/dist/mcp/tool-list.js +32 -4
  451. package/dist/mcp/tool-list.js.map +1 -1
  452. package/dist/mcp-inspect/routes.d.ts +3 -0
  453. package/dist/mcp-inspect/routes.d.ts.map +1 -1
  454. package/dist/mcp-inspect/routes.js +31 -18
  455. package/dist/mcp-inspect/routes.js.map +1 -1
  456. package/dist/persona/routes.d.ts +14 -69
  457. package/dist/persona/routes.d.ts.map +1 -1
  458. package/dist/persona/routes.js +2 -2
  459. package/dist/persona/routes.js.map +1 -1
  460. package/dist/persona/store.d.ts +13 -40
  461. package/dist/persona/store.d.ts.map +1 -1
  462. package/dist/persona/store.js +9 -11
  463. package/dist/persona/store.js.map +1 -1
  464. package/dist/presets/routes.d.ts +3 -21
  465. package/dist/presets/routes.d.ts.map +1 -1
  466. package/dist/presets/routes.js +5 -7
  467. package/dist/presets/routes.js.map +1 -1
  468. package/dist/projects/repo-guard.d.ts +32 -0
  469. package/dist/projects/repo-guard.d.ts.map +1 -0
  470. package/dist/projects/repo-guard.js +46 -0
  471. package/dist/projects/repo-guard.js.map +1 -0
  472. package/dist/projects/routes.d.ts +16 -44
  473. package/dist/projects/routes.d.ts.map +1 -1
  474. package/dist/projects/routes.js +15 -18
  475. package/dist/projects/routes.js.map +1 -1
  476. package/dist/schedules/routes.d.ts +4 -18
  477. package/dist/schedules/routes.d.ts.map +1 -1
  478. package/dist/schedules/routes.js +4 -6
  479. package/dist/schedules/routes.js.map +1 -1
  480. package/dist/skills/plugin-source.d.ts +6 -5
  481. package/dist/skills/plugin-source.d.ts.map +1 -1
  482. package/dist/skills/plugin-source.js +6 -5
  483. package/dist/skills/plugin-source.js.map +1 -1
  484. package/dist/sources/ask.d.ts +108 -0
  485. package/dist/sources/ask.d.ts.map +1 -0
  486. package/dist/sources/ask.js +251 -0
  487. package/dist/sources/ask.js.map +1 -0
  488. package/dist/sources/catalog/mysql.d.ts +9 -0
  489. package/dist/sources/catalog/mysql.d.ts.map +1 -0
  490. package/dist/sources/catalog/mysql.js +77 -0
  491. package/dist/sources/catalog/mysql.js.map +1 -0
  492. package/dist/sources/catalog/postgres.d.ts +68 -0
  493. package/dist/sources/catalog/postgres.d.ts.map +1 -0
  494. package/dist/sources/catalog/postgres.js +164 -0
  495. package/dist/sources/catalog/postgres.js.map +1 -0
  496. package/dist/sources/catalog/types.d.ts +53 -0
  497. package/dist/sources/catalog/types.d.ts.map +1 -0
  498. package/dist/sources/catalog/types.js +30 -0
  499. package/dist/sources/catalog/types.js.map +1 -0
  500. package/dist/sources/connection-test.d.ts +37 -0
  501. package/dist/sources/connection-test.d.ts.map +1 -0
  502. package/dist/sources/connection-test.js +101 -0
  503. package/dist/sources/connection-test.js.map +1 -0
  504. package/dist/sources/crew-source.d.ts +31 -0
  505. package/dist/sources/crew-source.d.ts.map +1 -0
  506. package/dist/sources/crew-source.js +48 -0
  507. package/dist/sources/crew-source.js.map +1 -0
  508. package/dist/sources/dialer.d.ts +169 -0
  509. package/dist/sources/dialer.d.ts.map +1 -0
  510. package/dist/sources/dialer.js +761 -0
  511. package/dist/sources/dialer.js.map +1 -0
  512. package/dist/sources/drivers/mysql.d.ts +52 -0
  513. package/dist/sources/drivers/mysql.d.ts.map +1 -0
  514. package/dist/sources/drivers/mysql.js +348 -0
  515. package/dist/sources/drivers/mysql.js.map +1 -0
  516. package/dist/sources/drivers/postgres.d.ts +84 -0
  517. package/dist/sources/drivers/postgres.d.ts.map +1 -0
  518. package/dist/sources/drivers/postgres.js +381 -0
  519. package/dist/sources/drivers/postgres.js.map +1 -0
  520. package/dist/sources/drivers/sqlite.d.ts +47 -0
  521. package/dist/sources/drivers/sqlite.d.ts.map +1 -0
  522. package/dist/sources/drivers/sqlite.js +156 -0
  523. package/dist/sources/drivers/sqlite.js.map +1 -0
  524. package/dist/sources/drivers/types.d.ts +79 -0
  525. package/dist/sources/drivers/types.d.ts.map +1 -0
  526. package/dist/sources/drivers/types.js +31 -0
  527. package/dist/sources/drivers/types.js.map +1 -0
  528. package/dist/sources/graphql.d.ts +85 -0
  529. package/dist/sources/graphql.d.ts.map +1 -0
  530. package/dist/sources/graphql.js +155 -0
  531. package/dist/sources/graphql.js.map +1 -0
  532. package/dist/sources/kinds.d.ts +79 -0
  533. package/dist/sources/kinds.d.ts.map +1 -0
  534. package/dist/sources/kinds.js +145 -0
  535. package/dist/sources/kinds.js.map +1 -0
  536. package/dist/sources/policy/allowlists.d.ts +30 -0
  537. package/dist/sources/policy/allowlists.d.ts.map +1 -0
  538. package/dist/sources/policy/allowlists.js +104 -0
  539. package/dist/sources/policy/allowlists.js.map +1 -0
  540. package/dist/sources/policy/index.d.ts +20 -0
  541. package/dist/sources/policy/index.d.ts.map +1 -0
  542. package/dist/sources/policy/index.js +34 -0
  543. package/dist/sources/policy/index.js.map +1 -0
  544. package/dist/sources/policy/mysql.d.ts +21 -0
  545. package/dist/sources/policy/mysql.d.ts.map +1 -0
  546. package/dist/sources/policy/mysql.js +834 -0
  547. package/dist/sources/policy/mysql.js.map +1 -0
  548. package/dist/sources/policy/pg.d.ts +37 -0
  549. package/dist/sources/policy/pg.d.ts.map +1 -0
  550. package/dist/sources/policy/pg.js +572 -0
  551. package/dist/sources/policy/pg.js.map +1 -0
  552. package/dist/sources/policy/sqlite.d.ts +37 -0
  553. package/dist/sources/policy/sqlite.d.ts.map +1 -0
  554. package/dist/sources/policy/sqlite.js +94 -0
  555. package/dist/sources/policy/sqlite.js.map +1 -0
  556. package/dist/sources/policy/types.d.ts +46 -0
  557. package/dist/sources/policy/types.d.ts.map +1 -0
  558. package/dist/sources/policy/types.js +13 -0
  559. package/dist/sources/policy/types.js.map +1 -0
  560. package/dist/sources/routes.d.ts +154 -0
  561. package/dist/sources/routes.d.ts.map +1 -0
  562. package/dist/sources/routes.js +745 -0
  563. package/dist/sources/routes.js.map +1 -0
  564. package/dist/sources/safety/postgres.d.ts +87 -0
  565. package/dist/sources/safety/postgres.d.ts.map +1 -0
  566. package/dist/sources/safety/postgres.js +349 -0
  567. package/dist/sources/safety/postgres.js.map +1 -0
  568. package/dist/sources/sql.d.ts +51 -0
  569. package/dist/sources/sql.d.ts.map +1 -0
  570. package/dist/sources/sql.js +89 -0
  571. package/dist/sources/sql.js.map +1 -0
  572. package/dist/sources/store.d.ts +25 -0
  573. package/dist/sources/store.d.ts.map +1 -0
  574. package/dist/sources/store.js +59 -0
  575. package/dist/sources/store.js.map +1 -0
  576. package/dist/sources/uploads.d.ts +70 -0
  577. package/dist/sources/uploads.d.ts.map +1 -0
  578. package/dist/sources/uploads.js +636 -0
  579. package/dist/sources/uploads.js.map +1 -0
  580. package/dist/standing-orders/parse.d.ts +38 -0
  581. package/dist/standing-orders/parse.d.ts.map +1 -1
  582. package/dist/standing-orders/parse.js +104 -43
  583. package/dist/standing-orders/parse.js.map +1 -1
  584. package/dist/standing-orders/routes.d.ts +25 -126
  585. package/dist/standing-orders/routes.d.ts.map +1 -1
  586. package/dist/standing-orders/routes.js +4 -6
  587. package/dist/standing-orders/routes.js.map +1 -1
  588. package/dist/standing-orders/store.d.ts +22 -73
  589. package/dist/standing-orders/store.d.ts.map +1 -1
  590. package/dist/standing-orders/store.js +8 -12
  591. package/dist/standing-orders/store.js.map +1 -1
  592. package/dist/studio/assets/KnowledgeGraph-Cpm46tEp.js +1 -0
  593. package/dist/studio/assets/WickedSansA-Regular-CGPJLyb8.woff2 +0 -0
  594. package/dist/studio/assets/WickedSansA-SemiBold-Bk9KXUaV.woff2 +0 -0
  595. package/dist/studio/assets/favicon-BJA6hF2f.svg +1 -0
  596. package/dist/studio/assets/index-BRBwWQMH.css +32 -0
  597. package/dist/studio/assets/index-CVrWDGRP.js +1097 -0
  598. package/dist/studio/assets/wicked-studio-lettering-small-CBwSGqop.svg +2 -0
  599. package/dist/studio/assets/wicked-studio-wordmark-small-gF5xn6IC.svg +2 -0
  600. package/dist/studio/editors/wicked-apps/editor.json +45 -0
  601. package/dist/studio/editors/wicked-apps/icon.svg +1 -0
  602. package/dist/studio/editors/wicked-apps/index.html +151 -0
  603. package/dist/studio/editors/wicked-deck/editor.json +1 -1
  604. package/dist/studio/editors/wicked-deck/index.html +12 -8
  605. package/dist/studio/editors/wicked-doc/editor.json +1 -1
  606. package/dist/studio/editors/wicked-doc/index.html +12 -8
  607. package/dist/studio/editors/wicked-insights/editor.json +1 -1
  608. package/dist/studio/editors/wicked-insights/index.html +1 -1
  609. package/dist/studio/editors/wicked-page/editor.json +1 -1
  610. package/dist/studio/editors/wicked-page/index.html +12 -8
  611. package/dist/studio/editors/wicked-video/editor.json +1 -1
  612. package/dist/studio/editors/wicked-video/index.html +1 -1
  613. package/dist/studio/fonts/LICENSE-WickedSans.txt +97 -0
  614. package/dist/studio/index.html +3 -2
  615. package/dist/studio/testid-inventory.json +10850 -6700
  616. package/dist/team/routes.d.ts +21 -172
  617. package/dist/team/routes.d.ts.map +1 -1
  618. package/dist/team/routes.js +4 -8
  619. package/dist/team/routes.js.map +1 -1
  620. package/dist/voice/dashboard.d.ts +35 -313
  621. package/dist/voice/dashboard.d.ts.map +1 -1
  622. package/dist/voice/dashboard.js +10 -10
  623. package/dist/voice/dashboard.js.map +1 -1
  624. package/dist/voice/routes.d.ts +2 -6
  625. package/dist/voice/routes.d.ts.map +1 -1
  626. package/dist/voice/routes.js +2 -2
  627. package/dist/voice/routes.js.map +1 -1
  628. package/dist/watch/checks/check-failed.d.ts +4 -10
  629. package/dist/watch/checks/check-failed.d.ts.map +1 -1
  630. package/dist/watch/checks/check-failed.js +6 -8
  631. package/dist/watch/checks/check-failed.js.map +1 -1
  632. package/dist/watch/checks/claim-vs-evidence.js +3 -3
  633. package/dist/watch/checks/claim-vs-evidence.js.map +1 -1
  634. package/dist/watch/checks/deliver-audit.js +3 -3
  635. package/dist/watch/checks/deliver-audit.js.map +1 -1
  636. package/dist/watch/checks/discovery.d.ts.map +1 -1
  637. package/dist/watch/checks/discovery.js +5 -7
  638. package/dist/watch/checks/discovery.js.map +1 -1
  639. package/dist/watch/checks/lag.d.ts +4 -10
  640. package/dist/watch/checks/lag.d.ts.map +1 -1
  641. package/dist/watch/checks/lag.js +6 -8
  642. package/dist/watch/checks/lag.js.map +1 -1
  643. package/dist/watch/checks/quiet-after-claim.js +3 -3
  644. package/dist/watch/checks/quiet-after-claim.js.map +1 -1
  645. package/dist/watch/checks/scope-drift.js +3 -3
  646. package/dist/watch/checks/scope-drift.js.map +1 -1
  647. package/dist/watch/checks/team-path.js +2 -2
  648. package/dist/watch/checks/team-path.js.map +1 -1
  649. package/dist/watch/checks/ungated.js +3 -3
  650. package/dist/watch/checks/ungated.js.map +1 -1
  651. package/dist/watch/checks/warned-rule.js +3 -3
  652. package/dist/watch/checks/warned-rule.js.map +1 -1
  653. package/dist/watch/loader.d.ts.map +1 -1
  654. package/dist/watch/loader.js +12 -16
  655. package/dist/watch/loader.js.map +1 -1
  656. package/dist/workflow-catalog/build.d.ts +2 -0
  657. package/dist/workflow-catalog/build.d.ts.map +1 -1
  658. package/dist/workflow-catalog/build.js +8 -4
  659. package/dist/workflow-catalog/build.js.map +1 -1
  660. package/dist/workflow-catalog/catalog-data.d.ts +7 -1
  661. package/dist/workflow-catalog/catalog-data.d.ts.map +1 -1
  662. package/dist/workflow-catalog/catalog-data.js +36 -7
  663. package/dist/workflow-catalog/catalog-data.js.map +1 -1
  664. package/dist/working-doc/service.d.ts.map +1 -1
  665. package/dist/working-doc/service.js +2 -1
  666. package/dist/working-doc/service.js.map +1 -1
  667. package/dist/zod.d.ts +39 -0
  668. package/dist/zod.d.ts.map +1 -0
  669. package/dist/zod.js +197 -0
  670. package/dist/zod.js.map +1 -0
  671. package/endpoint-manifest.json +617 -7
  672. package/package.json +10 -5
  673. package/runners/sqlite-runner.mjs +110 -0
  674. package/dist/studio/assets/WickedSans-Regular-fb698rcD.woff2 +0 -0
  675. package/dist/studio/assets/WickedSans-SemiBold-CD53n1AC.woff2 +0 -0
  676. package/dist/studio/assets/index-BUZ_-Syk.css +0 -32
  677. package/dist/studio/assets/index-u4O_7N-b.js +0 -986
@@ -2,7 +2,7 @@ import { REVIEW_WORKFLOW } from '../insights/workflow.js';
2
2
  import { busSeamsOffWarning, busUnavailableWarning } from '../core/bus-notice.js';
3
3
  import { vaultBinWarning, vaultDiagnostics } from '../core/vault-bin.js';
4
4
  import { PlanSchema, toLaunchPlan } from './plan-schema.js';
5
- import { z } from 'zod';
5
+ import { record, z } from '../zod.js';
6
6
  import { listRequirementsRead, getRequirement, patchRequirement, readRequirementsGraph, REQUIREMENTS_NOT_GENERATED, } from './requirements.js';
7
7
  import { randomUUID } from 'node:crypto';
8
8
  import { homedir } from 'node:os';
@@ -11,7 +11,7 @@ import { promises as fsp } from 'node:fs';
11
11
  import { basename, isAbsolute, join, relative, resolve } from 'node:path';
12
12
  import { fileURLToPath } from 'node:url';
13
13
  import { videoPalette } from '../appearance/video-palette.js';
14
- import { CampaignsUnsupportedError, ChatUnsupportedError, CoreAdapter, ElicitationUnsupportedError, GovernanceReplayUnsupportedError, PlanLaunchUnsupportedError, SteeringUnsupportedError, addonSupportsQeOverride, addonSupportsReducedAssurance, humanGatePhaseIds, settingsFilePath } from '../core/adapter.js';
14
+ import { CampaignsUnsupportedError, ChatUnsupportedError, CoreAdapter, ElicitationUnsupportedError, GovernanceReplayUnsupportedError, PlanGateNoteUnsupportedError, PlanLaunchUnsupportedError, SteeringUnsupportedError, addonSupportsQeOverride, addonSupportsReducedAssurance, humanGatePhaseIds, settingsFilePath } from '../core/adapter.js';
15
15
  import { codeGraphDb, codeGraphErrorStatus, repoFolderMissing, repoFolderMissingBody } from '../core/repoPaths.js';
16
16
  import { resolveCursorUnit } from '../core/cursor.js';
17
17
  /** Create `dir` (private) when missing and answer it — a read root must exist when a run launches. */
@@ -43,6 +43,7 @@ import { attemptUnavailableReason, capturedAttempts, outputUnavailableReason, re
43
43
  import { execCapped, ExecOutputTooLarge } from '../core/exec.js';
44
44
  import { callEstateTool, EstateMcpError, ESTATE_INSTALL_HINT, memoryStoreInfo } from '../core/estate-mcp-client.js';
45
45
  import { NO_LEARNINGS_WORKFLOWS } from '../learnings/service.js';
46
+ import { matchRulesForJob, stripRulesBrief, withRulesBrief } from '../decisions/rules-brief.js';
46
47
  import { SeatHealthTracker } from './seat-health.js';
47
48
  import { applyWorkerConfigRoot, signedInHeuristic } from './seat-signin.js';
48
49
  import { applyCouncilSettings, isCouncilSize, isCouncilStaggerMs } from '../core/council-settings.js';
@@ -58,7 +59,7 @@ import { CHAT_ID, chatMakeDigest, ChatScopeIndex, chatScopeDeps, chatScopeStatem
58
59
  import { ASK_TURN_BUDGET_SECS, AskPathIndex, isAskTurn } from './ask-paths.js';
59
60
  import { chatTurnStep, resolveChatWorkflow, servedChatWorkflows, writeCapableStep } from './chat-workflow.js';
60
61
  import { reassignRefusedSeats } from '../core/reassign-refusal.js';
61
- import { allowedRootsFor, isInsideRoot, openWithSystemDefault } from './open-path.js';
62
+ import { allowedRootsFor, isInsideRoot, mayBeInsideRoot, openWithSystemDefault } from './open-path.js';
62
63
  import { InvalidDiffBaseError, MERGE_BASE_LITERAL, NotARegularFileError, UnresolvableDiffBaseError, branchDiff, isGitStopped, isPlainRef, readFileCapped, worktreeDiff, } from './run-files.js';
63
64
  import { DocRunIndex } from '../interactive/doc-run-index.js';
64
65
  import { listInteractiveDocs } from '../interactive/docs-index.js';
@@ -84,8 +85,13 @@ import { gardenRootFor } from '../learn/scheduler.js';
84
85
  import { DEMO_PRESET, demoLaunchRoots, registerDemoDocumentRoute, registerDemoRoutes, registerWalkthroughRoutes, walkthroughAcceptance } from './recording.js';
85
86
  import { projectDocsRoot } from '../interactive/project-root.js';
86
87
  import { registerSkillsRoutes } from './skills.js';
88
+ import { registerSourceRoutes } from '../sources/routes.js';
89
+ import { seatTurn } from '../standing-orders/parse.js';
87
90
  import { registerMcpRoutes } from './mcp.js';
88
- import { chatMcpToolsFor } from './chat-mcp.js';
91
+ import { chatKnowledgeFor, chatMcpToolsFor } from './chat-mcp.js';
92
+ import { registerGateRoutes } from '../knowledge/gate/routes.js';
93
+ import { registerShapeRoutes } from '../knowledge/shapes/routes.js';
94
+ import { STATEMENT_DEADLINE_MS } from '../sources/drivers/types.js';
89
95
  import { McpPolicies } from '../mcp/policies.js';
90
96
  import { disabledSkillsHealth } from '../skills/runtime.js';
91
97
  import { withPhaseSkillGaps } from '../skills/phase-skill-gaps.js';
@@ -121,14 +127,19 @@ import { registerInteractiveDocList } from '../interactive/doc-list-routes.js';
121
127
  import { REVIEWS_DIRNAME } from '../interactive/review-ledger.js';
122
128
  import { MembershipIndex } from '../projects/membership-index.js';
123
129
  import { MEMBERSHIP_ATTACHED, membershipAttachedKey } from '../projects/events.js';
124
- import { resolveLinkedIssues } from '../core/linked-issues.js';
130
+ import { resolveLinkedIssues, stripLinkedIssues } from '../core/linked-issues.js';
131
+ import { reRegisterRefusal } from '../projects/repo-guard.js';
132
+ import { registerTrackerActionRoutes } from '../knowledge/trackers/actions.js';
133
+ import { pmRegistered, readPmIssues } from '../knowledge/trackers/issues.js';
134
+ import { registerTrackerRoutes } from '../knowledge/trackers/routes.js';
125
135
  import { AuditLog } from './audit.js';
136
+ import { auditFor } from './audit-view.js';
126
137
  import { AcpFoldCache, EngineVersionCache, FloorCacheCache, eventsDirOf, installedPackageVersion, hostSandboxLauncher, seatRosterFile, listStoreFiles, readStudioBundleVersion, } from './diagnostics.js';
127
138
  import { GovernanceDiagnostics } from './governance-health.js';
128
139
  import { ATTACHMENT_LIMITS, ATTACHMENT_MAX_MESSAGE_BYTES, AttachmentError, ChatAttachmentStore, attachmentWire, attachmentsBlock, boundaryOf, parseMultipart, stageForSeat } from './chat-attachments.js';
129
140
  import { CHAT_HISTORY_MAX_LIMIT, ChatHistoryStore, decodeCursor } from './chat-history.js';
130
141
  import { PROBE_TIMEOUT_MS, SYSTEM_BUDGET_MS, SYSTEM_STATS_DAYS, SYSTEM_STATS_TTL_MS, WeekFoldCache, assembleSnapshot, buildNeeds, buildClis, buildGovernance, diskRow, estateReadonlyCall, infraRow, judgeGaps, livenessThresholds, loadRow, probeBroker, probeBus, probeEstate, probeGateway, probeInteractive, probeVault, readBridgeLockAsync, readWeek, resolveContainerRuntime, runLiveness, settleWithin, skillsRow, sortRuns, stateHomeRow, reposRow, unfinished, } from './system-snapshot.js';
131
- import { parseSeatImageStatus, probeSeatImages, SeatImageRebuilder } from './seat-images.js';
142
+ import { idleClis, parseSeatImageStatus, probeSeatImages, SeatImageRebuilder } from './seat-images.js';
132
143
  import { RunCostCache } from './needs.js';
133
144
  import { governanceStoreFix, legacyHomeOutboxPath } from '../core/governance-store.js';
134
145
  import { UsageError, replayOutboxInto } from '../cli/governance.js';
@@ -147,7 +158,7 @@ import { GuidanceIndex } from './guidance-index.js';
147
158
  import { DELIVER_REQUESTED_ACTION, DeliveryIndex, gitRunBranchIsEmpty, gitWorktreeIsClean, isDeliverConflictStranded, deliveryRecordFrom, deliverUnitOf, pushedState, canDeliverResolver, FREE_TEXT_NOTICE, freeTextOutcome, } from './delivery-index.js';
148
159
  import { DeliveryDerivationCache } from './delivery-cache.js';
149
160
  import { gitReprovisionWorktree, runDeliverScript, } from './post-hoc-deliver.js';
150
- import { LOCAL_ACTOR, trustAtLeast } from './auth.js';
161
+ import { LOCAL_ACTOR, trustAtLeast, viewOf } from './auth.js';
151
162
  // Re-exported so existing `import { API_PREFIX } from './routes.js'` callers keep working; the
152
163
  // value lives in the leaf module api-prefix.ts to keep unit-output.ts out of this file's cycle.
153
164
  export { API_PREFIX } from './api-prefix.js';
@@ -162,6 +173,11 @@ import { gardenConformance, gardenPackCheck } from '../editors/pack-install.js';
162
173
  import { conformanceProvisioner, conformanceRuntimeRoot } from '../editors/conformance-runtime.js';
163
174
  import { EditorRegistry } from '../editors/registry.js';
164
175
  import { registerEditorRoutes } from '../editors/routes.js';
176
+ import { AppWritePath } from '../apps/actions/write-path.js';
177
+ import { AppExecutor } from '../apps/exec/executor.js';
178
+ import { localViewerOf } from '../apps/exec/viewer.js';
179
+ import { registerAppRoutes } from '../apps/routes.js';
180
+ import { AppStoreError } from '../apps/store.js';
165
181
  import { registerMcpInspectRoutes } from '../mcp-inspect/routes.js';
166
182
  import { discoverLivePlugin } from '../skills/plugin-source.js';
167
183
  import { resolveDecisionsMode } from '../decisions/types.js';
@@ -352,8 +368,7 @@ const RULE_STATUSES = new Set(['active', 'retired', 'all']);
352
368
  // Repo names become directory components under ~/.wicked/repos/ — reject anything
353
369
  // that would allow path traversal (slashes, dots-only segments, control chars).
354
370
  const SAFE_REPO_NAME = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
355
- const RegisterRepoSchema = z
356
- .object({
371
+ export const RegisterRepoSchema = z.strictObject({
357
372
  name: z
358
373
  .string()
359
374
  .min(1)
@@ -372,25 +387,24 @@ const RegisterRepoSchema = z
372
387
  actor: z.string().min(1).max(256).optional(),
373
388
  /** crew#552: `false` = this onboarding chains no capture-learnings run (a one-off). */
374
389
  autoCapture: z.boolean().optional(),
390
+ /** (api-types 0.172.0, DES-APPS-001) A new empty repo under the apps root; no onboarding. */
391
+ create: z.literal(true).optional(),
375
392
  })
376
- .strict()
377
393
  .refine((d) => {
378
394
  const hasRemote = typeof d.gitUrl === 'string' && d.gitUrl.length > 0;
379
395
  const hasLocal = typeof d.rootPath === 'string' && d.rootPath.length > 0;
380
- // gitUrl alone (clone to default path), gitUrl + rootPath (clone to custom path),
381
- // or rootPath alone (register existing local repo) — all valid.
382
- return hasRemote || hasLocal;
383
- }, { message: 'Provide gitUrl (remote clone) or rootPath (local registration), or both.' });
396
+ // create alone (a new empty repo), gitUrl alone (clone to default path), gitUrl + rootPath (clone
397
+ // to custom path), or rootPath alone (register existing local repo) — all valid.
398
+ return d.create === true ? !hasRemote && !hasLocal : hasRemote || hasLocal;
399
+ }, { error: 'Provide create (a new empty repo), or gitUrl (remote clone) or rootPath (local registration), or both of those.' });
384
400
  /** `POST /repos/:id/onboard`'s optional body (crew#496): where to file the run, and who asked. */
385
- const OnboardBodySchema = z
386
- .object({
401
+ const OnboardBodySchema = z.strictObject({
387
402
  projectId: z.string().min(1).max(128).optional(),
388
403
  channel: z.enum(['studio', 'cli', 'api']).optional(),
389
404
  actor: z.string().min(1).max(256).optional(),
390
405
  /** crew#552: `false` = this onboarding chains no capture-learnings run (a one-off). */
391
406
  autoCapture: z.boolean().optional(),
392
- })
393
- .strict();
407
+ });
394
408
  /**
395
409
  * The launch body. Every field but `problem` is optional, which is what made stripping dangerous:
396
410
  * omitting one is a legitimate request that gets an engine default, so a MISSPELLED one was
@@ -462,7 +476,7 @@ export function primaryRefusal(primary, clisJson) {
462
476
  }
463
477
  return null;
464
478
  }
465
- export const LaunchSchema = z.object({
479
+ export const LaunchSchema = z.strictObject({
466
480
  problem: z.string().min(1),
467
481
  sessionId: z.string().min(1).optional(),
468
482
  clisJson: z.string().min(1).optional(),
@@ -514,7 +528,7 @@ export const LaunchSchema = z.object({
514
528
  * (explicit `"none"` is a 400; a daemon that resolves the omitted field to `none` is a 409).
515
529
  * Resolved via `gh pr view` at launch — not OPEN / a fork / gh failure ⇒ 409, nothing launched.
516
530
  * Send it only when `GET /health.capabilities.revisesPr === true` (engine ≥ 0.7.27). */
517
- revisesPr: z.number().int().positive().optional(),
531
+ revisesPr: z.int().positive().optional(),
518
532
  /** crew#619 — the chat this run was promoted from; the daemon retains that chat's transcript
519
533
  * on disk until this run reaches a terminal state so the Continue-in-Build prefill is
520
534
  * always reproducible. Optional; omit when the launch is not promoted from a chat. */
@@ -544,32 +558,32 @@ export const LaunchSchema = z.object({
544
558
  * acceptance, with a reason (labelled on the run, every gate and the delivery), or its explicit
545
559
  * force (no score waiver). Forwarded only when sent; crew never decides either for the caller,
546
560
  * and the engine refuses either on a run whose workflow does not require QE acceptance. */
547
- skipQeAcceptance: z.object({ reason: z.string().trim().min(1).max(2000) }).strict().optional(),
561
+ skipQeAcceptance: z.strictObject({ reason: z.string().trim().min(1).max(2000) }).optional(),
548
562
  forceQeAcceptance: z.boolean().optional(),
549
- }).strict().refine((b) => b.skipQeAcceptance === undefined || b.forceQeAcceptance !== true, {
550
- message: 'skipQeAcceptance and forceQeAcceptance are mutually exclusive — skip it with a reason, or force it',
563
+ }).refine((b) => b.skipQeAcceptance === undefined || b.forceQeAcceptance !== true, {
551
564
  path: ['forceQeAcceptance'],
565
+ error: 'skipQeAcceptance and forceQeAcceptance are mutually exclusive — skip it with a reason, or force it',
552
566
  }).refine((b) => b.plan === undefined || b.workflow === undefined, {
553
- message: 'plan and workflow are mutually exclusive — a launch carries a plan or names a preset, not both',
554
567
  path: ['plan'],
568
+ error: 'plan and workflow are mutually exclusive — a launch carries a plan or names a preset, not both',
555
569
  }).refine((b) => b.plan !== undefined || b.deliver !== 'pr' || b.workflow !== undefined, {
556
- message: 'deliver: "pr" requires a workflow — a free-text run has no def to append the deliver phase to',
557
570
  path: ['deliver'],
571
+ error: 'deliver: "pr" requires a workflow — a free-text run has no def to append the deliver phase to',
558
572
  }).refine((b) => b.deliverGate === undefined || b.deliver !== 'none', {
559
573
  // F-E2E-030: a deliver-gate posture on a launch that declines delivery is a contradiction the
560
574
  // caller should hear about, not a silent no-op. (A launch that OMITS `deliver` may still
561
575
  // resolve to no deliver unit — repo-less, free-text, read-only def; the field is then inert.)
562
- message: 'deliverGate has no meaning with deliver: "none" — there is no deliver phase to gate',
563
576
  path: ['deliverGate'],
577
+ error: 'deliverGate has no meaning with deliver: "none" — there is no deliver phase to gate',
564
578
  }).refine((b) => b.campaignId === undefined || b.groupLabel === undefined, {
565
- message: 'campaignId and groupLabel are mutually exclusive — a run files onto ONE grouping surface (an existing campaign, or a label group)',
566
579
  path: ['groupLabel'],
580
+ error: 'campaignId and groupLabel are mutually exclusive — a run files onto ONE grouping surface (an existing campaign, or a label group)',
567
581
  }).refine((b) => b.revisesPr === undefined || (b.repoRef !== undefined && b.workflow !== undefined), {
568
- message: 'revisesPr needs repoRef and workflow — a revision bases a repo-scoped, def-driven run on the pull request\'s branch',
569
582
  path: ['revisesPr'],
583
+ error: 'revisesPr needs repoRef and workflow — a revision bases a repo-scoped, def-driven run on the pull request\'s branch',
570
584
  }).refine((b) => b.revisesPr === undefined || b.deliver !== 'none', {
571
- message: 'revisesPr needs deliver: "pr" — a launch that declines delivery has no phase to push the revision with',
572
585
  path: ['revisesPr'],
586
+ error: 'revisesPr needs deliver: "pr" — a launch that declines delivery has no phase to push the revision with',
573
587
  });
574
588
  /** The escalation arms (wicked-core#469 / #467): approve-shaped, no `amend` / `amendScope`.
575
589
  * `extend` | `targeted` | `accept_partial` answer the gate of a repo-checks floor that did not
@@ -579,7 +593,14 @@ export const LaunchSchema = z.object({
579
593
  * re-runs the judge of a `judge_unavailable` gate on the same work, the step's seat not run again.
580
594
  * The ENGINE refuses each at any other gate (a 409 naming the gate it answers) — and `rejudge`
581
595
  * while no judge seat is eligible ({@link GateInfo.rejudge} says beforehand). */
582
- export const ESCALATION_ACTIONS = ['extend', 'targeted', 'accept_partial', 'accept_suggestion', 'rejudge'];
596
+ export const ESCALATION_ACTIONS = ['extend', 'targeted', 'accept_partial', 'accept_suggestion', 'rejudge', 'retry_rules'];
597
+ /** (DES-RULE-CHECK-001 S2, api-types 0.190.0) At a `rules_unchecked` gate (a steering rule no judge
598
+ * ruled on): `retry_rules` (an escalation arm above) re-runs the rule check on the same work, the
599
+ * step's seat not run again; `skip_rules` skips unchecked rules, each with a written reason
600
+ * (`skipRules: [{id, reason}]`, required), then re-runs it. A skip is labelled on the run, the gate
601
+ * and the delivery receipts. The engine refuses both at any other gate, and a skip of a rule that
602
+ * is not unchecked (a broken rule denies). Skipping is the human operator's call alone. */
603
+ export const SKIP_RULES_ACTION = 'skip_rules';
583
604
  /** (core#820) A consent gate's answer token: `consent:<choice id>` approves that row of the dry-run
584
605
  * plan (the engine refuses an id its plan does not offer); `reject` stays the decline. */
585
606
  export const CONSENT_CHOICE_ACTION = /^consent:[A-Za-z0-9_-]{1,32}$/u; // core `parse_plan` caps a choice id at 32
@@ -614,15 +635,19 @@ export const OPERATOR_JUDGMENT_ACTION = 'operator_judgment';
614
635
  * denied (it counts), or a failed floor's gate with QE behind it (it re-opens on the floor alone).
615
636
  * Refused (409, gate left open) everywhere else and on a run that does not require QE. */
616
637
  export const SKIP_QE_ACTION = 'skip_qe';
638
+ /** (DES-RULE-CHECK-001 S2) The engine's `skip_rules` amend: `[{"id", "reason"}]`, reasons trimmed. */
639
+ export function skipRulesAmend(skips) {
640
+ return JSON.stringify(skips.map((s) => ({ id: s.id.trim(), reason: s.reason.trim() })));
641
+ }
617
642
  /** (studio#923) The label an operator's QE skip carries on the run, every later gate and the
618
643
  * delivery — the engine's words ("QE acceptance skipped by operator: <reason>"). */
619
644
  export const QE_SKIPPED_BY_OPERATOR_LABEL = 'QE acceptance skipped by operator';
620
- export const GateSchema = z.object({
645
+ export const GateSchema = z.strictObject({
621
646
  approve: z.boolean(),
622
647
  amend: z.string().optional(),
623
648
  action: z
624
649
  .union([
625
- z.enum(['approve', 'request_changes', 'reject', 'edit_plan', 'amend_intent', OPERATOR_JUDGMENT_ACTION, SKIP_QE_ACTION, ...ESCALATION_ACTIONS]),
650
+ z.enum(['approve', 'request_changes', 'reject', 'edit_plan', 'amend_intent', OPERATOR_JUDGMENT_ACTION, SKIP_QE_ACTION, SKIP_RULES_ACTION, ...ESCALATION_ACTIONS]),
626
651
  z.string().regex(CONSENT_CHOICE_ACTION, 'a consent choice is `consent:<choice id>`'),
627
652
  ])
628
653
  .optional(),
@@ -631,7 +656,7 @@ export const GateSchema = z.object({
631
656
  plan: PlanSchema.optional(),
632
657
  /** api-types 0.44.0 — the gate this decision answers (its unit `ord`). A mismatch with the run's
633
658
  * open gate is a 409 `gate_changed`: the decision was made on a gate that is no longer open. */
634
- ord: z.number().int().nonnegative().optional(),
659
+ ord: z.int().nonnegative().optional(),
635
660
  /** (api-types 0.156.0, DES-VOICE) The person answered by voice and confirmed it on screen: recorded on the
636
661
  * `gate.decided` audit line and the decided-gate history ("by voice, confirmed"). It grants nothing. */
637
662
  input: z.literal('voice').optional(),
@@ -640,31 +665,41 @@ export const GateSchema = z.object({
640
665
  * declined. Absent = every drafted rule lands, as before. 409 `no_draft` unless the run waits at its
641
666
  * steering-author propose gate with a readable draft; 400 with anything but a plain approve. */
642
667
  keepRules: z.array(z.string().min(1).max(256)).max(500).optional(),
643
- }).strict().refine((b) => b.keepRules === undefined || (b.approve && (b.action === undefined || b.action === 'approve') && b.plan === undefined), { message: 'keepRules goes with a plain approve (no action other than approve, no plan) of a steering-author propose gate', path: ['keepRules'] }).refine((b) => b.action === undefined
644
- || (b.action === 'approve' || b.action === 'edit_plan' || b.action === 'amend_intent' || b.action === OPERATOR_JUDGMENT_ACTION || b.action === SKIP_QE_ACTION || isEscalationAction(b.action)) === b.approve, { message: '`action` disagrees with `approve`: request_changes and reject require approve: false; approve, edit_plan, amend_intent, operator_judgment, skip_qe, extend, targeted, accept_partial, accept_suggestion, rejudge and consent:<id> require approve: true', path: ['action'] }).refine(
668
+ /** (DES-RULE-CHECK-001 S2, api-types 0.190.0) With `action: 'skip_rules'`: the unchecked rules to
669
+ * skip, each with the person's written reason. */
670
+ skipRules: z
671
+ .array(z.strictObject({ id: z.string().trim().min(1).max(256), reason: z.string().trim().min(1).max(2000) }))
672
+ .min(1)
673
+ .max(500)
674
+ .optional(),
675
+ }).refine((b) => (b.action === SKIP_RULES_ACTION) === (b.skipRules !== undefined), { path: ['skipRules'], error: 'skip_rules needs `skipRules`: [{id, reason}] for each unchecked rule you skip, each with your written reason; skipRules goes with skip_rules only' }).refine((b) => b.action !== SKIP_RULES_ACTION || (b.approve && b.amend === undefined && b.amendScope === undefined && b.plan === undefined), { path: ['action'], error: 'skip_rules takes approve: true and no amend, amendScope or plan — the reasons ride skipRules' }).refine((b) => b.skipRules === undefined || new Set(b.skipRules.map((r) => r.id)).size === b.skipRules.length, { path: ['skipRules'], error: 'skipRules names a rule twice' }).refine((b) => b.keepRules === undefined || (b.approve && (b.action === undefined || b.action === 'approve') && b.plan === undefined), { path: ['keepRules'], error: 'keepRules goes with a plain approve (no action other than approve, no plan) of a steering-author propose gate' }).refine((b) => b.action === undefined
676
+ || (b.action === 'approve' || b.action === 'edit_plan' || b.action === 'amend_intent' || b.action === OPERATOR_JUDGMENT_ACTION || b.action === SKIP_QE_ACTION || b.action === SKIP_RULES_ACTION || isEscalationAction(b.action)) === b.approve, { path: ['action'], error: '`action` disagrees with `approve`: request_changes and reject require approve: false; approve, edit_plan, amend_intent, operator_judgment, skip_qe, skip_rules, extend, targeted, accept_partial, accept_suggestion, rejudge, retry_rules and consent:<id> require approve: true' }).refine(
645
677
  // (operator ruling 2026-10-21) The override's rationale IS its record: a blank one is a 400 here,
646
678
  // before the engine is asked.
647
- (b) => b.action !== OPERATOR_JUDGMENT_ACTION || (b.amend !== undefined && b.amend.trim() !== ''), { message: 'operator_judgment needs `amend`: your written rationale — why the failed floor is not the work\'s (an empty one is refused)', path: ['amend'] }).refine((b) => b.action !== OPERATOR_JUDGMENT_ACTION || (b.amendScope === undefined && b.plan === undefined), { message: 'operator_judgment takes no amendScope or plan — it answers the failed floor of the gated unit', path: ['amendScope'] }).refine(
679
+ (b) => b.action !== OPERATOR_JUDGMENT_ACTION || (b.amend !== undefined && b.amend.trim() !== ''), { path: ['amend'], error: 'operator_judgment needs `amend`: your written rationale — why the failed floor is not the work\'s (an empty one is refused)' }).refine((b) => b.action !== OPERATOR_JUDGMENT_ACTION || (b.amendScope === undefined && b.plan === undefined), { path: ['amendScope'], error: 'operator_judgment takes no amendScope or plan — it answers the failed floor of the gated unit' }).refine(
648
680
  // (j4-gates) A QE skip's reason IS its record, as at launch: a blank one is a 400 here.
649
- (b) => b.action !== SKIP_QE_ACTION || (b.amend !== undefined && b.amend.trim() !== ''), { message: 'skip_qe needs `amend`: your written reason for skipping QE acceptance (an empty one is refused)', path: ['amend'] }).refine((b) => b.action !== SKIP_QE_ACTION || (b.amendScope === undefined && b.plan === undefined), { message: 'skip_qe takes no amendScope or plan — it answers the run\'s QE acceptance', path: ['amendScope'] }).refine(
681
+ (b) => b.action !== SKIP_QE_ACTION || (b.amend !== undefined && b.amend.trim() !== ''), { path: ['amend'], error: 'skip_qe needs `amend`: your written reason for skipping QE acceptance (an empty one is refused)' }).refine((b) => b.action !== SKIP_QE_ACTION || (b.amendScope === undefined && b.plan === undefined), { path: ['amendScope'], error: 'skip_qe takes no amendScope or plan — it answers the run\'s QE acceptance' }).refine(
650
682
  // (wicked-core#555) An intent amendment IS its text: an empty one amends nothing, and the arm's
651
683
  // scope is every unit at or after the cursor — which is what makes it reach the evaluator — so
652
684
  // `amendScope` cannot narrow it. Both are 400s here rather than a 409 from the engine.
653
- (b) => b.action !== 'amend_intent' || (b.amend !== undefined && b.amend.trim() !== ''), { message: 'amend_intent needs `amend`: what the run\'s acceptance list now says (approve without an action to proceed unamended)', path: ['amend'] }).refine((b) => b.action !== 'amend_intent' || (b.amendScope === undefined && b.plan === undefined), { message: 'amend_intent takes no amendScope or plan — an intent amendment reaches every unit at or after the cursor, which is what makes it reach the evaluator', path: ['amendScope'] }).refine((b) => !isEscalationAction(b.action) || (b.amend === undefined && b.amendScope === undefined && b.plan === undefined), { message: 'extend, targeted, accept_partial, accept_suggestion, rejudge and consent:<id> take no amend, amendScope or plan — the engine re-runs the floor, adopts the pinned edit, re-runs the judge, or runs the chosen install as it stands', path: ['action'] }).refine((b) => (b.action === 'edit_plan') === (b.plan !== undefined) || (b.action === undefined && b.plan !== undefined), { message: 'an edited plan answers a plan_approval gate: `plan` needs approve: true with `action` omitted or edit_plan, and edit_plan needs `plan`', path: ['plan'] }).refine((b) => b.plan === undefined || (b.approve && b.amend === undefined && b.amendScope === undefined), { message: '`plan` is an approve WITH an edited plan: approve: true, and no amend / amendScope (the plan is the edit)', path: ['plan'] }).refine((b) => b.amendScope === undefined || b.approve, { message: '`amendScope` applies to an approve only (approve: true)', path: ['amendScope'] });
685
+ (b) => b.action !== 'amend_intent' || (b.amend !== undefined && b.amend.trim() !== ''), { path: ['amend'], error: 'amend_intent needs `amend`: what the run\'s acceptance list now says (approve without an action to proceed unamended)' }).refine((b) => b.action !== 'amend_intent' || (b.amendScope === undefined && b.plan === undefined), { path: ['amendScope'], error: 'amend_intent takes no amendScope or plan — an intent amendment reaches every unit at or after the cursor, which is what makes it reach the evaluator' }).refine((b) => !isEscalationAction(b.action) || (b.amend === undefined && b.amendScope === undefined && b.plan === undefined), { path: ['action'], error: 'extend, targeted, accept_partial, accept_suggestion, rejudge, retry_rules and consent:<id> take no amend, amendScope or plan — the engine re-runs the floor, adopts the pinned edit, re-runs the judge or the rule check, or runs the chosen install as it stands' }).refine((b) => (b.action === 'edit_plan') === (b.plan !== undefined) || (b.action === undefined && b.plan !== undefined), { path: ['plan'], error: 'an edited plan answers a plan_approval gate: `plan` needs approve: true with `action` omitted or edit_plan, and edit_plan needs `plan`' }).refine(
686
+ // (crew#1139) `amend` beside a plan is the operator's note to the steps it releases (the engine lands
687
+ // it on the plan's first creator step); a plan gate's note has no scope to choose.
688
+ (b) => b.plan === undefined || (b.approve && b.amendScope === undefined), { path: ['plan'], error: '`plan` is an approve WITH an edited plan: approve: true, and no amendScope (a note in `amend` lands on the plan\'s first creator step)' }).refine((b) => b.amendScope === undefined || b.approve, { path: ['amendScope'], error: '`amendScope` applies to an approve only (approve: true)' });
654
689
  /** `PUT /runs/:id/guidance` (DES-UX-002 §7.2, CREW-UX-7) — the durable pre-gate note body.
655
690
  * The empty string is a legal body: it CLEARS the note. The byte cap is checked in the route
656
691
  * (not zod's char-counting `max`) so the 400 names the actual limit. */
657
- export const GuidanceSchema = z.object({
692
+ export const GuidanceSchema = z.strictObject({
658
693
  text: z.string(),
659
- }).strict();
694
+ });
660
695
  /** ~8KB — a guidance note is operator prose, not a document store. */
661
696
  const GUIDANCE_MAX_BYTES = 8192;
662
697
  /** `POST /runs/:id/cancel` (api-types `CancelRunRequest`): optional, so a bodiless cancel stays valid. */
663
- const CancelSchema = z.object({
698
+ const CancelSchema = z.strictObject({
664
699
  reason: z.string().trim().max(2000).optional(),
665
700
  input: z.literal('voice').optional(),
666
- }).strict();
667
- const InjectSchema = z.object({
701
+ });
702
+ const InjectSchema = z.strictObject({
668
703
  message: z.string().min(1),
669
704
  /** `"all"` broadcasts to every active worker; any other value is a CLI key. */
670
705
  target: z.string().min(1).default('all'),
@@ -672,56 +707,56 @@ const InjectSchema = z.object({
672
707
  * any other actor); kept on the `run.injected` audit line and stamped on the note's queued/injected frames so the
673
708
  * thread says "You (by voice)". It grants nothing a typed note does not. */
674
709
  input: z.literal('voice').optional(),
675
- }).strict();
710
+ });
676
711
  // The manual reassign lever (crew#442): `cli` omitted lets the engine's council re-pick, the
677
712
  // same shape the automatic stall-watchdog escalation uses for an unknown failover target.
678
- const ReassignSchema = z.object({
713
+ const ReassignSchema = z.strictObject({
679
714
  cli: z.string().min(1).optional(),
680
715
  /** crew#1153: an operator note that rides a GATED reassign as the approve's amendment. Trimmed in
681
716
  * the route; blank counts as absent. The byte cap (on the raw note) is checked there too so the 400 names the limit. */
682
717
  note: z.string().optional(),
683
- }).strict();
684
- export const OpenTerminalSchema = z.object({
718
+ });
719
+ export const OpenTerminalSchema = z.strictObject({
685
720
  cwd: z.string().min(1),
686
721
  cmd: z.array(z.string().min(1)).min(1).optional(),
687
- cols: z.number().int().positive(),
688
- rows: z.number().int().positive(),
722
+ cols: z.int().positive(),
723
+ rows: z.int().positive(),
689
724
  // Optional so omission is the SAFE governed default (§7 — `false` is never a
690
725
  // default; the ungoverned operator shell must opt in explicitly).
691
726
  governed: z.boolean().optional(),
692
- }).strict();
727
+ });
693
728
  /** `POST /seats/:cli/login|logout` body (crew#615): the PTY size, both optional. */
694
- export const SeatSessionSchema = z.object({
695
- cols: z.number().int().positive().optional(),
696
- rows: z.number().int().positive().optional(),
697
- }).strict();
698
- const ResizeTerminalSchema = z.object({
699
- cols: z.number().int().positive(),
700
- rows: z.number().int().positive(),
701
- }).strict();
729
+ export const SeatSessionSchema = z.strictObject({
730
+ cols: z.int().positive().optional(),
731
+ rows: z.int().positive().optional(),
732
+ });
733
+ const ResizeTerminalSchema = z.strictObject({
734
+ cols: z.int().positive(),
735
+ rows: z.int().positive(),
736
+ });
702
737
  /** `POST /open` (crew#273) — the studio Files tab's "open with the OS default app" body. */
703
- export const OpenPathSchema = z.object({
738
+ export const OpenPathSchema = z.strictObject({
704
739
  path: z.string().min(1),
705
740
  runId: z.string().min(1).optional(),
706
- }).strict();
741
+ });
707
742
  /** `POST /memory/retire` body (DES-MEM-FACETED-001). `scope_prefix` is REQUIRED and, after trim,
708
743
  * non-empty (enforced in the route so the 400 names the total-wipe guard): estate `memory.erase`
709
744
  * is subtree-scoped and refuses an empty prefix. `.strict()` for the FINDING-031 posture — an
710
745
  * unknown field is a 400, never silently ignored into a broader erase than the caller sent. */
711
- export const RetireMemorySchema = z.object({
746
+ export const RetireMemorySchema = z.strictObject({
712
747
  scope_prefix: z.string(),
713
- }).strict();
748
+ });
714
749
  /** `POST /memory/retire-item` body (studio#206): ONE memory, by its `memory_id` from `GET /memory`.
715
750
  * `.strict()`: a stray `scope_prefix` is a 400, never read as a wider erase than one row. */
716
- export const RetireMemoryItemSchema = z.object({
751
+ export const RetireMemoryItemSchema = z.strictObject({
717
752
  memory_id: z.string().min(1).max(512),
718
- }).strict();
753
+ });
719
754
  /** `POST /memory/edit` body (wicked-studio's Memory page): ONE memory's new words. `.strict()`: an
720
755
  * unknown field is a 400, never read as something wider than one memory. */
721
- export const EditMemorySchema = z.object({
756
+ export const EditMemorySchema = z.strictObject({
722
757
  memory_id: z.string().min(1).max(512),
723
758
  content: z.string().min(1).max(4000),
724
- }).strict();
759
+ });
725
760
  /** estate `memory.capture`'s `kind` for a tier — the kind natural to it, as estate's own proposal
726
761
  * approve picks (`kind_for_tier`), so an edited memory keeps the kind its tier implies. */
727
762
  const KIND_FOR_TIER = {
@@ -781,7 +816,7 @@ function withServedSeq(merged) {
781
816
  * `POST /chats` body (crew#165; `projectId` DES-PROJECT-001 §2.2; `repoRefs` + scope semantics
782
817
  * crew#502). Exported for the wire-contract drift guard (`tests/wire-contract.test.ts`).
783
818
  */
784
- export const ChatOpenSchema = z.object({
819
+ export const ChatOpenSchema = z.strictObject({
785
820
  chatId: z.string().min(1).max(128).regex(/^[A-Za-z0-9._-]+$/).optional(),
786
821
  clis: z.array(z.string().min(1)).min(1).max(8).optional(),
787
822
  /** One repo in scope — the legacy spelling, merged into `repoRefs` (crew#502). */
@@ -797,14 +832,14 @@ export const ChatOpenSchema = z.object({
797
832
  /** (ASK-C1) The seat the operator chose as the primary agent; omitted ⇒ the engine picks at random. */
798
833
  primary: z.string().min(1).optional(),
799
834
  /** (api-types 0.137.0, DES-SYSTEM-CHAT) The page the chat was started on, for the history list. */
800
- startedOn: z.object({ route: z.string().min(1).max(512), label: z.string().min(1).max(200) }).strict().optional(),
835
+ startedOn: z.strictObject({ route: z.string().min(1).max(512), label: z.string().min(1).max(200) }).optional(),
801
836
  /** (api-types 0.141.0, crew#1157) The read-only workflow every turn runs (`analyze`); see
802
837
  * `chat-workflow.ts`. Omitted ⇒ a plain chat. */
803
838
  workflow: z.string().min(1).max(64).optional(),
804
839
  /** (api-types 0.169.0, DES-CHAT-ARTIFACTS-001 §6.3) "Ask about this" on a document no open chat holds: seed the
805
840
  * chat's repositories from the document's recorded binding, after an access check. */
806
841
  seedFromArtifact: z.string().max(200).optional(),
807
- }).strict();
842
+ });
808
843
  /**
809
844
  * The `singleSeat` disclosure (crew#641, hole closed in crew#650) — built in ONE place so the 201
810
845
  * and the 202 cannot drift.
@@ -1056,6 +1091,55 @@ runtime = {}) {
1056
1091
  conformance: runtime.editorConformance ?? gardenConformance(discoverLivePlugin()?.path ?? null, () => process.env['WICKED_CREW_URL'] ?? null, { provision: editorConformanceRuntime }),
1057
1092
  log: (m) => app.log.warn(m),
1058
1093
  });
1094
+ // DES-APPS-001 §7.6 (K2a): the app store's routes, when this daemon has a store.
1095
+ // (K2b) The executor: queries of an accepted version run for real (DES §7.2), crew-source reads in process.
1096
+ // (DES-KNOWLEDGE-DATA-001 §9.1) What an app's knowledge query reads: the gate's registry, the app's project's
1097
+ // visible set, estate (this daemon's stores) and the engine's rules. Absent pieces = no knowledge query runs.
1098
+ const appsKnowledge = runtime.dataGate !== undefined && runtime.appsKnowledgeVisible !== undefined
1099
+ ? {
1100
+ sources: () => runtime.dataGate.sources(),
1101
+ visible: runtime.appsKnowledgeVisible,
1102
+ // Each estate call of an app's read is bounded by the read's own deadline (10 s), not the operator client's 30 s.
1103
+ estate: runtime.callEstateTool ?? ((tool, args) => callEstateTool(tool, args, { timeoutMs: STATEMENT_DEADLINE_MS })),
1104
+ rules: () => adapter.listConformanceRules(),
1105
+ }
1106
+ : undefined;
1107
+ const appsExecutor = runtime.apps !== undefined
1108
+ ? new AppExecutor({
1109
+ store: runtime.apps,
1110
+ registry: runtime.mcp ?? null,
1111
+ ...(appsKnowledge !== undefined ? { knowledge: appsKnowledge } : {}),
1112
+ projectOf: (slug) => runtime.apps.projectOf(slug),
1113
+ crewInject: async (r) => {
1114
+ const res = await app.inject({ method: r.method, url: r.url, headers: r.headers });
1115
+ return { statusCode: res.statusCode, body: res.body };
1116
+ },
1117
+ viewerOf: runtime.appsViewerOf ?? localViewerOf,
1118
+ })
1119
+ : undefined;
1120
+ // (K2b) The write path: grants, records, API actions and Postgres row writes (DES §7.3, §7.4, §9.4).
1121
+ const appsWritePath = runtime.apps !== undefined && runtime.appsActions !== undefined
1122
+ ? new AppWritePath({
1123
+ store: runtime.apps,
1124
+ actions: runtime.appsActions,
1125
+ registry: runtime.mcp ?? null,
1126
+ audit,
1127
+ viewerOf: runtime.appsViewerOf ?? localViewerOf,
1128
+ ...(appsExecutor !== undefined ? { executor: appsExecutor } : {}),
1129
+ })
1130
+ : undefined;
1131
+ if (runtime.apps !== undefined) {
1132
+ registerAppRoutes(app, {
1133
+ store: runtime.apps,
1134
+ audit,
1135
+ ...(appsExecutor !== undefined ? { executor: appsExecutor } : {}),
1136
+ ...(appsWritePath !== undefined ? { writePath: appsWritePath } : {}),
1137
+ ...(runtime.appsVerifyUnitToken !== undefined ? { verifyUnitToken: runtime.appsVerifyUnitToken } : {}),
1138
+ ...(typeof adapter.projectsSupported === 'function' && adapter.projectsSupported()
1139
+ ? { projectExists: async (id) => (await adapter.projectGet(id)) !== null }
1140
+ : {}),
1141
+ });
1142
+ }
1059
1143
  const chatRecorder = decisions !== null && chatTranscripts !== undefined && runtime.broadcast !== undefined
1060
1144
  ? new ChatDecisionRecorder({
1061
1145
  service: decisions,
@@ -1071,8 +1155,21 @@ runtime = {}) {
1071
1155
  /** DES-L9: PR number → head branch, through `gh pr view` unless the runtime injected an answerer. */
1072
1156
  const resolvePullRequest = runtime.resolvePullRequest ?? resolvePullRequestViaGh;
1073
1157
  /** crew#627: the intent's linked issues, read under the daemon's identity at launch. */
1158
+ /** (DES-PM-001 §3.2) A project's live `crew.repo` members, for a tracker set. */
1159
+ const repoMembersOf = async (projectId) => (await adapter.projectMembers(projectId)).filter((m) => m.member_kind === 'crew.repo').map((m) => m.member_ref);
1160
+ /** (Q-PM5) With a PM source registered, its system's refs resolve only through the launch's tracker set. */
1161
+ const pmIssueReader = async (projectId, repoRef) => {
1162
+ const gate = runtime.dataGate;
1163
+ if (gate === undefined)
1164
+ return undefined;
1165
+ const entries = await gate.pm.entries();
1166
+ if (entries.length === 0)
1167
+ return undefined;
1168
+ const { systems, jiraKeys } = pmRegistered(entries);
1169
+ return { systems, jiraKeys, read: (refs) => readPmIssues(gate.pm, entries, { projectId, repoId: repoRef }, repoMembersOf, refs, () => gate.pm.entries()) };
1170
+ };
1074
1171
  const readLinkedIssues = runtime.resolveLinkedIssues ??
1075
- ((p, root, ref, exclude) => resolveLinkedIssues(p, root, ref, undefined, exclude));
1172
+ (async (p, root, ref, exclude, projectId) => resolveLinkedIssues(p, root, ref, undefined, exclude, await pmIssueReader(projectId ?? null, ref ?? null)));
1076
1173
  /** crew#550 P-7: the follow-ups the run's evaluator units flagged, read from their captured output.
1077
1174
  * A unit whose output cannot be read contributes nothing (the section then says what WAS read);
1078
1175
  * an adapter without transcripts (a directly-driven route set) reads as "not read" — absent. */
@@ -1397,6 +1494,8 @@ runtime = {}) {
1397
1494
  runChatId: true,
1398
1495
  // crew#825: `LaunchRunBody.excludeLinkedIssues` + `POST /linked-issues/preview` are served.
1399
1496
  linkedIssuesExclude: true,
1497
+ // DES-PM-001 PM-1: PM sources, tracker links, tracker sets in linked issues, tracker actions.
1498
+ trackerLinks: true,
1400
1499
  // ASK-C1 (DES-ASK-TEAM-CHAT-001 §5.1): an ask starts a path — the whole contract is the
1401
1500
  // pinned core-ts floor the adapter reports; an older studio reads ABSENT as "every helper
1402
1501
  // answers", a newer one renders the one PA voice.
@@ -1434,6 +1533,9 @@ runtime = {}) {
1434
1533
  workingDoc: app.hasRoute({ method: 'GET', url: `${V}/runs/:id/working-doc` }),
1435
1534
  // (api-types 0.149.0) Power mode: the routes are served AND the engine runs it.
1436
1535
  powerMode: powerSupported(),
1536
+ // (api-types 0.188.0, crew#1139) A plan approval carries the operator's note (`GateDecision.amend` at a
1537
+ // plan_approval gate, with or without `plan`): the engine lands it on the plan's first creator step.
1538
+ planGateNote: typeof adapter.supportsPlanGateNote === 'function' && adapter.supportsPlanGateNote(),
1437
1539
  // (api-types 0.156.0, DES-VOICE) Voice mode's routes are served: local speech to text, the model with
1438
1540
  // consent, and the per-person dashboard. Whether transcription can run now is `GET /voice/status`.
1439
1541
  voice: app.hasRoute({ method: 'POST', url: `${V}/voice/transcribe` }),
@@ -1443,6 +1545,20 @@ runtime = {}) {
1443
1545
  // artifact and the runs the person names; `seedFromArtifact`); A2 (0.170.0) `proposals`. The operations are later
1444
1546
  // slices (all on, with `stub`, in the test configuration).
1445
1547
  chatArtifacts: { ...chatArtifactFlags },
1548
+ // (api-types 0.172.0, DES-APPS-001 K2a) The app store is served; each later route says when it serves for real.
1549
+ ...(runtime.apps !== undefined
1550
+ ? {
1551
+ apps: {
1552
+ // (typed against the contract below: a renamed flag fails the build)
1553
+ query: appsExecutor !== undefined,
1554
+ actions: appsWritePath !== undefined,
1555
+ turns: runtime.apps.turns !== null,
1556
+ publish: false,
1557
+ uploads: app.hasRoute({ method: 'POST', url: `${V}/apps/uploads` }),
1558
+ sourceCheck: runtime.apps.sourceStage !== null,
1559
+ },
1560
+ }
1561
+ : {}),
1446
1562
  };
1447
1563
  // wicked-core#411 / crew#497: the state-home blocker rides the health probe as a WARNING. The
1448
1564
  // daemon still SERVES (status stays ok — studio must load and show the blocker) but refuses to
@@ -1584,7 +1700,8 @@ runtime = {}) {
1584
1700
  ...(limit !== undefined ? { limit } : {}),
1585
1701
  ...(since !== undefined ? { since } : {}),
1586
1702
  });
1587
- return { entries };
1703
+ // (crew#1317) A non-human reader gets the MCP and source lines without their connection data.
1704
+ return { entries: auditFor(actorOf(req), entries) };
1588
1705
  }
1589
1706
  catch (err) {
1590
1707
  return reply.code(500).send({ error: message(err) });
@@ -1761,6 +1878,35 @@ runtime = {}) {
1761
1878
  }
1762
1879
  return { session, target };
1763
1880
  };
1881
+ /**
1882
+ * (crew#1324, DES-KNOWLEDGE-DATA-001 §5.2) An app repo's files are a person's to read: its `apps.lock.json`
1883
+ * pins each source's connection descriptor, `queries/` holds SQL that names relations, `apps.json` holds what
1884
+ * its actions write. A non-human actor ({@link viewOf} `agent`) is refused both reads when the run works in an
1885
+ * app's repository, or the path or the run's worktree is inside one (so every file of an app's run, and the run
1886
+ * branch's diff); `GET /apps/:app` answers it the agent-safe view. With no app store (an unreadable one leaves
1887
+ * Apps off) crew cannot tell an app's files from any other, so a non-human reads no run file or diff. Humans
1888
+ * (studio's run pages) are unchanged. Returns `true` after replying.
1889
+ */
1890
+ const appFilesRefused = async (req, reply, session, target) => {
1891
+ if (viewOf(actorOf(req)) === 'full')
1892
+ return false;
1893
+ const repos = runtime.apps?.appRepos();
1894
+ const appRun = () => {
1895
+ if (repos === undefined)
1896
+ return true;
1897
+ if (session.repo_ref !== null && repos.some((r) => r.repoId !== '' && r.repoId === session.repo_ref))
1898
+ return true;
1899
+ const paths = [target, session.workdir].filter((p) => typeof p === 'string' && p.length > 0);
1900
+ return paths.some((p) => repos.some((r) => mayBeInsideRoot(r.root, p)));
1901
+ };
1902
+ if (!appRun())
1903
+ return false;
1904
+ await reply.code(403).send({
1905
+ code: 'app_files_human_only',
1906
+ error: "an app's files are read by people; GET /apps/:app answers the agent-safe view of the app",
1907
+ });
1908
+ return true;
1909
+ };
1764
1910
  // Fastify parses a repeated param as string[] (Copilot, #250/#266). These are FILE-READ
1765
1911
  // routes: `?path=a&path=b` is rejected outright (400) rather than silently reading as
1766
1912
  // either (Copilot, #305).
@@ -1781,6 +1927,8 @@ runtime = {}) {
1781
1927
  const resolved = await resolveRunPath(reply, id, rawPath);
1782
1928
  if (resolved === null)
1783
1929
  return reply;
1930
+ if (await appFilesRefused(req, reply, resolved.session, resolved.target))
1931
+ return reply;
1784
1932
  const target = resolved.target;
1785
1933
  try {
1786
1934
  const read = await readFileCapped(target);
@@ -1818,6 +1966,8 @@ runtime = {}) {
1818
1966
  const resolved = await resolveRunPath(reply, id, rawPath);
1819
1967
  if (resolved === null)
1820
1968
  return reply;
1969
+ if (await appFilesRefused(req, reply, resolved.session, resolved.target))
1970
+ return reply;
1821
1971
  const workdir = resolved.session.workdir;
1822
1972
  /** The route's one error mapping, shared by the worktree and the branch reads. */
1823
1973
  const diffError = (err) => {
@@ -2023,15 +2173,38 @@ runtime = {}) {
2023
2173
  * (core has no unregister). A registered repo returns 201 with `onboardRunId: null` and
2024
2174
  * `onboardError` on launch failure, so callers can attach it to their project and retry onboarding.
2025
2175
  */
2026
- app.post(`${V}/repos`, async (req, reply) => {
2176
+ app.post(`${V}/repos`, { config: { manifest: { requestType: 'RegisterRepoBody', statusCodes: [201, 400, 409, 422, 503] } } }, async (req, reply) => {
2027
2177
  const parsed = RegisterRepoSchema.safeParse(req.body);
2028
2178
  if (!parsed.success) {
2029
2179
  return reply.code(400).send(invalidBody(parsed.error, 'Invalid request body'));
2030
2180
  }
2181
+ if (parsed.data.create === true) {
2182
+ // DES-APPS-001 (K2a): `<apps root>/<name>`, `git init` with one empty commit, registered; an empty
2183
+ // tree has nothing to onboard. A taken (or reserved) name is refused with a suggestion.
2184
+ const store = runtime.apps;
2185
+ if (store === undefined)
2186
+ return reply.code(503).send({ code: 'apps_unavailable', error: 'this daemon has no apps root to make a repo in' });
2187
+ const name = parsed.data.name;
2188
+ try {
2189
+ const { repo } = await store.createRepo(name);
2190
+ audit.record('repo.created', actorOf(req), { detail: { repoId: repo.id, name } });
2191
+ return reply.code(201).send({ repo, onboardRunId: null });
2192
+ }
2193
+ catch (err) {
2194
+ if (err instanceof AppStoreError)
2195
+ return reply.code(err.status).send({ code: err.code, error: err.message, ...err.extra });
2196
+ // A registration the engine refused: the repo was removed again, nothing is left.
2197
+ return reply.code(400).send({ error: message(err) });
2198
+ }
2199
+ }
2031
2200
  const refused = await onboardRefusal();
2032
2201
  if (refused !== null)
2033
2202
  return reply.code(refused.status).send(refused.body);
2034
2203
  const { name, rootPath, gitUrl, projectId, channel, actor, autoCapture } = parsed.data;
2204
+ // (DES-PM-001 Q-PM2) Re-pointing an existing repo id at another checkout keeps its projects and tracker links.
2205
+ const repointed = await reRegisterRefusal(actorOf(req), name, rootPath, Boolean(gitUrl), () => adapter.listRepos());
2206
+ if (repointed !== null)
2207
+ return reply.code(repointed.status).send(repointed.body);
2035
2208
  let repo;
2036
2209
  let runId;
2037
2210
  try {
@@ -2091,13 +2264,13 @@ runtime = {}) {
2091
2264
  // crew#825: what a workflow launch WOULD append — the same reading `POST /runs` does, before Send,
2092
2265
  // so the composer shows "N linked issues will be appended (≈K chars)" with a way to leave one out
2093
2266
  // (`excludeLinkedIssues`). Read-only: nothing launches, nothing is stored.
2094
- const LinkedIssuesPreviewSchema = z
2095
- .object({
2267
+ const LinkedIssuesPreviewSchema = z.strictObject({
2096
2268
  problem: z.string().min(1),
2097
2269
  repoRef: z.string().min(1).optional(),
2098
2270
  excludeLinkedIssues: ExcludeLinkedIssuesSchema,
2099
- })
2100
- .strict();
2271
+ // (DES-PM-001 §3.2) The project the launch would be filed in: its tracker set reads the refs.
2272
+ projectId: z.string().min(1).max(128).optional(),
2273
+ });
2101
2274
  app.post(`${V}/linked-issues/preview`, { config: { manifest: { requestType: 'LinkedIssuesPreviewBody', responseType: 'LinkedIssuesPreviewResponse', statusCodes: [200, 400] } } }, async (req, reply) => {
2102
2275
  const parsed = LinkedIssuesPreviewSchema.safeParse(req.body);
2103
2276
  if (!parsed.success)
@@ -2107,7 +2280,7 @@ runtime = {}) {
2107
2280
  // intent alone, so the preview answers "nothing appended" and says why — never a 500.
2108
2281
  try {
2109
2282
  const root = b.repoRef !== undefined ? await repoRootOf(b.repoRef) : undefined;
2110
- const linked = await readLinkedIssues(b.problem, root, b.repoRef, b.excludeLinkedIssues ?? []);
2283
+ const linked = await readLinkedIssues(b.problem, root, b.repoRef, b.excludeLinkedIssues ?? [], b.projectId ?? null);
2111
2284
  return { issues: linked.issues, appendedChars: linked.block === null ? 0 : linked.block.length + 2 };
2112
2285
  }
2113
2286
  catch (err) {
@@ -2182,7 +2355,9 @@ runtime = {}) {
2182
2355
  if (b.clisJson === undefined)
2183
2356
  await rosterWithStanding.ready?.();
2184
2357
  const input = {
2185
- problem: b.problem,
2358
+ // (xreview r1 on S1) An inherited rules block never rides a relaunch, workflow or free text: the workflow path
2359
+ // below lists the rules afresh; a free-text launch carries none (its planner would turn rule lines into units).
2360
+ problem: stripRulesBrief(b.problem),
2186
2361
  sessionId: b.sessionId ?? randomUUID(),
2187
2362
  // The default roster carries crew's STANDING (wave 6, the crew half of F-7R2-006): the adapter
2188
2363
  // translates `council_eligible: false` into the engine's per-seat bench verdict at launch
@@ -2417,18 +2592,53 @@ runtime = {}) {
2417
2592
  // worker cannot read GitHub. The daemon reads each linked issue now and appends its text to the
2418
2593
  // problem, inside a marked block the deliver text takes back out. Workflow launches only: the
2419
2594
  // free-text planner turns sentences into units, so issue text there would become work units.
2595
+ // E7 (operator ruling 2026-11-05) + DES-RULE-CHECK-001 S1: the project's in-force steering rules ride in the brief,
2596
+ // in a marked block the deliver text takes back out (decisions/rules-brief.ts), so the review and QE seats can judge
2597
+ // the work against them. Every rule is matched against the job and listed as applies / may apply / not applicable
2598
+ // with the fact; none is cut. The steps are not known at launch (a run may be planned into catalog steps whose ids
2599
+ // are the planner's), so step scopes decide nothing here; the def's kinds only order the list. Governed launches
2600
+ // only (a named workflow or an explicit plan); best-effort: an unreadable store launches without it.
2601
+ const briefRules = async (workflow) => {
2602
+ try {
2603
+ const read = await considerations.inForceFor(b.projectId ?? null);
2604
+ const def = workflow === null ? null : adapter.getWorkflow(workflow);
2605
+ const kinds = def === null ? null : def.phases.map((p) => String(p.kind ?? 'build'));
2606
+ const rules = read.source === 'unavailable' ? [] : read.rules;
2607
+ // (coord, E7 rerun) The job's repository: a rule that names it (its statement or its source doc) applies.
2608
+ const job = { workflow, steps: null, kinds, project: b.projectId ?? null, repo: b.repoRef ?? null };
2609
+ const matches = await matchRulesForJob(rules, job, runtime.matchRules ?? CoreAdapter.ruleMatcher(), (m) => req.log.warn(m));
2610
+ const briefed = withRulesBrief(input.problem, rules, matches);
2611
+ input.problem = briefed.problem;
2612
+ if (matches.length > 0) {
2613
+ req.log.info(`[rules] ${input.sessionId}: ${briefed.listed} steering rule(s) to check, ${briefed.notApplicable} not applicable, in the brief`);
2614
+ }
2615
+ }
2616
+ catch (err) {
2617
+ req.log.warn(`[rules] the rules in force could not be read; launching without them: ${message(err)}`);
2618
+ }
2619
+ };
2420
2620
  let linkedIssues;
2621
+ let linkedAddresses;
2421
2622
  if (b.workflow !== undefined) {
2623
+ // A retry relaunches with the earlier run's whole problem (studio sends its `problem`), daemon
2624
+ // blocks included. They are dropped before anything is read, whatever the read answers, and
2625
+ // read again below: the intent is the text before the first linked-issues marker, never a
2626
+ // block an earlier launch appended (stripLinkedIssues).
2627
+ // (xreview r1) An inherited rules block goes first, so no rule id is read as a linked issue on a relaunch.
2628
+ const intent = stripLinkedIssues(stripRulesBrief(b.problem));
2629
+ input.problem = intent;
2422
2630
  // Best-effort by contract: reading issues never fails the launch it decorates. A resolver
2423
2631
  // fault (the repo list unreadable, say) launches the run on its intent alone and is logged.
2424
2632
  try {
2425
2633
  const root = b.repoRef !== undefined ? await repoRootOf(b.repoRef) : undefined;
2426
- const linked = await readLinkedIssues(b.problem, root, b.repoRef, b.excludeLinkedIssues ?? []);
2634
+ const linked = await readLinkedIssues(intent, root, b.repoRef, b.excludeLinkedIssues ?? [], b.projectId ?? null);
2427
2635
  if (linked.block !== null)
2428
- input.problem = `${b.problem.trimEnd()}\n\n${linked.block}`;
2636
+ input.problem = `${intent.trimEnd()}\n\n${linked.block}`;
2429
2637
  // crew#825: an all-excluded intent appends nothing but still answers what it left out.
2430
2638
  if (linked.issues.length > 0)
2431
2639
  linkedIssues = linked.issues;
2640
+ if (linked.addresses !== undefined && linked.addresses.length > 0)
2641
+ linkedAddresses = linked.addresses;
2432
2642
  }
2433
2643
  catch (err) {
2434
2644
  req.log.warn(`linked-issue resolution failed; launching on the intent alone: ${message(err)}`);
@@ -2447,6 +2657,13 @@ runtime = {}) {
2447
2657
  req.log.warn(`[learnings] the memory store could not be read; launching without approved learnings: ${message(err)}`);
2448
2658
  }
2449
2659
  }
2660
+ if (!NO_LEARNINGS_WORKFLOWS.has(b.workflow))
2661
+ await briefRules(b.workflow);
2662
+ }
2663
+ else if (b.plan !== undefined) {
2664
+ // (xreview r2 on S1) A launch with an explicit plan is governed like a named workflow (its steps are given, so
2665
+ // no prose planner reads the brief): its rules ride along too, an inherited block replaced.
2666
+ await briefRules(null);
2450
2667
  }
2451
2668
  // DES-RUNS-REVIEW-001 §3: a hand launch of the run review (`/workflow-review-recent-work`) is prepared like a
2452
2669
  // scheduled one: its snapshot written, repo-less, one seat, its review directory as the only write root.
@@ -2555,6 +2772,25 @@ runtime = {}) {
2555
2772
  retryIndex.set(runId, b.retryOf);
2556
2773
  if (revisesPr !== undefined)
2557
2774
  retryIndex.setRevisesPr(runId, revisesPr);
2775
+ // (DES-PM-001 §3.2, §4) The issues this run addresses, as its tracker set resolved them: delivery links them
2776
+ // back, the deliver gate's actions are offered for them, and the projection draws the trail.
2777
+ if (linkedAddresses !== undefined && runtime.trackerAddresses !== undefined) {
2778
+ // Retried: a run that addresses issues but has no record of them would deliver and project as if it did not.
2779
+ for (let attempt = 1;; attempt++) {
2780
+ try {
2781
+ await runtime.trackerAddresses.record(runId, linkedAddresses, { projectId: b.projectId ?? null, repoId: b.repoRef ?? null });
2782
+ runtime.trackerProjector?.changed();
2783
+ break;
2784
+ }
2785
+ catch (err) {
2786
+ if (attempt >= 3) {
2787
+ req.log.error(`[trackers] the issues run ${runId} addresses could not be recorded after ${attempt} attempts: ${message(err)}`);
2788
+ break;
2789
+ }
2790
+ await new Promise((r) => setTimeout(r, 200 * attempt));
2791
+ }
2792
+ }
2793
+ }
2558
2794
  if (b.campaignId !== undefined)
2559
2795
  groupIndex.set(runId, { campaignId: b.campaignId });
2560
2796
  else if (b.groupLabel !== undefined)
@@ -2704,10 +2940,10 @@ runtime = {}) {
2704
2940
  return { runs: served.map(decorateRun) };
2705
2941
  });
2706
2942
  // ── Run archival (crew#265) — write-off, not delete ────────────────────────
2707
- const ArchiveSchema = z.object({
2943
+ const ArchiveSchema = z.strictObject({
2708
2944
  archived: z.boolean(),
2709
2945
  note: z.string().max(500).optional(),
2710
- }).strict();
2946
+ });
2711
2947
  app.post(`${V}/runs/:id/archive`, async (req, reply) => {
2712
2948
  const { id } = req.params;
2713
2949
  const parsed = ArchiveSchema.safeParse(req.body ?? {});
@@ -2736,8 +2972,8 @@ runtime = {}) {
2736
2972
  // parked at a gate is stopped first (no worker is running), then archived; a run that is
2737
2973
  // executing is refused, so a resolve never ends live work. The note keeps the reason.
2738
2974
  const ResolveSchema = z.discriminatedUnion('action', [
2739
- z.object({ action: z.literal('archive'), reason: z.string().trim().min(1, 'a reason is required to archive').max(480) }).strict(),
2740
- z.object({ action: z.literal('superseded'), by: z.string().min(1), reason: z.string().trim().max(400).optional() }).strict(),
2975
+ z.strictObject({ action: z.literal('archive'), reason: z.string().trim().min(1, 'a reason is required to archive').max(480) }),
2976
+ z.strictObject({ action: z.literal('superseded'), by: z.string().min(1), reason: z.string().trim().max(400).optional() }),
2741
2977
  ]);
2742
2978
  app.post(`${V}/runs/:id/resolve`, { config: { manifest: { requestType: 'ResolveRunRequest', responseType: 'ResolveRunResponse', statusCodes: [200, 400, 404, 409, 500] } } }, async (req, reply) => {
2743
2979
  const { id } = req.params;
@@ -2785,10 +3021,10 @@ runtime = {}) {
2785
3021
  return reply.code(outcome.code).send(outcome.body);
2786
3022
  });
2787
3023
  // Bulk write-off for campaign backlogs — explicit ids only, never implicit age selection.
2788
- const BulkArchiveSchema = z.object({
3024
+ const BulkArchiveSchema = z.strictObject({
2789
3025
  ids: z.array(z.string().min(1)).min(1).max(200),
2790
3026
  note: z.string().max(500).optional(),
2791
- }).strict();
3027
+ });
2792
3028
  app.post(`${V}/runs/archive`, async (req, reply) => {
2793
3029
  const parsed = BulkArchiveSchema.safeParse(req.body ?? {});
2794
3030
  if (!parsed.success) {
@@ -2933,8 +3169,11 @@ runtime = {}) {
2933
3169
  const reports = await seatReports(run);
2934
3170
  // crew#1192: the QE check the deliver gate reads, so a required QE that passed says so.
2935
3171
  const qeAcceptance = await qeAcceptanceCheckFor(run);
3172
+ // (DES-PM-001 §6 step 3) Each addressed issue links back in its tracker's own form.
3173
+ const trackerRefs = ((await runtime.trackerAddresses?.of(id).catch(() => [])) ?? []).map((a) => ({ system: a.system, ref: a.ref, ...(a.asked !== undefined ? { asked: a.asked } : {}) }));
2936
3174
  // The run's preset or workflow NAME, as the engine recorded it (seam X2).
2937
3175
  const text = composeDeliverText(factsFromRun(decorateRun(run), runUrlFor(configuredPublicOrigin(), id), {
3176
+ ...(trackerRefs.length > 0 ? { trackerRefs } : {}),
2938
3177
  workflowId: runIdentityOf(run).name,
2939
3178
  revisesPr: retryIndex.revisesPrFor(id) ?? null,
2940
3179
  ...(followUps !== undefined ? { followUps } : {}),
@@ -3107,10 +3346,13 @@ runtime = {}) {
3107
3346
  }
3108
3347
  const followUps = await evaluatorFollowUps(run);
3109
3348
  const reports = await seatReports(run);
3349
+ // (DES-PM-001 §6 step 3) The post-hoc PR links back in each tracker's own form, as the deliver phase's does.
3350
+ const trackerRefs = ((await runtime.trackerAddresses?.of(id).catch(() => [])) ?? []).map((a) => ({ system: a.system, ref: a.ref, ...(a.asked !== undefined ? { asked: a.asked } : {}) }));
3110
3351
  result = await deliverExec(workdir, s.problem ?? undefined, {
3111
3352
  runId: id,
3112
3353
  apiOrigin: origin,
3113
3354
  facts: factsFromRun(run, runUrlFor(configuredPublicOrigin(), id), {
3355
+ ...(trackerRefs.length > 0 ? { trackerRefs } : {}),
3114
3356
  workflowId: workflowName,
3115
3357
  revisesPr: revisesPr === null ? null : { number: revisesPr.number, url: revisesPr.url },
3116
3358
  ...(followUps !== undefined ? { followUps } : {}),
@@ -3667,14 +3909,14 @@ runtime = {}) {
3667
3909
  chatId,
3668
3910
  turn: inFlight,
3669
3911
  });
3670
- const ChatMessageSchema = z.object({
3912
+ const ChatMessageSchema = z.strictObject({
3671
3913
  text: z.string().min(1).max(65536),
3672
3914
  targets: z.array(z.string().min(1)).min(1).max(8).optional(),
3673
3915
  /** (api-types 0.137.0) Attachment ids from `POST /chats/:id/attachments`. */
3674
3916
  attachments: z.array(z.string().min(1).max(64)).optional(),
3675
3917
  /** (api-types 0.169.0, DES-CHAT-ARTIFACTS-001 §5.1) What studio shows beside the message. */
3676
3918
  context: ChatMessageContextSchema.optional(),
3677
- }).strict();
3919
+ });
3678
3920
  // DES-CHAT-ARTIFACTS-001 §5.1 (A1): what a turn's block reads — the docs roots, the decorated runs (project,
3679
3921
  // document and chat ids), unit outputs and the acceptance line. One set of deps, so the block and the run pages
3680
3922
  // read the same records.
@@ -3867,13 +4109,16 @@ runtime = {}) {
3867
4109
  // crew#1155: the installed MCP tools and the one command that reaches them (the broker), read
3868
4110
  // per turn so a server installed or disabled since the last turn is reflected.
3869
4111
  let mcpTools = null;
4112
+ // DES-KNOWLEDGE-DATA-001 §8.1: the live sources the chat's project may use (structure, switches, commands).
4113
+ let knowledgeBlock = null;
3870
4114
  const withPreface = (preface) => {
3871
- const body = mcpTools !== null ? `${mcpTools}\n\n${seatText}` : seatText;
4115
+ const body = [mcpTools, knowledgeBlock, seatText].filter((x) => x !== null).join('\n\n');
3872
4116
  return preface !== null ? `${preface}\n\n${body}` : body;
3873
4117
  };
3874
4118
  try {
3875
4119
  const rules = (await considerations.inForceFor(scope?.projectId ?? null)).rules;
3876
4120
  mcpTools = await chatMcpToolsFor(runtime.mcp);
4121
+ knowledgeBlock = await chatKnowledgeFor(runtime.dataGate, scope?.projectId ?? null, (scope?.repos ?? []).map((r) => r.id));
3877
4122
  // crew#1020: a project/everything chat must see repos attached since open. Admission was
3878
4123
  // under this scope KIND and the kind stays the same, so do not re-run seat admission.
3879
4124
  const scopeRequest = chatScopes.requestOf(id);
@@ -4149,9 +4394,9 @@ runtime = {}) {
4149
4394
  // first on every call (a worker or system actor is refused even on an `accepting` proposal); the service then takes
4150
4395
  // the proposal's lock and looks for what already happened before any state check.
4151
4396
  const ProposalPatchValue = z.union([z.string().max(200), z.number(), z.boolean()]);
4152
- const ProposalDecisionSchema = z.object({
4397
+ const ProposalDecisionSchema = z.strictObject({
4153
4398
  decision: z.enum(['go', 'not_now']),
4154
- edits: z.object({
4399
+ edits: z.strictObject({
4155
4400
  title: z.string().max(400).optional(),
4156
4401
  brief: z.string().max(16000).optional(),
4157
4402
  sources: z.array(z.string().min(1).max(300)).max(32).optional(),
@@ -4160,13 +4405,13 @@ runtime = {}) {
4160
4405
  ask: z.string().max(8000).optional(),
4161
4406
  allow: z.array(z.string().min(1).max(128)).max(64).optional(),
4162
4407
  name: z.string().max(200).optional(),
4163
- patch: z.record(z.string().max(40), ProposalPatchValue).optional(),
4408
+ patch: record(z.string().max(40), ProposalPatchValue).optional(),
4164
4409
  url: z.string().max(2048).optional(),
4165
4410
  audience: z.string().max(800).optional(),
4166
4411
  show: z.string().max(4000).optional(),
4167
4412
  helpers: z.array(z.string().min(1).max(64)).max(8).optional(),
4168
- }).strict().optional(),
4169
- }).strict();
4413
+ }).optional(),
4414
+ });
4170
4415
  app.post(`${V}/chats/:id/proposals/:pid`, { config: { manifest: { requestType: 'ChatProposalDecisionBody', responseType: 'ChatProposalDecisionResponse', statusCodes: [200, 400, 403, 404, 409, 502] } } }, async (req, reply) => {
4171
4416
  const { id, pid } = req.params;
4172
4417
  if (!chatArtifactFlags.proposals)
@@ -4195,9 +4440,9 @@ runtime = {}) {
4195
4440
  const out = await chatProposals.decide(id, pid, { decision: parsed.data.decision, ...(edits !== undefined ? { edits } : {}) }, actor, instance);
4196
4441
  return reply.code(out.code).send(out.body);
4197
4442
  });
4198
- const ChatSeatsSchema = z.object({
4443
+ const ChatSeatsSchema = z.strictObject({
4199
4444
  clis: z.array(z.string().min(1)).min(1).max(8),
4200
- }).strict();
4445
+ });
4201
4446
  app.post(`${V}/chats/:id/seats`,
4202
4447
  // Typed like every neighbouring chat route (review HIGH-1): the names bind the 0.39.0 api-types
4203
4448
  // mirror to this row — `ChatSeatsBody { clis }` in, `ChatSeatsResponse { chatId, seats, refused }`
@@ -5047,6 +5292,20 @@ runtime = {}) {
5047
5292
  // (studio#923) Skipping QE acceptance is the human operator's call alone: a seat's token, a
5048
5293
  // standing order or any other non-human actor is refused before anything is read, and the
5049
5294
  // attempt is audited. The engine records WHO skipped it from the same actor (recordGateActor).
5295
+ // (DES-RULE-CHECK-001 S2) …and so is skipping a steering rule no judge ruled on.
5296
+ if (parsed.data.action === SKIP_RULES_ACTION && !isHumanOperator(actor)) {
5297
+ audit.record('gate.skip_rules_refused', actor, {
5298
+ runId: id,
5299
+ detail: { reason: 'human_operator_only', ...(parsed.data.ord !== undefined ? { ord: parsed.data.ord } : {}) },
5300
+ });
5301
+ return {
5302
+ code: 403,
5303
+ body: {
5304
+ error: `only a human operator can skip a steering rule (you are ${actor.kind}/${actor.trust})`,
5305
+ code: 'human_operator_only',
5306
+ },
5307
+ };
5308
+ }
5050
5309
  if (parsed.data.action === SKIP_QE_ACTION && !isHumanOperator(actor)) {
5051
5310
  audit.record('gate.skip_qe_refused', actor, {
5052
5311
  runId: id,
@@ -5074,6 +5333,12 @@ runtime = {}) {
5074
5333
  const decided = await gateForDecision(run, parsed.data.ord, { declining: !parsed.data.approve });
5075
5334
  if ('refusal' in decided)
5076
5335
  return decided.refusal;
5336
+ // (crew#1139) A note on a plan approval needs an engine that lands it. An older one refuses it with
5337
+ // words that predate notes ("send the edited steps"), so the daemon says what to do instead.
5338
+ if (parsed.data.approve && decided.gateKind === 'plan_approval' && (parsed.data.amend ?? '').trim() !== ''
5339
+ && !(typeof adapter.supportsPlanGateNote === 'function' && adapter.supportsPlanGateNote())) {
5340
+ return { code: 501, body: { error: message(new PlanGateNoteUnsupportedError()) } };
5341
+ }
5077
5342
  const analysis = parsed.data.approve ? analysisPlanRefusal(id, { plan: parsed.data.plan }) : null;
5078
5343
  if (analysis !== null)
5079
5344
  return analysis;
@@ -5120,7 +5385,9 @@ runtime = {}) {
5120
5385
  // confirm, which records it as the judge when this approve answers a `judge_unavailable`
5121
5386
  // gate ("judged by operator").
5122
5387
  adapter.recordGateActor?.(id, `${actor.id} (${actor.kind})`);
5123
- const status = await adapter.confirmGate(id, parsed.data.approve, parsed.data.amend, parsed.data.action, parsed.data.amendScope, parsed.data.plan !== undefined ? toLaunchPlan(parsed.data.plan) : undefined);
5388
+ const status = await adapter.confirmGate(id, parsed.data.approve,
5389
+ // (DES-RULE-CHECK-001 S2) The engine takes a rule skip's reasons in `amend` as JSON.
5390
+ parsed.data.action === SKIP_RULES_ACTION ? skipRulesAmend(parsed.data.skipRules ?? []) : parsed.data.amend, parsed.data.action, parsed.data.amendScope, parsed.data.plan !== undefined ? toLaunchPlan(parsed.data.plan) : undefined);
5124
5391
  // WHO approved/rejected — the gate-decision audit (task #88). The engine
5125
5392
  // records THAT the gate resolved (interaction_requests / gateDecided);
5126
5393
  // only this HTTP layer knows the authenticated principal behind it.
@@ -5132,6 +5399,13 @@ runtime = {}) {
5132
5399
  detail: { reason: parsed.data.amend ?? '', ...(gated !== undefined ? { ord: gated.ord } : {}), status },
5133
5400
  });
5134
5401
  }
5402
+ // (DES-RULE-CHECK-001 S2) Each skipped rule with its reason, on its own audit line.
5403
+ if (parsed.data.action === SKIP_RULES_ACTION) {
5404
+ audit.record('gate.rules_skipped', actor, {
5405
+ runId: id,
5406
+ detail: { skips: parsed.data.skipRules ?? [], ...(gated !== undefined ? { ord: gated.ord } : {}), status },
5407
+ });
5408
+ }
5135
5409
  audit.record('gate.decided', actor, {
5136
5410
  runId: id,
5137
5411
  detail: {
@@ -5184,7 +5458,7 @@ runtime = {}) {
5184
5458
  };
5185
5459
  }
5186
5460
  catch (err) {
5187
- if (err instanceof PlanLaunchUnsupportedError) {
5461
+ if (err instanceof PlanLaunchUnsupportedError || err instanceof PlanGateNoteUnsupportedError) {
5188
5462
  return { code: 501, body: { error: message(err) } };
5189
5463
  }
5190
5464
  return { code: 409, body: { error: message(err) } };
@@ -5395,11 +5669,9 @@ runtime = {}) {
5395
5669
  const RIGORS = ['light', 'standard', 'high', 'highest'];
5396
5670
  /** A trimmed free-text field: empty is absent (`null`), never `""`. */
5397
5671
  const textOrNull = (v) => (v === undefined || v === null || v.trim() === '' ? null : v.trim());
5398
- const PowerToggleSchema = z.object({ on: z.boolean(), reason: z.string().trim().max(2000).nullish() }).strict();
5399
- const RigorRaiseSchema = z.object({ atLeast: z.enum(RIGORS), reason: z.string().trim().min(1).max(2000) }).strict();
5400
- const PowerPauseSchema = z
5401
- .object({ decision: z.enum(['continue_high', 'continue', 'switch_phased', 'stop']), note: z.string().trim().max(8000).nullish() })
5402
- .strict();
5672
+ const PowerToggleSchema = z.strictObject({ on: z.boolean(), reason: z.string().trim().max(2000).nullish() });
5673
+ const RigorRaiseSchema = z.strictObject({ atLeast: z.enum(RIGORS), reason: z.string().trim().min(1).max(2000) });
5674
+ const PowerPauseSchema = z.strictObject({ decision: z.enum(['continue_high', 'continue', 'switch_phased', 'stop']), note: z.string().trim().max(8000).nullish() });
5403
5675
  /** An engine refusal as HTTP: `not_found:` 404, `conflict:` 409, `refused:` / `bad_request:` 409 / 400. */
5404
5676
  const powerError = (reply, err) => {
5405
5677
  const msg = message(err);
@@ -5927,23 +6199,21 @@ runtime = {}) {
5927
6199
  }
5928
6200
  return reply.code(404).send({ error: 'No pending elicitation for this run' });
5929
6201
  });
5930
- const ElicitationRespondSchema = z
5931
- .object({
6202
+ const ElicitationRespondSchema = z.strictObject({
5932
6203
  /** Guards against stale-tab submissions: must match the current elicitation's id. */
5933
6204
  elicitationId: z.string().min(1),
5934
6205
  action: z.enum(['accept', 'decline', 'cancel']),
5935
6206
  /** Required when action is "accept"; must be absent for decline/cancel. `response` answers a free-text or
5936
6207
  * single-choice question; `values` (api-types 0.158.0) a multi-select one. */
5937
6208
  content: z.union([
5938
- z.object({ response: z.string().min(1) }).strict(),
5939
- z.object({ values: z.array(z.string().min(1)).min(1).max(100) }).strict(),
6209
+ z.strictObject({ response: z.string().min(1) }),
6210
+ z.strictObject({ values: z.array(z.string().min(1)).min(1).max(100) }),
5940
6211
  ]).optional(),
5941
6212
  })
5942
- .strict()
5943
6213
  .superRefine((val, ctx) => {
5944
6214
  if (val.action !== 'accept' && val.content !== undefined) {
5945
6215
  ctx.addIssue({
5946
- code: z.ZodIssueCode.custom,
6216
+ code: 'custom',
5947
6217
  path: ['content'],
5948
6218
  message: 'content must only be provided when action is "accept"',
5949
6219
  });
@@ -6230,7 +6500,7 @@ runtime = {}) {
6230
6500
  },
6231
6501
  },
6232
6502
  }, async (req, reply) => {
6233
- const parsed = z.object({ dryRun: z.boolean().optional() }).strict().safeParse(req.body ?? {});
6503
+ const parsed = z.strictObject({ dryRun: z.boolean().optional() }).safeParse(req.body ?? {});
6234
6504
  if (!parsed.success)
6235
6505
  return reply.code(400).send({ error: parsed.error.message });
6236
6506
  const dryRun = parsed.data.dryRun === true;
@@ -6295,6 +6565,31 @@ runtime = {}) {
6295
6565
  // An unknown repo is the CALLER's error (404); a binding/parse failure is OURS (500). Don't collapse
6296
6566
  // them (Copilot #227). Core spells the not-found case `no registered repo '<ref>'`.
6297
6567
  const repoReadStatus = (msg) => (/no registered repo/i.test(msg) ? 404 : 500);
6568
+ // crew#1359: a registered repo with no code graph yet is "not indexed", a 404 with a code, never a 500. Only a
6569
+ // CONFIRMED missing graph file says so (the engine resolves the path, `code_graph_db`); any other open failure (a
6570
+ // permissions problem, a path that is a directory) stays a server error, its detail in the log (xreview r1/r2).
6571
+ const repoNotIndexed = async (repo) => {
6572
+ try {
6573
+ const entry = (await adapter.listRepos()).find((r) => r.id === repo || r.name === repo);
6574
+ const db = entry?.code_graph_db;
6575
+ if (typeof db !== 'string' || db === '')
6576
+ return false;
6577
+ // (xreview r2) Only ENOENT means "absent": existsSync is also false when a parent cannot be searched (EACCES).
6578
+ await fsp.stat(db);
6579
+ return false;
6580
+ }
6581
+ catch (err) {
6582
+ return err?.code === 'ENOENT';
6583
+ }
6584
+ };
6585
+ const repoReadFailure = async (reply, repo, err) => {
6586
+ const msg = message(err);
6587
+ const status = repoReadStatus(msg);
6588
+ if (status === 500 && (await repoNotIndexed(repo))) {
6589
+ return reply.code(404).send({ error: 'this repository has no code graph yet: index it first', code: 'not_indexed' });
6590
+ }
6591
+ return reply.code(status).send({ error: msg });
6592
+ };
6298
6593
  app.get(`${V}/governance/coverage`, async (req, reply) => {
6299
6594
  // FINDING-009: with `?repo=<ref>`, report coverage over THAT repo's own code graph. The bare
6300
6595
  // endpoint reads the daemon store and reports a vacuous `coverage: 1.0` that names no repo — the
@@ -6306,8 +6601,7 @@ runtime = {}) {
6306
6601
  return { report };
6307
6602
  }
6308
6603
  catch (err) {
6309
- const msg = message(err);
6310
- return reply.code(repoReadStatus(msg)).send({ error: msg });
6604
+ return repoReadFailure(reply, repo, err);
6311
6605
  }
6312
6606
  }
6313
6607
  const report = await adapter.getCoverageReport();
@@ -6327,8 +6621,7 @@ runtime = {}) {
6327
6621
  return { kinds };
6328
6622
  }
6329
6623
  catch (err) {
6330
- const msg = message(err);
6331
- return reply.code(repoReadStatus(msg)).send({ error: msg });
6624
+ return repoReadFailure(reply, repo, err);
6332
6625
  }
6333
6626
  });
6334
6627
  // ── Governance writes (crew#42; STEERING fold) ─────────────────────────────
@@ -6525,7 +6818,11 @@ runtime = {}) {
6525
6818
  retryOf: retryIndex.retryOfFor(view.session.id),
6526
6819
  principal: runTimingIndex.principalFor(view.session.id),
6527
6820
  }));
6528
- const body = buildWorkflowCatalog({ defs: workflows, presets, runs, actorId: me, projectId });
6821
+ const body = buildWorkflowCatalog({
6822
+ defs: workflows, presets, runs, actorId: me, projectId,
6823
+ // The same rule as `GET /health.capabilities.apps.turns`.
6824
+ appsByChat: runtime.apps !== undefined && runtime.apps.turns !== null,
6825
+ });
6529
6826
  return body;
6530
6827
  });
6531
6828
  app.get(`${V}/workflows/:id`, async (req, reply) => {
@@ -6636,8 +6933,8 @@ runtime = {}) {
6636
6933
  risk: z.enum(['risk', 'no-risk']).optional(),
6637
6934
  category: z.enum(['functional', 'config-data']).optional(),
6638
6935
  domain: z.string().optional(),
6639
- offset: z.coerce.number().int().min(0).default(0),
6640
- limit: z.coerce.number().int().min(1).max(200).default(50),
6936
+ offset: z.coerce.number().int().min(0).prefault(0),
6937
+ limit: z.coerce.number().int().min(1).max(200).prefault(50),
6641
6938
  }).strict();
6642
6939
  app.get(`${V}/repos/:id/requirements`, async (req, reply) => {
6643
6940
  const { id } = req.params;
@@ -6705,19 +7002,17 @@ runtime = {}) {
6705
7002
  return reply.code(404).send({ error: 'Requirement not found' });
6706
7003
  return { requirement: detail };
6707
7004
  });
6708
- const ReqPatchSchema = z
6709
- .object({
7005
+ const ReqPatchSchema = z.strictObject({
6710
7006
  title: z.string().min(1).max(500).optional(),
6711
7007
  notes: z.string().max(5000).optional(),
6712
7008
  status: z.enum(['active', 'deprecated', 'review']).optional(),
6713
7009
  risk: z.boolean().optional(),
6714
7010
  })
6715
- .strict()
6716
7011
  // `.strict()` BEFORE `.refine()`: the refine runs on the parsed object, so with stripping still
6717
7012
  // in effect `{"title":"x","note":"y"}` would pass the non-empty check having silently discarded
6718
7013
  // the edit the caller cared about. Every field here is optional, which is exactly the shape
6719
7014
  // FINDING-031 makes dangerous.
6720
- .refine((b) => Object.keys(b).length > 0, { message: 'empty patch' });
7015
+ .refine((b) => Object.keys(b).length > 0, { error: 'empty patch' });
6721
7016
  app.patch(`${V}/repos/:id/requirements/:key`, async (req, reply) => {
6722
7017
  const { id, key } = req.params;
6723
7018
  const repos = await adapter.listRepos();
@@ -6875,7 +7170,7 @@ runtime = {}) {
6875
7170
  });
6876
7171
  // `?limit=` (1..500, default 20): the repo page shows the latest 20; its "Show all" asks for more.
6877
7172
  const GitHistoryQuerySchema = z.object({
6878
- limit: z.coerce.number().int().min(1).max(500).default(20),
7173
+ limit: z.coerce.number().int().min(1).max(500).prefault(20),
6879
7174
  }).strict();
6880
7175
  app.get(`${V}/repos/:id/git-history`, async (req, reply) => {
6881
7176
  const { id } = req.params;
@@ -7599,6 +7894,18 @@ runtime = {}) {
7599
7894
  }
7600
7895
  return reply.code(201).send({ id: submitted.id });
7601
7896
  });
7897
+ // A data shape (`knowledge` proposal) is reviewed by a human: an agent-kind actor, whatever its trust, is refused.
7898
+ // Only a non-human's decision costs the extra queue read.
7899
+ const knowledgeReviewRefused = async (req, id) => {
7900
+ if (actorOf(req).kind === 'human')
7901
+ return false;
7902
+ const pending = (await estateTool('proposal.list', { kind_type: 'knowledge', state: 'pending' }));
7903
+ return pending.proposals.some((p) => p.id === id);
7904
+ };
7905
+ const KNOWLEDGE_REVIEW_HUMAN_ONLY = (actor) => ({
7906
+ error: `a data shape is approved or declined by a person; you are ${actor.kind}/${actor.trust}`,
7907
+ code: 'knowledge_review_human_only',
7908
+ });
7602
7909
  // POST /proposals/:id/approve → proposal.approve →
7603
7910
  // { outcome:'promoted', active_id } — a MEMORY proposal, now an active memory (complete);
7604
7911
  // { outcome:'handed_off', payload, landing } — a POLICY proposal, LANDED here as a steering rule.
@@ -7617,7 +7924,7 @@ runtime = {}) {
7617
7924
  requestType: 'ApproveProposalBody',
7618
7925
  responseType: 'ApproveProposalResponse',
7619
7926
  // 404: an accept-with-edit naming no pending proposal; 409: one already in flight for it.
7620
- statusCodes: [200, 400, 404, 409, 502],
7927
+ statusCodes: [200, 400, 403, 404, 409, 502],
7621
7928
  },
7622
7929
  },
7623
7930
  }, async (req, reply) => {
@@ -7628,6 +7935,14 @@ runtime = {}) {
7628
7935
  if (id === '') {
7629
7936
  return reply.code(400).send({ error: '`id` is required' });
7630
7937
  }
7938
+ // DES-KNOWLEDGE-DATA-001 §10.1: a data shape becomes knowledge only when a PERSON approves it.
7939
+ try {
7940
+ if (await knowledgeReviewRefused(req, id))
7941
+ return reply.code(403).send(KNOWLEDGE_REVIEW_HUMAN_ONLY(actorOf(req)));
7942
+ }
7943
+ catch (err) {
7944
+ return estateUpstreamError(reply, err);
7945
+ }
7631
7946
  // An accept WITH an edit (capture review, api-types 0.49.0): the edited copy replaces the
7632
7947
  // original in the same queue — see `approveEdited`. No body / `{}` is the plain approve below.
7633
7948
  const edit = ApproveEditSchema.safeParse(req.body ?? {});
@@ -7799,7 +8114,7 @@ runtime = {}) {
7799
8114
  // POST /proposals/:id/reject → proposal.reject → { ok: true }.
7800
8115
  app.post(`${V}/proposals/:id/reject`,
7801
8116
  // 409: an accept-with-edit of this proposal is in flight (api/capture.ts).
7802
- { config: { manifest: { responseType: 'RejectProposalResponse', statusCodes: [200, 400, 409, 502] } } }, async (req, reply) => {
8117
+ { config: { manifest: { responseType: 'RejectProposalResponse', statusCodes: [200, 400, 403, 409, 502] } } }, async (req, reply) => {
7803
8118
  const { id } = req.params;
7804
8119
  if (id.trim() === '') {
7805
8120
  return reply.code(400).send({ error: '`id` is required' });
@@ -7807,6 +8122,14 @@ runtime = {}) {
7807
8122
  if (editInFlight(id.trim())) {
7808
8123
  return reply.code(409).send({ error: `proposal ${id.trim()} is being accepted` });
7809
8124
  }
8125
+ // DES-KNOWLEDGE-DATA-001 §10.1: a data shape is declined by a person, as it is approved by one.
8126
+ try {
8127
+ if (await knowledgeReviewRefused(req, id.trim()))
8128
+ return reply.code(403).send(KNOWLEDGE_REVIEW_HUMAN_ONLY(actorOf(req)));
8129
+ }
8130
+ catch (err) {
8131
+ return estateUpstreamError(reply, err);
8132
+ }
7810
8133
  // DC-S4a B12: rejecting a decision's proposal dismisses the decision too (one object, two places).
7811
8134
  const rejectedDecision = decisions?.deps.ledger.decisionForProposal(id.trim()) ?? null;
7812
8135
  if (decisions !== null && rejectedDecision !== null) {
@@ -8338,11 +8661,77 @@ runtime = {}) {
8338
8661
  ...(runtime.askServer !== undefined ? { askServer: runtime.askServer } : {}),
8339
8662
  ...(runtime.mcp !== undefined ? { registry: runtime.mcp, toolLister: () => CoreAdapter.mcpToolLister() } : {}),
8340
8663
  ...(runtime.mcpBroker !== undefined ? { broker: runtime.mcpBroker } : {}),
8664
+ ...(runtime.dataGate !== undefined ? { gate: runtime.dataGate } : {}),
8341
8665
  ...(mcpPolicies !== undefined ? { policies: mcpPolicies } : {}),
8342
8666
  ...(runtime.mcpCalls !== undefined ? { usage: runtime.mcpCalls } : {}),
8343
8667
  audit,
8344
8668
  actorOf,
8345
8669
  });
8670
+ // Apps data sources (DES-APPS-001 §5): the source sheet's routes over the same registry. "Ask a
8671
+ // question of this data" drafts through the standing-order parse's one-shot seat turn (one seat, one
8672
+ // `understand` step, never the warm chat pool).
8673
+ registerSourceRoutes(app, {
8674
+ ...(runtime.mcp !== undefined ? { registry: runtime.mcp } : {}),
8675
+ audit,
8676
+ actorOf,
8677
+ // (K2b) Allow writes off withdraws the source's row-write grants.
8678
+ ...(appsWritePath !== undefined ? { rowWriteGrants: appsWritePath } : {}),
8679
+ draft: seatTurn({ adapter, roster: rosterWithStanding }),
8680
+ ...(runtime.dataGate !== undefined ? { gate: runtime.dataGate } : {}),
8681
+ });
8682
+ // DES-KNOWLEDGE-DATA-001 §7.1, §7.9: the per-source agent switches (human-only) and the read record.
8683
+ registerGateRoutes(app, {
8684
+ ...(runtime.mcpRegistryStore !== undefined ? { store: runtime.mcpRegistryStore } : {}),
8685
+ ...(runtime.sourceReads !== undefined ? { record: runtime.sourceReads } : {}),
8686
+ audit,
8687
+ actorOf,
8688
+ });
8689
+ // DES-PM-001 §3.3: tracker links (human-only), on the PM source's registry entry, projected into estate.
8690
+ registerTrackerRoutes(app, {
8691
+ ...(runtime.mcpRegistryStore !== undefined ? { store: runtime.mcpRegistryStore } : {}),
8692
+ ...(runtime.dataGate !== undefined ? { pm: runtime.dataGate.pm } : {}),
8693
+ projects: {
8694
+ get: (id) => adapter.projectGet(id),
8695
+ repos: (id) => repoMembersOf(id),
8696
+ ofRepo: (id) => adapter.memberProjects('crew.repo', id),
8697
+ allRepos: async () => (await adapter.listRepos()).map((r) => r.id),
8698
+ },
8699
+ audit,
8700
+ actorOf,
8701
+ ...(runtime.trackerProjector !== undefined ? { projection: runtime.trackerProjector.projection, changed: (_source, trackerId) => runtime.trackerProjector?.changed(trackerId) } : {}),
8702
+ });
8703
+ // DES-PM-001 §5: governed actions on a run's issues (comment, transition), human-only, asked every time in v1.
8704
+ registerTrackerActionRoutes(app, {
8705
+ ...(runtime.mcpRegistryStore !== undefined ? { store: runtime.mcpRegistryStore } : {}),
8706
+ ...(runtime.dataGate !== undefined ? { pm: runtime.dataGate.pm } : {}),
8707
+ ...(runtime.trackerAddresses !== undefined ? { addresses: runtime.trackerAddresses } : {}),
8708
+ runScope: async (runId) => {
8709
+ const run = (await adapter.sessionsDetail()).find((v) => v.session.id === runId);
8710
+ if (run === undefined)
8711
+ return null;
8712
+ const projectId = projects.index.projectOf(runId) ?? (await adapter.memberProjects('crew.run', runId).catch(() => []))[0] ?? null;
8713
+ return { projectId, repoId: run.session.repo_ref ?? null };
8714
+ },
8715
+ members: repoMembersOf,
8716
+ audit,
8717
+ actorOf,
8718
+ });
8719
+ // DES-KNOWLEDGE-DATA-001 §10 (B4): profile a source into data-shape proposals, and the Knowledge map (both human-only).
8720
+ registerShapeRoutes(app, {
8721
+ ...(runtime.mcp !== undefined ? { registry: runtime.mcp } : {}),
8722
+ ...(runtime.dataGate !== undefined ? { gate: runtime.dataGate } : {}),
8723
+ estate: estateTool,
8724
+ repos: () => adapter.listRepos(),
8725
+ audit,
8726
+ actorOf,
8727
+ ...(runtime.dataGate !== undefined
8728
+ ? {
8729
+ trackers: async () => (await runtime.dataGate.pm.entries()).flatMap((e) => e.trackers.map((t) => ({ id: t.id, source: e.name, key: t.key, label: t.label }))),
8730
+ projects: async () => (await adapter.projectList()).map((p) => ({ id: p.id, name: p.name })),
8731
+ }
8732
+ : {}),
8733
+ ...(appsKnowledge !== undefined ? { knowledge: appsKnowledge } : {}),
8734
+ });
8346
8735
  // ── The wicked-interactive bridge, reverse-proxied (DES-MERGE-001 §5.3/§7.2) ──
8347
8736
  // Mounted BESIDE the routes above and under the same `${V}` prefix, so it inherits one
8348
8737
  // origin, one auth hook, and one CORS posture — the whole point of slice 1.
@@ -8379,6 +8768,14 @@ runtime = {}) {
8379
8768
  }
8380
8769
  });
8381
8770
  // The roster's seats (on the container floor every seat runs in an image); `null` when unreadable.
8771
+ const rosterSeatsNow = () => {
8772
+ try {
8773
+ return rosterWithStanding();
8774
+ }
8775
+ catch {
8776
+ return [];
8777
+ }
8778
+ };
8382
8779
  const rosterSeatClis = () => {
8383
8780
  try {
8384
8781
  return rosterWithStanding().map((r) => String(r.key));
@@ -8497,13 +8894,16 @@ runtime = {}) {
8497
8894
  catch {
8498
8895
  return null;
8499
8896
  } })() : null;
8897
+ // The broker probe refreshes each container seat's sign-in: the seat images row reads which CLIs
8898
+ // are signed in only after it, as the CLI cards do.
8899
+ const brokerP = probeBroker({
8900
+ containerFloor,
8901
+ clis: roster.map((r) => r.key).filter((k) => isContainerLoginCli(k)),
8902
+ status: (cli) => containerStatus.refreshFresh(cli),
8903
+ });
8500
8904
  const infraP = Promise.all([
8501
8905
  probeGateway({ containerFloor, gatewayDir, runtime: containerFloor ? resolveContainerRuntime() : null, exec: systemExec }),
8502
- probeBroker({
8503
- containerFloor,
8504
- clis: roster.map((r) => r.key).filter((k) => isContainerLoginCli(k)),
8505
- status: (cli) => containerStatus.refreshFresh(cli),
8506
- }),
8906
+ brokerP,
8507
8907
  probeInteractive({
8508
8908
  roots: interactiveRoots,
8509
8909
  readLock: (root) => readBridgeLockAsync(root),
@@ -8519,7 +8919,18 @@ runtime = {}) {
8519
8919
  }),
8520
8920
  probeVault({ vault: adapter.vaultBin != null ? vaultDiagnostics(adapter.vaultBin) : null, exec: systemExec }),
8521
8921
  diskRow(stateHome),
8522
- probeSeatImages({ containerFloor, clis: rosterSeatClis(), status: seatImageStatus, rebuild: () => seatImageRebuilder.current() }),
8922
+ probeSeatImages({
8923
+ containerFloor,
8924
+ clis: rosterSeatClis(),
8925
+ // A CLI none of whose seats is signed in needs no image yet, read after the broker's refresh;
8926
+ // a CLI with any signed-in seat (`claude#2`) keeps its image.
8927
+ idle: async () => {
8928
+ await brokerP;
8929
+ return idleClis(rosterSeatsNow());
8930
+ },
8931
+ status: seatImageStatus,
8932
+ rebuild: () => seatImageRebuilder.current(),
8933
+ }),
8523
8934
  ]);
8524
8935
  const [views, settings, openGates, diag, ping, rules, gatesByYou, infraProbed, reposRead] = await Promise.all([
8525
8936
  viewsP, settingsP, gatesP, diagP, pingP, rulesP, gatesByYouP, infraP, reposP,