@shawnstack/quickforge 1.7.11 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/AgentProfilesPage-lKGIE5Dj.js +1 -0
  3. package/dist/assets/ChatPanelHost-CWUYIkXG.js +11 -0
  4. package/dist/assets/CloudAccountSettingsPage-BhXH0ups.js +1 -0
  5. package/dist/assets/{PluginsPage-mLvwvTmL.js → PluginsPage-DHWF13mN.js} +1 -1
  6. package/dist/assets/ScheduledTasksPage-DLAg-i8c.js +2 -0
  7. package/dist/assets/{SettingsWorkspacePage-0OINfEqK.js → SettingsWorkspacePage-BhUzL5oi.js} +313 -313
  8. package/dist/assets/ShareLinksSettingsPage-DogGa3lH.js +1 -0
  9. package/dist/assets/SharedConversationPage-7QpeaG_P.js +1 -0
  10. package/dist/assets/TerminalDock-CWSKcuiU.js +2 -0
  11. package/dist/assets/WorkspaceInspector-CEfyYqWy.js +36 -0
  12. package/dist/assets/{abnfDiagram-VRR7QNED-CMhVoYUh.js → abnfDiagram-VRR7QNED-DGklo3PO.js} +1 -1
  13. package/dist/assets/{architectureDiagram-ZJ3FMSHR-C52qL6Hg.js → architectureDiagram-ZJ3FMSHR-CioWLVTp.js} +1 -1
  14. package/dist/assets/{blockDiagram-677ZJIJ3-CM3XbLol.js → blockDiagram-677ZJIJ3-BJWBq5e9.js} +1 -1
  15. package/dist/assets/{c4Diagram-LMCZKHZV-D7Bh1ui1.js → c4Diagram-LMCZKHZV-BacRvqFK.js} +1 -1
  16. package/dist/assets/channel-CeXY-wZo.js +1 -0
  17. package/dist/assets/{chunk-32BRIVSS-xgrtbT8e.js → chunk-32BRIVSS-B53BNE2C.js} +1 -1
  18. package/dist/assets/{chunk-52WLFC77-CDbaHw80.js → chunk-52WLFC77-CYq4hT4f.js} +1 -1
  19. package/dist/assets/{chunk-C7G6YPKG-ZMLUvfLy.js → chunk-C7G6YPKG-KFaGpP_Z.js} +1 -1
  20. package/dist/assets/{chunk-EX3LRPZG-BcQhaqt7.js → chunk-EX3LRPZG-DqVd_ihG.js} +1 -1
  21. package/dist/assets/{chunk-FWX5IMBZ-DrnrdrSu.js → chunk-FWX5IMBZ-BxRjZkOP.js} +2 -2
  22. package/dist/assets/{chunk-HOUHSVGY-tdc-Z9eW.js → chunk-HOUHSVGY-C9QO8omv.js} +1 -1
  23. package/dist/assets/{chunk-ICXQ74PX-Cd7igVGt.js → chunk-ICXQ74PX-ClbGPgLV.js} +1 -1
  24. package/dist/assets/{chunk-MOJQB5TN-CLTjV5ov.js → chunk-MOJQB5TN-Ba4wlF1J.js} +1 -1
  25. package/dist/assets/{chunk-OGEWGWER-TgvkXkFX.js → chunk-OGEWGWER-DczhQmcx.js} +1 -1
  26. package/dist/assets/{chunk-PUDLZKDR-C5GMVYup.js → chunk-PUDLZKDR-CPWpcKUF.js} +1 -1
  27. package/dist/assets/{chunk-Q4XR5HBZ-fo5-HsqY.js → chunk-Q4XR5HBZ-CiF6T--X.js} +1 -1
  28. package/dist/assets/{chunk-V7JOEXUC-CEDazV6w.js → chunk-V7JOEXUC-Dxv0zwmw.js} +1 -1
  29. package/dist/assets/{chunk-VAUOI2AC-CWYjg8zE.js → chunk-VAUOI2AC-D3J5bw1P.js} +1 -1
  30. package/dist/assets/{chunk-VR4S4FIN-C_-eEj-9.js → chunk-VR4S4FIN-BXQSwwII.js} +1 -1
  31. package/dist/assets/{chunk-WYO6CB5R-NF-MsJJR.js → chunk-WYO6CB5R-C0azl-fk.js} +2 -2
  32. package/dist/assets/{chunk-ZGVPDNZ5-CRrAYi4g.js → chunk-ZGVPDNZ5-D_8F4Akx.js} +1 -1
  33. package/dist/assets/classDiagram-OUVF2IWQ-B8M6sf49.js +1 -0
  34. package/dist/assets/classDiagram-v2-EOCWNBFH-BY7fzBDH.js +1 -0
  35. package/dist/assets/{cynefinDiagram-TSTJHNR4-D4sZ7LYI.js → cynefinDiagram-TSTJHNR4-BFlsWz0B.js} +1 -1
  36. package/dist/assets/{dagre-VKFMJZFB-BlsnSh-Q.js → dagre-VKFMJZFB-DXhpjlEs.js} +1 -1
  37. package/dist/assets/{diagram-FQU43EPY-DW1yQiRO.js → diagram-FQU43EPY-DRVVOD9k.js} +1 -1
  38. package/dist/assets/{diagram-G47NLZAW-BTUAsFjb.js → diagram-G47NLZAW-BV9Gw1tL.js} +1 -1
  39. package/dist/assets/{diagram-NH7WQ7WH-BcaomqSd.js → diagram-NH7WQ7WH-CrUkXfRY.js} +1 -1
  40. package/dist/assets/{diagram-OA4YK3LP-DDLX7Xwr.js → diagram-OA4YK3LP-CuILjn7v.js} +1 -1
  41. package/dist/assets/{diagram-WEI45ONY-CIave0An.js → diagram-WEI45ONY-nlNN3tWB.js} +1 -1
  42. package/dist/assets/{ebnfDiagram-CCIWWBDH-Cr1Y6lPu.js → ebnfDiagram-CCIWWBDH-BuDgZt9n.js} +1 -1
  43. package/dist/assets/{erDiagram-Q63AITRT-D3EgiVVH.js → erDiagram-Q63AITRT-MEwxjmtP.js} +1 -1
  44. package/dist/assets/flowDiagram-23GEKE2U-BiUP-Scq.js +1 -0
  45. package/dist/assets/{ganttDiagram-NO4QXBWP-B0oyDIqK.js → ganttDiagram-NO4QXBWP-DNw5qghE.js} +1 -1
  46. package/dist/assets/{gitGraphDiagram-IHSO6WYX-uQtr6IqK.js → gitGraphDiagram-IHSO6WYX-CaTcakAt.js} +1 -1
  47. package/dist/assets/index-CX36XjVA.css +3 -0
  48. package/dist/assets/index-CgVTwN15.js +66 -0
  49. package/dist/assets/{infoDiagram-FWYZ7A6U-B_GzlLIM.js → infoDiagram-FWYZ7A6U-DwfyP7dU.js} +1 -1
  50. package/dist/assets/{ishikawaDiagram-FXEZZL3T-CKQIsSdU.js → ishikawaDiagram-FXEZZL3T-CmrzbOCV.js} +1 -1
  51. package/dist/assets/{journeyDiagram-5HDEW3XC-DrrvzZL1.js → journeyDiagram-5HDEW3XC-CYqe3sgr.js} +1 -1
  52. package/dist/assets/{kanban-definition-HUTT4EX6-CJQRTdXz.js → kanban-definition-HUTT4EX6-BMDO_mv0.js} +1 -1
  53. package/dist/assets/{line-B4DxX7tC.js → line-SbxJR8ZT.js} +1 -1
  54. package/dist/assets/lit-vendor-CinchGmI.js +2 -0
  55. package/dist/assets/local-tools-CJVNO1aW.js +388 -0
  56. package/dist/assets/{mcp-servers-dialog-B2lALtTE.js → mcp-servers-dialog-xf3UR49J.js} +2 -2
  57. package/dist/assets/{mermaid.core-DWpShXCs.js → mermaid.core-CwXTzYjs.js} +3 -3
  58. package/dist/assets/{mindmap-definition-LN4V7U3C-CEVwZD78.js → mindmap-definition-LN4V7U3C-CLyJ78mO.js} +1 -1
  59. package/dist/assets/{pegDiagram-2B236MQR-CBLkBdnQ.js → pegDiagram-2B236MQR-4qFznrSw.js} +1 -1
  60. package/dist/assets/{pi-web-ui-DV5jKjSg.js → pi-web-ui-BNuvqKDT.js} +289 -289
  61. package/dist/assets/{pieDiagram-ENE6RG2P-8tCnwtWS.js → pieDiagram-ENE6RG2P-141sGxVe.js} +1 -1
  62. package/dist/assets/{quadrantDiagram-ABIIQ3AL-CWd28cHF.js → quadrantDiagram-ABIIQ3AL-SUI44pAX.js} +1 -1
  63. package/dist/assets/{railroadDiagram-RFXS5EU6-CI4ouOBs.js → railroadDiagram-RFXS5EU6-1oiZuYBB.js} +1 -1
  64. package/dist/assets/{requirementDiagram-TGXJPOKE-DtFz7sw4.js → requirementDiagram-TGXJPOKE-CfVishLi.js} +1 -1
  65. package/dist/assets/{sankeyDiagram-HTMAVEWB--VeOwwk9.js → sankeyDiagram-HTMAVEWB-DVu7J_Z9.js} +1 -1
  66. package/dist/assets/{sequenceDiagram-DBY2YBRQ-B8AHk5Oe.js → sequenceDiagram-DBY2YBRQ-D-Ip2yiS.js} +1 -1
  67. package/dist/assets/{skills-dialog-DYp35JM3.js → skills-dialog-Bbqtuy2h.js} +3 -3
  68. package/dist/assets/{stateDiagram-2N3HPSRC-etXnJ8X8.js → stateDiagram-2N3HPSRC-Cg0hWwrp.js} +1 -1
  69. package/dist/assets/stateDiagram-v2-6OUMAXLB-DhmzNQd9.js +1 -0
  70. package/dist/assets/{swimlanes-5IMT3BWC-pabIKAmn.js → swimlanes-5IMT3BWC-Co5D-cGU.js} +1 -1
  71. package/dist/assets/swimlanesDiagram-G3AALYLV-BEvomQNa.js +8 -0
  72. package/dist/assets/{timeline-definition-FHXFAJF6-C55MKm3L.js → timeline-definition-FHXFAJF6-CBk4c_Ua.js} +1 -1
  73. package/dist/assets/{vennDiagram-L72KCM5P-CgNf1Q9W.js → vennDiagram-L72KCM5P-BII7wdRx.js} +1 -1
  74. package/dist/assets/{wardleyDiagram-EHGQE667-Drt5ytec.js → wardleyDiagram-EHGQE667-CkyJJIXP.js} +1 -1
  75. package/dist/assets/{xychartDiagram-FW5EYKEG-hhoEo_Ar.js → xychartDiagram-FW5EYKEG-B1A66Ks0.js} +1 -1
  76. package/dist/index.html +6 -6
  77. package/dist/licenses/material-icon-theme.txt +8 -8
  78. package/package.json +1 -1
  79. package/server/agent-manager.mjs +305 -49
  80. package/server/approval-store.mjs +1 -0
  81. package/server/ask-store.mjs +78 -0
  82. package/server/context-references.mjs +139 -0
  83. package/server/custom-commands.mjs +43 -0
  84. package/server/index.mjs +1 -1
  85. package/server/project-config.mjs +17 -5
  86. package/server/routes/agent-profiles.mjs +16 -1
  87. package/server/routes/agent.mjs +10 -1
  88. package/server/routes/shared-conversation.mjs +13 -1
  89. package/server/routes/skills.mjs +22 -0
  90. package/server/routes/workspace.mjs +166 -2
  91. package/server/selected-capabilities.mjs +76 -0
  92. package/server/session-state-import.mjs +20 -3
  93. package/server/skills.mjs +1 -1
  94. package/server/system-prompt.mjs +1 -3
  95. package/server/tools/definitions.mjs +18 -10
  96. package/server/tools/index.mjs +14 -2
  97. package/server/utils/workspace.mjs +13 -4
  98. package/skills/skill-creator/SKILL.md +485 -485
  99. package/skills/skill-creator/agents/analyzer.md +274 -274
  100. package/skills/skill-creator/agents/comparator.md +202 -202
  101. package/skills/skill-creator/agents/grader.md +223 -223
  102. package/skills/skill-creator/assets/eval_review.html +146 -146
  103. package/skills/skill-creator/eval-viewer/viewer.html +1325 -1325
  104. package/skills/skill-creator/references/schemas.md +430 -430
  105. package/dist/assets/AgentProfilesPage-Cvb1KTz5.js +0 -1
  106. package/dist/assets/ChatPanelHost-C7zV-xE_.js +0 -48
  107. package/dist/assets/CloudAccountSettingsPage-mAs_nbvw.js +0 -1
  108. package/dist/assets/ScheduledTasksPage-CuUW_9lq.js +0 -2
  109. package/dist/assets/ShareLinksSettingsPage-DqeyJYoD.js +0 -1
  110. package/dist/assets/SharedConversationPage-C7CDEoX9.js +0 -1
  111. package/dist/assets/TerminalDock-CZXcuMpq.js +0 -2
  112. package/dist/assets/WorkspaceInspector-CNSBOEvP.js +0 -36
  113. package/dist/assets/channel-Duu1CuH9.js +0 -1
  114. package/dist/assets/classDiagram-OUVF2IWQ-Cc63fLWP.js +0 -1
  115. package/dist/assets/classDiagram-v2-EOCWNBFH-CoXU0qT6.js +0 -1
  116. package/dist/assets/flowDiagram-23GEKE2U-BS7KXcqn.js +0 -1
  117. package/dist/assets/index-BgMvQW1b.js +0 -66
  118. package/dist/assets/index-CB1g2D0f.css +0 -3
  119. package/dist/assets/lit-vendor-DvaQX_UQ.js +0 -2
  120. package/dist/assets/local-tools-Dopjg9xq.js +0 -270
  121. package/dist/assets/stateDiagram-v2-6OUMAXLB-Dms3pICj.js +0 -1
  122. package/dist/assets/swimlanesDiagram-G3AALYLV-B14aWjv6.js +0 -8
package/README.md CHANGED
@@ -147,7 +147,7 @@ API Key: 本地模型或部分代理服务可留空
147
147
  - 流式回复、停止生成、复制、回滚、重试与对话分支
148
148
  - 草稿恢复、会话置顶、归档、搜索和长对话压缩
149
149
  - 图片附件与视觉模型配置
150
- - `/init`、`/plan`、`/review`、`/summary`、`/compact`、`/help` 等内置命令;`/init` 会调研当前仓库并生成或更新根目录 `AGENTS.md` 贡献者指南
150
+ - `/init`、`/plan`、`/review`、`/commit [message]`、`/summary`、`/compact`、`/help` 等内置命令;`/commit` 会先验证并只提交当前任务相关改动,最多创建一个本地 commit;`/init` 会调研当前仓库并生成或更新根目录 `AGENTS.md` 贡献者指南
151
151
  - 跨对话、跨项目的全局记忆,可在设置中查看、编辑或关闭
152
152
  - 设置 → 常规提供直连、跟随操作系统真实代理、手动 HTTP(S) 代理和 PAC 地址四种网络模式;自定义 PAC 地址由 Desktop 的 Electron/Chromium 处理,CLI/SDK 当前不支持,系统代理仍由原生跨平台解析,本地地址始终直连
