wicked-crew 0.18.19 → 0.18.21

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 (700) hide show
  1. package/README.md +9 -6
  2. package/dist/api/ask-paths.d.ts +2 -0
  3. package/dist/api/ask-paths.d.ts.map +1 -1
  4. package/dist/api/ask-paths.js +6 -0
  5. package/dist/api/ask-paths.js.map +1 -1
  6. package/dist/api/auth.d.ts +7 -5
  7. package/dist/api/auth.d.ts.map +1 -1
  8. package/dist/api/auth.js +23 -9
  9. package/dist/api/auth.js.map +1 -1
  10. package/dist/api/capture.d.ts +5 -2
  11. package/dist/api/capture.d.ts.map +1 -1
  12. package/dist/api/capture.js +13 -10
  13. package/dist/api/capture.js.map +1 -1
  14. package/dist/api/chat-attachments.d.ts.map +1 -1
  15. package/dist/api/chat-attachments.js +69 -19
  16. package/dist/api/chat-attachments.js.map +1 -1
  17. package/dist/api/chat-citations.d.ts.map +1 -1
  18. package/dist/api/chat-citations.js +22 -0
  19. package/dist/api/chat-citations.js.map +1 -1
  20. package/dist/api/chat-context.d.ts +16 -1
  21. package/dist/api/chat-context.d.ts.map +1 -1
  22. package/dist/api/chat-context.js +75 -14
  23. package/dist/api/chat-context.js.map +1 -1
  24. package/dist/api/chat-freshness.js +2 -2
  25. package/dist/api/chat-freshness.js.map +1 -1
  26. package/dist/api/chat-history.d.ts +13 -0
  27. package/dist/api/chat-history.d.ts.map +1 -1
  28. package/dist/api/chat-history.js +25 -0
  29. package/dist/api/chat-history.js.map +1 -1
  30. package/dist/api/chat-jobs.d.ts +67 -6
  31. package/dist/api/chat-jobs.d.ts.map +1 -1
  32. package/dist/api/chat-jobs.js +243 -22
  33. package/dist/api/chat-jobs.js.map +1 -1
  34. package/dist/api/chat-proposals.d.ts +69 -6
  35. package/dist/api/chat-proposals.d.ts.map +1 -1
  36. package/dist/api/chat-proposals.js +310 -49
  37. package/dist/api/chat-proposals.js.map +1 -1
  38. package/dist/api/chat-requirements.d.ts.map +1 -1
  39. package/dist/api/chat-requirements.js +4 -1
  40. package/dist/api/chat-requirements.js.map +1 -1
  41. package/dist/api/chat-scope.d.ts +17 -9
  42. package/dist/api/chat-scope.d.ts.map +1 -1
  43. package/dist/api/chat-scope.js +55 -21
  44. package/dist/api/chat-scope.js.map +1 -1
  45. package/dist/api/cluster-status.d.ts +24 -12
  46. package/dist/api/cluster-status.d.ts.map +1 -1
  47. package/dist/api/cluster-status.js +82 -4
  48. package/dist/api/cluster-status.js.map +1 -1
  49. package/dist/api/codebase-archive.d.ts +4 -3
  50. package/dist/api/codebase-archive.d.ts.map +1 -1
  51. package/dist/api/codebase-archive.js +6 -5
  52. package/dist/api/codebase-archive.js.map +1 -1
  53. package/dist/api/delivery-cache.d.ts +2 -0
  54. package/dist/api/delivery-cache.d.ts.map +1 -1
  55. package/dist/api/delivery-cache.js +1 -2
  56. package/dist/api/delivery-cache.js.map +1 -1
  57. package/dist/api/delivery-index.d.ts +2 -2
  58. package/dist/api/delivery-index.d.ts.map +1 -1
  59. package/dist/api/delivery-index.js +1 -2
  60. package/dist/api/delivery-index.js.map +1 -1
  61. package/dist/api/eval-compare.d.ts +1 -1
  62. package/dist/api/eval-compare.js +1 -1
  63. package/dist/api/eval-sample.d.ts +7 -0
  64. package/dist/api/eval-sample.d.ts.map +1 -1
  65. package/dist/api/eval-sample.js +20 -0
  66. package/dist/api/eval-sample.js.map +1 -1
  67. package/dist/api/gate-cache.d.ts +1 -0
  68. package/dist/api/gate-cache.d.ts.map +1 -1
  69. package/dist/api/gate-cache.js +19 -6
  70. package/dist/api/gate-cache.js.map +1 -1
  71. package/dist/api/governance-steering.d.ts +17 -4
  72. package/dist/api/governance-steering.d.ts.map +1 -1
  73. package/dist/api/governance-steering.js +56 -7
  74. package/dist/api/governance-steering.js.map +1 -1
  75. package/dist/api/mcp.d.ts +12 -2
  76. package/dist/api/mcp.d.ts.map +1 -1
  77. package/dist/api/mcp.js +56 -12
  78. package/dist/api/mcp.js.map +1 -1
  79. package/dist/api/needs.d.ts +20 -0
  80. package/dist/api/needs.d.ts.map +1 -1
  81. package/dist/api/needs.js +120 -19
  82. package/dist/api/needs.js.map +1 -1
  83. package/dist/api/onboarding-capture.d.ts +21 -1
  84. package/dist/api/onboarding-capture.d.ts.map +1 -1
  85. package/dist/api/onboarding-capture.js +112 -8
  86. package/dist/api/onboarding-capture.js.map +1 -1
  87. package/dist/api/policy-landing.d.ts +36 -0
  88. package/dist/api/policy-landing.d.ts.map +1 -1
  89. package/dist/api/policy-landing.js +123 -4
  90. package/dist/api/policy-landing.js.map +1 -1
  91. package/dist/api/post-hoc-deliver.d.ts.map +1 -1
  92. package/dist/api/post-hoc-deliver.js +2 -1
  93. package/dist/api/post-hoc-deliver.js.map +1 -1
  94. package/dist/api/product.d.ts +1 -1
  95. package/dist/api/proposal-decisions.d.ts +44 -0
  96. package/dist/api/proposal-decisions.d.ts.map +1 -0
  97. package/dist/api/proposal-decisions.js +85 -0
  98. package/dist/api/proposal-decisions.js.map +1 -0
  99. package/dist/api/proposal-onboard.d.ts +38 -1
  100. package/dist/api/proposal-onboard.d.ts.map +1 -1
  101. package/dist/api/proposal-onboard.js +203 -14
  102. package/dist/api/proposal-onboard.js.map +1 -1
  103. package/dist/api/recording.d.ts +1 -1
  104. package/dist/api/recording.d.ts.map +1 -1
  105. package/dist/api/recording.js +4 -5
  106. package/dist/api/recording.js.map +1 -1
  107. package/dist/api/redeliver.d.ts.map +1 -1
  108. package/dist/api/redeliver.js +11 -7
  109. package/dist/api/redeliver.js.map +1 -1
  110. package/dist/api/repo-input.d.ts.map +1 -1
  111. package/dist/api/repo-input.js +5 -2
  112. package/dist/api/repo-input.js.map +1 -1
  113. package/dist/api/repo-origins.d.ts +24 -0
  114. package/dist/api/repo-origins.d.ts.map +1 -0
  115. package/dist/api/repo-origins.js +71 -0
  116. package/dist/api/repo-origins.js.map +1 -0
  117. package/dist/api/requirements.d.ts +37 -16
  118. package/dist/api/requirements.d.ts.map +1 -1
  119. package/dist/api/requirements.js +73 -2
  120. package/dist/api/requirements.js.map +1 -1
  121. package/dist/api/retry-index.d.ts +2 -0
  122. package/dist/api/retry-index.d.ts.map +1 -1
  123. package/dist/api/retry-index.js +16 -8
  124. package/dist/api/retry-index.js.map +1 -1
  125. package/dist/api/review-change.d.ts +5 -6
  126. package/dist/api/review-change.d.ts.map +1 -1
  127. package/dist/api/review-change.js +45 -8
  128. package/dist/api/review-change.js.map +1 -1
  129. package/dist/api/roster-standing.d.ts +2 -0
  130. package/dist/api/roster-standing.d.ts.map +1 -1
  131. package/dist/api/roster-standing.js +8 -1
  132. package/dist/api/roster-standing.js.map +1 -1
  133. package/dist/api/routes.d.ts +55 -12
  134. package/dist/api/routes.d.ts.map +1 -1
  135. package/dist/api/routes.js +961 -277
  136. package/dist/api/routes.js.map +1 -1
  137. package/dist/api/run-documents.d.ts +9 -1
  138. package/dist/api/run-documents.d.ts.map +1 -1
  139. package/dist/api/run-documents.js +63 -5
  140. package/dist/api/run-documents.js.map +1 -1
  141. package/dist/api/run-sources.d.ts +11 -1
  142. package/dist/api/run-sources.d.ts.map +1 -1
  143. package/dist/api/run-sources.js +26 -3
  144. package/dist/api/run-sources.js.map +1 -1
  145. package/dist/api/run-timing-index.d.ts +47 -0
  146. package/dist/api/run-timing-index.d.ts.map +1 -1
  147. package/dist/api/run-timing-index.js +196 -86
  148. package/dist/api/run-timing-index.js.map +1 -1
  149. package/dist/api/runtime-state.d.ts +6 -0
  150. package/dist/api/runtime-state.d.ts.map +1 -1
  151. package/dist/api/runtime-state.js +14 -3
  152. package/dist/api/runtime-state.js.map +1 -1
  153. package/dist/api/seat-agents.d.ts.map +1 -1
  154. package/dist/api/seat-agents.js +3 -3
  155. package/dist/api/seat-agents.js.map +1 -1
  156. package/dist/api/seat-container-login.d.ts +6 -2
  157. package/dist/api/seat-container-login.d.ts.map +1 -1
  158. package/dist/api/seat-container-login.js +17 -9
  159. package/dist/api/seat-container-login.js.map +1 -1
  160. package/dist/api/seat-governance.d.ts +3 -2
  161. package/dist/api/seat-governance.d.ts.map +1 -1
  162. package/dist/api/seat-governance.js +31 -9
  163. package/dist/api/seat-governance.js.map +1 -1
  164. package/dist/api/seat-standing.d.ts +8 -0
  165. package/dist/api/seat-standing.d.ts.map +1 -1
  166. package/dist/api/seat-standing.js +26 -1
  167. package/dist/api/seat-standing.js.map +1 -1
  168. package/dist/api/server.d.ts +7 -0
  169. package/dist/api/server.d.ts.map +1 -1
  170. package/dist/api/server.js +172 -59
  171. package/dist/api/server.js.map +1 -1
  172. package/dist/api/stall-watchdog.d.ts +6 -0
  173. package/dist/api/stall-watchdog.d.ts.map +1 -1
  174. package/dist/api/stall-watchdog.js +28 -0
  175. package/dist/api/stall-watchdog.js.map +1 -1
  176. package/dist/api/start-on-login.d.ts +4 -0
  177. package/dist/api/start-on-login.d.ts.map +1 -0
  178. package/dist/api/start-on-login.js +35 -0
  179. package/dist/api/start-on-login.js.map +1 -0
  180. package/dist/api/steering-landing.d.ts +33 -8
  181. package/dist/api/steering-landing.d.ts.map +1 -1
  182. package/dist/api/steering-landing.js +235 -51
  183. package/dist/api/steering-landing.js.map +1 -1
  184. package/dist/api/system-snapshot.d.ts +5 -0
  185. package/dist/api/system-snapshot.d.ts.map +1 -1
  186. package/dist/api/system-snapshot.js +22 -10
  187. package/dist/api/system-snapshot.js.map +1 -1
  188. package/dist/api/testing.d.ts +2 -2
  189. package/dist/api/ui-text.js +2 -2
  190. package/dist/api/ui-text.js.map +1 -1
  191. package/dist/api/worktree-sweep.d.ts +7 -3
  192. package/dist/api/worktree-sweep.d.ts.map +1 -1
  193. package/dist/api/worktree-sweep.js +10 -6
  194. package/dist/api/worktree-sweep.js.map +1 -1
  195. package/dist/apps/actions/api-action.js +5 -2
  196. package/dist/apps/actions/api-action.js.map +1 -1
  197. package/dist/apps/actions/write-path.d.ts +9 -0
  198. package/dist/apps/actions/write-path.d.ts.map +1 -1
  199. package/dist/apps/actions/write-path.js +17 -9
  200. package/dist/apps/actions/write-path.js.map +1 -1
  201. package/dist/apps/exec/executor.d.ts +8 -15
  202. package/dist/apps/exec/executor.d.ts.map +1 -1
  203. package/dist/apps/exec/executor.js +10 -3
  204. package/dist/apps/exec/executor.js.map +1 -1
  205. package/dist/apps/exec/recall.d.ts.map +1 -1
  206. package/dist/apps/exec/recall.js +4 -4
  207. package/dist/apps/exec/recall.js.map +1 -1
  208. package/dist/apps/exec/redescribe.d.ts +37 -0
  209. package/dist/apps/exec/redescribe.d.ts.map +1 -0
  210. package/dist/apps/exec/redescribe.js +86 -0
  211. package/dist/apps/exec/redescribe.js.map +1 -0
  212. package/dist/apps/exec/source-stage.d.ts +3 -1
  213. package/dist/apps/exec/source-stage.d.ts.map +1 -1
  214. package/dist/apps/exec/source-stage.js +13 -3
  215. package/dist/apps/exec/source-stage.js.map +1 -1
  216. package/dist/apps/exec/sources.d.ts +6 -0
  217. package/dist/apps/exec/sources.d.ts.map +1 -1
  218. package/dist/apps/exec/sources.js +8 -0
  219. package/dist/apps/exec/sources.js.map +1 -1
  220. package/dist/apps/git.js +2 -2
  221. package/dist/apps/git.js.map +1 -1
  222. package/dist/apps/publish/manifest.d.ts +8 -1
  223. package/dist/apps/publish/manifest.d.ts.map +1 -1
  224. package/dist/apps/publish/manifest.js +14 -3
  225. package/dist/apps/publish/manifest.js.map +1 -1
  226. package/dist/apps/publish/run.d.ts +15 -2
  227. package/dist/apps/publish/run.d.ts.map +1 -1
  228. package/dist/apps/publish/run.js +100 -17
  229. package/dist/apps/publish/run.js.map +1 -1
  230. package/dist/apps/routes.d.ts +3 -0
  231. package/dist/apps/routes.d.ts.map +1 -1
  232. package/dist/apps/routes.js +58 -2
  233. package/dist/apps/routes.js.map +1 -1
  234. package/dist/apps/store.d.ts +24 -3
  235. package/dist/apps/store.d.ts.map +1 -1
  236. package/dist/apps/store.js +26 -9
  237. package/dist/apps/store.js.map +1 -1
  238. package/dist/apps/turns.d.ts +25 -2
  239. package/dist/apps/turns.d.ts.map +1 -1
  240. package/dist/apps/turns.js +276 -11
  241. package/dist/apps/turns.js.map +1 -1
  242. package/dist/apps-server/Dockerfile +2 -2
  243. package/dist/apps-server/runners/sqlite-runner.mjs +67 -12
  244. package/dist/apps-server/server/lib/bundle/server.mjs +353 -159
  245. package/dist/cli/governance.d.ts +5 -2
  246. package/dist/cli/governance.d.ts.map +1 -1
  247. package/dist/cli/governance.js +8 -5
  248. package/dist/cli/governance.js.map +1 -1
  249. package/dist/cli/index.d.ts.map +1 -1
  250. package/dist/cli/index.js +6 -5
  251. package/dist/cli/index.js.map +1 -1
  252. package/dist/cli/service.d.ts +10 -6
  253. package/dist/cli/service.d.ts.map +1 -1
  254. package/dist/cli/service.js +39 -23
  255. package/dist/cli/service.js.map +1 -1
  256. package/dist/core/adapter.d.ts +61 -29
  257. package/dist/core/adapter.d.ts.map +1 -1
  258. package/dist/core/adapter.js +214 -83
  259. package/dist/core/adapter.js.map +1 -1
  260. package/dist/core/ado-deliver-helper.d.ts +2 -1
  261. package/dist/core/ado-deliver-helper.d.ts.map +1 -1
  262. package/dist/core/ado-deliver-helper.js +26 -1
  263. package/dist/core/ado-deliver-helper.js.map +1 -1
  264. package/dist/core/assurance.d.ts +45 -42
  265. package/dist/core/assurance.d.ts.map +1 -1
  266. package/dist/core/assurance.js +74 -67
  267. package/dist/core/assurance.js.map +1 -1
  268. package/dist/core/deliver-text.d.ts +14 -0
  269. package/dist/core/deliver-text.d.ts.map +1 -1
  270. package/dist/core/deliver-text.js +41 -2
  271. package/dist/core/deliver-text.js.map +1 -1
  272. package/dist/core/deliver.d.ts +66 -1
  273. package/dist/core/deliver.d.ts.map +1 -1
  274. package/dist/core/deliver.js +183 -10
  275. package/dist/core/deliver.js.map +1 -1
  276. package/dist/core/engine-roster.d.ts +2 -0
  277. package/dist/core/engine-roster.d.ts.map +1 -1
  278. package/dist/core/engine-roster.js +13 -0
  279. package/dist/core/engine-roster.js.map +1 -1
  280. package/dist/core/estate-mcp-client.d.ts +13 -14
  281. package/dist/core/estate-mcp-client.d.ts.map +1 -1
  282. package/dist/core/estate-mcp-client.js +49 -68
  283. package/dist/core/estate-mcp-client.js.map +1 -1
  284. package/dist/core/exec.d.ts +24 -0
  285. package/dist/core/exec.d.ts.map +1 -1
  286. package/dist/core/exec.js +45 -2
  287. package/dist/core/exec.js.map +1 -1
  288. package/dist/core/linked-issues.d.ts +13 -2
  289. package/dist/core/linked-issues.d.ts.map +1 -1
  290. package/dist/core/linked-issues.js +135 -4
  291. package/dist/core/linked-issues.js.map +1 -1
  292. package/dist/core/pr-checks-helper.d.ts +8 -4
  293. package/dist/core/pr-checks-helper.d.ts.map +1 -1
  294. package/dist/core/pr-checks-helper.js +39 -17
  295. package/dist/core/pr-checks-helper.js.map +1 -1
  296. package/dist/core/redeliver.js +2 -2
  297. package/dist/core/redeliver.js.map +1 -1
  298. package/dist/core/repo-clone.d.ts +64 -0
  299. package/dist/core/repo-clone.d.ts.map +1 -0
  300. package/dist/core/repo-clone.js +306 -0
  301. package/dist/core/repo-clone.js.map +1 -0
  302. package/dist/core/repoPaths.d.ts +2 -4
  303. package/dist/core/repoPaths.d.ts.map +1 -1
  304. package/dist/core/repoPaths.js +4 -6
  305. package/dist/core/repoPaths.js.map +1 -1
  306. package/dist/core/run-identity.d.ts.map +1 -1
  307. package/dist/core/run-identity.js +3 -0
  308. package/dist/core/run-identity.js.map +1 -1
  309. package/dist/core/run-read-lane.d.ts +30 -0
  310. package/dist/core/run-read-lane.d.ts.map +1 -0
  311. package/dist/core/run-read-lane.js +103 -0
  312. package/dist/core/run-read-lane.js.map +1 -0
  313. package/dist/core/types.d.ts +10 -0
  314. package/dist/core/types.d.ts.map +1 -1
  315. package/dist/core/types.js +2 -0
  316. package/dist/core/types.js.map +1 -1
  317. package/dist/core/walkthrough-root.d.ts.map +1 -1
  318. package/dist/core/walkthrough-root.js +3 -5
  319. package/dist/core/walkthrough-root.js.map +1 -1
  320. package/dist/core/wicked-home.d.ts +9 -0
  321. package/dist/core/wicked-home.d.ts.map +1 -0
  322. package/dist/core/wicked-home.js +25 -0
  323. package/dist/core/wicked-home.js.map +1 -0
  324. package/dist/decisions/consider.d.ts +2 -1
  325. package/dist/decisions/consider.d.ts.map +1 -1
  326. package/dist/decisions/consider.js +2 -2
  327. package/dist/decisions/consider.js.map +1 -1
  328. package/dist/decisions/land.d.ts +2 -0
  329. package/dist/decisions/land.d.ts.map +1 -1
  330. package/dist/decisions/land.js +16 -3
  331. package/dist/decisions/land.js.map +1 -1
  332. package/dist/decisions/rules-brief.d.ts +4 -1
  333. package/dist/decisions/rules-brief.d.ts.map +1 -1
  334. package/dist/decisions/rules-brief.js +3 -2
  335. package/dist/decisions/rules-brief.js.map +1 -1
  336. package/dist/editors/conformance-runtime.d.ts +0 -2
  337. package/dist/editors/conformance-runtime.d.ts.map +1 -1
  338. package/dist/editors/conformance-runtime.js +0 -4
  339. package/dist/editors/conformance-runtime.js.map +1 -1
  340. package/dist/editors/csp.d.ts +6 -0
  341. package/dist/editors/csp.d.ts.map +1 -1
  342. package/dist/editors/csp.js +10 -0
  343. package/dist/editors/csp.js.map +1 -1
  344. package/dist/editors/pack-install.d.ts +11 -15
  345. package/dist/editors/pack-install.d.ts.map +1 -1
  346. package/dist/editors/pack-install.js +52 -65
  347. package/dist/editors/pack-install.js.map +1 -1
  348. package/dist/editors/registry.d.ts +31 -13
  349. package/dist/editors/registry.d.ts.map +1 -1
  350. package/dist/editors/registry.js +51 -18
  351. package/dist/editors/registry.js.map +1 -1
  352. package/dist/editors/routes.d.ts +4 -2
  353. package/dist/editors/routes.d.ts.map +1 -1
  354. package/dist/editors/routes.js +23 -6
  355. package/dist/editors/routes.js.map +1 -1
  356. package/dist/editors/visuals.d.ts +4 -3
  357. package/dist/editors/visuals.d.ts.map +1 -1
  358. package/dist/editors/visuals.js +17 -7
  359. package/dist/editors/visuals.js.map +1 -1
  360. package/dist/evals/runner.js +1 -1
  361. package/dist/evals/runner.js.map +1 -1
  362. package/dist/evals/shape-corrections.js +1 -1
  363. package/dist/evals/shape-corrections.js.map +1 -1
  364. package/dist/evals/shape.d.ts +7 -1
  365. package/dist/evals/shape.d.ts.map +1 -1
  366. package/dist/evals/shape.js +26 -6
  367. package/dist/evals/shape.js.map +1 -1
  368. package/dist/evals/workflow.d.ts +16 -3
  369. package/dist/evals/workflow.d.ts.map +1 -1
  370. package/dist/evals/workflow.js +32 -6
  371. package/dist/evals/workflow.js.map +1 -1
  372. package/dist/governance/rule-revision.d.ts +7 -0
  373. package/dist/governance/rule-revision.d.ts.map +1 -0
  374. package/dist/governance/rule-revision.js +23 -0
  375. package/dist/governance/rule-revision.js.map +1 -0
  376. package/dist/insights/review-service.d.ts +26 -3
  377. package/dist/insights/review-service.d.ts.map +1 -1
  378. package/dist/insights/review-service.js +101 -11
  379. package/dist/insights/review-service.js.map +1 -1
  380. package/dist/insights/routes.d.ts +2 -1
  381. package/dist/insights/routes.d.ts.map +1 -1
  382. package/dist/insights/routes.js +19 -4
  383. package/dist/insights/routes.js.map +1 -1
  384. package/dist/insights/run-facts.d.ts +5 -0
  385. package/dist/insights/run-facts.d.ts.map +1 -1
  386. package/dist/insights/run-facts.js +15 -0
  387. package/dist/insights/run-facts.js.map +1 -1
  388. package/dist/insights/workflow.d.ts +2 -1
  389. package/dist/insights/workflow.d.ts.map +1 -1
  390. package/dist/insights/workflow.js +4 -4
  391. package/dist/insights/workflow.js.map +1 -1
  392. package/dist/inspect/service.d.ts +3 -2
  393. package/dist/inspect/service.d.ts.map +1 -1
  394. package/dist/inspect/service.js +4 -4
  395. package/dist/inspect/service.js.map +1 -1
  396. package/dist/interactive/bridge-pool.d.ts +2 -0
  397. package/dist/interactive/bridge-pool.d.ts.map +1 -1
  398. package/dist/interactive/bridge-pool.js +18 -8
  399. package/dist/interactive/bridge-pool.js.map +1 -1
  400. package/dist/interactive/chat-events.d.ts +3 -0
  401. package/dist/interactive/chat-events.d.ts.map +1 -1
  402. package/dist/interactive/chat-events.js +20 -5
  403. package/dist/interactive/chat-events.js.map +1 -1
  404. package/dist/interactive/doc-delete-routes.d.ts +1 -0
  405. package/dist/interactive/doc-delete-routes.d.ts.map +1 -1
  406. package/dist/interactive/doc-delete-routes.js +126 -123
  407. package/dist/interactive/doc-delete-routes.js.map +1 -1
  408. package/dist/interactive/draft-events.d.ts +11 -7
  409. package/dist/interactive/draft-events.d.ts.map +1 -1
  410. package/dist/interactive/draft-events.js +29 -22
  411. package/dist/interactive/draft-events.js.map +1 -1
  412. package/dist/interactive/draft-skill.d.ts +56 -3
  413. package/dist/interactive/draft-skill.d.ts.map +1 -1
  414. package/dist/interactive/draft-skill.js +129 -20
  415. package/dist/interactive/draft-skill.js.map +1 -1
  416. package/dist/interactive/landing-guard.d.ts +30 -5
  417. package/dist/interactive/landing-guard.d.ts.map +1 -1
  418. package/dist/interactive/landing-guard.js +121 -5
  419. package/dist/interactive/landing-guard.js.map +1 -1
  420. package/dist/interactive/proposal-create.d.ts +9 -11
  421. package/dist/interactive/proposal-create.d.ts.map +1 -1
  422. package/dist/interactive/proposal-create.js +28 -21
  423. package/dist/interactive/proposal-create.js.map +1 -1
  424. package/dist/interactive/proposal-refine.d.ts +4 -4
  425. package/dist/interactive/proposal-refine.d.ts.map +1 -1
  426. package/dist/interactive/proposal-refine.js +40 -7
  427. package/dist/interactive/proposal-refine.js.map +1 -1
  428. package/dist/interactive/proxy-routes.d.ts +10 -5
  429. package/dist/interactive/proxy-routes.d.ts.map +1 -1
  430. package/dist/interactive/proxy-routes.js +108 -11
  431. package/dist/interactive/proxy-routes.js.map +1 -1
  432. package/dist/interactive/review-events.js +1 -1
  433. package/dist/interactive/review-events.js.map +1 -1
  434. package/dist/interactive/run-units.d.ts.map +1 -1
  435. package/dist/interactive/run-units.js +3 -2
  436. package/dist/interactive/run-units.js.map +1 -1
  437. package/dist/interactive/source-packet.d.ts +13 -1
  438. package/dist/interactive/source-packet.d.ts.map +1 -1
  439. package/dist/interactive/source-packet.js +108 -34
  440. package/dist/interactive/source-packet.js.map +1 -1
  441. package/dist/knowledge/adapters/toolbox/memory.d.ts +2 -0
  442. package/dist/knowledge/adapters/toolbox/memory.d.ts.map +1 -0
  443. package/dist/knowledge/adapters/toolbox/memory.js +43 -0
  444. package/dist/knowledge/adapters/toolbox/memory.js.map +1 -0
  445. package/dist/knowledge/adapters/toolbox/supervisor.d.ts +30 -4
  446. package/dist/knowledge/adapters/toolbox/supervisor.d.ts.map +1 -1
  447. package/dist/knowledge/adapters/toolbox/supervisor.js +112 -28
  448. package/dist/knowledge/adapters/toolbox/supervisor.js.map +1 -1
  449. package/dist/knowledge/estate-write.d.ts +5 -0
  450. package/dist/knowledge/estate-write.d.ts.map +1 -1
  451. package/dist/knowledge/estate-write.js +7 -0
  452. package/dist/knowledge/estate-write.js.map +1 -1
  453. package/dist/knowledge/gate/gate.d.ts.map +1 -1
  454. package/dist/knowledge/gate/gate.js +4 -1
  455. package/dist/knowledge/gate/gate.js.map +1 -1
  456. package/dist/knowledge/gate/record.d.ts +15 -2
  457. package/dist/knowledge/gate/record.d.ts.map +1 -1
  458. package/dist/knowledge/gate/record.js +108 -29
  459. package/dist/knowledge/gate/record.js.map +1 -1
  460. package/dist/knowledge/projector.d.ts +60 -5
  461. package/dist/knowledge/projector.d.ts.map +1 -1
  462. package/dist/knowledge/projector.js +264 -21
  463. package/dist/knowledge/projector.js.map +1 -1
  464. package/dist/knowledge/registry/entry.d.ts +7 -0
  465. package/dist/knowledge/registry/entry.d.ts.map +1 -1
  466. package/dist/knowledge/registry/entry.js +4 -0
  467. package/dist/knowledge/registry/entry.js.map +1 -1
  468. package/dist/knowledge/shapes/map.d.ts.map +1 -1
  469. package/dist/knowledge/shapes/map.js +12 -2
  470. package/dist/knowledge/shapes/map.js.map +1 -1
  471. package/dist/knowledge/shapes/routes.d.ts +1 -1
  472. package/dist/knowledge/shapes/routes.d.ts.map +1 -1
  473. package/dist/knowledge/shapes/routes.js +42 -16
  474. package/dist/knowledge/shapes/routes.js.map +1 -1
  475. package/dist/knowledge/shapes/shapes.d.ts +60 -13
  476. package/dist/knowledge/shapes/shapes.d.ts.map +1 -1
  477. package/dist/knowledge/shapes/shapes.js +199 -31
  478. package/dist/knowledge/shapes/shapes.js.map +1 -1
  479. package/dist/knowledge/shapes/verified.d.ts.map +1 -1
  480. package/dist/knowledge/shapes/verified.js +3 -2
  481. package/dist/knowledge/shapes/verified.js.map +1 -1
  482. package/dist/knowledge/trackers/addresses.d.ts +27 -3
  483. package/dist/knowledge/trackers/addresses.d.ts.map +1 -1
  484. package/dist/knowledge/trackers/addresses.js +33 -5
  485. package/dist/knowledge/trackers/addresses.js.map +1 -1
  486. package/dist/knowledge/trackers/gate-pm.d.ts.map +1 -1
  487. package/dist/knowledge/trackers/gate-pm.js +4 -2
  488. package/dist/knowledge/trackers/gate-pm.js.map +1 -1
  489. package/dist/knowledge/trackers/projector.d.ts +3 -1
  490. package/dist/knowledge/trackers/projector.d.ts.map +1 -1
  491. package/dist/knowledge/trackers/projector.js +59 -8
  492. package/dist/knowledge/trackers/projector.js.map +1 -1
  493. package/dist/learn/scheduler.d.ts.map +1 -1
  494. package/dist/learn/scheduler.js +13 -3
  495. package/dist/learn/scheduler.js.map +1 -1
  496. package/dist/learnings/estate.d.ts.map +1 -1
  497. package/dist/learnings/estate.js +3 -14
  498. package/dist/learnings/estate.js.map +1 -1
  499. package/dist/learnings/extract.d.ts +9 -3
  500. package/dist/learnings/extract.d.ts.map +1 -1
  501. package/dist/learnings/extract.js +62 -4
  502. package/dist/learnings/extract.js.map +1 -1
  503. package/dist/learnings/replacement-lineage.d.ts +3 -2
  504. package/dist/learnings/replacement-lineage.d.ts.map +1 -1
  505. package/dist/learnings/replacement-lineage.js +7 -6
  506. package/dist/learnings/replacement-lineage.js.map +1 -1
  507. package/dist/learnings/service.d.ts +12 -2
  508. package/dist/learnings/service.d.ts.map +1 -1
  509. package/dist/learnings/service.js +30 -5
  510. package/dist/learnings/service.js.map +1 -1
  511. package/dist/mcp/broker.d.ts.map +1 -1
  512. package/dist/mcp/broker.js +19 -5
  513. package/dist/mcp/broker.js.map +1 -1
  514. package/dist/mcp/env.d.ts +12 -4
  515. package/dist/mcp/env.d.ts.map +1 -1
  516. package/dist/mcp/env.js +24 -4
  517. package/dist/mcp/env.js.map +1 -1
  518. package/dist/mcp/estate-relay.d.ts +3 -0
  519. package/dist/mcp/estate-relay.d.ts.map +1 -1
  520. package/dist/mcp/estate-relay.js +7 -6
  521. package/dist/mcp/estate-relay.js.map +1 -1
  522. package/dist/mcp/invoke.d.ts.map +1 -1
  523. package/dist/mcp/invoke.js +6 -5
  524. package/dist/mcp/invoke.js.map +1 -1
  525. package/dist/mcp/probe.d.ts +14 -1
  526. package/dist/mcp/probe.d.ts.map +1 -1
  527. package/dist/mcp/probe.js +55 -10
  528. package/dist/mcp/probe.js.map +1 -1
  529. package/dist/mcp/redact.d.ts +1 -1
  530. package/dist/mcp/redact.d.ts.map +1 -1
  531. package/dist/mcp/redact.js +61 -4
  532. package/dist/mcp/redact.js.map +1 -1
  533. package/dist/mcp/registry-store.d.ts +37 -0
  534. package/dist/mcp/registry-store.d.ts.map +1 -1
  535. package/dist/mcp/registry-store.js +43 -0
  536. package/dist/mcp/registry-store.js.map +1 -1
  537. package/dist/mcp/registry.d.ts +38 -6
  538. package/dist/mcp/registry.d.ts.map +1 -1
  539. package/dist/mcp/registry.js +145 -14
  540. package/dist/mcp/registry.js.map +1 -1
  541. package/dist/mcp/rest.js +4 -4
  542. package/dist/mcp/rest.js.map +1 -1
  543. package/dist/mcp/run-fence.d.ts +2 -0
  544. package/dist/mcp/run-fence.d.ts.map +1 -1
  545. package/dist/mcp/run-fence.js +9 -0
  546. package/dist/mcp/run-fence.js.map +1 -1
  547. package/dist/mcp/secrets.d.ts +1 -1
  548. package/dist/mcp/secrets.d.ts.map +1 -1
  549. package/dist/mcp/secrets.js +10 -11
  550. package/dist/mcp/secrets.js.map +1 -1
  551. package/dist/mcp/upstream-error.d.ts +6 -2
  552. package/dist/mcp/upstream-error.d.ts.map +1 -1
  553. package/dist/mcp/upstream-error.js +5 -1
  554. package/dist/mcp/upstream-error.js.map +1 -1
  555. package/dist/projects/graph.d.ts +15 -5
  556. package/dist/projects/graph.d.ts.map +1 -1
  557. package/dist/projects/graph.js +354 -26
  558. package/dist/projects/graph.js.map +1 -1
  559. package/dist/projects/repo-watch.d.ts +2 -2
  560. package/dist/projects/repo-watch.d.ts.map +1 -1
  561. package/dist/projects/repo-watch.js +26 -9
  562. package/dist/projects/repo-watch.js.map +1 -1
  563. package/dist/projects/routes.d.ts +9 -1
  564. package/dist/projects/routes.d.ts.map +1 -1
  565. package/dist/projects/routes.js +63 -6
  566. package/dist/projects/routes.js.map +1 -1
  567. package/dist/projects/state-home-preflight.d.ts +5 -0
  568. package/dist/projects/state-home-preflight.d.ts.map +1 -1
  569. package/dist/projects/state-home-preflight.js +48 -8
  570. package/dist/projects/state-home-preflight.js.map +1 -1
  571. package/dist/projects/state-home-registry.d.ts.map +1 -1
  572. package/dist/projects/state-home-registry.js +9 -0
  573. package/dist/projects/state-home-registry.js.map +1 -1
  574. package/dist/projects/state-home.d.ts +11 -0
  575. package/dist/projects/state-home.d.ts.map +1 -1
  576. package/dist/projects/state-home.js +14 -0
  577. package/dist/projects/state-home.js.map +1 -1
  578. package/dist/qe/author-workflow.d.ts +4 -0
  579. package/dist/qe/author-workflow.d.ts.map +1 -1
  580. package/dist/qe/author-workflow.js +4 -0
  581. package/dist/qe/author-workflow.js.map +1 -1
  582. package/dist/qe/test-sets.d.ts +5 -6
  583. package/dist/qe/test-sets.d.ts.map +1 -1
  584. package/dist/qe/test-sets.js +4 -3
  585. package/dist/qe/test-sets.js.map +1 -1
  586. package/dist/schedules/routes.d.ts +5 -0
  587. package/dist/schedules/routes.d.ts.map +1 -1
  588. package/dist/schedules/routes.js +32 -5
  589. package/dist/schedules/routes.js.map +1 -1
  590. package/dist/schedules/scheduler.d.ts +8 -1
  591. package/dist/schedules/scheduler.d.ts.map +1 -1
  592. package/dist/schedules/scheduler.js +10 -1
  593. package/dist/schedules/scheduler.js.map +1 -1
  594. package/dist/schedules/store.d.ts +7 -0
  595. package/dist/schedules/store.d.ts.map +1 -1
  596. package/dist/schedules/store.js +19 -4
  597. package/dist/schedules/store.js.map +1 -1
  598. package/dist/skills/plugin-source.js +4 -4
  599. package/dist/skills/plugin-source.js.map +1 -1
  600. package/dist/sources/ask.d.ts.map +1 -1
  601. package/dist/sources/ask.js +12 -12
  602. package/dist/sources/ask.js.map +1 -1
  603. package/dist/sources/dialer.d.ts +6 -1
  604. package/dist/sources/dialer.d.ts.map +1 -1
  605. package/dist/sources/dialer.js +53 -31
  606. package/dist/sources/dialer.js.map +1 -1
  607. package/dist/sources/drivers/mysql.d.ts +2 -0
  608. package/dist/sources/drivers/mysql.d.ts.map +1 -1
  609. package/dist/sources/drivers/mysql.js +18 -2
  610. package/dist/sources/drivers/mysql.js.map +1 -1
  611. package/dist/sources/drivers/postgres.d.ts +2 -0
  612. package/dist/sources/drivers/postgres.d.ts.map +1 -1
  613. package/dist/sources/drivers/postgres.js +10 -3
  614. package/dist/sources/drivers/postgres.js.map +1 -1
  615. package/dist/sources/drivers/sqlite.d.ts +33 -3
  616. package/dist/sources/drivers/sqlite.d.ts.map +1 -1
  617. package/dist/sources/drivers/sqlite.js +18 -6
  618. package/dist/sources/drivers/sqlite.js.map +1 -1
  619. package/dist/sources/drivers/types.d.ts +3 -1
  620. package/dist/sources/drivers/types.d.ts.map +1 -1
  621. package/dist/sources/drivers/types.js +3 -1
  622. package/dist/sources/drivers/types.js.map +1 -1
  623. package/dist/sources/routes.d.ts.map +1 -1
  624. package/dist/sources/routes.js +1 -0
  625. package/dist/sources/routes.js.map +1 -1
  626. package/dist/sources/uploads.d.ts +22 -15
  627. package/dist/sources/uploads.d.ts.map +1 -1
  628. package/dist/sources/uploads.js +124 -436
  629. package/dist/sources/uploads.js.map +1 -1
  630. package/dist/standing-orders/history.d.ts +5 -3
  631. package/dist/standing-orders/history.d.ts.map +1 -1
  632. package/dist/standing-orders/history.js +6 -2
  633. package/dist/standing-orders/history.js.map +1 -1
  634. package/dist/standing-orders/parse.d.ts +8 -0
  635. package/dist/standing-orders/parse.d.ts.map +1 -1
  636. package/dist/standing-orders/parse.js +52 -5
  637. package/dist/standing-orders/parse.js.map +1 -1
  638. package/dist/studio/apps-standalone/fixture.js +3 -3
  639. package/dist/studio/apps-standalone/runtime.js +1 -1
  640. package/dist/studio/assets/{KnowledgeGraph-DWw0I8RJ.js → KnowledgeGraph-yP4WsnST.js} +1 -1
  641. package/dist/studio/assets/index-DNaLjJ7M.css +32 -0
  642. package/dist/studio/assets/index-DW53FKuT.js +1114 -0
  643. package/dist/studio/editors/wicked-apps/editor.json +1 -1
  644. package/dist/studio/editors/wicked-apps/index.html +2 -2
  645. package/dist/studio/editors/wicked-deck/editor.json +1 -1
  646. package/dist/studio/editors/wicked-deck/index.html +2 -2
  647. package/dist/studio/editors/wicked-doc/editor.json +1 -1
  648. package/dist/studio/editors/wicked-doc/index.html +1 -1
  649. package/dist/studio/editors/wicked-insights/editor.json +1 -1
  650. package/dist/studio/editors/wicked-insights/index.html +1 -1
  651. package/dist/studio/editors/wicked-page/editor.json +1 -1
  652. package/dist/studio/editors/wicked-page/index.html +1 -1
  653. package/dist/studio/editors/wicked-video/editor.json +1 -1
  654. package/dist/studio/editors/wicked-video/index.html +1 -1
  655. package/dist/studio/index.html +2 -2
  656. package/dist/studio/testid-inventory.json +1589 -281
  657. package/dist/team/routes.d.ts +11 -1
  658. package/dist/team/routes.d.ts.map +1 -1
  659. package/dist/team/routes.js +8 -4
  660. package/dist/team/routes.js.map +1 -1
  661. package/dist/voice/tts.d.ts +12 -0
  662. package/dist/voice/tts.d.ts.map +1 -1
  663. package/dist/voice/tts.js +118 -28
  664. package/dist/voice/tts.js.map +1 -1
  665. package/dist/workflow-catalog/build-v2.d.ts +34 -0
  666. package/dist/workflow-catalog/build-v2.d.ts.map +1 -1
  667. package/dist/workflow-catalog/build-v2.js +131 -10
  668. package/dist/workflow-catalog/build-v2.js.map +1 -1
  669. package/dist/workflow-catalog/catalog-data-v2.d.ts +6 -2
  670. package/dist/workflow-catalog/catalog-data-v2.d.ts.map +1 -1
  671. package/dist/workflow-catalog/catalog-data-v2.js.map +1 -1
  672. package/dist/workflow-catalog/catalog-data.d.ts.map +1 -1
  673. package/dist/workflow-catalog/catalog-data.js +0 -2
  674. package/dist/workflow-catalog/catalog-data.js.map +1 -1
  675. package/dist/workflow-catalog/detect.d.ts +18 -3
  676. package/dist/workflow-catalog/detect.d.ts.map +1 -1
  677. package/dist/workflow-catalog/detect.js +43 -8
  678. package/dist/workflow-catalog/detect.js.map +1 -1
  679. package/dist/workflow-catalog/shape.d.ts +1 -1
  680. package/dist/working-doc/event-lines.d.ts +12 -2
  681. package/dist/working-doc/event-lines.d.ts.map +1 -1
  682. package/dist/working-doc/event-lines.js +62 -10
  683. package/dist/working-doc/event-lines.js.map +1 -1
  684. package/dist/working-doc/sections.d.ts +3 -0
  685. package/dist/working-doc/sections.d.ts.map +1 -1
  686. package/dist/working-doc/sections.js +5 -0
  687. package/dist/working-doc/sections.js.map +1 -1
  688. package/dist/working-doc/service.d.ts +23 -3
  689. package/dist/working-doc/service.d.ts.map +1 -1
  690. package/dist/working-doc/service.js +93 -54
  691. package/dist/working-doc/service.js.map +1 -1
  692. package/endpoint-manifest.json +148 -8
  693. package/evals/corpora/shape-v1.json +25 -1
  694. package/evals/corpora/shape-v1.seat-fixture.json +25 -1
  695. package/package.json +4 -4
  696. package/runners/sqlite-runner.mjs +67 -12
  697. package/runners/upload-parse.d.mts +13 -0
  698. package/runners/upload-parse.mjs +364 -0
  699. package/dist/studio/assets/index-C4Xj-zxa.css +0 -32
  700. package/dist/studio/assets/index-CrNY3d06.js +0 -1109
