wicked-crew 0.16.13 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (707) hide show
  1. package/README.md +27 -9
  2. package/dist/api/audit-view.d.ts +24 -0
  3. package/dist/api/audit-view.d.ts.map +1 -0
  4. package/dist/api/audit-view.js +70 -0
  5. package/dist/api/audit-view.js.map +1 -0
  6. package/dist/api/auth.d.ts +42 -2
  7. package/dist/api/auth.d.ts.map +1 -1
  8. package/dist/api/auth.js +157 -18
  9. package/dist/api/auth.js.map +1 -1
  10. package/dist/api/capture.d.ts +12 -59
  11. package/dist/api/capture.d.ts.map +1 -1
  12. package/dist/api/capture.js +9 -17
  13. package/dist/api/capture.js.map +1 -1
  14. package/dist/api/chat-context.d.ts +6 -62
  15. package/dist/api/chat-context.d.ts.map +1 -1
  16. package/dist/api/chat-context.js +6 -12
  17. package/dist/api/chat-context.js.map +1 -1
  18. package/dist/api/chat-jobs.d.ts +163 -0
  19. package/dist/api/chat-jobs.d.ts.map +1 -0
  20. package/dist/api/chat-jobs.js +767 -0
  21. package/dist/api/chat-jobs.js.map +1 -0
  22. package/dist/api/chat-mcp.d.ts +37 -0
  23. package/dist/api/chat-mcp.d.ts.map +1 -1
  24. package/dist/api/chat-mcp.js +118 -2
  25. package/dist/api/chat-mcp.js.map +1 -1
  26. package/dist/api/chat-proposals.d.ts +170 -152
  27. package/dist/api/chat-proposals.d.ts.map +1 -1
  28. package/dist/api/chat-proposals.js +833 -15
  29. package/dist/api/chat-proposals.js.map +1 -1
  30. package/dist/api/delivery-assurance.d.ts +3 -1
  31. package/dist/api/delivery-assurance.d.ts.map +1 -1
  32. package/dist/api/delivery-assurance.js +20 -0
  33. package/dist/api/delivery-assurance.js.map +1 -1
  34. package/dist/api/delivery-freeze.d.ts +2 -8
  35. package/dist/api/delivery-freeze.d.ts.map +1 -1
  36. package/dist/api/delivery-freeze.js +2 -4
  37. package/dist/api/delivery-freeze.js.map +1 -1
  38. package/dist/api/eval-sample.d.ts +18 -114
  39. package/dist/api/eval-sample.d.ts.map +1 -1
  40. package/dist/api/eval-sample.js +7 -13
  41. package/dist/api/eval-sample.js.map +1 -1
  42. package/dist/api/governance-steering.d.ts +27 -71
  43. package/dist/api/governance-steering.d.ts.map +1 -1
  44. package/dist/api/governance-steering.js +11 -19
  45. package/dist/api/governance-steering.js.map +1 -1
  46. package/dist/api/mcp.d.ts +159 -199
  47. package/dist/api/mcp.d.ts.map +1 -1
  48. package/dist/api/mcp.js +433 -68
  49. package/dist/api/mcp.js.map +1 -1
  50. package/dist/api/needs.d.ts +10 -0
  51. package/dist/api/needs.d.ts.map +1 -1
  52. package/dist/api/needs.js +77 -0
  53. package/dist/api/needs.js.map +1 -1
  54. package/dist/api/open-path.d.ts +10 -0
  55. package/dist/api/open-path.d.ts.map +1 -1
  56. package/dist/api/open-path.js +58 -1
  57. package/dist/api/open-path.js.map +1 -1
  58. package/dist/api/plan-schema.d.ts +8 -51
  59. package/dist/api/plan-schema.d.ts.map +1 -1
  60. package/dist/api/plan-schema.js +6 -6
  61. package/dist/api/plan-schema.js.map +1 -1
  62. package/dist/api/product.d.ts +81 -23
  63. package/dist/api/product.d.ts.map +1 -1
  64. package/dist/api/product.js +149 -72
  65. package/dist/api/product.js.map +1 -1
  66. package/dist/api/project-aggregates.d.ts +12 -20
  67. package/dist/api/project-aggregates.d.ts.map +1 -1
  68. package/dist/api/project-aggregates.js +3 -3
  69. package/dist/api/project-aggregates.js.map +1 -1
  70. package/dist/api/recording.d.ts +69 -39
  71. package/dist/api/recording.d.ts.map +1 -1
  72. package/dist/api/recording.js +60 -49
  73. package/dist/api/recording.js.map +1 -1
  74. package/dist/api/routes.d.ts +229 -1506
  75. package/dist/api/routes.d.ts.map +1 -1
  76. package/dist/api/routes.js +1226 -169
  77. package/dist/api/routes.js.map +1 -1
  78. package/dist/api/run-timing-index.d.ts +12 -1
  79. package/dist/api/run-timing-index.d.ts.map +1 -1
  80. package/dist/api/run-timing-index.js +35 -0
  81. package/dist/api/run-timing-index.js.map +1 -1
  82. package/dist/api/seat-images.d.ts +10 -0
  83. package/dist/api/seat-images.d.ts.map +1 -1
  84. package/dist/api/seat-images.js +16 -3
  85. package/dist/api/seat-images.js.map +1 -1
  86. package/dist/api/server-error-body.d.ts +44 -0
  87. package/dist/api/server-error-body.d.ts.map +1 -0
  88. package/dist/api/server-error-body.js +206 -0
  89. package/dist/api/server-error-body.js.map +1 -0
  90. package/dist/api/server.d.ts.map +1 -1
  91. package/dist/api/server.js +179 -4
  92. package/dist/api/server.js.map +1 -1
  93. package/dist/api/skills.d.ts +12 -36
  94. package/dist/api/skills.d.ts.map +1 -1
  95. package/dist/api/skills.js +12 -15
  96. package/dist/api/skills.js.map +1 -1
  97. package/dist/api/system-snapshot.d.ts +1 -5
  98. package/dist/api/system-snapshot.d.ts.map +1 -1
  99. package/dist/api/system-snapshot.js +7 -15
  100. package/dist/api/system-snapshot.js.map +1 -1
  101. package/dist/api/testing.d.ts +29 -50
  102. package/dist/api/testing.d.ts.map +1 -1
  103. package/dist/api/testing.js +7 -13
  104. package/dist/api/testing.js.map +1 -1
  105. package/dist/apps/actions/api-action.d.ts +47 -0
  106. package/dist/apps/actions/api-action.d.ts.map +1 -0
  107. package/dist/apps/actions/api-action.js +135 -0
  108. package/dist/apps/actions/api-action.js.map +1 -0
  109. package/dist/apps/actions/pg-fit.d.ts +27 -0
  110. package/dist/apps/actions/pg-fit.d.ts.map +1 -0
  111. package/dist/apps/actions/pg-fit.js +35 -0
  112. package/dist/apps/actions/pg-fit.js.map +1 -0
  113. package/dist/apps/actions/pg-write.d.ts +84 -0
  114. package/dist/apps/actions/pg-write.d.ts.map +1 -0
  115. package/dist/apps/actions/pg-write.js +161 -0
  116. package/dist/apps/actions/pg-write.js.map +1 -0
  117. package/dist/apps/actions/store.d.ts +109 -0
  118. package/dist/apps/actions/store.d.ts.map +1 -0
  119. package/dist/apps/actions/store.js +182 -0
  120. package/dist/apps/actions/store.js.map +1 -0
  121. package/dist/apps/actions/values.d.ts +59 -0
  122. package/dist/apps/actions/values.d.ts.map +1 -0
  123. package/dist/apps/actions/values.js +315 -0
  124. package/dist/apps/actions/values.js.map +1 -0
  125. package/dist/apps/actions/write-path.d.ts +103 -0
  126. package/dist/apps/actions/write-path.d.ts.map +1 -0
  127. package/dist/apps/actions/write-path.js +576 -0
  128. package/dist/apps/actions/write-path.js.map +1 -0
  129. package/dist/apps/check.d.ts +112 -0
  130. package/dist/apps/check.d.ts.map +1 -0
  131. package/dist/apps/check.js +358 -0
  132. package/dist/apps/check.js.map +1 -0
  133. package/dist/apps/exec/arg-types.d.ts +56 -0
  134. package/dist/apps/exec/arg-types.d.ts.map +1 -0
  135. package/dist/apps/exec/arg-types.js +234 -0
  136. package/dist/apps/exec/arg-types.js.map +1 -0
  137. package/dist/apps/exec/cache.d.ts +46 -0
  138. package/dist/apps/exec/cache.d.ts.map +1 -0
  139. package/dist/apps/exec/cache.js +93 -0
  140. package/dist/apps/exec/cache.js.map +1 -0
  141. package/dist/apps/exec/contract.d.ts +83 -0
  142. package/dist/apps/exec/contract.d.ts.map +1 -0
  143. package/dist/apps/exec/contract.js +220 -0
  144. package/dist/apps/exec/contract.js.map +1 -0
  145. package/dist/apps/exec/executor.d.ts +122 -0
  146. package/dist/apps/exec/executor.d.ts.map +1 -0
  147. package/dist/apps/exec/executor.js +455 -0
  148. package/dist/apps/exec/executor.js.map +1 -0
  149. package/dist/apps/exec/limits.d.ts +25 -0
  150. package/dist/apps/exec/limits.d.ts.map +1 -0
  151. package/dist/apps/exec/limits.js +71 -0
  152. package/dist/apps/exec/limits.js.map +1 -0
  153. package/dist/apps/exec/params.d.ts +34 -0
  154. package/dist/apps/exec/params.d.ts.map +1 -0
  155. package/dist/apps/exec/params.js +97 -0
  156. package/dist/apps/exec/params.js.map +1 -0
  157. package/dist/apps/exec/project.d.ts +67 -0
  158. package/dist/apps/exec/project.d.ts.map +1 -0
  159. package/dist/apps/exec/project.js +299 -0
  160. package/dist/apps/exec/project.js.map +1 -0
  161. package/dist/apps/exec/recall.d.ts +88 -0
  162. package/dist/apps/exec/recall.d.ts.map +1 -0
  163. package/dist/apps/exec/recall.js +301 -0
  164. package/dist/apps/exec/recall.js.map +1 -0
  165. package/dist/apps/exec/source-stage.d.ts +61 -0
  166. package/dist/apps/exec/source-stage.d.ts.map +1 -0
  167. package/dist/apps/exec/source-stage.js +540 -0
  168. package/dist/apps/exec/source-stage.js.map +1 -0
  169. package/dist/apps/exec/sources.d.ts +65 -0
  170. package/dist/apps/exec/sources.d.ts.map +1 -0
  171. package/dist/apps/exec/sources.js +77 -0
  172. package/dist/apps/exec/sources.js.map +1 -0
  173. package/dist/apps/exec/texts.d.ts +140 -0
  174. package/dist/apps/exec/texts.d.ts.map +1 -0
  175. package/dist/apps/exec/texts.js +76 -0
  176. package/dist/apps/exec/texts.js.map +1 -0
  177. package/dist/apps/exec/viewer.d.ts +11 -0
  178. package/dist/apps/exec/viewer.d.ts.map +1 -0
  179. package/dist/apps/exec/viewer.js +26 -0
  180. package/dist/apps/exec/viewer.js.map +1 -0
  181. package/dist/apps/git.d.ts +109 -0
  182. package/dist/apps/git.d.ts.map +1 -0
  183. package/dist/apps/git.js +361 -0
  184. package/dist/apps/git.js.map +1 -0
  185. package/dist/apps/publish/image.d.ts +25 -0
  186. package/dist/apps/publish/image.d.ts.map +1 -0
  187. package/dist/apps/publish/image.js +86 -0
  188. package/dist/apps/publish/image.js.map +1 -0
  189. package/dist/apps/publish/layout.d.ts +41 -0
  190. package/dist/apps/publish/layout.d.ts.map +1 -0
  191. package/dist/apps/publish/layout.js +31 -0
  192. package/dist/apps/publish/layout.js.map +1 -0
  193. package/dist/apps/publish/manifest.d.ts +64 -0
  194. package/dist/apps/publish/manifest.d.ts.map +1 -0
  195. package/dist/apps/publish/manifest.js +282 -0
  196. package/dist/apps/publish/manifest.js.map +1 -0
  197. package/dist/apps/publish/pack.d.ts +40 -0
  198. package/dist/apps/publish/pack.d.ts.map +1 -0
  199. package/dist/apps/publish/pack.js +78 -0
  200. package/dist/apps/publish/pack.js.map +1 -0
  201. package/dist/apps/routes.d.ts +103 -0
  202. package/dist/apps/routes.d.ts.map +1 -0
  203. package/dist/apps/routes.js +440 -0
  204. package/dist/apps/routes.js.map +1 -0
  205. package/dist/apps/spec.d.ts +322 -2640
  206. package/dist/apps/spec.d.ts.map +1 -1
  207. package/dist/apps/spec.js +89 -120
  208. package/dist/apps/spec.js.map +1 -1
  209. package/dist/apps/store.d.ts +341 -0
  210. package/dist/apps/store.d.ts.map +1 -0
  211. package/dist/apps/store.js +905 -0
  212. package/dist/apps/store.js.map +1 -0
  213. package/dist/apps/turns.d.ts +169 -0
  214. package/dist/apps/turns.d.ts.map +1 -0
  215. package/dist/apps/turns.js +556 -0
  216. package/dist/apps/turns.js.map +1 -0
  217. package/dist/apps/views.d.ts +44 -0
  218. package/dist/apps/views.d.ts.map +1 -0
  219. package/dist/apps/views.js +53 -0
  220. package/dist/apps/views.js.map +1 -0
  221. package/dist/campaigns/routes.d.ts +22 -94
  222. package/dist/campaigns/routes.d.ts.map +1 -1
  223. package/dist/campaigns/routes.js +8 -14
  224. package/dist/campaigns/routes.js.map +1 -1
  225. package/dist/cli/apps-check.d.ts +43 -0
  226. package/dist/cli/apps-check.d.ts.map +1 -0
  227. package/dist/cli/apps-check.js +166 -0
  228. package/dist/cli/apps-check.js.map +1 -0
  229. package/dist/cli/index.d.ts.map +1 -1
  230. package/dist/cli/index.js +6 -1
  231. package/dist/cli/index.js.map +1 -1
  232. package/dist/cli/mcp.js +2 -2
  233. package/dist/cli/mcp.js.map +1 -1
  234. package/dist/core/adapter.d.ts +34 -1
  235. package/dist/core/adapter.d.ts.map +1 -1
  236. package/dist/core/adapter.js +78 -2
  237. package/dist/core/adapter.js.map +1 -1
  238. package/dist/core/builtin-catalog.d.ts.map +1 -1
  239. package/dist/core/builtin-catalog.js +2 -0
  240. package/dist/core/builtin-catalog.js.map +1 -1
  241. package/dist/core/deliver-text.d.ts +62 -1
  242. package/dist/core/deliver-text.d.ts.map +1 -1
  243. package/dist/core/deliver-text.js +244 -22
  244. package/dist/core/deliver-text.js.map +1 -1
  245. package/dist/core/deliver.d.ts.map +1 -1
  246. package/dist/core/deliver.js +30 -3
  247. package/dist/core/deliver.js.map +1 -1
  248. package/dist/core/estate-mcp-client.d.ts +9 -0
  249. package/dist/core/estate-mcp-client.d.ts.map +1 -1
  250. package/dist/core/estate-mcp-client.js +31 -3
  251. package/dist/core/estate-mcp-client.js.map +1 -1
  252. package/dist/core/linked-issues.d.ts +51 -3
  253. package/dist/core/linked-issues.d.ts.map +1 -1
  254. package/dist/core/linked-issues.js +59 -14
  255. package/dist/core/linked-issues.js.map +1 -1
  256. package/dist/core/qe-acceptance-setting.d.ts.map +1 -1
  257. package/dist/core/qe-acceptance-setting.js +6 -0
  258. package/dist/core/qe-acceptance-setting.js.map +1 -1
  259. package/dist/decisions/chat-recorder.js +1 -1
  260. package/dist/decisions/chat-recorder.js.map +1 -1
  261. package/dist/decisions/routes.d.ts.map +1 -1
  262. package/dist/decisions/routes.js +5 -9
  263. package/dist/decisions/routes.js.map +1 -1
  264. package/dist/decisions/rules-brief.d.ts +76 -0
  265. package/dist/decisions/rules-brief.d.ts.map +1 -0
  266. package/dist/decisions/rules-brief.js +179 -0
  267. package/dist/decisions/rules-brief.js.map +1 -0
  268. package/dist/editors/registry.d.ts +97 -258
  269. package/dist/editors/registry.d.ts.map +1 -1
  270. package/dist/editors/registry.js +11 -11
  271. package/dist/editors/registry.js.map +1 -1
  272. package/dist/editors/routes.js +3 -3
  273. package/dist/editors/routes.js.map +1 -1
  274. package/dist/evals/routes.d.ts.map +1 -1
  275. package/dist/evals/routes.js +3 -5
  276. package/dist/evals/routes.js.map +1 -1
  277. package/dist/insights/routes.js +2 -2
  278. package/dist/insights/routes.js.map +1 -1
  279. package/dist/interactive/proxy-routes.d.ts.map +1 -1
  280. package/dist/interactive/proxy-routes.js +76 -7
  281. package/dist/interactive/proxy-routes.js.map +1 -1
  282. package/dist/interactive/ws-relay.d.ts +3 -9
  283. package/dist/interactive/ws-relay.d.ts.map +1 -1
  284. package/dist/interactive/ws-relay.js +4 -6
  285. package/dist/interactive/ws-relay.js.map +1 -1
  286. package/dist/knowledge/adapters/native.d.ts +44 -0
  287. package/dist/knowledge/adapters/native.d.ts.map +1 -0
  288. package/dist/knowledge/adapters/native.js +60 -0
  289. package/dist/knowledge/adapters/native.js.map +1 -0
  290. package/dist/knowledge/adapters/toolbox/binary.d.ts +48 -0
  291. package/dist/knowledge/adapters/toolbox/binary.d.ts.map +1 -0
  292. package/dist/knowledge/adapters/toolbox/binary.js +145 -0
  293. package/dist/knowledge/adapters/toolbox/binary.js.map +1 -0
  294. package/dist/knowledge/adapters/toolbox/catalog.d.ts +22 -0
  295. package/dist/knowledge/adapters/toolbox/catalog.d.ts.map +1 -0
  296. package/dist/knowledge/adapters/toolbox/catalog.js +87 -0
  297. package/dist/knowledge/adapters/toolbox/catalog.js.map +1 -0
  298. package/dist/knowledge/adapters/toolbox/document.d.ts +71 -0
  299. package/dist/knowledge/adapters/toolbox/document.d.ts.map +1 -0
  300. package/dist/knowledge/adapters/toolbox/document.js +165 -0
  301. package/dist/knowledge/adapters/toolbox/document.js.map +1 -0
  302. package/dist/knowledge/adapters/toolbox/supervisor.d.ts +142 -0
  303. package/dist/knowledge/adapters/toolbox/supervisor.d.ts.map +1 -0
  304. package/dist/knowledge/adapters/toolbox/supervisor.js +438 -0
  305. package/dist/knowledge/adapters/toolbox/supervisor.js.map +1 -0
  306. package/dist/knowledge/gate/access.d.ts +36 -0
  307. package/dist/knowledge/gate/access.d.ts.map +1 -0
  308. package/dist/knowledge/gate/access.js +46 -0
  309. package/dist/knowledge/gate/access.js.map +1 -0
  310. package/dist/knowledge/gate/envelope.d.ts +67 -0
  311. package/dist/knowledge/gate/envelope.d.ts.map +1 -0
  312. package/dist/knowledge/gate/envelope.js +96 -0
  313. package/dist/knowledge/gate/envelope.js.map +1 -0
  314. package/dist/knowledge/gate/gate.d.ts +238 -0
  315. package/dist/knowledge/gate/gate.d.ts.map +1 -0
  316. package/dist/knowledge/gate/gate.js +782 -0
  317. package/dist/knowledge/gate/gate.js.map +1 -0
  318. package/dist/knowledge/gate/pg.d.ts +57 -0
  319. package/dist/knowledge/gate/pg.d.ts.map +1 -0
  320. package/dist/knowledge/gate/pg.js +94 -0
  321. package/dist/knowledge/gate/pg.js.map +1 -0
  322. package/dist/knowledge/gate/record.d.ts +77 -0
  323. package/dist/knowledge/gate/record.d.ts.map +1 -0
  324. package/dist/knowledge/gate/record.js +205 -0
  325. package/dist/knowledge/gate/record.js.map +1 -0
  326. package/dist/knowledge/gate/routes.d.ts +38 -0
  327. package/dist/knowledge/gate/routes.d.ts.map +1 -0
  328. package/dist/knowledge/gate/routes.js +102 -0
  329. package/dist/knowledge/gate/routes.js.map +1 -0
  330. package/dist/knowledge/gate/scheduler.d.ts +90 -0
  331. package/dist/knowledge/gate/scheduler.d.ts.map +1 -0
  332. package/dist/knowledge/gate/scheduler.js +224 -0
  333. package/dist/knowledge/gate/scheduler.js.map +1 -0
  334. package/dist/knowledge/gate/sources.d.ts +69 -0
  335. package/dist/knowledge/gate/sources.d.ts.map +1 -0
  336. package/dist/knowledge/gate/sources.js +135 -0
  337. package/dist/knowledge/gate/sources.js.map +1 -0
  338. package/dist/knowledge/package.d.ts +136 -0
  339. package/dist/knowledge/package.d.ts.map +1 -0
  340. package/dist/knowledge/package.js +148 -0
  341. package/dist/knowledge/package.js.map +1 -0
  342. package/dist/knowledge/projector.d.ts +144 -0
  343. package/dist/knowledge/projector.d.ts.map +1 -0
  344. package/dist/knowledge/projector.js +287 -0
  345. package/dist/knowledge/projector.js.map +1 -0
  346. package/dist/knowledge/registry/entry.d.ts +177 -0
  347. package/dist/knowledge/registry/entry.d.ts.map +1 -0
  348. package/dist/knowledge/registry/entry.js +126 -0
  349. package/dist/knowledge/registry/entry.js.map +1 -0
  350. package/dist/knowledge/registry/policy.d.ts +79 -0
  351. package/dist/knowledge/registry/policy.d.ts.map +1 -0
  352. package/dist/knowledge/registry/policy.js +139 -0
  353. package/dist/knowledge/registry/policy.js.map +1 -0
  354. package/dist/knowledge/shapes/code-search.d.ts +55 -0
  355. package/dist/knowledge/shapes/code-search.d.ts.map +1 -0
  356. package/dist/knowledge/shapes/code-search.js +88 -0
  357. package/dist/knowledge/shapes/code-search.js.map +1 -0
  358. package/dist/knowledge/shapes/map.d.ts +25 -0
  359. package/dist/knowledge/shapes/map.d.ts.map +1 -0
  360. package/dist/knowledge/shapes/map.js +187 -0
  361. package/dist/knowledge/shapes/map.js.map +1 -0
  362. package/dist/knowledge/shapes/profile.d.ts +117 -0
  363. package/dist/knowledge/shapes/profile.d.ts.map +1 -0
  364. package/dist/knowledge/shapes/profile.js +264 -0
  365. package/dist/knowledge/shapes/profile.js.map +1 -0
  366. package/dist/knowledge/shapes/routes.d.ts +69 -0
  367. package/dist/knowledge/shapes/routes.d.ts.map +1 -0
  368. package/dist/knowledge/shapes/routes.js +270 -0
  369. package/dist/knowledge/shapes/routes.js.map +1 -0
  370. package/dist/knowledge/shapes/shapes.d.ts +144 -0
  371. package/dist/knowledge/shapes/shapes.d.ts.map +1 -0
  372. package/dist/knowledge/shapes/shapes.js +280 -0
  373. package/dist/knowledge/shapes/shapes.js.map +1 -0
  374. package/dist/knowledge/shapes/verified.d.ts +36 -0
  375. package/dist/knowledge/shapes/verified.d.ts.map +1 -0
  376. package/dist/knowledge/shapes/verified.js +73 -0
  377. package/dist/knowledge/shapes/verified.js.map +1 -0
  378. package/dist/knowledge/summary.d.ts +45 -0
  379. package/dist/knowledge/summary.d.ts.map +1 -0
  380. package/dist/knowledge/summary.js +119 -0
  381. package/dist/knowledge/summary.js.map +1 -0
  382. package/dist/knowledge/trackers/actions.d.ts +55 -0
  383. package/dist/knowledge/trackers/actions.d.ts.map +1 -0
  384. package/dist/knowledge/trackers/actions.js +327 -0
  385. package/dist/knowledge/trackers/actions.js.map +1 -0
  386. package/dist/knowledge/trackers/addresses.d.ts +45 -0
  387. package/dist/knowledge/trackers/addresses.d.ts.map +1 -0
  388. package/dist/knowledge/trackers/addresses.js +59 -0
  389. package/dist/knowledge/trackers/addresses.js.map +1 -0
  390. package/dist/knowledge/trackers/bindings.d.ts +190 -0
  391. package/dist/knowledge/trackers/bindings.d.ts.map +1 -0
  392. package/dist/knowledge/trackers/bindings.js +970 -0
  393. package/dist/knowledge/trackers/bindings.js.map +1 -0
  394. package/dist/knowledge/trackers/gate-pm.d.ts +160 -0
  395. package/dist/knowledge/trackers/gate-pm.d.ts.map +1 -0
  396. package/dist/knowledge/trackers/gate-pm.js +427 -0
  397. package/dist/knowledge/trackers/gate-pm.js.map +1 -0
  398. package/dist/knowledge/trackers/issues.d.ts +69 -0
  399. package/dist/knowledge/trackers/issues.d.ts.map +1 -0
  400. package/dist/knowledge/trackers/issues.js +193 -0
  401. package/dist/knowledge/trackers/issues.js.map +1 -0
  402. package/dist/knowledge/trackers/map.d.ts +23 -0
  403. package/dist/knowledge/trackers/map.d.ts.map +1 -0
  404. package/dist/knowledge/trackers/map.js +130 -0
  405. package/dist/knowledge/trackers/map.js.map +1 -0
  406. package/dist/knowledge/trackers/projector.d.ts +113 -0
  407. package/dist/knowledge/trackers/projector.d.ts.map +1 -0
  408. package/dist/knowledge/trackers/projector.js +274 -0
  409. package/dist/knowledge/trackers/projector.js.map +1 -0
  410. package/dist/knowledge/trackers/routes.d.ts +107 -0
  411. package/dist/knowledge/trackers/routes.d.ts.map +1 -0
  412. package/dist/knowledge/trackers/routes.js +563 -0
  413. package/dist/knowledge/trackers/routes.js.map +1 -0
  414. package/dist/knowledge/trackers/set.d.ts +61 -0
  415. package/dist/knowledge/trackers/set.d.ts.map +1 -0
  416. package/dist/knowledge/trackers/set.js +77 -0
  417. package/dist/knowledge/trackers/set.js.map +1 -0
  418. package/dist/knowledge/trackers/view.d.ts +22 -0
  419. package/dist/knowledge/trackers/view.d.ts.map +1 -0
  420. package/dist/knowledge/trackers/view.js +31 -0
  421. package/dist/knowledge/trackers/view.js.map +1 -0
  422. package/dist/knowledge/trackers/visible.d.ts +9 -0
  423. package/dist/knowledge/trackers/visible.d.ts.map +1 -0
  424. package/dist/knowledge/trackers/visible.js +10 -0
  425. package/dist/knowledge/trackers/visible.js.map +1 -0
  426. package/dist/learn/routes.d.ts +3 -17
  427. package/dist/learn/routes.d.ts.map +1 -1
  428. package/dist/learn/routes.js +4 -6
  429. package/dist/learn/routes.js.map +1 -1
  430. package/dist/mcp/ask-server.d.ts +6 -0
  431. package/dist/mcp/ask-server.d.ts.map +1 -1
  432. package/dist/mcp/ask-server.js +15 -9
  433. package/dist/mcp/ask-server.js.map +1 -1
  434. package/dist/mcp/broker.d.ts +16 -0
  435. package/dist/mcp/broker.d.ts.map +1 -1
  436. package/dist/mcp/broker.js +137 -3
  437. package/dist/mcp/broker.js.map +1 -1
  438. package/dist/mcp/estate-relay.d.ts +50 -2
  439. package/dist/mcp/estate-relay.d.ts.map +1 -1
  440. package/dist/mcp/estate-relay.js +126 -4
  441. package/dist/mcp/estate-relay.js.map +1 -1
  442. package/dist/mcp/invoke.d.ts +12 -1
  443. package/dist/mcp/invoke.d.ts.map +1 -1
  444. package/dist/mcp/invoke.js +5 -2
  445. package/dist/mcp/invoke.js.map +1 -1
  446. package/dist/mcp/probe.d.ts +34 -2
  447. package/dist/mcp/probe.d.ts.map +1 -1
  448. package/dist/mcp/probe.js +51 -9
  449. package/dist/mcp/probe.js.map +1 -1
  450. package/dist/mcp/registry-store.d.ts +91 -0
  451. package/dist/mcp/registry-store.d.ts.map +1 -1
  452. package/dist/mcp/registry-store.js +116 -9
  453. package/dist/mcp/registry-store.js.map +1 -1
  454. package/dist/mcp/registry.d.ts +249 -6
  455. package/dist/mcp/registry.d.ts.map +1 -1
  456. package/dist/mcp/registry.js +735 -35
  457. package/dist/mcp/registry.js.map +1 -1
  458. package/dist/mcp/rest.d.ts +36 -10
  459. package/dist/mcp/rest.d.ts.map +1 -1
  460. package/dist/mcp/rest.js +71 -73
  461. package/dist/mcp/rest.js.map +1 -1
  462. package/dist/mcp/tool-list.d.ts +7 -0
  463. package/dist/mcp/tool-list.d.ts.map +1 -1
  464. package/dist/mcp/tool-list.js +32 -4
  465. package/dist/mcp/tool-list.js.map +1 -1
  466. package/dist/mcp-inspect/routes.d.ts +3 -0
  467. package/dist/mcp-inspect/routes.d.ts.map +1 -1
  468. package/dist/mcp-inspect/routes.js +31 -18
  469. package/dist/mcp-inspect/routes.js.map +1 -1
  470. package/dist/persona/routes.d.ts +14 -69
  471. package/dist/persona/routes.d.ts.map +1 -1
  472. package/dist/persona/routes.js +2 -2
  473. package/dist/persona/routes.js.map +1 -1
  474. package/dist/persona/store.d.ts +13 -40
  475. package/dist/persona/store.d.ts.map +1 -1
  476. package/dist/persona/store.js +9 -11
  477. package/dist/persona/store.js.map +1 -1
  478. package/dist/presets/routes.d.ts +3 -21
  479. package/dist/presets/routes.d.ts.map +1 -1
  480. package/dist/presets/routes.js +5 -7
  481. package/dist/presets/routes.js.map +1 -1
  482. package/dist/projects/repo-guard.d.ts +32 -0
  483. package/dist/projects/repo-guard.d.ts.map +1 -0
  484. package/dist/projects/repo-guard.js +46 -0
  485. package/dist/projects/repo-guard.js.map +1 -0
  486. package/dist/projects/routes.d.ts +16 -44
  487. package/dist/projects/routes.d.ts.map +1 -1
  488. package/dist/projects/routes.js +15 -18
  489. package/dist/projects/routes.js.map +1 -1
  490. package/dist/schedules/routes.d.ts +4 -18
  491. package/dist/schedules/routes.d.ts.map +1 -1
  492. package/dist/schedules/routes.js +4 -6
  493. package/dist/schedules/routes.js.map +1 -1
  494. package/dist/skills/plugin-source.d.ts +6 -5
  495. package/dist/skills/plugin-source.d.ts.map +1 -1
  496. package/dist/skills/plugin-source.js +6 -5
  497. package/dist/skills/plugin-source.js.map +1 -1
  498. package/dist/sources/ask.d.ts +108 -0
  499. package/dist/sources/ask.d.ts.map +1 -0
  500. package/dist/sources/ask.js +251 -0
  501. package/dist/sources/ask.js.map +1 -0
  502. package/dist/sources/catalog/mysql.d.ts +9 -0
  503. package/dist/sources/catalog/mysql.d.ts.map +1 -0
  504. package/dist/sources/catalog/mysql.js +77 -0
  505. package/dist/sources/catalog/mysql.js.map +1 -0
  506. package/dist/sources/catalog/postgres.d.ts +68 -0
  507. package/dist/sources/catalog/postgres.d.ts.map +1 -0
  508. package/dist/sources/catalog/postgres.js +164 -0
  509. package/dist/sources/catalog/postgres.js.map +1 -0
  510. package/dist/sources/catalog/types.d.ts +53 -0
  511. package/dist/sources/catalog/types.d.ts.map +1 -0
  512. package/dist/sources/catalog/types.js +30 -0
  513. package/dist/sources/catalog/types.js.map +1 -0
  514. package/dist/sources/connection-test.d.ts +37 -0
  515. package/dist/sources/connection-test.d.ts.map +1 -0
  516. package/dist/sources/connection-test.js +101 -0
  517. package/dist/sources/connection-test.js.map +1 -0
  518. package/dist/sources/crew-source.d.ts +31 -0
  519. package/dist/sources/crew-source.d.ts.map +1 -0
  520. package/dist/sources/crew-source.js +48 -0
  521. package/dist/sources/crew-source.js.map +1 -0
  522. package/dist/sources/dialer.d.ts +169 -0
  523. package/dist/sources/dialer.d.ts.map +1 -0
  524. package/dist/sources/dialer.js +761 -0
  525. package/dist/sources/dialer.js.map +1 -0
  526. package/dist/sources/drivers/mysql.d.ts +52 -0
  527. package/dist/sources/drivers/mysql.d.ts.map +1 -0
  528. package/dist/sources/drivers/mysql.js +348 -0
  529. package/dist/sources/drivers/mysql.js.map +1 -0
  530. package/dist/sources/drivers/postgres.d.ts +84 -0
  531. package/dist/sources/drivers/postgres.d.ts.map +1 -0
  532. package/dist/sources/drivers/postgres.js +381 -0
  533. package/dist/sources/drivers/postgres.js.map +1 -0
  534. package/dist/sources/drivers/sqlite.d.ts +47 -0
  535. package/dist/sources/drivers/sqlite.d.ts.map +1 -0
  536. package/dist/sources/drivers/sqlite.js +156 -0
  537. package/dist/sources/drivers/sqlite.js.map +1 -0
  538. package/dist/sources/drivers/types.d.ts +79 -0
  539. package/dist/sources/drivers/types.d.ts.map +1 -0
  540. package/dist/sources/drivers/types.js +31 -0
  541. package/dist/sources/drivers/types.js.map +1 -0
  542. package/dist/sources/graphql.d.ts +85 -0
  543. package/dist/sources/graphql.d.ts.map +1 -0
  544. package/dist/sources/graphql.js +155 -0
  545. package/dist/sources/graphql.js.map +1 -0
  546. package/dist/sources/kinds.d.ts +79 -0
  547. package/dist/sources/kinds.d.ts.map +1 -0
  548. package/dist/sources/kinds.js +145 -0
  549. package/dist/sources/kinds.js.map +1 -0
  550. package/dist/sources/policy/allowlists.d.ts +30 -0
  551. package/dist/sources/policy/allowlists.d.ts.map +1 -0
  552. package/dist/sources/policy/allowlists.js +104 -0
  553. package/dist/sources/policy/allowlists.js.map +1 -0
  554. package/dist/sources/policy/index.d.ts +20 -0
  555. package/dist/sources/policy/index.d.ts.map +1 -0
  556. package/dist/sources/policy/index.js +34 -0
  557. package/dist/sources/policy/index.js.map +1 -0
  558. package/dist/sources/policy/mysql.d.ts +21 -0
  559. package/dist/sources/policy/mysql.d.ts.map +1 -0
  560. package/dist/sources/policy/mysql.js +834 -0
  561. package/dist/sources/policy/mysql.js.map +1 -0
  562. package/dist/sources/policy/pg.d.ts +37 -0
  563. package/dist/sources/policy/pg.d.ts.map +1 -0
  564. package/dist/sources/policy/pg.js +572 -0
  565. package/dist/sources/policy/pg.js.map +1 -0
  566. package/dist/sources/policy/sqlite.d.ts +37 -0
  567. package/dist/sources/policy/sqlite.d.ts.map +1 -0
  568. package/dist/sources/policy/sqlite.js +94 -0
  569. package/dist/sources/policy/sqlite.js.map +1 -0
  570. package/dist/sources/policy/types.d.ts +46 -0
  571. package/dist/sources/policy/types.d.ts.map +1 -0
  572. package/dist/sources/policy/types.js +13 -0
  573. package/dist/sources/policy/types.js.map +1 -0
  574. package/dist/sources/routes.d.ts +154 -0
  575. package/dist/sources/routes.d.ts.map +1 -0
  576. package/dist/sources/routes.js +745 -0
  577. package/dist/sources/routes.js.map +1 -0
  578. package/dist/sources/safety/postgres.d.ts +87 -0
  579. package/dist/sources/safety/postgres.d.ts.map +1 -0
  580. package/dist/sources/safety/postgres.js +349 -0
  581. package/dist/sources/safety/postgres.js.map +1 -0
  582. package/dist/sources/sql.d.ts +51 -0
  583. package/dist/sources/sql.d.ts.map +1 -0
  584. package/dist/sources/sql.js +89 -0
  585. package/dist/sources/sql.js.map +1 -0
  586. package/dist/sources/store.d.ts +25 -0
  587. package/dist/sources/store.d.ts.map +1 -0
  588. package/dist/sources/store.js +59 -0
  589. package/dist/sources/store.js.map +1 -0
  590. package/dist/sources/uploads.d.ts +70 -0
  591. package/dist/sources/uploads.d.ts.map +1 -0
  592. package/dist/sources/uploads.js +636 -0
  593. package/dist/sources/uploads.js.map +1 -0
  594. package/dist/standing-orders/parse.d.ts +38 -0
  595. package/dist/standing-orders/parse.d.ts.map +1 -1
  596. package/dist/standing-orders/parse.js +104 -43
  597. package/dist/standing-orders/parse.js.map +1 -1
  598. package/dist/standing-orders/routes.d.ts +25 -126
  599. package/dist/standing-orders/routes.d.ts.map +1 -1
  600. package/dist/standing-orders/routes.js +4 -6
  601. package/dist/standing-orders/routes.js.map +1 -1
  602. package/dist/standing-orders/store.d.ts +22 -73
  603. package/dist/standing-orders/store.d.ts.map +1 -1
  604. package/dist/standing-orders/store.js +8 -12
  605. package/dist/standing-orders/store.js.map +1 -1
  606. package/dist/studio/assets/KnowledgeGraph-Cpm46tEp.js +1 -0
  607. package/dist/studio/assets/WickedSansA-Regular-CGPJLyb8.woff2 +0 -0
  608. package/dist/studio/assets/WickedSansA-SemiBold-Bk9KXUaV.woff2 +0 -0
  609. package/dist/studio/assets/favicon-BJA6hF2f.svg +1 -0
  610. package/dist/studio/assets/index-BRBwWQMH.css +32 -0
  611. package/dist/studio/assets/index-CVrWDGRP.js +1097 -0
  612. package/dist/studio/assets/wicked-studio-lettering-small-CBwSGqop.svg +2 -0
  613. package/dist/studio/assets/wicked-studio-wordmark-small-gF5xn6IC.svg +2 -0
  614. package/dist/studio/editors/wicked-apps/editor.json +45 -0
  615. package/dist/studio/editors/wicked-apps/icon.svg +1 -0
  616. package/dist/studio/editors/wicked-apps/index.html +151 -0
  617. package/dist/studio/editors/wicked-deck/editor.json +1 -1
  618. package/dist/studio/editors/wicked-deck/index.html +12 -8
  619. package/dist/studio/editors/wicked-doc/editor.json +1 -1
  620. package/dist/studio/editors/wicked-doc/index.html +12 -8
  621. package/dist/studio/editors/wicked-insights/editor.json +1 -1
  622. package/dist/studio/editors/wicked-insights/index.html +1 -1
  623. package/dist/studio/editors/wicked-page/editor.json +1 -1
  624. package/dist/studio/editors/wicked-page/index.html +12 -8
  625. package/dist/studio/editors/wicked-video/editor.json +1 -1
  626. package/dist/studio/editors/wicked-video/index.html +1 -1
  627. package/dist/studio/fonts/LICENSE-WickedSans.txt +97 -0
  628. package/dist/studio/index.html +3 -2
  629. package/dist/studio/testid-inventory.json +10850 -6700
  630. package/dist/team/routes.d.ts +31 -172
  631. package/dist/team/routes.d.ts.map +1 -1
  632. package/dist/team/routes.js +31 -8
  633. package/dist/team/routes.js.map +1 -1
  634. package/dist/voice/dashboard.d.ts +35 -313
  635. package/dist/voice/dashboard.d.ts.map +1 -1
  636. package/dist/voice/dashboard.js +10 -10
  637. package/dist/voice/dashboard.js.map +1 -1
  638. package/dist/voice/routes.d.ts +2 -6
  639. package/dist/voice/routes.d.ts.map +1 -1
  640. package/dist/voice/routes.js +2 -2
  641. package/dist/voice/routes.js.map +1 -1
  642. package/dist/watch/checks/check-failed.d.ts +4 -10
  643. package/dist/watch/checks/check-failed.d.ts.map +1 -1
  644. package/dist/watch/checks/check-failed.js +6 -8
  645. package/dist/watch/checks/check-failed.js.map +1 -1
  646. package/dist/watch/checks/claim-vs-evidence.js +3 -3
  647. package/dist/watch/checks/claim-vs-evidence.js.map +1 -1
  648. package/dist/watch/checks/deliver-audit.js +3 -3
  649. package/dist/watch/checks/deliver-audit.js.map +1 -1
  650. package/dist/watch/checks/discovery.d.ts.map +1 -1
  651. package/dist/watch/checks/discovery.js +5 -7
  652. package/dist/watch/checks/discovery.js.map +1 -1
  653. package/dist/watch/checks/lag.d.ts +4 -10
  654. package/dist/watch/checks/lag.d.ts.map +1 -1
  655. package/dist/watch/checks/lag.js +6 -8
  656. package/dist/watch/checks/lag.js.map +1 -1
  657. package/dist/watch/checks/quiet-after-claim.js +3 -3
  658. package/dist/watch/checks/quiet-after-claim.js.map +1 -1
  659. package/dist/watch/checks/scope-drift.js +3 -3
  660. package/dist/watch/checks/scope-drift.js.map +1 -1
  661. package/dist/watch/checks/team-path.js +2 -2
  662. package/dist/watch/checks/team-path.js.map +1 -1
  663. package/dist/watch/checks/ungated.js +3 -3
  664. package/dist/watch/checks/ungated.js.map +1 -1
  665. package/dist/watch/checks/warned-rule.js +3 -3
  666. package/dist/watch/checks/warned-rule.js.map +1 -1
  667. package/dist/watch/loader.d.ts.map +1 -1
  668. package/dist/watch/loader.js +12 -16
  669. package/dist/watch/loader.js.map +1 -1
  670. package/dist/workflow-catalog/build-v2.d.ts +90 -0
  671. package/dist/workflow-catalog/build-v2.d.ts.map +1 -0
  672. package/dist/workflow-catalog/build-v2.js +527 -0
  673. package/dist/workflow-catalog/build-v2.js.map +1 -0
  674. package/dist/workflow-catalog/build.d.ts +2 -0
  675. package/dist/workflow-catalog/build.d.ts.map +1 -1
  676. package/dist/workflow-catalog/build.js +8 -4
  677. package/dist/workflow-catalog/build.js.map +1 -1
  678. package/dist/workflow-catalog/catalog-data-v2.d.ts +12 -0
  679. package/dist/workflow-catalog/catalog-data-v2.d.ts.map +1 -0
  680. package/dist/workflow-catalog/catalog-data-v2.js +2582 -0
  681. package/dist/workflow-catalog/catalog-data-v2.js.map +1 -0
  682. package/dist/workflow-catalog/catalog-data.d.ts +7 -1
  683. package/dist/workflow-catalog/catalog-data.d.ts.map +1 -1
  684. package/dist/workflow-catalog/catalog-data.js +36 -7
  685. package/dist/workflow-catalog/catalog-data.js.map +1 -1
  686. package/dist/workflow-catalog/seeds-v2.d.ts +91 -0
  687. package/dist/workflow-catalog/seeds-v2.d.ts.map +1 -0
  688. package/dist/workflow-catalog/seeds-v2.js +2 -0
  689. package/dist/workflow-catalog/seeds-v2.js.map +1 -0
  690. package/dist/workflow-catalog/shape.d.ts +97 -0
  691. package/dist/workflow-catalog/shape.d.ts.map +1 -0
  692. package/dist/workflow-catalog/shape.js +97 -0
  693. package/dist/workflow-catalog/shape.js.map +1 -0
  694. package/dist/working-doc/service.d.ts.map +1 -1
  695. package/dist/working-doc/service.js +2 -1
  696. package/dist/working-doc/service.js.map +1 -1
  697. package/dist/zod.d.ts +39 -0
  698. package/dist/zod.d.ts.map +1 -0
  699. package/dist/zod.js +197 -0
  700. package/dist/zod.js.map +1 -0
  701. package/endpoint-manifest.json +651 -11
  702. package/package.json +31 -7
  703. package/runners/sqlite-runner.mjs +110 -0
  704. package/dist/studio/assets/WickedSans-Regular-fb698rcD.woff2 +0 -0
  705. package/dist/studio/assets/WickedSans-SemiBold-CD53n1AC.woff2 +0 -0
  706. package/dist/studio/assets/index-BUZ_-Syk.css +0 -32
  707. package/dist/studio/assets/index-u4O_7N-b.js +0 -986
