@mndrk/agx 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/cloud-runtime/standalone/apps/local/.next/BUILD_ID +1 -1
  2. package/cloud-runtime/standalone/apps/local/.next/build-manifest.json +3 -3
  3. package/cloud-runtime/standalone/apps/local/.next/prerender-manifest.json +3 -3
  4. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.html +1 -1
  5. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.rsc +1 -1
  6. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  7. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  9. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  10. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.html +2 -2
  13. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.rsc +2 -2
  14. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  15. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  16. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  17. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  18. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  19. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  20. package/cloud-runtime/standalone/apps/local/.next/server/app/agents/[id]/page_client-reference-manifest.js +1 -1
  21. package/cloud-runtime/standalone/apps/local/.next/server/app/agents/page_client-reference-manifest.js +1 -1
  22. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.html +2 -2
  23. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.rsc +2 -2
  24. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/_full.segment.rsc +2 -2
  25. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/_head.segment.rsc +1 -1
  26. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/_index.segment.rsc +2 -2
  27. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/_tree.segment.rsc +2 -2
  28. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/agents/__PAGE__.segment.rsc +1 -1
  29. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/agents.segment.rsc +1 -1
  30. package/cloud-runtime/standalone/apps/local/.next/server/app/api/agent-specs/route.js.nft.json +1 -1
  31. package/cloud-runtime/standalone/apps/local/.next/server/app/api/agents/[id]/profile/route.js.nft.json +1 -1
  32. package/cloud-runtime/standalone/apps/local/.next/server/app/api/agents/export/route.js.nft.json +1 -1
  33. package/cloud-runtime/standalone/apps/local/.next/server/app/api/chat/route.js.nft.json +1 -1
  34. package/cloud-runtime/standalone/apps/local/.next/server/app/api/file-search/route.js.nft.json +1 -1
  35. package/cloud-runtime/standalone/apps/local/.next/server/app/api/linear/issues/[id]/route.js.nft.json +1 -1
  36. package/cloud-runtime/standalone/apps/local/.next/server/app/api/linear/issues/context/route.js.nft.json +1 -1
  37. package/cloud-runtime/standalone/apps/local/.next/server/app/api/linear/issues/route.js.nft.json +1 -1
  38. package/cloud-runtime/standalone/apps/local/.next/server/app/api/linear/options/route.js.nft.json +1 -1
  39. package/cloud-runtime/standalone/apps/local/.next/server/app/api/linear/runs/scripted/route.js.nft.json +1 -1
  40. package/cloud-runtime/standalone/apps/local/.next/server/app/api/linear/status/route.js.nft.json +1 -1
  41. package/cloud-runtime/standalone/apps/local/.next/server/app/api/participants/route.js.nft.json +1 -1
  42. package/cloud-runtime/standalone/apps/local/.next/server/app/api/projects/[id]/objectives/[objectiveId]/linear-issues/route.js.nft.json +1 -1
  43. package/cloud-runtime/standalone/apps/local/.next/server/app/api/projects/[id]/objectives/[objectiveId]/scheduled-tasks/route.js.nft.json +1 -1
  44. package/cloud-runtime/standalone/apps/local/.next/server/app/api/projects/[id]/objectives/[objectiveId]/worker/route.js.nft.json +1 -1
  45. package/cloud-runtime/standalone/apps/local/.next/server/app/api/projects/[id]/search/route.js.nft.json +1 -1
  46. package/cloud-runtime/standalone/apps/local/.next/server/app/api/projects/[id]/teams/route.js.nft.json +1 -1
  47. package/cloud-runtime/standalone/apps/local/.next/server/app/api/prompt-jobs/poll/route.js.nft.json +1 -1
  48. package/cloud-runtime/standalone/apps/local/.next/server/app/api/providers/check/[id]/route.js.nft.json +1 -1
  49. package/cloud-runtime/standalone/apps/local/.next/server/app/api/providers/route.js.nft.json +1 -1
  50. package/cloud-runtime/standalone/apps/local/.next/server/app/api/queue/route.js.nft.json +1 -1
  51. package/cloud-runtime/standalone/apps/local/.next/server/app/api/schedules/debug/route.js.nft.json +1 -1
  52. package/cloud-runtime/standalone/apps/local/.next/server/app/api/schedules/poll/route.js.nft.json +1 -1
  53. package/cloud-runtime/standalone/apps/local/.next/server/app/api/skills/assign/route.js.nft.json +1 -1
  54. package/cloud-runtime/standalone/apps/local/.next/server/app/api/skills/available/route.js.nft.json +1 -1
  55. package/cloud-runtime/standalone/apps/local/.next/server/app/api/skills/detail/route.js.nft.json +1 -1
  56. package/cloud-runtime/standalone/apps/local/.next/server/app/api/skills/history/route.js.nft.json +1 -1
  57. package/cloud-runtime/standalone/apps/local/.next/server/app/api/skills/learn/route.js.nft.json +1 -1
  58. package/cloud-runtime/standalone/apps/local/.next/server/app/api/skills/route.js.nft.json +1 -1
  59. package/cloud-runtime/standalone/apps/local/.next/server/app/api/skills/unlearn/route.js.nft.json +1 -1
  60. package/cloud-runtime/standalone/apps/local/.next/server/app/api/status/route.js.nft.json +1 -1
  61. package/cloud-runtime/standalone/apps/local/.next/server/app/api/summarize/route.js.nft.json +1 -1
  62. package/cloud-runtime/standalone/apps/local/.next/server/app/api/tasks/[id]/comments/[commentId]/route.js.nft.json +1 -1
  63. package/cloud-runtime/standalone/apps/local/.next/server/app/api/tasks/[id]/comments/route.js.nft.json +1 -1
  64. package/cloud-runtime/standalone/apps/local/.next/server/app/api/tasks/[id]/nodes/[nodeId]/verify/route.js.nft.json +1 -1
  65. package/cloud-runtime/standalone/apps/local/.next/server/app/api/tasks/[id]/route.js.nft.json +1 -1
  66. package/cloud-runtime/standalone/apps/local/.next/server/app/api/tasks/extract/route.js.nft.json +1 -1
  67. package/cloud-runtime/standalone/apps/local/.next/server/app/api/tasks/route.js.nft.json +1 -1
  68. package/cloud-runtime/standalone/apps/local/.next/server/app/api/threads/knowledge/route.js.nft.json +1 -1
  69. package/cloud-runtime/standalone/apps/local/.next/server/app/api/threads/route.js.nft.json +1 -1
  70. package/cloud-runtime/standalone/apps/local/.next/server/app/automations/page_client-reference-manifest.js +1 -1
  71. package/cloud-runtime/standalone/apps/local/.next/server/app/automations.html +2 -2
  72. package/cloud-runtime/standalone/apps/local/.next/server/app/automations.rsc +5 -5
  73. package/cloud-runtime/standalone/apps/local/.next/server/app/automations.segments/_full.segment.rsc +5 -5
  74. package/cloud-runtime/standalone/apps/local/.next/server/app/automations.segments/_head.segment.rsc +1 -1
  75. package/cloud-runtime/standalone/apps/local/.next/server/app/automations.segments/_index.segment.rsc +2 -2
  76. package/cloud-runtime/standalone/apps/local/.next/server/app/automations.segments/_tree.segment.rsc +3 -3
  77. package/cloud-runtime/standalone/apps/local/.next/server/app/automations.segments/automations/__PAGE__.segment.rsc +3 -3
  78. package/cloud-runtime/standalone/apps/local/.next/server/app/automations.segments/automations.segment.rsc +1 -1
  79. package/cloud-runtime/standalone/apps/local/.next/server/app/board/page_client-reference-manifest.js +1 -1
  80. package/cloud-runtime/standalone/apps/local/.next/server/app/board.html +2 -2
  81. package/cloud-runtime/standalone/apps/local/.next/server/app/board.rsc +2 -2
  82. package/cloud-runtime/standalone/apps/local/.next/server/app/board.segments/_full.segment.rsc +2 -2
  83. package/cloud-runtime/standalone/apps/local/.next/server/app/board.segments/_head.segment.rsc +1 -1
  84. package/cloud-runtime/standalone/apps/local/.next/server/app/board.segments/_index.segment.rsc +2 -2
  85. package/cloud-runtime/standalone/apps/local/.next/server/app/board.segments/_tree.segment.rsc +2 -2
  86. package/cloud-runtime/standalone/apps/local/.next/server/app/board.segments/board/__PAGE__.segment.rsc +1 -1
  87. package/cloud-runtime/standalone/apps/local/.next/server/app/board.segments/board.segment.rsc +1 -1
  88. package/cloud-runtime/standalone/apps/local/.next/server/app/execution-graph/page.js.nft.json +1 -1
  89. package/cloud-runtime/standalone/apps/local/.next/server/app/execution-graph/page_client-reference-manifest.js +1 -1
  90. package/cloud-runtime/standalone/apps/local/.next/server/app/execution-graph.html +2 -2
  91. package/cloud-runtime/standalone/apps/local/.next/server/app/execution-graph.rsc +3 -3
  92. package/cloud-runtime/standalone/apps/local/.next/server/app/execution-graph.segments/_full.segment.rsc +3 -3
  93. package/cloud-runtime/standalone/apps/local/.next/server/app/execution-graph.segments/_head.segment.rsc +1 -1
  94. package/cloud-runtime/standalone/apps/local/.next/server/app/execution-graph.segments/_index.segment.rsc +2 -2
  95. package/cloud-runtime/standalone/apps/local/.next/server/app/execution-graph.segments/_tree.segment.rsc +2 -2
  96. package/cloud-runtime/standalone/apps/local/.next/server/app/execution-graph.segments/execution-graph/__PAGE__.segment.rsc +2 -2
  97. package/cloud-runtime/standalone/apps/local/.next/server/app/execution-graph.segments/execution-graph.segment.rsc +1 -1
  98. package/cloud-runtime/standalone/apps/local/.next/server/app/folders/page_client-reference-manifest.js +1 -1
  99. package/cloud-runtime/standalone/apps/local/.next/server/app/folders.html +2 -2
  100. package/cloud-runtime/standalone/apps/local/.next/server/app/folders.rsc +2 -2
  101. package/cloud-runtime/standalone/apps/local/.next/server/app/folders.segments/_full.segment.rsc +2 -2
  102. package/cloud-runtime/standalone/apps/local/.next/server/app/folders.segments/_head.segment.rsc +1 -1
  103. package/cloud-runtime/standalone/apps/local/.next/server/app/folders.segments/_index.segment.rsc +2 -2
  104. package/cloud-runtime/standalone/apps/local/.next/server/app/folders.segments/_tree.segment.rsc +2 -2
  105. package/cloud-runtime/standalone/apps/local/.next/server/app/folders.segments/folders/__PAGE__.segment.rsc +1 -1
  106. package/cloud-runtime/standalone/apps/local/.next/server/app/folders.segments/folders.segment.rsc +1 -1
  107. package/cloud-runtime/standalone/apps/local/.next/server/app/index.html +2 -2
  108. package/cloud-runtime/standalone/apps/local/.next/server/app/index.rsc +2 -2
  109. package/cloud-runtime/standalone/apps/local/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  110. package/cloud-runtime/standalone/apps/local/.next/server/app/index.segments/_full.segment.rsc +2 -2
  111. package/cloud-runtime/standalone/apps/local/.next/server/app/index.segments/_head.segment.rsc +1 -1
  112. package/cloud-runtime/standalone/apps/local/.next/server/app/index.segments/_index.segment.rsc +2 -2
  113. package/cloud-runtime/standalone/apps/local/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  114. package/cloud-runtime/standalone/apps/local/.next/server/app/page_client-reference-manifest.js +1 -1
  115. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/automations/page_client-reference-manifest.js +1 -1
  116. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/env-vars/page_client-reference-manifest.js +1 -1
  117. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/folders/page_client-reference-manifest.js +1 -1
  118. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/graph/[taskId]/page_client-reference-manifest.js +1 -1
  119. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/knowledge/page_client-reference-manifest.js +1 -1
  120. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/linear/page.js.nft.json +1 -1
  121. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/linear/page_client-reference-manifest.js +1 -1
  122. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/objectives/[objectiveId]/page.js.nft.json +1 -1
  123. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/objectives/[objectiveId]/page_client-reference-manifest.js +1 -1
  124. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/objectives/page.js.nft.json +1 -1
  125. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/objectives/page_client-reference-manifest.js +1 -1
  126. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
  127. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/settings/page_client-reference-manifest.js +1 -1
  128. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/[teamId]/agents/[agentId]/page_client-reference-manifest.js +1 -1
  129. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/[teamId]/page_client-reference-manifest.js +1 -1
  130. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/adopt/page_client-reference-manifest.js +1 -1
  131. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/new/page_client-reference-manifest.js +1 -1
  132. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/page_client-reference-manifest.js +1 -1
  133. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/replace/page_client-reference-manifest.js +1 -1
  134. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/terminal/page_client-reference-manifest.js +1 -1
  135. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/thread/[threadId]/page.js.nft.json +1 -1
  136. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/thread/[threadId]/page_client-reference-manifest.js +1 -1
  137. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/orphans/page_client-reference-manifest.js +1 -1
  138. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/orphans.html +2 -2
  139. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/orphans.rsc +2 -2
  140. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/orphans.segments/_full.segment.rsc +2 -2
  141. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/orphans.segments/_head.segment.rsc +1 -1
  142. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/orphans.segments/_index.segment.rsc +2 -2
  143. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/orphans.segments/_tree.segment.rsc +2 -2
  144. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/orphans.segments/projects/orphans/__PAGE__.segment.rsc +1 -1
  145. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/orphans.segments/projects/orphans.segment.rsc +1 -1
  146. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/orphans.segments/projects.segment.rsc +1 -1
  147. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  148. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.html +2 -2
  149. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.rsc +2 -2
  150. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/_full.segment.rsc +2 -2
  151. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/_head.segment.rsc +1 -1
  152. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/_index.segment.rsc +2 -2
  153. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/_tree.segment.rsc +2 -2
  154. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/projects/__PAGE__.segment.rsc +1 -1
  155. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/projects.segment.rsc +1 -1
  156. package/cloud-runtime/standalone/apps/local/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  157. package/cloud-runtime/standalone/apps/local/.next/server/app/settings.html +2 -2
  158. package/cloud-runtime/standalone/apps/local/.next/server/app/settings.rsc +2 -2
  159. package/cloud-runtime/standalone/apps/local/.next/server/app/settings.segments/_full.segment.rsc +2 -2
  160. package/cloud-runtime/standalone/apps/local/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  161. package/cloud-runtime/standalone/apps/local/.next/server/app/settings.segments/_index.segment.rsc +2 -2
  162. package/cloud-runtime/standalone/apps/local/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
  163. package/cloud-runtime/standalone/apps/local/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +1 -1
  164. package/cloud-runtime/standalone/apps/local/.next/server/app/settings.segments/settings.segment.rsc +1 -1
  165. package/cloud-runtime/standalone/apps/local/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  166. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.html +2 -2
  167. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.rsc +2 -2
  168. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/_full.segment.rsc +2 -2
  169. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/_head.segment.rsc +1 -1
  170. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/_index.segment.rsc +2 -2
  171. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/_tree.segment.rsc +2 -2
  172. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/setup/__PAGE__.segment.rsc +1 -1
  173. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/setup.segment.rsc +1 -1
  174. package/cloud-runtime/standalone/apps/local/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  175. package/cloud-runtime/standalone/apps/local/.next/server/app/skills.html +2 -2
  176. package/cloud-runtime/standalone/apps/local/.next/server/app/skills.rsc +2 -2
  177. package/cloud-runtime/standalone/apps/local/.next/server/app/skills.segments/_full.segment.rsc +2 -2
  178. package/cloud-runtime/standalone/apps/local/.next/server/app/skills.segments/_head.segment.rsc +1 -1
  179. package/cloud-runtime/standalone/apps/local/.next/server/app/skills.segments/_index.segment.rsc +2 -2
  180. package/cloud-runtime/standalone/apps/local/.next/server/app/skills.segments/_tree.segment.rsc +2 -2
  181. package/cloud-runtime/standalone/apps/local/.next/server/app/skills.segments/skills/__PAGE__.segment.rsc +1 -1
  182. package/cloud-runtime/standalone/apps/local/.next/server/app/skills.segments/skills.segment.rsc +1 -1
  183. package/cloud-runtime/standalone/apps/local/.next/server/app/status/page.js.nft.json +1 -1
  184. package/cloud-runtime/standalone/apps/local/.next/server/app/status/page_client-reference-manifest.js +1 -1
  185. package/cloud-runtime/standalone/apps/local/.next/server/app/status.html +2 -2
  186. package/cloud-runtime/standalone/apps/local/.next/server/app/status.rsc +3 -3
  187. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/_full.segment.rsc +3 -3
  188. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/_head.segment.rsc +1 -1
  189. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/_index.segment.rsc +2 -2
  190. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/_tree.segment.rsc +2 -2
  191. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/status/__PAGE__.segment.rsc +2 -2
  192. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/status.segment.rsc +1 -1
  193. package/cloud-runtime/standalone/apps/local/.next/server/app/thread/[id]/page.js.nft.json +1 -1
  194. package/cloud-runtime/standalone/apps/local/.next/server/app/thread/[id]/page_client-reference-manifest.js +1 -1
  195. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/0rhn_lucide-react_dist_esm_067eb..._.js +3 -0
  196. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/[root-of-the-server]__039h7r.._.js +18 -0
  197. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/[root-of-the-server]__0lno3km._.js +3 -0
  198. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/{[root-of-the-server]__0fl7_-o._.js → [root-of-the-server]__0nqqk26._.js} +2 -2
  199. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/{[root-of-the-server]__0j9m72.._.js → [root-of-the-server]__0tqn-o5._.js} +2 -2
  200. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/[root-of-the-server]__0~nm7b6._.js +3 -0
  201. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/{_064h43p._.js → _05xj_bp._.js} +2 -2
  202. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/{apps_local_0nvzo3y._.js → apps_local_04dh2yh._.js} +2 -2
  203. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/apps_local_app_projects_[slug]_layout_tsx_0aaa3~t._.js +1 -1
  204. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/apps_local_app_projects_[slug]_linear_page_tsx_0a~n5y8._.js +2 -2
  205. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/apps_local_components_PromptJobBoard_tsx_06zob36._.js +1 -1
  206. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/apps_local_components_chat-ui_ChatContainer_tsx_0c9fjtl._.js +1 -1
  207. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/apps_local_components_projects_ProjectObjectivesWorkspace_tsx_0k4tfip._.js +1 -1
  208. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/apps_local_components_thread_WorkspaceSidebar_tsx_0unv2xp._.js +1 -1
  209. package/cloud-runtime/standalone/apps/local/.next/server/middleware-build-manifest.js +3 -3
  210. package/cloud-runtime/standalone/apps/local/.next/server/middleware-manifest.json +5 -5
  211. package/cloud-runtime/standalone/apps/local/.next/server/pages/404.html +2 -2
  212. package/cloud-runtime/standalone/apps/local/.next/server/pages/500.html +1 -1
  213. package/cloud-runtime/standalone/apps/local/.next/server/server-reference-manifest.js +1 -1
  214. package/cloud-runtime/standalone/apps/local/.next/server/server-reference-manifest.json +1 -1
  215. package/cloud-runtime/standalone/apps/local/.next/static/chunks/{0e307b-0c2jbx.js → 0-cets4_axpvm.js} +1 -1
  216. package/cloud-runtime/standalone/apps/local/.next/static/chunks/0-wlbe.ripd2w.css +1 -0
  217. package/cloud-runtime/standalone/apps/local/.next/static/chunks/00e1ihnb6ap3t.js +16 -0
  218. package/cloud-runtime/standalone/apps/local/.next/static/chunks/{119v0-idpg-cv.js → 0_cjth28_11b2.js} +1 -1
  219. package/cloud-runtime/standalone/apps/local/.next/static/chunks/0e6rxcxy.l5c8.js +1 -0
  220. package/cloud-runtime/standalone/apps/local/.next/static/chunks/0ime4btrg-g4l.js +1 -0
  221. package/cloud-runtime/standalone/apps/local/.next/static/chunks/{0jrkacz_dyem6.js → 0jglardpw~5uc.js} +5 -5
  222. package/cloud-runtime/standalone/apps/local/.next/static/chunks/{0tt1oh112yv-l.js → 0jq0t4zip38wt.js} +1 -1
  223. package/cloud-runtime/standalone/apps/local/.next/static/chunks/0kn66yvx08813.css +1 -0
  224. package/cloud-runtime/standalone/apps/local/.next/static/chunks/{07646a0h94826.js → 0l89kxqcf86on.js} +2 -2
  225. package/cloud-runtime/standalone/apps/local/.next/static/chunks/0ng6wy4ak35jg.js +1 -0
  226. package/cloud-runtime/standalone/apps/local/.next/static/chunks/0n~jhoq~op4e5.js +16 -0
  227. package/cloud-runtime/standalone/apps/local/.next/static/chunks/{0stvi5btlxl4m.js → 0xu_doej_wc-3.js} +1 -1
  228. package/cloud-runtime/standalone/apps/local/.next/static/chunks/{16d~es6h6k~rj.js → 16fyhcmwlw3th.js} +1 -1
  229. package/cloud-runtime/standalone/apps/local/.next/static/chunks/{0uve8xrt~0a2e.js → 18e8w~~mvoh5o.js} +1 -1
  230. package/cloud-runtime/standalone/apps/local/app/projects/[slug]/layout.tsx +1 -1
  231. package/cloud-runtime/standalone/apps/local/components/PromptJobBoard.tsx +3 -2
  232. package/cloud-runtime/standalone/apps/local/components/linear/LinearSettingsModal.tsx +9 -3
  233. package/cloud-runtime/standalone/apps/local/components/linear/LinearWorkerConfig.tsx +65 -30
  234. package/cloud-runtime/standalone/apps/local/components/linear/LinearWorkerRunLog.tsx +190 -0
  235. package/cloud-runtime/standalone/apps/local/components/projects/ObjectiveScheduledTasksPanel.tsx +38 -34
  236. package/cloud-runtime/standalone/apps/local/components/thread/WorkspaceSidebar.tsx +118 -17
  237. package/cloud-runtime/standalone/apps/local/styles/workspaceSidebar.css +71 -2
  238. package/cloud-runtime/standalone/apps/local/worker/index.js +2 -2
  239. package/package.json +1 -1
  240. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/0rhn_lucide-react_dist_esm_0tvwux2._.js +0 -3
  241. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/[root-of-the-server]__006vr7.._.js +0 -3
  242. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/[root-of-the-server]__0d18x53._.js +0 -18
  243. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/[root-of-the-server]__0z7nw_r._.js +0 -3
  244. package/cloud-runtime/standalone/apps/local/.next/static/chunks/0-_ukhpeg429c.js +0 -16
  245. package/cloud-runtime/standalone/apps/local/.next/static/chunks/04yoml2rqnuot.js +0 -16
  246. package/cloud-runtime/standalone/apps/local/.next/static/chunks/0_mrpyqcoyb_5.js +0 -1
  247. package/cloud-runtime/standalone/apps/local/.next/static/chunks/0edewt9l~cs~k.css +0 -1
  248. package/cloud-runtime/standalone/apps/local/.next/static/chunks/0f7i3ae1ynhf3.css +0 -1
  249. package/cloud-runtime/standalone/apps/local/.next/static/chunks/0r0c9y6.8.m5p.js +0 -1
  250. package/cloud-runtime/standalone/apps/local/.next/static/chunks/0zw85-xl9ysjs.js +0 -1
  251. /package/cloud-runtime/standalone/apps/local/.next/static/{RnYHmEXBwXJjVrVVx2CuP → qPuactsz6OYimwT6dSdHn}/_buildManifest.js +0 -0
  252. /package/cloud-runtime/standalone/apps/local/.next/static/{RnYHmEXBwXJjVrVVx2CuP → qPuactsz6OYimwT6dSdHn}/_clientMiddlewareManifest.js +0 -0
  253. /package/cloud-runtime/standalone/apps/local/.next/static/{RnYHmEXBwXJjVrVVx2CuP → qPuactsz6OYimwT6dSdHn}/_ssgManifest.js +0 -0
