sparkecoder 0.1.87 → 0.1.94

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 (125) hide show
  1. package/README.md +1 -1
  2. package/dist/agent/index.d.ts +3 -3
  3. package/dist/agent/index.js +158 -68
  4. package/dist/agent/index.js.map +1 -1
  5. package/dist/cli.js +416 -108
  6. package/dist/cli.js.map +1 -1
  7. package/dist/db/index.d.ts +2 -2
  8. package/dist/{index-BvIissiB.d.ts → index-C7Kkn5vq.d.ts} +29 -29
  9. package/dist/index.d.ts +5 -5
  10. package/dist/index.js +272 -97
  11. package/dist/index.js.map +1 -1
  12. package/dist/{schema-CohdIL13.d.ts → schema-D7BJyHLl.d.ts} +3 -3
  13. package/dist/{search-CCffrVJE.d.ts → search-CVVfuBPZ.d.ts} +4 -4
  14. package/dist/server/index.js +272 -97
  15. package/dist/server/index.js.map +1 -1
  16. package/dist/tools/index.d.ts +31 -4
  17. package/dist/tools/index.js +38 -4
  18. package/dist/tools/index.js.map +1 -1
  19. package/package.json +5 -5
  20. package/web/.next/BUILD_ID +1 -1
  21. package/web/.next/standalone/web/.next/BUILD_ID +1 -1
  22. package/web/.next/standalone/web/.next/build-manifest.json +2 -2
  23. package/web/.next/standalone/web/.next/prerender-manifest.json +3 -3
  24. package/web/.next/standalone/web/.next/server/app/(main)/page_client-reference-manifest.js +1 -1
  25. package/web/.next/standalone/web/.next/server/app/(main)/session/[id]/page_client-reference-manifest.js +1 -1
  26. package/web/.next/standalone/web/.next/server/app/_global-error.html +2 -2
  27. package/web/.next/standalone/web/.next/server/app/_global-error.rsc +1 -1
  28. package/web/.next/standalone/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  29. package/web/.next/standalone/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  30. package/web/.next/standalone/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  31. package/web/.next/standalone/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  32. package/web/.next/standalone/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  33. package/web/.next/standalone/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  34. package/web/.next/standalone/web/.next/server/app/_not-found.html +1 -1
  35. package/web/.next/standalone/web/.next/server/app/_not-found.rsc +2 -2
  36. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  37. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  38. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  39. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  40. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  41. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  42. package/web/.next/standalone/web/.next/server/app/docs/installation/page_client-reference-manifest.js +1 -1
  43. package/web/.next/standalone/web/.next/server/app/docs/installation.html +2 -2
  44. package/web/.next/standalone/web/.next/server/app/docs/installation.rsc +3 -3
  45. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_full.segment.rsc +3 -3
  46. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_head.segment.rsc +1 -1
  47. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_index.segment.rsc +2 -2
  48. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_tree.segment.rsc +1 -1
  49. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs/installation/__PAGE__.segment.rsc +2 -2
  50. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs/installation.segment.rsc +1 -1
  51. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs.segment.rsc +2 -2
  52. package/web/.next/standalone/web/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  53. package/web/.next/standalone/web/.next/server/app/docs/skills/page_client-reference-manifest.js +1 -1
  54. package/web/.next/standalone/web/.next/server/app/docs/skills.html +2 -2
  55. package/web/.next/standalone/web/.next/server/app/docs/skills.rsc +3 -3
  56. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_full.segment.rsc +3 -3
  57. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_head.segment.rsc +1 -1
  58. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_index.segment.rsc +2 -2
  59. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_tree.segment.rsc +1 -1
  60. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs/skills/__PAGE__.segment.rsc +1 -1
  61. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs/skills.segment.rsc +1 -1
  62. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs.segment.rsc +2 -2
  63. package/web/.next/standalone/web/.next/server/app/docs/tools/page_client-reference-manifest.js +1 -1
  64. package/web/.next/standalone/web/.next/server/app/docs/tools.html +2 -2
  65. package/web/.next/standalone/web/.next/server/app/docs/tools.rsc +3 -3
  66. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_full.segment.rsc +3 -3
  67. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_head.segment.rsc +1 -1
  68. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_index.segment.rsc +2 -2
  69. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_tree.segment.rsc +1 -1
  70. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs/tools/__PAGE__.segment.rsc +2 -2
  71. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs/tools.segment.rsc +1 -1
  72. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs.segment.rsc +2 -2
  73. package/web/.next/standalone/web/.next/server/app/docs.html +2 -2
  74. package/web/.next/standalone/web/.next/server/app/docs.rsc +3 -3
  75. package/web/.next/standalone/web/.next/server/app/docs.segments/_full.segment.rsc +3 -3
  76. package/web/.next/standalone/web/.next/server/app/docs.segments/_head.segment.rsc +1 -1
  77. package/web/.next/standalone/web/.next/server/app/docs.segments/_index.segment.rsc +2 -2
  78. package/web/.next/standalone/web/.next/server/app/docs.segments/_tree.segment.rsc +1 -1
  79. package/web/.next/standalone/web/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +2 -2
  80. package/web/.next/standalone/web/.next/server/app/docs.segments/docs.segment.rsc +2 -2
  81. package/web/.next/standalone/web/.next/server/app/embed/[id]/page_client-reference-manifest.js +1 -1
  82. package/web/.next/standalone/web/.next/server/app/index.html +1 -1
  83. package/web/.next/standalone/web/.next/server/app/index.rsc +4 -4
  84. package/web/.next/standalone/web/.next/server/app/index.segments/!KG1haW4p/__PAGE__.segment.rsc +2 -2
  85. package/web/.next/standalone/web/.next/server/app/index.segments/!KG1haW4p.segment.rsc +2 -2
  86. package/web/.next/standalone/web/.next/server/app/index.segments/_full.segment.rsc +4 -4
  87. package/web/.next/standalone/web/.next/server/app/index.segments/_head.segment.rsc +1 -1
  88. package/web/.next/standalone/web/.next/server/app/index.segments/_index.segment.rsc +2 -2
  89. package/web/.next/standalone/web/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  90. package/web/.next/standalone/web/.next/server/chunks/[root-of-the-server]__36edac7c._.js +1 -1
  91. package/web/.next/standalone/web/.next/server/chunks/ssr/[root-of-the-server]__be5e2967._.js +1 -1
  92. package/web/.next/standalone/web/.next/server/chunks/ssr/web_src_app_(main)_page_tsx_5ac4794b._.js +1 -1
  93. package/web/.next/standalone/web/.next/server/chunks/ssr/web_src_components_sessions-sidebar_tsx_92510070._.js +1 -1
  94. package/web/.next/standalone/web/.next/server/pages/404.html +1 -1
  95. package/web/.next/standalone/web/.next/server/pages/500.html +2 -2
  96. package/web/.next/standalone/web/.next/server/server-reference-manifest.js +1 -1
  97. package/web/.next/standalone/web/.next/server/server-reference-manifest.json +1 -1
  98. package/web/.next/{static/chunks/26eb5fab5216f3cc.js → standalone/web/.next/static/chunks/58fd0aaa2746b444.js} +1 -1
  99. package/web/.next/standalone/web/.next/static/chunks/9fce2ce79c4c834e.js +1 -0
  100. package/web/.next/standalone/web/.next/static/chunks/{8d3efc76109d2efc.js → a888d448ceab1abe.js} +1 -1
  101. package/web/.next/standalone/web/.next/static/static/chunks/{26eb5fab5216f3cc.js → 58fd0aaa2746b444.js} +1 -1
  102. package/web/.next/standalone/web/.next/static/static/chunks/9fce2ce79c4c834e.js +1 -0
  103. package/web/.next/{static/chunks/8d3efc76109d2efc.js → standalone/web/.next/static/static/chunks/a888d448ceab1abe.js} +1 -1
  104. package/web/.next/standalone/web/package-lock.json +27 -27
  105. package/web/.next/standalone/web/package.json +1 -1
  106. package/web/.next/standalone/web/src/app/(main)/page.tsx +2 -2
  107. package/web/.next/standalone/web/src/app/api/config/route.ts +3 -2
  108. package/web/.next/standalone/web/src/components/sessions-sidebar.tsx +1 -1
  109. package/web/.next/standalone/web/src/lib/config.ts +2 -1
  110. package/web/.next/{standalone/web/.next/static/chunks/26eb5fab5216f3cc.js → static/chunks/58fd0aaa2746b444.js} +1 -1
  111. package/web/.next/static/chunks/9fce2ce79c4c834e.js +1 -0
  112. package/web/.next/{standalone/web/.next/static/static/chunks/8d3efc76109d2efc.js → static/chunks/a888d448ceab1abe.js} +1 -1
  113. package/web/package.json +1 -1
  114. package/web/.next/standalone/web/.next/static/chunks/b31b0765abe0c427.js +0 -1
  115. package/web/.next/standalone/web/.next/static/static/chunks/b31b0765abe0c427.js +0 -1
  116. package/web/.next/static/chunks/b31b0765abe0c427.js +0 -1
  117. /package/web/.next/standalone/web/.next/static/{static/uUaN7Xe5kF_pP6zhfaeYi → glGjCSPew_3EV65tkHmVO}/_buildManifest.js +0 -0
  118. /package/web/.next/standalone/web/.next/static/{static/uUaN7Xe5kF_pP6zhfaeYi → glGjCSPew_3EV65tkHmVO}/_clientMiddlewareManifest.json +0 -0
  119. /package/web/.next/standalone/web/.next/static/{static/uUaN7Xe5kF_pP6zhfaeYi → glGjCSPew_3EV65tkHmVO}/_ssgManifest.js +0 -0
  120. /package/web/.next/standalone/web/.next/static/{uUaN7Xe5kF_pP6zhfaeYi → static/glGjCSPew_3EV65tkHmVO}/_buildManifest.js +0 -0
  121. /package/web/.next/standalone/web/.next/static/{uUaN7Xe5kF_pP6zhfaeYi → static/glGjCSPew_3EV65tkHmVO}/_clientMiddlewareManifest.json +0 -0
  122. /package/web/.next/standalone/web/.next/static/{uUaN7Xe5kF_pP6zhfaeYi → static/glGjCSPew_3EV65tkHmVO}/_ssgManifest.js +0 -0
  123. /package/web/.next/static/{uUaN7Xe5kF_pP6zhfaeYi → glGjCSPew_3EV65tkHmVO}/_buildManifest.js +0 -0
  124. /package/web/.next/static/{uUaN7Xe5kF_pP6zhfaeYi → glGjCSPew_3EV65tkHmVO}/_clientMiddlewareManifest.json +0 -0
  125. /package/web/.next/static/{uUaN7Xe5kF_pP6zhfaeYi → glGjCSPew_3EV65tkHmVO}/_ssgManifest.js +0 -0
