@shawnstack/quickforge 1.5.3 → 1.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -12
- package/dist/assets/{AgentProfilesPage-BToo_R3Y.js → AgentProfilesPage-nVhgwanY.js} +1 -1
- package/dist/assets/ChatPanelHost-u0K5IWMF.js +242 -0
- package/dist/assets/{PluginsPage-DwzV2vQ4.js → PluginsPage-BVRTC0rz.js} +1 -1
- package/dist/assets/ScheduledTasksPage-D37TE2cM.js +2 -0
- package/dist/assets/{SharedConversationPage-CHE9qABz.js → SharedConversationPage-D5hnzsZC.js} +1 -1
- package/dist/assets/TerminalDock-NvH9esAS.js +2 -0
- package/dist/assets/WorkspaceInspector-DbnO1fei.js +3 -0
- package/dist/assets/{WorkspaceReaderDialog-Bai7v3V0.js → WorkspaceReaderDialog-BcxIbNBq.js} +1 -1
- package/dist/assets/diff-line-counts-N83e7__F.js +10 -0
- package/dist/assets/{icons-DzxBk7tb.js → icons-Uo4Gd-eK.js} +1 -1
- package/dist/assets/index-DiaCCmXE.js +1482 -0
- package/dist/assets/index-KdiXReMI.css +3 -0
- package/dist/assets/{monaco-dMY7_GLO.js → monaco-DtXl4zfe.js} +1 -1
- package/dist/assets/{react-vendor-DsAeMFcm.js → react-vendor-BjDQPVuK.js} +1 -1
- package/dist/assets/useAppTheme-Bm6HIzLF.js +1 -0
- package/dist/favicon.svg +16 -16
- package/dist/index.html +4 -4
- package/dist/pwa-icon-192.png +0 -0
- package/dist/pwa-icon-512.png +0 -0
- package/dist/pwa-maskable-512.png +0 -0
- package/dist/sw.js +1 -1
- package/package.json +2 -1
- package/server/agent-manager.mjs +8 -1
- package/server/index.mjs +76 -6
- package/server/public-api.mjs +196 -0
- package/server/routes/system.mjs +2 -1
- package/server/update-supervisor.mjs +121 -0
- package/dist/assets/ChatPanelHost-BTqhhkWK.js +0 -242
- package/dist/assets/ScheduledTasksPage-Cbm6LVk3.js +0 -2
- package/dist/assets/TerminalDock-Loi8A4pJ.js +0 -2
- package/dist/assets/WorkspaceInspector-Nf5xELW7.js +0 -3
- package/dist/assets/diff-line-counts-CCPYa_e0.js +0 -10
- package/dist/assets/index-Bt_dRvdG.js +0 -1476
- package/dist/assets/index-BzaZg9Br.css +0 -3
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{B as t,Et as n}from"./icons-Uo4Gd-eK.js";import{n as r,t as i}from"./react-vendor-BjDQPVuK.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-DiaCCmXE.js";import{t as b}from"./plugin-api-YfYj_Bd7.js";var x=e(n(),1),S={maxHeight:`28rem`,overflow:`auto`,border:`1px solid color-mix(in oklab, var(--border) 75%, transparent)`,borderRadius:`0.75rem`,background:`color-mix(in oklab, var(--muted) 28%, transparent)`,fontFamily:`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 ee(e){if(!e||typeof e!=`object`)return;let t=e.diff;if(!t||typeof t!=`object`)return;let n=t;return typeof n.text==`string`?n:void 0}function te(e){if(!e||typeof e!=`object`)return e;let t=e,n=t.diff;if(!n||typeof n!=`object`)return e;let{text:r,...i}=n;return{...t,diff:i}}function N(e){if(!e||typeof e!=`object`)return{};let t=e;return{sessionId:typeof t.sessionId==`string`?t.sessionId:void 0,toolCallId:typeof t.toolCallId==`string`?t.toolCallId:void 0}}async function ne(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 re(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 P(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 ie(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 ae(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=${re(e)} style=${s(P(e))}>${e||` `}</div>
|
|
31
|
+
`)}</div>
|
|
32
|
+
</div>
|
|
33
|
+
`}function oe(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 F(e){if(e){if(typeof e.durationMs==`number`)return e.durationMs;if(typeof e.startedAt==`number`)return Date.now()-e.startedAt}}var se=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=oe(n)}};customElements.get(`quickforge-elapsed-time`)||customElements.define(`quickforge-elapsed-time`,se);function ce(e,t){return F(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 le(){return`text-emerald-600 dark:text-emerald-500`}function ue(e){let t=`quickforge-tool-type-icon shrink-0 ${le()}`;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 I(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 de(e){let t=`quickforge-tool-status-icon shrink-0 ${I(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 fe(e,t){return o`
|
|
41
|
+
<span class="shrink-0 inline-flex items-center gap-1.5" title=${f(e)}>
|
|
42
|
+
${de(e)}${ce(t,e)}
|
|
43
|
+
</span>
|
|
44
|
+
`}function pe(e,t,n){if(e!==`run_command`||t!==`running`)return a;let{sessionId:r,toolCallId:i}=N(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(),ne(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 L=`quickforge:preview-artifact`;function me(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 he(e,t){let n=me(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(L,{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 ge(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 R(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function z(e){return Array.isArray(e)?e:[]}function B(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 V=new Map,H=100;function _e(e,t){if(e){if(!V.has(e)&&V.size>=H){let e=V.keys().next().value;e&&V.delete(e)}V.set(e,t)}}var ve=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=ge(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=R(s?.allowedTools),_=z(s?.messages),y=z(s?.tools),b=new Set(R(s?.pendingToolCalls)),x=h(),S=x.showToolDetails?_:B(_),C=x.showToolDetails?T(e):``,w=x.showToolDetails?T(t?.details):``,O=E(t),k=typeof s?.sessionId==`string`?s.sessionId:`${c}:${u}`,A=V.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=>_e(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
|
+
${ue(`run_subagent`)}
|
|
65
|
+
<span class="min-w-0 flex-1 truncate">${j}${u?o`<span class="text-muted-foreground/70"> · ${u}</span>`:``}</span>
|
|
66
|
+
${fe(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>${ce(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 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
|
+
`}}},ye=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=ee(t?.details),m=c?T(p?te(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
|
+
${ue(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
|
+
${ie(this.toolName,p)}
|
|
93
|
+
${he(this.toolName,e)}
|
|
94
|
+
${pe(this.toolName,r,t?.details)}
|
|
95
|
+
${fe(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?ae(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 U(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 W(e,t){let n=U(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 G(e){if(!e)return`text`;try{return JSON.parse(e),`json`}catch{return`text`}}var be=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=W(this.toolName,t?.details)??U(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
|
+
${ue(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
|
+
${fe(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=${G(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
|
+
`}}},xe=new Set;function Se(e){for(let t of e){if(!D(t)||typeof t.name!=`string`||!U(t.name)||xe.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 be(t.name,e)),xe.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 ye(e,t));l(`run_subagent`,new ve);function Ce(e=[]){return Se(e),e}function K(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();if(!e||!t)return;let n=e.scrollHeight-e.clientHeight;if(Math.abs(e.scrollTop-n)<=1){r=e.scrollTop;return}e.scrollTop=e.scrollHeight,r=e.scrollTop},g=()=>{n===void 0&&(n=window.requestAnimationFrame(()=>{n=void 0,h(),window.requestAnimationFrame(h)}))},_=()=>{t=!0,u(!0),g()},v=()=>{let e=c();if(!e)return;let n=e.scrollTop,i=n<r-1,a=i&&d();if(i&&t&&!a&&!l(e)){r=n,g();return}a?f():l(e)&&(t=!0,u(!0)),r=n},y=e=>{e.deltaY<0&&p()},b=e=>{e.target===e.currentTarget&&m()},x=e=>{(e.key===`ArrowUp`||e.key===`PageUp`||e.key===`Home`)&&p()},S=e=>{i=e.touches[0]?.clientY},C=e=>{let t=e.touches[0]?.clientY;t===void 0||i===void 0||(t>i+1&&p(),i=t)};return{get isEnabled(){return t},enable:_,disable:f,scheduleScrollToBottom:g,setup:()=>{let n=c();if(!n||s)return;r=n.scrollTop,n.addEventListener(`scroll`,v,{passive:!0}),n.addEventListener(`wheel`,y,{passive:!0}),n.addEventListener(`pointerdown`,b,{passive:!0}),n.addEventListener(`keydown`,x),n.addEventListener(`touchstart`,S,{passive:!0}),n.addEventListener(`touchmove`,C,{passive:!0}),s=new ResizeObserver(()=>{t&&g()}),s.observe(n);let i=n.querySelector(`.max-w-3xl`);i&&s.observe(i);let a=e.querySelector(`.quickforge-composer-dock`);a&&s.observe(a),_()},cleanup:()=>{let e=c();e?.removeEventListener(`scroll`,v),e?.removeEventListener(`wheel`,y),e?.removeEventListener(`pointerdown`,b),e?.removeEventListener(`keydown`,x),e?.removeEventListener(`touchstart`,S),e?.removeEventListener(`touchmove`,C),s?.disconnect(),s=void 0,n!==void 0&&(window.cancelAnimationFrame(n),n=void 0)}}}function 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,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}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)(t,{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" 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>`,ot=`<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>`,st=`<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>`,ct=`<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>`,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" 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>`,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="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>`,dt=`<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>`,ft=`<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>`,pt=`<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>`,mt=`<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>`,ht=`<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>`,gt=`<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>`,_t=`<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 vt(e){return f(e===`full-access`?`agentAccessFullLabel`:`agentAccessDefaultLabel`)}function yt(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 bt(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=`
|
|
167
|
+
<span class="quickforge-agent-access-check-slot">${r?gt:``}</span>
|
|
168
|
+
<span class="quickforge-agent-access-option-icon-wrap">${e===`full-access`?ht:mt}</span>
|
|
169
|
+
<span class="quickforge-agent-access-item-label"></span>
|
|
170
|
+
`,i.querySelector(`.quickforge-agent-access-item-label`).textContent=vt(e),i.onpointerdown=t=>{t.preventDefault(),t.stopPropagation(),n(e)},i}function xt(e){let{panel:t,trigger:n,agentAccessMode:r,onAccessModeChange:i,dismissComposerMenus:a}=e;if(document.querySelector(`.quickforge-agent-access-menu`)){yt(t);return}a(),yt(t);let o=document.createElement(`div`);o.className=`quickforge-agent-access-menu`,o.setAttribute(`role`,`menu`),o.setAttribute(`aria-label`,f(`agentAccessMenuLabel`));let s=e=>{yt(t),e!==r&&i(e)};o.append(bt(`default`,r,s),bt(`full-access`,r,s));let c=()=>{let e=n.getBoundingClientRect(),t=Math.min(196,window.innerWidth-24);o.style.width=`${t}px`;let r=o.offsetHeight||96,i=Math.max(12,Math.min(e.left,window.innerWidth-t-12)),a=Math.max(12,e.top-r-8);o.style.left=`${i}px`,o.style.top=`${a}px`},l=e=>{if(e.type===`resize`||e.type===`scroll`){c();return}if(e instanceof KeyboardEvent){if(e.key!==`Escape`)return;e.preventDefault()}else{let t=e.target;if(o.contains(t)||n.contains(t))return}yt(t)};o.__quickforgeDismissHandler=l,o.addEventListener(`pointerdown`,e=>e.stopPropagation()),document.addEventListener(`pointerdown`,l,!0),document.addEventListener(`keydown`,l,!0),window.addEventListener(`resize`,l,!0),window.addEventListener(`scroll`,l,!0),document.body.append(o),c(),n.setAttribute(`aria-expanded`,`true`)}function St(e){let{panel:t,leftControls:n,agentAccessMode:r,onAccessModeChange:i,dismissComposerMenus:a}=e;n.classList.add(`quickforge-composer-left-controls`),t.querySelector(`.quickforge-yolo-inline`)?.remove();let o=vt(r),s=f(r===`full-access`?`agentAccessFullTitle`:`agentAccessDefaultTitle`),c=`${r===`full-access`?ht:mt}<span class="quickforge-agent-access-label"></span>${_t}`,l=`quickforge-agent-access-inline inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 text-xs font-medium text-muted-foreground${r===`full-access`?` quickforge-agent-access-inline-full`:``}`,u=n.querySelector(`.quickforge-agent-access-inline`),d=e=>{we(e,c),e.querySelector(`.quickforge-agent-access-label`).textContent=o,e.title=s,e.setAttribute(`aria-label`,s),e.setAttribute(`aria-haspopup`,`menu`),e.setAttribute(`aria-expanded`,document.querySelector(`.quickforge-agent-access-menu`)?`true`:`false`),e.dataset.quickforgeAgentAccessMode=r,e.className=l,e.onpointerdown=n=>{n.preventDefault(),n.stopPropagation(),xt({panel:t,trigger:e,agentAccessMode:r,onAccessModeChange:i,dismissComposerMenus:a})},e.onclick=e=>{e.preventDefault(),e.stopPropagation()},e.onkeydown=n=>{n.key!==`Enter`&&n.key!==` `&&n.key!==`ArrowDown`||(n.preventDefault(),xt({panel:t,trigger:e,agentAccessMode:r,onAccessModeChange:i,dismissComposerMenus:a}))}};if(u)d(u);else{let e=document.createElement(`button`);e.type=`button`,d(e),n.append(e)}let p=n.querySelector(`.quickforge-agent-access-inline`),m=n.querySelector(`.quickforge-plan-inline`);p&&m&&p.nextSibling!==m&&n.insertBefore(m,p.nextSibling)}var Ct=[{mention:`Documents`,nameKey:`pluginOpenaiDocumentsName`,descriptionKey:`pluginOpenaiDocumentsDescription`,pluginName:`openai-documents`,icon:dt},{mention:`Spreadsheets`,nameKey:`pluginOpenaiSpreadsheetsName`,descriptionKey:`pluginOpenaiSpreadsheetsDescription`,pluginName:`openai-spreadsheets`,icon:ft},{mention:`Presentations`,nameKey:`pluginOpenaiPresentationsName`,descriptionKey:`pluginOpenaiPresentationsDescription`,pluginName:`openai-presentations`,icon:pt}];function wt(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 Tt(e,t){e.querySelectorAll(`.quickforge-native-attachment-hidden`).forEach(e=>{t.contains(e)||e.classList.remove(`quickforge-native-attachment-hidden`)})}function Et(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 Dt(e,t){let n=e.querySelector(`input[type="file"]`);if(n){n.click();return}Et(t)?.click()}function Ot({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=`
|
|
171
|
+
<span class="quickforge-plus-popover-item-icon">${t}</span>
|
|
172
|
+
<span class="quickforge-plus-popover-item-main">
|
|
173
|
+
<span class="quickforge-plus-popover-item-label"></span>
|
|
174
|
+
${r?`<span class="quickforge-plus-popover-item-description"></span>`:``}
|
|
175
|
+
</span>
|
|
176
|
+
`,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 kt(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(Ot({icon:lt,label:f(`composerAddAttachment`),onSelect:()=>{wt(n),Dt(r,i)}}),Ot({icon:ut,label:f(`composerAddPlugins`),onSelect:()=>kt(e,`plugins`)}));else{let t=Ot({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:()=>kt(e,`main`)});c.append(t);for(let e of Ct)c.append(Ot({icon:e.icon,label:f(e.nameKey),description:f(e.descriptionKey),pluginName:e.pluginName,onSelect:()=>{a(e.mention),wt(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)||wt(n)},document.addEventListener(`pointerdown`,c.__quickforgeDismissHandler,!0),n.querySelector(`.quickforge-plus-inline`)?.setAttribute(`aria-expanded`,`true`)}function At(e){let{panel:t,editor:n,leftControls:r}=e;Tt(n,r),Et(r)?.classList.add(`quickforge-native-attachment-hidden`);let i=r.querySelector(`.quickforge-plus-inline`),a=n=>{n.type=`button`,we(n,ct),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`)?wt(t):kt(e,`main`)},n.onclick=e=>{e.preventDefault(),e.stopPropagation()}};if(i){a(i);return}let o=document.createElement(`button`);a(o),r.prepend(o)}function jt(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 Mt(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=`· ${jt(n?.thinkingLevel)}`:delete i.dataset.quickforgeThinkingLevel)}function Nt(e,t,n){let r=e?.querySelector(`textarea`);if(!r)return;let i=r;i.__quickforgePlanModeHandler&&i.removeEventListener(`keydown`,i.__quickforgePlanModeHandler,!0),i.__quickforgePlanModeHandler=e=>{e.isComposing||e.key===`Process`||e.key!==`Tab`||!e.shiftKey||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),n())},i.addEventListener(`keydown`,i.__quickforgePlanModeHandler,!0),e&&(e.dataset.quickforgePlanMode=String(t))}function Pt(e){let{panel:t,leftControls:n,planMode:r,onTogglePlanMode:i}=e,a=f(`planModeEnabledTitle`),o=`${ot}${st}<span>${f(`planModeLabel`)}</span>`,s=e=>{e.preventDefault(),e.stopPropagation(),i()},c=e=>{e.key!==`Enter`&&e.key!==` `||s(e)},l=t.querySelector(`.quickforge-plan-inline`),u=e=>{we(e,o),e.title=a,e.setAttribute(`aria-label`,a),e.setAttribute(`aria-pressed`,String(r)),e.className=`quickforge-plan-inline inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 text-xs font-medium text-muted-foreground`,e.onpointerdown=s,e.onclick=e=>{e.preventDefault(),e.stopPropagation()},e.onkeydown=c};if(!r)l?.remove();else if(l)u(l);else{let e=document.createElement(`button`);e.type=`button`,u(e);let t=n.querySelector(`.quickforge-agent-access-inline`);t?n.insertBefore(e,t.nextSibling):n.append(e)}}function Ft(e){let{rightControls:t,isStreaming:n,abort:r,removeCommandSuggestions:i}=e,a=t.querySelector(`button:last-child`);if(!a)return;let o=()=>{a.__quickforgeStopHandler&&=(a.removeEventListener(`pointerdown`,a.__quickforgeStopHandler,!0),a.removeEventListener(`click`,a.__quickforgeStopHandler,!0),void 0)};if(n())a.disabled=!1,a.classList.remove(`quickforge-send-button`),a.classList.add(`quickforge-stop-button`),a.title=`Stop`,a.setAttribute(`aria-label`,`Stop`),delete a.dataset.quickforgeSendIcon,K(a,`<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>`),a.__quickforgeStopHandler||(a.__quickforgeStopHandler=e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),i(),r()},a.addEventListener(`pointerdown`,a.__quickforgeStopHandler,!0),a.addEventListener(`click`,a.__quickforgeStopHandler,!0));else if(o(),a.classList.remove(`quickforge-stop-button`),a.classList.add(`quickforge-send-button`),a.dataset.quickforgeSendIcon!==`arrow-up`){a.dataset.quickforgeSendIcon=`arrow-up`,K(a,`<svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 19V5"/><path d="m5 12 7-7 7 7"/></svg>`);let e=a.querySelector(`svg`)?.parentElement;e&&e!==a&&e.style.transform&&(e.style.transform=``)}}function It(e){let{editor:t,onInput:n,onFilesChange:r,removeCommandSuggestions:i,updateCommandSuggestions:a,removeCapabilitySuggestions:o,updateCapabilitySuggestions:s,onBeforeSend:c}=e;if(!t)return;t.onInput=e=>{n(e),a(e),s(e)},t.onFilesChange=e=>{r(e?[...e]:[])};let l=t.onSend;l&&l!==t.__quickforgePlanWrappedOnSend&&(t.__quickforgePlanBaseOnSend=l);let u=t.__quickforgePlanBaseOnSend;if(u){let e=(e,t)=>{let n=String(e??``);n.trim().length>0&&c?.(n),i(),o(),u(n,t)};t.__quickforgePlanWrappedOnSend=e,t.onSend=e}a(),s()}function Lt(e){let t=e.querySelector(`message-editor`),n=t?.querySelector(`textarea`);return{text:t?.value??n?.value??``,attachments:t?.attachments?[...t.attachments]:[]}}function Rt(e,t,n){let r=Lt(e);q(r)?t.set(n,r):t.delete(n)}function zt(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)}function Y(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function Bt(e){return e.split(`
|
|
177
|
+
`).map(e=>{let t=Y(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(`
|
|
178
|
+
`)}function Vt(e,t){let n=e.split(`
|
|
179
|
+
`),r=t.split(`
|
|
180
|
+
`),i=[];for(let e of n)i.push(`<span style="color:rgb(153 27 27);background:rgba(239,68,68,.12);display:block;">- ${Y(e)}</span>`);for(let e of r)i.push(`<span style="color:rgb(22 101 52);background:rgba(34,197,94,.14);display:block;">+ ${Y(e)}</span>`);return i.join(`
|
|
181
|
+
`)}var Ht=`.quickforge-approval-card`;function Ut(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 Wt(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 Gt(e,t){let n=Wt(e,t);return`
|
|
182
|
+
${n?`<div class="text-xs text-muted-foreground mb-1">${Y(f(`toolArgsSummary`))}: ${Y(n)}</div>`:``}
|
|
183
|
+
<div class="text-xs bg-background border rounded p-2 text-muted-foreground">${Y(f(`toolDetailsHidden`))}</div>
|
|
184
|
+
`}function Kt(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;qt(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=Ut(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=`
|
|
185
|
+
<div class="rounded-md border bg-background/70 p-2 text-xs text-muted-foreground">
|
|
186
|
+
<div><span class="font-medium text-foreground">Source:</span> MCP</div>
|
|
187
|
+
<div><span class="font-medium text-foreground">Server:</span> ${Y(l.serverName)}</div>
|
|
188
|
+
<div><span class="font-medium text-foreground">Tool:</span> ${Y(l.toolName)}</div>
|
|
189
|
+
</div>
|
|
190
|
+
${g?`<pre class="mt-2 text-xs bg-background border rounded p-2 max-h-40 overflow-auto font-mono whitespace-pre-wrap">${Y(JSON.stringify(r,null,2))}</pre>`:Gt(t,r)}
|
|
191
|
+
`;else if(t===`write_file`){let e=String(r.path??``),t=String(r.content??``),n=t.length>800;m.innerHTML=`
|
|
192
|
+
<div class="text-xs text-muted-foreground mb-1">📁 ${Y(e)}</div>
|
|
193
|
+
<pre class="text-xs bg-background border rounded p-2 max-h-40 overflow-auto font-mono whitespace-pre-wrap">${Bt(t.slice(0,800))}${n?`\n${Y(f(`toolApprovalTruncated`))}`:``}</pre>
|
|
194
|
+
`}else if(t===`edit_file`){let e=String(r.path??``),t=Vt(String(r.oldText??``),String(r.newText??``));m.innerHTML=`
|
|
195
|
+
<div class="text-xs text-muted-foreground mb-1">📁 ${Y(e)}</div>
|
|
196
|
+
<pre class="text-xs bg-background border rounded p-2 max-h-40 overflow-auto font-mono whitespace-pre-wrap">${t}</pre>
|
|
197
|
+
`}else if(t===`run_command`){let e=String(r.command??``);m.innerHTML=`
|
|
198
|
+
<div class="text-xs text-muted-foreground mb-1">⏱️ ${f(`toolApprovalTimeout`)}: ${Y(`30m`)}</div>
|
|
199
|
+
<pre class="text-xs bg-background border rounded p-2 max-h-40 overflow-auto font-mono whitespace-pre-wrap">$ ${Y(e)}</pre>
|
|
200
|
+
`}else typeof r.description==`string`?m.innerHTML=`<div class="text-xs bg-background border rounded p-2 text-muted-foreground">${Y(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">${Y(JSON.stringify(r,null,2))}</pre>`:Gt(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 qt(e){e.querySelectorAll(Ht).forEach(e=>e.remove())}function Jt(e,t,n){let r=f(`copied`),i=Number(e.dataset.quickforgeCopyFeedbackTimer);i&&window.clearTimeout(i),K(e,nt),e.title=r,e.setAttribute(`aria-label`,r),e.style.color=`rgb(5 150 105)`;let a=window.setTimeout(()=>{K(e,n),e.title=t,e.setAttribute(`aria-label`,t),e.style.color=``,delete e.dataset.quickforgeCopyFeedbackTimer},1200);e.dataset.quickforgeCopyFeedbackTimer=String(a)}function Yt(e){return e.role===`user`||e.role===`user-with-attachments`||e.role===`assistant`}function Xt(e){let t=e.querySelector(`message-list`);return t?Array.from(t.querySelectorAll(`user-message, assistant-message`)).filter(e=>e.closest(`message-list`)===t):[]}function Zt(e,t,n,r){let i=Xt(e),a=0;for(let e=0;e<t.length;e++)if(Yt(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 Qt(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 $t(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),Jt(o,f(`contextCompactedCopySummary`),tt)})}function en(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?Qt(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?`
|
|
201
|
+
<details class="quickforge-context-compaction-details">
|
|
202
|
+
<summary class="quickforge-context-compaction-summary">
|
|
203
|
+
<div class="quickforge-context-compaction-line"></div>
|
|
204
|
+
<div class="quickforge-context-compaction-pill">
|
|
205
|
+
<span class="quickforge-context-compaction-dot" aria-hidden="true"></span>
|
|
206
|
+
<span><strong>${Y(f(`contextCompactedLabel`))}</strong> · ${Y(f(`contextCompactedTimelineLabel`))} · <span class="quickforge-context-compaction-toggle-label"></span></span>
|
|
207
|
+
</div>
|
|
208
|
+
<div class="quickforge-context-compaction-line"></div>
|
|
209
|
+
</summary>
|
|
210
|
+
<div class="quickforge-context-compaction-card">
|
|
211
|
+
<div class="quickforge-context-compaction-card-header">
|
|
212
|
+
<span>${Y(f(`contextCompactedSummaryTitle`))}</span>
|
|
213
|
+
<button type="button" class="quickforge-context-compaction-copy" data-quickforge-action="copy-compact-summary">${tt}<span>${Y(f(`contextCompactedCopySummary`))}</span></button>
|
|
214
|
+
</div>
|
|
215
|
+
<pre class="quickforge-context-compaction-text">${Y(c)}</pre>
|
|
216
|
+
</div>
|
|
217
|
+
</details>
|
|
218
|
+
`:`
|
|
219
|
+
<div class="quickforge-context-compaction-summary" role="separator">
|
|
220
|
+
<div class="quickforge-context-compaction-line"></div>
|
|
221
|
+
<div class="quickforge-context-compaction-pill">
|
|
222
|
+
<span class="quickforge-context-compaction-dot" aria-hidden="true"></span>
|
|
223
|
+
<span><strong>${Y(f(`contextCompactedLabel`))}</strong> · ${Y(f(`contextCompactedTimelineLabel`))}</span>
|
|
224
|
+
</div>
|
|
225
|
+
<div class="quickforge-context-compaction-line"></div>
|
|
226
|
+
</div>
|
|
227
|
+
`),c&&$t(u,c,l),Zt(t,a,s,u)}var tn=new Set([`bash`,`sh`,`shell`,`zsh`,`fish`,`cmd`,`bat`,`batch`,`powershell`,`ps1`,`terminal`,`console`]),nn=/\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,rn=/<\s*(script|foreignObject)\b|\son[a-z]+\s*=|javascript\s*:/i;function an(e,t,n){let r=f(`copied`),i=Number(e.dataset.quickforgeCopyFeedbackTimer);i&&window.clearTimeout(i),K(e,nt),e.title=r,e.setAttribute(`aria-label`,r),e.style.color=`rgb(5 150 105)`;let a=window.setTimeout(()=>{K(e,n),e.title=t,e.setAttribute(`aria-label`,t),e.style.color=``,delete e.dataset.quickforgeCopyFeedbackTimer},1200);e.dataset.quickforgeCopyFeedbackTimer=String(a)}function on(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),K(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 sn(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 cn(e){return e.replace(/\r\n/g,`
|
|
228
|
+
`).split(`
|
|
229
|
+
`).map(e=>e.replace(/^\s*\$\s+/,``).replace(/^\s*>\s+/,``).replace(/^\s*PS\s+[^>\n]+>\s+/i,``)).join(`
|
|
230
|
+
`).trim()}function ln(e){return e.split(`
|
|
231
|
+
`).map(e=>e.trim()).filter(Boolean).length}function un(e){let t=String(e.language??e.getAttribute(`language`)??``).trim().toLowerCase();return tn.has(t)}function dn(e){return String(e.language??e.getAttribute(`language`)??``).trim().toLowerCase()===`svg`}function fn(e){let t=e.trim();return/^<svg[\s>]/i.test(t)&&/<\/svg>\s*$/i.test(t)&&!rn.test(t)}function pn(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}function mn(){let e=document.querySelector(`.quickforge-svg-code-lightbox`);e?.quickforgeCleanup?.(),e?.remove()}function hn(e){mn();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=()=>mn(),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 gn(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 _n(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 vn(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 yn(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 bn(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`),K(r,n),r}function xn(e=document,t){e.querySelectorAll(`.quickforge-svg-code-menu[open]`).forEach(e=>{e!==t&&(e.open=!1)})}var Sn=!1;function Cn(){Sn||(Sn=!0,document.addEventListener(`pointerdown`,e=>{e.target?.closest(`.quickforge-svg-code-menu`)||xn(document)},!0),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&xn(document)}))}function wn(e,t){Cn();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=bn(`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=bn(`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=bn(`copy-svg-code`,f(`copySvgSource`),tt),c=bn(`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&&xn(e.closest(`markdown-block`)??document,a)})),o&&(o.onclick=()=>{yn(e,`preview`),u()}),s&&(s.onclick=()=>{yn(e,`source`),u()}),c&&(c.onclick=async()=>{await _(t),an(c,f(`copySvgSource`),tt)}),l&&(l.onclick=()=>{gn(`quickforge-svg-${Date.now()}.svg`,t,`image/svg+xml;charset=utf-8`),u()})}function Tn(e,t){e.querySelectorAll(`assistant-message markdown-block code-block`).forEach(e=>{if(!dn(e)){vn(e);return}if(t)return;let n=sn(e).trim();if(!n||!fn(n)){vn(e);return}let r=_n(n);if(e.querySelector(`[data-quickforge-svg-preview="true"]`)&&e.dataset.quickforgeSvgPreviewSource===r){wn(e,n),yn(e,e.dataset.quickforgeSvgMode===`source`?`source`:`preview`);return}let i=e.querySelector(`:scope > div > div:first-child`);if(!i)return;vn(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=pn(n),o.title=f(`svgEnlargePreview`),o.addEventListener(`click`,()=>hn(o.src)),a.replaceChildren(o),i.after(a),wn(e,n),e.dataset.quickforgeSvgPreviewSource=r,yn(e,e.dataset.quickforgeSvgMode===`source`?`source`:`preview`)})}function En(e,t){e.querySelectorAll(`assistant-message markdown-block code-block`).forEach(e=>{let n=e.querySelector(`[data-quickforge-action="execute-markdown-command"]`);if(!un(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=cn(sn(e));if(!r){n?.remove(),delete e.dataset.quickforgeCommand;return}e.dataset.quickforgeCommand=r;let i=f(`executeInTerminal`),a=n??on(`execute-markdown-command`,i,`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polygon points="6 3 20 12 6 21 6 3"/></svg>`,()=>{let t=cn(sn(e));t&&window.dispatchEvent(new CustomEvent(`quickforge:execute-markdown-command`,{detail:{command:t,confirm:ln(t)>1,dangerous:nn.test(t)}}))});if(a.title=i,a.setAttribute(`aria-label`,i),a.disabled=t,a.className=`pointer-events-auto inline-flex size-8 items-center justify-center rounded-md text-emerald-600 transition-colors hover:bg-emerald-500/10 hover:text-emerald-700 disabled:cursor-not-allowed disabled:opacity-40 dark:text-emerald-400 dark:hover:text-emerald-300`,!n){let t=e.querySelector(`:scope > div > div:first-child`),n=t?.querySelector(`copy-button`);if(t&&n){let e=document.createElement(`div`);e.className=`flex items-center gap-1`,n.before(e),e.appendChild(n),e.appendChild(a)}}})}var Dn=`.quickforge-process-group`,X=`.quickforge-process-body`,On=`thinking-block, tool-message, streaming-message-container`,kn=`thinking-block, tool-message, markdown-block, streaming-message-container`,An=`data-quickforge-process-final-summary`,jn=`data-quickforge-process-folded`,Mn=500,Nn=new WeakMap;function Pn(e){let t=Nn.get(e);return t||(t=new Map,Nn.set(e,t)),t}function Fn(e,t,n){let r=Pn(e);if(r.set(t,n),r.size<=Mn)return;let i=r.keys().next().value;i&&r.delete(i)}function In(e,t){return`turn:${t}:started:${Bn(e[0]?.message?.timestamp)??`unknown`}`}function Ln(e,t,n){let r=t.dataset.quickforgeProcessKey;t.dataset.quickforgeProcessKey=n;let i=Pn(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 Rn(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function zn(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function Bn(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 Vn(e){if(!Rn(e))return;let t=e.details;if(!Rn(t))return;let n=t.quickforgeTiming;if(Rn(n))return{startedAt:zn(n.startedAt),finishedAt:zn(n.finishedAt),durationMs:zn(n.durationMs)}}function Hn(e){let t=Vn(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 Un(e){return Vn(e.result)?.startedAt}function Wn(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 Gn(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=>Bn(e.message?.timestamp)),...o.map(Un)].filter(e=>e!==void 0),c=o.map(Hn).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=Bn(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?Wn(Math.max(0,u-l)):``,p=f(a===`error`?`processFailed`:a===`aborted`?`processAborted`:i?`processing`:`processed`);return d?`${p} ${d}`:p}function Kn(e){let t=e.querySelector(`${kn}, ${Dn}`);return t?.closest(`.px-4.flex.flex-col`)??t?.parentElement??null}function qn(){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=`
|
|
232
|
+
<span class="quickforge-process-label"></span>
|
|
233
|
+
<span class="quickforge-process-chevron" aria-hidden="true">
|
|
234
|
+
<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>
|
|
235
|
+
</span>
|
|
236
|
+
`;let n=document.createElement(`div`);return n.className=`quickforge-process-body`,e.append(t,n),e}function Jn(e){let t=e.querySelector(Dn);if(t)return t;let n=Kn(e);if(!n)return null;let r=qn();return n.insertBefore(r,n.firstElementChild),r}function Yn(e,t,n,r,i){Ln(e,r,t);let a=r.querySelector(X),o=r.querySelector(`.quickforge-process-summary`),s=r.querySelector(`.quickforge-process-label`);if(!a||!o||!s)return;let c=Gn(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),Fn(e,t,i),o.setAttribute(`aria-expanded`,String(i)),o.setAttribute(`aria-label`,f(i?`collapseProcess`:`expandProcess`))}}function Xn(e){return Array.from(e.querySelectorAll(`markdown-block`)).filter(e=>!e.closest(On))}function Zn(e){let t=e.filter(e=>(e.textContent??``).trim().length>0);return t[t.length-1]??e[e.length-1]??null}function Z(e,t,n){if(n){e.hasAttribute(t)||e.setAttribute(t,`true`);return}e.hasAttribute(t)&&e.removeAttribute(t)}function Qn(e,t){if(t)return null;let n=Xn(e);return Zn(n.filter(e=>e.hasAttribute(An)))||Zn(n.filter(e=>!e.closest(X)))||Zn(n)}function $n(e,t){Xn(e).forEach(e=>{e===t?(Z(e,An,!0),Z(e,jn,!1)):Z(e,An,!1)})}function er(e){return e.length>1||e.some(e=>!!e.querySelector(On))}function tr(e,t,n){return e===t?!1:e.tagName.toLowerCase()===`markdown-block`?n:!0}function nr(e,t,n){return e.some(e=>Array.from(e.querySelectorAll(kn)).some(e=>tr(e,t,n)))}function rr(e,t){return t?.closest(X)?(e.after(t),Z(t,jn,!1),Z(t,An,!0),!0):!1}function ir(e){return(e.querySelector(X)?.childElementCount??0)>0}function ar(e){for(let t of e)t.classList.remove(`quickforge-process-source-empty`),t.querySelectorAll(Dn).forEach(e=>{let t=e.querySelector(X);t&&Array.from(t.children).forEach(t=>{t instanceof HTMLElement&&(Z(t,jn,!1),Z(t,An,!1)),e.parentElement?.insertBefore(t,e)}),e.remove()}),Xn(t).forEach(e=>{Z(e,jn,!1),Z(e,An,!1)})}function or(e,t,n,r){let i=t.querySelector(X);if(!i)return!1;let a=!1;for(let o of e)o.querySelectorAll(Dn).forEach(e=>{let n=e.querySelector(X);n&&n!==i&&Array.from(n.children).forEach(e=>{i.append(e),a=!0}),e!==t&&e.remove()}),o.querySelectorAll(kn).forEach(e=>{tr(e,n,r)&&(e.closest(X)||(Z(e,jn,!0),i.append(e),a=!0))});return rr(t,n),a||ir(t)}function sr(e,t){for(let n of e){if(n===t){n.classList.remove(`quickforge-process-source-empty`);continue}let e=!!n.querySelector(`markdown-block, thinking-block, tool-message, .quickforge-process-group, .quickforge-approval-card`);n.classList.toggle(`quickforge-process-source-empty`,!e)}}function cr(e){let t=0,n=0;for(let r of e)t+=r.querySelectorAll(kn).length,n+=r.querySelectorAll(`tool-message`).length;return`${e.length}:${t}:${n}`}function lr(e,t,n,r,i){if(t.length===0)return;let a=t[t.length-1],o=In(t,r),s=a.querySelector(Dn);if(n){s&&ar(t);return}let c=cr(t);if(i&&s&&s.dataset.quickforgeProcessFp===c)return;let l=er(t),u=l?Qn(a,n):null;if(l&&$n(a,u),!nr(t,u,l)){s&&(rr(s,u),ar(t));return}let d=Jn(a);if(d){if(!or(t,d,u,l)||!ir(d)){d.remove();return}d.dataset.quickforgeProcessFp=c,Yn(e,o,t,d,n),sr(t,a)}}function ur(e,t,n){let r=t[t.length-1]?.tagName.toLowerCase()===`assistant-message`,i=[],a=[];for(let e of t){if(e.tagName.toLowerCase()===`user-message`){a.length>0&&i.push(a),a=[];continue}a.push(e)}a.length>0&&i.push(a),i.forEach((t,a)=>{let o=n&&r&&a===i.length-1;lr(e,t,o,a,n&&!o)})}var dr=/[A-Za-z]:[\\/][^\s"'<>`]+|(?:\/Users|\/home|\/workspace|\/mnt|\/Volumes)\/[^\s"'<>`]+/g,fr=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`)`,`]`,`}`,`>`,`。`,`,`,`;`,`:`,`!`,`?`,`)`,`】`,`》`]),pr=[`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 mr(e){let t=e.length;for(;t>0&&fr.has(e[t-1]);)--t;return{path:e.slice(0,t),suffix:e.slice(t)}}function hr(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 gr(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.textContent??``;if(!dr.test(t))return NodeFilter.FILTER_REJECT;dr.lastIndex=0;let n=e.parentElement;return!n||n.closest(pr)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),r=n.nextNode();for(;r;)t.push(r),r=n.nextNode();return t}function _r(e,t){let n=e.textContent??``;dr.lastIndex=0;let r,i=0,a=document.createDocumentFragment(),o=!1;for(;r=dr.exec(n);){let e=r[0],{path:s,suffix:c}=mr(e);if(!s)continue;let l=r.index,u=l+e.length;l>i&&a.append(document.createTextNode(n.slice(i,l))),a.append(hr(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 vr(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=>{gr(e).forEach(e=>_r(e,n))}),e.dataset.quickforgeLocalPathSignature=o)}function yr(e,t,n){let r=f(`copied`),i=Number(e.dataset.quickforgeCopyFeedbackTimer);i&&window.clearTimeout(i),K(e,nt),e.title=r,e.setAttribute(`aria-label`,r),e.style.color=`rgb(5 150 105)`;let a=window.setTimeout(()=>{K(e,n),e.title=t,e.setAttribute(`aria-label`,t),e.style.color=``,delete e.dataset.quickforgeCopyFeedbackTimer},1200);e.dataset.quickforgeCopyFeedbackTimer=String(a)}function br(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),K(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 xr(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 Sr(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`)){xr(t);return}xr(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=()=>xr(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 Cr(e){let t=document.createElement(`span`);t.className=`quickforge-rollback-action`;let n=br(`rollback`,f(`rollback`),rt,t=>{Sr({panel:e.panel,button:t,messageIndex:e.messageIndex,title:e.title,description:e.description,onConfirm:e.onConfirm})});return n.disabled=e.isDisabled,n.setAttribute(`aria-haspopup`,`dialog`),n.setAttribute(`aria-expanded`,`false`),t.append(n),t}function wr(e){return e.querySelector(`message-list`)}function Tr(e){let t=wr(e);return t?Array.from(t.querySelectorAll(`user-message, assistant-message`)).filter(e=>e.closest(`message-list`)===t):[]}function Er(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=Tr(t),b=e=>{let t=f(`copy`);return br(`copy`,t,tt,async n=>{let r=e();if(r)try{await i(r),yr(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&&vr(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&&xr(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()&&xr(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=br(`retry`,f(`retry`),at,()=>{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=br(`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=Cr({panel:t,messageIndex:d.index,isDisabled:r(),title:m,description:h,onConfirm:a});S.append(e)}if(!u&&_&&d.index===_.index){let e=br(`retry`,f(`retry`),at,()=>{o(d.index)});e.disabled=r(),S.append(e)}}e.append(S)}),xn(t),ur(t,v,r()),Tn(t,r()),d?En(t,r()):t.querySelectorAll(`[data-quickforge-action="execute-markdown-command"]`).forEach(e=>e.remove())}function Dr(e){return e.role===`user`||e.role===`user-with-attachments`||e.role===`assistant`}function Or(e){return e.role===`user`||e.role===`user-with-attachments`}function kr(e){return e.role===`assistant`?p(e).trim().length>0:!1}function Ar(e){return e.querySelector(`message-list`)}function jr(e){let t=Ar(e);return t?Array.from(t.querySelectorAll(`user-message, assistant-message`)).filter(e=>e.closest(`message-list`)===t):[]}var Mr=`.quickforge-assistant-waiting`;function Nr(e){e.querySelectorAll(Mr).forEach(e=>e.remove())}function Pr(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 Fr(e){let{panel:t,getMessages:n,isStreaming:r,isActive:i}=e,a=t.querySelector(Mr);if(!r()||!i)return Nr(t),!1;let o=Ar(t),s=n(),c=s.map((e,t)=>({message:e,index:t})).filter(({message:e})=>Dr(e)),l=(()=>{for(let e=c.length-1;e>=0;e--)if(Or(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(kr),p=jr(t),m=p[l],h=p.slice(l+1).some(e=>e.matches(`assistant-message`)&&Pr(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=`
|
|
237
|
+
<div class="quickforge-assistant-waiting-dots" aria-hidden="true">
|
|
238
|
+
<span></span>
|
|
239
|
+
<span></span>
|
|
240
|
+
<span></span>
|
|
241
|
+
</div>
|
|
242
|
+
`),g.previousElementSibling!==m&&m.after(g),!0}function Ir(e){let{panel:t,isStreaming:n,abort:r,agentAccessMode:i,planMode:a,workspaceToolsEnabled:o,readOnly:s,allowModelControls:c,onAccessModeChange:l,onTogglePlanMode:u,onInput:d,onFilesChange: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}It({editor:S,onInput:d,onFilesChange:p,removeCommandSuggestions:m,updateCommandSuggestions:h,removeCapabilitySuggestions:_,updateCapabilitySuggestions:v,onBeforeSend:x}),g(S),y(S),Nt(S,a,u);let w=t.querySelector(`agent-interface`);if(w){let e=w.enableModelSelector!==c;w.enableModelSelector=c,w.enableThinkingSelector=!1,e&&w.requestUpdate?.()}let T=S?.querySelectorAll(`.flex.gap-2.items-center`),E=T?.[0],D=T?.[T.length-1];if(D){if(Mt(S,D),Ft({rightControls:D,isStreaming:n,abort:r,removeCommandSuggestions:m}),!E){t.querySelector(`.quickforge-plus-inline`)?.remove(),wt(t),t.querySelector(`.quickforge-agent-access-inline`)?.remove(),yt(t),t.querySelector(`.quickforge-yolo-inline`)?.remove(),t.querySelector(`.quickforge-plan-inline`)?.remove();return}if(S&&At({panel:t,editor:S,leftControls:E,insertBuiltinPluginMention:b,removeCommandSuggestions:m,removeCapabilitySuggestions:_}),Pt({panel:t,leftControls:E,planMode:a,onTogglePlanMode:u}),!o){t.querySelector(`.quickforge-agent-access-inline`)?.remove(),yt(t),t.querySelector(`.quickforge-yolo-inline`)?.remove();return}St({panel:t,leftControls:E,agentAccessMode:i,onAccessModeChange:l,dismissComposerMenus:()=>wt(t)})}}function Q(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function $(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n:void 0}function Lr(e,t){let n=e[t];return typeof n==`boolean`?n:void 0}function Rr(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function zr(e){let t=e&&Q(e.diff)?e.diff:void 0;return{addedLines:t?Rr(t,`addedLines`):void 0,removedLines:t?Rr(t,`removedLines`):void 0}}function Br(e=``){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)?`html`:/\.(svg|png|jpe?g|webp|gif|bmp|ico)$/i.test(t)?`image`:t.endsWith(`.md`)||t.endsWith(`.mdx`)?`markdown`:/\.(ts|tsx|js|jsx|mjs|cjs|css|scss|less|json|jsonc|txt|xml|yml|yaml|toml|ini|py|rb|go|rs|java|c|h|cpp|hpp|cs|php|sh|bash|zsh|ps1)$/i.test(t)?`code`:`unknown`}function Vr(e){return e===`html`||e===`image`||e===`markdown`||e===`code`}function Hr(e){return[e.source,e.path??``,e.command??``,e.outputFile??``,e.toolCallId??``,e.preview?`preview`:``].join(`\0`)}function Ur(e,t,n){let r=Hr(n);t.has(r)||(t.add(r),e.push({id:`${e.length}:${r}`,...n}))}function Wr(e){if(!(typeof e!=`string`||!e.trim()))try{return JSON.parse(e)}catch{return}}function Gr(e,t){if(t&&(Array.isArray(t.files)||Array.isArray(t.previewed)))return t;let n=e.data;if(Array.isArray(n))for(let e of n){if(!Q(e)||e.type!==`text`)continue;let t=Wr(e.text);if(Q(t)&&(Array.isArray(t.files)||Array.isArray(t.previewed)))return t}let r=e.content;if(Array.isArray(r))for(let e of r){if(!Q(e)||e.type!==`text`)continue;let t=Wr(e.text);if(Q(t)&&(Array.isArray(t.files)||Array.isArray(t.previewed)))return t}return t}function Kr(e){if(typeof e==`string`&&e.trim())return{path:e};if(Q(e)){let t=$(e,`path`);return t?{path:t,title:$(e,`title`),description:$(e,`description`),kind:$(e,`kind`),preview:Lr(e,`preview`)}:void 0}}function qr(e){let t=new Set,n=[];for(let r of e){if(r.role!==`toolResult`)continue;let e=typeof r.toolName==`string`?r.toolName:``,i=Q(r.details)?r.details:void 0,a=typeof r.toolCallId==`string`?r.toolCallId:void 0;if(!(!i&&e!==`present_files`)){if(e===`write_file`||e===`edit_file`){let r=i?$(i,`path`):void 0;if(r){let o=Br(r),{addedLines:s,removedLines:c}=zr(i);Ur(n,t,{source:e,confidence:`high`,path:r,toolCallId:a,kind:o,preview:Vr(o),presentation:`inferred`,addedLines:s,removedLines:c})}}else if(e===`present_files`){let e=Gr(r,i),o=Q(e)&&Array.isArray(e.files)?e.files:[],s=Q(e)?$(e,`defaultPreview`):void 0,c=new Set(Q(e)&&Array.isArray(e.previewed)?e.previewed.filter(e=>typeof e==`string`):[]);for(let e of o){let r=Kr(e);if(!r?.path)continue;let i=r.kind??Br(r.path);Ur(n,t,{source:`present_files`,confidence:`high`,path:r.path,title:r.title,description:r.description,toolCallId:a,kind:i,preview:r.preview??(c.has(r.path)||s===r.path||Vr(i)),defaultPreview:s===r.path,presentation:`explicit`})}}else if(e===`run_command`&&i){let e=$(i,`command`),r=$(i,`outputFile`);(e||r)&&Ur(n,t,{source:`run_command`,confidence:`low`,command:e,outputFile:r,toolCallId:a})}}}return n}function Jr(e){return e?.length?qr(e):[]}var Yr=`quickforge:composer-drafts:v1`,Xr=100,Zr={},Qr=!1;function $r(e){return!!(e&&!e.startsWith(`pending-`))}function ei(e){return $r(e.sessionId)?`session:${e.sessionId}`:e.scope===`project`&&e.projectId?`new:project:${e.projectId}`:`new:global`}function ti(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e)){if(!r||typeof r!=`object`||Array.isArray(r))continue;let e=r;typeof e.text==`string`&&(t[n]={text:e.text,updatedAt:typeof e.updatedAt==`string`?e.updatedAt:new Date().toISOString(),scope:e.scope===`project`?`project`:e.scope===`global`?`global`:void 0,projectId:typeof e.projectId==`string`?e.projectId:void 0,sessionId:typeof e.sessionId==`string`?e.sessionId:void 0})}return t}function ni(){try{return globalThis.localStorage}catch{return}}function ri(e,t=Xr){return Object.fromEntries(Object.entries(e).filter(([,e])=>e.text.length>0).sort(([,e],[,t])=>t.updatedAt.localeCompare(e.updatedAt)).slice(0,t))}function ii(){let e=ni();if(!e||Qr)return Zr;let t;try{t=e.getItem(Yr)}catch{return Qr=!0,Zr}try{return ti(t?JSON.parse(t):void 0)}catch{return Zr}}function ai(e){let t=ri(e);Zr=t;let n=ni();if(!(!n||Qr))try{Object.keys(t).length===0?n.removeItem(Yr):n.setItem(Yr,JSON.stringify(t))}catch{let e=ri(t,Math.ceil(Xr/2));Zr=e;try{Object.keys(e).length===0?n.removeItem(Yr):n.setItem(Yr,JSON.stringify(e))}catch{Qr=!0}}}async function oi(e){let t=ii()[e];if(!(!t||t.text.length===0))return{text:t.text,attachments:[]}}async function si(e,t,n){let r=t.text??``;if(r.length===0){await ci(e);return}let i=ii();i[e]={text:r,updatedAt:new Date().toISOString(),scope:n.scope,projectId:n.scope===`project`?n.projectId:void 0,sessionId:$r(n.sessionId)?n.sessionId:void 0},ai(i)}async function ci(e){let t=ii();Object.prototype.hasOwnProperty.call(t,e)&&(delete t[e],ai(t))}var li=r();function ui(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 di(e){let t=String(e.length);for(let n of e)n.role===`toolResult`&&(t+=`|${n.toolCallId??``}:${n.toolName??``}`);return t}function fi({agent:e,onModelSelect:t,revision:n,agentAccessMode:r,workspaceToolsEnabled:i,project:a,projectId:o,chatScope:s=`global`,onAccessModeChange:l,onRollbackFromMessage:p,onRetryFromMessage:h,onCopyAnswer:g,onForkFromMessage:_,onApproveToolCall:v,onRejectToolCall:y,onApproveAutoCompact:b,onRejectAutoCompact:S,onOpenWorkspaceGitChanges:C,onOpenLocalFilePath:w,onArtifactsChange:T,onContextUsageDisplayChange:E,restoredDraft:D,disableFork:O=!1,readOnly:k=!1,bypassClientApiKeyCheck:A=!1,allowModelControls:j=!0,newChatEmptyState:M=!1,rollbackConfirmTitle:ee,rollbackConfirmDescription:te}){let N=(0,x.useRef)(null),ne=(0,x.useRef)(void 0),re=(0,x.useRef)(void 0),P=(0,x.useRef)(new Map),ie=(0,x.useRef)([]),ae=(0,x.useRef)(void 0),oe=(0,x.useRef)(new Set),F=(0,x.useRef)(void 0),se=(0,x.useRef)(``),ce=(0,x.useRef)(``),[le,ue]=(0,x.useState)(),[I,de]=(0,x.useState)(!1),fe=(0,x.useCallback)(()=>de(e=>!e),[]),pe=(0,x.useCallback)(()=>de(!1),[]);(0,x.useEffect)(()=>{e?.setPlanMode?.(I,I?pe:void 0)},[e,I,pe]);let L=(0,x.useCallback)(()=>{F.current&&=(window.clearTimeout(F.current),void 0)},[]),me=(0,x.useMemo)(()=>({sessionId:e?.sessionId,scope:s,projectId:o}),[e?.sessionId,s,o]),he=ei(me),ge=(0,x.useRef)(me),R=(0,x.useRef)(he);(0,x.useEffect)(()=>{ge.current=me,R.current=he},[me,he]),(0,x.useEffect)(()=>()=>{L()},[L]);let z=(0,x.useCallback)((e,t,n)=>{if(t.text.length===0){ci(e).catch(e=>d.error(`Failed to clear composer draft:`,e));return}si(e,t,n).catch(e=>d.error(`Failed to save composer draft:`,e))},[]),B=(0,x.useCallback)((e,t,n)=>{F.current&&window.clearTimeout(F.current),F.current=window.setTimeout(()=>{F.current=void 0,z(e,t,n)},400)},[z]),V=(0,x.useCallback)((e,t=R.current,n=ge.current)=>{let r=Lt(e);q(r)?P.current.set(t,r):P.current.delete(t),z(t,r,n)},[z]),H=(0,x.useRef)({onCopyAnswer:g,onRollbackFromMessage:p,onRetryFromMessage:h,onForkFromMessage:_,onAccessModeChange:l,onTogglePlanMode:fe,onApproveToolCall:v,onRejectToolCall:y,onApproveAutoCompact:b,onRejectAutoCompact:S,onOpenWorkspaceGitChanges:C,onOpenLocalFilePath:w,onArtifactsChange:T,onContextUsageDisplayChange:E,onModelSelect:t,agentAccessMode:r,planMode:I,workspaceToolsEnabled:i,disableFork:O,readOnly:k,allowModelControls:j,newChatEmptyState:M,bypassClientApiKeyCheck:A,rollbackConfirmTitle:ee,rollbackConfirmDescription:te,gitBranch:le});(0,x.useEffect)(()=>{H.current={onCopyAnswer:g,onRollbackFromMessage:p,onRetryFromMessage:h,onForkFromMessage:_,onAccessModeChange:l,onTogglePlanMode:fe,onApproveToolCall:v,onRejectToolCall:y,onApproveAutoCompact:b,onRejectAutoCompact:S,onOpenWorkspaceGitChanges:C,onOpenLocalFilePath:w,onArtifactsChange:T,onContextUsageDisplayChange:E,onModelSelect:t,agentAccessMode:r,planMode:I,workspaceToolsEnabled:i,disableFork:O,readOnly:k,allowModelControls:j,newChatEmptyState:M,bypassClientApiKeyCheck:A,rollbackConfirmTitle:ee,rollbackConfirmDescription:te,gitBranch:le},re.current=D});let _e=a?.id??o;(0,x.useEffect)(()=>{let e=!1;return queueMicrotask(()=>{if(!e){if(!_e){ue(void 0);return}m(_e).then(t=>{e||ue(t.isGitRepository?t.branch:void 0)}).catch(t=>{e||(d.warn(`Failed to load git branch:`,t),ue(void 0))})}}),()=>{e=!0}},[_e,n]);let ve=(0,x.useRef)(null),ye=(0,x.useRef)(null),U=(0,x.useRef)(null),W=(0,x.useRef)(null),G=(0,x.useRef)(null);(0,x.useEffect)(()=>{let e=!1;return a?.id?(fetch(`/api/project/commands?projectId=${encodeURIComponent(a.id)}`,{cache:`no-store`}).then(e=>e.ok?e.json():{commands:[]}).then(t=>{e||(ie.current=Array.isArray(t.commands)?t.commands:[],U.current?.())}).catch(()=>{e||(ie.current=[],U.current?.())}),()=>{e=!0}):(ie.current=[],()=>{e=!0})},[a?.id,n]);let be=(e,t,n,r,i=!1)=>{if(t.sessionId&&t.sessionId!==n||!q(t)||!i&&oe.current.has(t.id))return;let a=()=>{if(!i&&oe.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]:[]}:P.current.get(r),o=ae.current;(o?.id!==t.id||!q(a??Te())||a?.text===o.text)&&(zt(e,t,P.current,r),ae.current={id:t.id,text:t.text})};a(),window.requestAnimationFrame(a);for(let e of[0,50,150,300,600])window.setTimeout(a,e);e.querySelector(`agent-interface`)?.updateComplete?.then(a)};return(0,x.useEffect)(()=>{if(!N.current||!e)return;let t=new c;de(!1);let n=e.sessionId,r=R.current,i=ge.current,a=!1,o,s=!1,l=e.state.isStreaming,p=!1,m=Fe({panel:t});ye.current=m;let h=Ie({panel:t,getCustomCommands:()=>ie.current,getComposerDrafts:()=>P.current,sessionId:r,setComposerDrafts:e=>{P.current=e},restoreDraftIntoComposer:e=>{zt(t,e,P.current,r),B(r,e,i)}}),g=We({panel:t,restoreDraftIntoComposer:e=>{zt(t,e,P.current,r),B(r,e,i)}}),_=et({panel:t,getSystemPrompt:()=>e.state.systemPrompt,getMessages:()=>e.state.messages,getEffectiveMessages:()=>ui(e),getContextWindow:()=>e.state.model?.contextWindow??0,getTools:()=>e.state.tools,getMaxTokens:()=>e.state.model?.maxTokens,getServerContextUsage:()=>e.state.contextUsage??null,getGitBranch:()=>H.current.gitBranch,onGitBranchClick:()=>H.current.onOpenWorkspaceGitChanges?.(),renderInline:!1,onDisplayChange:t=>H.current.onContextUsageDisplayChange?.(e.sessionId,t)}),v=e=>{s=!1;let n=t.querySelector(`message-editor`),a={text:e,attachments:n?.attachments?[...n.attachments]:[]};q(a)?P.current.set(r,a):P.current.delete(r),B(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)?P.current.set(r,o):P.current.delete(r),B(r,o,i);let c=t.querySelector(`agent-interface`);c?.requestUpdate?.(),window.requestAnimationFrame(()=>U.current?.()),c?.updateComplete?.then(()=>U.current?.())},b=()=>{e.state.isStreaming?t.dataset.quickforgeAgentStreaming=`true`:delete t.dataset.quickforgeAgentStreaming},x=()=>{if(a||!t.isConnected)return;b();let n=H.current,r=di(e.state.messages);if(r!==ce.current){ce.current=r;let t=Jr(e.state.messages),i=JSON.stringify(t.map(e=>[e.source,e.path,e.command,e.outputFile,e.confidence,e.preview,e.defaultPreview,e.addedLines,e.removedLines]));i!==se.current&&(se.current=i,n.onArtifactsChange?.(t))}try{Er({panel:t,getMessages:()=>e.state.messages,isStreaming:()=>e.state.isStreaming,onCopyAnswer:n.onCopyAnswer,onRollbackFromMessage:n.onRollbackFromMessage,onRetryFromMessage:n.onRetryFromMessage,onForkFromMessage:n.onForkFromMessage,onOpenLocalFilePath:n.onOpenLocalFilePath,disableFork:n.disableFork,readOnly:n.readOnly,enableTerminalCommandActions:!n.readOnly,rollbackConfirmTitle:n.rollbackConfirmTitle,rollbackConfirmDescription:n.rollbackConfirmDescription}),en({panel:t,getMessages:()=>e.state.messages,getContextCompaction:()=>e.state.contextCompaction??null}),Fr({panel:t,getMessages:()=>e.state.messages,isStreaming:()=>e.state.isStreaming,isActive:l})}catch{}try{Ir({panel:t,isStreaming:()=>e.state.isStreaming,abort:()=>e.abort(),agentAccessMode:n.agentAccessMode,planMode:n.planMode,workspaceToolsEnabled:n.workspaceToolsEnabled,readOnly:n.readOnly,allowModelControls:n.allowModelControls,onAccessModeChange:n.onAccessModeChange,onTogglePlanMode:n.onTogglePlanMode,onInput: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 i=W.current;if(i&&i.sessionId===e.sessionId){let e=i.toolCallId;Kt({panel:t,onApprove:async()=>{await H.current.onApproveToolCall(e),W.current=null,qt(t)},onReject:async()=>{await H.current.onRejectToolCall(e),W.current=null,qt(t)}},i.toolName,e,i.args,i.source)}else{let n=G.current;if(n&&n.sessionId===e.sessionId){let e=n.approvalId;Kt({panel:t,onApprove:async()=>{await H.current.onApproveAutoCompact?.(e),G.current=null,qt(t)},onReject:async()=>{await H.current.onRejectAutoCompact?.(e),G.current=null,qt(t)}},f(`contextManagement`),e,{percent:n.usage?.percent??0,threshold:n.thresholdPercent??0,keepRecentTurns:n.keepRecentTurns??3,summary:f(`autoCompactApprovalWaiting`,{percent:n.usage?.percent??0,threshold:n.thresholdPercent??0}),description:f(`autoCompactApprovalPreview`,{keepRecentTurns:n.keepRecentTurns??3})})}else qt(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()}))};ve.current=D;let k=()=>{p||(p=!0,window.requestAnimationFrame(()=>{if(p=!1,a)return;b();let e=t.querySelector(`agent-interface`);e?.requestUpdate?.(),U.current?.(),e?.updateComplete?.then(()=>U.current?.()),m.isEnabled&&m.scheduleScrollToBottom()}))};U.current=O,t.setAgent(e,{onApiKeyRequired:H.current.bypassClientApiKeyCheck?async()=>!0:e=>u.prompt(e),onBeforeSend:()=>{let e=re.current;e&&oe.current.add(e.id),L(),s=!0,h.remove(),P.current.delete(r),ci(r).catch(e=>d.error(`Failed to clear composer draft:`,e)),m.enable()},onModelSelect:H.current.onModelSelect,toolsFactory:()=>Ce(e.state.tools)}).then(()=>{if(a)return;let e=re.current,i=i=>{a||(e&&ne.current!==e.id?(ne.current=e.id,be(t,e,n,r)):zt(t,i??P.current.get(r)??Te(),P.current,r))};if(e&&ne.current!==e.id)i();else{let e=P.current.get(r);e?i(e):oi(r).then(e=>i(e)).catch(e=>d.error(`Failed to load composer draft:`,e))}o=new MutationObserver(()=>{w||O()}),o.observe(t,{childList:!0,subtree:!0}),window.requestAnimationFrame(()=>{a||D()})}),N.current.replaceChildren(t);let A=e.subscribe(i=>{if(i.type===`agent_start`&&(l=!0,b(),U.current?.(),m.enable(),W.current?.sessionId===e.sessionId&&(W.current=null),G.current?.sessionId===e.sessionId&&(G.current=null)),i.type===`message_start`||i.type===`message_update`||i.type===`message_end`||i.type===`turn_end`||i.type===`agent_end`){b();let e=i.message;(i.type===`message_update`||e?.role===`assistant`)&&(l=!1),U.current?.(),m.isEnabled&&m.scheduleScrollToBottom()}if(i.type===`messages_replaced`){let e=re.current;e&&ne.current===e.id&&be(t,e,n,r)}let a=i.type;if(a===`tool_execution_start`||a===`tool_execution_end`){b();let e=t.querySelector(`agent-interface`);e?.requestUpdate?.(),U.current?.(),window.requestAnimationFrame(()=>U.current?.()),e?.updateComplete?.then(()=>U.current?.()),m.isEnabled&&m.scheduleScrollToBottom()}if(a===`tool_execution_update`&&k(),i.type===`agent_end`&&(l=!1,b(),U.current?.(),W.current?.sessionId===e.sessionId&&(W.current=null,U.current?.()),G.current?.sessionId===e.sessionId&&(G.current=null,U.current?.())),a===`auto_compact_completed`||a===`messages_replaced`){let e=t.querySelector(`agent-interface`);e?.requestUpdate?.(),U.current?.(),window.requestAnimationFrame(()=>U.current?.()),e?.updateComplete?.then(()=>U.current?.())}if(a===`auto_compact_failed`&&d.warn(f(`autoCompactFailed`)),i.type===`tool_approval_required`){let e=i;W.current={toolCallId:e.toolCallId,toolName:e.toolName,args:e.args,sessionId:e.sessionId,source:e.source},U.current?.()}if(i.type===`auto_compact_approval_required`){let e=i;G.current={approvalId:e.approvalId,usage:e.usage,thresholdPercent:e.thresholdPercent,keepRecentTurns:e.keepRecentTurns,sessionId:e.sessionId},U.current?.()}});return()=>{s?(L(),P.current.delete(r),ci(r).catch(e=>d.error(`Failed to clear composer draft:`,e))):(Rt(t,P.current,r),V(t,r,i)),h.remove(),h.cleanupTextareaHandler(),g.remove(),g.cleanupTextareaHandler(),a=!0,m.cleanup(),ye.current=null,A(),o?.disconnect(),C!==void 0&&window.cancelAnimationFrame(C),T!==void 0&&window.cancelAnimationFrame(T),ve.current=null,t.remove()}},[e,L,V,B]),(0,x.useEffect)(()=>{let e=N.current;e&&(e.classList.toggle(`quickforge-chat-panel-empty-host`,M),e.dataset.quickforgeEmptyChat=M?`true`:`false`)},[M]),(0,x.useEffect)(()=>{ve.current?.(),(N.current?.querySelector(`agent-interface`))?.requestUpdate?.()},[r,I,i,le,O,k,j,n]),(0,x.useEffect)(()=>{let t=re.current;if(!t||!N.current)return;let n=e?.sessionId??``;if(t.sessionId&&t.sessionId!==n)return;let r=N.current.querySelector(`pi-chat-panel`);r&&(ne.current=t.id,be(r,t,n,R.current,!0))},[D,e]),(0,li.jsx)(`div`,{ref:N,className:`min-h-0 flex-1 overflow-hidden`})}export{fi as ChatPanelHost};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{
|
|
1
|
+
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Et as t,I as n,i as r,l as i,r as a,v as o,y as s}from"./icons-Uo4Gd-eK.js";import{n as c}from"./react-vendor-BjDQPVuK.js";import{F as l,I as u,N as d,P as f}from"./index-DiaCCmXE.js";import{n as p,r as m,t as h}from"./plugin-api-YfYj_Bd7.js";var g=e(t(),1),_=c();function v(e){return e===`loaded`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`error`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`}function y(e){return e===`loaded`?u(`pluginStatusLoaded`):e===`disabled`?u(`pluginStatusDisabled`):e===`error`?u(`pluginStatusError`):e}function b(e){switch(e){case`openai-documents`:return{label:u(`pluginOpenaiDocumentsName`),description:u(`pluginOpenaiDocumentsDescription`)};case`openai-spreadsheets`:return{label:u(`pluginOpenaiSpreadsheetsName`),description:u(`pluginOpenaiSpreadsheetsDescription`)};case`openai-presentations`:return{label:u(`pluginOpenaiPresentationsName`),description:u(`pluginOpenaiPresentationsDescription`)};default:return null}}function x(e){return b(e.name)?.label||(e.displayName||e.name).replace(/^OpenAI\s+/i,``)}function S(e){return b(e.name)?.description||e.description||u(`noDescription`)}function C(e){return(e.label||e.name||e.quickForgeName).replace(/^OpenAI\s+/i,``)}function w({onChanged:e}){let[t,c]=(0,g.useState)(null),[b,w]=(0,g.useState)(!0),[T,E]=(0,g.useState)(null),[D,O]=(0,g.useState)(null),[k,A]=(0,g.useState)(null),j=(0,g.useCallback)(async(t=`load`)=>{A(null),w(!0);try{c(t===`reload`?await p():await h()),t===`reload`&&e?.()}catch(e){A(e instanceof Error?e.message:u(`pluginsLoadFailed`))}finally{w(!1)}},[e]);(0,g.useEffect)(()=>{let e=!1;return h().then(t=>{e||c(t)}).catch(t=>{e||A(t instanceof Error?t.message:u(`pluginsLoadFailed`))}).finally(()=>{e||w(!1)}),()=>{e=!0}},[]);let M=(0,g.useMemo)(()=>{let e=t?.plugins||[];return{total:e.length,enabled:e.filter(e=>e.enabled).length,tools:e.reduce((e,t)=>e+t.tools.length,0)}},[t]),N=(0,g.useMemo)(()=>D&&(t?.plugins||[]).find(e=>e.name===D)||null,[t,D]),P=async(t,n)=>{E(t),A(null);try{c(await m(t,n)),e?.()}catch(e){A(e instanceof Error?e.message:u(`pluginsSaveFailed`))}finally{E(null)}};return(0,_.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,children:[(0,_.jsxs)(`div`,{className:`border-b border-border px-6 py-5`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,_.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-2xl bg-primary/10 text-primary`,children:(0,_.jsx)(s,{className:`size-5`})}),(0,_.jsx)(`div`,{children:(0,_.jsxs)(`h1`,{className:`inline-flex items-center gap-1.5 text-lg font-semibold text-foreground`,children:[u(`plugins`),(0,_.jsx)(d,{label:u(`pluginsDescription`)})]})})]}),(0,_.jsxs)(f,{variant:`outline`,size:`sm`,onClick:()=>void j(`reload`),disabled:b,children:[b?(0,_.jsx)(n,{className:`mr-2 size-4 animate-spin`}):(0,_.jsx)(o,{className:`mr-2 size-4`}),u(`pluginsReload`)]})]}),(0,_.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[(0,_.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5`,children:u(`pluginsCount`,M)}),(0,_.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5`,children:u(`pluginToolsCount`,{count:M.tools})})]})]}),(0,_.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-6`,children:(0,_.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:[k?(0,_.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:k}):null,t?.errors?.length?(0,_.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-amber-500/30 bg-amber-500/8 p-3 text-sm`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-amber-700 dark:text-amber-300`,children:[(0,_.jsx)(r,{className:`size-4`}),u(`pluginDiscoveryErrors`)]}),t.errors.map((e,t)=>(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[(0,_.jsx)(`span`,{className:`font-mono text-xs`,children:e.dir}),`: `,e.error]},`${e.dir}-${t}`))]}):null,b&&!t?(0,_.jsxs)(`div`,{className:`flex h-40 items-center justify-center text-sm text-muted-foreground`,children:[(0,_.jsx)(n,{className:`mr-2 size-4 animate-spin`}),u(`loadingPlugins`)]}):null,!b&&t&&t.plugins.length===0?(0,_.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted/15 p-4 text-xs text-muted-foreground/55`,children:[(0,_.jsx)(`div`,{className:`text-base font-medium text-foreground`,children:u(`noPlugins`)}),(0,_.jsx)(`p`,{className:`mt-2`,children:u(`noPluginsDescription`)}),(0,_.jsx)(`div`,{className:`mt-4 space-y-1`,children:(t.searchPaths||[]).map(e=>(0,_.jsx)(`div`,{className:`font-mono text-xs`,children:e},e))})]}):null,(0,_.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:(t?.plugins||[]).map(e=>(0,_.jsxs)(`article`,{className:`rounded-xl border border-border bg-card p-4`,children:[(0,_.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,_.jsx)(`h2`,{className:`truncate text-sm font-medium text-foreground/90`,children:x(e)}),(0,_.jsxs)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground`,children:[`v`,e.version]}),(0,_.jsx)(`span`,{className:l(`rounded-full px-2 py-0.5 text-xs`,v(e.status)),children:y(e.status)})]}),(0,_.jsx)(`p`,{className:`mt-2 line-clamp-2 text-sm text-muted-foreground`,children:S(e)})]}),(0,_.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1.5`,children:[(0,_.jsxs)(f,{variant:e.enabled?`outline`:`default`,size:`sm`,disabled:T===e.name,onClick:()=>void P(e.name,!e.enabled),children:[T===e.name?(0,_.jsx)(n,{className:`mr-2 size-4 animate-spin`}):null,e.enabled?u(`disablePlugin`):u(`enablePlugin`)]}),(0,_.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>O(e.name),children:u(`viewDetails`)})]})]}),e.error?(0,_.jsx)(`div`,{className:`mt-3 rounded-lg border border-destructive/30 bg-destructive/8 px-3 py-2 text-sm text-destructive`,children:e.error}):null,(0,_.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-x-4 gap-y-1 border-t border-border pt-3 text-xs text-muted-foreground`,children:[(0,_.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,_.jsx)(a,{className:`size-3`}),u(`pluginToolsCount`,{count:e.tools.length})]}),(0,_.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,_.jsx)(i,{className:`size-3`}),u(`pluginPermissionsCount`,{count:e.permissions.length})]}),(0,_.jsx)(`span`,{children:e.enabled?u(`enabled`):u(`disabled`)})]})]},e.name))})]})}),N?(0,_.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,onMouseDown:e=>{e.target===e.currentTarget&&O(null)},children:(0,_.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,_.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-border px-5 py-4`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsx)(`h2`,{className:`text-base font-medium text-foreground`,children:u(`pluginDetails`)}),(0,_.jsx)(`p`,{className:`mt-1 truncate text-sm text-muted-foreground`,children:x(N)})]}),(0,_.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>O(null),children:u(`close`)})]}),(0,_.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,_.jsxs)(`div`,{className:`space-y-4`,children:[N.error?(0,_.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/8 px-3 py-2 text-sm text-destructive`,children:N.error}):null,(0,_.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4`,children:[(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:S(N)}),(0,_.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t border-border pt-3 text-xs text-muted-foreground sm:grid-cols-2`,children:[(0,_.jsxs)(`span`,{children:[u(`pluginVersion`),`:`,N.version]}),(0,_.jsxs)(`span`,{children:[u(`status`),`:`,y(N.status)]}),(0,_.jsx)(`span`,{children:u(`pluginToolsCount`,{count:N.tools.length})}),(0,_.jsx)(`span`,{children:N.enabled?u(`enabled`):u(`disabled`)})]})]}),(0,_.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4`,children:[(0,_.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-sm font-medium text-foreground`,children:[(0,_.jsx)(a,{className:`size-4 text-muted-foreground`}),u(`pluginTools`)]}),N.tools.length?(0,_.jsx)(`div`,{className:`space-y-2`,children:N.tools.map(e=>(0,_.jsxs)(`div`,{className:`rounded-xl bg-muted/30 px-3 py-2`,children:[(0,_.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:C(e)}),e.description?(0,_.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.description}):null]},e.quickForgeName))}):(0,_.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:u(`pluginNoTools`)})]}),(0,_.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4`,children:[(0,_.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-sm font-medium text-foreground`,children:[(0,_.jsx)(i,{className:`size-4 text-muted-foreground`}),u(`pluginPermissions`)]}),N.permissions.length?(0,_.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:N.permissions.map(e=>(0,_.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground`,children:e},e))}):(0,_.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:u(`pluginNoPermissions`)}),(0,_.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground/80`,children:u(`pluginTrustedNotice`)})]})]})})]})}):null]})}export{w as PluginsPage};
|