wicked-crew 0.17.1 → 0.18.1

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 (520) hide show
  1. package/README.md +49 -14
  2. package/adapters/web-source.lock +1314 -0
  3. package/dist/api/audit.d.ts +5 -0
  4. package/dist/api/audit.d.ts.map +1 -1
  5. package/dist/api/audit.js +20 -0
  6. package/dist/api/audit.js.map +1 -1
  7. package/dist/api/auth.d.ts.map +1 -1
  8. package/dist/api/auth.js +3 -0
  9. package/dist/api/auth.js.map +1 -1
  10. package/dist/api/chat-context.js +1 -1
  11. package/dist/api/chat-history.d.ts +3 -0
  12. package/dist/api/chat-history.d.ts.map +1 -1
  13. package/dist/api/chat-history.js +6 -1
  14. package/dist/api/chat-history.js.map +1 -1
  15. package/dist/api/chat-jobs.d.ts +30 -1
  16. package/dist/api/chat-jobs.d.ts.map +1 -1
  17. package/dist/api/chat-jobs.js +172 -10
  18. package/dist/api/chat-jobs.js.map +1 -1
  19. package/dist/api/chat-proposals.d.ts +178 -8
  20. package/dist/api/chat-proposals.d.ts.map +1 -1
  21. package/dist/api/chat-proposals.js +775 -54
  22. package/dist/api/chat-proposals.js.map +1 -1
  23. package/dist/api/chat-requirements.d.ts +54 -0
  24. package/dist/api/chat-requirements.d.ts.map +1 -0
  25. package/dist/api/chat-requirements.js +282 -0
  26. package/dist/api/chat-requirements.js.map +1 -0
  27. package/dist/api/chat-scope.d.ts +56 -0
  28. package/dist/api/chat-scope.d.ts.map +1 -1
  29. package/dist/api/chat-scope.js +175 -5
  30. package/dist/api/chat-scope.js.map +1 -1
  31. package/dist/api/chat-transcripts.d.ts +7 -0
  32. package/dist/api/chat-transcripts.d.ts.map +1 -1
  33. package/dist/api/chat-transcripts.js +17 -1
  34. package/dist/api/chat-transcripts.js.map +1 -1
  35. package/dist/api/delivery-index.d.ts +109 -5
  36. package/dist/api/delivery-index.d.ts.map +1 -1
  37. package/dist/api/delivery-index.js +199 -7
  38. package/dist/api/delivery-index.js.map +1 -1
  39. package/dist/api/mcp.d.ts +7 -2
  40. package/dist/api/mcp.d.ts.map +1 -1
  41. package/dist/api/mcp.js +1 -1
  42. package/dist/api/mcp.js.map +1 -1
  43. package/dist/api/needs.d.ts.map +1 -1
  44. package/dist/api/needs.js +19 -1
  45. package/dist/api/needs.js.map +1 -1
  46. package/dist/api/product.d.ts +9 -2
  47. package/dist/api/product.d.ts.map +1 -1
  48. package/dist/api/product.js +10 -2
  49. package/dist/api/product.js.map +1 -1
  50. package/dist/api/proposal-theme.d.ts +23 -0
  51. package/dist/api/proposal-theme.d.ts.map +1 -0
  52. package/dist/api/proposal-theme.js +30 -0
  53. package/dist/api/proposal-theme.js.map +1 -0
  54. package/dist/api/recording.d.ts +70 -10
  55. package/dist/api/recording.d.ts.map +1 -1
  56. package/dist/api/recording.js +278 -39
  57. package/dist/api/recording.js.map +1 -1
  58. package/dist/api/repo-input.d.ts +55 -0
  59. package/dist/api/repo-input.d.ts.map +1 -0
  60. package/dist/api/repo-input.js +113 -0
  61. package/dist/api/repo-input.js.map +1 -0
  62. package/dist/api/requirements.d.ts +75 -0
  63. package/dist/api/requirements.d.ts.map +1 -1
  64. package/dist/api/requirements.js +97 -9
  65. package/dist/api/requirements.js.map +1 -1
  66. package/dist/api/review-change.d.ts +64 -0
  67. package/dist/api/review-change.d.ts.map +1 -0
  68. package/dist/api/review-change.js +214 -0
  69. package/dist/api/review-change.js.map +1 -0
  70. package/dist/api/roster-standing.d.ts +4 -0
  71. package/dist/api/roster-standing.d.ts.map +1 -1
  72. package/dist/api/roster-standing.js +43 -10
  73. package/dist/api/roster-standing.js.map +1 -1
  74. package/dist/api/routes.d.ts +63 -6
  75. package/dist/api/routes.d.ts.map +1 -1
  76. package/dist/api/routes.js +818 -269
  77. package/dist/api/routes.js.map +1 -1
  78. package/dist/api/run-documents.d.ts +97 -0
  79. package/dist/api/run-documents.d.ts.map +1 -0
  80. package/dist/api/run-documents.js +458 -0
  81. package/dist/api/run-documents.js.map +1 -0
  82. package/dist/api/run-sources.d.ts +51 -0
  83. package/dist/api/run-sources.d.ts.map +1 -0
  84. package/dist/api/run-sources.js +133 -0
  85. package/dist/api/run-sources.js.map +1 -0
  86. package/dist/api/runtime-state.d.ts +41 -0
  87. package/dist/api/runtime-state.d.ts.map +1 -0
  88. package/dist/api/runtime-state.js +75 -0
  89. package/dist/api/runtime-state.js.map +1 -0
  90. package/dist/api/seat-container-login.d.ts +51 -0
  91. package/dist/api/seat-container-login.d.ts.map +1 -1
  92. package/dist/api/seat-container-login.js +317 -1
  93. package/dist/api/seat-container-login.js.map +1 -1
  94. package/dist/api/seat-images.d.ts.map +1 -1
  95. package/dist/api/seat-images.js +7 -0
  96. package/dist/api/seat-images.js.map +1 -1
  97. package/dist/api/server.d.ts +7 -0
  98. package/dist/api/server.d.ts.map +1 -1
  99. package/dist/api/server.js +206 -25
  100. package/dist/api/server.js.map +1 -1
  101. package/dist/api/skills.d.ts +8 -0
  102. package/dist/api/skills.d.ts.map +1 -1
  103. package/dist/api/skills.js +21 -0
  104. package/dist/api/skills.js.map +1 -1
  105. package/dist/api/system-snapshot.d.ts +7 -2
  106. package/dist/api/system-snapshot.d.ts.map +1 -1
  107. package/dist/api/system-snapshot.js +31 -7
  108. package/dist/api/system-snapshot.js.map +1 -1
  109. package/dist/api/testing.d.ts +3 -3
  110. package/dist/api/ui-text.d.ts +45 -0
  111. package/dist/api/ui-text.d.ts.map +1 -0
  112. package/dist/api/ui-text.js +188 -0
  113. package/dist/api/ui-text.js.map +1 -0
  114. package/dist/apps/actions/card.d.ts +62 -0
  115. package/dist/apps/actions/card.d.ts.map +1 -0
  116. package/dist/apps/actions/card.js +111 -0
  117. package/dist/apps/actions/card.js.map +1 -0
  118. package/dist/apps/actions/write-path.d.ts.map +1 -1
  119. package/dist/apps/actions/write-path.js +26 -77
  120. package/dist/apps/actions/write-path.js.map +1 -1
  121. package/dist/apps/exec/sources.d.ts.map +1 -1
  122. package/dist/apps/exec/sources.js +3 -0
  123. package/dist/apps/exec/sources.js.map +1 -1
  124. package/dist/apps/publish/artifacts.d.ts +18 -0
  125. package/dist/apps/publish/artifacts.d.ts.map +1 -0
  126. package/dist/apps/publish/artifacts.js +87 -0
  127. package/dist/apps/publish/artifacts.js.map +1 -0
  128. package/dist/apps/publish/check.d.ts +103 -0
  129. package/dist/apps/publish/check.d.ts.map +1 -0
  130. package/dist/apps/publish/check.js +235 -0
  131. package/dist/apps/publish/check.js.map +1 -0
  132. package/dist/apps/publish/image.d.ts +2 -0
  133. package/dist/apps/publish/image.d.ts.map +1 -1
  134. package/dist/apps/publish/image.js +2 -1
  135. package/dist/apps/publish/image.js.map +1 -1
  136. package/dist/apps/publish/render.d.ts +71 -0
  137. package/dist/apps/publish/render.d.ts.map +1 -0
  138. package/dist/apps/publish/render.js +122 -0
  139. package/dist/apps/publish/render.js.map +1 -0
  140. package/dist/apps/publish/run.d.ts +35 -0
  141. package/dist/apps/publish/run.d.ts.map +1 -0
  142. package/dist/apps/publish/run.js +127 -0
  143. package/dist/apps/publish/run.js.map +1 -0
  144. package/dist/apps/routes.d.ts +54 -2
  145. package/dist/apps/routes.d.ts.map +1 -1
  146. package/dist/apps/routes.js +124 -7
  147. package/dist/apps/routes.js.map +1 -1
  148. package/dist/apps/spec.d.ts +8 -8
  149. package/dist/apps/store.d.ts +84 -5
  150. package/dist/apps/store.d.ts.map +1 -1
  151. package/dist/apps/store.js +191 -4
  152. package/dist/apps/store.js.map +1 -1
  153. package/dist/apps/turns.d.ts +19 -1
  154. package/dist/apps/turns.d.ts.map +1 -1
  155. package/dist/apps/turns.js +60 -2
  156. package/dist/apps/turns.js.map +1 -1
  157. package/dist/apps/views.d.ts +5 -1
  158. package/dist/apps/views.d.ts.map +1 -1
  159. package/dist/apps/views.js +18 -7
  160. package/dist/apps/views.js.map +1 -1
  161. package/dist/apps-server/Dockerfile +25 -0
  162. package/dist/apps-server/runners/sqlite-runner.mjs +110 -0
  163. package/dist/apps-server/server/lib/bundle/server.mjs +92523 -0
  164. package/dist/apps-server/server/node_modules/@pgsql/types/LICENSE +22 -0
  165. package/dist/apps-server/server/node_modules/@pgsql/types/README.md +106 -0
  166. package/dist/apps-server/server/node_modules/@pgsql/types/enums.d.ts +76 -0
  167. package/dist/apps-server/server/node_modules/@pgsql/types/enums.js +2 -0
  168. package/dist/apps-server/server/node_modules/@pgsql/types/esm/enums.js +1 -0
  169. package/dist/apps-server/server/node_modules/@pgsql/types/esm/index.js +2 -0
  170. package/dist/apps-server/server/node_modules/@pgsql/types/esm/types.js +1 -0
  171. package/dist/apps-server/server/node_modules/@pgsql/types/index.d.ts +2 -0
  172. package/dist/apps-server/server/node_modules/@pgsql/types/index.js +18 -0
  173. package/dist/apps-server/server/node_modules/@pgsql/types/package.json +36 -0
  174. package/dist/apps-server/server/node_modules/@pgsql/types/types.d.ts +2488 -0
  175. package/dist/apps-server/server/node_modules/@pgsql/types/types.js +2 -0
  176. package/dist/apps-server/server/node_modules/libpg-query/LICENSE +22 -0
  177. package/dist/apps-server/server/node_modules/libpg-query/README.md +275 -0
  178. package/dist/apps-server/server/node_modules/libpg-query/package.json +58 -0
  179. package/dist/apps-server/server/node_modules/libpg-query/wasm/index.cjs +369 -0
  180. package/dist/apps-server/server/node_modules/libpg-query/wasm/index.d.ts +48 -0
  181. package/dist/apps-server/server/node_modules/libpg-query/wasm/index.js +344 -0
  182. package/dist/apps-server/server/node_modules/libpg-query/wasm/libpg-query.js +2 -0
  183. package/dist/apps-server/server/node_modules/libpg-query/wasm/libpg-query.wasm +0 -0
  184. package/dist/apps-server/server/shim/host.css +22 -0
  185. package/dist/apps-server/server/shim/host.js +1 -0
  186. package/dist/cli/apps-check.d.ts +18 -0
  187. package/dist/cli/apps-check.d.ts.map +1 -1
  188. package/dist/cli/apps-check.js +179 -5
  189. package/dist/cli/apps-check.js.map +1 -1
  190. package/dist/cli/apps-produce.d.ts +9 -0
  191. package/dist/cli/apps-produce.d.ts.map +1 -0
  192. package/dist/cli/apps-produce.js +27 -0
  193. package/dist/cli/apps-produce.js.map +1 -0
  194. package/dist/cli/index.d.ts.map +1 -1
  195. package/dist/cli/index.js +15 -3
  196. package/dist/cli/index.js.map +1 -1
  197. package/dist/cli/insights-facts.d.ts +17 -0
  198. package/dist/cli/insights-facts.d.ts.map +1 -0
  199. package/dist/cli/insights-facts.js +56 -0
  200. package/dist/cli/insights-facts.js.map +1 -0
  201. package/dist/core/adapter.d.ts +74 -15
  202. package/dist/core/adapter.d.ts.map +1 -1
  203. package/dist/core/adapter.js +245 -53
  204. package/dist/core/adapter.js.map +1 -1
  205. package/dist/core/engine-roster.d.ts.map +1 -1
  206. package/dist/core/engine-roster.js +1 -0
  207. package/dist/core/engine-roster.js.map +1 -1
  208. package/dist/core/estate-mcp-client.d.ts +3 -2
  209. package/dist/core/estate-mcp-client.d.ts.map +1 -1
  210. package/dist/core/estate-mcp-client.js +3 -2
  211. package/dist/core/estate-mcp-client.js.map +1 -1
  212. package/dist/core/run-identity.d.ts.map +1 -1
  213. package/dist/core/run-identity.js +3 -0
  214. package/dist/core/run-identity.js.map +1 -1
  215. package/dist/core/types.d.ts +5 -0
  216. package/dist/core/types.d.ts.map +1 -1
  217. package/dist/core/types.js.map +1 -1
  218. package/dist/editors/conformance-runtime.d.ts +107 -0
  219. package/dist/editors/conformance-runtime.d.ts.map +1 -1
  220. package/dist/editors/conformance-runtime.js +268 -13
  221. package/dist/editors/conformance-runtime.js.map +1 -1
  222. package/dist/editors/csp.d.ts +2 -2
  223. package/dist/editors/csp.d.ts.map +1 -1
  224. package/dist/editors/csp.js +4 -2
  225. package/dist/editors/csp.js.map +1 -1
  226. package/dist/editors/pack-install.d.ts +28 -13
  227. package/dist/editors/pack-install.d.ts.map +1 -1
  228. package/dist/editors/pack-install.js +96 -48
  229. package/dist/editors/pack-install.js.map +1 -1
  230. package/dist/editors/registry.d.ts +111 -8
  231. package/dist/editors/registry.d.ts.map +1 -1
  232. package/dist/editors/registry.js +183 -7
  233. package/dist/editors/registry.js.map +1 -1
  234. package/dist/editors/routes.d.ts +66 -13
  235. package/dist/editors/routes.d.ts.map +1 -1
  236. package/dist/editors/routes.js +277 -44
  237. package/dist/editors/routes.js.map +1 -1
  238. package/dist/evals/replay.d.ts +6 -0
  239. package/dist/evals/replay.d.ts.map +1 -1
  240. package/dist/evals/replay.js +24 -1
  241. package/dist/evals/replay.js.map +1 -1
  242. package/dist/evals/routes.d.ts.map +1 -1
  243. package/dist/evals/routes.js +17 -2
  244. package/dist/evals/routes.js.map +1 -1
  245. package/dist/evals/runner.d.ts.map +1 -1
  246. package/dist/evals/runner.js +5 -0
  247. package/dist/evals/runner.js.map +1 -1
  248. package/dist/evals/shape-corrections.d.ts +146 -0
  249. package/dist/evals/shape-corrections.d.ts.map +1 -0
  250. package/dist/evals/shape-corrections.js +394 -0
  251. package/dist/evals/shape-corrections.js.map +1 -0
  252. package/dist/evals/shape.d.ts +145 -0
  253. package/dist/evals/shape.d.ts.map +1 -0
  254. package/dist/evals/shape.js +376 -0
  255. package/dist/evals/shape.js.map +1 -0
  256. package/dist/evals/types.d.ts +2 -2
  257. package/dist/evals/types.d.ts.map +1 -1
  258. package/dist/evals/types.js +2 -1
  259. package/dist/evals/types.js.map +1 -1
  260. package/dist/insights/analyze.d.ts +14 -1
  261. package/dist/insights/analyze.d.ts.map +1 -1
  262. package/dist/insights/analyze.js +35 -8
  263. package/dist/insights/analyze.js.map +1 -1
  264. package/dist/insights/cost.d.ts +123 -0
  265. package/dist/insights/cost.d.ts.map +1 -0
  266. package/dist/insights/cost.js +221 -0
  267. package/dist/insights/cost.js.map +1 -0
  268. package/dist/insights/review-service.d.ts +20 -1
  269. package/dist/insights/review-service.d.ts.map +1 -1
  270. package/dist/insights/review-service.js +50 -25
  271. package/dist/insights/review-service.js.map +1 -1
  272. package/dist/insights/routes.d.ts +29 -0
  273. package/dist/insights/routes.d.ts.map +1 -1
  274. package/dist/insights/routes.js +62 -0
  275. package/dist/insights/routes.js.map +1 -1
  276. package/dist/insights/run-facts.d.ts +16 -0
  277. package/dist/insights/run-facts.d.ts.map +1 -1
  278. package/dist/insights/run-facts.js +26 -3
  279. package/dist/insights/run-facts.js.map +1 -1
  280. package/dist/interactive/bridge-pool.d.ts +11 -2
  281. package/dist/interactive/bridge-pool.d.ts.map +1 -1
  282. package/dist/interactive/bridge-pool.js +10 -1
  283. package/dist/interactive/bridge-pool.js.map +1 -1
  284. package/dist/interactive/chat-events.d.ts +74 -1
  285. package/dist/interactive/chat-events.d.ts.map +1 -1
  286. package/dist/interactive/chat-events.js +338 -6
  287. package/dist/interactive/chat-events.js.map +1 -1
  288. package/dist/interactive/doc-binding.d.ts +15 -0
  289. package/dist/interactive/doc-binding.d.ts.map +1 -1
  290. package/dist/interactive/doc-binding.js +4 -0
  291. package/dist/interactive/doc-binding.js.map +1 -1
  292. package/dist/interactive/doc-checks-routes.d.ts +34 -1
  293. package/dist/interactive/doc-checks-routes.d.ts.map +1 -1
  294. package/dist/interactive/doc-checks-routes.js +84 -0
  295. package/dist/interactive/doc-checks-routes.js.map +1 -1
  296. package/dist/interactive/draft-events.d.ts +7 -0
  297. package/dist/interactive/draft-events.d.ts.map +1 -1
  298. package/dist/interactive/draft-events.js +38 -6
  299. package/dist/interactive/draft-events.js.map +1 -1
  300. package/dist/interactive/draft-skill.d.ts +76 -6
  301. package/dist/interactive/draft-skill.d.ts.map +1 -1
  302. package/dist/interactive/draft-skill.js +219 -17
  303. package/dist/interactive/draft-skill.js.map +1 -1
  304. package/dist/interactive/edit-events.d.ts.map +1 -1
  305. package/dist/interactive/edit-events.js +4 -2
  306. package/dist/interactive/edit-events.js.map +1 -1
  307. package/dist/interactive/landing-guard.d.ts +47 -0
  308. package/dist/interactive/landing-guard.d.ts.map +1 -0
  309. package/dist/interactive/landing-guard.js +43 -0
  310. package/dist/interactive/landing-guard.js.map +1 -0
  311. package/dist/interactive/landing-record.d.ts +68 -0
  312. package/dist/interactive/landing-record.d.ts.map +1 -0
  313. package/dist/interactive/landing-record.js +154 -0
  314. package/dist/interactive/landing-record.js.map +1 -0
  315. package/dist/interactive/proposal-create.d.ts +3 -1
  316. package/dist/interactive/proposal-create.d.ts.map +1 -1
  317. package/dist/interactive/proposal-create.js +14 -2
  318. package/dist/interactive/proposal-create.js.map +1 -1
  319. package/dist/interactive/proposal-refine.d.ts +48 -0
  320. package/dist/interactive/proposal-refine.d.ts.map +1 -0
  321. package/dist/interactive/proposal-refine.js +99 -0
  322. package/dist/interactive/proposal-refine.js.map +1 -0
  323. package/dist/interactive/protected-edits.d.ts +67 -0
  324. package/dist/interactive/protected-edits.d.ts.map +1 -0
  325. package/dist/interactive/protected-edits.js +160 -0
  326. package/dist/interactive/protected-edits.js.map +1 -0
  327. package/dist/interactive/proxy-routes.js +2 -2
  328. package/dist/interactive/review-events.js +1 -1
  329. package/dist/interactive/run-units.d.ts +1 -1
  330. package/dist/interactive/run-units.d.ts.map +1 -1
  331. package/dist/interactive/run-units.js +8 -2
  332. package/dist/interactive/run-units.js.map +1 -1
  333. package/dist/interactive/source-packet.d.ts +66 -1
  334. package/dist/interactive/source-packet.d.ts.map +1 -1
  335. package/dist/interactive/source-packet.js +309 -60
  336. package/dist/interactive/source-packet.js.map +1 -1
  337. package/dist/interactive/theme-events.js +1 -1
  338. package/dist/knowledge/adapters/web/egress.d.ts +99 -0
  339. package/dist/knowledge/adapters/web/egress.d.ts.map +1 -0
  340. package/dist/knowledge/adapters/web/egress.js +330 -0
  341. package/dist/knowledge/adapters/web/egress.js.map +1 -0
  342. package/dist/knowledge/adapters/web/engine.d.ts +54 -0
  343. package/dist/knowledge/adapters/web/engine.d.ts.map +1 -0
  344. package/dist/knowledge/adapters/web/engine.js +101 -0
  345. package/dist/knowledge/adapters/web/engine.js.map +1 -0
  346. package/dist/knowledge/adapters/web/fetch.d.ts +131 -0
  347. package/dist/knowledge/adapters/web/fetch.d.ts.map +1 -0
  348. package/dist/knowledge/adapters/web/fetch.js +325 -0
  349. package/dist/knowledge/adapters/web/fetch.js.map +1 -0
  350. package/dist/knowledge/adapters/web/gate-web.d.ts +182 -0
  351. package/dist/knowledge/adapters/web/gate-web.d.ts.map +1 -0
  352. package/dist/knowledge/adapters/web/gate-web.js +496 -0
  353. package/dist/knowledge/adapters/web/gate-web.js.map +1 -0
  354. package/dist/knowledge/adapters/web/routes.d.ts +36 -0
  355. package/dist/knowledge/adapters/web/routes.d.ts.map +1 -0
  356. package/dist/knowledge/adapters/web/routes.js +99 -0
  357. package/dist/knowledge/adapters/web/routes.js.map +1 -0
  358. package/dist/knowledge/adapters/web/searxng.d.ts +89 -0
  359. package/dist/knowledge/adapters/web/searxng.d.ts.map +1 -0
  360. package/dist/knowledge/adapters/web/searxng.js +274 -0
  361. package/dist/knowledge/adapters/web/searxng.js.map +1 -0
  362. package/dist/knowledge/adapters/web/source.d.ts +65 -0
  363. package/dist/knowledge/adapters/web/source.d.ts.map +1 -0
  364. package/dist/knowledge/adapters/web/source.js +192 -0
  365. package/dist/knowledge/adapters/web/source.js.map +1 -0
  366. package/dist/knowledge/gate/gate.d.ts +22 -0
  367. package/dist/knowledge/gate/gate.d.ts.map +1 -1
  368. package/dist/knowledge/gate/gate.js +62 -1
  369. package/dist/knowledge/gate/gate.js.map +1 -1
  370. package/dist/knowledge/gate/sources.d.ts +2 -0
  371. package/dist/knowledge/gate/sources.d.ts.map +1 -1
  372. package/dist/knowledge/gate/sources.js +5 -2
  373. package/dist/knowledge/gate/sources.js.map +1 -1
  374. package/dist/knowledge/package.d.ts +7 -0
  375. package/dist/knowledge/package.d.ts.map +1 -1
  376. package/dist/knowledge/package.js +15 -1
  377. package/dist/knowledge/package.js.map +1 -1
  378. package/dist/knowledge/trackers/actions.js +1 -1
  379. package/dist/knowledge/trackers/actions.js.map +1 -1
  380. package/dist/knowledge/trackers/bindings.d.ts +3 -3
  381. package/dist/knowledge/trackers/bindings.d.ts.map +1 -1
  382. package/dist/knowledge/trackers/bindings.js +36 -23
  383. package/dist/knowledge/trackers/bindings.js.map +1 -1
  384. package/dist/knowledge/trackers/routes.js +1 -1
  385. package/dist/knowledge/trackers/routes.js.map +1 -1
  386. package/dist/learnings/service.d.ts.map +1 -1
  387. package/dist/learnings/service.js +2 -0
  388. package/dist/learnings/service.js.map +1 -1
  389. package/dist/mcp/broker.d.ts +8 -0
  390. package/dist/mcp/broker.d.ts.map +1 -1
  391. package/dist/mcp/broker.js +48 -3
  392. package/dist/mcp/broker.js.map +1 -1
  393. package/dist/mcp/estate-relay.d.ts +43 -1
  394. package/dist/mcp/estate-relay.d.ts.map +1 -1
  395. package/dist/mcp/estate-relay.js +38 -2
  396. package/dist/mcp/estate-relay.js.map +1 -1
  397. package/dist/mcp/registry.d.ts +6 -0
  398. package/dist/mcp/registry.d.ts.map +1 -1
  399. package/dist/mcp/registry.js +42 -3
  400. package/dist/mcp/registry.js.map +1 -1
  401. package/dist/mcp/run-fence.d.ts +57 -0
  402. package/dist/mcp/run-fence.d.ts.map +1 -0
  403. package/dist/mcp/run-fence.js +86 -0
  404. package/dist/mcp/run-fence.js.map +1 -0
  405. package/dist/mcp/tool-list.d.ts +5 -0
  406. package/dist/mcp/tool-list.d.ts.map +1 -1
  407. package/dist/mcp/tool-list.js +7 -3
  408. package/dist/mcp/tool-list.js.map +1 -1
  409. package/dist/presets/routes.d.ts.map +1 -1
  410. package/dist/presets/routes.js +6 -0
  411. package/dist/presets/routes.js.map +1 -1
  412. package/dist/projects/routes.d.ts +1 -1
  413. package/dist/projects/state-home-preflight.d.ts.map +1 -1
  414. package/dist/projects/state-home-preflight.js +2 -0
  415. package/dist/projects/state-home-preflight.js.map +1 -1
  416. package/dist/setup/tool-path.d.ts +16 -0
  417. package/dist/setup/tool-path.d.ts.map +1 -0
  418. package/dist/setup/tool-path.js +66 -0
  419. package/dist/setup/tool-path.js.map +1 -0
  420. package/dist/skills/plugin-source.d.ts +46 -88
  421. package/dist/skills/plugin-source.d.ts.map +1 -1
  422. package/dist/skills/plugin-source.js +144 -100
  423. package/dist/skills/plugin-source.js.map +1 -1
  424. package/dist/skills/runtime.d.ts +47 -0
  425. package/dist/skills/runtime.d.ts.map +1 -1
  426. package/dist/skills/runtime.js +110 -14
  427. package/dist/skills/runtime.js.map +1 -1
  428. package/dist/skills/store.d.ts +2 -0
  429. package/dist/skills/store.d.ts.map +1 -1
  430. package/dist/skills/store.js +29 -14
  431. package/dist/skills/store.js.map +1 -1
  432. package/dist/skills/usage.d.ts +238 -0
  433. package/dist/skills/usage.d.ts.map +1 -0
  434. package/dist/skills/usage.js +789 -0
  435. package/dist/skills/usage.js.map +1 -0
  436. package/dist/skills/venv.d.ts +18 -2
  437. package/dist/skills/venv.d.ts.map +1 -1
  438. package/dist/skills/venv.js +2 -2
  439. package/dist/skills/venv.js.map +1 -1
  440. package/dist/sources/routes.d.ts +3 -1
  441. package/dist/sources/routes.d.ts.map +1 -1
  442. package/dist/sources/routes.js +11 -0
  443. package/dist/sources/routes.js.map +1 -1
  444. package/dist/standing-orders/parse.d.ts +19 -0
  445. package/dist/standing-orders/parse.d.ts.map +1 -1
  446. package/dist/standing-orders/parse.js +61 -18
  447. package/dist/standing-orders/parse.js.map +1 -1
  448. package/dist/studio/apps-standalone/fixture.html +12 -0
  449. package/dist/studio/apps-standalone/fixture.js +10 -0
  450. package/dist/studio/apps-standalone/runtime.css +139 -0
  451. package/dist/studio/apps-standalone/runtime.js +1 -0
  452. package/dist/studio/assets/{KnowledgeGraph-Cpm46tEp.js → KnowledgeGraph-BT5Y-B8b.js} +1 -1
  453. package/dist/studio/assets/index-B_JwrHVF.css +32 -0
  454. package/dist/studio/assets/index-Bl9m8ldl.js +1104 -0
  455. package/dist/studio/editors/wicked-apps/editor.json +1 -1
  456. package/dist/studio/editors/wicked-apps/index.html +2 -2
  457. package/dist/studio/editors/wicked-deck/editor.json +1 -1
  458. package/dist/studio/editors/wicked-deck/index.html +14 -1
  459. package/dist/studio/editors/wicked-doc/editor.json +1 -1
  460. package/dist/studio/editors/wicked-doc/index.html +1 -1
  461. package/dist/studio/editors/wicked-insights/editor.json +1 -1
  462. package/dist/studio/editors/wicked-insights/index.html +1 -1
  463. package/dist/studio/editors/wicked-page/editor.json +10 -1
  464. package/dist/studio/editors/wicked-page/index.html +2 -2
  465. package/dist/studio/editors/wicked-video/editor.json +7 -2
  466. package/dist/studio/editors/wicked-video/index.html +14 -11
  467. package/dist/studio/index.html +2 -2
  468. package/dist/studio/testid-inventory.json +2073 -240
  469. package/dist/team/routes.d.ts +1 -1
  470. package/dist/workflow-catalog/build-v2.d.ts +6 -2
  471. package/dist/workflow-catalog/build-v2.d.ts.map +1 -1
  472. package/dist/workflow-catalog/build-v2.js +37 -13
  473. package/dist/workflow-catalog/build-v2.js.map +1 -1
  474. package/dist/workflow-catalog/catalog-data-v2.d.ts.map +1 -1
  475. package/dist/workflow-catalog/catalog-data-v2.js +310 -105
  476. package/dist/workflow-catalog/catalog-data-v2.js.map +1 -1
  477. package/dist/workflow-catalog/catalog-data.d.ts.map +1 -1
  478. package/dist/workflow-catalog/catalog-data.js +2 -20
  479. package/dist/workflow-catalog/catalog-data.js.map +1 -1
  480. package/dist/workflow-catalog/detect-service.d.ts +95 -0
  481. package/dist/workflow-catalog/detect-service.d.ts.map +1 -0
  482. package/dist/workflow-catalog/detect-service.js +239 -0
  483. package/dist/workflow-catalog/detect-service.js.map +1 -0
  484. package/dist/workflow-catalog/detect.d.ts +213 -0
  485. package/dist/workflow-catalog/detect.d.ts.map +1 -0
  486. package/dist/workflow-catalog/detect.js +653 -0
  487. package/dist/workflow-catalog/detect.js.map +1 -0
  488. package/dist/workflow-catalog/shape.d.ts +3 -1
  489. package/dist/workflow-catalog/shape.d.ts.map +1 -1
  490. package/dist/workflow-catalog/shape.js +7 -1
  491. package/dist/workflow-catalog/shape.js.map +1 -1
  492. package/dist/working-doc/bridge-backend.js +2 -2
  493. package/dist/working-doc/event-lines.d.ts +67 -2
  494. package/dist/working-doc/event-lines.d.ts.map +1 -1
  495. package/dist/working-doc/event-lines.js +155 -8
  496. package/dist/working-doc/event-lines.js.map +1 -1
  497. package/dist/working-doc/notes-index.d.ts +35 -0
  498. package/dist/working-doc/notes-index.d.ts.map +1 -0
  499. package/dist/working-doc/notes-index.js +82 -0
  500. package/dist/working-doc/notes-index.js.map +1 -0
  501. package/dist/working-doc/routes.js +4 -4
  502. package/dist/working-doc/sections.js +2 -2
  503. package/dist/working-doc/service.d.ts +260 -21
  504. package/dist/working-doc/service.d.ts.map +1 -1
  505. package/dist/working-doc/service.js +791 -90
  506. package/dist/working-doc/service.js.map +1 -1
  507. package/dist/working-doc/store.d.ts +50 -1
  508. package/dist/working-doc/store.d.ts.map +1 -1
  509. package/dist/working-doc/store.js +4 -1
  510. package/dist/working-doc/store.js.map +1 -1
  511. package/endpoint-manifest.json +187 -3
  512. package/evals/corpora/shape-corrections-v1.json +594 -0
  513. package/evals/corpora/shape-corrections-v1.seat-fixture.json +186 -0
  514. package/evals/corpora/shape-v1.json +2113 -0
  515. package/evals/corpora/shape-v1.seat-fixture.json +1800 -0
  516. package/package.json +11 -7
  517. package/scripts/apps-render.py +226 -0
  518. package/workflows/detect-shape.json +29 -0
  519. package/dist/studio/assets/index-BRBwWQMH.css +0 -32
  520. package/dist/studio/assets/index-CVrWDGRP.js +0 -1097