153
153
 
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Gt as t,Jt as n,Pt as r,f as i,ht as a,j as o,s,zt as ee}from"./icons-DM_qJ7VJ.js";import{i as te,n as c}from"./react-vendor-BpWW_Nvp.js";import{n as ne,r as re,t as ie}from"./model-display-label-CURwH0xM.js";import{Et as ae,In as l,Rn as u,Sn as oe,Un as d,kn as f,lt as se,vn as ce,xn as le,yn as ue}from"./index-CgVTwN15.js";import{i as de,r as fe,t as pe}from"./model-identity-CgA6_Pbm.js";var p=e(n(),1),me=te(),he=1e3/6e4,m=6e4,h=1e3;function g(e){let t=Number.isFinite(e)&&Number(e)>0?Math.max(Math.round(Number(e)),h):60*m;return Number((t/m).toFixed(6)).toString()}function _(e){return Math.max(Math.round(Number(e)*m),h)}function v(e){let t=Number(e);return Number.isFinite(t)&&t>=.016666666666666666&&t<=60}var y=c(),ge=144,b=82,x=4,S=8;function C(e){return JSON.stringify(re(e))}function w(e){if(!e)return{mode:`inherit`};try{return{mode:`fixed`,...JSON.parse(e)}}catch{return{mode:`inherit`}}}function T(e){return!e||e.mode!==`fixed`?``:e.source===`cloud`?JSON.stringify({version:1,source:`cloud`,catalogId:e.catalogId}):e.source===`custom`?JSON.stringify({version:1,source:`custom`,providerId:e.providerId,modelId:e.modelId}):JSON.stringify({version:1,source:`legacy-custom`,provider:e.provider,modelId:e.modelId,...e.api?{api:e.api}:{},...e.baseUrl?{baseUrl:e.baseUrl}:{}})}function E(){return{name:``,label:``,description:``,systemPrompt:``,allowedTools:[`read_file`,`grep_files`],maxRuntimeMinutes:`60`,maxToolCalls:`300`,enabledAsSubagent:!0,modelMode:`inherit`,fixedModelValue:``,thinkingLevel:`inherit`}}function _e(e){return{name:e.name,label:e.label,description:e.description??``,systemPrompt:e.systemPrompt??``,allowedTools:e.allowedTools??[],maxRuntimeMinutes:g(e.maxRuntimeMs),maxToolCalls:String(e.maxToolCalls??300),enabledAsSubagent:e.enabledAsSubagent,modelMode:e.model?.mode===`fixed`?`fixed`:`inherit`,fixedModelValue:T(e.model),thinkingLevel:e.thinkingLevel??`inherit`}}function ve(e){return{name:e.name.trim().toLowerCase(),label:e.label.trim(),description:e.description.trim(),systemPrompt:e.systemPrompt.trim(),allowedTools:e.allowedTools,maxRuntimeMs:_(e.maxRuntimeMinutes),maxToolCalls:Number(e.maxToolCalls||300),enabledAsSubagent:e.enabledAsSubagent,model:e.modelMode===`fixed`?w(e.fixedModelValue):{mode:`inherit`},thinkingLevel:e.thinkingLevel}}function D(e){return!!(e.name.trim()&&e.label.trim()&&e.allowedTools.length>0&&v(e.maxRuntimeMinutes))}async function O(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 k(){let[e,n]=(0,p.useState)([]),[te,c]=(0,p.useState)([]),[m,h]=(0,p.useState)(!1),[g,_]=(0,p.useState)(null),[v,k]=(0,p.useState)(()=>E()),[A,j]=(0,p.useState)(!1),[M,N]=(0,p.useState)(``),[P,F]=(0,p.useState)(!1),[I,ye]=(0,p.useState)(),[L,be]=(0,p.useState)([]),[xe,Se]=(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([O(`/api/agent-profiles`),O(`/api/agent-profiles/available-tools`)]);n(e.agents),c(t.tools)}(0,p.useEffect)(()=>{let e=!1;async function t(){try{let[t,r]=await Promise.all([O(`/api/agent-profiles`),O(`/api/agent-profiles/available-tools`)]);if(e)return;n(t.agents),c(r.tools)}catch(t){e||z(t instanceof Error?t.message:d(`requestFailed`))}}return t(),()=>{e=!0}},[]),(0,p.useEffect)(()=>{let e=!1;async function t(){try{let t=await le(),[n,r]=await Promise.all([ue(t),ne().catch(()=>[])]),i=r.length?r:n;be(i);let a=i.filter(f),o=await oe(t),s=(o.model&&f(o.model)?a.find(e=>de(e,o.model)):void 0)??a[0];if(e)return;ye(s),Se(o.thinkingLevel??ce(s))}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===g)??null,[e,g]),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)(()=>{let e=w(v.fixedModelValue);if(e.mode!==`fixed`)return;let t=T(e);return L.find(e=>C(e)===t)??(`provider`in e?L.find(t=>fe(t,e)):void 0)},[v.fixedModelValue,L]),Ce=(0,p.useMemo)(()=>L.filter(f),[L]),we=(0,p.useMemo)(()=>pe(Ce,Y),[Ce,Y]),Te=Y?C(Y):v.fixedModelValue,X=v.modelMode===`fixed`&&!!Y&&Y?.reasoning!==!0;function Ee(e,t){if(e.stopPropagation(),B===t){V(null),U(null);return}let n=e.currentTarget.getBoundingClientRect(),r=Math.max(S,Math.min(n.right-ge,window.innerWidth-ge-S)),i=n.bottom+x,a=n.top-x-b;U({left:r,top:i+b<=window.innerHeight-S?i:Math.max(S,a)}),V(t)}function Z(e,t){k(n=>({...n,[e]:t}))}function De(e){se(Y??null,we,e=>Z(`fixedModelValue`,e?C(e):``),{anchor:e.currentTarget,noneLabel:d(`agentModelInherit`)})}function Oe(e){k(t=>({...t,allowedTools:t.allowedTools.includes(e)?t.allowedTools.filter(t=>t!==e):[...t.allowedTools,e]}))}function ke(){_(null),k(E()),N(``),z(``),h(!0)}function Q(e){_(e.id),k(_e(e)),N(``),z(``),h(!0)}function $(){A||P||(h(!1),_(null),k(E()),N(``))}async function Ae(){let e=M.trim();if(!e){z(d(`aiFillAgentInputRequired`));return}if(!I){z(d(`aiFillAgentNoModel`));return}F(!0),z(``);try{let t=await O(`/api/agent-profiles/ai-fill`,{method:`POST`,body:JSON.stringify({instruction:e,modelRef:re(I),model:I,thinkingLevel:xe})});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 je(){if(!D(v))return;j(!0),z(``);let e=X&&v.thinkingLevel!==`inherit`?`off`:v.thinkingLevel;try{let t=G?.builtin?{model:v.modelMode===`fixed`?w(v.fixedModelValue):{mode:`inherit`},thinkingLevel:e}:ve({...v,thinkingLevel:e});g?await O(`/api/agent-profiles/${encodeURIComponent(g)}`,{method:`PATCH`,body:JSON.stringify(t)}):await O(`/api/agent-profiles`,{method:`POST`,body:JSON.stringify(t)}),$(),await W()}catch(e){z(e instanceof Error?e.message:d(`requestFailed`))}finally{j(!1)}}async function Me(e){if(e.builtin||e.readonly)return;let t=!e.enabledAsSubagent,r=e.enabledAsSubagent;n(n=>n.map(n=>n.id===e.id?{...n,enabledAsSubagent:t}:n)),V(null);try{await O(`/api/agent-profiles/${encodeURIComponent(e.id)}`,{method:`PATCH`,body:JSON.stringify({enabledAsSubagent:t})})}catch(t){n(t=>t.map(t=>t.id===e.id?{...t,enabledAsSubagent:r}:t)),z(t instanceof Error?t.message:d(`requestFailed`))}}async function Ne(e){if(!(e.builtin||e.readonly)&&await ae({description:d(`confirmDeleteAgent`),confirmLabel:d(`confirmDelete`),cancelLabel:d(`cancel`),variant:`destructive`})){z(``);try{await O(`/api/agent-profiles/${encodeURIComponent(e.id)}`,{method:`DELETE`}),await W()}catch(e){z(e instanceof Error?e.message:d(`requestFailed`))}}}return m?(0,y.jsxs)(`div`,{className:`quickforge-settings-stack`,children:[(0,y.jsx)(`div`,{className:`quickforge-settings-heading`,children:(0,y.jsxs)(`h3`,{className:`quickforge-settings-title`,children:[G?.builtin?d(`builtinAgentModelSettings`):d(G?`editAgent`:`createAgent`),(0,y.jsx)(l,{label:G?.builtin?d(`builtinAgentModelOnly`):G?.readonly?d(`readonlyAgentDescription`):d(`agentsDescription`)})]})}),(0,y.jsxs)(`section`,{className:`quickforge-settings-section`,"aria-label":d(G?`editAgent`:`createAgent`),children:[(0,y.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,y.jsxs)(`button`,{className:`quickforge-settings-button quickforge-settings-button-secondary`,type:`button`,onClick:$,disabled:A||P,children:[(0,y.jsx)(t,{className:`mr-2 size-4`}),d(`back`)]}),(0,y.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,y.jsx)(`div`,{className:`quickforge-settings-row-title`,children:G?.builtin?d(`builtinAgentModelSettings`):d(G?`editAgent`:`createAgent`)}),G?.builtin?(0,y.jsx)(`div`,{className:`quickforge-settings-row-description`,children:d(`builtinAgentModelOnly`)}):G?.readonly?(0,y.jsx)(`div`,{className:`quickforge-settings-row-description`,children:d(`readonlyAgentDescription`)}):null]})]}),(0,y.jsx)(`div`,{className:`px-5 py-4`,children:(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(`div`,{className:`rounded-2xl border border-border bg-muted/20 p-3`,children:[(0,y.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-medium text-foreground`,children:[(0,y.jsx)(i,{className:`size-4 text-primary`}),d(`aiFillAgent`),(0,y.jsx)(l,{label:d(`aiFillAgentDescription`)})]}),(0,y.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,y.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,y.jsxs)(u,{variant:`outline`,size:`sm`,onClick:()=>void Ae(),disabled:q||P||!M.trim(),children:[(0,y.jsx)(i,{className:`mr-1 size-3.5`}),d(P?`aiFillAgentLoading`:`aiFillAgent`)]})})]}),(0,y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,y.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`agentName`),(0,y.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:v.name,disabled:q,onChange:e=>Z(`name`,e.target.value),placeholder:`reviewer`})]}),(0,y.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`agentLabel`),(0,y.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:v.label,disabled:q,onChange:e=>Z(`label`,e.target.value),placeholder:d(`agentLabelPlaceholder`)})]})]}),G?(0,y.jsxs)(`div`,{className:`rounded-xl border border-border bg-muted/20 px-3 py-2 text-sm`,children:[(0,y.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:d(`agentSourcePath`)}),(0,y.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,y.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`agentDescription`),(0,y.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:v.description,disabled:q,onChange:e=>Z(`description`,e.target.value)})]}),(0,y.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`agentSystemPrompt`),(0,y.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:v.systemPrompt,disabled:q,onChange:e=>Z(`systemPrompt`,e.target.value)})]}),(0,y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,y.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`agentModelMode`),(0,y.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:v.modelMode,disabled:J,onChange:e=>Z(`modelMode`,e.target.value),children:[(0,y.jsx)(`option`,{value:`inherit`,children:d(`agentModelInherit`)}),(0,y.jsx)(`option`,{value:`fixed`,children:d(`agentModelFixed`)})]})]}),(0,y.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`agentFixedModel`),(0,y.jsxs)(`select`,{className:`quickforge-model-select-desktop 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:Te,disabled:J||v.modelMode!==`fixed`,onChange:e=>Z(`fixedModelValue`,e.target.value),children:[(0,y.jsx)(`option`,{value:``,children:d(`agentModelInherit`)}),we.map(e=>(0,y.jsx)(`option`,{value:C(e),children:ie(e)},C(e)))]}),(0,y.jsxs)(`button`,{type:`button`,className:`quickforge-model-select-mobile mt-1 flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 text-sm text-left outline-none focus:border-ring disabled:opacity-60`,disabled:J||v.modelMode!==`fixed`,onClick:De,children:[(0,y.jsx)(`span`,{className:`truncate`,children:Y?ie(Y):d(`agentModelInherit`)}),(0,y.jsx)(r,{className:`ml-2 size-4 shrink-0 text-muted-foreground`})]})]})]}),(0,y.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`agentThinkingLevel`),(0,y.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&&v.thinkingLevel!==`inherit`?`off`:v.thinkingLevel,disabled:J||X,onChange:e=>Z(`thinkingLevel`,e.target.value),children:[(0,y.jsx)(`option`,{value:`inherit`,children:d(`agentThinkingInherit`)}),(0,y.jsx)(`option`,{value:`off`,children:d(`thinkingOff`)}),(0,y.jsx)(`option`,{value:`low`,children:d(`thinkingLow`)}),(0,y.jsx)(`option`,{value:`medium`,children:d(`thinkingMedium`)}),(0,y.jsx)(`option`,{value:`high`,children:d(`thinkingHigh`)}),(0,y.jsx)(`option`,{value:`xhigh`,children:d(`thinkingXHigh`)})]}),(0,y.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:d(X?`agentThinkingUnsupported`:`agentThinkingDescription`)})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`mb-2 text-sm font-medium text-foreground`,children:d(`allowedTools`)}),(0,y.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:te.map(e=>(0,y.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,y.jsx)(`input`,{type:`checkbox`,className:`mt-1`,disabled:q,checked:v.allowedTools.includes(e.name),onChange:()=>Oe(e.name)}),(0,y.jsxs)(`span`,{children:[(0,y.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),(0,y.jsx)(`span`,{className:`ml-2 font-mono text-xs text-muted-foreground`,children:e.name}),e.riskLevel===`dangerous`?(0,y.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,y.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:e.description})]})]},e.name))})]}),(0,y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,y.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`maxRuntimeMinutes`),(0,y.jsx)(`input`,{type:`number`,min:he,max:60,step:`any`,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:v.maxRuntimeMinutes,disabled:q,onChange:e=>Z(`maxRuntimeMinutes`,e.target.value)}),(0,y.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:d(`maxRuntimeMinutesHelp`)})]}),(0,y.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[d(`maxToolCalls`),(0,y.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:v.maxToolCalls,disabled:q,onChange:e=>Z(`maxToolCalls`,e.target.value)})]})]}),(0,y.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,y.jsx)(`input`,{type:`checkbox`,checked:v.enabledAsSubagent,disabled:q,onChange:e=>Z(`enabledAsSubagent`,e.target.checked)}),d(`enabledAsSubagent`)]}),R?(0,y.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:R}):null]})}),(0,y.jsxs)(`div`,{className:`quickforge-settings-divider flex justify-end gap-2 px-5 py-4`,children:[(0,y.jsx)(u,{variant:`outline`,onClick:$,disabled:A||P,children:d(`cancel`)}),(0,y.jsx)(u,{onClick:je,disabled:A||P||J||!G?.builtin&&!D(v)||v.modelMode===`fixed`&&!v.fixedModelValue,children:d(`save`)})]})]})]}):(0,y.jsxs)(`div`,{className:`quickforge-settings-stack`,children:[(0,y.jsxs)(`section`,{className:`quickforge-settings-section`,"aria-label":d(`agentsTab`),children:[(0,y.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,y.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,y.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,y.jsx)(ee,{className:`size-4 text-primary`}),d(`agentsTab`)]}),(0,y.jsx)(`div`,{className:`quickforge-settings-row-description`,children:d(`agentsDescription`)})]}),(0,y.jsx)(`button`,{className:`quickforge-settings-button quickforge-settings-button-primary`,type:`button`,onClick:ke,children:d(`createAgent`)})]}),R?(0,y.jsx)(`div`,{className:`quickforge-settings-alert quickforge-settings-warning-attached`,children:R}):null,e.length===0?(0,y.jsx)(`div`,{className:`quickforge-settings-empty-row`,children:d(`loading`)}):e.map(e=>(0,y.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,y.jsx)(`div`,{className:`quickforge-settings-list-item-main quickforge-agent-profile-row-main`,children:(0,y.jsxs)(`div`,{className:`quickforge-agent-profile-summary`,children:[(0,y.jsx)(`span`,{className:`quickforge-agent-profile-label`,title:e.label,children:e.label}),e.description?(0,y.jsx)(`span`,{className:`quickforge-agent-profile-description`,title:e.description,children:e.description}):null]})}),(0,y.jsxs)(`div`,{className:`quickforge-settings-list-item-actions`,onClick:e=>e.stopPropagation(),children:[(0,y.jsxs)(`label`,{className:`quickforge-settings-switch`,"aria-disabled":e.builtin||e.readonly?`true`:`false`,title:e.enabledAsSubagent?d(`disableAsSubagent`):d(`enableAsSubagent`),children:[(0,y.jsx)(`input`,{type:`checkbox`,checked:e.enabledAsSubagent,disabled:e.builtin||e.readonly,onChange:()=>void Me(e)}),(0,y.jsx)(`span`,{"aria-hidden":`true`})]}),(0,y.jsx)(`button`,{className:`quickforge-settings-icon-action`,type:`button`,onClick:t=>Ee(t,e.id),title:d(`moreActions`),"aria-label":d(`moreActions`),"aria-haspopup":`menu`,"aria-expanded":B===e.id,children:(0,y.jsx)(a,{className:`size-4`})})]})]},e.id))]}),K&&H?(0,me.createPortal)((0,y.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,y.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,y.jsx)(o,{className:`size-3.5`}),d(`editTask`)]}),(0,y.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),Ne(K)},children:[(0,y.jsx)(s,{className:`size-3.5`}),d(`delete`)]})]}),document.body):null]})}export{k as AgentProfilesPage};
@@ -0,0 +1,11 @@
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Jt as t}from"./icons-DM_qJ7VJ.js";import{n}from"./react-vendor-BpWW_Nvp.js";import{g as r,h as i}from"./pi-web-ui-BNuvqKDT.js";import{t as a}from"./logger-8REuLPGK.js";import{i as o}from"./model-display-label-CURwH0xM.js";import{A as s,H as c,Jt as l,Nt as u,Pt as d,Un as f,Zt as p,jt as m,n as h,o as g,qt as _,t as v}from"./index-CgVTwN15.js";import{C as y,D as b,E as x,O as S,S as C,T as ee,_ as te,a as ne,b as re,c as ie,d as w,f as T,g as ae,i as oe,l as E,n as se,o as ce,r as le,s as ue,t as de,u as fe,v as pe,w as me,x as he,y as ge}from"./local-tools-CJVNO1aW.js";var D=e(t(),1);function _e({panel:e,onReachTop:t,onAutoScrollEnabled:n}){let r=!0,i,a=0,o,s=-1/0,c=-1/0,l,u=0,d=()=>e.querySelector(`agent-interface .overflow-y-auto`),f=e=>e.scrollHeight-e.scrollTop-e.clientHeight<=80,p=t=>{e.querySelector(`agent-interface`)?.setAutoScroll?.(t)},m=()=>{let e=Math.max(s,c);return window.performance.now()-e<=500},h=()=>{i!==void 0&&(window.cancelAnimationFrame(i),i=void 0),r=!1,p(!1)},g=()=>{s=window.performance.now(),h()},_=()=>{c=window.performance.now()},v=()=>{let e=d();if(!e||!r)return;let t=e.scrollHeight-e.clientHeight;if(Math.abs(e.scrollTop-t)<=1){a=e.scrollTop;return}e.scrollTop=e.scrollHeight,a=e.scrollTop},y=()=>{i===void 0&&(i=window.requestAnimationFrame(()=>{i=void 0,v(),window.requestAnimationFrame(v)}))},b=()=>{r=!0,p(!0),n?.(),y()},x=()=>{let e=d();if(!e)return;let n=e.scrollTop,i=n<a-1;if(u>0){a=n;return}n<=0&&a>0&&t?.();let o=i&&m();if(i&&r&&!o&&!f(e)){a=n,y();return}o?h():f(e)&&(r=!0,p(!0)),a=n},S=e=>{e.deltaY<0&&g()},C=e=>{e.target===e.currentTarget&&_()},ee=e=>{(e.key===`ArrowUp`||e.key===`PageUp`||e.key===`Home`)&&g()},te=e=>{o=e.touches[0]?.clientY},ne=e=>{let t=e.touches[0]?.clientY;t===void 0||o===void 0||(t>o+1&&g(),o=t)};return{get isEnabled(){return r},beginProgrammaticScroll:()=>(u+=1,h(),()=>{u=Math.max(0,u-1);let e=d();e&&(a=e.scrollTop)}),enable:b,disable:h,scheduleScrollToBottom:y,setup:()=>{let t=d();if(!t||l)return;a=t.scrollTop,t.addEventListener(`scroll`,x,{passive:!0}),t.addEventListener(`wheel`,S,{passive:!0}),t.addEventListener(`pointerdown`,C,{passive:!0}),t.addEventListener(`keydown`,ee),t.addEventListener(`touchstart`,te,{passive:!0}),t.addEventListener(`touchmove`,ne,{passive:!0}),l=new ResizeObserver(()=>{r&&y()}),l.observe(t);let n=t.querySelector(`.max-w-3xl`);n&&l.observe(n);let i=e.querySelector(`.quickforge-composer-dock`);i&&l.observe(i),b()},cleanup:()=>{let e=d();e?.removeEventListener(`scroll`,x),e?.removeEventListener(`wheel`,S),e?.removeEventListener(`pointerdown`,C),e?.removeEventListener(`keydown`,ee),e?.removeEventListener(`touchstart`,te),e?.removeEventListener(`touchmove`,ne),l?.disconnect(),l=void 0,i!==void 0&&(window.cancelAnimationFrame(i),i=void 0)}}}function O(e){return e.role===`user`||e.role===`user-with-attachments`}function ve(e){let t=[];for(let n=0;n<e.length;n++)O(e[n])&&t.push(n);return t}function k(e,t){if(typeof e==`string`)return Math.min(e.length,t);if(!Array.isArray(e))return 0;let n=0;for(let r of e){if(n>=t)break;if(typeof r==`string`){n+=Math.min(r.length,t-n);continue}if(!r||typeof r!=`object`)continue;let e=r;for(let r of[`text`,`content`,`arguments`]){let i=e[r];if(typeof i==`string`&&(n+=Math.min(i.length,t-n),n>=t))break}}return n}function ye(e,t){let n=0;for(let r of e)if(n+=k(r.content,t-n),n>=t)return!0;return!1}function A(e,t){if(e.role!==`assistant`)return;let n=Array.isArray(e.content)?e.content:[];for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;n.type!==`toolCall`||!n.id||t.add(n.id)}}function be(e,t,n){let r=e.slice(t,n),i=new Set;for(let r=t;r<n;r++)A(e[r],i);if(i.size===0)return r;let a=[];for(let r=0;r<e.length;r++){if(r>=t&&r<n)continue;let o=e[r];o.role===`toolResult`&&typeof o.toolCallId==`string`&&i.has(o.toolCallId)&&a.push(o)}return a.length>0?[...r,...a]:r}function xe(e={}){let t=e.enabled??!0,n=e.enableTurns??6,r=e.enableMessages??48,i=e.enableContentChars??8e4,a=e.windowTurns??3,o=e.pageTurns??3,s=[],c=[],l=a,u=0,d=0,f=[],p=!1,m=!1,h=e=>Math.max(0,e-l),g=()=>{let e=u===0?0:c[u],t=Math.min(c.length,u+l),n=t<c.length?c[t]:s.length;d=e,f=be(s,e,n)};return{setFullMessages(e){s=e,c=ve(e);let o=c.length;return l=Math.min(a,Math.max(1,o-1)),m=t&&o>1&&(o>n||e.length>r||ye(e,i)),m?(u=p?Math.max(0,Math.min(u,h(o))):h(o),g(),f):(u=0,d=0,f=e,p=!1,e)},getWindowStart(){return d},getWindowMessages(){return f},isEnabled(){return m},hasMore(){return m&&u>0},loadMore(){return!m||u<=0?null:(p=!0,u=Math.max(0,u-o),g(),f)},showMessageIndex(e){if(!m||c.length===0)return null;let t=Math.max(0,Math.min(e,s.length-1)),n=0;for(let e=0;e<c.length&&!(c[e]>t);e++)n=e;let r=Math.min(c.length,u+l);return n>=u&&n<r?f:(p=!0,u=Math.min(n,h(c.length)),g(),f)},resetToTail(){p=!1},isAssignedWindow(e){return e===f}}}var Se=!1,j=null;function Ce(){return customElements.get(`message-list`)||null}function we(e){if(j=e(),Se)return;let t=()=>{let e=Ce();if(!e)return!1;let t=Object.getOwnPropertyDescriptor(e,`messages`);if(!t||typeof t.set!=`function`)return!1;Se=!0;let n=t.set;return Object.defineProperty(e,`messages`,{...t,set(e){let t=j,r=this.hasAttribute(`data-quickforge-subagent-process`);if(t&&!r){if(t.isAssignedWindow(e)){n.call(this,e);return}n.call(this,t.setFullMessages(e));return}n.call(this,e)}}),!0};t()||customElements.whenDefined(`message-list`).then(()=>{t()})}function Te(e){j===e&&(j=null)}var Ee=e=>T[e];function De({panel:e,getCustomCommands:t,restoreDraftIntoComposer:n,loadSlashCatalog:r}){let i=`idle`,a=null,o=!1,s=!1,c=null,l=E({panel:e}),u=()=>[{name:`init`,description:f(`initCommandDescription`),argumentHint:``},{name:`plan`,description:f(`planCommandDescription`),argumentHint:`[task]`},{name:`review`,description:f(`reviewCommandDescription`),argumentHint:`[scope]`},{name:`commit`,description:f(`commitCommandDescription`),argumentHint:`[message]`},{name:`summary`,description:f(`summaryCommandDescription`),argumentHint:``},{name:`compact`,description:f(`compactCommandDescription`),argumentHint:``},{name:`clear`,description:f(`clearCommandDescription`),argumentHint:``},{name:`help`,description:f(`helpCommandDescription`),argumentHint:``}],d=()=>e.querySelector(`.quickforge-command-suggestions`),p=()=>{let t=e.querySelector(`message-editor`),n=t?.querySelector(`textarea`);return t?.value??n?.value??``},m=()=>{let e=d();return e?Array.from(e.querySelectorAll(`.quickforge-command-suggestion-item`)).filter(e=>e.tagName===`BUTTON`):[]},h=()=>{let e=m().findIndex(e=>e.getAttribute(`aria-selected`)===`true`);return e>=0?e:0},g=(e,t)=>{e.forEach((e,n)=>{n===t?e.setAttribute(`aria-selected`,`true`):e.removeAttribute(`aria-selected`)}),e[t]?.scrollIntoView?.({block:`nearest`})},_=()=>{c&&=(document.removeEventListener(`pointerdown`,c,!0),null);let e=d();e&&(e.__quickforgeDismissHandler=void 0),e?.remove(),o=!1},v=()=>{s=!0,_()},y=t=>{let r=e.querySelector(`message-editor`),i=t.insertText;n({text:i,attachments:r?.attachments?[...r.attachments]:[],contextReferences:r?.contextReferences?[...r.contextReferences]:[],selectedCapabilities:r?.selectedCapabilities?[...r.selectedCapabilities]:[]});let a=r?.querySelector(`textarea`);a?.focus(),a&&(a.selectionStart=i.length,a.selectionEnd=i.length),_(),(t.kind===`skill`||t.kind===`agent`)&&l.engage({kind:t.kind,name:t.name,cmd:`/${t.kind} ${t.name}`})},b=()=>{p().startsWith(`/`)&&ce()},x=()=>{if(!r){i=`error`;return}i=`loading`,r().then(e=>{a=e,i=`ready`,b()}).catch(()=>{i=`error`,b()})},S=e=>`${e.usage.replace(/^\//,``)} ${e.description}`.replace(/\s+/g,` `).toLowerCase(),C=(e,t)=>t?e.filter(e=>S(e).includes(t)):e,ee=()=>[...u(),...t()].map(e=>({kind:`command`,name:e.name,usage:`/${e.name}${e.argumentHint?` ${e.argumentHint}`:``}`,hint:e.argumentHint??``,description:e.description??``,insertText:`/${e.name} `})),te=()=>(a?.skills??[]).map(e=>({kind:`skill`,name:e.name,usage:`/skill ${e.name}`,hint:``,description:e.description??``,insertText:`/skill ${e.name} `})),ne=()=>(a?.agents??[]).map(e=>({kind:`agent`,name:e.name,usage:`/agent ${e.name}`,hint:``,description:e.label&&e.description?`${e.label} · ${e.description}`:e.label??e.description??``,insertText:`/agent ${e.name} `})),re=(e,t,n)=>{let r=document.createElement(`div`);r.className=`quickforge-command-suggestion-group-head`,r.setAttribute(`role`,`presentation`);let i=document.createElement(`span`);i.textContent=t;let a=document.createElement(`span`);a.className=`quickforge-command-suggestion-count`,a.textContent=n,r.append(i,a),e.append(r)},ie=(e,t)=>{for(let n=0;n<2;n++){let n=document.createElement(`div`);n.className=`quickforge-command-suggestion-item quickforge-command-suggestion-item-skeleton`,n.setAttribute(`role`,`presentation`),n.dataset.skeleton=``,n.innerHTML=`
2
+ <span class="quickforge-command-suggestion-icon quickforge-command-suggestion-icon-${t}">${Ee(t)}</span>
3
+ <span class="quickforge-command-suggestion-name">loading</span>
4
+ <span class="quickforge-command-suggestion-description">loading</span>
5
+ `,e.append(n)}},T=(e,t,n)=>{let r=t.kind===`command`?t.hint?t.usage.slice(0,t.usage.length-t.hint.length).trimEnd():t.usage:t.name;if(n&&!n.includes(` `)){let t=r.toLowerCase().indexOf(n);if(t>=0){let i=document.createElement(`b`);i.textContent=r.slice(t,t+n.length),e.append(document.createTextNode(r.slice(0,t)),i,document.createTextNode(r.slice(t+n.length)))}else e.textContent=r}else e.textContent=r;if(t.hint){let n=document.createElement(`span`);n.className=`quickforge-command-suggestion-hint`,n.textContent=` ${t.hint}`,e.append(n)}},ae=(e,t,n)=>{let r=document.createElement(`button`);r.type=`button`,r.className=`quickforge-command-suggestion-item`,r.dataset.quickforgeCommandName=t.name,r.dataset.quickforgeInsert=t.insertText,r.setAttribute(`role`,`option`),r.__quickforgeSlashEntry=t,r.innerHTML=`
6
+ <span class="quickforge-command-suggestion-icon quickforge-command-suggestion-icon-${t.kind}">${Ee(t.kind)}</span>
7
+ <span class="quickforge-command-suggestion-name"></span>
8
+ <span class="quickforge-command-suggestion-description"></span>
9
+ `,T(r.querySelector(`.quickforge-command-suggestion-name`),t,n),r.querySelector(`.quickforge-command-suggestion-description`).textContent=t.description,r.onpointerdown=e=>{e.preventDefault(),e.stopPropagation(),y(t)},e.append(r)},oe=e=>{let t=document.createElement(`div`);t.className=`quickforge-command-suggestions-foot`,t.setAttribute(`role`,`presentation`);let n=[{keys:[`↑`,`↓`],label:f(`slashHintNavigate`)},{keys:[`Tab`],label:f(`slashHintComplete`)},{keys:[`Enter`],label:f(`slashHintSend`)},{keys:[`Esc`],label:f(`slashHintClose`)}];for(let{keys:e,label:r}of n){let n=document.createElement(`span`);for(let t of e){let e=document.createElement(`kbd`);e.textContent=t,n.append(e)}n.append(document.createTextNode(r)),t.append(n)}e.append(t)},se=e=>e.kind===`skill`?(a?.skills??[]).some(t=>t.name.toLowerCase()===e.name.toLowerCase()):(a?.agents??[]).some(t=>t.name===e.name),ce=t=>{let n=e.querySelector(`message-editor`),r=n?.querySelector(`textarea`);t!==void 0&&(s=!1);let u=t??p(),h=d();if(l.update(u),!l.isActive()&&i===`ready`&&a&&(a.skills.length>0||a.agents.length>0)){let e=fe(u);e&&!l.isDismissed(e.cmd)&&se(e)&&l.engage(e)}if(l.isActive()){_();return}if(!n||!r||!u.startsWith(`/`)){_();return}if(s){_();return}!o&&i===`error`&&(i=`idle`),o=!0,i===`idle`&&x();let y=u.slice(1).trim().toLowerCase(),b=i===`loading`,S=[{key:`command`,label:f(`slashGroupCommands`),entries:C(ee(),y)},{key:`skill`,label:f(`slashGroupSkills`),entries:C(te(),y)},{key:`agent`,label:f(`slashGroupAgents`),entries:C(ne(),y)}];if(S.every(e=>e.entries.length===0&&!(b&&e.key!==`command`))){_();return}let w=h??document.createElement(`div`);w.className=`quickforge-command-suggestions`,w.setAttribute(`role`,`listbox`),b?w.setAttribute(`aria-busy`,`true`):w.removeAttribute(`aria-busy`),w.innerHTML=``;for(let e of S){if(e.key!==`command`&&b){re(w,e.label,`…`),ie(w,e.key);continue}if(e.entries.length!==0){re(w,e.label,String(e.entries.length));for(let t of e.entries)ae(w,t,y)}}oe(w),h||n.parentElement?.insertBefore(w,n),g(m(),0),c||(c=e=>{d()?.contains(e.target)||v()},w.__quickforgeDismissHandler=c,document.addEventListener(`pointerdown`,c,!0))};return{update:ce,remove:v,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}let r=!!d(),i=e?.value??n.value??``;if(t.key===`Escape`){r&&v(),l.isActive()&&l.clear();return}if((t.key===`ArrowDown`||t.key===`ArrowUp`)&&r&&i.startsWith(`/`)){t.preventDefault();let e=m();if(e.length===0)return;let n=t.key===`ArrowDown`?1:-1;g(e,(h()+n+e.length)%e.length);return}if(t.key===`Backspace`){let e=l.getInvocation();if(!e||!w(i,e.cmd))return;let r=n.selectionStart;if(r!==e.cmd.length||n.selectionEnd!==r)return;t.preventDefault(),t.stopPropagation(),l.removePrefix();return}if(t.key!==`Tab`||!i.startsWith(`/`)||t.shiftKey||!r)return;let a=m()[h()]?.__quickforgeSlashEntry;a&&(t.preventDefault(),t.stopPropagation(),y(a))},n.addEventListener(`keydown`,n.__quickforgeCommandCompleteHandler,!0)},cleanupTextareaHandler:()=>{_();let t=e.querySelector(`message-editor textarea`);t?.__quickforgeCommandCompleteHandler&&t.removeEventListener(`keydown`,t.__quickforgeCommandCompleteHandler,!0)}}}var M=new Map;async function N(e){let t=await fetch(e,{cache:`no-store`});if(!t.ok)throw Error(`Request failed: ${t.status}`);return t.json()}function P(e){if(!e||typeof e!=`object`)return null;let t=e.skills;if(!Array.isArray(t))return null;let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e;typeof t.name!=`string`||!t.name||n.push({name:t.name,description:typeof t.description==`string`?t.description:void 0})}return n}function Oe(e){if(!e||typeof e!=`object`)return null;let t=e.agents;if(!Array.isArray(t))return null;let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e;t.enabledAsSubagent===!0&&(typeof t.name!=`string`||!t.name||n.push({name:t.name,label:typeof t.label==`string`?t.label:void 0,description:typeof t.description==`string`?t.description:void 0}))}return n}async function ke(e){let t=e??``,n=M.get(t);if(n)return n;try{let n=e?`/api/skills?available=true&projectId=${encodeURIComponent(e)}`:`/api/skills?available=true`,r=e?`/api/agent-profiles?projectId=${encodeURIComponent(e)}`:`/api/agent-profiles`,[i,a]=await Promise.all([N(n),N(r)]),o=P(i),s=Oe(a);if(!o||!s)return null;let c={skills:o,agents:s};return M.set(t,c),c}catch{return null}}function Ae(e){return e>=5}function je(e){return e.role===`user`||e.role===`user-with-attachments`}function Me(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`text`&&`text`in e&&typeof e.text==`string`).map(e=>e.text).join(`
10
+
11
+ `).trim():``}function Ne(e){return je(e)?(typeof e.content==`string`?e.content:Me(e.content)).trim():``}function Pe(e){return e.role===`assistant`?Me(e.content):``}function F(e,t){let n=[];for(let t=0;t<e.length;t++){let r=e[t];if(!je(r))continue;let i=``;for(let n=t+1;n<e.length;n++){let t=e[n];if(je(t))break;t.role===`assistant`&&(i=Pe(t))}n.push({messageIndex:t,userText:Ne(r),finalAnswerText:i,isGenerating:!1})}return t&&n.length>0&&(n[n.length-1].isGenerating=!0),n}var I=je;function Fe(e,t){return e.trim().replace(/\s+/g,` `)||t}function Ie({host:e,panel:t,getMessages:n,isStreaming:r,windowLayer:i,beginProgrammaticScroll:a,onWindowChanged:o}){let s=document.createElement(`nav`);s.className=`quickforge-turn-navigation`,s.setAttribute(`aria-label`,f(`turnNavigationLabel`)),s.hidden=!0;let c=document.createElement(`div`);c.className=`quickforge-turn-navigation-track`,s.append(c),e.append(s);let l=[],u=``,d=-1,p=null,m=null,h,g,_=null,v=0,y=null,b=null,x=()=>{h!==void 0&&(window.clearTimeout(h),h=void 0)},S=()=>{g!==void 0&&(window.clearTimeout(g),g=void 0)},C=()=>{x(),S(),p?.remove(),p=null,m?.removeAttribute(`aria-describedby`),m=null},ee=()=>{if(!p||!m)return;let e=m.getBoundingClientRect(),t=p.getBoundingClientRect(),n=e.right+10;n+t.width>window.innerWidth-12&&(n=e.left-t.width-10);let r=Math.min(Math.max(12,e.top+e.height/2-t.height/2),Math.max(12,window.innerHeight-t.height-12));p.style.left=`${Math.max(12,n)}px`,p.style.top=`${r}px`},te=(e,t)=>{x(),S(),C();let n=l[t];if(!n)return;let r=document.createElement(`div`),i=`quickforge-turn-navigation-tooltip-${t}`;r.id=i,r.className=`quickforge-turn-navigation-tooltip`,r.setAttribute(`role`,`tooltip`);let a=document.createElement(`div`);a.className=`quickforge-turn-navigation-tooltip-text quickforge-turn-navigation-tooltip-user`,a.textContent=Fe(n.userText,f(`turnNavigationAttachmentOnly`)),r.append(a);let o=n.isGenerating?f(`turnNavigationGenerating`):n.finalAnswerText.trim();if(o){let e=document.createElement(`div`);e.className=`quickforge-turn-navigation-tooltip-text quickforge-turn-navigation-tooltip-answer`,e.textContent=o,r.append(e)}r.addEventListener(`pointerenter`,S),r.addEventListener(`pointerleave`,()=>{g=window.setTimeout(C,100)}),document.body.append(r),p=r,m=e,e.setAttribute(`aria-describedby`,i),ee()},ne=(e,t)=>{x(),S(),h=window.setTimeout(()=>te(e,t),150)},re=e=>{e!==d&&(d=e,c.querySelectorAll(`.quickforge-turn-navigation-node`).forEach((t,n)=>{let r=n===e,i=Math.abs(n-e);t.classList.toggle(`is-active`,r),t.classList.toggle(`is-nearby`,i===1),t.classList.toggle(`is-nearby-secondary`,i===2),r?t.setAttribute(`aria-current`,`true`):t.removeAttribute(`aria-current`)}))},ie=()=>{let e=_,r=t.querySelector(`message-list`);if(!e||!r||l.length===0)return;let a=n(),o=(i.isEnabled()?i.getWindowMessages():a).map(e=>I(e)?a.indexOf(e):-1).filter(e=>e>=0).map(e=>l.findIndex(t=>t.messageIndex===e)).filter(e=>e>=0),s=Array.from(r.querySelectorAll(`user-message`)).filter(e=>e.closest(`message-list`)===r);if(s.length===0||o.length===0)return;let c=e.getBoundingClientRect().top+Math.min(120,e.clientHeight*.2),u=0;for(let e=0;e<s.length&&s[e].getBoundingClientRect().top<=c;e++)u=e;re(o[Math.min(u,o.length-1)])},w=()=>{let e=t.querySelector(`agent-interface .overflow-y-auto`);e!==_&&(_?.removeEventListener(`scroll`,ie),_=e,_?.addEventListener(`scroll`,ie,{passive:!0}))},T=e=>{let r=l[e],s=t.querySelector(`message-list`),c=t.querySelector(`agent-interface .overflow-y-auto`);if(!r||!s||!c)return;C();let u=++v;b?.(),b=null,y?.(),y=a();let d=()=>{if(u!==v)return;b?.(),b=null;let e=y;y=null,window.requestAnimationFrame(()=>e?.())},f=()=>{let e=!1,t=()=>{e||(e=!0,c.removeEventListener(`scrollend`,t),window.clearTimeout(n),d())};c.addEventListener(`scrollend`,t,{once:!0});let n=window.setTimeout(t,900);b=()=>{e=!0,c.removeEventListener(`scrollend`,t),window.clearTimeout(n)}},p=i.showMessageIndex(r.messageIndex);p&&s.messages!==p&&(s.messages=p);let m=()=>{window.requestAnimationFrame(()=>{if(u!==v)return;let t=n(),a=i.isEnabled()?i.getWindowMessages():t,l=a.findIndex(e=>e===t[r.messageIndex]);if(l<0){d();return}let p=a.slice(0,l+1).filter(I).length-1,m=Array.from(s.querySelectorAll(`user-message`)).filter(e=>e.closest(`message-list`)===s)[p];if(!m){d();return}let h=c.scrollTop+m.getBoundingClientRect().top-c.getBoundingClientRect().top-24,g=Math.max(0,h);Math.abs(c.scrollTop-g)<=1?(c.scrollTop=g,d()):(f(),c.scrollTo({top:g,behavior:`smooth`})),re(e),o()})};(s.updateComplete??Promise.resolve()).then(m,m)},ae=()=>{if(c.replaceChildren(),!Ae(l.length)){s.hidden=!0;return}s.hidden=!1,l.forEach((e,t)=>{let n=document.createElement(`button`);n.type=`button`,n.className=`quickforge-turn-navigation-node`,n.setAttribute(`aria-label`,f(`turnNavigationJumpLabel`,{index:t+1,preview:Fe(e.userText,f(`turnNavigationAttachmentOnly`))})),n.addEventListener(`pointerenter`,()=>ne(n,t)),n.addEventListener(`pointerleave`,()=>{x(),g=window.setTimeout(C,100)}),n.addEventListener(`focus`,()=>ne(n,t)),n.addEventListener(`blur`,()=>{g=window.setTimeout(C,100)}),n.addEventListener(`click`,()=>T(t)),c.append(n)}),d=-1},oe=()=>{l=F(n(),r());let e=l.map(e=>`${e.messageIndex}:${e.userText}`).join(`|`);e!==u&&(u=e,ae()),w(),ie()},E=e=>{e.key===`Escape`&&C()},se=()=>C();return document.addEventListener(`keydown`,E),window.addEventListener(`resize`,se),{update:oe,cleanup(){v+=1,b?.(),b=null,y?.(),y=null,C(),_?.removeEventListener(`scroll`,ie),document.removeEventListener(`keydown`,E),window.removeEventListener(`resize`,se),s.remove()}}}function L(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function R(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n:void 0}function Le(e,t){let n=e[t];return typeof n==`boolean`?n:void 0}function z(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function Re(e){let t=e&&L(e.diff)?e.diff:void 0;return{addedLines:t?z(t,`addedLines`):void 0,removedLines:t?z(t,`removedLines`):void 0}}function B(e=``){let t=e.toLowerCase(),n=t.replace(/\\/g,`/`).split(`/`).pop()||t;return t.endsWith(`.html`)||t.endsWith(`.htm`)?`html`:/\.(svg|png|jpe?g|webp|gif|ico)$/i.test(t)?`image`:/\.(md|mdx|markdown)$/i.test(t)?`markdown`:n===`dockerfile`||n.endsWith(`.dockerfile`)||n===`makefile`||/\.(ts|tsx|js|jsx|mjs|cjs|css|scss|less|json|jsonc|txt|csv|tsv|log|sql|xml|yml|yaml|toml|ini|py|rb|go|rs|java|swift|kt|kts|c|h|cpp|hpp|cs|php|sh|bash|zsh|ps1)$/i.test(t)?`code`:`unknown`}function V(e){return e===`html`||e===`image`||e===`markdown`||e===`code`}function ze(e){return[e.source,e.path??``,e.command??``,e.outputFile??``,e.toolCallId??``,e.preview?`preview`:``].join(`\0`)}function H(e,t,n){let r=ze(n);t.has(r)||(t.add(r),e.push({id:`${e.length}:${r}`,...n}))}function U(e){if(!(typeof e!=`string`||!e.trim()))try{return JSON.parse(e)}catch{return}}function Be(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(!L(e)||e.type!==`text`)continue;let t=U(e.text);if(L(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(!L(e)||e.type!==`text`)continue;let t=U(e.text);if(L(t)&&(Array.isArray(t.files)||Array.isArray(t.previewed)))return t}return t}function Ve(e){if(typeof e==`string`&&e.trim())return{path:e};if(L(e)){let t=R(e,`path`);return t?{path:t,title:R(e,`title`),description:R(e,`description`),kind:R(e,`kind`),preview:Le(e,`preview`)}:void 0}}function W(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=L(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?R(i,`path`):void 0;if(r){let o=B(r),{addedLines:s,removedLines:c}=Re(i);H(n,t,{source:e,confidence:`high`,path:r,toolCallId:a,kind:o,preview:V(o),presentation:`inferred`,addedLines:s,removedLines:c})}}else if(e===`present_files`){let e=Be(r,i),o=L(e)&&Array.isArray(e.files)?e.files:[],s=L(e)?R(e,`defaultPreview`):void 0,c=new Set(L(e)&&Array.isArray(e.previewed)?e.previewed.filter(e=>typeof e==`string`):[]);for(let e of o){let r=Ve(e);if(!r?.path)continue;let i=r.kind??B(r.path);H(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||V(i)),defaultPreview:s===r.path,presentation:`explicit`})}}else if(e===`run_command`&&i){let e=R(i,`command`),r=R(i,`outputFile`);(e||r)&&H(n,t,{source:`run_command`,confidence:`low`,command:e,outputFile:r,toolCallId:a})}}}return n}function He(e){return e?.length?W(e):[]}var G=`quickforge:composer-drafts:v1`,Ue=100,K={},We=!1;function Ge(e){return!!(e&&!e.startsWith(`pending-`))}function Ke(e){return Ge(e.sessionId)?`session:${e.sessionId}`:e.scope===`project`&&e.projectId?`new:project:${e.projectId}`:`new:global`}function qe(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(!n||typeof n!=`object`||Array.isArray(n))continue;let e=n;if(e.description!==void 0&&typeof e.description!=`string`||e.mention!==void 0&&typeof e.mention!=`string`)continue;let r=m([e])[0];r&&t.push({...r,...typeof e.mention==`string`?{mention:e.mention}:{}})}let n=new Map;for(let e of t){let t=u(e);if(!n.has(t)&&(n.set(t,e),n.size>=4))break}return n.size>0?[...n.values()]:void 0}function Je(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;if(typeof e.text!=`string`)continue;let i=qe(e.selectedCapabilities);t[n]={text:e.text,contextReferences:Array.isArray(e.contextReferences)?e.contextReferences.filter(e=>!!(e&&typeof e==`object`&&!Array.isArray(e)&&e.type===`file`&&typeof e.projectId==`string`&&typeof e.path==`string`)).slice(0,8):void 0,...i?{selectedCapabilities:i}:{},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 Ye(){try{return globalThis.localStorage}catch{return}}function Xe(e,t=Ue){return Object.fromEntries(Object.entries(e).filter(([,e])=>e.text.length>0||(e.contextReferences?.length??0)>0||(e.selectedCapabilities?.length??0)>0).sort(([,e],[,t])=>t.updatedAt.localeCompare(e.updatedAt)).slice(0,t))}function q(){let e=Ye();if(!e||We)return K;let t;try{t=e.getItem(G)}catch{return We=!0,K}try{return Je(t?JSON.parse(t):void 0)}catch{return K}}function Ze(e){let t=Xe(e);K=t;let n=Ye();if(!(!n||We))try{Object.keys(t).length===0?n.removeItem(G):n.setItem(G,JSON.stringify(t))}catch{let e=Xe(t,Math.ceil(Ue/2));K=e;try{Object.keys(e).length===0?n.removeItem(G):n.setItem(G,JSON.stringify(e))}catch{We=!0}}}async function Qe(e){let t=q()[e];if(!t||t.text.length===0&&(t.contextReferences?.length??0)===0&&(t.selectedCapabilities?.length??0)===0)return;let n={text:t.text,attachments:[]};return t.contextReferences?.length&&(n.contextReferences=[...t.contextReferences]),t.selectedCapabilities?.length&&(n.selectedCapabilities=[...t.selectedCapabilities]),n}async function $e(e,t,n){let r=t.text??``,i=t.contextReferences?[...t.contextReferences].slice(0,8):[],a=m(t.selectedCapabilities);if(r.length===0&&i.length===0&&a.length===0){await et(e);return}let o=q();o[e]={text:r,contextReferences:i,...a.length>0?{selectedCapabilities:a}:{},updatedAt:new Date().toISOString(),scope:n.scope,projectId:n.scope===`project`?n.projectId:void 0,sessionId:Ge(n.sessionId)?n.sessionId:void 0},Ze(o)}async function et(e){let t=q();Object.prototype.hasOwnProperty.call(t,e)&&(delete t[e],Ze(t))}function tt(e,t,n=200){for(e.delete(t),e.add(t);e.size>n;){let t=e.values().next().value;if(t===void 0)break;e.delete(t)}}function nt(){let e=0;return{version:()=>e,isCurrent:t=>t===e,invalidate:()=>(e+=1,e)}}var rt=n();function it(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 at(e){let t=String(e.length);for(let n of e)n.role===`toolResult`&&(t+=`|${n.toolCallId??``}:${n.toolName??``}`);return t}function J({agent:e,onModelSelect:t,revision:n,agentAccessMode:u,workspaceToolsEnabled:m,project:w,projectId:T,chatScope:E=`global`,onAccessModeChange:fe,onRollbackFromMessage:O,onRetryFromMessage:ve,onCopyAnswer:k,onForkFromMessage:ye,onApproveToolCall:A,onRejectToolCall:be,onAnswerAsk:Se,onApproveAutoCompact:j,onRejectAutoCompact:Ce,onOpenWorkspaceGitChanges:Ee,onOpenLocalFilePath:M,onArtifactsChange:N,onContextUsageDisplayChange:P,onInitialRenderReady:Oe,onInitialRenderError:Ae,restoredDraft:je,onRestoredDraftConsumed:Me,disableFork:Ne=!1,readOnly:Pe=!1,approvalReadOnly:F=!1,approvalReadOnlyMessage:I,bypassClientApiKeyCheck:Fe=!1,allowModelControls:L=!0,newChatEmptyState:R=!1,showTurnNavigation:Le=!0,rollbackConfirmTitle:z,rollbackConfirmDescription:Re,capabilities:B=v}){let V=(0,D.useRef)(null),ze=(0,D.useRef)(void 0),H=(0,D.useRef)(void 0),U=(0,D.useRef)(new Map),Be=(0,D.useRef)([]),Ve=(0,D.useRef)(void 0),W=(0,D.useRef)(new Set),G=(0,D.useRef)(void 0),Ue=(0,D.useRef)(null),K=(0,D.useRef)(!1),We=(0,D.useRef)(new WeakSet),Ge=(0,D.useRef)(``),qe=(0,D.useRef)(``),Je=(0,D.useRef)(nt()),[Ye,Xe]=(0,D.useState)(),[q,Ze]=(0,D.useState)(!1),J=(0,D.useMemo)(()=>h(B,{readOnly:Pe,disableFork:Ne}),[B,Pe,Ne]),ot=(0,D.useCallback)(()=>Ze(e=>!e),[]),st=(0,D.useCallback)(()=>Ze(!1),[]);(0,D.useEffect)(()=>{let t=e,n=J.planMode&&q;t?.setPlanMode?.(n,n?st:void 0),!J.planMode&&q&&queueMicrotask(st)},[e,q,st,J.planMode]);let ct=(0,D.useCallback)(()=>{G.current&&=(window.clearTimeout(G.current),void 0)},[]),Y=(0,D.useCallback)(()=>{Ue.current?.cancel(),Ue.current=null,K.current=!1},[]),lt=(0,D.useCallback)(e=>{tt(W.current,e),Me?.(e)},[Me]),ut=(0,D.useMemo)(()=>({sessionId:e?.sessionId,scope:E,projectId:T}),[e?.sessionId,E,T]),dt=Ke(ut),ft=(0,D.useRef)(ut),pt=(0,D.useRef)(dt);(0,D.useEffect)(()=>{ft.current=ut,pt.current=dt},[ut,dt]),(0,D.useEffect)(()=>()=>{ct(),Y()},[ct,Y]);let mt=(0,D.useCallback)((e,t,n)=>{if(!p({...t,attachments:[]})){et(e).catch(e=>a.error(`Failed to clear composer draft:`,e));return}$e(e,t,n).catch(e=>a.error(`Failed to save composer draft:`,e))},[]),ht=(0,D.useCallback)((e,t,n)=>{G.current&&window.clearTimeout(G.current),G.current=window.setTimeout(()=>{G.current=void 0,mt(e,t,n)},400)},[mt]),gt=(0,D.useCallback)((e,t=pt.current,n=ft.current)=>{let r=ee(e);p(r)?U.current.set(t,r):U.current.delete(t),mt(t,r,n)},[mt]),X=(0,D.useRef)({onCopyAnswer:k,onRollbackFromMessage:O,onRetryFromMessage:ve,onForkFromMessage:ye,onAccessModeChange:fe,onTogglePlanMode:ot,onApproveToolCall:A,onRejectToolCall:be,onAnswerAsk:Se,onApproveAutoCompact:j,onRejectAutoCompact:Ce,onOpenWorkspaceGitChanges:Ee,onOpenLocalFilePath:M,onArtifactsChange:N,onContextUsageDisplayChange:P,onInitialRenderReady:Oe,onInitialRenderError:Ae,onModelSelect:t,agentAccessMode:u,planMode:q,workspaceToolsEnabled:m,disableFork:Ne,readOnly:Pe,approvalReadOnly:F,approvalReadOnlyMessage:I,allowModelControls:L,newChatEmptyState:R,bypassClientApiKeyCheck:Fe,rollbackConfirmTitle:z,rollbackConfirmDescription:Re,capabilities:J,gitBranch:Ye});(0,D.useEffect)(()=>{X.current={onCopyAnswer:k,onRollbackFromMessage:O,onRetryFromMessage:ve,onForkFromMessage:ye,onAccessModeChange:fe,onTogglePlanMode:ot,onApproveToolCall:A,onRejectToolCall:be,onAnswerAsk:Se,onApproveAutoCompact:j,onRejectAutoCompact:Ce,onOpenWorkspaceGitChanges:Ee,onOpenLocalFilePath:M,onArtifactsChange:N,onContextUsageDisplayChange:P,onInitialRenderReady:Oe,onInitialRenderError:Ae,onModelSelect:t,agentAccessMode:u,planMode:q,workspaceToolsEnabled:m,disableFork:Ne,readOnly:Pe,approvalReadOnly:F,approvalReadOnlyMessage:I,allowModelControls:L,newChatEmptyState:R,bypassClientApiKeyCheck:Fe,rollbackConfirmTitle:z,rollbackConfirmDescription:Re,capabilities:J,gitBranch:Ye},H.current=je});let _t=w?.id??T;(0,D.useEffect)(()=>{let e=!1;return queueMicrotask(()=>{if(!e){if(!_t){Xe(void 0);return}s(_t).then(t=>{e||Xe(t.isGitRepository?t.branch:void 0)}).catch(t=>{e||(a.warn(`Failed to load git branch:`,t),Xe(void 0))})}}),()=>{e=!0}},[_t,n]);let vt=(0,D.useRef)(null),yt=(0,D.useRef)(null),Z=(0,D.useRef)(null),bt=(0,D.useRef)(w?.id),Q=(0,D.useRef)(null),$=(0,D.useRef)(null),xt=(0,D.useRef)(null);(0,D.useEffect)(()=>{bt.current=w?.id},[w?.id]),(0,D.useEffect)(()=>{let e=!1;return!J.commands||!w?.id?(Be.current=[],()=>{e=!0}):(fetch(`/api/project/commands?projectId=${encodeURIComponent(w.id)}`,{cache:`no-store`}).then(e=>e.ok?e.json():{commands:[]}).then(t=>{e||(Be.current=Array.isArray(t.commands)?t.commands:[],Z.current?.())}).catch(()=>{e||(Be.current=[],Z.current?.())}),()=>{e=!0})},[w?.id,n,J.commands]);let St=(0,D.useCallback)((e,t,n,r)=>{if(t.sessionId&&t.sessionId!==n||!p(t)||W.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]:[],contextReferences:i.contextReferences?[...i.contextReferences]:[],selectedCapabilities:i.selectedCapabilities?[...i.selectedCapabilities]:[]}:U.current.get(r),o=Ve.current;if(!(o?.id!==t.id||!p(a??l())||a?.text===o.text))return;Je.current.invalidate(),Y();let s=e.querySelector(`agent-interface`);Ue.current=b(e,t,U.current,r,{shouldApply:()=>!W.current.has(t.id)&&e.isConnected&&!!V.current?.contains(e),onApplyStart:()=>{K.current=!0},onApplyEnd:()=>{K.current=!1},onApplied:()=>{We.current.add(e),ze.current=t.id,Ve.current={id:t.id,text:t.text},lt(t.id)},updateComplete:s?.updateComplete})},[Y,lt]);return(0,D.useEffect)(()=>{if(!V.current||!e)return;let t=Je.current,n=We.current,s=new r;Ze(!1);let u=e.sessionId,m=pt.current,h=ft.current,v=!1,ee,E=!1,fe=!1,D=!1,O=e.state.isStreaming,ve=!1,k=0,ye,A=xe({enabled:!1});we(()=>A);let be=!1,Se=()=>{if(v||be||!A.hasMore())return;let e=s.querySelector(`message-list`),t=s.querySelector(`agent-interface .overflow-y-auto`);if(!e||!t)return;let n=Array.from(e.querySelectorAll(`user-message, assistant-message`)).filter(t=>t.closest(`message-list`)===e),r=t.getBoundingClientRect().top,i=-1,a=0;for(let e=0;e<n.length;e++){let t=n[e].getBoundingClientRect();if(t.bottom>r){i=e,a=t.top;break}}let o=t.scrollTop,c=A.loadMore();if(!c)return;be=!0,e.messages=c;let l=()=>{window.requestAnimationFrame(()=>{if(be=!1,!v){if(i>=0){let n=Array.from(e.querySelectorAll(`user-message, assistant-message`))[i];n&&(t.scrollTop=o+(n.getBoundingClientRect().top-a))}Z.current?.()}})};(e.updateComplete??Promise.resolve()).then(l,l)},j=_e({panel:s,onReachTop:()=>{Se()},onAutoScrollEnabled:()=>{A.resetToTail()}});yt.current=j;let Ce=le({panel:s,onJumpSettled:()=>{let e=s.querySelector(`agent-interface .overflow-y-auto`);e&&e.scrollHeight-e.scrollTop-e.clientHeight<=120&&j.enable()}}),Ee=null,M=De({panel:s,getCustomCommands:()=>Be.current,getComposerDrafts:()=>U.current,sessionId:m,setComposerDrafts:e=>{U.current=e},restoreDraftIntoComposer:e=>{x(s,e,U.current,m),ht(m,e,h)},loadSlashCatalog:()=>ke(bt.current)}),N=ce({panel:s,enabled:J.capabilitySuggestions,restoreDraftIntoComposer:e=>{x(s,e,U.current,m),ht(m,e,h)}}),P=ie({panel:s,projectId:w?.id??T,enabled:ue({projectId:w?.id??T,readOnly:Pe,harness:e.harness,shared:`shareId`in e}),restoreDraftIntoComposer:e=>{x(s,e,U.current,m),ht(m,e,h)},removeCommandSuggestions:M.remove,removeCapabilitySuggestions:N.remove,removePlusMenu:()=>S(s)}),Oe=_({panel:s,getSystemPrompt:()=>e.state.systemPrompt,getMessages:()=>e.state.messages,getEffectiveMessages:()=>it(e),getContextWindow:()=>e.state.model?.contextWindow??0,getTools:()=>e.state.tools,getServerContextUsage:()=>e.state.contextUsage??null,getIsCompacted:()=>!!e.state.contextCompaction?.summaryMessage,getGitBranch:()=>X.current.gitBranch,onGitBranchClick:()=>X.current.onOpenWorkspaceGitChanges?.(),renderInline:!1,renderModelRing:d().showContextUsage,onDisplayChange:t=>X.current.onContextUsageDisplayChange?.(e.sessionId,t)}),Ae=te({panel:s,getAcpSession:()=>e.state.acpSession??null}),je=()=>{if(K.current)return;D=!0,t.invalidate(),Y();let e=H.current;e&&(!e.sessionId||e.sessionId===u)&&lt(e.id)},Me=e=>{je(),E=!1;let t=s.querySelector(`message-editor`),n={text:e,attachments:t?.attachments?[...t.attachments]:[],contextReferences:t?.contextReferences?[...t.contextReferences]:[],selectedCapabilities:N.snapshotSelectedCapabilities()};p(n)?(U.current.set(m,n),ht(m,n,h)):(U.current.delete(m),ct(),et(m).catch(e=>a.error(`Failed to clear composer draft:`,e)))},Ne=e=>{je(),E=!1;let t=s.querySelector(`message-editor`),n=t?.querySelector(`textarea`),r=t?.value??n?.value??``,i=t?.contextReferences?[...t.contextReferences]:[],o=N.snapshotSelectedCapabilities(),c={text:r,attachments:e?[...e]:[],contextReferences:i,selectedCapabilities:o};p(c)?(U.current.set(m,c),ht(m,c,h)):(U.current.delete(m),ct(),et(m).catch(e=>a.error(`Failed to clear composer draft:`,e)));let l=s.querySelector(`agent-interface`);l?.requestUpdate?.(),window.requestAnimationFrame(()=>Z.current?.()),l?.updateComplete?.then(()=>Z.current?.())},F=()=>{e.state.isStreaming?s.dataset.quickforgeAgentStreaming=`true`:delete s.dataset.quickforgeAgentStreaming},I=!1,Fe=()=>{if(v||I)return;I=!0;let t=()=>{if(I=!1,v)return;let t=He(e.state.messages),n=JSON.stringify(t.map(e=>[e.source,e.path,e.command,e.outputFile,e.confidence,e.preview,e.defaultPreview,e.addedLines,e.removedLines]));n!==Ge.current&&(Ge.current=n,X.current.onArtifactsChange?.(t))};typeof window.requestIdleCallback==`function`?window.requestIdleCallback(t,{timeout:500}):t()},L=()=>{if(v||!s.isConnected)return;F();let t=()=>A.isEnabled()?A.getWindowMessages():e.state.messages,n=A.isEnabled()?A.getWindowStart():0,r=X.current,i=at(e.state.messages);i!==qe.current&&(qe.current=i,Fe());try{ne({panel:s,getMessages:t,messageIndexOffset:n,isStreaming:()=>e.state.isStreaming,onCopyAnswer:r.onCopyAnswer,onRollbackFromMessage:r.onRollbackFromMessage,onRetryFromMessage:r.onRetryFromMessage,onForkFromMessage:r.onForkFromMessage,onOpenLocalFilePath:r.onOpenLocalFilePath,disableFork:!r.capabilities.forkFromMessage,allowRollback:r.capabilities.rollback,allowRetry:r.capabilities.retry,readOnly:r.readOnly,enableTerminalCommandActions:!r.readOnly,rollbackConfirmTitle:r.rollbackConfirmTitle,rollbackConfirmDescription:r.rollbackConfirmDescription}),ge({panel:s,getMessages:t,getContextCompaction:()=>r.capabilities.compaction?e.state.contextCompaction??null:null,messageIndexOffset:n}),pe({panel:s,isDegraded:()=>e.state.persistDegraded===!0}),oe({panel:s,getMessages:t,isStreaming:()=>e.state.isStreaming,isActive:O})}catch(e){a.warn(`Failed to decorate chat messages:`,e)}try{se({panel:s,isStreaming:()=>e.state.isStreaming,isWaiting:()=>O,abort:()=>e.abort(),agentAccessMode:r.agentAccessMode,harness:e.harness,getAcpSession:()=>e.state.acpSession??null,onOpenCodeConfigOptionChange:(t,n)=>{e.setConfigOption(t,n).catch(e=>{a.error(`Failed to update OpenCode config option:`,e)})},onOpenCodeModeChange:t=>{e.setMode(t).catch(e=>{a.error(`Failed to update OpenCode mode:`,e)})},planMode:r.planMode,workspaceToolsEnabled:r.workspaceToolsEnabled,readOnly:r.readOnly,allowModelControls:r.allowModelControls&&r.capabilities.modelSelection,planModeEnabled:r.capabilities.planMode,accessModeEnabled:r.capabilities.accessMode,commandSuggestionsEnabled:r.capabilities.commands,capabilitySuggestionsEnabled:r.capabilities.capabilitySuggestions,attachmentsEnabled:r.capabilities.attachments,onAccessModeChange:r.onAccessModeChange,onTogglePlanMode:r.onTogglePlanMode,onInput:Me,onFilesChange:Ne,removeCommandSuggestions:M.remove,updateCommandSuggestions:M.update,setupCommandTextareaHandler:M.setupTextareaHandler,removeCapabilitySuggestions:N.remove,updateCapabilitySuggestions:N.update,setupCapabilityTextareaHandler:N.setupTextareaHandler,removeFileReferenceSuggestions:P.remove,updateFileReferenceSuggestions:P.update,setupFileReferenceTextareaHandler:P.setupTextareaHandler,syncContextChips:()=>{N.syncChips(),P.syncChips()},selectPluginCapability:N.selectPlugin,availablePluginRows:N.availablePluginRows,onBeforeSend:()=>{g();let t=r.capabilities.capabilitySuggestions?N.consumeSelectedCapabilities():[],n=s.querySelector(`message-editor`),i=n?.contextReferences?[...n.contextReferences]:[],a=e;a.setNextPromptCapabilities?.(t),a.setNextPromptContextReferences?.(i,()=>{let e=s.querySelector(`message-editor`);e&&(e.contextReferences=(e.contextReferences??[]).filter(e=>!i.some(t=>t.projectId===e.projectId&&t.path===e.path)),e.requestUpdate?.(),P.syncChips())})}})}catch{}let o=Q.current??(()=>{let t=e.state.pendingToolApproval;return t?{...t,sessionId:e.sessionId}:null})();if(o&&o.sessionId===e.sessionId&&typeof o.toolCallId==`string`&&typeof o.toolName==`string`){let t=o.toolCallId;C({panel:s,tone:`warning`,disabled:r.approvalReadOnly,disabledReason:r.approvalReadOnlyMessage,onApprove:async()=>{await X.current.onApproveToolCall(t),Q.current=null,e.state.pendingToolApproval=null,y(s)},onReject:async()=>{await X.current.onRejectToolCall(t),Q.current=null,e.state.pendingToolApproval=null,y(s)}},o.toolName,t,o.args,o.source)}else{let n=$.current??(()=>{let t=e.state.pendingAutoCompactApproval;return t?{...t,sessionId:e.sessionId}:null})();if(n&&n.sessionId===e.sessionId){let i=n.approvalId,a=!r.onApproveAutoCompact||!r.onRejectAutoCompact,o=r.approvalReadOnly||a,c=r.approvalReadOnly?r.approvalReadOnlyMessage:a?f(`autoCompactApprovalUnavailable`):void 0;C({panel:s,tone:`info`,copy:{status:f(`autoCompactApprovalStatus`),title:f(`autoCompactApprovalTitle`),risk:f(`autoCompactApprovalRisk`,{keepRecentTurns:n.keepRecentTurns??3}),approve:f(`autoCompactApprovalAccept`),reject:f(`autoCompactApprovalReject`)},disabled:o,disabledReason:c,getMessages:t,keepRecentTurns:n.keepRecentTurns??3,onApprove:async()=>{let t=X.current.onApproveAutoCompact;if(!t)throw Error(f(`autoCompactApprovalUnavailable`));await t(i),$.current=null,e.state.pendingAutoCompactApproval=null,y(s)},onReject:async()=>{let t=X.current.onRejectAutoCompact;if(!t)throw Error(f(`autoCompactApprovalUnavailable`));await t(i),$.current=null,e.state.pendingAutoCompactApproval=null,y(s)}},f(`contextManagement`),i,{percent:n.usage?.percent??0,threshold:n.thresholdPercent??0,keepRecentTurns:n.keepRecentTurns??3,summary:f(`autoCompactApprovalWaiting`,{percent:n.usage?.percent??0,threshold:n.thresholdPercent??0}),description:f(`autoCompactApprovalPreview`,{keepRecentTurns:n.keepRecentTurns??3})})}else y(s)}let c=xt.current??(()=>{let t=e.state.pendingAsk;return t?{...t,sessionId:e.sessionId}:null})();if(c&&c.sessionId===e.sessionId&&typeof c.askId==`string`&&Array.isArray(c.questions)&&c.questions.length>0){let e=c.askId;re({panel:s,disabled:r.approvalReadOnly||!X.current.onAnswerAsk,disabledReason:r.approvalReadOnly?r.approvalReadOnlyMessage:void 0,onSubmit:async t=>{await X.current.onAnswerAsk?.(e,t,!1),xt.current=null,he(s)},onSkip:async()=>{await X.current.onAnswerAsk?.(e,[],!0),xt.current=null,he(s)}},c)}else he(s);r.capabilities.contextUsage?Oe.update():Oe.cleanup(),e.harness===`opencode`&&Ae.update(),Ee?.update(),j.setup(),Ce.setup(),j.isEnabled&&(A.resetToTail(),j.scheduleScrollToBottom())},R=!1,z,Re=!1,B,Ve=()=>{B===void 0&&(B=window.requestAnimationFrame(()=>{B=void 0,Re=!1}))},W=()=>{if(!v){Re=!0;try{L()}finally{Ve()}}},G=()=>{R||(R=!0,z=window.requestAnimationFrame(()=>{z=void 0,R=!1,W()}))};vt.current=W;let Ke=()=>s.querySelector(`agent-interface`),Ye=()=>{ve||(ve=!0,window.requestAnimationFrame(()=>{if(ve=!1,v)return;F();let e=Ke();e?.requestUpdate?.(),(e?.updateComplete??Promise.resolve()).then(()=>{v||W()}),j.isEnabled&&j.scheduleScrollToBottom()}))};Z.current=G;let Xe=()=>{let e=++k;s.dataset.quickforgeProcessHandoff=String(e);let t=Ke();t?.requestUpdate?.(),Z.current?.(),window.requestAnimationFrame(()=>{!v&&k===e&&Z.current?.()});let n=()=>{v||k!==e||(delete s.dataset.quickforgeProcessHandoff,Z.current?.(),window.requestAnimationFrame(()=>{!v&&k===e&&Z.current?.()}))};(t?.updateComplete??Promise.resolve()).then(n,n)};s.setAgent(e,{onApiKeyRequired:!X.current.capabilities.clientApiKeyCheck||X.current.bypassClientApiKeyCheck?async()=>!0:t=>o(e.state.model)?Promise.resolve(!0):i.prompt(t),onBeforeSend:()=>{t.invalidate(),Y();let e=H.current;e&&(!e.sessionId||e.sessionId===u)&&lt(e.id),ct(),E=!0,M.remove(),U.current.delete(m),et(m).catch(e=>a.error(`Failed to clear composer draft:`,e)),j.enable()},onModelSelect:X.current.onModelSelect,toolsFactory:()=>de(e.state.tools)}).then(()=>{if(v)return;let e=H.current,n=t.version(),r=r=>{if(!(v||!t.isCurrent(n)))if(N.restoreSelectedCapabilities(r?.selectedCapabilities??[]),e&&ze.current!==e.id)St(s,e,u,m);else{let e=r??U.current.get(m)??l();p(e)||(fe=!0),Y();let i=s.querySelector(`agent-interface`);Ue.current=b(s,e,U.current,m,{shouldApply:()=>!v&&t.isCurrent(n)&&s.isConnected&&!!V.current?.contains(s),onApplyStart:()=>{K.current=!0},onApplyEnd:()=>{K.current=!1},onApplied:()=>{fe=!0,We.current.add(s)},updateComplete:i?.updateComplete})}};if(e&&ze.current!==e.id)r();else{let e=U.current.get(m);e?r(e):Qe(m).then(e=>r(e)).catch(e=>a.error(`Failed to load composer draft:`,e))}ee=new MutationObserver(()=>{Re||G()}),ee.observe(s,{childList:!0,subtree:!0}),window.requestAnimationFrame(()=>{v||W()});let i=Ke(),o=()=>{v||(ye=c(()=>{v||X.current.onInitialRenderReady?.(u)}))};(i?.updateComplete??Promise.resolve()).then(o,o)},e=>{v||(a.error(`Failed to initialize chat panel:`,e),X.current.onInitialRenderError?.(u,e))}),V.current.replaceChildren(s),Le&&(Ee=Ie({host:V.current,panel:s,getMessages:()=>e.state.messages,isStreaming:()=>e.state.isStreaming,windowLayer:A,beginProgrammaticScroll:j.beginProgrammaticScroll,onWindowChanged:()=>Z.current?.()}));let q=e.subscribe(t=>{if(t.type===`agent_start`&&(k+=1,delete s.dataset.quickforgeProcessHandoff,O=!0,F(),Z.current?.(),j.enable(),Q.current?.sessionId===e.sessionId&&(Q.current=null),$.current?.sessionId===e.sessionId&&($.current=null)),t.type===`message_start`||t.type===`message_update`||t.type===`message_end`||t.type===`turn_end`||t.type===`agent_end`){F();let e=t.message;t.type===`message_start`&&e?.role===`assistant`&&(k+=1,delete s.dataset.quickforgeProcessHandoff,Ce.notifyNewAssistantMessage()),(t.type===`message_update`||e?.role===`assistant`)&&(O=!1),Z.current?.(),t.type===`message_end`&&e?.role===`assistant`&&Xe(),j.isEnabled&&j.scheduleScrollToBottom()}if(t.type===`messages_replaced`){let e=H.current;e&&ze.current===e.id&&St(s,e,u,m)}let n=t.type;if(n===`tool_execution_start`){let n=t,r=Q.current,i=n.sessionId??e.sessionId;r&&r.sessionId===e.sessionId&&i===e.sessionId&&n.toolCallId===r.toolCallId&&(Q.current=null,e.state.pendingToolApproval?.toolCallId===n.toolCallId&&(e.state.pendingToolApproval=null),Z.current?.())}if((n===`tool_execution_start`||n===`tool_execution_update`||n===`tool_execution_end`)&&Ye(),(n===`acp_session_update`||n===`acp_session_usage_update`)&&Z.current?.(),n===`persist_degraded`&&Z.current?.(),t.type===`agent_end`&&(O=!1,F(),Xe(),Q.current?.sessionId===e.sessionId&&(Q.current=null,Z.current?.()),xt.current?.sessionId===e.sessionId&&(xt.current=null,Z.current?.()),$.current?.sessionId===e.sessionId&&($.current=null,Z.current?.())),(n===`auto_compact_completed`||n===`auto_compact_failed`)&&($.current?.sessionId===e.sessionId&&($.current=null),e.state.pendingAutoCompactApproval=null,Z.current?.()),n===`auto_compact_completed`||n===`messages_replaced`){ae(s);let e=Ke();e?.requestUpdate?.(),Z.current?.(),window.requestAnimationFrame(()=>Z.current?.()),e?.updateComplete?.then(()=>Z.current?.())}if(n===`auto_compact_failed`&&a.warn(f(`autoCompactFailed`)),t.type===`tool_approval_required`){let e=t;Q.current={toolCallId:e.toolCallId,toolName:e.toolName,args:e.args,sessionId:e.sessionId,source:e.source},Z.current?.()}if(t.type===`ask_user_required`){let n=t;typeof n.askId==`string`&&Array.isArray(n.questions)&&(xt.current={...n,sessionId:n.sessionId??e.sessionId},Z.current?.())}if(t.type===`ask_user_answered`){let e=t;(!e.askId||xt.current?.askId===e.askId)&&(xt.current=null,Z.current?.())}if(t.type===`auto_compact_approval_required`){let e=t;$.current={approvalId:e.approvalId,usage:e.usage,thresholdPercent:e.thresholdPercent,keepRecentTurns:e.keepRecentTurns,sessionId:e.sessionId},Z.current?.()}});return()=>{v=!0,t.invalidate(),Y(),ct(),ye?.(),E?(U.current.delete(m),et(m).catch(e=>a.error(`Failed to clear composer draft:`,e))):(fe||D||n.has(s))&&(me(s,U.current,m),gt(s,m,h)),M.remove(),M.cleanupTextareaHandler(),N.remove(),N.cleanupTextareaHandler(),P.remove(),P.cleanupTextareaHandler(),Oe.cleanup(),Ae.cleanup(),Ee?.cleanup(),j.cleanup(),yt.current=null,Ce.cleanup(),Te(A),q(),ee?.disconnect(),z!==void 0&&window.cancelAnimationFrame(z),B!==void 0&&window.cancelAnimationFrame(B),vt.current=null,s.remove()}},[e,w?.id,T,Pe,Le,J.capabilitySuggestions,ct,Y,lt,gt,St,ht]),(0,D.useEffect)(()=>{let e=V.current;e&&(e.classList.toggle(`quickforge-chat-panel-empty-host`,R),e.dataset.quickforgeEmptyChat=R?`true`:`false`)},[R]),(0,D.useEffect)(()=>{vt.current?.(),(V.current?.querySelector(`agent-interface`))?.requestUpdate?.()},[u,q,m,Ye,Ne,Pe,F,I,L,B,n]),(0,D.useEffect)(()=>{let t=H.current;if(!t||!V.current)return;let n=e?.sessionId??``;if(t.sessionId&&t.sessionId!==n||W.current.has(t.id))return;let r=V.current.querySelector(`pi-chat-panel`);r&&St(r,t,n,pt.current)},[je,e,St]),(0,rt.jsx)(`div`,{ref:V,className:`quickforge-chat-panel-host min-h-0 flex-1 overflow-hidden`})}export{J as ChatPanelHost};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{C as t,Jt as n,K as r,St as i,Z as a,a as ee,bt as te,c as ne,m as re,mt as ie,q as ae,v as oe,vt as se,w as o,x as ce}from"./icons-DM_qJ7VJ.js";import{n as s}from"./react-vendor-BpWW_Nvp.js";import{$ as le,Et as c,G as l,Hn as u,J as ue,K as de,Q as fe,Rn as d,U as pe,Un as f,Vn as p,W as me,X as he,Y as ge,Z as _e,at as ve,et as ye,it as be,nt as xe,ot as m,q as Se,rt as Ce,tt as we,zn as Te}from"./index-CgVTwN15.js";var h=e(n(),1);function g(e,t=`cloudRequestFailed`){return e instanceof l?e.code===`cloud_session_active`?f(`cloudSessionActiveGuidance`):e.code===`cloud_disabled`?f(`cloudDisabledError`):e.code===`cloud_local_only`?f(`cloudLocalOnlyError`):e.code===`cloud_configuration_error`||e.code===`cloud_not_configured`?f(`cloudConfigurationError`):e.code===`cloud_session_service_mismatch`?f(`cloudSessionServiceMismatch`):[`expired_token`,`device_code_expired`,`expired`].includes(e.code)?f(`cloudDeviceFlowExpiredError`):[`access_denied`,`authorization_declined`,`denied`].includes(e.code)?f(`cloudDeviceFlowDeniedError`):[`refresh_token_reused`,`installation_revoked`,`invalid_refresh_token`,`cloud_not_connected`].includes(e.code)?f(`cloudSessionExpired`):p()===`en`&&e.message.trim()?e.message:e.status>0?f(`cloudRequestFailedWithStatus`,{status:e.status}):f(t):f(t)}var Ee={usage:void 0,installations:[],models:[],errors:{},loading:!1};function De(e,t){return t.type===`replace`?t.state:{...Ee,loading:t.type===`begin`}}async function Oe(e,t){let[n,r,i]=await Promise.allSettled([e.usage(),e.installations(),e.models()]);return{usage:n.status===`fulfilled`?n.value:void 0,installations:r.status===`fulfilled`?r.value:[],models:i.status===`fulfilled`?i.value:[],errors:{...n.status===`rejected`?{usage:t(`usage`,n.reason)}:{},...r.status===`rejected`?{installations:t(`installations`,r.reason)}:{},...i.status===`rejected`?{models:t(`models`,i.reason)}:{}},loading:!1}}function ke({loading:e,loadError:t,status:n,details:r}){if(e&&!n)return`loading`;if(t)return`load-error`;if(!n?.configured)return`unconfigured`;if(n.sessionServiceMismatch)return`session-mismatch`;if(n.pendingDeviceFlow)return n.hasSession?`connected`:`no-session`;if(!n.hasSession)return`no-session`;let i=Object.values(r.errors);return n.cloudAvailable===!1||i.length===3&&i.every(e=>e?.unavailable)?`cloud-unavailable`:i.length>0?`partial-details`:`connected`}function Ae(e){let t=e?.configured===!0,n=t&&e.hasSession===!0,r=n&&e.sessionServiceMismatch!==!0;return{showDeviceFlow:t&&!!e.pendingDeviceFlow,showDisconnectedActions:t&&!e.pendingDeviceFlow&&!n,showDetails:r}}function je(e){return e===`starting`||e===`authorizing`}function Me(e){if(e?.status!==`authorizing`)return{pending:!1,failed:!1,needsLocalEnable:!1};let t=e.autoApproval;return t?.status===`armed`||t?.status===`pending`||t?.status===`consumed`?{pending:!0,failed:!1,needsLocalEnable:!1}:t?.status===`failed`?{pending:!1,failed:!0,failedError:t.error||void 0,needsLocalEnable:!1}:{pending:!1,failed:!1,needsLocalEnable:!0}}function Ne(e,t){return!!(e?.hasSession&&(t||e.sessionServiceMismatch))}async function Pe(e,t){await t.reset(),t.onIdentityReset?.();try{return{status:`success`,config:await t.save(e)}}catch(e){return{status:`url-save-failed`,error:e}}}var _=s();function v(e){if(!e)return f(`cloudNotAvailable`);let t=new Date(e);return Number.isNaN(t.getTime())?f(`cloudNotAvailable`):t.toLocaleString(u())}function y(e){let t=e.id||e.installationId;return typeof t==`string`?t:``}function b(e){let t=e.name||e.installationName;return typeof t==`string`&&t?t:f(`cloudUnnamedDevice`)}function Fe(e){return typeof e==`number`&&Number.isFinite(e)?e.toLocaleString(u()):f(`cloudNotAvailable`)}function Ie(e){return f(e===`saved`?`cloudConfigSourceSaved`:e===`env`?`cloudConfigSourceEnv`:`cloudConfigSourceDefault`)}function x(e){let t=String(e||``).toLowerCase();return t===`localhost`||t.endsWith(`.localhost`)||t.startsWith(`127.`)?!0:t===`::1`}function S(e){let t=e.trim();if(!t)return``;let n;try{n=new URL(t)}catch{return f(`cloudUrlInvalid`)}return n.protocol!==`https:`&&n.protocol!==`http:`?f(`cloudUrlInvalidProtocol`):x(n.hostname)&&n.port===`8081`?f(`cloudUrlAdminPort`):``}function C(e){if(!e||typeof e!=`object`)return f(`cloudConnectionUnknown`);let t=e;return t.ok===!0||t.status===`ok`||t.ready===!0?f(`cloudConnectionOk`):f(`cloudConnectionError`)}function w(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.ok===!0||t.status===`ok`||t.ready===!0}function Le(e,t){let n=C(t);return(0,_.jsxs)(`span`,{className:Te(`quickforge-settings-badge`,n===f(`cloudConnectionUnknown`)?`quickforge-settings-badge-muted`:w(t)?`quickforge-settings-badge-success`:`quickforge-settings-badge-danger`),children:[e,`: `,n]})}function Re(e){let t=e.quickforgeCapabilities;return[t?.tools?f(`cloudCapabilityTools`):void 0,t?.vision?f(`cloudCapabilityVision`):void 0,t?.reasoning?f(`cloudCapabilityReasoning`):void 0].filter(Boolean).join(` · `)||f(`cloudCapabilityText`)}function ze(e){return f(e?e===`disabled`?`cloudRemoteStatusDisabled`:e===`unavailable`?`cloudRemoteStatusUnavailable`:e===`stopped`?`cloudRemoteStatusStopped`:e===`starting`?`cloudRemoteStatusStarting`:e===`authorizing`?`cloudRemoteStatusAuthorizing`:e===`running`?`cloudRemoteStatusRunning`:e===`conflict`?`cloudRemoteStatusConflict`:`cloudRemoteStatusError`:`cloudRemoteStatusLoading`)}function Be(e,t){let n=e===`usage`?`cloudUsageLoadFailed`:e===`installations`?`cloudDevicesLoadFailed`:`cloudModelsLoadFailed`,r=g(t);return{message:r===f(`cloudRequestFailed`)?f(n):r,unavailable:!(`code`in Object(t))||[`cloud_request_failed`,`cloud_unavailable`].includes(String(t?.code||``))}}function T({error:e,onRetry:t,disabled:n}){return(0,_.jsxs)(`div`,{className:`p-4 text-sm`,children:[(0,_.jsx)(`div`,{className:`quickforge-settings-error`,children:e.message}),(0,_.jsxs)(d,{type:`button`,variant:`outline`,size:`sm`,className:`mt-3`,onClick:t,disabled:n,children:[(0,_.jsx)(o,{className:`mr-2 size-4`}),f(`retry`)]})]})}function E(){let[e,n]=(0,h.useState)(),[s,l]=(0,h.useState)(``),[u,p]=(0,h.useState)(!1),[x,C]=(0,h.useState)(),[w,E]=(0,h.useState)(),[D,Ve]=(0,h.useState)(),[O,k]=(0,h.useReducer)(De,Ee),[A,He]=(0,h.useState)(!0),[j,M]=(0,h.useState)(``),[Ue,N]=(0,h.useState)(``),[P,F]=(0,h.useState)(``),[We,I]=(0,h.useState)(``),[Ge,Ke]=(0,h.useState)(0),L=(0,h.useRef)(0),R=(0,h.useRef)(0),z=w?.pendingDeviceFlow,B=z?Math.max(0,Math.ceil((z.expiresAt-Ge)/1e3)):0,V=(0,h.useCallback)(()=>k({type:`clear`}),[]),H=(0,h.useCallback)(async()=>{let e=++R.current;try{let t=await he();e===R.current&&Ve(t)}catch{}},[]),U=(0,h.useCallback)(async(e=!0,t=!1,r=!0)=>{let i=++L.current;e&&He(!0),F(``),k({type:`begin`}),r&&H();try{let[e,r]=await Promise.all([Se(),_e()]);if(i!==L.current)return;if(n(e),t||l(e.cloudUrl),E(r),!e.enabled||!r.configured||!r.hasSession||r.sessionServiceMismatch){V();return}let a=await Oe({usage:fe,installations:ue,models:ge},Be);if(i!==L.current)return;k({type:`replace`,state:a})}catch(e){if(i!==L.current)return;n(void 0),E(void 0),V(),F(g(e,`cloudLoadFailed`))}finally{i===L.current&&He(!1)}},[V,H]);(0,h.useEffect)(()=>{let e=window.setTimeout(()=>{U()},0);return()=>{window.clearTimeout(e),L.current+=1,R.current+=1}},[U]),(0,h.useEffect)(()=>{if(!e?.enabled||!je(D?.status))return;let t=window.setInterval(()=>{H()},1750);return()=>window.clearInterval(t)},[e?.enabled,H,D?.status]),(0,h.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&H()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[H]),(0,h.useEffect)(()=>{if(!e?.enabled||!w?.pendingDeviceFlow)return;let t=()=>Ke(Date.now()),n=window.setTimeout(t,0),r=window.setInterval(t,1e3);return()=>{window.clearTimeout(n),window.clearInterval(r)}},[e?.enabled,w?.pendingDeviceFlow]),(0,h.useEffect)(()=>{let t=w?.pendingDeviceFlow;if(!e?.enabled||!t||B>0)return;let n=window.setTimeout(()=>{U(!1)},0);return()=>window.clearTimeout(n)},[e?.enabled,B,U,w?.pendingDeviceFlow]),(0,h.useEffect)(()=>{let t=w?.pendingDeviceFlow;if(!e?.enabled||!t||j===`device-start`||j===`device-cancel`)return;let n=Math.max(1,Number(t.interval)||5)*1e3,r=window.setTimeout(async()=>{try{let e=await ye();E(e),e.deviceFlowResult===`success`?(window.dispatchEvent(new Event(me)),F(``),N(f(`cloudDeviceFlowSucceeded`)),await Promise.all([U(!1,!1,!1),H()])):e.deviceFlowResult===`denied`?F(f(`cloudDeviceFlowDenied`)):e.deviceFlowResult===`expired`?F(f(`cloudDeviceFlowExpired`)):e.deviceFlowResult===`network`&&F(f(`cloudDeviceFlowNetwork`))}catch(e){F(g(e))}},n);return()=>window.clearTimeout(r)},[j,e?.enabled,U,H,w?.pendingDeviceFlow]);let W=()=>window.dispatchEvent(new Event(me)),qe=async()=>{if(!j){if(S(s)){p(!0);return}M(`test`),N(``),F(``),C(void 0);try{let e=await ve(s);l(e.cloudUrl),C(e),N(f(`cloudConnectionTestSucceeded`))}catch(e){F(g(e,`cloudConnectionFailed`))}finally{M(``)}}},Je=async()=>{if(!j){if(S(s)){p(!0);return}M(`save`),N(``),F(``);try{let e=await m({cloudUrl:s});n(e),l(e.cloudUrl),C(void 0),I(``),W(),N(f(`cloudConnectionSaved`)),await U(!1)}catch(e){F(g(e))}finally{M(``)}}},Ye=async t=>{if(!(j||!e||e.enabled===t)){M(`cloud-toggle`),N(``),F(``),I(``);try{let e=await m({enabled:t});n(e),l(e.cloudUrl),C(void 0),e.enabled||V(),W(),N(f(e.enabled?`cloudServiceEnabledSaved`:`cloudServiceDisabledSaved`)),await U(!1)}catch(e){F(g(e))}finally{M(``)}}},Xe=async()=>{let t=s.trim()||e?.cloudUrl||``;if(S(t)){p(!0);return}if(!(!await c({title:f(`cloudForceSwitchTitle`),description:f(`cloudForceSwitchDescription`),confirmLabel:f(`cloudForceSwitchConfirm`),cancelLabel:f(`cancel`),variant:`destructive`})||j||!t)){M(`force-switch`),N(``),F(``),I(``);try{let e=await Pe(t,{reset:we,save:e=>m({cloudUrl:e}),onIdentityReset:()=>{L.current+=1,E(e=>e&&{...e,mode:`local`,hasSession:!1,sessionServiceMismatch:!1}),V(),W()}});if(e.status===`url-save-failed`){let t=g(e.error);I(f(`cloudIdentityRebuiltUrlSaveFailed`)),await U(!1,!0),F(t);return}n(e.config),l(e.config.cloudUrl),C(void 0),W(),N(f(`cloudForceSwitchSucceeded`)),await U(!1)}catch(e){F(g(e))}finally{M(``)}}},Ze=async()=>{if(!j){M(`device-start`),N(``),F(``),I(``);try{E(await be()),W()}catch(e){F(g(e))}finally{M(``)}}},Qe=async()=>{if(!j){M(`device-cancel`),N(``),F(``);try{E(await de()),N(f(`cloudDeviceFlowCancelled`))}catch(e){F(g(e))}finally{M(``)}}},$e=async()=>{if(!j){M(`remote-authorize-retry`),N(``),F(``);try{let e=await xe();H(),e.status===`failed`?F(e.error||f(`cloudRemoteAutoApprovalFailed`)):N(f(`cloudRemoteAutoApprovalRetried`))}catch(e){F(g(e))}finally{M(``)}}},et=async()=>{let e=w?.pendingDeviceFlow?.userCode;if(e)try{await navigator.clipboard.writeText(e),N(f(`cloudDeviceCodeCopied`))}catch{F(f(`copyFailed`))}},tt=async()=>{if(!(!await c({title:f(`cloudLogoutTitle`),description:f(`cloudLogoutDescription`),confirmLabel:f(`cloudLogout`),cancelLabel:f(`cancel`),variant:`destructive`})||j)){M(`logout`),N(``),F(``),I(``);try{await le(),L.current+=1,V(),E(e=>e&&{...e,mode:`local`,hasSession:!1,sessionServiceMismatch:!1}),W(),N(f(`cloudLoggedOut`)),await U(!1)}catch(e){F(g(e))}finally{M(``)}}},nt=async e=>{let t=y(e);if(!(!t||t===w?.installationId||j)&&await c({description:f(`cloudRevokeDeviceConfirm`,{name:b(e)}),confirmLabel:f(`cloudRevokeDevice`),cancelLabel:f(`cancel`),variant:`destructive`})){M(t),N(``),F(``);try{await Ce(t),k({type:`replace`,state:{...O,installations:O.installations.filter(e=>y(e)!==t)}}),N(f(`cloudDeviceRevoked`))}catch(e){F(g(e))}finally{M(``)}}},G=e?.enabled===!0,rt=!!(w?.configured&&w.hasSession),K=w?.sessionServiceMismatch===!0,q=rt&&!K,J=!!(e?.cloudUrl&&s.trim()&&e.cloudUrl!==s.trim()),Y=S(s),X=!!(Y&&u),it=ke({loading:A,loadError:P,status:w,details:O}),at=Ae(w),Z=it===`cloud-unavailable`,ot=K?f(`cloudSessionMismatchLabel`):w?.mode===`account`?f(`cloudFormalAccount`):f(`cloudNotConnected`),st=ze(D?.status),ct=D?.status===`running`?`quickforge-settings-badge-success`:D?.status===`authorizing`||D?.status===`starting`?`quickforge-settings-badge-info`:D?.status===`error`||D?.status===`conflict`?`quickforge-settings-badge-warning`:`quickforge-settings-badge-muted`,Q=Me(D),lt=G?w?.configured?f(K?`cloudSessionServiceMismatch`:q?Z?`cloudUnavailableDescription`:`cloudConnectedDescription`:`cloudLocalOnlyDescription`):f(`cloudNotConfiguredDescription`):f(`cloudServiceDisabledDescription`),ut=()=>{U()},$=A||O.loading,dt=new Map;for(let e of O.installations){let t=b(e);dt.set(t,(dt.get(t)??0)+1)}let ft=[...dt.entries()].filter(([,e])=>e>1),pt=ft.reduce((e,[,t])=>e+t,0);return(0,_.jsxs)(`div`,{className:`quickforge-settings-stack`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-heading`,children:[(0,_.jsx)(`div`,{children:(0,_.jsxs)(`h2`,{className:`quickforge-settings-title`,children:[(0,_.jsx)(i,{className:`size-5`}),f(`cloudAccount`)]})}),(0,_.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>void U(),disabled:A||!!j,className:`quickforge-settings-heading-action`,children:[(0,_.jsx)(o,{className:`mr-2 size-4 ${A?`animate-spin`:``}`}),f(`refresh`)]})]}),Ue?(0,_.jsx)(`div`,{className:`quickforge-settings-message`,children:Ue}):null,We?(0,_.jsx)(`div`,{className:`quickforge-settings-warning`,children:We}):null,P?(0,_.jsx)(`div`,{className:`quickforge-settings-error`,children:P}):null,(0,_.jsxs)(`div`,{className:`quickforge-settings-section`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-list-header`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,_.jsx)(oe,{className:`size-4`}),f(`cloudServiceConnection`)]}),(0,_.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-info shrink-0`,children:`QuickForge Cloud`})]}),(0,_.jsxs)(`div`,{className:`quickforge-settings-row`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,_.jsx)(`div`,{className:`quickforge-settings-row-title`,children:f(`cloudServiceEnabled`)}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-description`,children:f(`cloudServiceEnabledDescription`)})]}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-control`,children:(0,_.jsxs)(`label`,{className:`quickforge-settings-switch`,"aria-label":f(`cloudServiceEnabled`),children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:G,disabled:!e||!!j,onChange:e=>{Ye(e.target.checked)}}),(0,_.jsx)(`span`,{"aria-hidden":`true`})]})})]}),(0,_.jsxs)(`div`,{className:`quickforge-settings-row items-start`,children:[(0,_.jsx)(`div`,{className:`quickforge-settings-row-main`,children:(0,_.jsx)(`label`,{className:`quickforge-settings-row-title h-9 whitespace-nowrap`,htmlFor:`quickforge-cloud-url`,children:f(`cloudUrl`)})}),(0,_.jsxs)(`div`,{className:`quickforge-settings-row-control w-full max-w-xl flex-col items-stretch gap-2`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,_.jsx)(pe,{id:`quickforge-cloud-url`,value:s,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s.trim()&&J&&!j&&(e.preventDefault(),Je())},placeholder:f(`cloudUrlPlaceholder`),inputMode:`url`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,onBlur:()=>p(!0),"aria-invalid":X,className:Te(`min-w-0 flex-1`,X?`border-destructive`:void 0),disabled:!!j}),(0,_.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,_.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>void qe(),disabled:!s.trim()||!!Y||!!j,children:[j===`test`?(0,_.jsx)(o,{className:`mr-2 size-4 animate-spin`}):(0,_.jsx)(ne,{className:`mr-2 size-4`}),f(`cloudTestConnection`)]}),(0,_.jsxs)(d,{size:`sm`,onClick:()=>void Je(),disabled:!s.trim()||!J||!!Y||!!j,children:[j===`save`?(0,_.jsx)(o,{className:`mr-2 size-4 animate-spin`}):(0,_.jsx)(ce,{className:`mr-2 size-4`}),f(`saveChanges`)]})]})]}),X?(0,_.jsx)(`div`,{className:`text-xs text-destructive`,children:Y}):null,(0,_.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[f(`cloudConfigSource`),`: `,Ie(e?.source)]}),Ne(w,J)&&!Y?(0,_.jsx)(`div`,{className:`quickforge-settings-cloud-force-switch flex justify-end`,children:(0,_.jsxs)(d,{variant:`destructive`,size:`sm`,onClick:()=>void Xe(),disabled:!!j,title:f(`cloudForceSwitchDescription`),children:[(0,_.jsx)(t,{className:`mr-2 size-4`}),f(`cloudForceSwitch`)]})}):null]})]}),e?.configurationError?(0,_.jsx)(`div`,{className:`quickforge-settings-error m-3`,children:f(`cloudConfigurationError`)}):null,x?(0,_.jsxs)(`div`,{className:`quickforge-settings-row`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,_.jsx)(`div`,{className:`quickforge-settings-row-title`,children:f(`cloudConnectionTestResult`)}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-description break-all`,children:x.cloudUrl})]}),(0,_.jsxs)(`div`,{className:`quickforge-settings-row-control flex-wrap justify-end gap-1.5`,children:[Le(f(`cloudHealth`),x.health),Le(f(`cloudReady`),x.ready)]})]}):null]}),G?(0,_.jsxs)(`div`,{className:`quickforge-settings-section`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,_.jsx)(a,{className:`size-4`}),f(`cloudRemoteAccess`)]}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-description`,children:f(`cloudRemoteAccessDescription`)})]}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-control`,children:(0,_.jsx)(`span`,{className:`quickforge-settings-badge ${ct}`,children:st})})]}),D?.serverUrl?(0,_.jsxs)(`div`,{className:`quickforge-settings-row`,children:[(0,_.jsx)(`div`,{className:`quickforge-settings-row-main`,children:(0,_.jsx)(`div`,{className:`quickforge-settings-row-title`,children:f(`cloudRemoteServerUrl`)})}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-control break-all text-sm text-muted-foreground`,children:D.serverUrl})]}):null,D?.pid?(0,_.jsxs)(`div`,{className:`quickforge-settings-row`,children:[(0,_.jsx)(`div`,{className:`quickforge-settings-row-main`,children:(0,_.jsx)(`div`,{className:`quickforge-settings-row-title`,children:f(`cloudRemotePid`)})}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-control text-sm font-medium`,children:D.pid})]}):null,D?.status===`authorizing`?(0,_.jsxs)(`div`,{className:`quickforge-settings-row items-start`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,_.jsx)(`div`,{className:`quickforge-settings-row-title`,children:f(`cloudRemoteAuthorization`)}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-description`,children:Q.pending?f(`cloudRemoteAutoApprovalPending`):Q.failed?f(`cloudRemoteAutoApprovalFailed`):f(`cloudRemoteAutoApprovalNeedsLocalEnable`)}),Q.failed&&Q.failedError?(0,_.jsx)(`div`,{className:`quickforge-settings-warning quickforge-settings-warning-attached mt-1`,children:Q.failedError}):null]}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-control flex-wrap gap-1.5`,children:Q.pending?(0,_.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:f(`cloudRemoteAutoApprovalWaiting`)}):Q.failed?(0,_.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>void $e(),disabled:!!j,children:[(0,_.jsx)(o,{className:`mr-2 size-3.5`}),f(`cloudRemoteAutoApprovalRetry`)]}):null})]}):null,D?.error?(0,_.jsx)(`div`,{className:`quickforge-settings-warning quickforge-settings-warning-attached`,children:D.error}):null]}):null,(0,_.jsxs)(`div`,{className:`quickforge-settings-section`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,_.jsx)(re,{className:`size-4`}),f(`cloudIdentityStatus`)]}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-description`,children:lt})]}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-control`,children:(0,_.jsx)(`span`,{className:`quickforge-settings-badge ${q&&!Z?`quickforge-settings-badge-success`:K||Z?`quickforge-settings-badge-warning`:`quickforge-settings-badge-muted`}`,children:ot})})]}),Z?(0,_.jsx)(`div`,{className:`quickforge-settings-warning quickforge-settings-warning-attached`,children:f(`cloudUnavailableDescription`)}):null,K?(0,_.jsx)(`div`,{className:`quickforge-settings-warning quickforge-settings-warning-attached`,children:f(`cloudSessionServiceMismatch`)}):null,q?(0,_.jsxs)(_.Fragment,{children:[w?.mode===`account`?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row`,children:[(0,_.jsx)(`div`,{className:`quickforge-settings-row-main`,children:(0,_.jsx)(`div`,{className:`quickforge-settings-row-title`,children:f(`cloudAccountEmail`)})}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-control text-sm font-medium`,children:w.account?.email||f(`cloudNotAvailable`)})]}),(0,_.jsxs)(`div`,{className:`quickforge-settings-row`,children:[(0,_.jsx)(`div`,{className:`quickforge-settings-row-main`,children:(0,_.jsx)(`div`,{className:`quickforge-settings-row-title`,children:f(`cloudAccountPlan`)})}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-control text-sm font-medium`,children:w.account?.plan||f(`cloudNotAvailable`)})]})]}):null,G?O.errors.usage?(0,_.jsx)(T,{error:O.errors.usage,onRetry:ut,disabled:$||!!j}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row`,children:[(0,_.jsx)(`div`,{className:`quickforge-settings-row-main`,children:(0,_.jsx)(`div`,{className:`quickforge-settings-row-title`,children:f(`cloudRemainingQuota`)})}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-control text-sm font-medium`,children:Fe(O.usage?.remaining)})]}),(0,_.jsxs)(`div`,{className:`quickforge-settings-row`,children:[(0,_.jsx)(`div`,{className:`quickforge-settings-row-main`,children:(0,_.jsx)(`div`,{className:`quickforge-settings-row-title`,children:f(`cloudQuotaExpiresAt`)})}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-control text-sm text-muted-foreground`,children:v(O.usage?.resetsAt||O.usage?.expiresAt)})]})]}):null,(0,_.jsxs)(`div`,{className:`quickforge-settings-row`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,_.jsx)(`div`,{className:`quickforge-settings-row-title`,children:f(`cloudLogout`)}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-description`,children:f(`cloudLogoutRowDescription`)})]}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-control`,children:(0,_.jsxs)(d,{variant:`destructive`,className:`quickforge-settings-cloud-logout`,onClick:()=>void tt(),disabled:!!j,children:[(0,_.jsx)(r,{className:`mr-2 size-4`}),f(`cloudLogout`)]})})]})]}):null]}),!G||!w?.configured?null:at.showDeviceFlow&&z?(0,_.jsxs)(`div`,{className:`quickforge-settings-section`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-list-header`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,_.jsx)(ee,{className:`size-4`}),f(`cloudDeviceFlowTitle`)]}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-description`,children:f(`cloudDeviceFlowDescription`)})]}),(0,_.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-info`,children:f(`cloudDeviceFlowCountdown`,{seconds:B})})]}),(0,_.jsxs)(`div`,{className:`quickforge-settings-row items-start`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,_.jsx)(`div`,{className:`quickforge-settings-row-description`,children:f(`cloudDeviceCode`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono text-2xl font-semibold tracking-[0.18em] text-foreground`,children:z.userCode})]}),(0,_.jsxs)(`div`,{className:`quickforge-settings-row-control flex-wrap gap-2`,children:[(0,_.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>void et(),children:[(0,_.jsx)(te,{className:`mr-2 size-4`}),f(`copy`)]}),(0,_.jsxs)(d,{size:`sm`,onClick:()=>window.open(z.verificationUriComplete||z.verificationUri,`_blank`,`noopener,noreferrer`),children:[(0,_.jsx)(ie,{className:`mr-2 size-4`}),f(`cloudOpenVerificationPage`)]}),(0,_.jsx)(d,{variant:`outline`,size:`sm`,onClick:()=>void Qe(),disabled:!!j,children:f(`cancel`)})]})]}),w.deviceFlowResult===`slow_down`?(0,_.jsx)(`div`,{className:`quickforge-settings-warning quickforge-settings-warning-attached`,children:f(`cloudDeviceFlowSlowDown`)}):null]}):at.showDisconnectedActions?(0,_.jsx)(`div`,{className:`quickforge-settings-section`,children:(0,_.jsxs)(`div`,{className:`quickforge-settings-row`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,_.jsx)(ee,{className:`size-4`}),f(`cloudLoginOrRegister`)]}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-description`,children:f(`cloudLoginOrRegisterDescription`)})]}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-control`,children:(0,_.jsxs)(d,{onClick:()=>void Ze(),disabled:A||!!j,children:[(0,_.jsx)(ae,{className:`mr-2 size-4`}),f(`cloudLoginOrRegister`)]})})]})}):at.showDetails?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-section`,children:[(0,_.jsx)(`div`,{className:`quickforge-settings-list-header`,children:(0,_.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,_.jsx)(se,{className:`size-4`}),f(`cloudModels`)]})}),O.errors.models?(0,_.jsx)(T,{error:O.errors.models,onRetry:ut,disabled:$||!!j}):O.models.length===0?(0,_.jsx)(`div`,{className:`p-6 text-center text-sm text-muted-foreground`,children:f($?`loading`:`cloudNoModels`)}):O.models.map(e=>(0,_.jsx)(`div`,{className:`quickforge-settings-list-item`,children:(0,_.jsxs)(`div`,{className:`quickforge-settings-list-item-main`,children:[(0,_.jsx)(`div`,{className:`text-sm font-medium`,children:e.name||e.id}),(0,_.jsxs)(`div`,{className:`quickforge-settings-row-description`,children:[e.id,` · `,Re(e)]})]})},`${e.provider}:${e.id}`))]}),(0,_.jsxs)(`div`,{className:`quickforge-settings-section`,children:[(0,_.jsx)(`div`,{className:`quickforge-settings-list-header`,children:(0,_.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,_.jsx)(a,{className:`size-4`}),f(`cloudDevices`)]})}),pt>1?(0,_.jsx)(`div`,{className:`quickforge-settings-warning quickforge-settings-warning-attached`,children:f(`cloudDuplicateDevicesHint`,{count:pt,name:ft[0][0]})}):null,O.errors.installations?(0,_.jsx)(T,{error:O.errors.installations,onRetry:ut,disabled:$||!!j}):O.installations.length===0?(0,_.jsx)(`div`,{className:`p-6 text-center text-sm text-muted-foreground`,children:f($?`loading`:`cloudNoDevices`)}):O.installations.map(e=>{let t=y(e),n=e.current===!0||t===w?.installationId;return(0,_.jsxs)(`div`,{className:`quickforge-settings-list-item`,children:[(0,_.jsxs)(`div`,{className:`quickforge-settings-list-item-main`,children:[(0,_.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,_.jsx)(`div`,{className:`truncate text-sm font-medium`,children:b(e)}),n?(0,_.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-info`,children:f(`cloudCurrentDevice`)}):null]}),(0,_.jsx)(`div`,{className:`quickforge-settings-row-description`,children:[e.platform,e.createdAt?`${f(`cloudRegisteredAt`)} ${v(e.createdAt)}`:void 0,e.lastSeenAt?`${f(`cloudLastSeenAt`)} ${v(e.lastSeenAt)}`:void 0,t?`#${t.slice(0,8)}`:void 0].filter(Boolean).join(` · `)||f(`cloudNotAvailable`)})]}),(0,_.jsx)(`div`,{className:`quickforge-settings-list-item-actions`,children:(0,_.jsx)(d,{variant:`outline`,size:`sm`,onClick:()=>void nt(e),disabled:n||!!j,children:f(`cloudRevokeDevice`)})})]},t||b(e))})]})]}):null]})}export{E as CloudAccountSettingsPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{J as t,Jt as n,T as r,o as i,w as a}from"./icons-DM_qJ7VJ.js";import{n as o}from"./react-vendor-BpWW_Nvp.js";import{Pn as s}from"./index-BgMvQW1b.js";import{n as c,r as l,t as u}from"./plugin-api-BrdQeM4B.js";var d=e(n(),1),f=o();function p(e){switch(e){case`documents`:return{label:s(`pluginDocumentsName`),description:s(`pluginDocumentsDescription`)};case`spreadsheets`:return{label:s(`pluginSpreadsheetsName`),description:s(`pluginSpreadsheetsDescription`)};case`presentations`:return{label:s(`pluginPresentationsName`),description:s(`pluginPresentationsDescription`)};default:return null}}function m(e){return p(e.name)?.label||(e.displayName||e.name).replace(/^OpenAI\s+/i,``)}function h(e){return p(e.name)?.description||e.description||s(`noDescription`)}function g({onChanged:e}){let[n,o]=(0,d.useState)(null),[p,g]=(0,d.useState)(!0),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(null),x=(0,d.useCallback)(async(t=`load`)=>{b(null),g(!0);try{o(t===`reload`?await c():await u()),t===`reload`&&e?.()}catch(e){b(e instanceof Error?e.message:s(`pluginsLoadFailed`))}finally{g(!1)}},[e]);(0,d.useEffect)(()=>{let e=!1;return u().then(t=>{e||o(t)}).catch(t=>{e||b(t instanceof Error?t.message:s(`pluginsLoadFailed`))}).finally(()=>{e||g(!1)}),()=>{e=!0}},[]);let S=(0,d.useMemo)(()=>{let e=n?.plugins||[];return{total:e.length,enabled:e.filter(e=>e.enabled).length}},[n]),C=(0,d.useMemo)(()=>n?.plugins||[],[n]),w=async(t,n)=>{v(t),b(null);try{o(await l(t,n)),e?.()}catch(e){b(e instanceof Error?e.message:s(`pluginsSaveFailed`))}finally{v(null)}};return(0,f.jsx)(`div`,{className:`quickforge-settings-stack`,children:(0,f.jsxs)(`section`,{className:`quickforge-settings-section`,"aria-label":s(`plugins`),children:[(0,f.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,f.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,f.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,f.jsx)(r,{className:`size-4 text-primary`}),s(`plugins`)]}),(0,f.jsx)(`div`,{className:`quickforge-settings-row-description`,children:s(`pluginsDescription`)}),(0,f.jsx)(`div`,{className:`quickforge-settings-meta`,children:(0,f.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:s(`pluginsCount`,S)})})]}),(0,f.jsxs)(`button`,{className:`quickforge-settings-button quickforge-settings-button-secondary`,type:`button`,onClick:()=>void x(`reload`),disabled:p,children:[p?(0,f.jsx)(t,{className:`mr-2 size-4 animate-spin`}):(0,f.jsx)(a,{className:`mr-2 size-4`}),s(`pluginsReload`)]})]}),y?(0,f.jsx)(`div`,{className:`quickforge-settings-alert quickforge-settings-warning-attached`,children:y}):null,n?.errors?.length?(0,f.jsxs)(`div`,{className:`quickforge-settings-warning quickforge-settings-warning-attached`,children:[(0,f.jsxs)(`div`,{className:`mb-2 inline-flex items-center gap-2 font-medium`,children:[(0,f.jsx)(i,{className:`size-4`}),s(`pluginDiscoveryErrors`)]}),n.errors.map((e,t)=>(0,f.jsxs)(`div`,{className:`break-all text-sm`,children:[(0,f.jsx)(`code`,{className:`quickforge-settings-command-name`,children:e.dir}),`: `,e.error]},`${e.dir}-${t}`))]}):null,p&&!n?(0,f.jsxs)(`div`,{className:`quickforge-settings-empty-row inline-flex items-center gap-2`,children:[(0,f.jsx)(t,{className:`size-4 animate-spin`}),s(`loadingPlugins`)]}):null,!p&&n&&n.plugins.length===0?(0,f.jsxs)(`div`,{className:`quickforge-settings-empty-row`,children:[(0,f.jsx)(`div`,{className:`quickforge-settings-row-title`,children:s(`noPlugins`)}),(0,f.jsx)(`div`,{className:`quickforge-settings-row-description`,children:s(`noPluginsDescription`)}),(0,f.jsx)(`div`,{className:`quickforge-settings-meta`,children:(n.searchPaths||[]).map(e=>(0,f.jsx)(`code`,{className:`quickforge-settings-command-name`,children:e},e))})]}):null,C.map(e=>(0,f.jsx)(`article`,{className:`quickforge-settings-list-item quickforge-settings-list-item--column`,children:(0,f.jsxs)(`div`,{className:`quickforge-settings-list-item-header`,children:[(0,f.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,f.jsx)(`span`,{className:`quickforge-settings-row-title`,children:m(e)}),(0,f.jsx)(`span`,{className:`quickforge-settings-row-description`,children:h(e)}),e.error?(0,f.jsx)(`span`,{className:`quickforge-settings-alert mt-3 block`,children:e.error}):null]}),(0,f.jsx)(`div`,{className:`quickforge-settings-list-item-actions`,children:(0,f.jsxs)(`label`,{className:`quickforge-settings-switch`,"aria-disabled":_===e.name?`true`:`false`,children:[(0,f.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:_===e.name,onChange:t=>void w(e.name,t.target.checked)}),(0,f.jsx)(`span`,{"aria-hidden":`true`})]})})]})},e.name))]})})}export{g as PluginsPage};
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{J as t,Jt as n,T as r,o as i,w as a}from"./icons-DM_qJ7VJ.js";import{n as o}from"./react-vendor-BpWW_Nvp.js";import{Un as s}from"./index-CgVTwN15.js";import{n as c,r as l,t as u}from"./plugin-api-BrdQeM4B.js";var d=e(n(),1),f=o();function p(e){switch(e){case`documents`:return{label:s(`pluginDocumentsName`),description:s(`pluginDocumentsDescription`)};case`spreadsheets`:return{label:s(`pluginSpreadsheetsName`),description:s(`pluginSpreadsheetsDescription`)};case`presentations`:return{label:s(`pluginPresentationsName`),description:s(`pluginPresentationsDescription`)};default:return null}}function m(e){return p(e.name)?.label||(e.displayName||e.name).replace(/^OpenAI\s+/i,``)}function h(e){return p(e.name)?.description||e.description||s(`noDescription`)}function g({onChanged:e}){let[n,o]=(0,d.useState)(null),[p,g]=(0,d.useState)(!0),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(null),x=(0,d.useCallback)(async(t=`load`)=>{b(null),g(!0);try{o(t===`reload`?await c():await u()),t===`reload`&&e?.()}catch(e){b(e instanceof Error?e.message:s(`pluginsLoadFailed`))}finally{g(!1)}},[e]);(0,d.useEffect)(()=>{let e=!1;return u().then(t=>{e||o(t)}).catch(t=>{e||b(t instanceof Error?t.message:s(`pluginsLoadFailed`))}).finally(()=>{e||g(!1)}),()=>{e=!0}},[]);let S=(0,d.useMemo)(()=>{let e=n?.plugins||[];return{total:e.length,enabled:e.filter(e=>e.enabled).length}},[n]),C=(0,d.useMemo)(()=>n?.plugins||[],[n]),w=async(t,n)=>{v(t),b(null);try{o(await l(t,n)),e?.()}catch(e){b(e instanceof Error?e.message:s(`pluginsSaveFailed`))}finally{v(null)}};return(0,f.jsx)(`div`,{className:`quickforge-settings-stack`,children:(0,f.jsxs)(`section`,{className:`quickforge-settings-section`,"aria-label":s(`plugins`),children:[(0,f.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,f.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,f.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[(0,f.jsx)(r,{className:`size-4 text-primary`}),s(`plugins`)]}),(0,f.jsx)(`div`,{className:`quickforge-settings-row-description`,children:s(`pluginsDescription`)}),(0,f.jsx)(`div`,{className:`quickforge-settings-meta`,children:(0,f.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:s(`pluginsCount`,S)})})]}),(0,f.jsxs)(`button`,{className:`quickforge-settings-button quickforge-settings-button-secondary`,type:`button`,onClick:()=>void x(`reload`),disabled:p,children:[p?(0,f.jsx)(t,{className:`mr-2 size-4 animate-spin`}):(0,f.jsx)(a,{className:`mr-2 size-4`}),s(`pluginsReload`)]})]}),y?(0,f.jsx)(`div`,{className:`quickforge-settings-alert quickforge-settings-warning-attached`,children:y}):null,n?.errors?.length?(0,f.jsxs)(`div`,{className:`quickforge-settings-warning quickforge-settings-warning-attached`,children:[(0,f.jsxs)(`div`,{className:`mb-2 inline-flex items-center gap-2 font-medium`,children:[(0,f.jsx)(i,{className:`size-4`}),s(`pluginDiscoveryErrors`)]}),n.errors.map((e,t)=>(0,f.jsxs)(`div`,{className:`break-all text-sm`,children:[(0,f.jsx)(`code`,{className:`quickforge-settings-command-name`,children:e.dir}),`: `,e.error]},`${e.dir}-${t}`))]}):null,p&&!n?(0,f.jsxs)(`div`,{className:`quickforge-settings-empty-row inline-flex items-center gap-2`,children:[(0,f.jsx)(t,{className:`size-4 animate-spin`}),s(`loadingPlugins`)]}):null,!p&&n&&n.plugins.length===0?(0,f.jsxs)(`div`,{className:`quickforge-settings-empty-row`,children:[(0,f.jsx)(`div`,{className:`quickforge-settings-row-title`,children:s(`noPlugins`)}),(0,f.jsx)(`div`,{className:`quickforge-settings-row-description`,children:s(`noPluginsDescription`)}),(0,f.jsx)(`div`,{className:`quickforge-settings-meta`,children:(n.searchPaths||[]).map(e=>(0,f.jsx)(`code`,{className:`quickforge-settings-command-name`,children:e},e))})]}):null,C.map(e=>(0,f.jsx)(`article`,{className:`quickforge-settings-list-item quickforge-settings-list-item--column`,children:(0,f.jsxs)(`div`,{className:`quickforge-settings-list-item-header`,children:[(0,f.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,f.jsx)(`span`,{className:`quickforge-settings-row-title`,children:m(e)}),(0,f.jsx)(`span`,{className:`quickforge-settings-row-description`,children:h(e)}),e.error?(0,f.jsx)(`span`,{className:`quickforge-settings-alert mt-3 block`,children:e.error}):null]}),(0,f.jsx)(`div`,{className:`quickforge-settings-list-item-actions`,children:(0,f.jsxs)(`label`,{className:`quickforge-settings-switch`,"aria-disabled":_===e.name?`true`:`false`,children:[(0,f.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:_===e.name,onChange:t=>void w(e.name,t.target.checked)}),(0,f.jsx)(`span`,{"aria-hidden":`true`})]})})]})},e.name))]})})}export{g as PluginsPage};
@@ -0,0 +1,2 @@
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Et as t,Gt as n,Jt as r,Ot as i,Rt as a,b as o,f as s,ht as ee,j as te,ot as ne,pt as re,s as ie,t as ae,zt as oe}from"./icons-DM_qJ7VJ.js";import{n as c}from"./react-vendor-BpWW_Nvp.js";import{i as se,n as ce,r as le,t as ue}from"./model-display-label-CURwH0xM.js";import{Et as de,In as fe,Rn as l,Sn as pe,Un as u,kn as d,vn as f,xn as me,yn as he,zn as p}from"./index-CgVTwN15.js";import{i as m,n as h,t as ge}from"./model-identity-CgA6_Pbm.js";var g=e(r(),1),_=c(),_e=[{value:`off`,label:()=>u(`thinkingOff`)},{value:`low`,label:()=>u(`thinkingLow`)},{value:`medium`,label:()=>u(`thinkingMedium`)},{value:`high`,label:()=>u(`thinkingHigh`)},{value:`xhigh`,label:()=>u(`thinkingXHigh`)}];function ve(e,t){return m(e,t)}function v(e){return String(e).padStart(2,`0`)}function y(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:`${t.getFullYear()}-${v(t.getMonth()+1)}-${v(t.getDate())} ${v(t.getHours())}:${v(t.getMinutes())}`}function ye(e,t=20){let n=String(e||``).trim();return n.length>t?`${n.slice(0,t)}...`:n}function be(){return{scheduleText:``,title:``,instruction:``,cronExpression:``,scheduleRule:``,nextRunAt:``,enabled:!0,agentId:``,executionMode:`serial`}}function xe(){return{taskId:``,status:``,trigger:``,keyword:``,startedFrom:``,startedTo:``,page:1,pageSize:10}}function Se(e){return{scheduleText:[e.scheduleRule,e.instruction].filter(Boolean).join(`
2
+ `),title:e.title,instruction:e.instruction,cronExpression:e.cronExpression??``,scheduleRule:e.scheduleRule,nextRunAt:e.nextRunAt,enabled:e.status!==`paused`,agentId:e.agentId??``,executionMode:e.executionMode??`serial`}}function Ce(e,t){return{...t,title:e.title,instruction:e.instruction,cronExpression:e.cronExpression??``,scheduleRule:e.scheduleRule,nextRunAt:e.nextRunAt,enabled:t.enabled}}function we(e){return{title:e.title.trim(),instruction:e.instruction.trim(),scheduleType:`cron`,scheduleRule:e.scheduleRule.trim()||e.cronExpression.trim(),cronExpression:e.cronExpression.trim(),nextRunAt:e.nextRunAt,enabled:e.enabled,agentId:e.agentId||null,executionMode:e.executionMode}}function b(e){return!!(e.currentRunId||e.currentRunIds?.length)}function Te(e){return(e.executionMode??`serial`)===`parallel`||!b(e)}function Ee(e){return u(e===`parallel`?`taskExecutionModeParallel`:`taskExecutionModeSerial`)}function De(e){return!!(e.title.trim()&&e.instruction.trim()&&e.cronExpression.trim())}function Oe(e){return u(e===`enabled`?`taskEnabled`:e===`running`?`taskRunning`:e===`paused`?`taskPaused`:e===`completed`?`taskFinished`:e===`success`?`executionSuccess`:`taskFailed`)}function ke(e){return e===`enabled`||e===`success`?`bg-emerald-500/10 text-emerald-700`:e===`running`?`bg-blue-500/10 text-blue-700`:e===`paused`?`bg-amber-500/10 text-amber-700`:`bg-muted text-muted-foreground`}async function x(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 S({onOpenSession:e}){let[r,c]=(0,g.useState)([]),[m,v]=(0,g.useState)(`tasks`),[S,C]=(0,g.useState)(()=>be()),[w,Ae]=(0,g.useState)(null),[T,E]=(0,g.useState)(null),[D,O]=(0,g.useState)(null),[k,A]=(0,g.useState)(!1),[j,M]=(0,g.useState)(null),[je,N]=(0,g.useState)(``),[P,F]=(0,g.useState)(!1),[I,L]=(0,g.useState)(``),[R,Me]=(0,g.useState)([]),[z,B]=(0,g.useState)(),[Ne,V]=(0,g.useState)(`off`),[H,Pe]=(0,g.useState)([]),[Fe,Ie]=(0,g.useState)(``),[U,W]=(0,g.useState)(()=>xe()),[G,K]=(0,g.useState)(()=>xe()),[q,Le]=(0,g.useState)({runs:[],total:0,page:1,pageSize:10}),[Re,ze]=(0,g.useState)(!1),[Be,Ve]=(0,g.useState)(null),[He,Ue]=(0,g.useState)([]),We=H[0]?.id??``;(0,g.useEffect)(()=>{if(!D)return;let e=()=>O(null);return window.addEventListener(`click`,e),window.addEventListener(`blur`,e),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`blur`,e)}},[D]);async function Ge(){c((await x(`/api/scheduled-tasks`)).tasks)}async function J(e=G){ze(!0),L(``);try{let t=new URLSearchParams;t.set(`page`,String(e.page)),t.set(`pageSize`,String(e.pageSize)),e.taskId&&t.set(`taskId`,e.taskId),e.status&&t.set(`status`,e.status),e.trigger&&t.set(`trigger`,e.trigger),e.keyword.trim()&&t.set(`keyword`,e.keyword.trim()),e.startedFrom&&t.set(`startedFrom`,e.startedFrom),e.startedTo&&t.set(`startedTo`,e.startedTo),Le(await x(`/api/scheduled-tasks/runs?${t.toString()}`))}catch(e){L(e instanceof Error?e.message:u(`requestFailed`))}finally{ze(!1)}}(0,g.useEffect)(()=>{let e=!1;async function t(){try{let t=await x(`/api/project`);if(e)return;Pe(t.projects??[])}catch{}}return t(),()=>{e=!0}},[]),(0,g.useEffect)(()=>{let e=!1;async function t(){try{let t=await me(),[n,r]=await Promise.all([he(t),ce().catch(()=>[])]),i=r.length?r:n,a=i.filter(d),o=await pe(t),s=(o.model&&d(o.model)?a.find(e=>ve(e,o.model))||(se(o.model)?a.find(e=>e.quickforgeCatalogId===o.model.quickforgeCatalogId):void 0):void 0)??a[0];if(e)return;Me(i),B(s),V(o.thinkingLevel??f(s))}catch(t){e||L(t instanceof Error?t.message:u(`requestFailed`))}}return t(),()=>{e=!0}},[]),(0,g.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await x(`/api/scheduled-tasks`);e||c(t.tasks)}catch(t){e||L(t instanceof Error?t.message:u(`requestFailed`))}};t();let n=window.setInterval(t,10*1e3);return()=>{e=!0,window.clearInterval(n)}},[]),(0,g.useEffect)(()=>{let e=!1;async function t(){try{let t=await x(`/api/agent-profiles`);if(e)return;Ue(t.agents)}catch(t){e||L(t instanceof Error?t.message:u(`requestFailed`))}}return t(),()=>{e=!0}},[]);let Ke=(0,g.useMemo)(()=>r.find(e=>e.id===w),[w,r]),qe=(0,g.useMemo)(()=>R.filter(d),[R]),Je=(0,g.useMemo)(()=>ge(qe,z),[qe,z]),Y=(0,g.useMemo)(()=>r.find(e=>e.id===T)??null,[T,r]),Ye=(0,g.useMemo)(()=>r.filter(e=>e.status===`enabled`).length,[r]),Xe=Math.max(1,Math.ceil(q.total/q.pageSize));function Ze(e){return e?He.find(t=>t.id===e||t.name===e)?.label??e:u(`defaultAgent`)}function X(e,t){C(n=>({...n,[e]:t}))}function Z(e,t){W(n=>({...n,[e]:t}))}function Qe(){let e=R.find(d);Ae(null),Ie(We),B(e),V(f(e)),C(be()),M(null),N(``),L(``)}function $e(){Qe(),A(!0)}function Q(){P||(A(!1),Qe())}function et(){let e={...U,page:1};W(e),K(e),J(e)}function tt(){let e=xe();W(e),K(e),J(e)}function nt(e){let t=Math.min(Math.max(1,e),Xe),n={...G,page:t};W(n),K(n),J(n)}function rt(e){let t={...G,page:1,pageSize:e};W(t),K(t),J(t)}async function it(){let e=S.scheduleText.trim();if(e){F(!0),L(``);try{let t=await x(`/api/scheduled-tasks/parse`,{method:`POST`,body:JSON.stringify({instruction:e,modelRef:z?le(z):void 0,model:z,thinkingLevel:Ne})});if(t.needMoreInfo||!t.task){N(t.question||`请补充任务信息。`),M(null);return}let n=t.task;N(``),M(n),C(e=>Ce(n,e))}catch(e){L(e instanceof Error?e.message:u(`requestFailed`))}finally{F(!1)}}}async function at(){if(De(S)){F(!0),L(``);try{let e=H.find(e=>e.id===Fe),t={task:we(S),modelRef:z?le(z):void 0,model:z,thinkingLevel:Ne,projectId:e?.id,projectName:e?.name};w?await x(`/api/scheduled-tasks/${encodeURIComponent(w)}`,{method:`PUT`,body:JSON.stringify(t)}):await x(`/api/scheduled-tasks`,{method:`POST`,body:JSON.stringify(t)}),Q(),await Ge(),m===`history`&&await J(G)}catch(e){L(e instanceof Error?e.message:u(`requestFailed`))}finally{F(!1)}}}function ot(e){O(null),Ae(e.id),C(Se(e)),M(null),N(``),L(``),Ie(e.projectId??``),e.model&&B(e.model),e.thinkingLevel&&V(e.thinkingLevel),A(!0)}async function $(e,t){if(L(``),O(null),!(t===`delete`&&!await de({description:u(`confirmDeleteTask`),confirmLabel:u(`confirmDelete`),cancelLabel:u(`cancel`),variant:`destructive`})))try{t===`delete`?(await x(`/api/scheduled-tasks/${encodeURIComponent(e)}`,{method:`DELETE`}),w===e&&Q(),T===e&&E(null)):await x(`/api/scheduled-tasks/${encodeURIComponent(e)}/${t}`,{method:`POST`}),await Ge(),m===`history`&&await J(G)}catch(e){L(e instanceof Error?e.message:u(`requestFailed`))}}function st(t){return(0,_.jsxs)(`div`,{className:`mt-2 space-y-2 text-xs text-muted-foreground`,children:[t.sessionId?(0,_.jsx)(l,{variant:`outline`,size:`sm`,onClick:()=>e?.(t.sessionId),children:u(`viewConversation`)}):null,(0,_.jsxs)(`div`,{children:[u(`executionAgent`),t.agentLabel||Ze(t.agentId)]}),t.warning?(0,_.jsx)(`div`,{className:`text-amber-600`,children:t.warning}):null,t.inputContent?(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`font-medium text-foreground`,children:u(`runInputContent`)}),(0,_.jsx)(`pre`,{className:`mt-1 max-h-32 overflow-auto whitespace-pre-wrap`,children:t.inputContent})]}):null,t.aiResult||t.result?(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`font-medium text-foreground`,children:u(`runAiResult`)}),(0,_.jsx)(`pre`,{className:`mt-1 max-h-48 overflow-auto whitespace-pre-wrap`,children:t.aiResult||t.result})]}):null,t.errorMessage?(0,_.jsx)(`div`,{className:`text-destructive`,children:t.errorMessage}):null,t.durationMs?(0,_.jsxs)(`div`,{children:[u(`runDuration`),t.durationMs,`ms`]}):null]})}return(0,_.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[(0,_.jsxs)(`div`,{className:`border-b border-border px-6 py-5`,children:[(0,_.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-3`,children:k||Y?(0,_.jsxs)(l,{variant:`outline`,onClick:()=>{k?Q():E(null)},children:[(0,_.jsx)(n,{className:`mr-1 size-4`}),u(`back`)]}):(0,_.jsx)(l,{onClick:$e,children:u(`createTask`)})}),!k&&!Y?(0,_.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,_.jsxs)(`button`,{type:`button`,className:p(`rounded-full px-4 py-2 text-sm font-medium transition-colors`,m===`tasks`?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:text-foreground`),onClick:()=>v(`tasks`),children:[u(`taskListTab`),` `,(0,_.jsx)(`span`,{className:`opacity-80`,children:r.length})]}),(0,_.jsx)(`button`,{type:`button`,className:p(`rounded-full px-4 py-2 text-sm font-medium transition-colors`,m===`history`?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:text-foreground`),onClick:()=>{v(`history`),J(G)},children:u(`executionHistoryTab`)})]}):null]}),(0,_.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-6`,children:(0,_.jsx)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:k?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-5 space-y-4`,children:[(0,_.jsxs)(`h2`,{className:`inline-flex items-center gap-1.5 text-base font-semibold text-foreground`,children:[u(Ke?`editTask`:`createTask`),(0,_.jsx)(fe,{label:u(`quickAiParseTask`)})]}),(0,_.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[u(`taskScheduleDescriptionLabel`),(0,_.jsx)(`textarea`,{className:`mt-1 min-h-24 w-full resize-y rounded-xl border border-input bg-background px-3 py-2 text-sm outline-none transition-colors placeholder:text-muted-foreground/65 focus:border-ring`,value:S.scheduleText,onChange:e=>X(`scheduleText`,e.target.value),placeholder:u(`taskScheduleDescriptionPlaceholder`)})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,_.jsxs)(l,{onClick:it,disabled:P||!z||!S.scheduleText.trim(),children:[(0,_.jsx)(s,{className:`mr-1 size-3.5`}),u(`aiParseTask`)]}),je?(0,_.jsx)(`span`,{className:`text-sm text-amber-600`,children:je}):null]}),(0,_.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,_.jsxs)(`label`,{className:`block text-sm font-medium text-foreground`,children:[u(`taskTitleLabel`),(0,_.jsx)(`input`,{className:`mt-1 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-ring`,value:S.title,onChange:e=>X(`title`,e.target.value),placeholder:u(`taskTitlePlaceholder`)})]}),(0,_.jsxs)(`div`,{className:`block text-sm font-medium text-foreground`,children:[u(`executionRule`),(0,_.jsx)(`div`,{className:`mt-1 flex h-10 items-center rounded-md border border-input bg-muted/20 px-3 text-sm text-muted-foreground`,children:S.scheduleRule||`-`})]}),(0,_.jsxs)(`div`,{className:`block text-sm font-medium text-foreground`,children:[`cron`,(0,_.jsx)(`div`,{className:`mt-1 flex h-10 items-center rounded-md border border-input bg-muted/20 px-3 font-mono text-sm text-muted-foreground`,children:S.cronExpression||`-`})]}),(0,_.jsxs)(`div`,{className:`block text-sm font-medium text-foreground`,children:[u(`nextExecutionTime`),(0,_.jsx)(`div`,{className:`mt-1 flex h-10 items-center rounded-md border border-input bg-muted/20 px-3 text-sm text-muted-foreground`,children:y(S.nextRunAt)})]}),(0,_.jsxs)(`label`,{className:`block text-sm font-medium text-foreground sm:col-span-2`,children:[(0,_.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[u(`taskExecutionMode`),(0,_.jsx)(fe,{label:u(`taskExecutionModeHelp`)})]}),(0,_.jsxs)(`select`,{className:`mt-1 h-10 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground outline-none focus:border-ring`,value:S.executionMode,onChange:e=>X(`executionMode`,e.target.value),children:[(0,_.jsx)(`option`,{value:`serial`,children:u(`taskExecutionModeSerial`)}),(0,_.jsx)(`option`,{value:`parallel`,children:u(`taskExecutionModeParallel`)})]})]}),(0,_.jsxs)(`label`,{className:`block text-sm font-medium text-foreground sm:col-span-2`,children:[u(`promptContentLabel`),(0,_.jsx)(`textarea`,{className:`mt-1 min-h-28 w-full resize-y rounded-xl border border-input bg-background px-3 py-2 text-sm text-foreground outline-none transition-colors placeholder:text-muted-foreground/65 focus:border-ring`,value:S.instruction,onChange:e=>X(`instruction`,e.target.value),placeholder:u(`promptContentPlaceholder`)})]})]}),(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:S.enabled,onChange:e=>X(`enabled`,e.target.checked)}),u(`taskEnabledSwitch`)]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-xl border border-border bg-muted/20 px-2 py-2`,children:[(0,_.jsxs)(`span`,{className:`relative inline-flex items-center`,children:[(0,_.jsx)(s,{className:`pointer-events-none absolute left-2 size-3.5 text-muted-foreground/70`}),(0,_.jsxs)(`select`,{className:`h-8 max-w-[240px] rounded-md border border-transparent bg-transparent pl-7 pr-2 text-xs text-muted-foreground outline-none hover:bg-background focus:border-ring`,value:z?h(z):``,onChange:e=>{let t=Je.find(t=>h(t)===e.target.value);B(t),V(f(t))},title:u(`taskModel`),children:[Je.length===0?(0,_.jsx)(`option`,{value:``,children:u(`noModelAvailable`)}):null,Je.map(e=>(0,_.jsxs)(`option`,{value:h(e),children:[ue(e),ve(e,z)?` ✓`:``]},h(e)))]})]}),(0,_.jsxs)(`span`,{className:`relative inline-flex items-center`,children:[(0,_.jsx)(a,{className:`pointer-events-none absolute left-2 size-3.5 text-muted-foreground/70`}),(0,_.jsx)(`select`,{className:`h-8 rounded-md border border-transparent bg-transparent pl-7 pr-2 text-xs text-muted-foreground outline-none hover:bg-background focus:border-ring`,value:Ne,onChange:e=>V(e.target.value),title:u(`taskThinking`),children:_e.map(e=>(0,_.jsx)(`option`,{value:e.value,children:e.label()},e.value))})]}),(0,_.jsxs)(`span`,{className:`relative inline-flex items-center`,children:[(0,_.jsx)(ne,{className:`pointer-events-none absolute left-2 size-3.5 text-muted-foreground/70`}),(0,_.jsxs)(`select`,{className:`h-8 max-w-[220px] rounded-md border border-transparent bg-transparent pl-7 pr-2 text-xs text-muted-foreground outline-none hover:bg-background focus:border-ring`,value:Fe,onChange:e=>Ie(e.target.value),title:u(`taskProjectLabel`),children:[(0,_.jsx)(`option`,{value:``,children:u(`noProjectBound`)}),H.map(e=>(0,_.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,_.jsxs)(`span`,{className:`relative inline-flex items-center`,children:[(0,_.jsx)(oe,{className:`pointer-events-none absolute left-2 size-3.5 text-muted-foreground/70`}),(0,_.jsxs)(`select`,{className:`h-8 max-w-[220px] rounded-md border border-transparent bg-transparent pl-7 pr-2 text-xs text-muted-foreground outline-none hover:bg-background focus:border-ring`,value:S.agentId,onChange:e=>X(`agentId`,e.target.value),title:u(`executionAgent`),children:[(0,_.jsx)(`option`,{value:``,children:u(`defaultAgent`)}),He.map(e=>(0,_.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})]}),j?(0,_.jsxs)(`div`,{className:`rounded-xl border border-border bg-muted/30 p-3 text-sm`,children:[(0,_.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 font-medium text-foreground`,children:[(0,_.jsx)(i,{className:`size-4 text-emerald-600`}),u(`aiParsed`)]}),(0,_.jsxs)(`div`,{className:`grid gap-2 text-muted-foreground sm:grid-cols-2`,children:[(0,_.jsxs)(`div`,{children:[u(`taskName`),(0,_.jsx)(`span`,{className:`text-foreground`,children:j.title})]}),(0,_.jsxs)(`div`,{children:[u(`executionRule`),(0,_.jsx)(`span`,{className:`text-foreground`,children:j.scheduleRule})]}),(0,_.jsxs)(`div`,{children:[`cron:`,(0,_.jsx)(`span`,{className:`font-mono text-foreground`,children:j.cronExpression??`-`})]}),(0,_.jsxs)(`div`,{children:[u(`nextExecutionTime`),(0,_.jsx)(`span`,{className:`text-foreground`,children:y(j.nextRunAt)})]}),(0,_.jsxs)(`div`,{className:`sm:col-span-2`,children:[u(`aiInstruction`),(0,_.jsx)(`span`,{className:`text-foreground`,children:j.instruction})]})]})]}):null,I?(0,_.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:I}):null]}),(0,_.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,_.jsx)(l,{variant:`outline`,onClick:Q,disabled:P,children:u(`cancel`)}),(0,_.jsx)(l,{onClick:at,disabled:P||!z||!De(S),children:u(Ke?`saveTask`:`confirmCreate`)})]})]}):Y?(0,_.jsxs)(`div`,{className:`rounded-xl border border-border bg-card`,children:[(0,_.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-border px-5 py-4`,children:(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:Y.title}),(0,_.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:Y.scheduleRule})]})}),(0,_.jsx)(`div`,{className:`px-5 py-4`,children:(0,_.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`mb-1 font-medium text-foreground`,children:u(`taskContent`)}),(0,_.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap rounded-xl border border-border bg-muted/20 p-3 text-muted-foreground`,children:Y.instruction})]}),(0,_.jsxs)(`div`,{className:`grid gap-3 text-muted-foreground sm:grid-cols-2`,children:[(0,_.jsxs)(`div`,{children:[u(`executionRule`),(0,_.jsx)(`span`,{className:`text-foreground`,children:Y.scheduleRule})]}),(0,_.jsxs)(`div`,{children:[u(`taskExecutionMode`),`:`,(0,_.jsx)(`span`,{className:`text-foreground`,children:Ee(Y.executionMode)})]}),(0,_.jsxs)(`div`,{children:[`cron:`,(0,_.jsx)(`span`,{className:`font-mono text-foreground`,children:Y.cronExpression??`-`})]}),(0,_.jsxs)(`div`,{children:[u(`lastExecution`),(0,_.jsx)(`span`,{className:`text-foreground`,children:y(Y.lastRunAt)})]}),(0,_.jsxs)(`div`,{children:[u(`nextExecution`),(0,_.jsx)(`span`,{className:`text-foreground`,children:y(Y.nextRunAt)})]}),(0,_.jsxs)(`div`,{children:[u(`executionAgent`),(0,_.jsx)(`span`,{className:`text-foreground`,children:Ze(Y.agentId)})]}),Y.projectName?(0,_.jsxs)(`div`,{children:[u(`taskProject`),(0,_.jsx)(`span`,{className:`text-foreground`,children:Y.projectName})]}):null,Y.model?(0,_.jsxs)(`div`,{children:[u(`taskModel`),`:`,(0,_.jsx)(`span`,{className:`text-foreground`,children:ue(Y.model)})]}):null,Y.thinkingLevel?(0,_.jsxs)(`div`,{children:[u(`taskThinkingLevel`),(0,_.jsx)(`span`,{className:`text-foreground`,children:_e.find(e=>e.value===Y.thinkingLevel)?.label()??Y.thinkingLevel})]}):null,(0,_.jsxs)(`div`,{children:[u(`createdAt`),`:`,(0,_.jsx)(`span`,{className:`text-foreground`,children:y(Y.createdAt)})]})]}),Y.runs?.length>0?(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`mb-2 font-medium text-foreground`,children:u(`recentExecutions`)}),(0,_.jsx)(`div`,{className:`space-y-2`,children:Y.runs.slice(0,5).map(e=>(0,_.jsxs)(`details`,{className:`rounded-lg border border-border bg-muted/20 p-2 text-xs text-muted-foreground`,children:[(0,_.jsxs)(`summary`,{className:`cursor-pointer text-foreground`,children:[y(e.startedAt),` · `,e.trigger===`manual`?u(`manualRun`):u(`autoRun`),` · `,Oe(e.status)]}),st(e)]},`${Y.id}:${e.id}`))})]}):null]})}),(0,_.jsx)(`div`,{className:`border-t border-border px-5 py-4`,children:(0,_.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[Y.lastSessionId?(0,_.jsx)(l,{variant:`outline`,onClick:()=>e?.(Y.lastSessionId),children:u(`viewConversation`)}):null,(0,_.jsxs)(l,{variant:`outline`,disabled:!Te(Y),onClick:()=>void $(Y.id,`run`),children:[(0,_.jsx)(ae,{className:`mr-1 size-3.5`}),u(`executeNow`)]}),(0,_.jsxs)(l,{variant:`outline`,disabled:b(Y),onClick:()=>ot(Y),children:[(0,_.jsx)(te,{className:`mr-1 size-3.5`}),u(`editTask`)]}),(0,_.jsxs)(l,{variant:`destructive`,disabled:b(Y),onClick:()=>void $(Y.id,`delete`),children:[(0,_.jsx)(ie,{className:`mr-1 size-3.5`}),u(`deleteTask`)]})]})})]}):(0,_.jsxs)(_.Fragment,{children:[I?(0,_.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:I}):null,m===`tasks`?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`rounded-xl border border-border bg-card p-4`,children:(0,_.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:u(`taskList`)}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u(`tasksCount`,{total:r.length,enabled:Ye})})]})})}),(0,_.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:r.length===0?(0,_.jsx)(`div`,{className:`rounded-lg px-3 py-3 text-center text-xs text-muted-foreground/55 md:col-span-2`,children:u(`noScheduledTasks`)}):r.map(e=>{let n=e.status===`enabled`,r=e.status===`completed`,i=b(e);return(0,_.jsxs)(`div`,{className:`relative cursor-pointer rounded-xl border border-border bg-card p-4 transition-colors hover:bg-muted/15`,onClick:()=>E(e.id),children:[(0,_.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,_.jsx)(`h3`,{className:`truncate text-sm font-medium text-foreground/90`,children:e.title})}),(0,_.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:ye(e.instruction,20)})]}),(0,_.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,onClick:e=>e.stopPropagation(),children:[(0,_.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,disabled:r,className:p(`relative h-6 w-11 rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-60`,n?`bg-emerald-500`:`bg-muted-foreground/30`),onClick:()=>void $(e.id,e.status===`paused`?`resume`:`pause`),title:e.status===`paused`?u(`enable`):u(`pauseTask`),children:(0,_.jsx)(`span`,{className:p(`absolute left-0.5 top-0.5 size-5 rounded-full bg-white shadow transition-transform`,n?`translate-x-5`:`translate-x-0`)})}),(0,_.jsxs)(`div`,{className:`relative`,children:[(0,_.jsx)(l,{variant:`ghost`,size:`icon`,onClick:()=>O(D===e.id?null:e.id),title:u(`moreActions`),children:(0,_.jsx)(ee,{className:`size-4`})}),D===e.id?(0,_.jsxs)(`div`,{className:`absolute right-0 z-20 mt-1 w-36 overflow-hidden rounded-xl border border-border bg-popover py-1 text-sm shadow-quickforge`,children:[(0,_.jsxs)(`button`,{className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50`,disabled:!Te(e),onClick:()=>void $(e.id,`run`),children:[(0,_.jsx)(ae,{className:`size-3.5`}),u(`executeNow`)]}),(0,_.jsxs)(`button`,{className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50`,disabled:i,onClick:()=>ot(e),children:[(0,_.jsx)(te,{className:`size-3.5`}),u(`editTask`)]}),(0,_.jsxs)(`button`,{className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted`,onClick:()=>{O(null),E(e.id)},children:[(0,_.jsx)(re,{className:`size-3.5`}),u(`viewDetails`)]}),(0,_.jsxs)(`button`,{className:`flex w-full items-center gap-2 px-3 py-2 text-left text-destructive hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50`,disabled:i,onClick:()=>void $(e.id,`delete`),children:[(0,_.jsx)(ie,{className:`size-3.5`}),u(`deleteTask`)]})]}):null]})]})]}),(0,_.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,_.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,_.jsx)(t,{className:`size-3`}),e.scheduleRule]}),(0,_.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,_.jsx)(oe,{className:`size-3`}),Ze(e.agentId)]}),(0,_.jsxs)(`span`,{children:[u(`taskExecutionMode`),`:`,Ee(e.executionMode)]}),e.projectName?(0,_.jsxs)(`span`,{children:[u(`taskProject`),e.projectName]}):null]}),(0,_.jsxs)(`div`,{className:`mt-4 grid gap-2 border-t border-border pt-3 text-xs text-muted-foreground sm:grid-cols-2`,children:[(0,_.jsxs)(`span`,{children:[u(`lastExecution`),y(e.lastRunAt)]}),(0,_.jsxs)(`span`,{children:[u(`nextExecution`),y(e.nextRunAt)]})]})]},e.id)})})]}):(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4`,children:[(0,_.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-sm font-medium text-foreground`,children:[(0,_.jsx)(o,{className:`size-4`}),u(`historyFilters`)]}),(0,_.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,_.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[u(`taskName`),(0,_.jsxs)(`select`,{className:`mt-1 h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground`,value:U.taskId,onChange:e=>Z(`taskId`,e.target.value),children:[(0,_.jsx)(`option`,{value:``,children:u(`allTasks`)}),r.map(e=>(0,_.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,_.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[u(`status`),(0,_.jsxs)(`select`,{className:`mt-1 h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground`,value:U.status,onChange:e=>Z(`status`,e.target.value),children:[(0,_.jsx)(`option`,{value:``,children:u(`allStatuses`)}),(0,_.jsx)(`option`,{value:`running`,children:u(`executionRunning`)}),(0,_.jsx)(`option`,{value:`success`,children:u(`executionSuccess`)}),(0,_.jsx)(`option`,{value:`failed`,children:u(`taskFailed`)})]})]}),(0,_.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[u(`triggerType`),(0,_.jsxs)(`select`,{className:`mt-1 h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground`,value:U.trigger,onChange:e=>Z(`trigger`,e.target.value),children:[(0,_.jsx)(`option`,{value:``,children:u(`allTriggers`)}),(0,_.jsx)(`option`,{value:`schedule`,children:u(`autoRun`)}),(0,_.jsx)(`option`,{value:`manual`,children:u(`manualRun`)})]})]}),(0,_.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[u(`startTime`),(0,_.jsx)(`input`,{type:`datetime-local`,className:`mt-1 h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground`,value:U.startedFrom,onChange:e=>Z(`startedFrom`,e.target.value)})]}),(0,_.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[u(`endTime`),(0,_.jsx)(`input`,{type:`datetime-local`,className:`mt-1 h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground`,value:U.startedTo,onChange:e=>Z(`startedTo`,e.target.value)})]}),(0,_.jsxs)(`label`,{className:`block text-xs font-medium text-muted-foreground`,children:[u(`keyword`),(0,_.jsx)(`input`,{className:`mt-1 h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground`,value:U.keyword,onChange:e=>Z(`keyword`,e.target.value),placeholder:u(`keywordPlaceholder`)})]})]}),(0,_.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,_.jsx)(l,{variant:`outline`,onClick:tt,children:u(`reset`)}),(0,_.jsx)(l,{onClick:et,children:u(`query`)})]})]}),(0,_.jsxs)(`div`,{className:`overflow-x-auto rounded-xl border border-border bg-card`,children:[(0,_.jsxs)(`div`,{className:`grid min-w-[600px] grid-cols-[1.3fr_0.7fr_0.7fr_1fr_0.7fr] gap-3 border-b border-border px-4 py-3 text-xs font-medium text-muted-foreground`,children:[(0,_.jsx)(`span`,{children:u(`taskName`)}),(0,_.jsx)(`span`,{children:u(`status`)}),(0,_.jsx)(`span`,{children:u(`triggerType`)}),(0,_.jsx)(`span`,{children:u(`startTime`)}),(0,_.jsx)(`span`,{children:u(`runDuration`)})]}),Re?(0,_.jsx)(`div`,{className:`p-8 text-center text-sm text-muted-foreground`,children:u(`loading`)}):q.runs.length===0?(0,_.jsx)(`div`,{className:`p-8 text-center text-sm text-muted-foreground`,children:u(`noExecutionHistory`)}):q.runs.map(e=>(0,_.jsxs)(`div`,{className:`border-b border-border last:border-b-0`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`grid w-full min-w-[600px] grid-cols-[1.3fr_0.7fr_0.7fr_1fr_0.7fr] gap-3 px-4 py-3 text-left text-sm hover:bg-muted/40`,onClick:()=>{let t=`${e.taskId}:${e.id}`;Ve(Be===t?null:t)},children:[(0,_.jsx)(`span`,{className:`min-w-0 truncate text-foreground`,children:e.taskTitle}),(0,_.jsx)(`span`,{children:(0,_.jsx)(`span`,{className:p(`rounded-full px-2 py-0.5 text-xs`,ke(e.status)),children:Oe(e.status)})}),(0,_.jsx)(`span`,{className:`text-muted-foreground`,children:e.trigger===`manual`?u(`manualRun`):u(`autoRun`)}),(0,_.jsx)(`span`,{className:`text-muted-foreground`,children:y(e.startedAt)}),(0,_.jsx)(`span`,{className:`text-muted-foreground`,children:e.durationMs?`${e.durationMs}ms`:`-`})]}),Be===`${e.taskId}:${e.id}`?(0,_.jsx)(`div`,{className:`border-t border-border bg-muted/20 px-4 py-3`,children:st(e)}):null]},`${e.taskId}:${e.id}`)),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3 text-sm text-muted-foreground`,children:[(0,_.jsx)(`span`,{children:u(`paginationSummary`,{page:q.page,pages:Xe,total:q.total})}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`select`,{className:`h-8 rounded-md border border-input bg-background px-2 text-sm`,value:q.pageSize,onChange:e=>rt(Number(e.target.value)),children:[10,20,50,100].map(e=>(0,_.jsx)(`option`,{value:e,children:u(`pageSize`,{size:e})},e))}),(0,_.jsx)(l,{variant:`outline`,size:`sm`,disabled:q.page<=1,onClick:()=>nt(q.page-1),children:u(`previousPage`)}),(0,_.jsx)(l,{variant:`outline`,size:`sm`,disabled:q.page>=Xe,onClick:()=>nt(q.page+1),children:u(`nextPage`)})]})]})]})]})]})})})]})}export{S as ScheduledTasksPage};