@@ -191,7 +191,7 @@ export function SessionsSidebar() {
191
191
  try {
192
192
  const session = await createSession({
193
193
  name: `Session ${sessions.length + 1}`,
194
- model: config?.defaultModel || 'anthropic/claude-opus-4-6',
194
+ model: config?.defaultModel || 'anthropic/claude-opus-4.7',
195
195
  toolApprovals, // Use current tool approval settings from global config
196
196
  });
197
197
  mutateSessions(); // Refresh the sessions list
@@ -98,6 +98,7 @@ export interface AppConfig {
98
98
 
99
99
  const DEFAULT_CONFIG: AppConfig = {
100
100
  availableModels: [
101
+ { id: 'anthropic/claude-opus-4.7', name: 'Claude Opus 4.7', provider: 'Anthropic' },
101
102
  { id: 'anthropic/claude-opus-4-6', name: 'Claude Opus 4.6', provider: 'Anthropic' },
102
103
  { id: 'anthropic/claude-opus-4-5', name: 'Claude Opus 4.5', provider: 'Anthropic' },
103
104
  { id: 'anthropic/claude-sonnet-4', name: 'Claude Sonnet 4', provider: 'Anthropic' },
@@ -111,7 +112,7 @@ const DEFAULT_CONFIG: AppConfig = {
111
112
  { id: 'write_file', name: 'Write File', description: 'Create or edit files', dangerous: true },
112
113
  { id: 'read_file', name: 'Read File', description: 'Read file contents', dangerous: false },
113
114
  ],
114
- defaultModel: 'anthropic/claude-opus-4-6',
115
+ defaultModel: 'anthropic/claude-opus-4.7',
115
116
  defaultToolApprovals: {},
116
117
  serverConnected: false,
117
118
  apiKeyConfigured: false,
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,996720,e=>{"use strict";var s=e.i(257868);e.s(["Plus",()=>s.default])},667249,e=>{"use strict";let s=(0,e.i(292511).default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);e.s(["MessageSquare",()=>s],667249)},846193,e=>{"use strict";let s=(0,e.i(292511).default)("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);e.s(["Key",()=>s],846193)},421722,e=>{"use strict";var s=e.i(414294),t=e.i(430878),a=e.i(353913),i=e.i(504561),l=e.i(292623),r=e.i(996720),n=e.i(667249),d=e.i(904781),o=e.i(461957),c=e.i(816187),m=e.i(292511);let x=(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 h=e.i(220563),u=e.i(846193),p=e.i(719583),j=e.i(707387),g=e.i(481298),g=g;let f=(0,m.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),N=(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 v=e.i(79092),b=e.i(372379),y=e.i(928574),k=e.i(529757),S=e.i(666904),C=e.i(836191),T=e.i(77982),z=e.i(634066),w=e.i(865259),M=e.i(553880),L=e.i(87614),P=e.i(524741),A=e.i(455706),D=e.i(743053),B=e.i(739963),I=e.i(555552),F=e.i(300739),$=e.i(335130);function q(){let e=(0,a.useRouter)(),m=(0,a.usePathname)(),{state:q,toggleSidebar:E}=(0,k.useSidebar)(),{sessions:V,isLoading:K}=(0,F.useSessions)(),[O,R]=(0,t.useState)(!1),[U,W]=(0,t.useState)(!1),[H,J]=(0,t.useState)(!1),[G,X]=(0,t.useState)(null),[Y,Q]=(0,t.useState)(null),Z=(0,t.useRef)(null),[_,ee]=(0,t.useState)(""),[es,et]=(0,t.useState)(""),[ea,ei]=(0,t.useState)({}),[el,er]=(0,t.useState)(!1),[en,ed]=(0,t.useState)(""),eo={type:"object",properties:{},required:[]},[ec,em]=(0,t.useState)(eo),[ex,eh]=(0,t.useState)(""),[eu,ep]=(0,t.useState)(""),[ej,eg]=(0,t.useState)(""),[ef,eN]=(0,t.useState)(""),[ev,eb]=(0,t.useState)("50"),[ey,ek]=(0,t.useState)(!1),[eS,eC]=(0,t.useState)([]),[eT,ez]=(0,t.useState)(null),[ew,eM]=(0,t.useState)(""),[eL,eP]=(0,t.useState)(!1),[eA,eD]=(0,t.useState)(!1),{enabled:eB,setEnabled:eI}=(0,$.useNotificationSound)(),eF=m.startsWith("/embed/"),e$=m.startsWith("/session/")?m.split("/session/")[1]:m.startsWith("/embed/")?m.split("/embed/")[1]:null,eq=eF?"/embed":"/session",eE=V.some(e=>e.isStreaming),eV=async()=>{let e=await (0,B.getConfig)();X(e),et(e.defaultModel),ei(e.defaultToolApprovals)},eK=async()=>{try{let e=await (0,P.getApiKeys)();eC(e.providers)}catch(e){console.error("Failed to load API keys:",e)}};(0,t.useEffect)(()=>{eV(),eK()},[]),(0,t.useEffect)(()=>{H&&eK()},[H]);let eO=async e=>{if(ew.trim()){eD(!0);try{await (0,P.setApiKey)(e,ew),await eK(),ez(null),eM(""),eP(!1)}catch(e){console.error("Failed to save API key:",e)}finally{eD(!1)}}},eR=()=>{ez(null),eM(""),eP(!1)};(0,t.useEffect)(()=>{Z.current&&(eE?Z.current.play().catch(()=>{}):(Z.current.pause(),Z.current.currentTime=0))},[eE]);let eU=async()=>{if(!O){R(!0);try{let s=await (0,P.createSession)({name:`Session ${V.length+1}`,model:G?.defaultModel||"anthropic/claude-opus-4-6",toolApprovals:ea});(0,F.mutateSessions)(),e.push(`${eq}/${s.id}`)}catch(e){console.error("Failed to create session:",e)}finally{R(!1)}}},eW=async()=>{R(!0);try{let s=await (0,P.createSession)({name:_||`Session ${V.length+1}`,model:es,toolApprovals:ea});(0,F.mutateSessions)(),eH(),W(!1),e.push(`${eq}/${s.id}`)}catch(e){console.error("Failed to create session:",e)}finally{R(!1)}},eH=()=>{ee(""),G&&(et(G.defaultModel),ei(G.defaultToolApprovals))},eJ=()=>{ed(""),em(eo),eh(""),ep(""),eg(""),eN(G?.defaultModel||""),eb("50")},eG=async()=>{if(en.trim()){if(eh(""),!ec||"object"!=typeof ec)return void eh("Schema must be a JSON object");ek(!0);try{let s=await (0,P.createTask)({prompt:en,outputSchema:ec,webhookUrl:eu||void 0,model:ef||G?.defaultModel,name:ej||void 0,maxIterations:parseInt(ev)||50});(0,F.mutateSessions)(),er(!1),eJ(),e.push(`${eq}/${s.taskId}`)}catch(e){console.error("Failed to create task:",e)}finally{ek(!1)}}},eX=async(s,t)=>{s.preventDefault(),s.stopPropagation();try{await (0,P.deleteSession)(t),(0,F.mutateSessions)(),e$===t&&e.push("/")}catch(e){console.error("Failed to delete session:",e)}},eY=e=>{ei(s=>({...s,[e]:!s[e]}))},eQ="collapsed"===q;return(0,s.jsxs)(k.Sidebar,{collapsible:eF?"offcanvas":"icon",className:"border-r border-border/50",children:[(0,s.jsxs)(k.SidebarHeader,{className:(0,I.cn)(eQ?"p-2 space-y-2":"p-3 space-y-3"),children:[!eQ&&(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:Z,src:"/sparkecode.mp4",muted:!0,loop:!0,playsInline:!0,className:(0,I.cn)("absolute inset-0 size-full object-cover transition-opacity duration-300",eE?"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)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-7 hover:bg-accent transition-colors",onClick:E,children:(0,s.jsx)(x,{className:"size-4"})})}),(0,s.jsxs)(L.TooltipContent,{side:"bottom",children:["Collapse ",(0,s.jsx)("kbd",{className:"ml-1 text-[10px] opacity-60",children:"⌘B"})]})]})})]})]}),(0,s.jsxs)("div",{className:"flex gap-2 w-full",children:[(0,s.jsxs)(S.Button,{onClick:eU,disabled:O,className:"flex-1 justify-center gap-2 h-9",children:[O?(0,s.jsx)(o.Loader2,{className:"size-4 animate-spin"}):(0,s.jsx)(r.Plus,{className:"size-4"}),"New Agent"]}),(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(S.Button,{variant:"outline",onClick:()=>{G||eV(),er(!0)},className:"h-9 px-2.5",children:(0,s.jsx)(v.ListChecks,{className:"size-4"})})}),(0,s.jsx)(L.TooltipContent,{side:"bottom",children:"New Task"})]})})]})]}),eQ&&(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 w-full",children:[(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(S.Button,{size:"icon",variant:"ghost",onClick:E,className:"size-8 mx-auto",children:(0,s.jsx)(h.PanelLeft,{className:"size-4"})})}),(0,s.jsxs)(L.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:Z,src:"/sparkecode.mp4",muted:!0,loop:!0,playsInline:!0,className:(0,I.cn)("absolute inset-0 size-full object-cover transition-opacity duration-300",eE?"opacity-100":"opacity-0")})]}),(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(S.Button,{size:"icon",onClick:eU,disabled:O,className:"size-8 mx-auto",children:O?(0,s.jsx)(o.Loader2,{className:"size-4 animate-spin"}):(0,s.jsx)(r.Plus,{className:"size-4"})})}),(0,s.jsx)(L.TooltipContent,{side:"right",children:"New Agent"})]})}),(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(S.Button,{size:"icon",variant:"outline",onClick:()=>{G||eV(),er(!0)},className:"size-8 mx-auto",children:(0,s.jsx)(v.ListChecks,{className:"size-4"})})}),(0,s.jsx)(L.TooltipContent,{side:"right",children:"New Task"})]})})]})]}),(0,s.jsx)(C.Dialog,{open:U,onOpenChange:e=>{W(e),e&&eH()},children:(0,s.jsxs)(C.DialogContent,{className:"sm:max-w-md",children:[(0,s.jsx)(C.DialogHeader,{children:(0,s.jsxs)(C.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)(c.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)(z.Label,{htmlFor:"name",className:"text-sm font-medium",children:"Session Name"}),(0,s.jsx)(T.Input,{id:"name",placeholder:"My Coding Project (optional)",value:_,onChange:e=>ee(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)(z.Label,{className:"text-sm font-medium",children:"Model"}),(0,s.jsxs)(M.Select,{value:es,onValueChange:et,children:[(0,s.jsx)(M.SelectTrigger,{className:"transition-all hover:border-primary/50",children:(0,s.jsx)(M.SelectValue,{placeholder:"Select a model"})}),(0,s.jsx)(M.SelectContent,{children:G?.availableModels.map(e=>(0,s.jsx)(M.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)(z.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:G?.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)(w.Switch,{checked:ea[e.id]??!1,onCheckedChange:()=>eY(e.id)})]},e.id))})]}),(0,s.jsxs)(S.Button,{onClick:eW,disabled:O,className:"w-full",children:[O?(0,s.jsx)(o.Loader2,{className:"size-4 animate-spin mr-2"}):(0,s.jsx)(r.Plus,{className:"size-4 mr-2"}),"Create Session"]})]})]})}),(0,s.jsx)(C.Dialog,{open:el,onOpenChange:e=>{er(e),e&&eJ()},children:(0,s.jsxs)(C.DialogContent,{className:"sm:max-w-lg",children:[(0,s.jsx)(C.DialogHeader,{children:(0,s.jsxs)(C.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)(v.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)(z.Label,{htmlFor:"task-prompt",className:"text-sm font-medium",children:"What should the agent do?"}),(0,s.jsx)(A.Textarea,{id:"task-prompt",placeholder:"e.g. Refactor the auth module to use JWT tokens...",value:en,onChange:e=>ed(e.target.value),rows:3,autoFocus:!0})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(z.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,I.cn)("rounded-md border bg-muted/30 overflow-hidden transition-colors",ex&&"border-red-500"),children:(0,s.jsx)(D.VisualJson,{value:ec,onChange:e=>{em(e),eh("")},children:(0,s.jsx)(D.TreeView,{className:"h-44 text-sm"})})}),ex&&(0,s.jsx)("p",{className:"text-xs text-red-500 mt-1",children:ex})]}),(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)(z.Label,{className:"text-xs text-muted-foreground",children:"Model"}),(0,s.jsxs)(M.Select,{value:ef,onValueChange:eN,children:[(0,s.jsx)(M.SelectTrigger,{className:"h-9",children:(0,s.jsx)(M.SelectValue,{placeholder:"Select a model"})}),(0,s.jsx)(M.SelectContent,{children:G?.availableModels.map(e=>(0,s.jsx)(M.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)(z.Label,{htmlFor:"task-name",className:"text-xs text-muted-foreground",children:"Name"}),(0,s.jsx)(T.Input,{id:"task-name",placeholder:"Optional",value:ej,onChange:e=>eg(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)(b.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)(z.Label,{htmlFor:"task-webhook",className:"text-xs text-muted-foreground",children:"Webhook URL"}),(0,s.jsx)(T.Input,{id:"task-webhook",placeholder:"https://...",value:eu,onChange:e=>ep(e.target.value),className:"h-9"})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(z.Label,{htmlFor:"task-iterations",className:"text-xs text-muted-foreground",children:"Max iterations"}),(0,s.jsx)(T.Input,{id:"task-iterations",type:"number",min:1,max:500,value:ev,onChange:e=>eb(e.target.value),className:"h-9"})]})]})]}),(0,s.jsx)(S.Button,{onClick:eG,disabled:ey||!en.trim(),className:"w-full",children:ey?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Loader2,{className:"size-4 animate-spin mr-2"}),"Creating..."]}):"Start Task"})]})]})}),(0,s.jsx)(k.SidebarContent,{className:"px-2",children:(0,s.jsx)(k.SidebarGroup,{className:"p-0",children:(0,s.jsx)(k.SidebarGroupContent,{children:(0,s.jsx)(k.SidebarMenu,{className:"gap-1",children:K?(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===V.length?!eQ&&(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"}),eE&&(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"})]}):V.map(e=>{let t,a,l,r,o=e.id===e$,c=Y===e.id,m=!0===e.isStreaming,x=!eQ&&(c||o);return(0,s.jsx)(k.SidebarMenuItem,{onMouseEnter:()=>Q(e.id),onMouseLeave:()=>Q(null),children:eQ?(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(i.default,{href:`${eq}/${e.id}`,className:(0,I.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)(n.MessageSquare,{className:(0,I.cn)("size-4",o?"text-primary":"text-muted-foreground")})})}),(0,s.jsxs)(L.TooltipContent,{side:"right",children:[e.name||"Untitled",m&&" (Running)"]})]})}):(0,s.jsx)(k.SidebarMenuButton,{asChild:!0,isActive:o,className:(0,I.cn)("h-9 transition-all duration-150","hover:bg-accent/60",o&&"bg-accent",m&&!o&&"bg-emerald-500/5"),children:(0,s.jsxs)(i.default,{href:`${eq}/${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)(n.MessageSquare,{className:(0,I.cn)("size-4 shrink-0",o?"text-primary":"text-muted-foreground")}),(0,s.jsx)("span",{className:(0,I.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)(y.Badge,{variant:"outline",className:(0,I.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)(v.ListChecks,{className:"size-2.5"}),"Task"]}),x?(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-6 shrink-0 hover:bg-destructive/10 hover:text-destructive transition-colors",onClick:s=>eX(s,e.id),children:(0,s.jsx)(d.Trash2,{className:"size-3.5"})})}),(0,s.jsx)(L.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:(t=new Date(e.createdAt),r=Math.floor((l=Math.floor((a=Math.floor(Math.floor((new Date().getTime()-t.getTime())/1e3)/60))/60))/24),a<1?"now":a<60?`${a}m`:l<24?`${l}h`:r<7?`${r}d`:`${Math.floor(r/7)}w`)})]})})},e.id)})})})})}),(0,s.jsx)(k.SidebarFooter,{className:(0,I.cn)("border-t border-border/50",eQ?"p-2":"p-3"),children:(0,s.jsx)("div",{className:"flex items-center justify-between",children:eQ?(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 w-full",children:[(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)("div",{className:"flex items-center justify-center",children:(0,s.jsx)("span",{className:(0,I.cn)("size-2 rounded-full",G?.serverConnected?"bg-emerald-500 animate-pulse":"bg-red-500")})})}),(0,s.jsx)(L.TooltipContent,{side:"right",children:G?.serverConnected?"Connected":"Disconnected"})]})}),(0,s.jsx)(C.Dialog,{open:H,onOpenChange:J,children:(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(C.DialogTrigger,{asChild:!0,children:(0,s.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-8",children:(0,s.jsx)(c.Settings,{className:"size-4"})})})}),(0,s.jsx)(L.TooltipContent,{side:"right",children:"Settings"})]})})})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[G?.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:V.length})]}),(0,s.jsxs)(C.Dialog,{open:H,onOpenChange:J,children:[(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(C.DialogTrigger,{asChild:!0,children:(0,s.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-7 hover:bg-accent transition-colors",children:(0,s.jsx)(c.Settings,{className:"size-4"})})})}),(0,s.jsx)(L.TooltipContent,{side:"top",children:"Settings"})]})}),(0,s.jsxs)(C.DialogContent,{className:"sm:max-w-md",children:[(0,s.jsx)(C.DialogHeader,{children:(0,s.jsxs)(C.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)(c.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)(z.Label,{className:"text-sm font-medium",children:"Default Model"}),(0,s.jsxs)(M.Select,{value:es,onValueChange:et,children:[(0,s.jsx)(M.SelectTrigger,{className:"transition-all hover:border-primary/50",children:(0,s.jsx)(M.SelectValue,{placeholder:"Select a model"})}),(0,s.jsx)(M.SelectContent,{children:G?.availableModels.map(e=>(0,s.jsx)(M.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)(z.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:G?.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)(w.Switch,{checked:ea[e.id]??!1,onCheckedChange:()=>eY(e.id)})]},e.id))})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)(z.Label,{className:"flex items-center gap-2 text-sm font-medium",children:[(0,s.jsx)(u.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:eS.map(e=>(0,s.jsx)("div",{className:"py-1.5 hover:bg-muted/50 rounded px-2 -mx-1 transition-colors",children:eT===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)(T.Input,{type:eL?"text":"password",value:ew,onChange:e=>eM(e.target.value),placeholder:"Paste your API key...",className:"pr-8 text-sm font-mono",autoFocus:!0}),(0,s.jsx)(S.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-2 hover:bg-transparent",onClick:()=>eP(!eL),children:eL?(0,s.jsx)(f,{className:"size-4"}):(0,s.jsx)(g.default,{className:"size-4"})})]}),(0,s.jsx)(S.Button,{size:"icon",variant:"ghost",className:"shrink-0",onClick:()=>eO(e.provider),disabled:eA||!ew.trim(),children:eA?(0,s.jsx)(o.Loader2,{className:"size-4 animate-spin"}):(0,s.jsx)(p.Check,{className:"size-4 text-green-500"})}),(0,s.jsx)(S.Button,{size:"icon",variant:"ghost",className:"shrink-0",onClick:eR,children:(0,s.jsx)(j.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,I.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)(S.Button,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>ez(e.provider),children:e.configured?"Update":"Add"})]})},e.provider))})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsxs)(z.Label,{className:"flex items-center gap-2 text-sm font-medium",children:[(0,s.jsx)(N,{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)(w.Switch,{checked:eB,onCheckedChange:eI})]})]}),(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."})]})]})]})]})})})]})}e.s(["SessionsSidebar",()=>q],421722)}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,996720,e=>{"use strict";var s=e.i(257868);e.s(["Plus",()=>s.default])},667249,e=>{"use strict";let s=(0,e.i(292511).default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);e.s(["MessageSquare",()=>s],667249)},846193,e=>{"use strict";let s=(0,e.i(292511).default)("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);e.s(["Key",()=>s],846193)},421722,e=>{"use strict";var s=e.i(414294),t=e.i(430878),a=e.i(353913),i=e.i(504561),l=e.i(292623),r=e.i(996720),n=e.i(667249),d=e.i(904781),o=e.i(461957),c=e.i(816187),m=e.i(292511);let x=(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 h=e.i(220563),u=e.i(846193),p=e.i(719583),j=e.i(707387),g=e.i(481298),g=g;let f=(0,m.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),N=(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 v=e.i(79092),b=e.i(372379),y=e.i(928574),k=e.i(529757),S=e.i(666904),C=e.i(836191),T=e.i(77982),z=e.i(634066),w=e.i(865259),M=e.i(553880),L=e.i(87614),P=e.i(524741),A=e.i(455706),D=e.i(743053),B=e.i(739963),I=e.i(555552),F=e.i(300739),$=e.i(335130);function q(){let e=(0,a.useRouter)(),m=(0,a.usePathname)(),{state:q,toggleSidebar:E}=(0,k.useSidebar)(),{sessions:V,isLoading:K}=(0,F.useSessions)(),[O,R]=(0,t.useState)(!1),[U,W]=(0,t.useState)(!1),[H,J]=(0,t.useState)(!1),[G,X]=(0,t.useState)(null),[Y,Q]=(0,t.useState)(null),Z=(0,t.useRef)(null),[_,ee]=(0,t.useState)(""),[es,et]=(0,t.useState)(""),[ea,ei]=(0,t.useState)({}),[el,er]=(0,t.useState)(!1),[en,ed]=(0,t.useState)(""),eo={type:"object",properties:{},required:[]},[ec,em]=(0,t.useState)(eo),[ex,eh]=(0,t.useState)(""),[eu,ep]=(0,t.useState)(""),[ej,eg]=(0,t.useState)(""),[ef,eN]=(0,t.useState)(""),[ev,eb]=(0,t.useState)("50"),[ey,ek]=(0,t.useState)(!1),[eS,eC]=(0,t.useState)([]),[eT,ez]=(0,t.useState)(null),[ew,eM]=(0,t.useState)(""),[eL,eP]=(0,t.useState)(!1),[eA,eD]=(0,t.useState)(!1),{enabled:eB,setEnabled:eI}=(0,$.useNotificationSound)(),eF=m.startsWith("/embed/"),e$=m.startsWith("/session/")?m.split("/session/")[1]:m.startsWith("/embed/")?m.split("/embed/")[1]:null,eq=eF?"/embed":"/session",eE=V.some(e=>e.isStreaming),eV=async()=>{let e=await (0,B.getConfig)();X(e),et(e.defaultModel),ei(e.defaultToolApprovals)},eK=async()=>{try{let e=await (0,P.getApiKeys)();eC(e.providers)}catch(e){console.error("Failed to load API keys:",e)}};(0,t.useEffect)(()=>{eV(),eK()},[]),(0,t.useEffect)(()=>{H&&eK()},[H]);let eO=async e=>{if(ew.trim()){eD(!0);try{await (0,P.setApiKey)(e,ew),await eK(),ez(null),eM(""),eP(!1)}catch(e){console.error("Failed to save API key:",e)}finally{eD(!1)}}},eR=()=>{ez(null),eM(""),eP(!1)};(0,t.useEffect)(()=>{Z.current&&(eE?Z.current.play().catch(()=>{}):(Z.current.pause(),Z.current.currentTime=0))},[eE]);let eU=async()=>{if(!O){R(!0);try{let s=await (0,P.createSession)({name:`Session ${V.length+1}`,model:G?.defaultModel||"anthropic/claude-opus-4.7",toolApprovals:ea});(0,F.mutateSessions)(),e.push(`${eq}/${s.id}`)}catch(e){console.error("Failed to create session:",e)}finally{R(!1)}}},eW=async()=>{R(!0);try{let s=await (0,P.createSession)({name:_||`Session ${V.length+1}`,model:es,toolApprovals:ea});(0,F.mutateSessions)(),eH(),W(!1),e.push(`${eq}/${s.id}`)}catch(e){console.error("Failed to create session:",e)}finally{R(!1)}},eH=()=>{ee(""),G&&(et(G.defaultModel),ei(G.defaultToolApprovals))},eJ=()=>{ed(""),em(eo),eh(""),ep(""),eg(""),eN(G?.defaultModel||""),eb("50")},eG=async()=>{if(en.trim()){if(eh(""),!ec||"object"!=typeof ec)return void eh("Schema must be a JSON object");ek(!0);try{let s=await (0,P.createTask)({prompt:en,outputSchema:ec,webhookUrl:eu||void 0,model:ef||G?.defaultModel,name:ej||void 0,maxIterations:parseInt(ev)||50});(0,F.mutateSessions)(),er(!1),eJ(),e.push(`${eq}/${s.taskId}`)}catch(e){console.error("Failed to create task:",e)}finally{ek(!1)}}},eX=async(s,t)=>{s.preventDefault(),s.stopPropagation();try{await (0,P.deleteSession)(t),(0,F.mutateSessions)(),e$===t&&e.push("/")}catch(e){console.error("Failed to delete session:",e)}},eY=e=>{ei(s=>({...s,[e]:!s[e]}))},eQ="collapsed"===q;return(0,s.jsxs)(k.Sidebar,{collapsible:eF?"offcanvas":"icon",className:"border-r border-border/50",children:[(0,s.jsxs)(k.SidebarHeader,{className:(0,I.cn)(eQ?"p-2 space-y-2":"p-3 space-y-3"),children:[!eQ&&(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:Z,src:"/sparkecode.mp4",muted:!0,loop:!0,playsInline:!0,className:(0,I.cn)("absolute inset-0 size-full object-cover transition-opacity duration-300",eE?"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)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-7 hover:bg-accent transition-colors",onClick:E,children:(0,s.jsx)(x,{className:"size-4"})})}),(0,s.jsxs)(L.TooltipContent,{side:"bottom",children:["Collapse ",(0,s.jsx)("kbd",{className:"ml-1 text-[10px] opacity-60",children:"⌘B"})]})]})})]})]}),(0,s.jsxs)("div",{className:"flex gap-2 w-full",children:[(0,s.jsxs)(S.Button,{onClick:eU,disabled:O,className:"flex-1 justify-center gap-2 h-9",children:[O?(0,s.jsx)(o.Loader2,{className:"size-4 animate-spin"}):(0,s.jsx)(r.Plus,{className:"size-4"}),"New Agent"]}),(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(S.Button,{variant:"outline",onClick:()=>{G||eV(),er(!0)},className:"h-9 px-2.5",children:(0,s.jsx)(v.ListChecks,{className:"size-4"})})}),(0,s.jsx)(L.TooltipContent,{side:"bottom",children:"New Task"})]})})]})]}),eQ&&(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 w-full",children:[(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(S.Button,{size:"icon",variant:"ghost",onClick:E,className:"size-8 mx-auto",children:(0,s.jsx)(h.PanelLeft,{className:"size-4"})})}),(0,s.jsxs)(L.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:Z,src:"/sparkecode.mp4",muted:!0,loop:!0,playsInline:!0,className:(0,I.cn)("absolute inset-0 size-full object-cover transition-opacity duration-300",eE?"opacity-100":"opacity-0")})]}),(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(S.Button,{size:"icon",onClick:eU,disabled:O,className:"size-8 mx-auto",children:O?(0,s.jsx)(o.Loader2,{className:"size-4 animate-spin"}):(0,s.jsx)(r.Plus,{className:"size-4"})})}),(0,s.jsx)(L.TooltipContent,{side:"right",children:"New Agent"})]})}),(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(S.Button,{size:"icon",variant:"outline",onClick:()=>{G||eV(),er(!0)},className:"size-8 mx-auto",children:(0,s.jsx)(v.ListChecks,{className:"size-4"})})}),(0,s.jsx)(L.TooltipContent,{side:"right",children:"New Task"})]})})]})]}),(0,s.jsx)(C.Dialog,{open:U,onOpenChange:e=>{W(e),e&&eH()},children:(0,s.jsxs)(C.DialogContent,{className:"sm:max-w-md",children:[(0,s.jsx)(C.DialogHeader,{children:(0,s.jsxs)(C.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)(c.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)(z.Label,{htmlFor:"name",className:"text-sm font-medium",children:"Session Name"}),(0,s.jsx)(T.Input,{id:"name",placeholder:"My Coding Project (optional)",value:_,onChange:e=>ee(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)(z.Label,{className:"text-sm font-medium",children:"Model"}),(0,s.jsxs)(M.Select,{value:es,onValueChange:et,children:[(0,s.jsx)(M.SelectTrigger,{className:"transition-all hover:border-primary/50",children:(0,s.jsx)(M.SelectValue,{placeholder:"Select a model"})}),(0,s.jsx)(M.SelectContent,{children:G?.availableModels.map(e=>(0,s.jsx)(M.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)(z.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:G?.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)(w.Switch,{checked:ea[e.id]??!1,onCheckedChange:()=>eY(e.id)})]},e.id))})]}),(0,s.jsxs)(S.Button,{onClick:eW,disabled:O,className:"w-full",children:[O?(0,s.jsx)(o.Loader2,{className:"size-4 animate-spin mr-2"}):(0,s.jsx)(r.Plus,{className:"size-4 mr-2"}),"Create Session"]})]})]})}),(0,s.jsx)(C.Dialog,{open:el,onOpenChange:e=>{er(e),e&&eJ()},children:(0,s.jsxs)(C.DialogContent,{className:"sm:max-w-lg",children:[(0,s.jsx)(C.DialogHeader,{children:(0,s.jsxs)(C.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)(v.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)(z.Label,{htmlFor:"task-prompt",className:"text-sm font-medium",children:"What should the agent do?"}),(0,s.jsx)(A.Textarea,{id:"task-prompt",placeholder:"e.g. Refactor the auth module to use JWT tokens...",value:en,onChange:e=>ed(e.target.value),rows:3,autoFocus:!0})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(z.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,I.cn)("rounded-md border bg-muted/30 overflow-hidden transition-colors",ex&&"border-red-500"),children:(0,s.jsx)(D.VisualJson,{value:ec,onChange:e=>{em(e),eh("")},children:(0,s.jsx)(D.TreeView,{className:"h-44 text-sm"})})}),ex&&(0,s.jsx)("p",{className:"text-xs text-red-500 mt-1",children:ex})]}),(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)(z.Label,{className:"text-xs text-muted-foreground",children:"Model"}),(0,s.jsxs)(M.Select,{value:ef,onValueChange:eN,children:[(0,s.jsx)(M.SelectTrigger,{className:"h-9",children:(0,s.jsx)(M.SelectValue,{placeholder:"Select a model"})}),(0,s.jsx)(M.SelectContent,{children:G?.availableModels.map(e=>(0,s.jsx)(M.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)(z.Label,{htmlFor:"task-name",className:"text-xs text-muted-foreground",children:"Name"}),(0,s.jsx)(T.Input,{id:"task-name",placeholder:"Optional",value:ej,onChange:e=>eg(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)(b.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)(z.Label,{htmlFor:"task-webhook",className:"text-xs text-muted-foreground",children:"Webhook URL"}),(0,s.jsx)(T.Input,{id:"task-webhook",placeholder:"https://...",value:eu,onChange:e=>ep(e.target.value),className:"h-9"})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(z.Label,{htmlFor:"task-iterations",className:"text-xs text-muted-foreground",children:"Max iterations"}),(0,s.jsx)(T.Input,{id:"task-iterations",type:"number",min:1,max:500,value:ev,onChange:e=>eb(e.target.value),className:"h-9"})]})]})]}),(0,s.jsx)(S.Button,{onClick:eG,disabled:ey||!en.trim(),className:"w-full",children:ey?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Loader2,{className:"size-4 animate-spin mr-2"}),"Creating..."]}):"Start Task"})]})]})}),(0,s.jsx)(k.SidebarContent,{className:"px-2",children:(0,s.jsx)(k.SidebarGroup,{className:"p-0",children:(0,s.jsx)(k.SidebarGroupContent,{children:(0,s.jsx)(k.SidebarMenu,{className:"gap-1",children:K?(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===V.length?!eQ&&(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"}),eE&&(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"})]}):V.map(e=>{let t,a,l,r,o=e.id===e$,c=Y===e.id,m=!0===e.isStreaming,x=!eQ&&(c||o);return(0,s.jsx)(k.SidebarMenuItem,{onMouseEnter:()=>Q(e.id),onMouseLeave:()=>Q(null),children:eQ?(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(i.default,{href:`${eq}/${e.id}`,className:(0,I.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)(n.MessageSquare,{className:(0,I.cn)("size-4",o?"text-primary":"text-muted-foreground")})})}),(0,s.jsxs)(L.TooltipContent,{side:"right",children:[e.name||"Untitled",m&&" (Running)"]})]})}):(0,s.jsx)(k.SidebarMenuButton,{asChild:!0,isActive:o,className:(0,I.cn)("h-9 transition-all duration-150","hover:bg-accent/60",o&&"bg-accent",m&&!o&&"bg-emerald-500/5"),children:(0,s.jsxs)(i.default,{href:`${eq}/${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)(n.MessageSquare,{className:(0,I.cn)("size-4 shrink-0",o?"text-primary":"text-muted-foreground")}),(0,s.jsx)("span",{className:(0,I.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)(y.Badge,{variant:"outline",className:(0,I.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)(v.ListChecks,{className:"size-2.5"}),"Task"]}),x?(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-6 shrink-0 hover:bg-destructive/10 hover:text-destructive transition-colors",onClick:s=>eX(s,e.id),children:(0,s.jsx)(d.Trash2,{className:"size-3.5"})})}),(0,s.jsx)(L.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:(t=new Date(e.createdAt),r=Math.floor((l=Math.floor((a=Math.floor(Math.floor((new Date().getTime()-t.getTime())/1e3)/60))/60))/24),a<1?"now":a<60?`${a}m`:l<24?`${l}h`:r<7?`${r}d`:`${Math.floor(r/7)}w`)})]})})},e.id)})})})})}),(0,s.jsx)(k.SidebarFooter,{className:(0,I.cn)("border-t border-border/50",eQ?"p-2":"p-3"),children:(0,s.jsx)("div",{className:"flex items-center justify-between",children:eQ?(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 w-full",children:[(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)("div",{className:"flex items-center justify-center",children:(0,s.jsx)("span",{className:(0,I.cn)("size-2 rounded-full",G?.serverConnected?"bg-emerald-500 animate-pulse":"bg-red-500")})})}),(0,s.jsx)(L.TooltipContent,{side:"right",children:G?.serverConnected?"Connected":"Disconnected"})]})}),(0,s.jsx)(C.Dialog,{open:H,onOpenChange:J,children:(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(C.DialogTrigger,{asChild:!0,children:(0,s.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-8",children:(0,s.jsx)(c.Settings,{className:"size-4"})})})}),(0,s.jsx)(L.TooltipContent,{side:"right",children:"Settings"})]})})})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[G?.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:V.length})]}),(0,s.jsxs)(C.Dialog,{open:H,onOpenChange:J,children:[(0,s.jsx)(L.TooltipProvider,{children:(0,s.jsxs)(L.Tooltip,{children:[(0,s.jsx)(L.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(C.DialogTrigger,{asChild:!0,children:(0,s.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-7 hover:bg-accent transition-colors",children:(0,s.jsx)(c.Settings,{className:"size-4"})})})}),(0,s.jsx)(L.TooltipContent,{side:"top",children:"Settings"})]})}),(0,s.jsxs)(C.DialogContent,{className:"sm:max-w-md",children:[(0,s.jsx)(C.DialogHeader,{children:(0,s.jsxs)(C.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)(c.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)(z.Label,{className:"text-sm font-medium",children:"Default Model"}),(0,s.jsxs)(M.Select,{value:es,onValueChange:et,children:[(0,s.jsx)(M.SelectTrigger,{className:"transition-all hover:border-primary/50",children:(0,s.jsx)(M.SelectValue,{placeholder:"Select a model"})}),(0,s.jsx)(M.SelectContent,{children:G?.availableModels.map(e=>(0,s.jsx)(M.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)(z.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:G?.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)(w.Switch,{checked:ea[e.id]??!1,onCheckedChange:()=>eY(e.id)})]},e.id))})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)(z.Label,{className:"flex items-center gap-2 text-sm font-medium",children:[(0,s.jsx)(u.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:eS.map(e=>(0,s.jsx)("div",{className:"py-1.5 hover:bg-muted/50 rounded px-2 -mx-1 transition-colors",children:eT===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)(T.Input,{type:eL?"text":"password",value:ew,onChange:e=>eM(e.target.value),placeholder:"Paste your API key...",className:"pr-8 text-sm font-mono",autoFocus:!0}),(0,s.jsx)(S.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-2 hover:bg-transparent",onClick:()=>eP(!eL),children:eL?(0,s.jsx)(f,{className:"size-4"}):(0,s.jsx)(g.default,{className:"size-4"})})]}),(0,s.jsx)(S.Button,{size:"icon",variant:"ghost",className:"shrink-0",onClick:()=>eO(e.provider),disabled:eA||!ew.trim(),children:eA?(0,s.jsx)(o.Loader2,{className:"size-4 animate-spin"}):(0,s.jsx)(p.Check,{className:"size-4 text-green-500"})}),(0,s.jsx)(S.Button,{size:"icon",variant:"ghost",className:"shrink-0",onClick:eR,children:(0,s.jsx)(j.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,I.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)(S.Button,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>ez(e.provider),children:e.configured?"Update":"Add"})]})},e.provider))})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsxs)(z.Label,{className:"flex items-center gap-2 text-sm font-medium",children:[(0,s.jsx)(N,{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)(w.Switch,{checked:eB,onCheckedChange:eI})]})]}),(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."})]})]})]})]})})})]})}e.s(["SessionsSidebar",()=>q],421722)}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,739963,e=>{"use strict";let o="sparkecoder_api_url",i="http://localhost:3141",a=!1;function t(){if(a)return;a=!0;let e=new URLSearchParams(window.location.search),i=e.get("apiUrl");if(i){localStorage.setItem(o,i),e.delete("apiUrl");let a=e.toString()?`${window.location.pathname}?${e.toString()}`:window.location.pathname;window.history.replaceState({},"",a),console.log(`[SparkECoder] API URL set to: ${i}`)}}function r(){return a||t(),localStorage.getItem(o)||i}let n={availableModels:[{id:"anthropic/claude-opus-4.7",name:"Claude Opus 4.7",provider:"Anthropic"},{id:"anthropic/claude-opus-4-6",name:"Claude Opus 4.6",provider:"Anthropic"},{id:"anthropic/claude-opus-4-5",name:"Claude Opus 4.5",provider:"Anthropic"},{id:"anthropic/claude-sonnet-4",name:"Claude Sonnet 4",provider:"Anthropic"},{id:"anthropic/claude-haiku-4-5",name:"Claude Haiku 4.5",provider:"Anthropic"},{id:"openai/gpt-5-2-codex",name:"GPT-5.2 Codex",provider:"OpenAI"},{id:"google/gemini-3-flash",name:"Gemini 3 Flash",provider:"Google"},{id:"xai/grok-code-fast-1",name:"Grok Code Fast",provider:"xAI"}],availableTools:[{id:"bash",name:"Bash",description:"Execute shell commands",dangerous:!0},{id:"write_file",name:"Write File",description:"Create or edit files",dangerous:!0},{id:"read_file",name:"Read File",description:"Read file contents",dangerous:!1}],defaultModel:"anthropic/claude-opus-4.7",defaultToolApprovals:{},serverConnected:!1,apiKeyConfigured:!1,apiBaseUrl:i};async function l(){let e=r();try{let o=new AbortController,i=setTimeout(()=>o.abort(),3e3),a=await fetch(`${e}/health`,{signal:o.signal});if(clearTimeout(i),!a.ok)return{...n,apiBaseUrl:e};let t=await a.json();return{...n,defaultModel:t.config?.defaultModel||n.defaultModel,defaultToolApprovals:t.config?.defaultToolApprovals||{},serverConnected:!0,apiKeyConfigured:t.apiKeyConfigured??!1,apiBaseUrl:e}}catch{return{...n,apiBaseUrl:e}}}e.s(["getApiUrl",()=>r,"getConfig",()=>l,"initApiUrl",()=>t])},760800,e=>{"use strict";var o=e.i(430878),i=e.i(739963);function a(){return(0,o.useEffect)(()=>{(0,i.initApiUrl)()},[]),null}e.s(["ApiInit",()=>a])}]);
@@ -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 o=e.i(309945),n=Symbol("radix.slottable");function s(e){return l.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===n}var i=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{var n,i;let a,c,d,u=(i=n=`Primitive.${t}`,(a=l.forwardRef((e,t)=>{let{children:r,...n}=e;if(l.isValidElement(r)){var s;let e,i,a=(s=r,(i=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(i=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),c=function(e,t){let r={...t};for(let l in t){let o=e[l],n=t[l];/^on[A-Z]/.test(l)?o&&n?r[l]=(...e)=>{let t=n(...e);return o(...e),t}:o&&(r[l]=o):"style"===l?r[l]={...o,...n}:"className"===l&&(r[l]=[o,n].filter(Boolean).join(" "))}return{...e,...r}}(n,r.props);return r.type!==l.Fragment&&(c.ref=t?(0,o.composeRefs)(t,a):a),l.cloneElement(r,c)}return l.Children.count(r)>1?l.Children.only(null):null})).displayName=`${i}.SlotClone`,c=a,(d=l.forwardRef((e,t)=>{let{children:o,...n}=e,i=l.Children.toArray(o),a=i.find(s);if(a){let e=a.props.children,o=i.map(t=>t!==a?t:l.Children.count(e)>1?l.Children.only(null):l.isValidElement(e)?e.props.children:null);return(0,r.jsx)(c,{...n,ref:t,children:l.isValidElement(e)?l.cloneElement(e,void 0,o):null})}return(0,r.jsx)(c,{...n,ref:t,children:o})})).displayName=`${n}.Slot`,d),p=l.forwardRef((e,l)=>{let{asChild:o,...n}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,r.jsx)(o?u:t,{...n,ref:l})});return p.displayName=`Primitive.${t}`,{...e,[t]:p}},{}),a=e.i(395509),c=e.i(897462),d=e.i(542899),u=e.i(995945),p=e.i(992421),f=e.i(241416),m="ScrollArea",[h,x]=function(e,t=[]){let o=[],n=()=>{let t=o.map(e=>l.createContext(e));return function(r){let o=r?.[e]||t;return l.useMemo(()=>({[`__scope${e}`]:{...r,[e]:o}}),[r,o])}};return n.scopeName=e,[function(t,n){let s=l.createContext(n),i=o.length;o=[...o,n];let a=t=>{let{scope:o,children:n,...a}=t,c=o?.[e]?.[i]||s,d=l.useMemo(()=>a,Object.values(a));return(0,r.jsx)(c.Provider,{value:d,children:n})};return a.displayName=t+"Provider",[a,function(r,o){let a=o?.[e]?.[i]||s,c=l.useContext(a);if(c)return c;if(void 0!==n)return n;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 o=r.reduce((t,{useScope:r,scopeName:l})=>{let o=r(e)[`__scope${l}`];return{...t,...o}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return r.scopeName=t.scopeName,r}(n,...t)]}(m),[v,g]=h(m),w=l.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:s="hover",dir:a,scrollHideDelay:c=600,...u}=e,[p,f]=l.useState(null),[m,h]=l.useState(null),[x,g]=l.useState(null),[w,b]=l.useState(null),[y,j]=l.useState(null),[S,C]=l.useState(0),[N,E]=l.useState(0),[R,T]=l.useState(!1),[P,k]=l.useState(!1),A=(0,o.useComposedRefs)(t,e=>f(e)),L=(0,d.useDirection)(a);return(0,r.jsx)(v,{scope:n,type:s,dir:L,scrollHideDelay:c,scrollArea:p,viewport:m,onViewportChange:h,content:x,onContentChange:g,scrollbarX:w,onScrollbarXChange:b,scrollbarXEnabled:R,onScrollbarXEnabledChange:T,scrollbarY:y,onScrollbarYChange:j,scrollbarYEnabled:P,onScrollbarYEnabledChange:k,onCornerWidthChange:C,onCornerHeightChange:E,children:(0,r.jsx)(i.div,{dir:L,...u,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":S+"px","--radix-scroll-area-corner-height":N+"px",...e.style}})})});w.displayName=m;var b="ScrollAreaViewport",y=l.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:s,nonce:a,...c}=e,d=g(b,n),u=l.useRef(null),p=(0,o.useComposedRefs)(t,u,d.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:a}),(0,r.jsx)(i.div,{"data-radix-scroll-area-viewport":"",...c,ref:p,style:{overflowX:d.scrollbarXEnabled?"scroll":"hidden",overflowY:d.scrollbarYEnabled?"scroll":"hidden",...e.style},children:(0,r.jsx)("div",{ref:d.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});y.displayName=b;var j="ScrollAreaScrollbar",S=l.forwardRef((e,t)=>{let{forceMount:o,...n}=e,s=g(j,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:a}=s,c="horizontal"===e.orientation;return l.useEffect(()=>(c?i(!0):a(!0),()=>{c?i(!1):a(!1)}),[c,i,a]),"hover"===s.type?(0,r.jsx)(C,{...n,ref:t,forceMount:o}):"scroll"===s.type?(0,r.jsx)(N,{...n,ref:t,forceMount:o}):"auto"===s.type?(0,r.jsx)(E,{...n,ref:t,forceMount:o}):"always"===s.type?(0,r.jsx)(R,{...n,ref:t}):null});S.displayName=j;var C=l.forwardRef((e,t)=>{let{forceMount:o,...n}=e,s=g(j,e.__scopeScrollArea),[i,c]=l.useState(!1);return l.useEffect(()=>{let e=s.scrollArea,t=0;if(e){let r=()=>{window.clearTimeout(t),c(!0)},l=()=>{t=window.setTimeout(()=>c(!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)(a.Presence,{present:o||i,children:(0,r.jsx)(E,{"data-state":i?"visible":"hidden",...n,ref:t})})}),N=l.forwardRef((e,t)=>{var o;let{forceMount:n,...s}=e,i=g(j,e.__scopeScrollArea),c="horizontal"===e.orientation,d=V(()=>p("SCROLL_END"),100),[u,p]=(o={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)=>o[e][t]??e,"hidden"));return l.useEffect(()=>{if("idle"===u){let e=window.setTimeout(()=>p("HIDE"),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[u,i.scrollHideDelay,p]),l.useEffect(()=>{let e=i.viewport,t=c?"scrollLeft":"scrollTop";if(e){let r=e[t],l=()=>{let l=e[t];r!==l&&(p("SCROLL"),d()),r=l};return e.addEventListener("scroll",l),()=>e.removeEventListener("scroll",l)}},[i.viewport,c,p,d]),(0,r.jsx)(a.Presence,{present:n||"hidden"!==u,children:(0,r.jsx)(R,{"data-state":"hidden"===u?"hidden":"visible",...s,ref:t,onPointerEnter:(0,f.composeEventHandlers)(e.onPointerEnter,()=>p("POINTER_ENTER")),onPointerLeave:(0,f.composeEventHandlers)(e.onPointerLeave,()=>p("POINTER_LEAVE"))})})}),E=l.forwardRef((e,t)=>{let o=g(j,e.__scopeScrollArea),{forceMount:n,...s}=e,[i,c]=l.useState(!1),d="horizontal"===e.orientation,u=V(()=>{if(o.viewport){let e=o.viewport.offsetWidth<o.viewport.scrollWidth,t=o.viewport.offsetHeight<o.viewport.scrollHeight;c(d?e:t)}},10);return Y(o.viewport,u),Y(o.content,u),(0,r.jsx)(a.Presence,{present:n||i,children:(0,r.jsx)(R,{"data-state":i?"visible":"hidden",...s,ref:t})})}),R=l.forwardRef((e,t)=>{let{orientation:o="vertical",...n}=e,s=g(j,e.__scopeScrollArea),i=l.useRef(null),a=l.useRef(0),[c,d]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=$(c.viewport,c.content),p={...n,sizes:c,onSizesChange:d,hasThumb:!!(u>0&&u<1),onThumbChange:e=>i.current=e,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:e=>a.current=e};function f(e,t){return function(e,t,r,l="ltr"){let o=O(r),n=t||o/2,s=r.scrollbar.paddingStart+n,i=r.scrollbar.size-r.scrollbar.paddingEnd-(o-n),a=r.content-r.viewport;return B([s,i],"ltr"===l?[0,a]:[-1*a,0])(e)}(e,a.current,c,t)}return"horizontal"===o?(0,r.jsx)(T,{...p,ref:t,onThumbPositionChange:()=>{if(s.viewport&&i.current){let e=F(s.viewport.scrollLeft,c,s.dir);i.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{s.viewport&&(s.viewport.scrollLeft=e)},onDragScroll:e=>{s.viewport&&(s.viewport.scrollLeft=f(e,s.dir))}}):"vertical"===o?(0,r.jsx)(P,{...p,ref:t,onThumbPositionChange:()=>{if(s.viewport&&i.current){let e=F(s.viewport.scrollTop,c);i.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{s.viewport&&(s.viewport.scrollTop=e)},onDragScroll:e=>{s.viewport&&(s.viewport.scrollTop=f(e))}}):null}),T=l.forwardRef((e,t)=>{let{sizes:n,onSizesChange:s,...i}=e,a=g(j,e.__scopeScrollArea),[c,d]=l.useState(),u=l.useRef(null),p=(0,o.useComposedRefs)(t,u,a.onScrollbarXChange);return l.useEffect(()=>{u.current&&d(getComputedStyle(u.current))},[u]),(0,r.jsx)(L,{"data-orientation":"horizontal",...i,ref:p,sizes:n,style:{bottom:0,left:"rtl"===a.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===a.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":O(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,r)=>{if(a.viewport){var l,o;let n=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(n),l=n,o=r,l>0&&l<o&&t.preventDefault()}},onResize:()=>{u.current&&a.viewport&&c&&s({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:u.current.clientWidth,paddingStart:W(c.paddingLeft),paddingEnd:W(c.paddingRight)}})}})}),P=l.forwardRef((e,t)=>{let{sizes:n,onSizesChange:s,...i}=e,a=g(j,e.__scopeScrollArea),[c,d]=l.useState(),u=l.useRef(null),p=(0,o.useComposedRefs)(t,u,a.onScrollbarYChange);return l.useEffect(()=>{u.current&&d(getComputedStyle(u.current))},[u]),(0,r.jsx)(L,{"data-orientation":"vertical",...i,ref:p,sizes:n,style:{top:0,right:"ltr"===a.dir?0:void 0,left:"rtl"===a.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":O(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,r)=>{if(a.viewport){var l,o;let n=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(n),l=n,o=r,l>0&&l<o&&t.preventDefault()}},onResize:()=>{u.current&&a.viewport&&c&&s({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:u.current.clientHeight,paddingStart:W(c.paddingTop),paddingEnd:W(c.paddingBottom)}})}})}),[k,A]=h(j),L=l.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:s,hasThumb:a,onThumbChange:d,onThumbPointerUp:u,onThumbPointerDown:p,onThumbPositionChange:m,onDragScroll:h,onWheelScroll:x,onResize:v,...w}=e,b=g(j,n),[y,S]=l.useState(null),C=(0,o.useComposedRefs)(t,e=>S(e)),N=l.useRef(null),E=l.useRef(""),R=b.viewport,T=s.content-s.viewport,P=(0,c.useCallbackRef)(x),A=(0,c.useCallbackRef)(m),L=V(v,10);function _(e){N.current&&h({x:e.clientX-N.current.left,y:e.clientY-N.current.top})}return l.useEffect(()=>{let e=e=>{let t=e.target;y?.contains(t)&&P(e,T)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[R,y,T,P]),l.useEffect(A,[s,A]),Y(y,L),Y(b.content,L),(0,r.jsx)(k,{scope:n,scrollbar:y,hasThumb:a,onThumbChange:(0,c.useCallbackRef)(d),onThumbPointerUp:(0,c.useCallbackRef)(u),onThumbPositionChange:A,onThumbPointerDown:(0,c.useCallbackRef)(p),children:(0,r.jsx)(i.div,{...w,ref:C,style:{position:"absolute",...w.style},onPointerDown:(0,f.composeEventHandlers)(e.onPointerDown,e=>{0===e.button&&(e.target.setPointerCapture(e.pointerId),N.current=y.getBoundingClientRect(),E.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",b.viewport&&(b.viewport.style.scrollBehavior="auto"),_(e))}),onPointerMove:(0,f.composeEventHandlers)(e.onPointerMove,_),onPointerUp:(0,f.composeEventHandlers)(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=E.current,b.viewport&&(b.viewport.style.scrollBehavior=""),N.current=null})})})}),_="ScrollAreaThumb",D=l.forwardRef((e,t)=>{let{forceMount:l,...o}=e,n=A(_,e.__scopeScrollArea);return(0,r.jsx)(a.Presence,{present:l||n.hasThumb,children:(0,r.jsx)(z,{ref:t,...o})})}),z=l.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:s,...a}=e,c=g(_,n),d=A(_,n),{onThumbPositionChange:u}=d,p=(0,o.useComposedRefs)(t,e=>d.onThumbChange(e)),m=l.useRef(void 0),h=V(()=>{m.current&&(m.current(),m.current=void 0)},100);return l.useEffect(()=>{let e=c.viewport;if(e){let t=()=>{h(),m.current||(m.current=U(e,u),u())};return u(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}},[c.viewport,h,u]),(0,r.jsx)(i.div,{"data-state":d.hasThumb?"visible":"hidden",...a,ref:p,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:(0,f.composeEventHandlers)(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),r=e.clientX-t.left,l=e.clientY-t.top;d.onThumbPointerDown({x:r,y:l})}),onPointerUp:(0,f.composeEventHandlers)(e.onPointerUp,d.onThumbPointerUp)})});D.displayName=_;var I="ScrollAreaCorner",H=l.forwardRef((e,t)=>{let l=g(I,e.__scopeScrollArea),o=!!(l.scrollbarX&&l.scrollbarY);return"scroll"!==l.type&&o?(0,r.jsx)(M,{...e,ref:t}):null});H.displayName=I;var M=l.forwardRef((e,t)=>{let{__scopeScrollArea:o,...n}=e,s=g(I,o),[a,c]=l.useState(0),[d,u]=l.useState(0),p=!!(a&&d);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),c(e)}),p?(0,r.jsx)(i.div,{...n,ref:t,style:{width:a,height:d,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),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=t.scrollbar.size-o,s=t.content-t.viewport,i=(0,p.clamp)(e,"ltr"===r?[0,s]:[-1*s,0]);return B([0,s],[0,n-l])(i)}function B(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 U=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},l=0;return!function o(){let n={left:e.scrollLeft,top:e.scrollTop},s=r.left!==n.left,i=r.top!==n.top;(s||i)&&t(),r=n,l=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(l)};function V(e,t){let r=(0,c.useCallbackRef)(e),o=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(o.current),[]),l.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(r,t)},[r,t])}function Y(e,t){let r=(0,c.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)(w,{"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),o=e.i(292623),n=e.i(504561),s=e.i(996720),i=e.i(461957),a=e.i(846193),c=e.i(77589),c=c,d=e.i(416667),d=d,u=e.i(667249),p=e.i(191729),p=p,f=e.i(904781),m=e.i(87614),h=e.i(666904),x=e.i(77982),v=e.i(772857),g=e.i(524741),w=e.i(739963),b=e.i(300739),y=e.i(555552);function j(){let e=(0,l.useRouter)(),j=(0,l.useSearchParams)(),{sessions:S,isLoading:C}=(0,b.useSessions)(),[N,E]=(0,r.useState)(!1),[R,T]=(0,r.useState)(null),[P,k]=(0,r.useState)(""),[A,L]=(0,r.useState)(!1),[_,D]=(0,r.useState)(null),[z,I]=(0,r.useState)(null),H=(0,r.useRef)(!1),M=async(e,t)=>{e.preventDefault(),e.stopPropagation();try{await (0,g.deleteSession)(t),(0,b.mutateSessions)()}catch(e){console.error("Failed to delete session:",e)}};(0,r.useEffect)(()=>{(0,w.getConfig)().then(T)},[]),(0,r.useEffect)(()=>{j.has("new")&&R&&R.apiKeyConfigured&&!H.current&&!N&&(H.current=!0,(async()=>{E(!0);try{let t=await (0,g.createSession)({name:`Session ${S.length+1}`,model:R.defaultModel||"anthropic/claude-opus-4-6",toolApprovals:R.defaultToolApprovals||{}});(0,b.mutateSessions)(),e.replace(`/session/${t.id}`)}catch(e){console.error("Failed to auto-create session:",e),E(!1)}})())},[j,R,S.length,N,e]),(0,r.useEffect)(()=>{j.has("latest")&&!C&&S.length>0&&e.replace(`/session/${S[0].id}`)},[j,C,S,e]);let W=async()=>{if(P.trim()&&!A){L(!0),D(null);try{if((await (0,g.setApiKey)("ai-gateway",P.trim())).success){let e=await (0,w.getConfig)();T(e),k("")}else D("Failed to save API key. Please try again.")}catch(e){D("Failed to save API key. Please try again.")}finally{L(!1)}}},$=async()=>{if(!N){E(!0);try{let t=await (0,g.createSession)({name:`Session ${S.length+1}`,model:R?.defaultModel||"anthropic/claude-opus-4-6",toolApprovals:R?.defaultToolApprovals||{}});(0,b.mutateSessions)(),e.push(`/session/${t.id}`)}catch(e){console.error("Failed to create session:",e)}finally{E(!1)}}};return((0,r.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"t"===e.key&&(e.preventDefault(),$())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[N,S.length,R]),R&&!R.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)(o.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)(a.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)(x.Input,{type:"password",placeholder:"Enter your AI Gateway API key",value:P,onChange:e=>k(e.target.value),onKeyDown:e=>"Enter"===e.key&&W(),className:"flex-1"}),(0,t.jsx)(h.Button,{onClick:W,disabled:!P.trim()||A,children:A?(0,t.jsx)(i.Loader2,{className:"size-4 animate-spin"}):"Save"})]}),_&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-destructive mb-3",children:[(0,t.jsx)(d.default,{className:"size-4"}),_]}),(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)(c.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)(m.TooltipProvider,{children:(0,t.jsxs)(m.Tooltip,{children:[(0,t.jsx)(m.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)(o.default,{src:"/sparke-coder.png",alt:"Sparke - AI Coding Assistant",fill:!0,className:"object-cover sparke-idle",priority:!0})})]})}),(0,t.jsx)(m.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)(h.Button,{size:"lg",onClick:$,disabled:N,className:"gap-2 px-8",children:N?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(i.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"]}),!C&&S.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,y.cn)(S.length>5?"h-[280px]":""),children:(0,t.jsx)("div",{className:"divide-y divide-border/40",children:S.map(e=>{let r,l,o,s,i=z===e.id,a=!0===e.isStreaming;return(0,t.jsxs)(n.default,{href:`/session/${e.id}`,className:(0,y.cn)("flex items-center gap-3 p-3 transition-colors hover:bg-accent/50 group",a&&"bg-emerald-500/5"),onMouseEnter:()=>I(e.id),onMouseLeave:()=>I(null),children:[(0,t.jsx)("div",{className:(0,y.cn)("size-9 rounded-lg flex items-center justify-center shrink-0 transition-colors",a?"bg-emerald-500/10":"bg-muted/60 group-hover:bg-muted"),children:a?(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,y.cn)("text-sm font-medium truncate",a&&"text-emerald-600 dark:text-emerald-400"),children:e.name||"Untitled Session"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:a?(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((o=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===o?"1 hour ago":o<24?`${o} hours ago`:1===s?"yesterday":s<7?`${s} days ago`:`${Math.floor(s/7)} weeks ago`)})]}),i&&(0,t.jsx)(m.TooltipProvider,{children:(0,t.jsxs)(m.Tooltip,{children:[(0,t.jsx)(m.TooltipTrigger,{asChild:!0,children:(0,t.jsx)(h.Button,{size:"icon",variant:"ghost",className:"size-7 shrink-0 hover:bg-destructive/10 hover:text-destructive transition-colors",onClick:t=>M(t,e.id),children:(0,t.jsx)(f.Trash2,{className:"size-3.5"})})}),(0,t.jsx)(m.TooltipContent,{children:"Delete session"})]})})]},e.id)})})})})]})]})})}function S(){return(0,t.jsx)(r.Suspense,{fallback:(0,t.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,t.jsx)(i.Loader2,{className:"size-6 animate-spin text-muted-foreground"})}),children:(0,t.jsx)(j,{})})}e.s(["default",()=>S],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 o=e.i(309945),n=Symbol("radix.slottable");function s(e){return l.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===n}var i=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{var n,i;let a,c,d,u=(i=n=`Primitive.${t}`,(a=l.forwardRef((e,t)=>{let{children:r,...n}=e;if(l.isValidElement(r)){var s;let e,i,a=(s=r,(i=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(i=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),c=function(e,t){let r={...t};for(let l in t){let o=e[l],n=t[l];/^on[A-Z]/.test(l)?o&&n?r[l]=(...e)=>{let t=n(...e);return o(...e),t}:o&&(r[l]=o):"style"===l?r[l]={...o,...n}:"className"===l&&(r[l]=[o,n].filter(Boolean).join(" "))}return{...e,...r}}(n,r.props);return r.type!==l.Fragment&&(c.ref=t?(0,o.composeRefs)(t,a):a),l.cloneElement(r,c)}return l.Children.count(r)>1?l.Children.only(null):null})).displayName=`${i}.SlotClone`,c=a,(d=l.forwardRef((e,t)=>{let{children:o,...n}=e,i=l.Children.toArray(o),a=i.find(s);if(a){let e=a.props.children,o=i.map(t=>t!==a?t:l.Children.count(e)>1?l.Children.only(null):l.isValidElement(e)?e.props.children:null);return(0,r.jsx)(c,{...n,ref:t,children:l.isValidElement(e)?l.cloneElement(e,void 0,o):null})}return(0,r.jsx)(c,{...n,ref:t,children:o})})).displayName=`${n}.Slot`,d),p=l.forwardRef((e,l)=>{let{asChild:o,...n}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,r.jsx)(o?u:t,{...n,ref:l})});return p.displayName=`Primitive.${t}`,{...e,[t]:p}},{}),a=e.i(395509),c=e.i(897462),d=e.i(542899),u=e.i(995945),p=e.i(992421),f=e.i(241416),m="ScrollArea",[h,x]=function(e,t=[]){let o=[],n=()=>{let t=o.map(e=>l.createContext(e));return function(r){let o=r?.[e]||t;return l.useMemo(()=>({[`__scope${e}`]:{...r,[e]:o}}),[r,o])}};return n.scopeName=e,[function(t,n){let s=l.createContext(n),i=o.length;o=[...o,n];let a=t=>{let{scope:o,children:n,...a}=t,c=o?.[e]?.[i]||s,d=l.useMemo(()=>a,Object.values(a));return(0,r.jsx)(c.Provider,{value:d,children:n})};return a.displayName=t+"Provider",[a,function(r,o){let a=o?.[e]?.[i]||s,c=l.useContext(a);if(c)return c;if(void 0!==n)return n;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 o=r.reduce((t,{useScope:r,scopeName:l})=>{let o=r(e)[`__scope${l}`];return{...t,...o}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return r.scopeName=t.scopeName,r}(n,...t)]}(m),[v,g]=h(m),w=l.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:s="hover",dir:a,scrollHideDelay:c=600,...u}=e,[p,f]=l.useState(null),[m,h]=l.useState(null),[x,g]=l.useState(null),[w,b]=l.useState(null),[y,j]=l.useState(null),[S,C]=l.useState(0),[N,E]=l.useState(0),[R,T]=l.useState(!1),[P,k]=l.useState(!1),A=(0,o.useComposedRefs)(t,e=>f(e)),L=(0,d.useDirection)(a);return(0,r.jsx)(v,{scope:n,type:s,dir:L,scrollHideDelay:c,scrollArea:p,viewport:m,onViewportChange:h,content:x,onContentChange:g,scrollbarX:w,onScrollbarXChange:b,scrollbarXEnabled:R,onScrollbarXEnabledChange:T,scrollbarY:y,onScrollbarYChange:j,scrollbarYEnabled:P,onScrollbarYEnabledChange:k,onCornerWidthChange:C,onCornerHeightChange:E,children:(0,r.jsx)(i.div,{dir:L,...u,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":S+"px","--radix-scroll-area-corner-height":N+"px",...e.style}})})});w.displayName=m;var b="ScrollAreaViewport",y=l.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:s,nonce:a,...c}=e,d=g(b,n),u=l.useRef(null),p=(0,o.useComposedRefs)(t,u,d.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:a}),(0,r.jsx)(i.div,{"data-radix-scroll-area-viewport":"",...c,ref:p,style:{overflowX:d.scrollbarXEnabled?"scroll":"hidden",overflowY:d.scrollbarYEnabled?"scroll":"hidden",...e.style},children:(0,r.jsx)("div",{ref:d.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});y.displayName=b;var j="ScrollAreaScrollbar",S=l.forwardRef((e,t)=>{let{forceMount:o,...n}=e,s=g(j,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:a}=s,c="horizontal"===e.orientation;return l.useEffect(()=>(c?i(!0):a(!0),()=>{c?i(!1):a(!1)}),[c,i,a]),"hover"===s.type?(0,r.jsx)(C,{...n,ref:t,forceMount:o}):"scroll"===s.type?(0,r.jsx)(N,{...n,ref:t,forceMount:o}):"auto"===s.type?(0,r.jsx)(E,{...n,ref:t,forceMount:o}):"always"===s.type?(0,r.jsx)(R,{...n,ref:t}):null});S.displayName=j;var C=l.forwardRef((e,t)=>{let{forceMount:o,...n}=e,s=g(j,e.__scopeScrollArea),[i,c]=l.useState(!1);return l.useEffect(()=>{let e=s.scrollArea,t=0;if(e){let r=()=>{window.clearTimeout(t),c(!0)},l=()=>{t=window.setTimeout(()=>c(!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)(a.Presence,{present:o||i,children:(0,r.jsx)(E,{"data-state":i?"visible":"hidden",...n,ref:t})})}),N=l.forwardRef((e,t)=>{var o;let{forceMount:n,...s}=e,i=g(j,e.__scopeScrollArea),c="horizontal"===e.orientation,d=V(()=>p("SCROLL_END"),100),[u,p]=(o={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)=>o[e][t]??e,"hidden"));return l.useEffect(()=>{if("idle"===u){let e=window.setTimeout(()=>p("HIDE"),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[u,i.scrollHideDelay,p]),l.useEffect(()=>{let e=i.viewport,t=c?"scrollLeft":"scrollTop";if(e){let r=e[t],l=()=>{let l=e[t];r!==l&&(p("SCROLL"),d()),r=l};return e.addEventListener("scroll",l),()=>e.removeEventListener("scroll",l)}},[i.viewport,c,p,d]),(0,r.jsx)(a.Presence,{present:n||"hidden"!==u,children:(0,r.jsx)(R,{"data-state":"hidden"===u?"hidden":"visible",...s,ref:t,onPointerEnter:(0,f.composeEventHandlers)(e.onPointerEnter,()=>p("POINTER_ENTER")),onPointerLeave:(0,f.composeEventHandlers)(e.onPointerLeave,()=>p("POINTER_LEAVE"))})})}),E=l.forwardRef((e,t)=>{let o=g(j,e.__scopeScrollArea),{forceMount:n,...s}=e,[i,c]=l.useState(!1),d="horizontal"===e.orientation,u=V(()=>{if(o.viewport){let e=o.viewport.offsetWidth<o.viewport.scrollWidth,t=o.viewport.offsetHeight<o.viewport.scrollHeight;c(d?e:t)}},10);return Y(o.viewport,u),Y(o.content,u),(0,r.jsx)(a.Presence,{present:n||i,children:(0,r.jsx)(R,{"data-state":i?"visible":"hidden",...s,ref:t})})}),R=l.forwardRef((e,t)=>{let{orientation:o="vertical",...n}=e,s=g(j,e.__scopeScrollArea),i=l.useRef(null),a=l.useRef(0),[c,d]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=$(c.viewport,c.content),p={...n,sizes:c,onSizesChange:d,hasThumb:!!(u>0&&u<1),onThumbChange:e=>i.current=e,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:e=>a.current=e};function f(e,t){return function(e,t,r,l="ltr"){let o=O(r),n=t||o/2,s=r.scrollbar.paddingStart+n,i=r.scrollbar.size-r.scrollbar.paddingEnd-(o-n),a=r.content-r.viewport;return B([s,i],"ltr"===l?[0,a]:[-1*a,0])(e)}(e,a.current,c,t)}return"horizontal"===o?(0,r.jsx)(T,{...p,ref:t,onThumbPositionChange:()=>{if(s.viewport&&i.current){let e=F(s.viewport.scrollLeft,c,s.dir);i.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{s.viewport&&(s.viewport.scrollLeft=e)},onDragScroll:e=>{s.viewport&&(s.viewport.scrollLeft=f(e,s.dir))}}):"vertical"===o?(0,r.jsx)(P,{...p,ref:t,onThumbPositionChange:()=>{if(s.viewport&&i.current){let e=F(s.viewport.scrollTop,c);i.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{s.viewport&&(s.viewport.scrollTop=e)},onDragScroll:e=>{s.viewport&&(s.viewport.scrollTop=f(e))}}):null}),T=l.forwardRef((e,t)=>{let{sizes:n,onSizesChange:s,...i}=e,a=g(j,e.__scopeScrollArea),[c,d]=l.useState(),u=l.useRef(null),p=(0,o.useComposedRefs)(t,u,a.onScrollbarXChange);return l.useEffect(()=>{u.current&&d(getComputedStyle(u.current))},[u]),(0,r.jsx)(L,{"data-orientation":"horizontal",...i,ref:p,sizes:n,style:{bottom:0,left:"rtl"===a.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===a.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":O(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,r)=>{if(a.viewport){var l,o;let n=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(n),l=n,o=r,l>0&&l<o&&t.preventDefault()}},onResize:()=>{u.current&&a.viewport&&c&&s({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:u.current.clientWidth,paddingStart:W(c.paddingLeft),paddingEnd:W(c.paddingRight)}})}})}),P=l.forwardRef((e,t)=>{let{sizes:n,onSizesChange:s,...i}=e,a=g(j,e.__scopeScrollArea),[c,d]=l.useState(),u=l.useRef(null),p=(0,o.useComposedRefs)(t,u,a.onScrollbarYChange);return l.useEffect(()=>{u.current&&d(getComputedStyle(u.current))},[u]),(0,r.jsx)(L,{"data-orientation":"vertical",...i,ref:p,sizes:n,style:{top:0,right:"ltr"===a.dir?0:void 0,left:"rtl"===a.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":O(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,r)=>{if(a.viewport){var l,o;let n=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(n),l=n,o=r,l>0&&l<o&&t.preventDefault()}},onResize:()=>{u.current&&a.viewport&&c&&s({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:u.current.clientHeight,paddingStart:W(c.paddingTop),paddingEnd:W(c.paddingBottom)}})}})}),[k,A]=h(j),L=l.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:s,hasThumb:a,onThumbChange:d,onThumbPointerUp:u,onThumbPointerDown:p,onThumbPositionChange:m,onDragScroll:h,onWheelScroll:x,onResize:v,...w}=e,b=g(j,n),[y,S]=l.useState(null),C=(0,o.useComposedRefs)(t,e=>S(e)),N=l.useRef(null),E=l.useRef(""),R=b.viewport,T=s.content-s.viewport,P=(0,c.useCallbackRef)(x),A=(0,c.useCallbackRef)(m),L=V(v,10);function _(e){N.current&&h({x:e.clientX-N.current.left,y:e.clientY-N.current.top})}return l.useEffect(()=>{let e=e=>{let t=e.target;y?.contains(t)&&P(e,T)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[R,y,T,P]),l.useEffect(A,[s,A]),Y(y,L),Y(b.content,L),(0,r.jsx)(k,{scope:n,scrollbar:y,hasThumb:a,onThumbChange:(0,c.useCallbackRef)(d),onThumbPointerUp:(0,c.useCallbackRef)(u),onThumbPositionChange:A,onThumbPointerDown:(0,c.useCallbackRef)(p),children:(0,r.jsx)(i.div,{...w,ref:C,style:{position:"absolute",...w.style},onPointerDown:(0,f.composeEventHandlers)(e.onPointerDown,e=>{0===e.button&&(e.target.setPointerCapture(e.pointerId),N.current=y.getBoundingClientRect(),E.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",b.viewport&&(b.viewport.style.scrollBehavior="auto"),_(e))}),onPointerMove:(0,f.composeEventHandlers)(e.onPointerMove,_),onPointerUp:(0,f.composeEventHandlers)(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=E.current,b.viewport&&(b.viewport.style.scrollBehavior=""),N.current=null})})})}),_="ScrollAreaThumb",D=l.forwardRef((e,t)=>{let{forceMount:l,...o}=e,n=A(_,e.__scopeScrollArea);return(0,r.jsx)(a.Presence,{present:l||n.hasThumb,children:(0,r.jsx)(z,{ref:t,...o})})}),z=l.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:s,...a}=e,c=g(_,n),d=A(_,n),{onThumbPositionChange:u}=d,p=(0,o.useComposedRefs)(t,e=>d.onThumbChange(e)),m=l.useRef(void 0),h=V(()=>{m.current&&(m.current(),m.current=void 0)},100);return l.useEffect(()=>{let e=c.viewport;if(e){let t=()=>{h(),m.current||(m.current=U(e,u),u())};return u(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}},[c.viewport,h,u]),(0,r.jsx)(i.div,{"data-state":d.hasThumb?"visible":"hidden",...a,ref:p,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:(0,f.composeEventHandlers)(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),r=e.clientX-t.left,l=e.clientY-t.top;d.onThumbPointerDown({x:r,y:l})}),onPointerUp:(0,f.composeEventHandlers)(e.onPointerUp,d.onThumbPointerUp)})});D.displayName=_;var I="ScrollAreaCorner",H=l.forwardRef((e,t)=>{let l=g(I,e.__scopeScrollArea),o=!!(l.scrollbarX&&l.scrollbarY);return"scroll"!==l.type&&o?(0,r.jsx)(M,{...e,ref:t}):null});H.displayName=I;var M=l.forwardRef((e,t)=>{let{__scopeScrollArea:o,...n}=e,s=g(I,o),[a,c]=l.useState(0),[d,u]=l.useState(0),p=!!(a&&d);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),c(e)}),p?(0,r.jsx)(i.div,{...n,ref:t,style:{width:a,height:d,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),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=t.scrollbar.size-o,s=t.content-t.viewport,i=(0,p.clamp)(e,"ltr"===r?[0,s]:[-1*s,0]);return B([0,s],[0,n-l])(i)}function B(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 U=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},l=0;return!function o(){let n={left:e.scrollLeft,top:e.scrollTop},s=r.left!==n.left,i=r.top!==n.top;(s||i)&&t(),r=n,l=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(l)};function V(e,t){let r=(0,c.useCallbackRef)(e),o=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(o.current),[]),l.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(r,t)},[r,t])}function Y(e,t){let r=(0,c.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)(w,{"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),o=e.i(292623),n=e.i(504561),s=e.i(996720),i=e.i(461957),a=e.i(846193),c=e.i(77589),c=c,d=e.i(416667),d=d,u=e.i(667249),p=e.i(191729),p=p,f=e.i(904781),m=e.i(87614),h=e.i(666904),x=e.i(77982),v=e.i(772857),g=e.i(524741),w=e.i(739963),b=e.i(300739),y=e.i(555552);function j(){let e=(0,l.useRouter)(),j=(0,l.useSearchParams)(),{sessions:S,isLoading:C}=(0,b.useSessions)(),[N,E]=(0,r.useState)(!1),[R,T]=(0,r.useState)(null),[P,k]=(0,r.useState)(""),[A,L]=(0,r.useState)(!1),[_,D]=(0,r.useState)(null),[z,I]=(0,r.useState)(null),H=(0,r.useRef)(!1),M=async(e,t)=>{e.preventDefault(),e.stopPropagation();try{await (0,g.deleteSession)(t),(0,b.mutateSessions)()}catch(e){console.error("Failed to delete session:",e)}};(0,r.useEffect)(()=>{(0,w.getConfig)().then(T)},[]),(0,r.useEffect)(()=>{j.has("new")&&R&&R.apiKeyConfigured&&!H.current&&!N&&(H.current=!0,(async()=>{E(!0);try{let t=await (0,g.createSession)({name:`Session ${S.length+1}`,model:R.defaultModel||"anthropic/claude-opus-4.7",toolApprovals:R.defaultToolApprovals||{}});(0,b.mutateSessions)(),e.replace(`/session/${t.id}`)}catch(e){console.error("Failed to auto-create session:",e),E(!1)}})())},[j,R,S.length,N,e]),(0,r.useEffect)(()=>{j.has("latest")&&!C&&S.length>0&&e.replace(`/session/${S[0].id}`)},[j,C,S,e]);let W=async()=>{if(P.trim()&&!A){L(!0),D(null);try{if((await (0,g.setApiKey)("ai-gateway",P.trim())).success){let e=await (0,w.getConfig)();T(e),k("")}else D("Failed to save API key. Please try again.")}catch(e){D("Failed to save API key. Please try again.")}finally{L(!1)}}},$=async()=>{if(!N){E(!0);try{let t=await (0,g.createSession)({name:`Session ${S.length+1}`,model:R?.defaultModel||"anthropic/claude-opus-4.7",toolApprovals:R?.defaultToolApprovals||{}});(0,b.mutateSessions)(),e.push(`/session/${t.id}`)}catch(e){console.error("Failed to create session:",e)}finally{E(!1)}}};return((0,r.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"t"===e.key&&(e.preventDefault(),$())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[N,S.length,R]),R&&!R.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)(o.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)(a.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)(x.Input,{type:"password",placeholder:"Enter your AI Gateway API key",value:P,onChange:e=>k(e.target.value),onKeyDown:e=>"Enter"===e.key&&W(),className:"flex-1"}),(0,t.jsx)(h.Button,{onClick:W,disabled:!P.trim()||A,children:A?(0,t.jsx)(i.Loader2,{className:"size-4 animate-spin"}):"Save"})]}),_&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-destructive mb-3",children:[(0,t.jsx)(d.default,{className:"size-4"}),_]}),(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)(c.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)(m.TooltipProvider,{children:(0,t.jsxs)(m.Tooltip,{children:[(0,t.jsx)(m.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)(o.default,{src:"/sparke-coder.png",alt:"Sparke - AI Coding Assistant",fill:!0,className:"object-cover sparke-idle",priority:!0})})]})}),(0,t.jsx)(m.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)(h.Button,{size:"lg",onClick:$,disabled:N,className:"gap-2 px-8",children:N?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(i.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"]}),!C&&S.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,y.cn)(S.length>5?"h-[280px]":""),children:(0,t.jsx)("div",{className:"divide-y divide-border/40",children:S.map(e=>{let r,l,o,s,i=z===e.id,a=!0===e.isStreaming;return(0,t.jsxs)(n.default,{href:`/session/${e.id}`,className:(0,y.cn)("flex items-center gap-3 p-3 transition-colors hover:bg-accent/50 group",a&&"bg-emerald-500/5"),onMouseEnter:()=>I(e.id),onMouseLeave:()=>I(null),children:[(0,t.jsx)("div",{className:(0,y.cn)("size-9 rounded-lg flex items-center justify-center shrink-0 transition-colors",a?"bg-emerald-500/10":"bg-muted/60 group-hover:bg-muted"),children:a?(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,y.cn)("text-sm font-medium truncate",a&&"text-emerald-600 dark:text-emerald-400"),children:e.name||"Untitled Session"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:a?(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((o=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===o?"1 hour ago":o<24?`${o} hours ago`:1===s?"yesterday":s<7?`${s} days ago`:`${Math.floor(s/7)} weeks ago`)})]}),i&&(0,t.jsx)(m.TooltipProvider,{children:(0,t.jsxs)(m.Tooltip,{children:[(0,t.jsx)(m.TooltipTrigger,{asChild:!0,children:(0,t.jsx)(h.Button,{size:"icon",variant:"ghost",className:"size-7 shrink-0 hover:bg-destructive/10 hover:text-destructive transition-colors",onClick:t=>M(t,e.id),children:(0,t.jsx)(f.Trash2,{className:"size-3.5"})})}),(0,t.jsx)(m.TooltipContent,{children:"Delete session"})]})})]},e.id)})})})})]})]})})}function S(){return(0,t.jsx)(r.Suspense,{fallback:(0,t.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,t.jsx)(i.Loader2,{className:"size-6 animate-spin text-muted-foreground"})}),children:(0,t.jsx)(j,{})})}e.s(["default",()=>S],375635)}]);
package/web/package.json CHANGED
@@ -42,7 +42,7 @@
42
42
  "@visual-json/core": "^0.1.1",