@@ -1,18 +1,35 @@
1
1
  /**
2
2
  * `/api/v1/editors` (DES-artifact-editor-plugins §6, §8.2, §9.1; EP-C1).
3
3
  *
4
- * - `GET /editors` (operator+): the registry, as Settings → Editors renders it.
5
- * - `POST /editors {packRoot, enabled?}` (HUMAN-only): install or update a pack's editors — garden's
6
- * fail-closed gate, then crew's own conformance run, then the registry (`pack-install.ts`). 200 with
4
+ * - `GET /editors` (operator+): the registry, as Settings → Editors renders it. A run plugin (CS7) lists as an
5
+ * `EditorView` row too, its `granted_topics` filled from the engine's observe decisions (`[]` when it cannot
6
+ * decide them: fail closed).
7
+ * - `POST /editors {packRoot, enabled?}` (HUMAN-only): install or update a pack's editors and/or run plugins —
8
+ * garden's fail-closed gate, then crew's own conformance run, then the registry (`pack-install.ts`). 200 with
7
9
  * the installed editors; 422 with the verdict or the conformance report; 501 with the approval list
8
- * for a pack that also ships skills or blocks; 409 for an id another pack or a first-party editor holds.
9
- * - `DELETE /editors/:id` (HUMAN-only): an installed pack editor is removed from the registry (the
10
- * installer deletes its files); a first-party editor ships with studio and cannot be removed (409;
11
- * disable it instead).
10
+ * for a pack that also ships skills or blocks; 409 for an id another pack or a first-party editor holds. The
11
+ * install consent writes each installed plugin's `observe:<topic>` tokens (CS7 C3), beside the editors'
12
+ * `mcp.session` tokens, in one ledger edit.
13
+ * - `DELETE /editors/:id` (HUMAN-only): an installed pack editor or run plugin is removed from the registry (the
14
+ * installer deletes its files); every `editor:<id>@` and `plugin:<id>@` grant of it is withdrawn. A first-party
15
+ * editor ships with studio and cannot be removed (409; disable it instead).
12
16
  * - `POST /editors/:id/enabled {enabled}` (HUMAN-only): the operator's switch.
13
17
  * - `GET /editors/:id/grants?project=` (operator+): the engine's decided set
14
18
  * (`evaluate_editor_grants`: EDITOR-GRANTS ledger + EDITOR-BUILTIN posture, deny dominates), with
15
19
  * the token an "allow" would add. The host fetches it before `host.hello` and enforces it.
20
+ * - `GET /editors/:id/grants` for a run plugin answers the engine's observe decisions (CS7 C3): one grant per
21
+ * declared topic, deny dominating.
22
+ * - `POST /editors/:id/grants` for a run plugin is 409 `install_only` (CS7 C3): its topics are granted by the
23
+ * install consent alone; Remove withdraws them.
24
+ * - `POST /editors/:id/grants {permission, allow, version, sha256, project?}` (HUMAN-only, §6.4; F37):
25
+ * the person's allow or revoke of one permission the editor declares, for the build they were shown
26
+ * (`version` + `sha256` must still be the installed build, else 409 `build_changed`). Allow writes
27
+ * that build's token (built from crew's own record) into the EDITOR-GRANTS ledger, for every project;
28
+ * revoke drops every token of that editor and permission. `mcp.session` is the install consent's
29
+ * alone (409 `install_only`). Under `auth=off` a request carrying a governed unit's token is refused
30
+ * (403 `seat_token`; 503 when the engine cannot tell; under `auth=required` such a token is no identity
31
+ * at all: 401). An install, update or removal drops every grant of the editor. `project` only
32
+ * scopes the answer: the decided set after the write, so a project deny that dominates shows as deny.
16
33
  * - `GET /editors/:id/:version/entry`: the bundle, with exactly the §8.2 headers. The file path comes
17
34
  * from the registry record — never from the URL — and the bytes are re-hashed on every serve: a
18
35
  * changed file answers 409 `bundle_hash_mismatch`, never the changed bundle. The pinned bytes are
@@ -27,7 +44,7 @@
27
44
  import type { FastifyInstance, FastifyReply } from 'fastify';
28
45
  import type { ConformanceRule, EditorGrantsResponse } from '../core/types.js';
29
46
  import { type ConformanceRunner, type PackCheckRunner } from './pack-install.js';
30
- import { EditorRegistry, type EditorRecord } from './registry.js';
47
+ import { EditorRegistry, type RegisteredRecord } from './registry.js';
31
48
  /** The slice of the adapter the grants route needs; every method optional so a stub never throws. */
