@shawnstack/quickforge 1.6.7 → 1.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +10 -10
  2. package/dist/assets/{AgentProfilesPage-XJdWmkQb.js → AgentProfilesPage-R7N7eDq5.js} +1 -1
  3. package/dist/assets/{ChatPanelHost-BrUHIzBw.js → ChatPanelHost-C4orgd5l.js} +2 -2
  4. package/dist/assets/{PluginsPage-DDxjlhiK.js → PluginsPage-3pZG7D7e.js} +1 -1
  5. package/dist/assets/{ScheduledTasksPage-Bw-pSpbv.js → ScheduledTasksPage-BAqoK4xk.js} +1 -1
  6. package/dist/assets/{SettingsWorkspacePage-B_7o3noo.js → SettingsWorkspacePage-DWkPyGP_.js} +3 -3
  7. package/dist/assets/{SharedConversationPage-B5DPQla3.js → SharedConversationPage-C-1n_MmB.js} +1 -1
  8. package/dist/assets/{TerminalDock-CVObjSM6.js → TerminalDock-B6KAXkIU.js} +1 -1
  9. package/dist/assets/{WorkspaceInspector-Dk5887WR.js → WorkspaceInspector-CkXyD_k4.js} +1 -1
  10. package/dist/assets/{WorkspaceReaderDialog-D-_BBvud.js → WorkspaceReaderDialog-Dp2QAwBo.js} +1 -1
  11. package/dist/assets/{diff-line-counts-DagL0jQr.js → diff-line-counts-Dm5kKQOo.js} +1 -1
  12. package/dist/assets/index-CZb_mGGF.js +63 -0
  13. package/dist/assets/{mcp-servers-dialog-CJ4HKWVZ.js → mcp-servers-dialog-VbGvNekJ.js} +1 -1
  14. package/dist/assets/otel-DQf3c6v2.js +3 -0
  15. package/dist/assets/pi-ai-DjJwSQBQ.js +131 -0
  16. package/dist/assets/pi-web-ui-DqxtBlZL.js +2803 -0
  17. package/dist/assets/{skills-dialog-CmCLl7K_.js → skills-dialog-B0jNVGZW.js} +1 -1
  18. package/dist/assets/{useAppTheme-BwZ5OEf3.js → useAppTheme-DsabFF9D.js} +1 -1
  19. package/dist/index.html +5 -5
  20. package/package.json +3 -3
  21. package/server/ai-http-logger.mjs +1 -1
  22. package/server/routes/agent-profiles.mjs +1 -1
  23. package/server/routes/models.mjs +1 -1
  24. package/server/routes/scheduled-tasks.mjs +1 -1
  25. package/server/routes/workspace.mjs +1 -1
  26. package/server/session-utils.mjs +1 -1
  27. package/server/utils/platform.mjs +25 -2
  28. package/dist/assets/index-DeUvsbzW.js +0 -63
  29. package/dist/assets/pi-ai-Cx633yhb.js +0 -134
  30. package/dist/assets/pi-web-ui-DFNE2m5b.js +0 -2770
  31. /package/dist/assets/{monaco-FCb94ino.js → monaco-CzxeAjEw.js} +0 -0
  32. /package/dist/assets/{plugin-api-UKg_cgSG.js → plugin-api-Ds5xGIL7.js} +0 -0
  33. /package/dist/assets/{xterm-BtSXYfUR.js → xterm-aPHkK8RR.js} +0 -0
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # 速构 QuickForge
2
2
 
3
3
  <p align="center">
4
- <img alt="Version" src="https://img.shields.io/badge/version-1.6.7-blue" />
4
+ <img alt="Version" src="https://img.shields.io/badge/version-1.6.8-blue" />
5
5
  <img alt="License" src="https://img.shields.io/badge/license-MIT-green" />
6
6
  <img alt="Node" src="https://img.shields.io/badge/node-%3E%3D22.19-brightgreen" />
7
7
  <img alt="React" src="https://img.shields.io/badge/react-19-61DAFB?logo=react" />
@@ -73,7 +73,7 @@ QuickForge 的工具能力很直接,因此也需要谨慎使用:
73
73
  #### 从 npm 安装
74
74
 
75
75
  ```bash
76
- npm install -g @shawnstack/quickforge@1.6.7
76
+ npm install -g @shawnstack/quickforge@1.6.8
77
77
  qf
78
78
 
79
79
  # CLI 工具
@@ -104,17 +104,17 @@ console.log(app.url)
104
104
  当前版本的离线包:
105
105
 
106
106
  ```text
107
- package-offline/shawnstack-quickforge-1.6.7.tgz
107
+ package-offline/shawnstack-quickforge-1.6.8.tgz
108
108
  ```
109
109
 
110
110
  在安装了 Node.js 22.19+ 和 npm 的机器上执行:
111
111
 
112
112
  ```bash
113
- npm install -g ./package-offline/shawnstack-quickforge-1.6.7.tgz
113
+ npm install -g ./package-offline/shawnstack-quickforge-1.6.8.tgz
114
114
  qf
115
115
  ```
116
116
 
117
- 该包由 `v1.6.7` 标签生成,包含 QuickForge 运行时资源,依赖由 npm 安装。
117
+ 该包由 `v1.6.8` 标签生成,包含 QuickForge 运行时资源,依赖由 npm 安装。
118
118
 
119
119
  ### 本地开发
120
120
 
@@ -286,7 +286,7 @@ QuickForge intentionally exposes powerful local capabilities, so the boundaries
286
286
  #### npm
287
287
 
288
288
  ```bash
289
- npm install -g @shawnstack/quickforge@1.6.7
289
+ npm install -g @shawnstack/quickforge@1.6.8
290
290
  qf
291
291
 
292
292
  # CLI utilities
@@ -314,20 +314,20 @@ This entry is exposed through the `main` field in `package.json` and does not ch
314
314
 
315
315
  #### Offline tarball
316
316
 
317
- The offline release package for `v1.6.7` is:
317
+ The offline release package for `v1.6.8` is:
318
318
 
319
319
  ```text
320
- package-offline/shawnstack-quickforge-1.6.7.tgz
320
+ package-offline/shawnstack-quickforge-1.6.8.tgz
321
321
  ```
322
322
 
323
323
  Install it on a machine with Node.js 22.19+ and npm:
324
324
 
325
325
  ```bash
326
- npm install -g ./package-offline/shawnstack-quickforge-1.6.7.tgz
326
+ npm install -g ./package-offline/shawnstack-quickforge-1.6.8.tgz
327
327
  qf
328
328
  ```
329
329
 
330
- The package was generated from tag `v1.6.7` and includes QuickForge runtime assets and installs dependencies with npm.
330
+ The package was generated from tag `v1.6.8` and includes QuickForge runtime assets and installs dependencies with npm.
331
331
 
332
332
  ### Local development