43
43
  "@visual-json/react": "^0.1.1",
44
44
  "@xyflow/react": "^12.10.0",
45
- "ai": "^6.0.49",
45
+ "ai": "^6.0.168",
46
46
  "ansi-to-react": "^6.2.6",
47
47
  "class-variance-authority": "^0.7.1",
48
48
  "clsx": "^2.1.1",
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,739963,e=>{"use strict";let o="sparkecoder_api_url",i="http://localhost:3141",a=!1;function t(){if(a)return;a=!0;let e=new URLSearchParams(window.location.search),i=e.get("apiUrl");if(i){localStorage.setItem(o,i),e.delete("apiUrl");let a=e.toString()?`${window.location.pathname}?${e.toString()}`:window.location.pathname;window.history.replaceState({},"",a),console.log(`[SparkECoder] API URL set to: ${i}`)}}function r(){return a||t(),localStorage.getItem(o)||i}let l={availableModels:[{id:"anthropic/claude-opus-4-6",name:"Claude Opus 4.6",provider:"Anthropic"},{id:"anthropic/claude-opus-4-5",name:"Claude Opus 4.5",provider:"Anthropic"},{id:"anthropic/claude-sonnet-4",name:"Claude Sonnet 4",provider:"Anthropic"},{id:"anthropic/claude-haiku-4-5",name:"Claude Haiku 4.5",provider:"Anthropic"},{id:"openai/gpt-5-2-codex",name:"GPT-5.2 Codex",provider:"OpenAI"},{id:"google/gemini-3-flash",name:"Gemini 3 Flash",provider:"Google"},{id:"xai/grok-code-fast-1",name:"Grok Code Fast",provider:"xAI"}],availableTools:[{id:"bash",name:"Bash",description:"Execute shell commands",dangerous:!0},{id:"write_file",name:"Write File",description:"Create or edit files",dangerous:!0},{id:"read_file",name:"Read File",description:"Read file contents",dangerous:!1}],defaultModel:"anthropic/claude-opus-4-6",defaultToolApprovals:{},serverConnected:!1,apiKeyConfigured:!1,apiBaseUrl:i};async function n(){let e=r();try{let o=new AbortController,i=setTimeout(()=>o.abort(),3e3),a=await fetch(`${e}/health`,{signal:o.signal});if(clearTimeout(i),!a.ok)return{...l,apiBaseUrl:e};let t=await a.json();return{...l,defaultModel:t.config?.defaultModel||l.defaultModel,defaultToolApprovals:t.config?.defaultToolApprovals||{},serverConnected:!0,apiKeyConfigured:t.apiKeyConfigured??!1,apiBaseUrl:e}}catch{return{...l,apiBaseUrl:e}}}e.s(["getApiUrl",()=>r,"getConfig",()=>n,"initApiUrl",()=>t])},760800,e=>{"use strict";var o=e.i(430878),i=e.i(739963);function a(){return(0,o.useEffect)(()=>{(0,i.initApiUrl)()},[]),null}e.s(["ApiInit",()=>a])}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,739963,e=>{"use strict";let o="sparkecoder_api_url",i="http://localhost:3141",a=!1;function t(){if(a)return;a=!0;let e=new URLSearchParams(window.location.search),i=e.get("apiUrl");if(i){localStorage.setItem(o,i),e.delete("apiUrl");let a=e.toString()?`${window.location.pathname}?${e.toString()}`:window.location.pathname;window.history.replaceState({},"",a),console.log(`[SparkECoder] API URL set to: ${i}`)}}function r(){return a||t(),localStorage.getItem(o)||i}let l={availableModels:[{id:"anthropic/claude-opus-4-6",name:"Claude Opus 4.6",provider:"Anthropic"},{id:"anthropic/claude-opus-4-5",name:"Claude Opus 4.5",provider:"Anthropic"},{id:"anthropic/claude-sonnet-4",name:"Claude Sonnet 4",provider:"Anthropic"},{id:"anthropic/claude-haiku-4-5",name:"Claude Haiku 4.5",provider:"Anthropic"},{id:"openai/gpt-5-2-codex",name:"GPT-5.2 Codex",provider:"OpenAI"},{id:"google/gemini-3-flash",name:"Gemini 3 Flash",provider:"Google"},{id:"xai/grok-code-fast-1",name:"Grok Code Fast",provider:"xAI"}],availableTools:[{id:"bash",name:"Bash",description:"Execute shell commands",dangerous:!0},{id:"write_file",name:"Write File",description:"Create or edit files",dangerous:!0},{id:"read_file",name:"Read File",description:"Read file contents",dangerous:!1}],defaultModel:"anthropic/claude-opus-4-6",defaultToolApprovals:{},serverConnected:!1,apiKeyConfigured:!1,apiBaseUrl:i};async function n(){let e=r();try{let o=new AbortController,i=setTimeout(()=>o.abort(),3e3),a=await fetch(`${e}/health`,{signal:o.signal});if(clearTimeout(i),!a.ok)return{...l,apiBaseUrl:e};let t=await a.json();return{...l,defaultModel:t.config?.defaultModel||l.defaultModel,defaultToolApprovals:t.config?.defaultToolApprovals||{},serverConnected:!0,apiKeyConfigured:t.apiKeyConfigured??!1,apiBaseUrl:e}}catch{return{...l,apiBaseUrl:e}}}e.s(["getApiUrl",()=>r,"getConfig",()=>n,"initApiUrl",()=>t])},760800,e=>{"use strict";var o=e.i(430878),i=e.i(739963);function a(){return(0,o.useEffect)(()=>{(0,i.initApiUrl)()},[]),null}e.s(["ApiInit",()=>a])}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,739963,e=>{"use strict";let o="sparkecoder_api_url",i="http://localhost:3141",a=!1;function t(){if(a)return;a=!0;let e=new URLSearchParams(window.location.search),i=e.get("apiUrl");if(i){localStorage.setItem(o,i),e.delete("apiUrl");let a=e.toString()?`${window.location.pathname}?${e.toString()}`:window.location.pathname;window.history.replaceState({},"",a),console.log(`[SparkECoder] API URL set to: ${i}`)}}function r(){return a||t(),localStorage.getItem(o)||i}let l={availableModels:[{id:"anthropic/claude-opus-4-6",name:"Claude Opus 4.6",provider:"Anthropic"},{id:"anthropic/claude-opus-4-5",name:"Claude Opus 4.5",provider:"Anthropic"},{id:"anthropic/claude-sonnet-4",name:"Claude Sonnet 4",provider:"Anthropic"},{id:"anthropic/claude-haiku-4-5",name:"Claude Haiku 4.5",provider:"Anthropic"},{id:"openai/gpt-5-2-codex",name:"GPT-5.2 Codex",provider:"OpenAI"},{id:"google/gemini-3-flash",name:"Gemini 3 Flash",provider:"Google"},{id:"xai/grok-code-fast-1",name:"Grok Code Fast",provider:"xAI"}],availableTools:[{id:"bash",name:"Bash",description:"Execute shell commands",dangerous:!0},{id:"write_file",name:"Write File",description:"Create or edit files",dangerous:!0},{id:"read_file",name:"Read File",description:"Read file contents",dangerous:!1}],defaultModel:"anthropic/claude-opus-4-6",defaultToolApprovals:{},serverConnected:!1,apiKeyConfigured:!1,apiBaseUrl:i};async function n(){let e=r();try{let o=new AbortController,i=setTimeout(()=>o.abort(),3e3),a=await fetch(`${e}/health`,{signal:o.signal});if(clearTimeout(i),!a.ok)return{...l,apiBaseUrl:e};let t=await a.json();return{...l,defaultModel:t.config?.defaultModel||l.defaultModel,defaultToolApprovals:t.config?.defaultToolApprovals||{},serverConnected:!0,apiKeyConfigured:t.apiKeyConfigured??!1,apiBaseUrl:e}}catch{return{...l,apiBaseUrl:e}}}e.s(["getApiUrl",()=>r,"getConfig",()=>n,"initApiUrl",()=>t])},760800,e=>{"use strict";var o=e.i(430878),i=e.i(739963);function a(){return(0,o.useEffect)(()=>{(0,i.initApiUrl)()},[]),null}e.s(["ApiInit",()=>a])}]);