32
49
  export interface EditorGrantsAdapter {
33
50
  editorGrantsSupported?(): boolean;
@@ -38,8 +55,13 @@ export interface EditorGrantsAdapter {
38
55
  permissions: string[];
39
56
  project?: string;
40
57
  firstParty: boolean;
58
+ /** CS7: `plugin` evaluates a run plugin's observe topics (C3); absent / `editor` the artifact-editor permissions. */
59
+ subject?: 'editor' | 'plugin';
60
+ /** CS7: a run plugin's declared topic patterns, for `subject:'plugin'`. */
61
+ observe?: string[];
41
62
  }): Promise<EditorGrantsResponse>;
42
- /** The rule store, for the install consent's `mcp.session` grant (DES-MCP-INSPECTOR-001 §6). */
63
+ /** The rule store, for the install consent's `mcp.session` grant (DES-MCP-INSPECTOR-001 §6) and the
64
+ * person's allow / revoke (`POST /editors/:id/grants`). */
43
65
  listConformanceRules?(): Promise<ConformanceRule[]>;
44
66
  upsertConformanceRule?(rule: ConformanceRule): Promise<void>;
45
67
  }
@@ -48,25 +70,56 @@ export declare const EDITOR_GRANTS_LEDGER = "EDITOR-GRANTS";
48
70
  /** The permission only an install consent grants: no posture or allow rule can (core LEDGER_ONLY_PERMISSIONS). */
