@mastra/factory 0.0.0-aggregate-trace-20261015182851

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 (926) hide show
  1. package/LICENSE.md +32 -0
  2. package/README.md +671 -0
  3. package/dist/auth.d.ts +201 -0
  4. package/dist/auth.d.ts.map +1 -0
  5. package/dist/auth.js +623 -0
  6. package/dist/auth.js.map +1 -0
  7. package/dist/boards/define-board.d.ts +111 -0
  8. package/dist/boards/define-board.d.ts.map +1 -0
  9. package/dist/boards/define-board.js +156 -0
  10. package/dist/boards/define-board.js.map +1 -0
  11. package/dist/boards/index.d.ts +14 -0
  12. package/dist/boards/index.d.ts.map +1 -0
  13. package/dist/boards/index.js +21 -0
  14. package/dist/boards/index.js.map +1 -0
  15. package/dist/boards/registry.d.ts +16 -0
  16. package/dist/boards/registry.d.ts.map +1 -0
  17. package/dist/boards/registry.js +25 -0
  18. package/dist/boards/registry.js.map +1 -0
  19. package/dist/boards/relocate.d.ts +21 -0
  20. package/dist/boards/relocate.d.ts.map +1 -0
  21. package/dist/boards/relocate.js +58 -0
  22. package/dist/boards/relocate.js.map +1 -0
  23. package/dist/boards/review.d.ts +6 -0
  24. package/dist/boards/review.d.ts.map +1 -0
  25. package/dist/boards/review.js +104 -0
  26. package/dist/boards/review.js.map +1 -0
  27. package/dist/boards/semantics.d.ts +68 -0
  28. package/dist/boards/semantics.d.ts.map +1 -0
  29. package/dist/boards/semantics.js +119 -0
  30. package/dist/boards/semantics.js.map +1 -0
  31. package/dist/boards/transition-policy.d.ts +67 -0
  32. package/dist/boards/transition-policy.d.ts.map +1 -0
  33. package/dist/boards/transition-policy.js +36 -0
  34. package/dist/boards/transition-policy.js.map +1 -0
  35. package/dist/boards/work-tool-rules.d.ts +8 -0
  36. package/dist/boards/work-tool-rules.d.ts.map +1 -0
  37. package/dist/boards/work-tool-rules.js +20 -0
  38. package/dist/boards/work-tool-rules.js.map +1 -0
  39. package/dist/boards/work-transition-policy.d.ts +3 -0
  40. package/dist/boards/work-transition-policy.d.ts.map +1 -0
  41. package/dist/boards/work-transition-policy.js +46 -0
  42. package/dist/boards/work-transition-policy.js.map +1 -0
  43. package/dist/boards/work.d.ts +4 -0
  44. package/dist/boards/work.d.ts.map +1 -0
  45. package/dist/boards/work.js +222 -0
  46. package/dist/boards/work.js.map +1 -0
  47. package/dist/capabilities/connection.d.ts +9 -0
  48. package/dist/capabilities/connection.d.ts.map +1 -0
  49. package/dist/capabilities/connection.js +1 -0
  50. package/dist/capabilities/intake.d.ts +153 -0
  51. package/dist/capabilities/intake.d.ts.map +1 -0
  52. package/dist/capabilities/intake.js +1 -0
  53. package/dist/capabilities/version-control.d.ts +268 -0
  54. package/dist/capabilities/version-control.d.ts.map +1 -0
  55. package/dist/capabilities/version-control.js +1 -0
  56. package/dist/environment/build-runner.d.ts +72 -0
  57. package/dist/environment/build-runner.d.ts.map +1 -0
  58. package/dist/environment/build-runner.js +131 -0
  59. package/dist/environment/build-runner.js.map +1 -0
  60. package/dist/environment/build-schedule.d.ts +40 -0
  61. package/dist/environment/build-schedule.d.ts.map +1 -0
  62. package/dist/environment/build-schedule.js +94 -0
  63. package/dist/environment/build-schedule.js.map +1 -0
  64. package/dist/environment/build-workflow.d.ts +62 -0
  65. package/dist/environment/build-workflow.d.ts.map +1 -0
  66. package/dist/environment/build-workflow.js +149 -0
  67. package/dist/environment/build-workflow.js.map +1 -0
  68. package/dist/environment/build.d.ts +111 -0
  69. package/dist/environment/build.d.ts.map +1 -0
  70. package/dist/environment/build.js +344 -0
  71. package/dist/environment/build.js.map +1 -0
  72. package/dist/environment/heads.d.ts +36 -0
  73. package/dist/environment/heads.d.ts.map +1 -0
  74. package/dist/environment/heads.js +60 -0
  75. package/dist/environment/heads.js.map +1 -0
  76. package/dist/factory.d.ts +225 -0
  77. package/dist/factory.d.ts.map +1 -0
  78. package/dist/factory.js +1006 -0
  79. package/dist/factory.js.map +1 -0
  80. package/dist/feed-events.d.ts +13 -0
  81. package/dist/feed-events.d.ts.map +1 -0
  82. package/dist/feed-events.js +25 -0
  83. package/dist/feed-events.js.map +1 -0
  84. package/dist/index.d.ts +22 -0
  85. package/dist/index.d.ts.map +1 -0
  86. package/dist/index.js +15 -0
  87. package/dist/integrations/base.d.ts +302 -0
  88. package/dist/integrations/base.d.ts.map +1 -0
  89. package/dist/integrations/base.js +1 -0
  90. package/dist/integrations/github/acceptance-labels.d.ts +16 -0
  91. package/dist/integrations/github/acceptance-labels.d.ts.map +1 -0
  92. package/dist/integrations/github/acceptance-labels.js +55 -0
  93. package/dist/integrations/github/acceptance-labels.js.map +1 -0
  94. package/dist/integrations/github/app-identity.d.ts +43 -0
  95. package/dist/integrations/github/app-identity.d.ts.map +1 -0
  96. package/dist/integrations/github/app-identity.js +62 -0
  97. package/dist/integrations/github/app-identity.js.map +1 -0
  98. package/dist/integrations/github/commits.d.ts +40 -0
  99. package/dist/integrations/github/commits.d.ts.map +1 -0
  100. package/dist/integrations/github/commits.js +48 -0
  101. package/dist/integrations/github/commits.js.map +1 -0
  102. package/dist/integrations/github/config.d.ts +60 -0
  103. package/dist/integrations/github/config.d.ts.map +1 -0
  104. package/dist/integrations/github/config.js +42 -0
  105. package/dist/integrations/github/config.js.map +1 -0
  106. package/dist/integrations/github/default-rules.d.ts +218 -0
  107. package/dist/integrations/github/default-rules.d.ts.map +1 -0
  108. package/dist/integrations/github/default-rules.js +296 -0
  109. package/dist/integrations/github/default-rules.js.map +1 -0
  110. package/dist/integrations/github/integration.d.ts +270 -0
  111. package/dist/integrations/github/integration.d.ts.map +1 -0
  112. package/dist/integrations/github/integration.js +1375 -0
  113. package/dist/integrations/github/integration.js.map +1 -0
  114. package/dist/integrations/github/issue-reconciler.d.ts +28 -0
  115. package/dist/integrations/github/issue-reconciler.d.ts.map +1 -0
  116. package/dist/integrations/github/issue-reconciler.js +138 -0
  117. package/dist/integrations/github/issue-reconciler.js.map +1 -0
  118. package/dist/integrations/github/pat.d.ts +38 -0
  119. package/dist/integrations/github/pat.d.ts.map +1 -0
  120. package/dist/integrations/github/pat.js +59 -0
  121. package/dist/integrations/github/pat.js.map +1 -0
  122. package/dist/integrations/github/provenance.d.ts +34 -0
  123. package/dist/integrations/github/provenance.d.ts.map +1 -0
  124. package/dist/integrations/github/provenance.js +91 -0
  125. package/dist/integrations/github/provenance.js.map +1 -0
  126. package/dist/integrations/github/reconcile-worker.d.ts +45 -0
  127. package/dist/integrations/github/reconcile-worker.d.ts.map +1 -0
  128. package/dist/integrations/github/reconcile-worker.js +189 -0
  129. package/dist/integrations/github/reconcile-worker.js.map +1 -0
  130. package/dist/integrations/github/reconciliation-config.d.ts +3 -0
  131. package/dist/integrations/github/reconciliation-config.d.ts.map +1 -0
  132. package/dist/integrations/github/reconciliation-config.js +19 -0
  133. package/dist/integrations/github/reconciliation-config.js.map +1 -0
  134. package/dist/integrations/github/routes.d.ts +90 -0
  135. package/dist/integrations/github/routes.d.ts.map +1 -0
  136. package/dist/integrations/github/routes.js +1362 -0
  137. package/dist/integrations/github/routes.js.map +1 -0
  138. package/dist/integrations/github/rules.d.ts +173 -0
  139. package/dist/integrations/github/rules.d.ts.map +1 -0
  140. package/dist/integrations/github/rules.js +1021 -0
  141. package/dist/integrations/github/rules.js.map +1 -0
  142. package/dist/integrations/github/sandbox-release.d.ts +25 -0
  143. package/dist/integrations/github/sandbox-release.d.ts.map +1 -0
  144. package/dist/integrations/github/sandbox-release.js +38 -0
  145. package/dist/integrations/github/sandbox-release.js.map +1 -0
  146. package/dist/integrations/github/sandbox.d.ts +234 -0
  147. package/dist/integrations/github/sandbox.d.ts.map +1 -0
  148. package/dist/integrations/github/sandbox.js +947 -0
  149. package/dist/integrations/github/sandbox.js.map +1 -0
  150. package/dist/integrations/github/session-subscriptions.d.ts +28 -0
  151. package/dist/integrations/github/session-subscriptions.d.ts.map +1 -0
  152. package/dist/integrations/github/session-subscriptions.js +283 -0
  153. package/dist/integrations/github/session-subscriptions.js.map +1 -0
  154. package/dist/integrations/github/settle-or-abort.d.ts +7 -0
  155. package/dist/integrations/github/settle-or-abort.d.ts.map +1 -0
  156. package/dist/integrations/github/settle-or-abort.js +25 -0
  157. package/dist/integrations/github/settle-or-abort.js.map +1 -0
  158. package/dist/integrations/github/stale-reviews.d.ts +22 -0
  159. package/dist/integrations/github/stale-reviews.d.ts.map +1 -0
  160. package/dist/integrations/github/stale-reviews.js +70 -0
  161. package/dist/integrations/github/stale-reviews.js.map +1 -0
  162. package/dist/integrations/github/subscriptions.d.ts +54 -0
  163. package/dist/integrations/github/subscriptions.d.ts.map +1 -0
  164. package/dist/integrations/github/subscriptions.js +64 -0
  165. package/dist/integrations/github/subscriptions.js.map +1 -0
  166. package/dist/integrations/github/token-refresh.d.ts +31 -0
  167. package/dist/integrations/github/token-refresh.d.ts.map +1 -0
  168. package/dist/integrations/github/token-refresh.js +42 -0
  169. package/dist/integrations/github/token-refresh.js.map +1 -0
  170. package/dist/integrations/github/webhook.d.ts +139 -0
  171. package/dist/integrations/github/webhook.d.ts.map +1 -0
  172. package/dist/integrations/github/webhook.js +432 -0
  173. package/dist/integrations/github/webhook.js.map +1 -0
  174. package/dist/integrations/gitlab/agent-tools.d.ts +14 -0
  175. package/dist/integrations/gitlab/agent-tools.d.ts.map +1 -0
  176. package/dist/integrations/gitlab/agent-tools.js +42 -0
  177. package/dist/integrations/gitlab/agent-tools.js.map +1 -0
  178. package/dist/integrations/gitlab/api.d.ts +222 -0
  179. package/dist/integrations/gitlab/api.d.ts.map +1 -0
  180. package/dist/integrations/gitlab/api.js +274 -0
  181. package/dist/integrations/gitlab/api.js.map +1 -0
  182. package/dist/integrations/gitlab/default-rules.d.ts +125 -0
  183. package/dist/integrations/gitlab/default-rules.d.ts.map +1 -0
  184. package/dist/integrations/gitlab/default-rules.js +180 -0
  185. package/dist/integrations/gitlab/default-rules.js.map +1 -0
  186. package/dist/integrations/gitlab/integration.d.ts +138 -0
  187. package/dist/integrations/gitlab/integration.d.ts.map +1 -0
  188. package/dist/integrations/gitlab/integration.js +705 -0
  189. package/dist/integrations/gitlab/integration.js.map +1 -0
  190. package/dist/integrations/gitlab/issue-reconciler.d.ts +6 -0
  191. package/dist/integrations/gitlab/issue-reconciler.d.ts.map +1 -0
  192. package/dist/integrations/gitlab/issue-reconciler.js +123 -0
  193. package/dist/integrations/gitlab/issue-reconciler.js.map +1 -0
  194. package/dist/integrations/gitlab/merge-request-reconciler.d.ts +6 -0
  195. package/dist/integrations/gitlab/merge-request-reconciler.d.ts.map +1 -0
  196. package/dist/integrations/gitlab/merge-request-reconciler.js +267 -0
  197. package/dist/integrations/gitlab/merge-request-reconciler.js.map +1 -0
  198. package/dist/integrations/gitlab/reconciler.d.ts +5 -0
  199. package/dist/integrations/gitlab/reconciler.d.ts.map +1 -0
  200. package/dist/integrations/gitlab/reconciler.js +31 -0
  201. package/dist/integrations/gitlab/reconciler.js.map +1 -0
  202. package/dist/integrations/gitlab/reconciliation-config.d.ts +3 -0
  203. package/dist/integrations/gitlab/reconciliation-config.d.ts.map +1 -0
  204. package/dist/integrations/gitlab/reconciliation-config.js +17 -0
  205. package/dist/integrations/gitlab/reconciliation-config.js.map +1 -0
  206. package/dist/integrations/gitlab/routes.d.ts +20 -0
  207. package/dist/integrations/gitlab/routes.d.ts.map +1 -0
  208. package/dist/integrations/gitlab/routes.js +474 -0
  209. package/dist/integrations/gitlab/routes.js.map +1 -0
  210. package/dist/integrations/gitlab/rules.d.ts +35 -0
  211. package/dist/integrations/gitlab/rules.d.ts.map +1 -0
  212. package/dist/integrations/gitlab/rules.js +502 -0
  213. package/dist/integrations/gitlab/rules.js.map +1 -0
  214. package/dist/integrations/gitlab/session-subscriptions.d.ts +32 -0
  215. package/dist/integrations/gitlab/session-subscriptions.d.ts.map +1 -0
  216. package/dist/integrations/gitlab/session-subscriptions.js +193 -0
  217. package/dist/integrations/gitlab/session-subscriptions.js.map +1 -0
  218. package/dist/integrations/gitlab/subscriptions.d.ts +70 -0
  219. package/dist/integrations/gitlab/subscriptions.d.ts.map +1 -0
  220. package/dist/integrations/gitlab/subscriptions.js +76 -0
  221. package/dist/integrations/gitlab/subscriptions.js.map +1 -0
  222. package/dist/integrations/gitlab/version-control.d.ts +16 -0
  223. package/dist/integrations/gitlab/version-control.d.ts.map +1 -0
  224. package/dist/integrations/gitlab/version-control.js +621 -0
  225. package/dist/integrations/gitlab/version-control.js.map +1 -0
  226. package/dist/integrations/gitlab/webhook-dispatch.d.ts +75 -0
  227. package/dist/integrations/gitlab/webhook-dispatch.d.ts.map +1 -0
  228. package/dist/integrations/gitlab/webhook-dispatch.js +235 -0
  229. package/dist/integrations/gitlab/webhook-dispatch.js.map +1 -0
  230. package/dist/integrations/gitlab/webhook.d.ts +72 -0
  231. package/dist/integrations/gitlab/webhook.d.ts.map +1 -0
  232. package/dist/integrations/gitlab/webhook.js +201 -0
  233. package/dist/integrations/gitlab/webhook.js.map +1 -0
  234. package/dist/integrations/incidentio/agent-tools.d.ts +49 -0
  235. package/dist/integrations/incidentio/agent-tools.d.ts.map +1 -0
  236. package/dist/integrations/incidentio/agent-tools.js +90 -0
  237. package/dist/integrations/incidentio/agent-tools.js.map +1 -0
  238. package/dist/integrations/incidentio/api.d.ts +400 -0
  239. package/dist/integrations/incidentio/api.d.ts.map +1 -0
  240. package/dist/integrations/incidentio/api.js +192 -0
  241. package/dist/integrations/incidentio/api.js.map +1 -0
  242. package/dist/integrations/incidentio/claim.d.ts +8 -0
  243. package/dist/integrations/incidentio/claim.d.ts.map +1 -0
  244. package/dist/integrations/incidentio/claim.js +14 -0
  245. package/dist/integrations/incidentio/claim.js.map +1 -0
  246. package/dist/integrations/incidentio/default-rules.d.ts +46 -0
  247. package/dist/integrations/incidentio/default-rules.d.ts.map +1 -0
  248. package/dist/integrations/incidentio/default-rules.js +68 -0
  249. package/dist/integrations/incidentio/default-rules.js.map +1 -0
  250. package/dist/integrations/incidentio/intake.d.ts +10 -0
  251. package/dist/integrations/incidentio/intake.d.ts.map +1 -0
  252. package/dist/integrations/incidentio/intake.js +307 -0
  253. package/dist/integrations/incidentio/intake.js.map +1 -0
  254. package/dist/integrations/incidentio/integration.d.ts +63 -0
  255. package/dist/integrations/incidentio/integration.d.ts.map +1 -0
  256. package/dist/integrations/incidentio/integration.js +141 -0
  257. package/dist/integrations/incidentio/integration.js.map +1 -0
  258. package/dist/integrations/incidentio/issue-reconciler.d.ts +10 -0
  259. package/dist/integrations/incidentio/issue-reconciler.d.ts.map +1 -0
  260. package/dist/integrations/incidentio/issue-reconciler.js +75 -0
  261. package/dist/integrations/incidentio/issue-reconciler.js.map +1 -0
  262. package/dist/integrations/incidentio/reconciliation-config.d.ts +3 -0
  263. package/dist/integrations/incidentio/reconciliation-config.d.ts.map +1 -0
  264. package/dist/integrations/incidentio/reconciliation-config.js +17 -0
  265. package/dist/integrations/incidentio/reconciliation-config.js.map +1 -0
  266. package/dist/integrations/incidentio/routes.d.ts +76 -0
  267. package/dist/integrations/incidentio/routes.d.ts.map +1 -0
  268. package/dist/integrations/incidentio/routes.js +249 -0
  269. package/dist/integrations/incidentio/routes.js.map +1 -0
  270. package/dist/integrations/incidentio/rules.d.ts +55 -0
  271. package/dist/integrations/incidentio/rules.d.ts.map +1 -0
  272. package/dist/integrations/incidentio/rules.js +189 -0
  273. package/dist/integrations/incidentio/rules.js.map +1 -0
  274. package/dist/integrations/issue-reconcile-worker.d.ts +19 -0
  275. package/dist/integrations/issue-reconcile-worker.d.ts.map +1 -0
  276. package/dist/integrations/issue-reconcile-worker.js +97 -0
  277. package/dist/integrations/issue-reconcile-worker.js.map +1 -0
  278. package/dist/integrations/issue-reconciler.d.ts +51 -0
  279. package/dist/integrations/issue-reconciler.d.ts.map +1 -0
  280. package/dist/integrations/issue-reconciler.js +158 -0
  281. package/dist/integrations/issue-reconciler.js.map +1 -0
  282. package/dist/integrations/jira/adf.d.ts +26 -0
  283. package/dist/integrations/jira/adf.d.ts.map +1 -0
  284. package/dist/integrations/jira/adf.js +73 -0
  285. package/dist/integrations/jira/adf.js.map +1 -0
  286. package/dist/integrations/jira/agent-tools.d.ts +45 -0
  287. package/dist/integrations/jira/agent-tools.d.ts.map +1 -0
  288. package/dist/integrations/jira/agent-tools.js +87 -0
  289. package/dist/integrations/jira/agent-tools.js.map +1 -0
  290. package/dist/integrations/jira/api.d.ts +157 -0
  291. package/dist/integrations/jira/api.d.ts.map +1 -0
  292. package/dist/integrations/jira/api.js +141 -0
  293. package/dist/integrations/jira/api.js.map +1 -0
  294. package/dist/integrations/jira/claim.d.ts +9 -0
  295. package/dist/integrations/jira/claim.d.ts.map +1 -0
  296. package/dist/integrations/jira/claim.js +15 -0
  297. package/dist/integrations/jira/claim.js.map +1 -0
  298. package/dist/integrations/jira/default-rules.d.ts +47 -0
  299. package/dist/integrations/jira/default-rules.d.ts.map +1 -0
  300. package/dist/integrations/jira/default-rules.js +69 -0
  301. package/dist/integrations/jira/default-rules.js.map +1 -0
  302. package/dist/integrations/jira/integration.d.ts +114 -0
  303. package/dist/integrations/jira/integration.d.ts.map +1 -0
  304. package/dist/integrations/jira/integration.js +407 -0
  305. package/dist/integrations/jira/integration.js.map +1 -0
  306. package/dist/integrations/jira/issue-reconciler.d.ts +10 -0
  307. package/dist/integrations/jira/issue-reconciler.d.ts.map +1 -0
  308. package/dist/integrations/jira/issue-reconciler.js +70 -0
  309. package/dist/integrations/jira/issue-reconciler.js.map +1 -0
  310. package/dist/integrations/jira/reconciliation-config.d.ts +3 -0
  311. package/dist/integrations/jira/reconciliation-config.d.ts.map +1 -0
  312. package/dist/integrations/jira/reconciliation-config.js +17 -0
  313. package/dist/integrations/jira/reconciliation-config.js.map +1 -0
  314. package/dist/integrations/jira/routes.d.ts +54 -0
  315. package/dist/integrations/jira/routes.d.ts.map +1 -0
  316. package/dist/integrations/jira/routes.js +260 -0
  317. package/dist/integrations/jira/routes.js.map +1 -0
  318. package/dist/integrations/jira/rules.d.ts +57 -0
  319. package/dist/integrations/jira/rules.d.ts.map +1 -0
  320. package/dist/integrations/jira/rules.js +189 -0
  321. package/dist/integrations/jira/rules.js.map +1 -0
  322. package/dist/integrations/linear/agent-tools.d.ts +34 -0
  323. package/dist/integrations/linear/agent-tools.d.ts.map +1 -0
  324. package/dist/integrations/linear/agent-tools.js +87 -0
  325. package/dist/integrations/linear/agent-tools.js.map +1 -0
  326. package/dist/integrations/linear/claim.d.ts +8 -0
  327. package/dist/integrations/linear/claim.d.ts.map +1 -0
  328. package/dist/integrations/linear/claim.js +14 -0
  329. package/dist/integrations/linear/claim.js.map +1 -0
  330. package/dist/integrations/linear/default-rules.d.ts +46 -0
  331. package/dist/integrations/linear/default-rules.d.ts.map +1 -0
  332. package/dist/integrations/linear/default-rules.js +70 -0
  333. package/dist/integrations/linear/default-rules.js.map +1 -0
  334. package/dist/integrations/linear/integration.d.ts +260 -0
  335. package/dist/integrations/linear/integration.d.ts.map +1 -0
  336. package/dist/integrations/linear/integration.js +900 -0
  337. package/dist/integrations/linear/integration.js.map +1 -0
  338. package/dist/integrations/linear/issue-reconciler.d.ts +8 -0
  339. package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -0
  340. package/dist/integrations/linear/issue-reconciler.js +73 -0
  341. package/dist/integrations/linear/issue-reconciler.js.map +1 -0
  342. package/dist/integrations/linear/reconciliation-config.d.ts +3 -0
  343. package/dist/integrations/linear/reconciliation-config.d.ts.map +1 -0
  344. package/dist/integrations/linear/reconciliation-config.js +21 -0
  345. package/dist/integrations/linear/reconciliation-config.js.map +1 -0
  346. package/dist/integrations/linear/routes.d.ts +81 -0
  347. package/dist/integrations/linear/routes.d.ts.map +1 -0
  348. package/dist/integrations/linear/routes.js +380 -0
  349. package/dist/integrations/linear/routes.js.map +1 -0
  350. package/dist/integrations/linear/rules.d.ts +54 -0
  351. package/dist/integrations/linear/rules.d.ts.map +1 -0
  352. package/dist/integrations/linear/rules.js +189 -0
  353. package/dist/integrations/linear/rules.js.map +1 -0
  354. package/dist/integrations/linear/storage.d.ts +65 -0
  355. package/dist/integrations/linear/storage.d.ts.map +1 -0
  356. package/dist/integrations/linear/storage.js +1 -0
  357. package/dist/integrations/platform/api-client.d.ts +26 -0
  358. package/dist/integrations/platform/api-client.d.ts.map +1 -0
  359. package/dist/integrations/platform/api-client.js +177 -0
  360. package/dist/integrations/platform/api-client.js.map +1 -0
  361. package/dist/integrations/platform/connect/routes.d.ts +39 -0
  362. package/dist/integrations/platform/connect/routes.d.ts.map +1 -0
  363. package/dist/integrations/platform/connect/routes.js +133 -0
  364. package/dist/integrations/platform/connect/routes.js.map +1 -0
  365. package/dist/integrations/platform/github/event-worker.d.ts +58 -0
  366. package/dist/integrations/platform/github/event-worker.d.ts.map +1 -0
  367. package/dist/integrations/platform/github/event-worker.js +449 -0
  368. package/dist/integrations/platform/github/event-worker.js.map +1 -0
  369. package/dist/integrations/platform/github/integration.d.ts +89 -0
  370. package/dist/integrations/platform/github/integration.d.ts.map +1 -0
  371. package/dist/integrations/platform/github/integration.js +1266 -0
  372. package/dist/integrations/platform/github/integration.js.map +1 -0
  373. package/dist/integrations/platform/gitlab/event-worker.d.ts +64 -0
  374. package/dist/integrations/platform/gitlab/event-worker.d.ts.map +1 -0
  375. package/dist/integrations/platform/gitlab/event-worker.js +305 -0
  376. package/dist/integrations/platform/gitlab/event-worker.js.map +1 -0
  377. package/dist/integrations/platform/gitlab/integration.d.ts +57 -0
  378. package/dist/integrations/platform/gitlab/integration.d.ts.map +1 -0
  379. package/dist/integrations/platform/gitlab/integration.js +113 -0
  380. package/dist/integrations/platform/gitlab/integration.js.map +1 -0
  381. package/dist/integrations/platform/incidentio/integration.d.ts +74 -0
  382. package/dist/integrations/platform/incidentio/integration.d.ts.map +1 -0
  383. package/dist/integrations/platform/incidentio/integration.js +406 -0
  384. package/dist/integrations/platform/incidentio/integration.js.map +1 -0
  385. package/dist/integrations/platform/jira/agent-tools.d.ts +36 -0
  386. package/dist/integrations/platform/jira/agent-tools.d.ts.map +1 -0
  387. package/dist/integrations/platform/jira/agent-tools.js +85 -0
  388. package/dist/integrations/platform/jira/agent-tools.js.map +1 -0
  389. package/dist/integrations/platform/jira/integration.d.ts +65 -0
  390. package/dist/integrations/platform/jira/integration.d.ts.map +1 -0
  391. package/dist/integrations/platform/jira/integration.js +546 -0
  392. package/dist/integrations/platform/jira/integration.js.map +1 -0
  393. package/dist/integrations/platform/jira/routes.d.ts +55 -0
  394. package/dist/integrations/platform/jira/routes.d.ts.map +1 -0
  395. package/dist/integrations/platform/jira/routes.js +274 -0
  396. package/dist/integrations/platform/jira/routes.js.map +1 -0
  397. package/dist/integrations/platform/linear/event-worker.d.ts +105 -0
  398. package/dist/integrations/platform/linear/event-worker.d.ts.map +1 -0
  399. package/dist/integrations/platform/linear/event-worker.js +379 -0
  400. package/dist/integrations/platform/linear/event-worker.js.map +1 -0
  401. package/dist/integrations/platform/linear/integration.d.ts +92 -0
  402. package/dist/integrations/platform/linear/integration.d.ts.map +1 -0
  403. package/dist/integrations/platform/linear/integration.js +754 -0
  404. package/dist/integrations/platform/linear/integration.js.map +1 -0
  405. package/dist/integrations/pull-request-head.d.ts +18 -0
  406. package/dist/integrations/pull-request-head.d.ts.map +1 -0
  407. package/dist/integrations/pull-request-head.js +45 -0
  408. package/dist/integrations/pull-request-head.js.map +1 -0
  409. package/dist/integrations/reconciliation-config.d.ts +3 -0
  410. package/dist/integrations/reconciliation-config.d.ts.map +1 -0
  411. package/dist/integrations/reconciliation-config.js +16 -0
  412. package/dist/integrations/reconciliation-config.js.map +1 -0
  413. package/dist/integrations/slack/connect-route.d.ts +46 -0
  414. package/dist/integrations/slack/connect-route.d.ts.map +1 -0
  415. package/dist/integrations/slack/connect-route.js +186 -0
  416. package/dist/integrations/slack/connect-route.js.map +1 -0
  417. package/dist/integrations/slack/emoji-shortcodes.generated.d.ts +8 -0
  418. package/dist/integrations/slack/emoji-shortcodes.generated.d.ts.map +1 -0
  419. package/dist/integrations/slack/emoji-shortcodes.generated.js +1985 -0
  420. package/dist/integrations/slack/emoji-shortcodes.generated.js.map +1 -0
  421. package/dist/integrations/slack/emoji.d.ts +3 -0
  422. package/dist/integrations/slack/emoji.d.ts.map +1 -0
  423. package/dist/integrations/slack/emoji.js +12 -0
  424. package/dist/integrations/slack/emoji.js.map +1 -0
  425. package/dist/integrations/slack/feed-publisher.d.ts +26 -0
  426. package/dist/integrations/slack/feed-publisher.d.ts.map +1 -0
  427. package/dist/integrations/slack/feed-publisher.js +44 -0
  428. package/dist/integrations/slack/feed-publisher.js.map +1 -0
  429. package/dist/integrations/slack/integration.d.ts +80 -0
  430. package/dist/integrations/slack/integration.d.ts.map +1 -0
  431. package/dist/integrations/slack/integration.js +93 -0
  432. package/dist/integrations/slack/integration.js.map +1 -0
  433. package/dist/integrations/slack/slack.d.ts +205 -0
  434. package/dist/integrations/slack/slack.d.ts.map +1 -0
  435. package/dist/integrations/slack/slack.js +653 -0
  436. package/dist/integrations/slack/slack.js.map +1 -0
  437. package/dist/integrations/subscription-session.d.ts +49 -0
  438. package/dist/integrations/subscription-session.d.ts.map +1 -0
  439. package/dist/integrations/subscription-session.js +103 -0
  440. package/dist/integrations/subscription-session.js.map +1 -0
  441. package/dist/integrations/workos/integration.d.ts +39 -0
  442. package/dist/integrations/workos/integration.d.ts.map +1 -0
  443. package/dist/integrations/workos/integration.js +91 -0
  444. package/dist/integrations/workos/integration.js.map +1 -0
  445. package/dist/packages/_internals/workspace/dist/index.js +48 -0
  446. package/dist/packages/_internals/workspace/dist/index.js.map +1 -0
  447. package/dist/platform-auth-host.d.ts +4 -0
  448. package/dist/platform-auth-host.d.ts.map +1 -0
  449. package/dist/platform-auth-host.js +18 -0
  450. package/dist/platform-auth-host.js.map +1 -0
  451. package/dist/review-verdict.d.ts +6 -0
  452. package/dist/review-verdict.d.ts.map +1 -0
  453. package/dist/review-verdict.js +14 -0
  454. package/dist/review-verdict.js.map +1 -0
  455. package/dist/routes/attention-activity.d.ts +23 -0
  456. package/dist/routes/attention-activity.d.ts.map +1 -0
  457. package/dist/routes/attention-activity.js +152 -0
  458. package/dist/routes/attention-activity.js.map +1 -0
  459. package/dist/routes/attention-parked.d.ts +22 -0
  460. package/dist/routes/attention-parked.d.ts.map +1 -0
  461. package/dist/routes/attention-parked.js +136 -0
  462. package/dist/routes/attention-parked.js.map +1 -0
  463. package/dist/routes/attention-proposed.d.ts +3 -0
  464. package/dist/routes/attention-proposed.d.ts.map +1 -0
  465. package/dist/routes/attention-proposed.js +21 -0
  466. package/dist/routes/attention-proposed.js.map +1 -0
  467. package/dist/routes/attention-providers.d.ts +159 -0
  468. package/dist/routes/attention-providers.d.ts.map +1 -0
  469. package/dist/routes/attention-providers.js +524 -0
  470. package/dist/routes/attention-providers.js.map +1 -0
  471. package/dist/routes/attention.d.ts +23 -0
  472. package/dist/routes/attention.d.ts.map +1 -0
  473. package/dist/routes/attention.js +219 -0
  474. package/dist/routes/attention.js.map +1 -0
  475. package/dist/routes/automation-runs.d.ts +37 -0
  476. package/dist/routes/automation-runs.d.ts.map +1 -0
  477. package/dist/routes/automation-runs.js +196 -0
  478. package/dist/routes/automation-runs.js.map +1 -0
  479. package/dist/routes/config.d.ts +238 -0
  480. package/dist/routes/config.d.ts.map +1 -0
  481. package/dist/routes/config.js +1011 -0
  482. package/dist/routes/config.js.map +1 -0
  483. package/dist/routes/contracts.d.ts +1080 -0
  484. package/dist/routes/contracts.d.ts.map +1 -0
  485. package/dist/routes/contracts.js +673 -0
  486. package/dist/routes/contracts.js.map +1 -0
  487. package/dist/routes/custom-provider-source.d.ts +52 -0
  488. package/dist/routes/custom-provider-source.d.ts.map +1 -0
  489. package/dist/routes/custom-provider-source.js +124 -0
  490. package/dist/routes/custom-provider-source.js.map +1 -0
  491. package/dist/routes/fs.d.ts +189 -0
  492. package/dist/routes/fs.d.ts.map +1 -0
  493. package/dist/routes/fs.js +916 -0
  494. package/dist/routes/fs.js.map +1 -0
  495. package/dist/routes/intake.d.ts +64 -0
  496. package/dist/routes/intake.d.ts.map +1 -0
  497. package/dist/routes/intake.js +627 -0
  498. package/dist/routes/intake.js.map +1 -0
  499. package/dist/routes/knowledge.d.ts +247 -0
  500. package/dist/routes/knowledge.d.ts.map +1 -0
  501. package/dist/routes/knowledge.js +1128 -0
  502. package/dist/routes/knowledge.js.map +1 -0
  503. package/dist/routes/oauth.d.ts +43 -0
  504. package/dist/routes/oauth.d.ts.map +1 -0
  505. package/dist/routes/oauth.js +477 -0
  506. package/dist/routes/oauth.js.map +1 -0
  507. package/dist/routes/projects.d.ts +68 -0
  508. package/dist/routes/projects.d.ts.map +1 -0
  509. package/dist/routes/projects.js +919 -0
  510. package/dist/routes/projects.js.map +1 -0
  511. package/dist/routes/provider-credentials.d.ts +82 -0
  512. package/dist/routes/provider-credentials.d.ts.map +1 -0
  513. package/dist/routes/provider-credentials.js +80 -0
  514. package/dist/routes/provider-credentials.js.map +1 -0
  515. package/dist/routes/route.d.ts +48 -0
  516. package/dist/routes/route.d.ts.map +1 -0
  517. package/dist/routes/route.js +15 -0
  518. package/dist/routes/route.js.map +1 -0
  519. package/dist/routes/skills.d.ts +30 -0
  520. package/dist/routes/skills.d.ts.map +1 -0
  521. package/dist/routes/skills.js +198 -0
  522. package/dist/routes/skills.js.map +1 -0
  523. package/dist/routes/source-control-sessions.d.ts +22 -0
  524. package/dist/routes/source-control-sessions.d.ts.map +1 -0
  525. package/dist/routes/source-control-sessions.js +356 -0
  526. package/dist/routes/source-control-sessions.js.map +1 -0
  527. package/dist/routes/source-control-settings.d.ts +10 -0
  528. package/dist/routes/source-control-settings.d.ts.map +1 -0
  529. package/dist/routes/source-control-settings.js +87 -0
  530. package/dist/routes/source-control-settings.js.map +1 -0
  531. package/dist/routes/supervisor.d.ts +25 -0
  532. package/dist/routes/supervisor.d.ts.map +1 -0
  533. package/dist/routes/supervisor.js +35 -0
  534. package/dist/routes/supervisor.js.map +1 -0
  535. package/dist/routes/surface.d.ts +133 -0
  536. package/dist/routes/surface.d.ts.map +1 -0
  537. package/dist/routes/surface.js +518 -0
  538. package/dist/routes/surface.js.map +1 -0
  539. package/dist/routes/telemetry.d.ts +13 -0
  540. package/dist/routes/telemetry.d.ts.map +1 -0
  541. package/dist/routes/telemetry.js +60 -0
  542. package/dist/routes/telemetry.js.map +1 -0
  543. package/dist/routes/tenant-credentials.d.ts +87 -0
  544. package/dist/routes/tenant-credentials.d.ts.map +1 -0
  545. package/dist/routes/tenant-credentials.js +219 -0
  546. package/dist/routes/tenant-credentials.js.map +1 -0
  547. package/dist/routes/work-items.d.ts +49 -0
  548. package/dist/routes/work-items.d.ts.map +1 -0
  549. package/dist/routes/work-items.js +633 -0
  550. package/dist/routes/work-items.js.map +1 -0
  551. package/dist/rules/binding-context.d.ts +59 -0
  552. package/dist/rules/binding-context.d.ts.map +1 -0
  553. package/dist/rules/binding-context.js +134 -0
  554. package/dist/rules/binding-context.js.map +1 -0
  555. package/dist/rules/decision-applicability.d.ts +32 -0
  556. package/dist/rules/decision-applicability.d.ts.map +1 -0
  557. package/dist/rules/decision-applicability.js +56 -0
  558. package/dist/rules/decision-applicability.js.map +1 -0
  559. package/dist/rules/dispatch-errors.d.ts +13 -0
  560. package/dist/rules/dispatch-errors.d.ts.map +1 -0
  561. package/dist/rules/dispatch-errors.js +105 -0
  562. package/dist/rules/dispatch-errors.js.map +1 -0
  563. package/dist/rules/dispatcher.d.ts +86 -0
  564. package/dist/rules/dispatcher.d.ts.map +1 -0
  565. package/dist/rules/dispatcher.js +1159 -0
  566. package/dist/rules/dispatcher.js.map +1 -0
  567. package/dist/rules/event-rules.d.ts +23 -0
  568. package/dist/rules/event-rules.d.ts.map +1 -0
  569. package/dist/rules/event-rules.js +46 -0
  570. package/dist/rules/event-rules.js.map +1 -0
  571. package/dist/rules/index.d.ts +6 -0
  572. package/dist/rules/index.d.ts.map +1 -0
  573. package/dist/rules/index.js +4 -0
  574. package/dist/rules/processor.d.ts +90 -0
  575. package/dist/rules/processor.d.ts.map +1 -0
  576. package/dist/rules/processor.js +486 -0
  577. package/dist/rules/processor.js.map +1 -0
  578. package/dist/rules/resolve.d.ts +15 -0
  579. package/dist/rules/resolve.d.ts.map +1 -0
  580. package/dist/rules/resolve.js +23 -0
  581. package/dist/rules/resolve.js.map +1 -0
  582. package/dist/rules/review-source-tool.d.ts +105 -0
  583. package/dist/rules/review-source-tool.d.ts.map +1 -0
  584. package/dist/rules/review-source-tool.js +109 -0
  585. package/dist/rules/review-source-tool.js.map +1 -0
  586. package/dist/rules/start-coordinator.d.ts +64 -0
  587. package/dist/rules/start-coordinator.d.ts.map +1 -0
  588. package/dist/rules/start-coordinator.js +246 -0
  589. package/dist/rules/start-coordinator.js.map +1 -0
  590. package/dist/rules/terminal-cleanup.d.ts +38 -0
  591. package/dist/rules/terminal-cleanup.d.ts.map +1 -0
  592. package/dist/rules/terminal-cleanup.js +68 -0
  593. package/dist/rules/terminal-cleanup.js.map +1 -0
  594. package/dist/rules/tools.d.ts +15 -0
  595. package/dist/rules/tools.d.ts.map +1 -0
  596. package/dist/rules/tools.js +185 -0
  597. package/dist/rules/tools.js.map +1 -0
  598. package/dist/rules/transition-service.d.ts +93 -0
  599. package/dist/rules/transition-service.d.ts.map +1 -0
  600. package/dist/rules/transition-service.js +402 -0
  601. package/dist/rules/transition-service.js.map +1 -0
  602. package/dist/rules/types.d.ts +553 -0
  603. package/dist/rules/types.d.ts.map +1 -0
  604. package/dist/rules/types.js +154 -0
  605. package/dist/rules/types.js.map +1 -0
  606. package/dist/rules/validation.d.ts +21 -0
  607. package/dist/rules/validation.d.ts.map +1 -0
  608. package/dist/rules/validation.js +327 -0
  609. package/dist/rules/validation.js.map +1 -0
  610. package/dist/sandbox/callback-factory-sandbox.d.ts +15 -0
  611. package/dist/sandbox/callback-factory-sandbox.d.ts.map +1 -0
  612. package/dist/sandbox/callback-factory-sandbox.js +22 -0
  613. package/dist/sandbox/callback-factory-sandbox.js.map +1 -0
  614. package/dist/sandbox/git-ref.d.ts +7 -0
  615. package/dist/sandbox/git-ref.d.ts.map +1 -0
  616. package/dist/sandbox/git-ref.js +15 -0
  617. package/dist/sandbox/git-ref.js.map +1 -0
  618. package/dist/sandbox/local-factory-sandbox.d.ts +20 -0
  619. package/dist/sandbox/local-factory-sandbox.d.ts.map +1 -0
  620. package/dist/sandbox/local-factory-sandbox.js +27 -0
  621. package/dist/sandbox/local-factory-sandbox.js.map +1 -0
  622. package/dist/sandbox/materialization.d.ts +41 -0
  623. package/dist/sandbox/materialization.d.ts.map +1 -0
  624. package/dist/sandbox/materialization.js +18 -0
  625. package/dist/sandbox/materialization.js.map +1 -0
  626. package/dist/sandbox/session-retirement.d.ts +45 -0
  627. package/dist/sandbox/session-retirement.d.ts.map +1 -0
  628. package/dist/sandbox/session-retirement.js +153 -0
  629. package/dist/sandbox/session-retirement.js.map +1 -0
  630. package/dist/sandbox/session-sandbox.d.ts +185 -0
  631. package/dist/sandbox/session-sandbox.d.ts.map +1 -0
  632. package/dist/sandbox/session-sandbox.js +248 -0
  633. package/dist/sandbox/session-sandbox.js.map +1 -0
  634. package/dist/sandbox/workdir.d.ts +45 -0
  635. package/dist/sandbox/workdir.d.ts.map +1 -0
  636. package/dist/sandbox/workdir.js +64 -0
  637. package/dist/sandbox/workdir.js.map +1 -0
  638. package/dist/secret-encryption.d.ts +25 -0
  639. package/dist/secret-encryption.d.ts.map +1 -0
  640. package/dist/secret-encryption.js +107 -0
  641. package/dist/secret-encryption.js.map +1 -0
  642. package/dist/server-error.d.ts +12 -0
  643. package/dist/server-error.d.ts.map +1 -0
  644. package/dist/server-error.js +16 -0
  645. package/dist/server-error.js.map +1 -0
  646. package/dist/session/credential-policy.d.ts +20 -0
  647. package/dist/session/credential-policy.d.ts.map +1 -0
  648. package/dist/session/credential-policy.js +70 -0
  649. package/dist/session/credential-policy.js.map +1 -0
  650. package/dist/session/default-model-hydration.d.ts +46 -0
  651. package/dist/session/default-model-hydration.d.ts.map +1 -0
  652. package/dist/session/default-model-hydration.js +85 -0
  653. package/dist/session/default-model-hydration.js.map +1 -0
  654. package/dist/session/environment-repositories.d.ts +31 -0
  655. package/dist/session/environment-repositories.d.ts.map +1 -0
  656. package/dist/session/environment-repositories.js +89 -0
  657. package/dist/session/environment-repositories.js.map +1 -0
  658. package/dist/session/environment-state-processor.d.ts +59 -0
  659. package/dist/session/environment-state-processor.d.ts.map +1 -0
  660. package/dist/session/environment-state-processor.js +105 -0
  661. package/dist/session/environment-state-processor.js.map +1 -0
  662. package/dist/session/factory-session.d.ts +159 -0
  663. package/dist/session/factory-session.d.ts.map +1 -0
  664. package/dist/session/factory-session.js +226 -0
  665. package/dist/session/factory-session.js.map +1 -0
  666. package/dist/session/filesystem-capture.d.ts +50 -0
  667. package/dist/session/filesystem-capture.d.ts.map +1 -0
  668. package/dist/session/filesystem-capture.js +231 -0
  669. package/dist/session/filesystem-capture.js.map +1 -0
  670. package/dist/session/first-exec-capture.d.ts +38 -0
  671. package/dist/session/first-exec-capture.d.ts.map +1 -0
  672. package/dist/session/first-exec-capture.js +91 -0
  673. package/dist/session/first-exec-capture.js.map +1 -0
  674. package/dist/session/first-message-capture.d.ts +33 -0
  675. package/dist/session/first-message-capture.d.ts.map +1 -0
  676. package/dist/session/first-message-capture.js +35 -0
  677. package/dist/session/first-message-capture.js.map +1 -0
  678. package/dist/session/live-sessions.d.ts +63 -0
  679. package/dist/session/live-sessions.d.ts.map +1 -0
  680. package/dist/session/live-sessions.js +90 -0
  681. package/dist/session/live-sessions.js.map +1 -0
  682. package/dist/session/memory-settings-hydration.d.ts +36 -0
  683. package/dist/session/memory-settings-hydration.d.ts.map +1 -0
  684. package/dist/session/memory-settings-hydration.js +43 -0
  685. package/dist/session/memory-settings-hydration.js.map +1 -0
  686. package/dist/session/org-seed.d.ts +67 -0
  687. package/dist/session/org-seed.d.ts.map +1 -0
  688. package/dist/session/org-seed.js +53 -0
  689. package/dist/session/org-seed.js.map +1 -0
  690. package/dist/session/run-audit.d.ts +54 -0
  691. package/dist/session/run-audit.d.ts.map +1 -0
  692. package/dist/session/run-audit.js +124 -0
  693. package/dist/session/run-audit.js.map +1 -0
  694. package/dist/session/session-title.d.ts +7 -0
  695. package/dist/session/session-title.d.ts.map +1 -0
  696. package/dist/session/session-title.js +14 -0
  697. package/dist/session/session-title.js.map +1 -0
  698. package/dist/session/shell-commands.d.ts +5 -0
  699. package/dist/session/shell-commands.d.ts.map +1 -0
  700. package/dist/session/shell-commands.js +25 -0
  701. package/dist/session/shell-commands.js.map +1 -0
  702. package/dist/session/source-control-tools.d.ts +25 -0
  703. package/dist/session/source-control-tools.d.ts.map +1 -0
  704. package/dist/session/source-control-tools.js +594 -0
  705. package/dist/session/source-control-tools.js.map +1 -0
  706. package/dist/session/thread-title-mirror.d.ts +35 -0
  707. package/dist/session/thread-title-mirror.d.ts.map +1 -0
  708. package/dist/session/thread-title-mirror.js +51 -0
  709. package/dist/session/thread-title-mirror.js.map +1 -0
  710. package/dist/session/work-item-repository.d.ts +21 -0
  711. package/dist/session/work-item-repository.d.ts.map +1 -0
  712. package/dist/session/work-item-repository.js +113 -0
  713. package/dist/session/work-item-repository.js.map +1 -0
  714. package/dist/skills/catalog.d.ts +14 -0
  715. package/dist/skills/catalog.d.ts.map +1 -0
  716. package/dist/skills/catalog.js +62 -0
  717. package/dist/skills/catalog.js.map +1 -0
  718. package/dist/skills/service.d.ts +70 -0
  719. package/dist/skills/service.d.ts.map +1 -0
  720. package/dist/skills/service.js +88 -0
  721. package/dist/skills/service.js.map +1 -0
  722. package/dist/spa-static.d.ts +33 -0
  723. package/dist/spa-static.d.ts.map +1 -0
  724. package/dist/spa-static.js +104 -0
  725. package/dist/spa-static.js.map +1 -0
  726. package/dist/state-signing.d.ts +59 -0
  727. package/dist/state-signing.d.ts.map +1 -0
  728. package/dist/state-signing.js +83 -0
  729. package/dist/state-signing.js.map +1 -0
  730. package/dist/storage/domains/audit/actions.d.ts +24 -0
  731. package/dist/storage/domains/audit/actions.d.ts.map +1 -0
  732. package/dist/storage/domains/audit/actions.js +69 -0
  733. package/dist/storage/domains/audit/actions.js.map +1 -0
  734. package/dist/storage/domains/audit/actors.d.ts +5 -0
  735. package/dist/storage/domains/audit/actors.d.ts.map +1 -0
  736. package/dist/storage/domains/audit/actors.js +25 -0
  737. package/dist/storage/domains/audit/actors.js.map +1 -0
  738. package/dist/storage/domains/audit/agent-audit.d.ts +30 -0
  739. package/dist/storage/domains/audit/agent-audit.d.ts.map +1 -0
  740. package/dist/storage/domains/audit/agent-audit.js +93 -0
  741. package/dist/storage/domains/audit/agent-audit.js.map +1 -0
  742. package/dist/storage/domains/audit/base.d.ts +133 -0
  743. package/dist/storage/domains/audit/base.d.ts.map +1 -0
  744. package/dist/storage/domains/audit/base.js +206 -0
  745. package/dist/storage/domains/audit/base.js.map +1 -0
  746. package/dist/storage/domains/audit/domain.d.ts +79 -0
  747. package/dist/storage/domains/audit/domain.d.ts.map +1 -0
  748. package/dist/storage/domains/audit/domain.js +248 -0
  749. package/dist/storage/domains/audit/domain.js.map +1 -0
  750. package/dist/storage/domains/audit/wire.d.ts +24 -0
  751. package/dist/storage/domains/audit/wire.d.ts.map +1 -0
  752. package/dist/storage/domains/audit/wire.js +16 -0
  753. package/dist/storage/domains/audit/wire.js.map +1 -0
  754. package/dist/storage/domains/channel-identity/base.d.ts +100 -0
  755. package/dist/storage/domains/channel-identity/base.d.ts.map +1 -0
  756. package/dist/storage/domains/channel-identity/base.js +164 -0
  757. package/dist/storage/domains/channel-identity/base.js.map +1 -0
  758. package/dist/storage/domains/comments/activity.d.ts +40 -0
  759. package/dist/storage/domains/comments/activity.d.ts.map +1 -0
  760. package/dist/storage/domains/comments/activity.js +94 -0
  761. package/dist/storage/domains/comments/activity.js.map +1 -0
  762. package/dist/storage/domains/comments/actor.d.ts +51 -0
  763. package/dist/storage/domains/comments/actor.d.ts.map +1 -0
  764. package/dist/storage/domains/comments/actor.js +38 -0
  765. package/dist/storage/domains/comments/actor.js.map +1 -0
  766. package/dist/storage/domains/comments/base.d.ts +245 -0
  767. package/dist/storage/domains/comments/base.d.ts.map +1 -0
  768. package/dist/storage/domains/comments/base.js +533 -0
  769. package/dist/storage/domains/comments/base.js.map +1 -0
  770. package/dist/storage/domains/comments/domain.d.ts +135 -0
  771. package/dist/storage/domains/comments/domain.d.ts.map +1 -0
  772. package/dist/storage/domains/comments/domain.js +285 -0
  773. package/dist/storage/domains/comments/domain.js.map +1 -0
  774. package/dist/storage/domains/comments/feed-context.d.ts +22 -0
  775. package/dist/storage/domains/comments/feed-context.d.ts.map +1 -0
  776. package/dist/storage/domains/comments/feed-context.js +89 -0
  777. package/dist/storage/domains/comments/feed-context.js.map +1 -0
  778. package/dist/storage/domains/comments/feed-sync.d.ts +21 -0
  779. package/dist/storage/domains/comments/feed-sync.d.ts.map +1 -0
  780. package/dist/storage/domains/comments/feed-sync.js +1 -0
  781. package/dist/storage/domains/comments/parse.d.ts +23 -0
  782. package/dist/storage/domains/comments/parse.d.ts.map +1 -0
  783. package/dist/storage/domains/comments/parse.js +90 -0
  784. package/dist/storage/domains/comments/parse.js.map +1 -0
  785. package/dist/storage/domains/comments/routes.d.ts +24 -0
  786. package/dist/storage/domains/comments/routes.d.ts.map +1 -0
  787. package/dist/storage/domains/comments/routes.js +302 -0
  788. package/dist/storage/domains/comments/routes.js.map +1 -0
  789. package/dist/storage/domains/comments/schema.d.ts +5 -0
  790. package/dist/storage/domains/comments/schema.d.ts.map +1 -0
  791. package/dist/storage/domains/comments/schema.js +179 -0
  792. package/dist/storage/domains/comments/schema.js.map +1 -0
  793. package/dist/storage/domains/comments/wire.d.ts +40 -0
  794. package/dist/storage/domains/comments/wire.d.ts.map +1 -0
  795. package/dist/storage/domains/comments/wire.js +37 -0
  796. package/dist/storage/domains/comments/wire.js.map +1 -0
  797. package/dist/storage/domains/credentials/base.d.ts +136 -0
  798. package/dist/storage/domains/credentials/base.d.ts.map +1 -0
  799. package/dist/storage/domains/credentials/base.js +294 -0
  800. package/dist/storage/domains/credentials/base.js.map +1 -0
  801. package/dist/storage/domains/custom-providers/base.d.ts +59 -0
  802. package/dist/storage/domains/custom-providers/base.d.ts.map +1 -0
  803. package/dist/storage/domains/custom-providers/base.js +176 -0
  804. package/dist/storage/domains/custom-providers/base.js.map +1 -0
  805. package/dist/storage/domains/filesystem/base.d.ts +26 -0
  806. package/dist/storage/domains/filesystem/base.d.ts.map +1 -0
  807. package/dist/storage/domains/filesystem/base.js +74 -0
  808. package/dist/storage/domains/filesystem/base.js.map +1 -0
  809. package/dist/storage/domains/intake/base.d.ts +150 -0
  810. package/dist/storage/domains/intake/base.d.ts.map +1 -0
  811. package/dist/storage/domains/intake/base.js +431 -0
  812. package/dist/storage/domains/intake/base.js.map +1 -0
  813. package/dist/storage/domains/integrations/base.d.ts +128 -0
  814. package/dist/storage/domains/integrations/base.d.ts.map +1 -0
  815. package/dist/storage/domains/integrations/base.js +333 -0
  816. package/dist/storage/domains/integrations/base.js.map +1 -0
  817. package/dist/storage/domains/memory-settings/base.d.ts +58 -0
  818. package/dist/storage/domains/memory-settings/base.d.ts.map +1 -0
  819. package/dist/storage/domains/memory-settings/base.js +129 -0
  820. package/dist/storage/domains/memory-settings/base.js.map +1 -0
  821. package/dist/storage/domains/model-defaults/base.d.ts +29 -0
  822. package/dist/storage/domains/model-defaults/base.d.ts.map +1 -0
  823. package/dist/storage/domains/model-defaults/base.js +79 -0
  824. package/dist/storage/domains/model-defaults/base.js.map +1 -0
  825. package/dist/storage/domains/projects/base.d.ts +191 -0
  826. package/dist/storage/domains/projects/base.d.ts.map +1 -0
  827. package/dist/storage/domains/projects/base.js +352 -0
  828. package/dist/storage/domains/projects/base.js.map +1 -0
  829. package/dist/storage/domains/queue-health/base.d.ts +52 -0
  830. package/dist/storage/domains/queue-health/base.d.ts.map +1 -0
  831. package/dist/storage/domains/queue-health/base.js +122 -0
  832. package/dist/storage/domains/queue-health/base.js.map +1 -0
  833. package/dist/storage/domains/source-control/base.d.ts +422 -0
  834. package/dist/storage/domains/source-control/base.d.ts.map +1 -0
  835. package/dist/storage/domains/source-control/base.js +1114 -0
  836. package/dist/storage/domains/source-control/base.js.map +1 -0
  837. package/dist/storage/domains/source-control/inmemory.d.ts +147 -0
  838. package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -0
  839. package/dist/storage/domains/source-control/inmemory.js +416 -0
  840. package/dist/storage/domains/source-control/inmemory.js.map +1 -0
  841. package/dist/storage/domains/work-items/base.d.ts +794 -0
  842. package/dist/storage/domains/work-items/base.d.ts.map +1 -0
  843. package/dist/storage/domains/work-items/base.js +2747 -0
  844. package/dist/storage/domains/work-items/base.js.map +1 -0
  845. package/dist/storage/domains/work-items/board-version.d.ts +26 -0
  846. package/dist/storage/domains/work-items/board-version.d.ts.map +1 -0
  847. package/dist/storage/domains/work-items/board-version.js +110 -0
  848. package/dist/storage/domains/work-items/board-version.js.map +1 -0
  849. package/dist/storage/domains/work-items/metrics.d.ts +97 -0
  850. package/dist/storage/domains/work-items/metrics.d.ts.map +1 -0
  851. package/dist/storage/domains/work-items/metrics.js +226 -0
  852. package/dist/storage/domains/work-items/metrics.js.map +1 -0
  853. package/dist/supervisor/health-worker.d.ts +19 -0
  854. package/dist/supervisor/health-worker.d.ts.map +1 -0
  855. package/dist/supervisor/health-worker.js +74 -0
  856. package/dist/supervisor/health-worker.js.map +1 -0
  857. package/dist/supervisor/health.d.ts +79 -0
  858. package/dist/supervisor/health.d.ts.map +1 -0
  859. package/dist/supervisor/health.js +228 -0
  860. package/dist/supervisor/health.js.map +1 -0
  861. package/dist/supervisor/instructions.d.ts +6 -0
  862. package/dist/supervisor/instructions.d.ts.map +1 -0
  863. package/dist/supervisor/instructions.js +66 -0
  864. package/dist/supervisor/instructions.js.map +1 -0
  865. package/dist/supervisor/read-tools.d.ts +43 -0
  866. package/dist/supervisor/read-tools.d.ts.map +1 -0
  867. package/dist/supervisor/read-tools.js +343 -0
  868. package/dist/supervisor/read-tools.js.map +1 -0
  869. package/dist/supervisor/session-messaging.d.ts +26 -0
  870. package/dist/supervisor/session-messaging.d.ts.map +1 -0
  871. package/dist/supervisor/session-messaging.js +21 -0
  872. package/dist/supervisor/session-messaging.js.map +1 -0
  873. package/dist/supervisor/session.d.ts +38 -0
  874. package/dist/supervisor/session.d.ts.map +1 -0
  875. package/dist/supervisor/session.js +79 -0
  876. package/dist/supervisor/session.js.map +1 -0
  877. package/dist/supervisor/write-tools.d.ts +30 -0
  878. package/dist/supervisor/write-tools.d.ts.map +1 -0
  879. package/dist/supervisor/write-tools.js +231 -0
  880. package/dist/supervisor/write-tools.js.map +1 -0
  881. package/dist/telemetry-types.d.ts +7 -0
  882. package/dist/telemetry-types.d.ts.map +1 -0
  883. package/dist/telemetry-types.js +24 -0
  884. package/dist/telemetry-types.js.map +1 -0
  885. package/dist/telemetry.d.ts +9 -0
  886. package/dist/telemetry.d.ts.map +1 -0
  887. package/dist/telemetry.js +47 -0
  888. package/dist/telemetry.js.map +1 -0
  889. package/dist/timing.d.ts +15 -0
  890. package/dist/timing.d.ts.map +1 -0
  891. package/dist/timing.js +34 -0
  892. package/dist/timing.js.map +1 -0
  893. package/dist/work-item-branch.d.ts +33 -0
  894. package/dist/work-item-branch.d.ts.map +1 -0
  895. package/dist/work-item-branch.js +70 -0
  896. package/dist/work-item-branch.js.map +1 -0
  897. package/dist/workspace.d.ts +131 -0
  898. package/dist/workspace.d.ts.map +1 -0
  899. package/dist/workspace.js +995 -0
  900. package/dist/workspace.js.map +1 -0
  901. package/factory-skills/configure-factory-rules/SKILL.md +122 -0
  902. package/factory-skills/factory-complete-issue/SKILL.md +24 -0
  903. package/factory-skills/factory-gitlab-rereview/SKILL.md +22 -0
  904. package/factory-skills/factory-gitlab-review/SKILL.md +48 -0
  905. package/factory-skills/factory-plan/SKILL.md +72 -0
  906. package/factory-skills/factory-rereview/SKILL.md +225 -0
  907. package/factory-skills/factory-review/SKILL.md +214 -0
  908. package/factory-skills/factory-review/references/archaeology.md +225 -0
  909. package/factory-skills/factory-review/references/categories/README.md +34 -0
  910. package/factory-skills/factory-review/references/categories/behavior-change.md +36 -0
  911. package/factory-skills/factory-review/references/categories/bug-fix.md +37 -0
  912. package/factory-skills/factory-review/references/categories/docs.md +32 -0
  913. package/factory-skills/factory-review/references/categories/experimental-flagged.md +34 -0
  914. package/factory-skills/factory-review/references/categories/infra-tooling.md +37 -0
  915. package/factory-skills/factory-review/references/categories/internal-capability.md +35 -0
  916. package/factory-skills/factory-review/references/categories/large-cross-cutting.md +35 -0
  917. package/factory-skills/factory-review/references/categories/mechanical.md +36 -0
  918. package/factory-skills/factory-review/references/categories/performance.md +33 -0
  919. package/factory-skills/factory-review/references/categories/public-api.md +38 -0
  920. package/factory-skills/factory-review/references/categories/refactor.md +35 -0
  921. package/factory-skills/factory-review/references/categories/revert.md +31 -0
  922. package/factory-skills/factory-review/references/categories/schema-storage.md +39 -0
  923. package/factory-skills/factory-review/references/categories/security.md +35 -0
  924. package/factory-skills/factory-review/references/categories/tests-only.md +38 -0
  925. package/factory-skills/factory-triage/SKILL.md +197 -0
  926. package/package.json +92 -0