@@ -56364,18 +56364,20 @@ import { lookup as dnsLookup } from "node:dns/promises";
56364
56364
  import { request as httpRequest } from "node:http";
56365
56365
  import { request as httpsRequest } from "node:https";
56366
56366
  import { connect as netConnect, isIP } from "node:net";
56367
- import { pipeline, Readable } from "node:stream";
56367
+ import { pipeline, Readable, Transform } from "node:stream";
56368
56368
  import { constants as zlibConstants, createBrotliDecompress, createGunzip, createInflate, createInflateRaw } from "node:zlib";
56369
56369
 
56370
56370
  // src/mcp/upstream-error.ts
56371
56371
  var UpstreamCallError = class extends Error {
56372
- constructor(errorClass, retryable, message) {
56372
+ constructor(errorClass, retryable, message, status) {
56373
56373
  super(message);
56374
56374
  this.errorClass = errorClass;
56375
56375
  this.retryable = retryable;
56376
+ this.status = status;
56376
56377
  }
56377
56378
  errorClass;
56378
56379
  retryable;
56380
+ status;
56379
56381
  };
56380
56382
 
56381
56383
  // src/sources/dialer.ts
@@ -56531,12 +56533,20 @@ function plaintextAllowed(cls, policy2) {
56531
56533
  return cls === "loopback" || cls === "private" && policy2.plaintext;
56532
56534
  }
56533
56535
  var DialRefusedError = class extends UpstreamCallError {
56534
- constructor(code, message) {
56536
+ constructor(code, message, addresses, suggest) {
56535
56537
  super("boundary", false, message);
56536
56538
  this.code = code;
56539
+ this.addresses = addresses;
56540
+ this.suggest = suggest;
56537
56541
  this.name = "DialRefusedError";
56538
56542
  }
56539
56543
  code;
56544
+ addresses;
56545
+ suggest;
56546
+ /** Structured confirmation data travels with the refusal, so callers need not parse its words. */
56547
+ get detail() {
56548
+ return { ...this.addresses !== void 0 ? { addresses: this.addresses } : {}, ...this.suggest !== void 0 ? { suggest: this.suggest } : {} };
56549
+ }
56540
56550
  };
56541
56551
  var DialRedirectRefusedError = class extends DialRefusedError {
56542
56552
  constructor(status, location, message) {
@@ -56596,13 +56606,16 @@ async function resolveTarget(host, policy2, resolver = systemResolver, signal) {
56596
56606
  if (signal !== void 0 && isAborted(signal)) throw abortError(signal);
56597
56607
  if (answers.length === 0) throw new DialRefusedError("unresolved", `${hostname4} did not resolve, so crew could not check where it goes`);
56598
56608
  const checked = answers.map((a) => classifyAddress(a));
56609
+ const unconfirmed = checked.filter((c) => (c.cls === "loopback" || c.cls === "private") && !confirmed(c, policy2));
56599
56610
  for (const c of checked) {
56600
56611
  const named2 = literal2 ? c.address : `${hostname4} (${c.address})`;
56601
56612
  if (c.cls === "refused") throw new DialRefusedError("address_refused", `${named2} is refused: ${c.why ?? "not allowed"}; crew never connects there`);
56602
56613
  if ((c.cls === "loopback" || c.cls === "private") && !confirmed(c, policy2)) {
56603
56614
  throw new DialRefusedError(
56604
56615
  "address_unconfirmed",
56605
- `${named2} is a ${c.cls} address, which a source reaches only when the person confirms a range covering it for that source (e.g. ${suggestRange(c)})`
56616
+ `${named2} is a ${c.cls} address, which a source reaches only when the person confirms a range covering it for that source (e.g. ${suggestRange(c)})`,
56617
+ unconfirmed.map((a) => ({ address: a.address, class: a.cls })),
56618
+ unconfirmed.map(suggestRange)
56606
56619
  );
56607
56620
  }
56608
56621
  }
@@ -56689,29 +56702,38 @@ function bodyBytes(body) {
56689
56702
  var NULL_BODY_STATUSES = /* @__PURE__ */ new Set([204, 205, 304]);
56690
56703
  var ZLIB_LENIENT = { flush: zlibConstants.Z_SYNC_FLUSH, finishFlush: zlibConstants.Z_SYNC_FLUSH };
56691
56704
  var MAX_CODINGS = 5;
56692
- async function peekFirstByte(src) {
56693
- for (; ; ) {
56694
- const chunk = src.read();
56695
- if (chunk !== null) {
56696
- src.unshift(chunk);
56697
- return chunk[0] ?? null;
56698
- }
56699
- if (src.readableEnded || src.destroyed) return null;
56700
- await new Promise((resolve4) => {
56701
- const done = () => {
56702
- src.off("readable", done);
56703
- src.off("end", done);
56704
- src.off("error", done);
56705
- src.off("close", done);
56706
- resolve4();
56707
- };
56708
- src.on("readable", done);
56709
- src.on("end", done);
56710
- src.on("error", done);
56711
- src.on("close", done);
56712
- });
56705
+ var DeflateDecoder = class extends Transform {
56706
+ inflater = null;
56707
+ flushed = null;
56708
+ _transform(chunk, encoding, callback) {
56709
+ if (this.inflater === null) {
56710
+ if (chunk.length === 0) return callback();
56711
+ this.inflater = (chunk[0] & 15) !== 8 ? createInflateRaw(ZLIB_LENIENT) : createInflate(ZLIB_LENIENT);
56712
+ this.inflater.on("data", (data) => {
56713
+ if (!this.push(data)) this.inflater.pause();
56714
+ });
56715
+ this.inflater.once("error", (err) => this.destroy(err));
56716
+ this.inflater.once("end", () => {
56717
+ this.flushed?.();
56718
+ this.flushed = null;
56719
+ });
56720
+ }
56721
+ this.inflater.write(chunk, encoding, callback);
56713
56722
  }
56714
- }
56723
+ _read(size2) {
56724
+ this.inflater?.resume();
56725
+ super._read(size2);
56726
+ }
56727
+ _flush(callback) {
56728
+ if (this.inflater === null) return callback();
56729
+ this.flushed = callback;
56730
+ this.inflater.end();
56731
+ }
56732
+ _destroy(err, callback) {
56733
+ this.inflater?.destroy();
56734
+ callback(err);
56735
+ }
56736
+ };
56715
56737
  async function decoded(res) {
56716
56738
  const codings = String(res.headers["content-encoding"] ?? "").split(",").map((c) => c.trim().toLowerCase()).filter((c) => c !== "" && c !== "identity").reverse();
56717
56739
  if (codings.length === 0) return { stream: res, encoded: false };
@@ -56722,10 +56744,7 @@ async function decoded(res) {
56722
56744
  let decoder;
56723
56745
  if (c === "gzip" || c === "x-gzip") decoder = createGunzip(ZLIB_LENIENT);
56724
56746
  else if (c === "br") decoder = createBrotliDecompress({ flush: zlibConstants.BROTLI_OPERATION_FLUSH, finishFlush: zlibConstants.BROTLI_OPERATION_FLUSH });
56725
- else {
56726
- const first = await peekFirstByte(current);
56727
- decoder = first !== null && (first & 15) !== 8 ? createInflateRaw(ZLIB_LENIENT) : createInflate(ZLIB_LENIENT);
56728
- }
56747
+ else decoder = new DeflateDecoder();
56729
56748
  pipeline(current, decoder, () => void 0);
56730
56749
  current = decoder;
56731
56750
  }
@@ -57095,6 +57114,18 @@ var APP_QUERY_PATH = new RegExp(`^${API_PREFIX}/apps/[^/]+/query$`);
57095
57114
  var PROJECT_DETAIL_PATH = new RegExp(`^${API_PREFIX}/projects/[^/]+$`);
57096
57115
  var SOURCE_MANAGEMENT_READ = new RegExp(`^${API_PREFIX}/sources/[^/]+/(?:catalog|describe|privileges|check|safety|test)$`);
57097
57116
  var SOURCE_MANAGEMENT_ROUTES = new Set(["catalog", "describe", "privileges", "check", "safety", "test"].map((r) => `${API_PREFIX}/sources/:name/${r}`));
57117
+ var HUMAN_ONLY_RULES = [
57118
+ {
57119
+ routes: SOURCE_MANAGEMENT_ROUTES,
57120
+ path: SOURCE_MANAGEMENT_READ,
57121
+ reason: "a source's management reads are a human operator's only"
57122
+ },
57123
+ {
57124
+ routes: /* @__PURE__ */ new Set([`${API_PREFIX}/terminals`, `${API_PREFIX}/terminals/:id/resize`, `${API_PREFIX}/terminals/:id/close`, "/ws/terminals/:id"]),
57125
+ path: new RegExp(`^(?:${API_PREFIX}/terminals|/ws/terminals)(?:/|$)`),
57126
+ reason: "a terminal runs programs on the daemon host: a human operator's only"
57127
+ }
57128
+ ];
57098
57129
  var UNIT_TOKEN_ROUTES = /* @__PURE__ */ new Set([
57099
57130
  `POST ${API_PREFIX}/mcp/call`,
57100
57131
  `POST ${API_PREFIX}/mcp/tools`,
@@ -59294,16 +59325,18 @@ function approxRowBytes(row) {
59294
59325
  }
59295
59326
  var READ_MAX_ROWS = 5e3;
59296
59327
  var SourceQueryError = class extends Error {
59297
- constructor(sqlstate, errorClass, message, refusal = null) {
59328
+ constructor(sqlstate, errorClass, message, refusal = null, detail = {}) {
59298
59329
  super(message);
59299
59330
  this.sqlstate = sqlstate;
59300
59331
  this.errorClass = errorClass;
59301
59332
  this.refusal = refusal;
59333
+ this.detail = detail;
59302
59334
  this.name = "SourceQueryError";
59303
59335
  }
59304
59336
  sqlstate;
59305
59337
  errorClass;
59306
59338
  refusal;
59339
+ detail;
59307
59340
  };
59308
59341
 
59309
59342
  // src/sources/drivers/postgres.ts
@@ -59352,9 +59385,11 @@ function pgClient(args, opts = {}) {
59352
59385
  max: 1,
59353
59386
  prepare: false,
59354
59387
  fetch_types: false,
59355
- idle_timeout: 5,
59388
+ // Hand-run transactions own this client for one call and close it in finally. Pool timers
59389
+ // must not end an idle transaction and dispatch its next statement on another connection.
59390
+ idle_timeout: opts.onclose !== void 0 ? 0 : 5,
59356
59391
  connect_timeout: 10,
59357
- max_lifetime: 60,
59392
+ max_lifetime: opts.onclose !== void 0 ? 0 : 60,
59358
59393
  onnotice: () => void 0,
59359
59394
  ...opts.onclose !== void 0 ? { onclose: opts.onclose } : {},
59360
59395
  connection: params,
@@ -59388,7 +59423,7 @@ function pgClient(args, opts = {}) {
59388
59423
  }
59389
59424
  function pgError(err) {
59390
59425
  if (err instanceof SourceQueryError) return err;
59391
- if (err instanceof DialRefusedError) return new SourceQueryError(null, "refused", err.message, err.code);
59426
+ if (err instanceof DialRefusedError) return new SourceQueryError(null, "refused", err.message, err.code, err.detail);
59392
59427
  const e = err;
59393
59428
  const code = typeof e?.code === "string" ? e.code : null;
59394
59429
  const message = typeof e?.message === "string" ? e.message : String(err);
@@ -59518,6 +59553,7 @@ async function pgRead(args, text2, params, opts = {}) {
59518
59553
  await tx.unsafe(`SET LOCAL work_mem = '${AGENT_WORK_MEM}'`);
59519
59554
  }
59520
59555
  if (opts.expect !== void 0) await pgExpectRelations(tx, opts.expect);
59556
+ await opts.afterExpect?.();
59521
59557
  let run = text2;
59522
59558
  let described = null;
59523
59559
  if (opts.shape !== void 0) {
@@ -59546,6 +59582,7 @@ async function pgRead(args, text2, params, opts = {}) {
59546
59582
  }
59547
59583
  return void 0;
59548
59584
  });
59585
+ if (opts.expect !== void 0) await pgExpectRelations(tx, opts.expect);
59549
59586
  if (columns.length === 0) columns = query.statement?.columns ?? [];
59550
59587
  if (described !== null) return { columns: described, rows, truncated };
59551
59588
  const names = await typeNames(tx, [...new Set(columns.map((c) => c.type))]);
@@ -59821,7 +59858,7 @@ async function connectOn(args, stream, address, deadlineMs) {
59821
59858
  }
59822
59859
  function mysqlError(err) {
59823
59860
  if (err instanceof SourceQueryError) return err;
59824
- if (err instanceof DialRefusedError) return new SourceQueryError(null, "refused", err.message, err.code);
59861
+ if (err instanceof DialRefusedError) return new SourceQueryError(null, "refused", err.message, err.code, err.detail);
59825
59862
  const e = err;
59826
59863
  const message = typeof e?.message === "string" ? e.message : String(err);
59827
59864
  const sqlstate = typeof e?.sqlState === "string" ? e.sqlState : null;
@@ -59911,8 +59948,11 @@ async function mysqlRead(args, text2, params, opts = {}) {
59911
59948
  const guard = setTimeout(() => void kill(), Math.max(1, deadlineMs - (Date.now() - started)));
59912
59949
  opts.signal?.addEventListener("abort", () => void kill(), { once: true });
59913
59950
  const work = (async () => {
59951
+ await conn.query("SET TRANSACTION ISOLATION LEVEL READ COMMITTED");
59914
59952
  await conn.query("START TRANSACTION READ ONLY");
59915
59953
  if (opts.expect !== void 0) await mysqlExpectRelations(conn, opts.expect);
59954
+ await opts.afterExpect?.();
59955
+ let capStop;
59916
59956
  const core = conn.connection;
59917
59957
  const streamed = new Promise((resolve4, reject) => {
59918
59958
  const rows2 = [];
@@ -59927,7 +59967,7 @@ async function mysqlRead(args, text2, params, opts = {}) {
59927
59967
  if (rows2.length >= maxRows || opts.maxBytes !== void 0 && bytes >= opts.maxBytes) {
59928
59968
  if (!truncated2) {
59929
59969
  truncated2 = true;
59930
- void kill();
59970
+ capStop = kill();
59931
59971
  }
59932
59972
  return;
59933
59973
  }
@@ -59938,6 +59978,8 @@ async function mysqlRead(args, text2, params, opts = {}) {
59938
59978
  q.on("end", () => resolve4({ rows: rows2, fields: fields2, truncated: truncated2 }));
59939
59979
  });
59940
59980
  const { rows, fields, truncated } = await streamed;
59981
+ await capStop;
59982
+ if (opts.expect !== void 0) await mysqlExpectRelations(conn, opts.expect);
59941
59983
  if (!truncated) await conn.query("COMMIT");
59942
59984
  return {
59943
59985
  columns: (fields ?? []).map((f) => ({ name: f.name, type: typeName(f) })),
@@ -60579,6 +60621,7 @@ function sqliteCteHint(text2) {
60579
60621
 
60580
60622
  // src/sources/drivers/sqlite.ts
60581
60623
  var RUNNER_PATH = fileURLToPath(new URL("../../../runners/sqlite-runner.mjs", import.meta.url));
60624
+ var RUNNER_FAILED = "the SQLite runner failed";
60582
60625
  var ANSWER_MAX_BYTES = 64 * 1024 * 1024;
60583
60626
  var onSpawnForTests = null;
60584
60627
  function runnerEnv(boot) {
@@ -60625,7 +60668,7 @@ async function runChild(request, deadlineMs, signal) {
60625
60668
  try {
60626
60669
  finish(null, JSON.parse(stdout + decoder.end()));
60627
60670
  } catch {
60628
- finish(new SourceQueryError(null, "source", `the SQLite runner failed${stderr === "" ? "" : `: ${stderr.trim()}`}`));
60671
+ finish(new SourceQueryError(null, "source", `${RUNNER_FAILED}${stderr === "" ? "" : `: ${stderr.trim()}`}`));
60629
60672
  }
60630
60673
  });
60631
60674
  child.stdin.end(JSON.stringify(request));
@@ -60672,6 +60715,14 @@ async function sqliteRead(path, catalog, text2, params, opts = {}) {
60672
60715
  // src/sources/graphql.ts
60673
60716
  var import_graphql = __toESM(require_graphql2(), 1);
60674
60717
 
60718
+ // src/core/exec.ts
60719
+ import { execFile } from "node:child_process";
60720
+ import { promisify } from "node:util";
60721
+ var execFileAsync = promisify(execFile);
60722
+ var ADO_RAW_ENV = ["AZURE_DEVOPS_EXT_PAT", "CREW_ADO_TENANT_ID", "CREW_ADO_CLIENT_ID", "CREW_ADO_CLIENT_SECRET"];
60723
+ var FSMONITOR_OFF_PARAMETER = "'core.fsmonitor=false'";
60724
+ var EXEC_MAX_BUFFER_BYTES = 64 * 1024 * 1024;
60725
+
60675
60726
  // src/core/ado-deliver-helper.ts
60676
60727
  var ADO_HELPER_JS = String.raw`
60677
60728
  const [, , cmd, ...args] = process.argv;
@@ -60804,6 +60855,29 @@ async function view(loginBase, apiBase, webUrl, id) {
60804
60855
  const head = typeof p.sourceRefName === 'string' && p.sourceRefName.startsWith('refs/heads/') ? p.sourceRefName.slice('refs/heads/'.length) : null;
60805
60856
  process.stdout.write(JSON.stringify({ headRefName: head, state: prState(p), isCrossRepository: Boolean(p.forkSource), url: webUrl + '/pullrequest/' + p.pullRequestId }) + '\n');
60806
60857
  }
60858
+ // (crew#1838) Launch time: an Azure Boards work item the intent names (AB#<id>), read with the daemon's own
60859
+ // credential (the header is minted here, as 'view' does). Prints the fields a reader needs as JSON; the description and
60860
+ // the comments stay HTML (the daemon turns them into text). Comments are read only when the item says it has some.
60861
+ async function workitem(loginBase, projectBase, id) {
60862
+ if (!/^[0-9]+$/.test(String(id))) fail('not a work item id: ' + String(id).slice(0, 40));
60863
+ const auth = await header(loginBase);
60864
+ const base = projectBase.replace(/\/+$/, '') + '/_apis/wit/workitems/' + id;
60865
+ const r = await call(base + '?$expand=all&' + API, { method: 'GET', headers: { Authorization: auth, Accept: 'application/json' } });
60866
+ if (r.status === 401 || r.status === 403 || r.status === 203) fail('Azure DevOps refused the daemon\'s credential for work item ' + id + ' (HTTP ' + r.status + ')', 5);
60867
+ if (r.status === 404) fail('Azure DevOps has no work item ' + id + ' in this project, or the credential cannot see it (HTTP 404)', 6);
60868
+ if (!r.ok || !r.json || typeof r.json.id !== 'number' || !r.json.fields) fail('Azure DevOps could not read work item ' + id + ' (HTTP ' + r.status + ')');
60869
+ const f = r.json.fields;
60870
+ const s = (x) => (typeof x === 'string' ? x : '');
60871
+ const html = r.json._links && r.json._links.html && typeof r.json._links.html.href === 'string' ? r.json._links.html.href : '';
60872
+ const out = { id: r.json.id, title: s(f['System.Title']), state: s(f['System.State']), type: s(f['System.WorkItemType']), description: s(f['System.Description']), reproSteps: s(f['Microsoft.VSTS.TCM.ReproSteps']), url: /^https:\/\//.test(html) ? html : '', comments: [], commentsRead: true };
60873
+ if (typeof f['System.CommentCount'] === 'number' && f['System.CommentCount'] > 0) {
60874
+ const c = await call(base.replace('/_apis/wit/workitems/', '/_apis/wit/workItems/') + '/comments?api-version=7.1-preview.4', { method: 'GET', headers: { Authorization: auth, Accept: 'application/json' } });
60875
+ const list = c.ok && c.json && Array.isArray(c.json.comments) ? c.json.comments : null;
60876
+ if (list === null) out.commentsRead = false;
60877
+ else out.comments = list.map((x) => ({ author: x && x.createdBy && typeof x.createdBy.displayName === 'string' ? x.createdBy.displayName : 'unknown', text: x && typeof x.text === 'string' ? x.text : '' }));
60878
+ }
60879
+ process.stdout.write(JSON.stringify(out) + '\n');
60880
+ }
60807
60881
  async function state(apiBase, id) {
60808
60882
  const auth = env.WICKED_ADO_AUTH || '';
60809
60883
  if (!auth) fail('no Azure DevOps auth header was handed to the state step');
@@ -60824,6 +60898,7 @@ async function comment(apiBase, id, bodyFile) {
60824
60898
  (async () => {
60825
60899
  if (cmd === 'header') process.stdout.write((await header(args[0])) + '\n');
60826
60900
  else if (cmd === 'view') await view(...args);
60901
+ else if (cmd === 'workitem') await workitem(...args);
60827
60902
  else if (cmd === 'state') await state(...args);
60828
60903
  else if (cmd === 'comment') await comment(...args);
60829
60904
  else if (cmd === 'same') {
@@ -60835,6 +60910,33 @@ async function comment(apiBase, id, bodyFile) {
60835
60910
  })().catch((e) => fail(e && e.message ? e.message : String(e)));
60836
60911
  `;
60837
60912
 
60913
+ // src/mcp/redact.ts
60914
+ var REDACTED = (reason) => `[REDACTED:${reason}]`;
60915
+ var VALUE_PATTERNS = [
60916
+ { id: "bearer", re: /\bBearer\s+[A-Za-z0-9._~+/=-]{8,}/g },
60917
+ { id: "basic-auth", re: /\bBasic\s+[A-Za-z0-9+/=]{8,}/g },
60918
+ { id: "jwt", re: /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]{4,}\b/g },
60919
+ { id: "aws-access-key", re: /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g },
60920
+ { id: "github-token", re: /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}\b/g },
60921
+ { id: "github-pat", re: /\bgithub_pat_[A-Za-z0-9_]{20,}\b/g },
60922
+ { id: "openai-key", re: /\bsk-[A-Za-z0-9_-]{16,}\b/g },
60923
+ { id: "slack-token", re: /\bxox[abprs]-[A-Za-z0-9-]{10,}\b/g },
60924
+ {
60925
+ id: "kv-secret",
60926
+ re: /\b(token|secret|password|passwd|pwd|api[-_]?key|apikey|access[-_]?key|auth)=([^&\s"']{4,})/gi,
60927
+ replace: (_m, k) => `${k}=${REDACTED("kv")}`
60928
+ },
60929
+ { id: "private-key-block", re: /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g }
60930
+ ];
60931
+ var ESCAPE_BOUNDARY = String.raw`(?:\b|(?<=\\[nrtbf]))`;
60932
+ function overJsonText(re) {
60933
+ return re.source.startsWith(String.raw`\b`) ? new RegExp(ESCAPE_BOUNDARY + re.source.slice(2), re.flags) : re;
60934
+ }
60935
+ var JSON_TEXT_PATTERNS = VALUE_PATTERNS.map((p) => ({
60936
+ ...p,
60937
+ re: overJsonText(p.id === "kv-secret" ? /\b(token|secret|password|passwd|pwd|api[-_]?key|apikey|access[-_]?key|auth)=((?:[^&\s"'\\]|\\[^"\s]){4,})/gi : p.re)
60938
+ }));
60939
+
60838
60940
  // src/api/ui-text.ts
60839
60941
  var PATH_START = String.raw`(?<![\w.\\-])`;
60840
60942
  var SEP = String.raw`(?:\\\\|\\\/|[\\/])`;
@@ -60868,9 +60970,9 @@ function gh(args) {
60868
60970
  });
60869
60971
  }
60870
60972
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
60871
- // One read of the required checks: { rows } or { error }.
60872
- async function read() {
60873
- const r = await gh(['pr', 'checks', url, '--required', '--json', 'name,bucket,link,workflow']);
60973
+ // One read of the required checks (all PR checks in own mode): { rows } or { error }.
60974
+ async function read(own) {
60975
+ const r = await gh(['pr', 'checks', url, ...(own ? [] : ['--required']), '--json', 'name,bucket,link,workflow']);
60874
60976
  const text = r.stdout.trim();
60875
60977
  if (text !== '') {
60876
60978
  try {
@@ -60880,9 +60982,18 @@ async function read() {
60880
60982
  }
60881
60983
  // gh answers a PR with no required checks on stderr (older versions, exit 1) or with an empty list.
60882
60984
  if (/no required checks reported/i.test(r.stderr)) return { rows: [] };
60985
+ if (own && /no checks reported/i.test(r.stderr)) return { rows: [] };
60883
60986
  return { error: redact((r.spawnError || r.stderr || r.stdout || 'gh answered nothing') .trim().split('\n').slice(-3).join(' | ')).slice(0, 300) };
60884
60987
  }
60885
- // The contexts the base branch requires: { names } or { error }. Rulesets must read; classic protection is best-effort.
60988
+ function planGated(r) {
60989
+ if (r.code === 0) return false;
60990
+ let body;
60991
+ try { body = JSON.parse(r.stdout); } catch { return false; }
60992
+ return body !== null && typeof body === 'object' && !Array.isArray(body)
60993
+ && (body.status === '403' || body.status === 403) && typeof body.message === 'string'
60994
+ && body.message.trim() === 'Upgrade to GitHub Pro or make this repository public to enable this feature.';
60995
+ }
60996
+ // The contexts the base branch requires: { names, own } or { error }. Only a plan-gated read declares no contexts.
60886
60997
  async function expected() {
60887
60998
  const m = /^https:\/\/([^/]+)\/([^/]+\/[^/]+)\/pull\/\d+$/.exec(url);
60888
60999
  const repo = m[2];
@@ -60892,22 +61003,24 @@ async function expected() {
60892
61003
  if (base.code !== 0 || branch === '') return { error: redact((base.stderr || 'no base branch').trim().split('\n').slice(-1)[0]).slice(0, 200) };
60893
61004
  const names = new Set();
60894
61005
  const rules = await gh(['api', 'repos/' + repo + '/rules/branches/' + encodeURIComponent(branch).replace(/%2F/g, '/'), '--hostname', host]);
61006
+ const rulesOwn = planGated(rules);
60895
61007
  let parsed;
60896
- try { parsed = JSON.parse(rules.stdout); } catch {}
60897
- if (rules.code !== 0 || !Array.isArray(parsed)) return { error: 'the base branch rules could not be read: ' + redact((rules.stderr || rules.stdout || 'empty').trim().split('\n').slice(-1)[0]).slice(0, 200) };
61008
+ try { parsed = rulesOwn ? [] : JSON.parse(rules.stdout); } catch {}
61009
+ if ((rules.code !== 0 && !rulesOwn) || !Array.isArray(parsed)) return { error: 'the base branch rules could not be read: ' + redact((rules.stderr || rules.stdout || 'empty').trim().split('\n').slice(-1)[0]).slice(0, 200) };
60898
61010
  for (const rule of parsed) if (rule && rule.type === 'required_status_checks') for (const c of (rule.parameters && rule.parameters.required_status_checks) || []) if (c && c.context) names.add(c.context);
60899
61011
  // Classic branch protection, from the branch itself (readable with repo read access; its own endpoint needs admin).
60900
61012
  const classic = await gh(['api', 'repos/' + repo + '/branches/' + encodeURIComponent(branch).replace(/%2F/g, '/'), '--hostname', host]);
60901
- if (classic.code !== 0) return { error: 'the base branch protection could not be read: ' + redact((classic.stderr || 'empty').trim().split('\n').slice(-1)[0]).slice(0, 200) };
61013
+ const classicOwn = planGated(classic);
61014
+ if (classic.code !== 0 && !classicOwn) return { error: 'the base branch protection could not be read: ' + redact((classic.stderr || 'empty').trim().split('\n').slice(-1)[0]).slice(0, 200) };
60902
61015
  // A branch answer that is not the branch object is unreadable, never "nothing required".
60903
61016
  let branchInfo;
60904
- try { branchInfo = JSON.parse(classic.stdout); } catch {}
61017
+ try { branchInfo = classicOwn ? {} : JSON.parse(classic.stdout); } catch {}
60905
61018
  if (branchInfo === null || typeof branchInfo !== 'object' || Array.isArray(branchInfo)) return { error: 'the base branch protection could not be read: the answer is not a branch' };
60906
61019
  // An unprotected branch has no protection key or a null required_status_checks; both mean none.
60907
61020
  const rsc = branchInfo.protection && branchInfo.protection.required_status_checks;
60908
61021
  for (const c of (rsc && rsc.contexts) || []) names.add(c);
60909
61022
  for (const c of (rsc && rsc.checks) || []) if (c && c.context) names.add(c.context);
60910
- return { names: [...names] };
61023
+ return { names: [...names], own: rulesOwn || classicOwn };
60911
61024
  }
60912
61025
  function label(row) { return (row.workflow ? row.workflow + ' / ' : '') + row.name; }
60913
61026
  async function failedLog(row) {
@@ -60925,8 +61038,12 @@ async function main() {
60925
61038
  let last = [];
60926
61039
  let want = null;
60927
61040
  for (;;) {
60928
- let got = want === null ? await expected() : { names: want };
60929
- if (got.error === undefined) { want = got.names; got = await read(); }
61041
+ let got = want === null ? await expected() : want;
61042
+ if (got.error === undefined) {
61043
+ if (want === null && got.own) process.stdout.write("deliver: PR checks: branch rules are not available on this repository's plan; judged by the PR's own checks\n");
61044
+ want = got;
61045
+ got = await read(want.own);
61046
+ }
60930
61047
  const elapsed = Date.now() - start;
60931
61048
  if (got.error !== undefined) {
60932
61049
  unreadable += 1;
@@ -60943,9 +61060,12 @@ async function main() {
60943
61060
  process.exit(3);
60944
61061
  }
60945
61062
  const reported = new Set(last.map((r) => r.name));
60946
- const late = want.filter((n) => !reported.has(n));
61063
+ const late = want.names.filter((n) => !reported.has(n));
60947
61064
  const pending = last.filter((r) => r.bucket !== 'pass' && r.bucket !== 'skipping').map(label).concat(late.map((n) => n + ' (not reported yet)'));
60948
- if (pending.length === 0) { process.stdout.write('deliver: PR checks: ' + (want.length === 0 && last.length === 0 ? 'the base branch requires no status check' : last.length + ' required check(s) green') + '\n'); process.exit(0); }
61065
+ if (pending.length === 0) {
61066
+ const pass = want.own ? (last.length === 0 ? 'the PR has no checks' : last.length + ' check(s) green') : (want.names.length === 0 && last.length === 0 ? 'the base branch requires no status check' : last.length + ' required check(s) green');
61067
+ process.stdout.write('deliver: PR checks: ' + pass + '\n'); process.exit(0);
61068
+ }
60949
61069
  if (elapsed + pollMs >= timeoutMs) { process.stdout.write('deliver: PR checks: still pending after ' + Math.round(elapsed / 1000) + 's: ' + pending.join(', ') + '\n'); process.exit(4); }
60950
61070
  }
60951
61071
  await sleep(pollMs);
@@ -60970,6 +61090,9 @@ var HOME_SLUG_SEGMENT = new RegExp(HOME_SLUG_SEGMENT_ERE);
60970
61090
 
60971
61091
  // src/knowledge/registry/entry.ts
60972
61092
  var AGENT_ACCESS_DEFAULT = Object.freeze({ see: true, query: false, projects: [], everyProject: false });
61093
+ function effectiveReadAccepted(t) {
61094
+ return t.schemaHash !== null && t.readAccepted?.schemaHash === t.schemaHash;
61095
+ }
60973
61096
 
60974
61097
  // src/knowledge/gate/access.ts
60975
61098
  function agentMay(access, src, projectId, what) {
@@ -82847,7 +82970,7 @@ async function probeRestServer(config2, secret, dial = {}) {
82847
82970
  return scrubSecrets({ ok: true, serverInfo: imported.serverInfo, tools: imported.tools, skipped: imported.skipped, egress }, secrets);
82848
82971
  } catch (err) {
82849
82972
  const message = err instanceof Error ? err.message : String(err);
82850
- return scrubSecrets({ ok: false, error: message, ...err instanceof DialRefusedError ? { refusal: err.code } : {} }, secrets);
82973
+ return scrubSecrets({ ok: false, error: message, ...err instanceof DialRefusedError ? { refusal: err.code, detail: err.detail } : {} }, secrets);
82851
82974
  }
82852
82975
  }
82853
82976
  function scalar(v, what) {
@@ -82927,18 +83050,18 @@ function refuseRedirect(config2, url2, status, location) {
82927
83050
  const base2 = parseBaseUrl(config2.url);
82928
83051
  const escape3 = target !== null && base2 !== null ? boundaryEscape(base2, target) : null;
82929
83052
  if (escape3 !== null) throw new RestBoundaryError(`the API redirected off its pin (${escape3}); not followed`);
82930
- throw new UpstreamCallError("http", false, `the API answered HTTP ${status} (a redirect); redirects are not followed`);
83053
+ throw new UpstreamCallError("http", false, `the API answered HTTP ${status} (a redirect); redirects are not followed`, status);
82931
83054
  }
82932
83055
  async function readRestResult(res, droppedArgs) {
82933
83056
  if (res.status === 429 || res.status >= 500) {
82934
83057
  await res.body?.cancel().catch(() => void 0);
82935
- throw new UpstreamCallError("http", true, `the API answered HTTP ${res.status}`);
83058
+ throw new UpstreamCallError("http", true, `the API answered HTTP ${res.status}`, res.status);
82936
83059
  }
82937
83060
  let read;
82938
83061
  try {
82939
83062
  read = await readCapped(res, REST_RESPONSE_MAX_BYTES);
82940
83063
  } catch (err) {
82941
- if (res.status >= 400) throw new UpstreamCallError("http", false, `the API answered HTTP ${res.status} (its body could not be read)`);
83064
+ if (res.status >= 400) throw new UpstreamCallError("http", false, `the API answered HTTP ${res.status} (its body could not be read)`, res.status);
82942
83065
  throw new UpstreamCallError("transport", true, `reading the response failed: ${err instanceof Error ? err.message : String(err)}`);
82943
83066
  }
82944
83067
  let structured;
@@ -82961,15 +83084,17 @@ async function readRestResult(res, droppedArgs) {
82961
83084
  // src/mcp/registry.ts
82962
83085
  var PREVIEW_TTL_MS = 15 * 60 * 1e3;
82963
83086
  var McpRegistryError = class extends Error {
82964
- constructor(status, code, message, humanMessage) {
83087
+ constructor(status, code, message, humanMessage, detail = {}) {
82965
83088
  super(message);
82966
83089
  this.status = status;
82967
83090
  this.code = code;
82968
83091
  this.humanMessage = humanMessage;
83092
+ this.detail = detail;
82969
83093
  }
82970
83094
  status;
82971
83095
  code;
82972
83096
  humanMessage;
83097
+ detail;
82973
83098
  };
82974
83099
 
82975
83100
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
@@ -84928,8 +85053,8 @@ async function random(size2) {
84928
85053
  const evenDistCutoff = Math.pow(2, 8) - Math.pow(2, 8) % mask.length;
84929
85054
  let result = "";
84930
85055
  while (result.length < size2) {
84931
- const randomBytes3 = await getRandomValues(size2 - result.length);
84932
- for (const randomByte of randomBytes3) {
85056
+ const randomBytes2 = await getRandomValues(size2 - result.length);
85057
+ for (const randomByte of randomBytes2) {
84933
85058
  if (randomByte < evenDistCutoff) {
84934
85059
  result += mask[randomByte % mask.length];
84935
85060
  }
@@ -86430,6 +86555,23 @@ var StreamableHTTPClientTransport = class {
86430
86555
  };
86431
86556
 
86432
86557
  // src/mcp/probe.ts
86558
+ var MCP_RESPONSE_MAX_BYTES = 10 * 1024 * 1024;
86559
+ var ResponseBound = class {
86560
+ tripped = false;
86561
+ error = new UpstreamCallError("too_large", false, "the server's answer passed crew's 10 MiB read bound; crew stopped reading it");
86562
+ reject;
86563
+ promise = new Promise((_, reject) => {
86564
+ this.reject = reject;
86565
+ });
86566
+ constructor() {
86567
+ void this.promise.catch(() => void 0);
86568
+ }
86569
+ trip() {
86570
+ if (this.tripped) return;
86571
+ this.tripped = true;
86572
+ this.reject(this.error);
86573
+ }
86574
+ };
86433
86575
  var MCP_PROBE_TIMEOUT_MS = 45e3;
86434
86576
  var MCP_PROBE_RETRY_DELAYS_MS = [500, 1e3, 2e3, 4e3, 8e3, 8e3, 8e3];
86435
86577
  var STDERR_TAIL_BYTES = 2048;
@@ -86452,21 +86594,43 @@ function objectOrNull(raw) {
86452
86594
  function transportFor(config2, secret, dial = {}) {
86453
86595
  if (config2.kind === "rest") throw new Error("a rest upstream is not an MCP server; it has no MCP transport");
86454
86596
  if (config2.kind === "sql" || config2.kind === "graphql") throw new Error(`a ${config2.kind} source is not an MCP server; it has no MCP transport`);
86597
+ const bound = new ResponseBound();
86455
86598
  if (config2.kind === "mcp-stdio") {
86456
86599
  const env = { ...getDefaultEnvironment() };
86457
86600
  Object.assign(env, config2.env);
86458
86601
  if (config2.auth?.env !== void 0 && secret !== null) env[config2.auth.env] = secret;
86459
- const transport = new StdioClientTransport({ command: config2.command ?? "", args: config2.args, env, stderr: "pipe" });
86602
+ const transport = new StdioClientTransport({ command: config2.command ?? "", args: config2.args, env, stderr: "pipe", maxBufferSize: MCP_RESPONSE_MAX_BYTES });
86603
+ transport.onerror = (err) => {
86604
+ if (err.message.includes("ReadBuffer exceeded maximum size")) bound.trip();
86605
+ };
86460
86606
  let tail = "";
86461
86607
  transport.stderr?.on("data", (chunk) => {
86462
86608
  tail = (tail + chunk.toString("utf8")).slice(-STDERR_TAIL_BYTES);
86463
86609
  });
86464
- return { transport, stderrTail: () => tail };
86610
+ return { transport, stderrTail: () => tail, bound };
86465
86611
  }
86466
86612
  const headers = {};
86467
86613
  if (config2.auth?.header !== void 0 && secret !== null) headers[config2.auth.header] = `${config2.auth.prefix ?? ""}${secret}`;
86468
- const http = new StreamableHTTPClientTransport(new URL(config2.url ?? ""), { requestInit: { headers }, fetch: boundFetch(addressPolicyOf(config2), dial) });
86469
- return { transport: http, stderrTail: () => "" };
86614
+ const upstreamFetch = boundFetch(addressPolicyOf(config2), dial);
86615
+ const cappedFetch = async (input2, init) => {
86616
+ const response = await upstreamFetch(input2, init);
86617
+ if (response.body === null) return response;
86618
+ let bytes = 0;
86619
+ const body = response.body.pipeThrough(new TransformStream({
86620
+ transform(chunk, controller) {
86621
+ bytes += chunk.byteLength;
86622
+ if (bytes > MCP_RESPONSE_MAX_BYTES) {
86623
+ bound.trip();
86624
+ controller.error(bound.error);
86625
+ return;
86626
+ }
86627
+ controller.enqueue(chunk);
86628
+ }
86629
+ }));
86630
+ return new Response(body, { status: response.status, statusText: response.statusText, headers: response.headers });
86631
+ };
86632
+ const http = new StreamableHTTPClientTransport(new URL(config2.url ?? ""), { requestInit: { headers }, fetch: cappedFetch });
86633
+ return { transport: http, stderrTail: () => "", bound };
86470
86634
  }
86471
86635
  async function probeSourceKind(config2, secret, dial) {
86472
86636
  const secrets = secret === null ? [] : [.../* @__PURE__ */ new Set([secret, JSON.stringify(secret).slice(1, -1)])];
@@ -86477,7 +86641,7 @@ async function probeSourceKind(config2, secret, dial) {
86477
86641
  } catch (err) {
86478
86642
  const message = err instanceof Error ? err.message : String(err);
86479
86643
  const refusal = err instanceof DialRefusedError ? err.code : err?.refusal ?? void 0;
86480
- const coded = refusal !== void 0 && refusal !== null ? { refusal } : {};
86644
+ const coded = refusal !== void 0 && refusal !== null ? { refusal, ...err instanceof DialRefusedError || err instanceof SourceQueryError ? { detail: err.detail } : {} } : {};
86481
86645
  if (err instanceof DialRefusedError) {
86482
86646
  const where = err instanceof DialRedirectRefusedError && err.location !== null ? ` (to ${err.location})` : "";
86483
86647
  return scrubSecrets({ ok: false, error: `the connection was refused (${err.code})`, sourceDetail: `${message}${where}`, ...coded }, secrets);
@@ -86524,11 +86688,11 @@ async function probeMcpServerWithin(config2, secret, budget, dial = {}) {
86524
86688
  continue;
86525
86689
  }
86526
86690
  const message = retryable ? stillStartingMessage(budget.budgetMs, config2.kind) : outcome.message;
86527
- return scrubSecrets({ ok: false, error: lastTail === "" ? message : `${message}; stderr: ${lastTail}`, ...outcome.refusal !== void 0 ? { refusal: outcome.refusal } : {} }, secrets);
86691
+ return scrubSecrets({ ok: false, error: lastTail === "" ? message : `${message}; stderr: ${lastTail}`, ...outcome.refusal !== void 0 ? { refusal: outcome.refusal, ...outcome.detail !== void 0 ? { detail: outcome.detail } : {} } : {} }, secrets);
86528
86692
  }
86529
86693
  }
86530
86694
  async function probeOnce(config2, secret, deadlineMs, dial) {
86531
- const { transport, stderrTail } = transportFor(config2, secret, dial);
86695
+ const { transport, stderrTail, bound } = transportFor(config2, secret, dial);
86532
86696
  const client = new Client({ name: "wicked-crew-mcp-probe", version: "1" }, { capabilities: {} });
86533
86697
  let timer2;
86534
86698
  const deadline = new Promise((_, reject) => {
@@ -86557,11 +86721,12 @@ async function probeOnce(config2, secret, deadlineMs, dial) {
86557
86721
  return { ok: true, serverInfo: info === void 0 ? null : { name: info.name, version: info.version }, tools };
86558
86722
  })();
86559
86723
  try {
86560
- return { ok: true, result: await Promise.race([work, deadline]) };
86724
+ return { ok: true, result: await Promise.race([work, deadline, bound.promise]) };
86561
86725
  } catch (err) {
86562
86726
  work.catch(() => void 0);
86563
- const message = err instanceof Error ? err.message : String(err);
86564
- return { ok: false, message, tail: stderrTail().trim(), stillStarting: err instanceof StillStarting, ...err instanceof DialRefusedError ? { refusal: err.code } : {} };
86727
+ const failure3 = bound.tripped ? bound.error : err;
86728
+ const message = failure3 instanceof Error ? failure3.message : String(failure3);
86729
+ return { ok: false, message, tail: stderrTail().trim(), stillStarting: failure3 instanceof StillStarting, ...err instanceof DialRefusedError ? { refusal: err.code, detail: err.detail } : {} };
86565
86730
  } finally {
86566
86731
  clearTimeout(timer2);
86567
86732
  await client.close().catch(() => void 0);
@@ -86576,7 +86741,7 @@ function classifyUpstreamError(err) {
86576
86741
  const message = err instanceof Error ? err.message : String(err);
86577
86742
  if (err instanceof StreamableHTTPError) {
86578
86743
  const status = typeof err.code === "number" ? err.code : 0;
86579
- return new UpstreamCallError("http", status === 429 || status >= 500, message);
86744
+ return new UpstreamCallError("http", status === 429 || status >= 500, message, Number.isInteger(status) && status >= 100 && status <= 599 ? status : void 0);
86580
86745
  }
86581
86746
  if (err instanceof McpError) {
86582
86747
  if (err.code === ErrorCode.ConnectionClosed) return new UpstreamCallError("transport", true, message);
@@ -86590,7 +86755,7 @@ var invokeMcpTool = async (config2, secret, tool, args, timeoutMs, rest = null,
86590
86755
  if (rest === null) throw new UpstreamCallError("protocol", false, `${tool} has no REST mapping; test and save the server again`);
86591
86756
  return invokeRestTool(config2, secret, rest, args, timeoutMs, {}, onDispatch);
86592
86757
  }
86593
- const { transport, stderrTail } = transportFor(config2, secret);
86758
+ const { transport, stderrTail, bound } = transportFor(config2, secret);
86594
86759
  const client = new Client({ name: "wicked-crew-mcp-broker", version: "1" }, { capabilities: {} });
86595
86760
  let timer2;
86596
86761
  let connected = false;
@@ -86609,12 +86774,12 @@ var invokeMcpTool = async (config2, secret, tool, args, timeoutMs, rest = null,
86609
86774
  return await client.callTool({ name: tool, arguments: args }, void 0, sdkTimeout);
86610
86775
  })();
86611
86776
  try {
86612
- return await Promise.race([work, deadline]);
86777
+ return await Promise.race([work, deadline, bound.promise]);
86613
86778
  } catch (err) {
86614
86779
  work.catch(() => void 0);
86615
- const classified = classifyUpstreamError(err);
86780
+ const classified = bound.tripped ? bound.error : classifyUpstreamError(err);
86616
86781
  const tail = stderrTail().trim();
86617
- throw tail === "" ? classified : new UpstreamCallError(classified.errorClass, classified.retryable, `${classified.message}; stderr: ${tail}`);
86782
+ throw tail === "" ? classified : new UpstreamCallError(classified.errorClass, classified.retryable, `${classified.message}; stderr: ${tail}`, classified.status);
86618
86783
  } finally {
86619
86784
  clearTimeout(timer2);
86620
86785
  await client.close().catch(() => void 0);
@@ -86657,6 +86822,11 @@ var HELD_WORDS = [
86657
86822
  var NAMED_STATUSES = /* @__PURE__ */ new Set(["kept", "broken", "n_a", "skipped", ...HELD_WORDS.map(([s2]) => s2)]);
86658
86823
 
86659
86824
  // src/core/deliver.ts
86825
+ var SCRIPT_GIT_ENV_LINES = [
86826
+ `export -n ${ADO_RAW_ENV.join(" ")}`,
86827
+ `for _v in $(compgen -e); do case "$_v" in ${ADO_RAW_ENV.map((n) => n.replace(/[A-Za-z]/g, (c) => `[${c.toLowerCase()}${c.toUpperCase()}]`)).join("|")}) export -n "$_v";; esac; done`,
86828
+ `export GIT_CONFIG_PARAMETERS="\${GIT_CONFIG_PARAMETERS:+$GIT_CONFIG_PARAMETERS }${FSMONITOR_OFF_PARAMETER}"`
86829
+ ];
86660
86830
  var CHANGELOG_REBASE_LINES = [
86661
86831
  " while _rebasing; do",
86662
86832
  " CF=$(git diff --name-only --diff-filter=U || true)",
@@ -86907,8 +87077,7 @@ function snapshotPath(digest, dir = snapshotDir()) {
86907
87077
  if (!/^[0-9a-f]{64}$/.test(digest)) throw new UploadError("bad_digest", "a snapshot digest is 64 hex characters");
86908
87078
  return join3(dir, `${digest}.sqlite`);
86909
87079
  }
86910
- var INT64_MIN = -(2n ** 63n);
86911
- var INT64_MAX = 2n ** 63n - 1n;
87080
+ var STALE_TMP_MS = 2 * UPLOAD_LIMITS.parseMs;
86912
87081
 
86913
87082
  // src/sources/kinds.ts
86914
87083
  var CREW_SOURCE = "crew";
@@ -88392,7 +88561,10 @@ function failure2(err, what, sent) {
88392
88561
  if (err instanceof DialRefusedError) return { state: "failed", reason: `the connection to ${what} was refused (${err.code}); nothing was sent` };
88393
88562
  if (err instanceof UpstreamCallError) {
88394
88563
  if (err.errorClass === "boundary") return { state: "failed", reason: `crew refused the request to ${what} (${err.errorClass}); nothing was sent` };
88395
- if (err.errorClass === "http") return { state: "failed", reason: `${what} answered an HTTP error` };
88564
+ if (err.errorClass === "http") {
88565
+ const status = /HTTP ([1-5][0-9]{2})\b/.exec(err.message)?.[1];
88566
+ return { state: "failed", reason: `${what} answered an HTTP error${status !== void 0 ? ` (HTTP ${status})` : ""}` };
88567
+ }
88396
88568
  if (err.errorClass === "protocol" && sent) return { state: "failed", reason: `${what} answered an error (the call was refused)` };
88397
88569
  }
88398
88570
  if (!sent) return { state: "failed", reason: `${what} could not be reached; nothing was sent` };
@@ -89987,6 +90159,9 @@ function pinOf(config2) {
89987
90159
  const descriptor = appSourceDescriptor(config2);
89988
90160
  return { kind: config2.kind, descriptor, descriptorHash: sha2(descriptor) };
89989
90161
  }
90162
+ async function projectMaySee(source, visible) {
90163
+ return source.kind !== "sql" || (await visible()).has(source.name);
90164
+ }
89990
90165
  async function lookupSource(registry2, name) {
89991
90166
  if (name === CREW_SOURCE) return { name: CREW_SOURCE, kind: "crew", pin: CREW_PIN };
89992
90167
  if (name === ESTATE_SERVER) return { name: ESTATE_SERVER, kind: "estate", pin: ESTATE_PIN };
@@ -90110,7 +90285,13 @@ var TOOLBOX_PINS = Object.freeze({
90110
90285
  });
90111
90286
  var MAX_BYTES = 400 * 1024 * 1024;
90112
90287
 
90288
+ // src/knowledge/adapters/toolbox/memory.ts
90289
+ import { execFile as execFile2 } from "node:child_process";
90290
+ import { promisify as promisify2 } from "node:util";
90291
+ var exec = promisify2(execFile2);
90292
+
90113
90293
  // src/knowledge/adapters/toolbox/supervisor.ts
90294
+ var TOOLBOX_MEMORY_BYTES = 512 * 1024 * 1024;
90114
90295
  var TOOLBOX_IDLE_MS = 15 * 60 * 1e3;
90115
90296
  var STDERR_KEEP = 8 * 1024;
90116
90297
  var INTERNAL_BYTES = 8 * 1024 * 1024;
@@ -90289,7 +90470,15 @@ async function readCatalog(estate, sourceId, visible, opts = {}) {
90289
90470
  }
90290
90471
  if (opts.owner === true && got.sourceId !== sourceId) throw new Error(`estate answered a catalog that is not source ${sourceId}'s`);
90291
90472
  if (typeof got.generation === "number") generation = got.generation;
90292
- for (const d of got.docs ?? []) if (typeof d.key === "string") docs.push({ key: d.key, title: typeof d.title === "string" ? d.title : null, entry: d.entry ?? null });
90473
+ for (const d of got.docs ?? []) {
90474
+ if (typeof d.key !== "string") continue;
90475
+ const entry = d.entry;
90476
+ if (typeof entry === "object" && entry !== null && entry.kind === "not_listed") {
90477
+ truncated = true;
90478
+ continue;
90479
+ }
90480
+ docs.push({ key: d.key, title: typeof d.title === "string" ? d.title : null, entry: d.entry ?? null });
90481
+ }
90293
90482
  const pages = typeof got.pages === "number" ? got.pages : 1;
90294
90483
  if (page + 1 >= pages) break;
90295
90484
  if (page + 1 === CATALOG_PAGES_MAX) truncated = true;
@@ -90298,9 +90487,35 @@ async function readCatalog(estate, sourceId, visible, opts = {}) {
90298
90487
  }
90299
90488
  throw new CatalogChangedError(`the structure of source ${sourceId} kept changing while it was read`);
90300
90489
  }
90490
+ function ownedShape(p) {
90491
+ const q = p;
90492
+ const shape = q?.payload?.shape;
90493
+ const prov = q?.provenance;
90494
+ const stamped = typeof prov === "object" && prov !== null && Object.keys(prov).some((k) => k.startsWith("run_"));
90495
+ return typeof q?.id === "string" && q.payload?.capture === "profile" && typeof shape?.sourceId === "string" && typeof shape.relation === "string" && !stamped;
90496
+ }
90497
+ function currentShapes(approved) {
90498
+ const keyOf = (p) => {
90499
+ if (!ownedShape(p)) return null;
90500
+ const shape = p.payload.shape;
90501
+ return JSON.stringify([shape.sourceId, shape.relation]);
90502
+ };
90503
+ const newest = /* @__PURE__ */ new Map();
90504
+ approved.forEach((p, i) => {
90505
+ const key = keyOf(p);
90506
+ if (key === null) return;
90507
+ const at = String(p.payload?.observed_at ?? "");
90508
+ const held = newest.get(key);
90509
+ if (held === void 0 || String(approved[held].payload?.observed_at ?? "") <= at) newest.set(key, i);
90510
+ });
90511
+ return approved.filter((p, i) => {
90512
+ const key = keyOf(p);
90513
+ return key === null || newest.get(key) === i;
90514
+ });
90515
+ }
90301
90516
 
90302
90517
  // src/core/estate-mcp-client.ts
90303
- import { existsSync as existsSync2, mkdirSync, readFileSync, realpathSync as realpathSync2 } from "node:fs";
90518
+ import { existsSync as existsSync2, mkdirSync, readFileSync } from "node:fs";
90304
90519
  import { fileURLToPath as fileURLToPath2 } from "node:url";
90305
90520
  var CLIENT_VERSION = (() => {
90306
90521
  try {
@@ -90359,7 +90574,7 @@ async function verifiedShapes(estate, proposals, sourceId, visible, fresh, opts
90359
90574
  const want = opts.want ?? Number.POSITIVE_INFINITY;
90360
90575
  const budget = opts.budget ?? VERIFY_BUDGET;
90361
90576
  const candidates = [];
90362
- for (const p of proposals) {
90577
+ for (const p of currentShapes(proposals)) {
90363
90578
  if (!isObj3(p) || p["state"] !== "approved" || typeof p["id"] !== "string" || !isObj3(p["payload"])) continue;
90364
90579
  const shape = p["payload"]["shape"];
90365
90580
  if (!isObj3(shape) || shape["sourceId"] !== sourceId || typeof shape["relation"] !== "string") continue;
@@ -90420,7 +90635,6 @@ var RECALL_LIMIT_DEFAULT = 20;
90420
90635
  var TITLE_MAX = 200;
90421
90636
  var CONTENT_MAX = 2e3;
90422
90637
  var TOKEN_BUDGET = 8e3;
90423
- var TOKEN_BUDGET_NAMED = 16e3;
90424
90638
  var QUERY_TEXT_MAX = 200;
90425
90639
  var RecallRefusal = class extends Error {
90426
90640
  constructor(code, message) {
@@ -90506,7 +90720,7 @@ async function readRecall(deps, projectId, t, queryText, opts = {}) {
90506
90720
  if (t.from === "knowledge") {
90507
90721
  const only = t.source !== void 0 ? await visibleSource(deps, projectId, t.source) : null;
90508
90722
  const visible = await deps.visible(projectId);
90509
- const got = await estate("knowledge.recall", { query: queryText ?? "", visible, token_budget: only === null ? TOKEN_BUDGET : TOKEN_BUDGET_NAMED });
90723
+ const got = await estate("knowledge.recall", { query: queryText ?? "", visible, token_budget: TOKEN_BUDGET, ...only !== null ? { require: [sourceDep(only.id)] } : {} });
90510
90724
  const items = isObj5(got) && Array.isArray(got["items"]) ? got["items"] : null;
90511
90725
  if (items === null) throw new RecallRefusal("unavailable", "estate answered the recall with no items");
90512
90726
  const now = await fresh();
@@ -90728,6 +90942,8 @@ var AppExecutor = class {
90728
90942
  throw err;
90729
90943
  }
90730
90944
  if (source === null || !queryKindFits(q.kind, source)) throw new AppExecError(409, "contract_changed", `${q.source} is gone or is another kind of source now`);
90945
+ const visibleSources = this.deps.visibleSources;
90946
+ if (visibleSources !== null && !await projectMaySee(source, () => visibleSources(this.deps.projectOf(app)))) throw new AppExecError(409, "query_refused", `${q.source} is not visible to ${app}'s project now`);
90731
90947
  if (source.pin.descriptorHash !== pinned.descriptorHash) throw new AppExecError(409, "contract_changed", `${q.source}'s connection changed since this version was checked: check it again`);
90732
90948
  if ((source.kind === "sql" || source.kind === "graphql") && !source.enabled) throw new AppExecError(409, "query_refused", `${q.source} is switched off`);
90733
90949
  const changed = () => new AppExecError(409, "contract_changed", `what query ${q.id} reads at ${q.source} changed since this version was checked: check it again`);
@@ -90738,7 +90954,7 @@ var AppExecutor = class {
90738
90954
  if (!t.ok || recallProblem(q, t.value) !== null) throw changed();
90739
90955
  const knowledge = this.deps.knowledge;
90740
90956
  if (knowledge === void 0) throw new AppExecError(503, "apps_unavailable", "this server does not read the system's knowledge: knowledge queries run in studio only");
90741
- const projectId = this.deps.projectOf?.(app) ?? null;
90957
+ const projectId = this.deps.projectOf(app);
90742
90958
  if (projectId === null) throw new AppExecError(409, "query_refused", `${app} belongs to no project, so it reads no knowledge`);
90743
90959
  let sourceId = null;
90744
90960
  try {
@@ -90778,7 +90994,7 @@ var AppExecutor = class {
90778
90994
  if (!t.ok) throw changed();
90779
90995
  const found = await this.deps.registry.appTool(source.name, t.value.tool);
90780
90996
  if (found === null || !found.bound || pinOf(found.config).descriptorHash !== source.pin.descriptorHash) throw changed();
90781
- if (effectiveToolClass(deriveToolClass(found.tool.annotations), found.tool.classOverride) !== "read") throw changed();
90997
+ if (effectiveToolClass(deriveToolClass(found.tool.annotations), found.tool.classOverride) !== "read" || !effectiveReadAccepted(found.tool)) throw changed();
90782
90998
  contract = toolQueryContract(source.kind, found.tool, q.params);
90783
90999
  plan = { kind: "tool", source, tool: found.tool, args: t.value.args };
90784
91000
  }
@@ -90899,6 +91115,7 @@ var AppExecutor = class {
90899
91115
  if (err.errorClass === "refused") return new AppExecError(409, "query_refused", `the source refused the read${err.refusal !== null ? ` (${err.refusal})` : ""}: describe it again if it changed`);
90900
91116
  return new AppExecError(502, err.errorClass === "connection" ? "source_unavailable" : "source_failed", `the source answered ${err.errorClass}${st}`);
90901
91117
  }
91118
+ if (err instanceof UpstreamCallError && err.errorClass === "too_large") return new AppExecError(502, "source_failed", "the source's answer passed the 10 MiB read bound");
90902
91119
  if (err instanceof UpstreamCallError) return new AppExecError(err.errorClass === "timeout" ? 504 : 502, err.errorClass === "timeout" ? "source_timeout" : "source_failed", `the source call failed (${err.errorClass})`);
90903
91120
  if (err instanceof McpRegistryError) return new AppExecError(409, "contract_changed", `the source cannot be used now (${err.code})`);
90904
91121
  return new AppExecError(502, "source_failed", "the read failed");
@@ -91385,9 +91602,16 @@ var AppWritePath = class {
91385
91602
  if (locked === void 0 || pinned === void 0 || locked.actionHash !== actionHash(action)) throw refuse3(409, "contract_changed", `action ${id2} was never checked in this version: check it again`);
91386
91603
  return { at, action, locked, pinned };
91387
91604
  }
91605
+ /** Visibility can narrow after landing or preparing: refuse before describing or sending a write. */
91606
+ async source(app, name) {
91607
+ const source = await lookupSource(this.deps.registry, name);
91608
+ const visibleSources = this.deps.visibleSources;
91609
+ if (source !== null && visibleSources !== null && !await projectMaySee(source, () => visibleSources(this.deps.projectOf(app)))) throw refuse3(409, "action_refused", `${name} is not visible to ${app}'s project now`);
91610
+ return source;
91611
+ }
91388
91612
  /** Recompute the action's contract against the source now (never executes it). */
91389
- async resolve(action, snapshot) {
91390
- const source = snapshot !== void 0 ? snapshot : await lookupSource(this.deps.registry, action.source);
91613
+ async resolve(app, action, snapshot) {
91614
+ const source = snapshot !== void 0 ? snapshot : await this.source(app, action.source);
91391
91615
  if (source === null) throw refuse3(409, "contract_changed", `${action.source} is gone`);
91392
91616
  if (action.kind === "row-write") {
91393
91617
  if (source.kind !== "sql" || source.config.sql?.driver !== "postgres") throw refuse3(409, "contract_changed", `${action.source} is not a Postgres source`);
@@ -91434,9 +91658,9 @@ var AppWritePath = class {
91434
91658
  // ── grant / revoke ───────────────────────────────────────────────────────────────────────────
91435
91659
  async grant(app, id2, input2) {
91436
91660
  const { action, locked, pinned } = await this.actionAt(app, input2.version, id2);
91437
- const source = await lookupSource(this.deps.registry, action.source);
91661
+ const source = await this.source(app, action.source);
91438
91662
  if (source !== null && source.kind === "sql" && !source.allowWrites) throw refuse3(409, "writes_off", `${action.source}'s Allow writes switch is off: turn it on before granting a row write`);
91439
- const r = await this.resolve(action);
91663
+ const r = await this.resolve(app, action);
91440
91664
  if (action.kind === "row-write" && r.source.kind === "sql") {
91441
91665
  const { schema, name } = splitTable(action.table);
91442
91666
  const report = await pgPrivileges(sqlConnectArgs(r.source.config, await this.secret(r.source), this.deps.dial ?? {}), [{ schema, table: name, op: action.op, set: Object.keys(action.set ?? {}), key: Object.keys(action.key) }]).catch(() => null);
@@ -91460,7 +91684,7 @@ var AppWritePath = class {
91460
91684
  };
91461
91685
  await this.deps.actions.locked(async (tx) => {
91462
91686
  if (action.kind === "row-write") {
91463
- const now = await lookupSource(this.deps.registry, action.source);
91687
+ const now = await this.source(app, action.source);
91464
91688
  if (now === null || now.kind !== "sql" || !now.allowWrites || now.pin.descriptorHash !== pinned.descriptorHash) throw refuse3(409, "writes_off", `${action.source}'s Allow writes switch is off`);
91465
91689
  }
91466
91690
  tx.setGrant(grant);
@@ -91493,7 +91717,7 @@ var AppWritePath = class {
91493
91717
  if (grant.actionHash !== hash2 || record3 !== void 0 && (record3.actionHash !== hash2 || record3.actionHash !== grant.actionHash || record3.contractHash !== grant.contractHash)) {
91494
91718
  throw refuse3(409, "not_granted", `this version of action ${action.id} is not the one granted: grant it again to use it`);
91495
91719
  }
91496
- const source = await lookupSource(this.deps.registry, action.source);
91720
+ const source = await this.source(app, action.source);
91497
91721
  if (source === null || source.pin.descriptorHash !== grant.descriptorHash || record3 !== void 0 && record3.descriptorHash !== source.pin.descriptorHash) {
91498
91722
  return this.withdraw(app, action.id, "source_changed", "contract_changed", `${action.source}'s connection changed since the grant: the grant is withdrawn`, grant);
91499
91723
  }
@@ -91502,7 +91726,7 @@ var AppWritePath = class {
91502
91726
  if (action.kind === "row-write" && (source.kind !== "sql" || !source.allowWrites)) throw refuse3(409, "writes_off", `${action.source}'s Allow writes switch is off`);
91503
91727
  let resolved;
91504
91728
  try {
91505
- resolved = await this.resolve(action, source);
91729
+ resolved = await this.resolve(app, action, source);
91506
91730
  } catch (err) {
91507
91731
  if (err instanceof AppWriteError && (err.code === "table_changed" || err.code === "contract_changed")) return this.withdraw(app, action.id, err.code, err.code, `${err.message}: the grant is withdrawn`, grant);
91508
91732
  throw err;
@@ -91656,7 +91880,7 @@ var AppWritePath = class {
91656
91880
  const secret = await this.secret(resolved.source);
91657
91881
  await this.deps.hooks?.beforeRunning?.();
91658
91882
  const rec = await this.deps.actions.locked(async (tx) => {
91659
- const now = await lookupSource(this.deps.registry, action.source);
91883
+ const now = await this.source(app, action.source);
91660
91884
  const r = tx.record(snap.id);
91661
91885
  if (r === null || r.state !== "prepared") throw refuse3(409, "record_used", `record ${snap.id} already ran`);
91662
91886
  if (this.now() >= r.expiresAt) throw refuse3(409, "record_expired", `record ${snap.id} expired: prepare the action again`);
@@ -91908,6 +92132,9 @@ var SITE_SNAPSHOTS = "snapshots";
91908
92132
  var SITE_PORT = 8080;
91909
92133
  var TEAMS_FRAME_ORIGINS = ["https://teams.microsoft.com", "https://*.teams.microsoft.com", "https://teams.cloud.microsoft"];
91910
92134
 
92135
+ // src/apps/exec/redescribe.ts
92136
+ var REDESCRIBE_MS = 10 * 6e4;
92137
+
91911
92138
  // ../apps-server/src/identity.ts
91912
92139
  import { createHash as createHash12 } from "node:crypto";
91913
92140
  var TEAMS_CLIENT_IDS = ["1fec8e78-bce4-4aaf-ab1b-5451cc387264", "5e3ce6c0-2b1f-4285-8d4b-75ee78787346"];
@@ -92208,10 +92435,10 @@ function isMountPoint(dir, mountinfo = "/proc/self/mountinfo") {
92208
92435
  }
92209
92436
 
92210
92437
  // ../apps-server/src/owner.ts
92211
- import { randomBytes as randomBytes2 } from "node:crypto";
92212
- import { mkdirSync as mkdirSync4, readFileSync as readFileSync5, renameSync as renameSync2, rmSync, statSync as statSync2, writeFileSync as writeFileSync2 } from "node:fs";
92438
+ import { readFileSync as readFileSync5, statSync as statSync2, writeFileSync as writeFileSync2 } from "node:fs";
92213
92439
  import { hostname as hostname3 } from "node:os";
92214
92440
  import { join as join6 } from "node:path";
92441
+ import { DatabaseSync } from "node:sqlite";
92215
92442
 
92216
92443
  // ../apps-server/src/site.ts
92217
92444
  import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
@@ -92278,84 +92505,51 @@ function loadSite(dir) {
92278
92505
  }
92279
92506
 
92280
92507
  // ../apps-server/src/owner.ts
92281
- var HEARTBEAT_MS = 1e4;
92282
- var STALE_MS = 3e4;
92283
- var SETTLE_MS = 250;
92284
- var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
92285
92508
  async function claimDataDir(dir, opts = {}) {
92286
- const now = opts.now ?? Date.now;
92287
- const lock = join6(dir, ".owner");
92288
- const beatFile = join6(lock, "heartbeat.json");
92289
- const token = randomBytes2(12).toString("hex");
92290
- const taken = () => new SiteError(`another wicked-apps-server took ${dir} over just now: one server per app with actions`);
92509
+ const lock = join6(dir, ".owner.lock");
92510
+ const ownerFile = join6(dir, ".owner.json");
92291
92511
  const owner = () => {
92292
92512
  try {
92293
- return JSON.parse(readFileSync5(beatFile, "utf8"));
92513
+ const info = JSON.parse(readFileSync5(ownerFile, "utf8"));
92514
+ if (typeof info?.host === "string" && typeof info.pid === "number") return `${info.host}:${info.pid}`;
92294
92515
  } catch {
92295
- return null;
92296
92516
  }
92517
+ return "starting up";
92297
92518
  };
92298
- const beat = () => {
92299
- const tmp = join6(lock, `.beat-${token}`);
92300
- writeFileSync2(tmp, `${JSON.stringify({ token, host: hostname3(), pid: process.pid, at: now() })}
92519
+ let db;
92520
+ let identity;
92521
+ try {
92522
+ db = new DatabaseSync(lock);
92523
+ db.exec("PRAGMA busy_timeout = 0; BEGIN IMMEDIATE");
92524
+ identity = statSync2(lock, { bigint: true });
92525
+ writeFileSync2(ownerFile, `${JSON.stringify({ host: hostname3(), pid: process.pid })}
92301
92526
  `, { mode: 384 });
92302
- renameSync2(tmp, beatFile);
92303
- };
92304
- const take = () => {
92305
- try {
92306
- mkdirSync4(lock, { mode: 448 });
92307
- } catch (err) {
92308
- if (err.code !== "EEXIST") throw err;
92309
- return false;
92310
- }
92311
- beat();
92312
- return true;
92313
- };
92314
- const ageMs = () => {
92315
- try {
92316
- return now() - statSync2(lock).mtimeMs;
92317
- } catch {
92318
- return null;
92527
+ } catch (err) {
92528
+ db?.close();
92529
+ if (err.errcode === 5) {
92530
+ throw new SiteError(`another wicked-apps-server owns ${dir} (${owner()}): one server per app with actions; stop the other first`);
92319
92531
  }
92320
- };
92321
- if (!take()) {
92322
- const age = ageMs();
92323
- if (age === null) {
92324
- if (!take()) throw taken();
92325
- } else if (age < (opts.staleMs ?? STALE_MS)) {
92326
- throw new SiteError(`another wicked-apps-server owns ${dir} (${owner()?.host ?? "starting up"}): one server per app with actions; stop the other first`);
92327
- } else {
92328
- const away = `${lock}.stale-${token}`;
92532
+ throw err;
92533
+ }
92534
+ const database = db;
92535
+ let open2 = true;
92536
+ let lost = false;
92537
+ return {
92538
+ held() {
92539
+ if (!open2 || lost) return false;
92329
92540
  try {
92330
- renameSync2(lock, away);
92541
+ const current = statSync2(lock, { bigint: true });
92542
+ if (current.dev === identity.dev && current.ino === identity.ino) return true;
92331
92543
  } catch {
92332
- throw taken();
92333
92544
  }
92334
- rmSync(away, { recursive: true, force: true });
92335
- if (!take()) throw taken();
92336
- await sleep(opts.settleMs ?? SETTLE_MS);
92337
- if (owner()?.token !== token) throw taken();
92338
- }
92339
- }
92340
- let lost = false;
92341
- const held = () => {
92342
- if (lost) return false;
92343
- if (owner()?.token !== token) {
92344
92545
  lost = true;
92345
92546
  opts.onLost?.();
92346
- }
92347
- return !lost;
92348
- };
92349
- const timer2 = setInterval(() => {
92350
- if (held()) beat();
92351
- }, opts.heartbeatMs ?? HEARTBEAT_MS);
92352
- timer2.unref();
92353
- return {
92354
- held,
92547
+ return false;
92548
+ },
92355
92549
  release() {
92356
- clearInterval(timer2);
92357
- if (!lost && owner()?.token === token) rmSync(lock, { recursive: true, force: true });
92358
- lost = true;
92550
+ if (!open2) return;
92551
+ database.close();
92552
+ open2 = false;
92359
92553
  }
92360
92554
  };
92361
92555
  }
@@ -92726,7 +92920,6 @@ var SiteState = class {
92726
92920
  return [...this.refused.values()].sort((a, b2) => a.kind === b2.kind ? a.id.localeCompare(b2.id) : a.kind.localeCompare(b2.kind));
92727
92921
  }
92728
92922
  };
92729
- var REDESCRIBE_MS = 10 * 60 * 1e3;
92730
92923
  var DESCRIBE_DEADLINE_MS = 2e4;
92731
92924
  function missingSecrets(manifest, env = process.env) {
92732
92925
  return [...manifest.env].filter((name) => (env[name] ?? "") === "").sort();
@@ -92863,7 +93056,7 @@ async function startSiteWith(opts, held) {
92863
93056
  const registry2 = new ImageRegistry(site.sources, manifest.sources, env);
92864
93057
  const viewers = /* @__PURE__ */ new WeakMap();
92865
93058
  const viewerOf = async (actor) => viewers.get(actor) ?? { id: actor.id, email: null, name: null, groups: [] };
92866
- const executor = new AppExecutor({ store: files, registry: registry2, viewerOf, ...opts.dial !== void 0 ? { dial: opts.dial } : {}, snapshotDir: site.snapshotDir });
93059
+ const executor = new AppExecutor({ store: files, registry: registry2, visibleSources: null, projectOf: () => null, viewerOf, ...opts.dial !== void 0 ? { dial: opts.dial } : {}, snapshotDir: site.snapshotDir });
92867
93060
  let writePath = null;
92868
93061
  let actions = null;
92869
93062
  const seedGrants = async () => {
@@ -92881,7 +93074,7 @@ async function startSiteWith(opts, held) {
92881
93074
  held.claim = claim2;
92882
93075
  actions = new FencedActionStore(join7(opts.dataDir, "apps-actions.json"), () => claim2.held());
92883
93076
  await seedGrants();
92884
- writePath = new AppWritePath({ store: files, actions, registry: registry2, audit: auditSink(audit), viewerOf, executor, env, ...opts.dial !== void 0 ? { dial: opts.dial } : {} });
93077
+ writePath = new AppWritePath({ store: files, actions, registry: registry2, visibleSources: null, projectOf: () => null, audit: auditSink(audit), viewerOf, executor, env, ...opts.dial !== void 0 ? { dial: opts.dial } : {} });
92885
93078
  }
92886
93079
  state.actions = actionsOff === null ? { on: true, reason: null } : { on: false, reason: actionsOff };
92887
93080
  let checking = Promise.resolve();
@@ -93005,5 +93198,6 @@ async function main() {
93005
93198
  }
93006
93199
  if (process.argv[1] !== void 0 && fileURLToPath3(import.meta.url) === process.argv[1]) void main();
93007
93200
  export {
93201
+ FencedActionStore,
93008
93202
  startSite
93009
93203
  };