@@ -0,0 +1,563 @@
1
+ /**
2
+ * Tracker links (DES-PM-001 §3.3): which trackers (one project inside one tenant of a registered PM system) are
3
+ * linked to which studio projects and repos. Every route is a HUMAN's only: any other actor, whatever its trust, gets
4
+ * 403 `tracker_links_human_only` (the rule of `knowledge/gate/routes.ts`): a link says "this work is tracked there",
5
+ * and it widens what a project's agents may read.
6
+ *
7
+ * GET /tracker-links?project=&repo= the links of a project and/or a repo (with both: a run's tracker set)
8
+ * POST /tracker-links link a tracker (a direct live lookup first); 201, or 200 when it exists
9
+ * DELETE /tracker-links/:id unlink; the tracker's last link retires it (its estate documents go)
10
+ * GET /sources/:name/trackers one page of the projects the source lists NOW (a person's live read)
11
+ *
12
+ * The links live on the PM source's registry entry (`trackers[]`), written in one registry mutation (a generation,
13
+ * an atomic rename), audited `knowledge.source.tracker_linked` / `tracker_unlinked`, then projected into estate.
14
+ * Access follows the registry at once (the gate reads it on every call); Understand follows the projection.
15
+ */
16
+ import { z } from '../../zod.js';
17
+ import { API_PREFIX } from '../../api/api-prefix.js';
18
+ import { trustAtLeast } from '../../api/auth.js';
19
+ import { MCP_SERVER_NAME_RE } from '../../mcp/classify.js';
20
+ import { configOf, normalizeRegistryFile, pmDescriptorHash } from '../../mcp/registry.js';
21
+ import { McpRegistryCorruptError } from '../../mcp/registry-store.js';
22
+ import { DEFAULT_PROJECT_ID } from '../../projects/default-project.js';
23
+ import { agentMay } from '../gate/access.js';
24
+ import { trackerIdOf, trackerLabel, trackerLinkIdOf, trackersOf } from '../registry/entry.js';
25
+ import { bindingInForce, GITHUB_TENANT, jiraSitesOf, outlineOf, readPayload } from './bindings.js';
26
+ import { projectOptsVia } from './gate-pm.js';
27
+ import { pmEntriesOf } from './set.js';
28
+ import { PROJECTION_UNKNOWN, trackerLinkView } from './view.js';
29
+ const V = API_PREFIX;
30
+ const isHuman = (a) => a.kind === 'human';
31
+ const isHumanOperator = (a) => a.kind === 'human' && trustAtLeast(a, 'operator');
32
+ function humanOnly(reply, actor) {
33
+ return reply.code(403).send({ error: `only a person links trackers to projects and repos, or reads a tracker source's projects; you are ${actor.kind}/${actor.trust}`, code: 'tracker_links_human_only' });
34
+ }
35
+ const TargetSchema = z.discriminatedUnion('kind', [
36
+ z.strictObject({ kind: z.literal('project'), id: z.string().min(1).max(128).regex(/^[A-Za-z0-9_.:-]+$/) }),
37
+ z.strictObject({ kind: z.literal('repo'), id: z.string().min(1).max(128).regex(/^[A-Za-z0-9_.:-]+$/) }),
38
+ ]);
39
+ export const CreateTrackerLinkSchema = z.strictObject({
40
+ source: z.string().min(1).max(63),
41
+ tenant: z.string().min(1).max(256),
42
+ key: z.string().min(1).max(201),
43
+ target: TargetSchema,
44
+ });
45
+ const ListQuery = z.strictObject({ project: z.string().min(1).max(128).optional(), repo: z.string().min(1).max(128).optional() });
46
+ const IssuesQuery = z.strictObject({ project: z.string().min(1).max(128).optional(), repo: z.string().min(1).max(128).optional(), q: z.string().max(200).optional() });
47
+ const SourceTrackersQuery = z.strictObject({ q: z.string().max(200).optional(), cursor: z.string().max(400).optional(), tenant: z.string().max(256).optional() });
48
+ /** A Jira project key, or a GitHub `owner/repo`: one key names one project (no wildcard, JQL or whole site). */
49
+ export function validTrackerKey(system, key) {
50
+ if (system === 'jira')
51
+ return /^[A-Z][A-Z0-9_]{0,19}$/.test(key);
52
+ if (system === 'github')
53
+ return /^[A-Za-z0-9_.-]{1,100}\/[A-Za-z0-9_.-]{1,100}$/.test(key);
54
+ return false;
55
+ }
56
+ const PAGE = 50;
57
+ /** At most this many links per tracker (estate's per-document link bound). */
58
+ export const TRACKER_LINKS_MAX = 200;
59
+ const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
60
+ /** The single JSON payload of a person read (the same rule the projectors use), or `null`. */
61
+ function payload(result) {
62
+ const r = readPayload(result);
63
+ return r.ok ? r.payload : null;
64
+ }
65
+ /**
66
+ * A person read's payload, or why there is none, said so the next attempt is diagnosable: the vendor's error with its
67
+ * HTTP status, or the outline of a shape crew does not know (block types, field names, array lengths; never a value).
68
+ */
69
+ function read(e, tool, result) {
70
+ return readPayload(result, `${e.name} (${tool})`);
71
+ }
72
+ /** Jira sites the credential reaches (`getAccessibleAtlassianResources`): v2 `{resources: [{cloudId, url, products}]}`. */
73
+ async function jiraSites(pm, e) {
74
+ const r = await pm.personCall(e, 'getAccessibleAtlassianResources', {});
75
+ if (!r.ok)
76
+ return r;
77
+ const p = read(e, 'getAccessibleAtlassianResources', r.result);
78
+ if (!p.ok)
79
+ return p;
80
+ const sites = jiraSitesOf(p.payload);
81
+ if (sites === null)
82
+ return { ok: false, code: 'unknown_shape', reason: `${e.name} answered its sites in a shape crew does not know (got ${outlineOf(p.payload)})` };
83
+ return { ok: true, sites: sites.map((s) => ({ ...s, label: trackerLabel(s.label, s.id) })) };
84
+ }
85
+ /** One page of a Jira site's projects (`listJiraProjects`). */
86
+ async function jiraProjects(pm, e, cloudId, q, startAt) {
87
+ // A non-primary operation on the Atlassian v2 server: by name, or through its executeRead meta-tool.
88
+ const r = await pm.personOp(e, 'listJiraProjects', cloudId, { ...(q !== '' ? { searchString: q } : {}), startAt, maxResults: PAGE });
89
+ if (!r.ok)
90
+ return r;
91
+ const pr = read(e, 'listJiraProjects', r.result);
92
+ if (!pr.ok)
93
+ return pr;
94
+ const p = pr.payload;
95
+ const list = Array.isArray(p) ? p : isObj(p) && Array.isArray(p['values']) ? p['values'] : isObj(p) && Array.isArray(p['projects']) ? p['projects'] : null;
96
+ if (list === null)
97
+ return { ok: false, code: 'unknown_shape', reason: `${e.name} answered its projects in a shape crew does not know (got ${outlineOf(p)})` };
98
+ const rows = list.filter(isObj).filter((x) => typeof x['key'] === 'string' && validTrackerKey('jira', x['key'])).map((x) => ({ key: x['key'], label: trackerLabel(x['name'], x['key']) }));
99
+ const more = isObj(p) && p['isLast'] === false ? true : isObj(p) && typeof p['total'] === 'number' ? startAt + list.length < p['total'] : list.length >= PAGE;
100
+ return { ok: true, rows, more };
101
+ }
102
+ /** One page of GitHub repositories (`search_repositories`). */
103
+ async function githubRepos(pm, e, query, page) {
104
+ const r = await pm.personCall(e, 'search_repositories', { query, page, perPage: PAGE });
105
+ if (!r.ok)
106
+ return r;
107
+ const pr = read(e, 'search_repositories', r.result);
108
+ if (!pr.ok)
109
+ return pr;
110
+ const p = pr.payload;
111
+ if (!isObj(p) || !Array.isArray(p['items']))
112
+ return { ok: false, code: 'unknown_shape', reason: `${e.name} answered its repositories in a shape crew does not know (got ${outlineOf(p)})` };
113
+ const rows = p['items'].filter(isObj).filter((x) => typeof x['full_name'] === 'string' && validTrackerKey('github', x['full_name'])).map((x) => ({ key: x['full_name'], label: trackerLabel(x['full_name'], x['full_name']) }));
114
+ const total = typeof p['total_count'] === 'number' ? p['total_count'] : 0;
115
+ return { ok: true, rows, more: page * PAGE < Math.min(total, 1000) };
116
+ }
117
+ const enc = (v) => Buffer.from(JSON.stringify(v), 'utf8').toString('base64url');
118
+ function dec(c) {
119
+ if (c === undefined || c === '')
120
+ return {};
121
+ try {
122
+ const v = JSON.parse(Buffer.from(c, 'base64url').toString('utf8'));
123
+ if (!isObj(v))
124
+ return null;
125
+ // Only this route's own shapes: whole, non-negative offsets (`t`, `s`) or a page from 1 (`p`).
126
+ const keys = Object.keys(v);
127
+ const nat = (x, min) => typeof x === 'number' && Number.isInteger(x) && x >= min && x <= 1_000_000;
128
+ if (keys.every((k) => k === 't' || k === 's') && (v['t'] === undefined || nat(v['t'], 0)) && (v['s'] === undefined || nat(v['s'], 0)))
129
+ return v;
130
+ if (keys.length === 1 && keys[0] === 'p' && nat(v['p'], 1))
131
+ return v;
132
+ return null;
133
+ }
134
+ catch {
135
+ return null;
136
+ }
137
+ }
138
+ /** One page of the projects a PM source lists now. */
139
+ export async function listSourceTrackers(pm, e, q, cursor, onlyTenant) {
140
+ if (e.system === 'github') {
141
+ const page = typeof cursor['p'] === 'number' && cursor['p'] >= 1 ? Math.trunc(cursor['p']) : 1;
142
+ let query = q.trim();
143
+ if (query === '') {
144
+ const me = await pm.personCall(e, 'get_me', {});
145
+ if (!me.ok)
146
+ return me;
147
+ const pr = read(e, 'get_me', me.result);
148
+ if (!pr.ok)
149
+ return pr;
150
+ const p = pr.payload;
151
+ const login = isObj(p) && typeof p['login'] === 'string' ? p['login'] : null;
152
+ if (login === null)
153
+ return { ok: false, code: 'unknown_shape', reason: `${e.name} did not say whose credential it holds (get_me answered ${outlineOf(p)})` };
154
+ query = `user:${login}`;
155
+ }
156
+ else {
157
+ query = `${query.replace(/[^\w./ -]/g, ' ')} in:name`;
158
+ }
159
+ const r = await githubRepos(pm, e, `${query} fork:true`, page);
160
+ if (!r.ok)
161
+ return r;
162
+ return { ok: true, rows: r.rows.map((x) => ({ tenant: GITHUB_TENANT, key: x.key, label: x.label })), next: r.more ? enc({ p: page + 1 }) : null };
163
+ }
164
+ const sites = await jiraSites(pm, e);
165
+ if (!sites.ok)
166
+ return sites;
167
+ const pool = onlyTenant === null ? sites.sites : sites.sites.filter((s) => s.id === onlyTenant);
168
+ let t = typeof cursor['t'] === 'number' ? Math.trunc(cursor['t']) : 0;
169
+ let s = typeof cursor['s'] === 'number' ? Math.trunc(cursor['s']) : 0;
170
+ const rows = [];
171
+ while (t < pool.length && rows.length === 0) {
172
+ const site = pool[t];
173
+ const r = await jiraProjects(pm, e, site.id, q.trim(), s);
174
+ if (!r.ok)
175
+ return r;
176
+ rows.push(...r.rows.map((x) => ({ tenant: site.id, tenantLabel: site.label, key: x.key, label: x.label })));
177
+ if (r.more) {
178
+ s += PAGE;
179
+ return { ok: true, rows, next: enc({ t, s }) };
180
+ }
181
+ t += 1;
182
+ s = 0;
183
+ }
184
+ return { ok: true, rows, next: t < pool.length ? enc({ t, s: 0 }) : null };
185
+ }
186
+ /** The direct live lookup a link needs (§3.3): the tracker's label, or why it cannot be linked. */
187
+ export async function lookupTracker(pm, e, tenant, key) {
188
+ if (!validTrackerKey(e.system, key))
189
+ return { ok: false, status: 422, code: 'tracker_unknown', reason: e.system === 'jira' ? 'a Jira tracker is one project key, such as PROJA' : 'a GitHub tracker is one owner/repo' };
190
+ if (e.system === 'github') {
191
+ if (tenant !== GITHUB_TENANT)
192
+ return { ok: false, status: 422, code: 'tracker_unknown', reason: `a GitHub source's tenant is ${GITHUB_TENANT}` };
193
+ const r = await githubRepos(pm, e, `repo:${key}`, 1);
194
+ if (!r.ok)
195
+ return { ...r, status: 503, code: 'source_unavailable', cause: r.code };
196
+ const hit = r.rows.find((x) => x.key.toLowerCase() === key.toLowerCase());
197
+ if (hit === undefined)
198
+ return { ok: false, status: 422, code: 'tracker_unknown', reason: `${e.name} finds no repository ${key}` };
199
+ return { ok: true, key: hit.key, label: hit.label, tenantLabel: null };
200
+ }
201
+ const sites = await jiraSites(pm, e);
202
+ if (!sites.ok)
203
+ return { ...sites, status: 503, code: 'source_unavailable', cause: sites.code };
204
+ const site = sites.sites.find((s) => s.id === tenant);
205
+ if (site === undefined)
206
+ return { ok: false, status: 422, code: 'tracker_unknown', reason: `${e.name}'s credential reaches no Jira site ${tenant}` };
207
+ // Every page of the key's search, until the exact key is found or the site says it was the last page.
208
+ for (let page = 0; page < 20; page++) {
209
+ const r = await jiraProjects(pm, e, tenant, key, page * PAGE);
210
+ if (!r.ok)
211
+ return { ...r, status: 503, code: 'source_unavailable', cause: r.code };
212
+ const hit = r.rows.find((x) => x.key === key);
213
+ if (hit !== undefined)
214
+ return { ok: true, key: hit.key, label: hit.label, tenantLabel: site.label, siteHost: site.host };
215
+ if (!r.more)
216
+ return { ok: false, status: 422, code: 'tracker_unknown', reason: `${site.label} has no project ${key}` };
217
+ }
218
+ // Pages left that were not read: not a "no such project", which this could not tell.
219
+ return { ok: false, status: 503, code: 'source_unavailable', reason: `${site.label} answered more projects matching ${key} than crew reads at once; try again with the exact key` };
220
+ }
221
+ /**
222
+ * A tracker's value-free structure (§3.4): its issue types and workflow states, mapped to todo/doing/done. Read at
223
+ * link time, best-effort: a tool the server lacks, or an answer this cannot read, leaves that part empty.
224
+ */
225
+ export async function readStructure(pm, e, tenant, key) {
226
+ const names = (p, ...lists) => {
227
+ const l = Array.isArray(p) ? p : isObj(p) ? lists.map((k) => p[k]).find(Array.isArray) : null;
228
+ return Array.isArray(l) ? l.filter(isObj).slice(0, 50) : [];
229
+ };
230
+ const cat = (v) => {
231
+ const k = String(isObj(v) ? (v['key'] ?? '') : (v ?? '')).toLowerCase();
232
+ return k === 'new' || k === 'todo' || k === 'to_do' ? 'todo' : k === 'indeterminate' || k === 'in_progress' ? 'doing' : k === 'done' ? 'done' : null;
233
+ };
234
+ if (e.system === 'github') {
235
+ const [owner] = key.split('/');
236
+ const r = await pm.personCall(e, 'list_issue_types', { owner }).catch(() => null);
237
+ const types = r !== null && r.ok ? names(payload(r.result), 'issue_types', 'types').map((x) => trackerLabel(x['name'], '?')) : [];
238
+ return { issueTypes: types, states: [{ name: 'open', category: 'todo' }, { name: 'closed', category: 'done' }], fields: [] };
239
+ }
240
+ const t = await pm.personOp(e, 'listJiraProjectIssueTypesMetadata', tenant, { projectIdOrKey: key }).catch(() => null);
241
+ const st = await pm.personOp(e, 'listJiraStatuses', tenant, { projectIdOrKey: key }).catch(() => null);
242
+ const types = t !== null && t.ok ? names(payload(t.result), 'issueTypes', 'values') : [];
243
+ // The fields of the first issue type: identifiers, names and value types only (never a value or a default).
244
+ const first = types.find((x) => typeof x['id'] === 'string');
245
+ const f = first === undefined ? null : await pm.personOp(e, 'getJiraIssueTypeMetaWithFields', tenant, { projectIdOrKey: key, issueTypeId: first['id'] }).catch(() => null);
246
+ return {
247
+ issueTypes: types.map((x) => trackerLabel(x['name'], '?')),
248
+ states: st !== null && st.ok ? names(payload(st.result), 'values', 'statuses').map((x) => ({ name: trackerLabel(x['name'], '?'), category: cat(x['statusCategory']) })) : [],
249
+ fields: f !== null && f.ok
250
+ ? names(payload(f.result), 'fields', 'values').map((x) => ({ id: trackerLabel(x['fieldId'] ?? x['key'] ?? x['id'], '?'), name: trackerLabel(x['name'], '?'), type: isObj(x['schema']) ? trackerLabel(x['schema']['type'], '?') : null }))
251
+ : [],
252
+ };
253
+ }
254
+ /** Every link of every PM entry, as stored, with its entry and tracker. */
255
+ function allLinks(entries) {
256
+ const out = [];
257
+ for (const e of entries)
258
+ for (const t of e.trackers)
259
+ for (const l of t.links)
260
+ out.push({ e, t, l });
261
+ return out;
262
+ }
263
+ export function registerTrackerRoutes(app, deps) {
264
+ const projection = deps.projection ?? PROJECTION_UNKNOWN;
265
+ const view = (x) => trackerLinkView({ id: x.e.id, name: x.e.name, system: x.e.system }, x.t, x.l, projection);
266
+ const entries = async () => pmEntriesOf(await deps.store.read());
267
+ app.get(`${V}/tracker-links`, { config: { manifest: { responseType: 'TrackerLinksResponse', statusCodes: [200, 400, 403, 503] } } }, async (req, reply) => {
268
+ const actor = deps.actorOf(req);
269
+ if (!isHuman(actor))
270
+ return humanOnly(reply, actor);
271
+ const q = ListQuery.safeParse(req.query ?? {});
272
+ if (!q.success || (q.data.project === undefined && q.data.repo === undefined))
273
+ return reply.code(400).send({ error: 'name ?project=<id>, ?repo=<id>, or both', code: 'bad_request' });
274
+ if (deps.store === undefined)
275
+ return reply.code(503).send({ error: 'the connector registry is not available on this daemon', code: 'registry_unavailable' });
276
+ let es;
277
+ try {
278
+ es = await entries();
279
+ }
280
+ catch (err) {
281
+ if (err instanceof McpRegistryCorruptError)
282
+ return reply.code(503).send({ error: err.message, code: 'registry_corrupt' });
283
+ throw err;
284
+ }
285
+ const { project, repo } = q.data;
286
+ const all = allLinks(es);
287
+ const own = (t) => (project !== undefined ? t.kind === 'project' && t.id === project : t.kind === 'repo' && t.id === repo);
288
+ const links = all.filter((x) => own(x.l.target)).map(view);
289
+ const viaRepos = [];
290
+ const projects = [];
291
+ const agents = [];
292
+ if (project !== undefined) {
293
+ const repos = new Set();
294
+ try {
295
+ for (const r of await deps.projects.repos(project))
296
+ repos.add(r);
297
+ }
298
+ catch {
299
+ // a membership read that fails shows the project's own links only
300
+ }
301
+ if (repo !== undefined)
302
+ repos.add(repo);
303
+ for (const x of all)
304
+ if (x.l.target.kind === 'repo' && repos.has(x.l.target.id))
305
+ viaRepos.push({ ...view(x), viaRepo: x.l.target.id });
306
+ const named = new Set([...links, ...viaRepos].map((l) => l.source));
307
+ for (const e of es.filter((x) => named.has(x.name))) {
308
+ const src = { enabled: e.enabled, queryable: true };
309
+ agents.push({ source: e.name, see: agentMay(e.access, src, project, 'see'), query: agentMay(e.access, src, project, 'query') });
310
+ }
311
+ }
312
+ else if (repo !== undefined) {
313
+ try {
314
+ for (const id of await deps.projects.ofRepo(repo)) {
315
+ const p = await deps.projects.get(id).catch(() => null);
316
+ if (p !== null)
317
+ projects.push({ id: p.id, name: p.name });
318
+ }
319
+ }
320
+ catch {
321
+ // the reverse read is unavailable: the card says nothing about reach
322
+ }
323
+ }
324
+ const body = { target: { ...(project !== undefined ? { project } : {}), ...(repo !== undefined ? { repo } : {}) }, links, viaRepos, projects, agents };
325
+ return body;
326
+ });
327
+ // §6 step 1: the issues of a launch's tracker set, for "Start a job from an issue" (a person's live read, bound).
328
+ app.get(`${V}/tracker-links/issues`, { config: { manifest: { responseType: 'TrackerIssuesResponse', statusCodes: [200, 400, 403, 503] } } }, async (req, reply) => {
329
+ const actor = deps.actorOf(req);
330
+ // A live read with the source's credential, like the picker and the link lookup: a human operator's.
331
+ if (!isHumanOperator(actor))
332
+ return humanOnly(reply, actor);
333
+ const q = IssuesQuery.safeParse(req.query ?? {});
334
+ if (!q.success || (q.data.project === undefined && q.data.repo === undefined))
335
+ return reply.code(400).send({ error: 'name ?project=<id>, ?repo=<id>, or both', code: 'bad_request' });
336
+ if (deps.store === undefined || deps.pm === undefined)
337
+ return reply.code(503).send({ error: 'the connector registry is not available on this daemon', code: 'registry_unavailable' });
338
+ const pm = deps.pm;
339
+ const es = await entries();
340
+ const set = await pm.trackerSet({ projectId: q.data.project ?? null, repoId: q.data.repo ?? null }, es);
341
+ const text = (q.data.q ?? '').replace(/[^\w\s.#-]/g, ' ').replace(/\s+/g, ' ').trim();
342
+ const out = [];
343
+ for (const t of set.slice(0, 10)) {
344
+ const e = es.find((x) => x.id === t.sourceId);
345
+ const row = {
346
+ trackerId: t.trackerId,
347
+ source: t.source,
348
+ system: t.system,
349
+ tenant: t.tenant,
350
+ key: t.key,
351
+ label: t.label,
352
+ ...(t.tenantLabel !== null ? { tenantLabel: t.tenantLabel } : {}),
353
+ via: t.via.find((v) => v.kind === 'project') ?? t.via[0],
354
+ issues: [],
355
+ };
356
+ out.push(row);
357
+ if (!agentMay(e.access, { enabled: e.enabled, queryable: true }, q.data.project ?? null, 'query')) {
358
+ row.error = 'query_off';
359
+ continue;
360
+ }
361
+ const tool = e.system === 'jira' ? 'searchJiraIssuesUsingJql' : 'search_issues';
362
+ const stored = e.record.tools.find((x) => x.name === tool && x.present);
363
+ const binding = stored === undefined ? null : bindingInForce(e.system, stored);
364
+ if (binding === null) {
365
+ row.error = 'tool_unbound';
366
+ continue;
367
+ }
368
+ const [owner, repo] = t.key.split('/');
369
+ const args = e.system === 'jira'
370
+ ? { cloudId: t.tenant, jql: `${text !== '' ? `text ~ "${text}" ` : ''}ORDER BY updated DESC`, maxResults: 20 }
371
+ : { query: `${text} is:issue is:open`.trim(), owner, repo, perPage: 20 };
372
+ const prepared = binding.bindArgs(args, [{ trackerId: t.trackerId, tenant: t.tenant, key: t.key, siteHost: t.siteHost }]);
373
+ if (!prepared.ok) {
374
+ row.error = prepared.code;
375
+ continue;
376
+ }
377
+ const r = await pm.vendorRead(e, tool, prepared.args, 'person');
378
+ const p = r.ok ? binding.project(r.result, prepared, await projectOptsVia(pm, e, r.credential)) : null;
379
+ if (p === null || !p.ok) {
380
+ row.error = 'unavailable';
381
+ continue;
382
+ }
383
+ // A key two trackers of this set share is qualified, so the reference a launch takes is never ambiguous.
384
+ const shared = e.system === 'jira' && set.filter((x) => x.system === 'jira' && x.key === t.key).length > 1;
385
+ row.issues = p.items.map((i) => ({
386
+ key: i.ref,
387
+ ref: shared ? `${t.source}@${t.tenant}:${i.ref}` : i.ref,
388
+ title: String((e.system === 'jira' ? i.value['summary'] : i.value['title']) ?? ''),
389
+ state: typeof (e.system === 'jira' ? i.value['status'] : i.value['state']) === 'string' ? String(e.system === 'jira' ? i.value['status'] : i.value['state']) : null,
390
+ }));
391
+ }
392
+ const body = { trackers: out };
393
+ return body;
394
+ });
395
+ app.post(`${V}/tracker-links`, { config: { manifest: { requestType: 'CreateTrackerLinkBody', responseType: 'TrackerLink', statusCodes: [200, 201, 400, 403, 404, 409, 422, 503] } } }, async (req, reply) => {
396
+ const actor = deps.actorOf(req);
397
+ if (!isHumanOperator(actor))
398
+ return humanOnly(reply, actor);
399
+ const parsed = CreateTrackerLinkSchema.safeParse(req.body);
400
+ if (!parsed.success)
401
+ return reply.code(400).send({ error: parsed.error.issues.map((i) => `${i.path.join('.') || 'body'}: ${i.message}`).join('; '), code: 'bad_request' });
402
+ if (deps.store === undefined || deps.pm === undefined)
403
+ return reply.code(503).send({ error: 'the connector registry is not available on this daemon', code: 'registry_unavailable' });
404
+ const b = parsed.data;
405
+ if (!MCP_SERVER_NAME_RE.test(b.source))
406
+ return reply.code(404).send({ error: `no source named ${b.source}`, code: 'source_not_found' });
407
+ const file = normalizeRegistryFile(await deps.store.read());
408
+ const rec = file.servers.find((s) => s.name === b.source);
409
+ if (rec === undefined)
410
+ return reply.code(404).send({ error: `no source named ${b.source}`, code: 'source_not_found' });
411
+ const e = pmEntriesOf(file).find((x) => x.name === b.source);
412
+ if (e === undefined)
413
+ return reply.code(409).send({ error: `${b.source} is not a project-management source`, code: 'not_a_tracker' });
414
+ if (b.target.kind === 'project') {
415
+ if (b.target.id === DEFAULT_PROJECT_ID)
416
+ return reply.code(409).send({ error: 'trackers link to a real project, not the synthesised Unfiled one', code: 'default_project' });
417
+ const p = await deps.projects.get(b.target.id).catch(() => null);
418
+ if (p === null)
419
+ return reply.code(404).send({ error: `no project ${b.target.id}`, code: 'project_not_found' });
420
+ if (p.status === 'archived')
421
+ return reply.code(409).send({ error: `${p.name} is archived`, code: 'project_archived' });
422
+ }
423
+ else if (!(await deps.projects.allRepos()).includes(b.target.id)) {
424
+ return reply.code(404).send({ error: `no repo ${b.target.id}`, code: 'repo_not_found' });
425
+ }
426
+ const found = await lookupTracker(deps.pm, e, b.tenant, b.key);
427
+ if (!found.ok)
428
+ return reply.code(found.status).send({ error: found.reason, code: found.code, ...(found.cause !== undefined ? { cause: found.cause } : {}) });
429
+ const structure = await readStructure(deps.pm, e, b.tenant, found.key);
430
+ const trackerId = trackerIdOf(e.id, b.tenant, found.key);
431
+ const target = b.target.kind === 'project' ? { kind: 'project', id: b.target.id } : { kind: 'repo', id: b.target.id };
432
+ const linkId = trackerLinkIdOf(trackerId, target);
433
+ const stamp = new Date().toISOString();
434
+ let out;
435
+ try {
436
+ out = await deps.store.mutate((f) => {
437
+ const s = f.servers.find((x) => x.name === b.source);
438
+ // Saved again as another entry (a new id), or re-pointed at another server, since the lookup: nothing is linked.
439
+ if (s === undefined || s.id !== e.id || pmDescriptorHash(configOf(s)) !== pmDescriptorHash(configOf(e.record)))
440
+ return { gone: true };
441
+ const trackers = trackersOf(s);
442
+ let t = trackers.find((x) => x.id === trackerId);
443
+ if (t === undefined) {
444
+ t = { id: trackerId, tenant: b.tenant, tenantLabel: found.tenantLabel, siteHost: found.siteHost ?? null, key: found.key, label: found.label, links: [], structure };
445
+ trackers.push(t);
446
+ }
447
+ else {
448
+ t.structure = structure;
449
+ t.label = found.label;
450
+ if (found.tenantLabel !== null)
451
+ t.tenantLabel = found.tenantLabel;
452
+ if (found.siteHost != null)
453
+ t.siteHost = found.siteHost;
454
+ }
455
+ // estate bounds a document's links (200): one tracker holds at most TRACKER_LINKS_MAX.
456
+ if (!t.links.some((l) => l.id === linkId) && t.links.length >= TRACKER_LINKS_MAX)
457
+ return { full: true };
458
+ let link = t.links.find((l) => l.id === linkId);
459
+ const created = link === undefined;
460
+ if (link === undefined) {
461
+ link = { id: linkId, target, linkedAt: stamp, linkedBy: actor.id };
462
+ t.links.push(link);
463
+ }
464
+ s.trackers = trackers;
465
+ if (s.retired !== undefined)
466
+ s.retired = s.retired.filter((r) => r.id !== trackerId);
467
+ s.updatedAt = stamp;
468
+ return { created, tracker: structuredClone(t), link: structuredClone(link) };
469
+ });
470
+ }
471
+ catch (err) {
472
+ if (err instanceof McpRegistryCorruptError)
473
+ return reply.code(503).send({ error: err.message, code: 'registry_corrupt' });
474
+ throw err;
475
+ }
476
+ if ('gone' in out)
477
+ return reply.code(409).send({ error: `${b.source} was removed or saved again while linking; nothing was linked: try again`, code: 'source_changed' });
478
+ if ('full' in out)
479
+ return reply.code(409).send({ error: `${found.key} already has ${TRACKER_LINKS_MAX} links`, code: 'too_many_links' });
480
+ if (out.created)
481
+ deps.audit.record('knowledge.source.tracker_linked', actor, { detail: { source: b.source, tenant: b.tenant, key: found.key, target } });
482
+ // Projected either way: a link made again may carry a new label.
483
+ deps.changed?.(b.source, trackerId);
484
+ return reply.code(out.created ? 201 : 200).send(view({ e, t: out.tracker, l: out.link }));
485
+ });
486
+ app.delete(`${V}/tracker-links/:id`, { config: { manifest: { statusCodes: [204, 403, 404, 503] } } }, async (req, reply) => {
487
+ const actor = deps.actorOf(req);
488
+ if (!isHumanOperator(actor))
489
+ return humanOnly(reply, actor);
490
+ if (deps.store === undefined)
491
+ return reply.code(503).send({ error: 'the connector registry is not available on this daemon', code: 'registry_unavailable' });
492
+ const id = req.params.id;
493
+ if (!/^tl_[0-9a-f]{16}$/.test(id))
494
+ return reply.code(404).send({ error: `no tracker link ${id}`, code: 'not_found' });
495
+ const stamp = new Date().toISOString();
496
+ let out;
497
+ try {
498
+ out = await deps.store.mutate((f) => {
499
+ for (const s of normalizeRegistryFile(f).servers) {
500
+ const trackers = trackersOf(s);
501
+ for (const t of trackers) {
502
+ const l = t.links.find((x) => x.id === id);
503
+ if (l === undefined)
504
+ continue;
505
+ t.links = t.links.filter((x) => x.id !== id);
506
+ const kept = trackers.filter((x) => x.links.length > 0);
507
+ s.trackers = kept;
508
+ // The tracker's last link: it is retired until estate takes its empty generation (its documents go).
509
+ if (t.links.length === 0)
510
+ s.retired = [...(s.retired ?? []).filter((r) => r.id !== t.id), { id: t.id, since: stamp }];
511
+ s.updatedAt = stamp;
512
+ return { source: s.name, tenant: t.tenant, key: t.key, target: l.target, trackerId: t.id };
513
+ }
514
+ }
515
+ return null;
516
+ });
517
+ }
518
+ catch (err) {
519
+ if (err instanceof McpRegistryCorruptError)
520
+ return reply.code(503).send({ error: err.message, code: 'registry_corrupt' });
521
+ throw err;
522
+ }
523
+ if (out === null)
524
+ return reply.code(404).send({ error: `no tracker link ${id}`, code: 'not_found' });
525
+ deps.audit.record('knowledge.source.tracker_unlinked', actor, { detail: { source: out.source, tenant: out.tenant, key: out.key, target: out.target } });
526
+ deps.changed?.(out.source, out.trackerId);
527
+ return reply.code(204).send();
528
+ });
529
+ app.get(`${V}/sources/:name/trackers`, { config: { manifest: { responseType: 'SourceTrackersResponse', statusCodes: [200, 400, 403, 404, 409, 503] } } }, async (req, reply) => {
530
+ const actor = deps.actorOf(req);
531
+ if (!isHumanOperator(actor))
532
+ return humanOnly(reply, actor);
533
+ const q = SourceTrackersQuery.safeParse(req.query ?? {});
534
+ const cursor = q.success ? dec(q.data.cursor) : null;
535
+ if (!q.success || cursor === null)
536
+ return reply.code(400).send({ error: 'q is at most 200 characters; cursor is a cursor this route answered', code: 'bad_request' });
537
+ if (deps.store === undefined || deps.pm === undefined)
538
+ return reply.code(503).send({ error: 'the connector registry is not available on this daemon', code: 'registry_unavailable' });
539
+ if (!MCP_SERVER_NAME_RE.test(req.params.name))
540
+ return reply.code(404).send({ error: `no source named ${req.params.name}`, code: 'source_not_found' });
541
+ const file = normalizeRegistryFile(await deps.store.read());
542
+ if (!file.servers.some((s) => s.name === req.params.name))
543
+ return reply.code(404).send({ error: `no source named ${req.params.name}`, code: 'source_not_found' });
544
+ const e = pmEntriesOf(file).find((x) => x.name === req.params.name);
545
+ if (e === undefined)
546
+ return reply.code(409).send({ error: `${req.params.name} is not a project-management source`, code: 'not_a_tracker' });
547
+ const page = await listSourceTrackers(deps.pm, e, q.data.q ?? '', cursor, q.data.tenant ?? null);
548
+ // `cause` is the lister's own class (vendor_error, unknown_shape, unavailable, secret_missing, …): the reason names it.
549
+ if (!page.ok)
550
+ return reply.code(503).send({ error: page.reason, code: 'source_unavailable', cause: page.code });
551
+ const links = allLinks([e]);
552
+ const body = {
553
+ name: e.name,
554
+ trackers: page.rows.map((r) => ({
555
+ ...r,
556
+ links: links.filter((x) => x.t.tenant === r.tenant && x.t.key.toLowerCase() === r.key.toLowerCase()).map(view),
557
+ })),
558
+ next: page.next,
559
+ };
560
+ return body;
561
+ });
562
+ }
563
+ //# sourceMappingURL=routes.js.map