@shawnstack/quickforge 1.6.11 → 1.6.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +292 -452
- package/dist/assets/AgentProfilesPage-Be0oZDW5.js +1 -0
- package/dist/assets/ChatPanelHost-CxEotTsy.js +291 -0
- package/dist/assets/{PluginsPage-B_4nlPca.js → PluginsPage-DZlqGFLn.js} +1 -1
- package/dist/assets/ScheduledTasksPage-DTkj-0O4.js +2 -0
- package/dist/assets/{SettingsWorkspacePage-BtgkwIKN.js → SettingsWorkspacePage-BJq11OPD.js} +397 -403
- package/dist/assets/{SharedConversationPage-B5FS3eSl.js → SharedConversationPage-BCR8xzii.js} +1 -1
- package/dist/assets/TerminalDock-Bs5b-YNp.js +2 -0
- package/dist/assets/WorkspaceInspector-BP0XyAlE.js +13 -0
- package/dist/assets/icons-DAxUA0e-.js +1 -0
- package/dist/assets/index-BZC61KZg.css +3 -0
- package/dist/assets/index-DGQbvw7v.js +63 -0
- package/dist/assets/{mcp-servers-dialog-BPk4a4nW.js → mcp-servers-dialog-BHljnwYv.js} +2 -2
- package/dist/assets/{monaco-CdOyGlWD.js → monaco-DEQoYzYI.js} +1 -1
- package/dist/assets/{react-vendor-VqdnQHHS.js → react-vendor-CZsiwuxm.js} +1 -1
- package/dist/assets/{skills-dialog-DcxeFWSt.js → skills-dialog-8rn1XU9U.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/licenses/material-icon-theme.txt +8 -0
- package/package.json +1 -1
- package/server/agent-manager.mjs +163 -25
- package/server/custom-commands.mjs +17 -0
- package/server/image-generation.mjs +130 -0
- package/server/index.mjs +6 -0
- package/server/provider-config.mjs +78 -0
- package/server/routes/agent.mjs +9 -0
- package/server/routes/project.mjs +3 -18
- package/server/routes/session-assets.mjs +49 -0
- package/server/routes/shared-conversation.mjs +10 -0
- package/server/routes/tools.mjs +1 -1
- package/server/routes/workspace.mjs +5 -2
- package/server/session-assets.mjs +134 -0
- package/server/storage.mjs +13 -1
- package/server/tools/definitions.mjs +10 -0
- package/server/tools/index.mjs +2 -0
- package/server/utils/platform.mjs +20 -3
- package/dist/assets/AgentProfilesPage-CvoB0OId.js +0 -1
- package/dist/assets/ChatPanelHost-Cyi1yi_P.js +0 -244
- package/dist/assets/ScheduledTasksPage-Zbsuo8o6.js +0 -2
- package/dist/assets/TerminalDock-CiJCmyqg.js +0 -2
- package/dist/assets/WorkspaceInspector-C9HyQIvF.js +0 -13
- package/dist/assets/icons-C7j5jdKo.js +0 -1
- package/dist/assets/index-BFKildY3.js +0 -63
- package/dist/assets/index-CsKSKUn-.css +0 -3
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{D as t,Ft as n,Rt as r,Vt as i,a,dt as ee,l as o}from"./icons-C7j5jdKo.js";import{i as s,n as c}from"./react-vendor-VqdnQHHS.js";import{$ as te,H as l,Q as ne,ct as u,et as re,ht as d,nt as ie,tt as ae,ut as f}from"./index-BFKildY3.js";var p=e(i(),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,i]=(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`)]);i(e.agents),c(t.tools)}(0,p.useEffect)(()=>{let e=!1;async function t(){try{let[t,n]=await Promise.all([w(`/api/agent-profiles`),w(`/api/agent-profiles/available-tools`)]);if(e)return;i(t.agents),c(n.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 re(),n=await te(t);de(n);let r=await ae(t),i=r.model??await ie(t)??n[0];if(e)return;ue(i),pe(r.thinkingLevel??ne(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,n=e.enabledAsSubagent;i(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){i(t=>t.map(t=>t.id===e.id?{...t,enabledAsSubagent:n}:t)),z(t instanceof Error?t.message:d(`requestFailed`))}}async function be(e){if(!(e.builtin||e.readonly)&&await l({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)(u,{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)(u,{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)(f,{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)(f,{variant:`outline`,onClick:$,disabled:A||P,children:d(`cancel`)}),(0,m.jsx)(f,{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)(n,{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,244 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Vt as t,q as n}from"./icons-C7j5jdKo.js";import{n as r,t as i}from"./react-vendor-VqdnQHHS.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{G as f,R as p,U as m,W as h,d as g,ht as _,q as v,r as y}from"./index-BFKildY3.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`):``}var D={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`},O={minHeight:`1.35em`,padding:`0 0.75rem`,whiteSpace:`pre`},k={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 A(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 j(e){return e?.content?.filter(e=>e.type===`text`).map(e=>e.text??``).join(`
|
|
2
|
-
`)??``}function M(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function N(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 ee(e,t,n){let r=M(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}`,N(r,n),``,`STDOUT:`,a||`(empty)`,``,`STDERR:`,o||`(empty)`].join(`
|
|
3
|
-
`)}function te(e,t,n,r){let i=j(n);return e===`manage_global_memory`?E(n,r,_)||i:i||(e===`run_command`?ee(t,n?.details,r):``)}function P(e,t){return M(e)&&typeof e[t]==`string`?e[t]:``}function ne(e,t,n){if(!t&&!n?.details)return``;if(e===`run_command`&&typeof t?.command==`string`)return t.command;if(e===`present_files`){let e=(Array.isArray(t?.files)?t.files:Array.isArray(n?.details&&n.details.files)?(n?.details).files:[]).map(e=>typeof e==`string`?e:M(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:P(n?.details,`query`),r=typeof t?.path==`string`&&t.path?t.path:P(n?.details,`path`)||`.`,i=t?.regex||M(n?.details)&&M(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 re(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 F(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 ie(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 ae(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 oe(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 I(e){return e.startsWith(`+++`)||e.startsWith(`---`)?{...O,background:`color-mix(in oklab, var(--muted) 48%, transparent)`,color:`color-mix(in oklab, var(--muted-foreground) 88%, transparent)`}:e.startsWith(`@@`)?{...O,background:`color-mix(in oklab, rgb(37 99 235) 10%, transparent)`,color:`rgb(37 99 235)`}:e.startsWith(`+`)?{...O,background:`color-mix(in oklab, rgb(34 197 94) 16%, transparent)`,color:`rgb(22 101 52)`}:e.startsWith(`-`)?{...O,background:`color-mix(in oklab, rgb(239 68 68) 14%, transparent)`,color:`rgb(153 27 27)`}:{...O,color:`var(--foreground)`}}function se(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
|
-
<span class="shrink-0 inline-flex items-center gap-1" title="+${n} -${r}">
|
|
5
|
-
<span
|
|
6
|
-
class="quickforge-diff-badge quickforge-diff-badge-add"
|
|
7
|
-
style=${s({...k,background:`color-mix(in oklab, rgb(34 197 94) 16%, transparent)`,color:`rgb(22 101 52)`})}
|
|
8
|
-
>+${n}</span>
|
|
9
|
-
<span
|
|
10
|
-
class="quickforge-diff-badge quickforge-diff-badge-del"
|
|
11
|
-
style=${s({...k,background:`color-mix(in oklab, rgb(239 68 68) 14%, transparent)`,color:`rgb(153 27 27)`})}
|
|
12
|
-
>-${r}</span>
|
|
13
|
-
</span>
|
|
14
|
-
`}function ce(e){let t=e.text?.split(`
|
|
15
|
-
`)??[],n=Number(e.addedLines??0),r=Number(e.removedLines??0);return o`
|
|
16
|
-
<div>
|
|
17
|
-
<div class="mb-1 flex items-center gap-2 text-xs font-medium text-muted-foreground">
|
|
18
|
-
<span>Diff</span>
|
|
19
|
-
<span
|
|
20
|
-
class="quickforge-diff-badge quickforge-diff-badge-add"
|
|
21
|
-
style=${s({...k,background:`color-mix(in oklab, rgb(34 197 94) 16%, transparent)`,color:`rgb(22 101 52)`})}
|
|
22
|
-
>+${n}</span>
|
|
23
|
-
<span
|
|
24
|
-
class="quickforge-diff-badge quickforge-diff-badge-del"
|
|
25
|
-
style=${s({...k,background:`color-mix(in oklab, rgb(239 68 68) 14%, transparent)`,color:`rgb(153 27 27)`})}
|
|
26
|
-
>-${r}</span>
|
|
27
|
-
${e.truncated?o`<span class="text-muted-foreground/80">truncated</span>`:a}
|
|
28
|
-
</div>
|
|
29
|
-
<div class="quickforge-diff-block" style=${s(D)}>${t.map(e=>o`
|
|
30
|
-
<div class=${oe(e)} style=${s(I(e))}>${e||` `}</div>
|
|
31
|
-
`)}</div>
|
|
32
|
-
</div>
|
|
33
|
-
`}function le(e){if(!Number.isFinite(e)||e<0)return``;if(e<1e3)return`${Math.max(0,Math.round(e))}ms`;let t=e/1e3;return t<10?`${t.toFixed(1)}s`:t<60?`${Math.round(t)}s`:`${Math.floor(t/60)}m ${Math.floor(t%60).toString().padStart(2,`0`)}s`}function ue(e){if(e){if(typeof e.durationMs==`number`)return e.durationMs;if(typeof e.startedAt==`number`)return Date.now()-e.startedAt}}var de=class extends HTMLElement{timer;static get observedAttributes(){return[`duration-ms`,`running`,`started-at`]}connectedCallback(){this.render(),this.syncTimer()}disconnectedCallback(){this.stopTimer()}attributeChangedCallback(){this.render(),this.syncTimer()}readNumberAttribute(e){let t=this.getAttribute(e);if(t===null||t.trim()===``)return;let n=Number(t);return Number.isFinite(n)&&n>=0?n:void 0}syncTimer(){this.getAttribute(`running`)===`true`&&this.readNumberAttribute(`duration-ms`)===void 0?this.timer||=setInterval(()=>this.render(),500):this.stopTimer()}stopTimer(){this.timer&&=(clearInterval(this.timer),void 0)}render(){let e=this.readNumberAttribute(`duration-ms`),t=this.readNumberAttribute(`started-at`),n=e===void 0?t!==void 0&&t>0?Date.now()-t:0:e;this.textContent=le(n)}};customElements.get(`quickforge-elapsed-time`)||customElements.define(`quickforge-elapsed-time`,de);function fe(e,t){return ue(e)===void 0?a:o`
|
|
34
|
-
<quickforge-elapsed-time
|
|
35
|
-
class="text-xs text-muted-foreground/70"
|
|
36
|
-
started-at=${String(e?.startedAt??``)}
|
|
37
|
-
duration-ms=${typeof e?.durationMs==`number`?String(e.durationMs):``}
|
|
38
|
-
running=${String(t===`running`)}
|
|
39
|
-
></quickforge-elapsed-time>
|
|
40
|
-
`}function pe(){return`text-emerald-600 dark:text-emerald-500`}function me(e){let t=`quickforge-tool-type-icon shrink-0 ${pe()}`;return e===`manage_global_memory`?o`<svg class=${t} xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 18V5"/><path d="M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4"/><path d="M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5"/><path d="M17.997 5.125a4 4 0 0 1 2.526 5.77"/><path d="M18 18a4 4 0 0 0 2-7.464"/><path d="M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517"/><path d="M6 18a4 4 0 0 1-2-7.464"/><path d="M6.003 5.125a4 4 0 0 0-2.526 5.77"/></svg>`:e===`edit_file`?o`<svg class=${t} xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.4 2.6a2.1 2.1 0 0 1 3 3L12 15l-4 1 1-4Z"/></svg>`:e===`write_file`?o`<svg class=${t} xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"/><path d="M14 2v6h6"/><path d="M12 18v-6"/><path d="M9 15h6"/></svg>`:e===`read_file`?o`<svg class=${t} xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"/><path d="M14 2v6h6"/><path d="M16 13H8"/><path d="M16 17H8"/><path d="M10 9H8"/></svg>`:e===`grep_files`?o`<svg class=${t} xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`:e===`present_files`?o`<svg class=${t} xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"/><path d="M14 2v6h6"/><path d="M10 13.5 8 16l2 2.5"/><path d="m14 13.5 2 2.5-2 2.5"/></svg>`:e===`read_skill_resource`?o`<svg class=${t} xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 7v14"/><path d="M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3Z"/></svg>`:e===`run_command`?o`<svg class=${t} xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="4 17 10 11 4 5"/><line x1="12" x2="20" y1="19" y2="19"/></svg>`:e===`run_subagent`?o`<svg class=${t} xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 8V4H8"/><rect width="16" height="12" x="4" y="8" rx="2"/><path d="M2 14h2"/><path d="M20 14h2"/><path d="M15 13v2"/><path d="M9 13v2"/></svg>`:e===`activate_skill`?o`<svg class=${t} xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9.9 2.1 8.5 8.5 2.1 9.9l6.4 1.4 1.4 6.4 1.4-6.4 6.4-1.4-6.4-1.4Z"/><path d="M19 15v4"/><path d="M21 17h-4"/></svg>`:o`<svg class=${t} xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.8-3.8a6 6 0 0 1-7.9 7.9l-6.9 6.9a2.1 2.1 0 0 1-3-3l6.9-6.9a6 6 0 0 1 7.9-7.9Z"/></svg>`}function L(e){return e===`error`?`text-destructive`:e===`running`?`text-primary animate-spin`:e===`done`?`text-emerald-600 dark:text-emerald-500`:`text-muted-foreground/70`}function he(e){let t=`quickforge-tool-status-icon shrink-0 ${L(e)}`,n=_(e);return e===`running`?o`<svg class=${t} xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" role="img" aria-label=${n}><path d="M21 12a9 9 0 1 1-6.2-8.6"/></svg>`:e===`done`?o`<svg class=${t} xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" role="img" aria-label=${n}><path d="M22 11.1V12a10 10 0 1 1-5.9-9.1"/><path d="m9 11 3 3L22 4"/></svg>`:e===`error`?o`<svg class=${t} xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" role="img" aria-label=${n}><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`:o`<svg class=${t} xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" role="img" aria-label=${n}><circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="2" fill="currentColor" stroke="none"/></svg>`}function ge(e,t){return o`
|
|
41
|
-
<span class="shrink-0 inline-flex items-center gap-1.5" title=${_(e)}>
|
|
42
|
-
${he(e)}${fe(t,e)}
|
|
43
|
-
</span>
|
|
44
|
-
`}function _e(e,t,n){if(e!==`run_command`||t!==`running`)return a;let{sessionId:r,toolCallId:i}=ie(n);return!r||!i?a:o`
|
|
45
|
-
<button
|
|
46
|
-
type="button"
|
|
47
|
-
class="shrink-0 inline-flex size-5 items-center justify-center text-foreground transition-opacity hover:opacity-70 disabled:cursor-not-allowed disabled:opacity-40"
|
|
48
|
-
title=${_(`terminateCommandTitle`)}
|
|
49
|
-
aria-label=${_(`terminateCommandTitle`)}
|
|
50
|
-
@click=${e=>{e.preventDefault(),e.stopPropagation(),ae(r,i,e.currentTarget)}}
|
|
51
|
-
><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="7" y="7" width="10" height="10" rx="2.4"/></svg></button>
|
|
52
|
-
`}var ve=`quickforge:preview-artifact`;function R(e,t){if(e===`write_file`||e===`edit_file`){let e=t&&`path`in t&&typeof t.path==`string`?t.path:``;return e&&y(e)?e:``}if(e===`present_files`){let e=(t&&Array.isArray(t.files)?t.files:[]).map(e=>typeof e==`string`?e:M(e)&&typeof e.path==`string`?e.path:``).filter(Boolean),n=t&&typeof t.defaultPreview==`string`?t.defaultPreview:``;return n&&y(n)?n:e.find(e=>y(e))??``}return``}function ye(e,t){let n=R(e,t);return n?o`
|
|
53
|
-
<button
|
|
54
|
-
type="button"
|
|
55
|
-
class="shrink-0 inline-flex size-5 items-center justify-center text-muted-foreground transition-colors hover:text-foreground"
|
|
56
|
-
title=${_(`previewArtifact`)}
|
|
57
|
-
aria-label=${_(`previewArtifact`)}
|
|
58
|
-
@click=${e=>{e.preventDefault(),e.stopPropagation(),window.dispatchEvent(new CustomEvent(ve,{detail:{path:n}}))}}
|
|
59
|
-
><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg></button>
|
|
60
|
-
`:a}function be(e,t){return M(t)&&typeof t.label==`string`&&t.label?t.label:e===`general`?_(`subagentGeneral`):e===`explore`?_(`subagentExplore`):e||_(`runSubagent`)}function xe(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Se(e){return Array.isArray(e)?e:[]}function Ce(e){let t=new Set,n=[];for(let r of e){if(!M(r)||r.role!==`assistant`||!Array.isArray(r.content))continue;let e=r.content.filter(e=>M(e)&&e.type===`toolCall`);if(e.length!==0){for(let n of e)M(n)&&typeof n.id==`string`&&t.add(n.id);n.push({...r,content:e,usage:void 0})}}let r=e.filter(e=>M(e)&&e.role===`toolResult`&&typeof e.toolCallId==`string`&&t.has(e.toolCallId));return[...n,...r]}var z=new Map,we=100;function Te(e,t){if(e){if(!z.has(e)&&z.size>=we){let e=z.keys().next().value;e&&z.delete(e)}z.set(e,t)}}var B=class{render(e,t,n){let r=t?.isError?`error`:n?`running`:t?`done`:`called`,i=v(t?.details),s=M(t?.details)?t.details:void 0,c=typeof e?.subagent==`string`?e.subagent:typeof s?.subagent==`string`?s.subagent:``,l=be(c,s),u=typeof e?.task==`string`?e.task:``,d=typeof e?.context==`string`?e.context:``,f=typeof e?.expectedOutput==`string`?e.expectedOutput:``,m=typeof s?.toolCalls==`number`?s.toolCalls:void 0,h=xe(s?.allowedTools),g=Se(s?.messages),y=Se(s?.tools),b=new Set(xe(s?.pendingToolCalls)),x=p(),S=x.showToolDetails?g:Ce(g),C=x.showToolDetails?A(e):``,w=x.showToolDetails?A(t?.details):``,T=j(t),E=typeof s?.sessionId==`string`?s.sessionId:`${c}:${u}`,D=z.get(E)??x.expandToolsByDefault,O=r===`running`?_(`subagentRunning`,{name:l}):r===`done`?_(`subagentCompleted`,{name:l}):r===`error`?_(`subagentFailed`,{name:l}):_(`runSubagent`);return{isCustom:!1,content:o`
|
|
61
|
-
<details class="group/tool quickforge-subagent-tool" ?open=${D} @toggle=${e=>Te(E,e.currentTarget.open)}>
|
|
62
|
-
<summary class="flex cursor-pointer list-none items-center gap-2 text-sm text-muted-foreground select-none">
|
|
63
|
-
<svg class="shrink-0 transition-transform group-open/tool:rotate-90" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg>
|
|
64
|
-
${me(`run_subagent`)}
|
|
65
|
-
<span class="min-w-0 flex-1 truncate">${O}</span>
|
|
66
|
-
${ge(r,i)}
|
|
67
|
-
</summary>
|
|
68
|
-
<div class="mt-3 space-y-3">
|
|
69
|
-
${u||d||f?o`<div class="quickforge-subagent-task rounded-lg border border-border bg-background/60 px-3 py-2.5 text-sm">
|
|
70
|
-
${u?o`<div class="text-muted-foreground/85"><span class="font-medium text-foreground/75">${_(`subagentTask`)}:</span> ${u}</div>`:a}
|
|
71
|
-
${d?o`<div class="mt-1 text-xs text-muted-foreground/70"><span class="font-medium">${_(`subagentContext`)}:</span> ${d}</div>`:a}
|
|
72
|
-
${f?o`<div class="mt-1 text-xs text-muted-foreground/70"><span class="font-medium">${_(`subagentExpectedOutput`)}:</span> ${f}</div>`:a}
|
|
73
|
-
</div>`:a}
|
|
74
|
-
${x.showToolDetails?o`<div class="quickforge-subagent-summary rounded-lg border border-border/75 bg-muted/20 px-3 py-2.5 text-sm">
|
|
75
|
-
<div class="flex flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground">
|
|
76
|
-
<span class="font-medium text-foreground/85">${l}</span>
|
|
77
|
-
${m===void 0?a:o`<span>${_(`subagentToolCalls`)}: ${m}</span>`}
|
|
78
|
-
${i?o`<span>${fe(i,r)}</span>`:a}
|
|
79
|
-
</div>
|
|
80
|
-
${h.length>0?o`<div class="mt-2 flex flex-wrap gap-1.5">${h.map(e=>o`<span class="rounded-full bg-background/80 px-2 py-0.5 text-[11px] text-muted-foreground/80">${e}</span>`)}</div>`:a}
|
|
81
|
-
</div>`:a}
|
|
82
|
-
${S.length>0?o`<div class="quickforge-subagent-trace rounded-lg border border-border bg-background/60 p-2.5"><message-list .messages=${S} .tools=${y} .pendingToolCalls=${b} .isStreaming=${r===`running`}></message-list></div>`:a}
|
|
83
|
-
${T?o`<div><div class="mb-1 text-xs font-medium text-muted-foreground">${_(`subagentResult`)}</div><code-block .code=${T} language="text"></code-block></div>`:a}
|
|
84
|
-
${C?o`<div><div class="mb-1 text-xs font-medium text-muted-foreground">${_(`input`)}</div><code-block .code=${C} language="json"></code-block></div>`:a}
|
|
85
|
-
${w?o`<div><div class="mb-1 text-xs font-medium text-muted-foreground">${_(`details`)}</div><code-block .code=${w} language="json"></code-block></div>`:a}
|
|
86
|
-
</div>
|
|
87
|
-
</details>
|
|
88
|
-
`}}},Ee=class{toolName;labelKey;constructor(e,t){this.toolName=e,this.labelKey=t}render(e,t,n){let r=t?.isError?`error`:n?`running`:t?`done`:`called`,i=v(t?.details),a=ne(this.toolName,e,t),s=p(),c=s.showToolDetails,l=s.expandToolsByDefault,u=c?A(e):``,d=te(this.toolName,e,t,n),f=re(t?.details),m=c?A(f?F(t?.details):t?.details):``,h=t?.isError?`error`:`default`;return{isCustom:!1,content:o`
|
|
89
|
-
<details class="group/tool" ?open=${l}>
|
|
90
|
-
<summary class="flex cursor-pointer list-none items-center gap-2 text-sm text-muted-foreground select-none">
|
|
91
|
-
<svg class="shrink-0 transition-transform group-open/tool:rotate-90" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg>
|
|
92
|
-
${me(this.toolName)}
|
|
93
|
-
<span class="min-w-0 flex-1 truncate">${_(this.labelKey)}${a?o`<span class="text-muted-foreground/70"> · ${a}</span>`:``}</span>
|
|
94
|
-
${se(this.toolName,f)}
|
|
95
|
-
${ye(this.toolName,e)}
|
|
96
|
-
${_e(this.toolName,r,t?.details)}
|
|
97
|
-
${ge(r,i)}
|
|
98
|
-
</summary>
|
|
99
|
-
<div class="mt-3 space-y-3">
|
|
100
|
-
${u?o`<div><div class="mb-1 text-xs font-medium text-muted-foreground">${_(`input`)}</div><code-block .code=${u} language="json"></code-block></div>`:``}
|
|
101
|
-
${d?o`<div><div class="mb-1 text-xs font-medium text-muted-foreground">${_(`output`)}</div>${this.toolName===`run_command`?o`<console-block .content=${d} .variant=${h}></console-block>`:o`<code-block .code=${d} language="text"></code-block>`}</div>`:``}
|
|
102
|
-
${f?ce(f):``}
|
|
103
|
-
${m?o`<div><div class="mb-1 text-xs font-medium text-muted-foreground">${_(`details`)}</div><code-block .code=${m} language="json"></code-block></div>`:``}
|
|
104
|
-
</div>
|
|
105
|
-
</details>
|
|
106
|
-
`}}};function De(e){if(!e.startsWith(`mcp__`))return null;let t=e.slice(5),n=t.indexOf(`__`);return n<=0||n>=t.length-2?null:{serverName:t.slice(0,n),toolName:t.slice(n+2)}}function Oe(e,t){let n=De(e),r=M(t)?t:void 0,i=typeof r?.server==`string`&&r.server?r.server:n?.serverName??``,a=typeof r?.tool==`string`&&r.tool?r.tool:n?.toolName??e;return n||r?.mcp===!0?{serverName:i,toolName:a}:null}function V(e){if(!e)return`text`;try{return JSON.parse(e),`json`}catch{return`text`}}var H=class{toolName;label;constructor(e,t){this.toolName=e,this.label=t}render(e,t,n){let r=t?.isError?`error`:n?`running`:t?`done`:`called`,i=v(t?.details),s=Oe(this.toolName,t?.details)??De(this.toolName),c=s?.serverName??``,l=s?.toolName??this.toolName,u=ne(this.toolName,e,t),d=p(),f=A(e),m=te(this.toolName,e,t,n),h=d.showToolDetails?A(t?.details):``,g=this.label&&this.label!==l?`${this.label} (${l})`:l;return{isCustom:!1,content:o`
|
|
107
|
-
<details class="group/tool quickforge-mcp-tool" ?open=${d.expandToolsByDefault}>
|
|
108
|
-
<summary class="flex cursor-pointer list-none items-center gap-2 text-sm text-muted-foreground select-none">
|
|
109
|
-
<svg class="shrink-0 transition-transform group-open/tool:rotate-90" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg>
|
|
110
|
-
${me(this.toolName)}
|
|
111
|
-
<span class="min-w-0 flex-1 truncate">MCP${c?o`<span class="text-muted-foreground/70"> · ${c}</span>`:a}<span class="text-muted-foreground/70"> · ${g}</span>${u?o`<span class="text-muted-foreground/70"> · ${u}</span>`:a}</span>
|
|
112
|
-
${ge(r,i)}
|
|
113
|
-
</summary>
|
|
114
|
-
<div class="mt-3 space-y-3">
|
|
115
|
-
${f?o`<div><div class="mb-1 text-xs font-medium text-muted-foreground">${_(`input`)}</div><code-block .code=${f} language="json"></code-block></div>`:a}
|
|
116
|
-
${m?o`<div><div class="mb-1 text-xs font-medium text-muted-foreground">${_(`output`)}</div><code-block .code=${m} language=${V(m)}></code-block></div>`:a}
|
|
117
|
-
${h?o`<div><div class="mb-1 text-xs font-medium text-muted-foreground">${_(`details`)}</div><code-block .code=${h} language="json"></code-block></div>`:a}
|
|
118
|
-
</div>
|
|
119
|
-
</details>
|
|
120
|
-
`}}},U=new Set;function ke(e){for(let t of e){if(!M(t)||typeof t.name!=`string`||!De(t.name)||U.has(t.name))continue;let e=typeof t.label==`string`?t.label:typeof t.description==`string`?t.description.replace(/^\[MCP:[^\]]+\]\s*/,``):void 0;u(t.name,new H(t.name,e)),U.add(t.name)}}for(let[e,t]of[[`manage_global_memory`,`manageGlobalMemory`],[`read_file`,`readFile`],[`grep_files`,`searchFiles`],[`write_file`,`writeFile`],[`edit_file`,`editFile`],[`run_command`,`runCommand`],[`present_files`,`presentFiles`],[`activate_skill`,`activateSkill`],[`read_skill_resource`,`readSkillResource`]])u(e,new Ee(e,t));u(`run_subagent`,new B);function Ae(e=[]){return ke(e),e}function W(e,t){let n=document.createElement(`template`);n.innerHTML=t;let r=n.content.firstElementChild;if(!r)return;let i=e.querySelector(`svg`);i?i.replaceWith(r):e.appendChild(r)}function je(e,t){let n=document.createElement(`template`);n.innerHTML=t;let r=Array.from(n.content.children);for(let t of Array.from(e.children))t.remove();for(let t of r)e.appendChild(t)}var Me=()=>({text:``,attachments:[]}),G=e=>e.text.length>0||(e.attachments?.length??0)>0;function Ne(e){try{return JSON.stringify(e)}catch{return``}}function Pe(e){let t=String(e||``);if(!t)return 0;let n=t.match(/[\u3400-\u9fff\uf900-\ufaff]/g)?.length??0,r=Math.max(0,t.length-n);return Math.ceil(n+r/3.5)}function Fe(e){return e?typeof e==`string`?e:Array.isArray(e)?e.map(e=>{if(!e||typeof e!=`object`)return Fe(e);let t=e;return t.type===`text`?typeof t.text==`string`?t.text:``:t.type===`thinking`?typeof t.thinking==`string`?t.thinking:``:t.type===`image`?`[image:${typeof t.mimeType==`string`?t.mimeType:`unknown`}]`:t.type===`toolCall`?`[toolCall:${typeof t.name==`string`?t.name:`unknown`}] ${Ne(t.arguments)}`:Ne(t)}).filter(Boolean).join(`
|
|
121
|
-
`):typeof e==`object`?Ne(e):String(e):``}function Ie(e){let t=[e.role??``,Fe(e.content)];return e.toolName&&t.push(e.toolName),e.toolCallId&&t.push(e.toolCallId),e.attachments!==void 0&&t.push(Ne(e.attachments)),Pe(t.filter(Boolean).join(`
|
|
122
|
-
`))}function Le(e,t,n=[]){return Pe(e)+t.reduce((e,t)=>e+Ie(t),0)+Pe(Ne(n))}function Re(e){if(typeof e.timestamp==`number`)return e.timestamp;if(typeof e.timestamp==`string`){let t=Date.parse(e.timestamp);return Number.isNaN(t)?0:t}return 0}function ze(e){return e.role===`user`&&Fe(e.content).includes(`<compact_summary>`)}function Be(e){let t=0;for(let n of e)ze(n)&&(t=Math.max(t,Re(n)));return t}function Ve(e,t,n,r=[],i){let a=Be(t),o=t.reduce((e,t)=>{let n=t.usage;return t.role!==`assistant`||!n||a>0&&Re(t)<=a?e:n},void 0),s=o?.input??o?.totalTokens??0,c=Le(e,t,r),l=Number.isFinite(Number(s))&&Number(s)>0,u=l?Number(s):c,d=u,f=l?`provider`:`estimated`,p=Math.max(0,Number(i)||4096),m=d+p,h=n>0?Math.round(m/n*1e3)/10:0,g=Math.round(142-142*Math.min(100,Math.max(0,h))/100);return{contextWindow:n,usedTokens:d,totalTokens:m,inputTokens:u,estimatedInputTokens:c,knownInputTokens:l?Number(s):0,inputTokenSource:f,reservedOutputTokens:p,percent:h,color:`hsl(${g} 72% 45%)`}}function K(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function He({panel:e}){let t=!0,n,r=0,i,a=-1/0,o=-1/0,s,c=()=>e.querySelector(`agent-interface .overflow-y-auto`),l=e=>e.scrollHeight-e.scrollTop-e.clientHeight<=80,u=t=>{e.querySelector(`agent-interface`)?.setAutoScroll?.(t)},d=()=>{let e=Math.max(a,o);return window.performance.now()-e<=500},f=()=>{n!==void 0&&(window.cancelAnimationFrame(n),n=void 0),t=!1,u(!1)},p=()=>{a=window.performance.now(),f()},m=()=>{o=window.performance.now()},h=()=>{let e=c();if(!e||!t)return;let n=e.scrollHeight-e.clientHeight;if(Math.abs(e.scrollTop-n)<=1){r=e.scrollTop;return}e.scrollTop=e.scrollHeight,r=e.scrollTop},g=()=>{n===void 0&&(n=window.requestAnimationFrame(()=>{n=void 0,h(),window.requestAnimationFrame(h)}))},_=()=>{t=!0,u(!0),g()},v=()=>{let e=c();if(!e)return;let n=e.scrollTop,i=n<r-1,a=i&&d();if(i&&t&&!a&&!l(e)){r=n,g();return}a?f():l(e)&&(t=!0,u(!0)),r=n},y=e=>{e.deltaY<0&&p()},b=e=>{e.target===e.currentTarget&&m()},x=e=>{(e.key===`ArrowUp`||e.key===`PageUp`||e.key===`Home`)&&p()},S=e=>{i=e.touches[0]?.clientY},C=e=>{let t=e.touches[0]?.clientY;t===void 0||i===void 0||(t>i+1&&p(),i=t)};return{get isEnabled(){return t},enable:_,disable:f,scheduleScrollToBottom:g,setup:()=>{let n=c();if(!n||s)return;r=n.scrollTop,n.addEventListener(`scroll`,v,{passive:!0}),n.addEventListener(`wheel`,y,{passive:!0}),n.addEventListener(`pointerdown`,b,{passive:!0}),n.addEventListener(`keydown`,x),n.addEventListener(`touchstart`,S,{passive:!0}),n.addEventListener(`touchmove`,C,{passive:!0}),s=new ResizeObserver(()=>{t&&g()}),s.observe(n);let i=n.querySelector(`.max-w-3xl`);i&&s.observe(i);let a=e.querySelector(`.quickforge-composer-dock`);a&&s.observe(a),_()},cleanup:()=>{let e=c();e?.removeEventListener(`scroll`,v),e?.removeEventListener(`wheel`,y),e?.removeEventListener(`pointerdown`,b),e?.removeEventListener(`keydown`,x),e?.removeEventListener(`touchstart`,S),e?.removeEventListener(`touchmove`,C),s?.disconnect(),s=void 0,n!==void 0&&(window.cancelAnimationFrame(n),n=void 0)}}}function Ue({panel:e,getCustomCommands:t,restoreDraftIntoComposer:n}){let r=e=>`/${e.name}${e.argumentHint?` ${e.argumentHint}`:``}`,i=()=>[{name:`plan`,description:_(`planCommandDescription`),argumentHint:`[task]`},{name:`review`,description:_(`reviewCommandDescription`),argumentHint:`[scope]`},{name:`summary`,description:_(`summaryCommandDescription`),argumentHint:``},{name:`compact`,description:_(`compactCommandDescription`),argumentHint:``},{name:`clear`,description:_(`clearCommandDescription`),argumentHint:``},{name:`help`,description:_(`helpCommandDescription`),argumentHint:``}],a=()=>{let n=(e.querySelector(`.quickforge-command-suggestions`)?.querySelector(`.quickforge-command-suggestion-item`))?.dataset.quickforgeCommandName;if(n)return[...i(),...t()].find(e=>e.name===n)},o=()=>{let t=e.querySelector(`.quickforge-command-suggestions`);t?.__quickforgeDismissHandler&&(document.removeEventListener(`pointerdown`,t.__quickforgeDismissHandler,!0),t.__quickforgeDismissHandler=void 0),t?.remove()},s=t=>{let r=e.querySelector(`message-editor`),i=`/${t.name}${t.argumentHint?` `:``}`;n({text:i,attachments:[]});let a=r?.querySelector(`textarea`);a?.focus(),a&&(a.selectionStart=i.length,a.selectionEnd=i.length),o()};return{update:n=>{let a=e.querySelector(`message-editor`),c=n??a?.value??a?.querySelector(`textarea`)?.value??``,l=a?.querySelector(`textarea`),u=e.querySelector(`.quickforge-command-suggestions`);if(!a||!l||!c.startsWith(`/`)){u?.remove();return}let d=c.slice(1).trim().toLowerCase(),f=t(),p=[...i(),...f].filter(e=>e.name.includes(d)||e.description?.toLowerCase().includes(d));if(p.length===0){u?.remove();return}let m=u??document.createElement(`div`);m.className=`quickforge-command-suggestions`,m.setAttribute(`role`,`listbox`),m.innerHTML=``;let h=document.createElement(`div`);h.className=`quickforge-command-suggestions-header`,h.textContent=_(f.length?`customCommandsHint`:`customCommandsEmptyHint`),m.append(h);for(let e of p){let t=document.createElement(`button`);t.type=`button`,t.className=`quickforge-command-suggestion-item`,t.dataset.quickforgeCommandName=e.name,t.setAttribute(`role`,`option`),t.innerHTML=`
|
|
123
|
-
<span class="quickforge-command-suggestion-name"></span>
|
|
124
|
-
<span class="quickforge-command-suggestion-description"></span>
|
|
125
|
-
`,t.querySelector(`.quickforge-command-suggestion-name`).textContent=r(e),t.querySelector(`.quickforge-command-suggestion-description`).textContent=e.description??``,t.onpointerdown=t=>{t.preventDefault(),t.stopPropagation(),s(e)},m.append(t)}u||a.parentElement?.insertBefore(m,a),m.__quickforgeDismissHandler||(m.__quickforgeDismissHandler=e=>{m.contains(e.target)||a.contains(e.target)||o()},document.addEventListener(`pointerdown`,m.__quickforgeDismissHandler,!0))},remove:o,setupTextareaHandler:e=>{let t=e?.querySelector(`textarea`);if(!t)return;let n=t;n.__quickforgeCommandCompleteHandler&&n.removeEventListener(`keydown`,n.__quickforgeCommandCompleteHandler,!0),n.__quickforgeCommandCompleteHandler=t=>{if(t.isComposing||t.key===`Process`)return;if(t.key===`Enter`&&t.shiftKey){t.stopImmediatePropagation();return}if(t.key!==`Tab`||!(e?.value??n.value??``).startsWith(`/`)||t.shiftKey)return;let r=a();r&&(t.preventDefault(),t.stopPropagation(),s(r))},n.addEventListener(`keydown`,n.__quickforgeCommandCompleteHandler,!0)},cleanupTextareaHandler:()=>{let t=e.querySelector(`message-editor textarea`);t?.__quickforgeCommandCompleteHandler&&t.removeEventListener(`keydown`,t.__quickforgeCommandCompleteHandler,!0)}}}var We={plugin:`
|
|
126
|
-
<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
|
|
127
|
-
<path d="M7.4 3.2h5.2a1.2 1.2 0 0 1 1.2 1.2v2.1h.9a2.1 2.1 0 1 1 0 4.2h-.9v2.1a1.2 1.2 0 0 1-1.2 1.2h-2.1v.7a2.1 2.1 0 1 1-4.2 0V14H4.4a1.2 1.2 0 0 1-1.2-1.2V9.9h.8a1.8 1.8 0 1 0 0-3.6h-.8V4.4a1.2 1.2 0 0 1 1.2-1.2h2.1v-.8a1.8 1.8 0 1 1 3.6 0v.8Z" />
|
|
128
|
-
</svg>`,document:`
|
|
129
|
-
<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.65" stroke-linecap="round" stroke-linejoin="round">
|
|
130
|
-
<path d="M5.4 2.8h6.1L15.8 7v10.2H5.4z" />
|
|
131
|
-
<path d="M11.4 2.9V7h4.1" />
|
|
132
|
-
<path d="M7.6 10.2h5" />
|
|
133
|
-
<path d="M7.6 13h4.3" />
|
|
134
|
-
</svg>`,spreadsheet:`
|
|
135
|
-
<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.65" stroke-linecap="round" stroke-linejoin="round">
|
|
136
|
-
<rect x="3.4" y="4" width="13.2" height="12.2" rx="1.5" />
|
|
137
|
-
<path d="M3.4 8h13.2" />
|
|
138
|
-
<path d="M7.8 4v12.2" />
|
|
139
|
-
<path d="M12.2 4v12.2" />
|
|
140
|
-
<path d="M3.4 12h13.2" />
|
|
141
|
-
</svg>`,presentation:`
|
|
142
|
-
<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.65" stroke-linecap="round" stroke-linejoin="round">
|
|
143
|
-
<path d="M3 4.2h14" />
|
|
144
|
-
<rect x="4.2" y="4.2" width="11.6" height="8.4" rx="1.2" />
|
|
145
|
-
<path d="M10 12.6v3.2" />
|
|
146
|
-
<path d="m7.2 17 2.8-1.2 2.8 1.2" />
|
|
147
|
-
<path d="M7.1 9.5 9 7.7l1.5 1.3 2.4-2.5" />
|
|
148
|
-
</svg>`,skill:`
|
|
149
|
-
<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
|
|
150
|
-
<path d="M4.2 3.2h4.4A2.4 2.4 0 0 1 11 5.6v11a2.4 2.4 0 0 0-2.4-2.4H4.2V3.2Z" />
|
|
151
|
-
<path d="M11 5.6a2.4 2.4 0 0 1 2.4-2.4h2.4v11.1h-2.4A2.4 2.4 0 0 0 11 16.7" />
|
|
152
|
-
</svg>`,tool:`
|
|
153
|
-
<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
|
154
|
-
<path d="M12.8 3.5a4.2 4.2 0 0 0 4 5.5l-7.6 7.6a2.2 2.2 0 0 1-3.1-3.1l7.6-7.6a4.2 4.2 0 0 0-5.5-4" />
|
|
155
|
-
</svg>`,command:`
|
|
156
|
-
<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
|
157
|
-
<path d="m5 6 4 4-4 4" />
|
|
158
|
-
<path d="M10.5 14h4.5" />
|
|
159
|
-
</svg>`};function Ge(e){return e.split(/[-_/\\]+/).filter(Boolean).map(e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`).join(` `)}function Ke(e){switch(e.name){case`openai-documents`:return{label:_(`pluginOpenaiDocumentsName`),description:_(`pluginOpenaiDocumentsDescription`),mention:`Documents`,iconKind:`document`};case`openai-spreadsheets`:return{label:_(`pluginOpenaiSpreadsheetsName`),description:_(`pluginOpenaiSpreadsheetsDescription`),mention:`Spreadsheets`,iconKind:`spreadsheet`};case`openai-presentations`:return{label:_(`pluginOpenaiPresentationsName`),description:_(`pluginOpenaiPresentationsDescription`),mention:`Presentations`,iconKind:`presentation`};default:return null}}function qe(e){let t=Ke(e);return t?t.label:(e.displayName||Ge(e.name.replace(/^openai-/,``))).replace(/^OpenAI\s+/i,``)}function Je(e){let t=Ke(e),n=t?.label??qe(e),r=t?.mention??n.replace(/\s+/g,``);return[{type:`plugin`,iconKind:t?.iconKind??`plugin`,pluginName:e.name,name:e.name,label:n,mention:r,insertText:r,description:t?.description??e.description}]}function Ye(e,t){let n=e.slice(0,t),r=/(^|\s)@([^\s@]*)$/.exec(n);if(!r)return null;let i=r[1]?.length??0;return{start:n.length-r[0].length+i,end:t,query:r[2]??``}}function Xe(e){let t=new Set,n=/(^|\s)@([\p{L}\p{N}_-]+)/gu,r;for(;r=n.exec(e);)t.add((r[2]||``).toLowerCase());return t}function Ze({panel:e,restoreDraftIntoComposer:t,onSelectionChange:n}){let r=[],i=null,a=new Map,o=()=>n?.([...a.values()]),s=()=>i||(i=b().then(e=>{r=(e.plugins??[]).filter(e=>e.enabled&&e.status===`loaded`)}).catch(()=>{r=[]}).finally(()=>{i=null}),i);s();let c=()=>r.flatMap(Je),l=()=>{let t=(e.querySelector(`.quickforge-capability-suggestions`)?.querySelector(`.quickforge-capability-suggestion-item`))?.dataset.quickforgeCapabilityKey;if(t)return c().find(e=>Qe(e)===t)},u=()=>{let t=e.querySelector(`.quickforge-capability-suggestions`);t?.__quickforgeDismissHandler&&(document.removeEventListener(`pointerdown`,t.__quickforgeDismissHandler,!0),t.__quickforgeDismissHandler=void 0),t?.remove()},d=(n,r)=>{let i=e.querySelector(`message-editor`),s=i?.querySelector(`textarea`),c=i?.value??s?.value??``,l=s?.selectionStart??c.length,d=r??Ye(c,l),f=`@${n.insertText}`,p=d?`${c.slice(0,d.start)}${f} ${c.slice(d.end)}`:`${c}${c.endsWith(` `)||c.length===0?``:` `}${f} `,m=d?d.start+f.length+1:p.length;a.set(Qe(n),n),o(),t({text:p,attachments:i?.attachments?[...i.attachments]:[]});let h=i?.querySelector(`textarea`);h?.focus(),h&&(h.selectionStart=m,h.selectionEnd=m),u()},f=e=>{let t=()=>{let t=c().find(t=>t.insertText===e);t&&d(t)};if(r.length===0){s().then(t);return}t()},p=t=>{let n=e.querySelector(`message-editor`),i=n?.querySelector(`textarea`),a=t??n?.value??i?.value??``,o=Ye(a,i?.selectionStart??a.length),l=e.querySelector(`.quickforge-capability-suggestions`);if(!n||!i||!o){l?.remove();return}r.length===0&&s().then(()=>p(t));let f=o.query.toLowerCase(),m=c().filter(e=>[e.label,e.name,e.pluginName,e.description].filter(Boolean).join(` `).toLowerCase().includes(f)).slice(0,8);if(m.length===0){l?.remove();return}let h=l??document.createElement(`div`);h.className=`quickforge-capability-suggestions`,h.setAttribute(`role`,`listbox`),h.innerHTML=``;let g=document.createElement(`div`);g.className=`quickforge-capability-suggestions-header`,g.textContent=_(`pluginMentionHeader`),h.append(g);for(let e of m){let t=document.createElement(`button`);t.type=`button`,t.className=`quickforge-capability-suggestion-item`,t.dataset.quickforgeCapabilityKey=Qe(e),t.dataset.quickforgePluginName=e.pluginName,t.setAttribute(`role`,`option`),t.innerHTML=`
|
|
160
|
-
<span class="quickforge-capability-suggestion-icon quickforge-capability-suggestion-icon-${e.iconKind}">${We[e.iconKind]}</span>
|
|
161
|
-
<span class="quickforge-capability-suggestion-main">
|
|
162
|
-
<span class="quickforge-capability-suggestion-line">
|
|
163
|
-
<span class="quickforge-capability-suggestion-name"></span>
|
|
164
|
-
</span>
|
|
165
|
-
<span class="quickforge-capability-suggestion-description"></span>
|
|
166
|
-
</span>
|
|
167
|
-
`,t.querySelector(`.quickforge-capability-suggestion-name`).textContent=e.label,t.querySelector(`.quickforge-capability-suggestion-description`).textContent=e.description??e.pluginName,t.onpointerdown=t=>{t.preventDefault(),t.stopPropagation(),d(e,o)},h.append(t)}l||n.parentElement?.insertBefore(h,n),h.__quickforgeDismissHandler||(h.__quickforgeDismissHandler=e=>{h.contains(e.target)||n.contains(e.target)||u()},document.addEventListener(`pointerdown`,h.__quickforgeDismissHandler,!0))};return{update:p,remove:u,setupTextareaHandler:e=>{let t=e?.querySelector(`textarea`);if(!t)return;let n=t;n.__quickforgeCapabilityCompleteHandler&&n.removeEventListener(`keydown`,n.__quickforgeCapabilityCompleteHandler,!0),n.__quickforgeCapabilityCompleteHandler=t=>{if(t.isComposing||t.key===`Process`)return;if(t.key===`Escape`){u();return}if(t.key!==`Tab`&&t.key!==`Enter`)return;let r=e?.value??n.value??``,i=Ye(r,n.selectionStart??r.length);if(!i||t.shiftKey)return;let a=l();a&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),d(a,i))},n.addEventListener(`keydown`,n.__quickforgeCapabilityCompleteHandler,!0)},cleanupTextareaHandler:()=>{let t=e.querySelector(`message-editor textarea`);t?.__quickforgeCapabilityCompleteHandler&&t.removeEventListener(`keydown`,t.__quickforgeCapabilityCompleteHandler,!0)},consumeSelectedCapabilities:e=>{let t=Xe(e),n=[...a.values()].filter(e=>t.has(e.mention.toLowerCase())),r=c().filter(e=>t.has(e.insertText.toLowerCase())||t.has(e.label.replace(/\s+/g,``).toLowerCase())),i=new Map;for(let e of[...n,...r])i.set(Qe(e),e);return a=new Map,o(),[...i.values()].slice(0,4)},insertBuiltinPluginMention:f}}function Qe(e){return`${e.type}:${e.pluginName}:${e.name}`}var $e=i();function et(e){return`hsl(${Math.round(142-142*Math.min(100,Math.max(0,e))/100)} 72% 45%)`}function tt(e,t){let n=Number(e.inputTokens)||0,r=Math.max(0,Number(e.knownInputTokens??e.providerContextTokens)||0),i=Math.max(0,Number(e.estimatedInputTokens)||0),a=Math.max(0,Number(e.reservedOutputTokens)||0),o=Math.max(0,Number(e.totalTokens)||n+a),s=Number.isFinite(Number(e.percent))?Number(e.percent):0,c=e.inputTokenSource??(r>0?`provider`:`estimated`);return{contextWindow:Math.max(0,Number(e.contextWindow)||t),usedTokens:Math.max(0,Number(e.usedTokens)||n),totalTokens:o,inputTokens:n,estimatedInputTokens:i,knownInputTokens:r,inputTokenSource:c,reservedOutputTokens:a,percent:s,color:e.color||et(s),isCompacted:e.isCompacted,compactedUpToIndex:e.compactedUpToIndex,originalMessageCount:e.originalMessageCount,effectiveMessageCount:e.effectiveMessageCount,breakdown:e.breakdown}}function nt(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function rt(e){let t=Math.max(0,Number(e)||0);return t>0?K(t):null}function it({usage:e,contextWindow:t,serverCalculated:n,compacted:r}){let i=e.inputTokenSource===`provider`?`provider context`:e.inputTokenSource===`mixed`?`provider/local mixed context`:`estimated context`,a=[`Context used: ${e.percent}% (${K(e.totalTokens)} / ${K(t)} tokens)`,`Input/context: ${K(e.inputTokens)} (${i})`,`Local estimate: ${K(e.estimatedInputTokens)}`],o=e.breakdown;return o&&(a.push(` System prompt: ${rt(o.systemPromptTokens)??`0`}`,` Tools schema: ${rt(o.toolsTokens)??`0`}`,` Messages: ${rt(o.messagesTokens)??`0`}`),(o.providerUsageTokens||o.trailingTokens)&&a.push(` Provider usage baseline: ${rt(o.providerUsageTokens)??`0`}`,` Trailing messages after usage: ${rt(o.trailingTokens)??`0`}`)),a.push(`Reserved output: ${K(e.reservedOutputTokens)}`),n&&a.push(`Source: server calculated via pi-agent-core/pi-ai`),a.push(r?`Scope: compacted model context, not full visible chat history`:`Scope: full model context`),r&&e.originalMessageCount!==void 0&&e.effectiveMessageCount!==void 0&&a.push(`Messages: ${e.effectiveMessageCount} effective / ${e.originalMessageCount} visible`),e.knownInputTokens&&e.knownInputTokens>0&&a.push(`Provider context tokens: ${K(e.knownInputTokens)}`),a.join(`
|
|
168
|
-
`)}function at(e,t){if(!t){e.removeAttribute(`role`),e.removeAttribute(`tabindex`),e.style.cursor=``;return}e.setAttribute(`role`,`button`),e.tabIndex=0,e.style.cursor=`pointer`,!e.dataset.quickforgeGitBranchBound&&(e.dataset.quickforgeGitBranchBound=`true`,e.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),t()}),e.addEventListener(`keydown`,e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),e.stopPropagation(),t())}))}var ot=(0,$e.renderToStaticMarkup)((0,w.createElement)(n,{size:13,strokeWidth:2,"aria-hidden":!0,style:{flex:`0 0 auto`}}));function st({panel:e,getSystemPrompt:t,getMessages:n,getContextWindow:r,getTools:i,getMaxTokens:a,getEffectiveMessages:o,getServerContextUsage:s,getGitBranch:c,onGitBranchClick:l,renderInline:u=!0,onDisplayChange:d}){return{update:()=>{let f=r(),p=n(),m=o?.()??p,h=e.querySelector(`.quickforge-context-usage`),g=e.querySelector(`.quickforge-context-usage-label`),_=e.querySelector(`.quickforge-git-branch-inline`),v=u?e.querySelector(`message-editor`)?.parentElement?.querySelector(`.ml-auto.items-center`):null,y=c?.()?.trim()||void 0,b={gitBranch:y};if(!u)_?.remove(),h?.remove(),g?.remove();else if(y&&v){let e=`${ot}<span style="max-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${nt(y)}</span>`,t=`Git branch: ${y}`;if(_)_.dataset.quickforgeGitBranch!==y&&(_.innerHTML=e,_.dataset.quickforgeGitBranch=y),_.title=t,_.setAttribute(`aria-label`,t),at(_,l);else{let n=document.createElement(`span`);n.className=`quickforge-git-branch-inline`,n.dataset.quickforgeGitBranch=y,n.title=t,n.setAttribute(`aria-label`,t),n.innerHTML=e,n.style.cssText=[`display: inline-flex`,`align-items: center`,`gap: 0.25rem`,`max-width: 10rem`,`color: hsl(var(--muted-foreground))`,`font-size: 12px`,`line-height: 1`,`font-weight: 500`].join(`;`),at(n,l),v.prepend(n)}}else _?.remove();if(!f)return u&&(h?.remove(),g?.remove()),d?.(b),b;let x=s?.(),S=m.length>0,C=x?tt(x,f):S?Ve(t(),m,f,i?.()??[],a?.()):{contextWindow:f,usedTokens:0,totalTokens:0,inputTokens:0,estimatedInputTokens:0,inputTokenSource:`estimated`,reservedOutputTokens:0,percent:0,color:`hsl(142 72% 45%)`},w=C.contextWindow||f,T=!!C.isCompacted||m!==p,E=it({usage:C,contextWindow:w,serverCalculated:!!x,compacted:T});if(b.context={percent:C.percent,color:C.color,label:`${C.percent}% · ${K(C.totalTokens)} / ${K(w)} tokens`,title:E},d?.(b),!u||!v)return h?.remove(),g?.remove(),b;let D=Math.min(100,Math.max(0,C.percent)),O=`conic-gradient(${C.color} ${D*3.6}deg, rgb(229 231 235) 0deg)`,k=h??document.createElement(`span`);k.className=`quickforge-context-usage`,k.title=E,k.setAttribute(`aria-label`,E),k.style.cssText=[`position: relative`,`display: inline-flex`,`width: 14px`,`height: 14px`,`flex: 0 0 auto`,`border-radius: 9999px`,`background: ${O}`,`vertical-align: middle`,`box-shadow: 0 0 0 1px rgb(0 0 0 / 0.06)`].join(`;`);let A=k.firstElementChild;A||(A=document.createElement(`span`),k.append(A)),A.style.cssText=[`position: absolute`,`inset: 3px`,`border-radius: 9999px`,`background: hsl(var(--background))`].join(`;`);let j=k.nextElementSibling;return j?.classList.contains(`quickforge-context-usage-label`)||(j=document.createElement(`span`),j.className=`quickforge-context-usage-label`,j.style.cssText=`color: hsl(var(--muted-foreground)); font-size: 12px; line-height: 1;`),j.textContent=`${C.percent}%`,j.title=E,j.setAttribute(`aria-label`,E),h?k.nextElementSibling!==j&&k.after(j):(v.prepend(j),v.prepend(k)),b}}}var q=`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,ct=`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>`,lt=`<svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 0 11H11"/></svg>`,ut=`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="18" r="3"/><circle cx="6" cy="6" r="3"/><circle cx="18" cy="6" r="3"/><path d="M18 9v1a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V9"/><path d="M12 12v3"/></svg>`,dt=`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 2v6h-6"/><path d="M3 12a9 9 0 0 1 15.36-5.64L21 9"/><path d="M3 22v-6h6"/><path d="M21 12a9 9 0 0 1-15.36 5.64L3 15"/></svg>`,ft=`<svg class="quickforge-plan-mode-icon" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 6h1"/><path d="M4 12h1"/><path d="M4 18h1"/><path d="M9 6h11"/><path d="M9 12h11"/><path d="M9 18h11"/></svg>`,pt=`<svg class="quickforge-plan-remove-icon" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,mt=`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 5v14"/><path d="M5 12h14"/></svg>`,ht=`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`,gt=`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7.5 4.5h5a1.5 1.5 0 0 1 1.5 1.5v2h1a2.5 2.5 0 0 1 0 5h-1v2a1.5 1.5 0 0 1-1.5 1.5h-2v1a2.5 2.5 0 0 1-5 0v-1h-2A1.5 1.5 0 0 1 2 15.5v-3h1a2 2 0 1 0 0-4H2v-2A1.5 1.5 0 0 1 3.5 5h2v-1a2.5 2.5 0 0 1 5 0v.5Z"/></svg>`,_t=`<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.65" stroke-linecap="round" stroke-linejoin="round"><path d="M5.4 2.8h6.1L15.8 7v10.2H5.4z"/><path d="M11.4 2.9V7h4.1"/><path d="M7.6 10.2h5"/><path d="M7.6 13h4.3"/></svg>`,vt=`<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.65" stroke-linecap="round" stroke-linejoin="round"><rect x="3.4" y="4" width="13.2" height="12.2" rx="1.5"/><path d="M3.4 8h13.2"/><path d="M7.8 4v12.2"/><path d="M12.2 4v12.2"/><path d="M3.4 12h13.2"/></svg>`,yt=`<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.65" stroke-linecap="round" stroke-linejoin="round"><path d="M3 4.2h14"/><rect x="4.2" y="4.2" width="11.6" height="8.4" rx="1.2"/><path d="M10 12.6v3.2"/><path d="m7.2 17 2.8-1.2 2.8 1.2"/><path d="M7.1 9.5 9 7.7l1.5 1.3 2.4-2.5"/></svg>`,bt=`<svg class="quickforge-agent-access-trigger-icon" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3 19 6v5c0 4.5-2.8 8.4-7 10-4.2-1.6-7-5.5-7-10V6l7-3Z"/><path d="M9 12h6"/></svg>`,xt=`<svg class="quickforge-agent-access-option-icon" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m21.73 18-8-14a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>`,St=`<svg class="quickforge-agent-access-check" xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>`,Ct=`<svg class="quickforge-agent-access-chevron" xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg>`;function wt(e){return _(e===`full-access`?`agentAccessFullLabel`:`agentAccessDefaultLabel`)}function Tt(e){let t=document.querySelector(`.quickforge-agent-access-menu`);t?.__quickforgeDismissHandler&&(document.removeEventListener(`pointerdown`,t.__quickforgeDismissHandler,!0),document.removeEventListener(`keydown`,t.__quickforgeDismissHandler,!0),window.removeEventListener(`resize`,t.__quickforgeDismissHandler,!0),window.removeEventListener(`scroll`,t.__quickforgeDismissHandler,!0),t.__quickforgeDismissHandler=void 0),t?.remove(),e.querySelector(`.quickforge-agent-access-inline`)?.setAttribute(`aria-expanded`,`false`)}function Et(e,t,n){let r=e===t,i=document.createElement(`button`);return i.type=`button`,i.className=`quickforge-agent-access-item`,i.setAttribute(`role`,`menuitemradio`),i.setAttribute(`aria-checked`,String(r)),i.dataset.quickforgeAgentAccessMode=e,i.innerHTML=`
|
|
169
|
-
<span class="quickforge-agent-access-check-slot">${r?St:``}</span>
|
|
170
|
-
<span class="quickforge-agent-access-option-icon-wrap">${e===`full-access`?xt:bt}</span>
|
|
171
|
-
<span class="quickforge-agent-access-item-label"></span>
|
|
172
|
-
`,i.querySelector(`.quickforge-agent-access-item-label`).textContent=wt(e),i.onpointerdown=t=>{t.preventDefault(),t.stopPropagation(),n(e)},i}function Dt(e){let{panel:t,trigger:n,agentAccessMode:r,onAccessModeChange:i,dismissComposerMenus:a}=e;if(document.querySelector(`.quickforge-agent-access-menu`)){Tt(t);return}a(),Tt(t);let o=document.createElement(`div`);o.className=`quickforge-agent-access-menu`,o.setAttribute(`role`,`menu`),o.setAttribute(`aria-label`,_(`agentAccessMenuLabel`));let s=e=>{Tt(t),e!==r&&i(e)};o.append(Et(`default`,r,s),Et(`full-access`,r,s));let c=()=>{let e=n.getBoundingClientRect(),t=Math.min(196,window.innerWidth-24);o.style.width=`${t}px`;let r=o.offsetHeight||96,i=Math.max(12,Math.min(e.left,window.innerWidth-t-12)),a=Math.max(12,e.top-r-8);o.style.left=`${i}px`,o.style.top=`${a}px`},l=e=>{if(e.type===`resize`||e.type===`scroll`){c();return}if(e instanceof KeyboardEvent){if(e.key!==`Escape`)return;e.preventDefault()}else{let t=e.target;if(o.contains(t)||n.contains(t))return}Tt(t)};o.__quickforgeDismissHandler=l,o.addEventListener(`pointerdown`,e=>e.stopPropagation()),document.addEventListener(`pointerdown`,l,!0),document.addEventListener(`keydown`,l,!0),window.addEventListener(`resize`,l,!0),window.addEventListener(`scroll`,l,!0),document.body.append(o),c(),n.setAttribute(`aria-expanded`,`true`)}function Ot(e){let{panel:t,leftControls:n,agentAccessMode:r,onAccessModeChange:i,dismissComposerMenus:a}=e;n.classList.add(`quickforge-composer-left-controls`),t.querySelector(`.quickforge-yolo-inline`)?.remove();let o=wt(r),s=_(r===`full-access`?`agentAccessFullTitle`:`agentAccessDefaultTitle`),c=`${r===`full-access`?xt:bt}<span class="quickforge-agent-access-label"></span>${Ct}`,l=`quickforge-agent-access-inline inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 text-xs font-medium text-muted-foreground${r===`full-access`?` quickforge-agent-access-inline-full`:``}`,u=n.querySelector(`.quickforge-agent-access-inline`),d=e=>{je(e,c),e.querySelector(`.quickforge-agent-access-label`).textContent=o,e.title=s,e.setAttribute(`aria-label`,s),e.setAttribute(`aria-haspopup`,`menu`),e.setAttribute(`aria-expanded`,document.querySelector(`.quickforge-agent-access-menu`)?`true`:`false`),e.dataset.quickforgeAgentAccessMode=r,e.className=l,e.onpointerdown=n=>{n.preventDefault(),n.stopPropagation(),Dt({panel:t,trigger:e,agentAccessMode:r,onAccessModeChange:i,dismissComposerMenus:a})},e.onclick=e=>{e.preventDefault(),e.stopPropagation()},e.onkeydown=n=>{n.key!==`Enter`&&n.key!==` `&&n.key!==`ArrowDown`||(n.preventDefault(),Dt({panel:t,trigger:e,agentAccessMode:r,onAccessModeChange:i,dismissComposerMenus:a}))}};if(u)d(u);else{let e=document.createElement(`button`);e.type=`button`,d(e),n.append(e)}let f=n.querySelector(`.quickforge-agent-access-inline`),p=n.querySelector(`.quickforge-plan-inline`);f&&p&&f.nextSibling!==p&&n.insertBefore(p,f.nextSibling)}var kt=[{mention:`Documents`,nameKey:`pluginOpenaiDocumentsName`,descriptionKey:`pluginOpenaiDocumentsDescription`,pluginName:`openai-documents`,icon:_t},{mention:`Spreadsheets`,nameKey:`pluginOpenaiSpreadsheetsName`,descriptionKey:`pluginOpenaiSpreadsheetsDescription`,pluginName:`openai-spreadsheets`,icon:vt},{mention:`Presentations`,nameKey:`pluginOpenaiPresentationsName`,descriptionKey:`pluginOpenaiPresentationsDescription`,pluginName:`openai-presentations`,icon:yt}];function At(e){let t=e.querySelector(`.quickforge-plus-popover`);t?.__quickforgeDismissHandler&&(document.removeEventListener(`pointerdown`,t.__quickforgeDismissHandler,!0),t.__quickforgeDismissHandler=void 0),t?.remove(),e.querySelector(`.quickforge-plus-inline`)?.setAttribute(`aria-expanded`,`false`)}function jt(e,t){e.querySelectorAll(`.quickforge-native-attachment-hidden`).forEach(e=>{t.contains(e)||e.classList.remove(`quickforge-native-attachment-hidden`)})}function Mt(e){return e.querySelector(`.quickforge-native-attachment-hidden`)||Array.from(e.querySelectorAll(`button`)).find(e=>!e.classList.contains(`quickforge-plus-inline`)&&!e.classList.contains(`quickforge-agent-access-inline`)&&!e.classList.contains(`quickforge-yolo-inline`)&&!e.classList.contains(`quickforge-plan-inline`))}function Nt(e,t){let n=e.querySelector(`input[type="file"]`);if(n){n.click();return}Mt(t)?.click()}function Pt({className:e,icon:t,label:n,description:r,pluginName:i,onSelect:a}){let o=document.createElement(`button`);o.type=`button`,o.className=`quickforge-plus-popover-item${e?` ${e}`:``}`,i&&(o.dataset.quickforgePluginName=i),o.innerHTML=`
|
|
173
|
-
<span class="quickforge-plus-popover-item-icon">${t}</span>
|
|
174
|
-
<span class="quickforge-plus-popover-item-main">
|
|
175
|
-
<span class="quickforge-plus-popover-item-label"></span>
|
|
176
|
-
${r?`<span class="quickforge-plus-popover-item-description"></span>`:``}
|
|
177
|
-
</span>
|
|
178
|
-
`,o.querySelector(`.quickforge-plus-popover-item-label`).textContent=n;let s=o.querySelector(`.quickforge-plus-popover-item-description`);return s&&r&&(s.textContent=r),o.onpointerdown=e=>{e.preventDefault(),e.stopPropagation(),a()},o}function Ft(e,t){let{panel:n,editor:r,leftControls:i,insertBuiltinPluginMention:a,removeCommandSuggestions:o,removeCapabilitySuggestions:s}=e;o(),s();let c=n.querySelector(`.quickforge-plus-popover`)??document.createElement(`div`);c.className=`quickforge-plus-popover`,c.setAttribute(`role`,`menu`),c.innerHTML=``;let l=document.createElement(`div`);if(l.className=`quickforge-plus-popover-header`,l.textContent=_(t===`plugins`?`composerAddPlugins`:`composerAddMenu`),c.append(l),t===`main`)c.append(Pt({icon:ht,label:_(`composerAddAttachment`),onSelect:()=>{At(n),Nt(r,i)}}),Pt({icon:gt,label:_(`composerAddPlugins`),onSelect:()=>Ft(e,`plugins`)}));else{let t=Pt({className:`quickforge-plus-popover-back`,icon:`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg>`,label:_(`composerAddBack`),onSelect:()=>Ft(e,`main`)});c.append(t);for(let e of kt)c.append(Pt({icon:e.icon,label:_(e.nameKey),description:_(e.descriptionKey),pluginName:e.pluginName,onSelect:()=>{a(e.mention),At(n)}}))}c.isConnected||r.parentElement?.insertBefore(c,r),c.__quickforgeDismissHandler&&document.removeEventListener(`pointerdown`,c.__quickforgeDismissHandler,!0),c.__quickforgeDismissHandler=e=>{let t=e.target;c.contains(t)||n.querySelector(`.quickforge-plus-inline`)?.contains(t)||At(n)},document.addEventListener(`pointerdown`,c.__quickforgeDismissHandler,!0),n.querySelector(`.quickforge-plus-inline`)?.setAttribute(`aria-expanded`,`true`)}function It(e){let{panel:t,editor:n,leftControls:r}=e;jt(n,r),Mt(r)?.classList.add(`quickforge-native-attachment-hidden`);let i=r.querySelector(`.quickforge-plus-inline`),a=n=>{n.type=`button`,je(n,mt),n.title=_(`composerAddMenu`),n.setAttribute(`aria-label`,_(`composerAddMenu`)),n.setAttribute(`aria-haspopup`,`menu`),n.setAttribute(`aria-expanded`,t.querySelector(`.quickforge-plus-popover`)?`true`:`false`),n.className=`quickforge-plus-inline inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-muted-foreground`,n.onpointerdown=n=>{n.preventDefault(),n.stopPropagation(),t.querySelector(`.quickforge-plus-popover`)?At(t):Ft(e,`main`)},n.onclick=e=>{e.preventDefault(),e.stopPropagation()}};if(i){a(i);return}let o=document.createElement(`button`);a(o),r.prepend(o)}function Lt(e){switch(e){case`low`:return _(`thinkingLow`);case`medium`:return _(`thinkingMedium`);case`high`:return _(`thinkingHigh`);case`xhigh`:return _(`thinkingXHigh`);default:return _(`thinkingOff`)}}function Rt(e,t){let n=e,r=n?.currentModel;t.querySelector(`[data-quickforge-thinking-badge]`)?.remove();let i=Array.from(t.querySelectorAll(`button:not(.quickforge-agent-access-inline):not(.quickforge-yolo-inline):not(.quickforge-plan-inline)`)).find(e=>!!(r?.id&&e.textContent?.includes(r.id)));i&&(i.classList.add(`quickforge-model-trigger`),i.setAttribute(`aria-haspopup`,`menu`),i.setAttribute(`aria-expanded`,document.querySelector(`.quickforge-model-menu`)?`true`:`false`),r?.reasoning?i.dataset.quickforgeThinkingLevel=`· ${Lt(n?.thinkingLevel)}`:delete i.dataset.quickforgeThinkingLevel)}function zt(e,t,n){let r=e?.querySelector(`textarea`);if(!r)return;let i=r;i.__quickforgePlanModeHandler&&i.removeEventListener(`keydown`,i.__quickforgePlanModeHandler,!0),i.__quickforgePlanModeHandler=e=>{e.isComposing||e.key===`Process`||e.key!==`Tab`||!e.shiftKey||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),n())},i.addEventListener(`keydown`,i.__quickforgePlanModeHandler,!0),e&&(e.dataset.quickforgePlanMode=String(t))}function Bt(e){let{panel:t,leftControls:n,planMode:r,onTogglePlanMode:i}=e,a=_(`planModeEnabledTitle`),o=`${ft}${pt}<span>${_(`planModeLabel`)}</span>`,s=e=>{e.preventDefault(),e.stopPropagation(),i()},c=e=>{e.key!==`Enter`&&e.key!==` `||s(e)},l=t.querySelector(`.quickforge-plan-inline`),u=e=>{je(e,o),e.title=a,e.setAttribute(`aria-label`,a),e.setAttribute(`aria-pressed`,String(r)),e.className=`quickforge-plan-inline inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 text-xs font-medium text-muted-foreground`,e.onpointerdown=s,e.onclick=e=>{e.preventDefault(),e.stopPropagation()},e.onkeydown=c};if(!r)l?.remove();else if(l)u(l);else{let e=document.createElement(`button`);e.type=`button`,u(e);let t=n.querySelector(`.quickforge-agent-access-inline`);t?n.insertBefore(e,t.nextSibling):n.append(e)}}function Vt(e){let{rightControls:t,isStreaming:n,abort:r,removeCommandSuggestions:i}=e,a=t.querySelector(`button:last-child`);if(!a)return;let o=()=>{a.__quickforgeStopHandler&&=(a.removeEventListener(`pointerdown`,a.__quickforgeStopHandler,!0),a.removeEventListener(`click`,a.__quickforgeStopHandler,!0),void 0)};if(n())a.disabled=!1,a.classList.remove(`quickforge-send-button`),a.classList.add(`quickforge-stop-button`),a.title=`Stop`,a.setAttribute(`aria-label`,`Stop`),delete a.dataset.quickforgeSendIcon,W(a,`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>`),a.__quickforgeStopHandler||(a.__quickforgeStopHandler=e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),i(),r()},a.addEventListener(`pointerdown`,a.__quickforgeStopHandler,!0),a.addEventListener(`click`,a.__quickforgeStopHandler,!0));else if(o(),a.classList.remove(`quickforge-stop-button`),a.classList.add(`quickforge-send-button`),a.dataset.quickforgeSendIcon!==`arrow-up`){a.dataset.quickforgeSendIcon=`arrow-up`,W(a,`<svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 19V5"/><path d="m5 12 7-7 7 7"/></svg>`);let e=a.querySelector(`svg`)?.parentElement;e&&e!==a&&e.style.transform&&(e.style.transform=``)}}function Ht(e){let{editor:t,onInput:n,onFilesChange:r,removeCommandSuggestions:i,updateCommandSuggestions:a,removeCapabilitySuggestions:o,updateCapabilitySuggestions:s,onBeforeSend:c}=e;if(!t)return;t.onInput=e=>{n(e),a(e),s(e)},t.onFilesChange=e=>{r(e?[...e]:[])};let l=t.onSend;l&&l!==t.__quickforgePlanWrappedOnSend&&(t.__quickforgePlanBaseOnSend=l);let u=t.__quickforgePlanBaseOnSend;if(u){let e=(e,t)=>{let n=String(e??``);n.trim().length>0&&c?.(n),i(),o(),u(n,t)};t.__quickforgePlanWrappedOnSend=e,t.onSend=e}a(),s()}function Ut(e){let t=e.querySelector(`message-editor`),n=t?.querySelector(`textarea`);return{text:t?.value??n?.value??``,attachments:t?.attachments?[...t.attachments]:[]}}function Wt(e,t,n){let r=Ut(e);G(r)?t.set(n,r):t.delete(n)}function Gt(e,t,n,r){if(!G(t))return!1;let i={text:t.text,attachments:t.attachments?[...t.attachments]:[]},a=e.querySelector(`message-editor`),o=a?.querySelector(`textarea`);return!a&&!o?!1:(a&&(a.value=i.text,a.attachments=i.attachments,a.requestUpdate?.(),a.onInput?.(i.text),a.onFilesChange?.(i.attachments)),o&&(o.value=i.text,o.dispatchEvent(new Event(`input`,{bubbles:!0})),o.focus()),n.set(r,i),!0)}function Kt(e,t,n,r,i={}){let a=!0,o,s=new Set,c=()=>{o!==void 0&&(window.cancelAnimationFrame(o),o=void 0);for(let e of s)window.clearTimeout(e);s.clear()},l=()=>{a&&(a=!1,c())},u=()=>{if(a){if(i.shouldApply&&!i.shouldApply()){l();return}i.onApplyStart?.();try{if(!Gt(e,t,n,r))return;i.onApplied?.(),l()}finally{i.onApplyEnd?.()}}};if(u(),a){o=window.requestAnimationFrame(u);for(let e of[0,50,150,300,600]){let t=window.setTimeout(()=>{s.delete(t),u()},e);s.add(t)}i.updateComplete?.then(u)}return{cancel:l}}function J(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function qt(e){return e.split(`
|
|
179
|
-
`).map(e=>{let t=J(e);return e.startsWith(`+`)?`<span style="color:rgb(22 101 52);background:rgba(34,197,94,.14);display:block;">${t}</span>`:e.startsWith(`-`)?`<span style="color:rgb(153 27 27);background:rgba(239,68,68,.12);display:block;">${t}</span>`:e.startsWith(`@@`)?`<span style="color:rgb(37 99 235);background:rgba(37,99,235,.10);display:block;">${t}</span>`:`<span style="display:block;">${t||` `}</span>`}).join(`
|
|
180
|
-
`)}function Jt(e,t){let n=e.split(`
|
|
181
|
-
`),r=t.split(`
|
|
182
|
-
`),i=[];for(let e of n)i.push(`<span style="color:rgb(153 27 27);background:rgba(239,68,68,.12);display:block;">- ${J(e)}</span>`);for(let e of r)i.push(`<span style="color:rgb(22 101 52);background:rgba(34,197,94,.14);display:block;">+ ${J(e)}</span>`);return i.join(`
|
|
183
|
-
`)}var Yt=`.quickforge-approval-card`;function Xt(e){if(typeof e!=`string`||!e.startsWith(`mcp__`))return null;let t=e.slice(5),n=t.indexOf(`__`);return n<=0||n>=t.length-2?null:{serverName:t.slice(0,n),toolName:t.slice(n+2)}}function Zt(e,t){return typeof t.summary==`string`?t.summary:e===`run_command`&&typeof t.command==`string`?t.command:e===`activate_skill`&&typeof t.name==`string`?t.name:e===`read_skill_resource`&&typeof t.path==`string`||typeof t.path==`string`?t.path:typeof t.query==`string`?t.query:typeof t.name==`string`?t.name:``}function Qt(e,t){let n=Zt(e,t);return`
|
|
184
|
-
${n?`<div class="text-xs text-muted-foreground mb-1">${J(_(`toolArgsSummary`))}: ${J(n)}</div>`:``}
|
|
185
|
-
<div class="text-xs bg-background border rounded p-2 text-muted-foreground">${J(_(`toolDetailsHidden`))}</div>
|
|
186
|
-
`}function $t(e,t,n,r,i){let{panel:a,onApprove:o,onReject:s}=e;if(a.querySelector(`.quickforge-approval-card[data-tool-call-id="${CSS.escape(n)}"]`))return;en(a);let c=document.createElement(`div`);c.className=`quickforge-approval-card pointer-events-auto mb-4 mx-4 rounded-lg border border-amber-300 dark:border-amber-700 bg-amber-50 dark:bg-amber-950/30 p-4`,c.dataset.toolCallId=n;let l=Xt(t),u=l?`MCP · ${l.serverName} · ${l.toolName}`:t,d=i?.type===`subagent`?i.label||i.subagent||`Subagent`:``,f=document.createElement(`div`);if(f.className=`flex items-center gap-2 mb-3 text-sm font-medium text-amber-800 dark:text-amber-300`,f.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>`,f.append(` ${d?_(`subagentToolApprovalWaiting`,{source:d,toolName:u}):_(`toolApprovalWaiting`,{toolName:u})}`),c.append(f),d){let e=document.createElement(`div`);e.className=`mb-3 rounded-md border border-amber-200/80 bg-background/65 px-2.5 py-1.5 text-xs text-amber-800/85 dark:border-amber-800/70 dark:text-amber-200/85`,e.textContent=_(`toolApprovalSourceSubagent`,{source:d}),c.append(e)}let m=document.createElement(`div`);m.className=`quickforge-approval-preview mb-3`;let h=p().showToolDetails;if(l)m.innerHTML=`
|
|
187
|
-
<div class="rounded-md border bg-background/70 p-2 text-xs text-muted-foreground">
|
|
188
|
-
<div><span class="font-medium text-foreground">Source:</span> MCP</div>
|
|
189
|
-
<div><span class="font-medium text-foreground">Server:</span> ${J(l.serverName)}</div>
|
|
190
|
-
<div><span class="font-medium text-foreground">Tool:</span> ${J(l.toolName)}</div>
|
|
191
|
-
</div>
|
|
192
|
-
${h?`<pre class="mt-2 text-xs bg-background border rounded p-2 max-h-40 overflow-auto font-mono whitespace-pre-wrap">${J(JSON.stringify(r,null,2))}</pre>`:Qt(t,r)}
|
|
193
|
-
`;else if(t===`write_file`){let e=String(r.path??``),t=String(r.content??``),n=t.length>800;m.innerHTML=`
|
|
194
|
-
<div class="text-xs text-muted-foreground mb-1">📁 ${J(e)}</div>
|
|
195
|
-
<pre class="text-xs bg-background border rounded p-2 max-h-40 overflow-auto font-mono whitespace-pre-wrap">${qt(t.slice(0,800))}${n?`\n${J(_(`toolApprovalTruncated`))}`:``}</pre>
|
|
196
|
-
`}else if(t===`edit_file`){let e=String(r.path??``),t=Jt(String(r.oldText??``),String(r.newText??``));m.innerHTML=`
|
|
197
|
-
<div class="text-xs text-muted-foreground mb-1">📁 ${J(e)}</div>
|
|
198
|
-
<pre class="text-xs bg-background border rounded p-2 max-h-40 overflow-auto font-mono whitespace-pre-wrap">${t}</pre>
|
|
199
|
-
`}else if(t===`run_command`){let e=String(r.command??``);m.innerHTML=`
|
|
200
|
-
<div class="text-xs text-muted-foreground mb-1">⏱️ ${_(`toolApprovalTimeout`)}: ${J(`30m`)}</div>
|
|
201
|
-
<pre class="text-xs bg-background border rounded p-2 max-h-40 overflow-auto font-mono whitespace-pre-wrap">$ ${J(e)}</pre>
|
|
202
|
-
`}else typeof r.description==`string`?m.innerHTML=`<div class="text-xs bg-background border rounded p-2 text-muted-foreground">${J(r.description)}</div>`:m.innerHTML=h?`<pre class="text-xs bg-background border rounded p-2 max-h-40 overflow-auto font-mono whitespace-pre-wrap">${J(JSON.stringify(r,null,2))}</pre>`:Qt(t,r);c.append(m);let g=document.createElement(`div`);g.className=`mb-2 hidden text-xs text-red-700 dark:text-red-400`,c.append(g);let v=document.createElement(`div`);v.className=`flex items-center gap-2`;let y=e=>{x.disabled=e,S.disabled=e,x.classList.toggle(`opacity-60`,e),S.classList.toggle(`opacity-60`,e),x.textContent=_(e?`toolApprovalSubmitting`:`toolApprovalAccept`)},b=async e=>{g.classList.add(`hidden`),g.textContent=``,y(!0);try{await e()}catch(e){g.textContent=e instanceof Error?e.message:_(`toolApprovalFailed`),g.classList.remove(`hidden`),y(!1)}},x=document.createElement(`button`);x.type=`button`,x.className=`inline-flex items-center gap-1.5 rounded-md bg-emerald-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-emerald-700 transition-colors cursor-pointer disabled:cursor-not-allowed`,x.textContent=_(`toolApprovalAccept`),x.addEventListener(`click`,e=>{e.stopPropagation(),e.preventDefault(),b(o)});let S=document.createElement(`button`);S.type=`button`,S.className=`inline-flex items-center gap-1.5 rounded-md border border-red-300 dark:border-red-700 px-3 py-1.5 text-xs font-medium text-red-700 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-950/30 transition-colors cursor-pointer disabled:cursor-not-allowed`,S.textContent=_(`toolApprovalReject`),S.addEventListener(`click`,e=>{e.stopPropagation(),e.preventDefault(),b(s)}),v.append(x,S),c.append(v);let C=a.querySelector(`message-list`);C?C.append(c):a.querySelector(`agent-interface`)?.append(c),c.scrollIntoView({behavior:`smooth`,block:`end`})}function en(e){e.querySelectorAll(Yt).forEach(e=>e.remove())}function tn(e,t,n){let r=_(`copied`),i=Number(e.dataset.quickforgeCopyFeedbackTimer);i&&window.clearTimeout(i),W(e,ct),e.title=r,e.setAttribute(`aria-label`,r),e.style.color=`rgb(5 150 105)`;let a=window.setTimeout(()=>{W(e,n),e.title=t,e.setAttribute(`aria-label`,t),e.style.color=``,delete e.dataset.quickforgeCopyFeedbackTimer},1200);e.dataset.quickforgeCopyFeedbackTimer=String(a)}function nn(e){return e.role===`user`||e.role===`user-with-attachments`||e.role===`assistant`}function rn(e){let t=e.querySelector(`message-list`);return t?Array.from(t.querySelectorAll(`user-message, assistant-message`)).filter(e=>e.closest(`message-list`)===t):[]}function an(e,t,n,r){let i=rn(e),a=0;for(let e=0;e<t.length;e++)if(nn(t[e])){if(e===n){let e=i[a];if(e){r.nextElementSibling!==e&&e.before(r);return}break}a+=1}let o=e.querySelector(`message-list`);o&&o.firstElementChild!==r&&o.prepend(r)}function on(e){let t=e,n=t?.role===`assistant`?m(t):f(t);return(n.match(/<compact_summary>\s*([\s\S]*?)\s*<\/compact_summary>/i)?.[1]??n).trim()}function sn(e,t,n=!1){let r=e.querySelector(`.quickforge-context-compaction-details`),i=e.querySelector(`.quickforge-context-compaction-summary`),a=e.querySelector(`.quickforge-context-compaction-toggle-label`),o=e.querySelector(`[data-quickforge-action="copy-compact-summary"]`);r&&(r.open=n);let s=()=>{a&&r&&(a.textContent=r.open?_(`contextCompactedHideSummary`):_(`contextCompactedViewSummary`))};i&&!i.dataset.quickforgeCompactionBound&&(i.dataset.quickforgeCompactionBound=`true`,i.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),r&&(r.open=!r.open,s())})),r&&!r.dataset.quickforgeCompactionBound&&(r.dataset.quickforgeCompactionBound=`true`,r.addEventListener(`toggle`,s)),s(),o&&(o.onclick=async e=>{e.preventDefault(),e.stopPropagation(),await h(t),tn(o,_(`contextCompactedCopySummary`),q)})}function cn(e){let{panel:t,getMessages:n,getContextCompaction:r}=e,i=r(),a=n(),o=t.querySelector(`.quickforge-context-compaction-notice`);if(!i||a.length===0){o?.remove();return}let s=Math.min(a.length,Math.max(0,Number(i.compactedUpToIndex)||0));if(s<=0){o?.remove();return}let c=i.summaryMessage?on(i.summaryMessage):``,l=o?.querySelector(`.quickforge-context-compaction-details`)?.open??!1,u=o??document.createElement(`div`),d=u.dataset.summaryText??``,f=u.dataset.hasSummary===`true`,p=!o||d!==c||f!==!!c;u.className=`quickforge-context-compaction-notice`,u.dataset.tailStart=String(s),u.dataset.summaryText=c,u.dataset.hasSummary=String(!!c),u.title=_(`contextCompactedTooltip`),u.setAttribute(`aria-label`,_(`contextCompactedTooltip`)),p&&(u.innerHTML=c?`
|
|
203
|
-
<details class="quickforge-context-compaction-details">
|
|
204
|
-
<summary class="quickforge-context-compaction-summary">
|
|
205
|
-
<div class="quickforge-context-compaction-line"></div>
|
|
206
|
-
<div class="quickforge-context-compaction-pill">
|
|
207
|
-
<span class="quickforge-context-compaction-dot" aria-hidden="true"></span>
|
|
208
|
-
<span><strong>${J(_(`contextCompactedLabel`))}</strong> · ${J(_(`contextCompactedTimelineLabel`))} · <span class="quickforge-context-compaction-toggle-label"></span></span>
|
|
209
|
-
</div>
|
|
210
|
-
<div class="quickforge-context-compaction-line"></div>
|
|
211
|
-
</summary>
|
|
212
|
-
<div class="quickforge-context-compaction-card">
|
|
213
|
-
<div class="quickforge-context-compaction-card-header">
|
|
214
|
-
<span>${J(_(`contextCompactedSummaryTitle`))}</span>
|
|
215
|
-
<button type="button" class="quickforge-context-compaction-copy" data-quickforge-action="copy-compact-summary">${q}<span>${J(_(`contextCompactedCopySummary`))}</span></button>
|
|
216
|
-
</div>
|
|
217
|
-
<pre class="quickforge-context-compaction-text">${J(c)}</pre>
|
|
218
|
-
</div>
|
|
219
|
-
</details>
|
|
220
|
-
`:`
|
|
221
|
-
<div class="quickforge-context-compaction-summary" role="separator">
|
|
222
|
-
<div class="quickforge-context-compaction-line"></div>
|
|
223
|
-
<div class="quickforge-context-compaction-pill">
|
|
224
|
-
<span class="quickforge-context-compaction-dot" aria-hidden="true"></span>
|
|
225
|
-
<span><strong>${J(_(`contextCompactedLabel`))}</strong> · ${J(_(`contextCompactedTimelineLabel`))}</span>
|
|
226
|
-
</div>
|
|
227
|
-
<div class="quickforge-context-compaction-line"></div>
|
|
228
|
-
</div>
|
|
229
|
-
`),c&&sn(u,c,l),an(t,a,s,u)}var ln=new Set([`bash`,`sh`,`shell`,`zsh`,`fish`,`cmd`,`bat`,`batch`,`powershell`,`ps1`,`terminal`,`console`]),un=/\b(rm\s+-rf|sudo|chmod\b|chown\b|npm\s+publish|pnpm\s+publish|yarn\s+publish|git\s+push|curl\b[^\n|;]*\|\s*(sh|bash)|wget\b[^\n|;]*\|\s*(sh|bash))\b/i,dn=/<\s*(script|foreignObject)\b|\son[a-z]+\s*=|javascript\s*:/i;function fn(e,t,n){let r=_(`copied`),i=Number(e.dataset.quickforgeCopyFeedbackTimer);i&&window.clearTimeout(i),W(e,ct),e.title=r,e.setAttribute(`aria-label`,r),e.style.color=`rgb(5 150 105)`;let a=window.setTimeout(()=>{W(e,n),e.title=t,e.setAttribute(`aria-label`,t),e.style.color=``,delete e.dataset.quickforgeCopyFeedbackTimer},1200);e.dataset.quickforgeCopyFeedbackTimer=String(a)}function pn(e,t,n,r){let i=document.createElement(`button`);return i.type=`button`,i.dataset.quickforgeAction=e,i.title=t,i.setAttribute(`aria-label`,t),W(i,n),i.className=`pointer-events-auto inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-transparent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,i.onclick=e=>{e.stopPropagation(),r(i)},i}function mn(e){if(typeof e.getDecodedCode==`function`)try{return e.getDecodedCode()}catch{}let t=typeof e.code==`string`?e.code:e.getAttribute(`code`)??``;if(!t)return``;try{return decodeURIComponent(escape(window.atob(t)))}catch{return t}}function hn(e){return e.replace(/\r\n/g,`
|
|
230
|
-
`).split(`
|
|
231
|
-
`).map(e=>e.replace(/^\s*\$\s+/,``).replace(/^\s*>\s+/,``).replace(/^\s*PS\s+[^>\n]+>\s+/i,``)).join(`
|
|
232
|
-
`).trim()}function gn(e){return e.split(`
|
|
233
|
-
`).map(e=>e.trim()).filter(Boolean).length}function _n(e){let t=String(e.language??e.getAttribute(`language`)??``).trim().toLowerCase();return ln.has(t)}function vn(e){return String(e.language??e.getAttribute(`language`)??``).trim().toLowerCase()===`svg`}function yn(e){let t=e.trim();return/^<svg[\s>]/i.test(t)&&/<\/svg>\s*$/i.test(t)&&!dn.test(t)}function bn(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}function xn(){let e=document.querySelector(`.quickforge-svg-code-lightbox`);e?.quickforgeCleanup?.(),e?.remove()}function Sn(e,t=`SVG preview`){xn();let n=document.createElement(`div`);n.className=`quickforge-svg-code-lightbox`,n.setAttribute(`role`,`dialog`),n.setAttribute(`aria-modal`,`true`),n.setAttribute(`aria-label`,t);let r=document.createElement(`img`);r.alt=t,r.src=e,r.addEventListener(`click`,e=>e.stopPropagation()),n.append(r);let i=()=>xn(),a=e=>{e.key===`Escape`&&i()};n.quickforgeCleanup=()=>document.removeEventListener(`keydown`,a),n.addEventListener(`click`,i),document.addEventListener(`keydown`,a),document.body.append(n)}function Cn(e,t,n){let r=new Blob([t],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}function wn(e){let t=0;for(let n=0;n<e.length;n++)t=Math.imul(31,t)+e.charCodeAt(n)|0;return`${e.length}:${t}`}function Tn(e){e.nextElementSibling instanceof HTMLElement&&e.nextElementSibling.dataset.quickforgeSvgPreview===`true`&&e.nextElementSibling.remove(),e.querySelector(`[data-quickforge-svg-preview="true"]`)?.remove(),e.classList.contains(`quickforge-mermaid-code-block`)||e.classList.remove(`quickforge-svg-code-block`),e.querySelector(`copy-button[data-quickforge-svg-original-copy="true"]`)?.removeAttribute(`hidden`),e.querySelector(`copy-button[data-quickforge-svg-original-copy="true"]`)?.removeAttribute(`data-quickforge-svg-original-copy`),e.querySelector(`[data-quickforge-svg-toolbar="true"]`)?.remove();let t=e.querySelector(`pre`)?.parentElement,n=e.querySelector(`[data-quickforge-mermaid-preview="true"]`)!==null;t instanceof HTMLElement&&!n&&(t.hidden=!1),delete e.dataset.quickforgeSvgPreviewSource,delete e.dataset.quickforgeSvgMode}function En(e,t){let n=e.querySelector(`[data-quickforge-svg-preview="true"]`),r=e.querySelector(`:scope > div > div:first-child`),i=e.querySelector(`pre`)?.parentElement;e.dataset.quickforgeSvgMode=t,n&&(n.hidden=t!==`preview`),r&&r.classList.toggle(`quickforge-svg-code-toolbar-floating`,t===`preview`),i instanceof HTMLElement&&(i.hidden=t===`preview`)}function Y(e,t,n){let r=document.createElement(`button`);return r.type=`button`,r.dataset.quickforgeAction=e,r.className=`quickforge-svg-code-menu-item`,r.title=t,r.setAttribute(`aria-label`,t),r.setAttribute(`role`,`menuitem`),W(r,n),r}function Dn(e=document,t){e.querySelectorAll(`.quickforge-svg-code-menu[open]`).forEach(e=>{e!==t&&(e.open=!1)})}var On=!1;function kn(){On||(On=!0,document.addEventListener(`pointerdown`,e=>{e.target?.closest(`.quickforge-svg-code-menu`)||Dn(document)},!0),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&Dn(document)}))}function An(e,t){kn();let n=e.querySelector(`:scope > div > div:first-child`),r=n?.querySelector(`copy-button`);if(!n||!r)return;let i=n.querySelector(`[data-quickforge-svg-toolbar="true"]`);if(!i){i=document.createElement(`div`),i.dataset.quickforgeSvgToolbar=`true`,i.className=`quickforge-svg-code-toolbar`;let e=document.createElement(`details`);e.className=`quickforge-svg-code-menu`;let t=document.createElement(`summary`);t.className=`quickforge-svg-code-menu-trigger`,t.title=_(`moreActions`),t.setAttribute(`aria-label`,_(`moreActions`)),t.textContent=`⋯`;let n=document.createElement(`div`);n.className=`quickforge-svg-code-menu-content`,n.setAttribute(`role`,`menu`);let a=Y(`svg-preview-mode`,_(`svgPreviewMode`),`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`),o=Y(`svg-source-mode`,_(`svgSourceMode`),`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m16 18 6-6-6-6"/><path d="m8 6-6 6 6 6"/></svg>`),s=Y(`copy-svg-code`,_(`copySvgSource`),q),c=Y(`download-svg-code`,_(`downloadSvg`),`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="M7 10l5 5 5-5"/><path d="M12 15V3"/></svg>`);n.append(a,o,s,c),r.before(i),r.dataset.quickforgeSvgOriginalCopy=`true`,r.setAttribute(`hidden`,``),e.append(t,n),i.append(e)}let a=i.querySelector(`.quickforge-svg-code-menu`),o=i.querySelector(`[data-quickforge-action="svg-preview-mode"]`),s=i.querySelector(`[data-quickforge-action="svg-source-mode"]`),c=i.querySelector(`[data-quickforge-action="copy-svg-code"]`),l=i.querySelector(`[data-quickforge-action="download-svg-code"]`),u=()=>{a&&(a.open=!1)};a&&!a.dataset.quickforgeSvgMenuBound&&(a.dataset.quickforgeSvgMenuBound=`true`,a.addEventListener(`toggle`,()=>{a.open&&Dn(e.closest(`markdown-block`)??document,a)})),o&&(o.onclick=()=>{En(e,`preview`),u()}),s&&(s.onclick=()=>{En(e,`source`),u()}),c&&(c.onclick=async()=>{await h(t),fn(c,_(`copySvgSource`),q)}),l&&(l.onclick=()=>{Cn(`quickforge-svg-${Date.now()}.svg`,t,`image/svg+xml;charset=utf-8`),u()})}function jn(e,t){e.querySelectorAll(`assistant-message markdown-block code-block`).forEach(e=>{if(!vn(e)){Tn(e);return}if(t)return;let n=mn(e).trim();if(!n||!yn(n)){Tn(e);return}let r=wn(n);if(e.querySelector(`[data-quickforge-svg-preview="true"]`)&&e.dataset.quickforgeSvgPreviewSource===r){An(e,n),En(e,e.dataset.quickforgeSvgMode===`source`?`source`:`preview`);return}let i=e.querySelector(`:scope > div > div:first-child`);if(!i)return;Tn(e);let a=document.createElement(`div`);e.classList.add(`quickforge-svg-code-block`),a.dataset.quickforgeSvgPreview=`true`,a.className=`quickforge-svg-code-preview`,a.setAttribute(`aria-label`,`SVG preview`);let o=document.createElement(`img`);o.alt=`SVG preview`,o.src=bn(n),o.title=_(`svgEnlargePreview`),o.addEventListener(`click`,()=>Sn(o.src)),a.replaceChildren(o),i.after(a),An(e,n),e.dataset.quickforgeSvgPreviewSource=r,En(e,e.dataset.quickforgeSvgMode===`source`?`source`:`preview`)})}var Mn=0;function Nn(e){return x(String(e.language??e.getAttribute(`language`)??``))}function Pn(e){let t=e.classList.contains(`quickforge-mermaid-code-block`);if(!(t||e.dataset.quickforgeMermaidRequestToken!==void 0||e.dataset.quickforgeMermaidPendingSource!==void 0||e.dataset.quickforgeMermaidPreviewSource!==void 0||e.dataset.quickforgeMermaidFailedSource!==void 0||e.querySelector(`[data-quickforge-mermaid-preview="true"], [data-quickforge-mermaid-error="true"], [data-quickforge-mermaid-toolbar="true"], copy-button[data-quickforge-mermaid-original-copy="true"]`)!==null))return;e.dataset.quickforgeMermaidRequestToken&&(e.dataset.quickforgeMermaidRequestToken=String(++Mn)),e.querySelector(`[data-quickforge-mermaid-preview="true"]`)?.remove(),e.querySelector(`[data-quickforge-mermaid-error="true"]`)?.remove(),e.querySelector(`[data-quickforge-mermaid-toolbar="true"]`)?.remove(),e.classList.remove(`quickforge-mermaid-code-block`),t&&!e.querySelector(`[data-quickforge-svg-preview="true"]`)&&e.classList.remove(`quickforge-svg-code-block`),e.querySelector(`copy-button[data-quickforge-mermaid-original-copy="true"]`)?.removeAttribute(`hidden`),e.querySelector(`copy-button[data-quickforge-mermaid-original-copy="true"]`)?.removeAttribute(`data-quickforge-mermaid-original-copy`);let n=e.querySelector(`pre`)?.parentElement,r=e.querySelector(`[data-quickforge-svg-preview="true"]`)!==null;n instanceof HTMLElement&&!r&&(n.hidden=!1),delete e.dataset.quickforgeMermaidMode,delete e.dataset.quickforgeMermaidPreviewSource,delete e.dataset.quickforgeMermaidPendingSource,delete e.dataset.quickforgeMermaidFailedSource,delete e.dataset.quickforgeMermaidRequestToken}function Fn(e,t){let n=e.querySelector(`[data-quickforge-mermaid-preview="true"]`),r=e.querySelector(`:scope > div > div:first-child`),i=e.querySelector(`pre`)?.parentElement;e.dataset.quickforgeMermaidMode=t,n&&(n.hidden=t!==`preview`),r&&r.classList.toggle(`quickforge-svg-code-toolbar-floating`,t===`preview`),i instanceof HTMLElement&&(i.hidden=t===`preview`)}function In(e,t,n){kn();let r=e.querySelector(`:scope > div > div:first-child`),i=r?.querySelector(`copy-button`);if(!r||!i)return;let a=r.querySelector(`[data-quickforge-mermaid-toolbar="true"]`);if(!a){a=document.createElement(`div`),a.dataset.quickforgeMermaidToolbar=`true`,a.className=`quickforge-svg-code-toolbar`;let e=document.createElement(`details`);e.className=`quickforge-svg-code-menu quickforge-mermaid-code-menu`;let t=document.createElement(`summary`);t.className=`quickforge-svg-code-menu-trigger`,t.title=_(`moreActions`),t.setAttribute(`aria-label`,_(`moreActions`)),t.textContent=`⋯`;let n=document.createElement(`div`);n.className=`quickforge-svg-code-menu-content`,n.setAttribute(`role`,`menu`);let r=Y(`mermaid-preview-mode`,_(`svgPreviewMode`),`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`),o=Y(`mermaid-source-mode`,_(`svgSourceMode`),`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m16 18 6-6-6-6"/><path d="m8 6-6 6 6 6"/></svg>`),s=Y(`copy-mermaid-code`,_(`copyMermaidSource`),q),c=Y(`download-mermaid-svg`,_(`downloadMermaidSvg`),`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="M7 10l5 5 5-5"/><path d="M12 15V3"/></svg>`);n.append(r,o,s,c),i.before(a),i.dataset.quickforgeMermaidOriginalCopy=`true`,i.setAttribute(`hidden`,``),e.append(t,n),a.append(e)}let o=a.querySelector(`.quickforge-mermaid-code-menu`),s=a.querySelector(`[data-quickforge-action="mermaid-preview-mode"]`),c=a.querySelector(`[data-quickforge-action="mermaid-source-mode"]`),l=a.querySelector(`[data-quickforge-action="copy-mermaid-code"]`),u=a.querySelector(`[data-quickforge-action="download-mermaid-svg"]`),d=()=>{o&&(o.open=!1)};o&&!o.dataset.quickforgeMermaidMenuBound&&(o.dataset.quickforgeMermaidMenuBound=`true`,o.addEventListener(`toggle`,()=>{o.open&&Dn(e.closest(`markdown-block`)??document,o)})),s&&(s.onclick=()=>{Fn(e,`preview`),d()}),c&&(c.onclick=()=>{Fn(e,`source`),d()}),l&&(l.onclick=async()=>{await h(t),fn(l,_(`copyMermaidSource`),q)}),u&&(u.onclick=()=>{Cn(`quickforge-mermaid-${Date.now()}.svg`,n,`image/svg+xml;charset=utf-8`),d()})}function Ln(e){let t=e.querySelector(`:scope > div > div:first-child`);if(!t||e.querySelector(`[data-quickforge-mermaid-error="true"]`))return;let n=document.createElement(`div`);n.dataset.quickforgeMermaidError=`true`,n.className=`quickforge-mermaid-code-error`,n.textContent=_(`mermaidRenderFailed`),t.after(n)}function Rn(e,t){e.querySelectorAll(`assistant-message markdown-block code-block`).forEach(n=>{try{if(!Nn(n)){Pn(n);return}let r=mn(n).trim();if(!r){Pn(n);return}let i=wn(r);if(n.querySelector(`[data-quickforge-mermaid-preview="true"]`)&&n.dataset.quickforgeMermaidPreviewSource===i){Fn(n,n.dataset.quickforgeMermaidMode===`source`?`source`:`preview`);return}if(t){(n.dataset.quickforgeMermaidPendingSource||n.dataset.quickforgeMermaidPreviewSource)&&Pn(n);return}if(n.dataset.quickforgeMermaidPendingSource===i||n.dataset.quickforgeMermaidFailedSource===i||!n.querySelector(`:scope > div > div:first-child`))return;Pn(n);let a=String(++Mn);n.dataset.quickforgeMermaidRequestToken=a,n.dataset.quickforgeMermaidPendingSource=i,(async()=>{try{let t=await S(r);if(!t)throw Error(`Empty Mermaid SVG`);let o=C(t);if(!n.isConnected||n.dataset.quickforgeMermaidRequestToken!==a||e.dataset.quickforgeAgentStreaming===`true`||!Nn(n)||wn(mn(n).trim())!==i){n.dataset.quickforgeMermaidRequestToken===a&&(delete n.dataset.quickforgeMermaidPendingSource,delete n.dataset.quickforgeMermaidRequestToken);return}let s=n.querySelector(`:scope > div > div:first-child`);if(!s){delete n.dataset.quickforgeMermaidPendingSource,delete n.dataset.quickforgeMermaidRequestToken;return}let c=document.createElement(`div`);c.dataset.quickforgeMermaidPreview=`true`,c.className=`quickforge-svg-code-preview quickforge-mermaid-code-preview`,c.setAttribute(`aria-label`,_(`mermaidPreviewLabel`));let l=document.createElement(`img`);l.alt=_(`mermaidPreviewLabel`),l.src=o,l.title=_(`mermaidEnlargePreview`),l.addEventListener(`click`,()=>Sn(l.src,_(`mermaidPreviewLabel`))),c.replaceChildren(l),n.classList.add(`quickforge-svg-code-block`,`quickforge-mermaid-code-block`),s.after(c),In(n,r,t),n.dataset.quickforgeMermaidPreviewSource=i,delete n.dataset.quickforgeMermaidPendingSource,delete n.dataset.quickforgeMermaidFailedSource,delete n.dataset.quickforgeMermaidRequestToken,Fn(n,`preview`)}catch{if(!n.isConnected||n.dataset.quickforgeMermaidRequestToken!==a||!Nn(n)||wn(mn(n).trim())!==i)return;delete n.dataset.quickforgeMermaidPendingSource,delete n.dataset.quickforgeMermaidRequestToken,n.dataset.quickforgeMermaidFailedSource=i,Ln(n)}})()}catch{Pn(n),Ln(n)}})}function zn(e,t){e.querySelectorAll(`assistant-message markdown-block code-block`).forEach(e=>{let n=e.querySelector(`[data-quickforge-action="execute-markdown-command"]`);if(!_n(e)){n?.remove(),delete e.dataset.quickforgeCommand;return}let r;if(n&&e.dataset.quickforgeCommand!==void 0){if(n.disabled===t)return;r=e.dataset.quickforgeCommand}else r=hn(mn(e));if(!r){n?.remove(),delete e.dataset.quickforgeCommand;return}e.dataset.quickforgeCommand=r;let i=_(`executeInTerminal`),a=n??pn(`execute-markdown-command`,i,`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polygon points="6 3 20 12 6 21 6 3"/></svg>`,()=>{let t=hn(mn(e));t&&window.dispatchEvent(new CustomEvent(`quickforge:execute-markdown-command`,{detail:{command:t,confirm:gn(t)>1,dangerous:un.test(t)}}))});if(a.title=i,a.setAttribute(`aria-label`,i),a.disabled=t,a.className=`pointer-events-auto inline-flex size-8 items-center justify-center rounded-md text-emerald-600 transition-colors hover:bg-emerald-500/10 hover:text-emerald-700 disabled:cursor-not-allowed disabled:opacity-40 dark:text-emerald-400 dark:hover:text-emerald-300`,!n){let t=e.querySelector(`:scope > div > div:first-child`),n=t?.querySelector(`copy-button`);if(t&&n){let e=document.createElement(`div`);e.className=`flex items-center gap-1`,n.before(e),e.appendChild(n),e.appendChild(a)}}})}var Bn=`.quickforge-process-group`,X=`.quickforge-process-body`,Vn=`thinking-block, tool-message, streaming-message-container`,Hn=`thinking-block, tool-message, markdown-block, streaming-message-container`,Un=`data-quickforge-process-final-summary`,Wn=`data-quickforge-process-folded`,Gn=500,Kn=new WeakMap;function qn(e){let t=Kn.get(e);return t||(t=new Map,Kn.set(e,t)),t}function Jn(e,t,n){let r=qn(e);if(r.set(t,n),r.size<=Gn)return;let i=r.keys().next().value;i&&r.delete(i)}function Yn(e,t){return`turn:${t}:started:${$n(e[0]?.message?.timestamp)??`unknown`}`}function Xn(e,t,n){let r=t.dataset.quickforgeProcessKey;t.dataset.quickforgeProcessKey=n;let i=qn(e).get(n);if(i!==void 0){t.dataset.expanded=String(i);return}t.dataset.expanded=r===n&&t.dataset.expanded===`true`?`true`:`false`}function Zn(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function Qn(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function $n(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`){let t=e.trim();if(!t)return;let n=Number(t);if(Number.isFinite(n))return n;let r=Date.parse(t);return Number.isNaN(r)?void 0:r}}function er(e){if(!Zn(e))return;let t=e.details;if(!Zn(t))return;let n=t.quickforgeTiming;if(Zn(n))return{startedAt:Qn(n.startedAt),finishedAt:Qn(n.finishedAt),durationMs:Qn(n.durationMs)}}function tr(e){let t=er(e.result);if(t?.finishedAt!==void 0)return t.finishedAt;if(t?.startedAt!==void 0&&t.durationMs!==void 0)return t.startedAt+t.durationMs}function nr(e){return er(e.result)?.startedAt}function rr(e){if(Zn(e.details))return $n(e.details.quickforgeProcessFinishedAt)}function ir(e){let t=e.map(rr).filter(e=>e!==void 0);return t.length>0?Math.max(...t):void 0}function ar(e){if(e===void 0||e<1e3)return``;let t=Math.max(1,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n>0?`${n}m ${r}s`:`${r}s`}function or(e,t,n,r){let i=r,a=[...e].reverse().find(e=>e.message?.stopReason)?.message?.stopReason,o=Array.from(t.querySelectorAll(`tool-message`)),s=[...e.map(e=>$n(e.message?.timestamp)),...o.map(nr)].filter(e=>e!==void 0),c=[ir(e.map(e=>e.message??{})),...o.map(tr)].filter(e=>e!==void 0),l=s.length>0?Math.min(...s):void 0,u=c.length>0?Math.max(...c):void 0;if(i)u=Date.now();else{let e=$n(n.dataset.quickforgeFinishedAt);e!==void 0&&e>0?u=e:(u??=Date.now(),n.dataset.quickforgeFinishedAt=String(u))}let d=l!==void 0&&u!==void 0?ar(Math.max(0,u-l)):``,f=_(a===`error`?`processFailed`:a===`aborted`?`processAborted`:i?`processing`:`processed`);return d?`${f} ${d}`:f}function sr(e){let t=e.querySelector(`${Hn}, ${Bn}`);return t?.closest(`.px-4.flex.flex-col`)??t?.parentElement??null}function cr(){let e=document.createElement(`div`);e.className=`quickforge-process-group`,e.dataset.expanded=`false`;let t=document.createElement(`button`);t.type=`button`,t.className=`quickforge-process-summary`,t.innerHTML=`
|
|
234
|
-
<span class="quickforge-process-label"></span>
|
|
235
|
-
<span class="quickforge-process-chevron" aria-hidden="true">
|
|
236
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m9 18 6-6-6-6"/></svg>
|
|
237
|
-
</span>
|
|
238
|
-
`;let n=document.createElement(`div`);return n.className=`quickforge-process-body`,e.append(t,n),e}function lr(e){let t=e.querySelector(Bn);if(t)return t;let n=sr(e);if(!n)return null;let r=cr();return n.insertBefore(r,n.firstElementChild),r}function ur(e,t,n,r,i){Xn(e,r,t);let a=r.querySelector(X),o=r.querySelector(`.quickforge-process-summary`),s=r.querySelector(`.quickforge-process-label`);if(!a||!o||!s)return;let c=or(n,a,r,i);s.textContent!==c&&(s.textContent=c);let l=r.dataset.expanded===`true`;o.setAttribute(`aria-expanded`,String(l)),o.setAttribute(`aria-label`,_(l?`collapseProcess`:`expandProcess`)),o.onclick=n=>{n.preventDefault(),n.stopPropagation();let i=r.dataset.expanded!==`true`;r.dataset.expanded=String(i),Jn(e,t,i),o.setAttribute(`aria-expanded`,String(i)),o.setAttribute(`aria-label`,_(i?`collapseProcess`:`expandProcess`))}}function dr(e){return Array.from(e.querySelectorAll(`markdown-block`)).filter(e=>!e.closest(Vn))}function fr(e){let t=e.filter(e=>(e.textContent??``).trim().length>0);return t[t.length-1]??e[e.length-1]??null}function Z(e,t,n){if(n){e.hasAttribute(t)||e.setAttribute(t,`true`);return}e.hasAttribute(t)&&e.removeAttribute(t)}function pr(e,t){if(t)return null;let n=dr(e);return fr(n.filter(e=>e.hasAttribute(Un)))||fr(n.filter(e=>!e.closest(X)))||fr(n)}function mr(e,t){dr(e).forEach(e=>{e===t?(Z(e,Un,!0),Z(e,Wn,!1)):Z(e,Un,!1)})}function hr(e){return e.length>1||e.some(e=>!!e.querySelector(Vn))}function gr(e,t,n){return e===t?!1:e.tagName.toLowerCase()===`markdown-block`?n:!0}function _r(e,t,n){return e.some(e=>Array.from(e.querySelectorAll(Hn)).some(e=>gr(e,t,n)))}function vr(e,t){return t?.closest(X)?(e.after(t),Z(t,Wn,!1),Z(t,Un,!0),!0):!1}function yr(e){return(e.querySelector(X)?.childElementCount??0)>0}function br(e){for(let t of e)t.classList.remove(`quickforge-process-source-empty`),t.querySelectorAll(Bn).forEach(e=>{let t=e.querySelector(X);t&&Array.from(t.children).forEach(t=>{t instanceof HTMLElement&&(Z(t,Wn,!1),Z(t,Un,!1)),e.parentElement?.insertBefore(t,e)}),e.remove()}),dr(t).forEach(e=>{Z(e,Wn,!1),Z(e,Un,!1)})}function xr(e,t,n,r){let i=t.querySelector(X);if(!i)return!1;let a=!1;for(let o of e)o.querySelectorAll(Bn).forEach(e=>{let n=e.querySelector(X);n&&n!==i&&Array.from(n.children).forEach(e=>{i.append(e),a=!0}),e!==t&&e.remove()}),o.querySelectorAll(Hn).forEach(e=>{gr(e,n,r)&&(e.closest(X)||(Z(e,Wn,!0),i.append(e),a=!0))});return vr(t,n),a||yr(t)}function Sr(e,t){for(let n of e){if(n===t){n.classList.remove(`quickforge-process-source-empty`);continue}let e=!!n.querySelector(`markdown-block, thinking-block, tool-message, .quickforge-process-group, .quickforge-approval-card`);n.classList.toggle(`quickforge-process-source-empty`,!e)}}function Cr(e){let t=0,n=0;for(let r of e)t+=r.querySelectorAll(Hn).length,n+=r.querySelectorAll(`tool-message`).length;return`${e.length}:${t}:${n}`}function wr(e,t,n,r,i){if(t.length===0)return;let a=t[t.length-1],o=Yn(t,r),s=a.querySelector(Bn);if(n){s&&br(t);return}let c=Cr(t);if(i&&s&&s.dataset.quickforgeProcessFp===c)return;let l=hr(t),u=l?pr(a,n):null;if(l&&mr(a,u),!_r(t,u,l)){s&&(vr(s,u),br(t));return}let d=lr(a);if(d){if(!xr(t,d,u,l)||!yr(d)){d.remove();return}d.dataset.quickforgeProcessFp=c,ur(e,o,t,d,n),Sr(t,a)}}function Tr(e,t,n){let r=t[t.length-1]?.tagName.toLowerCase()===`assistant-message`,i=[],a=[];for(let e of t){if(e.tagName.toLowerCase()===`user-message`){a.length>0&&i.push(a),a=[];continue}a.push(e)}a.length>0&&i.push(a),i.forEach((t,a)=>{let o=n&&r&&a===i.length-1;wr(e,t,o,a,n&&!o)})}var Er=/[A-Za-z]:[\\/][^\s"'<>`]+|(?:\/Users|\/home|\/workspace|\/mnt|\/Volumes)\/[^\s"'<>`]+/g,Dr=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`)`,`]`,`}`,`>`,`。`,`,`,`;`,`:`,`!`,`?`,`)`,`】`,`》`]),Or=[`pre`,`code`,`a`,`button`,`textarea`,`input`,`select`,`thinking-block`,`tool-message`,`.quickforge-file-path-link`,`.quickforge-message-actions`,`.quickforge-process-group`,`.quickforge-approval-card`].join(`,`);function kr(e){let t=e.length;for(;t>0&&Dr.has(e[t-1]);)--t;return{path:e.slice(0,t),suffix:e.slice(t)}}function Ar(e,t){let n=document.createElement(`button`);return n.type=`button`,n.className=`quickforge-file-path-link`,n.dataset.quickforgeFilePath=e,n.textContent=e,n.title=`Open file`,n.setAttribute(`aria-label`,`Open file ${e}`),n.onclick=n=>{n.preventDefault(),n.stopPropagation(),t(e)},n}function jr(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.textContent??``;if(!Er.test(t))return NodeFilter.FILTER_REJECT;Er.lastIndex=0;let n=e.parentElement;return!n||n.closest(Or)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),r=n.nextNode();for(;r;)t.push(r),r=n.nextNode();return t}function Mr(e,t){let n=e.textContent??``;Er.lastIndex=0;let r,i=0,a=document.createDocumentFragment(),o=!1;for(;r=Er.exec(n);){let e=r[0],{path:s,suffix:c}=kr(e);if(!s)continue;let l=r.index,u=l+e.length;l>i&&a.append(document.createTextNode(n.slice(i,l))),a.append(Ar(s,t)),c&&a.append(document.createTextNode(c)),i=u,o=!0}o&&(i<n.length&&a.append(document.createTextNode(n.slice(i))),e.replaceWith(a))}function Nr(e,t,n){let r=Array.from(e.querySelectorAll(`markdown-block`)),i=r.reduce((e,t)=>e+(t.textContent?.length??0),0),a=m(t).length,o=`${String(t.timestamp??``)}:${a}:${r.length}:${i}`;e.dataset.quickforgeLocalPathSignature!==o&&(r.forEach(e=>{jr(e).forEach(e=>Mr(e,n))}),e.dataset.quickforgeLocalPathSignature=o)}function Pr(e,t){let n=new Set,r;e.forEach((e,t)=>{if(e.role===`assistant`){r=t;return}r!==void 0&&n.add(r),r=void 0});let i=t&&e[e.length-1]?.role===`assistant`;return r!==void 0&&!i&&n.add(r),n}function Fr(e,t,n){let r=_(`copied`),i=Number(e.dataset.quickforgeCopyFeedbackTimer);i&&window.clearTimeout(i),W(e,ct),e.title=r,e.setAttribute(`aria-label`,r),e.style.color=`rgb(5 150 105)`;let a=window.setTimeout(()=>{W(e,n),e.title=t,e.setAttribute(`aria-label`,t),e.style.color=``,delete e.dataset.quickforgeCopyFeedbackTimer},1200);e.dataset.quickforgeCopyFeedbackTimer=String(a)}function Ir(e,t,n,r){let i=document.createElement(`button`);return i.type=`button`,i.dataset.quickforgeAction=e,i.title=t,i.setAttribute(`aria-label`,t),W(i,n),i.className=`pointer-events-auto inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-transparent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,i.onclick=e=>{e.stopPropagation(),r(i)},i}function Lr(e){e.querySelectorAll(`.quickforge-rollback-popover`).forEach(e=>{e.quickforgeCleanup?.(),(e.closest(`.quickforge-rollback-action`)?.querySelector(`button[data-quickforge-action="rollback"]`))?.setAttribute(`aria-expanded`,`false`),e.remove()})}function Rr(e){let{panel:t,button:n,messageIndex:r,title:i,description:a,onConfirm:o}=e,s=n.closest(`.quickforge-rollback-action`);if(!s||n.disabled)return;if(s.querySelector(`.quickforge-rollback-popover`)){Lr(t);return}Lr(t);let c=document.createElement(`div`);c.className=`quickforge-rollback-popover`,c.setAttribute(`role`,`dialog`),c.setAttribute(`aria-label`,i),c.tabIndex=-1;let l=document.createElement(`div`);l.className=`quickforge-rollback-popover-arrow`;let u=document.createElement(`div`);u.className=`quickforge-rollback-popover-title`,u.textContent=i;let d=document.createElement(`div`);d.className=`quickforge-rollback-popover-description`,d.textContent=a;let f=document.createElement(`div`);f.className=`quickforge-rollback-popover-footer`;let p=document.createElement(`button`);p.type=`button`,p.className=`quickforge-rollback-popover-cancel`,p.textContent=_(`cancel`);let m=document.createElement(`button`);m.type=`button`,m.className=`quickforge-rollback-popover-confirm`,m.textContent=_(`confirmRollback`),f.append(p,m),c.append(l,u,d,f);let h=()=>Lr(t),g=e=>{let t=e.target;!t||c.contains(t)||n.contains(t)||h()},v=e=>{e.key===`Escape`&&(e.preventDefault(),h())};c.quickforgeCleanup=()=>{document.removeEventListener(`pointerdown`,g,!0),document.removeEventListener(`keydown`,v)},c.addEventListener(`pointerdown`,e=>e.stopPropagation()),c.addEventListener(`click`,e=>e.stopPropagation()),p.addEventListener(`click`,h),m.addEventListener(`click`,async()=>{m.disabled=!0,p.disabled=!0,m.textContent=_(`rollingBack`);try{await o(r)}finally{h()}}),s.append(c),n.setAttribute(`aria-expanded`,`true`),document.addEventListener(`pointerdown`,g,!0),document.addEventListener(`keydown`,v),window.requestAnimationFrame(()=>m.focus())}function zr(e){let t=document.createElement(`span`);t.className=`quickforge-rollback-action`;let n=Ir(`rollback`,_(`rollback`),lt,t=>{Rr({panel:e.panel,button:t,messageIndex:e.messageIndex,title:e.title,description:e.description,onConfirm:e.onConfirm})});return n.disabled=e.isDisabled,n.setAttribute(`aria-haspopup`,`dialog`),n.setAttribute(`aria-expanded`,`false`),t.append(n),t}function Br(e){return e.querySelector(`message-list`)}function Vr(e){let t=Br(e);return t?Array.from(t.querySelectorAll(`user-message, assistant-message`)).filter(e=>e.closest(`message-list`)===t):[]}function Hr(e){let{panel:t,getMessages:n,isStreaming:r,onCopyAnswer:i,onRollbackFromMessage:a,onRetryFromMessage:o,onForkFromMessage:s,onOpenLocalFilePath:c,disableFork:l,readOnly:u=!1,enableTerminalCommandActions:d=!0,rollbackConfirmTitle:p=_(`rollbackConfirmTitle`),rollbackConfirmDescription:h=_(`rollbackConfirm`)}=e,g=n().map((e,t)=>({message:e,index:t})).filter(({message:e})=>e.role===`user`||e.role===`user-with-attachments`||e.role===`assistant`),v=(()=>{for(let e=g.length-1;e>=0;e--)if(g[e].message.role!==`assistant`)return g[e]})(),y=Vr(t),b=r(),x=Pr(g.map(({message:e})=>e),b),S=e=>{let t=_(`copy`);return Ir(`copy`,t,q,async n=>{let r=e();if(r)try{await i(r),Fr(n,t,q)}catch{}})};y.forEach((e,i)=>{let d=g[i];if(!d)return;e.classList.add(`group`,`relative`),e.classList.toggle(`quickforge-assistant-message`,d.message.role===`assistant`),e.classList.toggle(`quickforge-user-message`,d.message.role!==`assistant`),d.message.role===`assistant`&&c&&Nr(e,d.message,c);let y=`quickforge-message-actions pointer-events-none mt-1 flex gap-1 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 ${d.message.role===`assistant`?`px-4 justify-start`:`mx-4 justify-end`}`,b=e.querySelector(`.quickforge-message-actions`);if(!(d.message.role!==`assistant`||x.has(i))){b?.remove();return}if(b?.dataset.quickforgeLayout===`message-bottom`){b.className=y,b.parentElement===e&&b!==e.lastElementChild&&e.append(b),u&&Lr(t),b.querySelectorAll(`button[data-quickforge-action="rollback"], button[data-quickforge-action="retry"], button[data-quickforge-action="fork"]`).forEach(e=>{if(u){e.closest(`.quickforge-rollback-action`)?.remove(),e.remove();return}e.disabled=r()}),r()&&Lr(t);let n=b.querySelector(`button[data-quickforge-action="retry"]`),i=!u&&v&&d.index===v.index&&d.message.role!==`assistant`;if(n&&!i)n.remove();else if(!n&&i){let e=Ir(`retry`,_(`retry`),dt,()=>{o(d.index)});e.disabled=r(),b.append(e)}return}b?.remove();let C=document.createElement(`div`);if(C.dataset.quickforgeLayout=`message-bottom`,C.className=y,d.message.role===`assistant`){let e=m(d.message);if(!e)return;let t=S(()=>{let t=n()[d.index];return t?m(t):e});if(C.append(t),!u&&!l){let e=Ir(`fork`,_(`forkConversation`),ut,()=>{s(d.index)});e.disabled=r(),C.append(e)}}else{let e=f(d.message);if(e){let t=S(()=>{let t=n()[d.index];return t?f(t):e});C.append(t)}if(!u){let e=zr({panel:t,messageIndex:d.index,isDisabled:r(),title:p,description:h,onConfirm:a});C.append(e)}if(!u&&v&&d.index===v.index){let e=Ir(`retry`,_(`retry`),dt,()=>{o(d.index)});e.disabled=r(),C.append(e)}}e.append(C)}),Dn(t),Tr(t,y,r()),jn(t,r()),Rn(t,r()),d?zn(t,r()):t.querySelectorAll(`[data-quickforge-action="execute-markdown-command"]`).forEach(e=>e.remove())}function Ur(e){return e.role===`user`||e.role===`user-with-attachments`||e.role===`assistant`}function Wr(e){return e.role===`user`||e.role===`user-with-attachments`}function Gr(e){return e.role===`assistant`?m(e).trim().length>0:!1}function Kr(e){return e.querySelector(`message-list`)}function qr(e){let t=Kr(e);return t?Array.from(t.querySelectorAll(`user-message, assistant-message`)).filter(e=>e.closest(`message-list`)===t):[]}var Jr=`.quickforge-assistant-waiting`;function Yr(e){e.querySelectorAll(Jr).forEach(e=>e.remove())}function Xr(e){let t=e.querySelectorAll(`thinking-block, tool-message`);for(let e of t)if(!e.closest(`.quickforge-process-body`))return!0;let n=e.querySelectorAll(`markdown-block, code-block`);for(let e of n)if(!e.closest(`.quickforge-process-body`)&&(e.textContent??``).trim().length>0)return!0;let r=e.cloneNode(!0);return r.querySelectorAll(`.quickforge-message-actions`).forEach(e=>e.remove()),r.querySelectorAll(`.quickforge-process-body`).forEach(e=>e.remove()),(r.textContent??``).trim().length>0}function Zr(e){let{panel:t,getMessages:n,isStreaming:r,isActive:i}=e,a=t.querySelector(Jr);if(!r()||!i)return Yr(t),!1;let o=Kr(t),s=n(),c=s.map((e,t)=>({message:e,index:t})).filter(({message:e})=>Ur(e)),l=(()=>{for(let e=c.length-1;e>=0;e--)if(Wr(c[e].message))return e;return-1})();if(!o||l<0)return a?.remove(),!1;let u=c[l],d=s.slice(u.index+1).some(Gr),f=qr(t),p=f[l],m=f.slice(l+1).some(e=>e.matches(`assistant-message`)&&Xr(e));if(!p||d||m)return a?.remove(),!1;let h=a??document.createElement(`div`);return h.className=`quickforge-assistant-waiting`,h.setAttribute(`role`,`status`),h.setAttribute(`aria-live`,`polite`),h.setAttribute(`aria-label`,_(`assistantWaitingAriaLabel`)),a||(h.innerHTML=`
|
|
239
|
-
<div class="quickforge-assistant-waiting-dots" aria-hidden="true">
|
|
240
|
-
<span></span>
|
|
241
|
-
<span></span>
|
|
242
|
-
<span></span>
|
|
243
|
-
</div>
|
|
244
|
-
`),h.previousElementSibling!==p&&p.after(h),!0}function Qr(e){let{panel:t,isStreaming:n,abort:r,agentAccessMode:i,planMode:a,workspaceToolsEnabled:o,readOnly:s,allowModelControls:c,onAccessModeChange:l,onTogglePlanMode:u,onInput:d,onFilesChange:f,removeCommandSuggestions:p,updateCommandSuggestions:m,setupCommandTextareaHandler:h,removeCapabilitySuggestions:g,updateCapabilitySuggestions:v,setupCapabilityTextareaHandler:y,insertBuiltinPluginMention:b,onBeforeSend:x}=e,S=t.querySelector(`message-editor`);S?.classList.add(`quickforge-composer`),S?.parentElement?.classList.add(`quickforge-composer-shell`),S?.parentElement?.parentElement?.classList.add(`quickforge-composer-dock`);let C=S?.querySelector(`textarea`);if(C&&(C.placeholder=_(`composerPlaceholder`)),s){t.querySelector(`.quickforge-composer-dock`)?.remove();return}Ht({editor:S,onInput:d,onFilesChange:f,removeCommandSuggestions:p,updateCommandSuggestions:m,removeCapabilitySuggestions:g,updateCapabilitySuggestions:v,onBeforeSend:x}),h(S),y(S),zt(S,a,u);let w=t.querySelector(`agent-interface`);if(w){let e=w.enableModelSelector!==c;w.enableModelSelector=c,w.enableThinkingSelector=!1,e&&w.requestUpdate?.()}let T=S?.querySelectorAll(`.flex.gap-2.items-center`),E=T?.[0],D=T?.[T.length-1];if(D){if(Rt(S,D),Vt({rightControls:D,isStreaming:n,abort:r,removeCommandSuggestions:p}),!E){t.querySelector(`.quickforge-plus-inline`)?.remove(),At(t),t.querySelector(`.quickforge-agent-access-inline`)?.remove(),Tt(t),t.querySelector(`.quickforge-yolo-inline`)?.remove(),t.querySelector(`.quickforge-plan-inline`)?.remove();return}if(S&&It({panel:t,editor:S,leftControls:E,insertBuiltinPluginMention:b,removeCommandSuggestions:p,removeCapabilitySuggestions:g}),Bt({panel:t,leftControls:E,planMode:a,onTogglePlanMode:u}),!o){t.querySelector(`.quickforge-agent-access-inline`)?.remove(),Tt(t),t.querySelector(`.quickforge-yolo-inline`)?.remove();return}Ot({panel:t,leftControls:E,agentAccessMode:i,onAccessModeChange:l,dismissComposerMenus:()=>At(t)})}}function Q(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function $(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n:void 0}function $r(e,t){let n=e[t];return typeof n==`boolean`?n:void 0}function ei(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function ti(e){let t=e&&Q(e.diff)?e.diff:void 0;return{addedLines:t?ei(t,`addedLines`):void 0,removedLines:t?ei(t,`removedLines`):void 0}}function ni(e=``){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)?`html`:/\.(svg|png|jpe?g|webp|gif|bmp|ico)$/i.test(t)?`image`:t.endsWith(`.md`)||t.endsWith(`.mdx`)?`markdown`:/\.(ts|tsx|js|jsx|mjs|cjs|css|scss|less|json|jsonc|txt|xml|yml|yaml|toml|ini|py|rb|go|rs|java|c|h|cpp|hpp|cs|php|sh|bash|zsh|ps1)$/i.test(t)?`code`:`unknown`}function ri(e){return e===`html`||e===`image`||e===`markdown`||e===`code`}function ii(e){return[e.source,e.path??``,e.command??``,e.outputFile??``,e.toolCallId??``,e.preview?`preview`:``].join(`\0`)}function ai(e,t,n){let r=ii(n);t.has(r)||(t.add(r),e.push({id:`${e.length}:${r}`,...n}))}function oi(e){if(!(typeof e!=`string`||!e.trim()))try{return JSON.parse(e)}catch{return}}function si(e,t){if(t&&(Array.isArray(t.files)||Array.isArray(t.previewed)))return t;let n=e.data;if(Array.isArray(n))for(let e of n){if(!Q(e)||e.type!==`text`)continue;let t=oi(e.text);if(Q(t)&&(Array.isArray(t.files)||Array.isArray(t.previewed)))return t}let r=e.content;if(Array.isArray(r))for(let e of r){if(!Q(e)||e.type!==`text`)continue;let t=oi(e.text);if(Q(t)&&(Array.isArray(t.files)||Array.isArray(t.previewed)))return t}return t}function ci(e){if(typeof e==`string`&&e.trim())return{path:e};if(Q(e)){let t=$(e,`path`);return t?{path:t,title:$(e,`title`),description:$(e,`description`),kind:$(e,`kind`),preview:$r(e,`preview`)}:void 0}}function li(e){let t=new Set,n=[];for(let r of e){if(r.role!==`toolResult`)continue;let e=typeof r.toolName==`string`?r.toolName:``,i=Q(r.details)?r.details:void 0,a=typeof r.toolCallId==`string`?r.toolCallId:void 0;if(!(!i&&e!==`present_files`)){if(e===`write_file`||e===`edit_file`){let r=i?$(i,`path`):void 0;if(r){let o=ni(r),{addedLines:s,removedLines:c}=ti(i);ai(n,t,{source:e,confidence:`high`,path:r,toolCallId:a,kind:o,preview:ri(o),presentation:`inferred`,addedLines:s,removedLines:c})}}else if(e===`present_files`){let e=si(r,i),o=Q(e)&&Array.isArray(e.files)?e.files:[],s=Q(e)?$(e,`defaultPreview`):void 0,c=new Set(Q(e)&&Array.isArray(e.previewed)?e.previewed.filter(e=>typeof e==`string`):[]);for(let e of o){let r=ci(e);if(!r?.path)continue;let i=r.kind??ni(r.path);ai(n,t,{source:`present_files`,confidence:`high`,path:r.path,title:r.title,description:r.description,toolCallId:a,kind:i,preview:r.preview??(c.has(r.path)||s===r.path||ri(i)),defaultPreview:s===r.path,presentation:`explicit`})}}else if(e===`run_command`&&i){let e=$(i,`command`),r=$(i,`outputFile`);(e||r)&&ai(n,t,{source:`run_command`,confidence:`low`,command:e,outputFile:r,toolCallId:a})}}}return n}function ui(e){return e?.length?li(e):[]}var di=`quickforge:composer-drafts:v1`,fi=100,pi={},mi=!1;function hi(e){return!!(e&&!e.startsWith(`pending-`))}function gi(e){return hi(e.sessionId)?`session:${e.sessionId}`:e.scope===`project`&&e.projectId?`new:project:${e.projectId}`:`new:global`}function _i(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e)){if(!r||typeof r!=`object`||Array.isArray(r))continue;let e=r;typeof e.text==`string`&&(t[n]={text:e.text,updatedAt:typeof e.updatedAt==`string`?e.updatedAt:new Date().toISOString(),scope:e.scope===`project`?`project`:e.scope===`global`?`global`:void 0,projectId:typeof e.projectId==`string`?e.projectId:void 0,sessionId:typeof e.sessionId==`string`?e.sessionId:void 0})}return t}function vi(){try{return globalThis.localStorage}catch{return}}function yi(e,t=fi){return Object.fromEntries(Object.entries(e).filter(([,e])=>e.text.length>0).sort(([,e],[,t])=>t.updatedAt.localeCompare(e.updatedAt)).slice(0,t))}function bi(){let e=vi();if(!e||mi)return pi;let t;try{t=e.getItem(di)}catch{return mi=!0,pi}try{return _i(t?JSON.parse(t):void 0)}catch{return pi}}function xi(e){let t=yi(e);pi=t;let n=vi();if(!(!n||mi))try{Object.keys(t).length===0?n.removeItem(di):n.setItem(di,JSON.stringify(t))}catch{let e=yi(t,Math.ceil(fi/2));pi=e;try{Object.keys(e).length===0?n.removeItem(di):n.setItem(di,JSON.stringify(e))}catch{mi=!0}}}async function Si(e){let t=bi()[e];if(!(!t||t.text.length===0))return{text:t.text,attachments:[]}}async function Ci(e,t,n){let r=t.text??``;if(r.length===0){await wi(e);return}let i=bi();i[e]={text:r,updatedAt:new Date().toISOString(),scope:n.scope,projectId:n.scope===`project`?n.projectId:void 0,sessionId:hi(n.sessionId)?n.sessionId:void 0},xi(i)}async function wi(e){let t=bi();Object.prototype.hasOwnProperty.call(t,e)&&(delete t[e],xi(t))}function Ti(){let e=0;return{version:()=>e,isCurrent:t=>t===e,invalidate:()=>(e+=1,e)}}var Ei=r();function Di(e){let t=e.state.contextCompaction;if(!t?.summaryMessage)return e.state.messages;let n=e.state.messages,r=Math.min(n.length,Math.max(0,Number(t.compactedUpToIndex)||0));return[t.summaryMessage,...n.slice(r)]}function Oi(e){let t=String(e.length);for(let n of e)n.role===`toolResult`&&(t+=`|${n.toolCallId??``}:${n.toolName??``}`);return t}function ki({agent:e,onModelSelect:t,revision:n,agentAccessMode:r,workspaceToolsEnabled:i,project:a,projectId:o,chatScope:s=`global`,onAccessModeChange:u,onRollbackFromMessage:f,onRetryFromMessage:p,onCopyAnswer:m,onForkFromMessage:h,onApproveToolCall:v,onRejectToolCall:y,onApproveAutoCompact:b,onRejectAutoCompact:x,onOpenWorkspaceGitChanges:S,onOpenLocalFilePath:C,onArtifactsChange:T,onContextUsageDisplayChange:E,restoredDraft:D,onRestoredDraftConsumed:O,disableFork:k=!1,readOnly:A=!1,bypassClientApiKeyCheck:j=!1,allowModelControls:M=!0,newChatEmptyState:N=!1,rollbackConfirmTitle:ee,rollbackConfirmDescription:te}){let P=(0,w.useRef)(null),ne=(0,w.useRef)(void 0),re=(0,w.useRef)(void 0),F=(0,w.useRef)(new Map),ie=(0,w.useRef)([]),ae=(0,w.useRef)(void 0),oe=(0,w.useRef)(new Set),I=(0,w.useRef)(void 0),se=(0,w.useRef)(null),ce=(0,w.useRef)(!1),le=(0,w.useRef)(new WeakSet),ue=(0,w.useRef)(``),de=(0,w.useRef)(``),fe=(0,w.useRef)(Ti()),[pe,me]=(0,w.useState)(),[L,he]=(0,w.useState)(!1),ge=(0,w.useCallback)(()=>he(e=>!e),[]),_e=(0,w.useCallback)(()=>he(!1),[]);(0,w.useEffect)(()=>{e?.setPlanMode?.(L,L?_e:void 0)},[e,L,_e]);let ve=(0,w.useCallback)(()=>{I.current&&=(window.clearTimeout(I.current),void 0)},[]),R=(0,w.useCallback)(()=>{se.current?.cancel(),se.current=null,ce.current=!1},[]),ye=(0,w.useCallback)(e=>{oe.current.add(e),O?.(e)},[O]),be=(0,w.useMemo)(()=>({sessionId:e?.sessionId,scope:s,projectId:o}),[e?.sessionId,s,o]),xe=gi(be),Se=(0,w.useRef)(be),Ce=(0,w.useRef)(xe);(0,w.useEffect)(()=>{Se.current=be,Ce.current=xe},[be,xe]),(0,w.useEffect)(()=>()=>{ve(),R()},[ve,R]);let z=(0,w.useCallback)((e,t,n)=>{if(t.text.length===0){wi(e).catch(e=>d.error(`Failed to clear composer draft:`,e));return}Ci(e,t,n).catch(e=>d.error(`Failed to save composer draft:`,e))},[]),we=(0,w.useCallback)((e,t,n)=>{I.current&&window.clearTimeout(I.current),I.current=window.setTimeout(()=>{I.current=void 0,z(e,t,n)},400)},[z]),Te=(0,w.useCallback)((e,t=Ce.current,n=Se.current)=>{let r=Ut(e);G(r)?F.current.set(t,r):F.current.delete(t),z(t,r,n)},[z]),B=(0,w.useRef)({onCopyAnswer:m,onRollbackFromMessage:f,onRetryFromMessage:p,onForkFromMessage:h,onAccessModeChange:u,onTogglePlanMode:ge,onApproveToolCall:v,onRejectToolCall:y,onApproveAutoCompact:b,onRejectAutoCompact:x,onOpenWorkspaceGitChanges:S,onOpenLocalFilePath:C,onArtifactsChange:T,onContextUsageDisplayChange:E,onModelSelect:t,agentAccessMode:r,planMode:L,workspaceToolsEnabled:i,disableFork:k,readOnly:A,allowModelControls:M,newChatEmptyState:N,bypassClientApiKeyCheck:j,rollbackConfirmTitle:ee,rollbackConfirmDescription:te,gitBranch:pe});(0,w.useEffect)(()=>{B.current={onCopyAnswer:m,onRollbackFromMessage:f,onRetryFromMessage:p,onForkFromMessage:h,onAccessModeChange:u,onTogglePlanMode:ge,onApproveToolCall:v,onRejectToolCall:y,onApproveAutoCompact:b,onRejectAutoCompact:x,onOpenWorkspaceGitChanges:S,onOpenLocalFilePath:C,onArtifactsChange:T,onContextUsageDisplayChange:E,onModelSelect:t,agentAccessMode:r,planMode:L,workspaceToolsEnabled:i,disableFork:k,readOnly:A,allowModelControls:M,newChatEmptyState:N,bypassClientApiKeyCheck:j,rollbackConfirmTitle:ee,rollbackConfirmDescription:te,gitBranch:pe},re.current=D});let Ee=a?.id??o;(0,w.useEffect)(()=>{let e=!1;return queueMicrotask(()=>{if(!e){if(!Ee){me(void 0);return}g(Ee).then(t=>{e||me(t.isGitRepository?t.branch:void 0)}).catch(t=>{e||(d.warn(`Failed to load git branch:`,t),me(void 0))})}}),()=>{e=!0}},[Ee,n]);let De=(0,w.useRef)(null),Oe=(0,w.useRef)(null),V=(0,w.useRef)(null),H=(0,w.useRef)(null),U=(0,w.useRef)(null);(0,w.useEffect)(()=>{let e=!1;return a?.id?(fetch(`/api/project/commands?projectId=${encodeURIComponent(a.id)}`,{cache:`no-store`}).then(e=>e.ok?e.json():{commands:[]}).then(t=>{e||(ie.current=Array.isArray(t.commands)?t.commands:[],V.current?.())}).catch(()=>{e||(ie.current=[],V.current?.())}),()=>{e=!0}):(ie.current=[],()=>{e=!0})},[a?.id,n]);let ke=(0,w.useCallback)((e,t,n,r)=>{if(t.sessionId&&t.sessionId!==n||!G(t)||oe.current.has(t.id))return;let i=e.querySelector(`message-editor`),a=i?{text:i.value??i.querySelector(`textarea`)?.value??``,attachments:i.attachments?[...i.attachments]:[]}:F.current.get(r),o=ae.current;if(!(o?.id!==t.id||!G(a??Me())||a?.text===o.text))return;fe.current.invalidate(),R();let s=e.querySelector(`agent-interface`);se.current=Kt(e,t,F.current,r,{shouldApply:()=>!oe.current.has(t.id)&&e.isConnected&&!!P.current?.contains(e),onApplyStart:()=>{ce.current=!0},onApplyEnd:()=>{ce.current=!1},onApplied:()=>{le.current.add(e),ne.current=t.id,ae.current={id:t.id,text:t.text},ye(t.id)},updateComplete:s?.updateComplete})},[R,ye]);return(0,w.useEffect)(()=>{if(!P.current||!e)return;let t=fe.current,n=le.current,r=new c;he(!1);let i=e.sessionId,a=Ce.current,o=Se.current,s=!1,u,f=!1,p=!1,m=!1,h=e.state.isStreaming,g=!1,v=He({panel:r});Oe.current=v;let y=Ue({panel:r,getCustomCommands:()=>ie.current,getComposerDrafts:()=>F.current,sessionId:a,setComposerDrafts:e=>{F.current=e},restoreDraftIntoComposer:e=>{Gt(r,e,F.current,a),we(a,e,o)}}),b=Ze({panel:r,restoreDraftIntoComposer:e=>{Gt(r,e,F.current,a),we(a,e,o)}}),x=st({panel:r,getSystemPrompt:()=>e.state.systemPrompt,getMessages:()=>e.state.messages,getEffectiveMessages:()=>Di(e),getContextWindow:()=>e.state.model?.contextWindow??0,getTools:()=>e.state.tools,getMaxTokens:()=>e.state.model?.maxTokens,getServerContextUsage:()=>e.state.contextUsage??null,getGitBranch:()=>B.current.gitBranch,onGitBranchClick:()=>B.current.onOpenWorkspaceGitChanges?.(),renderInline:!1,onDisplayChange:t=>B.current.onContextUsageDisplayChange?.(e.sessionId,t)}),S=()=>{if(ce.current)return;m=!0,t.invalidate(),R();let e=re.current;e&&(!e.sessionId||e.sessionId===i)&&ye(e.id)},C=e=>{S(),f=!1;let t=r.querySelector(`message-editor`),n={text:e,attachments:t?.attachments?[...t.attachments]:[]};G(n)?F.current.set(a,n):F.current.delete(a),we(a,n,o)},w=e=>{S(),f=!1;let t=r.querySelector(`message-editor`),n=t?.querySelector(`textarea`),i={text:t?.value??n?.value??``,attachments:e?[...e]:[]};G(i)?F.current.set(a,i):F.current.delete(a),we(a,i,o);let s=r.querySelector(`agent-interface`);s?.requestUpdate?.(),window.requestAnimationFrame(()=>V.current?.()),s?.updateComplete?.then(()=>V.current?.())},T=()=>{e.state.isStreaming?r.dataset.quickforgeAgentStreaming=`true`:delete r.dataset.quickforgeAgentStreaming},E=()=>{if(s||!r.isConnected)return;T();let t=B.current,n=Oi(e.state.messages);if(n!==de.current){de.current=n;let r=ui(e.state.messages),i=JSON.stringify(r.map(e=>[e.source,e.path,e.command,e.outputFile,e.confidence,e.preview,e.defaultPreview,e.addedLines,e.removedLines]));i!==ue.current&&(ue.current=i,t.onArtifactsChange?.(r))}try{Hr({panel:r,getMessages:()=>e.state.messages,isStreaming:()=>e.state.isStreaming,onCopyAnswer:t.onCopyAnswer,onRollbackFromMessage:t.onRollbackFromMessage,onRetryFromMessage:t.onRetryFromMessage,onForkFromMessage:t.onForkFromMessage,onOpenLocalFilePath:t.onOpenLocalFilePath,disableFork:t.disableFork,readOnly:t.readOnly,enableTerminalCommandActions:!t.readOnly,rollbackConfirmTitle:t.rollbackConfirmTitle,rollbackConfirmDescription:t.rollbackConfirmDescription}),cn({panel:r,getMessages:()=>e.state.messages,getContextCompaction:()=>e.state.contextCompaction??null}),Zr({panel:r,getMessages:()=>e.state.messages,isStreaming:()=>e.state.isStreaming,isActive:h})}catch{}try{Qr({panel:r,isStreaming:()=>e.state.isStreaming,abort:()=>e.abort(),agentAccessMode:t.agentAccessMode,planMode:t.planMode,workspaceToolsEnabled:t.workspaceToolsEnabled,readOnly:t.readOnly,allowModelControls:t.allowModelControls,onAccessModeChange:t.onAccessModeChange,onTogglePlanMode:t.onTogglePlanMode,onInput:C,onFilesChange:w,removeCommandSuggestions:y.remove,updateCommandSuggestions:y.update,setupCommandTextareaHandler:y.setupTextareaHandler,removeCapabilitySuggestions:b.remove,updateCapabilitySuggestions:b.update,setupCapabilityTextareaHandler:b.setupTextareaHandler,insertBuiltinPluginMention:b.insertBuiltinPluginMention,onBeforeSend:t=>{let n=b.consumeSelectedCapabilities(t);e.setNextPromptCapabilities?.(n)}})}catch{}let i=H.current??(()=>{let t=e.state.pendingToolApproval;return t?{...t,sessionId:e.sessionId}:null})();if(i&&i.sessionId===e.sessionId&&typeof i.toolCallId==`string`&&typeof i.toolName==`string`){let t=i.toolCallId;$t({panel:r,onApprove:async()=>{await B.current.onApproveToolCall(t),H.current=null,e.state.pendingToolApproval=null,en(r)},onReject:async()=>{await B.current.onRejectToolCall(t),H.current=null,e.state.pendingToolApproval=null,en(r)}},i.toolName,t,i.args,i.source)}else{let t=U.current??(()=>{let t=e.state.pendingAutoCompactApproval;return t?{...t,sessionId:e.sessionId}:null})();if(t&&t.sessionId===e.sessionId){let n=t.approvalId;$t({panel:r,onApprove:async()=>{await B.current.onApproveAutoCompact?.(n),U.current=null,e.state.pendingAutoCompactApproval=null,en(r)},onReject:async()=>{await B.current.onRejectAutoCompact?.(n),U.current=null,e.state.pendingAutoCompactApproval=null,en(r)}},_(`contextManagement`),n,{percent:t.usage?.percent??0,threshold:t.thresholdPercent??0,keepRecentTurns:t.keepRecentTurns??3,summary:_(`autoCompactApprovalWaiting`,{percent:t.usage?.percent??0,threshold:t.thresholdPercent??0}),description:_(`autoCompactApprovalPreview`,{keepRecentTurns:t.keepRecentTurns??3})})}else en(r)}x.update(),v.setup(),v.isEnabled&&v.scheduleScrollToBottom()},D=!1,O,k=!1,A,j=()=>{A===void 0&&(A=window.requestAnimationFrame(()=>{A=void 0,k=!1}))},M=()=>{if(!s){k=!0;try{E()}finally{j()}}},N=()=>{D||(D=!0,O=window.requestAnimationFrame(()=>{O=void 0,D=!1,M()}))};De.current=M;let ee=()=>{g||(g=!0,window.requestAnimationFrame(()=>{if(g=!1,s)return;T();let e=r.querySelector(`agent-interface`);e?.requestUpdate?.(),V.current?.(),e?.updateComplete?.then(()=>V.current?.()),v.isEnabled&&v.scheduleScrollToBottom()}))};V.current=N,r.setAgent(e,{onApiKeyRequired:B.current.bypassClientApiKeyCheck?async()=>!0:e=>l.prompt(e),onBeforeSend:()=>{t.invalidate(),R();let e=re.current;e&&(!e.sessionId||e.sessionId===i)&&ye(e.id),ve(),f=!0,y.remove(),F.current.delete(a),wi(a).catch(e=>d.error(`Failed to clear composer draft:`,e)),v.enable()},onModelSelect:B.current.onModelSelect,toolsFactory:()=>Ae(e.state.tools)}).then(()=>{if(s)return;let e=re.current,n=t.version(),o=o=>{if(!(s||!t.isCurrent(n)))if(e&&ne.current!==e.id)ke(r,e,i,a);else{let e=o??F.current.get(a)??Me();G(e)||(p=!0),R();let i=r.querySelector(`agent-interface`);se.current=Kt(r,e,F.current,a,{shouldApply:()=>!s&&t.isCurrent(n)&&r.isConnected&&!!P.current?.contains(r),onApplyStart:()=>{ce.current=!0},onApplyEnd:()=>{ce.current=!1},onApplied:()=>{p=!0,le.current.add(r)},updateComplete:i?.updateComplete})}};if(e&&ne.current!==e.id)o();else{let e=F.current.get(a);e?o(e):Si(a).then(e=>o(e)).catch(e=>d.error(`Failed to load composer draft:`,e))}u=new MutationObserver(()=>{k||N()}),u.observe(r,{childList:!0,subtree:!0}),window.requestAnimationFrame(()=>{s||M()})}),P.current.replaceChildren(r);let te=e.subscribe(t=>{if(t.type===`agent_start`&&(h=!0,T(),V.current?.(),v.enable(),H.current?.sessionId===e.sessionId&&(H.current=null),U.current?.sessionId===e.sessionId&&(U.current=null)),t.type===`message_start`||t.type===`message_update`||t.type===`message_end`||t.type===`turn_end`||t.type===`agent_end`){T();let e=t.message;(t.type===`message_update`||e?.role===`assistant`)&&(h=!1),V.current?.(),v.isEnabled&&v.scheduleScrollToBottom()}if(t.type===`messages_replaced`){let e=re.current;e&&ne.current===e.id&&ke(r,e,i,a)}let n=t.type;if(n===`tool_execution_start`||n===`tool_execution_end`){T();let e=r.querySelector(`agent-interface`);e?.requestUpdate?.(),V.current?.(),window.requestAnimationFrame(()=>V.current?.()),e?.updateComplete?.then(()=>V.current?.()),v.isEnabled&&v.scheduleScrollToBottom()}if(n===`tool_execution_update`&&ee(),t.type===`agent_end`&&(h=!1,T(),V.current?.(),H.current?.sessionId===e.sessionId&&(H.current=null,V.current?.()),U.current?.sessionId===e.sessionId&&(U.current=null,V.current?.())),n===`auto_compact_completed`||n===`messages_replaced`){let e=r.querySelector(`agent-interface`);e?.requestUpdate?.(),V.current?.(),window.requestAnimationFrame(()=>V.current?.()),e?.updateComplete?.then(()=>V.current?.())}if(n===`auto_compact_failed`&&d.warn(_(`autoCompactFailed`)),t.type===`tool_approval_required`){let e=t;H.current={toolCallId:e.toolCallId,toolName:e.toolName,args:e.args,sessionId:e.sessionId,source:e.source},V.current?.()}if(t.type===`auto_compact_approval_required`){let e=t;U.current={approvalId:e.approvalId,usage:e.usage,thresholdPercent:e.thresholdPercent,keepRecentTurns:e.keepRecentTurns,sessionId:e.sessionId},V.current?.()}});return()=>{s=!0,t.invalidate(),R(),ve(),f?(F.current.delete(a),wi(a).catch(e=>d.error(`Failed to clear composer draft:`,e))):(p||m||n.has(r))&&(Wt(r,F.current,a),Te(r,a,o)),y.remove(),y.cleanupTextareaHandler(),b.remove(),b.cleanupTextareaHandler(),v.cleanup(),Oe.current=null,te(),u?.disconnect(),O!==void 0&&window.cancelAnimationFrame(O),A!==void 0&&window.cancelAnimationFrame(A),De.current=null,r.remove()}},[e,ve,R,ye,Te,ke,we]),(0,w.useEffect)(()=>{let e=P.current;e&&(e.classList.toggle(`quickforge-chat-panel-empty-host`,N),e.dataset.quickforgeEmptyChat=N?`true`:`false`)},[N]),(0,w.useEffect)(()=>{De.current?.(),(P.current?.querySelector(`agent-interface`))?.requestUpdate?.()},[r,L,i,pe,k,A,M,n]),(0,w.useEffect)(()=>{let t=re.current;if(!t||!P.current)return;let n=e?.sessionId??``;if(t.sessionId&&t.sessionId!==n||oe.current.has(t.id))return;let r=P.current.querySelector(`pi-chat-panel`);r&&ke(r,t,n,Ce.current)},[D,e,ke]),(0,Ei.jsx)(`div`,{ref:P,className:`min-h-0 flex-1 overflow-hidden`})}export{ki as ChatPanelHost};
|