sparkecoder 0.1.130 → 0.1.132

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 (216) hide show
  1. package/README.md +3 -3
  2. package/dist/agent/index.d.ts +3 -3
  3. package/dist/agent/index.js +1480 -638
  4. package/dist/agent/index.js.map +1 -1
  5. package/dist/cli.js +2281 -808
  6. package/dist/cli.js.map +1 -1
  7. package/dist/db/index.d.ts +2 -2
  8. package/dist/db/index.js.map +1 -1
  9. package/dist/{index-Bcz0aCAR.d.ts → index-BM99kjgq.d.ts} +177 -103
  10. package/dist/index.d.ts +5 -5
  11. package/dist/index.js +2215 -780
  12. package/dist/index.js.map +1 -1
  13. package/dist/{schema-BWbWmfDQ.d.ts → schema-Dz-wABVY.d.ts} +27 -4
  14. package/dist/{search-DOzC4ojH.d.ts → search-CVVfuBPZ.d.ts} +4 -4
  15. package/dist/server/index.js +2215 -780
  16. package/dist/server/index.js.map +1 -1
  17. package/dist/skills/default/build-context-and-solve-issue.md +74 -0
  18. package/dist/skills/default/doublecheck.md +95 -0
  19. package/dist/tools/index.d.ts +3 -3
  20. package/dist/tools/index.js +11 -2
  21. package/dist/tools/index.js.map +1 -1
  22. package/package.json +1 -1
  23. package/src/skills/default/build-context-and-solve-issue.md +74 -0
  24. package/src/skills/default/doublecheck.md +95 -0
  25. package/web/.next/BUILD_ID +1 -1
  26. package/web/.next/standalone/web/.next/BUILD_ID +1 -1
  27. package/web/.next/standalone/web/.next/build-manifest.json +2 -2
  28. package/web/.next/standalone/web/.next/prerender-manifest.json +3 -3
  29. package/web/.next/standalone/web/.next/server/app/(main)/agents/page/next-font-manifest.json +1 -1
  30. package/web/.next/standalone/web/.next/server/app/(main)/agents/page_client-reference-manifest.js +1 -1
  31. package/web/.next/standalone/web/.next/server/app/(main)/page/next-font-manifest.json +1 -1
  32. package/web/.next/standalone/web/.next/server/app/(main)/page_client-reference-manifest.js +1 -1
  33. package/web/.next/standalone/web/.next/server/app/(main)/session/[id]/page/next-font-manifest.json +1 -1
  34. package/web/.next/standalone/web/.next/server/app/(main)/session/[id]/page_client-reference-manifest.js +1 -1
  35. package/web/.next/standalone/web/.next/server/app/(main)/settings/page/next-font-manifest.json +1 -1
  36. package/web/.next/standalone/web/.next/server/app/(main)/settings/page_client-reference-manifest.js +1 -1
  37. package/web/.next/standalone/web/.next/server/app/_global-error.html +2 -2
  38. package/web/.next/standalone/web/.next/server/app/_global-error.rsc +1 -1
  39. package/web/.next/standalone/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  40. package/web/.next/standalone/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  41. package/web/.next/standalone/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  42. package/web/.next/standalone/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  43. package/web/.next/standalone/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  44. package/web/.next/standalone/web/.next/server/app/_not-found/page/next-font-manifest.json +1 -1
  45. package/web/.next/standalone/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  46. package/web/.next/standalone/web/.next/server/app/_not-found.html +1 -1
  47. package/web/.next/standalone/web/.next/server/app/_not-found.rsc +3 -3
  48. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  49. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  50. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  51. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  52. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  53. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  54. package/web/.next/standalone/web/.next/server/app/agents.html +1 -1
  55. package/web/.next/standalone/web/.next/server/app/agents.rsc +6 -6
  56. package/web/.next/standalone/web/.next/server/app/agents.segments/!KG1haW4p/agents/__PAGE__.segment.rsc +2 -2
  57. package/web/.next/standalone/web/.next/server/app/agents.segments/!KG1haW4p/agents.segment.rsc +1 -1
  58. package/web/.next/standalone/web/.next/server/app/agents.segments/!KG1haW4p.segment.rsc +2 -2
  59. package/web/.next/standalone/web/.next/server/app/agents.segments/_full.segment.rsc +6 -6
  60. package/web/.next/standalone/web/.next/server/app/agents.segments/_head.segment.rsc +1 -1
  61. package/web/.next/standalone/web/.next/server/app/agents.segments/_index.segment.rsc +3 -3
  62. package/web/.next/standalone/web/.next/server/app/agents.segments/_tree.segment.rsc +3 -3
  63. package/web/.next/standalone/web/.next/server/app/api/config/route.js.nft.json +1 -1
  64. package/web/.next/standalone/web/.next/server/app/api/health/route.js.nft.json +1 -1
  65. package/web/.next/standalone/web/.next/server/app/docs/installation/page/next-font-manifest.json +1 -1
  66. package/web/.next/standalone/web/.next/server/app/docs/installation/page_client-reference-manifest.js +1 -1
  67. package/web/.next/standalone/web/.next/server/app/docs/installation.html +4 -4
  68. package/web/.next/standalone/web/.next/server/app/docs/installation.rsc +6 -6
  69. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_full.segment.rsc +6 -6
  70. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_head.segment.rsc +1 -1
  71. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_index.segment.rsc +3 -3
  72. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_tree.segment.rsc +2 -2
  73. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs/installation/__PAGE__.segment.rsc +20 -21
  74. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs/installation.segment.rsc +1 -1
  75. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs.segment.rsc +2 -2
  76. package/web/.next/standalone/web/.next/server/app/docs/page/next-font-manifest.json +1 -1
  77. package/web/.next/standalone/web/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  78. package/web/.next/standalone/web/.next/server/app/docs/skills/page/next-font-manifest.json +1 -1
  79. package/web/.next/standalone/web/.next/server/app/docs/skills/page_client-reference-manifest.js +1 -1
  80. package/web/.next/standalone/web/.next/server/app/docs/skills.html +2 -2
  81. package/web/.next/standalone/web/.next/server/app/docs/skills.rsc +4 -4
  82. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_full.segment.rsc +4 -4
  83. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_head.segment.rsc +1 -1
  84. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_index.segment.rsc +3 -3
  85. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_tree.segment.rsc +2 -2
  86. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs/skills/__PAGE__.segment.rsc +1 -1
  87. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs/skills.segment.rsc +1 -1
  88. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs.segment.rsc +2 -2
  89. package/web/.next/standalone/web/.next/server/app/docs/tools/page/next-font-manifest.json +1 -1
  90. package/web/.next/standalone/web/.next/server/app/docs/tools/page_client-reference-manifest.js +1 -1
  91. package/web/.next/standalone/web/.next/server/app/docs/tools.html +2 -2
  92. package/web/.next/standalone/web/.next/server/app/docs/tools.rsc +4 -4
  93. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_full.segment.rsc +4 -4
  94. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_head.segment.rsc +1 -1
  95. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_index.segment.rsc +3 -3
  96. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_tree.segment.rsc +2 -2
  97. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs/tools/__PAGE__.segment.rsc +2 -2
  98. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs/tools.segment.rsc +1 -1
  99. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs.segment.rsc +2 -2
  100. package/web/.next/standalone/web/.next/server/app/docs.html +3 -3
  101. package/web/.next/standalone/web/.next/server/app/docs.rsc +5 -5
  102. package/web/.next/standalone/web/.next/server/app/docs.segments/_full.segment.rsc +5 -5
  103. package/web/.next/standalone/web/.next/server/app/docs.segments/_head.segment.rsc +1 -1
  104. package/web/.next/standalone/web/.next/server/app/docs.segments/_index.segment.rsc +3 -3
  105. package/web/.next/standalone/web/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
  106. package/web/.next/standalone/web/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +3 -3
  107. package/web/.next/standalone/web/.next/server/app/docs.segments/docs.segment.rsc +2 -2
  108. package/web/.next/standalone/web/.next/server/app/index.html +1 -1
  109. package/web/.next/standalone/web/.next/server/app/index.rsc +6 -6
  110. package/web/.next/standalone/web/.next/server/app/index.segments/!KG1haW4p/__PAGE__.segment.rsc +2 -2
  111. package/web/.next/standalone/web/.next/server/app/index.segments/!KG1haW4p.segment.rsc +2 -2
  112. package/web/.next/standalone/web/.next/server/app/index.segments/_full.segment.rsc +6 -6
  113. package/web/.next/standalone/web/.next/server/app/index.segments/_head.segment.rsc +1 -1
  114. package/web/.next/standalone/web/.next/server/app/index.segments/_index.segment.rsc +3 -3
  115. package/web/.next/standalone/web/.next/server/app/index.segments/_tree.segment.rsc +3 -3
  116. package/web/.next/standalone/web/.next/server/app/settings.html +1 -1
  117. package/web/.next/standalone/web/.next/server/app/settings.rsc +6 -6
  118. package/web/.next/standalone/web/.next/server/app/settings.segments/!KG1haW4p/settings/__PAGE__.segment.rsc +2 -2
  119. package/web/.next/standalone/web/.next/server/app/settings.segments/!KG1haW4p/settings.segment.rsc +1 -1
  120. package/web/.next/standalone/web/.next/server/app/settings.segments/!KG1haW4p.segment.rsc +2 -2
  121. package/web/.next/standalone/web/.next/server/app/settings.segments/_full.segment.rsc +6 -6
  122. package/web/.next/standalone/web/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  123. package/web/.next/standalone/web/.next/server/app/settings.segments/_index.segment.rsc +3 -3
  124. package/web/.next/standalone/web/.next/server/app/settings.segments/_tree.segment.rsc +3 -3
  125. package/web/.next/standalone/web/.next/server/chunks/[root-of-the-server]__36edac7c._.js +1 -1
  126. package/web/.next/standalone/web/.next/server/chunks/ssr/[root-of-the-server]__397fadd4._.js +1 -1
  127. package/web/.next/standalone/web/.next/server/chunks/ssr/[root-of-the-server]__70cecda8._.js +1 -1
  128. package/web/.next/standalone/web/.next/server/chunks/ssr/[root-of-the-server]__be5e2967._.js +1 -1
  129. package/web/.next/standalone/web/.next/server/chunks/ssr/web_src_app_(main)_layout_tsx_453f6492._.js +1 -1
  130. package/web/.next/standalone/web/.next/server/chunks/ssr/web_src_app_(main)_page_tsx_5ac4794b._.js +1 -1
  131. package/web/.next/standalone/web/.next/server/chunks/ssr/web_src_app_(main)_settings_page_tsx_eb320e07._.js +2 -2
  132. package/web/.next/standalone/web/.next/server/next-font-manifest.js +1 -1
  133. package/web/.next/standalone/web/.next/server/next-font-manifest.json +9 -9
  134. package/web/.next/standalone/web/.next/server/pages/404.html +1 -1
  135. package/web/.next/standalone/web/.next/server/pages/500.html +2 -2
  136. package/web/.next/standalone/web/.next/server/server-reference-manifest.js +1 -1
  137. package/web/.next/standalone/web/.next/server/server-reference-manifest.json +1 -1
  138. package/web/.next/standalone/web/.next/static/chunks/185f69f6478ba713.js +1 -0
  139. package/web/.next/standalone/web/.next/static/chunks/20ca4e35e9bb3e94.js +3 -0
  140. package/web/.next/standalone/web/.next/static/chunks/{a7d5d0791c8c6223.css → 34d933785a17edf3.css} +1 -1
  141. package/web/.next/standalone/web/.next/static/chunks/7549a5b7c7f6786e.js +1 -0
  142. package/web/.next/standalone/web/.next/static/{static/chunks/c5dd884b71007965.js → chunks/a839c83078c56476.js} +1 -1
  143. package/web/.next/standalone/web/.next/static/media/4fa387ec64143e14-s.3b336396.woff2 +0 -0
  144. package/web/.next/standalone/web/.next/static/media/5ce348bf30bf5439-s.56c1f21e.woff2 +0 -0
  145. package/web/.next/standalone/web/.next/static/media/6306c77e7c8268e4-s.e3369375.woff2 +0 -0
  146. package/web/.next/standalone/web/.next/static/media/797e433ab948586e-s.p.29207c2f.woff2 +0 -0
  147. package/web/.next/standalone/web/.next/static/media/7d817b4c03b0c5f1-s.a40b9a8b.woff2 +0 -0
  148. package/web/.next/standalone/web/.next/static/media/bbc41e54d2fcbd21-s.fe42ddf4.woff2 +0 -0
  149. package/web/.next/standalone/web/.next/static/static/chunks/185f69f6478ba713.js +1 -0
  150. package/web/.next/standalone/web/.next/static/static/chunks/20ca4e35e9bb3e94.js +3 -0
  151. package/web/.next/standalone/web/.next/static/static/chunks/{a7d5d0791c8c6223.css → 34d933785a17edf3.css} +1 -1
  152. package/web/.next/standalone/web/.next/static/static/chunks/7549a5b7c7f6786e.js +1 -0
  153. package/web/.next/{static/chunks/c5dd884b71007965.js → standalone/web/.next/static/static/chunks/a839c83078c56476.js} +1 -1
  154. package/web/.next/standalone/web/.next/static/static/media/4fa387ec64143e14-s.3b336396.woff2 +0 -0
  155. package/web/.next/standalone/web/.next/static/static/media/5ce348bf30bf5439-s.56c1f21e.woff2 +0 -0
  156. package/web/.next/standalone/web/.next/static/static/media/6306c77e7c8268e4-s.e3369375.woff2 +0 -0
  157. package/web/.next/standalone/web/.next/static/static/media/797e433ab948586e-s.p.29207c2f.woff2 +0 -0
  158. package/web/.next/standalone/web/.next/static/static/media/7d817b4c03b0c5f1-s.a40b9a8b.woff2 +0 -0
  159. package/web/.next/standalone/web/.next/static/static/media/bbc41e54d2fcbd21-s.fe42ddf4.woff2 +0 -0
  160. package/web/.next/standalone/web/package-lock.json +21 -21
  161. package/web/.next/standalone/web/runtime-config.json +2 -1
  162. package/web/.next/standalone/web/src/app/(main)/page.tsx +2 -2
  163. package/web/.next/standalone/web/src/app/(main)/settings/page.tsx +111 -11
  164. package/web/.next/standalone/web/src/app/__sfapi/[...path]/route.ts +96 -0
  165. package/web/.next/standalone/web/src/app/api/config/route.ts +5 -12
  166. package/web/.next/standalone/web/src/app/docs/installation/page.mdx +2 -2
  167. package/web/.next/standalone/web/src/app/docs/page.mdx +1 -1
  168. package/web/.next/standalone/web/src/components/sessions-sidebar.tsx +1 -1
  169. package/web/.next/standalone/web/src/lib/config.ts +26 -16
  170. package/web/.next/static/chunks/185f69f6478ba713.js +1 -0
  171. package/web/.next/static/chunks/20ca4e35e9bb3e94.js +3 -0
  172. package/web/.next/static/chunks/{a7d5d0791c8c6223.css → 34d933785a17edf3.css} +1 -1
  173. package/web/.next/static/chunks/7549a5b7c7f6786e.js +1 -0
  174. package/web/.next/{standalone/web/.next/static/chunks/c5dd884b71007965.js → static/chunks/a839c83078c56476.js} +1 -1
  175. package/web/.next/static/media/4fa387ec64143e14-s.3b336396.woff2 +0 -0
  176. package/web/.next/static/media/5ce348bf30bf5439-s.56c1f21e.woff2 +0 -0
  177. package/web/.next/static/media/6306c77e7c8268e4-s.e3369375.woff2 +0 -0
  178. package/web/.next/static/media/797e433ab948586e-s.p.29207c2f.woff2 +0 -0
  179. package/web/.next/static/media/7d817b4c03b0c5f1-s.a40b9a8b.woff2 +0 -0
  180. package/web/.next/static/media/bbc41e54d2fcbd21-s.fe42ddf4.woff2 +0 -0
  181. package/web/.next/standalone/web/.next/static/chunks/9b88f148788e4504.js +0 -3
  182. package/web/.next/standalone/web/.next/static/chunks/b203b9aa975135d3.js +0 -1
  183. package/web/.next/standalone/web/.next/static/chunks/ea89ca7892d8c557.js +0 -1
  184. package/web/.next/standalone/web/.next/static/media/4fa387ec64143e14-s.c36e1862.woff2 +0 -0
  185. package/web/.next/standalone/web/.next/static/media/5ce348bf30bf5439-s.ebceb24d.woff2 +0 -0
  186. package/web/.next/standalone/web/.next/static/media/6306c77e7c8268e4-s.ff4a2084.woff2 +0 -0
  187. package/web/.next/standalone/web/.next/static/media/797e433ab948586e-s.p.479bea2b.woff2 +0 -0
  188. package/web/.next/standalone/web/.next/static/media/7d817b4c03b0c5f1-s.f377b9c4.woff2 +0 -0
  189. package/web/.next/standalone/web/.next/static/media/bbc41e54d2fcbd21-s.d1207556.woff2 +0 -0
  190. package/web/.next/standalone/web/.next/static/static/chunks/9b88f148788e4504.js +0 -3
  191. package/web/.next/standalone/web/.next/static/static/chunks/b203b9aa975135d3.js +0 -1
  192. package/web/.next/standalone/web/.next/static/static/chunks/ea89ca7892d8c557.js +0 -1
  193. package/web/.next/standalone/web/.next/static/static/media/4fa387ec64143e14-s.c36e1862.woff2 +0 -0
  194. package/web/.next/standalone/web/.next/static/static/media/5ce348bf30bf5439-s.ebceb24d.woff2 +0 -0
  195. package/web/.next/standalone/web/.next/static/static/media/6306c77e7c8268e4-s.ff4a2084.woff2 +0 -0
  196. package/web/.next/standalone/web/.next/static/static/media/797e433ab948586e-s.p.479bea2b.woff2 +0 -0
  197. package/web/.next/standalone/web/.next/static/static/media/7d817b4c03b0c5f1-s.f377b9c4.woff2 +0 -0
  198. package/web/.next/standalone/web/.next/static/static/media/bbc41e54d2fcbd21-s.d1207556.woff2 +0 -0
  199. package/web/.next/static/chunks/9b88f148788e4504.js +0 -3
  200. package/web/.next/static/chunks/b203b9aa975135d3.js +0 -1
  201. package/web/.next/static/chunks/ea89ca7892d8c557.js +0 -1
  202. package/web/.next/static/media/4fa387ec64143e14-s.c36e1862.woff2 +0 -0
  203. package/web/.next/static/media/5ce348bf30bf5439-s.ebceb24d.woff2 +0 -0
  204. package/web/.next/static/media/6306c77e7c8268e4-s.ff4a2084.woff2 +0 -0
  205. package/web/.next/static/media/797e433ab948586e-s.p.479bea2b.woff2 +0 -0
  206. package/web/.next/static/media/7d817b4c03b0c5f1-s.f377b9c4.woff2 +0 -0
  207. package/web/.next/static/media/bbc41e54d2fcbd21-s.d1207556.woff2 +0 -0
  208. /package/web/.next/standalone/web/.next/static/{2mUQ8I-TCRE5uOBFhIWag → WaAcu3X3K00MDvfn1ik7H}/_buildManifest.js +0 -0
  209. /package/web/.next/standalone/web/.next/static/{2mUQ8I-TCRE5uOBFhIWag → WaAcu3X3K00MDvfn1ik7H}/_clientMiddlewareManifest.json +0 -0
  210. /package/web/.next/standalone/web/.next/static/{2mUQ8I-TCRE5uOBFhIWag → WaAcu3X3K00MDvfn1ik7H}/_ssgManifest.js +0 -0
  211. /package/web/.next/standalone/web/.next/static/static/{2mUQ8I-TCRE5uOBFhIWag → WaAcu3X3K00MDvfn1ik7H}/_buildManifest.js +0 -0
  212. /package/web/.next/standalone/web/.next/static/static/{2mUQ8I-TCRE5uOBFhIWag → WaAcu3X3K00MDvfn1ik7H}/_clientMiddlewareManifest.json +0 -0
  213. /package/web/.next/standalone/web/.next/static/static/{2mUQ8I-TCRE5uOBFhIWag → WaAcu3X3K00MDvfn1ik7H}/_ssgManifest.js +0 -0
  214. /package/web/.next/static/{2mUQ8I-TCRE5uOBFhIWag → WaAcu3X3K00MDvfn1ik7H}/_buildManifest.js +0 -0
  215. /package/web/.next/static/{2mUQ8I-TCRE5uOBFhIWag → WaAcu3X3K00MDvfn1ik7H}/_clientMiddlewareManifest.json +0 -0
  216. /package/web/.next/static/{2mUQ8I-TCRE5uOBFhIWag → WaAcu3X3K00MDvfn1ik7H}/_ssgManifest.js +0 -0