49
71
  export declare const INSTALL_GRANTED = "mcp.session";
50
72
  export declare function grantToken(id: string, version: string, sha256: string, permission: string): string;
73
+ /** A run plugin's observe-topic grant token (CS7 C3): `plugin:<id>@<version>#<sha256>/observe:<topic>`. */
74
+ export declare function pluginToken(id: string, version: string, sha256: string, topic: string): string;
51
75
  /**
52
- * Rewrite the ledger's `mcp.session` tokens for `ids`: every token of those editors is dropped, and
53
- * `add` (this install's tokens, for the builds that declare it) is written. One read-modify-write;
76
+ * Rewrite the ledger's tokens for the editors `builds` just installed: EVERY token of those editors is
77
+ * dropped (F37: an install or update asks again for what the person allowed, the same build included,
78
+ * and nothing piles up), and `add` (this install's `mcp.session` consent tokens, for the builds that
79
+ * declare it) is written. One read-modify-write;
54
80
  * nothing is written when the list is unchanged. With nothing to add, an engine with no ledger has
55
81
  * no grant to withdraw, so that is no change; with something to add it is an error (it would ask).
56
82
  *
57
83
  * The edit is serialized against the other editor routes only. A governance write landing between
58
84
  * the read and the upsert is not covered, the same limit as the MCP approvals ledger (`mcp/policies.ts`).
59
85
  */
