constellai 0.3.2 → 0.3.4

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 (238) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +3 -3
  3. package/.next/prerender-manifest.json +3 -3
  4. package/.next/react-loadable-manifest.json +2 -2
  5. package/.next/server/app/(app)/activity/page.js +2 -2
  6. package/.next/server/app/(app)/activity/page.js.nft.json +1 -1
  7. package/.next/server/app/(app)/activity/page_client-reference-manifest.js +1 -1
  8. package/.next/server/app/(app)/agents/[handle]/page.js +2 -2
  9. package/.next/server/app/(app)/agents/[handle]/page.js.nft.json +1 -1
  10. package/.next/server/app/(app)/agents/[handle]/page_client-reference-manifest.js +1 -1
  11. package/.next/server/app/(app)/code/page.js +2 -2
  12. package/.next/server/app/(app)/code/page.js.nft.json +1 -1
  13. package/.next/server/app/(app)/code/page_client-reference-manifest.js +1 -1
  14. package/.next/server/app/(app)/config/page.js +2 -2
  15. package/.next/server/app/(app)/config/page.js.nft.json +1 -1
  16. package/.next/server/app/(app)/config/page_client-reference-manifest.js +1 -1
  17. package/.next/server/app/(app)/costs/page.js +2 -2
  18. package/.next/server/app/(app)/costs/page.js.nft.json +1 -1
  19. package/.next/server/app/(app)/costs/page_client-reference-manifest.js +1 -1
  20. package/.next/server/app/(app)/cron/page.js +2 -2
  21. package/.next/server/app/(app)/cron/page.js.nft.json +1 -1
  22. package/.next/server/app/(app)/cron/page_client-reference-manifest.js +1 -1
  23. package/.next/server/app/(app)/dashboard/page.js +2 -2
  24. package/.next/server/app/(app)/dashboard/page.js.nft.json +1 -1
  25. package/.next/server/app/(app)/dashboard/page_client-reference-manifest.js +1 -1
  26. package/.next/server/app/(app)/design/page.js +13 -13
  27. package/.next/server/app/(app)/design/page.js.nft.json +1 -1
  28. package/.next/server/app/(app)/design/page_client-reference-manifest.js +1 -1
  29. package/.next/server/app/(app)/docs/[id]/page.js +2 -2
  30. package/.next/server/app/(app)/docs/[id]/page.js.nft.json +1 -1
  31. package/.next/server/app/(app)/docs/[id]/page_client-reference-manifest.js +1 -1
  32. package/.next/server/app/(app)/docs/page.js +2 -2
  33. package/.next/server/app/(app)/docs/page.js.nft.json +1 -1
  34. package/.next/server/app/(app)/docs/page_client-reference-manifest.js +1 -1
  35. package/.next/server/app/(app)/github/page.js +1 -1
  36. package/.next/server/app/(app)/github/page.js.nft.json +1 -1
  37. package/.next/server/app/(app)/github/page_client-reference-manifest.js +1 -1
  38. package/.next/server/app/(app)/goals/page.js +2 -2
  39. package/.next/server/app/(app)/goals/page.js.nft.json +1 -1
  40. package/.next/server/app/(app)/goals/page_client-reference-manifest.js +1 -1
  41. package/.next/server/app/(app)/inbox/page.js +2 -2
  42. package/.next/server/app/(app)/inbox/page.js.nft.json +1 -1
  43. package/.next/server/app/(app)/inbox/page_client-reference-manifest.js +1 -1
  44. package/.next/server/app/(app)/knowledge/page.js +3 -3
  45. package/.next/server/app/(app)/knowledge/page.js.nft.json +1 -1
  46. package/.next/server/app/(app)/knowledge/page_client-reference-manifest.js +1 -1
  47. package/.next/server/app/(app)/models/page.js +2 -2
  48. package/.next/server/app/(app)/models/page.js.nft.json +1 -1
  49. package/.next/server/app/(app)/models/page_client-reference-manifest.js +1 -1
  50. package/.next/server/app/(app)/notifications/page.js +2 -2
  51. package/.next/server/app/(app)/notifications/page.js.nft.json +1 -1
  52. package/.next/server/app/(app)/notifications/page_client-reference-manifest.js +1 -1
  53. package/.next/server/app/(app)/org/page.js +4 -4
  54. package/.next/server/app/(app)/org/page.js.nft.json +1 -1
  55. package/.next/server/app/(app)/org/page_client-reference-manifest.js +1 -1
  56. package/.next/server/app/(app)/organizations/page.js +2 -2
  57. package/.next/server/app/(app)/organizations/page.js.nft.json +1 -1
  58. package/.next/server/app/(app)/organizations/page_client-reference-manifest.js +1 -1
  59. package/.next/server/app/(app)/page.js +3 -3
  60. package/.next/server/app/(app)/page.js.nft.json +1 -1
  61. package/.next/server/app/(app)/page_client-reference-manifest.js +1 -1
  62. package/.next/server/app/(app)/planner/page.js +2 -2
  63. package/.next/server/app/(app)/planner/page.js.nft.json +1 -1
  64. package/.next/server/app/(app)/planner/page_client-reference-manifest.js +1 -1
  65. package/.next/server/app/(app)/plugins/page.js +2 -2
  66. package/.next/server/app/(app)/plugins/page.js.nft.json +1 -1
  67. package/.next/server/app/(app)/plugins/page_client-reference-manifest.js +1 -1
  68. package/.next/server/app/(app)/pm/page.js +2 -2
  69. package/.next/server/app/(app)/pm/page.js.nft.json +1 -1
  70. package/.next/server/app/(app)/pm/page_client-reference-manifest.js +1 -1
  71. package/.next/server/app/(app)/prepare-deploy/page.js +2 -2
  72. package/.next/server/app/(app)/prepare-deploy/page.js.nft.json +1 -1
  73. package/.next/server/app/(app)/prepare-deploy/page_client-reference-manifest.js +1 -1
  74. package/.next/server/app/(app)/profile/page.js +2 -2
  75. package/.next/server/app/(app)/profile/page.js.nft.json +1 -1
  76. package/.next/server/app/(app)/profile/page_client-reference-manifest.js +1 -1
  77. package/.next/server/app/(app)/pulse/page.js +2 -2
  78. package/.next/server/app/(app)/pulse/page.js.nft.json +1 -1
  79. package/.next/server/app/(app)/pulse/page_client-reference-manifest.js +1 -1
  80. package/.next/server/app/(app)/reports/[id]/page.js +2 -2
  81. package/.next/server/app/(app)/reports/[id]/page.js.nft.json +1 -1
  82. package/.next/server/app/(app)/reports/[id]/page_client-reference-manifest.js +1 -1
  83. package/.next/server/app/(app)/reports/page.js +3 -3
  84. package/.next/server/app/(app)/reports/page.js.nft.json +1 -1
  85. package/.next/server/app/(app)/reports/page_client-reference-manifest.js +1 -1
  86. package/.next/server/app/(app)/routines/page.js +2 -2
  87. package/.next/server/app/(app)/routines/page.js.nft.json +1 -1
  88. package/.next/server/app/(app)/routines/page_client-reference-manifest.js +1 -1
  89. package/.next/server/app/(app)/search/page.js +2 -2
  90. package/.next/server/app/(app)/search/page.js.nft.json +1 -1
  91. package/.next/server/app/(app)/search/page_client-reference-manifest.js +1 -1
  92. package/.next/server/app/(app)/security/page.js +2 -2
  93. package/.next/server/app/(app)/security/page.js.nft.json +1 -1
  94. package/.next/server/app/(app)/security/page_client-reference-manifest.js +1 -1
  95. package/.next/server/app/(app)/skills/page.js +2 -2
  96. package/.next/server/app/(app)/skills/page.js.nft.json +1 -1
  97. package/.next/server/app/(app)/skills/page_client-reference-manifest.js +1 -1
  98. package/.next/server/app/(app)/tasks/page.js +2 -2
  99. package/.next/server/app/(app)/tasks/page.js.nft.json +1 -1
  100. package/.next/server/app/(app)/tasks/page_client-reference-manifest.js +1 -1
  101. package/.next/server/app/(app)/test-dev/page.js +2 -2
  102. package/.next/server/app/(app)/test-dev/page.js.nft.json +1 -1
  103. package/.next/server/app/(app)/test-dev/page_client-reference-manifest.js +1 -1
  104. package/.next/server/app/(app)/update/page.js +3 -3
  105. package/.next/server/app/(app)/update/page.js.nft.json +1 -1
  106. package/.next/server/app/(app)/update/page_client-reference-manifest.js +1 -1
  107. package/.next/server/app/(auth)/login/page.js +2 -2
  108. package/.next/server/app/(auth)/login/page_client-reference-manifest.js +1 -1
  109. package/.next/server/app/(auth)/onboarding/page.js +1 -1
  110. package/.next/server/app/(auth)/onboarding/page_client-reference-manifest.js +1 -1
  111. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  112. package/.next/server/app/_global-error.html +1 -1
  113. package/.next/server/app/_global-error.rsc +1 -1
  114. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  115. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  116. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  117. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  118. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  119. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  120. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  121. package/.next/server/app/api/cron/tick/route.js +2 -2
  122. package/.next/server/app/api/sync/file/route.js +1 -1
  123. package/.next/server/app/api/telegram/poll/route.js +3 -3
  124. package/.next/server/app/api/v1/[[...path]]/route.js +1 -1
  125. package/.next/server/chunks/1249.js +5 -5
  126. package/.next/server/chunks/259.js +1 -1
  127. package/.next/server/chunks/2867.js +1 -1
  128. package/.next/server/chunks/2960.js +1 -1
  129. package/.next/server/chunks/319.js +1 -0
  130. package/.next/server/chunks/3234.js +1 -1
  131. package/.next/server/chunks/4828.js +1 -0
  132. package/.next/server/chunks/4979.js +2 -2
  133. package/.next/server/chunks/5697.js +1 -0
  134. package/.next/server/chunks/6151.js +12 -0
  135. package/.next/server/chunks/6431.js +1 -1
  136. package/.next/server/chunks/6798.js +21 -0
  137. package/.next/server/chunks/{3078.js → 6903.js} +15 -15
  138. package/.next/server/chunks/7589.js +1 -1
  139. package/.next/server/chunks/7989.js +1 -1
  140. package/.next/server/chunks/8486.js +4 -0
  141. package/.next/server/chunks/8561.js +1 -1
  142. package/.next/server/chunks/8823.js +1 -1
  143. package/.next/server/chunks/9783.js +1 -1
  144. package/.next/server/middleware-build-manifest.js +1 -1
  145. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  146. package/.next/server/pages/500.html +1 -1
  147. package/.next/server/server-reference-manifest.js +1 -1
  148. package/.next/server/server-reference-manifest.json +1 -1
  149. package/.next/static/chunks/4353-12629098ed83e468.js +1 -0
  150. package/.next/static/chunks/4398-e798770ae782576f.js +1 -0
  151. package/.next/static/chunks/4428-09f7d473d9e33d59.js +1 -0
  152. package/.next/static/chunks/7457-c37382c6f4e115f8.js +4 -0
  153. package/.next/static/chunks/{7509.8d3cbebb5fbe6247.js → 7509.721cd47a931c5518.js} +1 -1
  154. package/.next/static/chunks/{8370-4a29b1affcb7dc68.js → 8370-6da6aa10d687b8ae.js} +2 -2
  155. package/.next/static/chunks/9690-00ad96a74abac075.js +1 -0
  156. package/.next/static/chunks/app/(app)/activity/{page-02fbf7cf46282feb.js → page-09bc1c776962737c.js} +1 -1
  157. package/.next/static/chunks/app/(app)/agents/[handle]/page-b11e5f8f25fb2f88.js +1 -0
  158. package/.next/static/chunks/app/(app)/code/{page-8f8ae22136752631.js → page-ff6925db6e10e3cc.js} +1 -1
  159. package/.next/static/chunks/app/(app)/config/page-4df2facd9c81adb5.js +1 -0
  160. package/.next/static/chunks/app/(app)/costs/{page-aadb60fb329974f3.js → page-c0a07c0283731a8c.js} +1 -1
  161. package/.next/static/chunks/app/(app)/cron/{page-0219c7a0530ad628.js → page-662e6e1a25b14025.js} +1 -1
  162. package/.next/static/chunks/app/(app)/dashboard/page-e6f62eaecc0f9926.js +1 -0
  163. package/.next/static/chunks/app/(app)/design/{page-f889489d70e0e839.js → page-d457cdfa525acb85.js} +3 -3
  164. package/.next/static/chunks/app/(app)/docs/[id]/{page-f2e1f3d72634fb4b.js → page-4a1be0c9bd6ca402.js} +1 -1
  165. package/.next/static/chunks/app/(app)/docs/page-e6db758a14f57ec8.js +1 -0
  166. package/.next/static/chunks/app/(app)/github/{page-0e47c2c1c9c927e4.js → page-57bb812627d083a1.js} +1 -1
  167. package/.next/static/chunks/app/(app)/goals/page-81e1af515f78e13b.js +1 -0
  168. package/.next/static/chunks/app/(app)/inbox/page-0baef1b01009c832.js +12 -0
  169. package/.next/static/chunks/app/(app)/knowledge/page-eb1317bf385e31ed.js +1 -0
  170. package/.next/static/chunks/app/(app)/layout-dcd4f30b53cb140f.js +1 -0
  171. package/.next/static/chunks/app/(app)/models/page-d73965ae6ca317e8.js +1 -0
  172. package/.next/static/chunks/app/(app)/notifications/page-b3ff14483cb6694e.js +12 -0
  173. package/.next/static/chunks/app/(app)/org/{page-30bb71b216cc152e.js → page-3075b218dbc681ce.js} +2 -2
  174. package/.next/static/chunks/app/(app)/organizations/page-a6d35dbb21a61b7c.js +1 -0
  175. package/.next/static/chunks/app/(app)/page-c9e4fc0616a0083e.js +1 -0
  176. package/.next/static/chunks/app/(app)/planner/{page-5177b5fd72d529f4.js → page-809dd3edda4ada93.js} +1 -1
  177. package/.next/static/chunks/app/(app)/plugins/page-7e2aad1b702b5c88.js +1 -0
  178. package/.next/static/chunks/app/(app)/pm/page-709f9ac68ac98693.js +1 -0
  179. package/.next/static/chunks/app/(app)/prepare-deploy/page-f9609626153c2483.js +1 -0
  180. package/.next/static/chunks/app/(app)/profile/page-6d22c7bd0adb7a52.js +1 -0
  181. package/.next/static/chunks/app/(app)/pulse/{page-a0895a89c74c1d4c.js → page-f529917828ff4884.js} +1 -1
  182. package/.next/static/chunks/app/(app)/reports/[id]/{page-0219c7a0530ad628.js → page-662e6e1a25b14025.js} +1 -1
  183. package/.next/static/chunks/app/(app)/reports/page-5248735b18767054.js +1 -0
  184. package/.next/static/chunks/app/(app)/routines/{page-eaba9756a33d98a6.js → page-cf4e597389865ae8.js} +1 -1
  185. package/.next/static/chunks/app/(app)/search/{page-d975712d07eed70d.js → page-4d1e07c4c43a7489.js} +1 -1
  186. package/.next/static/chunks/app/(app)/security/{page-4b126307f9963c2a.js → page-db7b8840d9cc6b72.js} +1 -1
  187. package/.next/static/chunks/app/(app)/skills/page-a98da9e415efc310.js +1 -0
  188. package/.next/static/chunks/app/(app)/tasks/page-ab33402626a50c88.js +1 -0
  189. package/.next/static/chunks/app/(app)/test-dev/page-34612a4b47ec9aa2.js +1 -0
  190. package/.next/static/chunks/app/(app)/update/page-99d63495bfdd56a9.js +1 -0
  191. package/.next/static/chunks/app/(auth)/login/{page-3df648bab2319a0b.js → page-c7b372a5053512f0.js} +1 -1
  192. package/.next/static/chunks/app/(auth)/onboarding/{page-ee09eb3fd38f3365.js → page-450bfc87fb942f9b.js} +1 -1
  193. package/.next/static/chunks/{main-2e2f6e1d0f3b78b1.js → main-722e16032e7764d1.js} +1 -1
  194. package/.next/static/chunks/webpack-222e3894b78c67db.js +1 -0
  195. package/.next/trace-build +1 -1
  196. package/CHANGELOG.md +32 -0
  197. package/README.md +1 -1
  198. package/README.pt-BR.md +1 -1
  199. package/bin/constella-update.mjs +44 -0
  200. package/docs/UPDATE.md +51 -6
  201. package/package.json +1 -1
  202. package/scripts/vps-install.sh +22 -0
  203. package/scripts/vps-update.sh +22 -0
  204. package/.next/server/chunks/104.js +0 -1
  205. package/.next/server/chunks/1082.js +0 -1
  206. package/.next/server/chunks/2359.js +0 -1
  207. package/.next/server/chunks/7970.js +0 -21
  208. package/.next/server/chunks/8071.js +0 -4
  209. package/.next/server/chunks/8102.js +0 -12
  210. package/.next/static/chunks/1068-50497be19315ccfb.js +0 -1
  211. package/.next/static/chunks/4991-0306ad0e6cd8cb8a.js +0 -1
  212. package/.next/static/chunks/6061-f3ad54a48323cba0.js +0 -1
  213. package/.next/static/chunks/6121-37930472292e5a6c.js +0 -4
  214. package/.next/static/chunks/9690-53d5222618cbeddb.js +0 -1
  215. package/.next/static/chunks/app/(app)/agents/[handle]/page-e3eda42a3f20e3e5.js +0 -1
  216. package/.next/static/chunks/app/(app)/config/page-84216e49b0b08248.js +0 -1
  217. package/.next/static/chunks/app/(app)/dashboard/page-1e7ecb2bdefcdc19.js +0 -1
  218. package/.next/static/chunks/app/(app)/docs/page-ab10f655b932f175.js +0 -1
  219. package/.next/static/chunks/app/(app)/goals/page-9a68e61bbc392281.js +0 -1
  220. package/.next/static/chunks/app/(app)/inbox/page-6ee42cdd99664d11.js +0 -12
  221. package/.next/static/chunks/app/(app)/knowledge/page-c02936180f61550f.js +0 -1
  222. package/.next/static/chunks/app/(app)/layout-7d2d377b224620c8.js +0 -1
  223. package/.next/static/chunks/app/(app)/models/page-8635495017d696c1.js +0 -1
  224. package/.next/static/chunks/app/(app)/notifications/page-72f15bd4b6289bf1.js +0 -12
  225. package/.next/static/chunks/app/(app)/organizations/page-50c64b60a6850870.js +0 -1
  226. package/.next/static/chunks/app/(app)/page-638517264806ba7e.js +0 -1
  227. package/.next/static/chunks/app/(app)/plugins/page-66921b5b398f2c05.js +0 -1
  228. package/.next/static/chunks/app/(app)/pm/page-a1f93d19d3c28627.js +0 -1
  229. package/.next/static/chunks/app/(app)/prepare-deploy/page-de7dc9413e3dbf82.js +0 -1
  230. package/.next/static/chunks/app/(app)/profile/page-e73d191fce633cd7.js +0 -1
  231. package/.next/static/chunks/app/(app)/reports/page-fd0b0d0fa742819e.js +0 -1
  232. package/.next/static/chunks/app/(app)/skills/page-f1fc99f1d15e26a4.js +0 -1
  233. package/.next/static/chunks/app/(app)/tasks/page-a4b78a8d76fd9432.js +0 -1
  234. package/.next/static/chunks/app/(app)/test-dev/page-55cef74633b3cf4c.js +0 -1
  235. package/.next/static/chunks/app/(app)/update/page-92764fc98b253709.js +0 -1
  236. package/.next/static/chunks/webpack-94c9726ec79ee4b4.js +0 -1
  237. /package/.next/static/{N4KMSOY3i-qyXrbfm97sO → mOVW9EdxrQ1xPT7vDdRdK}/_buildManifest.js +0 -0
  238. /package/.next/static/{N4KMSOY3i-qyXrbfm97sO → mOVW9EdxrQ1xPT7vDdRdK}/_ssgManifest.js +0 -0
@@ -1,4 +1,7 @@
1
- exports.id=3078,exports.ids=[3078],exports.modules={387:(a,b,c)=>{"use strict";c.d(b,{O:()=>i,f:()=>j});var d=c(6866),e=c(31371),f=c(53993),g=c(56338),h=c(57300);async function i(){let{org:a}=await (0,f.nP)(),b=await (0,g.aE)(a.id);return(0,e.revalidatePath)("/knowledge"),(0,e.revalidatePath)("/reports"),b}async function j(){let{org:a}=await (0,f.nP)(),b=await (0,h.xV)(a.id);return(0,e.revalidatePath)("/knowledge"),{ok:b.ok,chunks:b.chunks}}(0,c(74252).D)([i,j]),(0,d.A)(i,"00989a2c152ceb87b200f52f9d56d6a1006b3ae418",null),(0,d.A)(j,"004ec7f252351e38a9c4baf338040eebc632b425d2",null)},437:(a,b,c)=>{"use strict";c.d(b,{Y:()=>j,g:()=>i});var d=c(97603),e=c(76760),f=c(65705),g=c(1890),h=c(57086);async function i(a,b,c,d){let i=(0,h.HZ)(b);for(let b of d){if(!b.path)continue;let d=((0,e.isAbsolute)(b.path)?(0,e.relative)(i,b.path):b.path).replace(/\\/g,"/");if(!(!d||d.startsWith(".."))&&!(d.startsWith(".claude/")||d.startsWith("archives/")||d.startsWith(".git/")))try{await f.db.insert(g.goalFile).values({workspaceId:a,goalId:c,path:d,op:b.op}).onConflictDoUpdate({target:[g.goalFile.goalId,g.goalFile.path],set:{op:b.op,at:new Date}})}catch{}}}async function j(a,b){return(await f.db.select({path:g.goalFile.path}).from(g.goalFile).where((0,d.Uo)((0,d.eq)(g.goalFile.workspaceId,a),(0,d.eq)(g.goalFile.goalId,b)))).map(a=>a.path)}},1273:(a,b,c)=>{"use strict";c.d(b,{_:()=>g});let d={"gpt-4o":[2.5,10],"gpt-4o-mini":[.15,.6],"o4-mini":[1.1,4.4],"gemini-2.0-flash":[.1,.4],"gemini-1.5-pro":[1.25,5],"gemini-1.5-flash":[.075,.3]};function e(a,b,c){let e=Object.keys(d).find(b=>a.toLowerCase().startsWith(b));if(!e)return 0;let[f,g]=d[e];return b/1e6*f+c/1e6*g}function f(a,b,c,d){return{ok:!1,text:"",usd:0,inputTokens:0,outputTokens:0,durationMs:c,binary:a,model:b,error:d}}async function g(a,b,c,d){let g,h=Date.now(),i=b.baseUrl.replace(/\/$/,""),j="google"===b.provider,k=j?`${i}/models/${encodeURIComponent(b.model)}:streamGenerateContent?alt=sse&key=${encodeURIComponent(b.apiKey)}`:`${i}/chat/completions`,l={"content-type":"application/json"};!j&&b.apiKey&&(l.authorization=`Bearer ${b.apiKey}`);let m=j?{contents:[{role:"user",parts:[{text:a}]}]}:{model:b.model,messages:[{role:"user",content:a}],stream:!0,stream_options:{include_usage:!0}};try{g=await fetch(k,{method:"POST",headers:l,body:JSON.stringify(m),signal:AbortSignal.timeout(c.timeoutMs??18e4)})}catch(a){return f(b.provider,b.model,Date.now()-h,String(a instanceof Error?a.message:a))}if(!g.ok||!g.body){let a=await g.text().catch(()=>"");return f(b.provider,b.model,Date.now()-h,`http ${g.status} ${a.slice(0,200)}`)}let n=g.body.getReader(),o=new TextDecoder,p="",q="",r=0,s=0,t=0,u=()=>{q.length>r&&(d({kind:"text",detail:q.slice(r,r+8e3)}),r=q.length)};try{for(;;){let a,{value:b,done:c}=await n.read();if(c)break;for(p+=o.decode(b,{stream:!0});(a=p.indexOf("\n"))>=0;){let b=p.slice(0,a).trim();if(p=p.slice(a+1),!b.startsWith("data:"))continue;let c=b.slice(5).trim();if("[DONE]"!==c)try{let a=JSON.parse(c);if(j){let b=a.candidates?.[0]?.content?.parts?.map(a=>a.text??"").join("")??"";b&&(q+=b).length-r>=120&&u();let c=a.usageMetadata;c&&(s=c.promptTokenCount??s,t=c.candidatesTokenCount??t)}else{let b=a.choices?.[0]?.delta?.content??"";b&&(q+=b).length-r>=120&&u(),a.usage&&(s=a.usage.prompt_tokens??s,t=a.usage.completion_tokens??t)}}catch{}}}}catch(a){return u(),d({kind:"done"}),{ok:!!q,text:q,usd:e(b.model,s,t),inputTokens:s,outputTokens:t,durationMs:Date.now()-h,binary:b.provider,model:b.model,error:q?void 0:String(a instanceof Error?a.message:a)}}return u(),d({kind:"done"}),{ok:!!q.trim(),text:q,usd:e(b.model,s,t),inputTokens:s,outputTokens:t,durationMs:Date.now()-h,binary:b.provider,model:b.model,error:q.trim()?void 0:"empty response"}}},1308:(a,b,c)=>{"use strict";c.d(b,{b:()=>w});var d=c(61576),e=c(81992),f=c.n(e),g=c(79676),h=c(1782),i=c(80280),j=c(25533),k=c(95896),l=c(14565);function m({size:a=34,rx:b=9}){return(0,d.jsxs)("svg",{width:a,height:a,viewBox:"0 0 100 100",style:{display:"block",flex:`0 0 ${a}px`},"aria-label":"Constella",children:[(0,d.jsx)("rect",{x:"1",y:"1",width:"98",height:"98",rx:b,fill:"var(--cs-bg)",stroke:"var(--cs-border)",strokeWidth:"1.5"}),(0,d.jsx)("path",{d:"M66.06 27.06 L42.75 22.95 L24.62 38.17 L24.62 61.83 L42.75 77.05 L66.06 72.94",fill:"none",stroke:"var(--cs-line)",strokeWidth:"2.1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,d.jsx)("path",{d:"M48 50 L42.75 22.95 M48 50 L24.62 50 M48 50 L42.75 77.05",fill:"none",stroke:"var(--cs-line)",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.55"}),[[66.06,27.06],[42.75,22.95],[24.62,38.17],[24.62,61.83],[42.75,77.05],[66.06,72.94]].map((a,b)=>(0,d.jsx)("circle",{cx:a[0],cy:a[1],r:"3.1",fill:"var(--cs-node)"},b)),(0,d.jsx)("circle",{cx:"48",cy:"50",r:"8.5",fill:"var(--cs-glow)",opacity:"0.4"}),(0,d.jsx)("circle",{cx:"48",cy:"50",r:"4.3",fill:"var(--cs-core)"})]})}var n=c(2756),o=c(67686),p=c(32825),q=c(29876),r=c(15783),s=c(16120),t=c(42328),u=c(83836),v=c(75785);async function w({title:a}){let b=await (0,g.cookies)(),c=b.get("cn-theme")?.value==="dark"?"dark":"light",e=(0,v.e)(b.get("cn-lang")?.value),{workspace:x}=await (0,k.nP)(),y=(await i.db.select().from(j.notification).where((0,h.Uo)((0,h.eq)(j.notification.workspaceId,x.id),(0,h.eq)(j.notification.read,!1)))).length,z=u.e.find(b=>b.title===a);return(0,d.jsxs)("div",{className:"app-top",children:[(0,d.jsx)(s.SidebarToggle,{}),(0,d.jsx)(r.BackButton,{}),(0,d.jsxs)("div",{className:"app-crumb",children:[(0,d.jsxs)(f(),{href:"/",style:{display:"inline-flex",alignItems:"center",gap:7,textDecoration:"none",color:"inherit"},children:[(0,d.jsx)(m,{size:16,rx:5})," Constella"]}),(0,d.jsx)(n.I,{name:"chevronRight",size:12,style:{opacity:.4}}),(0,d.jsxs)("b",{style:{display:"inline-flex",alignItems:"center",gap:7},children:[(0,d.jsx)(n.I,{name:z?z.icon:"grid",size:14,style:{color:"var(--accent)"}})," ",z?(0,v.t)(e,`mod.${z.id}`):a]})]}),(0,d.jsxs)("div",{className:"app-top-actions",children:[(0,d.jsx)(t.UpdateHeaderBadge,{}),(0,d.jsx)(f(),{href:"/search",className:"top-btn",title:(0,v.t)(e,"nav.search"),children:(0,d.jsx)(n.I,{name:"search",size:17})}),(0,d.jsxs)(f(),{href:"/notifications",className:"top-btn",title:(0,v.t)(e,"top.notifications"),style:{position:"relative"},children:[(0,d.jsx)(n.I,{name:"bell",size:17}),y>0&&(0,d.jsx)("span",{className:"nv-badge",children:y})]}),(0,d.jsx)(o.ChatToggle,{}),(0,d.jsx)(q.LangSwitch,{}),(0,d.jsx)(p.AnimToggle,{}),(0,d.jsx)("form",{action:l.OD.bind(null,c),children:(0,d.jsx)("button",{className:"top-btn",title:(0,v.t)(e,"top.theme"),type:"submit",children:(0,d.jsx)(n.I,{name:"dark"===c?"sun":"moon",size:17})})})]})]})}},1684:(a,b,c)=>{"use strict";c.d(b,{_:()=>e});var d=c(2910);let e=(0,d.createServerReference)("700e7dc42f9902ba897ac4e36d45bfd5032bd56211",d.callServer,void 0,d.findSourceMapURL,"sendMessage")},2756:(a,b,c)=>{"use strict";c.d(b,{I:()=>f});var d=c(61576);let e={files:(0,d.jsx)("path",{d:"M3 3.5h5l1.5 2H13a1 1 0 0 1 1 1V12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4.5a1 1 0 0 1 1-1z"}),search:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"7",cy:"7",r:"4.2"}),(0,d.jsx)("path",{d:"M10.2 10.2 14 14"})]}),git:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"4",cy:"4",r:"1.8"}),(0,d.jsx)("circle",{cx:"4",cy:"12",r:"1.8"}),(0,d.jsx)("circle",{cx:"12",cy:"9.5",r:"1.8"}),(0,d.jsx)("path",{d:"M4 5.8v4.4M5.8 4H9a2 2 0 0 1 2 2v1.6"})]}),debug:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"8",cy:"8.5",r:"3.5"}),(0,d.jsx)("path",{d:"M8 5V3M4.5 8.5H2m12 0h-2.5M4.8 11.8 3.4 13M11.2 11.8l1.4 1.2M5.2 5 3.8 3.6M10.8 5l1.4-1.4"})]}),ext:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"1"}),(0,d.jsx)("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"1"}),(0,d.jsx)("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"1"}),(0,d.jsx)("path",{d:"M9 11.2h4.5M11.2 9v4.5"})]}),settings:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"8",cy:"8",r:"2.2"}),(0,d.jsx)("path",{d:"M8 1.5v2M8 12.5v2M14.5 8h-2M3.5 8h-2M12.6 3.4l-1.4 1.4M4.8 11.2l-1.4 1.4M12.6 12.6l-1.4-1.4M4.8 4.8 3.4 3.4"})]}),account:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"8",cy:"5.5",r:"2.8"}),(0,d.jsx)("path",{d:"M2.8 14c0-2.8 2.3-4.5 5.2-4.5s5.2 1.7 5.2 4.5"})]}),chevronRight:(0,d.jsx)("path",{d:"M6 4l4 4-4 4"}),chevronDown:(0,d.jsx)("path",{d:"M4 6l4 4 4-4"}),chevronUp:(0,d.jsx)("path",{d:"M4 10l4-4 4 4"}),close:(0,d.jsx)("path",{d:"M4 4l8 8M12 4l-8 8"}),add:(0,d.jsx)("path",{d:"M8 3v10M3 8h10"}),newFile:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M9 2H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V6L9 2z"}),(0,d.jsx)("path",{d:"M9 2v4h4M8 8v4M6 10h4"})]}),newFolder:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M2 5.5a1 1 0 0 1 1-1h3l1.2 1.5H13a1 1 0 0 1 1 1V12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V5.5z"}),(0,d.jsx)("path",{d:"M8 8v3M6.5 9.5h3"})]}),refresh:(0,d.jsx)("path",{d:"M13 8a5 5 0 1 1-1.5-3.5M13 2.5V5h-2.5"}),collapse:(0,d.jsx)("path",{d:"M3 5h6M3 8h6M3 11h6M12 6l-1.5 1.5L12 9"}),more:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"3.5",cy:"8",r:"1"}),(0,d.jsx)("circle",{cx:"8",cy:"8",r:"1"}),(0,d.jsx)("circle",{cx:"12.5",cy:"8",r:"1"})]}),split:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1"}),(0,d.jsx)("path",{d:"M8 3v10"})]}),terminal:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,d.jsx)("path",{d:"M4.5 6.5 6.5 8l-2 1.5M8 10h3.5"})]}),panelBottom:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,d.jsx)("path",{d:"M2 10h12"})]}),sidebarIcon:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,d.jsx)("path",{d:"M6 3v10"})]}),bell:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M8 2a3.5 3.5 0 0 0-3.5 3.5c0 3-1.3 4-1.3 4h9.6s-1.3-1-1.3-4A3.5 3.5 0 0 0 8 2z"}),(0,d.jsx)("path",{d:"M6.7 12a1.4 1.4 0 0 0 2.6 0"})]}),check:(0,d.jsx)("path",{d:"M3 8.5 6.5 12 13 4"}),error:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,d.jsx)("path",{d:"M8 5v4M8 11h.01"})]}),warn:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M8 2.5 14.5 13.5h-13z"}),(0,d.jsx)("path",{d:"M8 7v3M8 12h.01"})]}),branch:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"4",cy:"4",r:"1.6"}),(0,d.jsx)("circle",{cx:"4",cy:"12",r:"1.6"}),(0,d.jsx)("circle",{cx:"12",cy:"9",r:"1.6"}),(0,d.jsx)("path",{d:"M4 5.6v4.8M5.6 4H9a1.8 1.8 0 0 1 1.8 1.8v1.6"})]}),sync:(0,d.jsx)("path",{d:"M3 6a5 5 0 0 1 8.5-2M13 10a5 5 0 0 1-8.5 2M11.5 2.5V4h-1.5M4.5 13.5V12h1.5"}),command:(0,d.jsx)("path",{d:"M5.5 3.5A1.5 1.5 0 1 1 4 5h8a1.5 1.5 0 1 1-1.5 1.5v3A1.5 1.5 0 1 1 12 11H4a1.5 1.5 0 1 1 1.5-1.5v-3z"}),goto:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M3 8h8M7.5 4.5 11 8l-3.5 3.5"}),(0,d.jsx)("path",{d:"M13 3v10"})]}),sun:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"8",cy:"8",r:"3"}),(0,d.jsx)("path",{d:"M8 1.5v1.5M8 13v1.5M14.5 8H13M3 8H1.5M12.6 3.4l-1 1M4.4 11.6l-1 1M12.6 12.6l-1-1M4.4 4.4l-1-1"})]}),moon:(0,d.jsx)("path",{d:"M13 9.2A5.5 5.5 0 0 1 6.8 3 5.5 5.5 0 1 0 13 9.2z"}),play:(0,d.jsx)("path",{d:"M5 3.5v9l7-4.5z"}),trash:(0,d.jsx)("path",{d:"M3.5 4.5h9M6 4.5V3h4v1.5M5 4.5l.5 8.5h5l.5-8.5"}),dot:(0,d.jsx)("circle",{cx:"8",cy:"8",r:"3"}),fileTs:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M9 2H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V6L9 2z"}),(0,d.jsx)("path",{d:"M9 2v4h4"})]}),arrowUp:(0,d.jsx)("path",{d:"M8 13V3M4 7l4-4 4 4"}),arrowDown:(0,d.jsx)("path",{d:"M8 3v10M4 9l4 4 4-4"}),agents:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"5.5",cy:"6",r:"2.2"}),(0,d.jsx)("circle",{cx:"11",cy:"6.5",r:"1.8"}),(0,d.jsx)("path",{d:"M2 13c0-2 1.6-3.2 3.5-3.2S9 11 9 13M9.5 12.5c.2-1.6 1.3-2.5 2.8-2.5 1.3 0 2.4.8 2.4 2.3"})]}),bot:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"3",y:"5.5",width:"10",height:"7",rx:"2"}),(0,d.jsx)("path",{d:"M8 3v2.5M5.8 9h.01M10.2 9h.01M6 12h4"}),(0,d.jsx)("circle",{cx:"8",cy:"3",r:"1"})]}),send:(0,d.jsx)("path",{d:"M14 2 7 9M14 2l-4.5 12-2.5-5L2 6.5z"}),at:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"8",cy:"8",r:"3"}),(0,d.jsx)("path",{d:"M11 8v1.2a1.8 1.8 0 0 0 3.5.6A6.5 6.5 0 1 0 11 13.2"})]}),chevronLeft:(0,d.jsx)("path",{d:"M10 4 6 8l4 4"}),dockRight:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,d.jsx)("path",{d:"M10 3v10"}),(0,d.jsx)("rect",{x:"10.5",y:"3.5",width:"3",height:"9",rx:"1",fill:"currentColor",stroke:"none",opacity:"0.25"})]}),dockLeft:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,d.jsx)("path",{d:"M6 3v10"}),(0,d.jsx)("rect",{x:"2.5",y:"3.5",width:"3",height:"9",rx:"1",fill:"currentColor",stroke:"none",opacity:"0.25"})]}),chat:(0,d.jsx)("path",{d:"M3 4.5h10a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H7l-3 2.5V11.5H3a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1z"}),grid:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"1"}),(0,d.jsx)("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"1"}),(0,d.jsx)("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"1"}),(0,d.jsx)("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"1"})]}),inbox:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M2 9h3l1 2h4l1-2h3"}),(0,d.jsx)("path",{d:"M2.5 9 4 3.5h8L13.5 9v3.5a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1z"})]}),calendar:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2.5",y:"3.5",width:"11",height:"10",rx:"1.5"}),(0,d.jsx)("path",{d:"M2.5 6.5h11M5.5 2v3M10.5 2v3"})]}),repeat:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M3 6a4 4 0 0 1 7-2.5L12 5M13 10a4 4 0 0 1-7 2.5L4 11"}),(0,d.jsx)("path",{d:"M12 2v3H9M4 14v-3h3"})]}),doc:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M9 2H4.5a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1V5.5L9 2z"}),(0,d.jsx)("path",{d:"M9 2v3.5h3.5M6 8.5h4M6 11h4"})]}),skill:(0,d.jsx)("path",{d:"M8 2.5l1.4 3.1 3.4.4-2.5 2.3.7 3.3L8 9.9 5 11.6l.7-3.3L3.2 6l3.4-.4z"}),pulse:(0,d.jsx)("path",{d:"M2 8h3l1.5-4 2.5 8 1.5-4H14"}),coins:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("ellipse",{cx:"6",cy:"4.5",rx:"3.5",ry:"1.8"}),(0,d.jsx)("path",{d:"M2.5 4.5v3c0 1 1.6 1.8 3.5 1.8s3.5-.8 3.5-1.8v-3"}),(0,d.jsx)("ellipse",{cx:"10",cy:"9.5",rx:"3.5",ry:"1.8"}),(0,d.jsx)("path",{d:"M6.5 9.5c.4.9 1.8 1.5 3.5 1.5s3.5-.8 3.5-1.8v-1.2"})]}),cpu:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1.5"}),(0,d.jsx)("rect",{x:"6.3",y:"6.3",width:"3.4",height:"3.4",rx:".5"}),(0,d.jsx)("path",{d:"M6 2v2M10 2v2M6 12v2M10 12v2M2 6h2M2 10h2M12 6h2M12 10h2"})]}),shield:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M8 2 3 4v4c0 3 2.2 5 5 6 2.8-1 5-3 5-6V4z"}),(0,d.jsx)("path",{d:"M5.8 8 7.3 9.5 10.4 6.3"})]}),target:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"8",cy:"8",r:"5.5"}),(0,d.jsx)("circle",{cx:"8",cy:"8",r:"2.4"})]}),selectParent:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2",y:"2.5",width:"12",height:"11",rx:"1.5"}),(0,d.jsx)("path",{d:"M8 11V6.5M5.5 9 8 6.5l2.5 2.5"})]})};function f({name:a,size:b=16,className:c="",strokeWidth:g=1.4,style:h}){let i=e[a];return i?(0,d.jsx)("svg",{width:b,height:b,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:g,strokeLinecap:"round",strokeLinejoin:"round",className:c,style:h,children:"play"===a||"dot"===a?(0,d.jsx)("g",{fill:"currentColor",stroke:"none",children:i}):i}):null}},4864:(a,b,c)=>{"use strict";c.d(b,{SearchHotkey:()=>e}),c(74679);var d=c(47104);function e(){return(0,d.useRouter)(),null}},5704:(a,b,c)=>{"use strict";c.d(b,{T:()=>e});var d=c(2910);let e=(0,d.createServerReference)("40249f352fbd111bf83a85129254e9e18ef8ea9d64",d.callServer,void 0,d.findSourceMapURL,"setActiveOrg")},7482:(a,b,c)=>{"use strict";c.d(b,{IL:()=>y,Jp:()=>u,TX:()=>t,bV:()=>v,bk:()=>x,q4:()=>w});var d=c(6866),e=c(73024),f=c(76760),g=c(31371),h=c(97603),i=c(65705),j=c(1890),k=c(53993),l=c(57086),m=c(56267),n=c(84903),o=c(76158),p=c(10133),q=c(93571),r=c(57300);async function s(a,b){let[c]=await i.db.select().from(j.member).where((0,h.Uo)((0,h.eq)(j.member.userId,a),(0,h.eq)(j.member.orgId,b)));return!!c}async function t(a){let b=await (0,k.Ht)();b&&await s(b.user.id,a)&&(await i.db.update(j.session).set({activeOrgId:a}).where((0,h.eq)(j.session.userId,b.user.id)),(0,g.revalidatePath)("/","layout"))}async function u(a,b){let c=await (0,k.Ht)();c&&await s(c.user.id,a)&&(await i.db.update(j.organization).set({name:b.trim()||"Organization"}).where((0,h.eq)(j.organization.id,a)),await i.db.update(j.workspace).set({name:b.trim()||"Organization"}).where((0,h.eq)(j.workspace.orgId,a)),(0,g.revalidatePath)("/organizations"))}async function v(a,b){let c=await (0,k.Ht)();c&&await s(c.user.id,a)&&(await i.db.update(j.organization).set({archived:b}).where((0,h.eq)(j.organization.id,a)),(0,g.revalidatePath)("/organizations"))}async function w(a){let b=await (0,k.Ht)();if(b&&await s(b.user.id,a)){try{let b=(0,f.join)((0,l.r$)(),"organizations",a);(0,e.existsSync)(b)&&(0,e.rmSync)(b,{recursive:!0,force:!0})}catch{}await i.db.delete(j.organization).where((0,h.eq)(j.organization.id,a)),await i.db.update(j.session).set({activeOrgId:null}).where((0,h.eq)(j.session.userId,b.user.id)),(0,g.revalidatePath)("/","layout")}}async function x(a,b){let{org:c,workspace:d}=await (0,k.nP)(),e=(d.mission??"")!==a||(d.objective??"")!==b;if(await i.db.update(j.workspace).set({mission:a,objective:b}).where((0,h.eq)(j.workspace.id,d.id)),e){try{(0,m.Lb)({orgId:c.id,slug:d.slug,company:d.name,mission:a,objective:b,stack:d.stack??{}})}catch(a){console.error("[editWorkspaceMeta] doc rerender failed:",a)}await (0,n.j)(d.id,{text:`Direction updated — objective: ${b.slice(0,160)}`,by:"operator",source:"operator-instruction"})}(0,g.revalidatePath)("/organizations"),(0,g.revalidatePath)("/","layout")}async function y(a){let{org:b,workspace:c}=await (0,k.nP)(),d={};for(let[b,c]of Object.entries(a??{}))"string"==typeof c&&c.trim()&&(d[b]=c.trim());let e=(0,p.T1)(d).stack,f=JSON.stringify(c.stack??{})!==JSON.stringify(e);if(await i.db.update(j.workspace).set({stack:e}).where((0,h.eq)(j.workspace.id,c.id)),f)try{let a=await i.db.select({id:j.agent.id,handle:j.agent.handle}).from(j.agent).where((0,h.eq)(j.agent.workspaceId,c.id)),d=Object.fromEntries(a.map(a=>[a.handle,a.id]));(0,o.fR)({orgId:b.id,wsId:c.id,names:(0,q.AQ)(e),agentIds:d,linkNames:[]}),(0,o.J$)(c.id),(0,m.Lb)({orgId:b.id,slug:c.slug,company:c.name,mission:c.mission??"",objective:c.objective??"",stack:e}),await (0,n.j)(c.id,{text:`Stack updated — ${Object.entries(e).map(([a,b])=>`${a}:${b}`).filter(a=>!a.endsWith(":None")).join(", ").slice(0,200)}`,by:"operator",source:"operator-instruction"}),(0,r.xV)(b.id).catch(()=>{})}catch(a){console.error("[setWorkspaceStack] reconcile failed:",a)}(0,g.revalidatePath)("/config"),(0,g.revalidatePath)("/","layout")}(0,c(74252).D)([t,u,v,w,x,y]),(0,d.A)(t,"40249f352fbd111bf83a85129254e9e18ef8ea9d64",null),(0,d.A)(u,"602541726f950df2e46bd648c470b35caff4290401",null),(0,d.A)(v,"605cdb117d7636ebc2c1655a5624f369a8c5530ef3",null),(0,d.A)(w,"40eca98781164e186e8b92598018c0247eee2533ed",null),(0,d.A)(x,"6043588d0686a7654ec852ff74b41a1990afb8ad5b",null),(0,d.A)(y,"404005f581c185523c57ba4de7b6e623b00422d422",null)},8556:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>g});var d=c(4374),e=c(47104),f=c(31819);function g({error:a,reset:b}){let c=(0,e.useRouter)(),h=(0,f.k)();return(0,d.jsx)("div",{style:{height:"100%",display:"grid",placeItems:"center",padding:40},children:(0,d.jsxs)("div",{style:{maxWidth:480,textAlign:"center"},children:[(0,d.jsx)("div",{style:{fontSize:16,fontWeight:800,marginBottom:8,color:"var(--text)"},children:h("errors.screenTitle")}),(0,d.jsx)("div",{style:{fontSize:13,color:"var(--text-dim)",marginBottom:14,wordBreak:"break-word"},children:a.message||h("errors.unexpected")}),a.digest&&(0,d.jsxs)("div",{style:{fontSize:11,color:"var(--text-faint)",marginBottom:16,fontFamily:"var(--mono-font, monospace)"},children:[h("errors.digest"),": ",a.digest]}),(0,d.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"center"},children:[(0,d.jsx)("button",{className:"btn-accent",onClick:()=>b(),children:h("errors.tryAgain")}),(0,d.jsx)("button",{className:"btn-ghost",onClick:()=>c.push("/"),children:h("errors.goDashboard")})]})]})})}},10245:(a,b,c)=>{"use strict";c.d(b,{CJ:()=>k,fQ:()=>i,hW:()=>j});var d=c(65705),e=c(1890),f=c(97603),g=c(55511),h=c(57086);let i=9e4;async function j(a,b,c={}){let h=new Date,i=c.ok??!0;return await d.db.insert(e.pulse).values({id:(0,g.randomUUID)(),workspaceId:a,agentId:b,at:h,ok:i,latencyMs:c.latencyMs??0,note:c.note??""}),await d.db.update(e.agent).set({lastPulse:h,health:i?"alive":"stale"}).where((0,f.eq)(e.agent.id,b)),h}async function k(a,b){let c=await d.db.query.agent.findMany({where:(0,f.eq)(e.agent.workspaceId,a)}),g=[];for(let a of c){let{intervalSec:c,maxMissed:i}=function(a,b){let c=(0,h.sL)(a,`.claude/agents/${b}/pulse.md`)??"";return{intervalSec:parseInt(c.match(/intervalSec:\s*(\d+)/)?.[1]??"30",10)||30,maxMissed:parseInt(c.match(/maxMissed:\s*(\d+)/)?.[1]??"2",10)||2}}(b,a.handle),j=c*i*1e3,k=3*j,l=function(a,b,c){if(!a)return"down";let d=Date.now()-a.getTime();return d<=b?"alive":d<=c?"stale":"down"}(a.lastPulse??null,j,k);l!==a.health&&await d.db.update(e.agent).set({health:l}).where((0,f.eq)(e.agent.id,a.id)),g.push({a,health:l})}let i=new Date().toISOString(),j=`# Agent status
1
+ exports.id=6903,exports.ids=[6903],exports.modules={387:(a,b,c)=>{"use strict";c.d(b,{O:()=>i,f:()=>j});var d=c(6866),e=c(31371),f=c(53993),g=c(56338),h=c(57300);async function i(){let{org:a}=await (0,f.nP)(),b=await (0,g.aE)(a.id);return(0,e.revalidatePath)("/knowledge"),(0,e.revalidatePath)("/reports"),b}async function j(){let{org:a}=await (0,f.nP)(),b=await (0,h.xV)(a.id);return(0,e.revalidatePath)("/knowledge"),{ok:b.ok,chunks:b.chunks}}(0,c(74252).D)([i,j]),(0,d.A)(i,"00cc51162e050f1938c1f15d597fdd4ebe929aa049",null),(0,d.A)(j,"00a15e709e3207ab4c46e487231119285bf1ecb00d",null)},437:(a,b,c)=>{"use strict";c.d(b,{Y:()=>j,g:()=>i});var d=c(97603),e=c(76760),f=c(65705),g=c(1890),h=c(57086);async function i(a,b,c,d){let i=(0,h.HZ)(b);for(let b of d){if(!b.path)continue;let d=((0,e.isAbsolute)(b.path)?(0,e.relative)(i,b.path):b.path).replace(/\\/g,"/");if(!(!d||d.startsWith(".."))&&!(d.startsWith(".claude/")||d.startsWith("archives/")||d.startsWith(".git/")))try{await f.db.insert(g.goalFile).values({workspaceId:a,goalId:c,path:d,op:b.op}).onConflictDoUpdate({target:[g.goalFile.goalId,g.goalFile.path],set:{op:b.op,at:new Date}})}catch{}}}async function j(a,b){return(await f.db.select({path:g.goalFile.path}).from(g.goalFile).where((0,d.Uo)((0,d.eq)(g.goalFile.workspaceId,a),(0,d.eq)(g.goalFile.goalId,b)))).map(a=>a.path)}},1130:(a,b,c)=>{"use strict";c.d(b,{Sidebar:()=>q});var d=c(4374),e=c(63885),f=c.n(e),g=c(47104),h=c(48442),i=c(43526),j=c(74679),k=c(93542),l=c(31819),m=c(43141);function n({orgs:a,currentId:b,workspaceSlug:c}){let e=(0,l.k)(),f=(0,g.useRouter)(),[h,o]=(0,j.useState)(!1),[p,q]=(0,j.useTransition)(),r=(0,j.useRef)(null),s=a.find(a=>a.id===b)||a[0];return(0,d.jsxs)("div",{className:"org-switch",ref:r,children:[(0,d.jsxs)("button",{className:"org-switch-btn"+(h?" open":""),disabled:p,onClick:()=>o(a=>!a),title:s?.name,children:[(0,d.jsx)(k.J,{size:34,rx:10}),(0,d.jsxs)("div",{className:"os-meta",children:[(0,d.jsx)("div",{className:"os-name",children:s?.name??"Constella"}),(0,d.jsx)("div",{className:"os-sub mono",children:c})]}),(0,d.jsx)(i.I,{name:"chevronDown",size:14})]}),h&&(0,d.jsxs)("div",{className:"org-pop",children:[(0,d.jsx)("div",{className:"org-pop-h",children:e("mod.organizations")}),a.map((a,c)=>(0,d.jsxs)("button",{className:"org-pop-item"+(a.id===b?" on":""),onClick:()=>{var c;return c=a.id,void(o(!1),c!==b&&q(async()=>{await (0,m.T)(c),window.location.href="/"}))},children:[(0,d.jsx)("span",{className:"op-badge",children:c+1}),(0,d.jsx)("span",{className:"op-name",children:a.name}),a.id===b&&(0,d.jsx)(i.I,{name:"check",size:14})]},a.id)),(0,d.jsx)("div",{className:"org-pop-sep"}),(0,d.jsxs)("button",{className:"org-pop-create",onClick:()=>{o(!1),f.push("/onboarding")},children:[(0,d.jsx)("span",{className:"opc-ic",children:(0,d.jsx)(i.I,{name:"add",size:13})})," ",e("orgs.createOrganization")]})]})]})}var o=c(2910);let p=(0,o.createServerReference)("00aa0d28cabf2459beec6d25ce8d4cc2266ca99154",o.callServer,void 0,o.findSourceMapURL,"signOutAction");function q({orgs:a,currentOrgId:b,workspaceSlug:c,userName:e,userEmail:j,userImage:k,inboxCount:m,notifCount:o}){let r=(0,g.usePathname)(),s=(0,l.k)();return(0,d.jsxs)("aside",{className:"side",children:[(0,d.jsx)("div",{className:"side-brand-wrap",children:(0,d.jsx)(n,{orgs:a,currentId:b,workspaceSlug:c})}),(0,d.jsxs)(f(),{href:"/search",className:"nav-search",children:[(0,d.jsx)(i.I,{name:"search",size:13}),(0,d.jsx)("input",{placeholder:s("nav.search"),readOnly:!0,style:{pointerEvents:"none"}})]}),(0,d.jsx)("div",{className:"side-nav scroll",children:h.E.map(a=>{let b=h.e.filter(b=>b.group===a);return b.length?(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"nav-group-label",children:s(`group.${a}`)}),b.map(a=>{let b=a=>"/"+(a.split("/")[1]??""),c="home"===a.id?"/"===r:b(r)===b(a.href),e="inbox"===a.id?m:"notifications"===a.id?o:0;return(0,d.jsxs)(f(),{href:a.href,className:"nav-item"+(c?" active":""),children:[(0,d.jsx)(i.I,{name:a.icon,size:17}),(0,d.jsx)("span",{children:s(`mod.${a.id}`)}),e?(0,d.jsx)("span",{className:"nv-badge",children:e}):null]},a.id)})]},a):null})}),(0,d.jsxs)("div",{className:"side-foot",children:[(0,d.jsx)("div",{className:"top-avatar",style:{margin:0,overflow:"hidden",padding:k?0:void 0},children:k?(0,d.jsx)("img",{src:/^(data:|https?:|\/)/.test(k)?k:`/api/upload?path=${encodeURIComponent(k)}`,alt:e,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):(e?.[0]||"O").toUpperCase()}),(0,d.jsxs)(f(),{href:"/profile",className:"pf",children:[(0,d.jsx)("div",{className:"pn",children:e||s("nav.operator")}),(0,d.jsx)("div",{className:"pe",children:j||""})]}),(0,d.jsx)("form",{action:p,children:(0,d.jsx)("button",{className:"foot-signout",title:s("nav.signout"),type:"submit",children:(0,d.jsx)(i.I,{name:"close",size:15})})})]})]})}},1262:(a,b,c)=>{"use strict";c.d(b,{L:()=>e});var d=c(2910);let e=(0,d.createServerReference)("40e5564668bafedda17fe12ac371e358864fd39c63",d.callServer,void 0,d.findSourceMapURL,"compactConversation")},1273:(a,b,c)=>{"use strict";c.d(b,{_:()=>g});let d={"gpt-4o":[2.5,10],"gpt-4o-mini":[.15,.6],"o4-mini":[1.1,4.4],"gemini-2.0-flash":[.1,.4],"gemini-1.5-pro":[1.25,5],"gemini-1.5-flash":[.075,.3]};function e(a,b,c){let e=Object.keys(d).find(b=>a.toLowerCase().startsWith(b));if(!e)return 0;let[f,g]=d[e];return b/1e6*f+c/1e6*g}function f(a,b,c,d){return{ok:!1,text:"",usd:0,inputTokens:0,outputTokens:0,durationMs:c,binary:a,model:b,error:d}}async function g(a,b,c,d){let g,h=Date.now(),i=b.baseUrl.replace(/\/$/,""),j="google"===b.provider,k=j?`${i}/models/${encodeURIComponent(b.model)}:streamGenerateContent?alt=sse&key=${encodeURIComponent(b.apiKey)}`:`${i}/chat/completions`,l={"content-type":"application/json"};!j&&b.apiKey&&(l.authorization=`Bearer ${b.apiKey}`);let m=j?{contents:[{role:"user",parts:[{text:a}]}]}:{model:b.model,messages:[{role:"user",content:a}],stream:!0,stream_options:{include_usage:!0}};try{g=await fetch(k,{method:"POST",headers:l,body:JSON.stringify(m),signal:AbortSignal.timeout(c.timeoutMs??18e4)})}catch(a){return f(b.provider,b.model,Date.now()-h,String(a instanceof Error?a.message:a))}if(!g.ok||!g.body){let a=await g.text().catch(()=>"");return f(b.provider,b.model,Date.now()-h,`http ${g.status} ${a.slice(0,200)}`)}let n=g.body.getReader(),o=new TextDecoder,p="",q="",r=0,s=0,t=0,u=()=>{q.length>r&&(d({kind:"text",detail:q.slice(r,r+8e3)}),r=q.length)};try{for(;;){let a,{value:b,done:c}=await n.read();if(c)break;for(p+=o.decode(b,{stream:!0});(a=p.indexOf("\n"))>=0;){let b=p.slice(0,a).trim();if(p=p.slice(a+1),!b.startsWith("data:"))continue;let c=b.slice(5).trim();if("[DONE]"!==c)try{let a=JSON.parse(c);if(j){let b=a.candidates?.[0]?.content?.parts?.map(a=>a.text??"").join("")??"";b&&(q+=b).length-r>=120&&u();let c=a.usageMetadata;c&&(s=c.promptTokenCount??s,t=c.candidatesTokenCount??t)}else{let b=a.choices?.[0]?.delta?.content??"";b&&(q+=b).length-r>=120&&u(),a.usage&&(s=a.usage.prompt_tokens??s,t=a.usage.completion_tokens??t)}}catch{}}}}catch(a){return u(),d({kind:"done"}),{ok:!!q,text:q,usd:e(b.model,s,t),inputTokens:s,outputTokens:t,durationMs:Date.now()-h,binary:b.provider,model:b.model,error:q?void 0:String(a instanceof Error?a.message:a)}}return u(),d({kind:"done"}),{ok:!!q.trim(),text:q,usd:e(b.model,s,t),inputTokens:s,outputTokens:t,durationMs:Date.now()-h,binary:b.provider,model:b.model,error:q.trim()?void 0:"empty response"}}},1308:(a,b,c)=>{"use strict";c.d(b,{b:()=>w});var d=c(61576),e=c(81992),f=c.n(e),g=c(79676),h=c(1782),i=c(80280),j=c(25533),k=c(95896),l=c(14565);function m({size:a=34,rx:b=9}){return(0,d.jsxs)("svg",{width:a,height:a,viewBox:"0 0 100 100",style:{display:"block",flex:`0 0 ${a}px`},"aria-label":"Constella",children:[(0,d.jsx)("rect",{x:"1",y:"1",width:"98",height:"98",rx:b,fill:"var(--cs-bg)",stroke:"var(--cs-border)",strokeWidth:"1.5"}),(0,d.jsx)("path",{d:"M66.06 27.06 L42.75 22.95 L24.62 38.17 L24.62 61.83 L42.75 77.05 L66.06 72.94",fill:"none",stroke:"var(--cs-line)",strokeWidth:"2.1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,d.jsx)("path",{d:"M48 50 L42.75 22.95 M48 50 L24.62 50 M48 50 L42.75 77.05",fill:"none",stroke:"var(--cs-line)",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.55"}),[[66.06,27.06],[42.75,22.95],[24.62,38.17],[24.62,61.83],[42.75,77.05],[66.06,72.94]].map((a,b)=>(0,d.jsx)("circle",{cx:a[0],cy:a[1],r:"3.1",fill:"var(--cs-node)"},b)),(0,d.jsx)("circle",{cx:"48",cy:"50",r:"8.5",fill:"var(--cs-glow)",opacity:"0.4"}),(0,d.jsx)("circle",{cx:"48",cy:"50",r:"4.3",fill:"var(--cs-core)"})]})}var n=c(2756),o=c(67686),p=c(32825),q=c(29876),r=c(15783),s=c(16120),t=c(42328),u=c(83836),v=c(75785);async function w({title:a}){let b=await (0,g.cookies)(),c=b.get("cn-theme")?.value==="dark"?"dark":"light",e=(0,v.e)(b.get("cn-lang")?.value),{workspace:x}=await (0,k.nP)(),y=(await i.db.select().from(j.notification).where((0,h.Uo)((0,h.eq)(j.notification.workspaceId,x.id),(0,h.eq)(j.notification.read,!1)))).length,z=u.e.find(b=>b.title===a);return(0,d.jsxs)("div",{className:"app-top",children:[(0,d.jsx)(s.SidebarToggle,{}),(0,d.jsx)(r.BackButton,{}),(0,d.jsxs)("div",{className:"app-crumb",children:[(0,d.jsxs)(f(),{href:"/",style:{display:"inline-flex",alignItems:"center",gap:7,textDecoration:"none",color:"inherit"},children:[(0,d.jsx)(m,{size:16,rx:5})," Constella"]}),(0,d.jsx)(n.I,{name:"chevronRight",size:12,style:{opacity:.4}}),(0,d.jsxs)("b",{style:{display:"inline-flex",alignItems:"center",gap:7},children:[(0,d.jsx)(n.I,{name:z?z.icon:"grid",size:14,style:{color:"var(--accent)"}})," ",z?(0,v.t)(e,`mod.${z.id}`):a]})]}),(0,d.jsxs)("div",{className:"app-top-actions",children:[(0,d.jsx)(t.UpdateHeaderBadge,{}),(0,d.jsx)(f(),{href:"/search",className:"top-btn",title:(0,v.t)(e,"nav.search"),children:(0,d.jsx)(n.I,{name:"search",size:17})}),(0,d.jsxs)(f(),{href:"/notifications",className:"top-btn",title:(0,v.t)(e,"top.notifications"),style:{position:"relative"},children:[(0,d.jsx)(n.I,{name:"bell",size:17}),y>0&&(0,d.jsx)("span",{className:"nv-badge",children:y})]}),(0,d.jsx)(o.ChatToggle,{}),(0,d.jsx)(q.LangSwitch,{}),(0,d.jsx)(p.AnimToggle,{}),(0,d.jsx)("form",{action:l.OD.bind(null,c),children:(0,d.jsx)("button",{className:"top-btn",title:(0,v.t)(e,"top.theme"),type:"submit",children:(0,d.jsx)(n.I,{name:"dark"===c?"sun":"moon",size:17})})})]})]})}},1662:(a,b,c)=>{"use strict";c.d(b,{V:()=>e});var d=c(2910);let e=(0,d.createServerReference)("408bdae443a0482c1bfbd42dc2b720e682b1423fab",d.callServer,void 0,d.findSourceMapURL,"getMessages")},2756:(a,b,c)=>{"use strict";c.d(b,{I:()=>f});var d=c(61576);let e={files:(0,d.jsx)("path",{d:"M3 3.5h5l1.5 2H13a1 1 0 0 1 1 1V12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4.5a1 1 0 0 1 1-1z"}),search:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"7",cy:"7",r:"4.2"}),(0,d.jsx)("path",{d:"M10.2 10.2 14 14"})]}),git:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"4",cy:"4",r:"1.8"}),(0,d.jsx)("circle",{cx:"4",cy:"12",r:"1.8"}),(0,d.jsx)("circle",{cx:"12",cy:"9.5",r:"1.8"}),(0,d.jsx)("path",{d:"M4 5.8v4.4M5.8 4H9a2 2 0 0 1 2 2v1.6"})]}),debug:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"8",cy:"8.5",r:"3.5"}),(0,d.jsx)("path",{d:"M8 5V3M4.5 8.5H2m12 0h-2.5M4.8 11.8 3.4 13M11.2 11.8l1.4 1.2M5.2 5 3.8 3.6M10.8 5l1.4-1.4"})]}),ext:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"1"}),(0,d.jsx)("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"1"}),(0,d.jsx)("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"1"}),(0,d.jsx)("path",{d:"M9 11.2h4.5M11.2 9v4.5"})]}),settings:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"8",cy:"8",r:"2.2"}),(0,d.jsx)("path",{d:"M8 1.5v2M8 12.5v2M14.5 8h-2M3.5 8h-2M12.6 3.4l-1.4 1.4M4.8 11.2l-1.4 1.4M12.6 12.6l-1.4-1.4M4.8 4.8 3.4 3.4"})]}),account:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"8",cy:"5.5",r:"2.8"}),(0,d.jsx)("path",{d:"M2.8 14c0-2.8 2.3-4.5 5.2-4.5s5.2 1.7 5.2 4.5"})]}),chevronRight:(0,d.jsx)("path",{d:"M6 4l4 4-4 4"}),chevronDown:(0,d.jsx)("path",{d:"M4 6l4 4 4-4"}),chevronUp:(0,d.jsx)("path",{d:"M4 10l4-4 4 4"}),close:(0,d.jsx)("path",{d:"M4 4l8 8M12 4l-8 8"}),add:(0,d.jsx)("path",{d:"M8 3v10M3 8h10"}),newFile:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M9 2H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V6L9 2z"}),(0,d.jsx)("path",{d:"M9 2v4h4M8 8v4M6 10h4"})]}),newFolder:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M2 5.5a1 1 0 0 1 1-1h3l1.2 1.5H13a1 1 0 0 1 1 1V12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V5.5z"}),(0,d.jsx)("path",{d:"M8 8v3M6.5 9.5h3"})]}),refresh:(0,d.jsx)("path",{d:"M13 8a5 5 0 1 1-1.5-3.5M13 2.5V5h-2.5"}),collapse:(0,d.jsx)("path",{d:"M3 5h6M3 8h6M3 11h6M12 6l-1.5 1.5L12 9"}),more:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"3.5",cy:"8",r:"1"}),(0,d.jsx)("circle",{cx:"8",cy:"8",r:"1"}),(0,d.jsx)("circle",{cx:"12.5",cy:"8",r:"1"})]}),split:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1"}),(0,d.jsx)("path",{d:"M8 3v10"})]}),terminal:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,d.jsx)("path",{d:"M4.5 6.5 6.5 8l-2 1.5M8 10h3.5"})]}),panelBottom:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,d.jsx)("path",{d:"M2 10h12"})]}),sidebarIcon:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,d.jsx)("path",{d:"M6 3v10"})]}),bell:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M8 2a3.5 3.5 0 0 0-3.5 3.5c0 3-1.3 4-1.3 4h9.6s-1.3-1-1.3-4A3.5 3.5 0 0 0 8 2z"}),(0,d.jsx)("path",{d:"M6.7 12a1.4 1.4 0 0 0 2.6 0"})]}),check:(0,d.jsx)("path",{d:"M3 8.5 6.5 12 13 4"}),error:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,d.jsx)("path",{d:"M8 5v4M8 11h.01"})]}),warn:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M8 2.5 14.5 13.5h-13z"}),(0,d.jsx)("path",{d:"M8 7v3M8 12h.01"})]}),branch:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"4",cy:"4",r:"1.6"}),(0,d.jsx)("circle",{cx:"4",cy:"12",r:"1.6"}),(0,d.jsx)("circle",{cx:"12",cy:"9",r:"1.6"}),(0,d.jsx)("path",{d:"M4 5.6v4.8M5.6 4H9a1.8 1.8 0 0 1 1.8 1.8v1.6"})]}),sync:(0,d.jsx)("path",{d:"M3 6a5 5 0 0 1 8.5-2M13 10a5 5 0 0 1-8.5 2M11.5 2.5V4h-1.5M4.5 13.5V12h1.5"}),command:(0,d.jsx)("path",{d:"M5.5 3.5A1.5 1.5 0 1 1 4 5h8a1.5 1.5 0 1 1-1.5 1.5v3A1.5 1.5 0 1 1 12 11H4a1.5 1.5 0 1 1 1.5-1.5v-3z"}),goto:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M3 8h8M7.5 4.5 11 8l-3.5 3.5"}),(0,d.jsx)("path",{d:"M13 3v10"})]}),sun:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"8",cy:"8",r:"3"}),(0,d.jsx)("path",{d:"M8 1.5v1.5M8 13v1.5M14.5 8H13M3 8H1.5M12.6 3.4l-1 1M4.4 11.6l-1 1M12.6 12.6l-1-1M4.4 4.4l-1-1"})]}),moon:(0,d.jsx)("path",{d:"M13 9.2A5.5 5.5 0 0 1 6.8 3 5.5 5.5 0 1 0 13 9.2z"}),play:(0,d.jsx)("path",{d:"M5 3.5v9l7-4.5z"}),trash:(0,d.jsx)("path",{d:"M3.5 4.5h9M6 4.5V3h4v1.5M5 4.5l.5 8.5h5l.5-8.5"}),dot:(0,d.jsx)("circle",{cx:"8",cy:"8",r:"3"}),fileTs:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M9 2H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V6L9 2z"}),(0,d.jsx)("path",{d:"M9 2v4h4"})]}),arrowUp:(0,d.jsx)("path",{d:"M8 13V3M4 7l4-4 4 4"}),arrowDown:(0,d.jsx)("path",{d:"M8 3v10M4 9l4 4 4-4"}),agents:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"5.5",cy:"6",r:"2.2"}),(0,d.jsx)("circle",{cx:"11",cy:"6.5",r:"1.8"}),(0,d.jsx)("path",{d:"M2 13c0-2 1.6-3.2 3.5-3.2S9 11 9 13M9.5 12.5c.2-1.6 1.3-2.5 2.8-2.5 1.3 0 2.4.8 2.4 2.3"})]}),bot:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"3",y:"5.5",width:"10",height:"7",rx:"2"}),(0,d.jsx)("path",{d:"M8 3v2.5M5.8 9h.01M10.2 9h.01M6 12h4"}),(0,d.jsx)("circle",{cx:"8",cy:"3",r:"1"})]}),send:(0,d.jsx)("path",{d:"M14 2 7 9M14 2l-4.5 12-2.5-5L2 6.5z"}),at:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"8",cy:"8",r:"3"}),(0,d.jsx)("path",{d:"M11 8v1.2a1.8 1.8 0 0 0 3.5.6A6.5 6.5 0 1 0 11 13.2"})]}),chevronLeft:(0,d.jsx)("path",{d:"M10 4 6 8l4 4"}),dockRight:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,d.jsx)("path",{d:"M10 3v10"}),(0,d.jsx)("rect",{x:"10.5",y:"3.5",width:"3",height:"9",rx:"1",fill:"currentColor",stroke:"none",opacity:"0.25"})]}),dockLeft:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,d.jsx)("path",{d:"M6 3v10"}),(0,d.jsx)("rect",{x:"2.5",y:"3.5",width:"3",height:"9",rx:"1",fill:"currentColor",stroke:"none",opacity:"0.25"})]}),chat:(0,d.jsx)("path",{d:"M3 4.5h10a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H7l-3 2.5V11.5H3a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1z"}),grid:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"1"}),(0,d.jsx)("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"1"}),(0,d.jsx)("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"1"}),(0,d.jsx)("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"1"})]}),inbox:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M2 9h3l1 2h4l1-2h3"}),(0,d.jsx)("path",{d:"M2.5 9 4 3.5h8L13.5 9v3.5a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1z"})]}),calendar:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2.5",y:"3.5",width:"11",height:"10",rx:"1.5"}),(0,d.jsx)("path",{d:"M2.5 6.5h11M5.5 2v3M10.5 2v3"})]}),repeat:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M3 6a4 4 0 0 1 7-2.5L12 5M13 10a4 4 0 0 1-7 2.5L4 11"}),(0,d.jsx)("path",{d:"M12 2v3H9M4 14v-3h3"})]}),doc:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M9 2H4.5a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1V5.5L9 2z"}),(0,d.jsx)("path",{d:"M9 2v3.5h3.5M6 8.5h4M6 11h4"})]}),skill:(0,d.jsx)("path",{d:"M8 2.5l1.4 3.1 3.4.4-2.5 2.3.7 3.3L8 9.9 5 11.6l.7-3.3L3.2 6l3.4-.4z"}),pulse:(0,d.jsx)("path",{d:"M2 8h3l1.5-4 2.5 8 1.5-4H14"}),coins:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("ellipse",{cx:"6",cy:"4.5",rx:"3.5",ry:"1.8"}),(0,d.jsx)("path",{d:"M2.5 4.5v3c0 1 1.6 1.8 3.5 1.8s3.5-.8 3.5-1.8v-3"}),(0,d.jsx)("ellipse",{cx:"10",cy:"9.5",rx:"3.5",ry:"1.8"}),(0,d.jsx)("path",{d:"M6.5 9.5c.4.9 1.8 1.5 3.5 1.5s3.5-.8 3.5-1.8v-1.2"})]}),cpu:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1.5"}),(0,d.jsx)("rect",{x:"6.3",y:"6.3",width:"3.4",height:"3.4",rx:".5"}),(0,d.jsx)("path",{d:"M6 2v2M10 2v2M6 12v2M10 12v2M2 6h2M2 10h2M12 6h2M12 10h2"})]}),shield:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("path",{d:"M8 2 3 4v4c0 3 2.2 5 5 6 2.8-1 5-3 5-6V4z"}),(0,d.jsx)("path",{d:"M5.8 8 7.3 9.5 10.4 6.3"})]}),target:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("circle",{cx:"8",cy:"8",r:"5.5"}),(0,d.jsx)("circle",{cx:"8",cy:"8",r:"2.4"})]}),selectParent:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("rect",{x:"2",y:"2.5",width:"12",height:"11",rx:"1.5"}),(0,d.jsx)("path",{d:"M8 11V6.5M5.5 9 8 6.5l2.5 2.5"})]})};function f({name:a,size:b=16,className:c="",strokeWidth:g=1.4,style:h}){let i=e[a];return i?(0,d.jsx)("svg",{width:b,height:b,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:g,strokeLinecap:"round",strokeLinejoin:"round",className:c,style:h,children:"play"===a||"dot"===a?(0,d.jsx)("g",{fill:"currentColor",stroke:"none",children:i}):i}):null}},4864:(a,b,c)=>{"use strict";c.d(b,{SearchHotkey:()=>e}),c(74679);var d=c(47104);function e(){return(0,d.useRouter)(),null}},5152:(a,b,c)=>{"use strict";c.d(b,{M:()=>e});var d=c(2910);let e=(0,d.createServerReference)("70134ed93c744753cbd112c32720864d9c20816aac",d.callServer,void 0,d.findSourceMapURL,"connectTelegram")},6857:(a,b,c)=>{"use strict";c.d(b,{V4:()=>x,H8:()=>F,qs:()=>t});var d=c(4374),e=c(74679),f=c(47104),g=c(89814),h=c(77954),i=c(14698),j=c(43526),k=c(31819),l=c(2910);let m=(0,l.createServerReference)("40fb601e332b01b2db0128c9248448e91ee1e8823a",l.callServer,void 0,l.findSourceMapURL,"pullKbForComposer"),n=(0,l.createServerReference)("40bdecbf659bb86c86705318c2779dca409a75fc6a",l.callServer,void 0,l.findSourceMapURL,"sendMessageToKb");l.callServer,l.findSourceMapURL;var o=c(92663),p=c(86004);let q={read:"Read",create:"Create",edit:"Edit",run:"Run",search:"Search"},r=[{cmd:"/help",descKey:"help"},{cmd:"/kb",descKey:"kb",arg:"<question>"},{cmd:"/search",descKey:"search",arg:"<query>"},{cmd:"/graph",descKey:"graph",arg:"<key>"},{cmd:"/status",descKey:"status"},{cmd:"/agents",descKey:"agents"},{cmd:"/agent",descKey:"agent",arg:"<handle>"},{cmd:"/new-goal",descKey:"newGoal",arg:"<brief>"},{cmd:"/new-issue",descKey:"newIssue",arg:"<title>"},{cmd:"/new-spec",descKey:"newSpec",arg:"<title>"},{cmd:"/generate-plan",descKey:"generatePlan",arg:"<brief>"},{cmd:"/approve",descKey:"approve"},{cmd:"/reject",descKey:"reject",arg:"<reason>"},{cmd:"/run-247",descKey:"run247"},{cmd:"/pause",descKey:"pause"},{cmd:"/cancel",descKey:"cancel"},{cmd:"/archive",descKey:"archive"},{cmd:"/assign",descKey:"assign",arg:"<issue> <@agent>"},{cmd:"/review",descKey:"review"},{cmd:"/close-sprint",descKey:"closeSprint"},{cmd:"/test-dev",descKey:"testDev"},{cmd:"/github",descKey:"github"},{cmd:"/prepare-deploy",descKey:"prepareDeploy"},{cmd:"/export-source",descKey:"exportSource",arg:"<repo>"},{cmd:"/models",descKey:"models"},{cmd:"/skills",descKey:"skills"},{cmd:"/locks",descKey:"locks"},{cmd:"/telegram",descKey:"telegram"},{cmd:"/reindex",descKey:"reindex"},{cmd:"/curate",descKey:"curate"},{cmd:"/clear",descKey:"clear"}],s={idle:{c:"#6b7390",bg:"rgba(120,130,160,.16)"},working:{c:"#b3d97a",bg:"rgba(179,217,122,.15)"},review:{c:"#e0a44e",bg:"rgba(224,164,78,.16)"},blocked:{c:"#e8688f",bg:"rgba(232,104,143,.16)"}};function t({status:a}){let b=(0,k.k)(),c=s[a]??s.idle;return(0,d.jsx)("span",{className:"status-pill",style:{color:c.c,background:c.bg},children:a in s?b("chat.status."+a):a})}function u(a,b,c){let e=c?Object.fromEntries(c.map(a=>[a.key.toLowerCase(),a])):{},f=c&&c.length>0;return a.split(f?/(@[a-z0-9-]+|#[a-z0-9_-]+)/gi:/(@[a-z0-9-]+)/gi).map((a,c)=>{if(/^@[a-z0-9-]+$/i.test(a)&&b.has(a.slice(1).toLowerCase()))return(0,d.jsx)("span",{className:"mention",children:a},c);if(f&&/^#[a-z0-9_-]+$/i.test(a)){let b=e[a.slice(1).toLowerCase()];if(b){let e="goal"===b.kind?"/goals":"spec"===b.kind?"/planner":"/pm";return(0,d.jsx)("a",{className:"ref-chip",href:e,title:b.title,children:a},c)}}return(0,d.jsx)("span",{children:a},c)})}function v({step:a}){let b,c,e=(0,k.k)(),f=a.kind in q?e("chat.verb."+a.kind):a.kind,g="run"===a.kind,h="edit"===a.kind&&!!a.detail,i="create"===a.kind&&!!a.detail,j=h?a.detail.split("\n"):[],l=h?j.filter(a=>a.startsWith("+")).length:0,m=h?j.filter(a=>a.startsWith("-")).length:0,n=i?a.detail.slice(0,4e3).split("\n"):[];return(0,d.jsxs)("div",{className:"work-step",children:[(0,d.jsxs)("div",{className:"wstep-head",children:[(0,d.jsx)("span",{className:"wstep-verb "+a.kind,children:f}),(0,d.jsx)("span",{className:"wstep-file",children:a.target}),h&&(0,d.jsxs)("span",{className:"wstep-badge",children:[(0,d.jsxs)("span",{className:"plus",children:["+",l]})," ",(0,d.jsxs)("span",{className:"minus",children:["−",m]})]}),i&&(0,d.jsx)("span",{className:"wstep-badge",children:(0,d.jsxs)("span",{className:"plus",children:["+",n.length]})})]}),i&&(0,d.jsx)("div",{className:"wstep-code scroll",children:n.map((a,b)=>(0,d.jsxs)("div",{className:"wcode-line",children:[(0,d.jsx)("span",{className:"wcode-gutter",children:b+1}),(0,d.jsx)("span",{className:"wcode-text",children:a||"​"})]},b))}),h&&(0,d.jsx)("div",{className:"wstep-code scroll",children:j.map((a,b)=>{let c=a.startsWith("+")?"add":a.startsWith("-")?"del":"ctx";return(0,d.jsxs)("div",{className:"wdiff-line "+c,children:[(0,d.jsx)("span",{className:"wdiff-sign",children:"add"===c?"+":"del"===c?"−":" "}),(0,d.jsx)("span",{className:"wdiff-text",children:a.slice(1)||"​"})]},b)})}),g&&a.detail&&(c=(b=a.detail.split("\n")).slice(0,14),(0,d.jsxs)("div",{className:"wstep-term",children:[c.map((a,b)=>(0,d.jsx)("div",{className:/✓|passed|ok\b/i.test(a)?"ok":"",children:a||"​"},b)),b.length>c.length&&(0,d.jsxs)("div",{className:"wstep-more",children:["… +",b.length-c.length," lines"]})]}))]})}function w({steps:a,live:b}){let c=(0,k.k)(),f=a.filter(a=>["read","create","edit","run","search"].includes(a.kind)),g=f.filter(a=>"create"===a.kind||"edit"===a.kind).length,h=[...a].reverse().find(a=>"thinking"===a.kind),i=!b,[l,m]=(0,e.useState)(b);return 0!==f.length||h?(0,d.jsxs)("div",{className:"work-block"+(l?"":" collapsed"),children:[(0,d.jsxs)("button",{type:"button",className:"work-head",onClick:()=>m(a=>!a),children:[i?(0,d.jsx)("span",{className:"done-check",children:(0,d.jsx)(j.I,{name:"check",size:15})}):(0,d.jsx)("span",{className:"spin",children:(0,d.jsx)(j.I,{name:"refresh",size:14})}),(0,d.jsx)("span",{className:"wlabel",children:c(i?"chat.work.done":"chat.work.working")}),(0,d.jsx)("span",{className:"wmeta",children:i?c(1===f.length?"chat.work.actions.one":"chat.work.actions.other",{n:f.length}):c("chat.work.workingEllipsis")}),i&&g>0&&(0,d.jsxs)("span",{className:"wmeta wfiles",title:"files changed",children:["✎ ",g]}),(0,d.jsx)("span",{className:"work-toggle"+(l?" open":""),children:(0,d.jsx)(j.I,{name:"chevronRight",size:13})})]}),l&&(0,d.jsxs)(d.Fragment,{children:[h?.detail&&(0,d.jsxs)("div",{className:"work-thinking",children:[(0,d.jsx)("span",{className:"ti",children:(0,d.jsx)(j.I,{name:"bot",size:13})}),(0,d.jsx)("span",{children:h.detail})]}),(0,d.jsx)("div",{className:"work-steps",children:f.map(a=>(0,d.jsx)(v,{step:a},a.id))})]})]}):null}function x({onSend:a,placeholder:b,agents:c,defaultText:f="",requireMention:g=!1,enableAttachments:h=!0,refs:l}){let[n,o]=(0,e.useState)(f),p=(0,k.k)(),q=!g||n.trim().startsWith("/")||(n.match(/@([a-z0-9-]+)/gi)||[]).some(a=>c.some(b=>b.handle.toLowerCase()===a.slice(1).toLowerCase())),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(null),[w,y]=(0,e.useState)(null),[z,A]=(0,e.useState)(null),[B,C]=(0,e.useState)([]),[D,E]=(0,e.useState)(""),[F,G]=(0,e.useState)(!1),[H,I]=(0,e.useState)(!1),[J,K]=(0,e.useState)(""),[L,M]=(0,e.useState)(null),[N,O]=(0,e.useState)(""),[P,Q]=(0,e.useTransition)(),R=(0,e.useRef)(null),S=(0,e.useRef)(null),T=(0,e.useRef)(null),U=void 0!==l;async function V(a){if(!a||!a.length)return;E("");let b=10-B.length,c=Array.from(a).slice(0,Math.max(0,b));if(!c.length)return void E(p("chat.composer.maxAttachments"));let d=new FormData;for(let a of c)d.append("files",a);G(!0);try{let a=await fetch("/api/upload",{method:"POST",body:d}),b=await a.json();if(!a.ok||!b.ok)return void E(b.error??p("chat.composer.uploadFailed"));C(a=>[...a,...b.attachments].slice(0,10))}catch{E(p("chat.composer.uploadFailed"))}finally{G(!1),S.current&&(S.current.value="")}}function W(a){a.style.height="auto",a.style.height=Math.min(a.scrollHeight,260)+"px"}function X(a){if(!u||!R.current)return;let b=n.slice(0,u.start),c=n.slice(R.current.selectionStart),d="@"+a.handle+" ";o(b+d+c),T.current=(b+d).length,v(null),requestAnimationFrame(()=>R.current?.focus())}function Y(a){if(!w||!R.current)return;let b=n.slice(0,w.start),c=n.slice(R.current.selectionStart),d="#"+a.key+" ";o(b+d+c),T.current=(b+d).length,y(null),requestAnimationFrame(()=>R.current?.focus())}function Z(a){let b=a.cmd+(a.arg?" ":"");o(b),T.current=b.length,A(null),requestAnimationFrame(()=>R.current?.focus())}function $(){let a=J.trim();if(!a){M(null),O(p("chat.kbPull.empty"));return}O(""),M(null),Q(async()=>{let b=await m(a);b.ok&&b.text?M({text:b.text,sources:b.sources??[]}):O(p("chat.kbPull.noResult"))})}function _(){let b=n.trim();!b&&0===B.length||q&&(a(b,B.length?B:void 0),o(""),C([]),E(""),R.current&&(R.current.style.height="auto"),v(null),A(null),y(null),I(!1))}return(0,d.jsxs)("div",{className:"chat-composer",children:[u&&(0,d.jsxs)("div",{className:"mention-pop",children:[(0,d.jsxs)("div",{className:"mention-head",children:[(0,d.jsx)(j.I,{name:"at",size:12})," ",p("chat.composer.mentionAgent")]}),(0,d.jsxs)("div",{className:"mention-list scroll",children:[0===u.items.length&&(0,d.jsx)("div",{className:"mention-empty",children:p("chat.noAgentMatch",{q:u.query})}),u.items.map((a,b)=>(0,d.jsxs)("div",{className:"mention-item"+(b===u.index?" active":""),onMouseEnter:()=>v(a=>a&&{...a,index:b}),onMouseDown:b=>{b.preventDefault(),X(a)},children:[(0,d.jsx)(i.e,{name:a.name,color:a.color,image:a.image,size:24}),(0,d.jsx)("div",{className:"mi-text",children:(0,d.jsxs)("div",{className:"mi-name",children:[a.name," ",(0,d.jsxs)("span",{className:"mi-handle",children:["@",a.handle]})]})}),(0,d.jsx)("span",{className:"mi-role",children:a.role})]},a.handle))]})]}),w&&(0,d.jsxs)("div",{className:"mention-pop",children:[(0,d.jsxs)("div",{className:"mention-head",children:[(0,d.jsx)(j.I,{name:"branch",size:12})," ",p("chat.composer.referenceItem")]}),(0,d.jsxs)("div",{className:"mention-list scroll",children:[0===w.items.length&&(0,d.jsx)("div",{className:"mention-empty",children:p("chat.noRefMatch",{q:w.query})}),w.items.map((a,b)=>(0,d.jsxs)("div",{className:"mention-item"+(b===w.index?" active":""),onMouseEnter:()=>y(a=>a&&{...a,index:b}),onMouseDown:b=>{b.preventDefault(),Y(a)},children:[(0,d.jsx)("span",{className:"mi-ref-kind",children:p("chat.composer.refKind."+a.kind)}),(0,d.jsx)("div",{className:"mi-text",children:(0,d.jsxs)("div",{className:"mi-name",children:[(0,d.jsxs)("span",{className:"mi-handle",children:["#",a.key]})," ",a.title]})})]},a.id))]})]}),z&&(0,d.jsxs)("div",{className:"mention-pop",children:[(0,d.jsxs)("div",{className:"mention-head",children:[(0,d.jsx)(j.I,{name:"command",size:12})," ",p("chat.commands")]}),(0,d.jsx)("div",{className:"mention-list scroll",children:z.items.map((a,b)=>(0,d.jsxs)("div",{className:"mention-item"+(b===z.index?" active":""),onMouseEnter:()=>A(a=>a&&{...a,index:b}),onMouseDown:b=>{b.preventDefault(),Z(a)},children:[(0,d.jsx)("div",{className:"mi-text",children:(0,d.jsxs)("div",{className:"mi-name",children:[a.cmd,a.arg&&(0,d.jsxs)("span",{className:"mi-handle",children:[" ",a.arg]})]})}),(0,d.jsx)("span",{className:"mi-role",children:p("chat.slash."+a.descKey)})]},a.cmd))})]}),H&&(0,d.jsxs)("div",{className:"mention-pop kb-pull-pop",children:[(0,d.jsxs)("div",{className:"mention-head",children:[(0,d.jsx)(j.I,{name:"branch",size:12})," ",p("chat.kbPull.title")]}),(0,d.jsxs)("div",{className:"kb-pull-body",children:[(0,d.jsxs)("div",{className:"kb-pull-row",children:[(0,d.jsx)("input",{className:"kb-pull-input",value:J,placeholder:p("chat.kbPull.placeholder"),onChange:a=>{K(a.target.value),O("")},onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),$()),"Escape"===a.key&&(a.preventDefault(),I(!1))}}),(0,d.jsxs)("button",{type:"button",className:"att-btn",disabled:P,onMouseDown:a=>a.preventDefault(),onClick:$,children:[P?(0,d.jsx)("span",{className:"spin",children:(0,d.jsx)(j.I,{name:"refresh",size:13})}):(0,d.jsx)(j.I,{name:"search",size:13}),p("chat.kbPull.search")]})]}),(0,d.jsx)("div",{className:"kb-pull-preview",children:P?(0,d.jsx)("div",{className:"kb-pull-muted",children:p("chat.kbPull.searching")}):L?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"kb-pull-text",children:L.text}),L.sources.length>0&&(0,d.jsx)("div",{className:"kb-pull-sources",children:L.sources.map(a=>(0,d.jsx)("span",{children:a},a))})]}):(0,d.jsx)("div",{className:N?"kb-pull-error":"kb-pull-muted",children:N||p("chat.kbPull.empty")})}),L&&(0,d.jsx)("div",{className:"kb-pull-actions",children:(0,d.jsxs)("button",{type:"button",className:"send-btn",onMouseDown:a=>a.preventDefault(),onClick:function(){if(!L)return;let a=L.sources.length?`
2
+ Sources: ${L.sources.join(", ")}`:"",b=`KB: ${L.text}${a}`;o(a=>a.trim()?`${a.trimEnd()}
3
+
4
+ ${b}`:b),I(!1),M(null),O(""),requestAnimationFrame(()=>{R.current&&(W(R.current),R.current.focus())})},children:[(0,d.jsx)(j.I,{name:"add",size:13})," ",p("chat.kbPull.insert")]})})]})]}),(0,d.jsxs)("div",{className:"composer-box"+(s?" focus":""),children:[B.length>0&&(0,d.jsx)("div",{className:"att-row",children:B.map((a,b)=>(0,d.jsxs)("span",{className:"att-chip",children:[(0,d.jsx)(j.I,{name:/^image\//.test(a.type)||"application/pdf"===a.type?"doc":"files",size:11}),(0,d.jsx)("span",{className:"att-name",children:a.name}),(0,d.jsx)("button",{className:"att-x",onClick:()=>C(a=>a.filter((a,c)=>c!==b)),children:(0,d.jsx)(j.I,{name:"close",size:10})})]},a.path))}),D&&(0,d.jsx)("div",{style:{fontSize:10.5,color:"#e8688f",padding:"2px 8px"},children:D}),(0,d.jsx)("textarea",{ref:R,className:"composer-input",value:n,rows:1,placeholder:b,onChange:a=>{o(a.target.value),function(a,b){let d=a.match(/^\/([a-z-]*)$/i);if(d){let a=d[1].toLowerCase(),b=r.filter(b=>b.cmd.slice(1).startsWith(a));v(null),y(null),A(b.length?{items:b,index:0}:null);return}A(null);let e=a.slice(0,b).match(/#([a-z0-9_-]*)$/i);if(e&&l&&l.length>0){let a=e[1].toLowerCase(),c=l.filter(b=>b.key.toLowerCase().includes(a)||b.title.toLowerCase().includes(a));v(null),y({query:a,start:b-e[0].length,items:c,index:0});return}y(null);let f=a.slice(0,b).match(/@([a-z0-9-]*)$/i);if(!f)return v(null);let g=f[1].toLowerCase(),h=c.filter(a=>a.handle.includes(g)||a.name.toLowerCase().includes(g)||a.role.toLowerCase().includes(g));v({query:g,start:b-f[0].length,items:h,index:0})}(a.target.value,a.target.selectionStart),W(a.target)},onKeyDown:function(a){if(z&&z.items.length){if("ArrowDown"===a.key){a.preventDefault(),A(a=>a&&{...a,index:(a.index+1)%a.items.length});return}if("ArrowUp"===a.key){a.preventDefault(),A(a=>a&&{...a,index:(a.index-1+a.items.length)%a.items.length});return}if("Enter"===a.key||"Tab"===a.key){a.preventDefault(),Z(z.items[z.index]);return}if("Escape"===a.key){a.preventDefault(),A(null);return}}if(w&&w.items.length){if("ArrowDown"===a.key){a.preventDefault(),y(a=>a&&{...a,index:(a.index+1)%a.items.length});return}if("ArrowUp"===a.key){a.preventDefault(),y(a=>a&&{...a,index:(a.index-1+a.items.length)%a.items.length});return}if("Enter"===a.key||"Tab"===a.key){a.preventDefault(),Y(w.items[w.index]);return}if("Escape"===a.key){a.preventDefault(),y(null);return}}if(u&&u.items.length){if("ArrowDown"===a.key){a.preventDefault(),v(a=>a&&{...a,index:(a.index+1)%a.items.length});return}if("ArrowUp"===a.key){a.preventDefault(),v(a=>a&&{...a,index:(a.index-1+a.items.length)%a.items.length});return}if("Enter"===a.key||"Tab"===a.key){a.preventDefault(),X(u.items[u.index]);return}if("Escape"===a.key){a.preventDefault(),v(null);return}}if("Escape"===a.key&&H){a.preventDefault(),I(!1);return}"Enter"!==a.key||a.shiftKey||(a.preventDefault(),_())},onFocus:()=>t(!0),onBlur:()=>t(!1)}),h&&(0,d.jsx)("input",{ref:S,type:"file",multiple:!0,hidden:!0,accept:".png,.jpg,.jpeg,.gif,.webp,.bmp,.pdf,.txt,.md,.csv,.json,.log,.zip,.doc,.docx,.xls,.xlsx,.ppt,.pptx",onChange:a=>V(a.target.files)}),(0,d.jsxs)("div",{className:"composer-foot",children:[(0,d.jsxs)("span",{className:"composer-actions",children:[h&&(0,d.jsxs)("button",{type:"button",className:"att-btn",title:p("chat.composer.attachTitle"),disabled:F||B.length>=10,onClick:()=>S.current?.click(),children:[F?(0,d.jsx)("span",{className:"spin",children:(0,d.jsx)(j.I,{name:"refresh",size:13})}):(0,d.jsx)(j.I,{name:"add",size:14})," ",B.length>0?`${B.length}/10`:p("chat.composer.attach")]}),U&&(0,d.jsxs)("button",{type:"button",className:"att-btn kb-pull-btn",title:p("chat.kbPull.open"),disabled:P,onMouseDown:a=>a.preventDefault(),onClick:function(){K(n.replace(/@[a-z0-9-]+/gi,"").trim().slice(0,180)),M(null),O(""),v(null),A(null),y(null),I(a=>!a)},children:[(0,d.jsx)(j.I,{name:"branch",size:13})," ",p("chat.kbPull.open")]})]}),g&&n.trim()&&!q?(0,d.jsxs)("span",{className:"composer-hint",style:{color:"#f0a35e"},children:[(0,d.jsx)(j.I,{name:"at",size:11})," ",p("chat.composer.mentionToSend")]}):(0,d.jsxs)("span",{className:"composer-hint",children:[(0,d.jsx)("kbd",{children:"↵"})," ",p("chat.composer.send")," \xb7 ",(0,d.jsx)("kbd",{children:"⇧↵"})," ",p("chat.composer.newline")]}),(0,d.jsxs)("button",{className:"send-btn",disabled:!n.trim()&&0===B.length||!q,onMouseDown:a=>a.preventDefault(),onClick:_,children:[(0,d.jsx)(j.I,{name:"send",size:13})," ",p("home.cmd.run")]})]})]})]})}function y({atts:a}){return(0,d.jsx)("div",{className:"msg-atts",children:a.map(a=>{let b=`/api/upload?path=${encodeURIComponent(a.path)}`;return/^image\//.test(a.type)?(0,d.jsx)("a",{href:b,target:"_blank",rel:"noreferrer",className:"msg-att-img",title:a.name,children:(0,d.jsx)("img",{src:b,alt:a.name,loading:"lazy"})},a.path):(0,d.jsxs)("a",{href:b,target:"_blank",rel:"noreferrer",className:"msg-att-doc",title:a.name,children:[(0,d.jsx)(j.I,{name:"doc",size:13})," ",(0,d.jsx)("span",{className:"mad-name",children:a.name})]},a.path)})})}function z({id:a}){let b=(0,k.k)(),[c,f]=(0,e.useTransition)(),[g,h]=(0,e.useState)(!1);return(0,d.jsx)("button",{type:"button",className:"cmsg-kb",disabled:c||g,title:b(g?"chat.kbSave.saved":"chat.kbSave.send"),onClick:()=>f(async()=>{(await n(a)).ok&&h(!0)}),style:{background:"none",border:"none",cursor:g?"default":"pointer",padding:0,marginLeft:2,display:"inline-flex",alignItems:"center",color:g?"var(--accent)":"var(--text-faint)",opacity:c?.5:1},children:(0,d.jsx)(j.I,{name:g?"check":"branch",size:11,className:c?"sync-spin":""})})}function A({taskId:a}){let[b,c]=(0,e.useState)(null);return b?(0,d.jsxs)("div",{style:{marginTop:5,fontSize:10.5,color:"var(--text-faint)",display:"flex",alignItems:"center",gap:5,flexWrap:"wrap"},children:[(0,d.jsx)(j.I,{name:"branch",size:10}),(0,d.jsx)("span",{style:{color:"var(--accent)",fontWeight:600},children:b.taskKey}),b.issueKey&&(0,d.jsxs)("span",{children:["\xb7 ",b.issueKey]}),b.goalTitle&&(0,d.jsxs)("span",{children:["\xb7 ",b.goalTitle.slice(0,40)]}),b.col&&(0,d.jsx)("span",{style:{padding:"0 5px",borderRadius:5,border:"1px solid var(--border)",textTransform:"capitalize"},children:b.col})]}):null}function B({blocks:a}){let b=(0,f.useRouter)(),c=(0,k.k)();return(0,d.jsxs)("div",{style:{marginTop:5,fontSize:10.5,color:"var(--text-faint)",display:"flex",alignItems:"center",gap:5,flexWrap:"wrap"},children:[(0,d.jsx)(j.I,{name:"doc",size:10}),(0,d.jsx)("span",{children:c("chat.touchedBlocks")}),a.map(a=>(0,d.jsx)("button",{type:"button",title:c("chat.touchedBlocks"),onClick:()=>b.push("/knowledge"),style:{color:"var(--accent)",fontWeight:600,background:"rgba(120,100,255,.10)",border:"1px solid rgba(120,100,255,.25)",borderRadius:4,padding:"0 5px",cursor:"pointer"},children:a},a))]})}function C({sources:a}){let[b,c]=(0,e.useState)(!1),f=(0,k.k)();return(0,d.jsxs)("div",{className:"msg-sources",children:[(0,d.jsxs)("button",{type:"button",className:"msg-sources-toggle",onClick:()=>c(a=>!a),children:[(0,d.jsx)(j.I,{name:"pulse",size:10})," ",f("chat.sources",{n:a.length})," ",(0,d.jsx)(j.I,{name:b?"chevronDown":"chevronRight",size:11})]}),b&&(0,d.jsx)("div",{className:"msg-sources-list",children:a.map((a,b)=>(0,d.jsx)("span",{children:a},b))})]})}function D({text:a,markdown:b,known:c,refs:f}){let i=(0,k.k)(),[j,l]=(0,e.useState)(!1),m=a.length>900;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"cmsg-bubble"+(m&&!j?" clamped":"")+(m&&j?" expanded":""),children:b?(0,d.jsx)("div",{className:"md cmsg-md",children:(0,d.jsx)(g.oz,{remarkPlugins:[h.A],children:a})}):u(a,c,f)}),m&&(0,d.jsx)("button",{type:"button",className:"cmsg-more",onClick:()=>l(a=>!a),children:i(j?"chat.showLess":"chat.showMore")})]})}function E({m:a}){let b=(0,k.k)(),c=(0,f.useRouter)(),[i,l]=(0,e.useTransition)(),[m,n]=(0,e.useState)(!1),[q,r]=(0,e.useState)(null);return(0,d.jsxs)("div",{className:"kb-card",children:[(0,d.jsxs)("div",{className:"kb-card-head",children:[(0,d.jsx)(j.I,{name:"branch",size:14})," ",b("kbcard.title")]}),(0,d.jsx)("div",{className:"kb-card-body cmsg-md",children:(0,d.jsx)(g.oz,{remarkPlugins:[h.A],children:a.text})}),q&&(0,d.jsxs)("div",{className:"kb-card-note",children:[(0,d.jsx)(j.I,{name:"check",size:12})," ",q]}),(0,d.jsxs)("div",{className:"kb-card-actions",children:[(0,d.jsx)("button",{className:"kbc-btn primary",disabled:i,onClick:()=>l(async()=>{r(b("kbcard.created",{n:(await (0,o.V)()).seeded})),c.refresh()}),children:b("home.createBlocks")}),(0,d.jsx)("button",{className:"kbc-btn",onClick:()=>c.push("/knowledge"),children:b("home.openKnowledge")}),(0,d.jsx)("button",{className:"kbc-btn",disabled:i,onClick:()=>l(async()=>{r(b("kb.reindexResult",{n:(await (0,p.f)()).chunks})),c.refresh()}),children:b("kb.reindex")})]}),a.sources&&a.sources.length>0&&(0,d.jsxs)("div",{className:"kb-card-sources",children:[(0,d.jsxs)("button",{type:"button",className:"msg-sources-toggle",onClick:()=>n(a=>!a),children:[(0,d.jsx)(j.I,{name:"pulse",size:10})," ",b("chat.sources",{n:a.sources.length})," ",(0,d.jsx)(j.I,{name:m?"chevronDown":"chevronRight",size:11})]}),m&&(0,d.jsx)("div",{className:"msg-sources-list",children:a.sources.map((a,b)=>(0,d.jsx)("span",{children:a},b))})]})]})}function F({msgs:a,typing:b,agents:c,byRun:f,liveRuns:g,loading:h,highlightId:j,operator:l,markdownAgent:m=!1,emptyHint:n,avatarSize:o=30,refs:p}){let q=(0,k.k)(),r=(0,e.useRef)(null),s=(0,e.useRef)(!0),t=Object.fromEntries(c.map(a=>[a.handle,a])),v=new Set(c.map(a=>a.handle));return(0,d.jsxs)("div",{className:"chat-stream scroll",ref:r,onScroll:()=>{let a=r.current;a&&(s.current=a.scrollHeight-a.scrollTop-a.clientHeight<120)},children:[[...a].sort((a,b)=>{let c=a.createdAt?new Date(a.createdAt).getTime():0,d=b.createdAt?new Date(b.createdAt).getTime():0;return c!==d?c-d:("operator"!==a.fromKind)-("operator"!==b.fromKind)}).map(a=>{let b="operator"===a.fromKind,c=a.fromHandle?t[a.fromHandle]:null,e=f[a.id],g=!b&&"kb-card"===a.kind;return(0,d.jsxs)("div",{className:"cmsg"+(b?" operator":"")+(j===a.id?" highlight":""),id:"m-"+a.id,children:[b?l?.image?(0,d.jsx)(i.e,{name:l.name||q("chat.you"),color:"#9a5cff",image:l.image,size:o}):(0,d.jsx)("div",{className:"avatar",style:{background:"linear-gradient(150deg,#e0a44e,#9a5cff)",color:"#1a1206",width:o,height:o,borderRadius:Math.round(.3*o),display:"grid",placeItems:"center",fontWeight:700,fontSize:Math.round(.4*o)},children:"OP"}):c?(0,d.jsx)(i.e,{name:c.name,color:c.color,image:c.image,size:o}):(0,d.jsx)(i.e,{name:"?",color:"#6b7390",size:o}),(0,d.jsxs)("div",{className:"cmsg-body",children:[(0,d.jsxs)("div",{className:"cmsg-head",children:[(0,d.jsx)("span",{className:"cmsg-name",children:b?q("chat.you"):c?.name??a.fromHandle}),!b&&c&&(0,d.jsx)("span",{className:"cmsg-role",children:c.role}),(0,d.jsx)("span",{className:"cmsg-when",children:function(a){if(!a)return"";let b="string"==typeof a?new Date(a):a,c=b.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),d=b.toLocaleDateString([],{day:"2-digit",month:"short"});return`${d}, ${c}`}(a.createdAt)}),!b&&a.text&&(0,d.jsx)(z,{id:a.id})]}),e&&e.length>0&&(0,d.jsx)(w,{steps:e,live:!1}),g?(0,d.jsx)(E,{m:a}):a.text&&(0,d.jsx)(D,{text:a.text,markdown:m&&!b,known:v,refs:p}),a.attachments&&a.attachments.length>0&&(0,d.jsx)(y,{atts:a.attachments}),!b&&!g&&a.sources&&a.sources.length>0&&(0,d.jsx)(C,{sources:a.sources}),!b&&a.taskId&&(0,d.jsx)(A,{taskId:a.taskId}),!b&&a.blocks&&a.blocks.length>0&&(0,d.jsx)(B,{blocks:a.blocks})]})]},a.id)}),g.map(([a,b])=>{let e=b.find(a=>a.agentId)?.agentId,f=c.find(a=>a.id===e);if(!f)return null;let g=b.reduce((a,b)=>Math.max(a,b.seq||0),0),h=b.some(a=>"done"===a.kind)||g>0&&Date.now()-g>12e4,j=b.filter(a=>"text"===a.kind).map(a=>a.detail).join("");return(0,d.jsxs)("div",{className:"cmsg",children:[(0,d.jsx)(i.e,{name:f.name,color:f.color,image:f.image,size:o}),(0,d.jsxs)("div",{className:"cmsg-body",children:[(0,d.jsxs)("div",{className:"cmsg-head",children:[(0,d.jsx)("span",{className:"cmsg-name",children:f.name}),(0,d.jsx)("span",{className:"cmsg-role",children:f.role})]}),(0,d.jsx)(w,{steps:b,live:!h}),j&&(0,d.jsxs)("div",{className:"cmsg-bubble",children:[u(j,v,p),!h&&(0,d.jsx)("span",{className:"live-caret"})]})]})]},"live-"+a)}),b.filter(a=>{let b=t[a];return b&&!g.some(([,a])=>a.some(a=>a.agentId===b.id))}).map(a=>{let b=t[a];return b?(0,d.jsxs)("div",{className:"cmsg",children:[(0,d.jsx)(i.e,{name:b.name,color:b.color,image:b.image,size:o}),(0,d.jsxs)("div",{className:"cmsg-body",children:[(0,d.jsxs)("div",{className:"cmsg-head",children:[(0,d.jsx)("span",{className:"cmsg-name",children:b.name}),(0,d.jsx)("span",{className:"cmsg-role",children:b.role})]}),(0,d.jsxs)("div",{className:"typing-bubble",children:[(0,d.jsx)("span",{}),(0,d.jsx)("span",{}),(0,d.jsx)("span",{})]})]})]},"typing-"+a):null}),h&&0===a.length&&0===g.length&&(0,d.jsx)("div",{className:"chat-skel","aria-label":q("home.chat.loading"),children:[0,1,2].map(a=>(0,d.jsxs)("div",{className:"skel-row",style:{animationDelay:`${.12*a}s`},children:[(0,d.jsx)("div",{className:"skel-avatar"}),(0,d.jsxs)("div",{className:"skel-lines",children:[(0,d.jsx)("div",{className:"skel-line",style:{width:"38%"}}),(0,d.jsx)("div",{className:"skel-line",style:{width:1===a?"82%":"64%"}}),2!==a&&(0,d.jsx)("div",{className:"skel-line",style:{width:"48%"}})]})]},a))}),!h&&0===a.length&&0===b.length&&0===g.length&&(0,d.jsx)("div",{className:"mention-empty",style:{textAlign:"center",padding:22},children:n??q("chat.stream.emptyHint")})]})}},7482:(a,b,c)=>{"use strict";c.d(b,{IL:()=>y,Jp:()=>u,TX:()=>t,bV:()=>v,bk:()=>x,q4:()=>w});var d=c(6866),e=c(73024),f=c(76760),g=c(31371),h=c(97603),i=c(65705),j=c(1890),k=c(53993),l=c(57086),m=c(56267),n=c(84903),o=c(76158),p=c(10133),q=c(93571),r=c(57300);async function s(a,b){let[c]=await i.db.select().from(j.member).where((0,h.Uo)((0,h.eq)(j.member.userId,a),(0,h.eq)(j.member.orgId,b)));return!!c}async function t(a){let b=await (0,k.Ht)();b&&await s(b.user.id,a)&&(await i.db.update(j.session).set({activeOrgId:a}).where((0,h.eq)(j.session.userId,b.user.id)),(0,g.revalidatePath)("/","layout"))}async function u(a,b){let c=await (0,k.Ht)();c&&await s(c.user.id,a)&&(await i.db.update(j.organization).set({name:b.trim()||"Organization"}).where((0,h.eq)(j.organization.id,a)),await i.db.update(j.workspace).set({name:b.trim()||"Organization"}).where((0,h.eq)(j.workspace.orgId,a)),(0,g.revalidatePath)("/organizations"))}async function v(a,b){let c=await (0,k.Ht)();c&&await s(c.user.id,a)&&(await i.db.update(j.organization).set({archived:b}).where((0,h.eq)(j.organization.id,a)),(0,g.revalidatePath)("/organizations"))}async function w(a){let b=await (0,k.Ht)();if(b&&await s(b.user.id,a)){try{let b=(0,f.join)((0,l.r$)(),"organizations",a);(0,e.existsSync)(b)&&(0,e.rmSync)(b,{recursive:!0,force:!0})}catch{}await i.db.delete(j.organization).where((0,h.eq)(j.organization.id,a)),await i.db.update(j.session).set({activeOrgId:null}).where((0,h.eq)(j.session.userId,b.user.id)),(0,g.revalidatePath)("/","layout")}}async function x(a,b){let{org:c,workspace:d}=await (0,k.nP)(),e=(d.mission??"")!==a||(d.objective??"")!==b;if(await i.db.update(j.workspace).set({mission:a,objective:b}).where((0,h.eq)(j.workspace.id,d.id)),e){try{(0,m.Lb)({orgId:c.id,slug:d.slug,company:d.name,mission:a,objective:b,stack:d.stack??{}})}catch(a){console.error("[editWorkspaceMeta] doc rerender failed:",a)}await (0,n.j)(d.id,{text:`Direction updated — objective: ${b.slice(0,160)}`,by:"operator",source:"operator-instruction"})}(0,g.revalidatePath)("/organizations"),(0,g.revalidatePath)("/","layout")}async function y(a){let{org:b,workspace:c}=await (0,k.nP)(),d={};for(let[b,c]of Object.entries(a??{}))"string"==typeof c&&c.trim()&&(d[b]=c.trim());let e=(0,p.T1)(d).stack,f=JSON.stringify(c.stack??{})!==JSON.stringify(e);if(await i.db.update(j.workspace).set({stack:e}).where((0,h.eq)(j.workspace.id,c.id)),f)try{let a=await i.db.select({id:j.agent.id,handle:j.agent.handle}).from(j.agent).where((0,h.eq)(j.agent.workspaceId,c.id)),d=Object.fromEntries(a.map(a=>[a.handle,a.id]));(0,o.fR)({orgId:b.id,wsId:c.id,names:(0,q.AQ)(e),agentIds:d,linkNames:[]}),(0,o.J$)(c.id),(0,m.Lb)({orgId:b.id,slug:c.slug,company:c.name,mission:c.mission??"",objective:c.objective??"",stack:e}),await (0,n.j)(c.id,{text:`Stack updated — ${Object.entries(e).map(([a,b])=>`${a}:${b}`).filter(a=>!a.endsWith(":None")).join(", ").slice(0,200)}`,by:"operator",source:"operator-instruction"}),(0,r.xV)(b.id).catch(()=>{})}catch(a){console.error("[setWorkspaceStack] reconcile failed:",a)}(0,g.revalidatePath)("/config"),(0,g.revalidatePath)("/","layout")}(0,c(74252).D)([t,u,v,w,x,y]),(0,d.A)(t,"403972c138470189ab9c965aa2785e0f74d37a5ec3",null),(0,d.A)(u,"60ebcc6da0ab0e901014ce384cb554138b17e7a52a",null),(0,d.A)(v,"602b26646ec90ca51fda510271d274904b830577d5",null),(0,d.A)(w,"40e6f8258f8df805f6fcd2e91a396cd355b0751db3",null),(0,d.A)(x,"609bdc02d3153f832541f2c952a5e7cb917a504f2c",null),(0,d.A)(y,"408ebe3c75c8f47e1a33ca1ac0e850c6a92692ec67",null)},8556:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>g});var d=c(4374),e=c(47104),f=c(31819);function g({error:a,reset:b}){let c=(0,e.useRouter)(),h=(0,f.k)();return(0,d.jsx)("div",{style:{height:"100%",display:"grid",placeItems:"center",padding:40},children:(0,d.jsxs)("div",{style:{maxWidth:480,textAlign:"center"},children:[(0,d.jsx)("div",{style:{fontSize:16,fontWeight:800,marginBottom:8,color:"var(--text)"},children:h("errors.screenTitle")}),(0,d.jsx)("div",{style:{fontSize:13,color:"var(--text-dim)",marginBottom:14,wordBreak:"break-word"},children:a.message||h("errors.unexpected")}),a.digest&&(0,d.jsxs)("div",{style:{fontSize:11,color:"var(--text-faint)",marginBottom:16,fontFamily:"var(--mono-font, monospace)"},children:[h("errors.digest"),": ",a.digest]}),(0,d.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"center"},children:[(0,d.jsx)("button",{className:"btn-accent",onClick:()=>b(),children:h("errors.tryAgain")}),(0,d.jsx)("button",{className:"btn-ghost",onClick:()=>c.push("/"),children:h("errors.goDashboard")})]})]})})}},10245:(a,b,c)=>{"use strict";c.d(b,{CJ:()=>k,fQ:()=>i,hW:()=>j});var d=c(65705),e=c(1890),f=c(97603),g=c(55511),h=c(57086);let i=9e4;async function j(a,b,c={}){let h=new Date,i=c.ok??!0;return await d.db.insert(e.pulse).values({id:(0,g.randomUUID)(),workspaceId:a,agentId:b,at:h,ok:i,latencyMs:c.latencyMs??0,note:c.note??""}),await d.db.update(e.agent).set({lastPulse:h,health:i?"alive":"stale"}).where((0,f.eq)(e.agent.id,b)),h}async function k(a,b){let c=await d.db.query.agent.findMany({where:(0,f.eq)(e.agent.workspaceId,a)}),g=[];for(let a of c){let{intervalSec:c,maxMissed:i}=function(a,b){let c=(0,h.sL)(a,`.claude/agents/${b}/pulse.md`)??"";return{intervalSec:parseInt(c.match(/intervalSec:\s*(\d+)/)?.[1]??"30",10)||30,maxMissed:parseInt(c.match(/maxMissed:\s*(\d+)/)?.[1]??"2",10)||2}}(b,a.handle),j=c*i*1e3,k=3*j,l=function(a,b,c){if(!a)return"down";let d=Date.now()-a.getTime();return d<=b?"alive":d<=c?"stale":"down"}(a.lastPulse??null,j,k);l!==a.health&&await d.db.update(e.agent).set({health:l}).where((0,f.eq)(e.agent.id,a.id)),g.push({a,health:l})}let i=new Date().toISOString(),j=`# Agent status
2
5
 
3
6
  _Updated by the pulse sweep at ${i}._
4
7
 
@@ -9,7 +12,7 @@ _Updated by the pulse sweep at ${i}._
9
12
  - Updated: ${i}
10
13
  - Agents: ${g.length} (alive ${k.alive} \xb7 stale ${k.stale} \xb7 down ${k.down})
11
14
  - Workspace config: ${l?"present":"MISSING"}
12
- `;try{(0,h.dx)(b,"Reports/agent-status.md",j),(0,h.dx)(b,"Reports/system-health.md",m)}catch{}}},10335:(a,b,c)=>{"use strict";c.d(b,{ZF:()=>i,h6:()=>j,w1:()=>h});var d=c(97603);c(76760);var e=c(65705),f=c(1890);c(57086);var g=c(77558);async function h(a,b){if(b)try{let c=await e.db.select({path:f.fileLock.path}).from(f.fileLock).where((0,d.Uo)((0,d.eq)(f.fileLock.workspaceId,a),(0,d.eq)(f.fileLock.taskId,b)));for(let h of(await e.db.delete(f.fileLock).where((0,d.Uo)((0,d.eq)(f.fileLock.workspaceId,a),(0,d.eq)(f.fileLock.taskId,b))),c))await (0,g.W_)(a,"task",`lock:${h.path}`)}catch{}}async function i(a=3e5){try{await e.db.delete(f.fileLock).where((0,d.lt)(f.fileLock.heartbeatAt,new Date(Date.now()-a)))}catch{}}async function j(a){try{return await e.db.select({path:f.fileLock.path,agentHandle:f.fileLock.agentHandle,taskId:f.fileLock.taskId}).from(f.fileLock).where((0,d.eq)(f.fileLock.workspaceId,a))}catch{return[]}}},12325:(a,b,c)=>{"use strict";c.d(b,{K:()=>e});var d=c(2910);let e=(0,d.createServerReference)("00df7e6e08eaa29f35def8db35d7aefb6c9acb9ce2",d.callServer,void 0,d.findSourceMapURL,"disconnectTelegram")},12677:(a,b,c)=>{"use strict";c.d(b,{f:()=>l});var d=c(77598),e=c(97603),f=c(95357),g=c(65705),h=c(1890),i=c(70149),j=c(57086),k=c(57806);async function l(a,b,c,m,n=!1,o,p){let{window:q,keepRecent:r,aggressive:s}=o??(0,k.S)(m),t=[(0,e.eq)(h.message.workspaceId,b),(0,e.eq)(h.message.channel,c)];p&&t.push((0,e.eq)(h.message.sessionId,p));let u=await g.db.select().from(h.message).where((0,e.Uo)(...t)).orderBy((0,f.Y)(h.message.createdAt)),[v]=await g.db.select().from(h.messageSummary).where((0,e.Uo)((0,e.eq)(h.messageSummary.workspaceId,b),(0,e.eq)(h.messageSummary.channel,c),p?(0,e.eq)(h.messageSummary.sessionId,p):(0,e.kZ)(h.messageSummary.sessionId))),w=(0,k.b)(u.map(a=>a.text).join("\n"));if(u.length<=r+1||!n&&(u.length<=r+4||w<.4*q))return{summary:v?.summary??"",recent:u.slice(-r)};let x=u.slice(0,u.length-r),y=u.slice(-r),z=x[x.length-1]?.id??"";if(v&&v.throughId===z)return{summary:v.summary,recent:y};let A=x.map(a=>("operator"===a.fromKind?"Operator":"@"+(a.fromHandle??"agent"))+": "+a.text).join("\n"),B=["Summarize this team chat history into a COMPACT, STRUCTURED context for an AI teammate.","Output EXACTLY these markdown sections (omit one only if truly empty), with the substance under each:",`## Decisions
15
+ `;try{(0,h.dx)(b,"Reports/agent-status.md",j),(0,h.dx)(b,"Reports/system-health.md",m)}catch{}}},10335:(a,b,c)=>{"use strict";c.d(b,{ZF:()=>i,h6:()=>j,w1:()=>h});var d=c(97603);c(76760);var e=c(65705),f=c(1890);c(57086);var g=c(77558);async function h(a,b){if(b)try{let c=await e.db.select({path:f.fileLock.path}).from(f.fileLock).where((0,d.Uo)((0,d.eq)(f.fileLock.workspaceId,a),(0,d.eq)(f.fileLock.taskId,b)));for(let h of(await e.db.delete(f.fileLock).where((0,d.Uo)((0,d.eq)(f.fileLock.workspaceId,a),(0,d.eq)(f.fileLock.taskId,b))),c))await (0,g.W_)(a,"task",`lock:${h.path}`)}catch{}}async function i(a=3e5){try{await e.db.delete(f.fileLock).where((0,d.lt)(f.fileLock.heartbeatAt,new Date(Date.now()-a)))}catch{}}async function j(a){try{return await e.db.select({path:f.fileLock.path,agentHandle:f.fileLock.agentHandle,taskId:f.fileLock.taskId}).from(f.fileLock).where((0,d.eq)(f.fileLock.workspaceId,a))}catch{return[]}}},12677:(a,b,c)=>{"use strict";c.d(b,{f:()=>l});var d=c(77598),e=c(97603),f=c(95357),g=c(65705),h=c(1890),i=c(70149),j=c(57086),k=c(57806);async function l(a,b,c,m,n=!1,o,p){let{window:q,keepRecent:r,aggressive:s}=o??(0,k.S)(m),t=[(0,e.eq)(h.message.workspaceId,b),(0,e.eq)(h.message.channel,c)];p&&t.push((0,e.eq)(h.message.sessionId,p));let u=await g.db.select().from(h.message).where((0,e.Uo)(...t)).orderBy((0,f.Y)(h.message.createdAt)),[v]=await g.db.select().from(h.messageSummary).where((0,e.Uo)((0,e.eq)(h.messageSummary.workspaceId,b),(0,e.eq)(h.messageSummary.channel,c),p?(0,e.eq)(h.messageSummary.sessionId,p):(0,e.kZ)(h.messageSummary.sessionId))),w=(0,k.b)(u.map(a=>a.text).join("\n"));if(u.length<=r+1||!n&&(u.length<=r+4||w<.4*q))return{summary:v?.summary??"",recent:u.slice(-r)};let x=u.slice(0,u.length-r),y=u.slice(-r),z=x[x.length-1]?.id??"";if(v&&v.throughId===z)return{summary:v.summary,recent:y};let A=x.map(a=>("operator"===a.fromKind?"Operator":"@"+(a.fromHandle??"agent"))+": "+a.text).join("\n"),B=["Summarize this team chat history into a COMPACT, STRUCTURED context for an AI teammate.","Output EXACTLY these markdown sections (omit one only if truly empty), with the substance under each:",`## Decisions
13
16
  ## Requirements
14
17
  ## Open issues
15
18
  ## Files
@@ -69,7 +72,7 @@ ${f}`.slice(0,500)}),await (0,F.I)(a.id,{kind:"review",text:`${d.key} held — c
69
72
  ${x.text.slice(0,600)}`),await g.db.insert(h.cronRun).values({id:(0,l.randomUUID)(),workspaceId:a.id,task:`${d.key} — ${d.title}`.slice(0,200),agentId:e.id,ok:!0,at:new Date}),await g.db.update(h.agent).set({status:"idle"}).where((0,f.eq)(h.agent.id,e.id))}else await g.db.update(h.task).set({col:"blocked"}).where((0,f.eq)(h.task.id,d.id)),d.issueId&&await g.db.update(h.issue).set({col:"blocked"}).where((0,f.eq)(h.issue.id,d.issueId)),await g.db.update(h.agent).set({status:"blocked"}).where((0,f.eq)(h.agent.id,e.id)),await g.db.insert(h.activity).values({id:(0,l.randomUUID)(),workspaceId:a.id,agentId:e.id,action:"task blocked",target:`${d.title}: ${x.error??"error"}`.slice(0,200),at:new Date}),await (0,p.lM)(a.id,d.id,x.text),d.goalId&&await s(a.id,d.goalId),await Z(a,!1,e,d,x.error??"Run failed with no output."),await g.db.insert(h.cronRun).values({id:(0,l.randomUUID)(),workspaceId:a.id,task:`${d.key} — ${d.title}`.slice(0,200),agentId:e.id,ok:!1,at:new Date}),await (0,F.I)(a.id,{kind:"review",text:`${d.key} blocked — ${d.title}`,detail:(x.error??"Run failed").slice(0,300),agentId:e.id}),await (0,C.vE)(a.id,{kind:"block",refType:"task",refId:d.id,goalId:d.goalId??null,fromAgentId:e.id,title:`${d.key} blocked — needs you`,detail:`${d.title}
70
73
 
71
74
  ${(x.error??"Run failed").slice(0,400)}`}),await (0,u.j)(a.id,{text:`Blocked ${d.key}: ${d.title}`,by:e.handle,source:"issue-block",refKey:d.key,rationale:(x.error??"").slice(0,300)});return!0}finally{_.delete(d.id),(0,A.w1)(a.id,d.id);try{let b=(0,K.sL)(a.orgId,".claude/guard-denials.jsonl");if(b&&b.trim()){let c=b.trim().split("\n").map(a=>{try{return JSON.parse(a)}catch{return null}}).filter(Boolean);if(c.length){let b=c.slice(0,8).map(a=>`• ${a.why}: \`${String(a.cmd).slice(0,120)}\``).join("\n");await (0,C.vE)(a.id,{kind:"block",refType:"task",refId:`guard:${d.id}`,goalId:d.goalId??null,fromAgentId:e.id,title:`@${e.handle} attempted ${c.length} blocked command(s) on ${d.key}`,detail:`The safety guard blocked these destructive commands during the run:
72
- ${b}`})}(0,K.EX)(a.orgId,".claude/guard-denials.jsonl")}}catch{}}}async function af(a,b={}){let c=await g.db.query.workspace.findFirst({where:(0,f.eq)(h.workspace.id,a)});if(!c)return{pulsed:0,advanced:0,paused:0};let d=await g.db.query.agent.findMany({where:(0,f.eq)(h.agent.workspaceId,a)});if(0===d.length)return{pulsed:0,advanced:0,paused:0};let e={claude:await V("claude"),codex:await V("codex"),openclaw:await V("openclaw"),hermes:await V("hermes"),aider:await V("aider"),opencode:await V("opencode"),copilot:await V("copilot"),"cursor-agent":await V("cursor-agent"),cline:await V("cline"),kilocode:await V("kilocode")},i=a=>!a.startsWith("cli_")||e[(0,n.hW)(a)],j=0,k=0,l=0;for(let b of d){if("idle"!==b.status&&await T(b.id,b.dailyCapUsd)){k++;continue}let c=i(b.adapter),d=c?"alive":"stale";"idle"!==b.status?await (0,m.hW)(a,b.id,{ok:c,note:`tick:${b.status}`}):await g.db.update(h.agent).set({lastPulse:new Date,health:d}).where((0,f.eq)(h.agent.id,b.id)),b.health!==d&&l++,j++}let o=0;return b.execute&&await ad(c,{auto:b.auto})&&(o=1),b.execute&&!b.browser&&await (0,m.CJ)(c.id,c.orgId),{pulsed:j,advanced:o,paused:k,changed:l}}async function ag(){let{workspace:a}=await (0,i.nP)();if(!a.runMode||"off"===a.runMode)return{paused:!0};let b=await af(a.id,{execute:!1});return((b.changed??0)>0||(b.advanced??0)>0)&&(0,e.revalidatePath)("/","layout"),{...b,paused:!1}}async function ah(){let{org:a,workspace:b}=await (0,i.nP)(),c=await g.db.query.plan.findFirst({where:(0,f.eq)(h.plan.workspaceId,b.id)});if(!c?.approved||!c?.auto247)return{ran:!1,remaining:0,paused:!0};0===(await g.db.select({id:h.task.id}).from(h.task).where((0,f.eq)(h.task.workspaceId,b.id)).limit(1)).length&&await (0,p.s$)(a.id,b.id);let d=await af(b.id,{execute:!0,auto:!0,browser:!0}),j=await g.db.select({id:h.task.id}).from(h.task).where((0,f.Uo)((0,f.eq)(h.task.workspaceId,b.id),(0,f.RV)(h.task.col,["todo","doing"]),(0,f.Pe)(h.task.assigneeId)));return(0,e.revalidatePath)("/","layout"),{ran:(d.advanced??0)>0,remaining:j.length,paused:!1}}async function ai(){let{workspace:a}=await (0,i.nP)(),b=await af(a.id,{execute:!0});return(0,e.revalidatePath)("/","layout"),b}async function aj(a){let{workspace:b}=await (0,i.nP)();return(0,j.n)()?(await g.db.update(h.workspace).set({runMode:a}).where((0,f.eq)(h.workspace.id,b.id)),(0,e.revalidatePath)("/","layout"),{runMode:a}):{runMode:b.runMode}}(0,c(74252).D)([ag,ah,ai,aj]),(0,d.A)(ag,"00ce8a19facd18b6c85993ebd6da347d63d0579dfa",null),(0,d.A)(ah,"008945e940738840c2c3f8cf09a767e9dff2d1d34b",null),(0,d.A)(ai,"00bb81b2ee7b45ce9f2c558b5098b2acbe223d936e",null),(0,d.A)(aj,"404aa55a36511316cdf338b098de663d429f9e7c1f",null)},14284:(a,b,c)=>{"use strict";c.d(b,{e:()=>e});var d=c(2910);let e=(0,d.createServerReference)("009be10f119924c7536924e7aa423be2a59d4a0f40",d.callServer,void 0,d.findSourceMapURL,"pollUpdateResult")},14565:(a,b,c)=>{"use strict";c.d(b,{Kd:()=>k,OD:()=>h,cT:()=>i,j0:()=>j});var d=c(52813),e=c(79676),f=c(17971),g=c(51063);async function h(a){(await (0,e.cookies)()).set("cn-theme","light"===a?"dark":"light",{path:"/",maxAge:31536e3})}async function i(){let a=await (0,e.cookies)(),b=a.get("cn-anim")?.value==="off"?"on":"off";a.set("cn-anim",b,{path:"/",maxAge:31536e3})}async function j(a){(await (0,e.cookies)()).set("cn-lang","pt"===a?"pt":"en",{path:"/",maxAge:31536e3})}async function k(){await g.j2.api.signOut({headers:await (0,e.headers)()}),(0,f.redirect)("/login")}(0,c(29635).D)([h,i,j,k]),(0,d.A)(h,"40834c7dee509b9fe3747f69a43078710b318bcdf5",null),(0,d.A)(i,"007022a76790c9702b4391280231b2e171ccb37259",null),(0,d.A)(j,"405c3175ae584fd80327c8ee43d0a247dd50e3c25b",null),(0,d.A)(k,"0028f961902c9e2476af137bbeb472cd7073047824",null)},14631:(a,b,c)=>{"use strict";c.d(b,{k:()=>e});var d=c(2910);let e=(0,d.createServerReference)("6089bcc5361f39d22c01d6f92038ab1a71d519835f",d.callServer,void 0,d.findSourceMapURL,"getEvents")},14698:(a,b,c)=>{"use strict";c.d(b,{e:()=>e});var d=c(4374);function e({name:a,color:b,size:c=24,health:f,image:g}){let h=Math.max(6,Math.round(.3*c)),i=Math.round(.28*c),j=g?/^(data:|https?:|\/)/.test(g)?g:`/api/upload?path=${encodeURIComponent(g)}`:null;return(0,d.jsxs)("span",{style:{position:"relative",width:c,height:c,flex:`0 0 ${c}px`,display:"inline-block"},children:[j?(0,d.jsx)("img",{src:j,alt:a,width:c,height:c,style:{width:c,height:c,borderRadius:i,objectFit:"cover",display:"block"}}):(0,d.jsx)("span",{style:{width:c,height:c,borderRadius:i,background:b,color:"#fff",display:"grid",placeItems:"center",fontSize:Math.round(.42*c),fontWeight:700},children:(a[0]||"?").toUpperCase()}),f&&(0,d.jsx)("span",{style:{position:"absolute",right:-1,bottom:-1,width:h,height:h,borderRadius:"50%",background:"alive"===f?"var(--sx-string)":"stale"===f?"var(--sx-number)":"var(--text-faint)",border:"1.5px solid var(--bg-elevated)"}})]})}},15487:(a,b,c)=>{"use strict";c.d(b,{AA:()=>t,GK:()=>z,KO:()=>A,LZ:()=>C,M8:()=>y,PE:()=>D,RG:()=>x,S:()=>u,ey:()=>s,jc:()=>v,lJ:()=>B,q$:()=>r,r7:()=>q,y_:()=>w});var d=c(6866),e=c(44013),f=c(84988),g=c(97603),h=c(31371),i=c(65705),j=c(1890),k=c(37296),l=c(53993),m=c(57086),n=c(38926),o=c(88007);async function p(){let a=await (0,l.Ht)();return a||(0,f.redirect)("/login"),a.user.id}async function q(a){let b=await p(),c={};if("string"==typeof a.name&&a.name.trim()&&(c.name=a.name.trim()),"string"==typeof a.addressAs&&(c.addressAs=a.addressAs),"string"==typeof a.lang&&(c.lang=a.lang),"string"==typeof a.tz&&(c.tz=a.tz),void 0!==a.image){c.image=a.image;try{let[c]=await i.db.select({image:j.user.image}).from(j.user).where((0,g.eq)(j.user.id,b));if(c?.image&&c.image.startsWith("uploads/")&&c.image!==a.image){let{org:a}=await (0,l.nP)();(0,m.EX)(a.id,c.image.split("/").slice(0,2).join("/"))}}catch{}}Object.keys(c).length&&await i.db.update(j.user).set(c).where((0,g.eq)(j.user.id,b)),(0,h.revalidatePath)("/profile"),(0,h.revalidatePath)("/","layout")}async function r(a,b){let c=await p();await i.db.insert(j.notificationPref).values({userId:c,[a]:b}).onConflictDoUpdate({target:j.notificationPref.userId,set:{[a]:b}}),(0,h.revalidatePath)("/profile")}async function s(a){let b=await p();await i.db.insert(j.notificationPref).values({userId:b,reducedMotion:a}).onConflictDoUpdate({target:j.notificationPref.userId,set:{reducedMotion:a}}),(await (0,e.cookies)()).set("cn-anim",a?"off":"on",{path:"/",maxAge:31536e3}),(0,h.revalidatePath)("/profile"),(0,h.revalidatePath)("/","layout")}async function t(a,b){throw Error("Personal access tokens are disabled.")}async function u(a){let b=await p();await i.db.delete(j.personalAccessToken).where((0,g.Uo)((0,g.eq)(j.personalAccessToken.id,a),(0,g.eq)(j.personalAccessToken.userId,b))),(0,h.revalidatePath)("/profile")}async function v(a){await k.j2.api.revokeSession({body:{token:a},headers:await (0,e.headers)()}),(0,h.revalidatePath)("/profile")}async function w(){await k.j2.api.revokeOtherSessions({headers:await (0,e.headers)()}),(0,h.revalidatePath)("/profile")}async function x(a){let b=await p();await i.db.delete(j.account).where((0,g.Uo)((0,g.eq)(j.account.userId,b),(0,g.eq)(j.account.providerId,a))),(0,h.revalidatePath)("/profile")}async function y(a,b,c){let{workspace:d}=await (0,l.nP)(),e=a.trim(),f=b.trim();if(!(0,o.Py)(e))return{ok:!1,error:"Invalid bot token format"};if(!/^\d{1,20}$/.test(f))return{ok:!1,error:"Chat id must be your personal numeric id (a private chat — not a group)."};let g=await (0,o.gg)(e);return g.ok?(await (0,n.IW)(d.id,"telegram_bot",JSON.stringify({botToken:e,chatId:f,allowedName:(c??"").trim().slice(0,80)})),(0,o.A3)(e).catch(()=>{}),(0,h.revalidatePath)("/profile"),{ok:!0,username:g.username}):{ok:!1,error:"Telegram rejected this bot token."}}async function z(){let{workspace:a}=await (0,l.nP)(),b=await (0,o._9)(a.id);if(!b)return{connected:!1};let c=b.chatId,d=c.length>4?c.slice(0,2)+"•••"+c.slice(-2):"•••";return{connected:!0,allowedName:b.allowedName,chatIdMasked:d}}async function A(){let{workspace:a}=await (0,l.nP)(),{db:b}=await Promise.resolve().then(c.bind(c,65705)),{vault:d}=await Promise.resolve().then(c.bind(c,1890));await b.delete(d).where((0,g.Uo)((0,g.eq)(d.workspaceId,a.id),(0,g.eq)(d.ref,"telegram_bot"))),(0,h.revalidatePath)("/profile")}async function B(a){let b=await p();await i.db.delete(j.passkey).where((0,g.Uo)((0,g.eq)(j.passkey.id,a),(0,g.eq)(j.passkey.userId,b))),(0,h.revalidatePath)("/profile")}async function C(a,b){let c=await p();await i.db.update(j.passkey).set({name:b.trim()||"Passkey"}).where((0,g.Uo)((0,g.eq)(j.passkey.id,a),(0,g.eq)(j.passkey.userId,c))),(0,h.revalidatePath)("/profile")}async function D(){let a=await p();await k.j2.api.signOut({headers:await (0,e.headers)()}).catch(()=>{}),await i.db.delete(j.user).where((0,g.eq)(j.user.id,a)),(0,f.redirect)("/login")}(0,c(74252).D)([q,r,s,t,u,v,w,x,y,z,A,B,C,D]),(0,d.A)(q,"40e311db584b685c4692979c63d0c6e43ebfbb3776",null),(0,d.A)(r,"60b6a569caae9899b156707b836ab2851f5218fa91",null),(0,d.A)(s,"4004cb652b9955d22ac032162768b4e0579a46079b",null),(0,d.A)(t,"60641a6b24e31ba5d7c698743071a038d3366fc586",null),(0,d.A)(u,"40b85e5a61026f49480c36b5f71ce876512194b848",null),(0,d.A)(v,"40242806df9ad69eb1c87ff62b4b2b34b3abad98dd",null),(0,d.A)(w,"005a226f73ea851bb80ec4f9fdf3aedb50fb7fbcd1",null),(0,d.A)(x,"407c52c4d4449ab61d90dcfa9cbf1ddd27160f6838",null),(0,d.A)(y,"706d88c745d18277356678742d9b6b2b19c4f6e86d",null),(0,d.A)(z,"00ee824db0a18ba9e4b113a979c27e43db14785003",null),(0,d.A)(A,"00df7e6e08eaa29f35def8db35d7aefb6c9acb9ce2",null),(0,d.A)(B,"40b05730806e4d6ca81c8b097bbe58fc8b2a6a9c19",null),(0,d.A)(C,"60e6371f54999c9587eca32148839e4ce8eef9abc3",null),(0,d.A)(D,"0051a52502b49e09ad171c2a611bc2418ed1c1a9dc",null)},15783:(a,b,c)=>{"use strict";c.d(b,{BackButton:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call BackButton() from the server but BackButton is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\back-button.tsx","BackButton")},16120:(a,b,c)=>{"use strict";c.d(b,{SidebarToggle:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call SidebarToggle() from the server but SidebarToggle is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\sidebar-toggle.tsx","SidebarToggle")},17738:(a,b,c)=>{"use strict";c.d(b,{LangSwitch:()=>i});var d=c(4374),e=c(74679),f=c(47104),g=c(2910);let h=(0,g.createServerReference)("405c3175ae584fd80327c8ee43d0a247dd50e3c25b",g.callServer,void 0,g.findSourceMapURL,"setLang");function i(){let a=(0,f.useRouter)(),[b,c]=(0,e.useState)("en"),[g,i]=(0,e.useTransition)();return(0,d.jsx)("div",{style:{display:"inline-flex",border:"1px solid var(--border)",borderRadius:7,overflow:"hidden"},children:["en","pt"].map(e=>(0,d.jsx)("button",{type:"button",disabled:g,onClick:()=>{e===b||g||i(async()=>{await h(e),c(e),a.refresh()})},title:"en"===e?"English":"Portugu\xeas (BR)",style:{padding:"3px 8px",fontSize:11,fontWeight:600,cursor:"pointer",border:"none",background:b===e?"var(--accent)":"transparent",color:b===e?"var(--accent-fg)":"var(--text-dim)"},children:e.toUpperCase()},e))})}},18773:(a,b,c)=>{"use strict";c.d(b,{Toaster:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call Toaster() from the server but Toaster is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\toaster.tsx","Toaster")},21985:(a,b,c)=>{"use strict";c.d(b,{n:()=>e});var d=c(2910);let e=(0,d.createServerReference)("605ee4201fe65199f85db7180e840b038e2e8ffd10",d.callServer,void 0,d.findSourceMapURL,"agentRespond")},23297:(a,b,c)=>{"use strict";c.d(b,{generatePlanFor:()=>u,startNewWorkFor:()=>v});var d=c(77598),e=c(97603),f=c(95357),g=c(31371),h=c(65705),i=c(1890),j=c(70149),k=c(63562),l=c(79505),m=c(57086);let n="specs/SUPER-SPEC.md";async function o(a){let b,{orgId:c,wsId:e,ada:f,binary:g,model:k}=a,o=`You are ${f.name}, analyzing an EXISTING project that is ALREADY present in this workspace (the current directory). Do NOT write any product code, do NOT scaffold anything — your ONLY job is to UNDERSTAND the project and write a thorough "super spec".
75
+ ${b}`})}(0,K.EX)(a.orgId,".claude/guard-denials.jsonl")}}catch{}}}async function af(a,b={}){let c=await g.db.query.workspace.findFirst({where:(0,f.eq)(h.workspace.id,a)});if(!c)return{pulsed:0,advanced:0,paused:0};let d=await g.db.query.agent.findMany({where:(0,f.eq)(h.agent.workspaceId,a)});if(0===d.length)return{pulsed:0,advanced:0,paused:0};let e={claude:await V("claude"),codex:await V("codex"),openclaw:await V("openclaw"),hermes:await V("hermes"),aider:await V("aider"),opencode:await V("opencode"),copilot:await V("copilot"),"cursor-agent":await V("cursor-agent"),cline:await V("cline"),kilocode:await V("kilocode")},i=a=>!a.startsWith("cli_")||e[(0,n.hW)(a)],j=0,k=0,l=0;for(let b of d){if("idle"!==b.status&&await T(b.id,b.dailyCapUsd)){k++;continue}let c=i(b.adapter),d=c?"alive":"stale";"idle"!==b.status?await (0,m.hW)(a,b.id,{ok:c,note:`tick:${b.status}`}):await g.db.update(h.agent).set({lastPulse:new Date,health:d}).where((0,f.eq)(h.agent.id,b.id)),b.health!==d&&l++,j++}let o=0;return b.execute&&await ad(c,{auto:b.auto})&&(o=1),b.execute&&!b.browser&&await (0,m.CJ)(c.id,c.orgId),{pulsed:j,advanced:o,paused:k,changed:l}}async function ag(){let{workspace:a}=await (0,i.nP)();if(!a.runMode||"off"===a.runMode)return{paused:!0};let b=await af(a.id,{execute:!1});return((b.changed??0)>0||(b.advanced??0)>0)&&(0,e.revalidatePath)("/","layout"),{...b,paused:!1}}async function ah(){let{org:a,workspace:b}=await (0,i.nP)(),c=await g.db.query.plan.findFirst({where:(0,f.eq)(h.plan.workspaceId,b.id)});if(!c?.approved||!c?.auto247)return{ran:!1,remaining:0,paused:!0};0===(await g.db.select({id:h.task.id}).from(h.task).where((0,f.eq)(h.task.workspaceId,b.id)).limit(1)).length&&await (0,p.s$)(a.id,b.id);let d=await af(b.id,{execute:!0,auto:!0,browser:!0}),j=await g.db.select({id:h.task.id}).from(h.task).where((0,f.Uo)((0,f.eq)(h.task.workspaceId,b.id),(0,f.RV)(h.task.col,["todo","doing"]),(0,f.Pe)(h.task.assigneeId)));return(0,e.revalidatePath)("/","layout"),{ran:(d.advanced??0)>0,remaining:j.length,paused:!1}}async function ai(){let{workspace:a}=await (0,i.nP)(),b=await af(a.id,{execute:!0});return(0,e.revalidatePath)("/","layout"),b}async function aj(a){let{workspace:b}=await (0,i.nP)();return(0,j.n)()?(await g.db.update(h.workspace).set({runMode:a}).where((0,f.eq)(h.workspace.id,b.id)),(0,e.revalidatePath)("/","layout"),{runMode:a}):{runMode:b.runMode}}(0,c(74252).D)([ag,ah,ai,aj]),(0,d.A)(ag,"0065234ec6235cc124d8268103b09cd0ad037b016f",null),(0,d.A)(ah,"00f01dbe7e3288c64986b5cec39c20d584b4648648",null),(0,d.A)(ai,"00ee9b9abaabf91913653db0b6b047580fe9e40d61",null),(0,d.A)(aj,"401b43fc7b171ab4f339d8b50f0126ae09197482ce",null)},14565:(a,b,c)=>{"use strict";c.d(b,{Kd:()=>k,OD:()=>h,cT:()=>i,j0:()=>j});var d=c(52813),e=c(79676),f=c(17971),g=c(51063);async function h(a){(await (0,e.cookies)()).set("cn-theme","light"===a?"dark":"light",{path:"/",maxAge:31536e3})}async function i(){let a=await (0,e.cookies)(),b=a.get("cn-anim")?.value==="off"?"on":"off";a.set("cn-anim",b,{path:"/",maxAge:31536e3})}async function j(a){(await (0,e.cookies)()).set("cn-lang","pt"===a?"pt":"en",{path:"/",maxAge:31536e3})}async function k(){await g.j2.api.signOut({headers:await (0,e.headers)()}),(0,f.redirect)("/login")}(0,c(29635).D)([h,i,j,k]),(0,d.A)(h,"40139e6107d1834286c2b80d82e1525a7c0753066e",null),(0,d.A)(i,"0020ee1e4504363fce8f1b7fda9b92e0b5f0073be2",null),(0,d.A)(j,"40664d1b326c4e702d0a3077bb46439f2b2600cd50",null),(0,d.A)(k,"00aa0d28cabf2459beec6d25ce8d4cc2266ca99154",null)},14661:(a,b,c)=>{"use strict";c.d(b,{n:()=>e});var d=c(2910);let e=(0,d.createServerReference)("6029b8dd07385c22b79cec8930cd425924cfa64f1c",d.callServer,void 0,d.findSourceMapURL,"agentRespond")},14698:(a,b,c)=>{"use strict";c.d(b,{e:()=>e});var d=c(4374);function e({name:a,color:b,size:c=24,health:f,image:g}){let h=Math.max(6,Math.round(.3*c)),i=Math.round(.28*c),j=g?/^(data:|https?:|\/)/.test(g)?g:`/api/upload?path=${encodeURIComponent(g)}`:null;return(0,d.jsxs)("span",{style:{position:"relative",width:c,height:c,flex:`0 0 ${c}px`,display:"inline-block"},children:[j?(0,d.jsx)("img",{src:j,alt:a,width:c,height:c,style:{width:c,height:c,borderRadius:i,objectFit:"cover",display:"block"}}):(0,d.jsx)("span",{style:{width:c,height:c,borderRadius:i,background:b,color:"#fff",display:"grid",placeItems:"center",fontSize:Math.round(.42*c),fontWeight:700},children:(a[0]||"?").toUpperCase()}),f&&(0,d.jsx)("span",{style:{position:"absolute",right:-1,bottom:-1,width:h,height:h,borderRadius:"50%",background:"alive"===f?"var(--sx-string)":"stale"===f?"var(--sx-number)":"var(--text-faint)",border:"1.5px solid var(--bg-elevated)"}})]})}},15487:(a,b,c)=>{"use strict";c.d(b,{AA:()=>t,GK:()=>z,KO:()=>A,LZ:()=>C,M8:()=>y,PE:()=>D,RG:()=>x,S:()=>u,ey:()=>s,jc:()=>v,lJ:()=>B,q$:()=>r,r7:()=>q,y_:()=>w});var d=c(6866),e=c(44013),f=c(84988),g=c(97603),h=c(31371),i=c(65705),j=c(1890),k=c(37296),l=c(53993),m=c(57086),n=c(38926),o=c(88007);async function p(){let a=await (0,l.Ht)();return a||(0,f.redirect)("/login"),a.user.id}async function q(a){let b=await p(),c={};if("string"==typeof a.name&&a.name.trim()&&(c.name=a.name.trim()),"string"==typeof a.addressAs&&(c.addressAs=a.addressAs),"string"==typeof a.lang&&(c.lang=a.lang),"string"==typeof a.tz&&(c.tz=a.tz),void 0!==a.image){c.image=a.image;try{let[c]=await i.db.select({image:j.user.image}).from(j.user).where((0,g.eq)(j.user.id,b));if(c?.image&&c.image.startsWith("uploads/")&&c.image!==a.image){let{org:a}=await (0,l.nP)();(0,m.EX)(a.id,c.image.split("/").slice(0,2).join("/"))}}catch{}}Object.keys(c).length&&await i.db.update(j.user).set(c).where((0,g.eq)(j.user.id,b)),(0,h.revalidatePath)("/profile"),(0,h.revalidatePath)("/","layout")}async function r(a,b){let c=await p();await i.db.insert(j.notificationPref).values({userId:c,[a]:b}).onConflictDoUpdate({target:j.notificationPref.userId,set:{[a]:b}}),(0,h.revalidatePath)("/profile")}async function s(a){let b=await p();await i.db.insert(j.notificationPref).values({userId:b,reducedMotion:a}).onConflictDoUpdate({target:j.notificationPref.userId,set:{reducedMotion:a}}),(await (0,e.cookies)()).set("cn-anim",a?"off":"on",{path:"/",maxAge:31536e3}),(0,h.revalidatePath)("/profile"),(0,h.revalidatePath)("/","layout")}async function t(a,b){throw Error("Personal access tokens are disabled.")}async function u(a){let b=await p();await i.db.delete(j.personalAccessToken).where((0,g.Uo)((0,g.eq)(j.personalAccessToken.id,a),(0,g.eq)(j.personalAccessToken.userId,b))),(0,h.revalidatePath)("/profile")}async function v(a){await k.j2.api.revokeSession({body:{token:a},headers:await (0,e.headers)()}),(0,h.revalidatePath)("/profile")}async function w(){await k.j2.api.revokeOtherSessions({headers:await (0,e.headers)()}),(0,h.revalidatePath)("/profile")}async function x(a){let b=await p();await i.db.delete(j.account).where((0,g.Uo)((0,g.eq)(j.account.userId,b),(0,g.eq)(j.account.providerId,a))),(0,h.revalidatePath)("/profile")}async function y(a,b,c){let{workspace:d}=await (0,l.nP)(),e=a.trim(),f=b.trim();if(!(0,o.Py)(e))return{ok:!1,error:"Invalid bot token format"};if(!/^\d{1,20}$/.test(f))return{ok:!1,error:"Chat id must be your personal numeric id (a private chat — not a group)."};let g=await (0,o.gg)(e);return g.ok?(await (0,n.IW)(d.id,"telegram_bot",JSON.stringify({botToken:e,chatId:f,allowedName:(c??"").trim().slice(0,80)})),(0,o.A3)(e).catch(()=>{}),(0,h.revalidatePath)("/profile"),{ok:!0,username:g.username}):{ok:!1,error:"Telegram rejected this bot token."}}async function z(){let{workspace:a}=await (0,l.nP)(),b=await (0,o._9)(a.id);if(!b)return{connected:!1};let c=b.chatId,d=c.length>4?c.slice(0,2)+"•••"+c.slice(-2):"•••";return{connected:!0,allowedName:b.allowedName,chatIdMasked:d}}async function A(){let{workspace:a}=await (0,l.nP)(),{db:b}=await Promise.resolve().then(c.bind(c,65705)),{vault:d}=await Promise.resolve().then(c.bind(c,1890));await b.delete(d).where((0,g.Uo)((0,g.eq)(d.workspaceId,a.id),(0,g.eq)(d.ref,"telegram_bot"))),(0,h.revalidatePath)("/profile")}async function B(a){let b=await p();await i.db.delete(j.passkey).where((0,g.Uo)((0,g.eq)(j.passkey.id,a),(0,g.eq)(j.passkey.userId,b))),(0,h.revalidatePath)("/profile")}async function C(a,b){let c=await p();await i.db.update(j.passkey).set({name:b.trim()||"Passkey"}).where((0,g.Uo)((0,g.eq)(j.passkey.id,a),(0,g.eq)(j.passkey.userId,c))),(0,h.revalidatePath)("/profile")}async function D(){let a=await p();await k.j2.api.signOut({headers:await (0,e.headers)()}).catch(()=>{}),await i.db.delete(j.user).where((0,g.eq)(j.user.id,a)),(0,f.redirect)("/login")}(0,c(74252).D)([q,r,s,t,u,v,w,x,y,z,A,B,C,D]),(0,d.A)(q,"40fe7401f127a1c1cc7a0858efa9433492cd7b6733",null),(0,d.A)(r,"603d5aa97fbe0bbf3427d3ee472365f0b23650bcda",null),(0,d.A)(s,"407c0cb497cd58cede6444312d86a0897e484fcbf4",null),(0,d.A)(t,"60e445cd55fb14a068d8f02683ec15e66fd3ae9758",null),(0,d.A)(u,"40703e1390372ba8fd666366ceb11519e934daad10",null),(0,d.A)(v,"40bc3f927e0fe8d759dd0dea9050858496659453f6",null),(0,d.A)(w,"006bc3f553199954dcf2c1a667ea89a5b6afe55440",null),(0,d.A)(x,"402a68b40ff3fcd1dda4de0258b9204475d0ee7d46",null),(0,d.A)(y,"70134ed93c744753cbd112c32720864d9c20816aac",null),(0,d.A)(z,"0020ba3cad47f2e7c8173f78aff33a686a334486c7",null),(0,d.A)(A,"00d896599aa05f6b9b14826b3e2ffa5b7a98370f22",null),(0,d.A)(B,"40d9ef0b5544036e6021cca383858b56347d4c5411",null),(0,d.A)(C,"60e3c5311af1bc54bbb9acfb1fdfd248223c4e1b8d",null),(0,d.A)(D,"002dfa6e2da323d4372c36e94679624da8728b1435",null)},15783:(a,b,c)=>{"use strict";c.d(b,{BackButton:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call BackButton() from the server but BackButton is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\back-button.tsx","BackButton")},16120:(a,b,c)=>{"use strict";c.d(b,{SidebarToggle:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call SidebarToggle() from the server but SidebarToggle is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\sidebar-toggle.tsx","SidebarToggle")},16366:(a,b,c)=>{"use strict";c.d(b,{b:()=>e});var d=c(2910);let e=(0,d.createServerReference)("004d9216cd0b492704be3f3914da6586dd305de8d5",d.callServer,void 0,d.findSourceMapURL,"getDmPreviews")},17309:(a,b,c)=>{"use strict";c.d(b,{RunnerHeartbeat:()=>g});var d=c(74679),e=c(47104),f=c(2910);function g({intervalMs:a=8e3,approved:b=!1,auto247:c=!1}){return(0,e.useRouter)(),(0,d.useRef)(!1),(0,d.useRef)(!1),null}f.callServer,f.findSourceMapURL,f.callServer,f.findSourceMapURL},18462:(a,b,c)=>{"use strict";c.d(b,{G:()=>e});var d=c(2910);let e=(0,d.createServerReference)("0020ba3cad47f2e7c8173f78aff33a686a334486c7",d.callServer,void 0,d.findSourceMapURL,"telegramStatus")},18773:(a,b,c)=>{"use strict";c.d(b,{Toaster:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call Toaster() from the server but Toaster is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\toaster.tsx","Toaster")},20992:(a,b,c)=>{"use strict";c.d(b,{e:()=>e});var d=c(2910);let e=(0,d.createServerReference)("0083096d6b88e89fee2e833270be160a64f9948543",d.callServer,void 0,d.findSourceMapURL,"pollUpdateResult")},23297:(a,b,c)=>{"use strict";c.d(b,{generatePlanFor:()=>u,startNewWorkFor:()=>v});var d=c(77598),e=c(97603),f=c(95357),g=c(31371),h=c(65705),i=c(1890),j=c(70149),k=c(63562),l=c(79505),m=c(57086);let n="specs/SUPER-SPEC.md";async function o(a){let b,{orgId:c,wsId:e,ada:f,binary:g,model:k}=a,o=`You are ${f.name}, analyzing an EXISTING project that is ALREADY present in this workspace (the current directory). Do NOT write any product code, do NOT scaffold anything — your ONLY job is to UNDERSTAND the project and write a thorough "super spec".
73
76
 
74
77
  Read in THIS order, then go deeper:
75
78
  1. Docs first: README*, CHANGELOG*, docs/**, any install/setup/usage guides, CONTRIBUTING.
@@ -135,7 +138,7 @@ How this organization operates. Agents follow this order; code starts only after
135
138
  `),z||await h.db.update(i.plan).set({stage:4,approved:!1}).where((0,e.eq)(i.plan.workspaceId,c.id)),await (0,l.I)(c.id,{runId:u,channel:"planner",agentId:f.id,kind:"done",target:`${Object.keys(U).length} specs \xb7 ${ab} issues drafted`}),await h.db.insert(i.message).values({id:(0,d.randomUUID)(),workspaceId:c.id,channel:"room",fromKind:"agent",fromHandle:f.handle,text:`Plan ready for review: ${Object.keys(U).length} specs and ${ab} issues drafted from the brief. Open the CEO Planner and approve to start execution.`,createdAt:new Date}),await (0,p.I)(c.id,{kind:"done",text:`${f.name} drafted ${z?"a new work plan":"the delivery plan"}`,detail:`${Object.keys(U).length} specs \xb7 ${ab} issues.`,agentId:f.id,tg:!1}),await (0,q.vE)(c.id,{kind:"approval",refType:"plan",refId:c.id,goalId:W,fromAgentId:f.id,channel:"room",title:`Approve plan — ${c.name}`,detail:`${Object.keys(U).length} spec(s) \xb7 ${ab} issue(s) drafted from the brief. Approve to start execution.`});try{let a=await (0,s._9)(c.id);a&&await (0,s.bT)(a.botToken,a.chatId,`📋 Plan ready — ${c.name}
136
139
  ${Object.keys(U).length} spec(s) \xb7 ${ab} issue(s) drafted from the brief.
137
140
 
138
- Approve to queue tasks, or Start execution to also run 24/7.`,[[{text:"✅ Approve",data:"approve_plan"},{text:"▶️ Start execution",data:"start_exec"}],[{text:"\uD83D\uDCDD Review",data:"review"},{text:"↩️ Reject",data:"reject_plan"}]])}catch(a){console.error("[planner] telegram plan-ready push failed:",a)}try{(0,g.revalidatePath)("/planner"),(0,g.revalidatePath)("/inbox"),(0,g.revalidatePath)("/pm"),(0,g.revalidatePath)("/goals")}catch{}}catch(a){console.error("[planner] plan job failed:",a);try{await (0,l.I)(c.id,{runId:u,channel:"planner",agentId:f.id,kind:"error",target:(a?.message??"Planning failed.").slice(0,200)})}catch{}try{await (0,p.I)(c.id,{kind:"info",text:"Planning run failed",detail:(a?.message??"").slice(0,300),agentId:f.id})}catch{}}finally{try{await h.db.update(i.agent).set({status:"idle"}).where((0,e.eq)(i.agent.id,f.id))}catch{}}}},24960:(a,b,c)=>{"use strict";c.d(b,{RunnerHeartbeat:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call RunnerHeartbeat() from the server but RunnerHeartbeat is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\runner-heartbeat.tsx","RunnerHeartbeat")},25497:(a,b,c)=>{"use strict";c.d(b,{b:()=>i});var d=c(24701);let e=/@(operator|you|boss|human)\b/i,f=/@[a-z0-9-]+/i,g=/\b(approv(e|al)?|sign[- ]?off|go[- ]?ahead|your (ok|sign|approval|decision|call)|permission to|need(s|ed)?\s+(your|operator|human|approval)|should i\b|may i\b|can i\s+(proceed|merge|deploy|continue|ship)|waiting (for|on)\s+(you|your|approval|operator)|please\s+(confirm|approve|decide|review))\b/i;var h=c(77558);async function i(a,b){var c;let i,j,k,{mention:l,approvalRequest:m}=(c=b.text,i=e.test(c),j=g.test(c),k=!i&&f.test(c),{mention:i||j&&!k,approvalRequest:j});if(l)try{await (0,d.I)(a,{kind:m?"approval":"mention",text:m?`@${b.agentHandle} needs your approval`:`@${b.agentHandle} mentioned you`,detail:b.text.slice(0,300),agentId:b.agentId,messageId:b.messageId,channel:b.channel}),await (0,h.vE)(a,{kind:m?"approval":"question",refType:"question",refId:b.messageId,fromAgentId:b.agentId??null,channel:b.channel,messageId:b.messageId,title:m?`@${b.agentHandle} needs your approval`:`@${b.agentHandle} asked you`,detail:b.text.slice(0,500)})}catch(a){console.error("[operator-ping] failed:",a)}}},26945:(a,b,c)=>{"use strict";c.d(b,{m:()=>i});var d=c(4374),e=c(14698),f=c(43526),g=c(31819);let h=a=>(a>=1e3?`${(a/1e3).toFixed(1)}k`:String(a))+" tks";function i({stat:a,onCompact:b,compacting:c}){let j=(0,g.k)(),k=2*Math.PI*15,l=Math.min(1,a.used/a.max)*k,m=Math.min(1,a.reserve/a.max)*k,n=a.usedPct>=85?"#e8688f":a.usedPct>=65?"#e0a44e":"#b3d97a",o=a.remainingPct<=35,p=a.used>0&&a.usedPct<1?"<1%":`${a.usedPct}%`;return(0,d.jsxs)("div",{className:"ctx-donut-wrap",children:[(0,d.jsxs)("div",{className:"ctx-donut",tabIndex:0,children:[(0,d.jsxs)("svg",{width:38,height:38,viewBox:"0 0 38 38",children:[(0,d.jsx)("circle",{cx:19,cy:19,r:15,fill:"none",stroke:"var(--border)",strokeWidth:4}),(0,d.jsx)("circle",{cx:19,cy:19,r:15,fill:"none",stroke:n,strokeWidth:4,strokeLinecap:"round",strokeDasharray:`${l} ${k}`,transform:"rotate(-90 19 19)"}),(0,d.jsx)("circle",{cx:19,cy:19,r:15,fill:"none",stroke:"var(--text-faint)",strokeWidth:4,strokeDasharray:`${m} ${k}`,strokeDashoffset:-l,transform:"rotate(-90 19 19)"}),(0,d.jsx)("text",{x:19,y:20,textAnchor:"middle",dominantBaseline:"middle",fontSize:10,fontWeight:700,fill:"var(--text)",children:p})]}),(0,d.jsxs)("div",{className:"ctx-pop",children:[(0,d.jsxs)("div",{className:"ctx-pop-title",children:[(0,d.jsx)(f.I,{name:"pulse",size:12})," ",j("chrome.ctx.title")]}),(0,d.jsxs)("div",{className:"ctx-rows",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{children:j("chrome.ctx.max")}),(0,d.jsx)("b",{children:h(a.max)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{children:j("chrome.ctx.used")}),(0,d.jsxs)("b",{style:{color:n},children:[h(a.used)," \xb7 ",p]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{children:j("chrome.ctx.reserve")}),(0,d.jsxs)("b",{children:[h(a.reserve)," \xb7 ",a.reservePct,"%"]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{children:j("chrome.ctx.remaining")}),(0,d.jsxs)("b",{children:[h(a.remaining)," \xb7 ",a.remainingPct,"%"]})]})]}),a.perAgent.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"ctx-pop-sub",children:j("chrome.ctx.byAgent")}),(0,d.jsx)("div",{className:"ctx-agents",children:a.perAgent.slice(0,8).map(a=>(0,d.jsxs)("div",{className:"ctx-agent",children:[(0,d.jsx)(e.e,{name:a.name,color:a.color,size:18}),(0,d.jsx)("span",{className:"ctx-agent-name",children:a.name}),(0,d.jsx)("span",{className:"ctx-agent-bar",children:(0,d.jsx)("span",{style:{width:`${a.pct}%`,background:a.color}})}),(0,d.jsxs)("span",{className:"ctx-agent-tok",children:[h(a.tokens)," \xb7 ",a.pct,"%",a.usd>0?` \xb7 $${a.usd.toFixed(2)}`:""]})]},a.handle))})]}),(0,d.jsx)("div",{className:"ctx-pop-note",children:j("chrome.ctx.explain")})]})]}),o&&(0,d.jsxs)("button",{className:"ctx-compact",onClick:b,disabled:c,title:j("chrome.ctx.compactHint"),children:[c?(0,d.jsx)("span",{className:"spin",children:(0,d.jsx)(f.I,{name:"refresh",size:12})}):(0,d.jsx)(f.I,{name:"collapse",size:12}),j(c?"chrome.ctx.compacting":"chrome.ctx.compact")]})]})}},28018:(a,b,c)=>{"use strict";c.d(b,{SearchHotkey:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call SearchHotkey() from the server but SearchHotkey is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\search-hotkey.tsx","SearchHotkey")},29517:(a,b,c)=>{"use strict";c.d(b,{M:()=>e});var d=c(2910);let e=(0,d.createServerReference)("706d88c745d18277356678742d9b6b2b19c4f6e86d",d.callServer,void 0,d.findSourceMapURL,"connectTelegram")},29876:(a,b,c)=>{"use strict";c.d(b,{LangSwitch:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call LangSwitch() from the server but LangSwitch is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\lang-switch.tsx","LangSwitch")},30170:(a,b,c)=>{"use strict";function d(){return"1"!==process.env.CONSTELLA_PUBLIC&&"1"===process.env.CONSTELLA_DEV}c.d(b,{n:()=>d})},32825:(a,b,c)=>{"use strict";c.r(b),c.d(b,{AnimToggle:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call AnimToggle() from the server but AnimToggle is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\anim-toggle.tsx","AnimToggle")},33644:(a,b,c)=>{"use strict";c.d(b,{r:()=>g});var d=c(78474);let e=globalThis,f=e.__constellaBus??(e.__constellaBus=new d.EventEmitter);function g(a){f.emit("wake",a)}f.setMaxListeners(64)},34020:(a,b,c)=>{Promise.resolve().then(c.bind(c,35266))},35266:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call the default export of \"C:\\\\Users\\\\Usuario\\\\Documents\\\\constella\\\\src\\\\app\\\\(app)\\\\error.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\app\\(app)\\error.tsx","default")},36250:(a,b,c)=>{"use strict";c.r(b),c.d(b,{advanceIssue:()=>C,approveIssue:()=>z,approvePlan:()=>t,approveSpec:()=>x,generatePlan:()=>D,groomBacklog:()=>v,groomBacklogFor:()=>u,planFromConversation:()=>F,rejectIssue:()=>A,rejectSpec:()=>y,requestPlanChanges:()=>w,setAuto247:()=>B,startNewWork:()=>E});var d=c(6866),e=c(77598),f=c(97603),g=c(95357),h=c(31371),i=c(65705),j=c(1890),k=c(53993),l=c(70149),m=c(24701),n=c(84903),o=c(77558),p=c(57086),q=c(13328),r=c(23297),s=c(56338);async function t(){let{org:a,workspace:b}=await (0,k.nP)();await (0,q.wz)(a.id,b),(0,h.revalidatePath)("/planner"),(0,h.revalidatePath)("/pm"),(0,h.revalidatePath)("/tasks"),(0,h.revalidatePath)("/inbox"),(0,h.revalidatePath)("/","layout")}async function u(a,b){let c,d=await i.db.select().from(j.agent).where((0,f.eq)(j.agent.workspaceId,b.id)),h=d.find(a=>"donald"===a.handle)??d.find(a=>/product owner|\bpo\b|product manager/i.test(a.role));if(!h)return{ok:!1,error:"No Product Owner agent in this workspace."};let k=(await i.db.select().from(j.issue).where((0,f.Uo)((0,f.eq)(j.issue.workspaceId,b.id),(0,f.eq)(j.issue.status,"active")))).filter(a=>"done"!==a.col);if(!k.length)return{ok:!1,error:"No active issues to groom."};let m=(0,l.hW)(h.adapter,h.model),p="claude"===m?h.model.includes("opus")?"opus":h.model.includes("haiku")?"haiku":"sonnet":void 0,q=Object.fromEntries((await i.db.select({id:j.spec.id,summary:j.spec.summary}).from(j.spec).where((0,f.eq)(j.spec.workspaceId,b.id))).map(a=>[a.id,a.summary])),r=k.map(a=>`- ${a.key}: ${a.title}${a.specId&&q[a.specId]?` — spec: ${String(q[a.specId]).slice(0,120)}`:""} (current priority: ${a.prio})`).join("\n"),t=await (0,s.yY)(a,`product objectives, existing features and code, prior decisions, duplicate or overlapping requirements for: ${k.map(a=>a.title).slice(0,12).join("; ")}`,{agentHandle:h.handle,k:8}),u=t.context?`
141
+ Approve to queue tasks, or Start execution to also run 24/7.`,[[{text:"✅ Approve",data:"approve_plan"},{text:"▶️ Start execution",data:"start_exec"}],[{text:"\uD83D\uDCDD Review",data:"review"},{text:"↩️ Reject",data:"reject_plan"}]])}catch(a){console.error("[planner] telegram plan-ready push failed:",a)}try{(0,g.revalidatePath)("/planner"),(0,g.revalidatePath)("/inbox"),(0,g.revalidatePath)("/pm"),(0,g.revalidatePath)("/goals")}catch{}}catch(a){console.error("[planner] plan job failed:",a);try{await (0,l.I)(c.id,{runId:u,channel:"planner",agentId:f.id,kind:"error",target:(a?.message??"Planning failed.").slice(0,200)})}catch{}try{await (0,p.I)(c.id,{kind:"info",text:"Planning run failed",detail:(a?.message??"").slice(0,300),agentId:f.id})}catch{}}finally{try{await h.db.update(i.agent).set({status:"idle"}).where((0,e.eq)(i.agent.id,f.id))}catch{}}}},24746:(a,b,c)=>{"use strict";c.d(b,{l:()=>e});var d=c(2910);let e=(0,d.createServerReference)("405ee9cc58fe89e8c6f9f1f265a850575a129a7936",d.callServer,void 0,d.findSourceMapURL,"getUpdateState")},24960:(a,b,c)=>{"use strict";c.d(b,{RunnerHeartbeat:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call RunnerHeartbeat() from the server but RunnerHeartbeat is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\runner-heartbeat.tsx","RunnerHeartbeat")},25497:(a,b,c)=>{"use strict";c.d(b,{b:()=>i});var d=c(24701);let e=/@(operator|you|boss|human)\b/i,f=/@[a-z0-9-]+/i,g=/\b(approv(e|al)?|sign[- ]?off|go[- ]?ahead|your (ok|sign|approval|decision|call)|permission to|need(s|ed)?\s+(your|operator|human|approval)|should i\b|may i\b|can i\s+(proceed|merge|deploy|continue|ship)|waiting (for|on)\s+(you|your|approval|operator)|please\s+(confirm|approve|decide|review))\b/i;var h=c(77558);async function i(a,b){var c;let i,j,k,{mention:l,approvalRequest:m}=(c=b.text,i=e.test(c),j=g.test(c),k=!i&&f.test(c),{mention:i||j&&!k,approvalRequest:j});if(l)try{await (0,d.I)(a,{kind:m?"approval":"mention",text:m?`@${b.agentHandle} needs your approval`:`@${b.agentHandle} mentioned you`,detail:b.text.slice(0,300),agentId:b.agentId,messageId:b.messageId,channel:b.channel}),await (0,h.vE)(a,{kind:m?"approval":"question",refType:"question",refId:b.messageId,fromAgentId:b.agentId??null,channel:b.channel,messageId:b.messageId,title:m?`@${b.agentHandle} needs your approval`:`@${b.agentHandle} asked you`,detail:b.text.slice(0,500)})}catch(a){console.error("[operator-ping] failed:",a)}}},26331:(a,b,c)=>{"use strict";c.r(b),c.d(b,{AnimToggle:()=>k});var d=c(4374),e=c(74679),f=c(47104),g=c(43526),h=c(31819),i=c(2910);let j=(0,i.createServerReference)("0020ee1e4504363fce8f1b7fda9b92e0b5f0073be2",i.callServer,void 0,i.findSourceMapURL,"toggleAnim");function k({labeled:a}){let b=(0,h.k)(),c=(0,f.useRouter)(),[i,l]=(0,e.useState)(!0),[m,n]=(0,e.useTransition)(),o=()=>n(async()=>{await j(),l(a=>!a),c.refresh()});return a?(0,d.jsxs)("button",{className:"btn-ghost",onClick:o,disabled:m,type:"button",style:{gap:8},children:[(0,d.jsx)(g.I,{name:"pulse",size:14,style:{opacity:i?1:.4}})," ",b("chrome.anim.label",{state:b(i?"common.on":"common.off")})]}):(0,d.jsx)("button",{className:"top-btn",onClick:o,disabled:m,type:"button",title:b(i?"chrome.anim.titleOn":"chrome.anim.titleOff"),children:(0,d.jsx)(g.I,{name:"pulse",size:17,style:{opacity:i?1:.4}})})}},26945:(a,b,c)=>{"use strict";c.d(b,{m:()=>i});var d=c(4374),e=c(14698),f=c(43526),g=c(31819);let h=a=>(a>=1e3?`${(a/1e3).toFixed(1)}k`:String(a))+" tks";function i({stat:a,onCompact:b,compacting:c}){let j=(0,g.k)(),k=2*Math.PI*15,l=Math.min(1,a.used/a.max)*k,m=Math.min(1,a.reserve/a.max)*k,n=a.usedPct>=85?"#e8688f":a.usedPct>=65?"#e0a44e":"#b3d97a",o=a.remainingPct<=35,p=a.used>0&&a.usedPct<1?"<1%":`${a.usedPct}%`;return(0,d.jsxs)("div",{className:"ctx-donut-wrap",children:[(0,d.jsxs)("div",{className:"ctx-donut",tabIndex:0,children:[(0,d.jsxs)("svg",{width:38,height:38,viewBox:"0 0 38 38",children:[(0,d.jsx)("circle",{cx:19,cy:19,r:15,fill:"none",stroke:"var(--border)",strokeWidth:4}),(0,d.jsx)("circle",{cx:19,cy:19,r:15,fill:"none",stroke:n,strokeWidth:4,strokeLinecap:"round",strokeDasharray:`${l} ${k}`,transform:"rotate(-90 19 19)"}),(0,d.jsx)("circle",{cx:19,cy:19,r:15,fill:"none",stroke:"var(--text-faint)",strokeWidth:4,strokeDasharray:`${m} ${k}`,strokeDashoffset:-l,transform:"rotate(-90 19 19)"}),(0,d.jsx)("text",{x:19,y:20,textAnchor:"middle",dominantBaseline:"middle",fontSize:10,fontWeight:700,fill:"var(--text)",children:p})]}),(0,d.jsxs)("div",{className:"ctx-pop",children:[(0,d.jsxs)("div",{className:"ctx-pop-title",children:[(0,d.jsx)(f.I,{name:"pulse",size:12})," ",j("chrome.ctx.title")]}),(0,d.jsxs)("div",{className:"ctx-rows",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{children:j("chrome.ctx.max")}),(0,d.jsx)("b",{children:h(a.max)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{children:j("chrome.ctx.used")}),(0,d.jsxs)("b",{style:{color:n},children:[h(a.used)," \xb7 ",p]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{children:j("chrome.ctx.reserve")}),(0,d.jsxs)("b",{children:[h(a.reserve)," \xb7 ",a.reservePct,"%"]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{children:j("chrome.ctx.remaining")}),(0,d.jsxs)("b",{children:[h(a.remaining)," \xb7 ",a.remainingPct,"%"]})]})]}),a.perAgent.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"ctx-pop-sub",children:j("chrome.ctx.byAgent")}),(0,d.jsx)("div",{className:"ctx-agents",children:a.perAgent.slice(0,8).map(a=>(0,d.jsxs)("div",{className:"ctx-agent",children:[(0,d.jsx)(e.e,{name:a.name,color:a.color,size:18}),(0,d.jsx)("span",{className:"ctx-agent-name",children:a.name}),(0,d.jsx)("span",{className:"ctx-agent-bar",children:(0,d.jsx)("span",{style:{width:`${a.pct}%`,background:a.color}})}),(0,d.jsxs)("span",{className:"ctx-agent-tok",children:[h(a.tokens)," \xb7 ",a.pct,"%",a.usd>0?` \xb7 $${a.usd.toFixed(2)}`:""]})]},a.handle))})]}),(0,d.jsx)("div",{className:"ctx-pop-note",children:j("chrome.ctx.explain")})]})]}),o&&(0,d.jsxs)("button",{className:"ctx-compact",onClick:b,disabled:c,title:j("chrome.ctx.compactHint"),children:[c?(0,d.jsx)("span",{className:"spin",children:(0,d.jsx)(f.I,{name:"refresh",size:12})}):(0,d.jsx)(f.I,{name:"collapse",size:12}),j(c?"chrome.ctx.compacting":"chrome.ctx.compact")]})]})}},27326:(a,b,c)=>{"use strict";c.d(b,{k:()=>e});var d=c(2910);let e=(0,d.createServerReference)("60274f514b61483b6e070a65f4817ee1ad9fe43504",d.callServer,void 0,d.findSourceMapURL,"getEvents")},28018:(a,b,c)=>{"use strict";c.d(b,{SearchHotkey:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call SearchHotkey() from the server but SearchHotkey is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\search-hotkey.tsx","SearchHotkey")},29876:(a,b,c)=>{"use strict";c.d(b,{LangSwitch:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call LangSwitch() from the server but LangSwitch is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\lang-switch.tsx","LangSwitch")},30170:(a,b,c)=>{"use strict";function d(){return"1"!==process.env.CONSTELLA_PUBLIC&&"1"===process.env.CONSTELLA_DEV}c.d(b,{n:()=>d})},32825:(a,b,c)=>{"use strict";c.r(b),c.d(b,{AnimToggle:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call AnimToggle() from the server but AnimToggle is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\anim-toggle.tsx","AnimToggle")},33644:(a,b,c)=>{"use strict";c.d(b,{r:()=>g});var d=c(78474);let e=globalThis,f=e.__constellaBus??(e.__constellaBus=new d.EventEmitter);function g(a){f.emit("wake",a)}f.setMaxListeners(64)},34020:(a,b,c)=>{Promise.resolve().then(c.bind(c,35266))},35266:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call the default export of \"C:\\\\Users\\\\Usuario\\\\Documents\\\\constella\\\\src\\\\app\\\\(app)\\\\error.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\app\\(app)\\error.tsx","default")},36250:(a,b,c)=>{"use strict";c.r(b),c.d(b,{advanceIssue:()=>C,approveIssue:()=>z,approvePlan:()=>t,approveSpec:()=>x,generatePlan:()=>D,groomBacklog:()=>v,groomBacklogFor:()=>u,planFromConversation:()=>F,rejectIssue:()=>A,rejectSpec:()=>y,requestPlanChanges:()=>w,setAuto247:()=>B,startNewWork:()=>E});var d=c(6866),e=c(77598),f=c(97603),g=c(95357),h=c(31371),i=c(65705),j=c(1890),k=c(53993),l=c(70149),m=c(24701),n=c(84903),o=c(77558),p=c(57086),q=c(13328),r=c(23297),s=c(56338);async function t(){let{org:a,workspace:b}=await (0,k.nP)();await (0,q.wz)(a.id,b),(0,h.revalidatePath)("/planner"),(0,h.revalidatePath)("/pm"),(0,h.revalidatePath)("/tasks"),(0,h.revalidatePath)("/inbox"),(0,h.revalidatePath)("/","layout")}async function u(a,b){let c,d=await i.db.select().from(j.agent).where((0,f.eq)(j.agent.workspaceId,b.id)),h=d.find(a=>"donald"===a.handle)??d.find(a=>/product owner|\bpo\b|product manager/i.test(a.role));if(!h)return{ok:!1,error:"No Product Owner agent in this workspace."};let k=(await i.db.select().from(j.issue).where((0,f.Uo)((0,f.eq)(j.issue.workspaceId,b.id),(0,f.eq)(j.issue.status,"active")))).filter(a=>"done"!==a.col);if(!k.length)return{ok:!1,error:"No active issues to groom."};let m=(0,l.hW)(h.adapter,h.model),p="claude"===m?h.model.includes("opus")?"opus":h.model.includes("haiku")?"haiku":"sonnet":void 0,q=Object.fromEntries((await i.db.select({id:j.spec.id,summary:j.spec.summary}).from(j.spec).where((0,f.eq)(j.spec.workspaceId,b.id))).map(a=>[a.id,a.summary])),r=k.map(a=>`- ${a.key}: ${a.title}${a.specId&&q[a.specId]?` — spec: ${String(q[a.specId]).slice(0,120)}`:""} (current priority: ${a.prio})`).join("\n"),t=await (0,s.yY)(a,`product objectives, existing features and code, prior decisions, duplicate or overlapping requirements for: ${k.map(a=>a.title).slice(0,12).join("; ")}`,{agentHandle:h.handle,k:8}),u=t.context?`
139
142
  Project knowledge (objectives, existing work, prior decisions — use it to avoid duplicates and spot gaps; do not contradict):
140
143
  ${t.context}`:"",v=await i.db.select({text:j.decision.text,by:j.decision.by}).from(j.decision).where((0,f.eq)(j.decision.workspaceId,b.id)).orderBy((0,g.i)(j.decision.createdAt)).limit(12),w=v.length?`
141
144
  Recent decisions:
@@ -145,10 +148,7 @@ ${r}`,`
145
148
  Output ONLY a JSON object (no prose, no markdown fences): {"estimates":[{"key":"1","points":5,"moscow":"Must","duplicateOf":"3"}],"gaps":["a missing issue the objectives need"]} — one estimate per issue above, "points" one of 1,2,3,5,8,13, "duplicateOf" optional, "gaps" optional.`].filter(Boolean).join("\n");await i.db.update(j.agent).set({status:"working"}).where((0,f.eq)(j.agent.id,h.id));try{c=await (0,l.p1)(x,{orgId:a,binary:m,model:p,timeoutMs:12e4},()=>{})}finally{try{await i.db.update(j.agent).set({status:"idle"}).where((0,f.eq)(j.agent.id,h.id))}catch{}}(c.usd>0||c.inputTokens+c.outputTokens>0)&&await i.db.insert(j.costEntry).values({id:(0,e.randomUUID)(),workspaceId:b.id,agentId:h.id,provider:c.binary,model:c.model??h.model,usd:c.usd,tokens:c.inputTokens+c.outputTokens,at:new Date});let y=[],z=[],A=c.text.match(/\{[\s\S]*\}|\[[\s\S]*\]/);if(A)try{let a=JSON.parse(A[0]);Array.isArray(a)?y=a:(y=Array.isArray(a.estimates)?a.estimates:[],z=Array.isArray(a.gaps)?a.gaps.map(String).slice(0,8):[])}catch{y=[]}if(!Array.isArray(y)||!y.length)return{ok:!1,error:"The PO returned no parseable estimates — try again."};let B=new Set([1,2,3,5,8,13]),C=new Set(["Must","Should","Could","Won't"]),D=Object.fromEntries(k.map(a=>[String(a.key),a.id])),E=0;for(let a of y){let b=D[String(a.key)];if(!b)continue;let c="number"==typeof a.points?Math.round(a.points):NaN,d=B.has(c)?c:void 0,e="string"==typeof a.moscow&&C.has(a.moscow)?a.moscow:void 0;(void 0!==d||e)&&(await i.db.update(j.issue).set({...void 0!==d?{points:d}:{},...e?{moscow:e}:{}}).where((0,f.eq)(j.issue.id,b)),E++)}if(E){for(let a of(await i.db.select().from(j.issue).where((0,f.Uo)((0,f.eq)(j.issue.workspaceId,b.id),(0,f.eq)(j.issue.status,"active")))))await i.db.update(j.backlogItem).set({points:a.points,moscow:a.moscow??"Should"}).where((0,f.Uo)((0,f.eq)(j.backlogItem.workspaceId,b.id),(0,f.eq)(j.backlogItem.title,a.title)));await i.db.insert(j.message).values({id:(0,e.randomUUID)(),workspaceId:b.id,channel:"room",fromKind:"agent",fromHandle:h.handle,text:`Backlog groomed — estimated story points + MoSCoW for ${E} issue${1===E?"":"s"}. Open the Product Manager to review.`,createdAt:new Date}),await (0,n.j)(b.id,{text:`Backlog groomed by ${h.name} — sized ${E} issue(s)`,by:h.handle,source:"po-grooming"})}let F=y.filter(a=>null!=a.duplicateOf&&D[String(a.duplicateOf)]&&D[String(a.key)]&&String(a.duplicateOf)!==String(a.key)).map(a=>`${a.key} ↔ ${a.duplicateOf}`);if(F.length||z.length){let a=[];F.length&&a.push(`Possible duplicate / overlapping issues: ${F.join(", ")}.`),z.length&&a.push(`Gaps the objectives need:
146
149
  ${z.map(a=>`- ${a}`).join("\n")}`);let c=a.join("\n\n");await i.db.insert(j.message).values({id:(0,e.randomUUID)(),workspaceId:b.id,channel:"room",fromKind:"agent",fromHandle:h.handle,text:`Backlog review — ${c}`.slice(0,4e3),createdAt:new Date}),await (0,o.vE)(b.id,{kind:"review",fromAgentId:h.id,title:`PO backlog review — ${F.length} duplicate, ${z.length} gap`,detail:c.slice(0,500)}),await (0,n.j)(b.id,{text:`PO flagged ${F.length} duplicate + ${z.length} gap during grooming`,by:h.handle,source:"po-grooming"})}return{ok:!0,groomed:E}}async function v(){let{org:a,workspace:b}=await (0,k.nP)(),c=await u(a.id,b);return(0,h.revalidatePath)("/pm"),(0,h.revalidatePath)("/planner"),(0,h.revalidatePath)("/","layout"),c}async function w(){let{workspace:a}=await (0,k.nP)();await (0,q.TR)(a.id),(0,h.revalidatePath)("/planner"),(0,h.revalidatePath)("/inbox")}async function x(a){let{workspace:b}=await (0,k.nP)();await i.db.update(j.spec).set({approved:!0}).where((0,f.Uo)((0,f.eq)(j.spec.id,a),(0,f.eq)(j.spec.workspaceId,b.id))),await (0,o.W_)(b.id,"spec",a),(0,h.revalidatePath)("/planner"),(0,h.revalidatePath)("/inbox")}async function y(a){let{workspace:b}=await (0,k.nP)(),[c]=await i.db.select().from(j.spec).where((0,f.Uo)((0,f.eq)(j.spec.id,a),(0,f.eq)(j.spec.workspaceId,b.id)));await i.db.update(j.spec).set({approved:!1}).where((0,f.eq)(j.spec.id,a));let d="ada",e=null;if(c?.authorId){let[a]=await i.db.select().from(j.agent).where((0,f.eq)(j.agent.id,c.authorId));a&&(d=a.handle,e=a.id)}return await (0,m.I)(b.id,{kind:"review",text:`Spec ${c?.key??""} sent back for revision`,detail:"The operator rejected this spec."}),await (0,o.vE)(b.id,{kind:"review",refType:"spec",refId:a,goalId:c?.goalId??null,fromAgentId:e,title:`Revise spec ${c?.key??""}`,detail:`Rejected — @${d} should revise “${c?.title??""}”.`}),(0,h.revalidatePath)("/planner"),(0,h.revalidatePath)("/inbox"),{handle:d,key:c?.key??"spec"}}async function z(a){let{org:b,workspace:c}=await (0,k.nP)(),[d]=await i.db.update(j.issue).set({approved:!0}).where((0,f.Uo)((0,f.eq)(j.issue.id,a),(0,f.eq)(j.issue.workspaceId,c.id))).returning();if(d?.key){let a=(0,p.sL)(b.id,`issues/${d.key}.md`);a&&(0,p.dx)(b.id,`issues/${d.key}.md`,a.replace(/\*\*Status:\*\* .*/m,"**Status:** approved"))}await (0,o.W_)(c.id,"issue",a),(0,h.revalidatePath)("/pm"),(0,h.revalidatePath)("/planner"),(0,h.revalidatePath)("/inbox")}async function A(a){let{workspace:b}=await (0,k.nP)(),[c]=await i.db.select().from(j.issue).where((0,f.Uo)((0,f.eq)(j.issue.id,a),(0,f.eq)(j.issue.workspaceId,b.id)));await i.db.update(j.issue).set({approved:!1}).where((0,f.eq)(j.issue.id,a));let d="donald",e=null;if(c?.assigneeId){let[a]=await i.db.select().from(j.agent).where((0,f.eq)(j.agent.id,c.assigneeId));a&&(d=a.handle,e=a.id)}return await (0,m.I)(b.id,{kind:"review",text:`Issue ${c?.key??""} sent back for revision`,detail:"The operator rejected this issue."}),await (0,o.vE)(b.id,{kind:"review",refType:"issue",refId:a,goalId:c?.goalId??null,fromAgentId:e,title:`Revise issue ${c?.key??""}`,detail:`Rejected — @${d} should revise “${c?.title??""}”.`}),(0,h.revalidatePath)("/pm"),(0,h.revalidatePath)("/planner"),(0,h.revalidatePath)("/inbox"),{handle:d,key:c?.key??"issue"}}async function B(a){let{workspace:b}=await (0,k.nP)();await (0,q.mL)(b.id,a),(0,h.revalidatePath)("/planner")}async function C(a){let{workspace:b}=await (0,k.nP)(),c=["todo","doing","review","done"],[d]=await i.db.select().from(j.issue).where((0,f.Uo)((0,f.eq)(j.issue.id,a),(0,f.eq)(j.issue.workspaceId,b.id)));if(!d||"done"===d.col||"blocked"===d.col)return;let e=c[c.indexOf(d.col)+1]??"done";await i.db.update(j.issue).set({col:e}).where((0,f.eq)(j.issue.id,a)),"done"===e&&await (0,m.I)(b.id,{kind:"test",text:`${d.key} merged — ${d.title}`,detail:"QA passed and the issue was merged.",tg:!0}),(0,h.revalidatePath)("/planner")}async function D(a){let{org:b,workspace:c}=await (0,k.nP)();return(0,r.generatePlanFor)(b.id,c,a)}async function E(a){let b=a.brief?.trim();return b?D({brief:b,goalTitle:a.title?.trim()||void 0}):{ok:!1,error:"Describe what you want to implement, fix or change."}}async function F(a){let{workspace:b}=await (0,k.nP)(),c=(await i.db.select().from(j.message).where((0,f.Uo)((0,f.eq)(j.message.workspaceId,b.id),(0,f.eq)(j.message.channel,a))).orderBy((0,g.Y)(j.message.createdAt))).slice(-30).map(a=>("operator"===a.fromKind?"Operator":"@"+(a.fromHandle??"agent"))+": "+a.text).join("\n");return c.trim()?D({brief:`Turn the operator's request from this chat into a delivery plan. Conversation:
147
150
 
148
- ${c}`}):{ok:!1,error:"No conversation to plan from yet."}}(0,c(74252).D)([t,u,v,w,x,y,z,A,B,C,D,E,F]),(0,d.A)(t,"003febf4e7267ca98f9eb9b6dc436d9a4e2b65e7ca",null),(0,d.A)(u,"60eb6b77d80b13f25b83a55396fb595ef8099342e7",null),(0,d.A)(v,"0013275f5daef5cf97d9d2a604a968874bb91db236",null),(0,d.A)(w,"005cb5bb28bc19f2d5ed503834ad00dc741d78a51d",null),(0,d.A)(x,"40278c98b65eb6a42ba19ed36299f6ada32c9eea34",null),(0,d.A)(y,"409c5ecd26ccaec10a2e66bce9e702bf46d8cc21e0",null),(0,d.A)(z,"40aa8d10fe1fc7b3d00fb58cf6686d7e66a57a82de",null),(0,d.A)(A,"4067ca80a5da742c05fbb50e0a730ae4a24a79b000",null),(0,d.A)(B,"4096425e44cce93bbec45707a6319457d2f7f2d3cb",null),(0,d.A)(C,"4049840f63a4a408162f9433c695913d7d732f0cc3",null),(0,d.A)(D,"40a5db20e92cac0094f3ce6250a17ec8d42fc4d887",null),(0,d.A)(E,"409cee80b303bd917177f77ad49c5e1746aca73a8a",null),(0,d.A)(F,"408d0690db0d1f458d2753a2a425c6d0588dddbf99",null)},36482:(a,b,c)=>{"use strict";c.d(b,{f:()=>h});var d=c(97603),e=c(95357),f=c(65705),g=c(1890);async function h(a,b,c){try{await f.db.delete(g.event).where((0,d.Uo)((0,d.eq)(g.event.workspaceId,a),(0,d.eq)(g.event.runId,b),(0,d.eq)(g.event.kind,"text")));let h=await f.db.select({seq:g.event.seq}).from(g.event).where((0,d.Uo)((0,d.eq)(g.event.workspaceId,a),(0,d.eq)(g.event.channel,c))).orderBy((0,e.i)(g.event.seq)).limit(500);if(500===h.length){let b=h[h.length-1].seq;await f.db.delete(g.event).where((0,d.Uo)((0,d.eq)(g.event.workspaceId,a),(0,d.eq)(g.event.channel,c),(0,d.lt)(g.event.seq,b)))}}catch(a){console.error("[events-prune] failed:",a)}}},38273:(a,b,c)=>{"use strict";c.d(b,{V:()=>e});var d=c(2910);let e=(0,d.createServerReference)("003d1836382188603c5b40a8fd0c7735cec69e7922",d.callServer,void 0,d.findSourceMapURL,"seedDefaultBlocksAction")},41014:(a,b,c)=>{"use strict";c.d(b,{Toaster:()=>j});var d=c(4374),e=c(74679),f=c(47104),g=c(43526),h=c(31819),i=c(2910);function j(){let a=(0,h.k)(),[b,c]=(0,e.useState)([]);(0,e.useRef)(0),(0,e.useRef)(new Set);let i=(0,f.useRouter)();function j(a){c(b=>b.filter(b=>b.id!==a))}return b.length?(0,d.jsx)("div",{className:"toaster",children:b.map(b=>{var c;return(0,d.jsxs)("div",{className:"toast toast-"+b.kind,role:"status",onClick:()=>{var a,c;(j((a=b).id),a.channel&&("room"===(c=a.channel)||"telegram"===c||c.startsWith("dm:")))?window.dispatchEvent(new CustomEvent("constella:open-chat",{detail:{channel:a.channel}})):i.push("/notifications")},children:[(0,d.jsx)("span",{className:"toast-ic",children:(0,d.jsx)(g.I,{name:"approval"===(c=b.kind)||"needs-approval"===c?"inbox":"security"===c||"block"===c||"blocked"===c?"shield":"deploy"===c?"goto":"error"===c||"warn"===c||"warning"===c?"warn":c.startsWith("dm")||"mention"===c||"message"===c?"chat":"bell",size:15})}),(0,d.jsxs)("div",{className:"toast-body",children:[(0,d.jsx)("div",{className:"toast-title",children:b.text}),b.detail&&(0,d.jsx)("div",{className:"toast-detail",children:b.detail})]}),(0,d.jsx)("button",{className:"toast-x",title:a("common.dismiss"),onClick:a=>{a.stopPropagation(),j(b.id)},children:(0,d.jsx)(g.I,{name:"close",size:12})})]},b.id)})}):null}i.callServer,i.findSourceMapURL},42328:(a,b,c)=>{"use strict";c.d(b,{UpdateHeaderBadge:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call UpdateHeaderBadge() from the server but UpdateHeaderBadge is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\update-header-badge.tsx","UpdateHeaderBadge")},44964:(a,b,c)=>{"use strict";c.d(b,{p:()=>e});var d=c(2910);let e=(0,d.createServerReference)("40972d5b822e66513389d5179af32bb5f9ab77ca88",d.callServer,void 0,d.findSourceMapURL,"conversationContext")},45125:(a,b,c)=>{"use strict";c.d(b,{Jb:()=>m,OL:()=>n,RL:()=>k,WU:()=>l,X0:()=>j,xF:()=>i});var d=c(77598),e=c(97603),f=c(95357),g=c(65705),h=c(1890);async function i(a,b){if(!b.startsWith("dm:"))return null;let[c]=await g.db.select().from(h.chatSession).where((0,e.Uo)((0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b),(0,e.eq)(h.chatSession.active,!0)));if(c)return c.id;let i=await g.db.select().from(h.chatSession).where((0,e.Uo)((0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b))).orderBy((0,f.i)(h.chatSession.createdAt));if(i.length)return await g.db.update(h.chatSession).set({active:!0}).where((0,e.eq)(h.chatSession.id,i[0].id)),i[0].id;let j=(0,d.randomUUID)();return await g.db.insert(h.chatSession).values({id:j,workspaceId:a,channel:b,title:"Session 1",active:!0}),await g.db.update(h.message).set({sessionId:j}).where((0,e.Uo)((0,e.eq)(h.message.workspaceId,a),(0,e.eq)(h.message.channel,b),(0,e.kZ)(h.message.sessionId))),j}async function j(a,b){return b.startsWith("dm:")?(await i(a,b),(await g.db.select().from(h.chatSession).where((0,e.Uo)((0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b))).orderBy((0,f.i)(h.chatSession.createdAt))).map(a=>({id:a.id,title:a.title,active:a.active,createdAt:(a.createdAt instanceof Date?a.createdAt.getTime():1e3*Number(a.createdAt))||0}))):[]}async function k(a,b,c){if(!b.startsWith("dm:"))return null;await i(a,b);let f=(await g.db.select({id:h.chatSession.id}).from(h.chatSession).where((0,e.Uo)((0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b)))).length,j=(0,d.randomUUID)();return await g.db.update(h.chatSession).set({active:!1}).where((0,e.Uo)((0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b))),await g.db.insert(h.chatSession).values({id:j,workspaceId:a,channel:b,title:c?.trim()||`Session ${f+1}`,active:!0}),j}async function l(a,b,c){let[d]=await g.db.select().from(h.chatSession).where((0,e.Uo)((0,e.eq)(h.chatSession.id,c),(0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b)));d&&(await g.db.update(h.chatSession).set({active:!1}).where((0,e.Uo)((0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b))),await g.db.update(h.chatSession).set({active:!0}).where((0,e.eq)(h.chatSession.id,c)))}async function m(a,b,c){await g.db.update(h.chatSession).set({title:c.trim().slice(0,60)||"Session"}).where((0,e.Uo)((0,e.eq)(h.chatSession.id,b),(0,e.eq)(h.chatSession.workspaceId,a)))}async function n(a,b,c){if(!b.startsWith("dm:"))return;let[d]=await g.db.select().from(h.chatSession).where((0,e.Uo)((0,e.eq)(h.chatSession.id,c),(0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b)));if(d&&(await g.db.delete(h.message).where((0,e.Uo)((0,e.eq)(h.message.workspaceId,a),(0,e.eq)(h.message.sessionId,c))),await g.db.delete(h.chatSession).where((0,e.eq)(h.chatSession.id,c)),d.active)){let[c]=await g.db.select().from(h.chatSession).where((0,e.Uo)((0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b))).orderBy((0,f.i)(h.chatSession.createdAt));c&&await g.db.update(h.chatSession).set({active:!0}).where((0,e.eq)(h.chatSession.id,c.id))}}},45912:(a,b,c)=>{"use strict";c.d(b,{uG:()=>F,QE:()=>D,CZ:()=>E});var d=c(4374),e=c(74679),f=c(2910);f.callServer,f.findSourceMapURL,c(55357);let g=(0,f.createServerReference)("4049b65fc61de5f15ea027c832048d695017a2cadc",f.callServer,void 0,f.findSourceMapURL,"listSessions"),h=(0,f.createServerReference)("60e9b223d15847a611ea2b6fdf59614eceb4151ee9",f.callServer,void 0,f.findSourceMapURL,"createSession"),i=(0,f.createServerReference)("60581df9364a1b92ebc0d853d7c78efa696792047f",f.callServer,void 0,f.findSourceMapURL,"switchSession"),j=(0,f.createServerReference)("600d82e3d7031f663a63e6110ba9f565e1925bac77",f.callServer,void 0,f.findSourceMapURL,"renameSession"),k=(0,f.createServerReference)("60301fe28cb811b08550b91045a0558179995780c0",f.callServer,void 0,f.findSourceMapURL,"deleteSession");var l=c(72507),m=c(78282),n=c(1684),o=c(21985),p=c(31819),q=c(29517),r=c(62565),s=c(12325);c(14631);var t=c(44964),u=c(65636);let v=(0,f.createServerReference)("00cdd261029ea6d12df690e0b43e69818dbfeca142",f.callServer,void 0,f.findSourceMapURL,"getChatNotifications"),w=(0,f.createServerReference)("00e68579200e3df5cde1803035a93f8406aa41e3b0",f.callServer,void 0,f.findSourceMapURL,"getUnreadCounts");f.callServer,f.findSourceMapURL;let x=(0,f.createServerReference)("40a6b782c452b9d7da8220c5630efb6277ba4077a1",f.callServer,void 0,f.findSourceMapURL,"markNotifRead");var y=c(14698),z=c(43526),A=c(69626),B=c(26945),C=c(49137);function D({agents:a,previews:b,onOpenDM:c}){let f=(0,p.k)(),[g,h]=(0,e.useState)(""),i=g.trim().toLowerCase(),j=a.filter(a=>!i||a.name.toLowerCase().includes(i)||a.handle.includes(i)||a.role.toLowerCase().includes(i));return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"dm-search",children:[(0,d.jsx)(z.I,{name:"search",size:13}),(0,d.jsx)("input",{placeholder:f("chat.searchAgents"),value:g,onChange:a=>h(a.target.value),autoFocus:!0})]}),(0,d.jsxs)("div",{className:"people-list scroll",children:[0===j.length&&(0,d.jsx)("div",{className:"mention-empty",children:f("chat.noAgentMatch",{q:g})}),j.map(a=>{let e=b[a.handle];return(0,d.jsxs)("div",{className:"people-row",onClick:()=>c(a.handle),children:[(0,d.jsx)(y.e,{name:a.name,color:a.color,image:a.image,size:36,health:a.health}),(0,d.jsxs)("div",{className:"people-meta",children:[(0,d.jsxs)("div",{className:"people-name",style:{display:"flex",alignItems:"center",gap:6},children:[a.name," ",(0,d.jsxs)("span",{className:"agent-handle",children:["@",a.handle]})," ","idle"!==a.status&&(0,d.jsx)(A.m,{status:a.status})]}),(0,d.jsx)("div",{className:"people-sub"+(e?" preview":""),children:e?(e.mine?f("chat.youPrefix"):"")+(e.text||"…"):`${a.role} \xb7 ${a.adapter}`})]}),(0,d.jsx)("span",{className:"people-go",children:(0,d.jsx)(z.I,{name:e?"chat":"chevronRight",size:14})})]},a.handle)})]})]})}function E({onConnected:a}){let b=(0,p.k)(),[c,f]=(0,e.useState)(""),[g,h]=(0,e.useState)(""),[i,j]=(0,e.useState)(""),[k,l]=(0,e.useState)(""),[m,n]=(0,e.useState)(""),[o,r]=(0,e.useTransition)();return(0,d.jsx)("div",{className:"tg-connect scroll",children:(0,d.jsxs)("div",{className:"tg-card",children:[(0,d.jsxs)("div",{className:"tg-card-head",children:[(0,d.jsx)("span",{className:"tg-card-ico",children:(0,d.jsx)(z.I,{name:"send",size:18})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"tg-card-title",children:b("chat.tg.connectTitle")}),(0,d.jsx)("div",{className:"tg-card-sub",children:b("chat.tg.connectSub")})]})]}),(0,d.jsxs)("ol",{className:"tg-steps",children:[(0,d.jsxs)("li",{children:[b("chat.tg.step1.a")," ",(0,d.jsx)("b",{children:"@BotFather"})," ",b("chat.tg.step1.b")," → ",(0,d.jsx)("code",{children:"/newbot"})," → ",b("chat.tg.step1.c")," ",(0,d.jsx)("b",{children:b("chat.tg.step1.token")}),"."]}),(0,d.jsxs)("li",{children:[b("chat.tg.step2.a")," ",(0,d.jsx)("b",{children:"@userinfobot"})," → ",b("chat.tg.step2.b")," ",(0,d.jsx)("b",{children:b("chat.tg.step2.chatId")})," ",b("chat.tg.step2.c")]}),(0,d.jsx)("li",{children:b("chat.tg.step3")})]}),(0,d.jsxs)("label",{className:"tg-field",children:[(0,d.jsx)("span",{children:b("chat.tg.botToken")}),(0,d.jsx)("input",{className:"form-input",placeholder:"123456789:AA…",value:c,onChange:a=>f(a.target.value)})]}),(0,d.jsxs)("div",{className:"tg-field-row",children:[(0,d.jsxs)("label",{className:"tg-field",children:[(0,d.jsx)("span",{children:b("chat.tg.yourChatId")}),(0,d.jsx)("input",{className:"form-input",placeholder:"123456789",value:g,onChange:a=>h(a.target.value)})]}),(0,d.jsxs)("label",{className:"tg-field",children:[(0,d.jsx)("span",{children:b("chat.tg.yourName")}),(0,d.jsx)("input",{className:"form-input",placeholder:b("chat.tg.namePlaceholder"),value:i,onChange:a=>j(a.target.value)})]})]}),k&&(0,d.jsx)("div",{className:"tg-msg err",children:k}),m&&(0,d.jsx)("div",{className:"tg-msg ok",children:m}),(0,d.jsxs)("button",{className:"btn-accent tg-save",disabled:o||!c.trim()||!g.trim(),onClick:function(){l(""),n(""),r(async()=>{let d=await (0,q.M)(c,g,i);d.ok?(n(b("chat.tg.botConnected",{bot:"@"+(d.username??"bot")})),f(""),h(""),j(""),a()):l(d.error??b("chat.tg.connectionFailed"))})},children:[o?(0,d.jsx)("span",{className:"spin",children:(0,d.jsx)(z.I,{name:"refresh",size:13})}):(0,d.jsx)(z.I,{name:"send",size:13})," ",b("chat.tg.connectBot")]}),(0,d.jsxs)("div",{className:"tg-note",children:[(0,d.jsx)(z.I,{name:"bot",size:12})," ",b("chat.tg.isolatedNote")]})]})})}function F({agents:a,operator:b}){let c,f,q,A,[G,H]=(0,e.useState)(!1),[I,J]=(0,e.useState)("right"),[K,L]=(0,e.useState)(380),[M,N]=(0,e.useState)("room"),[O,P]=(0,e.useState)("all"),[Q,R]=(0,e.useState)(""),S=(0,p.k)(),[T,U]=(0,e.useState)([]),[V,W]=(0,e.useState)([]),[X,Y]=(0,e.useState)([]),[Z,$]=(0,e.useState)(!1),[_,aa]=(0,e.useState)(null),[ab,ac]=(0,e.useState)(!1),[ad,ae]=(0,e.useState)([]),[af,ag]=(0,e.useState)({}),[ah,ai]=(0,e.useState)(!1),[aj,ak]=(0,e.useState)(null),[al,am]=(0,e.useState)({}),[an,ao]=(0,e.useState)(""),[ap,aq]=(0,e.useState)(0),[ar,as]=(0,e.useState)([]),[at,au]=(0,e.useState)(null),[av,aw]=(0,e.useState)(0),[ax,ay]=(0,e.useState)([]),[,az]=(0,e.useTransition)(),aA=(0,e.useRef)(0),aB=(0,e.useRef)(0);(0,e.useRef)(null);let aC=(0,e.useRef)({});(0,e.useRef)([]);let[aD,aE]=(0,e.useState)(null),aF=Object.fromEntries(a.map(a=>[a.handle,a])),aG=M.startsWith("dm:"),aH="people"===M,aI="telegram"===M,aJ=aG?M.slice(3):null,aK=aJ?aF[aJ]:null,aL=aG?M:aI?"telegram":"room";function aM(){delete aC.current[aL],aw(a=>a+1)}let aN=()=>(0,l.b)().then(a=>am(a)),aO=()=>(0,r.G)().then(a=>aE(a)).catch(()=>aE({connected:!1})),aP=async()=>{if(!aH)try{let a=await (0,t.p)(aL);if(a.used>=a.max&&!ab){ac(!0);try{await (0,u.L)(aL),a=await (0,t.p)(aL)}finally{ac(!1)}}aa(a)}catch{}};async function aQ(){if(!ab){ac(!0);try{await (0,u.L)(aL),await aP()}finally{ac(!1)}}}function aR(){au({title:S("chat.dock.clearTitle"),body:S("chat.dock.clearBody"),confirmLabel:S("common.clear"),onConfirm:()=>az(async()=>{await (0,m.H)(aL).catch(()=>{}),U([]),W([]),Y([]),delete aC.current[aL],aA.current=0,aB.current=0,await aP(),aG&&await aN()})})}let aS=async()=>{try{let[a,b]=await Promise.all([v(),w()]);ae(a),ag(b)}catch{}};async function aT(a){ai(!1),a.channel&&N(a.channel.startsWith("dm:")?a.channel:"room"),a.messageId&&(ak(a.messageId),setTimeout(()=>ak(null),2600));try{await x(a.id)}catch{}aS()}function aU(a,b){az(async()=>{let{responders:c}=await (0,n._)(aL,a,b);if(c.length){for(let a of(Y(c),c))await (0,o.n)(aL,a),Y(b=>b.filter(b=>b!==a));Y([])}aG&&await aN()})}if(!G)return(0,d.jsx)("button",{className:"chat-fab",style:{display:"grid",placeItems:"center"},onClick:()=>H(!0),title:S("chrome.chat.agentRoom"),children:(0,d.jsx)(z.I,{name:"chat",size:20})});let aV={};for(let a of V)(aV[a.runId]??=[]).push(a);let aW=new Set(T.map(a=>a.id)),aX=Object.entries(aV).filter(([a])=>!aW.has(a)),aY=Object.keys(al).length,aZ=af.room??0,a$=Object.entries(af).reduce((a,[b,c])=>b.startsWith("dm:")?a+c:a,0),a_=af.telegram??0;return(0,d.jsxs)("div",{className:"chat-dock "+I,style:{width:K},children:[(0,d.jsx)("div",{className:"dock-resizer "+I,onMouseDown:function(a){a.preventDefault();let b=a.clientX;function c(a){let c=a.clientX-b;L(Math.max(320,Math.min(640,"right"===I?K-c:K+c)))}document.body.style.cursor="col-resize",window.addEventListener("mousemove",c),window.addEventListener("mouseup",function a(){window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",a),document.body.style.cursor=""})}}),(0,d.jsxs)("div",{className:"dock-toolbar",children:[(0,d.jsxs)("span",{className:"dock-toolbar-title",children:[(0,d.jsx)(z.I,{name:"agents",size:15,style:{color:"var(--accent)"}})," ",S("chat.dock.agents")]}),(0,d.jsxs)("div",{className:"dock-tools",children:[(0,d.jsxs)("div",{className:"dock-bell-wrap",children:[(0,d.jsxs)("button",{className:"dock-tool",title:S("top.notifications"),onClick:()=>ai(a=>!a),children:[(0,d.jsx)(z.I,{name:"bell",size:15}),ad.length>0&&(0,d.jsx)("span",{className:"dock-bell-badge",children:ad.length})]}),ah&&(0,d.jsxs)("div",{className:"dock-notif-pop",children:[(0,d.jsxs)("div",{className:"dock-notif-head",children:[S("top.notifications")," ",ad.length>0&&(0,d.jsxs)("span",{children:["(",ad.length,")"]})]}),0===ad.length&&(0,d.jsx)("div",{className:"dock-notif-empty",children:S("chat.dock.nothingNeedsYou")}),ad.map(a=>(0,d.jsxs)("button",{className:"dock-notif-row"+("approval"===a.kind?" approval":""),onClick:()=>aT(a),children:[(0,d.jsx)("span",{className:"dn-ico",children:(0,d.jsx)(z.I,{name:"approval"===a.kind?"check":"at",size:13})}),(0,d.jsxs)("span",{className:"dn-body",children:[(0,d.jsx)("span",{className:"dn-text",children:a.text}),a.detail&&(0,d.jsx)("span",{className:"dn-detail",children:a.detail})]}),(0,d.jsx)("span",{className:"dn-go",children:(0,d.jsx)(z.I,{name:"chevronRight",size:12})})]},a.id))]})]}),(0,d.jsx)("button",{className:"dock-tool",title:"right"===I?S("chat.dock.moveLeft"):S("chat.dock.moveRight"),onClick:()=>J(a=>"right"===a?"left":"right"),children:(0,d.jsx)(z.I,{name:"right"===I?"dockLeft":"dockRight",size:15})}),(0,d.jsx)("button",{className:"dock-tool",title:S("chat.dock.hide"),onClick:()=>H(!1),children:(0,d.jsx)(z.I,{name:"close",size:15})})]})]}),(0,d.jsxs)("div",{className:"dock-tabs",children:[(0,d.jsxs)("button",{className:"dock-tab"+(aG||aH||aI?"":" on"),onClick:()=>N("room"),children:[(0,d.jsx)(z.I,{name:"agents",size:14})," ",S("chat.dock.tabRoom"),aZ>0&&(0,d.jsx)("span",{className:"dt-badge",children:aZ})]}),(0,d.jsxs)("button",{className:"dock-tab"+(aH||aG?" on":""),onClick:()=>N("people"),children:[(0,d.jsx)(z.I,{name:"chat",size:14})," ",S("chat.dock.tabDirect"),(a$||aY)>0&&(0,d.jsx)("span",{className:"dt-badge",children:a$||aY})]}),(0,d.jsxs)("button",{className:"dock-tab"+(aI?" on":""),onClick:()=>N("telegram"),children:[(0,d.jsx)(z.I,{name:"send",size:14})," Telegram",a_>0&&(0,d.jsx)("span",{className:"dt-badge",children:a_})]})]}),!aH&&!(aI&&aD&&!aD.connected)&&(0,d.jsxs)("div",{className:"ctx-bar",children:[_?(0,d.jsx)(B.m,{stat:_,onCompact:aQ,compacting:ab}):(0,d.jsx)("span",{}),aI?(0,d.jsxs)("span",{className:"ctx-hint",title:S("chat.dock.tgIsolatedTip"),children:[(0,d.jsx)(z.I,{name:"bot",size:12})," ",S("chat.dock.isolatedThreadAda")]}):(0,d.jsxs)("span",{className:"ctx-hint",title:S("chat.dock.dmAdaTip"),children:[(0,d.jsx)(z.I,{name:"bot",size:12})," ",S("home.chat.dmAda")]})]}),aG&&aK?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"dm-back-row",children:[(0,d.jsxs)("button",{className:"dm-back-btn",onClick:()=>N("people"),children:[(0,d.jsx)(z.I,{name:"chevronLeft",size:14})," ",S("chat.dock.allAgents")]}),(0,d.jsxs)("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:5,flexWrap:"wrap",justifyContent:"flex-end"},children:[ar.map(a=>(0,d.jsxs)("span",{className:"sess-pill",children:[(0,d.jsx)("button",{className:"sess-tab"+(a.active?" active":""),title:a.active?S("chat.dock.sessActiveTip"):S("chat.dock.sessSwitchTip"),onClick:()=>{var b;return b=a.id,void(!ar.find(a=>a.id===b)?.active&&az(async()=>{await i(aL,b).catch(()=>{}),aM()}))},onDoubleClick:()=>{var b,c;let d;return b=a.id,c=a.title,void(null!=(d=prompt(S("chat.dock.renameSession"),c))&&az(async()=>{await j(b,d).catch(()=>{}),g(aL).then(as).catch(()=>{})}))},children:a.title}),ar.length>1&&(0,d.jsx)("button",{className:"sess-del",title:S("chat.dock.sessDelete"),onClick:()=>{var b,c;return b=a.id,c=a.title,void au({title:S("chat.dock.deleteSessionTitle"),body:S("chat.dock.deleteSessionBody",{title:c}),confirmLabel:S("common.delete"),onConfirm:()=>az(async()=>{await k(aL,b).catch(()=>{}),aM(),g(aL).then(as).catch(()=>{})})})},children:(0,d.jsx)(z.I,{name:"close",size:11})})]},a.id)),(0,d.jsxs)("button",{className:"sess-new",title:S("chat.dock.sessNewTip"),onClick:function(){az(async()=>{await h(aL).catch(()=>{}),aM()})},children:[(0,d.jsx)(z.I,{name:"add",size:12})," ",S("chat.dock.sessNew")]})]})]}),(0,d.jsxs)("div",{className:"chat-header dm",children:[(0,d.jsx)(y.e,{name:aK.name,color:aK.color,image:aK.image,size:34,health:aK.health}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"chat-title",children:[aK.name," ",(0,d.jsxs)("span",{className:"agent-handle",children:["@",aK.handle]})]}),(0,d.jsxs)("div",{className:"chat-sub",children:[aK.role," \xb7 ",aK.adapter]})]}),(0,d.jsxs)("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:8},children:[(0,d.jsx)(C.qs,{status:aK.status}),(0,d.jsx)("button",{className:"dock-tool",title:S("chat.dock.clearConversation"),onClick:aR,children:(0,d.jsx)(z.I,{name:"trash",size:15})})]})]}),(0,d.jsxs)("div",{className:"dm-context-note",children:[(0,d.jsx)("span",{className:"ico",children:(0,d.jsx)(z.I,{name:"bot",size:14})}),S("chat.dock.dmContextNote",{name:aK.name})]}),(0,d.jsx)(C.H8,{msgs:T,typing:X,agents:a,byRun:aV,liveRuns:aX,loading:Z,highlightId:aj,operator:b,markdownAgent:!0}),(0,d.jsx)(C.V4,{onSend:aU,agents:a,defaultText:an,placeholder:S("chat.dock.messageAgent",{name:aK.name})},"dm:"+aJ+":"+ap)]}):aH?(0,d.jsx)(D,{agents:a,previews:al,onOpenDM:a=>{N("dm:"+a)}}):aI?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"chat-header room",children:[(0,d.jsx)("div",{className:"brand-ico",style:{background:"linear-gradient(150deg,#2aabee,#229ed9)",color:"#fff"},children:(0,d.jsx)(z.I,{name:"send",size:16})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"chat-title",children:"Telegram"}),(0,d.jsx)("div",{className:"chat-sub",children:aD?.connected?S("chat.tg.connectedSub",{name:aD.allowedName||S("chat.tg.you"),chatId:aD.chatIdMasked??""}):S("chat.tg.connectPrompt")})]}),aD?.connected&&(0,d.jsxs)("div",{style:{marginLeft:"auto",display:"flex",gap:6},children:[(0,d.jsx)("button",{className:"dock-tool",title:S("chat.dock.clearConversation"),onClick:aR,children:(0,d.jsx)(z.I,{name:"trash",size:15})}),(0,d.jsx)("button",{className:"dock-tool",title:S("chat.tg.disconnect"),onClick:()=>{confirm(S("chat.tg.disconnectConfirm"))&&az(async()=>{await (0,s.K)(),aO()})},children:(0,d.jsx)(z.I,{name:"close",size:15})})]})]}),aD&&!aD.connected?(0,d.jsx)(E,{onConnected:aO}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"dm-context-note",children:[(0,d.jsx)("span",{className:"ico",children:(0,d.jsx)(z.I,{name:"send",size:14})}),S("chat.tg.isolatedThreadNote")]}),(0,d.jsx)(C.H8,{msgs:T,typing:X,agents:a,byRun:aV,liveRuns:aX,loading:Z||!aD,highlightId:aj,operator:b,markdownAgent:!0}),(0,d.jsx)(C.V4,{onSend:aU,agents:a,placeholder:S("chat.tg.composerPlaceholder")},"telegram:"+ap)]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"chat-header room",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"chat-title",children:S("chat.dock.teamChannel")}),(0,d.jsx)("div",{className:"chat-sub",children:S("chat.dock.teamChannelSub",{n:a.length})})]}),(0,d.jsxs)("div",{className:"chat-members",children:[a.slice(0,6).map(a=>(0,d.jsx)("button",{className:"member-btn",title:S("chat.dock.dmName",{name:a.name}),onClick:()=>{N("dm:"+a.handle)},children:(0,d.jsx)(y.e,{name:a.name,color:a.color,size:26})},a.handle)),a.length>6&&(0,d.jsxs)("button",{className:"more",title:S("chat.dock.allAgents"),onClick:()=>N("people"),children:["+",a.length-6]})]})]}),(c=Array.from(new Set(a.map(a=>a.role))).sort(),f="all"===O?T:"type:work"===O?T.filter(a=>(aV[a.id]?.length??0)>0||!!a.kind):"type:chat"===O?T.filter(a=>!aV[a.id]?.length&&!a.kind):O.startsWith("role:")?T.filter(a=>"operator"===a.fromKind||a.fromHandle&&aF[a.fromHandle]?.role===O.slice(5)):T.filter(a=>"operator"===a.fromKind||a.fromHandle===O),A=(q=Q.trim().toLowerCase())?f.filter(a=>(a.text??"").toLowerCase().includes(q)):f,(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"room-filter",children:[(0,d.jsx)("span",{className:"rf-label",children:S("chat.filter")}),(0,d.jsx)("button",{type:"button",className:"rf-chip"+("all"===O?" on":""),onClick:()=>P("all"),children:S("common.all")}),(0,d.jsx)("button",{type:"button",className:"rf-chip rf-lane"+("type:work"===O?" on":""),title:S("chat.filter.work"),onClick:()=>P("type:work"===O?"all":"type:work"),children:S("chat.filter.work")}),(0,d.jsx)("button",{type:"button",className:"rf-chip rf-lane"+("type:chat"===O?" on":""),title:S("chat.filter.discussion"),onClick:()=>P("type:chat"===O?"all":"type:chat"),children:S("chat.filter.discussion")}),c.map(a=>(0,d.jsx)("button",{type:"button",className:"rf-chip rf-role"+(O==="role:"+a?" on":""),title:S("chat.filter.byRole"),onClick:()=>P(O==="role:"+a?"all":"role:"+a),children:a},"role:"+a)),a.map(a=>(0,d.jsxs)("button",{type:"button",className:"rf-chip"+(O===a.handle?" on":""),title:a.name,onClick:()=>P(O===a.handle?"all":a.handle),children:["@",a.handle]},a.handle)),(0,d.jsxs)("span",{className:"rf-search",children:[(0,d.jsx)(z.I,{name:"search",size:12}),(0,d.jsx)("input",{value:Q,onChange:a=>R(a.target.value),placeholder:S("chat.filter.search"),"aria-label":S("chat.filter.search")}),Q&&(0,d.jsx)("button",{type:"button",className:"rf-clear",onClick:()=>R(""),"aria-label":S("common.dismiss"),children:(0,d.jsx)(z.I,{name:"close",size:11})})]})]}),(0,d.jsx)(C.H8,{msgs:A,typing:X,agents:a,byRun:aV,liveRuns:aX,loading:Z,highlightId:aj,operator:b,markdownAgent:!0,refs:ax})]})),(0,d.jsx)(C.V4,{onSend:aU,agents:a,defaultText:"room"===M?an:"",requireMention:!0,placeholder:S("chat.dock.roomPlaceholder"),refs:ax},"room:"+ap)]}),at&&(0,d.jsx)("div",{className:"modal-overlay",onMouseDown:()=>au(null),children:(0,d.jsxs)("div",{className:"modal",style:{width:380},onMouseDown:a=>a.stopPropagation(),children:[(0,d.jsx)("div",{className:"modal-head",children:(0,d.jsxs)("div",{className:"modal-title",children:[(0,d.jsx)(z.I,{name:"trash",size:15,style:{color:"var(--sx-keyword)"}})," ",at.title]})}),(0,d.jsx)("div",{className:"modal-body",children:(0,d.jsx)("div",{style:{fontSize:13,color:"var(--text-dim)",lineHeight:1.55},children:at.body})}),(0,d.jsxs)("div",{className:"modal-foot",children:[(0,d.jsx)("button",{className:"btn-ghost",onClick:()=>au(null),children:S("common.cancel")}),(0,d.jsx)("button",{className:"btn-accent",style:{background:"var(--sx-keyword)",borderColor:"var(--sx-keyword)",color:"#fff"},onClick:()=>{at.onConfirm(),au(null)},children:at.confirmLabel})]})]})})]})}},46282:(a,b,c)=>{"use strict";c.d(b,{E_:()=>l,F:()=>j,V:()=>h,VJ:()=>i,zS:()=>k});var d=c(6866),e=c(31371),f=c(53993),g=c(63556);async function h(){let{org:a}=await (0,f.nP)(),b=await (0,g.q)(a.id);return(0,e.revalidatePath)("/knowledge"),(0,e.revalidatePath)("/"),b}async function i(a){let{workspace:b}=await (0,f.nP)(),c=await (0,g.zk)(b.id,{...a,updatedBy:"operator"});return(0,e.revalidatePath)("/knowledge"),(0,e.revalidatePath)("/"),c}async function j(a){let{workspace:b}=await (0,f.nP)();return await (0,g.zo)(b.id,a),(0,e.revalidatePath)("/knowledge"),(0,e.revalidatePath)("/"),{ok:!0}}async function k(a){let{workspace:b}=await (0,f.nP)(),c=await (0,g.t8)(b.id,a,"operator");return(0,e.revalidatePath)("/knowledge"),(0,e.revalidatePath)("/"),c}async function l(a){let{workspace:b}=await (0,f.nP)(),c=await (0,g.IV)(b.id,a,"operator");return(0,e.revalidatePath)("/knowledge"),c}(0,c(74252).D)([h,i,j,k,l]),(0,d.A)(h,"003d1836382188603c5b40a8fd0c7735cec69e7922",null),(0,d.A)(i,"40a7dc12aa0d1b7b04c68ad7e482ba71fd189a44a7",null),(0,d.A)(j,"4055d44350781ccf3333fcaf2f5cb371866c797769",null),(0,d.A)(k,"4021ca58f6081eea2ecbd22b042f8eb7cb116a2fc3",null),(0,d.A)(l,"40180769811ee904607ab5b31116043b8c5f8be1a1",null)},46363:(a,b,c)=>{"use strict";c.d(b,{Mp:()=>n,lR:()=>m,sE:()=>l,x7:()=>k});var d=c(6866),e=c(97603),f=c(95357),g=c(54548),h=c(65705),i=c(1890),j=c(53993);async function k(){let{workspace:a}=await (0,j.nP)();return await h.db.select({id:i.notification.id,kind:i.notification.kind,text:i.notification.text,detail:i.notification.detail,messageId:i.notification.messageId,channel:i.notification.channel,createdAt:i.notification.createdAt,agentName:i.agent.name,agentColor:i.agent.color}).from(i.notification).leftJoin(i.agent,(0,e.eq)(i.notification.agentId,i.agent.id)).where((0,e.Uo)((0,e.eq)(i.notification.workspaceId,a.id),(0,e.eq)(i.notification.read,!1),(0,e.RV)(i.notification.kind,["mention","approval"]))).orderBy((0,f.i)(i.notification.createdAt)).limit(20)}async function l(a){let{workspace:b}=await (0,j.nP)();await h.db.update(i.notification).set({read:!0}).where((0,e.Uo)((0,e.eq)(i.notification.id,a),(0,e.eq)(i.notification.workspaceId,b.id)))}async function m(a){let{workspace:b}=await (0,j.nP)();await h.db.insert(i.channelRead).values({workspaceId:b.id,channel:a,lastReadAt:new Date}).onConflictDoUpdate({target:[i.channelRead.workspaceId,i.channelRead.channel],set:{lastReadAt:new Date}})}async function n(){let{workspace:a}=await (0,j.nP)(),b=Object.fromEntries((await h.db.select().from(i.channelRead).where((0,e.eq)(i.channelRead.workspaceId,a.id))).map(a=>[a.channel,a.lastReadAt])),c=await h.db.selectDistinct({channel:i.message.channel}).from(i.message).where((0,e.Uo)((0,e.eq)(i.message.workspaceId,a.id),(0,e.eq)(i.message.fromKind,"agent"))),d={};for(let{channel:f}of c){let c=b[f]??new Date(0),[j]=await h.db.select({n:(0,g.U9)()}).from(i.message).where((0,e.Uo)((0,e.eq)(i.message.workspaceId,a.id),(0,e.eq)(i.message.channel,f),(0,e.eq)(i.message.fromKind,"agent"),(0,e.gt)(i.message.createdAt,c)));Number(j?.n??0)>0&&(d[f]=Number(j.n))}return d}(0,c(74252).D)([k,l,m,n]),(0,d.A)(k,"00cdd261029ea6d12df690e0b43e69818dbfeca142",null),(0,d.A)(l,"40a6b782c452b9d7da8220c5630efb6277ba4077a1",null),(0,d.A)(m,"409743adf88b2fc6a237494fd51038d3a4527b0203",null),(0,d.A)(n,"00e68579200e3df5cde1803035a93f8406aa41e3b0",null)},46694:(a,b,c)=>{"use strict";c.d(b,{UpdateHeaderBadge:()=>m});var d=c(4374),e=c(74679),f=c(47104),g=c(43526),h=c(31819),i=c(51239),j=c(47426),k=c(14284),l=c(49123);function m(){let a=(0,h.k)(),b=(0,f.useRouter)(),[c,m]=(0,e.useState)(null),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)("available"),[r,s]=(0,e.useState)(!1),[t,u]=(0,e.useState)(""),v=(0,e.useRef)(null);async function w(){if(!r){s(!0),u("");try{let b=await (0,i.l)(!0);m(b.info.updateAvailable&&b.info.latest?b.info.latest:null),o(b.busy),b.info.updateAvailable||u(a("chrome.update.upToDate"))}catch{}finally{s(!1)}}}async function x(){if("updating"!==p&&!n){if("done"===p)return void b.refresh();q("updating"),u("");try{let c=await (0,j.P)();if(c.blocked){q("available"),o(!0),u(a("chrome.update.busy"));return}c.started?v.current=setInterval(async()=>{let b=await (0,k.e)().catch(a=>((0,l.st)(a)&&(v.current&&clearInterval(v.current),(0,l.Uy)()),null));b&&("done"===b.status?(v.current&&clearInterval(v.current),window.location.reload()):"error"===b.status&&(v.current&&clearInterval(v.current),q("error"),u(a("chrome.update.failed"))))},3e3):(q("available"),u(c.message||""),b.push("/update"))}catch{q("error"),u(a("chrome.update.failed"))}}}let y=(0,d.jsx)("button",{type:"button",className:"top-btn",onClick:w,disabled:r,title:t||a("chrome.update.check"),children:(0,d.jsx)("span",{className:r?"sync-spin":"",style:{display:"inline-flex"},children:(0,d.jsx)(g.I,{name:"sync",size:17})})});if(!c)return y;let z="updating"===p?a("chrome.update.updating"):"done"===p?a("chrome.update.restart"):"error"===p?a("chrome.update.failed"):n?`v${c}`:`${a("chrome.update.update")} v${c}`,A="updating"===p||n;return(0,d.jsxs)(d.Fragment,{children:[y,(0,d.jsxs)("button",{type:"button",onClick:x,disabled:A,title:n?a("chrome.update.busy"):t||`${a("chrome.update.available")} — v${c}`,style:{display:"inline-flex",alignItems:"center",gap:6,width:"auto",padding:"0 11px",height:30,background:"error"===p?"var(--sx-keyword)":n?"var(--bg-active)":"var(--accent)",color:n?"var(--text-dim)":"var(--accent-fg)",borderRadius:999,fontSize:12,fontWeight:600,border:"none",opacity:"updating"===p?.75:1,cursor:A?"default":"pointer"},children:["updating"===p?(0,d.jsx)("span",{className:"sync-spin",style:{display:"inline-flex"},children:(0,d.jsx)(g.I,{name:"sync",size:14})}):(0,d.jsx)(g.I,{name:"updating"===p?"sync":"done"===p?"refresh":"error"===p?"bell":"arrowUp",size:14}),(0,d.jsx)("span",{children:z})]})]})}},47426:(a,b,c)=>{"use strict";c.d(b,{P:()=>e});var d=c(2910);let e=(0,d.createServerReference)("004385fd0fd07982e82eeb3fc0a146319a0c4cddcf",d.callServer,void 0,d.findSourceMapURL,"runUpdate")},47541:(a,b,c)=>{Promise.resolve().then(c.bind(c,50069)),Promise.resolve().then(c.bind(c,77126)),Promise.resolve().then(c.bind(c,4864)),Promise.resolve().then(c.bind(c,66852)),Promise.resolve().then(c.bind(c,41014))},48442:(a,b,c)=>{"use strict";c.d(b,{E:()=>d,e:()=>e});let d=["Cockpit","Hierarchy","Execution","Product","Knowledge","Operations","Inbox","System"],e=[{id:"home",title:"Home",href:"/",group:"Cockpit",tile:"Welcome — canonical knowledge & quick navigation",icon:"grid"},{id:"dashboard",title:"Dashboard",href:"/dashboard",group:"Cockpit",tile:"Cockpit hub — status at a glance",icon:"pulse"},{id:"organizations",title:"Organizations",href:"/organizations",group:"Hierarchy",tile:"Manage organizations & workspaces",icon:"grid"},{id:"org",title:"Org Chart",href:"/org",group:"Hierarchy",tile:"Hierarchy & delegation",icon:"agents"},{id:"agents",title:"Agent Studio",href:"/agents/ada",group:"Hierarchy",tile:"Configure each agent",icon:"bot"},{id:"code",title:"Code",href:"/code",group:"Execution",tile:"Code editor & repo files",icon:"terminal"},{id:"tasks",title:"Tasks",href:"/tasks",group:"Execution",tile:"Team kanban board",icon:"files"},{id:"cron",title:"Cron",href:"/cron",group:"Execution",tile:"Scheduled tasks & history",icon:"calendar"},{id:"routines",title:"Routines",href:"/routines",group:"Execution",tile:"Recurring automations",icon:"repeat"},{id:"goals",title:"Goals",href:"/goals",group:"Execution",tile:"Objective tree",icon:"target"},{id:"design",title:"Design",href:"/design",group:"Execution",tile:"Prototype the UI with the frontend agent before the plan",icon:"grid"},{id:"planner",title:"CEO Planner",href:"/planner",group:"Execution",tile:"Specs → issues → approval → 24/7",icon:"command"},{id:"test-dev",title:"Test Dev",href:"/test-dev",group:"Execution",tile:"Boot, navigate + validate the project",icon:"play"},{id:"pm",title:"Product Manager",href:"/pm",group:"Product",tile:"Sprints & backlog (PO)",icon:"goto"},{id:"reports",title:"Reports",href:"/reports",group:"Knowledge",tile:"Plans, reviews, audits",icon:"doc"},{id:"docs",title:"Docs",href:"/docs",group:"Knowledge",tile:"Architecture, API & PO docs",icon:"doc"},{id:"skills",title:"Skills",href:"/skills",group:"Knowledge",tile:"Agent procedure library",icon:"skill"},{id:"activity",title:"Activity",href:"/activity",group:"Knowledge",tile:"Agent action timeline",icon:"pulse"},{id:"knowledge",title:"Knowledge",href:"/knowledge",group:"Knowledge",tile:"KB index, coverage, gaps & agent recall",icon:"branch"},{id:"costs",title:"Costs",href:"/costs",group:"Operations",tile:"Spend by agent/provider",icon:"coins"},{id:"security",title:"Security",href:"/security",group:"Operations",tile:"Findings & security score",icon:"shield"},{id:"pulse",title:"Pulse",href:"/pulse",group:"Operations",tile:"Agent health & validation",icon:"pulse"},{id:"github",title:"Commit GitHub",href:"/github",group:"Operations",tile:"Push workspace to remote",icon:"git"},{id:"prepare-deploy",title:"Prepare Deploy",href:"/prepare-deploy",group:"Operations",tile:"Prod-prep + export clean source to a deploy repo",icon:"goto"},{id:"models",title:"Models",href:"/models",group:"Operations",tile:"Providers & local models",icon:"cpu"},{id:"update",title:"Update",href:"/update",group:"Operations",tile:"Detect & apply new versions",icon:"goto"},{id:"plugins",title:"Plugins",href:"/plugins",group:"Operations",tile:"Extensions & integrations",icon:"ext"},{id:"inbox",title:"Inbox",href:"/inbox",group:"Inbox",tile:"Approvals & escalations",icon:"inbox"},{id:"notifications",title:"Notifications",href:"/notifications",group:"Inbox",tile:"Passive alert feed",icon:"bell"},{id:"config",title:"Config",href:"/config",group:"System",tile:"Platform settings",icon:"settings"},{id:"profile",title:"Profile",href:"/profile",group:"System",tile:"Account & preferences",icon:"account"}]},48503:(a,b,c)=>{"use strict";c.d(b,{Z:()=>f});let d=["CONSTELLA_VAULT_KEY","BETTER_AUTH_SECRET","CONSTELLA_WORKER_SECRET"],e=RegExp("sk-[A-Za-z0-9_-]{16,}|gh[posru]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{40,}|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{30,}|xox[baprs]-[A-Za-z0-9-]{10,}|eyJ[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{6,}|-----BEGIN[\\s\\S]*?PRIVATE KEY-----[\\s\\S]*?-----END[\\s\\S]*?-----|\\bcn_[A-Za-z0-9_-]{24,}\\b|\\b\\d{6,}:[A-Za-z0-9_-]{30,}\\b","g");function f(a,b=[]){if(!a)return a;let c=a;for(let a of[...b,...d.map(a=>process.env[a])])a&&a.length>=8&&(c=c.split(a).join("[redacted]"));return c.replace(e,"[redacted]")}},49137:(a,b,c)=>{"use strict";c.d(b,{V4:()=>x,H8:()=>F,qs:()=>t});var d=c(4374),e=c(74679),f=c(47104),g=c(89814),h=c(77954),i=c(14698),j=c(43526),k=c(31819),l=c(2910);let m=(0,l.createServerReference)("4087e6e58cd4d57932fba61705c67f27c76e9dbebb",l.callServer,void 0,l.findSourceMapURL,"pullKbForComposer"),n=(0,l.createServerReference)("40faf10ed1dd931e743694b6ab07acfffa9f1c5fff",l.callServer,void 0,l.findSourceMapURL,"sendMessageToKb");l.callServer,l.findSourceMapURL;var o=c(38273),p=c(63742);let q={read:"Read",create:"Create",edit:"Edit",run:"Run",search:"Search"},r=[{cmd:"/help",descKey:"help"},{cmd:"/kb",descKey:"kb",arg:"<question>"},{cmd:"/search",descKey:"search",arg:"<query>"},{cmd:"/graph",descKey:"graph",arg:"<key>"},{cmd:"/status",descKey:"status"},{cmd:"/agents",descKey:"agents"},{cmd:"/agent",descKey:"agent",arg:"<handle>"},{cmd:"/new-goal",descKey:"newGoal",arg:"<brief>"},{cmd:"/new-issue",descKey:"newIssue",arg:"<title>"},{cmd:"/new-spec",descKey:"newSpec",arg:"<title>"},{cmd:"/generate-plan",descKey:"generatePlan",arg:"<brief>"},{cmd:"/approve",descKey:"approve"},{cmd:"/reject",descKey:"reject",arg:"<reason>"},{cmd:"/run-247",descKey:"run247"},{cmd:"/pause",descKey:"pause"},{cmd:"/cancel",descKey:"cancel"},{cmd:"/archive",descKey:"archive"},{cmd:"/assign",descKey:"assign",arg:"<issue> <@agent>"},{cmd:"/review",descKey:"review"},{cmd:"/close-sprint",descKey:"closeSprint"},{cmd:"/test-dev",descKey:"testDev"},{cmd:"/github",descKey:"github"},{cmd:"/prepare-deploy",descKey:"prepareDeploy"},{cmd:"/export-source",descKey:"exportSource",arg:"<repo>"},{cmd:"/models",descKey:"models"},{cmd:"/skills",descKey:"skills"},{cmd:"/locks",descKey:"locks"},{cmd:"/telegram",descKey:"telegram"},{cmd:"/reindex",descKey:"reindex"},{cmd:"/curate",descKey:"curate"},{cmd:"/clear",descKey:"clear"}],s={idle:{c:"#6b7390",bg:"rgba(120,130,160,.16)"},working:{c:"#b3d97a",bg:"rgba(179,217,122,.15)"},review:{c:"#e0a44e",bg:"rgba(224,164,78,.16)"},blocked:{c:"#e8688f",bg:"rgba(232,104,143,.16)"}};function t({status:a}){let b=(0,k.k)(),c=s[a]??s.idle;return(0,d.jsx)("span",{className:"status-pill",style:{color:c.c,background:c.bg},children:a in s?b("chat.status."+a):a})}function u(a,b,c){let e=c?Object.fromEntries(c.map(a=>[a.key.toLowerCase(),a])):{},f=c&&c.length>0;return a.split(f?/(@[a-z0-9-]+|#[a-z0-9_-]+)/gi:/(@[a-z0-9-]+)/gi).map((a,c)=>{if(/^@[a-z0-9-]+$/i.test(a)&&b.has(a.slice(1).toLowerCase()))return(0,d.jsx)("span",{className:"mention",children:a},c);if(f&&/^#[a-z0-9_-]+$/i.test(a)){let b=e[a.slice(1).toLowerCase()];if(b){let e="goal"===b.kind?"/goals":"spec"===b.kind?"/planner":"/pm";return(0,d.jsx)("a",{className:"ref-chip",href:e,title:b.title,children:a},c)}}return(0,d.jsx)("span",{children:a},c)})}function v({step:a}){let b,c,e=(0,k.k)(),f=a.kind in q?e("chat.verb."+a.kind):a.kind,g="run"===a.kind,h="edit"===a.kind&&!!a.detail,i="create"===a.kind&&!!a.detail,j=h?a.detail.split("\n"):[],l=h?j.filter(a=>a.startsWith("+")).length:0,m=h?j.filter(a=>a.startsWith("-")).length:0,n=i?a.detail.slice(0,4e3).split("\n"):[];return(0,d.jsxs)("div",{className:"work-step",children:[(0,d.jsxs)("div",{className:"wstep-head",children:[(0,d.jsx)("span",{className:"wstep-verb "+a.kind,children:f}),(0,d.jsx)("span",{className:"wstep-file",children:a.target}),h&&(0,d.jsxs)("span",{className:"wstep-badge",children:[(0,d.jsxs)("span",{className:"plus",children:["+",l]})," ",(0,d.jsxs)("span",{className:"minus",children:["−",m]})]}),i&&(0,d.jsx)("span",{className:"wstep-badge",children:(0,d.jsxs)("span",{className:"plus",children:["+",n.length]})})]}),i&&(0,d.jsx)("div",{className:"wstep-code scroll",children:n.map((a,b)=>(0,d.jsxs)("div",{className:"wcode-line",children:[(0,d.jsx)("span",{className:"wcode-gutter",children:b+1}),(0,d.jsx)("span",{className:"wcode-text",children:a||"​"})]},b))}),h&&(0,d.jsx)("div",{className:"wstep-code scroll",children:j.map((a,b)=>{let c=a.startsWith("+")?"add":a.startsWith("-")?"del":"ctx";return(0,d.jsxs)("div",{className:"wdiff-line "+c,children:[(0,d.jsx)("span",{className:"wdiff-sign",children:"add"===c?"+":"del"===c?"−":" "}),(0,d.jsx)("span",{className:"wdiff-text",children:a.slice(1)||"​"})]},b)})}),g&&a.detail&&(c=(b=a.detail.split("\n")).slice(0,14),(0,d.jsxs)("div",{className:"wstep-term",children:[c.map((a,b)=>(0,d.jsx)("div",{className:/✓|passed|ok\b/i.test(a)?"ok":"",children:a||"​"},b)),b.length>c.length&&(0,d.jsxs)("div",{className:"wstep-more",children:["… +",b.length-c.length," lines"]})]}))]})}function w({steps:a,live:b}){let c=(0,k.k)(),f=a.filter(a=>["read","create","edit","run","search"].includes(a.kind)),g=f.filter(a=>"create"===a.kind||"edit"===a.kind).length,h=[...a].reverse().find(a=>"thinking"===a.kind),i=!b,[l,m]=(0,e.useState)(b);return 0!==f.length||h?(0,d.jsxs)("div",{className:"work-block"+(l?"":" collapsed"),children:[(0,d.jsxs)("button",{type:"button",className:"work-head",onClick:()=>m(a=>!a),children:[i?(0,d.jsx)("span",{className:"done-check",children:(0,d.jsx)(j.I,{name:"check",size:15})}):(0,d.jsx)("span",{className:"spin",children:(0,d.jsx)(j.I,{name:"refresh",size:14})}),(0,d.jsx)("span",{className:"wlabel",children:c(i?"chat.work.done":"chat.work.working")}),(0,d.jsx)("span",{className:"wmeta",children:i?c(1===f.length?"chat.work.actions.one":"chat.work.actions.other",{n:f.length}):c("chat.work.workingEllipsis")}),i&&g>0&&(0,d.jsxs)("span",{className:"wmeta wfiles",title:"files changed",children:["✎ ",g]}),(0,d.jsx)("span",{className:"work-toggle"+(l?" open":""),children:(0,d.jsx)(j.I,{name:"chevronRight",size:13})})]}),l&&(0,d.jsxs)(d.Fragment,{children:[h?.detail&&(0,d.jsxs)("div",{className:"work-thinking",children:[(0,d.jsx)("span",{className:"ti",children:(0,d.jsx)(j.I,{name:"bot",size:13})}),(0,d.jsx)("span",{children:h.detail})]}),(0,d.jsx)("div",{className:"work-steps",children:f.map(a=>(0,d.jsx)(v,{step:a},a.id))})]})]}):null}function x({onSend:a,placeholder:b,agents:c,defaultText:f="",requireMention:g=!1,enableAttachments:h=!0,refs:l}){let[n,o]=(0,e.useState)(f),p=(0,k.k)(),q=!g||n.trim().startsWith("/")||(n.match(/@([a-z0-9-]+)/gi)||[]).some(a=>c.some(b=>b.handle.toLowerCase()===a.slice(1).toLowerCase())),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(null),[w,y]=(0,e.useState)(null),[z,A]=(0,e.useState)(null),[B,C]=(0,e.useState)([]),[D,E]=(0,e.useState)(""),[F,G]=(0,e.useState)(!1),[H,I]=(0,e.useState)(!1),[J,K]=(0,e.useState)(""),[L,M]=(0,e.useState)(null),[N,O]=(0,e.useState)(""),[P,Q]=(0,e.useTransition)(),R=(0,e.useRef)(null),S=(0,e.useRef)(null),T=(0,e.useRef)(null),U=void 0!==l;async function V(a){if(!a||!a.length)return;E("");let b=10-B.length,c=Array.from(a).slice(0,Math.max(0,b));if(!c.length)return void E(p("chat.composer.maxAttachments"));let d=new FormData;for(let a of c)d.append("files",a);G(!0);try{let a=await fetch("/api/upload",{method:"POST",body:d}),b=await a.json();if(!a.ok||!b.ok)return void E(b.error??p("chat.composer.uploadFailed"));C(a=>[...a,...b.attachments].slice(0,10))}catch{E(p("chat.composer.uploadFailed"))}finally{G(!1),S.current&&(S.current.value="")}}function W(a){a.style.height="auto",a.style.height=Math.min(a.scrollHeight,260)+"px"}function X(a){if(!u||!R.current)return;let b=n.slice(0,u.start),c=n.slice(R.current.selectionStart),d="@"+a.handle+" ";o(b+d+c),T.current=(b+d).length,v(null),requestAnimationFrame(()=>R.current?.focus())}function Y(a){if(!w||!R.current)return;let b=n.slice(0,w.start),c=n.slice(R.current.selectionStart),d="#"+a.key+" ";o(b+d+c),T.current=(b+d).length,y(null),requestAnimationFrame(()=>R.current?.focus())}function Z(a){let b=a.cmd+(a.arg?" ":"");o(b),T.current=b.length,A(null),requestAnimationFrame(()=>R.current?.focus())}function $(){let a=J.trim();if(!a){M(null),O(p("chat.kbPull.empty"));return}O(""),M(null),Q(async()=>{let b=await m(a);b.ok&&b.text?M({text:b.text,sources:b.sources??[]}):O(p("chat.kbPull.noResult"))})}function _(){let b=n.trim();!b&&0===B.length||q&&(a(b,B.length?B:void 0),o(""),C([]),E(""),R.current&&(R.current.style.height="auto"),v(null),A(null),y(null),I(!1))}return(0,d.jsxs)("div",{className:"chat-composer",children:[u&&(0,d.jsxs)("div",{className:"mention-pop",children:[(0,d.jsxs)("div",{className:"mention-head",children:[(0,d.jsx)(j.I,{name:"at",size:12})," ",p("chat.composer.mentionAgent")]}),(0,d.jsxs)("div",{className:"mention-list scroll",children:[0===u.items.length&&(0,d.jsx)("div",{className:"mention-empty",children:p("chat.noAgentMatch",{q:u.query})}),u.items.map((a,b)=>(0,d.jsxs)("div",{className:"mention-item"+(b===u.index?" active":""),onMouseEnter:()=>v(a=>a&&{...a,index:b}),onMouseDown:b=>{b.preventDefault(),X(a)},children:[(0,d.jsx)(i.e,{name:a.name,color:a.color,size:24}),(0,d.jsx)("div",{className:"mi-text",children:(0,d.jsxs)("div",{className:"mi-name",children:[a.name," ",(0,d.jsxs)("span",{className:"mi-handle",children:["@",a.handle]})]})}),(0,d.jsx)("span",{className:"mi-role",children:a.role})]},a.handle))]})]}),w&&(0,d.jsxs)("div",{className:"mention-pop",children:[(0,d.jsxs)("div",{className:"mention-head",children:[(0,d.jsx)(j.I,{name:"branch",size:12})," ",p("chat.composer.referenceItem")]}),(0,d.jsxs)("div",{className:"mention-list scroll",children:[0===w.items.length&&(0,d.jsx)("div",{className:"mention-empty",children:p("chat.noRefMatch",{q:w.query})}),w.items.map((a,b)=>(0,d.jsxs)("div",{className:"mention-item"+(b===w.index?" active":""),onMouseEnter:()=>y(a=>a&&{...a,index:b}),onMouseDown:b=>{b.preventDefault(),Y(a)},children:[(0,d.jsx)("span",{className:"mi-ref-kind",children:p("chat.composer.refKind."+a.kind)}),(0,d.jsx)("div",{className:"mi-text",children:(0,d.jsxs)("div",{className:"mi-name",children:[(0,d.jsxs)("span",{className:"mi-handle",children:["#",a.key]})," ",a.title]})})]},a.id))]})]}),z&&(0,d.jsxs)("div",{className:"mention-pop",children:[(0,d.jsxs)("div",{className:"mention-head",children:[(0,d.jsx)(j.I,{name:"command",size:12})," ",p("chat.commands")]}),(0,d.jsx)("div",{className:"mention-list scroll",children:z.items.map((a,b)=>(0,d.jsxs)("div",{className:"mention-item"+(b===z.index?" active":""),onMouseEnter:()=>A(a=>a&&{...a,index:b}),onMouseDown:b=>{b.preventDefault(),Z(a)},children:[(0,d.jsx)("div",{className:"mi-text",children:(0,d.jsxs)("div",{className:"mi-name",children:[a.cmd,a.arg&&(0,d.jsxs)("span",{className:"mi-handle",children:[" ",a.arg]})]})}),(0,d.jsx)("span",{className:"mi-role",children:p("chat.slash."+a.descKey)})]},a.cmd))})]}),H&&(0,d.jsxs)("div",{className:"mention-pop kb-pull-pop",children:[(0,d.jsxs)("div",{className:"mention-head",children:[(0,d.jsx)(j.I,{name:"branch",size:12})," ",p("chat.kbPull.title")]}),(0,d.jsxs)("div",{className:"kb-pull-body",children:[(0,d.jsxs)("div",{className:"kb-pull-row",children:[(0,d.jsx)("input",{className:"kb-pull-input",value:J,placeholder:p("chat.kbPull.placeholder"),onChange:a=>{K(a.target.value),O("")},onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),$()),"Escape"===a.key&&(a.preventDefault(),I(!1))}}),(0,d.jsxs)("button",{type:"button",className:"att-btn",disabled:P,onMouseDown:a=>a.preventDefault(),onClick:$,children:[P?(0,d.jsx)("span",{className:"spin",children:(0,d.jsx)(j.I,{name:"refresh",size:13})}):(0,d.jsx)(j.I,{name:"search",size:13}),p("chat.kbPull.search")]})]}),(0,d.jsx)("div",{className:"kb-pull-preview",children:P?(0,d.jsx)("div",{className:"kb-pull-muted",children:p("chat.kbPull.searching")}):L?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"kb-pull-text",children:L.text}),L.sources.length>0&&(0,d.jsx)("div",{className:"kb-pull-sources",children:L.sources.map(a=>(0,d.jsx)("span",{children:a},a))})]}):(0,d.jsx)("div",{className:N?"kb-pull-error":"kb-pull-muted",children:N||p("chat.kbPull.empty")})}),L&&(0,d.jsx)("div",{className:"kb-pull-actions",children:(0,d.jsxs)("button",{type:"button",className:"send-btn",onMouseDown:a=>a.preventDefault(),onClick:function(){if(!L)return;let a=L.sources.length?`
149
- Sources: ${L.sources.join(", ")}`:"",b=`KB: ${L.text}${a}`;o(a=>a.trim()?`${a.trimEnd()}
150
-
151
- ${b}`:b),I(!1),M(null),O(""),requestAnimationFrame(()=>{R.current&&(W(R.current),R.current.focus())})},children:[(0,d.jsx)(j.I,{name:"add",size:13})," ",p("chat.kbPull.insert")]})})]})]}),(0,d.jsxs)("div",{className:"composer-box"+(s?" focus":""),children:[B.length>0&&(0,d.jsx)("div",{className:"att-row",children:B.map((a,b)=>(0,d.jsxs)("span",{className:"att-chip",children:[(0,d.jsx)(j.I,{name:/^image\//.test(a.type)||"application/pdf"===a.type?"doc":"files",size:11}),(0,d.jsx)("span",{className:"att-name",children:a.name}),(0,d.jsx)("button",{className:"att-x",onClick:()=>C(a=>a.filter((a,c)=>c!==b)),children:(0,d.jsx)(j.I,{name:"close",size:10})})]},a.path))}),D&&(0,d.jsx)("div",{style:{fontSize:10.5,color:"#e8688f",padding:"2px 8px"},children:D}),(0,d.jsx)("textarea",{ref:R,className:"composer-input",value:n,rows:1,placeholder:b,onChange:a=>{o(a.target.value),function(a,b){let d=a.match(/^\/([a-z-]*)$/i);if(d){let a=d[1].toLowerCase(),b=r.filter(b=>b.cmd.slice(1).startsWith(a));v(null),y(null),A(b.length?{items:b,index:0}:null);return}A(null);let e=a.slice(0,b).match(/#([a-z0-9_-]*)$/i);if(e&&l&&l.length>0){let a=e[1].toLowerCase(),c=l.filter(b=>b.key.toLowerCase().includes(a)||b.title.toLowerCase().includes(a));v(null),y({query:a,start:b-e[0].length,items:c,index:0});return}y(null);let f=a.slice(0,b).match(/@([a-z0-9-]*)$/i);if(!f)return v(null);let g=f[1].toLowerCase(),h=c.filter(a=>a.handle.includes(g)||a.name.toLowerCase().includes(g)||a.role.toLowerCase().includes(g));v({query:g,start:b-f[0].length,items:h,index:0})}(a.target.value,a.target.selectionStart),W(a.target)},onKeyDown:function(a){if(z&&z.items.length){if("ArrowDown"===a.key){a.preventDefault(),A(a=>a&&{...a,index:(a.index+1)%a.items.length});return}if("ArrowUp"===a.key){a.preventDefault(),A(a=>a&&{...a,index:(a.index-1+a.items.length)%a.items.length});return}if("Enter"===a.key||"Tab"===a.key){a.preventDefault(),Z(z.items[z.index]);return}if("Escape"===a.key){a.preventDefault(),A(null);return}}if(w&&w.items.length){if("ArrowDown"===a.key){a.preventDefault(),y(a=>a&&{...a,index:(a.index+1)%a.items.length});return}if("ArrowUp"===a.key){a.preventDefault(),y(a=>a&&{...a,index:(a.index-1+a.items.length)%a.items.length});return}if("Enter"===a.key||"Tab"===a.key){a.preventDefault(),Y(w.items[w.index]);return}if("Escape"===a.key){a.preventDefault(),y(null);return}}if(u&&u.items.length){if("ArrowDown"===a.key){a.preventDefault(),v(a=>a&&{...a,index:(a.index+1)%a.items.length});return}if("ArrowUp"===a.key){a.preventDefault(),v(a=>a&&{...a,index:(a.index-1+a.items.length)%a.items.length});return}if("Enter"===a.key||"Tab"===a.key){a.preventDefault(),X(u.items[u.index]);return}if("Escape"===a.key){a.preventDefault(),v(null);return}}if("Escape"===a.key&&H){a.preventDefault(),I(!1);return}"Enter"!==a.key||a.shiftKey||(a.preventDefault(),_())},onFocus:()=>t(!0),onBlur:()=>t(!1)}),h&&(0,d.jsx)("input",{ref:S,type:"file",multiple:!0,hidden:!0,accept:".png,.jpg,.jpeg,.gif,.webp,.bmp,.pdf,.txt,.md,.csv,.json,.log,.zip,.doc,.docx,.xls,.xlsx,.ppt,.pptx",onChange:a=>V(a.target.files)}),(0,d.jsxs)("div",{className:"composer-foot",children:[(0,d.jsxs)("span",{className:"composer-actions",children:[h&&(0,d.jsxs)("button",{type:"button",className:"att-btn",title:p("chat.composer.attachTitle"),disabled:F||B.length>=10,onClick:()=>S.current?.click(),children:[F?(0,d.jsx)("span",{className:"spin",children:(0,d.jsx)(j.I,{name:"refresh",size:13})}):(0,d.jsx)(j.I,{name:"add",size:14})," ",B.length>0?`${B.length}/10`:p("chat.composer.attach")]}),U&&(0,d.jsxs)("button",{type:"button",className:"att-btn kb-pull-btn",title:p("chat.kbPull.open"),disabled:P,onMouseDown:a=>a.preventDefault(),onClick:function(){K(n.replace(/@[a-z0-9-]+/gi,"").trim().slice(0,180)),M(null),O(""),v(null),A(null),y(null),I(a=>!a)},children:[(0,d.jsx)(j.I,{name:"branch",size:13})," ",p("chat.kbPull.open")]})]}),g&&n.trim()&&!q?(0,d.jsxs)("span",{className:"composer-hint",style:{color:"#f0a35e"},children:[(0,d.jsx)(j.I,{name:"at",size:11})," ",p("chat.composer.mentionToSend")]}):(0,d.jsxs)("span",{className:"composer-hint",children:[(0,d.jsx)("kbd",{children:"↵"})," ",p("chat.composer.send")," \xb7 ",(0,d.jsx)("kbd",{children:"⇧↵"})," ",p("chat.composer.newline")]}),(0,d.jsxs)("button",{className:"send-btn",disabled:!n.trim()&&0===B.length||!q,onMouseDown:a=>a.preventDefault(),onClick:_,children:[(0,d.jsx)(j.I,{name:"send",size:13})," ",p("home.cmd.run")]})]})]})]})}function y({atts:a}){return(0,d.jsx)("div",{className:"msg-atts",children:a.map(a=>{let b=`/api/upload?path=${encodeURIComponent(a.path)}`;return/^image\//.test(a.type)?(0,d.jsx)("a",{href:b,target:"_blank",rel:"noreferrer",className:"msg-att-img",title:a.name,children:(0,d.jsx)("img",{src:b,alt:a.name,loading:"lazy"})},a.path):(0,d.jsxs)("a",{href:b,target:"_blank",rel:"noreferrer",className:"msg-att-doc",title:a.name,children:[(0,d.jsx)(j.I,{name:"doc",size:13})," ",(0,d.jsx)("span",{className:"mad-name",children:a.name})]},a.path)})})}function z({id:a}){let b=(0,k.k)(),[c,f]=(0,e.useTransition)(),[g,h]=(0,e.useState)(!1);return(0,d.jsx)("button",{type:"button",className:"cmsg-kb",disabled:c||g,title:b(g?"chat.kbSave.saved":"chat.kbSave.send"),onClick:()=>f(async()=>{(await n(a)).ok&&h(!0)}),style:{background:"none",border:"none",cursor:g?"default":"pointer",padding:0,marginLeft:2,display:"inline-flex",alignItems:"center",color:g?"var(--accent)":"var(--text-faint)",opacity:c?.5:1},children:(0,d.jsx)(j.I,{name:g?"check":"branch",size:11,className:c?"sync-spin":""})})}function A({taskId:a}){let[b,c]=(0,e.useState)(null);return b?(0,d.jsxs)("div",{style:{marginTop:5,fontSize:10.5,color:"var(--text-faint)",display:"flex",alignItems:"center",gap:5,flexWrap:"wrap"},children:[(0,d.jsx)(j.I,{name:"branch",size:10}),(0,d.jsx)("span",{style:{color:"var(--accent)",fontWeight:600},children:b.taskKey}),b.issueKey&&(0,d.jsxs)("span",{children:["\xb7 ",b.issueKey]}),b.goalTitle&&(0,d.jsxs)("span",{children:["\xb7 ",b.goalTitle.slice(0,40)]}),b.col&&(0,d.jsx)("span",{style:{padding:"0 5px",borderRadius:5,border:"1px solid var(--border)",textTransform:"capitalize"},children:b.col})]}):null}function B({blocks:a}){let b=(0,f.useRouter)(),c=(0,k.k)();return(0,d.jsxs)("div",{style:{marginTop:5,fontSize:10.5,color:"var(--text-faint)",display:"flex",alignItems:"center",gap:5,flexWrap:"wrap"},children:[(0,d.jsx)(j.I,{name:"doc",size:10}),(0,d.jsx)("span",{children:c("chat.touchedBlocks")}),a.map(a=>(0,d.jsx)("button",{type:"button",title:c("chat.touchedBlocks"),onClick:()=>b.push("/knowledge"),style:{color:"var(--accent)",fontWeight:600,background:"rgba(120,100,255,.10)",border:"1px solid rgba(120,100,255,.25)",borderRadius:4,padding:"0 5px",cursor:"pointer"},children:a},a))]})}function C({sources:a}){let[b,c]=(0,e.useState)(!1),f=(0,k.k)();return(0,d.jsxs)("div",{className:"msg-sources",children:[(0,d.jsxs)("button",{type:"button",className:"msg-sources-toggle",onClick:()=>c(a=>!a),children:[(0,d.jsx)(j.I,{name:"pulse",size:10})," ",f("chat.sources",{n:a.length})," ",(0,d.jsx)(j.I,{name:b?"chevronDown":"chevronRight",size:11})]}),b&&(0,d.jsx)("div",{className:"msg-sources-list",children:a.map((a,b)=>(0,d.jsx)("span",{children:a},b))})]})}function D({text:a,markdown:b,known:c,refs:f}){let i=(0,k.k)(),[j,l]=(0,e.useState)(!1),m=a.length>900;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"cmsg-bubble"+(m&&!j?" clamped":"")+(m&&j?" expanded":""),children:b?(0,d.jsx)("div",{className:"md cmsg-md",children:(0,d.jsx)(g.oz,{remarkPlugins:[h.A],children:a})}):u(a,c,f)}),m&&(0,d.jsx)("button",{type:"button",className:"cmsg-more",onClick:()=>l(a=>!a),children:i(j?"chat.showLess":"chat.showMore")})]})}function E({m:a}){let b=(0,k.k)(),c=(0,f.useRouter)(),[i,l]=(0,e.useTransition)(),[m,n]=(0,e.useState)(!1),[q,r]=(0,e.useState)(null);return(0,d.jsxs)("div",{className:"kb-card",children:[(0,d.jsxs)("div",{className:"kb-card-head",children:[(0,d.jsx)(j.I,{name:"branch",size:14})," ",b("kbcard.title")]}),(0,d.jsx)("div",{className:"kb-card-body cmsg-md",children:(0,d.jsx)(g.oz,{remarkPlugins:[h.A],children:a.text})}),q&&(0,d.jsxs)("div",{className:"kb-card-note",children:[(0,d.jsx)(j.I,{name:"check",size:12})," ",q]}),(0,d.jsxs)("div",{className:"kb-card-actions",children:[(0,d.jsx)("button",{className:"kbc-btn primary",disabled:i,onClick:()=>l(async()=>{r(b("kbcard.created",{n:(await (0,o.V)()).seeded})),c.refresh()}),children:b("home.createBlocks")}),(0,d.jsx)("button",{className:"kbc-btn",onClick:()=>c.push("/knowledge"),children:b("home.openKnowledge")}),(0,d.jsx)("button",{className:"kbc-btn",disabled:i,onClick:()=>l(async()=>{r(b("kb.reindexResult",{n:(await (0,p.f)()).chunks})),c.refresh()}),children:b("kb.reindex")})]}),a.sources&&a.sources.length>0&&(0,d.jsxs)("div",{className:"kb-card-sources",children:[(0,d.jsxs)("button",{type:"button",className:"msg-sources-toggle",onClick:()=>n(a=>!a),children:[(0,d.jsx)(j.I,{name:"pulse",size:10})," ",b("chat.sources",{n:a.sources.length})," ",(0,d.jsx)(j.I,{name:m?"chevronDown":"chevronRight",size:11})]}),m&&(0,d.jsx)("div",{className:"msg-sources-list",children:a.sources.map((a,b)=>(0,d.jsx)("span",{children:a},b))})]})]})}function F({msgs:a,typing:b,agents:c,byRun:f,liveRuns:g,loading:h,highlightId:j,operator:l,markdownAgent:m=!1,emptyHint:n,avatarSize:o=30,refs:p}){let q=(0,k.k)(),r=(0,e.useRef)(null),s=(0,e.useRef)(!0),t=Object.fromEntries(c.map(a=>[a.handle,a])),v=new Set(c.map(a=>a.handle));return(0,d.jsxs)("div",{className:"chat-stream scroll",ref:r,onScroll:()=>{let a=r.current;a&&(s.current=a.scrollHeight-a.scrollTop-a.clientHeight<120)},children:[[...a].sort((a,b)=>{let c=a.createdAt?new Date(a.createdAt).getTime():0,d=b.createdAt?new Date(b.createdAt).getTime():0;return c!==d?c-d:("operator"!==a.fromKind)-("operator"!==b.fromKind)}).map(a=>{let b="operator"===a.fromKind,c=a.fromHandle?t[a.fromHandle]:null,e=f[a.id],g=!b&&"kb-card"===a.kind;return(0,d.jsxs)("div",{className:"cmsg"+(b?" operator":"")+(j===a.id?" highlight":""),id:"m-"+a.id,children:[b?l?.image?(0,d.jsx)(i.e,{name:l.name||q("chat.you"),color:"#9a5cff",image:l.image,size:o}):(0,d.jsx)("div",{className:"avatar",style:{background:"linear-gradient(150deg,#e0a44e,#9a5cff)",color:"#1a1206",width:o,height:o,borderRadius:Math.round(.3*o),display:"grid",placeItems:"center",fontWeight:700,fontSize:Math.round(.4*o)},children:"OP"}):c?(0,d.jsx)(i.e,{name:c.name,color:c.color,image:c.image,size:o}):(0,d.jsx)(i.e,{name:"?",color:"#6b7390",size:o}),(0,d.jsxs)("div",{className:"cmsg-body",children:[(0,d.jsxs)("div",{className:"cmsg-head",children:[(0,d.jsx)("span",{className:"cmsg-name",children:b?q("chat.you"):c?.name??a.fromHandle}),!b&&c&&(0,d.jsx)("span",{className:"cmsg-role",children:c.role}),(0,d.jsx)("span",{className:"cmsg-when",children:function(a){if(!a)return"";let b="string"==typeof a?new Date(a):a,c=b.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),d=b.toLocaleDateString([],{day:"2-digit",month:"short"});return`${d}, ${c}`}(a.createdAt)}),!b&&a.text&&(0,d.jsx)(z,{id:a.id})]}),e&&e.length>0&&(0,d.jsx)(w,{steps:e,live:!1}),g?(0,d.jsx)(E,{m:a}):a.text&&(0,d.jsx)(D,{text:a.text,markdown:m&&!b,known:v,refs:p}),a.attachments&&a.attachments.length>0&&(0,d.jsx)(y,{atts:a.attachments}),!b&&!g&&a.sources&&a.sources.length>0&&(0,d.jsx)(C,{sources:a.sources}),!b&&a.taskId&&(0,d.jsx)(A,{taskId:a.taskId}),!b&&a.blocks&&a.blocks.length>0&&(0,d.jsx)(B,{blocks:a.blocks})]})]},a.id)}),g.map(([a,b])=>{let e=b.find(a=>a.agentId)?.agentId,f=c.find(a=>a.id===e);if(!f)return null;let g=b.reduce((a,b)=>Math.max(a,b.seq||0),0),h=b.some(a=>"done"===a.kind)||g>0&&Date.now()-g>12e4,j=b.filter(a=>"text"===a.kind).map(a=>a.detail).join("");return(0,d.jsxs)("div",{className:"cmsg",children:[(0,d.jsx)(i.e,{name:f.name,color:f.color,image:f.image,size:o}),(0,d.jsxs)("div",{className:"cmsg-body",children:[(0,d.jsxs)("div",{className:"cmsg-head",children:[(0,d.jsx)("span",{className:"cmsg-name",children:f.name}),(0,d.jsx)("span",{className:"cmsg-role",children:f.role})]}),(0,d.jsx)(w,{steps:b,live:!h}),j&&(0,d.jsxs)("div",{className:"cmsg-bubble",children:[u(j,v,p),!h&&(0,d.jsx)("span",{className:"live-caret"})]})]})]},"live-"+a)}),b.filter(a=>{let b=t[a];return b&&!g.some(([,a])=>a.some(a=>a.agentId===b.id))}).map(a=>{let b=t[a];return b?(0,d.jsxs)("div",{className:"cmsg",children:[(0,d.jsx)(i.e,{name:b.name,color:b.color,image:b.image,size:o}),(0,d.jsxs)("div",{className:"cmsg-body",children:[(0,d.jsxs)("div",{className:"cmsg-head",children:[(0,d.jsx)("span",{className:"cmsg-name",children:b.name}),(0,d.jsx)("span",{className:"cmsg-role",children:b.role})]}),(0,d.jsxs)("div",{className:"typing-bubble",children:[(0,d.jsx)("span",{}),(0,d.jsx)("span",{}),(0,d.jsx)("span",{})]})]})]},"typing-"+a):null}),h&&0===a.length&&0===g.length&&(0,d.jsx)("div",{className:"chat-skel","aria-label":q("home.chat.loading"),children:[0,1,2].map(a=>(0,d.jsxs)("div",{className:"skel-row",style:{animationDelay:`${.12*a}s`},children:[(0,d.jsx)("div",{className:"skel-avatar"}),(0,d.jsxs)("div",{className:"skel-lines",children:[(0,d.jsx)("div",{className:"skel-line",style:{width:"38%"}}),(0,d.jsx)("div",{className:"skel-line",style:{width:1===a?"82%":"64%"}}),2!==a&&(0,d.jsx)("div",{className:"skel-line",style:{width:"48%"}})]})]},a))}),!h&&0===a.length&&0===b.length&&0===g.length&&(0,d.jsx)("div",{className:"mention-empty",style:{textAlign:"center",padding:22},children:n??q("chat.stream.emptyHint")})]})}},50069:(a,b,c)=>{"use strict";c.d(b,{ChatDockGate:()=>g});var d=c(4374),e=c(47104),f=c(45912);function g(a){return"/"===(0,e.usePathname)()?null:(0,d.jsx)(f.uG,{...a})}},51203:(a,b,c)=>{"use strict";c.d(b,{ChatDockGate:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call ChatDockGate() from the server but ChatDockGate is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\chat-dock-gate.tsx","ChatDockGate")},51239:(a,b,c)=>{"use strict";c.d(b,{l:()=>e});var d=c(2910);let e=(0,d.createServerReference)("401b5fdc3d8fb095679094c177536777e53f9c06fd",d.callServer,void 0,d.findSourceMapURL,"getUpdateState")},51605:(a,b,c)=>{"use strict";c.d(b,{L:()=>o,p:()=>n});var d=c(6866),e=c(97603),f=c(54548),g=c(31371),h=c(65705),i=c(1890),j=c(53993),k=c(57806),l=c(12677),m=c(45125);async function n(a){let{workspace:b}=await (0,j.nP)(),c=await h.db.select().from(i.agent).where((0,e.eq)(i.agent.workspaceId,b.id)),d=2e5;if(a.startsWith("dm:")){let b=c.find(b=>b.handle===a.slice(3));d=(0,k.S)(b?.model).window}else c.length&&(d=Math.min(...c.map(a=>(0,k.S)(a.model).window)));let g=a.startsWith("dm:")?await (0,m.xF)(b.id,a):null,l=[(0,e.eq)(i.message.workspaceId,b.id),(0,e.eq)(i.message.channel,a)];g&&l.push((0,e.eq)(i.message.sessionId,g));let n=await h.db.select({text:i.message.text,fromKind:i.message.fromKind,fromHandle:i.message.fromHandle}).from(i.message).where((0,e.Uo)(...l)),o=(0,k.b)(n.map(a=>a.text).join("\n")),p=Math.round(.15*d),q=Math.max(0,d-o-p),r=new Map;for(let a of n){if("agent"!==a.fromKind||!a.fromHandle)continue;let b=r.get(a.fromHandle);b?b.push(a.text):r.set(a.fromHandle,[a.text])}let s=await h.db.select({agentId:i.costEntry.agentId,usd:(0,f.cz)(i.costEntry.usd)}).from(i.costEntry).where((0,e.Uo)((0,e.eq)(i.costEntry.workspaceId,b.id),(0,e.eq)(i.costEntry.channel,a))).groupBy(i.costEntry.agentId),t=new Map;for(let a of s){let b=c.find(b=>b.id===a.agentId);b&&t.set(b.handle,Number(a.usd??0))}let u=[...r.entries()].map(([a,b])=>{let d=c.find(b=>b.handle===a);return{handle:a,name:d?.name??a,color:d?.color??"#6b7390",tokens:(0,k.b)(b.join("\n")),usd:t.get(a)??0}}).map(a=>({...a,pct:Math.round(a.tokens/Math.max(1,o)*100)})).sort((a,b)=>b.tokens-a.tokens);return{max:d,used:o,reserve:p,remaining:q,usedPct:Math.min(100,Math.round(o/d*100)),reservePct:Math.round(p/d*100),remainingPct:Math.max(0,Math.round(q/d*100)),perAgent:u}}async function o(a){let{org:b,workspace:c}=await (0,j.nP)(),d=a.startsWith("dm:")?await (0,m.xF)(c.id,a):null,{summary:e}=await (0,l.f)(b.id,c.id,a,null,!0,void 0,d);return(0,g.revalidatePath)("/","layout"),{ok:!0,summarized:!!e}}(0,c(74252).D)([n,o]),(0,d.A)(n,"40972d5b822e66513389d5179af32bb5f9ab77ca88",null),(0,d.A)(o,"4012df9fe60cdc771539fe5ed6ee353f894150d310",null)},53080:(a,b,c)=>{"use strict";c.d(b,{Bl:()=>y,DQ:()=>q,Er:()=>m,H5:()=>p,Iz:()=>o,Nt:()=>w,Oi:()=>g,e1:()=>t,hp:()=>s,iF:()=>u,uy:()=>i,zw:()=>h});var d=c(57086),e=c(83101),f=c(93571);let g="design-mock/APPROVED.md";function h(a,b){let c=(0,d.CS)(a),f=c.filter(a=>a.startsWith("mock/")&&"mock/README.md"!==a),h=c.filter(a=>a.startsWith("design-mock/")&&!/\/README\.md$/i.test(a)&&a!==g),i=c.filter(a=>a.startsWith("design-skills/")&&a.endsWith(".md")&&"design-skills/README.md"!==a),j=Object.entries(b.stack??{}).flatMap(([a,b])=>(0,e.jX)(b).filter(a=>"None"!==a).map(b=>`${a}: ${b}`)).join(", "),k=/^(\.claude\/|DOCS\/|PO\/|Reports\/|specs\/|issues\/|mock\/|design-mock\/|design-skills\/|README\.md$)/i,l=c.some(a=>!k.test(a));return{brief:(0,d.sL)(a,".claude/BRIEF.md")??"",mission:b.mission??"",objective:b.objective??"",stackList:j,mockFiles:f,designMockFiles:h,designSkills:i,approved:(0,d.sL)(a,g),hasImported:l}}function i(a){return[a.mission?`Mission: ${a.mission}`:"",a.objective?`Objective: ${a.objective}`:"",a.stackList?`Chosen stack: ${a.stackList}. Generate markup compatible with it — never generic.`:"",a.brief?`
151
+ ${c}`}):{ok:!1,error:"No conversation to plan from yet."}}(0,c(74252).D)([t,u,v,w,x,y,z,A,B,C,D,E,F]),(0,d.A)(t,"00417fb0c5992b5d8c9bf7bfdb20091c0b75f967d3",null),(0,d.A)(u,"60d43730d40153cb1c4e21154a523dfb9804f2610f",null),(0,d.A)(v,"004b14ab45f1d73caf1fa096fd428f0885213bc9dd",null),(0,d.A)(w,"009534a6350f6d7ee36028fb9ab4659b11f05bd937",null),(0,d.A)(x,"4019def9d61c1f2ae2b3ef51af11efa0f5c439d65d",null),(0,d.A)(y,"4096c37c3555263308f9a36206eaf746d0defe25ad",null),(0,d.A)(z,"40aed83757bf4e7d35906a784d6f38596d11a37abf",null),(0,d.A)(A,"4088847163a13dc2e80c3095763da6ac497a5b9e37",null),(0,d.A)(B,"40ea0236fb2729d70fa5f0bf6383e5f20dfa0c930e",null),(0,d.A)(C,"406d2bac523e293dc8e736d45dbfd24078855b371f",null),(0,d.A)(D,"40e3b911773e190273915e8ecd96b865a3e34df027",null),(0,d.A)(E,"402bb61d0ec0ca426f1594c554cd83c9d2f55e4e2a",null),(0,d.A)(F,"403e4537b9c0d6aa80d4e7fc51b9a4ed3c5f832593",null)},36482:(a,b,c)=>{"use strict";c.d(b,{f:()=>h});var d=c(97603),e=c(95357),f=c(65705),g=c(1890);async function h(a,b,c){try{await f.db.delete(g.event).where((0,d.Uo)((0,d.eq)(g.event.workspaceId,a),(0,d.eq)(g.event.runId,b),(0,d.eq)(g.event.kind,"text")));let h=await f.db.select({seq:g.event.seq}).from(g.event).where((0,d.Uo)((0,d.eq)(g.event.workspaceId,a),(0,d.eq)(g.event.channel,c))).orderBy((0,e.i)(g.event.seq)).limit(500);if(500===h.length){let b=h[h.length-1].seq;await f.db.delete(g.event).where((0,d.Uo)((0,d.eq)(g.event.workspaceId,a),(0,d.eq)(g.event.channel,c),(0,d.lt)(g.event.seq,b)))}}catch(a){console.error("[events-prune] failed:",a)}}},36549:(a,b,c)=>{"use strict";c.d(b,{p:()=>e});var d=c(2910);let e=(0,d.createServerReference)("40632f18c6e8cc524a1b65fbb8e73c1786b9759f01",d.callServer,void 0,d.findSourceMapURL,"conversationContext")},38706:(a,b,c)=>{"use strict";c.d(b,{H:()=>e});var d=c(2910);let e=(0,d.createServerReference)("40daf6dca3077229fd6d6cbccfd335893f03280125",d.callServer,void 0,d.findSourceMapURL,"clearConversation")},42328:(a,b,c)=>{"use strict";c.d(b,{UpdateHeaderBadge:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call UpdateHeaderBadge() from the server but UpdateHeaderBadge is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\update-header-badge.tsx","UpdateHeaderBadge")},43141:(a,b,c)=>{"use strict";c.d(b,{T:()=>e});var d=c(2910);let e=(0,d.createServerReference)("403972c138470189ab9c965aa2785e0f74d37a5ec3",d.callServer,void 0,d.findSourceMapURL,"setActiveOrg")},45125:(a,b,c)=>{"use strict";c.d(b,{Jb:()=>m,OL:()=>n,RL:()=>k,WU:()=>l,X0:()=>j,xF:()=>i});var d=c(77598),e=c(97603),f=c(95357),g=c(65705),h=c(1890);async function i(a,b){if(!b.startsWith("dm:"))return null;let[c]=await g.db.select().from(h.chatSession).where((0,e.Uo)((0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b),(0,e.eq)(h.chatSession.active,!0)));if(c)return c.id;let i=await g.db.select().from(h.chatSession).where((0,e.Uo)((0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b))).orderBy((0,f.i)(h.chatSession.createdAt));if(i.length)return await g.db.update(h.chatSession).set({active:!0}).where((0,e.eq)(h.chatSession.id,i[0].id)),i[0].id;let j=(0,d.randomUUID)();return await g.db.insert(h.chatSession).values({id:j,workspaceId:a,channel:b,title:"Session 1",active:!0}),await g.db.update(h.message).set({sessionId:j}).where((0,e.Uo)((0,e.eq)(h.message.workspaceId,a),(0,e.eq)(h.message.channel,b),(0,e.kZ)(h.message.sessionId))),j}async function j(a,b){return b.startsWith("dm:")?(await i(a,b),(await g.db.select().from(h.chatSession).where((0,e.Uo)((0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b))).orderBy((0,f.i)(h.chatSession.createdAt))).map(a=>({id:a.id,title:a.title,active:a.active,createdAt:(a.createdAt instanceof Date?a.createdAt.getTime():1e3*Number(a.createdAt))||0}))):[]}async function k(a,b,c){if(!b.startsWith("dm:"))return null;await i(a,b);let f=(await g.db.select({id:h.chatSession.id}).from(h.chatSession).where((0,e.Uo)((0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b)))).length,j=(0,d.randomUUID)();return await g.db.update(h.chatSession).set({active:!1}).where((0,e.Uo)((0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b))),await g.db.insert(h.chatSession).values({id:j,workspaceId:a,channel:b,title:c?.trim()||`Session ${f+1}`,active:!0}),j}async function l(a,b,c){let[d]=await g.db.select().from(h.chatSession).where((0,e.Uo)((0,e.eq)(h.chatSession.id,c),(0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b)));d&&(await g.db.update(h.chatSession).set({active:!1}).where((0,e.Uo)((0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b))),await g.db.update(h.chatSession).set({active:!0}).where((0,e.eq)(h.chatSession.id,c)))}async function m(a,b,c){await g.db.update(h.chatSession).set({title:c.trim().slice(0,60)||"Session"}).where((0,e.Uo)((0,e.eq)(h.chatSession.id,b),(0,e.eq)(h.chatSession.workspaceId,a)))}async function n(a,b,c){if(!b.startsWith("dm:"))return;let[d]=await g.db.select().from(h.chatSession).where((0,e.Uo)((0,e.eq)(h.chatSession.id,c),(0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b)));if(d&&(await g.db.delete(h.message).where((0,e.Uo)((0,e.eq)(h.message.workspaceId,a),(0,e.eq)(h.message.sessionId,c))),await g.db.delete(h.chatSession).where((0,e.eq)(h.chatSession.id,c)),d.active)){let[c]=await g.db.select().from(h.chatSession).where((0,e.Uo)((0,e.eq)(h.chatSession.workspaceId,a),(0,e.eq)(h.chatSession.channel,b))).orderBy((0,f.i)(h.chatSession.createdAt));c&&await g.db.update(h.chatSession).set({active:!0}).where((0,e.eq)(h.chatSession.id,c.id))}}},46282:(a,b,c)=>{"use strict";c.d(b,{E_:()=>l,F:()=>j,V:()=>h,VJ:()=>i,zS:()=>k});var d=c(6866),e=c(31371),f=c(53993),g=c(63556);async function h(){let{org:a}=await (0,f.nP)(),b=await (0,g.q)(a.id);return(0,e.revalidatePath)("/knowledge"),(0,e.revalidatePath)("/"),b}async function i(a){let{workspace:b}=await (0,f.nP)(),c=await (0,g.zk)(b.id,{...a,updatedBy:"operator"});return(0,e.revalidatePath)("/knowledge"),(0,e.revalidatePath)("/"),c}async function j(a){let{workspace:b}=await (0,f.nP)();return await (0,g.zo)(b.id,a),(0,e.revalidatePath)("/knowledge"),(0,e.revalidatePath)("/"),{ok:!0}}async function k(a){let{workspace:b}=await (0,f.nP)(),c=await (0,g.t8)(b.id,a,"operator");return(0,e.revalidatePath)("/knowledge"),(0,e.revalidatePath)("/"),c}async function l(a){let{workspace:b}=await (0,f.nP)(),c=await (0,g.IV)(b.id,a,"operator");return(0,e.revalidatePath)("/knowledge"),c}(0,c(74252).D)([h,i,j,k,l]),(0,d.A)(h,"001b3f03a4be8dae997cef3766f261a8abe4f1f85a",null),(0,d.A)(i,"40474231a88f9e8bd4f8bcb6d7e140a521cd469e9c",null),(0,d.A)(j,"40cee959506187490f4f61c2b214db367eb7ce8ff4",null),(0,d.A)(k,"408cb12118c88d982632feabb744bd15c77b28ff96",null),(0,d.A)(l,"409593733c2627144a84b980b2909a9bf701a39f13",null)},46363:(a,b,c)=>{"use strict";c.d(b,{Mp:()=>n,lR:()=>m,sE:()=>l,x7:()=>k});var d=c(6866),e=c(97603),f=c(95357),g=c(54548),h=c(65705),i=c(1890),j=c(53993);async function k(){let{workspace:a}=await (0,j.nP)();return await h.db.select({id:i.notification.id,kind:i.notification.kind,text:i.notification.text,detail:i.notification.detail,messageId:i.notification.messageId,channel:i.notification.channel,createdAt:i.notification.createdAt,agentName:i.agent.name,agentColor:i.agent.color}).from(i.notification).leftJoin(i.agent,(0,e.eq)(i.notification.agentId,i.agent.id)).where((0,e.Uo)((0,e.eq)(i.notification.workspaceId,a.id),(0,e.eq)(i.notification.read,!1),(0,e.RV)(i.notification.kind,["mention","approval"]))).orderBy((0,f.i)(i.notification.createdAt)).limit(20)}async function l(a){let{workspace:b}=await (0,j.nP)();await h.db.update(i.notification).set({read:!0}).where((0,e.Uo)((0,e.eq)(i.notification.id,a),(0,e.eq)(i.notification.workspaceId,b.id)))}async function m(a){let{workspace:b}=await (0,j.nP)();await h.db.insert(i.channelRead).values({workspaceId:b.id,channel:a,lastReadAt:new Date}).onConflictDoUpdate({target:[i.channelRead.workspaceId,i.channelRead.channel],set:{lastReadAt:new Date}})}async function n(){let{workspace:a}=await (0,j.nP)(),b=Object.fromEntries((await h.db.select().from(i.channelRead).where((0,e.eq)(i.channelRead.workspaceId,a.id))).map(a=>[a.channel,a.lastReadAt])),c=await h.db.selectDistinct({channel:i.message.channel}).from(i.message).where((0,e.Uo)((0,e.eq)(i.message.workspaceId,a.id),(0,e.eq)(i.message.fromKind,"agent"))),d={};for(let{channel:f}of c){let c=b[f]??new Date(0),[j]=await h.db.select({n:(0,g.U9)()}).from(i.message).where((0,e.Uo)((0,e.eq)(i.message.workspaceId,a.id),(0,e.eq)(i.message.channel,f),(0,e.eq)(i.message.fromKind,"agent"),(0,e.gt)(i.message.createdAt,c)));Number(j?.n??0)>0&&(d[f]=Number(j.n))}return d}(0,c(74252).D)([k,l,m,n]),(0,d.A)(k,"00ffdd5039d3f6a2972d259f688e974bc22fce2faa",null),(0,d.A)(l,"403917580efb407e1766db48881562b96dbf6c5fcb",null),(0,d.A)(m,"405e24180c17959a1265888000a45d837e7964045b",null),(0,d.A)(n,"008385a17df8e9a6678d83c4e627af6724a6f6bd63",null)},46694:(a,b,c)=>{"use strict";c.d(b,{UpdateHeaderBadge:()=>m});var d=c(4374),e=c(74679),f=c(47104),g=c(43526),h=c(31819),i=c(24746),j=c(92694),k=c(20992),l=c(49123);function m(){let a=(0,h.k)(),b=(0,f.useRouter)(),[c,m]=(0,e.useState)(null),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)("available"),[r,s]=(0,e.useState)(!1),[t,u]=(0,e.useState)(""),v=(0,e.useRef)(null);async function w(){if(!r){s(!0),u("");try{let b=await (0,i.l)(!0);m(b.info.updateAvailable&&b.info.latest?b.info.latest:null),o(b.busy),b.info.updateAvailable||u(a("chrome.update.upToDate"))}catch{}finally{s(!1)}}}async function x(){if("updating"!==p&&!n){if("done"===p)return void b.refresh();q("updating"),u("");try{let c=await (0,j.P)();if(c.blocked){q("available"),o(!0),u(a("chrome.update.busy"));return}c.started?v.current=setInterval(async()=>{let b=await (0,k.e)().catch(a=>((0,l.st)(a)&&(v.current&&clearInterval(v.current),(0,l.Uy)()),null));b&&("done"===b.status?(v.current&&clearInterval(v.current),window.location.reload()):"error"===b.status&&(v.current&&clearInterval(v.current),q("error"),u(a("chrome.update.failed"))))},3e3):(q("available"),u(c.message||""),b.push("/update"))}catch{q("error"),u(a("chrome.update.failed"))}}}let y=(0,d.jsx)("button",{type:"button",className:"top-btn",onClick:w,disabled:r,title:t||a("chrome.update.check"),children:(0,d.jsx)("span",{className:r?"sync-spin":"",style:{display:"inline-flex"},children:(0,d.jsx)(g.I,{name:"sync",size:17})})});if(!c)return y;let z="updating"===p?a("chrome.update.updating"):"done"===p?a("chrome.update.restart"):"error"===p?a("chrome.update.failed"):n?`v${c}`:`${a("chrome.update.update")} v${c}`,A="updating"===p||n;return(0,d.jsxs)(d.Fragment,{children:[y,(0,d.jsxs)("button",{type:"button",onClick:x,disabled:A,title:n?a("chrome.update.busy"):t||`${a("chrome.update.available")} — v${c}`,style:{display:"inline-flex",alignItems:"center",gap:6,width:"auto",padding:"0 11px",height:30,background:"error"===p?"var(--sx-keyword)":n?"var(--bg-active)":"var(--accent)",color:n?"var(--text-dim)":"var(--accent-fg)",borderRadius:999,fontSize:12,fontWeight:600,border:"none",opacity:"updating"===p?.75:1,cursor:A?"default":"pointer"},children:["updating"===p?(0,d.jsx)("span",{className:"sync-spin",style:{display:"inline-flex"},children:(0,d.jsx)(g.I,{name:"sync",size:14})}):(0,d.jsx)(g.I,{name:"updating"===p?"sync":"done"===p?"refresh":"error"===p?"bell":"arrowUp",size:14}),(0,d.jsx)("span",{children:z})]})]})}},47541:(a,b,c)=>{Promise.resolve().then(c.bind(c,50069)),Promise.resolve().then(c.bind(c,17309)),Promise.resolve().then(c.bind(c,4864)),Promise.resolve().then(c.bind(c,1130)),Promise.resolve().then(c.bind(c,86203))},48442:(a,b,c)=>{"use strict";c.d(b,{E:()=>d,e:()=>e});let d=["Cockpit","Hierarchy","Execution","Product","Knowledge","Operations","Inbox","System"],e=[{id:"home",title:"Home",href:"/",group:"Cockpit",tile:"Welcome — canonical knowledge & quick navigation",icon:"grid"},{id:"dashboard",title:"Dashboard",href:"/dashboard",group:"Cockpit",tile:"Cockpit hub — status at a glance",icon:"pulse"},{id:"organizations",title:"Organizations",href:"/organizations",group:"Hierarchy",tile:"Manage organizations & workspaces",icon:"grid"},{id:"org",title:"Org Chart",href:"/org",group:"Hierarchy",tile:"Hierarchy & delegation",icon:"agents"},{id:"agents",title:"Agent Studio",href:"/agents/ada",group:"Hierarchy",tile:"Configure each agent",icon:"bot"},{id:"code",title:"Code",href:"/code",group:"Execution",tile:"Code editor & repo files",icon:"terminal"},{id:"tasks",title:"Tasks",href:"/tasks",group:"Execution",tile:"Team kanban board",icon:"files"},{id:"cron",title:"Cron",href:"/cron",group:"Execution",tile:"Scheduled tasks & history",icon:"calendar"},{id:"routines",title:"Routines",href:"/routines",group:"Execution",tile:"Recurring automations",icon:"repeat"},{id:"goals",title:"Goals",href:"/goals",group:"Execution",tile:"Objective tree",icon:"target"},{id:"design",title:"Design",href:"/design",group:"Execution",tile:"Prototype the UI with the frontend agent before the plan",icon:"grid"},{id:"planner",title:"CEO Planner",href:"/planner",group:"Execution",tile:"Specs → issues → approval → 24/7",icon:"command"},{id:"test-dev",title:"Test Dev",href:"/test-dev",group:"Execution",tile:"Boot, navigate + validate the project",icon:"play"},{id:"pm",title:"Product Manager",href:"/pm",group:"Product",tile:"Sprints & backlog (PO)",icon:"goto"},{id:"reports",title:"Reports",href:"/reports",group:"Knowledge",tile:"Plans, reviews, audits",icon:"doc"},{id:"docs",title:"Docs",href:"/docs",group:"Knowledge",tile:"Architecture, API & PO docs",icon:"doc"},{id:"skills",title:"Skills",href:"/skills",group:"Knowledge",tile:"Agent procedure library",icon:"skill"},{id:"activity",title:"Activity",href:"/activity",group:"Knowledge",tile:"Agent action timeline",icon:"pulse"},{id:"knowledge",title:"Knowledge",href:"/knowledge",group:"Knowledge",tile:"KB index, coverage, gaps & agent recall",icon:"branch"},{id:"costs",title:"Costs",href:"/costs",group:"Operations",tile:"Spend by agent/provider",icon:"coins"},{id:"security",title:"Security",href:"/security",group:"Operations",tile:"Findings & security score",icon:"shield"},{id:"pulse",title:"Pulse",href:"/pulse",group:"Operations",tile:"Agent health & validation",icon:"pulse"},{id:"github",title:"Commit GitHub",href:"/github",group:"Operations",tile:"Push workspace to remote",icon:"git"},{id:"prepare-deploy",title:"Prepare Deploy",href:"/prepare-deploy",group:"Operations",tile:"Prod-prep + export clean source to a deploy repo",icon:"goto"},{id:"models",title:"Models",href:"/models",group:"Operations",tile:"Providers & local models",icon:"cpu"},{id:"update",title:"Update",href:"/update",group:"Operations",tile:"Detect & apply new versions",icon:"goto"},{id:"plugins",title:"Plugins",href:"/plugins",group:"Operations",tile:"Extensions & integrations",icon:"ext"},{id:"inbox",title:"Inbox",href:"/inbox",group:"Inbox",tile:"Approvals & escalations",icon:"inbox"},{id:"notifications",title:"Notifications",href:"/notifications",group:"Inbox",tile:"Passive alert feed",icon:"bell"},{id:"config",title:"Config",href:"/config",group:"System",tile:"Platform settings",icon:"settings"},{id:"profile",title:"Profile",href:"/profile",group:"System",tile:"Account & preferences",icon:"account"}]},48503:(a,b,c)=>{"use strict";c.d(b,{Z:()=>f});let d=["CONSTELLA_VAULT_KEY","BETTER_AUTH_SECRET","CONSTELLA_WORKER_SECRET"],e=RegExp("sk-[A-Za-z0-9_-]{16,}|gh[posru]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{40,}|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{30,}|xox[baprs]-[A-Za-z0-9-]{10,}|eyJ[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{6,}|-----BEGIN[\\s\\S]*?PRIVATE KEY-----[\\s\\S]*?-----END[\\s\\S]*?-----|\\bcn_[A-Za-z0-9_-]{24,}\\b|\\b\\d{6,}:[A-Za-z0-9_-]{30,}\\b","g");function f(a,b=[]){if(!a)return a;let c=a;for(let a of[...b,...d.map(a=>process.env[a])])a&&a.length>=8&&(c=c.split(a).join("[redacted]"));return c.replace(e,"[redacted]")}},50069:(a,b,c)=>{"use strict";c.d(b,{ChatDockGate:()=>g});var d=c(4374),e=c(47104),f=c(69390);function g(a){return"/"===(0,e.usePathname)()?null:(0,d.jsx)(f.uG,{...a})}},51203:(a,b,c)=>{"use strict";c.d(b,{ChatDockGate:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call ChatDockGate() from the server but ChatDockGate is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\chat-dock-gate.tsx","ChatDockGate")},51605:(a,b,c)=>{"use strict";c.d(b,{L:()=>o,p:()=>n});var d=c(6866),e=c(97603),f=c(54548),g=c(31371),h=c(65705),i=c(1890),j=c(53993),k=c(57806),l=c(12677),m=c(45125);async function n(a){let{workspace:b}=await (0,j.nP)(),c=await h.db.select().from(i.agent).where((0,e.eq)(i.agent.workspaceId,b.id)),d=2e5;if(a.startsWith("dm:")){let b=c.find(b=>b.handle===a.slice(3));d=(0,k.S)(b?.model).window}else c.length&&(d=Math.min(...c.map(a=>(0,k.S)(a.model).window)));let g=a.startsWith("dm:")?await (0,m.xF)(b.id,a):null,l=[(0,e.eq)(i.message.workspaceId,b.id),(0,e.eq)(i.message.channel,a)];g&&l.push((0,e.eq)(i.message.sessionId,g));let n=await h.db.select({text:i.message.text,fromKind:i.message.fromKind,fromHandle:i.message.fromHandle}).from(i.message).where((0,e.Uo)(...l)),o=(0,k.b)(n.map(a=>a.text).join("\n")),p=Math.round(.15*d),q=Math.max(0,d-o-p),r=new Map;for(let a of n){if("agent"!==a.fromKind||!a.fromHandle)continue;let b=r.get(a.fromHandle);b?b.push(a.text):r.set(a.fromHandle,[a.text])}let s=await h.db.select({agentId:i.costEntry.agentId,usd:(0,f.cz)(i.costEntry.usd)}).from(i.costEntry).where((0,e.Uo)((0,e.eq)(i.costEntry.workspaceId,b.id),(0,e.eq)(i.costEntry.channel,a))).groupBy(i.costEntry.agentId),t=new Map;for(let a of s){let b=c.find(b=>b.id===a.agentId);b&&t.set(b.handle,Number(a.usd??0))}let u=[...r.entries()].map(([a,b])=>{let d=c.find(b=>b.handle===a);return{handle:a,name:d?.name??a,color:d?.color??"#6b7390",tokens:(0,k.b)(b.join("\n")),usd:t.get(a)??0}}).map(a=>({...a,pct:Math.round(a.tokens/Math.max(1,o)*100)})).sort((a,b)=>b.tokens-a.tokens);return{max:d,used:o,reserve:p,remaining:q,usedPct:Math.min(100,Math.round(o/d*100)),reservePct:Math.round(p/d*100),remainingPct:Math.max(0,Math.round(q/d*100)),perAgent:u}}async function o(a){let{org:b,workspace:c}=await (0,j.nP)(),d=a.startsWith("dm:")?await (0,m.xF)(c.id,a):null,{summary:e}=await (0,l.f)(b.id,c.id,a,null,!0,void 0,d);return(0,g.revalidatePath)("/","layout"),{ok:!0,summarized:!!e}}(0,c(74252).D)([n,o]),(0,d.A)(n,"40632f18c6e8cc524a1b65fbb8e73c1786b9759f01",null),(0,d.A)(o,"40e5564668bafedda17fe12ac371e358864fd39c63",null)},53080:(a,b,c)=>{"use strict";c.d(b,{Bl:()=>y,DQ:()=>q,Er:()=>m,H5:()=>p,Iz:()=>o,Nt:()=>w,Oi:()=>g,e1:()=>t,hp:()=>s,iF:()=>u,uy:()=>i,zw:()=>h});var d=c(57086),e=c(83101),f=c(93571);let g="design-mock/APPROVED.md";function h(a,b){let c=(0,d.CS)(a),f=c.filter(a=>a.startsWith("mock/")&&"mock/README.md"!==a),h=c.filter(a=>a.startsWith("design-mock/")&&!/\/README\.md$/i.test(a)&&a!==g),i=c.filter(a=>a.startsWith("design-skills/")&&a.endsWith(".md")&&"design-skills/README.md"!==a),j=Object.entries(b.stack??{}).flatMap(([a,b])=>(0,e.jX)(b).filter(a=>"None"!==a).map(b=>`${a}: ${b}`)).join(", "),k=/^(\.claude\/|DOCS\/|PO\/|Reports\/|specs\/|issues\/|mock\/|design-mock\/|design-skills\/|README\.md$)/i,l=c.some(a=>!k.test(a));return{brief:(0,d.sL)(a,".claude/BRIEF.md")??"",mission:b.mission??"",objective:b.objective??"",stackList:j,mockFiles:f,designMockFiles:h,designSkills:i,approved:(0,d.sL)(a,g),hasImported:l}}function i(a){return[a.mission?`Mission: ${a.mission}`:"",a.objective?`Objective: ${a.objective}`:"",a.stackList?`Chosen stack: ${a.stackList}. Generate markup compatible with it — never generic.`:"",a.brief?`
152
152
  Project brief:
153
153
  ${a.brief.slice(0,3e3)}`:"",a.mockFiles.length?`
154
154
  Attached mock/prototype (${a.mockFiles.length} files): ${a.mockFiles.slice(0,14).join(", ")} — read them and match the product precisely.`:"",a.designMockFiles.length?`
@@ -158,7 +158,7 @@ An APPROVED design already exists (design-mock/APPROVED.md) — the official vis
158
158
  There is an existing imported/scaffolded project in this workspace — extend it, preserve its visual identity.`:""].filter(Boolean).join("\n")}let j={hotel:["hospitality","booking","reservation","rooms","travel","checkin","premium","gallery","amenities"],hospedagem:["hotel","booking","reservation","rooms","hospitality"],reserva:["booking","calendar","availability","checkout"],restaurant:["menu","food","reservation","hospitality","gallery"],restaurante:["menu","food","reservation","hospitality"],ecommerce:["product","cart","checkout","catalog","pricing","payment"],loja:["ecommerce","product","cart","checkout","catalog"],shop:["ecommerce","product","cart","checkout"],store:["ecommerce","product","cart","checkout"],dashboard:["charts","dataviz","tables","kpi","analytics","admin"],saas:["dashboard","pricing","onboarding","settings","billing"],fintech:["dashboard","charts","security","transactions","kpi"],banking:["fintech","transactions","security","cards","dashboard"],banco:["fintech","transactions","security","cards"],calculator:["mobile","grid","buttons","keypad","ios"],calculadora:["mobile","grid","buttons","keypad","ios"],apple:["ios","glassmorphism","minimal","typography","rounded","microinteractions"],ios:["apple","glassmorphism","mobile","rounded","microinteractions","minimal"],glassmorphism:["blur","translucent","frosted","depth","gradient"],neumorphism:["shadow","embossed","monochrome"],minimal:["whitespace","typography","restraint","grid"],minimalista:["whitespace","typography","grid"],brutalist:["bold","contrast","raw","monospace"],landing:["hero","cta","sections","features","testimonials","pricing","footer"],portfolio:["gallery","grid","casestudy","minimal","typography"],blog:["typography","reading","article","content"],social:["feed","cards","avatars","interactions","realtime"],chat:["messages","bubbles","realtime","input","avatars"],mobile:["responsive","touch","ios","android"],admin:["dashboard","tables","forms","crud","data"],dark:["theme","contrast"],premium:["luxury","typography","spacing","motion","elegant"],animation:["motion","transitions","keyframes","microinteractions"],motion:["animation","transitions","microinteractions"],accessibility:["a11y","contrast","focus","aria","wcag"]},k=new Set("the a an and or of to for with in on at is are be this that you your our it its build create make page screen app site website using use want need please can grace design quero uma para com que the and dos das uma novo nova".split(/\s+/));function l(a){return(a||"").toLowerCase().replace(/[^a-z0-9çãáéíóúâêôà\s-]/gi," ").split(/\s+/).filter(a=>a.length>=3&&!k.has(a))}function m(a,b){let c=function(a,b){let c=l([b||"",a.mission,a.objective,a.brief.slice(0,1500),a.stackList,a.mockFiles.map(a=>a.split("/").pop()||"").join(" ")].join(" ")),d={};for(let a of c)d[a]=(d[a]||0)+1;if(b)for(let a of l(b))d[a]=(d[a]||0)+3;let e=new Map;for(let a of Object.keys(d))e.set(a,(e.get(a)||0)+d[a]);for(let a of Object.keys(d))for(let[b,c]of Object.entries(j))if(a.includes(b)||b.includes(a))for(let a of c)e.set(a,(e.get(a)||0)+1);return Array.from(e.entries()).sort((a,b)=>b[1]-a[1]).map(([a])=>a).slice(0,24)}(a,b),d=function(a,b=8){let c=a.map(a=>a.toLowerCase());if(!c.length)return[];let d=[];for(let a of(0,f.Cg)().values()){let b=(a.tags||[]).map(a=>a.toLowerCase()),e=(a.name+" "+a.description+" "+a.domain+" "+a.category+" "+b.join(" ")).toLowerCase(),f=a.name.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean),g=0;for(let a of c)f.includes(a)||b.includes(a)?g+=4:e.includes(a)&&(g+=1);("design"===a.domain||"design"===a.category)&&(g+=.5),g>0&&d.push({name:a.name,description:a.description,score:g})}return d.sort((a,b)=>b.score-a.score).slice(0,b).map(({name:a,description:b})=>({name:a,description:b}))}(c,8);return[c.length?`
159
159
  DETECTED CONTEXT (domain + visual intent): ${c.slice(0,16).join(", ")}. Ground the palette, typography, layout, components and motion in THIS product's domain and style — never a generic AI look.`:"",d.length?`
160
160
  MOST RELEVANT seeded skills for THIS request — READ the matching \`.claude/skills/<name>.md\` FIRST before building:
161
- ${d.map(a=>`- ${a.name}: ${a.description}`).join("\n")}`:""].filter(Boolean).join("\n")}let n=".claude/design-gate.json";function o(a){let b=(0,d.sL)(a,n);if(!b)return{};try{return JSON.parse(b)||{}}catch{return{}}}function p(a,b){try{(0,d.dx)(a,n,JSON.stringify(b,null,2))}catch{}}function q(a){p(a,{skip:!1})}let r=".claude/design-promoted.json";function s(a){let b=(0,d.sL)(a,r);if(!b)return{};try{return JSON.parse(b)||{}}catch{return{}}}function t(a,b){try{(0,d.dx)(a,r,JSON.stringify(b,null,2))}catch{}}function u(a){let b=a.designMockFiles.some(a=>/design-mock\/screens\/.+\.html?$/i.test(a));return!a.approved&&!b}let v=/\b(tela|telas|screen|screens|p[áa]gina|pagina|page|pages|web|webapp|web-?app|website|site|app|apps|aplicativo|aplica[çc][ãa]o|spa|single-?page|pwa|ui|ux|interface|frontend|front-?end|layout|component|componente|design|visual|dashboard|form|formul[áa]rio|formulario|bot[ãa]o|botao|button|modal|menu|nav|navbar|sidebar|card|landing|hero|gallery|galeria|theme|tema|palette|paleta|typography|tipografia|style|estilo|css|html|responsive|responsiv[oa]|mobile|desktop|tablet|anima[çc][ãa]o|animation|microintera[çc][õo]es|wizard|onboarding|checkout|perfil|profile|settings|configura[çc][õo]es|view|views|render)\b/i;function w(a){return!!a&&v.test(a)}let x=/\b(api|rest|restful|graphql|grpc|cli|command[\s-]?line|terminal|backend|back-?end|micro-?service|microservices|service|library|\bsdk\b|daemon|cron|scheduler|pipeline|etl|database|\bdb\b|infra|infrastructure|devops|webhook|message[\s-]?queue|\bqueue\b|worker|scraper|crawler|\bbot\b|middleware|server[\s-]?side|protocol|compiler|parser|scraping)\b/i;function y(a){return!!a&&x.test(a)&&!w(a)}},55357:(a,b,c)=>{"use strict";c.d(b,{V:()=>e});var d=c(2910);let e=(0,d.createServerReference)("406201c1d173ad16581e88feb7fdf42ebbc95ef841",d.callServer,void 0,d.findSourceMapURL,"getMessages")},55872:(a,b,c)=>{"use strict";c.d(b,{ChatToggle:()=>g});var d=c(4374),e=c(43526),f=c(31819);function g(){let a=(0,f.k)();return(0,d.jsx)("button",{className:"top-btn",title:`${a("chrome.chat.agentRoom")} (⌘J)`,type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("constella:toggle-chat")),children:(0,d.jsx)(e.I,{name:"chat",size:17})})}},56338:(a,b,c)=>{"use strict";c.d(b,{uJ:()=>w,V1:()=>A,c5:()=>u,ru:()=>F,ed:()=>O,yY:()=>G,Qi:()=>V,Mn:()=>J,aE:()=>U,QU:()=>y});var d=c(77598),e=c(97603),f=c(95357),g=c(54548),h=c(65705),i=c(1890),j=c(57300),k=c(70149),l=c(1273),m=c(31578),n=c(57086),o=c(83963),p=c(24701),q=c(48503);let r=`You are Vannevar, the Knowledge agent — Constella's CENTRAL SOURCE OF TRUTH. You own the Knowledge Base (KB): a curated, classified, state-aware layer over the semantic RAG index.
161
+ ${d.map(a=>`- ${a.name}: ${a.description}`).join("\n")}`:""].filter(Boolean).join("\n")}let n=".claude/design-gate.json";function o(a){let b=(0,d.sL)(a,n);if(!b)return{};try{return JSON.parse(b)||{}}catch{return{}}}function p(a,b){try{(0,d.dx)(a,n,JSON.stringify(b,null,2))}catch{}}function q(a){p(a,{skip:!1})}let r=".claude/design-promoted.json";function s(a){let b=(0,d.sL)(a,r);if(!b)return{};try{return JSON.parse(b)||{}}catch{return{}}}function t(a,b){try{(0,d.dx)(a,r,JSON.stringify(b,null,2))}catch{}}function u(a){let b=a.designMockFiles.some(a=>/design-mock\/screens\/.+\.html?$/i.test(a));return!a.approved&&!b}let v=/\b(tela|telas|screen|screens|p[áa]gina|pagina|page|pages|web|webapp|web-?app|website|site|app|apps|aplicativo|aplica[çc][ãa]o|spa|single-?page|pwa|ui|ux|interface|frontend|front-?end|layout|component|componente|design|visual|dashboard|form|formul[áa]rio|formulario|bot[ãa]o|botao|button|modal|menu|nav|navbar|sidebar|card|landing|hero|gallery|galeria|theme|tema|palette|paleta|typography|tipografia|style|estilo|css|html|responsive|responsiv[oa]|mobile|desktop|tablet|anima[çc][ãa]o|animation|microintera[çc][õo]es|wizard|onboarding|checkout|perfil|profile|settings|configura[çc][õo]es|view|views|render)\b/i;function w(a){return!!a&&v.test(a)}let x=/\b(api|rest|restful|graphql|grpc|cli|command[\s-]?line|terminal|backend|back-?end|micro-?service|microservices|service|library|\bsdk\b|daemon|cron|scheduler|pipeline|etl|database|\bdb\b|infra|infrastructure|devops|webhook|message[\s-]?queue|\bqueue\b|worker|scraper|crawler|\bbot\b|middleware|server[\s-]?side|protocol|compiler|parser|scraping)\b/i;function y(a){return!!a&&x.test(a)&&!w(a)}},55872:(a,b,c)=>{"use strict";c.d(b,{ChatToggle:()=>g});var d=c(4374),e=c(43526),f=c(31819);function g(){let a=(0,f.k)();return(0,d.jsx)("button",{className:"top-btn",title:`${a("chrome.chat.agentRoom")} (⌘J)`,type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("constella:toggle-chat")),children:(0,d.jsx)(e.I,{name:"chat",size:17})})}},56338:(a,b,c)=>{"use strict";c.d(b,{uJ:()=>w,V1:()=>A,c5:()=>u,ru:()=>F,ed:()=>O,yY:()=>G,Qi:()=>V,Mn:()=>J,aE:()=>U,QU:()=>y});var d=c(77598),e=c(97603),f=c(95357),g=c(54548),h=c(65705),i=c(1890),j=c(57300),k=c(70149),l=c(1273),m=c(31578),n=c(57086),o=c(83963),p=c(24701),q=c(48503);let r=`You are Vannevar, the Knowledge agent — Constella's CENTRAL SOURCE OF TRUTH. You own the Knowledge Base (KB): a curated, classified, state-aware layer over the semantic RAG index.
162
162
 
163
163
  ## What the KB is for
164
164
  Agents must not leave reusable knowledge scattered in chat. When anything important is created, changed, discovered, reviewed or completed, it is captured into a typed kb_entry, deduped, lifecycle-tracked (active → superseded → obsolete → archived), embedded, and made retrievable. You keep it organised, current and trustworthy.
@@ -327,9 +327,9 @@ ${f}
327
327
 
328
328
  ## Procedure
329
329
  ${e}
330
- `)}catch{}o.add(b),w++}return w&&await (0,p.I)(c.id,{kind:"review",text:`${j.name} proposed ${w} new skill${1===w?"":"s"} from learnings`,detail:"Review + approve in /skills.",agentId:j.id}),{ok:!0,proposed:w}}catch{return b}}let W=new Map,X=new Map},57269:(a,b,c)=>{Promise.resolve().then(c.bind(c,51203)),Promise.resolve().then(c.bind(c,24960)),Promise.resolve().then(c.bind(c,28018)),Promise.resolve().then(c.bind(c,64557)),Promise.resolve().then(c.bind(c,18773))},57806:(a,b,c)=>{"use strict";function d(a){let b=(a||"").toLowerCase();return b.includes("opus")||b.includes("sonnet")?{window:2e5,keepRecent:16,aggressive:!1}:b.includes("haiku")?{window:2e5,keepRecent:12,aggressive:!1}:b.startsWith("gpt")||b.includes("codex")||b.startsWith("o3")||b.startsWith("o4")?{window:128e3,keepRecent:12,aggressive:!0}:{window:1e5,keepRecent:8,aggressive:!0}}function e(a){return Math.ceil(a.length/4)}c.d(b,{S:()=>d,b:()=>e})},58169:(a,b,c)=>{"use strict";c.d(b,{y:()=>j});var d=c(6866),e=c(97603),f=c(95357),g=c(65705),h=c(1890),i=c(53993);async function j(a){let{workspace:b}=await (0,i.nP)(),c=new Date(Math.max(0,Math.floor(a)));return(await g.db.select().from(h.notification).where((0,e.Uo)((0,e.eq)(h.notification.workspaceId,b.id),(0,e.gt)(h.notification.createdAt,c))).orderBy((0,f.i)(h.notification.createdAt)).limit(8)).map(a=>({id:a.id,kind:a.kind,text:a.text,detail:a.detail,channel:a.channel,at:a.createdAt.getTime()}))}(0,c(74252).D)([j]),(0,d.A)(j,"4010339d35fee3f9209079d6bec35c010e1bbd23f5",null)},62565:(a,b,c)=>{"use strict";c.d(b,{G:()=>e});var d=c(2910);let e=(0,d.createServerReference)("00ee824db0a18ba9e4b113a979c27e43db14785003",d.callServer,void 0,d.findSourceMapURL,"telegramStatus")},63556:(a,b,c)=>{"use strict";c.d(b,{IV:()=>y,Xe:()=>t,bX:()=>s,iJ:()=>w,q:()=>v,t8:()=>x,zk:()=>q,zo:()=>r});var d=c(77598),e=c(97603),f=c(95357),g=c(65705),h=c(1890),i=c(57300),j=c(56338),k=c(77558),l=c(24701);let m=/^[a-z0-9][a-z0-9-]{0,60}$/,n=a=>(a||"").toLowerCase().trim().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60);async function o(a){let[b]=await g.db.select({id:h.workspace.id}).from(h.workspace).where((0,e.eq)(h.workspace.orgId,a));return b?.id??null}async function p(a,b,c,f){let j=`block/${b}`;await g.db.delete(h.ragChunk).where((0,e.Uo)((0,e.eq)(h.ragChunk.workspaceId,a),(0,e.eq)(h.ragChunk.path,j)));let k=`# ${c||b}
330
+ `)}catch{}o.add(b),w++}return w&&await (0,p.I)(c.id,{kind:"review",text:`${j.name} proposed ${w} new skill${1===w?"":"s"} from learnings`,detail:"Review + approve in /skills.",agentId:j.id}),{ok:!0,proposed:w}}catch{return b}}let W=new Map,X=new Map},57269:(a,b,c)=>{Promise.resolve().then(c.bind(c,51203)),Promise.resolve().then(c.bind(c,24960)),Promise.resolve().then(c.bind(c,28018)),Promise.resolve().then(c.bind(c,64557)),Promise.resolve().then(c.bind(c,18773))},57806:(a,b,c)=>{"use strict";function d(a){let b=(a||"").toLowerCase();return b.includes("opus")||b.includes("sonnet")?{window:2e5,keepRecent:16,aggressive:!1}:b.includes("haiku")?{window:2e5,keepRecent:12,aggressive:!1}:b.startsWith("gpt")||b.includes("codex")||b.startsWith("o3")||b.startsWith("o4")?{window:128e3,keepRecent:12,aggressive:!0}:{window:1e5,keepRecent:8,aggressive:!0}}function e(a){return Math.ceil(a.length/4)}c.d(b,{S:()=>d,b:()=>e})},58169:(a,b,c)=>{"use strict";c.d(b,{y:()=>j});var d=c(6866),e=c(97603),f=c(95357),g=c(65705),h=c(1890),i=c(53993);async function j(a){let{workspace:b}=await (0,i.nP)(),c=new Date(Math.max(0,Math.floor(a)));return(await g.db.select().from(h.notification).where((0,e.Uo)((0,e.eq)(h.notification.workspaceId,b.id),(0,e.gt)(h.notification.createdAt,c))).orderBy((0,f.i)(h.notification.createdAt)).limit(8)).map(a=>({id:a.id,kind:a.kind,text:a.text,detail:a.detail,channel:a.channel,at:a.createdAt.getTime()}))}(0,c(74252).D)([j]),(0,d.A)(j,"40b05dffaf8ef88241a211ca40c5da2d954b5a412e",null)},63556:(a,b,c)=>{"use strict";c.d(b,{IV:()=>y,Xe:()=>t,bX:()=>s,iJ:()=>w,q:()=>v,t8:()=>x,zk:()=>q,zo:()=>r});var d=c(77598),e=c(97603),f=c(95357),g=c(65705),h=c(1890),i=c(57300),j=c(56338),k=c(77558),l=c(24701);let m=/^[a-z0-9][a-z0-9-]{0,60}$/,n=a=>(a||"").toLowerCase().trim().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60);async function o(a){let[b]=await g.db.select({id:h.workspace.id}).from(h.workspace).where((0,e.eq)(h.workspace.orgId,a));return b?.id??null}async function p(a,b,c,f){let j=`block/${b}`;await g.db.delete(h.ragChunk).where((0,e.Uo)((0,e.eq)(h.ragChunk.workspaceId,a),(0,e.eq)(h.ragChunk.path,j)));let k=`# ${c||b}
331
331
  ${(f||"").trim()}`.slice(0,6e3);for(let b of(0,i.U_)(k)){let c=await (0,i.E6)(b);await g.db.insert(h.ragChunk).values({id:(0,d.randomUUID)(),workspaceId:a,path:j,chunk:b,vector:c?JSON.stringify(c):null,obsolete:!1})}}async function q(a,b){try{(0,j.V1)();let c=n(b.slug);if(!c||!m.test(c))return{ok:!1,slug:""};let d=(b.title??"").slice(0,200),f=(b.body??"").slice(0,2e4),i=(b.kind??"note").slice(0,40),k=(b.updatedBy??"operator").slice(0,60),[l]=await g.db.select().from(h.syncedBlock).where((0,e.Uo)((0,e.eq)(h.syncedBlock.workspaceId,a),(0,e.eq)(h.syncedBlock.slug,c)));return l?await g.db.update(h.syncedBlock).set({kind:i,title:d||l.title,body:f,version:l.version+1,updatedBy:k,updatedAt:new Date}).where((0,e.Uo)((0,e.eq)(h.syncedBlock.workspaceId,a),(0,e.eq)(h.syncedBlock.slug,c))):await g.db.insert(h.syncedBlock).values({workspaceId:a,slug:c,kind:i,title:d||c,body:f,version:1,updatedBy:k}),await p(a,c,d||l?.title||c,f),{ok:!0,slug:c}}catch{return{ok:!1,slug:""}}}async function r(a,b){try{(0,j.V1)(),await g.db.delete(h.syncedBlock).where((0,e.Uo)((0,e.eq)(h.syncedBlock.workspaceId,a),(0,e.eq)(h.syncedBlock.slug,b))),await g.db.delete(h.ragChunk).where((0,e.Uo)((0,e.eq)(h.ragChunk.workspaceId,a),(0,e.eq)(h.ragChunk.path,`block/${b}`)))}catch{}}async function s(a,b){if(!b||!b.includes("{{kb:"))return b;try{let c=await o(a);if(!c)return b;let d=await g.db.select({slug:h.syncedBlock.slug,body:h.syncedBlock.body}).from(h.syncedBlock).where((0,e.eq)(h.syncedBlock.workspaceId,c)),f=new Map(d.map(a=>[a.slug,a.body]));return b.replace(/\{\{kb:([a-z0-9-]+)\}\}/gi,(a,b)=>f.get(String(b).toLowerCase())??`[[missing block: ${b}]]`)}catch{return b}}async function t(a){try{(0,j.V1)();let b=await g.db.select().from(h.syncedBlock).where((0,e.eq)(h.syncedBlock.workspaceId,a)).orderBy((0,f.i)(h.syncedBlock.updatedAt)).limit(20);if(!b.length)return"";return b.map(a=>`### ${a.title||a.slug} (${a.kind})
332
- ${(a.body||"").trim().slice(0,800)}`).join("\n\n").slice(0,5e3)}catch{return""}}let u=[{slug:"mission",kind:"mission",title:"Mission",starter:""},{slug:"objective",kind:"objective",title:"Objective",starter:""},{slug:"official-stack",kind:"stack",title:"Official stack",starter:""},{slug:"current-architecture",kind:"architecture",title:"Current architecture",starter:"_Describe the system's current shape, modules and data flow — the architecture every agent should treat as canonical._"},{slug:"business-rules",kind:"business-rule",title:"Business rules",starter:"_List the domain rules the product must always obey._"},{slug:"ui-patterns",kind:"ui-pattern",title:"UI patterns",starter:"_Canonical UI/UX conventions and component patterns._"},{slug:"security-patterns",kind:"security",title:"Security patterns",starter:"_Required security practices: auth, secrets, isolation, input validation._"},{slug:"deploy-checklist",kind:"deploy-checklist",title:"Deploy checklist",starter:"_Steps that must pass before a deploy._"},{slug:"code-review-checklist",kind:"review-checklist",title:"Code review checklist",starter:"_What every review must check before merge._"},{slug:"glossary",kind:"glossary",title:"Glossary",starter:"_Shared vocabulary for the project._"},{slug:"technical-decisions",kind:"note",title:"Technical decisions",starter:"_The durable “why we chose X” log._"}];async function v(a){let b=0;try{(0,j.V1)();let[c]=await g.db.select().from(h.workspace).where((0,e.eq)(h.workspace.orgId,a));if(!c)return{seeded:b};let d=new Set((await g.db.select({slug:h.syncedBlock.slug}).from(h.syncedBlock).where((0,e.eq)(h.syncedBlock.workspaceId,c.id))).map(a=>a.slug)),f=Object.entries(c.stack??{}).filter(([,a])=>a&&"None"!==a).map(([a,b])=>`- **${a}:** ${b}`).join("\n"),i={mission:c.mission||"",objective:c.objective||"","official-stack":f};for(let a of u){if(d.has(a.slug))continue;let e=(i[a.slug]??"").trim()||a.starter;e&&(await q(c.id,{slug:a.slug,kind:a.kind,title:a.title,body:e,updatedBy:"system"}),b++)}}catch{}return{seeded:b}}async function w(a,b){try{(0,j.V1)();let c=await o(a);if(!c)return{ok:!1};let e=n(b.slug);if(!e||!b.body.trim())return{ok:!1};let f=(0,d.randomUUID)();return await g.db.insert(h.blockProposal).values({id:f,workspaceId:c,slug:e,kind:(b.kind??"note").slice(0,40),title:(b.title??"").slice(0,200),body:b.body.slice(0,2e4),byAgentHandle:(b.byAgentHandle??"").slice(0,60),status:"pending"}),await (0,k.vE)(c,{kind:"review",refType:"validation",refId:f,fromAgentId:null,title:`Block edit proposed — ${e}`,detail:`@${b.byAgentHandle} proposed an edit to the “${e}” knowledge block. Review + merge in Knowledge.`.slice(0,400)}),await (0,l.I)(c,{kind:"review",text:`Knowledge block edit proposed — ${e}`,detail:`by @${b.byAgentHandle}`}),{ok:!0}}catch{return{ok:!1}}}async function x(a,b,c="operator"){try{(0,j.V1)();let[d]=await g.db.select().from(h.blockProposal).where((0,e.Uo)((0,e.eq)(h.blockProposal.workspaceId,a),(0,e.eq)(h.blockProposal.id,b)));if(!d||"pending"!==d.status)return{ok:!1};return await q(a,{slug:d.slug,kind:d.kind,title:d.title,body:d.body,updatedBy:d.byAgentHandle||c}),await g.db.update(h.blockProposal).set({status:"merged",decidedAt:new Date,decidedBy:c}).where((0,e.eq)(h.blockProposal.id,b)),await (0,k.W_)(a,"validation",b),{ok:!0}}catch{return{ok:!1}}}async function y(a,b,c="operator"){try{return(0,j.V1)(),await g.db.update(h.blockProposal).set({status:"rejected",decidedAt:new Date,decidedBy:c}).where((0,e.Uo)((0,e.eq)(h.blockProposal.workspaceId,a),(0,e.eq)(h.blockProposal.id,b))),await (0,k.W_)(a,"validation",b),{ok:!0}}catch{return{ok:!1}}}},63562:(a,b,c)=>{"use strict";c.d(b,{CS:()=>t,VX:()=>q,Vd:()=>u,ZF:()=>p,n9:()=>r,pp:()=>l});var d=c(31421),e=c(73024),f=c(76760),g=c(77030),h=c(57086),i=c(81204);let j="win32"===process.platform,k=new Map;function l(a){let b=(0,h.HZ)(a),c=[b];for(let a of["packages","apps","app","web","client","frontend","backend","server","api"]){let d=(0,f.join)(b,a);if((0,e.existsSync)(d))try{for(let a of(0,e.readdirSync)(d,{withFileTypes:!0}))a.isDirectory()&&c.push((0,f.join)(d,a.name))}catch{}}let d="$PORT";for(let a of c){let b=function(a){let b=(0,f.join)(a,"package.json");if(!(0,e.existsSync)(b))return null;try{let c=JSON.parse((0,e.readFileSync)(b,"utf8")),d=c.scripts??{},g=d.dev?"dev":d.start?"start":d.serve?"serve":null;if(!g)return null;let h=(0,e.existsSync)((0,f.join)(a,"pnpm-lock.yaml"))?"pnpm":(0,e.existsSync)((0,f.join)(a,"yarn.lock"))?"yarn":"npm",i=!(0,e.existsSync)((0,f.join)(a,"node_modules"));return{dir:a,kind:"node",name:c.name??"project",label:`${h} ${g}`,install:i?{cmd:h,args:["install"]}:void 0,runCmd:h,runArgs:"npm"===h?["run",g]:[g]}}catch{return null}}(a);if(b)return b}for(let a of c){let b=b=>(0,e.existsSync)((0,f.join)(a,b)),c=a.split(/[\\/]/).pop()||"project",g=b("requirements.txt")?{cmd:"python",args:["-m","pip","install","-r","requirements.txt"]}:void 0;if(b("manage.py"))return{dir:a,kind:"python",name:c,label:"django runserver",install:g,runCmd:"python",runArgs:["manage.py","runserver",`127.0.0.1:${d}`]};if(b("main.py")){let b="";try{b=(0,e.readFileSync)((0,f.join)(a,"main.py"),"utf8")}catch{}if(/FastAPI\s*\(/.test(b))return{dir:a,kind:"python",name:c,label:"uvicorn",install:g,runCmd:"python",runArgs:["-m","uvicorn","main:app","--host","127.0.0.1","--port",d]};return{dir:a,kind:"python",name:c,label:"python main.py",install:g,runCmd:"python",runArgs:["main.py"]}}if(b("go.mod"))return{dir:a,kind:"go",name:c,label:"go run",runCmd:"go",runArgs:["run","."]};if(b("Cargo.toml"))return{dir:a,kind:"rust",name:c,label:"cargo run",runCmd:"cargo",runArgs:["run"]};if(b("server.js"))return{dir:a,kind:"static",name:c,label:"node server.js",runCmd:"node",runArgs:["server.js"]}}return null}let m=new Map;async function n(a){let b=m.get(a);if(b&&Date.now()-b.at<6e4)return b.ok;let c=await new Promise(b=>{try{let c=(0,d.spawn)(a,["--version"],{shell:j,windowsHide:!0}),e=!1,f=a=>{e||(e=!0,b(a))};c.on("error",()=>f(!1)),c.on("close",a=>f(0===a||null===a)),setTimeout(()=>{try{c.kill()}catch{}f(!1)},8e3)}catch{b(!1)}});return m.set(a,{ok:c,at:Date.now()}),c}function o(a,b,c){for(let d of c.split(/\r?\n/)){let c=d.trimEnd();c&&(a.logs.push({c:b,t:c}),"starting"===a.status&&/(ready|listening|localhost:|started server|compiled)/i.test(c)&&(a.status="running"))}a.logs.length>400&&a.logs.splice(0,a.logs.length-400)}async function p(a,b){let c,h,i=k.get(a);if(i&&"stopped"!==i.status&&"error"!==i.status&&!i.proc.killed)return s(i);let m=l(b);if(!m)return{running:!1,status:"error",logs:[{c:"err",t:"No runnable project found (no package.json with a dev/start script, or a Python/Go/Rust project, under the workspace)."}]};if("node"!==m.kind&&"static"!==m.kind&&!await n(m.runCmd))return{running:!1,status:"error",port:void 0,url:void 0,project:m.label,logs:[{c:"err",t:`Toolchain not found: '${m.runCmd}' is not installed or not on PATH. This ${m.kind} starter needs it to boot — install ${m.kind} (or pick a Node stack).`}]};try{c=await function(a=4173,b=4999){return new Promise((c,d)=>{let e=a=>{if(a>b)return d(Error("no free port"));let f=(0,g.createServer)();f.once("error",()=>e(a+1)),f.once("listening",()=>f.close(()=>c(a))),f.listen(a,"127.0.0.1")};e(a)})}()}catch{return{running:!1,status:"error",logs:[{c:"err",t:"No free port available."}]}}let p={...process.env,PORT:String(c),BROWSER:"none",NODE_ENV:"development"},q=m.runArgs.map(a=>a.includes("$PORT")?a.replace("$PORT",String(c)):a),r={proc:null,port:c,url:`http://127.0.0.1:${c}`,status:"starting",dir:m.dir,kind:m.kind,label:m.label,logs:[],startedAt:Date.now()};o(r,"info",`project: ${m.name} \xb7 ${m.label} \xb7 :${c}`);let t=(0,f.join)(m.dir,".constella-pyinstalled"),u=m.install&&("node"===m.kind||"python"===m.kind&&!(0,e.existsSync)(t));if(m.install&&u){o(r,"info",`$ ${m.install.cmd} ${m.install.args.join(" ")}`),k.set(a,r);let b=(0,d.spawn)(m.install.cmd,m.install.args,{cwd:m.dir,env:p,shell:j,windowsHide:!0});b.stdout?.on("data",a=>o(r,"out",a.toString())),b.stderr?.on("data",a=>o(r,"err",a.toString()));let c=await new Promise(a=>{b.on("close",a),b.on("error",()=>a(-1))});if("python"===m.kind&&0===c)try{(0,e.writeFileSync)(t,"ok")}catch{}}r.proc=h=(0,d.spawn)(m.runCmd,q,{cwd:m.dir,env:p,shell:j,windowsHide:!0}),h.stdout?.on("data",a=>o(r,"out",a.toString())),h.stderr?.on("data",a=>o(r,"err",a.toString())),h.on("error",a=>{r.status="error",o(r,"err",/ENOENT/.test(String(a))?`'${m.runCmd}' not found — install the ${m.kind} toolchain or pick a Node stack.`:"spawn failed: "+String(a instanceof Error?a.message:a))}),h.on("close",a=>{"stopped"!==r.status&&(r.status=0===a?"stopped":"error",o(r,"info",`process exited (${a})`))}),k.set(a,r);let w="go"===m.kind||"rust"===m.kind?12e4:"python"===m.kind?6e4:3e4;return await v(r.url,w).then(a=>{a&&"starting"===r.status&&(r.status="running")}),s(r)}async function q(a,b){if(!l(b))return{ok:!0,detail:"no runnable project to gate"};let c=t(a);if("running"===c.status&&c.url&&await v(c.url,3e3))return{ok:!0,detail:"dev server still reachable"};("error"===c.status||"stopped"===c.status)&&await r(a);let d=await p(a,b);if(("running"===d.status||"starting"===d.status)&&d.url&&await v(d.url,6e3))return{ok:!0,detail:"booted"};let e=d.logs.map(a=>a.t).join(" | ");return/Toolchain not found|not found —|not installed/.test(e)?{ok:!0,detail:"toolchain unavailable — boot gate skipped (cannot validate)"}:{ok:!1,detail:d.logs.slice(-5).map(a=>a.t).join(" | ")||"dev server failed to boot"}}async function r(a){let b=k.get(a);if(!b)return{running:!1,status:"stopped",logs:[]};b.status="stopped";try{b.proc?.pid&&(j?(0,d.spawn)("taskkill",["/PID",String(b.proc.pid),"/T","/F"],{windowsHide:!0}):process.kill(-b.proc.pid,"SIGKILL"))}catch{try{b.proc?.kill("SIGKILL")}catch{}}return(0,i.hA)(a),o(b,"info","server stopped"),s(b)}function s(a){return{running:"running"===a.status||"starting"===a.status,status:a.status,port:a.port,url:a.url,project:a.label,logs:a.logs.slice(-120)}}function t(a){let b=k.get(a);return b?s(b):{running:!1,status:"none",logs:[]}}function u(a){let b=k.get(a);return b&&("running"===b.status||"starting"===b.status)?b.url:null}async function v(a,b){let c=Date.now()+b;for(;Date.now()<c;){try{return await fetch(a,{signal:AbortSignal.timeout(2e3)}),!0}catch{}await new Promise(a=>setTimeout(a,1e3))}return!1}},63742:(a,b,c)=>{"use strict";c.d(b,{f:()=>e});var d=c(2910);let e=(0,d.createServerReference)("004ec7f252351e38a9c4baf338040eebc632b425d2",d.callServer,void 0,d.findSourceMapURL,"reindexKbAction")},63876:(a,b,c)=>{Promise.resolve().then(c.bind(c,8556))},64557:(a,b,c)=>{"use strict";c.d(b,{Sidebar:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call Sidebar() from the server but Sidebar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\sidebar.tsx","Sidebar")},65636:(a,b,c)=>{"use strict";c.d(b,{L:()=>e});var d=c(2910);let e=(0,d.createServerReference)("4012df9fe60cdc771539fe5ed6ee353f894150d310",d.callServer,void 0,d.findSourceMapURL,"compactConversation")},66852:(a,b,c)=>{"use strict";c.d(b,{Sidebar:()=>q});var d=c(4374),e=c(63885),f=c.n(e),g=c(47104),h=c(48442),i=c(43526),j=c(74679),k=c(93542),l=c(31819),m=c(5704);function n({orgs:a,currentId:b,workspaceSlug:c}){let e=(0,l.k)(),f=(0,g.useRouter)(),[h,o]=(0,j.useState)(!1),[p,q]=(0,j.useTransition)(),r=(0,j.useRef)(null),s=a.find(a=>a.id===b)||a[0];return(0,d.jsxs)("div",{className:"org-switch",ref:r,children:[(0,d.jsxs)("button",{className:"org-switch-btn"+(h?" open":""),disabled:p,onClick:()=>o(a=>!a),title:s?.name,children:[(0,d.jsx)(k.J,{size:34,rx:10}),(0,d.jsxs)("div",{className:"os-meta",children:[(0,d.jsx)("div",{className:"os-name",children:s?.name??"Constella"}),(0,d.jsx)("div",{className:"os-sub mono",children:c})]}),(0,d.jsx)(i.I,{name:"chevronDown",size:14})]}),h&&(0,d.jsxs)("div",{className:"org-pop",children:[(0,d.jsx)("div",{className:"org-pop-h",children:e("mod.organizations")}),a.map((a,c)=>(0,d.jsxs)("button",{className:"org-pop-item"+(a.id===b?" on":""),onClick:()=>{var c;return c=a.id,void(o(!1),c!==b&&q(async()=>{await (0,m.T)(c),window.location.href="/"}))},children:[(0,d.jsx)("span",{className:"op-badge",children:c+1}),(0,d.jsx)("span",{className:"op-name",children:a.name}),a.id===b&&(0,d.jsx)(i.I,{name:"check",size:14})]},a.id)),(0,d.jsx)("div",{className:"org-pop-sep"}),(0,d.jsxs)("button",{className:"org-pop-create",onClick:()=>{o(!1),f.push("/onboarding")},children:[(0,d.jsx)("span",{className:"opc-ic",children:(0,d.jsx)(i.I,{name:"add",size:13})})," ",e("orgs.createOrganization")]})]})]})}var o=c(2910);let p=(0,o.createServerReference)("0028f961902c9e2476af137bbeb472cd7073047824",o.callServer,void 0,o.findSourceMapURL,"signOutAction");function q({orgs:a,currentOrgId:b,workspaceSlug:c,userName:e,userEmail:j,userImage:k,inboxCount:m,notifCount:o}){let r=(0,g.usePathname)(),s=(0,l.k)();return(0,d.jsxs)("aside",{className:"side",children:[(0,d.jsx)("div",{className:"side-brand-wrap",children:(0,d.jsx)(n,{orgs:a,currentId:b,workspaceSlug:c})}),(0,d.jsxs)(f(),{href:"/search",className:"nav-search",children:[(0,d.jsx)(i.I,{name:"search",size:13}),(0,d.jsx)("input",{placeholder:s("nav.search"),readOnly:!0,style:{pointerEvents:"none"}})]}),(0,d.jsx)("div",{className:"side-nav scroll",children:h.E.map(a=>{let b=h.e.filter(b=>b.group===a);return b.length?(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"nav-group-label",children:s(`group.${a}`)}),b.map(a=>{let b=a=>"/"+(a.split("/")[1]??""),c="home"===a.id?"/"===r:b(r)===b(a.href),e="inbox"===a.id?m:"notifications"===a.id?o:0;return(0,d.jsxs)(f(),{href:a.href,className:"nav-item"+(c?" active":""),children:[(0,d.jsx)(i.I,{name:a.icon,size:17}),(0,d.jsx)("span",{children:s(`mod.${a.id}`)}),e?(0,d.jsx)("span",{className:"nv-badge",children:e}):null]},a.id)})]},a):null})}),(0,d.jsxs)("div",{className:"side-foot",children:[(0,d.jsx)("div",{className:"top-avatar",style:{margin:0,overflow:"hidden",padding:k?0:void 0},children:k?(0,d.jsx)("img",{src:/^(data:|https?:|\/)/.test(k)?k:`/api/upload?path=${encodeURIComponent(k)}`,alt:e,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):(e?.[0]||"O").toUpperCase()}),(0,d.jsxs)(f(),{href:"/profile",className:"pf",children:[(0,d.jsx)("div",{className:"pn",children:e||s("nav.operator")}),(0,d.jsx)("div",{className:"pe",children:j||""})]}),(0,d.jsx)("form",{action:p,children:(0,d.jsx)("button",{className:"foot-signout",title:s("nav.signout"),type:"submit",children:(0,d.jsx)(i.I,{name:"close",size:15})})})]})]})}},67686:(a,b,c)=>{"use strict";c.d(b,{ChatToggle:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call ChatToggle() from the server but ChatToggle is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\chat-toggle.tsx","ChatToggle")},68294:(a,b,c)=>{"use strict";c.d(b,{SidebarToggle:()=>g});var d=c(4374),e=c(74679),f=c(43526);function g(){let[a,b]=(0,e.useState)(!1);return(0,d.jsx)("button",{className:"top-btn"+(a?" on":""),onClick:function(){b(a=>{let b=!a;document.body.classList.toggle("side-collapsed",b);try{localStorage.setItem("bx.sideCollapsed",b?"1":"0")}catch{}return b})},title:a?"Expand sidebar":"Collapse sidebar","aria-label":"Toggle sidebar",children:(0,d.jsx)(f.I,{name:"sidebarIcon",size:17})})}},69626:(a,b,c)=>{"use strict";c.d(b,{m:()=>f});var d=c(4374);let e={working:{c:"var(--sx-string)",pulse:!0,label:"working"},review:{c:"#e0a44e",label:"review"},blocked:{c:"#e8688f",label:"blocked"},idle:{c:"var(--text-faint)",label:"idle"}};function f({status:a,label:b=!1,size:c=8}){let g=e[a]??e.idle;return(0,d.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5},title:g.label,children:[g.pulse?(0,d.jsx)("span",{className:"dotpulse"}):(0,d.jsx)("span",{style:{width:c,height:c,borderRadius:"50%",background:g.c,display:"inline-block",flex:`0 0 ${c}px`}}),b&&(0,d.jsx)("span",{style:{fontSize:11,color:g.c,fontWeight:600},children:g.label})]})}},70221:(a,b,c)=>{"use strict";c.d(b,{B:()=>x,z:()=>w});var d=c(77598),e=c(73024),f=c(76760),g=c(73136),h=c(31421),i=c(97603),j=c(65705),k=c(1890),l=c(57086),m=c(79505),n=c(33644),o=c(63562),p=c(56338),q=c(53080);async function r(a,b,c){let d=await a.newPage();try{return await d.evaluate(async a=>{let b=a=>new Promise((b,c)=>{let d=new Image;d.onload=()=>b(d),d.onerror=c,d.src=a}),[c,d]=await Promise.all([b(a[0]),b(a[1])]),e=a=>{let b=document.createElement("canvas");b.width=1280,b.height=800;let c=b.getContext("2d");return c.drawImage(a,0,0,1280,800),c.getImageData(0,0,1280,800).data},f=e(c),g=e(d),h=0;for(let a=0;a<f.length;a+=4)(Math.abs(f[a]-g[a])>32||Math.abs(f[a+1]-g[a+1])>32||Math.abs(f[a+2]-g[a+2])>32)&&h++;return h/1024e3},[`data:image/png;base64,${b}`,`data:image/png;base64,${c}`])}catch{return null}finally{try{await d.close()}catch{}}}let s=["/.env","/.env.local","/.git/config","/config.json","/admin","/api"],t=/(sk-[a-z0-9]{20,}|AKIA[0-9A-Z]{16}|-----BEGIN (?:RSA |EC )?PRIVATE KEY-----|password["']?\s*[:=]\s*["'][^"']{4,})/i,u=null;function v(a,b,c,d="",e=""){(0,m.I)(a,{runId:b,channel:"testdev",agentId:null,kind:c,target:d,detail:e}),(0,n.r)(a)}async function w(a,b,m={}){let n,x=(0,d.randomUUID)();await j.db.insert(k.testRun).values({id:x,workspaceId:a,goalId:m.goalId??null,issueId:m.issueId??null,status:"running",by:m.by??"operator"}),v(a,x,"thinking","Starting Test Dev…");let y=async(b,c,d)=>(await j.db.update(k.testRun).set({status:b,summary:c.slice(0,600),findings:JSON.stringify(d).slice(0,2e4),finishedAt:new Date}).where((0,i.eq)(k.testRun.id,x)),v(a,x,"done",`${b} \xb7 ${d.length} finding(s)`),{id:x,status:b,summary:c,findings:d}),z=(0,o.Vd)(a);if(!z&&m.noBoot)return y("inconclusive","Dev server not running — start it in Test Dev to gate task completion.",[]);if(!z){v(a,x,"thinking","Booting project dev server…");let c=await (0,o.ZF)(a,b);if(!c.running||!c.url)return y("inconclusive","No runnable project / dev server didn't boot — nothing to test yet.",[{severity:"low",kind:"boot",route:"-",message:c.logs.slice(-3).map(a=>a.t).join(" | ")||"no project"}]);z=c.url}if("running"!==(0,o.CS)(a).status)return y("inconclusive","Dev server is still starting — try again shortly.",[{severity:"low",kind:"boot",route:"-",message:"server not reachable yet"}]);let A=(m.routes&&m.routes.length?m.routes:["/"]).slice(0,8);try{({chromium:n}=await Promise.resolve().then(c.bind(c,5006)))}catch{return y("inconclusive","Playwright not available — install it (`npx playwright install chromium`) to enable browser tests.",[])}let B=[],C=(0,f.join)((0,l.HZ)(b),".testdev");try{(0,e.mkdirSync)(C,{recursive:!0})}catch{}let D=null;try{D=await n.launch({headless:!0})}catch(c){v(a,x,"thinking","Installing the test browser (chromium, one-time ~150MB)…");let b=await (!u&&(u=new Promise(a=>{try{let b="win32"===process.platform?"npx.cmd":"npx",c=(0,h.spawn)(b,["playwright","install","chromium"],{stdio:"ignore",windowsHide:!0}),d=setTimeout(()=>{try{c.kill()}catch{}a(!1)},3e5);c.on("exit",b=>{clearTimeout(d),a(0===b)}),c.on("error",()=>{clearTimeout(d),a(!1)})}catch{a(!1)}})),u);if(b)try{D=await n.launch({headless:!0})}catch{}if(!D)return y("inconclusive",b?"Couldn't launch chromium after install — try again.":"Couldn't install/launch chromium. Run `npx playwright install chromium` in the install dir, then retry.",[{severity:"low",kind:"boot",route:"-",message:String(c instanceof Error?c.message:c).slice(0,200)}])}try{let c=await D.newContext({viewport:{width:1280,height:800}}),d=await c.newPage();d.on("console",a=>{let b=a.type();"error"===b?B.push({severity:"high",kind:"console",route:d.url(),message:a.text().slice(0,300)}):"warning"===b&&B.push({severity:"low",kind:"console",route:d.url(),message:a.text().slice(0,300)})}),d.on("pageerror",a=>B.push({severity:"high",kind:"pageerror",route:d.url(),message:String(a.message??a).slice(0,300)})),d.on("requestfailed",a=>{let b=a.failure()?.errorText??"";/ERR_ABORTED/.test(b)||B.push({severity:"med",kind:"request",route:d.url(),message:`${a.method()} ${a.url().slice(0,160)} — ${b}`})});let h=(0,q.hp)(b),i=!!h.served&&!!h.target,j=(0,f.join)(C,"baseline");if(i)try{(0,e.mkdirSync)(j,{recursive:!0})}catch{}for(let k of A){v(a,x,"text",`navigate ${k}`);try{let a=await d.goto(z+k,{waitUntil:"domcontentloaded",timeout:2e4});a&&a.status()>=500&&B.push({severity:"high",kind:"request",route:k,message:`${k} → HTTP ${a.status()}`}),await d.waitForTimeout(800);let m=d.locator("button:visible:not([disabled])").first();if(await m.count())try{await m.click({timeout:2e3}),await d.waitForTimeout(500)}catch{}let n=await d.content();t.test(n)&&B.push({severity:"high",kind:"security",route:k,message:"Possible secret/credential present in served HTML/JS."});let o=k.replace(/[^a-z0-9]/gi,"_")||"root";try{await d.screenshot({path:(0,f.join)(C,`${x}-${o}.png`)})}catch{}if(i)try{let a=(0,f.join)(j,`${o}.png`);if(!(0,e.existsSync)(a)){let d="/"===k?"index.html":k.replace(/^\//,"").replace(/\/+$/,"")+".html",i=(0,f.join)((0,l.HZ)(b),h.target,d);if((0,e.existsSync)(i)){let b=await c.newPage();try{await b.goto((0,g.pathToFileURL)(i).href,{waitUntil:"domcontentloaded",timeout:15e3}),await b.waitForTimeout(400),await b.screenshot({path:a})}finally{try{await b.close()}catch{}}}}if((0,e.existsSync)(a)){let b=await d.screenshot(),f=await r(c,(0,e.readFileSync)(a).toString("base64"),b.toString("base64"));if(null!=f){let a=Math.round(100*f);f>.5?B.push({severity:"high",kind:"fidelity",route:k,message:`Visual fidelity: ${a}% of the screen differs from the APPROVED design — it doesn't match; build ${k} to the design (zero drift).`}):f>.12&&B.push({severity:"med",kind:"fidelity",route:k,message:`Visual drift: ${a}% differs from the approved design at ${k}.`})}}}catch{}}catch(a){B.push({severity:"med",kind:"request",route:k,message:`navigation failed: ${String(a instanceof Error?a.message:a).slice(0,160)}`})}}for(let a of s)try{let b=await fetch(z+a,{redirect:"manual",signal:AbortSignal.timeout(4e3)});if(200===b.status){let c=await b.text().catch(()=>"");("/api"!==a&&c.length>0||t.test(c))&&B.push({severity:"high",kind:"security",route:a,message:`${a} returns 200 with content unauthenticated.`})}}catch{}await c.close()}finally{try{await D.close()}catch{}}let E=B.filter(a=>"high"===a.severity),F=E.length?"fail":"pass",G="fail"===F?`${E.length} blocking issue(s): ${E.slice(0,3).map(a=>`${a.kind} @ ${a.route}`).join(", ")}`:`Passed — ${B.length} note(s), no blocking issues. Navigated ${A.length} route(s).`;return(0,p.ru)(b,[{type:"test",title:`Test Dev — ${F}`,summary:G,goalId:m.goalId??null,issueId:m.issueId??null,agentHandle:"agent"===m.by?"edsger":"operator",sourceKind:"test",sourceRef:x}]).catch(()=>{}),y(F,G,B)}async function x(a,b){let[c]=await j.db.select().from(k.issue).where((0,i.eq)(k.issue.id,b)),d=new Set(["/"]);if(c){let a=(c.title+" "+(c.key??"")).match(/\/[a-z0-9\-/]{2,}/gi);a&&a.slice(0,4).forEach(a=>d.add(a))}return[...d]}},71352:(a,b,c)=>{"use strict";c.d(b,{Tc:()=>z,YK:()=>D,PM:()=>B});var d=c(77598),e=c(54548),f=c(97603),g=c(95357),h=c(65705),i=c(1890),j=c(70149),k=c(38926),l=c(29803),m=c(1273);async function n(a,b){let c=b.adapter??"";if(c.startsWith("local_"))return{kind:"http",http:{provider:"openai",baseUrl:"local_ollama"===c?(process.env.OLLAMA_URL??"http://127.0.0.1:11434")+"/v1":(process.env.LLAMACPP_URL??"http://127.0.0.1:8082")+"/v1",apiKey:"",model:b.model||"local"}};if(c.startsWith("http_")){let[d]=await h.db.select().from(i.provider).where((0,f.Uo)((0,f.eq)(i.provider.workspaceId,a),(0,f.eq)(i.provider.adapter,c)));if(d){let e=(0,l.kH)(d.catalogId),f=await (0,k.r6)(a,`${d.catalogId}_api_key`);if(e?.baseUrl&&f)return{kind:"http",http:{provider:c.includes("google")?"google":"openai",baseUrl:e.baseUrl,apiKey:f,model:b.model}}}}return{kind:"cli",binary:(0,j.hW)(b.adapter,b.model)}}async function o(a,b,c,d){return"http"===b.kind?(0,m._)(a,b.http,{timeoutMs:c.timeoutMs},d):(0,j.p1)(a,{orgId:c.orgId,binary:b.binary,model:c.model,timeoutMs:c.timeoutMs},d)}var p=c(78161),q=c(45125),r=c(25497),s=c(79505),t=c(36482),u=c(33644),v=c(57300),w=c(56338),x=c(48503);async function y(a,b){if(!b)return!1;let c=new Date;c.setHours(0,0,0,0);let[d]=await h.db.select({total:(0,e.cz)(i.costEntry.usd)}).from(i.costEntry).where((0,f.Uo)((0,f.eq)(i.costEntry.agentId,a),(0,f.RO)(i.costEntry.at,c)));return Number(d?.total??0)>=b}function z(a){let b=(a??"").trim();return b?/not logged in|please run \/login|unauthenticated|unauthorized|invalid api key|authentication failed/i.test(b)?"the agent's CLI isn't authenticated in this runtime — check the model provider / CLI login in the Models module":b:"no output"}let A="[[CREATE_WORK]]";async function B(a,b,c,e,k,l){let m=(0,d.randomUUID)(),y=(0,j.hW)(e.adapter,e.model),B="work"===k?`This is the team room.${l?` Your teammate @${l.from} just handed off to YOU:
332
+ ${(a.body||"").trim().slice(0,800)}`).join("\n\n").slice(0,5e3)}catch{return""}}let u=[{slug:"mission",kind:"mission",title:"Mission",starter:""},{slug:"objective",kind:"objective",title:"Objective",starter:""},{slug:"official-stack",kind:"stack",title:"Official stack",starter:""},{slug:"current-architecture",kind:"architecture",title:"Current architecture",starter:"_Describe the system's current shape, modules and data flow — the architecture every agent should treat as canonical._"},{slug:"business-rules",kind:"business-rule",title:"Business rules",starter:"_List the domain rules the product must always obey._"},{slug:"ui-patterns",kind:"ui-pattern",title:"UI patterns",starter:"_Canonical UI/UX conventions and component patterns._"},{slug:"security-patterns",kind:"security",title:"Security patterns",starter:"_Required security practices: auth, secrets, isolation, input validation._"},{slug:"deploy-checklist",kind:"deploy-checklist",title:"Deploy checklist",starter:"_Steps that must pass before a deploy._"},{slug:"code-review-checklist",kind:"review-checklist",title:"Code review checklist",starter:"_What every review must check before merge._"},{slug:"glossary",kind:"glossary",title:"Glossary",starter:"_Shared vocabulary for the project._"},{slug:"technical-decisions",kind:"note",title:"Technical decisions",starter:"_The durable “why we chose X” log._"}];async function v(a){let b=0;try{(0,j.V1)();let[c]=await g.db.select().from(h.workspace).where((0,e.eq)(h.workspace.orgId,a));if(!c)return{seeded:b};let d=new Set((await g.db.select({slug:h.syncedBlock.slug}).from(h.syncedBlock).where((0,e.eq)(h.syncedBlock.workspaceId,c.id))).map(a=>a.slug)),f=Object.entries(c.stack??{}).filter(([,a])=>a&&"None"!==a).map(([a,b])=>`- **${a}:** ${b}`).join("\n"),i={mission:c.mission||"",objective:c.objective||"","official-stack":f};for(let a of u){if(d.has(a.slug))continue;let e=(i[a.slug]??"").trim()||a.starter;e&&(await q(c.id,{slug:a.slug,kind:a.kind,title:a.title,body:e,updatedBy:"system"}),b++)}}catch{}return{seeded:b}}async function w(a,b){try{(0,j.V1)();let c=await o(a);if(!c)return{ok:!1};let e=n(b.slug);if(!e||!b.body.trim())return{ok:!1};let f=(0,d.randomUUID)();return await g.db.insert(h.blockProposal).values({id:f,workspaceId:c,slug:e,kind:(b.kind??"note").slice(0,40),title:(b.title??"").slice(0,200),body:b.body.slice(0,2e4),byAgentHandle:(b.byAgentHandle??"").slice(0,60),status:"pending"}),await (0,k.vE)(c,{kind:"review",refType:"validation",refId:f,fromAgentId:null,title:`Block edit proposed — ${e}`,detail:`@${b.byAgentHandle} proposed an edit to the “${e}” knowledge block. Review + merge in Knowledge.`.slice(0,400)}),await (0,l.I)(c,{kind:"review",text:`Knowledge block edit proposed — ${e}`,detail:`by @${b.byAgentHandle}`}),{ok:!0}}catch{return{ok:!1}}}async function x(a,b,c="operator"){try{(0,j.V1)();let[d]=await g.db.select().from(h.blockProposal).where((0,e.Uo)((0,e.eq)(h.blockProposal.workspaceId,a),(0,e.eq)(h.blockProposal.id,b)));if(!d||"pending"!==d.status)return{ok:!1};return await q(a,{slug:d.slug,kind:d.kind,title:d.title,body:d.body,updatedBy:d.byAgentHandle||c}),await g.db.update(h.blockProposal).set({status:"merged",decidedAt:new Date,decidedBy:c}).where((0,e.eq)(h.blockProposal.id,b)),await (0,k.W_)(a,"validation",b),{ok:!0}}catch{return{ok:!1}}}async function y(a,b,c="operator"){try{return(0,j.V1)(),await g.db.update(h.blockProposal).set({status:"rejected",decidedAt:new Date,decidedBy:c}).where((0,e.Uo)((0,e.eq)(h.blockProposal.workspaceId,a),(0,e.eq)(h.blockProposal.id,b))),await (0,k.W_)(a,"validation",b),{ok:!0}}catch{return{ok:!1}}}},63562:(a,b,c)=>{"use strict";c.d(b,{CS:()=>t,VX:()=>q,Vd:()=>u,ZF:()=>p,n9:()=>r,pp:()=>l});var d=c(31421),e=c(73024),f=c(76760),g=c(77030),h=c(57086),i=c(81204);let j="win32"===process.platform,k=new Map;function l(a){let b=(0,h.HZ)(a),c=[b];for(let a of["packages","apps","app","web","client","frontend","backend","server","api"]){let d=(0,f.join)(b,a);if((0,e.existsSync)(d))try{for(let a of(0,e.readdirSync)(d,{withFileTypes:!0}))a.isDirectory()&&c.push((0,f.join)(d,a.name))}catch{}}let d="$PORT";for(let a of c){let b=function(a){let b=(0,f.join)(a,"package.json");if(!(0,e.existsSync)(b))return null;try{let c=JSON.parse((0,e.readFileSync)(b,"utf8")),d=c.scripts??{},g=d.dev?"dev":d.start?"start":d.serve?"serve":null;if(!g)return null;let h=(0,e.existsSync)((0,f.join)(a,"pnpm-lock.yaml"))?"pnpm":(0,e.existsSync)((0,f.join)(a,"yarn.lock"))?"yarn":"npm",i=!(0,e.existsSync)((0,f.join)(a,"node_modules"));return{dir:a,kind:"node",name:c.name??"project",label:`${h} ${g}`,install:i?{cmd:h,args:["install"]}:void 0,runCmd:h,runArgs:"npm"===h?["run",g]:[g]}}catch{return null}}(a);if(b)return b}for(let a of c){let b=b=>(0,e.existsSync)((0,f.join)(a,b)),c=a.split(/[\\/]/).pop()||"project",g=b("requirements.txt")?{cmd:"python",args:["-m","pip","install","-r","requirements.txt"]}:void 0;if(b("manage.py"))return{dir:a,kind:"python",name:c,label:"django runserver",install:g,runCmd:"python",runArgs:["manage.py","runserver",`127.0.0.1:${d}`]};if(b("main.py")){let b="";try{b=(0,e.readFileSync)((0,f.join)(a,"main.py"),"utf8")}catch{}if(/FastAPI\s*\(/.test(b))return{dir:a,kind:"python",name:c,label:"uvicorn",install:g,runCmd:"python",runArgs:["-m","uvicorn","main:app","--host","127.0.0.1","--port",d]};return{dir:a,kind:"python",name:c,label:"python main.py",install:g,runCmd:"python",runArgs:["main.py"]}}if(b("go.mod"))return{dir:a,kind:"go",name:c,label:"go run",runCmd:"go",runArgs:["run","."]};if(b("Cargo.toml"))return{dir:a,kind:"rust",name:c,label:"cargo run",runCmd:"cargo",runArgs:["run"]};if(b("server.js"))return{dir:a,kind:"static",name:c,label:"node server.js",runCmd:"node",runArgs:["server.js"]}}return null}let m=new Map;async function n(a){let b=m.get(a);if(b&&Date.now()-b.at<6e4)return b.ok;let c=await new Promise(b=>{try{let c=(0,d.spawn)(a,["--version"],{shell:j,windowsHide:!0}),e=!1,f=a=>{e||(e=!0,b(a))};c.on("error",()=>f(!1)),c.on("close",a=>f(0===a||null===a)),setTimeout(()=>{try{c.kill()}catch{}f(!1)},8e3)}catch{b(!1)}});return m.set(a,{ok:c,at:Date.now()}),c}function o(a,b,c){for(let d of c.split(/\r?\n/)){let c=d.trimEnd();c&&(a.logs.push({c:b,t:c}),"starting"===a.status&&/(ready|listening|localhost:|started server|compiled)/i.test(c)&&(a.status="running"))}a.logs.length>400&&a.logs.splice(0,a.logs.length-400)}async function p(a,b){let c,h,i=k.get(a);if(i&&"stopped"!==i.status&&"error"!==i.status&&!i.proc.killed)return s(i);let m=l(b);if(!m)return{running:!1,status:"error",logs:[{c:"err",t:"No runnable project found (no package.json with a dev/start script, or a Python/Go/Rust project, under the workspace)."}]};if("node"!==m.kind&&"static"!==m.kind&&!await n(m.runCmd))return{running:!1,status:"error",port:void 0,url:void 0,project:m.label,logs:[{c:"err",t:`Toolchain not found: '${m.runCmd}' is not installed or not on PATH. This ${m.kind} starter needs it to boot — install ${m.kind} (or pick a Node stack).`}]};try{c=await function(a=4173,b=4999){return new Promise((c,d)=>{let e=a=>{if(a>b)return d(Error("no free port"));let f=(0,g.createServer)();f.once("error",()=>e(a+1)),f.once("listening",()=>f.close(()=>c(a))),f.listen(a,"127.0.0.1")};e(a)})}()}catch{return{running:!1,status:"error",logs:[{c:"err",t:"No free port available."}]}}let p={...process.env,PORT:String(c),BROWSER:"none",NODE_ENV:"development"},q=m.runArgs.map(a=>a.includes("$PORT")?a.replace("$PORT",String(c)):a),r={proc:null,port:c,url:`http://127.0.0.1:${c}`,status:"starting",dir:m.dir,kind:m.kind,label:m.label,logs:[],startedAt:Date.now()};o(r,"info",`project: ${m.name} \xb7 ${m.label} \xb7 :${c}`);let t=(0,f.join)(m.dir,".constella-pyinstalled"),u=m.install&&("node"===m.kind||"python"===m.kind&&!(0,e.existsSync)(t));if(m.install&&u){o(r,"info",`$ ${m.install.cmd} ${m.install.args.join(" ")}`),k.set(a,r);let b=(0,d.spawn)(m.install.cmd,m.install.args,{cwd:m.dir,env:p,shell:j,windowsHide:!0});b.stdout?.on("data",a=>o(r,"out",a.toString())),b.stderr?.on("data",a=>o(r,"err",a.toString()));let c=await new Promise(a=>{b.on("close",a),b.on("error",()=>a(-1))});if("python"===m.kind&&0===c)try{(0,e.writeFileSync)(t,"ok")}catch{}}r.proc=h=(0,d.spawn)(m.runCmd,q,{cwd:m.dir,env:p,shell:j,windowsHide:!0}),h.stdout?.on("data",a=>o(r,"out",a.toString())),h.stderr?.on("data",a=>o(r,"err",a.toString())),h.on("error",a=>{r.status="error",o(r,"err",/ENOENT/.test(String(a))?`'${m.runCmd}' not found — install the ${m.kind} toolchain or pick a Node stack.`:"spawn failed: "+String(a instanceof Error?a.message:a))}),h.on("close",a=>{"stopped"!==r.status&&(r.status=0===a?"stopped":"error",o(r,"info",`process exited (${a})`))}),k.set(a,r);let w="go"===m.kind||"rust"===m.kind?12e4:"python"===m.kind?6e4:3e4;return await v(r.url,w).then(a=>{a&&"starting"===r.status&&(r.status="running")}),s(r)}async function q(a,b){if(!l(b))return{ok:!0,detail:"no runnable project to gate"};let c=t(a);if("running"===c.status&&c.url&&await v(c.url,3e3))return{ok:!0,detail:"dev server still reachable"};("error"===c.status||"stopped"===c.status)&&await r(a);let d=await p(a,b);if(("running"===d.status||"starting"===d.status)&&d.url&&await v(d.url,6e3))return{ok:!0,detail:"booted"};let e=d.logs.map(a=>a.t).join(" | ");return/Toolchain not found|not found —|not installed/.test(e)?{ok:!0,detail:"toolchain unavailable — boot gate skipped (cannot validate)"}:{ok:!1,detail:d.logs.slice(-5).map(a=>a.t).join(" | ")||"dev server failed to boot"}}async function r(a){let b=k.get(a);if(!b)return{running:!1,status:"stopped",logs:[]};b.status="stopped";try{b.proc?.pid&&(j?(0,d.spawn)("taskkill",["/PID",String(b.proc.pid),"/T","/F"],{windowsHide:!0}):process.kill(-b.proc.pid,"SIGKILL"))}catch{try{b.proc?.kill("SIGKILL")}catch{}}return(0,i.hA)(a),o(b,"info","server stopped"),s(b)}function s(a){return{running:"running"===a.status||"starting"===a.status,status:a.status,port:a.port,url:a.url,project:a.label,logs:a.logs.slice(-120)}}function t(a){let b=k.get(a);return b?s(b):{running:!1,status:"none",logs:[]}}function u(a){let b=k.get(a);return b&&("running"===b.status||"starting"===b.status)?b.url:null}async function v(a,b){let c=Date.now()+b;for(;Date.now()<c;){try{return await fetch(a,{signal:AbortSignal.timeout(2e3)}),!0}catch{}await new Promise(a=>setTimeout(a,1e3))}return!1}},63876:(a,b,c)=>{Promise.resolve().then(c.bind(c,8556))},64557:(a,b,c)=>{"use strict";c.d(b,{Sidebar:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call Sidebar() from the server but Sidebar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\sidebar.tsx","Sidebar")},64889:(a,b,c)=>{"use strict";c.d(b,{_:()=>e});var d=c(2910);let e=(0,d.createServerReference)("702777ba042d40b1d5705ed063aec09cc357fcdd61",d.callServer,void 0,d.findSourceMapURL,"sendMessage")},66049:(a,b,c)=>{"use strict";c.d(b,{K:()=>e});var d=c(2910);let e=(0,d.createServerReference)("00d896599aa05f6b9b14826b3e2ffa5b7a98370f22",d.callServer,void 0,d.findSourceMapURL,"disconnectTelegram")},66898:(a,b,c)=>{"use strict";c.d(b,{LangSwitch:()=>i});var d=c(4374),e=c(74679),f=c(47104),g=c(2910);let h=(0,g.createServerReference)("40664d1b326c4e702d0a3077bb46439f2b2600cd50",g.callServer,void 0,g.findSourceMapURL,"setLang");function i(){let a=(0,f.useRouter)(),[b,c]=(0,e.useState)("en"),[g,i]=(0,e.useTransition)();return(0,d.jsx)("div",{style:{display:"inline-flex",border:"1px solid var(--border)",borderRadius:7,overflow:"hidden"},children:["en","pt"].map(e=>(0,d.jsx)("button",{type:"button",disabled:g,onClick:()=>{e===b||g||i(async()=>{await h(e),c(e),a.refresh()})},title:"en"===e?"English":"Portugu\xeas (BR)",style:{padding:"3px 8px",fontSize:11,fontWeight:600,cursor:"pointer",border:"none",background:b===e?"var(--accent)":"transparent",color:b===e?"var(--accent-fg)":"var(--text-dim)"},children:e.toUpperCase()},e))})}},67686:(a,b,c)=>{"use strict";c.d(b,{ChatToggle:()=>d});let d=(0,c(62060).registerClientReference)(function(){throw Error("Attempted to call ChatToggle() from the server but ChatToggle is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"C:\\Users\\Usuario\\Documents\\constella\\src\\components\\shell\\chat-toggle.tsx","ChatToggle")},68294:(a,b,c)=>{"use strict";c.d(b,{SidebarToggle:()=>g});var d=c(4374),e=c(74679),f=c(43526);function g(){let[a,b]=(0,e.useState)(!1);return(0,d.jsx)("button",{className:"top-btn"+(a?" on":""),onClick:function(){b(a=>{let b=!a;document.body.classList.toggle("side-collapsed",b);try{localStorage.setItem("bx.sideCollapsed",b?"1":"0")}catch{}return b})},title:a?"Expand sidebar":"Collapse sidebar","aria-label":"Toggle sidebar",children:(0,d.jsx)(f.I,{name:"sidebarIcon",size:17})})}},69390:(a,b,c)=>{"use strict";c.d(b,{uG:()=>F,QE:()=>D,CZ:()=>E});var d=c(4374),e=c(74679),f=c(2910);f.callServer,f.findSourceMapURL,c(1662);let g=(0,f.createServerReference)("40972e72e17f52772e05b1c26618888916aa0a95cc",f.callServer,void 0,f.findSourceMapURL,"listSessions"),h=(0,f.createServerReference)("60face35dada2c40df11c8516d8fa9bd434df12801",f.callServer,void 0,f.findSourceMapURL,"createSession"),i=(0,f.createServerReference)("601269a69c549fe5fca4611d91fa20388e33f4e50b",f.callServer,void 0,f.findSourceMapURL,"switchSession"),j=(0,f.createServerReference)("6061163d33474b69b44ca71969e7e32eea6632c216",f.callServer,void 0,f.findSourceMapURL,"renameSession"),k=(0,f.createServerReference)("606c496fc7ae51c9732c206c25c0180519765eb1c5",f.callServer,void 0,f.findSourceMapURL,"deleteSession");var l=c(16366),m=c(38706),n=c(64889),o=c(14661),p=c(31819),q=c(5152),r=c(18462),s=c(66049);c(27326);var t=c(36549),u=c(1262);let v=(0,f.createServerReference)("00ffdd5039d3f6a2972d259f688e974bc22fce2faa",f.callServer,void 0,f.findSourceMapURL,"getChatNotifications"),w=(0,f.createServerReference)("008385a17df8e9a6678d83c4e627af6724a6f6bd63",f.callServer,void 0,f.findSourceMapURL,"getUnreadCounts");f.callServer,f.findSourceMapURL;let x=(0,f.createServerReference)("403917580efb407e1766db48881562b96dbf6c5fcb",f.callServer,void 0,f.findSourceMapURL,"markNotifRead");var y=c(14698),z=c(43526),A=c(69626),B=c(26945),C=c(6857);function D({agents:a,previews:b,onOpenDM:c}){let f=(0,p.k)(),[g,h]=(0,e.useState)(""),i=g.trim().toLowerCase(),j=a.filter(a=>!i||a.name.toLowerCase().includes(i)||a.handle.includes(i)||a.role.toLowerCase().includes(i));return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"dm-search",children:[(0,d.jsx)(z.I,{name:"search",size:13}),(0,d.jsx)("input",{placeholder:f("chat.searchAgents"),value:g,onChange:a=>h(a.target.value),autoFocus:!0})]}),(0,d.jsxs)("div",{className:"people-list scroll",children:[0===j.length&&(0,d.jsx)("div",{className:"mention-empty",children:f("chat.noAgentMatch",{q:g})}),j.map(a=>{let e=b[a.handle];return(0,d.jsxs)("div",{className:"people-row",onClick:()=>c(a.handle),children:[(0,d.jsx)(y.e,{name:a.name,color:a.color,image:a.image,size:36,health:a.health}),(0,d.jsxs)("div",{className:"people-meta",children:[(0,d.jsxs)("div",{className:"people-name",style:{display:"flex",alignItems:"center",gap:6},children:[a.name," ",(0,d.jsxs)("span",{className:"agent-handle",children:["@",a.handle]})," ","idle"!==a.status&&(0,d.jsx)(A.m,{status:a.status})]}),(0,d.jsx)("div",{className:"people-sub"+(e?" preview":""),children:e?(e.mine?f("chat.youPrefix"):"")+(e.text||"…"):`${a.role} \xb7 ${a.adapter}`})]}),(0,d.jsx)("span",{className:"people-go",children:(0,d.jsx)(z.I,{name:e?"chat":"chevronRight",size:14})})]},a.handle)})]})]})}function E({onConnected:a}){let b=(0,p.k)(),[c,f]=(0,e.useState)(""),[g,h]=(0,e.useState)(""),[i,j]=(0,e.useState)(""),[k,l]=(0,e.useState)(""),[m,n]=(0,e.useState)(""),[o,r]=(0,e.useTransition)();return(0,d.jsx)("div",{className:"tg-connect scroll",children:(0,d.jsxs)("div",{className:"tg-card",children:[(0,d.jsxs)("div",{className:"tg-card-head",children:[(0,d.jsx)("span",{className:"tg-card-ico",children:(0,d.jsx)(z.I,{name:"send",size:18})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"tg-card-title",children:b("chat.tg.connectTitle")}),(0,d.jsx)("div",{className:"tg-card-sub",children:b("chat.tg.connectSub")})]})]}),(0,d.jsxs)("ol",{className:"tg-steps",children:[(0,d.jsxs)("li",{children:[b("chat.tg.step1.a")," ",(0,d.jsx)("b",{children:"@BotFather"})," ",b("chat.tg.step1.b")," → ",(0,d.jsx)("code",{children:"/newbot"})," → ",b("chat.tg.step1.c")," ",(0,d.jsx)("b",{children:b("chat.tg.step1.token")}),"."]}),(0,d.jsxs)("li",{children:[b("chat.tg.step2.a")," ",(0,d.jsx)("b",{children:"@userinfobot"})," → ",b("chat.tg.step2.b")," ",(0,d.jsx)("b",{children:b("chat.tg.step2.chatId")})," ",b("chat.tg.step2.c")]}),(0,d.jsx)("li",{children:b("chat.tg.step3")})]}),(0,d.jsxs)("label",{className:"tg-field",children:[(0,d.jsx)("span",{children:b("chat.tg.botToken")}),(0,d.jsx)("input",{className:"form-input",placeholder:"123456789:AA…",value:c,onChange:a=>f(a.target.value)})]}),(0,d.jsxs)("div",{className:"tg-field-row",children:[(0,d.jsxs)("label",{className:"tg-field",children:[(0,d.jsx)("span",{children:b("chat.tg.yourChatId")}),(0,d.jsx)("input",{className:"form-input",placeholder:"123456789",value:g,onChange:a=>h(a.target.value)})]}),(0,d.jsxs)("label",{className:"tg-field",children:[(0,d.jsx)("span",{children:b("chat.tg.yourName")}),(0,d.jsx)("input",{className:"form-input",placeholder:b("chat.tg.namePlaceholder"),value:i,onChange:a=>j(a.target.value)})]})]}),k&&(0,d.jsx)("div",{className:"tg-msg err",children:k}),m&&(0,d.jsx)("div",{className:"tg-msg ok",children:m}),(0,d.jsxs)("button",{className:"btn-accent tg-save",disabled:o||!c.trim()||!g.trim(),onClick:function(){l(""),n(""),r(async()=>{let d=await (0,q.M)(c,g,i);d.ok?(n(b("chat.tg.botConnected",{bot:"@"+(d.username??"bot")})),f(""),h(""),j(""),a()):l(d.error??b("chat.tg.connectionFailed"))})},children:[o?(0,d.jsx)("span",{className:"spin",children:(0,d.jsx)(z.I,{name:"refresh",size:13})}):(0,d.jsx)(z.I,{name:"send",size:13})," ",b("chat.tg.connectBot")]}),(0,d.jsxs)("div",{className:"tg-note",children:[(0,d.jsx)(z.I,{name:"bot",size:12})," ",b("chat.tg.isolatedNote")]})]})})}function F({agents:a,operator:b}){let c,f,q,A,[G,H]=(0,e.useState)(!1),[I,J]=(0,e.useState)("right"),[K,L]=(0,e.useState)(380),[M,N]=(0,e.useState)("room"),[O,P]=(0,e.useState)("all"),[Q,R]=(0,e.useState)(""),S=(0,p.k)(),[T,U]=(0,e.useState)([]),[V,W]=(0,e.useState)([]),[X,Y]=(0,e.useState)([]),[Z,$]=(0,e.useState)(!1),[_,aa]=(0,e.useState)(null),[ab,ac]=(0,e.useState)(!1),[ad,ae]=(0,e.useState)([]),[af,ag]=(0,e.useState)({}),[ah,ai]=(0,e.useState)(!1),[aj,ak]=(0,e.useState)(null),[al,am]=(0,e.useState)({}),[an,ao]=(0,e.useState)(""),[ap,aq]=(0,e.useState)(0),[ar,as]=(0,e.useState)([]),[at,au]=(0,e.useState)(null),[av,aw]=(0,e.useState)(0),[ax,ay]=(0,e.useState)([]),[,az]=(0,e.useTransition)(),aA=(0,e.useRef)(0),aB=(0,e.useRef)(0);(0,e.useRef)(null);let aC=(0,e.useRef)({});(0,e.useRef)([]);let[aD,aE]=(0,e.useState)(null),aF=Object.fromEntries(a.map(a=>[a.handle,a])),aG=M.startsWith("dm:"),aH="people"===M,aI="telegram"===M,aJ=aG?M.slice(3):null,aK=aJ?aF[aJ]:null,aL=aG?M:aI?"telegram":"room";function aM(){delete aC.current[aL],aw(a=>a+1)}let aN=()=>(0,l.b)().then(a=>am(a)),aO=()=>(0,r.G)().then(a=>aE(a)).catch(()=>aE({connected:!1})),aP=async()=>{if(!aH)try{let a=await (0,t.p)(aL);if(a.used>=a.max&&!ab){ac(!0);try{await (0,u.L)(aL),a=await (0,t.p)(aL)}finally{ac(!1)}}aa(a)}catch{}};async function aQ(){if(!ab){ac(!0);try{await (0,u.L)(aL),await aP()}finally{ac(!1)}}}function aR(){au({title:S("chat.dock.clearTitle"),body:S("chat.dock.clearBody"),confirmLabel:S("common.clear"),onConfirm:()=>az(async()=>{await (0,m.H)(aL).catch(()=>{}),U([]),W([]),Y([]),delete aC.current[aL],aA.current=0,aB.current=0,await aP(),aG&&await aN()})})}let aS=async()=>{try{let[a,b]=await Promise.all([v(),w()]);ae(a),ag(b)}catch{}};async function aT(a){ai(!1),a.channel&&N(a.channel.startsWith("dm:")?a.channel:"room"),a.messageId&&(ak(a.messageId),setTimeout(()=>ak(null),2600));try{await x(a.id)}catch{}aS()}function aU(a,b){az(async()=>{let{responders:c}=await (0,n._)(aL,a,b);if(c.length){for(let a of(Y(c),c))await (0,o.n)(aL,a),Y(b=>b.filter(b=>b!==a));Y([])}aG&&await aN()})}if(!G)return(0,d.jsx)("button",{className:"chat-fab",style:{display:"grid",placeItems:"center"},onClick:()=>H(!0),title:S("chrome.chat.agentRoom"),children:(0,d.jsx)(z.I,{name:"chat",size:20})});let aV={};for(let a of V)(aV[a.runId]??=[]).push(a);let aW=new Set(T.map(a=>a.id)),aX=Object.entries(aV).filter(([a])=>!aW.has(a)),aY=Object.keys(al).length,aZ=af.room??0,a$=Object.entries(af).reduce((a,[b,c])=>b.startsWith("dm:")?a+c:a,0),a_=af.telegram??0;return(0,d.jsxs)("div",{className:"chat-dock "+I,style:{width:K},children:[(0,d.jsx)("div",{className:"dock-resizer "+I,onMouseDown:function(a){a.preventDefault();let b=a.clientX;function c(a){let c=a.clientX-b;L(Math.max(320,Math.min(640,"right"===I?K-c:K+c)))}document.body.style.cursor="col-resize",window.addEventListener("mousemove",c),window.addEventListener("mouseup",function a(){window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",a),document.body.style.cursor=""})}}),(0,d.jsxs)("div",{className:"dock-toolbar",children:[(0,d.jsxs)("span",{className:"dock-toolbar-title",children:[(0,d.jsx)(z.I,{name:"agents",size:15,style:{color:"var(--accent)"}})," ",S("chat.dock.agents")]}),(0,d.jsxs)("div",{className:"dock-tools",children:[(0,d.jsxs)("div",{className:"dock-bell-wrap",children:[(0,d.jsxs)("button",{className:"dock-tool",title:S("top.notifications"),onClick:()=>ai(a=>!a),children:[(0,d.jsx)(z.I,{name:"bell",size:15}),ad.length>0&&(0,d.jsx)("span",{className:"dock-bell-badge",children:ad.length})]}),ah&&(0,d.jsxs)("div",{className:"dock-notif-pop",children:[(0,d.jsxs)("div",{className:"dock-notif-head",children:[S("top.notifications")," ",ad.length>0&&(0,d.jsxs)("span",{children:["(",ad.length,")"]})]}),0===ad.length&&(0,d.jsx)("div",{className:"dock-notif-empty",children:S("chat.dock.nothingNeedsYou")}),ad.map(a=>(0,d.jsxs)("button",{className:"dock-notif-row"+("approval"===a.kind?" approval":""),onClick:()=>aT(a),children:[(0,d.jsx)("span",{className:"dn-ico",children:(0,d.jsx)(z.I,{name:"approval"===a.kind?"check":"at",size:13})}),(0,d.jsxs)("span",{className:"dn-body",children:[(0,d.jsx)("span",{className:"dn-text",children:a.text}),a.detail&&(0,d.jsx)("span",{className:"dn-detail",children:a.detail})]}),(0,d.jsx)("span",{className:"dn-go",children:(0,d.jsx)(z.I,{name:"chevronRight",size:12})})]},a.id))]})]}),(0,d.jsx)("button",{className:"dock-tool",title:"right"===I?S("chat.dock.moveLeft"):S("chat.dock.moveRight"),onClick:()=>J(a=>"right"===a?"left":"right"),children:(0,d.jsx)(z.I,{name:"right"===I?"dockLeft":"dockRight",size:15})}),(0,d.jsx)("button",{className:"dock-tool",title:S("chat.dock.hide"),onClick:()=>H(!1),children:(0,d.jsx)(z.I,{name:"close",size:15})})]})]}),(0,d.jsxs)("div",{className:"dock-tabs",children:[(0,d.jsxs)("button",{className:"dock-tab"+(aG||aH||aI?"":" on"),onClick:()=>N("room"),children:[(0,d.jsx)(z.I,{name:"agents",size:14})," ",S("chat.dock.tabRoom"),aZ>0&&(0,d.jsx)("span",{className:"dt-badge",children:aZ})]}),(0,d.jsxs)("button",{className:"dock-tab"+(aH||aG?" on":""),onClick:()=>N("people"),children:[(0,d.jsx)(z.I,{name:"chat",size:14})," ",S("chat.dock.tabDirect"),(a$||aY)>0&&(0,d.jsx)("span",{className:"dt-badge",children:a$||aY})]}),(0,d.jsxs)("button",{className:"dock-tab"+(aI?" on":""),onClick:()=>N("telegram"),children:[(0,d.jsx)(z.I,{name:"send",size:14})," Telegram",a_>0&&(0,d.jsx)("span",{className:"dt-badge",children:a_})]})]}),!aH&&!(aI&&aD&&!aD.connected)&&(0,d.jsxs)("div",{className:"ctx-bar",children:[_?(0,d.jsx)(B.m,{stat:_,onCompact:aQ,compacting:ab}):(0,d.jsx)("span",{}),aI?(0,d.jsxs)("span",{className:"ctx-hint",title:S("chat.dock.tgIsolatedTip"),children:[(0,d.jsx)(z.I,{name:"bot",size:12})," ",S("chat.dock.isolatedThreadAda")]}):(0,d.jsxs)("span",{className:"ctx-hint",title:S("chat.dock.dmAdaTip"),children:[(0,d.jsx)(z.I,{name:"bot",size:12})," ",S("home.chat.dmAda")]})]}),aG&&aK?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"dm-back-row",children:[(0,d.jsxs)("button",{className:"dm-back-btn",onClick:()=>N("people"),children:[(0,d.jsx)(z.I,{name:"chevronLeft",size:14})," ",S("chat.dock.allAgents")]}),(0,d.jsxs)("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:5,flexWrap:"wrap",justifyContent:"flex-end"},children:[ar.map(a=>(0,d.jsxs)("span",{className:"sess-pill",children:[(0,d.jsx)("button",{className:"sess-tab"+(a.active?" active":""),title:a.active?S("chat.dock.sessActiveTip"):S("chat.dock.sessSwitchTip"),onClick:()=>{var b;return b=a.id,void(!ar.find(a=>a.id===b)?.active&&az(async()=>{await i(aL,b).catch(()=>{}),aM()}))},onDoubleClick:()=>{var b,c;let d;return b=a.id,c=a.title,void(null!=(d=prompt(S("chat.dock.renameSession"),c))&&az(async()=>{await j(b,d).catch(()=>{}),g(aL).then(as).catch(()=>{})}))},children:a.title}),ar.length>1&&(0,d.jsx)("button",{className:"sess-del",title:S("chat.dock.sessDelete"),onClick:()=>{var b,c;return b=a.id,c=a.title,void au({title:S("chat.dock.deleteSessionTitle"),body:S("chat.dock.deleteSessionBody",{title:c}),confirmLabel:S("common.delete"),onConfirm:()=>az(async()=>{await k(aL,b).catch(()=>{}),aM(),g(aL).then(as).catch(()=>{})})})},children:(0,d.jsx)(z.I,{name:"close",size:11})})]},a.id)),(0,d.jsxs)("button",{className:"sess-new",title:S("chat.dock.sessNewTip"),onClick:function(){az(async()=>{await h(aL).catch(()=>{}),aM()})},children:[(0,d.jsx)(z.I,{name:"add",size:12})," ",S("chat.dock.sessNew")]})]})]}),(0,d.jsxs)("div",{className:"chat-header dm",children:[(0,d.jsx)(y.e,{name:aK.name,color:aK.color,image:aK.image,size:34,health:aK.health}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"chat-title",children:[aK.name," ",(0,d.jsxs)("span",{className:"agent-handle",children:["@",aK.handle]})]}),(0,d.jsxs)("div",{className:"chat-sub",children:[aK.role," \xb7 ",aK.adapter]})]}),(0,d.jsxs)("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:8},children:[(0,d.jsx)(C.qs,{status:aK.status}),(0,d.jsx)("button",{className:"dock-tool",title:S("chat.dock.clearConversation"),onClick:aR,children:(0,d.jsx)(z.I,{name:"trash",size:15})})]})]}),(0,d.jsxs)("div",{className:"dm-context-note",children:[(0,d.jsx)("span",{className:"ico",children:(0,d.jsx)(z.I,{name:"bot",size:14})}),S("chat.dock.dmContextNote",{name:aK.name})]}),(0,d.jsx)(C.H8,{msgs:T,typing:X,agents:a,byRun:aV,liveRuns:aX,loading:Z,highlightId:aj,operator:b,markdownAgent:!0}),(0,d.jsx)(C.V4,{onSend:aU,agents:a,defaultText:an,placeholder:S("chat.dock.messageAgent",{name:aK.name})},"dm:"+aJ+":"+ap)]}):aH?(0,d.jsx)(D,{agents:a,previews:al,onOpenDM:a=>{N("dm:"+a)}}):aI?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"chat-header room",children:[(0,d.jsx)("div",{className:"brand-ico",style:{background:"linear-gradient(150deg,#2aabee,#229ed9)",color:"#fff"},children:(0,d.jsx)(z.I,{name:"send",size:16})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"chat-title",children:"Telegram"}),(0,d.jsx)("div",{className:"chat-sub",children:aD?.connected?S("chat.tg.connectedSub",{name:aD.allowedName||S("chat.tg.you"),chatId:aD.chatIdMasked??""}):S("chat.tg.connectPrompt")})]}),aD?.connected&&(0,d.jsxs)("div",{style:{marginLeft:"auto",display:"flex",gap:6},children:[(0,d.jsx)("button",{className:"dock-tool",title:S("chat.dock.clearConversation"),onClick:aR,children:(0,d.jsx)(z.I,{name:"trash",size:15})}),(0,d.jsx)("button",{className:"dock-tool",title:S("chat.tg.disconnect"),onClick:()=>{confirm(S("chat.tg.disconnectConfirm"))&&az(async()=>{await (0,s.K)(),aO()})},children:(0,d.jsx)(z.I,{name:"close",size:15})})]})]}),aD&&!aD.connected?(0,d.jsx)(E,{onConnected:aO}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"dm-context-note",children:[(0,d.jsx)("span",{className:"ico",children:(0,d.jsx)(z.I,{name:"send",size:14})}),S("chat.tg.isolatedThreadNote")]}),(0,d.jsx)(C.H8,{msgs:T,typing:X,agents:a,byRun:aV,liveRuns:aX,loading:Z||!aD,highlightId:aj,operator:b,markdownAgent:!0}),(0,d.jsx)(C.V4,{onSend:aU,agents:a,placeholder:S("chat.tg.composerPlaceholder")},"telegram:"+ap)]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"chat-header room",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"chat-title",children:S("chat.dock.teamChannel")}),(0,d.jsx)("div",{className:"chat-sub",children:S("chat.dock.teamChannelSub",{n:a.length})})]}),(0,d.jsxs)("div",{className:"chat-members",children:[a.slice(0,6).map(a=>(0,d.jsx)("button",{className:"member-btn",title:S("chat.dock.dmName",{name:a.name}),onClick:()=>{N("dm:"+a.handle)},children:(0,d.jsx)(y.e,{name:a.name,color:a.color,size:26})},a.handle)),a.length>6&&(0,d.jsxs)("button",{className:"more",title:S("chat.dock.allAgents"),onClick:()=>N("people"),children:["+",a.length-6]})]})]}),(c=Array.from(new Set(a.map(a=>a.role))).sort(),f="all"===O?T:"type:work"===O?T.filter(a=>(aV[a.id]?.length??0)>0||!!a.kind):"type:chat"===O?T.filter(a=>!aV[a.id]?.length&&!a.kind):O.startsWith("role:")?T.filter(a=>"operator"===a.fromKind||a.fromHandle&&aF[a.fromHandle]?.role===O.slice(5)):T.filter(a=>"operator"===a.fromKind||a.fromHandle===O),A=(q=Q.trim().toLowerCase())?f.filter(a=>(a.text??"").toLowerCase().includes(q)):f,(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"room-filter",children:[(0,d.jsx)("span",{className:"rf-label",children:S("chat.filter")}),(0,d.jsx)("button",{type:"button",className:"rf-chip"+("all"===O?" on":""),onClick:()=>P("all"),children:S("common.all")}),(0,d.jsx)("button",{type:"button",className:"rf-chip rf-lane"+("type:work"===O?" on":""),title:S("chat.filter.work"),onClick:()=>P("type:work"===O?"all":"type:work"),children:S("chat.filter.work")}),(0,d.jsx)("button",{type:"button",className:"rf-chip rf-lane"+("type:chat"===O?" on":""),title:S("chat.filter.discussion"),onClick:()=>P("type:chat"===O?"all":"type:chat"),children:S("chat.filter.discussion")}),c.map(a=>(0,d.jsx)("button",{type:"button",className:"rf-chip rf-role"+(O==="role:"+a?" on":""),title:S("chat.filter.byRole"),onClick:()=>P(O==="role:"+a?"all":"role:"+a),children:a},"role:"+a)),a.map(a=>(0,d.jsxs)("button",{type:"button",className:"rf-chip"+(O===a.handle?" on":""),title:a.name,onClick:()=>P(O===a.handle?"all":a.handle),children:["@",a.handle]},a.handle)),(0,d.jsxs)("span",{className:"rf-search",children:[(0,d.jsx)(z.I,{name:"search",size:12}),(0,d.jsx)("input",{value:Q,onChange:a=>R(a.target.value),placeholder:S("chat.filter.search"),"aria-label":S("chat.filter.search")}),Q&&(0,d.jsx)("button",{type:"button",className:"rf-clear",onClick:()=>R(""),"aria-label":S("common.dismiss"),children:(0,d.jsx)(z.I,{name:"close",size:11})})]})]}),(0,d.jsx)(C.H8,{msgs:A,typing:X,agents:a,byRun:aV,liveRuns:aX,loading:Z,highlightId:aj,operator:b,markdownAgent:!0,refs:ax})]})),(0,d.jsx)(C.V4,{onSend:aU,agents:a,defaultText:"room"===M?an:"",requireMention:!0,placeholder:S("chat.dock.roomPlaceholder"),refs:ax},"room:"+ap)]}),at&&(0,d.jsx)("div",{className:"modal-overlay",onMouseDown:()=>au(null),children:(0,d.jsxs)("div",{className:"modal",style:{width:380},onMouseDown:a=>a.stopPropagation(),children:[(0,d.jsx)("div",{className:"modal-head",children:(0,d.jsxs)("div",{className:"modal-title",children:[(0,d.jsx)(z.I,{name:"trash",size:15,style:{color:"var(--sx-keyword)"}})," ",at.title]})}),(0,d.jsx)("div",{className:"modal-body",children:(0,d.jsx)("div",{style:{fontSize:13,color:"var(--text-dim)",lineHeight:1.55},children:at.body})}),(0,d.jsxs)("div",{className:"modal-foot",children:[(0,d.jsx)("button",{className:"btn-ghost",onClick:()=>au(null),children:S("common.cancel")}),(0,d.jsx)("button",{className:"btn-accent",style:{background:"var(--sx-keyword)",borderColor:"var(--sx-keyword)",color:"#fff"},onClick:()=>{at.onConfirm(),au(null)},children:at.confirmLabel})]})]})})]})}},69626:(a,b,c)=>{"use strict";c.d(b,{m:()=>f});var d=c(4374);let e={working:{c:"var(--sx-string)",pulse:!0,label:"working"},review:{c:"#e0a44e",label:"review"},blocked:{c:"#e8688f",label:"blocked"},idle:{c:"var(--text-faint)",label:"idle"}};function f({status:a,label:b=!1,size:c=8}){let g=e[a]??e.idle;return(0,d.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5},title:g.label,children:[g.pulse?(0,d.jsx)("span",{className:"dotpulse"}):(0,d.jsx)("span",{style:{width:c,height:c,borderRadius:"50%",background:g.c,display:"inline-block",flex:`0 0 ${c}px`}}),b&&(0,d.jsx)("span",{style:{fontSize:11,color:g.c,fontWeight:600},children:g.label})]})}},70221:(a,b,c)=>{"use strict";c.d(b,{B:()=>x,z:()=>w});var d=c(77598),e=c(73024),f=c(76760),g=c(73136),h=c(31421),i=c(97603),j=c(65705),k=c(1890),l=c(57086),m=c(79505),n=c(33644),o=c(63562),p=c(56338),q=c(53080);async function r(a,b,c){let d=await a.newPage();try{return await d.evaluate(async a=>{let b=a=>new Promise((b,c)=>{let d=new Image;d.onload=()=>b(d),d.onerror=c,d.src=a}),[c,d]=await Promise.all([b(a[0]),b(a[1])]),e=a=>{let b=document.createElement("canvas");b.width=1280,b.height=800;let c=b.getContext("2d");return c.drawImage(a,0,0,1280,800),c.getImageData(0,0,1280,800).data},f=e(c),g=e(d),h=0;for(let a=0;a<f.length;a+=4)(Math.abs(f[a]-g[a])>32||Math.abs(f[a+1]-g[a+1])>32||Math.abs(f[a+2]-g[a+2])>32)&&h++;return h/1024e3},[`data:image/png;base64,${b}`,`data:image/png;base64,${c}`])}catch{return null}finally{try{await d.close()}catch{}}}let s=["/.env","/.env.local","/.git/config","/config.json","/admin","/api"],t=/(sk-[a-z0-9]{20,}|AKIA[0-9A-Z]{16}|-----BEGIN (?:RSA |EC )?PRIVATE KEY-----|password["']?\s*[:=]\s*["'][^"']{4,})/i,u=null;function v(a,b,c,d="",e=""){(0,m.I)(a,{runId:b,channel:"testdev",agentId:null,kind:c,target:d,detail:e}),(0,n.r)(a)}async function w(a,b,m={}){let n,x=(0,d.randomUUID)();await j.db.insert(k.testRun).values({id:x,workspaceId:a,goalId:m.goalId??null,issueId:m.issueId??null,status:"running",by:m.by??"operator"}),v(a,x,"thinking","Starting Test Dev…");let y=async(b,c,d)=>(await j.db.update(k.testRun).set({status:b,summary:c.slice(0,600),findings:JSON.stringify(d).slice(0,2e4),finishedAt:new Date}).where((0,i.eq)(k.testRun.id,x)),v(a,x,"done",`${b} \xb7 ${d.length} finding(s)`),{id:x,status:b,summary:c,findings:d}),z=(0,o.Vd)(a);if(!z&&m.noBoot)return y("inconclusive","Dev server not running — start it in Test Dev to gate task completion.",[]);if(!z){v(a,x,"thinking","Booting project dev server…");let c=await (0,o.ZF)(a,b);if(!c.running||!c.url)return y("inconclusive","No runnable project / dev server didn't boot — nothing to test yet.",[{severity:"low",kind:"boot",route:"-",message:c.logs.slice(-3).map(a=>a.t).join(" | ")||"no project"}]);z=c.url}if("running"!==(0,o.CS)(a).status)return y("inconclusive","Dev server is still starting — try again shortly.",[{severity:"low",kind:"boot",route:"-",message:"server not reachable yet"}]);let A=(m.routes&&m.routes.length?m.routes:["/"]).slice(0,8);try{({chromium:n}=await Promise.resolve().then(c.bind(c,5006)))}catch{return y("inconclusive","Playwright not available — install it (`npx playwright install chromium`) to enable browser tests.",[])}let B=[],C=(0,f.join)((0,l.HZ)(b),".testdev");try{(0,e.mkdirSync)(C,{recursive:!0})}catch{}let D=null;try{D=await n.launch({headless:!0})}catch(c){v(a,x,"thinking","Installing the test browser (chromium, one-time ~150MB)…");let b=await (!u&&(u=new Promise(a=>{try{let b="win32"===process.platform?"npx.cmd":"npx",c=(0,h.spawn)(b,["playwright","install","chromium"],{stdio:"ignore",windowsHide:!0}),d=setTimeout(()=>{try{c.kill()}catch{}a(!1)},3e5);c.on("exit",b=>{clearTimeout(d),a(0===b)}),c.on("error",()=>{clearTimeout(d),a(!1)})}catch{a(!1)}})),u);if(b)try{D=await n.launch({headless:!0})}catch{}if(!D)return y("inconclusive",b?"Couldn't launch chromium after install — try again.":"Couldn't install/launch chromium. Run `npx playwright install chromium` in the install dir, then retry.",[{severity:"low",kind:"boot",route:"-",message:String(c instanceof Error?c.message:c).slice(0,200)}])}try{let c=await D.newContext({viewport:{width:1280,height:800}}),d=await c.newPage();d.on("console",a=>{let b=a.type();"error"===b?B.push({severity:"high",kind:"console",route:d.url(),message:a.text().slice(0,300)}):"warning"===b&&B.push({severity:"low",kind:"console",route:d.url(),message:a.text().slice(0,300)})}),d.on("pageerror",a=>B.push({severity:"high",kind:"pageerror",route:d.url(),message:String(a.message??a).slice(0,300)})),d.on("requestfailed",a=>{let b=a.failure()?.errorText??"";/ERR_ABORTED/.test(b)||B.push({severity:"med",kind:"request",route:d.url(),message:`${a.method()} ${a.url().slice(0,160)} — ${b}`})});let h=(0,q.hp)(b),i=!!h.served&&!!h.target,j=(0,f.join)(C,"baseline");if(i)try{(0,e.mkdirSync)(j,{recursive:!0})}catch{}for(let k of A){v(a,x,"text",`navigate ${k}`);try{let a=await d.goto(z+k,{waitUntil:"domcontentloaded",timeout:2e4});a&&a.status()>=500&&B.push({severity:"high",kind:"request",route:k,message:`${k} → HTTP ${a.status()}`}),await d.waitForTimeout(800);let m=d.locator("button:visible:not([disabled])").first();if(await m.count())try{await m.click({timeout:2e3}),await d.waitForTimeout(500)}catch{}let n=await d.content();t.test(n)&&B.push({severity:"high",kind:"security",route:k,message:"Possible secret/credential present in served HTML/JS."});let o=k.replace(/[^a-z0-9]/gi,"_")||"root";try{await d.screenshot({path:(0,f.join)(C,`${x}-${o}.png`)})}catch{}if(i)try{let a=(0,f.join)(j,`${o}.png`);if(!(0,e.existsSync)(a)){let d="/"===k?"index.html":k.replace(/^\//,"").replace(/\/+$/,"")+".html",i=(0,f.join)((0,l.HZ)(b),h.target,d);if((0,e.existsSync)(i)){let b=await c.newPage();try{await b.goto((0,g.pathToFileURL)(i).href,{waitUntil:"domcontentloaded",timeout:15e3}),await b.waitForTimeout(400),await b.screenshot({path:a})}finally{try{await b.close()}catch{}}}}if((0,e.existsSync)(a)){let b=await d.screenshot(),f=await r(c,(0,e.readFileSync)(a).toString("base64"),b.toString("base64"));if(null!=f){let a=Math.round(100*f);f>.5?B.push({severity:"high",kind:"fidelity",route:k,message:`Visual fidelity: ${a}% of the screen differs from the APPROVED design — it doesn't match; build ${k} to the design (zero drift).`}):f>.12&&B.push({severity:"med",kind:"fidelity",route:k,message:`Visual drift: ${a}% differs from the approved design at ${k}.`})}}}catch{}}catch(a){B.push({severity:"med",kind:"request",route:k,message:`navigation failed: ${String(a instanceof Error?a.message:a).slice(0,160)}`})}}for(let a of s)try{let b=await fetch(z+a,{redirect:"manual",signal:AbortSignal.timeout(4e3)});if(200===b.status){let c=await b.text().catch(()=>"");("/api"!==a&&c.length>0||t.test(c))&&B.push({severity:"high",kind:"security",route:a,message:`${a} returns 200 with content unauthenticated.`})}}catch{}await c.close()}finally{try{await D.close()}catch{}}let E=B.filter(a=>"high"===a.severity),F=E.length?"fail":"pass",G="fail"===F?`${E.length} blocking issue(s): ${E.slice(0,3).map(a=>`${a.kind} @ ${a.route}`).join(", ")}`:`Passed — ${B.length} note(s), no blocking issues. Navigated ${A.length} route(s).`;return(0,p.ru)(b,[{type:"test",title:`Test Dev — ${F}`,summary:G,goalId:m.goalId??null,issueId:m.issueId??null,agentHandle:"agent"===m.by?"edsger":"operator",sourceKind:"test",sourceRef:x}]).catch(()=>{}),y(F,G,B)}async function x(a,b){let[c]=await j.db.select().from(k.issue).where((0,i.eq)(k.issue.id,b)),d=new Set(["/"]);if(c){let a=(c.title+" "+(c.key??"")).match(/\/[a-z0-9\-/]{2,}/gi);a&&a.slice(0,4).forEach(a=>d.add(a))}return[...d]}},71352:(a,b,c)=>{"use strict";c.d(b,{Tc:()=>z,YK:()=>D,PM:()=>B});var d=c(77598),e=c(54548),f=c(97603),g=c(95357),h=c(65705),i=c(1890),j=c(70149),k=c(38926),l=c(29803),m=c(1273);async function n(a,b){let c=b.adapter??"";if(c.startsWith("local_"))return{kind:"http",http:{provider:"openai",baseUrl:"local_ollama"===c?(process.env.OLLAMA_URL??"http://127.0.0.1:11434")+"/v1":(process.env.LLAMACPP_URL??"http://127.0.0.1:8082")+"/v1",apiKey:"",model:b.model||"local"}};if(c.startsWith("http_")){let[d]=await h.db.select().from(i.provider).where((0,f.Uo)((0,f.eq)(i.provider.workspaceId,a),(0,f.eq)(i.provider.adapter,c)));if(d){let e=(0,l.kH)(d.catalogId),f=await (0,k.r6)(a,`${d.catalogId}_api_key`);if(e?.baseUrl&&f)return{kind:"http",http:{provider:c.includes("google")?"google":"openai",baseUrl:e.baseUrl,apiKey:f,model:b.model}}}}return{kind:"cli",binary:(0,j.hW)(b.adapter,b.model)}}async function o(a,b,c,d){return"http"===b.kind?(0,m._)(a,b.http,{timeoutMs:c.timeoutMs},d):(0,j.p1)(a,{orgId:c.orgId,binary:b.binary,model:c.model,timeoutMs:c.timeoutMs},d)}var p=c(78161),q=c(45125),r=c(25497),s=c(79505),t=c(36482),u=c(33644),v=c(57300),w=c(56338),x=c(48503);async function y(a,b){if(!b)return!1;let c=new Date;c.setHours(0,0,0,0);let[d]=await h.db.select({total:(0,e.cz)(i.costEntry.usd)}).from(i.costEntry).where((0,f.Uo)((0,f.eq)(i.costEntry.agentId,a),(0,f.RO)(i.costEntry.at,c)));return Number(d?.total??0)>=b}function z(a){let b=(a??"").trim();return b?/not logged in|please run \/login|unauthenticated|unauthorized|invalid api key|authentication failed/i.test(b)?"the agent's CLI isn't authenticated in this runtime — check the model provider / CLI login in the Models module":b:"no output"}let A="[[CREATE_WORK]]";async function B(a,b,c,e,k,l){let m=(0,d.randomUUID)(),y=(0,j.hW)(e.adapter,e.model),B="work"===k?`This is the team room.${l?` Your teammate @${l.from} just handed off to YOU:
333
333
  """
334
334
  ${l.text.slice(0,800)}
335
335
  """
@@ -352,9 +352,9 @@ KNOWLEDGE CONSULT: before you assume a convention, a prior decision, or whether
352
352
 
353
353
  KB MAINTENANCE (you are the Knowledge agent): you may trigger "[[KB: reindex]]", "[[KB: index-chat]]" or "[[KB: health]]" on their own line to refresh the workspace index, re-index the conversations, or check the embedding server — each result is reported back into the thread.`:""),{prompt:F,sources:G}=await (0,p.s)({orgId:a,ws:b,agent:e,channel:c,instruction:E});(0,j.Pe)(b.settings?.agents?.fileLocks??null),(0,j.Hs)(b.settings?.agents?.cmdGuard??null),(0,j.UC)(b.settings?.agents?.webResearch??null);let H=await n(b.id,e),I=await o(F,H,{orgId:a,model:function(a,b){if("claude"===a){let a=(b||"").toLowerCase();return a.includes("opus")?"opus":a.includes("haiku")?"haiku":"sonnet"}if("codex"!==a)return b||void 0}(y,e.model),timeoutMs:18e4},a=>{(0,s.I)(b.id,{runId:m,channel:c,agentId:e.id,kind:a.kind,target:a.target,detail:a.detail})}),J=""!==C&&I.text.includes(A),K=I.text.split(A).join("").trim(),L=(0,w.c5)(K,{agentHandle:e.handle,sourceKind:"chat",sourceRef:m});L.items.length&&(0,w.ru)(a,L.items).catch(()=>{});let M=await (0,w.uJ)(a,L.stripped,e.handle),N=await (0,w.QU)(a,M.stripped),O=(0,x.Z)(N.stripped);for(let a of(await h.db.insert(i.message).values({id:m,workspaceId:b.id,channel:c,fromKind:"agent",fromHandle:e.handle,text:I.ok&&O?O.slice(0,4e3):`(${e.name} couldn't respond: ${z(I.error)})`,sources:G.length?G:null,sessionId:await (0,q.xF)(b.id,c)}),M.answers))await h.db.insert(i.message).values({id:(0,d.randomUUID)(),workspaceId:b.id,channel:c,fromKind:"agent",fromHandle:"vannevar",text:`🔎 KB consult — "${a.q}"
354
354
 
355
- ${a.a}`.slice(0,4e3),sources:a.sources.length?a.sources:null,sessionId:await (0,q.xF)(b.id,c)});return N.results.length&&await h.db.insert(i.message).values({id:(0,d.randomUUID)(),workspaceId:b.id,channel:c,fromKind:"agent",fromHandle:"vannevar",text:`🛠️ KB tools — ${N.results.join(" \xb7 ")}`.slice(0,4e3),sessionId:await (0,q.xF)(b.id,c)}),await (0,t.f)(b.id,m,c),I.ok&&O&&"telegram"!==c&&await (0,r.b)(b.id,{text:O,agentId:e.id,agentHandle:e.handle,messageId:m,channel:c}),(0,u.r)(b.id),(0,v.PD)(a),(I.usd>0||I.inputTokens+I.outputTokens>0)&&await h.db.insert(i.costEntry).values({id:(0,d.randomUUID)(),workspaceId:b.id,agentId:e.id,channel:c,provider:I.binary,model:I.model??e.model,usd:I.usd,tokens:I.inputTokens+I.outputTokens,at:new Date}),{text:I.ok?K:"",planRequested:J}}async function C(a,b){return"working"===b.status||!!await h.db.query.task.findFirst({where:(0,f.Uo)((0,f.eq)(i.task.workspaceId,a),(0,f.eq)(i.task.assigneeId,b.id),(0,f.eq)(i.task.col,"doing"))})}async function D(a,b,c,d,e=0,g=new Set){let j;if(e>=2||!d.trim()||!(j=d.replace(/@\w[\w-]*/g," ").replace(/\p{Extended_Pictographic}/gu," ").replace(/[^\p{L}\p{N}]+/gu," ").trim().toLowerCase())||/^(ok|okay|k|got it|on it|im on it|working on it|starting|starting now|will do|sure|sounds good|done|thanks|thank you|np|yep|yes|roger|copy)$/.test(j))return;let k=d.replace(/(\p{Extended_Pictographic}[️‍]?){2,}/gu,a=>Array.from(a)[0]).trim(),l=Object.fromEntries((await h.db.select().from(i.agent).where((0,f.eq)(i.agent.workspaceId,b.id))).map(a=>[a.handle,a])),m=[...new Set((d.match(/@([a-z0-9-]+)/gi)||[]).map(a=>a.slice(1).toLowerCase()))].filter(a=>a!==c&&l[a]&&!g.has(a)),n=0;for(let d of m){if(n>=1)break;let f=l[d];if(await y(f.id,f.dailyCapUsd)||await C(b.id,f))continue;n++,g.add(d);let{text:h}=await B(a,b,"room",f,"work",{from:c,text:k});await D(a,b,d,h,e+1,g)}}},72507:(a,b,c)=>{"use strict";c.d(b,{b:()=>e});var d=c(2910);let e=(0,d.createServerReference)("00703229b811528142c40576d5c57f3467b87b9b61",d.callServer,void 0,d.findSourceMapURL,"getDmPreviews")},76737:(a,b,c)=>{"use strict";c.d(b,{lM:()=>j,s$:()=>k});var d=c(77598),e=c(97603),f=c(65705),g=c(1890),h=c(57086);function i(a){let b=[];for(let c of a.split("\n")){let a=c.match(/^\s*-\s*\[([ xX])\]\s+(.+)$/);a&&b.push({text:a[2].trim().slice(0,200),done:"x"===a[1].toLowerCase()})}return b.slice(0,12)}async function j(a,b,c){let h=i(c);if(!h.length)return;let j=await f.db.select().from(g.taskStep).where((0,e.eq)(g.taskStep.taskId,b)),k=new Map(j.map(a=>[a.text.toLowerCase(),a])),l=j.length;for(let c of h){let h=k.get(c.text.toLowerCase());h?h.done!==c.done&&await f.db.update(g.taskStep).set({done:c.done}).where((0,e.eq)(g.taskStep.id,h.id)):await f.db.insert(g.taskStep).values({id:(0,d.randomUUID)(),workspaceId:a,taskId:b,text:c.text,done:c.done,ord:l++})}}async function k(a,b){let c=await f.db.select().from(g.issue).where((0,e.eq)(g.issue.workspaceId,b)),j=Object.fromEntries((await f.db.select().from(g.spec).where((0,e.eq)(g.spec.workspaceId,b))).map(a=>[a.id,a.summary])),k=new Set((await f.db.select({issueId:g.task.issueId}).from(g.task).where((0,e.eq)(g.task.workspaceId,b))).map(a=>a.issueId).filter(Boolean)),m=0;for(let e of c){if(k.has(e.id))continue;let c=(0,h.sL)(a,`issues/${e.key}.md`)??"",l=c.match(/^\*\*Skills to consult:\*\*\s*(.+)$/m)?.[1]?.trim(),n=l?`
355
+ ${a.a}`.slice(0,4e3),sources:a.sources.length?a.sources:null,sessionId:await (0,q.xF)(b.id,c)});return N.results.length&&await h.db.insert(i.message).values({id:(0,d.randomUUID)(),workspaceId:b.id,channel:c,fromKind:"agent",fromHandle:"vannevar",text:`🛠️ KB tools — ${N.results.join(" \xb7 ")}`.slice(0,4e3),sessionId:await (0,q.xF)(b.id,c)}),await (0,t.f)(b.id,m,c),I.ok&&O&&"telegram"!==c&&await (0,r.b)(b.id,{text:O,agentId:e.id,agentHandle:e.handle,messageId:m,channel:c}),(0,u.r)(b.id),(0,v.PD)(a),(I.usd>0||I.inputTokens+I.outputTokens>0)&&await h.db.insert(i.costEntry).values({id:(0,d.randomUUID)(),workspaceId:b.id,agentId:e.id,channel:c,provider:I.binary,model:I.model??e.model,usd:I.usd,tokens:I.inputTokens+I.outputTokens,at:new Date}),{text:I.ok?K:"",planRequested:J}}async function C(a,b){return"working"===b.status||!!await h.db.query.task.findFirst({where:(0,f.Uo)((0,f.eq)(i.task.workspaceId,a),(0,f.eq)(i.task.assigneeId,b.id),(0,f.eq)(i.task.col,"doing"))})}async function D(a,b,c,d,e=0,g=new Set){let j;if(e>=2||!d.trim()||!(j=d.replace(/@\w[\w-]*/g," ").replace(/\p{Extended_Pictographic}/gu," ").replace(/[^\p{L}\p{N}]+/gu," ").trim().toLowerCase())||/^(ok|okay|k|got it|on it|im on it|working on it|starting|starting now|will do|sure|sounds good|done|thanks|thank you|np|yep|yes|roger|copy)$/.test(j))return;let k=d.replace(/(\p{Extended_Pictographic}[️‍]?){2,}/gu,a=>Array.from(a)[0]).trim(),l=Object.fromEntries((await h.db.select().from(i.agent).where((0,f.eq)(i.agent.workspaceId,b.id))).map(a=>[a.handle,a])),m=[...new Set((d.match(/@([a-z0-9-]+)/gi)||[]).map(a=>a.slice(1).toLowerCase()))].filter(a=>a!==c&&l[a]&&!g.has(a)),n=0;for(let d of m){if(n>=1)break;let f=l[d];if(await y(f.id,f.dailyCapUsd)||await C(b.id,f))continue;n++,g.add(d);let{text:h}=await B(a,b,"room",f,"work",{from:c,text:k});await D(a,b,d,h,e+1,g)}}},76737:(a,b,c)=>{"use strict";c.d(b,{lM:()=>j,s$:()=>k});var d=c(77598),e=c(97603),f=c(65705),g=c(1890),h=c(57086);function i(a){let b=[];for(let c of a.split("\n")){let a=c.match(/^\s*-\s*\[([ xX])\]\s+(.+)$/);a&&b.push({text:a[2].trim().slice(0,200),done:"x"===a[1].toLowerCase()})}return b.slice(0,12)}async function j(a,b,c){let h=i(c);if(!h.length)return;let j=await f.db.select().from(g.taskStep).where((0,e.eq)(g.taskStep.taskId,b)),k=new Map(j.map(a=>[a.text.toLowerCase(),a])),l=j.length;for(let c of h){let h=k.get(c.text.toLowerCase());h?h.done!==c.done&&await f.db.update(g.taskStep).set({done:c.done}).where((0,e.eq)(g.taskStep.id,h.id)):await f.db.insert(g.taskStep).values({id:(0,d.randomUUID)(),workspaceId:a,taskId:b,text:c.text,done:c.done,ord:l++})}}async function k(a,b){let c=await f.db.select().from(g.issue).where((0,e.eq)(g.issue.workspaceId,b)),j=Object.fromEntries((await f.db.select().from(g.spec).where((0,e.eq)(g.spec.workspaceId,b))).map(a=>[a.id,a.summary])),k=new Set((await f.db.select({issueId:g.task.issueId}).from(g.task).where((0,e.eq)(g.task.workspaceId,b))).map(a=>a.issueId).filter(Boolean)),m=0;for(let e of c){if(k.has(e.id))continue;let c=(0,h.sL)(a,`issues/${e.key}.md`)??"",l=c.match(/^\*\*Skills to consult:\*\*\s*(.+)$/m)?.[1]?.trim(),n=l?`
356
356
 
357
- Consult these skills BEFORE building (read the matching .claude/skills/<name>.md): ${l}.`:"",o=(((e.specId?j[e.specId]:"")||c).slice(0,2e3)+n).slice(0,2200),p=(0,d.randomUUID)();await f.db.insert(g.task).values({id:p,workspaceId:b,issueId:e.id,goalId:e.goalId,key:e.key,title:e.title,description:o,col:"todo",prio:e.prio,assigneeId:e.assigneeId,createdBy:"agent"});let q=0;for(let a of i(c))await f.db.insert(g.taskStep).values({id:(0,d.randomUUID)(),workspaceId:b,taskId:p,text:a.text,done:a.done,ord:q++});m++}return await l(b),m}async function l(a){let[b]=await f.db.select().from(g.agent).where((0,e.Uo)((0,e.eq)(g.agent.workspaceId,a),(0,e.eq)(g.agent.handle,"barbara"))),c=b??(await f.db.select().from(g.agent).where((0,e.Uo)((0,e.eq)(g.agent.workspaceId,a),(0,e.mj)(g.agent.role,"%Docs%"))))[0];!c||(await f.db.select({id:g.task.id}).from(g.task).where((0,e.Uo)((0,e.eq)(g.task.workspaceId,a),(0,e.eq)(g.task.key,"DOCS-1")))).length||await f.db.insert(g.task).values({id:(0,d.randomUUID)(),workspaceId:a,key:"DOCS-1",title:"Document the project — update DOCS/ to match what was built",description:"Read the real code, specs and structure in this workspace, then write/refresh accurate documentation under DOCS/ (architecture, API, usage, how to run). Replace the scaffold templates with real content grounded in the actual files. Do not invent features.",col:"todo",prio:"low",assigneeId:c.id,createdBy:"agent"})}},77126:(a,b,c)=>{"use strict";c.d(b,{RunnerHeartbeat:()=>g});var d=c(74679),e=c(47104),f=c(2910);function g({intervalMs:a=8e3,approved:b=!1,auto247:c=!1}){return(0,e.useRouter)(),(0,d.useRef)(!1),(0,d.useRef)(!1),null}f.callServer,f.findSourceMapURL,f.callServer,f.findSourceMapURL},78161:(a,b,c)=>{"use strict";c.d(b,{s:()=>s});var d=c(97603),e=c(95357),f=c(65705),g=c(1890),h=c(57086),i=c(12677),j=c(45125),k=c(56338),l=c(63556),m=c(57806),n=c(35745),o=c(93571);async function p(a,b){let[c,h,i,j]=await Promise.all([f.db.select({key:g.issue.key,title:g.issue.title,col:g.issue.col}).from(g.issue).where((0,d.Uo)((0,d.eq)(g.issue.workspaceId,a),(0,d.ne)(g.issue.col,"done"))).limit(40),f.db.select({key:g.task.key,title:g.task.title,col:g.task.col,assigneeId:g.task.assigneeId}).from(g.task).where((0,d.Uo)((0,d.eq)(g.task.workspaceId,a),(0,d.RV)(g.task.col,["todo","doing","blocked"]))).limit(40),f.db.select({key:g.spec.key,title:g.spec.title}).from(g.spec).where((0,d.eq)(g.spec.workspaceId,a)).limit(20),f.db.select({text:g.decision.text,by:g.decision.by,source:g.decision.source}).from(g.decision).where((0,d.eq)(g.decision.workspaceId,a)).orderBy((0,e.i)(g.decision.createdAt)).limit(8)]),k=h.filter(a=>a.assigneeId===b.id),l=[];return j.length&&l.push(`Recent decisions:
357
+ Consult these skills BEFORE building (read the matching .claude/skills/<name>.md): ${l}.`:"",o=(((e.specId?j[e.specId]:"")||c).slice(0,2e3)+n).slice(0,2200),p=(0,d.randomUUID)();await f.db.insert(g.task).values({id:p,workspaceId:b,issueId:e.id,goalId:e.goalId,key:e.key,title:e.title,description:o,col:"todo",prio:e.prio,assigneeId:e.assigneeId,createdBy:"agent"});let q=0;for(let a of i(c))await f.db.insert(g.taskStep).values({id:(0,d.randomUUID)(),workspaceId:b,taskId:p,text:a.text,done:a.done,ord:q++});m++}return await l(b),m}async function l(a){let[b]=await f.db.select().from(g.agent).where((0,e.Uo)((0,e.eq)(g.agent.workspaceId,a),(0,e.eq)(g.agent.handle,"barbara"))),c=b??(await f.db.select().from(g.agent).where((0,e.Uo)((0,e.eq)(g.agent.workspaceId,a),(0,e.mj)(g.agent.role,"%Docs%"))))[0];!c||(await f.db.select({id:g.task.id}).from(g.task).where((0,e.Uo)((0,e.eq)(g.task.workspaceId,a),(0,e.eq)(g.task.key,"DOCS-1")))).length||await f.db.insert(g.task).values({id:(0,d.randomUUID)(),workspaceId:a,key:"DOCS-1",title:"Document the project — update DOCS/ to match what was built",description:"Read the real code, specs and structure in this workspace, then write/refresh accurate documentation under DOCS/ (architecture, API, usage, how to run). Replace the scaffold templates with real content grounded in the actual files. Do not invent features.",col:"todo",prio:"low",assigneeId:c.id,createdBy:"agent"})}},78161:(a,b,c)=>{"use strict";c.d(b,{s:()=>s});var d=c(97603),e=c(95357),f=c(65705),g=c(1890),h=c(57086),i=c(12677),j=c(45125),k=c(56338),l=c(63556),m=c(57806),n=c(35745),o=c(93571);async function p(a,b){let[c,h,i,j]=await Promise.all([f.db.select({key:g.issue.key,title:g.issue.title,col:g.issue.col}).from(g.issue).where((0,d.Uo)((0,d.eq)(g.issue.workspaceId,a),(0,d.ne)(g.issue.col,"done"))).limit(40),f.db.select({key:g.task.key,title:g.task.title,col:g.task.col,assigneeId:g.task.assigneeId}).from(g.task).where((0,d.Uo)((0,d.eq)(g.task.workspaceId,a),(0,d.RV)(g.task.col,["todo","doing","blocked"]))).limit(40),f.db.select({key:g.spec.key,title:g.spec.title}).from(g.spec).where((0,d.eq)(g.spec.workspaceId,a)).limit(20),f.db.select({text:g.decision.text,by:g.decision.by,source:g.decision.source}).from(g.decision).where((0,d.eq)(g.decision.workspaceId,a)).orderBy((0,e.i)(g.decision.createdAt)).limit(8)]),k=h.filter(a=>a.assigneeId===b.id),l=[];return j.length&&l.push(`Recent decisions:
358
358
  ${j.map(a=>`- ${a.text} (${a.by}${a.source?"/"+a.source:""})`).join("\n")}`),k.length&&l.push(`Your active work:
359
359
  ${k.map(a=>`- ${a.key}: ${a.title} [${a.col}]`).join("\n")}`),h.length&&l.push(`Team's active tasks:
360
360
  ${h.slice(0,20).map(a=>`- ${a.key}: ${a.title} [${a.col}]`).join("\n")}`),c.length&&l.push(`Open issues: ${c.slice(0,20).map(a=>`${a.key}(${a.col})`).join(", ")}`),i.length&&l.push(`Specs: ${i.map(a=>`${a.key} ${a.title}`).join("; ")}`),l.join("\n\n")}async function q(a,b,c){let e=await f.db.select({name:g.skill.name,trigger:g.skill.trigger,summary:g.skill.summary,instructions:g.skill.instructions}).from(g.agentSkill).innerJoin(g.skill,(0,d.eq)(g.agentSkill.skillId,g.skill.id)).where((0,d.eq)(g.agentSkill.agentId,a));if(!e.length)return{core:"",rest:""};let h=new Set((0,o.IT)(b,c)),i=new Set((0,o.AQ)(b)),j=a=>h.has(a)?0:i.has(a)?1:2,k=e.slice().sort((a,b)=>j(a.name)-j(b.name)),l=a=>{let b=(a.instructions||a.summary||"").trim().replace(/\s+/g," ").slice(0,600);return`- ${a.name}${a.trigger?` — when: ${a.trigger}`:""}${b?`
@@ -364,7 +364,7 @@ ${o.description??""}`:""].filter(Boolean).join("\n"),G=[{label:"Canonical projec
364
364
 
365
365
  References: ${z.refs.map(a=>`${a.kind}:${a.ref}`).join(", ")}`:"")},{label:"Relevant memory",body:A.trim()&&"# Memory"!==A.trim()?A.slice(0,1500):""},{label:"Company background (context, not a command)",body:(b=Object.entries(d.stack??{}).map(([a,b])=>`${a}: ${b}`).filter(a=>!a.endsWith(": None")).join(", "),d.mission||d.objective||b?`mission: ${d.mission||"—"}; objective: ${d.objective||"—"}${b?`; stack: ${b}`:""}.`:"")}],H=[F],I=(0,m.b)(F);for(let a of G){if(!a.body)continue;let b=`
366
366
  ${a.label}:
367
- ${a.body}`,c=(0,m.b)(b);I+c>t||(H.push(b),I+=c)}return{prompt:await (0,l.bX)(c,H.join("\n")),sources:z.sources}}},78282:(a,b,c)=>{"use strict";c.d(b,{H:()=>e});var d=c(2910);let e=(0,d.createServerReference)("4098f6bc6c8bcf5e0704daf3a5a7bab7ffa82a196c",d.callServer,void 0,d.findSourceMapURL,"clearConversation")},79505:(a,b,c)=>{"use strict";c.d(b,{I:()=>l,k:()=>m});var d=c(6866),e=c(77598),f=c(97603),g=c(95357),h=c(65705),i=c(1890),j=c(53993),k=c(33644);async function l(a,b){await h.db.insert(i.event).values({id:(0,e.randomUUID)(),workspaceId:a,runId:b.runId,channel:b.channel??"room",agentId:b.agentId??null,seq:Date.now(),kind:b.kind,target:(b.target??"").slice(0,500),detail:(b.detail??"").slice(0,8e3)}),(0,k.r)(a)}async function m(a,b=0){let{workspace:c}=await (0,j.nP)();return h.db.select().from(i.event).where((0,f.Uo)((0,f.eq)(i.event.workspaceId,c.id),(0,f.eq)(i.event.channel,a),(0,f.gt)(i.event.seq,b))).orderBy((0,g.Y)(i.event.seq)).limit(300)}(0,c(74252).D)([l,m]),(0,d.A)(l,"60c1724f6f00fd2d33760b52f4dde31de692d1b203",null),(0,d.A)(m,"6089bcc5361f39d22c01d6f92038ab1a71d519835f",null)},81204:(a,b,c)=>{"use strict";c.d(b,{nK:()=>k,hA:()=>l});var d=c(37067),e=c.n(d),f=c(77030),g=c.n(f);let h=`(function(){
367
+ ${a.body}`,c=(0,m.b)(b);I+c>t||(H.push(b),I+=c)}return{prompt:await (0,l.bX)(c,H.join("\n")),sources:z.sources}}},79505:(a,b,c)=>{"use strict";c.d(b,{I:()=>l,k:()=>m});var d=c(6866),e=c(77598),f=c(97603),g=c(95357),h=c(65705),i=c(1890),j=c(53993),k=c(33644);async function l(a,b){await h.db.insert(i.event).values({id:(0,e.randomUUID)(),workspaceId:a,runId:b.runId,channel:b.channel??"room",agentId:b.agentId??null,seq:Date.now(),kind:b.kind,target:(b.target??"").slice(0,500),detail:(b.detail??"").slice(0,8e3)}),(0,k.r)(a)}async function m(a,b=0){let{workspace:c}=await (0,j.nP)();return h.db.select().from(i.event).where((0,f.Uo)((0,f.eq)(i.event.workspaceId,c.id),(0,f.eq)(i.event.channel,a),(0,f.gt)(i.event.seq,b))).orderBy((0,g.Y)(i.event.seq)).limit(300)}(0,c(74252).D)([l,m]),(0,d.A)(l,"60dbdf46cddec83114ce6551fd870fa84f68016765",null),(0,d.A)(m,"60274f514b61483b6e070a65f4817ee1ad9fe43504",null)},81204:(a,b,c)=>{"use strict";c.d(b,{nK:()=>k,hA:()=>l});var d=c(37067),e=c.n(d),f=c(77030),g=c.n(f);let h=`(function(){
368
368
  if(window.__cstlaLiveLoaded) return; window.__cstlaLiveLoaded = true;
369
369
  var MODE = "off"; // "off" (inert) | "inspect" (highlight + click-to-select)
370
370
  function post(type, payload){ try{ parent.postMessage({ __cstlaLive:1, type:type, payload:payload }, "*"); }catch(e){} }
@@ -414,4 +414,4 @@ ${a.body}`,c=(0,m.b)(b);I+c>t||(H.push(b),I+=c)}return{prompt:await (0,l.bX)(c,H
414
414
  });
415
415
 
416
416
  post("live:ready", { path: (location.pathname||"/")+(location.search||"") });
417
- })();`,i=new Map,j=`<script data-cstla-live-instrument>${h}</script>`;async function k(a,b){let c,d,f,h=i.get(a);if(h&&h.devUrl===b&&h.server.listening)return{url:`http://127.0.0.1:${h.port}`,port:h.port};if(h){try{h.server.close()}catch{}i.delete(a)}try{let a=new URL(b);c=a.hostname,d=Number(a.port)||("https:"===a.protocol?443:80)}catch{return null}let k=e().createServer((a,b)=>{let f={...a.headers};delete f["accept-encoding"],f.host=`${c}:${d}`;let g=e().request({host:c,port:d,method:a.method,path:a.url,headers:f},a=>{let c=String(a.headers["content-type"]||"");if(/text\/html/i.test(c)){let c=[];a.on("data",a=>c.push(a)),a.on("end",()=>{var d;let e=(d=Buffer.concat(c).toString("utf8"),/<\/body>/i.test(d)?d.replace(/<\/body>/i,`${j}</body>`):d+j),f={...a.headers};delete f["content-length"],delete f["content-encoding"],delete f["transfer-encoding"];try{b.writeHead(a.statusCode||200,f),b.end(e)}catch{}}),a.on("error",()=>{try{b.destroy()}catch{}})}else{try{b.writeHead(a.statusCode||200,a.headers)}catch{}a.pipe(b)}});g.on("error",()=>{try{b.writeHead(502),b.end("inspect proxy: upstream error")}catch{}}),a.pipe(g)});k.on("upgrade",(a,b,e)=>{let f=g().connect(d,c,()=>{let c=[`${a.method} ${a.url} HTTP/1.1`];for(let[b,d]of Object.entries(a.headers))if(null!=d)if(Array.isArray(d))for(let a of d)c.push(`${b}: ${a}`);else c.push(`${b}: ${d}`);f.write(c.join("\r\n")+"\r\n\r\n"),e&&e.length&&f.write(e),f.pipe(b),b.pipe(f)});f.on("error",()=>{try{b.destroy()}catch{}}),b.on("error",()=>{try{f.destroy()}catch{}})});try{f=await function(a=5100,b=5400){return new Promise((c,d)=>{let e=a=>{if(a>b)return d(Error("no free port"));let f=g().createServer();f.once("error",()=>e(a+1)),f.once("listening",()=>f.close(()=>c(a))),f.listen(a,"127.0.0.1")};e(a)})}()}catch{return null}try{await new Promise((a,b)=>{k.once("error",b),k.listen(f,"127.0.0.1",()=>{k.removeListener("error",b),a()})})}catch{return null}return i.set(a,{server:k,port:f,devUrl:b,host:c,tport:d}),{url:`http://127.0.0.1:${f}`,port:f}}function l(a){let b=i.get(a);if(b){try{b.server.close()}catch{}i.delete(a)}}},83836:(a,b,c)=>{"use strict";c.d(b,{e:()=>d});let d=[{id:"home",title:"Home",href:"/",group:"Cockpit",tile:"Welcome — canonical knowledge & quick navigation",icon:"grid"},{id:"dashboard",title:"Dashboard",href:"/dashboard",group:"Cockpit",tile:"Cockpit hub — status at a glance",icon:"pulse"},{id:"organizations",title:"Organizations",href:"/organizations",group:"Hierarchy",tile:"Manage organizations & workspaces",icon:"grid"},{id:"org",title:"Org Chart",href:"/org",group:"Hierarchy",tile:"Hierarchy & delegation",icon:"agents"},{id:"agents",title:"Agent Studio",href:"/agents/ada",group:"Hierarchy",tile:"Configure each agent",icon:"bot"},{id:"code",title:"Code",href:"/code",group:"Execution",tile:"Code editor & repo files",icon:"terminal"},{id:"tasks",title:"Tasks",href:"/tasks",group:"Execution",tile:"Team kanban board",icon:"files"},{id:"cron",title:"Cron",href:"/cron",group:"Execution",tile:"Scheduled tasks & history",icon:"calendar"},{id:"routines",title:"Routines",href:"/routines",group:"Execution",tile:"Recurring automations",icon:"repeat"},{id:"goals",title:"Goals",href:"/goals",group:"Execution",tile:"Objective tree",icon:"target"},{id:"design",title:"Design",href:"/design",group:"Execution",tile:"Prototype the UI with the frontend agent before the plan",icon:"grid"},{id:"planner",title:"CEO Planner",href:"/planner",group:"Execution",tile:"Specs → issues → approval → 24/7",icon:"command"},{id:"test-dev",title:"Test Dev",href:"/test-dev",group:"Execution",tile:"Boot, navigate + validate the project",icon:"play"},{id:"pm",title:"Product Manager",href:"/pm",group:"Product",tile:"Sprints & backlog (PO)",icon:"goto"},{id:"reports",title:"Reports",href:"/reports",group:"Knowledge",tile:"Plans, reviews, audits",icon:"doc"},{id:"docs",title:"Docs",href:"/docs",group:"Knowledge",tile:"Architecture, API & PO docs",icon:"doc"},{id:"skills",title:"Skills",href:"/skills",group:"Knowledge",tile:"Agent procedure library",icon:"skill"},{id:"activity",title:"Activity",href:"/activity",group:"Knowledge",tile:"Agent action timeline",icon:"pulse"},{id:"knowledge",title:"Knowledge",href:"/knowledge",group:"Knowledge",tile:"KB index, coverage, gaps & agent recall",icon:"branch"},{id:"costs",title:"Costs",href:"/costs",group:"Operations",tile:"Spend by agent/provider",icon:"coins"},{id:"security",title:"Security",href:"/security",group:"Operations",tile:"Findings & security score",icon:"shield"},{id:"pulse",title:"Pulse",href:"/pulse",group:"Operations",tile:"Agent health & validation",icon:"pulse"},{id:"github",title:"Commit GitHub",href:"/github",group:"Operations",tile:"Push workspace to remote",icon:"git"},{id:"prepare-deploy",title:"Prepare Deploy",href:"/prepare-deploy",group:"Operations",tile:"Prod-prep + export clean source to a deploy repo",icon:"goto"},{id:"models",title:"Models",href:"/models",group:"Operations",tile:"Providers & local models",icon:"cpu"},{id:"update",title:"Update",href:"/update",group:"Operations",tile:"Detect & apply new versions",icon:"goto"},{id:"plugins",title:"Plugins",href:"/plugins",group:"Operations",tile:"Extensions & integrations",icon:"ext"},{id:"inbox",title:"Inbox",href:"/inbox",group:"Inbox",tile:"Approvals & escalations",icon:"inbox"},{id:"notifications",title:"Notifications",href:"/notifications",group:"Inbox",tile:"Passive alert feed",icon:"bell"},{id:"config",title:"Config",href:"/config",group:"System",tile:"Platform settings",icon:"settings"},{id:"profile",title:"Profile",href:"/profile",group:"System",tile:"Account & preferences",icon:"account"}]},83963:(a,b,c)=>{"use strict";c.d(b,{l:()=>z,g:()=>y});var d=c(57086),e=c(6866),f=c(77598),g=c(97603),h=c(31371),i=c(65705),j=c(1890),k=c(53993),l=c(57300);function m(a,b){let c=RegExp(`##\\s+${b}\\s*\\n([\\s\\S]*?)(?:\\n##\\s|$)`,"i");return a.match(c)?.[1].trim()??""}function n(a){return a.split("\n").find(a=>a.trim()&&!a.startsWith("#")&&!a.startsWith("**")&&!a.startsWith("---")&&!a.startsWith("|"))?.trim()??""}function o(a,b){let c=a.split("\n").find(a=>a.startsWith("# "));return c?c.slice(2).trim():b}async function p(a){let[b]=await i.db.select().from(j.workspace).where((0,g.eq)(j.workspace.orgId,a));return b??null}async function q(a,b,c){let e=(0,d.sL)(b,`.claude/skills/${c}.md`)??"",h=n(e),k=(e.match(/\*\*Trigger:\*\*\s*(.+)/)?.[1]??"").trim(),l=m(e,"Procedure")||"",[o]=await i.db.select().from(j.skill).where((0,g.Uo)((0,g.eq)(j.skill.workspaceId,a),(0,g.eq)(j.skill.name,c)));o?await i.db.update(j.skill).set({summary:h,trigger:k,...l?{instructions:l}:{},indexed:"indexed"}).where((0,g.eq)(j.skill.id,o.id)):await i.db.insert(j.skill).values({id:(0,f.randomUUID)(),workspaceId:a,name:c,summary:h,trigger:k,instructions:l,native:!0,provisional:!1,indexed:"indexed"})}async function r(a,b,c){let e=(0,d.sL)(b,`.claude/agents/${c}/Agent.md`)??"";if(!e)return;let[f]=await i.db.select().from(j.agent).where((0,g.Uo)((0,g.eq)(j.agent.workspaceId,a),(0,g.eq)(j.agent.handle,c)));if(!f)return;let h=function(a){let b=a.match(/^---\n([\s\S]*?)\n---/);if(!b)return{};let c={};for(let a of b[1].split("\n")){let b=a.indexOf(":");b>0&&(c[a.slice(0,b).trim()]=a.slice(b+1).trim())}return c}(e),k={identity:(e.match(/\*\*Identity:\*\*\s*(.+)/)?.[1]??"").trim(),ritual:(e.match(/\*\*Ritual:\*\*\s*(.+)/)?.[1]??"").trim(),tone:(e.match(/\*\*Tone:\*\*\s*(.+)/)?.[1]??"").trim()||(f.persona?.tone??""),systemPrompt:m(e,"System prompt")},l={...h.provider?{adapter:h.provider}:{},...h.model?{model:h.model}:{},...h.temperature?{temperature:parseFloat(h.temperature)}:{},...h.dailyCapUsd?{dailyCapUsd:parseFloat(h.dailyCapUsd)}:{},...h.tierFloor?{tierFloor:h.tierFloor}:{},...h.reportsTo&&"null"!==h.reportsTo?{reportsTo:h.reportsTo}:{},persona:k};for(let e of(await i.db.update(j.agent).set(l).where((0,g.eq)(j.agent.id,f.id)),[...((0,d.sL)(b,`.claude/agents/${c}/skills.md`)??"").matchAll(/`([a-z0-9-]+)`/g)].map(a=>a[1]))){let[b]=await i.db.select().from(j.skill).where((0,g.Uo)((0,g.eq)(j.skill.workspaceId,a),(0,g.eq)(j.skill.name,e)));b&&await i.db.insert(j.agentSkill).values({agentId:f.id,skillId:b.id}).onConflictDoNothing()}}async function s(a,b,c){let e=c.split("/").pop()??c;if("README.md"===e)return;let h=(0,d.sL)(b,c)??"",k=o(h,e),[l]=await i.db.select().from(j.report).where((0,g.Uo)((0,g.eq)(j.report.workspaceId,a),(0,g.eq)(j.report.title,k)));l?await i.db.update(j.report).set({body:h}).where((0,g.eq)(j.report.id,l.id)):await i.db.insert(j.report).values({id:(0,f.randomUUID)(),workspaceId:a,title:k,type:"Report",body:h})}async function t(a,b,c,e){let h=(0,d.sL)(b,c)??"",k=o(h,c.split("/").pop()??c),l=n(h),[m]=await i.db.select().from(j.docIndex).where((0,g.Uo)((0,g.eq)(j.docIndex.workspaceId,a),(0,g.eq)(j.docIndex.path,c)));m?await i.db.update(j.docIndex).set({title:k,summary:l,updatedAt:new Date}).where((0,g.eq)(j.docIndex.id,m.id)):await i.db.insert(j.docIndex).values({id:(0,f.randomUUID)(),workspaceId:a,kind:e,path:c,title:k,summary:l})}function u(a){(a.startsWith(".claude/skills")||a.endsWith("/skills.md"))&&(0,h.revalidatePath)("/skills"),a.startsWith(".claude/agents")&&(0,h.revalidatePath)("/agents/[handle]","page"),a.startsWith("DOCS")&&(0,h.revalidatePath)("/docs"),a.startsWith("PO")&&(0,h.revalidatePath)("/pm"),a.startsWith("Reports")&&(0,h.revalidatePath)("/reports"),(0,h.revalidatePath)("/code")}async function v(a,b,c=!0){let d,e=await p(a);if(!e)return{ok:!1};let f=e.id;if((0,l.Nm)(a,b),d=b.match(/^\.claude\/skills\/(.+)\.md$/))await q(f,a,d[1]);else if(d=b.match(/^\.claude\/agents\/([^/]+)\/(?:Agent|skills)\.md$/))await r(f,a,d[1]);else if(/^Reports\/.+\.md$/.test(b))await s(f,a,b);else if(/^DOCS\/.+\.md$/.test(b))await t(f,a,b,"docs");else{if(!/^PO\/.+\.md$/.test(b))return{ok:!0};await t(f,a,b,"po")}return c&&u(b),{ok:!0}}async function w(a,b){let c,d=await p(a);if(!d)return{ok:!1};let e=d.id;return(0,l.SH)(a,b).catch(()=>{}),(c=b.match(/^\.claude\/skills\/(.+)\.md$/))?await i.db.delete(j.skill).where((0,g.Uo)((0,g.eq)(j.skill.workspaceId,e),(0,g.eq)(j.skill.name,c[1]))):/^(?:DOCS|PO)\/.+\.md$/.test(b)&&await i.db.delete(j.docIndex).where((0,g.Uo)((0,g.eq)(j.docIndex.workspaceId,e),(0,g.eq)(j.docIndex.path,b))),u(b),{ok:!0}}async function x(a=!0){let{org:b}=await (0,k.nP)(),c=b.id;for(let a of(0,d.Ci)(c,".claude/skills"))!a.isDir&&a.name.endsWith(".md")&&await v(c,a.path,!1);for(let a of(0,d.Ci)(c,".claude/agents"))a.isDir&&await v(c,`${a.path}/Agent.md`,!1);for(let a of["DOCS","PO","Reports"])for(let b of(0,d.Ci)(c,a))!b.isDir&&b.name.endsWith(".md")&&await v(c,b.path,!1);return a&&(0,h.revalidatePath)("/","layout"),{ok:!0}}async function y(a,b,c){(0,d.dx)(a,b,c),await v(a,b)}async function z(a,b){(0,d.EX)(a,b),await w(a,b)}(0,c(74252).D)([v,w,x]),(0,e.A)(v,"70b0b82ea9214047eb4e73b585747b125fcb19b83c",null),(0,e.A)(w,"605e93011b17ee708d84a82a6d3a495fedcb831dd8",null),(0,e.A)(x,"40768eae7836f81f32aeddd76337123f449ddf99d6",null)},84903:(a,b,c)=>{"use strict";c.d(b,{j:()=>i});var d=c(77598),e=c(97603),f=c(65705),g=c(1890),h=c(56338);async function i(a,b){if(b.text.trim()){try{await f.db.insert(g.decision).values({id:(0,d.randomUUID)(),workspaceId:a,text:b.text.slice(0,1e3),by:b.by??"",source:b.source??"",refKey:b.refKey??"",rationale:b.rationale??"",goalId:b.goalId??null,createdAt:new Date})}catch(a){console.error("[decision] log failed:",a)}(async()=>{try{let[c]=await f.db.select({orgId:g.workspace.orgId}).from(g.workspace).where((0,e.eq)(g.workspace.id,a));c?.orgId&&await (0,h.ru)(c.orgId,[{type:"decision",title:b.text.slice(0,120),summary:b.text.slice(0,1e3),body:b.rationale??"",goalId:b.goalId??null,agentHandle:b.by??"",sourceKind:"decision",sourceRef:b.refKey??""}])}catch{}})()}}},93209:(a,b,c)=>{"use strict";c.d(b,{BackButton:()=>h});var d=c(4374),e=c(47104),f=c(43526),g=c(31819);function h(){let a=(0,g.k)(),b=(0,e.useRouter)();return(0,d.jsx)("button",{className:"top-btn",title:a("common.back"),style:{marginRight:2},onClick:()=>{b.push("/")},children:(0,d.jsx)(f.I,{name:"chevronLeft",size:18})})}},94496:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>n});var d=c(61576),e=c(1782),f=c(80280),g=c(25533),h=c(95896),i=c(64557),j=c(51203),k=c(24960),l=c(28018),m=c(18773);async function n({children:a}){let{session:b,org:c,workspace:o}=await (0,h.nP)(),[p,q,r,s,t,u]=await Promise.all([f.db.select().from(g.agent).where((0,e.eq)(g.agent.workspaceId,o.id)),(0,h.O5)(b.user.id),f.db.select().from(g.inboxItem).where((0,e.Uo)((0,e.eq)(g.inboxItem.workspaceId,o.id),(0,e.eq)(g.inboxItem.resolved,!1))),f.db.select().from(g.notification).where((0,e.Uo)((0,e.eq)(g.notification.workspaceId,o.id),(0,e.eq)(g.notification.read,!1))),f.db.select().from(g.plan).where((0,e.eq)(g.plan.workspaceId,o.id)),f.db.select({image:g.user.image}).from(g.user).where((0,e.eq)(g.user.id,b.user.id))]),v=t[0],w=u[0]?.image??null;return(0,d.jsxs)("div",{className:"app",children:[(0,d.jsx)(i.Sidebar,{orgs:q,currentOrgId:c.id,workspaceSlug:o.slug,userName:b.user.name,userEmail:b.user.email,userImage:w,inboxCount:r.length,notifCount:s.length}),(0,d.jsx)("main",{className:"app-main",children:a}),(0,d.jsx)(j.ChatDockGate,{agents:p.map(a=>({id:a.id,handle:a.handle,name:a.name,role:a.role,color:a.color,image:a.image,adapter:a.adapter,status:a.status,health:a.health})),operator:{name:b.user.name,image:w}}),(0,d.jsx)(k.RunnerHeartbeat,{approved:!!v?.approved,auto247:!!v?.auto247}),(0,d.jsx)(l.SearchHotkey,{}),(0,d.jsx)(m.Toaster,{})]})}},95896:(a,b,c)=>{"use strict";c.d(b,{$x:()=>k,Ht:()=>j,K4:()=>l,O5:()=>m,nP:()=>n});var d=c(79676),e=c(17971),f=c(1782),g=c(80280),h=c(25533),i=c(51063);async function j(){return i.j2.api.getSession({headers:await (0,d.headers)()})}async function k(a,b){if(b){let[c]=await g.db.select({org:h.organization}).from(h.member).innerJoin(h.organization,(0,f.eq)(h.member.orgId,h.organization.id)).where((0,f.Uo)((0,f.eq)(h.member.userId,a),(0,f.eq)(h.organization.id,b)));if(c)return c.org}let c=await g.db.select({org:h.organization}).from(h.member).innerJoin(h.organization,(0,f.eq)(h.member.orgId,h.organization.id)).where((0,f.eq)(h.member.userId,a));return c[0]?.org??null}async function l(a){let[b]=await g.db.select().from(h.workspace).where((0,f.eq)(h.workspace.orgId,a));return b??null}async function m(a){return g.db.select({id:h.organization.id,name:h.organization.name}).from(h.member).innerJoin(h.organization,(0,f.eq)(h.member.orgId,h.organization.id)).where((0,f.eq)(h.member.userId,a))}async function n(){let a=await j();a||(0,e.redirect)("/login"),"1"===process.env.CONSTELLA_FORCE_ONBOARDING&&(0,e.redirect)("/onboarding");let b=await k(a.user.id,a.session.activeOrgId);b||(0,e.redirect)("/onboarding");let c=await l(b.id);return c||(0,e.redirect)("/onboarding"),{session:a,org:b,workspace:c}}},97140:(a,b,c)=>{"use strict";c.d(b,{Fu:()=>D,GW:()=>A,H7:()=>y,ME:()=>E,VL:()=>z,Wu:()=>w,_z:()=>t,bt:()=>F,gg:()=>v,jw:()=>B,n4:()=>u,rd:()=>x,rm:()=>C,xU:()=>s});var d=c(6866),e=c(77598),f=c(97603),g=c(95357),h=c(31371),i=c(65705),j=c(1890),k=c(53993),l=c(71352),m=c(36250),n=c(84903),o=c(33644),p=c(57300),q=c(56338),r=c(45125);async function s(){let{workspace:a}=await (0,k.nP)(),[b,c,d]=await Promise.all([i.db.select({id:j.goal.id,title:j.goal.title}).from(j.goal).where((0,f.Uo)((0,f.eq)(j.goal.workspaceId,a.id),(0,f.eq)(j.goal.status,"active"))),i.db.select({id:j.spec.id,key:j.spec.key,title:j.spec.title}).from(j.spec).where((0,f.Uo)((0,f.eq)(j.spec.workspaceId,a.id),(0,f.eq)(j.spec.status,"active"))),i.db.select({id:j.issue.id,key:j.issue.key,title:j.issue.title}).from(j.issue).where((0,f.eq)(j.issue.workspaceId,a.id))]),e=a=>a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,24)||"goal",g=[];for(let a of b.slice(0,60))g.push({kind:"goal",key:e(a.title),title:a.title,id:a.id});for(let a of c.slice(0,80))g.push({kind:"spec",key:a.key,title:a.title,id:a.id});for(let a of d.slice(0,150))g.push({kind:"issue",key:a.key,title:a.title,id:a.id});return g}async function t(a,b,d){let{org:g,workspace:l}=await (0,k.nP)(),m=await i.db.select().from(j.agent).where((0,f.eq)(j.agent.workspaceId,l.id)),q=new Set(m.map(a=>a.handle)),s=(b??"").trim();if(s.startsWith("/")&&"telegram"!==a){let{runSlashCommand:b}=await Promise.all([c.e(9783),c.e(4979)]).then(c.bind(c,84979)),d=await b(g.id,l.id,m,a,s);if(d.handled)return(0,h.revalidatePath)("/","layout"),{responders:d.responders}}let t=[];if(a.startsWith("dm:")){let b=a.slice(3);q.has(b)&&(t=[b])}else if("telegram"===a)t=q.has("ada")?["ada"]:m.slice(0,1).map(a=>a.handle);else if(0===(t=[...b.matchAll(/@([a-z0-9-]+)/gi)].map(a=>a[1].toLowerCase()).filter(a=>q.has(a)).slice(0,3)).length)return{responders:[]};let u=await (0,r.xF)(l.id,a);return await i.db.insert(j.message).values({id:(0,e.randomUUID)(),workspaceId:l.id,channel:a,fromKind:"operator",text:b,attachments:d?.length?d.slice(0,10):null,sessionId:u}),(0,o.r)(l.id),(0,p.PD)(l.orgId),"room"===a&&b.trim().length>=15&&await (0,n.j)(l.id,{text:b.slice(0,400),by:"operator",source:"operator-instruction"}),(0,h.revalidatePath)("/","layout"),{responders:t}}async function u(a,b){let{org:d,workspace:g}=await (0,k.nP)(),[n]=await i.db.select().from(j.agent).where((0,f.Uo)((0,f.eq)(j.agent.workspaceId,g.id),(0,f.eq)(j.agent.handle,b)));if(!n)return;await i.db.update(j.agent).set({status:"working"}).where((0,f.eq)(j.agent.id,n.id));let{text:p,planRequested:q}=await (0,l.PM)(d.id,g,a,n,"chat");if(await i.db.update(j.agent).set({status:"idle"}).where((0,f.eq)(j.agent.id,n.id)),"telegram"===a&&p)try{let{mirrorToTelegram:a}=await Promise.all([c.e(259),c.e(7622)]).then(c.bind(c,47622));await a(g.id,p)}catch(a){console.error("[agentRespond] telegram mirror failed:",a)}if(q)try{let b=await (0,m.planFromConversation)(a),c=b.ok?"Got it — registering this as new work. I'm drafting the plan now (specs, issues and TODOs); it'll appear in the CEO Planner for your approval, and I'll post it here when it's ready.":`I couldn't start a plan from this yet (${b.error??"no structured plan"}). Add a little more detail on what you want and I'll try again.`;await i.db.insert(j.message).values({id:(0,e.randomUUID)(),workspaceId:g.id,channel:a,fromKind:"agent",fromHandle:n.handle,text:c,createdAt:new Date,sessionId:await (0,r.xF)(g.id,a)}),(0,o.r)(g.id)}catch(a){console.error("[agentRespond] new-work planning failed:",a)}a.startsWith("dm:")||await (0,l.YK)(d.id,g,b,p,0),(0,h.revalidatePath)("/","layout")}async function v(a){let{org:b,workspace:c}=await (0,k.nP)(),[d]=await i.db.select().from(j.message).where((0,f.Uo)((0,f.eq)(j.message.workspaceId,c.id),(0,f.eq)(j.message.id,a)));return d&&d.text?.trim()?(await (0,q.ru)(b.id,[{type:"note",title:d.text.trim().slice(0,80),summary:d.text.trim().slice(0,1200),agentHandle:d.fromHandle??"",sourceKind:"note",sourceRef:a}]),{ok:!0}):{ok:!1}}async function w(a){let{org:b}=await (0,k.nP)(),c=(a??"").trim().slice(0,500);if(!c)return{ok:!1,error:"empty"};try{let a=await (0,q.ed)(b.id,c),d=(a.text??"").trim();if("none"===a.mode||!d)return{ok:!1,error:"none"};return{ok:!0,text:d.slice(0,1200),sources:(a.sources??[]).slice(0,6)}}catch(a){return console.error("[pullKbForComposer] failed:",a),{ok:!1,error:"failed"}}}async function x(a){let b,c,{workspace:d}=await (0,k.nP)(),[e]=await i.db.select().from(j.task).where((0,f.Uo)((0,f.eq)(j.task.workspaceId,d.id),(0,f.eq)(j.task.id,a)));if(!e)return null;if(e.issueId){let[a]=await i.db.select({key:j.issue.key}).from(j.issue).where((0,f.eq)(j.issue.id,e.issueId));b=a?.key}if(e.goalId){let[a]=await i.db.select({title:j.goal.title}).from(j.goal).where((0,f.eq)(j.goal.id,e.goalId));c=a?.title}return{taskKey:e.key,issueKey:b,goalTitle:c,col:e.col}}async function y(a){let{workspace:b}=await (0,k.nP)();if(!a.startsWith("dm:")&&"telegram"!==a&&"room"!==a)return{ok:!1};if(a.startsWith("dm:")){let c=await (0,r.xF)(b.id,a);await i.db.delete(j.message).where((0,f.Uo)((0,f.eq)(j.message.workspaceId,b.id),(0,f.eq)(j.message.channel,a),(0,f.eq)(j.message.sessionId,c))),await i.db.delete(j.messageSummary).where((0,f.Uo)((0,f.eq)(j.messageSummary.workspaceId,b.id),(0,f.eq)(j.messageSummary.channel,a),(0,f.eq)(j.messageSummary.sessionId,c)))}else await i.db.delete(j.message).where((0,f.Uo)((0,f.eq)(j.message.workspaceId,b.id),(0,f.eq)(j.message.channel,a))),await i.db.delete(j.messageSummary).where((0,f.Uo)((0,f.eq)(j.messageSummary.workspaceId,b.id),(0,f.eq)(j.messageSummary.channel,a)));return await i.db.delete(j.event).where((0,f.Uo)((0,f.eq)(j.event.workspaceId,b.id),(0,f.eq)(j.event.channel,a))),(0,o.r)(b.id),(0,h.revalidatePath)("/","layout"),{ok:!0}}async function z(a){let{workspace:b}=await (0,k.nP)();if(a.startsWith("dm:")){let c=await (0,r.xF)(b.id,a);return i.db.select().from(j.message).where((0,f.Uo)((0,f.eq)(j.message.workspaceId,b.id),(0,f.eq)(j.message.channel,a),(0,f.eq)(j.message.sessionId,c))).orderBy((0,g.Y)(j.message.createdAt))}return i.db.select().from(j.message).where((0,f.Uo)((0,f.eq)(j.message.workspaceId,b.id),(0,f.eq)(j.message.channel,a))).orderBy((0,g.Y)(j.message.createdAt))}async function A(a){let{workspace:b}=await (0,k.nP)();return(0,r.X0)(b.id,a)}async function B(a,b){let{workspace:c}=await (0,k.nP)(),d=await (0,r.RL)(c.id,a,b);return(0,h.revalidatePath)("/","layout"),{id:d}}async function C(a,b){let{workspace:c}=await (0,k.nP)();return await (0,r.WU)(c.id,a,b),(0,h.revalidatePath)("/","layout"),{ok:!0}}async function D(a,b){let{workspace:c}=await (0,k.nP)();return await (0,r.Jb)(c.id,a,b),(0,h.revalidatePath)("/","layout"),{ok:!0}}async function E(a,b){let{workspace:c}=await (0,k.nP)();return await (0,r.OL)(c.id,a,b),(0,h.revalidatePath)("/","layout"),{ok:!0}}async function F(){let{workspace:a}=await (0,k.nP)(),b=await i.db.select().from(j.message).where((0,f.Uo)((0,f.eq)(j.message.workspaceId,a.id),(0,f.mj)(j.message.channel,"dm:%"))).orderBy((0,g.Y)(j.message.createdAt)),c={};for(let a of b)c[a.channel.slice(3)]={text:a.text??"",mine:"operator"===a.fromKind};return c}(0,c(74252).D)([s,t,u,v,w,x,y,z,A,B,C,D,E,F]),(0,d.A)(s,"00d423e1c54f47493dd9e26787f081501532d5754f",null),(0,d.A)(t,"700e7dc42f9902ba897ac4e36d45bfd5032bd56211",null),(0,d.A)(u,"605ee4201fe65199f85db7180e840b038e2e8ffd10",null),(0,d.A)(v,"40faf10ed1dd931e743694b6ab07acfffa9f1c5fff",null),(0,d.A)(w,"4087e6e58cd4d57932fba61705c67f27c76e9dbebb",null),(0,d.A)(x,"40dd7a9ba904e27f9eeac05cd7a750583e8de84545",null),(0,d.A)(y,"4098f6bc6c8bcf5e0704daf3a5a7bab7ffa82a196c",null),(0,d.A)(z,"406201c1d173ad16581e88feb7fdf42ebbc95ef841",null),(0,d.A)(A,"4049b65fc61de5f15ea027c832048d695017a2cadc",null),(0,d.A)(B,"60e9b223d15847a611ea2b6fdf59614eceb4151ee9",null),(0,d.A)(C,"60581df9364a1b92ebc0d853d7c78efa696792047f",null),(0,d.A)(D,"600d82e3d7031f663a63e6110ba9f565e1925bac77",null),(0,d.A)(E,"60301fe28cb811b08550b91045a0558179995780c0",null),(0,d.A)(F,"00703229b811528142c40576d5c57f3467b87b9b61",null)},98459:(a,b,c)=>{"use strict";c.r(b),c.d(b,{AnimToggle:()=>k});var d=c(4374),e=c(74679),f=c(47104),g=c(43526),h=c(31819),i=c(2910);let j=(0,i.createServerReference)("007022a76790c9702b4391280231b2e171ccb37259",i.callServer,void 0,i.findSourceMapURL,"toggleAnim");function k({labeled:a}){let b=(0,h.k)(),c=(0,f.useRouter)(),[i,l]=(0,e.useState)(!0),[m,n]=(0,e.useTransition)(),o=()=>n(async()=>{await j(),l(a=>!a),c.refresh()});return a?(0,d.jsxs)("button",{className:"btn-ghost",onClick:o,disabled:m,type:"button",style:{gap:8},children:[(0,d.jsx)(g.I,{name:"pulse",size:14,style:{opacity:i?1:.4}})," ",b("chrome.anim.label",{state:b(i?"common.on":"common.off")})]}):(0,d.jsx)("button",{className:"top-btn",onClick:o,disabled:m,type:"button",title:b(i?"chrome.anim.titleOn":"chrome.anim.titleOff"),children:(0,d.jsx)(g.I,{name:"pulse",size:17,style:{opacity:i?1:.4}})})}}};
417
+ })();`,i=new Map,j=`<script data-cstla-live-instrument>${h}</script>`;async function k(a,b){let c,d,f,h=i.get(a);if(h&&h.devUrl===b&&h.server.listening)return{url:`http://127.0.0.1:${h.port}`,port:h.port};if(h){try{h.server.close()}catch{}i.delete(a)}try{let a=new URL(b);c=a.hostname,d=Number(a.port)||("https:"===a.protocol?443:80)}catch{return null}let k=e().createServer((a,b)=>{let f={...a.headers};delete f["accept-encoding"],f.host=`${c}:${d}`;let g=e().request({host:c,port:d,method:a.method,path:a.url,headers:f},a=>{let c=String(a.headers["content-type"]||"");if(/text\/html/i.test(c)){let c=[];a.on("data",a=>c.push(a)),a.on("end",()=>{var d;let e=(d=Buffer.concat(c).toString("utf8"),/<\/body>/i.test(d)?d.replace(/<\/body>/i,`${j}</body>`):d+j),f={...a.headers};delete f["content-length"],delete f["content-encoding"],delete f["transfer-encoding"];try{b.writeHead(a.statusCode||200,f),b.end(e)}catch{}}),a.on("error",()=>{try{b.destroy()}catch{}})}else{try{b.writeHead(a.statusCode||200,a.headers)}catch{}a.pipe(b)}});g.on("error",()=>{try{b.writeHead(502),b.end("inspect proxy: upstream error")}catch{}}),a.pipe(g)});k.on("upgrade",(a,b,e)=>{let f=g().connect(d,c,()=>{let c=[`${a.method} ${a.url} HTTP/1.1`];for(let[b,d]of Object.entries(a.headers))if(null!=d)if(Array.isArray(d))for(let a of d)c.push(`${b}: ${a}`);else c.push(`${b}: ${d}`);f.write(c.join("\r\n")+"\r\n\r\n"),e&&e.length&&f.write(e),f.pipe(b),b.pipe(f)});f.on("error",()=>{try{b.destroy()}catch{}}),b.on("error",()=>{try{f.destroy()}catch{}})});try{f=await function(a=5100,b=5400){return new Promise((c,d)=>{let e=a=>{if(a>b)return d(Error("no free port"));let f=g().createServer();f.once("error",()=>e(a+1)),f.once("listening",()=>f.close(()=>c(a))),f.listen(a,"127.0.0.1")};e(a)})}()}catch{return null}try{await new Promise((a,b)=>{k.once("error",b),k.listen(f,"127.0.0.1",()=>{k.removeListener("error",b),a()})})}catch{return null}return i.set(a,{server:k,port:f,devUrl:b,host:c,tport:d}),{url:`http://127.0.0.1:${f}`,port:f}}function l(a){let b=i.get(a);if(b){try{b.server.close()}catch{}i.delete(a)}}},83836:(a,b,c)=>{"use strict";c.d(b,{e:()=>d});let d=[{id:"home",title:"Home",href:"/",group:"Cockpit",tile:"Welcome — canonical knowledge & quick navigation",icon:"grid"},{id:"dashboard",title:"Dashboard",href:"/dashboard",group:"Cockpit",tile:"Cockpit hub — status at a glance",icon:"pulse"},{id:"organizations",title:"Organizations",href:"/organizations",group:"Hierarchy",tile:"Manage organizations & workspaces",icon:"grid"},{id:"org",title:"Org Chart",href:"/org",group:"Hierarchy",tile:"Hierarchy & delegation",icon:"agents"},{id:"agents",title:"Agent Studio",href:"/agents/ada",group:"Hierarchy",tile:"Configure each agent",icon:"bot"},{id:"code",title:"Code",href:"/code",group:"Execution",tile:"Code editor & repo files",icon:"terminal"},{id:"tasks",title:"Tasks",href:"/tasks",group:"Execution",tile:"Team kanban board",icon:"files"},{id:"cron",title:"Cron",href:"/cron",group:"Execution",tile:"Scheduled tasks & history",icon:"calendar"},{id:"routines",title:"Routines",href:"/routines",group:"Execution",tile:"Recurring automations",icon:"repeat"},{id:"goals",title:"Goals",href:"/goals",group:"Execution",tile:"Objective tree",icon:"target"},{id:"design",title:"Design",href:"/design",group:"Execution",tile:"Prototype the UI with the frontend agent before the plan",icon:"grid"},{id:"planner",title:"CEO Planner",href:"/planner",group:"Execution",tile:"Specs → issues → approval → 24/7",icon:"command"},{id:"test-dev",title:"Test Dev",href:"/test-dev",group:"Execution",tile:"Boot, navigate + validate the project",icon:"play"},{id:"pm",title:"Product Manager",href:"/pm",group:"Product",tile:"Sprints & backlog (PO)",icon:"goto"},{id:"reports",title:"Reports",href:"/reports",group:"Knowledge",tile:"Plans, reviews, audits",icon:"doc"},{id:"docs",title:"Docs",href:"/docs",group:"Knowledge",tile:"Architecture, API & PO docs",icon:"doc"},{id:"skills",title:"Skills",href:"/skills",group:"Knowledge",tile:"Agent procedure library",icon:"skill"},{id:"activity",title:"Activity",href:"/activity",group:"Knowledge",tile:"Agent action timeline",icon:"pulse"},{id:"knowledge",title:"Knowledge",href:"/knowledge",group:"Knowledge",tile:"KB index, coverage, gaps & agent recall",icon:"branch"},{id:"costs",title:"Costs",href:"/costs",group:"Operations",tile:"Spend by agent/provider",icon:"coins"},{id:"security",title:"Security",href:"/security",group:"Operations",tile:"Findings & security score",icon:"shield"},{id:"pulse",title:"Pulse",href:"/pulse",group:"Operations",tile:"Agent health & validation",icon:"pulse"},{id:"github",title:"Commit GitHub",href:"/github",group:"Operations",tile:"Push workspace to remote",icon:"git"},{id:"prepare-deploy",title:"Prepare Deploy",href:"/prepare-deploy",group:"Operations",tile:"Prod-prep + export clean source to a deploy repo",icon:"goto"},{id:"models",title:"Models",href:"/models",group:"Operations",tile:"Providers & local models",icon:"cpu"},{id:"update",title:"Update",href:"/update",group:"Operations",tile:"Detect & apply new versions",icon:"goto"},{id:"plugins",title:"Plugins",href:"/plugins",group:"Operations",tile:"Extensions & integrations",icon:"ext"},{id:"inbox",title:"Inbox",href:"/inbox",group:"Inbox",tile:"Approvals & escalations",icon:"inbox"},{id:"notifications",title:"Notifications",href:"/notifications",group:"Inbox",tile:"Passive alert feed",icon:"bell"},{id:"config",title:"Config",href:"/config",group:"System",tile:"Platform settings",icon:"settings"},{id:"profile",title:"Profile",href:"/profile",group:"System",tile:"Account & preferences",icon:"account"}]},83963:(a,b,c)=>{"use strict";c.d(b,{l:()=>z,g:()=>y});var d=c(57086),e=c(6866),f=c(77598),g=c(97603),h=c(31371),i=c(65705),j=c(1890),k=c(53993),l=c(57300);function m(a,b){let c=RegExp(`##\\s+${b}\\s*\\n([\\s\\S]*?)(?:\\n##\\s|$)`,"i");return a.match(c)?.[1].trim()??""}function n(a){return a.split("\n").find(a=>a.trim()&&!a.startsWith("#")&&!a.startsWith("**")&&!a.startsWith("---")&&!a.startsWith("|"))?.trim()??""}function o(a,b){let c=a.split("\n").find(a=>a.startsWith("# "));return c?c.slice(2).trim():b}async function p(a){let[b]=await i.db.select().from(j.workspace).where((0,g.eq)(j.workspace.orgId,a));return b??null}async function q(a,b,c){let e=(0,d.sL)(b,`.claude/skills/${c}.md`)??"",h=n(e),k=(e.match(/\*\*Trigger:\*\*\s*(.+)/)?.[1]??"").trim(),l=m(e,"Procedure")||"",[o]=await i.db.select().from(j.skill).where((0,g.Uo)((0,g.eq)(j.skill.workspaceId,a),(0,g.eq)(j.skill.name,c)));o?await i.db.update(j.skill).set({summary:h,trigger:k,...l?{instructions:l}:{},indexed:"indexed"}).where((0,g.eq)(j.skill.id,o.id)):await i.db.insert(j.skill).values({id:(0,f.randomUUID)(),workspaceId:a,name:c,summary:h,trigger:k,instructions:l,native:!0,provisional:!1,indexed:"indexed"})}async function r(a,b,c){let e=(0,d.sL)(b,`.claude/agents/${c}/Agent.md`)??"";if(!e)return;let[f]=await i.db.select().from(j.agent).where((0,g.Uo)((0,g.eq)(j.agent.workspaceId,a),(0,g.eq)(j.agent.handle,c)));if(!f)return;let h=function(a){let b=a.match(/^---\n([\s\S]*?)\n---/);if(!b)return{};let c={};for(let a of b[1].split("\n")){let b=a.indexOf(":");b>0&&(c[a.slice(0,b).trim()]=a.slice(b+1).trim())}return c}(e),k={identity:(e.match(/\*\*Identity:\*\*\s*(.+)/)?.[1]??"").trim(),ritual:(e.match(/\*\*Ritual:\*\*\s*(.+)/)?.[1]??"").trim(),tone:(e.match(/\*\*Tone:\*\*\s*(.+)/)?.[1]??"").trim()||(f.persona?.tone??""),systemPrompt:m(e,"System prompt")},l={...h.provider?{adapter:h.provider}:{},...h.model?{model:h.model}:{},...h.temperature?{temperature:parseFloat(h.temperature)}:{},...h.dailyCapUsd?{dailyCapUsd:parseFloat(h.dailyCapUsd)}:{},...h.tierFloor?{tierFloor:h.tierFloor}:{},...h.reportsTo&&"null"!==h.reportsTo?{reportsTo:h.reportsTo}:{},persona:k};for(let e of(await i.db.update(j.agent).set(l).where((0,g.eq)(j.agent.id,f.id)),[...((0,d.sL)(b,`.claude/agents/${c}/skills.md`)??"").matchAll(/`([a-z0-9-]+)`/g)].map(a=>a[1]))){let[b]=await i.db.select().from(j.skill).where((0,g.Uo)((0,g.eq)(j.skill.workspaceId,a),(0,g.eq)(j.skill.name,e)));b&&await i.db.insert(j.agentSkill).values({agentId:f.id,skillId:b.id}).onConflictDoNothing()}}async function s(a,b,c){let e=c.split("/").pop()??c;if("README.md"===e)return;let h=(0,d.sL)(b,c)??"",k=o(h,e),[l]=await i.db.select().from(j.report).where((0,g.Uo)((0,g.eq)(j.report.workspaceId,a),(0,g.eq)(j.report.title,k)));l?await i.db.update(j.report).set({body:h}).where((0,g.eq)(j.report.id,l.id)):await i.db.insert(j.report).values({id:(0,f.randomUUID)(),workspaceId:a,title:k,type:"Report",body:h})}async function t(a,b,c,e){let h=(0,d.sL)(b,c)??"",k=o(h,c.split("/").pop()??c),l=n(h),[m]=await i.db.select().from(j.docIndex).where((0,g.Uo)((0,g.eq)(j.docIndex.workspaceId,a),(0,g.eq)(j.docIndex.path,c)));m?await i.db.update(j.docIndex).set({title:k,summary:l,updatedAt:new Date}).where((0,g.eq)(j.docIndex.id,m.id)):await i.db.insert(j.docIndex).values({id:(0,f.randomUUID)(),workspaceId:a,kind:e,path:c,title:k,summary:l})}function u(a){(a.startsWith(".claude/skills")||a.endsWith("/skills.md"))&&(0,h.revalidatePath)("/skills"),a.startsWith(".claude/agents")&&(0,h.revalidatePath)("/agents/[handle]","page"),a.startsWith("DOCS")&&(0,h.revalidatePath)("/docs"),a.startsWith("PO")&&(0,h.revalidatePath)("/pm"),a.startsWith("Reports")&&(0,h.revalidatePath)("/reports"),(0,h.revalidatePath)("/code")}async function v(a,b,c=!0){let d,e=await p(a);if(!e)return{ok:!1};let f=e.id;if((0,l.Nm)(a,b),d=b.match(/^\.claude\/skills\/(.+)\.md$/))await q(f,a,d[1]);else if(d=b.match(/^\.claude\/agents\/([^/]+)\/(?:Agent|skills)\.md$/))await r(f,a,d[1]);else if(/^Reports\/.+\.md$/.test(b))await s(f,a,b);else if(/^DOCS\/.+\.md$/.test(b))await t(f,a,b,"docs");else{if(!/^PO\/.+\.md$/.test(b))return{ok:!0};await t(f,a,b,"po")}return c&&u(b),{ok:!0}}async function w(a,b){let c,d=await p(a);if(!d)return{ok:!1};let e=d.id;return(0,l.SH)(a,b).catch(()=>{}),(c=b.match(/^\.claude\/skills\/(.+)\.md$/))?await i.db.delete(j.skill).where((0,g.Uo)((0,g.eq)(j.skill.workspaceId,e),(0,g.eq)(j.skill.name,c[1]))):/^(?:DOCS|PO)\/.+\.md$/.test(b)&&await i.db.delete(j.docIndex).where((0,g.Uo)((0,g.eq)(j.docIndex.workspaceId,e),(0,g.eq)(j.docIndex.path,b))),u(b),{ok:!0}}async function x(a=!0){let{org:b}=await (0,k.nP)(),c=b.id;for(let a of(0,d.Ci)(c,".claude/skills"))!a.isDir&&a.name.endsWith(".md")&&await v(c,a.path,!1);for(let a of(0,d.Ci)(c,".claude/agents"))a.isDir&&await v(c,`${a.path}/Agent.md`,!1);for(let a of["DOCS","PO","Reports"])for(let b of(0,d.Ci)(c,a))!b.isDir&&b.name.endsWith(".md")&&await v(c,b.path,!1);return a&&(0,h.revalidatePath)("/","layout"),{ok:!0}}async function y(a,b,c){(0,d.dx)(a,b,c),await v(a,b)}async function z(a,b){(0,d.EX)(a,b),await w(a,b)}(0,c(74252).D)([v,w,x]),(0,e.A)(v,"707fe9e0791bae72cb4b58e28b3fc406ee75f494c4",null),(0,e.A)(w,"6049641843ec1c7e875c48a2c3f9449777b8ccc9c5",null),(0,e.A)(x,"40fae88371459f73885109eab788ff958ee3beeed7",null)},84903:(a,b,c)=>{"use strict";c.d(b,{j:()=>i});var d=c(77598),e=c(97603),f=c(65705),g=c(1890),h=c(56338);async function i(a,b){if(b.text.trim()){try{await f.db.insert(g.decision).values({id:(0,d.randomUUID)(),workspaceId:a,text:b.text.slice(0,1e3),by:b.by??"",source:b.source??"",refKey:b.refKey??"",rationale:b.rationale??"",goalId:b.goalId??null,createdAt:new Date})}catch(a){console.error("[decision] log failed:",a)}(async()=>{try{let[c]=await f.db.select({orgId:g.workspace.orgId}).from(g.workspace).where((0,e.eq)(g.workspace.id,a));c?.orgId&&await (0,h.ru)(c.orgId,[{type:"decision",title:b.text.slice(0,120),summary:b.text.slice(0,1e3),body:b.rationale??"",goalId:b.goalId??null,agentHandle:b.by??"",sourceKind:"decision",sourceRef:b.refKey??""}])}catch{}})()}}},86004:(a,b,c)=>{"use strict";c.d(b,{f:()=>e});var d=c(2910);let e=(0,d.createServerReference)("00a15e709e3207ab4c46e487231119285bf1ecb00d",d.callServer,void 0,d.findSourceMapURL,"reindexKbAction")},86203:(a,b,c)=>{"use strict";c.d(b,{Toaster:()=>j});var d=c(4374),e=c(74679),f=c(47104),g=c(43526),h=c(31819),i=c(2910);function j(){let a=(0,h.k)(),[b,c]=(0,e.useState)([]);(0,e.useRef)(0),(0,e.useRef)(new Set);let i=(0,f.useRouter)();function j(a){c(b=>b.filter(b=>b.id!==a))}return b.length?(0,d.jsx)("div",{className:"toaster",children:b.map(b=>{var c;return(0,d.jsxs)("div",{className:"toast toast-"+b.kind,role:"status",onClick:()=>{var a,c;(j((a=b).id),a.channel&&("room"===(c=a.channel)||"telegram"===c||c.startsWith("dm:")))?window.dispatchEvent(new CustomEvent("constella:open-chat",{detail:{channel:a.channel}})):i.push("/notifications")},children:[(0,d.jsx)("span",{className:"toast-ic",children:(0,d.jsx)(g.I,{name:"approval"===(c=b.kind)||"needs-approval"===c?"inbox":"security"===c||"block"===c||"blocked"===c?"shield":"deploy"===c?"goto":"error"===c||"warn"===c||"warning"===c?"warn":c.startsWith("dm")||"mention"===c||"message"===c?"chat":"bell",size:15})}),(0,d.jsxs)("div",{className:"toast-body",children:[(0,d.jsx)("div",{className:"toast-title",children:b.text}),b.detail&&(0,d.jsx)("div",{className:"toast-detail",children:b.detail})]}),(0,d.jsx)("button",{className:"toast-x",title:a("common.dismiss"),onClick:a=>{a.stopPropagation(),j(b.id)},children:(0,d.jsx)(g.I,{name:"close",size:12})})]},b.id)})}):null}i.callServer,i.findSourceMapURL},92663:(a,b,c)=>{"use strict";c.d(b,{V:()=>e});var d=c(2910);let e=(0,d.createServerReference)("001b3f03a4be8dae997cef3766f261a8abe4f1f85a",d.callServer,void 0,d.findSourceMapURL,"seedDefaultBlocksAction")},92694:(a,b,c)=>{"use strict";c.d(b,{P:()=>e});var d=c(2910);let e=(0,d.createServerReference)("00448c48579abd11cee040b8b9ddca4e41be6f184e",d.callServer,void 0,d.findSourceMapURL,"runUpdate")},93209:(a,b,c)=>{"use strict";c.d(b,{BackButton:()=>h});var d=c(4374),e=c(47104),f=c(43526),g=c(31819);function h(){let a=(0,g.k)(),b=(0,e.useRouter)();return(0,d.jsx)("button",{className:"top-btn",title:a("common.back"),style:{marginRight:2},onClick:()=>{b.push("/")},children:(0,d.jsx)(f.I,{name:"chevronLeft",size:18})})}},94496:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>n});var d=c(61576),e=c(1782),f=c(80280),g=c(25533),h=c(95896),i=c(64557),j=c(51203),k=c(24960),l=c(28018),m=c(18773);async function n({children:a}){let{session:b,org:c,workspace:o}=await (0,h.nP)(),[p,q,r,s,t,u]=await Promise.all([f.db.select().from(g.agent).where((0,e.eq)(g.agent.workspaceId,o.id)),(0,h.O5)(b.user.id),f.db.select().from(g.inboxItem).where((0,e.Uo)((0,e.eq)(g.inboxItem.workspaceId,o.id),(0,e.eq)(g.inboxItem.resolved,!1))),f.db.select().from(g.notification).where((0,e.Uo)((0,e.eq)(g.notification.workspaceId,o.id),(0,e.eq)(g.notification.read,!1))),f.db.select().from(g.plan).where((0,e.eq)(g.plan.workspaceId,o.id)),f.db.select({image:g.user.image}).from(g.user).where((0,e.eq)(g.user.id,b.user.id))]),v=t[0],w=u[0]?.image??null;return(0,d.jsxs)("div",{className:"app",children:[(0,d.jsx)(i.Sidebar,{orgs:q,currentOrgId:c.id,workspaceSlug:o.slug,userName:b.user.name,userEmail:b.user.email,userImage:w,inboxCount:r.length,notifCount:s.length}),(0,d.jsx)("main",{className:"app-main",children:a}),(0,d.jsx)(j.ChatDockGate,{agents:p.map(a=>({id:a.id,handle:a.handle,name:a.name,role:a.role,color:a.color,image:a.image,adapter:a.adapter,status:a.status,health:a.health})),operator:{name:b.user.name,image:w}}),(0,d.jsx)(k.RunnerHeartbeat,{approved:!!v?.approved,auto247:!!v?.auto247}),(0,d.jsx)(l.SearchHotkey,{}),(0,d.jsx)(m.Toaster,{})]})}},95896:(a,b,c)=>{"use strict";c.d(b,{$x:()=>k,Ht:()=>j,K4:()=>l,O5:()=>m,nP:()=>n});var d=c(79676),e=c(17971),f=c(1782),g=c(80280),h=c(25533),i=c(51063);async function j(){return i.j2.api.getSession({headers:await (0,d.headers)()})}async function k(a,b){if(b){let[c]=await g.db.select({org:h.organization}).from(h.member).innerJoin(h.organization,(0,f.eq)(h.member.orgId,h.organization.id)).where((0,f.Uo)((0,f.eq)(h.member.userId,a),(0,f.eq)(h.organization.id,b)));if(c)return c.org}let c=await g.db.select({org:h.organization}).from(h.member).innerJoin(h.organization,(0,f.eq)(h.member.orgId,h.organization.id)).where((0,f.eq)(h.member.userId,a));return c[0]?.org??null}async function l(a){let[b]=await g.db.select().from(h.workspace).where((0,f.eq)(h.workspace.orgId,a));return b??null}async function m(a){return g.db.select({id:h.organization.id,name:h.organization.name}).from(h.member).innerJoin(h.organization,(0,f.eq)(h.member.orgId,h.organization.id)).where((0,f.eq)(h.member.userId,a))}async function n(){let a=await j();a||(0,e.redirect)("/login"),"1"===process.env.CONSTELLA_FORCE_ONBOARDING&&(0,e.redirect)("/onboarding");let b=await k(a.user.id,a.session.activeOrgId);b||(0,e.redirect)("/onboarding");let c=await l(b.id);return c||(0,e.redirect)("/onboarding"),{session:a,org:b,workspace:c}}},97140:(a,b,c)=>{"use strict";c.d(b,{Fu:()=>D,GW:()=>A,H7:()=>y,ME:()=>E,VL:()=>z,Wu:()=>w,_z:()=>t,bt:()=>F,gg:()=>v,jw:()=>B,n4:()=>u,rd:()=>x,rm:()=>C,xU:()=>s});var d=c(6866),e=c(77598),f=c(97603),g=c(95357),h=c(31371),i=c(65705),j=c(1890),k=c(53993),l=c(71352),m=c(36250),n=c(84903),o=c(33644),p=c(57300),q=c(56338),r=c(45125);async function s(){let{workspace:a}=await (0,k.nP)(),[b,c,d]=await Promise.all([i.db.select({id:j.goal.id,title:j.goal.title}).from(j.goal).where((0,f.Uo)((0,f.eq)(j.goal.workspaceId,a.id),(0,f.eq)(j.goal.status,"active"))),i.db.select({id:j.spec.id,key:j.spec.key,title:j.spec.title}).from(j.spec).where((0,f.Uo)((0,f.eq)(j.spec.workspaceId,a.id),(0,f.eq)(j.spec.status,"active"))),i.db.select({id:j.issue.id,key:j.issue.key,title:j.issue.title}).from(j.issue).where((0,f.eq)(j.issue.workspaceId,a.id))]),e=a=>a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,24)||"goal",g=[];for(let a of b.slice(0,60))g.push({kind:"goal",key:e(a.title),title:a.title,id:a.id});for(let a of c.slice(0,80))g.push({kind:"spec",key:a.key,title:a.title,id:a.id});for(let a of d.slice(0,150))g.push({kind:"issue",key:a.key,title:a.title,id:a.id});return g}async function t(a,b,d){let{org:g,workspace:l}=await (0,k.nP)(),m=await i.db.select().from(j.agent).where((0,f.eq)(j.agent.workspaceId,l.id)),q=new Set(m.map(a=>a.handle)),s=(b??"").trim();if(s.startsWith("/")&&"telegram"!==a){let{runSlashCommand:b}=await Promise.all([c.e(9783),c.e(4979)]).then(c.bind(c,84979)),d=await b(g.id,l.id,m,a,s);if(d.handled)return(0,h.revalidatePath)("/","layout"),{responders:d.responders}}let t=[];if(a.startsWith("dm:")){let b=a.slice(3);q.has(b)&&(t=[b])}else if("telegram"===a)t=q.has("ada")?["ada"]:m.slice(0,1).map(a=>a.handle);else if(0===(t=[...b.matchAll(/@([a-z0-9-]+)/gi)].map(a=>a[1].toLowerCase()).filter(a=>q.has(a)).slice(0,3)).length)return{responders:[]};let u=await (0,r.xF)(l.id,a);return await i.db.insert(j.message).values({id:(0,e.randomUUID)(),workspaceId:l.id,channel:a,fromKind:"operator",text:b,attachments:d?.length?d.slice(0,10):null,sessionId:u}),(0,o.r)(l.id),(0,p.PD)(l.orgId),"room"===a&&b.trim().length>=15&&await (0,n.j)(l.id,{text:b.slice(0,400),by:"operator",source:"operator-instruction"}),(0,h.revalidatePath)("/","layout"),{responders:t}}async function u(a,b){let{org:d,workspace:g}=await (0,k.nP)(),[n]=await i.db.select().from(j.agent).where((0,f.Uo)((0,f.eq)(j.agent.workspaceId,g.id),(0,f.eq)(j.agent.handle,b)));if(!n)return;await i.db.update(j.agent).set({status:"working"}).where((0,f.eq)(j.agent.id,n.id));let{text:p,planRequested:q}=await (0,l.PM)(d.id,g,a,n,"chat");if(await i.db.update(j.agent).set({status:"idle"}).where((0,f.eq)(j.agent.id,n.id)),"telegram"===a&&p)try{let{mirrorToTelegram:a}=await Promise.all([c.e(259),c.e(7622)]).then(c.bind(c,47622));await a(g.id,p)}catch(a){console.error("[agentRespond] telegram mirror failed:",a)}if(q)try{let b=await (0,m.planFromConversation)(a),c=b.ok?"Got it — registering this as new work. I'm drafting the plan now (specs, issues and TODOs); it'll appear in the CEO Planner for your approval, and I'll post it here when it's ready.":`I couldn't start a plan from this yet (${b.error??"no structured plan"}). Add a little more detail on what you want and I'll try again.`;await i.db.insert(j.message).values({id:(0,e.randomUUID)(),workspaceId:g.id,channel:a,fromKind:"agent",fromHandle:n.handle,text:c,createdAt:new Date,sessionId:await (0,r.xF)(g.id,a)}),(0,o.r)(g.id)}catch(a){console.error("[agentRespond] new-work planning failed:",a)}a.startsWith("dm:")||await (0,l.YK)(d.id,g,b,p,0),(0,h.revalidatePath)("/","layout")}async function v(a){let{org:b,workspace:c}=await (0,k.nP)(),[d]=await i.db.select().from(j.message).where((0,f.Uo)((0,f.eq)(j.message.workspaceId,c.id),(0,f.eq)(j.message.id,a)));return d&&d.text?.trim()?(await (0,q.ru)(b.id,[{type:"note",title:d.text.trim().slice(0,80),summary:d.text.trim().slice(0,1200),agentHandle:d.fromHandle??"",sourceKind:"note",sourceRef:a}]),{ok:!0}):{ok:!1}}async function w(a){let{org:b}=await (0,k.nP)(),c=(a??"").trim().slice(0,500);if(!c)return{ok:!1,error:"empty"};try{let a=await (0,q.ed)(b.id,c),d=(a.text??"").trim();if("none"===a.mode||!d)return{ok:!1,error:"none"};return{ok:!0,text:d.slice(0,1200),sources:(a.sources??[]).slice(0,6)}}catch(a){return console.error("[pullKbForComposer] failed:",a),{ok:!1,error:"failed"}}}async function x(a){let b,c,{workspace:d}=await (0,k.nP)(),[e]=await i.db.select().from(j.task).where((0,f.Uo)((0,f.eq)(j.task.workspaceId,d.id),(0,f.eq)(j.task.id,a)));if(!e)return null;if(e.issueId){let[a]=await i.db.select({key:j.issue.key}).from(j.issue).where((0,f.eq)(j.issue.id,e.issueId));b=a?.key}if(e.goalId){let[a]=await i.db.select({title:j.goal.title}).from(j.goal).where((0,f.eq)(j.goal.id,e.goalId));c=a?.title}return{taskKey:e.key,issueKey:b,goalTitle:c,col:e.col}}async function y(a){let{workspace:b}=await (0,k.nP)();if(!a.startsWith("dm:")&&"telegram"!==a&&"room"!==a)return{ok:!1};if(a.startsWith("dm:")){let c=await (0,r.xF)(b.id,a);await i.db.delete(j.message).where((0,f.Uo)((0,f.eq)(j.message.workspaceId,b.id),(0,f.eq)(j.message.channel,a),(0,f.eq)(j.message.sessionId,c))),await i.db.delete(j.messageSummary).where((0,f.Uo)((0,f.eq)(j.messageSummary.workspaceId,b.id),(0,f.eq)(j.messageSummary.channel,a),(0,f.eq)(j.messageSummary.sessionId,c)))}else await i.db.delete(j.message).where((0,f.Uo)((0,f.eq)(j.message.workspaceId,b.id),(0,f.eq)(j.message.channel,a))),await i.db.delete(j.messageSummary).where((0,f.Uo)((0,f.eq)(j.messageSummary.workspaceId,b.id),(0,f.eq)(j.messageSummary.channel,a)));return await i.db.delete(j.event).where((0,f.Uo)((0,f.eq)(j.event.workspaceId,b.id),(0,f.eq)(j.event.channel,a))),(0,o.r)(b.id),(0,h.revalidatePath)("/","layout"),{ok:!0}}async function z(a){let{workspace:b}=await (0,k.nP)();if(a.startsWith("dm:")){let c=await (0,r.xF)(b.id,a);return i.db.select().from(j.message).where((0,f.Uo)((0,f.eq)(j.message.workspaceId,b.id),(0,f.eq)(j.message.channel,a),(0,f.eq)(j.message.sessionId,c))).orderBy((0,g.Y)(j.message.createdAt))}return i.db.select().from(j.message).where((0,f.Uo)((0,f.eq)(j.message.workspaceId,b.id),(0,f.eq)(j.message.channel,a))).orderBy((0,g.Y)(j.message.createdAt))}async function A(a){let{workspace:b}=await (0,k.nP)();return(0,r.X0)(b.id,a)}async function B(a,b){let{workspace:c}=await (0,k.nP)(),d=await (0,r.RL)(c.id,a,b);return(0,h.revalidatePath)("/","layout"),{id:d}}async function C(a,b){let{workspace:c}=await (0,k.nP)();return await (0,r.WU)(c.id,a,b),(0,h.revalidatePath)("/","layout"),{ok:!0}}async function D(a,b){let{workspace:c}=await (0,k.nP)();return await (0,r.Jb)(c.id,a,b),(0,h.revalidatePath)("/","layout"),{ok:!0}}async function E(a,b){let{workspace:c}=await (0,k.nP)();return await (0,r.OL)(c.id,a,b),(0,h.revalidatePath)("/","layout"),{ok:!0}}async function F(){let{workspace:a}=await (0,k.nP)(),b=await i.db.select().from(j.message).where((0,f.Uo)((0,f.eq)(j.message.workspaceId,a.id),(0,f.mj)(j.message.channel,"dm:%"))).orderBy((0,g.Y)(j.message.createdAt)),c={};for(let a of b)c[a.channel.slice(3)]={text:a.text??"",mine:"operator"===a.fromKind};return c}(0,c(74252).D)([s,t,u,v,w,x,y,z,A,B,C,D,E,F]),(0,d.A)(s,"0025f5c700bf585074afe9a3d74daf5d034b95a18d",null),(0,d.A)(t,"702777ba042d40b1d5705ed063aec09cc357fcdd61",null),(0,d.A)(u,"6029b8dd07385c22b79cec8930cd425924cfa64f1c",null),(0,d.A)(v,"40bdecbf659bb86c86705318c2779dca409a75fc6a",null),(0,d.A)(w,"40fb601e332b01b2db0128c9248448e91ee1e8823a",null),(0,d.A)(x,"40673eeabfff5b8aa941d94d53ce3478e168718e95",null),(0,d.A)(y,"40daf6dca3077229fd6d6cbccfd335893f03280125",null),(0,d.A)(z,"408bdae443a0482c1bfbd42dc2b720e682b1423fab",null),(0,d.A)(A,"40972e72e17f52772e05b1c26618888916aa0a95cc",null),(0,d.A)(B,"60face35dada2c40df11c8516d8fa9bd434df12801",null),(0,d.A)(C,"601269a69c549fe5fca4611d91fa20388e33f4e50b",null),(0,d.A)(D,"6061163d33474b69b44ca71969e7e32eea6632c216",null),(0,d.A)(E,"606c496fc7ae51c9732c206c25c0180519765eb1c5",null),(0,d.A)(F,"004d9216cd0b492704be3f3914da6586dd305de8d5",null)}};