ompchamber 0.8.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +1 -1
- package/dist/client/static/css/index.b859cc1cc5.css +2 -0
- package/dist/client/static/js/async/{5b.0d6ae50fe8.js → 5b.a5ccbc19dc.js} +2 -2
- package/dist/client/static/js/async/g.a06ca3b3e9.js +2 -0
- package/dist/client/static/js/async/{m.0896dab823.js → m.c038c71b9f.js} +2 -2
- package/dist/client/static/js/async/ms.98960af4eb.js +67 -0
- package/dist/client/static/js/async/ms.98960af4eb.js.LICENSE.txt +12 -0
- package/dist/client/static/js/async/ot.84c71b308f.js +2 -0
- package/dist/client/static/js/async/{x4.69ec69c61b.js.LICENSE.txt → ot.84c71b308f.js.LICENSE.txt} +5 -0
- package/dist/client/static/js/index.6e065017eb.js +33 -0
- package/package.json +2 -1
- package/src/client/components/common/ComposerPicker.tsx +16 -4
- package/src/client/components/common/ComposerTextarea.tsx +1 -0
- package/src/client/components/layout/RightActivityBar.tsx +1 -1
- package/src/client/components/layout/desktop-layout/ResizeHandle.tsx +2 -2
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +13 -2
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +107 -56
- package/src/client/components/layout/desktop-layout/index.tsx +25 -96
- package/src/client/components/layout/desktop-layout/resizer/index.tsx +79 -118
- package/src/client/components/layout/desktop-layout/resizer/separator-drag.ts +140 -0
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +1 -1
- package/src/client/components/layout/session-sidebar/Header.tsx +1 -1
- package/src/client/components/layout/session-sidebar/SessionItem.tsx +27 -13
- package/src/client/components/layout/session-sidebar/SessionList.tsx +1 -1
- package/src/client/components/layout/session-sidebar/SubagentList.tsx +6 -4
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +1 -1
- package/src/client/components/mobile/mobile-session-sidebar/List.tsx +1 -1
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +14 -4
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/QueueList.tsx +18 -14
- package/src/client/components/workspace/chat-timeline/SubagentView.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +23 -3
- package/src/client/components/workspace/chat-timeline/index.tsx +7 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Goal.tsx +3 -3
- package/src/client/components/workspace/git-panel/BranchToolbar.tsx +2 -2
- package/src/client/components/workspace/git-panel/index.tsx +5 -1
- package/src/client/components/workspace/model-dropdown/groups.ts +35 -2
- package/src/client/components/workspace/model-dropdown/index.tsx +48 -7
- package/src/client/components/workspace/model-dropdown/use-catalog.ts +28 -4
- package/src/client/components/workspace/terminal-panel/Header.tsx +51 -19
- package/src/client/components/workspace/terminal-panel/RealtimeXtermView.tsx +86 -282
- package/src/client/components/workspace/terminal-panel/index.tsx +76 -50
- package/src/client/components/workspace/terminal-panel/mount.ts +275 -0
- package/src/client/data/theme/terminal.ts +27 -29
- package/src/client/hooks/chat/composer/index.ts +28 -8
- package/src/client/hooks/chat/omp/session-list.tsx +19 -2
- package/src/client/hooks/chat/omp/session-sidebar-controller.ts +1 -1
- package/src/client/hooks/chat/timeline/actions.ts +47 -28
- package/src/client/hooks/chat/timeline/deferred-model.test.ts +219 -0
- package/src/client/hooks/chat/timeline/deferred-model.ts +92 -0
- package/src/client/hooks/chat/timeline/index.ts +25 -21
- package/src/client/hooks/chat/timeline/queue.ts +110 -46
- package/src/client/hooks/chat/timeline/send.ts +16 -5
- package/src/client/hooks/workspace/available-width.ts +33 -0
- package/src/client/hooks/workspace/panel-widths.ts +34 -37
- package/src/client/hooks/workspace/terminal/index.ts +217 -0
- package/src/client/hooks/workspace/terminal/socket.ts +227 -0
- package/src/server/db.server.ts +19 -0
- package/src/server/lib/fs/git-sync.ts +191 -0
- package/src/server/lib/models/preferences.server.ts +110 -0
- package/src/server/lib/models/registry.server.ts +206 -0
- package/src/server/lib/omp/rpc/manager.ts +58 -3
- package/src/server/lib/omp/rpc/session-commands.ts +6 -0
- package/src/server/lib/omp/rpc/utility.ts +7 -1
- package/src/server/lib/omp/session/sidebar-data.server.ts +3 -3
- package/src/server/lib/queue/delivery.server.test.ts +203 -0
- package/src/server/lib/queue/delivery.server.ts +144 -0
- package/src/server/lib/queue/schema-migration.server.ts +50 -0
- package/src/server/lib/queue/store.server.ts +185 -0
- package/src/server/lib/terminal/foreground.ts +73 -0
- package/src/server/lib/terminal/history.test.ts +118 -0
- package/src/server/lib/terminal/history.ts +205 -0
- package/src/server/lib/terminal/runtime.server.ts +338 -0
- package/src/server/lib/terminal/session.server.ts +215 -0
- package/src/server/lib/terminal/shell.test.ts +97 -0
- package/src/server/lib/terminal/shell.ts +103 -0
- package/src/server/routes/fs/git.ts +22 -12
- package/src/server/routes/index.ts +2 -1
- package/src/server/routes/models/root.ts +88 -215
- package/src/server/routes/sessions/index.ts +11 -3
- package/src/server/routes/sessions/queue.ts +121 -0
- package/src/server/routes/sessions/session.ts +1 -132
- package/src/server/routes/settings/commands.ts +59 -18
- package/src/server/routes/terminal/index.ts +2 -2
- package/src/server/routes/terminal/run.ts +8 -100
- package/src/server/routes/terminal/sessions.ts +24 -0
- package/src/server/routes/terminal/ws.ts +149 -0
- package/src/shared/lib/chat/composer/client.ts +17 -8
- package/src/shared/lib/chat/composer/commands.ts +290 -0
- package/src/shared/lib/chat/composer/composer.test.ts +157 -0
- package/src/shared/lib/chat/composer/filter.ts +21 -7
- package/src/shared/lib/chat/composer/trigger.ts +109 -20
- package/src/shared/lib/chat/omp/agent-events.test.ts +37 -1
- package/src/shared/lib/chat/omp/agent-events.ts +30 -0
- package/src/shared/lib/chat/timeline/omp-callbacks.test.ts +9 -1
- package/src/shared/lib/chat/timeline/omp-callbacks.ts +45 -8
- package/src/shared/lib/models/preferences.test.ts +131 -0
- package/src/shared/lib/models/preferences.ts +88 -0
- package/src/shared/lib/models/provider-models.ts +8 -1
- package/src/shared/lib/omp/session/stream-state.server.ts +2 -3
- package/src/shared/lib/omp/subagent/label.test.ts +94 -0
- package/src/shared/lib/omp/subagent/label.ts +84 -0
- package/src/shared/lib/workspace/panel-widths.test.ts +113 -18
- package/src/shared/lib/workspace/panel-widths.ts +161 -30
- package/src/shared/lib/workspace/right-panels.ts +50 -11
- package/src/shared/lib/workspace/session-state/store.ts +4 -4
- package/src/shared/lib/workspace/terminal/protocol.ts +222 -0
- package/src/shared/types/chat.ts +38 -65
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/models.ts +101 -0
- package/src/shared/types/omp/agent.ts +12 -0
- package/src/shared/types/omp/subagent.ts +4 -0
- package/src/shared/types/settings/command.ts +13 -0
- package/src/shared/types/terminal.ts +17 -15
- package/src/shared/types/workspace.ts +2 -2
- package/dist/client/static/css/index.5c0447cefe.css +0 -2
- package/dist/client/static/js/async/g.d1c2fe09aa.js +0 -2
- package/dist/client/static/js/async/x4.69ec69c61b.js +0 -6
- package/dist/client/static/js/index.dc5f5fabe8.js +0 -33
- package/src/client/components/workspace/terminal-panel/InputBar.tsx +0 -82
- package/src/client/components/workspace/terminal-panel/LogEntry.tsx +0 -70
- package/src/client/hooks/workspace/terminal-output.ts +0 -66
- package/src/client/hooks/workspace/terminal.ts +0 -283
- package/src/server/lib/fs/terminal-cwd.ts +0 -49
- package/src/server/routes/terminal/stream.ts +0 -100
- /package/dist/client/static/js/async/{5b.0d6ae50fe8.js.LICENSE.txt → 5b.a5ccbc19dc.js.LICENSE.txt} +0 -0
- /package/dist/client/static/js/async/{g.d1c2fe09aa.js.LICENSE.txt → g.a06ca3b3e9.js.LICENSE.txt} +0 -0
- /package/dist/client/static/js/async/{m.0896dab823.js.LICENSE.txt → m.c038c71b9f.js.LICENSE.txt} +0 -0
- /package/dist/client/static/js/{index.dc5f5fabe8.js.LICENSE.txt → index.6e065017eb.js.LICENSE.txt} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! LICENSE: 5b.
|
|
2
|
-
"use strict";(self.rspackChunkompchamber=self.rspackChunkompchamber||[]).push([["5b"],{bS(e,t,i){i.d(t,{SettingsModal:()=>iv});var a=i("j"),n=i("H"),o=i("qp"),l=i("S"),r=i("z"),s=i("So"),d=i("C7q"),c=i("fe"),p=i("NO"),u=i("HJ"),m=i("qn"),b=i("s0"),h=i("SJ"),f=i("kk"),g=i("y");let v=(0,g.A)({name:"folder-git",size:24,node:[["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M14 13h3",key:"1dgedf"}],["path",{d:"M7 13h3",key:"1pygq7"}]]});var x=i("uV");let k=(0,g.A)({name:"cloud",size:24,node:[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]});var y=i("lW");let w=(0,g.A)({name:"sliders-vertical",size:24,node:[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],aliases:["sliders"]});var N=i("N"),A=i("C7");let Y=(0,g.A)({name:"library",size:24,node:[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]});var S=i("YO"),C=i("t3"),D=i("n");let F=[{id:"appearance",label:"Appearance",icon:u.A,section:"OMPCHAMBER",description:"Custom themes, typography scale, and layout density."},{id:"chats",label:"Chats",icon:m.A,section:"OMPCHAMBER",description:"Message streaming, thinking blocks, and tool view modes."},{id:"notifications",label:"Notifications",icon:b.A,section:"OMPCHAMBER",description:"Build failure alerts, sounds, and system popups."},{id:"usage",label:"Usage",icon:h.A,section:"OMPCHAMBER",description:"Build minutes quota, storage, and general usage."},{id:"token-usage",label:"Token Usage",icon:f.A,section:"OMPCHAMBER",description:"Token telemetry, cache, and cost breakdown."},{id:"projects",label:"Projects",icon:v,section:"WORKSPACE",description:"Workspace directories, roots, and ignored paths."},{id:"omp",label:"OMP Engine",icon:x.A,section:"OMP",description:"Live agent state and native omp config keys."},{id:"providers",label:"Providers",icon:k,section:"OMP",description:"AI model engines, endpoints, and credentials."},{id:"agents",label:"Agents",icon:y.A,section:"OMP",description:"Autonomous agent persona, self-healing, and reasoning."},{id:"behavior",label:"Behavior",icon:w,section:"OMP",description:"Native AGENTS.md and RULES.md — global instructions, permission gates, and safety filters."},{id:"commands",label:"Commands",icon:N.A,section:"OMP",description:"Slash command macros and terminal shortcuts."},{id:"mcp",label:"MCP",icon:A.A,section:"OMP",description:"Model Context Protocol servers and dynamic tools."},{id:"skills",label:"Skills",icon:Y,section:"LIBRARY",description:"Manage downloaded skills and scripts."},{id:"skills-catalog",label:"Skills Catalog",icon:S.A,section:"LIBRARY",description:"Browse and install new skills."}];function T(e){let{activeCategory:t,onSelectCategory:i,searchQuery:n,onSearchChange:o,onReloadOmpEngine:r,isReloading:s,className:d=""}=e,c=F.filter(e=>{if(!n.trim())return!0;let t=n.toLowerCase();return e.label.toLowerCase().includes(t)||e.section.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)});return(0,a.FD)("div",{className:`flex flex-col h-full bg-canvas border-r border-ink/10 text-ink select-none ${d}`,children:[(0,a.Y)("div",{className:"p-3 border-b border-ink/10 flex-shrink-0",children:(0,a.FD)("div",{className:"relative flex items-center",children:[(0,a.Y)(C.A,{size:14,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),(0,a.Y)("input",{type:"text",placeholder:"Search settings",value:n,onChange:e=>o(e.currentTarget.value),className:"w-full bg-paper border border-ink/15 rounded-lg pl-8 pr-7 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors"}),n&&(0,a.Y)("button",{type:"button",onClick:()=>o(""),className:"absolute right-2 text-ink/40 hover:text-ink p-0.5",children:(0,a.Y)(l.A,{size:12})})]})}),(0,a.Y)("div",{className:"flex-1 scrollbar-overlay-container scrollbar-overlay-static p-2 space-y-4",children:0===c.length?(0,a.Y)("div",{className:"text-center py-8 text-xs text-ink/50 italic",children:"No matching settings found"}):["OMPCHAMBER","WORKSPACE","OMP","LIBRARY"].map(e=>{let n=c.filter(t=>t.section===e);return 0===n.length?null:(0,a.FD)("div",{className:"space-y-1",children:[(0,a.Y)("div",{className:"px-2.5 py-1 text-[10px] font-bold text-ink/40 tracking-wider font-mono uppercase",children:e}),(0,a.Y)("div",{className:"space-y-0.5",children:n.map(e=>{let n=e.icon,o=t===e.id;return(0,a.FD)("button",{type:"button",onClick:()=>i(e.id),className:`w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs transition-all text-left ${o?"bg-ink/10 font-semibold text-ink shadow-2xs":"text-ink/75 hover:bg-ink/5 hover:text-ink"}`,children:[(0,a.FD)("div",{className:"flex items-center space-x-2.5 truncate",children:[(0,a.Y)(n,{size:14,className:o?"text-ink":"text-ink/60"}),(0,a.Y)("span",{className:"truncate",children:e.label})]}),e.badge&&(0,a.Y)("span",{className:"px-1.5 py-0.2 text-[9px] font-mono font-medium rounded bg-amber-500/15 text-amber-900 border border-amber-500/20",children:e.badge})]},e.id)})})]},e)})}),(0,a.Y)("div",{className:"p-2 border-t border-ink/10 flex-shrink-0 bg-canvas",children:(0,a.FD)("button",{type:"button",onClick:r,disabled:s,className:"w-full flex items-center space-x-2 px-2.5 py-1.5 text-xs text-ink/75 hover:text-ink hover:bg-ink/5 rounded-lg transition-colors font-medium cursor-pointer",children:[(0,a.Y)(D.A,{size:13,className:`${s?"animate-spin text-warning":"text-ink/60"}`}),(0,a.Y)("span",{children:s?"Reloading OMP Engine...":"Reload OMP Engine"})]})})]})}let M=(0,g.A)({name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]}),P=(0,g.A)({name:"moon",size:24,node:[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]});function I(e){let{settings:t,onUpdate:i}=e;return(0,a.Y)("div",{className:"w-full space-y-8 text-xs text-ink",children:(0,a.FD)("section",{className:"space-y-4",children:[(0,a.FD)("div",{className:"flex items-center space-x-2 border-b border-ink/10 pb-2",children:[(0,a.Y)(u.A,{size:16,className:"text-ink/60"}),(0,a.Y)("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80",children:"Theme Preferences"})]}),(0,a.Y)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[{id:"paper",name:"E-Ink Paper",desc:"Tema terang bawaan E-Ink Monochrome.",icon:M},{id:"one-dark-pro-soft",name:"One Dark Pro Soft",desc:"Tema gelap ala One Dark Pro.",icon:P}].map(e=>(0,a.FD)("button",{onClick:()=>i({theme:e.id}),className:`flex items-start space-x-3 p-3 rounded-lg border text-left transition-all ${t.theme===e.id?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[(0,a.Y)("div",{className:`p-1.5 rounded-full ${t.theme===e.id?"bg-ink text-paper":"bg-canvas text-ink/60"}`,children:(0,a.Y)(e.icon,{size:16})}),(0,a.FD)("div",{className:"flex-1",children:[(0,a.Y)("div",{className:"font-semibold text-ink",children:e.name}),(0,a.Y)("div",{className:"text-ink/60 mt-0.5 leading-relaxed",children:e.desc})]}),t.theme===e.id&&(0,a.Y)(r.A,{size:16,className:"text-ink mt-1"})]},e.id))})]})})}let R=(0,g.A)({name:"list-ordered",size:24,node:[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]]}),E=(0,g.A)({name:"compass",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]]});function L(e){let{settings:t,onUpdate:i}=e;return(0,a.FD)("section",{className:"space-y-3",children:[(0,a.FD)("div",{children:[(0,a.Y)("h4",{className:"text-sm font-semibold text-ink",children:"Follow-up Dispatch"}),(0,a.Y)("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"Choose how new user prompts are handled while the AI agent is actively executing."})]}),(0,a.FD)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,a.FD)("div",{onClick:()=>i({followUpBehavior:"queue"}),role:"button",tabIndex:0,onKeyDown:e=>"Enter"===e.key&&i({followUpBehavior:"queue"}),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${"queue"===t.followUpBehavior?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.Y)("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${"queue"===t.followUpBehavior?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:(0,a.Y)(R,{size:15})}),(0,a.Y)("span",{className:"font-semibold text-xs text-ink",children:"Queue Mode"})]}),(0,a.Y)("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:"Sequential"})]}),(0,a.Y)("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:"Messages wait in an execution queue and run in succession once current inference completes."})]}),(0,a.FD)("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[(0,a.Y)("span",{className:"text-ink/50 text-[10px]",children:"Recommended for batch operations"}),(0,a.Y)("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${"queue"===t.followUpBehavior?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:"queue"===t.followUpBehavior&&(0,a.Y)(r.A,{size:10,strokeWidth:3})})]})]}),(0,a.FD)("div",{onClick:()=>i({followUpBehavior:"steering"}),role:"button",tabIndex:0,onKeyDown:e=>"Enter"===e.key&&i({followUpBehavior:"steering"}),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${"steering"===t.followUpBehavior?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.Y)("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${"steering"===t.followUpBehavior?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:(0,a.Y)(E,{size:15})}),(0,a.Y)("span",{className:"font-semibold text-xs text-ink",children:"Steering Mode"})]}),(0,a.Y)("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:"Intervention"})]}),(0,a.Y)("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:"Immediately redirects current agent trajectory and focuses runtime resources onto the new instruction."})]}),(0,a.FD)("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[(0,a.Y)("span",{className:"text-ink/50 text-[10px]",children:"Recommended for active debugging"}),(0,a.Y)("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${"steering"===t.followUpBehavior?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:"steering"===t.followUpBehavior&&(0,a.Y)(r.A,{size:10,strokeWidth:3})})]})]})]})]})}var O=i("DTR"),j=i("yh");let z=(0,g.A)({name:"keyboard",size:24,node:[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]});function B(e){let{settings:t,onUpdate:i}=e,n=["Enter","Shift + Enter","Ctrl / Cmd + Enter"],o=[{id:"keybindingSend",label:"Send Message",desc:"Submit prompt and initiate agent reasoning",icon:O.A,value:t.keybindingSend||"Enter"},{id:"keybindingNewLine",label:"Line Break",desc:"Insert newline inside input box without dispatching",icon:j.A,value:t.keybindingNewLine||"Shift + Enter"},{id:"keybindingSteering",label:"Steering Intervention",desc:"Send prompt with steering interruption priority",icon:E,value:t.keybindingSteering||"Ctrl / Cmd + Enter"}];return(0,a.FD)("section",{className:"space-y-3",children:[(0,a.FD)("div",{className:"flex items-center justify-between",children:[(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.Y)(z,{size:15,className:"text-ink/70"}),(0,a.Y)("h4",{className:"text-sm font-semibold text-ink",children:"Keyboard Shortcuts"})]}),(0,a.Y)("span",{className:"text-[10px] text-ink/50 font-mono",children:"Auto-conflict resolution"})]}),(0,a.Y)("div",{className:"bg-paper border border-ink/15 rounded-lg divide-y divide-ink/10 shadow-xs overflow-hidden",children:o.map(e=>(0,a.FD)("div",{className:"p-3.5 flex flex-col sm:flex-row sm:items-center justify-between gap-3 hover:bg-ink/[0.015] transition-colors",children:[(0,a.FD)("div",{className:"flex items-start gap-3",children:[(0,a.Y)("div",{className:"w-7 h-7 rounded-md bg-ink/5 flex items-center justify-center text-ink/70 flex-shrink-0 mt-0.5",children:(0,a.Y)(e.icon,{size:14})}),(0,a.FD)("div",{children:[(0,a.Y)("div",{className:"font-semibold text-xs text-ink",children:e.label}),(0,a.Y)("div",{className:"text-[11px] text-ink/60 mt-0.5",children:e.desc})]})]}),(0,a.Y)("div",{className:"flex items-center gap-2 self-end sm:self-center",children:(0,a.Y)("select",{value:e.value,onChange:t=>{var a,n;return a=e.id,n=t.currentTarget.value,void i(e=>{let t={[a]:n};for(let i of["keybindingSend","keybindingNewLine","keybindingSteering"].filter(e=>e!==a))e[i]===n&&(t[i]=e[a]);return{...e,...t}})},className:"bg-paper border border-ink/20 rounded-md px-2.5 py-1.5 outline-none focus:border-ink text-[11px] font-medium text-ink cursor-pointer hover:border-ink/40 transition-colors",children:n.map(e=>(0,a.Y)("option",{value:e,children:e},e))})})]},e.id))})]})}var U=i("XT"),K=i("zH");let q=[{id:"websocket",label:"WebSocket",badge:"Default",icon:U.A,description:"One duplex socket carries every agent frame — no per-event HTTP framing, protocol-level ping keepalive, and capped client backoff on drops.",note:"Lowest overhead per frame"},{id:"sse",label:"Server-Sent Events",badge:"Fallback",icon:K.A,description:"Long-lived HTTP response stream with automatic browser reconnection. Pick this when a proxy or network blocks the WebSocket upgrade.",note:"Works through HTTP-only proxies"}];function _(e){let{settings:t,onUpdate:i}=e,n=t.streamTransport??"websocket";return(0,a.FD)("section",{className:"space-y-3",children:[(0,a.FD)("div",{children:[(0,a.Y)("h4",{className:"text-sm font-semibold text-ink",children:"Streaming Transport"}),(0,a.Y)("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"Wire protocol for live agent events. Applies to the next connection — reconnect or send a new prompt to switch."})]}),(0,a.Y)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:q.map(e=>{let{id:t,label:o,badge:l,icon:s,description:d,note:c}=e,p=n===t,u=()=>i({streamTransport:t});return(0,a.FD)("div",{onClick:u,role:"button",tabIndex:0,onKeyDown:e=>"Enter"===e.key&&u(),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${p?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.Y)("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${p?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:(0,a.Y)(s,{size:15})}),(0,a.Y)("span",{className:"font-semibold text-xs text-ink",children:o})]}),(0,a.Y)("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:l})]}),(0,a.Y)("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:d})]}),(0,a.FD)("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[(0,a.Y)("span",{className:"text-ink/50 text-[10px]",children:c}),(0,a.Y)("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${p?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:p&&(0,a.Y)(r.A,{size:10,strokeWidth:3})})]})]},t)})})]})}function J(e){let{settings:t,onUpdate:i}=e;return(0,a.FD)("div",{className:"w-full space-y-7 text-xs text-ink",children:[(0,a.Y)(_,{settings:t,onUpdate:i}),(0,a.Y)(L,{settings:t,onUpdate:i}),(0,a.Y)(B,{settings:t,onUpdate:i})]})}var $=i("g6"),G=i("AB"),H=i("h"),W=i("al"),V=i("nv"),X=i("nT"),Q=i("w"),Z=i("Oj"),ee=i("Gh"),et=i("R"),ei=i("DK"),ea=i("f"),en=i("z9"),eo=i("Fx"),el=i("F9"),er=i("bt"),es=i("by"),ed=i("r");let ec={default:$.A,code:G.A,terminal:N.A,rocket:H.A,flask:W.A,gamepad:V.A,briefcase:X.A,home:Q.A,globe:Z.A,leaf:ee.A,shield:et.A,palette:u.A,server:ei.A,smartphone:ea.A,database:en.A,lightbulb:eo.A,music:el.A,camera:er.A,book:S.A,heart:es.A};function ep(e){let{projects:t,selectedProjectId:i,onSelectProject:n,onAddProject:o}=e;return(0,a.FD)("div",{className:"w-56 sm:w-64 border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0",children:[(0,a.FD)("div",{className:"px-3.5 py-3 border-b border-ink/10 flex items-center justify-between",children:[(0,a.FD)("span",{className:"text-xs font-semibold text-ink",children:["Total ",t.length]}),(0,a.Y)("button",{type:"button",onClick:o,title:"Add New Project",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:(0,a.Y)(ed.A,{size:15,strokeWidth:2.2})})]}),(0,a.Y)("div",{className:"flex-1 scrollbar-overlay-container scrollbar-overlay-static p-1.5 space-y-0.5",children:t.map(e=>{let t=e.id===i,o=ec[e.icon]||$.A;return(0,a.FD)("button",{type:"button",onClick:()=>n(e.id),className:`w-full flex items-center gap-2 px-2.5 py-1.5 rounded-md text-left transition-colors cursor-pointer group ${t?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e.customIconUrl?(0,a.Y)("img",{src:e.customIconUrl,alt:"",className:"w-3.5 h-3.5 rounded-xs object-contain flex-shrink-0",referrerPolicy:"no-referrer"}):(0,a.Y)(o,{size:14,className:"flex-shrink-0",style:{color:e.accentColor||"currentColor"}}),(0,a.Y)("span",{className:"text-[11.5px] truncate flex-1",children:e.name})]},e.id)})})]})}var eu=i("mO");function em(e){let{project:t,canDelete:i,onDelete:n}=e;return(0,a.FD)("div",{className:"flex items-start justify-between gap-4 pb-4 border-b border-ink/10",children:[(0,a.FD)("div",{className:"min-w-0 flex-1",children:[(0,a.Y)("h2",{className:"text-xl font-bold tracking-tight text-ink truncate",children:t.name}),(0,a.Y)("p",{className:"text-[11px] font-mono text-ink/50 truncate mt-0.5 select-all",children:t.path})]}),i&&(0,a.Y)("button",{type:"button",onClick:n,title:"Delete Project",className:"p-1.5 text-ink/40 hover:text-error hover:bg-error/10 rounded-md transition-colors cursor-pointer",children:(0,a.Y)(eu.A,{size:15})})]})}function eb(e){let{name:t,onChangeName:i}=e;return(0,a.FD)("div",{className:"space-y-2",children:[(0,a.Y)("label",{htmlFor:"project-name-input",className:"block text-xs font-semibold text-ink",children:"Project Name"}),(0,a.Y)("input",{id:"project-name-input",type:"text",value:t,onChange:e=>i(e.currentTarget.value),placeholder:"Enter project name...",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-xs font-medium text-ink outline-none focus:border-ink/60 transition-colors shadow-2xs"})]})}var eh=i("wU"),ef=i("tN"),eg=i("Go"),ev=i("oj");let ex=["Not selected","DeepSeek-V3","DeepSeek-R1","Claude 3.5 Sonnet","Claude 3.7 Sonnet","GPT-4o","Gemini 2.5 Pro"];function ek(e){let{model:t,onSelectModel:i,models:o=ex}=e,l=o&&o.length>0?o:ex,[s,d]=(0,n.J0)(!1),[c,p]=(0,n.J0)(!1),u=(0,n.li)(null);return(0,ev.W)(u,()=>d(!1)),(0,a.FD)("div",{className:"space-y-2.5",children:[(0,a.FD)("div",{className:"flex items-center gap-1.5 relative",children:[(0,a.Y)("h4",{className:"text-xs font-semibold text-ink",children:"Defaults for new chats"}),(0,a.FD)("div",{className:"relative inline-block cursor-help",onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[(0,a.Y)(eh.A,{size:12,className:"text-ink/40 hover:text-ink/70 transition-colors"}),c&&(0,a.Y)("div",{className:"absolute left-4 top-1/2 -translate-y-1/2 bg-ink text-canvas text-[10px] rounded px-2 py-1 shadow-lg whitespace-nowrap z-50 pointer-events-none",children:"Default model assigned when starting new sessions in this project"})]})]}),(0,a.FD)("div",{className:"flex items-center justify-between gap-4 p-3 bg-paper border border-ink/15 rounded-lg",children:[(0,a.FD)("div",{children:[(0,a.Y)("div",{className:"text-xs font-medium text-ink",children:"Project Model"}),(0,a.Y)("div",{className:"text-[11px] text-ink/50",children:"Fallback model for agent sessions"})]}),(0,a.FD)("div",{className:"relative",ref:u,children:[(0,a.FD)("button",{type:"button",onClick:()=>d(!s),className:"flex items-center gap-2 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs",children:[(0,a.Y)(ef.A,{size:13,className:"text-ink/70"}),(0,a.Y)("span",{children:t||"Not selected"}),(0,a.Y)(eg.A,{size:13,className:"text-ink/50 ml-1"})]}),s&&(0,a.Y)("div",{className:"absolute right-0 mt-1 w-52 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 z-50 max-h-56 scrollbar-overlay-container scrollbar-overlay-static",children:l.map(e=>(0,a.FD)("button",{type:"button",onClick:()=>{i(e),d(!1)},className:"w-full flex items-center justify-between px-3 py-1.5 text-left text-xs hover:bg-ink/5 transition-colors cursor-pointer",children:[(0,a.Y)("span",{className:e===t?"font-semibold text-ink":"text-ink/80",children:e}),e===t&&(0,a.Y)(r.A,{size:13,className:"text-ink"})]},e))})]})]})]})}let ey=[{label:"None",value:"",bgHex:"transparent"},{label:"Sky Blue",value:"#38bdf8",bgHex:"#38bdf8"},{label:"Light Green",value:"#a3e635",bgHex:"#a3e635"},{label:"Coral",value:"#f87171",bgHex:"#f87171"},{label:"Amber",value:"#fbbf24",bgHex:"#fbbf24"},{label:"Teal",value:"#2dd4bf",bgHex:"#2dd4bf"},{label:"Slate",value:"#94a3b8",bgHex:"#94a3b8"},{label:"Rose",value:"#f43f5e",bgHex:"#f43f5e"},{label:"Vivid Blue",value:"#3b82f6",bgHex:"#3b82f6"},{label:"Lime Green",value:"#84cc16",bgHex:"#84cc16"}];function ew(e){let{accentColor:t,onSelectColor:i,options:n=ey}=e,o=n&&n.length>0?n:ey;return(0,a.FD)("div",{className:"space-y-2.5",children:[(0,a.Y)("h4",{className:"text-xs font-semibold text-ink",children:"Accent Color"}),(0,a.Y)("div",{className:"flex flex-wrap items-center gap-2.5",children:o.map(e=>{let n=t===e.value;return""===e.value?(0,a.Y)("button",{type:"button",onClick:()=>i(""),title:"Default / No Accent",className:`w-7 h-7 rounded-full border flex items-center justify-center transition-all cursor-pointer ${n?"border-ink bg-ink/10 ring-2 ring-ink/30 ring-offset-2 ring-offset-paper":"border-ink/25 bg-paper hover:border-ink/50 text-ink/60"}`,children:(0,a.Y)(l.A,{size:12,strokeWidth:2.2})},"none"):(0,a.Y)("button",{type:"button",onClick:()=>i(e.value),title:e.label,style:{backgroundColor:e.bgHex},className:`w-7 h-7 rounded-full transition-all cursor-pointer shadow-2xs ${n?"ring-2 ring-ink ring-offset-2 ring-offset-paper scale-105":"hover:scale-105 opacity-90 hover:opacity-100"}`},e.value)})})]})}var eN=i("ke");let eA=[{id:"default",label:"Default Folder",icon:l.A},{id:"code",label:"Code",icon:G.A},{id:"terminal",label:"Terminal",icon:N.A},{id:"rocket",label:"Rocket",icon:H.A},{id:"flask",label:"Flask",icon:W.A},{id:"gamepad",label:"Gamepad",icon:V.A},{id:"briefcase",label:"Briefcase",icon:X.A},{id:"home",label:"Home",icon:Q.A},{id:"globe",label:"Globe",icon:Z.A},{id:"leaf",label:"Leaf",icon:ee.A},{id:"shield",label:"Shield",icon:et.A},{id:"palette",label:"Palette",icon:u.A},{id:"server",label:"Server",icon:ei.A},{id:"smartphone",label:"Smartphone",icon:ea.A},{id:"database",label:"Database",icon:en.A},{id:"lightbulb",label:"Lightbulb",icon:eo.A},{id:"music",label:"Music",icon:el.A},{id:"camera",label:"Camera",icon:er.A},{id:"book",label:"Book",icon:S.A},{id:"heart",label:"Heart",icon:es.A}];function eY(e){let{currentIcon:t,customIconUrl:i,projectName:o,onSelectIcon:l,onSetCustomIcon:r}=e,s=(0,n.li)(null);return(0,a.FD)("div",{className:"space-y-3",children:[(0,a.FD)("div",{className:"flex items-center justify-between",children:[(0,a.Y)("h4",{className:"text-xs font-semibold text-ink",children:"Project Icon"}),i&&(0,a.Y)("button",{type:"button",onClick:()=>r(void 0),className:"text-[11px] text-ink/50 hover:text-error transition-colors cursor-pointer",children:"Reset to standard icon"})]}),(0,a.Y)("div",{className:"flex flex-wrap gap-2",children:eA.map(e=>{let n=!i&&t===e.id,o=e.icon;return(0,a.Y)("button",{type:"button",onClick:()=>{r(void 0),l(e.id)},title:e.label,className:`w-7 h-7 rounded-md flex items-center justify-center transition-all cursor-pointer ${n?"border border-ink/40 bg-ink/5 text-ink shadow-2xs":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:(0,a.Y)(o,{size:14,strokeWidth:1.8})},e.id)})}),(0,a.FD)("div",{className:"flex items-center gap-2 pt-1",children:[(0,a.Y)("input",{type:"file",ref:s,onChange:e=>{let t=e.currentTarget.files?.[0];if(!t)return;let i=new FileReader;i.onload=e=>{let t=e.target?.result;t&&(r(t),l("custom"))},i.readAsDataURL(t),e.currentTarget.value=""},accept:"image/*",className:"hidden"}),(0,a.FD)("button",{type:"button",onClick:()=>s.current?.click(),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs",children:[(0,a.Y)(eN.A,{size:13,className:"text-ink/60"}),(0,a.Y)("span",{children:"upload icon"})]}),(0,a.FD)("button",{type:"button",onClick:()=>{let e=o.toLowerCase().replace(/[^a-z0-9]/g,"")||"app";r(`https://api.dicebear.com/7.x/identicon/svg?seed=${e}&radius=50`),l("custom")},className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs",children:[(0,a.Y)(E,{size:13,className:"text-ink/60"}),(0,a.Y)("span",{children:"discover favicon"})]}),i&&(0,a.FD)("div",{className:"flex items-center gap-2 ml-2 pl-2 border-l border-ink/10",children:[(0,a.Y)("img",{src:i,alt:"Custom icon",className:"w-5 h-5 rounded-xs object-contain border border-ink/15",referrerPolicy:"no-referrer"}),(0,a.Y)("span",{className:"text-[11px] text-ink/60",children:"Custom active"})]})]})]})}function eS(e){let{project:t,canDelete:i,onUpdateField:n,onDeleteProject:o,availableModels:l,accentColorOptions:r}=e;return(0,a.FD)("div",{className:"flex-1 scrollbar-overlay-container scrollbar-overlay-static p-6 md:p-8 space-y-7",children:[(0,a.Y)(em,{project:t,canDelete:i,onDelete:o}),(0,a.Y)(eb,{name:t.name,onChangeName:e=>{if(n("name",e),t.path.endsWith(t.name)){let i=t.path.slice(0,-t.name.length);n("path",`${i}${e}`)}}}),(0,a.Y)(ek,{model:t.model,onSelectModel:e=>n("model",e),models:l}),(0,a.Y)(ew,{accentColor:t.accentColor,onSelectColor:e=>n("accentColor",e),options:r}),(0,a.Y)(eY,{currentIcon:t.icon,customIconUrl:t.customIconUrl,projectName:t.name,onSelectIcon:e=>n("icon",e),onSetCustomIcon:e=>n("customIconUrl",e)})]})}let eC={full:"flex h-full w-full items-center justify-center text-xs text-ink/40",fill:"flex-1 flex items-center justify-center text-xs text-ink/40"},eD=e=>{let{variant:t="full",children:i}=e;return(0,a.Y)("div",{className:eC[t],children:i})};function eF(){let[e,t]=(0,n.J0)([]),[i,o]=(0,n.J0)([]),[l,r]=(0,n.J0)([]),[s,d]=(0,n.J0)("proj-workspace"),[c,u]=(0,n.J0)(!0);(0,n.vJ)(()=>{let e=!0;return(async()=>{try{let i=await fetch("/api/settings/projects"),a=await i.json();if(!e)return;Array.isArray(a?.projects)&&(t(a.projects),d(e=>a.projects.some(t=>t.id===e)?e:a.projects[0]?.id||"")),Array.isArray(a?.availableModels)&&o(a.availableModels),Array.isArray(a?.accentColorOptions)&&r(a.accentColorOptions)}catch(e){console.error("Failed to load projects from API:",e)}finally{e&&u(!1)}})(),()=>{e=!1}},[]);let m=async(e,t,i)=>{if(void 0!==e.folderId)try{let a=await fetch("/api/settings/projects",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:{folderId:e.folderId,[t]:void 0===i?null:i}})});if(!a.ok)throw Error(`HTTP ${a.status}`);window.dispatchEvent(new CustomEvent("omp:workspace-updated",{detail:{folderId:e.folderId}}))}catch(e){console.error("Failed to save project settings:",e)}},b=e.find(e=>e.id===s)||e[0],h=async()=>{let i=`Project ${e.length+1}`;try{let e=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i})}),a=await e.json();if(!e.ok||!a?.success)throw Error(a?.error||`HTTP ${e.status}`);let n=a.folder?.id;if("number"!=typeof n)throw Error("Created workspace has no folder id");let o={id:`folder-${n}`,folderId:n,name:a.folder.name,path:a.folder.project_path||"",model:"Not selected",accentColor:"",icon:"default",isPinned:!1,isExpanded:!0};t(e=>[...e,o]),d(o.id),window.dispatchEvent(new CustomEvent("omp:workspace-updated",{detail:{folderId:n}}))}catch(e){console.error("Failed to add project:",e)}},f=async()=>{if(!(e.length<=1))try{let i=await fetch(`/api/settings/projects?id=${encodeURIComponent(s)}`,{method:"DELETE"});if(!i.ok)throw Error(`HTTP ${i.status}`);let a=e.filter(e=>e.id!==s);t(a),d(a[0]?.id||""),window.dispatchEvent(new CustomEvent("omp:workspace-updated"))}catch(e){console.error("Failed to delete project:",e)}};return((0,p.sY)("omp:workspace-updated",()=>{fetch("/api/settings/projects").then(e=>e.json()).then(e=>{Array.isArray(e?.projects)&&(t(e.projects),d(t=>e.projects.some(e=>e.id===t)?t:e.projects[0]?.id||""))}).catch(e=>{console.error("Failed to refresh projects:",e)})}),c)?(0,a.Y)(eD,{children:"Loading projects from database..."}):(0,a.FD)("div",{className:"w-full h-full flex flex-col md:flex-row overflow-hidden bg-paper text-ink",children:[(0,a.Y)(ep,{projects:e,selectedProjectId:b?.id||"",onSelectProject:d,onAddProject:h}),b&&(0,a.Y)(eS,{project:b,canDelete:e.length>1,onUpdateField:(e,i)=>{b&&(t(t=>t.map(t=>t.id===b.id?{...t,[e]:i}:t)),m(b,e,i))},onDeleteProject:f,availableModels:i,accentColorOptions:l})]})}var eT=i("wu");Array.from({length:41},(e,t)=>{let i=["Command Code Qwen-2.5-Coder-32B-Instruct","Command Code DeepSeek-Coder-V2-0724","Command Code Claude-3.5-Haiku-Fast","Command Code GLM-4-9B-Chat","Command Code Mistral-Codestral-22B","Command Code Llama-3.3-70B-Instruct","Command Code StarCoder-2-15B","Command Code CodeGemma-7B-IT","Command Code Yi-Coder-9B","Command Code DeepSeek-V3-Base","Command Code OpenAI-GPT-4o-Mini","Command Code Gemini-2.5-Flash-Code"],a=t<i.length?i[t]:`Command Code Custom Model-${t+1}`;return{id:`cc-model-${t+1}`,name:a,contextWindow:t%2==0?"1M ctx · 128K out":"128K ctx · 16K out",hasTools:!0,hasVision:t%3==0,hasReasoning:t%4==0,isVisible:!0,temperature:.6,maxTokens:64e3}});let eM=[{id:"openai",name:"OpenAI",slug:"openai",icon:"openai",defaultUrl:"https://api.openai.com/v1"},{id:"anthropic",name:"Anthropic",slug:"anthropic",icon:"claude",defaultUrl:"https://api.anthropic.com/v1"},{id:"google",name:"Google Gemini",slug:"google",icon:"gemini",defaultUrl:"https://generativelanguage.googleapis.com/v1beta"},{id:"groq",name:"Groq Cloud",slug:"groq",icon:"groq",defaultUrl:"https://api.groq.com/openai/v1"},{id:"mistral",name:"Mistral AI",slug:"mistral",icon:"mistral",defaultUrl:"https://api.mistral.ai/v1"},{id:"ollama",name:"Ollama (Local)",slug:"ollama",icon:"ollama",defaultUrl:"http://localhost:11434/v1"},{id:"custom",name:"Custom OpenAI-Compatible",slug:"custom",icon:"custom",defaultUrl:"https://"}];var eP=i("W9");async function eI(e,t,i){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];try{let n=await fetch("/api/settings/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:e,apiKey:t,providerSlug:i,persistToOmp:a})}),o=await n.json();if(!n.ok)return{ok:!1,error:o?.error||`Request failed (HTTP ${n.status})`};return o}catch(e){return{ok:!1,error:e instanceof Error?e.message:"Network error while fetching models"}}}async function eR(e,t){try{await Promise.all(t.map(t=>fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"addModel",model:{id:t.id,name:t.name,provider:e,contextWindow:t.contextWindow?.split(" ")[0]||"128K",thinkingLevel:"Default",isFavorite:!0,capabilities:["Tool calling","Reasoning"],inputFormats:["text"],outputFormats:["text"]}})}))),(0,eP.$P)()}catch(e){console.error("Failed to sync provider models to catalog:",e)}}let eE=/^model-\d+-(?:1|2)$/;async function eL(e){let t=await fetch("/api/settings/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),i=await t.json();if(!t.ok)throw Error(i?.error||`Providers request failed (HTTP ${t.status})`);return(0,eP.$P)(),Array.isArray(i.providers)?i.providers:null}var eO=i("oZ");let ej=(0,g.A)({name:"network",size:24,node:[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]}),ez=(0,g.A)({name:"square-terminal",size:24,node:[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],aliases:["terminal-square"]}),eB=(0,g.A)({name:"flame",size:24,node:[["path",{d:"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4",key:"1slcih"}]]});function eU(e){let{icon:t,size:i=16,className:n=""}=e;switch(t){case"deepseek":return(0,a.Y)(ef.A,{size:i,className:`text-sky-400 ${n}`});case"agentrouter":return(0,a.Y)(ej,{size:i,className:`text-emerald-400 ${n}`});case"commandcode":return(0,a.Y)(ez,{size:i,className:`text-amber-400 ${n}`});case"opencode":return(0,a.Y)(U.A,{size:i,className:`text-violet-400 ${n}`});case"claude":return(0,a.Y)(y.A,{size:i,className:`text-orange-400 ${n}`});case"openai":return(0,a.Y)(A.A,{size:i,className:`text-emerald-400 ${n}`});case"gemini":return(0,a.Y)(ef.A,{size:i,className:`text-blue-400 ${n}`});case"groq":return(0,a.Y)(eB,{size:i,className:`text-amber-500 ${n}`});case"ollama":return(0,a.Y)(ei.A,{size:i,className:`text-slate-400 ${n}`});case"mistral":return(0,a.Y)(Z.A,{size:i,className:`text-rose-400 ${n}`});default:return(0,a.Y)(k,{size:i,className:`text-ink/60 ${n}`})}}function eK(e){let{providers:t,selectedProviderId:i,onSelectProvider:o,onOpenAddModal:l,projects:s=[{id:"proj-ompchamber",name:"ompchamber"},{id:"proj-workspace",name:"Workspace"},{id:"proj-drrealhandler",name:"drrealhandler"},{id:"proj-opencode-zen",name:"opencode-zen"}],currentProject:d,onSelectProject:c}=e,[p,u]=(0,n.J0)(!1),m=(0,n.li)(null);return(0,ev.W)(m,()=>u(!1)),(0,a.FD)("div",{className:"w-56 sm:w-64 border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0",children:[(0,a.FD)("div",{className:"p-3 border-b border-ink/10 relative",ref:m,children:[(0,a.FD)("button",{type:"button",onClick:()=>u(!p),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs",children:[(0,a.FD)("div",{className:"flex items-center gap-2 truncate",children:[(0,a.Y)($.A,{size:14,className:"text-ink/60 flex-shrink-0"}),(0,a.Y)("span",{className:"truncate",children:d})]}),(0,a.Y)(eg.A,{size:14,className:"text-ink/50 flex-shrink-0"})]}),p&&(0,a.Y)("div",{className:"absolute left-3 right-3 mt-1.5 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 z-50 max-h-56 scrollbar-overlay-container scrollbar-overlay",children:s.map(e=>(0,a.FD)("button",{type:"button",onClick:()=>{c(e.name),u(!1)},className:"w-full flex items-center justify-between px-3 py-1.5 text-left text-xs hover:bg-ink/5 transition-colors cursor-pointer",children:[(0,a.Y)("span",{className:e.name===d?"font-semibold text-ink":"text-ink/80",children:e.name}),e.name===d&&(0,a.Y)(r.A,{size:13,className:"text-ink"})]},e.id))})]}),(0,a.FD)("div",{className:"px-3.5 py-2.5 flex items-center justify-between",children:[(0,a.FD)("span",{className:"text-xs font-semibold text-ink/70",children:["Total ",t.length]}),(0,a.Y)("button",{type:"button",onClick:l,title:"Add Provider",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:(0,a.Y)(ed.A,{size:15,strokeWidth:2.2})})]}),(0,a.Y)("div",{className:"px-3.5 pt-1 pb-1.5",children:(0,a.Y)("span",{className:"text-[10px] font-semibold tracking-wider text-ink/50 uppercase",children:"User Providers"})}),(0,a.Y)("div",{className:"flex-1 scrollbar-overlay-container scrollbar-overlay-static p-1.5 space-y-0.5",children:0===t.length?(0,a.Y)("div",{className:"px-2.5 py-4 text-[11px] leading-relaxed text-ink/50",children:"No connected providers yet. Use the plus button above to add one."}):t.map(e=>{let t=e.id===i;return(0,a.FD)("button",{type:"button",onClick:()=>o(e.id),className:`w-full flex items-center justify-between px-2.5 py-2 rounded-md text-left transition-colors cursor-pointer group ${t?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[(0,a.FD)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,a.Y)(eU,{icon:e.icon,size:15,className:"flex-shrink-0"}),(0,a.Y)("span",{className:"text-[12px] truncate",children:e.name})]}),(0,a.Y)("span",{className:`text-[11px] px-1.5 py-0.5 rounded font-mono ${t?"text-ink/90 bg-ink/10":"text-ink/50 group-hover:text-ink/70"}`,children:e.models.length})]},e.id)})})]})}function eq(e){let{provider:t}=e;return(0,a.FD)("div",{className:"flex flex-col gap-1 pb-4",children:[(0,a.FD)("div",{className:"flex items-center gap-2.5",children:[(0,a.Y)(eU,{icon:t.icon,size:22}),(0,a.Y)("h2",{className:"text-xl font-bold tracking-tight text-ink",children:t.name})]}),(0,a.Y)("p",{className:"text-xs font-mono text-ink/50 pl-8",children:t.slug})]})}var e_=i("F"),eJ=i("p");function e$(e){let{provider:t,onOpenReconnectModal:i,onToggleDisconnect:o,onToggleDisabled:l}=e,[s,d]=(0,n.J0)(!1),c="connected"===t.status,p=!0===t.disabled;return(0,a.FD)("div",{className:"space-y-6",children:[(0,a.FD)("div",{className:"space-y-3",children:[(0,a.Y)("div",{className:"text-xs font-semibold text-ink",children:"Authentication"}),(0,a.FD)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.FD)("div",{className:"flex items-center gap-2",children:[p?(0,a.FD)(a.FK,{children:[(0,a.Y)(e_.A,{size:15,className:"text-ink/50 flex-shrink-0",strokeWidth:2.4}),(0,a.Y)("span",{className:"text-xs font-medium text-ink/70",children:"Disabled"})]}):c?(0,a.FD)(a.FK,{children:[(0,a.Y)(r.A,{size:15,className:"text-emerald-500 flex-shrink-0",strokeWidth:2.4}),(0,a.Y)("span",{className:"text-xs font-medium text-ink",children:"Connected"})]}):(0,a.FD)(a.FK,{children:[(0,a.Y)(eJ.A,{size:15,className:"text-error flex-shrink-0",strokeWidth:2.4}),(0,a.Y)("span",{className:"text-xs font-medium text-error",children:"Disconnected"})]}),(0,a.FD)("div",{className:"relative inline-block cursor-help ml-0.5",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[(0,a.Y)(eh.A,{size:13,className:"text-ink/40 hover:text-ink/70 transition-colors"}),s&&(0,a.Y)("div",{className:"absolute left-4 top-1/2 -translate-y-1/2 bg-ink text-canvas text-[10px] rounded px-2.5 py-1.5 shadow-xl whitespace-nowrap z-50 pointer-events-none",children:p?"Provider is disabled — none of its models appear in the chat model list":c?"Endpoint validated and operational for agent inference":"Provider authentication is currently offline or inactive"})]})]}),(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.Y)("button",{type:"button",onClick:l,title:p?"Offer this provider in the model list again":"Remove this provider from the model list",className:"px-3 py-1.5 rounded-md bg-ink/5 hover:bg-ink/10 text-ink text-xs font-medium transition-colors cursor-pointer border border-ink/10",children:p?"enable":"disable"}),(0,a.Y)("button",{type:"button",onClick:i,className:"px-3 py-1.5 rounded-md bg-ink/5 hover:bg-ink/10 text-ink text-xs font-medium transition-colors cursor-pointer border border-ink/10",children:c?"reconnect":"connect"})]})]})]}),(0,a.Y)("div",{className:"border-b border-ink/10"}),(0,a.FD)("div",{className:"space-y-3",children:[(0,a.Y)("div",{className:"text-xs font-semibold text-ink",children:"Connection Details"}),(0,a.FD)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.FD)("div",{className:"text-xs text-ink/70",children:["Configured in: ",(0,a.Y)("span",{className:"font-mono text-ink font-medium",children:t.configuredIn})]}),c?(0,a.Y)("button",{type:"button",onClick:o,className:"text-xs text-error/90 hover:text-error font-medium hover:underline transition-colors cursor-pointer",children:"disconnect"}):(0,a.Y)("span",{className:"text-xs text-ink/40 italic",children:"inactive"})]})]}),(0,a.Y)("div",{className:"border-b border-ink/10"})]})}let eG=(0,g.A)({name:"sliders-horizontal",size:24,node:[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]});var eH=i("W");let eW=(0,g.A)({name:"image",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]});var eV=i("bH"),eX=i("Soe"),eQ=i("pm"),eZ=i("U8");function e0(e){let{models:t,onToggleModelVisibility:i,onHideAll:o,onShowAll:l,onFetchModels:r,canFetchModels:s,isFetchingModels:d,onOpenModelConfig:c,onOpenModelCapabilities:p}=e,[u,m]=(0,n.J0)(""),b=t.filter(e=>e.name.toLowerCase().includes(u.toLowerCase()));return(0,a.FD)("div",{className:"space-y-3.5",children:[(0,a.FD)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.FD)("div",{className:"text-xs font-semibold text-ink",children:["Available Models ",(0,a.FD)("span",{className:"font-normal text-ink/60",children:["(",t.length,")"]})]}),(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.FD)("button",{type:"button",onClick:r,disabled:!s||d,title:s?"Fetch models from provider endpoint":"This provider has no fetchable endpoint",className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded bg-ink text-canvas text-[11px] font-medium hover:opacity-90 transition-opacity cursor-pointer border border-ink disabled:opacity-40 disabled:cursor-not-allowed",children:[(0,a.Y)(D.A,{size:12,className:d?"animate-spin":""}),(0,a.Y)("span",{children:d?"fetching...":"fetch models"})]}),(0,a.Y)("button",{type:"button",onClick:o,className:"px-2.5 py-1 rounded bg-ink/5 hover:bg-ink/10 text-[11px] font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer border border-ink/10",children:"hide all"}),(0,a.Y)("button",{type:"button",onClick:l,className:"px-2.5 py-1 rounded bg-ink/5 hover:bg-ink/10 text-[11px] font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer border border-ink/10",children:"show all"})]})]}),(0,a.FD)("div",{className:"relative flex items-center",children:[(0,a.Y)(C.A,{size:14,className:"absolute left-3 text-ink/40 pointer-events-none"}),(0,a.Y)("input",{type:"text",value:u,onChange:e=>m(e.currentTarget.value),placeholder:"Filter models...",className:"w-full bg-paper border border-ink/15 rounded-lg pl-9 pr-3 py-2 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors shadow-2xs"}),u&&(0,a.Y)("button",{type:"button",onClick:()=>m(""),className:"absolute right-3 text-[11px] text-ink/40 hover:text-ink cursor-pointer",children:"clear"})]}),(0,a.Y)("div",{className:"space-y-1 pt-1",children:0===b.length?(0,a.FD)("div",{className:"py-8 text-center text-xs text-ink/40",children:['No models found matching "',u,'"']}):b.map(e=>(0,a.FD)("div",{className:`flex items-center justify-between gap-3 px-3 py-2.5 rounded-lg hover:bg-ink/5 transition-colors group ${!e.isVisible?"opacity-50":""}`,children:[(0,a.Y)("div",{className:"min-w-0 flex-1",children:(0,a.Y)("span",{className:`text-xs font-medium truncate block ${e.isVisible?"text-ink":"text-ink/60 line-through decoration-ink/40"}`,children:e.name})}),(0,a.FD)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[(void 0!==e.priceInput||void 0!==e.priceOutput)&&(0,a.FD)("span",{title:`$${e.priceInput??"?"} in / $${e.priceOutput??"?"} out per 1M tokens`,className:"text-[11px] font-mono px-2 py-0.5 rounded bg-ink/5 text-ink/70 border border-ink/10",children:[(0,eZ.$g)(e.priceInput)," / ",(0,eZ.$g)(e.priceOutput)]}),e.contextWindow&&(0,a.Y)("span",{className:"text-[11px] font-mono px-2 py-0.5 rounded bg-ink/5 text-ink/70 border border-ink/10",children:(0,eQ.F)(e.contextWindow)}),e.hasTools&&(0,a.Y)("button",{type:"button",onClick:()=>p(e),title:"Tool Calling & Steering Capabilities",className:"p-1 rounded text-ink/50 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:(0,a.Y)(eG,{size:13,strokeWidth:1.8})}),(0,a.Y)("button",{type:"button",onClick:()=>c(e),title:"Configure Model Parameters",className:"p-1 rounded text-ink/50 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:(0,a.Y)(eH.A,{size:13,strokeWidth:1.8})}),e.hasVision&&(0,a.Y)("div",{title:"Multimodal / Vision inputs enabled",className:"p-1 text-ink/60",children:(0,a.Y)(eW,{size:13,strokeWidth:1.8})}),(0,a.Y)("button",{type:"button",onClick:()=>i(e.id),title:e.isVisible?"Hide model from chat picker":"Show model in chat picker",className:`p-1 rounded transition-colors cursor-pointer ${e.isVisible?"text-ink/60 hover:text-ink hover:bg-ink/10":"text-ink/30 hover:text-ink/70 hover:bg-ink/10"}`,children:e.isVisible?(0,a.Y)(eV.A,{size:14,strokeWidth:1.8}):(0,a.Y)(eX.A,{size:14,strokeWidth:1.8})})]})]},e.id))})]})}var e1=i("oE");let e5=(0,g.A)({name:"cloud-download",size:24,node:[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]],aliases:["download-cloud"]}),e2=(0,g.A)({name:"key",size:24,node:[["path",{d:"m2 21 9.6-9.6",key:"9l79m3"}],["path",{d:"m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19",key:"fw8biw"}],["circle",{cx:"15.5",cy:"7.5",r:"5.5",key:"4wxmhb"}]]});function e3(e){let{onClose:t,header:i,children:n,footer:o,form:r,maxWidthClass:s="max-w-md",zClass:d="z-[60]"}=e,c=(0,a.FD)(a.FK,{children:[n,o]});return(0,a.Y)("div",{className:`fixed inset-0 bg-ink/40 backdrop-blur-[2px] ${d} flex items-center justify-center p-4`,onClick:t,children:(0,a.FD)("div",{className:`bg-paper border border-ink/15 rounded-xl shadow-2xl w-full ${s} overflow-hidden text-ink`,onClick:e=>e.stopPropagation(),children:[(0,a.FD)("div",{className:"px-5 py-4 border-b border-ink/10 flex items-center justify-between",children:[i,(0,a.Y)("button",{type:"button",onClick:t,className:"p-1 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:(0,a.Y)(l.A,{size:16})})]}),r?(0,a.Y)("form",{onSubmit:r.onSubmit,className:r.className,children:c}):c]})})}function e4(e){let{isOpen:t,onClose:i,onAddProvider:o,presets:l}=e,s=l[0],[d,c]=(0,n.J0)(s?.id||"openai"),[p,u]=(0,n.J0)(s?.name||"OpenAI"),[m,b]=(0,n.J0)(s?.defaultUrl||"https://api.openai.com/v1"),[h,f]=(0,n.J0)(""),[g,v]=(0,n.J0)(!1),x=e=>{c(e.id),u(e.name),b(e.defaultUrl)};if((0,n.vJ)(()=>{!l.find(e=>e.id===d)&&l[0]&&x(l[0])},[l,d]),!t)return null;let k=async e=>{if(e.preventDefault(),p.trim()&&0!==l.length&&!g){v(!0);try{let e=l.find(e=>e.id===d),t=Date.now(),a={id:`provider-${t}`,name:p.trim(),slug:p.toLowerCase().replace(/[^a-z0-9]/g,"-")||`provider-${t}`,icon:e?.icon||"custom",status:"connected",configuredIn:"auth credentials",baseUrl:m.trim(),apiKey:h.trim()||"sk-custom-••••••••••••••••••••••••",models:[]},n=await eI(m.trim(),h.trim()||void 0,a.slug,!0);n.ok&&n.models?(a.models=n.models,o(a,{fetchedCount:n.models.length})):o(a,{fetchedCount:-1}),i()}finally{v(!1)}}};return(0,a.FD)(e3,{onClose:i,header:(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.Y)(e1.A,{size:16,className:"text-ink/70"}),(0,a.Y)("h3",{className:"text-sm font-semibold text-ink",children:"Add Model Provider"})]}),form:{onSubmit:k,className:"p-5 space-y-4"},footer:(0,a.FD)("div",{className:"pt-2 flex items-center justify-end gap-2 border-t border-ink/10",children:[(0,a.Y)("button",{type:"button",onClick:i,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),(0,a.Y)("button",{type:"submit",disabled:g||0===l.length,className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:g?(0,a.FD)(a.FK,{children:[(0,a.Y)(e5,{size:14,className:"animate-pulse"}),(0,a.Y)("span",{children:"Fetching models..."})]}):(0,a.FD)(a.FK,{children:[(0,a.Y)(r.A,{size:14}),(0,a.Y)("span",{children:"Connect Provider"})]})})]}),children:[(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink mb-1.5",children:"Provider Preset"}),(0,a.FD)("div",{className:"grid grid-cols-2 gap-2 max-h-36 scrollbar-overlay-container scrollbar-overlay-static pr-1",children:[0===l.length&&(0,a.Y)("p",{className:"col-span-2 px-2 py-3 text-xs text-ink/50",children:"All known provider types are already connected."}),l.map(e=>{let t=e.id===d;return(0,a.FD)("button",{type:"button",onClick:()=>x(e),className:`flex items-center gap-2 p-2 rounded-lg border text-left text-xs transition-colors cursor-pointer ${t?"border-ink/50 bg-ink/5 font-semibold text-ink shadow-2xs":"border-ink/15 hover:border-ink/30 text-ink/70"}`,children:[(0,a.Y)(eU,{icon:e.icon,size:14}),(0,a.Y)("span",{className:"truncate",children:e.name})]},e.id)})]})]}),(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Display Name"}),(0,a.Y)("input",{type:"text",required:!0,value:p,onChange:e=>u(e.currentTarget.value),placeholder:"e.g. My Provider",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60"})]}),(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink mb-1",children:"API Base URL"}),(0,a.FD)("div",{className:"relative flex items-center",children:[(0,a.Y)(Z.A,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),(0,a.Y)("input",{type:"text",required:!0,value:m,onChange:e=>b(e.currentTarget.value),placeholder:"https://api.domain.com/v1",className:"w-full bg-paper border border-ink/20 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]})]}),(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink mb-1",children:"API Key (stored securely)"}),(0,a.FD)("div",{className:"relative flex items-center",children:[(0,a.Y)(e2,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),(0,a.Y)("input",{type:"password",value:h,onChange:e=>f(e.currentTarget.value),placeholder:"sk-••••••••••••••••",className:"w-full bg-paper border border-ink/20 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]})]})]})}var e6=i("m");function e8(e){let{isOpen:t,provider:i,isFetchingModels:o,onClose:l,onReconnect:r,onFetchModels:s}=e,[d,c]=(0,n.J0)(i.apiKey||"sk-••••••••••••••••••••••••"),[p,u]=(0,n.J0)(i.baseUrl||"https://api.openai.com/v1"),[m,b]=(0,n.J0)(!1),[h,f]=(0,n.J0)(null);if(!t)return null;let g={apiKey:d.includes("••••")?void 0:d,baseUrl:p},v=async()=>{b(!0),f(null);let e=await eI(p,g.apiKey);b(!1),f(e.ok?"success":"failed")},x=async e=>{e.preventDefault(),r({apiKey:d,baseUrl:p,status:"connected"}),await s(g),l()};return(0,a.FD)(e3,{onClose:l,header:(0,a.FD)("div",{className:"flex items-center gap-2.5",children:[(0,a.Y)(eU,{icon:i.icon,size:18}),(0,a.FD)("div",{children:[(0,a.Y)("h3",{className:"text-sm font-semibold text-ink",children:"Authentication & Credentials"}),(0,a.Y)("p",{className:"text-[11px] text-ink/50 font-mono",children:i.slug})]})]}),form:{onSubmit:x,className:"p-5 space-y-4"},footer:(0,a.FD)("div",{className:"pt-3 flex items-center justify-end gap-2 border-t border-ink/10",children:[(0,a.Y)("button",{type:"button",onClick:l,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),(0,a.FD)("button",{type:"submit",disabled:o,className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:[(0,a.Y)(D.A,{size:13,className:o?"animate-spin":""}),(0,a.Y)("span",{children:o?"Fetching models...":"Save & Reconnect"})]})]}),children:[(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Endpoint URL"}),(0,a.FD)("div",{className:"relative flex items-center",children:[(0,a.Y)(Z.A,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),(0,a.Y)("input",{type:"text",value:p,onChange:e=>u(e.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]})]}),(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink mb-1",children:"API Key / Auth Token"}),(0,a.FD)("div",{className:"relative flex items-center",children:[(0,a.Y)(e2,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),(0,a.Y)("input",{type:"text",value:d,onChange:e=>c(e.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]})]}),(0,a.FD)("div",{className:"flex items-center justify-between pt-1",children:[(0,a.FD)("button",{type:"button",disabled:m||o,onClick:v,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 text-xs font-medium text-ink transition-colors cursor-pointer bg-ink/5 disabled:opacity-50",children:[(0,a.Y)(D.A,{size:13,className:m?"animate-spin":""}),(0,a.Y)("span",{children:m?"Testing endpoint...":"Test Connection"})]}),"success"===h&&(0,a.FD)("span",{className:"inline-flex items-center gap-1 text-xs text-emerald-500 font-medium",children:[(0,a.Y)(e6.A,{size:13}),(0,a.Y)("span",{children:"Models endpoint reachable"})]}),"failed"===h&&(0,a.FD)("span",{className:"inline-flex items-center gap-1 text-xs text-error font-medium",children:[(0,a.Y)(eJ.A,{size:13}),(0,a.Y)("span",{children:"Connection failed"})]})]}),(0,a.FD)("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md bg-ink/5 border border-ink/10 text-[11px] text-ink/60",children:[(0,a.Y)(e5,{size:13,className:"mt-0.5 flex-shrink-0 text-ink/50"}),(0,a.Y)("span",{children:"On save, models are fetched from the endpoint and merged into the list below — existing models are kept, only new ones are added."})]})]})}var e7=i("t");function e9(e){let{isOpen:t,provider:i,onClose:o,onAuthenticated:l}=e,[r,s]=(0,n.J0)("connecting"),[d,c]=(0,n.J0)(null),[p,u]=(0,n.J0)(null),[m,b]=(0,n.J0)(null),[h,f]=(0,n.J0)(""),[g,v]=(0,n.J0)(null),x=(0,n.li)(null),k=(0,n.li)(l);k.current=l,(0,n.vJ)(()=>{if(!t)return;s("connecting"),c(null),u(null),b(null),v(null),f("");let e=new AbortController,a=t=>{fetch("/api/omp/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:e.signal}).catch(()=>{})};return x.current=a,fetch("/api/omp/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:i.slug}),signal:e.signal}).then(async t=>{if(!t.body)throw Error("Streaming not supported");let i=t.body.getReader(),n=new TextDecoder,o="";for(;;){let{done:t,value:l}=await i.read();if(t)break;let r=(o+=n.decode(l,{stream:!0})).split("\n\n");for(let t of(o=r.pop()??"",r)){let i=t.split("\n").find(e=>e.startsWith("data: "));if(i)try{let t=JSON.parse(i.slice(6));if("extension_ui_request"===t.type)s("waiting"),"open_url"===t.method&&t.launchUrl?(c(t.launchUrl),window.open(t.launchUrl,"_blank","noopener")):"input"===t.method?u(t):"notify"===t.method?(b(t.title??""),t.title&&a({id:t.id,accepted:!0})):a({id:t.id,cancelled:!0});else if("login_result"===t.type){s(t.success?"success":"failed"),t.success||v(t.error??"Login failed"),t.success&&k.current(),e.abort();return}}catch{}}}}).catch(t=>{e.signal.aborted||(s("failed"),v(t instanceof Error?t.message:String(t)))}),()=>{e.abort(),x.current=null}},[t,i.slug]);let y=e=>{p&&(x.current?.(e?{id:p.id,cancelled:!0}:{id:p.id,value:h}),u(null),s("connecting"))};return t?(0,a.Y)(e3,{onClose:o,header:(0,a.FD)("div",{className:"flex items-center gap-2.5",children:[(0,a.Y)(eU,{icon:i.icon,size:18}),(0,a.FD)("div",{children:[(0,a.FD)("h3",{className:"text-sm font-semibold text-ink",children:["Sign in to ",i.name]}),(0,a.Y)("p",{className:"text-[11px] text-ink/50 font-mono",children:i.slug})]})]}),footer:(0,a.Y)("div",{className:"px-5 py-3 border-t border-ink/10 flex justify-end",children:(0,a.Y)("button",{type:"button",onClick:o,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"success"===r?"Done":"Close"})}),children:(0,a.FD)("div",{className:"p-5 space-y-4",children:["connecting"===r&&(0,a.FD)("div",{className:"flex items-center gap-2.5 text-xs text-ink/70",children:[(0,a.Y)(e7.A,{size:14,className:"animate-spin"}),"Starting login flow..."]}),"waiting"===r&&(0,a.FD)("div",{className:"space-y-4",children:[d&&(0,a.FD)("div",{className:"space-y-2",children:[(0,a.FD)("div",{className:"flex items-center gap-2 text-xs font-semibold text-ink",children:[(0,a.Y)(Z.A,{size:13,className:"text-ink/50"})," OAuth browser"]}),(0,a.Y)("p",{className:"text-xs text-ink/60",children:"Complete the sign-in in the opened browser tab."}),(0,a.Y)("button",{type:"button",onClick:()=>window.open(d,"_blank","noopener"),className:"text-xs text-ink underline underline-offset-2 break-all text-left",children:d})]}),p&&(0,a.FD)("div",{className:"space-y-2",children:[(0,a.FD)("div",{className:"flex items-center gap-2 text-xs font-semibold text-ink",children:[(0,a.Y)(e2,{size:13,className:"text-ink/50"})," ",p.title??"Credential"]}),(0,a.Y)("input",{type:"text",autoFocus:!0,value:h,onChange:e=>f(e.currentTarget.value),onKeyDown:e=>"Enter"===e.key&&y(!1),placeholder:p.placeholder??"Paste your API key",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"}),(0,a.FD)("div",{className:"flex justify-end gap-2",children:[(0,a.Y)("button",{type:"button",onClick:()=>y(!0),className:"px-3 py-1.5 rounded-md border border-ink/20 text-xs text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),(0,a.Y)("button",{type:"button",onClick:()=>y(!1),className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer",children:"Submit"})]})]}),m&&(0,a.Y)("p",{className:"text-xs text-ink/60",children:m}),!d&&!p&&!m&&(0,a.Y)("p",{className:"text-xs text-ink/50",children:"Waiting for the provider flow..."})]}),"success"===r&&(0,a.FD)("div",{className:"flex items-center gap-2 text-xs text-emerald-500 font-medium",children:[(0,a.Y)(e6.A,{size:14})," Signed in. Credentials stored by omp."]}),"failed"===r&&(0,a.FD)("div",{className:"flex items-start gap-2 text-xs text-error font-medium",children:[(0,a.Y)(eJ.A,{size:14,className:"mt-0.5 shrink-0"}),(0,a.Y)("span",{children:g??"Login failed"})]})]})}):null}function te(e){let{isOpen:t,model:i,onClose:o,onSaveModelConfig:l}=e;if(!t||!i)return null;let[s,d]=(0,n.J0)(i.temperature??.7),[c,p]=(0,n.J0)(i.maxTokens??384e3),[u,m]=(0,n.J0)(i.topP??.95),[b,h]=(0,n.J0)(i.reasoningEffort??"medium");return(0,a.FD)(e3,{onClose:o,header:(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.Y)(eH.A,{size:16,className:"text-ink/70"}),(0,a.FD)("div",{children:[(0,a.Y)("h3",{className:"text-sm font-semibold text-ink",children:"Model Configuration"}),(0,a.Y)("p",{className:"text-[11px] text-ink/50 truncate max-w-[280px]",children:i.name})]})]}),form:{onSubmit:e=>{e.preventDefault(),l(i.id,{temperature:s,maxTokens:c,topP:u,reasoningEffort:b}),o()},className:"p-5 space-y-4"},footer:(0,a.FD)("div",{className:"pt-2 flex items-center justify-end gap-2 border-t border-ink/10",children:[(0,a.Y)("button",{type:"button",onClick:o,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),(0,a.FD)("button",{type:"submit",className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer flex items-center gap-1.5",children:[(0,a.Y)(r.A,{size:14}),(0,a.Y)("span",{children:"Save Parameters"})]})]}),children:[(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center justify-between mb-1 text-xs",children:[(0,a.Y)("span",{className:"font-semibold text-ink",children:"Sampling Temperature"}),(0,a.Y)("span",{className:"font-mono text-ink/70 font-semibold",children:s.toFixed(2)})]}),(0,a.Y)("input",{type:"range",min:"0.0",max:"2.0",step:"0.05",value:s,onChange:e=>d(parseFloat(e.currentTarget.value)),className:"w-full accent-ink cursor-pointer"}),(0,a.Y)("p",{className:"text-[10px] text-ink/40 mt-0.5",children:"Controls randomness: lower is more deterministic, higher is more creative."})]}),(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center justify-between mb-1 text-xs",children:[(0,a.Y)("span",{className:"font-semibold text-ink",children:"Top P (Nucleus Sampling)"}),(0,a.Y)("span",{className:"font-mono text-ink/70 font-semibold",children:u.toFixed(2)})]}),(0,a.Y)("input",{type:"range",min:"0.1",max:"1.0",step:"0.05",value:u,onChange:e=>m(parseFloat(e.currentTarget.value)),className:"w-full accent-ink cursor-pointer"})]}),(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Max Output Tokens"}),(0,a.Y)("input",{type:"number",min:1024,max:1e6,step:1024,value:c,onChange:e=>p(parseInt(e.currentTarget.value,10)||4096),className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]}),i.hasReasoning&&(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink mb-1.5",children:"Reasoning Effort"}),(0,a.Y)("div",{className:"grid grid-cols-3 gap-2",children:["low","medium","high"].map(e=>(0,a.Y)("button",{type:"button",onClick:()=>h(e),className:`py-1.5 rounded-md text-xs font-medium border text-center transition-colors cursor-pointer capitalize ${b===e?"border-ink/50 bg-ink/10 text-ink":"border-ink/15 text-ink/60 hover:border-ink/30"}`,children:e},e))})]})]})}var tt=i("B5");function ti(e){let{isOpen:t,model:i,onClose:n}=e;if(!t||!i)return null;let o=[{title:"Tool & Function Calling",desc:"Allows autonomous agents to invoke CLI scripts, read files, and manipulate workspace files.",enabled:i.hasTools,icon:N.A},{title:"Multimodal Vision",desc:"Analyzes visual screenshots, terminal diffs, diagrams, and image uploads directly.",enabled:i.hasVision,icon:eV.A},{title:"Extended Reasoning & Thinking Blocks",desc:"Provides deep chain-of-thought scratchpad tokens before outputting code patches.",enabled:!!i.hasReasoning,icon:x.A},{title:"Structured Output (JSON Schema)",desc:"Forces strict conformance to specified JSON schemas for deterministic tool execution.",enabled:!0,icon:tt.A},{title:"Streaming Inference",desc:"Delivers real-time incremental token chunks to the chat timeline with zero latency.",enabled:!0,icon:ef.A}];return(0,a.Y)(e3,{onClose:n,header:(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.Y)(eG,{size:16,className:"text-ink/70"}),(0,a.FD)("div",{children:[(0,a.Y)("h3",{className:"text-sm font-semibold text-ink",children:"Model Capabilities & Tools"}),(0,a.Y)("p",{className:"text-[11px] text-ink/50 truncate max-w-[280px]",children:i.name})]})]}),footer:(0,a.Y)("div",{className:"px-5 py-3 border-t border-ink/10 flex justify-end",children:(0,a.Y)("button",{type:"button",onClick:n,className:"px-4 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer",children:"Close"})}),children:(0,a.Y)("div",{className:"p-5 space-y-3",children:o.map(e=>{let t=e.icon;return(0,a.FD)("div",{className:"flex items-start gap-3 p-2.5 rounded-lg bg-ink/5 border border-ink/10",children:[(0,a.Y)("div",{className:"p-1.5 rounded bg-ink/10 text-ink mt-0.5",children:(0,a.Y)(t,{size:14})}),(0,a.FD)("div",{className:"flex-1 min-w-0",children:[(0,a.FD)("div",{className:"flex items-center justify-between",children:[(0,a.Y)("span",{className:"text-xs font-semibold text-ink",children:e.title}),e.enabled?(0,a.FD)("span",{className:"inline-flex items-center gap-1 text-[10px] text-emerald-500 font-semibold uppercase tracking-wider",children:[(0,a.Y)(r.A,{size:11,strokeWidth:2.5}),"Supported"]}):(0,a.Y)("span",{className:"text-[10px] text-ink/40 font-medium uppercase tracking-wider",children:"Not supported"})]}),(0,a.Y)("p",{className:"text-[11px] text-ink/60 mt-0.5 leading-relaxed",children:e.desc})]})]},e.title)})})})}function ta(e){let{autoOpenAdd:t=!1,onAddModalClose:i}=e,{connectedProviders:o,availablePresetProviders:l,selectedProvider:r,currentProject:s,setCurrentProject:d,isFetchingModels:c,toasts:p,dismissToast:u,isAddModalOpen:m,setIsAddModalOpen:b,isReconnectModalOpen:h,setIsReconnectModalOpen:f,isLoginModalOpen:g,setIsLoginModalOpen:v,configModel:x,setConfigModel:k,capabilitiesModel:y,setCapabilitiesModel:w,setSelectedProviderId:N,handleAddProvider:A,handleReconnect:Y,handleFetchModels:S,handleFetchModelsFromList:C,handleOmpAuthSuccess:D,handleToggleDisconnect:F,handleToggleProviderDisabled:T,handleHideAll:M,handleShowAll:P,handleToggleModelVisibility:I,handleSaveModelConfig:R}=function(){let{autoOpenAdd:e=!1,onAddModalClose:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[i,a]=(0,n.J0)([]),[o,l]=(0,n.J0)(eM),[r,s]=(0,n.J0)("provider-deepseek"),[d,c]=(0,n.J0)("ompchamber"),[p,u]=(0,n.J0)(!1),{toasts:m,pushToast:b,dismissToast:h}=(0,eO.Y)(),[f,g]=(0,n.J0)(e),[v,x]=(0,n.J0)(!1),[k,y]=(0,n.J0)(!1),[w,N]=(0,n.J0)(null),[A,Y]=(0,n.J0)(null);(0,n.vJ)(()=>{e&&g(!0)},[e]),(0,n.vJ)(()=>{let e=!0;return fetch("/api/settings/providers").then(e=>e.json()).then(t=>{if(e){if(t?.providers&&Array.isArray(t.providers)){a(t.providers);let e=t.providers.filter(e=>"connected"===e.status);s(e.length>0?e[0].id:"")}t?.presetProviders&&l(t.presetProviders)}}).catch(e=>console.error("Failed to load providers from API:",e)),()=>{e=!1}},[]);let S=(0,n.Kr)(()=>i.filter(e=>"connected"===e.status||!0===e.disabled),[i]),C=(0,n.Kr)(()=>{let e,t;return e=new Set(i.filter(e=>"connected"===e.status).map(e=>e.slug.trim().toLowerCase())),t=new Set,[...o,...i.filter(e=>"connected"!==e.status).map(e=>({id:e.slug,name:e.name,slug:e.slug,icon:e.icon,defaultUrl:e.baseUrl||"https://"}))].filter(i=>{let a=i.slug.trim().toLowerCase();return!(e.has(a)||t.has(a))&&(t.add(a),!0)})},[i,o]),D=S.find(e=>e.id===r)||S[0],F=async e=>{a(e);try{let t=await eL({providers:e});t&&a(t)}catch(e){console.error("Failed to save providers via API:",e),b("Failed to save provider settings.","error")}},T=async(e,t)=>{try{let i=await eL(t?{enableProvider:e}:{disableProvider:e});return i&&a(i),i}catch(e){return console.error("Failed to update provider connection:",e),b("Failed to update the provider connection.","error"),null}},M=async(e,a)=>{await F([...i,e]);let n=await T(e.slug,!0),o=n?.find(t=>t.slug.trim().toLowerCase()===e.slug.trim().toLowerCase());s(o?.id||e.id),g(!1),t?.(),a.fetchedCount>0?b(`Fetched ${a.fetchedCount} new model${1===a.fetchedCount?"":"s"} from the provider.`,"success"):-1===a.fetchedCount&&b("Auto-fetch models failed — provider added with default models.","error"),eR(e.name,e.models)},P=async e=>{D&&(await F(i.map(t=>t.id===D.id?{...t,...e,status:"connected"}:t)),"connected"!==D.status&&await T(D.slug,!0))},I=async e=>{if(!D||p)return;let t=e.baseUrl||D.baseUrl;if(!t)return void b("Base URL is required to fetch models.","error");u(!0);try{var i;let a=await eI(t,e.apiKey||D.apiKey,D.slug,!0);if(!a.ok||!a.models)return void b(a.error||"Failed to fetch models from the provider.","error");let n=(i=D.models,`${D.name} ${D.slug} ${D.baseUrl||""}`.toLowerCase().includes("kenari")?i.filter(e=>{let t=e.name.trim().toLowerCase();return!(eE.test(e.id)&&("kenari default model"===t||"kenari fast / flash"===t))}):i),o=D.models.length-n.length,{merged:l,addedCount:r}=function(e,t){let i=new Set(e.map(e=>e.id)),a=[];for(let e of t)!e.id||i.has(e.id)||(i.add(e.id),a.push({...e}));return{merged:[...e,...a],added:a,addedCount:a.length}}(n,a.models);if((r>0||o>0)&&await P({models:l}),a.omp?.written&&(0,eP.$P)(),r>0?b(`Fetched ${r} new model${1===r?"":"s"} from the provider.`,"success"):o>0?b("Removed legacy fallback models from the provider.","success"):b("No new models found — all fetched models already exist.","success"),a.omp?.written){let e=[];a.omp.addedCount>0&&e.push(`${a.omp.addedCount} new model${1===a.omp.addedCount?"":"s"} registered`),a.omp.backfilledCount>0&&e.push(`${a.omp.backfilledCount} model${1===a.omp.backfilledCount?"":"s"} enriched`),b(`omp models.yml updated${e.length>0?`: ${e.join(", ")}`:""}.`,"success")}else a.omp&&!a.omp.written&&a.omp.reason&&b(`omp models.yml not updated: ${a.omp.reason}`,"error")}finally{u(!1)}},R=async()=>{D&&await I({apiKey:D.apiKey,baseUrl:D.baseUrl})},E=async()=>{if(!D)return;let e="connected"===D.status;e&&s(S.find(e=>e.id!==D.id)?.id||""),await T(D.slug,!e)&&b(e?`${D.name} disconnected — its models are no longer offered in the chat picker.`:`${D.name} reconnected.`,"success")},L=e=>{D&&F(i.map(t=>t.id===D.id?{...t,models:e(t.models)}:t))},O=async()=>{if(!D)return;let e=!0!==D.disabled;await T(D.slug,!e)&&b(e?`${D.name} disabled — it no longer appears in the model list.`:`${D.name} enabled — its models are offered again.`,"success")};return{providers:i,connectedProviders:S,availablePresetProviders:C,selectedProvider:D,currentProject:d,setCurrentProject:c,isFetchingModels:p,toasts:m,pushToast:b,dismissToast:h,isAddModalOpen:f,setIsAddModalOpen:g,isReconnectModalOpen:v,setIsReconnectModalOpen:x,isLoginModalOpen:k,setIsLoginModalOpen:y,configModel:w,setConfigModel:N,capabilitiesModel:A,setCapabilitiesModel:Y,setSelectedProviderId:s,handleAddProvider:M,handleReconnect:P,handleFetchModels:I,handleFetchModelsFromList:R,handleOmpAuthSuccess:()=>{D&&(F(i.map(e=>e.id===D.id?{...e,status:"connected"}:e)),T(D.slug,!0))},handleToggleDisconnect:E,handleToggleProviderDisabled:O,handleHideAll:()=>L(e=>e.map(e=>({...e,isVisible:!1}))),handleShowAll:()=>L(e=>e.map(e=>({...e,isVisible:!0}))),handleToggleModelVisibility:e=>L(t=>t.map(t=>t.id===e?{...t,isVisible:!t.isVisible}:t)),handleSaveModelConfig:(e,t)=>L(i=>i.map(i=>i.id===e?{...i,...t}:i))}}({autoOpenAdd:t,onAddModalClose:i});return(0,a.FD)("div",{className:"w-full h-full flex flex-col md:flex-row overflow-hidden bg-paper text-ink",children:[(0,a.Y)(eK,{providers:o,selectedProviderId:r?.id||"",onSelectProvider:N,onOpenAddModal:()=>b(!0),currentProject:s,onSelectProject:d}),(0,a.Y)("div",{className:"flex-1 scrollbar-overlay-container scrollbar-overlay-static p-6 md:p-8 space-y-6",children:r?(0,a.FD)(a.FK,{children:[(0,a.Y)(eq,{provider:r}),(0,a.Y)(e$,{provider:r,onOpenReconnectModal:()=>{r.id.startsWith("omp-auth-")?v(!0):f(!0)},onToggleDisconnect:F,onToggleDisabled:T}),(0,a.Y)(e0,{models:r.models,onToggleModelVisibility:I,onHideAll:M,onShowAll:P,onFetchModels:C,canFetchModels:!!r.baseUrl,isFetchingModels:c,onOpenModelConfig:e=>k(e),onOpenModelCapabilities:e=>w(e)})]}):(0,a.Y)("div",{className:"py-12 text-center text-xs text-ink/40",children:"Select a provider from the sidebar to view connection details"})}),(0,a.Y)(eT.y,{toasts:p,onDismiss:u}),(0,a.Y)(e4,{isOpen:m,onClose:()=>{b(!1),i?.()},onAddProvider:A,presets:l}),r&&(0,a.Y)(e8,{isOpen:h,provider:r,isFetchingModels:c,onClose:()=>f(!1),onReconnect:Y,onFetchModels:S}),r&&(0,a.Y)(e9,{isOpen:g,provider:r,onClose:()=>v(!1),onAuthenticated:D}),(0,a.Y)(te,{isOpen:!!x,model:x,onClose:()=>k(null),onSaveModelConfig:R}),(0,a.Y)(ti,{isOpen:!!y,model:y,onClose:()=>w(null)})]})}let tn=[{id:"ompchamber",name:"ompchamber",label:"ompchamber"},{id:"workspace-edge",name:"workspace-edge",label:"workspace-edge"},{id:"global",name:"global config",label:"Global (All Projects)"}],to=(e,t)=>t,tl=e=>{let{selectedProject:t,onChangeProject:i,options:o=tn,getTriggerLabel:l=to,variant:s="default"}=e,[d,c]=(0,n.J0)(!1),p=(0,n.li)(null);(0,ev.W)(p,()=>c(!1));let u=l(o,t),m=o.map(e=>{let n=e.value??e.id,o=t===n;return(0,a.Y)("button",{type:"button",onClick:()=>{i(n),c(!1)},className:"compact"===s?`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer ${o?"text-ink font-semibold bg-ink/5":"text-ink/70"}`:`w-full px-3 py-1.5 text-left text-xs flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer ${o?"font-semibold text-ink bg-ink/5":"text-ink/80"}`,children:"compact"===s?(0,a.FD)(a.FK,{children:[(0,a.Y)("span",{className:"truncate",children:e.label}),o&&(0,a.Y)(r.A,{size:12,className:"text-ink flex-shrink-0"})]}):(0,a.FD)("div",{className:"flex items-center gap-2 truncate",children:[(0,a.Y)($.A,{size:13,className:"text-ink/60"}),(0,a.Y)("span",{className:"truncate",children:e.name})]})},e.id)});return"compact"===s?(0,a.FD)("div",{className:"p-2.5 border-b border-ink/10 relative",ref:p,children:[(0,a.FD)("button",{type:"button",onClick:()=>c(!d),className:"w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper text-xs text-ink transition-colors cursor-pointer",children:[(0,a.FD)("div",{className:"flex items-center gap-2 truncate",children:[(0,a.Y)($.A,{size:14,className:"text-ink/60 flex-shrink-0"}),(0,a.Y)("span",{className:"truncate font-medium",children:u})]}),(0,a.Y)(eg.A,{size:14,className:"text-ink/50 flex-shrink-0"})]}),d&&(0,a.FD)(a.FK,{children:[(0,a.Y)("div",{className:"fixed inset-0 z-20",onClick:()=>c(!1)}),(0,a.Y)("div",{className:"absolute left-2.5 right-2.5 top-12 z-30 bg-paper border border-ink/15 rounded-lg shadow-lg py-1 animate-in fade-in zoom-in-95 duration-100",children:m})]})]}):(0,a.FD)("div",{className:"p-3 border-b border-ink/10 relative",ref:p,children:[(0,a.FD)("button",{type:"button",onClick:()=>c(!d),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs",children:[(0,a.FD)("div",{className:"flex items-center gap-2 truncate",children:[(0,a.Y)($.A,{size:14,className:"text-ink/60 flex-shrink-0"}),(0,a.Y)("span",{className:"truncate",children:u})]}),(0,a.Y)(eg.A,{size:14,className:"text-ink/50 flex-shrink-0"})]}),d&&(0,a.Y)("div",{className:"absolute top-12 left-3 right-3 bg-paper border border-ink/20 rounded-lg shadow-lg z-30 py-1 divide-y divide-ink/5 animate-in fade-in zoom-in-95 duration-100",children:m})]})},tr=e=>{let{items:t,selectedId:i,onSelect:n,onAddNew:o,addTitle:l,builtInLabel:r,customLabel:s,formatName:d,nameClassName:c,renderIcon:p,selectedProject:u,onChangeProject:m}=e,b=t.filter(e=>e.isBuiltIn),h=t.filter(e=>!e.isBuiltIn),f=e=>{let t=e.id===i;return(0,a.FD)("button",{type:"button",onClick:()=>n(e.id),className:`w-full text-left px-2.5 py-2 rounded-lg transition-colors cursor-pointer flex flex-col gap-0.5 group ${t?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[(0,a.FD)("div",{className:"flex items-center justify-between gap-1.5",children:[(0,a.FD)("div",{className:"flex items-center gap-1.5 min-w-0",children:[p(!!e.isBuiltIn),(0,a.Y)("span",{className:c,children:d(e.name)})]}),(0,a.Y)("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:e.scope})]}),(0,a.Y)("p",{className:"text-[11px] text-ink/60 line-clamp-1 leading-snug pl-5",children:e.description})]},e.id)};return(0,a.FD)("div",{className:"w-56 sm:w-64 border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0 select-none",children:[(0,a.Y)(tl,{selectedProject:u,onChangeProject:m}),(0,a.FD)("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between",children:[(0,a.FD)("span",{className:"text-xs font-semibold text-ink",children:["Total ",t.length]}),(0,a.Y)("button",{type:"button",onClick:o,title:l,className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:(0,a.Y)(ed.A,{size:15,strokeWidth:2.2})})]}),(0,a.FD)("div",{className:"flex-1 scrollbar-overlay-container scrollbar-overlay-static p-1.5 space-y-3 text-xs",children:[(0,a.FD)("div",{children:[(0,a.Y)("div",{className:"px-2.5 pt-1.5 pb-1 text-[10px] font-bold text-ink/50 uppercase tracking-wider",children:r}),(0,a.Y)("div",{className:"space-y-0.5",children:b.map(f)})]}),(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"px-2.5 pt-1.5 pb-1 text-[10px] font-bold text-ink/50 uppercase tracking-wider flex items-center justify-between",children:[(0,a.Y)("span",{children:s}),(0,a.Y)("span",{className:"text-[10px] font-normal",children:h.length})]}),(0,a.Y)("div",{className:"space-y-0.5",children:h.map(f)})]})]})]})},ts=e=>{let{agents:t,selectedAgentId:i,onSelectAgent:n,onAddNewAgent:o,selectedProject:l,onChangeProject:r}=e;return(0,a.Y)(tr,{items:t,selectedId:i,onSelect:n,onAddNew:o,addTitle:"Create new agent",builtInLabel:"Built-in Agents",customLabel:"Custom Agents",formatName:e=>e,nameClassName:"font-semibold text-xs text-ink truncate",selectedProject:l,onChangeProject:r,renderIcon:e=>(0,a.FD)("div",{className:"relative",children:[(0,a.Y)(y.A,{className:`w-3.5 h-3.5 ${e?"text-ink/80":"text-ink/60"} flex-shrink-0`}),e&&(0,a.Y)("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 rounded-full bg-ink"})]})})},td=(0,g.A)({name:"pen-tool",size:24,node:[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]]});var tc=i("DV"),tp=i("b0");let tu=["Not selected","claude-3-7-sonnet-20250219","claude-3-5-sonnet-20241022","claude-3-5-haiku-20241022","gpt-4o","gpt-4o-mini","o3-mini","gemini-2.5-pro-preview-03-25","gemini-2.5-flash","deepseek-chat-v3","deepseek-reasoner-r1"],tm=e=>{let{agent:t,isNew:i=!1,onSave:o,onDelete:l}=e,[s,d]=(0,n.J0)(t),[c,p]=(0,n.J0)(!1),[u,m]=(0,n.J0)(!1);(0,n.vJ)(()=>{d(t),p(!1)},[t]);let b=e=>{d(t=>{let i=Math.max(0,Math.min(2,parseFloat(((t.temperature??.7)+e).toFixed(2))));return{...t,temperature:i}})},h=e=>{d(t=>{let i=Math.max(0,Math.min(1,parseFloat(((t.topP??.95)+e).toFixed(2))));return{...t,topP:i}})};return(0,a.FD)("form",{onSubmit:e=>{e.preventDefault(),o(s),p(!0),setTimeout(()=>p(!1),2e3)},className:"flex-1 flex flex-col h-full scrollbar-overlay-container scrollbar-overlay-static bg-paper text-ink p-6 md:p-8 space-y-6",children:[(0,a.FD)("div",{className:"space-y-3",children:[(0,a.FD)("div",{className:"flex items-center justify-between",children:[(0,a.Y)("h2",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"Identity & Role"}),s.isBuiltIn&&(0,a.Y)("span",{className:"text-[10px] font-mono px-2 py-0.5 rounded-md bg-ink/5 border border-ink/10 text-ink/60",children:"Built-in System Agent (Read-only System Core)"})]}),(0,a.FD)("div",{className:"flex items-center gap-3",children:[(0,a.FD)("div",{className:"flex-1",children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink/80 mb-1.5",children:"Agent Name"}),(0,a.FD)("div",{className:"flex items-center border border-ink/20 hover:border-ink/40 focus-within:border-ink rounded-lg bg-paper transition-colors",children:[(0,a.Y)("span",{className:"px-3 py-2 font-mono text-xs text-ink/40 border-r border-ink/15 select-none",children:"@"}),(0,a.Y)("input",{type:"text",value:s.name,onChange:e=>d({...s,name:e.currentTarget.value}),required:!0,placeholder:"agent-name",disabled:s.isBuiltIn,className:"w-full text-xs font-mono px-3 py-2 bg-transparent focus:outline-none disabled:opacity-60 text-ink"})]})]}),(0,a.FD)("div",{className:"w-40",children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink/80 mb-1.5",children:"Scope"}),(0,a.FD)("select",{value:s.scope,onChange:e=>d({...s,scope:e.currentTarget.value}),disabled:s.isBuiltIn,className:"w-full text-xs py-2 px-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink disabled:opacity-60 text-ink transition-colors cursor-pointer",children:[(0,a.Y)("option",{value:"user",children:"user"}),(0,a.Y)("option",{value:"project",children:"project"}),(0,a.Y)("option",{value:"system",children:"system"})]})]})]}),(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink/80 mb-1.5",children:"Description"}),(0,a.Y)("textarea",{value:s.description,onChange:e=>d({...s,description:e.currentTarget.value}),placeholder:"What does this agent do?",rows:2,className:"w-full text-xs p-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink placeholder:text-ink/30 text-ink transition-colors"})]}),(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center gap-1.5 mb-1.5",children:[(0,a.Y)("label",{className:"text-xs font-semibold text-ink/80",children:"Mode"}),(0,a.Y)("span",{title:"Defines agent delegation context (primary, subagent, or all)",children:(0,a.Y)(eh.A,{className:"w-3.5 h-3.5 text-ink/40"})})]}),(0,a.Y)("div",{className:"inline-flex rounded-lg border border-ink/15 p-0.5 bg-ink/5",children:["primary","subagent","all"].map(e=>(0,a.Y)("button",{type:"button",onClick:()=>d({...s,mode:e}),className:`px-3 py-1 text-xs rounded-md transition-colors cursor-pointer capitalize ${s.mode===e?"bg-paper text-ink shadow-xs font-semibold":"text-ink/60 hover:text-ink"}`,children:e},e))})]})]}),(0,a.Y)("div",{className:"border-t border-ink/10"}),(0,a.FD)("div",{className:"space-y-3",children:[(0,a.Y)("h2",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"Model & Parameters"}),(0,a.FD)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink/80 mb-1.5",children:"Override Model"}),(0,a.FD)("div",{className:"flex items-center border border-ink/20 hover:border-ink/40 focus-within:border-ink rounded-lg bg-paper transition-colors",children:[(0,a.Y)("span",{className:"px-2.5 text-ink/40",children:(0,a.Y)(td,{className:"w-3.5 h-3.5"})}),(0,a.Y)("select",{value:s.overrideModel||"Not selected",onChange:e=>d({...s,overrideModel:e.currentTarget.value}),className:"w-full text-xs font-mono py-2 pr-3 bg-transparent focus:outline-none cursor-pointer text-ink",children:tu.map(e=>(0,a.Y)("option",{value:e,children:e},e))})]})]}),(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,a.Y)("label",{className:"text-xs font-semibold text-ink/80",children:"Thinking Variant"}),(0,a.Y)("span",{title:"Controls chain-of-thought token depth",children:(0,a.Y)(eh.A,{className:"w-3.5 h-3.5 text-ink/40"})})]}),(0,a.Y)("input",{type:"text",value:s.thinkingVariant||"default",onChange:e=>d({...s,thinkingVariant:e.currentTarget.value}),placeholder:"default",className:"w-full text-xs font-mono px-3 py-2 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors"})]}),(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,a.Y)("label",{className:"text-xs font-semibold text-ink/80",children:"Temperature"}),(0,a.Y)("span",{title:"Higher values make output more random, lower values more deterministic",children:(0,a.Y)(eh.A,{className:"w-3.5 h-3.5 text-ink/40"})})]}),(0,a.FD)("div",{className:"flex items-center border border-ink/20 rounded-lg max-w-[150px] bg-paper overflow-hidden",children:[(0,a.Y)("button",{type:"button",onClick:()=>b(-.05),className:"px-3 py-1.5 text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:(0,a.Y)(tc.A,{className:"w-3.5 h-3.5"})}),(0,a.Y)("span",{className:"flex-1 text-center font-mono text-xs font-medium text-ink",children:null!=s.temperature?s.temperature.toFixed(2):"—"}),(0,a.Y)("button",{type:"button",onClick:()=>b(.05),className:"px-3 py-1.5 text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:(0,a.Y)(ed.A,{className:"w-3.5 h-3.5"})})]})]}),(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,a.Y)("label",{className:"text-xs font-semibold text-ink/80",children:"Top P"}),(0,a.Y)("span",{title:"Nucleus sampling cutoff",children:(0,a.Y)(eh.A,{className:"w-3.5 h-3.5 text-ink/40"})})]}),(0,a.FD)("div",{className:"flex items-center border border-ink/20 rounded-lg max-w-[150px] bg-paper overflow-hidden",children:[(0,a.Y)("button",{type:"button",onClick:()=>h(-.05),className:"px-3 py-1.5 text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:(0,a.Y)(tc.A,{className:"w-3.5 h-3.5"})}),(0,a.Y)("span",{className:"flex-1 text-center font-mono text-xs font-medium text-ink",children:null!=s.topP?s.topP.toFixed(2):"—"}),(0,a.Y)("button",{type:"button",onClick:()=>h(.05),className:"px-3 py-1.5 text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:(0,a.Y)(ed.A,{className:"w-3.5 h-3.5"})})]})]})]})]}),(0,a.Y)("div",{className:"border-t border-ink/10"}),(0,a.FD)("div",{className:"space-y-2 flex-1 flex flex-col",children:[(0,a.FD)("div",{className:"flex items-center justify-between",children:[(0,a.Y)("label",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"System Prompt"}),(0,a.FD)("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(s.systemPrompt),m(!0),setTimeout(()=>m(!1),1800)},className:"flex items-center gap-1.5 text-xs text-ink/60 hover:text-ink transition-colors cursor-pointer",children:[u?(0,a.Y)(r.A,{className:"w-3.5 h-3.5 text-ink"}):(0,a.Y)(tp.A,{className:"w-3.5 h-3.5"}),(0,a.Y)("span",{children:u?"Copied":"Copy"})]})]}),(0,a.Y)("textarea",{value:s.systemPrompt,onChange:e=>d({...s,systemPrompt:e.currentTarget.value}),rows:7,placeholder:"You are an expert coding assistant...",className:"w-full flex-1 min-h-[140px] text-xs font-mono p-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-ink/5 focus:outline-none focus:border-ink leading-relaxed transition-colors"})]}),(0,a.FD)("div",{className:"pt-3 border-t border-ink/10 flex items-center justify-between",children:[(0,a.Y)("div",{children:!s.isBuiltIn&&!i&&l&&(0,a.FD)("button",{type:"button",onClick:()=>l(s.id),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-lg border border-ink/20 hover:border-error hover:text-error text-ink/70 text-xs font-medium transition-colors cursor-pointer",children:[(0,a.Y)(eu.A,{className:"w-3.5 h-3.5"}),"Delete Agent"]})}),(0,a.FD)("div",{className:"flex items-center gap-3",children:[c&&(0,a.FD)("span",{className:"flex items-center gap-1 text-xs text-ink font-medium",children:[(0,a.Y)(r.A,{className:"w-3.5 h-3.5"}),"Saved successfully"]}),(0,a.Y)("button",{type:"submit",className:"px-4 py-2 rounded-lg bg-ink text-paper text-xs font-medium hover:bg-ink/90 transition-colors shadow-xs cursor-pointer",children:i?"Create Agent":"Save Agent"})]})]})]})};var tb=i("ns");function th(e){let{endpoint:t,listKey:i,query:a,messages:o,cacheKey:l}=e,[r,s]=(0,n.J0)([]),[d,c]=(0,n.J0)(null),[p,u]=(0,n.J0)(!1),[m,b]=(0,n.J0)(!0),h=e.readList??(e=>{let t=e?.[i];return Array.isArray(t)?t:null});(0,n.vJ)(()=>{let i=!0;return fetch(`${t}${a??""}`).then(e=>e.json()).then(t=>{if(!i)return;let a=h(t)??[];s(a),c(t=>e.resolveOnLoad?e.resolveOnLoad(t,a):a.length>0?a[0].id:null)}).catch(e=>console.error(o.load,e)).finally(()=>{i&&b(!1)}),()=>{i=!1}},[t,a]);let f=!1===e.fallbackToFirst?r.find(e=>e.id===d):r.find(e=>e.id===d)??r[0];return{items:r,selectedId:d,selected:f,isCreatingNew:p,isLoading:m,select:e=>{u(!1),c(e)},startCreate:()=>{u(!0),c(null)},save:i=>{let a=p?e.buildNew(i):e.buildUpdate(i,f,d);fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e.buildBody?e.buildBody(a):{[e.bodyKey]:a})}).then(e=>e.json()).then(t=>{if(e.isSaveError?.(t))return;let i=h(t);i?s(i):e.serverListOnly||s(e=>e.some(e=>e.id===a.id)?e.map(e=>e.id===a.id?a:e):[...e,a]);let n=e.resolveOnSave?e.resolveOnSave(a,i):a.id;void 0!==n&&c(n),u(!1),l&&(0,tb.SA)(l)}).catch(e=>console.error(o.save,e))},remove:i=>{let n=e.buildDeleteQuery?e.buildDeleteQuery(i):`?id=${encodeURIComponent(i)}`;fetch(`${t}${n}`,{method:"DELETE"}).then(e=>e.json()).then(n=>{if(!e.isDeleteError?.(n))if(l&&(0,tb.SA)(l),e.deleteFromResponse){let e=h(n)??r.filter(e=>e.id!==i);s(e),d===i&&c(e[0]?.id??null)}else fetch(`${t}${a??""}`).then(e=>e.json()).then(e=>{let t=h(e)??[];s(t),d===i&&c(t[0]?.id||null)})}).catch(e=>console.error(o.delete,e))}}}let tf=()=>{let[e,t]=(0,n.J0)("ompchamber"),{items:i,selectedId:o,selected:l,isCreatingNew:r,isLoading:s,select:d,startCreate:c,save:p,remove:u}=th({endpoint:"/api/settings/agents",listKey:"agents",bodyKey:"agent",messages:{load:"Failed to load agents from API:",save:"Failed to save agent via API:",delete:"Failed to delete agent via API:"},cacheKey:"agent",buildNew:e=>({...e,id:`agent-${Date.now()}`,isBuiltIn:!1}),buildUpdate:e=>e,isDeleteError:e=>!!e?.error}),m={id:`new-${Date.now()}`,name:"new-agent",description:"",scope:"user",mode:"subagent",overrideModel:"Not selected",thinkingVariant:"default",temperature:null,topP:null,systemPrompt:"You are a specialized assistant...",isBuiltIn:!1};return s?(0,a.Y)(eD,{children:"Loading agents from database..."}):(0,a.FD)("div",{className:"flex h-full w-full overflow-hidden bg-paper",children:[(0,a.Y)(ts,{agents:i,selectedAgentId:r?null:o,onSelectAgent:d,onAddNewAgent:c,selectedProject:e,onChangeProject:t}),(0,a.Y)("div",{className:"flex-1 h-full overflow-hidden flex flex-col",children:r?(0,a.Y)(tm,{agent:m,isNew:!0,onSave:p}):l?(0,a.Y)(tm,{agent:l,isNew:!1,onSave:p,onDelete:u},l.id):(0,a.Y)("div",{className:"flex-1 flex items-center justify-center text-xs font-mono text-ink/40",children:"Select an agent or click + to create one"})})]})};var tg=i("Ir"),tv=i("ES"),tx=i("uF");let tk={agents:{title:"Global AGENTS.md",badge:"context file",tooltip:"User context file omp loads when a session starts (~/.omp/agent/AGENTS.md, relocated by PI_CODING_AGENT_DIR). It shadows every other user-level context file, so it is the place for long-lived global rules. Recognizable permission directives are also mirrored into config.yml tools.approval. Saving empty content removes the file.",placeholder:"Type instructions in <mandatory_rules> tags..."},rules:{title:"Global RULES.md",badge:"sticky rule",tooltip:"User sticky rule (~/.omp/agent/RULES.md). Its whole body is re-sent on every request and re-read when a session starts or after /clear and /new, so it keeps its hold in long conversations — keep it to a few hard requirements. Saving empty content removes the file.",placeholder:"One hard requirement per line, e.g. Never commit or push unless asked."}},ty=e=>{let{kind:t,content:i,filePath:o,exists:l,isMock:s,onSave:d,onReset:c}=e,[p,u]=(0,n.J0)(i),[m,b]=(0,n.J0)(!1),[h,f]=(0,n.J0)(!1),[g,v]=(0,n.J0)(!1),[x,k]=(0,n.J0)(null),[y,w]=(0,n.J0)(null);(0,n.vJ)(()=>{u(i)},[i]);let N=tk[t],A=p.split("\n").length,Y=p.length,S=Math.round(Y/4),C=s?"Demo preset — MOCK=true, nothing is written to disk":o?`${o}${l?"":" · not created yet"}`:"Native path unavailable",D=async e=>{f(!0),k(null),w(null);try{let t=await e();if(t.error)return void k(t.error);w(t.note??null),v(!0),setTimeout(()=>v(!1),2e3)}finally{f(!1)}},F=async()=>{!c||window.confirm(`Replace ${o??"the stored content"} with the shipped default rules?`)&&await D(c)},T=e=>{u(t=>`${t.trim()}
|
|
1
|
+
/*! LICENSE: 5b.a5ccbc19dc.js.LICENSE.txt */
|
|
2
|
+
"use strict";(self.rspackChunkompchamber=self.rspackChunkompchamber||[]).push([["5b"],{bS(e,t,i){i.d(t,{SettingsModal:()=>iv});var a=i("j"),n=i("H"),o=i("qp"),l=i("S"),r=i("z"),s=i("So"),d=i("C7q"),c=i("fe"),p=i("NO"),u=i("HJ"),m=i("qn"),b=i("s0"),h=i("SJ"),f=i("kk"),g=i("y");let v=(0,g.A)({name:"folder-git",size:24,node:[["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M14 13h3",key:"1dgedf"}],["path",{d:"M7 13h3",key:"1pygq7"}]]});var x=i("uV");let k=(0,g.A)({name:"cloud",size:24,node:[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]});var y=i("lW");let w=(0,g.A)({name:"sliders-vertical",size:24,node:[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],aliases:["sliders"]});var N=i("N"),A=i("C7");let Y=(0,g.A)({name:"library",size:24,node:[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]});var S=i("YO"),C=i("t3"),D=i("n");let F=[{id:"appearance",label:"Appearance",icon:u.A,section:"OMPCHAMBER",description:"Custom themes, typography scale, and layout density."},{id:"chats",label:"Chats",icon:m.A,section:"OMPCHAMBER",description:"Message streaming, thinking blocks, and tool view modes."},{id:"notifications",label:"Notifications",icon:b.A,section:"OMPCHAMBER",description:"Build failure alerts, sounds, and system popups."},{id:"usage",label:"Usage",icon:h.A,section:"OMPCHAMBER",description:"Build minutes quota, storage, and general usage."},{id:"token-usage",label:"Token Usage",icon:f.A,section:"OMPCHAMBER",description:"Token telemetry, cache, and cost breakdown."},{id:"projects",label:"Projects",icon:v,section:"WORKSPACE",description:"Workspace directories, roots, and ignored paths."},{id:"omp",label:"OMP Engine",icon:x.A,section:"OMP",description:"Live agent state and native omp config keys."},{id:"providers",label:"Providers",icon:k,section:"OMP",description:"AI model engines, endpoints, and credentials."},{id:"agents",label:"Agents",icon:y.A,section:"OMP",description:"Autonomous agent persona, self-healing, and reasoning."},{id:"behavior",label:"Behavior",icon:w,section:"OMP",description:"Native AGENTS.md and RULES.md — global instructions, permission gates, and safety filters."},{id:"commands",label:"Commands",icon:N.A,section:"OMP",description:"Slash command macros and terminal shortcuts."},{id:"mcp",label:"MCP",icon:A.A,section:"OMP",description:"Model Context Protocol servers and dynamic tools."},{id:"skills",label:"Skills",icon:Y,section:"LIBRARY",description:"Manage downloaded skills and scripts."},{id:"skills-catalog",label:"Skills Catalog",icon:S.A,section:"LIBRARY",description:"Browse and install new skills."}];function T(e){let{activeCategory:t,onSelectCategory:i,searchQuery:n,onSearchChange:o,onReloadOmpEngine:r,isReloading:s,className:d=""}=e,c=F.filter(e=>{if(!n.trim())return!0;let t=n.toLowerCase();return e.label.toLowerCase().includes(t)||e.section.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)});return(0,a.FD)("div",{className:`flex flex-col h-full bg-canvas border-r border-ink/10 text-ink select-none ${d}`,children:[(0,a.Y)("div",{className:"p-3 border-b border-ink/10 flex-shrink-0",children:(0,a.FD)("div",{className:"relative flex items-center",children:[(0,a.Y)(C.A,{size:14,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),(0,a.Y)("input",{type:"text",placeholder:"Search settings",value:n,onChange:e=>o(e.currentTarget.value),className:"w-full bg-paper border border-ink/15 rounded-lg pl-8 pr-7 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors"}),n&&(0,a.Y)("button",{type:"button",onClick:()=>o(""),className:"absolute right-2 text-ink/40 hover:text-ink p-0.5",children:(0,a.Y)(l.A,{size:12})})]})}),(0,a.Y)("div",{className:"flex-1 scrollbar-overlay-container scrollbar-overlay-static p-2 space-y-4",children:0===c.length?(0,a.Y)("div",{className:"text-center py-8 text-xs text-ink/50 italic",children:"No matching settings found"}):["OMPCHAMBER","WORKSPACE","OMP","LIBRARY"].map(e=>{let n=c.filter(t=>t.section===e);return 0===n.length?null:(0,a.FD)("div",{className:"space-y-1",children:[(0,a.Y)("div",{className:"px-2.5 py-1 text-[10px] font-bold text-ink/40 tracking-wider font-mono uppercase",children:e}),(0,a.Y)("div",{className:"space-y-0.5",children:n.map(e=>{let n=e.icon,o=t===e.id;return(0,a.FD)("button",{type:"button",onClick:()=>i(e.id),className:`w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs transition-all text-left ${o?"bg-ink/10 font-semibold text-ink shadow-2xs":"text-ink/75 hover:bg-ink/5 hover:text-ink"}`,children:[(0,a.FD)("div",{className:"flex items-center space-x-2.5 truncate",children:[(0,a.Y)(n,{size:14,className:o?"text-ink":"text-ink/60"}),(0,a.Y)("span",{className:"truncate",children:e.label})]}),e.badge&&(0,a.Y)("span",{className:"px-1.5 py-0.2 text-[9px] font-mono font-medium rounded bg-amber-500/15 text-amber-900 border border-amber-500/20",children:e.badge})]},e.id)})})]},e)})}),(0,a.Y)("div",{className:"p-2 border-t border-ink/10 flex-shrink-0 bg-canvas",children:(0,a.FD)("button",{type:"button",onClick:r,disabled:s,className:"w-full flex items-center space-x-2 px-2.5 py-1.5 text-xs text-ink/75 hover:text-ink hover:bg-ink/5 rounded-lg transition-colors font-medium cursor-pointer",children:[(0,a.Y)(D.A,{size:13,className:`${s?"animate-spin text-warning":"text-ink/60"}`}),(0,a.Y)("span",{children:s?"Reloading OMP Engine...":"Reload OMP Engine"})]})})]})}let M=(0,g.A)({name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]}),P=(0,g.A)({name:"moon",size:24,node:[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]});function I(e){let{settings:t,onUpdate:i}=e;return(0,a.Y)("div",{className:"w-full space-y-8 text-xs text-ink",children:(0,a.FD)("section",{className:"space-y-4",children:[(0,a.FD)("div",{className:"flex items-center space-x-2 border-b border-ink/10 pb-2",children:[(0,a.Y)(u.A,{size:16,className:"text-ink/60"}),(0,a.Y)("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80",children:"Theme Preferences"})]}),(0,a.Y)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[{id:"paper",name:"E-Ink Paper",desc:"Tema terang bawaan E-Ink Monochrome.",icon:M},{id:"one-dark-pro-soft",name:"One Dark Pro Soft",desc:"Tema gelap ala One Dark Pro.",icon:P}].map(e=>(0,a.FD)("button",{onClick:()=>i({theme:e.id}),className:`flex items-start space-x-3 p-3 rounded-lg border text-left transition-all ${t.theme===e.id?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[(0,a.Y)("div",{className:`p-1.5 rounded-full ${t.theme===e.id?"bg-ink text-paper":"bg-canvas text-ink/60"}`,children:(0,a.Y)(e.icon,{size:16})}),(0,a.FD)("div",{className:"flex-1",children:[(0,a.Y)("div",{className:"font-semibold text-ink",children:e.name}),(0,a.Y)("div",{className:"text-ink/60 mt-0.5 leading-relaxed",children:e.desc})]}),t.theme===e.id&&(0,a.Y)(r.A,{size:16,className:"text-ink mt-1"})]},e.id))})]})})}let R=(0,g.A)({name:"list-ordered",size:24,node:[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]]}),E=(0,g.A)({name:"compass",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]]});function L(e){let{settings:t,onUpdate:i}=e;return(0,a.FD)("section",{className:"space-y-3",children:[(0,a.FD)("div",{children:[(0,a.Y)("h4",{className:"text-sm font-semibold text-ink",children:"Follow-up Dispatch"}),(0,a.Y)("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"Choose how new user prompts are handled while the AI agent is actively executing."})]}),(0,a.FD)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,a.FD)("div",{onClick:()=>i({followUpBehavior:"queue"}),role:"button",tabIndex:0,onKeyDown:e=>"Enter"===e.key&&i({followUpBehavior:"queue"}),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${"queue"===t.followUpBehavior?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.Y)("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${"queue"===t.followUpBehavior?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:(0,a.Y)(R,{size:15})}),(0,a.Y)("span",{className:"font-semibold text-xs text-ink",children:"Queue Mode"})]}),(0,a.Y)("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:"Sequential"})]}),(0,a.Y)("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:"Messages wait in an execution queue and run in succession once current inference completes."})]}),(0,a.FD)("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[(0,a.Y)("span",{className:"text-ink/50 text-[10px]",children:"Recommended for batch operations"}),(0,a.Y)("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${"queue"===t.followUpBehavior?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:"queue"===t.followUpBehavior&&(0,a.Y)(r.A,{size:10,strokeWidth:3})})]})]}),(0,a.FD)("div",{onClick:()=>i({followUpBehavior:"steering"}),role:"button",tabIndex:0,onKeyDown:e=>"Enter"===e.key&&i({followUpBehavior:"steering"}),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${"steering"===t.followUpBehavior?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.Y)("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${"steering"===t.followUpBehavior?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:(0,a.Y)(E,{size:15})}),(0,a.Y)("span",{className:"font-semibold text-xs text-ink",children:"Steering Mode"})]}),(0,a.Y)("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:"Intervention"})]}),(0,a.Y)("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:"Immediately redirects current agent trajectory and focuses runtime resources onto the new instruction."})]}),(0,a.FD)("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[(0,a.Y)("span",{className:"text-ink/50 text-[10px]",children:"Recommended for active debugging"}),(0,a.Y)("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${"steering"===t.followUpBehavior?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:"steering"===t.followUpBehavior&&(0,a.Y)(r.A,{size:10,strokeWidth:3})})]})]})]})]})}var O=i("DTR"),j=i("yh");let z=(0,g.A)({name:"keyboard",size:24,node:[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]});function B(e){let{settings:t,onUpdate:i}=e,n=["Enter","Shift + Enter","Ctrl / Cmd + Enter"],o=[{id:"keybindingSend",label:"Send Message",desc:"Submit prompt and initiate agent reasoning",icon:O.A,value:t.keybindingSend||"Enter"},{id:"keybindingNewLine",label:"Line Break",desc:"Insert newline inside input box without dispatching",icon:j.A,value:t.keybindingNewLine||"Shift + Enter"},{id:"keybindingSteering",label:"Steering Intervention",desc:"Send prompt with steering interruption priority",icon:E,value:t.keybindingSteering||"Ctrl / Cmd + Enter"}];return(0,a.FD)("section",{className:"space-y-3",children:[(0,a.FD)("div",{className:"flex items-center justify-between",children:[(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.Y)(z,{size:15,className:"text-ink/70"}),(0,a.Y)("h4",{className:"text-sm font-semibold text-ink",children:"Keyboard Shortcuts"})]}),(0,a.Y)("span",{className:"text-[10px] text-ink/50 font-mono",children:"Auto-conflict resolution"})]}),(0,a.Y)("div",{className:"bg-paper border border-ink/15 rounded-lg divide-y divide-ink/10 shadow-xs overflow-hidden",children:o.map(e=>(0,a.FD)("div",{className:"p-3.5 flex flex-col sm:flex-row sm:items-center justify-between gap-3 hover:bg-ink/[0.015] transition-colors",children:[(0,a.FD)("div",{className:"flex items-start gap-3",children:[(0,a.Y)("div",{className:"w-7 h-7 rounded-md bg-ink/5 flex items-center justify-center text-ink/70 flex-shrink-0 mt-0.5",children:(0,a.Y)(e.icon,{size:14})}),(0,a.FD)("div",{children:[(0,a.Y)("div",{className:"font-semibold text-xs text-ink",children:e.label}),(0,a.Y)("div",{className:"text-[11px] text-ink/60 mt-0.5",children:e.desc})]})]}),(0,a.Y)("div",{className:"flex items-center gap-2 self-end sm:self-center",children:(0,a.Y)("select",{value:e.value,onChange:t=>{var a,n;return a=e.id,n=t.currentTarget.value,void i(e=>{let t={[a]:n};for(let i of["keybindingSend","keybindingNewLine","keybindingSteering"].filter(e=>e!==a))e[i]===n&&(t[i]=e[a]);return{...e,...t}})},className:"bg-paper border border-ink/20 rounded-md px-2.5 py-1.5 outline-none focus:border-ink text-[11px] font-medium text-ink cursor-pointer hover:border-ink/40 transition-colors",children:n.map(e=>(0,a.Y)("option",{value:e,children:e},e))})})]},e.id))})]})}var U=i("XT"),K=i("zH");let q=[{id:"websocket",label:"WebSocket",badge:"Default",icon:U.A,description:"One duplex socket carries every agent frame — no per-event HTTP framing, protocol-level ping keepalive, and capped client backoff on drops.",note:"Lowest overhead per frame"},{id:"sse",label:"Server-Sent Events",badge:"Fallback",icon:K.A,description:"Long-lived HTTP response stream with automatic browser reconnection. Pick this when a proxy or network blocks the WebSocket upgrade.",note:"Works through HTTP-only proxies"}];function _(e){let{settings:t,onUpdate:i}=e,n=t.streamTransport??"websocket";return(0,a.FD)("section",{className:"space-y-3",children:[(0,a.FD)("div",{children:[(0,a.Y)("h4",{className:"text-sm font-semibold text-ink",children:"Streaming Transport"}),(0,a.Y)("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"Wire protocol for live agent events. Applies to the next connection — reconnect or send a new prompt to switch."})]}),(0,a.Y)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:q.map(e=>{let{id:t,label:o,badge:l,icon:s,description:d,note:c}=e,p=n===t,u=()=>i({streamTransport:t});return(0,a.FD)("div",{onClick:u,role:"button",tabIndex:0,onKeyDown:e=>"Enter"===e.key&&u(),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${p?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.Y)("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${p?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:(0,a.Y)(s,{size:15})}),(0,a.Y)("span",{className:"font-semibold text-xs text-ink",children:o})]}),(0,a.Y)("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:l})]}),(0,a.Y)("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:d})]}),(0,a.FD)("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[(0,a.Y)("span",{className:"text-ink/50 text-[10px]",children:c}),(0,a.Y)("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${p?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:p&&(0,a.Y)(r.A,{size:10,strokeWidth:3})})]})]},t)})})]})}function J(e){let{settings:t,onUpdate:i}=e;return(0,a.FD)("div",{className:"w-full space-y-7 text-xs text-ink",children:[(0,a.Y)(_,{settings:t,onUpdate:i}),(0,a.Y)(L,{settings:t,onUpdate:i}),(0,a.Y)(B,{settings:t,onUpdate:i})]})}var $=i("g6"),G=i("AB"),H=i("h"),W=i("al"),V=i("nv"),X=i("nT"),Q=i("w"),Z=i("Oj"),ee=i("Gh"),et=i("R"),ei=i("DK"),ea=i("f"),en=i("z9"),eo=i("Fx"),el=i("F9"),er=i("bt"),es=i("by"),ed=i("r");let ec={default:$.A,code:G.A,terminal:N.A,rocket:H.A,flask:W.A,gamepad:V.A,briefcase:X.A,home:Q.A,globe:Z.A,leaf:ee.A,shield:et.A,palette:u.A,server:ei.A,smartphone:ea.A,database:en.A,lightbulb:eo.A,music:el.A,camera:er.A,book:S.A,heart:es.A};function ep(e){let{projects:t,selectedProjectId:i,onSelectProject:n,onAddProject:o}=e;return(0,a.FD)("div",{className:"w-56 sm:w-64 border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0",children:[(0,a.FD)("div",{className:"px-3.5 py-3 border-b border-ink/10 flex items-center justify-between",children:[(0,a.FD)("span",{className:"text-xs font-semibold text-ink",children:["Total ",t.length]}),(0,a.Y)("button",{type:"button",onClick:o,title:"Add New Project",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:(0,a.Y)(ed.A,{size:15,strokeWidth:2.2})})]}),(0,a.Y)("div",{className:"flex-1 scrollbar-overlay-container scrollbar-overlay-static p-1.5 space-y-0.5",children:t.map(e=>{let t=e.id===i,o=ec[e.icon]||$.A;return(0,a.FD)("button",{type:"button",onClick:()=>n(e.id),className:`w-full flex items-center gap-2 px-2.5 py-1.5 rounded-md text-left transition-colors cursor-pointer group ${t?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e.customIconUrl?(0,a.Y)("img",{src:e.customIconUrl,alt:"",className:"w-3.5 h-3.5 rounded-xs object-contain flex-shrink-0",referrerPolicy:"no-referrer"}):(0,a.Y)(o,{size:14,className:"flex-shrink-0",style:{color:e.accentColor||"currentColor"}}),(0,a.Y)("span",{className:"text-[11.5px] truncate flex-1",children:e.name})]},e.id)})})]})}var eu=i("mO");function em(e){let{project:t,canDelete:i,onDelete:n}=e;return(0,a.FD)("div",{className:"flex items-start justify-between gap-4 pb-4 border-b border-ink/10",children:[(0,a.FD)("div",{className:"min-w-0 flex-1",children:[(0,a.Y)("h2",{className:"text-xl font-bold tracking-tight text-ink truncate",children:t.name}),(0,a.Y)("p",{className:"text-[11px] font-mono text-ink/50 truncate mt-0.5 select-all",children:t.path})]}),i&&(0,a.Y)("button",{type:"button",onClick:n,title:"Delete Project",className:"p-1.5 text-ink/40 hover:text-error hover:bg-error/10 rounded-md transition-colors cursor-pointer",children:(0,a.Y)(eu.A,{size:15})})]})}function eb(e){let{name:t,onChangeName:i}=e;return(0,a.FD)("div",{className:"space-y-2",children:[(0,a.Y)("label",{htmlFor:"project-name-input",className:"block text-xs font-semibold text-ink",children:"Project Name"}),(0,a.Y)("input",{id:"project-name-input",type:"text",value:t,onChange:e=>i(e.currentTarget.value),placeholder:"Enter project name...",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-xs font-medium text-ink outline-none focus:border-ink/60 transition-colors shadow-2xs"})]})}var eh=i("wU"),ef=i("tN"),eg=i("Go"),ev=i("oj");let ex=["Not selected","DeepSeek-V3","DeepSeek-R1","Claude 3.5 Sonnet","Claude 3.7 Sonnet","GPT-4o","Gemini 2.5 Pro"];function ek(e){let{model:t,onSelectModel:i,models:o=ex}=e,l=o&&o.length>0?o:ex,[s,d]=(0,n.J0)(!1),[c,p]=(0,n.J0)(!1),u=(0,n.li)(null);return(0,ev.W)(u,()=>d(!1)),(0,a.FD)("div",{className:"space-y-2.5",children:[(0,a.FD)("div",{className:"flex items-center gap-1.5 relative",children:[(0,a.Y)("h4",{className:"text-xs font-semibold text-ink",children:"Defaults for new chats"}),(0,a.FD)("div",{className:"relative inline-block cursor-help",onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[(0,a.Y)(eh.A,{size:12,className:"text-ink/40 hover:text-ink/70 transition-colors"}),c&&(0,a.Y)("div",{className:"absolute left-4 top-1/2 -translate-y-1/2 bg-ink text-canvas text-[10px] rounded px-2 py-1 shadow-lg whitespace-nowrap z-50 pointer-events-none",children:"Default model assigned when starting new sessions in this project"})]})]}),(0,a.FD)("div",{className:"flex items-center justify-between gap-4 p-3 bg-paper border border-ink/15 rounded-lg",children:[(0,a.FD)("div",{children:[(0,a.Y)("div",{className:"text-xs font-medium text-ink",children:"Project Model"}),(0,a.Y)("div",{className:"text-[11px] text-ink/50",children:"Fallback model for agent sessions"})]}),(0,a.FD)("div",{className:"relative",ref:u,children:[(0,a.FD)("button",{type:"button",onClick:()=>d(!s),className:"flex items-center gap-2 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs",children:[(0,a.Y)(ef.A,{size:13,className:"text-ink/70"}),(0,a.Y)("span",{children:t||"Not selected"}),(0,a.Y)(eg.A,{size:13,className:"text-ink/50 ml-1"})]}),s&&(0,a.Y)("div",{className:"absolute right-0 mt-1 w-52 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 z-50 max-h-56 scrollbar-overlay-container scrollbar-overlay-static",children:l.map(e=>(0,a.FD)("button",{type:"button",onClick:()=>{i(e),d(!1)},className:"w-full flex items-center justify-between px-3 py-1.5 text-left text-xs hover:bg-ink/5 transition-colors cursor-pointer",children:[(0,a.Y)("span",{className:e===t?"font-semibold text-ink":"text-ink/80",children:e}),e===t&&(0,a.Y)(r.A,{size:13,className:"text-ink"})]},e))})]})]})]})}let ey=[{label:"None",value:"",bgHex:"transparent"},{label:"Sky Blue",value:"#38bdf8",bgHex:"#38bdf8"},{label:"Light Green",value:"#a3e635",bgHex:"#a3e635"},{label:"Coral",value:"#f87171",bgHex:"#f87171"},{label:"Amber",value:"#fbbf24",bgHex:"#fbbf24"},{label:"Teal",value:"#2dd4bf",bgHex:"#2dd4bf"},{label:"Slate",value:"#94a3b8",bgHex:"#94a3b8"},{label:"Rose",value:"#f43f5e",bgHex:"#f43f5e"},{label:"Vivid Blue",value:"#3b82f6",bgHex:"#3b82f6"},{label:"Lime Green",value:"#84cc16",bgHex:"#84cc16"}];function ew(e){let{accentColor:t,onSelectColor:i,options:n=ey}=e,o=n&&n.length>0?n:ey;return(0,a.FD)("div",{className:"space-y-2.5",children:[(0,a.Y)("h4",{className:"text-xs font-semibold text-ink",children:"Accent Color"}),(0,a.Y)("div",{className:"flex flex-wrap items-center gap-2.5",children:o.map(e=>{let n=t===e.value;return""===e.value?(0,a.Y)("button",{type:"button",onClick:()=>i(""),title:"Default / No Accent",className:`w-7 h-7 rounded-full border flex items-center justify-center transition-all cursor-pointer ${n?"border-ink bg-ink/10 ring-2 ring-ink/30 ring-offset-2 ring-offset-paper":"border-ink/25 bg-paper hover:border-ink/50 text-ink/60"}`,children:(0,a.Y)(l.A,{size:12,strokeWidth:2.2})},"none"):(0,a.Y)("button",{type:"button",onClick:()=>i(e.value),title:e.label,style:{backgroundColor:e.bgHex},className:`w-7 h-7 rounded-full transition-all cursor-pointer shadow-2xs ${n?"ring-2 ring-ink ring-offset-2 ring-offset-paper scale-105":"hover:scale-105 opacity-90 hover:opacity-100"}`},e.value)})})]})}var eN=i("ke");let eA=[{id:"default",label:"Default Folder",icon:l.A},{id:"code",label:"Code",icon:G.A},{id:"terminal",label:"Terminal",icon:N.A},{id:"rocket",label:"Rocket",icon:H.A},{id:"flask",label:"Flask",icon:W.A},{id:"gamepad",label:"Gamepad",icon:V.A},{id:"briefcase",label:"Briefcase",icon:X.A},{id:"home",label:"Home",icon:Q.A},{id:"globe",label:"Globe",icon:Z.A},{id:"leaf",label:"Leaf",icon:ee.A},{id:"shield",label:"Shield",icon:et.A},{id:"palette",label:"Palette",icon:u.A},{id:"server",label:"Server",icon:ei.A},{id:"smartphone",label:"Smartphone",icon:ea.A},{id:"database",label:"Database",icon:en.A},{id:"lightbulb",label:"Lightbulb",icon:eo.A},{id:"music",label:"Music",icon:el.A},{id:"camera",label:"Camera",icon:er.A},{id:"book",label:"Book",icon:S.A},{id:"heart",label:"Heart",icon:es.A}];function eY(e){let{currentIcon:t,customIconUrl:i,projectName:o,onSelectIcon:l,onSetCustomIcon:r}=e,s=(0,n.li)(null);return(0,a.FD)("div",{className:"space-y-3",children:[(0,a.FD)("div",{className:"flex items-center justify-between",children:[(0,a.Y)("h4",{className:"text-xs font-semibold text-ink",children:"Project Icon"}),i&&(0,a.Y)("button",{type:"button",onClick:()=>r(void 0),className:"text-[11px] text-ink/50 hover:text-error transition-colors cursor-pointer",children:"Reset to standard icon"})]}),(0,a.Y)("div",{className:"flex flex-wrap gap-2",children:eA.map(e=>{let n=!i&&t===e.id,o=e.icon;return(0,a.Y)("button",{type:"button",onClick:()=>{r(void 0),l(e.id)},title:e.label,className:`w-7 h-7 rounded-md flex items-center justify-center transition-all cursor-pointer ${n?"border border-ink/40 bg-ink/5 text-ink shadow-2xs":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:(0,a.Y)(o,{size:14,strokeWidth:1.8})},e.id)})}),(0,a.FD)("div",{className:"flex items-center gap-2 pt-1",children:[(0,a.Y)("input",{type:"file",ref:s,onChange:e=>{let t=e.currentTarget.files?.[0];if(!t)return;let i=new FileReader;i.onload=e=>{let t=e.target?.result;t&&(r(t),l("custom"))},i.readAsDataURL(t),e.currentTarget.value=""},accept:"image/*",className:"hidden"}),(0,a.FD)("button",{type:"button",onClick:()=>s.current?.click(),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs",children:[(0,a.Y)(eN.A,{size:13,className:"text-ink/60"}),(0,a.Y)("span",{children:"upload icon"})]}),(0,a.FD)("button",{type:"button",onClick:()=>{let e=o.toLowerCase().replace(/[^a-z0-9]/g,"")||"app";r(`https://api.dicebear.com/7.x/identicon/svg?seed=${e}&radius=50`),l("custom")},className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs",children:[(0,a.Y)(E,{size:13,className:"text-ink/60"}),(0,a.Y)("span",{children:"discover favicon"})]}),i&&(0,a.FD)("div",{className:"flex items-center gap-2 ml-2 pl-2 border-l border-ink/10",children:[(0,a.Y)("img",{src:i,alt:"Custom icon",className:"w-5 h-5 rounded-xs object-contain border border-ink/15",referrerPolicy:"no-referrer"}),(0,a.Y)("span",{className:"text-[11px] text-ink/60",children:"Custom active"})]})]})]})}function eS(e){let{project:t,canDelete:i,onUpdateField:n,onDeleteProject:o,availableModels:l,accentColorOptions:r}=e;return(0,a.FD)("div",{className:"flex-1 scrollbar-overlay-container scrollbar-overlay-static p-6 md:p-8 space-y-7",children:[(0,a.Y)(em,{project:t,canDelete:i,onDelete:o}),(0,a.Y)(eb,{name:t.name,onChangeName:e=>{if(n("name",e),t.path.endsWith(t.name)){let i=t.path.slice(0,-t.name.length);n("path",`${i}${e}`)}}}),(0,a.Y)(ek,{model:t.model,onSelectModel:e=>n("model",e),models:l}),(0,a.Y)(ew,{accentColor:t.accentColor,onSelectColor:e=>n("accentColor",e),options:r}),(0,a.Y)(eY,{currentIcon:t.icon,customIconUrl:t.customIconUrl,projectName:t.name,onSelectIcon:e=>n("icon",e),onSetCustomIcon:e=>n("customIconUrl",e)})]})}let eC={full:"flex h-full w-full items-center justify-center text-xs text-ink/40",fill:"flex-1 flex items-center justify-center text-xs text-ink/40"},eD=e=>{let{variant:t="full",children:i}=e;return(0,a.Y)("div",{className:eC[t],children:i})};function eF(){let[e,t]=(0,n.J0)([]),[i,o]=(0,n.J0)([]),[l,r]=(0,n.J0)([]),[s,d]=(0,n.J0)("proj-workspace"),[c,u]=(0,n.J0)(!0);(0,n.vJ)(()=>{let e=!0;return(async()=>{try{let i=await fetch("/api/settings/projects"),a=await i.json();if(!e)return;Array.isArray(a?.projects)&&(t(a.projects),d(e=>a.projects.some(t=>t.id===e)?e:a.projects[0]?.id||"")),Array.isArray(a?.availableModels)&&o(a.availableModels),Array.isArray(a?.accentColorOptions)&&r(a.accentColorOptions)}catch(e){console.error("Failed to load projects from API:",e)}finally{e&&u(!1)}})(),()=>{e=!1}},[]);let m=async(e,t,i)=>{if(void 0!==e.folderId)try{let a=await fetch("/api/settings/projects",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:{folderId:e.folderId,[t]:void 0===i?null:i}})});if(!a.ok)throw Error(`HTTP ${a.status}`);window.dispatchEvent(new CustomEvent("omp:workspace-updated",{detail:{folderId:e.folderId}}))}catch(e){console.error("Failed to save project settings:",e)}},b=e.find(e=>e.id===s)||e[0],h=async()=>{let i=`Project ${e.length+1}`;try{let e=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i})}),a=await e.json();if(!e.ok||!a?.success)throw Error(a?.error||`HTTP ${e.status}`);let n=a.folder?.id;if("number"!=typeof n)throw Error("Created workspace has no folder id");let o={id:`folder-${n}`,folderId:n,name:a.folder.name,path:a.folder.project_path||"",model:"Not selected",accentColor:"",icon:"default",isPinned:!1,isExpanded:!0};t(e=>[...e,o]),d(o.id),window.dispatchEvent(new CustomEvent("omp:workspace-updated",{detail:{folderId:n}}))}catch(e){console.error("Failed to add project:",e)}},f=async()=>{if(!(e.length<=1))try{let i=await fetch(`/api/settings/projects?id=${encodeURIComponent(s)}`,{method:"DELETE"});if(!i.ok)throw Error(`HTTP ${i.status}`);let a=e.filter(e=>e.id!==s);t(a),d(a[0]?.id||""),window.dispatchEvent(new CustomEvent("omp:workspace-updated"))}catch(e){console.error("Failed to delete project:",e)}};return((0,p.sY)("omp:workspace-updated",()=>{fetch("/api/settings/projects").then(e=>e.json()).then(e=>{Array.isArray(e?.projects)&&(t(e.projects),d(t=>e.projects.some(e=>e.id===t)?t:e.projects[0]?.id||""))}).catch(e=>{console.error("Failed to refresh projects:",e)})}),c)?(0,a.Y)(eD,{children:"Loading projects from database..."}):(0,a.FD)("div",{className:"w-full h-full flex flex-col md:flex-row overflow-hidden bg-paper text-ink",children:[(0,a.Y)(ep,{projects:e,selectedProjectId:b?.id||"",onSelectProject:d,onAddProject:h}),b&&(0,a.Y)(eS,{project:b,canDelete:e.length>1,onUpdateField:(e,i)=>{b&&(t(t=>t.map(t=>t.id===b.id?{...t,[e]:i}:t)),m(b,e,i))},onDeleteProject:f,availableModels:i,accentColorOptions:l})]})}var eT=i("wu");Array.from({length:41},(e,t)=>{let i=["Command Code Qwen-2.5-Coder-32B-Instruct","Command Code DeepSeek-Coder-V2-0724","Command Code Claude-3.5-Haiku-Fast","Command Code GLM-4-9B-Chat","Command Code Mistral-Codestral-22B","Command Code Llama-3.3-70B-Instruct","Command Code StarCoder-2-15B","Command Code CodeGemma-7B-IT","Command Code Yi-Coder-9B","Command Code DeepSeek-V3-Base","Command Code OpenAI-GPT-4o-Mini","Command Code Gemini-2.5-Flash-Code"],a=t<i.length?i[t]:`Command Code Custom Model-${t+1}`;return{id:`cc-model-${t+1}`,name:a,contextWindow:t%2==0?"1M ctx · 128K out":"128K ctx · 16K out",hasTools:!0,hasVision:t%3==0,hasReasoning:t%4==0,isVisible:!0,temperature:.6,maxTokens:64e3}});let eM=[{id:"openai",name:"OpenAI",slug:"openai",icon:"openai",defaultUrl:"https://api.openai.com/v1"},{id:"anthropic",name:"Anthropic",slug:"anthropic",icon:"claude",defaultUrl:"https://api.anthropic.com/v1"},{id:"google",name:"Google Gemini",slug:"google",icon:"gemini",defaultUrl:"https://generativelanguage.googleapis.com/v1beta"},{id:"groq",name:"Groq Cloud",slug:"groq",icon:"groq",defaultUrl:"https://api.groq.com/openai/v1"},{id:"mistral",name:"Mistral AI",slug:"mistral",icon:"mistral",defaultUrl:"https://api.mistral.ai/v1"},{id:"ollama",name:"Ollama (Local)",slug:"ollama",icon:"ollama",defaultUrl:"http://localhost:11434/v1"},{id:"custom",name:"Custom OpenAI-Compatible",slug:"custom",icon:"custom",defaultUrl:"https://"}];var eP=i("W9");async function eI(e,t,i){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];try{let n=await fetch("/api/settings/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:e,apiKey:t,providerSlug:i,persistToOmp:a})}),o=await n.json();if(!n.ok)return{ok:!1,error:o?.error||`Request failed (HTTP ${n.status})`};return o}catch(e){return{ok:!1,error:e instanceof Error?e.message:"Network error while fetching models"}}}async function eR(e,t){try{await Promise.all(t.map(t=>fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"addModel",model:{id:t.id,name:t.name,provider:e,contextWindow:t.contextWindow?.split(" ")[0]||"128K",thinkingLevel:"Default",capabilities:["Tool calling","Reasoning"],inputFormats:["text"],outputFormats:["text"]}})}))),(0,eP.$P)()}catch(e){console.error("Failed to sync provider models to catalog:",e)}}let eE=/^model-\d+-(?:1|2)$/;async function eL(e){let t=await fetch("/api/settings/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),i=await t.json();if(!t.ok)throw Error(i?.error||`Providers request failed (HTTP ${t.status})`);return(0,eP.$P)(),Array.isArray(i.providers)?i.providers:null}var eO=i("oZ");let ej=(0,g.A)({name:"network",size:24,node:[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]}),ez=(0,g.A)({name:"square-terminal",size:24,node:[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],aliases:["terminal-square"]}),eB=(0,g.A)({name:"flame",size:24,node:[["path",{d:"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4",key:"1slcih"}]]});function eU(e){let{icon:t,size:i=16,className:n=""}=e;switch(t){case"deepseek":return(0,a.Y)(ef.A,{size:i,className:`text-sky-400 ${n}`});case"agentrouter":return(0,a.Y)(ej,{size:i,className:`text-emerald-400 ${n}`});case"commandcode":return(0,a.Y)(ez,{size:i,className:`text-amber-400 ${n}`});case"opencode":return(0,a.Y)(U.A,{size:i,className:`text-violet-400 ${n}`});case"claude":return(0,a.Y)(y.A,{size:i,className:`text-orange-400 ${n}`});case"openai":return(0,a.Y)(A.A,{size:i,className:`text-emerald-400 ${n}`});case"gemini":return(0,a.Y)(ef.A,{size:i,className:`text-blue-400 ${n}`});case"groq":return(0,a.Y)(eB,{size:i,className:`text-amber-500 ${n}`});case"ollama":return(0,a.Y)(ei.A,{size:i,className:`text-slate-400 ${n}`});case"mistral":return(0,a.Y)(Z.A,{size:i,className:`text-rose-400 ${n}`});default:return(0,a.Y)(k,{size:i,className:`text-ink/60 ${n}`})}}function eK(e){let{providers:t,selectedProviderId:i,onSelectProvider:o,onOpenAddModal:l,projects:s=[{id:"proj-ompchamber",name:"ompchamber"},{id:"proj-workspace",name:"Workspace"},{id:"proj-drrealhandler",name:"drrealhandler"},{id:"proj-opencode-zen",name:"opencode-zen"}],currentProject:d,onSelectProject:c}=e,[p,u]=(0,n.J0)(!1),m=(0,n.li)(null);return(0,ev.W)(m,()=>u(!1)),(0,a.FD)("div",{className:"w-56 sm:w-64 border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0",children:[(0,a.FD)("div",{className:"p-3 border-b border-ink/10 relative",ref:m,children:[(0,a.FD)("button",{type:"button",onClick:()=>u(!p),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs",children:[(0,a.FD)("div",{className:"flex items-center gap-2 truncate",children:[(0,a.Y)($.A,{size:14,className:"text-ink/60 flex-shrink-0"}),(0,a.Y)("span",{className:"truncate",children:d})]}),(0,a.Y)(eg.A,{size:14,className:"text-ink/50 flex-shrink-0"})]}),p&&(0,a.Y)("div",{className:"absolute left-3 right-3 mt-1.5 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 z-50 max-h-56 scrollbar-overlay-container scrollbar-overlay",children:s.map(e=>(0,a.FD)("button",{type:"button",onClick:()=>{c(e.name),u(!1)},className:"w-full flex items-center justify-between px-3 py-1.5 text-left text-xs hover:bg-ink/5 transition-colors cursor-pointer",children:[(0,a.Y)("span",{className:e.name===d?"font-semibold text-ink":"text-ink/80",children:e.name}),e.name===d&&(0,a.Y)(r.A,{size:13,className:"text-ink"})]},e.id))})]}),(0,a.FD)("div",{className:"px-3.5 py-2.5 flex items-center justify-between",children:[(0,a.FD)("span",{className:"text-xs font-semibold text-ink/70",children:["Total ",t.length]}),(0,a.Y)("button",{type:"button",onClick:l,title:"Add Provider",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:(0,a.Y)(ed.A,{size:15,strokeWidth:2.2})})]}),(0,a.Y)("div",{className:"px-3.5 pt-1 pb-1.5",children:(0,a.Y)("span",{className:"text-[10px] font-semibold tracking-wider text-ink/50 uppercase",children:"User Providers"})}),(0,a.Y)("div",{className:"flex-1 scrollbar-overlay-container scrollbar-overlay-static p-1.5 space-y-0.5",children:0===t.length?(0,a.Y)("div",{className:"px-2.5 py-4 text-[11px] leading-relaxed text-ink/50",children:"No connected providers yet. Use the plus button above to add one."}):t.map(e=>{let t=e.id===i;return(0,a.FD)("button",{type:"button",onClick:()=>o(e.id),className:`w-full flex items-center justify-between px-2.5 py-2 rounded-md text-left transition-colors cursor-pointer group ${t?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[(0,a.FD)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,a.Y)(eU,{icon:e.icon,size:15,className:"flex-shrink-0"}),(0,a.Y)("span",{className:"text-[12px] truncate",children:e.name})]}),(0,a.Y)("span",{className:`text-[11px] px-1.5 py-0.5 rounded font-mono ${t?"text-ink/90 bg-ink/10":"text-ink/50 group-hover:text-ink/70"}`,children:e.models.length})]},e.id)})})]})}function eq(e){let{provider:t}=e;return(0,a.FD)("div",{className:"flex flex-col gap-1 pb-4",children:[(0,a.FD)("div",{className:"flex items-center gap-2.5",children:[(0,a.Y)(eU,{icon:t.icon,size:22}),(0,a.Y)("h2",{className:"text-xl font-bold tracking-tight text-ink",children:t.name})]}),(0,a.Y)("p",{className:"text-xs font-mono text-ink/50 pl-8",children:t.slug})]})}var e_=i("F"),eJ=i("p");function e$(e){let{provider:t,onOpenReconnectModal:i,onToggleDisconnect:o,onToggleDisabled:l}=e,[s,d]=(0,n.J0)(!1),c="connected"===t.status,p=!0===t.disabled;return(0,a.FD)("div",{className:"space-y-6",children:[(0,a.FD)("div",{className:"space-y-3",children:[(0,a.Y)("div",{className:"text-xs font-semibold text-ink",children:"Authentication"}),(0,a.FD)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.FD)("div",{className:"flex items-center gap-2",children:[p?(0,a.FD)(a.FK,{children:[(0,a.Y)(e_.A,{size:15,className:"text-ink/50 flex-shrink-0",strokeWidth:2.4}),(0,a.Y)("span",{className:"text-xs font-medium text-ink/70",children:"Disabled"})]}):c?(0,a.FD)(a.FK,{children:[(0,a.Y)(r.A,{size:15,className:"text-emerald-500 flex-shrink-0",strokeWidth:2.4}),(0,a.Y)("span",{className:"text-xs font-medium text-ink",children:"Connected"})]}):(0,a.FD)(a.FK,{children:[(0,a.Y)(eJ.A,{size:15,className:"text-error flex-shrink-0",strokeWidth:2.4}),(0,a.Y)("span",{className:"text-xs font-medium text-error",children:"Disconnected"})]}),(0,a.FD)("div",{className:"relative inline-block cursor-help ml-0.5",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[(0,a.Y)(eh.A,{size:13,className:"text-ink/40 hover:text-ink/70 transition-colors"}),s&&(0,a.Y)("div",{className:"absolute left-4 top-1/2 -translate-y-1/2 bg-ink text-canvas text-[10px] rounded px-2.5 py-1.5 shadow-xl whitespace-nowrap z-50 pointer-events-none",children:p?"Provider is disabled — none of its models appear in the chat model list":c?"Endpoint validated and operational for agent inference":"Provider authentication is currently offline or inactive"})]})]}),(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.Y)("button",{type:"button",onClick:l,title:p?"Offer this provider in the model list again":"Remove this provider from the model list",className:"px-3 py-1.5 rounded-md bg-ink/5 hover:bg-ink/10 text-ink text-xs font-medium transition-colors cursor-pointer border border-ink/10",children:p?"enable":"disable"}),(0,a.Y)("button",{type:"button",onClick:i,className:"px-3 py-1.5 rounded-md bg-ink/5 hover:bg-ink/10 text-ink text-xs font-medium transition-colors cursor-pointer border border-ink/10",children:c?"reconnect":"connect"})]})]})]}),(0,a.Y)("div",{className:"border-b border-ink/10"}),(0,a.FD)("div",{className:"space-y-3",children:[(0,a.Y)("div",{className:"text-xs font-semibold text-ink",children:"Connection Details"}),(0,a.FD)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.FD)("div",{className:"text-xs text-ink/70",children:["Configured in: ",(0,a.Y)("span",{className:"font-mono text-ink font-medium",children:t.configuredIn})]}),c?(0,a.Y)("button",{type:"button",onClick:o,className:"text-xs text-error/90 hover:text-error font-medium hover:underline transition-colors cursor-pointer",children:"disconnect"}):(0,a.Y)("span",{className:"text-xs text-ink/40 italic",children:"inactive"})]})]}),(0,a.Y)("div",{className:"border-b border-ink/10"})]})}let eG=(0,g.A)({name:"sliders-horizontal",size:24,node:[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]});var eH=i("W");let eW=(0,g.A)({name:"image",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]});var eV=i("bH"),eX=i("Soe"),eQ=i("pm"),eZ=i("U8");function e0(e){let{models:t,onToggleModelVisibility:i,onHideAll:o,onShowAll:l,onFetchModels:r,canFetchModels:s,isFetchingModels:d,onOpenModelConfig:c,onOpenModelCapabilities:p}=e,[u,m]=(0,n.J0)(""),b=t.filter(e=>e.name.toLowerCase().includes(u.toLowerCase()));return(0,a.FD)("div",{className:"space-y-3.5",children:[(0,a.FD)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.FD)("div",{className:"text-xs font-semibold text-ink",children:["Available Models ",(0,a.FD)("span",{className:"font-normal text-ink/60",children:["(",t.length,")"]})]}),(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.FD)("button",{type:"button",onClick:r,disabled:!s||d,title:s?"Fetch models from provider endpoint":"This provider has no fetchable endpoint",className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded bg-ink text-canvas text-[11px] font-medium hover:opacity-90 transition-opacity cursor-pointer border border-ink disabled:opacity-40 disabled:cursor-not-allowed",children:[(0,a.Y)(D.A,{size:12,className:d?"animate-spin":""}),(0,a.Y)("span",{children:d?"fetching...":"fetch models"})]}),(0,a.Y)("button",{type:"button",onClick:o,className:"px-2.5 py-1 rounded bg-ink/5 hover:bg-ink/10 text-[11px] font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer border border-ink/10",children:"hide all"}),(0,a.Y)("button",{type:"button",onClick:l,className:"px-2.5 py-1 rounded bg-ink/5 hover:bg-ink/10 text-[11px] font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer border border-ink/10",children:"show all"})]})]}),(0,a.FD)("div",{className:"relative flex items-center",children:[(0,a.Y)(C.A,{size:14,className:"absolute left-3 text-ink/40 pointer-events-none"}),(0,a.Y)("input",{type:"text",value:u,onChange:e=>m(e.currentTarget.value),placeholder:"Filter models...",className:"w-full bg-paper border border-ink/15 rounded-lg pl-9 pr-3 py-2 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors shadow-2xs"}),u&&(0,a.Y)("button",{type:"button",onClick:()=>m(""),className:"absolute right-3 text-[11px] text-ink/40 hover:text-ink cursor-pointer",children:"clear"})]}),(0,a.Y)("div",{className:"space-y-1 pt-1",children:0===b.length?(0,a.FD)("div",{className:"py-8 text-center text-xs text-ink/40",children:['No models found matching "',u,'"']}):b.map(e=>(0,a.FD)("div",{className:`flex items-center justify-between gap-3 px-3 py-2.5 rounded-lg hover:bg-ink/5 transition-colors group ${!e.isVisible?"opacity-50":""}`,children:[(0,a.Y)("div",{className:"min-w-0 flex-1",children:(0,a.Y)("span",{className:`text-xs font-medium truncate block ${e.isVisible?"text-ink":"text-ink/60 line-through decoration-ink/40"}`,children:e.name})}),(0,a.FD)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[(void 0!==e.priceInput||void 0!==e.priceOutput)&&(0,a.FD)("span",{title:`$${e.priceInput??"?"} in / $${e.priceOutput??"?"} out per 1M tokens`,className:"text-[11px] font-mono px-2 py-0.5 rounded bg-ink/5 text-ink/70 border border-ink/10",children:[(0,eZ.$g)(e.priceInput)," / ",(0,eZ.$g)(e.priceOutput)]}),e.contextWindow&&(0,a.Y)("span",{className:"text-[11px] font-mono px-2 py-0.5 rounded bg-ink/5 text-ink/70 border border-ink/10",children:(0,eQ.F)(e.contextWindow)}),e.hasTools&&(0,a.Y)("button",{type:"button",onClick:()=>p(e),title:"Tool Calling & Steering Capabilities",className:"p-1 rounded text-ink/50 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:(0,a.Y)(eG,{size:13,strokeWidth:1.8})}),(0,a.Y)("button",{type:"button",onClick:()=>c(e),title:"Configure Model Parameters",className:"p-1 rounded text-ink/50 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:(0,a.Y)(eH.A,{size:13,strokeWidth:1.8})}),e.hasVision&&(0,a.Y)("div",{title:"Multimodal / Vision inputs enabled",className:"p-1 text-ink/60",children:(0,a.Y)(eW,{size:13,strokeWidth:1.8})}),(0,a.Y)("button",{type:"button",onClick:()=>i(e.id),title:e.isVisible?"Hide model from chat picker":"Show model in chat picker",className:`p-1 rounded transition-colors cursor-pointer ${e.isVisible?"text-ink/60 hover:text-ink hover:bg-ink/10":"text-ink/30 hover:text-ink/70 hover:bg-ink/10"}`,children:e.isVisible?(0,a.Y)(eV.A,{size:14,strokeWidth:1.8}):(0,a.Y)(eX.A,{size:14,strokeWidth:1.8})})]})]},e.id))})]})}var e1=i("oE");let e5=(0,g.A)({name:"cloud-download",size:24,node:[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]],aliases:["download-cloud"]}),e2=(0,g.A)({name:"key",size:24,node:[["path",{d:"m2 21 9.6-9.6",key:"9l79m3"}],["path",{d:"m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19",key:"fw8biw"}],["circle",{cx:"15.5",cy:"7.5",r:"5.5",key:"4wxmhb"}]]});function e3(e){let{onClose:t,header:i,children:n,footer:o,form:r,maxWidthClass:s="max-w-md",zClass:d="z-[60]"}=e,c=(0,a.FD)(a.FK,{children:[n,o]});return(0,a.Y)("div",{className:`fixed inset-0 bg-ink/40 backdrop-blur-[2px] ${d} flex items-center justify-center p-4`,onClick:t,children:(0,a.FD)("div",{className:`bg-paper border border-ink/15 rounded-xl shadow-2xl w-full ${s} overflow-hidden text-ink`,onClick:e=>e.stopPropagation(),children:[(0,a.FD)("div",{className:"px-5 py-4 border-b border-ink/10 flex items-center justify-between",children:[i,(0,a.Y)("button",{type:"button",onClick:t,className:"p-1 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:(0,a.Y)(l.A,{size:16})})]}),r?(0,a.Y)("form",{onSubmit:r.onSubmit,className:r.className,children:c}):c]})})}function e4(e){let{isOpen:t,onClose:i,onAddProvider:o,presets:l}=e,s=l[0],[d,c]=(0,n.J0)(s?.id||"openai"),[p,u]=(0,n.J0)(s?.name||"OpenAI"),[m,b]=(0,n.J0)(s?.defaultUrl||"https://api.openai.com/v1"),[h,f]=(0,n.J0)(""),[g,v]=(0,n.J0)(!1),x=e=>{c(e.id),u(e.name),b(e.defaultUrl)};if((0,n.vJ)(()=>{!l.find(e=>e.id===d)&&l[0]&&x(l[0])},[l,d]),!t)return null;let k=async e=>{if(e.preventDefault(),p.trim()&&0!==l.length&&!g){v(!0);try{let e=l.find(e=>e.id===d),t=Date.now(),a={id:`provider-${t}`,name:p.trim(),slug:p.toLowerCase().replace(/[^a-z0-9]/g,"-")||`provider-${t}`,icon:e?.icon||"custom",status:"connected",configuredIn:"auth credentials",baseUrl:m.trim(),apiKey:h.trim()||"sk-custom-••••••••••••••••••••••••",models:[]},n=await eI(m.trim(),h.trim()||void 0,a.slug,!0);n.ok&&n.models?(a.models=n.models,o(a,{fetchedCount:n.models.length})):o(a,{fetchedCount:-1}),i()}finally{v(!1)}}};return(0,a.FD)(e3,{onClose:i,header:(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.Y)(e1.A,{size:16,className:"text-ink/70"}),(0,a.Y)("h3",{className:"text-sm font-semibold text-ink",children:"Add Model Provider"})]}),form:{onSubmit:k,className:"p-5 space-y-4"},footer:(0,a.FD)("div",{className:"pt-2 flex items-center justify-end gap-2 border-t border-ink/10",children:[(0,a.Y)("button",{type:"button",onClick:i,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),(0,a.Y)("button",{type:"submit",disabled:g||0===l.length,className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:g?(0,a.FD)(a.FK,{children:[(0,a.Y)(e5,{size:14,className:"animate-pulse"}),(0,a.Y)("span",{children:"Fetching models..."})]}):(0,a.FD)(a.FK,{children:[(0,a.Y)(r.A,{size:14}),(0,a.Y)("span",{children:"Connect Provider"})]})})]}),children:[(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink mb-1.5",children:"Provider Preset"}),(0,a.FD)("div",{className:"grid grid-cols-2 gap-2 max-h-36 scrollbar-overlay-container scrollbar-overlay-static pr-1",children:[0===l.length&&(0,a.Y)("p",{className:"col-span-2 px-2 py-3 text-xs text-ink/50",children:"All known provider types are already connected."}),l.map(e=>{let t=e.id===d;return(0,a.FD)("button",{type:"button",onClick:()=>x(e),className:`flex items-center gap-2 p-2 rounded-lg border text-left text-xs transition-colors cursor-pointer ${t?"border-ink/50 bg-ink/5 font-semibold text-ink shadow-2xs":"border-ink/15 hover:border-ink/30 text-ink/70"}`,children:[(0,a.Y)(eU,{icon:e.icon,size:14}),(0,a.Y)("span",{className:"truncate",children:e.name})]},e.id)})]})]}),(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Display Name"}),(0,a.Y)("input",{type:"text",required:!0,value:p,onChange:e=>u(e.currentTarget.value),placeholder:"e.g. My Provider",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60"})]}),(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink mb-1",children:"API Base URL"}),(0,a.FD)("div",{className:"relative flex items-center",children:[(0,a.Y)(Z.A,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),(0,a.Y)("input",{type:"text",required:!0,value:m,onChange:e=>b(e.currentTarget.value),placeholder:"https://api.domain.com/v1",className:"w-full bg-paper border border-ink/20 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]})]}),(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink mb-1",children:"API Key (stored securely)"}),(0,a.FD)("div",{className:"relative flex items-center",children:[(0,a.Y)(e2,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),(0,a.Y)("input",{type:"password",value:h,onChange:e=>f(e.currentTarget.value),placeholder:"sk-••••••••••••••••",className:"w-full bg-paper border border-ink/20 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]})]})]})}var e6=i("m");function e8(e){let{isOpen:t,provider:i,isFetchingModels:o,onClose:l,onReconnect:r,onFetchModels:s}=e,[d,c]=(0,n.J0)(i.apiKey||"sk-••••••••••••••••••••••••"),[p,u]=(0,n.J0)(i.baseUrl||"https://api.openai.com/v1"),[m,b]=(0,n.J0)(!1),[h,f]=(0,n.J0)(null);if(!t)return null;let g={apiKey:d.includes("••••")?void 0:d,baseUrl:p},v=async()=>{b(!0),f(null);let e=await eI(p,g.apiKey);b(!1),f(e.ok?"success":"failed")},x=async e=>{e.preventDefault(),r({apiKey:d,baseUrl:p,status:"connected"}),await s(g),l()};return(0,a.FD)(e3,{onClose:l,header:(0,a.FD)("div",{className:"flex items-center gap-2.5",children:[(0,a.Y)(eU,{icon:i.icon,size:18}),(0,a.FD)("div",{children:[(0,a.Y)("h3",{className:"text-sm font-semibold text-ink",children:"Authentication & Credentials"}),(0,a.Y)("p",{className:"text-[11px] text-ink/50 font-mono",children:i.slug})]})]}),form:{onSubmit:x,className:"p-5 space-y-4"},footer:(0,a.FD)("div",{className:"pt-3 flex items-center justify-end gap-2 border-t border-ink/10",children:[(0,a.Y)("button",{type:"button",onClick:l,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),(0,a.FD)("button",{type:"submit",disabled:o,className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:[(0,a.Y)(D.A,{size:13,className:o?"animate-spin":""}),(0,a.Y)("span",{children:o?"Fetching models...":"Save & Reconnect"})]})]}),children:[(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Endpoint URL"}),(0,a.FD)("div",{className:"relative flex items-center",children:[(0,a.Y)(Z.A,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),(0,a.Y)("input",{type:"text",value:p,onChange:e=>u(e.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]})]}),(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink mb-1",children:"API Key / Auth Token"}),(0,a.FD)("div",{className:"relative flex items-center",children:[(0,a.Y)(e2,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),(0,a.Y)("input",{type:"text",value:d,onChange:e=>c(e.currentTarget.value),className:"w-full bg-paper border border-ink/20 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]})]}),(0,a.FD)("div",{className:"flex items-center justify-between pt-1",children:[(0,a.FD)("button",{type:"button",disabled:m||o,onClick:v,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 text-xs font-medium text-ink transition-colors cursor-pointer bg-ink/5 disabled:opacity-50",children:[(0,a.Y)(D.A,{size:13,className:m?"animate-spin":""}),(0,a.Y)("span",{children:m?"Testing endpoint...":"Test Connection"})]}),"success"===h&&(0,a.FD)("span",{className:"inline-flex items-center gap-1 text-xs text-emerald-500 font-medium",children:[(0,a.Y)(e6.A,{size:13}),(0,a.Y)("span",{children:"Models endpoint reachable"})]}),"failed"===h&&(0,a.FD)("span",{className:"inline-flex items-center gap-1 text-xs text-error font-medium",children:[(0,a.Y)(eJ.A,{size:13}),(0,a.Y)("span",{children:"Connection failed"})]})]}),(0,a.FD)("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md bg-ink/5 border border-ink/10 text-[11px] text-ink/60",children:[(0,a.Y)(e5,{size:13,className:"mt-0.5 flex-shrink-0 text-ink/50"}),(0,a.Y)("span",{children:"On save, models are fetched from the endpoint and merged into the list below — existing models are kept, only new ones are added."})]})]})}var e7=i("t");function e9(e){let{isOpen:t,provider:i,onClose:o,onAuthenticated:l}=e,[r,s]=(0,n.J0)("connecting"),[d,c]=(0,n.J0)(null),[p,u]=(0,n.J0)(null),[m,b]=(0,n.J0)(null),[h,f]=(0,n.J0)(""),[g,v]=(0,n.J0)(null),x=(0,n.li)(null),k=(0,n.li)(l);k.current=l,(0,n.vJ)(()=>{if(!t)return;s("connecting"),c(null),u(null),b(null),v(null),f("");let e=new AbortController,a=t=>{fetch("/api/omp/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:e.signal}).catch(()=>{})};return x.current=a,fetch("/api/omp/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:i.slug}),signal:e.signal}).then(async t=>{if(!t.body)throw Error("Streaming not supported");let i=t.body.getReader(),n=new TextDecoder,o="";for(;;){let{done:t,value:l}=await i.read();if(t)break;let r=(o+=n.decode(l,{stream:!0})).split("\n\n");for(let t of(o=r.pop()??"",r)){let i=t.split("\n").find(e=>e.startsWith("data: "));if(i)try{let t=JSON.parse(i.slice(6));if("extension_ui_request"===t.type)s("waiting"),"open_url"===t.method&&t.launchUrl?(c(t.launchUrl),window.open(t.launchUrl,"_blank","noopener")):"input"===t.method?u(t):"notify"===t.method?(b(t.title??""),t.title&&a({id:t.id,accepted:!0})):a({id:t.id,cancelled:!0});else if("login_result"===t.type){s(t.success?"success":"failed"),t.success||v(t.error??"Login failed"),t.success&&k.current(),e.abort();return}}catch{}}}}).catch(t=>{e.signal.aborted||(s("failed"),v(t instanceof Error?t.message:String(t)))}),()=>{e.abort(),x.current=null}},[t,i.slug]);let y=e=>{p&&(x.current?.(e?{id:p.id,cancelled:!0}:{id:p.id,value:h}),u(null),s("connecting"))};return t?(0,a.Y)(e3,{onClose:o,header:(0,a.FD)("div",{className:"flex items-center gap-2.5",children:[(0,a.Y)(eU,{icon:i.icon,size:18}),(0,a.FD)("div",{children:[(0,a.FD)("h3",{className:"text-sm font-semibold text-ink",children:["Sign in to ",i.name]}),(0,a.Y)("p",{className:"text-[11px] text-ink/50 font-mono",children:i.slug})]})]}),footer:(0,a.Y)("div",{className:"px-5 py-3 border-t border-ink/10 flex justify-end",children:(0,a.Y)("button",{type:"button",onClick:o,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"success"===r?"Done":"Close"})}),children:(0,a.FD)("div",{className:"p-5 space-y-4",children:["connecting"===r&&(0,a.FD)("div",{className:"flex items-center gap-2.5 text-xs text-ink/70",children:[(0,a.Y)(e7.A,{size:14,className:"animate-spin"}),"Starting login flow..."]}),"waiting"===r&&(0,a.FD)("div",{className:"space-y-4",children:[d&&(0,a.FD)("div",{className:"space-y-2",children:[(0,a.FD)("div",{className:"flex items-center gap-2 text-xs font-semibold text-ink",children:[(0,a.Y)(Z.A,{size:13,className:"text-ink/50"})," OAuth browser"]}),(0,a.Y)("p",{className:"text-xs text-ink/60",children:"Complete the sign-in in the opened browser tab."}),(0,a.Y)("button",{type:"button",onClick:()=>window.open(d,"_blank","noopener"),className:"text-xs text-ink underline underline-offset-2 break-all text-left",children:d})]}),p&&(0,a.FD)("div",{className:"space-y-2",children:[(0,a.FD)("div",{className:"flex items-center gap-2 text-xs font-semibold text-ink",children:[(0,a.Y)(e2,{size:13,className:"text-ink/50"})," ",p.title??"Credential"]}),(0,a.Y)("input",{type:"text",autoFocus:!0,value:h,onChange:e=>f(e.currentTarget.value),onKeyDown:e=>"Enter"===e.key&&y(!1),placeholder:p.placeholder??"Paste your API key",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"}),(0,a.FD)("div",{className:"flex justify-end gap-2",children:[(0,a.Y)("button",{type:"button",onClick:()=>y(!0),className:"px-3 py-1.5 rounded-md border border-ink/20 text-xs text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),(0,a.Y)("button",{type:"button",onClick:()=>y(!1),className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer",children:"Submit"})]})]}),m&&(0,a.Y)("p",{className:"text-xs text-ink/60",children:m}),!d&&!p&&!m&&(0,a.Y)("p",{className:"text-xs text-ink/50",children:"Waiting for the provider flow..."})]}),"success"===r&&(0,a.FD)("div",{className:"flex items-center gap-2 text-xs text-emerald-500 font-medium",children:[(0,a.Y)(e6.A,{size:14})," Signed in. Credentials stored by omp."]}),"failed"===r&&(0,a.FD)("div",{className:"flex items-start gap-2 text-xs text-error font-medium",children:[(0,a.Y)(eJ.A,{size:14,className:"mt-0.5 shrink-0"}),(0,a.Y)("span",{children:g??"Login failed"})]})]})}):null}function te(e){let{isOpen:t,model:i,onClose:o,onSaveModelConfig:l}=e;if(!t||!i)return null;let[s,d]=(0,n.J0)(i.temperature??.7),[c,p]=(0,n.J0)(i.maxTokens??384e3),[u,m]=(0,n.J0)(i.topP??.95),[b,h]=(0,n.J0)(i.reasoningEffort??"medium");return(0,a.FD)(e3,{onClose:o,header:(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.Y)(eH.A,{size:16,className:"text-ink/70"}),(0,a.FD)("div",{children:[(0,a.Y)("h3",{className:"text-sm font-semibold text-ink",children:"Model Configuration"}),(0,a.Y)("p",{className:"text-[11px] text-ink/50 truncate max-w-[280px]",children:i.name})]})]}),form:{onSubmit:e=>{e.preventDefault(),l(i.id,{temperature:s,maxTokens:c,topP:u,reasoningEffort:b}),o()},className:"p-5 space-y-4"},footer:(0,a.FD)("div",{className:"pt-2 flex items-center justify-end gap-2 border-t border-ink/10",children:[(0,a.Y)("button",{type:"button",onClick:o,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),(0,a.FD)("button",{type:"submit",className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer flex items-center gap-1.5",children:[(0,a.Y)(r.A,{size:14}),(0,a.Y)("span",{children:"Save Parameters"})]})]}),children:[(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center justify-between mb-1 text-xs",children:[(0,a.Y)("span",{className:"font-semibold text-ink",children:"Sampling Temperature"}),(0,a.Y)("span",{className:"font-mono text-ink/70 font-semibold",children:s.toFixed(2)})]}),(0,a.Y)("input",{type:"range",min:"0.0",max:"2.0",step:"0.05",value:s,onChange:e=>d(parseFloat(e.currentTarget.value)),className:"w-full accent-ink cursor-pointer"}),(0,a.Y)("p",{className:"text-[10px] text-ink/40 mt-0.5",children:"Controls randomness: lower is more deterministic, higher is more creative."})]}),(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center justify-between mb-1 text-xs",children:[(0,a.Y)("span",{className:"font-semibold text-ink",children:"Top P (Nucleus Sampling)"}),(0,a.Y)("span",{className:"font-mono text-ink/70 font-semibold",children:u.toFixed(2)})]}),(0,a.Y)("input",{type:"range",min:"0.1",max:"1.0",step:"0.05",value:u,onChange:e=>m(parseFloat(e.currentTarget.value)),className:"w-full accent-ink cursor-pointer"})]}),(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Max Output Tokens"}),(0,a.Y)("input",{type:"number",min:1024,max:1e6,step:1024,value:c,onChange:e=>p(parseInt(e.currentTarget.value,10)||4096),className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]}),i.hasReasoning&&(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink mb-1.5",children:"Reasoning Effort"}),(0,a.Y)("div",{className:"grid grid-cols-3 gap-2",children:["low","medium","high"].map(e=>(0,a.Y)("button",{type:"button",onClick:()=>h(e),className:`py-1.5 rounded-md text-xs font-medium border text-center transition-colors cursor-pointer capitalize ${b===e?"border-ink/50 bg-ink/10 text-ink":"border-ink/15 text-ink/60 hover:border-ink/30"}`,children:e},e))})]})]})}var tt=i("B5");function ti(e){let{isOpen:t,model:i,onClose:n}=e;if(!t||!i)return null;let o=[{title:"Tool & Function Calling",desc:"Allows autonomous agents to invoke CLI scripts, read files, and manipulate workspace files.",enabled:i.hasTools,icon:N.A},{title:"Multimodal Vision",desc:"Analyzes visual screenshots, terminal diffs, diagrams, and image uploads directly.",enabled:i.hasVision,icon:eV.A},{title:"Extended Reasoning & Thinking Blocks",desc:"Provides deep chain-of-thought scratchpad tokens before outputting code patches.",enabled:!!i.hasReasoning,icon:x.A},{title:"Structured Output (JSON Schema)",desc:"Forces strict conformance to specified JSON schemas for deterministic tool execution.",enabled:!0,icon:tt.A},{title:"Streaming Inference",desc:"Delivers real-time incremental token chunks to the chat timeline with zero latency.",enabled:!0,icon:ef.A}];return(0,a.Y)(e3,{onClose:n,header:(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.Y)(eG,{size:16,className:"text-ink/70"}),(0,a.FD)("div",{children:[(0,a.Y)("h3",{className:"text-sm font-semibold text-ink",children:"Model Capabilities & Tools"}),(0,a.Y)("p",{className:"text-[11px] text-ink/50 truncate max-w-[280px]",children:i.name})]})]}),footer:(0,a.Y)("div",{className:"px-5 py-3 border-t border-ink/10 flex justify-end",children:(0,a.Y)("button",{type:"button",onClick:n,className:"px-4 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer",children:"Close"})}),children:(0,a.Y)("div",{className:"p-5 space-y-3",children:o.map(e=>{let t=e.icon;return(0,a.FD)("div",{className:"flex items-start gap-3 p-2.5 rounded-lg bg-ink/5 border border-ink/10",children:[(0,a.Y)("div",{className:"p-1.5 rounded bg-ink/10 text-ink mt-0.5",children:(0,a.Y)(t,{size:14})}),(0,a.FD)("div",{className:"flex-1 min-w-0",children:[(0,a.FD)("div",{className:"flex items-center justify-between",children:[(0,a.Y)("span",{className:"text-xs font-semibold text-ink",children:e.title}),e.enabled?(0,a.FD)("span",{className:"inline-flex items-center gap-1 text-[10px] text-emerald-500 font-semibold uppercase tracking-wider",children:[(0,a.Y)(r.A,{size:11,strokeWidth:2.5}),"Supported"]}):(0,a.Y)("span",{className:"text-[10px] text-ink/40 font-medium uppercase tracking-wider",children:"Not supported"})]}),(0,a.Y)("p",{className:"text-[11px] text-ink/60 mt-0.5 leading-relaxed",children:e.desc})]})]},e.title)})})})}function ta(e){let{autoOpenAdd:t=!1,onAddModalClose:i}=e,{connectedProviders:o,availablePresetProviders:l,selectedProvider:r,currentProject:s,setCurrentProject:d,isFetchingModels:c,toasts:p,dismissToast:u,isAddModalOpen:m,setIsAddModalOpen:b,isReconnectModalOpen:h,setIsReconnectModalOpen:f,isLoginModalOpen:g,setIsLoginModalOpen:v,configModel:x,setConfigModel:k,capabilitiesModel:y,setCapabilitiesModel:w,setSelectedProviderId:N,handleAddProvider:A,handleReconnect:Y,handleFetchModels:S,handleFetchModelsFromList:C,handleOmpAuthSuccess:D,handleToggleDisconnect:F,handleToggleProviderDisabled:T,handleHideAll:M,handleShowAll:P,handleToggleModelVisibility:I,handleSaveModelConfig:R}=function(){let{autoOpenAdd:e=!1,onAddModalClose:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[i,a]=(0,n.J0)([]),[o,l]=(0,n.J0)(eM),[r,s]=(0,n.J0)("provider-deepseek"),[d,c]=(0,n.J0)("ompchamber"),[p,u]=(0,n.J0)(!1),{toasts:m,pushToast:b,dismissToast:h}=(0,eO.Y)(),[f,g]=(0,n.J0)(e),[v,x]=(0,n.J0)(!1),[k,y]=(0,n.J0)(!1),[w,N]=(0,n.J0)(null),[A,Y]=(0,n.J0)(null);(0,n.vJ)(()=>{e&&g(!0)},[e]),(0,n.vJ)(()=>{let e=!0;return fetch("/api/settings/providers").then(e=>e.json()).then(t=>{if(e){if(t?.providers&&Array.isArray(t.providers)){a(t.providers);let e=t.providers.filter(e=>"connected"===e.status);s(e.length>0?e[0].id:"")}t?.presetProviders&&l(t.presetProviders)}}).catch(e=>console.error("Failed to load providers from API:",e)),()=>{e=!1}},[]);let S=(0,n.Kr)(()=>i.filter(e=>"connected"===e.status||!0===e.disabled),[i]),C=(0,n.Kr)(()=>{let e,t;return e=new Set(i.filter(e=>"connected"===e.status).map(e=>e.slug.trim().toLowerCase())),t=new Set,[...o,...i.filter(e=>"connected"!==e.status).map(e=>({id:e.slug,name:e.name,slug:e.slug,icon:e.icon,defaultUrl:e.baseUrl||"https://"}))].filter(i=>{let a=i.slug.trim().toLowerCase();return!(e.has(a)||t.has(a))&&(t.add(a),!0)})},[i,o]),D=S.find(e=>e.id===r)||S[0],F=async e=>{a(e);try{let t=await eL({providers:e});t&&a(t)}catch(e){console.error("Failed to save providers via API:",e),b("Failed to save provider settings.","error")}},T=async(e,t)=>{try{let i=await eL(t?{enableProvider:e}:{disableProvider:e});return i&&a(i),i}catch(e){return console.error("Failed to update provider connection:",e),b("Failed to update the provider connection.","error"),null}},M=async(e,a)=>{await F([...i,e]);let n=await T(e.slug,!0),o=n?.find(t=>t.slug.trim().toLowerCase()===e.slug.trim().toLowerCase());s(o?.id||e.id),g(!1),t?.(),a.fetchedCount>0?b(`Fetched ${a.fetchedCount} new model${1===a.fetchedCount?"":"s"} from the provider.`,"success"):-1===a.fetchedCount&&b("Auto-fetch models failed — provider added with default models.","error"),eR(e.name,e.models)},P=async e=>{D&&(await F(i.map(t=>t.id===D.id?{...t,...e,status:"connected"}:t)),"connected"!==D.status&&await T(D.slug,!0))},I=async e=>{if(!D||p)return;let t=e.baseUrl||D.baseUrl;if(!t)return void b("Base URL is required to fetch models.","error");u(!0);try{var i;let a=await eI(t,e.apiKey||D.apiKey,D.slug,!0);if(!a.ok||!a.models)return void b(a.error||"Failed to fetch models from the provider.","error");let n=(i=D.models,`${D.name} ${D.slug} ${D.baseUrl||""}`.toLowerCase().includes("kenari")?i.filter(e=>{let t=e.name.trim().toLowerCase();return!(eE.test(e.id)&&("kenari default model"===t||"kenari fast / flash"===t))}):i),o=D.models.length-n.length,{merged:l,addedCount:r}=function(e,t){let i=new Set(e.map(e=>e.id)),a=[];for(let e of t)!e.id||i.has(e.id)||(i.add(e.id),a.push({...e}));return{merged:[...e,...a],added:a,addedCount:a.length}}(n,a.models);if((r>0||o>0)&&await P({models:l}),a.omp?.written&&(0,eP.$P)(),r>0?b(`Fetched ${r} new model${1===r?"":"s"} from the provider.`,"success"):o>0?b("Removed legacy fallback models from the provider.","success"):b("No new models found — all fetched models already exist.","success"),a.omp?.written){let e=[];a.omp.addedCount>0&&e.push(`${a.omp.addedCount} new model${1===a.omp.addedCount?"":"s"} registered`),a.omp.backfilledCount>0&&e.push(`${a.omp.backfilledCount} model${1===a.omp.backfilledCount?"":"s"} enriched`),b(`omp models.yml updated${e.length>0?`: ${e.join(", ")}`:""}.`,"success")}else a.omp&&!a.omp.written&&a.omp.reason&&b(`omp models.yml not updated: ${a.omp.reason}`,"error")}finally{u(!1)}},R=async()=>{D&&await I({apiKey:D.apiKey,baseUrl:D.baseUrl})},E=async()=>{if(!D)return;let e="connected"===D.status;e&&s(S.find(e=>e.id!==D.id)?.id||""),await T(D.slug,!e)&&b(e?`${D.name} disconnected — its models are no longer offered in the chat picker.`:`${D.name} reconnected.`,"success")},L=e=>{D&&F(i.map(t=>t.id===D.id?{...t,models:e(t.models)}:t))},O=async()=>{if(!D)return;let e=!0!==D.disabled;await T(D.slug,!e)&&b(e?`${D.name} disabled — it no longer appears in the model list.`:`${D.name} enabled — its models are offered again.`,"success")};return{providers:i,connectedProviders:S,availablePresetProviders:C,selectedProvider:D,currentProject:d,setCurrentProject:c,isFetchingModels:p,toasts:m,pushToast:b,dismissToast:h,isAddModalOpen:f,setIsAddModalOpen:g,isReconnectModalOpen:v,setIsReconnectModalOpen:x,isLoginModalOpen:k,setIsLoginModalOpen:y,configModel:w,setConfigModel:N,capabilitiesModel:A,setCapabilitiesModel:Y,setSelectedProviderId:s,handleAddProvider:M,handleReconnect:P,handleFetchModels:I,handleFetchModelsFromList:R,handleOmpAuthSuccess:()=>{D&&(F(i.map(e=>e.id===D.id?{...e,status:"connected"}:e)),T(D.slug,!0))},handleToggleDisconnect:E,handleToggleProviderDisabled:O,handleHideAll:()=>L(e=>e.map(e=>({...e,isVisible:!1}))),handleShowAll:()=>L(e=>e.map(e=>({...e,isVisible:!0}))),handleToggleModelVisibility:e=>L(t=>t.map(t=>t.id===e?{...t,isVisible:!t.isVisible}:t)),handleSaveModelConfig:(e,t)=>L(i=>i.map(i=>i.id===e?{...i,...t}:i))}}({autoOpenAdd:t,onAddModalClose:i});return(0,a.FD)("div",{className:"w-full h-full flex flex-col md:flex-row overflow-hidden bg-paper text-ink",children:[(0,a.Y)(eK,{providers:o,selectedProviderId:r?.id||"",onSelectProvider:N,onOpenAddModal:()=>b(!0),currentProject:s,onSelectProject:d}),(0,a.Y)("div",{className:"flex-1 scrollbar-overlay-container scrollbar-overlay-static p-6 md:p-8 space-y-6",children:r?(0,a.FD)(a.FK,{children:[(0,a.Y)(eq,{provider:r}),(0,a.Y)(e$,{provider:r,onOpenReconnectModal:()=>{r.id.startsWith("omp-auth-")?v(!0):f(!0)},onToggleDisconnect:F,onToggleDisabled:T}),(0,a.Y)(e0,{models:r.models,onToggleModelVisibility:I,onHideAll:M,onShowAll:P,onFetchModels:C,canFetchModels:!!r.baseUrl,isFetchingModels:c,onOpenModelConfig:e=>k(e),onOpenModelCapabilities:e=>w(e)})]}):(0,a.Y)("div",{className:"py-12 text-center text-xs text-ink/40",children:"Select a provider from the sidebar to view connection details"})}),(0,a.Y)(eT.y,{toasts:p,onDismiss:u}),(0,a.Y)(e4,{isOpen:m,onClose:()=>{b(!1),i?.()},onAddProvider:A,presets:l}),r&&(0,a.Y)(e8,{isOpen:h,provider:r,isFetchingModels:c,onClose:()=>f(!1),onReconnect:Y,onFetchModels:S}),r&&(0,a.Y)(e9,{isOpen:g,provider:r,onClose:()=>v(!1),onAuthenticated:D}),(0,a.Y)(te,{isOpen:!!x,model:x,onClose:()=>k(null),onSaveModelConfig:R}),(0,a.Y)(ti,{isOpen:!!y,model:y,onClose:()=>w(null)})]})}let tn=[{id:"ompchamber",name:"ompchamber",label:"ompchamber"},{id:"workspace-edge",name:"workspace-edge",label:"workspace-edge"},{id:"global",name:"global config",label:"Global (All Projects)"}],to=(e,t)=>t,tl=e=>{let{selectedProject:t,onChangeProject:i,options:o=tn,getTriggerLabel:l=to,variant:s="default"}=e,[d,c]=(0,n.J0)(!1),p=(0,n.li)(null);(0,ev.W)(p,()=>c(!1));let u=l(o,t),m=o.map(e=>{let n=e.value??e.id,o=t===n;return(0,a.Y)("button",{type:"button",onClick:()=>{i(n),c(!1)},className:"compact"===s?`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer ${o?"text-ink font-semibold bg-ink/5":"text-ink/70"}`:`w-full px-3 py-1.5 text-left text-xs flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer ${o?"font-semibold text-ink bg-ink/5":"text-ink/80"}`,children:"compact"===s?(0,a.FD)(a.FK,{children:[(0,a.Y)("span",{className:"truncate",children:e.label}),o&&(0,a.Y)(r.A,{size:12,className:"text-ink flex-shrink-0"})]}):(0,a.FD)("div",{className:"flex items-center gap-2 truncate",children:[(0,a.Y)($.A,{size:13,className:"text-ink/60"}),(0,a.Y)("span",{className:"truncate",children:e.name})]})},e.id)});return"compact"===s?(0,a.FD)("div",{className:"p-2.5 border-b border-ink/10 relative",ref:p,children:[(0,a.FD)("button",{type:"button",onClick:()=>c(!d),className:"w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper text-xs text-ink transition-colors cursor-pointer",children:[(0,a.FD)("div",{className:"flex items-center gap-2 truncate",children:[(0,a.Y)($.A,{size:14,className:"text-ink/60 flex-shrink-0"}),(0,a.Y)("span",{className:"truncate font-medium",children:u})]}),(0,a.Y)(eg.A,{size:14,className:"text-ink/50 flex-shrink-0"})]}),d&&(0,a.FD)(a.FK,{children:[(0,a.Y)("div",{className:"fixed inset-0 z-20",onClick:()=>c(!1)}),(0,a.Y)("div",{className:"absolute left-2.5 right-2.5 top-12 z-30 bg-paper border border-ink/15 rounded-lg shadow-lg py-1 animate-in fade-in zoom-in-95 duration-100",children:m})]})]}):(0,a.FD)("div",{className:"p-3 border-b border-ink/10 relative",ref:p,children:[(0,a.FD)("button",{type:"button",onClick:()=>c(!d),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs",children:[(0,a.FD)("div",{className:"flex items-center gap-2 truncate",children:[(0,a.Y)($.A,{size:14,className:"text-ink/60 flex-shrink-0"}),(0,a.Y)("span",{className:"truncate",children:u})]}),(0,a.Y)(eg.A,{size:14,className:"text-ink/50 flex-shrink-0"})]}),d&&(0,a.Y)("div",{className:"absolute top-12 left-3 right-3 bg-paper border border-ink/20 rounded-lg shadow-lg z-30 py-1 divide-y divide-ink/5 animate-in fade-in zoom-in-95 duration-100",children:m})]})},tr=e=>{let{items:t,selectedId:i,onSelect:n,onAddNew:o,addTitle:l,builtInLabel:r,customLabel:s,formatName:d,nameClassName:c,renderIcon:p,selectedProject:u,onChangeProject:m}=e,b=t.filter(e=>e.isBuiltIn),h=t.filter(e=>!e.isBuiltIn),f=e=>{let t=e.id===i;return(0,a.FD)("button",{type:"button",onClick:()=>n(e.id),className:`w-full text-left px-2.5 py-2 rounded-lg transition-colors cursor-pointer flex flex-col gap-0.5 group ${t?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[(0,a.FD)("div",{className:"flex items-center justify-between gap-1.5",children:[(0,a.FD)("div",{className:"flex items-center gap-1.5 min-w-0",children:[p(!!e.isBuiltIn),(0,a.Y)("span",{className:c,children:d(e.name)})]}),(0,a.Y)("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:e.scope})]}),(0,a.Y)("p",{className:"text-[11px] text-ink/60 line-clamp-1 leading-snug pl-5",children:e.description})]},e.id)};return(0,a.FD)("div",{className:"w-56 sm:w-64 border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0 select-none",children:[(0,a.Y)(tl,{selectedProject:u,onChangeProject:m}),(0,a.FD)("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between",children:[(0,a.FD)("span",{className:"text-xs font-semibold text-ink",children:["Total ",t.length]}),(0,a.Y)("button",{type:"button",onClick:o,title:l,className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:(0,a.Y)(ed.A,{size:15,strokeWidth:2.2})})]}),(0,a.FD)("div",{className:"flex-1 scrollbar-overlay-container scrollbar-overlay-static p-1.5 space-y-3 text-xs",children:[(0,a.FD)("div",{children:[(0,a.Y)("div",{className:"px-2.5 pt-1.5 pb-1 text-[10px] font-bold text-ink/50 uppercase tracking-wider",children:r}),(0,a.Y)("div",{className:"space-y-0.5",children:b.map(f)})]}),(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"px-2.5 pt-1.5 pb-1 text-[10px] font-bold text-ink/50 uppercase tracking-wider flex items-center justify-between",children:[(0,a.Y)("span",{children:s}),(0,a.Y)("span",{className:"text-[10px] font-normal",children:h.length})]}),(0,a.Y)("div",{className:"space-y-0.5",children:h.map(f)})]})]})]})},ts=e=>{let{agents:t,selectedAgentId:i,onSelectAgent:n,onAddNewAgent:o,selectedProject:l,onChangeProject:r}=e;return(0,a.Y)(tr,{items:t,selectedId:i,onSelect:n,onAddNew:o,addTitle:"Create new agent",builtInLabel:"Built-in Agents",customLabel:"Custom Agents",formatName:e=>e,nameClassName:"font-semibold text-xs text-ink truncate",selectedProject:l,onChangeProject:r,renderIcon:e=>(0,a.FD)("div",{className:"relative",children:[(0,a.Y)(y.A,{className:`w-3.5 h-3.5 ${e?"text-ink/80":"text-ink/60"} flex-shrink-0`}),e&&(0,a.Y)("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 rounded-full bg-ink"})]})})},td=(0,g.A)({name:"pen-tool",size:24,node:[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]]});var tc=i("DV"),tp=i("b0");let tu=["Not selected","claude-3-7-sonnet-20250219","claude-3-5-sonnet-20241022","claude-3-5-haiku-20241022","gpt-4o","gpt-4o-mini","o3-mini","gemini-2.5-pro-preview-03-25","gemini-2.5-flash","deepseek-chat-v3","deepseek-reasoner-r1"],tm=e=>{let{agent:t,isNew:i=!1,onSave:o,onDelete:l}=e,[s,d]=(0,n.J0)(t),[c,p]=(0,n.J0)(!1),[u,m]=(0,n.J0)(!1);(0,n.vJ)(()=>{d(t),p(!1)},[t]);let b=e=>{d(t=>{let i=Math.max(0,Math.min(2,parseFloat(((t.temperature??.7)+e).toFixed(2))));return{...t,temperature:i}})},h=e=>{d(t=>{let i=Math.max(0,Math.min(1,parseFloat(((t.topP??.95)+e).toFixed(2))));return{...t,topP:i}})};return(0,a.FD)("form",{onSubmit:e=>{e.preventDefault(),o(s),p(!0),setTimeout(()=>p(!1),2e3)},className:"flex-1 flex flex-col h-full scrollbar-overlay-container scrollbar-overlay-static bg-paper text-ink p-6 md:p-8 space-y-6",children:[(0,a.FD)("div",{className:"space-y-3",children:[(0,a.FD)("div",{className:"flex items-center justify-between",children:[(0,a.Y)("h2",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"Identity & Role"}),s.isBuiltIn&&(0,a.Y)("span",{className:"text-[10px] font-mono px-2 py-0.5 rounded-md bg-ink/5 border border-ink/10 text-ink/60",children:"Built-in System Agent (Read-only System Core)"})]}),(0,a.FD)("div",{className:"flex items-center gap-3",children:[(0,a.FD)("div",{className:"flex-1",children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink/80 mb-1.5",children:"Agent Name"}),(0,a.FD)("div",{className:"flex items-center border border-ink/20 hover:border-ink/40 focus-within:border-ink rounded-lg bg-paper transition-colors",children:[(0,a.Y)("span",{className:"px-3 py-2 font-mono text-xs text-ink/40 border-r border-ink/15 select-none",children:"@"}),(0,a.Y)("input",{type:"text",value:s.name,onChange:e=>d({...s,name:e.currentTarget.value}),required:!0,placeholder:"agent-name",disabled:s.isBuiltIn,className:"w-full text-xs font-mono px-3 py-2 bg-transparent focus:outline-none disabled:opacity-60 text-ink"})]})]}),(0,a.FD)("div",{className:"w-40",children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink/80 mb-1.5",children:"Scope"}),(0,a.FD)("select",{value:s.scope,onChange:e=>d({...s,scope:e.currentTarget.value}),disabled:s.isBuiltIn,className:"w-full text-xs py-2 px-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink disabled:opacity-60 text-ink transition-colors cursor-pointer",children:[(0,a.Y)("option",{value:"user",children:"user"}),(0,a.Y)("option",{value:"project",children:"project"}),(0,a.Y)("option",{value:"system",children:"system"})]})]})]}),(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink/80 mb-1.5",children:"Description"}),(0,a.Y)("textarea",{value:s.description,onChange:e=>d({...s,description:e.currentTarget.value}),placeholder:"What does this agent do?",rows:2,className:"w-full text-xs p-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink placeholder:text-ink/30 text-ink transition-colors"})]}),(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center gap-1.5 mb-1.5",children:[(0,a.Y)("label",{className:"text-xs font-semibold text-ink/80",children:"Mode"}),(0,a.Y)("span",{title:"Defines agent delegation context (primary, subagent, or all)",children:(0,a.Y)(eh.A,{className:"w-3.5 h-3.5 text-ink/40"})})]}),(0,a.Y)("div",{className:"inline-flex rounded-lg border border-ink/15 p-0.5 bg-ink/5",children:["primary","subagent","all"].map(e=>(0,a.Y)("button",{type:"button",onClick:()=>d({...s,mode:e}),className:`px-3 py-1 text-xs rounded-md transition-colors cursor-pointer capitalize ${s.mode===e?"bg-paper text-ink shadow-xs font-semibold":"text-ink/60 hover:text-ink"}`,children:e},e))})]})]}),(0,a.Y)("div",{className:"border-t border-ink/10"}),(0,a.FD)("div",{className:"space-y-3",children:[(0,a.Y)("h2",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"Model & Parameters"}),(0,a.FD)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,a.FD)("div",{children:[(0,a.Y)("label",{className:"block text-xs font-semibold text-ink/80 mb-1.5",children:"Override Model"}),(0,a.FD)("div",{className:"flex items-center border border-ink/20 hover:border-ink/40 focus-within:border-ink rounded-lg bg-paper transition-colors",children:[(0,a.Y)("span",{className:"px-2.5 text-ink/40",children:(0,a.Y)(td,{className:"w-3.5 h-3.5"})}),(0,a.Y)("select",{value:s.overrideModel||"Not selected",onChange:e=>d({...s,overrideModel:e.currentTarget.value}),className:"w-full text-xs font-mono py-2 pr-3 bg-transparent focus:outline-none cursor-pointer text-ink",children:tu.map(e=>(0,a.Y)("option",{value:e,children:e},e))})]})]}),(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,a.Y)("label",{className:"text-xs font-semibold text-ink/80",children:"Thinking Variant"}),(0,a.Y)("span",{title:"Controls chain-of-thought token depth",children:(0,a.Y)(eh.A,{className:"w-3.5 h-3.5 text-ink/40"})})]}),(0,a.Y)("input",{type:"text",value:s.thinkingVariant||"default",onChange:e=>d({...s,thinkingVariant:e.currentTarget.value}),placeholder:"default",className:"w-full text-xs font-mono px-3 py-2 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors"})]}),(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,a.Y)("label",{className:"text-xs font-semibold text-ink/80",children:"Temperature"}),(0,a.Y)("span",{title:"Higher values make output more random, lower values more deterministic",children:(0,a.Y)(eh.A,{className:"w-3.5 h-3.5 text-ink/40"})})]}),(0,a.FD)("div",{className:"flex items-center border border-ink/20 rounded-lg max-w-[150px] bg-paper overflow-hidden",children:[(0,a.Y)("button",{type:"button",onClick:()=>b(-.05),className:"px-3 py-1.5 text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:(0,a.Y)(tc.A,{className:"w-3.5 h-3.5"})}),(0,a.Y)("span",{className:"flex-1 text-center font-mono text-xs font-medium text-ink",children:null!=s.temperature?s.temperature.toFixed(2):"—"}),(0,a.Y)("button",{type:"button",onClick:()=>b(.05),className:"px-3 py-1.5 text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:(0,a.Y)(ed.A,{className:"w-3.5 h-3.5"})})]})]}),(0,a.FD)("div",{children:[(0,a.FD)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,a.Y)("label",{className:"text-xs font-semibold text-ink/80",children:"Top P"}),(0,a.Y)("span",{title:"Nucleus sampling cutoff",children:(0,a.Y)(eh.A,{className:"w-3.5 h-3.5 text-ink/40"})})]}),(0,a.FD)("div",{className:"flex items-center border border-ink/20 rounded-lg max-w-[150px] bg-paper overflow-hidden",children:[(0,a.Y)("button",{type:"button",onClick:()=>h(-.05),className:"px-3 py-1.5 text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:(0,a.Y)(tc.A,{className:"w-3.5 h-3.5"})}),(0,a.Y)("span",{className:"flex-1 text-center font-mono text-xs font-medium text-ink",children:null!=s.topP?s.topP.toFixed(2):"—"}),(0,a.Y)("button",{type:"button",onClick:()=>h(.05),className:"px-3 py-1.5 text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:(0,a.Y)(ed.A,{className:"w-3.5 h-3.5"})})]})]})]})]}),(0,a.Y)("div",{className:"border-t border-ink/10"}),(0,a.FD)("div",{className:"space-y-2 flex-1 flex flex-col",children:[(0,a.FD)("div",{className:"flex items-center justify-between",children:[(0,a.Y)("label",{className:"text-xs font-bold uppercase tracking-wider text-ink",children:"System Prompt"}),(0,a.FD)("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(s.systemPrompt),m(!0),setTimeout(()=>m(!1),1800)},className:"flex items-center gap-1.5 text-xs text-ink/60 hover:text-ink transition-colors cursor-pointer",children:[u?(0,a.Y)(r.A,{className:"w-3.5 h-3.5 text-ink"}):(0,a.Y)(tp.A,{className:"w-3.5 h-3.5"}),(0,a.Y)("span",{children:u?"Copied":"Copy"})]})]}),(0,a.Y)("textarea",{value:s.systemPrompt,onChange:e=>d({...s,systemPrompt:e.currentTarget.value}),rows:7,placeholder:"You are an expert coding assistant...",className:"w-full flex-1 min-h-[140px] text-xs font-mono p-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-ink/5 focus:outline-none focus:border-ink leading-relaxed transition-colors"})]}),(0,a.FD)("div",{className:"pt-3 border-t border-ink/10 flex items-center justify-between",children:[(0,a.Y)("div",{children:!s.isBuiltIn&&!i&&l&&(0,a.FD)("button",{type:"button",onClick:()=>l(s.id),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-lg border border-ink/20 hover:border-error hover:text-error text-ink/70 text-xs font-medium transition-colors cursor-pointer",children:[(0,a.Y)(eu.A,{className:"w-3.5 h-3.5"}),"Delete Agent"]})}),(0,a.FD)("div",{className:"flex items-center gap-3",children:[c&&(0,a.FD)("span",{className:"flex items-center gap-1 text-xs text-ink font-medium",children:[(0,a.Y)(r.A,{className:"w-3.5 h-3.5"}),"Saved successfully"]}),(0,a.Y)("button",{type:"submit",className:"px-4 py-2 rounded-lg bg-ink text-paper text-xs font-medium hover:bg-ink/90 transition-colors shadow-xs cursor-pointer",children:i?"Create Agent":"Save Agent"})]})]})]})};var tb=i("ns");function th(e){let{endpoint:t,listKey:i,query:a,messages:o,cacheKey:l}=e,[r,s]=(0,n.J0)([]),[d,c]=(0,n.J0)(null),[p,u]=(0,n.J0)(!1),[m,b]=(0,n.J0)(!0),h=e.readList??(e=>{let t=e?.[i];return Array.isArray(t)?t:null});(0,n.vJ)(()=>{let i=!0;return fetch(`${t}${a??""}`).then(e=>e.json()).then(t=>{if(!i)return;let a=h(t)??[];s(a),c(t=>e.resolveOnLoad?e.resolveOnLoad(t,a):a.length>0?a[0].id:null)}).catch(e=>console.error(o.load,e)).finally(()=>{i&&b(!1)}),()=>{i=!1}},[t,a]);let f=!1===e.fallbackToFirst?r.find(e=>e.id===d):r.find(e=>e.id===d)??r[0];return{items:r,selectedId:d,selected:f,isCreatingNew:p,isLoading:m,select:e=>{u(!1),c(e)},startCreate:()=>{u(!0),c(null)},save:i=>{let a=p?e.buildNew(i):e.buildUpdate(i,f,d);fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e.buildBody?e.buildBody(a):{[e.bodyKey]:a})}).then(e=>e.json()).then(t=>{if(e.isSaveError?.(t))return;let i=h(t);i?s(i):e.serverListOnly||s(e=>e.some(e=>e.id===a.id)?e.map(e=>e.id===a.id?a:e):[...e,a]);let n=e.resolveOnSave?e.resolveOnSave(a,i):a.id;void 0!==n&&c(n),u(!1),l&&(0,tb.SA)(l)}).catch(e=>console.error(o.save,e))},remove:i=>{let n=e.buildDeleteQuery?e.buildDeleteQuery(i):`?id=${encodeURIComponent(i)}`;fetch(`${t}${n}`,{method:"DELETE"}).then(e=>e.json()).then(n=>{if(!e.isDeleteError?.(n))if(l&&(0,tb.SA)(l),e.deleteFromResponse){let e=h(n)??r.filter(e=>e.id!==i);s(e),d===i&&c(e[0]?.id??null)}else fetch(`${t}${a??""}`).then(e=>e.json()).then(e=>{let t=h(e)??[];s(t),d===i&&c(t[0]?.id||null)})}).catch(e=>console.error(o.delete,e))}}}let tf=()=>{let[e,t]=(0,n.J0)("ompchamber"),{items:i,selectedId:o,selected:l,isCreatingNew:r,isLoading:s,select:d,startCreate:c,save:p,remove:u}=th({endpoint:"/api/settings/agents",listKey:"agents",bodyKey:"agent",messages:{load:"Failed to load agents from API:",save:"Failed to save agent via API:",delete:"Failed to delete agent via API:"},cacheKey:"agent",buildNew:e=>({...e,id:`agent-${Date.now()}`,isBuiltIn:!1}),buildUpdate:e=>e,isDeleteError:e=>!!e?.error}),m={id:`new-${Date.now()}`,name:"new-agent",description:"",scope:"user",mode:"subagent",overrideModel:"Not selected",thinkingVariant:"default",temperature:null,topP:null,systemPrompt:"You are a specialized assistant...",isBuiltIn:!1};return s?(0,a.Y)(eD,{children:"Loading agents from database..."}):(0,a.FD)("div",{className:"flex h-full w-full overflow-hidden bg-paper",children:[(0,a.Y)(ts,{agents:i,selectedAgentId:r?null:o,onSelectAgent:d,onAddNewAgent:c,selectedProject:e,onChangeProject:t}),(0,a.Y)("div",{className:"flex-1 h-full overflow-hidden flex flex-col",children:r?(0,a.Y)(tm,{agent:m,isNew:!0,onSave:p}):l?(0,a.Y)(tm,{agent:l,isNew:!1,onSave:p,onDelete:u},l.id):(0,a.Y)("div",{className:"flex-1 flex items-center justify-center text-xs font-mono text-ink/40",children:"Select an agent or click + to create one"})})]})};var tg=i("Ir"),tv=i("ES"),tx=i("uF");let tk={agents:{title:"Global AGENTS.md",badge:"context file",tooltip:"User context file omp loads when a session starts (~/.omp/agent/AGENTS.md, relocated by PI_CODING_AGENT_DIR). It shadows every other user-level context file, so it is the place for long-lived global rules. Recognizable permission directives are also mirrored into config.yml tools.approval. Saving empty content removes the file.",placeholder:"Type instructions in <mandatory_rules> tags..."},rules:{title:"Global RULES.md",badge:"sticky rule",tooltip:"User sticky rule (~/.omp/agent/RULES.md). Its whole body is re-sent on every request and re-read when a session starts or after /clear and /new, so it keeps its hold in long conversations — keep it to a few hard requirements. Saving empty content removes the file.",placeholder:"One hard requirement per line, e.g. Never commit or push unless asked."}},ty=e=>{let{kind:t,content:i,filePath:o,exists:l,isMock:s,onSave:d,onReset:c}=e,[p,u]=(0,n.J0)(i),[m,b]=(0,n.J0)(!1),[h,f]=(0,n.J0)(!1),[g,v]=(0,n.J0)(!1),[x,k]=(0,n.J0)(null),[y,w]=(0,n.J0)(null);(0,n.vJ)(()=>{u(i)},[i]);let N=tk[t],A=p.split("\n").length,Y=p.length,S=Math.round(Y/4),C=s?"Demo preset — MOCK=true, nothing is written to disk":o?`${o}${l?"":" · not created yet"}`:"Native path unavailable",D=async e=>{f(!0),k(null),w(null);try{let t=await e();if(t.error)return void k(t.error);w(t.note??null),v(!0),setTimeout(()=>v(!1),2e3)}finally{f(!1)}},F=async()=>{!c||window.confirm(`Replace ${o??"the stored content"} with the shipped default rules?`)&&await D(c)},T=e=>{u(t=>`${t.trim()}
|
|
3
3
|
|
|
4
4
|
${e}
|
|
5
5
|
`)};return(0,a.FD)("div",{className:"flex-1 flex flex-col h-full bg-paper text-ink p-6 md:p-8 overflow-hidden",children:[(0,a.FD)("div",{className:"flex items-center justify-between pb-4 border-b border-ink/10",children:[(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.FD)("h2",{className:"text-sm font-bold tracking-tight text-ink flex items-center gap-2",children:[(0,a.Y)("span",{children:N.title}),(0,a.Y)("span",{className:"text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded border border-ink/15 text-ink/50 font-medium",children:N.badge})]}),(0,a.FD)("div",{className:"group relative",children:[(0,a.Y)(eh.A,{className:"w-4 h-4 text-ink/40 cursor-help"}),(0,a.Y)("div",{className:"absolute left-0 top-6 hidden group-hover:block w-80 p-2.5 rounded-lg bg-ink text-paper text-xs shadow-lg z-20 leading-relaxed pointer-events-none",children:N.tooltip})]})]}),(0,a.FD)("div",{className:"flex items-center gap-2",children:[(0,a.FD)("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(p),b(!0),setTimeout(()=>b(!1),2e3)},title:"Copy to clipboard",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border border-ink/20 hover:border-ink/40 hover:bg-ink/5 text-ink transition-colors cursor-pointer",children:[m?(0,a.Y)(r.A,{className:"w-3.5 h-3.5 text-ink"}):(0,a.Y)(tp.A,{className:"w-3.5 h-3.5"}),(0,a.Y)("span",{children:m?"Copied":"Copy"})]}),c&&(0,a.FD)("button",{type:"button",onClick:F,disabled:h,title:"Reset to default rules",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border border-ink/20 hover:border-ink/40 hover:bg-ink/5 text-ink transition-colors cursor-pointer disabled:opacity-50",children:[(0,a.Y)(tg.A,{className:"w-3.5 h-3.5"}),(0,a.Y)("span",{children:"Reset"})]}),(0,a.FD)("button",{type:"button",onClick:()=>D(()=>d(p)),disabled:h,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium rounded-lg bg-ink text-paper hover:bg-ink/90 transition-colors shadow-xs cursor-pointer disabled:opacity-50",children:[g?(0,a.Y)(r.A,{className:"w-3.5 h-3.5"}):(0,a.Y)(tv.A,{className:"w-3.5 h-3.5"}),(0,a.Y)("span",{children:h?"Saving…":g?"Saved":"Save Changes"})]})]})]}),(x||y)&&(0,a.Y)("div",{className:`pt-3 text-xs font-mono break-words ${x?"text-error":"text-ink/60"}`,children:x??y}),(0,a.FD)("div",{className:"py-3 flex items-center gap-2 overflow-x-auto text-xs border-b border-ink/10",children:[(0,a.Y)("span",{className:"text-ink/50 uppercase tracking-wider text-[10px] font-bold whitespace-nowrap",children:"Quick Insert:"}),(0,a.FD)("button",{type:"button",onClick:()=>T(`<mandatory_rules>
|