60
- export declare function editInstallGrants(adapter: EditorGrantsAdapter, ids: readonly string[], add: readonly string[]): Promise<void>;
86
+ export declare function editInstallGrants(adapter: EditorGrantsAdapter, builds: ReadonlyArray<{
87
+ id: string;
88
+ version: string;
89
+ sha256: string;
90
+ }>, add: readonly string[]): Promise<void>;
91
+ /**
92
+ * The person's allow or revoke of one permission (F37). One read-modify-write of the ledger: `add` (the
93
+ * build's token, or null to revoke) replaces every token of `id` + `permission`; or, with `permission`
94
+ * undefined and `add` null, every token of `id` goes (a removal). Throws when the ledger cannot be
95
+ * written for an allow; nothing is written when the list is unchanged. Serialized against the other
96
+ * editor routes only: a governance rule write landing between the read and the upsert is not covered,
97
+ * the same stated limit as {@link editInstallGrants} and the MCP approvals ledger.
98
+ */
99
+ export declare function editGrant(adapter: EditorGrantsAdapter, id: string, permission: string | undefined, add: string | null): Promise<void>;
100
+ /**
101
+ * A governed unit's token → true (the engine's `resolveEstateScope` names its unit), anything else → false.
102
+ * The §6.4 tripwire for the grant write: under `auth=off` every caller is the local human, so a worker
103
+ * that SENDS its token is caught here; one that omits it is the stated honest limit.
104
+ */
105
+ export type UnitTokenVerdict = 'unit' | 'not_unit' | 'unknown';
106
+ /**
107
+ * The engine's word on a bearer: `unit` (it names the unit), `not_unit` (it refused the token as
108
+ * `invalid_token:`), or `unknown` (any other failure, or an answer without a unit): the tripwire then
109
+ * fails CLOSED, so a resolver fault never waves a worker's token through (codex r1).
110
+ */
111
+ export declare function unitTokenProbe(resolve: ((requestJson: string) => Promise<string>) | null): ((token: string) => Promise<UnitTokenVerdict>) | undefined;
61
112
  export interface EditorRoutesDeps {
62
113
  registry: EditorRegistry;
63
114
  adapter: EditorGrantsAdapter;
64
115
  packCheck: PackCheckRunner;
65
116
  /** The install-time conformance run (garden's runner against this daemon's conformance host page). */
66
117
  conformance: ConformanceRunner;
118
+ /** The §6.4 tripwire: is this bearer a governed unit's token? Absent = no engine to ask (nothing refused on it). */
119
+ isUnitToken?: (token: string) => Promise<UnitTokenVerdict>;
67
120
  log?: (msg: string) => void;
68
121
  }
69
122
  export declare function registerEditorRoutes(app: FastifyInstance, deps: EditorRoutesDeps): void;
70
123
  /** Re-hash on every serve: a bundle that changed on disk is refused, never served. */
