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
package/dist/api/mcp.js CHANGED
@@ -11,11 +11,18 @@
11
11
  * is registered DISABLED; `enabledWrites` names the ones the operator
12
12
  * grants (human operator only → else 403), each audited
13
13
  * `mcp.tool.write_granted`.
14
- * (G2) a `rest` base URL that matches none of the spec's `servers`, or a
15
- * loopback/private host, needs `allowOrigin` = exactly that origin (409
16
- * `egress_unconfirmed`; human operator only → else 403), audited
17
- * `mcp.server.egress_confirmed`. A REST tool's hash covers the target, so
18
- * a changed target re-registers its tools and withdraws their approvals
14
+ * (G2) a `rest` base URL that matches none of the spec's `servers` needs
15
+ * `allowOrigin` = exactly that origin (409 `egress_unconfirmed`; human
16
+ * operator only → else 403), audited `mcp.server.egress_confirmed`. A REST
17
+ * tool's hash covers the target, so a changed target re-registers its tools
18
+ * and withdraws their approvals.
19
+ * (DES-APPS-001 §5.2) every connection to an `mcp-http`/`rest` server goes
20
+ * through the one dialer: a loopback/private host needs `address.allow` on
21
+ * the PREVIEW (which dials) and the save, human operator only (403
22
+ * `address_confirm_human_only`), audited `mcp.server.address_confirmed`
23
+ * (crew#1316) a preview whose `auth.ref` names a secret it does not stage (an
24
+ * `env:` reference, a keychain entry crew already holds) probes with that
25
+ * secret: human operator only (403 `stored_secret_human_only`)
19
26
  * PATCH /mcp/servers/:name `{enabled}`
20
27
  * DELETE /mcp/servers/:name remove the server and the keychain secret it owns
21
28
  * POST /mcp/servers/:name/test probe again: health plus the tool diff
@@ -50,52 +57,107 @@
50
57
  * `POST /mcp/servers/preview` also answers the matrix (`policies`); a save that changes a saved
51
58
  * tool's schema, and a removal, withdraw the approvals that named it, BEFORE the registry changes.
52
59
  *