@@ -0,0 +1,1128 @@
1
+ import { Route } from "./route.js";
2
+ import { registerApiRoute } from "@mastra/core/server";
3
+ import { KnowledgeUnsupportedCapabilityError, canonicalizeKnowledgeScope, isKnowledgeScopeVisible, knowledgeScopeKey, parseKnowledgeWikilinks } from "@mastra/core/storage";
4
+ //#region src/routes/knowledge.ts
5
+ /** Reserved node that anchors pinned records (see subconscious/pinned.ts). */
6
+ const PINNED_NODE_NAME = "pinned";
7
+ /** Hover-card budget for record text shipped in the graph payload. */
8
+ const RECORD_TEXT_LIMIT = 240;
9
+ function truncateRecordText(text) {
10
+ return text.length > RECORD_TEXT_LIMIT ? `${text.slice(0, RECORD_TEXT_LIMIT - 1)}…` : text;
11
+ }
12
+ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
13
+ /** Authorized visible events returned per activity page. */
14
+ const ACTIVITY_PAGE_SIZE = 25;
15
+ /** Events fetched per `listActivity` batch while filling a visible page. */
16
+ const ACTIVITY_BATCH = 100;
17
+ /** Hard scan cap so a huge hidden backlog cannot spin the request. */
18
+ const ACTIVITY_SCAN_CAP = 1e3;
19
+ /** Maximum visible nodes inspected for non-prefix name matches. */
20
+ const SEARCH_SCAN_CAP = 1e3;
21
+ /** Compact result window returned to the search popover. */
22
+ const SEARCH_RESULT_LIMIT = 20;
23
+ /** Prevent an unbounded query string from reaching storage. */
24
+ const SEARCH_QUERY_LIMIT = 128;
25
+ /** Scope nodes returned per parent while lazily expanding the tree. */
26
+ const SCOPE_PAGE_SIZE = 25;
27
+ /** Bound storage pressure while calculating direct-member counts. */
28
+ const SCOPE_COUNT_CONCURRENCY = 8;
29
+ const DEFAULT_LIMITS = {
30
+ maxNodes: 500,
31
+ maxRecords: 2e3,
32
+ maxFallbackLookups: 100,
33
+ maxOrgScopePages: 10
34
+ };
35
+ function loose(c) {
36
+ return c;
37
+ }
38
+ function deepestRung(scope) {
39
+ let rung = "org";
40
+ for (const entry of scope) {
41
+ const ns = entry.slice(0, entry.indexOf(":"));
42
+ if (ns === "thread") return "thread";
43
+ if (ns === "resource") rung = "resource";
44
+ }
45
+ return rung;
46
+ }
47
+ /**
48
+ * True when `scope` is a prefix of the active view scope — the content lives
49
+ * inside the current org + project boundary. Structural member lenses use
50
+ * this to keep sibling-project knowledge out of a project-scoped view.
51
+ */
52
+ function withinViewBoundary(scope, viewScope) {
53
+ return scope.length <= viewScope.length && scope.every((entry, index) => entry === viewScope[index]);
54
+ }
55
+ function directScopeMemberCounts({ members, hasMore }, childScopeCount, viewScope, maxNodes) {
56
+ const contentNodeCount = members.filter((member) => !member.isScope && Array.isArray(member.scope) && withinViewBoundary(member.scope, viewScope)).length;
57
+ const directMemberCount = childScopeCount + contentNodeCount;
58
+ return {
59
+ memberCount: Math.min(directMemberCount, maxNodes),
60
+ memberCountTruncated: directMemberCount > maxNodes || hasMore,
61
+ contentNodeCount,
62
+ childScopeCount
63
+ };
64
+ }
65
+ function compareScopeNodes(a, b) {
66
+ return a.name.localeCompare(b.name) || a.id.localeCompare(b.id);
67
+ }
68
+ /**
69
+ * Scopes in one org (the org scope and everything beneath it), filtered and paged in storage.
70
+ * Reads at most `maxPages` pages; `truncated` is true when scopes remain past that point.
71
+ */
72
+ async function listOrgScopeNodes(store, orgId, maxPages) {
73
+ const scopes = [];
74
+ let cursor;
75
+ for (let page = 0; page < maxPages; page += 1) {
76
+ const result = await store.listScopeNodes({
77
+ withinAddress: `org:${orgId}`,
78
+ cursor
79
+ });
80
+ scopes.push(...result.scopes);
81
+ if (!result.nextCursor) return {
82
+ scopes,
83
+ truncated: false
84
+ };
85
+ cursor = result.nextCursor;
86
+ }
87
+ return {
88
+ scopes,
89
+ truncated: true
90
+ };
91
+ }
92
+ /** One scope node, only if it is in the org. Independent of how many scopes the org has. */
93
+ async function findOrgScopeNode(store, orgId, scopeNodeId) {
94
+ const { scopes } = await store.listScopeNodes({
95
+ withinAddress: `org:${orgId}`,
96
+ ids: [scopeNodeId],
97
+ limit: 1
98
+ });
99
+ return scopes[0];
100
+ }
101
+ function knowledgeSearchRank(name, query) {
102
+ const normalized = name.toLocaleLowerCase();
103
+ if (normalized === query) return 0;
104
+ if (normalized.startsWith(query)) return 1;
105
+ return 2;
106
+ }
107
+ /**
108
+ * What a scope node is, for labels: the rung name for vouched identity scopes, otherwise the
109
+ * stored kind, or "topic" for structural scopes created without one. Matches the scope list.
110
+ */
111
+ function scopeKindLabel(address, kind) {
112
+ if (address.startsWith("org:")) return "org";
113
+ if (address.startsWith("resource:")) return "project";
114
+ if (address.startsWith("thread:")) return "session";
115
+ return kind || "topic";
116
+ }
117
+ /** The thread id of a session (`thread:<id>`) scope node, or undefined for any other scope. */
118
+ function sessionThreadId(node) {
119
+ return node.address.startsWith("thread:") ? boundedThreadId(node.address.slice(7)) : void 0;
120
+ }
121
+ function boundedThreadId(raw) {
122
+ if (!raw) return void 0;
123
+ const trimmed = raw.trim();
124
+ return trimmed.length > 0 && trimmed.length <= 512 ? trimmed : void 0;
125
+ }
126
+ /**
127
+ * In-record + capped-fallback wikilink resolver, shared by both endpoints.
128
+ * Resolution uses the store's own algorithm: a descending-prefix walk over the
129
+ * record's canonical scope matching canonical name + exact scope key at each
130
+ * prefix, so an edge never depends on whether the target landed in the window.
131
+ */
132
+ var WikilinkResolver = class {
133
+ /** exact `${scopeKey}\u0000${lowerName}` → node, from the fetched window. */
134
+ #inWindow = /* @__PURE__ */ new Map();
135
+ #windowIds = /* @__PURE__ */ new Set();
136
+ /** `${recordScopeKey}\u0000${lowerName}` → fallback result (null = dangling). */
137
+ #fallbackCache = /* @__PURE__ */ new Map();
138
+ #fallbackLookups = 0;
139
+ #store;
140
+ #maxFallbackLookups;
141
+ outOfWindow = /* @__PURE__ */ new Map();
142
+ cappedNames = [];
143
+ #cappedSeen = /* @__PURE__ */ new Set();
144
+ constructor(store, nodes, maxFallbackLookups) {
145
+ this.#store = store;
146
+ this.#maxFallbackLookups = maxFallbackLookups;
147
+ for (const node of nodes) {
148
+ this.#inWindow.set(`${knowledgeScopeKey(node.scope)}\u0000${node.name.trim().toLocaleLowerCase()}`, node);
149
+ this.#windowIds.add(node.id);
150
+ }
151
+ }
152
+ inWindowId(id) {
153
+ return this.#windowIds.has(id);
154
+ }
155
+ /** Resolve a wikilink name from a knowledge record's scope. Returns the node or null (dangling/capped). */
156
+ async resolve(name, recordScope) {
157
+ const canonical = canonicalizeKnowledgeScope(recordScope);
158
+ const lower = name.trim().toLocaleLowerCase();
159
+ for (let length = canonical.length; length > 0; length--) {
160
+ const hit = this.#inWindow.get(`${knowledgeScopeKey(canonical.slice(0, length))}\u0000${lower}`);
161
+ if (hit) return hit;
162
+ }
163
+ const cacheKey = `${knowledgeScopeKey(canonical)}\u0000${lower}`;
164
+ if (this.#fallbackCache.has(cacheKey)) return this.#trackOutOfWindow(this.#fallbackCache.get(cacheKey) ?? null);
165
+ if (this.#fallbackLookups >= this.#maxFallbackLookups) {
166
+ if (!this.#cappedSeen.has(lower) && this.cappedNames.length < 100) {
167
+ this.#cappedSeen.add(lower);
168
+ this.cappedNames.push(name.trim());
169
+ } else if (!this.#cappedSeen.has(lower)) this.#cappedSeen.add(lower);
170
+ return null;
171
+ }
172
+ this.#fallbackLookups += 1;
173
+ let resolved = null;
174
+ try {
175
+ resolved = await this.#store.resolveNode({
176
+ name,
177
+ scope: canonical
178
+ });
179
+ } catch {
180
+ resolved = null;
181
+ }
182
+ this.#fallbackCache.set(cacheKey, resolved);
183
+ return this.#trackOutOfWindow(resolved);
184
+ }
185
+ #trackOutOfWindow(node) {
186
+ if (node && !this.#windowIds.has(node.id)) this.outOfWindow.set(node.id, {
187
+ id: node.id,
188
+ name: node.name,
189
+ scope: node.scope,
190
+ rung: deepestRung(node.scope)
191
+ });
192
+ return node;
193
+ }
194
+ get cappedCount() {
195
+ return this.#cappedSeen.size;
196
+ }
197
+ };
198
+ var KnowledgeRoutes = class extends Route {
199
+ #limits;
200
+ constructor(deps) {
201
+ super(deps);
202
+ this.#limits = {
203
+ ...DEFAULT_LIMITS,
204
+ ...deps.limits
205
+ };
206
+ }
207
+ /** Resolve the `(orgId, userId)` tenant or a ready-to-return error response. */
208
+ async #resolveTenant(c) {
209
+ await this.deps.auth.ensureUser(c);
210
+ const tenant = this.deps.auth.tenant(c);
211
+ if (!tenant) return { response: c.json({ error: "unauthorized" }, 401) };
212
+ if (!tenant.orgId) return { response: c.json({
213
+ error: "organization_required",
214
+ message: "The knowledge graph requires an organization."
215
+ }, 403) };
216
+ return {
217
+ orgId: tenant.orgId,
218
+ userId: tenant.userId
219
+ };
220
+ }
221
+ /**
222
+ * Resolve tenant + org-owned project + knowledge store + the active view's
223
+ * query scope. The ONE seam both endpoints share, so the default/thread view
224
+ * scope and the pin rungs cannot drift between them.
225
+ *
226
+ * threadId validation runs a single `listRecordsBySource` lookup with
227
+ * `limit: 1` AT THE CANDIDATE SCOPE `[org, resource, thread:<id>]` — the
228
+ * store's own visibility predicate is the authorization: the thread's own
229
+ * records (equal scope key) and its project/org captures (prefix) match, while
230
+ * a cross-org thread's records match nothing → zero rows → 404.
231
+ */
232
+ async #resolveView(c) {
233
+ const tenant = await this.#resolveTenant(c);
234
+ if ("response" in tenant) return tenant;
235
+ const projectId = c.req.param("id");
236
+ if (!projectId || !UUID_RE.test(projectId)) return { response: c.json({ error: "Project not found" }, 404) };
237
+ const { projects } = this.deps;
238
+ await projects.ensureReady();
239
+ const project = await projects.get({
240
+ orgId: tenant.orgId,
241
+ id: projectId
242
+ });
243
+ if (!project) return { response: c.json({ error: "Project not found" }, 404) };
244
+ let knowledge;
245
+ let store;
246
+ try {
247
+ const key = this.deps.defaultKnowledgeKey ?? "default";
248
+ knowledge = await this.deps.knowledge(key);
249
+ store = knowledge ? await knowledge.getStorage() : void 0;
250
+ } catch {
251
+ store = void 0;
252
+ }
253
+ if (!store || !knowledge) return { response: c.json({
254
+ error: "knowledge_unavailable",
255
+ message: "The configured Knowledge runtime is unavailable."
256
+ }, 503) };
257
+ const defaultScope = [`org:${tenant.orgId}`, `resource:${projectId}`];
258
+ const resourceRungScope = defaultScope;
259
+ const threadId = boundedThreadId(c.req.query("threadId"));
260
+ if (c.req.query("threadId") !== void 0 && !threadId) return { response: c.json({ error: "thread_not_found" }, 404) };
261
+ if (!threadId) return {
262
+ ...tenant,
263
+ factoryProjectId: projectId,
264
+ factoryProjectName: project.name,
265
+ knowledge,
266
+ store,
267
+ view: "project",
268
+ scope: defaultScope,
269
+ pinRungs: [{
270
+ rung: "resource",
271
+ scope: resourceRungScope
272
+ }]
273
+ };
274
+ const candidateScope = [...defaultScope, `thread:${threadId}`];
275
+ if ((await store.knowledgeBySource({
276
+ sourceThreadId: threadId,
277
+ scope: candidateScope,
278
+ limit: 1
279
+ })).records.length === 0) return { response: c.json({ error: "thread_not_found" }, 404) };
280
+ return {
281
+ ...tenant,
282
+ factoryProjectId: projectId,
283
+ factoryProjectName: project.name,
284
+ knowledge,
285
+ store,
286
+ view: "thread",
287
+ threadId,
288
+ scope: candidateScope,
289
+ pinRungs: [{
290
+ rung: "resource",
291
+ scope: resourceRungScope
292
+ }, {
293
+ rung: "thread",
294
+ scope: candidateScope
295
+ }]
296
+ };
297
+ }
298
+ #selectedView(view, level) {
299
+ const projectView = {
300
+ orgId: view.orgId,
301
+ userId: view.userId,
302
+ factoryProjectId: view.factoryProjectId,
303
+ factoryProjectName: view.factoryProjectName,
304
+ knowledge: view.knowledge,
305
+ store: view.store,
306
+ view: "project"
307
+ };
308
+ if (level === "org") return {
309
+ ...projectView,
310
+ scope: view.scope.slice(0, 1),
311
+ pinRungs: []
312
+ };
313
+ if (level === "resource") return {
314
+ ...projectView,
315
+ scope: view.scope.slice(0, 2),
316
+ pinRungs: view.pinRungs.filter((rung) => rung.rung === "resource")
317
+ };
318
+ if (level === "thread" && view.threadId) return view;
319
+ }
320
+ /**
321
+ * Host-vouched identity chain: the org → project → session rungs this
322
+ * request resolved are materialized as ordinary scope nodes linked by
323
+ * membership edges, so the sidebar tree is built from scopes that EXIST —
324
+ * never from the declared structure plan or the rung config. Materialization
325
+ * is create-only and deduped by address (existing nodes keep their declared
326
+ * names/parents), so the steady state is a no-op skip. No companion scope is
327
+ * created here or anywhere automatically. A vouch failure never fails the read —
328
+ * the tree simply serves the scopes that already exist.
329
+ */
330
+ async #vouchIdentityScopes(view) {
331
+ const orgAddress = `org:${view.orgId}`;
332
+ const resourceAddress = `resource:${view.factoryProjectId}`;
333
+ const chain = [
334
+ {
335
+ address: orgAddress,
336
+ contextualScopeAddress: orgAddress
337
+ },
338
+ {
339
+ address: resourceAddress,
340
+ name: view.factoryProjectName,
341
+ contextualScopeAddress: orgAddress,
342
+ parentAddresses: [orgAddress]
343
+ },
344
+ ...view.threadId ? [{
345
+ address: `thread:${view.threadId}`,
346
+ contextualScopeAddress: resourceAddress,
347
+ parentAddresses: [resourceAddress]
348
+ }] : []
349
+ ];
350
+ let existing;
351
+ try {
352
+ const { scopes } = await view.store.listScopeNodes({ addresses: chain.map((link) => link.address) });
353
+ existing = new Set(scopes.map((node) => node.address));
354
+ } catch (error) {
355
+ if (error instanceof KnowledgeUnsupportedCapabilityError) return;
356
+ throw error;
357
+ }
358
+ for (const link of chain) {
359
+ if (existing.has(link.address)) continue;
360
+ await view.knowledge.materializeScope(link).catch(() => void 0);
361
+ }
362
+ }
363
+ /**
364
+ * Session scopes are listed only under the viewed project, and only when the `threadId`
365
+ * drill-down would accept them (a visible record captured in that session), so no listing
366
+ * exposes a session id the drill-down would reject. Returns the ids of hidden session nodes.
367
+ * With `probe: false` only the cheap project check runs; callers probe the bounded page they return.
368
+ */
369
+ async #hiddenSessionIds(view, nodes, projectNodeId, { probe }) {
370
+ const hidden = /* @__PURE__ */ new Set();
371
+ const projectScope = [`org:${view.orgId}`, `resource:${view.factoryProjectId}`];
372
+ const sessions = [];
373
+ for (const node of nodes) {
374
+ if (!node.address.startsWith("thread:")) continue;
375
+ const threadId = sessionThreadId(node);
376
+ if (!threadId || !projectNodeId || !node.parentIds.includes(projectNodeId)) hidden.add(node.id);
377
+ else if (probe && threadId !== view.threadId) sessions.push({
378
+ id: node.id,
379
+ threadId
380
+ });
381
+ }
382
+ for (let index = 0; index < sessions.length; index += SCOPE_COUNT_CONCURRENCY) await Promise.all(sessions.slice(index, index + SCOPE_COUNT_CONCURRENCY).map(async ({ id, threadId }) => {
383
+ const { records } = await view.store.knowledgeBySource({
384
+ sourceThreadId: threadId,
385
+ scope: [...projectScope, `thread:${threadId}`],
386
+ limit: 1
387
+ });
388
+ if (records.length === 0) hidden.add(id);
389
+ }));
390
+ return hidden;
391
+ }
392
+ /**
393
+ * Display names for session scopes, resolved at read time from the thread's current title
394
+ * (never stored on the scope node, where it would go stale). Keyed by scope node id.
395
+ */
396
+ async #sessionNames(nodes) {
397
+ const names = /* @__PURE__ */ new Map();
398
+ const sessions = nodes.flatMap((node) => {
399
+ const threadId = node.address.startsWith("thread:") ? node.address.slice(7) : "";
400
+ return threadId ? [{
401
+ id: node.id,
402
+ threadId
403
+ }] : [];
404
+ });
405
+ for (let index = 0; index < sessions.length; index += SCOPE_COUNT_CONCURRENCY) await Promise.all(sessions.slice(index, index + SCOPE_COUNT_CONCURRENCY).map(async ({ id, threadId }) => {
406
+ let title;
407
+ try {
408
+ title = (await this.deps.threadTitle?.(threadId))?.trim();
409
+ } catch {}
410
+ names.set(id, title || `session ${threadId.slice(0, 8)}`);
411
+ }));
412
+ return names;
413
+ }
414
+ /** Reserved `pinned` node ids at the active view's rungs (one exact-scope lookup per rung). */
415
+ async #pinnedNodeIds(view) {
416
+ const out = [];
417
+ for (const { rung, scope } of view.pinRungs) {
418
+ const node = await view.store.getNodeByName({
419
+ name: PINNED_NODE_NAME,
420
+ scope
421
+ });
422
+ if (node && !node.mergedInto) out.push({
423
+ rung,
424
+ id: node.id
425
+ });
426
+ }
427
+ return out;
428
+ }
429
+ /** Non-deleted pinned records for the given pinned-node ids, visible in the view. */
430
+ async #pinnedRecords(view, pinnedNodeIds) {
431
+ const out = [];
432
+ for (const { rung, id } of pinnedNodeIds) {
433
+ const { records } = await view.store.listKnowledgeAbout({
434
+ node: id,
435
+ scope: view.scope,
436
+ limit: 200
437
+ });
438
+ for (const record of records) out.push({
439
+ rung,
440
+ record
441
+ });
442
+ }
443
+ return out;
444
+ }
445
+ routes() {
446
+ return [
447
+ registerApiRoute("/web/factory/projects/:id/knowledge/scopes", {
448
+ method: "GET",
449
+ requiresAuth: false,
450
+ handler: async (c) => {
451
+ const view = await this.#resolveView(loose(c));
452
+ if ("response" in view) return view.response;
453
+ await this.#vouchIdentityScopes(view);
454
+ let scopeNodes;
455
+ let nextCursor;
456
+ const childCursors = {};
457
+ let storedScopeNodes = [];
458
+ let scopesTruncated = false;
459
+ try {
460
+ ({scopes: storedScopeNodes, truncated: scopesTruncated} = await listOrgScopeNodes(view.store, view.orgId, this.#limits.maxOrgScopePages));
461
+ const projectNodeId = storedScopeNodes.find((node) => node.address === `resource:${view.factoryProjectId}`)?.id;
462
+ const foreignSessions = await this.#hiddenSessionIds(view, storedScopeNodes, projectNodeId, { probe: false });
463
+ storedScopeNodes = storedScopeNodes.filter((node) => !foreignSessions.has(node.id));
464
+ const scopeNodeById = new Map(storedScopeNodes.map((node) => [node.id, node]));
465
+ const childScopeCountByParent = /* @__PURE__ */ new Map();
466
+ for (const node of storedScopeNodes) for (const parentId of node.parentIds) childScopeCountByParent.set(parentId, (childScopeCountByParent.get(parentId) ?? 0) + 1);
467
+ const parentId = loose(c).req.query("parentId");
468
+ const cursor = loose(c).req.query("cursor");
469
+ if (parentId && !UUID_RE.test(parentId)) return c.json({ error: "invalid_scope_parent" }, 400);
470
+ if (cursor && !UUID_RE.test(cursor)) return c.json({ error: "invalid_scope_cursor" }, 400);
471
+ if (parentId && !scopeNodeById.has(parentId)) return c.json({ error: "scope_not_found" }, 404);
472
+ const siblings = storedScopeNodes.filter((node) => parentId ? node.parentIds.includes(parentId) : node.parentIds.length === 0).sort(compareScopeNodes);
473
+ const cursorIndex = cursor ? siblings.findIndex((node) => node.id === cursor) : -1;
474
+ if (cursor && cursorIndex < 0) return c.json({ error: "invalid_scope_cursor" }, 400);
475
+ const pageStart = cursorIndex + 1;
476
+ const siblingPage = siblings.slice(pageStart, pageStart + SCOPE_PAGE_SIZE);
477
+ if (pageStart + siblingPage.length < siblings.length) nextCursor = siblingPage.at(-1)?.id;
478
+ const returnedById = new Map(siblingPage.map((node) => [node.id, node]));
479
+ if (!parentId) {
480
+ const addFirstChildPage = (parent) => {
481
+ const children = storedScopeNodes.filter((node) => node.parentIds.includes(parent.id)).sort(compareScopeNodes);
482
+ const returnedChildren = [];
483
+ for (const child of children.slice(0, SCOPE_PAGE_SIZE)) {
484
+ if (returnedById.size >= this.#limits.maxNodes) break;
485
+ returnedById.set(child.id, child);
486
+ returnedChildren.push(child);
487
+ }
488
+ if (returnedChildren.length < children.length) {
489
+ const lastChild = returnedChildren.at(-1);
490
+ if (lastChild) childCursors[parent.id] = lastChild.id;
491
+ }
492
+ };
493
+ for (const root of siblingPage) addFirstChildPage(root);
494
+ const identityAddresses = /* @__PURE__ */ new Set([
495
+ `org:${view.orgId}`,
496
+ `resource:${view.factoryProjectId}`,
497
+ ...view.threadId ? [`thread:${view.threadId}`] : []
498
+ ]);
499
+ const includeWithParents = (node) => {
500
+ if (returnedById.has(node.id) || returnedById.size >= this.#limits.maxNodes) return;
501
+ for (const ancestorId of node.parentIds) {
502
+ const ancestor = scopeNodeById.get(ancestorId);
503
+ if (ancestor) includeWithParents(ancestor);
504
+ }
505
+ returnedById.set(node.id, node);
506
+ };
507
+ for (const node of storedScopeNodes) if (identityAddresses.has(node.address)) includeWithParents(node);
508
+ const projectNode = projectNodeId ? scopeNodeById.get(projectNodeId) : void 0;
509
+ if (projectNode && returnedById.has(projectNode.id)) addFirstChildPage(projectNode);
510
+ }
511
+ const unreadableSessions = await this.#hiddenSessionIds(view, [...returnedById.values()], projectNodeId, { probe: true });
512
+ for (const id of unreadableSessions) returnedById.delete(id);
513
+ scopeNodes = [];
514
+ const returnedNodes = [...returnedById.values()].sort(compareScopeNodes);
515
+ for (let index = 0; index < returnedNodes.length; index += SCOPE_COUNT_CONCURRENCY) {
516
+ const batch = returnedNodes.slice(index, index + SCOPE_COUNT_CONCURRENCY);
517
+ scopeNodes.push(...await Promise.all(batch.map(async (node) => {
518
+ const members = await view.store.listScopeMembers({
519
+ scopeNodeId: node.id,
520
+ limit: this.#limits.maxNodes
521
+ });
522
+ return {
523
+ ...node,
524
+ ...node.address === `resource:${view.factoryProjectId}` ? { name: view.factoryProjectName } : {},
525
+ ...directScopeMemberCounts(members, childScopeCountByParent.get(node.id) ?? 0, view.scope, this.#limits.maxNodes)
526
+ };
527
+ })));
528
+ }
529
+ const sessionNames = await this.#sessionNames(scopeNodes);
530
+ scopeNodes = scopeNodes.map((node) => ({
531
+ ...node,
532
+ kind: scopeKindLabel(node.address, node.kind),
533
+ ...sessionNames.has(node.id) ? { name: sessionNames.get(node.id) } : {}
534
+ }));
535
+ } catch (error) {
536
+ if (!(error instanceof KnowledgeUnsupportedCapabilityError)) throw error;
537
+ scopeNodes = void 0;
538
+ }
539
+ const scopeNodeByAddress = new Map(storedScopeNodes.map((node) => [node.address, node]));
540
+ const threadRoot = view.threadId ? scopeNodeByAddress.get(`thread:${view.threadId}`) : void 0;
541
+ const threadRootName = threadRoot ? (await this.#sessionNames([threadRoot])).get(threadRoot.id) : void 0;
542
+ const rungs = [
543
+ {
544
+ level: "org",
545
+ id: view.orgId,
546
+ available: true
547
+ },
548
+ {
549
+ level: "resource",
550
+ id: view.factoryProjectId,
551
+ available: true
552
+ },
553
+ ...view.threadId ? [{
554
+ level: "thread",
555
+ id: view.threadId,
556
+ available: true
557
+ }] : []
558
+ ];
559
+ return c.json({
560
+ roots: rungs.map((rung) => {
561
+ const match = scopeNodeByAddress.get(`${rung.level}:${rung.id}`);
562
+ const name = match?.address === `resource:${view.factoryProjectId}` ? view.factoryProjectName : match && rung.level === "thread" ? threadRootName : match?.name;
563
+ return match ? {
564
+ ...rung,
565
+ scopeNodeId: match.id,
566
+ name
567
+ } : rung;
568
+ }),
569
+ defaultLevel: "resource",
570
+ ...scopeNodes ? { scopeNodes } : {},
571
+ ...nextCursor ? { nextCursor } : {},
572
+ ...Object.keys(childCursors).length > 0 ? { childCursors } : {},
573
+ ...scopesTruncated ? { truncated: true } : {}
574
+ });
575
+ }
576
+ }),
577
+ registerApiRoute("/web/factory/projects/:id/knowledge/search", {
578
+ method: "GET",
579
+ requiresAuth: false,
580
+ handler: async (c) => {
581
+ const view = await this.#resolveView(loose(c));
582
+ if ("response" in view) return view.response;
583
+ const query = (loose(c).req.query("q") ?? "").trim().slice(0, SEARCH_QUERY_LIMIT).toLocaleLowerCase();
584
+ if (query.length < 2) return c.json({
585
+ results: [],
586
+ truncated: false
587
+ });
588
+ const scanLimit = Math.min(SEARCH_SCAN_CAP, this.#limits.maxNodes);
589
+ const [prefixNodes, scannedNodes] = await Promise.all([view.store.listNodes({
590
+ scope: view.scope,
591
+ namePrefix: query,
592
+ limit: 21
593
+ }), view.store.listNodes({
594
+ scope: view.scope,
595
+ limit: scanLimit
596
+ })]);
597
+ const contentById = /* @__PURE__ */ new Map();
598
+ for (const node of [...prefixNodes, ...scannedNodes]) {
599
+ if (node.isScope || !Array.isArray(node.scope) || !withinViewBoundary(node.scope, view.scope) || !node.name.toLocaleLowerCase().includes(query)) continue;
600
+ contentById.set(node.id, node);
601
+ }
602
+ let structuralScopes = [];
603
+ let scopesTruncated = false;
604
+ try {
605
+ const orgScopes = await listOrgScopeNodes(view.store, view.orgId, this.#limits.maxOrgScopePages);
606
+ scopesTruncated = orgScopes.truncated;
607
+ structuralScopes = orgScopes.scopes.filter((node) => (!node.address.startsWith("thread:") || sessionThreadId(node) === view.threadId) && node.name.toLocaleLowerCase().includes(query));
608
+ } catch (error) {
609
+ if (!(error instanceof KnowledgeUnsupportedCapabilityError)) throw error;
610
+ }
611
+ const scopeSessionNames = await this.#sessionNames(structuralScopes);
612
+ const results = [...structuralScopes.map((scopeNode) => {
613
+ const rung = scopeNode.address === `org:${view.orgId}` ? "org" : scopeNode.address === `resource:${view.factoryProjectId}` ? "resource" : view.threadId && scopeNode.address === `thread:${view.threadId}` ? "thread" : null;
614
+ return {
615
+ id: scopeNode.id,
616
+ name: scopeNode.address === `resource:${view.factoryProjectId}` ? view.factoryProjectName : scopeSessionNames.get(scopeNode.id) ?? scopeNode.name,
617
+ kind: scopeKindLabel(scopeNode.address, scopeNode.kind),
618
+ type: "scope",
619
+ rung,
620
+ address: scopeNode.address,
621
+ ...scopeNode.description ? { description: scopeNode.description } : {}
622
+ };
623
+ }), ...[...contentById.values()].map((node) => {
624
+ const rung = deepestRung(node.scope);
625
+ const threadId = rung === "thread" ? node.scope.find((address) => address.startsWith("thread:"))?.slice(7) : void 0;
626
+ return {
627
+ id: node.id,
628
+ name: node.name,
629
+ kind: node.kind,
630
+ type: "node",
631
+ rung,
632
+ ...threadId ? { threadId } : {}
633
+ };
634
+ })].sort((a, b) => knowledgeSearchRank(a.name, query) - knowledgeSearchRank(b.name, query) || a.name.localeCompare(b.name) || a.id.localeCompare(b.id));
635
+ return c.json({
636
+ results: results.slice(0, SEARCH_RESULT_LIMIT),
637
+ truncated: scopesTruncated || results.length > SEARCH_RESULT_LIMIT || prefixNodes.length > SEARCH_RESULT_LIMIT || scannedNodes.length >= scanLimit
638
+ });
639
+ }
640
+ }),
641
+ registerApiRoute("/web/factory/projects/:id/knowledge/subgraph", {
642
+ method: "GET",
643
+ requiresAuth: false,
644
+ handler: async (c) => {
645
+ const resolved = await this.#resolveView(loose(c));
646
+ if ("response" in resolved) return resolved.response;
647
+ const scopeNodeId = loose(c).req.query("scopeNodeId");
648
+ if (scopeNodeId !== void 0) {
649
+ if (!UUID_RE.test(scopeNodeId)) return c.json({ error: "scope_not_found" }, 404);
650
+ const limits = this.#limits;
651
+ const { store } = resolved;
652
+ let storedRoot;
653
+ try {
654
+ storedRoot = await findOrgScopeNode(store, resolved.orgId, scopeNodeId);
655
+ } catch (error) {
656
+ if (error instanceof KnowledgeUnsupportedCapabilityError) return c.json({ error: "scope_not_found" }, 404);
657
+ throw error;
658
+ }
659
+ if (!storedRoot) return c.json({ error: "scope_not_found" }, 404);
660
+ const { scopes: scopeNodes, truncated: scopesTruncated } = await listOrgScopeNodes(store, resolved.orgId, limits.maxOrgScopePages);
661
+ const rootSessionName = (await this.#sessionNames([storedRoot])).get(storedRoot.id);
662
+ const root = storedRoot.address === `resource:${resolved.factoryProjectId}` ? {
663
+ ...storedRoot,
664
+ name: resolved.factoryProjectName
665
+ } : rootSessionName ? {
666
+ ...storedRoot,
667
+ name: rootSessionName
668
+ } : storedRoot;
669
+ if (storedRoot.address.startsWith("thread:")) {
670
+ const projectNodeId = scopeNodes.find((node) => node.address === `resource:${resolved.factoryProjectId}`)?.id;
671
+ if ((await this.#hiddenSessionIds(resolved, [storedRoot], projectNodeId, { probe: true })).has(storedRoot.id)) return c.json({ error: "scope_not_found" }, 404);
672
+ }
673
+ const otherSessionIds = new Set(scopeNodes.filter((node) => node.address.startsWith("thread:") && sessionThreadId(node) !== resolved.threadId).map((node) => node.id));
674
+ const fetched = await store.listScopeMembers({
675
+ scopeNodeId,
676
+ limit: limits.maxNodes
677
+ });
678
+ const bounded = fetched.members.filter((node) => node.isScope && !otherSessionIds.has(node.id) || !node.isScope && Array.isArray(node.scope) && withinViewBoundary(node.scope, resolved.scope));
679
+ let truncated = scopesTruncated || fetched.hasMore || bounded.length > limits.maxNodes;
680
+ const members = bounded.slice(0, limits.maxNodes);
681
+ const contentMembers = members.filter((node) => !node.isScope && Array.isArray(node.scope));
682
+ const childScopeCountByParent = /* @__PURE__ */ new Map();
683
+ for (const node of scopeNodes) for (const parentId of node.parentIds) childScopeCountByParent.set(parentId, (childScopeCountByParent.get(parentId) ?? 0) + 1);
684
+ const scopeCountsById = /* @__PURE__ */ new Map([[root.id, directScopeMemberCounts(fetched, childScopeCountByParent.get(root.id) ?? 0, resolved.scope, limits.maxNodes)]]);
685
+ const memberScopes = members.filter((node) => node.isScope);
686
+ for (let index = 0; index < memberScopes.length; index += SCOPE_COUNT_CONCURRENCY) {
687
+ const batch = memberScopes.slice(index, index + SCOPE_COUNT_CONCURRENCY);
688
+ await Promise.all(batch.map(async (node) => {
689
+ const directMembers = await store.listScopeMembers({
690
+ scopeNodeId: node.id,
691
+ limit: limits.maxNodes
692
+ });
693
+ scopeCountsById.set(node.id, directScopeMemberCounts(directMembers, childScopeCountByParent.get(node.id) ?? 0, resolved.scope, limits.maxNodes));
694
+ }));
695
+ }
696
+ const recordWindow = [];
697
+ for (const node of contentMembers) {
698
+ if (recordWindow.length > limits.maxRecords) break;
699
+ const { records } = await store.listKnowledgeAbout({
700
+ node: node.id,
701
+ scope: node.scope,
702
+ limit: limits.maxRecords + 1 - recordWindow.length
703
+ });
704
+ recordWindow.push(...records);
705
+ }
706
+ recordWindow.sort((a, b) => b.id.localeCompare(a.id));
707
+ if (recordWindow.length > limits.maxRecords) {
708
+ truncated = true;
709
+ recordWindow.length = limits.maxRecords;
710
+ }
711
+ const resolver = new WikilinkResolver(store, contentMembers, limits.maxFallbackLookups);
712
+ const edges = [];
713
+ const graphRecords = [];
714
+ const edgeSeen = /* @__PURE__ */ new Set();
715
+ const recordCounts = /* @__PURE__ */ new Map();
716
+ for (const record of recordWindow) {
717
+ recordCounts.set(record.node, (recordCounts.get(record.node) ?? 0) + 1);
718
+ const nodeIds = [record.node];
719
+ for (const name of parseKnowledgeWikilinks(record.text)) {
720
+ const target = await resolver.resolve(name, record.scope);
721
+ if (!target) continue;
722
+ if (target.id === record.node) continue;
723
+ if (!resolver.inWindowId(target.id)) continue;
724
+ if (!nodeIds.includes(target.id)) nodeIds.push(target.id);
725
+ const key = `${record.node}\u0000${target.id}`;
726
+ if (edgeSeen.has(key)) continue;
727
+ edgeSeen.add(key);
728
+ edges.push({
729
+ id: `wikilink:${record.node}:${target.id}`,
730
+ source: record.node,
731
+ target: target.id,
732
+ type: "wikilink",
733
+ recordId: record.id
734
+ });
735
+ }
736
+ graphRecords.push({
737
+ id: record.id,
738
+ nodeIds,
739
+ pinned: false,
740
+ text: truncateRecordText(record.text)
741
+ });
742
+ }
743
+ for (const member of members) edges.push({
744
+ id: `contains:${root.id}:${member.id}`,
745
+ source: root.id,
746
+ target: member.id,
747
+ type: "contains"
748
+ });
749
+ const scopeAddressById = new Map(scopeNodes.map((node) => [node.id, node.address]));
750
+ const memberSessionNames = await this.#sessionNames(members.flatMap((node) => {
751
+ const address = node.isScope ? scopeAddressById.get(node.id) : void 0;
752
+ return address ? [{
753
+ id: node.id,
754
+ address
755
+ }] : [];
756
+ }));
757
+ const rootRow = await store.getNode(root.id);
758
+ const activity = await store.listActivity({
759
+ scope: resolved.scope,
760
+ limit: 1
761
+ });
762
+ const payload = {
763
+ view: resolved.view,
764
+ ...resolved.threadId ? { threadId: resolved.threadId } : {},
765
+ nodes: [{
766
+ id: root.id,
767
+ name: root.name,
768
+ kind: scopeKindLabel(root.address, root.kind),
769
+ ...root.description ? { description: root.description } : {},
770
+ scope: null,
771
+ rung: null,
772
+ isScope: true,
773
+ pinned: false,
774
+ recordCount: 0,
775
+ ...scopeCountsById.get(root.id),
776
+ ...rootRow ? {
777
+ createdAt: rootRow.createdAt.toISOString(),
778
+ updatedAt: rootRow.updatedAt.toISOString()
779
+ } : {}
780
+ }, ...members.map((node) => {
781
+ const nodeScope = Array.isArray(node.scope) ? node.scope : null;
782
+ const address = node.isScope ? scopeAddressById.get(node.id) : void 0;
783
+ return {
784
+ id: node.id,
785
+ name: memberSessionNames.get(node.id) ?? node.name,
786
+ kind: node.isScope ? scopeKindLabel(address ?? "", node.kind) : node.kind,
787
+ ...node.description ? { description: node.description } : {},
788
+ scope: nodeScope,
789
+ rung: nodeScope ? deepestRung(nodeScope) : null,
790
+ ...node.isScope ? {
791
+ isScope: true,
792
+ ...scopeCountsById.get(node.id)
793
+ } : {},
794
+ pinned: false,
795
+ recordCount: recordCounts.get(node.id) ?? 0,
796
+ createdAt: node.createdAt.toISOString(),
797
+ updatedAt: node.updatedAt.toISOString()
798
+ };
799
+ })],
800
+ edges,
801
+ records: graphRecords,
802
+ truncated,
803
+ outOfWindow: [...resolver.outOfWindow.values()],
804
+ unresolvedCapped: {
805
+ count: resolver.cappedCount,
806
+ names: resolver.cappedNames
807
+ },
808
+ pinCensus: {
809
+ resource: 0,
810
+ thread: null
811
+ },
812
+ version: activity[0]?.id ?? null
813
+ };
814
+ return c.json(payload);
815
+ }
816
+ const view = this.#selectedView(resolved, loose(c).req.query("scopeLevel"));
817
+ if (!view) return c.json({ error: "scope_not_found" }, 404);
818
+ const { store, scope } = view;
819
+ const limits = this.#limits;
820
+ const fetched = (await store.listNodes({
821
+ scope,
822
+ limit: limits.maxNodes + 1
823
+ })).filter((node) => Array.isArray(node.scope));
824
+ let truncated = fetched.length > limits.maxNodes;
825
+ const pinnedNodeIds = await this.#pinnedNodeIds(view);
826
+ const pinnedNodeIdSet = new Set(pinnedNodeIds.map((p) => p.id));
827
+ const nodes = fetched.slice(0, limits.maxNodes).filter((node) => !pinnedNodeIdSet.has(node.id));
828
+ const recordWindow = [];
829
+ for (const node of nodes) {
830
+ if (recordWindow.length > limits.maxRecords) break;
831
+ const { records } = await store.listKnowledgeAbout({
832
+ node: node.id,
833
+ scope,
834
+ limit: limits.maxRecords + 1 - recordWindow.length
835
+ });
836
+ recordWindow.push(...records);
837
+ }
838
+ recordWindow.sort((a, b) => b.id.localeCompare(a.id));
839
+ if (recordWindow.length > limits.maxRecords) {
840
+ truncated = true;
841
+ recordWindow.length = limits.maxRecords;
842
+ }
843
+ const resolver = new WikilinkResolver(store, nodes, limits.maxFallbackLookups);
844
+ const edges = [];
845
+ const graphRecords = [];
846
+ const edgeSeen = /* @__PURE__ */ new Set();
847
+ const recordCounts = /* @__PURE__ */ new Map();
848
+ for (const record of recordWindow) {
849
+ recordCounts.set(record.node, (recordCounts.get(record.node) ?? 0) + 1);
850
+ const nodeIds = [record.node];
851
+ for (const name of parseKnowledgeWikilinks(record.text)) {
852
+ const target = await resolver.resolve(name, record.scope);
853
+ if (!target) continue;
854
+ if (target.id === record.node) continue;
855
+ if (!resolver.inWindowId(target.id)) continue;
856
+ if (!nodeIds.includes(target.id)) nodeIds.push(target.id);
857
+ const key = `${record.node}\u0000${target.id}`;
858
+ if (edgeSeen.has(key)) continue;
859
+ edgeSeen.add(key);
860
+ edges.push({
861
+ id: `wikilink:${record.node}:${target.id}`,
862
+ source: record.node,
863
+ target: target.id,
864
+ type: "wikilink",
865
+ recordId: record.id
866
+ });
867
+ }
868
+ graphRecords.push({
869
+ id: record.id,
870
+ nodeIds,
871
+ pinned: false,
872
+ text: truncateRecordText(record.text)
873
+ });
874
+ }
875
+ const pinnedRecords = await this.#pinnedRecords(view, pinnedNodeIds);
876
+ const accented = /* @__PURE__ */ new Set();
877
+ for (const { record } of pinnedRecords) {
878
+ const targets = [];
879
+ for (const name of parseKnowledgeWikilinks(record.text)) {
880
+ const target = await resolver.resolve(name, record.scope);
881
+ if (target && resolver.inWindowId(target.id) && !targets.includes(target.id)) targets.push(target.id);
882
+ }
883
+ graphRecords.push({
884
+ id: record.id,
885
+ nodeIds: targets,
886
+ pinned: true,
887
+ text: truncateRecordText(record.text)
888
+ });
889
+ if (targets.length === 1) {
890
+ accented.add(targets[0]);
891
+ continue;
892
+ }
893
+ for (let a = 0; a < targets.length; a += 1) for (let b = a + 1; b < targets.length; b += 1) {
894
+ const key = `${targets[a]}\u0000${targets[b]}\u0000pin`;
895
+ if (edgeSeen.has(key)) continue;
896
+ edgeSeen.add(key);
897
+ edges.push({
898
+ id: `pin:${record.id}:${targets[a]}:${targets[b]}`,
899
+ source: targets[a],
900
+ target: targets[b],
901
+ type: "wikilink",
902
+ recordId: record.id,
903
+ pinned: true
904
+ });
905
+ }
906
+ }
907
+ const pinCensus = {
908
+ resource: pinnedRecords.filter((p) => p.rung === "resource").length,
909
+ thread: view.view === "thread" ? pinnedRecords.filter((p) => p.rung === "thread").length : null
910
+ };
911
+ const activity = await store.listActivity({
912
+ scope,
913
+ limit: 1
914
+ });
915
+ const payload = {
916
+ view: view.view,
917
+ ...view.threadId ? { threadId: view.threadId } : {},
918
+ nodes: nodes.map((node) => ({
919
+ id: node.id,
920
+ name: node.name,
921
+ kind: node.kind,
922
+ ...node.description ? { description: node.description } : {},
923
+ scope: node.scope,
924
+ rung: deepestRung(node.scope),
925
+ pinned: accented.has(node.id),
926
+ recordCount: recordCounts.get(node.id) ?? 0,
927
+ createdAt: node.createdAt.toISOString(),
928
+ updatedAt: node.updatedAt.toISOString()
929
+ })),
930
+ edges,
931
+ records: graphRecords,
932
+ truncated,
933
+ outOfWindow: [...resolver.outOfWindow.values()],
934
+ unresolvedCapped: {
935
+ count: resolver.cappedCount,
936
+ names: resolver.cappedNames
937
+ },
938
+ pinCensus,
939
+ version: activity[0]?.id ?? null
940
+ };
941
+ return c.json(payload);
942
+ }
943
+ }),
944
+ registerApiRoute("/web/factory/projects/:id/knowledge/nodes/:nodeId", {
945
+ method: "GET",
946
+ requiresAuth: false,
947
+ handler: async (c) => {
948
+ const resolved = await this.#resolveView(loose(c));
949
+ if ("response" in resolved) return resolved.response;
950
+ const nodeId = loose(c).req.param("nodeId");
951
+ if (!nodeId || nodeId.length > 512) return c.json({ error: "node_not_found" }, 404);
952
+ const view = this.#selectedView(resolved, loose(c).req.query("scopeLevel"));
953
+ if (!view) return c.json({ error: "scope_not_found" }, 404);
954
+ const { store, scope } = view;
955
+ const node = await store.getNode(nodeId);
956
+ if (!node?.scope || !isKnowledgeScopeVisible(node.scope, scope)) return c.json({ error: "node_not_found" }, 404);
957
+ const pinnedNodeIds = await this.#pinnedNodeIds(view);
958
+ const pinnedNodeIdSet = new Set(pinnedNodeIds.map((p) => p.id));
959
+ const [owned, mentioning] = await Promise.all([store.listKnowledgeAbout({
960
+ node: node.id,
961
+ scope,
962
+ limit: 200
963
+ }), store.listKnowledgeMentioning({
964
+ node: node.id,
965
+ scope,
966
+ limit: 200
967
+ })]);
968
+ const seen = /* @__PURE__ */ new Set();
969
+ const records = [];
970
+ const push = (record, relation) => {
971
+ if (seen.has(record.id)) return;
972
+ seen.add(record.id);
973
+ records.push({
974
+ id: record.id,
975
+ node: record.node,
976
+ relation,
977
+ text: record.text,
978
+ scope: record.scope,
979
+ rung: deepestRung(record.scope),
980
+ sourceThreadId: record.sourceThreadId,
981
+ capturedAt: record.capturedAt.toISOString(),
982
+ ...record.when ? { when: record.when.toISOString() } : {},
983
+ pinned: pinnedNodeIdSet.has(record.node),
984
+ ...record.metadata ? { metadata: record.metadata } : {}
985
+ });
986
+ };
987
+ for (const record of [...owned.records].sort((a, b) => b.id.localeCompare(a.id))) push(record, "owned");
988
+ for (const record of [...mentioning.records].sort((a, b) => b.id.localeCompare(a.id))) push(record, "mentions");
989
+ const payload = {
990
+ node: {
991
+ id: node.id,
992
+ name: node.name,
993
+ kind: node.kind,
994
+ content: node.content ?? "",
995
+ ...node.description ? { description: node.description } : {},
996
+ scope: node.scope,
997
+ rung: deepestRung(node.scope),
998
+ createdAt: node.createdAt.toISOString(),
999
+ updatedAt: node.updatedAt.toISOString()
1000
+ },
1001
+ records
1002
+ };
1003
+ return c.json(payload);
1004
+ }
1005
+ }),
1006
+ registerApiRoute("/web/factory/projects/:id/knowledge/activity", {
1007
+ method: "GET",
1008
+ requiresAuth: false,
1009
+ handler: async (c) => {
1010
+ const resolved = await this.#resolveView(loose(c));
1011
+ if ("response" in resolved) return resolved.response;
1012
+ const scopeNodeId = loose(c).req.query("scopeNodeId");
1013
+ let view;
1014
+ let memberIds;
1015
+ let membersTruncated = false;
1016
+ if (scopeNodeId !== void 0) {
1017
+ if (!UUID_RE.test(scopeNodeId)) return c.json({ error: "scope_not_found" }, 404);
1018
+ let scopeNode;
1019
+ try {
1020
+ scopeNode = await findOrgScopeNode(resolved.store, resolved.orgId, scopeNodeId);
1021
+ } catch (error) {
1022
+ if (error instanceof KnowledgeUnsupportedCapabilityError) return c.json({ error: "scope_not_found" }, 404);
1023
+ throw error;
1024
+ }
1025
+ if (!scopeNode) return c.json({ error: "scope_not_found" }, 404);
1026
+ const { members, hasMore } = await resolved.store.listScopeMembers({
1027
+ scopeNodeId,
1028
+ limit: this.#limits.maxNodes
1029
+ });
1030
+ membersTruncated = hasMore || members.length > this.#limits.maxNodes;
1031
+ memberIds = new Set(members.slice(0, this.#limits.maxNodes).filter((member) => !member.isScope).map((member) => member.id));
1032
+ view = resolved;
1033
+ } else {
1034
+ const selected = this.#selectedView(resolved, loose(c).req.query("scopeLevel"));
1035
+ if (!selected) return c.json({ error: "scope_not_found" }, 404);
1036
+ view = selected;
1037
+ }
1038
+ const cursor = loose(c).req.query("cursor");
1039
+ if (cursor && cursor.length > 128) return c.json({ error: "invalid_activity_cursor" }, 400);
1040
+ const { items: activity, scanCursor } = await this.#visibleActivity(view, memberIds, cursor, 26);
1041
+ const visiblePage = activity.slice(0, ACTIVITY_PAGE_SIZE);
1042
+ const lastVisible = visiblePage.at(-1);
1043
+ const payload = {
1044
+ events: visiblePage.map(({ event, node }) => {
1045
+ const rung = deepestRung(node.scope);
1046
+ const threadId = rung === "thread" ? node.scope.find((address) => address.startsWith("thread:"))?.slice(7) : void 0;
1047
+ return {
1048
+ id: event.id,
1049
+ action: event.action,
1050
+ recordType: event.recordType,
1051
+ ...event.recordType === "record" ? { recordId: event.recordId } : {},
1052
+ scope: event.scope,
1053
+ node: {
1054
+ id: node.id,
1055
+ name: node.name,
1056
+ rung,
1057
+ ...threadId ? { threadId } : {}
1058
+ },
1059
+ createdAt: event.createdAt.toISOString()
1060
+ };
1061
+ }),
1062
+ ...activity.length > ACTIVITY_PAGE_SIZE && lastVisible ? { nextCursor: lastVisible.event.id } : scanCursor ? { nextCursor: scanCursor } : {},
1063
+ ...membersTruncated ? { truncated: true } : {}
1064
+ };
1065
+ return c.json(payload);
1066
+ }
1067
+ })
1068
+ ];
1069
+ }
1070
+ /**
1071
+ * Newest-first activity page where EVERY returned event targets a node
1072
+ * visible in the view. Visibility is decided BEFORE window shaping: hidden
1073
+ * rows are skipped entirely (no action/type/id/time metadata leaks) and a
1074
+ * hidden backlog can never displace visible events from the window.
1075
+ * When the scan cap stops the walk before the stream ends, `scanCursor` is
1076
+ * the last scanned event so the caller can continue past hidden rows.
1077
+ */
1078
+ async #visibleActivity(view, memberIds, cursor, limit) {
1079
+ const out = [];
1080
+ const nodes = /* @__PURE__ */ new Map();
1081
+ const getNode = (id) => {
1082
+ let node = nodes.get(id);
1083
+ if (!node) {
1084
+ node = view.store.getNode(id);
1085
+ nodes.set(id, node);
1086
+ }
1087
+ return node;
1088
+ };
1089
+ let after = cursor;
1090
+ let scanned = 0;
1091
+ let exhausted = false;
1092
+ while (out.length < limit && scanned < ACTIVITY_SCAN_CAP) {
1093
+ const batch = await view.store.listActivity({
1094
+ scope: view.scope,
1095
+ after,
1096
+ limit: ACTIVITY_BATCH
1097
+ });
1098
+ if (batch.length === 0) {
1099
+ exhausted = true;
1100
+ break;
1101
+ }
1102
+ for (const event of batch) {
1103
+ after = event.id;
1104
+ scanned += 1;
1105
+ let targetNode;
1106
+ if (event.recordType === "node") targetNode = await getNode(event.recordId);
1107
+ else {
1108
+ const record = await view.store.getKnowledge({ id: event.recordId });
1109
+ targetNode = record ? await getNode(record.node) : null;
1110
+ if (record && !isKnowledgeScopeVisible(record.scope, view.scope)) targetNode = null;
1111
+ }
1112
+ if (targetNode?.scope && isKnowledgeScopeVisible(targetNode.scope, view.scope) && (memberIds === void 0 || memberIds.has(targetNode.id))) out.push({
1113
+ event,
1114
+ node: targetNode
1115
+ });
1116
+ if (out.length >= limit || scanned >= ACTIVITY_SCAN_CAP) break;
1117
+ }
1118
+ }
1119
+ return {
1120
+ items: out,
1121
+ ...!exhausted && out.length < limit && scanned >= ACTIVITY_SCAN_CAP && after ? { scanCursor: after } : {}
1122
+ };
1123
+ }
1124
+ };
1125
+ //#endregion
1126
+ export { KnowledgeRoutes };
1127
+
1128
+ //# sourceMappingURL=knowledge.js.map