71
- export declare function serveBundle(record: EditorRecord, reply: FastifyReply, log?: (msg: string) => void): FastifyReply;
124
+ export declare function serveBundle(record: RegisteredRecord, reply: FastifyReply, log?: (msg: string) => void): FastifyReply;
72
125
  //# sourceMappingURL=routes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/editors/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAkB,MAAM,SAAS,CAAC;AAI7E,OAAO,KAAK,EAAS,eAAe,EAAE,oBAAoB,EAAuB,MAAM,kBAAkB,CAAC;AAE1G,OAAO,EAAiC,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAChH,OAAO,EAA6B,cAAc,EAAmD,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAK9I,qGAAqG;AACrG,MAAM,WAAW,mBAAmB;IAClC,qBAAqB,CAAC,IAAI,OAAO,CAAC;IAClC,oBAAoB,CAAC,CAAC,OAAO,EAAE;QAC7B,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,OAAO,CAAC;KACrB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAClC,gGAAgG;IAChG,oBAAoB,CAAC,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IACpD,qBAAqB,CAAC,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D;AAED,mFAAmF;AACnF,eAAO,MAAM,oBAAoB,kBAAkB,CAAC;AACpD,kHAAkH;AAClH,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAE7C,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAElG;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,mBAAmB,EAC5B,GAAG,EAAE,SAAS,MAAM,EAAE,EACtB,GAAG,EAAE,SAAS,MAAM,EAAE,GACrB,OAAO,CAAC,IAAI,CAAC,CAef;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,SAAS,EAAE,eAAe,CAAC;IAC3B,sGAAsG;IACtG,WAAW,EAAE,iBAAiB,CAAC;IAC/B,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAqKvF;AAeD,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,YAAY,CAmChH"}
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/editors/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAkB,MAAM,SAAS,CAAC;AAI7E,OAAO,KAAK,EAAS,eAAe,EAAE,oBAAoB,EAAmC,MAAM,kBAAkB,CAAC;AAEtH,OAAO,EAAiC,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAChH,OAAO,EAA6B,cAAc,EAAyF,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKxL,qGAAqG;AACrG,MAAM,WAAW,mBAAmB;IAClC,qBAAqB,CAAC,IAAI,OAAO,CAAC;IAClC,oBAAoB,CAAC,CAAC,OAAO,EAAE;QAC7B,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,OAAO,CAAC;QACpB,qHAAqH;QACrH,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;QAC9B,2EAA2E;QAC3E,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAClC;gEAC4D;IAC5D,oBAAoB,CAAC,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IACpD,qBAAqB,CAAC,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D;AAED,mFAAmF;AACnF,eAAO,MAAM,oBAAoB,kBAAkB,CAAC;AACpD,kHAAkH;AAClH,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAE7C,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAElG;AAED,2GAA2G;AAC3G,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9F;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,aAAa,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,EACtE,GAAG,EAAE,SAAS,MAAM,EAAE,GACrB,OAAO,CAAC,IAAI,CAAC,CAkBf;AAYD;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,mBAAmB,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB3I;AAUD;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;AAE/D;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,SAAS,CAgBrJ;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,SAAS,EAAE,eAAe,CAAC;IAC3B,sGAAsG;IACtG,WAAW,EAAE,iBAAiB,CAAC;IAC/B,oHAAoH;IACpH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC3D,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAwSvF;AAeD,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,YAAY,CAmCpH"}
@@ -1,18 +1,35 @@
1
1
  /**
2
2
  * `/api/v1/editors` (DES-artifact-editor-plugins §6, §8.2, §9.1; EP-C1).
3
3
  *
4
- * - `GET /editors` (operator+): the registry, as Settings → Editors renders it.
5
- * - `POST /editors {packRoot, enabled?}` (HUMAN-only): install or update a pack's editors — garden's
6
- * fail-closed gate, then crew's own conformance run, then the registry (`pack-install.ts`). 200 with
4
+ * - `GET /editors` (operator+): the registry, as Settings → Editors renders it. A run plugin (CS7) lists as an
5
+ * `EditorView` row too, its `granted_topics` filled from the engine's observe decisions (`[]` when it cannot
6
+ * decide them: fail closed).
7
+ * - `POST /editors {packRoot, enabled?}` (HUMAN-only): install or update a pack's editors and/or run plugins —
8
+ * garden's fail-closed gate, then crew's own conformance run, then the registry (`pack-install.ts`). 200 with
7
9
  * the installed editors; 422 with the verdict or the conformance report; 501 with the approval list
8
- * for a pack that also ships skills or blocks; 409 for an id another pack or a first-party editor holds.
9
- * - `DELETE /editors/:id` (HUMAN-only): an installed pack editor is removed from the registry (the
10
- * installer deletes its files); a first-party editor ships with studio and cannot be removed (409;
11
- * disable it instead).
10
+ * for a pack that also ships skills or blocks; 409 for an id another pack or a first-party editor holds. The
11
+ * install consent writes each installed plugin's `observe:<topic>` tokens (CS7 C3), beside the editors'
12
+ * `mcp.session` tokens, in one ledger edit.
13
+ * - `DELETE /editors/:id` (HUMAN-only): an installed pack editor or run plugin is removed from the registry (the
14
+ * installer deletes its files); every `editor:<id>@` and `plugin:<id>@` grant of it is withdrawn. A first-party
15
+ * editor ships with studio and cannot be removed (409; disable it instead).
12
16
  * - `POST /editors/:id/enabled {enabled}` (HUMAN-only): the operator's switch.
13
17
  * - `GET /editors/:id/grants?project=` (operator+): the engine's decided set
14
18
  * (`evaluate_editor_grants`: EDITOR-GRANTS ledger + EDITOR-BUILTIN posture, deny dominates), with
15
19
  * the token an "allow" would add. The host fetches it before `host.hello` and enforces it.
20
+ * - `GET /editors/:id/grants` for a run plugin answers the engine's observe decisions (CS7 C3): one grant per
21
+ * declared topic, deny dominating.
22
+ * - `POST /editors/:id/grants` for a run plugin is 409 `install_only` (CS7 C3): its topics are granted by the
23
+ * install consent alone; Remove withdraws them.
24
+ * - `POST /editors/:id/grants {permission, allow, version, sha256, project?}` (HUMAN-only, §6.4; F37):
25
+ * the person's allow or revoke of one permission the editor declares, for the build they were shown
26
+ * (`version` + `sha256` must still be the installed build, else 409 `build_changed`). Allow writes
27
+ * that build's token (built from crew's own record) into the EDITOR-GRANTS ledger, for every project;
28
+ * revoke drops every token of that editor and permission. `mcp.session` is the install consent's
29
+ * alone (409 `install_only`). Under `auth=off` a request carrying a governed unit's token is refused
30
+ * (403 `seat_token`; 503 when the engine cannot tell; under `auth=required` such a token is no identity
31
+ * at all: 401). An install, update or removal drops every grant of the editor. `project` only
32
+ * scopes the answer: the decided set after the write, so a project deny that dominates shows as deny.
16
33
  * - `GET /editors/:id/:version/entry`: the bundle, with exactly the §8.2 headers. The file path comes
17
34
  * from the registry record — never from the URL — and the bytes are re-hashed on every serve: a
18
35
  * changed file answers 409 `bundle_hash_mismatch`, never the changed bundle. The pinned bytes are
@@ -39,16 +56,22 @@ export const INSTALL_GRANTED = 'mcp.session';
39
56
  export function grantToken(id, version, sha256, permission) {
40
57
  return `editor:${id}@${version}#${sha256}/${permission}`;
41
58
  }
59
+ /** A run plugin's observe-topic grant token (CS7 C3): `plugin:<id>@<version>#<sha256>/observe:<topic>`. */
60
+ export function pluginToken(id, version, sha256, topic) {
61
+ return `plugin:${id}@${version}#${sha256}/observe:${topic}`;
62
+ }
42
63
  /**
43
- * Rewrite the ledger's `mcp.session` tokens for `ids`: every token of those editors is dropped, and
44
- * `add` (this install's tokens, for the builds that declare it) is written. One read-modify-write;
64
+ * Rewrite the ledger's tokens for the editors `builds` just installed: EVERY token of those editors is
65
+ * dropped (F37: an install or update asks again for what the person allowed, the same build included,
66
+ * and nothing piles up), and `add` (this install's `mcp.session` consent tokens, for the builds that
67
+ * declare it) is written. One read-modify-write;
45
68
  * nothing is written when the list is unchanged. With nothing to add, an engine with no ledger has
46
69
  * no grant to withdraw, so that is no change; with something to add it is an error (it would ask).
47
70
  *
48
71
  * The edit is serialized against the other editor routes only. A governance write landing between
49
72
  * the read and the upsert is not covered, the same limit as the MCP approvals ledger (`mcp/policies.ts`).
50
73
  */