60
+ * DES-KNOWLEDGE-DATA-001 §5 (the one registry, B1):
61
+ *
62
+ * GET /mcp/servers?view=agent the agent-safe projection (crew#1310): every NON-HUMAN actor gets it
63
+ * whatever it asks; a human gets it on request. The answers of a save,
64
+ * `PATCH /mcp/servers/:name` and a test are projected the same way
65
+ * POST /mcp/servers/preview also `kind: "toolbox-source"` (Toolbox's own source document, checked
66
+ * against the deployment policy: 400 with the policy's code); a `sql`
67
+ * Postgres body is saved as the same document (descriptor version 2)
68
+ * POST /mcp/servers also `disclosures` (each tool's disclosure class): human operator only
69
+ * PATCH /mcp/tools/:subject also `disclosure`: setting one is human operator only
70
+ * GET /mcp/registry/generations the kept generations (human operator only)
71
+ * POST /mcp/registry/restore `{generation}`: restore one, failing closed (human operator only)
72
+ *
53
73
  * The secret value is in no response, log, audit entry or file (D-2); tests/mcp-registry.test.ts
54
74
  * scans all of them, a malformed secret body included.
55
75
  */
56
- import { z } from 'zod';
57
- import { MCP_SERVER_NAME_RE } from '../mcp/classify.js';
76
+ import { record, z } from '../zod.js';
77
+ import { canonicalJson, MCP_SERVER_NAME_RE } from '../mcp/classify.js';
58
78
  import { MCP_PREVIEW_ROLES, MCP_RUN_MODES, McpLedgerEditError } from '../mcp/policies.js';
59
- import { isWriteGrant, McpRegistryError } from '../mcp/registry.js';
79
+ import { agentServerView, configOf, isWriteGrant, McpRegistryError } from '../mcp/registry.js';
80
+ import { restTarget } from '../mcp/rest.js';
60
81
  import { listUnitTools } from '../mcp/tool-list.js';
61
82
  import { McpRegistryCorruptError } from '../mcp/registry-store.js';
62
83
  import { parseSecretRef, SecretStoreError } from '../mcp/secrets.js';
63
84
  import { foldMcpUsage, MCP_USAGE_DECISIONS, MCP_USAGE_DEFAULT_DAYS, MCP_USAGE_MAX_DAYS } from '../mcp/usage.js';
64
85
  import { parseBaseUrl, REST_SPEC_MAX_BYTES } from '../mcp/rest.js';
86
+ import { NO_CONFIRMATION, validateAllowRanges } from '../sources/dialer.js';
65
87
  import { API_PREFIX } from './api-prefix.js';
66
- import { trustAtLeast } from './auth.js';
88
+ import { trustAtLeast, viewOf } from './auth.js';
67
89
  const V = API_PREFIX;
68
90
  const serverName = z.string().regex(MCP_SERVER_NAME_RE, 'a server name is 1-63 of a-z 0-9 _ -, starting with a letter or digit');
69
91
  const toolClass = z.enum(['read', 'write', 'destructive']);
92
+ /** (DES-KNOWLEDGE-DATA-001 §7.1) What a tool's answer discloses. */
93
+ const disclosureClass = z.enum(['none', 'structure', 'rows']);
70
94
  /** A pasted secret VALUE. Shared by the staged-secret preview field and `PUT …/secret` (crew#719). */
71
95
  const secretValue = z
72
96
  .string()
73
97
  .min(8, 'a secret is at least 8 characters')
74
98
  .max(8192)
75
- .refine((v) => !/[\r\n\0]/.test(v), { message: 'a secret is one line' });
76
- const AuthSchema = z
77
- .object({
78
- ref: z.string().refine((r) => parseSecretRef(r) !== null, { message: 'ref must be keychain:wicked-mcp/<name> or env:<NAME>' }),
99
+ .refine((v) => !/[\r\n\0]/.test(v), { error: 'a secret is one line' });
100
+ const AuthSchema = z.strictObject({
101
+ ref: z.string().refine((r) => parseSecretRef(r) !== null, { error: 'ref must be keychain:wicked-mcp/<name> or env:<NAME>' }),
79
102
  env: z.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/).optional(),
80
103
  header: z.string().regex(/^[A-Za-z0-9-]{1,64}$/).optional(),
81
104
  prefix: z.string().max(32).optional(),
105
+ });
106
+ /** (DES-APPS-001 §5.2) A source's address confirmation: CIDRs inside loopback/private ranges only. */
107
+ export const AddressSchema = z.strictObject({
108
+ allow: z.array(z.string().min(1).max(64)).max(16),
109
+ plaintext: z.boolean().optional(),
82
110
  })
83
- .strict();
111
+ .superRefine((a, ctx) => {
112
+ const problem = validateAllowRanges(a.allow);
113
+ if (problem !== null)
114
+ ctx.addIssue({ code: 'custom', path: ['allow'], message: problem });
115
+ });
116
+ /** (DES-APPS-001 §5.1) A network SQL source's settings; the password is `auth.ref`'s secret. */
117
+ export const SqlSourceSchema = z.strictObject({
118
+ driver: z.enum(['postgres', 'mysql']),
119
+ host: z.string().min(1).max(253).regex(/^[^\s/@?#]+$/, 'a host name or IP address'),
120
+ port: z.int().min(1).max(65_535).optional(),
121
+ database: z.string().min(1).max(128),
122
+ user: z.string().min(1).max(128),
123
+ tls: z.enum(['verify-full', 'disable']).optional(),
124
+ ca: z.string().min(1).max(65_536).optional(),
125
+ });
126
+ /**
127
+ * (DES-KNOWLEDGE-DATA-001 §5.1) Toolbox's source document, as sent: an object of at most 32 fields, each judged
128
+ * by the deployment policy (`knowledge/registry/policy.ts`) at the preview, not here.
129
+ */
130
+ const ToolboxDocumentSchema = record(z.string().max(64), z.union([z.string().max(4096), z.number(), z.boolean(), z.null(), record(z.string(), z.unknown()), z.array(z.unknown())]))
131
+ .refine((d) => Object.keys(d).length <= 32, { error: 'a Toolbox source document has at most 32 fields' });
84
132
  // Exported so tests/wire-contract.test.ts can pin the published bodies against them.
85
- export const McpServerConfigSchema = z
86
- .object({
133
+ export const McpServerConfigSchema = z.strictObject({
87
134
  name: serverName,
88
- kind: z.enum(['mcp-stdio', 'mcp-http', 'rest']),
135
+ kind: z.enum(['mcp-stdio', 'mcp-http', 'rest', 'sql', 'graphql', 'toolbox-source']),
89
136
  command: z.string().min(1).max(4096).optional(),
90
137
  args: z.array(z.string().max(4096)).max(64).optional(),
91
138
  url: z.string().max(4096).optional(),
92
139
  auth: AuthSchema.nullable().optional(),
93
140
  openapiUrl: z.string().max(4096).optional(),
94
- openapi: z
95
- .record(z.string(), z.unknown())
96
- .refine((d) => Buffer.byteLength(JSON.stringify(d), 'utf8') <= REST_SPEC_MAX_BYTES, { message: `the OpenAPI document is at most ${REST_SPEC_MAX_BYTES} bytes` })
141
+ openapi: record(z.string(), z.unknown())
142
+ .refine((d) => Buffer.byteLength(JSON.stringify(d), 'utf8') <= REST_SPEC_MAX_BYTES, { error: `the OpenAPI document is at most ${REST_SPEC_MAX_BYTES} bytes` })
97
143
  .optional(),
98
144
  operations: z.array(z.string().min(1).max(256)).min(1).max(512).optional(),
145
+ /**
146
+ * (DES-APPS-001 §5.2) The loopback/private ranges the person confirms for this server's
147
+ * connections, and whether plaintext is accepted on a confirmed private range. Human operator
148
+ * only (403 `address_confirm_human_only`), on the preview (which dials) and the save; audited
149
+ * `mcp.server.address_confirmed`. `mcp-http` and `rest` only: an `mcp-stdio` server is a local
150
+ * program, outside the dialer.
151
+ */
152
+ address: AddressSchema.optional(),
153
+ /** (DES-APPS-001 §5.1) `sql` only: a network SQL source's settings (sqlite sources come from uploads). */
154
+ sql: SqlSourceSchema.optional(),
155
+ /** `sql` only: the views a read may name (`schema.view`). */
156
+ viewsAllowed: z.array(z.string().min(3).max(256).regex(/^[^.\s]+\.[^.\s]+$/, 'a view is named schema.view')).max(256).optional(),
157
+ /** (DES-KNOWLEDGE-DATA-001 §5.1) `toolbox-source` only: Toolbox's own source document, its runtime and TLS choice. */
158
+ toolbox: ToolboxDocumentSchema.optional(),
159
+ runtime: z.enum(['native', 'toolbox']).optional(),
160
+ tls: z.strictObject({ mode: z.enum(['verify-full', 'disable']), ca: z.string().min(1).max(65_536).optional() }).optional(),
99
161
  /**
100
162
  * (crew#719) The secret VALUE this server's keychain entry will hold. The preview is probed
101
163
  * with it and it is held with the preview; `POST /mcp/servers` writes it to the OS store as
@@ -103,10 +165,14 @@ export const McpServerConfigSchema = z
103
165
  * `auth.ref` = `keychain:wicked-mcp/<name>`. It is in no response, log, audit entry or file.
104
166
  */
105
167
  secret: secretValue.optional(),
168
+ /**
169
+ * (DES-PM-001 §3) `mcp-http` / `mcp-stdio` only: this server is a project-management system's own MCP server. A
170
+ * human operator's only (403 `pm_source_human_only`). `gitlab` and `ado` are wave PM-2.
171
+ */
172
+ pm: z.strictObject({ system: z.enum(['github', 'jira']) }).optional(),
106
173
  })
107
- .strict()
108
174
  .superRefine((c, ctx) => {
109
- const issue = (path, message) => ctx.addIssue({ code: z.ZodIssueCode.custom, path: [path], message });
175
+ const issue = (path, message) => ctx.addIssue({ code: 'custom', path: [path], message });
110
176
  const httpUrl = (raw) => {
111
177
  try {
112
178
  const u = new URL(raw ?? '');
@@ -119,6 +185,43 @@ export const McpServerConfigSchema = z
119
185
  if (c.kind !== 'rest' && (c.openapiUrl !== undefined || c.openapi !== undefined || c.operations !== undefined)) {
120
186
  issue('openapi', 'openapiUrl, openapi and operations are for a rest server');
121
187
  }
188
+ if (c.kind !== 'sql' && c.sql !== undefined)
189
+ issue('sql', 'sql is for a sql source');
190
+ if (c.pm !== undefined && c.kind !== 'mcp-http' && c.kind !== 'mcp-stdio')
191
+ issue('pm', 'pm marks a project-management system\'s own MCP server: kind mcp-http or mcp-stdio');
192
+ if (c.kind !== 'sql' && c.kind !== 'toolbox-source' && c.viewsAllowed !== undefined)
193
+ issue('viewsAllowed', 'viewsAllowed is for a sql or toolbox-source source');
194
+ if (c.kind !== 'toolbox-source' && (c.toolbox !== undefined || c.runtime !== undefined || c.tls !== undefined))
195
+ issue('toolbox', 'toolbox, runtime and tls are for a toolbox-source');
196
+ if (c.kind === 'toolbox-source') {
197
+ if (c.toolbox === undefined)
198
+ issue('toolbox', "a toolbox-source needs toolbox: Toolbox's own source document ({kind: 'source', type: 'postgres', host, port, database, user, password: '${WICKED_SRC_1}'})");
199
+ if (c.command !== undefined || c.args !== undefined || c.url !== undefined)
200
+ issue('url', 'a toolbox-source takes its Toolbox document, not a command or url');
201
+ if (c.auth != null && (c.auth.env !== undefined || c.auth.header !== undefined || c.auth.prefix !== undefined))
202
+ issue('auth', 'a toolbox-source takes its secret as auth.ref only');
203
+ return;
204
+ }
205
+ if (c.kind === 'sql') {
206
+ if (c.sql === undefined)
207
+ issue('sql', 'a sql source needs sql: {driver, host, database, user} (a sqlite source comes from POST /apps/uploads)');
208
+ if (c.command !== undefined || c.args !== undefined || c.url !== undefined)
209
+ issue('url', 'a sql source takes sql settings, not a command or url');
210
+ if (c.auth != null && (c.auth.env !== undefined || c.auth.header !== undefined || c.auth.prefix !== undefined))
211
+ issue('auth', 'a sql source takes its password as auth.ref only');
212
+ return;
213
+ }
214
+ if (c.kind === 'graphql') {
215
+ if (c.command !== undefined || c.args !== undefined)
216
+ issue('command', 'a graphql source takes a url, not a command');
217
+ if (!httpUrl(c.url))
218
+ issue('url', 'a graphql source needs an http(s) endpoint url');
219
+ else if (new URL(c.url ?? '').username + new URL(c.url ?? '').password !== '')
220
+ issue('url', 'the url must not carry credentials; reference the secret with auth.ref');
221
+ if (c.auth != null && (c.auth.header === undefined || c.auth.env !== undefined))
222
+ issue('auth', 'a graphql source injects its secret into one header: auth.header, no auth.env');
223
+ return;
224
+ }
122
225
  if (c.kind === 'rest') {
123
226
  if (c.command !== undefined || c.args !== undefined)
124
227
  issue('command', 'a rest server takes a base url, not a command');
@@ -136,6 +239,8 @@ export const McpServerConfigSchema = z
136
239
  issue('auth', 'a rest server injects its secret into one header: auth.header, no auth.env');
137
240
  }
138
241
  else if (c.kind === 'mcp-stdio') {
242
+ if (c.address !== undefined)
243
+ issue('address', 'an mcp-stdio server is a local program, outside the dialer: it takes no address confirmation');
139
244
  if (c.command === undefined)
140
245
  issue('command', 'an mcp-stdio server needs a command');
141
246
  if (c.url !== undefined)
@@ -160,31 +265,29 @@ export const McpServerConfigSchema = z
160
265
  issue('auth', 'an mcp-http server injects its secret into one header: auth.header, no auth.env');
161
266
  }
162
267
  });
163
- export const SaveMcpServerSchema = z
164
- .object({
268
+ export const SaveMcpServerSchema = z.strictObject({
165
269
  previewHash: z.string().min(1).max(128).optional(),
166
270
  /** (G1) The write/destructive tools of the preview the operator grants: registered enabled. */
167
271
  enabledWrites: z.array(z.string().min(1).max(256)).max(512).optional(),
168
272
  /** (G2) The exact origin a `rest` server's calls go to, confirmed by a human operator. */
169
273
  allowOrigin: z.string().min(1).max(4096).optional(),
170
- })
171
- .strict();
172
- export const PatchMcpServerSchema = z.object({ enabled: z.boolean() }).strict();
173
- export const PatchMcpToolSchema = z
174
- .object({ enabled: z.boolean().optional(), classOverride: toolClass.nullable().optional() })
175
- .strict()
176
- .refine((p) => p.enabled !== undefined || p.classOverride !== undefined, { message: 'set enabled, classOverride or both' });
177
- export const PutMcpSecretSchema = z.object({ value: secretValue }).strict();
178
- export const McpCallSchema = z
179
- .object({
274
+ /** (DES-KNOWLEDGE-DATA-001 §5.1) Each tool's disclosure class, reviewed by a human operator. */
275
+ disclosures: record(z.string().min(1).max(256), disclosureClass).refine((d) => Object.keys(d).length <= 512, { error: 'at most 512 tools' }).optional(),
276
+ });
277
+ export const PatchMcpServerSchema = z.strictObject({ enabled: z.boolean() });
278
+ export const PatchMcpToolSchema = z.strictObject({ enabled: z.boolean().optional(), classOverride: toolClass.nullable().optional(), disclosure: disclosureClass.nullable().optional() })
279
+ .refine((p) => p.enabled !== undefined || p.classOverride !== undefined || p.disclosure !== undefined, { error: 'set enabled, classOverride, disclosure or a combination' });
280
+ /** Unknown query parameters (a cache-buster) are ignored, as they always were. */
281
+ export const McpServersQuerySchema = z.object({ view: z.enum(['full', 'agent']).optional() });
282
+ export const McpRegistryRestoreSchema = z.strictObject({ generation: z.int().min(1).max(Number.MAX_SAFE_INTEGER) });
283
+ export const PutMcpSecretSchema = z.strictObject({ value: secretValue });
284
+ export const McpCallSchema = z.strictObject({
180
285
  token: z.string().min(1).max(256),
181
286
  subject: z.string().min(1).max(512),
182
- args: z.record(z.string(), z.unknown()).optional(),
183
- })
184
- .strict();
185
- export const McpToolsSchema = z.object({ token: z.string().min(1).max(256) }).strict();
186
- export const McpPolicyPreviewSchema = z
187
- .object({
287
+ args: record(z.string(), z.unknown()).optional(),
288
+ });
289
+ export const McpToolsSchema = z.strictObject({ token: z.string().min(1).max(256) });
290
+ export const McpPolicyPreviewSchema = z.strictObject({
188
291
  subject: z.string().min(1).max(256).optional(),
189
292
  server: serverName.optional(),
190
293
  phaseRole: z.enum(MCP_PREVIEW_ROLES).optional(),
@@ -192,17 +295,14 @@ export const McpPolicyPreviewSchema = z
192
295
  mode: z.enum(MCP_RUN_MODES).optional(),
193
296
  phaseId: z.string().regex(/^[A-Za-z0-9_.-]{1,128}$/).optional(),
194
297
  })
195
- .strict()
196
- .refine((b) => b.subject === undefined || b.server === undefined, { message: 'give subject or server, not both' });
197
- export const McpApprovalSchema = z.object({ subject: z.string().min(5).max(256) }).strict();
198
- export const McpUsageQuerySchema = z
199
- .object({
298
+ .refine((b) => b.subject === undefined || b.server === undefined, { error: 'give subject or server, not both' });
299
+ export const McpApprovalSchema = z.strictObject({ subject: z.string().min(5).max(256) });
300
+ export const McpUsageQuerySchema = z.strictObject({
200
301
  days: z.coerce.number().int().min(1).max(MCP_USAGE_MAX_DAYS).optional(),
201
302
  subject: z.string().min(1).max(512).optional(),
202
303
  seat: z.string().regex(/^[A-Za-z0-9_.-]{1,64}$/).optional(),
203
304
  decision: z.enum(MCP_USAGE_DECISIONS).optional(),
204
- })
205
- .strict();
305
+ });
206
306
  function invalidBody(reply, err) {
207
307
  return reply.code(400).send({ error: err.issues.map((i) => `${i.path.join('.') || 'body'}: ${i.message}`).join('; ') });
208
308
  }
@@ -214,9 +314,12 @@ function auditPartial(deps, req, err, subjects) {
214
314
  for (const id of err.changed)
215
315
  deps.audit.record('governance.rule.upserted', deps.actorOf(req), { detail: { id, source: 'mcp-approval', partial: true } });
216
316
  }
217
- function fail(reply, err) {
218
- if (err instanceof McpRegistryError)
219
- return reply.code(err.status).send({ error: err.message, code: err.code });
317
+ function fail(reply, err, actor) {
318
+ if (err instanceof McpRegistryError) {
319
+ // A source's own words go to a human only (DES-APPS-001 §5.2); an agent gets crew's sentence.
320
+ const words = actor?.kind === 'human' && err.humanMessage !== undefined ? err.humanMessage : err.message;
321
+ return reply.code(err.status).send({ error: words, code: err.code });
322
+ }
220
323
  if (err instanceof McpRegistryCorruptError)
221
324
  return reply.code(503).send({ error: err.message, code: 'registry_corrupt' });
222
325
  if (err instanceof SecretStoreError)
@@ -231,12 +334,46 @@ function fail(reply, err) {
231
334
  function mayGrantWrite(actor) {
232
335
  return actor.kind === 'human' && trustAtLeast(actor, 'operator');
233
336
  }
337
+ /** (DES-KNOWLEDGE-DATA-001 §5.2) The full view is a human actor's; every other actor gets the agent-safe one. */
338
+ const sees = viewOf;
339
+ /** A server answer as `actor` may see it. */
340
+ function serverFor(actor, server) {
341
+ return sees(actor) === 'full' ? server : agentServerView(server);
342
+ }
343
+ function humanOperatorOnly(reply, actor, what, code) {
344
+ return reply.code(403).send({ error: `only a human operator can ${what}; you are ${actor.kind}/${actor.trust}`, code });
345
+ }
234
346
  function writeGrantRefused(reply, actor) {
235
347
  return reply.code(403).send({
236
348
  error: `only a human operator can enable a write tool (a write grant); you are ${actor.kind}/${actor.trust}`,
237
349
  code: 'write_grant_human_only',
238
350
  });
239
351
  }
352
+ /** Whether a confirmation actually confirms something (a range, or plaintext). */
353
+ function confirmsAddress(address) {
354
+ return address != null && (address.allow.length > 0 || address.plaintext === true);
355
+ }
356
+ function addressConfirmRefused(reply, actor) {
357
+ return reply.code(403).send({
358
+ error: `only a human operator can confirm a loopback or private range (or plaintext) for a server's connections; you are ${actor.kind}/${actor.trust}`,
359
+ code: 'address_confirm_human_only',
360
+ });
361
+ }
362
+ /**
363
+ * (crew#1316) Whether a preview names a secret the caller did not stage with it: an `env:` variable of the daemon,
364
+ * or a keychain entry crew already holds (another server's, or this name's own saved one). The preview probes with
365
+ * that secret, so it would go to a host the caller chose. A staged secret is the caller's own value, and the
366
+ * registry pins it to this server's own keychain reference (`secret_not_staged_here`), so it is not one.
367
+ */
368
+ function namesStoredSecret(body) {
369
+ return body.auth != null && body.secret === undefined;
370
+ }
371
+ function storedSecretRefused(reply, actor) {
372
+ return reply.code(403).send({
373
+ error: `only a human operator can preview a server with a secret crew already holds (an env: reference, or a keychain entry this preview did not stage); you are ${actor.kind}/${actor.trust}`,
374
+ code: 'stored_secret_human_only',
375
+ });
376
+ }
240
377
  function egressConfirmRefused(reply, actor) {
241
378
  return reply.code(403).send({
242
379
  error: `only a human operator can confirm where a rest server's calls go (allowOrigin); you are ${actor.kind}/${actor.trust}`,
@@ -250,9 +387,42 @@ function toConfig(body) {
250
387
  command: body.command ?? null,
251
388
  args: body.args ?? [],
252
389
  url: body.url ?? null,
390
+ ...(body.pm !== undefined ? { pm: { system: body.pm.system } } : {}),
253
391
  ...(body.kind === 'rest'
254
392
  ? { openapiUrl: body.openapiUrl ?? null, openapi: body.openapi ?? null, operations: body.operations ?? null }
255
393
  : {}),
394
+ ...(body.kind === 'sql' && body.sql !== undefined
395
+ ? {
396
+ sql: {
397
+ driver: body.sql.driver,
398
+ host: body.sql.host,
399
+ port: body.sql.port ?? (body.sql.driver === 'postgres' ? 5432 : 3306),
400
+ database: body.sql.database,
401
+ user: body.sql.user,
402
+ tls: body.sql.tls ?? 'verify-full',
403
+ ...(body.sql.ca !== undefined ? { ca: body.sql.ca } : {}),
404
+ },
405
+ viewsAllowed: body.viewsAllowed ?? [],
406
+ }
407
+ : {}),
408
+ // (DES-KNOWLEDGE-DATA-001 §5.1) The document as sent: the registry checks it against the deployment policy.
409
+ ...(body.kind === 'toolbox-source' && body.toolbox !== undefined
410
+ ? {
411
+ entry: {
412
+ toolbox: body.toolbox,
413
+ runtime: body.runtime ?? 'native',
414
+ tls: { mode: body.tls?.mode ?? 'verify-full', ca: body.tls?.ca ?? null },
415
+ descriptorVersion: 2,
416
+ policyVersion: '',
417
+ },
418
+ viewsAllowed: body.viewsAllowed ?? [],
419
+ }
420
+ : {}),
421
+ // A dialled server always carries its confirmation (none = global unicast over TLS only), so a
422
+ // save stores it and a legacy record is the only one ever derived (registry.ts legacyAddress).
423
+ ...(body.kind !== 'mcp-stdio'
424
+ ? { address: body.address === undefined ? { ...NO_CONFIRMATION, allow: [] } : { allow: [...body.address.allow], plaintext: body.address.plaintext ?? false } }
425
+ : {}),
256
426
  auth: body.auth == null
257
427
  ? null
258
428
  : {
@@ -263,6 +433,47 @@ function toConfig(body) {
263
433
  },
264
434
  };
265
435
  }
436
+ /**
437
+ * (DES-KNOWLEDGE-DATA-001 §5.5) The approval tokens a restore withdraws: an approval covers a tool's SAVED schema,
438
+ * not its name. Every held token of a tool whose restored record is absent, was never saved (`schemaHash` null) or
439
+ * was saved under another schema is withdrawn, with its server's own token (a server-wide approval cannot leave one
440
+ * tool out); every token of a server the generation does not hold, or of a `rest` server whose target differs; and
441
+ * every token naming a server the generation brings back that is not registered now (an orphan).
442
+ */
443
+ export async function restoreWithdrawals(p, current, restored) {
444
+ const out = new Set();
445
+ for (const now of current) {
446
+ const held = await p.tokensOf(now.name);
447
+ if (held.length === 0)
448
+ continue;
449
+ const then = restored.find((x) => x.name === now.name);
450
+ const targetChanged = then !== undefined && (now.kind === 'rest' || then.kind === 'rest') && canonicalJson(now.kind === 'rest' ? restTarget(now) : null) !== canonicalJson(then.kind === 'rest' ? restTarget(configOf(then)) : null);
451
+ if (then === undefined || targetChanged) {
452
+ for (const t of held)
453
+ out.add(t);
454
+ continue;
455
+ }
456
+ const changed = now.tools
457
+ .filter((t) => {
458
+ const was = then.tools.find((x) => x.name === t.name);
459
+ return was === undefined || was.schemaHash === null || was.schemaHash !== t.schemaHash;
460
+ })
461
+ .map((t) => t.subject);
462
+ const drop = new Set([...changed, ...(changed.length > 0 ? [`mcp:${now.name}`] : [])]);
463
+ for (const t of held)
464
+ if (drop.has(t))
465
+ out.add(t);
466
+ }
467
+ // codex r3: an approval naming a server that is not registered now covers nothing anyone reviewed; a restore that
468
+ // brings the name back must not hand it to that registration.
469
+ for (const then of restored) {
470
+ if (current.some((c) => c.name === then.name))
471
+ continue;
472
+ for (const t of await p.tokensOf(then.name))
473
+ out.add(t);
474
+ }
475
+ return [...out].sort();
476
+ }
266
477
  export function registerMcpRoutes(app, deps) {
267
478
  // The MCP ask tool (streamable HTTP, stateless): worker-facing, the unit token in Authorization.
268
479
  app.post(`${V}/mcp/ask`, { config: { manifest: { statusCodes: [200, 401, 503] } } }, async (req, reply) => {
@@ -285,26 +496,49 @@ export function registerMcpRoutes(app, deps) {
285
496
  void reply.code(503).send({ error: 'the MCP registry is not configured on this daemon', code: 'mcp_unavailable' });
286
497
  return null;
287
498
  };
288
- app.get(`${V}/mcp/servers`, { config: { manifest: { responseType: 'McpServersResponse', statusCodes: [200, 503] } } }, async (_req, reply) => {
499
+ app.get(`${V}/mcp/servers`, { config: { manifest: { responseType: 'McpServersResponse | McpServersAgentResponse', statusCodes: [200, 400, 503] } } }, async (req, reply) => {
289
500
  const r = registry(reply);
290
501
  if (r === null)
291
502
  return reply;
503
+ const q = McpServersQuerySchema.safeParse(req.query ?? {});
504
+ if (!q.success)
505
+ return invalidBody(reply, q.error);
292
506
  try {
507
+ // (DES-KNOWLEDGE-DATA-001 §5.2, crew#1310) Connection fields are a human operator's: any other actor gets
508
+ // the projection whatever it asks for.
509
+ if (q.data.view === 'agent' || sees(deps.actorOf(req)) === 'agent')
510
+ return { view: 'agent', ...(await r.listForAgents()) };
293
511
  return await r.list();
294
512
  }
295
513
  catch (err) {
296
514
  return fail(reply, err);
297
515
  }
298
516
  });
299
- app.post(`${V}/mcp/servers/preview`, { config: { manifest: { requestType: 'McpServerConfigBody', responseType: 'McpPreviewResponse', statusCodes: [200, 400, 409, 501, 502, 503] } } }, async (req, reply) => {
517
+ app.post(`${V}/mcp/servers/preview`, { config: { manifest: { requestType: 'McpServerConfigBody', responseType: 'McpPreviewResponse', statusCodes: [200, 400, 403, 409, 501, 502, 503] } } }, async (req, reply) => {
300
518
  const r = registry(reply);
301
519
  if (r === null)
302
520
  return reply;
303
521
  const parsed = McpServerConfigSchema.safeParse(req.body);
304
522
  if (!parsed.success)
305
523
  return invalidBody(reply, parsed.error);
524
+ const actor = deps.actorOf(req);
525
+ // (DES-APPS-001 §5.2) The preview DIALS: a confirmed private range is used now, so only a
526
+ // human operator may name one, here as at the save.
527
+ if (confirmsAddress(parsed.data.address) && !mayGrantWrite(actor))
528
+ return addressConfirmRefused(reply, actor);
529
+ // (crew#1316) It also PROBES with the secret `auth.ref` names: a secret crew already holds is a human operator's to send.
530
+ if (namesStoredSecret(parsed.data) && !mayGrantWrite(actor))
531
+ return storedSecretRefused(reply, actor);
532
+ // (DES-PM-001 §3) A PM source gains tracker links and the gate's bindings: only a person registers one, or
533
+ // previews a save over one.
534
+ const over = await r.get(parsed.data.name).catch(() => null);
535
+ if ((parsed.data.pm !== undefined || over?.pm !== undefined) && !mayGrantWrite(actor))
536
+ return humanOperatorOnly(reply, actor, 'register a project-management source', 'pm_source_human_only');
306
537
  try {
307
- const preview = await r.preview(toConfig(parsed.data), parsed.data.secret ?? null);
538
+ const full = await r.preview(toConfig(parsed.data), parsed.data.secret ?? null);
539
+ // (DES-KNOWLEDGE-DATA-001 §5.2) A source's structure reaches an agent only through estate and the gate.
540
+ const { source: described, ...rest } = full;
541
+ const preview = sees(actor) === 'full' && described !== undefined ? { ...rest, source: described } : rest;
308
542
  if (deps.policies === undefined)
309
543
  return preview;
310
544
  let policies = null;
@@ -317,10 +551,10 @@ export function registerMcpRoutes(app, deps) {
317
551
  return { ...preview, policies };
318
552
  }
319
553
  catch (err) {
320
- return fail(reply, err);
554
+ return fail(reply, err, actor);
321
555
  }
322
556
  });
323
- app.post(`${V}/mcp/servers`, { config: { manifest: { requestType: 'SaveMcpServerBody', responseType: 'McpServer', statusCodes: [201, 400, 403, 409, 500, 502, 503] } } }, async (req, reply) => {
557
+ app.post(`${V}/mcp/servers`, { config: { manifest: { requestType: 'SaveMcpServerBody', responseType: 'McpServer | McpServerAgentView', statusCodes: [201, 400, 403, 409, 500, 502, 503] } } }, async (req, reply) => {
324
558
  const r = registry(reply);
325
559
  if (r === null)
326
560
  return reply;
@@ -335,6 +569,10 @@ export function registerMcpRoutes(app, deps) {
335
569
  const allowOrigin = parsed.data.allowOrigin ?? null;
336
570
  if (allowOrigin !== null && !mayGrantWrite(deps.actorOf(req)))
337
571
  return egressConfirmRefused(reply, deps.actorOf(req));
572
+ // (DES-KNOWLEDGE-DATA-001 §5.1) So is a review of what a tool discloses.
573
+ const disclosures = parsed.data.disclosures ?? {};
574
+ if (Object.keys(disclosures).length > 0 && !mayGrantWrite(deps.actorOf(req)))
575
+ return humanOperatorOnly(reply, deps.actorOf(req), 'review what a tool discloses', 'disclosure_review_human_only');
338
576
  try {
339
577
  // A saved tool whose schema changed loses its approvals BEFORE the save lands, so a failed
340
578
  // withdrawal refuses the save rather than leaving an approval over a schema nobody approved.
@@ -343,8 +581,14 @@ export function registerMcpRoutes(app, deps) {
343
581
  await r.checkWriteGrants(parsed.data.previewHash, enabledWrites);
344
582
  // (G2) An unconfirmed egress is refused before any approval is withdrawn, too.
345
583
  await r.checkEgress(parsed.data.previewHash, allowOrigin);
584
+ r.checkDisclosures(parsed.data.previewHash, disclosures);
346
585
  }
347
586
  const held = parsed.data.previewHash === undefined ? null : r.peekPreview(parsed.data.previewHash);
587
+ // The confirmation rides in the previewed config; saving it is the human operator's, too.
588
+ if (held !== null && confirmsAddress(held.address) && !mayGrantWrite(deps.actorOf(req)))
589
+ return addressConfirmRefused(reply, deps.actorOf(req));
590
+ if (held !== null && held.pm != null && !mayGrantWrite(deps.actorOf(req)))
591
+ return humanOperatorOnly(reply, deps.actorOf(req), 'register a project-management source', 'pm_source_human_only');
348
592
  const commit = async () => {
349
593
  if (held !== null && deps.policies !== undefined) {
350
594
  const tokens = await deps.policies.withdrawnBySave(held);
@@ -355,7 +599,7 @@ export function registerMcpRoutes(app, deps) {
355
599
  deps.audit.record('governance.rule.upserted', deps.actorOf(req), { detail: { id, source: 'mcp-approval' } });
356
600
  }
357
601
  }
358
- return r.save(parsed.data.previewHash, enabledWrites, allowOrigin);
602
+ return r.save(parsed.data.previewHash, enabledWrites, allowOrigin, disclosures);
359
603
  };
360
604
  // (crew#993) The withdrawal and the save are one step for the server: an approval for it
361
605
  // waits until the save commits, then is judged against the new registration. With no held
@@ -371,6 +615,9 @@ export function registerMcpRoutes(app, deps) {
371
615
  disabledWrites: server.tools.filter((t) => t.status !== 'gone' && !t.enabled && isWriteGrant(t.annotations, t.classOverride)).map((t) => t.subject),
372
616
  },
373
617
  });
618
+ if (held !== null && confirmsAddress(held.address)) {
619
+ deps.audit.record('mcp.server.address_confirmed', deps.actorOf(req), { detail: { name: server.name, kind: server.kind, allow: held.address?.allow ?? [], plaintext: held.address?.plaintext ?? false } });
620
+ }
374
621
  // Audited whenever the operator named the origin: the save accepted it, so it is the origin.
375
622
  if (allowOrigin !== null && held?.egress != null) {
376
623
  const e = held.egress;
@@ -382,13 +629,18 @@ export function registerMcpRoutes(app, deps) {
382
629
  continue;
383
630
  deps.audit.record('mcp.tool.write_granted', deps.actorOf(req), { detail: { subject: tool.subject, class: tool.class, via: 'save' } });
384
631
  }
385
- return reply.code(201).send(server);
632
+ for (const [name, disclosure] of Object.entries(disclosures)) {
633
+ const tool = server.tools.find((t) => t.name === name);
634
+ if (tool !== undefined)
635
+ deps.audit.record('mcp.tool.disclosure_reviewed', deps.actorOf(req), { detail: { subject: tool.subject, disclosure, via: 'save' } });
636
+ }
637
+ return reply.code(201).send(serverFor(deps.actorOf(req), server));
386
638
  }
387
639
  catch (err) {
388
640
  return fail(reply, err);
389
641
  }
390
642
  });
391
- app.patch(`${V}/mcp/servers/:name`, { config: { manifest: { requestType: 'PatchMcpServerBody', responseType: 'McpServer', statusCodes: [200, 400, 404, 503] } } }, async (req, reply) => {
643
+ app.patch(`${V}/mcp/servers/:name`, { config: { manifest: { requestType: 'PatchMcpServerBody', responseType: 'McpServer | McpServerAgentView', statusCodes: [200, 400, 403, 404, 503] } } }, async (req, reply) => {
392
644
  const r = registry(reply);
393
645
  if (r === null)
394
646
  return reply;
@@ -396,23 +648,38 @@ export function registerMcpRoutes(app, deps) {
396
648
  if (!parsed.success)
397
649
  return invalidBody(reply, parsed.error);
398
650
  try {
399
- const server = await r.setServerEnabled(req.params.name, parsed.data.enabled);
651
+ // (DES-PM-001 §3) Switching a PM source on or off changes what its links reach: a person's only. Judged and
652
+ // done inside the server's lock, so a save that makes the name a PM source cannot slip between.
653
+ const actor = deps.actorOf(req);
654
+ const server = await exclusive(req.params.name, async () => {
655
+ if ((await r.get(req.params.name)).pm !== undefined && !mayGrantWrite(actor))
656
+ return null;
657
+ return r.setServerEnabled(req.params.name, parsed.data.enabled);
658
+ });
659
+ if (server === null)
660
+ return humanOperatorOnly(reply, actor, 'switch a project-management source on or off', 'pm_source_human_only');
400
661
  deps.audit.record(parsed.data.enabled ? 'mcp.server.enabled' : 'mcp.server.disabled', deps.actorOf(req), { detail: { name: server.name } });
401
- return server;
662
+ return serverFor(deps.actorOf(req), server);
402
663
  }
403
664
  catch (err) {
404
665
  return fail(reply, err);
405
666
  }
406
667
  });
407
- app.delete(`${V}/mcp/servers/:name`, { config: { manifest: { responseType: '{ removed: string }', statusCodes: [200, 404, 500, 502, 503] } } }, async (req, reply) => {
668
+ app.delete(`${V}/mcp/servers/:name`, { config: { manifest: { responseType: '{ removed: string }', statusCodes: [200, 403, 404, 500, 502, 503] } } }, async (req, reply) => {
408
669
  const r = registry(reply);
409
670
  if (r === null)
410
671
  return reply;
411
672
  try {
412
673
  // (crew#993) One step for the server, like the save: no approval lands between the
413
674
  // withdrawal and the removal.
675
+ let refused = false;
414
676
  await exclusive(req.params.name, async () => {
415
- await r.get(req.params.name); // 404 before anything is withdrawn
677
+ // (DES-PM-001 §3.2, Q-PM5) Removing a PM source drops its links, and the last GitHub one would hand `#N` back
678
+ // to the daemon's own `gh`: a person's only. Judged on the record being removed, inside the server's lock.
679
+ if ((await r.get(req.params.name)).pm !== undefined && !mayGrantWrite(deps.actorOf(req))) {
680
+ refused = true;
681
+ return;
682
+ }
416
683
  if (deps.policies !== undefined) {
417
684
  const tokens = await deps.policies.tokensOf(req.params.name);
418
685
  if (tokens.length > 0) {
@@ -424,6 +691,8 @@ export function registerMcpRoutes(app, deps) {
424
691
  }
425
692
  await r.remove(req.params.name);
426
693
  });
694
+ if (refused)
695
+ return humanOperatorOnly(reply, deps.actorOf(req), 'remove a project-management source', 'pm_source_human_only');
427
696
  deps.audit.record('mcp.server.removed', deps.actorOf(req), { detail: { name: req.params.name } });
428
697
  return { removed: req.params.name };
429
698
  }
@@ -431,12 +700,17 @@ export function registerMcpRoutes(app, deps) {
431
700
  return fail(reply, err);
432
701
  }
433
702
  });
434
- app.post(`${V}/mcp/servers/:name/test`, { config: { manifest: { responseType: 'McpServerTestResponse', statusCodes: [200, 404, 409, 503] } } }, async (req, reply) => {
703
+ app.post(`${V}/mcp/servers/:name/test`, { config: { manifest: { responseType: 'McpServerTestResponse | McpServerTestAgentResponse', statusCodes: [200, 404, 409, 503] } } }, async (req, reply) => {
435
704
  const r = registry(reply);
436
705
  if (r === null)
437
706
  return reply;
438
707
  try {
439
- return await r.test(req.params.name);
708
+ const t = await r.test(req.params.name);
709
+ if (sees(deps.actorOf(req)) === 'full')
710
+ return t;
711
+ // A probe's error can name the host it could not reach: an agent gets that it failed.
712
+ const agentAnswer = { ok: t.ok, error: t.error === null ? null : 'the probe failed', diff: t.diff, server: agentServerView(t.server) };
713
+ return agentAnswer;
440
714
  }
441
715
  catch (err) {
442
716
  return fail(reply, err);
@@ -451,11 +725,13 @@ export function registerMcpRoutes(app, deps) {
451
725
  return invalidBody(reply, parsed.error);
452
726
  try {
453
727
  const actor = deps.actorOf(req);
454
- const { tool, grantedWrite } = await r.patchTool(req.params.subject, parsed.data, { mayGrantWrite: mayGrantWrite(actor) });
728
+ const { tool, grantedWrite } = await r.patchTool(req.params.subject, parsed.data, { mayGrantWrite: mayGrantWrite(actor), mayReviewDisclosure: mayGrantWrite(actor) });
455
729
  deps.audit.record('mcp.tool.updated', actor, { detail: { subject: tool.subject, ...parsed.data } });
456
730
  if (grantedWrite) {
457
731
  deps.audit.record('mcp.tool.write_granted', actor, { detail: { subject: tool.subject, class: tool.class, via: 'toggle' } });
458
732
  }
733
+ if (parsed.data.disclosure !== undefined)
734
+ deps.audit.record('mcp.tool.disclosure_reviewed', actor, { detail: { subject: tool.subject, disclosure: parsed.data.disclosure, via: 'patch' } });
459
735
  return tool;
460
736
  }
461
737
  catch (err) {
@@ -495,14 +771,14 @@ export function registerMcpRoutes(app, deps) {
495
771
  if (!parsed.success) {
496
772
  return reply.code(400).send({ error: `body: ${parsed.error.issues.map((i) => `${i.path.join('.') || 'body'} ${i.code}`).join('; ')}`, code: 'bad_request' });
497
773
  }
498
- const answer = await listUnitTools({ registry, lister: toolLister }, parsed.data.token);
774
+ const answer = await listUnitTools({ registry, lister: toolLister, ...(deps.gate !== undefined ? { gate: deps.gate } : {}) }, parsed.data.token);
499
775
  return reply.code(answer.status).send(answer.body);
500
776
  });
501
777
  // (crew#719) RE-KEY only: the server must already be registered and already reference this
502
778
  // keychain entry. A NEW server's secret is staged with its preview (`secret` on the preview
503
779
  // body) and committed by the save, so the two can no longer half-land.
504
780
  app.put(`${V}/mcp/servers/:name/secret`, {
505
- config: { manifest: { requestType: 'PutMcpSecretBody', responseType: 'McpSecretResponse', statusCodes: [200, 400, 404, 501, 502, 503] } },
781
+ config: { manifest: { requestType: 'PutMcpSecretBody', responseType: 'McpSecretResponse', statusCodes: [200, 400, 403, 404, 501, 502, 503] } },
506
782
  }, async (req, reply) => {
507
783
  const r = registry(reply);
508
784
  if (r === null)
@@ -514,7 +790,17 @@ export function registerMcpRoutes(app, deps) {
514
790
  if (!parsed.success)
515
791
  return invalidBody(reply, parsed.error);
516
792
  try {
517
- const ref = await r.setSecret(name.data, parsed.data.value);
793
+ // (DES-PM-001 §5) A PM source's credential is the identity its approved actions post as: a person re-keys it.
794
+ // Judged and written inside the server's lock, so a save that makes the name a PM source cannot slip between.
795
+ const actor = deps.actorOf(req);
796
+ const ref = await exclusive(name.data, async () => {
797
+ // An unknown name is setSecret's to answer (its own refusals come first, as before).
798
+ if ((await r.get(name.data).catch(() => null))?.pm !== undefined && !mayGrantWrite(actor))
799
+ return null;
800
+ return r.setSecret(name.data, parsed.data.value);
801
+ });
802
+ if (ref === null)
803
+ return humanOperatorOnly(reply, actor, "re-key a project-management source's credential", 'pm_source_human_only');
518
804
  deps.audit.record('mcp.secret.set', deps.actorOf(req), { detail: { name: name.data, ref } });
519
805
  return { ref, set: true };
520
806
  }
@@ -522,6 +808,85 @@ export function registerMcpRoutes(app, deps) {
522
808
  return fail(reply, err);
523
809
  }
524
810
  });
811
+ // ── DES-KNOWLEDGE-DATA-001 §5.5: generations and a fail-closed restore ───────────────────────
812
+ app.get(`${V}/mcp/registry/generations`, { config: { manifest: { responseType: 'McpRegistryGenerationsResponse', statusCodes: [200, 403, 503] } } }, async (req, reply) => {
813
+ const actor = deps.actorOf(req);
814
+ if (!mayGrantWrite(actor))
815
+ return humanOperatorOnly(reply, actor, "read the registry's generations", 'human_only');
816
+ const r = registry(reply);
817
+ if (r === null)
818
+ return reply;
819
+ try {
820
+ return await r.generations();
821
+ }
822
+ catch (err) {
823
+ return fail(reply, err, actor);
824
+ }
825
+ });
826
+ app.post(`${V}/mcp/registry/restore`, { config: { manifest: { requestType: 'McpRegistryRestoreBody', responseType: 'McpRegistryRestoreResponse', statusCodes: [200, 400, 403, 404, 409, 500, 503] } } }, async (req, reply) => {
827
+ const actor = deps.actorOf(req);
828
+ if (!mayGrantWrite(actor))
829
+ return humanOperatorOnly(reply, actor, 'restore the registry', 'restore_human_only');
830
+ const r = registry(reply);
831
+ if (r === null)
832
+ return reply;
833
+ const parsed = McpRegistryRestoreSchema.safeParse(req.body);
834
+ if (!parsed.success)
835
+ return invalidBody(reply, parsed.error);
836
+ const generation = parsed.data.generation;
837
+ try {
838
+ // ONE snapshot, read and validated before anything changes: a restore that is refused (unknown, unreadable,
839
+ // a document the policy refuses) withdraws nothing, and a generation pruned meanwhile cannot fail it half-way.
840
+ const plan = await r.planRestore(generation);
841
+ const p = deps.policies;
842
+ const planned = plan.servers.map((s) => s.name);
843
+ // (crew#993) The withdrawal and the commit are one step for EVERY server they touch: each server's lock, in
844
+ // name order (every other holder takes one lock, so the order cannot deadlock), so no approval, save or
845
+ // removal of those servers lands between them. A server registered while the locks were being taken is not
846
+ // covered: then nothing is done, and the locks are taken again over the larger set (codex r2).
847
+ const locked = (names, fn) => (p === undefined ? fn() : names.reduceRight((inner, name) => () => p.exclusive(name, inner), fn)());
848
+ let names = [...new Set([...(await r.list()).servers.map((s) => s.name), ...planned])].sort();
849
+ let done = null;
850
+ for (let attempt = 0; attempt < 3 && done === null; attempt++) {
851
+ const held = names;
852
+ done = await locked(held, async () => {
853
+ const now = (await r.list()).servers;
854
+ const wider = now.map((s) => s.name).filter((n) => !held.includes(n));
855
+ if (wider.length > 0) {
856
+ names = [...new Set([...held, ...wider])].sort();
857
+ return null;
858
+ }
859
+ let withdrawn = [];
860
+ if (p !== undefined) {
861
+ withdrawn = await restoreWithdrawals(p, now, plan.servers);
862
+ if (withdrawn.length > 0) {
863
+ let rules;
864
+ try {
865
+ rules = await p.withdraw(withdrawn);
866
+ }
867
+ catch (err) {
868
+ auditPartial(deps, req, err, withdrawn);
869
+ throw new McpRegistryError(500, 'withdraw_failed', `the registry was not restored: approvals that generation ${generation} does not cover could not be withdrawn (${err instanceof Error ? err.message : String(err)})`);
870
+ }
871
+ deps.audit.record('mcp.approval.withdrawn', actor, { detail: { subjects: withdrawn, rules, why: 'registry_restored' } });
872
+ for (const id of rules)
873
+ deps.audit.record('governance.rule.upserted', actor, { detail: { id, source: 'mcp-approval' } });
874
+ }
875
+ }
876
+ return { out: await r.restore(plan, held), withdrawn };
877
+ });
878
+ }
879
+ if (done === null)
880
+ throw new McpRegistryError(409, 'registry_busy', 'servers kept being registered while the restore was taking their locks; nothing was restored: try again');
881
+ const { out, withdrawn } = done;
882
+ const body = { ...out, withdrawnApprovals: withdrawn };
883
+ deps.audit.record('mcp.registry.restored', actor, { detail: { restored: generation, generation: out.generation, servers: out.servers, disabled: out.disabled, queryReset: out.queryReset, writesReset: out.writesReset, withdrawnApprovals: withdrawn } });
884
+ return body;
885
+ }
886
+ catch (err) {
887
+ return fail(reply, err, actor);
888
+ }
889
+ });
525
890
  // ── S6: the policy preview and the approvals ────────────────────────────────────────────────
526
891
  const policies = (reply) => {
527
892
  if (deps.registry !== undefined && deps.policies !== undefined)