@shawnstack/quickforge 1.7.0 → 1.7.1

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 (26) hide show
  1. package/dist/assets/AgentProfilesPage-__uY0AvK.js +1 -0
  2. package/dist/assets/{ChatPanelHost-vi1tDqlJ.js → ChatPanelHost-DIs_vWFX.js} +1 -1
  3. package/dist/assets/{PluginsPage-B8bHMwfv.js → PluginsPage-CKyWhlCo.js} +1 -1
  4. package/dist/assets/ScheduledTasksPage-KtJoeJYt.js +2 -0
  5. package/dist/assets/{SettingsWorkspacePage-BOP9CtoI.js → SettingsWorkspacePage-DwqEnUmX.js} +4 -4
  6. package/dist/assets/{SharedConversationPage-9A4L9UcQ.js → SharedConversationPage-yujCRsbe.js} +1 -1
  7. package/dist/assets/TerminalDock-B9xKnimU.js +2 -0
  8. package/dist/assets/WorkspaceInspector-CE6RD6Ys.js +13 -0
  9. package/dist/assets/icons-pPRMD2tE.js +1 -0
  10. package/dist/assets/index-BSXpUDCq.js +63 -0
  11. package/dist/assets/index-DpO7jEGP.css +3 -0
  12. package/dist/assets/{mcp-servers-dialog-XE4K8PCO.js → mcp-servers-dialog-CaQTvGiW.js} +2 -2
  13. package/dist/assets/{monaco-C13M09wD.js → monaco-CPwJMUsl.js} +1 -1
  14. package/dist/assets/{react-vendor-2RKYr-A4.js → react-vendor-CLbWF1Oy.js} +1 -1
  15. package/dist/assets/{skills-dialog-MpoxntiV.js → skills-dialog-D18mxNyW.js} +1 -1
  16. package/dist/index.html +6 -6
  17. package/package.json +1 -1
  18. package/server/routes/backup.mjs +79 -72
  19. package/server/routes/workspace.mjs +84 -32
  20. package/dist/assets/AgentProfilesPage-DQ8URegq.js +0 -1
  21. package/dist/assets/ScheduledTasksPage-AaUz5el2.js +0 -2
  22. package/dist/assets/TerminalDock-DQOXpaDe.js +0 -2
  23. package/dist/assets/WorkspaceInspector-DaM7TJHb.js +0 -13
  24. package/dist/assets/icons-ko_i0WpN.js +0 -1
  25. package/dist/assets/index-B2eauKpo.css +0 -3
  26. package/dist/assets/index-B8Awq5FV.js +0 -63
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{E as t,Ft as n,Mt as r,Ot as i,a,c as o,it as ee}from"./icons-pPRMD2tE.js";import{i as s,n as c}from"./react-vendor-CLbWF1Oy.js";import{$ as te,Q as l,V as ne,Z as re,et as ie,lt as u,mt as d,st as f,tt as ae}from"./index-BSXpUDCq.js";var p=e(n(),1),oe=s(),m=c(),h=144,g=82,_=4,v=8;function y(e){return JSON.stringify({provider:e.provider,modelId:e.id,api:e.api,baseUrl:e.baseUrl})}function b(e){if(!e)return{mode:`inherit`};try{let t=JSON.parse(e);return{mode:`fixed`,provider:String(t.provider||``),modelId:String(t.modelId||``),api:t.api?String(t.api):void 0,baseUrl:t.baseUrl?String(t.baseUrl):void 0}}catch{return{mode:`inherit`}}}function x(e){return!e||e.mode!==`fixed`?``:JSON.stringify({provider:e.provider,modelId:e.modelId,api:e.api,baseUrl:e.baseUrl})}function se(e){return e.name||`${e.provider}/${e.id}`}function S(){return{name:``,label:``,description:``,systemPrompt:``,allowedTools:[`read_file`,`grep_files`],maxRuntimeMs:`1800000`,maxToolCalls:`300`,enabledAsSubagent:!0,modelMode:`inherit`,fixedModelValue:``,thinkingLevel:`inherit`}}function ce(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,modelMode:e.model?.mode===`fixed`?`fixed`:`inherit`,fixedModelValue:x(e.model),thinkingLevel:e.thinkingLevel??`inherit`}}function le(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,model:e.modelMode===`fixed`?b(e.fixedModelValue):{mode:`inherit`},thinkingLevel:e.thinkingLevel}}function C(e){return!!(e.name.trim()&&e.label.trim()&&e.allowedTools.length>0)}async function w(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 T(){let[e,n]=(0,p.useState)([]),[s,c]=(0,p.useState)([]),[x,T]=(0,p.useState)(!1),[E,D]=(0,p.useState)(null),[O,k]=(0,p.useState)(()=>S()),[A,j]=(0,p.useState)(!1),[M,N]=(0,p.useState)(``),[P,F]=(0,p.useState)(!1),[I,ue]=(0,p.useState)(),[L,de]=(0,p.useState)([]),[fe,pe]=(0,p.useState)(`off`),[R,z]=(0,p.useState)(``),[B,V]=(0,p.useState)(null),[H,U]=(0,p.useState)(null);async function W(){let[e,t]=await Promise.all([w(`/api/agent-profiles`),w(`/api/agent-profiles/available-tools`)]);n(e.agents),c(t.tools)}(0,p.useEffect)(()=>{let e=!1;async function t(){try{let[t,r]=await Promise.all([w(`/api/agent-profiles`),w(`/api/agent-profiles/available-tools`)]);if(e)return;n(t.agents),c(r.tools)}catch(t){e||z(t instanceof Error?t.message:d(`requestFailed`))}}return t(),()=>{e=!0}},[]),(0,p.useEffect)(()=>{let e=!1;async function t(){try{let t=await te(),n=await l(t);de(n);let r=await ie(t),i=r.model??await ae(t)??n[0];if(e)return;ue(i),pe(r.thinkingLevel??re(i))}catch{}}return t(),()=>{e=!0}},[]),(0,p.useEffect)(()=>{if(!B)return;let e=()=>{V(null),U(null)},t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`click`,e),window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),document.addEventListener(`keydown`,t),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0),document.removeEventListener(`keydown`,t)}},[B]);let G=(0,p.useMemo)(()=>e.find(e=>e.id===E)??null,[e,E]),K=(0,p.useMemo)(()=>e.find(e=>e.id===B)??null,[e,B]),q=!!G?.readonly,J=!!(G?.readonly&&!G?.builtin),Y=(0,p.useMemo)(()=>L.find(e=>y(e)===O.fixedModelValue),[O.fixedModelValue,L]),X=O.modelMode===`fixed`&&!!Y&&Y?.reasoning!==!0;function me(e,t){if(e.stopPropagation(),B===t){V(null),U(null);return}let n=e.currentTarget.getBoundingClientRect(),r=Math.max(v,Math.min(n.right-h,window.innerWidth-h-v)),i=n.bottom+_,a=n.top-_-g;U({left:r,top:i+g<=window.innerHeight-v?i:Math.max(v,a)}),V(t)}function Z(e,t){k(n=>({...n,[e]:t}))}function he(e){k(t=>({...t,allowedTools:t.allowedTools.includes(e)?t.allowedTools.filter(t=>t!==e):[...t.allowedTools,e]}))}function ge(){D(null),k(S()),N(``),z(``),T(!0)}function Q(e){D(e.id),k(ce(e)),N(``),z(``),T(!0)}function $(){A||P||(T(!1),D(null),k(S()),N(``))}async function _e(){let e=M.trim();if(!e){z(d(`aiFillAgentInputRequired`));return}if(!I){z(d(`aiFillAgentNoModel`));return}F(!0),z(``);try{let t=await w(`/api/agent-profiles/ai-fill`,{method:`POST`,body:JSON.stringify({instruction:e,model:I,thinkingLevel:fe})});k(e=>({...e,name:t.agent.name,label:t.agent.label,description:t.agent.description,systemPrompt:t.agent.systemPrompt}))}catch(e){z(e instanceof Error?e.message:d(`aiFillAgentFailed`))}finally{F(!1)}}async function ve(){if(C(O)){j(!0),z(``);try{let e=G?.builtin?{model:O.modelMode===`fixed`?b(O.fixedModelValue):{mode:`inherit`}}:le({...O,thinkingLevel:X?`off`:O.thinkingLevel});E?await w(`/api/agent-profiles/${encodeURIComponent(E)}`,{method:`PATCH`,body:JSON.stringify(e)}):await w(`/api/agent-profiles`,{method:`POST`,body:JSON.stringify(e)}),$(),await W()}catch(e){z(e instanceof Error?e.message:d(`requestFailed`))}finally{j(!1)}}}async function ye(e){if(e.builtin||e.readonly)return;let t=!e.enabledAsSubagent,r=e.enabledAsSubagent;n(n=>n.map(n=>n.id===e.id?{...n,enabledAsSubagent:t}:n)),V(null);try{await w(`/api/agent-profiles/${encodeURIComponent(e.id)}`,{method:`PATCH`,body:JSON.stringify({enabledAsSubagent:t})})}catch(t){n(t=>t.map(t=>t.id===e.id?{...t,enabledAsSubagent:r}:t)),z(t instanceof Error?t.message:d(`requestFailed`))}}async function be(e){if(!(e.builtin||e.readonly)&&await ne({description:d(`confirmDeleteAgent`),confirmLabel:d(`confirmDelete`),cancelLabel:d(`cancel`),variant:`destructive`})){z(``);try{await w(`/api/agent-profiles/${encodeURIComponent(e.id)}`,{method:`DELETE`}),await W()}catch(e){z(e instanceof Error?e.message:d(`requestFailed`))}}}return x?(0,m.jsxs)(`div`,{className:`quickforge-settings-stack`,children:[(0,m.jsx)(`div`,{className:`quickforge-settings-heading`,children:(0,m.jsxs)(`h3`,{className:`quickforge-settings-title`,children:[G?.builtin?d(`builtinAgentModelSettings`):d(G?`editAgent`:`createAgent`),(0,m.jsx)(f,{label:G?.builtin?d(`builtinAgentModelOnly`):G?.readonly?d(`readonlyAgentDescription`):d(`agentsDescription`)})]})}),(0,m.jsxs)(`section`,{className:`quickforge-settings-section`,"aria-label":d(G?`editAgent`:`createAgent`),children:[(0,m.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,m.jsxs)(`button`,{className:`quickforge-settings-button quickforge-settings-button-secondary`,type:`button`,onClick:$,disabled:A||P,children:[(0,m.jsx)(r,{className:`mr-2 size-4`}),d(`back`)]}),(0,m.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,m.jsx)(`div`,{className:`quickforge-settings-row-title`,children:G?.builtin?d(`builtinAgentModelSettings`):d(G?`editAgent`:`createAgent`)}),G?.builtin?(0,m.jsx)(`div`,{className:`quickforge-settings-row-description`,children:d(`builtinAgentModelOnly`)}):G?.readonly?(0,m.jsx)(`div`,{className:`quickforge-settings-row-description`,children:d(`readonlyAgentDescription`)}):null]})]}),(0,m.jsx)(`div`,{className:`px-5 py-4`,children:(0,m.jsxs)(`div`,{className:`space-y-4`,children:[(0,m.jsxs)(`div`,{className:`rounded-2xl border border-border bg-muted/20 p-3`,children:[(0,m.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-medium text-foreground`,children:[(0,m.jsx)(o,{className:`size-4 text-primary`}),d(`aiFillAgent`),(0,m.jsx)(f,{label:d(`aiFillAgentDescription`)})]}),(0,m.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:M,disabled:q||P,onChange:e=>N(e.target.value),placeholder:d(`aiFillAgentPlaceholder`)}),(0,m.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,m.jsxs)(u,{variant:`outline`,size:`sm`,onClick:()=>void _e(),disabled:q||P||!M.trim(),children:[(0,m.jsx)(o,{className:`mr-1 size-3.5`}),d(P?`aiFillAgentLoading`:`aiFillAgent`)]})})]}),(0,m.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,m.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`agentName`),(0,m.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:O.name,disabled:q,onChange:e=>Z(`name`,e.target.value),placeholder:`reviewer`})]}),(0,m.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`agentLabel`),(0,m.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:O.label,disabled:q,onChange:e=>Z(`label`,e.target.value),placeholder:d(`agentLabelPlaceholder`)})]})]}),G?(0,m.jsxs)(`div`,{className:`rounded-xl border border-border bg-muted/20 px-3 py-2 text-sm`,children:[(0,m.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:d(`agentSourcePath`)}),(0,m.jsx)(`div`,{className:`mt-1 truncate font-mono text-xs text-foreground`,title:G.source?`${G.source}${G.relativePath?` · ${G.relativePath}`:``}`:void 0,children:G.source?`${G.source}${G.relativePath?` · ${G.relativePath}`:``}`:G.builtin?d(`builtinAgent`):`-`})]}):null,(0,m.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`agentDescription`),(0,m.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:O.description,disabled:q,onChange:e=>Z(`description`,e.target.value)})]}),(0,m.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`agentSystemPrompt`),(0,m.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:O.systemPrompt,disabled:q,onChange:e=>Z(`systemPrompt`,e.target.value)})]}),(0,m.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,m.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`agentModelMode`),(0,m.jsxs)(`select`,{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:O.modelMode,disabled:J,onChange:e=>Z(`modelMode`,e.target.value),children:[(0,m.jsx)(`option`,{value:`inherit`,children:d(`agentModelInherit`)}),(0,m.jsx)(`option`,{value:`fixed`,children:d(`agentModelFixed`)})]})]}),(0,m.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`agentFixedModel`),(0,m.jsxs)(`select`,{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:O.fixedModelValue,disabled:J||O.modelMode!==`fixed`,onChange:e=>Z(`fixedModelValue`,e.target.value),children:[(0,m.jsx)(`option`,{value:``,children:d(`agentModelInherit`)}),L.map(e=>(0,m.jsx)(`option`,{value:y(e),children:se(e)},y(e)))]})]})]}),(0,m.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`agentThinkingLevel`),(0,m.jsxs)(`select`,{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:X&&O.thinkingLevel!==`inherit`?`off`:O.thinkingLevel,disabled:q||X,onChange:e=>Z(`thinkingLevel`,e.target.value),children:[(0,m.jsx)(`option`,{value:`inherit`,children:d(`agentThinkingInherit`)}),(0,m.jsx)(`option`,{value:`off`,children:d(`thinkingOff`)}),(0,m.jsx)(`option`,{value:`low`,children:d(`thinkingLow`)}),(0,m.jsx)(`option`,{value:`medium`,children:d(`thinkingMedium`)}),(0,m.jsx)(`option`,{value:`high`,children:d(`thinkingHigh`)}),(0,m.jsx)(`option`,{value:`xhigh`,children:d(`thinkingXHigh`)})]}),(0,m.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:d(X?`agentThinkingUnsupported`:`agentThinkingDescription`)})]}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`mb-2 text-sm font-medium text-foreground`,children:d(`allowedTools`)}),(0,m.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:s.map(e=>(0,m.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,m.jsx)(`input`,{type:`checkbox`,className:`mt-1`,disabled:q,checked:O.allowedTools.includes(e.name),onChange:()=>he(e.name)}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),(0,m.jsx)(`span`,{className:`ml-2 font-mono text-xs text-muted-foreground`,children:e.name}),e.riskLevel===`dangerous`?(0,m.jsx)(`span`,{className:`ml-2 rounded-full bg-amber-500/10 px-2 py-0.5 text-xs text-amber-700`,children:d(`highRiskTool`)}):null,(0,m.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:e.description})]})]},e.name))})]}),(0,m.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,m.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`maxRuntimeMs`),(0,m.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:O.maxRuntimeMs,disabled:q,onChange:e=>Z(`maxRuntimeMs`,e.target.value)})]}),(0,m.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`maxToolCalls`),(0,m.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:O.maxToolCalls,disabled:q,onChange:e=>Z(`maxToolCalls`,e.target.value)})]})]}),(0,m.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:O.enabledAsSubagent,disabled:q,onChange:e=>Z(`enabledAsSubagent`,e.target.checked)}),d(`enabledAsSubagent`)]}),R?(0,m.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:R}):null]})}),(0,m.jsxs)(`div`,{className:`quickforge-settings-divider flex justify-end gap-2 px-5 py-4`,children:[(0,m.jsx)(u,{variant:`outline`,onClick:$,disabled:A||P,children:d(`cancel`)}),(0,m.jsx)(u,{onClick:ve,disabled:A||P||J||!G?.builtin&&!C(O)||O.modelMode===`fixed`&&!O.fixedModelValue,children:d(`save`)})]})]})]}):(0,m.jsxs)(`div`,{className:`quickforge-settings-stack`,children:[(0,m.jsxs)(`section`,{className:`quickforge-settings-section`,"aria-label":d(`agentsTab`),children:[(0,m.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,m.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,m.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,m.jsx)(i,{className:`size-4 text-primary`}),d(`agentsTab`)]}),(0,m.jsx)(`div`,{className:`quickforge-settings-row-description`,children:d(`agentsDescription`)})]}),(0,m.jsx)(`button`,{className:`quickforge-settings-button quickforge-settings-button-primary`,type:`button`,onClick:ge,children:d(`createAgent`)})]}),R?(0,m.jsx)(`div`,{className:`quickforge-settings-alert quickforge-settings-warning-attached`,children:R}):null,e.length===0?(0,m.jsx)(`div`,{className:`quickforge-settings-empty-row`,children:d(`loading`)}):e.map(e=>(0,m.jsxs)(`div`,{className:`quickforge-settings-list-item quickforge-agent-profile-row`,role:`button`,tabIndex:0,onClick:()=>Q(e),onKeyDown:t=>{t.target===t.currentTarget&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),Q(e))},children:[(0,m.jsx)(`div`,{className:`quickforge-settings-list-item-main quickforge-agent-profile-row-main`,children:(0,m.jsxs)(`div`,{className:`quickforge-agent-profile-summary`,children:[(0,m.jsx)(`span`,{className:`quickforge-agent-profile-label`,title:e.label,children:e.label}),e.description?(0,m.jsx)(`span`,{className:`quickforge-agent-profile-description`,title:e.description,children:e.description}):null]})}),(0,m.jsxs)(`div`,{className:`quickforge-settings-list-item-actions`,onClick:e=>e.stopPropagation(),children:[(0,m.jsxs)(`label`,{className:`quickforge-settings-switch`,"aria-disabled":e.builtin||e.readonly?`true`:`false`,title:e.enabledAsSubagent?d(`disableAsSubagent`):d(`enableAsSubagent`),children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:e.enabledAsSubagent,disabled:e.builtin||e.readonly,onChange:()=>void ye(e)}),(0,m.jsx)(`span`,{"aria-hidden":`true`})]}),(0,m.jsx)(`button`,{className:`quickforge-settings-icon-action`,type:`button`,onClick:t=>me(t,e.id),title:d(`moreActions`),"aria-label":d(`moreActions`),"aria-haspopup":`menu`,"aria-expanded":B===e.id,children:(0,m.jsx)(ee,{className:`size-4`})})]})]},e.id))]}),K&&H?(0,oe.createPortal)((0,m.jsxs)(`div`,{className:`fixed z-50 w-36 overflow-hidden rounded-xl border border-border bg-popover py-1 text-sm shadow-quickforge`,style:{left:H.left,top:H.top},role:`menu`,"aria-label":d(`moreActions`),onClick:e=>e.stopPropagation(),children:[(0,m.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`,type:`button`,role:`menuitem`,disabled:K.readonly&&!K.builtin,onClick:()=>{V(null),U(null),Q(K)},children:[(0,m.jsx)(t,{className:`size-3.5`}),K.builtin?d(`builtinAgentModelSettings`):d(`editTask`)]}),(0,m.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`,type:`button`,role:`menuitem`,disabled:K.builtin||K.readonly,onClick:()=>{V(null),U(null),be(K)},children:[(0,m.jsx)(a,{className:`size-3.5`}),d(`delete`)]})]}),document.body):null]})}export{T as AgentProfilesPage};
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Ot as t,U as n}from"./icons-ko_i0WpN.js";import{n as r,t as i}from"./react-vendor-2RKYr-A4.js";import{d as a,p as o,t as s}from"./lit-vendor-Dr3cpBGF.js";import{g as c,h as l,y as u}from"./pi-web-ui-DoRGtREc.js";import{t as d}from"./logger-B65Akg8A.js";import{H as f,K as p,L as m,U as h,W as g,mt as _,r as v,u as y}from"./index-B8Awq5FV.js";import{t as b}from"./plugin-api-BbUkYm3Y.js";import{n as x,r as S,t as C}from"./mermaid-renderer-BmbSAmpG.js";var w=e(t(),1);function T(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function E(e,t,n){if(!e||e.isError||t||!T(e.details))return``;let r=e.details.action,i=e.details.status,a=e.details.markdown;if(typeof a!=`string`)return``;if(r===`read`){if(a)return a;if(i===`empty`||i===void 0)return n(`memoryContentEmpty`)}return r===`write`&&(i===`saved`||i===void 0)?n(`memoryContentSaved`):``}function D(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function ee(e){let t=new Set;for(let n of e)!D(n)||n.role!==`assistant`||!Array.isArray(n.content)||n.content.forEach(e=>{D(e)&&e.type===`toolCall`&&typeof e.id==`string`&&t.add(e.id)});return e.filter(e=>D(e)&&(e.role===`assistant`||e.role===`toolResult`&&typeof e.toolCallId==`string`&&t.has(e.toolCallId)))}var O=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.(?:png|jpg|webp|gif)$/i,k=new Set([`image/png`,`image/jpeg`,`image/webp`,`image/gif`]);function A(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function j(e){if(!A(e)||e.type!==`generated_image_result`||typeof e.sessionId!=`string`||!e.sessionId||typeof e.prompt!=`string`||typeof e.model!=`string`||!Array.isArray(e.assets))return null;let t=e.assets.flatMap(e=>!A(e)||typeof e.assetId!=`string`||!O.test(e.assetId)||typeof e.mimeType!=`string`||!k.has(e.mimeType)||typeof e.size!=`number`||!Number.isFinite(e.size)||e.size<0?[]:[{assetId:e.assetId,mimeType:e.mimeType,size:e.size}]);return t.length?{type:`generated_image_result`,sessionId:e.sessionId,prompt:e.prompt,model:e.model,assets:t,...typeof e.text==`string`&&e.text?{text:e.text}:{}}:null}function te(e,t,n=window.location.pathname){let r=n.match(/^\/share\/([^/]+)\/?$/)?.[1];return r?`/api/shared/${encodeURIComponent(decodeURIComponent(r))}/assets/${encodeURIComponent(t.assetId)}`:`/api/session-assets/${encodeURIComponent(e.sessionId)}/${encodeURIComponent(t.assetId)}`}var M={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`},N={minHeight:`1.35em`,padding:`0 0.75rem`,whiteSpace:`pre`},P={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 F(e,t){let n=R(e?.details)?e.details:void 0;return e?.isError||n?.aborted===!0||n?.timedOut===!0?`error`:t?`running`:e?`done`:`called`}function I(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 L(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{Ft as t,q as n}from"./icons-pPRMD2tE.js";import{n as r,t as i}from"./react-vendor-CLbWF1Oy.js";import{d as a,p as o,t as s}from"./lit-vendor-Dr3cpBGF.js";import{g as c,h as l,y as u}from"./pi-web-ui-DoRGtREc.js";import{t as d}from"./logger-B65Akg8A.js";import{H as f,K as p,L as m,U as h,W as g,mt as _,r as v,u as y}from"./index-BSXpUDCq.js";import{t as b}from"./plugin-api-BbUkYm3Y.js";import{n as x,r as S,t as C}from"./mermaid-renderer-BmbSAmpG.js";var w=e(t(),1);function T(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function E(e,t,n){if(!e||e.isError||t||!T(e.details))return``;let r=e.details.action,i=e.details.status,a=e.details.markdown;if(typeof a!=`string`)return``;if(r===`read`){if(a)return a;if(i===`empty`||i===void 0)return n(`memoryContentEmpty`)}return r===`write`&&(i===`saved`||i===void 0)?n(`memoryContentSaved`):``}function D(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function ee(e){let t=new Set;for(let n of e)!D(n)||n.role!==`assistant`||!Array.isArray(n.content)||n.content.forEach(e=>{D(e)&&e.type===`toolCall`&&typeof e.id==`string`&&t.add(e.id)});return e.filter(e=>D(e)&&(e.role===`assistant`||e.role===`toolResult`&&typeof e.toolCallId==`string`&&t.has(e.toolCallId)))}var O=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.(?:png|jpg|webp|gif)$/i,k=new Set([`image/png`,`image/jpeg`,`image/webp`,`image/gif`]);function A(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function j(e){if(!A(e)||e.type!==`generated_image_result`||typeof e.sessionId!=`string`||!e.sessionId||typeof e.prompt!=`string`||typeof e.model!=`string`||!Array.isArray(e.assets))return null;let t=e.assets.flatMap(e=>!A(e)||typeof e.assetId!=`string`||!O.test(e.assetId)||typeof e.mimeType!=`string`||!k.has(e.mimeType)||typeof e.size!=`number`||!Number.isFinite(e.size)||e.size<0?[]:[{assetId:e.assetId,mimeType:e.mimeType,size:e.size}]);return t.length?{type:`generated_image_result`,sessionId:e.sessionId,prompt:e.prompt,model:e.model,assets:t,...typeof e.text==`string`&&e.text?{text:e.text}:{}}:null}function te(e,t,n=window.location.pathname){let r=n.match(/^\/share\/([^/]+)\/?$/)?.[1];return r?`/api/shared/${encodeURIComponent(decodeURIComponent(r))}/assets/${encodeURIComponent(t.assetId)}`:`/api/session-assets/${encodeURIComponent(e.sessionId)}/${encodeURIComponent(t.assetId)}`}var M={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`},N={minHeight:`1.35em`,padding:`0 0.75rem`,whiteSpace:`pre`},P={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 F(e,t){let n=R(e?.details)?e.details:void 0;return e?.isError||n?.aborted===!0||n?.timedOut===!0?`error`:t?`running`:e?`done`:`called`}function I(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 L(e){return e?.content?.filter(e=>e.type===`text`).map(e=>e.text??``).join(`
2
2
  `)??``}function R(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function ne(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 re(e,t,n){let r=R(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}`,ne(r,n),``,`STDOUT:`,a||`(empty)`,``,`STDERR:`,o||`(empty)`].join(`
3
3
  `)}function z(e,t,n,r){let i=L(n);return e===`manage_global_memory`?E(n,r,_)||i:i||(e===`run_command`?re(t,n?.details,r):``)}function B(e,t){return R(e)&&typeof e[t]==`string`?e[t]:``}function ie(e,t,n){if(!t&&!n?.details)return``;if(e===`run_command`&&typeof t?.command==`string`)return t.command;if(e===`generate_image`){let e=typeof t?.prompt==`string`?t.prompt.trim():``;return e.length>100?`${e.slice(0,100)}…`:e}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:R(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:B(n?.details,`query`),r=typeof t?.path==`string`&&t.path?t.path:B(n?.details,`path`)||`.`,i=t?.regex||R(n?.details)&&R(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 ae(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 oe(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 se(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 ce(e,t,n){let r=n.getAttribute(`aria-label`)||_(`terminateCommand`);n.disabled=!0,n.setAttribute(`aria-label`,_(`commandTerminateRequested`)),n.setAttribute(`title`,_(`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`,_(`terminateCommandTitle`))}}function le(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 ue(e){return e.startsWith(`+++`)||e.startsWith(`---`)?{...N,background:`color-mix(in oklab, var(--muted) 48%, transparent)`,color:`color-mix(in oklab, var(--muted-foreground) 88%, transparent)`}:e.startsWith(`@@`)?{...N,background:`color-mix(in oklab, rgb(37 99 235) 10%, transparent)`,color:`rgb(37 99 235)`}:e.startsWith(`+`)?{...N,background:`color-mix(in oklab, rgb(34 197 94) 16%, transparent)`,color:`rgb(22 101 52)`}:e.startsWith(`-`)?{...N,background:`color-mix(in oklab, rgb(239 68 68) 14%, transparent)`,color:`rgb(153 27 27)`}:{...N,color:`var(--foreground)`}}function de(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="quickforge-tool-meta-hover shrink-0 inline-flex items-center gap-1" title="+${n} -${r}">
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{L as t,Ot as n,_t as r,b as i,i as a,r as o,u as s,y as c}from"./icons-ko_i0WpN.js";import{n as l}from"./react-vendor-2RKYr-A4.js";import{mt as u,ut as d}from"./index-B8Awq5FV.js";import{n as f,r as p,t as m}from"./plugin-api-BbUkYm3Y.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`?u(`pluginStatusLoaded`):e===`disabled`?u(`pluginStatusDisabled`):e===`error`?u(`pluginStatusError`):e}function y(e){switch(e){case`openai-documents`:return{label:u(`pluginOpenaiDocumentsName`),description:u(`pluginOpenaiDocumentsDescription`)};case`openai-spreadsheets`:return{label:u(`pluginOpenaiSpreadsheetsName`),description:u(`pluginOpenaiSpreadsheetsDescription`)};case`openai-presentations`:return{label:u(`pluginOpenaiPresentationsName`),description:u(`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||u(`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:u(`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:u(`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:u(`pluginsSaveFailed`))}finally{T(null)}};return(0,g.jsx)(`div`,{className:`quickforge-settings-stack`,children:(0,g.jsxs)(`section`,{className:`quickforge-settings-section`,"aria-label":u(`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)(i,{className:`size-4 text-primary`}),u(`plugins`)]}),(0,g.jsx)(`div`,{className:`quickforge-settings-row-description`,children:u(`pluginsDescription`)}),(0,g.jsxs)(`div`,{className:`quickforge-settings-meta`,children:[(0,g.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:u(`pluginsCount`,j)}),(0,g.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-info`,children:u(`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)(t,{className:`mr-2 size-4 animate-spin`}):(0,g.jsx)(c,{className:`mr-2 size-4`}),u(`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`}),u(`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)(t,{className:`size-4 animate-spin`}),u(`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:u(`noPlugins`)}),(0,g.jsx)(`div`,{className:`quickforge-settings-row-description`,children:u(`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 t=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":t,children:[(0,g.jsx)(r,{className:d(`quickforge-settings-expand-chevron size-4`,t&&`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:d(`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`}),u(`pluginToolsCount`,{count:e.tools.length})]}),(0,g.jsxs)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:[(0,g.jsx)(s,{className:`size-3`}),u(`pluginPermissionsCount`,{count:e.permissions.length})]}),(0,g.jsx)(`span`,{className:d(`quickforge-settings-badge`,e.enabled?`quickforge-settings-badge-success`:`quickforge-settings-badge-muted`),children:e.enabled?u(`enabled`):u(`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`})]})})]}),t?(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`}),u(`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:u(`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)(s,{className:`size-4 text-muted-foreground`}),u(`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:u(`pluginNoPermissions`)}),(0,g.jsx)(`div`,{className:`quickforge-settings-row-description mt-3`,children:u(`pluginTrustedNotice`)})]})]}):null]},e.name)})]})})}export{C as PluginsPage};
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{B as t,Ct as n,Ft as r,b as i,i as a,r as o,u as s,x as c}from"./icons-pPRMD2tE.js";import{n as l}from"./react-vendor-CLbWF1Oy.js";import{mt as u,ut as d}from"./index-BSXpUDCq.js";import{n as f,r as p,t as m}from"./plugin-api-BbUkYm3Y.js";var h=e(r(),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`?u(`pluginStatusLoaded`):e===`disabled`?u(`pluginStatusDisabled`):e===`error`?u(`pluginStatusError`):e}function y(e){switch(e){case`openai-documents`:return{label:u(`pluginOpenaiDocumentsName`),description:u(`pluginOpenaiDocumentsDescription`)};case`openai-spreadsheets`:return{label:u(`pluginOpenaiSpreadsheetsName`),description:u(`pluginOpenaiSpreadsheetsDescription`)};case`openai-presentations`:return{label:u(`pluginOpenaiPresentationsName`),description:u(`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||u(`noDescription`)}function S(e){return(e.label||e.name||e.quickForgeName).replace(/^OpenAI\s+/i,``)}function C({onChanged:e}){let[r,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:u(`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:u(`pluginsLoadFailed`))}).finally(()=>{e||C(!1)}),()=>{e=!0}},[]);let j=(0,h.useMemo)(()=>{let e=r?.plugins||[];return{total:e.length,enabled:e.filter(e=>e.enabled).length,tools:e.reduce((e,t)=>e+t.tools.length,0)}},[r]),M=(0,h.useMemo)(()=>r?.plugins||[],[r]),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:u(`pluginsSaveFailed`))}finally{T(null)}};return(0,g.jsx)(`div`,{className:`quickforge-settings-stack`,children:(0,g.jsxs)(`section`,{className:`quickforge-settings-section`,"aria-label":u(`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)(c,{className:`size-4 text-primary`}),u(`plugins`)]}),(0,g.jsx)(`div`,{className:`quickforge-settings-row-description`,children:u(`pluginsDescription`)}),(0,g.jsxs)(`div`,{className:`quickforge-settings-meta`,children:[(0,g.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:u(`pluginsCount`,j)}),(0,g.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-info`,children:u(`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)(t,{className:`mr-2 size-4 animate-spin`}):(0,g.jsx)(i,{className:`mr-2 size-4`}),u(`pluginsReload`)]})]}),O?(0,g.jsx)(`div`,{className:`quickforge-settings-alert quickforge-settings-warning-attached`,children:O}):null,r?.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`}),u(`pluginDiscoveryErrors`)]}),r.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&&!r?(0,g.jsxs)(`div`,{className:`quickforge-settings-empty-row inline-flex items-center gap-2`,children:[(0,g.jsx)(t,{className:`size-4 animate-spin`}),u(`loadingPlugins`)]}):null,!y&&r&&r.plugins.length===0?(0,g.jsxs)(`div`,{className:`quickforge-settings-empty-row`,children:[(0,g.jsx)(`div`,{className:`quickforge-settings-row-title`,children:u(`noPlugins`)}),(0,g.jsx)(`div`,{className:`quickforge-settings-row-description`,children:u(`noPluginsDescription`)}),(0,g.jsx)(`div`,{className:`quickforge-settings-meta`,children:(r.searchPaths||[]).map(e=>(0,g.jsx)(`code`,{className:`quickforge-settings-command-name`,children:e},e))})]}):null,M.map(e=>{let t=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":t,children:[(0,g.jsx)(n,{className:d(`quickforge-settings-expand-chevron size-4`,t&&`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:d(`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`}),u(`pluginToolsCount`,{count:e.tools.length})]}),(0,g.jsxs)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:[(0,g.jsx)(s,{className:`size-3`}),u(`pluginPermissionsCount`,{count:e.permissions.length})]}),(0,g.jsx)(`span`,{className:d(`quickforge-settings-badge`,e.enabled?`quickforge-settings-badge-success`:`quickforge-settings-badge-muted`),children:e.enabled?u(`enabled`):u(`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`})]})})]}),t?(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`}),u(`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:u(`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)(s,{className:`size-4 text-muted-foreground`}),u(`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:u(`pluginNoPermissions`)}),(0,g.jsx)(`div`,{className:`quickforge-settings-row-description mt-3`,children:u(`pluginTrustedNotice`)})]})]}):null]},e.name)})]})})}export{C as PluginsPage};
@@ -0,0 +1,2 @@
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Dt as t,E as n,Ft as r,Mt as i,Ot as ee,Y as te,_ as ne,a as re,c as ie,gt as ae,it as oe,mt as se,nt as ce,t as le}from"./icons-pPRMD2tE.js";import{n as a}from"./react-vendor-CLbWF1Oy.js";import{$ as ue,Q as de,V as fe,Z as pe,et as me,lt as o,mt as s,st as he,tt as ge,ut as c}from"./index-BSXpUDCq.js";var l=e(r(),1),u=a(),_e=[{value:`off`,label:()=>s(`thinkingOff`)},{value:`low`,label:()=>s(`thinkingLow`)},{value:`medium`,label:()=>s(`thinkingMedium`)},{value:`high`,label:()=>s(`thinkingHigh`)},{value:`xhigh`,label:()=>s(`thinkingXHigh`)}];function ve(e){return`${e.provider} / ${e.id}`}function ye(e,t){return!!(e&&t&&e.api===t.api&&e.provider===t.provider&&e.id===t.id)}function d(e){return String(e).padStart(2,`0`)}function f(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:`${t.getFullYear()}-${d(t.getMonth()+1)}-${d(t.getDate())} ${d(t.getHours())}:${d(t.getMinutes())}`}function be(e,t=20){let n=String(e||``).trim();return n.length>t?`${n.slice(0,t)}...`:n}function xe(){return{scheduleText:``,title:``,instruction:``,cronExpression:``,scheduleRule:``,nextRunAt:``,enabled:!0,agentId:``,executionMode:`serial`}}function p(){return{taskId:``,status:``,trigger:``,keyword:``,startedFrom:``,startedTo:``,page:1,pageSize:10}}function Se(e){return{scheduleText:[e.scheduleRule,e.instruction].filter(Boolean).join(`
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 Ce(e,t){return{...t,title:e.title,instruction:e.instruction,cronExpression:e.cronExpression??``,scheduleRule:e.scheduleRule,nextRunAt:e.nextRunAt,enabled:t.enabled}}function we(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 m(e){return!!(e.currentRunId||e.currentRunIds?.length)}function Te(e){return(e.executionMode??`serial`)===`parallel`||!m(e)}function Ee(e){return s(e===`parallel`?`taskExecutionModeParallel`:`taskExecutionModeSerial`)}function De(e){return!!(e.title.trim()&&e.instruction.trim()&&e.cronExpression.trim())}function Oe(e){return s(e===`enabled`?`taskEnabled`:e===`running`?`taskRunning`:e===`paused`?`taskPaused`:e===`completed`?`taskFinished`:e===`success`?`executionSuccess`:`taskFailed`)}function ke(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 h(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 g({onOpenSession:e}){let[r,a]=(0,l.useState)([]),[d,g]=(0,l.useState)(`tasks`),[_,v]=(0,l.useState)(()=>xe()),[y,Ae]=(0,l.useState)(null),[b,x]=(0,l.useState)(null),[S,C]=(0,l.useState)(null),[w,T]=(0,l.useState)(!1),[E,D]=(0,l.useState)(null),[je,O]=(0,l.useState)(``),[k,A]=(0,l.useState)(!1),[j,M]=(0,l.useState)(``),[N,Me]=(0,l.useState)([]),[P,F]=(0,l.useState)(),[I,L]=(0,l.useState)(`off`),[R,Ne]=(0,l.useState)([]),[Pe,z]=(0,l.useState)(``),[B,V]=(0,l.useState)(()=>p()),[H,U]=(0,l.useState)(()=>p()),[W,Fe]=(0,l.useState)({runs:[],total:0,page:1,pageSize:10}),[Ie,Le]=(0,l.useState)(!1),[Re,ze]=(0,l.useState)(null),[Be,Ve]=(0,l.useState)([]),He=R[0]?.id??``;(0,l.useEffect)(()=>{if(!S)return;let e=()=>C(null);return window.addEventListener(`click`,e),window.addEventListener(`blur`,e),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`blur`,e)}},[S]);async function Ue(){a((await h(`/api/scheduled-tasks`)).tasks)}async function G(e=H){Le(!0),M(``);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),Fe(await h(`/api/scheduled-tasks/runs?${t.toString()}`))}catch(e){M(e instanceof Error?e.message:s(`requestFailed`))}finally{Le(!1)}}(0,l.useEffect)(()=>{let e=!1;async function t(){try{let t=await h(`/api/project`);if(e)return;Ne(t.projects??[])}catch{}}return t(),()=>{e=!0}},[]),(0,l.useEffect)(()=>{let e=!1;async function t(){try{let t=await ue(),n=await de(t),r=await me(t),i=r.model??await ge(t)??n[0];if(e)return;Me(n),F(i),L(r.thinkingLevel??pe(i))}catch(t){e||M(t instanceof Error?t.message:s(`requestFailed`))}}return t(),()=>{e=!0}},[]),(0,l.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await h(`/api/scheduled-tasks`);e||a(t.tasks)}catch(t){e||M(t instanceof Error?t.message:s(`requestFailed`))}};t();let n=window.setInterval(t,10*1e3);return()=>{e=!0,window.clearInterval(n)}},[]),(0,l.useEffect)(()=>{let e=!1;async function t(){try{let t=await h(`/api/agent-profiles`);if(e)return;Ve(t.agents)}catch(t){e||M(t instanceof Error?t.message:s(`requestFailed`))}}return t(),()=>{e=!0}},[]);let We=(0,l.useMemo)(()=>r.find(e=>e.id===y),[y,r]),K=(0,l.useMemo)(()=>r.find(e=>e.id===b)??null,[b,r]),Ge=(0,l.useMemo)(()=>r.filter(e=>e.status===`enabled`).length,[r]),q=Math.max(1,Math.ceil(W.total/W.pageSize));function J(e){return e?Be.find(t=>t.id===e||t.name===e)?.label??e:s(`defaultAgent`)}function Y(e,t){v(n=>({...n,[e]:t}))}function X(e,t){V(n=>({...n,[e]:t}))}function Z(){Ae(null),z(He),v(xe()),D(null),O(``),M(``)}function Ke(){Z(),T(!0)}function Q(){k||(T(!1),Z())}function qe(){let e={...B,page:1};V(e),U(e),G(e)}function Je(){let e=p();V(e),U(e),G(e)}function Ye(e){let t=Math.min(Math.max(1,e),q),n={...H,page:t};V(n),U(n),G(n)}function Xe(e){let t={...H,page:1,pageSize:e};V(t),U(t),G(t)}async function Ze(){let e=_.scheduleText.trim();if(e){A(!0),M(``);try{let t=await h(`/api/scheduled-tasks/parse`,{method:`POST`,body:JSON.stringify({instruction:e,model:P,thinkingLevel:I})});if(t.needMoreInfo||!t.task){O(t.question||`请补充任务信息。`),D(null);return}let n=t.task;O(``),D(n),v(e=>Ce(n,e))}catch(e){M(e instanceof Error?e.message:s(`requestFailed`))}finally{A(!1)}}}async function Qe(){if(De(_)){A(!0),M(``);try{let e=R.find(e=>e.id===Pe),t={task:we(_),model:P,thinkingLevel:I,projectId:e?.id,projectName:e?.name};y?await h(`/api/scheduled-tasks/${encodeURIComponent(y)}`,{method:`PUT`,body:JSON.stringify(t)}):await h(`/api/scheduled-tasks`,{method:`POST`,body:JSON.stringify(t)}),Q(),await Ue(),d===`history`&&await G(H)}catch(e){M(e instanceof Error?e.message:s(`requestFailed`))}finally{A(!1)}}}function $e(e){C(null),Ae(e.id),v(Se(e)),D(null),O(``),M(``),z(e.projectId??``),e.model&&F(e.model),e.thinkingLevel&&L(e.thinkingLevel),T(!0)}async function $(e,t){if(M(``),C(null),!(t===`delete`&&!await fe({description:s(`confirmDeleteTask`),confirmLabel:s(`confirmDelete`),cancelLabel:s(`cancel`),variant:`destructive`})))try{t===`delete`?(await h(`/api/scheduled-tasks/${encodeURIComponent(e)}`,{method:`DELETE`}),y===e&&Q(),b===e&&x(null)):await h(`/api/scheduled-tasks/${encodeURIComponent(e)}/${t}`,{method:`POST`}),await Ue(),d===`history`&&await G(H)}catch(e){M(e instanceof Error?e.message:s(`requestFailed`))}}function et(t){return(0,u.jsxs)(`div`,{className:`mt-2 space-y-2 text-xs text-muted-foreground`,children:[t.sessionId?(0,u.jsx)(o,{variant:`outline`,size:`sm`,onClick:()=>e?.(t.sessionId),children:s(`viewConversation`)}):null,(0,u.jsxs)(`div`,{children:[s(`executionAgent`),t.agentLabel||J(t.agentId)]}),t.warning?(0,u.jsx)(`div`,{className:`text-amber-600`,children:t.warning}):null,t.inputContent?(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`font-medium text-foreground`,children:s(`runInputContent`)}),(0,u.jsx)(`pre`,{className:`mt-1 max-h-32 overflow-auto whitespace-pre-wrap`,children:t.inputContent})]}):null,t.aiResult||t.result?(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`font-medium text-foreground`,children:s(`runAiResult`)}),(0,u.jsx)(`pre`,{className:`mt-1 max-h-48 overflow-auto whitespace-pre-wrap`,children:t.aiResult||t.result})]}):null,t.errorMessage?(0,u.jsx)(`div`,{className:`text-destructive`,children:t.errorMessage}):null,t.durationMs?(0,u.jsxs)(`div`,{children:[s(`runDuration`),t.durationMs,`ms`]}):null]})}return(0,u.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[(0,u.jsxs)(`div`,{className:`border-b border-border px-6 py-5`,children:[(0,u.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-3`,children:w||K?(0,u.jsxs)(o,{variant:`outline`,onClick:()=>{w?Q():x(null)},children:[(0,u.jsx)(i,{className:`mr-1 size-4`}),s(`back`)]}):(0,u.jsx)(o,{onClick:Ke,children:s(`createTask`)})}),!w&&!K?(0,u.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,u.jsxs)(`button`,{type:`button`,className:c(`rounded-full px-4 py-2 text-sm font-medium transition-colors`,d===`tasks`?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:text-foreground`),onClick:()=>g(`tasks`),children:[s(`taskListTab`),` `,(0,u.jsx)(`span`,{className:`opacity-80`,children:r.length})]}),(0,u.jsx)(`button`,{type:`button`,className:c(`rounded-full px-4 py-2 text-sm font-medium transition-colors`,d===`history`?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:text-foreground`),onClick:()=>{g(`history`),G(H)},children:s(`executionHistoryTab`)})]}):null]}),(0,u.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-6`,children:(0,u.jsx)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:w?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-5 space-y-4`,children:[(0,u.jsxs)(`h2`,{className:`inline-flex items-center gap-1.5 text-base font-semibold text-foreground`,children:[s(We?`editTask`:`createTask`),(0,u.jsx)(he,{label:s(`quickAiParseTask`)})]}),(0,u.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[s(`taskScheduleDescriptionLabel`),(0,u.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:_.scheduleText,onChange:e=>Y(`scheduleText`,e.target.value),placeholder:s(`taskScheduleDescriptionPlaceholder`)})]}),(0,u.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,u.jsxs)(o,{onClick:Ze,disabled:k||!P||!_.scheduleText.trim(),children:[(0,u.jsx)(ie,{className:`mr-1 size-3.5`}),s(`aiParseTask`)]}),je?(0,u.jsx)(`span`,{className:`text-sm text-amber-600`,children:je}):null]}),(0,u.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,u.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[s(`taskTitleLabel`),(0,u.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:_.title,onChange:e=>Y(`title`,e.target.value),placeholder:s(`taskTitlePlaceholder`)})]}),(0,u.jsxs)(`div`,{className:`block text-sm font-medium text-foreground`,children:[s(`executionRule`),(0,u.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:_.scheduleRule||`-`})]}),(0,u.jsxs)(`div`,{className:`block text-sm font-medium text-foreground`,children:[`cron`,(0,u.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:_.cronExpression||`-`})]}),(0,u.jsxs)(`div`,{className:`block text-sm font-medium text-foreground`,children:[s(`nextExecutionTime`),(0,u.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:f(_.nextRunAt)})]}),(0,u.jsxs)(`label`,{className:`block text-sm font-medium text-foreground sm:col-span-2`,children:[(0,u.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[s(`taskExecutionMode`),(0,u.jsx)(he,{label:s(`taskExecutionModeHelp`)})]}),(0,u.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:_.executionMode,onChange:e=>Y(`executionMode`,e.target.value),children:[(0,u.jsx)(`option`,{value:`serial`,children:s(`taskExecutionModeSerial`)}),(0,u.jsx)(`option`,{value:`parallel`,children:s(`taskExecutionModeParallel`)})]})]}),(0,u.jsxs)(`label`,{className:`block text-sm font-medium text-foreground sm:col-span-2`,children:[s(`promptContentLabel`),(0,u.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:_.instruction,onChange:e=>Y(`instruction`,e.target.value),placeholder:s(`promptContentPlaceholder`)})]})]}),(0,u.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,u.jsx)(`input`,{type:`checkbox`,checked:_.enabled,onChange:e=>Y(`enabled`,e.target.checked)}),s(`taskEnabledSwitch`)]}),(0,u.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-xl border border-border bg-muted/20 px-2 py-2`,children:[(0,u.jsxs)(`span`,{className:`relative inline-flex items-center`,children:[(0,u.jsx)(ie,{className:`pointer-events-none absolute left-2 size-3.5 text-muted-foreground/70`}),(0,u.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:P?`${P.provider}\u0000${P.id}`:``,onChange:e=>{let t=N.find(t=>`${t.provider}\u0000${t.id}`===e.target.value);F(t),L(pe(t))},title:s(`taskModel`),children:[N.length===0?(0,u.jsx)(`option`,{value:``,children:s(`noModelAvailable`)}):null,N.map(e=>(0,u.jsxs)(`option`,{value:`${e.provider}\u0000${e.id}`,children:[ve(e),ye(e,P)?` ✓`:``]},`${e.provider}:${e.id}`))]})]}),(0,u.jsxs)(`span`,{className:`relative inline-flex items-center`,children:[(0,u.jsx)(t,{className:`pointer-events-none absolute left-2 size-3.5 text-muted-foreground/70`}),(0,u.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:I,onChange:e=>L(e.target.value),title:s(`taskThinking`),children:_e.map(e=>(0,u.jsx)(`option`,{value:e.value,children:e.label()},e.value))})]}),(0,u.jsxs)(`span`,{className:`relative inline-flex items-center`,children:[(0,u.jsx)(te,{className:`pointer-events-none absolute left-2 size-3.5 text-muted-foreground/70`}),(0,u.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:Pe,onChange:e=>z(e.target.value),title:s(`taskProjectLabel`),children:[(0,u.jsx)(`option`,{value:``,children:s(`noProjectBound`)}),R.map(e=>(0,u.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,u.jsxs)(`span`,{className:`relative inline-flex items-center`,children:[(0,u.jsx)(ee,{className:`pointer-events-none absolute left-2 size-3.5 text-muted-foreground/70`}),(0,u.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:_.agentId,onChange:e=>Y(`agentId`,e.target.value),title:s(`executionAgent`),children:[(0,u.jsx)(`option`,{value:``,children:s(`defaultAgent`)}),Be.map(e=>(0,u.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})]}),E?(0,u.jsxs)(`div`,{className:`rounded-xl border border-border bg-muted/30 p-3 text-sm`,children:[(0,u.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 font-medium text-foreground`,children:[(0,u.jsx)(ae,{className:`size-4 text-emerald-600`}),s(`aiParsed`)]}),(0,u.jsxs)(`div`,{className:`grid gap-2 text-muted-foreground sm:grid-cols-2`,children:[(0,u.jsxs)(`div`,{children:[s(`taskName`),(0,u.jsx)(`span`,{className:`text-foreground`,children:E.title})]}),(0,u.jsxs)(`div`,{children:[s(`executionRule`),(0,u.jsx)(`span`,{className:`text-foreground`,children:E.scheduleRule})]}),(0,u.jsxs)(`div`,{children:[`cron:`,(0,u.jsx)(`span`,{className:`font-mono text-foreground`,children:E.cronExpression??`-`})]}),(0,u.jsxs)(`div`,{children:[s(`nextExecutionTime`),(0,u.jsx)(`span`,{className:`text-foreground`,children:f(E.nextRunAt)})]}),(0,u.jsxs)(`div`,{className:`sm:col-span-2`,children:[s(`aiInstruction`),(0,u.jsx)(`span`,{className:`text-foreground`,children:E.instruction})]})]})]}):null,j?(0,u.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:j}):null]}),(0,u.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,u.jsx)(o,{variant:`outline`,onClick:Q,disabled:k,children:s(`cancel`)}),(0,u.jsx)(o,{onClick:Qe,disabled:k||!P||!De(_),children:s(We?`saveTask`:`confirmCreate`)})]})]}):K?(0,u.jsxs)(`div`,{className:`rounded-xl border border-border bg-card`,children:[(0,u.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-border px-5 py-4`,children:(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:K.title}),(0,u.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:K.scheduleRule})]})}),(0,u.jsx)(`div`,{className:`px-5 py-4`,children:(0,u.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`mb-1 font-medium text-foreground`,children:s(`taskContent`)}),(0,u.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:K.instruction})]}),(0,u.jsxs)(`div`,{className:`grid gap-3 text-muted-foreground sm:grid-cols-2`,children:[(0,u.jsxs)(`div`,{children:[s(`executionRule`),(0,u.jsx)(`span`,{className:`text-foreground`,children:K.scheduleRule})]}),(0,u.jsxs)(`div`,{children:[s(`taskExecutionMode`),`:`,(0,u.jsx)(`span`,{className:`text-foreground`,children:Ee(K.executionMode)})]}),(0,u.jsxs)(`div`,{children:[`cron:`,(0,u.jsx)(`span`,{className:`font-mono text-foreground`,children:K.cronExpression??`-`})]}),(0,u.jsxs)(`div`,{children:[s(`lastExecution`),(0,u.jsx)(`span`,{className:`text-foreground`,children:f(K.lastRunAt)})]}),(0,u.jsxs)(`div`,{children:[s(`nextExecution`),(0,u.jsx)(`span`,{className:`text-foreground`,children:f(K.nextRunAt)})]}),(0,u.jsxs)(`div`,{children:[s(`executionAgent`),(0,u.jsx)(`span`,{className:`text-foreground`,children:J(K.agentId)})]}),K.projectName?(0,u.jsxs)(`div`,{children:[s(`taskProject`),(0,u.jsx)(`span`,{className:`text-foreground`,children:K.projectName})]}):null,K.model?(0,u.jsxs)(`div`,{children:[s(`taskModel`),`:`,(0,u.jsx)(`span`,{className:`text-foreground`,children:ve(K.model)})]}):null,K.thinkingLevel?(0,u.jsxs)(`div`,{children:[s(`taskThinkingLevel`),(0,u.jsx)(`span`,{className:`text-foreground`,children:_e.find(e=>e.value===K.thinkingLevel)?.label()??K.thinkingLevel})]}):null,(0,u.jsxs)(`div`,{children:[s(`createdAt`),`:`,(0,u.jsx)(`span`,{className:`text-foreground`,children:f(K.createdAt)})]})]}),K.runs?.length>0?(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`mb-2 font-medium text-foreground`,children:s(`recentExecutions`)}),(0,u.jsx)(`div`,{className:`space-y-2`,children:K.runs.slice(0,5).map(e=>(0,u.jsxs)(`details`,{className:`rounded-lg border border-border bg-muted/20 p-2 text-xs text-muted-foreground`,children:[(0,u.jsxs)(`summary`,{className:`cursor-pointer text-foreground`,children:[f(e.startedAt),` · `,e.trigger===`manual`?s(`manualRun`):s(`autoRun`),` · `,Oe(e.status)]}),et(e)]},e.id))})]}):null]})}),(0,u.jsx)(`div`,{className:`border-t border-border px-5 py-4`,children:(0,u.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[K.lastSessionId?(0,u.jsx)(o,{variant:`outline`,onClick:()=>e?.(K.lastSessionId),children:s(`viewConversation`)}):null,(0,u.jsxs)(o,{variant:`outline`,disabled:!Te(K),onClick:()=>void $(K.id,`run`),children:[(0,u.jsx)(le,{className:`mr-1 size-3.5`}),s(`executeNow`)]}),(0,u.jsxs)(o,{variant:`outline`,disabled:m(K),onClick:()=>$e(K),children:[(0,u.jsx)(n,{className:`mr-1 size-3.5`}),s(`editTask`)]}),(0,u.jsxs)(o,{variant:`destructive`,disabled:m(K),onClick:()=>void $(K.id,`delete`),children:[(0,u.jsx)(re,{className:`mr-1 size-3.5`}),s(`deleteTask`)]})]})})]}):(0,u.jsxs)(u.Fragment,{children:[j?(0,u.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:j}):null,d===`tasks`?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{className:`rounded-xl border border-border bg-card p-4`,children:(0,u.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:s(`taskList`)}),(0,u.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`tasksCount`,{total:r.length,enabled:Ge})})]})})}),(0,u.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:r.length===0?(0,u.jsx)(`div`,{className:`rounded-lg px-3 py-3 text-center text-xs text-muted-foreground/55 md:col-span-2`,children:s(`noScheduledTasks`)}):r.map(e=>{let t=e.status===`enabled`,r=e.status===`completed`,i=m(e);return(0,u.jsxs)(`div`,{className:`relative cursor-pointer rounded-xl border border-border bg-card p-4 transition-colors hover:bg-muted/15`,onClick:()=>x(e.id),children:[(0,u.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,u.jsxs)(`div`,{className:`min-w-0`,children:[(0,u.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,u.jsx)(`h3`,{className:`truncate text-sm font-medium text-foreground/90`,children:e.title})}),(0,u.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:be(e.instruction,20)})]}),(0,u.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,onClick:e=>e.stopPropagation(),children:[(0,u.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,disabled:r,className:c(`relative h-6 w-11 rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-60`,t?`bg-emerald-500`:`bg-muted-foreground/30`),onClick:()=>void $(e.id,e.status===`paused`?`resume`:`pause`),title:e.status===`paused`?s(`enable`):s(`pauseTask`),children:(0,u.jsx)(`span`,{className:c(`absolute left-0.5 top-0.5 size-5 rounded-full bg-white shadow transition-transform`,t?`translate-x-5`:`translate-x-0`)})}),(0,u.jsxs)(`div`,{className:`relative`,children:[(0,u.jsx)(o,{variant:`ghost`,size:`icon`,onClick:()=>C(S===e.id?null:e.id),title:s(`moreActions`),children:(0,u.jsx)(oe,{className:`size-4`})}),S===e.id?(0,u.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,u.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:!Te(e),onClick:()=>void $(e.id,`run`),children:[(0,u.jsx)(le,{className:`size-3.5`}),s(`executeNow`)]}),(0,u.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:i,onClick:()=>$e(e),children:[(0,u.jsx)(n,{className:`size-3.5`}),s(`editTask`)]}),(0,u.jsxs)(`button`,{className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted`,onClick:()=>{C(null),x(e.id)},children:[(0,u.jsx)(ce,{className:`size-3.5`}),s(`viewDetails`)]}),(0,u.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:i,onClick:()=>void $(e.id,`delete`),children:[(0,u.jsx)(re,{className:`size-3.5`}),s(`deleteTask`)]})]}):null]})]})]}),(0,u.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,u.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,u.jsx)(se,{className:`size-3`}),e.scheduleRule]}),(0,u.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,u.jsx)(ee,{className:`size-3`}),J(e.agentId)]}),(0,u.jsxs)(`span`,{children:[s(`taskExecutionMode`),`:`,Ee(e.executionMode)]}),e.projectName?(0,u.jsxs)(`span`,{children:[s(`taskProject`),e.projectName]}):null]}),(0,u.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,u.jsxs)(`span`,{children:[s(`lastExecution`),f(e.lastRunAt)]}),(0,u.jsxs)(`span`,{children:[s(`nextExecution`),f(e.nextRunAt)]})]})]},e.id)})})]}):(0,u.jsxs)(`div`,{className:`space-y-4`,children:[(0,u.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4`,children:[(0,u.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-sm font-medium text-foreground`,children:[(0,u.jsx)(ne,{className:`size-4`}),s(`historyFilters`)]}),(0,u.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,u.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[s(`taskName`),(0,u.jsxs)(`select`,{className:`mt-1 h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground`,value:B.taskId,onChange:e=>X(`taskId`,e.target.value),children:[(0,u.jsx)(`option`,{value:``,children:s(`allTasks`)}),r.map(e=>(0,u.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,u.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[s(`status`),(0,u.jsxs)(`select`,{className:`mt-1 h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground`,value:B.status,onChange:e=>X(`status`,e.target.value),children:[(0,u.jsx)(`option`,{value:``,children:s(`allStatuses`)}),(0,u.jsx)(`option`,{value:`running`,children:s(`executionRunning`)}),(0,u.jsx)(`option`,{value:`success`,children:s(`executionSuccess`)}),(0,u.jsx)(`option`,{value:`failed`,children:s(`taskFailed`)})]})]}),(0,u.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[s(`triggerType`),(0,u.jsxs)(`select`,{className:`mt-1 h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground`,value:B.trigger,onChange:e=>X(`trigger`,e.target.value),children:[(0,u.jsx)(`option`,{value:``,children:s(`allTriggers`)}),(0,u.jsx)(`option`,{value:`schedule`,children:s(`autoRun`)}),(0,u.jsx)(`option`,{value:`manual`,children:s(`manualRun`)})]})]}),(0,u.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[s(`startTime`),(0,u.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:B.startedFrom,onChange:e=>X(`startedFrom`,e.target.value)})]}),(0,u.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[s(`endTime`),(0,u.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:B.startedTo,onChange:e=>X(`startedTo`,e.target.value)})]}),(0,u.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[s(`keyword`),(0,u.jsx)(`input`,{className:`mt-1 h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground`,value:B.keyword,onChange:e=>X(`keyword`,e.target.value),placeholder:s(`keywordPlaceholder`)})]})]}),(0,u.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,u.jsx)(o,{variant:`outline`,onClick:Je,children:s(`reset`)}),(0,u.jsx)(o,{onClick:qe,children:s(`query`)})]})]}),(0,u.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-card`,children:[(0,u.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,u.jsx)(`span`,{children:s(`taskName`)}),(0,u.jsx)(`span`,{children:s(`status`)}),(0,u.jsx)(`span`,{children:s(`triggerType`)}),(0,u.jsx)(`span`,{children:s(`startTime`)}),(0,u.jsx)(`span`,{children:s(`runDuration`)})]}),Ie?(0,u.jsx)(`div`,{className:`p-8 text-center text-sm text-muted-foreground`,children:s(`loading`)}):W.runs.length===0?(0,u.jsx)(`div`,{className:`p-8 text-center text-sm text-muted-foreground`,children:s(`noExecutionHistory`)}):W.runs.map(e=>(0,u.jsxs)(`div`,{className:`border-b border-border last:border-b-0`,children:[(0,u.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:()=>ze(Re===e.id?null:e.id),children:[(0,u.jsx)(`span`,{className:`min-w-0 truncate text-foreground`,children:e.taskTitle}),(0,u.jsx)(`span`,{children:(0,u.jsx)(`span`,{className:c(`rounded-full px-2 py-0.5 text-xs`,ke(e.status)),children:Oe(e.status)})}),(0,u.jsx)(`span`,{className:`text-muted-foreground`,children:e.trigger===`manual`?s(`manualRun`):s(`autoRun`)}),(0,u.jsx)(`span`,{className:`text-muted-foreground`,children:f(e.startedAt)}),(0,u.jsx)(`span`,{className:`text-muted-foreground`,children:e.durationMs?`${e.durationMs}ms`:`-`})]}),Re===e.id?(0,u.jsx)(`div`,{className:`border-t border-border bg-muted/20 px-4 py-3`,children:et(e)}):null]},`${e.taskId}:${e.id}`)),(0,u.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3 text-sm text-muted-foreground`,children:[(0,u.jsx)(`span`,{children:s(`paginationSummary`,{page:W.page,pages:q,total:W.total})}),(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(`select`,{className:`h-8 rounded-md border border-input bg-background px-2 text-sm`,value:W.pageSize,onChange:e=>Xe(Number(e.target.value)),children:[10,20,50,100].map(e=>(0,u.jsx)(`option`,{value:e,children:s(`pageSize`,{size:e})},e))}),(0,u.jsx)(o,{variant:`outline`,size:`sm`,disabled:W.page<=1,onClick:()=>Ye(W.page-1),children:s(`previousPage`)}),(0,u.jsx)(o,{variant:`outline`,size:`sm`,disabled:W.page>=q,onClick:()=>Ye(W.page+1),children:s(`nextPage`)})]})]})]})]})]})})})]})}export{g as ScheduledTasksPage};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AgentProfilesPage-DQ8URegq.js","assets/rolldown-runtime-DWdDZTNf.js","assets/index-B8Awq5FV.js","assets/pi-ai-Cr3rpCXT.js","assets/pi-web-ui-DoRGtREc.js","assets/lit-vendor-Dr3cpBGF.js","assets/css-utils-rkE68RDy.js","assets/icons-ko_i0WpN.js","assets/react-vendor-2RKYr-A4.js","assets/skills-dialog-MpoxntiV.js","assets/logger-B65Akg8A.js","assets/index-B2eauKpo.css","assets/mcp-servers-dialog-XE4K8PCO.js","assets/PluginsPage-B8bHMwfv.js","assets/plugin-api-BbUkYm3Y.js","assets/ScheduledTasksPage-AaUz5el2.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Ct as t,Et as n,Ot as r,St as i,Tt as a,b as o,bt as s,et as c,f as l,g as ee,h as u,k as d,l as f,ot as p,s as m,tt as h,xt as te,z as ne}from"./icons-ko_i0WpN.js";import{n as re,r as ie}from"./react-vendor-2RKYr-A4.js";import{p as g}from"./lit-vendor-Dr3cpBGF.js";import{m as _,x as v}from"./pi-web-ui-DoRGtREc.js";import{J as y}from"./pi-ai-Cr3rpCXT.js";import{t as b}from"./logger-B65Akg8A.js";import{B as x,C as ae,D as oe,E as se,F as ce,I as le,O as S,P as ue,Q as de,R as fe,S as pe,T as me,V as C,X as w,Z as he,at as ge,dt as _e,et as ve,ft as ye,it as T,j as be,k as E,lt as xe,mt as D,nt as Se,pt as Ce,rt as we,st as Te,ut as O,w as Ee,z as De}from"./index-B8Awq5FV.js";var k=e(r(),1),Oe={openai:{name:`OpenAI`,baseUrl:`https://api.openai.com/v1`,protocol:`openai-completions`,modelId:`gpt-4o`,supportsImages:!0},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:w.name,baseUrl:w.baseUrl,protocol:`openai-completions`,modelId:w.modelId,supportsImages:w.supportsImages}},ke=[{key:`openai`,label:D(`presetOpenai`)},{key:`deepseek`,label:D(`presetDeepseek`)},{key:`glm`,label:D(`presetGlm`)},{key:`ollama`,label:D(`presetOllama`)},{key:`litellm`,label:D(`presetLitellm`)},{key:`custom`,label:D(`presetCustom`)}],A=()=>({modelId:``,contextWindow:w.contextWindow,maxTokens:w.maxTokens,reasoning:!0,supportsImages:!1,open:!1}),j=()=>({name:w.name,baseUrl:w.baseUrl,apiKey:``,headerRows:[],protocol:`openai-completions`,models:[A()]}),Ae=class extends _{providers=[];form=j();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 D(`customModels`)}async loadProviders(){this.loading=!0,this.requestUpdate();try{this.providers=await v().customProviders.getAll()}catch(e){b.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=j(),this.apiKeyVisible=!1,this.advancedOpen=!1,this.activePreset=``,this.resetTestState(),this.formOpen=!0,this.requestUpdate()}async openEditForm(e){let t=await v().providerKeys.get(e.name)??e.apiKey??``,n=e.models??[],r=n.length>0?n.map(e=>({modelId:e.id,contextWindow:e.contextWindow??w.contextWindow,maxTokens:e.maxTokens??w.maxTokens,reasoning:e.reasoning===!0,supportsImages:e.input?.includes(`image`)===!0,open:!1})):[A()],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=j(),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,A()]},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:[A()]};else{let t=Oe[e];this.form={...this.form,name:t.name,baseUrl:t.baseUrl,protocol:t.protocol,models:[{...A(),modelId:t.modelId,supportsImages:t.supportsImages===!0,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=e.supportsImages===!0?[`text`,`image`]:[`text`],o=r.includes(`api.deepseek.com`);return Se({id:e.modelId,name:`${e.modelId} (${n})`,api:this.form.protocol,provider:n,baseUrl:r.replace(/\/$/,``),reasoning:i,input:a,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:Number(e.contextWindow)||w.contextWindow,maxTokens:Number(e.maxTokens)||w.maxTokens,headers:Object.keys(t).length>0?t:void 0,thinkingLevelMap:o&&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`,...o&&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=D(`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||D(`connectionFailed`))}catch(e){this.testResult=`fail`,this.testError=e?.message||D(`connectionFailed`)}finally{this.testing=!1,this.requestUpdate()}}async saveModel(){let e=this.form.name.trim(),t=this.form.baseUrl.trim();if(!e||!t){x(D(`fillProviderBaseUrlModel`));return}let n=this.form.models.filter(e=>e.modelId.trim());if(n.length===0){x(D(`atLeastOneModel`));return}let r=n.map(e=>e.modelId.trim());if(new Set(r).size!==r.length){x(D(`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??ge(),name:e,type:this.form.protocol,baseUrl:a[0].baseUrl,apiKey:o||void 0,models:a};try{let e=v();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){b.error(`Failed to save custom model:`,e),x(D(`saveCustomModelFailed`))}}async deleteProvider(e){if(await C({description:D(`confirmDeleteProvider`,{name:e.name}),confirmLabel:D(`confirmDelete`),cancelLabel:D(`cancel`),variant:`destructive`}))try{let t=v();await t.customProviders.delete(e.id),await t.providerKeys.delete(e.name),await this.loadProviders()}catch(e){b.error(`Failed to delete custom provider:`,e),x(D(`deleteFailed`))}}renderProvider(e){let t=e.models??[],n=t.length,r=e.type===`anthropic-messages`?`Anthropic Messages`:`OpenAI Compatible`;return g`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AgentProfilesPage-__uY0AvK.js","assets/rolldown-runtime-DWdDZTNf.js","assets/index-BSXpUDCq.js","assets/pi-ai-Cr3rpCXT.js","assets/pi-web-ui-DoRGtREc.js","assets/lit-vendor-Dr3cpBGF.js","assets/css-utils-rkE68RDy.js","assets/icons-pPRMD2tE.js","assets/react-vendor-CLbWF1Oy.js","assets/skills-dialog-D18mxNyW.js","assets/logger-B65Akg8A.js","assets/index-DpO7jEGP.css","assets/mcp-servers-dialog-CaQTvGiW.js","assets/PluginsPage-CKyWhlCo.js","assets/plugin-api-BbUkYm3Y.js","assets/ScheduledTasksPage-KtJoeJYt.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{A as t,Dt as n,Et as r,Ft as i,H as a,Mt as o,Nt as s,Ot as c,_ as ee,f as l,ft as u,h as d,kt as f,l as p,ot as m,s as h,st as te,x as ne}from"./icons-pPRMD2tE.js";import{n as re,r as ie}from"./react-vendor-CLbWF1Oy.js";import{p as g}from"./lit-vendor-Dr3cpBGF.js";import{m as _,x as v}from"./pi-web-ui-DoRGtREc.js";import{J as y}from"./pi-ai-Cr3rpCXT.js";import{t as b}from"./logger-B65Akg8A.js";import{B as x,C as ae,D as oe,E as se,F as ce,I as le,O as S,P as ue,Q as de,R as fe,S as pe,T as me,V as C,X as w,Z as he,at as ge,dt as _e,et as ve,ft as ye,it as T,j as be,k as E,lt as xe,mt as D,nt as Se,pt as Ce,rt as we,st as Te,ut as O,w as Ee,z as De}from"./index-BSXpUDCq.js";var k=e(i(),1),Oe={openai:{name:`OpenAI`,baseUrl:`https://api.openai.com/v1`,protocol:`openai-completions`,modelId:`gpt-4o`,supportsImages:!0},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:w.name,baseUrl:w.baseUrl,protocol:`openai-completions`,modelId:w.modelId,supportsImages:w.supportsImages}},ke=[{key:`openai`,label:D(`presetOpenai`)},{key:`deepseek`,label:D(`presetDeepseek`)},{key:`glm`,label:D(`presetGlm`)},{key:`ollama`,label:D(`presetOllama`)},{key:`litellm`,label:D(`presetLitellm`)},{key:`custom`,label:D(`presetCustom`)}],A=()=>({modelId:``,contextWindow:w.contextWindow,maxTokens:w.maxTokens,reasoning:!0,supportsImages:!1,open:!1}),j=()=>({name:w.name,baseUrl:w.baseUrl,apiKey:``,headerRows:[],protocol:`openai-completions`,models:[A()]}),Ae=class extends _{providers=[];form=j();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 D(`customModels`)}async loadProviders(){this.loading=!0,this.requestUpdate();try{this.providers=await v().customProviders.getAll()}catch(e){b.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=j(),this.apiKeyVisible=!1,this.advancedOpen=!1,this.activePreset=``,this.resetTestState(),this.formOpen=!0,this.requestUpdate()}async openEditForm(e){let t=await v().providerKeys.get(e.name)??e.apiKey??``,n=e.models??[],r=n.length>0?n.map(e=>({modelId:e.id,contextWindow:e.contextWindow??w.contextWindow,maxTokens:e.maxTokens??w.maxTokens,reasoning:e.reasoning===!0,supportsImages:e.input?.includes(`image`)===!0,open:!1})):[A()],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=j(),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,A()]},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:[A()]};else{let t=Oe[e];this.form={...this.form,name:t.name,baseUrl:t.baseUrl,protocol:t.protocol,models:[{...A(),modelId:t.modelId,supportsImages:t.supportsImages===!0,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=e.supportsImages===!0?[`text`,`image`]:[`text`],o=r.includes(`api.deepseek.com`);return Se({id:e.modelId,name:`${e.modelId} (${n})`,api:this.form.protocol,provider:n,baseUrl:r.replace(/\/$/,``),reasoning:i,input:a,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:Number(e.contextWindow)||w.contextWindow,maxTokens:Number(e.maxTokens)||w.maxTokens,headers:Object.keys(t).length>0?t:void 0,thinkingLevelMap:o&&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`,...o&&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=D(`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||D(`connectionFailed`))}catch(e){this.testResult=`fail`,this.testError=e?.message||D(`connectionFailed`)}finally{this.testing=!1,this.requestUpdate()}}async saveModel(){let e=this.form.name.trim(),t=this.form.baseUrl.trim();if(!e||!t){x(D(`fillProviderBaseUrlModel`));return}let n=this.form.models.filter(e=>e.modelId.trim());if(n.length===0){x(D(`atLeastOneModel`));return}let r=n.map(e=>e.modelId.trim());if(new Set(r).size!==r.length){x(D(`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??ge(),name:e,type:this.form.protocol,baseUrl:a[0].baseUrl,apiKey:o||void 0,models:a};try{let e=v();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){b.error(`Failed to save custom model:`,e),x(D(`saveCustomModelFailed`))}}async deleteProvider(e){if(await C({description:D(`confirmDeleteProvider`,{name:e.name}),confirmLabel:D(`confirmDelete`),cancelLabel:D(`cancel`),variant:`destructive`}))try{let t=v();await t.customProviders.delete(e.id),await t.providerKeys.delete(e.name),await this.loadProviders()}catch(e){b.error(`Failed to delete custom provider:`,e),x(D(`deleteFailed`))}}renderProvider(e){let t=e.models??[],n=t.length,r=e.type===`anthropic-messages`?`Anthropic Messages`:`OpenAI Compatible`;return g`
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">
@@ -733,7 +733,7 @@ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Ct as t,Et as n,Ot as
733
733
  ${this.message?g`<div class="quickforge-settings-message">${this.message}</div>`:null}
734
734
  ${this.error?g`<div class="quickforge-settings-alert">${this.error}</div>`:null}
735
735
  </div>
736
- `}},R=`quickforge-memory-settings-tab`;customElements.get(R)||customElements.define(R,at);function ot(){return document.createElement(R)}var st=`quickforge-backup`,z=[{id:`settings`,countKey:`settings`,label:()=>D(`restoreSettings`),description:()=>D(`restoreSettingsDescription`)},{id:`mcp`,countKey:`mcp`,label:()=>D(`restoreMcp`),description:()=>D(`restoreMcpDescription`)},{id:`providerKeys`,countKey:`providerKeys`,label:()=>D(`restoreProviderKeys`),description:()=>D(`restoreProviderKeysDescription`)},{id:`customProviders`,countKey:`customProviders`,label:()=>D(`restoreCustomProviders`),description:()=>D(`restoreCustomProvidersDescription`)},{id:`projects`,countKey:`projects`,label:()=>D(`restoreProjects`),description:()=>D(`restoreProjectsDescription`)},{id:`scheduledTasks`,countKey:`scheduledTasks`,label:()=>D(`restoreScheduledTasks`),description:()=>D(`restoreScheduledTasksDescription`)}],ct=z;function lt(e,t){let n=new Blob([`${JSON.stringify(t,null,2)}\n`],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function ut(){return new Date().toISOString().replace(/[:.]/g,`-`)}function dt(e){return e?Object.entries(e).map(([e,t])=>`${e}: ${t}`).join(`, `):``}function ft(e){return ct.filter(t=>(e.sections?.[t.countKey]??0)>0)}function pt(e){return ft(e).map(e=>e.id)}function mt(e){return e instanceof RangeError||e instanceof Error&&e.message.includes(`Invalid string length`)}function B(e,t){return mt(e)?D(`backupStringTooLarge`):e instanceof Error?e.message:t}var ht=class extends _{exportSections=new Set(z.map(e=>e.id));busy=!1;message=``;error=``;safetyBackupPath=``;pendingImport=null;getTabName(){return D(`backupRestore`)}toggleExportSection(e,t){t?this.exportSections.add(e):this.exportSections.delete(e),this.clearStatus(),this.requestUpdate()}clearStatus(){this.message=``,this.error=``,this.safetyBackupPath=``}async exportBackup(){if(this.exportSections.size===0){this.error=D(`selectAtLeastOneExportSection`),this.requestUpdate();return}this.busy=!0,this.clearStatus(),this.requestUpdate();try{let e=new URLSearchParams({sections:[...this.exportSections].join(`,`)}),t=await fetch(`/api/backup/export?${e.toString()}`,{cache:`no-store`}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||D(`backupExportFailed`));lt(`${st}-settings-${ut()}.json`,n),this.message=D(`backupExported`)}catch(e){this.error=B(e,D(`backupExportFailed`))}finally{this.busy=!1,this.requestUpdate()}}async inspectBackupFile(e){let t=await fetch(`/api/backup/inspect-file`,{method:`POST`,headers:{"content-type":`application/json`},body:e}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||D(`backupInspectFailed`));if(!n)throw Error(D(`backupInspectFailed`));return n}async importBackupFromFile(e){this.busy=!0,this.clearStatus(),this.pendingImport=null,this.requestUpdate();try{let t=await this.inspectBackupFile(e),n=new Set(pt(t));this.pendingImport={backup:null,importToken:t.importToken,inspect:t,selectedSections:n,mode:`replace`},this.message=t.ignoredConversations?D(`backupInspectedWithIgnoredConversations`):D(`backupInspected`)}catch(e){this.error=B(e,D(`backupImportFailed`))}finally{this.busy=!1,this.requestUpdate()}}togglePendingSection(e,t){this.pendingImport&&(t?this.pendingImport.selectedSections.add(e):this.pendingImport.selectedSections.delete(e),this.message=``,this.error=``,this.requestUpdate())}setRestoreMode(e){this.pendingImport&&(this.pendingImport.mode=e,this.message=``,this.error=``,this.requestUpdate())}cancelPendingImport(){this.pendingImport=null,this.message=``,this.error=``,this.requestUpdate()}async confirmPendingImport(){if(this.pendingImport){if(this.pendingImport.selectedSections.size===0){this.error=D(`selectAtLeastOneRestoreSection`),this.requestUpdate();return}if(await C({description:this.pendingImport.mode===`replace`?D(`backupImportReplaceConfirm`):D(`backupImportMergeConfirm`),confirmLabel:D(`confirmImportSelected`),cancelLabel:D(`cancel`)})){this.busy=!0,this.clearStatus(),this.requestUpdate();try{let e=this.pendingImport.importToken?{importToken:this.pendingImport.importToken,sections:[...this.pendingImport.selectedSections],mode:this.pendingImport.mode}:{backup:this.pendingImport.backup,sections:[...this.pendingImport.selectedSections],mode:this.pendingImport.mode},t=await fetch(`/api/backup/import`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||D(`backupImportFailed`));let r=dt(n?.summary);this.safetyBackupPath=n?.safetyBackupPath||``,this.pendingImport=null,this.message=r?`${D(`backupImported`)} ${r}`:D(`backupImported`),window.setTimeout(()=>window.location.reload(),1500)}catch(e){this.error=B(e,D(`backupImportFailed`))}finally{this.busy=!1,this.requestUpdate()}}}}handleFileChange(e){let t=e.target,n=t.files?.[0];t.value=``,n&&this.importBackupFromFile(n)}renderSwitch(e,t,n=!1){return g`
736
+ `}},R=`quickforge-memory-settings-tab`;customElements.get(R)||customElements.define(R,at);function ot(){return document.createElement(R)}var st=`quickforge-backup`,z=[{id:`settings`,countKey:`settings`,label:()=>D(`restoreSettings`),description:()=>D(`restoreSettingsDescription`)},{id:`mcp`,countKey:`mcp`,label:()=>D(`restoreMcp`),description:()=>D(`restoreMcpDescription`)},{id:`providerKeys`,countKey:`providerKeys`,label:()=>D(`restoreProviderKeys`),description:()=>D(`restoreProviderKeysDescription`)},{id:`customProviders`,countKey:`customProviders`,label:()=>D(`restoreCustomProviders`),description:()=>D(`restoreCustomProvidersDescription`)},{id:`scheduledTasks`,countKey:`scheduledTasks`,label:()=>D(`restoreScheduledTasks`),description:()=>D(`restoreScheduledTasksDescription`)}],ct=z;function lt(e,t){let n=new Blob([`${JSON.stringify(t,null,2)}\n`],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function ut(){return new Date().toISOString().replace(/[:.]/g,`-`)}function dt(e){return e?Object.entries(e).map(([e,t])=>`${e}: ${t}`).join(`, `):``}function ft(e){return ct.filter(t=>(e.sections?.[t.countKey]??0)>0)}function pt(e){return ft(e).map(e=>e.id)}function mt(e){return e instanceof RangeError||e instanceof Error&&e.message.includes(`Invalid string length`)}function B(e,t){return mt(e)?D(`backupStringTooLarge`):e instanceof Error?e.message:t}var ht=class extends _{exportSections=new Set(z.map(e=>e.id));busy=!1;message=``;error=``;safetyBackupPath=``;pendingImport=null;getTabName(){return D(`backupRestore`)}toggleExportSection(e,t){t?this.exportSections.add(e):this.exportSections.delete(e),this.clearStatus(),this.requestUpdate()}clearStatus(){this.message=``,this.error=``,this.safetyBackupPath=``}async exportBackup(){if(this.exportSections.size===0){this.error=D(`selectAtLeastOneExportSection`),this.requestUpdate();return}this.busy=!0,this.clearStatus(),this.requestUpdate();try{let e=new URLSearchParams({sections:[...this.exportSections].join(`,`)}),t=await fetch(`/api/backup/export?${e.toString()}`,{cache:`no-store`}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||D(`backupExportFailed`));lt(`${st}-settings-${ut()}.json`,n),this.message=D(`backupExported`)}catch(e){this.error=B(e,D(`backupExportFailed`))}finally{this.busy=!1,this.requestUpdate()}}async inspectBackupFile(e){let t=await fetch(`/api/backup/inspect-file`,{method:`POST`,headers:{"content-type":`application/json`},body:e}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||D(`backupInspectFailed`));if(!n)throw Error(D(`backupInspectFailed`));return n}async importBackupFromFile(e){this.busy=!0,this.clearStatus(),this.pendingImport=null,this.requestUpdate();try{let t=await this.inspectBackupFile(e),n=new Set(pt(t));this.pendingImport={backup:null,importToken:t.importToken,inspect:t,selectedSections:n,mode:`replace`},this.message=t.ignoredConversations?D(`backupInspectedWithIgnoredConversations`):D(`backupInspected`)}catch(e){this.error=B(e,D(`backupImportFailed`))}finally{this.busy=!1,this.requestUpdate()}}togglePendingSection(e,t){this.pendingImport&&(t?this.pendingImport.selectedSections.add(e):this.pendingImport.selectedSections.delete(e),this.message=``,this.error=``,this.requestUpdate())}setRestoreMode(e){this.pendingImport&&(this.pendingImport.mode=e,this.message=``,this.error=``,this.requestUpdate())}cancelPendingImport(){this.pendingImport=null,this.message=``,this.error=``,this.requestUpdate()}async confirmPendingImport(){if(this.pendingImport){if(this.pendingImport.selectedSections.size===0){this.error=D(`selectAtLeastOneRestoreSection`),this.requestUpdate();return}if(await C({description:this.pendingImport.mode===`replace`?D(`backupImportReplaceConfirm`):D(`backupImportMergeConfirm`),confirmLabel:D(`confirmImportSelected`),cancelLabel:D(`cancel`)})){this.busy=!0,this.clearStatus(),this.requestUpdate();try{let e=this.pendingImport.importToken?{importToken:this.pendingImport.importToken,sections:[...this.pendingImport.selectedSections],mode:this.pendingImport.mode}:{backup:this.pendingImport.backup,sections:[...this.pendingImport.selectedSections],mode:this.pendingImport.mode},t=await fetch(`/api/backup/import`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||D(`backupImportFailed`));let r=dt(n?.summary);this.safetyBackupPath=n?.safetyBackupPath||``,this.pendingImport=null,this.message=r?`${D(`backupImported`)} ${r}`:D(`backupImported`),window.setTimeout(()=>window.location.reload(),1500)}catch(e){this.error=B(e,D(`backupImportFailed`))}finally{this.busy=!1,this.requestUpdate()}}}}handleFileChange(e){let t=e.target,n=t.files?.[0];t.value=``,n&&this.importBackupFromFile(n)}renderSwitch(e,t,n=!1){return g`
737
737
  <label class="quickforge-settings-switch" aria-disabled=${n?`true`:`false`}>
738
738
  <input
739
739
  type="checkbox"
@@ -1492,4 +1492,4 @@ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Ct as t,Et as n,Ot as
1492
1492
  ${this.message?g`<div class="quickforge-settings-message">${this.message}</div>`:null}
1493
1493
  ${this.error?g`<div class="quickforge-settings-alert">${this.error}</div>`:null}
1494
1494
  </div>
1495
- `}},Y=`quickforge-channels-settings-tab`;customElements.get(Y)||customElements.define(Y,Lt);function Rt(){return document.createElement(Y)}var zt=ie(),X=re(),Bt=(0,k.lazy)(()=>y(()=>import(`./AgentProfilesPage-DQ8URegq.js`).then(e=>({default:e.AgentProfilesPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),Vt=(0,k.lazy)(()=>y(()=>import(`./mcp-servers-dialog-XE4K8PCO.js`).then(e=>({default:e.McpServersPanel})),__vite__mapDeps([12,1,2,3,4,5,6,7,8,9,10,11]))),Ht=(0,k.lazy)(()=>y(()=>import(`./skills-dialog-MpoxntiV.js`).then(e=>e.n).then(e=>({default:e.SkillsManagerPanel})),__vite__mapDeps([9,1,2,3,4,5,6,7,8,10,11]))),Ut=(0,k.lazy)(()=>y(()=>import(`./PluginsPage-B8bHMwfv.js`).then(e=>({default:e.PluginsPage})),__vite__mapDeps([13,1,2,3,4,5,6,7,8,9,10,11,14]))),Wt=(0,k.lazy)(()=>y(()=>import(`./ScheduledTasksPage-AaUz5el2.js`).then(e=>({default:e.ScheduledTasksPage})),__vite__mapDeps([15,1,2,3,4,5,6,7,8,9,10,11]))),Gt=class extends _{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 g`<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,zt.createRoot)(e),this.root.render(this.renderReact()))}},Z=`quickforge-react-settings-tab`;customElements.get(Z)||customElements.define(Z,Gt);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)(k.Suspense,{fallback:(0,X.jsx)(`div`,{className:`quickforge-settings-note`,children:D(`loading`)}),children:e})})}function Kt(e){window.dispatchEvent(new CustomEvent(`quickforge:open-session-from-settings`,{detail:{sessionId:e}}))}function qt(){return Q(D(`agentsTab`),()=>(0,X.jsx)($,{children:(0,X.jsx)(Bt,{})}))}function Jt(){return Q(D(`skills`),()=>(0,X.jsx)($,{children:(0,X.jsx)(Ht,{active:!0,scope:`global`,embedded:!0,onSaved:()=>void 0})}))}function Yt(){return Q(D(`mcpServers`),()=>(0,X.jsx)($,{children:(0,X.jsx)(Vt,{active:!0})}))}function Xt(){return Q(D(`plugins`),()=>(0,X.jsx)($,{children:(0,X.jsx)(Ut,{})}))}function Zt(){return Q(D(`scheduledTasks`),()=>(0,X.jsx)($,{children:(0,X.jsx)(Wt,{onOpenSession:Kt})}))}function Qt(e){let t=[{key:`appearance`,tab:Fe(),getDescription:()=>D(`appearanceDescription`)},{key:`defaults`,tab:$e(),getDescription:()=>D(`defaultOptionsDescription`)},{key:`memory`,tab:ot(),getDescription:()=>D(`memoryDescription`)},{key:`customModels`,tab:je(e),getDescription:()=>D(`customModelsDescription`)},{key:`agents`,tab:qt(),getDescription:()=>D(`agentsDescription`)},{key:`skills`,tab:Jt(),getDescription:()=>D(`globalSkillsDescription`)},{key:`mcp`,tab:Yt(),getDescription:void 0},{key:`plugins`,tab:Xt(),getDescription:()=>D(`pluginsDescription`)},{key:`scheduledTasks`,tab:Zt(),getDescription:()=>D(`scheduledTasksDescription`)},{key:`projectCommands`,tab:Nt(),getDescription:()=>D(`projectCommandsDescription`)},{key:`backup`,tab:gt(),getDescription:()=>D(`backupRestoreDescription`)},{key:`archivedConversations`,tab:bt(),getDescription:()=>D(`archivedConversationsDescription`)},{key:`channels`,tab:Rt(),getDescription:()=>D(`channelsDescription`)},{key:`lanAccess`,tab:Ct(),getDescription:()=>D(`lanAccessDescription`)},{key:`about`,tab:jt(),getDescription:()=>D(`aboutQuickForgeDescription`)}];return{items:[...t],tabs:t.map(e=>e.tab),indexOf:e=>t.findIndex(t=>t.key===e)}}var $t={appearance:d,defaults:f,memory:te,customModels:h,agents:i,skills:t,mcp:u,plugins:o,scheduledTasks:s,projectCommands:m,backup:p,archivedConversations:n,channels:l,lanAccess:c,about:ne};function en({tab:e}){let t=(0,k.useRef)(null);return(0,k.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 tn({initialTab:e,customProvider:t,onBack:n}){let r=(0,k.useMemo)(()=>Qt(t),[t]),i=Math.max(0,r.indexOf(e)),[o,s]=(0,k.useState)(),c=o??i,l=r.items[c]??r.items[0],u=l?.getDescription?.(),d=l?$t[l.key]:void 0,[f,p]=(0,k.useState)(``),m=f.trim().toLowerCase(),h=(0,k.useMemo)(()=>r.items.map((e,t)=>({item:e,index:t})).filter(({item:e})=>m?[e.key,e.tab.getTabName(),e.getDescription?.()??``].join(` `).toLowerCase().includes(m):!0),[r.items,m]);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:n,"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)(a,{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)(ee,{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:f,onChange:e=>p(e.target.value),placeholder:D(`searchSettings`),"aria-label":D(`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":D(`settings`),children:[h.map(({item:e,index:t})=>{let n=t===c,r=$t[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)}),h.length===0?(0,X.jsx)(`div`,{className:`px-2 py-3 text-sm text-muted-foreground/70`,children:D(`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)(xe,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:n,"aria-label":`返回工作区`,children:(0,X.jsx)(a,{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:[d?(0,X.jsx)(d,{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:l?.tab.getTabName()}),u?(0,X.jsx)(Te,{label:u}):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)(ee,{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:f,onChange:e=>p(e.target.value),placeholder:D(`searchSettings`),"aria-label":D(`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:[h.map(({item:e,index:t})=>{let n=t===c,r=$t[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)}),h.length===0?(0,X.jsx)(`div`,{className:`shrink-0 px-1 py-1.5 text-sm text-muted-foreground/70`,children:D(`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:l?(0,X.jsx)(en,{tab:l.tab}):null})})]})]})}export{tn as SettingsWorkspacePage};
1495
+ `}},Y=`quickforge-channels-settings-tab`;customElements.get(Y)||customElements.define(Y,Lt);function Rt(){return document.createElement(Y)}var zt=ie(),X=re(),Bt=(0,k.lazy)(()=>y(()=>import(`./AgentProfilesPage-__uY0AvK.js`).then(e=>({default:e.AgentProfilesPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),Vt=(0,k.lazy)(()=>y(()=>import(`./mcp-servers-dialog-CaQTvGiW.js`).then(e=>({default:e.McpServersPanel})),__vite__mapDeps([12,1,2,3,4,5,6,7,8,9,10,11]))),Ht=(0,k.lazy)(()=>y(()=>import(`./skills-dialog-D18mxNyW.js`).then(e=>e.n).then(e=>({default:e.SkillsManagerPanel})),__vite__mapDeps([9,1,2,3,4,5,6,7,8,10,11]))),Ut=(0,k.lazy)(()=>y(()=>import(`./PluginsPage-CKyWhlCo.js`).then(e=>({default:e.PluginsPage})),__vite__mapDeps([13,1,2,3,4,5,6,7,8,9,10,11,14]))),Wt=(0,k.lazy)(()=>y(()=>import(`./ScheduledTasksPage-KtJoeJYt.js`).then(e=>({default:e.ScheduledTasksPage})),__vite__mapDeps([15,1,2,3,4,5,6,7,8,9,10,11]))),Gt=class extends _{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 g`<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,zt.createRoot)(e),this.root.render(this.renderReact()))}},Z=`quickforge-react-settings-tab`;customElements.get(Z)||customElements.define(Z,Gt);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)(k.Suspense,{fallback:(0,X.jsx)(`div`,{className:`quickforge-settings-note`,children:D(`loading`)}),children:e})})}function Kt(e){window.dispatchEvent(new CustomEvent(`quickforge:open-session-from-settings`,{detail:{sessionId:e}}))}function qt(){return Q(D(`agentsTab`),()=>(0,X.jsx)($,{children:(0,X.jsx)(Bt,{})}))}function Jt(){return Q(D(`skills`),()=>(0,X.jsx)($,{children:(0,X.jsx)(Ht,{active:!0,scope:`global`,embedded:!0,onSaved:()=>void 0})}))}function Yt(){return Q(D(`mcpServers`),()=>(0,X.jsx)($,{children:(0,X.jsx)(Vt,{active:!0})}))}function Xt(){return Q(D(`plugins`),()=>(0,X.jsx)($,{children:(0,X.jsx)(Ut,{})}))}function Zt(){return Q(D(`scheduledTasks`),()=>(0,X.jsx)($,{children:(0,X.jsx)(Wt,{onOpenSession:Kt})}))}function Qt(e){let t=[{key:`appearance`,tab:Fe(),getDescription:()=>D(`appearanceDescription`)},{key:`defaults`,tab:$e(),getDescription:()=>D(`defaultOptionsDescription`)},{key:`memory`,tab:ot(),getDescription:()=>D(`memoryDescription`)},{key:`customModels`,tab:je(e),getDescription:()=>D(`customModelsDescription`)},{key:`agents`,tab:qt(),getDescription:()=>D(`agentsDescription`)},{key:`skills`,tab:Jt(),getDescription:()=>D(`globalSkillsDescription`)},{key:`mcp`,tab:Yt(),getDescription:void 0},{key:`plugins`,tab:Xt(),getDescription:()=>D(`pluginsDescription`)},{key:`scheduledTasks`,tab:Zt(),getDescription:()=>D(`scheduledTasksDescription`)},{key:`projectCommands`,tab:Nt(),getDescription:()=>D(`projectCommandsDescription`)},{key:`backup`,tab:gt(),getDescription:()=>D(`backupRestoreDescription`)},{key:`archivedConversations`,tab:bt(),getDescription:()=>D(`archivedConversationsDescription`)},{key:`channels`,tab:Rt(),getDescription:()=>D(`channelsDescription`)},{key:`lanAccess`,tab:Ct(),getDescription:()=>D(`lanAccessDescription`)},{key:`about`,tab:jt(),getDescription:()=>D(`aboutQuickForgeDescription`)}];return{items:[...t],tabs:t.map(e=>e.tab),indexOf:e=>t.findIndex(t=>t.key===e)}}var $t={appearance:t,defaults:p,memory:n,customModels:te,agents:c,skills:f,mcp:d,plugins:ne,scheduledTasks:r,projectCommands:h,backup:u,archivedConversations:s,channels:l,lanAccess:m,about:a};function en({tab:e}){let t=(0,k.useRef)(null);return(0,k.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 tn({initialTab:e,customProvider:t,onBack:n}){let r=(0,k.useMemo)(()=>Qt(t),[t]),i=Math.max(0,r.indexOf(e)),[a,s]=(0,k.useState)(),c=a??i,l=r.items[c]??r.items[0],u=l?.getDescription?.(),d=l?$t[l.key]:void 0,[f,p]=(0,k.useState)(``),m=f.trim().toLowerCase(),h=(0,k.useMemo)(()=>r.items.map((e,t)=>({item:e,index:t})).filter(({item:e})=>m?[e.key,e.tab.getTabName(),e.getDescription?.()??``].join(` `).toLowerCase().includes(m):!0),[r.items,m]);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:n,"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)(o,{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)(ee,{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:f,onChange:e=>p(e.target.value),placeholder:D(`searchSettings`),"aria-label":D(`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":D(`settings`),children:[h.map(({item:e,index:t})=>{let n=t===c,r=$t[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)}),h.length===0?(0,X.jsx)(`div`,{className:`px-2 py-3 text-sm text-muted-foreground/70`,children:D(`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)(xe,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:n,"aria-label":`返回工作区`,children:(0,X.jsx)(o,{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:[d?(0,X.jsx)(d,{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:l?.tab.getTabName()}),u?(0,X.jsx)(Te,{label:u}):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)(ee,{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:f,onChange:e=>p(e.target.value),placeholder:D(`searchSettings`),"aria-label":D(`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:[h.map(({item:e,index:t})=>{let n=t===c,r=$t[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)}),h.length===0?(0,X.jsx)(`div`,{className:`shrink-0 px-1 py-1.5 text-sm text-muted-foreground/70`,children:D(`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:l?(0,X.jsx)(en,{tab:l.tab}):null})})]})]})}export{tn as SettingsWorkspacePage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Ot as t,i as n,rt as r}from"./icons-ko_i0WpN.js";import{n as i}from"./react-vendor-2RKYr-A4.js";import{S as a,b as o,d as s,f as c,p as l,u}from"./pi-web-ui-DoRGtREc.js";import{U as d}from"./pi-ai-Cr3rpCXT.js";import{t as f}from"./logger-B65Akg8A.js";import{B as p,G as m,J as h,U as g,W as _,Y as v,Z as y,c as b,lt as x,mt as S,o as C,ot as w,q as T,s as E,ut as D,x as O}from"./index-B8Awq5FV.js";import{ChatPanelHost as k}from"./ChatPanelHost-vi1tDqlJ.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=h(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,T(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 E(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??y(n)})}function W(e,t){let n={settings:new u,providerKeys:new c,sessions:new s,customProviders:new l},r=new w(``,{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 o(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,h]=(0,A.useState)(),[v,y]=(0,A.useState)(!1),[w,T]=(0,A.useState)(),E=(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())=>{h(void 0),y(!0);try{let t=await b(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){h(e instanceof Error?e.message:`Failed to unlock shared conversation`)}finally{y(!1)}},[t,e]);(0,A.useEffect)(()=>{if(M||v||E.current)return;E.current=!0;let t=window.setTimeout(()=>{(async()=>{try{(await C(e)).share.hasPassword||await P(``)}catch(e){h(e instanceof Error?e.message:`Failed to load shared conversation`)}})()},0);return()=>window.clearTimeout(t)},[v,e,P,M]);let F=(0,A.useCallback)(async e=>{await g(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;O(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=>{h(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),h(e instanceof Error?e.message:`Failed to update thinking level`)})}})}catch(e){h(e instanceof Error?e.message:`Failed to load models`)}},[a,e]),L=(0,A.useCallback)(e=>{T(t=>t?.id===e?void 0:t)},[]),R=(0,A.useCallback)(async e=>{if(!a||a.permission!==`operate`)return;if(h(void 0),a.state.isStreaming){p(S(`generationStillRunning`));return}let t=m(a.state.messages,e),n=t>=0?a.state.messages[t]:void 0;if(!n){p(S(`noConversationTurnToRollback`));return}try{await a.rollback(e),T({id:Date.now(),sessionId:a.sessionId,text:_(n),attachments:n.role===`user-with-attachments`?n.attachments:void 0})}catch(e){h(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:D(`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:D(`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:D(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)(x,{variant:`ghost`,size:`sm`,className:D(`shrink-0`,j?`text-red-700 hover:bg-red-100 hover:text-red-800`:void 0),onClick:()=>void g(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:R,onRetryFromMessage:()=>void 0,onCopyAnswer:F,onForkFromMessage:()=>void 0,onApproveToolCall:()=>void 0,onRejectToolCall:()=>void 0,disableFork:!0,rollbackConfirmTitle:S(`sharedRollbackConfirmTitle`),rollbackConfirmDescription:S(`sharedRollbackConfirm`),readOnly:!j,restoredDraft:w,onRestoredDraftConsumed:L,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)(x,{className:`mt-5 w-full`,onClick:()=>void P(),disabled:v||!t.trim(),children:v?S(`loading`):`用密码打开分享对话`})]})})}export{G as SharedConversationPage};
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Ft as t,i as n,lt as r}from"./icons-pPRMD2tE.js";import{n as i}from"./react-vendor-CLbWF1Oy.js";import{S as a,b as o,d as s,f as c,p as l,u}from"./pi-web-ui-DoRGtREc.js";import{U as d}from"./pi-ai-Cr3rpCXT.js";import{t as f}from"./logger-B65Akg8A.js";import{B as p,G as m,J as h,U as g,W as _,Y as v,Z as y,c as b,lt as x,mt as S,o as C,ot as w,q as T,s as E,ut as D,x as O}from"./index-BSXpUDCq.js";import{ChatPanelHost as k}from"./ChatPanelHost-DIs_vWFX.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=h(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,T(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 E(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??y(n)})}function W(e,t){let n={settings:new u,providerKeys:new c,sessions:new s,customProviders:new l},r=new w(``,{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 o(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,h]=(0,A.useState)(),[v,y]=(0,A.useState)(!1),[w,T]=(0,A.useState)(),E=(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())=>{h(void 0),y(!0);try{let t=await b(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){h(e instanceof Error?e.message:`Failed to unlock shared conversation`)}finally{y(!1)}},[t,e]);(0,A.useEffect)(()=>{if(M||v||E.current)return;E.current=!0;let t=window.setTimeout(()=>{(async()=>{try{(await C(e)).share.hasPassword||await P(``)}catch(e){h(e instanceof Error?e.message:`Failed to load shared conversation`)}})()},0);return()=>window.clearTimeout(t)},[v,e,P,M]);let F=(0,A.useCallback)(async e=>{await g(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;O(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=>{h(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),h(e instanceof Error?e.message:`Failed to update thinking level`)})}})}catch(e){h(e instanceof Error?e.message:`Failed to load models`)}},[a,e]),L=(0,A.useCallback)(e=>{T(t=>t?.id===e?void 0:t)},[]),R=(0,A.useCallback)(async e=>{if(!a||a.permission!==`operate`)return;if(h(void 0),a.state.isStreaming){p(S(`generationStillRunning`));return}let t=m(a.state.messages,e),n=t>=0?a.state.messages[t]:void 0;if(!n){p(S(`noConversationTurnToRollback`));return}try{await a.rollback(e),T({id:Date.now(),sessionId:a.sessionId,text:_(n),attachments:n.role===`user-with-attachments`?n.attachments:void 0})}catch(e){h(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:D(`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:D(`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:D(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)(x,{variant:`ghost`,size:`sm`,className:D(`shrink-0`,j?`text-red-700 hover:bg-red-100 hover:text-red-800`:void 0),onClick:()=>void g(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:R,onRetryFromMessage:()=>void 0,onCopyAnswer:F,onForkFromMessage:()=>void 0,onApproveToolCall:()=>void 0,onRejectToolCall:()=>void 0,disableFork:!0,rollbackConfirmTitle:S(`sharedRollbackConfirmTitle`),rollbackConfirmDescription:S(`sharedRollbackConfirm`),readOnly:!j,restoredDraft:w,onRestoredDraftConsumed:L,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)(x,{className:`mt-5 w-full`,onClick:()=>void P(),disabled:v||!t.trim(),children:v?S(`loading`):`用密码打开分享对话`})]})})}export{G as SharedConversationPage};
@@ -0,0 +1,2 @@
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{B as t,Ct as n,Ft as r,N as i,R as a,S as o,n as s,s as c}from"./icons-pPRMD2tE.js";import{n as l}from"./react-vendor-CLbWF1Oy.js";import{A as u,N as d,T as f,lt as p,mt as m,ut as h}from"./index-BSXpUDCq.js";import{n as ee,t as g}from"./xterm-CGiQzDiR.js";var _=e(r(),1);async function v(e,t){let n=await fetch(e,{cache:`no-store`,...t}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Request failed: ${n.status}`);return r}function y(){return v(`/api/terminal/capabilities`)}function b(e){return v(`/api/terminal/sessions${e?`?projectId=${encodeURIComponent(e)}`:``}`)}function x(e){return v(`/api/terminal/sessions`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})}function S(e){return v(`/api/terminal/sessions/${encodeURIComponent(e)}`,{method:`DELETE`})}function C(e,t){return v(`/api/terminal/sessions/${encodeURIComponent(e)}/input`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({data:t})})}function w(){return``}function te(){let e=w();if(e){let t=new URL(e);return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString().replace(/\/$/,``)}return`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}`}function T(){let[e,t]=(0,_.useState)(()=>f());return(0,_.useEffect)(()=>{if(typeof document>`u`)return;let e=document.documentElement,n=()=>t(f());n();let r=new MutationObserver(n);return r.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>r.disconnect()},[]),e}var E=l(),D={light:{background:`#ffffff`,foreground:`#1f2937`,cursor:`#1f2937`,selectionBackground:`#dbeafe`},dark:{background:`#171717`,foreground:`#e5e7eb`,cursor:`#e5e7eb`,selectionBackground:`#3f3f46`}};function ne({session:e,active:t,height:n,onReady:r,onExited:i,onConnectionError:a}){let o=T(),s=D[o],c=(0,_.useRef)(null),l=(0,_.useRef)(null),f=(0,_.useRef)(null),p=(0,_.useRef)(null),h=(0,_.useRef)(null),v=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let t=c.current;if(!t)return;let n=!1,o=!1,_=!1,y=!1,b=t=>{n||_||y||(y=!0,a(e.id,t))},x=d(),S=new ee({cursorBlink:!0,convertEol:!1,fontFamily:getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`,fontSize:x.fontSize,lineHeight:x.lineHeight,scrollback:5e3,theme:s}),C=new g;S.loadAddon(C),S.open(t),S.writeln(`\x1b[2mConnected to ${e.cwd}\x1b[0m`),l.current=S,f.current=C;let w=()=>{if(t.isConnected)try{C.fit();let{cols:e,rows:t}=S,n=p.current;n?.readyState===WebSocket.OPEN&&n.send(JSON.stringify({type:`resize`,cols:e,rows:t}))}catch{}},T=new WebSocket(`${te()}/api/terminal/sessions/${encodeURIComponent(e.id)}/ws`);p.current=T,T.addEventListener(`open`,()=>{o=!0,y=!1,a(e.id,void 0),h.current=S.onData(e=>{T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:`input`,data:e}))}),window.setTimeout(w,0)}),T.addEventListener(`message`,t=>{try{let n=JSON.parse(String(t.data));n.type===`ready`?r(e.id):n.type===`output`?S.write(n.data):n.type===`exit`?(_=!0,S.writeln(``),S.writeln(`\x1b[33m[process exited with code ${n.exitCode??`unknown`}]\x1b[0m`),i(e.id)):n.type===`error`&&S.writeln(`\x1b[31m${n.message}\x1b[0m`)}catch{}}),T.addEventListener(`error`,()=>{b(m(o?`terminalConnectionClosedUnexpectedly`:`terminalConnectionFailed`))}),T.addEventListener(`close`,e=>{h.current?.dispose(),h.current=null,!(n||_)&&(!e.wasClean||e.code!==1e3)&&b(m(o?`terminalConnectionClosedUnexpectedly`:`terminalConnectionFailed`))});let E=new ResizeObserver(()=>w());E.observe(t),v.current=E;let D=()=>{let e=d();S.options.fontSize=e.fontSize,S.options.lineHeight=e.lineHeight,window.setTimeout(w,0)};return window.addEventListener(u,D),window.setTimeout(w,50),()=>{n=!0,window.removeEventListener(u,D),E.disconnect(),v.current=null,h.current?.dispose(),h.current=null,T.close(),p.current=null,S.dispose(),l.current=null,f.current=null}},[o,a,i,r,e.cwd,e.id,s]),(0,_.useEffect)(()=>{if(!t)return;let e=f.current,n=l.current;window.setTimeout(()=>{try{e?.fit(),n?.focus()}catch{}},0)},[t,n]),(0,E.jsx)(`div`,{className:t?`h-full min-h-0 w-full pl-2 md:pl-3`:`hidden`,"aria-hidden":!t,children:(0,E.jsx)(`div`,{ref:c,className:`h-full min-h-0 w-full`})})}var re=180,ie=.7,ae=320;function O(e,t){let n=t?t.name:`Terminal`,r=new Set(e.map(e=>e.name));if(n!==`Terminal`&&!r.has(n))return n;let i=1;for(;r.has(`${n} ${i}`);)i+=1;return`${n} ${i}`}function k(e,t){let n=e?.terminalShellProfiles||[],r=t||e?.defaultTerminalShellProfileId||``;return n.find(e=>e.id===r)||n[0]}function A({project:e,onCollapse:r,pendingCommand:l,onPendingCommandHandled:u,variant:d=`dock`,singleSession:f=!1,panelInstanceId:ee,panelSessionId:g,onPanelSessionReady:v}){let[w,te]=(0,_.useState)(null),[T,D]=(0,_.useState)([]),[A,j]=(0,_.useState)(),[M,oe]=(0,_.useState)(ae),[N,se]=(0,_.useState)(!0),[P,ce]=(0,_.useState)(!1),[le,F]=(0,_.useState)(),[ue,I]=(0,_.useState)({}),[L,R]=(0,_.useState)(!1),[z,de]=(0,_.useState)(!1),B=(0,_.useRef)(!1),V=(0,_.useRef)(!1),H=(0,_.useRef)(new Set),fe=(0,_.useRef)(l),U=(0,_.useRef)(new Set),W=(0,_.useRef)(new Set),G=(0,_.useRef)(new Map),K=(0,_.useRef)(!0),pe=(0,_.useRef)(v),[me,he]=(0,_.useState)(()=>new Set),q=(0,_.useRef)(null),ge=(0,_.useRef)(null),J=e?.id,Y=d===`panel`&&!!ee,X=(0,_.useMemo)(()=>T.find(e=>e.id===A)??T[0],[A,T]);(0,_.useEffect)(()=>{fe.current=l},[l]),(0,_.useEffect)(()=>{pe.current=v},[v]),(0,_.useEffect)(()=>()=>{K.current=!1},[]);let _e=(0,_.useCallback)(async()=>{let e=await b(J);return D(e.sessions),j(t=>t&&e.sessions.some(e=>e.id===t)?t:e.sessions[0]?.id),e.sessions},[J]),ve=(0,_.useCallback)(async(e,t)=>{if(B.current)return;let n=k(w,t);B.current=!0,ce(!0),F(void 0),I({});try{let t=await x({projectId:J,name:O(e,n),cols:120,rows:30,shellProfileId:n?.id,shellProfileName:n?.name});D(e=>[...e,t]),j(t.id)}catch(e){F(e instanceof Error?e.message:m(`terminalCreateFailed`))}finally{B.current=!1,ce(!1)}},[w,J]);(0,_.useEffect)(()=>{let e=!1;return(async()=>{se(!0),F(void 0);try{let[t,n]=await Promise.all([y(),b(J)]);if(e)return;if(te(t),t.enabled&&Y&&g&&n.sessions.some(e=>e.id===g)){V.current=!0,D(n.sessions),j(g);return}if(t.enabled&&Y&&!V.current){V.current=!0;let r=k(t);try{let t=await x({projectId:J,name:O(n.sessions,r),cols:120,rows:30,shellProfileId:r?.id,shellProfileName:r?.name});if(e){S(t.id).catch(()=>{});return}D([...n.sessions,t]),j(t.id),pe.current?.(t.id);return}catch(t){e||F(t instanceof Error?t.message:m(`terminalCreateFailed`))}}if(D(n.sessions),j(n.sessions[0]?.id),t.enabled&&n.sessions.length===0&&!fe.current){let n=k(t);x({projectId:J,name:O([],n),cols:120,rows:30,shellProfileId:n?.id,shellProfileName:n?.name}).then(t=>{if(e){S(t.id).catch(()=>{});return}D([t]),j(t.id)}).catch(t=>{e||F(t instanceof Error?t.message:m(`terminalCreateFailed`))})}}catch(t){e||F(t instanceof Error?t.message:m(`terminalUnavailable`))}finally{e||se(!1)}})(),()=>{e=!0}},[Y,g,J]),(0,_.useEffect)(()=>{if(!L)return;let e=e=>{ge.current?.contains(e.target)||R(!1)},t=e=>{e.key===`Escape`&&R(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[L]),(0,_.useEffect)(()=>{if(!z)return;let e=e=>{e.key===`Escape`&&de(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[z]),(0,_.useEffect)(()=>{if(!l||H.current.has(l.id)||G.current.has(l.id)||U.current.has(l.id)||N||P||!w)return;if(!w.enabled){H.current.add(l.id),window.setTimeout(()=>{F(w.reason||m(`terminalUnavailable`)),u?.(l.id)},0);return}let e=X&&!X.exited?X:T.find(e=>!e.exited);if(e){G.current.set(l.id,e.id),window.setTimeout(()=>{K.current&&j(e.id)},0);return}U.current.add(l.id),window.setTimeout(()=>{K.current&&F(void 0)},0);let t=k(w);x({projectId:J,name:O(T,t),cols:120,rows:30,shellProfileId:t?.id,shellProfileName:t?.name}).then(e=>{if(!K.current){S(e.id).catch(()=>{});return}G.current.set(l.id,e.id),D(t=>t.some(t=>t.id===e.id)?t:[...t,e]),j(e.id)}).catch(e=>{K.current&&(F(e instanceof Error?e.message:m(`terminalCommandExecuteFailed`)),H.current.add(l.id),u?.(l.id))}).finally(()=>{U.current.delete(l.id)})},[X,w,P,N,u,l,J,T]),(0,_.useEffect)(()=>{if(!l||H.current.has(l.id)||W.current.has(l.id))return;let e=G.current.get(l.id),t=e?T.find(t=>t.id===e):X&&!X.exited?X:T.find(e=>!e.exited);!t||t.exited||!me.has(t.id)||(W.current.add(l.id),window.setTimeout(()=>{K.current&&(j(t.id),F(void 0))},0),(async()=>{try{if(l.execute){let e=l.command.split(`
2
+ `),n=e.flatMap((t,n)=>n<e.length-1?[t,`\r`]:[t]);n.push(`\r`),await C(t.id,n.join(``))}else await C(t.id,l.command)}catch(e){K.current&&F(e instanceof Error?e.message:m(`terminalCommandExecuteFailed`))}finally{H.current.add(l.id),W.current.delete(l.id),G.current.delete(l.id),K.current&&u?.(l.id)}})())},[X,u,l,me,T]);let ye=async e=>{F(void 0),I(t=>{if(!t[e])return t;let n={...t};return delete n[e],n});let t=T.filter(t=>t.id!==e);D(t),A===e&&j(t[0]?.id);try{await S(e)}catch(e){F(e instanceof Error?e.message:m(`terminalCloseFailed`)),_e().catch(()=>{})}},be=(0,_.useCallback)(e=>{D(t=>t.map(t=>t.id===e?{...t,exited:!0}:t)),he(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),xe=(0,_.useCallback)(e=>{he(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),Se=(0,_.useCallback)((e,t)=>{I(n=>{if(!t){if(!n[e])return n;let t={...n};return delete t[e],t}return n[e]===t?n:{...n,[e]:t}})},[]),Ce=e=>{q.current={startY:e.clientY,startHeight:M},e.currentTarget.setPointerCapture(e.pointerId)},we=e=>{let t=q.current;if(!t)return;let n=Math.max(re,Math.floor(window.innerHeight*ie));oe(Math.min(n,Math.max(re,t.startHeight+t.startY-e.clientY)))},Te=e=>{q.current=null;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}},Z=w?.terminalShellProfiles||[],Ee=w?.defaultTerminalShellProfileId||``,De=Z.find(e=>e.id===Ee)||Z[0],Oe=!!(w&&T.length>=w.maxSessions),ke=P||Oe,Ae=X?ue[X.id]:void 0,je=Y&&X?[X]:T,Q=le??Ae,$=d===`panel`,Me=$&&f,Ne=$?void 0:z?Q?`calc(100% - 4.25rem)`:`calc(100% - 2.25rem)`:Q?M-72:M-45;return(0,E.jsxs)(`div`,{className:h($?`flex min-h-0 flex-1 flex-col bg-background`:`shrink-0 border-t border-border bg-background`,z&&`quickforge-terminal-fullscreen z-40 flex flex-col border-t-0`),style:z||$?void 0:{height:M},children:[!z&&!$?(0,E.jsx)(`div`,{className:`h-1 cursor-row-resize bg-transparent hover:bg-border`,onPointerDown:Ce,onPointerMove:we,onPointerUp:Te,onPointerCancel:Te}):null,(0,E.jsxs)(`div`,{className:`flex h-9 items-center gap-1 border-b border-border px-2`,children:[(0,E.jsx)(c,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,E.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto`,children:je.map(e=>{let t=h(`flex max-w-44 shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground/72`,X?.id===e.id&&`bg-muted/28 text-foreground/90`);return Me?(0,E.jsxs)(`div`,{className:t,title:`${e.name} — ${e.cwd}`,children:[(0,E.jsx)(`span`,{className:h(`size-1.5 rounded-full`,e.exited?`bg-muted-foreground/40`:`bg-emerald-500/80`)}),(0,E.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id):(0,E.jsxs)(`button`,{type:`button`,className:h(t,`hover:bg-muted/20 hover:text-foreground/85`),onClick:()=>j(e.id),title:`${e.name} — ${e.cwd}`,children:[(0,E.jsx)(`span`,{className:h(`size-1.5 rounded-full`,e.exited?`bg-muted-foreground/40`:`bg-emerald-500/80`)}),(0,E.jsx)(`span`,{className:`truncate`,children:e.name}),(0,E.jsx)(`span`,{role:`button`,tabIndex:0,className:`ml-1 rounded-sm p-0.5 opacity-60 hover:bg-background hover:opacity-100`,onClick:t=>{t.stopPropagation(),ye(e.id)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),ye(e.id))},"aria-label":m(`terminalCloseSession`,{name:e.name}),children:(0,E.jsx)(s,{className:`size-3`})})]},e.id)})}),Me?null:(0,E.jsxs)(`div`,{className:`relative shrink-0`,ref:ge,children:[(0,E.jsxs)(`div`,{className:`flex items-center overflow-hidden rounded-md border border-border bg-background`,children:[(0,E.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center text-foreground/85 transition-colors hover:bg-muted/20 disabled:pointer-events-none disabled:opacity-50`,onClick:()=>void ve(T),disabled:ke,title:De?m(`terminalNewWithProfile`,{name:De.name}):m(`terminalNew`),"aria-label":m(`terminalNew`),children:P?(0,E.jsx)(t,{className:`size-3.5 animate-spin`}):(0,E.jsx)(o,{className:`size-3.5`})}),Z.length>0?(0,E.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center border-l border-border text-muted-foreground/72 transition-colors hover:bg-muted/20 hover:text-foreground/85 disabled:pointer-events-none disabled:opacity-50`,onClick:()=>R(e=>!e),disabled:ke,title:m(`terminalSelectShell`),"aria-label":m(`terminalSelectShell`),"aria-expanded":L,children:(0,E.jsx)(n,{className:`size-3.5`})}):null]}),L?(0,E.jsxs)(`div`,{className:h(`absolute right-0 z-30 w-64 overflow-hidden rounded-lg border border-border bg-background p-1.5 shadow-[0_16px_38px_-22px_rgb(15_23_42_/_0.65)]`,$?`top-9`:`bottom-9`),children:[(0,E.jsx)(`div`,{className:`px-2 pb-1.5 pt-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60`,children:m(`terminalNewWith`)}),Z.map(e=>(0,E.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground/80 hover:bg-muted/20 hover:text-foreground/90`,onClick:()=>{R(!1),ve(T,e.id)},children:[(0,E.jsx)(`span`,{className:`inline-flex size-5 shrink-0 items-center justify-center rounded bg-muted/20 text-[10px] text-muted-foreground/70`,children:e.name.slice(0,1).toUpperCase()}),(0,E.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,E.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,E.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-muted-foreground/55`,children:e.command})]})]},e.id))]}):null]}),Me?null:(0,E.jsx)(p,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>de(e=>!e),title:m(z?`terminalExitFullscreen`:`terminalFullscreen`),"aria-label":m(z?`terminalExitFullscreen`:`terminalFullscreen`),children:z?(0,E.jsx)(i,{className:`size-3.5`}):(0,E.jsx)(a,{className:`size-3.5`})}),(0,E.jsx)(p,{variant:`ghost`,size:`icon`,className:h(`size-7`,$&&`hidden`),onClick:r,title:m(`terminalCollapse`),"aria-label":m(`terminalCollapse`),children:(0,E.jsx)(n,{className:`size-3.5`})})]}),Q?(0,E.jsx)(`div`,{className:`border-b border-border px-3 py-1.5 text-xs text-destructive`,children:Q}):null,(0,E.jsx)(`div`,{className:h(`min-h-0 bg-background`,$&&`flex-1`),style:Ne===void 0?void 0:{height:Ne},children:N?(0,E.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-xs text-muted-foreground/60`,children:[(0,E.jsx)(t,{className:`size-4 animate-spin`}),` `,m(`terminalStarting`)]}):w&&!w.enabled?(0,E.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-muted-foreground/60`,children:w.reason||m(`terminalUnavailable`)}):T.length===0?(0,E.jsx)(`div`,{className:`flex h-full items-center justify-center text-xs text-muted-foreground/60`,children:m(`terminalNoSessions`)}):T.map(e=>(0,E.jsx)(ne,{session:e,active:e.id===X?.id,height:z?window.innerHeight-36:$?0:M,onReady:xe,onExited:be,onConnectionError:Se},e.id))})]})}export{A as TerminalDock,T as t};