@@ -1,3 +1,3 @@
1
1
  (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,186552,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(810605),s=e.i(66386),l=e.i(945028),n=e.i(490011),i=e.i(969039),o=e.i(44054),d=e.i(749410),c=e.i(522016),u=e.i(208343),p=e.i(884564),h=e.i(423709);function m(){return(0,t.jsxs)("span",{className:"inline-flex items-center gap-[3px] ml-1",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--muted-foreground)] animate-[pulse-dot_1.4s_ease-in-out_infinite]"}),(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--muted-foreground)] animate-[pulse-dot_1.4s_ease-in-out_0.2s_infinite]"}),(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--muted-foreground)] animate-[pulse-dot_1.4s_ease-in-out_0.4s_infinite]"})]})}function f({participantId:e,participantName:a,participantColor:r,content:s}){let l=(0,h.stripMarkers)(s),n=l.length>0;return(0,t.jsxs)("div",{className:"flex gap-4 py-4 group transition-colors animate-in fade-in slide-in-from-bottom-2 duration-300",children:[(0,t.jsx)(c.default,{href:`/agents/${e}`,className:"w-9 h-9 rounded-full bg-[var(--muted)] overflow-hidden shrink-0 shadow-sm border border-[var(--border)] hover:ring-2 hover:ring-blue-300 transition-shadow",children:(0,t.jsx)("img",{src:(0,p.agentAvatarUrl)(e,36,r),alt:"",className:"w-full h-full object-cover"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-baseline gap-2 mb-1",children:[(0,t.jsx)(c.default,{href:`/agents/${e}`,className:"font-bold text-[15px] hover:underline",style:{color:r},children:a}),(0,t.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-[var(--muted-foreground)] font-bold opacity-0 group-hover:opacity-100 transition-opacity",children:"Streaming"})]}),(0,t.jsx)("div",{className:"text-[15px] text-[var(--foreground)] leading-relaxed min-h-[1.5rem] flex items-center",children:n?(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)(u.Markdown,{content:l}),(0,t.jsx)("span",{className:"inline-flex items-baseline ml-0.5",children:(0,t.jsx)("span",{className:"w-1 h-1 rounded-full bg-indigo-400 animate-[pulse-dot_1.4s_ease-in-out_infinite]"})})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2 text-[var(--muted-foreground)] italic",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:"working"}),(0,t.jsx)(m,{})]})})]})]})}var x=e.i(575479),g=e.i(80673);function v({attachments:e,compact:a=!1}){if(0===e.length)return null;let r=e.filter(e=>e.mimeType.startsWith("image/")),s=e.filter(e=>!e.mimeType.startsWith("image/")),l=a?"max-w-[120px]":"max-w-[240px]",n=a?"max-h-[90px]":"max-h-[180px]";return(0,t.jsxs)("div",{className:"mt-2 space-y-2",children:[r.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.map(e=>(0,t.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"block rounded-lg overflow-hidden border border-[var(--border)] hover:border-[var(--border)] transition-colors",children:(0,t.jsx)("img",{src:e.url,alt:e.filename,className:`${l} ${n} object-cover`,loading:"lazy"})},e.id))}),s.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:s.map(e=>{var r;return(0,t.jsxs)("a",{href:e.url,download:e.filename,className:`inline-flex items-center gap-1.5 rounded-md border border-[var(--border)] bg-[var(--app-shell-subtle)] text-[var(--muted-foreground)] hover:bg-[var(--muted)] hover:border-[var(--border)] transition-colors ${a?"px-2 py-0.5 text-[11px]":"px-2.5 py-1 text-xs"}`,children:[(0,t.jsx)(x.FileText,{className:`text-[var(--muted-foreground)] shrink-0 ${a?"w-3 h-3":"w-3.5 h-3.5"}`}),(0,t.jsx)("span",{className:`truncate ${a?"max-w-[100px]":"max-w-[150px]"}`,children:e.filename}),(0,t.jsx)("span",{className:"text-[var(--muted-foreground)] shrink-0",children:(r=e.size)<1024?`${r}B`:r<1048576?`${(r/1024).toFixed(0)}KB`:`${(r/1048576).toFixed(1)}MB`}),(0,t.jsx)(g.Download,{className:`text-[var(--muted-foreground)] shrink-0 ${a?"w-2.5 h-2.5":"w-3 h-3"}`})]},e.id)})})]})}var b=e.i(997626),j=e.i(363732);let w=(0,j.default)("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);var y=e.i(498027),k=e.i(367859),N=e.i(929870),C=e.i(797167);let S=(0,j.default)("arrow-up-right",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);var I=e.i(19035),T=e.i(529471),M=e.i(247167);let $=M.default.env.NEXT_PUBLIC_AGX_BOARD_URL||"http://localhost:41741";async function R(){let e=await fetch(`${$}/api/projects`);if(!e.ok){if(503===e.status)throw Error("SCHEMA_NOT_READY");throw Error(`Failed to list projects: ${e.status}`)}let t=await e.json();return t.projects??t}async function P(e,t){let a=await fetch(`${$}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,description:t})});if(!a.ok)throw Error(`Failed to create project: ${a.status}`);return a.json()}async function A(e,t){let a=await fetch(`${$}/api/tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:e,...t})});if(!a.ok)throw Error(`Failed to create task: ${a.status}`);let r=await a.json(),s=r.task??r;return r.id&&!s.id&&(s.id=r.id),s}async function E(e){let t=await fetch(`${$}/api/tasks/${e}`);if(!t.ok)return null;let a=await t.json();return a.task??a}async function _(e,t,a,r){let s=[],l={...r},n=new Map((function(e){let t=new Set(e.map(e=>e.id)),a=new Map;for(let r of e)a.set(r.id,(r.dependsOn||[]).filter(e=>t.has(e)));let r=[],s=new Set,l=new Set;for(let t of e)!function t(n){if(!s.has(n)&&!l.has(n)){for(let e of(l.add(n),a.get(n)||[]))t(e);l.delete(n),s.add(n),r.push(e.find(e=>e.id===n))}}(t.id);return r})(e).map(e=>[e.id,e]));for(;n.size>0;){let e=[];for(let t of n.values())(t.dependsOn||[]).every(e=>!n.has(e)||l[e])&&e.push(t);0===e.length&&e.push(...n.values());let a=await Promise.allSettled(e.map(async e=>{let a=l[e.id];if(a&&await E(a))return{task:e,remoteId:a};let r=(e.dependsOn||[]).map(e=>l[e]).filter(Boolean),s=await A(e.description,{title:e.title,project_id:t,depends_on:r.length>0?r:void 0});return{task:e,remoteId:s.id}}));for(let t of a)if("fulfilled"===t.status){let{task:e,remoteId:a}=t.value;l[e.id]=a,s.push({clientTaskId:e.id,remoteTaskId:a,status:"created"}),n.delete(e.id)}else{let r=e[a.indexOf(t)];s.push({clientTaskId:r.id,status:"failed",error:t.reason instanceof Error?t.reason.message:"Unknown error"}),n.delete(r.id)}}return{buildId:a,projectId:t,results:s}}var O=e.i(906724),U=e.i(538292),z=e.i(958164);function D({onSelect:e,onClose:r}){let[s,l]=(0,a.useState)([]),[n,i]=(0,a.useState)(!0),[o,d]=(0,a.useState)(null),[c,u]=(0,a.useState)(!1),[p,h]=(0,a.useState)(""),[m,f]=(0,a.useState)(!1);(0,a.useEffect)(()=>{(async()=>{try{let e=await R();l(e)}catch(e){e instanceof Error&&"SCHEMA_NOT_READY"===e.message?d("agx-cloud database not ready. Run migrations first."):d("Failed to load projects. Is agx-cloud running?")}finally{i(!1)}})()},[]);let x=(0,a.useCallback)(async()=>{let t=p.trim();if(t){u(!0);try{let a=await P(t);e(a.id,a.name)}catch(e){d("Failed to create project")}finally{u(!1)}}},[p,e]);return(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/20 backdrop-blur-sm",children:(0,t.jsxs)("div",{className:"bg-[var(--app-shell-elevated)] rounded-2xl shadow-xl border border-[var(--app-shell-border)] w-full max-w-sm mx-4 overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-[var(--app-shell-border)]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(U.FolderOpen,{className:"w-4 h-4 text-[var(--app-shell-muted)]"}),(0,t.jsx)("h3",{className:"text-sm font-bold text-[var(--foreground)]",children:"Select Project"})]}),(0,t.jsx)("button",{type:"button",onClick:r,className:"p-1 text-[var(--app-shell-muted)] hover:text-[var(--foreground)] rounded-md hover:bg-[var(--app-shell-subtle)]",children:(0,t.jsx)(C.X,{className:"w-4 h-4"})})]}),(0,t.jsxs)("div",{className:"p-4 max-h-64 overflow-y-auto",children:[n&&(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)(O.Loader2,{className:"w-5 h-5 text-[var(--app-shell-muted)] animate-spin"})}),o&&(0,t.jsxs)("div",{className:"flex items-center gap-2 p-3 bg-amber-50 rounded-lg text-amber-700 text-xs font-medium",children:[(0,t.jsx)(z.AlertTriangle,{className:"w-4 h-4 shrink-0"}),o]}),!n&&!o&&0===s.length&&(0,t.jsx)("p",{className:"text-xs text-[var(--app-shell-muted)] text-center py-4",children:"No projects found. Create one below."}),!n&&s.map(a=>(0,t.jsxs)("button",{type:"button",onClick:()=>e(a.id,a.name),className:"w-full text-left px-3 py-2.5 rounded-lg hover:bg-[var(--app-shell-subtle)] transition-colors flex items-center gap-3 group",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-lg bg-[var(--app-shell-subtle)] flex items-center justify-center shrink-0",children:(0,t.jsx)(U.FolderOpen,{className:"w-4 h-4 text-[var(--app-shell-muted)] group-hover:text-[var(--foreground)]"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-[var(--foreground)] truncate",children:a.name}),a.description&&(0,t.jsx)("div",{className:"text-[11px] text-[var(--app-shell-muted)] truncate",children:a.description})]})]},a.id))]}),(0,t.jsx)("div",{className:"px-4 pb-4 pt-2 border-t border-[var(--app-shell-border)]",children:m?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{type:"text",value:p,onChange:e=>h(e.target.value),onKeyDown:e=>"Enter"===e.key&&x(),placeholder:"Project name",autoFocus:!0,className:"flex-1 h-8 px-3 text-sm bg-[var(--input)] border border-[var(--app-shell-border)] rounded-lg outline-none focus:ring-1 focus:ring-[var(--ring)] text-[var(--foreground)]"}),(0,t.jsx)("button",{type:"button",onClick:x,disabled:c||!p.trim(),className:"h-8 px-3 text-xs font-bold text-[var(--primary-foreground)] bg-[var(--primary)] hover:bg-[var(--primary-hover)] rounded-lg disabled:opacity-40",children:c?"…":"Create"}),(0,t.jsx)("button",{type:"button",onClick:()=>f(!1),className:"h-8 px-2 text-[var(--app-shell-muted)] hover:text-[var(--foreground)]",children:(0,t.jsx)(C.X,{className:"w-3.5 h-3.5"})})]}):(0,t.jsxs)("button",{type:"button",onClick:()=>f(!0),className:"flex items-center gap-1.5 text-xs font-bold text-[var(--muted-foreground)] hover:text-[var(--foreground)]",children:[(0,t.jsx)(N.Plus,{className:"w-3.5 h-3.5"}),"Create new project"]})})]})})}function L({draft:e,onUpdate:r,onBuild:s,building:l}){let[n,i]=(0,a.useState)(null),[o,d]=(0,a.useState)(!1),[c,u]=(0,a.useState)(!1),p=(0,a.useCallback)(()=>{let t=e.tasks.map((e,t)=>{let a=`${t+1}. **${e.title}**`;return e.description&&"Add description..."!==e.description&&(a+=`
2
- ${e.description.replace(/\n/g,"\n ")}`),a}).join("\n");navigator.clipboard.writeText(t).then(()=>{u(!0),setTimeout(()=>u(!1),1500)})},[e.tasks]),h=(0,a.useCallback)((t,a)=>{let s=e.tasks.map(e=>e.id===t?{...e,...a}:e);r({...e,tasks:s,revision:e.revision+1})},[e,r]),m=(0,a.useCallback)(t=>{let a=e.tasks.filter(e=>e.id!==t);r({...e,tasks:a,revision:e.revision+1})},[e,r]),f=(0,a.useCallback)(()=>{let t={id:crypto.randomUUID(),title:"New task",description:"Add description..."};r({...e,tasks:[...e.tasks,t],revision:e.revision+1})},[e,r]),x=(0,a.useCallback)(()=>{d(!0)},[]),g=(0,a.useCallback)((t,a)=>{d(!1),s(e,t,a)},[e,s]),v="idle"===e.buildStatus||!e.buildStatus;return(0,t.jsxs)("div",{className:"mt-6 p-4 bg-[var(--app-shell-subtle)]/80 rounded-2xl border border-[var(--border)] shadow-sm",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(b.Zap,{className:"w-3.5 h-3.5 text-amber-500 fill-amber-500"}),(0,t.jsx)("span",{className:"text-[10px] font-extrabold uppercase tracking-widest text-[var(--muted-foreground)]",children:"Tasks"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("span",{className:"text-[11px] font-bold text-[var(--muted-foreground)]",children:[e.tasks.length," task",1!==e.tasks.length?"s":""]}),e.tasks.length>0&&(0,t.jsx)("button",{type:"button",onClick:p,className:"text-[var(--muted-foreground)] hover:text-[var(--muted-foreground)] transition-colors",title:"Copy as markdown",children:c?(0,t.jsx)(T.Check,{className:"w-3.5 h-3.5 text-emerald-500"}):(0,t.jsx)(I.Copy,{className:"w-3.5 h-3.5"})})]})]}),(0,t.jsx)("div",{className:"space-y-1 mb-4",children:e.tasks.map(e=>{let a=n===e.id;return(0,t.jsxs)("div",{className:"group",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 py-1.5 px-2 rounded-lg hover:bg-[var(--app-shell-subtle)] transition-colors",children:[v&&(0,t.jsx)(w,{className:"w-3.5 h-3.5 text-[var(--app-shell-soft-text)] opacity-0 group-hover:opacity-100 cursor-grab shrink-0"}),(0,t.jsx)("button",{type:"button",onClick:()=>i(a?null:e.id),className:"shrink-0 text-[var(--app-shell-muted)] hover:text-[var(--foreground)]",children:a?(0,t.jsx)(y.ChevronDown,{className:"w-3.5 h-3.5"}):(0,t.jsx)(k.ChevronRight,{className:"w-3.5 h-3.5"})}),v?(0,t.jsx)("input",{type:"text",value:e.title,onChange:t=>h(e.id,{title:t.target.value}),className:"flex-1 text-xs font-semibold text-[var(--foreground)] bg-transparent border-none outline-none focus:ring-0 p-0"}):(0,t.jsx)("span",{className:"flex-1 text-xs font-semibold text-[var(--foreground)]",children:e.title}),v&&(0,t.jsx)("button",{type:"button",onClick:()=>m(e.id),className:"shrink-0 text-[var(--app-shell-soft-text)] hover:text-rose-500 opacity-0 group-hover:opacity-100 transition-all",children:(0,t.jsx)(C.X,{className:"w-3.5 h-3.5"})})]}),a&&(0,t.jsx)("div",{className:"ml-9 mr-2 mb-2",children:v?(0,t.jsx)("textarea",{value:e.description,onChange:t=>h(e.id,{description:t.target.value}),rows:4,className:"w-full text-xs text-[var(--muted-foreground)] bg-[var(--input)] border border-[var(--app-shell-border)] rounded-lg p-2 outline-none focus:ring-1 focus:ring-[var(--ring)] resize-y"}):(0,t.jsx)("p",{className:"text-xs text-[var(--muted-foreground)] whitespace-pre-wrap",children:e.description})})]},e.id)})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[v&&(0,t.jsxs)("button",{type:"button",onClick:f,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-bold text-[var(--app-shell-muted)] hover:text-[var(--foreground)] rounded-full border border-dashed border-[var(--app-shell-border)] hover:border-[var(--app-shell-border-strong)] transition-all",children:[(0,t.jsx)(N.Plus,{className:"w-3 h-3"}),"Add task"]}),(0,t.jsx)("div",{className:"flex-1"}),v&&(0,t.jsxs)("button",{type:"button",onClick:x,disabled:l||0===e.tasks.length,className:"flex items-center gap-1.5 px-4 py-1.5 text-xs font-bold text-[var(--primary-foreground)] bg-[var(--primary)] hover:bg-[var(--primary-hover)] rounded-full shadow-sm transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:[(0,t.jsx)(S,{className:"w-3 h-3"}),l?"Pushing…":"Push to agx"]})]}),o&&(0,t.jsx)(D,{onSelect:g,onClose:()=>d(!1)})]})}let F=new Set(["completed","done","failed","blocked"]);var B=e.i(807087),W=e.i(211464);let q=(0,j.default)("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]);var V=e.i(437307);let J={queued:(0,t.jsx)(W.Circle,{className:"w-4 h-4 text-[var(--muted-foreground)]"}),pending:(0,t.jsx)(W.Circle,{className:"w-4 h-4 text-[var(--muted-foreground)]"}),in_progress:(0,t.jsx)(O.Loader2,{className:"w-4 h-4 text-blue-500 animate-spin"}),running:(0,t.jsx)(O.Loader2,{className:"w-4 h-4 text-blue-500 animate-spin"}),blocked:(0,t.jsx)(q,{className:"w-4 h-4 text-amber-500"}),completed:(0,t.jsx)(B.CheckCircle2,{className:"w-4 h-4 text-emerald-500"}),done:(0,t.jsx)(B.CheckCircle2,{className:"w-4 h-4 text-emerald-500"}),failed:(0,t.jsx)(V.XCircle,{className:"w-4 h-4 text-rose-500"})};function H({draft:e,onPush:r,pushing:s}){let[l,n]=(0,a.useState)(!1),[i,o]=(0,a.useState)(!1),d=(0,a.useCallback)(()=>{let t=e.tasks.map((e,t)=>`${t+1}. **${e.title}**${e.description?`
3
- ${e.description.replace(/\n/g,"\n ")}`:""}`).join("\n");navigator.clipboard.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})},[e.tasks]),{tasks:c,error:u}=function({projectId:e,enabled:t,interval:r=3e4}){let[s,l]=(0,a.useState)([]),[n,i]=(0,a.useState)(null),o=(0,a.useRef)(0),d=(0,a.useRef)([]),c=(0,a.useCallback)(async()=>{if(e&&"undefined"!==e)try{let t=M.default.env.NEXT_PUBLIC_AGX_BOARD_URL||"http://localhost:41741",a=await fetch(`${t}/api/tasks?project=${e}`);if(!a.ok)throw Error(`Poll failed: ${a.status}`);let r=await a.json(),s=r.tasks??r;d.current=s,l(s),i(null)}catch(e){i(e instanceof Error?e.message:"Poll failed")}},[e]);return(0,a.useEffect)(()=>{if(!t||!e)return;o.current=Date.now(),c();let a=setInterval(()=>{Date.now()-o.current>18e5||d.current.length>0&&d.current.every(e=>F.has(e.status))?clearInterval(a):c()},r);return()=>clearInterval(a)},[t,e,r,c]),{tasks:s,error:n,refetch:c}}({projectId:e.projectId??null,enabled:!!e.projectId&&"done"===e.buildStatus}),p=new Map;if(e.builtTaskIds)for(let[t,a]of Object.entries(e.builtTaskIds)){let e=c.find(e=>e.id===a);e&&p.set(t,e)}let h=e.tasks.filter(e=>{let t=p.get(e.id);return t&&("completed"===t.status||"done"===t.status)}).length,m=e.tasks.length>0?h/e.tasks.length:0,f=(0,a.useCallback)(()=>{e.projectId&&e.projectName?r?.(e,e.projectId,e.projectName):n(!0)},[e,r]),x=(0,a.useCallback)((t,a)=>{n(!1),r?.(e,t,a)},[e,r]);e.tasks.some(t=>!e.builtTaskIds?.[t.id]);let g=e.tasks.some(e=>{let t=p.get(e.id);return t&&"queued"!==t.status&&"pending"!==t.status});return(0,t.jsxs)("div",{className:"mt-6 p-4 bg-[var(--app-shell-subtle)]/80 rounded-2xl border border-[var(--border)] shadow-sm",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(b.Zap,{className:"w-3.5 h-3.5 text-amber-500 fill-amber-500"}),(0,t.jsx)("span",{className:"text-[10px] font-extrabold uppercase tracking-widest text-[var(--muted-foreground)]",children:"Tasks"}),e.projectName&&(0,t.jsxs)("span",{className:"text-[10px] font-semibold text-[var(--muted-foreground)]",children:["· ",e.projectName]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("span",{className:"text-[11px] font-bold text-[var(--muted-foreground)]",children:[h,"/",e.tasks.length," Complete"]}),e.tasks.length>0&&(0,t.jsx)("button",{type:"button",onClick:d,className:"text-[var(--muted-foreground)] hover:text-[var(--muted-foreground)] transition-colors",title:"Copy as markdown",children:i?(0,t.jsx)(T.Check,{className:"w-3.5 h-3.5 text-emerald-500"}):(0,t.jsx)(I.Copy,{className:"w-3.5 h-3.5"})})]})]}),(0,t.jsx)("div",{className:"space-y-3 mb-4",children:e.tasks.map(e=>{let a=p.get(e.id),r=a?.status||"queued",s=J[r]||J.queued;return(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[s,(0,t.jsx)("span",{className:"text-xs font-semibold text-[var(--muted-foreground)]",children:e.title})]},e.id)})}),(0,t.jsx)("div",{className:"h-1.5 w-full bg-[var(--muted)] rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"h-full bg-emerald-500 rounded-full shadow-[0_0_8px_rgba(16,185,129,0.4)] transition-all duration-500",style:{width:`${Math.round(100*m)}%`}})}),r&&!g&&(0,t.jsxs)("div",{className:"mt-3 flex items-center gap-3",children:["partial_failure"===e.buildStatus&&(0,t.jsx)("span",{className:"text-[11px] text-amber-600 font-semibold",children:"Some tasks failed to push."}),(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsxs)("button",{type:"button",onClick:f,disabled:s,className:"flex items-center gap-1.5 px-4 py-1.5 text-xs font-bold text-[var(--primary-foreground)] bg-[var(--primary)] hover:bg-[var(--primary-hover)] rounded-full shadow-sm transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:[(0,t.jsx)(S,{className:"w-3 h-3"}),s?"Pushing…":"Push to agx"]})]}),u&&(0,t.jsxs)("div",{className:"mt-2 text-[11px] text-amber-600 font-medium",children:["Status polling error: ",u]}),l&&(0,t.jsx)(D,{onSelect:x,onClose:()=>n(!1)})]})}let X=(0,a.forwardRef)(({children:e,className:a="",...r},s)=>{let{isTouchLayout:l}=(0,o.useInputCapabilities)(),n=`absolute top-4 right-4 flex items-center gap-1 ${l?"opacity-100":"opacity-0 group-hover:opacity-100"} transition-opacity duration-200 bg-[var(--app-shell-elevated)] border border-[var(--app-shell-border)] shadow-md rounded-lg p-1 z-10 backdrop-blur-sm`,i=`${n} ${a}`.trim();return(0,t.jsx)("div",{ref:s,className:i,"data-touch-visible":l?"true":void 0,...r,children:e})});X.displayName="ActionToolbar";let K=()=>(0,t.jsx)("div",{className:"w-px h-4 bg-[var(--app-shell-border)] mx-1"}),G=(0,a.forwardRef)(({className:e="",variant:a="neutral",size:r="md",children:s,...l},n)=>{let{isTouchLayout:i}=(0,o.useInputCapabilities)(),d=`inline-flex items-center justify-center rounded-md transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)] disabled:opacity-50 disabled:pointer-events-none ${i?({sm:"h-11 w-11 p-2",md:"h-11 w-11 p-2",lg:"h-12 w-12 p-2.5"})[r]:({sm:"p-1 w-6 h-6",md:"p-1.5 w-8 h-8",lg:"p-2 w-10 h-10"})[r]} ${({neutral:"text-[var(--app-shell-muted)] hover:text-[var(--foreground)] hover:bg-[var(--app-shell-subtle)]",ghost:"text-[var(--muted-foreground)] hover:text-[var(--foreground)] hover:bg-[var(--muted)]",primary:"text-[var(--primary)] hover:text-[var(--primary-foreground)] hover:bg-[var(--primary-hover)]",destructive:"text-[var(--app-shell-muted)] hover:text-[var(--destructive)] hover:bg-[var(--destructive-muted)]"})[a]} ${e}`.trim();return(0,t.jsx)("button",{ref:n,className:d,"data-touch-target":i?"true":void 0,...l,children:s})});G.displayName="IconButton";var Y=e.i(597628),Z=e.i(629155),Q=e.i(794731),ee=e.i(169610),et=e.i(580873);let ea=(0,j.default)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]),er=(0,j.default)("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),es=(0,j.default)("at-sign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);var el=e.i(999824);let en=[{value:"active",label:"Active",color:"#f59e0b"},{value:"paused",label:"Paused",color:"#f97316"},{value:"in-review",label:"In Review",color:"#6b7280"},{value:"done",label:"Done",color:"#3b82f6"},{value:"archived",label:"Archived",color:"#9ca3af"}],ei=new Set(["done","in-review","archived"]),eo="<!-- thread-summary -->";function ed({messages:e,streaming:r,participants:s,onOpenThread:l,onCopyThread:n,onAddToChat:i,onDeleteThreadRoot:o,onSummarize:d,onCreateTasks:m,onUpdateTaskDraft:x,onBuildTasks:g,summarizingThreads:b,extractingTasks:j,buildingDrafts:w,taskDrafts:y,deletingThreadRootId:k,highlightedMessageId:N,onUpdateMessageThreadStatus:C,onUpdateMessageOutcomeNote:S,shipModeThreads:T}){let M=(0,a.useRef)(new Map),[$,R]=(0,a.useState)(null),[P,A]=(0,a.useState)("active"),E=Object.fromEntries(s.map(e=>[e.id,e])),_=(0,a.useMemo)(()=>[...e.filter(e=>!e.rootMessageId)].reverse(),[e]),U={active:new Set(["active"]),paused:new Set(["paused"]),"in-review":new Set(["in-review"]),done:new Set(["done"]),archived:new Set(["archived"])},z=(0,a.useMemo)(()=>_.filter(e=>U[P].has(e.threadStatus??"active")),[_,P]),D=(0,a.useMemo)(()=>({active:_.filter(e=>U.active.has(e.threadStatus??"active")).length,paused:_.filter(e=>U.paused.has(e.threadStatus??"active")).length,"in-review":_.filter(e=>U["in-review"].has(e.threadStatus??"active")).length,done:_.filter(e=>U.done.has(e.threadStatus??"active")).length,archived:_.filter(e=>U.archived.has(e.threadStatus??"active")).length}),[_]),F=(0,a.useMemo)(()=>(function(e){let t=new Map;for(let a of e){let e=a.rootMessageId;if(!e)continue;let r=t.get(e);r||(r={rootMessageId:e,replyCount:0,participants:[],lastActivityAt:0,allReplies:[]},t.set(e,r)),r.replyCount++,r.lastActivityAt=Math.max(r.lastActivityAt,a.timestamp),r.lastReply=a,r.allReplies.push(a),a.participantId&&!r.participants.includes(a.participantId)?r.participants.push(a.participantId):a.participantId||r.participants.includes("user")||r.participants.push("user")}for(let e of t.values())e.allReplies.sort((e,t)=>e.timestamp-t.timestamp);return t})(e),[e]),B=(0,a.useCallback)((e,t)=>{t?M.current.set(e,t):M.current.delete(e)},[]),W=(0,a.useRef)(null);return(0,a.useEffect)(()=>{if(!N){W.current=null;return}if(N===W.current)return;W.current=N;let e=M.current.get(N);e&&e.scrollIntoView({behavior:"smooth",block:"center"})},[N,e]),(0,t.jsx)("div",{className:"chat-scrollbar flex-1 overflow-y-auto p-4",children:(0,t.jsxs)("div",{className:"max-w-3xl mx-auto",children:[_.length>0&&(0,t.jsx)("div",{className:"flex items-center justify-center gap-1 p-1 rounded-lg w-fit mx-auto border border-[var(--app-shell-border)] bg-[var(--app-shell-subtle)] mb-4",children:[{key:"active",label:"Active"},{key:"paused",label:"Paused"},{key:"in-review",label:"In Review"},{key:"done",label:"Done"},{key:"archived",label:"Archived"}].map(e=>{let a=D[e.key],r=P===e.key;return(0,t.jsxs)("button",{type:"button",onClick:()=>A(e.key),className:`px-3 py-1.5 text-xs font-bold rounded-md transition-all ${r?"bg-[var(--app-shell-surface)] text-[var(--foreground)] shadow-sm":"text-[var(--app-shell-muted)] hover:text-[var(--foreground)]"}`,children:[e.label,a>0&&(0,t.jsx)("span",{className:`ml-1.5 text-[10px] ${r?"opacity-60":"opacity-50"}`,children:a})]},e.key)})}),0===_.length&&0===Object.keys(r).length&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center text-[var(--app-shell-muted)] mt-32 space-y-3",children:[(0,t.jsx)(Y.MessageSquare,{className:"h-6 w-6",strokeWidth:1.5}),(0,t.jsx)("span",{className:"text-sm font-medium tracking-wide",children:"Start a thread"})]}),_.length>0&&0===z.length&&(0,t.jsx)("div",{className:"flex flex-col items-center justify-center text-[var(--app-shell-muted)] mt-16 space-y-2",children:(0,t.jsxs)("span",{className:"text-sm font-medium",children:["No ",P," threads"]})}),z.map(e=>{let a,s=e.participantId?E[e.participantId]:null,N=F.get(e.id),S=k===e.id,M=N?.allReplies.find(e=>e.content.startsWith(eo)),P=M?M.content.slice(eo.length).trim():null,A=e.threadStatus??"active",_=ei.has(A),U=en.find(e=>e.value===A)??en[0],z=Object.values(r).some(t=>t.rootMessageId===e.id);if(_){let a;return(0,t.jsx)("div",{ref:t=>B(e.id,t),"data-message-id":e.id,className:`max-w-2xl mx-auto bg-[var(--app-shell-subtle)] rounded-xl border border-[var(--app-shell-border)] mb-3 group transition-all hover:border-[var(--app-shell-border-strong)] relative cursor-pointer ${$===e.id?"z-50":""}`,onClick:()=>l?.(e.id),children:(0,t.jsxs)("div",{className:"px-4 py-2.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(Z.Hash,{className:"w-3.5 h-3.5 text-[var(--app-shell-muted)] shrink-0"}),(0,t.jsx)("span",{className:"text-sm font-medium text-[var(--app-shell-muted)] truncate flex-1",children:(0,h.stripMarkers)(e.content.split("\n")[0])}),T?.has(e.id)&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] text-indigo-500 font-medium shrink-0",title:"Ship Mode active",children:[(0,t.jsx)(el.Rocket,{size:11,style:{animation:"shipPulse 2s ease-in-out infinite"}}),"Ship"]}),z&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] text-green-600 font-medium shrink-0",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 animate-pulse"}),"Working"]}),e.outcomeNote&&(0,t.jsx)("span",{className:"text-[11px] text-[var(--app-shell-soft-text)] truncate max-w-[200px]",children:e.outcomeNote}),(0,t.jsx)("span",{className:"text-[10px] text-[var(--app-shell-soft-text)] shrink-0",children:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(e.timestamp)}),C&&(a=$===e.id,(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("button",{type:"button",onClick:t=>{t.stopPropagation(),R(a?null:e.id)},className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-semibold border transition-colors hover:bg-[var(--app-shell-elevated)]",style:{borderColor:U.color+"40",color:U.color},children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:U.color}}),U.label]}),a&&(0,t.jsx)("div",{className:"absolute top-full right-0 mt-1 z-50 bg-[var(--app-shell-elevated)] border border-[var(--app-shell-border)] rounded-lg shadow-lg p-1 min-w-[8.5rem]",onClick:e=>e.stopPropagation(),children:en.map(a=>(0,t.jsxs)("button",{type:"button",className:`flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-xs font-medium transition-colors ${a.value===A?"bg-[var(--primary-muted)] text-[var(--primary)]":"text-[var(--muted-foreground)] hover:bg-[var(--app-shell-subtle)]"}`,onClick:t=>{t.stopPropagation(),C(e.id,a.value),R(null)},children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:a.color}}),a.label]},a.value))})]})),N&&N.replyCount>0&&(0,t.jsxs)("span",{className:"text-[10px] text-[var(--app-shell-muted)] shrink-0",children:[N.replyCount," replies"]})]}),(P||y?.[e.id])&&(0,t.jsxs)("div",{className:"mt-1.5 pl-6 flex flex-col gap-1",children:[P&&(0,t.jsx)("div",{className:"text-sm text-[var(--muted-foreground)] leading-relaxed prose prose-sm prose-neutralmax-w-none",children:(0,t.jsx)(u.Markdown,{content:P,isUser:!1})}),y?.[e.id]&&y[e.id].tasks.length>0&&(0,t.jsxs)("span",{className:"text-[10px] text-[var(--app-shell-muted)] flex items-center gap-1",children:[(0,t.jsx)(ea,{className:"w-3 h-3"}),y[e.id].tasks.length," ",1===y[e.id].tasks.length?"task":"tasks"]})]})]})},e.id)}return(0,t.jsxs)("div",{className:`max-w-2xl mx-auto surface-card mb-6 group relative ${$===e.id?"z-50":""}`,children:[(n||i||o)&&(0,t.jsxs)(X,{className:"z-10",children:[i&&(0,t.jsx)(G,{type:"button",variant:"primary",size:"sm",onClick:()=>i(e.id),title:"Mention in chat",children:(0,t.jsx)(es,{className:"w-3.5 h-3.5"})}),(0,t.jsx)(G,{type:"button",variant:"neutral",size:"sm",onClick:()=>{navigator.clipboard.writeText(e.id)},title:"Copy message ID",children:(0,t.jsx)(er,{className:"w-3.5 h-3.5"})}),n&&(0,t.jsx)(G,{type:"button",variant:"neutral",size:"sm",onClick:()=>n(e.id),title:"Copy thread as markdown",children:(0,t.jsx)(I.Copy,{className:"w-3.5 h-3.5"})}),o&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(K,{}),(0,t.jsx)(G,{type:"button",variant:"destructive",size:"sm",onClick:()=>o(e.id),disabled:S,title:"Delete this thread",children:S?(0,t.jsx)(O.Loader2,{className:"w-3.5 h-3.5 animate-spin"}):(0,t.jsx)(Q.Trash2,{className:"w-3.5 h-3.5"})})]})]}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("div",{className:"p-5",children:(0,t.jsxs)("div",{ref:t=>B(e.id,t),"data-message-id":e.id,className:"flex flex-col",children:[(0,t.jsxs)("div",{className:"flex gap-3 mb-4",children:["user"!==e.role&&(0,t.jsx)(c.default,{href:`/agents/${s?.id||e.participantId||"assistant"}`,className:"w-10 h-10 rounded-full bg-[var(--app-shell-subtle)] overflow-hidden border border-[var(--app-shell-border)] shadow-sm flex items-center justify-center shrink-0 hover:ring-2 hover:ring-[var(--ring)] transition-shadow",children:s?(0,t.jsx)("img",{src:(0,p.agentAvatarUrl)(s.id,40,s.color),alt:s.name,className:"w-full h-full object-cover"}):(0,t.jsx)("img",{src:(0,p.agentAvatarUrl)(e.participantId||"assistant",40),alt:e.participantId||"Assistant",className:"w-full h-full object-cover"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 pt-0.5",children:["user"!==e.role&&(0,t.jsx)("div",{className:"flex items-center gap-2 mb-0.5",children:(0,t.jsx)(c.default,{href:`/agents/${s?.id||e.participantId||"assistant"}`,className:"font-bold text-sm text-[var(--foreground)] hover:underline",children:s?.name||e.participantId||"Assistant"})}),(0,t.jsxs)("div",{className:"cursor-pointer group/msg-title mb-1",onClick:()=>l?.(e.id),children:[(0,t.jsx)("h3",{className:"text-lg font-bold text-[var(--foreground)] leading-tight group-hover/msg-title:text-[var(--primary)] transition-colors line-clamp-1",children:(0,h.stripMarkers)(e.content.split("\n")[0])}),(0,t.jsxs)("div",{className:"mt-1 flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-[11px] font-medium text-[var(--app-shell-soft-text)]",children:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(e.timestamp)}),C&&(a=$===e.id,(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("button",{type:"button",onClick:t=>{t.stopPropagation(),R(a?null:e.id)},className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-semibold border transition-colors hover:bg-[var(--app-shell-subtle)]",style:{borderColor:U.color+"40",color:U.color},children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:U.color}}),U.label]}),a&&(0,t.jsx)("div",{className:"absolute top-full left-0 mt-1 z-50 bg-[var(--app-shell-elevated)] border border-[var(--app-shell-border)] rounded-lg shadow-lg p-1 min-w-[8.5rem]",onClick:e=>e.stopPropagation(),children:en.map(a=>(0,t.jsxs)("button",{type:"button",className:`flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-xs font-medium transition-colors ${a.value===A?"bg-[var(--primary-muted)] text-[var(--primary)]":"text-[var(--muted-foreground)] hover:bg-[var(--app-shell-subtle)]"}`,onClick:t=>{t.stopPropagation(),C(e.id,a.value),R(null)},children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:a.color}}),a.label]},a.value))})]})),T?.has(e.id)&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] text-indigo-500 font-medium",title:"Ship Mode active",children:[(0,t.jsx)(el.Rocket,{size:11,style:{animation:"shipPulse 2s ease-in-out infinite"}}),"Ship"]}),z&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] text-green-600 font-medium",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 animate-pulse"}),"Working"]})]}),(e.content.length>80||e.content.includes("\n"))&&(0,t.jsx)("div",{className:"mt-2 text-[15px] text-[var(--muted-foreground)] leading-relaxed line-clamp-3",children:(0,t.jsx)(u.Markdown,{content:(0,h.stripMarkers)(e.content.split("\n").slice(1).join("\n").trimStart()),isUser:"user"===e.role})})]})]})]}),e.attachments&&e.attachments.length>0&&(0,t.jsx)("div",{className:`mb-4 ${"user"!==e.role?"ml-[52px]":""}`,children:(0,t.jsx)(v,{attachments:e.attachments,compact:!0})}),P&&(0,t.jsx)("div",{className:"mb-4 text-sm text-[var(--muted-foreground)] leading-relaxed",children:(0,t.jsx)(u.Markdown,{content:P,isUser:!1})}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pt-2 mt-2 border-t border-[var(--card-border)]",children:[d&&N&&N.replyCount>0&&(0,t.jsxs)("button",{type:"button",onClick:()=>d(e.id),disabled:b?.has(e.id),className:"flex items-center gap-1.5 px-3 py-1.5 bg-[var(--app-shell-subtle)] hover:bg-[var(--item-hover-bg)] text-[var(--foreground)] border border-[var(--card-border)] text-xs font-medium rounded-lg transition-colors disabled:opacity-50",children:[b?.has(e.id)?(0,t.jsx)(O.Loader2,{className:"w-3.5 h-3.5 animate-spin text-[var(--muted-foreground)]"}):(0,t.jsx)(et.Clock,{className:"w-3.5 h-3.5 text-[var(--muted-foreground)]"}),b?.has(e.id)?"Summarizing…":"Summarize"]}),m&&N&&N.replyCount>0&&(0,t.jsxs)("button",{type:"button",onClick:()=>m(e.id),disabled:j?.has(e.id),className:"flex items-center gap-1.5 px-3 py-1.5 bg-[var(--app-shell-subtle)] hover:bg-[var(--item-hover-bg)] text-[var(--foreground)] border border-[var(--card-border)] text-xs font-medium rounded-lg transition-colors disabled:opacity-50",children:[j?.has(e.id)?(0,t.jsx)(O.Loader2,{className:"w-3.5 h-3.5 animate-spin text-[var(--muted-foreground)]"}):(0,t.jsx)(ea,{className:"w-3.5 h-3.5 text-[var(--muted-foreground)]"}),j?.has(e.id)?"Extracting…":y?.[e.id]?"Re-extract tasks":"Create tasks"]}),N&&N.replyCount>0&&l&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>l(e.id),children:[(0,t.jsxs)("span",{className:"text-xs text-[var(--muted-foreground)] font-medium",children:[N.replyCount," replies"]}),(0,t.jsx)("div",{className:"flex -space-x-2",children:N.participants.slice(0,3).map(e=>{if("user"===e)return(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-[var(--app-shell-subtle)] border-2 border-[var(--card-bg)] flex items-center justify-center z-10",children:(0,t.jsx)(ee.User,{className:"w-3 h-3 text-[var(--muted-foreground)]"})},"user");let a=E[e];return a?(0,t.jsx)("img",{src:(0,p.agentAvatarUrl)(e,24,a.color),alt:a.name,className:"w-6 h-6 rounded-full border-2 border-[var(--card-bg)] object-cover z-10"},e):(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-[var(--app-shell-subtle)] border-2 border-[var(--card-bg)] z-10"},e)})})]})]}),y?.[e.id]&&(y[e.id].builtTaskIds&&Object.keys(y[e.id].builtTaskIds).length>0?(0,t.jsx)(H,{draft:y[e.id],onPush:(t,a,r)=>g?.(e.id,t,a,r),pushing:w?.has(y[e.id].draftId)}):(0,t.jsx)(L,{draft:y[e.id],onUpdate:t=>x?.(e.id,t),onBuild:(t,a,r)=>g?.(e.id,t,a,r),building:w?.has(y[e.id].draftId)})),j?.has(e.id)&&(0,t.jsxs)("div",{className:"mt-4 flex items-center gap-2 text-xs text-[var(--app-shell-muted)]",children:[(0,t.jsx)(O.Loader2,{className:"w-3.5 h-3.5 animate-spin"}),(0,t.jsx)("span",{children:"Extracting tasks…"})]})]})}),Object.entries(r).filter(([,t])=>t.rootMessageId===e.id).map(([e,a])=>{let r=E[e];return(0,t.jsx)("div",{className:"px-6 pb-4",children:(0,t.jsx)(f,{participantId:e,participantName:r?.name||e,participantColor:r?.color||"#888",content:a.content})},`streaming-${e}`)})]})]},e.id)})]})})}let ec=(0,j.default)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]);var eu=e.i(519132);let ep={ack:{symbol:"👍",label:"Acknowledged"},working:{symbol:"🔄",label:"Working"},done:{symbol:"✅",label:"Done"},clarify:{symbol:"❓",label:"Needs clarification"},blocked:{symbol:"⛔",label:"Blocked"}};function eh({type:e,count:a,participantIds:r}){let s=ep[e],l=r.join(", "),n=l?`${s.label}: ${l}`:s.label;return(0,t.jsxs)("span",{title:n,className:"inline-flex items-center gap-1 rounded-full border border-[var(--app-shell-border)] bg-[var(--app-shell-surface)] px-2 py-0.5 text-xs text-[var(--foreground)]",children:[(0,t.jsx)("span",{"aria-hidden":!0,children:s.symbol}),(0,t.jsx)("span",{className:"tabular-nums",children:a})]})}function em({reactions:e}){if(!e||0===e.length)return null;let a=[...e].sort((e,t)=>t.count!==e.count?t.count-e.count:e.type.localeCompare(t.type));return(0,t.jsx)("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:a.map(e=>(0,t.jsx)(eh,{type:e.type,count:e.count,participantIds:e.participantIds},e.type))})}function ef({messages:e,streaming:r,participants:s,rootMessageId:l,queued:n=!1,onClose:i,onCopyThread:o,onAddToChat:d,onDeleteThreadRoot:m,onDeleteMessage:f,highlightedMessageId:x,renderReplyComposer:g,activeProcesses:b=[]}){let j=(0,a.useRef)(null),w=(0,a.useRef)(new Map),y=Object.fromEntries(s.map(e=>[e.id,e])),k=(0,a.useMemo)(()=>{let t=e.find(e=>e.id===l),a=e.filter(e=>e.rootMessageId===l).sort((e,t)=>e.timestamp-t.timestamp);return t?[t,...a]:a},[e,l]),N=(0,a.useRef)(null),C=(0,a.useRef)(!1),S=(0,a.useRef)(null);return(0,a.useEffect)(()=>{let e=N.current;if(!e)return;let t=()=>{let{scrollTop:t,scrollHeight:a,clientHeight:r}=e;C.current=a-t-r>80};return e.addEventListener("scroll",t,{passive:!0}),()=>e.removeEventListener("scroll",t)},[]),(0,a.useEffect)(()=>{if(x&&x!==S.current){S.current=x;let e=w.current.get(x);e&&e.scrollIntoView({behavior:"smooth",block:"center"})}else x||C.current||(S.current=null,j.current?.scrollIntoView({behavior:"smooth"}))},[x,k,r]),(0,t.jsxs)("div",{className:"flex flex-col h-full overflow-hidden bg-[var(--app-shell-bg)] transition-colors",children:[b.length>0&&(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-[var(--app-shell-border)] bg-[var(--app-shell-surface)] backdrop-blur-md transition-colors",children:[(0,t.jsxs)("div",{className:"inline-flex items-center gap-2 text-[11px] font-medium text-[var(--app-shell-muted)]",children:[(0,t.jsx)(eu.Sparkles,{className:"h-3.5 w-3.5 text-indigo-500",strokeWidth:1.75}),(0,t.jsx)("span",{className:"uppercase tracking-[0.16em]",children:"Working"})]}),(0,t.jsx)("div",{className:"flex items-center -space-x-1.5",children:b.map(e=>{let a=y[e.agentId];return(0,t.jsxs)("div",{className:"relative",title:`${a?.name||e.agentId} — ${e.state}`,children:[(0,t.jsx)("img",{src:(0,p.agentAvatarUrl)(e.agentId,24,a?.color),alt:a?.name||e.agentId,className:"w-6 h-6 rounded-full border-2 border-[var(--app-shell-surface)] shadow-sm"}),(0,t.jsx)("span",{className:"absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 bg-green-400 rounded-full border-2 border-[var(--app-shell-surface)] animate-pulse"})]},e.agentId)})})]}),(0,t.jsx)("div",{ref:N,className:"flex-1 overflow-y-auto p-4 md:p-8 space-y-6 chat-scrollbar",children:(0,t.jsxs)("div",{className:"max-w-2xl mx-auto space-y-8 pb-4",children:[k.map(e=>{let a,r="user"===e.role,s=e.participantId?y[e.participantId]:null;return(0,t.jsxs)("div",{ref:t=>{var a;return a=e.id,void(t?w.current.set(a,t):w.current.delete(a))},"data-message-id":e.id,className:"group relative flex gap-4 ",children:[(0,t.jsx)("div",{className:"flex-shrink-0 mt-1",children:r?(0,t.jsx)("div",{className:"w-9 h-9 bg-[var(--app-shell-subtle)] rounded-full flex items-center justify-center text-[var(--app-shell-muted)] shadow-sm",children:(0,t.jsx)(ee.User,{className:"w-5 h-5"})}):(0,t.jsx)(c.default,{href:`/agents/${s?.id||e.participantId||"assistant"}`,className:"hover:ring-2 hover:ring-[var(--ring)] rounded-full transition-shadow",children:(0,t.jsx)("img",{src:s?(0,p.agentAvatarUrl)(s.id,36,s.color):(0,p.agentAvatarUrl)(e.participantId||"assistant",36),alt:s?.name||e.participantId||"Assistant",className:"w-9 h-9 rounded-full shadow-sm border border-[var(--app-shell-border)] object-cover bg-[var(--app-shell-subtle)]"})})}),(0,t.jsxs)("div",{className:"flex-1 space-y-1.5 max-w-full overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[r?(0,t.jsx)("span",{className:"font-bold text-sm text-[var(--foreground)]",children:"You"}):(0,t.jsx)(c.default,{href:`/agents/${s?.id||e.participantId||"assistant"}`,className:"font-bold text-sm text-[var(--foreground)] hover:underline",style:s?.color?{color:s.color}:void 0,children:s?.name||e.participantId||"Assistant"}),void 0===e.rootMessageId&&e.id===l&&(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 bg-[var(--app-shell-elevated)] text-[var(--app-shell-muted)] rounded font-mono uppercase",children:"ROOT"}),(0,t.jsx)("span",{className:"text-[11px] text-[var(--app-shell-soft-text)]",children:(a=e.timestamp,new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(a))})]}),(0,t.jsxs)("div",{className:`surface-card rounded-2xl p-5 text-[15px] leading-relaxed ${e.id===x?"ring-2 ring-[var(--ring)]":""}`,children:[(0,t.jsx)(u.Markdown,{content:(0,h.stripMarkers)(e.content),isUser:r}),e.attachments&&e.attachments.length>0&&(0,t.jsx)(v,{attachments:e.attachments}),e.reactions&&e.reactions.length>0&&(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(em,{reactions:e.reactions})})]}),(0,t.jsxs)(X,{children:[e.id===l&&(0,t.jsx)(G,{variant:"primary",size:"sm",onClick:()=>navigator.clipboard.writeText(e.id),title:"Copy message ID",children:(0,t.jsx)(er,{className:"w-3.5 h-3.5"})}),e.id===l&&o&&(0,t.jsx)(G,{variant:"neutral",size:"sm",onClick:()=>o(e.id),title:"Copy Thread",children:(0,t.jsx)(ec,{className:"w-3.5 h-3.5"})}),(0,t.jsx)(G,{variant:"neutral",size:"sm",onClick:()=>navigator.clipboard.writeText(e.content),title:"Copy as Markdown",children:(0,t.jsx)(I.Copy,{className:"w-3.5 h-3.5"})}),e.id===l&&m&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(K,{}),(0,t.jsx)(G,{variant:"destructive",size:"sm",onClick:()=>m(e.id),title:"Delete Thread",children:(0,t.jsx)(Q.Trash2,{className:"w-3.5 h-3.5"})})]}),e.id!==l&&f&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(K,{}),(0,t.jsx)(G,{variant:"destructive",size:"sm",onClick:()=>f(e.id),title:"Delete Message",children:(0,t.jsx)(Q.Trash2,{className:"w-3.5 h-3.5"})})]})]})]})]},e.id)}),n&&0===b.length&&(0,t.jsxs)("div",{className:"flex gap-3 group relative opacity-80 animate-in fade-in slide-in-from-bottom-1 duration-300",children:[(0,t.jsx)("div",{className:"flex-shrink-0 mt-0.5",children:(0,t.jsx)("div",{className:"w-7 h-7 rounded-full border border-[var(--app-shell-border)] bg-[var(--app-shell-subtle)] flex items-center justify-center",children:(0,t.jsx)(eu.Sparkles,{className:"w-3.5 h-3.5 text-[var(--app-shell-soft-text)]",strokeWidth:1.5})})}),(0,t.jsx)("div",{className:"flex-1 max-w-full overflow-hidden",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 py-1",children:[(0,t.jsx)("span",{className:"text-xs tracking-wide text-[var(--app-shell-soft-text)]",children:"Processing"}),(0,t.jsxs)("span",{className:"inline-flex items-center gap-[3px]",children:[(0,t.jsx)("span",{className:"w-1 h-1 rounded-full bg-[var(--app-shell-soft-text)]/50 animate-[pulse-dot_1.4s_ease-in-out_infinite]"}),(0,t.jsx)("span",{className:"w-1 h-1 rounded-full bg-[var(--app-shell-soft-text)]/50 animate-[pulse-dot_1.4s_ease-in-out_0.2s_infinite]"}),(0,t.jsx)("span",{className:"w-1 h-1 rounded-full bg-[var(--app-shell-soft-text)]/50 animate-[pulse-dot_1.4s_ease-in-out_0.4s_infinite]"})]})]})})]}),Object.entries(r).filter(([,e])=>e.rootMessageId===l).map(([e,a])=>{let r=y[e],s=a.content.trim().length>0;return(0,t.jsxs)("div",{className:"flex gap-4 group relative animate-in fade-in slide-in-from-bottom-2 duration-300",children:[(0,t.jsx)("div",{className:"flex-shrink-0 mt-1",children:(0,t.jsx)(c.default,{href:`/agents/${r?.id||e}`,className:"hover:ring-2 hover:ring-[var(--ring)] rounded-full transition-shadow",children:(0,t.jsx)("img",{src:r?(0,p.agentAvatarUrl)(r.id,36,r.color):(0,p.agentAvatarUrl)(e,36),alt:r?.name||e,className:"w-9 h-9 rounded-full shadow-sm border border-[var(--app-shell-border)] object-cover bg-[var(--app-shell-subtle)]"})})}),(0,t.jsxs)("div",{className:"flex-1 space-y-1.5 max-w-full overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(c.default,{href:`/agents/${r?.id||e}`,className:"font-bold text-sm text-[var(--foreground)] hover:underline",style:r?.color?{color:r.color}:void 0,children:r?.name||e}),!s&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-[3px]",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--app-shell-muted)] animate-[pulse-dot_1.4s_ease-in-out_infinite]"}),(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--app-shell-muted)] animate-[pulse-dot_1.4s_ease-in-out_0.2s_infinite]"}),(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--app-shell-muted)] animate-[pulse-dot_1.4s_ease-in-out_0.4s_infinite]"})]})]}),s&&(0,t.jsx)("div",{className:"surface-card rounded-2xl p-5 text-[15px] leading-relaxed",children:(0,t.jsx)(u.Markdown,{content:(0,h.stripMarkers)(a.content),isUser:!1})})]})]},`streaming-${e}`)}),(0,t.jsx)("div",{ref:j,className:"h-4"})]})}),(0,t.jsx)("div",{className:"z-20 transition-colors duration-200",children:g(l)})]})}var ex=e.i(51297);let eg=(0,j.default)("search-x",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);function ev({query:e,results:a,total:r,participants:s,threadTitleById:l,isLoading:n,error:i,onSelectResult:o,headerSlot:d}){let u=Object.fromEntries(s.map(e=>[e.id,e]));return(0,t.jsx)("div",{className:"chat-scrollbar flex-1 overflow-y-auto p-4",children:(0,t.jsxs)("div",{className:"max-w-3xl mx-auto",children:[d?(0,t.jsx)("div",{className:"sticky top-0 z-20 bg-[var(--app-shell-subtle)]/70 backdrop-blur-md pt-4 pb-6 px-4 -mx-4 border-b border-transparent transition-colors",children:(0,t.jsx)("div",{className:"max-w-2xl mx-auto",children:d})}):null,(0,t.jsxs)("div",{className:"mb-4 rounded-xl border border-[var(--card-border)] bg-[var(--card-bg)] px-4 py-3",children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-[var(--foreground)]",children:"Search results"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-[var(--muted-foreground)]",children:n?"Searching…":`${r} result${1===r?"":"s"} for "${e}"`}),i?(0,t.jsx)("div",{className:"mt-2 text-sm text-rose-600",children:i}):null]}),n||i||0!==a.length?null:(0,t.jsxs)("div",{className:"mt-20 flex flex-col items-center justify-center space-y-2 text-[var(--app-shell-muted)]",children:[(0,t.jsx)(eg,{className:"h-6 w-6",strokeWidth:1.5}),(0,t.jsx)("p",{className:"text-sm font-medium",children:"No matching messages"})]}),(0,t.jsx)("div",{className:"space-y-3 pb-6",children:a.map(e=>{var a;let r=e.participantId?u[e.participantId]:null,s=l[e.threadId]||"Untitled thread",n="user"===e.role?"You":r?.name||e.participantId||"Assistant";return(0,t.jsxs)("button",{type:"button",onClick:()=>o(e),className:"w-full rounded-xl border border-[var(--border)] bg-[var(--card-bg)] p-4 text-left transition hover:border-[var(--border)] hover:shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-slate-400",children:[(0,t.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)("div",{className:"flex h-8 w-8 items-center justify-center overflow-hidden rounded-full bg-[var(--muted)]",children:"user"===e.role?(0,t.jsx)(ee.User,{className:"h-4 w-4 text-[var(--foreground)]"}):r?(0,t.jsx)(c.default,{href:`/agents/${r.id}`,onClick:e=>e.stopPropagation(),className:"h-full w-full hover:ring-2 hover:ring-blue-300 rounded-full transition-shadow",children:(0,t.jsx)("img",{src:(0,p.agentAvatarUrl)(r.id,32,r.color),alt:"",className:"h-full w-full object-cover"})}):(0,t.jsx)(ex.Bot,{className:"h-4 w-4 text-[var(--foreground)]"})}),(0,t.jsxs)("div",{className:"min-w-0",children:["user"!==e.role&&r?(0,t.jsx)(c.default,{href:`/agents/${r.id}`,onClick:e=>e.stopPropagation(),className:"truncate text-sm font-semibold text-[var(--foreground)] hover:underline block",children:n}):(0,t.jsx)("p",{className:"truncate text-sm font-semibold text-[var(--foreground)]",children:n}),(0,t.jsx)("p",{className:"truncate text-xs text-[var(--muted-foreground)]",children:s})]})]}),(0,t.jsx)("span",{className:"shrink-0 text-xs text-[var(--muted-foreground)]",children:(a=e.timestamp,new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(a))})]}),(0,t.jsx)("p",{className:"text-sm leading-relaxed text-[var(--foreground)]",children:function(e){let a=e.split(/(<\/?mark>)/g),r=!1,s=[];for(let[e,l]of a.entries()){if("<mark>"===l){r=!0;continue}if("</mark>"===l){r=!1;continue}l&&s.push(r?(0,t.jsx)("mark",{className:"rounded bg-amber-200/80 px-0.5",children:l},`${e}-mark`):(0,t.jsx)("span",{children:l},`${e}-text`))}return s}(e.snippet)})]},`${e.threadId}-${e.messageId}`)})})]})})}var eb=e.i(984242),ej=e.i(481248),ew=e.i(169433);let ey="agx-chat:project-agent-config",ek={activeParticipantIdsByThread:{}};function eN(){return void 0!==window.localStorage}function eC(e){if(!Array.isArray(e))return[];let t=new Set,a=[];for(let r of e){if("string"!=typeof r)continue;let e=r.trim();!e||t.has(e)||(t.add(e),a.push(e))}return a}function eS(){if(!eN())return{...ek};let e=window.localStorage.getItem(ey);if(!e)return{...ek};try{let t=JSON.parse(e).activeParticipantIdsByThread;if(!t||"object"!=typeof t)return{...ek};return{activeParticipantIdsByThread:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,eC(t)]))}}catch{return{...ek}}}function eI(e,t){let a=e.trim();if(!a)return;let r=eS();r.activeParticipantIdsByThread[a]=eC(t);if(eN())try{window.localStorage.setItem(ey,JSON.stringify(r))}catch{}}let eT={threadSidebarVisible:!1,workspaceRoots:[],homeSearchConsent:!1,fileIgnorePatterns:[]};function eM(e){return e&&"object"==typeof e?{threadSidebarVisible:"boolean"==typeof e.threadSidebarVisible?e.threadSidebarVisible:eT.threadSidebarVisible,workspaceRoots:Array.isArray(e.workspaceRoots)?e.workspaceRoots.filter(e=>"string"==typeof e):eT.workspaceRoots,homeSearchConsent:"boolean"==typeof e.homeSearchConsent?e.homeSearchConsent:eT.homeSearchConsent,fileIgnorePatterns:Array.isArray(e.fileIgnorePatterns)?e.fileIgnorePatterns.filter(e=>"string"==typeof e):eT.fileIgnorePatterns}:eT}let e$="/api/userPreferences";function eR(e){return e.json().then(e=>e&&"object"==typeof e?eM(e.preferences??e):eM(e)).catch(()=>eM(null))}function eP(e){return e.statusText||`Failed to reach ${e$} (${e.status})`}async function eA(){let e=await fetch(e$,{cache:"no-store"});if(!e.ok)throw Error(eP(e));return eR(e)}async function eE(e){let t=await fetch(e$,{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-store",body:JSON.stringify({preferences:e})});if(!t.ok)throw Error(eP(t));return eR(t)}var e_=e.i(990933),eO=e.i(352687),eU=e.i(524123),ez=e.i(8707),eD=e.i(493141),eL=e.i(846279),eL=eL,eF=e.i(169729),eB=e.i(721571),eW=e.i(468947),eq=e.i(837958),eV=e.i(595807),eV=eV;function eJ({logs:e,participants:r,onClear:s,open:l,onToggle:n}){let[i,o]=(0,a.useState)(420),[d,c]=(0,a.useState)(null),u=(0,a.useRef)(null),p=(0,a.useRef)(!1),h=(0,a.useRef)(0),m=(0,a.useRef)(0),f=Object.fromEntries(r.map(e=>[e.id,e]));(0,a.useEffect)(()=>{l&&u.current?.scrollIntoView({behavior:"smooth"})},[e.length,l]);let x=(0,a.useCallback)(e=>{e.preventDefault(),p.current=!0,h.current=e.clientX,m.current=i,e.target.setPointerCapture(e.pointerId)},[i]),g=(0,a.useCallback)(e=>{if(!p.current)return;let t=h.current-e.clientX;o(Math.max(280,Math.min(m.current+t,.6*window.innerWidth)))},[]),v=(0,a.useCallback)(()=>{p.current=!1},[]);if(!l)return null;let b=d?e.filter(e=>e.participantId===d):e;return(0,t.jsxs)("div",{className:"flex h-full shrink-0",children:[(0,t.jsx)("div",{onPointerDown:x,onPointerMove:g,onPointerUp:v,className:"w-1.5 cursor-col-resize bg-zinc-800 hover:bg-zinc-600 transition-colors flex items-center justify-center shrink-0",children:(0,t.jsx)("div",{className:"h-8 w-0.5 rounded-full bg-zinc-500"})}),(0,t.jsxs)("div",{className:"flex flex-col bg-zinc-950 h-full",style:{width:i},children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-zinc-800 shrink-0",children:[(0,t.jsx)("span",{className:"text-[11px] text-[var(--muted-foreground)] font-mono",children:"Logs"}),(0,t.jsxs)("select",{value:d||"",onChange:e=>c(e.target.value||null),className:"bg-zinc-800 text-zinc-300 text-[11px] rounded px-1.5 py-0.5 outline-none",children:[(0,t.jsx)("option",{value:"",children:"All"}),r.map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,t.jsx)("button",{onClick:s,className:"text-[11px] text-[var(--muted-foreground)] hover:text-zinc-300",children:"Clear"}),(0,t.jsx)("button",{onClick:n,className:"text-[11px] text-[var(--muted-foreground)] hover:text-zinc-300",children:"✕"})]})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto font-mono text-[11px] leading-4 px-3 py-2",children:[b.map((e,a)=>{let r=f[e.participantId]?.name||e.participantId,s=f[e.participantId]?.color||"#888",l="stderr"===e.stream;return(0,t.jsxs)("div",{className:"flex gap-2 whitespace-pre-wrap break-all",children:[(0,t.jsx)("span",{className:"text-[var(--muted-foreground)] shrink-0 select-none",children:new Date(e.timestamp).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}),(0,t.jsx)("span",{className:"shrink-0",style:{color:s},children:r}),(0,t.jsx)("span",{className:l?"text-red-400":"text-[var(--muted-foreground)]",children:e.line})]},a)}),(0,t.jsx)("div",{ref:u})]})]})]})}var eH=e.i(524780);let eX="agx-theme";function eK(e,t=!1){return(t?e.replace(/(?:^|\n)Thinking\.\.\.[\s\S]*?\.\.\.done thinking\.?\s*/g,"\n").trim():e).replaceAll("<!-- thread-summary -->","").replaceAll("<!-- task-draft -->","").trim().replace(/\r\n/g,"\n").replace(/\n{3,}/g,"\n\n").trim()}async function eG(e){let t=await fetch(`/api/threads/knowledge?rootMessageId=${encodeURIComponent(e)}`,{cache:"no-store"});if(!t.ok)throw Error("Failed to load thread knowledge run");let a=await t.json().catch(e=>(console.warn("[ChatContainer] failed to parse thread knowledge response:",e),null));return a?.run??null}function eY(e,t,a){let r=new Set(e.map(e=>e.id)),s=a?t.find(e=>e.thread_ids?.includes(a)):t[0],l=s?s.agents.map(e=>e.agent_id).filter(e=>r.has(e)):[];return s?l:0===l.length?e.map(e=>e.id):l}function eZ(e,t,a){let r=Object.fromEntries(t.map(e=>[e.id,e])),s=[];for(let t of e){let e="user"===t.role?"You":t.participantId?r[t.participantId]?.name||t.participantId:"Assistant",a=eK(t.content,"user"!==t.role);a&&(s.push(`**${e}:**`),s.push(""),s.push(a),s.push(""))}if(a){let e=function(e){if(0===e.tasks.length)return"";let t=new Map(e.tasks.map(e=>[e.id,e.title.trim()])),a=["## Draft Tasks",""];return e.projectName&&a.push(`Project: ${e.projectName}`),e.buildStatus&&a.push(`Build status: ${e.buildStatus.replaceAll("_"," ")}`),(e.projectName||e.buildStatus)&&a.push(""),e.tasks.forEach((r,s)=>{let l=eK(r.title)||`Task ${s+1}`,n=eK(r.description),i=(r.dependsOn||[]).map(e=>t.get(e)?.trim()).filter(e=>!!e),o=e.builtTaskIds?.[r.id];a.push(`${s+1}. [ ] **${l}**`),n&&a.push(n),i.length>0&&a.push(`Depends on: ${i.join(", ")}`),o&&a.push(`agx task id: \`${o}\``),a.push("")}),a.join("\n").trim()}(a);e&&s.push(e)}return s.join("\n").trim()}e.s(["ChatContainer",0,function({projectSlug:e,initialThreadId:c,initialRootMessageId:u,showSidebar:p=!0}={}){let{isTouchLayout:h}=(0,o.useInputCapabilities)(),{getSelection:m,pushSelection:f,replaceSelection:x}=(0,s.useUrlSelection)(),{threads:g,activeThreadId:v,selectThread:b,createThread:j,deleteThread:w,updateThreadMessages:y,isCreating:k,deletingThreadId:N,renamingThreadId:C,isLoading:S,isRestoringActiveThread:I,renameThread:T,updateThreadStatus:M,updateThreadOutcomeNote:$,updateMessageThreadStatus:R,updateMessageOutcomeNote:P}=(0,i.useThreadState)(c),{messages:A,setMessages:E,logs:O,sendMessage:U,loadHistory:z,clearLogs:D,chatRuns:L,setChatRuns:F,stop:B,stopThread:W}=(0,l.useGroupChat)(v),{activeAgents:q,processes:V,streaming:J,chatRuns:H,poll:X}=(0,n.useProcessPolling)(v?{workspaceId:v}:null,{messages:A,setMessages:E}),K=(0,a.useMemo)(()=>{let e=Date.now(),t=new Map(H.map(e=>[e.chatRunId,e]));for(let a of L)!(!a.optimistic||t.has(a.chatRunId))&&(e-(a.enqueuedAt??0)>5e3||t.set(a.chatRunId,a));return Array.from(t.values()).filter(e=>"queued"===e.status||"running"===e.status)},[L,H]),G=q.size>0||K.some(e=>"running"===e.status)?"working":K.some(e=>"queued"===e.status)?"queued":"ready";(0,a.useEffect)(()=>{F(e=>{let t=Date.now(),a=new Map(e.filter(e=>"string"==typeof e.chatRunId&&e.chatRunId.length>0).map(e=>[e.chatRunId,e]));for(let e of H)e?.chatRunId&&a.set(e.chatRunId,e);return Array.from(a.values()).filter(e=>!!(!e.optimistic||H.some(t=>t.chatRunId===e.chatRunId))||t-(e.enqueuedAt??0)<=5e3).sort((e,t)=>String(e.chatRunId||"").localeCompare(String(t.chatRunId||"")))})},[H,F]);let Y=(0,a.useCallback)(async e=>{await fetch(`/api/chat-runs/${encodeURIComponent(e)}/signal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({signal:"cancel",reason:"Stopped from chat UI"})}).catch(e=>console.warn("[ChatContainer] cancel chat run failed:",e))},[]),Z=(0,a.useCallback)(async()=>{let e=K[0];e?.chatRunId&&await Y(e.chatRunId),await B(),await X()},[K,Y,B,X]),Q=(0,a.useCallback)(async e=>{let t=K.find(t=>t.rootMessageId===e);t?.chatRunId&&await Y(t.chatRunId),await W(e),await X()},[K,Y,W,X]),ee=(0,a.useRef)(Z);(0,a.useEffect)(()=>{ee.current=Z},[Z]);let{projects:et,createProject:ea,deleteProject:er,addAgent:es,removeAgent:el,reorderAgents:en}=(0,eU.useProjectsWithAgents)(),{projects:ei,updateProject:eo}=(0,eU.useProjects)(),ec=(0,a.useMemo)(()=>v?et.filter(e=>e.thread_ids?.includes(v)):et,[et,v]),eu=(0,a.useMemo)(()=>e||ec[0]?.slug||void 0,[e,ec]),[ep,eh]=(0,a.useState)([]),[em,ex]=(0,a.useState)(!1),[eg,ey]=(0,a.useState)([]),[ek,eN]=(0,a.useState)(!1),[eC,eT]=(0,a.useState)(()=>{let e=window.localStorage.getItem(eX);return"dark"===e||"light"===e?e:document.documentElement.classList.contains("dark")?"dark":"light"}),[eM,e$]=(0,a.useState)(!1),[eR,eP]=(0,a.useState)(368),eK=(0,a.useRef)(!1);(0,a.useEffect)(()=>{let e=(0,ej.loadWorkspaceSidebarVisible)();eK.current=!0,e$(e),eP((0,ew.loadWorkspaceWidth)()||368)},[]),(0,a.useEffect)(()=>{let e="dark"===eC;document.documentElement.classList.toggle("dark",e),document.documentElement.style.colorScheme=eC,window.localStorage.setItem(eX,eC)},[eC]);let[eQ,e0]=(0,a.useState)(!1),[e1,e5]=(0,a.useState)(new Set),[e2,e3]=(0,a.useState)(!1),[e4,e6]=(0,a.useState)(!1),[e8,e7]=(0,a.useState)(null),e9=m("open"),te=m("message"),tt=e?e9??u??null:u??null,ta=tt?e1.has(tt):e2;(0,a.useEffect)(()=>{if(!tt)return;let e=!1,t=()=>{fetch(`/api/schedules?rootMessageId=${encodeURIComponent(tt)}`).then(e=>e.json()).then(t=>{e||e5(e=>{let a=e.has(tt);if(t.active&&!a){let t=new Set(e);return t.add(tt),t}if(!t.active&&a){let t=new Set(e);return t.delete(tt),t}return e})}).catch(e=>console.warn("[ChatContainer] check auto-mode status failed:",e))};t();let a=setInterval(t,r.UI_POLL_CHAT_CHECK_MS);return()=>{e=!0,clearInterval(a)}},[tt]),(0,a.useEffect)(()=>{let e=!1,t=()=>{fetch("/api/schedules").then(e=>e.json()).then(t=>{!e&&t.activeRootMessageIds&&e5(e=>{let a=new Set(t.activeRootMessageIds);return a.size===e.size&&[...a].every(t=>e.has(t))?e:a})}).catch(e=>console.warn("[ChatContainer] fetch schedules failed:",e))};t();let a=setInterval(t,r.UI_POLL_CHAT_ALT_MS);return()=>{e=!0,clearInterval(a)}},[]);let tr=(0,a.useCallback)((t,a={})=>{let r=a.replace?x:f;if(e){let s=a.threadId??v??c??null;if(!s)return;r({open:t,message:a.messageId??null},`/projects/${e}/thread/${encodeURIComponent(s)}`);return}t?r({message:a.messageId??null},`/thread/${encodeURIComponent(t)}`):r({message:null},"/")},[v,c,e,f,x]);(0,a.useEffect)(()=>{u&&(async()=>{try{let e=await fetch(`/api/messages/${u}`);if(!e.ok)return;let{threadId:t}=await e.json();t&&b(t)}catch{}})()},[u,b]);let[ts,tl]=(0,a.useState)(""),[tn,ti]=(0,a.useState)([]),[to,td]=(0,a.useState)(0),[tc,tu]=(0,a.useState)(!1),[tp,th]=(0,a.useState)(null),[tm,tf]=(0,a.useState)(new Set),[tx,tg]=(0,a.useState)(null),[tv,tb]=(0,a.useState)(null),[tj,tw]=(0,a.useState)({}),ty=(0,a.useCallback)(e=>{tw(t=>{let a="function"==typeof e?e(t):e;if(v)for(let[e,r]of Object.entries(a))t[e]!==r&&fetch("/api/task-drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:v,messageId:e,draft:r})}).catch(e=>console.warn("[ChatContainer] persist task draft failed:",e));return a})},[v]),[tk,tN]=(0,a.useState)(new Set),[tC,tS]=(0,a.useState)(new Set),tI=(0,a.useRef)(null),tT=(0,a.useRef)(""),tM=(0,a.useCallback)(async(e=!1)=>{try{let e=await fetch("/api/participants");if(!e.ok)return;let t=await e.json();if(!Array.isArray(t))return;eh(t)}finally{e&&ex(!0)}},[]),t$=(0,a.useCallback)(async e=>{try{await eE({threadSidebarVisible:e})}catch(e){console.error("Unable to persist thread sidebar preference",e)}},[eE]),tR=(0,a.useCallback)(e=>{(0,ej.persistWorkspaceSidebarVisible)(e),t$(e)},[t$]),tP=ts.trim(),tA=tP.length>0,tE=(0,a.useMemo)(()=>Object.fromEntries(g.map(e=>[e.id,e.title?.trim()||"Untitled thread"])),[g]),t_=(0,a.useMemo)(()=>{if(!tt)return[];let e=new Set([A.find(e=>e.id===tt),...A.filter(e=>e.rootMessageId===tt)].filter(Boolean).map(e=>e.participantId).filter(Boolean));return Object.keys(J).forEach(t=>{J[t].rootMessageId===tt&&e.add(t)}),ep.filter(t=>e.has(t.id))},[tt,A,J,ep]),tO=(0,a.useMemo)(()=>{let e=new Map(ep.map(e=>[e.id,e]));return eg.map(t=>e.get(t)).filter(Boolean)},[ep,eg]),tU=(0,a.useMemo)(()=>ei.map(e=>({id:e.id,name:e.name,slug:e.slug})),[ei]),tz=(0,a.useMemo)(()=>{if(!tt)return 0;let e=[A.find(e=>e.id===tt),...A.filter(e=>e.rootMessageId===tt)].filter(Boolean);return 0===e.length?0:Math.max(...e.map(e=>e.timestamp))},[tt,A]),tD=(0,a.useMemo)(()=>{if(!tt)return"";let e=A.find(e=>e.id===tt);if(!e)return"Discussion";let t=e.content.trim();return t.length>60?t.slice(0,60)+"...":t},[tt,A]),tL=(0,a.useMemo)(()=>{if(!tt)return null;let e=A.find(e=>e.id===tt),t=e?.threadStatus??"active";return{value:t,...{active:{label:"Active",color:"#f59e0b"},paused:{label:"Paused",color:"#f97316"},"in-review":{label:"In Review",color:"#6b7280"},done:{label:"Done",color:"#3b82f6"},archived:{label:"Archived",color:"#9ca3af"}}[t]}},[tt,A]);(0,a.useEffect)(()=>{if(!te)return;let e=A.find(e=>e.id===te)??null;if(e){let t=e.rootMessageId||e.id;t!==tt&&tr(t,{messageId:te,replace:!0});return}!tt||[A.find(e=>e.id===tt),...A.filter(e=>e.rootMessageId===tt)].filter(Boolean).length>0&&x({message:null})},[A,tr,tt,x,te]);let tF=(0,a.useCallback)(()=>{tl(""),ti([]),td(0),th(null),tu(!1)},[]);(0,a.useCallback)(()=>{let e=eZ(A,ep);navigator.clipboard.writeText(e).then(()=>{eN(!0),setTimeout(()=>eN(!1),2e3)})},[A,ep]);let[tB,tW]=(0,a.useState)(null),tq=(0,a.useCallback)(e=>{let t=A.find(t=>t.id===e);if(!t)return;let a=[t,...A.filter(t=>t.rootMessageId===e).sort((e,t)=>e.timestamp-t.timestamp)];tW({title:t.content.slice(0,60).replace(/\n/g," ").trim()||"Untitled",threadId:e,messages:a})},[A]),tV=(0,a.useCallback)(e=>{let t=eZ([A.find(t=>t.id===e),...A.filter(t=>t.rootMessageId===e).sort((e,t)=>e.timestamp-t.timestamp)].filter(Boolean),ep,tj[e]);navigator.clipboard.writeText(t).catch(e=>console.error("Failed to copy thread",e))},[A,ep,tj]),tJ=(0,a.useCallback)(async()=>{if(tt){e6(!0);try{let e=["repo"];eu&&e.push("project");let t=await fetch("/api/threads/knowledge",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootMessageId:tt,scopes:e})}),a=await t.json().catch(e=>(console.warn("[ChatContainer] failed to parse knowledge extraction response:",e),null));if(!t.ok)throw Error("string"==typeof a?.error?a.error:"Request failed");e7(a?.run??null)}catch(t){let e=t instanceof Error?t.message:"Request failed";window.alert(`Failed to extract knowledge: ${e}`)}finally{e6(!1)}}},[tt,eu]);(0,a.useEffect)(()=>{if(!tt){e7(null),e6(!1);return}let e=!1;return(async()=>{try{let t=await eG(tt);if(e)return;e7(t)}catch{e||e7(null)}})(),()=>{e=!0}},[tt]),(0,a.useEffect)(()=>{if(!tt||e8?.status!=="running")return;let e=!1,t=async()=>{try{let t=await eG(tt);if(e)return;e7(t)}catch{}};t();let a=window.setInterval(()=>{t()},2e3);return()=>{e=!0,window.clearInterval(a)}},[tt,e8?.status]);let tH=e8?.status==="running",tX=e4||tH,tK=(e8?.repoInsertedCount??0)+(e8?.projectInsertedCount??0),tG=(0,a.useMemo)(()=>{if(!e8)return null;if("running"===e8.status)return"Learning in progress";if("failed"===e8.status)return"Last learning run failed";if(tK>0){let e=1===tK?"insight":"insights";return`Learned ${tK} ${e}`}return"No new learnings"},[tK,e8]);(0,a.useEffect)(()=>{tM(!0)},[tM]);let tY=(0,a.useMemo)(()=>{if(!em)return[];let e=new Set(ep.map(e=>e.id)),t=new Set;for(let a of A)"assistant"===a.role&&a.participantId&&(e.has(a.participantId)||t.add(a.participantId));for(let a of Object.keys(J))e.has(a)||t.add(a);return Array.from(t).sort()},[A,ep,em,J]);(0,a.useEffect)(()=>{if(!em)return;let e=tY.join("|");if(!e){tT.current="";return}tT.current!==e&&(tT.current=e,tM(!1))},[em,tM,tY]),(0,a.useEffect)(()=>{if(!em)return;let e=eY(ep,et,v);if(!v)return void ey(e);let t=function(e){let t=e.trim();if(!t)return null;let a=eS();return t in a.activeParticipantIdsByThread?[...a.activeParticipantIdsByThread[t]]:null}(v);if(null===t)return void ey(e);let a=function(e,t){if(null===t)return e;let a=new Set(t);return e.filter(e=>a.has(e))}(e,t),r=a.length>0?a:e;(r.length!==t.length||r.some((e,a)=>t[a]!==e))&&eI(v,r),ey(r)},[v,ep,em,et]),(0,a.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await eA();if(e)return;e$(e=>e===t.threadSidebarVisible?e:eK.current?(t$(e),e):((0,ej.persistWorkspaceSidebarVisible)(t.threadSidebarVisible),t.threadSidebarVisible))}catch(e){console.error("Failed to load user preferences",e)}})(),()=>{e=!0}},[t$]),(0,a.useEffect)(()=>{S||k||0!==g.length||j({id:"global",title:"General"})},[S,k,g.length,j]),(0,a.useEffect)(()=>{if(e)return;let t=e=>{if((e.metaKey||e.ctrlKey)&&"k"===e.key.toLowerCase()){e.preventDefault(),tI.current?.focus(),tI.current?.select();return}"Escape"===e.key&&tP&&tF()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[tF,tP,e]),(0,a.useEffect)(()=>{if(!tP){ti([]),td(0),th(null),tu(!1);return}let e=!1;tu(!0);let t=window.setTimeout(()=>{(async()=>{try{let t=new URLSearchParams({q:tP,limit:"20",offset:"0"}),a=await fetch(`/api/search?${t.toString()}`),r=await a.json().catch(e=>(console.warn("[ChatContainer] failed to parse search response:",e),null));if(e)return;if(!a.ok){let e=r&&"object"==typeof r&&"error"in r?String(r.error):"Search failed";ti([]),td(0),th(e);return}ti(Array.isArray(r.results)?r.results:[]),td("number"==typeof r.total?r.total:0),th(null)}catch(t){if(e)return;console.error("Search request failed",t),ti([]),td(0),th("Search failed")}finally{e||tu(!1)}})()},300);return()=>{e=!0,window.clearTimeout(t)}},[tP]);let tZ=(0,a.useRef)(null);(0,a.useEffect)(()=>{null!==tZ.current&&tZ.current!==v&&ee.current(),tZ.current=v,v&&(z(v),fetch(`/api/task-drafts?threadId=${encodeURIComponent(v)}`).then(e=>e.json()).then(e=>{e.drafts&&Object.keys(e.drafts).length>0?tw(e.drafts):tw({})}).catch(e=>{console.warn("[ChatContainer] load task drafts failed:",e),tw({})}))},[v,z]),(0,a.useEffect)(()=>{v&&y(v,A)},[v,A,y]);let tQ=(0,a.useCallback)((e,t,a=10,r,s,l)=>{v&&0!==tO.length&&U(t,a,v,e,void 0,void 0,(0,e_.orderParticipantIds)(tO.map(e=>e.id),r),eu,s,l)},[v,U,tO,eu]),t0=(0,a.useCallback)(async e=>{if(v){if(0===tO.length)return void window.alert("Enable at least one agent in this project.");tf(t=>new Set(t).add(e));try{let t=await fetch("/api/summarize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:v,rootMessageId:e,activeParticipantIds:tO.map(e=>e.id)})});t.ok?await z(v):console.error("Summarize failed:",await t.text())}catch(e){console.error("Summarize error:",e)}finally{tf(t=>{let a=new Set(t);return a.delete(e),a})}}},[v,z,tO]),t1=(0,a.useCallback)(async e=>{if(v){if(0===tO.length)return void window.alert("Enable at least one agent in this project.");tN(t=>new Set(t).add(e));try{let t=await fetch("/api/tasks/extract",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:v,rootMessageId:e,activeParticipantIds:tO.map(e=>e.id)})});if(t.ok){let a=await t.json(),r={draftId:crypto.randomUUID(),revision:0,tasks:a.tasks,buildStatus:"idle"};ty(t=>({...t,[e]:r}))}else console.error("Task extraction failed:",await t.text())}catch(e){console.error("Task extraction error:",e)}finally{tN(t=>{let a=new Set(t);return a.delete(e),a})}}},[v,tO]),t5=(0,a.useCallback)((e,t)=>{ty(a=>({...a,[e]:t}))},[]),t2=(0,a.useCallback)(async(e,t,a,r)=>{if(v){tS(e=>new Set(e).add(t.draftId)),ty(s=>({...s,[e]:{...t,buildStatus:"building",projectId:a,projectName:r}}));try{let r=crypto.randomUUID(),s=await _(t.tasks,a,r,t.builtTaskIds),l={...t.builtTaskIds},n=!1;for(let e of s.results)"created"===e.status&&e.remoteTaskId?l[e.clientTaskId]=e.remoteTaskId:n=!0;ty(t=>({...t,[e]:{...t[e],buildId:r,buildStatus:n?"partial_failure":"done",builtTaskIds:l}}))}catch(t){console.error("Build error:",t),ty(t=>({...t,[e]:{...t[e],buildStatus:"partial_failure"}}))}finally{tS(e=>{let a=new Set(e);return a.delete(t.draftId),a})}}},[v]),t3=(0,a.useCallback)(()=>{if(!v)return;let e=(()=>{if(tt)return tt;let e=new Set(A.map(e=>e.rootMessageId).filter(e=>!!e));for(let t=A.length-1;t>=0;t-=1){let a=A[t];if(!a.rootMessageId&&e.has(a.id))return a.id}return null})();e?t1(e):console.warn("No thread with replies available to extract tasks from")},[v,t1,A,tt]);(0,a.useCallback)(e=>{tr(e)},[tr]);let t4=(0,a.useCallback)(e=>{tr(e)},[tr]),t6=(0,a.useCallback)(e=>{let t=e?.trim()??"";t&&tl(t),requestAnimationFrame(()=>{tI.current?.focus(),t||tI.current?.select()})},[]),t8=(0,a.useCallback)(()=>{if(!v)return;let e=(()=>{if(tt)return tt;let e=new Set(A.map(e=>e.rootMessageId).filter(e=>!!e));for(let t=A.length-1;t>=0;t-=1){let a=A[t];if(!a.rootMessageId&&e.has(a.id))return a.id}return null})();e?t0(e):console.warn("No thread with replies available to summarize")},[v,t0,A,tt]),t7=(0,a.useCallback)(async(e,t,a,r,s,l,n)=>{let i=e.match(/^\/search(?:\s+([\s\S]+))?$/i);if(i)return void t6(i[1]);if(/^\/summarize(?:\s+[\s\S]+)?$/i.test(e))return void t8();if(/^\/tasks(?:\s+[\s\S]+)?$/i.test(e)||/^\/create(?:\s+[\s\S]+)?$/i.test(e))return void t3();let o=v;o||(o=(await j()).id);let d=tO.map(e=>e.id);if(0===d.length)return void window.alert("Enable at least one agent in this project.");let c=(0,e_.orderParticipantIds)(d,s);if(tt)return void await U(e,t,o,tt,a,r,c,eu,l,n);let u=await U(e,t,o,null,a,r,c,eu,l,n);e2&&u&&(e3(!1),e5(e=>{let t=new Set(e);return t.add(u),t}),fetch("/api/schedules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"activate",rootMessageId:u})}).catch(e=>console.error("Failed to activate schedule for new thread:",e)))},[v,e2,j,t6,t8,tt,tO,U,eu]),t9=(0,a.useCallback)(async e=>{if(!tt)return void e3(e);e5(t=>{let a=new Set(t);return e?a.add(tt):a.delete(tt),a});try{await fetch("/api/schedules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e?"activate":"stop",rootMessageId:tt})})}catch(e){console.error("Failed to toggle autonomous schedule:",e)}},[tt]),ae=(0,a.useCallback)(e=>{tr(e.rootMessageId||e.messageId,{messageId:e.messageId,threadId:e.threadId}),tF()},[tF,tr]),at=(0,a.useCallback)(async e=>{Z(),await w(e)},[w,Z]),aa=(0,a.useCallback)(e=>{if(!v||!e)return;let t=A.find(t=>t.id===e);tb({type:"thread",id:e,preview:t?.content?.slice(0,120)||void 0})},[v,A]),ar=(0,a.useCallback)(async e=>{if(v){tg(e),Q(e);try{let t=new URLSearchParams({threadId:v,rootMessageId:e}),a=await fetch(`/api/history?${t.toString()}`,{method:"DELETE"});if(!a.ok)return void console.error("Failed to delete message thread",await a.text());let r=te?A.find(e=>e.id===te)??null:null,s=r?r.rootMessageId||r.id:null;tt===e?tr(null,{replace:!0}):s===e&&x({message:null});let l=A.filter(t=>t.id!==e&&t.rootMessageId!==e);y(v,l),await z(v)}catch(e){console.error("Failed to delete message thread",e)}finally{tg(t=>t===e?null:t)}}},[v,Q,z,A,tr,tt,x,te,y]),as=(0,a.useCallback)(e=>{if(!v||!e)return;let t=A.find(t=>t.id===e);tb({type:"message",id:e,preview:t?.content?.slice(0,120)||void 0})},[v,A]),al=(0,a.useCallback)(async e=>{if(v)try{let t=new URLSearchParams({threadId:v,messageId:e}),a=await fetch(`/api/history?${t.toString()}`,{method:"DELETE"});if(!a.ok)return void console.error("Failed to delete message",await a.text());te===e&&x({message:null});let r=A.filter(t=>t.id!==e);y(v,r),await z(v)}catch(e){console.error("Failed to delete message",e)}},[v,z,A,x,te,y]),an=(0,a.useCallback)(()=>{tv&&("thread"===tv.type?ar(tv.id):al(tv.id),tb(null))},[tv,ar,al]),ai=(0,a.useCallback)(()=>{tb(null)},[]),ao=(0,a.useMemo)(()=>[{name:"/search",description:"Search messages (usage: /search <query>)",aliases:["find"],execute:()=>t6()},{name:"/summarize",description:"Summarize current thread or latest thread with replies",aliases:["sum"],execute:()=>t8()},{name:"/tasks",description:"Extract tasks from current thread discussion",aliases:["create"],execute:()=>t3()}],[t6,t8,t3]),ad=(0,a.useMemo)(()=>{let e=eu?ec.find(e=>e.slug===eu):ec[0];return e?.repos??[]},[ec,eu]),[ac,au]=(0,a.useState)(new Set),ap=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(!tt){au(new Set),ap.current=null;return}ap.current!==tt&&(au(new Set),ap.current=tt,fetch(`/api/thread-repos?rootMessageId=${encodeURIComponent(tt)}`).then(e=>e.json()).then(e=>{ap.current===tt&&e.repoIds&&e.repoIds.length>0&&au(new Set(e.repoIds))}).catch(e=>console.warn("[ChatContainer] load thread repos failed:",e)))},[tt]);let ah=(0,a.useCallback)(e=>{au(e),tt&&fetch("/api/thread-repos",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootMessageId:tt,repoIds:[...e]})}).catch(e=>console.warn("[ChatContainer] save thread repos failed:",e))},[tt]),am=(0,a.useCallback)(e=>{let a=V.some(t=>["spawning","running"].includes(t.state)&&t.threadId===e)||Object.values(J).some(t=>t.rootMessageId===e)?"working":K.some(t=>t.rootMessageId===e&&"queued"===t.status)?"queued":"ready";return(0,t.jsx)(eb.Composer,{onSend:(t,a,r,s,l,n,i)=>tQ(e,t,a,l,n,i),onStop:()=>Q(e),loading:"ready"!==a,activityStatus:a,participants:tO,projectGroups:ec,projects:tU,projectSlug:eu,messages:A,commands:ao,placeholder:"Reply — @name to mention, /search, /summarize",autoMode:ta,onAutoModeChange:t9,repos:ad,selectedRepoIds:ac,onRepoSelectionChange:ah})},[tQ,Q,J,tO,ec,tU,eu,ao,A,ta,t9,V,K,ad,ac,ah]),af=(0,a.useCallback)(()=>{e$(e=>{let t=!e;return tR(t),t})},[tR]),ax=(0,a.useCallback)(e=>{eP(e),(0,ew.persistWorkspaceWidth)(e)},[]),ag=async e=>{let t=await fetch("/api/participants",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok){let e=await t.json();eh(t=>t.map(t=>t.id===e.id?e:t))}},av=(0,a.useCallback)((e,t)=>{ey(a=>{let r=eY(ep,et,v);if(!new Set(r).has(e))return a;let s=new Set(a);t?s.add(e):s.delete(e);let l=r.filter(e=>s.has(e));return v&&eI(v,l),l})},[v,ep,et]),ab=(0,a.useCallback)(e=>{let t=et.find(t=>t.id===e);if(!t||v&&!t.thread_ids?.includes(v))return;let a=t.agents.map(e=>e.agent_id);ey(a),v&&eI(v,a)},[et,v]),aj=(0,a.useCallback)(()=>{eT(e=>"dark"===e?"light":"dark")},[]),aw=()=>(0,t.jsx)("button",{type:"button",onClick:aj,"aria-label":"dark"===eC?"Switch to light theme":"Switch to dark theme",title:"dark"===eC?"Switch to light theme":"Switch to dark theme",className:"inline-flex h-9 w-9 items-center justify-center rounded-xl border border-[var(--app-shell-border)] bg-[var(--app-shell-elevated)] text-[var(--app-shell-muted)] transition-all hover:border-[var(--app-shell-border-strong)] hover:bg-[var(--app-shell-subtle)] hover:text-[var(--foreground)]",children:"dark"===eC?(0,t.jsx)(eW.Sun,{className:"h-4 w-4",strokeWidth:1.75}):(0,t.jsx)(eB.Moon,{className:"h-4 w-4",strokeWidth:1.75})}),ay=(0,t.jsxs)("div",{className:"relative group/search min-w-0 flex-1",children:[(0,t.jsx)(ez.Search,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-[var(--app-shell-soft-text)] transition-colors group-focus-within/search:text-[var(--primary)]",strokeWidth:2}),(0,t.jsx)("input",{ref:tI,type:"text",value:ts,onChange:e=>tl(e.target.value),onKeyDown:e=>{"Escape"===e.key&&tF()},placeholder:"Search messages…",className:`w-full rounded-xl border border-[var(--app-shell-border)] bg-[var(--app-shell-elevated)] pl-9 pr-16 text-sm font-medium text-[var(--foreground)] outline-none placeholder:text-[var(--app-shell-soft-text)] transition-all hover:border-[var(--app-shell-border-strong)] focus:border-[var(--primary)] focus:ring-2 focus:ring-[var(--ring)] ${e?"h-7 text-xs":"h-9"}`}),tP?(0,t.jsxs)("div",{className:"absolute right-3 top-1/2 flex -translate-y-1/2 items-center gap-2",children:[(0,t.jsx)("span",{className:"text-[11px] font-bold text-[var(--muted-foreground)]",children:tc?"…":to}),(0,t.jsx)("button",{type:"button",onClick:tF,className:"text-[10px] font-bold text-[var(--app-shell-soft-text)] transition-colors hover:text-[var(--app-shell-muted)]",children:"✕"})]}):h?null:(0,t.jsx)("kbd",{className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 rounded-md border border-[var(--app-shell-border)] bg-[var(--app-shell-subtle)] px-1.5 py-0.5 font-sans text-[10px] font-bold text-[var(--app-shell-soft-text)]",children:"⌘K"})]}),ak=e?null:(0,t.jsx)("div",{className:"desktop-titlebar border-b border-[var(--app-shell-border)] bg-[var(--app-shell-surface)] px-4 py-2.5 backdrop-blur-xl md:px-6",children:(0,t.jsxs)("div",{className:"mx-auto flex max-w-5xl items-center gap-3",children:[(0,t.jsx)("div",{className:"flex min-w-0 items-center flex-shrink-0",children:p&&!eM&&(0,t.jsx)("button",{type:"button",onClick:af,className:"inline-flex h-9 w-9 items-center justify-center rounded-xl border border-[var(--app-shell-border)] bg-[var(--app-shell-elevated)] text-[var(--app-shell-muted)] transition hover:border-[var(--app-shell-border-strong)] hover:text-[var(--foreground)]",title:"Show sidebar","aria-label":"Show sidebar",children:(0,t.jsx)(eF.PanelLeftOpen,{className:"h-4 w-4",strokeWidth:1.75})})}),(0,t.jsx)("div",{className:"flex flex-1 justify-center min-w-0",children:(0,t.jsxs)("div",{className:"flex w-full max-w-2xl items-center gap-2",children:[ay,(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[aw(),(0,t.jsx)(eH.StatusIndicator,{}),tt&&(0,t.jsx)("button",{type:"button",onClick:()=>e0(!eQ),"aria-label":eQ?"Hide logs":`Show logs${O.length>0?` (${O.length})`:""}`,"aria-pressed":eQ,title:eQ?"Hide logs":`Show logs${O.length>0?` (${O.length})`:""}`,className:`inline-flex h-9 w-9 items-center justify-center rounded-xl border transition-all focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ring)] ${eQ?"border-[var(--app-shell-border-strong)] bg-[var(--app-shell-subtle)] text-[var(--foreground)]":"border-[var(--app-shell-border)] bg-[var(--app-shell-elevated)] text-[var(--app-shell-muted)] hover:bg-[var(--app-shell-subtle)] hover:text-[var(--foreground)]"}`,children:(0,t.jsx)(eL.default,{className:"h-4 w-4",strokeWidth:1.75})})]})]})})]})});return(0,t.jsxs)("div",{className:`flex ${e?"h-full":"h-screen"} bg-[var(--app-shell-bg)] text-[var(--foreground)]`,children:[p?(0,t.jsx)(d.WorkspaceSidebar,{threads:g,participants:ep,activeThreadId:v,isLoading:S,isRestoringActiveThread:I,isCreating:k,deletingThreadId:N,renamingThreadId:C,onSelectThread:b,onCreateThread:j,onRenameThread:T,onDeleteThread:at,activeParticipantIds:eg,onToggleParticipantActive:av,visible:eM,onToggle:af,width:eR,onWidthChange:ax,projects:et,onCreateProject:ea,onUpdateProject:eo,onDeleteProject:er,onAddAgentToProject:es,onRemoveAgentFromProject:el,onReorderProjectAgents:en,onUpdateParticipant:ag,onSelectProject:ab}):null,(0,t.jsx)("div",{className:"flex flex-col flex-1 min-w-0 relative",children:I?(0,t.jsx)("div",{className:"flex-1 flex items-center justify-center px-4 text-sm text-[var(--muted-foreground)]",children:"Loading your last project…"}):(0,t.jsx)("div",{className:"flex flex-1 min-h-0 bg-transparent relative",children:(0,t.jsxs)("div",{className:"flex flex-col flex-1 min-w-0",children:[tt?(0,t.jsx)("div",{className:"desktop-titlebar border-b border-[var(--app-shell-border)] bg-[var(--app-shell-surface)] px-4 py-2.5 backdrop-blur-xl md:px-6 transition-colors duration-200 shrink-0",children:(0,t.jsxs)("div",{className:"mx-auto flex max-w-5xl items-center gap-3 min-w-0",children:[p&&!eM?(0,t.jsx)("button",{type:"button",onClick:af,className:"inline-flex h-9 w-9 items-center justify-center rounded-xl border border-[var(--app-shell-border)] bg-[var(--app-shell-elevated)] text-[var(--app-shell-muted)] transition hover:border-[var(--app-shell-border-strong)] hover:text-[var(--foreground)]",title:"Show sidebar","aria-label":"Show sidebar",children:(0,t.jsx)(eF.PanelLeftOpen,{className:"h-4 w-4",strokeWidth:1.75})}):null,(0,t.jsx)("button",{onClick:()=>tr(null),className:"p-1.5 text-[var(--app-shell-muted)] hover:text-[var(--primary)] hover:bg-[var(--app-shell-subtle)] rounded-xl transition-all active:scale-95 flex-shrink-0",title:"Back to main feed",children:(0,t.jsx)(eD.ChevronLeft,{size:20,strokeWidth:2.25})}),(0,t.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,t.jsx)("h2",{className:"text-[15px] font-semibold text-[var(--foreground)] tracking-tight leading-tight truncate min-w-0",children:tD}),tL&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-semibold border shrink-0",style:{borderColor:tL.color+"40",color:tL.color},children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:tL.color}}),tL.label]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-[var(--app-shell-muted)]",children:[(0,t.jsxs)("span",{className:"opacity-80",children:[t_.length," agents"]}),(0,t.jsx)("span",{className:"h-0.5 w-0.5 rounded-full bg-[var(--app-shell-soft-text)]"}),(0,t.jsxs)("span",{className:"opacity-80",children:["Updated ",function(e){if(!e)return"recently";let t=Math.floor((Date.now()-e)/1e3);if(t<60)return"just now";let a=Math.floor(t/60);if(a<60)return`${a}m ago`;let r=Math.floor(a/60);return r<24?`${r}h ago`:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(e)}(tz)]}),tG&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"h-0.5 w-0.5 rounded-full bg-[var(--app-shell-soft-text)]"}),(0,t.jsx)("span",{className:"opacity-80",children:tG})]})]})]}),(0,t.jsx)("div",{className:"flex -space-x-1.5 flex-shrink-0",children:t_.map(e=>(0,t.jsx)("img",{src:`https://api.dicebear.com/9.x/bottts-neutral/svg?seed=${e.id}&backgroundColor=${e.color?e.color.replace("#",""):"e2e8f0"}`,alt:e.name,className:"h-7 w-7 rounded-full border-2 border-[var(--app-shell-elevated)] object-cover shadow-sm ring-1 ring-[var(--app-shell-border)]",title:e.name},e.id))}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>void tJ(),disabled:tX,title:tH?"Learning is already running for this discussion":"Learn from this discussion",className:`inline-flex h-9 items-center gap-1.5 rounded-xl border px-3 text-xs font-medium transition-all focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ring)] ${tX?"cursor-wait border-[var(--app-shell-border)] bg-[var(--app-shell-subtle)] text-[var(--app-shell-muted)]":"border-[var(--app-shell-border)] bg-[var(--app-shell-elevated)] text-[var(--app-shell-muted)] hover:bg-[var(--app-shell-subtle)] hover:text-[var(--foreground)]"}`,children:[tX?(0,t.jsx)(eV.default,{className:"h-3.5 w-3.5 animate-spin",strokeWidth:1.75}):(0,t.jsx)(eq.BookOpen,{className:"h-3.5 w-3.5",strokeWidth:1.75}),(0,t.jsx)("span",{className:"hidden sm:inline",children:tH?"Learning...":"Learn from discussion"})]}),!e&&aw(),!e&&(0,t.jsx)(eH.StatusIndicator,{}),(0,t.jsx)("button",{type:"button",onClick:()=>e0(!eQ),"aria-label":eQ?"Hide logs":`Show logs${O.length>0?` (${O.length})`:""}`,"aria-pressed":eQ,title:eQ?"Hide logs":`Show logs${O.length>0?` (${O.length})`:""}`,className:`inline-flex h-9 w-9 items-center justify-center rounded-xl border transition-all focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ring)] ${eQ?"border-[var(--app-shell-border-strong)] bg-[var(--app-shell-subtle)] text-[var(--foreground)]":"border-[var(--app-shell-border)] bg-[var(--app-shell-elevated)] text-[var(--app-shell-muted)] hover:bg-[var(--app-shell-subtle)] hover:text-[var(--foreground)]"}`,children:(0,t.jsx)(eL.default,{className:"h-4 w-4",strokeWidth:1.75})})]})]})}):ak,tA?(0,t.jsx)(ev,{query:tP,results:tn,total:to,participants:ep,threadTitleById:tE,isLoading:tc,error:tp,onSelectResult:ae}):tt?(0,t.jsx)(ef,{messages:A,streaming:J,participants:ep,rootMessageId:tt,queued:K.some(e=>e.rootMessageId===tt&&"queued"===e.status),onClose:()=>tr(null),onCopyThread:tV,onAddToChat:tq,onDeleteThreadRoot:aa,onDeleteMessage:as,highlightedMessageId:te||void 0,renderReplyComposer:am,activeProcesses:V.filter(e=>["spawning","running"].includes(e.state)&&e.threadId===tt)}):(0,t.jsx)(ed,{messages:A,streaming:J,participants:ep,onOpenThread:t4,onCopyThread:tV,onAddToChat:tq,onDeleteThreadRoot:aa,onSummarize:t0,onCreateTasks:t1,onUpdateTaskDraft:t5,onBuildTasks:t2,summarizingThreads:tm,extractingTasks:tk,buildingDrafts:tC,taskDrafts:tj,deletingThreadRootId:tx,highlightedMessageId:te,shipModeThreads:e1,onUpdateMessageThreadStatus:v?(e,t)=>{E(a=>a.map(a=>a.id===e?{...a,threadStatus:t}:a)),R(v,e,t),fetch("/api/threads",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootMessageId:e,status:t})})}:void 0,onUpdateMessageOutcomeNote:v?(e,t)=>{E(a=>a.map(a=>a.id===e?{...a,outcomeNote:t}:a)),P(v,e,t);let a=A.find(t=>t.id===e);fetch("/api/threads",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootMessageId:e,status:a?.threadStatus??null,outcomeNote:t})})}:void 0}),!tA&&!tt&&(0,t.jsx)(eb.Composer,{onSend:t7,onStop:Z,loading:"ready"!==G,activityStatus:G,participants:tO,projects:tU,projectGroups:ec,projectSlug:eu,messages:A,commands:ao,pendingThreadInsert:tB,onClearPendingThread:()=>tW(null),autoMode:ta,onAutoModeChange:t9,repos:ad,selectedRepoIds:ac,onRepoSelectionChange:ah})]})})}),u&&(0,t.jsx)(eJ,{logs:O,participants:ep,onClear:()=>void D(v),open:eQ,onToggle:()=>e0(!1)}),(0,t.jsx)(eO.default,{isOpen:null!==tv,title:tv?.type==="thread"?"Delete Discussion":"Delete Message",message:tv?.type==="thread"?"This will permanently delete this discussion and all of its replies. This action cannot be undone.":"This will permanently delete this message. This action cannot be undone.",preview:tv?.preview,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"danger",onConfirm:an,onCancel:ai})]})}],186552)}]);
2
+ ${e.description.replace(/\n/g,"\n ")}`),a}).join("\n");navigator.clipboard.writeText(t).then(()=>{u(!0),setTimeout(()=>u(!1),1500)})},[e.tasks]),h=(0,a.useCallback)((t,a)=>{let s=e.tasks.map(e=>e.id===t?{...e,...a}:e);r({...e,tasks:s,revision:e.revision+1})},[e,r]),m=(0,a.useCallback)(t=>{let a=e.tasks.filter(e=>e.id!==t);r({...e,tasks:a,revision:e.revision+1})},[e,r]),f=(0,a.useCallback)(()=>{let t={id:crypto.randomUUID(),title:"New task",description:"Add description..."};r({...e,tasks:[...e.tasks,t],revision:e.revision+1})},[e,r]),x=(0,a.useCallback)(()=>{d(!0)},[]),g=(0,a.useCallback)((t,a)=>{d(!1),s(e,t,a)},[e,s]),v="idle"===e.buildStatus||!e.buildStatus;return(0,t.jsxs)("div",{className:"mt-6 p-4 bg-[var(--app-shell-subtle)]/80 rounded-2xl border border-[var(--border)] shadow-sm",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(b.Zap,{className:"w-3.5 h-3.5 text-amber-500 fill-amber-500"}),(0,t.jsx)("span",{className:"text-[10px] font-extrabold uppercase tracking-widest text-[var(--muted-foreground)]",children:"Tasks"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("span",{className:"text-[11px] font-bold text-[var(--muted-foreground)]",children:[e.tasks.length," task",1!==e.tasks.length?"s":""]}),e.tasks.length>0&&(0,t.jsx)("button",{type:"button",onClick:p,className:"text-[var(--muted-foreground)] hover:text-[var(--muted-foreground)] transition-colors",title:"Copy as markdown",children:c?(0,t.jsx)(T.Check,{className:"w-3.5 h-3.5 text-emerald-500"}):(0,t.jsx)(I.Copy,{className:"w-3.5 h-3.5"})})]})]}),(0,t.jsx)("div",{className:"space-y-1 mb-4",children:e.tasks.map(e=>{let a=n===e.id;return(0,t.jsxs)("div",{className:"group",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 py-1.5 px-2 rounded-lg hover:bg-[var(--app-shell-subtle)] transition-colors",children:[v&&(0,t.jsx)(w,{className:"w-3.5 h-3.5 text-[var(--app-shell-soft-text)] opacity-0 group-hover:opacity-100 cursor-grab shrink-0"}),(0,t.jsx)("button",{type:"button",onClick:()=>i(a?null:e.id),className:"shrink-0 text-[var(--app-shell-muted)] hover:text-[var(--foreground)]",children:a?(0,t.jsx)(y.ChevronDown,{className:"w-3.5 h-3.5"}):(0,t.jsx)(k.ChevronRight,{className:"w-3.5 h-3.5"})}),v?(0,t.jsx)("input",{type:"text",value:e.title,onChange:t=>h(e.id,{title:t.target.value}),className:"flex-1 text-xs font-semibold text-[var(--foreground)] bg-transparent border-none outline-none focus:ring-0 p-0"}):(0,t.jsx)("span",{className:"flex-1 text-xs font-semibold text-[var(--foreground)]",children:e.title}),v&&(0,t.jsx)("button",{type:"button",onClick:()=>m(e.id),className:"shrink-0 text-[var(--app-shell-soft-text)] hover:text-rose-500 opacity-0 group-hover:opacity-100 transition-all",children:(0,t.jsx)(C.X,{className:"w-3.5 h-3.5"})})]}),a&&(0,t.jsx)("div",{className:"ml-9 mr-2 mb-2",children:v?(0,t.jsx)("textarea",{value:e.description,onChange:t=>h(e.id,{description:t.target.value}),rows:4,className:"w-full text-xs text-[var(--muted-foreground)] bg-[var(--input)] border border-[var(--app-shell-border)] rounded-lg p-2 outline-none focus:ring-1 focus:ring-[var(--ring)] resize-y"}):(0,t.jsx)("p",{className:"text-xs text-[var(--muted-foreground)] whitespace-pre-wrap",children:e.description})})]},e.id)})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[v&&(0,t.jsxs)("button",{type:"button",onClick:f,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-bold text-[var(--app-shell-muted)] hover:text-[var(--foreground)] rounded-full border border-dashed border-[var(--app-shell-border)] hover:border-[var(--app-shell-border-strong)] transition-all",children:[(0,t.jsx)(N.Plus,{className:"w-3 h-3"}),"Add task"]}),(0,t.jsx)("div",{className:"flex-1"}),v&&(0,t.jsxs)("button",{type:"button",onClick:x,disabled:l||0===e.tasks.length,className:"flex items-center gap-1.5 px-4 py-1.5 text-xs font-bold text-[var(--primary-foreground)] bg-[var(--primary)] hover:bg-[var(--primary-hover)] rounded-full shadow-sm transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:[(0,t.jsx)(S,{className:"w-3 h-3"}),l?"Pushing…":"Push to agx"]})]}),o&&(0,t.jsx)(D,{onSelect:g,onClose:()=>d(!1)})]})}let B=new Set(["completed","done","failed","blocked"]);var F=e.i(807087),W=e.i(211464),q=e.i(100373),V=e.i(437307);let J={queued:(0,t.jsx)(W.Circle,{className:"w-4 h-4 text-[var(--muted-foreground)]"}),pending:(0,t.jsx)(W.Circle,{className:"w-4 h-4 text-[var(--muted-foreground)]"}),in_progress:(0,t.jsx)(O.Loader2,{className:"w-4 h-4 text-blue-500 animate-spin"}),running:(0,t.jsx)(O.Loader2,{className:"w-4 h-4 text-blue-500 animate-spin"}),blocked:(0,t.jsx)(q.Ban,{className:"w-4 h-4 text-amber-500"}),completed:(0,t.jsx)(F.CheckCircle2,{className:"w-4 h-4 text-emerald-500"}),done:(0,t.jsx)(F.CheckCircle2,{className:"w-4 h-4 text-emerald-500"}),failed:(0,t.jsx)(V.XCircle,{className:"w-4 h-4 text-rose-500"})};function H({draft:e,onPush:r,pushing:s}){let[l,n]=(0,a.useState)(!1),[i,o]=(0,a.useState)(!1),d=(0,a.useCallback)(()=>{let t=e.tasks.map((e,t)=>`${t+1}. **${e.title}**${e.description?`
3
+ ${e.description.replace(/\n/g,"\n ")}`:""}`).join("\n");navigator.clipboard.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})},[e.tasks]),{tasks:c,error:u}=function({projectId:e,enabled:t,interval:r=3e4}){let[s,l]=(0,a.useState)([]),[n,i]=(0,a.useState)(null),o=(0,a.useRef)(0),d=(0,a.useRef)([]),c=(0,a.useCallback)(async()=>{if(e&&"undefined"!==e)try{let t=M.default.env.NEXT_PUBLIC_AGX_BOARD_URL||"http://localhost:41741",a=await fetch(`${t}/api/tasks?project=${e}`);if(!a.ok)throw Error(`Poll failed: ${a.status}`);let r=await a.json(),s=r.tasks??r;d.current=s,l(s),i(null)}catch(e){i(e instanceof Error?e.message:"Poll failed")}},[e]);return(0,a.useEffect)(()=>{if(!t||!e)return;o.current=Date.now(),c();let a=setInterval(()=>{Date.now()-o.current>18e5||d.current.length>0&&d.current.every(e=>B.has(e.status))?clearInterval(a):c()},r);return()=>clearInterval(a)},[t,e,r,c]),{tasks:s,error:n,refetch:c}}({projectId:e.projectId??null,enabled:!!e.projectId&&"done"===e.buildStatus}),p=new Map;if(e.builtTaskIds)for(let[t,a]of Object.entries(e.builtTaskIds)){let e=c.find(e=>e.id===a);e&&p.set(t,e)}let h=e.tasks.filter(e=>{let t=p.get(e.id);return t&&("completed"===t.status||"done"===t.status)}).length,m=e.tasks.length>0?h/e.tasks.length:0,f=(0,a.useCallback)(()=>{e.projectId&&e.projectName?r?.(e,e.projectId,e.projectName):n(!0)},[e,r]),x=(0,a.useCallback)((t,a)=>{n(!1),r?.(e,t,a)},[e,r]);e.tasks.some(t=>!e.builtTaskIds?.[t.id]);let g=e.tasks.some(e=>{let t=p.get(e.id);return t&&"queued"!==t.status&&"pending"!==t.status});return(0,t.jsxs)("div",{className:"mt-6 p-4 bg-[var(--app-shell-subtle)]/80 rounded-2xl border border-[var(--border)] shadow-sm",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(b.Zap,{className:"w-3.5 h-3.5 text-amber-500 fill-amber-500"}),(0,t.jsx)("span",{className:"text-[10px] font-extrabold uppercase tracking-widest text-[var(--muted-foreground)]",children:"Tasks"}),e.projectName&&(0,t.jsxs)("span",{className:"text-[10px] font-semibold text-[var(--muted-foreground)]",children:["· ",e.projectName]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("span",{className:"text-[11px] font-bold text-[var(--muted-foreground)]",children:[h,"/",e.tasks.length," Complete"]}),e.tasks.length>0&&(0,t.jsx)("button",{type:"button",onClick:d,className:"text-[var(--muted-foreground)] hover:text-[var(--muted-foreground)] transition-colors",title:"Copy as markdown",children:i?(0,t.jsx)(T.Check,{className:"w-3.5 h-3.5 text-emerald-500"}):(0,t.jsx)(I.Copy,{className:"w-3.5 h-3.5"})})]})]}),(0,t.jsx)("div",{className:"space-y-3 mb-4",children:e.tasks.map(e=>{let a=p.get(e.id),r=a?.status||"queued",s=J[r]||J.queued;return(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[s,(0,t.jsx)("span",{className:"text-xs font-semibold text-[var(--muted-foreground)]",children:e.title})]},e.id)})}),(0,t.jsx)("div",{className:"h-1.5 w-full bg-[var(--muted)] rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"h-full bg-emerald-500 rounded-full shadow-[0_0_8px_rgba(16,185,129,0.4)] transition-all duration-500",style:{width:`${Math.round(100*m)}%`}})}),r&&!g&&(0,t.jsxs)("div",{className:"mt-3 flex items-center gap-3",children:["partial_failure"===e.buildStatus&&(0,t.jsx)("span",{className:"text-[11px] text-amber-600 font-semibold",children:"Some tasks failed to push."}),(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsxs)("button",{type:"button",onClick:f,disabled:s,className:"flex items-center gap-1.5 px-4 py-1.5 text-xs font-bold text-[var(--primary-foreground)] bg-[var(--primary)] hover:bg-[var(--primary-hover)] rounded-full shadow-sm transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:[(0,t.jsx)(S,{className:"w-3 h-3"}),s?"Pushing…":"Push to agx"]})]}),u&&(0,t.jsxs)("div",{className:"mt-2 text-[11px] text-amber-600 font-medium",children:["Status polling error: ",u]}),l&&(0,t.jsx)(D,{onSelect:x,onClose:()=>n(!1)})]})}let X=(0,a.forwardRef)(({children:e,className:a="",...r},s)=>{let{isTouchLayout:l}=(0,o.useInputCapabilities)(),n=`absolute top-4 right-4 flex items-center gap-1 ${l?"opacity-100":"opacity-0 group-hover:opacity-100"} transition-opacity duration-200 bg-[var(--app-shell-elevated)] border border-[var(--app-shell-border)] shadow-md rounded-lg p-1 z-10 backdrop-blur-sm`,i=`${n} ${a}`.trim();return(0,t.jsx)("div",{ref:s,className:i,"data-touch-visible":l?"true":void 0,...r,children:e})});X.displayName="ActionToolbar";let K=()=>(0,t.jsx)("div",{className:"w-px h-4 bg-[var(--app-shell-border)] mx-1"}),G=(0,a.forwardRef)(({className:e="",variant:a="neutral",size:r="md",children:s,...l},n)=>{let{isTouchLayout:i}=(0,o.useInputCapabilities)(),d=`inline-flex items-center justify-center rounded-md transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)] disabled:opacity-50 disabled:pointer-events-none ${i?({sm:"h-11 w-11 p-2",md:"h-11 w-11 p-2",lg:"h-12 w-12 p-2.5"})[r]:({sm:"p-1 w-6 h-6",md:"p-1.5 w-8 h-8",lg:"p-2 w-10 h-10"})[r]} ${({neutral:"text-[var(--app-shell-muted)] hover:text-[var(--foreground)] hover:bg-[var(--app-shell-subtle)]",ghost:"text-[var(--muted-foreground)] hover:text-[var(--foreground)] hover:bg-[var(--muted)]",primary:"text-[var(--primary)] hover:text-[var(--primary-foreground)] hover:bg-[var(--primary-hover)]",destructive:"text-[var(--app-shell-muted)] hover:text-[var(--destructive)] hover:bg-[var(--destructive-muted)]"})[a]} ${e}`.trim();return(0,t.jsx)("button",{ref:n,className:d,"data-touch-target":i?"true":void 0,...l,children:s})});G.displayName="IconButton";var Y=e.i(597628),Z=e.i(629155),Q=e.i(794731),ee=e.i(169610),et=e.i(580873);let ea=(0,j.default)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]),er=(0,j.default)("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),es=(0,j.default)("at-sign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);var el=e.i(999824);let en=[{value:"active",label:"Active",color:"#f59e0b"},{value:"paused",label:"Paused",color:"#f97316"},{value:"in-review",label:"In Review",color:"#6b7280"},{value:"done",label:"Done",color:"#3b82f6"},{value:"archived",label:"Archived",color:"#9ca3af"}],ei=new Set(["done","in-review","archived"]),eo="<!-- thread-summary -->";function ed({messages:e,streaming:r,participants:s,onOpenThread:l,onCopyThread:n,onAddToChat:i,onDeleteThreadRoot:o,onSummarize:d,onCreateTasks:m,onUpdateTaskDraft:x,onBuildTasks:g,summarizingThreads:b,extractingTasks:j,buildingDrafts:w,taskDrafts:y,deletingThreadRootId:k,highlightedMessageId:N,onUpdateMessageThreadStatus:C,onUpdateMessageOutcomeNote:S,shipModeThreads:T}){let M=(0,a.useRef)(new Map),[$,R]=(0,a.useState)(null),[P,A]=(0,a.useState)("active"),E=Object.fromEntries(s.map(e=>[e.id,e])),_=(0,a.useMemo)(()=>[...e.filter(e=>!e.rootMessageId)].reverse(),[e]),U={active:new Set(["active"]),paused:new Set(["paused"]),"in-review":new Set(["in-review"]),done:new Set(["done"]),archived:new Set(["archived"])},z=(0,a.useMemo)(()=>_.filter(e=>U[P].has(e.threadStatus??"active")),[_,P]),D=(0,a.useMemo)(()=>({active:_.filter(e=>U.active.has(e.threadStatus??"active")).length,paused:_.filter(e=>U.paused.has(e.threadStatus??"active")).length,"in-review":_.filter(e=>U["in-review"].has(e.threadStatus??"active")).length,done:_.filter(e=>U.done.has(e.threadStatus??"active")).length,archived:_.filter(e=>U.archived.has(e.threadStatus??"active")).length}),[_]),B=(0,a.useMemo)(()=>(function(e){let t=new Map;for(let a of e){let e=a.rootMessageId;if(!e)continue;let r=t.get(e);r||(r={rootMessageId:e,replyCount:0,participants:[],lastActivityAt:0,allReplies:[]},t.set(e,r)),r.replyCount++,r.lastActivityAt=Math.max(r.lastActivityAt,a.timestamp),r.lastReply=a,r.allReplies.push(a),a.participantId&&!r.participants.includes(a.participantId)?r.participants.push(a.participantId):a.participantId||r.participants.includes("user")||r.participants.push("user")}for(let e of t.values())e.allReplies.sort((e,t)=>e.timestamp-t.timestamp);return t})(e),[e]),F=(0,a.useCallback)((e,t)=>{t?M.current.set(e,t):M.current.delete(e)},[]),W=(0,a.useRef)(null);return(0,a.useEffect)(()=>{if(!N){W.current=null;return}if(N===W.current)return;W.current=N;let e=M.current.get(N);e&&e.scrollIntoView({behavior:"smooth",block:"center"})},[N,e]),(0,t.jsx)("div",{className:"chat-scrollbar flex-1 overflow-y-auto p-4",children:(0,t.jsxs)("div",{className:"max-w-3xl mx-auto",children:[_.length>0&&(0,t.jsx)("div",{className:"flex items-center justify-center gap-1 p-1 rounded-lg w-fit mx-auto border border-[var(--app-shell-border)] bg-[var(--app-shell-subtle)] mb-4",children:[{key:"active",label:"Active"},{key:"paused",label:"Paused"},{key:"in-review",label:"In Review"},{key:"done",label:"Done"},{key:"archived",label:"Archived"}].map(e=>{let a=D[e.key],r=P===e.key;return(0,t.jsxs)("button",{type:"button",onClick:()=>A(e.key),className:`px-3 py-1.5 text-xs font-bold rounded-md transition-all ${r?"bg-[var(--app-shell-surface)] text-[var(--foreground)] shadow-sm":"text-[var(--app-shell-muted)] hover:text-[var(--foreground)]"}`,children:[e.label,a>0&&(0,t.jsx)("span",{className:`ml-1.5 text-[10px] ${r?"opacity-60":"opacity-50"}`,children:a})]},e.key)})}),0===_.length&&0===Object.keys(r).length&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center text-[var(--app-shell-muted)] mt-32 space-y-3",children:[(0,t.jsx)(Y.MessageSquare,{className:"h-6 w-6",strokeWidth:1.5}),(0,t.jsx)("span",{className:"text-sm font-medium tracking-wide",children:"Start a thread"})]}),_.length>0&&0===z.length&&(0,t.jsx)("div",{className:"flex flex-col items-center justify-center text-[var(--app-shell-muted)] mt-16 space-y-2",children:(0,t.jsxs)("span",{className:"text-sm font-medium",children:["No ",P," threads"]})}),z.map(e=>{let a,s=e.participantId?E[e.participantId]:null,N=B.get(e.id),S=k===e.id,M=N?.allReplies.find(e=>e.content.startsWith(eo)),P=M?M.content.slice(eo.length).trim():null,A=e.threadStatus??"active",_=ei.has(A),U=en.find(e=>e.value===A)??en[0],z=Object.values(r).some(t=>t.rootMessageId===e.id);if(_){let a;return(0,t.jsx)("div",{ref:t=>F(e.id,t),"data-message-id":e.id,className:`max-w-2xl mx-auto bg-[var(--app-shell-subtle)] rounded-xl border border-[var(--app-shell-border)] mb-3 group transition-all hover:border-[var(--app-shell-border-strong)] relative cursor-pointer ${$===e.id?"z-50":""}`,onClick:()=>l?.(e.id),children:(0,t.jsxs)("div",{className:"px-4 py-2.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(Z.Hash,{className:"w-3.5 h-3.5 text-[var(--app-shell-muted)] shrink-0"}),(0,t.jsx)("span",{className:"text-sm font-medium text-[var(--app-shell-muted)] truncate flex-1",children:(0,h.stripMarkers)(e.content.split("\n")[0])}),T?.has(e.id)&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] text-indigo-500 font-medium shrink-0",title:"Ship Mode active",children:[(0,t.jsx)(el.Rocket,{size:11,style:{animation:"shipPulse 2s ease-in-out infinite"}}),"Ship"]}),z&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] text-green-600 font-medium shrink-0",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 animate-pulse"}),"Working"]}),e.outcomeNote&&(0,t.jsx)("span",{className:"text-[11px] text-[var(--app-shell-soft-text)] truncate max-w-[200px]",children:e.outcomeNote}),(0,t.jsx)("span",{className:"text-[10px] text-[var(--app-shell-soft-text)] shrink-0",children:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(e.timestamp)}),C&&(a=$===e.id,(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("button",{type:"button",onClick:t=>{t.stopPropagation(),R(a?null:e.id)},className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-semibold border transition-colors hover:bg-[var(--app-shell-elevated)]",style:{borderColor:U.color+"40",color:U.color},children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:U.color}}),U.label]}),a&&(0,t.jsx)("div",{className:"absolute top-full right-0 mt-1 z-50 bg-[var(--app-shell-elevated)] border border-[var(--app-shell-border)] rounded-lg shadow-lg p-1 min-w-[8.5rem]",onClick:e=>e.stopPropagation(),children:en.map(a=>(0,t.jsxs)("button",{type:"button",className:`flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-xs font-medium transition-colors ${a.value===A?"bg-[var(--primary-muted)] text-[var(--primary)]":"text-[var(--muted-foreground)] hover:bg-[var(--app-shell-subtle)]"}`,onClick:t=>{t.stopPropagation(),C(e.id,a.value),R(null)},children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:a.color}}),a.label]},a.value))})]})),N&&N.replyCount>0&&(0,t.jsxs)("span",{className:"text-[10px] text-[var(--app-shell-muted)] shrink-0",children:[N.replyCount," replies"]})]}),(P||y?.[e.id])&&(0,t.jsxs)("div",{className:"mt-1.5 pl-6 flex flex-col gap-1",children:[P&&(0,t.jsx)("div",{className:"text-sm text-[var(--muted-foreground)] leading-relaxed prose prose-sm prose-neutralmax-w-none",children:(0,t.jsx)(u.Markdown,{content:P,isUser:!1})}),y?.[e.id]&&y[e.id].tasks.length>0&&(0,t.jsxs)("span",{className:"text-[10px] text-[var(--app-shell-muted)] flex items-center gap-1",children:[(0,t.jsx)(ea,{className:"w-3 h-3"}),y[e.id].tasks.length," ",1===y[e.id].tasks.length?"task":"tasks"]})]})]})},e.id)}return(0,t.jsxs)("div",{className:`max-w-2xl mx-auto surface-card mb-6 group relative ${$===e.id?"z-50":""}`,children:[(n||i||o)&&(0,t.jsxs)(X,{className:"z-10",children:[i&&(0,t.jsx)(G,{type:"button",variant:"primary",size:"sm",onClick:()=>i(e.id),title:"Mention in chat",children:(0,t.jsx)(es,{className:"w-3.5 h-3.5"})}),(0,t.jsx)(G,{type:"button",variant:"neutral",size:"sm",onClick:()=>{navigator.clipboard.writeText(e.id)},title:"Copy message ID",children:(0,t.jsx)(er,{className:"w-3.5 h-3.5"})}),n&&(0,t.jsx)(G,{type:"button",variant:"neutral",size:"sm",onClick:()=>n(e.id),title:"Copy thread as markdown",children:(0,t.jsx)(I.Copy,{className:"w-3.5 h-3.5"})}),o&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(K,{}),(0,t.jsx)(G,{type:"button",variant:"destructive",size:"sm",onClick:()=>o(e.id),disabled:S,title:"Delete this thread",children:S?(0,t.jsx)(O.Loader2,{className:"w-3.5 h-3.5 animate-spin"}):(0,t.jsx)(Q.Trash2,{className:"w-3.5 h-3.5"})})]})]}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("div",{className:"p-5",children:(0,t.jsxs)("div",{ref:t=>F(e.id,t),"data-message-id":e.id,className:"flex flex-col",children:[(0,t.jsxs)("div",{className:"flex gap-3 mb-4",children:["user"!==e.role&&(0,t.jsx)(c.default,{href:`/agents/${s?.id||e.participantId||"assistant"}`,className:"w-10 h-10 rounded-full bg-[var(--app-shell-subtle)] overflow-hidden border border-[var(--app-shell-border)] shadow-sm flex items-center justify-center shrink-0 hover:ring-2 hover:ring-[var(--ring)] transition-shadow",children:s?(0,t.jsx)("img",{src:(0,p.agentAvatarUrl)(s.id,40,s.color),alt:s.name,className:"w-full h-full object-cover"}):(0,t.jsx)("img",{src:(0,p.agentAvatarUrl)(e.participantId||"assistant",40),alt:e.participantId||"Assistant",className:"w-full h-full object-cover"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 pt-0.5",children:["user"!==e.role&&(0,t.jsx)("div",{className:"flex items-center gap-2 mb-0.5",children:(0,t.jsx)(c.default,{href:`/agents/${s?.id||e.participantId||"assistant"}`,className:"font-bold text-sm text-[var(--foreground)] hover:underline",children:s?.name||e.participantId||"Assistant"})}),(0,t.jsxs)("div",{className:"cursor-pointer group/msg-title mb-1",onClick:()=>l?.(e.id),children:[(0,t.jsx)("h3",{className:"text-lg font-bold text-[var(--foreground)] leading-tight group-hover/msg-title:text-[var(--primary)] transition-colors line-clamp-1",children:(0,h.stripMarkers)(e.content.split("\n")[0])}),(0,t.jsxs)("div",{className:"mt-1 flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-[11px] font-medium text-[var(--app-shell-soft-text)]",children:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(e.timestamp)}),C&&(a=$===e.id,(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("button",{type:"button",onClick:t=>{t.stopPropagation(),R(a?null:e.id)},className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-semibold border transition-colors hover:bg-[var(--app-shell-subtle)]",style:{borderColor:U.color+"40",color:U.color},children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:U.color}}),U.label]}),a&&(0,t.jsx)("div",{className:"absolute top-full left-0 mt-1 z-50 bg-[var(--app-shell-elevated)] border border-[var(--app-shell-border)] rounded-lg shadow-lg p-1 min-w-[8.5rem]",onClick:e=>e.stopPropagation(),children:en.map(a=>(0,t.jsxs)("button",{type:"button",className:`flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-xs font-medium transition-colors ${a.value===A?"bg-[var(--primary-muted)] text-[var(--primary)]":"text-[var(--muted-foreground)] hover:bg-[var(--app-shell-subtle)]"}`,onClick:t=>{t.stopPropagation(),C(e.id,a.value),R(null)},children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:a.color}}),a.label]},a.value))})]})),T?.has(e.id)&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] text-indigo-500 font-medium",title:"Ship Mode active",children:[(0,t.jsx)(el.Rocket,{size:11,style:{animation:"shipPulse 2s ease-in-out infinite"}}),"Ship"]}),z&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] text-green-600 font-medium",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 animate-pulse"}),"Working"]})]}),(e.content.length>80||e.content.includes("\n"))&&(0,t.jsx)("div",{className:"mt-2 text-[15px] text-[var(--muted-foreground)] leading-relaxed line-clamp-3",children:(0,t.jsx)(u.Markdown,{content:(0,h.stripMarkers)(e.content.split("\n").slice(1).join("\n").trimStart()),isUser:"user"===e.role})})]})]})]}),e.attachments&&e.attachments.length>0&&(0,t.jsx)("div",{className:`mb-4 ${"user"!==e.role?"ml-[52px]":""}`,children:(0,t.jsx)(v,{attachments:e.attachments,compact:!0})}),P&&(0,t.jsx)("div",{className:"mb-4 text-sm text-[var(--muted-foreground)] leading-relaxed",children:(0,t.jsx)(u.Markdown,{content:P,isUser:!1})}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pt-2 mt-2 border-t border-[var(--card-border)]",children:[d&&N&&N.replyCount>0&&(0,t.jsxs)("button",{type:"button",onClick:()=>d(e.id),disabled:b?.has(e.id),className:"flex items-center gap-1.5 px-3 py-1.5 bg-[var(--app-shell-subtle)] hover:bg-[var(--item-hover-bg)] text-[var(--foreground)] border border-[var(--card-border)] text-xs font-medium rounded-lg transition-colors disabled:opacity-50",children:[b?.has(e.id)?(0,t.jsx)(O.Loader2,{className:"w-3.5 h-3.5 animate-spin text-[var(--muted-foreground)]"}):(0,t.jsx)(et.Clock,{className:"w-3.5 h-3.5 text-[var(--muted-foreground)]"}),b?.has(e.id)?"Summarizing…":"Summarize"]}),m&&N&&N.replyCount>0&&(0,t.jsxs)("button",{type:"button",onClick:()=>m(e.id),disabled:j?.has(e.id),className:"flex items-center gap-1.5 px-3 py-1.5 bg-[var(--app-shell-subtle)] hover:bg-[var(--item-hover-bg)] text-[var(--foreground)] border border-[var(--card-border)] text-xs font-medium rounded-lg transition-colors disabled:opacity-50",children:[j?.has(e.id)?(0,t.jsx)(O.Loader2,{className:"w-3.5 h-3.5 animate-spin text-[var(--muted-foreground)]"}):(0,t.jsx)(ea,{className:"w-3.5 h-3.5 text-[var(--muted-foreground)]"}),j?.has(e.id)?"Extracting…":y?.[e.id]?"Re-extract tasks":"Create tasks"]}),N&&N.replyCount>0&&l&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>l(e.id),children:[(0,t.jsxs)("span",{className:"text-xs text-[var(--muted-foreground)] font-medium",children:[N.replyCount," replies"]}),(0,t.jsx)("div",{className:"flex -space-x-2",children:N.participants.slice(0,3).map(e=>{if("user"===e)return(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-[var(--app-shell-subtle)] border-2 border-[var(--card-bg)] flex items-center justify-center z-10",children:(0,t.jsx)(ee.User,{className:"w-3 h-3 text-[var(--muted-foreground)]"})},"user");let a=E[e];return a?(0,t.jsx)("img",{src:(0,p.agentAvatarUrl)(e,24,a.color),alt:a.name,className:"w-6 h-6 rounded-full border-2 border-[var(--card-bg)] object-cover z-10"},e):(0,t.jsx)("div",{className:"w-6 h-6 rounded-full bg-[var(--app-shell-subtle)] border-2 border-[var(--card-bg)] z-10"},e)})})]})]}),y?.[e.id]&&(y[e.id].builtTaskIds&&Object.keys(y[e.id].builtTaskIds).length>0?(0,t.jsx)(H,{draft:y[e.id],onPush:(t,a,r)=>g?.(e.id,t,a,r),pushing:w?.has(y[e.id].draftId)}):(0,t.jsx)(L,{draft:y[e.id],onUpdate:t=>x?.(e.id,t),onBuild:(t,a,r)=>g?.(e.id,t,a,r),building:w?.has(y[e.id].draftId)})),j?.has(e.id)&&(0,t.jsxs)("div",{className:"mt-4 flex items-center gap-2 text-xs text-[var(--app-shell-muted)]",children:[(0,t.jsx)(O.Loader2,{className:"w-3.5 h-3.5 animate-spin"}),(0,t.jsx)("span",{children:"Extracting tasks…"})]})]})}),Object.entries(r).filter(([,t])=>t.rootMessageId===e.id).map(([e,a])=>{let r=E[e];return(0,t.jsx)("div",{className:"px-6 pb-4",children:(0,t.jsx)(f,{participantId:e,participantName:r?.name||e,participantColor:r?.color||"#888",content:a.content})},`streaming-${e}`)})]})]},e.id)})]})})}let ec=(0,j.default)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]);var eu=e.i(519132);let ep={ack:{symbol:"👍",label:"Acknowledged"},working:{symbol:"🔄",label:"Working"},done:{symbol:"✅",label:"Done"},clarify:{symbol:"❓",label:"Needs clarification"},blocked:{symbol:"⛔",label:"Blocked"}};function eh({type:e,count:a,participantIds:r}){let s=ep[e],l=r.join(", "),n=l?`${s.label}: ${l}`:s.label;return(0,t.jsxs)("span",{title:n,className:"inline-flex items-center gap-1 rounded-full border border-[var(--app-shell-border)] bg-[var(--app-shell-surface)] px-2 py-0.5 text-xs text-[var(--foreground)]",children:[(0,t.jsx)("span",{"aria-hidden":!0,children:s.symbol}),(0,t.jsx)("span",{className:"tabular-nums",children:a})]})}function em({reactions:e}){if(!e||0===e.length)return null;let a=[...e].sort((e,t)=>t.count!==e.count?t.count-e.count:e.type.localeCompare(t.type));return(0,t.jsx)("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:a.map(e=>(0,t.jsx)(eh,{type:e.type,count:e.count,participantIds:e.participantIds},e.type))})}function ef({messages:e,streaming:r,participants:s,rootMessageId:l,queued:n=!1,onClose:i,onCopyThread:o,onAddToChat:d,onDeleteThreadRoot:m,onDeleteMessage:f,highlightedMessageId:x,renderReplyComposer:g,activeProcesses:b=[]}){let j=(0,a.useRef)(null),w=(0,a.useRef)(new Map),y=Object.fromEntries(s.map(e=>[e.id,e])),k=(0,a.useMemo)(()=>{let t=e.find(e=>e.id===l),a=e.filter(e=>e.rootMessageId===l).sort((e,t)=>e.timestamp-t.timestamp);return t?[t,...a]:a},[e,l]),N=(0,a.useRef)(null),C=(0,a.useRef)(!1),S=(0,a.useRef)(null);return(0,a.useEffect)(()=>{let e=N.current;if(!e)return;let t=()=>{let{scrollTop:t,scrollHeight:a,clientHeight:r}=e;C.current=a-t-r>80};return e.addEventListener("scroll",t,{passive:!0}),()=>e.removeEventListener("scroll",t)},[]),(0,a.useEffect)(()=>{if(x&&x!==S.current){S.current=x;let e=w.current.get(x);e&&e.scrollIntoView({behavior:"smooth",block:"center"})}else x||C.current||(S.current=null,j.current?.scrollIntoView({behavior:"smooth"}))},[x,k,r]),(0,t.jsxs)("div",{className:"flex flex-col h-full overflow-hidden bg-[var(--app-shell-bg)] transition-colors",children:[b.length>0&&(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-2 border-b border-[var(--app-shell-border)] bg-[var(--app-shell-surface)] backdrop-blur-md transition-colors",children:[(0,t.jsxs)("div",{className:"inline-flex items-center gap-2 text-[11px] font-medium text-[var(--app-shell-muted)]",children:[(0,t.jsx)(eu.Sparkles,{className:"h-3.5 w-3.5 text-indigo-500",strokeWidth:1.75}),(0,t.jsx)("span",{className:"uppercase tracking-[0.16em]",children:"Working"})]}),(0,t.jsx)("div",{className:"flex items-center -space-x-1.5",children:b.map(e=>{let a=y[e.agentId];return(0,t.jsxs)("div",{className:"relative",title:`${a?.name||e.agentId} — ${e.state}`,children:[(0,t.jsx)("img",{src:(0,p.agentAvatarUrl)(e.agentId,24,a?.color),alt:a?.name||e.agentId,className:"w-6 h-6 rounded-full border-2 border-[var(--app-shell-surface)] shadow-sm"}),(0,t.jsx)("span",{className:"absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 bg-green-400 rounded-full border-2 border-[var(--app-shell-surface)] animate-pulse"})]},e.agentId)})})]}),(0,t.jsx)("div",{ref:N,className:"flex-1 overflow-y-auto p-4 md:p-8 space-y-6 chat-scrollbar",children:(0,t.jsxs)("div",{className:"max-w-2xl mx-auto space-y-8 pb-4",children:[k.map(e=>{let a,r="user"===e.role,s=e.participantId?y[e.participantId]:null;return(0,t.jsxs)("div",{ref:t=>{var a;return a=e.id,void(t?w.current.set(a,t):w.current.delete(a))},"data-message-id":e.id,className:"group relative flex gap-4 ",children:[(0,t.jsx)("div",{className:"flex-shrink-0 mt-1",children:r?(0,t.jsx)("div",{className:"w-9 h-9 bg-[var(--app-shell-subtle)] rounded-full flex items-center justify-center text-[var(--app-shell-muted)] shadow-sm",children:(0,t.jsx)(ee.User,{className:"w-5 h-5"})}):(0,t.jsx)(c.default,{href:`/agents/${s?.id||e.participantId||"assistant"}`,className:"hover:ring-2 hover:ring-[var(--ring)] rounded-full transition-shadow",children:(0,t.jsx)("img",{src:s?(0,p.agentAvatarUrl)(s.id,36,s.color):(0,p.agentAvatarUrl)(e.participantId||"assistant",36),alt:s?.name||e.participantId||"Assistant",className:"w-9 h-9 rounded-full shadow-sm border border-[var(--app-shell-border)] object-cover bg-[var(--app-shell-subtle)]"})})}),(0,t.jsxs)("div",{className:"flex-1 space-y-1.5 max-w-full overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[r?(0,t.jsx)("span",{className:"font-bold text-sm text-[var(--foreground)]",children:"You"}):(0,t.jsx)(c.default,{href:`/agents/${s?.id||e.participantId||"assistant"}`,className:"font-bold text-sm text-[var(--foreground)] hover:underline",style:s?.color?{color:s.color}:void 0,children:s?.name||e.participantId||"Assistant"}),void 0===e.rootMessageId&&e.id===l&&(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 bg-[var(--app-shell-elevated)] text-[var(--app-shell-muted)] rounded font-mono uppercase",children:"ROOT"}),(0,t.jsx)("span",{className:"text-[11px] text-[var(--app-shell-soft-text)]",children:(a=e.timestamp,new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(a))})]}),(0,t.jsxs)("div",{className:`surface-card rounded-2xl p-5 text-[15px] leading-relaxed ${e.id===x?"ring-2 ring-[var(--ring)]":""}`,children:[(0,t.jsx)(u.Markdown,{content:(0,h.stripMarkers)(e.content),isUser:r}),e.attachments&&e.attachments.length>0&&(0,t.jsx)(v,{attachments:e.attachments}),e.reactions&&e.reactions.length>0&&(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(em,{reactions:e.reactions})})]}),(0,t.jsxs)(X,{children:[e.id===l&&(0,t.jsx)(G,{variant:"primary",size:"sm",onClick:()=>navigator.clipboard.writeText(e.id),title:"Copy message ID",children:(0,t.jsx)(er,{className:"w-3.5 h-3.5"})}),e.id===l&&o&&(0,t.jsx)(G,{variant:"neutral",size:"sm",onClick:()=>o(e.id),title:"Copy Thread",children:(0,t.jsx)(ec,{className:"w-3.5 h-3.5"})}),(0,t.jsx)(G,{variant:"neutral",size:"sm",onClick:()=>navigator.clipboard.writeText(e.content),title:"Copy as Markdown",children:(0,t.jsx)(I.Copy,{className:"w-3.5 h-3.5"})}),e.id===l&&m&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(K,{}),(0,t.jsx)(G,{variant:"destructive",size:"sm",onClick:()=>m(e.id),title:"Delete Thread",children:(0,t.jsx)(Q.Trash2,{className:"w-3.5 h-3.5"})})]}),e.id!==l&&f&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(K,{}),(0,t.jsx)(G,{variant:"destructive",size:"sm",onClick:()=>f(e.id),title:"Delete Message",children:(0,t.jsx)(Q.Trash2,{className:"w-3.5 h-3.5"})})]})]})]})]},e.id)}),n&&0===b.length&&(0,t.jsxs)("div",{className:"flex gap-3 group relative opacity-80 animate-in fade-in slide-in-from-bottom-1 duration-300",children:[(0,t.jsx)("div",{className:"flex-shrink-0 mt-0.5",children:(0,t.jsx)("div",{className:"w-7 h-7 rounded-full border border-[var(--app-shell-border)] bg-[var(--app-shell-subtle)] flex items-center justify-center",children:(0,t.jsx)(eu.Sparkles,{className:"w-3.5 h-3.5 text-[var(--app-shell-soft-text)]",strokeWidth:1.5})})}),(0,t.jsx)("div",{className:"flex-1 max-w-full overflow-hidden",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 py-1",children:[(0,t.jsx)("span",{className:"text-xs tracking-wide text-[var(--app-shell-soft-text)]",children:"Processing"}),(0,t.jsxs)("span",{className:"inline-flex items-center gap-[3px]",children:[(0,t.jsx)("span",{className:"w-1 h-1 rounded-full bg-[var(--app-shell-soft-text)]/50 animate-[pulse-dot_1.4s_ease-in-out_infinite]"}),(0,t.jsx)("span",{className:"w-1 h-1 rounded-full bg-[var(--app-shell-soft-text)]/50 animate-[pulse-dot_1.4s_ease-in-out_0.2s_infinite]"}),(0,t.jsx)("span",{className:"w-1 h-1 rounded-full bg-[var(--app-shell-soft-text)]/50 animate-[pulse-dot_1.4s_ease-in-out_0.4s_infinite]"})]})]})})]}),Object.entries(r).filter(([,e])=>e.rootMessageId===l).map(([e,a])=>{let r=y[e],s=a.content.trim().length>0;return(0,t.jsxs)("div",{className:"flex gap-4 group relative animate-in fade-in slide-in-from-bottom-2 duration-300",children:[(0,t.jsx)("div",{className:"flex-shrink-0 mt-1",children:(0,t.jsx)(c.default,{href:`/agents/${r?.id||e}`,className:"hover:ring-2 hover:ring-[var(--ring)] rounded-full transition-shadow",children:(0,t.jsx)("img",{src:r?(0,p.agentAvatarUrl)(r.id,36,r.color):(0,p.agentAvatarUrl)(e,36),alt:r?.name||e,className:"w-9 h-9 rounded-full shadow-sm border border-[var(--app-shell-border)] object-cover bg-[var(--app-shell-subtle)]"})})}),(0,t.jsxs)("div",{className:"flex-1 space-y-1.5 max-w-full overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(c.default,{href:`/agents/${r?.id||e}`,className:"font-bold text-sm text-[var(--foreground)] hover:underline",style:r?.color?{color:r.color}:void 0,children:r?.name||e}),!s&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-[3px]",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--app-shell-muted)] animate-[pulse-dot_1.4s_ease-in-out_infinite]"}),(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--app-shell-muted)] animate-[pulse-dot_1.4s_ease-in-out_0.2s_infinite]"}),(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--app-shell-muted)] animate-[pulse-dot_1.4s_ease-in-out_0.4s_infinite]"})]})]}),s&&(0,t.jsx)("div",{className:"surface-card rounded-2xl p-5 text-[15px] leading-relaxed",children:(0,t.jsx)(u.Markdown,{content:(0,h.stripMarkers)(a.content),isUser:!1})})]})]},`streaming-${e}`)}),(0,t.jsx)("div",{ref:j,className:"h-4"})]})}),(0,t.jsx)("div",{className:"z-20 transition-colors duration-200",children:g(l)})]})}var ex=e.i(51297);let eg=(0,j.default)("search-x",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);function ev({query:e,results:a,total:r,participants:s,threadTitleById:l,isLoading:n,error:i,onSelectResult:o,headerSlot:d}){let u=Object.fromEntries(s.map(e=>[e.id,e]));return(0,t.jsx)("div",{className:"chat-scrollbar flex-1 overflow-y-auto p-4",children:(0,t.jsxs)("div",{className:"max-w-3xl mx-auto",children:[d?(0,t.jsx)("div",{className:"sticky top-0 z-20 bg-[var(--app-shell-subtle)]/70 backdrop-blur-md pt-4 pb-6 px-4 -mx-4 border-b border-transparent transition-colors",children:(0,t.jsx)("div",{className:"max-w-2xl mx-auto",children:d})}):null,(0,t.jsxs)("div",{className:"mb-4 rounded-xl border border-[var(--card-border)] bg-[var(--card-bg)] px-4 py-3",children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-[var(--foreground)]",children:"Search results"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-[var(--muted-foreground)]",children:n?"Searching…":`${r} result${1===r?"":"s"} for "${e}"`}),i?(0,t.jsx)("div",{className:"mt-2 text-sm text-rose-600",children:i}):null]}),n||i||0!==a.length?null:(0,t.jsxs)("div",{className:"mt-20 flex flex-col items-center justify-center space-y-2 text-[var(--app-shell-muted)]",children:[(0,t.jsx)(eg,{className:"h-6 w-6",strokeWidth:1.5}),(0,t.jsx)("p",{className:"text-sm font-medium",children:"No matching messages"})]}),(0,t.jsx)("div",{className:"space-y-3 pb-6",children:a.map(e=>{var a;let r=e.participantId?u[e.participantId]:null,s=l[e.threadId]||"Untitled thread",n="user"===e.role?"You":r?.name||e.participantId||"Assistant";return(0,t.jsxs)("button",{type:"button",onClick:()=>o(e),className:"w-full rounded-xl border border-[var(--border)] bg-[var(--card-bg)] p-4 text-left transition hover:border-[var(--border)] hover:shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-slate-400",children:[(0,t.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)("div",{className:"flex h-8 w-8 items-center justify-center overflow-hidden rounded-full bg-[var(--muted)]",children:"user"===e.role?(0,t.jsx)(ee.User,{className:"h-4 w-4 text-[var(--foreground)]"}):r?(0,t.jsx)(c.default,{href:`/agents/${r.id}`,onClick:e=>e.stopPropagation(),className:"h-full w-full hover:ring-2 hover:ring-blue-300 rounded-full transition-shadow",children:(0,t.jsx)("img",{src:(0,p.agentAvatarUrl)(r.id,32,r.color),alt:"",className:"h-full w-full object-cover"})}):(0,t.jsx)(ex.Bot,{className:"h-4 w-4 text-[var(--foreground)]"})}),(0,t.jsxs)("div",{className:"min-w-0",children:["user"!==e.role&&r?(0,t.jsx)(c.default,{href:`/agents/${r.id}`,onClick:e=>e.stopPropagation(),className:"truncate text-sm font-semibold text-[var(--foreground)] hover:underline block",children:n}):(0,t.jsx)("p",{className:"truncate text-sm font-semibold text-[var(--foreground)]",children:n}),(0,t.jsx)("p",{className:"truncate text-xs text-[var(--muted-foreground)]",children:s})]})]}),(0,t.jsx)("span",{className:"shrink-0 text-xs text-[var(--muted-foreground)]",children:(a=e.timestamp,new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(a))})]}),(0,t.jsx)("p",{className:"text-sm leading-relaxed text-[var(--foreground)]",children:function(e){let a=e.split(/(<\/?mark>)/g),r=!1,s=[];for(let[e,l]of a.entries()){if("<mark>"===l){r=!0;continue}if("</mark>"===l){r=!1;continue}l&&s.push(r?(0,t.jsx)("mark",{className:"rounded bg-amber-200/80 px-0.5",children:l},`${e}-mark`):(0,t.jsx)("span",{children:l},`${e}-text`))}return s}(e.snippet)})]},`${e.threadId}-${e.messageId}`)})})]})})}var eb=e.i(984242),ej=e.i(481248),ew=e.i(169433);let ey="agx-chat:project-agent-config",ek={activeParticipantIdsByThread:{}};function eN(){return void 0!==window.localStorage}function eC(e){if(!Array.isArray(e))return[];let t=new Set,a=[];for(let r of e){if("string"!=typeof r)continue;let e=r.trim();!e||t.has(e)||(t.add(e),a.push(e))}return a}function eS(){if(!eN())return{...ek};let e=window.localStorage.getItem(ey);if(!e)return{...ek};try{let t=JSON.parse(e).activeParticipantIdsByThread;if(!t||"object"!=typeof t)return{...ek};return{activeParticipantIdsByThread:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,eC(t)]))}}catch{return{...ek}}}function eI(e,t){let a=e.trim();if(!a)return;let r=eS();r.activeParticipantIdsByThread[a]=eC(t);if(eN())try{window.localStorage.setItem(ey,JSON.stringify(r))}catch{}}let eT={threadSidebarVisible:!1,workspaceRoots:[],homeSearchConsent:!1,fileIgnorePatterns:[]};function eM(e){return e&&"object"==typeof e?{threadSidebarVisible:"boolean"==typeof e.threadSidebarVisible?e.threadSidebarVisible:eT.threadSidebarVisible,workspaceRoots:Array.isArray(e.workspaceRoots)?e.workspaceRoots.filter(e=>"string"==typeof e):eT.workspaceRoots,homeSearchConsent:"boolean"==typeof e.homeSearchConsent?e.homeSearchConsent:eT.homeSearchConsent,fileIgnorePatterns:Array.isArray(e.fileIgnorePatterns)?e.fileIgnorePatterns.filter(e=>"string"==typeof e):eT.fileIgnorePatterns}:eT}let e$="/api/userPreferences";function eR(e){return e.json().then(e=>e&&"object"==typeof e?eM(e.preferences??e):eM(e)).catch(()=>eM(null))}function eP(e){return e.statusText||`Failed to reach ${e$} (${e.status})`}async function eA(){let e=await fetch(e$,{cache:"no-store"});if(!e.ok)throw Error(eP(e));return eR(e)}async function eE(e){let t=await fetch(e$,{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-store",body:JSON.stringify({preferences:e})});if(!t.ok)throw Error(eP(t));return eR(t)}var e_=e.i(990933),eO=e.i(352687),eU=e.i(524123),ez=e.i(8707),eD=e.i(493141),eL=e.i(846279),eL=eL,eB=e.i(169729),eF=e.i(721571),eW=e.i(468947),eq=e.i(837958),eV=e.i(595807),eV=eV;function eJ({logs:e,participants:r,onClear:s,open:l,onToggle:n}){let[i,o]=(0,a.useState)(420),[d,c]=(0,a.useState)(null),u=(0,a.useRef)(null),p=(0,a.useRef)(!1),h=(0,a.useRef)(0),m=(0,a.useRef)(0),f=Object.fromEntries(r.map(e=>[e.id,e]));(0,a.useEffect)(()=>{l&&u.current?.scrollIntoView({behavior:"smooth"})},[e.length,l]);let x=(0,a.useCallback)(e=>{e.preventDefault(),p.current=!0,h.current=e.clientX,m.current=i,e.target.setPointerCapture(e.pointerId)},[i]),g=(0,a.useCallback)(e=>{if(!p.current)return;let t=h.current-e.clientX;o(Math.max(280,Math.min(m.current+t,.6*window.innerWidth)))},[]),v=(0,a.useCallback)(()=>{p.current=!1},[]);if(!l)return null;let b=d?e.filter(e=>e.participantId===d):e;return(0,t.jsxs)("div",{className:"flex h-full shrink-0",children:[(0,t.jsx)("div",{onPointerDown:x,onPointerMove:g,onPointerUp:v,className:"w-1.5 cursor-col-resize bg-zinc-800 hover:bg-zinc-600 transition-colors flex items-center justify-center shrink-0",children:(0,t.jsx)("div",{className:"h-8 w-0.5 rounded-full bg-zinc-500"})}),(0,t.jsxs)("div",{className:"flex flex-col bg-zinc-950 h-full",style:{width:i},children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-zinc-800 shrink-0",children:[(0,t.jsx)("span",{className:"text-[11px] text-[var(--muted-foreground)] font-mono",children:"Logs"}),(0,t.jsxs)("select",{value:d||"",onChange:e=>c(e.target.value||null),className:"bg-zinc-800 text-zinc-300 text-[11px] rounded px-1.5 py-0.5 outline-none",children:[(0,t.jsx)("option",{value:"",children:"All"}),r.map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,t.jsx)("button",{onClick:s,className:"text-[11px] text-[var(--muted-foreground)] hover:text-zinc-300",children:"Clear"}),(0,t.jsx)("button",{onClick:n,className:"text-[11px] text-[var(--muted-foreground)] hover:text-zinc-300",children:"✕"})]})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto font-mono text-[11px] leading-4 px-3 py-2",children:[b.map((e,a)=>{let r=f[e.participantId]?.name||e.participantId,s=f[e.participantId]?.color||"#888",l="stderr"===e.stream;return(0,t.jsxs)("div",{className:"flex gap-2 whitespace-pre-wrap break-all",children:[(0,t.jsx)("span",{className:"text-[var(--muted-foreground)] shrink-0 select-none",children:new Date(e.timestamp).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}),(0,t.jsx)("span",{className:"shrink-0",style:{color:s},children:r}),(0,t.jsx)("span",{className:l?"text-red-400":"text-[var(--muted-foreground)]",children:e.line})]},a)}),(0,t.jsx)("div",{ref:u})]})]})]})}var eH=e.i(524780);let eX="agx-theme";function eK(e,t=!1){return(t?e.replace(/(?:^|\n)Thinking\.\.\.[\s\S]*?\.\.\.done thinking\.?\s*/g,"\n").trim():e).replaceAll("<!-- thread-summary -->","").replaceAll("<!-- task-draft -->","").trim().replace(/\r\n/g,"\n").replace(/\n{3,}/g,"\n\n").trim()}async function eG(e){let t=await fetch(`/api/threads/knowledge?rootMessageId=${encodeURIComponent(e)}`,{cache:"no-store"});if(!t.ok)throw Error("Failed to load thread knowledge run");let a=await t.json().catch(e=>(console.warn("[ChatContainer] failed to parse thread knowledge response:",e),null));return a?.run??null}function eY(e,t,a){let r=new Set(e.map(e=>e.id)),s=a?t.find(e=>e.thread_ids?.includes(a)):t[0],l=s?s.agents.map(e=>e.agent_id).filter(e=>r.has(e)):[];return s?l:0===l.length?e.map(e=>e.id):l}function eZ(e,t,a){let r=Object.fromEntries(t.map(e=>[e.id,e])),s=[];for(let t of e){let e="user"===t.role?"You":t.participantId?r[t.participantId]?.name||t.participantId:"Assistant",a=eK(t.content,"user"!==t.role);a&&(s.push(`**${e}:**`),s.push(""),s.push(a),s.push(""))}if(a){let e=function(e){if(0===e.tasks.length)return"";let t=new Map(e.tasks.map(e=>[e.id,e.title.trim()])),a=["## Draft Tasks",""];return e.projectName&&a.push(`Project: ${e.projectName}`),e.buildStatus&&a.push(`Build status: ${e.buildStatus.replaceAll("_"," ")}`),(e.projectName||e.buildStatus)&&a.push(""),e.tasks.forEach((r,s)=>{let l=eK(r.title)||`Task ${s+1}`,n=eK(r.description),i=(r.dependsOn||[]).map(e=>t.get(e)?.trim()).filter(e=>!!e),o=e.builtTaskIds?.[r.id];a.push(`${s+1}. [ ] **${l}**`),n&&a.push(n),i.length>0&&a.push(`Depends on: ${i.join(", ")}`),o&&a.push(`agx task id: \`${o}\``),a.push("")}),a.join("\n").trim()}(a);e&&s.push(e)}return s.join("\n").trim()}e.s(["ChatContainer",0,function({projectSlug:e,initialThreadId:c,initialRootMessageId:u,showSidebar:p=!0}={}){let{isTouchLayout:h}=(0,o.useInputCapabilities)(),{getSelection:m,pushSelection:f,replaceSelection:x}=(0,s.useUrlSelection)(),{threads:g,activeThreadId:v,selectThread:b,createThread:j,deleteThread:w,updateThreadMessages:y,isCreating:k,deletingThreadId:N,renamingThreadId:C,isLoading:S,isRestoringActiveThread:I,renameThread:T,updateThreadStatus:M,updateThreadOutcomeNote:$,updateMessageThreadStatus:R,updateMessageOutcomeNote:P}=(0,i.useThreadState)(c),{messages:A,setMessages:E,logs:O,sendMessage:U,loadHistory:z,clearLogs:D,chatRuns:L,setChatRuns:B,stop:F,stopThread:W}=(0,l.useGroupChat)(v),{activeAgents:q,processes:V,streaming:J,chatRuns:H,poll:X}=(0,n.useProcessPolling)(v?{workspaceId:v}:null,{messages:A,setMessages:E}),K=(0,a.useMemo)(()=>{let e=Date.now(),t=new Map(H.map(e=>[e.chatRunId,e]));for(let a of L)!(!a.optimistic||t.has(a.chatRunId))&&(e-(a.enqueuedAt??0)>5e3||t.set(a.chatRunId,a));return Array.from(t.values()).filter(e=>"queued"===e.status||"running"===e.status)},[L,H]),G=q.size>0||K.some(e=>"running"===e.status)?"working":K.some(e=>"queued"===e.status)?"queued":"ready";(0,a.useEffect)(()=>{B(e=>{let t=Date.now(),a=new Map(e.filter(e=>"string"==typeof e.chatRunId&&e.chatRunId.length>0).map(e=>[e.chatRunId,e]));for(let e of H)e?.chatRunId&&a.set(e.chatRunId,e);return Array.from(a.values()).filter(e=>!!(!e.optimistic||H.some(t=>t.chatRunId===e.chatRunId))||t-(e.enqueuedAt??0)<=5e3).sort((e,t)=>String(e.chatRunId||"").localeCompare(String(t.chatRunId||"")))})},[H,B]);let Y=(0,a.useCallback)(async e=>{await fetch(`/api/chat-runs/${encodeURIComponent(e)}/signal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({signal:"cancel",reason:"Stopped from chat UI"})}).catch(e=>console.warn("[ChatContainer] cancel chat run failed:",e))},[]),Z=(0,a.useCallback)(async()=>{let e=K[0];e?.chatRunId&&await Y(e.chatRunId),await F(),await X()},[K,Y,F,X]),Q=(0,a.useCallback)(async e=>{let t=K.find(t=>t.rootMessageId===e);t?.chatRunId&&await Y(t.chatRunId),await W(e),await X()},[K,Y,W,X]),ee=(0,a.useRef)(Z);(0,a.useEffect)(()=>{ee.current=Z},[Z]);let{projects:et,createProject:ea,deleteProject:er,addAgent:es,removeAgent:el,reorderAgents:en}=(0,eU.useProjectsWithAgents)(),{projects:ei,updateProject:eo}=(0,eU.useProjects)(),ec=(0,a.useMemo)(()=>v?et.filter(e=>e.thread_ids?.includes(v)):et,[et,v]),eu=(0,a.useMemo)(()=>e||ec[0]?.slug||void 0,[e,ec]),[ep,eh]=(0,a.useState)([]),[em,ex]=(0,a.useState)(!1),[eg,ey]=(0,a.useState)([]),[ek,eN]=(0,a.useState)(!1),[eC,eT]=(0,a.useState)(()=>{let e=window.localStorage.getItem(eX);return"dark"===e||"light"===e?e:document.documentElement.classList.contains("dark")?"dark":"light"}),[eM,e$]=(0,a.useState)(!1),[eR,eP]=(0,a.useState)(368),eK=(0,a.useRef)(!1);(0,a.useEffect)(()=>{let e=(0,ej.loadWorkspaceSidebarVisible)();eK.current=!0,e$(e),eP((0,ew.loadWorkspaceWidth)()||368)},[]),(0,a.useEffect)(()=>{let e="dark"===eC;document.documentElement.classList.toggle("dark",e),document.documentElement.style.colorScheme=eC,window.localStorage.setItem(eX,eC)},[eC]);let[eQ,e0]=(0,a.useState)(!1),[e1,e5]=(0,a.useState)(new Set),[e2,e3]=(0,a.useState)(!1),[e4,e6]=(0,a.useState)(!1),[e8,e7]=(0,a.useState)(null),e9=m("open"),te=m("message"),tt=e?e9??u??null:u??null,ta=tt?e1.has(tt):e2;(0,a.useEffect)(()=>{if(!tt)return;let e=!1,t=()=>{fetch(`/api/schedules?rootMessageId=${encodeURIComponent(tt)}`).then(e=>e.json()).then(t=>{e||e5(e=>{let a=e.has(tt);if(t.active&&!a){let t=new Set(e);return t.add(tt),t}if(!t.active&&a){let t=new Set(e);return t.delete(tt),t}return e})}).catch(e=>console.warn("[ChatContainer] check auto-mode status failed:",e))};t();let a=setInterval(t,r.UI_POLL_CHAT_CHECK_MS);return()=>{e=!0,clearInterval(a)}},[tt]),(0,a.useEffect)(()=>{let e=!1,t=()=>{fetch("/api/schedules").then(e=>e.json()).then(t=>{!e&&t.activeRootMessageIds&&e5(e=>{let a=new Set(t.activeRootMessageIds);return a.size===e.size&&[...a].every(t=>e.has(t))?e:a})}).catch(e=>console.warn("[ChatContainer] fetch schedules failed:",e))};t();let a=setInterval(t,r.UI_POLL_CHAT_ALT_MS);return()=>{e=!0,clearInterval(a)}},[]);let tr=(0,a.useCallback)((t,a={})=>{let r=a.replace?x:f;if(e){let s=a.threadId??v??c??null;if(!s)return;r({open:t,message:a.messageId??null},`/projects/${e}/thread/${encodeURIComponent(s)}`);return}t?r({message:a.messageId??null},`/thread/${encodeURIComponent(t)}`):r({message:null},"/")},[v,c,e,f,x]);(0,a.useEffect)(()=>{u&&(async()=>{try{let e=await fetch(`/api/messages/${u}`);if(!e.ok)return;let{threadId:t}=await e.json();t&&b(t)}catch{}})()},[u,b]);let[ts,tl]=(0,a.useState)(""),[tn,ti]=(0,a.useState)([]),[to,td]=(0,a.useState)(0),[tc,tu]=(0,a.useState)(!1),[tp,th]=(0,a.useState)(null),[tm,tf]=(0,a.useState)(new Set),[tx,tg]=(0,a.useState)(null),[tv,tb]=(0,a.useState)(null),[tj,tw]=(0,a.useState)({}),ty=(0,a.useCallback)(e=>{tw(t=>{let a="function"==typeof e?e(t):e;if(v)for(let[e,r]of Object.entries(a))t[e]!==r&&fetch("/api/task-drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:v,messageId:e,draft:r})}).catch(e=>console.warn("[ChatContainer] persist task draft failed:",e));return a})},[v]),[tk,tN]=(0,a.useState)(new Set),[tC,tS]=(0,a.useState)(new Set),tI=(0,a.useRef)(null),tT=(0,a.useRef)(""),tM=(0,a.useCallback)(async(e=!1)=>{try{let e=await fetch("/api/participants");if(!e.ok)return;let t=await e.json();if(!Array.isArray(t))return;eh(t)}finally{e&&ex(!0)}},[]),t$=(0,a.useCallback)(async e=>{try{await eE({threadSidebarVisible:e})}catch(e){console.error("Unable to persist thread sidebar preference",e)}},[eE]),tR=(0,a.useCallback)(e=>{(0,ej.persistWorkspaceSidebarVisible)(e),t$(e)},[t$]),tP=ts.trim(),tA=tP.length>0,tE=(0,a.useMemo)(()=>Object.fromEntries(g.map(e=>[e.id,e.title?.trim()||"Untitled thread"])),[g]),t_=(0,a.useMemo)(()=>{if(!tt)return[];let e=new Set([A.find(e=>e.id===tt),...A.filter(e=>e.rootMessageId===tt)].filter(Boolean).map(e=>e.participantId).filter(Boolean));return Object.keys(J).forEach(t=>{J[t].rootMessageId===tt&&e.add(t)}),ep.filter(t=>e.has(t.id))},[tt,A,J,ep]),tO=(0,a.useMemo)(()=>{let e=new Map(ep.map(e=>[e.id,e]));return eg.map(t=>e.get(t)).filter(Boolean)},[ep,eg]),tU=(0,a.useMemo)(()=>ei.map(e=>({id:e.id,name:e.name,slug:e.slug})),[ei]),tz=(0,a.useMemo)(()=>{if(!tt)return 0;let e=[A.find(e=>e.id===tt),...A.filter(e=>e.rootMessageId===tt)].filter(Boolean);return 0===e.length?0:Math.max(...e.map(e=>e.timestamp))},[tt,A]),tD=(0,a.useMemo)(()=>{if(!tt)return"";let e=A.find(e=>e.id===tt);if(!e)return"Discussion";let t=e.content.trim();return t.length>60?t.slice(0,60)+"...":t},[tt,A]),tL=(0,a.useMemo)(()=>{if(!tt)return null;let e=A.find(e=>e.id===tt),t=e?.threadStatus??"active";return{value:t,...{active:{label:"Active",color:"#f59e0b"},paused:{label:"Paused",color:"#f97316"},"in-review":{label:"In Review",color:"#6b7280"},done:{label:"Done",color:"#3b82f6"},archived:{label:"Archived",color:"#9ca3af"}}[t]}},[tt,A]);(0,a.useEffect)(()=>{if(!te)return;let e=A.find(e=>e.id===te)??null;if(e){let t=e.rootMessageId||e.id;t!==tt&&tr(t,{messageId:te,replace:!0});return}!tt||[A.find(e=>e.id===tt),...A.filter(e=>e.rootMessageId===tt)].filter(Boolean).length>0&&x({message:null})},[A,tr,tt,x,te]);let tB=(0,a.useCallback)(()=>{tl(""),ti([]),td(0),th(null),tu(!1)},[]);(0,a.useCallback)(()=>{let e=eZ(A,ep);navigator.clipboard.writeText(e).then(()=>{eN(!0),setTimeout(()=>eN(!1),2e3)})},[A,ep]);let[tF,tW]=(0,a.useState)(null),tq=(0,a.useCallback)(e=>{let t=A.find(t=>t.id===e);if(!t)return;let a=[t,...A.filter(t=>t.rootMessageId===e).sort((e,t)=>e.timestamp-t.timestamp)];tW({title:t.content.slice(0,60).replace(/\n/g," ").trim()||"Untitled",threadId:e,messages:a})},[A]),tV=(0,a.useCallback)(e=>{let t=eZ([A.find(t=>t.id===e),...A.filter(t=>t.rootMessageId===e).sort((e,t)=>e.timestamp-t.timestamp)].filter(Boolean),ep,tj[e]);navigator.clipboard.writeText(t).catch(e=>console.error("Failed to copy thread",e))},[A,ep,tj]),tJ=(0,a.useCallback)(async()=>{if(tt){e6(!0);try{let e=["repo"];eu&&e.push("project");let t=await fetch("/api/threads/knowledge",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootMessageId:tt,scopes:e})}),a=await t.json().catch(e=>(console.warn("[ChatContainer] failed to parse knowledge extraction response:",e),null));if(!t.ok)throw Error("string"==typeof a?.error?a.error:"Request failed");e7(a?.run??null)}catch(t){let e=t instanceof Error?t.message:"Request failed";window.alert(`Failed to extract knowledge: ${e}`)}finally{e6(!1)}}},[tt,eu]);(0,a.useEffect)(()=>{if(!tt){e7(null),e6(!1);return}let e=!1;return(async()=>{try{let t=await eG(tt);if(e)return;e7(t)}catch{e||e7(null)}})(),()=>{e=!0}},[tt]),(0,a.useEffect)(()=>{if(!tt||e8?.status!=="running")return;let e=!1,t=async()=>{try{let t=await eG(tt);if(e)return;e7(t)}catch{}};t();let a=window.setInterval(()=>{t()},2e3);return()=>{e=!0,window.clearInterval(a)}},[tt,e8?.status]);let tH=e8?.status==="running",tX=e4||tH,tK=(e8?.repoInsertedCount??0)+(e8?.projectInsertedCount??0),tG=(0,a.useMemo)(()=>{if(!e8)return null;if("running"===e8.status)return"Learning in progress";if("failed"===e8.status)return"Last learning run failed";if(tK>0){let e=1===tK?"insight":"insights";return`Learned ${tK} ${e}`}return"No new learnings"},[tK,e8]);(0,a.useEffect)(()=>{tM(!0)},[tM]);let tY=(0,a.useMemo)(()=>{if(!em)return[];let e=new Set(ep.map(e=>e.id)),t=new Set;for(let a of A)"assistant"===a.role&&a.participantId&&(e.has(a.participantId)||t.add(a.participantId));for(let a of Object.keys(J))e.has(a)||t.add(a);return Array.from(t).sort()},[A,ep,em,J]);(0,a.useEffect)(()=>{if(!em)return;let e=tY.join("|");if(!e){tT.current="";return}tT.current!==e&&(tT.current=e,tM(!1))},[em,tM,tY]),(0,a.useEffect)(()=>{if(!em)return;let e=eY(ep,et,v);if(!v)return void ey(e);let t=function(e){let t=e.trim();if(!t)return null;let a=eS();return t in a.activeParticipantIdsByThread?[...a.activeParticipantIdsByThread[t]]:null}(v);if(null===t)return void ey(e);let a=function(e,t){if(null===t)return e;let a=new Set(t);return e.filter(e=>a.has(e))}(e,t),r=a.length>0?a:e;(r.length!==t.length||r.some((e,a)=>t[a]!==e))&&eI(v,r),ey(r)},[v,ep,em,et]),(0,a.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await eA();if(e)return;e$(e=>e===t.threadSidebarVisible?e:eK.current?(t$(e),e):((0,ej.persistWorkspaceSidebarVisible)(t.threadSidebarVisible),t.threadSidebarVisible))}catch(e){console.error("Failed to load user preferences",e)}})(),()=>{e=!0}},[t$]),(0,a.useEffect)(()=>{S||k||0!==g.length||j({id:"global",title:"General"})},[S,k,g.length,j]),(0,a.useEffect)(()=>{if(e)return;let t=e=>{if((e.metaKey||e.ctrlKey)&&"k"===e.key.toLowerCase()){e.preventDefault(),tI.current?.focus(),tI.current?.select();return}"Escape"===e.key&&tP&&tB()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[tB,tP,e]),(0,a.useEffect)(()=>{if(!tP){ti([]),td(0),th(null),tu(!1);return}let e=!1;tu(!0);let t=window.setTimeout(()=>{(async()=>{try{let t=new URLSearchParams({q:tP,limit:"20",offset:"0"}),a=await fetch(`/api/search?${t.toString()}`),r=await a.json().catch(e=>(console.warn("[ChatContainer] failed to parse search response:",e),null));if(e)return;if(!a.ok){let e=r&&"object"==typeof r&&"error"in r?String(r.error):"Search failed";ti([]),td(0),th(e);return}ti(Array.isArray(r.results)?r.results:[]),td("number"==typeof r.total?r.total:0),th(null)}catch(t){if(e)return;console.error("Search request failed",t),ti([]),td(0),th("Search failed")}finally{e||tu(!1)}})()},300);return()=>{e=!0,window.clearTimeout(t)}},[tP]);let tZ=(0,a.useRef)(null);(0,a.useEffect)(()=>{null!==tZ.current&&tZ.current!==v&&ee.current(),tZ.current=v,v&&(z(v),fetch(`/api/task-drafts?threadId=${encodeURIComponent(v)}`).then(e=>e.json()).then(e=>{e.drafts&&Object.keys(e.drafts).length>0?tw(e.drafts):tw({})}).catch(e=>{console.warn("[ChatContainer] load task drafts failed:",e),tw({})}))},[v,z]),(0,a.useEffect)(()=>{v&&y(v,A)},[v,A,y]);let tQ=(0,a.useCallback)((e,t,a=10,r,s,l)=>{v&&0!==tO.length&&U(t,a,v,e,void 0,void 0,(0,e_.orderParticipantIds)(tO.map(e=>e.id),r),eu,s,l)},[v,U,tO,eu]),t0=(0,a.useCallback)(async e=>{if(v){if(0===tO.length)return void window.alert("Enable at least one agent in this project.");tf(t=>new Set(t).add(e));try{let t=await fetch("/api/summarize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:v,rootMessageId:e,activeParticipantIds:tO.map(e=>e.id)})});t.ok?await z(v):console.error("Summarize failed:",await t.text())}catch(e){console.error("Summarize error:",e)}finally{tf(t=>{let a=new Set(t);return a.delete(e),a})}}},[v,z,tO]),t1=(0,a.useCallback)(async e=>{if(v){if(0===tO.length)return void window.alert("Enable at least one agent in this project.");tN(t=>new Set(t).add(e));try{let t=await fetch("/api/tasks/extract",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:v,rootMessageId:e,activeParticipantIds:tO.map(e=>e.id)})});if(t.ok){let a=await t.json(),r={draftId:crypto.randomUUID(),revision:0,tasks:a.tasks,buildStatus:"idle"};ty(t=>({...t,[e]:r}))}else console.error("Task extraction failed:",await t.text())}catch(e){console.error("Task extraction error:",e)}finally{tN(t=>{let a=new Set(t);return a.delete(e),a})}}},[v,tO]),t5=(0,a.useCallback)((e,t)=>{ty(a=>({...a,[e]:t}))},[]),t2=(0,a.useCallback)(async(e,t,a,r)=>{if(v){tS(e=>new Set(e).add(t.draftId)),ty(s=>({...s,[e]:{...t,buildStatus:"building",projectId:a,projectName:r}}));try{let r=crypto.randomUUID(),s=await _(t.tasks,a,r,t.builtTaskIds),l={...t.builtTaskIds},n=!1;for(let e of s.results)"created"===e.status&&e.remoteTaskId?l[e.clientTaskId]=e.remoteTaskId:n=!0;ty(t=>({...t,[e]:{...t[e],buildId:r,buildStatus:n?"partial_failure":"done",builtTaskIds:l}}))}catch(t){console.error("Build error:",t),ty(t=>({...t,[e]:{...t[e],buildStatus:"partial_failure"}}))}finally{tS(e=>{let a=new Set(e);return a.delete(t.draftId),a})}}},[v]),t3=(0,a.useCallback)(()=>{if(!v)return;let e=(()=>{if(tt)return tt;let e=new Set(A.map(e=>e.rootMessageId).filter(e=>!!e));for(let t=A.length-1;t>=0;t-=1){let a=A[t];if(!a.rootMessageId&&e.has(a.id))return a.id}return null})();e?t1(e):console.warn("No thread with replies available to extract tasks from")},[v,t1,A,tt]);(0,a.useCallback)(e=>{tr(e)},[tr]);let t4=(0,a.useCallback)(e=>{tr(e)},[tr]),t6=(0,a.useCallback)(e=>{let t=e?.trim()??"";t&&tl(t),requestAnimationFrame(()=>{tI.current?.focus(),t||tI.current?.select()})},[]),t8=(0,a.useCallback)(()=>{if(!v)return;let e=(()=>{if(tt)return tt;let e=new Set(A.map(e=>e.rootMessageId).filter(e=>!!e));for(let t=A.length-1;t>=0;t-=1){let a=A[t];if(!a.rootMessageId&&e.has(a.id))return a.id}return null})();e?t0(e):console.warn("No thread with replies available to summarize")},[v,t0,A,tt]),t7=(0,a.useCallback)(async(e,t,a,r,s,l,n)=>{let i=e.match(/^\/search(?:\s+([\s\S]+))?$/i);if(i)return void t6(i[1]);if(/^\/summarize(?:\s+[\s\S]+)?$/i.test(e))return void t8();if(/^\/tasks(?:\s+[\s\S]+)?$/i.test(e)||/^\/create(?:\s+[\s\S]+)?$/i.test(e))return void t3();let o=v;o||(o=(await j()).id);let d=tO.map(e=>e.id);if(0===d.length)return void window.alert("Enable at least one agent in this project.");let c=(0,e_.orderParticipantIds)(d,s);if(tt)return void await U(e,t,o,tt,a,r,c,eu,l,n);let u=await U(e,t,o,null,a,r,c,eu,l,n);e2&&u&&(e3(!1),e5(e=>{let t=new Set(e);return t.add(u),t}),fetch("/api/schedules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"activate",rootMessageId:u})}).catch(e=>console.error("Failed to activate schedule for new thread:",e)))},[v,e2,j,t6,t8,tt,tO,U,eu]),t9=(0,a.useCallback)(async e=>{if(!tt)return void e3(e);e5(t=>{let a=new Set(t);return e?a.add(tt):a.delete(tt),a});try{await fetch("/api/schedules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e?"activate":"stop",rootMessageId:tt})})}catch(e){console.error("Failed to toggle autonomous schedule:",e)}},[tt]),ae=(0,a.useCallback)(e=>{tr(e.rootMessageId||e.messageId,{messageId:e.messageId,threadId:e.threadId}),tB()},[tB,tr]),at=(0,a.useCallback)(async e=>{Z(),await w(e)},[w,Z]),aa=(0,a.useCallback)(e=>{if(!v||!e)return;let t=A.find(t=>t.id===e);tb({type:"thread",id:e,preview:t?.content?.slice(0,120)||void 0})},[v,A]),ar=(0,a.useCallback)(async e=>{if(v){tg(e),Q(e);try{let t=new URLSearchParams({threadId:v,rootMessageId:e}),a=await fetch(`/api/history?${t.toString()}`,{method:"DELETE"});if(!a.ok)return void console.error("Failed to delete message thread",await a.text());let r=te?A.find(e=>e.id===te)??null:null,s=r?r.rootMessageId||r.id:null;tt===e?tr(null,{replace:!0}):s===e&&x({message:null});let l=A.filter(t=>t.id!==e&&t.rootMessageId!==e);y(v,l),await z(v)}catch(e){console.error("Failed to delete message thread",e)}finally{tg(t=>t===e?null:t)}}},[v,Q,z,A,tr,tt,x,te,y]),as=(0,a.useCallback)(e=>{if(!v||!e)return;let t=A.find(t=>t.id===e);tb({type:"message",id:e,preview:t?.content?.slice(0,120)||void 0})},[v,A]),al=(0,a.useCallback)(async e=>{if(v)try{let t=new URLSearchParams({threadId:v,messageId:e}),a=await fetch(`/api/history?${t.toString()}`,{method:"DELETE"});if(!a.ok)return void console.error("Failed to delete message",await a.text());te===e&&x({message:null});let r=A.filter(t=>t.id!==e);y(v,r),await z(v)}catch(e){console.error("Failed to delete message",e)}},[v,z,A,x,te,y]),an=(0,a.useCallback)(()=>{tv&&("thread"===tv.type?ar(tv.id):al(tv.id),tb(null))},[tv,ar,al]),ai=(0,a.useCallback)(()=>{tb(null)},[]),ao=(0,a.useMemo)(()=>[{name:"/search",description:"Search messages (usage: /search <query>)",aliases:["find"],execute:()=>t6()},{name:"/summarize",description:"Summarize current thread or latest thread with replies",aliases:["sum"],execute:()=>t8()},{name:"/tasks",description:"Extract tasks from current thread discussion",aliases:["create"],execute:()=>t3()}],[t6,t8,t3]),ad=(0,a.useMemo)(()=>{let e=eu?ec.find(e=>e.slug===eu):ec[0];return e?.repos??[]},[ec,eu]),[ac,au]=(0,a.useState)(new Set),ap=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(!tt){au(new Set),ap.current=null;return}ap.current!==tt&&(au(new Set),ap.current=tt,fetch(`/api/thread-repos?rootMessageId=${encodeURIComponent(tt)}`).then(e=>e.json()).then(e=>{ap.current===tt&&e.repoIds&&e.repoIds.length>0&&au(new Set(e.repoIds))}).catch(e=>console.warn("[ChatContainer] load thread repos failed:",e)))},[tt]);let ah=(0,a.useCallback)(e=>{au(e),tt&&fetch("/api/thread-repos",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootMessageId:tt,repoIds:[...e]})}).catch(e=>console.warn("[ChatContainer] save thread repos failed:",e))},[tt]),am=(0,a.useCallback)(e=>{let a=V.some(t=>["spawning","running"].includes(t.state)&&t.threadId===e)||Object.values(J).some(t=>t.rootMessageId===e)?"working":K.some(t=>t.rootMessageId===e&&"queued"===t.status)?"queued":"ready";return(0,t.jsx)(eb.Composer,{onSend:(t,a,r,s,l,n,i)=>tQ(e,t,a,l,n,i),onStop:()=>Q(e),loading:"ready"!==a,activityStatus:a,participants:tO,projectGroups:ec,projects:tU,projectSlug:eu,messages:A,commands:ao,placeholder:"Reply — @name to mention, /search, /summarize",autoMode:ta,onAutoModeChange:t9,repos:ad,selectedRepoIds:ac,onRepoSelectionChange:ah})},[tQ,Q,J,tO,ec,tU,eu,ao,A,ta,t9,V,K,ad,ac,ah]),af=(0,a.useCallback)(()=>{e$(e=>{let t=!e;return tR(t),t})},[tR]),ax=(0,a.useCallback)(e=>{eP(e),(0,ew.persistWorkspaceWidth)(e)},[]),ag=async e=>{let t=await fetch("/api/participants",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok){let e=await t.json();eh(t=>t.map(t=>t.id===e.id?e:t))}},av=(0,a.useCallback)((e,t)=>{ey(a=>{let r=eY(ep,et,v);if(!new Set(r).has(e))return a;let s=new Set(a);t?s.add(e):s.delete(e);let l=r.filter(e=>s.has(e));return v&&eI(v,l),l})},[v,ep,et]),ab=(0,a.useCallback)(e=>{let t=et.find(t=>t.id===e);if(!t||v&&!t.thread_ids?.includes(v))return;let a=t.agents.map(e=>e.agent_id);ey(a),v&&eI(v,a)},[et,v]),aj=(0,a.useCallback)(()=>{eT(e=>"dark"===e?"light":"dark")},[]),aw=()=>(0,t.jsx)("button",{type:"button",onClick:aj,"aria-label":"dark"===eC?"Switch to light theme":"Switch to dark theme",title:"dark"===eC?"Switch to light theme":"Switch to dark theme",className:"inline-flex h-9 w-9 items-center justify-center rounded-xl border border-[var(--app-shell-border)] bg-[var(--app-shell-elevated)] text-[var(--app-shell-muted)] transition-all hover:border-[var(--app-shell-border-strong)] hover:bg-[var(--app-shell-subtle)] hover:text-[var(--foreground)]",children:"dark"===eC?(0,t.jsx)(eW.Sun,{className:"h-4 w-4",strokeWidth:1.75}):(0,t.jsx)(eF.Moon,{className:"h-4 w-4",strokeWidth:1.75})}),ay=(0,t.jsxs)("div",{className:"relative group/search min-w-0 flex-1",children:[(0,t.jsx)(ez.Search,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-[var(--app-shell-soft-text)] transition-colors group-focus-within/search:text-[var(--primary)]",strokeWidth:2}),(0,t.jsx)("input",{ref:tI,type:"text",value:ts,onChange:e=>tl(e.target.value),onKeyDown:e=>{"Escape"===e.key&&tB()},placeholder:"Search messages…",className:`w-full rounded-xl border border-[var(--app-shell-border)] bg-[var(--app-shell-elevated)] pl-9 pr-16 text-sm font-medium text-[var(--foreground)] outline-none placeholder:text-[var(--app-shell-soft-text)] transition-all hover:border-[var(--app-shell-border-strong)] focus:border-[var(--primary)] focus:ring-2 focus:ring-[var(--ring)] ${e?"h-7 text-xs":"h-9"}`}),tP?(0,t.jsxs)("div",{className:"absolute right-3 top-1/2 flex -translate-y-1/2 items-center gap-2",children:[(0,t.jsx)("span",{className:"text-[11px] font-bold text-[var(--muted-foreground)]",children:tc?"…":to}),(0,t.jsx)("button",{type:"button",onClick:tB,className:"text-[10px] font-bold text-[var(--app-shell-soft-text)] transition-colors hover:text-[var(--app-shell-muted)]",children:"✕"})]}):h?null:(0,t.jsx)("kbd",{className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 rounded-md border border-[var(--app-shell-border)] bg-[var(--app-shell-subtle)] px-1.5 py-0.5 font-sans text-[10px] font-bold text-[var(--app-shell-soft-text)]",children:"⌘K"})]}),ak=e?null:(0,t.jsx)("div",{className:"desktop-titlebar border-b border-[var(--app-shell-border)] bg-[var(--app-shell-surface)] px-4 py-2.5 backdrop-blur-xl md:px-6",children:(0,t.jsxs)("div",{className:"mx-auto flex max-w-5xl items-center gap-3",children:[(0,t.jsx)("div",{className:"flex min-w-0 items-center flex-shrink-0",children:p&&!eM&&(0,t.jsx)("button",{type:"button",onClick:af,className:"inline-flex h-9 w-9 items-center justify-center rounded-xl border border-[var(--app-shell-border)] bg-[var(--app-shell-elevated)] text-[var(--app-shell-muted)] transition hover:border-[var(--app-shell-border-strong)] hover:text-[var(--foreground)]",title:"Show sidebar","aria-label":"Show sidebar",children:(0,t.jsx)(eB.PanelLeftOpen,{className:"h-4 w-4",strokeWidth:1.75})})}),(0,t.jsx)("div",{className:"flex flex-1 justify-center min-w-0",children:(0,t.jsxs)("div",{className:"flex w-full max-w-2xl items-center gap-2",children:[ay,(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[aw(),(0,t.jsx)(eH.StatusIndicator,{}),tt&&(0,t.jsx)("button",{type:"button",onClick:()=>e0(!eQ),"aria-label":eQ?"Hide logs":`Show logs${O.length>0?` (${O.length})`:""}`,"aria-pressed":eQ,title:eQ?"Hide logs":`Show logs${O.length>0?` (${O.length})`:""}`,className:`inline-flex h-9 w-9 items-center justify-center rounded-xl border transition-all focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ring)] ${eQ?"border-[var(--app-shell-border-strong)] bg-[var(--app-shell-subtle)] text-[var(--foreground)]":"border-[var(--app-shell-border)] bg-[var(--app-shell-elevated)] text-[var(--app-shell-muted)] hover:bg-[var(--app-shell-subtle)] hover:text-[var(--foreground)]"}`,children:(0,t.jsx)(eL.default,{className:"h-4 w-4",strokeWidth:1.75})})]})]})})]})});return(0,t.jsxs)("div",{className:`flex ${e?"h-full":"h-screen"} bg-[var(--app-shell-bg)] text-[var(--foreground)]`,children:[p?(0,t.jsx)(d.WorkspaceSidebar,{threads:g,participants:ep,activeThreadId:v,isLoading:S,isRestoringActiveThread:I,isCreating:k,deletingThreadId:N,renamingThreadId:C,onSelectThread:b,onCreateThread:j,onRenameThread:T,onDeleteThread:at,activeParticipantIds:eg,onToggleParticipantActive:av,visible:eM,onToggle:af,width:eR,onWidthChange:ax,projects:et,onCreateProject:ea,onUpdateProject:eo,onDeleteProject:er,onAddAgentToProject:es,onRemoveAgentFromProject:el,onReorderProjectAgents:en,onUpdateParticipant:ag,onSelectProject:ab}):null,(0,t.jsx)("div",{className:"flex flex-col flex-1 min-w-0 relative",children:I?(0,t.jsx)("div",{className:"flex-1 flex items-center justify-center px-4 text-sm text-[var(--muted-foreground)]",children:"Loading your last project…"}):(0,t.jsx)("div",{className:"flex flex-1 min-h-0 bg-transparent relative",children:(0,t.jsxs)("div",{className:"flex flex-col flex-1 min-w-0",children:[tt?(0,t.jsx)("div",{className:"desktop-titlebar border-b border-[var(--app-shell-border)] bg-[var(--app-shell-surface)] px-4 py-2.5 backdrop-blur-xl md:px-6 transition-colors duration-200 shrink-0",children:(0,t.jsxs)("div",{className:"mx-auto flex max-w-5xl items-center gap-3 min-w-0",children:[p&&!eM?(0,t.jsx)("button",{type:"button",onClick:af,className:"inline-flex h-9 w-9 items-center justify-center rounded-xl border border-[var(--app-shell-border)] bg-[var(--app-shell-elevated)] text-[var(--app-shell-muted)] transition hover:border-[var(--app-shell-border-strong)] hover:text-[var(--foreground)]",title:"Show sidebar","aria-label":"Show sidebar",children:(0,t.jsx)(eB.PanelLeftOpen,{className:"h-4 w-4",strokeWidth:1.75})}):null,(0,t.jsx)("button",{onClick:()=>tr(null),className:"p-1.5 text-[var(--app-shell-muted)] hover:text-[var(--primary)] hover:bg-[var(--app-shell-subtle)] rounded-xl transition-all active:scale-95 flex-shrink-0",title:"Back to main feed",children:(0,t.jsx)(eD.ChevronLeft,{size:20,strokeWidth:2.25})}),(0,t.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,t.jsx)("h2",{className:"text-[15px] font-semibold text-[var(--foreground)] tracking-tight leading-tight truncate min-w-0",children:tD}),tL&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-semibold border shrink-0",style:{borderColor:tL.color+"40",color:tL.color},children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:tL.color}}),tL.label]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-[var(--app-shell-muted)]",children:[(0,t.jsxs)("span",{className:"opacity-80",children:[t_.length," agents"]}),(0,t.jsx)("span",{className:"h-0.5 w-0.5 rounded-full bg-[var(--app-shell-soft-text)]"}),(0,t.jsxs)("span",{className:"opacity-80",children:["Updated ",function(e){if(!e)return"recently";let t=Math.floor((Date.now()-e)/1e3);if(t<60)return"just now";let a=Math.floor(t/60);if(a<60)return`${a}m ago`;let r=Math.floor(a/60);return r<24?`${r}h ago`:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(e)}(tz)]}),tG&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"h-0.5 w-0.5 rounded-full bg-[var(--app-shell-soft-text)]"}),(0,t.jsx)("span",{className:"opacity-80",children:tG})]})]})]}),(0,t.jsx)("div",{className:"flex -space-x-1.5 flex-shrink-0",children:t_.map(e=>(0,t.jsx)("img",{src:`https://api.dicebear.com/9.x/bottts-neutral/svg?seed=${e.id}&backgroundColor=${e.color?e.color.replace("#",""):"e2e8f0"}`,alt:e.name,className:"h-7 w-7 rounded-full border-2 border-[var(--app-shell-elevated)] object-cover shadow-sm ring-1 ring-[var(--app-shell-border)]",title:e.name},e.id))}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>void tJ(),disabled:tX,title:tH?"Learning is already running for this discussion":"Learn from this discussion",className:`inline-flex h-9 items-center gap-1.5 rounded-xl border px-3 text-xs font-medium transition-all focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ring)] ${tX?"cursor-wait border-[var(--app-shell-border)] bg-[var(--app-shell-subtle)] text-[var(--app-shell-muted)]":"border-[var(--app-shell-border)] bg-[var(--app-shell-elevated)] text-[var(--app-shell-muted)] hover:bg-[var(--app-shell-subtle)] hover:text-[var(--foreground)]"}`,children:[tX?(0,t.jsx)(eV.default,{className:"h-3.5 w-3.5 animate-spin",strokeWidth:1.75}):(0,t.jsx)(eq.BookOpen,{className:"h-3.5 w-3.5",strokeWidth:1.75}),(0,t.jsx)("span",{className:"hidden sm:inline",children:tH?"Learning...":"Learn from discussion"})]}),!e&&aw(),!e&&(0,t.jsx)(eH.StatusIndicator,{}),(0,t.jsx)("button",{type:"button",onClick:()=>e0(!eQ),"aria-label":eQ?"Hide logs":`Show logs${O.length>0?` (${O.length})`:""}`,"aria-pressed":eQ,title:eQ?"Hide logs":`Show logs${O.length>0?` (${O.length})`:""}`,className:`inline-flex h-9 w-9 items-center justify-center rounded-xl border transition-all focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ring)] ${eQ?"border-[var(--app-shell-border-strong)] bg-[var(--app-shell-subtle)] text-[var(--foreground)]":"border-[var(--app-shell-border)] bg-[var(--app-shell-elevated)] text-[var(--app-shell-muted)] hover:bg-[var(--app-shell-subtle)] hover:text-[var(--foreground)]"}`,children:(0,t.jsx)(eL.default,{className:"h-4 w-4",strokeWidth:1.75})})]})]})}):ak,tA?(0,t.jsx)(ev,{query:tP,results:tn,total:to,participants:ep,threadTitleById:tE,isLoading:tc,error:tp,onSelectResult:ae}):tt?(0,t.jsx)(ef,{messages:A,streaming:J,participants:ep,rootMessageId:tt,queued:K.some(e=>e.rootMessageId===tt&&"queued"===e.status),onClose:()=>tr(null),onCopyThread:tV,onAddToChat:tq,onDeleteThreadRoot:aa,onDeleteMessage:as,highlightedMessageId:te||void 0,renderReplyComposer:am,activeProcesses:V.filter(e=>["spawning","running"].includes(e.state)&&e.threadId===tt)}):(0,t.jsx)(ed,{messages:A,streaming:J,participants:ep,onOpenThread:t4,onCopyThread:tV,onAddToChat:tq,onDeleteThreadRoot:aa,onSummarize:t0,onCreateTasks:t1,onUpdateTaskDraft:t5,onBuildTasks:t2,summarizingThreads:tm,extractingTasks:tk,buildingDrafts:tC,taskDrafts:tj,deletingThreadRootId:tx,highlightedMessageId:te,shipModeThreads:e1,onUpdateMessageThreadStatus:v?(e,t)=>{E(a=>a.map(a=>a.id===e?{...a,threadStatus:t}:a)),R(v,e,t),fetch("/api/threads",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootMessageId:e,status:t})})}:void 0,onUpdateMessageOutcomeNote:v?(e,t)=>{E(a=>a.map(a=>a.id===e?{...a,outcomeNote:t}:a)),P(v,e,t);let a=A.find(t=>t.id===e);fetch("/api/threads",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootMessageId:e,status:a?.threadStatus??null,outcomeNote:t})})}:void 0}),!tA&&!tt&&(0,t.jsx)(eb.Composer,{onSend:t7,onStop:Z,loading:"ready"!==G,activityStatus:G,participants:tO,projects:tU,projectGroups:ec,projectSlug:eu,messages:A,commands:ao,pendingThreadInsert:tF,onClearPendingThread:()=>tW(null),autoMode:ta,onAutoModeChange:t9,repos:ad,selectedRepoIds:ac,onRepoSelectionChange:ah})]})})}),u&&(0,t.jsx)(eJ,{logs:O,participants:ep,onClear:()=>void D(v),open:eQ,onToggle:()=>e0(!1)}),(0,t.jsx)(eO.default,{isOpen:null!==tv,title:tv?.type==="thread"?"Delete Discussion":"Delete Message",message:tv?.type==="thread"?"This will permanently delete this discussion and all of its replies. This action cannot be undone.":"This will permanently delete this message. This action cannot be undone.",preview:tv?.preview,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"danger",onConfirm:an,onCancel:ai})]})}],186552)}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,640481,e=>{"use strict";let t=(0,e.i(363732).default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);e.s(["Pencil",0,t],640481)},958164,e=>{"use strict";let t=(0,e.i(363732).default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);e.s(["AlertTriangle",0,t],958164)},741746,e=>{"use strict";let t=(0,e.i(363732).default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);e.s(["AlertCircle",0,t],741746)},367859,e=>{"use strict";let t=(0,e.i(363732).default)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);e.s(["ChevronRight",0,t],367859)},437307,e=>{"use strict";let t=(0,e.i(363732).default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);e.s(["XCircle",0,t],437307)},794731,e=>{"use strict";let t=(0,e.i(363732).default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);e.s(["Trash2",0,t],794731)},580873,e=>{"use strict";let t=(0,e.i(363732).default)("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]);e.s(["Clock",0,t],580873)},203096,e=>{"use strict";let t=(0,e.i(363732).default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);e.s(["RefreshCw",0,t],203096)},423709,e=>{"use strict";e.s(["stripMarkers",0,function(e){return e.replace(/\[reaction\s+[^\]]*\]/gi,"").replace(/\[agx:[^\]]*\]/g,"").replace(/\[checkpoint\]/g,"").replace(/\[criteria:\s*[^\]]*\]/g,"").replace(/\[done\]/g,"").replace(/\[blocked[^\]]*\]/g,"").replace(/^\[SKIP\]$/gm,"").trim()}])},990933,e=>{"use strict";function t(e){if("string"==typeof e)return e.trim()||void 0}e.s(["extractComposerRouting",0,function(e,r){let a=new Set,s=new Set;!function e(t,r){if(t)for(let a of t)r(a),e(a.content,r)}(e.content,e=>{if("participantMention"!==e.type)return;let t=e.attrs??{},r="string"==typeof t.id?t.id.trim():"",n="string"==typeof t.kind?t.kind:"agent";r&&"agent"===n&&(a.add(r),"parallel"===t.mode&&s.add(r))});let n=t(r);return{...n?{pinnedParticipantId:n}:{},mentionedParticipantIds:Array.from(a),parallelParticipantIds:Array.from(s)}},"orderParticipantIds",0,function(e,r){let a=function(e){if(!Array.isArray(e))return[];let t=new Set,r=[];for(let a of e){if("string"!=typeof a)continue;let e=a.trim();!e||t.has(e)||(t.add(e),r.push(e))}return r}(e),s=t(r);return s&&a.includes(s)?[s,...a.filter(e=>e!==s)]:a}])},66386,e=>{"use strict";var t=e.i(271645),r=e.i(618566);function a(e){return"string"!=typeof e?null:e.trim()||null}function s(e,t){return(e.get(t)?.trim()??"")||null}e.s(["useUrlSelection",0,function(){let e=(0,r.useRouter)(),n=(0,r.usePathname)(),i=(0,r.useSearchParams)(),l=(0,t.useCallback)(e=>s(i,e),[i]),c=(0,t.useCallback)((e,t)=>(function(e,t,r){let n=function(e,t){let r={...t},n=e=>Object.prototype.hasOwnProperty.call(t,e);if(n("issue")&&!n("run")){let n=s(e,"issue");a(t.issue)!==n&&(r.run=null)}if(n("job")&&!n("run")){let n=s(e,"job");a(t.job)!==n&&(r.run=null)}if(n("open")&&!n("message")){let n=s(e,"open");a(t.open)!==n&&(r.message=null)}return r}(t,r),i=new URLSearchParams(t.toString());for(let[e,t]of Object.entries(n)){let r=a(t);r?i.set(e,r):i.delete(e)}let l=i.toString();return l?`${e}?${l}`:e})(t??n,i,e),[n,i]),u=(0,t.useCallback)((t,r)=>{e.push(c(t,r))},[c,e]),o=(0,t.useCallback)((t,r)=>{e.replace(c(t,r))},[c,e]);return{pathname:n,searchParams:i,getSelection:l,buildHref:c,pushSelection:u,replaceSelection:o}}])},945028,490011,e=>{"use strict";var t=e.i(271645);function r(e){return`threadId=${encodeURIComponent(e)}`}function a(e){return`workspaceId=${encodeURIComponent(e)}`}e.s(["useGroupChat",0,function(e){let[s,n]=(0,t.useState)([]),[i,l]=(0,t.useState)([]),[c,u]=(0,t.useState)([]),o=(0,t.useRef)(e),d=(0,t.useRef)(e);o.current=e,d.current!==e&&(d.current=e,n([]),l([]),u([]));let p=(0,t.useCallback)(async e=>{let t=e?.trim()||o.current?.trim();if(!t){n([]),l([]);return}let s=r(t);try{let[e,r]=await Promise.all([fetch(`/api/history?${s}`),fetch(`/api/logs?${a(t)}`)]);if(o.current!==t)return;e.ok&&n(await e.json()),r.ok&&l(await r.json())}catch{}},[]),h=(0,t.useCallback)(async e=>{let t=e?.trim()||o.current?.trim();if(!t){n([]),l([]);return}let s=r(t);await Promise.all([fetch(`/api/history?${s}`,{method:"DELETE"}),fetch(`/api/logs?${a(t)}`,{method:"DELETE"})]),o.current===t&&(n([]),l([]))},[]),f=(0,t.useCallback)(async(e,t=10,r,a,s,i,l,c,d,p)=>{let h=r?.trim()||o.current?.trim();if(!h)return;let f=Date.now(),m=crypto.randomUUID(),y={id:m,role:"user",participantId:null,content:e,timestamp:f,rootMessageId:a||null,parentMessageId:a||null,depth:+!!a,...i&&i.length>0?{attachments:i}:{}};n(e=>[...e,y]);try{let r=await fetch("/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:h,prompt:e,promptPrefix:d||void 0,maxRounds:t,userMessageId:m,rootMessageId:a||void 0,attachmentIds:s?.length?s:void 0,activeParticipantIds:Array.isArray(l)?l:void 0,projectSlug:c?.trim()||void 0,routing:p})}),i=await r.json().catch(e=>(console.warn("[useGroupChat] failed to parse run response:",e),null));r.ok&&i?.chatRunId?u(e=>[{chatRunId:i.chatRunId,threadId:h,rootMessageId:a||m,status:"queued",optimistic:!0,enqueuedAt:Date.now()},...e.filter(e=>e.chatRunId!==i.chatRunId)]):r.ok||(console.error(`[useGroupChat] POST /api/chat failed (${r.status}):`,i?.error||r.statusText),n(e=>e.map(e=>e.id===m?{...e,sendFailed:!0}:e)))}catch(e){console.error("[useGroupChat] network error sending message:",e),n(e=>e.map(e=>e.id===m?{...e,sendFailed:!0}:e))}return m},[]),m=(0,t.useCallback)(async()=>{let e=o.current?.trim();if(e)try{await fetch(`/api/processes?workspaceId=${encodeURIComponent(e)}`,{method:"DELETE"})}catch{}},[]),y=(0,t.useCallback)(async e=>{let t=o.current?.trim();if(t)try{await fetch(`/api/processes?workspaceId=${encodeURIComponent(t)}&threadId=${encodeURIComponent(e)}`,{method:"DELETE"})}catch{}},[]);return{messages:s,setMessages:n,logs:i,sendMessage:f,loadHistory:p,clearHistory:h,clearLogs:(0,t.useCallback)(async e=>{let t=e?.trim()||o.current?.trim();t?(await fetch(`/api/logs?${a(t)}`,{method:"DELETE"}).catch(e=>console.warn("[useGroupChat] delete logs failed:",e)),o.current===t&&l([])):l([])},[]),chatRuns:c,setChatRuns:u,stop:m,stopThread:y}}],945028);let s=new Set(["spawning","running"]);e.s(["useProcessPolling",0,function(e,r){let a=r?.intervalMs??1500,n=r?.idleIntervalMs??1e4,[i,l]=(0,t.useState)(new Set),[c,u]=(0,t.useState)([]),[o,d]=(0,t.useState)({}),[p,h]=(0,t.useState)([]),f=(0,t.useRef)(e);f.current=e;let m=(0,t.useRef)(r?.messages??[]);m.current=r?.messages??[];let y=(0,t.useRef)(r?.setMessages);y.current=r?.setMessages;let g=(0,t.useRef)(0);(0,t.useEffect)(()=>{let e=r?.messages??[];if(e.length>0){let t=Math.max(...e.map(e=>e.timestamp));t>g.current&&(g.current=t)}},[r?.messages]);let k=(0,t.useCallback)(async()=>{let e=f.current;if(!e){l(new Set),u([]),d({}),h([]);return}let t=null;if(e.threadId?t=`/api/processes?threadId=${encodeURIComponent(e.threadId)}`:e.workspaceId&&(t=`/api/processes?workspaceId=${encodeURIComponent(e.workspaceId)}`),!t){l(new Set),u([]),d({}),h([]);return}try{let a=e.workspaceId||e.threadId,n=a?`/api/history?threadId=${encodeURIComponent(a)}&since=${g.current}`:null,i=a?`/api/chat-runs?threadId=${encodeURIComponent(a)}&limit=20`:null,c=[fetch(t)];n&&c.push(fetch(n)),i&&c.push(fetch(i));let[o,p,k]=await Promise.all(c),I=f.current;if(I?.threadId!==e.threadId||I?.workspaceId!==e.workspaceId)return;if(o.ok){let e=await o.json();u(e);let t=new Set(e.filter(e=>s.has(e.state)).map(e=>e.agentId));l(t);let r={};for(let t of e){if(!s.has(t.state))continue;let e=m.current.find(e=>e.id===t.sinceMessageId),a=e?.rootMessageId??t.sinceMessageId;r[t.agentId]={content:"",rootMessageId:a}}d(r)}if(k?.ok){var r;let e=(r=await k.json(),Array.isArray(r)?r.map(e=>{if(!e||"object"!=typeof e)return null;let t="string"==typeof e.chatRunId?e.chatRunId:"string"==typeof e.id?e.id:null,r="string"==typeof e.threadId?e.threadId:null,a="string"==typeof e.status?e.status:null,s="string"==typeof e.rootMessageId?e.rootMessageId:(e.rootMessageId,null);return t&&r&&a&&("queued"===a||"running"===a||"awaiting_user"===a||"blocked"===a||"completed"===a||"failed"===a||"cancelled"===a)?{chatRunId:t,threadId:r,rootMessageId:s,status:a,optimistic:!1}:null}).filter(e=>!!e):[]);h(e)}if(p?.ok&&y.current){let e=await p.json();if(e.length>0){let t=Math.max(...e.map(e=>e.timestamp));t>g.current&&(g.current=t),y.current(t=>{let r=new Set(t.map(e=>e.id)),a=e.filter(e=>!r.has(e.id)),s=t.map(t=>e.find(e=>e.id===t.id)??t);return 0===a.length?s:[...s,...a].sort((e,t)=>e.timestamp-t.timestamp)})}}}catch{}},[]),I=e?.threadId||e?.workspaceId||null,w=p.some(e=>"queued"===e.status||"running"===e.status),v=c.some(e=>s.has(e.state)),M=w||v?a:n;return(0,t.useEffect)(()=>{if(!I){l(new Set),u([]),d({}),h([]);return}k();let e=setInterval(k,M);return()=>clearInterval(e)},[I,M,k]),{activeAgents:i,processes:c,streaming:o,chatRuns:p,poll:k}}],490011)},417442,e=>{"use strict";let t=(0,e.i(363732).default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);e.s(["ArrowRight",0,t],417442)},558201,e=>{"use strict";let t=(0,e.i(363732).default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);e.s(["Terminal",0,t],558201)},245900,e=>{"use strict";let t=(0,e.i(363732).default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);e.s(["Play",0,t],245900)},248004,e=>{"use strict";let t=(0,e.i(363732).default)("settings-2",[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);e.s(["Settings2",0,t],248004)},524507,e=>{"use strict";let t=(0,e.i(363732).default)("pause",[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]);e.s(["Pause",0,t],524507)},74636,e=>{"use strict";var t=e.i(843476),r=e.i(271645),a=e.i(568656);e.s(["default",0,function({params:e}){let{slug:s}=(0,r.use)(e);return(0,t.jsx)(a.ProjectObjectivesOverview,{projectSlug:s})}])},501223,e=>{e.v(t=>Promise.all(["static/chunks/0qhyo1udst01v.js"].map(t=>e.l(t))).then(()=>t(844118)))},469612,e=>{e.v(t=>Promise.all(["static/chunks/0il_ov6232avr.js"].map(t=>e.l(t))).then(()=>t(668610)))}]);
@@ -0,0 +1,16 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,958164,e=>{"use strict";let t=(0,e.i(363732).default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);e.s(["AlertTriangle",0,t],958164)},741746,e=>{"use strict";let t=(0,e.i(363732).default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);e.s(["AlertCircle",0,t],741746)},367859,e=>{"use strict";let t=(0,e.i(363732).default)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);e.s(["ChevronRight",0,t],367859)},80673,e=>{"use strict";let t=(0,e.i(363732).default)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);e.s(["Download",0,t],80673)},629155,e=>{"use strict";let t=(0,e.i(363732).default)("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);e.s(["Hash",0,t],629155)},211464,e=>{"use strict";let t=(0,e.i(363732).default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);e.s(["Circle",0,t],211464)},807087,e=>{"use strict";let t=(0,e.i(363732).default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);e.s(["CheckCircle2",0,t],807087)},493141,e=>{"use strict";let t=(0,e.i(363732).default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);e.s(["ChevronLeft",0,t],493141)},437307,e=>{"use strict";let t=(0,e.i(363732).default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);e.s(["XCircle",0,t],437307)},794731,e=>{"use strict";let t=(0,e.i(363732).default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);e.s(["Trash2",0,t],794731)},580873,e=>{"use strict";let t=(0,e.i(363732).default)("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]);e.s(["Clock",0,t],580873)},203096,e=>{"use strict";let t=(0,e.i(363732).default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);e.s(["RefreshCw",0,t],203096)},423709,e=>{"use strict";e.s(["stripMarkers",0,function(e){return e.replace(/\[reaction\s+[^\]]*\]/gi,"").replace(/\[agx:[^\]]*\]/g,"").replace(/\[checkpoint\]/g,"").replace(/\[criteria:\s*[^\]]*\]/g,"").replace(/\[done\]/g,"").replace(/\[blocked[^\]]*\]/g,"").replace(/^\[SKIP\]$/gm,"").trim()}])},990933,e=>{"use strict";function t(e){if("string"==typeof e)return e.trim()||void 0}e.s(["extractComposerRouting",0,function(e,r){let a=new Set,n=new Set;!function e(t,r){if(t)for(let a of t)r(a),e(a.content,r)}(e.content,e=>{if("participantMention"!==e.type)return;let t=e.attrs??{},r="string"==typeof t.id?t.id.trim():"",s="string"==typeof t.kind?t.kind:"agent";r&&"agent"===s&&(a.add(r),"parallel"===t.mode&&n.add(r))});let s=t(r);return{...s?{pinnedParticipantId:s}:{},mentionedParticipantIds:Array.from(a),parallelParticipantIds:Array.from(n)}},"orderParticipantIds",0,function(e,r){let a=function(e){if(!Array.isArray(e))return[];let t=new Set,r=[];for(let a of e){if("string"!=typeof a)continue;let e=a.trim();!e||t.has(e)||(t.add(e),r.push(e))}return r}(e),n=t(r);return n&&a.includes(n)?[n,...a.filter(e=>e!==n)]:a}])},66386,e=>{"use strict";var t=e.i(271645),r=e.i(618566);function a(e){return"string"!=typeof e?null:e.trim()||null}function n(e,t){return(e.get(t)?.trim()??"")||null}e.s(["useUrlSelection",0,function(){let e=(0,r.useRouter)(),s=(0,r.usePathname)(),i=(0,r.useSearchParams)(),l=(0,t.useCallback)(e=>n(i,e),[i]),c=(0,t.useCallback)((e,t)=>(function(e,t,r){let s=function(e,t){let r={...t},s=e=>Object.prototype.hasOwnProperty.call(t,e);if(s("issue")&&!s("run")){let s=n(e,"issue");a(t.issue)!==s&&(r.run=null)}if(s("job")&&!s("run")){let s=n(e,"job");a(t.job)!==s&&(r.run=null)}if(s("open")&&!s("message")){let s=n(e,"open");a(t.open)!==s&&(r.message=null)}return r}(t,r),i=new URLSearchParams(t.toString());for(let[e,t]of Object.entries(s)){let r=a(t);r?i.set(e,r):i.delete(e)}let l=i.toString();return l?`${e}?${l}`:e})(t??s,i,e),[s,i]),o=(0,t.useCallback)((t,r)=>{e.push(c(t,r))},[c,e]),d=(0,t.useCallback)((t,r)=>{e.replace(c(t,r))},[c,e]);return{pathname:s,searchParams:i,getSelection:l,buildHref:c,pushSelection:o,replaceSelection:d}}])},945028,490011,e=>{"use strict";var t=e.i(271645);function r(e){return`threadId=${encodeURIComponent(e)}`}function a(e){return`workspaceId=${encodeURIComponent(e)}`}e.s(["useGroupChat",0,function(e){let[n,s]=(0,t.useState)([]),[i,l]=(0,t.useState)([]),[c,o]=(0,t.useState)([]),d=(0,t.useRef)(e),u=(0,t.useRef)(e);d.current=e,u.current!==e&&(u.current=e,s([]),l([]),o([]));let p=(0,t.useCallback)(async e=>{let t=e?.trim()||d.current?.trim();if(!t){s([]),l([]);return}let n=r(t);try{let[e,r]=await Promise.all([fetch(`/api/history?${n}`),fetch(`/api/logs?${a(t)}`)]);if(d.current!==t)return;e.ok&&s(await e.json()),r.ok&&l(await r.json())}catch{}},[]),m=(0,t.useCallback)(async e=>{let t=e?.trim()||d.current?.trim();if(!t){s([]),l([]);return}let n=r(t);await Promise.all([fetch(`/api/history?${n}`,{method:"DELETE"}),fetch(`/api/logs?${a(t)}`,{method:"DELETE"})]),d.current===t&&(s([]),l([]))},[]),h=(0,t.useCallback)(async(e,t=10,r,a,n,i,l,c,u,p)=>{let m=r?.trim()||d.current?.trim();if(!m)return;let h=Date.now(),f=crypto.randomUUID(),y={id:f,role:"user",participantId:null,content:e,timestamp:h,rootMessageId:a||null,parentMessageId:a||null,depth:+!!a,...i&&i.length>0?{attachments:i}:{}};s(e=>[...e,y]);try{let r=await fetch("/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:m,prompt:e,promptPrefix:u||void 0,maxRounds:t,userMessageId:f,rootMessageId:a||void 0,attachmentIds:n?.length?n:void 0,activeParticipantIds:Array.isArray(l)?l:void 0,projectSlug:c?.trim()||void 0,routing:p})}),i=await r.json().catch(e=>(console.warn("[useGroupChat] failed to parse run response:",e),null));r.ok&&i?.chatRunId?o(e=>[{chatRunId:i.chatRunId,threadId:m,rootMessageId:a||f,status:"queued",optimistic:!0,enqueuedAt:Date.now()},...e.filter(e=>e.chatRunId!==i.chatRunId)]):r.ok||(console.error(`[useGroupChat] POST /api/chat failed (${r.status}):`,i?.error||r.statusText),s(e=>e.map(e=>e.id===f?{...e,sendFailed:!0}:e)))}catch(e){console.error("[useGroupChat] network error sending message:",e),s(e=>e.map(e=>e.id===f?{...e,sendFailed:!0}:e))}return f},[]),f=(0,t.useCallback)(async()=>{let e=d.current?.trim();if(e)try{await fetch(`/api/processes?workspaceId=${encodeURIComponent(e)}`,{method:"DELETE"})}catch{}},[]),y=(0,t.useCallback)(async e=>{let t=d.current?.trim();if(t)try{await fetch(`/api/processes?workspaceId=${encodeURIComponent(t)}&threadId=${encodeURIComponent(e)}`,{method:"DELETE"})}catch{}},[]);return{messages:n,setMessages:s,logs:i,sendMessage:h,loadHistory:p,clearHistory:m,clearLogs:(0,t.useCallback)(async e=>{let t=e?.trim()||d.current?.trim();t?(await fetch(`/api/logs?${a(t)}`,{method:"DELETE"}).catch(e=>console.warn("[useGroupChat] delete logs failed:",e)),d.current===t&&l([])):l([])},[]),chatRuns:c,setChatRuns:o,stop:f,stopThread:y}}],945028);let n=new Set(["spawning","running"]);e.s(["useProcessPolling",0,function(e,r){let a=r?.intervalMs??1500,s=r?.idleIntervalMs??1e4,[i,l]=(0,t.useState)(new Set),[c,o]=(0,t.useState)([]),[d,u]=(0,t.useState)({}),[p,m]=(0,t.useState)([]),h=(0,t.useRef)(e);h.current=e;let f=(0,t.useRef)(r?.messages??[]);f.current=r?.messages??[];let y=(0,t.useRef)(r?.setMessages);y.current=r?.setMessages;let g=(0,t.useRef)(0);(0,t.useEffect)(()=>{let e=r?.messages??[];if(e.length>0){let t=Math.max(...e.map(e=>e.timestamp));t>g.current&&(g.current=t)}},[r?.messages]);let k=(0,t.useCallback)(async()=>{let e=h.current;if(!e){l(new Set),o([]),u({}),m([]);return}let t=null;if(e.threadId?t=`/api/processes?threadId=${encodeURIComponent(e.threadId)}`:e.workspaceId&&(t=`/api/processes?workspaceId=${encodeURIComponent(e.workspaceId)}`),!t){l(new Set),o([]),u({}),m([]);return}try{let a=e.workspaceId||e.threadId,s=a?`/api/history?threadId=${encodeURIComponent(a)}&since=${g.current}`:null,i=a?`/api/chat-runs?threadId=${encodeURIComponent(a)}&limit=20`:null,c=[fetch(t)];s&&c.push(fetch(s)),i&&c.push(fetch(i));let[d,p,k]=await Promise.all(c),x=h.current;if(x?.threadId!==e.threadId||x?.workspaceId!==e.workspaceId)return;if(d.ok){let e=await d.json();o(e);let t=new Set(e.filter(e=>n.has(e.state)).map(e=>e.agentId));l(t);let r={};for(let t of e){if(!n.has(t.state))continue;let e=f.current.find(e=>e.id===t.sinceMessageId),a=e?.rootMessageId??t.sinceMessageId;r[t.agentId]={content:"",rootMessageId:a}}u(r)}if(k?.ok){var r;let e=(r=await k.json(),Array.isArray(r)?r.map(e=>{if(!e||"object"!=typeof e)return null;let t="string"==typeof e.chatRunId?e.chatRunId:"string"==typeof e.id?e.id:null,r="string"==typeof e.threadId?e.threadId:null,a="string"==typeof e.status?e.status:null,n="string"==typeof e.rootMessageId?e.rootMessageId:(e.rootMessageId,null);return t&&r&&a&&("queued"===a||"running"===a||"awaiting_user"===a||"blocked"===a||"completed"===a||"failed"===a||"cancelled"===a)?{chatRunId:t,threadId:r,rootMessageId:n,status:a,optimistic:!1}:null}).filter(e=>!!e):[]);m(e)}if(p?.ok&&y.current){let e=await p.json();if(e.length>0){let t=Math.max(...e.map(e=>e.timestamp));t>g.current&&(g.current=t),y.current(t=>{let r=new Set(t.map(e=>e.id)),a=e.filter(e=>!r.has(e.id)),n=t.map(t=>e.find(e=>e.id===t.id)??t);return 0===a.length?n:[...n,...a].sort((e,t)=>e.timestamp-t.timestamp)})}}}catch{}},[]),x=e?.threadId||e?.workspaceId||null,v=p.some(e=>"queued"===e.status||"running"===e.status),I=c.some(e=>n.has(e.state)),w=v||I?a:s;return(0,t.useEffect)(()=>{if(!x){l(new Set),o([]),u({}),m([]);return}k();let e=setInterval(k,w);return()=>clearInterval(e)},[x,w,k]),{activeAgents:i,processes:c,streaming:d,chatRuns:p,poll:k}}],490011)},100373,e=>{"use strict";let t=(0,e.i(363732).default)("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]);e.s(["Ban",0,t],100373)},352687,e=>{"use strict";var t=e.i(843476),r=e.i(271645);e.s(["default",0,function({isOpen:e,title:a,message:n,preview:s,confirmLabel:i="Confirm",cancelLabel:l="Cancel",variant:c="default",onConfirm:o,onCancel:d}){let u=(0,r.useRef)(null),p=(0,r.useRef)(null);(0,r.useEffect)(()=>{if(e){let e=setTimeout(()=>u.current?.focus(),50);return()=>clearTimeout(e)}},[e]);let m=(0,r.useCallback)(e=>{"Escape"===e.key&&d()},[d]);if(!e)return null;let h="danger"===c;return(0,t.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-md",style:{animation:"confirm-overlay-in 200ms ease-out"},onClick:e=>e.target===e.currentTarget&&d(),onKeyDown:m,children:[(0,t.jsxs)("div",{ref:p,className:"w-full max-w-md mx-4 bg-[var(--card-bg)] rounded-2xl border border-[var(--card-border)] shadow-2xl overflow-hidden",style:{animation:"confirm-dialog-in 250ms cubic-bezier(0.34, 1.56, 0.64, 1)"},children:[(0,t.jsx)("div",{className:"px-6 pt-6 pb-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[h&&(0,t.jsx)("div",{className:"flex-shrink-0 w-11 h-11 rounded-full bg-red-500/10 border border-red-500/20 flex items-center justify-center",children:(0,t.jsx)("svg",{className:"w-5 h-5 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h3",{className:"text-[15px] font-semibold text-[var(--foreground)]",children:a}),(0,t.jsx)("p",{className:"mt-1 text-[13px] text-[var(--muted-foreground)] leading-relaxed",children:n})]})]})}),s&&(0,t.jsx)("div",{className:"mx-6 mb-3 px-3 py-2.5 rounded-lg bg-[var(--muted)]/40 border border-[var(--card-border)]",children:(0,t.jsxs)("p",{className:"text-[12px] text-[var(--muted-foreground)] line-clamp-3 leading-relaxed italic",children:["“",s,"”"]})}),(0,t.jsx)("div",{className:"mx-6 border-t border-[var(--card-border)]"}),(0,t.jsxs)("div",{className:"px-6 py-4 flex items-center justify-end gap-2.5",children:[(0,t.jsx)("button",{onClick:d,className:"px-4 py-2 rounded-lg text-[13px] font-medium text-[var(--muted-foreground)] hover:text-[var(--foreground)] hover:bg-[var(--muted)]/60 transition-all duration-150",children:l}),(0,t.jsx)("button",{ref:u,onClick:o,className:`px-4 py-2 rounded-lg text-[13px] font-medium transition-all duration-150 ${h?"bg-red-500 text-white hover:bg-red-600 active:scale-[0.97]":"btn-primary active:scale-[0.97]"}`,children:i})]})]}),(0,t.jsx)("style",{children:`
2
+ @keyframes confirm-overlay-in {
3
+ from { opacity: 0; }
4
+ to { opacity: 1; }
5
+ }
6
+ @keyframes confirm-dialog-in {
7
+ from {
8
+ opacity: 0;
9
+ transform: scale(0.9) translateY(10px);
10
+ }
11
+ to {
12
+ opacity: 1;
13
+ transform: scale(1) translateY(0);
14
+ }
15
+ }
16
+ `})]})}])},574957,e=>{"use strict";var t=e.i(843476),r=e.i(271645),a=e.i(186552);e.s(["default",0,function({params:e}){let{slug:n,threadId:s}=(0,r.use)(e);return(0,t.jsx)(a.ChatContainer,{projectSlug:n,initialThreadId:s,showSidebar:!1})}])}]);