@@ -0,0 +1,3 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,412490,e=>{"use strict";var s=e.i(414294),t=e.i(430878),a=e.i(461957),r=e.i(292511);let l=(0,r.default)("slack",[["rect",{width:"3",height:"8",x:"13",y:"2",rx:"1.5",key:"diqz80"}],["path",{d:"M19 8.5V10h1.5A1.5 1.5 0 1 0 19 8.5",key:"183iwg"}],["rect",{width:"3",height:"8",x:"8",y:"14",rx:"1.5",key:"hqg7r1"}],["path",{d:"M5 15.5V14H3.5A1.5 1.5 0 1 0 5 15.5",key:"76g71w"}],["rect",{width:"8",height:"3",x:"14",y:"13",rx:"1.5",key:"1kmz0a"}],["path",{d:"M15.5 19H14v1.5a1.5 1.5 0 1 0 1.5-1.5",key:"jc4sz0"}],["rect",{width:"8",height:"3",x:"2",y:"8",rx:"1.5",key:"1omvl4"}],["path",{d:"M8.5 5H10V3.5A1.5 1.5 0 1 0 8.5 5",key:"16f3cl"}]]),n=(0,r.default)("cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]),i=(0,r.default)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]),o=(0,r.default)("webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);var d=e.i(367887);let c=(0,r.default)("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);var x=e.i(904781),m=e.i(996720),u=e.i(719583),h=e.i(991234),p=e.i(775377),j=e.i(266514);let f=(0,r.default)("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);var g=e.i(846193),b=e.i(978964),b=b,v=e.i(707387);let N=(0,r.default)("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),y=(0,r.default)("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]]);var k=e.i(114507),k=k,w=e.i(263845),w=w,S=e.i(501253),S=S,C=e.i(482306),z=e.i(210162),z=z,L=e.i(101291),L=L;let A=(0,r.default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);var T=e.i(681711),T=T,B=e.i(99027);let M=(0,r.default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);var D=e.i(865373);let E=(0,r.default)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);var O=e.i(666904),P=e.i(77982),I=e.i(634066),U=e.i(739963),$=e.i(555552);let _=e=>`${(0,U.getApiUrl)()}${e}`;async function R(e,s){return(await fetch(_(e),{...s,headers:{"Content-Type":"application/json",...s?.headers||{}}})).json()}let F=[{id:"general",label:"General",icon:j.Bot},{id:"integrations",label:"Integrations",icon:l},{id:"mcp",label:"MCP",icon:y},{id:"skills",label:"Skills",icon:L.default},{id:"schedules",label:"Schedules",icon:i},{id:"webhooks",label:"Webhooks",icon:o},{id:"audit",label:"Audit log",icon:k.default},{id:"models",label:"Models",icon:f},{id:"apikeys",label:"API Keys",icon:g.Key}];function J(){let[e,a]=(0,t.useState)("general"),[r,l]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let e=!1;return(async()=>{try{let s,t=await fetch(_("/health"));if(!t.ok)return;let a=await t.json();try{let e=a&&a.config?.remoteServer?.url;if(e){let t=await fetch(`${e.replace(/\/$/,"")}/health`);t.ok&&(s=(await t.json()).version)}}catch{}e||l({version:a?.version,remoteVersion:s})}catch{}})(),()=>{e=!0}},[]),(0,s.jsxs)("div",{className:"h-full flex bg-background",children:[(0,s.jsxs)("nav",{className:"w-56 shrink-0 border-r border-border/60 p-3 overflow-y-auto",children:[(0,s.jsxs)("div",{className:"px-2 py-2 mb-2",children:[(0,s.jsx)("h1",{className:"text-base font-semibold",children:"Settings"}),(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:"Configure your orchestrator and channels."}),r?.version&&(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground/70 mt-1 font-mono",children:["sparkecoder v",r.version,r.remoteVersion&&(0,s.jsxs)(s.Fragment,{children:[" · remote v",r.remoteVersion]})]})]}),(0,s.jsx)("ul",{className:"space-y-0.5",children:F.map(t=>{let r=t.icon,l=e===t.id;return(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",onClick:()=>a(t.id),className:(0,$.cn)("w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-sm transition-colors",l?"bg-accent text-foreground":"hover:bg-accent/60 text-foreground/80"),children:[(0,s.jsx)(r,{className:(0,$.cn)("size-4 shrink-0",l?"text-primary":"text-muted-foreground")}),(0,s.jsx)("span",{children:t.label})]})},t.id)})})]}),(0,s.jsx)("div",{className:"flex-1 min-w-0 overflow-y-auto",children:(0,s.jsxs)("div",{className:"max-w-3xl mx-auto p-6",children:["general"===e&&(0,s.jsx)(q,{}),"integrations"===e&&(0,s.jsx)(V,{}),"mcp"===e&&(0,s.jsx)(ed,{}),"schedules"===e&&(0,s.jsx)(ee,{}),"webhooks"===e&&(0,s.jsx)(ea,{}),"audit"===e&&(0,s.jsx)(eh,{}),"models"===e&&(0,s.jsx)(en,{}),"apikeys"===e&&(0,s.jsx)(ei,{}),"skills"===e&&(0,s.jsx)(ep,{})]})})]})}function H({title:e,description:t}){return(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:e}),t&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground mt-0.5",children:t})]})}function q(){let[e,r]=(0,t.useState)(null),[l,n]=(0,t.useState)(""),[i,o]=(0,t.useState)(""),[d,c]=(0,t.useState)(!1),[x,m]=(0,t.useState)(!1),u=(0,t.useCallback)(async()=>{let e=await R("/api/orchestrator");r(e),n(e.name||""),o(e.personality||"")},[]);(0,t.useEffect)(()=>{u()},[u]);let h=async()=>{c(!0),m(!1);try{await R("/api/orchestrator",{method:"PATCH",body:JSON.stringify({name:l||void 0,personality:i})}),m(!0),setTimeout(()=>m(!1),1500)}finally{c(!1)}};if(!e)return(0,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)(a.Loader2,{className:"size-5 animate-spin text-muted-foreground"})});let p=l!==e.name||i!==(e.personality||"");return(0,s.jsxs)("section",{children:[(0,s.jsx)(H,{title:"Orchestrator",description:"Your supervisor agent's name and personality. The personality is appended to its system prompt."}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-sm font-medium",children:"Agent name"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-1.5",children:"Shown in the sidebar and chat header."}),(0,s.jsx)(P.Input,{value:l,onChange:e=>n(e.target.value),placeholder:"Orchestrator",className:"max-w-md"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-sm font-medium",children:"Personality / persona"}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground mb-1.5",children:["Optional. Free-form instructions appended to your orchestrator's system prompt every turn. Examples: ",(0,s.jsx)("em",{children:'"speak in haiku"'}),", ",(0,s.jsx)("em",{children:'"be terse and professional"'}),", ",(0,s.jsx)("em",{children:'"respond in Korean"'}),",",(0,s.jsx)("em",{children:'"you are a senior engineer who values shipping over perfection"'}),"."]}),(0,s.jsx)("textarea",{value:i,onChange:e=>o(e.target.value),rows:6,placeholder:"(blank = default tone)",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-primary/40"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3 pt-1",children:[(0,s.jsxs)(O.Button,{onClick:h,disabled:!p||d,children:[d?(0,s.jsx)(a.Loader2,{className:"size-4 animate-spin mr-2"}):null,"Save"]}),x&&(0,s.jsx)("span",{className:"text-xs text-emerald-500",children:"Saved ✓"})]}),(0,s.jsxs)("div",{className:"rounded-md border border-border/40 bg-muted/30 p-3 text-xs space-y-1",children:[(0,s.jsxs)("p",{children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Session id:"})," ",(0,s.jsx)("code",{children:e.id})]}),(0,s.jsxs)("p",{children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Model:"})," ",(0,s.jsx)("code",{children:e.model})]}),(0,s.jsxs)("p",{children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Working directory:"})," ",(0,s.jsx)("code",{className:"break-all",children:e.workingDirectory})]})]})]})]})}function V(){let[e,r]=(0,t.useState)(null),l=(0,t.useCallback)(async()=>{r(await R("/api/integrations"))},[]);return((0,t.useEffect)(()=>{l()},[l]),e)?(0,s.jsxs)("section",{className:"space-y-4",children:[(0,s.jsx)(H,{title:"Integrations",description:"External channels the orchestrator can send and receive messages on."}),(0,s.jsx)(K,{data:e,onChange:l}),(0,s.jsx)(Z,{data:e,onChange:l})]}):(0,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)(a.Loader2,{className:"size-5 animate-spin text-muted-foreground"})})}function K({data:e,onChange:r}){var n;let i,[o,d]=(0,t.useState)(""),[c,x]=(0,t.useState)(""),[m,u]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[g,v]=(0,t.useState)(""),[y,k]=(0,t.useState)(null),[w,S]=(0,t.useState)(!1),C=async()=>{f(!0);try{await R("/api/integrations/slack",{method:"POST",body:JSON.stringify({botToken:o||void 0,signingSecret:c||void 0})}),d(""),x(""),r()}finally{f(!1)}},z=async()=>{confirm("Remove Slack credentials?")&&(await R("/api/integrations/slack",{method:"DELETE"}),r())},L=async()=>{if(!g)return;k("Sending…");let e=await R("/api/integrations/slack/test",{method:"POST",body:JSON.stringify({channel:g})});k(e.ok?"Sent.":`Failed: ${e.error}`)};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(em,{children:[(0,s.jsx)(eu,{icon:(0,s.jsx)(l,{className:"size-4 text-[#4A154B] dark:text-pink-300"}),title:"Slack",status:e.slack.configured?"Configured":"Not configured",statusTone:e.slack.configured?"text-emerald-500":"text-muted-foreground"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:"Lets the orchestrator receive @mentions and DMs in Slack and reply in-thread via the messenger tool."}),(0,s.jsx)("div",{className:"flex gap-2 mb-3",children:(0,s.jsxs)(O.Button,{size:"sm",variant:"outline",onClick:()=>S(!0),children:[(0,s.jsx)(b.default,{className:"size-3.5 mr-1.5"}),"Setup instructions"]})}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Bot token (xoxb-...)"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(P.Input,{type:m?"text":"password",value:o,onChange:e=>d(e.target.value),placeholder:e.slack.botTokenSet?"(set)":"xoxb-...",className:"text-xs"}),(0,s.jsx)(O.Button,{variant:"outline",size:"icon",onClick:()=>u(e=>!e),children:m?(0,s.jsx)(p.EyeOff,{className:"size-3.5"}):(0,s.jsx)(h.Eye,{className:"size-3.5"})})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Signing secret"}),(0,s.jsx)(P.Input,{type:"password",value:c,onChange:e=>x(e.target.value),placeholder:e.slack.signingSecretSet?"(set)":"...",className:"text-xs"})]}),(0,s.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,s.jsx)(O.Button,{size:"sm",onClick:C,disabled:j||!o&&!c,children:j?(0,s.jsx)(a.Loader2,{className:"size-3.5 animate-spin"}):"Save"}),e.slack.configured&&(0,s.jsx)(O.Button,{size:"sm",variant:"outline",onClick:z,children:"Disconnect"})]})]}),(0,s.jsxs)("div",{className:"mt-3 rounded border border-border/40 bg-background/50 p-2 text-xs space-y-1",children:[(0,s.jsxs)("p",{children:[(0,s.jsx)("strong",{children:"Events URL"})," (paste into Slack → Event Subscriptions):"]}),(0,s.jsx)("code",{className:"block px-2 py-1 rounded bg-muted text-[11px] break-all",children:e.slack.eventsUrl}),(0,s.jsxs)("p",{className:"text-muted-foreground",children:["Subscribe to bot events: ",(0,s.jsx)("code",{children:"app_mention"}),", ",(0,s.jsx)("code",{children:"message.im"}),"."]})]}),e.slack.configured&&(0,s.jsxs)("div",{className:"mt-3 flex gap-2 items-end",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Test post (channel id or #channel)"}),(0,s.jsx)(P.Input,{value:g,onChange:e=>v(e.target.value),placeholder:"C0123 or #general",className:"text-xs"})]}),(0,s.jsx)(O.Button,{size:"sm",variant:"outline",onClick:L,disabled:!g,children:"Send test"}),y&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:y})]})]}),(0,s.jsxs)(em,{children:[(0,s.jsx)(eu,{icon:(0,s.jsx)(N,{className:"size-4 text-amber-500"}),title:"Slack access control",status:(n=e.slack,i=[],n.allowedUsers.length>0&&i.push(`${n.allowedUsers.length} user(s)`),n.allowedChannels.length>0&&i.push(`${n.allowedChannels.length} channel(s)`),n.allowDmsFromAnyone||i.push("DMs locked"),0===i.length?"Open to anyone":i.join(" · ")),statusTone:"text-muted-foreground"}),(0,s.jsx)(W,{data:e,onChange:r})]}),w&&(0,s.jsx)(Y,{eventsUrl:e.slack.eventsUrl,agentName:e.slack.defaultOrchestratorName||"orchestrator",onClose:()=>S(!1)})]})}function W({data:e,onChange:r}){let[l,n]=(0,t.useState)(e.slack.allowedUsers.join(", ")),[i,o]=(0,t.useState)(e.slack.allowedChannels.join(", ")),[d,c]=(0,t.useState)(e.slack.allowDmsFromAnyone),[x,m]=(0,t.useState)(e.slack.deniedReplyEnabled),[u,h]=(0,t.useState)(e.slack.deniedReplyTemplate),[p,j]=(0,t.useState)(!1),[f,g]=(0,t.useState)(!1),b=l.trim()!==e.slack.allowedUsers.join(", ").trim()||i.trim()!==e.slack.allowedChannels.join(", ").trim()||d!==e.slack.allowDmsFromAnyone||x!==e.slack.deniedReplyEnabled||u!==e.slack.deniedReplyTemplate,v=async()=>{j(!0),g(!1);try{let e=e=>e.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean);await R("/api/integrations/slack",{method:"POST",body:JSON.stringify({allowedUsers:e(l),allowedChannels:e(i),allowDmsFromAnyone:d,deniedReplyEnabled:x,deniedReplyTemplate:u})}),r(),g(!0),setTimeout(()=>g(!1),1500)}finally{j(!1)}};return(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Empty lists = no allowlist (accept anyone Slack delivers an event for). When a list is set, only matching users / channels can talk to the orchestrator."}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Allowed users (Slack user IDs)"}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground mb-1",children:["Comma or space separated. e.g. ",(0,s.jsx)("code",{children:"U01ABCD"}),", ",(0,s.jsx)("code",{children:"U09XYZ"}),". Leave blank to allow anyone."]}),(0,s.jsx)(P.Input,{value:l,onChange:e=>n(e.target.value),placeholder:"U01..., U02...",className:"text-xs font-mono"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Allowed channels (Slack channel IDs)"}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground mb-1",children:["Channel IDs only (not ",(0,s.jsx)("code",{children:"#name"}),"). e.g. ",(0,s.jsx)("code",{children:"C012345"}),". Affects @mentions; DMs use the toggle below."]}),(0,s.jsx)(P.Input,{value:i,onChange:e=>o(e.target.value),placeholder:"C012345, C098765",className:"text-xs font-mono"})]}),(0,s.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer",children:[(0,s.jsx)("input",{type:"checkbox",checked:d,onChange:e=>c(e.target.checked),className:"mt-1"}),(0,s.jsxs)("div",{className:"text-xs",children:[(0,s.jsx)("span",{className:"font-medium",children:"Allow DMs from anyone"}),(0,s.jsx)("p",{className:"text-muted-foreground",children:"On: anyone who DMs your bot can talk to it. Off: only users in the allowlist above can DM."})]})]}),(0,s.jsxs)("div",{className:"border-t border-border/40 pt-3",children:[(0,s.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer",children:[(0,s.jsx)("input",{type:"checkbox",checked:x,onChange:e=>m(e.target.checked),className:"mt-1"}),(0,s.jsxs)("div",{className:"text-xs",children:[(0,s.jsx)("span",{className:"font-medium",children:"Auto-reply to denied users"}),(0,s.jsx)("p",{className:"text-muted-foreground",children:"When someone is blocked by the rules above, post a canned reply (no AI) so they know why nothing happened. Posted in-thread for @mentions; in the DM for DMs."})]})]}),(0,s.jsxs)("div",{className:"mt-2 pl-6",children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Reply template"}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground mb-1",children:["Placeholders: ",(0,s.jsx)("code",{className:"px-1 rounded bg-muted",children:"{user}"})," → mentions the requester, ",(0,s.jsx)("code",{className:"px-1 rounded bg-muted",children:"{channel}"})," → mentions the channel."]}),(0,s.jsx)("textarea",{value:u,onChange:e=>h(e.target.value),rows:3,disabled:!x,className:"w-full rounded-md border border-input bg-background px-2 py-1.5 text-xs disabled:opacity-50"})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[(0,s.jsx)(O.Button,{size:"sm",onClick:v,disabled:!b||p,children:p?(0,s.jsx)(a.Loader2,{className:"size-3.5 animate-spin"}):"Save"}),f&&(0,s.jsx)("span",{className:"text-xs text-emerald-500",children:"Saved ✓"})]})]})}function Y({eventsUrl:e,agentName:a,onClose:r}){var n;let i,o,[d,c]=(0,t.useState)(null),x=(n=e,JSON.stringify({display_information:{name:o=(i=(a||"orchestrator").trim()||"orchestrator").slice(0,35),description:`${o} — your orchestrator agent. Spawns worker agents, posts updates, answers questions.`,background_color:"#1f1f24"},features:{bot_user:{display_name:i.replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"orchestrator",always_online:!0},app_home:{home_tab_enabled:!1,messages_tab_enabled:!0,messages_tab_read_only_enabled:!1}},oauth_config:{scopes:{bot:["app_mentions:read","channels:history","chat:write","groups:history","im:history","im:read","im:write","users:read"]}},settings:{event_subscriptions:{request_url:n,bot_events:["app_mention","message.im","message.channels","message.groups"]},interactivity:{is_enabled:!1},org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)),m=async(e,s)=>{await navigator.clipboard.writeText(s),c(e),setTimeout(()=>c(null),1500)};return(0,s.jsx)("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4",onClick:r,children:(0,s.jsxs)("div",{className:"bg-card rounded-lg border border-border max-w-2xl w-full max-h-[85vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border/60 sticky top-0 bg-card",children:[(0,s.jsxs)("h2",{className:"text-base font-semibold flex items-center gap-2",children:[(0,s.jsx)(l,{className:"size-4 text-[#4A154B] dark:text-pink-300"}),"Slack setup"]}),(0,s.jsx)(O.Button,{size:"icon",variant:"ghost",onClick:r,children:(0,s.jsx)(v.X,{className:"size-4"})})]}),(0,s.jsxs)("div",{className:"p-5 space-y-5 text-sm",children:[(0,s.jsxs)(G,{n:1,title:"Create a Slack app from manifest",children:[(0,s.jsxs)("p",{children:["Go to ",(0,s.jsx)("a",{href:"https://api.slack.com/apps?new_app=1",target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"api.slack.com/apps"}),", click ",(0,s.jsx)("strong",{children:"Create New App"})," → ",(0,s.jsx)("strong",{children:"From a manifest"}),", pick your workspace, paste the YAML below, then create."]}),(0,s.jsx)(X,{label:"Slack manifest",value:x,onCopy:()=>m("manifest",x),copied:"manifest"===d})]}),(0,s.jsxs)(G,{n:2,title:"Grab credentials",children:[(0,s.jsxs)("p",{children:["In your new app's ",(0,s.jsx)("strong",{children:"Basic Information"})," page, copy the ",(0,s.jsx)("strong",{children:"Signing Secret"}),". Then under ",(0,s.jsx)("strong",{children:"OAuth & Permissions"}),", install the app to your workspace and copy the ",(0,s.jsx)("strong",{children:"Bot User OAuth Token"})," (starts with ",(0,s.jsx)("code",{children:"xoxb-"}),")."]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Paste both into the Slack card above, then click Save."})]}),(0,s.jsxs)(G,{n:3,title:"Verify the Events URL",children:[(0,s.jsxs)("p",{children:["Slack will challenge the URL automatically when you create the app from the manifest (it's pre-filled with your URL below). If it shows ",(0,s.jsx)("strong",{children:"Verified"})," you're done."]}),(0,s.jsx)(X,{label:"Events URL (already in the manifest)",value:e,onCopy:()=>m("eventsUrl",e),copied:"eventsUrl"===d,mono:!0}),(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"If verification fails, your sparkecoder isn't reachable from the public internet. Set up a cloudflared tunnel — see the Cloudflared card."})]}),(0,s.jsx)(G,{n:4,title:"Invite the bot to channels",children:(0,s.jsxs)("p",{children:["In Slack: ",(0,s.jsx)("code",{children:"/invite @your-bot-name"})," in any channel you want it to respond in. (DMs work without an invite.)"]})}),(0,s.jsxs)(G,{n:5,title:"Lock it down (optional but recommended)",children:[(0,s.jsxs)("p",{children:["By default ",(0,s.jsx)("strong",{children:"anyone"})," in your workspace can DM the bot or mention it in any channel it's in. Use the ",(0,s.jsx)("strong",{children:"Slack access control"})," section to limit access to specific Slack user IDs and channel IDs."]}),(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Find a user ID: click their name in Slack → ⋮ → Copy member ID. Find a channel ID: click the channel name → About → bottom of the panel."})]})]})]})})}function G({n:e,title:t,children:a}){return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("h3",{className:"font-medium flex items-center gap-2",children:[(0,s.jsx)("span",{className:"inline-flex items-center justify-center size-5 rounded-full bg-primary/15 text-primary text-[11px] font-semibold",children:e}),t]}),(0,s.jsx)("div",{className:"pl-7 space-y-2 text-sm text-foreground/90",children:a})]})}function X({label:e,value:t,onCopy:a,copied:r,mono:l}){return(0,s.jsxs)("div",{className:"rounded border border-border/60 bg-background/60 overflow-hidden",children:[(0,s.jsxs)("div",{className:"px-3 py-1.5 flex items-center justify-between border-b border-border/40 bg-muted/40",children:[(0,s.jsx)("span",{className:"text-[11px] text-muted-foreground",children:e}),(0,s.jsxs)(O.Button,{size:"sm",variant:"ghost",onClick:a,className:"h-6 text-[11px]",children:[r?(0,s.jsx)(u.Check,{className:"size-3 mr-1"}):(0,s.jsx)(d.Copy,{className:"size-3 mr-1"}),r?"Copied":"Copy"]})]}),(0,s.jsx)("pre",{className:(0,$.cn)("px-3 py-2 text-[11px] overflow-x-auto whitespace-pre-wrap break-all",l&&"font-mono"),children:t})]})}function Z({data:e,onChange:t}){return(0,s.jsxs)(em,{children:[(0,s.jsx)(eu,{icon:(0,s.jsx)(n,{className:"size-4 text-orange-500"}),title:"Cloudflared tunnel",status:e.cloudflared.publicBaseUrl?"Hostname set":"Local-only",statusTone:e.cloudflared.publicBaseUrl?"text-emerald-500":"text-muted-foreground"}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground mb-2",children:["Required to receive Slack events and webhook hits from the public internet. Run"," ",(0,s.jsx)("code",{className:"px-1 rounded bg-muted text-[11px]",children:"sparkecoder cloudflared-setup"})," for a copy-paste recipe."]}),e.cloudflared.publicBaseUrl&&(0,s.jsxs)("div",{className:"text-xs",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Public base: "}),(0,s.jsx)("code",{className:"px-1 rounded bg-muted",children:e.cloudflared.publicBaseUrl})]}),(0,s.jsx)("div",{className:"mt-3 border-t border-border/40 pt-3",children:(0,s.jsx)(Q,{data:e,onChange:t})})]})}function Q({data:e,onChange:r}){let[l,n]=(0,t.useState)(e.cfAccess.enabled),[i,o]=(0,t.useState)(e.cfAccess.teamDomain??""),[d,c]=(0,t.useState)(e.cfAccess.audTag??""),[x,m]=(0,t.useState)(e.cfAccess.allowedEmails.join(", ")),[u,h]=(0,t.useState)(!1),[p,j]=(0,t.useState)(!1),[f,g]=(0,t.useState)(null),b=e.cfAccess.allowedEmails.join(", "),v=l!==e.cfAccess.enabled||i.trim()!==(e.cfAccess.teamDomain??"")||d.trim()!==(e.cfAccess.audTag??"")||x.trim()!==b.trim(),y=async()=>{h(!0),j(!1),g(null);try{let e=await fetch(_("/api/integrations/cf-access"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:l,teamDomain:i.trim(),audTag:d.trim(),allowedEmails:x.split(/[\s,]+/).map(e=>e.trim().toLowerCase()).filter(Boolean)})});if(!e.ok){let s=await e.json().catch(()=>({}));throw Error(s?.error||`Request failed (${e.status})`)}r(),j(!0),setTimeout(()=>j(!1),1500)}catch(e){g(e instanceof Error?e.message:"Failed to save")}finally{h(!1)}};return(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(N,{className:"size-3.5 text-emerald-500"}),(0,s.jsx)("span",{className:"text-xs font-medium",children:"Cloudflare Access"})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Restrict who can reach your public tunnel URL by email. Localhost always bypasses this, so you can't lock yourself out of your own machine."}),(0,s.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer",children:[(0,s.jsx)("input",{type:"checkbox",checked:l,onChange:e=>n(e.target.checked),className:"mt-1"}),(0,s.jsxs)("div",{className:"text-xs",children:[(0,s.jsx)("span",{className:"font-medium",children:"Enforce Cloudflare Access"}),(0,s.jsx)("p",{className:"text-muted-foreground",children:"When on, every non-local request must carry a valid Cloudflare Access JWT whose email is in the allowlist below."})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Team domain"}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground mb-1",children:["e.g. ",(0,s.jsx)("code",{children:"yourteam.cloudflareaccess.com"})]}),(0,s.jsx)(P.Input,{value:i,onChange:e=>o(e.target.value),placeholder:"yourteam.cloudflareaccess.com",className:"text-xs font-mono"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Application AUD tag"}),(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground mb-1",children:"From the Cloudflare Access application (Access → Applications)."}),(0,s.jsx)(P.Input,{value:d,onChange:e=>c(e.target.value),placeholder:"abc123...",className:"text-xs font-mono"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Allowed emails or domains"}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground mb-1",children:["Comma or space separated. Use a full address (",(0,s.jsx)("code",{children:"you@example.com"}),") or a bare domain (",(0,s.jsx)("code",{children:"studyfetch.com"}),") to allow everyone on it. Leave blank to allow any email that passes your Cloudflare Access policy."]}),(0,s.jsx)(P.Input,{value:x,onChange:e=>m(e.target.value),placeholder:"studyfetch.com, you@example.com",className:"text-xs font-mono"})]}),(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Heads up: this is one of two layers. You must also add the same emails to an “Allow” policy in the Cloudflare dashboard — that's the real gate."}),f&&(0,s.jsx)("p",{className:"text-xs text-red-500",children:f}),(0,s.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[(0,s.jsx)(O.Button,{size:"sm",onClick:y,disabled:!v||u,children:u?(0,s.jsx)(a.Loader2,{className:"size-3.5 animate-spin"}):"Save"}),p&&(0,s.jsx)("span",{className:"text-xs text-emerald-500",children:"Saved ✓"})]})]})}function ee(){let[e,a]=(0,t.useState)([]),[r,l]=(0,t.useState)(!1),n=(0,t.useCallback)(async()=>{a((await R("/api/schedules")).schedules||[])},[]);return(0,t.useEffect)(()=>{n()},[n]),(0,s.jsxs)("section",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)(H,{title:"Schedules",description:"Recurring prompts that wake the orchestrator on a cron."}),(0,s.jsxs)(O.Button,{size:"sm",variant:"outline",onClick:()=>l(e=>!e),children:[(0,s.jsx)(m.Plus,{className:"size-3.5 mr-1"}),"New"]})]}),r&&(0,s.jsx)(es,{onCancel:()=>l(!1),onSaved:()=>{l(!1),n()}}),0===e.length?(0,s.jsx)("p",{className:"text-xs text-muted-foreground italic px-1",children:"No schedules yet."}):(0,s.jsx)("div",{className:"space-y-2",children:e.map(e=>(0,s.jsx)(et,{row:e,onChange:n},e.id))})]})}function es({initial:e,onCancel:r,onSaved:l}){let[n,i]=(0,t.useState)(e?.name||""),[o,d]=(0,t.useState)(e?.cron||"0 9 * * 1-5"),[c,x]=(0,t.useState)(e?.prompt||""),[m,u]=(0,t.useState)(e?.replyChannel||""),[h,p]=(0,t.useState)(!1),j=async()=>{if(n&&o&&c){p(!0);try{e?.id?await R(`/api/schedules/${e.id}`,{method:"PATCH",body:JSON.stringify({name:n,cron:o,prompt:c,replyChannel:m||void 0})}):await R("/api/schedules",{method:"POST",body:JSON.stringify({name:n,cron:o,prompt:c,replyChannel:m||void 0})}),l()}finally{p(!1)}}};return(0,s.jsxs)("div",{className:"rounded-lg border border-border/60 bg-card/40 p-3 mb-2 space-y-2",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Name"}),(0,s.jsx)(P.Input,{value:n,onChange:e=>i(e.target.value),placeholder:"standup-9am",className:"text-xs"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Cron (5 fields)"}),(0,s.jsx)(P.Input,{value:o,onChange:e=>d(e.target.value),placeholder:"0 9 * * 1-5",className:"text-xs font-mono"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Prompt"}),(0,s.jsx)(P.Input,{value:c,onChange:e=>x(e.target.value),placeholder:"Summarize yesterday's git activity",className:"text-xs"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Default reply channel (optional)"}),(0,s.jsx)(P.Input,{value:m,onChange:e=>u(e.target.value),placeholder:"slack:#standup",className:"text-xs"})]}),(0,s.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,s.jsx)(O.Button,{size:"sm",onClick:j,disabled:h||!n||!o||!c,children:h?(0,s.jsx)(a.Loader2,{className:"size-3.5 animate-spin"}):"Save"}),(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",onClick:r,children:"Cancel"})]})]})}function et({row:e,onChange:t}){let a=async()=>{await R(`/api/schedules/${e.id}`,{method:"PATCH",body:JSON.stringify({enabled:!e.enabled})}),t()},r=async()=>{confirm(`Delete schedule "${e.name}"?`)&&(await R(`/api/schedules/${e.id}`,{method:"DELETE"}),t())};return(0,s.jsxs)("div",{className:"rounded-md border border-border/60 bg-background/50 p-3 flex items-start gap-3",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium",children:e.name}),!e.enabled&&(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"paused"})]}),(0,s.jsx)("code",{className:"text-[11px] text-muted-foreground font-mono",children:e.cron}),(0,s.jsx)("p",{className:"text-xs mt-1 line-clamp-2 text-foreground/80",children:e.prompt}),e.replyChannel&&(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:["replyChannel: ",e.replyChannel]}),e.lastFiredAt&&(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:["last fired ",new Date(e.lastFiredAt).toLocaleString()]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)(O.Button,{size:"sm",variant:"outline",onClick:a,children:e.enabled?"Pause":"Resume"}),(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",onClick:r,className:"text-rose-500 hover:text-rose-600",children:(0,s.jsx)(x.Trash2,{className:"size-3.5"})})]})]})}function ea(){let[e,a]=(0,t.useState)([]),[r,l]=(0,t.useState)(!1),n=(0,t.useCallback)(async()=>{a((await R("/api/webhooks")).webhooks||[])},[]);return(0,t.useEffect)(()=>{n()},[n]),(0,s.jsxs)("section",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)(H,{title:"Webhooks",description:"Custom token-protected URLs. POST any JSON to ping the orchestrator."}),(0,s.jsxs)(O.Button,{size:"sm",variant:"outline",onClick:()=>l(e=>!e),children:[(0,s.jsx)(m.Plus,{className:"size-3.5 mr-1"}),"New"]})]}),r&&(0,s.jsx)(er,{onCancel:()=>l(!1),onSaved:()=>{l(!1),n()}}),0===e.length?(0,s.jsx)("p",{className:"text-xs text-muted-foreground italic px-1",children:"No webhooks yet."}):(0,s.jsx)("div",{className:"space-y-2",children:e.map(e=>(0,s.jsx)(el,{row:e,onChange:n},e.id))})]})}function er({onCancel:e,onSaved:r}){let[l,n]=(0,t.useState)(""),[i,o]=(0,t.useState)("now"),[d,c]=(0,t.useState)(""),[x,m]=(0,t.useState)(!1),u=async()=>{if(l){m(!0);try{await R("/api/webhooks",{method:"POST",body:JSON.stringify({name:l,wake:i,template:d||void 0})}),r()}finally{m(!1)}}};return(0,s.jsxs)("div",{className:"rounded-lg border border-border/60 bg-card/40 p-3 mb-2 space-y-2",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Name"}),(0,s.jsx)(P.Input,{value:l,onChange:e=>n(e.target.value),placeholder:"github-prs",className:"text-xs"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Wake"}),(0,s.jsxs)("select",{value:i,onChange:e=>o(e.target.value),className:"w-full text-xs h-9 rounded-md border border-input bg-background px-2",children:[(0,s.jsx)("option",{value:"now",children:"now — ping orchestrator immediately"}),(0,s.jsx)("option",{value:"next",children:"next — add as context, fire later"})]})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Template (optional)"}),(0,s.jsx)(P.Input,{value:d,onChange:e=>c(e.target.value),placeholder:"PR {{pull_request.title}} by {{sender.login}}",className:"text-xs font-mono"})]}),(0,s.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,s.jsx)(O.Button,{size:"sm",onClick:u,disabled:x||!l,children:x?(0,s.jsx)(a.Loader2,{className:"size-3.5 animate-spin"}):"Create"}),(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",onClick:e,children:"Cancel"})]})]})}function el({row:e,onChange:a}){let[r,l]=(0,t.useState)(!1),n=async()=>{await navigator.clipboard.writeText(e.url),l(!0),setTimeout(()=>l(!1),1500)},i=async()=>{confirm("Rotate the token?")&&(await R(`/api/webhooks/${e.id}`,{method:"PATCH",body:JSON.stringify({rotateToken:!0})}),a())},o=async()=>{confirm(`Delete webhook "${e.name}"?`)&&(await R(`/api/webhooks/${e.id}`,{method:"DELETE"}),a())};return(0,s.jsxs)("div",{className:"rounded-md border border-border/60 bg-background/50 p-3 space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,s.jsxs)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:["wake=",e.wake]}),(0,s.jsxs)("span",{className:"ml-auto text-[11px] text-muted-foreground",children:[e.hitCount," hit",1===e.hitCount?"":"s"]})]}),(0,s.jsxs)("div",{className:"flex gap-1 items-center",children:[(0,s.jsx)("code",{className:"flex-1 text-[11px] px-2 py-1 rounded bg-muted break-all",children:e.url}),(0,s.jsx)(O.Button,{size:"icon",variant:"outline",onClick:n,children:r?(0,s.jsx)(u.Check,{className:"size-3.5"}):(0,s.jsx)(d.Copy,{className:"size-3.5"})}),(0,s.jsx)(O.Button,{size:"icon",variant:"outline",onClick:i,title:"Rotate token",children:(0,s.jsx)(c,{className:"size-3.5"})}),(0,s.jsx)(O.Button,{size:"icon",variant:"ghost",onClick:o,className:"text-rose-500 hover:text-rose-600",children:(0,s.jsx)(x.Trash2,{className:"size-3.5"})})]}),e.template&&(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground font-mono",children:["template: ",e.template]}),e.lastHitAt&&(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground",children:["last hit ",new Date(e.lastHitAt).toLocaleString()]})]})}function en(){let[e,r]=(0,t.useState)(null);if((0,t.useEffect)(()=>{(async()=>{r(await (0,U.getConfig)())})()},[]),!e)return(0,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)(a.Loader2,{className:"size-5 animate-spin text-muted-foreground"})});let l=e.availableModels.find(s=>s.id===e.defaultModel);return(0,s.jsxs)("section",{children:[(0,s.jsx)(H,{title:"Models",description:"Default model used for new sessions (orchestrator + workers). You can override per-session from the chat header."}),(0,s.jsxs)("div",{className:"rounded-lg border border-border/60 bg-card/40 p-3 max-w-lg",children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Current default"}),(0,s.jsxs)("p",{className:"text-sm mt-1",children:[(0,s.jsx)("strong",{children:l?.name||e.defaultModel}),l?.provider&&(0,s.jsxs)("span",{className:"text-muted-foreground",children:[" — ",l.provider]})]}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground mt-2",children:["To change the default, set ",(0,s.jsx)("code",{className:"px-1 rounded bg-muted",children:"defaultModel"})," in your"," ",(0,s.jsx)("code",{className:"px-1 rounded bg-muted",children:"sparkecoder.config.json"})," and restart the server."]})]}),(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsx)(I.Label,{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Available models"}),(0,s.jsx)("div",{className:"mt-2 rounded-lg border border-border/60 divide-y divide-border/40",children:e.availableModels.map(t=>(0,s.jsxs)("div",{className:(0,$.cn)("flex items-center justify-between px-3 py-2 text-sm",t.id===e.defaultModel&&"bg-primary/5"),children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"font-medium",children:t.name}),(0,s.jsxs)("span",{className:"text-muted-foreground",children:[" — ",t.provider]}),t.id===e.defaultModel&&(0,s.jsx)("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-primary",children:"default"})]}),(0,s.jsx)("code",{className:"text-[10px] text-muted-foreground font-mono",children:t.id})]},t.id))})]})]})}function ei(){let[e,a]=(0,t.useState)([]),r=(0,t.useCallback)(async()=>{a((await R("/health/api-keys")).providers||[])},[]);return(0,t.useEffect)(()=>{r()},[r]),(0,s.jsxs)("section",{children:[(0,s.jsx)(H,{title:"API Keys",description:"Provider credentials used for AI inference (Vercel AI Gateway etc.). Keys are stored locally."}),(0,s.jsxs)("div",{className:"space-y-2",children:[e.map(e=>(0,s.jsx)(eo,{keyStatus:e,onChange:r},e.provider)),0===e.length&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground italic px-1",children:"No providers configured."})]})]})}function eo({keyStatus:e,onChange:r}){let[l,n]=(0,t.useState)(!1),[i,o]=(0,t.useState)(""),[d,c]=(0,t.useState)(!1),[m,u]=(0,t.useState)(!1),j=async()=>{if(i.trim()){u(!0);try{await R("/health/api-keys",{method:"POST",body:JSON.stringify({provider:e.provider,apiKey:i.trim()})}),o(""),n(!1),r()}finally{u(!1)}}},f=async()=>{confirm(`Remove ${e.provider} API key?`)&&(await fetch(_(`/health/api-keys/${e.provider}`),{method:"DELETE"}),r())};return(0,s.jsxs)("div",{className:"rounded-md border border-border/60 bg-background/50 p-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium capitalize",children:e.provider}),e.configured&&(0,s.jsx)("span",{className:(0,$.cn)("text-[10px] px-1.5 py-0.5 rounded font-medium","env"===e.source?"bg-blue-500/20 text-blue-600 dark:text-blue-300":"bg-emerald-500/20 text-emerald-600 dark:text-emerald-300"),children:"env"===e.source?"from env":"saved"}),(0,s.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground font-mono",children:e.envVar})]}),l?(0,s.jsxs)("div",{className:"flex gap-2 mt-2",children:[(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsx)(P.Input,{type:d?"text":"password",value:i,onChange:e=>o(e.target.value),placeholder:"Paste your API key…",className:"pr-8 text-xs font-mono",autoFocus:!0}),(0,s.jsx)(O.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-2 hover:bg-transparent",onClick:()=>c(e=>!e),children:d?(0,s.jsx)(p.EyeOff,{className:"size-3.5"}):(0,s.jsx)(h.Eye,{className:"size-3.5"})})]}),(0,s.jsx)(O.Button,{size:"sm",onClick:j,disabled:m||!i.trim(),children:m?(0,s.jsx)(a.Loader2,{className:"size-3.5 animate-spin"}):"Save"}),(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",onClick:()=>{n(!1),o("")},children:"Cancel"})]}):(0,s.jsxs)("div",{className:"flex items-center mt-1",children:[(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground font-mono flex-1",children:e.configured?e.maskedKey:"Not configured"}),(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",onClick:()=>n(!0),className:"h-7 text-xs",children:e.configured?"Update":"Add"}),e.configured&&"storage"===e.source&&(0,s.jsx)(O.Button,{size:"icon",variant:"ghost",onClick:f,className:"text-rose-500 hover:text-rose-600",children:(0,s.jsx)(x.Trash2,{className:"size-3.5"})})]})]})}function ed(){let[e,r]=(0,t.useState)([]),[l,n]=(0,t.useState)(!1),[i,o]=(0,t.useState)(!0),d=(0,t.useCallback)(async()=>{o(!0);try{let e=await R("/api/mcp");r(e.servers||[])}finally{o(!1)}},[]);return(0,t.useEffect)(()=>{d()},[d]),(0,s.jsxs)("section",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)(H,{title:"MCP integrations",description:'Model Context Protocol servers. Each adds tools to every agent under "mcp_<name>_<tool>" on the next turn.'}),(0,s.jsxs)(O.Button,{size:"sm",variant:"outline",onClick:()=>n(e=>!e),children:[(0,s.jsx)(m.Plus,{className:"size-3.5 mr-1"}),"New"]})]}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground mb-3 max-w-2xl",children:["For OAuth-protected MCP servers, paste the access token as a header here:",(0,s.jsx)("code",{className:"px-1 rounded bg-muted ml-1",children:"{ Authorization: 'Bearer <your-token>' }"}),". For unauthed servers, leave headers empty. Use ",(0,s.jsx)("strong",{children:"Test"})," to confirm the server is reachable."]}),l&&(0,s.jsx)(ec,{onCancel:()=>n(!1),onSaved:()=>{n(!1),d()}}),i?(0,s.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,s.jsx)(a.Loader2,{className:"size-4 animate-spin text-muted-foreground"})}):0===e.length?(0,s.jsx)("p",{className:"text-xs text-muted-foreground italic px-1",children:"No MCP servers configured."}):(0,s.jsx)("div",{className:"space-y-2",children:e.map(e=>(0,s.jsx)(ex,{row:e,onChange:d},e.id))})]})}function ec({initial:e,onCancel:r,onSaved:l}){let[n,i]=(0,t.useState)(e?.name||""),[o,d]=(0,t.useState)(e?.transport||"http"),[c,x]=(0,t.useState)(e?.url||""),[m,u]=(0,t.useState)(e?.headers?JSON.stringify(e.headers,null,2):""),[h,p]=(0,t.useState)(e?.command||""),[j,f]=(0,t.useState)(e?.args?.join(" ")||""),[g,b]=(0,t.useState)(!1),[v,N]=(0,t.useState)(null),y=async()=>{let s;if(N(null),m.trim())try{let e=JSON.parse(m);e&&"object"==typeof e&&(s=e)}catch{N('Headers must be valid JSON, e.g. {"Authorization":"Bearer xxx"}');return}b(!0);try{let t={name:n,transport:o,enabled:!0};("http"===o||"sse"===o)&&(t.url=c,s&&(t.headers=s)),"stdio"===o&&(t.command=h,t.args=j.split(/\s+/).filter(Boolean)),e?.id?await R(`/api/mcp/${e.id}`,{method:"PATCH",body:JSON.stringify(t)}):await R("/api/mcp",{method:"POST",body:JSON.stringify(t)}),l()}catch(e){N(e?.message||"Save failed")}finally{b(!1)}};return(0,s.jsxs)("div",{className:"rounded-lg border border-border/60 bg-card/40 p-3 mb-3 space-y-2",children:[(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-2",children:[(0,s.jsxs)("div",{className:"col-span-2",children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Name"}),(0,s.jsx)(P.Input,{value:n,onChange:e=>i(e.target.value),placeholder:"github",className:"text-xs"}),(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:["Used as a tool prefix (e.g. ",(0,s.jsx)("code",{children:"mcp_github_search"}),")."]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Transport"}),(0,s.jsxs)("select",{value:o,onChange:e=>d(e.target.value),className:"w-full text-xs h-9 rounded-md border border-input bg-background px-2",children:[(0,s.jsx)("option",{value:"http",children:"HTTP (recommended)"}),(0,s.jsx)("option",{value:"sse",children:"SSE"}),(0,s.jsx)("option",{value:"stdio",children:"stdio (local)"})]})]})]}),"stdio"!==o?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"URL"}),(0,s.jsx)(P.Input,{value:c,onChange:e=>x(e.target.value),placeholder:"https://your-server.com/mcp",className:"text-xs font-mono"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Headers (JSON, optional)"}),(0,s.jsx)("textarea",{value:m,onChange:e=>u(e.target.value),rows:3,placeholder:'{ "Authorization": "Bearer xxx" }',className:"w-full rounded-md border border-input bg-background px-2 py-1.5 text-xs font-mono"})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Command"}),(0,s.jsx)(P.Input,{value:h,onChange:e=>p(e.target.value),placeholder:"node",className:"text-xs font-mono"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Args (space separated)"}),(0,s.jsx)(P.Input,{value:j,onChange:e=>f(e.target.value),placeholder:"src/stdio/dist/server.js",className:"text-xs font-mono"})]})]}),v&&(0,s.jsx)("p",{className:"text-[11px] text-rose-500",children:v}),(0,s.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,s.jsx)(O.Button,{size:"sm",onClick:y,disabled:g||!n||("stdio"!==o?!c:!h),children:g?(0,s.jsx)(a.Loader2,{className:"size-3.5 animate-spin"}):"Save"}),(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",onClick:r,children:"Cancel"})]})]})}function ex({row:e,onChange:r}){let[l,n]=(0,t.useState)(null),[i,o]=(0,t.useState)(!1),[d,c]=(0,t.useState)(!1),m=async()=>{await R(`/api/mcp/${e.id}`,{method:"PATCH",body:JSON.stringify({enabled:!e.enabled})}),r()},u=async()=>{confirm(`Delete MCP server "${e.name}"?`)&&(await R(`/api/mcp/${e.id}`,{method:"DELETE"}),r())},h=async()=>{o(!0),n(null);try{let s=await R(`/api/mcp/${e.id}/test`,{method:"POST"});n(s)}finally{o(!1)}};return d?(0,s.jsx)(ec,{initial:e,onCancel:()=>c(!1),onSaved:()=>{c(!1),r()}}):(0,s.jsxs)("div",{className:"rounded-md border border-border/60 bg-background/50 p-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(y,{className:(0,$.cn)("size-4",e.enabled?"text-emerald-500":"text-muted-foreground")}),(0,s.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:e.transport}),!e.enabled&&(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"disabled"}),(0,s.jsxs)("span",{className:"ml-auto text-[11px] text-muted-foreground font-mono break-all",children:["tool prefix: ",(0,s.jsxs)("code",{children:["mcp_",e.name,"_*"]})]})]}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground mt-1 break-all",children:["stdio"===e.transport?(0,s.jsxs)(s.Fragment,{children:["cmd: ",(0,s.jsxs)("code",{children:[e.command," ",e.args?.join(" ")]})]}):(0,s.jsxs)(s.Fragment,{children:["url: ",(0,s.jsx)("code",{children:e.url})]}),e.headers&&Object.keys(e.headers).length>0&&(0,s.jsxs)("span",{className:"ml-2",children:["headers: ",Object.entries(e.headers).map(([e,s])=>`${e}: ${s}`).join(", ")]})]}),(0,s.jsxs)("div",{className:"flex gap-1 mt-2",children:[(0,s.jsxs)(O.Button,{size:"sm",variant:"outline",onClick:h,disabled:i,children:[i?(0,s.jsx)(a.Loader2,{className:"size-3 animate-spin mr-1"}):null,"Test"]}),(0,s.jsx)(O.Button,{size:"sm",variant:"outline",onClick:m,children:e.enabled?"Disable":"Enable"}),(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",onClick:()=>c(!0),children:"Edit"}),(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",onClick:u,className:"text-rose-500 hover:text-rose-600 ml-auto",children:(0,s.jsx)(x.Trash2,{className:"size-3.5"})})]}),l&&(0,s.jsx)("div",{className:(0,$.cn)("mt-2 rounded border p-2 text-[11px]",l.ok?"border-emerald-500/40 bg-emerald-500/5":"border-rose-500/40 bg-rose-500/5"),children:l.ok?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-emerald-500",children:["✓ Connected — ",l.toolCount," tool(s) discovered"]}),l.toolNames&&l.toolNames.length>0&&(0,s.jsx)("p",{className:"text-muted-foreground font-mono mt-0.5 break-all",children:l.toolNames.join(", ")})]}):(0,s.jsxs)("p",{className:"text-rose-500",children:["✗ ",l.error]})})]})}function em({children:e}){return(0,s.jsx)("div",{className:"rounded-lg border border-border/60 bg-card/40 p-4",children:e})}function eu({icon:e,title:t,status:a,statusTone:r}){return(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[e,(0,s.jsx)("h3",{className:"font-medium",children:t}),(0,s.jsx)("span",{className:(0,$.cn)("ml-auto text-xs",r),children:a})]})}function eh(){let[e,a]=(0,t.useState)([]),[r,l]=(0,t.useState)(0),[n,i]=(0,t.useState)(!0),[o,d]=(0,t.useState)(""),[c,m]=(0,t.useState)(""),[u,h]=(0,t.useState)(""),[p,j]=(0,t.useState)(""),[f,g]=(0,t.useState)(0),[b]=(0,t.useState)(50),[v,N]=(0,t.useState)(null);(0,t.useEffect)(()=>{let e=setTimeout(()=>{j(u),g(0)},250);return()=>clearTimeout(e)},[u]);let y=(0,t.useRef)(!1),k=(0,t.useCallback)(async()=>{y.current||i(!0);try{let e=new URLSearchParams;o&&e.set("source",o),c&&e.set("status",c),p&&e.set("q",p),e.set("limit",String(b)),e.set("offset",String(f*b));let s=await fetch(`${(0,U.getApiUrl)()}/api/integrations/events?${e.toString()}`);if(s.ok){let e=await s.json();a(e.events),l(e.total)}}finally{y.current||i(!1),y.current=!1}},[o,c,p,f,b]);(0,t.useEffect)(()=>{k()},[k]),(0,t.useEffect)(()=>{if(0!==f||o||c||p)return;let e=setInterval(()=>{y.current=!0,k()},5e3);return()=>clearInterval(e)},[f,o,c,p,k]);let L=async()=>{confirm("Clear ALL audit log entries? This cannot be undone.")&&(await fetch(`${(0,U.getApiUrl)()}/api/integrations/events`,{method:"DELETE"}),g(0),k())},A=Math.max(1,Math.ceil(r/b));return(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-base font-semibold",children:"Audit log"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:'Every incoming Slack event, inbox webhook, schedule firing, and orchestrator turn outcome lands here. Use it to debug "why didn\'t the agent respond?".'})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 p-2 rounded-md border border-border/40 bg-card/40",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)(z.default,{className:"size-3.5 text-muted-foreground"}),(0,s.jsx)(P.Input,{value:u,onChange:e=>h(e.target.value),placeholder:"search channel, user, text, reason…",className:"h-7 w-56 text-xs"})]}),(0,s.jsxs)("select",{value:o,onChange:e=>{d(e.target.value),g(0)},className:"h-7 px-2 rounded text-xs bg-background border border-border/60",children:[(0,s.jsx)("option",{value:"",children:"all sources"}),(0,s.jsx)("option",{value:"slack",children:"slack"}),(0,s.jsx)("option",{value:"inbox",children:"inbox"}),(0,s.jsx)("option",{value:"schedule",children:"schedule"}),(0,s.jsx)("option",{value:"webhook",children:"webhook"}),(0,s.jsx)("option",{value:"daemon",children:"daemon"})]}),(0,s.jsxs)("select",{value:c,onChange:e=>{m(e.target.value),g(0)},className:"h-7 px-2 rounded text-xs bg-background border border-border/60",children:[(0,s.jsx)("option",{value:"",children:"all statuses"}),(0,s.jsx)("option",{value:"routed",children:"routed"}),(0,s.jsx)("option",{value:"dropped",children:"dropped"}),(0,s.jsx)("option",{value:"error",children:"error"}),(0,s.jsx)("option",{value:"completed",children:"completed"}),(0,s.jsx)("option",{value:"failed",children:"failed"}),(0,s.jsx)("option",{value:"received",children:"received"})]}),(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",onClick:()=>void k(),className:"h-7 px-2",children:(0,s.jsx)(C.RefreshCw,{className:"size-3.5"})}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground ml-auto",children:n?"loading…":`${r} event${1===r?"":"s"}`}),(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",onClick:()=>void L(),className:"h-7 px-2 text-destructive",children:(0,s.jsx)(x.Trash2,{className:"size-3.5"})})]}),(0,s.jsxs)("div",{className:"rounded-md border border-border/40 bg-card/40 overflow-hidden",children:[0===e.length&&!n&&(0,s.jsx)("p",{className:"p-4 text-xs text-muted-foreground text-center",children:"No events match the current filters."}),e.map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>{window.getSelection()?.toString()||N(s=>s===e.id?null:e.id)},className:"w-full text-left px-3 py-2 border-b border-border/30 last:border-b-0 hover:bg-accent/40 transition-colors",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,s.jsx)("span",{className:"font-mono text-muted-foreground tabular-nums whitespace-nowrap",title:new Date(e.ts).toLocaleString(),children:function(e){let s=new Date(e);if(isNaN(s.getTime()))return e;let t=new Date,a=s.toDateString()===t.toDateString(),r=s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});if(a)return r;let l=s.toLocaleDateString([],{month:"short",day:"numeric"});return`${l} ${r}`}(e.ts)}),(0,s.jsx)(eb,{status:e.status}),(0,s.jsx)("span",{className:"font-medium text-muted-foreground uppercase text-[10px] tracking-wide",children:e.source}),e.subtype&&(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground/70",children:e.subtype}),e.channel&&(0,s.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground/80 truncate max-w-[160px]",children:e.channel}),e.user&&(0,s.jsxs)("span",{className:"font-mono text-[10px] text-muted-foreground/80 truncate max-w-[120px]",children:["@",e.user]}),void 0!==e.durationMs&&(0,s.jsxs)("span",{className:"text-[10px] text-muted-foreground/70",children:[(e.durationMs/1e3).toFixed(1),"s"]}),(0,s.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground/60 font-mono",children:e.id.slice(0,8)})]}),e.textSnippet&&(0,s.jsx)("p",{className:"mt-1 text-xs text-foreground/80 truncate",children:e.textSnippet}),e.dropReason&&(0,s.jsxs)("p",{className:"mt-1 text-[11px] text-yellow-500/90",children:["dropped: ",e.dropReason]}),e.error&&(0,s.jsxs)("p",{className:"mt-1 text-[11px] text-red-500/90",children:["error: ",e.error]}),v===e.id&&(0,s.jsx)("pre",{className:"mt-2 p-2 rounded bg-background/60 text-[10px] font-mono text-muted-foreground overflow-x-auto whitespace-pre-wrap break-all",children:JSON.stringify(e,null,2)})]},e.id))]}),r>b&&(0,s.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,s.jsxs)("span",{className:"text-muted-foreground",children:["Page ",f+1," of ",A]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",disabled:0===f,onClick:()=>g(0),className:"h-7 px-2",children:"First"}),(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",disabled:0===f,onClick:()=>g(e=>e-1),className:"h-7 px-2",children:(0,s.jsx)(w.default,{className:"size-3.5"})}),(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",disabled:f>=A-1,onClick:()=>g(e=>e+1),className:"h-7 px-2",children:(0,s.jsx)(S.default,{className:"size-3.5"})})]})]})]})}function ep(){let[e,r]=(0,t.useState)(null),[l,n]=(0,t.useState)(!0),[i,o]=(0,t.useState)(""),[d,c]=(0,t.useState)(null),[u,h]=(0,t.useState)(null),[p,j]=(0,t.useState)(!1),[f,g]=(0,t.useState)(null),b=(0,t.useCallback)(async()=>{n(!0);try{r(await R("/api/skills"))}finally{n(!1)}},[]);if((0,t.useEffect)(()=>{b()},[b]),l||!e)return(0,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)(a.Loader2,{className:"size-5 animate-spin text-muted-foreground"})});let v=e.directories.map(s=>({dir:s,items:e.skills.filter(e=>e.sourceDir===s.path).filter(e=>!i||e.name.toLowerCase().includes(i.toLowerCase())||e.description.toLowerCase().includes(i.toLowerCase()))})),N=async(e,s)=>{if(e&&0!==e.length){for(let t of Array.from(e)){if(!/\.(md|mdc|markdown|txt)$/i.test(t.name))continue;let e=await t.text();try{await R("/api/skills",{method:"POST",body:JSON.stringify({directory:s,fileName:t.name,content:e})})}catch(e){console.error("skill upload failed",e)}}b()}};return(0,s.jsxs)("section",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)(H,{title:"Skills",description:"Markdown skill files the orchestrator loads on demand. Pulled from built-in defaults plus any directories below — drop .md files in or create new ones from here."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)(O.Button,{size:"sm",variant:"outline",onClick:()=>j(!0),children:[(0,s.jsx)(A,{className:"size-3.5 mr-1"}),"Add folder"]}),(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",onClick:b,children:(0,s.jsx)(C.RefreshCw,{className:"size-3.5"})})]})]}),(0,s.jsx)("div",{className:"mb-3",children:(0,s.jsxs)("div",{className:"relative max-w-sm",children:[(0,s.jsx)(z.default,{className:"absolute left-2 top-1/2 -translate-y-1/2 size-3.5 text-muted-foreground"}),(0,s.jsx)(P.Input,{value:i,onChange:e=>o(e.target.value),placeholder:"Search skills…",className:"pl-7 h-8 text-xs"})]})}),p&&(0,s.jsx)(ej,{onCancel:()=>j(!1),onSaved:()=>{j(!1),b()}}),(0,s.jsx)("div",{className:"space-y-3",children:v.map(({dir:e,items:t})=>(0,s.jsxs)("div",{onDragOver:s=>{e.writable&&(s.preventDefault(),g(e.path))},onDragLeave:()=>g(s=>s===e.path?null:s),onDrop:s=>{s.preventDefault(),g(null),e.writable&&N(s.dataTransfer.files,e.path)},className:(0,$.cn)("rounded-lg border bg-card/40 p-3 transition-colors",f===e.path?"border-primary bg-primary/5":"border-border/60"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)(B.FolderOpen,{className:(0,$.cn)("size-4",e.alwaysApply?"text-amber-500":"text-muted-foreground")}),(0,s.jsx)("span",{className:"text-sm font-medium",children:e.label}),(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:e.source}),e.alwaysApply&&(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-amber-500",children:"always-on"}),!e.exists&&(0,s.jsx)("span",{className:"text-[10px] text-rose-500",children:"missing"}),(0,s.jsx)("code",{className:"ml-auto text-[10px] text-muted-foreground/70 font-mono truncate max-w-[280px]",children:e.path}),e.writable&&(0,s.jsxs)(O.Button,{size:"sm",variant:"ghost",className:"h-6 px-2",onClick:()=>h(e.path),children:[(0,s.jsx)(m.Plus,{className:"size-3 mr-1"}),"New"]}),"additional"===e.source&&(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",className:"h-6 px-1 text-rose-500",onClick:async()=>{confirm(`Stop loading skills from ${e.path}?`)&&(await R(`/api/skills/directories?path=${encodeURIComponent(e.path)}`,{method:"DELETE"}),b())},children:(0,s.jsx)(x.Trash2,{className:"size-3"})})]}),u===e.path&&(0,s.jsx)(ef,{directory:e.path,onCancel:()=>h(null),onSaved:()=>{h(null),b()}}),0===t.length?(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground italic px-1",children:e.writable?"No skills here yet — drop .md files or click New.":"No skills here."}):(0,s.jsx)("div",{className:"divide-y divide-border/30",children:t.map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>c(e),className:"w-full flex items-start gap-2 px-1 py-2 text-left hover:bg-accent/40 rounded transition-colors",children:[(0,s.jsx)(T.default,{className:"size-3.5 text-muted-foreground shrink-0 mt-0.5"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-xs font-medium truncate",children:e.name}),(0,s.jsx)("code",{className:"text-[10px] text-muted-foreground font-mono truncate",children:e.fileName}),e.alwaysApply&&(0,s.jsx)("span",{className:"text-[10px] text-amber-500 uppercase tracking-wide",children:"always"}),e.globs.length>0&&(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground",children:e.globs.join(", ")})]}),e.description&&(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground line-clamp-2 mt-0.5",children:e.description})]}),(0,s.jsx)(D.Pencil,{className:"size-3 text-muted-foreground/60 mt-1"})]},e.id))})]},e.path))}),d&&(0,s.jsx)(eg,{skill:d,onClose:()=>c(null),onSaved:()=>{c(null),b()}})]})}function ej({onCancel:e,onSaved:r}){let[l,n]=(0,t.useState)(""),[i,o]=(0,t.useState)(!1),[d,c]=(0,t.useState)(null),x=(0,t.useRef)(null),m=async()=>{if(c(null),l.trim()){o(!0);try{let e=await R("/api/skills/directories",{method:"POST",body:JSON.stringify({path:l.trim()})});if(e.error)return void c(e.error);r()}finally{o(!1)}}};return(0,s.jsxs)("div",{className:"rounded-lg border border-border/60 bg-card/40 p-3 mb-3 space-y-2",children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Directory path"}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["Absolute path (recommended) or a path relative to the orchestrator's working directory. All ",(0,s.jsx)("code",{children:".md"})," / ",(0,s.jsx)("code",{children:".mdc"})," files inside are picked up automatically."]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(P.Input,{value:l,onChange:e=>n(e.target.value),placeholder:"/Users/you/skills or ./my-skills",className:"text-xs font-mono"}),(0,s.jsxs)(O.Button,{size:"sm",variant:"outline",onClick:()=>x.current?.click(),title:"Pick a folder to suggest its name (browser security: you'll still need to paste the absolute path)",children:[(0,s.jsx)(B.FolderOpen,{className:"size-3.5 mr-1"}),"Browse"]}),(0,s.jsx)("input",{ref:x,type:"file",webkitdirectory:"",directory:"",multiple:!0,hidden:!0,onChange:e=>{let s=e.target.files;if(!s||0===s.length)return;let t=s[0],a=(t.webkitRelativePath||t.name).split("/")[0];l||n(a)}})]}),d&&(0,s.jsx)("p",{className:"text-[11px] text-rose-500",children:d}),(0,s.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,s.jsx)(O.Button,{size:"sm",onClick:m,disabled:i||!l.trim(),children:i?(0,s.jsx)(a.Loader2,{className:"size-3.5 animate-spin"}):"Add folder"}),(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",onClick:e,children:"Cancel"})]})]})}function ef({directory:e,onCancel:r,onSaved:l}){let[n,i]=(0,t.useState)(""),[o,d]=(0,t.useState)(""),[c,x]=(0,t.useState)(""),[m,u]=(0,t.useState)(""),[h,p]=(0,t.useState)(!1),[j,f]=(0,t.useState)(null),g=(0,t.useRef)(null),b=async()=>{f(null);let s=n.trim()||(o?o.toLowerCase().replace(/[^a-z0-9]+/g,"-")+".md":"untitled.md");p(!0);try{let t,a=await R("/api/skills",{method:"POST",body:JSON.stringify({directory:e,fileName:s,content:(t=["---"],o&&t.push(`name: ${o}`),c&&t.push(`description: ${c.replace(/\n/g," ")}`),t.push("---",""),t.join("\n")+(m||`# ${o||"New skill"}
2
+
3
+ Describe what this skill does and when to use it.`))})});if(a.error)return void f(a.error);l()}finally{p(!1)}},v=async e=>{let s=e.target.files;if(!s||!s[0])return;let t=s[0];i(t.name),u(await t.text())};return(0,s.jsxs)("div",{className:"rounded-md border border-border/60 bg-background/50 p-3 mb-2 space-y-2",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Skill name"}),(0,s.jsx)(P.Input,{value:o,onChange:e=>d(e.target.value),placeholder:"React Performance",className:"text-xs"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"File name"}),(0,s.jsx)(P.Input,{value:n,onChange:e=>i(e.target.value),placeholder:"react-performance.md",className:"text-xs font-mono"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Description"}),(0,s.jsx)(P.Input,{value:c,onChange:e=>x(e.target.value),placeholder:"When to use this skill (one sentence).",className:"text-xs"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(I.Label,{className:"text-xs",children:"Body (markdown)"}),(0,s.jsx)("textarea",{value:m,onChange:e=>u(e.target.value),rows:6,placeholder:"# How to do X Step 1…",className:"w-full rounded-md border border-input bg-background px-2 py-1.5 text-xs font-mono"})]}),j&&(0,s.jsx)("p",{className:"text-[11px] text-rose-500",children:j}),(0,s.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,s.jsx)(O.Button,{size:"sm",onClick:b,disabled:h,children:h?(0,s.jsx)(a.Loader2,{className:"size-3.5 animate-spin"}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(M,{className:"size-3.5 mr-1"}),"Save"]})}),(0,s.jsxs)(O.Button,{size:"sm",variant:"outline",onClick:()=>g.current?.click(),children:[(0,s.jsx)(E,{className:"size-3.5 mr-1"}),"Import .md"]}),(0,s.jsx)("input",{ref:g,type:"file",hidden:!0,accept:".md,.mdc,.markdown,.txt",onChange:v}),(0,s.jsx)(O.Button,{size:"sm",variant:"ghost",onClick:r,children:"Cancel"})]})]})}function eg({skill:e,onClose:r,onSaved:l}){let[n,i]=(0,t.useState)(null),[o,d]=(0,t.useState)(!1),[c,m]=(0,t.useState)(!1),[u,h]=(0,t.useState)(!1),[p,j]=(0,t.useState)("");(0,t.useEffect)(()=>{let s=!1;return(async()=>{let t=await R(`/api/skills/${e.id}`);s||(i(t.content),j(t.content),d(t.writable))})(),()=>{s=!0}},[e.id]);let f=null!==n&&n!==p,g=async()=>{if(null!==n&&o){m(!0);try{await R(`/api/skills/${e.id}`,{method:"PUT",body:JSON.stringify({content:n})}),j(n),h(!0),setTimeout(()=>h(!1),1200)}finally{m(!1)}}},b=async()=>{confirm(`Delete skill "${e.name}"? This removes the file from disk.`)&&(await R(`/api/skills/${e.id}`,{method:"DELETE"}),l())};return(0,s.jsx)("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4",onClick:r,children:(0,s.jsxs)("div",{className:"bg-card rounded-lg border border-border max-w-3xl w-full max-h-[85vh] flex flex-col shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border/60",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("h2",{className:"text-base font-semibold flex items-center gap-2 truncate",children:[(0,s.jsx)(T.default,{className:"size-4 text-muted-foreground"}),e.name,!o&&(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"read-only"})]}),(0,s.jsx)("code",{className:"text-[11px] text-muted-foreground font-mono truncate block",children:e.filePath})]}),(0,s.jsx)(O.Button,{size:"icon",variant:"ghost",onClick:r,children:(0,s.jsx)(v.X,{className:"size-4"})})]}),(0,s.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col p-4",children:null===n?(0,s.jsx)("div",{className:"flex items-center justify-center flex-1",children:(0,s.jsx)(a.Loader2,{className:"size-5 animate-spin text-muted-foreground"})}):(0,s.jsx)("textarea",{value:n,onChange:e=>i(e.target.value),readOnly:!o,spellCheck:!1,className:"flex-1 w-full rounded-md border border-input bg-background px-3 py-2 text-xs font-mono resize-none focus:outline-none focus:ring-2 focus:ring-primary/40"})}),(0,s.jsxs)("div",{className:"flex items-center gap-2 px-5 py-3 border-t border-border/60",children:[o&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(O.Button,{size:"sm",onClick:g,disabled:!f||c,children:[c?(0,s.jsx)(a.Loader2,{className:"size-3.5 animate-spin mr-1"}):(0,s.jsx)(M,{className:"size-3.5 mr-1"}),"Save"]}),u&&(0,s.jsx)("span",{className:"text-xs text-emerald-500",children:"Saved ✓"}),(0,s.jsxs)(O.Button,{size:"sm",variant:"ghost",onClick:b,className:"text-rose-500 hover:text-rose-600 ml-auto",children:[(0,s.jsx)(x.Trash2,{className:"size-3.5 mr-1"}),"Delete"]})]}),!o&&(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Built-in skills can't be edited from the UI. Copy the contents into a custom folder to override."})]})]})})}function eb({status:e}){return(0,s.jsx)("span",{className:(0,$.cn)("inline-flex items-center px-1.5 py-0.5 rounded text-[10px] border",{routed:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",completed:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",dropped:"bg-yellow-500/15 text-yellow-400 border-yellow-500/30",received:"bg-blue-500/15 text-blue-400 border-blue-500/30",error:"bg-red-500/15 text-red-400 border-red-500/30",failed:"bg-red-500/15 text-red-400 border-red-500/30"}[e]),children:e})}e.s(["default",()=>J],412490)}]);
@@ -1,2 +1,2 @@
1
1
  @font-face{font-family:Geist;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/fef07dbb0973bf53-s.518e079e.woff2)format("woff2");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Geist;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/8a480f0b521d4e75-s.ea323500.woff2)format("woff2");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:Geist;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/53b9e256198e5412-s.853d50a3.woff2)format("woff2");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Geist;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/7178b3e590c64307-s.55554cd0.woff2)format("woff2");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Geist;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/caa3a2e1cccd8315-s.p.3b6cae6d.woff2)format("woff2");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:Geist Fallback;src:local(Arial);ascent-override:95.94%;descent-override:28.16%;line-gap-override:0.0%;size-adjust:104.76%}.geist_a71539c9-module__T19VSG__className{font-family:Geist,Geist Fallback;font-style:normal}.geist_a71539c9-module__T19VSG__variable{--font-geist-sans:"Geist","Geist Fallback"}
2
- @font-face{font-family:Geist Mono;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/5ce348bf30bf5439-s.ebceb24d.woff2)format("woff2");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Geist Mono;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/4fa387ec64143e14-s.c36e1862.woff2)format("woff2");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:Geist Mono;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/6306c77e7c8268e4-s.ff4a2084.woff2)format("woff2");unicode-range:U+2000-2001,U+2004-2008,U+200A,U+23B8-23BD,U+2500-259F}@font-face{font-family:Geist Mono;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/7d817b4c03b0c5f1-s.f377b9c4.woff2)format("woff2");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Geist Mono;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/bbc41e54d2fcbd21-s.d1207556.woff2)format("woff2");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Geist Mono;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/797e433ab948586e-s.p.479bea2b.woff2)format("woff2");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:Geist Mono Fallback;src:local(Arial);ascent-override:74.67%;descent-override:21.92%;line-gap-override:0.0%;size-adjust:134.59%}.geist_mono_8d43a2aa-module__8Li5zG__className{font-family:Geist Mono,Geist Mono Fallback;font-style:normal}.geist_mono_8d43a2aa-module__8Li5zG__variable{--font-geist-mono:"Geist Mono","Geist Mono Fallback"}
2
+ @font-face{font-family:Geist Mono;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/5ce348bf30bf5439-s.56c1f21e.woff2)format("woff2");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Geist Mono;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/4fa387ec64143e14-s.3b336396.woff2)format("woff2");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:Geist Mono;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/6306c77e7c8268e4-s.e3369375.woff2)format("woff2");unicode-range:U+2000-2001,U+2004-2008,U+200A,U+23B8-23BD,U+2500-259F}@font-face{font-family:Geist Mono;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/7d817b4c03b0c5f1-s.a40b9a8b.woff2)format("woff2");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Geist Mono;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/bbc41e54d2fcbd21-s.fe42ddf4.woff2)format("woff2");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Geist Mono;font-style:normal;font-weight:100 900;font-display:swap;src:url(../media/797e433ab948586e-s.p.29207c2f.woff2)format("woff2");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:Geist Mono Fallback;src:local(Arial);ascent-override:74.67%;descent-override:21.92%;line-gap-override:0.0%;size-adjust:134.59%}.geist_mono_8d43a2aa-module__8Li5zG__className{font-family:Geist Mono,Geist Mono Fallback;font-style:normal}.geist_mono_8d43a2aa-module__8Li5zG__variable{--font-geist-mono:"Geist Mono","Geist Mono Fallback"}
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,138134,e=>{"use strict";var s=e.i(414294),t=e.i(529757),a=e.i(430878),i=e.i(353913),r=e.i(504561),l=e.i(292623),n=e.i(996720),d=e.i(667249),c=e.i(904781),o=e.i(461957),x=e.i(816187),m=e.i(292511);let h=(0,m.default)("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);var u=e.i(220563),p=e.i(846193),j=e.i(719583),g=e.i(707387),f=e.i(991234),N=e.i(775377);let v=(0,m.default)("volume-2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);var b=e.i(79092),y=e.i(372379),k=e.i(266514);let S=(0,m.default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),T=(0,m.default)("sliders-vertical",[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]]);var C=e.i(928574),w=e.i(666904),z=e.i(836191),M=e.i(77982),P=e.i(634066),L=e.i(865259),A=e.i(553880),D=e.i(87614),B=e.i(524741),I=e.i(455706),$=e.i(743053),F=e.i(739963),E=e.i(555552),q=e.i(300739),O=e.i(335130);function V(){let e,m,V,K,R,U=(0,i.useRouter)(),W=(0,i.usePathname)(),{state:H,toggleSidebar:J}=(0,t.useSidebar)(),{sessions:G,isLoading:X}=(0,q.useSessions)(),[Y,_]=(0,a.useState)(!1),[Q,Z]=(0,a.useState)(!1),[ee,es]=(0,a.useState)(!1),[et,ea]=(0,a.useState)(null),[ei,er]=(0,a.useState)(null),el=(0,a.useRef)(null),[en,ed]=(0,a.useState)(""),[ec,eo]=(0,a.useState)(""),[ex,em]=(0,a.useState)({}),[eh,eu]=(0,a.useState)(!1),[ep,ej]=(0,a.useState)(""),eg={type:"object",properties:{},required:[]},[ef,eN]=(0,a.useState)(eg),[ev,eb]=(0,a.useState)(""),[ey,ek]=(0,a.useState)(""),[eS,eT]=(0,a.useState)(""),[eC,ew]=(0,a.useState)(""),[ez,eM]=(0,a.useState)("50"),[eP,eL]=(0,a.useState)(!1),[eA,eD]=(0,a.useState)([]),[eB,eI]=(0,a.useState)(null),[e$,eF]=(0,a.useState)(""),[eE,eq]=(0,a.useState)(!1),[eO,eV]=(0,a.useState)(!1),{enabled:eK,setEnabled:eR}=(0,O.useNotificationSound)(),eU=W.startsWith("/session/")?W.split("/session/")[1]:null,eW="/session",eH=G.some(e=>e.isStreaming),eJ=async()=>{let e=await (0,F.getConfig)();ea(e),eo(e.defaultModel),em(e.defaultToolApprovals)},eG=async()=>{try{let e=await (0,B.getApiKeys)();eD(e.providers)}catch(e){console.error("Failed to load API keys:",e)}};(0,a.useEffect)(()=>{eJ(),eG()},[]),(0,a.useEffect)(()=>{ee&&eG()},[ee]);let eX=async e=>{if(e$.trim()){eV(!0);try{await (0,B.setApiKey)(e,e$),await eG(),eI(null),eF(""),eq(!1)}catch(e){console.error("Failed to save API key:",e)}finally{eV(!1)}}},eY=()=>{eI(null),eF(""),eq(!1)};(0,a.useEffect)(()=>{el.current&&(eH?el.current.play().catch(()=>{}):(el.current.pause(),el.current.currentTime=0))},[eH]);let e_=async()=>{if(!Y){_(!0);try{let e=await (0,B.createSession)({name:`Session ${G.length+1}`,model:et?.defaultModel||"gpt-5.5",toolApprovals:ex});(0,q.mutateSessions)(),U.push(`${eW}/${e.id}`)}catch(e){console.error("Failed to create session:",e)}finally{_(!1)}}},eQ=async()=>{_(!0);try{let e=await (0,B.createSession)({name:en||`Session ${G.length+1}`,model:ec,toolApprovals:ex});(0,q.mutateSessions)(),eZ(),Z(!1),U.push(`${eW}/${e.id}`)}catch(e){console.error("Failed to create session:",e)}finally{_(!1)}},eZ=()=>{ed(""),et&&(eo(et.defaultModel),em(et.defaultToolApprovals))},e0=()=>{ej(""),eN(eg),eb(""),ek(""),eT(""),ew(et?.defaultModel||""),eM("50")},e1=async()=>{if(ep.trim()){if(eb(""),!ef||"object"!=typeof ef)return void eb("Schema must be a JSON object");eL(!0);try{let e=await (0,B.createTask)({prompt:ep,outputSchema:ef,webhookUrl:ey||void 0,model:eC||et?.defaultModel,name:eS||void 0,maxIterations:parseInt(ez)||50});(0,q.mutateSessions)(),eu(!1),e0(),U.push(`${eW}/${e.taskId}`)}catch(e){console.error("Failed to create task:",e)}finally{eL(!1)}}},e5=async(e,s)=>{e.preventDefault(),e.stopPropagation();try{await (0,B.deleteSession)(s),(0,q.mutateSessions)(),eU===s&&U.push("/")}catch(e){console.error("Failed to delete session:",e)}},e2=e=>{em(s=>({...s,[e]:!s[e]}))},e4="collapsed"===H;return(0,s.jsxs)(t.Sidebar,{collapsible:"icon",className:"border-r border-border/50",children:[(0,s.jsxs)(t.SidebarHeader,{className:(0,E.cn)(e4?"p-2 space-y-2":"p-3 space-y-3"),children:[!e4&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("div",{className:"relative shrink-0 overflow-hidden rounded-xl size-10 shadow-md ring-1 ring-white/10",children:[(0,s.jsx)(l.default,{src:"/sparke-coder.png",alt:"Sparke",width:40,height:40,className:"absolute inset-0 size-full object-cover",priority:!0}),(0,s.jsx)("video",{ref:el,src:"/sparkecode.mp4",muted:!0,loop:!0,playsInline:!0,className:(0,E.cn)("absolute inset-0 size-full object-cover transition-opacity duration-300",eH?"opacity-100":"opacity-0")})]}),(0,s.jsxs)("div",{className:"flex flex-1 items-center justify-between min-w-0",children:[(0,s.jsx)("h1",{className:"text-lg font-bold text-foreground",children:"SparkECoder"}),(0,s.jsx)(D.TooltipProvider,{children:(0,s.jsxs)(D.Tooltip,{children:[(0,s.jsx)(D.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(w.Button,{size:"icon",variant:"ghost",className:"size-7 hover:bg-accent transition-colors",onClick:J,children:(0,s.jsx)(h,{className:"size-4"})})}),(0,s.jsxs)(D.TooltipContent,{side:"bottom",children:["Collapse ",(0,s.jsx)("kbd",{className:"ml-1 text-[10px] opacity-60",children:"⌘B"})]})]})})]})]}),(e=G.find(e=>"orchestrator"===e.role),V=(m=G.filter(e=>"worker"===e.role)).filter(e=>"needs_attention"===e.agentStatus).length,K=m.filter(e=>"running"===e.agentStatus).length,(0,s.jsxs)("div",{className:"flex flex-col gap-1 w-full",children:[(0,s.jsxs)(r.default,{href:e?`/session/${e.id}`:"#",className:(0,E.cn)("flex items-center gap-2 px-2 py-1.5 rounded-md text-sm transition-colors",W.startsWith("/session/")&&e&&W.includes(e.id)?"bg-accent text-foreground":"hover:bg-accent/60 text-foreground/80"),children:[(0,s.jsx)(k.Bot,{className:"size-4 text-primary shrink-0"}),(0,s.jsx)("span",{className:"flex-1 truncate",children:"Orchestrator"}),e?.isStreaming&&(0,s.jsx)("span",{className:"size-1.5 rounded-full bg-emerald-500 animate-pulse"})]}),(0,s.jsxs)(r.default,{href:"/agents",className:(0,E.cn)("flex items-center gap-2 px-2 py-1.5 rounded-md text-sm transition-colors","/agents"===W?"bg-accent text-foreground":"hover:bg-accent/60 text-foreground/80"),children:[(0,s.jsx)(S,{className:"size-4 text-muted-foreground shrink-0"}),(0,s.jsx)("span",{className:"flex-1 truncate",children:"Agents"}),(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:m.length}),V>0&&(0,s.jsxs)("span",{className:"text-[10px] px-1 rounded bg-amber-500/20 text-amber-600 dark:text-amber-300 tabular-nums",children:[V,"!"]}),K>0&&0===V&&(0,s.jsx)("span",{className:"size-1.5 rounded-full bg-emerald-500 animate-pulse"})]}),(0,s.jsxs)(r.default,{href:"/settings",className:(0,E.cn)("flex items-center gap-2 px-2 py-1.5 rounded-md text-sm transition-colors","/settings"===W?"bg-accent text-foreground":"hover:bg-accent/60 text-foreground/80"),children:[(0,s.jsx)(T,{className:"size-4 text-muted-foreground shrink-0"}),(0,s.jsx)("span",{className:"flex-1 truncate",children:"Settings"})]})]})),(0,s.jsxs)("div",{className:"flex gap-2 w-full",children:[(0,s.jsxs)(w.Button,{onClick:e_,disabled:Y,className:"flex-1 justify-center gap-2 h-9",children:[Y?(0,s.jsx)(o.Loader2,{className:"size-4 animate-spin"}):(0,s.jsx)(n.Plus,{className:"size-4"}),"New Agent"]}),(0,s.jsx)(D.TooltipProvider,{children:(0,s.jsxs)(D.Tooltip,{children:[(0,s.jsx)(D.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(w.Button,{variant:"outline",onClick:()=>{et||eJ(),eu(!0)},className:"h-9 px-2.5",children:(0,s.jsx)(b.ListChecks,{className:"size-4"})})}),(0,s.jsx)(D.TooltipContent,{side:"bottom",children:"New Task"})]})})]})]}),e4&&(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 w-full",children:[(0,s.jsx)(D.TooltipProvider,{children:(0,s.jsxs)(D.Tooltip,{children:[(0,s.jsx)(D.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(w.Button,{size:"icon",variant:"ghost",onClick:J,className:"size-8 mx-auto",children:(0,s.jsx)(u.PanelLeft,{className:"size-4"})})}),(0,s.jsxs)(D.TooltipContent,{side:"right",children:["Expand ",(0,s.jsx)("kbd",{className:"ml-1 text-[10px] opacity-60",children:"⌘B"})]})]})}),(0,s.jsxs)("div",{className:"relative overflow-hidden rounded-xl size-8 shadow-md ring-1 ring-white/10 mx-auto",children:[(0,s.jsx)(l.default,{src:"/sparke-coder.png",alt:"SparkECoder",width:32,height:32,className:"absolute inset-0 size-full object-cover",priority:!0}),(0,s.jsx)("video",{ref:el,src:"/sparkecode.mp4",muted:!0,loop:!0,playsInline:!0,className:(0,E.cn)("absolute inset-0 size-full object-cover transition-opacity duration-300",eH?"opacity-100":"opacity-0")})]}),(0,s.jsx)(D.TooltipProvider,{children:(0,s.jsxs)(D.Tooltip,{children:[(0,s.jsx)(D.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(w.Button,{size:"icon",onClick:e_,disabled:Y,className:"size-8 mx-auto",children:Y?(0,s.jsx)(o.Loader2,{className:"size-4 animate-spin"}):(0,s.jsx)(n.Plus,{className:"size-4"})})}),(0,s.jsx)(D.TooltipContent,{side:"right",children:"New Agent"})]})}),(R=G.find(e=>"orchestrator"===e.role),(0,s.jsx)(D.TooltipProvider,{children:(0,s.jsxs)(D.Tooltip,{children:[(0,s.jsx)(D.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.default,{href:R?`/session/${R.id}`:"#",className:"size-8 mx-auto inline-flex items-center justify-center rounded-md hover:bg-accent",children:(0,s.jsx)(k.Bot,{className:"size-4 text-primary"})})}),(0,s.jsx)(D.TooltipContent,{side:"right",children:"Orchestrator"})]})})),(0,s.jsx)(D.TooltipProvider,{children:(0,s.jsxs)(D.Tooltip,{children:[(0,s.jsx)(D.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.default,{href:"/agents",className:"size-8 mx-auto inline-flex items-center justify-center rounded-md hover:bg-accent",children:(0,s.jsx)(S,{className:"size-4"})})}),(0,s.jsx)(D.TooltipContent,{side:"right",children:"Agents board"})]})}),(0,s.jsx)(D.TooltipProvider,{children:(0,s.jsxs)(D.Tooltip,{children:[(0,s.jsx)(D.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.default,{href:"/settings",className:"size-8 mx-auto inline-flex items-center justify-center rounded-md hover:bg-accent",children:(0,s.jsx)(T,{className:"size-4"})})}),(0,s.jsx)(D.TooltipContent,{side:"right",children:"Settings"})]})}),(0,s.jsx)(D.TooltipProvider,{children:(0,s.jsxs)(D.Tooltip,{children:[(0,s.jsx)(D.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(w.Button,{size:"icon",variant:"outline",onClick:()=>{et||eJ(),eu(!0)},className:"size-8 mx-auto",children:(0,s.jsx)(b.ListChecks,{className:"size-4"})})}),(0,s.jsx)(D.TooltipContent,{side:"right",children:"New Task"})]})})]})]}),(0,s.jsx)(z.Dialog,{open:Q,onOpenChange:e=>{Z(e),e&&eZ()},children:(0,s.jsxs)(z.DialogContent,{className:"sm:max-w-md",children:[(0,s.jsx)(z.DialogHeader,{children:(0,s.jsxs)(z.DialogTitle,{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"size-8 rounded-lg bg-primary flex items-center justify-center",children:(0,s.jsx)(x.Settings,{className:"size-4 text-primary-foreground"})}),"New Agent"]})}),(0,s.jsxs)("div",{className:"space-y-4 pt-2",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(P.Label,{htmlFor:"name",className:"text-sm font-medium",children:"Session Name"}),(0,s.jsx)(M.Input,{id:"name",placeholder:"My Coding Project (optional)",value:en,onChange:e=>ed(e.target.value),className:"transition-all focus:ring-2 focus:ring-primary/20"})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(P.Label,{className:"text-sm font-medium",children:"Model"}),(0,s.jsxs)(A.Select,{value:ec,onValueChange:eo,children:[(0,s.jsx)(A.SelectTrigger,{className:"transition-all hover:border-primary/50",children:(0,s.jsx)(A.SelectValue,{placeholder:"Select a model"})}),(0,s.jsx)(A.SelectContent,{children:et?.availableModels.map(e=>(0,s.jsx)(A.SelectItem,{value:e.id,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{children:e.name}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:e.provider})]})},e.id))})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(P.Label,{className:"flex items-center gap-2 text-sm font-medium",children:"Tool Approvals"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground -mt-0.5",children:"Toggle on to require approval before tool executes"}),(0,s.jsx)("div",{className:"space-y-1 rounded-lg border p-2.5 bg-muted/30",children:et?.availableTools.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between py-1.5 hover:bg-muted/50 rounded px-2 -mx-1 transition-colors",children:[(0,s.jsxs)("div",{className:"space-y-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium",children:e.name}),e.dangerous&&(0,s.jsx)("span",{className:"text-[10px] bg-amber-500/20 text-amber-600 dark:text-amber-400 px-1.5 py-0.5 rounded font-medium",children:"risky"})]}),(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:e.description})]}),(0,s.jsx)(L.Switch,{checked:ex[e.id]??!1,onCheckedChange:()=>e2(e.id)})]},e.id))})]}),(0,s.jsxs)(w.Button,{onClick:eQ,disabled:Y,className:"w-full",children:[Y?(0,s.jsx)(o.Loader2,{className:"size-4 animate-spin mr-2"}):(0,s.jsx)(n.Plus,{className:"size-4 mr-2"}),"Create Session"]})]})]})}),(0,s.jsx)(z.Dialog,{open:eh,onOpenChange:e=>{eu(e),e&&e0()},children:(0,s.jsxs)(z.DialogContent,{className:"sm:max-w-lg",children:[(0,s.jsx)(z.DialogHeader,{children:(0,s.jsxs)(z.DialogTitle,{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"size-8 rounded-lg bg-blue-600 flex items-center justify-center",children:(0,s.jsx)(b.ListChecks,{className:"size-4 text-white"})}),"New Task"]})}),(0,s.jsxs)("div",{className:"space-y-4 pt-2",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(P.Label,{htmlFor:"task-prompt",className:"text-sm font-medium",children:"What should the agent do?"}),(0,s.jsx)(I.Textarea,{id:"task-prompt",placeholder:"e.g. Refactor the auth module to use JWT tokens...",value:ep,onChange:e=>ej(e.target.value),rows:3,autoFocus:!0})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(P.Label,{className:"text-sm font-medium",children:"Expected output shape"}),(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground -mt-0.5",children:"Define the JSON structure the agent must return"}),(0,s.jsx)("div",{className:(0,E.cn)("rounded-md border bg-muted/30 overflow-hidden transition-colors",ev&&"border-red-500"),children:(0,s.jsx)($.VisualJson,{value:ef,onChange:e=>{eN(e),eb("")},children:(0,s.jsx)($.TreeView,{className:"h-44 text-sm"})})}),ev&&(0,s.jsx)("p",{className:"text-xs text-red-500 mt-1",children:ev})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(P.Label,{className:"text-xs text-muted-foreground",children:"Model"}),(0,s.jsxs)(A.Select,{value:eC,onValueChange:ew,children:[(0,s.jsx)(A.SelectTrigger,{className:"h-9",children:(0,s.jsx)(A.SelectValue,{placeholder:"Select a model"})}),(0,s.jsx)(A.SelectContent,{children:et?.availableModels.map(e=>(0,s.jsx)(A.SelectItem,{value:e.id,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{children:e.name}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:e.provider})]})},e.id))})]})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(P.Label,{htmlFor:"task-name",className:"text-xs text-muted-foreground",children:"Name"}),(0,s.jsx)(M.Input,{id:"task-name",placeholder:"Optional",value:eS,onChange:e=>eT(e.target.value),className:"h-9"})]})]}),(0,s.jsxs)("details",{className:"group",children:[(0,s.jsxs)("summary",{className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer select-none hover:text-foreground transition-colors",children:[(0,s.jsx)(y.ChevronDown,{className:"size-3 transition-transform group-open:rotate-180"}),"Advanced"]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3 pt-3",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(P.Label,{htmlFor:"task-webhook",className:"text-xs text-muted-foreground",children:"Webhook URL"}),(0,s.jsx)(M.Input,{id:"task-webhook",placeholder:"https://...",value:ey,onChange:e=>ek(e.target.value),className:"h-9"})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(P.Label,{htmlFor:"task-iterations",className:"text-xs text-muted-foreground",children:"Max iterations"}),(0,s.jsx)(M.Input,{id:"task-iterations",type:"number",min:1,max:500,value:ez,onChange:e=>eM(e.target.value),className:"h-9"})]})]})]}),(0,s.jsx)(w.Button,{onClick:e1,disabled:eP||!ep.trim(),className:"w-full",children:eP?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Loader2,{className:"size-4 animate-spin mr-2"}),"Creating..."]}):"Start Task"})]})]})}),(0,s.jsx)(t.SidebarContent,{className:"px-2",children:(0,s.jsx)(t.SidebarGroup,{className:"p-0",children:(0,s.jsx)(t.SidebarGroupContent,{children:(0,s.jsx)(t.SidebarMenu,{className:"gap-1",children:X?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(o.Loader2,{className:"size-5 animate-spin text-muted-foreground"})}):0===G.filter(e=>"orchestrator"!==e.role).length?!e4&&(0,s.jsxs)("div",{className:"text-center py-8 px-4",children:[(0,s.jsxs)("div",{className:"relative overflow-hidden rounded-xl size-12 mx-auto mb-3 shadow-md ring-1 ring-white/10",children:[(0,s.jsx)(l.default,{src:"/sparke-coder.png",alt:"SparkECoder",width:48,height:48,className:"absolute inset-0 size-full object-cover"}),eH&&(0,s.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})]}),(0,s.jsx)("p",{className:"text-sm text-foreground",children:"No sessions yet"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Click New Agent above"})]}):G.filter(e=>"orchestrator"!==e.role).map(e=>{let a,i,l,n,o=e.id===eU,x=ei===e.id,m=!0===e.isStreaming,h=!e4&&(x||o);return(0,s.jsx)(t.SidebarMenuItem,{onMouseEnter:()=>er(e.id),onMouseLeave:()=>er(null),children:e4?(0,s.jsx)(D.TooltipProvider,{children:(0,s.jsxs)(D.Tooltip,{children:[(0,s.jsx)(D.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.default,{href:`${eW}/${e.id}`,className:(0,E.cn)("flex items-center justify-center size-8 rounded-lg transition-colors mx-auto",o?"bg-accent":"hover:bg-accent/60",m&&!o&&"bg-emerald-500/10"),children:m?(0,s.jsx)("span",{className:"size-2 rounded-full bg-emerald-500 animate-pulse"}):(0,s.jsx)(d.MessageSquare,{className:(0,E.cn)("size-4",o?"text-primary":"text-muted-foreground")})})}),(0,s.jsxs)(D.TooltipContent,{side:"right",children:[e.name||"Untitled",m&&" (Running)"]})]})}):(0,s.jsx)(t.SidebarMenuButton,{asChild:!0,isActive:o,className:(0,E.cn)("h-9 transition-all duration-150","hover:bg-accent/60",o&&"bg-accent",m&&!o&&"bg-emerald-500/5"),children:(0,s.jsxs)(r.default,{href:`${eW}/${e.id}`,className:"flex items-center gap-2.5 px-2",children:[m?(0,s.jsx)("span",{className:"size-2 rounded-full bg-emerald-500 animate-pulse shrink-0"}):(0,s.jsx)(d.MessageSquare,{className:(0,E.cn)("size-4 shrink-0",o?"text-primary":"text-muted-foreground")}),(0,s.jsx)("span",{className:(0,E.cn)("truncate flex-1 text-sm",m&&"text-emerald-600 dark:text-emerald-400"),children:e.name||"Untitled"}),e.config?.task?.enabled&&(0,s.jsxs)(C.Badge,{variant:"outline",className:(0,E.cn)("shrink-0 text-[10px] px-1.5 py-0 h-4 font-medium gap-1","completed"===e.config.task.status&&"border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400","failed"===e.config.task.status&&"border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-400","running"===e.config.task.status&&"border-blue-500/30 bg-blue-500/10 text-blue-600 dark:text-blue-400"),children:[(0,s.jsx)(b.ListChecks,{className:"size-2.5"}),"Task"]}),h?(0,s.jsx)(D.TooltipProvider,{children:(0,s.jsxs)(D.Tooltip,{children:[(0,s.jsx)(D.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(w.Button,{size:"icon",variant:"ghost",className:"size-6 shrink-0 hover:bg-destructive/10 hover:text-destructive transition-colors",onClick:s=>e5(s,e.id),children:(0,s.jsx)(c.Trash2,{className:"size-3.5"})})}),(0,s.jsx)(D.TooltipContent,{side:"right",children:"Delete session"})]})}):m&&!e.config?.task?.enabled?(0,s.jsx)("span",{className:"inline-flex items-center gap-1 text-[10px] text-emerald-600 dark:text-emerald-400 shrink-0 font-medium",children:"Active"}):"waiting"===e.status?(0,s.jsx)("span",{className:"text-[10px] text-amber-600 dark:text-amber-400 shrink-0 font-medium",children:"Waiting"}):"error"===e.status?(0,s.jsx)("span",{className:"text-[10px] text-red-600 dark:text-red-400 shrink-0 font-medium",children:"Error"}):(0,s.jsx)("span",{className:"text-[11px] text-muted-foreground shrink-0 tabular-nums",children:(a=new Date(e.createdAt),n=Math.floor((l=Math.floor((i=Math.floor(Math.floor((new Date().getTime()-a.getTime())/1e3)/60))/60))/24),i<1?"now":i<60?`${i}m`:l<24?`${l}h`:n<7?`${n}d`:`${Math.floor(n/7)}w`)})]})})},e.id)})})})})}),(0,s.jsx)(t.SidebarFooter,{className:(0,E.cn)("border-t border-border/50",e4?"p-2":"p-3"),children:(0,s.jsx)("div",{className:"flex items-center justify-between",children:e4?(0,s.jsx)("div",{className:"flex flex-col items-center gap-2 w-full",children:(0,s.jsx)(D.TooltipProvider,{children:(0,s.jsxs)(D.Tooltip,{children:[(0,s.jsx)(D.TooltipTrigger,{asChild:!0,children:(0,s.jsx)("div",{className:"flex items-center justify-center",children:(0,s.jsx)("span",{className:(0,E.cn)("size-2 rounded-full",et?.serverConnected?"bg-emerald-500 animate-pulse":"bg-red-500")})})}),(0,s.jsx)(D.TooltipContent,{side:"right",children:et?.serverConnected?"Connected":"Disconnected"})]})})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[et?.serverConnected?(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-emerald-600 dark:text-emerald-400",children:[(0,s.jsx)("span",{className:"size-1.5 rounded-full bg-current animate-pulse"}),(0,s.jsx)("span",{children:"Connected"})]}):(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-red-500",children:[(0,s.jsx)("span",{className:"size-1.5 rounded-full bg-current"}),(0,s.jsx)("span",{children:"Disconnected"})]}),(0,s.jsx)("span",{className:"text-muted-foreground",children:"·"}),(0,s.jsx)("span",{className:"text-muted-foreground",children:G.length})]}),(0,s.jsx)(z.Dialog,{open:!1,onOpenChange:es,children:(0,s.jsxs)(z.DialogContent,{className:"sm:max-w-md",children:[(0,s.jsx)(z.DialogHeader,{children:(0,s.jsxs)(z.DialogTitle,{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"size-8 rounded-lg bg-muted flex items-center justify-center",children:(0,s.jsx)(x.Settings,{className:"size-4"})}),"Settings"]})}),(0,s.jsxs)("div",{className:"space-y-4 pt-2",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(P.Label,{className:"text-sm font-medium",children:"Default Model"}),(0,s.jsxs)(A.Select,{value:ec,onValueChange:eo,children:[(0,s.jsx)(A.SelectTrigger,{className:"transition-all hover:border-primary/50",children:(0,s.jsx)(A.SelectValue,{placeholder:"Select a model"})}),(0,s.jsx)(A.SelectContent,{children:et?.availableModels.map(e=>(0,s.jsx)(A.SelectItem,{value:e.id,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{children:e.name}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:e.provider})]})},e.id))})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(P.Label,{className:"flex items-center gap-2 text-sm font-medium",children:"Tool Approvals"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground -mt-0.5",children:"Toggle on to require approval before tool executes"}),(0,s.jsx)("div",{className:"space-y-1 rounded-lg border p-2.5 bg-muted/30",children:et?.availableTools.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between py-1.5 hover:bg-muted/50 rounded px-2 -mx-1 transition-colors",children:[(0,s.jsxs)("div",{className:"space-y-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium",children:e.name}),e.dangerous&&(0,s.jsx)("span",{className:"text-[10px] bg-amber-500/20 text-amber-600 dark:text-amber-400 px-1.5 py-0.5 rounded font-medium",children:"risky"})]}),(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:e.description})]}),(0,s.jsx)(L.Switch,{checked:ex[e.id]??!1,onCheckedChange:()=>e2(e.id)})]},e.id))})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)(P.Label,{className:"flex items-center gap-2 text-sm font-medium",children:[(0,s.jsx)(p.Key,{className:"size-4"}),"API Keys"]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground -mt-0.5",children:"Configure API keys for different providers. Keys are stored securely on your machine."}),(0,s.jsx)("div",{className:"space-y-1 rounded-lg border p-2.5 bg-muted/30",children:eA.map(e=>(0,s.jsx)("div",{className:"py-1.5 hover:bg-muted/50 rounded px-2 -mx-1 transition-colors",children:eB===e.provider?(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-sm font-medium capitalize",children:e.provider}),(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono",children:e.envVar})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsx)(M.Input,{type:eE?"text":"password",value:e$,onChange:e=>eF(e.target.value),placeholder:"Paste your API key...",className:"pr-8 text-sm font-mono",autoFocus:!0}),(0,s.jsx)(w.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-2 hover:bg-transparent",onClick:()=>eq(!eE),children:eE?(0,s.jsx)(N.EyeOff,{className:"size-4"}):(0,s.jsx)(f.Eye,{className:"size-4"})})]}),(0,s.jsx)(w.Button,{size:"icon",variant:"ghost",className:"shrink-0",onClick:()=>eX(e.provider),disabled:eO||!e$.trim(),children:eO?(0,s.jsx)(o.Loader2,{className:"size-4 animate-spin"}):(0,s.jsx)(j.Check,{className:"size-4 text-green-500"})}),(0,s.jsx)(w.Button,{size:"icon",variant:"ghost",className:"shrink-0",onClick:eY,children:(0,s.jsx)(g.X,{className:"size-4 text-muted-foreground"})})]})]}):(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"space-y-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium capitalize",children:e.provider}),e.configured&&(0,s.jsx)("span",{className:(0,E.cn)("text-[10px] px-1.5 py-0.5 rounded font-medium","env"===e.source?"bg-blue-500/20 text-blue-600 dark:text-blue-400":"bg-green-500/20 text-green-600 dark:text-green-400"),children:"env"===e.source?"from env":"saved"})]}),(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground font-mono",children:e.configured?e.maskedKey:"Not configured"})]}),(0,s.jsx)(w.Button,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>eI(e.provider),children:e.configured?"Update":"Add"})]})},e.provider))})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsxs)(P.Label,{className:"flex items-center gap-2 text-sm font-medium",children:[(0,s.jsx)(v,{className:"size-4"}),"Notification Sound"]}),(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-lg border p-2.5 bg-muted/30",children:[(0,s.jsxs)("div",{className:"space-y-0",children:[(0,s.jsx)("span",{className:"text-sm font-medium",children:"Play sound when done"}),(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Ding when the assistant finishes responding"})]}),(0,s.jsx)(L.Switch,{checked:eK,onCheckedChange:eR})]})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"These settings apply to new sessions. You can also change the model per-session in the chat header."})]})]})})]})})})]})}function K({children:e}){return(0,s.jsxs)(t.SidebarProvider,{defaultOpen:!0,children:[(0,s.jsx)(V,{}),(0,s.jsx)(t.SidebarInset,{className:"h-screen flex flex-col bg-background min-w-0",children:(0,s.jsx)("div",{className:"flex-1 overflow-hidden min-w-0",children:e})})]})}e.s(["default",()=>K],138134)}]);
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,77589,e=>{"use strict";let t=(0,e.i(292511).default)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);e.s(["default",()=>t])},416667,e=>{"use strict";let t=(0,e.i(292511).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(["default",()=>t])},191729,772857,e=>{"use strict";let t=(0,e.i(292511).default)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);e.s(["default",()=>t],191729);var r=e.i(414294),l=e.i(430878);e.i(773340);var n=e.i(309945),o=Symbol("radix.slottable");function s(e){return l.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===o}var a=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{var o,a;let i,d,c,u=(a=o=`Primitive.${t}`,(i=l.forwardRef((e,t)=>{let{children:r,...o}=e;if(l.isValidElement(r)){var s;let e,a,i=(s=r,(a=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(a=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),d=function(e,t){let r={...t};for(let l in t){let n=e[l],o=t[l];/^on[A-Z]/.test(l)?n&&o?r[l]=(...e)=>{let t=o(...e);return n(...e),t}:n&&(r[l]=n):"style"===l?r[l]={...n,...o}:"className"===l&&(r[l]=[n,o].filter(Boolean).join(" "))}return{...e,...r}}(o,r.props);return r.type!==l.Fragment&&(d.ref=t?(0,n.composeRefs)(t,i):i),l.cloneElement(r,d)}return l.Children.count(r)>1?l.Children.only(null):null})).displayName=`${a}.SlotClone`,d=i,(c=l.forwardRef((e,t)=>{let{children:n,...o}=e,a=l.Children.toArray(n),i=a.find(s);if(i){let e=i.props.children,n=a.map(t=>t!==i?t:l.Children.count(e)>1?l.Children.only(null):l.isValidElement(e)?e.props.children:null);return(0,r.jsx)(d,{...o,ref:t,children:l.isValidElement(e)?l.cloneElement(e,void 0,n):null})}return(0,r.jsx)(d,{...o,ref:t,children:n})})).displayName=`${o}.Slot`,c),p=l.forwardRef((e,l)=>{let{asChild:n,...o}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,r.jsx)(n?u:t,{...o,ref:l})});return p.displayName=`Primitive.${t}`,{...e,[t]:p}},{}),i=e.i(395509),d=e.i(897462),c=e.i(542899),u=e.i(995945),p=e.i(992421),m=e.i(241416),f="ScrollArea",[h,x]=function(e,t=[]){let n=[],o=()=>{let t=n.map(e=>l.createContext(e));return function(r){let n=r?.[e]||t;return l.useMemo(()=>({[`__scope${e}`]:{...r,[e]:n}}),[r,n])}};return o.scopeName=e,[function(t,o){let s=l.createContext(o),a=n.length;n=[...n,o];let i=t=>{let{scope:n,children:o,...i}=t,d=n?.[e]?.[a]||s,c=l.useMemo(()=>i,Object.values(i));return(0,r.jsx)(d.Provider,{value:c,children:o})};return i.displayName=t+"Provider",[i,function(r,n){let i=n?.[e]?.[a]||s,d=l.useContext(i);if(d)return d;if(void 0!==o)return o;throw Error(`\`${r}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let r=()=>{let r=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let n=r.reduce((t,{useScope:r,scopeName:l})=>{let n=r(e)[`__scope${l}`];return{...t,...n}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:n}),[n])}};return r.scopeName=t.scopeName,r}(o,...t)]}(f),[g,v]=h(f),b=l.forwardRef((e,t)=>{let{__scopeScrollArea:o,type:s="hover",dir:i,scrollHideDelay:d=600,...u}=e,[p,m]=l.useState(null),[f,h]=l.useState(null),[x,v]=l.useState(null),[b,w]=l.useState(null),[y,j]=l.useState(null),[S,N]=l.useState(0),[C,E]=l.useState(0),[R,k]=l.useState(!1),[T,P]=l.useState(!1),A=(0,n.useComposedRefs)(t,e=>m(e)),L=(0,c.useDirection)(i);return(0,r.jsx)(g,{scope:o,type:s,dir:L,scrollHideDelay:d,scrollArea:p,viewport:f,onViewportChange:h,content:x,onContentChange:v,scrollbarX:b,onScrollbarXChange:w,scrollbarXEnabled:R,onScrollbarXEnabledChange:k,scrollbarY:y,onScrollbarYChange:j,scrollbarYEnabled:T,onScrollbarYEnabledChange:P,onCornerWidthChange:N,onCornerHeightChange:E,children:(0,r.jsx)(a.div,{dir:L,...u,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":S+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});b.displayName=f;var w="ScrollAreaViewport",y=l.forwardRef((e,t)=>{let{__scopeScrollArea:o,children:s,nonce:i,...d}=e,c=v(w,o),u=l.useRef(null),p=(0,n.useComposedRefs)(t,u,c.onViewportChange);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),(0,r.jsx)(a.div,{"data-radix-scroll-area-viewport":"",...d,ref:p,style:{overflowX:c.scrollbarXEnabled?"scroll":"hidden",overflowY:c.scrollbarYEnabled?"scroll":"hidden",...e.style},children:(0,r.jsx)("div",{ref:c.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});y.displayName=w;var j="ScrollAreaScrollbar",S=l.forwardRef((e,t)=>{let{forceMount:n,...o}=e,s=v(j,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=s,d="horizontal"===e.orientation;return l.useEffect(()=>(d?a(!0):i(!0),()=>{d?a(!1):i(!1)}),[d,a,i]),"hover"===s.type?(0,r.jsx)(N,{...o,ref:t,forceMount:n}):"scroll"===s.type?(0,r.jsx)(C,{...o,ref:t,forceMount:n}):"auto"===s.type?(0,r.jsx)(E,{...o,ref:t,forceMount:n}):"always"===s.type?(0,r.jsx)(R,{...o,ref:t}):null});S.displayName=j;var N=l.forwardRef((e,t)=>{let{forceMount:n,...o}=e,s=v(j,e.__scopeScrollArea),[a,d]=l.useState(!1);return l.useEffect(()=>{let e=s.scrollArea,t=0;if(e){let r=()=>{window.clearTimeout(t),d(!0)},l=()=>{t=window.setTimeout(()=>d(!1),s.scrollHideDelay)};return e.addEventListener("pointerenter",r),e.addEventListener("pointerleave",l),()=>{window.clearTimeout(t),e.removeEventListener("pointerenter",r),e.removeEventListener("pointerleave",l)}}},[s.scrollArea,s.scrollHideDelay]),(0,r.jsx)(i.Presence,{present:n||a,children:(0,r.jsx)(E,{"data-state":a?"visible":"hidden",...o,ref:t})})}),C=l.forwardRef((e,t)=>{var n;let{forceMount:o,...s}=e,a=v(j,e.__scopeScrollArea),d="horizontal"===e.orientation,c=V(()=>p("SCROLL_END"),100),[u,p]=(n={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},l.useReducer((e,t)=>n[e][t]??e,"hidden"));return l.useEffect(()=>{if("idle"===u){let e=window.setTimeout(()=>p("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(e)}},[u,a.scrollHideDelay,p]),l.useEffect(()=>{let e=a.viewport,t=d?"scrollLeft":"scrollTop";if(e){let r=e[t],l=()=>{let l=e[t];r!==l&&(p("SCROLL"),c()),r=l};return e.addEventListener("scroll",l),()=>e.removeEventListener("scroll",l)}},[a.viewport,d,p,c]),(0,r.jsx)(i.Presence,{present:o||"hidden"!==u,children:(0,r.jsx)(R,{"data-state":"hidden"===u?"hidden":"visible",...s,ref:t,onPointerEnter:(0,m.composeEventHandlers)(e.onPointerEnter,()=>p("POINTER_ENTER")),onPointerLeave:(0,m.composeEventHandlers)(e.onPointerLeave,()=>p("POINTER_LEAVE"))})})}),E=l.forwardRef((e,t)=>{let n=v(j,e.__scopeScrollArea),{forceMount:o,...s}=e,[a,d]=l.useState(!1),c="horizontal"===e.orientation,u=V(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;d(c?e:t)}},10);return Y(n.viewport,u),Y(n.content,u),(0,r.jsx)(i.Presence,{present:o||a,children:(0,r.jsx)(R,{"data-state":a?"visible":"hidden",...s,ref:t})})}),R=l.forwardRef((e,t)=>{let{orientation:n="vertical",...o}=e,s=v(j,e.__scopeScrollArea),a=l.useRef(null),i=l.useRef(0),[d,c]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=$(d.viewport,d.content),p={...o,sizes:d,onSizesChange:c,hasThumb:!!(u>0&&u<1),onThumbChange:e=>a.current=e,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:e=>i.current=e};function m(e,t){return function(e,t,r,l="ltr"){let n=O(r),o=t||n/2,s=r.scrollbar.paddingStart+o,a=r.scrollbar.size-r.scrollbar.paddingEnd-(n-o),i=r.content-r.viewport;return U([s,a],"ltr"===l?[0,i]:[-1*i,0])(e)}(e,i.current,d,t)}return"horizontal"===n?(0,r.jsx)(k,{...p,ref:t,onThumbPositionChange:()=>{if(s.viewport&&a.current){let e=F(s.viewport.scrollLeft,d,s.dir);a.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{s.viewport&&(s.viewport.scrollLeft=e)},onDragScroll:e=>{s.viewport&&(s.viewport.scrollLeft=m(e,s.dir))}}):"vertical"===n?(0,r.jsx)(T,{...p,ref:t,onThumbPositionChange:()=>{if(s.viewport&&a.current){let e=F(s.viewport.scrollTop,d);a.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{s.viewport&&(s.viewport.scrollTop=e)},onDragScroll:e=>{s.viewport&&(s.viewport.scrollTop=m(e))}}):null}),k=l.forwardRef((e,t)=>{let{sizes:o,onSizesChange:s,...a}=e,i=v(j,e.__scopeScrollArea),[d,c]=l.useState(),u=l.useRef(null),p=(0,n.useComposedRefs)(t,u,i.onScrollbarXChange);return l.useEffect(()=>{u.current&&c(getComputedStyle(u.current))},[u]),(0,r.jsx)(L,{"data-orientation":"horizontal",...a,ref:p,sizes:o,style:{bottom:0,left:"rtl"===i.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===i.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":O(o)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,r)=>{if(i.viewport){var l,n;let o=i.viewport.scrollLeft+t.deltaX;e.onWheelScroll(o),l=o,n=r,l>0&&l<n&&t.preventDefault()}},onResize:()=>{u.current&&i.viewport&&d&&s({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:u.current.clientWidth,paddingStart:W(d.paddingLeft),paddingEnd:W(d.paddingRight)}})}})}),T=l.forwardRef((e,t)=>{let{sizes:o,onSizesChange:s,...a}=e,i=v(j,e.__scopeScrollArea),[d,c]=l.useState(),u=l.useRef(null),p=(0,n.useComposedRefs)(t,u,i.onScrollbarYChange);return l.useEffect(()=>{u.current&&c(getComputedStyle(u.current))},[u]),(0,r.jsx)(L,{"data-orientation":"vertical",...a,ref:p,sizes:o,style:{top:0,right:"ltr"===i.dir?0:void 0,left:"rtl"===i.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":O(o)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,r)=>{if(i.viewport){var l,n;let o=i.viewport.scrollTop+t.deltaY;e.onWheelScroll(o),l=o,n=r,l>0&&l<n&&t.preventDefault()}},onResize:()=>{u.current&&i.viewport&&d&&s({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:u.current.clientHeight,paddingStart:W(d.paddingTop),paddingEnd:W(d.paddingBottom)}})}})}),[P,A]=h(j),L=l.forwardRef((e,t)=>{let{__scopeScrollArea:o,sizes:s,hasThumb:i,onThumbChange:c,onThumbPointerUp:u,onThumbPointerDown:p,onThumbPositionChange:f,onDragScroll:h,onWheelScroll:x,onResize:g,...b}=e,w=v(j,o),[y,S]=l.useState(null),N=(0,n.useComposedRefs)(t,e=>S(e)),C=l.useRef(null),E=l.useRef(""),R=w.viewport,k=s.content-s.viewport,T=(0,d.useCallbackRef)(x),A=(0,d.useCallbackRef)(f),L=V(g,10);function _(e){C.current&&h({x:e.clientX-C.current.left,y:e.clientY-C.current.top})}return l.useEffect(()=>{let e=e=>{let t=e.target;y?.contains(t)&&T(e,k)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[R,y,k,T]),l.useEffect(A,[s,A]),Y(y,L),Y(w.content,L),(0,r.jsx)(P,{scope:o,scrollbar:y,hasThumb:i,onThumbChange:(0,d.useCallbackRef)(c),onThumbPointerUp:(0,d.useCallbackRef)(u),onThumbPositionChange:A,onThumbPointerDown:(0,d.useCallbackRef)(p),children:(0,r.jsx)(a.div,{...b,ref:N,style:{position:"absolute",...b.style},onPointerDown:(0,m.composeEventHandlers)(e.onPointerDown,e=>{0===e.button&&(e.target.setPointerCapture(e.pointerId),C.current=y.getBoundingClientRect(),E.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",w.viewport&&(w.viewport.style.scrollBehavior="auto"),_(e))}),onPointerMove:(0,m.composeEventHandlers)(e.onPointerMove,_),onPointerUp:(0,m.composeEventHandlers)(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=E.current,w.viewport&&(w.viewport.style.scrollBehavior=""),C.current=null})})})}),_="ScrollAreaThumb",D=l.forwardRef((e,t)=>{let{forceMount:l,...n}=e,o=A(_,e.__scopeScrollArea);return(0,r.jsx)(i.Presence,{present:l||o.hasThumb,children:(0,r.jsx)(z,{ref:t,...n})})}),z=l.forwardRef((e,t)=>{let{__scopeScrollArea:o,style:s,...i}=e,d=v(_,o),c=A(_,o),{onThumbPositionChange:u}=c,p=(0,n.useComposedRefs)(t,e=>c.onThumbChange(e)),f=l.useRef(void 0),h=V(()=>{f.current&&(f.current(),f.current=void 0)},100);return l.useEffect(()=>{let e=d.viewport;if(e){let t=()=>{h(),f.current||(f.current=B(e,u),u())};return u(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}},[d.viewport,h,u]),(0,r.jsx)(a.div,{"data-state":c.hasThumb?"visible":"hidden",...i,ref:p,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:(0,m.composeEventHandlers)(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),r=e.clientX-t.left,l=e.clientY-t.top;c.onThumbPointerDown({x:r,y:l})}),onPointerUp:(0,m.composeEventHandlers)(e.onPointerUp,c.onThumbPointerUp)})});D.displayName=_;var I="ScrollAreaCorner",H=l.forwardRef((e,t)=>{let l=v(I,e.__scopeScrollArea),n=!!(l.scrollbarX&&l.scrollbarY);return"scroll"!==l.type&&n?(0,r.jsx)(M,{...e,ref:t}):null});H.displayName=I;var M=l.forwardRef((e,t)=>{let{__scopeScrollArea:n,...o}=e,s=v(I,n),[i,d]=l.useState(0),[c,u]=l.useState(0),p=!!(i&&c);return Y(s.scrollbarX,()=>{let e=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(e),u(e)}),Y(s.scrollbarY,()=>{let e=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(e),d(e)}),p?(0,r.jsx)(a.div,{...o,ref:t,style:{width:i,height:c,position:"absolute",right:"ltr"===s.dir?0:void 0,left:"rtl"===s.dir?0:void 0,bottom:0,...e.style}}):null});function W(e){return e?parseInt(e,10):0}function $(e,t){let r=e/t;return isNaN(r)?0:r}function O(e){let t=$(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd;return Math.max((e.scrollbar.size-r)*t,18)}function F(e,t,r="ltr"){let l=O(t),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,o=t.scrollbar.size-n,s=t.content-t.viewport,a=(0,p.clamp)(e,"ltr"===r?[0,s]:[-1*s,0]);return U([0,s],[0,o-l])(a)}function U(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let l=(t[1]-t[0])/(e[1]-e[0]);return t[0]+l*(r-e[0])}}var B=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},l=0;return!function n(){let o={left:e.scrollLeft,top:e.scrollTop},s=r.left!==o.left,a=r.top!==o.top;(s||a)&&t(),r=o,l=window.requestAnimationFrame(n)}(),()=>window.cancelAnimationFrame(l)};function V(e,t){let r=(0,d.useCallbackRef)(e),n=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(n.current),[]),l.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function Y(e,t){let r=(0,d.useCallbackRef)(t);(0,u.useLayoutEffect)(()=>{let t=0;if(e){let l=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(r)});return l.observe(e),()=>{window.cancelAnimationFrame(t),l.unobserve(e)}}},[e,r])}var X=e.i(555552);function K({className:e,children:t,...l}){return(0,r.jsxs)(b,{"data-slot":"scroll-area",className:(0,X.cn)("relative",e),...l,children:[(0,r.jsx)(y,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),(0,r.jsx)(q,{}),(0,r.jsx)(H,{})]})}function q({className:e,orientation:t="vertical",...l}){return(0,r.jsx)(S,{"data-slot":"scroll-area-scrollbar",orientation:t,className:(0,X.cn)("flex touch-none p-px transition-colors select-none","vertical"===t&&"h-full w-2.5 border-l border-l-transparent","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent",e),...l,children:(0,r.jsx)(D,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}e.s(["ScrollArea",()=>K,"ScrollBar",()=>q],772857)},375635,e=>{"use strict";var t=e.i(414294),r=e.i(430878),l=e.i(353913),n=e.i(292623),o=e.i(504561),s=e.i(996720),a=e.i(461957),i=e.i(846193),d=e.i(77589),d=d,c=e.i(416667),c=c,u=e.i(667249),p=e.i(191729),p=p,m=e.i(904781),f=e.i(266514),h=e.i(87614),x=e.i(666904),g=e.i(77982),v=e.i(772857),b=e.i(524741),w=e.i(739963),y=e.i(300739),j=e.i(555552);function S({label:e,value:r,tone:l}){return(0,t.jsxs)("div",{className:"rounded-lg border border-border/60 bg-card/50 p-2 text-center",children:[(0,t.jsx)("p",{className:(0,j.cn)("text-lg font-semibold tabular-nums",l),children:r}),(0,t.jsx)("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:e})]})}function N(){let e=(0,l.useRouter)(),N=(0,l.useSearchParams)(),{sessions:C,isLoading:E}=(0,y.useSessions)(),R=C.filter(e=>"worker"===e.role),k={running:R.filter(e=>"running"===e.agentStatus).length,needs_attention:R.filter(e=>"needs_attention"===e.agentStatus).length,completed:R.filter(e=>"completed"===e.agentStatus).length,failed:R.filter(e=>"failed"===e.agentStatus).length,idle:R.filter(e=>"idle"===e.agentStatus).length},[T,P]=(0,r.useState)(!1),[A,L]=(0,r.useState)(null),[_,D]=(0,r.useState)(""),[z,I]=(0,r.useState)(!1),[H,M]=(0,r.useState)(null),[W,$]=(0,r.useState)(null),O=(0,r.useRef)(!1),F=async(e,t)=>{e.preventDefault(),e.stopPropagation();try{await (0,b.deleteSession)(t),(0,y.mutateSessions)()}catch(e){console.error("Failed to delete session:",e)}};(0,r.useEffect)(()=>{(0,w.getConfig)().then(L)},[]),(0,r.useEffect)(()=>{N.has("new")&&A&&A.apiKeyConfigured&&!O.current&&!T&&(O.current=!0,(async()=>{P(!0);try{let t=await (0,b.createSession)({name:`Session ${C.length+1}`,model:A.defaultModel||"anthropic/claude-opus-4.7",toolApprovals:A.defaultToolApprovals||{}});(0,y.mutateSessions)(),e.replace(`/session/${t.id}`)}catch(e){console.error("Failed to auto-create session:",e),P(!1)}})())},[N,A,C.length,T,e]),(0,r.useEffect)(()=>{N.has("latest")&&!E&&C.length>0&&e.replace(`/session/${C[0].id}`)},[N,E,C,e]);let U=async()=>{if(_.trim()&&!z){I(!0),M(null);try{if((await (0,b.setApiKey)("ai-gateway",_.trim())).success){let e=await (0,w.getConfig)();L(e),D("")}else M("Failed to save API key. Please try again.")}catch(e){M("Failed to save API key. Please try again.")}finally{I(!1)}}},B=async()=>{if(!T){P(!0);try{let t=await (0,b.createSession)({name:`Session ${C.length+1}`,model:A?.defaultModel||"anthropic/claude-opus-4.7",toolApprovals:A?.defaultToolApprovals||{}});(0,y.mutateSessions)(),e.push(`/session/${t.id}`)}catch(e){console.error("Failed to create session:",e)}finally{P(!1)}}};return((0,r.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"t"===e.key&&(e.preventDefault(),B())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[T,C.length,A]),A&&!A.serverConnected)?(0,t.jsx)("div",{className:"flex items-center justify-center h-full bg-gradient-to-b from-background to-muted/20",children:(0,t.jsxs)("div",{className:"text-center max-w-lg mx-auto p-8",children:[(0,t.jsx)("div",{className:"flex justify-center mb-8",children:(0,t.jsx)("div",{className:"relative size-28 rounded-2xl overflow-hidden shadow-xl ring-1 ring-white/10",children:(0,t.jsx)(n.default,{src:"/sparke-coder.png",alt:"Sparke",fill:!0,className:"object-cover",priority:!0})})}),(0,t.jsx)("h1",{className:"text-3xl font-bold mb-3 text-primary",children:"SparkECoder API unreachable"}),(0,t.jsxs)("div",{className:"bg-muted/50 rounded-lg p-6 mb-6 text-left",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground mb-2",children:["The browser couldn't reach the SparkECoder API at ",(0,t.jsx)("code",{className:"px-1 py-0.5 rounded bg-muted text-[11px] break-all",children:A.apiBaseUrl}),"."]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mb-2",children:"Common causes:"}),(0,t.jsxs)("ul",{className:"text-sm text-muted-foreground list-disc pl-5 space-y-1",children:[(0,t.jsxs)("li",{children:["The auto-detected URL is wrong for this hostname. Append ",(0,t.jsx)("code",{className:"px-1 py-0.5 rounded bg-muted text-[11px]",children:"?apiUrl=https://your-api-host"})," to the page URL to override (saves to localStorage)."]}),(0,t.jsx)("li",{children:"Cloudflared tunnel down or DNS not yet propagated."}),(0,t.jsxs)("li",{children:["Sparkecoder service stopped — run ",(0,t.jsx)("code",{className:"px-1 py-0.5 rounded bg-muted text-[11px]",children:"launchctl list | grep sparkecoder"}),"."]})]})]})]})}):A&&A.serverConnected&&!A.apiKeyConfigured?(0,t.jsx)("div",{className:"flex items-center justify-center h-full bg-gradient-to-b from-background to-muted/20",children:(0,t.jsxs)("div",{className:"text-center max-w-lg mx-auto p-8",children:[(0,t.jsx)("div",{className:"flex justify-center mb-8",children:(0,t.jsx)("div",{className:"relative size-28 rounded-2xl overflow-hidden shadow-xl ring-1 ring-white/10",children:(0,t.jsx)(n.default,{src:"/sparke-coder.png",alt:"Sparke - AI Coding Assistant",fill:!0,className:"object-cover",priority:!0})})}),(0,t.jsx)("h1",{className:"text-3xl font-bold mb-3 text-primary",children:"Welcome to SparkECoder"}),(0,t.jsxs)("div",{className:"bg-muted/50 rounded-lg p-6 mb-6 text-left",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)(i.Key,{className:"size-5 text-amber-500"}),(0,t.jsx)("h2",{className:"font-semibold",children:"API Key Required"})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"SparkECoder uses the Vercel AI Gateway. Enter your API key to get started."}),(0,t.jsxs)("div",{className:"flex gap-2 mb-3",children:[(0,t.jsx)(g.Input,{type:"password",placeholder:"Enter your AI Gateway API key",value:_,onChange:e=>D(e.target.value),onKeyDown:e=>"Enter"===e.key&&U(),className:"flex-1"}),(0,t.jsx)(x.Button,{onClick:U,disabled:!_.trim()||z,children:z?(0,t.jsx)(a.Loader2,{className:"size-4 animate-spin"}):"Save"})]}),H&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-destructive mb-3",children:[(0,t.jsx)(c.default,{className:"size-4"}),H]}),(0,t.jsxs)("a",{href:"https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary hover:underline",children:["Get an API key from Vercel",(0,t.jsx)(d.default,{className:"size-3"})]})]})]})}):(0,t.jsx)("div",{className:"flex items-center justify-center h-full bg-gradient-to-b from-background to-muted/20 overflow-auto",children:(0,t.jsxs)("div",{className:"text-center max-w-lg mx-auto p-8",children:[(0,t.jsx)("div",{className:"flex justify-center mb-8",children:(0,t.jsx)(h.TooltipProvider,{children:(0,t.jsxs)(h.Tooltip,{children:[(0,t.jsx)(h.TooltipTrigger,{asChild:!0,children:(0,t.jsxs)("div",{className:"relative group cursor-pointer",children:[(0,t.jsx)("div",{className:"absolute inset-0 rounded-3xl blur-2xl opacity-40 group-hover:opacity-60 transition-opacity bg-primary/30"}),(0,t.jsx)("div",{className:"relative size-28 rounded-2xl overflow-hidden shadow-xl ring-1 ring-white/10 hover-lift",children:(0,t.jsx)(n.default,{src:"/sparke-coder.png",alt:"Sparke - AI Coding Assistant",fill:!0,className:"object-cover sparke-idle",priority:!0})})]})}),(0,t.jsx)(h.TooltipContent,{children:"Meet Sparke, your coding companion!"})]})})}),(0,t.jsx)("h1",{className:"text-3xl font-bold mb-3 text-primary",children:"Welcome to SparkECoder"}),(0,t.jsx)("p",{className:"text-muted-foreground mb-8 leading-relaxed",children:"Your AI-powered coding assistant. Start a new session to begin building amazing things."}),(0,t.jsx)(x.Button,{size:"lg",onClick:B,disabled:T,className:"gap-2 px-8",children:T?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(a.Loader2,{className:"size-4 animate-spin"}),"Creating..."]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.Plus,{className:"size-4"}),"Start a Session"]})}),(0,t.jsxs)("p",{className:"mt-6 text-xs text-muted-foreground/70",children:["Press ",(0,t.jsx)("kbd",{className:"px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono",children:"⌘"})," + ",(0,t.jsx)("kbd",{className:"px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono",children:"T"})," to create a new session"]}),R.length>0&&(0,t.jsxs)("div",{className:"mt-6 text-left",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(f.Bot,{className:"size-4 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:"Agents"})]}),(0,t.jsx)(o.default,{href:"/agents",className:"text-xs text-muted-foreground hover:text-foreground",children:"Open board →"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-5 gap-2",children:[(0,t.jsx)(S,{label:"Running",value:k.running,tone:"text-emerald-500"}),(0,t.jsx)(S,{label:"Needs input",value:k.needs_attention,tone:"text-amber-500"}),(0,t.jsx)(S,{label:"Idle",value:k.idle,tone:"text-muted-foreground"}),(0,t.jsx)(S,{label:"Done",value:k.completed,tone:"text-blue-500"}),(0,t.jsx)(S,{label:"Failed",value:k.failed,tone:"text-rose-500"})]})]}),!E&&C.length>0&&(0,t.jsxs)("div",{className:"mt-10 text-left",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)(p.default,{className:"size-4 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:"Recent Sessions"})]}),(0,t.jsx)("div",{className:"rounded-xl border border-border/60 bg-card/50 backdrop-blur-sm overflow-hidden",children:(0,t.jsx)(v.ScrollArea,{className:(0,j.cn)(C.length>5?"h-[280px]":""),children:(0,t.jsx)("div",{className:"divide-y divide-border/40",children:C.map(e=>{let r,l,n,s,a=W===e.id,i=!0===e.isStreaming;return(0,t.jsxs)(o.default,{href:`/session/${e.id}`,className:(0,j.cn)("flex items-center gap-3 p-3 transition-colors hover:bg-accent/50 group",i&&"bg-emerald-500/5"),onMouseEnter:()=>$(e.id),onMouseLeave:()=>$(null),children:[(0,t.jsx)("div",{className:(0,j.cn)("size-9 rounded-lg flex items-center justify-center shrink-0 transition-colors",i?"bg-emerald-500/10":"bg-muted/60 group-hover:bg-muted"),children:i?(0,t.jsx)("span",{className:"size-2.5 rounded-full bg-emerald-500 animate-pulse"}):(0,t.jsx)(u.MessageSquare,{className:"size-4 text-muted-foreground"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:(0,j.cn)("text-sm font-medium truncate",i&&"text-emerald-600 dark:text-emerald-400"),children:e.name||"Untitled Session"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:i?(0,t.jsx)("span",{className:"text-emerald-600 dark:text-emerald-400",children:"Active now"}):"waiting"===e.status?(0,t.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Waiting for input"}):(r=new Date(e.updatedAt||e.createdAt),s=Math.floor((n=Math.floor((l=Math.floor(Math.floor((new Date().getTime()-r.getTime())/1e3)/60))/60))/24),l<1?"just now":1===l?"1 minute ago":l<60?`${l} minutes ago`:1===n?"1 hour ago":n<24?`${n} hours ago`:1===s?"yesterday":s<7?`${s} days ago`:`${Math.floor(s/7)} weeks ago`)})]}),a&&(0,t.jsx)(h.TooltipProvider,{children:(0,t.jsxs)(h.Tooltip,{children:[(0,t.jsx)(h.TooltipTrigger,{asChild:!0,children:(0,t.jsx)(x.Button,{size:"icon",variant:"ghost",className:"size-7 shrink-0 hover:bg-destructive/10 hover:text-destructive transition-colors",onClick:t=>F(t,e.id),children:(0,t.jsx)(m.Trash2,{className:"size-3.5"})})}),(0,t.jsx)(h.TooltipContent,{children:"Delete session"})]})})]},e.id)})})})})]})]})})}function C(){return(0,t.jsx)(r.Suspense,{fallback:(0,t.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,t.jsx)(a.Loader2,{className:"size-6 animate-spin text-muted-foreground"})}),children:(0,t.jsx)(N,{})})}e.s(["default",()=>C],375635)}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,77589,e=>{"use strict";let t=(0,e.i(292511).default)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);e.s(["default",()=>t])},416667,e=>{"use strict";let t=(0,e.i(292511).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(["default",()=>t])},191729,772857,e=>{"use strict";let t=(0,e.i(292511).default)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);e.s(["default",()=>t],191729);var r=e.i(414294),l=e.i(430878);e.i(773340);var n=e.i(309945),o=Symbol("radix.slottable");function s(e){return l.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===o}var a=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{var o,a;let i,d,c,u=(a=o=`Primitive.${t}`,(i=l.forwardRef((e,t)=>{let{children:r,...o}=e;if(l.isValidElement(r)){var s;let e,a,i=(s=r,(a=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(a=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),d=function(e,t){let r={...t};for(let l in t){let n=e[l],o=t[l];/^on[A-Z]/.test(l)?n&&o?r[l]=(...e)=>{let t=o(...e);return n(...e),t}:n&&(r[l]=n):"style"===l?r[l]={...n,...o}:"className"===l&&(r[l]=[n,o].filter(Boolean).join(" "))}return{...e,...r}}(o,r.props);return r.type!==l.Fragment&&(d.ref=t?(0,n.composeRefs)(t,i):i),l.cloneElement(r,d)}return l.Children.count(r)>1?l.Children.only(null):null})).displayName=`${a}.SlotClone`,d=i,(c=l.forwardRef((e,t)=>{let{children:n,...o}=e,a=l.Children.toArray(n),i=a.find(s);if(i){let e=i.props.children,n=a.map(t=>t!==i?t:l.Children.count(e)>1?l.Children.only(null):l.isValidElement(e)?e.props.children:null);return(0,r.jsx)(d,{...o,ref:t,children:l.isValidElement(e)?l.cloneElement(e,void 0,n):null})}return(0,r.jsx)(d,{...o,ref:t,children:n})})).displayName=`${o}.Slot`,c),p=l.forwardRef((e,l)=>{let{asChild:n,...o}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,r.jsx)(n?u:t,{...o,ref:l})});return p.displayName=`Primitive.${t}`,{...e,[t]:p}},{}),i=e.i(395509),d=e.i(897462),c=e.i(542899),u=e.i(995945),p=e.i(992421),m=e.i(241416),f="ScrollArea",[h,x]=function(e,t=[]){let n=[],o=()=>{let t=n.map(e=>l.createContext(e));return function(r){let n=r?.[e]||t;return l.useMemo(()=>({[`__scope${e}`]:{...r,[e]:n}}),[r,n])}};return o.scopeName=e,[function(t,o){let s=l.createContext(o),a=n.length;n=[...n,o];let i=t=>{let{scope:n,children:o,...i}=t,d=n?.[e]?.[a]||s,c=l.useMemo(()=>i,Object.values(i));return(0,r.jsx)(d.Provider,{value:c,children:o})};return i.displayName=t+"Provider",[i,function(r,n){let i=n?.[e]?.[a]||s,d=l.useContext(i);if(d)return d;if(void 0!==o)return o;throw Error(`\`${r}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let r=()=>{let r=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let n=r.reduce((t,{useScope:r,scopeName:l})=>{let n=r(e)[`__scope${l}`];return{...t,...n}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:n}),[n])}};return r.scopeName=t.scopeName,r}(o,...t)]}(f),[g,v]=h(f),b=l.forwardRef((e,t)=>{let{__scopeScrollArea:o,type:s="hover",dir:i,scrollHideDelay:d=600,...u}=e,[p,m]=l.useState(null),[f,h]=l.useState(null),[x,v]=l.useState(null),[b,w]=l.useState(null),[y,j]=l.useState(null),[S,N]=l.useState(0),[C,E]=l.useState(0),[R,k]=l.useState(!1),[T,P]=l.useState(!1),A=(0,n.useComposedRefs)(t,e=>m(e)),L=(0,c.useDirection)(i);return(0,r.jsx)(g,{scope:o,type:s,dir:L,scrollHideDelay:d,scrollArea:p,viewport:f,onViewportChange:h,content:x,onContentChange:v,scrollbarX:b,onScrollbarXChange:w,scrollbarXEnabled:R,onScrollbarXEnabledChange:k,scrollbarY:y,onScrollbarYChange:j,scrollbarYEnabled:T,onScrollbarYEnabledChange:P,onCornerWidthChange:N,onCornerHeightChange:E,children:(0,r.jsx)(a.div,{dir:L,...u,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":S+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});b.displayName=f;var w="ScrollAreaViewport",y=l.forwardRef((e,t)=>{let{__scopeScrollArea:o,children:s,nonce:i,...d}=e,c=v(w,o),u=l.useRef(null),p=(0,n.useComposedRefs)(t,u,c.onViewportChange);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),(0,r.jsx)(a.div,{"data-radix-scroll-area-viewport":"",...d,ref:p,style:{overflowX:c.scrollbarXEnabled?"scroll":"hidden",overflowY:c.scrollbarYEnabled?"scroll":"hidden",...e.style},children:(0,r.jsx)("div",{ref:c.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});y.displayName=w;var j="ScrollAreaScrollbar",S=l.forwardRef((e,t)=>{let{forceMount:n,...o}=e,s=v(j,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=s,d="horizontal"===e.orientation;return l.useEffect(()=>(d?a(!0):i(!0),()=>{d?a(!1):i(!1)}),[d,a,i]),"hover"===s.type?(0,r.jsx)(N,{...o,ref:t,forceMount:n}):"scroll"===s.type?(0,r.jsx)(C,{...o,ref:t,forceMount:n}):"auto"===s.type?(0,r.jsx)(E,{...o,ref:t,forceMount:n}):"always"===s.type?(0,r.jsx)(R,{...o,ref:t}):null});S.displayName=j;var N=l.forwardRef((e,t)=>{let{forceMount:n,...o}=e,s=v(j,e.__scopeScrollArea),[a,d]=l.useState(!1);return l.useEffect(()=>{let e=s.scrollArea,t=0;if(e){let r=()=>{window.clearTimeout(t),d(!0)},l=()=>{t=window.setTimeout(()=>d(!1),s.scrollHideDelay)};return e.addEventListener("pointerenter",r),e.addEventListener("pointerleave",l),()=>{window.clearTimeout(t),e.removeEventListener("pointerenter",r),e.removeEventListener("pointerleave",l)}}},[s.scrollArea,s.scrollHideDelay]),(0,r.jsx)(i.Presence,{present:n||a,children:(0,r.jsx)(E,{"data-state":a?"visible":"hidden",...o,ref:t})})}),C=l.forwardRef((e,t)=>{var n;let{forceMount:o,...s}=e,a=v(j,e.__scopeScrollArea),d="horizontal"===e.orientation,c=V(()=>p("SCROLL_END"),100),[u,p]=(n={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},l.useReducer((e,t)=>n[e][t]??e,"hidden"));return l.useEffect(()=>{if("idle"===u){let e=window.setTimeout(()=>p("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(e)}},[u,a.scrollHideDelay,p]),l.useEffect(()=>{let e=a.viewport,t=d?"scrollLeft":"scrollTop";if(e){let r=e[t],l=()=>{let l=e[t];r!==l&&(p("SCROLL"),c()),r=l};return e.addEventListener("scroll",l),()=>e.removeEventListener("scroll",l)}},[a.viewport,d,p,c]),(0,r.jsx)(i.Presence,{present:o||"hidden"!==u,children:(0,r.jsx)(R,{"data-state":"hidden"===u?"hidden":"visible",...s,ref:t,onPointerEnter:(0,m.composeEventHandlers)(e.onPointerEnter,()=>p("POINTER_ENTER")),onPointerLeave:(0,m.composeEventHandlers)(e.onPointerLeave,()=>p("POINTER_LEAVE"))})})}),E=l.forwardRef((e,t)=>{let n=v(j,e.__scopeScrollArea),{forceMount:o,...s}=e,[a,d]=l.useState(!1),c="horizontal"===e.orientation,u=V(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;d(c?e:t)}},10);return Y(n.viewport,u),Y(n.content,u),(0,r.jsx)(i.Presence,{present:o||a,children:(0,r.jsx)(R,{"data-state":a?"visible":"hidden",...s,ref:t})})}),R=l.forwardRef((e,t)=>{let{orientation:n="vertical",...o}=e,s=v(j,e.__scopeScrollArea),a=l.useRef(null),i=l.useRef(0),[d,c]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=$(d.viewport,d.content),p={...o,sizes:d,onSizesChange:c,hasThumb:!!(u>0&&u<1),onThumbChange:e=>a.current=e,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:e=>i.current=e};function m(e,t){return function(e,t,r,l="ltr"){let n=O(r),o=t||n/2,s=r.scrollbar.paddingStart+o,a=r.scrollbar.size-r.scrollbar.paddingEnd-(n-o),i=r.content-r.viewport;return U([s,a],"ltr"===l?[0,i]:[-1*i,0])(e)}(e,i.current,d,t)}return"horizontal"===n?(0,r.jsx)(k,{...p,ref:t,onThumbPositionChange:()=>{if(s.viewport&&a.current){let e=F(s.viewport.scrollLeft,d,s.dir);a.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{s.viewport&&(s.viewport.scrollLeft=e)},onDragScroll:e=>{s.viewport&&(s.viewport.scrollLeft=m(e,s.dir))}}):"vertical"===n?(0,r.jsx)(T,{...p,ref:t,onThumbPositionChange:()=>{if(s.viewport&&a.current){let e=F(s.viewport.scrollTop,d);a.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{s.viewport&&(s.viewport.scrollTop=e)},onDragScroll:e=>{s.viewport&&(s.viewport.scrollTop=m(e))}}):null}),k=l.forwardRef((e,t)=>{let{sizes:o,onSizesChange:s,...a}=e,i=v(j,e.__scopeScrollArea),[d,c]=l.useState(),u=l.useRef(null),p=(0,n.useComposedRefs)(t,u,i.onScrollbarXChange);return l.useEffect(()=>{u.current&&c(getComputedStyle(u.current))},[u]),(0,r.jsx)(L,{"data-orientation":"horizontal",...a,ref:p,sizes:o,style:{bottom:0,left:"rtl"===i.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===i.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":O(o)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,r)=>{if(i.viewport){var l,n;let o=i.viewport.scrollLeft+t.deltaX;e.onWheelScroll(o),l=o,n=r,l>0&&l<n&&t.preventDefault()}},onResize:()=>{u.current&&i.viewport&&d&&s({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:u.current.clientWidth,paddingStart:W(d.paddingLeft),paddingEnd:W(d.paddingRight)}})}})}),T=l.forwardRef((e,t)=>{let{sizes:o,onSizesChange:s,...a}=e,i=v(j,e.__scopeScrollArea),[d,c]=l.useState(),u=l.useRef(null),p=(0,n.useComposedRefs)(t,u,i.onScrollbarYChange);return l.useEffect(()=>{u.current&&c(getComputedStyle(u.current))},[u]),(0,r.jsx)(L,{"data-orientation":"vertical",...a,ref:p,sizes:o,style:{top:0,right:"ltr"===i.dir?0:void 0,left:"rtl"===i.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":O(o)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,r)=>{if(i.viewport){var l,n;let o=i.viewport.scrollTop+t.deltaY;e.onWheelScroll(o),l=o,n=r,l>0&&l<n&&t.preventDefault()}},onResize:()=>{u.current&&i.viewport&&d&&s({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:u.current.clientHeight,paddingStart:W(d.paddingTop),paddingEnd:W(d.paddingBottom)}})}})}),[P,A]=h(j),L=l.forwardRef((e,t)=>{let{__scopeScrollArea:o,sizes:s,hasThumb:i,onThumbChange:c,onThumbPointerUp:u,onThumbPointerDown:p,onThumbPositionChange:f,onDragScroll:h,onWheelScroll:x,onResize:g,...b}=e,w=v(j,o),[y,S]=l.useState(null),N=(0,n.useComposedRefs)(t,e=>S(e)),C=l.useRef(null),E=l.useRef(""),R=w.viewport,k=s.content-s.viewport,T=(0,d.useCallbackRef)(x),A=(0,d.useCallbackRef)(f),L=V(g,10);function _(e){C.current&&h({x:e.clientX-C.current.left,y:e.clientY-C.current.top})}return l.useEffect(()=>{let e=e=>{let t=e.target;y?.contains(t)&&T(e,k)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[R,y,k,T]),l.useEffect(A,[s,A]),Y(y,L),Y(w.content,L),(0,r.jsx)(P,{scope:o,scrollbar:y,hasThumb:i,onThumbChange:(0,d.useCallbackRef)(c),onThumbPointerUp:(0,d.useCallbackRef)(u),onThumbPositionChange:A,onThumbPointerDown:(0,d.useCallbackRef)(p),children:(0,r.jsx)(a.div,{...b,ref:N,style:{position:"absolute",...b.style},onPointerDown:(0,m.composeEventHandlers)(e.onPointerDown,e=>{0===e.button&&(e.target.setPointerCapture(e.pointerId),C.current=y.getBoundingClientRect(),E.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",w.viewport&&(w.viewport.style.scrollBehavior="auto"),_(e))}),onPointerMove:(0,m.composeEventHandlers)(e.onPointerMove,_),onPointerUp:(0,m.composeEventHandlers)(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=E.current,w.viewport&&(w.viewport.style.scrollBehavior=""),C.current=null})})})}),_="ScrollAreaThumb",D=l.forwardRef((e,t)=>{let{forceMount:l,...n}=e,o=A(_,e.__scopeScrollArea);return(0,r.jsx)(i.Presence,{present:l||o.hasThumb,children:(0,r.jsx)(z,{ref:t,...n})})}),z=l.forwardRef((e,t)=>{let{__scopeScrollArea:o,style:s,...i}=e,d=v(_,o),c=A(_,o),{onThumbPositionChange:u}=c,p=(0,n.useComposedRefs)(t,e=>c.onThumbChange(e)),f=l.useRef(void 0),h=V(()=>{f.current&&(f.current(),f.current=void 0)},100);return l.useEffect(()=>{let e=d.viewport;if(e){let t=()=>{h(),f.current||(f.current=B(e,u),u())};return u(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}},[d.viewport,h,u]),(0,r.jsx)(a.div,{"data-state":c.hasThumb?"visible":"hidden",...i,ref:p,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:(0,m.composeEventHandlers)(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),r=e.clientX-t.left,l=e.clientY-t.top;c.onThumbPointerDown({x:r,y:l})}),onPointerUp:(0,m.composeEventHandlers)(e.onPointerUp,c.onThumbPointerUp)})});D.displayName=_;var I="ScrollAreaCorner",H=l.forwardRef((e,t)=>{let l=v(I,e.__scopeScrollArea),n=!!(l.scrollbarX&&l.scrollbarY);return"scroll"!==l.type&&n?(0,r.jsx)(M,{...e,ref:t}):null});H.displayName=I;var M=l.forwardRef((e,t)=>{let{__scopeScrollArea:n,...o}=e,s=v(I,n),[i,d]=l.useState(0),[c,u]=l.useState(0),p=!!(i&&c);return Y(s.scrollbarX,()=>{let e=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(e),u(e)}),Y(s.scrollbarY,()=>{let e=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(e),d(e)}),p?(0,r.jsx)(a.div,{...o,ref:t,style:{width:i,height:c,position:"absolute",right:"ltr"===s.dir?0:void 0,left:"rtl"===s.dir?0:void 0,bottom:0,...e.style}}):null});function W(e){return e?parseInt(e,10):0}function $(e,t){let r=e/t;return isNaN(r)?0:r}function O(e){let t=$(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd;return Math.max((e.scrollbar.size-r)*t,18)}function F(e,t,r="ltr"){let l=O(t),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,o=t.scrollbar.size-n,s=t.content-t.viewport,a=(0,p.clamp)(e,"ltr"===r?[0,s]:[-1*s,0]);return U([0,s],[0,o-l])(a)}function U(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let l=(t[1]-t[0])/(e[1]-e[0]);return t[0]+l*(r-e[0])}}var B=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},l=0;return!function n(){let o={left:e.scrollLeft,top:e.scrollTop},s=r.left!==o.left,a=r.top!==o.top;(s||a)&&t(),r=o,l=window.requestAnimationFrame(n)}(),()=>window.cancelAnimationFrame(l)};function V(e,t){let r=(0,d.useCallbackRef)(e),n=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(n.current),[]),l.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function Y(e,t){let r=(0,d.useCallbackRef)(t);(0,u.useLayoutEffect)(()=>{let t=0;if(e){let l=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(r)});return l.observe(e),()=>{window.cancelAnimationFrame(t),l.unobserve(e)}}},[e,r])}var X=e.i(555552);function K({className:e,children:t,...l}){return(0,r.jsxs)(b,{"data-slot":"scroll-area",className:(0,X.cn)("relative",e),...l,children:[(0,r.jsx)(y,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),(0,r.jsx)(q,{}),(0,r.jsx)(H,{})]})}function q({className:e,orientation:t="vertical",...l}){return(0,r.jsx)(S,{"data-slot":"scroll-area-scrollbar",orientation:t,className:(0,X.cn)("flex touch-none p-px transition-colors select-none","vertical"===t&&"h-full w-2.5 border-l border-l-transparent","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent",e),...l,children:(0,r.jsx)(D,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}e.s(["ScrollArea",()=>K,"ScrollBar",()=>q],772857)},375635,e=>{"use strict";var t=e.i(414294),r=e.i(430878),l=e.i(353913),n=e.i(292623),o=e.i(504561),s=e.i(996720),a=e.i(461957),i=e.i(846193),d=e.i(77589),d=d,c=e.i(416667),c=c,u=e.i(667249),p=e.i(191729),p=p,m=e.i(904781),f=e.i(266514),h=e.i(87614),x=e.i(666904),g=e.i(77982),v=e.i(772857),b=e.i(524741),w=e.i(739963),y=e.i(300739),j=e.i(555552);function S({label:e,value:r,tone:l}){return(0,t.jsxs)("div",{className:"rounded-lg border border-border/60 bg-card/50 p-2 text-center",children:[(0,t.jsx)("p",{className:(0,j.cn)("text-lg font-semibold tabular-nums",l),children:r}),(0,t.jsx)("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:e})]})}function N(){let e=(0,l.useRouter)(),N=(0,l.useSearchParams)(),{sessions:C,isLoading:E}=(0,y.useSessions)(),R=C.filter(e=>"worker"===e.role),k={running:R.filter(e=>"running"===e.agentStatus).length,needs_attention:R.filter(e=>"needs_attention"===e.agentStatus).length,completed:R.filter(e=>"completed"===e.agentStatus).length,failed:R.filter(e=>"failed"===e.agentStatus).length,idle:R.filter(e=>"idle"===e.agentStatus).length},[T,P]=(0,r.useState)(!1),[A,L]=(0,r.useState)(null),[_,D]=(0,r.useState)(""),[z,I]=(0,r.useState)(!1),[H,M]=(0,r.useState)(null),[W,$]=(0,r.useState)(null),O=(0,r.useRef)(!1),F=async(e,t)=>{e.preventDefault(),e.stopPropagation();try{await (0,b.deleteSession)(t),(0,y.mutateSessions)()}catch(e){console.error("Failed to delete session:",e)}};(0,r.useEffect)(()=>{(0,w.getConfig)().then(L)},[]),(0,r.useEffect)(()=>{N.has("new")&&A&&A.apiKeyConfigured&&!O.current&&!T&&(O.current=!0,(async()=>{P(!0);try{let t=await (0,b.createSession)({name:`Session ${C.length+1}`,model:A.defaultModel||"gpt-5.5",toolApprovals:A.defaultToolApprovals||{}});(0,y.mutateSessions)(),e.replace(`/session/${t.id}`)}catch(e){console.error("Failed to auto-create session:",e),P(!1)}})())},[N,A,C.length,T,e]),(0,r.useEffect)(()=>{N.has("latest")&&!E&&C.length>0&&e.replace(`/session/${C[0].id}`)},[N,E,C,e]);let U=async()=>{if(_.trim()&&!z){I(!0),M(null);try{if((await (0,b.setApiKey)("ai-gateway",_.trim())).success){let e=await (0,w.getConfig)();L(e),D("")}else M("Failed to save API key. Please try again.")}catch(e){M("Failed to save API key. Please try again.")}finally{I(!1)}}},B=async()=>{if(!T){P(!0);try{let t=await (0,b.createSession)({name:`Session ${C.length+1}`,model:A?.defaultModel||"gpt-5.5",toolApprovals:A?.defaultToolApprovals||{}});(0,y.mutateSessions)(),e.push(`/session/${t.id}`)}catch(e){console.error("Failed to create session:",e)}finally{P(!1)}}};return((0,r.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"t"===e.key&&(e.preventDefault(),B())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[T,C.length,A]),A&&!A.serverConnected)?(0,t.jsx)("div",{className:"flex items-center justify-center h-full bg-gradient-to-b from-background to-muted/20",children:(0,t.jsxs)("div",{className:"text-center max-w-lg mx-auto p-8",children:[(0,t.jsx)("div",{className:"flex justify-center mb-8",children:(0,t.jsx)("div",{className:"relative size-28 rounded-2xl overflow-hidden shadow-xl ring-1 ring-white/10",children:(0,t.jsx)(n.default,{src:"/sparke-coder.png",alt:"Sparke",fill:!0,className:"object-cover",priority:!0})})}),(0,t.jsx)("h1",{className:"text-3xl font-bold mb-3 text-primary",children:"SparkECoder API unreachable"}),(0,t.jsxs)("div",{className:"bg-muted/50 rounded-lg p-6 mb-6 text-left",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground mb-2",children:["The browser couldn't reach the SparkECoder API at ",(0,t.jsx)("code",{className:"px-1 py-0.5 rounded bg-muted text-[11px] break-all",children:A.apiBaseUrl}),"."]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mb-2",children:"Common causes:"}),(0,t.jsxs)("ul",{className:"text-sm text-muted-foreground list-disc pl-5 space-y-1",children:[(0,t.jsxs)("li",{children:["The auto-detected URL is wrong for this hostname. Append ",(0,t.jsx)("code",{className:"px-1 py-0.5 rounded bg-muted text-[11px]",children:"?apiUrl=https://your-api-host"})," to the page URL to override (saves to localStorage)."]}),(0,t.jsx)("li",{children:"Cloudflared tunnel down or DNS not yet propagated."}),(0,t.jsxs)("li",{children:["Sparkecoder service stopped — run ",(0,t.jsx)("code",{className:"px-1 py-0.5 rounded bg-muted text-[11px]",children:"launchctl list | grep sparkecoder"}),"."]})]})]})]})}):A&&A.serverConnected&&!A.apiKeyConfigured?(0,t.jsx)("div",{className:"flex items-center justify-center h-full bg-gradient-to-b from-background to-muted/20",children:(0,t.jsxs)("div",{className:"text-center max-w-lg mx-auto p-8",children:[(0,t.jsx)("div",{className:"flex justify-center mb-8",children:(0,t.jsx)("div",{className:"relative size-28 rounded-2xl overflow-hidden shadow-xl ring-1 ring-white/10",children:(0,t.jsx)(n.default,{src:"/sparke-coder.png",alt:"Sparke - AI Coding Assistant",fill:!0,className:"object-cover",priority:!0})})}),(0,t.jsx)("h1",{className:"text-3xl font-bold mb-3 text-primary",children:"Welcome to SparkECoder"}),(0,t.jsxs)("div",{className:"bg-muted/50 rounded-lg p-6 mb-6 text-left",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)(i.Key,{className:"size-5 text-amber-500"}),(0,t.jsx)("h2",{className:"font-semibold",children:"API Key Required"})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"SparkECoder uses the Vercel AI Gateway. Enter your API key to get started."}),(0,t.jsxs)("div",{className:"flex gap-2 mb-3",children:[(0,t.jsx)(g.Input,{type:"password",placeholder:"Enter your AI Gateway API key",value:_,onChange:e=>D(e.target.value),onKeyDown:e=>"Enter"===e.key&&U(),className:"flex-1"}),(0,t.jsx)(x.Button,{onClick:U,disabled:!_.trim()||z,children:z?(0,t.jsx)(a.Loader2,{className:"size-4 animate-spin"}):"Save"})]}),H&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-destructive mb-3",children:[(0,t.jsx)(c.default,{className:"size-4"}),H]}),(0,t.jsxs)("a",{href:"https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary hover:underline",children:["Get an API key from Vercel",(0,t.jsx)(d.default,{className:"size-3"})]})]})]})}):(0,t.jsx)("div",{className:"flex items-center justify-center h-full bg-gradient-to-b from-background to-muted/20 overflow-auto",children:(0,t.jsxs)("div",{className:"text-center max-w-lg mx-auto p-8",children:[(0,t.jsx)("div",{className:"flex justify-center mb-8",children:(0,t.jsx)(h.TooltipProvider,{children:(0,t.jsxs)(h.Tooltip,{children:[(0,t.jsx)(h.TooltipTrigger,{asChild:!0,children:(0,t.jsxs)("div",{className:"relative group cursor-pointer",children:[(0,t.jsx)("div",{className:"absolute inset-0 rounded-3xl blur-2xl opacity-40 group-hover:opacity-60 transition-opacity bg-primary/30"}),(0,t.jsx)("div",{className:"relative size-28 rounded-2xl overflow-hidden shadow-xl ring-1 ring-white/10 hover-lift",children:(0,t.jsx)(n.default,{src:"/sparke-coder.png",alt:"Sparke - AI Coding Assistant",fill:!0,className:"object-cover sparke-idle",priority:!0})})]})}),(0,t.jsx)(h.TooltipContent,{children:"Meet Sparke, your coding companion!"})]})})}),(0,t.jsx)("h1",{className:"text-3xl font-bold mb-3 text-primary",children:"Welcome to SparkECoder"}),(0,t.jsx)("p",{className:"text-muted-foreground mb-8 leading-relaxed",children:"Your AI-powered coding assistant. Start a new session to begin building amazing things."}),(0,t.jsx)(x.Button,{size:"lg",onClick:B,disabled:T,className:"gap-2 px-8",children:T?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(a.Loader2,{className:"size-4 animate-spin"}),"Creating..."]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.Plus,{className:"size-4"}),"Start a Session"]})}),(0,t.jsxs)("p",{className:"mt-6 text-xs text-muted-foreground/70",children:["Press ",(0,t.jsx)("kbd",{className:"px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono",children:"⌘"})," + ",(0,t.jsx)("kbd",{className:"px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono",children:"T"})," to create a new session"]}),R.length>0&&(0,t.jsxs)("div",{className:"mt-6 text-left",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(f.Bot,{className:"size-4 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:"Agents"})]}),(0,t.jsx)(o.default,{href:"/agents",className:"text-xs text-muted-foreground hover:text-foreground",children:"Open board →"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-5 gap-2",children:[(0,t.jsx)(S,{label:"Running",value:k.running,tone:"text-emerald-500"}),(0,t.jsx)(S,{label:"Needs input",value:k.needs_attention,tone:"text-amber-500"}),(0,t.jsx)(S,{label:"Idle",value:k.idle,tone:"text-muted-foreground"}),(0,t.jsx)(S,{label:"Done",value:k.completed,tone:"text-blue-500"}),(0,t.jsx)(S,{label:"Failed",value:k.failed,tone:"text-rose-500"})]})]}),!E&&C.length>0&&(0,t.jsxs)("div",{className:"mt-10 text-left",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)(p.default,{className:"size-4 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:"Recent Sessions"})]}),(0,t.jsx)("div",{className:"rounded-xl border border-border/60 bg-card/50 backdrop-blur-sm overflow-hidden",children:(0,t.jsx)(v.ScrollArea,{className:(0,j.cn)(C.length>5?"h-[280px]":""),children:(0,t.jsx)("div",{className:"divide-y divide-border/40",children:C.map(e=>{let r,l,n,s,a=W===e.id,i=!0===e.isStreaming;return(0,t.jsxs)(o.default,{href:`/session/${e.id}`,className:(0,j.cn)("flex items-center gap-3 p-3 transition-colors hover:bg-accent/50 group",i&&"bg-emerald-500/5"),onMouseEnter:()=>$(e.id),onMouseLeave:()=>$(null),children:[(0,t.jsx)("div",{className:(0,j.cn)("size-9 rounded-lg flex items-center justify-center shrink-0 transition-colors",i?"bg-emerald-500/10":"bg-muted/60 group-hover:bg-muted"),children:i?(0,t.jsx)("span",{className:"size-2.5 rounded-full bg-emerald-500 animate-pulse"}):(0,t.jsx)(u.MessageSquare,{className:"size-4 text-muted-foreground"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:(0,j.cn)("text-sm font-medium truncate",i&&"text-emerald-600 dark:text-emerald-400"),children:e.name||"Untitled Session"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:i?(0,t.jsx)("span",{className:"text-emerald-600 dark:text-emerald-400",children:"Active now"}):"waiting"===e.status?(0,t.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Waiting for input"}):(r=new Date(e.updatedAt||e.createdAt),s=Math.floor((n=Math.floor((l=Math.floor(Math.floor((new Date().getTime()-r.getTime())/1e3)/60))/60))/24),l<1?"just now":1===l?"1 minute ago":l<60?`${l} minutes ago`:1===n?"1 hour ago":n<24?`${n} hours ago`:1===s?"yesterday":s<7?`${s} days ago`:`${Math.floor(s/7)} weeks ago`)})]}),a&&(0,t.jsx)(h.TooltipProvider,{children:(0,t.jsxs)(h.Tooltip,{children:[(0,t.jsx)(h.TooltipTrigger,{asChild:!0,children:(0,t.jsx)(x.Button,{size:"icon",variant:"ghost",className:"size-7 shrink-0 hover:bg-destructive/10 hover:text-destructive transition-colors",onClick:t=>F(t,e.id),children:(0,t.jsx)(m.Trash2,{className:"size-3.5"})})}),(0,t.jsx)(h.TooltipContent,{children:"Delete session"})]})})]},e.id)})})})})]})]})})}function C(){return(0,t.jsx)(r.Suspense,{fallback:(0,t.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,t.jsx)(a.Loader2,{className:"size-6 animate-spin text-muted-foreground"})}),children:(0,t.jsx)(N,{})})}e.s(["default",()=>C],375635)}]);
@@ -90,13 +90,13 @@
90
90
  "license": "MIT"
91
91
  },
92
92
  "node_modules/@ai-sdk/gateway": {
93
- "version": "3.0.119",
94
- "resolved": "https://registry.npmjs.org/@ai-sdk/gateway/-/gateway-3.0.119.tgz",
95
- "integrity": "sha512-VAhfRWC+JexZakkVfmjaJKaTj00x7/UHdE8kMWL3NhuQAlf8oXtg9r4dfvFZrByXxchGRBvYE3biEUyibkg0xg==",
93
+ "version": "3.0.128",
94
+ "resolved": "https://registry.npmjs.org/@ai-sdk/gateway/-/gateway-3.0.128.tgz",
95
+ "integrity": "sha512-t9Dyqk5thSmIzsNvVTQtZZiO3xqKGkk1hX3+GNpYmro+GuEdW+E6mKFHihb9Y1vCEt3rEyd4pbGUcin4D57FfQ==",
96
96
  "license": "Apache-2.0",
97
97
  "dependencies": {
98
98
  "@ai-sdk/provider": "3.0.10",
99
- "@ai-sdk/provider-utils": "4.0.27",
99
+ "@ai-sdk/provider-utils": "4.0.28",
100
100
  "@vercel/oidc": "3.2.0"
101
101
  },
102
102
  "engines": {
@@ -119,9 +119,9 @@
119
119
  }
120
120
  },
121
121
  "node_modules/@ai-sdk/provider-utils": {
122
- "version": "4.0.27",
123
- "resolved": "https://registry.npmjs.org/@ai-sdk/provider-utils/-/provider-utils-4.0.27.tgz",
124
- "integrity": "sha512-ubkAJ+xODouwtmN1tYlvTPphH1hPOBfZaEQe8U7skGvFAnIRs9PPpsq57bC2+Ky/MB4yzhd6YOsxTAx9sGpazw==",
122
+ "version": "4.0.28",
123
+ "resolved": "https://registry.npmjs.org/@ai-sdk/provider-utils/-/provider-utils-4.0.28.tgz",
124
+ "integrity": "sha512-nCtGJY43Kqwoyk0rYLj80a3eyXxcaWwyu+lYZDHgY+U6JbYYyvRdRTSy+XCDIB91rFH0Ul0eMDHmDr+YMYtrSw==",
125
125
  "license": "Apache-2.0",
126
126
  "dependencies": {
127
127
  "@ai-sdk/provider": "3.0.10",
@@ -2075,9 +2075,9 @@
2075
2075
  }
2076
2076
  },
2077
2077
  "node_modules/@next/mdx": {
2078
- "version": "16.2.6",
2079
- "resolved": "https://registry.npmjs.org/@next/mdx/-/mdx-16.2.6.tgz",
2080
- "integrity": "sha512-0hdoSkzRbyud1dNRRDiyqD9FrxR2wwdiW+ffhYx+n+fXrFOJ7Nwpi8o7nUz2LiiM44BB9M0eIO1Evy3BBrS50A==",
2078
+ "version": "16.2.9",
2079
+ "resolved": "https://registry.npmjs.org/@next/mdx/-/mdx-16.2.9.tgz",
2080
+ "integrity": "sha512-SdweShKGCuN639JjyFSMQ8uldo+I+254+HucpjwdbFfaWHqUNN6dnQ1Of6laahnFyo48CcfDXEc2OBCS/Wfngw==",
2081
2081
  "license": "MIT",
2082
2082
  "dependencies": {
2083
2083
  "source-map": "^0.7.0"
@@ -5658,9 +5658,9 @@
5658
5658
  }
5659
5659
  },
5660
5660
  "node_modules/@types/mdx": {
5661
- "version": "2.0.13",
5662
- "resolved": "https://registry.npmjs.org/@types/mdx/-/mdx-2.0.13.tgz",
5663
- "integrity": "sha512-+OWZQfAYyio6YkJb3HLxDrvnx6SWWDbC0zVPfBRzUk0/nqoDyf6dNxQi3eArPe8rJ473nobTMQ/8Zk+LxJ+Yuw==",
5661
+ "version": "2.0.14",
5662
+ "resolved": "https://registry.npmjs.org/@types/mdx/-/mdx-2.0.14.tgz",
5663
+ "integrity": "sha512-T48PeuJtvLosNTPVhfnIp3i/n3a4g4Bad7YCq5k64D4u7NwDrAotikQ+5+sjtUvBmxCMlbo3dVL+C2dP0rWHzg==",
5664
5664
  "license": "MIT"
5665
5665
  },
5666
5666
  "node_modules/@types/ms": {
@@ -6478,14 +6478,14 @@
6478
6478
  }
6479
6479
  },
6480
6480
  "node_modules/ai": {
6481
- "version": "6.0.190",
6482
- "resolved": "https://registry.npmjs.org/ai/-/ai-6.0.190.tgz",
6483
- "integrity": "sha512-T+ixHbWZ6jmHRREpVVJTkFyWJeCekCdzLPan7lp1F32jG5OUw4+odlVYjtMRXVzogU+pWzpMmXdRiHUmdL/q0w==",
6481
+ "version": "6.0.202",
6482
+ "resolved": "https://registry.npmjs.org/ai/-/ai-6.0.202.tgz",
6483
+ "integrity": "sha512-14O7uyHVa5lXyt1RzduRqM1zwOnLBN+EaE+btWiP2R7GLHd5oh+Z9uaebR785V/Y2hXlxvuQGsw2Gj6iHpkxsg==",
6484
6484
  "license": "Apache-2.0",
6485
6485
  "dependencies": {
6486
- "@ai-sdk/gateway": "3.0.119",
6486
+ "@ai-sdk/gateway": "3.0.128",
6487
6487
  "@ai-sdk/provider": "3.0.10",
6488
- "@ai-sdk/provider-utils": "4.0.27",
6488
+ "@ai-sdk/provider-utils": "4.0.28",
6489
6489
  "@opentelemetry/api": "^1.9.0"
6490
6490
  },
6491
6491
  "engines": {
@@ -8948,9 +8948,9 @@
8948
8948
  }
8949
8949
  },
8950
8950
  "node_modules/eventsource-parser": {
8951
- "version": "3.0.8",
8952
- "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.0.8.tgz",
8953
- "integrity": "sha512-70QWGkr4snxr0OXLRWsFLeRBIRPuQOvt4s8QYjmUlmlkyTZkRqS7EDVRZtzU3TiyDbXSzaOeF0XUKy8PchzukQ==",
8951
+ "version": "3.1.0",
8952
+ "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.1.0.tgz",
8953
+ "integrity": "sha512-kJezFj9YFAMLeORyi7aCLxLbD5/qWMQnoMVlVPyHIll7lgRJCc3JVln9Vgl9nwQi0YkMnhdGTMNn7CkRRAptMg==",
8954
8954
  "license": "MIT",
8955
8955
  "engines": {
8956
8956
  "node": ">=18.0.0"
@@ -1,3 +1,4 @@
1
1
  {
2
- "apiBaseUrl": "http://127.0.0.1:3145"
2
+ "apiBaseUrl": "http://127.0.0.1:3144",
3
+ "localApiBaseUrl": "http://127.0.0.1:3144"
3
4
  }
@@ -95,7 +95,7 @@ function HomeContent() {
95
95
  try {
96
96
  const session = await createSession({
97
97
  name: `Session ${sessions.length + 1}`,
98
- model: config.defaultModel || 'anthropic/claude-opus-4.7',
98
+ model: config.defaultModel || 'gpt-5.5',
99
99
  toolApprovals: config.defaultToolApprovals || {},
100
100
  });
101
101
  mutateSessions();
@@ -147,7 +147,7 @@ function HomeContent() {
147
147
  try {
148
148
  const session = await createSession({
149
149
  name: `Session ${sessions.length + 1}`,
150
- model: config?.defaultModel || 'anthropic/claude-opus-4.7',
150
+ model: config?.defaultModel || 'gpt-5.5',
151
151
  toolApprovals: config?.defaultToolApprovals || {},
152
152
  });
153
153
  mutateSessions();