@shawnstack/quickforge 1.5.1 → 1.5.3

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