333
333
 
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{E as t,Ft as n,Nt as r,Rt as i,a,l as o,lt as s}from"./icons-DHoaB5uq.js";import{n as c}from"./react-vendor-BR9MG2D-.js";import{F as l,G as u,J as d,K as f,Y as p,nt as m,q as h,rt as g,st as _,tt as v}from"./index-DeUvsbzW.js";var y=e(i(),1),b=c();function x(){return{name:``,label:``,description:``,systemPrompt:``,allowedTools:[`read_file`,`grep_files`],maxRuntimeMs:`1800000`,maxToolCalls:`300`,enabledAsSubagent:!0}}function S(e){return{name:e.name,label:e.label,description:e.description??``,systemPrompt:e.systemPrompt??``,allowedTools:e.allowedTools??[],maxRuntimeMs:String(e.maxRuntimeMs??18e5),maxToolCalls:String(e.maxToolCalls??300),enabledAsSubagent:e.enabledAsSubagent}}function C(e){return{name:e.name.trim().toLowerCase(),label:e.label.trim(),description:e.description.trim(),systemPrompt:e.systemPrompt.trim(),allowedTools:e.allowedTools,maxRuntimeMs:Number(e.maxRuntimeMs||18e5),maxToolCalls:Number(e.maxToolCalls||300),enabledAsSubagent:e.enabledAsSubagent}}function w(e){return!!(e.name.trim()&&e.label.trim()&&e.allowedTools.length>0)}async function T(e,t){let n=await fetch(e,{...t,headers:{"content-type":`application/json`,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`请求失败`);return r}function E(){let[e,i]=(0,y.useState)([]),[c,E]=(0,y.useState)([]),[D,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)(null),[j,M]=(0,y.useState)(()=>x()),[N,P]=(0,y.useState)(!1),[F,I]=(0,y.useState)(``),[L,R]=(0,y.useState)(!1),[z,B]=(0,y.useState)(),[V,H]=(0,y.useState)(`off`),[U,W]=(0,y.useState)(``),[G,K]=(0,y.useState)(null);async function q(){let[e,t]=await Promise.all([T(`/api/agent-profiles`),T(`/api/agent-profiles/available-tools`)]);i(e.agents),E(t.tools)}(0,y.useEffect)(()=>{let e=!1;async function t(){try{let[t,n]=await Promise.all([T(`/api/agent-profiles`),T(`/api/agent-profiles/available-tools`)]);if(e)return;i(t.agents),E(n.tools)}catch(t){e||W(t instanceof Error?t.message:_(`requestFailed`))}}return t(),()=>{e=!0}},[]),(0,y.useEffect)(()=>{let e=!1;async function t(){try{let t=await h(),n=await f(t),r=await d(t),i=r.model??await p(t)??n[0];if(e)return;B(i),H(r.thinkingLevel??u(i))}catch{}}return t(),()=>{e=!0}},[]),(0,y.useEffect)(()=>{if(!G)return;let e=()=>K(null);return window.addEventListener(`click`,e),window.addEventListener(`blur`,e),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`blur`,e)}},[G]);let J=(0,y.useMemo)(()=>e.find(e=>e.id===k)??null,[e,k]);function Y(e,t){M(n=>({...n,[e]:t}))}function X(e){M(t=>({...t,allowedTools:t.allowedTools.includes(e)?t.allowedTools.filter(t=>t!==e):[...t.allowedTools,e]}))}function Z(){A(null),M(x()),I(``),W(``),O(!0)}function Q(e){A(e.id),M(S(e)),I(``),W(``),O(!0)}function $(){N||L||(O(!1),A(null),M(x()),I(``))}async function ee(){let e=F.trim();if(!e){W(_(`aiFillAgentInputRequired`));return}if(!z){W(_(`aiFillAgentNoModel`));return}R(!0),W(``);try{let t=await T(`/api/agent-profiles/ai-fill`,{method:`POST`,body:JSON.stringify({instruction:e,model:z,thinkingLevel:V})});M(e=>({...e,name:t.agent.name,label:t.agent.label,description:t.agent.description,systemPrompt:t.agent.systemPrompt}))}catch(e){W(e instanceof Error?e.message:_(`aiFillAgentFailed`))}finally{R(!1)}}async function te(){if(w(j)){P(!0),W(``);try{let e=C(j);k?await T(`/api/agent-profiles/${encodeURIComponent(k)}`,{method:`PATCH`,body:JSON.stringify(e)}):await T(`/api/agent-profiles`,{method:`POST`,body:JSON.stringify(e)}),$(),await q()}catch(e){W(e instanceof Error?e.message:_(`requestFailed`))}finally{P(!1)}}}async function ne(e){if(e.builtin||e.readonly)return;let t=!e.enabledAsSubagent,n=e.enabledAsSubagent;i(n=>n.map(n=>n.id===e.id?{...n,enabledAsSubagent:t}:n)),K(null);try{await T(`/api/agent-profiles/${encodeURIComponent(e.id)}`,{method:`PATCH`,body:JSON.stringify({enabledAsSubagent:t})})}catch(t){i(t=>t.map(t=>t.id===e.id?{...t,enabledAsSubagent:n}:t)),W(t instanceof Error?t.message:_(`requestFailed`))}}async function re(e){if(!(e.builtin||e.readonly)&&await l({description:_(`confirmDeleteAgent`),confirmLabel:_(`confirmDelete`),cancelLabel:_(`cancel`),variant:`destructive`})){W(``);try{await T(`/api/agent-profiles/${encodeURIComponent(e.id)}`,{method:`DELETE`}),await q()}catch(e){W(e instanceof Error?e.message:_(`requestFailed`))}}}return D?(0,b.jsxs)(`div`,{className:`quickforge-settings-stack`,children:[(0,b.jsx)(`div`,{className:`quickforge-settings-heading`,children:(0,b.jsxs)(`h3`,{className:`quickforge-settings-title`,children:[_(J?`editAgent`:`createAgent`),(0,b.jsx)(v,{label:J?.readonly?_(`builtinAgentReadonly`):_(`agentsDescription`)})]})}),(0,b.jsxs)(`section`,{className:`quickforge-settings-section`,"aria-label":_(J?`editAgent`:`createAgent`),children:[(0,b.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,b.jsxs)(`button`,{className:`quickforge-settings-button quickforge-settings-button-secondary`,type:`button`,onClick:$,disabled:N||L,children:[(0,b.jsx)(n,{className:`mr-2 size-4`}),_(`back`)]}),(0,b.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,b.jsx)(`div`,{className:`quickforge-settings-row-title`,children:_(J?`editAgent`:`createAgent`)}),J?.readonly?(0,b.jsx)(`div`,{className:`quickforge-settings-row-description`,children:_(`builtinAgentReadonly`)}):null]})]}),(0,b.jsx)(`div`,{className:`px-5 py-4`,children:(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-2xl border border-border bg-muted/20 p-3`,children:[(0,b.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-medium text-foreground`,children:[(0,b.jsx)(o,{className:`size-4 text-primary`}),_(`aiFillAgent`),(0,b.jsx)(v,{label:_(`aiFillAgentDescription`)})]}),(0,b.jsx)(`textarea`,{className:`min-h-20 w-full resize-y rounded-xl border border-input bg-background px-3 py-2 text-sm outline-none transition-colors placeholder:text-muted-foreground/65 focus:border-ring disabled:opacity-60`,value:F,disabled:!!J?.readonly||L,onChange:e=>I(e.target.value),placeholder:_(`aiFillAgentPlaceholder`)}),(0,b.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,b.jsxs)(m,{variant:`outline`,size:`sm`,onClick:()=>void ee(),disabled:!!J?.readonly||L||!F.trim(),children:[(0,b.jsx)(o,{className:`mr-1 size-3.5`}),_(L?`aiFillAgentLoading`:`aiFillAgent`)]})})]}),(0,b.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,b.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[_(`agentName`),(0,b.jsx)(`input`,{className:`mt-1 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-ring disabled:opacity-60`,value:j.name,disabled:!!J?.readonly,onChange:e=>Y(`name`,e.target.value),placeholder:`reviewer`})]}),(0,b.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[_(`agentLabel`),(0,b.jsx)(`input`,{className:`mt-1 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-ring disabled:opacity-60`,value:j.label,disabled:!!J?.readonly,onChange:e=>Y(`label`,e.target.value),placeholder:_(`agentLabelPlaceholder`)})]})]}),(0,b.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[_(`agentDescription`),(0,b.jsx)(`input`,{className:`mt-1 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-ring disabled:opacity-60`,value:j.description,disabled:!!J?.readonly,onChange:e=>Y(`description`,e.target.value)})]}),(0,b.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[_(`agentSystemPrompt`),(0,b.jsx)(`textarea`,{className:`mt-1 min-h-36 w-full resize-y rounded-xl border border-input bg-background px-3 py-2 text-sm outline-none focus:border-ring disabled:opacity-60`,value:j.systemPrompt,disabled:!!J?.readonly,onChange:e=>Y(`systemPrompt`,e.target.value)})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`mb-2 text-sm font-medium text-foreground`,children:_(`allowedTools`)}),(0,b.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:c.map(e=>(0,b.jsxs)(`label`,{className:`flex items-start gap-2 rounded-xl border border-border bg-muted/20 p-3 text-sm disabled:opacity-60`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`mt-1`,disabled:!!J?.readonly,checked:j.allowedTools.includes(e.name),onChange:()=>X(e.name)}),(0,b.jsxs)(`span`,{children:[(0,b.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),(0,b.jsx)(`span`,{className:`ml-2 font-mono text-xs text-muted-foreground`,children:e.name}),e.riskLevel===`dangerous`?(0,b.jsx)(`span`,{className:`ml-2 rounded-full bg-amber-500/10 px-2 py-0.5 text-xs text-amber-700`,children:_(`highRiskTool`)}):null,(0,b.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:e.description})]})]},e.name))})]}),(0,b.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,b.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[_(`maxRuntimeMs`),(0,b.jsx)(`input`,{type:`number`,className:`mt-1 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-ring disabled:opacity-60`,value:j.maxRuntimeMs,disabled:!!J?.readonly,onChange:e=>Y(`maxRuntimeMs`,e.target.value)})]}),(0,b.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[_(`maxToolCalls`),(0,b.jsx)(`input`,{type:`number`,className:`mt-1 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-ring disabled:opacity-60`,value:j.maxToolCalls,disabled:!!J?.readonly,onChange:e=>Y(`maxToolCalls`,e.target.value)})]})]}),(0,b.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:j.enabledAsSubagent,disabled:!!J?.readonly,onChange:e=>Y(`enabledAsSubagent`,e.target.checked)}),_(`enabledAsSubagent`)]}),U?(0,b.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:U}):null]})}),(0,b.jsxs)(`div`,{className:`quickforge-settings-divider flex justify-end gap-2 px-5 py-4`,children:[(0,b.jsx)(m,{variant:`outline`,onClick:$,disabled:N||L,children:_(`cancel`)}),(0,b.jsx)(m,{onClick:te,disabled:N||L||!!J?.readonly||!w(j),children:_(`save`)})]})]})]}):(0,b.jsx)(`div`,{className:`quickforge-settings-stack`,children:(0,b.jsxs)(`section`,{className:`quickforge-settings-section`,"aria-label":_(`agentsTab`),children:[(0,b.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,b.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,b.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,b.jsx)(r,{className:`size-4 text-primary`}),_(`agentsTab`)]}),(0,b.jsx)(`div`,{className:`quickforge-settings-row-description`,children:_(`agentsDescription`)})]}),(0,b.jsx)(`button`,{className:`quickforge-settings-button quickforge-settings-button-primary`,type:`button`,onClick:Z,children:_(`createAgent`)})]}),U?(0,b.jsx)(`div`,{className:`quickforge-settings-alert quickforge-settings-warning-attached`,children:U}):null,e.length===0?(0,b.jsx)(`div`,{className:`quickforge-settings-empty-row`,children:_(`loading`)}):e.map(e=>(0,b.jsxs)(`div`,{className:`quickforge-settings-list-item`,children:[(0,b.jsxs)(`div`,{className:`quickforge-settings-list-item-main`,children:[(0,b.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[e.label,e.builtin?(0,b.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-info`,children:_(`builtinAgent`)}):null,(0,b.jsx)(`span`,{className:g(`quickforge-settings-badge`,e.enabledAsSubagent?`quickforge-settings-badge-success`:`quickforge-settings-badge-muted`),children:e.enabledAsSubagent?_(`enabled`):_(`disabled`)})]}),(0,b.jsx)(`div`,{className:`quickforge-settings-row-description quickforge-settings-mono`,children:e.name}),e.source&&!e.builtin?(0,b.jsxs)(`div`,{className:`quickforge-settings-row-description`,children:[e.source,e.relativePath?` · ${e.relativePath}`:``]}):null,(0,b.jsx)(`div`,{className:`quickforge-settings-row-description`,children:e.description||_(`noDescription`)}),(0,b.jsx)(`div`,{className:`quickforge-settings-meta`,children:e.allowedTools.map(e=>(0,b.jsx)(`code`,{className:`quickforge-settings-command-name`,children:e},e))}),(0,b.jsxs)(`div`,{className:`quickforge-settings-meta`,children:[(0,b.jsxs)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:[_(`maxRuntimeMs`),e.maxRuntimeMs??`-`]}),(0,b.jsxs)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:[_(`maxToolCalls`),e.maxToolCalls??`-`]})]})]}),(0,b.jsxs)(`div`,{className:`quickforge-settings-list-item-actions`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`label`,{className:`quickforge-settings-switch`,"aria-disabled":e.builtin||e.readonly?`true`:`false`,title:e.enabledAsSubagent?_(`disableAsSubagent`):_(`enableAsSubagent`),children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:e.enabledAsSubagent,disabled:e.builtin||e.readonly,onChange:()=>void ne(e)}),(0,b.jsx)(`span`,{"aria-hidden":`true`})]}),(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`button`,{className:`quickforge-settings-icon-action`,type:`button`,onClick:()=>K(G===e.id?null:e.id),title:_(`moreActions`),children:(0,b.jsx)(s,{className:`size-4`})}),G===e.id?(0,b.jsxs)(`div`,{className:`absolute right-0 z-20 mt-1 w-36 overflow-hidden rounded-xl border border-border bg-popover py-1 text-sm shadow-quickforge`,children:[(0,b.jsxs)(`button`,{className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50`,disabled:e.builtin||e.readonly,onClick:()=>{K(null),Q(e)},children:[(0,b.jsx)(t,{className:`size-3.5`}),_(`editTask`)]}),(0,b.jsxs)(`button`,{className:`flex w-full items-center gap-2 px-3 py-2 text-left text-destructive hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50`,disabled:e.builtin||e.readonly,onClick:()=>{K(null),re(e)},children:[(0,b.jsx)(a,{className:`size-3.5`}),_(`delete`)]})]}):null]})]})]},e.id))]})})}export{E as AgentProfilesPage};
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{E as t,Ft as n,Nt as r,Rt as i,a,l as o,lt as s}from"./icons-DHoaB5uq.js";import{n as c}from"./react-vendor-BR9MG2D-.js";import{F as l,G as u,J as d,K as f,Y as p,nt as m,q as h,rt as g,st as _,tt as v}from"./index-CZb_mGGF.js";var y=e(i(),1),b=c();function x(){return{name:``,label:``,description:``,systemPrompt:``,allowedTools:[`read_file`,`grep_files`],maxRuntimeMs:`1800000`,maxToolCalls:`300`,enabledAsSubagent:!0}}function S(e){return{name:e.name,label:e.label,description:e.description??``,systemPrompt:e.systemPrompt??``,allowedTools:e.allowedTools??[],maxRuntimeMs:String(e.maxRuntimeMs??18e5),maxToolCalls:String(e.maxToolCalls??300),enabledAsSubagent:e.enabledAsSubagent}}function C(e){return{name:e.name.trim().toLowerCase(),label:e.label.trim(),description:e.description.trim(),systemPrompt:e.systemPrompt.trim(),allowedTools:e.allowedTools,maxRuntimeMs:Number(e.maxRuntimeMs||18e5),maxToolCalls:Number(e.maxToolCalls||300),enabledAsSubagent:e.enabledAsSubagent}}function w(e){return!!(e.name.trim()&&e.label.trim()&&e.allowedTools.length>0)}async function T(e,t){let n=await fetch(e,{...t,headers:{"content-type":`application/json`,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`请求失败`);return r}function E(){let[e,i]=(0,y.useState)([]),[c,E]=(0,y.useState)([]),[D,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)(null),[j,M]=(0,y.useState)(()=>x()),[N,P]=(0,y.useState)(!1),[F,I]=(0,y.useState)(``),[L,R]=(0,y.useState)(!1),[z,B]=(0,y.useState)(),[V,H]=(0,y.useState)(`off`),[U,W]=(0,y.useState)(``),[G,K]=(0,y.useState)(null);async function q(){let[e,t]=await Promise.all([T(`/api/agent-profiles`),T(`/api/agent-profiles/available-tools`)]);i(e.agents),E(t.tools)}(0,y.useEffect)(()=>{let e=!1;async function t(){try{let[t,n]=await Promise.all([T(`/api/agent-profiles`),T(`/api/agent-profiles/available-tools`)]);if(e)return;i(t.agents),E(n.tools)}catch(t){e||W(t instanceof Error?t.message:_(`requestFailed`))}}return t(),()=>{e=!0}},[]),(0,y.useEffect)(()=>{let e=!1;async function t(){try{let t=await h(),n=await f(t),r=await d(t),i=r.model??await p(t)??n[0];if(e)return;B(i),H(r.thinkingLevel??u(i))}catch{}}return t(),()=>{e=!0}},[]),(0,y.useEffect)(()=>{if(!G)return;let e=()=>K(null);return window.addEventListener(`click`,e),window.addEventListener(`blur`,e),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`blur`,e)}},[G]);let J=(0,y.useMemo)(()=>e.find(e=>e.id===k)??null,[e,k]);function Y(e,t){M(n=>({...n,[e]:t}))}function X(e){M(t=>({...t,allowedTools:t.allowedTools.includes(e)?t.allowedTools.filter(t=>t!==e):[...t.allowedTools,e]}))}function Z(){A(null),M(x()),I(``),W(``),O(!0)}function Q(e){A(e.id),M(S(e)),I(``),W(``),O(!0)}function $(){N||L||(O(!1),A(null),M(x()),I(``))}async function ee(){let e=F.trim();if(!e){W(_(`aiFillAgentInputRequired`));return}if(!z){W(_(`aiFillAgentNoModel`));return}R(!0),W(``);try{let t=await T(`/api/agent-profiles/ai-fill`,{method:`POST`,body:JSON.stringify({instruction:e,model:z,thinkingLevel:V})});M(e=>({...e,name:t.agent.name,label:t.agent.label,description:t.agent.description,systemPrompt:t.agent.systemPrompt}))}catch(e){W(e instanceof Error?e.message:_(`aiFillAgentFailed`))}finally{R(!1)}}async function te(){if(w(j)){P(!0),W(``);try{let e=C(j);k?await T(`/api/agent-profiles/${encodeURIComponent(k)}`,{method:`PATCH`,body:JSON.stringify(e)}):await T(`/api/agent-profiles`,{method:`POST`,body:JSON.stringify(e)}),$(),await q()}catch(e){W(e instanceof Error?e.message:_(`requestFailed`))}finally{P(!1)}}}async function ne(e){if(e.builtin||e.readonly)return;let t=!e.enabledAsSubagent,n=e.enabledAsSubagent;i(n=>n.map(n=>n.id===e.id?{...n,enabledAsSubagent:t}:n)),K(null);try{await T(`/api/agent-profiles/${encodeURIComponent(e.id)}`,{method:`PATCH`,body:JSON.stringify({enabledAsSubagent:t})})}catch(t){i(t=>t.map(t=>t.id===e.id?{...t,enabledAsSubagent:n}:t)),W(t instanceof Error?t.message:_(`requestFailed`))}}async function re(e){if(!(e.builtin||e.readonly)&&await l({description:_(`confirmDeleteAgent`),confirmLabel:_(`confirmDelete`),cancelLabel:_(`cancel`),variant:`destructive`})){W(``);try{await T(`/api/agent-profiles/${encodeURIComponent(e.id)}`,{method:`DELETE`}),await q()}catch(e){W(e instanceof Error?e.message:_(`requestFailed`))}}}return D?(0,b.jsxs)(`div`,{className:`quickforge-settings-stack`,children:[(0,b.jsx)(`div`,{className:`quickforge-settings-heading`,children:(0,b.jsxs)(`h3`,{className:`quickforge-settings-title`,children:[_(J?`editAgent`:`createAgent`),(0,b.jsx)(v,{label:J?.readonly?_(`builtinAgentReadonly`):_(`agentsDescription`)})]})}),(0,b.jsxs)(`section`,{className:`quickforge-settings-section`,"aria-label":_(J?`editAgent`:`createAgent`),children:[(0,b.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,b.jsxs)(`button`,{className:`quickforge-settings-button quickforge-settings-button-secondary`,type:`button`,onClick:$,disabled:N||L,children:[(0,b.jsx)(n,{className:`mr-2 size-4`}),_(`back`)]}),(0,b.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,b.jsx)(`div`,{className:`quickforge-settings-row-title`,children:_(J?`editAgent`:`createAgent`)}),J?.readonly?(0,b.jsx)(`div`,{className:`quickforge-settings-row-description`,children:_(`builtinAgentReadonly`)}):null]})]}),(0,b.jsx)(`div`,{className:`px-5 py-4`,children:(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-2xl border border-border bg-muted/20 p-3`,children:[(0,b.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-medium text-foreground`,children:[(0,b.jsx)(o,{className:`size-4 text-primary`}),_(`aiFillAgent`),(0,b.jsx)(v,{label:_(`aiFillAgentDescription`)})]}),(0,b.jsx)(`textarea`,{className:`min-h-20 w-full resize-y rounded-xl border border-input bg-background px-3 py-2 text-sm outline-none transition-colors placeholder:text-muted-foreground/65 focus:border-ring disabled:opacity-60`,value:F,disabled:!!J?.readonly||L,onChange:e=>I(e.target.value),placeholder:_(`aiFillAgentPlaceholder`)}),(0,b.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,b.jsxs)(m,{variant:`outline`,size:`sm`,onClick:()=>void ee(),disabled:!!J?.readonly||L||!F.trim(),children:[(0,b.jsx)(o,{className:`mr-1 size-3.5`}),_(L?`aiFillAgentLoading`:`aiFillAgent`)]})})]}),(0,b.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,b.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[_(`agentName`),(0,b.jsx)(`input`,{className:`mt-1 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-ring disabled:opacity-60`,value:j.name,disabled:!!J?.readonly,onChange:e=>Y(`name`,e.target.value),placeholder:`reviewer`})]}),(0,b.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[_(`agentLabel`),(0,b.jsx)(`input`,{className:`mt-1 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-ring disabled:opacity-60`,value:j.label,disabled:!!J?.readonly,onChange:e=>Y(`label`,e.target.value),placeholder:_(`agentLabelPlaceholder`)})]})]}),(0,b.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[_(`agentDescription`),(0,b.jsx)(`input`,{className:`mt-1 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-ring disabled:opacity-60`,value:j.description,disabled:!!J?.readonly,onChange:e=>Y(`description`,e.target.value)})]}),(0,b.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[_(`agentSystemPrompt`),(0,b.jsx)(`textarea`,{className:`mt-1 min-h-36 w-full resize-y rounded-xl border border-input bg-background px-3 py-2 text-sm outline-none focus:border-ring disabled:opacity-60`,value:j.systemPrompt,disabled:!!J?.readonly,onChange:e=>Y(`systemPrompt`,e.target.value)})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`mb-2 text-sm font-medium text-foreground`,children:_(`allowedTools`)}),(0,b.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:c.map(e=>(0,b.jsxs)(`label`,{className:`flex items-start gap-2 rounded-xl border border-border bg-muted/20 p-3 text-sm disabled:opacity-60`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`mt-1`,disabled:!!J?.readonly,checked:j.allowedTools.includes(e.name),onChange:()=>X(e.name)}),(0,b.jsxs)(`span`,{children:[(0,b.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),(0,b.jsx)(`span`,{className:`ml-2 font-mono text-xs text-muted-foreground`,children:e.name}),e.riskLevel===`dangerous`?(0,b.jsx)(`span`,{className:`ml-2 rounded-full bg-amber-500/10 px-2 py-0.5 text-xs text-amber-700`,children:_(`highRiskTool`)}):null,(0,b.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:e.description})]})]},e.name))})]}),(0,b.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,b.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[_(`maxRuntimeMs`),(0,b.jsx)(`input`,{type:`number`,className:`mt-1 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-ring disabled:opacity-60`,value:j.maxRuntimeMs,disabled:!!J?.readonly,onChange:e=>Y(`maxRuntimeMs`,e.target.value)})]}),(0,b.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[_(`maxToolCalls`),(0,b.jsx)(`input`,{type:`number`,className:`mt-1 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-ring disabled:opacity-60`,value:j.maxToolCalls,disabled:!!J?.readonly,onChange:e=>Y(`maxToolCalls`,e.target.value)})]})]}),(0,b.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:j.enabledAsSubagent,disabled:!!J?.readonly,onChange:e=>Y(`enabledAsSubagent`,e.target.checked)}),_(`enabledAsSubagent`)]}),U?(0,b.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:U}):null]})}),(0,b.jsxs)(`div`,{className:`quickforge-settings-divider flex justify-end gap-2 px-5 py-4`,children:[(0,b.jsx)(m,{variant:`outline`,onClick:$,disabled:N||L,children:_(`cancel`)}),(0,b.jsx)(m,{onClick:te,disabled:N||L||!!J?.readonly||!w(j),children:_(`save`)})]})]})]}):(0,b.jsx)(`div`,{className:`quickforge-settings-stack`,children:(0,b.jsxs)(`section`,{className:`quickforge-settings-section`,"aria-label":_(`agentsTab`),children:[(0,b.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,b.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,b.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,b.jsx)(r,{className:`size-4 text-primary`}),_(`agentsTab`)]}),(0,b.jsx)(`div`,{className:`quickforge-settings-row-description`,children:_(`agentsDescription`)})]}),(0,b.jsx)(`button`,{className:`quickforge-settings-button quickforge-settings-button-primary`,type:`button`,onClick:Z,children:_(`createAgent`)})]}),U?(0,b.jsx)(`div`,{className:`quickforge-settings-alert quickforge-settings-warning-attached`,children:U}):null,e.length===0?(0,b.jsx)(`div`,{className:`quickforge-settings-empty-row`,children:_(`loading`)}):e.map(e=>(0,b.jsxs)(`div`,{className:`quickforge-settings-list-item`,children:[(0,b.jsxs)(`div`,{className:`quickforge-settings-list-item-main`,children:[(0,b.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[e.label,e.builtin?(0,b.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-info`,children:_(`builtinAgent`)}):null,(0,b.jsx)(`span`,{className:g(`quickforge-settings-badge`,e.enabledAsSubagent?`quickforge-settings-badge-success`:`quickforge-settings-badge-muted`),children:e.enabledAsSubagent?_(`enabled`):_(`disabled`)})]}),(0,b.jsx)(`div`,{className:`quickforge-settings-row-description quickforge-settings-mono`,children:e.name}),e.source&&!e.builtin?(0,b.jsxs)(`div`,{className:`quickforge-settings-row-description`,children:[e.source,e.relativePath?` · ${e.relativePath}`:``]}):null,(0,b.jsx)(`div`,{className:`quickforge-settings-row-description`,children:e.description||_(`noDescription`)}),(0,b.jsx)(`div`,{className:`quickforge-settings-meta`,children:e.allowedTools.map(e=>(0,b.jsx)(`code`,{className:`quickforge-settings-command-name`,children:e},e))}),(0,b.jsxs)(`div`,{className:`quickforge-settings-meta`,children:[(0,b.jsxs)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:[_(`maxRuntimeMs`),e.maxRuntimeMs??`-`]}),(0,b.jsxs)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:[_(`maxToolCalls`),e.maxToolCalls??`-`]})]})]}),(0,b.jsxs)(`div`,{className:`quickforge-settings-list-item-actions`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`label`,{className:`quickforge-settings-switch`,"aria-disabled":e.builtin||e.readonly?`true`:`false`,title:e.enabledAsSubagent?_(`disableAsSubagent`):_(`enableAsSubagent`),children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:e.enabledAsSubagent,disabled:e.builtin||e.readonly,onChange:()=>void ne(e)}),(0,b.jsx)(`span`,{"aria-hidden":`true`})]}),(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`button`,{className:`quickforge-settings-icon-action`,type:`button`,onClick:()=>K(G===e.id?null:e.id),title:_(`moreActions`),children:(0,b.jsx)(s,{className:`size-4`})}),G===e.id?(0,b.jsxs)(`div`,{className:`absolute right-0 z-20 mt-1 w-36 overflow-hidden rounded-xl border border-border bg-popover py-1 text-sm shadow-quickforge`,children:[(0,b.jsxs)(`button`,{className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50`,disabled:e.builtin||e.readonly,onClick:()=>{K(null),Q(e)},children:[(0,b.jsx)(t,{className:`size-3.5`}),_(`editTask`)]}),(0,b.jsxs)(`button`,{className:`flex w-full items-center gap-2 px-3 py-2 text-left text-destructive hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50`,disabled:e.builtin||e.readonly,onClick:()=>{K(null),re(e)},children:[(0,b.jsx)(a,{className:`size-3.5`}),_(`delete`)]})]}):null]})]})]},e.id))]})})}export{E as AgentProfilesPage};
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{G as t,Rt as n}from"./icons-DHoaB5uq.js";import{n as r,t as i}from"./react-vendor-BR9MG2D-.js";import{d as a,p as o,t as s}from"./lit-vendor-Dr3cpBGF.js";import{c,o as l,s as u}from"./pi-web-ui-DFNE2m5b.js";import{t as d}from"./logger-B65Akg8A.js";import{B as f,I as p,L as m,R as h,d as g,j as _,r as v,st as y}from"./index-DeUvsbzW.js";import{t as b}from"./plugin-api-UKg_cgSG.js";var x=e(n(),1),S={maxHeight:`28rem`,overflow:`auto`,border:`1px solid color-mix(in oklab, var(--border) 75%, transparent)`,borderRadius:`0.75rem`,background:`color-mix(in oklab, var(--muted) 28%, transparent)`,fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace)`,fontSize:`0.78rem`,lineHeight:`1.45`},C={minHeight:`1.35em`,padding:`0 0.75rem`,whiteSpace:`pre`},w={display:`inline-flex`,alignItems:`center`,borderRadius:`999px`,padding:`0.05rem 0.45rem`,fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace)`,fontSize:`0.72rem`,fontWeight:`650`};function T(e){if(e==null)return``;if(typeof e==`string`)try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}try{return JSON.stringify(e,null,2)}catch{return String(e)}}function E(e){return e?.content?.filter(e=>e.type===`text`).map(e=>e.text??``).join(`
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{G as t,Rt as n}from"./icons-DHoaB5uq.js";import{n as r,t as i}from"./react-vendor-BR9MG2D-.js";import{d as a,p as o,t as s}from"./lit-vendor-Dr3cpBGF.js";import{_ as c,g as l,h as u}from"./pi-web-ui-DqxtBlZL.js";import{t as d}from"./logger-B65Akg8A.js";import{B as f,I as p,L as m,R as h,d as g,j as _,r as v,st as y}from"./index-CZb_mGGF.js";import{t as b}from"./plugin-api-Ds5xGIL7.js";var x=e(n(),1),S={maxHeight:`28rem`,overflow:`auto`,border:`1px solid color-mix(in oklab, var(--border) 75%, transparent)`,borderRadius:`0.75rem`,background:`color-mix(in oklab, var(--muted) 28%, transparent)`,fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace)`,fontSize:`0.78rem`,lineHeight:`1.45`},C={minHeight:`1.35em`,padding:`0 0.75rem`,whiteSpace:`pre`},w={display:`inline-flex`,alignItems:`center`,borderRadius:`999px`,padding:`0.05rem 0.45rem`,fontFamily:`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace)`,fontSize:`0.72rem`,fontWeight:`650`};function T(e){if(e==null)return``;if(typeof e==`string`)try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}try{return JSON.stringify(e,null,2)}catch{return String(e)}}function E(e){return e?.content?.filter(e=>e.type===`text`).map(e=>e.text??``).join(`
2
2
  `)??``}function D(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function O(e,t){if(e.running===!0||t)return`Status: running`;let n=[e.timedOut?`timed out`:null,e.aborted?`aborted`:null].filter(Boolean),r=n.length?` (${n.join(`, `)})`:``;return`Exit code: ${e.code??`unknown`}${typeof e.signal==`string`&&e.signal?`, signal: ${e.signal}`:``}${r}`}function k(e,t,n){let r=D(t)?t:void 0,i=typeof r?.command==`string`?r.command:typeof e?.command==`string`?e.command:``;if(!i||!r)return``;let a=typeof r?.stdout_preview==`string`?r.stdout_preview:typeof r?.stdout==`string`?r.stdout:``,o=typeof r?.stderr_preview==`string`?r.stderr_preview:typeof r?.stderr==`string`?r.stderr:``,s=!!(a||o),c=r.running===!0||r.code!==void 0||r.signal!==void 0||r.timedOut===!0||r.aborted===!0;return!s&&!c&&!n?``:[`Command: ${i}`,O(r,n),``,`STDOUT:`,a||`(empty)`,``,`STDERR:`,o||`(empty)`].join(`
3
3
  `)}function A(e,t,n,r){return E(n)||(e===`run_command`?k(t,n?.details,r):``)}function j(e,t){return D(e)&&typeof e[t]==`string`?e[t]:``}function M(e,t,n){if(!t&&!n?.details)return``;if(e===`run_command`&&typeof t?.command==`string`)return t.command;if(e===`present_files`){let e=(Array.isArray(t?.files)?t.files:Array.isArray(n?.details&&n.details.files)?(n?.details).files:[]).map(e=>typeof e==`string`?e:D(e)&&typeof e.path==`string`?e.path:``).filter(Boolean);return e.length?e.slice(0,3).join(`, `)+(e.length>3?` +${e.length-3}`:``):``}if(e===`grep_files`){let e=typeof t?.query==`string`&&t.query?t.query:j(n?.details,`query`),r=typeof t?.path==`string`&&t.path?t.path:j(n?.details,`path`)||`.`,i=t?.regex||D(n?.details)&&D(n.details.searchOptions)&&n.details.searchOptions.regex?`regex`:`text`,a=r&&r!==`.`?` in ${r}`:` in current workspace`;return e?`${i}: ${e}${a}`:`searching${a}`}return e===`activate_skill`&&typeof t?.name==`string`?t.name:e===`read_skill_resource`&&typeof t?.path==`string`||t&&`path`in t&&typeof t.path==`string`?t.path:t&&`query`in t&&typeof t.query==`string`?t.query:t&&`search_query`in t&&typeof t.search_query==`string`?t.search_query:``}function ee(e){if(!e||typeof e!=`object`)return;let t=e.diff;if(!t||typeof t!=`object`)return;let n=t;return typeof n.text==`string`?n:void 0}function te(e){if(!e||typeof e!=`object`)return e;let t=e,n=t.diff;if(!n||typeof n!=`object`)return e;let{text:r,...i}=n;return{...t,diff:i}}function N(e){if(!e||typeof e!=`object`)return{};let t=e;return{sessionId:typeof t.sessionId==`string`?t.sessionId:void 0,toolCallId:typeof t.toolCallId==`string`?t.toolCallId:void 0}}async function P(e,t,n){let r=n.getAttribute(`aria-label`)||y(`terminateCommand`);n.disabled=!0,n.setAttribute(`aria-label`,y(`commandTerminateRequested`)),n.setAttribute(`title`,y(`commandTerminateRequested`));try{let n=await fetch(`/api/agents/${encodeURIComponent(e)}/abort-tool`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({toolCallId:t})});if(!n.ok)throw Error(`HTTP ${n.status}`)}catch{n.disabled=!1,n.setAttribute(`aria-label`,r),n.setAttribute(`title`,y(`terminateCommandTitle`))}}function ne(e){return e.startsWith(`+++`)||e.startsWith(`---`)?`quickforge-diff-file`:e.startsWith(`@@`)?`quickforge-diff-hunk`:e.startsWith(`+`)?`quickforge-diff-add`:e.startsWith(`-`)?`quickforge-diff-del`:`quickforge-diff-context`}function F(e){return e.startsWith(`+++`)||e.startsWith(`---`)?{...C,background:`color-mix(in oklab, var(--muted) 48%, transparent)`,color:`color-mix(in oklab, var(--muted-foreground) 88%, transparent)`}:e.startsWith(`@@`)?{...C,background:`color-mix(in oklab, rgb(37 99 235) 10%, transparent)`,color:`rgb(37 99 235)`}:e.startsWith(`+`)?{...C,background:`color-mix(in oklab, rgb(34 197 94) 16%, transparent)`,color:`rgb(22 101 52)`}:e.startsWith(`-`)?{...C,background:`color-mix(in oklab, rgb(239 68 68) 14%, transparent)`,color:`rgb(153 27 27)`}:{...C,color:`var(--foreground)`}}function re(e,t){if(e!==`write_file`&&e!==`edit_file`||!t)return a;let n=Number(t.addedLines??0),r=Number(t.removedLines??0);return o`
4
4
  <span class="shrink-0 inline-flex items-center gap-1" title="+${n} -${r}">
@@ -239,4 +239,4 @@ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{G as t,Rt as n}from"./
239
239
  <span></span>
240
240
  <span></span>
241
241
  </div>
242
- `),h.previousElementSibling!==p&&p.after(h),!0}function Ir(e){let{panel:t,isStreaming:n,abort:r,agentAccessMode:i,planMode:a,workspaceToolsEnabled:o,readOnly:s,allowModelControls:c,onAccessModeChange:l,onTogglePlanMode:u,onInput:d,onFilesChange:f,removeCommandSuggestions:p,updateCommandSuggestions:m,setupCommandTextareaHandler:h,removeCapabilitySuggestions:g,updateCapabilitySuggestions:_,setupCapabilityTextareaHandler:v,insertBuiltinPluginMention:b,onBeforeSend:x}=e,S=t.querySelector(`message-editor`);S?.classList.add(`quickforge-composer`),S?.parentElement?.classList.add(`quickforge-composer-shell`),S?.parentElement?.parentElement?.classList.add(`quickforge-composer-dock`);let C=S?.querySelector(`textarea`);if(C&&(C.placeholder=y(`composerPlaceholder`)),s){t.querySelector(`.quickforge-composer-dock`)?.remove();return}It({editor:S,onInput:d,onFilesChange:f,removeCommandSuggestions:p,updateCommandSuggestions:m,removeCapabilitySuggestions:g,updateCapabilitySuggestions:_,onBeforeSend:x}),h(S),v(S),Nt(S,a,u);let w=t.querySelector(`agent-interface`);if(w){let e=w.enableModelSelector!==c;w.enableModelSelector=c,w.enableThinkingSelector=!1,e&&w.requestUpdate?.()}let T=S?.querySelectorAll(`.flex.gap-2.items-center`),E=T?.[0],D=T?.[T.length-1];if(D){if(Mt(S,D),Ft({rightControls:D,isStreaming:n,abort:r,removeCommandSuggestions:p}),!E){t.querySelector(`.quickforge-plus-inline`)?.remove(),wt(t),t.querySelector(`.quickforge-agent-access-inline`)?.remove(),yt(t),t.querySelector(`.quickforge-yolo-inline`)?.remove(),t.querySelector(`.quickforge-plan-inline`)?.remove();return}if(S&&At({panel:t,editor:S,leftControls:E,insertBuiltinPluginMention:b,removeCommandSuggestions:p,removeCapabilitySuggestions:g}),Pt({panel:t,leftControls:E,planMode:a,onTogglePlanMode:u}),!o){t.querySelector(`.quickforge-agent-access-inline`)?.remove(),yt(t),t.querySelector(`.quickforge-yolo-inline`)?.remove();return}St({panel:t,leftControls:E,agentAccessMode:i,onAccessModeChange:l,dismissComposerMenus:()=>wt(t)})}}function Q(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function $(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n:void 0}function Lr(e,t){let n=e[t];return typeof n==`boolean`?n:void 0}function Rr(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function zr(e){let t=e&&Q(e.diff)?e.diff:void 0;return{addedLines:t?Rr(t,`addedLines`):void 0,removedLines:t?Rr(t,`removedLines`):void 0}}function Br(e=``){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)?`html`:/\.(svg|png|jpe?g|webp|gif|bmp|ico)$/i.test(t)?`image`:t.endsWith(`.md`)||t.endsWith(`.mdx`)?`markdown`:/\.(ts|tsx|js|jsx|mjs|cjs|css|scss|less|json|jsonc|txt|xml|yml|yaml|toml|ini|py|rb|go|rs|java|c|h|cpp|hpp|cs|php|sh|bash|zsh|ps1)$/i.test(t)?`code`:`unknown`}function Vr(e){return e===`html`||e===`image`||e===`markdown`||e===`code`}function Hr(e){return[e.source,e.path??``,e.command??``,e.outputFile??``,e.toolCallId??``,e.preview?`preview`:``].join(`\0`)}function Ur(e,t,n){let r=Hr(n);t.has(r)||(t.add(r),e.push({id:`${e.length}:${r}`,...n}))}function Wr(e){if(!(typeof e!=`string`||!e.trim()))try{return JSON.parse(e)}catch{return}}function Gr(e,t){if(t&&(Array.isArray(t.files)||Array.isArray(t.previewed)))return t;let n=e.data;if(Array.isArray(n))for(let e of n){if(!Q(e)||e.type!==`text`)continue;let t=Wr(e.text);if(Q(t)&&(Array.isArray(t.files)||Array.isArray(t.previewed)))return t}let r=e.content;if(Array.isArray(r))for(let e of r){if(!Q(e)||e.type!==`text`)continue;let t=Wr(e.text);if(Q(t)&&(Array.isArray(t.files)||Array.isArray(t.previewed)))return t}return t}function Kr(e){if(typeof e==`string`&&e.trim())return{path:e};if(Q(e)){let t=$(e,`path`);return t?{path:t,title:$(e,`title`),description:$(e,`description`),kind:$(e,`kind`),preview:Lr(e,`preview`)}:void 0}}function qr(e){let t=new Set,n=[];for(let r of e){if(r.role!==`toolResult`)continue;let e=typeof r.toolName==`string`?r.toolName:``,i=Q(r.details)?r.details:void 0,a=typeof r.toolCallId==`string`?r.toolCallId:void 0;if(!(!i&&e!==`present_files`)){if(e===`write_file`||e===`edit_file`){let r=i?$(i,`path`):void 0;if(r){let o=Br(r),{addedLines:s,removedLines:c}=zr(i);Ur(n,t,{source:e,confidence:`high`,path:r,toolCallId:a,kind:o,preview:Vr(o),presentation:`inferred`,addedLines:s,removedLines:c})}}else if(e===`present_files`){let e=Gr(r,i),o=Q(e)&&Array.isArray(e.files)?e.files:[],s=Q(e)?$(e,`defaultPreview`):void 0,c=new Set(Q(e)&&Array.isArray(e.previewed)?e.previewed.filter(e=>typeof e==`string`):[]);for(let e of o){let r=Kr(e);if(!r?.path)continue;let i=r.kind??Br(r.path);Ur(n,t,{source:`present_files`,confidence:`high`,path:r.path,title:r.title,description:r.description,toolCallId:a,kind:i,preview:r.preview??(c.has(r.path)||s===r.path||Vr(i)),defaultPreview:s===r.path,presentation:`explicit`})}}else if(e===`run_command`&&i){let e=$(i,`command`),r=$(i,`outputFile`);(e||r)&&Ur(n,t,{source:`run_command`,confidence:`low`,command:e,outputFile:r,toolCallId:a})}}}return n}function Jr(e){return e?.length?qr(e):[]}var Yr=`quickforge:composer-drafts:v1`,Xr=100,Zr={},Qr=!1;function $r(e){return!!(e&&!e.startsWith(`pending-`))}function ei(e){return $r(e.sessionId)?`session:${e.sessionId}`:e.scope===`project`&&e.projectId?`new:project:${e.projectId}`:`new:global`}function ti(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e)){if(!r||typeof r!=`object`||Array.isArray(r))continue;let e=r;typeof e.text==`string`&&(t[n]={text:e.text,updatedAt:typeof e.updatedAt==`string`?e.updatedAt:new Date().toISOString(),scope:e.scope===`project`?`project`:e.scope===`global`?`global`:void 0,projectId:typeof e.projectId==`string`?e.projectId:void 0,sessionId:typeof e.sessionId==`string`?e.sessionId:void 0})}return t}function ni(){try{return globalThis.localStorage}catch{return}}function ri(e,t=Xr){return Object.fromEntries(Object.entries(e).filter(([,e])=>e.text.length>0).sort(([,e],[,t])=>t.updatedAt.localeCompare(e.updatedAt)).slice(0,t))}function ii(){let e=ni();if(!e||Qr)return Zr;let t;try{t=e.getItem(Yr)}catch{return Qr=!0,Zr}try{return ti(t?JSON.parse(t):void 0)}catch{return Zr}}function ai(e){let t=ri(e);Zr=t;let n=ni();if(!(!n||Qr))try{Object.keys(t).length===0?n.removeItem(Yr):n.setItem(Yr,JSON.stringify(t))}catch{let e=ri(t,Math.ceil(Xr/2));Zr=e;try{Object.keys(e).length===0?n.removeItem(Yr):n.setItem(Yr,JSON.stringify(e))}catch{Qr=!0}}}async function oi(e){let t=ii()[e];if(!(!t||t.text.length===0))return{text:t.text,attachments:[]}}async function si(e,t,n){let r=t.text??``;if(r.length===0){await ci(e);return}let i=ii();i[e]={text:r,updatedAt:new Date().toISOString(),scope:n.scope,projectId:n.scope===`project`?n.projectId:void 0,sessionId:$r(n.sessionId)?n.sessionId:void 0},ai(i)}async function ci(e){let t=ii();Object.prototype.hasOwnProperty.call(t,e)&&(delete t[e],ai(t))}function li(){let e=0;return{version:()=>e,isCurrent:t=>t===e,invalidate:()=>(e+=1,e)}}var ui=r();function di(e){let t=e.state.contextCompaction;if(!t?.summaryMessage)return e.state.messages;let n=e.state.messages,r=Math.min(n.length,Math.max(0,Number(t.compactedUpToIndex)||0));return[t.summaryMessage,...n.slice(r)]}function fi(e){let t=String(e.length);for(let n of e)n.role===`toolResult`&&(t+=`|${n.toolCallId??``}:${n.toolName??``}`);return t}function pi({agent:e,onModelSelect:t,revision:n,agentAccessMode:r,workspaceToolsEnabled:i,project:a,projectId:o,chatScope:s=`global`,onAccessModeChange:c,onRollbackFromMessage:f,onRetryFromMessage:p,onCopyAnswer:m,onForkFromMessage:h,onApproveToolCall:_,onRejectToolCall:v,onApproveAutoCompact:b,onRejectAutoCompact:S,onOpenWorkspaceGitChanges:C,onOpenLocalFilePath:w,onArtifactsChange:T,onContextUsageDisplayChange:E,restoredDraft:D,disableFork:O=!1,readOnly:k=!1,bypassClientApiKeyCheck:A=!1,allowModelControls:j=!0,newChatEmptyState:M=!1,rollbackConfirmTitle:ee,rollbackConfirmDescription:te}){let N=(0,x.useRef)(null),P=(0,x.useRef)(void 0),ne=(0,x.useRef)(void 0),F=(0,x.useRef)(new Map),re=(0,x.useRef)([]),ie=(0,x.useRef)(void 0),ae=(0,x.useRef)(new Set),I=(0,x.useRef)(void 0),oe=(0,x.useRef)(``),se=(0,x.useRef)(``),ce=(0,x.useRef)(li()),[le,ue]=(0,x.useState)(),[L,R]=(0,x.useState)(!1),de=(0,x.useCallback)(()=>R(e=>!e),[]),fe=(0,x.useCallback)(()=>R(!1),[]);(0,x.useEffect)(()=>{e?.setPlanMode?.(L,L?fe:void 0)},[e,L,fe]);let z=(0,x.useCallback)(()=>{I.current&&=(window.clearTimeout(I.current),void 0)},[]),pe=(0,x.useMemo)(()=>({sessionId:e?.sessionId,scope:s,projectId:o}),[e?.sessionId,s,o]),me=ei(pe),he=(0,x.useRef)(pe),B=(0,x.useRef)(me);(0,x.useEffect)(()=>{he.current=pe,B.current=me},[pe,me]),(0,x.useEffect)(()=>()=>{z()},[z]);let ge=(0,x.useCallback)((e,t,n)=>{if(t.text.length===0){ci(e).catch(e=>d.error(`Failed to clear composer draft:`,e));return}si(e,t,n).catch(e=>d.error(`Failed to save composer draft:`,e))},[]),V=(0,x.useCallback)((e,t,n)=>{I.current&&window.clearTimeout(I.current),I.current=window.setTimeout(()=>{I.current=void 0,ge(e,t,n)},400)},[ge]),_e=(0,x.useCallback)((e,t=B.current,n=he.current)=>{let r=Lt(e);q(r)?F.current.set(t,r):F.current.delete(t),ge(t,r,n)},[ge]),H=(0,x.useRef)({onCopyAnswer:m,onRollbackFromMessage:f,onRetryFromMessage:p,onForkFromMessage:h,onAccessModeChange:c,onTogglePlanMode:de,onApproveToolCall:_,onRejectToolCall:v,onApproveAutoCompact:b,onRejectAutoCompact:S,onOpenWorkspaceGitChanges:C,onOpenLocalFilePath:w,onArtifactsChange:T,onContextUsageDisplayChange:E,onModelSelect:t,agentAccessMode:r,planMode:L,workspaceToolsEnabled:i,disableFork:O,readOnly:k,allowModelControls:j,newChatEmptyState:M,bypassClientApiKeyCheck:A,rollbackConfirmTitle:ee,rollbackConfirmDescription:te,gitBranch:le});(0,x.useEffect)(()=>{H.current={onCopyAnswer:m,onRollbackFromMessage:f,onRetryFromMessage:p,onForkFromMessage:h,onAccessModeChange:c,onTogglePlanMode:de,onApproveToolCall:_,onRejectToolCall:v,onApproveAutoCompact:b,onRejectAutoCompact:S,onOpenWorkspaceGitChanges:C,onOpenLocalFilePath:w,onArtifactsChange:T,onContextUsageDisplayChange:E,onModelSelect:t,agentAccessMode:r,planMode:L,workspaceToolsEnabled:i,disableFork:O,readOnly:k,allowModelControls:j,newChatEmptyState:M,bypassClientApiKeyCheck:A,rollbackConfirmTitle:ee,rollbackConfirmDescription:te,gitBranch:le},ne.current=D});let ve=a?.id??o;(0,x.useEffect)(()=>{let e=!1;return queueMicrotask(()=>{if(!e){if(!ve){ue(void 0);return}g(ve).then(t=>{e||ue(t.isGitRepository?t.branch:void 0)}).catch(t=>{e||(d.warn(`Failed to load git branch:`,t),ue(void 0))})}}),()=>{e=!0}},[ve,n]);let ye=(0,x.useRef)(null),be=(0,x.useRef)(null),U=(0,x.useRef)(null),W=(0,x.useRef)(null),G=(0,x.useRef)(null);(0,x.useEffect)(()=>{let e=!1;return a?.id?(fetch(`/api/project/commands?projectId=${encodeURIComponent(a.id)}`,{cache:`no-store`}).then(e=>e.ok?e.json():{commands:[]}).then(t=>{e||(re.current=Array.isArray(t.commands)?t.commands:[],U.current?.())}).catch(()=>{e||(re.current=[],U.current?.())}),()=>{e=!0}):(re.current=[],()=>{e=!0})},[a?.id,n]);let xe=(e,t,n,r,i=!1)=>{if(t.sessionId&&t.sessionId!==n||!q(t)||!i&&ae.current.has(t.id))return;let a=()=>{if(!i&&ae.current.has(t.id))return;let n=e.querySelector(`message-editor`),a=n?{text:n.value??n.querySelector(`textarea`)?.value??``,attachments:n.attachments?[...n.attachments]:[]}:F.current.get(r),o=ie.current;(o?.id!==t.id||!q(a??Te())||a?.text===o.text)&&(zt(e,t,F.current,r),ie.current={id:t.id,text:t.text})};a(),window.requestAnimationFrame(a);for(let e of[0,50,150,300,600])window.setTimeout(a,e);e.querySelector(`agent-interface`)?.updateComplete?.then(a)};return(0,x.useEffect)(()=>{if(!N.current||!e)return;let t=new u;R(!1);let n=e.sessionId,r=B.current,i=he.current,a=!1,o,s=!1,c=e.state.isStreaming,f=!1,p=Fe({panel:t});be.current=p;let m=Ie({panel:t,getCustomCommands:()=>re.current,getComposerDrafts:()=>F.current,sessionId:r,setComposerDrafts:e=>{F.current=e},restoreDraftIntoComposer:e=>{zt(t,e,F.current,r),V(r,e,i)}}),h=We({panel:t,restoreDraftIntoComposer:e=>{zt(t,e,F.current,r),V(r,e,i)}}),g=et({panel:t,getSystemPrompt:()=>e.state.systemPrompt,getMessages:()=>e.state.messages,getEffectiveMessages:()=>di(e),getContextWindow:()=>e.state.model?.contextWindow??0,getTools:()=>e.state.tools,getMaxTokens:()=>e.state.model?.maxTokens,getServerContextUsage:()=>e.state.contextUsage??null,getGitBranch:()=>H.current.gitBranch,onGitBranchClick:()=>H.current.onOpenWorkspaceGitChanges?.(),renderInline:!1,onDisplayChange:t=>H.current.onContextUsageDisplayChange?.(e.sessionId,t)}),_=e=>{s=!1;let n=t.querySelector(`message-editor`),a={text:e,attachments:n?.attachments?[...n.attachments]:[]};q(a)?F.current.set(r,a):F.current.delete(r),V(r,a,i)},v=e=>{s=!1;let n=t.querySelector(`message-editor`),a=n?.querySelector(`textarea`),o={text:n?.value??a?.value??``,attachments:e?[...e]:[]};q(o)?F.current.set(r,o):F.current.delete(r),V(r,o,i);let c=t.querySelector(`agent-interface`);c?.requestUpdate?.(),window.requestAnimationFrame(()=>U.current?.()),c?.updateComplete?.then(()=>U.current?.())},b=()=>{e.state.isStreaming?t.dataset.quickforgeAgentStreaming=`true`:delete t.dataset.quickforgeAgentStreaming},x=()=>{if(a||!t.isConnected)return;b();let n=H.current,r=fi(e.state.messages);if(r!==se.current){se.current=r;let t=Jr(e.state.messages),i=JSON.stringify(t.map(e=>[e.source,e.path,e.command,e.outputFile,e.confidence,e.preview,e.defaultPreview,e.addedLines,e.removedLines]));i!==oe.current&&(oe.current=i,n.onArtifactsChange?.(t))}try{Er({panel:t,getMessages:()=>e.state.messages,isStreaming:()=>e.state.isStreaming,onCopyAnswer:n.onCopyAnswer,onRollbackFromMessage:n.onRollbackFromMessage,onRetryFromMessage:n.onRetryFromMessage,onForkFromMessage:n.onForkFromMessage,onOpenLocalFilePath:n.onOpenLocalFilePath,disableFork:n.disableFork,readOnly:n.readOnly,enableTerminalCommandActions:!n.readOnly,rollbackConfirmTitle:n.rollbackConfirmTitle,rollbackConfirmDescription:n.rollbackConfirmDescription}),en({panel:t,getMessages:()=>e.state.messages,getContextCompaction:()=>e.state.contextCompaction??null}),Fr({panel:t,getMessages:()=>e.state.messages,isStreaming:()=>e.state.isStreaming,isActive:c})}catch{}try{Ir({panel:t,isStreaming:()=>e.state.isStreaming,abort:()=>e.abort(),agentAccessMode:n.agentAccessMode,planMode:n.planMode,workspaceToolsEnabled:n.workspaceToolsEnabled,readOnly:n.readOnly,allowModelControls:n.allowModelControls,onAccessModeChange:n.onAccessModeChange,onTogglePlanMode:n.onTogglePlanMode,onInput:_,onFilesChange:v,removeCommandSuggestions:m.remove,updateCommandSuggestions:m.update,setupCommandTextareaHandler:m.setupTextareaHandler,removeCapabilitySuggestions:h.remove,updateCapabilitySuggestions:h.update,setupCapabilityTextareaHandler:h.setupTextareaHandler,insertBuiltinPluginMention:h.insertBuiltinPluginMention,onBeforeSend:t=>{let n=h.consumeSelectedCapabilities(t);e.setNextPromptCapabilities?.(n)}})}catch{}let i=W.current??(()=>{let t=e.state.pendingToolApproval;return t?{...t,sessionId:e.sessionId}:null})();if(i&&i.sessionId===e.sessionId&&typeof i.toolCallId==`string`&&typeof i.toolName==`string`){let n=i.toolCallId;Kt({panel:t,onApprove:async()=>{await H.current.onApproveToolCall(n),W.current=null,e.state.pendingToolApproval=null,qt(t)},onReject:async()=>{await H.current.onRejectToolCall(n),W.current=null,e.state.pendingToolApproval=null,qt(t)}},i.toolName,n,i.args,i.source)}else{let n=G.current??(()=>{let t=e.state.pendingAutoCompactApproval;return t?{...t,sessionId:e.sessionId}:null})();if(n&&n.sessionId===e.sessionId){let r=n.approvalId;Kt({panel:t,onApprove:async()=>{await H.current.onApproveAutoCompact?.(r),G.current=null,e.state.pendingAutoCompactApproval=null,qt(t)},onReject:async()=>{await H.current.onRejectAutoCompact?.(r),G.current=null,e.state.pendingAutoCompactApproval=null,qt(t)}},y(`contextManagement`),r,{percent:n.usage?.percent??0,threshold:n.thresholdPercent??0,keepRecentTurns:n.keepRecentTurns??3,summary:y(`autoCompactApprovalWaiting`,{percent:n.usage?.percent??0,threshold:n.thresholdPercent??0}),description:y(`autoCompactApprovalPreview`,{keepRecentTurns:n.keepRecentTurns??3})})}else qt(t)}g.update(),p.setup(),p.isEnabled&&p.scheduleScrollToBottom()},S=!1,C,w=!1,T,E=()=>{T===void 0&&(T=window.requestAnimationFrame(()=>{T=void 0,w=!1}))},D=()=>{if(!a){w=!0;try{x()}finally{E()}}},O=()=>{S||(S=!0,C=window.requestAnimationFrame(()=>{C=void 0,S=!1,D()}))};ye.current=D;let k=()=>{f||(f=!0,window.requestAnimationFrame(()=>{if(f=!1,a)return;b();let e=t.querySelector(`agent-interface`);e?.requestUpdate?.(),U.current?.(),e?.updateComplete?.then(()=>U.current?.()),p.isEnabled&&p.scheduleScrollToBottom()}))};U.current=O,t.setAgent(e,{onApiKeyRequired:H.current.bypassClientApiKeyCheck?async()=>!0:e=>l.prompt(e),onBeforeSend:()=>{ce.current.invalidate();let e=ne.current;e&&ae.current.add(e.id),z(),s=!0,m.remove(),F.current.delete(r),ci(r).catch(e=>d.error(`Failed to clear composer draft:`,e)),p.enable()},onModelSelect:H.current.onModelSelect,toolsFactory:()=>Ce(e.state.tools)}).then(()=>{if(a)return;let e=ne.current,i=ce.current.version(),s=o=>{a||!ce.current.isCurrent(i)||(e&&P.current!==e.id?(P.current=e.id,xe(t,e,n,r)):zt(t,o??F.current.get(r)??Te(),F.current,r))};if(e&&P.current!==e.id)s();else{let e=F.current.get(r);e?s(e):oi(r).then(e=>s(e)).catch(e=>d.error(`Failed to load composer draft:`,e))}o=new MutationObserver(()=>{w||O()}),o.observe(t,{childList:!0,subtree:!0}),window.requestAnimationFrame(()=>{a||D()})}),N.current.replaceChildren(t);let A=e.subscribe(i=>{if(i.type===`agent_start`&&(c=!0,b(),U.current?.(),p.enable(),W.current?.sessionId===e.sessionId&&(W.current=null),G.current?.sessionId===e.sessionId&&(G.current=null)),i.type===`message_start`||i.type===`message_update`||i.type===`message_end`||i.type===`turn_end`||i.type===`agent_end`){b();let e=i.message;(i.type===`message_update`||e?.role===`assistant`)&&(c=!1),U.current?.(),p.isEnabled&&p.scheduleScrollToBottom()}if(i.type===`messages_replaced`){let e=ne.current;e&&P.current===e.id&&xe(t,e,n,r)}let a=i.type;if(a===`tool_execution_start`||a===`tool_execution_end`){b();let e=t.querySelector(`agent-interface`);e?.requestUpdate?.(),U.current?.(),window.requestAnimationFrame(()=>U.current?.()),e?.updateComplete?.then(()=>U.current?.()),p.isEnabled&&p.scheduleScrollToBottom()}if(a===`tool_execution_update`&&k(),i.type===`agent_end`&&(c=!1,b(),U.current?.(),W.current?.sessionId===e.sessionId&&(W.current=null,U.current?.()),G.current?.sessionId===e.sessionId&&(G.current=null,U.current?.())),a===`auto_compact_completed`||a===`messages_replaced`){let e=t.querySelector(`agent-interface`);e?.requestUpdate?.(),U.current?.(),window.requestAnimationFrame(()=>U.current?.()),e?.updateComplete?.then(()=>U.current?.())}if(a===`auto_compact_failed`&&d.warn(y(`autoCompactFailed`)),i.type===`tool_approval_required`){let e=i;W.current={toolCallId:e.toolCallId,toolName:e.toolName,args:e.args,sessionId:e.sessionId,source:e.source},U.current?.()}if(i.type===`auto_compact_approval_required`){let e=i;G.current={approvalId:e.approvalId,usage:e.usage,thresholdPercent:e.thresholdPercent,keepRecentTurns:e.keepRecentTurns,sessionId:e.sessionId},U.current?.()}});return()=>{s?(z(),F.current.delete(r),ci(r).catch(e=>d.error(`Failed to clear composer draft:`,e))):(Rt(t,F.current,r),_e(t,r,i)),m.remove(),m.cleanupTextareaHandler(),h.remove(),h.cleanupTextareaHandler(),a=!0,p.cleanup(),be.current=null,A(),o?.disconnect(),C!==void 0&&window.cancelAnimationFrame(C),T!==void 0&&window.cancelAnimationFrame(T),ye.current=null,t.remove()}},[e,z,_e,V]),(0,x.useEffect)(()=>{let e=N.current;e&&(e.classList.toggle(`quickforge-chat-panel-empty-host`,M),e.dataset.quickforgeEmptyChat=M?`true`:`false`)},[M]),(0,x.useEffect)(()=>{ye.current?.(),(N.current?.querySelector(`agent-interface`))?.requestUpdate?.()},[r,L,i,le,O,k,j,n]),(0,x.useEffect)(()=>{let t=ne.current;if(!t||!N.current)return;let n=e?.sessionId??``;if(t.sessionId&&t.sessionId!==n)return;let r=N.current.querySelector(`pi-chat-panel`);r&&(P.current=t.id,xe(r,t,n,B.current,!0))},[D,e]),(0,ui.jsx)(`div`,{ref:N,className:`min-h-0 flex-1 overflow-hidden`})}export{pi as ChatPanelHost};
242
+ `),h.previousElementSibling!==p&&p.after(h),!0}function Ir(e){let{panel:t,isStreaming:n,abort:r,agentAccessMode:i,planMode:a,workspaceToolsEnabled:o,readOnly:s,allowModelControls:c,onAccessModeChange:l,onTogglePlanMode:u,onInput:d,onFilesChange:f,removeCommandSuggestions:p,updateCommandSuggestions:m,setupCommandTextareaHandler:h,removeCapabilitySuggestions:g,updateCapabilitySuggestions:_,setupCapabilityTextareaHandler:v,insertBuiltinPluginMention:b,onBeforeSend:x}=e,S=t.querySelector(`message-editor`);S?.classList.add(`quickforge-composer`),S?.parentElement?.classList.add(`quickforge-composer-shell`),S?.parentElement?.parentElement?.classList.add(`quickforge-composer-dock`);let C=S?.querySelector(`textarea`);if(C&&(C.placeholder=y(`composerPlaceholder`)),s){t.querySelector(`.quickforge-composer-dock`)?.remove();return}It({editor:S,onInput:d,onFilesChange:f,removeCommandSuggestions:p,updateCommandSuggestions:m,removeCapabilitySuggestions:g,updateCapabilitySuggestions:_,onBeforeSend:x}),h(S),v(S),Nt(S,a,u);let w=t.querySelector(`agent-interface`);if(w){let e=w.enableModelSelector!==c;w.enableModelSelector=c,w.enableThinkingSelector=!1,e&&w.requestUpdate?.()}let T=S?.querySelectorAll(`.flex.gap-2.items-center`),E=T?.[0],D=T?.[T.length-1];if(D){if(Mt(S,D),Ft({rightControls:D,isStreaming:n,abort:r,removeCommandSuggestions:p}),!E){t.querySelector(`.quickforge-plus-inline`)?.remove(),wt(t),t.querySelector(`.quickforge-agent-access-inline`)?.remove(),yt(t),t.querySelector(`.quickforge-yolo-inline`)?.remove(),t.querySelector(`.quickforge-plan-inline`)?.remove();return}if(S&&At({panel:t,editor:S,leftControls:E,insertBuiltinPluginMention:b,removeCommandSuggestions:p,removeCapabilitySuggestions:g}),Pt({panel:t,leftControls:E,planMode:a,onTogglePlanMode:u}),!o){t.querySelector(`.quickforge-agent-access-inline`)?.remove(),yt(t),t.querySelector(`.quickforge-yolo-inline`)?.remove();return}St({panel:t,leftControls:E,agentAccessMode:i,onAccessModeChange:l,dismissComposerMenus:()=>wt(t)})}}function Q(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function $(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n:void 0}function Lr(e,t){let n=e[t];return typeof n==`boolean`?n:void 0}function Rr(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function zr(e){let t=e&&Q(e.diff)?e.diff:void 0;return{addedLines:t?Rr(t,`addedLines`):void 0,removedLines:t?Rr(t,`removedLines`):void 0}}function Br(e=``){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)?`html`:/\.(svg|png|jpe?g|webp|gif|bmp|ico)$/i.test(t)?`image`:t.endsWith(`.md`)||t.endsWith(`.mdx`)?`markdown`:/\.(ts|tsx|js|jsx|mjs|cjs|css|scss|less|json|jsonc|txt|xml|yml|yaml|toml|ini|py|rb|go|rs|java|c|h|cpp|hpp|cs|php|sh|bash|zsh|ps1)$/i.test(t)?`code`:`unknown`}function Vr(e){return e===`html`||e===`image`||e===`markdown`||e===`code`}function Hr(e){return[e.source,e.path??``,e.command??``,e.outputFile??``,e.toolCallId??``,e.preview?`preview`:``].join(`\0`)}function Ur(e,t,n){let r=Hr(n);t.has(r)||(t.add(r),e.push({id:`${e.length}:${r}`,...n}))}function Wr(e){if(!(typeof e!=`string`||!e.trim()))try{return JSON.parse(e)}catch{return}}function Gr(e,t){if(t&&(Array.isArray(t.files)||Array.isArray(t.previewed)))return t;let n=e.data;if(Array.isArray(n))for(let e of n){if(!Q(e)||e.type!==`text`)continue;let t=Wr(e.text);if(Q(t)&&(Array.isArray(t.files)||Array.isArray(t.previewed)))return t}let r=e.content;if(Array.isArray(r))for(let e of r){if(!Q(e)||e.type!==`text`)continue;let t=Wr(e.text);if(Q(t)&&(Array.isArray(t.files)||Array.isArray(t.previewed)))return t}return t}function Kr(e){if(typeof e==`string`&&e.trim())return{path:e};if(Q(e)){let t=$(e,`path`);return t?{path:t,title:$(e,`title`),description:$(e,`description`),kind:$(e,`kind`),preview:Lr(e,`preview`)}:void 0}}function qr(e){let t=new Set,n=[];for(let r of e){if(r.role!==`toolResult`)continue;let e=typeof r.toolName==`string`?r.toolName:``,i=Q(r.details)?r.details:void 0,a=typeof r.toolCallId==`string`?r.toolCallId:void 0;if(!(!i&&e!==`present_files`)){if(e===`write_file`||e===`edit_file`){let r=i?$(i,`path`):void 0;if(r){let o=Br(r),{addedLines:s,removedLines:c}=zr(i);Ur(n,t,{source:e,confidence:`high`,path:r,toolCallId:a,kind:o,preview:Vr(o),presentation:`inferred`,addedLines:s,removedLines:c})}}else if(e===`present_files`){let e=Gr(r,i),o=Q(e)&&Array.isArray(e.files)?e.files:[],s=Q(e)?$(e,`defaultPreview`):void 0,c=new Set(Q(e)&&Array.isArray(e.previewed)?e.previewed.filter(e=>typeof e==`string`):[]);for(let e of o){let r=Kr(e);if(!r?.path)continue;let i=r.kind??Br(r.path);Ur(n,t,{source:`present_files`,confidence:`high`,path:r.path,title:r.title,description:r.description,toolCallId:a,kind:i,preview:r.preview??(c.has(r.path)||s===r.path||Vr(i)),defaultPreview:s===r.path,presentation:`explicit`})}}else if(e===`run_command`&&i){let e=$(i,`command`),r=$(i,`outputFile`);(e||r)&&Ur(n,t,{source:`run_command`,confidence:`low`,command:e,outputFile:r,toolCallId:a})}}}return n}function Jr(e){return e?.length?qr(e):[]}var Yr=`quickforge:composer-drafts:v1`,Xr=100,Zr={},Qr=!1;function $r(e){return!!(e&&!e.startsWith(`pending-`))}function ei(e){return $r(e.sessionId)?`session:${e.sessionId}`:e.scope===`project`&&e.projectId?`new:project:${e.projectId}`:`new:global`}function ti(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e)){if(!r||typeof r!=`object`||Array.isArray(r))continue;let e=r;typeof e.text==`string`&&(t[n]={text:e.text,updatedAt:typeof e.updatedAt==`string`?e.updatedAt:new Date().toISOString(),scope:e.scope===`project`?`project`:e.scope===`global`?`global`:void 0,projectId:typeof e.projectId==`string`?e.projectId:void 0,sessionId:typeof e.sessionId==`string`?e.sessionId:void 0})}return t}function ni(){try{return globalThis.localStorage}catch{return}}function ri(e,t=Xr){return Object.fromEntries(Object.entries(e).filter(([,e])=>e.text.length>0).sort(([,e],[,t])=>t.updatedAt.localeCompare(e.updatedAt)).slice(0,t))}function ii(){let e=ni();if(!e||Qr)return Zr;let t;try{t=e.getItem(Yr)}catch{return Qr=!0,Zr}try{return ti(t?JSON.parse(t):void 0)}catch{return Zr}}function ai(e){let t=ri(e);Zr=t;let n=ni();if(!(!n||Qr))try{Object.keys(t).length===0?n.removeItem(Yr):n.setItem(Yr,JSON.stringify(t))}catch{let e=ri(t,Math.ceil(Xr/2));Zr=e;try{Object.keys(e).length===0?n.removeItem(Yr):n.setItem(Yr,JSON.stringify(e))}catch{Qr=!0}}}async function oi(e){let t=ii()[e];if(!(!t||t.text.length===0))return{text:t.text,attachments:[]}}async function si(e,t,n){let r=t.text??``;if(r.length===0){await ci(e);return}let i=ii();i[e]={text:r,updatedAt:new Date().toISOString(),scope:n.scope,projectId:n.scope===`project`?n.projectId:void 0,sessionId:$r(n.sessionId)?n.sessionId:void 0},ai(i)}async function ci(e){let t=ii();Object.prototype.hasOwnProperty.call(t,e)&&(delete t[e],ai(t))}function li(){let e=0;return{version:()=>e,isCurrent:t=>t===e,invalidate:()=>(e+=1,e)}}var ui=r();function di(e){let t=e.state.contextCompaction;if(!t?.summaryMessage)return e.state.messages;let n=e.state.messages,r=Math.min(n.length,Math.max(0,Number(t.compactedUpToIndex)||0));return[t.summaryMessage,...n.slice(r)]}function fi(e){let t=String(e.length);for(let n of e)n.role===`toolResult`&&(t+=`|${n.toolCallId??``}:${n.toolName??``}`);return t}function pi({agent:e,onModelSelect:t,revision:n,agentAccessMode:r,workspaceToolsEnabled:i,project:a,projectId:o,chatScope:s=`global`,onAccessModeChange:c,onRollbackFromMessage:f,onRetryFromMessage:p,onCopyAnswer:m,onForkFromMessage:h,onApproveToolCall:_,onRejectToolCall:v,onApproveAutoCompact:b,onRejectAutoCompact:S,onOpenWorkspaceGitChanges:C,onOpenLocalFilePath:w,onArtifactsChange:T,onContextUsageDisplayChange:E,restoredDraft:D,disableFork:O=!1,readOnly:k=!1,bypassClientApiKeyCheck:A=!1,allowModelControls:j=!0,newChatEmptyState:M=!1,rollbackConfirmTitle:ee,rollbackConfirmDescription:te}){let N=(0,x.useRef)(null),P=(0,x.useRef)(void 0),ne=(0,x.useRef)(void 0),F=(0,x.useRef)(new Map),re=(0,x.useRef)([]),ie=(0,x.useRef)(void 0),ae=(0,x.useRef)(new Set),I=(0,x.useRef)(void 0),oe=(0,x.useRef)(``),se=(0,x.useRef)(``),ce=(0,x.useRef)(li()),[le,ue]=(0,x.useState)(),[L,R]=(0,x.useState)(!1),de=(0,x.useCallback)(()=>R(e=>!e),[]),fe=(0,x.useCallback)(()=>R(!1),[]);(0,x.useEffect)(()=>{e?.setPlanMode?.(L,L?fe:void 0)},[e,L,fe]);let z=(0,x.useCallback)(()=>{I.current&&=(window.clearTimeout(I.current),void 0)},[]),pe=(0,x.useMemo)(()=>({sessionId:e?.sessionId,scope:s,projectId:o}),[e?.sessionId,s,o]),me=ei(pe),he=(0,x.useRef)(pe),B=(0,x.useRef)(me);(0,x.useEffect)(()=>{he.current=pe,B.current=me},[pe,me]),(0,x.useEffect)(()=>()=>{z()},[z]);let ge=(0,x.useCallback)((e,t,n)=>{if(t.text.length===0){ci(e).catch(e=>d.error(`Failed to clear composer draft:`,e));return}si(e,t,n).catch(e=>d.error(`Failed to save composer draft:`,e))},[]),V=(0,x.useCallback)((e,t,n)=>{I.current&&window.clearTimeout(I.current),I.current=window.setTimeout(()=>{I.current=void 0,ge(e,t,n)},400)},[ge]),_e=(0,x.useCallback)((e,t=B.current,n=he.current)=>{let r=Lt(e);q(r)?F.current.set(t,r):F.current.delete(t),ge(t,r,n)},[ge]),H=(0,x.useRef)({onCopyAnswer:m,onRollbackFromMessage:f,onRetryFromMessage:p,onForkFromMessage:h,onAccessModeChange:c,onTogglePlanMode:de,onApproveToolCall:_,onRejectToolCall:v,onApproveAutoCompact:b,onRejectAutoCompact:S,onOpenWorkspaceGitChanges:C,onOpenLocalFilePath:w,onArtifactsChange:T,onContextUsageDisplayChange:E,onModelSelect:t,agentAccessMode:r,planMode:L,workspaceToolsEnabled:i,disableFork:O,readOnly:k,allowModelControls:j,newChatEmptyState:M,bypassClientApiKeyCheck:A,rollbackConfirmTitle:ee,rollbackConfirmDescription:te,gitBranch:le});(0,x.useEffect)(()=>{H.current={onCopyAnswer:m,onRollbackFromMessage:f,onRetryFromMessage:p,onForkFromMessage:h,onAccessModeChange:c,onTogglePlanMode:de,onApproveToolCall:_,onRejectToolCall:v,onApproveAutoCompact:b,onRejectAutoCompact:S,onOpenWorkspaceGitChanges:C,onOpenLocalFilePath:w,onArtifactsChange:T,onContextUsageDisplayChange:E,onModelSelect:t,agentAccessMode:r,planMode:L,workspaceToolsEnabled:i,disableFork:O,readOnly:k,allowModelControls:j,newChatEmptyState:M,bypassClientApiKeyCheck:A,rollbackConfirmTitle:ee,rollbackConfirmDescription:te,gitBranch:le},ne.current=D});let ve=a?.id??o;(0,x.useEffect)(()=>{let e=!1;return queueMicrotask(()=>{if(!e){if(!ve){ue(void 0);return}g(ve).then(t=>{e||ue(t.isGitRepository?t.branch:void 0)}).catch(t=>{e||(d.warn(`Failed to load git branch:`,t),ue(void 0))})}}),()=>{e=!0}},[ve,n]);let ye=(0,x.useRef)(null),be=(0,x.useRef)(null),U=(0,x.useRef)(null),W=(0,x.useRef)(null),G=(0,x.useRef)(null);(0,x.useEffect)(()=>{let e=!1;return a?.id?(fetch(`/api/project/commands?projectId=${encodeURIComponent(a.id)}`,{cache:`no-store`}).then(e=>e.ok?e.json():{commands:[]}).then(t=>{e||(re.current=Array.isArray(t.commands)?t.commands:[],U.current?.())}).catch(()=>{e||(re.current=[],U.current?.())}),()=>{e=!0}):(re.current=[],()=>{e=!0})},[a?.id,n]);let xe=(e,t,n,r,i=!1)=>{if(t.sessionId&&t.sessionId!==n||!q(t)||!i&&ae.current.has(t.id))return;let a=()=>{if(!i&&ae.current.has(t.id))return;let n=e.querySelector(`message-editor`),a=n?{text:n.value??n.querySelector(`textarea`)?.value??``,attachments:n.attachments?[...n.attachments]:[]}:F.current.get(r),o=ie.current;(o?.id!==t.id||!q(a??Te())||a?.text===o.text)&&(zt(e,t,F.current,r),ie.current={id:t.id,text:t.text})};a(),window.requestAnimationFrame(a);for(let e of[0,50,150,300,600])window.setTimeout(a,e);e.querySelector(`agent-interface`)?.updateComplete?.then(a)};return(0,x.useEffect)(()=>{if(!N.current||!e)return;let t=new l;R(!1);let n=e.sessionId,r=B.current,i=he.current,a=!1,o,s=!1,c=e.state.isStreaming,f=!1,p=Fe({panel:t});be.current=p;let m=Ie({panel:t,getCustomCommands:()=>re.current,getComposerDrafts:()=>F.current,sessionId:r,setComposerDrafts:e=>{F.current=e},restoreDraftIntoComposer:e=>{zt(t,e,F.current,r),V(r,e,i)}}),h=We({panel:t,restoreDraftIntoComposer:e=>{zt(t,e,F.current,r),V(r,e,i)}}),g=et({panel:t,getSystemPrompt:()=>e.state.systemPrompt,getMessages:()=>e.state.messages,getEffectiveMessages:()=>di(e),getContextWindow:()=>e.state.model?.contextWindow??0,getTools:()=>e.state.tools,getMaxTokens:()=>e.state.model?.maxTokens,getServerContextUsage:()=>e.state.contextUsage??null,getGitBranch:()=>H.current.gitBranch,onGitBranchClick:()=>H.current.onOpenWorkspaceGitChanges?.(),renderInline:!1,onDisplayChange:t=>H.current.onContextUsageDisplayChange?.(e.sessionId,t)}),_=e=>{s=!1;let n=t.querySelector(`message-editor`),a={text:e,attachments:n?.attachments?[...n.attachments]:[]};q(a)?F.current.set(r,a):F.current.delete(r),V(r,a,i)},v=e=>{s=!1;let n=t.querySelector(`message-editor`),a=n?.querySelector(`textarea`),o={text:n?.value??a?.value??``,attachments:e?[...e]:[]};q(o)?F.current.set(r,o):F.current.delete(r),V(r,o,i);let c=t.querySelector(`agent-interface`);c?.requestUpdate?.(),window.requestAnimationFrame(()=>U.current?.()),c?.updateComplete?.then(()=>U.current?.())},b=()=>{e.state.isStreaming?t.dataset.quickforgeAgentStreaming=`true`:delete t.dataset.quickforgeAgentStreaming},x=()=>{if(a||!t.isConnected)return;b();let n=H.current,r=fi(e.state.messages);if(r!==se.current){se.current=r;let t=Jr(e.state.messages),i=JSON.stringify(t.map(e=>[e.source,e.path,e.command,e.outputFile,e.confidence,e.preview,e.defaultPreview,e.addedLines,e.removedLines]));i!==oe.current&&(oe.current=i,n.onArtifactsChange?.(t))}try{Er({panel:t,getMessages:()=>e.state.messages,isStreaming:()=>e.state.isStreaming,onCopyAnswer:n.onCopyAnswer,onRollbackFromMessage:n.onRollbackFromMessage,onRetryFromMessage:n.onRetryFromMessage,onForkFromMessage:n.onForkFromMessage,onOpenLocalFilePath:n.onOpenLocalFilePath,disableFork:n.disableFork,readOnly:n.readOnly,enableTerminalCommandActions:!n.readOnly,rollbackConfirmTitle:n.rollbackConfirmTitle,rollbackConfirmDescription:n.rollbackConfirmDescription}),en({panel:t,getMessages:()=>e.state.messages,getContextCompaction:()=>e.state.contextCompaction??null}),Fr({panel:t,getMessages:()=>e.state.messages,isStreaming:()=>e.state.isStreaming,isActive:c})}catch{}try{Ir({panel:t,isStreaming:()=>e.state.isStreaming,abort:()=>e.abort(),agentAccessMode:n.agentAccessMode,planMode:n.planMode,workspaceToolsEnabled:n.workspaceToolsEnabled,readOnly:n.readOnly,allowModelControls:n.allowModelControls,onAccessModeChange:n.onAccessModeChange,onTogglePlanMode:n.onTogglePlanMode,onInput:_,onFilesChange:v,removeCommandSuggestions:m.remove,updateCommandSuggestions:m.update,setupCommandTextareaHandler:m.setupTextareaHandler,removeCapabilitySuggestions:h.remove,updateCapabilitySuggestions:h.update,setupCapabilityTextareaHandler:h.setupTextareaHandler,insertBuiltinPluginMention:h.insertBuiltinPluginMention,onBeforeSend:t=>{let n=h.consumeSelectedCapabilities(t);e.setNextPromptCapabilities?.(n)}})}catch{}let i=W.current??(()=>{let t=e.state.pendingToolApproval;return t?{...t,sessionId:e.sessionId}:null})();if(i&&i.sessionId===e.sessionId&&typeof i.toolCallId==`string`&&typeof i.toolName==`string`){let n=i.toolCallId;Kt({panel:t,onApprove:async()=>{await H.current.onApproveToolCall(n),W.current=null,e.state.pendingToolApproval=null,qt(t)},onReject:async()=>{await H.current.onRejectToolCall(n),W.current=null,e.state.pendingToolApproval=null,qt(t)}},i.toolName,n,i.args,i.source)}else{let n=G.current??(()=>{let t=e.state.pendingAutoCompactApproval;return t?{...t,sessionId:e.sessionId}:null})();if(n&&n.sessionId===e.sessionId){let r=n.approvalId;Kt({panel:t,onApprove:async()=>{await H.current.onApproveAutoCompact?.(r),G.current=null,e.state.pendingAutoCompactApproval=null,qt(t)},onReject:async()=>{await H.current.onRejectAutoCompact?.(r),G.current=null,e.state.pendingAutoCompactApproval=null,qt(t)}},y(`contextManagement`),r,{percent:n.usage?.percent??0,threshold:n.thresholdPercent??0,keepRecentTurns:n.keepRecentTurns??3,summary:y(`autoCompactApprovalWaiting`,{percent:n.usage?.percent??0,threshold:n.thresholdPercent??0}),description:y(`autoCompactApprovalPreview`,{keepRecentTurns:n.keepRecentTurns??3})})}else qt(t)}g.update(),p.setup(),p.isEnabled&&p.scheduleScrollToBottom()},S=!1,C,w=!1,T,E=()=>{T===void 0&&(T=window.requestAnimationFrame(()=>{T=void 0,w=!1}))},D=()=>{if(!a){w=!0;try{x()}finally{E()}}},O=()=>{S||(S=!0,C=window.requestAnimationFrame(()=>{C=void 0,S=!1,D()}))};ye.current=D;let k=()=>{f||(f=!0,window.requestAnimationFrame(()=>{if(f=!1,a)return;b();let e=t.querySelector(`agent-interface`);e?.requestUpdate?.(),U.current?.(),e?.updateComplete?.then(()=>U.current?.()),p.isEnabled&&p.scheduleScrollToBottom()}))};U.current=O,t.setAgent(e,{onApiKeyRequired:H.current.bypassClientApiKeyCheck?async()=>!0:e=>u.prompt(e),onBeforeSend:()=>{ce.current.invalidate();let e=ne.current;e&&ae.current.add(e.id),z(),s=!0,m.remove(),F.current.delete(r),ci(r).catch(e=>d.error(`Failed to clear composer draft:`,e)),p.enable()},onModelSelect:H.current.onModelSelect,toolsFactory:()=>Ce(e.state.tools)}).then(()=>{if(a)return;let e=ne.current,i=ce.current.version(),s=o=>{a||!ce.current.isCurrent(i)||(e&&P.current!==e.id?(P.current=e.id,xe(t,e,n,r)):zt(t,o??F.current.get(r)??Te(),F.current,r))};if(e&&P.current!==e.id)s();else{let e=F.current.get(r);e?s(e):oi(r).then(e=>s(e)).catch(e=>d.error(`Failed to load composer draft:`,e))}o=new MutationObserver(()=>{w||O()}),o.observe(t,{childList:!0,subtree:!0}),window.requestAnimationFrame(()=>{a||D()})}),N.current.replaceChildren(t);let A=e.subscribe(i=>{if(i.type===`agent_start`&&(c=!0,b(),U.current?.(),p.enable(),W.current?.sessionId===e.sessionId&&(W.current=null),G.current?.sessionId===e.sessionId&&(G.current=null)),i.type===`message_start`||i.type===`message_update`||i.type===`message_end`||i.type===`turn_end`||i.type===`agent_end`){b();let e=i.message;(i.type===`message_update`||e?.role===`assistant`)&&(c=!1),U.current?.(),p.isEnabled&&p.scheduleScrollToBottom()}if(i.type===`messages_replaced`){let e=ne.current;e&&P.current===e.id&&xe(t,e,n,r)}let a=i.type;if(a===`tool_execution_start`||a===`tool_execution_end`){b();let e=t.querySelector(`agent-interface`);e?.requestUpdate?.(),U.current?.(),window.requestAnimationFrame(()=>U.current?.()),e?.updateComplete?.then(()=>U.current?.()),p.isEnabled&&p.scheduleScrollToBottom()}if(a===`tool_execution_update`&&k(),i.type===`agent_end`&&(c=!1,b(),U.current?.(),W.current?.sessionId===e.sessionId&&(W.current=null,U.current?.()),G.current?.sessionId===e.sessionId&&(G.current=null,U.current?.())),a===`auto_compact_completed`||a===`messages_replaced`){let e=t.querySelector(`agent-interface`);e?.requestUpdate?.(),U.current?.(),window.requestAnimationFrame(()=>U.current?.()),e?.updateComplete?.then(()=>U.current?.())}if(a===`auto_compact_failed`&&d.warn(y(`autoCompactFailed`)),i.type===`tool_approval_required`){let e=i;W.current={toolCallId:e.toolCallId,toolName:e.toolName,args:e.args,sessionId:e.sessionId,source:e.source},U.current?.()}if(i.type===`auto_compact_approval_required`){let e=i;G.current={approvalId:e.approvalId,usage:e.usage,thresholdPercent:e.thresholdPercent,keepRecentTurns:e.keepRecentTurns,sessionId:e.sessionId},U.current?.()}});return()=>{s?(z(),F.current.delete(r),ci(r).catch(e=>d.error(`Failed to clear composer draft:`,e))):(Rt(t,F.current,r),_e(t,r,i)),m.remove(),m.cleanupTextareaHandler(),h.remove(),h.cleanupTextareaHandler(),a=!0,p.cleanup(),be.current=null,A(),o?.disconnect(),C!==void 0&&window.cancelAnimationFrame(C),T!==void 0&&window.cancelAnimationFrame(T),ye.current=null,t.remove()}},[e,z,_e,V]),(0,x.useEffect)(()=>{let e=N.current;e&&(e.classList.toggle(`quickforge-chat-panel-empty-host`,M),e.dataset.quickforgeEmptyChat=M?`true`:`false`)},[M]),(0,x.useEffect)(()=>{ye.current?.(),(N.current?.querySelector(`agent-interface`))?.requestUpdate?.()},[r,L,i,le,O,k,j,n]),(0,x.useEffect)(()=>{let t=ne.current;if(!t||!N.current)return;let n=e?.sessionId??``;if(t.sessionId&&t.sessionId!==n)return;let r=N.current.querySelector(`pi-chat-panel`);r&&(P.current=t.id,xe(r,t,n,B.current,!0))},[D,e]),(0,ui.jsx)(`div`,{ref:N,className:`min-h-0 flex-1 overflow-hidden`})}export{pi as ChatPanelHost};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Ot as t,Rt as n,b as r,d as i,i as a,r as o,x as s,z as c}from"./icons-DHoaB5uq.js";import{n as l}from"./react-vendor-BR9MG2D-.js";import{rt as u,st as d}from"./index-DeUvsbzW.js";import{n as f,r as p,t as m}from"./plugin-api-UKg_cgSG.js";var h=e(n(),1),g=l();function _(e){return e===`loaded`?`quickforge-settings-badge-success`:e===`error`?`quickforge-settings-badge-danger`:`quickforge-settings-badge-muted`}function v(e){return e===`loaded`?d(`pluginStatusLoaded`):e===`disabled`?d(`pluginStatusDisabled`):e===`error`?d(`pluginStatusError`):e}function y(e){switch(e){case`openai-documents`:return{label:d(`pluginOpenaiDocumentsName`),description:d(`pluginOpenaiDocumentsDescription`)};case`openai-spreadsheets`:return{label:d(`pluginOpenaiSpreadsheetsName`),description:d(`pluginOpenaiSpreadsheetsDescription`)};case`openai-presentations`:return{label:d(`pluginOpenaiPresentationsName`),description:d(`pluginOpenaiPresentationsDescription`)};default:return null}}function b(e){return y(e.name)?.label||(e.displayName||e.name).replace(/^OpenAI\s+/i,``)}function x(e){return y(e.name)?.description||e.description||d(`noDescription`)}function S(e){return(e.label||e.name||e.quickForgeName).replace(/^OpenAI\s+/i,``)}function C({onChanged:e}){let[n,l]=(0,h.useState)(null),[y,C]=(0,h.useState)(!0),[w,T]=(0,h.useState)(null),[E,D]=(0,h.useState)(()=>new Set),[O,k]=(0,h.useState)(null),A=(0,h.useCallback)(async(t=`load`)=>{k(null),C(!0);try{l(t===`reload`?await f():await m()),t===`reload`&&e?.()}catch(e){k(e instanceof Error?e.message:d(`pluginsLoadFailed`))}finally{C(!1)}},[e]);(0,h.useEffect)(()=>{let e=!1;return m().then(t=>{e||l(t)}).catch(t=>{e||k(t instanceof Error?t.message:d(`pluginsLoadFailed`))}).finally(()=>{e||C(!1)}),()=>{e=!0}},[]);let j=(0,h.useMemo)(()=>{let e=n?.plugins||[];return{total:e.length,enabled:e.filter(e=>e.enabled).length,tools:e.reduce((e,t)=>e+t.tools.length,0)}},[n]),M=(0,h.useMemo)(()=>n?.plugins||[],[n]),N=(0,h.useCallback)(e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),P=async(t,n)=>{T(t),k(null);try{l(await p(t,n)),e?.()}catch(e){k(e instanceof Error?e.message:d(`pluginsSaveFailed`))}finally{T(null)}};return(0,g.jsx)(`div`,{className:`quickforge-settings-stack`,children:(0,g.jsxs)(`section`,{className:`quickforge-settings-section`,"aria-label":d(`plugins`),children:[(0,g.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,g.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,g.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,g.jsx)(s,{className:`size-4 text-primary`}),d(`plugins`)]}),(0,g.jsx)(`div`,{className:`quickforge-settings-row-description`,children:d(`pluginsDescription`)}),(0,g.jsxs)(`div`,{className:`quickforge-settings-meta`,children:[(0,g.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:d(`pluginsCount`,j)}),(0,g.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-info`,children:d(`pluginToolsCount`,{count:j.tools})})]})]}),(0,g.jsxs)(`button`,{className:`quickforge-settings-button quickforge-settings-button-secondary`,type:`button`,onClick:()=>void A(`reload`),disabled:y,children:[y?(0,g.jsx)(c,{className:`mr-2 size-4 animate-spin`}):(0,g.jsx)(r,{className:`mr-2 size-4`}),d(`pluginsReload`)]})]}),O?(0,g.jsx)(`div`,{className:`quickforge-settings-alert quickforge-settings-warning-attached`,children:O}):null,n?.errors?.length?(0,g.jsxs)(`div`,{className:`quickforge-settings-warning quickforge-settings-warning-attached`,children:[(0,g.jsxs)(`div`,{className:`mb-2 inline-flex items-center gap-2 font-medium`,children:[(0,g.jsx)(a,{className:`size-4`}),d(`pluginDiscoveryErrors`)]}),n.errors.map((e,t)=>(0,g.jsxs)(`div`,{className:`break-all text-sm`,children:[(0,g.jsx)(`code`,{className:`quickforge-settings-command-name`,children:e.dir}),`: `,e.error]},`${e.dir}-${t}`))]}):null,y&&!n?(0,g.jsxs)(`div`,{className:`quickforge-settings-empty-row inline-flex items-center gap-2`,children:[(0,g.jsx)(c,{className:`size-4 animate-spin`}),d(`loadingPlugins`)]}):null,!y&&n&&n.plugins.length===0?(0,g.jsxs)(`div`,{className:`quickforge-settings-empty-row`,children:[(0,g.jsx)(`div`,{className:`quickforge-settings-row-title`,children:d(`noPlugins`)}),(0,g.jsx)(`div`,{className:`quickforge-settings-row-description`,children:d(`noPluginsDescription`)}),(0,g.jsx)(`div`,{className:`quickforge-settings-meta`,children:(n.searchPaths||[]).map(e=>(0,g.jsx)(`code`,{className:`quickforge-settings-command-name`,children:e},e))})]}):null,M.map(e=>{let n=E.has(e.name);return(0,g.jsxs)(`article`,{className:`quickforge-settings-list-item quickforge-settings-list-item--column`,children:[(0,g.jsxs)(`div`,{className:`quickforge-settings-list-item-header`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`quickforge-settings-expand-toggle`,onClick:()=>N(e.name),"aria-expanded":n,children:[(0,g.jsx)(t,{className:u(`quickforge-settings-expand-chevron size-4`,n&&`rotate-90`)}),(0,g.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,g.jsxs)(`span`,{className:`quickforge-settings-row-title`,children:[b(e),(0,g.jsxs)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:[`v`,e.version]}),(0,g.jsx)(`span`,{className:u(`quickforge-settings-badge`,_(e.status)),children:v(e.status)})]}),(0,g.jsx)(`span`,{className:`quickforge-settings-row-description`,children:x(e)}),e.error?(0,g.jsx)(`span`,{className:`quickforge-settings-alert mt-3 block`,children:e.error}):null,(0,g.jsxs)(`span`,{className:`quickforge-settings-meta`,children:[(0,g.jsxs)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:[(0,g.jsx)(o,{className:`size-3`}),d(`pluginToolsCount`,{count:e.tools.length})]}),(0,g.jsxs)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:[(0,g.jsx)(i,{className:`size-3`}),d(`pluginPermissionsCount`,{count:e.permissions.length})]}),(0,g.jsx)(`span`,{className:u(`quickforge-settings-badge`,e.enabled?`quickforge-settings-badge-success`:`quickforge-settings-badge-muted`),children:e.enabled?d(`enabled`):d(`disabled`)})]})]})]}),(0,g.jsx)(`div`,{className:`quickforge-settings-list-item-actions`,onClick:e=>e.stopPropagation(),children:(0,g.jsxs)(`label`,{className:`quickforge-settings-switch`,"aria-disabled":w===e.name?`true`:`false`,children:[(0,g.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:w===e.name,onChange:t=>void P(e.name,t.target.checked)}),(0,g.jsx)(`span`,{"aria-hidden":`true`})]})})]}),n?(0,g.jsxs)(`div`,{className:`border-t border-border/60`,children:[(0,g.jsx)(`div`,{className:`quickforge-settings-row quickforge-settings-row-top`,children:(0,g.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,g.jsx)(o,{className:`size-4 text-muted-foreground`}),d(`pluginTools`)]})}),(0,g.jsx)(`div`,{className:`quickforge-settings-nested-list`,children:e.tools.length?e.tools.map(e=>(0,g.jsx)(`div`,{className:`quickforge-settings-subrow`,children:(0,g.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,g.jsx)(`div`,{className:`quickforge-settings-row-title`,children:S(e)}),e.description?(0,g.jsx)(`div`,{className:`quickforge-settings-row-description`,children:e.description}):null]})},e.quickForgeName)):(0,g.jsx)(`div`,{className:`quickforge-settings-empty-row`,children:d(`pluginNoTools`)})}),(0,g.jsx)(`div`,{className:`quickforge-settings-row quickforge-settings-row-top`,children:(0,g.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,g.jsx)(i,{className:`size-4 text-muted-foreground`}),d(`pluginPermissions`)]})}),(0,g.jsxs)(`div`,{className:`p-4`,children:[e.permissions.length?(0,g.jsx)(`div`,{className:`quickforge-settings-meta`,children:e.permissions.map(e=>(0,g.jsx)(`code`,{className:`quickforge-settings-command-name`,children:e},e))}):(0,g.jsx)(`div`,{className:`quickforge-settings-empty-row`,children:d(`pluginNoPermissions`)}),(0,g.jsx)(`div`,{className:`quickforge-settings-row-description mt-3`,children:d(`pluginTrustedNotice`)})]})]}):null]},e.name)})]})})}export{C as PluginsPage};
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Ot as t,Rt as n,b as r,d as i,i as a,r as o,x as s,z as c}from"./icons-DHoaB5uq.js";import{n as l}from"./react-vendor-BR9MG2D-.js";import{rt as u,st as d}from"./index-CZb_mGGF.js";import{n as f,r as p,t as m}from"./plugin-api-Ds5xGIL7.js";var h=e(n(),1),g=l();function _(e){return e===`loaded`?`quickforge-settings-badge-success`:e===`error`?`quickforge-settings-badge-danger`:`quickforge-settings-badge-muted`}function v(e){return e===`loaded`?d(`pluginStatusLoaded`):e===`disabled`?d(`pluginStatusDisabled`):e===`error`?d(`pluginStatusError`):e}function y(e){switch(e){case`openai-documents`:return{label:d(`pluginOpenaiDocumentsName`),description:d(`pluginOpenaiDocumentsDescription`)};case`openai-spreadsheets`:return{label:d(`pluginOpenaiSpreadsheetsName`),description:d(`pluginOpenaiSpreadsheetsDescription`)};case`openai-presentations`:return{label:d(`pluginOpenaiPresentationsName`),description:d(`pluginOpenaiPresentationsDescription`)};default:return null}}function b(e){return y(e.name)?.label||(e.displayName||e.name).replace(/^OpenAI\s+/i,``)}function x(e){return y(e.name)?.description||e.description||d(`noDescription`)}function S(e){return(e.label||e.name||e.quickForgeName).replace(/^OpenAI\s+/i,``)}function C({onChanged:e}){let[n,l]=(0,h.useState)(null),[y,C]=(0,h.useState)(!0),[w,T]=(0,h.useState)(null),[E,D]=(0,h.useState)(()=>new Set),[O,k]=(0,h.useState)(null),A=(0,h.useCallback)(async(t=`load`)=>{k(null),C(!0);try{l(t===`reload`?await f():await m()),t===`reload`&&e?.()}catch(e){k(e instanceof Error?e.message:d(`pluginsLoadFailed`))}finally{C(!1)}},[e]);(0,h.useEffect)(()=>{let e=!1;return m().then(t=>{e||l(t)}).catch(t=>{e||k(t instanceof Error?t.message:d(`pluginsLoadFailed`))}).finally(()=>{e||C(!1)}),()=>{e=!0}},[]);let j=(0,h.useMemo)(()=>{let e=n?.plugins||[];return{total:e.length,enabled:e.filter(e=>e.enabled).length,tools:e.reduce((e,t)=>e+t.tools.length,0)}},[n]),M=(0,h.useMemo)(()=>n?.plugins||[],[n]),N=(0,h.useCallback)(e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),P=async(t,n)=>{T(t),k(null);try{l(await p(t,n)),e?.()}catch(e){k(e instanceof Error?e.message:d(`pluginsSaveFailed`))}finally{T(null)}};return(0,g.jsx)(`div`,{className:`quickforge-settings-stack`,children:(0,g.jsxs)(`section`,{className:`quickforge-settings-section`,"aria-label":d(`plugins`),children:[(0,g.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,g.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,g.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,g.jsx)(s,{className:`size-4 text-primary`}),d(`plugins`)]}),(0,g.jsx)(`div`,{className:`quickforge-settings-row-description`,children:d(`pluginsDescription`)}),(0,g.jsxs)(`div`,{className:`quickforge-settings-meta`,children:[(0,g.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:d(`pluginsCount`,j)}),(0,g.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-info`,children:d(`pluginToolsCount`,{count:j.tools})})]})]}),(0,g.jsxs)(`button`,{className:`quickforge-settings-button quickforge-settings-button-secondary`,type:`button`,onClick:()=>void A(`reload`),disabled:y,children:[y?(0,g.jsx)(c,{className:`mr-2 size-4 animate-spin`}):(0,g.jsx)(r,{className:`mr-2 size-4`}),d(`pluginsReload`)]})]}),O?(0,g.jsx)(`div`,{className:`quickforge-settings-alert quickforge-settings-warning-attached`,children:O}):null,n?.errors?.length?(0,g.jsxs)(`div`,{className:`quickforge-settings-warning quickforge-settings-warning-attached`,children:[(0,g.jsxs)(`div`,{className:`mb-2 inline-flex items-center gap-2 font-medium`,children:[(0,g.jsx)(a,{className:`size-4`}),d(`pluginDiscoveryErrors`)]}),n.errors.map((e,t)=>(0,g.jsxs)(`div`,{className:`break-all text-sm`,children:[(0,g.jsx)(`code`,{className:`quickforge-settings-command-name`,children:e.dir}),`: `,e.error]},`${e.dir}-${t}`))]}):null,y&&!n?(0,g.jsxs)(`div`,{className:`quickforge-settings-empty-row inline-flex items-center gap-2`,children:[(0,g.jsx)(c,{className:`size-4 animate-spin`}),d(`loadingPlugins`)]}):null,!y&&n&&n.plugins.length===0?(0,g.jsxs)(`div`,{className:`quickforge-settings-empty-row`,children:[(0,g.jsx)(`div`,{className:`quickforge-settings-row-title`,children:d(`noPlugins`)}),(0,g.jsx)(`div`,{className:`quickforge-settings-row-description`,children:d(`noPluginsDescription`)}),(0,g.jsx)(`div`,{className:`quickforge-settings-meta`,children:(n.searchPaths||[]).map(e=>(0,g.jsx)(`code`,{className:`quickforge-settings-command-name`,children:e},e))})]}):null,M.map(e=>{let n=E.has(e.name);return(0,g.jsxs)(`article`,{className:`quickforge-settings-list-item quickforge-settings-list-item--column`,children:[(0,g.jsxs)(`div`,{className:`quickforge-settings-list-item-header`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`quickforge-settings-expand-toggle`,onClick:()=>N(e.name),"aria-expanded":n,children:[(0,g.jsx)(t,{className:u(`quickforge-settings-expand-chevron size-4`,n&&`rotate-90`)}),(0,g.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,g.jsxs)(`span`,{className:`quickforge-settings-row-title`,children:[b(e),(0,g.jsxs)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:[`v`,e.version]}),(0,g.jsx)(`span`,{className:u(`quickforge-settings-badge`,_(e.status)),children:v(e.status)})]}),(0,g.jsx)(`span`,{className:`quickforge-settings-row-description`,children:x(e)}),e.error?(0,g.jsx)(`span`,{className:`quickforge-settings-alert mt-3 block`,children:e.error}):null,(0,g.jsxs)(`span`,{className:`quickforge-settings-meta`,children:[(0,g.jsxs)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:[(0,g.jsx)(o,{className:`size-3`}),d(`pluginToolsCount`,{count:e.tools.length})]}),(0,g.jsxs)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:[(0,g.jsx)(i,{className:`size-3`}),d(`pluginPermissionsCount`,{count:e.permissions.length})]}),(0,g.jsx)(`span`,{className:u(`quickforge-settings-badge`,e.enabled?`quickforge-settings-badge-success`:`quickforge-settings-badge-muted`),children:e.enabled?d(`enabled`):d(`disabled`)})]})]})]}),(0,g.jsx)(`div`,{className:`quickforge-settings-list-item-actions`,onClick:e=>e.stopPropagation(),children:(0,g.jsxs)(`label`,{className:`quickforge-settings-switch`,"aria-disabled":w===e.name?`true`:`false`,children:[(0,g.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:w===e.name,onChange:t=>void P(e.name,t.target.checked)}),(0,g.jsx)(`span`,{"aria-hidden":`true`})]})})]}),n?(0,g.jsxs)(`div`,{className:`border-t border-border/60`,children:[(0,g.jsx)(`div`,{className:`quickforge-settings-row quickforge-settings-row-top`,children:(0,g.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,g.jsx)(o,{className:`size-4 text-muted-foreground`}),d(`pluginTools`)]})}),(0,g.jsx)(`div`,{className:`quickforge-settings-nested-list`,children:e.tools.length?e.tools.map(e=>(0,g.jsx)(`div`,{className:`quickforge-settings-subrow`,children:(0,g.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,g.jsx)(`div`,{className:`quickforge-settings-row-title`,children:S(e)}),e.description?(0,g.jsx)(`div`,{className:`quickforge-settings-row-description`,children:e.description}):null]})},e.quickForgeName)):(0,g.jsx)(`div`,{className:`quickforge-settings-empty-row`,children:d(`pluginNoTools`)})}),(0,g.jsx)(`div`,{className:`quickforge-settings-row quickforge-settings-row-top`,children:(0,g.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,g.jsx)(i,{className:`size-4 text-muted-foreground`}),d(`pluginPermissions`)]})}),(0,g.jsxs)(`div`,{className:`p-4`,children:[e.permissions.length?(0,g.jsx)(`div`,{className:`quickforge-settings-meta`,children:e.permissions.map(e=>(0,g.jsx)(`code`,{className:`quickforge-settings-command-name`,children:e},e))}):(0,g.jsx)(`div`,{className:`quickforge-settings-empty-row`,children:d(`pluginNoPermissions`)}),(0,g.jsx)(`div`,{className:`quickforge-settings-row-description mt-3`,children:d(`pluginTrustedNotice`)})]})]}):null]},e.name)})]})})}export{C as PluginsPage};
@@ -1,2 +1,2 @@
1
- import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{E as t,Ft as n,Mt as r,Nt as i,Rt as a,_ as ee,a as te,l as ne,lt as re,q as ie,st as ae,t as oe,xt as se,yt as ce}from"./icons-DHoaB5uq.js";import{n as o}from"./react-vendor-BR9MG2D-.js";import{F as le,G as ue,J as de,K as fe,Y as pe,nt as s,q as me,rt as c,st as l,tt as he}from"./index-DeUvsbzW.js";var u=e(a(),1),d=o(),ge=[{value:`off`,label:()=>l(`thinkingOff`)},{value:`low`,label:()=>l(`thinkingLow`)},{value:`medium`,label:()=>l(`thinkingMedium`)},{value:`high`,label:()=>l(`thinkingHigh`)},{value:`xhigh`,label:()=>l(`thinkingXHigh`)}];function _e(e){return`${e.provider} / ${e.id}`}function ve(e,t){return!!(e&&t&&e.api===t.api&&e.provider===t.provider&&e.id===t.id)}function f(e){return String(e).padStart(2,`0`)}function p(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:`${t.getFullYear()}-${f(t.getMonth()+1)}-${f(t.getDate())} ${f(t.getHours())}:${f(t.getMinutes())}`}function ye(e,t=20){let n=String(e||``).trim();return n.length>t?`${n.slice(0,t)}...`:n}function be(){return{scheduleText:``,title:``,instruction:``,cronExpression:``,scheduleRule:``,nextRunAt:``,enabled:!0,agentId:``,executionMode:`serial`}}function m(){return{taskId:``,status:``,trigger:``,keyword:``,startedFrom:``,startedTo:``,page:1,pageSize:10}}function xe(e){return{scheduleText:[e.scheduleRule,e.instruction].filter(Boolean).join(`
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{E as t,Ft as n,Mt as r,Nt as i,Rt as a,_ as ee,a as te,l as ne,lt as re,q as ie,st as ae,t as oe,xt as se,yt as ce}from"./icons-DHoaB5uq.js";import{n as o}from"./react-vendor-BR9MG2D-.js";import{F as le,G as ue,J as de,K as fe,Y as pe,nt as s,q as me,rt as c,st as l,tt as he}from"./index-CZb_mGGF.js";var u=e(a(),1),d=o(),ge=[{value:`off`,label:()=>l(`thinkingOff`)},{value:`low`,label:()=>l(`thinkingLow`)},{value:`medium`,label:()=>l(`thinkingMedium`)},{value:`high`,label:()=>l(`thinkingHigh`)},{value:`xhigh`,label:()=>l(`thinkingXHigh`)}];function _e(e){return`${e.provider} / ${e.id}`}function ve(e,t){return!!(e&&t&&e.api===t.api&&e.provider===t.provider&&e.id===t.id)}function f(e){return String(e).padStart(2,`0`)}function p(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:`${t.getFullYear()}-${f(t.getMonth()+1)}-${f(t.getDate())} ${f(t.getHours())}:${f(t.getMinutes())}`}function ye(e,t=20){let n=String(e||``).trim();return n.length>t?`${n.slice(0,t)}...`:n}function be(){return{scheduleText:``,title:``,instruction:``,cronExpression:``,scheduleRule:``,nextRunAt:``,enabled:!0,agentId:``,executionMode:`serial`}}function m(){return{taskId:``,status:``,trigger:``,keyword:``,startedFrom:``,startedTo:``,page:1,pageSize:10}}function xe(e){return{scheduleText:[e.scheduleRule,e.instruction].filter(Boolean).join(`
2
2
  `),title:e.title,instruction:e.instruction,cronExpression:e.cronExpression??``,scheduleRule:e.scheduleRule,nextRunAt:e.nextRunAt,enabled:e.status!==`paused`,agentId:e.agentId??``,executionMode:e.executionMode??`serial`}}function Se(e,t){return{...t,title:e.title,instruction:e.instruction,cronExpression:e.cronExpression??``,scheduleRule:e.scheduleRule,nextRunAt:e.nextRunAt,enabled:t.enabled}}function Ce(e){return{title:e.title.trim(),instruction:e.instruction.trim(),scheduleType:`cron`,scheduleRule:e.scheduleRule.trim()||e.cronExpression.trim(),cronExpression:e.cronExpression.trim(),nextRunAt:e.nextRunAt,enabled:e.enabled,agentId:e.agentId||null,executionMode:e.executionMode}}function h(e){return!!(e.currentRunId||e.currentRunIds?.length)}function we(e){return(e.executionMode??`serial`)===`parallel`||!h(e)}function Te(e){return l(e===`parallel`?`taskExecutionModeParallel`:`taskExecutionModeSerial`)}function Ee(e){return!!(e.title.trim()&&e.instruction.trim()&&e.cronExpression.trim())}function De(e){return l(e===`enabled`?`taskEnabled`:e===`running`?`taskRunning`:e===`paused`?`taskPaused`:e===`completed`?`taskFinished`:e===`success`?`executionSuccess`:`taskFailed`)}function Oe(e){return e===`enabled`||e===`success`?`bg-emerald-500/10 text-emerald-700`:e===`running`?`bg-blue-500/10 text-blue-700`:e===`paused`?`bg-amber-500/10 text-amber-700`:`bg-muted text-muted-foreground`}async function g(e,t){let n=await fetch(e,{...t,headers:{"content-type":`application/json`,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`请求失败`);return r}function _({onOpenSession:e}){let[a,o]=(0,u.useState)([]),[f,_]=(0,u.useState)(`tasks`),[v,y]=(0,u.useState)(()=>be()),[b,ke]=(0,u.useState)(null),[x,S]=(0,u.useState)(null),[C,w]=(0,u.useState)(null),[T,E]=(0,u.useState)(!1),[D,O]=(0,u.useState)(null),[Ae,k]=(0,u.useState)(``),[A,j]=(0,u.useState)(!1),[M,N]=(0,u.useState)(``),[P,je]=(0,u.useState)([]),[F,I]=(0,u.useState)(),[L,R]=(0,u.useState)(`off`),[z,Me]=(0,u.useState)([]),[Ne,B]=(0,u.useState)(``),[V,H]=(0,u.useState)(()=>m()),[U,W]=(0,u.useState)(()=>m()),[G,Pe]=(0,u.useState)({runs:[],total:0,page:1,pageSize:10}),[Fe,Ie]=(0,u.useState)(!1),[Le,Re]=(0,u.useState)(null),[ze,Be]=(0,u.useState)([]),Ve=z[0]?.id??``;(0,u.useEffect)(()=>{if(!C)return;let e=()=>w(null);return window.addEventListener(`click`,e),window.addEventListener(`blur`,e),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`blur`,e)}},[C]);async function He(){o((await g(`/api/scheduled-tasks`)).tasks)}async function K(e=U){Ie(!0),N(``);try{let t=new URLSearchParams;t.set(`page`,String(e.page)),t.set(`pageSize`,String(e.pageSize)),e.taskId&&t.set(`taskId`,e.taskId),e.status&&t.set(`status`,e.status),e.trigger&&t.set(`trigger`,e.trigger),e.keyword.trim()&&t.set(`keyword`,e.keyword.trim()),e.startedFrom&&t.set(`startedFrom`,e.startedFrom),e.startedTo&&t.set(`startedTo`,e.startedTo),Pe(await g(`/api/scheduled-tasks/runs?${t.toString()}`))}catch(e){N(e instanceof Error?e.message:l(`requestFailed`))}finally{Ie(!1)}}(0,u.useEffect)(()=>{let e=!1;async function t(){try{let t=await g(`/api/project`);if(e)return;Me(t.projects??[])}catch{}}return t(),()=>{e=!0}},[]),(0,u.useEffect)(()=>{let e=!1;async function t(){try{let t=await me(),n=await fe(t),r=await de(t),i=r.model??await pe(t)??n[0];if(e)return;je(n),I(i),R(r.thinkingLevel??ue(i))}catch(t){e||N(t instanceof Error?t.message:l(`requestFailed`))}}return t(),()=>{e=!0}},[]),(0,u.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await g(`/api/scheduled-tasks`);e||o(t.tasks)}catch(t){e||N(t instanceof Error?t.message:l(`requestFailed`))}};t();let n=window.setInterval(t,10*1e3);return()=>{e=!0,window.clearInterval(n)}},[]),(0,u.useEffect)(()=>{let e=!1;async function t(){try{let t=await g(`/api/agent-profiles`);if(e)return;Be(t.agents)}catch(t){e||N(t instanceof Error?t.message:l(`requestFailed`))}}return t(),()=>{e=!0}},[]);let Ue=(0,u.useMemo)(()=>a.find(e=>e.id===b),[b,a]),q=(0,u.useMemo)(()=>a.find(e=>e.id===x)??null,[x,a]),We=(0,u.useMemo)(()=>a.filter(e=>e.status===`enabled`).length,[a]),J=Math.max(1,Math.ceil(G.total/G.pageSize));function Y(e){return e?ze.find(t=>t.id===e||t.name===e)?.label??e:l(`defaultAgent`)}function X(e,t){y(n=>({...n,[e]:t}))}function Z(e,t){H(n=>({...n,[e]:t}))}function Ge(){ke(null),B(Ve),y(be()),O(null),k(``),N(``)}function Ke(){Ge(),E(!0)}function Q(){A||(E(!1),Ge())}function qe(){let e={...V,page:1};H(e),W(e),K(e)}function Je(){let e=m();H(e),W(e),K(e)}function Ye(e){let t=Math.min(Math.max(1,e),J),n={...U,page:t};H(n),W(n),K(n)}function Xe(e){let t={...U,page:1,pageSize:e};H(t),W(t),K(t)}async function Ze(){let e=v.scheduleText.trim();if(e){j(!0),N(``);try{let t=await g(`/api/scheduled-tasks/parse`,{method:`POST`,body:JSON.stringify({instruction:e,model:F,thinkingLevel:L})});if(t.needMoreInfo||!t.task){k(t.question||`请补充任务信息。`),O(null);return}let n=t.task;k(``),O(n),y(e=>Se(n,e))}catch(e){N(e instanceof Error?e.message:l(`requestFailed`))}finally{j(!1)}}}async function Qe(){if(Ee(v)){j(!0),N(``);try{let e=z.find(e=>e.id===Ne),t={task:Ce(v),model:F,thinkingLevel:L,projectId:e?.id,projectName:e?.name};b?await g(`/api/scheduled-tasks/${encodeURIComponent(b)}`,{method:`PUT`,body:JSON.stringify(t)}):await g(`/api/scheduled-tasks`,{method:`POST`,body:JSON.stringify(t)}),Q(),await He(),f===`history`&&await K(U)}catch(e){N(e instanceof Error?e.message:l(`requestFailed`))}finally{j(!1)}}}function $e(e){w(null),ke(e.id),y(xe(e)),O(null),k(``),N(``),B(e.projectId??``),e.model&&I(e.model),e.thinkingLevel&&R(e.thinkingLevel),E(!0)}async function $(e,t){if(N(``),w(null),!(t===`delete`&&!await le({description:l(`confirmDeleteTask`),confirmLabel:l(`confirmDelete`),cancelLabel:l(`cancel`),variant:`destructive`})))try{t===`delete`?(await g(`/api/scheduled-tasks/${encodeURIComponent(e)}`,{method:`DELETE`}),b===e&&Q(),x===e&&S(null)):await g(`/api/scheduled-tasks/${encodeURIComponent(e)}/${t}`,{method:`POST`}),await He(),f===`history`&&await K(U)}catch(e){N(e instanceof Error?e.message:l(`requestFailed`))}}function et(t){return(0,d.jsxs)(`div`,{className:`mt-2 space-y-2 text-xs text-muted-foreground`,children:[t.sessionId?(0,d.jsx)(s,{variant:`outline`,size:`sm`,onClick:()=>e?.(t.sessionId),children:l(`viewConversation`)}):null,(0,d.jsxs)(`div`,{children:[l(`executionAgent`),t.agentLabel||Y(t.agentId)]}),t.warning?(0,d.jsx)(`div`,{className:`text-amber-600`,children:t.warning}):null,t.inputContent?(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`font-medium text-foreground`,children:l(`runInputContent`)}),(0,d.jsx)(`pre`,{className:`mt-1 max-h-32 overflow-auto whitespace-pre-wrap`,children:t.inputContent})]}):null,t.aiResult||t.result?(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`font-medium text-foreground`,children:l(`runAiResult`)}),(0,d.jsx)(`pre`,{className:`mt-1 max-h-48 overflow-auto whitespace-pre-wrap`,children:t.aiResult||t.result})]}):null,t.errorMessage?(0,d.jsx)(`div`,{className:`text-destructive`,children:t.errorMessage}):null,t.durationMs?(0,d.jsxs)(`div`,{children:[l(`runDuration`),t.durationMs,`ms`]}):null]})}return(0,d.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[(0,d.jsxs)(`div`,{className:`border-b border-border px-6 py-5`,children:[(0,d.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-3`,children:T||q?(0,d.jsxs)(s,{variant:`outline`,onClick:()=>{T?Q():S(null)},children:[(0,d.jsx)(n,{className:`mr-1 size-4`}),l(`back`)]}):(0,d.jsx)(s,{onClick:Ke,children:l(`createTask`)})}),!T&&!q?(0,d.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,d.jsxs)(`button`,{type:`button`,className:c(`rounded-full px-4 py-2 text-sm font-medium transition-colors`,f===`tasks`?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:text-foreground`),onClick:()=>_(`tasks`),children:[l(`taskListTab`),` `,(0,d.jsx)(`span`,{className:`opacity-80`,children:a.length})]}),(0,d.jsx)(`button`,{type:`button`,className:c(`rounded-full px-4 py-2 text-sm font-medium transition-colors`,f===`history`?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:text-foreground`),onClick:()=>{_(`history`),K(U)},children:l(`executionHistoryTab`)})]}):null]}),(0,d.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-6`,children:(0,d.jsx)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:T?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-5 space-y-4`,children:[(0,d.jsxs)(`h2`,{className:`inline-flex items-center gap-1.5 text-base font-semibold text-foreground`,children:[l(Ue?`editTask`:`createTask`),(0,d.jsx)(he,{label:l(`quickAiParseTask`)})]}),(0,d.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[l(`taskScheduleDescriptionLabel`),(0,d.jsx)(`textarea`,{className:`mt-1 min-h-24 w-full resize-y rounded-xl border border-input bg-background px-3 py-2 text-sm outline-none transition-colors placeholder:text-muted-foreground/65 focus:border-ring`,value:v.scheduleText,onChange:e=>X(`scheduleText`,e.target.value),placeholder:l(`taskScheduleDescriptionPlaceholder`)})]}),(0,d.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,d.jsxs)(s,{onClick:Ze,disabled:A||!F||!v.scheduleText.trim(),children:[(0,d.jsx)(ne,{className:`mr-1 size-3.5`}),l(`aiParseTask`)]}),Ae?(0,d.jsx)(`span`,{className:`text-sm text-amber-600`,children:Ae}):null]}),(0,d.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,d.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[l(`taskTitleLabel`),(0,d.jsx)(`input`,{className:`mt-1 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-ring`,value:v.title,onChange:e=>X(`title`,e.target.value),placeholder:l(`taskTitlePlaceholder`)})]}),(0,d.jsxs)(`div`,{className:`block text-sm font-medium text-foreground`,children:[l(`executionRule`),(0,d.jsx)(`div`,{className:`mt-1 flex h-10 items-center rounded-md border border-input bg-muted/20 px-3 text-sm text-muted-foreground`,children:v.scheduleRule||`-`})]}),(0,d.jsxs)(`div`,{className:`block text-sm font-medium text-foreground`,children:[`cron`,(0,d.jsx)(`div`,{className:`mt-1 flex h-10 items-center rounded-md border border-input bg-muted/20 px-3 font-mono text-sm text-muted-foreground`,children:v.cronExpression||`-`})]}),(0,d.jsxs)(`div`,{className:`block text-sm font-medium text-foreground`,children:[l(`nextExecutionTime`),(0,d.jsx)(`div`,{className:`mt-1 flex h-10 items-center rounded-md border border-input bg-muted/20 px-3 text-sm text-muted-foreground`,children:p(v.nextRunAt)})]}),(0,d.jsxs)(`label`,{className:`block text-sm font-medium text-foreground sm:col-span-2`,children:[(0,d.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[l(`taskExecutionMode`),(0,d.jsx)(he,{label:l(`taskExecutionModeHelp`)})]}),(0,d.jsxs)(`select`,{className:`mt-1 h-10 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground outline-none focus:border-ring`,value:v.executionMode,onChange:e=>X(`executionMode`,e.target.value),children:[(0,d.jsx)(`option`,{value:`serial`,children:l(`taskExecutionModeSerial`)}),(0,d.jsx)(`option`,{value:`parallel`,children:l(`taskExecutionModeParallel`)})]})]}),(0,d.jsxs)(`label`,{className:`block text-sm font-medium text-foreground sm:col-span-2`,children:[l(`promptContentLabel`),(0,d.jsx)(`textarea`,{className:`mt-1 min-h-28 w-full resize-y rounded-xl border border-input bg-background px-3 py-2 text-sm text-foreground outline-none transition-colors placeholder:text-muted-foreground/65 focus:border-ring`,value:v.instruction,onChange:e=>X(`instruction`,e.target.value),placeholder:l(`promptContentPlaceholder`)})]})]}),(0,d.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,d.jsx)(`input`,{type:`checkbox`,checked:v.enabled,onChange:e=>X(`enabled`,e.target.checked)}),l(`taskEnabledSwitch`)]}),(0,d.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-xl border border-border bg-muted/20 px-2 py-2`,children:[(0,d.jsxs)(`span`,{className:`relative inline-flex items-center`,children:[(0,d.jsx)(ne,{className:`pointer-events-none absolute left-2 size-3.5 text-muted-foreground/70`}),(0,d.jsxs)(`select`,{className:`h-8 max-w-[240px] rounded-md border border-transparent bg-transparent pl-7 pr-2 text-xs text-muted-foreground outline-none hover:bg-background focus:border-ring`,value:F?`${F.provider}\u0000${F.id}`:``,onChange:e=>{let t=P.find(t=>`${t.provider}\u0000${t.id}`===e.target.value);I(t),R(ue(t))},title:l(`taskModel`),children:[P.length===0?(0,d.jsx)(`option`,{value:``,children:l(`noModelAvailable`)}):null,P.map(e=>(0,d.jsxs)(`option`,{value:`${e.provider}\u0000${e.id}`,children:[_e(e),ve(e,F)?` ✓`:``]},`${e.provider}:${e.id}`))]})]}),(0,d.jsxs)(`span`,{className:`relative inline-flex items-center`,children:[(0,d.jsx)(r,{className:`pointer-events-none absolute left-2 size-3.5 text-muted-foreground/70`}),(0,d.jsx)(`select`,{className:`h-8 rounded-md border border-transparent bg-transparent pl-7 pr-2 text-xs text-muted-foreground outline-none hover:bg-background focus:border-ring`,value:L,onChange:e=>R(e.target.value),title:l(`taskThinking`),children:ge.map(e=>(0,d.jsx)(`option`,{value:e.value,children:e.label()},e.value))})]}),(0,d.jsxs)(`span`,{className:`relative inline-flex items-center`,children:[(0,d.jsx)(ie,{className:`pointer-events-none absolute left-2 size-3.5 text-muted-foreground/70`}),(0,d.jsxs)(`select`,{className:`h-8 max-w-[220px] rounded-md border border-transparent bg-transparent pl-7 pr-2 text-xs text-muted-foreground outline-none hover:bg-background focus:border-ring`,value:Ne,onChange:e=>B(e.target.value),title:l(`taskProjectLabel`),children:[(0,d.jsx)(`option`,{value:``,children:l(`noProjectBound`)}),z.map(e=>(0,d.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,d.jsxs)(`span`,{className:`relative inline-flex items-center`,children:[(0,d.jsx)(i,{className:`pointer-events-none absolute left-2 size-3.5 text-muted-foreground/70`}),(0,d.jsxs)(`select`,{className:`h-8 max-w-[220px] rounded-md border border-transparent bg-transparent pl-7 pr-2 text-xs text-muted-foreground outline-none hover:bg-background focus:border-ring`,value:v.agentId,onChange:e=>X(`agentId`,e.target.value),title:l(`executionAgent`),children:[(0,d.jsx)(`option`,{value:``,children:l(`defaultAgent`)}),ze.map(e=>(0,d.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})]}),D?(0,d.jsxs)(`div`,{className:`rounded-xl border border-border bg-muted/30 p-3 text-sm`,children:[(0,d.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 font-medium text-foreground`,children:[(0,d.jsx)(se,{className:`size-4 text-emerald-600`}),l(`aiParsed`)]}),(0,d.jsxs)(`div`,{className:`grid gap-2 text-muted-foreground sm:grid-cols-2`,children:[(0,d.jsxs)(`div`,{children:[l(`taskName`),(0,d.jsx)(`span`,{className:`text-foreground`,children:D.title})]}),(0,d.jsxs)(`div`,{children:[l(`executionRule`),(0,d.jsx)(`span`,{className:`text-foreground`,children:D.scheduleRule})]}),(0,d.jsxs)(`div`,{children:[`cron:`,(0,d.jsx)(`span`,{className:`font-mono text-foreground`,children:D.cronExpression??`-`})]}),(0,d.jsxs)(`div`,{children:[l(`nextExecutionTime`),(0,d.jsx)(`span`,{className:`text-foreground`,children:p(D.nextRunAt)})]}),(0,d.jsxs)(`div`,{className:`sm:col-span-2`,children:[l(`aiInstruction`),(0,d.jsx)(`span`,{className:`text-foreground`,children:D.instruction})]})]})]}):null,M?(0,d.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:M}):null]}),(0,d.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,d.jsx)(s,{variant:`outline`,onClick:Q,disabled:A,children:l(`cancel`)}),(0,d.jsx)(s,{onClick:Qe,disabled:A||!F||!Ee(v),children:l(Ue?`saveTask`:`confirmCreate`)})]})]}):q?(0,d.jsxs)(`div`,{className:`rounded-xl border border-border bg-card`,children:[(0,d.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-border px-5 py-4`,children:(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:q.title}),(0,d.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:q.scheduleRule})]})}),(0,d.jsx)(`div`,{className:`px-5 py-4`,children:(0,d.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`mb-1 font-medium text-foreground`,children:l(`taskContent`)}),(0,d.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap rounded-xl border border-border bg-muted/20 p-3 text-muted-foreground`,children:q.instruction})]}),(0,d.jsxs)(`div`,{className:`grid gap-3 text-muted-foreground sm:grid-cols-2`,children:[(0,d.jsxs)(`div`,{children:[l(`executionRule`),(0,d.jsx)(`span`,{className:`text-foreground`,children:q.scheduleRule})]}),(0,d.jsxs)(`div`,{children:[l(`taskExecutionMode`),`:`,(0,d.jsx)(`span`,{className:`text-foreground`,children:Te(q.executionMode)})]}),(0,d.jsxs)(`div`,{children:[`cron:`,(0,d.jsx)(`span`,{className:`font-mono text-foreground`,children:q.cronExpression??`-`})]}),(0,d.jsxs)(`div`,{children:[l(`lastExecution`),(0,d.jsx)(`span`,{className:`text-foreground`,children:p(q.lastRunAt)})]}),(0,d.jsxs)(`div`,{children:[l(`nextExecution`),(0,d.jsx)(`span`,{className:`text-foreground`,children:p(q.nextRunAt)})]}),(0,d.jsxs)(`div`,{children:[l(`executionAgent`),(0,d.jsx)(`span`,{className:`text-foreground`,children:Y(q.agentId)})]}),q.projectName?(0,d.jsxs)(`div`,{children:[l(`taskProject`),(0,d.jsx)(`span`,{className:`text-foreground`,children:q.projectName})]}):null,q.model?(0,d.jsxs)(`div`,{children:[l(`taskModel`),`:`,(0,d.jsx)(`span`,{className:`text-foreground`,children:_e(q.model)})]}):null,q.thinkingLevel?(0,d.jsxs)(`div`,{children:[l(`taskThinkingLevel`),(0,d.jsx)(`span`,{className:`text-foreground`,children:ge.find(e=>e.value===q.thinkingLevel)?.label()??q.thinkingLevel})]}):null,(0,d.jsxs)(`div`,{children:[l(`createdAt`),`:`,(0,d.jsx)(`span`,{className:`text-foreground`,children:p(q.createdAt)})]})]}),q.runs?.length>0?(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`mb-2 font-medium text-foreground`,children:l(`recentExecutions`)}),(0,d.jsx)(`div`,{className:`space-y-2`,children:q.runs.slice(0,5).map(e=>(0,d.jsxs)(`details`,{className:`rounded-lg border border-border bg-muted/20 p-2 text-xs text-muted-foreground`,children:[(0,d.jsxs)(`summary`,{className:`cursor-pointer text-foreground`,children:[p(e.startedAt),` · `,e.trigger===`manual`?l(`manualRun`):l(`autoRun`),` · `,De(e.status)]}),et(e)]},e.id))})]}):null]})}),(0,d.jsx)(`div`,{className:`border-t border-border px-5 py-4`,children:(0,d.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[q.lastSessionId?(0,d.jsx)(s,{variant:`outline`,onClick:()=>e?.(q.lastSessionId),children:l(`viewConversation`)}):null,(0,d.jsxs)(s,{variant:`outline`,disabled:!we(q),onClick:()=>void $(q.id,`run`),children:[(0,d.jsx)(oe,{className:`mr-1 size-3.5`}),l(`executeNow`)]}),(0,d.jsxs)(s,{variant:`outline`,disabled:h(q),onClick:()=>$e(q),children:[(0,d.jsx)(t,{className:`mr-1 size-3.5`}),l(`editTask`)]}),(0,d.jsxs)(s,{variant:`destructive`,disabled:h(q),onClick:()=>void $(q.id,`delete`),children:[(0,d.jsx)(te,{className:`mr-1 size-3.5`}),l(`deleteTask`)]})]})})]}):(0,d.jsxs)(d.Fragment,{children:[M?(0,d.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:M}):null,f===`tasks`?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`rounded-xl border border-border bg-card p-4`,children:(0,d.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:l(`taskList`)}),(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:l(`tasksCount`,{total:a.length,enabled:We})})]})})}),(0,d.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:a.length===0?(0,d.jsx)(`div`,{className:`rounded-lg px-3 py-3 text-center text-xs text-muted-foreground/55 md:col-span-2`,children:l(`noScheduledTasks`)}):a.map(e=>{let n=e.status===`enabled`,r=e.status===`completed`,a=h(e);return(0,d.jsxs)(`div`,{className:`relative cursor-pointer rounded-xl border border-border bg-card p-4 transition-colors hover:bg-muted/15`,onClick:()=>S(e.id),children:[(0,d.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,d.jsxs)(`div`,{className:`min-w-0`,children:[(0,d.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,d.jsx)(`h3`,{className:`truncate text-sm font-medium text-foreground/90`,children:e.title})}),(0,d.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:ye(e.instruction,20)})]}),(0,d.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,onClick:e=>e.stopPropagation(),children:[(0,d.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,disabled:r,className:c(`relative h-6 w-11 rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-60`,n?`bg-emerald-500`:`bg-muted-foreground/30`),onClick:()=>void $(e.id,e.status===`paused`?`resume`:`pause`),title:e.status===`paused`?l(`enable`):l(`pauseTask`),children:(0,d.jsx)(`span`,{className:c(`absolute left-0.5 top-0.5 size-5 rounded-full bg-white shadow transition-transform`,n?`translate-x-5`:`translate-x-0`)})}),(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(s,{variant:`ghost`,size:`icon`,onClick:()=>w(C===e.id?null:e.id),title:l(`moreActions`),children:(0,d.jsx)(re,{className:`size-4`})}),C===e.id?(0,d.jsxs)(`div`,{className:`absolute right-0 z-20 mt-1 w-36 overflow-hidden rounded-xl border border-border bg-popover py-1 text-sm shadow-quickforge`,children:[(0,d.jsxs)(`button`,{className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50`,disabled:!we(e),onClick:()=>void $(e.id,`run`),children:[(0,d.jsx)(oe,{className:`size-3.5`}),l(`executeNow`)]}),(0,d.jsxs)(`button`,{className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50`,disabled:a,onClick:()=>$e(e),children:[(0,d.jsx)(t,{className:`size-3.5`}),l(`editTask`)]}),(0,d.jsxs)(`button`,{className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted`,onClick:()=>{w(null),S(e.id)},children:[(0,d.jsx)(ae,{className:`size-3.5`}),l(`viewDetails`)]}),(0,d.jsxs)(`button`,{className:`flex w-full items-center gap-2 px-3 py-2 text-left text-destructive hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50`,disabled:a,onClick:()=>void $(e.id,`delete`),children:[(0,d.jsx)(te,{className:`size-3.5`}),l(`deleteTask`)]})]}):null]})]})]}),(0,d.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,d.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,d.jsx)(ce,{className:`size-3`}),e.scheduleRule]}),(0,d.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,d.jsx)(i,{className:`size-3`}),Y(e.agentId)]}),(0,d.jsxs)(`span`,{children:[l(`taskExecutionMode`),`:`,Te(e.executionMode)]}),e.projectName?(0,d.jsxs)(`span`,{children:[l(`taskProject`),e.projectName]}):null]}),(0,d.jsxs)(`div`,{className:`mt-4 grid gap-2 border-t border-border pt-3 text-xs text-muted-foreground sm:grid-cols-2`,children:[(0,d.jsxs)(`span`,{children:[l(`lastExecution`),p(e.lastRunAt)]}),(0,d.jsxs)(`span`,{children:[l(`nextExecution`),p(e.nextRunAt)]})]})]},e.id)})})]}):(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4`,children:[(0,d.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-sm font-medium text-foreground`,children:[(0,d.jsx)(ee,{className:`size-4`}),l(`historyFilters`)]}),(0,d.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,d.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[l(`taskName`),(0,d.jsxs)(`select`,{className:`mt-1 h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground`,value:V.taskId,onChange:e=>Z(`taskId`,e.target.value),children:[(0,d.jsx)(`option`,{value:``,children:l(`allTasks`)}),a.map(e=>(0,d.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,d.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[l(`status`),(0,d.jsxs)(`select`,{className:`mt-1 h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground`,value:V.status,onChange:e=>Z(`status`,e.target.value),children:[(0,d.jsx)(`option`,{value:``,children:l(`allStatuses`)}),(0,d.jsx)(`option`,{value:`running`,children:l(`executionRunning`)}),(0,d.jsx)(`option`,{value:`success`,children:l(`executionSuccess`)}),(0,d.jsx)(`option`,{value:`failed`,children:l(`taskFailed`)})]})]}),(0,d.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[l(`triggerType`),(0,d.jsxs)(`select`,{className:`mt-1 h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground`,value:V.trigger,onChange:e=>Z(`trigger`,e.target.value),children:[(0,d.jsx)(`option`,{value:``,children:l(`allTriggers`)}),(0,d.jsx)(`option`,{value:`schedule`,children:l(`autoRun`)}),(0,d.jsx)(`option`,{value:`manual`,children:l(`manualRun`)})]})]}),(0,d.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[l(`startTime`),(0,d.jsx)(`input`,{type:`datetime-local`,className:`mt-1 h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground`,value:V.startedFrom,onChange:e=>Z(`startedFrom`,e.target.value)})]}),(0,d.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[l(`endTime`),(0,d.jsx)(`input`,{type:`datetime-local`,className:`mt-1 h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground`,value:V.startedTo,onChange:e=>Z(`startedTo`,e.target.value)})]}),(0,d.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[l(`keyword`),(0,d.jsx)(`input`,{className:`mt-1 h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground`,value:V.keyword,onChange:e=>Z(`keyword`,e.target.value),placeholder:l(`keywordPlaceholder`)})]})]}),(0,d.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,d.jsx)(s,{variant:`outline`,onClick:Je,children:l(`reset`)}),(0,d.jsx)(s,{onClick:qe,children:l(`query`)})]})]}),(0,d.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-card`,children:[(0,d.jsxs)(`div`,{className:`grid grid-cols-[1.3fr_0.7fr_0.7fr_1fr_0.7fr] gap-3 border-b border-border px-4 py-3 text-xs font-medium text-muted-foreground`,children:[(0,d.jsx)(`span`,{children:l(`taskName`)}),(0,d.jsx)(`span`,{children:l(`status`)}),(0,d.jsx)(`span`,{children:l(`triggerType`)}),(0,d.jsx)(`span`,{children:l(`startTime`)}),(0,d.jsx)(`span`,{children:l(`runDuration`)})]}),Fe?(0,d.jsx)(`div`,{className:`p-8 text-center text-sm text-muted-foreground`,children:l(`loading`)}):G.runs.length===0?(0,d.jsx)(`div`,{className:`p-8 text-center text-sm text-muted-foreground`,children:l(`noExecutionHistory`)}):G.runs.map(e=>(0,d.jsxs)(`div`,{className:`border-b border-border last:border-b-0`,children:[(0,d.jsxs)(`button`,{type:`button`,className:`grid w-full grid-cols-[1.3fr_0.7fr_0.7fr_1fr_0.7fr] gap-3 px-4 py-3 text-left text-sm hover:bg-muted/40`,onClick:()=>Re(Le===e.id?null:e.id),children:[(0,d.jsx)(`span`,{className:`min-w-0 truncate text-foreground`,children:e.taskTitle}),(0,d.jsx)(`span`,{children:(0,d.jsx)(`span`,{className:c(`rounded-full px-2 py-0.5 text-xs`,Oe(e.status)),children:De(e.status)})}),(0,d.jsx)(`span`,{className:`text-muted-foreground`,children:e.trigger===`manual`?l(`manualRun`):l(`autoRun`)}),(0,d.jsx)(`span`,{className:`text-muted-foreground`,children:p(e.startedAt)}),(0,d.jsx)(`span`,{className:`text-muted-foreground`,children:e.durationMs?`${e.durationMs}ms`:`-`})]}),Le===e.id?(0,d.jsx)(`div`,{className:`border-t border-border bg-muted/20 px-4 py-3`,children:et(e)}):null]},`${e.taskId}:${e.id}`)),(0,d.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3 text-sm text-muted-foreground`,children:[(0,d.jsx)(`span`,{children:l(`paginationSummary`,{page:G.page,pages:J,total:G.total})}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`select`,{className:`h-8 rounded-md border border-input bg-background px-2 text-sm`,value:G.pageSize,onChange:e=>Xe(Number(e.target.value)),children:[10,20,50,100].map(e=>(0,d.jsx)(`option`,{value:e,children:l(`pageSize`,{size:e})},e))}),(0,d.jsx)(s,{variant:`outline`,size:`sm`,disabled:G.page<=1,onClick:()=>Ye(G.page-1),children:l(`previousPage`)}),(0,d.jsx)(s,{variant:`outline`,size:`sm`,disabled:G.page>=J,onClick:()=>Ye(G.page+1),children:l(`nextPage`)})]})]})]})]})]})})})]})}export{_ as ScheduledTasksPage};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AgentProfilesPage-XJdWmkQb.js","assets/rolldown-runtime-DWdDZTNf.js","assets/index-DeUvsbzW.js","assets/pi-ai-Cx633yhb.js","assets/pi-web-ui-DFNE2m5b.js","assets/lit-vendor-Dr3cpBGF.js","assets/css-utils-rkE68RDy.js","assets/icons-DHoaB5uq.js","assets/react-vendor-BR9MG2D-.js","assets/skills-dialog-CmCLl7K_.js","assets/logger-B65Akg8A.js","assets/index-C77QCHE9.css","assets/mcp-servers-dialog-CJ4HKWVZ.js","assets/PluginsPage-DDxjlhiK.js","assets/plugin-api-UKg_cgSG.js","assets/ScheduledTasksPage-Bw-pSpbv.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{A as t,Ft as n,It as r,Nt as i,Pt as a,Rt as o,V as s,_ as c,_t as l,c as u,dt as d,ft as f,g as p,jt as m,p as h,u as g,x as ee}from"./icons-DHoaB5uq.js";import{n as te,r as ne}from"./react-vendor-BR9MG2D-.js";import{p as _}from"./lit-vendor-Dr3cpBGF.js";import{a as v,u as y}from"./pi-web-ui-DFNE2m5b.js";import{y as b}from"./pi-ai-Cx633yhb.js";import{t as x}from"./logger-B65Akg8A.js";import{$ as re,A as ie,C as S,F as C,G as ae,J as oe,K as se,M as ce,N as le,O as ue,P as w,Q as T,S as E,T as de,W as D,X as fe,Z as pe,_ as me,at as he,b as ge,g as _e,it as ve,k as ye,nt as be,ot as xe,rt as O,st as k,tt as Se,v as Ce,x as we,y as Te}from"./index-DeUvsbzW.js";var A=e(o(),1),Ee={openai:{name:`OpenAI`,baseUrl:`https://api.openai.com/v1`,protocol:`openai-completions`,modelId:`gpt-4o`},deepseek:{name:`DeepSeek`,baseUrl:`https://api.deepseek.com/v1`,protocol:`openai-completions`,modelId:`deepseek-chat`},glm:{name:`Zhipu GLM`,baseUrl:`https://open.bigmodel.cn/api/paas/v4`,protocol:`openai-completions`,modelId:`glm-4-plus`},ollama:{name:`Ollama`,baseUrl:`http://localhost:11434/v1`,protocol:`openai-completions`,modelId:`llama3.1`},litellm:{name:D.name,baseUrl:D.baseUrl,protocol:`openai-completions`,modelId:D.modelId}},De=[{key:`openai`,label:k(`presetOpenai`)},{key:`deepseek`,label:k(`presetDeepseek`)},{key:`glm`,label:k(`presetGlm`)},{key:`ollama`,label:k(`presetOllama`)},{key:`litellm`,label:k(`presetLitellm`)},{key:`custom`,label:k(`presetCustom`)}],j=()=>({modelId:``,contextWindow:D.contextWindow,maxTokens:D.maxTokens,reasoning:!0,open:!1}),M=()=>({name:D.name,baseUrl:D.baseUrl,apiKey:``,headerRows:[],protocol:`openai-completions`,models:[j()]}),Oe=class extends v{providers=[];form=M();editingProviderId;formOpen=!1;loading=!0;apiKeyVisible=!1;advancedOpen=!1;activePreset=``;testing=!1;testResult=`idle`;testError=``;autoEditProviderName=null;async connectedCallback(){if(super.connectedCallback(),await this.loadProviders(),this.autoEditProviderName){let e=this.providers.find(e=>e.name===this.autoEditProviderName);e&&await this.openEditForm(e),this.autoEditProviderName=null}}getTabName(){return k(`customModels`)}async loadProviders(){this.loading=!0,this.requestUpdate();try{this.providers=await y().customProviders.getAll()}catch(e){x.error(`Failed to load custom providers:`,e),this.providers=[]}finally{this.loading=!1,this.requestUpdate()}}resetTestState(){this.testing=!1,this.testResult=`idle`,this.testError=``}openAddForm(){this.editingProviderId=void 0,this.form=M(),this.apiKeyVisible=!1,this.advancedOpen=!1,this.activePreset=``,this.resetTestState(),this.formOpen=!0,this.requestUpdate()}async openEditForm(e){let t=await y().providerKeys.get(e.name)??e.apiKey??``,n=e.models??[],r=n.length>0?n.map(e=>({modelId:e.id,contextWindow:e.contextWindow??D.contextWindow,maxTokens:e.maxTokens??D.maxTokens,reasoning:e.reasoning===!0,open:!1})):[j()],i=n[0]?.headers??{},a=Object.entries(i).map(([e,t])=>({key:e,value:String(t)}));this.editingProviderId=e.id,this.form={providerId:e.id,id:e.id,name:e.name,baseUrl:e.baseUrl,apiKey:t,headerRows:a,protocol:e.type===`anthropic-messages`?`anthropic-messages`:`openai-completions`,models:r},this.apiKeyVisible=!1,this.advancedOpen=a.length>0||e.type===`anthropic-messages`,this.activePreset=``,this.resetTestState(),this.formOpen=!0,this.requestUpdate()}closeForm(){this.formOpen=!1,this.editingProviderId=void 0,this.form=M(),this.apiKeyVisible=!1,this.advancedOpen=!1,this.activePreset=``,this.resetTestState(),this.requestUpdate()}toggleApiKeyVisibility(){this.apiKeyVisible=!this.apiKeyVisible,this.requestUpdate()}updateForm(e,t){this.form={...this.form,[e]:t},(e===`name`||e===`baseUrl`)&&(this.activePreset=``),this.resetTestState(),this.requestUpdate()}updateModelField(e,t,n){let r=this.form.models.map((r,i)=>i===e?{...r,[t]:n}:r);this.form={...this.form,models:r},t===`modelId`&&(this.activePreset=``,this.resetTestState()),this.requestUpdate()}addModelRow(){this.form={...this.form,models:[...this.form.models,j()]},this.requestUpdate()}removeModelRow(e){let t=this.form.models.filter((t,n)=>n!==e);this.form={...this.form,models:t},this.requestUpdate()}toggleModelExpanded(e){let t=this.form.models.map((t,n)=>n===e?{...t,open:!t.open}:t);this.form={...this.form,models:t},this.requestUpdate()}addHeaderRow(){this.form={...this.form,headerRows:[...this.form.headerRows,{key:``,value:``}]},this.requestUpdate()}updateHeaderRow(e,t,n){let r=this.form.headerRows.map((r,i)=>i===e?{...r,[t]:n}:r);this.form={...this.form,headerRows:r},this.requestUpdate()}removeHeaderRow(e){let t=this.form.headerRows.filter((t,n)=>n!==e);this.form={...this.form,headerRows:t},this.requestUpdate()}applyPreset(e){if(this.activePreset=e,e===`custom`)this.form={...this.form,name:``,baseUrl:``,protocol:`openai-completions`,models:[j()]};else{let t=Ee[e];this.form={...this.form,name:t.name,baseUrl:t.baseUrl,protocol:t.protocol,models:[{...j(),modelId:t.modelId,open:!1}]}}this.resetTestState(),this.requestUpdate()}buildHeadersFromRows(){let e={};for(let t of this.form.headerRows){let n=t.key.trim(),r=t.value.trim();n&&r&&(e[n]=r)}return e}buildModel(e,t){let n=this.form.name.trim(),r=this.form.baseUrl.trim(),i=e.reasoning===!0,a=r.includes(`api.deepseek.com`);return fe({id:e.modelId,name:`${e.modelId} (${n})`,api:this.form.protocol,provider:n,baseUrl:r.replace(/\/$/,``),reasoning:i,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:Number(e.contextWindow)||D.contextWindow,maxTokens:Number(e.maxTokens)||D.maxTokens,headers:Object.keys(t).length>0?t:void 0,thinkingLevelMap:a&&i?{low:`high`,medium:`high`,high:`high`,xhigh:`max`}:void 0,compat:this.form.protocol===`openai-completions`?{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:i,supportsUsageInStreaming:!1,supportsStrictMode:!1,maxTokensField:`max_tokens`,...a&&i?{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:`deepseek`}:{}}:void 0})}async testConnection(){let e=this.form.baseUrl.trim(),t=this.form.models.find(e=>e.modelId.trim());if(!e||!t){this.testing=!1,this.testResult=`fail`,this.testError=k(`testRequiresFields`),this.requestUpdate();return}let n=this.buildHeadersFromRows(),r=this.buildModel(t,n);this.testing=!0,this.testResult=`idle`,this.testError=``,this.requestUpdate();try{let e=await(await fetch(`/api/models/test-connection`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({model:r,apiKey:this.form.apiKey.trim()})})).json().catch(()=>({}));e?.ok?(this.testResult=`ok`,this.testError=``):(this.testResult=`fail`,this.testError=e?.error||k(`connectionFailed`))}catch(e){this.testResult=`fail`,this.testError=e?.message||k(`connectionFailed`)}finally{this.testing=!1,this.requestUpdate()}}async saveModel(){let e=this.form.name.trim(),t=this.form.baseUrl.trim();if(!e||!t){w(k(`fillProviderBaseUrlModel`));return}let n=this.form.models.filter(e=>e.modelId.trim());if(n.length===0){w(k(`atLeastOneModel`));return}let r=n.map(e=>e.modelId.trim());if(new Set(r).size!==r.length){w(k(`duplicateModelId`));return}let i=this.buildHeadersFromRows(),a=n.map(e=>this.buildModel(e,i)),o=this.form.apiKey.trim(),s=this.editingProviderId?this.providers.find(e=>e.id===this.editingProviderId):void 0,c={id:this.editingProviderId??re(),name:e,type:this.form.protocol,baseUrl:a[0].baseUrl,apiKey:o||void 0,models:a};try{let e=y();await e.customProviders.set(c),s&&s.name!==c.name&&await e.providerKeys.delete(s.name),o?await e.providerKeys.set(c.name,o):await e.providerKeys.delete(c.name),this.closeForm(),await this.loadProviders()}catch(e){x.error(`Failed to save custom model:`,e),w(k(`saveCustomModelFailed`))}}async deleteProvider(e){if(await C({description:k(`confirmDeleteProvider`,{name:e.name}),confirmLabel:k(`confirmDelete`),cancelLabel:k(`cancel`),variant:`destructive`}))try{let t=y();await t.customProviders.delete(e.id),await t.providerKeys.delete(e.name),await this.loadProviders()}catch(e){x.error(`Failed to delete custom provider:`,e),w(k(`deleteFailed`))}}renderProvider(e){let t=e.models??[],n=t.length,r=e.type===`anthropic-messages`?`Anthropic Messages`:`OpenAI Compatible`;return _`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AgentProfilesPage-R7N7eDq5.js","assets/rolldown-runtime-DWdDZTNf.js","assets/index-CZb_mGGF.js","assets/pi-ai-DjJwSQBQ.js","assets/pi-web-ui-DqxtBlZL.js","assets/lit-vendor-Dr3cpBGF.js","assets/css-utils-rkE68RDy.js","assets/icons-DHoaB5uq.js","assets/react-vendor-BR9MG2D-.js","assets/skills-dialog-B0jNVGZW.js","assets/logger-B65Akg8A.js","assets/index-C77QCHE9.css","assets/mcp-servers-dialog-VbGvNekJ.js","assets/PluginsPage-3pZG7D7e.js","assets/plugin-api-Ds5xGIL7.js","assets/ScheduledTasksPage-BAqoK4xk.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{A as t,Ft as n,It as r,Nt as i,Pt as a,Rt as o,V as s,_ as c,_t as l,c as u,dt as d,ft as f,g as p,jt as m,p as h,u as g,x as ee}from"./icons-DHoaB5uq.js";import{n as te,r as ne}from"./react-vendor-BR9MG2D-.js";import{p as _}from"./lit-vendor-Dr3cpBGF.js";import{m as v,y}from"./pi-web-ui-DqxtBlZL.js";import{J as b}from"./pi-ai-DjJwSQBQ.js";import{t as x}from"./logger-B65Akg8A.js";import{$ as re,A as ie,C as S,F as C,G as ae,J as oe,K as se,M as ce,N as le,O as ue,P as w,Q as T,S as E,T as de,W as D,X as fe,Z as pe,_ as me,at as he,b as ge,g as _e,it as ve,k as ye,nt as be,ot as xe,rt as O,st as k,tt as Se,v as Ce,x as we,y as Te}from"./index-CZb_mGGF.js";var A=e(o(),1),Ee={openai:{name:`OpenAI`,baseUrl:`https://api.openai.com/v1`,protocol:`openai-completions`,modelId:`gpt-4o`},deepseek:{name:`DeepSeek`,baseUrl:`https://api.deepseek.com/v1`,protocol:`openai-completions`,modelId:`deepseek-chat`},glm:{name:`Zhipu GLM`,baseUrl:`https://open.bigmodel.cn/api/paas/v4`,protocol:`openai-completions`,modelId:`glm-4-plus`},ollama:{name:`Ollama`,baseUrl:`http://localhost:11434/v1`,protocol:`openai-completions`,modelId:`llama3.1`},litellm:{name:D.name,baseUrl:D.baseUrl,protocol:`openai-completions`,modelId:D.modelId}},De=[{key:`openai`,label:k(`presetOpenai`)},{key:`deepseek`,label:k(`presetDeepseek`)},{key:`glm`,label:k(`presetGlm`)},{key:`ollama`,label:k(`presetOllama`)},{key:`litellm`,label:k(`presetLitellm`)},{key:`custom`,label:k(`presetCustom`)}],j=()=>({modelId:``,contextWindow:D.contextWindow,maxTokens:D.maxTokens,reasoning:!0,open:!1}),M=()=>({name:D.name,baseUrl:D.baseUrl,apiKey:``,headerRows:[],protocol:`openai-completions`,models:[j()]}),Oe=class extends v{providers=[];form=M();editingProviderId;formOpen=!1;loading=!0;apiKeyVisible=!1;advancedOpen=!1;activePreset=``;testing=!1;testResult=`idle`;testError=``;autoEditProviderName=null;async connectedCallback(){if(super.connectedCallback(),await this.loadProviders(),this.autoEditProviderName){let e=this.providers.find(e=>e.name===this.autoEditProviderName);e&&await this.openEditForm(e),this.autoEditProviderName=null}}getTabName(){return k(`customModels`)}async loadProviders(){this.loading=!0,this.requestUpdate();try{this.providers=await y().customProviders.getAll()}catch(e){x.error(`Failed to load custom providers:`,e),this.providers=[]}finally{this.loading=!1,this.requestUpdate()}}resetTestState(){this.testing=!1,this.testResult=`idle`,this.testError=``}openAddForm(){this.editingProviderId=void 0,this.form=M(),this.apiKeyVisible=!1,this.advancedOpen=!1,this.activePreset=``,this.resetTestState(),this.formOpen=!0,this.requestUpdate()}async openEditForm(e){let t=await y().providerKeys.get(e.name)??e.apiKey??``,n=e.models??[],r=n.length>0?n.map(e=>({modelId:e.id,contextWindow:e.contextWindow??D.contextWindow,maxTokens:e.maxTokens??D.maxTokens,reasoning:e.reasoning===!0,open:!1})):[j()],i=n[0]?.headers??{},a=Object.entries(i).map(([e,t])=>({key:e,value:String(t)}));this.editingProviderId=e.id,this.form={providerId:e.id,id:e.id,name:e.name,baseUrl:e.baseUrl,apiKey:t,headerRows:a,protocol:e.type===`anthropic-messages`?`anthropic-messages`:`openai-completions`,models:r},this.apiKeyVisible=!1,this.advancedOpen=a.length>0||e.type===`anthropic-messages`,this.activePreset=``,this.resetTestState(),this.formOpen=!0,this.requestUpdate()}closeForm(){this.formOpen=!1,this.editingProviderId=void 0,this.form=M(),this.apiKeyVisible=!1,this.advancedOpen=!1,this.activePreset=``,this.resetTestState(),this.requestUpdate()}toggleApiKeyVisibility(){this.apiKeyVisible=!this.apiKeyVisible,this.requestUpdate()}updateForm(e,t){this.form={...this.form,[e]:t},(e===`name`||e===`baseUrl`)&&(this.activePreset=``),this.resetTestState(),this.requestUpdate()}updateModelField(e,t,n){let r=this.form.models.map((r,i)=>i===e?{...r,[t]:n}:r);this.form={...this.form,models:r},t===`modelId`&&(this.activePreset=``,this.resetTestState()),this.requestUpdate()}addModelRow(){this.form={...this.form,models:[...this.form.models,j()]},this.requestUpdate()}removeModelRow(e){let t=this.form.models.filter((t,n)=>n!==e);this.form={...this.form,models:t},this.requestUpdate()}toggleModelExpanded(e){let t=this.form.models.map((t,n)=>n===e?{...t,open:!t.open}:t);this.form={...this.form,models:t},this.requestUpdate()}addHeaderRow(){this.form={...this.form,headerRows:[...this.form.headerRows,{key:``,value:``}]},this.requestUpdate()}updateHeaderRow(e,t,n){let r=this.form.headerRows.map((r,i)=>i===e?{...r,[t]:n}:r);this.form={...this.form,headerRows:r},this.requestUpdate()}removeHeaderRow(e){let t=this.form.headerRows.filter((t,n)=>n!==e);this.form={...this.form,headerRows:t},this.requestUpdate()}applyPreset(e){if(this.activePreset=e,e===`custom`)this.form={...this.form,name:``,baseUrl:``,protocol:`openai-completions`,models:[j()]};else{let t=Ee[e];this.form={...this.form,name:t.name,baseUrl:t.baseUrl,protocol:t.protocol,models:[{...j(),modelId:t.modelId,open:!1}]}}this.resetTestState(),this.requestUpdate()}buildHeadersFromRows(){let e={};for(let t of this.form.headerRows){let n=t.key.trim(),r=t.value.trim();n&&r&&(e[n]=r)}return e}buildModel(e,t){let n=this.form.name.trim(),r=this.form.baseUrl.trim(),i=e.reasoning===!0,a=r.includes(`api.deepseek.com`);return fe({id:e.modelId,name:`${e.modelId} (${n})`,api:this.form.protocol,provider:n,baseUrl:r.replace(/\/$/,``),reasoning:i,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:Number(e.contextWindow)||D.contextWindow,maxTokens:Number(e.maxTokens)||D.maxTokens,headers:Object.keys(t).length>0?t:void 0,thinkingLevelMap:a&&i?{low:`high`,medium:`high`,high:`high`,xhigh:`max`}:void 0,compat:this.form.protocol===`openai-completions`?{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:i,supportsUsageInStreaming:!1,supportsStrictMode:!1,maxTokensField:`max_tokens`,...a&&i?{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:`deepseek`}:{}}:void 0})}async testConnection(){let e=this.form.baseUrl.trim(),t=this.form.models.find(e=>e.modelId.trim());if(!e||!t){this.testing=!1,this.testResult=`fail`,this.testError=k(`testRequiresFields`),this.requestUpdate();return}let n=this.buildHeadersFromRows(),r=this.buildModel(t,n);this.testing=!0,this.testResult=`idle`,this.testError=``,this.requestUpdate();try{let e=await(await fetch(`/api/models/test-connection`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({model:r,apiKey:this.form.apiKey.trim()})})).json().catch(()=>({}));e?.ok?(this.testResult=`ok`,this.testError=``):(this.testResult=`fail`,this.testError=e?.error||k(`connectionFailed`))}catch(e){this.testResult=`fail`,this.testError=e?.message||k(`connectionFailed`)}finally{this.testing=!1,this.requestUpdate()}}async saveModel(){let e=this.form.name.trim(),t=this.form.baseUrl.trim();if(!e||!t){w(k(`fillProviderBaseUrlModel`));return}let n=this.form.models.filter(e=>e.modelId.trim());if(n.length===0){w(k(`atLeastOneModel`));return}let r=n.map(e=>e.modelId.trim());if(new Set(r).size!==r.length){w(k(`duplicateModelId`));return}let i=this.buildHeadersFromRows(),a=n.map(e=>this.buildModel(e,i)),o=this.form.apiKey.trim(),s=this.editingProviderId?this.providers.find(e=>e.id===this.editingProviderId):void 0,c={id:this.editingProviderId??re(),name:e,type:this.form.protocol,baseUrl:a[0].baseUrl,apiKey:o||void 0,models:a};try{let e=y();await e.customProviders.set(c),s&&s.name!==c.name&&await e.providerKeys.delete(s.name),o?await e.providerKeys.set(c.name,o):await e.providerKeys.delete(c.name),this.closeForm(),await this.loadProviders()}catch(e){x.error(`Failed to save custom model:`,e),w(k(`saveCustomModelFailed`))}}async deleteProvider(e){if(await C({description:k(`confirmDeleteProvider`,{name:e.name}),confirmLabel:k(`confirmDelete`),cancelLabel:k(`cancel`),variant:`destructive`}))try{let t=y();await t.customProviders.delete(e.id),await t.providerKeys.delete(e.name),await this.loadProviders()}catch(e){x.error(`Failed to delete custom provider:`,e),w(k(`deleteFailed`))}}renderProvider(e){let t=e.models??[],n=t.length,r=e.type===`anthropic-messages`?`Anthropic Messages`:`OpenAI Compatible`;return _`
3
3
  <div class="quickforge-settings-list-item">
4
4
  <div class="quickforge-settings-list-item-main">
5
5
  <div class="flex min-w-0 items-start gap-3">
@@ -1409,4 +1409,4 @@ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{A as t,Ft as n,It as r
1409
1409
  ${this.message?_`<div class="quickforge-settings-message">${this.message}</div>`:null}
1410
1410
  ${this.error?_`<div class="quickforge-settings-alert">${this.error}</div>`:null}
1411
1411
  </div>
1412
- `}},Y=`quickforge-channels-settings-tab`;customElements.get(Y)||customElements.define(Y,Et);function Dt(){return document.createElement(Y)}var Ot=ne(),X=te(),kt=(0,A.lazy)(()=>b(()=>import(`./AgentProfilesPage-XJdWmkQb.js`).then(e=>({default:e.AgentProfilesPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),At=(0,A.lazy)(()=>b(()=>import(`./mcp-servers-dialog-CJ4HKWVZ.js`).then(e=>({default:e.McpServersPanel})),__vite__mapDeps([12,1,2,3,4,5,6,7,8,9,10,11]))),jt=(0,A.lazy)(()=>b(()=>import(`./skills-dialog-CmCLl7K_.js`).then(e=>e.n).then(e=>({default:e.SkillsManagerPanel})),__vite__mapDeps([9,1,2,3,4,5,6,7,8,10,11]))),Mt=(0,A.lazy)(()=>b(()=>import(`./PluginsPage-DDxjlhiK.js`).then(e=>({default:e.PluginsPage})),__vite__mapDeps([13,1,2,3,4,5,6,7,8,9,10,11,14]))),Nt=(0,A.lazy)(()=>b(()=>import(`./ScheduledTasksPage-Bw-pSpbv.js`).then(e=>({default:e.ScheduledTasksPage})),__vite__mapDeps([15,1,2,3,4,5,6,7,8,9,10,11]))),Pt=class extends v{tabName=``;renderReact;root;getTabName(){return this.tabName}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>this.mountReact())}disconnectedCallback(){this.root?.unmount(),this.root=void 0,super.disconnectedCallback()}render(){return _`<div class="quickforge-react-settings-tab h-full min-h-0"></div>`}mountReact(){let e=this.querySelector(`.quickforge-react-settings-tab`);!e||!this.renderReact||(this.root??=(0,Ot.createRoot)(e),this.root.render(this.renderReact()))}},Z=`quickforge-react-settings-tab`;customElements.get(Z)||customElements.define(Z,Pt);function Q(e,t){let n=document.createElement(Z);return n.tabName=e,n.renderReact=t,n}function $({children:e}){return(0,X.jsx)(`div`,{className:`quickforge-settings-stack h-full min-h-[30rem]`,children:(0,X.jsx)(A.Suspense,{fallback:(0,X.jsx)(`div`,{className:`quickforge-settings-note`,children:k(`loading`)}),children:e})})}function Ft(e){window.dispatchEvent(new CustomEvent(`quickforge:open-session-from-settings`,{detail:{sessionId:e}}))}function It(){return Q(k(`agentsTab`),()=>(0,X.jsx)($,{children:(0,X.jsx)(kt,{})}))}function Lt(){return Q(k(`skills`),()=>(0,X.jsx)($,{children:(0,X.jsx)(jt,{active:!0,scope:`global`,embedded:!0,onSaved:()=>void 0})}))}function Rt(){return Q(k(`mcpServers`),()=>(0,X.jsx)($,{children:(0,X.jsx)(At,{active:!0})}))}function zt(){return Q(k(`plugins`),()=>(0,X.jsx)($,{children:(0,X.jsx)(Mt,{})}))}function Bt(){return Q(k(`scheduledTasks`),()=>(0,X.jsx)($,{children:(0,X.jsx)(Nt,{onOpenSession:Ft})}))}function Vt(e){let t=[{key:`appearance`,tab:Me(),getDescription:()=>k(`appearanceDescription`)},{key:`defaults`,tab:Ke(),getDescription:()=>k(`defaultOptionsDescription`)},{key:`customModels`,tab:ke(e),getDescription:()=>k(`customModelsDescription`)},{key:`agents`,tab:It(),getDescription:()=>k(`agentsDescription`)},{key:`skills`,tab:Lt(),getDescription:()=>k(`globalSkillsDescription`)},{key:`mcp`,tab:Rt(),getDescription:void 0},{key:`plugins`,tab:zt(),getDescription:()=>k(`pluginsDescription`)},{key:`scheduledTasks`,tab:Bt(),getDescription:()=>k(`scheduledTasksDescription`)},{key:`projectCommands`,tab:St(),getDescription:()=>k(`projectCommandsDescription`)},{key:`backup`,tab:at(),getDescription:()=>k(`backupRestoreDescription`)},{key:`archivedConversations`,tab:lt(),getDescription:()=>k(`archivedConversationsDescription`)},{key:`channels`,tab:Dt(),getDescription:()=>k(`channelsDescription`)},{key:`lanAccess`,tab:ft(),getDescription:()=>k(`lanAccessDescription`)},{key:`about`,tab:bt(),getDescription:()=>k(`aboutQuickForgeDescription`)}];return{items:[...t],tabs:t.map(e=>e.tab),indexOf:e=>t.findIndex(t=>t.key===e)}}var Ht={appearance:t,defaults:g,customModels:f,agents:i,skills:a,mcp:p,plugins:ee,scheduledTasks:m,projectCommands:u,backup:l,archivedConversations:r,channels:h,lanAccess:d,about:s};function Ut({tab:e}){let t=(0,A.useRef)(null);return(0,A.useEffect)(()=>{let n=t.current;if(n)return n.replaceChildren(e),()=>{e.parentNode===n&&n.removeChild(e)}},[e]),(0,X.jsx)(`div`,{ref:t,className:`quickforge-settings-tab-host min-h-0 flex-1`})}function Wt({initialTab:e,customProvider:t,onBack:r}){let i=(0,A.useMemo)(()=>Vt(t),[t]),a=Math.max(0,i.indexOf(e)),[o,s]=(0,A.useState)(),l=o??a,u=i.items[l]??i.items[0],d=u?.getDescription?.(),f=u?Ht[u.key]:void 0,[p,m]=(0,A.useState)(``),h=p.trim().toLowerCase(),g=(0,A.useMemo)(()=>i.items.map((e,t)=>({item:e,index:t})).filter(({item:e})=>h?[e.key,e.tab.getTabName(),e.getDescription?.()??``].join(` `).toLowerCase().includes(h):!0),[i.items,h]);return(0,X.jsxs)(`div`,{className:`flex h-screen min-h-0 bg-[var(--quickforge-sidebar-bg)] text-foreground`,children:[(0,X.jsxs)(`aside`,{className:`relative z-10 hidden w-80 shrink-0 overflow-hidden bg-[var(--quickforge-sidebar-bg)] md:flex md:min-h-0 md:flex-col`,children:[(0,X.jsxs)(`div`,{className:`shrink-0 px-3 pb-2 pt-3`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`group relative flex w-full items-center gap-2 overflow-hidden rounded-lg px-2 py-1.5 text-left text-muted-foreground/72 transition-[background-color,color,box-shadow] duration-160 ease-out hover:bg-[var(--quickforge-sidebar-hover-bg)] hover:text-foreground/86 hover:shadow-[0_8px_20px_-18px_rgb(15_23_42_/_0.35)]`,onClick:r,"aria-label":`返回工作区`,children:[(0,X.jsx)(`span`,{className:`inline-flex size-6 shrink-0 items-center justify-center rounded-full text-muted-foreground/55 transition-colors group-hover:text-foreground/70`,children:(0,X.jsx)(n,{className:`size-4`})}),(0,X.jsx)(`span`,{className:`truncate text-sm leading-5`,children:`返回工作区`})]}),(0,X.jsxs)(`div`,{className:`quickforge-settings-inline-field mt-3`,children:[(0,X.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground/60`,"aria-hidden":`true`}),(0,X.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:k(`searchSettings`),"aria-label":k(`searchSettings`),className:`quickforge-settings-input`})]})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-4 pt-4`,children:(0,X.jsxs)(`nav`,{className:`space-y-1`,"aria-label":k(`settings`),children:[g.map(({item:e,index:t})=>{let n=t===l,r=Ht[e.key];return(0,X.jsxs)(`button`,{type:`button`,className:O(`group relative flex w-full items-center gap-2.5 overflow-hidden rounded-lg px-2 py-1.5 text-left text-sm leading-5 transition-[background-color,color,box-shadow] duration-160 ease-out`,n?`bg-[var(--quickforge-sidebar-active-bg)] font-medium text-foreground/92 shadow-[0_8px_22px_-20px_rgb(15_23_42_/_0.32)]`:`text-muted-foreground/76 hover:bg-[var(--quickforge-sidebar-hover-bg)] hover:text-foreground/90 hover:shadow-[0_8px_20px_-18px_rgb(15_23_42_/_0.35)]`),onClick:()=>s(t),"aria-current":n?`page`:void 0,children:[(0,X.jsx)(`span`,{className:O(`inline-flex size-5 shrink-0 items-center justify-center transition-colors`,n?`text-foreground/72`:`text-muted-foreground/52 group-hover:text-foreground/68`),children:(0,X.jsx)(r,{className:`size-4`,"aria-hidden":`true`})}),(0,X.jsx)(`span`,{className:`truncate`,children:e.tab.getTabName()})]},e.key)}),g.length===0?(0,X.jsx)(`div`,{className:`px-2 py-3 text-sm text-muted-foreground/70`,children:k(`noSettingsResults`)}):null]})})]}),(0,X.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col bg-[var(--quickforge-main-bg)] md:overflow-hidden md:rounded-l-2xl`,children:[(0,X.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-2 border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-3 pr-4 md:px-5`,children:[(0,X.jsx)(be,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:r,"aria-label":`返回工作区`,children:(0,X.jsx)(n,{className:`size-4`})}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[f?(0,X.jsx)(f,{className:`size-4 shrink-0 text-muted-foreground/65`,"aria-hidden":`true`}):null,(0,X.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium text-foreground/90`,children:u?.tab.getTabName()}),d?(0,X.jsx)(Se,{label:d}):null]})})]}),(0,X.jsx)(`div`,{className:`shrink-0 border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_30%,transparent)] px-3 py-2 md:hidden`,children:(0,X.jsxs)(`div`,{className:`quickforge-settings-inline-field`,children:[(0,X.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground/60`,"aria-hidden":`true`}),(0,X.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:k(`searchSettings`),"aria-label":k(`searchSettings`),className:`quickforge-settings-input`})]})}),(0,X.jsxs)(`div`,{className:`quickforge-settings-mobile-tabs flex shrink-0 gap-1 overflow-x-auto border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_30%,transparent)] px-3 py-2 md:hidden`,children:[g.map(({item:e,index:t})=>{let n=t===l,r=Ht[e.key];return(0,X.jsxs)(`button`,{type:`button`,className:O(`inline-flex shrink-0 items-center gap-1.5 rounded-full px-3 py-1.5 text-sm transition-colors`,n?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/55 hover:text-foreground`),onClick:()=>s(t),children:[(0,X.jsx)(r,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:e.tab.getTabName()})]},e.key)}),g.length===0?(0,X.jsx)(`div`,{className:`shrink-0 px-1 py-1.5 text-sm text-muted-foreground/70`,children:k(`noSettingsResults`)}):null]}),(0,X.jsx)(`section`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-5 md:px-8 md:py-7`,children:(0,X.jsx)(`div`,{className:`mx-auto flex min-h-full w-full max-w-5xl flex-col`,children:u?(0,X.jsx)(Ut,{tab:u.tab}):null})})]})]})}export{Wt as SettingsWorkspacePage};
1412
+ `}},Y=`quickforge-channels-settings-tab`;customElements.get(Y)||customElements.define(Y,Et);function Dt(){return document.createElement(Y)}var Ot=ne(),X=te(),kt=(0,A.lazy)(()=>b(()=>import(`./AgentProfilesPage-R7N7eDq5.js`).then(e=>({default:e.AgentProfilesPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),At=(0,A.lazy)(()=>b(()=>import(`./mcp-servers-dialog-VbGvNekJ.js`).then(e=>({default:e.McpServersPanel})),__vite__mapDeps([12,1,2,3,4,5,6,7,8,9,10,11]))),jt=(0,A.lazy)(()=>b(()=>import(`./skills-dialog-B0jNVGZW.js`).then(e=>e.n).then(e=>({default:e.SkillsManagerPanel})),__vite__mapDeps([9,1,2,3,4,5,6,7,8,10,11]))),Mt=(0,A.lazy)(()=>b(()=>import(`./PluginsPage-3pZG7D7e.js`).then(e=>({default:e.PluginsPage})),__vite__mapDeps([13,1,2,3,4,5,6,7,8,9,10,11,14]))),Nt=(0,A.lazy)(()=>b(()=>import(`./ScheduledTasksPage-BAqoK4xk.js`).then(e=>({default:e.ScheduledTasksPage})),__vite__mapDeps([15,1,2,3,4,5,6,7,8,9,10,11]))),Pt=class extends v{tabName=``;renderReact;root;getTabName(){return this.tabName}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>this.mountReact())}disconnectedCallback(){this.root?.unmount(),this.root=void 0,super.disconnectedCallback()}render(){return _`<div class="quickforge-react-settings-tab h-full min-h-0"></div>`}mountReact(){let e=this.querySelector(`.quickforge-react-settings-tab`);!e||!this.renderReact||(this.root??=(0,Ot.createRoot)(e),this.root.render(this.renderReact()))}},Z=`quickforge-react-settings-tab`;customElements.get(Z)||customElements.define(Z,Pt);function Q(e,t){let n=document.createElement(Z);return n.tabName=e,n.renderReact=t,n}function $({children:e}){return(0,X.jsx)(`div`,{className:`quickforge-settings-stack h-full min-h-[30rem]`,children:(0,X.jsx)(A.Suspense,{fallback:(0,X.jsx)(`div`,{className:`quickforge-settings-note`,children:k(`loading`)}),children:e})})}function Ft(e){window.dispatchEvent(new CustomEvent(`quickforge:open-session-from-settings`,{detail:{sessionId:e}}))}function It(){return Q(k(`agentsTab`),()=>(0,X.jsx)($,{children:(0,X.jsx)(kt,{})}))}function Lt(){return Q(k(`skills`),()=>(0,X.jsx)($,{children:(0,X.jsx)(jt,{active:!0,scope:`global`,embedded:!0,onSaved:()=>void 0})}))}function Rt(){return Q(k(`mcpServers`),()=>(0,X.jsx)($,{children:(0,X.jsx)(At,{active:!0})}))}function zt(){return Q(k(`plugins`),()=>(0,X.jsx)($,{children:(0,X.jsx)(Mt,{})}))}function Bt(){return Q(k(`scheduledTasks`),()=>(0,X.jsx)($,{children:(0,X.jsx)(Nt,{onOpenSession:Ft})}))}function Vt(e){let t=[{key:`appearance`,tab:Me(),getDescription:()=>k(`appearanceDescription`)},{key:`defaults`,tab:Ke(),getDescription:()=>k(`defaultOptionsDescription`)},{key:`customModels`,tab:ke(e),getDescription:()=>k(`customModelsDescription`)},{key:`agents`,tab:It(),getDescription:()=>k(`agentsDescription`)},{key:`skills`,tab:Lt(),getDescription:()=>k(`globalSkillsDescription`)},{key:`mcp`,tab:Rt(),getDescription:void 0},{key:`plugins`,tab:zt(),getDescription:()=>k(`pluginsDescription`)},{key:`scheduledTasks`,tab:Bt(),getDescription:()=>k(`scheduledTasksDescription`)},{key:`projectCommands`,tab:St(),getDescription:()=>k(`projectCommandsDescription`)},{key:`backup`,tab:at(),getDescription:()=>k(`backupRestoreDescription`)},{key:`archivedConversations`,tab:lt(),getDescription:()=>k(`archivedConversationsDescription`)},{key:`channels`,tab:Dt(),getDescription:()=>k(`channelsDescription`)},{key:`lanAccess`,tab:ft(),getDescription:()=>k(`lanAccessDescription`)},{key:`about`,tab:bt(),getDescription:()=>k(`aboutQuickForgeDescription`)}];return{items:[...t],tabs:t.map(e=>e.tab),indexOf:e=>t.findIndex(t=>t.key===e)}}var Ht={appearance:t,defaults:g,customModels:f,agents:i,skills:a,mcp:p,plugins:ee,scheduledTasks:m,projectCommands:u,backup:l,archivedConversations:r,channels:h,lanAccess:d,about:s};function Ut({tab:e}){let t=(0,A.useRef)(null);return(0,A.useEffect)(()=>{let n=t.current;if(n)return n.replaceChildren(e),()=>{e.parentNode===n&&n.removeChild(e)}},[e]),(0,X.jsx)(`div`,{ref:t,className:`quickforge-settings-tab-host min-h-0 flex-1`})}function Wt({initialTab:e,customProvider:t,onBack:r}){let i=(0,A.useMemo)(()=>Vt(t),[t]),a=Math.max(0,i.indexOf(e)),[o,s]=(0,A.useState)(),l=o??a,u=i.items[l]??i.items[0],d=u?.getDescription?.(),f=u?Ht[u.key]:void 0,[p,m]=(0,A.useState)(``),h=p.trim().toLowerCase(),g=(0,A.useMemo)(()=>i.items.map((e,t)=>({item:e,index:t})).filter(({item:e})=>h?[e.key,e.tab.getTabName(),e.getDescription?.()??``].join(` `).toLowerCase().includes(h):!0),[i.items,h]);return(0,X.jsxs)(`div`,{className:`flex h-screen min-h-0 bg-[var(--quickforge-sidebar-bg)] text-foreground`,children:[(0,X.jsxs)(`aside`,{className:`relative z-10 hidden w-80 shrink-0 overflow-hidden bg-[var(--quickforge-sidebar-bg)] md:flex md:min-h-0 md:flex-col`,children:[(0,X.jsxs)(`div`,{className:`shrink-0 px-3 pb-2 pt-3`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`group relative flex w-full items-center gap-2 overflow-hidden rounded-lg px-2 py-1.5 text-left text-muted-foreground/72 transition-[background-color,color,box-shadow] duration-160 ease-out hover:bg-[var(--quickforge-sidebar-hover-bg)] hover:text-foreground/86 hover:shadow-[0_8px_20px_-18px_rgb(15_23_42_/_0.35)]`,onClick:r,"aria-label":`返回工作区`,children:[(0,X.jsx)(`span`,{className:`inline-flex size-6 shrink-0 items-center justify-center rounded-full text-muted-foreground/55 transition-colors group-hover:text-foreground/70`,children:(0,X.jsx)(n,{className:`size-4`})}),(0,X.jsx)(`span`,{className:`truncate text-sm leading-5`,children:`返回工作区`})]}),(0,X.jsxs)(`div`,{className:`quickforge-settings-inline-field mt-3`,children:[(0,X.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground/60`,"aria-hidden":`true`}),(0,X.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:k(`searchSettings`),"aria-label":k(`searchSettings`),className:`quickforge-settings-input`})]})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-4 pt-4`,children:(0,X.jsxs)(`nav`,{className:`space-y-1`,"aria-label":k(`settings`),children:[g.map(({item:e,index:t})=>{let n=t===l,r=Ht[e.key];return(0,X.jsxs)(`button`,{type:`button`,className:O(`group relative flex w-full items-center gap-2.5 overflow-hidden rounded-lg px-2 py-1.5 text-left text-sm leading-5 transition-[background-color,color,box-shadow] duration-160 ease-out`,n?`bg-[var(--quickforge-sidebar-active-bg)] font-medium text-foreground/92 shadow-[0_8px_22px_-20px_rgb(15_23_42_/_0.32)]`:`text-muted-foreground/76 hover:bg-[var(--quickforge-sidebar-hover-bg)] hover:text-foreground/90 hover:shadow-[0_8px_20px_-18px_rgb(15_23_42_/_0.35)]`),onClick:()=>s(t),"aria-current":n?`page`:void 0,children:[(0,X.jsx)(`span`,{className:O(`inline-flex size-5 shrink-0 items-center justify-center transition-colors`,n?`text-foreground/72`:`text-muted-foreground/52 group-hover:text-foreground/68`),children:(0,X.jsx)(r,{className:`size-4`,"aria-hidden":`true`})}),(0,X.jsx)(`span`,{className:`truncate`,children:e.tab.getTabName()})]},e.key)}),g.length===0?(0,X.jsx)(`div`,{className:`px-2 py-3 text-sm text-muted-foreground/70`,children:k(`noSettingsResults`)}):null]})})]}),(0,X.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col bg-[var(--quickforge-main-bg)] md:overflow-hidden md:rounded-l-2xl`,children:[(0,X.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-2 border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-3 pr-4 md:px-5`,children:[(0,X.jsx)(be,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:r,"aria-label":`返回工作区`,children:(0,X.jsx)(n,{className:`size-4`})}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[f?(0,X.jsx)(f,{className:`size-4 shrink-0 text-muted-foreground/65`,"aria-hidden":`true`}):null,(0,X.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium text-foreground/90`,children:u?.tab.getTabName()}),d?(0,X.jsx)(Se,{label:d}):null]})})]}),(0,X.jsx)(`div`,{className:`shrink-0 border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_30%,transparent)] px-3 py-2 md:hidden`,children:(0,X.jsxs)(`div`,{className:`quickforge-settings-inline-field`,children:[(0,X.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground/60`,"aria-hidden":`true`}),(0,X.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:k(`searchSettings`),"aria-label":k(`searchSettings`),className:`quickforge-settings-input`})]})}),(0,X.jsxs)(`div`,{className:`quickforge-settings-mobile-tabs flex shrink-0 gap-1 overflow-x-auto border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_30%,transparent)] px-3 py-2 md:hidden`,children:[g.map(({item:e,index:t})=>{let n=t===l,r=Ht[e.key];return(0,X.jsxs)(`button`,{type:`button`,className:O(`inline-flex shrink-0 items-center gap-1.5 rounded-full px-3 py-1.5 text-sm transition-colors`,n?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/55 hover:text-foreground`),onClick:()=>s(t),children:[(0,X.jsx)(r,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:e.tab.getTabName()})]},e.key)}),g.length===0?(0,X.jsx)(`div`,{className:`shrink-0 px-1 py-1.5 text-sm text-muted-foreground/70`,children:k(`noSettingsResults`)}):null]}),(0,X.jsx)(`section`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-5 md:px-8 md:py-7`,children:(0,X.jsx)(`div`,{className:`mx-auto flex min-h-full w-full max-w-5xl flex-col`,children:u?(0,X.jsx)(Ut,{tab:u.tab}):null})})]})]})}export{Wt as SettingsWorkspacePage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Rt as t,i as n,pt as r}from"./icons-DHoaB5uq.js";import{n as i}from"./react-vendor-BR9MG2D-.js";import{d as a,i as o,l as s,n as c,r as l,t as u}from"./pi-web-ui-DFNE2m5b.js";import{p as d}from"./pi-ai-Cx633yhb.js";import{t as f}from"./logger-B65Akg8A.js";import{G as p,H as m,L as h,P as g,R as _,U as v,V as y,c as b,et as x,h as S,l as C,nt as w,rt as T,s as E,st as D,z as O}from"./index-DeUvsbzW.js";import{ChatPanelHost as k}from"./ChatPanelHost-BrUHIzBw.js";var A=e(t(),1),j=`quickforgeClientMessageId`;function M(e){let t=e?.metadata;return t&&typeof t==`object`&&!Array.isArray(t)?t:void 0}function N(e){let t=M(e)?.[j];return typeof t==`string`&&t?t:void 0}function P(){return`qfcm_${typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function F(e){let t=N(e);if(t)return{message:e,clientMessageId:t};let n=P();return{message:{...e,metadata:{...M(e),[j]:n}},clientMessageId:n}}function I(e){return typeof e==`string`?e:Array.isArray(e)?e.filter(e=>e&&typeof e==`object`&&e.type===`text`).map(e=>e.text).filter(e=>typeof e==`string`).join(``):``}function L(e,t){if(!e||!t||e.role!==t.role)return!1;let n=N(e),r=N(t);return n&&r?n===r:I(e.content)===I(t.content)}async function R(e,t){let n=await fetch(e,{...t,cache:`no-store`,headers:{...t?.body?{"content-type":`application/json`}:void 0,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Request failed: ${n.status}`);return r}var z=class e{state;streamFn=d;getApiKey;sessionId;shareId;permission;listeners=new Set;eventSource=null;disposed=!1;reconnectTimer=null;reconnectDelay=1e3;baseUrl=``;syncingThinkingLevel=!1;planMode=!1;onPlanModeConsumed;constructor(e,t){this.shareId=e,this.sessionId=t.sessionId||t.id||e,this.permission=t.permission??`read`;let n={systemPrompt:t.systemPrompt??``,model:t.model??{provider:`shared`,id:`shared`},thinkingLevel:t.thinkingLevel??`off`,messages:t.messages?.slice()??[],tools:t.tools??[],isStreaming:!!t.isStreaming,streamingMessage:void 0,pendingToolCalls:new Set,errorMessage:t.errorMessage,contextCompaction:t.contextCompaction??null,contextUsage:t.contextUsage??null};this.state=new Proxy(n,{set:(e,t,n)=>{let r=e[t];return e[t]=n,t===`thinkingLevel`&&!this.syncingThinkingLevel&&n!==r&&this.updateThinkingLevel(n).catch(e=>{f.error(`Failed to update shared thinking level:`,e)}),!0}}),this.connectEvents()}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setNextPromptCapabilities(){}setPlanMode(e,t){this.planMode=e,this.onPlanModeConsumed=e?t:void 0}async prompt(e){if(this.disposed||this.permission!==`operate`)return;let{message:t,clientMessageId:n}=F(this.normalizeInput(e)),r=this.planMode?{type:`plan`}:void 0;if(this.planMode){this.planMode=!1;let e=this.onPlanModeConsumed;this.onPlanModeConsumed=void 0,e?.()}this.state.messages=[...this.state.messages,t],this.emit({type:`message_start`,message:t}),this.state.isStreaming||(this.state.isStreaming=!0,this.state.errorMessage=void 0,this.emit({type:`agent_start`}));try{await R(`/api/shared/${encodeURIComponent(this.shareId)}/message`,{method:`POST`,body:JSON.stringify({message:t,clientMessageId:n,command:r})})}catch(e){let t=e instanceof Error?e.message:String(e);throw this.state.errorMessage=t,this.state.isStreaming=!1,this.emit({type:`error`,error:t}),this.emit({type:`agent_end`,messages:this.state.messages}),e}}async updateModel(e){if(!(this.disposed||this.permission!==`operate`)){this.state.model=e;try{let t=await R(`/api/shared/${encodeURIComponent(this.shareId)}/model`,{method:`POST`,body:JSON.stringify({model:e})});t.model&&(this.state.model=t.model)}catch(e){let t=e instanceof Error?e.message:String(e);throw this.state.errorMessage=t,this.emit({type:`error`,error:t}),e}}}async updateThinkingLevel(e){if(!(this.disposed||this.permission!==`operate`)){!this.syncingThinkingLevel&&this.state.thinkingLevel!==e&&(this.state.thinkingLevel=e);try{let t=await R(`/api/shared/${encodeURIComponent(this.shareId)}/thinking-level`,{method:`POST`,body:JSON.stringify({thinkingLevel:e})});t.thinkingLevel&&(this.state.thinkingLevel=t.thinkingLevel)}catch(e){let t=e instanceof Error?e.message:String(e);throw this.state.errorMessage=t,this.emit({type:`error`,error:t}),e}}}abort(){this.permission===`operate`&&fetch(`/api/shared/${encodeURIComponent(this.shareId)}/abort`,{method:`POST`}).catch(e=>{f.error(`Failed to abort shared conversation:`,e)})}steer(){}followUp(){}reset(){this.state.messages=[],this.state.errorMessage=void 0,this.state.isStreaming=!1,this.state.streamingMessage=void 0,this.state.pendingToolCalls=new Set}async rollback(e){if(this.permission!==`operate`)return;let t=await R(`/api/shared/${encodeURIComponent(this.shareId)}/rollback`,{method:`POST`,body:JSON.stringify({messageIndex:e})});return this.applyState(t.session),this.emit({type:`messages_replaced`,messages:this.state.messages}),t}dispose(){this.disposed=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.eventSource?.close(),this.eventSource=null,this.listeners.clear()}static async loadState(e){return R(`/api/shared/${encodeURIComponent(e)}/session`)}static async create(t){return new e(t,await e.loadState(t))}normalizeInput(e){return typeof e==`string`?{role:`user`,content:e,timestamp:Date.now()}:Array.isArray(e)?[...e].reverse().find(e=>e.role===`user`||e.role===`user-with-attachments`)??e[e.length-1]:e}connectEvents(){this.disposed||(this.eventSource?.close(),this.baseUrl=``,this.openEventSource())}openEventSource(){if(this.disposed)return;let e=`${this.baseUrl}/api/shared/${encodeURIComponent(this.shareId)}/events`;this.eventSource=new EventSource(e,{withCredentials:!0}),this.eventSource.onopen=()=>{this.reconnectDelay=1e3};let t=[`state`,`agent_start`,`agent_end`,`message_start`,`message_end`,`turn_start`,`turn_end`,`message_update`,`tool_execution_start`,`tool_execution_update`,`tool_execution_end`,`error`,`title_updated`,`messages_replaced`,`auto_compact_completed`],n=e=>t=>{try{let n=JSON.parse(t.data);this.handleEvent(e?{type:e,...n}:n)}catch{}};this.eventSource.onmessage=n();for(let e of t)this.eventSource.addEventListener(e,n(e));this.eventSource.onerror=()=>{this.eventSource?.close(),this.eventSource=null,this.scheduleReconnect()}}scheduleReconnect(){this.disposed||this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4),this.openEventSource()},this.reconnectDelay))}handleEvent(e){if(e.type){switch(e.type){case`state`:this.applyState(e);break;case`agent_start`:this.state.isStreaming=!0,this.state.errorMessage=void 0;break;case`agent_end`:this.state.isStreaming=!1,this.state.streamingMessage=void 0;break;case`message_start`:if(e.message){let t=this.state.messages.findIndex(t=>L(t,e.message));if(t>=0){let n=this.state.messages.slice();n[t]=e.message,this.state.messages=n}else this.state.messages=[...this.state.messages,e.message];this.state.contextUsage=null}break;case`message_update`:e.message&&(this.state.streamingMessage=e.message);break;case`message_end`:e.message&&(this.state.messages=m(this.state.messages,e.message)),this.state.contextUsage=`contextUsage`in e?e.contextUsage:null,this.state.streamingMessage=void 0;break;case`messages_replaced`:e.messages&&(this.state.messages=e.messages,this.state.streamingMessage=void 0),`contextCompaction`in e&&(this.state.contextCompaction=e.contextCompaction),`contextUsage`in e&&(this.state.contextUsage=e.contextUsage);break;case`auto_compact_completed`:`contextCompaction`in e&&(this.state.contextCompaction=e.contextCompaction),`contextUsage`in e&&(this.state.contextUsage=e.contextUsage);break;case`tool_execution_start`:{let t=e;t.toolCallId&&(this.state.messages=v(this.state.messages,y(t),!0),this.state.pendingToolCalls=new Set([...this.state.pendingToolCalls,t.toolCallId]));break}case`tool_execution_update`:{let t=e;this.state.messages=v(this.state.messages,t,!0),t.toolCallId&&(this.state.pendingToolCalls=new Set([...this.state.pendingToolCalls,t.toolCallId]));break}case`tool_execution_end`:{let t=e;if(this.state.messages=v(this.state.messages,t,!1),t.toolCallId){let e=new Set(this.state.pendingToolCalls);e.delete(t.toolCallId),this.state.pendingToolCalls=e}break}case`error`:this.state.errorMessage=typeof e.error==`string`?e.error:`Unknown error`,this.state.isStreaming=!1;break}this.emit(e)}}applyState(e){this.sessionId=e.sessionId||e.id||this.sessionId,e.messages&&(this.state.messages=e.messages,this.state.contextUsage=e.contextUsage===void 0?null:e.contextUsage),e.systemPrompt!==void 0&&(this.state.systemPrompt=e.systemPrompt),e.model&&(this.state.model=e.model),e.thinkingLevel&&(this.syncingThinkingLevel=!0,this.state.thinkingLevel=e.thinkingLevel,this.syncingThinkingLevel=!1),e.tools&&(this.state.tools=e.tools),e.isStreaming!==void 0&&(this.state.isStreaming=!!e.isStreaming),e.errorMessage!==void 0&&(this.state.errorMessage=e.errorMessage),e.contextCompaction!==void 0&&(this.state.contextCompaction=e.contextCompaction),e.contextUsage!==void 0&&(this.state.contextUsage=e.contextUsage)}emit(e){for(let t of this.listeners)try{t(e)}catch{}}},B=i();function V(e){return{id:`shared-${e.provider}`,name:e.provider,type:e.api,baseUrl:e.baseUrl??``,models:[e]}}async function H(e,t){try{let t=await b(e);if(t.providers?.length)return t.providers}catch{}return t?[V(t)]:[]}function U(e,t){let n=t.model??{provider:`shared`,id:`shared`};return new z(e,{...t,model:n,thinkingLevel:t.thinkingLevel??p(n)})}function W(e,t){let n={settings:new u,providerKeys:new l,sessions:new c,customProviders:new o},r=new x(``,{blockedStores:[`sessions`,`provider-keys`],fakeProviderKeys:t?[t.provider]:void 0,storeOverrides:t?{"custom-providers":{keys:async()=>(await H(e,t)).map(e=>e.name),get:async n=>(await H(e,t)).find(e=>e.name===n)??null,has:async n=>(await H(e,t)).some(e=>e.name===n)}}:void 0});n.settings.setBackend(r),n.providerKeys.setBackend(r),n.sessions.setBackend(r),n.customProviders.setBackend(r),a(new s(n.settings,n.providerKeys,n.sessions,n.customProviders,r))}function G({shareId:e}){let[t,i]=(0,A.useState)(``),[a,o]=(0,A.useState)(null),[s,c]=(0,A.useState)(`read`),[l,u]=(0,A.useState)(`QuickForge 分享对话`),[d,p]=(0,A.useState)(),[m,v]=(0,A.useState)(!1),[y,b]=(0,A.useState)(),x=(0,A.useRef)(!1),j=s===`operate`,M=!!a,N=!!a?.state.tools?.length;(0,A.useEffect)(()=>{W(e,a?.state.model)},[a?.state.model,e]),(0,A.useEffect)(()=>()=>a?.dispose(),[a]);let P=(0,A.useCallback)(async(n=t.trim())=>{p(void 0),v(!0);try{let t=await C(e,n);c(t.permission),u(t.title||t.share.titleSnapshot||`QuickForge 分享对话`);let r=await z.loadState(e);W(e,r.model),o(U(e,r))}catch(e){p(e instanceof Error?e.message:`Failed to unlock shared conversation`)}finally{v(!1)}},[t,e]);(0,A.useEffect)(()=>{if(M||m||x.current)return;x.current=!0;let t=window.setTimeout(()=>{(async()=>{try{(await E(e)).share.hasPassword||await P(``)}catch(e){p(e instanceof Error?e.message:`Failed to load shared conversation`)}})()},0);return()=>window.clearTimeout(t)},[m,e,P,M]);let F=(0,A.useCallback)(async e=>{await h(e)},[]),I=(0,A.useCallback)(async()=>{if(!(!a||a.permission!==`operate`))try{let t=(await H(e,a.state.model)).flatMap(e=>e.models??[]);if(!t.length)return;S(a.state.model,t,t=>{!t.reasoning&&a.state.thinkingLevel!==`off`&&a.updateThinkingLevel(`off`).catch(e=>{f.error(`Failed to update shared thinking level:`,e)}),W(e,t),a.updateModel(t).catch(e=>{p(e instanceof Error?e.message:`Failed to update model`)})},void 0,{thinkingLevel:a.state.thinkingLevel,onThinkingLevelSelect:e=>{a.updateThinkingLevel(e).catch(e=>{f.error(`Failed to update shared thinking level:`,e),p(e instanceof Error?e.message:`Failed to update thinking level`)})}})}catch(e){p(e instanceof Error?e.message:`Failed to load models`)}},[a,e]),L=(0,A.useCallback)(async e=>{if(!a||a.permission!==`operate`)return;if(p(void 0),a.state.isStreaming){g(D(`generationStillRunning`));return}let t=O(a.state.messages,e),n=t>=0?a.state.messages[t]:void 0;if(!n){g(D(`noConversationTurnToRollback`));return}try{await a.rollback(e),b({id:Date.now(),sessionId:a.sessionId,text:_(n),attachments:n.role===`user-with-attachments`?n.attachments:void 0})}catch(e){p(e instanceof Error?e.message:`Failed to roll back`)}},[a]);return M?(0,B.jsxs)(`div`,{className:`flex h-screen min-h-0 flex-col bg-background text-foreground`,children:[(0,B.jsx)(`header`,{className:T(`shrink-0 border-b px-4 py-3`,j?`border-red-300 bg-red-50 text-red-950`:`border-border bg-background`),children:(0,B.jsxs)(`div`,{className:`mx-auto flex max-w-4xl items-start gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:l}),(0,B.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs`,children:[(0,B.jsxs)(`span`,{className:T(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 font-medium`,j?`bg-red-100 text-red-700`:`bg-muted text-muted-foreground`),children:[j?(0,B.jsx)(n,{className:`size-3.5`}):null,j?`高危可操作`:`只读分享`]}),(0,B.jsx)(`span`,{className:T(j?`text-red-800`:`text-muted-foreground`),children:j?`正在操作分享者的原始对话`:`只能查看,不能发送或修改`})]}),j?null:(0,B.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`界面与正常对话保持一致`})]}),(0,B.jsxs)(w,{variant:`ghost`,size:`sm`,className:T(`shrink-0`,j?`text-red-700 hover:bg-red-100 hover:text-red-800`:void 0),onClick:()=>void h(window.location.href),"aria-label":j?`复制高危分享链接`:`复制分享链接`,title:j?`复制高危分享链接`:`复制分享链接`,children:[(0,B.jsx)(r,{className:`size-4`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:j?`复制高危链接`:`复制链接`})]})]})}),d?(0,B.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-4 py-2 text-sm text-destructive`,children:d}):null,(0,B.jsx)(k,{agent:a,revision:0,agentAccessMode:N?`full-access`:`default`,workspaceToolsEnabled:N,onModelSelect:I,onAccessModeChange:()=>void 0,onRollbackFromMessage:L,onRetryFromMessage:()=>void 0,onCopyAnswer:F,onForkFromMessage:()=>void 0,onApproveToolCall:()=>void 0,onRejectToolCall:()=>void 0,disableFork:!0,rollbackConfirmTitle:D(`sharedRollbackConfirmTitle`),rollbackConfirmDescription:D(`sharedRollbackConfirm`),readOnly:!j,restoredDraft:y,bypassClientApiKeyCheck:!0})]}):(0,B.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-6 text-foreground`,children:(0,B.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-border bg-background p-6 shadow-quickforge`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-base font-semibold`,children:[(0,B.jsx)(n,{className:`size-5 text-amber-500`}),`QuickForge 局域网对话分享`]}),(0,B.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`如果分享者设置了密码,请输入密码。未设置密码的链接会自动打开。`}),(0,B.jsx)(`input`,{type:`password`,value:t,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&P()},className:`mt-5 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-primary`,placeholder:`密码`,autoFocus:!0}),d?(0,B.jsx)(`div`,{className:`mt-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}):null,(0,B.jsx)(w,{className:`mt-5 w-full`,onClick:()=>void P(),disabled:m||!t.trim(),children:m?D(`loading`):`用密码打开分享对话`})]})})}export{G as SharedConversationPage};
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Rt as t,i as n,pt as r}from"./icons-DHoaB5uq.js";import{n as i}from"./react-vendor-BR9MG2D-.js";import{b as a,d as o,f as s,p as c,u as l,v as u}from"./pi-web-ui-DqxtBlZL.js";import{U as d}from"./pi-ai-DjJwSQBQ.js";import{t as f}from"./logger-B65Akg8A.js";import{G as p,H as m,L as h,P as g,R as _,U as v,V as y,c as b,et as x,h as S,l as C,nt as w,rt as T,s as E,st as D,z as O}from"./index-CZb_mGGF.js";import{ChatPanelHost as k}from"./ChatPanelHost-C4orgd5l.js";var A=e(t(),1),j=`quickforgeClientMessageId`;function M(e){let t=e?.metadata;return t&&typeof t==`object`&&!Array.isArray(t)?t:void 0}function N(e){let t=M(e)?.[j];return typeof t==`string`&&t?t:void 0}function P(){return`qfcm_${typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function F(e){let t=N(e);if(t)return{message:e,clientMessageId:t};let n=P();return{message:{...e,metadata:{...M(e),[j]:n}},clientMessageId:n}}function I(e){return typeof e==`string`?e:Array.isArray(e)?e.filter(e=>e&&typeof e==`object`&&e.type===`text`).map(e=>e.text).filter(e=>typeof e==`string`).join(``):``}function L(e,t){if(!e||!t||e.role!==t.role)return!1;let n=N(e),r=N(t);return n&&r?n===r:I(e.content)===I(t.content)}async function R(e,t){let n=await fetch(e,{...t,cache:`no-store`,headers:{...t?.body?{"content-type":`application/json`}:void 0,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Request failed: ${n.status}`);return r}var z=class e{state;streamFn=d;getApiKey;sessionId;shareId;permission;listeners=new Set;eventSource=null;disposed=!1;reconnectTimer=null;reconnectDelay=1e3;baseUrl=``;syncingThinkingLevel=!1;planMode=!1;onPlanModeConsumed;constructor(e,t){this.shareId=e,this.sessionId=t.sessionId||t.id||e,this.permission=t.permission??`read`;let n={systemPrompt:t.systemPrompt??``,model:t.model??{provider:`shared`,id:`shared`},thinkingLevel:t.thinkingLevel??`off`,messages:t.messages?.slice()??[],tools:t.tools??[],isStreaming:!!t.isStreaming,streamingMessage:void 0,pendingToolCalls:new Set,errorMessage:t.errorMessage,contextCompaction:t.contextCompaction??null,contextUsage:t.contextUsage??null};this.state=new Proxy(n,{set:(e,t,n)=>{let r=e[t];return e[t]=n,t===`thinkingLevel`&&!this.syncingThinkingLevel&&n!==r&&this.updateThinkingLevel(n).catch(e=>{f.error(`Failed to update shared thinking level:`,e)}),!0}}),this.connectEvents()}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setNextPromptCapabilities(){}setPlanMode(e,t){this.planMode=e,this.onPlanModeConsumed=e?t:void 0}async prompt(e){if(this.disposed||this.permission!==`operate`)return;let{message:t,clientMessageId:n}=F(this.normalizeInput(e)),r=this.planMode?{type:`plan`}:void 0;if(this.planMode){this.planMode=!1;let e=this.onPlanModeConsumed;this.onPlanModeConsumed=void 0,e?.()}this.state.messages=[...this.state.messages,t],this.emit({type:`message_start`,message:t}),this.state.isStreaming||(this.state.isStreaming=!0,this.state.errorMessage=void 0,this.emit({type:`agent_start`}));try{await R(`/api/shared/${encodeURIComponent(this.shareId)}/message`,{method:`POST`,body:JSON.stringify({message:t,clientMessageId:n,command:r})})}catch(e){let t=e instanceof Error?e.message:String(e);throw this.state.errorMessage=t,this.state.isStreaming=!1,this.emit({type:`error`,error:t}),this.emit({type:`agent_end`,messages:this.state.messages}),e}}async updateModel(e){if(!(this.disposed||this.permission!==`operate`)){this.state.model=e;try{let t=await R(`/api/shared/${encodeURIComponent(this.shareId)}/model`,{method:`POST`,body:JSON.stringify({model:e})});t.model&&(this.state.model=t.model)}catch(e){let t=e instanceof Error?e.message:String(e);throw this.state.errorMessage=t,this.emit({type:`error`,error:t}),e}}}async updateThinkingLevel(e){if(!(this.disposed||this.permission!==`operate`)){!this.syncingThinkingLevel&&this.state.thinkingLevel!==e&&(this.state.thinkingLevel=e);try{let t=await R(`/api/shared/${encodeURIComponent(this.shareId)}/thinking-level`,{method:`POST`,body:JSON.stringify({thinkingLevel:e})});t.thinkingLevel&&(this.state.thinkingLevel=t.thinkingLevel)}catch(e){let t=e instanceof Error?e.message:String(e);throw this.state.errorMessage=t,this.emit({type:`error`,error:t}),e}}}abort(){this.permission===`operate`&&fetch(`/api/shared/${encodeURIComponent(this.shareId)}/abort`,{method:`POST`}).catch(e=>{f.error(`Failed to abort shared conversation:`,e)})}steer(){}followUp(){}reset(){this.state.messages=[],this.state.errorMessage=void 0,this.state.isStreaming=!1,this.state.streamingMessage=void 0,this.state.pendingToolCalls=new Set}async rollback(e){if(this.permission!==`operate`)return;let t=await R(`/api/shared/${encodeURIComponent(this.shareId)}/rollback`,{method:`POST`,body:JSON.stringify({messageIndex:e})});return this.applyState(t.session),this.emit({type:`messages_replaced`,messages:this.state.messages}),t}dispose(){this.disposed=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.eventSource?.close(),this.eventSource=null,this.listeners.clear()}static async loadState(e){return R(`/api/shared/${encodeURIComponent(e)}/session`)}static async create(t){return new e(t,await e.loadState(t))}normalizeInput(e){return typeof e==`string`?{role:`user`,content:e,timestamp:Date.now()}:Array.isArray(e)?[...e].reverse().find(e=>e.role===`user`||e.role===`user-with-attachments`)??e[e.length-1]:e}connectEvents(){this.disposed||(this.eventSource?.close(),this.baseUrl=``,this.openEventSource())}openEventSource(){if(this.disposed)return;let e=`${this.baseUrl}/api/shared/${encodeURIComponent(this.shareId)}/events`;this.eventSource=new EventSource(e,{withCredentials:!0}),this.eventSource.onopen=()=>{this.reconnectDelay=1e3};let t=[`state`,`agent_start`,`agent_end`,`message_start`,`message_end`,`turn_start`,`turn_end`,`message_update`,`tool_execution_start`,`tool_execution_update`,`tool_execution_end`,`error`,`title_updated`,`messages_replaced`,`auto_compact_completed`],n=e=>t=>{try{let n=JSON.parse(t.data);this.handleEvent(e?{type:e,...n}:n)}catch{}};this.eventSource.onmessage=n();for(let e of t)this.eventSource.addEventListener(e,n(e));this.eventSource.onerror=()=>{this.eventSource?.close(),this.eventSource=null,this.scheduleReconnect()}}scheduleReconnect(){this.disposed||this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4),this.openEventSource()},this.reconnectDelay))}handleEvent(e){if(e.type){switch(e.type){case`state`:this.applyState(e);break;case`agent_start`:this.state.isStreaming=!0,this.state.errorMessage=void 0;break;case`agent_end`:this.state.isStreaming=!1,this.state.streamingMessage=void 0;break;case`message_start`:if(e.message){let t=this.state.messages.findIndex(t=>L(t,e.message));if(t>=0){let n=this.state.messages.slice();n[t]=e.message,this.state.messages=n}else this.state.messages=[...this.state.messages,e.message];this.state.contextUsage=null}break;case`message_update`:e.message&&(this.state.streamingMessage=e.message);break;case`message_end`:e.message&&(this.state.messages=m(this.state.messages,e.message)),this.state.contextUsage=`contextUsage`in e?e.contextUsage:null,this.state.streamingMessage=void 0;break;case`messages_replaced`:e.messages&&(this.state.messages=e.messages,this.state.streamingMessage=void 0),`contextCompaction`in e&&(this.state.contextCompaction=e.contextCompaction),`contextUsage`in e&&(this.state.contextUsage=e.contextUsage);break;case`auto_compact_completed`:`contextCompaction`in e&&(this.state.contextCompaction=e.contextCompaction),`contextUsage`in e&&(this.state.contextUsage=e.contextUsage);break;case`tool_execution_start`:{let t=e;t.toolCallId&&(this.state.messages=v(this.state.messages,y(t),!0),this.state.pendingToolCalls=new Set([...this.state.pendingToolCalls,t.toolCallId]));break}case`tool_execution_update`:{let t=e;this.state.messages=v(this.state.messages,t,!0),t.toolCallId&&(this.state.pendingToolCalls=new Set([...this.state.pendingToolCalls,t.toolCallId]));break}case`tool_execution_end`:{let t=e;if(this.state.messages=v(this.state.messages,t,!1),t.toolCallId){let e=new Set(this.state.pendingToolCalls);e.delete(t.toolCallId),this.state.pendingToolCalls=e}break}case`error`:this.state.errorMessage=typeof e.error==`string`?e.error:`Unknown error`,this.state.isStreaming=!1;break}this.emit(e)}}applyState(e){this.sessionId=e.sessionId||e.id||this.sessionId,e.messages&&(this.state.messages=e.messages,this.state.contextUsage=e.contextUsage===void 0?null:e.contextUsage),e.systemPrompt!==void 0&&(this.state.systemPrompt=e.systemPrompt),e.model&&(this.state.model=e.model),e.thinkingLevel&&(this.syncingThinkingLevel=!0,this.state.thinkingLevel=e.thinkingLevel,this.syncingThinkingLevel=!1),e.tools&&(this.state.tools=e.tools),e.isStreaming!==void 0&&(this.state.isStreaming=!!e.isStreaming),e.errorMessage!==void 0&&(this.state.errorMessage=e.errorMessage),e.contextCompaction!==void 0&&(this.state.contextCompaction=e.contextCompaction),e.contextUsage!==void 0&&(this.state.contextUsage=e.contextUsage)}emit(e){for(let t of this.listeners)try{t(e)}catch{}}},B=i();function V(e){return{id:`shared-${e.provider}`,name:e.provider,type:e.api,baseUrl:e.baseUrl??``,models:[e]}}async function H(e,t){try{let t=await b(e);if(t.providers?.length)return t.providers}catch{}return t?[V(t)]:[]}function U(e,t){let n=t.model??{provider:`shared`,id:`shared`};return new z(e,{...t,model:n,thinkingLevel:t.thinkingLevel??p(n)})}function W(e,t){let n={settings:new l,providerKeys:new s,sessions:new o,customProviders:new c},r=new x(``,{blockedStores:[`sessions`,`provider-keys`],fakeProviderKeys:t?[t.provider]:void 0,storeOverrides:t?{"custom-providers":{keys:async()=>(await H(e,t)).map(e=>e.name),get:async n=>(await H(e,t)).find(e=>e.name===n)??null,has:async n=>(await H(e,t)).some(e=>e.name===n)}}:void 0});n.settings.setBackend(r),n.providerKeys.setBackend(r),n.sessions.setBackend(r),n.customProviders.setBackend(r),a(new u(n.settings,n.providerKeys,n.sessions,n.customProviders,r))}function G({shareId:e}){let[t,i]=(0,A.useState)(``),[a,o]=(0,A.useState)(null),[s,c]=(0,A.useState)(`read`),[l,u]=(0,A.useState)(`QuickForge 分享对话`),[d,p]=(0,A.useState)(),[m,v]=(0,A.useState)(!1),[y,b]=(0,A.useState)(),x=(0,A.useRef)(!1),j=s===`operate`,M=!!a,N=!!a?.state.tools?.length;(0,A.useEffect)(()=>{W(e,a?.state.model)},[a?.state.model,e]),(0,A.useEffect)(()=>()=>a?.dispose(),[a]);let P=(0,A.useCallback)(async(n=t.trim())=>{p(void 0),v(!0);try{let t=await C(e,n);c(t.permission),u(t.title||t.share.titleSnapshot||`QuickForge 分享对话`);let r=await z.loadState(e);W(e,r.model),o(U(e,r))}catch(e){p(e instanceof Error?e.message:`Failed to unlock shared conversation`)}finally{v(!1)}},[t,e]);(0,A.useEffect)(()=>{if(M||m||x.current)return;x.current=!0;let t=window.setTimeout(()=>{(async()=>{try{(await E(e)).share.hasPassword||await P(``)}catch(e){p(e instanceof Error?e.message:`Failed to load shared conversation`)}})()},0);return()=>window.clearTimeout(t)},[m,e,P,M]);let F=(0,A.useCallback)(async e=>{await h(e)},[]),I=(0,A.useCallback)(async()=>{if(!(!a||a.permission!==`operate`))try{let t=(await H(e,a.state.model)).flatMap(e=>e.models??[]);if(!t.length)return;S(a.state.model,t,t=>{!t.reasoning&&a.state.thinkingLevel!==`off`&&a.updateThinkingLevel(`off`).catch(e=>{f.error(`Failed to update shared thinking level:`,e)}),W(e,t),a.updateModel(t).catch(e=>{p(e instanceof Error?e.message:`Failed to update model`)})},void 0,{thinkingLevel:a.state.thinkingLevel,onThinkingLevelSelect:e=>{a.updateThinkingLevel(e).catch(e=>{f.error(`Failed to update shared thinking level:`,e),p(e instanceof Error?e.message:`Failed to update thinking level`)})}})}catch(e){p(e instanceof Error?e.message:`Failed to load models`)}},[a,e]),L=(0,A.useCallback)(async e=>{if(!a||a.permission!==`operate`)return;if(p(void 0),a.state.isStreaming){g(D(`generationStillRunning`));return}let t=O(a.state.messages,e),n=t>=0?a.state.messages[t]:void 0;if(!n){g(D(`noConversationTurnToRollback`));return}try{await a.rollback(e),b({id:Date.now(),sessionId:a.sessionId,text:_(n),attachments:n.role===`user-with-attachments`?n.attachments:void 0})}catch(e){p(e instanceof Error?e.message:`Failed to roll back`)}},[a]);return M?(0,B.jsxs)(`div`,{className:`flex h-screen min-h-0 flex-col bg-background text-foreground`,children:[(0,B.jsx)(`header`,{className:T(`shrink-0 border-b px-4 py-3`,j?`border-red-300 bg-red-50 text-red-950`:`border-border bg-background`),children:(0,B.jsxs)(`div`,{className:`mx-auto flex max-w-4xl items-start gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:l}),(0,B.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs`,children:[(0,B.jsxs)(`span`,{className:T(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 font-medium`,j?`bg-red-100 text-red-700`:`bg-muted text-muted-foreground`),children:[j?(0,B.jsx)(n,{className:`size-3.5`}):null,j?`高危可操作`:`只读分享`]}),(0,B.jsx)(`span`,{className:T(j?`text-red-800`:`text-muted-foreground`),children:j?`正在操作分享者的原始对话`:`只能查看,不能发送或修改`})]}),j?null:(0,B.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`界面与正常对话保持一致`})]}),(0,B.jsxs)(w,{variant:`ghost`,size:`sm`,className:T(`shrink-0`,j?`text-red-700 hover:bg-red-100 hover:text-red-800`:void 0),onClick:()=>void h(window.location.href),"aria-label":j?`复制高危分享链接`:`复制分享链接`,title:j?`复制高危分享链接`:`复制分享链接`,children:[(0,B.jsx)(r,{className:`size-4`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:j?`复制高危链接`:`复制链接`})]})]})}),d?(0,B.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-4 py-2 text-sm text-destructive`,children:d}):null,(0,B.jsx)(k,{agent:a,revision:0,agentAccessMode:N?`full-access`:`default`,workspaceToolsEnabled:N,onModelSelect:I,onAccessModeChange:()=>void 0,onRollbackFromMessage:L,onRetryFromMessage:()=>void 0,onCopyAnswer:F,onForkFromMessage:()=>void 0,onApproveToolCall:()=>void 0,onRejectToolCall:()=>void 0,disableFork:!0,rollbackConfirmTitle:D(`sharedRollbackConfirmTitle`),rollbackConfirmDescription:D(`sharedRollbackConfirm`),readOnly:!j,restoredDraft:y,bypassClientApiKeyCheck:!0})]}):(0,B.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-6 text-foreground`,children:(0,B.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-border bg-background p-6 shadow-quickforge`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-base font-semibold`,children:[(0,B.jsx)(n,{className:`size-5 text-amber-500`}),`QuickForge 局域网对话分享`]}),(0,B.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`如果分享者设置了密码,请输入密码。未设置密码的链接会自动打开。`}),(0,B.jsx)(`input`,{type:`password`,value:t,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&P()},className:`mt-5 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-primary`,placeholder:`密码`,autoFocus:!0}),d?(0,B.jsx)(`div`,{className:`mt-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}):null,(0,B.jsx)(w,{className:`mt-5 w-full`,onClick:()=>void P(),disabled:m||!t.trim(),children:m?D(`loading`):`用密码打开分享对话`})]})})}export{G as SharedConversationPage};