@penclipai/server 2026.401.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (779) hide show
  1. package/LICENSE +21 -0
  2. package/dist/adapters/codex-models.d.ts +4 -0
  3. package/dist/adapters/codex-models.d.ts.map +1 -0
  4. package/dist/adapters/codex-models.js +98 -0
  5. package/dist/adapters/codex-models.js.map +1 -0
  6. package/dist/adapters/cursor-models.d.ts +13 -0
  7. package/dist/adapters/cursor-models.d.ts.map +1 -0
  8. package/dist/adapters/cursor-models.js +148 -0
  9. package/dist/adapters/cursor-models.js.map +1 -0
  10. package/dist/adapters/http/execute.d.ts +3 -0
  11. package/dist/adapters/http/execute.d.ts.map +1 -0
  12. package/dist/adapters/http/execute.js +39 -0
  13. package/dist/adapters/http/execute.js.map +1 -0
  14. package/dist/adapters/http/index.d.ts +3 -0
  15. package/dist/adapters/http/index.d.ts.map +1 -0
  16. package/dist/adapters/http/index.js +20 -0
  17. package/dist/adapters/http/index.js.map +1 -0
  18. package/dist/adapters/http/test.d.ts +3 -0
  19. package/dist/adapters/http/test.d.ts.map +1 -0
  20. package/dist/adapters/http/test.js +106 -0
  21. package/dist/adapters/http/test.js.map +1 -0
  22. package/dist/adapters/index.d.ts +4 -0
  23. package/dist/adapters/index.d.ts.map +1 -0
  24. package/dist/adapters/index.js +3 -0
  25. package/dist/adapters/index.js.map +1 -0
  26. package/dist/adapters/process/execute.d.ts +3 -0
  27. package/dist/adapters/process/execute.d.ts.map +1 -0
  28. package/dist/adapters/process/execute.js +70 -0
  29. package/dist/adapters/process/execute.js.map +1 -0
  30. package/dist/adapters/process/index.d.ts +3 -0
  31. package/dist/adapters/process/index.d.ts.map +1 -0
  32. package/dist/adapters/process/index.js +23 -0
  33. package/dist/adapters/process/index.js.map +1 -0
  34. package/dist/adapters/process/test.d.ts +3 -0
  35. package/dist/adapters/process/test.d.ts.map +1 -0
  36. package/dist/adapters/process/test.js +77 -0
  37. package/dist/adapters/process/test.js.map +1 -0
  38. package/dist/adapters/registry.d.ts +14 -0
  39. package/dist/adapters/registry.d.ts.map +1 -0
  40. package/dist/adapters/registry.js +164 -0
  41. package/dist/adapters/registry.js.map +1 -0
  42. package/dist/adapters/types.d.ts +2 -0
  43. package/dist/adapters/types.d.ts.map +1 -0
  44. package/dist/adapters/types.js +2 -0
  45. package/dist/adapters/types.js.map +1 -0
  46. package/dist/adapters/utils.d.ts +41 -0
  47. package/dist/adapters/utils.d.ts.map +1 -0
  48. package/dist/adapters/utils.js +51 -0
  49. package/dist/adapters/utils.js.map +1 -0
  50. package/dist/agent-auth-jwt.d.ts +14 -0
  51. package/dist/agent-auth-jwt.d.ts.map +1 -0
  52. package/dist/agent-auth-jwt.js +117 -0
  53. package/dist/agent-auth-jwt.js.map +1 -0
  54. package/dist/app.d.ts +25 -0
  55. package/dist/app.d.ts.map +1 -0
  56. package/dist/app.js +268 -0
  57. package/dist/app.js.map +1 -0
  58. package/dist/attachment-types.d.ts +33 -0
  59. package/dist/attachment-types.d.ts.map +1 -0
  60. package/dist/attachment-types.js +67 -0
  61. package/dist/attachment-types.js.map +1 -0
  62. package/dist/auth/better-auth.d.ts +24 -0
  63. package/dist/auth/better-auth.d.ts.map +1 -0
  64. package/dist/auth/better-auth.js +108 -0
  65. package/dist/auth/better-auth.js.map +1 -0
  66. package/dist/board-claim.d.ts +23 -0
  67. package/dist/board-claim.d.ts.map +1 -0
  68. package/dist/board-claim.js +115 -0
  69. package/dist/board-claim.js.map +1 -0
  70. package/dist/config-file.d.ts +3 -0
  71. package/dist/config-file.d.ts.map +1 -0
  72. package/dist/config-file.js +16 -0
  73. package/dist/config-file.js.map +1 -0
  74. package/dist/config.d.ts +38 -0
  75. package/dist/config.d.ts.map +1 -0
  76. package/dist/config.js +164 -0
  77. package/dist/config.js.map +1 -0
  78. package/dist/dev-server-status.d.ts +27 -0
  79. package/dist/dev-server-status.d.ts.map +1 -0
  80. package/dist/dev-server-status.js +70 -0
  81. package/dist/dev-server-status.js.map +1 -0
  82. package/dist/dev-watch-ignore.d.ts +2 -0
  83. package/dist/dev-watch-ignore.d.ts.map +1 -0
  84. package/dist/dev-watch-ignore.js +33 -0
  85. package/dist/dev-watch-ignore.js.map +1 -0
  86. package/dist/errors.d.ts +12 -0
  87. package/dist/errors.d.ts.map +1 -0
  88. package/dist/errors.js +28 -0
  89. package/dist/errors.js.map +1 -0
  90. package/dist/home-paths.d.ts +17 -0
  91. package/dist/home-paths.d.ts.map +1 -0
  92. package/dist/home-paths.js +75 -0
  93. package/dist/home-paths.js.map +1 -0
  94. package/dist/i18n.d.ts +6 -0
  95. package/dist/i18n.d.ts.map +1 -0
  96. package/dist/i18n.js +52 -0
  97. package/dist/i18n.js.map +1 -0
  98. package/dist/index.d.ts +10 -0
  99. package/dist/index.d.ts.map +1 -0
  100. package/dist/index.js +662 -0
  101. package/dist/index.js.map +1 -0
  102. package/dist/log-redaction.d.ts +11 -0
  103. package/dist/log-redaction.d.ts.map +1 -0
  104. package/dist/log-redaction.js +118 -0
  105. package/dist/log-redaction.js.map +1 -0
  106. package/dist/middleware/auth.d.ts +12 -0
  107. package/dist/middleware/auth.d.ts.map +1 -0
  108. package/dist/middleware/auth.js +144 -0
  109. package/dist/middleware/auth.js.map +1 -0
  110. package/dist/middleware/board-mutation-guard.d.ts +3 -0
  111. package/dist/middleware/board-mutation-guard.d.ts.map +1 -0
  112. package/dist/middleware/board-mutation-guard.js +60 -0
  113. package/dist/middleware/board-mutation-guard.js.map +1 -0
  114. package/dist/middleware/error-handler.d.ts +17 -0
  115. package/dist/middleware/error-handler.d.ts.map +1 -0
  116. package/dist/middleware/error-handler.js +42 -0
  117. package/dist/middleware/error-handler.js.map +1 -0
  118. package/dist/middleware/index.d.ts +5 -0
  119. package/dist/middleware/index.d.ts.map +1 -0
  120. package/dist/middleware/index.js +5 -0
  121. package/dist/middleware/index.js.map +1 -0
  122. package/dist/middleware/locale.d.ts +3 -0
  123. package/dist/middleware/locale.d.ts.map +1 -0
  124. package/dist/middleware/locale.js +10 -0
  125. package/dist/middleware/locale.js.map +1 -0
  126. package/dist/middleware/logger.d.ts +4 -0
  127. package/dist/middleware/logger.d.ts.map +1 -0
  128. package/dist/middleware/logger.js +87 -0
  129. package/dist/middleware/logger.js.map +1 -0
  130. package/dist/middleware/private-hostname-guard.d.ts +11 -0
  131. package/dist/middleware/private-hostname-guard.d.ts.map +1 -0
  132. package/dist/middleware/private-hostname-guard.js +78 -0
  133. package/dist/middleware/private-hostname-guard.js.map +1 -0
  134. package/dist/middleware/validate.d.ts +4 -0
  135. package/dist/middleware/validate.d.ts.map +1 -0
  136. package/dist/middleware/validate.js +7 -0
  137. package/dist/middleware/validate.js.map +1 -0
  138. package/dist/onboarding-assets/ceo/AGENTS.md +54 -0
  139. package/dist/onboarding-assets/ceo/HEARTBEAT.md +73 -0
  140. package/dist/onboarding-assets/ceo/SOUL.md +33 -0
  141. package/dist/onboarding-assets/ceo/TOOLS.md +3 -0
  142. package/dist/onboarding-assets/default/AGENTS.md +3 -0
  143. package/dist/paths.d.ts +3 -0
  144. package/dist/paths.d.ts.map +1 -0
  145. package/dist/paths.js +31 -0
  146. package/dist/paths.js.map +1 -0
  147. package/dist/realtime/live-events-ws.d.ts +28 -0
  148. package/dist/realtime/live-events-ws.d.ts.map +1 -0
  149. package/dist/realtime/live-events-ws.js +187 -0
  150. package/dist/realtime/live-events-ws.js.map +1 -0
  151. package/dist/redaction.d.ts +4 -0
  152. package/dist/redaction.d.ts.map +1 -0
  153. package/dist/redaction.js +63 -0
  154. package/dist/redaction.js.map +1 -0
  155. package/dist/routes/access.d.ts +62 -0
  156. package/dist/routes/access.d.ts.map +1 -0
  157. package/dist/routes/access.js +2296 -0
  158. package/dist/routes/access.js.map +1 -0
  159. package/dist/routes/activity.d.ts +3 -0
  160. package/dist/routes/activity.d.ts.map +1 -0
  161. package/dist/routes/activity.js +78 -0
  162. package/dist/routes/activity.js.map +1 -0
  163. package/dist/routes/agents.d.ts +3 -0
  164. package/dist/routes/agents.d.ts.map +1 -0
  165. package/dist/routes/agents.js +1847 -0
  166. package/dist/routes/agents.js.map +1 -0
  167. package/dist/routes/approvals.d.ts +3 -0
  168. package/dist/routes/approvals.d.ts.map +1 -0
  169. package/dist/routes/approvals.js +278 -0
  170. package/dist/routes/approvals.js.map +1 -0
  171. package/dist/routes/assets.d.ts +4 -0
  172. package/dist/routes/assets.d.ts.map +1 -0
  173. package/dist/routes/assets.js +309 -0
  174. package/dist/routes/assets.js.map +1 -0
  175. package/dist/routes/authz.d.ts +16 -0
  176. package/dist/routes/authz.d.ts.map +1 -0
  177. package/dist/routes/authz.js +47 -0
  178. package/dist/routes/authz.js.map +1 -0
  179. package/dist/routes/companies.d.ts +4 -0
  180. package/dist/routes/companies.d.ts.map +1 -0
  181. package/dist/routes/companies.js +303 -0
  182. package/dist/routes/companies.js.map +1 -0
  183. package/dist/routes/company-skills.d.ts +3 -0
  184. package/dist/routes/company-skills.d.ts.map +1 -0
  185. package/dist/routes/company-skills.js +228 -0
  186. package/dist/routes/company-skills.js.map +1 -0
  187. package/dist/routes/costs.d.ts +3 -0
  188. package/dist/routes/costs.d.ts.map +1 -0
  189. package/dist/routes/costs.js +268 -0
  190. package/dist/routes/costs.js.map +1 -0
  191. package/dist/routes/dashboard.d.ts +3 -0
  192. package/dist/routes/dashboard.d.ts.map +1 -0
  193. package/dist/routes/dashboard.js +15 -0
  194. package/dist/routes/dashboard.js.map +1 -0
  195. package/dist/routes/execution-workspaces.d.ts +3 -0
  196. package/dist/routes/execution-workspaces.d.ts.map +1 -0
  197. package/dist/routes/execution-workspaces.js +367 -0
  198. package/dist/routes/execution-workspaces.js.map +1 -0
  199. package/dist/routes/goals.d.ts +3 -0
  200. package/dist/routes/goals.d.ts.map +1 -0
  201. package/dist/routes/goals.js +95 -0
  202. package/dist/routes/goals.js.map +1 -0
  203. package/dist/routes/health.d.ts +9 -0
  204. package/dist/routes/health.d.ts.map +1 -0
  205. package/dist/routes/health.js +80 -0
  206. package/dist/routes/health.js.map +1 -0
  207. package/dist/routes/index.d.ts +18 -0
  208. package/dist/routes/index.d.ts.map +1 -0
  209. package/dist/routes/index.js +18 -0
  210. package/dist/routes/index.js.map +1 -0
  211. package/dist/routes/instance-settings.d.ts +3 -0
  212. package/dist/routes/instance-settings.d.ts.map +1 -0
  213. package/dist/routes/instance-settings.js +71 -0
  214. package/dist/routes/instance-settings.js.map +1 -0
  215. package/dist/routes/issues-checkout-wakeup.d.ts +9 -0
  216. package/dist/routes/issues-checkout-wakeup.d.ts.map +1 -0
  217. package/dist/routes/issues-checkout-wakeup.js +12 -0
  218. package/dist/routes/issues-checkout-wakeup.js.map +1 -0
  219. package/dist/routes/issues.d.ts +4 -0
  220. package/dist/routes/issues.d.ts.map +1 -0
  221. package/dist/routes/issues.js +1622 -0
  222. package/dist/routes/issues.js.map +1 -0
  223. package/dist/routes/llms.d.ts +3 -0
  224. package/dist/routes/llms.d.ts.map +1 -0
  225. package/dist/routes/llms.js +78 -0
  226. package/dist/routes/llms.js.map +1 -0
  227. package/dist/routes/org-chart-svg.d.ts +25 -0
  228. package/dist/routes/org-chart-svg.d.ts.map +1 -0
  229. package/dist/routes/org-chart-svg.js +656 -0
  230. package/dist/routes/org-chart-svg.js.map +1 -0
  231. package/dist/routes/plugin-ui-static.d.ts +69 -0
  232. package/dist/routes/plugin-ui-static.d.ts.map +1 -0
  233. package/dist/routes/plugin-ui-static.js +411 -0
  234. package/dist/routes/plugin-ui-static.js.map +1 -0
  235. package/dist/routes/plugins.d.ts +120 -0
  236. package/dist/routes/plugins.d.ts.map +1 -0
  237. package/dist/routes/plugins.js +1784 -0
  238. package/dist/routes/plugins.js.map +1 -0
  239. package/dist/routes/projects.d.ts +3 -0
  240. package/dist/routes/projects.d.ts.map +1 -0
  241. package/dist/routes/projects.js +386 -0
  242. package/dist/routes/projects.js.map +1 -0
  243. package/dist/routes/routines.d.ts +3 -0
  244. package/dist/routes/routines.d.ts.map +1 -0
  245. package/dist/routes/routines.js +277 -0
  246. package/dist/routes/routines.js.map +1 -0
  247. package/dist/routes/secrets.d.ts +3 -0
  248. package/dist/routes/secrets.d.ts.map +1 -0
  249. package/dist/routes/secrets.js +128 -0
  250. package/dist/routes/secrets.js.map +1 -0
  251. package/dist/routes/sidebar-badges.d.ts +3 -0
  252. package/dist/routes/sidebar-badges.d.ts.map +1 -0
  253. package/dist/routes/sidebar-badges.js +45 -0
  254. package/dist/routes/sidebar-badges.js.map +1 -0
  255. package/dist/secrets/external-stub-providers.d.ts +5 -0
  256. package/dist/secrets/external-stub-providers.d.ts.map +1 -0
  257. package/dist/secrets/external-stub-providers.js +21 -0
  258. package/dist/secrets/external-stub-providers.js.map +1 -0
  259. package/dist/secrets/local-encrypted-provider.d.ts +3 -0
  260. package/dist/secrets/local-encrypted-provider.d.ts.map +1 -0
  261. package/dist/secrets/local-encrypted-provider.js +116 -0
  262. package/dist/secrets/local-encrypted-provider.js.map +1 -0
  263. package/dist/secrets/provider-registry.d.ts +5 -0
  264. package/dist/secrets/provider-registry.d.ts.map +1 -0
  265. package/dist/secrets/provider-registry.js +20 -0
  266. package/dist/secrets/provider-registry.js.map +1 -0
  267. package/dist/secrets/types.d.ts +21 -0
  268. package/dist/secrets/types.d.ts.map +1 -0
  269. package/dist/secrets/types.js +2 -0
  270. package/dist/secrets/types.js.map +1 -0
  271. package/dist/services/access.d.ts +113 -0
  272. package/dist/services/access.d.ts.map +1 -0
  273. package/dist/services/access.js +247 -0
  274. package/dist/services/access.js.map +1 -0
  275. package/dist/services/activity-log.d.ts +17 -0
  276. package/dist/services/activity-log.d.ts.map +1 -0
  277. package/dist/services/activity-log.js +74 -0
  278. package/dist/services/activity-log.js.map +1 -0
  279. package/dist/services/activity.d.ts +764 -0
  280. package/dist/services/activity.d.ts.map +1 -0
  281. package/dist/services/activity.js +105 -0
  282. package/dist/services/activity.js.map +1 -0
  283. package/dist/services/agent-instructions.d.ts +91 -0
  284. package/dist/services/agent-instructions.d.ts.map +1 -0
  285. package/dist/services/agent-instructions.js +580 -0
  286. package/dist/services/agent-instructions.js.map +1 -0
  287. package/dist/services/agent-permissions.d.ts +6 -0
  288. package/dist/services/agent-permissions.d.ts.map +1 -0
  289. package/dist/services/agent-permissions.js +18 -0
  290. package/dist/services/agent-permissions.js.map +1 -0
  291. package/dist/services/agent-runtime-localization.d.ts +10 -0
  292. package/dist/services/agent-runtime-localization.d.ts.map +1 -0
  293. package/dist/services/agent-runtime-localization.js +114 -0
  294. package/dist/services/agent-runtime-localization.js.map +1 -0
  295. package/dist/services/agents.d.ts +1670 -0
  296. package/dist/services/agents.d.ts.map +1 -0
  297. package/dist/services/agents.js +566 -0
  298. package/dist/services/agents.js.map +1 -0
  299. package/dist/services/approvals.d.ts +546 -0
  300. package/dist/services/approvals.d.ts.map +1 -0
  301. package/dist/services/approvals.js +212 -0
  302. package/dist/services/approvals.js.map +1 -0
  303. package/dist/services/assets.d.ts +33 -0
  304. package/dist/services/assets.d.ts.map +1 -0
  305. package/dist/services/assets.js +17 -0
  306. package/dist/services/assets.js.map +1 -0
  307. package/dist/services/board-auth.d.ts +234 -0
  308. package/dist/services/board-auth.d.ts.map +1 -0
  309. package/dist/services/board-auth.js +295 -0
  310. package/dist/services/board-auth.js.map +1 -0
  311. package/dist/services/budgets.d.ts +38 -0
  312. package/dist/services/budgets.d.ts.map +1 -0
  313. package/dist/services/budgets.js +784 -0
  314. package/dist/services/budgets.js.map +1 -0
  315. package/dist/services/companies.d.ts +124 -0
  316. package/dist/services/companies.d.ts.map +1 -0
  317. package/dist/services/companies.js +256 -0
  318. package/dist/services/companies.js.map +1 -0
  319. package/dist/services/company-export-readme.d.ts +17 -0
  320. package/dist/services/company-export-readme.d.ts.map +1 -0
  321. package/dist/services/company-export-readme.js +148 -0
  322. package/dist/services/company-export-readme.js.map +1 -0
  323. package/dist/services/company-portability.d.ts +23 -0
  324. package/dist/services/company-portability.d.ts.map +1 -0
  325. package/dist/services/company-portability.js +3759 -0
  326. package/dist/services/company-portability.js.map +1 -0
  327. package/dist/services/company-skills.d.ts +77 -0
  328. package/dist/services/company-skills.d.ts.map +1 -0
  329. package/dist/services/company-skills.js +2069 -0
  330. package/dist/services/company-skills.js.map +1 -0
  331. package/dist/services/costs.d.ts +114 -0
  332. package/dist/services/costs.d.ts.map +1 -0
  333. package/dist/services/costs.js +294 -0
  334. package/dist/services/costs.js.map +1 -0
  335. package/dist/services/cron.d.ts +80 -0
  336. package/dist/services/cron.d.ts.map +1 -0
  337. package/dist/services/cron.js +300 -0
  338. package/dist/services/cron.js.map +1 -0
  339. package/dist/services/dashboard.d.ts +26 -0
  340. package/dist/services/dashboard.d.ts.map +1 -0
  341. package/dist/services/dashboard.js +98 -0
  342. package/dist/services/dashboard.js.map +1 -0
  343. package/dist/services/default-agent-instructions.d.ts +9 -0
  344. package/dist/services/default-agent-instructions.d.ts.map +1 -0
  345. package/dist/services/default-agent-instructions.js +20 -0
  346. package/dist/services/default-agent-instructions.js.map +1 -0
  347. package/dist/services/documents.d.ts +164 -0
  348. package/dist/services/documents.d.ts.map +1 -0
  349. package/dist/services/documents.js +382 -0
  350. package/dist/services/documents.js.map +1 -0
  351. package/dist/services/execution-workspace-policy.d.ts +21 -0
  352. package/dist/services/execution-workspace-policy.d.ts.map +1 -0
  353. package/dist/services/execution-workspace-policy.js +177 -0
  354. package/dist/services/execution-workspace-policy.js.map +1 -0
  355. package/dist/services/execution-workspaces.d.ts +22 -0
  356. package/dist/services/execution-workspaces.d.ts.map +1 -0
  357. package/dist/services/execution-workspaces.js +551 -0
  358. package/dist/services/execution-workspaces.js.map +1 -0
  359. package/dist/services/finance.d.ts +93 -0
  360. package/dist/services/finance.d.ts.map +1 -0
  361. package/dist/services/finance.js +120 -0
  362. package/dist/services/finance.js.map +1 -0
  363. package/dist/services/goals.d.ts +433 -0
  364. package/dist/services/goals.d.ts.map +1 -0
  365. package/dist/services/goals.js +54 -0
  366. package/dist/services/goals.js.map +1 -0
  367. package/dist/services/heartbeat-run-summary.d.ts +2 -0
  368. package/dist/services/heartbeat-run-summary.d.ts.map +1 -0
  369. package/dist/services/heartbeat-run-summary.js +30 -0
  370. package/dist/services/heartbeat-run-summary.js.map +1 -0
  371. package/dist/services/heartbeat.d.ts +833 -0
  372. package/dist/services/heartbeat.d.ts.map +1 -0
  373. package/dist/services/heartbeat.js +3299 -0
  374. package/dist/services/heartbeat.js.map +1 -0
  375. package/dist/services/hire-hook.d.ts +14 -0
  376. package/dist/services/hire-hook.d.ts.map +1 -0
  377. package/dist/services/hire-hook.js +85 -0
  378. package/dist/services/hire-hook.js.map +1 -0
  379. package/dist/services/index.d.ts +33 -0
  380. package/dist/services/index.d.ts.map +1 -0
  381. package/dist/services/index.js +33 -0
  382. package/dist/services/index.js.map +1 -0
  383. package/dist/services/instance-settings.d.ts +11 -0
  384. package/dist/services/instance-settings.d.ts.map +1 -0
  385. package/dist/services/instance-settings.js +116 -0
  386. package/dist/services/instance-settings.js.map +1 -0
  387. package/dist/services/issue-approvals.d.ts +56 -0
  388. package/dist/services/issue-approvals.d.ts.map +1 -0
  389. package/dist/services/issue-approvals.js +153 -0
  390. package/dist/services/issue-approvals.js.map +1 -0
  391. package/dist/services/issue-assignment-wakeup.d.ts +31 -0
  392. package/dist/services/issue-assignment-wakeup.d.ts.map +1 -0
  393. package/dist/services/issue-assignment-wakeup.js +26 -0
  394. package/dist/services/issue-assignment-wakeup.js.map +1 -0
  395. package/dist/services/issue-goal-fallback.d.ts +18 -0
  396. package/dist/services/issue-goal-fallback.d.ts.map +1 -0
  397. package/dist/services/issue-goal-fallback.js +33 -0
  398. package/dist/services/issue-goal-fallback.js.map +1 -0
  399. package/dist/services/issues.d.ts +564 -0
  400. package/dist/services/issues.d.ts.map +1 -0
  401. package/dist/services/issues.js +1541 -0
  402. package/dist/services/issues.js.map +1 -0
  403. package/dist/services/live-events.d.ts +17 -0
  404. package/dist/services/live-events.d.ts.map +1 -0
  405. package/dist/services/live-events.js +33 -0
  406. package/dist/services/live-events.js.map +1 -0
  407. package/dist/services/local-service-supervisor.d.ts +55 -0
  408. package/dist/services/local-service-supervisor.d.ts.map +1 -0
  409. package/dist/services/local-service-supervisor.js +240 -0
  410. package/dist/services/local-service-supervisor.js.map +1 -0
  411. package/dist/services/plugin-capability-validator.d.ts +108 -0
  412. package/dist/services/plugin-capability-validator.d.ts.map +1 -0
  413. package/dist/services/plugin-capability-validator.js +268 -0
  414. package/dist/services/plugin-capability-validator.js.map +1 -0
  415. package/dist/services/plugin-config-validator.d.ts +26 -0
  416. package/dist/services/plugin-config-validator.d.ts.map +1 -0
  417. package/dist/services/plugin-config-validator.js +41 -0
  418. package/dist/services/plugin-config-validator.js.map +1 -0
  419. package/dist/services/plugin-dev-watcher.d.ts +30 -0
  420. package/dist/services/plugin-dev-watcher.d.ts.map +1 -0
  421. package/dist/services/plugin-dev-watcher.js +241 -0
  422. package/dist/services/plugin-dev-watcher.js.map +1 -0
  423. package/dist/services/plugin-event-bus.d.ts +149 -0
  424. package/dist/services/plugin-event-bus.d.ts.map +1 -0
  425. package/dist/services/plugin-event-bus.js +258 -0
  426. package/dist/services/plugin-event-bus.js.map +1 -0
  427. package/dist/services/plugin-host-service-cleanup.d.ts +14 -0
  428. package/dist/services/plugin-host-service-cleanup.d.ts.map +1 -0
  429. package/dist/services/plugin-host-service-cleanup.js +37 -0
  430. package/dist/services/plugin-host-service-cleanup.js.map +1 -0
  431. package/dist/services/plugin-host-services.d.ts +13 -0
  432. package/dist/services/plugin-host-services.d.ts.map +1 -0
  433. package/dist/services/plugin-host-services.js +969 -0
  434. package/dist/services/plugin-host-services.js.map +1 -0
  435. package/dist/services/plugin-job-coordinator.d.ts +81 -0
  436. package/dist/services/plugin-job-coordinator.d.ts.map +1 -0
  437. package/dist/services/plugin-job-coordinator.js +172 -0
  438. package/dist/services/plugin-job-coordinator.js.map +1 -0
  439. package/dist/services/plugin-job-scheduler.d.ts +163 -0
  440. package/dist/services/plugin-job-scheduler.d.ts.map +1 -0
  441. package/dist/services/plugin-job-scheduler.js +454 -0
  442. package/dist/services/plugin-job-scheduler.js.map +1 -0
  443. package/dist/services/plugin-job-store.d.ts +208 -0
  444. package/dist/services/plugin-job-store.d.ts.map +1 -0
  445. package/dist/services/plugin-job-store.js +350 -0
  446. package/dist/services/plugin-job-store.js.map +1 -0
  447. package/dist/services/plugin-lifecycle.d.ts +203 -0
  448. package/dist/services/plugin-lifecycle.d.ts.map +1 -0
  449. package/dist/services/plugin-lifecycle.js +476 -0
  450. package/dist/services/plugin-lifecycle.js.map +1 -0
  451. package/dist/services/plugin-loader.d.ts +441 -0
  452. package/dist/services/plugin-loader.d.ts.map +1 -0
  453. package/dist/services/plugin-loader.js +1192 -0
  454. package/dist/services/plugin-loader.js.map +1 -0
  455. package/dist/services/plugin-log-retention.d.ts +20 -0
  456. package/dist/services/plugin-log-retention.d.ts.map +1 -0
  457. package/dist/services/plugin-log-retention.js +63 -0
  458. package/dist/services/plugin-log-retention.js.map +1 -0
  459. package/dist/services/plugin-manifest-validator.d.ts +79 -0
  460. package/dist/services/plugin-manifest-validator.d.ts.map +1 -0
  461. package/dist/services/plugin-manifest-validator.js +84 -0
  462. package/dist/services/plugin-manifest-validator.js.map +1 -0
  463. package/dist/services/plugin-registry.d.ts +2542 -0
  464. package/dist/services/plugin-registry.d.ts.map +1 -0
  465. package/dist/services/plugin-registry.js +539 -0
  466. package/dist/services/plugin-registry.js.map +1 -0
  467. package/dist/services/plugin-runtime-sandbox.d.ts +40 -0
  468. package/dist/services/plugin-runtime-sandbox.d.ts.map +1 -0
  469. package/dist/services/plugin-runtime-sandbox.js +154 -0
  470. package/dist/services/plugin-runtime-sandbox.js.map +1 -0
  471. package/dist/services/plugin-secrets-handler.d.ts +81 -0
  472. package/dist/services/plugin-secrets-handler.d.ts.map +1 -0
  473. package/dist/services/plugin-secrets-handler.js +275 -0
  474. package/dist/services/plugin-secrets-handler.js.map +1 -0
  475. package/dist/services/plugin-state-store.d.ts +92 -0
  476. package/dist/services/plugin-state-store.d.ts.map +1 -0
  477. package/dist/services/plugin-state-store.js +190 -0
  478. package/dist/services/plugin-state-store.js.map +1 -0
  479. package/dist/services/plugin-stream-bus.d.ts +29 -0
  480. package/dist/services/plugin-stream-bus.d.ts.map +1 -0
  481. package/dist/services/plugin-stream-bus.js +48 -0
  482. package/dist/services/plugin-stream-bus.js.map +1 -0
  483. package/dist/services/plugin-tool-dispatcher.d.ts +180 -0
  484. package/dist/services/plugin-tool-dispatcher.d.ts.map +1 -0
  485. package/dist/services/plugin-tool-dispatcher.js +224 -0
  486. package/dist/services/plugin-tool-dispatcher.js.map +1 -0
  487. package/dist/services/plugin-tool-registry.d.ts +192 -0
  488. package/dist/services/plugin-tool-registry.d.ts.map +1 -0
  489. package/dist/services/plugin-tool-registry.js +224 -0
  490. package/dist/services/plugin-tool-registry.js.map +1 -0
  491. package/dist/services/plugin-worker-manager.d.ts +260 -0
  492. package/dist/services/plugin-worker-manager.d.ts.map +1 -0
  493. package/dist/services/plugin-worker-manager.js +835 -0
  494. package/dist/services/plugin-worker-manager.js.map +1 -0
  495. package/dist/services/project-workspace-runtime-config.d.ts +4 -0
  496. package/dist/services/project-workspace-runtime-config.d.ts.map +1 -0
  497. package/dist/services/project-workspace-runtime-config.js +43 -0
  498. package/dist/services/project-workspace-runtime-config.js.map +1 -0
  499. package/dist/services/projects.d.ts +88 -0
  500. package/dist/services/projects.d.ts.map +1 -0
  501. package/dist/services/projects.js +666 -0
  502. package/dist/services/projects.js.map +1 -0
  503. package/dist/services/quota-windows.d.ts +9 -0
  504. package/dist/services/quota-windows.d.ts.map +1 -0
  505. package/dist/services/quota-windows.js +56 -0
  506. package/dist/services/quota-windows.js.map +1 -0
  507. package/dist/services/routines.d.ts +135 -0
  508. package/dist/services/routines.d.ts.map +1 -0
  509. package/dist/services/routines.js +1105 -0
  510. package/dist/services/routines.js.map +1 -0
  511. package/dist/services/run-log-store.d.ts +34 -0
  512. package/dist/services/run-log-store.d.ts.map +1 -0
  513. package/dist/services/run-log-store.js +109 -0
  514. package/dist/services/run-log-store.js.map +1 -0
  515. package/dist/services/secrets.d.ts +511 -0
  516. package/dist/services/secrets.d.ts.map +1 -0
  517. package/dist/services/secrets.js +289 -0
  518. package/dist/services/secrets.js.map +1 -0
  519. package/dist/services/sidebar-badges.d.ts +9 -0
  520. package/dist/services/sidebar-badges.d.ts.map +1 -0
  521. package/dist/services/sidebar-badges.js +33 -0
  522. package/dist/services/sidebar-badges.js.map +1 -0
  523. package/dist/services/work-products.d.ts +14 -0
  524. package/dist/services/work-products.d.ts.map +1 -0
  525. package/dist/services/work-products.js +100 -0
  526. package/dist/services/work-products.js.map +1 -0
  527. package/dist/services/workspace-operation-log-store.d.ts +33 -0
  528. package/dist/services/workspace-operation-log-store.d.ts.map +1 -0
  529. package/dist/services/workspace-operation-log-store.js +110 -0
  530. package/dist/services/workspace-operation-log-store.js.map +1 -0
  531. package/dist/services/workspace-operations.d.ts +44 -0
  532. package/dist/services/workspace-operations.d.ts.map +1 -0
  533. package/dist/services/workspace-operations.js +211 -0
  534. package/dist/services/workspace-operations.js.map +1 -0
  535. package/dist/services/workspace-runtime.d.ts +187 -0
  536. package/dist/services/workspace-runtime.d.ts.map +1 -0
  537. package/dist/services/workspace-runtime.js +1728 -0
  538. package/dist/services/workspace-runtime.js.map +1 -0
  539. package/dist/startup-banner.d.ts +31 -0
  540. package/dist/startup-banner.d.ts.map +1 -0
  541. package/dist/startup-banner.js +117 -0
  542. package/dist/startup-banner.js.map +1 -0
  543. package/dist/storage/index.d.ts +6 -0
  544. package/dist/storage/index.d.ts.map +1 -0
  545. package/dist/storage/index.js +29 -0
  546. package/dist/storage/index.js.map +1 -0
  547. package/dist/storage/local-disk-provider.d.ts +3 -0
  548. package/dist/storage/local-disk-provider.d.ts.map +1 -0
  549. package/dist/storage/local-disk-provider.js +79 -0
  550. package/dist/storage/local-disk-provider.js.map +1 -0
  551. package/dist/storage/provider-registry.d.ts +4 -0
  552. package/dist/storage/provider-registry.d.ts.map +1 -0
  553. package/dist/storage/provider-registry.js +15 -0
  554. package/dist/storage/provider-registry.js.map +1 -0
  555. package/dist/storage/s3-provider.d.ts +11 -0
  556. package/dist/storage/s3-provider.d.ts.map +1 -0
  557. package/dist/storage/s3-provider.js +123 -0
  558. package/dist/storage/s3-provider.js.map +1 -0
  559. package/dist/storage/service.d.ts +3 -0
  560. package/dist/storage/service.d.ts.map +1 -0
  561. package/dist/storage/service.js +120 -0
  562. package/dist/storage/service.js.map +1 -0
  563. package/dist/storage/types.d.ts +55 -0
  564. package/dist/storage/types.d.ts.map +1 -0
  565. package/dist/storage/types.js +2 -0
  566. package/dist/storage/types.js.map +1 -0
  567. package/dist/ui-branding.d.ts +13 -0
  568. package/dist/ui-branding.d.ts.map +1 -0
  569. package/dist/ui-branding.js +187 -0
  570. package/dist/ui-branding.js.map +1 -0
  571. package/dist/ui-locale.d.ts +11 -0
  572. package/dist/ui-locale.d.ts.map +1 -0
  573. package/dist/ui-locale.js +79 -0
  574. package/dist/ui-locale.js.map +1 -0
  575. package/dist/version.d.ts +2 -0
  576. package/dist/version.d.ts.map +1 -0
  577. package/dist/version.js +5 -0
  578. package/dist/version.js.map +1 -0
  579. package/dist/worktree-config.d.ts +19 -0
  580. package/dist/worktree-config.d.ts.map +1 -0
  581. package/dist/worktree-config.js +365 -0
  582. package/dist/worktree-config.js.map +1 -0
  583. package/package.json +91 -0
  584. package/skills/paperclip/SKILL.md +369 -0
  585. package/skills/paperclip/references/api-reference.md +676 -0
  586. package/skills/paperclip/references/company-skills.md +193 -0
  587. package/skills/paperclip-create-agent/SKILL.md +142 -0
  588. package/skills/paperclip-create-agent/references/api-reference.md +105 -0
  589. package/skills/paperclip-create-plugin/SKILL.md +101 -0
  590. package/skills/para-memory-files/SKILL.md +104 -0
  591. package/skills/para-memory-files/references/schemas.md +35 -0
  592. package/ui-dist/android-chrome-192x192.png +0 -0
  593. package/ui-dist/android-chrome-512x512.png +0 -0
  594. package/ui-dist/apple-touch-icon.png +0 -0
  595. package/ui-dist/assets/_basePickBy-BTQXevF1.js +1 -0
  596. package/ui-dist/assets/_baseUniq-BEhTac1J.js +1 -0
  597. package/ui-dist/assets/apl-B4CMkyY2.js +1 -0
  598. package/ui-dist/assets/arc-DxO8rLLU.js +1 -0
  599. package/ui-dist/assets/architectureDiagram-VXUJARFQ-Di2BSwQa.js +36 -0
  600. package/ui-dist/assets/asciiarmor-Df11BRmG.js +1 -0
  601. package/ui-dist/assets/asn1-EdZsLKOL.js +1 -0
  602. package/ui-dist/assets/asterisk-B-8jnY81.js +1 -0
  603. package/ui-dist/assets/blockDiagram-VD42YOAC-5IzJ5K6l.js +122 -0
  604. package/ui-dist/assets/brainfuck-C4LP7Hcl.js +1 -0
  605. package/ui-dist/assets/browser-ponyfill-Blw8korJ.js +2 -0
  606. package/ui-dist/assets/c4Diagram-YG6GDRKO-CrsidOqT.js +10 -0
  607. package/ui-dist/assets/channel-DuGyOef5.js +1 -0
  608. package/ui-dist/assets/chunk-4BX2VUAB-BHSGXFUt.js +1 -0
  609. package/ui-dist/assets/chunk-55IACEB6-Cj2QfdtL.js +1 -0
  610. package/ui-dist/assets/chunk-B4BG7PRW-BYCjGKK1.js +165 -0
  611. package/ui-dist/assets/chunk-DI55MBZ5-DmN3CZF1.js +220 -0
  612. package/ui-dist/assets/chunk-FMBD7UC4--jRhF8Cs.js +15 -0
  613. package/ui-dist/assets/chunk-QN33PNHL-XPpU2fj1.js +1 -0
  614. package/ui-dist/assets/chunk-QZHKN3VN-DLW8c9sV.js +1 -0
  615. package/ui-dist/assets/chunk-TZMSLE5B-DmGFEq3D.js +1 -0
  616. package/ui-dist/assets/classDiagram-2ON5EDUG-BOzhJlXp.js +1 -0
  617. package/ui-dist/assets/classDiagram-v2-WZHVMYZB-BOzhJlXp.js +1 -0
  618. package/ui-dist/assets/clike-B9uivgTg.js +1 -0
  619. package/ui-dist/assets/clojure-BMjYHr_A.js +1 -0
  620. package/ui-dist/assets/clone-MN5EUjO9.js +1 -0
  621. package/ui-dist/assets/cmake-BQqOBYOt.js +1 -0
  622. package/ui-dist/assets/cobol-CWcv1MsR.js +1 -0
  623. package/ui-dist/assets/coffeescript-S37ZYGWr.js +1 -0
  624. package/ui-dist/assets/commonlisp-DBKNyK5s.js +1 -0
  625. package/ui-dist/assets/cose-bilkent-S5V4N54A-Cqt3TJKm.js +1 -0
  626. package/ui-dist/assets/crystal-SjHAIU92.js +1 -0
  627. package/ui-dist/assets/css-BnMrqG3P.js +1 -0
  628. package/ui-dist/assets/cypher-C_CwsFkJ.js +1 -0
  629. package/ui-dist/assets/cytoscape.esm-BQaXIfA_.js +331 -0
  630. package/ui-dist/assets/d-pRatUO7H.js +1 -0
  631. package/ui-dist/assets/dagre-6UL2VRFP-jYpzbH9A.js +4 -0
  632. package/ui-dist/assets/defaultLocale-DX6XiGOO.js +1 -0
  633. package/ui-dist/assets/diagram-PSM6KHXK-Dc1Hv-Vh.js +24 -0
  634. package/ui-dist/assets/diagram-QEK2KX5R-oPEQIYAR.js +43 -0
  635. package/ui-dist/assets/diagram-S2PKOQOG-B6uyGC_6.js +24 -0
  636. package/ui-dist/assets/diff-DbItnlRl.js +1 -0
  637. package/ui-dist/assets/dockerfile-BKs6k2Af.js +1 -0
  638. package/ui-dist/assets/dtd-DF_7sFjM.js +1 -0
  639. package/ui-dist/assets/dylan-DwRh75JA.js +1 -0
  640. package/ui-dist/assets/ebnf-CDyGwa7X.js +1 -0
  641. package/ui-dist/assets/ecl-Cabwm37j.js +1 -0
  642. package/ui-dist/assets/eiffel-CnydiIhH.js +1 -0
  643. package/ui-dist/assets/elm-vLlmbW-K.js +1 -0
  644. package/ui-dist/assets/erDiagram-Q2GNP2WA-BYeILDJ-.js +60 -0
  645. package/ui-dist/assets/erlang-BNw1qcRV.js +1 -0
  646. package/ui-dist/assets/factor-kuTfRLto.js +1 -0
  647. package/ui-dist/assets/fcl-Kvtd6kyn.js +1 -0
  648. package/ui-dist/assets/flowDiagram-NV44I4VS-D_QtgcHc.js +162 -0
  649. package/ui-dist/assets/forth-Ffai-XNe.js +1 -0
  650. package/ui-dist/assets/fortran-DYz_wnZ1.js +1 -0
  651. package/ui-dist/assets/ganttDiagram-JELNMOA3-BUm8gqM3.js +267 -0
  652. package/ui-dist/assets/gas-Bneqetm1.js +1 -0
  653. package/ui-dist/assets/gherkin-heZmZLOM.js +1 -0
  654. package/ui-dist/assets/gitGraphDiagram-V2S2FVAM-BI-Sg0Go.js +65 -0
  655. package/ui-dist/assets/graph-BUqC2_Eh.js +1 -0
  656. package/ui-dist/assets/groovy-D9Dt4D0W.js +1 -0
  657. package/ui-dist/assets/haskell-Cw1EW3IL.js +1 -0
  658. package/ui-dist/assets/haxe-H-WmDvRZ.js +1 -0
  659. package/ui-dist/assets/http-DBlCnlav.js +1 -0
  660. package/ui-dist/assets/idl-BEugSyMb.js +1 -0
  661. package/ui-dist/assets/index-67wgPlFF.js +2 -0
  662. package/ui-dist/assets/index-AOupEZ7F.js +3 -0
  663. package/ui-dist/assets/index-Adh61992.css +1 -0
  664. package/ui-dist/assets/index-BDxTQGYs.js +1 -0
  665. package/ui-dist/assets/index-BPkGaKoo.js +1 -0
  666. package/ui-dist/assets/index-Bqv4zJgN.js +1 -0
  667. package/ui-dist/assets/index-BsG_gnx5.js +1 -0
  668. package/ui-dist/assets/index-CMr20CMo.js +1 -0
  669. package/ui-dist/assets/index-CWDSPi4k.js +1 -0
  670. package/ui-dist/assets/index-CjbPLXsH.js +1 -0
  671. package/ui-dist/assets/index-CpPrzV14.js +1 -0
  672. package/ui-dist/assets/index-CtMyHQ6R.js +13 -0
  673. package/ui-dist/assets/index-CxjxLAwB.js +1 -0
  674. package/ui-dist/assets/index-DM781ctw.js +1 -0
  675. package/ui-dist/assets/index-DRfcby21.js +1 -0
  676. package/ui-dist/assets/index-DT_WMp92.js +1208 -0
  677. package/ui-dist/assets/index-DeC7VY6K.js +7 -0
  678. package/ui-dist/assets/index-DjE1yn7n.js +1 -0
  679. package/ui-dist/assets/index-DpvIH4Bv.js +6 -0
  680. package/ui-dist/assets/index-Dr9BRllo.js +1 -0
  681. package/ui-dist/assets/index-M28FYTR1.js +1 -0
  682. package/ui-dist/assets/index-W7PRr-fr.js +1 -0
  683. package/ui-dist/assets/index-cQIqZijA.js +1 -0
  684. package/ui-dist/assets/index-pdiw2nOL.js +1 -0
  685. package/ui-dist/assets/infoDiagram-HS3SLOUP-Czj6Kk7r.js +2 -0
  686. package/ui-dist/assets/init-Gi6I4Gst.js +1 -0
  687. package/ui-dist/assets/javascript-iXu5QeM3.js +1 -0
  688. package/ui-dist/assets/journeyDiagram-XKPGCS4Q-DmbRbLNy.js +139 -0
  689. package/ui-dist/assets/julia-DuME0IfC.js +1 -0
  690. package/ui-dist/assets/kanban-definition-3W4ZIXB7-i8wImeeQ.js +89 -0
  691. package/ui-dist/assets/katex-O9d3_IXG.js +261 -0
  692. package/ui-dist/assets/layout-BZ41aZG6.js +1 -0
  693. package/ui-dist/assets/linear-Bd24j0eU.js +1 -0
  694. package/ui-dist/assets/livescript-BwQOo05w.js +1 -0
  695. package/ui-dist/assets/lua-BgMRiT3U.js +1 -0
  696. package/ui-dist/assets/mathematica-DTrFuWx2.js +1 -0
  697. package/ui-dist/assets/mbox-CNhZ1qSd.js +1 -0
  698. package/ui-dist/assets/mermaid.core-CnmYbevd.js +256 -0
  699. package/ui-dist/assets/mindmap-definition-VGOIOE7T-2yJkRaxJ.js +68 -0
  700. package/ui-dist/assets/mirc-CjQqDB4T.js +1 -0
  701. package/ui-dist/assets/mllike-CXdrOF99.js +1 -0
  702. package/ui-dist/assets/modelica-Dc1JOy9r.js +1 -0
  703. package/ui-dist/assets/mscgen-BA5vi2Kp.js +1 -0
  704. package/ui-dist/assets/mumps-BT43cFF4.js +1 -0
  705. package/ui-dist/assets/nginx-DdIZxoE0.js +1 -0
  706. package/ui-dist/assets/nsis-LdVXkNf5.js +1 -0
  707. package/ui-dist/assets/ntriples-BfvgReVJ.js +1 -0
  708. package/ui-dist/assets/octave-Ck1zUtKM.js +1 -0
  709. package/ui-dist/assets/ordinal-Cboi1Yqb.js +1 -0
  710. package/ui-dist/assets/oz-BzwKVEFT.js +1 -0
  711. package/ui-dist/assets/pascal--L3eBynH.js +1 -0
  712. package/ui-dist/assets/perl-CdXCOZ3F.js +1 -0
  713. package/ui-dist/assets/pieDiagram-ADFJNKIX-DfY80Olt.js +30 -0
  714. package/ui-dist/assets/pig-CevX1Tat.js +1 -0
  715. package/ui-dist/assets/powershell-CFHJl5sT.js +1 -0
  716. package/ui-dist/assets/properties-C78fOPTZ.js +1 -0
  717. package/ui-dist/assets/protobuf-ChK-085T.js +1 -0
  718. package/ui-dist/assets/pug-DeIclll2.js +1 -0
  719. package/ui-dist/assets/puppet-DMA9R1ak.js +1 -0
  720. package/ui-dist/assets/python-BuPzkPfP.js +1 -0
  721. package/ui-dist/assets/q-pXgVlZs6.js +1 -0
  722. package/ui-dist/assets/quadrantDiagram-AYHSOK5B-laGlzK_R.js +7 -0
  723. package/ui-dist/assets/r-B6wPVr8A.js +1 -0
  724. package/ui-dist/assets/requirementDiagram-UZGBJVZJ-DQu2AfNp.js +64 -0
  725. package/ui-dist/assets/rpm-CTu-6PCP.js +1 -0
  726. package/ui-dist/assets/ruby-B2Rjki9n.js +1 -0
  727. package/ui-dist/assets/sankeyDiagram-TZEHDZUN-CVXbe6_i.js +10 -0
  728. package/ui-dist/assets/sas-B4kiWyti.js +1 -0
  729. package/ui-dist/assets/scheme-C41bIUwD.js +1 -0
  730. package/ui-dist/assets/sequenceDiagram-WL72ISMW-CbzHcu8D.js +145 -0
  731. package/ui-dist/assets/shell-CjFT_Tl9.js +1 -0
  732. package/ui-dist/assets/sieve-C3Gn_uJK.js +1 -0
  733. package/ui-dist/assets/simple-mode-GW_nhZxv.js +1 -0
  734. package/ui-dist/assets/smalltalk-CnHTOXQT.js +1 -0
  735. package/ui-dist/assets/solr-DehyRSwq.js +1 -0
  736. package/ui-dist/assets/sparql-DkYu6x3z.js +1 -0
  737. package/ui-dist/assets/spreadsheet-BCZA_wO0.js +1 -0
  738. package/ui-dist/assets/sql-D0XecflT.js +1 -0
  739. package/ui-dist/assets/stateDiagram-FKZM4ZOC-BlA3BmIE.js +1 -0
  740. package/ui-dist/assets/stateDiagram-v2-4FDKWEC3-CKWuMBZK.js +1 -0
  741. package/ui-dist/assets/stex-C3f8Ysf7.js +1 -0
  742. package/ui-dist/assets/stylus-B533Al4x.js +1 -0
  743. package/ui-dist/assets/swift-BzpIVaGY.js +1 -0
  744. package/ui-dist/assets/tcl-DVfN8rqt.js +1 -0
  745. package/ui-dist/assets/textile-CnDTJFAw.js +1 -0
  746. package/ui-dist/assets/tiddlywiki-DO-Gjzrf.js +1 -0
  747. package/ui-dist/assets/tiki-DGYXhP31.js +1 -0
  748. package/ui-dist/assets/timeline-definition-IT6M3QCI-DIMG09X0.js +61 -0
  749. package/ui-dist/assets/toml-Bm5Em-hy.js +1 -0
  750. package/ui-dist/assets/treemap-GDKQZRPO-qYl32Jd0.js +162 -0
  751. package/ui-dist/assets/troff-wAsdV37c.js +1 -0
  752. package/ui-dist/assets/ttcn-CfJYG6tj.js +1 -0
  753. package/ui-dist/assets/ttcn-cfg-B9xdYoR4.js +1 -0
  754. package/ui-dist/assets/turtle-B1tBg_DP.js +1 -0
  755. package/ui-dist/assets/vb-CmGdzxic.js +1 -0
  756. package/ui-dist/assets/vbscript-BuJXcnF6.js +1 -0
  757. package/ui-dist/assets/velocity-D8B20fx6.js +1 -0
  758. package/ui-dist/assets/verilog-C6RDOZhf.js +1 -0
  759. package/ui-dist/assets/vhdl-lSbBsy5d.js +1 -0
  760. package/ui-dist/assets/webidl-ZXfAyPTL.js +1 -0
  761. package/ui-dist/assets/xquery-DzFWVndE.js +1 -0
  762. package/ui-dist/assets/xychartDiagram-PRI3JC2R-B3g_TERG.js +7 -0
  763. package/ui-dist/assets/yacas-BJ4BC0dw.js +1 -0
  764. package/ui-dist/assets/z80-Hz9HOZM7.js +1 -0
  765. package/ui-dist/brands/opencode-logo-dark-square.svg +18 -0
  766. package/ui-dist/brands/opencode-logo-light-square.svg +18 -0
  767. package/ui-dist/favicon-16x16.png +0 -0
  768. package/ui-dist/favicon-32x32.png +0 -0
  769. package/ui-dist/favicon.ico +0 -0
  770. package/ui-dist/favicon.svg +9 -0
  771. package/ui-dist/index.html +49 -0
  772. package/ui-dist/locales/en/common.json +2008 -0
  773. package/ui-dist/locales/zh-CN/common.json +2159 -0
  774. package/ui-dist/site.webmanifest +30 -0
  775. package/ui-dist/sw.js +42 -0
  776. package/ui-dist/worktree-favicon-16x16.png +0 -0
  777. package/ui-dist/worktree-favicon-32x32.png +0 -0
  778. package/ui-dist/worktree-favicon.ico +0 -0
  779. package/ui-dist/worktree-favicon.svg +9 -0