51
- export async function editInstallGrants(adapter, ids, add) {
74
+ export async function editInstallGrants(adapter, builds, add) {
52
75
  const unavailable = (why) => {
53
76
  if (add.length > 0)
54
77
  throw new Error(why);
@@ -60,13 +83,87 @@ export async function editInstallGrants(adapter, ids, add) {
60
83
  const ledger = rules.find((r) => r.id === EDITOR_GRANTS_LEDGER);
61
84
  if (ledger === undefined)
62
85
  return unavailable(`the ${EDITOR_GRANTS_LEDGER} ledger is not in the policy store; restart the daemon to seed it`);
63
- const owned = (t) => ids.some((id) => t.startsWith(`editor:${id}@`) && t.endsWith(`/${INSTALL_GRANTED}`));
86
+ // Every earlier grant of an installed editor OR run plugin goes (codex r2: a same-build "keep" let a failed
87
+ // cleanup resurrect an old build's allow on its reinstall); only this install's consent tokens (the editors'
88
+ // mcp.session and the plugins' observe topics, CS7 C3) are written back.
89
+ const owned = (t) => builds.some((b) => t.startsWith(`editor:${b.id}@`) || t.startsWith(`plugin:${b.id}@`));
64
90
  const before = ledger.excludes ?? [];
65
91
  const dedup = [...new Set([...before.filter((t) => !owned(t)), ...add])];
66
92
  if (dedup.length === before.length && dedup.every((t, i) => t === before[i]))
67
93
  return;
68
94
  await adapter.upsertConformanceRule({ ...ledger, excludes: dedup });
69
95
  }
96
+ /**
97
+ * Every ledger token of `id` (any build). With a `permission`, only that editor permission's tokens. Without one
98
+ * (a removal), both the editor family AND the run-plugin family `plugin:<id>@` (CS7 C3: `DELETE` withdraws a
99
+ * plugin's topic grants too).
100
+ */
101
+ function tokenOf(id, permission) {
102
+ if (permission === undefined)
103
+ return (t) => t.startsWith(`editor:${id}@`) || t.startsWith(`plugin:${id}@`);
104
+ return (t) => t.startsWith(`editor:${id}@`) && t.endsWith(`/${permission}`);
105
+ }
106
+ /**
107
+ * The person's allow or revoke of one permission (F37). One read-modify-write of the ledger: `add` (the
108
+ * build's token, or null to revoke) replaces every token of `id` + `permission`; or, with `permission`
109
+ * undefined and `add` null, every token of `id` goes (a removal). Throws when the ledger cannot be
110
+ * written for an allow; nothing is written when the list is unchanged. Serialized against the other
111
+ * editor routes only: a governance rule write landing between the read and the upsert is not covered,
112
+ * the same stated limit as {@link editInstallGrants} and the MCP approvals ledger.
113
+ */
114
+ export async function editGrant(adapter, id, permission, add) {
115
+ // With nothing to add, an engine with no ledger has no grant to withdraw: that is no change.
116
+ const unavailable = (why) => {
117
+ if (add !== null)
118
+ throw new Error(why);
119
+ };
120
+ if (typeof adapter.listConformanceRules !== 'function' || typeof adapter.upsertConformanceRule !== 'function') {
121
+ return unavailable('this engine cannot write editor grants');
122
+ }
123
+ const rules = await adapter.listConformanceRules();
124
+ const ledger = rules.find((r) => r.id === EDITOR_GRANTS_LEDGER);
125
+ if (ledger === undefined)
126
+ return unavailable(`the ${EDITOR_GRANTS_LEDGER} ledger is not in the policy store; restart the daemon to seed it`);
127
+ const before = ledger.excludes ?? [];
128
+ const owned = tokenOf(id, permission);
129
+ const next = [...new Set([...before.filter((t) => !owned(t)), ...(add !== null ? [add] : [])])];
130
+ if (next.length === before.length && next.every((t, i) => t === before[i]))
131
+ return;
132
+ await adapter.upsertConformanceRule({ ...ledger, excludes: next });
133
+ }
134
+ /** The bearer a request carries, if any (`Authorization: Bearer <token>`). */
135
+ function bearerOf(req) {
136
+ const h = req.headers.authorization;
137
+ if (typeof h !== 'string')
138
+ return null;
139
+ const m = /^Bearer\s+(\S+)\s*$/iu.exec(h);
140
+ return m === null ? null : m[1];
141
+ }
142
+ /**
143
+ * The engine's word on a bearer: `unit` (it names the unit), `not_unit` (it refused the token as
144
+ * `invalid_token:`), or `unknown` (any other failure, or an answer without a unit): the tripwire then
145
+ * fails CLOSED, so a resolver fault never waves a worker's token through (codex r1).
146
+ */
147
+ export function unitTokenProbe(resolve) {
148
+ if (resolve === null)
149
+ return undefined;
150
+ return async (token) => {
151
+ let raw;
152
+ try {
153
+ raw = await resolve(JSON.stringify({ token }));
154
+ }
155
+ catch (err) {
156
+ return /^invalid_token\b/u.test(err instanceof Error ? err.message : String(err)) ? 'not_unit' : 'unknown';
157
+ }
158
+ try {
159
+ const unit = JSON.parse(raw).unit;
160
+ return typeof unit?.runId === 'string' ? 'unit' : 'unknown';
161
+ }
162
+ catch {
163
+ return 'unknown';
164
+ }
165
+ };
166
+ }
70
167
  export function registerEditorRoutes(app, deps) {
71
168
  const { registry } = deps;
72
169
  // An install or a removal is ONE serialized step with its ledger edit (codex r2): the ledger edit is
@@ -92,14 +189,46 @@ export function registerEditorRoutes(app, deps) {
92
189
  return true;
93
190
  void reply
94
191
  .code(403)
95
- .send({ error: `only a human operator can install, remove, enable or disable an editor (you are ${actor.kind}/${actor.trust})` });
192
+ .send({ error: `only a human operator can install, remove, enable or disable an editor, or allow what it asks for (you are ${actor.kind}/${actor.trust})` });
96
193
  return false;
97
194
  };
98
195
  const idOf = (req) => req.params.id;
196
+ // CS7 C3/C4: a run plugin's granted topics are the ones the engine decides `allow` (deny dominates). The
197
+ // registry does not know them — the route asks the engine with `subject:'plugin'` and the plugin's declared
198
+ // topics. Any failure, or an engine with no plugin-grants support, means it hears nothing: `[]`, with a log line.
199
+ const grantedTopicsFor = async (view) => {
200
+ const { adapter } = deps;
201
+ if (typeof adapter.editorGrantsSupported !== 'function' || !adapter.editorGrantsSupported() || typeof adapter.evaluateEditorGrants !== 'function') {
202
+ deps.log?.(`[editors] ${view.id}: this engine cannot decide a run plugin's topics; it hears nothing`);
203
+ return [];
204
+ }
205
+ try {
206
+ const res = await adapter.evaluateEditorGrants({
207
+ subject: 'plugin',
208
+ editorId: view.id,
209
+ version: view.version,
210
+ sha256: view.sha256,
211
+ permissions: [],
212
+ observe: (view.observe ?? []).map((o) => o.topic),
213
+ firstParty: false,
214
+ });
215
+ return res.grants.filter((g) => g.decision === 'allow' && g.permission.startsWith('observe:')).map((g) => g.permission.slice('observe:'.length));
216
+ }
217
+ catch (err) {
218
+ deps.log?.(`[editors] ${view.id}: a run plugin's topics could not be decided (${err instanceof Error ? err.message : String(err)}); it hears nothing`);
219
+ return [];
220
+ }
221
+ };
99
222
  app.get(`${V}/editors`, { config: { manifest: { responseType: 'ListEditorsResponse', statusCodes: [200, 403] } } }, async (req, reply) => {
100
223
  if (!operatorOnly(req, reply))
101
224
  return reply;
102
- const body = { editors: registry.list().map((r) => EditorRegistry.view(r)), installs: 'conformance_required' };
225
+ const editors = registry.list().map((r) => EditorRegistry.view(r));
226
+ // Only run plugins carry `granted_topics`; editor rows are left unchanged (CS7 C4).
227
+ for (const view of editors) {
228
+ if (view.inline === 'run-thread')
229
+ view.granted_topics = await grantedTopicsFor(view);
230
+ }
231
+ const body = { editors, installs: 'conformance_required' };
103
232
  return body;
104
233
  });
105
234
  const InstallSchema = z.strictObject({ packRoot: z.string().min(1), enabled: z.boolean().optional() });
@@ -113,24 +242,33 @@ export function registerEditorRoutes(app, deps) {
113
242
  return await serial(async () => {
114
243
  const installed = await installPack(parsed.data.packRoot, parsed.data.enabled, { check: deps.packCheck, conformance: deps.conformance, registry });
115
244
  deps.log?.(`[editors] installed ${installed.editors.map((e) => `${e.id}@${e.version}`).join(', ')}${installed.updated ? ' (update)' : ''}`);
116
- // The install consent IS the mcp.session grant (DES-MCP-INSPECTOR-001 §6): this human-only
117
- // call, after the operator approved the install, writes each declaring editor's per-build
118
- // token. Every installed editor's earlier tokens are dropped first (codex r1: an update that
119
- // no longer declares it keeps none), and an editor that does not declare it gets none.
120
- const declaring = installed.editors.filter((e) => e.permissions.some((p) => p.id === INSTALL_GRANTED));
121
- const tokens = declaring.map((e) => grantToken(e.id, e.version, e.sha256, INSTALL_GRANTED));
245
+ // The install consent IS the grant (DES-MCP-INSPECTOR-001 §6; CS7 C3): this human-only call, after
246
+ // the operator approved the install, writes each declaring editor's per-build `mcp.session` token AND
247
+ // one `observe:<topic>` token per declared topic of each installed run plugin. Every installed
248
+ // editor's / plugin's earlier tokens are dropped first (codex r1: an update that no longer declares it
249
+ // keeps none), in the same read-modify-write as today's mcp.session edit.
250
+ const declaring = installed.editors.filter((e) => e.inline !== 'run-thread' && e.permissions.some((p) => p.id === INSTALL_GRANTED));
251
+ const editorTokens = declaring.map((e) => grantToken(e.id, e.version, e.sha256, INSTALL_GRANTED));
252
+ const plugins = installed.editors.filter((e) => e.inline === 'run-thread');
253
+ const pluginTokens = plugins.flatMap((p) => (p.observe ?? []).map((o) => pluginToken(p.id, p.version, p.sha256, o.topic)));
254
+ const tokens = [...editorTokens, ...pluginTokens];
122
255
  try {
123
- await editInstallGrants(deps.adapter, installed.editors.map((e) => e.id), tokens);
124
- if (declaring.length === 0)
256
+ await editInstallGrants(deps.adapter, installed.editors, tokens);
257
+ if (tokens.length === 0)
125
258
  return installed;
126
- deps.log?.(`[editors] install consent granted ${INSTALL_GRANTED} to ${declaring.map((e) => `${e.id}@${e.version}`).join(', ')}`);
259
+ if (declaring.length > 0)
260
+ deps.log?.(`[editors] install consent granted ${INSTALL_GRANTED} to ${declaring.map((e) => `${e.id}@${e.version}`).join(', ')}`);
261
+ if (plugins.length > 0)
262
+ deps.log?.(`[editors] install consent granted ${pluginTokens.length} observe topic(s) to ${plugins.map((e) => `${e.id}@${e.version}`).join(', ')}`);
127
263
  return { ...installed, granted: tokens };
128
264
  }
129
265
  catch (err) {
130
266
  const msg = err instanceof Error ? err.message : String(err);
131
- deps.log?.(`[editors] installed, but the ${INSTALL_GRANTED} grants were not written: ${msg}`);
267
+ deps.log?.(`[editors] installed, but the grants were not written: ${msg}`);
132
268
  // Said either way (codex r2): with nothing to grant, an earlier build's token was not withdrawn.
133
- const what = declaring.length > 0 ? `${INSTALL_GRANTED} was not granted (it asks)` : `an earlier build's ${INSTALL_GRANTED} grant was not withdrawn`;
269
+ const what = tokens.length > 0
270
+ ? `the install consent's grants were not written (it asks), and its earlier grants were not withdrawn`
271
+ : `its earlier grants (any permission you allowed) were not withdrawn`;
134
272
  return { ...installed, grantError: `installed, but ${what}: ${msg}` };
135
273
  }
136
274
  });
@@ -155,13 +293,14 @@ export function registerEditorRoutes(app, deps) {
155
293
  // Installed = served or skipped at boot (codex r2: a skipped one has no live record but is removable).
156
294
  if (!registry.isInstalled(id))
157
295
  return reply.code(404).send({ error: `no editor '${id}' is installed` });
158
- // Its install grant goes first (codex r1): a failed withdrawal keeps the editor installed, so a
159
- // retry of this DELETE can still reach it, and never leaves a grant behind a removed editor.
296
+ // Its grants go first (codex r1): a failed withdrawal keeps the editor installed, so a retry of
297
+ // this DELETE can still reach it, and never leaves a grant behind a removed editor. Every grant,
298
+ // not only the install's (F37): a reinstall of the same build asks again for what the person allowed.
160
299
  try {
161
- await editInstallGrants(deps.adapter, [id], []);
300
+ await editGrant(deps.adapter, id, undefined, null);
162
301
  }
163
302
  catch (err) {
164
- return reply.code(503).send({ error: `${id} was not removed: its ${INSTALL_GRANTED} grant could not be withdrawn (${err instanceof Error ? err.message : String(err)}); try again` });
303
+ return reply.code(503).send({ error: `${id} was not removed: its grants could not be withdrawn (${err instanceof Error ? err.message : String(err)}); try again` });
165
304
  }
166
305
  if (!registry.removeInstalled(id))
167
306
  return reply.code(404).send({ error: `no editor '${id}' is installed` });
@@ -181,24 +320,15 @@ export function registerEditorRoutes(app, deps) {
181
320
  return reply.code(404).send({ error: `no editor '${id}' is installed` });
182
321
  return EditorRegistry.view(next);
183
322
  });
184
- app.get(`${V}/editors/:id/grants`, { config: { manifest: { responseType: 'EditorGrantsResponse', statusCodes: [200, 400, 403, 404, 501, 502] } } }, async (req, reply) => {
185
- if (!operatorOnly(req, reply))
186
- return reply;
187
- const id = idOf(req);
188
- const record = EDITOR_ID.test(id) ? registry.get(id) : null;
189
- if (record === null)
190
- return reply.code(404).send({ error: `no editor '${id}' is installed` });
191
- const q = req.query;
192
- const projectRaw = Array.isArray(q.project) ? q.project[0] : q.project;
193
- const project = typeof projectRaw === 'string' && projectRaw.trim() !== '' ? projectRaw.trim() : undefined;
323
+ const grantsSupported = () => {
194
324
  const { adapter } = deps;
195
- if (typeof adapter.editorGrantsSupported !== 'function' || !adapter.editorGrantsSupported() || typeof adapter.evaluateEditorGrants !== 'function') {
196
- return reply.code(501).send({
197
- error: 'the installed wicked-core-ts has no editor grants (needs wicked-core-ts >= 0.7.35 with the editor-defaults pack)',
198
- });
199
- }
325
+ return typeof adapter.editorGrantsSupported === 'function' && adapter.editorGrantsSupported() && typeof adapter.evaluateEditorGrants === 'function';
326
+ };
327
+ const NO_GRANTS = 'the installed wicked-core-ts has no editor grants (needs wicked-core-ts >= 0.7.35 with the editor-defaults pack)';
328
+ /** The engine's decided set for this record (its pinned version + hash), or the reply that says why not. */
329
+ const decide = async (record, project, reply) => {
200
330
  try {
201
- return await adapter.evaluateEditorGrants({
331
+ return await deps.adapter.evaluateEditorGrants({
202
332
  editorId: record.manifest.id,
203
333
  version: record.manifest.version,
204
334
  sha256: record.sha256,
@@ -211,6 +341,109 @@ export function registerEditorRoutes(app, deps) {
211
341
  const msg = err instanceof Error ? err.message : String(err);
212
342
  return reply.code(/bad_request/u.test(msg) ? 400 : 502).send({ error: msg });
213
343
  }
344
+ };
345
+ /** A run plugin's decided observe set (CS7 C3): one grant per declared topic, deny dominating. */
346
+ const decidePlugin = async (record, project, reply) => {
347
+ try {
348
+ return await deps.adapter.evaluateEditorGrants({
349
+ subject: 'plugin',
350
+ editorId: record.manifest.id,
351
+ version: record.manifest.version,
352
+ sha256: record.sha256,
353
+ permissions: [],
354
+ observe: record.manifest.observe.map((o) => o.topic),
355
+ ...(project !== undefined ? { project } : {}),
356
+ firstParty: false,
357
+ });
358
+ }
359
+ catch (err) {
360
+ const msg = err instanceof Error ? err.message : String(err);
361
+ return reply.code(/bad_request/u.test(msg) ? 400 : 502).send({ error: msg });
362
+ }
363
+ };
364
+ const projectOf = (raw) => {
365
+ const v = Array.isArray(raw) ? raw[0] : raw;
366
+ return typeof v === 'string' && v.trim() !== '' ? v.trim() : undefined;
367
+ };
368
+ app.get(`${V}/editors/:id/grants`, { config: { manifest: { responseType: 'EditorGrantsResponse', statusCodes: [200, 400, 403, 404, 501, 502] } } }, async (req, reply) => {
369
+ if (!operatorOnly(req, reply))
370
+ return reply;
371
+ const id = idOf(req);
372
+ const record = EDITOR_ID.test(id) ? registry.get(id) : null;
373
+ if (record === null)
374
+ return reply.code(404).send({ error: `no editor '${id}' is installed` });
375
+ if (!grantsSupported())
376
+ return reply.code(501).send({ error: NO_GRANTS });
377
+ const project = projectOf(req.query.project);
378
+ // CS7 C3/C4: a run plugin answers its observe decisions; an editor its permission decisions.
379
+ return record.kind === 'plugin' ? decidePlugin(record, project, reply) : decide(record, project, reply);
380
+ });
381
+ // F37: the person's allow / revoke of one permission (§6.2 ledger, §6.4 human-only).
382
+ const GrantSchema = z.strictObject({
383
+ permission: z.string().min(1),
384
+ allow: z.boolean(),
385
+ version: z.string().min(1),
386
+ sha256: z.string().regex(/^[0-9a-f]{64}$/u),
387
+ project: z.string().optional(),
388
+ });
389
+ app.post(`${V}/editors/:id/grants`, { config: { manifest: { requestType: 'SetEditorGrantBody', responseType: 'EditorGrantsResponse', statusCodes: [200, 400, 403, 404, 409, 501, 502, 503] } } }, async (req, reply) => {
390
+ if (!humanOnly(req, reply))
391
+ return reply;
392
+ // The tripwire (§6.4): a request that carries a governed unit's token is a worker's, whatever the auth mode says.
393
+ // Under auth=required the bearer already proved a human operator (a unit token is no identity there: 401), so
394
+ // only the local actor of auth=off is checked; with no engine to ask, a bearer cannot be cleared (codex r2).
395
+ const bearer = actorOf(req) === LOCAL_ACTOR ? bearerOf(req) : null;
396
+ const verdict = bearer === null ? 'not_unit' : deps.isUnitToken !== undefined ? await deps.isUnitToken(bearer) : 'unknown';
397
+ if (verdict === 'unit') {
398
+ deps.log?.(`[editors] refused a grant write carrying a governed unit's token (${idOf(req)})`);
399
+ return reply.code(403).send({ code: 'seat_token', error: 'a governed worker cannot allow or revoke an editor permission; only the person can, in studio' });
400
+ }
401
+ if (verdict === 'unknown') {
402
+ return reply.code(503).send({ error: 'could not tell whether this request carries a governed worker\'s token, so nothing was changed; try again' });
403
+ }
404
+ const parsed = GrantSchema.safeParse(req.body);
405
+ if (!parsed.success)
406
+ return reply.code(400).send({ error: 'body must be { permission: <permission id>, allow: boolean, version: <the version shown>, sha256: <the hash shown>, project?: <project id> }' });
407
+ const { permission, allow } = parsed.data;
408
+ const id = idOf(req);
409
+ if (!EDITOR_ID.test(id) || registry.get(id) === null)
410
+ return reply.code(404).send({ error: `no editor '${id}' is installed` });
411
+ // CS7 C3: a run plugin's topics are the install consent's alone, whatever the engine supports (codex r1).
412
+ if (registry.get(id)?.kind === 'plugin') {
413
+ return reply.code(409).send({ code: 'install_only', error: `${id} is a run plugin; its topics are granted by its install consent, not here — reinstall it to grant them, remove it to withdraw them` });
414
+ }
415
+ if (!grantsSupported())
416
+ return reply.code(501).send({ error: NO_GRANTS });
417
+ return serial(async () => {
418
+ // Read the record INSIDE the chain: a removal or an update queued before this press has landed.
419
+ const record = registry.get(id);
420
+ if (record === null)
421
+ return reply.code(404).send({ error: `no editor '${id}' is installed` });
422
+ // The press is for the build the person was shown (codex r1): an update in between asks again.
423
+ if (record.manifest.version !== parsed.data.version || record.sha256 !== parsed.data.sha256) {
424
+ return reply.code(409).send({ code: 'build_changed', error: `${id} changed to version ${record.manifest.version} since this was shown; nothing was changed: look again and decide for the new version` });
425
+ }
426
+ // CS7 C3: a run plugin's topics are granted by the install consent only; Remove withdraws them.
427
+ if (record.kind === 'plugin') {
428
+ return reply.code(409).send({ code: 'install_only', error: `${id} is a run plugin; its topics are granted by its install consent, not here — reinstall it to grant them, remove it to withdraw them` });
429
+ }
430
+ if (!record.manifest.permissions.some((p) => p.id === permission)) {
431
+ return reply.code(400).send({ error: `${id} does not ask for '${permission}'` });
432
+ }
433
+ if (permission === INSTALL_GRANTED) {
434
+ return reply.code(409).send({ code: 'install_only', error: `${INSTALL_GRANTED} is granted only by the editor's install consent; reinstall it to grant it, remove it to withdraw it` });
435
+ }
436
+ // The token is crew's own measurement of this build, never the caller's.
437
+ const token = grantToken(record.manifest.id, record.manifest.version, record.sha256, permission);
438
+ try {
439
+ await editGrant(deps.adapter, id, permission, allow ? token : null);
440
+ }
441
+ catch (err) {
442
+ return reply.code(503).send({ error: `not ${allow ? 'allowed' : 'revoked'}: ${err instanceof Error ? err.message : String(err)}` });
443
+ }
444
+ deps.log?.(`[editors] ${allow ? 'allowed' : 'revoked'} ${permission} for ${id}@${record.manifest.version}`);
445
+ return decide(record, projectOf(parsed.data.project), reply);
446
+ });
214
447
  });
215
448
  app.get(`${V}/editors/:id/:version/entry`, { config: { manifest: { statusCodes: [200, 404, 409] } } }, async (req, reply) => {
216
449
  const { id, version } = req.params;