@@ -0,0 +1,1622 @@
1
+ import { Router } from "express";
2
+ import multer from "multer";
3
+ import { z } from "zod";
4
+ import { addIssueCommentSchema, createIssueAttachmentMetadataSchema, createIssueWorkProductSchema, createIssueLabelSchema, checkoutIssueSchema, createIssueSchema, linkIssueApprovalSchema, issueDocumentKeySchema, updateIssueWorkProductSchema, upsertIssueDocumentSchema, updateIssueSchema, } from "@penclipai/shared";
5
+ import { validate } from "../middleware/validate.js";
6
+ import { accessService, agentService, executionWorkspaceService, goalService, heartbeatService, issueApprovalService, issueService, documentService, logActivity, projectService, routineService, workProductService, } from "../services/index.js";
7
+ import { logger } from "../middleware/logger.js";
8
+ import { forbidden, HttpError, unauthorized } from "../errors.js";
9
+ import { assertCompanyAccess, getActorInfo } from "./authz.js";
10
+ import { shouldWakeAssigneeOnCheckout } from "./issues-checkout-wakeup.js";
11
+ import { isAllowedContentType, MAX_ATTACHMENT_BYTES } from "../attachment-types.js";
12
+ import { queueIssueAssignmentWakeup } from "../services/issue-assignment-wakeup.js";
13
+ import { resolveExplicitRequestUiLocale } from "../ui-locale.js";
14
+ const MAX_ISSUE_COMMENT_LIMIT = 500;
15
+ const updateIssueRouteSchema = updateIssueSchema.extend({
16
+ interrupt: z.boolean().optional(),
17
+ });
18
+ export function issueRoutes(db, storage) {
19
+ const router = Router();
20
+ const svc = issueService(db);
21
+ const access = accessService(db);
22
+ const heartbeat = heartbeatService(db);
23
+ const agentsSvc = agentService(db);
24
+ const projectsSvc = projectService(db);
25
+ const goalsSvc = goalService(db);
26
+ const issueApprovalsSvc = issueApprovalService(db);
27
+ const executionWorkspacesSvc = executionWorkspaceService(db);
28
+ const workProductsSvc = workProductService(db);
29
+ const documentsSvc = documentService(db);
30
+ const routinesSvc = routineService(db);
31
+ const upload = multer({
32
+ storage: multer.memoryStorage(),
33
+ limits: { fileSize: MAX_ATTACHMENT_BYTES, files: 1 },
34
+ });
35
+ function withContentPath(attachment) {
36
+ return {
37
+ ...attachment,
38
+ contentPath: `/api/attachments/${attachment.id}/content`,
39
+ };
40
+ }
41
+ async function runSingleFileUpload(req, res) {
42
+ await new Promise((resolve, reject) => {
43
+ upload.single("file")(req, res, (err) => {
44
+ if (err)
45
+ reject(err);
46
+ else
47
+ resolve();
48
+ });
49
+ });
50
+ }
51
+ async function assertCanManageIssueApprovalLinks(req, res, companyId) {
52
+ assertCompanyAccess(req, companyId);
53
+ if (req.actor.type === "board")
54
+ return true;
55
+ if (!req.actor.agentId) {
56
+ res.status(403).json({ error: "Agent authentication required" });
57
+ return false;
58
+ }
59
+ const actorAgent = await agentsSvc.getById(req.actor.agentId);
60
+ if (!actorAgent || actorAgent.companyId !== companyId) {
61
+ res.status(403).json({ error: "Forbidden" });
62
+ return false;
63
+ }
64
+ if (actorAgent.role === "ceo" || Boolean(actorAgent.permissions?.canCreateAgents))
65
+ return true;
66
+ res.status(403).json({ error: "Missing permission to link approvals" });
67
+ return false;
68
+ }
69
+ function canCreateAgentsLegacy(agent) {
70
+ if (agent.role === "ceo")
71
+ return true;
72
+ if (!agent.permissions || typeof agent.permissions !== "object")
73
+ return false;
74
+ return Boolean(agent.permissions.canCreateAgents);
75
+ }
76
+ async function assertCanAssignTasks(req, companyId) {
77
+ assertCompanyAccess(req, companyId);
78
+ if (req.actor.type === "board") {
79
+ if (req.actor.source === "local_implicit" || req.actor.isInstanceAdmin)
80
+ return;
81
+ const allowed = await access.canUser(companyId, req.actor.userId, "tasks:assign");
82
+ if (!allowed)
83
+ throw forbidden("Missing permission: tasks:assign");
84
+ return;
85
+ }
86
+ if (req.actor.type === "agent") {
87
+ if (!req.actor.agentId)
88
+ throw forbidden("Agent authentication required");
89
+ const allowedByGrant = await access.hasPermission(companyId, "agent", req.actor.agentId, "tasks:assign");
90
+ if (allowedByGrant)
91
+ return;
92
+ const actorAgent = await agentsSvc.getById(req.actor.agentId);
93
+ if (actorAgent && actorAgent.companyId === companyId && canCreateAgentsLegacy(actorAgent))
94
+ return;
95
+ throw forbidden("Missing permission: tasks:assign");
96
+ }
97
+ throw unauthorized();
98
+ }
99
+ function requireAgentRunId(req, res) {
100
+ if (req.actor.type !== "agent")
101
+ return null;
102
+ const runId = req.actor.runId?.trim();
103
+ if (runId)
104
+ return runId;
105
+ res.status(401).json({ error: "Agent run id required" });
106
+ return null;
107
+ }
108
+ async function assertAgentRunCheckoutOwnership(req, res, issue) {
109
+ if (req.actor.type !== "agent")
110
+ return true;
111
+ const actorAgentId = req.actor.agentId;
112
+ if (!actorAgentId) {
113
+ res.status(403).json({ error: "Agent authentication required" });
114
+ return false;
115
+ }
116
+ if (issue.status !== "in_progress" || issue.assigneeAgentId !== actorAgentId) {
117
+ return true;
118
+ }
119
+ const runId = requireAgentRunId(req, res);
120
+ if (!runId)
121
+ return false;
122
+ const ownership = await svc.assertCheckoutOwner(issue.id, actorAgentId, runId);
123
+ if (ownership.adoptedFromRunId) {
124
+ const actor = getActorInfo(req);
125
+ await logActivity(db, {
126
+ companyId: issue.companyId,
127
+ actorType: actor.actorType,
128
+ actorId: actor.actorId,
129
+ agentId: actor.agentId,
130
+ runId: actor.runId,
131
+ action: "issue.checkout_lock_adopted",
132
+ entityType: "issue",
133
+ entityId: issue.id,
134
+ details: {
135
+ previousCheckoutRunId: ownership.adoptedFromRunId,
136
+ checkoutRunId: runId,
137
+ reason: "stale_checkout_run",
138
+ },
139
+ });
140
+ }
141
+ return true;
142
+ }
143
+ async function resolveActiveIssueRun(issue) {
144
+ let runToInterrupt = issue.executionRunId ? await heartbeat.getRun(issue.executionRunId) : null;
145
+ if ((!runToInterrupt || runToInterrupt.status !== "running") && issue.assigneeAgentId) {
146
+ const activeRun = await heartbeat.getActiveRunForAgent(issue.assigneeAgentId);
147
+ const activeIssueId = activeRun &&
148
+ activeRun.contextSnapshot &&
149
+ typeof activeRun.contextSnapshot === "object" &&
150
+ typeof activeRun.contextSnapshot.issueId === "string"
151
+ ? activeRun.contextSnapshot.issueId
152
+ : null;
153
+ if (activeRun && activeRun.status === "running" && activeIssueId === issue.id) {
154
+ runToInterrupt = activeRun;
155
+ }
156
+ }
157
+ return runToInterrupt?.status === "running" ? runToInterrupt : null;
158
+ }
159
+ async function normalizeIssueIdentifier(rawId) {
160
+ if (/^[A-Z]+-\d+$/i.test(rawId)) {
161
+ const issue = await svc.getByIdentifier(rawId);
162
+ if (issue) {
163
+ return issue.id;
164
+ }
165
+ }
166
+ return rawId;
167
+ }
168
+ async function resolveIssueProjectAndGoal(issue) {
169
+ const projectPromise = issue.projectId ? projectsSvc.getById(issue.projectId) : Promise.resolve(null);
170
+ const directGoalPromise = issue.goalId ? goalsSvc.getById(issue.goalId) : Promise.resolve(null);
171
+ const [project, directGoal] = await Promise.all([projectPromise, directGoalPromise]);
172
+ if (directGoal) {
173
+ return { project, goal: directGoal };
174
+ }
175
+ const projectGoalId = project?.goalId ?? project?.goalIds[0] ?? null;
176
+ if (projectGoalId) {
177
+ const projectGoal = await goalsSvc.getById(projectGoalId);
178
+ return { project, goal: projectGoal };
179
+ }
180
+ if (!issue.projectId) {
181
+ const defaultGoal = await goalsSvc.getDefaultCompanyGoal(issue.companyId);
182
+ return { project, goal: defaultGoal };
183
+ }
184
+ return { project, goal: null };
185
+ }
186
+ // Resolve issue identifiers (e.g. "PAP-39") to UUIDs for all /issues/:id routes
187
+ router.param("id", async (req, res, next, rawId) => {
188
+ try {
189
+ req.params.id = await normalizeIssueIdentifier(rawId);
190
+ next();
191
+ }
192
+ catch (err) {
193
+ next(err);
194
+ }
195
+ });
196
+ // Resolve issue identifiers (e.g. "PAP-39") to UUIDs for company-scoped attachment routes.
197
+ router.param("issueId", async (req, res, next, rawId) => {
198
+ try {
199
+ req.params.issueId = await normalizeIssueIdentifier(rawId);
200
+ next();
201
+ }
202
+ catch (err) {
203
+ next(err);
204
+ }
205
+ });
206
+ // Common malformed path when companyId is empty in "/api/companies/{companyId}/issues".
207
+ router.get("/issues", (_req, res) => {
208
+ res.status(400).json({
209
+ error: "Missing companyId in path. Use /api/companies/{companyId}/issues.",
210
+ });
211
+ });
212
+ router.get("/companies/:companyId/issues", async (req, res) => {
213
+ const companyId = req.params.companyId;
214
+ assertCompanyAccess(req, companyId);
215
+ const assigneeUserFilterRaw = req.query.assigneeUserId;
216
+ const touchedByUserFilterRaw = req.query.touchedByUserId;
217
+ const inboxArchivedByUserFilterRaw = req.query.inboxArchivedByUserId;
218
+ const unreadForUserFilterRaw = req.query.unreadForUserId;
219
+ const assigneeUserId = assigneeUserFilterRaw === "me" && req.actor.type === "board"
220
+ ? req.actor.userId
221
+ : assigneeUserFilterRaw;
222
+ const touchedByUserId = touchedByUserFilterRaw === "me" && req.actor.type === "board"
223
+ ? req.actor.userId
224
+ : touchedByUserFilterRaw;
225
+ const inboxArchivedByUserId = inboxArchivedByUserFilterRaw === "me" && req.actor.type === "board"
226
+ ? req.actor.userId
227
+ : inboxArchivedByUserFilterRaw;
228
+ const unreadForUserId = unreadForUserFilterRaw === "me" && req.actor.type === "board"
229
+ ? req.actor.userId
230
+ : unreadForUserFilterRaw;
231
+ if (assigneeUserFilterRaw === "me" && (!assigneeUserId || req.actor.type !== "board")) {
232
+ res.status(403).json({ error: "assigneeUserId=me requires board authentication" });
233
+ return;
234
+ }
235
+ if (touchedByUserFilterRaw === "me" && (!touchedByUserId || req.actor.type !== "board")) {
236
+ res.status(403).json({ error: "touchedByUserId=me requires board authentication" });
237
+ return;
238
+ }
239
+ if (inboxArchivedByUserFilterRaw === "me" && (!inboxArchivedByUserId || req.actor.type !== "board")) {
240
+ res.status(403).json({ error: "inboxArchivedByUserId=me requires board authentication" });
241
+ return;
242
+ }
243
+ if (unreadForUserFilterRaw === "me" && (!unreadForUserId || req.actor.type !== "board")) {
244
+ res.status(403).json({ error: "unreadForUserId=me requires board authentication" });
245
+ return;
246
+ }
247
+ const result = await svc.list(companyId, {
248
+ status: req.query.status,
249
+ assigneeAgentId: req.query.assigneeAgentId,
250
+ participantAgentId: req.query.participantAgentId,
251
+ assigneeUserId,
252
+ touchedByUserId,
253
+ inboxArchivedByUserId,
254
+ unreadForUserId,
255
+ projectId: req.query.projectId,
256
+ executionWorkspaceId: req.query.executionWorkspaceId,
257
+ parentId: req.query.parentId,
258
+ labelId: req.query.labelId,
259
+ originKind: req.query.originKind,
260
+ originId: req.query.originId,
261
+ includeRoutineExecutions: req.query.includeRoutineExecutions === "true" || req.query.includeRoutineExecutions === "1",
262
+ q: req.query.q,
263
+ });
264
+ res.json(result);
265
+ });
266
+ router.get("/companies/:companyId/labels", async (req, res) => {
267
+ const companyId = req.params.companyId;
268
+ assertCompanyAccess(req, companyId);
269
+ const result = await svc.listLabels(companyId);
270
+ res.json(result);
271
+ });
272
+ router.post("/companies/:companyId/labels", validate(createIssueLabelSchema), async (req, res) => {
273
+ const companyId = req.params.companyId;
274
+ assertCompanyAccess(req, companyId);
275
+ const label = await svc.createLabel(companyId, req.body);
276
+ const actor = getActorInfo(req);
277
+ await logActivity(db, {
278
+ companyId,
279
+ actorType: actor.actorType,
280
+ actorId: actor.actorId,
281
+ agentId: actor.agentId,
282
+ runId: actor.runId,
283
+ action: "label.created",
284
+ entityType: "label",
285
+ entityId: label.id,
286
+ details: { name: label.name, color: label.color },
287
+ });
288
+ res.status(201).json(label);
289
+ });
290
+ router.delete("/labels/:labelId", async (req, res) => {
291
+ const labelId = req.params.labelId;
292
+ const existing = await svc.getLabelById(labelId);
293
+ if (!existing) {
294
+ res.status(404).json({ error: "Label not found" });
295
+ return;
296
+ }
297
+ assertCompanyAccess(req, existing.companyId);
298
+ const removed = await svc.deleteLabel(labelId);
299
+ if (!removed) {
300
+ res.status(404).json({ error: "Label not found" });
301
+ return;
302
+ }
303
+ const actor = getActorInfo(req);
304
+ await logActivity(db, {
305
+ companyId: removed.companyId,
306
+ actorType: actor.actorType,
307
+ actorId: actor.actorId,
308
+ agentId: actor.agentId,
309
+ runId: actor.runId,
310
+ action: "label.deleted",
311
+ entityType: "label",
312
+ entityId: removed.id,
313
+ details: { name: removed.name, color: removed.color },
314
+ });
315
+ res.json(removed);
316
+ });
317
+ router.get("/issues/:id", async (req, res) => {
318
+ const id = req.params.id;
319
+ const issue = await svc.getById(id);
320
+ if (!issue) {
321
+ res.status(404).json({ error: "Issue not found" });
322
+ return;
323
+ }
324
+ assertCompanyAccess(req, issue.companyId);
325
+ const [{ project, goal }, ancestors, mentionedProjectIds, documentPayload] = await Promise.all([
326
+ resolveIssueProjectAndGoal(issue),
327
+ svc.getAncestors(issue.id),
328
+ svc.findMentionedProjectIds(issue.id),
329
+ documentsSvc.getIssueDocumentPayload(issue),
330
+ ]);
331
+ const mentionedProjects = mentionedProjectIds.length > 0
332
+ ? await projectsSvc.listByIds(issue.companyId, mentionedProjectIds)
333
+ : [];
334
+ const currentExecutionWorkspace = issue.executionWorkspaceId
335
+ ? await executionWorkspacesSvc.getById(issue.executionWorkspaceId)
336
+ : null;
337
+ const workProducts = await workProductsSvc.listForIssue(issue.id);
338
+ res.json({
339
+ ...issue,
340
+ goalId: goal?.id ?? issue.goalId,
341
+ ancestors,
342
+ ...documentPayload,
343
+ project: project ?? null,
344
+ goal: goal ?? null,
345
+ mentionedProjects,
346
+ currentExecutionWorkspace,
347
+ workProducts,
348
+ });
349
+ });
350
+ router.get("/issues/:id/heartbeat-context", async (req, res) => {
351
+ const id = req.params.id;
352
+ const issue = await svc.getById(id);
353
+ if (!issue) {
354
+ res.status(404).json({ error: "Issue not found" });
355
+ return;
356
+ }
357
+ assertCompanyAccess(req, issue.companyId);
358
+ const wakeCommentId = typeof req.query.wakeCommentId === "string" && req.query.wakeCommentId.trim().length > 0
359
+ ? req.query.wakeCommentId.trim()
360
+ : null;
361
+ const [{ project, goal }, ancestors, commentCursor, wakeComment] = await Promise.all([
362
+ resolveIssueProjectAndGoal(issue),
363
+ svc.getAncestors(issue.id),
364
+ svc.getCommentCursor(issue.id),
365
+ wakeCommentId ? svc.getComment(wakeCommentId) : null,
366
+ ]);
367
+ res.json({
368
+ issue: {
369
+ id: issue.id,
370
+ identifier: issue.identifier,
371
+ title: issue.title,
372
+ description: issue.description,
373
+ status: issue.status,
374
+ priority: issue.priority,
375
+ projectId: issue.projectId,
376
+ goalId: goal?.id ?? issue.goalId,
377
+ parentId: issue.parentId,
378
+ assigneeAgentId: issue.assigneeAgentId,
379
+ assigneeUserId: issue.assigneeUserId,
380
+ updatedAt: issue.updatedAt,
381
+ },
382
+ ancestors: ancestors.map((ancestor) => ({
383
+ id: ancestor.id,
384
+ identifier: ancestor.identifier,
385
+ title: ancestor.title,
386
+ status: ancestor.status,
387
+ priority: ancestor.priority,
388
+ })),
389
+ project: project
390
+ ? {
391
+ id: project.id,
392
+ name: project.name,
393
+ status: project.status,
394
+ targetDate: project.targetDate,
395
+ }
396
+ : null,
397
+ goal: goal
398
+ ? {
399
+ id: goal.id,
400
+ title: goal.title,
401
+ status: goal.status,
402
+ level: goal.level,
403
+ parentId: goal.parentId,
404
+ }
405
+ : null,
406
+ commentCursor,
407
+ wakeComment: wakeComment && wakeComment.issueId === issue.id
408
+ ? wakeComment
409
+ : null,
410
+ });
411
+ });
412
+ router.get("/issues/:id/work-products", async (req, res) => {
413
+ const id = req.params.id;
414
+ const issue = await svc.getById(id);
415
+ if (!issue) {
416
+ res.status(404).json({ error: "Issue not found" });
417
+ return;
418
+ }
419
+ assertCompanyAccess(req, issue.companyId);
420
+ const workProducts = await workProductsSvc.listForIssue(issue.id);
421
+ res.json(workProducts);
422
+ });
423
+ router.get("/issues/:id/documents", async (req, res) => {
424
+ const id = req.params.id;
425
+ const issue = await svc.getById(id);
426
+ if (!issue) {
427
+ res.status(404).json({ error: "Issue not found" });
428
+ return;
429
+ }
430
+ assertCompanyAccess(req, issue.companyId);
431
+ const docs = await documentsSvc.listIssueDocuments(issue.id);
432
+ res.json(docs);
433
+ });
434
+ router.get("/issues/:id/documents/:key", async (req, res) => {
435
+ const id = req.params.id;
436
+ const issue = await svc.getById(id);
437
+ if (!issue) {
438
+ res.status(404).json({ error: "Issue not found" });
439
+ return;
440
+ }
441
+ assertCompanyAccess(req, issue.companyId);
442
+ const keyParsed = issueDocumentKeySchema.safeParse(String(req.params.key ?? "").trim().toLowerCase());
443
+ if (!keyParsed.success) {
444
+ res.status(400).json({ error: "Invalid document key", details: keyParsed.error.issues });
445
+ return;
446
+ }
447
+ const doc = await documentsSvc.getIssueDocumentByKey(issue.id, keyParsed.data);
448
+ if (!doc) {
449
+ res.status(404).json({ error: "Document not found" });
450
+ return;
451
+ }
452
+ res.json(doc);
453
+ });
454
+ router.put("/issues/:id/documents/:key", validate(upsertIssueDocumentSchema), async (req, res) => {
455
+ const id = req.params.id;
456
+ const issue = await svc.getById(id);
457
+ if (!issue) {
458
+ res.status(404).json({ error: "Issue not found" });
459
+ return;
460
+ }
461
+ assertCompanyAccess(req, issue.companyId);
462
+ const keyParsed = issueDocumentKeySchema.safeParse(String(req.params.key ?? "").trim().toLowerCase());
463
+ if (!keyParsed.success) {
464
+ res.status(400).json({ error: "Invalid document key", details: keyParsed.error.issues });
465
+ return;
466
+ }
467
+ const actor = getActorInfo(req);
468
+ const result = await documentsSvc.upsertIssueDocument({
469
+ issueId: issue.id,
470
+ key: keyParsed.data,
471
+ title: req.body.title ?? null,
472
+ format: req.body.format,
473
+ body: req.body.body,
474
+ changeSummary: req.body.changeSummary ?? null,
475
+ baseRevisionId: req.body.baseRevisionId ?? null,
476
+ createdByAgentId: actor.agentId ?? null,
477
+ createdByUserId: actor.actorType === "user" ? actor.actorId : null,
478
+ });
479
+ const doc = result.document;
480
+ await logActivity(db, {
481
+ companyId: issue.companyId,
482
+ actorType: actor.actorType,
483
+ actorId: actor.actorId,
484
+ agentId: actor.agentId,
485
+ runId: actor.runId,
486
+ action: result.created ? "issue.document_created" : "issue.document_updated",
487
+ entityType: "issue",
488
+ entityId: issue.id,
489
+ details: {
490
+ key: doc.key,
491
+ documentId: doc.id,
492
+ title: doc.title,
493
+ format: doc.format,
494
+ revisionNumber: doc.latestRevisionNumber,
495
+ },
496
+ });
497
+ res.status(result.created ? 201 : 200).json(doc);
498
+ });
499
+ router.get("/issues/:id/documents/:key/revisions", async (req, res) => {
500
+ const id = req.params.id;
501
+ const issue = await svc.getById(id);
502
+ if (!issue) {
503
+ res.status(404).json({ error: "Issue not found" });
504
+ return;
505
+ }
506
+ assertCompanyAccess(req, issue.companyId);
507
+ const keyParsed = issueDocumentKeySchema.safeParse(String(req.params.key ?? "").trim().toLowerCase());
508
+ if (!keyParsed.success) {
509
+ res.status(400).json({ error: "Invalid document key", details: keyParsed.error.issues });
510
+ return;
511
+ }
512
+ const revisions = await documentsSvc.listIssueDocumentRevisions(issue.id, keyParsed.data);
513
+ res.json(revisions);
514
+ });
515
+ router.delete("/issues/:id/documents/:key", async (req, res) => {
516
+ const id = req.params.id;
517
+ const issue = await svc.getById(id);
518
+ if (!issue) {
519
+ res.status(404).json({ error: "Issue not found" });
520
+ return;
521
+ }
522
+ assertCompanyAccess(req, issue.companyId);
523
+ if (req.actor.type !== "board") {
524
+ res.status(403).json({ error: "Board authentication required" });
525
+ return;
526
+ }
527
+ const keyParsed = issueDocumentKeySchema.safeParse(String(req.params.key ?? "").trim().toLowerCase());
528
+ if (!keyParsed.success) {
529
+ res.status(400).json({ error: "Invalid document key", details: keyParsed.error.issues });
530
+ return;
531
+ }
532
+ const removed = await documentsSvc.deleteIssueDocument(issue.id, keyParsed.data);
533
+ if (!removed) {
534
+ res.status(404).json({ error: "Document not found" });
535
+ return;
536
+ }
537
+ const actor = getActorInfo(req);
538
+ await logActivity(db, {
539
+ companyId: issue.companyId,
540
+ actorType: actor.actorType,
541
+ actorId: actor.actorId,
542
+ agentId: actor.agentId,
543
+ runId: actor.runId,
544
+ action: "issue.document_deleted",
545
+ entityType: "issue",
546
+ entityId: issue.id,
547
+ details: {
548
+ key: removed.key,
549
+ documentId: removed.id,
550
+ title: removed.title,
551
+ },
552
+ });
553
+ res.json({ ok: true });
554
+ });
555
+ router.post("/issues/:id/work-products", validate(createIssueWorkProductSchema), async (req, res) => {
556
+ const id = req.params.id;
557
+ const issue = await svc.getById(id);
558
+ if (!issue) {
559
+ res.status(404).json({ error: "Issue not found" });
560
+ return;
561
+ }
562
+ assertCompanyAccess(req, issue.companyId);
563
+ const product = await workProductsSvc.createForIssue(issue.id, issue.companyId, {
564
+ ...req.body,
565
+ projectId: req.body.projectId ?? issue.projectId ?? null,
566
+ });
567
+ if (!product) {
568
+ res.status(422).json({ error: "Invalid work product payload" });
569
+ return;
570
+ }
571
+ const actor = getActorInfo(req);
572
+ await logActivity(db, {
573
+ companyId: issue.companyId,
574
+ actorType: actor.actorType,
575
+ actorId: actor.actorId,
576
+ agentId: actor.agentId,
577
+ runId: actor.runId,
578
+ action: "issue.work_product_created",
579
+ entityType: "issue",
580
+ entityId: issue.id,
581
+ details: { workProductId: product.id, type: product.type, provider: product.provider },
582
+ });
583
+ res.status(201).json(product);
584
+ });
585
+ router.patch("/work-products/:id", validate(updateIssueWorkProductSchema), async (req, res) => {
586
+ const id = req.params.id;
587
+ const existing = await workProductsSvc.getById(id);
588
+ if (!existing) {
589
+ res.status(404).json({ error: "Work product not found" });
590
+ return;
591
+ }
592
+ assertCompanyAccess(req, existing.companyId);
593
+ const product = await workProductsSvc.update(id, req.body);
594
+ if (!product) {
595
+ res.status(404).json({ error: "Work product not found" });
596
+ return;
597
+ }
598
+ const actor = getActorInfo(req);
599
+ await logActivity(db, {
600
+ companyId: existing.companyId,
601
+ actorType: actor.actorType,
602
+ actorId: actor.actorId,
603
+ agentId: actor.agentId,
604
+ runId: actor.runId,
605
+ action: "issue.work_product_updated",
606
+ entityType: "issue",
607
+ entityId: existing.issueId,
608
+ details: { workProductId: product.id, changedKeys: Object.keys(req.body).sort() },
609
+ });
610
+ res.json(product);
611
+ });
612
+ router.delete("/work-products/:id", async (req, res) => {
613
+ const id = req.params.id;
614
+ const existing = await workProductsSvc.getById(id);
615
+ if (!existing) {
616
+ res.status(404).json({ error: "Work product not found" });
617
+ return;
618
+ }
619
+ assertCompanyAccess(req, existing.companyId);
620
+ const removed = await workProductsSvc.remove(id);
621
+ if (!removed) {
622
+ res.status(404).json({ error: "Work product not found" });
623
+ return;
624
+ }
625
+ const actor = getActorInfo(req);
626
+ await logActivity(db, {
627
+ companyId: existing.companyId,
628
+ actorType: actor.actorType,
629
+ actorId: actor.actorId,
630
+ agentId: actor.agentId,
631
+ runId: actor.runId,
632
+ action: "issue.work_product_deleted",
633
+ entityType: "issue",
634
+ entityId: existing.issueId,
635
+ details: { workProductId: removed.id, type: removed.type },
636
+ });
637
+ res.json(removed);
638
+ });
639
+ router.post("/issues/:id/read", async (req, res) => {
640
+ const id = req.params.id;
641
+ const issue = await svc.getById(id);
642
+ if (!issue) {
643
+ res.status(404).json({ error: "Issue not found" });
644
+ return;
645
+ }
646
+ assertCompanyAccess(req, issue.companyId);
647
+ if (req.actor.type !== "board") {
648
+ res.status(403).json({ error: "Board authentication required" });
649
+ return;
650
+ }
651
+ if (!req.actor.userId) {
652
+ res.status(403).json({ error: "Board user context required" });
653
+ return;
654
+ }
655
+ const readState = await svc.markRead(issue.companyId, issue.id, req.actor.userId, new Date());
656
+ const actor = getActorInfo(req);
657
+ await logActivity(db, {
658
+ companyId: issue.companyId,
659
+ actorType: actor.actorType,
660
+ actorId: actor.actorId,
661
+ agentId: actor.agentId,
662
+ runId: actor.runId,
663
+ action: "issue.read_marked",
664
+ entityType: "issue",
665
+ entityId: issue.id,
666
+ details: { userId: req.actor.userId, lastReadAt: readState.lastReadAt },
667
+ });
668
+ res.json(readState);
669
+ });
670
+ router.delete("/issues/:id/read", async (req, res) => {
671
+ const id = req.params.id;
672
+ const issue = await svc.getById(id);
673
+ if (!issue) {
674
+ res.status(404).json({ error: "Issue not found" });
675
+ return;
676
+ }
677
+ assertCompanyAccess(req, issue.companyId);
678
+ if (req.actor.type !== "board") {
679
+ res.status(403).json({ error: "Board authentication required" });
680
+ return;
681
+ }
682
+ if (!req.actor.userId) {
683
+ res.status(403).json({ error: "Board user context required" });
684
+ return;
685
+ }
686
+ const removed = await svc.markUnread(issue.companyId, issue.id, req.actor.userId);
687
+ const actor = getActorInfo(req);
688
+ await logActivity(db, {
689
+ companyId: issue.companyId,
690
+ actorType: actor.actorType,
691
+ actorId: actor.actorId,
692
+ agentId: actor.agentId,
693
+ runId: actor.runId,
694
+ action: "issue.read_unmarked",
695
+ entityType: "issue",
696
+ entityId: issue.id,
697
+ details: { userId: req.actor.userId },
698
+ });
699
+ res.json({ id: issue.id, removed });
700
+ });
701
+ router.post("/issues/:id/inbox-archive", async (req, res) => {
702
+ const id = req.params.id;
703
+ const issue = await svc.getById(id);
704
+ if (!issue) {
705
+ res.status(404).json({ error: "Issue not found" });
706
+ return;
707
+ }
708
+ assertCompanyAccess(req, issue.companyId);
709
+ if (req.actor.type !== "board") {
710
+ res.status(403).json({ error: "Board authentication required" });
711
+ return;
712
+ }
713
+ if (!req.actor.userId) {
714
+ res.status(403).json({ error: "Board user context required" });
715
+ return;
716
+ }
717
+ const archiveState = await svc.archiveInbox(issue.companyId, issue.id, req.actor.userId, new Date());
718
+ const actor = getActorInfo(req);
719
+ await logActivity(db, {
720
+ companyId: issue.companyId,
721
+ actorType: actor.actorType,
722
+ actorId: actor.actorId,
723
+ agentId: actor.agentId,
724
+ runId: actor.runId,
725
+ action: "issue.inbox_archived",
726
+ entityType: "issue",
727
+ entityId: issue.id,
728
+ details: { userId: req.actor.userId, archivedAt: archiveState.archivedAt },
729
+ });
730
+ res.json(archiveState);
731
+ });
732
+ router.delete("/issues/:id/inbox-archive", async (req, res) => {
733
+ const id = req.params.id;
734
+ const issue = await svc.getById(id);
735
+ if (!issue) {
736
+ res.status(404).json({ error: "Issue not found" });
737
+ return;
738
+ }
739
+ assertCompanyAccess(req, issue.companyId);
740
+ if (req.actor.type !== "board") {
741
+ res.status(403).json({ error: "Board authentication required" });
742
+ return;
743
+ }
744
+ if (!req.actor.userId) {
745
+ res.status(403).json({ error: "Board user context required" });
746
+ return;
747
+ }
748
+ const removed = await svc.unarchiveInbox(issue.companyId, issue.id, req.actor.userId);
749
+ const actor = getActorInfo(req);
750
+ await logActivity(db, {
751
+ companyId: issue.companyId,
752
+ actorType: actor.actorType,
753
+ actorId: actor.actorId,
754
+ agentId: actor.agentId,
755
+ runId: actor.runId,
756
+ action: "issue.inbox_unarchived",
757
+ entityType: "issue",
758
+ entityId: issue.id,
759
+ details: { userId: req.actor.userId },
760
+ });
761
+ res.json(removed ?? { ok: true });
762
+ });
763
+ router.get("/issues/:id/approvals", async (req, res) => {
764
+ const id = req.params.id;
765
+ const issue = await svc.getById(id);
766
+ if (!issue) {
767
+ res.status(404).json({ error: "Issue not found" });
768
+ return;
769
+ }
770
+ assertCompanyAccess(req, issue.companyId);
771
+ const approvals = await issueApprovalsSvc.listApprovalsForIssue(id);
772
+ res.json(approvals);
773
+ });
774
+ router.post("/issues/:id/approvals", validate(linkIssueApprovalSchema), async (req, res) => {
775
+ const id = req.params.id;
776
+ const issue = await svc.getById(id);
777
+ if (!issue) {
778
+ res.status(404).json({ error: "Issue not found" });
779
+ return;
780
+ }
781
+ if (!(await assertCanManageIssueApprovalLinks(req, res, issue.companyId)))
782
+ return;
783
+ const actor = getActorInfo(req);
784
+ await issueApprovalsSvc.link(id, req.body.approvalId, {
785
+ agentId: actor.agentId,
786
+ userId: actor.actorType === "user" ? actor.actorId : null,
787
+ });
788
+ await logActivity(db, {
789
+ companyId: issue.companyId,
790
+ actorType: actor.actorType,
791
+ actorId: actor.actorId,
792
+ agentId: actor.agentId,
793
+ runId: actor.runId,
794
+ action: "issue.approval_linked",
795
+ entityType: "issue",
796
+ entityId: issue.id,
797
+ details: { approvalId: req.body.approvalId },
798
+ });
799
+ const approvals = await issueApprovalsSvc.listApprovalsForIssue(id);
800
+ res.status(201).json(approvals);
801
+ });
802
+ router.delete("/issues/:id/approvals/:approvalId", async (req, res) => {
803
+ const id = req.params.id;
804
+ const approvalId = req.params.approvalId;
805
+ const issue = await svc.getById(id);
806
+ if (!issue) {
807
+ res.status(404).json({ error: "Issue not found" });
808
+ return;
809
+ }
810
+ if (!(await assertCanManageIssueApprovalLinks(req, res, issue.companyId)))
811
+ return;
812
+ await issueApprovalsSvc.unlink(id, approvalId);
813
+ const actor = getActorInfo(req);
814
+ await logActivity(db, {
815
+ companyId: issue.companyId,
816
+ actorType: actor.actorType,
817
+ actorId: actor.actorId,
818
+ agentId: actor.agentId,
819
+ runId: actor.runId,
820
+ action: "issue.approval_unlinked",
821
+ entityType: "issue",
822
+ entityId: issue.id,
823
+ details: { approvalId },
824
+ });
825
+ res.json({ ok: true });
826
+ });
827
+ router.post("/companies/:companyId/issues", validate(createIssueSchema), async (req, res) => {
828
+ const companyId = req.params.companyId;
829
+ assertCompanyAccess(req, companyId);
830
+ if (req.body.assigneeAgentId || req.body.assigneeUserId) {
831
+ await assertCanAssignTasks(req, companyId);
832
+ }
833
+ const actor = getActorInfo(req);
834
+ const requestedUiLocale = resolveExplicitRequestUiLocale(req);
835
+ const issue = await svc.create(companyId, {
836
+ ...req.body,
837
+ createdByAgentId: actor.agentId,
838
+ createdByUserId: actor.actorType === "user" ? actor.actorId : null,
839
+ });
840
+ await logActivity(db, {
841
+ companyId,
842
+ actorType: actor.actorType,
843
+ actorId: actor.actorId,
844
+ agentId: actor.agentId,
845
+ runId: actor.runId,
846
+ action: "issue.created",
847
+ entityType: "issue",
848
+ entityId: issue.id,
849
+ details: { title: issue.title, identifier: issue.identifier },
850
+ });
851
+ void queueIssueAssignmentWakeup({
852
+ heartbeat,
853
+ issue,
854
+ reason: "issue_assigned",
855
+ mutation: "create",
856
+ contextSource: "issue.create",
857
+ requestedUiLocale,
858
+ requestedByActorType: actor.actorType,
859
+ requestedByActorId: actor.actorId,
860
+ });
861
+ res.status(201).json(issue);
862
+ });
863
+ router.patch("/issues/:id", validate(updateIssueRouteSchema), async (req, res) => {
864
+ const id = req.params.id;
865
+ const existing = await svc.getById(id);
866
+ if (!existing) {
867
+ res.status(404).json({ error: "Issue not found" });
868
+ return;
869
+ }
870
+ assertCompanyAccess(req, existing.companyId);
871
+ const assigneeWillChange = (req.body.assigneeAgentId !== undefined && req.body.assigneeAgentId !== existing.assigneeAgentId) ||
872
+ (req.body.assigneeUserId !== undefined && req.body.assigneeUserId !== existing.assigneeUserId);
873
+ const isAgentReturningIssueToCreator = req.actor.type === "agent" &&
874
+ !!req.actor.agentId &&
875
+ existing.assigneeAgentId === req.actor.agentId &&
876
+ req.body.assigneeAgentId === null &&
877
+ typeof req.body.assigneeUserId === "string" &&
878
+ !!existing.createdByUserId &&
879
+ req.body.assigneeUserId === existing.createdByUserId;
880
+ if (assigneeWillChange) {
881
+ if (!isAgentReturningIssueToCreator) {
882
+ await assertCanAssignTasks(req, existing.companyId);
883
+ }
884
+ }
885
+ if (!(await assertAgentRunCheckoutOwnership(req, res, existing)))
886
+ return;
887
+ const actor = getActorInfo(req);
888
+ const requestedUiLocale = resolveExplicitRequestUiLocale(req);
889
+ const isClosed = existing.status === "done" || existing.status === "cancelled";
890
+ const { comment: commentBody, reopen: reopenRequested, interrupt: interruptRequested, hiddenAt: hiddenAtRaw, ...updateFields } = req.body;
891
+ let interruptedRunId = null;
892
+ if (interruptRequested) {
893
+ if (!commentBody) {
894
+ res.status(400).json({ error: "Interrupt is only supported when posting a comment" });
895
+ return;
896
+ }
897
+ if (req.actor.type !== "board") {
898
+ res.status(403).json({ error: "Only board users can interrupt active runs from issue comments" });
899
+ return;
900
+ }
901
+ const runToInterrupt = await resolveActiveIssueRun(existing);
902
+ if (runToInterrupt) {
903
+ const cancelled = await heartbeat.cancelRun(runToInterrupt.id);
904
+ if (cancelled) {
905
+ interruptedRunId = cancelled.id;
906
+ await logActivity(db, {
907
+ companyId: cancelled.companyId,
908
+ actorType: actor.actorType,
909
+ actorId: actor.actorId,
910
+ agentId: actor.agentId,
911
+ runId: actor.runId,
912
+ action: "heartbeat.cancelled",
913
+ entityType: "heartbeat_run",
914
+ entityId: cancelled.id,
915
+ details: { agentId: cancelled.agentId, source: "issue_comment_interrupt", issueId: existing.id },
916
+ });
917
+ }
918
+ }
919
+ }
920
+ if (hiddenAtRaw !== undefined) {
921
+ updateFields.hiddenAt = hiddenAtRaw ? new Date(hiddenAtRaw) : null;
922
+ }
923
+ if (commentBody && reopenRequested === true && isClosed && updateFields.status === undefined) {
924
+ updateFields.status = "todo";
925
+ }
926
+ let issue;
927
+ try {
928
+ issue = await svc.update(id, updateFields);
929
+ }
930
+ catch (err) {
931
+ if (err instanceof HttpError && err.status === 422) {
932
+ logger.warn({
933
+ issueId: id,
934
+ companyId: existing.companyId,
935
+ assigneePatch: {
936
+ assigneeAgentId: req.body.assigneeAgentId === undefined ? "__omitted__" : req.body.assigneeAgentId,
937
+ assigneeUserId: req.body.assigneeUserId === undefined ? "__omitted__" : req.body.assigneeUserId,
938
+ },
939
+ currentAssignee: {
940
+ assigneeAgentId: existing.assigneeAgentId,
941
+ assigneeUserId: existing.assigneeUserId,
942
+ },
943
+ error: err.message,
944
+ details: err.details,
945
+ }, "issue update rejected with 422");
946
+ }
947
+ throw err;
948
+ }
949
+ if (!issue) {
950
+ res.status(404).json({ error: "Issue not found" });
951
+ return;
952
+ }
953
+ await routinesSvc.syncRunStatusForIssue(issue.id);
954
+ if (actor.runId) {
955
+ await heartbeat.reportRunActivity(actor.runId).catch((err) => logger.warn({ err, runId: actor.runId }, "failed to clear detached run warning after issue activity"));
956
+ }
957
+ // Build activity details with previous values for changed fields
958
+ const previous = {};
959
+ for (const key of Object.keys(updateFields)) {
960
+ if (key in existing && existing[key] !== updateFields[key]) {
961
+ previous[key] = existing[key];
962
+ }
963
+ }
964
+ const hasFieldChanges = Object.keys(previous).length > 0;
965
+ const reopened = commentBody &&
966
+ reopenRequested === true &&
967
+ isClosed &&
968
+ previous.status !== undefined &&
969
+ issue.status === "todo";
970
+ const reopenFromStatus = reopened ? existing.status : null;
971
+ await logActivity(db, {
972
+ companyId: issue.companyId,
973
+ actorType: actor.actorType,
974
+ actorId: actor.actorId,
975
+ agentId: actor.agentId,
976
+ runId: actor.runId,
977
+ action: "issue.updated",
978
+ entityType: "issue",
979
+ entityId: issue.id,
980
+ details: {
981
+ ...updateFields,
982
+ identifier: issue.identifier,
983
+ ...(commentBody ? { source: "comment" } : {}),
984
+ ...(reopened ? { reopened: true, reopenedFrom: reopenFromStatus } : {}),
985
+ ...(interruptedRunId ? { interruptedRunId } : {}),
986
+ _previous: hasFieldChanges ? previous : undefined,
987
+ },
988
+ });
989
+ let comment = null;
990
+ if (commentBody) {
991
+ comment = await svc.addComment(id, commentBody, {
992
+ agentId: actor.agentId ?? undefined,
993
+ userId: actor.actorType === "user" ? actor.actorId : undefined,
994
+ });
995
+ await logActivity(db, {
996
+ companyId: issue.companyId,
997
+ actorType: actor.actorType,
998
+ actorId: actor.actorId,
999
+ agentId: actor.agentId,
1000
+ runId: actor.runId,
1001
+ action: "issue.comment_added",
1002
+ entityType: "issue",
1003
+ entityId: issue.id,
1004
+ details: {
1005
+ commentId: comment.id,
1006
+ bodySnippet: comment.body.slice(0, 120),
1007
+ identifier: issue.identifier,
1008
+ issueTitle: issue.title,
1009
+ ...(reopened ? { reopened: true, reopenedFrom: reopenFromStatus, source: "comment" } : {}),
1010
+ ...(interruptedRunId ? { interruptedRunId } : {}),
1011
+ ...(hasFieldChanges ? { updated: true } : {}),
1012
+ },
1013
+ });
1014
+ }
1015
+ const assigneeChanged = assigneeWillChange;
1016
+ const statusChangedFromBacklog = existing.status === "backlog" &&
1017
+ issue.status !== "backlog" &&
1018
+ req.body.status !== undefined;
1019
+ // Merge all wakeups from this update into one enqueue per agent to avoid duplicate runs.
1020
+ void (async () => {
1021
+ const wakeups = new Map();
1022
+ if (assigneeChanged && issue.assigneeAgentId && issue.status !== "backlog") {
1023
+ wakeups.set(issue.assigneeAgentId, {
1024
+ source: "assignment",
1025
+ triggerDetail: "system",
1026
+ reason: "issue_assigned",
1027
+ payload: {
1028
+ issueId: issue.id,
1029
+ mutation: "update",
1030
+ ...(interruptedRunId ? { interruptedRunId } : {}),
1031
+ },
1032
+ requestedByActorType: actor.actorType,
1033
+ requestedByActorId: actor.actorId,
1034
+ contextSnapshot: {
1035
+ issueId: issue.id,
1036
+ source: "issue.update",
1037
+ ...(requestedUiLocale ? { requestedUiLocale } : {}),
1038
+ ...(interruptedRunId ? { interruptedRunId } : {}),
1039
+ ...(requestedUiLocale ? { requestedUiLocale } : {}),
1040
+ },
1041
+ });
1042
+ }
1043
+ if (!assigneeChanged && statusChangedFromBacklog && issue.assigneeAgentId) {
1044
+ wakeups.set(issue.assigneeAgentId, {
1045
+ source: "automation",
1046
+ triggerDetail: "system",
1047
+ reason: "issue_status_changed",
1048
+ payload: {
1049
+ issueId: issue.id,
1050
+ mutation: "update",
1051
+ ...(interruptedRunId ? { interruptedRunId } : {}),
1052
+ },
1053
+ requestedByActorType: actor.actorType,
1054
+ requestedByActorId: actor.actorId,
1055
+ contextSnapshot: {
1056
+ issueId: issue.id,
1057
+ source: "issue.status_change",
1058
+ ...(requestedUiLocale ? { requestedUiLocale } : {}),
1059
+ ...(interruptedRunId ? { interruptedRunId } : {}),
1060
+ ...(requestedUiLocale ? { requestedUiLocale } : {}),
1061
+ },
1062
+ });
1063
+ }
1064
+ if (commentBody && comment) {
1065
+ let mentionedIds = [];
1066
+ try {
1067
+ mentionedIds = await svc.findMentionedAgents(issue.companyId, commentBody);
1068
+ }
1069
+ catch (err) {
1070
+ logger.warn({ err, issueId: id }, "failed to resolve @-mentions");
1071
+ }
1072
+ for (const mentionedId of mentionedIds) {
1073
+ if (wakeups.has(mentionedId))
1074
+ continue;
1075
+ if (actor.actorType === "agent" && actor.actorId === mentionedId)
1076
+ continue;
1077
+ wakeups.set(mentionedId, {
1078
+ source: "automation",
1079
+ triggerDetail: "system",
1080
+ reason: "issue_comment_mentioned",
1081
+ payload: { issueId: id, commentId: comment.id },
1082
+ requestedByActorType: actor.actorType,
1083
+ requestedByActorId: actor.actorId,
1084
+ contextSnapshot: {
1085
+ issueId: id,
1086
+ taskId: id,
1087
+ commentId: comment.id,
1088
+ wakeCommentId: comment.id,
1089
+ wakeReason: "issue_comment_mentioned",
1090
+ source: "comment.mention",
1091
+ ...(requestedUiLocale ? { requestedUiLocale } : {}),
1092
+ },
1093
+ });
1094
+ }
1095
+ }
1096
+ for (const [agentId, wakeup] of wakeups.entries()) {
1097
+ heartbeat
1098
+ .wakeup(agentId, wakeup)
1099
+ .catch((err) => logger.warn({ err, issueId: issue.id, agentId }, "failed to wake agent on issue update"));
1100
+ }
1101
+ })();
1102
+ res.json({ ...issue, comment });
1103
+ });
1104
+ router.delete("/issues/:id", async (req, res) => {
1105
+ const id = req.params.id;
1106
+ const existing = await svc.getById(id);
1107
+ if (!existing) {
1108
+ res.status(404).json({ error: "Issue not found" });
1109
+ return;
1110
+ }
1111
+ assertCompanyAccess(req, existing.companyId);
1112
+ const attachments = await svc.listAttachments(id);
1113
+ const issue = await svc.remove(id);
1114
+ if (!issue) {
1115
+ res.status(404).json({ error: "Issue not found" });
1116
+ return;
1117
+ }
1118
+ for (const attachment of attachments) {
1119
+ try {
1120
+ await storage.deleteObject(attachment.companyId, attachment.objectKey);
1121
+ }
1122
+ catch (err) {
1123
+ logger.warn({ err, issueId: id, attachmentId: attachment.id }, "failed to delete attachment object during issue delete");
1124
+ }
1125
+ }
1126
+ const actor = getActorInfo(req);
1127
+ await logActivity(db, {
1128
+ companyId: issue.companyId,
1129
+ actorType: actor.actorType,
1130
+ actorId: actor.actorId,
1131
+ agentId: actor.agentId,
1132
+ runId: actor.runId,
1133
+ action: "issue.deleted",
1134
+ entityType: "issue",
1135
+ entityId: issue.id,
1136
+ });
1137
+ res.json(issue);
1138
+ });
1139
+ router.post("/issues/:id/checkout", validate(checkoutIssueSchema), async (req, res) => {
1140
+ const id = req.params.id;
1141
+ const issue = await svc.getById(id);
1142
+ if (!issue) {
1143
+ res.status(404).json({ error: "Issue not found" });
1144
+ return;
1145
+ }
1146
+ assertCompanyAccess(req, issue.companyId);
1147
+ if (issue.projectId) {
1148
+ const project = await projectsSvc.getById(issue.projectId);
1149
+ if (project?.pausedAt) {
1150
+ res.status(409).json({
1151
+ error: project.pauseReason === "budget"
1152
+ ? "Project is paused because its budget hard-stop was reached"
1153
+ : "Project is paused",
1154
+ });
1155
+ return;
1156
+ }
1157
+ }
1158
+ if (req.actor.type === "agent" && req.actor.agentId !== req.body.agentId) {
1159
+ res.status(403).json({ error: "Agent can only checkout as itself" });
1160
+ return;
1161
+ }
1162
+ const checkoutRunId = requireAgentRunId(req, res);
1163
+ if (req.actor.type === "agent" && !checkoutRunId)
1164
+ return;
1165
+ const updated = await svc.checkout(id, req.body.agentId, req.body.expectedStatuses, checkoutRunId);
1166
+ const actor = getActorInfo(req);
1167
+ const requestedUiLocale = resolveExplicitRequestUiLocale(req);
1168
+ await logActivity(db, {
1169
+ companyId: issue.companyId,
1170
+ actorType: actor.actorType,
1171
+ actorId: actor.actorId,
1172
+ agentId: actor.agentId,
1173
+ runId: actor.runId,
1174
+ action: "issue.checked_out",
1175
+ entityType: "issue",
1176
+ entityId: issue.id,
1177
+ details: { agentId: req.body.agentId },
1178
+ });
1179
+ if (shouldWakeAssigneeOnCheckout({
1180
+ actorType: req.actor.type,
1181
+ actorAgentId: req.actor.type === "agent" ? req.actor.agentId ?? null : null,
1182
+ checkoutAgentId: req.body.agentId,
1183
+ checkoutRunId,
1184
+ })) {
1185
+ void heartbeat
1186
+ .wakeup(req.body.agentId, {
1187
+ source: "assignment",
1188
+ triggerDetail: "system",
1189
+ reason: "issue_checked_out",
1190
+ payload: { issueId: issue.id, mutation: "checkout" },
1191
+ requestedByActorType: actor.actorType,
1192
+ requestedByActorId: actor.actorId,
1193
+ contextSnapshot: {
1194
+ issueId: issue.id,
1195
+ source: "issue.checkout",
1196
+ ...(requestedUiLocale ? { requestedUiLocale } : {}),
1197
+ },
1198
+ })
1199
+ .catch((err) => logger.warn({ err, issueId: issue.id }, "failed to wake assignee on issue checkout"));
1200
+ }
1201
+ res.json(updated);
1202
+ });
1203
+ router.post("/issues/:id/release", async (req, res) => {
1204
+ const id = req.params.id;
1205
+ const existing = await svc.getById(id);
1206
+ if (!existing) {
1207
+ res.status(404).json({ error: "Issue not found" });
1208
+ return;
1209
+ }
1210
+ assertCompanyAccess(req, existing.companyId);
1211
+ if (!(await assertAgentRunCheckoutOwnership(req, res, existing)))
1212
+ return;
1213
+ const actorRunId = requireAgentRunId(req, res);
1214
+ if (req.actor.type === "agent" && !actorRunId)
1215
+ return;
1216
+ const released = await svc.release(id, req.actor.type === "agent" ? req.actor.agentId : undefined, actorRunId);
1217
+ if (!released) {
1218
+ res.status(404).json({ error: "Issue not found" });
1219
+ return;
1220
+ }
1221
+ const actor = getActorInfo(req);
1222
+ await logActivity(db, {
1223
+ companyId: released.companyId,
1224
+ actorType: actor.actorType,
1225
+ actorId: actor.actorId,
1226
+ agentId: actor.agentId,
1227
+ runId: actor.runId,
1228
+ action: "issue.released",
1229
+ entityType: "issue",
1230
+ entityId: released.id,
1231
+ });
1232
+ res.json(released);
1233
+ });
1234
+ router.get("/issues/:id/comments", async (req, res) => {
1235
+ const id = req.params.id;
1236
+ const issue = await svc.getById(id);
1237
+ if (!issue) {
1238
+ res.status(404).json({ error: "Issue not found" });
1239
+ return;
1240
+ }
1241
+ assertCompanyAccess(req, issue.companyId);
1242
+ const afterCommentId = typeof req.query.after === "string" && req.query.after.trim().length > 0
1243
+ ? req.query.after.trim()
1244
+ : typeof req.query.afterCommentId === "string" && req.query.afterCommentId.trim().length > 0
1245
+ ? req.query.afterCommentId.trim()
1246
+ : null;
1247
+ const order = typeof req.query.order === "string" && req.query.order.trim().toLowerCase() === "asc"
1248
+ ? "asc"
1249
+ : "desc";
1250
+ const limitRaw = typeof req.query.limit === "string" && req.query.limit.trim().length > 0
1251
+ ? Number(req.query.limit)
1252
+ : null;
1253
+ const limit = limitRaw && Number.isFinite(limitRaw) && limitRaw > 0
1254
+ ? Math.min(Math.floor(limitRaw), MAX_ISSUE_COMMENT_LIMIT)
1255
+ : null;
1256
+ const comments = await svc.listComments(id, {
1257
+ afterCommentId,
1258
+ order,
1259
+ limit,
1260
+ });
1261
+ res.json(comments);
1262
+ });
1263
+ router.get("/issues/:id/comments/:commentId", async (req, res) => {
1264
+ const id = req.params.id;
1265
+ const commentId = req.params.commentId;
1266
+ const issue = await svc.getById(id);
1267
+ if (!issue) {
1268
+ res.status(404).json({ error: "Issue not found" });
1269
+ return;
1270
+ }
1271
+ assertCompanyAccess(req, issue.companyId);
1272
+ const comment = await svc.getComment(commentId);
1273
+ if (!comment || comment.issueId !== id) {
1274
+ res.status(404).json({ error: "Comment not found" });
1275
+ return;
1276
+ }
1277
+ res.json(comment);
1278
+ });
1279
+ router.post("/issues/:id/comments", validate(addIssueCommentSchema), async (req, res) => {
1280
+ const id = req.params.id;
1281
+ const issue = await svc.getById(id);
1282
+ if (!issue) {
1283
+ res.status(404).json({ error: "Issue not found" });
1284
+ return;
1285
+ }
1286
+ assertCompanyAccess(req, issue.companyId);
1287
+ if (!(await assertAgentRunCheckoutOwnership(req, res, issue)))
1288
+ return;
1289
+ const actor = getActorInfo(req);
1290
+ const requestedUiLocale = resolveExplicitRequestUiLocale(req);
1291
+ const reopenRequested = req.body.reopen === true;
1292
+ const interruptRequested = req.body.interrupt === true;
1293
+ const isClosed = issue.status === "done" || issue.status === "cancelled";
1294
+ let reopened = false;
1295
+ let reopenFromStatus = null;
1296
+ let interruptedRunId = null;
1297
+ let currentIssue = issue;
1298
+ if (reopenRequested && isClosed) {
1299
+ const reopenedIssue = await svc.update(id, { status: "todo" });
1300
+ if (!reopenedIssue) {
1301
+ res.status(404).json({ error: "Issue not found" });
1302
+ return;
1303
+ }
1304
+ reopened = true;
1305
+ reopenFromStatus = issue.status;
1306
+ currentIssue = reopenedIssue;
1307
+ await logActivity(db, {
1308
+ companyId: currentIssue.companyId,
1309
+ actorType: actor.actorType,
1310
+ actorId: actor.actorId,
1311
+ agentId: actor.agentId,
1312
+ runId: actor.runId,
1313
+ action: "issue.updated",
1314
+ entityType: "issue",
1315
+ entityId: currentIssue.id,
1316
+ details: {
1317
+ status: "todo",
1318
+ reopened: true,
1319
+ reopenedFrom: reopenFromStatus,
1320
+ source: "comment",
1321
+ identifier: currentIssue.identifier,
1322
+ },
1323
+ });
1324
+ }
1325
+ if (interruptRequested) {
1326
+ if (req.actor.type !== "board") {
1327
+ res.status(403).json({ error: "Only board users can interrupt active runs from issue comments" });
1328
+ return;
1329
+ }
1330
+ const runToInterrupt = await resolveActiveIssueRun(currentIssue);
1331
+ if (runToInterrupt) {
1332
+ const cancelled = await heartbeat.cancelRun(runToInterrupt.id);
1333
+ if (cancelled) {
1334
+ interruptedRunId = cancelled.id;
1335
+ await logActivity(db, {
1336
+ companyId: cancelled.companyId,
1337
+ actorType: actor.actorType,
1338
+ actorId: actor.actorId,
1339
+ agentId: actor.agentId,
1340
+ runId: actor.runId,
1341
+ action: "heartbeat.cancelled",
1342
+ entityType: "heartbeat_run",
1343
+ entityId: cancelled.id,
1344
+ details: { agentId: cancelled.agentId, source: "issue_comment_interrupt", issueId: currentIssue.id },
1345
+ });
1346
+ }
1347
+ }
1348
+ }
1349
+ const comment = await svc.addComment(id, req.body.body, {
1350
+ agentId: actor.agentId ?? undefined,
1351
+ userId: actor.actorType === "user" ? actor.actorId : undefined,
1352
+ });
1353
+ if (actor.runId) {
1354
+ await heartbeat.reportRunActivity(actor.runId).catch((err) => logger.warn({ err, runId: actor.runId }, "failed to clear detached run warning after issue comment"));
1355
+ }
1356
+ await logActivity(db, {
1357
+ companyId: currentIssue.companyId,
1358
+ actorType: actor.actorType,
1359
+ actorId: actor.actorId,
1360
+ agentId: actor.agentId,
1361
+ runId: actor.runId,
1362
+ action: "issue.comment_added",
1363
+ entityType: "issue",
1364
+ entityId: currentIssue.id,
1365
+ details: {
1366
+ commentId: comment.id,
1367
+ bodySnippet: comment.body.slice(0, 120),
1368
+ identifier: currentIssue.identifier,
1369
+ issueTitle: currentIssue.title,
1370
+ ...(reopened ? { reopened: true, reopenedFrom: reopenFromStatus, source: "comment" } : {}),
1371
+ ...(interruptedRunId ? { interruptedRunId } : {}),
1372
+ },
1373
+ });
1374
+ // Merge all wakeups from this comment into one enqueue per agent to avoid duplicate runs.
1375
+ void (async () => {
1376
+ const wakeups = new Map();
1377
+ const assigneeId = currentIssue.assigneeAgentId;
1378
+ const actorIsAgent = actor.actorType === "agent";
1379
+ const selfComment = actorIsAgent && actor.actorId === assigneeId;
1380
+ const skipWake = selfComment || isClosed;
1381
+ if (assigneeId && (reopened || !skipWake)) {
1382
+ if (reopened) {
1383
+ wakeups.set(assigneeId, {
1384
+ source: "automation",
1385
+ triggerDetail: "system",
1386
+ reason: "issue_reopened_via_comment",
1387
+ payload: {
1388
+ issueId: currentIssue.id,
1389
+ commentId: comment.id,
1390
+ reopenedFrom: reopenFromStatus,
1391
+ mutation: "comment",
1392
+ ...(interruptedRunId ? { interruptedRunId } : {}),
1393
+ },
1394
+ requestedByActorType: actor.actorType,
1395
+ requestedByActorId: actor.actorId,
1396
+ contextSnapshot: {
1397
+ issueId: currentIssue.id,
1398
+ taskId: currentIssue.id,
1399
+ commentId: comment.id,
1400
+ source: "issue.comment.reopen",
1401
+ wakeReason: "issue_reopened_via_comment",
1402
+ reopenedFrom: reopenFromStatus,
1403
+ ...(requestedUiLocale ? { requestedUiLocale } : {}),
1404
+ ...(interruptedRunId ? { interruptedRunId } : {}),
1405
+ },
1406
+ });
1407
+ }
1408
+ else {
1409
+ wakeups.set(assigneeId, {
1410
+ source: "automation",
1411
+ triggerDetail: "system",
1412
+ reason: "issue_commented",
1413
+ payload: {
1414
+ issueId: currentIssue.id,
1415
+ commentId: comment.id,
1416
+ mutation: "comment",
1417
+ ...(interruptedRunId ? { interruptedRunId } : {}),
1418
+ },
1419
+ requestedByActorType: actor.actorType,
1420
+ requestedByActorId: actor.actorId,
1421
+ contextSnapshot: {
1422
+ issueId: currentIssue.id,
1423
+ taskId: currentIssue.id,
1424
+ commentId: comment.id,
1425
+ source: "issue.comment",
1426
+ wakeReason: "issue_commented",
1427
+ ...(requestedUiLocale ? { requestedUiLocale } : {}),
1428
+ ...(interruptedRunId ? { interruptedRunId } : {}),
1429
+ },
1430
+ });
1431
+ }
1432
+ }
1433
+ let mentionedIds = [];
1434
+ try {
1435
+ mentionedIds = await svc.findMentionedAgents(issue.companyId, req.body.body);
1436
+ }
1437
+ catch (err) {
1438
+ logger.warn({ err, issueId: id }, "failed to resolve @-mentions");
1439
+ }
1440
+ for (const mentionedId of mentionedIds) {
1441
+ if (wakeups.has(mentionedId))
1442
+ continue;
1443
+ if (actorIsAgent && actor.actorId === mentionedId)
1444
+ continue;
1445
+ wakeups.set(mentionedId, {
1446
+ source: "automation",
1447
+ triggerDetail: "system",
1448
+ reason: "issue_comment_mentioned",
1449
+ payload: { issueId: id, commentId: comment.id },
1450
+ requestedByActorType: actor.actorType,
1451
+ requestedByActorId: actor.actorId,
1452
+ contextSnapshot: {
1453
+ issueId: id,
1454
+ taskId: id,
1455
+ commentId: comment.id,
1456
+ wakeCommentId: comment.id,
1457
+ wakeReason: "issue_comment_mentioned",
1458
+ source: "comment.mention",
1459
+ ...(requestedUiLocale ? { requestedUiLocale } : {}),
1460
+ },
1461
+ });
1462
+ }
1463
+ for (const [agentId, wakeup] of wakeups.entries()) {
1464
+ heartbeat
1465
+ .wakeup(agentId, wakeup)
1466
+ .catch((err) => logger.warn({ err, issueId: currentIssue.id, agentId }, "failed to wake agent on issue comment"));
1467
+ }
1468
+ })();
1469
+ res.status(201).json(comment);
1470
+ });
1471
+ router.get("/issues/:id/attachments", async (req, res) => {
1472
+ const issueId = req.params.id;
1473
+ const issue = await svc.getById(issueId);
1474
+ if (!issue) {
1475
+ res.status(404).json({ error: "Issue not found" });
1476
+ return;
1477
+ }
1478
+ assertCompanyAccess(req, issue.companyId);
1479
+ const attachments = await svc.listAttachments(issueId);
1480
+ res.json(attachments.map(withContentPath));
1481
+ });
1482
+ router.post("/companies/:companyId/issues/:issueId/attachments", async (req, res) => {
1483
+ const companyId = req.params.companyId;
1484
+ const issueId = req.params.issueId;
1485
+ assertCompanyAccess(req, companyId);
1486
+ const issue = await svc.getById(issueId);
1487
+ if (!issue) {
1488
+ res.status(404).json({ error: "Issue not found" });
1489
+ return;
1490
+ }
1491
+ if (issue.companyId !== companyId) {
1492
+ res.status(422).json({ error: "Issue does not belong to company" });
1493
+ return;
1494
+ }
1495
+ try {
1496
+ await runSingleFileUpload(req, res);
1497
+ }
1498
+ catch (err) {
1499
+ if (err instanceof multer.MulterError) {
1500
+ if (err.code === "LIMIT_FILE_SIZE") {
1501
+ res.status(422).json({ error: `Attachment exceeds ${MAX_ATTACHMENT_BYTES} bytes` });
1502
+ return;
1503
+ }
1504
+ res.status(400).json({ error: err.message });
1505
+ return;
1506
+ }
1507
+ throw err;
1508
+ }
1509
+ const file = req.file;
1510
+ if (!file) {
1511
+ res.status(400).json({ error: "Missing file field 'file'" });
1512
+ return;
1513
+ }
1514
+ const contentType = (file.mimetype || "").toLowerCase();
1515
+ if (!isAllowedContentType(contentType)) {
1516
+ res.status(422).json({ error: `Unsupported attachment type: ${contentType || "unknown"}` });
1517
+ return;
1518
+ }
1519
+ if (file.buffer.length <= 0) {
1520
+ res.status(422).json({ error: "Attachment is empty" });
1521
+ return;
1522
+ }
1523
+ const parsedMeta = createIssueAttachmentMetadataSchema.safeParse(req.body ?? {});
1524
+ if (!parsedMeta.success) {
1525
+ res.status(400).json({ error: "Invalid attachment metadata", details: parsedMeta.error.issues });
1526
+ return;
1527
+ }
1528
+ const actor = getActorInfo(req);
1529
+ const stored = await storage.putFile({
1530
+ companyId,
1531
+ namespace: `issues/${issueId}`,
1532
+ originalFilename: file.originalname || null,
1533
+ contentType,
1534
+ body: file.buffer,
1535
+ });
1536
+ const attachment = await svc.createAttachment({
1537
+ issueId,
1538
+ issueCommentId: parsedMeta.data.issueCommentId ?? null,
1539
+ provider: stored.provider,
1540
+ objectKey: stored.objectKey,
1541
+ contentType: stored.contentType,
1542
+ byteSize: stored.byteSize,
1543
+ sha256: stored.sha256,
1544
+ originalFilename: stored.originalFilename,
1545
+ createdByAgentId: actor.agentId,
1546
+ createdByUserId: actor.actorType === "user" ? actor.actorId : null,
1547
+ });
1548
+ await logActivity(db, {
1549
+ companyId,
1550
+ actorType: actor.actorType,
1551
+ actorId: actor.actorId,
1552
+ agentId: actor.agentId,
1553
+ runId: actor.runId,
1554
+ action: "issue.attachment_added",
1555
+ entityType: "issue",
1556
+ entityId: issueId,
1557
+ details: {
1558
+ attachmentId: attachment.id,
1559
+ originalFilename: attachment.originalFilename,
1560
+ contentType: attachment.contentType,
1561
+ byteSize: attachment.byteSize,
1562
+ },
1563
+ });
1564
+ res.status(201).json(withContentPath(attachment));
1565
+ });
1566
+ router.get("/attachments/:attachmentId/content", async (req, res, next) => {
1567
+ const attachmentId = req.params.attachmentId;
1568
+ const attachment = await svc.getAttachmentById(attachmentId);
1569
+ if (!attachment) {
1570
+ res.status(404).json({ error: "Attachment not found" });
1571
+ return;
1572
+ }
1573
+ assertCompanyAccess(req, attachment.companyId);
1574
+ const object = await storage.getObject(attachment.companyId, attachment.objectKey);
1575
+ res.setHeader("Content-Type", attachment.contentType || object.contentType || "application/octet-stream");
1576
+ res.setHeader("Content-Length", String(attachment.byteSize || object.contentLength || 0));
1577
+ res.setHeader("Cache-Control", "private, max-age=60");
1578
+ const filename = attachment.originalFilename ?? "attachment";
1579
+ res.setHeader("Content-Disposition", `inline; filename=\"${filename.replaceAll("\"", "")}\"`);
1580
+ object.stream.on("error", (err) => {
1581
+ next(err);
1582
+ });
1583
+ object.stream.pipe(res);
1584
+ });
1585
+ router.delete("/attachments/:attachmentId", async (req, res) => {
1586
+ const attachmentId = req.params.attachmentId;
1587
+ const attachment = await svc.getAttachmentById(attachmentId);
1588
+ if (!attachment) {
1589
+ res.status(404).json({ error: "Attachment not found" });
1590
+ return;
1591
+ }
1592
+ assertCompanyAccess(req, attachment.companyId);
1593
+ try {
1594
+ await storage.deleteObject(attachment.companyId, attachment.objectKey);
1595
+ }
1596
+ catch (err) {
1597
+ logger.warn({ err, attachmentId }, "storage delete failed while removing attachment");
1598
+ }
1599
+ const removed = await svc.removeAttachment(attachmentId);
1600
+ if (!removed) {
1601
+ res.status(404).json({ error: "Attachment not found" });
1602
+ return;
1603
+ }
1604
+ const actor = getActorInfo(req);
1605
+ await logActivity(db, {
1606
+ companyId: removed.companyId,
1607
+ actorType: actor.actorType,
1608
+ actorId: actor.actorId,
1609
+ agentId: actor.agentId,
1610
+ runId: actor.runId,
1611
+ action: "issue.attachment_removed",
1612
+ entityType: "issue",
1613
+ entityId: removed.issueId,
1614
+ details: {
1615
+ attachmentId: removed.id,
1616
+ },
1617
+ });
1618
+ res.json({ ok: true });
1619
+ });
1620
+ return router;
1621
+ }
1622
+ //# sourceMappingURL=issues.js.map