scream-code 0.15.5 → 0.15.7
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 +7 -4
- package/dist/{app-ugHHjuy4.mjs → app-BWXezRMl.mjs} +1252 -42
- package/dist/{dispatch-aNzh78xW.mjs → dispatch-BJ6GyqMS.mjs} +1015 -469
- package/dist/{dispatch-B23MoYWm.mjs → dispatch-CPK1Lkxu.mjs} +1 -1
- package/dist/main.mjs +1 -1
- package/dist/public/assets/{index-ChLLVxTo.js → index-Bvn-ixUo.js} +2 -2
- package/dist/public/assets/index-Bvn-ixUo.js.map +1 -0
- package/dist/public/index.html +1 -1
- package/dist/{text-input-dialog-DbYfSAjy.mjs → text-input-dialog-CnQM0DYj.mjs} +98 -2
- package/dist/{text-input-dialog-C0UIQBlI.mjs → text-input-dialog-MAm2GHmm.mjs} +1 -1
- package/package.json +2 -2
- package/dist/public/assets/index-ChLLVxTo.js.map +0 -1
|
@@ -14,7 +14,7 @@ var hh=Object.defineProperty;var ph=(e,t,n)=>t in e?hh(e,t,{enumerable:!0,config
|
|
|
14
14
|
* @vue/runtime-dom v3.5.40
|
|
15
15
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
16
16
|
* @license MIT
|
|
17
|
-
**/let $l;const ca=typeof window<"u"&&window.trustedTypes;if(ca)try{$l=ca.createPolicy("vue",{createHTML:e=>e})}catch{}const Bu=$l?e=>$l.createHTML(e):e=>e,ag="http://www.w3.org/2000/svg",cg="http://www.w3.org/1998/Math/MathML",cn=typeof document<"u"?document:null,ua=cn&&cn.createElement("template"),ug={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,s)=>{const o=t==="svg"?cn.createElementNS(ag,e):t==="mathml"?cn.createElementNS(cg,e):n?cn.createElement(e,{is:n}):cn.createElement(e);return e==="select"&&s&&s.multiple!=null&&o.setAttribute("multiple",s.multiple),o},createText:e=>cn.createTextNode(e),createComment:e=>cn.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>cn.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,s,o,i){const l=n?n.previousSibling:t.lastChild;if(o&&(o===i||o.nextSibling))for(;t.insertBefore(o.cloneNode(!0),n),!(o===i||!(o=o.nextSibling)););else{ua.innerHTML=Bu(s==="svg"?`<svg>${e}</svg>`:s==="mathml"?`<math>${e}</math>`:e);const r=ua.content;if(s==="svg"||s==="mathml"){const a=r.firstChild;for(;a.firstChild;)r.appendChild(a.firstChild);r.removeChild(a)}t.insertBefore(r,n)}return[l?l.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},$n="transition",Ss="animation",gs=Symbol("_vtc"),Fu={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},ju=at({},lu,Fu),dg=e=>(e.displayName="Transition",e.props=ju,e),_i=dg((e,{slots:t})=>ze(fp,Uu(e),t)),Nn=(e,t=[])=>{we(e)?e.forEach(n=>n(...t)):e&&e(...t)},da=e=>e?we(e)?e.some(t=>t.length>1):e.length>1:!1;function Uu(e){const t={};for(const I in e)I in Fu||(t[I]=e[I]);if(e.css===!1)return t;const{name:n="v",type:s,duration:o,enterFromClass:i=`${n}-enter-from`,enterActiveClass:l=`${n}-enter-active`,enterToClass:r=`${n}-enter-to`,appearFromClass:a=i,appearActiveClass:c=l,appearToClass:u=r,leaveFromClass:f=`${n}-leave-from`,leaveActiveClass:h=`${n}-leave-active`,leaveToClass:p=`${n}-leave-to`}=e,v=fg(o),k=v&&v[0],w=v&&v[1],{onBeforeEnter:S,onEnter:$,onEnterCancelled:E,onLeave:L,onLeaveCancelled:Z,onBeforeAppear:j=S,onAppear:C=$,onAppearCancelled:x=E}=t,y=(I,H,O,B)=>{I._enterCancelled=B,Cn(I,H?u:r),Cn(I,H?c:l),O&&O()},T=(I,H)=>{I._isLeaving=!1,Cn(I,f),Cn(I,p),Cn(I,h),H&&H()},D=I=>(H,O)=>{const B=I?C:$,te=()=>y(H,I,O);Nn(B,[H,te]),fa(()=>{Cn(H,I?a:i),Qt(H,I?u:r),da(B)||ha(H,s,k,te)})};return at(t,{onBeforeEnter(I){Nn(S,[I]),Qt(I,i),Qt(I,l)},onBeforeAppear(I){Nn(j,[I]),Qt(I,a),Qt(I,c)},onEnter:D(!1),onAppear:D(!0),onLeave(I,H){I._isLeaving=!0;const O=()=>T(I,H);Qt(I,f),I._enterCancelled?(Qt(I,h),xl(I)):(xl(I),Qt(I,h)),fa(()=>{I._isLeaving&&(Cn(I,f),Qt(I,p),da(L)||ha(I,s,w,O))}),Nn(L,[I,O])},onEnterCancelled(I){y(I,!1,void 0,!0),Nn(E,[I])},onAppearCancelled(I){y(I,!0,void 0,!0),Nn(x,[I])},onLeaveCancelled(I){T(I),Nn(Z,[I])}})}function fg(e){if(e==null)return null;if(qe(e))return[Hi(e.enter),Hi(e.leave)];{const t=Hi(e);return[t,t]}}function Hi(e){return bh(e)}function Qt(e,t){t.split(/\s+/).forEach(n=>n&&e.classList.add(n)),(e[gs]||(e[gs]=new Set)).add(t)}function Cn(e,t){t.split(/\s+/).forEach(s=>s&&e.classList.remove(s));const n=e[gs];n&&(n.delete(t),n.size||(e[gs]=void 0))}function fa(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}let hg=0;function ha(e,t,n,s){const o=e._endId=++hg,i=()=>{o===e._endId&&s()};if(n!=null)return setTimeout(i,n);const{type:l,timeout:r,propCount:a}=Gu(e,t);if(!l)return s();const c=l+"end";let u=0;const f=()=>{e.removeEventListener(c,h),i()},h=p=>{p.target===e&&++u>=a&&f()};setTimeout(()=>{u<a&&f()},r+1),e.addEventListener(c,h)}function Gu(e,t){const n=window.getComputedStyle(e),s=v=>(n[v]||"").split(", "),o=s(`${$n}Delay`),i=s(`${$n}Duration`),l=pa(o,i),r=s(`${Ss}Delay`),a=s(`${Ss}Duration`),c=pa(r,a);let u=null,f=0,h=0;t===$n?l>0&&(u=$n,f=l,h=i.length):t===Ss?c>0&&(u=Ss,f=c,h=a.length):(f=Math.max(l,c),u=f>0?l>c?$n:Ss:null,h=u?u===$n?i.length:a.length:0);const p=u===$n&&/\b(?:transform|all)(?:,|$)/.test(s(`${$n}Property`).toString());return{type:u,timeout:f,propCount:h,hasTransform:p}}function pa(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max(...t.map((n,s)=>ga(n)+ga(e[s])))}function ga(e){return e==="auto"?0:Number(e.slice(0,-1).replace(",","."))*1e3}function xl(e){return(e?e.ownerDocument:document).body.offsetHeight}function pg(e,t,n){const s=e[gs];s&&(t=(t?[t,...s]:[...s]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}const Go=Symbol("_vod"),rr=Symbol("_vsh"),zu={name:"show",beforeMount(e,{value:t},{transition:n}){e[Go]=e.style.display==="none"?"":e.style.display,n&&t?n.beforeEnter(e):$s(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:s}){!t!=!n&&(s?t?(s.beforeEnter(e),$s(e,!0),s.enter(e)):s.leave(e,()=>{$s(e,!1)}):$s(e,t))},beforeUnmount(e,{value:t}){$s(e,t)}};function $s(e,t){e.style.display=t?e[Go]:"none",e[rr]=!t}const Hu=Symbol("");function gg(e){const t=ki();if(!t)return;const n=t.ut=(o=e(t.proxy))=>{Array.from(document.querySelectorAll(`[data-v-owner="${t.uid}"]`)).forEach(i=>zo(i,o))},s=()=>{const o=e(t.proxy);t.ce?zo(t.ce,o):Cl(t.subTree,o),n(o)};fu(()=>{Jc(s)}),ct(()=>{Ee(s,Vt,{flush:"post"});const o=new MutationObserver(s);o.observe(t.subTree.el.parentNode,{childList:!0}),vi(()=>o.disconnect())})}function Cl(e,t){if(e.shapeFlag&128){const n=e.suspense;e=n.activeBranch,n.pendingBranch&&!n.isHydrating&&n.effects.push(()=>{Cl(n.activeBranch,t)})}for(;e.component;)e=e.component.subTree;if(e.shapeFlag&1&&e.el)zo(e.el,t);else if(e.type===ee)e.children.forEach(n=>Cl(n,t));else if(e.type===To){let{el:n,anchor:s}=e;for(;n&&(zo(n,t),n!==s);)n=n.nextSibling}}function zo(e,t){if(e.nodeType===1){const n=e.style;let s="";for(const o in t){const i=Ih(t[o]);n.setProperty(`--${o}`,i),s+=`--${o}: ${i};`}n[Hu]=s}}const mg=/(?:^|;)\s*display\s*:/;function vg(e,t,n){const s=e.style,o=st(n);let i=!1;if(n&&!o){if(t)if(st(t))for(const l of t.split(";")){const r=l.slice(0,l.indexOf(":")).trim();n[r]==null&&Ms(s,r,"")}else for(const l in t)n[l]==null&&Ms(s,l,"");for(const l in n){l==="display"&&(i=!0);const r=n[l];r!=null?bg(e,l,!st(t)&&t?t[l]:void 0,r)||Ms(s,l,r):Ms(s,l,"")}}else if(o){if(t!==n){const l=s[Hu];l&&(n+=";"+l),s.cssText=n,i=mg.test(n)}}else t&&e.removeAttribute("style");Go in e&&(e[Go]=i?s.display:"",e[rr]&&(s.display="none"))}const ma=/\s*!important$/;function Ms(e,t,n){if(we(n))n.forEach(s=>Ms(e,t,s));else if(n==null&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const s=yg(e,t);ma.test(n)?e.setProperty(En(s),n.replace(ma,""),"important"):e[s]=n}}const va=["Webkit","Moz","ms"],Wi={};function yg(e,t){const n=Wi[t];if(n)return n;let s=Mt(t);if(s!=="filter"&&s in e)return Wi[t]=s;s=ui(s);for(let o=0;o<va.length;o++){const i=va[o]+s;if(i in e)return Wi[t]=i}return t}function bg(e,t,n,s){return e.tagName==="TEXTAREA"&&(t==="width"||t==="height")&&st(s)&&n===s}const ya="http://www.w3.org/1999/xlink";function ba(e,t,n,s,o,i=xh(t)){s&&t.startsWith("xlink:")?n==null?e.removeAttributeNS(ya,t.slice(6,t.length)):e.setAttributeNS(ya,t,n):n==null||i&&!Mc(n)?e.removeAttribute(t):e.setAttribute(t,i?"":Yt(n)?String(n):n)}function ka(e,t,n,s,o){if(t==="innerHTML"||t==="textContent"){n!=null&&(e[t]=t==="innerHTML"?Bu(n):n);return}const i=e.tagName;if(t==="value"&&i!=="PROGRESS"&&!i.includes("-")){const r=i==="OPTION"?e.getAttribute("value")||"":e.value,a=n==null?e.type==="checkbox"?"on":"":String(n);(r!==a||!("_value"in e))&&(e.value=a),n==null&&e.removeAttribute(t),e._value=n;return}let l=!1;if(n===""||n==null){const r=typeof e[t];r==="boolean"?n=Mc(n):n==null&&r==="string"?(n="",l=!0):r==="number"&&(n=0,l=!0)}try{e[t]=n}catch{}l&&e.removeAttribute(o||t)}function Gn(e,t,n,s){e.addEventListener(t,n,s)}function kg(e,t,n,s){e.removeEventListener(t,n,s)}const wa=Symbol("_vei");function wg(e,t,n,s,o=null){const i=e[wa]||(e[wa]={}),l=i[t];if(s&&l)l.value=s;else{const[r,a]=$g(t);if(s){const c=i[t]=Tg(s,o);Gn(e,r,c,a)}else l&&(kg(e,r,l,a),i[t]=void 0)}}const _g=/(Once|Passive|Capture)$/,Sg=/^on:?(?:Once|Passive|Capture)$/;function $g(e){let t,n;for(;(n=e.match(_g))&&!Sg.test(e);)t||(t={}),e=e.slice(0,e.length-n[1].length),t[n[1].toLowerCase()]=!0;return[e[2]===":"?e.slice(3):En(e.slice(2)),t]}let qi=0;const xg=Promise.resolve(),Cg=()=>qi||(xg.then(()=>qi=0),qi=Date.now());function Tg(e,t){const n=s=>{if(!s._vts)s._vts=Date.now();else if(s._vts<=n.attached)return;const o=n.value;if(we(o)){const i=s.stopImmediatePropagation;s.stopImmediatePropagation=()=>{i.call(s),s._stopped=!0};const l=o.slice(),r=[s];for(let a=0;a<l.length&&!s._stopped;a++){const c=l[a];c&&qt(c,t,5,r)}}else qt(o,t,5,[s])};return n.value=e,n.attached=Cg(),n}const _a=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,Ig=(e,t,n,s,o,i)=>{const l=o==="svg";t==="class"?pg(e,s,l):t==="style"?vg(e,n,s):li(t)?ri(t)||wg(e,t,n,s,i):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):Rg(e,t,s,l))?(ka(e,t,s),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&ba(e,t,s,l,i,t!=="value")):e._isVueCE&&(Ag(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!st(s)))?ka(e,Mt(t),s,i,t):(t==="true-value"?e._trueValue=s:t==="false-value"&&(e._falseValue=s),ba(e,t,s,l))};function Rg(e,t,n,s){if(s)return!!(t==="innerHTML"||t==="textContent"||t in e&&_a(t)&&Ae(n));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="autocorrect"||t==="sandbox"&&e.tagName==="IFRAME"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const o=e.tagName;if(o==="IMG"||o==="VIDEO"||o==="CANVAS"||o==="SOURCE")return!1}return _a(t)&&st(n)?!1:t in e}function Ag(e,t){const n=e._def.props;if(!n)return!1;const s=Mt(t);return Array.isArray(n)?n.some(o=>Mt(o)===s):Object.keys(n).some(o=>Mt(o)===s)}const Wu=new WeakMap,qu=new WeakMap,Ho=Symbol("_moveCb"),Sa=Symbol("_enterCb"),Mg=e=>(delete e.props.mode,e),Eg=Mg({name:"TransitionGroup",props:at({},ju,{tag:String,moveClass:String}),setup(e,{slots:t}){const n=ki(),s=iu();let o,i;return hu(()=>{if(!o.length)return;const l=e.moveClass||`${e.name||"v"}-move`;if(!Ng(o[0].el,n.vnode.el,l)){o=[];return}o.forEach(Lg),o.forEach(Og);const r=o.filter(Dg);xl(n.vnode.el),r.forEach(a=>{const c=a.el,u=c.style;Qt(c,l),u.transform=u.webkitTransform=u.transitionDuration="";const f=c[Ho]=h=>{h&&h.target!==c||(!h||h.propertyName.endsWith("transform"))&&(c.removeEventListener("transitionend",f),c[Ho]=null,Cn(c,l))};c.addEventListener("transitionend",f)}),o=[]}),()=>{const l=Ge(e),r=Uu(l);let a=l.tag||ee;if(o=[],i)for(let c=0;c<i.length;c++){const u=i[c];u.el&&u.el instanceof Element&&!u.el[rr]&&(o.push(u),Yn(u,zs(u,r,s,n)),Wu.set(u,Vu(u.el)))}i=t.default?nr(t.default()):[];for(let c=0;c<i.length;c++){const u=i[c];u.key!=null&&Yn(u,zs(u,r,s,n))}return J(a,null,i)}}}),Pg=Eg;function Lg(e){const t=e.el;t[Ho]&&t[Ho](),t[Sa]&&t[Sa]()}function Og(e){qu.set(e,Vu(e.el))}function Dg(e){const t=Wu.get(e),n=qu.get(e),s=t.left-n.left,o=t.top-n.top;if(s||o){const i=e.el,l=i.style,r=i.getBoundingClientRect();let a=1,c=1;return i.offsetWidth&&(a=r.width/i.offsetWidth),i.offsetHeight&&(c=r.height/i.offsetHeight),(!Number.isFinite(a)||a===0)&&(a=1),(!Number.isFinite(c)||c===0)&&(c=1),Math.abs(a-1)<.01&&(a=1),Math.abs(c-1)<.01&&(c=1),l.transform=l.webkitTransform=`translate(${s/a}px,${o/c}px)`,l.transitionDuration="0s",e}}function Vu(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top}}function Ng(e,t,n){const s=e.cloneNode(),o=e[gs];o&&o.forEach(r=>{r.split(/\s+/).forEach(a=>a&&s.classList.remove(a))}),n.split(/\s+/).forEach(r=>r&&s.classList.add(r)),s.style.display="none";const i=t.nodeType===1?t:t.parentNode;i.appendChild(s);const{hasTransform:l}=Gu(s);return i.removeChild(s),l}const Wo=e=>{const t=e.props["onUpdate:modelValue"]||!1;return we(t)?n=>$o(t,n):t};function Bg(e){e.target.composing=!0}function $a(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const fs=Symbol("_assign");function xa(e,t,n){return t&&(e=e.trim()),n&&(e=di(e)),e}const ut={created(e,{modifiers:{lazy:t,trim:n,number:s}},o){e[fs]=Wo(o);const i=s||o.props&&o.props.type==="number";Gn(e,t?"change":"input",l=>{l.target.composing||e[fs](xa(e.value,n,i))}),(n||i)&&Gn(e,"change",()=>{e.value=xa(e.value,n,i)}),t||(Gn(e,"compositionstart",Bg),Gn(e,"compositionend",$a),Gn(e,"change",$a))},mounted(e,{value:t}){e.value=t??""},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:s,trim:o,number:i}},l){if(e[fs]=Wo(l),e.composing)return;const r=(i||e.type==="number")&&!/^0\d/.test(e.value)?di(e.value):e.value,a=t??"";if(r===a)return;const c=e.getRootNode();(c instanceof Document||c instanceof ShadowRoot)&&c.activeElement===e&&e.type!=="range"&&(s&&t===n||o&&e.value.trim()===a)||(e.value=a)}},Ca={deep:!0,created(e,{value:t,modifiers:{number:n}},s){e._modelValue=t,Gn(e,"change",()=>{const o=Array.prototype.filter.call(e.options,i=>i.selected).map(i=>n?di(qo(i)):qo(i));e[fs](e.multiple?ai(e._modelValue)?new Set(o):o:o[0]),e._assigning=!0,ft(()=>{e._assigning=!1})}),e[fs]=Wo(s)},mounted(e,{value:t}){Ta(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[fs]=Wo(n)},updated(e,{value:t}){e._assigning||Ta(e,t)}};function Ta(e,t){const n=e.multiple,s=we(t);if(!(n&&!s&&!ai(t))){for(let o=0,i=e.options.length;o<i;o++){const l=e.options[o],r=qo(l);if(n)if(s){const a=typeof r;a==="string"||a==="number"?l.selected=t.some(c=>String(c)===String(r)):l.selected=Th(t,r)>-1}else l.selected=t.has(r);else if(to(qo(l),t)){e.selectedIndex!==o&&(e.selectedIndex=o);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function qo(e){return"_value"in e?e._value:e.value}const Fg=["ctrl","shift","alt","meta"],jg={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>Fg.some(n=>e[`${n}Key`]&&!t.includes(n))},rt=(e,t)=>{if(!e)return e;const n=e._withMods||(e._withMods={}),s=t.join(".");return n[s]||(n[s]=((o,...i)=>{for(let l=0;l<t.length;l++){const r=jg[t[l]];if(r&&r(o,t))return}return e(o,...i)}))},Ug={esc:"escape",space:" ",up:"arrow-up",left:"arrow-left",right:"arrow-right",down:"arrow-down",delete:"backspace"},Vn=(e,t)=>{const n=e._withKeys||(e._withKeys={}),s=t.join(".");return n[s]||(n[s]=(o=>{if(!("key"in o))return;const i=En(o.key);if(t.some(l=>l===i||Ug[l]===i))return e(o)}))},Gg=at({patchProp:Ig},ug);let Ia;function zg(){return Ia||(Ia=Hp(Gg))}const Hg=((...e)=>{const t=zg().createApp(...e),{mount:n}=t;return t.mount=s=>{const o=qg(s);if(!o)return;const i=t._component;!Ae(i)&&!i.render&&!i.template&&(i.template=o.innerHTML),o.nodeType===1&&(o.textContent="");const l=n(o,!1,Wg(o));return o instanceof Element&&(o.removeAttribute("v-cloak"),o.setAttribute("data-v-app","")),l},t});function Wg(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function qg(e){return st(e)?document.querySelector(e):e}function mo(e,t,n,s){return e===n&&t===s}function Vg(e){return e.currentSessionId===e.targetSessionId&&e.snapshot.sessionId===e.targetSessionId&&e.currentSessionGeneration===e.targetSessionGeneration&&e.currentConnectionGeneration===e.targetConnectionGeneration&&e.currentPromptGeneration===e.targetPromptGeneration&&e.currentLiveGeneration===e.targetLiveGeneration&&(e.currentEpoch===0||e.snapshot.epoch===e.currentEpoch)&&(e.snapshot.epoch!==e.currentEpoch||e.snapshot.seq>=e.currentSeq)}function Kg(e){return{objective:e.objective,completionCriterion:e.completionCriterion,replace:e.replace,budgets:e.budgets}}function Yg(e){return{objective:e.objective,budgets:e.budgets}}function Zg(e,t,n){return e!==0&&n.epoch!==e?"resync":n.seq<=t?"duplicate":"apply"}function Jg(e,t){return t.type==="goal.updated"?{...e,goal:t.snapshot}:t.type==="todo.updated"?{...e,todos:t.todos}:e}function Xg(e){const t=[],n=new Map;for(const s of e){const o=s.phase??null;let i=n.get(o);i===void 0&&(i=t.length,n.set(o,i),t.push({phase:o,items:[]})),t[i].items.push(s)}return t}const Vs=F([]);let Qg=0;function em(e,t="info",n=3500){const s=`toast_${++Qg}`;Vs.value=[...Vs.value,{id:s,type:t,message:e}],n>0&&window.setTimeout(()=>Ku(s),n)}function Ku(e){Vs.value=Vs.value.filter(t=>t.id!==e)}function ar(){return{toasts:Vs,showToast:em,removeToast:Ku}}function tm(e){let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},flushNow:()=>{t!==null&&(cancelAnimationFrame(t),t=null),e()},dispose:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}}const Ks=new Map;function nm(e){Ks.set(e,Date.now())}function sm(e){return Ks.get(e)}function om(e){const t=Ks.get(e);return t!==void 0&&Ks.delete(e),t}function im(){Ks.clear()}function Vi(e){const t=e/1e3;return t<10?`${t.toFixed(1)}s`:t<60?`${Math.round(t)}s`:`${Math.floor(t/60)}m${String(Math.round(t%60)).padStart(2,"0")}s`}const Be="/api/v1",lm=2*3e4;function rm(){const{showToast:e}=ar(),t=F("connecting"),n=F([]),s=F(!1),o=F(void 0),i=F([]),l=F({busy:!1}),r=F(null),a=F([]),c=F(!1),u=F(null),f=F(!1),h=F(null),p=F(null),v=F(null),k=q(()=>l.value.busy||f.value),w=F([]),S=F(null),$=F(!1),E=q(()=>p.value!==null&&!$.value),L=F(null),Z=F([]),j=F(null),C=F([]),x=F([]),y=F(null),T=F([]),D=F(null),I=F([]),H=F(""),O=F(null),B=F(null),te=F(!1);let oe=null,_e=null,Se=null,je=null,Qe=Date.now(),ge=0,he=0,Fe=0,K=0,ae=0,V=0,ve=0,Oe=0,Ue=0,Pe=null,_=!1,M=null,G=!1,Q=!1;const Y=new Map,X="scream-offline-prompt-queue";let ie=[];try{const b=localStorage.getItem(X);if(b){const P=JSON.parse(b);Array.isArray(P)&&(ie=P.filter(se=>typeof se=="string"))}}catch{ie=[]}function ce(){try{localStorage.setItem(X,JSON.stringify(ie.slice(0,20)))}catch{}}function A(){if(ie.length===0)return;const b=ie[0],P=`client_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,se=Ye();Y.set(P,{messageId:se,connectionGeneration:ae}),V++,G=!1,f.value=!0,n.value.push({id:se,role:"user",content:b,clientMessageId:P,tools:[],ts:Date.now()}),Lr(b),Ne({type:"prompt",text:b,clientMessageId:P})}function N(){ie.length>0&&ie.shift(),ce(),A()}let ue=0,de=0,pe=null,ye=0;function Le(){const P=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`;return S.value?`${P}?sessionId=${encodeURIComponent(S.value)}`:P}function De(b){t.value=b}function Ne(b){(oe==null?void 0:oe.readyState)===WebSocket.OPEN&&oe.send(JSON.stringify(b))}function Ke(){c.value=_||Pe!==null}function ot(){Ue++,Pe=null,_=!1,M=null,c.value=!1,u.value=null}function bt(b,P){if(b!==null&&typeof b=="object"){const se=b.message;if(typeof se=="string")return se}return P}function ne(){Q||je!==null||(je=window.setTimeout(()=>{je=null;const b=M;M=null,be(b??void 0)},250))}async function be(b){const P=p.value;if(!P)return;const se=n.value.length===0?100:void 0,re=K,ke=ae,Re=V,et=ve;try{const nt=await fetch(`${Be}/sessions/${P}/snapshot${se?`?tail=${se}`:""}`);if(!nt.ok){b!==void 0&&(Pe==null?void 0:Pe.generation)===b&&(M=b,ne());return}const Ft=await nt.json();if(!Vg({snapshot:Ft,targetSessionId:P,currentSessionId:p.value,targetSessionGeneration:re,currentSessionGeneration:K,targetConnectionGeneration:ke,currentConnectionGeneration:ae,targetPromptGeneration:Re,currentPromptGeneration:V,targetLiveGeneration:et,currentLiveGeneration:ve,currentEpoch:he,currentSeq:ge})){b!==void 0&&(M=b),ne();return}Et(Ft,b)}catch{b!==void 0&&(Pe==null?void 0:Pe.generation)===b&&(M=b,ne())}}function Et(b,P){var Ur;es="",Pn="",Ln.clear();const se=n.value.filter(jt=>jt.local),re=Y.keys().next().value,ke=re?Y.get(re):void 0,Re=ke?n.value.find(jt=>jt.id===ke.messageId):void 0,et=!!(re&&b.messages.some(jt=>jt.clientMessageId===re)),nt=!!(ke&&!et&&ke.connectionGeneration<ae);nt&&Re&&(Re.isError=!0);const Ft=Re&&!et?[Re]:[];n.value=[...b.messages.map(jt=>({...jt,id:jt.id??Ye()})),...se,...Ft];for(let jt=n.value.length-1;jt>=0;jt--){const uo=(Ur=n.value[jt])==null?void 0:Ur.turnStats;if(uo&&typeof uo.turn=="number"&&uo.turn>0){ue=uo.turn;break}}i.value=b.pendingApprovals,l.value={...b.status,busy:b.busy},s.value=!!b.olderAvailable,o.value=b.oldestSeq,r.value=b.goal,a.value=b.todos,P!==void 0&&Pe!==null&&Pe.generation===P&&Ue===P&&(Pe=null,Ke()),(et||nt)&&(f.value=!1,G=!1,Y.clear(),nt&&e("消息未送达,已恢复连接。","error")),ge=b.seq,he=b.epoch,v.value=b.workDir}function Ye(){return`msg_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Bt(b){Sn(),Qe=Date.now(),_e=window.setInterval(()=>{if(Date.now()-Qe>lm){oe==null||oe.close();return}Ne({type:"ping"})},b)}function Sn(){_e!==null&&(clearInterval(_e),_e=null)}function ro(){if(Q||Se!==null)return;De("reconnecting"),Fe++;const b=Math.min(1e3*2**Fe,3e4);Se=window.setTimeout(()=>{Se=null,Jt()},b)}function af(b){switch(b.type){case"server_hello":{const P=b;p.value=P.sessionId,v.value=P.workDir,S.value=P.sessionId,$.value=P.active;const se=he;he=P.epoch,Bt(P.heartbeat_ms),Ne({type:"client_hello",lastSeq:ge,epoch:se}),se!==0&&se!==P.epoch&&(ge=0),De("connected"),Fe=0,A(),P.active?(be(),ss(),ao()):yf(P.sessionId).then(re=>{re&&p.value===P.sessionId&&($.value=!0),be(),ss(),ao()});break}case"event":{const P=Zg(he,ge,b);if(P==="resync"){he=b.epoch,ge=0,be();break}if(P==="duplicate")break;ge=b.seq,he=b.epoch,ve++,uf(b.payload);break}case"user_message":{if(ve++,b.clientMessageId&&Y.has(b.clientMessageId)){G=!0,N();break}n.value.push({id:Ye(),role:"user",content:b.text,clientMessageId:b.clientMessageId,tools:[],ts:Date.now()});break}case"approval_request":{ve++,i.value=[...i.value,{id:b.id,toolName:b.toolName,action:b.action,display:b.display}];break}case"approval_resolved":{ve++,i.value=i.value.filter(P=>P.id!==b.id);break}case"command_result":{const P=b.pendingMsgId?n.value.findIndex(se=>se.id===b.pendingMsgId):-1;if(P>=0){const se=n.value[P];n.value[P]={...se,content:b.message,isError:!b.ok,pending:!1}}else n.value.push({id:Ye(),role:"system",content:b.message,tools:[],isError:!b.ok,ts:Date.now(),local:!0});(b.command==="fork"||b.command==="title")&&ss(),b.ok&&b.command==="compact"&&be();break}case"resync_required":{ge=0,be();break}case"status":{ve++,l.value={...l.value,...b.status};break}case"error":{if(h.value=b.message,b.clientMessageId){const P=Y.get(b.clientMessageId);if(P){Y.delete(b.clientMessageId),f.value=!1,G=!1;const se=n.value.find(re=>re.id===P.messageId);se&&(se.isError=!0),e(`消息未发送:${b.message}`,"error"),ie.length>0&&(ie.shift(),ce())}}break}case"server_empty":{De("idle");break}}}let es="",Pn="";const Ln=new Map;let Er=!1;function cf(){if(Er)return;const b=ns();if(!b){es="",Pn="",Ln.clear();return}if(es&&(b.content+=es,es=""),Pn){const P=b.tools.find(se=>se.name==="thinking");P?P.output=(P.output??"")+Pn:b.tools.push({toolCallId:"thinking",name:"thinking",output:Pn}),Pn=""}if(Ln.size>0){for(const[P,se]of Ln){const re=b.tools.find(ke=>ke.toolCallId===P);re&&(re.progress=se)}Ln.clear()}}const ts=tm(cf);function uf(b){var se;const P=Jg({goal:r.value,todos:a.value},b);switch(r.value=P.goal,a.value=P.todos,b.type==="goal.updated"&&Pe!==null&&Pe.generation===Ue&&(Pe=null,M=null,Ke()),b.type){case"turn.started":{G&&(f.value=!1,G=!1,Y.clear()),ts.flushNow(),l.value={...l.value,busy:!0},ue+=1,de=Date.now(),pe=null,ye=0,im(),n.value.push({id:Ye(),role:"assistant",content:"",tools:[],ts:Date.now(),model:l.value.model,turnStats:{turn:ue,step:0,status:"running",firstTokenMs:null,llmMs:0,toolMs:0,tokens:null,tokensPerSec:null}});break}case"assistant.delta":{pe===null&&(pe=Date.now()),es+=String(b.delta),ts.schedule();break}case"thinking.delta":{pe===null&&(pe=Date.now()),Pn+=String(b.delta),ts.schedule();break}case"tool.call.started":{const re=ns();re&&(re.tools.push({toolCallId:String(b.toolCallId),name:String(b.name),args:b.args}),re.turnStats&&(re.turnStats.step+=1)),nm(String(b.toolCallId));break}case"tool.result":{Ln.delete(String(b.toolCallId));const re=om(String(b.toolCallId));re!==void 0&&(ye+=Date.now()-re);const ke=ns();if(ke){const Re=ke.tools.find(et=>et.toolCallId===b.toolCallId);Re&&(Re.output=String(b.output),Re.isError=!!b.isError,Re.progress=void 0,re!==void 0&&(Re.durationMs=Date.now()-re))}break}case"tool.progress":{Ln.set(String(b.toolCallId),String(b.message??b.output)),ts.schedule();break}case"turn.ended":{if(ts.flushNow(),l.value={...l.value,busy:!1},b.reason==="failed"){const nt=ns();nt&&(nt.isError=!0),h.value=bt(b.error,"Turn failed")}const re=ns(),ke=Date.now()-de,Re=(se=l.value.usage)==null?void 0:se.currentTurn,et=Re?Re.inputOther+Re.output+Re.inputCacheRead+Re.inputCacheCreation:null;re&&re.turnStats&&(re.turnStats.status="done",re.turnStats.llmMs=ke,re.turnStats.toolMs=ye,re.turnStats.firstTokenMs=pe!==null?pe-de:null,re.turnStats.tokens=et,re.turnStats.tokensPerSec=et!==null&&ke>0?Math.round(et/ke*1e3):null),ss(),ao();break}case"session.meta.updated":{const re={};b.model!==void 0&&(re.model=b.model),b.contextTokens!==void 0&&(re.contextTokens=b.contextTokens),b.maxContextTokens!==void 0&&(re.maxContextTokens=b.maxContextTokens),b.contextUsage!==void 0&&(re.contextUsage=b.contextUsage),l.value={...l.value,...re};break}case"agent.status.updated":{const re={};if(b.model!==void 0&&(re.model=b.model),b.thinkingLevel!==void 0&&(re.thinkingLevel=b.thinkingLevel),b.contextTokens!==void 0&&(re.contextTokens=b.contextTokens),b.maxContextTokens!==void 0&&(re.maxContextTokens=b.maxContextTokens),b.contextUsage!==void 0&&(re.contextUsage=b.contextUsage),b.usage!==void 0){re.usage=b.usage;const ke=b.usage;if(ke!=null&&ke.currentTurn){const Re=ns(),et=ke.currentTurn.inputOther+ke.currentTurn.output+ke.currentTurn.inputCacheRead+ke.currentTurn.inputCacheCreation;Re!=null&&Re.turnStats&&Re.turnStats.status==="done"&&Re.turnStats.tokens===null&&(Re.turnStats.tokens=et,Re.turnStats.tokensPerSec=Re.turnStats.llmMs?Math.round(et/Re.turnStats.llmMs*1e3):null)}}l.value={...l.value,...re};break}case"error":{h.value=bt(b.error,"Unknown error");break}}}function ns(){for(let b=n.value.length-1;b>=0;b--)if(n.value[b].role==="assistant")return n.value[b];return null}function df(){if(!Q){if(Se!==null&&(clearTimeout(Se),Se=null),oe!==null){try{oe.close()}catch{}oe=null}Fe=0,Jt()}}async function ff(){var se;const b=p.value,P=o.value;if(!b||P===void 0)return 0;try{const re=await fetch(`${Be}/sessions/${b}/messages?before=${P}&tail=50`);if(!re.ok)return 0;const ke=await re.json();if(ke.messages.length===0)return 0;const Re=ke.messages.map(et=>({...et,id:et.id??Ye()}));return n.value=[...Re,...n.value],o.value=((se=Re[0])==null?void 0:se.seq)??P,s.value=ke.hasMore,Re.length}catch{return 0}}function Jt(){if(Q||oe&&(oe.readyState===WebSocket.CONNECTING||oe.readyState===WebSocket.OPEN))return;De("connecting"),h.value=null,ot(),ae++;const b=new WebSocket(Le());oe=b,b.onclose=P=>{if(oe===b&&(oe=null,Sn(),t.value!=="idle")){if(P.code===1008){K++,ot(),p.value=null,S.value=null,$.value=!1,r.value=null,a.value=[],De("idle");return}De("disconnected"),ro()}},b.onerror=()=>{oe===b&&De("reconnecting")},b.onmessage=P=>{if(oe!==b)return;Qe=Date.now();let se;try{se=JSON.parse(P.data)}catch{return}af(se)}}function hf(b){if(!b)return;if(t.value==="idle"){e("暂无会话,请先新建会话。","warning");return}if(t.value!=="connected"){ie.push(b),ce(),e("连接已断开,消息已排队,重连后自动发送。","warning"),Jt();return}if(k.value)return;const P=`client_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,se=Ye();Y.set(P,{messageId:se,connectionGeneration:ae}),V++,G=!1,f.value=!0,n.value.push({id:se,role:"user",content:b,clientMessageId:P,tools:[],ts:Date.now()}),Lr(b),Ne({type:"prompt",text:b,clientMessageId:P})}const Pr="scream-recent-prompts";let bs=[];try{const b=localStorage.getItem(Pr);if(b){const P=JSON.parse(b);Array.isArray(P)&&(bs=P.filter(se=>typeof se=="string"))}}catch{bs=[]}function Lr(b){const P=b.trim();if(P){bs=[P,...bs.filter(se=>se!==P)].slice(0,8);try{localStorage.setItem(Pr,JSON.stringify(bs))}catch{}}}function pf(){Ne({type:"abort"})}function gf(b,P){if(t.value==="idle"){e("暂无会话,请先新建会话。","warning");return}if(t.value!=="connected"){e("连接已断开,命令未发送。","error"),Jt();return}if(k.value&&b!=="btw"){e(`会话忙碌中,无法执行 /${b},请稍后再试。`,"warning");return}const se=["compact","plan","auto","yes","fork","title"];let re=null;se.includes(b)&&(re=Ye(),n.value.push({id:re,role:"system",content:`正在执行 /${b}${P?` ${P}`:""}...`,tools:[],pending:!0,ts:Date.now(),local:!0})),Ne({type:"command",command:b,...P?{args:P}:{},...re?{pendingMsgId:re}:{}})}function mf(){n.value=[],i.value=[]}function Or(b){n.value.push({id:Ye(),role:"system",content:b,tools:[],ts:Date.now(),local:!0})}function vf(b,P,se,re){if(t.value!=="connected"){e("连接已断开,审批结果未发送。","error"),Jt();return}i.value=i.value.filter(ke=>ke.id!==b),Ne({type:"approval_response",id:b,decision:P,...se?{feedback:se}:{},...re?{scope:re}:{}})}async function ss(){try{const b=await fetch(`${Be}/sessions`);if(!b.ok)return;w.value=await b.json()}catch{}}async function yf(b){const P=K,se=ae;try{return(await fetch(`${Be}/sessions/${b}/activate`,{method:"POST"})).ok&&ae===se&&mo(p.value,K,b,P)}catch{return!1}}async function ao(){try{const b=await fetch(`${Be}/git/status`);if(!b.ok)return;const P=await b.json();L.value=P.isRepo?P:null}catch{}}async function Dr(){try{const b=await fetch(`${Be}/models`);if(!b.ok)return;const P=await b.json();Z.value=P.models}catch{}}const Ei=F({});async function bf(){try{const b=await fetch(`${Be}/like`);if(!b.ok)return;Ei.value=await b.json()}catch{}}async function kf(b){try{return(await fetch(`${Be}/like`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)})).ok?(Ei.value=b,!0):!1}catch{return!1}}async function Nr(b,P,se){const re=p.value;if(!re)return;const ke=K,Re=ae,et=++Oe;try{const nt=await fetch(`${Be}/sessions/${re}/${b}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)}),Ft=await nt.json();if(p.value!==re||K!==ke||ae!==Re||Oe!==et)return;if(!nt.ok){e(Ft.message??`请求失败(HTTP ${nt.status})`,"error");return}Ft.status&&(l.value={...l.value,...Ft.status}),Or(se)}catch(nt){if(p.value!==re||K!==ke||ae!==Re||Oe!==et)return;e(`请求失败:${nt instanceof Error?nt.message:String(nt)}`,"error")}}async function wf(b){b!==l.value.model&&await Nr("model",{model:b},`已切换模型:${b}`)}async function _f(b){b!==l.value.thinkingLevel&&await Nr("thinking",{level:b},`思考强度已切换为 ${b}`)}async function co(b,P,se,re){const ke=p.value;if(!ke)return u.value="暂无可操作的会话。",null;if(t.value!=="connected")return u.value="连接已断开,请等待重连后再试。",null;if(E.value)return u.value="当前会话已归档,无法修改 Goal。",null;if(_)return u.value="正在处理上一个请求,请稍候。",null;Pe!==null&&(Pe=null,Ke());const Re=K,et=++Ue;_=!0,Ke(),u.value=null;try{const nt=await fetch(`${Be}/sessions/${ke}/goal${b}`,{method:P,headers:{"Content-Type":"application/json"},body:JSON.stringify(se)}),Ft=await nt.json().catch(()=>({}));return!mo(p.value,K,ke,Re)||Ue!==et?null:nt.ok?(re&&(Pe={generation:et},M=et),Ft):(u.value=typeof Ft.message=="string"?Ft.message:`请求失败(HTTP ${nt.status})`,null)}catch(nt){return mo(p.value,K,ke,Re)&&Ue===et&&(u.value=`请求失败:${nt instanceof Error?nt.message:String(nt)}`),null}finally{mo(p.value,K,ke,Re)&&Ue===et&&(_=!1,Ke())}}async function Sf(b){const P=await co("/refine","POST",{description:b},!1);return typeof(P==null?void 0:P.objective)=="string"?P.objective:null}async function $f(b){return await co("","POST",Kg(b),!0)===null?!1:(Pe!==null&&be(Pe.generation),!0)}async function xf(b){return await co("","PATCH",Yg(b),!0)===null?!1:(Pe!==null&&be(Pe.generation),!0)}async function Pi(b){return await co(b,"POST",{},!0)===null?!1:(Pe!==null&&be(Pe.generation),!0)}function Cf(){return Pi("/pause")}function Tf(){return Pi("/resume")}function If(){return Pi("/cancel")}async function Rf(){try{const b=await fetch(`${Be}/sessions`,{method:"POST"});if(!b.ok){e(`新建会话失败(HTTP ${b.status})`,"error");return}const P=await b.json();w.value=[P,...w.value],await Li(P.sessionId)}catch(b){e(`新建会话失败:${b instanceof Error?b.message:String(b)}`,"error")}}async function Li(b){S.value===b&&t.value==="connected"||(S.value=b,p.value=b,K++,ot(),ge=0,he=0,n.value=[],i.value=[],l.value={busy:!1},r.value=null,a.value=[],j.value=null,C.value=[],x.value=[],y.value=null,T.value=[],D.value=null,I.value=[],H.value="",$.value=!1,f.value=!1,G=!1,Y.clear(),Se!==null&&(clearTimeout(Se),Se=null),je!==null&&(clearTimeout(je),je=null),oe&&(oe.onclose=null,oe.close(),oe=null),Sn(),Jt())}async function Af(b){try{const P=await fetch(`${Be}/sessions/${b}`,{method:"DELETE"});if(!P.ok){e(`删除会话失败(HTTP ${P.status})`,"error");return}if(w.value=w.value.filter(se=>se.sessionId!==b),S.value===b){const se=w.value[0];se?await Li(se.sessionId):(K++,ot(),p.value=null,S.value=null,$.value=!1,ge=0,he=0,n.value=[],i.value=[],l.value={busy:!1},r.value=null,a.value=[],j.value=null,C.value=[],x.value=[],y.value=null,T.value=[],D.value=null,I.value=[],H.value="",f.value=!1,G=!1,Y.clear(),oe&&(oe.onclose=null,oe.close(),oe=null),Sn(),De("idle"))}}catch(P){e(`删除会话失败:${P instanceof Error?P.message:String(P)}`,"error")}}async function Mf(b){try{const P=await fetch(`${Be}/sessions/${b}/export`);if(!P.ok){e(`导出会话失败(HTTP ${P.status})`,"error");return}const se=await P.blob(),re=URL.createObjectURL(se),ke=document.createElement("a");ke.href=re,ke.download=`${b}.md`,ke.click(),URL.revokeObjectURL(re)}catch(P){e(`导出会话失败:${P instanceof Error?P.message:String(P)}`,"error")}}async function ks(){const b=p.value;if(b)try{const P=await fetch(`${Be}/sessions/${b}/status`);if(!P.ok)return;const se=await P.json();l.value={...l.value,...se}}catch{}}async function Ef(){const b=p.value;if(b)try{const P=await fetch(`${Be}/sessions/${b}/usage`);if(!P.ok)return;const se=await P.json();l.value={...l.value,usage:se}}catch{}}async function Pf(){const b=p.value;if(b)try{const P=await fetch(`${Be}/sessions/${b}/context`);if(!P.ok)return;const se=await P.json();se.tokenCount!==void 0&&(l.value={...l.value,contextTokens:se.tokenCount})}catch{}}async function Lf(){const b=p.value;if(b)try{const P=await fetch(`${Be}/sessions/${b}/plan`);if(!P.ok)return;j.value=await P.json()}catch{}}async function Of(){const b=p.value;if(!b)return!1;try{return(await fetch(`${Be}/sessions/${b}/plan/clear`,{method:"POST"})).ok?(j.value=null,!0):!1}catch{return!1}}async function kt(b,P){const se=p.value;if(!se)return!1;if(t.value!=="connected")return e("连接已断开,操作未发送。","error"),Jt(),!1;try{const re=await fetch(`${Be}/sessions/${se}/${b}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(P??{})});if(!re.ok){const ke=await re.json().catch(()=>({}));return e(ke.message??`操作失败(HTTP ${re.status})`,"error"),!1}return!0}catch(re){return e(`操作失败:${re instanceof Error?re.message:String(re)}`,"error"),!1}}async function Df(b){const P=await kt("permission",{mode:b});return P&&await ks(),P}async function Nf(b,P){const se=await kt("plan",{enabled:b,...P?{strategy:P}:{}});return se&&await ks(),se}async function Bf(b){const P=await kt("wolfpack",{enabled:b});return P&&await ks(),P}async function Ff(b,P){const se=await kt("rlm",{enabled:b,...P!==void 0?{maxDepth:P}:{}});return se&&await ks(),se}async function jf(b=1){return kt("undo",{count:b})}async function Uf(b){return kt("compact",b?{instruction:b}:{})}async function Gf(){const b=p.value;if(b)try{const P=await fetch(`${Be}/sessions/${b}/skills`);if(!P.ok)return;C.value=await P.json()}catch{}}async function zf(b,P){return kt(`skills/${encodeURIComponent(b)}/activate`,P?{args:P}:{})}async function Hf(b){const P=p.value;if(!P)return!1;try{return(await fetch(`${Be}/sessions/${P}/skills/${encodeURIComponent(b)}`,{method:"DELETE"})).ok?(C.value=C.value.filter(re=>re.name!==b),!0):!1}catch{return!1}}async function Oi(){const b=p.value;if(b)try{const P=await fetch(`${Be}/sessions/${b}/plugins`);if(!P.ok)return;x.value=await P.json()}catch{}}async function Wf(b){const P=p.value;if(P)try{const se=await fetch(`${Be}/sessions/${P}/plugins/${encodeURIComponent(b)}`);if(!se.ok)return;y.value=await se.json()}catch{}}async function qf(b){const P=p.value;if(!P)return null;try{const se=await fetch(`${Be}/sessions/${P}/plugins/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:b})});if(!se.ok)return null;const re=await se.json();return await Oi(),re}catch{return null}}async function Vf(b,P){return kt(`plugins/${encodeURIComponent(b)}/enable`,{enabled:P})}async function Kf(b,P,se){return kt(`plugins/${encodeURIComponent(b)}/mcp/${encodeURIComponent(P)}/enable`,{enabled:se})}async function Yf(b){const P=p.value;if(!P)return!1;try{return(await fetch(`${Be}/sessions/${P}/plugins/${encodeURIComponent(b)}`,{method:"DELETE"})).ok?(x.value=x.value.filter(re=>re.id!==b),!0):!1}catch{return!1}}async function Zf(){const b=p.value;if(!b)return null;try{const P=await fetch(`${Be}/sessions/${b}/plugins/reload`,{method:"POST"});if(!P.ok)return null;const se=await P.json();return await Oi(),se}catch{return null}}async function Jf(b){return kt(`plugins/${encodeURIComponent(b)}/activate`)}async function Xf(b){return kt(`plugins/${encodeURIComponent(b)}/deactivate`)}async function Qf(b){return kt(`plugins/${encodeURIComponent(b)}/inject`)}async function eh(){const b=p.value;if(b)try{const P=await fetch(`${Be}/sessions/${b}/mcp`);if(!P.ok)return;T.value=await P.json()}catch{}}async function th(){const b=p.value;if(b)try{const P=await fetch(`${Be}/sessions/${b}/mcp/startup-metrics`);if(!P.ok)return;D.value=await P.json()}catch{}}async function nh(b,P){return kt("mcp/add",{name:b,config:P})}async function sh(b){return kt(`mcp/${encodeURIComponent(b)}/reconnect`)}async function oh(b){return kt(`mcp/${encodeURIComponent(b)}/stop`)}async function ih(b){const P=p.value;if(!P)return!1;try{return(await fetch(`${Be}/sessions/${P}/mcp/${encodeURIComponent(b)}`,{method:"DELETE"})).ok?(T.value=T.value.filter(re=>re.name!==b),!0):!1}catch{return!1}}async function lh(b,P){const se=p.value;if(se)try{const re=new URLSearchParams;b!==void 0&&re.set("activeOnly",String(b)),P!==void 0&&re.set("limit",String(P));const ke=re.toString(),Re=await fetch(`${Be}/sessions/${se}/tasks${ke?`?${ke}`:""}`);if(!Re.ok)return;I.value=await Re.json()}catch{}}async function rh(b,P){const se=p.value;if(se)try{const re=P!==void 0?`?tail=${P}`:"",ke=await fetch(`${Be}/sessions/${se}/tasks/${encodeURIComponent(b)}/output${re}`);if(!ke.ok)return;const Re=await ke.json();H.value=Re.output}catch{}}async function ah(b,P){return kt(`tasks/${encodeURIComponent(b)}/stop`,P?{reason:P}:{})}async function Br(){try{const b=await fetch(`${Be}/config`);if(!b.ok)return;O.value=await b.json()}catch{}}async function ch(b){try{const P=await fetch(`${Be}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:b})});return P.ok?(O.value=await P.json(),!0):!1}catch{return!1}}async function uh(b){try{return(await fetch(`${Be}/config/providers/${encodeURIComponent(b)}`,{method:"DELETE"})).ok?(await Br(),!0):!1}catch{return!1}}async function dh(){try{const b=await fetch(`${Be}/experimental-flags`);if(!b.ok)return;B.value=await b.json()}catch{}}async function fh(){try{if(!(await fetch(`${Be}/preflight`)).ok)return;te.value=!0}catch{}}Jt(),ss(),Dr();const Fr=()=>{Jt()},jr=()=>{!document.hidden&&t.value!=="connected"&&Jt()};return window.addEventListener("online",Fr),document.addEventListener("visibilitychange",jr),Ct(()=>{Q=!0,Er=!0,ts.dispose(),window.removeEventListener("online",Fr),document.removeEventListener("visibilitychange",jr),Sn(),Se!==null&&(clearTimeout(Se),Se=null),je!==null&&(clearTimeout(je),je=null),oe&&(oe.onclose=null,oe.close(),oe=null)}),{connectionStatus:t,messages:n,pendingApprovals:i,status:l,goal:r,todos:a,goalRequestPending:c,goalRequestError:u,error:h,sessionId:p,workDir:v,isBusy:k,isArchived:E,sessions:w,currentSessionId:S,gitStatus:L,models:Z,like:Ei,fetchLike:bf,updateLike:kf,sendPrompt:hf,sendCommand:gf,clearMessages:mf,appendSystemMessage:Or,abort:pf,resolveApproval:vf,fetchSessions:ss,fetchGitStatus:ao,fetchModels:Dr,reconnectNow:df,olderAvailable:s,oldestSeq:o,loadOlderMessages:ff,switchModel:wf,switchThinking:_f,refineGoal:Sf,createGoal:$f,updateGoal:xf,pauseGoal:Cf,resumeGoal:Tf,cancelGoal:If,createSession:Rf,switchSession:Li,deleteSession:Af,exportSession:Mf,fetchSnapshot:be,fetchSessionStatus:ks,fetchSessionUsage:Ef,fetchSessionContext:Pf,fetchSessionPlan:Lf,sessionPlan:j,clearPlan:Of,switchPermission:Df,switchPlanMode:Nf,switchWolfpack:Bf,switchRlm:Ff,undoHistory:jf,compact:Uf,skills:C,fetchSkills:Gf,activateSkill:zf,removeSkill:Hf,plugins:x,pluginInfo:y,fetchPlugins:Oi,fetchPluginInfo:Wf,installPlugin:qf,setPluginEnabled:Vf,setPluginMcpServerEnabled:Kf,removePlugin:Yf,reloadPlugins:Zf,activatePlugin:Jf,deactivatePlugin:Xf,injectPlugin:Qf,mcpServers:T,mcpStartupMetrics:D,fetchMcpServers:eh,fetchMcpStartupMetrics:th,addMcpServer:nh,reconnectMcpServer:sh,stopMcpServer:oh,removeMcpServer:ih,backgroundTasks:I,backgroundTaskOutput:H,fetchBackgroundTasks:lh,fetchBackgroundTaskOutput:rh,stopBackgroundTask:ah,config:O,fetchConfig:Br,setConfig:ch,removeProvider:uh,experimentalFlags:B,fetchExperimentalFlags:dh,preflightOk:te,preflight:fh}}const Si=[{name:"compact",description:"压缩会话上下文",target:"backend"},{name:"model",description:"切换模型 / 思考强度",target:"local"},{name:"clear",description:"清空本地消息列表",target:"local"},{name:"new",description:"新建会话",target:"local"},{name:"help",description:"显示可用命令",target:"local"},{name:"auto",description:"切换为 auto 权限模式",target:"backend"},{name:"yes",description:"切换为 yolo 权限模式",target:"backend",aliases:["yolo"]},{name:"plan",description:"切换计划模式",target:"backend"},{name:"fork",description:"复制当前会话为新分支",target:"backend"},{name:"title",description:"重命名当前会话",target:"backend",aliases:["rename"],acceptsInput:!0},{name:"status",description:"查看会话状态",target:"local"},{name:"usage",description:"查看 Token 用量",target:"local"},{name:"btw",description:"快速侧问(不打断当前回合)",target:"backend",acceptsInput:!0}];function am(e){const t=e.toLowerCase();return Si.filter(n=>{var s;return n.name.startsWith(t)||((s=n.aliases)==null?void 0:s.some(o=>o.startsWith(t)))})}function cm(e){const t=e.toLowerCase(),n=Si.find(s=>{var o;return s.name===t||((o=s.aliases)==null?void 0:o.includes(t))});return(n==null?void 0:n.name)??t}function Yu(){return["可用命令:",...Si.map(t=>{var s;return`${(s=t.aliases)!=null&&s.length?[t.name,...t.aliases].map(o=>`/${o}`).join(", "):`/${t.name}`} - ${t.description}`})].join(`
|
|
17
|
+
**/let $l;const ca=typeof window<"u"&&window.trustedTypes;if(ca)try{$l=ca.createPolicy("vue",{createHTML:e=>e})}catch{}const Bu=$l?e=>$l.createHTML(e):e=>e,ag="http://www.w3.org/2000/svg",cg="http://www.w3.org/1998/Math/MathML",cn=typeof document<"u"?document:null,ua=cn&&cn.createElement("template"),ug={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,s)=>{const o=t==="svg"?cn.createElementNS(ag,e):t==="mathml"?cn.createElementNS(cg,e):n?cn.createElement(e,{is:n}):cn.createElement(e);return e==="select"&&s&&s.multiple!=null&&o.setAttribute("multiple",s.multiple),o},createText:e=>cn.createTextNode(e),createComment:e=>cn.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>cn.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,s,o,i){const l=n?n.previousSibling:t.lastChild;if(o&&(o===i||o.nextSibling))for(;t.insertBefore(o.cloneNode(!0),n),!(o===i||!(o=o.nextSibling)););else{ua.innerHTML=Bu(s==="svg"?`<svg>${e}</svg>`:s==="mathml"?`<math>${e}</math>`:e);const r=ua.content;if(s==="svg"||s==="mathml"){const a=r.firstChild;for(;a.firstChild;)r.appendChild(a.firstChild);r.removeChild(a)}t.insertBefore(r,n)}return[l?l.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},$n="transition",Ss="animation",gs=Symbol("_vtc"),Fu={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},ju=at({},lu,Fu),dg=e=>(e.displayName="Transition",e.props=ju,e),_i=dg((e,{slots:t})=>ze(fp,Uu(e),t)),Nn=(e,t=[])=>{we(e)?e.forEach(n=>n(...t)):e&&e(...t)},da=e=>e?we(e)?e.some(t=>t.length>1):e.length>1:!1;function Uu(e){const t={};for(const I in e)I in Fu||(t[I]=e[I]);if(e.css===!1)return t;const{name:n="v",type:s,duration:o,enterFromClass:i=`${n}-enter-from`,enterActiveClass:l=`${n}-enter-active`,enterToClass:r=`${n}-enter-to`,appearFromClass:a=i,appearActiveClass:c=l,appearToClass:u=r,leaveFromClass:f=`${n}-leave-from`,leaveActiveClass:h=`${n}-leave-active`,leaveToClass:p=`${n}-leave-to`}=e,v=fg(o),k=v&&v[0],w=v&&v[1],{onBeforeEnter:S,onEnter:$,onEnterCancelled:E,onLeave:L,onLeaveCancelled:Z,onBeforeAppear:j=S,onAppear:C=$,onAppearCancelled:x=E}=t,y=(I,H,O,B)=>{I._enterCancelled=B,Cn(I,H?u:r),Cn(I,H?c:l),O&&O()},T=(I,H)=>{I._isLeaving=!1,Cn(I,f),Cn(I,p),Cn(I,h),H&&H()},D=I=>(H,O)=>{const B=I?C:$,te=()=>y(H,I,O);Nn(B,[H,te]),fa(()=>{Cn(H,I?a:i),Qt(H,I?u:r),da(B)||ha(H,s,k,te)})};return at(t,{onBeforeEnter(I){Nn(S,[I]),Qt(I,i),Qt(I,l)},onBeforeAppear(I){Nn(j,[I]),Qt(I,a),Qt(I,c)},onEnter:D(!1),onAppear:D(!0),onLeave(I,H){I._isLeaving=!0;const O=()=>T(I,H);Qt(I,f),I._enterCancelled?(Qt(I,h),xl(I)):(xl(I),Qt(I,h)),fa(()=>{I._isLeaving&&(Cn(I,f),Qt(I,p),da(L)||ha(I,s,w,O))}),Nn(L,[I,O])},onEnterCancelled(I){y(I,!1,void 0,!0),Nn(E,[I])},onAppearCancelled(I){y(I,!0,void 0,!0),Nn(x,[I])},onLeaveCancelled(I){T(I),Nn(Z,[I])}})}function fg(e){if(e==null)return null;if(qe(e))return[Hi(e.enter),Hi(e.leave)];{const t=Hi(e);return[t,t]}}function Hi(e){return bh(e)}function Qt(e,t){t.split(/\s+/).forEach(n=>n&&e.classList.add(n)),(e[gs]||(e[gs]=new Set)).add(t)}function Cn(e,t){t.split(/\s+/).forEach(s=>s&&e.classList.remove(s));const n=e[gs];n&&(n.delete(t),n.size||(e[gs]=void 0))}function fa(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}let hg=0;function ha(e,t,n,s){const o=e._endId=++hg,i=()=>{o===e._endId&&s()};if(n!=null)return setTimeout(i,n);const{type:l,timeout:r,propCount:a}=Gu(e,t);if(!l)return s();const c=l+"end";let u=0;const f=()=>{e.removeEventListener(c,h),i()},h=p=>{p.target===e&&++u>=a&&f()};setTimeout(()=>{u<a&&f()},r+1),e.addEventListener(c,h)}function Gu(e,t){const n=window.getComputedStyle(e),s=v=>(n[v]||"").split(", "),o=s(`${$n}Delay`),i=s(`${$n}Duration`),l=pa(o,i),r=s(`${Ss}Delay`),a=s(`${Ss}Duration`),c=pa(r,a);let u=null,f=0,h=0;t===$n?l>0&&(u=$n,f=l,h=i.length):t===Ss?c>0&&(u=Ss,f=c,h=a.length):(f=Math.max(l,c),u=f>0?l>c?$n:Ss:null,h=u?u===$n?i.length:a.length:0);const p=u===$n&&/\b(?:transform|all)(?:,|$)/.test(s(`${$n}Property`).toString());return{type:u,timeout:f,propCount:h,hasTransform:p}}function pa(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max(...t.map((n,s)=>ga(n)+ga(e[s])))}function ga(e){return e==="auto"?0:Number(e.slice(0,-1).replace(",","."))*1e3}function xl(e){return(e?e.ownerDocument:document).body.offsetHeight}function pg(e,t,n){const s=e[gs];s&&(t=(t?[t,...s]:[...s]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}const Go=Symbol("_vod"),rr=Symbol("_vsh"),zu={name:"show",beforeMount(e,{value:t},{transition:n}){e[Go]=e.style.display==="none"?"":e.style.display,n&&t?n.beforeEnter(e):$s(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:s}){!t!=!n&&(s?t?(s.beforeEnter(e),$s(e,!0),s.enter(e)):s.leave(e,()=>{$s(e,!1)}):$s(e,t))},beforeUnmount(e,{value:t}){$s(e,t)}};function $s(e,t){e.style.display=t?e[Go]:"none",e[rr]=!t}const Hu=Symbol("");function gg(e){const t=ki();if(!t)return;const n=t.ut=(o=e(t.proxy))=>{Array.from(document.querySelectorAll(`[data-v-owner="${t.uid}"]`)).forEach(i=>zo(i,o))},s=()=>{const o=e(t.proxy);t.ce?zo(t.ce,o):Cl(t.subTree,o),n(o)};fu(()=>{Jc(s)}),ct(()=>{Ee(s,Vt,{flush:"post"});const o=new MutationObserver(s);o.observe(t.subTree.el.parentNode,{childList:!0}),vi(()=>o.disconnect())})}function Cl(e,t){if(e.shapeFlag&128){const n=e.suspense;e=n.activeBranch,n.pendingBranch&&!n.isHydrating&&n.effects.push(()=>{Cl(n.activeBranch,t)})}for(;e.component;)e=e.component.subTree;if(e.shapeFlag&1&&e.el)zo(e.el,t);else if(e.type===ee)e.children.forEach(n=>Cl(n,t));else if(e.type===To){let{el:n,anchor:s}=e;for(;n&&(zo(n,t),n!==s);)n=n.nextSibling}}function zo(e,t){if(e.nodeType===1){const n=e.style;let s="";for(const o in t){const i=Ih(t[o]);n.setProperty(`--${o}`,i),s+=`--${o}: ${i};`}n[Hu]=s}}const mg=/(?:^|;)\s*display\s*:/;function vg(e,t,n){const s=e.style,o=st(n);let i=!1;if(n&&!o){if(t)if(st(t))for(const l of t.split(";")){const r=l.slice(0,l.indexOf(":")).trim();n[r]==null&&Ms(s,r,"")}else for(const l in t)n[l]==null&&Ms(s,l,"");for(const l in n){l==="display"&&(i=!0);const r=n[l];r!=null?bg(e,l,!st(t)&&t?t[l]:void 0,r)||Ms(s,l,r):Ms(s,l,"")}}else if(o){if(t!==n){const l=s[Hu];l&&(n+=";"+l),s.cssText=n,i=mg.test(n)}}else t&&e.removeAttribute("style");Go in e&&(e[Go]=i?s.display:"",e[rr]&&(s.display="none"))}const ma=/\s*!important$/;function Ms(e,t,n){if(we(n))n.forEach(s=>Ms(e,t,s));else if(n==null&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const s=yg(e,t);ma.test(n)?e.setProperty(En(s),n.replace(ma,""),"important"):e[s]=n}}const va=["Webkit","Moz","ms"],Wi={};function yg(e,t){const n=Wi[t];if(n)return n;let s=Mt(t);if(s!=="filter"&&s in e)return Wi[t]=s;s=ui(s);for(let o=0;o<va.length;o++){const i=va[o]+s;if(i in e)return Wi[t]=i}return t}function bg(e,t,n,s){return e.tagName==="TEXTAREA"&&(t==="width"||t==="height")&&st(s)&&n===s}const ya="http://www.w3.org/1999/xlink";function ba(e,t,n,s,o,i=xh(t)){s&&t.startsWith("xlink:")?n==null?e.removeAttributeNS(ya,t.slice(6,t.length)):e.setAttributeNS(ya,t,n):n==null||i&&!Mc(n)?e.removeAttribute(t):e.setAttribute(t,i?"":Yt(n)?String(n):n)}function ka(e,t,n,s,o){if(t==="innerHTML"||t==="textContent"){n!=null&&(e[t]=t==="innerHTML"?Bu(n):n);return}const i=e.tagName;if(t==="value"&&i!=="PROGRESS"&&!i.includes("-")){const r=i==="OPTION"?e.getAttribute("value")||"":e.value,a=n==null?e.type==="checkbox"?"on":"":String(n);(r!==a||!("_value"in e))&&(e.value=a),n==null&&e.removeAttribute(t),e._value=n;return}let l=!1;if(n===""||n==null){const r=typeof e[t];r==="boolean"?n=Mc(n):n==null&&r==="string"?(n="",l=!0):r==="number"&&(n=0,l=!0)}try{e[t]=n}catch{}l&&e.removeAttribute(o||t)}function Gn(e,t,n,s){e.addEventListener(t,n,s)}function kg(e,t,n,s){e.removeEventListener(t,n,s)}const wa=Symbol("_vei");function wg(e,t,n,s,o=null){const i=e[wa]||(e[wa]={}),l=i[t];if(s&&l)l.value=s;else{const[r,a]=$g(t);if(s){const c=i[t]=Tg(s,o);Gn(e,r,c,a)}else l&&(kg(e,r,l,a),i[t]=void 0)}}const _g=/(Once|Passive|Capture)$/,Sg=/^on:?(?:Once|Passive|Capture)$/;function $g(e){let t,n;for(;(n=e.match(_g))&&!Sg.test(e);)t||(t={}),e=e.slice(0,e.length-n[1].length),t[n[1].toLowerCase()]=!0;return[e[2]===":"?e.slice(3):En(e.slice(2)),t]}let qi=0;const xg=Promise.resolve(),Cg=()=>qi||(xg.then(()=>qi=0),qi=Date.now());function Tg(e,t){const n=s=>{if(!s._vts)s._vts=Date.now();else if(s._vts<=n.attached)return;const o=n.value;if(we(o)){const i=s.stopImmediatePropagation;s.stopImmediatePropagation=()=>{i.call(s),s._stopped=!0};const l=o.slice(),r=[s];for(let a=0;a<l.length&&!s._stopped;a++){const c=l[a];c&&qt(c,t,5,r)}}else qt(o,t,5,[s])};return n.value=e,n.attached=Cg(),n}const _a=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,Ig=(e,t,n,s,o,i)=>{const l=o==="svg";t==="class"?pg(e,s,l):t==="style"?vg(e,n,s):li(t)?ri(t)||wg(e,t,n,s,i):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):Rg(e,t,s,l))?(ka(e,t,s),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&ba(e,t,s,l,i,t!=="value")):e._isVueCE&&(Ag(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!st(s)))?ka(e,Mt(t),s,i,t):(t==="true-value"?e._trueValue=s:t==="false-value"&&(e._falseValue=s),ba(e,t,s,l))};function Rg(e,t,n,s){if(s)return!!(t==="innerHTML"||t==="textContent"||t in e&&_a(t)&&Ae(n));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="autocorrect"||t==="sandbox"&&e.tagName==="IFRAME"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const o=e.tagName;if(o==="IMG"||o==="VIDEO"||o==="CANVAS"||o==="SOURCE")return!1}return _a(t)&&st(n)?!1:t in e}function Ag(e,t){const n=e._def.props;if(!n)return!1;const s=Mt(t);return Array.isArray(n)?n.some(o=>Mt(o)===s):Object.keys(n).some(o=>Mt(o)===s)}const Wu=new WeakMap,qu=new WeakMap,Ho=Symbol("_moveCb"),Sa=Symbol("_enterCb"),Mg=e=>(delete e.props.mode,e),Eg=Mg({name:"TransitionGroup",props:at({},ju,{tag:String,moveClass:String}),setup(e,{slots:t}){const n=ki(),s=iu();let o,i;return hu(()=>{if(!o.length)return;const l=e.moveClass||`${e.name||"v"}-move`;if(!Ng(o[0].el,n.vnode.el,l)){o=[];return}o.forEach(Lg),o.forEach(Og);const r=o.filter(Dg);xl(n.vnode.el),r.forEach(a=>{const c=a.el,u=c.style;Qt(c,l),u.transform=u.webkitTransform=u.transitionDuration="";const f=c[Ho]=h=>{h&&h.target!==c||(!h||h.propertyName.endsWith("transform"))&&(c.removeEventListener("transitionend",f),c[Ho]=null,Cn(c,l))};c.addEventListener("transitionend",f)}),o=[]}),()=>{const l=Ge(e),r=Uu(l);let a=l.tag||ee;if(o=[],i)for(let c=0;c<i.length;c++){const u=i[c];u.el&&u.el instanceof Element&&!u.el[rr]&&(o.push(u),Yn(u,zs(u,r,s,n)),Wu.set(u,Vu(u.el)))}i=t.default?nr(t.default()):[];for(let c=0;c<i.length;c++){const u=i[c];u.key!=null&&Yn(u,zs(u,r,s,n))}return J(a,null,i)}}}),Pg=Eg;function Lg(e){const t=e.el;t[Ho]&&t[Ho](),t[Sa]&&t[Sa]()}function Og(e){qu.set(e,Vu(e.el))}function Dg(e){const t=Wu.get(e),n=qu.get(e),s=t.left-n.left,o=t.top-n.top;if(s||o){const i=e.el,l=i.style,r=i.getBoundingClientRect();let a=1,c=1;return i.offsetWidth&&(a=r.width/i.offsetWidth),i.offsetHeight&&(c=r.height/i.offsetHeight),(!Number.isFinite(a)||a===0)&&(a=1),(!Number.isFinite(c)||c===0)&&(c=1),Math.abs(a-1)<.01&&(a=1),Math.abs(c-1)<.01&&(c=1),l.transform=l.webkitTransform=`translate(${s/a}px,${o/c}px)`,l.transitionDuration="0s",e}}function Vu(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top}}function Ng(e,t,n){const s=e.cloneNode(),o=e[gs];o&&o.forEach(r=>{r.split(/\s+/).forEach(a=>a&&s.classList.remove(a))}),n.split(/\s+/).forEach(r=>r&&s.classList.add(r)),s.style.display="none";const i=t.nodeType===1?t:t.parentNode;i.appendChild(s);const{hasTransform:l}=Gu(s);return i.removeChild(s),l}const Wo=e=>{const t=e.props["onUpdate:modelValue"]||!1;return we(t)?n=>$o(t,n):t};function Bg(e){e.target.composing=!0}function $a(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const fs=Symbol("_assign");function xa(e,t,n){return t&&(e=e.trim()),n&&(e=di(e)),e}const ut={created(e,{modifiers:{lazy:t,trim:n,number:s}},o){e[fs]=Wo(o);const i=s||o.props&&o.props.type==="number";Gn(e,t?"change":"input",l=>{l.target.composing||e[fs](xa(e.value,n,i))}),(n||i)&&Gn(e,"change",()=>{e.value=xa(e.value,n,i)}),t||(Gn(e,"compositionstart",Bg),Gn(e,"compositionend",$a),Gn(e,"change",$a))},mounted(e,{value:t}){e.value=t??""},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:s,trim:o,number:i}},l){if(e[fs]=Wo(l),e.composing)return;const r=(i||e.type==="number")&&!/^0\d/.test(e.value)?di(e.value):e.value,a=t??"";if(r===a)return;const c=e.getRootNode();(c instanceof Document||c instanceof ShadowRoot)&&c.activeElement===e&&e.type!=="range"&&(s&&t===n||o&&e.value.trim()===a)||(e.value=a)}},Ca={deep:!0,created(e,{value:t,modifiers:{number:n}},s){e._modelValue=t,Gn(e,"change",()=>{const o=Array.prototype.filter.call(e.options,i=>i.selected).map(i=>n?di(qo(i)):qo(i));e[fs](e.multiple?ai(e._modelValue)?new Set(o):o:o[0]),e._assigning=!0,ft(()=>{e._assigning=!1})}),e[fs]=Wo(s)},mounted(e,{value:t}){Ta(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[fs]=Wo(n)},updated(e,{value:t}){e._assigning||Ta(e,t)}};function Ta(e,t){const n=e.multiple,s=we(t);if(!(n&&!s&&!ai(t))){for(let o=0,i=e.options.length;o<i;o++){const l=e.options[o],r=qo(l);if(n)if(s){const a=typeof r;a==="string"||a==="number"?l.selected=t.some(c=>String(c)===String(r)):l.selected=Th(t,r)>-1}else l.selected=t.has(r);else if(to(qo(l),t)){e.selectedIndex!==o&&(e.selectedIndex=o);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function qo(e){return"_value"in e?e._value:e.value}const Fg=["ctrl","shift","alt","meta"],jg={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>Fg.some(n=>e[`${n}Key`]&&!t.includes(n))},rt=(e,t)=>{if(!e)return e;const n=e._withMods||(e._withMods={}),s=t.join(".");return n[s]||(n[s]=((o,...i)=>{for(let l=0;l<t.length;l++){const r=jg[t[l]];if(r&&r(o,t))return}return e(o,...i)}))},Ug={esc:"escape",space:" ",up:"arrow-up",left:"arrow-left",right:"arrow-right",down:"arrow-down",delete:"backspace"},Vn=(e,t)=>{const n=e._withKeys||(e._withKeys={}),s=t.join(".");return n[s]||(n[s]=(o=>{if(!("key"in o))return;const i=En(o.key);if(t.some(l=>l===i||Ug[l]===i))return e(o)}))},Gg=at({patchProp:Ig},ug);let Ia;function zg(){return Ia||(Ia=Hp(Gg))}const Hg=((...e)=>{const t=zg().createApp(...e),{mount:n}=t;return t.mount=s=>{const o=qg(s);if(!o)return;const i=t._component;!Ae(i)&&!i.render&&!i.template&&(i.template=o.innerHTML),o.nodeType===1&&(o.textContent="");const l=n(o,!1,Wg(o));return o instanceof Element&&(o.removeAttribute("v-cloak"),o.setAttribute("data-v-app","")),l},t});function Wg(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function qg(e){return st(e)?document.querySelector(e):e}function mo(e,t,n,s){return e===n&&t===s}function Vg(e){return e.currentSessionId===e.targetSessionId&&e.snapshot.sessionId===e.targetSessionId&&e.currentSessionGeneration===e.targetSessionGeneration&&e.currentConnectionGeneration===e.targetConnectionGeneration&&e.currentPromptGeneration===e.targetPromptGeneration&&e.currentLiveGeneration===e.targetLiveGeneration&&(e.currentEpoch===0||e.snapshot.epoch===e.currentEpoch)&&(e.snapshot.epoch!==e.currentEpoch||e.snapshot.seq>=e.currentSeq)}function Kg(e){return{objective:e.objective,completionCriterion:e.completionCriterion,replace:e.replace,budgets:e.budgets}}function Yg(e){return{objective:e.objective,budgets:e.budgets}}function Zg(e,t,n){return e!==0&&n.epoch!==e?"resync":n.seq<=t?"duplicate":"apply"}function Jg(e,t){return t.type==="goal.updated"?{...e,goal:t.snapshot}:t.type==="todo.updated"?{...e,todos:t.todos}:e}function Xg(e){const t=[],n=new Map;for(const s of e){const o=s.phase??null;let i=n.get(o);i===void 0&&(i=t.length,n.set(o,i),t.push({phase:o,items:[]})),t[i].items.push(s)}return t}const Vs=F([]);let Qg=0;function em(e,t="info",n=3500){const s=`toast_${++Qg}`;Vs.value=[...Vs.value,{id:s,type:t,message:e}],n>0&&window.setTimeout(()=>Ku(s),n)}function Ku(e){Vs.value=Vs.value.filter(t=>t.id!==e)}function ar(){return{toasts:Vs,showToast:em,removeToast:Ku}}function tm(e){let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},flushNow:()=>{t!==null&&(cancelAnimationFrame(t),t=null),e()},dispose:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}}const Ks=new Map;function nm(e){Ks.set(e,Date.now())}function sm(e){return Ks.get(e)}function om(e){const t=Ks.get(e);return t!==void 0&&Ks.delete(e),t}function im(){Ks.clear()}function Vi(e){const t=e/1e3;return t<10?`${t.toFixed(1)}s`:t<60?`${Math.round(t)}s`:`${Math.floor(t/60)}m${String(Math.round(t%60)).padStart(2,"0")}s`}const Be="/api/v1",lm=2*3e4;function rm(){const{showToast:e}=ar(),t=F("connecting"),n=F([]),s=F(!1),o=F(void 0),i=F([]),l=F({busy:!1}),r=F(null),a=F([]),c=F(!1),u=F(null),f=F(!1),h=F(null),p=F(null),v=F(null),k=q(()=>l.value.busy||f.value),w=F([]),S=F(null),$=F(!1),E=q(()=>p.value!==null&&!$.value),L=F(null),Z=F([]),j=F(null),C=F([]),x=F([]),y=F(null),T=F([]),D=F(null),I=F([]),H=F(""),O=F(null),B=F(null),te=F(!1);let oe=null,_e=null,Se=null,je=null,Qe=Date.now(),ge=0,he=0,Fe=0,K=0,ae=0,V=0,ve=0,Oe=0,Ue=0,Pe=null,_=!1,M=null,G=!1,Q=!1;const Y=new Map,X="scream-offline-prompt-queue";let ie=[];try{const b=localStorage.getItem(X);if(b){const P=JSON.parse(b);Array.isArray(P)&&(ie=P.filter(se=>typeof se=="string"))}}catch{ie=[]}function ce(){try{localStorage.setItem(X,JSON.stringify(ie.slice(0,20)))}catch{}}function A(){if(ie.length===0)return;const b=ie[0],P=`client_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,se=Ye();Y.set(P,{messageId:se,connectionGeneration:ae}),V++,G=!1,f.value=!0,n.value.push({id:se,role:"user",content:b,clientMessageId:P,tools:[],ts:Date.now()}),Lr(b),Ne({type:"prompt",text:b,clientMessageId:P})}function N(){ie.length>0&&ie.shift(),ce(),A()}let ue=0,de=0,pe=null,ye=0;function Le(){const P=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`;return S.value?`${P}?sessionId=${encodeURIComponent(S.value)}`:P}function De(b){t.value=b}function Ne(b){(oe==null?void 0:oe.readyState)===WebSocket.OPEN&&oe.send(JSON.stringify(b))}function Ke(){c.value=_||Pe!==null}function ot(){Ue++,Pe=null,_=!1,M=null,c.value=!1,u.value=null}function bt(b,P){if(b!==null&&typeof b=="object"){const se=b.message;if(typeof se=="string")return se}return P}function ne(){Q||je!==null||(je=window.setTimeout(()=>{je=null;const b=M;M=null,be(b??void 0)},250))}async function be(b){const P=p.value;if(!P)return;const se=n.value.length===0?100:void 0,re=K,ke=ae,Re=V,et=ve;try{const nt=await fetch(`${Be}/sessions/${P}/snapshot${se?`?tail=${se}`:""}`);if(!nt.ok){b!==void 0&&(Pe==null?void 0:Pe.generation)===b&&(M=b,ne());return}const Ft=await nt.json();if(!Vg({snapshot:Ft,targetSessionId:P,currentSessionId:p.value,targetSessionGeneration:re,currentSessionGeneration:K,targetConnectionGeneration:ke,currentConnectionGeneration:ae,targetPromptGeneration:Re,currentPromptGeneration:V,targetLiveGeneration:et,currentLiveGeneration:ve,currentEpoch:he,currentSeq:ge})){b!==void 0&&(M=b),ne();return}Et(Ft,b)}catch{b!==void 0&&(Pe==null?void 0:Pe.generation)===b&&(M=b,ne())}}function Et(b,P){var Ur;es="",Pn="",Ln.clear();const se=n.value.filter(jt=>jt.local),re=Y.keys().next().value,ke=re?Y.get(re):void 0,Re=ke?n.value.find(jt=>jt.id===ke.messageId):void 0,et=!!(re&&b.messages.some(jt=>jt.clientMessageId===re)),nt=!!(ke&&!et&&ke.connectionGeneration<ae);nt&&Re&&(Re.isError=!0);const Ft=Re&&!et?[Re]:[];n.value=[...b.messages.map(jt=>({...jt,id:jt.id??Ye()})),...se,...Ft];for(let jt=n.value.length-1;jt>=0;jt--){const uo=(Ur=n.value[jt])==null?void 0:Ur.turnStats;if(uo&&typeof uo.turn=="number"&&uo.turn>0){ue=uo.turn;break}}i.value=b.pendingApprovals,l.value={...b.status,busy:b.busy},s.value=!!b.olderAvailable,o.value=b.oldestSeq,r.value=b.goal,a.value=b.todos,P!==void 0&&Pe!==null&&Pe.generation===P&&Ue===P&&(Pe=null,Ke()),(et||nt)&&(f.value=!1,G=!1,Y.clear(),nt&&e("消息未送达,已恢复连接。","error")),ge=b.seq,he=b.epoch,v.value=b.workDir}function Ye(){return`msg_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Bt(b){Sn(),Qe=Date.now(),_e=window.setInterval(()=>{if(Date.now()-Qe>lm){oe==null||oe.close();return}Ne({type:"ping"})},b)}function Sn(){_e!==null&&(clearInterval(_e),_e=null)}function ro(){if(Q||Se!==null)return;De("reconnecting"),Fe++;const b=Math.min(1e3*2**Fe,3e4);Se=window.setTimeout(()=>{Se=null,Jt()},b)}function af(b){switch(b.type){case"server_hello":{const P=b;p.value=P.sessionId,v.value=P.workDir,S.value=P.sessionId,$.value=P.active;const se=he;he=P.epoch,Bt(P.heartbeat_ms),Ne({type:"client_hello",lastSeq:ge,epoch:se}),se!==0&&se!==P.epoch&&(ge=0),De("connected"),Fe=0,A(),P.active?(be(),ss(),ao()):yf(P.sessionId).then(re=>{re&&p.value===P.sessionId&&($.value=!0),be(),ss(),ao()});break}case"event":{const P=Zg(he,ge,b);if(P==="resync"){he=b.epoch,ge=0,be();break}if(P==="duplicate")break;ge=b.seq,he=b.epoch,ve++,uf(b.payload);break}case"user_message":{if(ve++,b.clientMessageId&&Y.has(b.clientMessageId)){G=!0,N();break}n.value.push({id:Ye(),role:"user",content:b.text,clientMessageId:b.clientMessageId,tools:[],ts:Date.now()});break}case"approval_request":{ve++,i.value=[...i.value,{id:b.id,toolName:b.toolName,action:b.action,display:b.display}];break}case"approval_resolved":{ve++,i.value=i.value.filter(P=>P.id!==b.id);break}case"command_result":{const P=b.pendingMsgId?n.value.findIndex(se=>se.id===b.pendingMsgId):-1;if(P>=0){const se=n.value[P];n.value[P]={...se,content:b.message,isError:!b.ok,pending:!1}}else n.value.push({id:Ye(),role:"system",content:b.message,tools:[],isError:!b.ok,ts:Date.now(),local:!0});(b.command==="fork"||b.command==="title")&&ss(),b.ok&&b.command==="compact"&&be();break}case"resync_required":{ge=0,be();break}case"status":{ve++,l.value={...l.value,...b.status};break}case"error":{if(h.value=b.message,b.clientMessageId){const P=Y.get(b.clientMessageId);if(P){Y.delete(b.clientMessageId),f.value=!1,G=!1;const se=n.value.find(re=>re.id===P.messageId);se&&(se.isError=!0),e(`消息未发送:${b.message}`,"error"),ie.length>0&&(ie.shift(),ce())}}break}case"server_empty":{De("idle");break}}}let es="",Pn="";const Ln=new Map;let Er=!1;function cf(){if(Er)return;const b=ns();if(!b){es="",Pn="",Ln.clear();return}if(es&&(b.content+=es,es=""),Pn){const P=b.tools.find(se=>se.name==="thinking");P?P.output=(P.output??"")+Pn:b.tools.push({toolCallId:"thinking",name:"thinking",output:Pn}),Pn=""}if(Ln.size>0){for(const[P,se]of Ln){const re=b.tools.find(ke=>ke.toolCallId===P);re&&(re.progress=se)}Ln.clear()}}const ts=tm(cf);function uf(b){var se;const P=Jg({goal:r.value,todos:a.value},b);switch(r.value=P.goal,a.value=P.todos,b.type==="goal.updated"&&Pe!==null&&Pe.generation===Ue&&(Pe=null,M=null,Ke()),b.type){case"turn.started":{G&&(f.value=!1,G=!1,Y.clear()),ts.flushNow(),l.value={...l.value,busy:!0},ue+=1,de=Date.now(),pe=null,ye=0,im(),n.value.push({id:Ye(),role:"assistant",content:"",tools:[],ts:Date.now(),model:l.value.model,turnStats:{turn:ue,step:0,status:"running",firstTokenMs:null,llmMs:0,toolMs:0,tokens:null,tokensPerSec:null}});break}case"assistant.delta":{pe===null&&(pe=Date.now()),es+=String(b.delta),ts.schedule();break}case"thinking.delta":{pe===null&&(pe=Date.now()),Pn+=String(b.delta),ts.schedule();break}case"tool.call.started":{const re=ns();re&&(re.tools.push({toolCallId:String(b.toolCallId),name:String(b.name),args:b.args}),re.turnStats&&(re.turnStats.step+=1)),nm(String(b.toolCallId));break}case"tool.result":{Ln.delete(String(b.toolCallId));const re=om(String(b.toolCallId));re!==void 0&&(ye+=Date.now()-re);const ke=ns();if(ke){const Re=ke.tools.find(et=>et.toolCallId===b.toolCallId);Re&&(Re.output=String(b.output),Re.isError=!!b.isError,Re.progress=void 0,re!==void 0&&(Re.durationMs=Date.now()-re))}break}case"tool.progress":{Ln.set(String(b.toolCallId),String(b.message??b.output)),ts.schedule();break}case"turn.ended":{if(ts.flushNow(),l.value={...l.value,busy:!1},b.reason==="failed"){const nt=ns();nt&&(nt.isError=!0),h.value=bt(b.error,"Turn failed")}const re=ns(),ke=Date.now()-de,Re=(se=l.value.usage)==null?void 0:se.currentTurn,et=Re?Re.inputOther+Re.output+Re.inputCacheRead+Re.inputCacheCreation:null;re&&re.turnStats&&(re.turnStats.status="done",re.turnStats.llmMs=ke,re.turnStats.toolMs=ye,re.turnStats.firstTokenMs=pe!==null?pe-de:null,re.turnStats.tokens=et,re.turnStats.tokensPerSec=et!==null&&ke>0?Math.round(et/ke*1e3):null),ss(),ao();break}case"session.meta.updated":{const re={};b.model!==void 0&&(re.model=b.model),b.contextTokens!==void 0&&(re.contextTokens=b.contextTokens),b.maxContextTokens!==void 0&&(re.maxContextTokens=b.maxContextTokens),b.contextUsage!==void 0&&(re.contextUsage=b.contextUsage),l.value={...l.value,...re};break}case"agent.status.updated":{const re={};if(b.model!==void 0&&(re.model=b.model),b.thinkingLevel!==void 0&&(re.thinkingLevel=b.thinkingLevel),b.contextTokens!==void 0&&(re.contextTokens=b.contextTokens),b.maxContextTokens!==void 0&&(re.maxContextTokens=b.maxContextTokens),b.contextUsage!==void 0&&(re.contextUsage=b.contextUsage),b.usage!==void 0){re.usage=b.usage;const ke=b.usage;if(ke!=null&&ke.currentTurn){const Re=ns(),et=ke.currentTurn.inputOther+ke.currentTurn.output+ke.currentTurn.inputCacheRead+ke.currentTurn.inputCacheCreation;Re!=null&&Re.turnStats&&Re.turnStats.status==="done"&&Re.turnStats.tokens===null&&(Re.turnStats.tokens=et,Re.turnStats.tokensPerSec=Re.turnStats.llmMs?Math.round(et/Re.turnStats.llmMs*1e3):null)}}l.value={...l.value,...re};break}case"error":{h.value=bt(b.error,"Unknown error");break}}}function ns(){for(let b=n.value.length-1;b>=0;b--)if(n.value[b].role==="assistant")return n.value[b];return null}function df(){if(!Q){if(Se!==null&&(clearTimeout(Se),Se=null),oe!==null){try{oe.close()}catch{}oe=null}Fe=0,Jt()}}async function ff(){var se;const b=p.value,P=o.value;if(!b||P===void 0)return 0;try{const re=await fetch(`${Be}/sessions/${b}/messages?before=${P}&tail=50`);if(!re.ok)return 0;const ke=await re.json();if(ke.messages.length===0)return 0;const Re=ke.messages.map(et=>({...et,id:et.id??Ye()}));return n.value=[...Re,...n.value],o.value=((se=Re[0])==null?void 0:se.seq)??P,s.value=ke.hasMore,Re.length}catch{return 0}}function Jt(){if(Q||oe&&(oe.readyState===WebSocket.CONNECTING||oe.readyState===WebSocket.OPEN))return;De("connecting"),h.value=null,ot(),ae++;const b=new WebSocket(Le());oe=b,b.onclose=P=>{if(oe===b&&(oe=null,Sn(),t.value!=="idle")){if(P.code===1008){K++,ot(),p.value=null,S.value=null,$.value=!1,r.value=null,a.value=[],De("idle");return}De("disconnected"),ro()}},b.onerror=()=>{oe===b&&De("reconnecting")},b.onmessage=P=>{if(oe!==b)return;Qe=Date.now();let se;try{se=JSON.parse(P.data)}catch{return}af(se)}}function hf(b){if(!b)return;if(t.value==="idle"){e("暂无会话,请先新建会话。","warning");return}if(t.value!=="connected"){ie.push(b),ce(),e("连接已断开,消息已排队,重连后自动发送。","warning"),Jt();return}if(k.value)return;const P=`client_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,se=Ye();Y.set(P,{messageId:se,connectionGeneration:ae}),V++,G=!1,f.value=!0,n.value.push({id:se,role:"user",content:b,clientMessageId:P,tools:[],ts:Date.now()}),Lr(b),Ne({type:"prompt",text:b,clientMessageId:P})}const Pr="scream-recent-prompts";let bs=[];try{const b=localStorage.getItem(Pr);if(b){const P=JSON.parse(b);Array.isArray(P)&&(bs=P.filter(se=>typeof se=="string"))}}catch{bs=[]}function Lr(b){const P=b.trim();if(P){bs=[P,...bs.filter(se=>se!==P)].slice(0,8);try{localStorage.setItem(Pr,JSON.stringify(bs))}catch{}}}function pf(){Ne({type:"abort"})}function gf(b,P){if(t.value==="idle"){e("暂无会话,请先新建会话。","warning");return}if(t.value!=="connected"){e("连接已断开,命令未发送。","error"),Jt();return}if(k.value&&b!=="btw"){e(`会话忙碌中,无法执行 /${b},请稍后再试。`,"warning");return}const se=["compact","plan","auto","yes","fork","title"];let re=null;se.includes(b)&&(re=Ye(),n.value.push({id:re,role:"system",content:`正在执行 /${b}${P?` ${P}`:""}...`,tools:[],pending:!0,ts:Date.now(),local:!0})),Ne({type:"command",command:b,...P?{args:P}:{},...re?{pendingMsgId:re}:{}})}function mf(){n.value=[],i.value=[]}function Or(b){n.value.push({id:Ye(),role:"system",content:b,tools:[],ts:Date.now(),local:!0})}function vf(b,P,se,re){if(t.value!=="connected"){e("连接已断开,审批结果未发送。","error"),Jt();return}i.value=i.value.filter(ke=>ke.id!==b),Ne({type:"approval_response",id:b,decision:P,...se?{feedback:se}:{},...re?{scope:re}:{}})}async function ss(){try{const b=await fetch(`${Be}/sessions`);if(!b.ok)return;w.value=await b.json()}catch{}}async function yf(b){const P=K,se=ae;try{return(await fetch(`${Be}/sessions/${b}/activate`,{method:"POST"})).ok&&ae===se&&mo(p.value,K,b,P)}catch{return!1}}async function ao(){try{const b=await fetch(`${Be}/git/status`);if(!b.ok)return;const P=await b.json();L.value=P.isRepo?P:null}catch{}}async function Dr(){try{const b=await fetch(`${Be}/models`);if(!b.ok)return;const P=await b.json();Z.value=P.models}catch{}}const Ei=F({});async function bf(){try{const b=await fetch(`${Be}/like`);if(!b.ok)return;Ei.value=await b.json()}catch{}}async function kf(b){try{return(await fetch(`${Be}/like`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)})).ok?(Ei.value=b,!0):!1}catch{return!1}}async function Nr(b,P,se){const re=p.value;if(!re)return;const ke=K,Re=ae,et=++Oe;try{const nt=await fetch(`${Be}/sessions/${re}/${b}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)}),Ft=await nt.json();if(p.value!==re||K!==ke||ae!==Re||Oe!==et)return;if(!nt.ok){e(Ft.message??`请求失败(HTTP ${nt.status})`,"error");return}Ft.status&&(l.value={...l.value,...Ft.status}),Or(se)}catch(nt){if(p.value!==re||K!==ke||ae!==Re||Oe!==et)return;e(`请求失败:${nt instanceof Error?nt.message:String(nt)}`,"error")}}async function wf(b){b!==l.value.model&&await Nr("model",{model:b},`已切换模型:${b}`)}async function _f(b){b!==l.value.thinkingLevel&&await Nr("thinking",{level:b},`思考强度已切换为 ${b}`)}async function co(b,P,se,re){const ke=p.value;if(!ke)return u.value="暂无可操作的会话。",null;if(t.value!=="connected")return u.value="连接已断开,请等待重连后再试。",null;if(E.value)return u.value="当前会话已归档,无法修改 Goal。",null;if(_)return u.value="正在处理上一个请求,请稍候。",null;Pe!==null&&(Pe=null,Ke());const Re=K,et=++Ue;_=!0,Ke(),u.value=null;try{const nt=await fetch(`${Be}/sessions/${ke}/goal${b}`,{method:P,headers:{"Content-Type":"application/json"},body:JSON.stringify(se)}),Ft=await nt.json().catch(()=>({}));return!mo(p.value,K,ke,Re)||Ue!==et?null:nt.ok?(re&&(Pe={generation:et},M=et),Ft):(u.value=typeof Ft.message=="string"?Ft.message:`请求失败(HTTP ${nt.status})`,null)}catch(nt){return mo(p.value,K,ke,Re)&&Ue===et&&(u.value=`请求失败:${nt instanceof Error?nt.message:String(nt)}`),null}finally{mo(p.value,K,ke,Re)&&Ue===et&&(_=!1,Ke())}}async function Sf(b){const P=await co("/refine","POST",{description:b},!1);return typeof(P==null?void 0:P.objective)=="string"?P.objective:null}async function $f(b){return await co("","POST",Kg(b),!0)===null?!1:(Pe!==null&&be(Pe.generation),!0)}async function xf(b){return await co("","PATCH",Yg(b),!0)===null?!1:(Pe!==null&&be(Pe.generation),!0)}async function Pi(b){return await co(b,"POST",{},!0)===null?!1:(Pe!==null&&be(Pe.generation),!0)}function Cf(){return Pi("/pause")}function Tf(){return Pi("/resume")}function If(){return Pi("/cancel")}async function Rf(){try{const b=await fetch(`${Be}/sessions`,{method:"POST"});if(!b.ok){e(`新建会话失败(HTTP ${b.status})`,"error");return}const P=await b.json();w.value=[P,...w.value],await Li(P.sessionId)}catch(b){e(`新建会话失败:${b instanceof Error?b.message:String(b)}`,"error")}}async function Li(b){S.value===b&&t.value==="connected"||(S.value=b,p.value=b,K++,ot(),ge=0,he=0,n.value=[],i.value=[],l.value={busy:!1},r.value=null,a.value=[],j.value=null,C.value=[],x.value=[],y.value=null,T.value=[],D.value=null,I.value=[],H.value="",$.value=!1,f.value=!1,G=!1,Y.clear(),Se!==null&&(clearTimeout(Se),Se=null),je!==null&&(clearTimeout(je),je=null),oe&&(oe.onclose=null,oe.close(),oe=null),Sn(),Jt())}async function Af(b){try{const P=await fetch(`${Be}/sessions/${b}`,{method:"DELETE"});if(!P.ok){e(`删除会话失败(HTTP ${P.status})`,"error");return}if(w.value=w.value.filter(se=>se.sessionId!==b),S.value===b){const se=w.value[0];se?await Li(se.sessionId):(K++,ot(),p.value=null,S.value=null,$.value=!1,ge=0,he=0,n.value=[],i.value=[],l.value={busy:!1},r.value=null,a.value=[],j.value=null,C.value=[],x.value=[],y.value=null,T.value=[],D.value=null,I.value=[],H.value="",f.value=!1,G=!1,Y.clear(),oe&&(oe.onclose=null,oe.close(),oe=null),Sn(),De("idle"))}}catch(P){e(`删除会话失败:${P instanceof Error?P.message:String(P)}`,"error")}}async function Mf(b){try{const P=await fetch(`${Be}/sessions/${b}/export`);if(!P.ok){e(`导出会话失败(HTTP ${P.status})`,"error");return}const se=await P.blob(),re=URL.createObjectURL(se),ke=document.createElement("a");ke.href=re,ke.download=`${b}.md`,ke.click(),URL.revokeObjectURL(re)}catch(P){e(`导出会话失败:${P instanceof Error?P.message:String(P)}`,"error")}}async function ks(){const b=p.value;if(b)try{const P=await fetch(`${Be}/sessions/${b}/status`);if(!P.ok)return;const se=await P.json();l.value={...l.value,...se}}catch{}}async function Ef(){const b=p.value;if(b)try{const P=await fetch(`${Be}/sessions/${b}/usage`);if(!P.ok)return;const se=await P.json();l.value={...l.value,usage:se}}catch{}}async function Pf(){const b=p.value;if(b)try{const P=await fetch(`${Be}/sessions/${b}/context`);if(!P.ok)return;const se=await P.json();se.tokenCount!==void 0&&(l.value={...l.value,contextTokens:se.tokenCount})}catch{}}async function Lf(){const b=p.value;if(b)try{const P=await fetch(`${Be}/sessions/${b}/plan`);if(!P.ok)return;j.value=await P.json()}catch{}}async function Of(){const b=p.value;if(!b)return!1;try{return(await fetch(`${Be}/sessions/${b}/plan/clear`,{method:"POST"})).ok?(j.value=null,!0):!1}catch{return!1}}async function kt(b,P){const se=p.value;if(!se)return!1;if(t.value!=="connected")return e("连接已断开,操作未发送。","error"),Jt(),!1;try{const re=await fetch(`${Be}/sessions/${se}/${b}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(P??{})});if(!re.ok){const ke=await re.json().catch(()=>({}));return e(ke.message??`操作失败(HTTP ${re.status})`,"error"),!1}return!0}catch(re){return e(`操作失败:${re instanceof Error?re.message:String(re)}`,"error"),!1}}async function Df(b){const P=await kt("permission",{mode:b});return P&&await ks(),P}async function Nf(b,P){const se=await kt("plan",{enabled:b,...P?{strategy:P}:{}});return se&&await ks(),se}async function Bf(b){const P=await kt("wolfpack",{enabled:b});return P&&await ks(),P}async function Ff(b,P){const se=await kt("rlm",{enabled:b,...P!==void 0?{maxDepth:P}:{}});return se&&await ks(),se}async function jf(b=1){return kt("undo",{count:b})}async function Uf(b){return kt("compact",b?{instruction:b}:{})}async function Gf(){const b=p.value;if(b)try{const P=await fetch(`${Be}/sessions/${b}/skills`);if(!P.ok)return;C.value=await P.json()}catch{}}async function zf(b,P){return kt(`skills/${encodeURIComponent(b)}/activate`,P?{args:P}:{})}async function Hf(b){const P=p.value;if(!P)return!1;try{return(await fetch(`${Be}/sessions/${P}/skills/${encodeURIComponent(b)}`,{method:"DELETE"})).ok?(C.value=C.value.filter(re=>re.name!==b),!0):!1}catch{return!1}}async function Oi(){const b=p.value;if(b)try{const P=await fetch(`${Be}/sessions/${b}/plugins`);if(!P.ok)return;x.value=await P.json()}catch{}}async function Wf(b){const P=p.value;if(P)try{const se=await fetch(`${Be}/sessions/${P}/plugins/${encodeURIComponent(b)}`);if(!se.ok)return;y.value=await se.json()}catch{}}async function qf(b){const P=p.value;if(!P)return null;try{const se=await fetch(`${Be}/sessions/${P}/plugins/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:b})});if(!se.ok)return null;const re=await se.json();return await Oi(),re}catch{return null}}async function Vf(b,P){return kt(`plugins/${encodeURIComponent(b)}/enable`,{enabled:P})}async function Kf(b,P,se){return kt(`plugins/${encodeURIComponent(b)}/mcp/${encodeURIComponent(P)}/enable`,{enabled:se})}async function Yf(b){const P=p.value;if(!P)return!1;try{return(await fetch(`${Be}/sessions/${P}/plugins/${encodeURIComponent(b)}`,{method:"DELETE"})).ok?(x.value=x.value.filter(re=>re.id!==b),!0):!1}catch{return!1}}async function Zf(){const b=p.value;if(!b)return null;try{const P=await fetch(`${Be}/sessions/${b}/plugins/reload`,{method:"POST"});if(!P.ok)return null;const se=await P.json();return await Oi(),se}catch{return null}}async function Jf(b){return kt(`plugins/${encodeURIComponent(b)}/activate`)}async function Xf(b){return kt(`plugins/${encodeURIComponent(b)}/deactivate`)}async function Qf(b){return kt(`plugins/${encodeURIComponent(b)}/inject`)}async function eh(){const b=p.value;if(b)try{const P=await fetch(`${Be}/sessions/${b}/mcp`);if(!P.ok)return;T.value=await P.json()}catch{}}async function th(){const b=p.value;if(b)try{const P=await fetch(`${Be}/sessions/${b}/mcp/startup-metrics`);if(!P.ok)return;D.value=await P.json()}catch{}}async function nh(b,P){return kt("mcp/add",{name:b,config:P})}async function sh(b){return kt(`mcp/${encodeURIComponent(b)}/reconnect`)}async function oh(b){return kt(`mcp/${encodeURIComponent(b)}/stop`)}async function ih(b){const P=p.value;if(!P)return!1;try{return(await fetch(`${Be}/sessions/${P}/mcp/${encodeURIComponent(b)}`,{method:"DELETE"})).ok?(T.value=T.value.filter(re=>re.name!==b),!0):!1}catch{return!1}}async function lh(b,P){const se=p.value;if(se)try{const re=new URLSearchParams;b!==void 0&&re.set("activeOnly",String(b)),P!==void 0&&re.set("limit",String(P));const ke=re.toString(),Re=await fetch(`${Be}/sessions/${se}/tasks${ke?`?${ke}`:""}`);if(!Re.ok)return;I.value=await Re.json()}catch{}}async function rh(b,P){const se=p.value;if(se)try{const re=P!==void 0?`?tail=${P}`:"",ke=await fetch(`${Be}/sessions/${se}/tasks/${encodeURIComponent(b)}/output${re}`);if(!ke.ok)return;const Re=await ke.json();H.value=Re.output}catch{}}async function ah(b,P){return kt(`tasks/${encodeURIComponent(b)}/stop`,P?{reason:P}:{})}async function Br(){try{const b=await fetch(`${Be}/config`);if(!b.ok)return;O.value=await b.json()}catch{}}async function ch(b){try{const P=await fetch(`${Be}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:b})});return P.ok?(O.value=await P.json(),!0):!1}catch{return!1}}async function uh(b){try{return(await fetch(`${Be}/config/providers/${encodeURIComponent(b)}`,{method:"DELETE"})).ok?(await Br(),!0):!1}catch{return!1}}async function dh(){try{const b=await fetch(`${Be}/experimental-flags`);if(!b.ok)return;B.value=await b.json()}catch{}}async function fh(){try{if(!(await fetch(`${Be}/preflight`)).ok)return;te.value=!0}catch{}}Jt(),ss(),Dr();const Fr=()=>{Jt()},jr=()=>{!document.hidden&&t.value!=="connected"&&Jt()};return window.addEventListener("online",Fr),document.addEventListener("visibilitychange",jr),Ct(()=>{Q=!0,Er=!0,ts.dispose(),window.removeEventListener("online",Fr),document.removeEventListener("visibilitychange",jr),Sn(),Se!==null&&(clearTimeout(Se),Se=null),je!==null&&(clearTimeout(je),je=null),oe&&(oe.onclose=null,oe.close(),oe=null)}),{connectionStatus:t,messages:n,pendingApprovals:i,status:l,goal:r,todos:a,goalRequestPending:c,goalRequestError:u,error:h,sessionId:p,workDir:v,isBusy:k,isArchived:E,sessions:w,currentSessionId:S,gitStatus:L,models:Z,like:Ei,fetchLike:bf,updateLike:kf,sendPrompt:hf,sendCommand:gf,clearMessages:mf,appendSystemMessage:Or,abort:pf,resolveApproval:vf,fetchSessions:ss,fetchGitStatus:ao,fetchModels:Dr,reconnectNow:df,olderAvailable:s,oldestSeq:o,loadOlderMessages:ff,switchModel:wf,switchThinking:_f,refineGoal:Sf,createGoal:$f,updateGoal:xf,pauseGoal:Cf,resumeGoal:Tf,cancelGoal:If,createSession:Rf,switchSession:Li,deleteSession:Af,exportSession:Mf,fetchSnapshot:be,fetchSessionStatus:ks,fetchSessionUsage:Ef,fetchSessionContext:Pf,fetchSessionPlan:Lf,sessionPlan:j,clearPlan:Of,switchPermission:Df,switchPlanMode:Nf,switchWolfpack:Bf,switchRlm:Ff,undoHistory:jf,compact:Uf,skills:C,fetchSkills:Gf,activateSkill:zf,removeSkill:Hf,plugins:x,pluginInfo:y,fetchPlugins:Oi,fetchPluginInfo:Wf,installPlugin:qf,setPluginEnabled:Vf,setPluginMcpServerEnabled:Kf,removePlugin:Yf,reloadPlugins:Zf,activatePlugin:Jf,deactivatePlugin:Xf,injectPlugin:Qf,mcpServers:T,mcpStartupMetrics:D,fetchMcpServers:eh,fetchMcpStartupMetrics:th,addMcpServer:nh,reconnectMcpServer:sh,stopMcpServer:oh,removeMcpServer:ih,backgroundTasks:I,backgroundTaskOutput:H,fetchBackgroundTasks:lh,fetchBackgroundTaskOutput:rh,stopBackgroundTask:ah,config:O,fetchConfig:Br,setConfig:ch,removeProvider:uh,experimentalFlags:B,fetchExperimentalFlags:dh,preflightOk:te,preflight:fh}}const Si=[{name:"compact",description:"压缩会话上下文",target:"backend"},{name:"model",description:"切换模型 / 思考强度",target:"local"},{name:"clear",description:"清空本地消息列表",target:"local"},{name:"new",description:"新建会话",target:"local"},{name:"help",description:"显示可用命令",target:"local"},{name:"auto",description:"切换为 auto 权限模式",target:"backend"},{name:"yes",description:"切换为 yolo 权限模式",target:"backend",aliases:["yolo"]},{name:"bot",description:"切换为 Bot 无人值守模式",target:"backend"},{name:"plan",description:"切换计划模式",target:"backend"},{name:"fork",description:"复制当前会话为新分支",target:"backend"},{name:"title",description:"重命名当前会话",target:"backend",aliases:["rename"],acceptsInput:!0},{name:"status",description:"查看会话状态",target:"local"},{name:"usage",description:"查看 Token 用量",target:"local"},{name:"btw",description:"快速侧问(不打断当前回合)",target:"backend",acceptsInput:!0}];function am(e){const t=e.toLowerCase();return Si.filter(n=>{var s;return n.name.startsWith(t)||((s=n.aliases)==null?void 0:s.some(o=>o.startsWith(t)))})}function cm(e){const t=e.toLowerCase(),n=Si.find(s=>{var o;return s.name===t||((o=s.aliases)==null?void 0:o.includes(t))});return(n==null?void 0:n.name)??t}function Yu(){return["可用命令:",...Si.map(t=>{var s;return`${(s=t.aliases)!=null&&s.length?[t.name,...t.aliases].map(o=>`/${o}`).join(", "):`/${t.name}`} - ${t.description}`})].join(`
|
|
18
18
|
`)}const um=640,cr=960,Ra=480,Aa=300,Ma=1200,dm=320,Zu=420;function Ju(e,t,n){const s=Number.isFinite(e)?e:t,o=Math.max(t,n);return Math.round(Math.max(t,Math.min(o,s)))}function Ea(e){return Ju(e*.42,360,640)}function Pa(e){const{viewportWidth:t,rightPanelOpen:n,rightPanelWidth:s}=e;if(t<=um)return Ra;const o=t<cr,i=o?dm:Zu,l=!o&&n?s:0;return Math.min(Ra,t-i-l)}function fm(e){const{viewportWidth:t,sidebarOpen:n,sidebarWidth:s}=e;if(t<cr)return Ma;const o=n?s:0;return Math.min(Ma,t-Zu-o)}function hm(e,t){return(e==null?void 0:e.displayMode)??t??"source"}function pm(e,t){const n=e.find(i=>i.id===t.tabId);if(!n)return[...e,{id:t.tabId,label:t.fileName,filePath:t.filePath,sourceSessionId:t.sourceSessionId,initialDisplayMode:t.modeHint,viewerState:t.modeHint?{displayMode:t.modeHint,wrapLines:!1,scrollTop:0,scrollLeft:0}:void 0,viewerRevision:0}];const s=!!(t.sourceSessionId&&n.sourceSessionId!==t.sourceSessionId);return!s&&!t.modeHint?e:e.map(i=>{var r;if(i.id!==t.tabId)return i;const l={...i};return s&&(l.sourceSessionId=t.sourceSessionId),t.modeHint?(l.initialDisplayMode=t.modeHint,l.viewerState={displayMode:t.modeHint,wrapLines:((r=i.viewerState)==null?void 0:r.wrapLines)??!1,scrollTop:0,scrollLeft:0},l.viewerRevision=(i.viewerRevision??0)+1):s&&(l.viewerRevision=(i.viewerRevision??0)+1),l})}function gm(e,t,n,s){const o=e.findIndex(l=>l.id===t);if(o===-1||(e[o].viewerRevision??0)!==n)return e;const i=[...e];return i[o]={...i[o],viewerState:s},i}const Xu="scream-file-tabs";function mm(){try{const e=localStorage.getItem(Xu);return e?JSON.parse(e):{}}catch{return{}}}function $i(e){try{localStorage.setItem(Xu,JSON.stringify(e))}catch{}}const Ys=mm(),Ki=Array.isArray(Ys.tabs)?Ys.tabs:[],La=typeof Ys.activeTabId=="string"?Ys.activeTabId:null;var xc;const $e=An({tabs:Ki,activeTabId:Ki.some(e=>e.id===La)?La:((xc=Ki.at(-1))==null?void 0:xc.id)??null,panelOpen:Ys.panelOpen===!0});function vm(){var e;if($e.tabs.length===0){$e.activeTabId=null;return}$e.tabs.some(t=>t.id===$e.activeTabId)||($e.activeTabId=((e=$e.tabs.at(-1))==null?void 0:e.id)??null)}function Zn(e,t={}){const n=e.split("/").pop()||e,s=e;return $e.tabs=pm($e.tabs,{fileName:t.label??n,filePath:e,modeHint:t.modeHint,sourceSessionId:t.sessionId??null,tabId:s}),$e.activeTabId=s,$e.panelOpen=!0,$i($e),s}function ym(e){$e.tabs.some(t=>t.id===e)&&($e.activeTabId=e,$i($e))}function Oa(e){const t=$e.tabs.findIndex(n=>n.id===e);if(t!==-1){if($e.tabs=$e.tabs.filter(n=>n.id!==e),$e.activeTabId===e){const n=$e.tabs[t]??$e.tabs[t-1]??null;$e.activeTabId=n?n.id:null}$e.tabs.length===0&&($e.panelOpen=!1,$e.activeTabId=null),$i($e)}}function Qu(e){$e.panelOpen=e,e&&vm(),$i($e)}function Da(){Qu(!$e.panelOpen)}const bm=()=>$e.tabs.find(e=>e.id===$e.activeTabId),km=["type","disabled"],wm=Te({__name:"Button",props:{variant:{default:"primary"},size:{default:"md"},disabled:{type:Boolean},type:{default:"button"}},setup(e){return(t,n)=>(g(),m("button",{class:fe(["ui-btn",[`ui-btn--${e.variant}`,`ui-btn--${e.size}`]]),type:e.type,disabled:e.disabled},[Co(t.$slots,"default",{},void 0)],10,km))}}),Ie=(e,t)=>{const n=e.__vccOpts||e;for(const[s,o]of t)n[s]=o;return n},zn=Ie(wm,[["__scopeId","data-v-746fbd2d"]]),_m={key:0,class:"approval-card"},Sm={class:"approval-header"},$m={class:"approval-title"},xm={class:"tool-name"},Cm={class:"action-summary"},Tm={key:0,class:"approval-count"},Im={class:"approval-action"},Rm={key:0,class:"feedback-area"},Am={class:"approval-buttons"},Mm={key:0,class:"busy-indicator","aria-label":"处理中"},Em=Te({__name:"ApprovalCard",props:{approvals:{}},emits:["resolve"],setup(e,{emit:t}){const n=e,s=t,o=F(!1),i=F(!1),l=F(""),r=F(new Set),a=q(()=>n.approvals[0]);Ee(()=>n.approvals.map(v=>v.id).join(","),()=>{i.value=!1,l.value="";const v=new Set(n.approvals.map(k=>k.id));r.value=new Set([...r.value].filter(k=>v.has(k)))});function c(v){return typeof v.display=="string"?v.display:v.display&&typeof v.display=="object"&&"description"in v.display?String(v.display.description??""):v.action??"执行该操作"}function u(v){return r.value.has(v)}function f(v,k,w){const S=a.value;!S||u(S.id)||(r.value=new Set([...r.value,S.id]),s("resolve",S.id,v,k,w))}function h(){const v=l.value.trim();v&&f("rejected",v)}function p(v){if(!a.value||o.value)return;const w=v.target;if(w&&(w.tagName==="TEXTAREA"||w.tagName==="INPUT")){i.value&&v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),h());return}switch(v.key){case"1":v.preventDefault(),f("approved",void 0,"once");break;case"2":v.preventDefault(),f("approved",void 0,"session");break;case"3":v.preventDefault(),f("rejected");break;case"4":v.preventDefault(),i.value=!i.value;break}}return ct(()=>window.addEventListener("keydown",p)),Ct(()=>window.removeEventListener("keydown",p)),(v,k)=>e.approvals.length?(g(),m("div",_m,[o.value?(g(),m("button",{key:0,class:"approval-minibar",onClick:k[0]||(k[0]=w=>o.value=!1)}," ⚠ "+R(e.approvals.length)+" 个待审批请求 — 点击展开 ",1)):a.value?(g(),m(ee,{key:1},[d("div",Sm,[k[7]||(k[7]=d("span",{class:"approval-icon"},"⚠",-1)),d("span",$m,[d("span",xm,R(a.value.toolName),1),d("span",Cm,R(c(a.value)),1)]),e.approvals.length>1?(g(),m("span",Tm,"+"+R(e.approvals.length-1),1)):U("",!0),d("button",{class:"icon-btn",title:"最小化","aria-label":"最小化",onClick:k[1]||(k[1]=w=>o.value=!0)},"—")]),d("pre",Im,R(c(a.value)),1),i.value?(g(),m("div",Rm,[it(d("textarea",{"onUpdate:modelValue":k[2]||(k[2]=w=>l.value=w),class:"feedback-input",rows:"2",name:"approval-feedback","aria-label":"拒绝反馈",placeholder:"输入反馈,Enter 提交(将作为拒绝原因反馈给 Agent)"},null,512),[[ut,l.value]])])):U("",!0),d("div",Am,[J(zn,{variant:"primary",disabled:u(a.value.id),onClick:k[3]||(k[3]=w=>f("approved",void 0,"once"))},{default:Pt(()=>[...k[8]||(k[8]=[d("kbd",null,"1",-1),Ce(" 批准 ",-1)])]),_:1},8,["disabled"]),J(zn,{variant:"secondary",disabled:u(a.value.id),onClick:k[4]||(k[4]=w=>f("approved",void 0,"session"))},{default:Pt(()=>[...k[9]||(k[9]=[d("kbd",null,"2",-1),Ce(" 会话批准 ",-1)])]),_:1},8,["disabled"]),J(zn,{variant:"danger",disabled:u(a.value.id),onClick:k[5]||(k[5]=w=>f("rejected"))},{default:Pt(()=>[...k[10]||(k[10]=[d("kbd",null,"3",-1),Ce(" 拒绝 ",-1)])]),_:1},8,["disabled"]),J(zn,{variant:"secondary",class:fe({"feedback-active":i.value}),disabled:u(a.value.id),onClick:k[6]||(k[6]=w=>i.value=!i.value)},{default:Pt(()=>[...k[11]||(k[11]=[d("kbd",null,"4",-1),Ce(" 反馈 ",-1)])]),_:1},8,["class","disabled"]),u(a.value.id)?(g(),m("span",Mm,[...k[12]||(k[12]=[d("span",{class:"spinner"},null,-1),Ce(" 处理中… ",-1)])])):U("",!0)])],64)):U("",!0)])):U("",!0)}}),Pm=Ie(Em,[["__scopeId","data-v-fa5dc764"]]);function Lm(e){const t=/(?:^|\s)@"([^"\n]*)$/.exec(e);if(t)return{start:e.length-(t[1].length+2),query:t[1],quoted:!0};const n=/(?:^|\s)@([^\s"]*)$/.exec(e);return n?{start:e.length-(n[1].length+1),query:n[1],quoted:!1}:null}function Na(e){let t=0;for(let n=0;n<e.length;n++)e[n]==="/"&&t++;return t}function Ba(e,t){if(!e)return!0;let n=0;for(let s=0;s<t.length&&n<e.length;s++)t[s]===e[n]&&n++;return n===e.length}function Om(e,t){const n=e.path.toLowerCase();let s=0;if(t.includes("/"))n===t?s=100:n.startsWith(t)?s=80:n.includes(t)?s=50:Ba(t,n)&&(s=10);else{const o=n.lastIndexOf("/"),i=o===-1?n:n.slice(o+1);i===t?s=100:i.startsWith(t)?s=80:i.includes(t)?s=50:n.includes(t)?s=30:Ba(t,n)&&(s=10)}return e.isDir&&s>0&&(s+=10),s}const Dm=20;function ed(e,t,n=Dm){const s=t.toLowerCase();if(!s)return e.slice(0,n);const o=[];for(const i of e){const l=Om(i,s);l>0&&o.push({entry:i,score:l})}return o.sort((i,l)=>l.score-i.score||Na(i.entry.path)-Na(l.entry.path)||i.entry.path.localeCompare(l.entry.path)),o.slice(0,n).map(i=>i.entry)}function Nm(e,t){const n=t?`${e}/`:e,s=n.includes(" ");if(t){const i=s?`@"${n}"`:`@${n}`;return{text:i,cursorOffset:s?i.length-1:i.length}}const o=s?`@"${n}" `:`@${n} `;return{text:o,cursorOffset:o.length}}const Bm="/api/v1/files",Fm=3e4,Tl=new Map,Ro=new Map;async function td(e){const t=Tl.get(e);if(t&&Date.now()-t.at<Fm)return t.entries;const n=Ro.get(e);if(n)return n;const s=(async()=>{try{const o=await fetch(`${Bm}/list?path=${encodeURIComponent(e)}`);if(!o.ok)return null;const i=await o.json();return i.entries&&Tl.set(e,{entries:i.entries,at:Date.now()}),i.entries??null}catch{return null}finally{Ro.delete(e)}})();return Ro.set(e,s),s}function jm(e){Tl.delete(e),Ro.delete(e)}function Um(e,t){const n=e.replace(/\/+$/,""),s=n.split("/").filter(Boolean),o=[...s];for(const l of t.split("/"))if(!(!l||l===".")){if(l===".."){if(o.length<=s.length)return null;o.pop();continue}o.push(l)}const i=`/${o.join("/")}`;return i===n||i.startsWith(`${n}/`)?i:null}function Gm(e,t,n){const s=F(null),o=F([]),i=F(!1),l=F(!1),r=F(0),a=F(!1),c=F(null),u=F("");let f=null;function h(){f||(f=(async()=>{var x;try{const y=await fetch("/api/v1/files/root"),T=y.ok?await y.json():{};u.value=((x=T.roots)==null?void 0:x[0])??""}catch{u.value=""}E()})())}const p=q(()=>{const x=c.value;if(!x)return[];const y=x.query.lastIndexOf("/"),T=x.query.slice(y+1);return ed(o.value,T)}),v=q(()=>c.value!==null&&!a.value&&(i.value||p.value.length>0));function k(x){const y=x.lastIndexOf("/");return y===-1?{dirRel:"",tail:x}:{dirRel:x.slice(0,y),tail:x.slice(y+1)}}let w=!1,S=0;async function $(x,y){const T=++S;i.value=!0;try{const D=await td(x);if(D===null)throw new Error("listing failed");if(T!==S)return;const I=y?`${y.replace(/\/+$/,"")}/`:"";o.value=D.map(H=>({path:`${I}${H.name}`,isDir:H.type==="dir"})),l.value=!1}catch{if(T!==S)return;o.value=[],l.value=!0,s.value=null}finally{T===S&&(i.value=!1)}}function E(){var B;if(w)return;const x=t.value;if(x&&x.value!==e.value){c.value=null;return}let y=(B=n.value)==null?void 0:B.trim();if(y||(h(),y=u.value),!x||!y){c.value=null;return}const T=x.selectionStart??x.value.length,D=Lm(x.value.slice(0,T));if(!D){c.value=null,a.value=!1;return}const I=c.value;(!I||I.start!==D.start||I.query!==D.query)&&(a.value=!1),c.value=D,r.value=0;const{dirRel:H}=k(D.query),O=Um(y,H);if(O===null){s.value=null,o.value=[],l.value=!0;return}s.value!==O&&(s.value=O,$(O,H))}function L(x){const y=p.value.length;y>0&&(r.value=(r.value+x+y)%y)}function Z(x){const y=c.value,T=x??p.value[r.value];if(!y||!T)return!1;const D=t.value;if(!D)return!1;const I=D.selectionStart??D.value.length,H=Nm(T.path,T.isDir),O=e.value.slice(0,y.start),B=e.value.slice(I);e.value=O+H.text+B,w=!0;const te=()=>{const oe=y.start+H.cursorOffset;D.focus(),D.setSelectionRange(oe,oe),w=!1,E()};return typeof requestAnimationFrame=="function"?requestAnimationFrame(te):Promise.resolve().then(te),!0}function j(){a.value=!0}function C(){c.value=null,a.value=!1,r.value=0}return{visible:v,suggestions:p,index:r,dirLoading:i,dirMissing:l,refresh:E,move:L,confirm:Z,dismiss:j,reset:C}}const nd=50;function zm(e,t=nd){const n=new Set,s=[];for(let o=e.length-1;o>=0&&s.length<t;o-=1){const i=e[o];if(!i||i.role!=="user"||i.local)continue;const l=(i.content??"").trim();!l||n.has(l)||(n.add(l),s.push(l))}return s}function Hm(e,t,n=nd){const s=new Set,o=[],i=l=>{const r=l.trim();!r||s.has(r)||(s.add(r),o.push(r))};for(const l of t)i(l);for(let l=e.length-1;l>=0;l-=1){const r=e[l];r!==void 0&&i(r)}return o.slice(0,n).toReversed()}const Wm=["width","height"],qm={key:0,d:"M4 7h16M4 12h16M4 17h16"},Vm={key:1,d:"M12 5v14M5 12h14"},Km={key:5,d:"M4 6h16M7 12h10M10 18h4"},Ym={key:6,d:"M12 3v12m0 0 4-4m-4 4-4-4M5 20h14"},Zm={key:7,d:"M4 7h16M9 7V4h6v3m3 0-1 13H7L6 7m4 4v5m4-5v5"},Jm={key:8,d:"M3 12h4l2-7 4 14 2-7h6"},Xm={key:10,d:"m15 18-6-6 6-6"},Qm={key:11,d:"m9 18 6-6-6-6"},ev={key:12,d:"m6 9 6 6 6-6"},tv={key:16,d:"M20 15.5A8.5 8.5 0 0 1 8.5 4 8.5 8.5 0 1 0 20 15.5Z"},nv={key:18,d:"M5 9a11 11 0 0 1 14 0M8.5 12.5a6 6 0 0 1 7 0M12 17h.01"},sv={key:19,d:"M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L8 18l-4 1 1-4Z"},ov={key:20,d:"M12 16V4m0 0-4 4m4-4 4 4M5 20h14"},iv={key:21,d:"m15 4 5 5M17.5 6.5 10 14m-2-2 4 4-3 4H3l1-6Z"},lv={key:22,d:"M9 6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3Z"},rv={key:24,d:"m22 2-7 20-4-9-9-4ZM22 2 11 13"},av={key:25,x:"6",y:"6",width:"12",height:"12",rx:"2"},cv={key:26,d:"m8 3 4 4 4-4M8 21l4-4 4 4M12 7v10"},uv={key:27,d:"M9.5 4.5A3 3 0 0 0 5 7a3 3 0 0 0 .5 5.5A3 3 0 0 0 9 17v2a2 2 0 0 0 4 0V5a2.5 2.5 0 0 0-3.5-.5ZM13 6a3 3 0 0 1 5 2 3 3 0 0 1 .5 5.5A3 3 0 0 1 15 18"},dv={key:30,d:"M21 12a8 8 0 0 1-9 8 9 9 0 0 1-4-.9L3 21l1.7-4A9 9 0 1 1 21 12Z"},fv={key:31,d:"M20 13 13 20l-9-9V4h7ZM8.5 8.5h.01"},hv={key:32,d:"m12 3 1.3 3.7L17 8l-3.7 1.3L12 13l-1.3-3.7L7 8l3.7-1.3ZM5 15l.8 2.2L8 18l-2.2.8L5 21l-.8-2.2L2 18l2.2-.8ZM19 14l.7 1.8 1.8.7-1.8.7L19 19l-.7-1.8-1.8-.7 1.8-.7Z"},pv={key:34,d:"M3 6h7l2 2h9v11H3Z"},gv={key:35,d:"m5 12 4 4L19 6"},mv={key:39,d:"M21 12a9 9 0 1 1-2.6-6.4M21 3v6h-6"},vv={key:46,d:"M14.7 6.3a4 4 0 0 0-5.4 5.4L3 18l3 3 6.3-6.3a4 4 0 0 0 5.4-5.4l-2.5 2.5-3-3Z"},yv={key:47,d:"M12 19V5m0 0-6 6m6-6 6 6"},bv={key:48,d:"M18 6 6 18M6 6l12 12"},kv={key:51,d:"M4 20V10M10 20V4M16 20v-7M21 20H3"},wv=Te({__name:"SvgIcon",props:{name:{},size:{default:20}},setup(e){return(t,n)=>(g(),m("svg",{class:"svg-icon",width:e.size,height:e.size,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.name==="menu"?(g(),m("path",qm)):e.name==="plus"?(g(),m("path",Vm)):e.name==="panel-left"?(g(),m(ee,{key:2},[n[0]||(n[0]=d("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"},null,-1)),n[1]||(n[1]=d("path",{d:"M9 4v16"},null,-1))],64)):e.name==="panel-right"?(g(),m(ee,{key:3},[n[2]||(n[2]=d("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"},null,-1)),n[3]||(n[3]=d("path",{d:"M15 4v16"},null,-1))],64)):e.name==="search"?(g(),m(ee,{key:4},[n[4]||(n[4]=d("circle",{cx:"11",cy:"11",r:"7"},null,-1)),n[5]||(n[5]=d("path",{d:"m20 20-4-4"},null,-1))],64)):e.name==="filter"?(g(),m("path",Km)):e.name==="download"?(g(),m("path",Ym)):e.name==="trash"?(g(),m("path",Zm)):e.name==="activity"?(g(),m("path",Jm)):e.name==="help"?(g(),m(ee,{key:9},[n[6]||(n[6]=d("circle",{cx:"12",cy:"12",r:"9"},null,-1)),n[7]||(n[7]=d("path",{d:"M9.7 9a2.5 2.5 0 1 1 3.5 2.3c-.8.4-1.2 1-1.2 1.7M12 17h.01"},null,-1))],64)):e.name==="chevron-left"?(g(),m("path",Xm)):e.name==="chevron-right"?(g(),m("path",Qm)):e.name==="chevron-down"?(g(),m("path",ev)):e.name==="bot"?(g(),m(ee,{key:13},[n[8]||(n[8]=d("rect",{x:"4",y:"7",width:"16",height:"12",rx:"3"},null,-1)),n[9]||(n[9]=d("path",{d:"M12 3v4M8 12h.01M16 12h.01M9 16h6"},null,-1))],64)):e.name==="git-branch"?(g(),m(ee,{key:14},[n[10]||(n[10]=d("circle",{cx:"6",cy:"5",r:"2"},null,-1)),n[11]||(n[11]=d("circle",{cx:"18",cy:"7",r:"2"},null,-1)),n[12]||(n[12]=d("circle",{cx:"6",cy:"19",r:"2"},null,-1)),n[13]||(n[13]=d("path",{d:"M6 7v10M8 10c5 0 3-3 8-3"},null,-1))],64)):e.name==="sun"?(g(),m(ee,{key:15},[n[14]||(n[14]=d("circle",{cx:"12",cy:"12",r:"4"},null,-1)),n[15]||(n[15]=d("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.42 1.42m11.3 11.3 1.42 1.42M2 12h2m16 0h2M4.93 19.07l1.42-1.42m11.3-11.3 1.42-1.42"},null,-1))],64)):e.name==="moon"?(g(),m("path",tv)):e.name==="monitor"?(g(),m(ee,{key:17},[n[16]||(n[16]=d("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"},null,-1)),n[17]||(n[17]=d("path",{d:"M8 21h8M12 17v4"},null,-1))],64)):e.name==="wifi"?(g(),m("path",nv)):e.name==="edit"?(g(),m("path",sv)):e.name==="upload"?(g(),m("path",ov)):e.name==="broom"?(g(),m("path",iv)):e.name==="command"?(g(),m("path",lv)):e.name==="at"?(g(),m(ee,{key:23},[n[18]||(n[18]=d("circle",{cx:"12",cy:"12",r:"4"},null,-1)),n[19]||(n[19]=d("path",{d:"M16 12v1.5a2.5 2.5 0 0 0 5 0V12a9 9 0 1 0-3.5 7"},null,-1))],64)):e.name==="send"?(g(),m("path",rv)):e.name==="stop"?(g(),m("rect",av)):e.name==="compact"?(g(),m("path",cv)):e.name==="brain"?(g(),m("path",uv)):e.name==="clipboard"?(g(),m(ee,{key:28},[n[20]||(n[20]=d("rect",{x:"5",y:"4",width:"14",height:"17",rx:"2"},null,-1)),n[21]||(n[21]=d("path",{d:"M9 4V2h6v2M9 10h6M9 14h6"},null,-1))],64)):e.name==="fork"?(g(),m(ee,{key:29},[n[22]||(n[22]=d("circle",{cx:"6",cy:"4",r:"2"},null,-1)),n[23]||(n[23]=d("circle",{cx:"18",cy:"6",r:"2"},null,-1)),n[24]||(n[24]=d("circle",{cx:"6",cy:"20",r:"2"},null,-1)),n[25]||(n[25]=d("path",{d:"M6 6v12M8 10c6 0 4-4 8-4"},null,-1))],64)):e.name==="message-circle"?(g(),m("path",dv)):e.name==="tag"?(g(),m("path",fv)):e.name==="sparkles"?(g(),m("path",hv)):e.name==="terminal"?(g(),m(ee,{key:33},[n[26]||(n[26]=d("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"},null,-1)),n[27]||(n[27]=d("path",{d:"m7 9 3 3-3 3m5 0h5"},null,-1))],64)):e.name==="folder"?(g(),m("path",pv)):e.name==="check"?(g(),m("path",gv)):e.name==="speaker"?(g(),m(ee,{key:36},[n[28]||(n[28]=d("path",{d:"M11 5 6 9H3v6h3l5 4V5z"},null,-1)),n[29]||(n[29]=d("path",{d:"M15.5 8.5a5 5 0 0 1 0 7"},null,-1)),n[30]||(n[30]=d("path",{d:"M18 6a8.5 8.5 0 0 1 0 12"},null,-1))],64)):e.name==="speaker-off"?(g(),m(ee,{key:37},[n[31]||(n[31]=d("path",{d:"M11 5 6 9H3v6h3l5 4V5z"},null,-1)),n[32]||(n[32]=d("path",{d:"m16 9 5 6M21 9l-5 6"},null,-1))],64)):e.name==="copy"?(g(),m(ee,{key:38},[n[33]||(n[33]=d("rect",{x:"8",y:"8",width:"12",height:"12",rx:"2"},null,-1)),n[34]||(n[34]=d("path",{d:"M16 8V4H4v12h4"},null,-1))],64)):e.name==="refresh"?(g(),m("path",mv)):e.name==="target"?(g(),m(ee,{key:40},[n[35]||(n[35]=d("circle",{cx:"12",cy:"12",r:"9"},null,-1)),n[36]||(n[36]=d("circle",{cx:"12",cy:"12",r:"5"},null,-1)),n[37]||(n[37]=d("circle",{cx:"12",cy:"12",r:"1"},null,-1))],64)):e.name==="settings"?(g(),m(ee,{key:41},[n[38]||(n[38]=d("circle",{cx:"12",cy:"12",r:"3"},null,-1)),n[39]||(n[39]=d("path",{d:"M19.4 15a1.7 1.7 0 0 0 .34 1.87l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.7 1.7 0 0 0-1.87-.34 1.7 1.7 0 0 0-1 1.55V21a2 2 0 1 1-4 0v-.09a1.7 1.7 0 0 0-1-1.55 1.7 1.7 0 0 0-1.87.34l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.7 1.7 0 0 0 .34-1.87 1.7 1.7 0 0 0-1.55-1H3a2 2 0 1 1 0-4h.09a1.7 1.7 0 0 0 1.55-1 1.7 1.7 0 0 0-.34-1.87l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.7 1.7 0 0 0 1.87.34h.09a1.7 1.7 0 0 0 1-1.55V3a2 2 0 1 1 4 0v.09a1.7 1.7 0 0 0 1 1.55 1.7 1.7 0 0 0 1.87-.34l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.7 1.7 0 0 0-.34 1.87v.09a1.7 1.7 0 0 0 1.55 1H21a2 2 0 1 1 0 4h-.09a1.7 1.7 0 0 0-1.55 1Z"},null,-1))],64)):e.name==="home"?(g(),m(ee,{key:42},[n[40]||(n[40]=d("path",{d:"M3 10.5 12 3l9 7.5"},null,-1)),n[41]||(n[41]=d("path",{d:"M5 9.5V21h14V9.5"},null,-1))],64)):e.name==="bell"?(g(),m(ee,{key:43},[n[42]||(n[42]=d("path",{d:"M6 9a6 6 0 1 1 12 0c0 5 2 6 2 6H4s2-1 2-6"},null,-1)),n[43]||(n[43]=d("path",{d:"M10 19a2 2 0 0 0 4 0"},null,-1))],64)):e.name==="book"?(g(),m(ee,{key:44},[n[44]||(n[44]=d("path",{d:"M4 5a2 2 0 0 1 2-2h13v18H6a2 2 0 0 0-2 2Z"},null,-1)),n[45]||(n[45]=d("path",{d:"M6 3v18"},null,-1))],64)):e.name==="layers"?(g(),m(ee,{key:45},[n[46]||(n[46]=d("path",{d:"m12 3 9 5-9 5-9-5Z"},null,-1)),n[47]||(n[47]=d("path",{d:"m3 13 9 5 9-5"},null,-1))],64)):e.name==="wrench"?(g(),m("path",vv)):e.name==="arrow-up"?(g(),m("path",yv)):e.name==="x"?(g(),m("path",bv)):e.name==="file"?(g(),m(ee,{key:49},[n[48]||(n[48]=d("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"},null,-1)),n[49]||(n[49]=d("path",{d:"M14 2v6h6"},null,-1))],64)):e.name==="user"?(g(),m(ee,{key:50},[n[50]||(n[50]=d("circle",{cx:"12",cy:"8",r:"3.5"},null,-1)),n[51]||(n[51]=d("path",{d:"M5 20a7 7 0 0 1 14 0"},null,-1))],64)):e.name==="bar-chart"?(g(),m("path",kv)):U("",!0)],8,Wm))}}),me=Ie(wv,[["__scopeId","data-v-3f977afb"]]),_v={class:"at-menu",role:"listbox","aria-label":"文件提及"},Sv={key:0,class:"at-status"},$v={key:1,class:"at-status"},xv=["data-active","aria-selected","onClick","onMousemove"],Cv={class:"at-item-name"},Tv={key:0,class:"at-item-dir"},Iv={class:"at-hints"},Rv={class:"at-hint"},Av=["title"],Mv=Te({__name:"AtFileMenu",props:{suggestions:{},activeIndex:{},loading:{type:Boolean,default:!1},workDir:{default:""}},emits:["select","hover"],setup(e,{emit:t}){const n=e,s=t,o=F(null);Ee(()=>n.activeIndex,async()=>{var c;await ft();const a=(c=o.value)==null?void 0:c.querySelector('[data-active="true"]');a==null||a.scrollIntoView({block:"nearest"})});const i=a=>a.split("/").pop()||a;function l(a){return i(a.path)}function r(a){const c=a.path.lastIndexOf("/");return c===-1?"":a.path.slice(0,c)}return(a,c)=>{var u;return g(),m("div",_v,[e.loading&&e.suggestions.length===0?(g(),m("div",Sv,"加载文件列表…")):e.suggestions.length===0?(g(),m("div",$v,"无匹配文件")):(g(),m("ul",{key:2,ref_key:"listRef",ref:o,class:"at-list"},[(g(!0),m(ee,null,Me(e.suggestions,(f,h)=>(g(),m("li",{key:f.path},[d("button",{class:fe(["at-item",{selected:h===e.activeIndex}]),"data-active":h===e.activeIndex?"true":void 0,role:"option","aria-selected":h===e.activeIndex,onClick:p=>s("select",f),onMousemove:p=>s("hover",h)},[d("span",{class:fe(["at-item-icon",{"is-dir":f.isDir}])},[J(me,{name:f.isDir?"folder":"file",size:14},null,8,["name"])],2),d("span",Cv,R(l(f)),1),r(f)?(g(),m("span",Tv,R(r(f)),1)):U("",!0)],42,xv)]))),128))],512)),d("div",Iv,[c[1]||(c[1]=d("span",{class:"at-hint"},[d("kbd",null,"↑↓"),Ce("选择")],-1)),d("span",Rv,[c[0]||(c[0]=d("kbd",null,"Tab/Enter",-1)),Ce(R((u=e.suggestions[e.activeIndex])!=null&&u.isDir?"进入目录":"插入引用"),1)]),c[2]||(c[2]=d("span",{class:"at-hint"},[d("kbd",null,"Esc"),Ce("关闭")],-1)),e.workDir?(g(),m("span",{key:0,class:"at-root",title:e.workDir},"根:"+R(i(e.workDir)),9,Av)):U("",!0)])])}}}),Ev=Ie(Mv,[["__scopeId","data-v-c228c98f"]]),Pv=["title","aria-label"],Lv=["width","height","viewBox"],Ov=["cx","cy","r"],Dv=["cx","cy","r","stroke-dasharray","stroke-dashoffset","transform"],Yi=2,Nv=Te({__name:"ContextRing",props:{usage:{default:void 0},size:{default:16}},setup(e){gg(a=>({v1d95ffa8:r.value}));const t=e,n=q(()=>{if(t.usage===void 0||Number.isNaN(t.usage))return 0;const a=t.usage>1?t.usage/100:t.usage;return Math.min(1,Math.max(0,a))}),s=q(()=>Math.round(n.value*100)),o=q(()=>(t.size-Yi)/2),i=q(()=>2*Math.PI*o.value),l=q(()=>i.value*(1-n.value)),r=q(()=>n.value>=.9?"var(--color-danger)":n.value>=.7?"var(--color-warning)":"var(--color-accent)");return(a,c)=>(g(),m("span",{class:"context-ring",role:"img",title:`上下文占用 ${s.value}%`,"aria-label":`上下文占用 ${s.value}%`},[(g(),m("svg",{width:e.size,height:e.size,viewBox:`0 0 ${e.size} ${e.size}`},[d("circle",{class:"ring-track",cx:e.size/2,cy:e.size/2,r:o.value,"stroke-width":Yi,fill:"none"},null,8,Ov),d("circle",{class:"ring-value",cx:e.size/2,cy:e.size/2,r:o.value,"stroke-width":Yi,fill:"none","stroke-linecap":"round","stroke-dasharray":i.value,"stroke-dashoffset":l.value,transform:`rotate(-90 ${e.size/2} ${e.size/2})`},null,8,Dv)],8,Lv))],8,Pv))}}),sd=Ie(Nv,[["__scopeId","data-v-3ffc343b"]]),Bv={class:"history-menu",role:"listbox","aria-label":"输入历史"},Fv={class:"history-header",title:"输入历史"},jv=["data-active","aria-selected","onClick","onMousemove"],Uv={class:"history-item-index"},Gv={class:"history-item-text"},zv=Te({__name:"HistoryMenu",props:{items:{},activeIndex:{}},emits:["apply","hover"],setup(e,{emit:t}){const n=e,s=t,o=F(null);return Ee(()=>n.activeIndex,async()=>{var l;await ft();const i=(l=o.value)==null?void 0:l.querySelector('[data-active="true"]');i==null||i.scrollIntoView({block:"nearest"})}),ct(async()=>{var l;await ft();const i=(l=o.value)==null?void 0:l.querySelector('[data-active="true"]');i==null||i.scrollIntoView({block:"nearest"})}),(i,l)=>(g(),m("div",Bv,[d("div",Fv,[J(me,{name:"refresh",size:14}),l[0]||(l[0]=d("span",{class:"history-hints"},[d("span",{class:"history-hint"},[d("kbd",null,"↑↓"),Ce("选择")]),d("span",{class:"history-hint"},[d("kbd",null,"Tab/Enter"),Ce("填入")]),d("span",{class:"history-hint"},[d("kbd",null,"Esc"),Ce("关闭")])],-1))]),d("ul",{ref_key:"listRef",ref:o,class:"history-list"},[(g(!0),m(ee,null,Me(e.items,(r,a)=>(g(),m("li",{key:`${a}:${r}`},[d("button",{class:fe(["history-item",{selected:a===e.activeIndex}]),"data-active":a===e.activeIndex?"true":void 0,role:"option","aria-selected":a===e.activeIndex,onClick:c=>s("apply",r),onMousemove:c=>s("hover",a)},[d("span",Uv,R(a+1),1),d("span",Gv,R(r),1)],42,jv)]))),128))],512)]))}}),Hv=Ie(zv,[["__scopeId","data-v-598dec8a"]]),Wv=["onKeydown"],qv={key:0,class:"picker-empty"},Vv={class:"picker-group-title"},Kv=["onClick"],Yv={class:"row-main"},Zv={class:"row-name"},Jv={class:"row-alias"},Xv={class:"row-meta"},Qv={key:0,class:"row-check"},ey={class:"picker-thinking"},ty={class:"thinking-options"},ny=["onClick"],sy=Te({__name:"ModelPicker",props:{models:{},currentModel:{},currentThinking:{}},emits:["apply-model","apply-thinking","close"],setup(e,{emit:t}){const n=e,s=t,o=["off","low","medium","high"],i={off:"关闭",low:"低",medium:"中",high:"高",xhigh:"超高",max:"最大"},l=F(""),r=F(null);ct(()=>{var C;(C=r.value)==null||C.focus()});const a=q(()=>{const C=l.value.trim().toLowerCase();return C?n.models.filter(x=>x.alias.toLowerCase().includes(C)||x.provider.toLowerCase().includes(C)||(x.displayName??"").toLowerCase().includes(C)):n.models}),c=q(()=>{const C=new Map;for(const x of a.value){const y=C.get(x.provider)??[];y.push(x),C.set(x.provider,y)}return[...C.entries()].map(([x,y])=>({provider:x,models:y}))}),u=q(()=>n.models.find(C=>C.alias===n.currentModel)),f=q(()=>{var C;return((C=u.value)==null?void 0:C.thinkingLevels)??o});function h(C){return i[C]??C}function p(C){return C>=1e3?`${Math.round(C/1e3)}k`:String(C)}function v(C){return C.displayName??C.model}const k=F(null);function w(C){k.value&&!k.value.contains(C.target)&&s("close")}ct(()=>document.addEventListener("mousedown",w,!0)),Ct(()=>document.removeEventListener("mousedown",w,!0));function S(C){C!==n.currentModel&&s("apply-model",C),s("close")}const $=F(null);function E(){const C=$.value;return C?Array.from(C.querySelectorAll(".picker-row")):[]}function L(){var C;(C=E()[0])==null||C.focus()}function Z(C){var T,D,I;if(C.key!=="ArrowDown"&&C.key!=="ArrowUp")return;const x=E();if(x.length===0)return;const y=x.indexOf(document.activeElement);C.preventDefault(),y===-1?(T=x[0])==null||T.focus():C.key==="ArrowDown"?(D=x[(y+1)%x.length])==null||D.focus():(I=x[(y-1+x.length)%x.length])==null||I.focus()}function j(C){C!==n.currentThinking&&s("apply-thinking",C)}return(C,x)=>(g(),m("div",{ref_key:"rootRef",ref:k,class:"model-picker",role:"dialog","aria-label":"模型选择",onKeydown:x[1]||(x[1]=Vn(rt(y=>s("close"),["stop"]),["esc"]))},[it(d("input",{ref_key:"searchRef",ref:r,"onUpdate:modelValue":x[0]||(x[0]=y=>l.value=y),class:"picker-search",type:"text",placeholder:"搜索模型…",id:"model-search-input",name:"model-search",autocomplete:"off",spellcheck:"false",onKeydown:Vn(rt(L,["prevent"]),["arrow-down"])},null,40,Wv),[[ut,l.value]]),d("div",{ref_key:"listRef",ref:$,class:"picker-list",onKeydown:Z},[c.value.length===0?(g(),m("div",qv,"无匹配模型")):U("",!0),(g(!0),m(ee,null,Me(c.value,y=>(g(),m("div",{key:y.provider,class:"picker-group"},[d("div",Vv,R(y.provider),1),(g(!0),m(ee,null,Me(y.models,T=>(g(),m("button",{key:T.alias,class:fe(["picker-row",{active:T.alias===e.currentModel}]),onClick:D=>S(T.alias)},[d("span",Yv,[d("span",Zv,R(v(T)),1),d("span",Jv,R(T.alias),1)]),d("span",Xv,R(p(T.maxContextSize)),1),T.alias===e.currentModel?(g(),m("span",Qv,"✓")):U("",!0)],10,Kv))),128))]))),128))],544),d("div",ey,[x[2]||(x[2]=d("span",{class:"thinking-label"},"思考强度",-1)),d("div",ty,[(g(!0),m(ee,null,Me(f.value,y=>(g(),m("button",{key:y,class:fe(["thinking-btn",{active:y===e.currentThinking}]),onClick:T=>j(y)},R(h(y)),11,ny))),128))])])],544))}}),oy=Ie(sy,[["__scopeId","data-v-438275ef"]]),iy={class:"slash-menu",role:"listbox","aria-label":"斜杠命令"},ly=["aria-selected","onMousedown","onMouseenter"],ry={class:"slash-name"},ay={key:0,class:"slash-aliases"},cy={class:"slash-desc"},uy={key:0,class:"slash-badge slash-badge-input"},dy={key:1,class:"slash-badge"},fy=Te({__name:"SlashMenu",props:{commands:{},activeIndex:{}},emits:["select","hover"],setup(e,{emit:t}){const n=t;return(s,o)=>(g(),m("div",iy,[(g(!0),m(ee,null,Me(e.commands,(i,l)=>{var r;return g(),m("button",{key:i.name,class:fe(["slash-item",{active:l===e.activeIndex}]),role:"option","aria-selected":l===e.activeIndex,onMousedown:rt(a=>n("select",i),["prevent"]),onMouseenter:a=>n("hover",l)},[d("span",ry,[Ce("/"+R(i.name),1),(r=i.aliases)!=null&&r.length?(g(),m("span",ay,R(i.aliases.map(a=>`/${a}`).join(" ")),1)):U("",!0)]),d("span",cy,R(i.description),1),i.acceptsInput?(g(),m("span",uy,"输入参数")):U("",!0),i.target==="backend"?(g(),m("span",dy,"服务端")):U("",!0)],42,ly)}),128)),o[0]||(o[0]=d("div",{class:"slash-hint"},"↑↓ 选择 · Enter/Tab 执行 · Esc 关闭",-1))]))}}),hy=Ie(fy,[["__scopeId","data-v-6983799d"]]),py=["placeholder"],gy={class:"composer-footer"},my={class:"composer-quick-actions"},vy=["title"],yy={key:3,class:"queue-label",title:"运行结束后自动发送"},by={class:"composer-actions"},ky=["disabled","title"],wy={key:1,class:"context-label",title:"上下文使用率"},_y=["disabled"],Fa=50,Sy=Te({__name:"Composer",props:{busy:{type:Boolean},status:{default:void 0},sessionId:{default:null},models:{default:()=>[]},workDir:{default:""},variant:{default:"chat"},placeholder:{default:void 0},messages:{}},emits:["send","abort","command","switch-model","switch-thinking"],setup(e,{expose:t,emit:n}){const s=e,o=n,i=F(""),l=F(null),r=q(()=>s.workDir||void 0),a=Gm(i,l,r),c=F(0),u=F(!1),f=q(()=>{const A=i.value;return!A.startsWith("/")||A.includes(`
|
|
19
19
|
`)||/\s/.test(A.slice(1))?null:A.slice(1)}),h=q(()=>f.value===null?[]:am(f.value)),p=q(()=>f.value!==null&&h.value.length>0&&!u.value);Ee(f,()=>{c.value=0,u.value=!1});function v(A){const N=A??h.value[c.value];if(N){if(N.acceptsInput){i.value=`/${N.name} `,u.value=!0,ft(()=>{var ue;(ue=l.value)==null||ue.focus(),H()});return}C(`/${N.name}`),_e(),o("command",N.name)}}const k=F([]);Ee(()=>s.sessionId,()=>{k.value=[]}),Ee(()=>s.busy,A=>{if(!A&&k.value.length>0){const[N,...ue]=k.value;k.value=ue,N&&o("send",N)}});let w=0;const S=F([]),$=q(()=>Hm(S.value,zm(s.messages??[]),Fa)),E=F(!1),L=F(0);function Z(){return`scream-history:${s.sessionId??"default"}`}function j(){try{const A=localStorage.getItem(Z());S.value=A?JSON.parse(A):[]}catch{S.value=[]}}function C(A){if(S.value.at(-1)!==A){S.value=[...S.value,A].slice(-Fa);try{localStorage.setItem(Z(),JSON.stringify(S.value))}catch{}}}function x(A){i.value=A,E.value=!1,ft(()=>{const N=l.value;N&&(N.focus(),N.setSelectionRange(N.value.length,N.value.length),H(),a.reset())})}function y(){u.value=!0,a.dismiss(),L.value=Math.max(0,$.value.length-1),E.value=!0}function T(A){const N=$.value.length;N!==0&&(L.value=Math.min(N-1,Math.max(0,L.value+A)))}Ee(()=>$.value.length,()=>{L.value>=$.value.length&&(L.value=Math.max(0,$.value.length-1))});function D(){return`scream-draft:${s.sessionId??"default"}`}let I;Ee(i,()=>{H(),E.value=!1,a.refresh(),clearTimeout(I),I=setTimeout(()=>{try{i.value?localStorage.setItem(D(),i.value):localStorage.removeItem(D())}catch{}},300)}),Ee(()=>s.sessionId,()=>{clearTimeout(I),j(),E.value=!1,L.value=0;let A="";try{A=localStorage.getItem(D())??""}catch{A=""}i.value=A,ft(H)},{immediate:!0});function H(){const A=l.value;if(!A)return;A.style.height="auto";const N=Math.round(window.innerHeight*.25);A.style.height=`${Math.min(Math.max(A.scrollHeight,36),N)}px`}function O(){a.refresh()}const B=F(0);function te(){const A=window.visualViewport;if(!A)return;const N=Math.round(window.innerHeight-A.height-A.offsetTop);B.value=N>120?N:0}"visualViewport"in window&&(ct(()=>{var A;(A=window.visualViewport)==null||A.addEventListener("resize",te),te()}),Ct(()=>{var A;(A=window.visualViewport)==null||A.removeEventListener("resize",te),B.value=0}));function oe(A){if(!E.value)return;const N=A.target;N instanceof Element&&(N.closest(".history-menu")||N.closest("#composer-input")||(E.value=!1))}ct(()=>document.addEventListener("mousedown",oe)),Ct(()=>document.removeEventListener("mousedown",oe));function _e(){i.value="",a.reset(),E.value=!1,ft(()=>{l.value&&(l.value.style.height="auto")})}function Se(){const A=i.value.trim();if(A){if(A.startsWith("/")){const N=A.indexOf(" "),ue=(N===-1?A.slice(1):A.slice(1,N)).toLowerCase(),de=cm(ue),pe=N===-1?"":A.slice(N+1).trim();C(A),o("command",de,pe),_e();return}if(s.busy){je();return}C(A),o("send",A),_e()}}function je(){const A=i.value.trim();A&&(C(A),k.value=[...k.value,A],_e())}function Qe(A){if(a.visible.value){if(A.key==="ArrowDown"){A.preventDefault(),a.move(1);return}if(A.key==="ArrowUp"){A.preventDefault(),a.move(-1);return}if((A.key==="Tab"||A.key==="Enter"&&!A.shiftKey)&&(A.isComposing||(A.preventDefault(),a.dirLoading.value)||a.confirm()))return;if(A.key==="Escape"){A.preventDefault(),a.dismiss();return}}if(p.value){if(A.key==="ArrowUp"){A.preventDefault(),c.value=(c.value-1+h.value.length)%h.value.length;return}if(A.key==="ArrowDown"){A.preventDefault(),c.value=(c.value+1)%h.value.length;return}if(A.key==="Tab"||A.key==="Enter"&&!A.shiftKey){if(A.key==="Enter"&&A.isComposing)return;A.preventDefault(),v();return}if(A.key==="Escape"){A.preventDefault(),u.value=!0;return}}if((A.ctrlKey||A.metaKey)&&A.key.toLowerCase()==="s"){A.preventDefault(),s.busy?je():Se();return}if(E.value&&!A.isComposing){if(A.key==="ArrowDown"){A.preventDefault(),T(1);return}if(A.key==="ArrowUp"){A.preventDefault(),T(-1);return}if(A.key==="Escape"){A.preventDefault(),E.value=!1;return}if((A.key==="Tab"||A.key==="Enter"&&!A.shiftKey)&&$.value[L.value]!==void 0){A.preventDefault(),x($.value[L.value]);return}}if(A.key==="Enter"&&!A.shiftKey){if(A.isComposing||Date.now()-w<100)return;A.preventDefault(),Se();return}A.key==="ArrowUp"&&!A.isComposing&&!s.busy&&i.value.trim().length===0&&$.value.length>0&&(A.preventDefault(),y())}function ge(){k.value=[],o("abort")}function he(A){i.value=A,E.value=!1,ft(()=>{var N;H(),(N=l.value)==null||N.focus()})}function Fe(A){i.value+=A,ft(()=>{var N;H(),(N=l.value)==null||N.focus()})}t({insertText:he,openModelPicker:G});const K=q(()=>{var A;return(A=s.status)==null?void 0:A.model}),ae=q(()=>{var A;return(A=s.status)==null?void 0:A.permission}),V=q(()=>{var A;return(A=s.status)==null?void 0:A.contextUsage}),ve=q(()=>s.placeholder??(s.busy?"回合进行中:Enter/Ctrl+S 排队消息,随下一轮注入":"输入消息,@ 提及,/ 触发指令")),Oe=F(!1),Ue={off:"关闭",low:"低",medium:"中",high:"高",xhigh:"超高",max:"最大"},Pe=q(()=>{var A;return(A=s.status)==null?void 0:A.thinkingLevel}),_=q(()=>{const A=Pe.value;return!A||A==="none"?"":Ue[A]??A}),M=q(()=>s.models.length>0);function G(){return M.value?(Oe.value=!0,!0):!1}function Q(){M.value&&(Oe.value=!Oe.value)}function Y(A){o("switch-model",A)}function X(A){o("switch-thinking",A)}const ie=q(()=>{switch(ae.value){case"auto":return"perm-auto";case"yolo":return"perm-yolo";default:return"perm-manual"}}),ce=q(()=>{switch(ae.value){case"auto":return"自动";case"yolo":return"YOLO";default:return"手动"}});return(A,N)=>(g(),m("div",{class:"composer",style:Nt(B.value?{paddingBottom:B.value+"px"}:void 0)},[p.value?(g(),Xe(hy,{key:0,commands:h.value,"active-index":c.value,onSelect:v,onHover:N[0]||(N[0]=ue=>c.value=ue)},null,8,["commands","active-index"])):U("",!0),W(a).visible.value?(g(),Xe(Ev,{key:1,suggestions:W(a).suggestions.value,"active-index":W(a).index.value,loading:W(a).dirLoading.value,"work-dir":e.workDir,onSelect:N[1]||(N[1]=ue=>W(a).confirm(ue)),onHover:N[2]||(N[2]=ue=>W(a).index.value=ue)},null,8,["suggestions","active-index","loading","work-dir"])):U("",!0),E.value&&$.value.length>0?(g(),Xe(Hv,{key:2,items:$.value,"active-index":L.value,onApply:x,onHover:N[3]||(N[3]=ue=>L.value=ue)},null,8,["items","active-index"])):U("",!0),it(d("textarea",{ref_key:"textareaRef",ref:l,"onUpdate:modelValue":N[4]||(N[4]=ue=>i.value=ue),id:"composer-input",name:"message",class:"composer-input",rows:"1",placeholder:ve.value,onKeydown:Qe,onCompositionend:N[5]||(N[5]=ue=>ht(w)?w.value=Date.now():w=Date.now()),onClick:O,onKeyup:O},null,40,py),[[ut,i.value]]),d("div",gy,[d("div",my,[e.variant==="home"?(g(),m("button",{key:0,class:"quick-action",title:"插入 / 触发指令",onClick:N[6]||(N[6]=ue=>Fe("/"))},[J(me,{name:"command",size:15}),N[10]||(N[10]=d("span",null,"技能",-1))])):(g(),m(ee,{key:1},[d("button",{class:"quick-action",title:"插入 @ 提及",onClick:N[7]||(N[7]=ue=>Fe("@"))},[J(me,{name:"at",size:15}),N[11]||(N[11]=d("span",null,"提及",-1))]),d("button",{class:"quick-action",title:"插入 / 触发指令",onClick:N[8]||(N[8]=ue=>Fe("/"))},[J(me,{name:"command",size:15}),N[12]||(N[12]=d("span",null,"指令",-1))])],64)),ae.value?(g(),m("span",{key:2,class:fe(["permission-label",ie.value]),title:`权限模式:${ae.value}`},R(ce.value),11,vy)):U("",!0),k.value.length?(g(),m("span",yy,"已排队 "+R(k.value.length)+" 条",1)):U("",!0)]),d("div",by,[K.value?(g(),m("button",{key:0,class:fe(["model-select",{clickable:M.value}]),disabled:!M.value,title:e.variant==="home"?`当前模型:${K.value}`:`当前模型:${K.value}`,onClick:Q},[J(me,{name:"brain",size:15}),d("span",null,R(e.variant==="home"?"通用智能体":K.value),1),e.variant!=="home"&&_.value?(g(),m(ee,{key:0},[Ce(" · "+R(_.value),1)],64)):U("",!0),M.value?(g(),Xe(me,{key:1,name:"chevron-down",size:12})):U("",!0)],10,ky)):U("",!0),J(_i,{name:"picker"},{default:Pt(()=>[Oe.value?(g(),Xe(oy,{key:0,models:e.models,"current-model":K.value,"current-thinking":Pe.value,onApplyModel:Y,onApplyThinking:X,onClose:N[9]||(N[9]=ue=>Oe.value=!1)},null,8,["models","current-model","current-thinking"])):U("",!0)]),_:1}),V.value!==void 0?(g(),m("span",wy,[J(sd,{usage:V.value,size:15},null,8,["usage"])])):U("",!0),e.busy?(g(),m("button",{key:2,class:"stop-btn",title:"停止当前回合",onClick:ge},[J(me,{name:"stop",size:14}),N[13]||(N[13]=d("span",null,"停止",-1))])):(g(),m("button",{key:3,class:"send-btn",disabled:!i.value.trim(),title:"发送 (Enter)","aria-label":"发送",onClick:Se},[J(me,{name:"arrow-up",size:16})],8,_y))])])],4))}}),od=Ie(Sy,[["__scopeId","data-v-ef09b90f"]]),$y={class:"conv-bar"},xy={class:"conv-bar-left"},Cy=["title"],Ty=["title"],Iy={key:1,class:"title-text"},Ry={class:"conv-bar-right"},Ay=["title","aria-label"],My=["title","aria-label","aria-expanded"],Ey={key:0,class:"stats-token mono"},Py=["title","aria-label"],Ly=Te({__name:"ConversationHeader",props:{title:{default:null},busy:{type:Boolean,default:!1},drawerOpen:{type:Boolean,default:!1},statsOpen:{type:Boolean,default:!1},turnTokens:{default:null}},emits:["home","rename","export","clear","toggle-drawer","toggle-stats"],setup(e,{emit:t}){const n=e,s=t;function o(f){return f===null||f<=0?"":f>=1e6?`${(f/1e6).toFixed(1)}M`:f>=1e3?`${(f/1e3).toFixed(1)}k`:String(f)}const i=F(!1),l=F("");function r(){l.value=n.title??"",i.value=!0}function a(){const f=l.value.trim();i.value=!1,f&&f!==n.title&&s("rename",f)}function c(f){f.key==="Enter"?(f.preventDefault(),a()):f.key==="Escape"&&(f.preventDefault(),i.value=!1)}const u=q(()=>n.busy?"运行中":"就绪");return(f,h)=>(g(),m("header",$y,[d("div",xy,[d("button",{class:"ghost-btn back-btn",title:"返回工作台","aria-label":"返回工作台",onClick:h[0]||(h[0]=p=>s("home"))},[J(me,{name:"chevron-left",size:20})]),d("span",{class:fe(["status-dot",{busy:e.busy}]),title:u.value,"aria-hidden":"true"},null,10,Cy),d("button",{class:"title-btn",title:i.value?"":"点击重命名",onClick:r},[i.value?it((g(),m("input",{key:0,"onUpdate:modelValue":h[1]||(h[1]=p=>l.value=p),class:"title-input","aria-label":"会话标题",onKeydown:c,onBlur:a,onClick:h[2]||(h[2]=rt(()=>{},["stop"]))},null,544)),[[ut,l.value]]):(g(),m("span",Iy,R(e.title||"新会话"),1))],8,Ty)]),d("div",Ry,[d("button",{class:"ghost-btn",title:"导出 Markdown","aria-label":"导出 Markdown",onClick:h[3]||(h[3]=p=>s("export"))},[J(me,{name:"download",size:18})]),d("button",{class:"ghost-btn",title:"清空本地消息","aria-label":"清空本地消息",onClick:h[4]||(h[4]=p=>s("clear"))},[J(me,{name:"broom",size:18})]),d("button",{class:fe(["ghost-btn",{active:e.drawerOpen}]),title:e.drawerOpen?"收起详情":"会话详情","aria-label":e.drawerOpen?"收起详情":"会话详情",onClick:h[5]||(h[5]=p=>s("toggle-drawer"))},[J(me,{name:"panel-right",size:18})],10,Ay),d("button",{class:fe(["ghost-btn stats-btn",{active:e.statsOpen}]),title:e.statsOpen?"收起会话统计":"会话统计","aria-label":e.statsOpen?"收起会话统计":"会话统计","aria-expanded":e.statsOpen,onPointerdown:h[6]||(h[6]=rt(()=>{},["stop"])),onClick:h[7]||(h[7]=p=>s("toggle-stats"))},[J(me,{name:"bar-chart",size:18}),o(e.turnTokens)?(g(),m("span",Ey,R(o(e.turnTokens)),1)):U("",!0)],42,My),d("button",{class:fe(["ghost-btn",{active:W($e).panelOpen}]),title:W($e).panelOpen?"收起文件面板":"打开文件面板","aria-label":W($e).panelOpen?"收起文件面板":"打开文件面板",onClick:h[8]||(h[8]=(...p)=>W(Da)&&W(Da)(...p))},[J(me,{name:"file",size:18})],10,Py)])]))}}),Oy=Ie(Ly,[["__scopeId","data-v-2090798b"]]),Dy={key:0,class:"ui-dialog-header"},Ny={class:"ui-dialog-title"},By={class:"ui-dialog-body"},Fy={key:1,class:"ui-dialog-footer"},jy='a[href], button:not([disabled]), textarea, input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',Uy=Te({__name:"Dialog",props:{open:{type:Boolean},title:{default:void 0},closable:{type:Boolean,default:!0},maxWidth:{default:void 0}},emits:["close"],setup(e,{emit:t}){const n=e,s=t,o=F(null);let i=null;function l(){const a=o.value;return a?Array.from(a.querySelectorAll(jy)).filter(c=>c.offsetParent!==null||c===document.activeElement):[]}function r(a){var p,v,k;if(!n.open)return;if(a.key==="Escape"&&n.closable!==!1){a.stopPropagation(),s("close");return}if(a.key!=="Tab")return;const c=l();if(c.length===0){a.preventDefault(),(p=o.value)==null||p.focus();return}const u=c[0],f=c[c.length-1],h=document.activeElement;a.shiftKey?(h===u||!((v=o.value)!=null&&v.contains(h)))&&(a.preventDefault(),f.focus()):(h===f||!((k=o.value)!=null&&k.contains(h)))&&(a.preventDefault(),u.focus())}return Ee(()=>n.open,a=>{a?(i=document.activeElement instanceof HTMLElement?document.activeElement:null,ft(()=>{const c=l()[0]??o.value;c==null||c.focus()})):i&&(i.focus(),i=null)},{immediate:!1}),ct(()=>window.addEventListener("keydown",r,!0)),Ct(()=>window.removeEventListener("keydown",r,!0)),(a,c)=>(g(),Xe(tr,{to:"body"},[J(_i,{name:"dialog"},{default:Pt(()=>[e.open?(g(),m("div",{key:0,class:"ui-dialog-overlay",onClick:c[1]||(c[1]=rt(u=>e.closable!==!1&&s("close"),["self"]))},[d("div",{ref_key:"dialogRef",ref:o,class:"ui-dialog",style:Nt(e.maxWidth?{maxWidth:e.maxWidth}:void 0),role:"dialog","aria-modal":"true",tabindex:"-1"},[e.title||a.$slots.header?(g(),m("div",Dy,[Co(a.$slots,"header",{},()=>[d("span",Ny,R(e.title),1)],!0),e.closable!==!1?(g(),m("button",{key:0,class:"ui-dialog-close","aria-label":"关闭",onClick:c[0]||(c[0]=u=>s("close"))},"✕")):U("",!0)])):U("",!0),d("div",By,[Co(a.$slots,"default",{},void 0,!0)]),a.$slots.footer?(g(),m("div",Fy,[Co(a.$slots,"footer",{},void 0,!0)])):U("",!0)],4)])):U("",!0)]),_:3})]))}}),Gy=Ie(Uy,[["__scopeId","data-v-396acebf"]]),zy={class:"info-row"},Hy={class:"info-val mono"},Wy={class:"info-row"},qy={class:"info-val mono"},Vy={class:"info-row"},Ky={class:"info-val"},Yy={class:"info-row"},Zy={class:"info-val"},Jy={class:"info-row"},Xy={class:"info-val"},Qy={class:"info-row"},eb={class:"info-val"},tb={class:"info-row"},nb={class:"info-val"},sb={class:"info-row"},ob={class:"info-val"},ib={class:"info-row"},lb={class:"info-val"},rb={class:"info-row"},ab={class:"info-val"},cb={key:0,class:"info-row"},ub={class:"info-val"},db={key:1,class:"info-row"},fb={class:"info-val"},hb={class:"info-val mono"},pb={class:"info-val"},gb={key:3,class:"info-empty"},mb=Te({__name:"InfoPanel",props:{mode:{},status:{},sessionId:{},workDir:{}},emits:["close"],setup(e,{emit:t}){const n=e,s=t,o=q(()=>n.mode==="status"?"会话状态":"Token 用量");function i(p){switch(p){case"auto":return"自动 (auto)";case"yolo":return"YOLO";case"manual":return"手动 (manual)";default:return p??"-"}}function l(p){return p?"开启":"关闭"}function r(p){return p!=null}function a(p){return typeof p=="number"?p.toLocaleString():"-"}function c(p){return typeof p!="number"?"-":`${(p>1?p:p*100).toFixed(1)}%`}function u(p){return p?p.inputOther+p.output+p.inputCacheRead+p.inputCacheCreation:0}function f(p){return p!=null&&p.byModel?Object.entries(p.byModel).map(([v,k])=>({model:v,tokens:u(k),output:k.output,cacheRead:k.inputCacheRead})):[]}const h=q(()=>r(n.status.usage)||r(n.status.contextTokens));return(p,v)=>(g(),Xe(Gy,{open:!0,title:o.value,onClose:v[0]||(v[0]=k=>s("close"))},{default:Pt(()=>{var k,w;return[e.mode==="status"?(g(),m(ee,{key:0},[d("div",zy,[v[1]||(v[1]=d("span",{class:"info-key"},"会话 ID",-1)),d("span",Hy,R(e.sessionId??"-"),1)]),d("div",Wy,[v[2]||(v[2]=d("span",{class:"info-key"},"工作目录",-1)),d("span",qy,R(e.workDir??"-"),1)]),d("div",Vy,[v[3]||(v[3]=d("span",{class:"info-key"},"模型",-1)),d("span",Ky,R(e.status.model??"-"),1)]),d("div",Yy,[v[4]||(v[4]=d("span",{class:"info-key"},"权限模式",-1)),d("span",Zy,R(i(e.status.permission)),1)]),d("div",Jy,[v[5]||(v[5]=d("span",{class:"info-key"},"思考级别",-1)),d("span",Xy,R(e.status.thinkingLevel??"-"),1)]),d("div",Qy,[v[6]||(v[6]=d("span",{class:"info-key"},"计划模式",-1)),d("span",eb,R(l(e.status.planMode)),1)]),d("div",tb,[v[7]||(v[7]=d("span",{class:"info-key"},"WolfPack 模式",-1)),d("span",nb,R(l(e.status.wolfpackMode)),1)]),d("div",sb,[v[8]||(v[8]=d("span",{class:"info-key"},"上下文",-1)),d("span",ob,R(a(e.status.contextTokens))+" / "+R(a(e.status.maxContextTokens))+" ("+R(c(e.status.contextUsage))+")",1)])],64)):(g(),m(ee,{key:1},[d("div",ib,[v[9]||(v[9]=d("span",{class:"info-key"},"上下文 Token",-1)),d("span",lb,R(a(e.status.contextTokens))+" / "+R(a(e.status.maxContextTokens)),1)]),d("div",rb,[v[10]||(v[10]=d("span",{class:"info-key"},"上下文占比",-1)),d("span",ab,R(c(e.status.contextUsage)),1)]),(k=e.status.usage)!=null&&k.total?(g(),m("div",cb,[v[11]||(v[11]=d("span",{class:"info-key"},"累计 Token",-1)),d("span",ub,R(a(u(e.status.usage.total))),1)])):U("",!0),(w=e.status.usage)!=null&&w.currentTurn?(g(),m("div",db,[v[12]||(v[12]=d("span",{class:"info-key"},"当前回合",-1)),d("span",fb,R(a(u(e.status.usage.currentTurn))),1)])):U("",!0),f(e.status.usage).length?(g(),m(ee,{key:2},[v[13]||(v[13]=d("div",{class:"info-subhead"},"按模型",-1)),(g(!0),m(ee,null,Me(f(e.status.usage),S=>(g(),m("div",{key:S.model,class:"info-row info-row-model"},[d("span",hb,R(S.model),1),d("span",pb,R(a(S.tokens))+"(输出 "+R(a(S.output))+" · 缓存读 "+R(a(S.cacheRead))+")",1)]))),128))],64)):U("",!0),h.value?U("",!0):(g(),m("div",gb,"暂无用量数据"))],64))]}),_:1},8,["title"]))}}),vb=Ie(mb,[["__scopeId","data-v-1555711d"]]);function yb(e,t=Date.now()){const n=new Date(e),s=new Date(t),o=n.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return n.getFullYear()===s.getFullYear()&&n.getMonth()===s.getMonth()&&n.getDate()===s.getDate()?o:`${n.getFullYear()===s.getFullYear()?`${n.getMonth()+1}月${n.getDate()}日`:`${n.getFullYear()}年${n.getMonth()+1}月${n.getDate()}日`} ${o}`}function bb(e,t){const n=new Date(e),s=new Date(t);return n.getFullYear()===s.getFullYear()&&n.getMonth()===s.getMonth()&&n.getDate()===s.getDate()}function kb(e,t=Date.now()){const n=new Date(e),s=new Date(t);return n.getFullYear()===s.getFullYear()?`${n.getMonth()+1}月${n.getDate()}日`:`${n.getFullYear()}年${n.getMonth()+1}月${n.getDate()}日`}const wb=new Set(["edit","str_replace","replace","write","multi_edit","create_file","edit_file","apply_patch"]);function id(e){return wb.has(e.toLowerCase())}function xi(e,t=!0){return e.suspended?"suspended":e.isError?"error":e.output===void 0?t?"running":"unknown":"ok"}function _b(e,t=!0){const n=new Set(e.map(s=>xi(s,t)));return n.has("running")?"running":n.has("error")?"error":n.has("suspended")?"suspended":n.has("unknown")?"unknown":"ok"}function Sb(e){if(!e||typeof e!="object")return null;const t=e,n=t.file_path??t.path;return typeof n=="string"&&n.length>0?n:null}function ur(e,t){if(e.startsWith("/")||e.startsWith("~"))return e;let n=e;for(;n.startsWith("./");)n=n.slice(2);return t?`${t.replace(/\/+$/,"")}/${n}`:n}function $b(e,t){const n=new Set,s=[];for(const o of e.tools){if(!id(o.name)||xi(o,!1)!=="ok")continue;const i=Sb(o.args);if(!i)continue;const l=ur(i,t);n.has(l)||(n.add(l),s.push({filePath:l,toolName:o.name}))}return s}function dr(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Xn=dr();function ld(e){Xn=e}var Bs={exec:()=>null};function Ve(e,t=""){let n=typeof e=="string"?e:e.source;const s={replace:(o,i)=>{let l=typeof i=="string"?i:i.source;return l=l.replace(At.caret,"$1"),n=n.replace(o,l),s},getRegex:()=>new RegExp(n,t)};return s}var At={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},xb=/^(?:[ \t]*(?:\n|$))+/,Cb=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Tb=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,oo=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ib=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,fr=/(?:[*+-]|\d{1,9}[.)])/,rd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ad=Ve(rd).replace(/bull/g,fr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Rb=Ve(rd).replace(/bull/g,fr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),hr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Ab=/^[^\n]+/,pr=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Mb=Ve(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",pr).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Eb=Ve(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,fr).getRegex(),Ci="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",gr=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Pb=Ve("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",gr).replace("tag",Ci).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),cd=Ve(hr).replace("hr",oo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ci).getRegex(),Lb=Ve(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",cd).getRegex(),mr={blockquote:Lb,code:Cb,def:Mb,fences:Tb,heading:Ib,hr:oo,html:Pb,lheading:ad,list:Eb,newline:xb,paragraph:cd,table:Bs,text:Ab},ja=Ve("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",oo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ci).getRegex(),Ob={...mr,lheading:Rb,table:ja,paragraph:Ve(hr).replace("hr",oo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ja).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ci).getRegex()},Db={...mr,html:Ve(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",gr).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Bs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ve(hr).replace("hr",oo).replace("heading",` *#{1,6} *[^
|
|
20
20
|
]`).replace("lheading",ad).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Nb=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Bb=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ud=/^( {2,}|\\)\n(?!\s*$)/,Fb=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ti=/[\p{P}\p{S}]/u,vr=/[\s\p{P}\p{S}]/u,dd=/[^\s\p{P}\p{S}]/u,jb=Ve(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,vr).getRegex(),fd=/(?!~)[\p{P}\p{S}]/u,Ub=/(?!~)[\s\p{P}\p{S}]/u,Gb=/(?:[^\s\p{P}\p{S}]|~)/u,zb=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,hd=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Hb=Ve(hd,"u").replace(/punct/g,Ti).getRegex(),Wb=Ve(hd,"u").replace(/punct/g,fd).getRegex(),pd="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",qb=Ve(pd,"gu").replace(/notPunctSpace/g,dd).replace(/punctSpace/g,vr).replace(/punct/g,Ti).getRegex(),Vb=Ve(pd,"gu").replace(/notPunctSpace/g,Gb).replace(/punctSpace/g,Ub).replace(/punct/g,fd).getRegex(),Kb=Ve("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,dd).replace(/punctSpace/g,vr).replace(/punct/g,Ti).getRegex(),Yb=Ve(/\\(punct)/,"gu").replace(/punct/g,Ti).getRegex(),Zb=Ve(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Jb=Ve(gr).replace("(?:-->|$)","-->").getRegex(),Xb=Ve("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Jb).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Vo=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Qb=Ve(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Vo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),gd=Ve(/^!?\[(label)\]\[(ref)\]/).replace("label",Vo).replace("ref",pr).getRegex(),md=Ve(/^!?\[(ref)\](?:\[\])?/).replace("ref",pr).getRegex(),e1=Ve("reflink|nolink(?!\\()","g").replace("reflink",gd).replace("nolink",md).getRegex(),yr={_backpedal:Bs,anyPunctuation:Yb,autolink:Zb,blockSkip:zb,br:ud,code:Bb,del:Bs,emStrongLDelim:Hb,emStrongRDelimAst:qb,emStrongRDelimUnd:Kb,escape:Nb,link:Qb,nolink:md,punctuation:jb,reflink:gd,reflinkSearch:e1,tag:Xb,text:Fb,url:Bs},t1={...yr,link:Ve(/^!?\[(label)\]\((.*?)\)/).replace("label",Vo).getRegex(),reflink:Ve(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Vo).getRegex()},Il={...yr,emStrongRDelimAst:Vb,emStrongLDelim:Wb,url:Ve(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},n1={...Il,br:Ve(ud).replace("{2,}","*").getRegex(),text:Ve(Il.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},vo={normal:mr,gfm:Ob,pedantic:Db},xs={normal:yr,gfm:Il,breaks:n1,pedantic:t1},s1={"&":"&","<":"<",">":">",'"':""","'":"'"},Ua=e=>s1[e];function en(e,t){if(t){if(At.escapeTest.test(e))return e.replace(At.escapeReplace,Ua)}else if(At.escapeTestNoEncode.test(e))return e.replace(At.escapeReplaceNoEncode,Ua);return e}function Ga(e){try{e=encodeURI(e).replace(At.percentDecode,"%")}catch{return null}return e}function za(e,t){var i;const n=e.replace(At.findPipe,(l,r,a)=>{let c=!1,u=r;for(;--u>=0&&a[u]==="\\";)c=!c;return c?"|":" |"}),s=n.split(At.splitPipe);let o=0;if(s[0].trim()||s.shift(),s.length>0&&!((i=s.at(-1))!=null&&i.trim())&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;o<s.length;o++)s[o]=s[o].trim().replace(At.slashPipe,"|");return s}function Cs(e,t,n){const s=e.length;if(s===0)return"";let o=0;for(;o<s&&e.charAt(s-o-1)===t;)o++;return e.slice(0,s-o)}function o1(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let s=0;s<e.length;s++)if(e[s]==="\\")s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return n>0?-2:-1}function Ha(e,t,n,s,o){const i=t.href,l=t.title||null,r=e[1].replace(o.other.outputLinkReplace,"$1");s.state.inLink=!0;const a={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:l,text:r,tokens:s.inlineTokens(r)};return s.state.inLink=!1,a}function i1(e,t,n){const s=e.match(n.other.indentCodeCompensation);if(s===null)return t;const o=s[1];return t.split(`
|
|
@@ -93,4 +93,4 @@ Please report this to https://github.com/markedjs/marked.`,e){const s="<p>An err
|
|
|
93
93
|
`),s=t.split(`
|
|
94
94
|
`);if(n.length+s.length>jw){const i=[];return n.forEach((l,r)=>i.push({type:"del",text:l,oldNo:r+1})),s.forEach((l,r)=>i.push({type:"add",text:l,newNo:r+1})),i}const o=Uw(n,s);return Gw(o,n,s,n.length,s.length)}function Hw(e){let t=0,n=0;for(const s of e)s.type==="add"?t++:s.type==="del"&&n++;return{added:t,removed:n}}const Ww=["old_string","oldString","old_str","old_text","oldText","old","search"],qw=["new_string","newString","new_str","new_text","newText","new","replace","content"],Vw=["path","file_path","filePath","file","filename"];function il(e,t){for(const n of t){const s=e[n];if(typeof s=="string"&&s.length>0)return s}}function Kw(e){if(!e||typeof e!="object")return null;const t=e,n=il(t,Vw),s=il(t,Ww),o=il(t,qw);if(!o&&!s)return null;const i=zw(s??"",o??""),l=Hw(i);return{path:n,diff:i,stats:l}}const Yw={class:"diff-lines"},Zw={class:"dl-gutter old"},Jw={class:"dl-gutter new"},Xw={class:"dl-sign"},Qw={class:"dl-text"},e_=Te({__name:"DiffLines",props:{lines:{}},setup(e){return(t,n)=>(g(),m("div",Yw,[(g(!0),m(ee,null,Me(e.lines,(s,o)=>(g(),m("div",{key:o,class:fe(["dl",`dl-${s.type}`])},[d("span",Zw,R(s.oldNo??""),1),d("span",Jw,R(s.newNo??""),1),d("span",Xw,R(s.type==="add"?"+":s.type==="del"?"−":" "),1),d("span",Qw,R(s.text),1)],2))),128))]))}}),Mr=Ie(e_,[["__scopeId","data-v-e2e145aa"]]),t_=["onKeydown"],n_={class:"tool-name"},s_=["title"],o_={key:1,class:"diff-chip"},i_={class:"tool-collapse-inner"},l_={class:"tool-body"},r_={key:1,class:"tool-result"},a_={key:2,class:"tool-running-hint"},c_=Te({__name:"EditToolCard",props:{tool:{},live:{type:Boolean,default:!0},workDir:{default:""},sessionId:{default:""}},setup(e){const t=e,n=q(()=>xi(t.tool,t.live)),s=q(()=>{switch(n.value){case"ok":return"✓";case"error":return"✗";default:return""}}),o=q(()=>Kw(t.tool.args)),i=q(()=>{const k=o.value;if(!k||n.value==="error")return"";const{added:w,removed:S}=k.stats;return!w&&!S?"":`+${w} −${S}`}),l=q(()=>{var k;return(k=o.value)==null?void 0:k.path}),r=F(!1);let a=!1;Ee(n,k=>{a||(r.value=k==="running")},{immediate:!0});function c(){a=!0,r.value=!r.value}const u=q(()=>{var k;return((k=o.value)==null?void 0:k.diff)??[]}),f=q(()=>u.value.length>0),h=nf(q(()=>t.tool),n,()=>t.live);function p(){const k=l.value;k&&Zn(ur(k,t.workDir||void 0),{modeHint:"diff",sessionId:t.sessionId||null})}const v=q(()=>{var S;const k=t.tool.progress;if(!k)return"";const w=k.split(`
|
|
95
95
|
`).filter($=>$.trim());return((S=w[w.length-1])==null?void 0:S.slice(0,60))??""});return(k,w)=>(g(),m("div",{class:fe(["tool-card",`is-${n.value}`,"edit-tool-card"])},[d("div",{class:"tool-header",role:"button",tabindex:"0",onClick:c,onKeydown:Vn(rt(c,["prevent"]),["enter"])},[d("span",{class:fe(["status-dot",n.value])},[s.value?(g(),m(ee,{key:0},[Ce(R(s.value),1)],64)):U("",!0)],2),d("span",n_,R(e.tool.name),1),l.value?(g(),m("button",{key:0,class:"tool-filepath",title:`在文件面板中打开(diff) ${l.value}`,onClick:rt(p,["stop"])},R(l.value),9,s_)):U("",!0),i.value?(g(),m("span",o_,R(i.value),1)):U("",!0),W(h)?(g(),m("span",{key:2,class:fe(["tool-duration",{live:e.tool.durationMs===void 0}])},R(W(h)),3)):U("",!0),d("span",{class:fe(["tool-chevron",{open:r.value}])},"▸",2)],40,t_),d("div",{class:fe(["tool-collapse",{open:r.value}])},[d("div",i_,[d("div",l_,[f.value?(g(),Xe(Mr,{key:0,lines:u.value},null,8,["lines"])):U("",!0),e.tool.output!==void 0?(g(),m("pre",r_,[d("code",null,R(e.tool.output||"(无输出)"),1)])):(g(),m("div",a_,R(v.value||"执行中…"),1))])])],2)],2))}}),u_=Ie(c_,[["__scopeId","data-v-eff4962d"]]),d_=["aria-expanded"],f_={class:"process-label"},h_={class:"process-meta"},p_=["title"],g_={class:"process-collapse"},m_={class:"process-inner"},v_=Te({__name:"ToolGroup",props:{name:{},tools:{},live:{type:Boolean,default:!0},workDir:{default:""},sessionId:{default:""}},setup(e){const t=e,n=F(!1),s=q(()=>_b(t.tools,t.live)),o=q(()=>t.tools.filter(r=>r.output!==void 0&&!r.isError).length),i=q(()=>s.value==="running"?"执行中":s.value==="error"?"含失败调用":s.value==="suspended"?"含挂起等待":s.value==="unknown"?"结果未持久化":`已完成 ${o.value} 项`);function l(){n.value=!n.value}return(r,a)=>(g(),m("section",{class:fe(["tool-process",{open:n.value,running:s.value==="running",error:s.value==="error"}])},[d("button",{class:"process-head",type:"button","aria-expanded":n.value,onClick:l},[J(me,{name:"chevron-down",size:12,class:"chevron"}),d("span",{class:fe(["process-dot",s.value]),"aria-hidden":"true"},null,2),d("span",f_,R(e.name),1),d("span",h_,R(i.value)+" · "+R(e.tools.length)+" 步",1),d("span",{class:"process-names",title:e.tools.map(c=>c.name).join("、")},R(e.tools.map(c=>c.name).join(" · ")),9,p_)],8,d_),d("div",g_,[d("div",m_,[(g(!0),m(ee,null,Me(t.tools,c=>(g(),Xe(_p(W(id)(c.name)?u_:Fw),{key:c.toolCallId,tool:c,live:e.live,"work-dir":e.workDir,"session-id":e.sessionId},null,8,["tool","live","work-dir","session-id"]))),128))])])],2))}}),y_=Ie(v_,[["__scopeId","data-v-ca5b0e07"]]),b_={class:"thinking-block"},k_=["title"],w_={class:"teaser-text"},__={class:"teaser-open"},S_={key:1,class:"thinking-stream"},$_={class:"thinking-panel",role:"dialog","aria-label":"思考过程"},x_={class:"panel-body"},C_=Te({__name:"ThinkingBlock",props:{tool:{},active:{type:Boolean,default:!1},sessionId:{default:""},msgSeq:{default:void 0}},setup(e){const t=e,n=F(!1),s=F(null),o=F(!1),i=F(!1),l=F(t.tool.output??"");Ee(()=>t.tool.output,h=>{h!==void 0&&!o.value&&!i.value&&(l.value=h)});const r=q(()=>!!t.tool.truncated);async function a(){if(!(!r.value||i.value||o.value)&&!(!t.sessionId||t.msgSeq===void 0)){o.value=!0;try{const p=await(await fetch(`/api/v1/sessions/${t.sessionId}/messages?seq=${t.msgSeq}&tool=${encodeURIComponent(t.tool.toolCallId)}`)).json();typeof p.output=="string"&&p.output.length>0&&(l.value=p.output,i.value=!0)}catch{}finally{o.value=!1}}}const c=q(()=>l.value.split(/\n+/).map(p=>p.trim()).filter(Boolean).at(-1)??"");Ee(l,()=>{t.active&&ft(()=>{const h=s.value;h&&(h.scrollTop=h.scrollHeight)})});function u(){a(),n.value=!0}function f(){n.value=!1}return(h,p)=>(g(),m("div",b_,[e.active?(g(),m("div",S_,[p[1]||(p[1]=d("div",{class:"stream-header"},[d("span",{class:"stream-icon"},"💭"),d("span",{class:"stream-title"},"思考中…"),d("span",{class:"stream-dot"})],-1)),d("div",{ref_key:"streamRef",ref:s,class:"stream-body"},R(l.value),513)])):(g(),m("button",{key:0,class:"thinking-teaser",title:r.value?"思考较长,点击查看完整思考过程":"点击查看完整思考过程",onClick:u},[p[0]||(p[0]=d("span",{class:"teaser-icon"},"💭",-1)),d("span",w_,R(o.value?"加载完整思考…":c.value||"思考过程"),1),d("span",__,R(r.value?"查看全文":"展开"),1)],8,k_)),(g(),Xe(tr,{to:"body"},[n.value?(g(),m("div",{key:0,class:"thinking-overlay",onClick:rt(f,["self"])},[d("aside",$_,[d("header",{class:"panel-header"},[p[2]||(p[2]=d("span",null,"💭 思考过程",-1)),d("button",{class:"panel-close","aria-label":"关闭",onClick:f},"✕")]),d("div",x_,R(l.value||"(空)"),1)])])):U("",!0)]))]))}}),T_=Ie(C_,[["__scopeId","data-v-436ab760"]]),I_={key:0,class:"clock"},R_={class:"stat"},A_={class:"stat"},M_={class:"stat"},E_={class:"stat"},P_={class:"stat"},L_={class:"stat"},O_=Te({__name:"TurnStats",props:{stats:{}},setup(e){const t=e,n=F(null);let s=null;function o(){s!==null&&(clearInterval(s),s=null)}function i(){o();const a=t.stats.llmMs??0,c=Date.now();n.value=a,s=setInterval(()=>{n.value=a+(Date.now()-c)},300)}Ee(()=>t.stats.status,a=>{a==="running"?i():o()},{immediate:!0}),Ct(o);function l(a){return a==null?"—":a<1e3?`${Math.round(a)}ms`:`${(a/1e3).toFixed(1)}s`}function r(a){return a==null?"—":a>=1e3?`${(a/1e3).toFixed(1)}k`:`${a}`}return(a,c)=>(g(),m("div",{class:fe(["turn-stats",`is-${e.stats.status}`]),"aria-live":"polite"},[e.stats.status==="running"?(g(),m(ee,{key:0},[c[0]||(c[0]=d("span",{class:"badge-gradient"},"正在思考",-1)),n.value!==null?(g(),m("span",I_,R(l(n.value)),1)):U("",!0)],64)):(g(),m(ee,{key:1},[d("span",R_,R(e.stats.turn)+" 轮 · "+R(e.stats.step)+" 步",1),c[10]||(c[10]=d("span",{class:"dot"},"·",-1)),d("span",A_,[c[1]||(c[1]=d("span",{class:"k"},"LLM",-1)),Ce(" "+R(l(e.stats.llmMs)),1)]),e.stats.toolMs?(g(),m(ee,{key:0},[c[3]||(c[3]=d("span",{class:"dot"},"·",-1)),d("span",M_,[c[2]||(c[2]=d("span",{class:"k"},"工具",-1)),Ce(" "+R(l(e.stats.toolMs)),1)])],64)):U("",!0),e.stats.firstTokenMs!==null&&e.stats.firstTokenMs!==void 0?(g(),m(ee,{key:1},[c[5]||(c[5]=d("span",{class:"dot"},"·",-1)),d("span",E_,[c[4]||(c[4]=d("span",{class:"k"},"首token",-1)),Ce(" "+R(l(e.stats.firstTokenMs)),1)])],64)):U("",!0),e.stats.tokens!==null&&e.stats.tokens!==void 0?(g(),m(ee,{key:2},[c[7]||(c[7]=d("span",{class:"dot"},"·",-1)),d("span",P_,[c[6]||(c[6]=d("span",{class:"k"},"tokens",-1)),Ce(" "+R(r(e.stats.tokens)),1)])],64)):U("",!0),e.stats.tokensPerSec!==null&&e.stats.tokensPerSec!==void 0?(g(),m(ee,{key:3},[c[9]||(c[9]=d("span",{class:"dot"},"·",-1)),d("span",L_,[c[8]||(c[8]=d("span",{class:"k"},"tok/s",-1)),Ce(" "+R(e.stats.tokensPerSec),1)])],64)):U("",!0)],64))],2))}}),D_=Ie(O_,[["__scopeId","data-v-95536a3e"]]),N_=["data-message-id","data-message-role"],B_={key:0,class:"user-wrap"},F_={class:"user-head"},j_={key:0,class:"meta-time"},U_={class:"user-avatar","aria-hidden":"true"},G_={class:"user-bubble"},z_=["title","onClick"],H_={key:0,class:"message-meta user-meta"},W_={key:1,class:"assistant-wrap"},q_={key:0,class:"assistant-brand"},V_={key:0,class:"brand-model"},K_={key:1,class:"brand-streaming"},Y_={key:2,class:"brand-time"},Z_={class:"assistant-body"},J_={key:0,class:"degraded-note"},X_={key:4,class:"streaming-cursor","aria-label":"正在生成"},Q_={key:6,class:"written-files",role:"group","aria-label":"本回合写入的文件"},eS=["title","onClick"],tS={class:"written-file-name"},nS={key:7,class:"message-meta"},sS=["title"],oS=["title"],iS=Te({__name:"MessageItem",props:{message:{},isLatestUser:{type:Boolean,default:!1},idle:{type:Boolean,default:!0},streaming:{type:Boolean,default:!1},canFork:{type:Boolean,default:!1},showTimestamp:{type:Boolean,default:!0},sessionId:{default:""},workDir:{default:""}},emits:["edit","retry","fork"],setup(e,{emit:t}){const n=e,s=t,o=F(!1);let i=null;const l=q(()=>n.message.role==="user"),r=q(()=>n.message.role==="assistant"),a=q(()=>n.message.tools.filter(y=>y.name==="thinking")),c=q(()=>n.message.tools.filter(y=>y.name!=="thinking")),u=q(()=>n.message.ts!==void 0?yb(n.message.ts):""),f=q(()=>l.value&&n.isLatestUser&&n.idle),h=q(()=>r.value&&!n.streaming?$b(n.message,n.workDir||void 0):[]);function p(y){return y.split("/").pop()||y}function v(y){Zn(y,{sessionId:n.sessionId||void 0})}const k=/(^|\s)@("[^"\n]+"|[^\s"]+)/g;function w(y){if(!y||y.startsWith("/")||y.startsWith("~"))return y;const T=n.workDir.trim();if(!T)return y;let D=y;for(;D.startsWith("./");)D=D.slice(2);return`${T.replace(/\/+$/,"")}/${D}`}const S=q(()=>{const y=n.message.content;if(!l.value||!y||!y.includes("@"))return[];const T=[];let D=0;k.lastIndex=0;let I;for(;(I=k.exec(y))!==null;){const H=I.index+I[1].length;H>D&&T.push({text:y.slice(D,H),path:null});const O=I[2],B=O.startsWith('"')?O.slice(1,-1):O;T.push({text:y.slice(H,H+1+O.length),path:w(B)}),D=H+1+O.length}return D<y.length&&T.push({text:y.slice(D),path:null}),T});function $(y){Zn(y,{sessionId:n.sessionId||void 0})}const E=vn("showThinking",F(!0)),L=vn("showTools",F(!0)),Z=F(!1);let j=null;function C(){if(typeof window>"u"||!("speechSynthesis"in window))return;if(Z.value){window.speechSynthesis.cancel(),Z.value=!1,j=null;return}const y=n.message.content;if(!y)return;const T=new SpeechSynthesisUtterance(y);T.lang="zh-CN";const D=()=>{j===D&&(Z.value=!1,j=null)};j=D,T.addEventListener("end",D),T.addEventListener("error",D),window.speechSynthesis.cancel(),requestAnimationFrame(()=>{window.speechSynthesis.speak(T)}),Z.value=!0}Ct(()=>{Z.value&&"speechSynthesis"in window&&window.speechSynthesis.cancel()});async function x(){try{await navigator.clipboard.writeText(n.message.content)}catch{const y=document.createElement("textarea");y.value=n.message.content,document.body.append(y),y.select(),document.execCommand("copy"),y.remove()}o.value=!0,i!==null&&clearTimeout(i),i=window.setTimeout(()=>{o.value=!1},1500)}return(y,T)=>(g(),m("article",{class:fe(["message",e.message.role,{error:e.message.isError}]),"data-message-id":e.message.id,"data-message-role":e.message.role},[l.value?(g(),m("div",B_,[d("div",F_,[u.value?(g(),m("span",j_,R(u.value),1)):U("",!0),T[3]||(T[3]=d("span",{class:"head-name"},"你",-1)),d("span",U_,[J(me,{name:"user",size:12})])]),d("div",G_,[S.value.length?(g(!0),m(ee,{key:0},Me(S.value,(D,I)=>(g(),m(ee,{key:I},[D.path!==null?(g(),m("button",{key:0,class:"at-link",title:`在文件面板中打开 ${D.path}`,onClick:H=>$(D.path??"")},R(D.text),9,z_)):(g(),m(ee,{key:1},[Ce(R(D.text),1)],64))],64))),128)):(g(),m(ee,{key:1},[Ce(R(e.message.content),1)],64))]),f.value?(g(),m("div",H_,[d("button",{title:"编辑并重新发送",onClick:T[0]||(T[0]=D=>s("edit",e.message.content))},[J(me,{name:"edit",size:12}),T[4]||(T[4]=Ce("编辑重发",-1))])])):U("",!0)])):(g(),m("div",W_,[r.value&&(e.message.model||e.streaming||e.showTimestamp&&u.value)?(g(),m("div",q_,[e.message.model?(g(),m("span",V_,R(e.message.model),1)):U("",!0),e.streaming?(g(),m("span",K_,[...T[5]||(T[5]=[d("i",{"aria-hidden":"true"},null,-1),Ce("生成中",-1)])])):U("",!0),e.showTimestamp&&u.value?(g(),m("time",Y_,R(u.value),1)):U("",!0)])):U("",!0),d("div",Z_,[e.message.degraded?(g(),m("p",J_,"该回合早于持久化快照:正文与思考在服务重启后无法恢复(工具记录与消息结构已保留)。")):U("",!0),W(E)?(g(!0),m(ee,{key:1},Me(a.value,D=>(g(),Xe(T_,{key:D.toolCallId,tool:D,active:e.streaming,"session-id":e.sessionId,"msg-seq":e.message.seq},null,8,["tool","active","session-id","msg-seq"]))),128)):U("",!0),c.value.length&&W(L)?(g(),Xe(y_,{key:2,name:"工具调用过程",tools:c.value,live:e.streaming,"work-dir":e.workDir,"session-id":e.sessionId},null,8,["tools","live","work-dir","session-id"])):U("",!0),e.message.content?(g(),Xe(tf,{key:3,class:"assistant-content",content:e.message.content,streaming:e.streaming},null,8,["content","streaming"])):e.streaming?(g(),m("span",X_)):U("",!0),e.message.turnStats?(g(),Xe(D_,{key:5,stats:e.message.turnStats},null,8,["stats"])):U("",!0),h.value.length?(g(),m("div",Q_,[(g(!0),m(ee,null,Me(h.value,D=>(g(),m("button",{key:D.filePath,type:"button",class:"written-file",title:`在文件面板中打开 ${D.filePath}`,onClick:I=>v(D.filePath)},[J(me,{name:"file",size:12}),d("span",tS,R(p(D.filePath)),1)],8,eS))),128))])):U("",!0),e.message.content||e.message.isError&&!e.streaming||e.canFork?(g(),m("div",nS,[e.message.content?(g(),m("button",{key:0,title:o.value?"已复制":"复制内容",onClick:x},[J(me,{name:o.value?"check":"copy",size:12},null,8,["name"]),Ce(R(o.value?"已复制":"复制"),1)],8,sS)):U("",!0),e.message.content?(g(),m("button",{key:1,title:Z.value?"停止朗读":"朗读",onClick:C},[J(me,{name:Z.value?"speaker-off":"speaker",size:12},null,8,["name"]),Ce(R(Z.value?"停止":"朗读"),1)],8,oS)):U("",!0),e.message.isError&&!e.streaming?(g(),m("button",{key:2,class:"retry-btn",title:"重发最后一条消息",onClick:T[1]||(T[1]=D=>s("retry"))},[J(me,{name:"refresh",size:12}),T[6]||(T[6]=Ce("重试",-1))])):U("",!0),r.value&&e.canFork&&!e.streaming?(g(),m("button",{key:3,title:"以当前对话为起点创建一个新会话",onClick:T[2]||(T[2]=D=>s("fork"))},[J(me,{name:"fork",size:12}),T[7]||(T[7]=Ce("Fork",-1))])):U("",!0)])):U("",!0)])]))],10,N_))}}),lS=Ie(iS,[["__scopeId","data-v-b04b0b4d"]]),rS=""+new URL("../icon.ico",import.meta.url).href,aS={class:"empty-state"},cS={class:"suggestions"},uS=["onClick"],dS={class:"suggestion-icon"},fS={class:"suggestion-title"},hS={key:0,class:"recent","aria-label":"最近输入"},pS={class:"recent-chips"},gS=["title","onClick"],mS=["title"],vS={class:"workdir-path"},yS={class:"empty-status","aria-label":"连接与模型状态"},bS={class:"status-item"},kS={class:"status-item"},wS={class:"status-item"},_S="scream-recent-prompts",SS=Te({__name:"EmptyState",props:{workDir:{default:null},model:{default:null},contextUsage:{default:null},connected:{type:Boolean,default:!1}},emits:["pick"],setup(e,{emit:t}){const n=t,s=[{icon:"edit",title:"帮我写一个函数",prompt:"帮我写一个函数"},{icon:"clipboard",title:"解释这段代码",prompt:"解释这段代码"},{icon:"activity",title:"调试这个问题",prompt:"调试这个问题"}],o=F([]);ct(()=>{try{const l=localStorage.getItem(_S);if(l){const r=JSON.parse(l);Array.isArray(r)&&(o.value=r.filter(a=>typeof a=="string").slice(0,4))}}catch{o.value=[]}});function i(l){if(l==null)return"—";const r=l<=1?Math.round(l*100):Math.round(l);return`${Math.min(r,100)}%`}return(l,r)=>(g(),m("div",aS,[r[4]||(r[4]=d("div",{class:"empty-logo"},[d("img",{src:rS,alt:"Scream",class:"logo-img"})],-1)),r[5]||(r[5]=d("h1",{class:"empty-title"},"Scream Web UI",-1)),r[6]||(r[6]=d("p",{class:"empty-subtitle"},"给 Scream 发消息,开始处理你的任务",-1)),d("div",cS,[(g(),m(ee,null,Me(s,a=>d("button",{key:a.title,class:"suggestion-card",onClick:c=>n("pick",a.prompt)},[d("span",dS,[J(me,{name:a.icon,size:22},null,8,["name"])]),d("span",fS,R(a.title),1)],8,uS)),64))]),o.value.length>0?(g(),m("div",hS,[r[0]||(r[0]=d("span",{class:"recent-label"},"最近",-1)),d("div",pS,[(g(!0),m(ee,null,Me(o.value,(a,c)=>(g(),m("button",{key:`${c}-${a}`,class:"recent-chip",title:a,onClick:u=>n("pick",a)},R(a),9,gS))),128))])])):U("",!0),e.workDir?(g(),m("div",{key:1,class:"empty-workdir",title:e.workDir},[r[1]||(r[1]=d("span",{class:"workdir-label"},"工作目录",-1)),d("span",vS,R(e.workDir),1)],8,mS)):U("",!0),d("div",yS,[d("span",{class:fe(["status-dot",e.connected?"on":"off"])},null,2),d("span",bS,R(e.connected?"已连接":"未连接"),1),e.model?(g(),m(ee,{key:0},[r[2]||(r[2]=d("span",{class:"status-sep"},"·",-1)),d("span",kS,"模型 "+R(e.model),1)],64)):U("",!0),e.contextUsage!==null&&e.contextUsage!==void 0?(g(),m(ee,{key:1},[r[3]||(r[3]=d("span",{class:"status-sep"},"·",-1)),d("span",wS,"上下文 "+R(i(e.contextUsage)),1)],64)):U("",!0)]),r[7]||(r[7]=d("div",{class:"empty-shortcuts","aria-hidden":"true"},[d("span",null,[d("kbd",null,"⌘K"),Ce(" 搜索会话")]),d("span",null,[d("kbd",null,"⌘N"),Ce(" 新建会话")])],-1))]))}}),$S=Ie(SS,[["__scopeId","data-v-71ca3ccd"]]),xS={key:0,class:"minimap",role:"navigation","aria-label":"消息地图"},CS={class:"minimap-track"},TS=["title","aria-label","onMouseenter","onClick"],IS={key:0,class:"minimap-tooltip"},RS="(min-width: 960px)",AS=Te({__name:"ChatMinimap",props:{messages:{},host:{}},setup(e){const t=e,n=F(null),o=typeof window.matchMedia=="function"?window.matchMedia(RS):null,i=F((o==null?void 0:o.matches)??!1);function l(w){i.value=w.matches}ct(()=>o==null?void 0:o.addEventListener("change",l)),Ct(()=>o==null?void 0:o.removeEventListener("change",l));function r(w){var $;const S=(($=w.content)==null?void 0:$.length)??0;return S<=0?.2:.2+.8*(1-1/(1+S/200))}const a=q(()=>{let w=0;return t.messages.map((S,$)=>{const E=r(S),L={id:S.id??`seq-${$}`,seq:S.seq??$,role:S.role??"tool",ratio:E,offset:w};return w+=E,L})}),c=q(()=>a.value.reduce((w,S)=>w+S.ratio,0)||1),u=F(new Set);let f=null;const h=typeof window<"u"&&typeof IntersectionObserver=="function";function p(){f==null||f.disconnect();const w=t.host;if(!(!w||!i.value||!h)){f=new IntersectionObserver(S=>{const $=new Set(u.value);for(const E of S){const L=E.target.dataset.messageId;L&&(E.isIntersecting?$.add(L):$.delete(L))}u.value=$},{root:w,threshold:0});for(const S of t.messages){if(!S.id)continue;const $=w.querySelector(`[data-message-id="${CSS.escape(S.id)}"]`);$&&f.observe($)}}}Ee([()=>t.messages.length,()=>t.host,i],()=>{ft(p)}),ct(()=>p()),Ct(()=>f==null?void 0:f.disconnect());function v(w){const S=t.host;if(!S)return;const $=S.querySelector(`[data-message-id="${CSS.escape(w)}"]`);$&&$.scrollIntoView({behavior:"smooth",block:"start"})}function k(w){const S=w.role==="user"?"用户":w.role==="assistant"?"助手":"工具";return`#${w.seq} ${S}`}return(w,S)=>i.value&&a.value.length>0?(g(),m("div",xS,[d("div",CS,[(g(!0),m(ee,null,Me(a.value,$=>(g(),m("button",{key:$.id,class:fe(["minimap-block",[`role-${$.role}`,{"in-view":u.value.has($.id)}]]),style:Nt({top:`${$.offset/c.value*100}%`,height:`${Math.max($.ratio/c.value*100,2)}%`}),title:k($),"aria-label":k($),onMouseenter:E=>n.value=$.seq,onMouseleave:S[0]||(S[0]=E=>n.value=null),onClick:E=>v($.id)},[n.value===$.seq?(g(),m("span",IS,R(k($)),1)):U("",!0)],46,TS))),128))])])):U("",!0)}}),MS=Ie(AS,[["__scopeId","data-v-78b50335"]]),ES={class:"message-list-wrapper"},PS={key:0,class:"conn-banner",role:"status"},LS=["disabled"],OS={key:0,class:"day-divider",role:"separator"},DS={key:1,class:"turn-divider","aria-hidden":"true"},NS={key:2,class:"message-skeleton","aria-hidden":"true"},BS=["aria-label"],FS={key:0,class:"scroll-badge"},jS=Te({__name:"MessageList",props:{messages:{},busy:{type:Boolean,default:!1},workDir:{default:null},sessionId:{default:""},model:{default:null},contextUsage:{default:null},connected:{type:Boolean,default:!1},olderAvailable:{type:Boolean,default:!1},olderLoading:{type:Boolean,default:!1}},emits:["edit","pick","retry-connection","retry-message","load-older","fork"],setup(e,{emit:t}){const n=e,s=t,o=F(null),i=F(null);let l=null;const r=q(()=>{for(let I=n.messages.length-1;I>=0;I--)if(n.messages[I].role==="user")return n.messages[I].id;return null}),a=q(()=>{var I;return((I=n.messages.at(-1))==null?void 0:I.id)??null}),c=q(()=>{var I;return((I=[...n.messages].reverse().find(H=>H.role==="assistant"))==null?void 0:I.id)??null});function u(I){const H=n.messages[I];if(!H)return!1;if(H.role!=="assistant")return!0;const O=n.messages[I+1];return!O||O.role!=="assistant"||H.ts!==void 0&&O.ts!==void 0&&O.ts-H.ts>300*1e3}function f(I){const H=n.messages[I];return!!H&&I>0&&H.role==="user"}function h(I){const H=n.messages[I],O=I>0?n.messages[I-1]:void 0;return!H||!O||H.ts===void 0||O.ts===void 0||bb(O.ts,H.ts)?null:kb(H.ts)}const p=q(()=>{var O;const I=n.messages.at(-1);if(!I)return 0;let H=I.content.length;for(const B of I.tools)H+=((O=B.output)==null?void 0:O.length)??0;return H});let v=!1;const k=F(!1),w=F(0);function S(){const I=o.value;return I?I.scrollHeight-I.scrollTop-I.clientHeight<80:!0}function $(){return typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function E(I){requestAnimationFrame(()=>{const H=o.value;if(!H)return;const O=$()?"auto":I;H.scrollTo({top:H.scrollHeight,behavior:O})})}let L=null;function Z(){const I=o.value,H=n.sessionId;!I||!H||L===null&&(L=requestAnimationFrame(()=>{L=null;try{localStorage.setItem(`scream-scroll:${H}`,String(I.scrollTop))}catch{}}))}function j(){const I=o.value,H=n.sessionId;if(!I||!H)return;let O=null;try{O=localStorage.getItem(`scream-scroll:${H}`)}catch{}O&&(I.scrollTop=Number(O))}let C=!1;Ee(()=>{var I;return[((I=n.messages[0])==null?void 0:I.id)??null,n.messages.length]},([I,H],[O,B])=>{const te=H>0&&I!==null&&O!==null&&I!==O&&H>(B??0);if(C=te,!te)return;const oe=o.value;if(!oe)return;const _e=oe.scrollHeight;ft(()=>{const Se=oe.scrollHeight-_e;Se>0&&(oe.scrollTop+=Se)})});function x(){const I=o.value;if(!I)return;const H=I.scrollHeight-I.scrollTop-I.clientHeight>80;k.value=H,H||(w.value=0),H&&v&&(v=!1),n.busy||Z()}let y="";Ee(()=>n.sessionId,()=>{y="",w.value=0,C=!1}),Ee(()=>[n.messages.length,p.value],([I],[H])=>{if(I!==H){const O=C;if(C=!1,I>0&&y!==n.sessionId){y=n.sessionId,requestAnimationFrame(()=>requestAnimationFrame(j));return}if(O)return;if(!S()){w.value=Math.max(0,w.value+Math.max(0,I-(H??0)));return}v=!0,k.value=!1,E("smooth");return}!v&&!S()||E("auto")}),Ee(()=>n.busy,I=>{I||(v=!1)});function T(){v=!0,k.value=!1,w.value=0,E("smooth")}const D=q(()=>!n.busy||n.messages.length===0?!1:n.messages.at(-1).role==="user");return ct(()=>{var I;(I=o.value)==null||I.addEventListener("scroll",x,{passive:!0}),typeof IntersectionObserver<"u"&&(l=new IntersectionObserver(H=>{var O;(O=H[0])!=null&&O.isIntersecting&&n.olderAvailable&&!n.olderLoading&&n.messages.length>0&&s("load-older")},{root:o.value,rootMargin:"120px 0px 0px 0px"}),i.value&&l.observe(i.value)),requestAnimationFrame(()=>requestAnimationFrame(j))}),vi(()=>{var I;(I=o.value)==null||I.removeEventListener("scroll",x),l==null||l.disconnect(),l=null,L!==null&&(cancelAnimationFrame(L),L=null)}),Ee(i,I=>{l&&(l.disconnect(),I&&l.observe(I))}),(I,H)=>(g(),m("div",ES,[!e.connected&&e.messages.length>0?(g(),m("div",PS,[H[6]||(H[6]=d("span",{class:"conn-dot","aria-hidden":"true"},null,-1)),H[7]||(H[7]=d("span",null,"连接中断,自动恢复中…",-1)),d("button",{class:"conn-retry",onClick:H[0]||(H[0]=O=>s("retry-connection"))},"立即重试")])):U("",!0),d("div",{ref_key:"listRef",ref:o,class:"message-list"},[e.olderAvailable?(g(),m("div",{key:0,ref_key:"topSentinelRef",ref:i,class:"load-older-row"},[d("button",{class:"load-older-btn",disabled:e.olderLoading,onClick:H[1]||(H[1]=O=>s("load-older"))},R(e.olderLoading?"加载中…":"加载更早消息"),9,LS)],512)):U("",!0),e.messages.length===0?(g(),Xe($S,{key:1,"work-dir":e.workDir,model:e.model,"context-usage":e.contextUsage,connected:e.connected,onPick:H[2]||(H[2]=O=>s("pick",O))},null,8,["work-dir","model","context-usage","connected"])):U("",!0),(g(!0),m(ee,null,Me(e.messages,(O,B)=>(g(),m(ee,{key:O.id},[h(B)?(g(),m("div",OS,[d("span",null,R(h(B)),1)])):f(B)?(g(),m("div",DS)):U("",!0),J(lS,{message:O,"is-latest-user":O.id===r.value,idle:!e.busy,streaming:e.busy&&O.id===a.value&&O.role==="assistant","session-id":e.sessionId,"can-fork":!e.busy&&O.id===c.value,"show-timestamp":u(B),"work-dir":e.workDir??void 0,onEdit:H[3]||(H[3]=te=>s("edit",te)),onRetry:H[4]||(H[4]=te=>s("retry-message")),onFork:H[5]||(H[5]=te=>s("fork"))},null,8,["message","is-latest-user","idle","streaming","session-id","can-fork","show-timestamp","work-dir"])],64))),128)),D.value?(g(),m("div",NS,[...H[8]||(H[8]=[d("div",{class:"sk-body"},[d("div",{class:"sk-line sk-w-60"}),d("div",{class:"sk-line sk-w-90"}),d("div",{class:"sk-line sk-w-40"})],-1)])])):U("",!0)],512),J(MS,{messages:e.messages,host:o.value},null,8,["messages","host"]),J(_i,{name:"scroll-btn"},{default:Pt(()=>[k.value?(g(),m("button",{key:0,class:fe(["scroll-to-bottom",{streaming:e.busy}]),title:"滚动到最新消息","aria-label":w.value>0?`滚动到最新消息,${w.value} 条新消息`:"滚动到最新消息",onClick:T},[J(me,{name:"chevron-down",size:18}),w.value>0?(g(),m("span",FS,R(w.value>99?"99+":w.value),1)):U("",!0)],10,BS)):U("",!0)]),_:1})]))}}),US=Ie(jS,[["__scopeId","data-v-2626b931"]]),GS={class:"files-pane"},zS={class:"files-path"},HS={class:"crumbs"},WS=["onClick"],qS={key:0,class:"crumb-sep"},VS={class:"crumb-name"},KS={key:0,class:"files-error"},YS={key:1,class:"files-loading"},ZS={class:"files-list"},JS=["onClick"],XS={class:"files-name"},QS={class:"files-meta"},e$={key:0,class:"files-empty"},pc="/api/v1/files",t$=Te({__name:"FilesBrowser",props:{initialPath:{default:""}},setup(e){const t=e,n=F(""),s=F([]),o=F(!1),i=F(""),l=q(()=>{if(!n.value)return[];const f=n.value.split("/"),h=[];for(let p=0;p<f.length;p++){if(f[p]==="")continue;let v=f[p];p>1&&v==="Users"&&f[p-1]===""&&(v=v),h.push({label:v.slice(0,12),path:f.slice(0,p+1).join("/")||"/"})}return h.length>4?[{label:"…",path:"/"},...h.slice(h.length-3)]:h});async function r(f){o.value=!0,i.value="";try{const h=await fetch(`${pc}/list?path=${encodeURIComponent(f)}`);if(!h.ok)throw new Error(`HTTP ${h.status}`);const p=await h.json();n.value=p.path||await a(),s.value=p.entries,n.value||(i.value="没有可访问的目录(尚无会话)")}catch(h){i.value=h instanceof Error?h.message:String(h)}finally{o.value=!1}}async function a(){try{return(await(await fetch(`${pc}/root`)).json()).roots[0]??""}catch{return""}}async function c(f){if(f.type==="dir"){await r(f.path);return}Zn(f.path)}function u(f){return f<1024?`${f} B`:f<1024*1024?`${(f/1024).toFixed(1)} KB`:`${(f/(1024*1024)).toFixed(1)} MB`}return ct(()=>{r(t.initialPath)}),Ee(()=>t.initialPath,f=>{f&&r(f)}),(f,h)=>(g(),m("div",GS,[d("div",zS,[d("button",{class:"files-up",title:"上一级","aria-label":"上一级",onClick:h[0]||(h[0]=p=>r(n.value.split("/").slice(0,-1).join("/")||"/"))},[J(me,{name:"chevron-left",size:16})]),d("div",HS,[(g(!0),m(ee,null,Me(l.value,(p,v)=>(g(),m("span",{key:v,class:"crumb",onClick:k=>r(p.path)},[v>0?(g(),m("b",qS,"/")):U("",!0),d("span",VS,R(p.label),1)],8,WS))),128))])]),i.value?(g(),m("p",KS,R(i.value),1)):o.value?(g(),m("p",YS,"加载中…")):U("",!0),d("ul",ZS,[(g(!0),m(ee,null,Me(s.value,p=>(g(),m("li",{key:p.path},[d("button",{class:fe(["files-item",{dir:p.type==="dir"}]),onClick:v=>c(p)},[J(me,{name:p.type==="dir"?"folder":"file",size:16},null,8,["name"]),d("span",XS,R(p.name),1),d("span",QS,R(p.type==="dir"?"目录":u(p.size)),1)],10,JS)]))),128)),!o.value&&s.value.length===0?(g(),m("li",e$,"空目录")):U("",!0)])]))}}),n$=Ie(t$,[["__scopeId","data-v-5b582389"]]),s$=34;function ll(e){const t=e.split("/"),n=t.at(-1)??e;return t.length<=2?{dir:t.length===2?`${t[0]}/`:"",base:n}:e.length<=s$?{dir:`${t.slice(0,-1).join("/")}/`,base:n}:{dir:`…/${t.at(-2)}/`,base:n}}const o$={class:"panel-head-row"},i$=["aria-expanded"],l$={class:"head-icon"},r$=["title"],a$={key:1,class:"head-hint"},c$={class:"head-tail"},u$={key:0,class:"head-count"},d$={class:"panel-body"},f$={key:0,class:"git-files"},h$=["title","onClick"],p$={class:"git-file-name"},g$={key:0,class:"git-file-dir"},m$={class:"git-file-base"},v$={key:0,class:"git-file-stat"},y$={key:0,class:"add"},b$={key:1,class:"del"},k$={key:2,class:"diff-body"},w$={key:3,class:"diff-empty"},_$={key:1,class:"diff-empty"},S$=8,gc="scream-panel-git-open",$$=Te({__name:"GitPanel",props:{gitStatus:{default:null}},emits:["refresh","diff"],setup(e,{emit:t}){const n=e,s=t,o={M:"M",A:"A",D:"D",R:"R",U:"U","??":"?","?":"?"},i={D:"danger",A:"success",R:"success",U:"danger","??":"warning","?":"warning"},l=F(!1),r=F(!0);try{r.value=localStorage.getItem(gc)!=="0"}catch{}function a(){r.value=!r.value;try{localStorage.setItem(gc,r.value?"1":"0")}catch{}}function c(){s("refresh")}const u=q(()=>{var v;const p=((v=n.gitStatus)==null?void 0:v.files)??[];return l.value?p:p.slice(0,S$)}),f=q(()=>{var p,v;return Math.max(0,(((v=(p=n.gitStatus)==null?void 0:p.files)==null?void 0:v.length)??0)-u.value.length)}),h=q(()=>{var w,S;const p=((w=n.gitStatus)==null?void 0:w.ahead)??0,v=((S=n.gitStatus)==null?void 0:S.behind)??0;if(!p&&!v)return"";const k=[];return p&&k.push(`↑${p}`),v&&k.push(`↓${v}`),` · ${k.join(" ")}`});return(p,v)=>{var k;return g(),m("section",{class:fe(["panel-section","git-panel",{"is-open":r.value}])},[d("div",o$,[d("button",{class:"panel-head","aria-expanded":r.value,onClick:a},[d("span",l$,[J(me,{name:"git-branch",size:14})]),v[1]||(v[1]=d("span",{class:"head-title"},"Git 变更",-1)),e.gitStatus?(g(),m("span",{key:0,class:"head-hint",title:`${e.gitStatus.branch??"detached"}${h.value}`},R(e.gitStatus.branch??"detached")+R(h.value),9,r$)):(g(),m("span",a$,"状态不可用")),d("span",c$,[e.gitStatus?(g(),m("span",u$,R(e.gitStatus.changed),1)):U("",!0),J(me,{class:fe(["chevron",{rotated:r.value}]),name:"chevron-down",size:14},null,8,["class"])])],8,i$),d("button",{class:"icon-btn",title:"刷新","aria-label":"刷新 Git 状态",onClick:c},[J(me,{name:"refresh",size:14})])]),it(d("div",d$,[e.gitStatus?(g(),m(ee,{key:0},[u.value.length?(g(),m("ul",f$,[(g(!0),m(ee,null,Me(u.value,w=>(g(),m("li",{key:w.path},[d("button",{class:"git-file",title:`查看 ${w.displayPath??w.path} 的 diff`,onClick:S=>s("diff",{path:w.path,display:w.displayPath??w.path,adds:w.adds,dels:w.dels})},[d("span",{class:fe(["git-file-status",i[w.status]??""])},R(o[w.status]??w.status),3),d("span",p$,[W(ll)(w.displayPath??w.path).dir?(g(),m("span",g$,R(W(ll)(w.displayPath??w.path).dir),1)):U("",!0),d("span",m$,R(W(ll)(w.displayPath??w.path).base),1)]),w.adds!==void 0||w.dels!==void 0?(g(),m("span",v$,[w.adds?(g(),m("span",y$,"+"+R(w.adds),1)):U("",!0),w.dels?(g(),m("span",b$,"−"+R(w.dels),1)):U("",!0)])):U("",!0)],8,h$)]))),128))])):U("",!0),f.value?(g(),m("button",{key:1,class:"git-more",onClick:v[0]||(v[0]=w=>l.value=!l.value)},R(l.value?"收起列表":`显示全部 ${((k=e.gitStatus.files)==null?void 0:k.length)??0} 个文件`),1)):U("",!0),e.gitStatus.diffStat?(g(),m("pre",k$,R(e.gitStatus.diffStat),1)):u.value.length?U("",!0):(g(),m("div",w$,"工作区干净,没有变更。"))],64)):(g(),m("div",_$,"读取 Git 状态失败,点右上角刷新重试。"))],512),[[zu,r.value]])],2)}}}),x$=Ie($$,[["__scopeId","data-v-07e2afd4"]]),C$={class:"goal-panel panel-section"},T$={class:"section-heading"},I$={class:"head-icon"},R$=["title"],A$={key:0,class:"head-tail"},M$={class:"panel-body"},E$={key:0,class:"empty-state"},P$=["disabled"],L$={class:"refine-row"},O$=["disabled"],D$={key:0},N$=["disabled"],B$={class:"budget-grid"},F$=["disabled"],j$=["disabled"],U$={class:"time-budget"},G$=["disabled"],z$=["disabled"],H$=["disabled"],W$={key:0,class:"goal-summary"},q$={class:"objective"},V$={class:"criterion"},K$={key:0,class:"reason"},Y$={class:"goal-metrics"},Z$={class:"goal-metric"},J$={key:0,class:"bar"},X$={class:"goal-metric"},Q$={key:0,class:"bar"},ex={class:"goal-metric"},tx={key:0,class:"bar"},nx={key:1,class:"budget-warning"},sx={key:2,class:"notes"},ox={class:"panel-actions"},ix=["disabled"],lx=["disabled"],rx=["disabled"],ax=["disabled"],cx=["disabled"],ux={class:"budget-grid"},dx=["disabled"],fx=["disabled"],hx={class:"time-budget"},px=["disabled"],gx=["disabled"],mx={class:"edit-actions"},vx=["disabled"],yx=["disabled"],bx={key:3,class:"form-error"},kx={key:4,class:"pending-copy"},wx=Te({__name:"GoalPanel",props:{goal:{},sessionId:{default:null},connectionStatus:{},busy:{type:Boolean,default:!1},archived:{type:Boolean,default:!1},pending:{type:Boolean,default:!1},error:{default:null},refineGoal:{},createGoal:{},updateGoal:{},pauseGoal:{},resumeGoal:{},cancelGoal:{}},setup(e){const t=e,n=F(""),s=F(""),o=F(""),i=F(""),l=F(""),r=F("minutes"),a=F(!1),c=F(null),u=F(!1),f=q(()=>t.connectionStatus==="connected"),h=q(()=>!t.sessionId||!f.value||t.archived||t.pending),p=q(()=>h.value),v=q(()=>{var O;return{active:"进行中",paused:"已暂停",blocked:"受阻",complete:"已完成"}[((O=t.goal)==null?void 0:O.status)??"active"]}),k=q(()=>t.sessionId?t.archived?"归档会话为只读状态":f.value?t.pending?"正在提交请求…":t.goal?"状态由核心事件实时同步":"创建后 Agent 将自动开始执行":"连接恢复后可继续管理":"选择或新建会话后即可配置");Ee(()=>t.sessionId,()=>{a.value=!1,w()}),Ee(()=>{var O;return(O=t.goal)==null?void 0:O.goalId},(O,B)=>{a.value=!1,O!==B&&w()});function w(){n.value="",s.value="",o.value="",i.value="",l.value="",r.value="minutes",u.value=!1,c.value=null}function S(O,B){const te=O.trim();if(!te)return null;const oe=Number(te);if(!Number.isSafeInteger(oe)||oe<=0){c.value=`${B}必须是正整数。`;return}return oe}function $(){c.value=null;const O=S(o.value,"轮次预算");if(O===void 0)return null;const B=S(i.value,"Token 预算");if(B===void 0)return null;const te=S(l.value,"时间预算");if(te===void 0)return null;const oe=[];return O!==null&&oe.push({value:O,unit:"turns"}),B!==null&&oe.push({value:B,unit:"tokens"}),te!==null&&oe.push({value:te,unit:r.value}),oe}async function E(){const O=n.value.trim();if(!O){c.value="请先输入需要优化的目标描述。";return}c.value=null,u.value=!1;const B=await t.refineGoal(O);B!==null&&(n.value=B,u.value=!0)}async function L(){const O=n.value.trim();if(!O){c.value="目标内容不能为空。";return}const B=$();if(B===null)return;await t.createGoal({objective:O,completionCriterion:s.value.trim()||void 0,replace:!1,budgets:B})&&(u.value=!1)}function Z(O){O===null?(l.value="",r.value="minutes"):O%36e5===0?(l.value=String(O/36e5),r.value="hours"):O%6e4===0?(l.value=String(O/6e4),r.value="minutes"):O%1e3===0?(l.value=String(O/1e3),r.value="seconds"):(l.value=String(O),r.value="milliseconds")}function j(){const O=t.goal;O&&(n.value=O.objective,o.value=O.budget.turnBudget===null?"":String(O.budget.turnBudget),i.value=O.budget.tokenBudget===null?"":String(O.budget.tokenBudget),Z(O.budget.wallClockBudgetMs),c.value=null,a.value=!0)}function C(O,B){return B==="hours"?O*36e5:B==="minutes"?O*6e4:B==="seconds"?O*1e3:O}async function x(){const O=t.goal;if(!O)return;const B=n.value.trim();if(!B){c.value="目标内容不能为空。";return}const te=$();if(te===null)return;const oe=S(o.value,"轮次预算"),_e=S(i.value,"Token 预算"),Se=S(l.value,"时间预算");if(oe===void 0||_e===void 0||Se===void 0)return;if(O.budget.turnBudget!==null&&oe===null){c.value="当前协议不支持清除已有轮次预算,请填写新的正整数。";return}if(O.budget.tokenBudget!==null&&_e===null){c.value="当前协议不支持清除已有 Token 预算,请填写新的正整数。";return}if(O.budget.wallClockBudgetMs!==null&&Se===null){c.value="当前协议不支持清除已有时间预算,请填写新的正整数。";return}const je=te.filter(he=>he.unit==="turns"?he.value!==O.budget.turnBudget:he.unit==="tokens"?he.value!==O.budget.tokenBudget:C(he.value,he.unit)!==O.budget.wallClockBudgetMs),Qe=B===O.objective?void 0:B;if(Qe===void 0&&je.length===0){c.value="目标与预算没有变化。";return}await t.updateGoal({objective:Qe,budgets:je})&&(a.value=!1)}async function y(O){c.value=null,!(O==="cancel"&&!window.confirm("确定取消当前 Goal?当前 Goal 状态将被清除。"))&&(O==="pause"?await t.pauseGoal():O==="resume"?await t.resumeGoal():await t.cancelGoal())}function T(O){return O.toLocaleString("zh-CN")}function D(O){if(O<1e3)return`${O} 毫秒`;const B=Math.floor(O/1e3);if(B<60)return`${B} 秒`;const te=Math.floor(B/3600),oe=Math.floor(B%3600/60);return te>0?`${te} 小时 ${oe} 分钟`:`${oe} 分钟`}function I(O,B){return B===null||B<=0?0:Math.min(100,Math.round(O/B*100))}function H(O){return new Date(O).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}return(O,B)=>(g(),m("section",C$,[d("div",T$,[d("span",I$,[J(me,{name:"target",size:14})]),B[15]||(B[15]=d("span",{class:"head-title"},"Goal 管理",-1)),d("span",{class:"head-hint",title:k.value},R(k.value),9,R$),e.goal?(g(),m("span",A$,[d("span",{class:fe(["status-pill",`is-${e.goal.status}`])},R(v.value),3)])):U("",!0)]),d("div",M$,[e.sessionId?e.goal?(g(),m(ee,{key:2},[a.value?(g(),m("form",{key:1,class:"goal-form edit-form",onSubmit:rt(x,["prevent"])},[d("label",null,[B[31]||(B[31]=d("span",null,"目标内容",-1)),it(d("textarea",{"onUpdate:modelValue":B[9]||(B[9]=te=>n.value=te),rows:"3",maxlength:"4000",disabled:h.value||e.busy},null,8,cx),[[ut,n.value]])]),B[36]||(B[36]=d("div",{class:"budget-title"},[Ce("更新预算 "),d("small",null,"仅提交发生变化的预算")],-1)),d("div",ux,[d("label",null,[B[32]||(B[32]=d("span",null,"轮次",-1)),it(d("input",{"onUpdate:modelValue":B[10]||(B[10]=te=>o.value=te),type:"number",min:"1",step:"1",placeholder:"不限",disabled:h.value||e.busy},null,8,dx),[[ut,o.value]])]),d("label",null,[B[33]||(B[33]=d("span",null,"Token",-1)),it(d("input",{"onUpdate:modelValue":B[11]||(B[11]=te=>i.value=te),type:"number",min:"1",step:"1",placeholder:"不限",disabled:h.value||e.busy},null,8,fx),[[ut,i.value]])])]),d("div",hx,[d("label",null,[B[34]||(B[34]=d("span",null,"时间",-1)),it(d("input",{"onUpdate:modelValue":B[12]||(B[12]=te=>l.value=te),type:"number",min:"1",step:"1",placeholder:"不限",disabled:h.value||e.busy},null,8,px),[[ut,l.value]])]),it(d("select",{"onUpdate:modelValue":B[13]||(B[13]=te=>r.value=te),"aria-label":"时间预算单位",disabled:h.value||e.busy},[...B[35]||(B[35]=[d("option",{value:"minutes"},"分钟",-1),d("option",{value:"hours"},"小时",-1),d("option",{value:"seconds"},"秒",-1),d("option",{value:"milliseconds"},"毫秒",-1)])],8,gx),[[Ca,r.value]])]),d("div",mx,[d("button",{type:"button",class:"secondary",disabled:e.pending,onClick:B[14]||(B[14]=te=>a.value=!1)},"返回",8,vx),d("button",{class:"primary small",type:"submit",disabled:h.value||e.busy},"保存修改",8,yx)])],32)):(g(),m("div",W$,[d("div",q$,[B[24]||(B[24]=d("small",null,"目标",-1)),d("p",null,R(e.goal.objective),1)]),d("div",V$,[B[25]||(B[25]=d("small",null,"完成标准",-1)),d("p",null,R(e.goal.completionCriterion??"未设置,由 Agent 根据目标判断完成。"),1)]),e.goal.terminalReason?(g(),m("div",K$,[B[26]||(B[26]=d("strong",null,"状态原因",-1)),d("span",null,R(e.goal.terminalReason),1)])):U("",!0),d("dl",Y$,[d("div",Z$,[B[27]||(B[27]=d("dt",null,"轮次",-1)),d("dd",null,R(e.goal.turnsUsed)+" / "+R(e.goal.budget.turnBudget??"不限"),1),e.goal.budget.turnBudget!==null?(g(),m("i",J$,[d("i",{style:Nt({width:`${I(e.goal.turnsUsed,e.goal.budget.turnBudget)}%`})},null,4)])):U("",!0)]),d("div",X$,[B[28]||(B[28]=d("dt",null,"Token",-1)),d("dd",null,R(T(e.goal.tokensUsed))+" / "+R(e.goal.budget.tokenBudget===null?"不限":T(e.goal.budget.tokenBudget)),1),e.goal.budget.tokenBudget!==null?(g(),m("i",Q$,[d("i",{style:Nt({width:`${I(e.goal.tokensUsed,e.goal.budget.tokenBudget)}%`})},null,4)])):U("",!0)]),d("div",ex,[B[29]||(B[29]=d("dt",null,"时间",-1)),d("dd",null,R(D(e.goal.wallClockMs))+" / "+R(e.goal.budget.wallClockBudgetMs===null?"不限":D(e.goal.budget.wallClockBudgetMs)),1),e.goal.budget.wallClockBudgetMs!==null?(g(),m("i",tx,[d("i",{style:Nt({width:`${I(e.goal.wallClockMs,e.goal.budget.wallClockBudgetMs)}%`})},null,4)])):U("",!0)])]),e.goal.budget.overBudget?(g(),m("div",nx,"已达到或超过执行预算。")):U("",!0),e.goal.notes.length?(g(),m("details",sx,[d("summary",null,"工作记录("+R(e.goal.notes.length)+")",1),d("ol",null,[(g(!0),m(ee,null,Me(e.goal.notes,te=>(g(),m("li",{key:`${te.time}-${te.content}`},[d("time",null,R(H(te.time)),1),d("span",null,R(te.content),1)]))),128))])])):U("",!0),d("div",ox,[e.goal.status!=="complete"?(g(),m("button",{key:0,class:"secondary",disabled:h.value||e.busy,onClick:j},[J(me,{name:"edit",size:14}),B[30]||(B[30]=Ce("编辑",-1))],8,ix)):U("",!0),e.goal.status==="active"?(g(),m("button",{key:1,class:"secondary",disabled:h.value,onClick:B[6]||(B[6]=te=>y("pause"))},"暂停",8,lx)):U("",!0),e.goal.status==="paused"||e.goal.status==="blocked"?(g(),m("button",{key:2,class:"primary small",disabled:h.value||e.busy,onClick:B[7]||(B[7]=te=>y("resume"))},"继续",8,rx)):U("",!0),d("button",{class:"danger",disabled:h.value,onClick:B[8]||(B[8]=te=>y("cancel"))},"取消 Goal",8,ax)])]))],64)):(g(),m("form",{key:1,class:"goal-form",onSubmit:rt(L,["prevent"])},[d("label",null,[B[16]||(B[16]=d("span",null,"目标内容",-1)),it(d("textarea",{"onUpdate:modelValue":B[0]||(B[0]=te=>n.value=te),rows:"3",maxlength:"4000",placeholder:"描述希望 Agent 持续完成的目标",disabled:p.value},null,8,P$),[[ut,n.value]])]),d("div",L$,[d("button",{type:"button",class:"secondary",disabled:p.value||!n.value.trim(),onClick:E},[J(me,{name:"sparkles",size:15}),B[17]||(B[17]=Ce(" AI 优化 ",-1))],8,O$),u.value?(g(),m("small",D$,"已优化,请确认或继续编辑后再创建。")):U("",!0)]),d("label",null,[B[18]||(B[18]=d("span",null,[Ce("完成标准 "),d("small",null,"可选")],-1)),it(d("textarea",{"onUpdate:modelValue":B[1]||(B[1]=te=>s.value=te),rows:"2",placeholder:"例如:聚焦测试、类型检查与 Web 构建全部通过",disabled:p.value},null,8,N$),[[ut,s.value]])]),B[23]||(B[23]=d("div",{class:"budget-title"},[Ce("执行预算 "),d("small",null,"留空表示不限制")],-1)),d("div",B$,[d("label",null,[B[19]||(B[19]=d("span",null,"轮次",-1)),it(d("input",{"onUpdate:modelValue":B[2]||(B[2]=te=>o.value=te),type:"number",min:"1",step:"1",placeholder:"不限",disabled:p.value},null,8,F$),[[ut,o.value]])]),d("label",null,[B[20]||(B[20]=d("span",null,"Token",-1)),it(d("input",{"onUpdate:modelValue":B[3]||(B[3]=te=>i.value=te),type:"number",min:"1",step:"1",placeholder:"不限",disabled:p.value},null,8,j$),[[ut,i.value]])])]),d("div",U$,[d("label",null,[B[21]||(B[21]=d("span",null,"时间",-1)),it(d("input",{"onUpdate:modelValue":B[4]||(B[4]=te=>l.value=te),type:"number",min:"1",step:"1",placeholder:"不限",disabled:p.value},null,8,G$),[[ut,l.value]])]),it(d("select",{"onUpdate:modelValue":B[5]||(B[5]=te=>r.value=te),"aria-label":"时间预算单位",disabled:p.value},[...B[22]||(B[22]=[d("option",{value:"minutes"},"分钟",-1),d("option",{value:"hours"},"小时",-1),d("option",{value:"seconds"},"秒",-1),d("option",{value:"milliseconds"},"毫秒",-1)])],8,z$),[[Ca,r.value]])]),d("button",{class:"primary",type:"submit",disabled:p.value||!n.value.trim()},R(e.pending?"正在创建…":"创建并开始执行"),9,H$)],32)):(g(),m("div",E$,"暂无会话,Goal 管理暂不可用。")),c.value||e.error?(g(),m("p",bx,R(c.value??e.error),1)):e.pending?(g(),m("p",kx,"请求处理中,状态将在核心事件到达后同步。")):U("",!0)])]))}}),_x=Ie(wx,[["__scopeId","data-v-2e8dbdc6"]]),Sx={class:"panel-section like-section"},$x={class:"section-heading"},xx={class:"head-icon"},Cx={class:"panel-body"},Tx={class:"kv-rows"},Ix={class:"dialog"},Rx=["onUpdate:modelValue","placeholder"],Ax={key:0,class:"dialog-error"},Mx={class:"dialog-actions"},Ex=["disabled"],Px=Te({__name:"LikePanel",props:{like:{},updateLike:{type:Function}},setup(e){const t=e,n=F(!1),s=F(!1),o=F(""),i=F({}),l=[{key:"nickname",label:"昵称",placeholder:"用户称呼,如:老板"},{key:"tone",label:"语气",placeholder:"AI 风格,如:专业不拖沓"},{key:"other",label:"偏好",placeholder:"其他用户偏好"},{key:"doNot",label:"禁止",placeholder:"用户明确不让做的事"}];function r(){i.value={...t.like},o.value="",n.value=!0}async function a(){s.value=!0,o.value="";const c=await t.updateLike(i.value);s.value=!1,c?n.value=!1:o.value="保存失败"}return(c,u)=>(g(),m("section",Sx,[d("div",$x,[d("span",xx,[J(me,{name:"settings",size:14})]),u[2]||(u[2]=d("span",{class:"head-title"},"偏好设置",-1)),u[3]||(u[3]=d("span",{class:"head-hint"},"/like 用户偏好",-1))]),d("div",Cx,[d("dl",Tx,[(g(),m(ee,null,Me(l,f=>d("div",{key:f.key,class:"kv-row"},[d("dt",null,R(f.label),1),d("dd",null,R((e.like[f.key]??"").trim()||"未设置"),1)])),64))]),d("div",{class:"panel-actions"},[d("button",{class:"like-edit",onClick:r},"编辑偏好")])]),n.value?(g(),m("div",{key:0,class:"dialog-overlay",onClick:u[1]||(u[1]=rt(f=>n.value=!1,["self"]))},[d("div",Ix,[u[4]||(u[4]=d("div",{class:"dialog-title"},"编辑用户偏好",-1)),(g(),m(ee,null,Me(l,f=>d("label",{key:f.key,class:"dialog-field"},[d("span",null,R(f.label),1),it(d("input",{"onUpdate:modelValue":h=>i.value[f.key]=h,placeholder:f.placeholder},null,8,Rx),[[ut,i.value[f.key]]])])),64)),o.value?(g(),m("div",Ax,R(o.value),1)):U("",!0),d("div",Mx,[d("button",{onClick:u[0]||(u[0]=f=>n.value=!1)},"取消"),d("button",{disabled:s.value,onClick:a},R(s.value?"保存中…":"确认"),9,Ex)])])])):U("",!0)]))}}),Lx=Ie(Px,[["__scopeId","data-v-a7906d58"]]),Ox=["aria-expanded"],Dx={class:"head-icon"},Nx={class:"head-hint"},Bx={class:"head-tail"},Fx=["title"],jx={class:"panel-body"},Ux={class:"stat-grid"},Gx={class:"stat"},zx={class:"stat"},Hx=["title"],Wx={key:1,class:"faint"},qx={class:"stat wide"},Vx={class:"mono"},mc="scream-panel-runstatus-open",Kx=Te({__name:"RunStatusPanel",props:{status:{},busy:{type:Boolean,default:!1},connectionStatus:{}},setup(e){const t=e,n=F(!0);try{n.value=localStorage.getItem(mc)!=="0"}catch{}function s(){n.value=!n.value;try{localStorage.setItem(mc,n.value?"1":"0")}catch{}}const o=q(()=>{const r=t.status.contextUsage;return r===void 0?null:Math.round((r>1?r/100:r)*100)}),i=q(()=>{var r,a;return`Tokens: ${((r=t.status.contextTokens)==null?void 0:r.toLocaleString())??"-"} / ${((a=t.status.maxContextTokens)==null?void 0:a.toLocaleString())??"-"}`}),l=q(()=>({connected:"已连接",connecting:"连接中",reconnecting:"重连中",disconnected:"已断开",idle:"空闲"})[t.connectionStatus]??"空闲");return Ee(()=>t.busy,()=>{t.busy&&!n.value&&(n.value=!0)}),(r,a)=>{var c,u;return g(),m("section",{class:fe(["panel-section","run-status",{"is-open":n.value}])},[d("button",{class:"panel-head","aria-expanded":n.value,onClick:s},[d("span",Dx,[J(me,{name:"activity",size:14})]),a[0]||(a[0]=d("span",{class:"head-title"},"运行状态",-1)),d("span",Nx,R(e.busy?"正在处理会话":"已就绪,等待任务"),1),d("span",Bx,[d("span",{class:fe(["head-dot",{busy:e.busy}]),title:e.busy?"Agent 正在处理":"空闲"},null,10,Fx),J(me,{class:fe(["chevron",{rotated:n.value}]),name:"chevron-down",size:14},null,8,["class"])])],8,Ox),it(d("div",jx,[d("dl",Ux,[d("div",Gx,[a[1]||(a[1]=d("dt",null,"连接",-1)),d("dd",null,[d("span",{class:fe(["conn-dot",e.connectionStatus]),"aria-hidden":"true"},null,2),d("span",{class:fe(["conn",e.connectionStatus])},R(l.value),3)])]),d("div",zx,[a[2]||(a[2]=d("dt",null,"上下文占用",-1)),o.value!==null?(g(),m("dd",{key:0,title:i.value},[J(sd,{usage:e.status.contextUsage,size:14},null,8,["usage"]),Ce(R(o.value)+"% ",1)],8,Hx)):(g(),m("dd",Wx,"未知"))]),d("div",qx,[a[3]||(a[3]=d("dt",null,"Token(输入 / 上限)",-1)),d("dd",Vx,R(((c=e.status.contextTokens)==null?void 0:c.toLocaleString())??"-")+" / "+R(((u=e.status.maxContextTokens)==null?void 0:u.toLocaleString())??"-"),1)])])],512),[[zu,n.value]])],2)}}}),Yx=Ie(Kx,[["__scopeId","data-v-59b0c4e7"]]),Zx={class:"todo-panel panel-section"},Jx={class:"section-heading"},Xx={class:"head-icon"},Qx={class:"head-hint"},eC={class:"head-tail"},tC={class:"head-count"},nC={key:0,class:"panel-body"},sC={class:"empty-state"},oC={key:1,class:"panel-body"},iC={class:"progress-row"},lC={class:"bar","aria-hidden":"true"},rC={class:"progress-value"},aC=["title"],cC={class:"todo-title"},uC=Te({__name:"TodoPanel",props:{todos:{}},setup(e){const t=e,n=q(()=>Xg(t.todos)),s=q(()=>t.todos.filter(c=>c.status==="done").length),o=q(()=>t.todos.filter(c=>c.status==="in_progress").length),i=q(()=>t.todos.filter(c=>c.status==="pending").length),l=q(()=>t.todos.length?Math.round(s.value/t.todos.length*100):0),r=q(()=>{if(!t.todos.length)return"直接来自 Agent 核心状态";if(s.value===t.todos.length)return"全部完成";const c=[];return o.value&&c.push(`进行中 ${o.value}`),i.value&&c.push(`待处理 ${i.value}`),c.join(" · ")||"直接来自 Agent 核心状态"}),a={pending:{label:"待处理",symbol:"○"},in_progress:{label:"进行中",symbol:"●"},done:{label:"已完成",symbol:"✓"}};return(c,u)=>(g(),m("section",Zx,[d("div",Jx,[d("span",Xx,[J(me,{name:"clipboard",size:14})]),u[0]||(u[0]=d("span",{class:"head-title"},"核心 Todo",-1)),d("span",Qx,R(r.value),1),d("span",eC,[d("span",tC,R(s.value)+"/"+R(e.todos.length),1)])]),e.todos.length===0?(g(),m("div",nC,[d("div",sC,[J(me,{name:"check",size:18}),u[1]||(u[1]=d("span",null,"暂无 Todo",-1)),u[2]||(u[2]=d("small",null,"Agent 创建任务清单后会在这里实时显示。",-1))])])):(g(),m("div",oC,[d("div",iC,[d("i",lC,[d("i",{style:Nt({width:`${l.value}%`})},null,4)]),d("span",rC,R(l.value)+"%",1)]),(g(!0),m(ee,null,Me(n.value,(f,h)=>(g(),m("section",{key:f.phase??`unphased-${h}`,class:"todo-group"},[d("h4",null,R(f.phase??"未分阶段"),1),d("ol",null,[(g(!0),m(ee,null,Me(f.items,(p,v)=>(g(),m("li",{key:`${h}-${v}-${p.title}`,class:fe(`is-${p.status}`)},[d("span",{class:"status-symbol",title:a[p.status].label},R(a[p.status].symbol),9,aC),d("span",cC,R(p.title),1),d("small",null,R(a[p.status].label),1)],2))),128))])]))),128))]))]))}}),dC=Ie(uC,[["__scopeId","data-v-6a025f22"]]),fC={class:"drawer"},hC={class:"drawer-toolbar"},pC={class:"drawer-tabs",role:"tablist","aria-label":"抽屉面板"},gC=["aria-selected"],mC=["aria-selected"],vC={class:"drawer-body"},yC={class:"git-diff-head"},bC=["title"],kC={class:"git-diff-tools"},wC={key:0,class:"git-diff-stat"},_C={key:0,class:"add"},SC={key:1,class:"del"},$C={key:0,class:"git-diff-body"},xC={key:1,class:"git-diff-empty"},CC=Te({__name:"SessionDrawer",props:{client:{}},emits:["refresh-git","close","insert"],setup(e){const t=e,n=F("detail"),s=F(null),o=F(null);async function i(C){var y,T,D;s.value={...C,lines:[],loading:!0};try{const H=await(await fetch(`/api/v1/git/diff?path=${encodeURIComponent(C.path)}`)).json(),O=sf(H.patch??""),B=C.adds??(C.dels===void 0?O.filter(te=>te.type==="add").length:void 0);s.value={...C,adds:B,lines:O,loading:!1}}catch{s.value={...C,lines:[],loading:!1}}await ft();const x=((T=(y=globalThis.window)==null?void 0:y.matchMedia)==null?void 0:T.call(y,"(prefers-reduced-motion: reduce)").matches)===!0;(D=o.value)==null||D.scrollIntoView({block:"start",behavior:x?"auto":"smooth"})}const{connectionStatus:l,status:r,sessionId:a,isBusy:c,isArchived:u,goal:f,todos:h,goalRequestPending:p,goalRequestError:v,like:k,gitStatus:w,refineGoal:S,createGoal:$,updateGoal:E,pauseGoal:L,resumeGoal:Z,cancelGoal:j}=t.client;return(C,x)=>{const y=wp("SvgIcon");return g(),m("aside",fC,[d("div",hC,[d("div",pC,[d("button",{role:"tab","aria-selected":n.value==="detail",class:fe(["drawer-tab",{active:n.value==="detail"}]),onClick:x[0]||(x[0]=T=>n.value="detail")}," 详情 ",10,gC),d("button",{role:"tab","aria-selected":n.value==="files",class:fe(["drawer-tab",{active:n.value==="files"}]),onClick:x[1]||(x[1]=T=>n.value="files")}," 文件 ",10,mC)]),d("button",{class:"drawer-close",title:"收起面板","aria-label":"收起详情",onClick:x[2]||(x[2]=T=>C.$emit("close"))},[J(y,{name:"panel-right",size:16})])]),d("div",vC,[n.value==="detail"?(g(),m(ee,{key:0},[J(Yx,{status:W(r),busy:W(c),"connection-status":W(l)},null,8,["status","busy","connection-status"]),J(x$,{"git-status":W(w),onRefresh:x[3]||(x[3]=T=>C.$emit("refresh-git")),onDiff:i},null,8,["git-status"]),s.value?(g(),m("div",{key:0,ref_key:"diffRef",ref:o,class:"git-diff-view"},[d("div",yC,[d("span",{class:"git-diff-title",title:s.value.path},R(s.value.loading?"加载中…":s.value.display),9,bC),d("span",kC,[!s.value.loading&&(s.value.adds||s.value.dels)?(g(),m("span",wC,[s.value.adds?(g(),m("span",_C,"+"+R(s.value.adds),1)):U("",!0),s.value.dels?(g(),m("span",SC,"−"+R(s.value.dels),1)):U("",!0)])):U("",!0),d("button",{class:"git-diff-close",title:"关闭 diff","aria-label":"关闭 diff",onClick:x[4]||(x[4]=T=>s.value=null)},"✕")])]),s.value.lines.length?(g(),m("div",$C,[J(Mr,{lines:s.value.lines},null,8,["lines"])])):s.value.loading?U("",!0):(g(),m("p",xC,"该文件无差异内容(可能是二进制文件或已被忽略)。"))],512)):U("",!0),J(dC,{todos:W(h)},null,8,["todos"]),J(Lx,{like:W(k),"update-like":t.client.updateLike},null,8,["like","update-like"]),J(_x,{goal:W(f),"session-id":W(a),"connection-status":W(l),busy:W(c),archived:W(u),pending:W(p),error:W(v),"refine-goal":W(S),"create-goal":W($),"update-goal":W(E),"pause-goal":W(L),"resume-goal":W(Z),"cancel-goal":W(j)},null,8,["goal","session-id","connection-status","busy","archived","pending","error","refine-goal","create-goal","update-goal","pause-goal","resume-goal","cancel-goal"])],64)):(g(),Xe(n$,{key:t.client.workDir.value||"none","initial-path":t.client.workDir.value||""},null,8,["initial-path"]))])])}}}),TC=Ie(CC,[["__scopeId","data-v-2d1f803d"]]),IC={class:"stats-head"},RC={class:"stats-body"},AC={class:"stats-section"},MC={class:"stats-label-row"},EC={class:"stats-value mono"},PC=["aria-valuenow","aria-label"],LC={key:0,class:"stats-section"},OC={class:"stats-label-row"},DC={class:"stats-value mono"},NC={class:"stats-section"},BC={class:"stats-label-row"},FC={class:"stats-value mono"},jC={class:"stats-grid"},UC={class:"stats-cell-label"},GC={class:"stats-cell-value mono"},zC={key:1,class:"stats-section"},HC=["title"],WC={class:"model-tokens mono"},qC={class:"model-dims mono"},VC={key:1,class:"stats-empty"},KC=Te({__name:"SessionStatsPanel",props:{status:{},fetchUsage:{type:Function},fetchContext:{type:Function}},emits:["close"],setup(e,{emit:t}){const n=e,s=t,o=F(null);ct(()=>{n.fetchUsage(),n.fetchContext()});function i($){const E=o.value;E&&!E.contains($.target)&&s("close")}function l($){$.key==="Escape"&&s("close")}ct(()=>{document.addEventListener("pointerdown",i),window.addEventListener("keydown",l)}),Ct(()=>{document.removeEventListener("pointerdown",i),window.removeEventListener("keydown",l)});function r($){return $?$.inputOther+$.output+$.inputCacheRead+$.inputCacheCreation:0}function a($){return typeof $!="number"?"-":$>=1e6?`${($/1e6).toFixed(1)}M`:$>=1e3?`${($/1e3).toFixed(1)}k`:String($)}function c($){return typeof $=="number"?$.toLocaleString():"-"}const u=q(()=>{const $=n.status.contextUsage;if(typeof $=="number"&&Number.isFinite($)){const Z=$>1?$:$*100;return Math.max(0,Math.min(Z,100))}const E=n.status.contextTokens??0,L=n.status.maxContextTokens??0;return L<=0?0:Math.max(0,Math.min(E/L*100,100))}),f=q(()=>typeof n.status.contextTokens=="number"&&typeof n.status.maxContextTokens=="number"?`${c(n.status.contextTokens)} / ${c(n.status.maxContextTokens)}`:u.value>0?`${u.value.toFixed(1)}%`:"-"),h=q(()=>{var $;return($=n.status.usage)==null?void 0:$.total}),p=q(()=>{var $;return($=n.status.usage)==null?void 0:$.currentTurn}),v=q(()=>r(h.value)),k=q(()=>{var E;const $=(E=n.status.usage)==null?void 0:E.byModel;return $?Object.entries($).map(([L,Z])=>({model:L,tokens:r(Z),input:Z.inputOther,output:Z.output,cacheRead:Z.inputCacheRead,cacheCreation:Z.inputCacheCreation})):[]}),w=q(()=>v.value>0||k.value.length>0||r(p.value)>0),S=q(()=>{var $,E,L,Z;return[{key:"input",label:"输入",value:($=h.value)==null?void 0:$.inputOther},{key:"output",label:"输出",value:(E=h.value)==null?void 0:E.output},{key:"cacheRead",label:"缓存读",value:(L=h.value)==null?void 0:L.inputCacheRead},{key:"cacheCreation",label:"缓存写",value:(Z=h.value)==null?void 0:Z.inputCacheCreation}]});return($,E)=>(g(),m("div",{ref_key:"rootRef",ref:o,class:"stats-panel",role:"dialog","aria-label":"会话统计"},[d("div",IC,[E[1]||(E[1]=d("span",{class:"stats-title"},"会话统计",-1)),d("button",{class:"stats-close","aria-label":"关闭统计面板",onClick:E[0]||(E[0]=L=>s("close"))},[J(me,{name:"x",size:14})])]),d("div",RC,[d("div",AC,[d("div",MC,[E[2]||(E[2]=d("span",{class:"stats-label"},"上下文水位",-1)),d("span",EC,R(f.value),1)]),d("div",{class:"ctx-track",role:"progressbar","aria-valuenow":Math.round(u.value),"aria-valuemin":"0","aria-valuemax":"100","aria-label":`上下文 ${u.value.toFixed(1)}%`},[d("div",{class:"ctx-fill",style:Nt({width:`${u.value}%`})},null,4)],8,PC)]),w.value?(g(),m(ee,{key:0},[r(p.value)>0?(g(),m("div",LC,[d("div",OC,[E[3]||(E[3]=d("span",{class:"stats-label"},"当前回合",-1)),d("span",DC,R(a(r(p.value)))+" tokens",1)])])):U("",!0),d("div",NC,[d("div",BC,[E[4]||(E[4]=d("span",{class:"stats-label"},"本会话累计",-1)),d("span",FC,R(a(v.value))+" tokens",1)]),d("div",jC,[(g(!0),m(ee,null,Me(S.value,L=>(g(),m("div",{key:L.key,class:"stats-cell"},[d("span",UC,R(L.label),1),d("span",GC,R(c(L.value)),1)]))),128))])]),k.value.length>0?(g(),m("div",zC,[E[5]||(E[5]=d("div",{class:"stats-label"},"按模型",-1)),(g(!0),m(ee,null,Me(k.value,L=>(g(),m("div",{key:L.model,class:"model-row"},[d("span",{class:"model-name",title:L.model},R(L.model),9,HC),d("span",WC,R(c(L.tokens)),1),d("span",qC," 入 "+R(c(L.input))+" · 出 "+R(c(L.output))+" · 缓存 "+R(c(L.cacheRead+L.cacheCreation)),1)]))),128))])):U("",!0)],64)):(g(),m("div",VC,"暂无用量数据"))])],512))}}),YC=Ie(KC,[["__scopeId","data-v-d7ef23ee"]]),ZC={class:"conversation"},JC={key:0,class:"stats-anchor"},XC={class:"chat-stage"},QC={class:"chat-column"},eT={class:"composer-dock"},tT=Te({__name:"ConversationView",props:{client:{}},emits:["home"],setup(e,{emit:t}){const n=e,s=t,{connectionStatus:o,messages:i,pendingApprovals:l,status:r,sessionId:a,workDir:c,isBusy:u,models:f,sendPrompt:h,sendCommand:p,clearMessages:v,appendSystemMessage:k,abort:w,resolveApproval:S,exportSession:$,fetchSnapshot:E,switchModel:L,switchThinking:Z}=n.client,j=F(null),C=F(!1),x=F(!1),y=F(!1),T=F("status"),D=q(()=>{var Fe;const ge=(Fe=r.value.usage)==null?void 0:Fe.currentTurn;if(!ge)return null;const he=ge.inputOther+ge.output+ge.inputCacheRead+ge.inputCacheCreation;return he>0?he:null}),I=q(()=>{const ge=n.client.sessions.value.find(K=>K.sessionId===n.client.currentSessionId.value),he=ge==null?void 0:ge.title;if(he&&he!=="新会话"&&he!=="New Session")return he;const Fe=i.value.find(K=>K.role==="user");if(Fe){const K=Fe.content.replace(/\s+/g," ").trim();if(K)return K.length>24?`${K.slice(0,24)}…`:K}return he??null});function H(ge){var he;(he=j.value)==null||he.insertText(ge)}function O(ge){E(),T.value=ge,y.value=!0}function B(){var he;(((he=j.value)==null?void 0:he.openModelPicker())??!1)||k(`当前模型:${r.value.model??"unknown"}`)}function te(ge,he){switch(ge){case"compact":p("compact");break;case"model":B();break;case"clear":v();break;case"new":s("home");break;case"help":k(Yu());break;case"auto":case"yes":case"plan":case"fork":case"title":case"btw":p(ge,he);break;case"status":O("status");break;case"usage":O("usage");break;default:k(`未知命令:/${ge}`)}}function oe(ge){p("title",ge)}function _e(){if(u.value||!o.value)return;const ge=[...i.value].reverse().find(he=>he.role==="user");ge&&h(ge.content)}const Se=F(!1);async function je(){Se.value=!0,await n.client.loadOlderMessages(),Se.value=!1}function Qe(){u.value||(p("fork"),setTimeout(()=>{n.client.fetchSessions()},1200))}return(ge,he)=>(g(),m("div",ZC,[J(Oy,{title:I.value,busy:W(u),"drawer-open":C.value,"stats-open":x.value,"turn-tokens":D.value,onHome:he[0]||(he[0]=Fe=>s("home")),onRename:oe,onExport:he[1]||(he[1]=Fe=>W(a)&&W($)(W(a))),onClear:W(v),onToggleDrawer:he[2]||(he[2]=Fe=>C.value=!C.value),onToggleStats:he[3]||(he[3]=Fe=>x.value=!x.value)},null,8,["title","busy","drawer-open","stats-open","turn-tokens","onClear"]),x.value?(g(),m("div",JC,[J(YC,{status:W(r),"fetch-usage":n.client.fetchSessionUsage,"fetch-context":n.client.fetchSessionContext,onClose:he[4]||(he[4]=Fe=>x.value=!1)},null,8,["status","fetch-usage","fetch-context"])])):U("",!0),d("div",XC,[d("div",QC,[J(US,{messages:W(i),busy:W(u),"work-dir":W(c),"session-id":W(a)??"",model:W(r).model??null,"context-usage":W(r).contextUsage??null,connected:W(o)==="connected","older-available":n.client.olderAvailable.value,"older-loading":Se.value,onEdit:H,onPick:W(h),onRetryConnection:he[5]||(he[5]=Fe=>n.client.reconnectNow()),onRetryMessage:_e,onLoadOlder:je,onFork:Qe},null,8,["messages","busy","work-dir","session-id","model","context-usage","connected","older-available","older-loading","onPick"]),d("div",eT,[J(Pm,{approvals:W(l),onResolve:W(S)},null,8,["approvals","onResolve"]),J(od,{ref_key:"composerRef",ref:j,busy:W(u),status:W(r),"session-id":W(a),models:W(f),"work-dir":W(c)||"",messages:W(i),onSend:W(h),onAbort:W(w),onCommand:te,onSwitchModel:W(L),onSwitchThinking:W(Z)},null,8,["busy","status","session-id","models","work-dir","messages","onSend","onAbort","onSwitchModel","onSwitchThinking"])])]),J(_i,{name:"drawer"},{default:Pt(()=>[C.value?(g(),Xe(TC,{key:0,client:n.client,onRefreshGit:he[6]||(he[6]=Fe=>n.client.fetchGitStatus()),onClose:he[7]||(he[7]=Fe=>C.value=!1)},null,8,["client"])):U("",!0)]),_:1})]),y.value?(g(),Xe(vb,{key:1,mode:T.value,status:W(r),"session-id":W(a),"work-dir":W(c),onClose:he[8]||(he[8]=Fe=>y.value=!1)},null,8,["mode","status","session-id","work-dir"])):U("",!0)]))}}),nT=Ie(tT,[["__scopeId","data-v-1f8d863e"]]),sT=new Set(["png","jpg","jpeg","gif","webp","svg","avif","ico"]),oT=new Set(["mp3","wav","m4a","ogg"]),iT=new Set(["md","markdown"]);function of(e){const t=e.split(/[\\/]/).pop()??e,n=t.lastIndexOf(".");return n>0?t.slice(n+1).toLowerCase():""}function lT(e){const t=of(e);return sT.has(t)?"image":oT.has(t)?"audio":iT.has(t)?"markdown":t==="pdf"?"pdf":"source"}const rT={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",py:"python",rs:"rust",go:"go",java:"java",c:"c",h:"c",cpp:"cpp",hpp:"cpp",cs:"csharp",rb:"ruby",php:"php",sh:"bash",bash:"bash",zsh:"bash",yml:"yaml",yaml:"yaml",json:"json",toml:"toml",ini:"ini",xml:"xml",html:"html",css:"css",scss:"scss",less:"less",sql:"sql",md:"markdown",markdown:"markdown",vue:"vue",svelte:"svelte",swift:"swift",kt:"kotlin",lua:"lua",r:"r",dart:"dart",graphql:"graphql",proto:"protobuf",txt:"text"};function vc(e){const t=(e.split(/[\\/]/).pop()??"").toLowerCase();return t==="dockerfile"?"docker":t==="makefile"?"make":rT[of(e)]??"text"}const aT={key:0,class:"file-viewer"},cT={class:"fv-toolbar"},uT=["title","aria-label"],dT={class:"fv-path-text"},fT={class:"fv-modes",role:"tablist","aria-label":"显示模式"},hT=["aria-selected","title","onClick"],pT={class:"fv-body"},gT={key:0,class:"fv-status"},mT={key:1,class:"fv-status fv-error"},vT={class:"fv-error-name"},yT={class:"fv-error-msg"},bT={key:0,class:"fv-scroll"},kT={key:1,class:"fv-status"},wT={key:0,class:"fv-media"},_T=["src","alt"],ST={key:1,class:"fv-media"},$T=["src"],xT={key:2,class:"fv-media fv-pdf"},CT=["src","title"],TT={key:3,class:"fv-scroll fv-markdown"},IT={key:4,class:"fv-scroll"},RT={key:4,class:"fv-scroll"},AT={key:0,class:"fv-note"},MT={key:1,class:"fv-empty"},rl="/api/v1",ET=Te({__name:"FileViewer",props:{client:{}},setup(e){const t=e,n=[{id:"source",label:"源码"},{id:"preview",label:"预览"},{id:"diff",label:"Diff"}],s=q(()=>bm()),o=q(()=>s.value?hm(s.value.viewerState,s.value.initialDisplayMode):"source"),i=q(()=>s.value?lT(s.value.filePath):"source"),l=F(0),r=q(()=>{if(!s.value)return"";const y=l.value>0?`&t=${l.value}`:"";return`${rl}/files/raw?path=${encodeURIComponent(s.value.filePath)}${y}`}),a=An(new Map),c=An(new Map);async function u(y){try{const T=await y.json();return T.message??T.error??`HTTP ${y.status}`}catch{return`HTTP ${y.status}`}}function f(y){var H,O;const T=(H=t.client)==null?void 0:H.gitStatus.value,D=((O=t.client)==null?void 0:O.workDir.value)??"";if(!(T!=null&&T.files)||T.files.length===0)return null;const I=D&&y.startsWith(`${D}/`)?y.slice(D.length+1):y.startsWith("/")?null:y;if(I){const B=T.files.find(te=>(te.displayPath??te.path)===I);if(B)return B.path;for(const te of T.files){const oe=te.displayPath??te.path;if(oe&&te.path.endsWith(oe))return te.path.slice(0,te.path.length-oe.length)+I}}return null}function h(y){var H;const T=[],D=O=>{O&&O!==y&&!T.includes(O)&&T.push(O)};D(f(y)),T.push(y);const I=((H=t.client)==null?void 0:H.workDir.value)??"";return I&&y.startsWith(`${I}/`)&&D(y.slice(I.length+1)),T}async function p(){const y=s.value;if(!(!y||c.has(y.filePath)))try{for(const T of h(y.filePath)){const D=await fetch(`${rl}/git/diff?path=${encodeURIComponent(T)}`);if(!D.ok){c.set(y.filePath,{status:"error",message:await u(D)});return}const I=await D.json();if((I.patch??"")!==""){c.set(y.filePath,{status:"ok",patch:I.patch??""});return}}c.set(y.filePath,{status:"ok",patch:""})}catch(T){c.set(y.filePath,{status:"error",message:T instanceof Error?T.message:String(T)})}}async function v(){const y=s.value;if(y){if(o.value==="diff"){await p();return}if(!(o.value==="preview"&&(i.value==="image"||i.value==="audio"||i.value==="pdf"))&&!a.has(y.filePath))try{const T=await fetch(`${rl}/files/read?path=${encodeURIComponent(y.filePath)}`);if(!T.ok)a.set(y.filePath,{status:"error",message:await u(T)});else{const D=await T.json();a.set(y.filePath,{status:"ok",content:D.content,truncated:D.truncated===!0})}}catch(T){a.set(y.filePath,{status:"error",message:T instanceof Error?T.message:String(T)})}}}Ee(()=>{var y;return[(y=s.value)==null?void 0:y.id,o.value]},()=>{v()},{immediate:!0});const k=q(()=>{const y=s.value;if(y)return o.value==="diff"?c.get(y.filePath):o.value==="preview"&&(i.value==="image"||i.value==="audio"||i.value==="pdf")?{status:"ok"}:a.get(y.filePath)}),w=q(()=>s.value!==void 0&&k.value===void 0),S=q(()=>{var y;return((y=k.value)==null?void 0:y.status)==="error"?k.value:null}),$=q(()=>{const y=s.value?a.get(s.value.filePath):void 0;return(y==null?void 0:y.status)==="ok"?y.content:""}),E=q(()=>{const y=s.value?a.get(s.value.filePath):void 0;return(y==null?void 0:y.status)==="ok"?y.truncated:!1}),L=q(()=>{const y=s.value?c.get(s.value.filePath):void 0;return(y==null?void 0:y.status)==="ok"&&y.patch.trim()!==""?sf(y.patch):[]});function Z(y){var I,H,O;const T=s.value;if(!T||o.value===y)return;const D={displayMode:y,wrapLines:((I=T.viewerState)==null?void 0:I.wrapLines)??!1,scrollTop:((H=T.viewerState)==null?void 0:H.scrollTop)??0,scrollLeft:((O=T.viewerState)==null?void 0:O.scrollLeft)??0};$e.tabs=gm($e.tabs,T.id,T.viewerRevision??0,D)}function j(){const y=s.value;if(y){if(o.value==="diff")c.delete(y.filePath);else if(o.value==="preview"&&(i.value==="image"||i.value==="audio"||i.value==="pdf")){l.value+=1;return}else a.delete(y.filePath);v()}}const C=F(!1);function x(){var T;const y=s.value;y&&((T=navigator.clipboard)==null||T.writeText(y.filePath).then(()=>{C.value=!0,setTimeout(()=>C.value=!1,1500)}).catch(()=>{}))}return(y,T)=>s.value?(g(),m("div",aT,[d("div",cT,[d("button",{class:"fv-path",title:C.value?"已复制路径":`复制路径:${s.value.filePath}`,"aria-label":`文件路径 ${s.value.filePath}`,onClick:x},[J(me,{name:"copy",size:12,class:"fv-path-icon"}),d("span",dT,R(s.value.filePath),1)],8,uT),d("div",fT,[(g(),m(ee,null,Me(n,D=>d("button",{key:D.id,class:fe(["fv-mode",{active:o.value===D.id}]),role:"tab","aria-selected":o.value===D.id,title:`${D.label}模式`,onClick:I=>Z(D.id)},R(D.label),11,hT)),64))]),d("button",{class:"fv-icon-btn",title:"刷新","aria-label":"刷新",onClick:j},[J(me,{name:"refresh",size:14})])]),d("div",pT,[w.value?(g(),m("div",gT,[...T[0]||(T[0]=[d("span",{class:"fv-spinner","aria-hidden":"true"},null,-1),d("span",null,"加载中…",-1)])])):S.value?(g(),m("div",mT,[d("p",vT,R(s.value.label),1),d("p",yT,R(S.value.message),1),d("button",{class:"fv-retry",onClick:j},"重试")])):o.value==="diff"?(g(),m(ee,{key:2},[L.value.length>0?(g(),m("div",bT,[J(Mr,{lines:L.value},null,8,["lines"])])):(g(),m("div",kT,"该文件没有未提交的改动。"))],64)):o.value==="preview"?(g(),m(ee,{key:3},[i.value==="image"?(g(),m("div",wT,[d("img",{src:r.value,alt:s.value.label},null,8,_T)])):i.value==="audio"?(g(),m("div",ST,[d("audio",{class:"fv-audio",controls:"",src:r.value},null,8,$T)])):i.value==="pdf"?(g(),m("div",xT,[d("iframe",{class:"fv-pdf-frame",src:r.value,title:s.value.label},null,8,CT)])):i.value==="markdown"?(g(),m("div",TT,[J(tf,{content:$.value},null,8,["content"])])):(g(),m("div",IT,[T[1]||(T[1]=d("p",{class:"fv-note"},"该类型暂不支持预览,显示源码内容。",-1)),J(Gl,{code:$.value,lang:W(vc)(s.value.filePath)},null,8,["code","lang"])]))],64)):(g(),m("div",RT,[E.value?(g(),m("p",AT,"文件较大,仅显示前 256KB。")):U("",!0),J(Gl,{code:$.value,lang:W(vc)(s.value.filePath)},null,8,["code","lang"])]))])])):(g(),m("div",MT,"从工具卡片、文件浏览或消息中选择文件打开"))}}),PT=Ie(ET,[["__scopeId","data-v-7756f288"]]),LT={class:"settings"},OT={class:"settings-layout"},DT={class:"rail","aria-label":"设置分区"},NT=["aria-current","onClick"],BT={class:"pane"},FT={key:0,class:"pane-section"},jT={class:"block"},UT={class:"theme-grid",role:"radiogroup","aria-label":"主题"},GT=["aria-checked","onClick"],zT={class:"block"},HT={class:"like-fields"},WT={class:"like-label"},qT=["onUpdate:modelValue","placeholder","aria-label"],VT={class:"like-actions"},KT={key:0,class:"saved-hint"},YT={key:1,class:"pane-section"},ZT={key:0,class:"empty"},JT={key:1,class:"list"},XT={class:"row-main"},QT={class:"row-title"},e2={class:"row-sub"},t2=["disabled","onClick"],n2={key:2,class:"pane-section"},s2={key:0,class:"empty"},o2={key:1,class:"list"},i2={class:"row-main"},l2={class:"row-title"},r2={class:"row-sub"},a2={class:"row-actions"},c2=["disabled","onClick"],u2=["disabled","onClick"],d2={key:3,class:"pane-section"},f2={class:"block"},h2={class:"inline-form"},p2={key:0,class:"hint"},g2={key:0,class:"empty"},m2={key:1,class:"list"},v2={class:"row-main"},y2={class:"row-title"},b2={key:0,class:"version"},k2={class:"row-sub"},w2=["disabled","onClick"],_2={key:4,class:"pane-section"},S2={key:0,class:"hint"},$2={key:1,class:"empty"},x2={key:2,class:"list"},C2={class:"row-main"},T2={class:"row-title"},I2={class:"row-sub"},R2={class:"row-actions"},A2=["disabled","onClick"],M2=["disabled","onClick"],E2=["disabled","onClick"],P2={key:5,class:"pane-section"},L2={key:0,class:"hint"},O2={key:1,class:"empty"},D2={key:2,class:"list"},N2={class:"row-main"},B2={class:"row-title"},F2={class:"row-sub"},j2={class:"row-actions"},U2=["disabled","onClick"],G2=["disabled","onClick"],z2=Te({__name:"SettingsView",props:{like:{default:()=>({})},client:{}},emits:["update-like"],setup(e,{emit:t}){const n=e,s=t;function o(K){return K!==null&&typeof K=="object"&&K.__v_isRef===!0?K.value:K}const i=[{id:"general",label:"通用",icon:"settings"},{id:"models",label:"模型",icon:"bot"},{id:"skills",label:"技能",icon:"sparkles"},{id:"plugins",label:"插件",icon:"layers"},{id:"mcp",label:"MCP 服务器",icon:"monitor"},{id:"tasks",label:"后台任务",icon:"activity"}],l=F("general"),r=q(()=>n.client),a=vn("theme",F("system")),c=vn("setTheme",()=>{}),u=[{id:"light",label:"浅色",icon:"sun"},{id:"dark",label:"深色",icon:"moon"},{id:"system",label:"跟随系统",icon:"monitor"}],f=F({...n.like}),h=F(!1);Ee(()=>n.like,K=>{f.value={...K}});const p=[{key:"nickname",label:"称呼",hint:"AI 如何称呼你"},{key:"tone",label:"语气",hint:"回复的语气风格"},{key:"other",label:"偏好",hint:"其他偏好说明"},{key:"doNot",label:"禁止事项",hint:"明确禁止的行为"}];function v(){s("update-like",k()),h.value=!0,setTimeout(()=>h.value=!1,1500)}function k(){const K={};for(const ae of p){const V=f.value[ae.key];typeof V=="string"&&V.trim()&&(K[ae.key]=V.trim())}return K}const w=q(()=>{var K;return o((K=r.value)==null?void 0:K.models)??[]}),S=q(()=>{var K,ae;return((ae=o((K=r.value)==null?void 0:K.status))==null?void 0:ae.model)??""});function $(K){var ae,V;(V=(ae=r.value)==null?void 0:ae.switchModel)==null||V.call(ae,K)}const E=q(()=>{var K;return o((K=r.value)==null?void 0:K.skills)??[]}),L=F(!1);async function Z(K){var ae,V,ve,Oe;L.value=!0;try{await((V=(ae=r.value)==null?void 0:ae.activateSkill)==null?void 0:V.call(ae,K))&&await((Oe=(ve=r.value)==null?void 0:ve.fetchSkills)==null?void 0:Oe.call(ve))}finally{L.value=!1}}async function j(K){var V,ve,Oe,Ue;if(!window.confirm(`移除技能「${K}」?`))return;await((ve=(V=r.value)==null?void 0:V.removeSkill)==null?void 0:ve.call(V,K))&&await((Ue=(Oe=r.value)==null?void 0:Oe.fetchSkills)==null?void 0:Ue.call(Oe))}const C=q(()=>{var K;return o((K=r.value)==null?void 0:K.plugins)??[]}),x=F(!1);async function y(K,ae){var V,ve,Oe,Ue;x.value=!0;try{await((ve=(V=r.value)==null?void 0:V.setPluginEnabled)==null?void 0:ve.call(V,K,ae))&&await((Ue=(Oe=r.value)==null?void 0:Oe.fetchPlugins)==null?void 0:Ue.call(Oe))}finally{x.value=!1}}const T=F(""),D=F(!1),I=F("");async function H(){var ae,V;const K=T.value.trim();if(K){D.value=!0,I.value="";try{const ve=await((V=(ae=r.value)==null?void 0:ae.installPlugin)==null?void 0:V.call(ae,K));I.value=ve?`已安装 ${ve.displayName}`:"安装失败",ve&&(T.value="")}finally{D.value=!1}}}const O=q(()=>{var K;return o((K=r.value)==null?void 0:K.mcpServers)??[]}),B=F(!1),te=F("");async function oe(K,ae){var V,ve,Oe,Ue;B.value=!0,te.value="";try{const Pe=await((ve=(V=r.value)==null?void 0:V[K])==null?void 0:ve.call(V,ae));te.value=Pe?"操作成功":"操作失败",await((Ue=(Oe=r.value)==null?void 0:Oe.fetchMcpServers)==null?void 0:Ue.call(Oe))}finally{B.value=!1}}const _e=q(()=>{var K;return o((K=r.value)==null?void 0:K.backgroundTasks)??[]}),Se=F(""),je=F(!1),Qe=F("");async function ge(K){var ae,V,ve,Oe;je.value=!0,Qe.value="";try{const Ue=await((V=(ae=r.value)==null?void 0:ae.stopBackgroundTask)==null?void 0:V.call(ae,K));Qe.value=Ue?"已停止":"取消失败",await((Oe=(ve=r.value)==null?void 0:ve.fetchBackgroundTasks)==null?void 0:Oe.call(ve))}finally{je.value=!1}}async function he(K){var ae,V,ve;je.value=!0,Qe.value="";try{await((V=(ae=r.value)==null?void 0:ae.fetchBackgroundTaskOutput)==null?void 0:V.call(ae,K,200)),Se.value=o((ve=r.value)==null?void 0:ve.backgroundTaskOutput)??""}finally{je.value=!1}}ct(()=>{var ae,V,ve,Oe,Ue,Pe;const K=r.value;(ae=K==null?void 0:K.fetchModels)==null||ae.call(K),(V=K==null?void 0:K.fetchConfig)==null||V.call(K),(ve=K==null?void 0:K.fetchSkills)==null||ve.call(K),(Oe=K==null?void 0:K.fetchPlugins)==null||Oe.call(K),(Ue=K==null?void 0:K.fetchMcpServers)==null||Ue.call(K),(Pe=K==null?void 0:K.fetchBackgroundTasks)==null||Pe.call(K)});function Fe(K){return K==="connected"||K==="completed"?"ok":K==="failed"||K==="killed"?"bad":K==="running"||K==="pending"?"run":"muted"}return(K,ae)=>(g(),m("div",LT,[d("div",OT,[d("nav",DT,[(g(),m(ee,null,Me(i,V=>d("button",{key:V.id,class:fe(["rail-tab",{active:l.value===V.id}]),"aria-current":l.value===V.id?"page":void 0,onClick:ve=>l.value=V.id},[J(me,{name:V.icon,size:16},null,8,["name"]),d("span",null,R(V.label),1)],10,NT)),64))]),d("div",BT,[l.value==="general"?(g(),m("section",FT,[ae[4]||(ae[4]=d("h1",{class:"settings-title"},"通用设置",-1)),d("div",jT,[ae[1]||(ae[1]=d("h2",{class:"block-title"},"外观",-1)),d("div",UT,[(g(),m(ee,null,Me(u,V=>d("button",{key:V.id,role:"radio","aria-checked":W(a)===V.id,class:fe(["theme-option",{active:W(a)===V.id}]),onClick:ve=>W(c)(V.id)},[J(me,{name:V.icon,size:20},null,8,["name"]),d("span",null,R(V.label),1)],10,GT)),64))])]),d("div",zT,[ae[3]||(ae[3]=d("h2",{class:"block-title"},"偏好设置",-1)),d("div",HT,[(g(),m(ee,null,Me(p,V=>d("label",{key:V.key,class:"like-field"},[d("span",WT,R(V.label),1),it(d("input",{"onUpdate:modelValue":ve=>f.value[V.key]=ve,class:"like-input",placeholder:V.hint,"aria-label":V.label},null,8,qT),[[ut,f.value[V.key]]])])),64)),d("div",VT,[J(zn,{variant:"primary",onClick:v},{default:Pt(()=>[...ae[2]||(ae[2]=[Ce("保存偏好",-1)])]),_:1}),h.value?(g(),m("span",KT,"已保存")):U("",!0)])])])])):l.value==="models"?(g(),m("section",YT,[ae[5]||(ae[5]=d("h1",{class:"settings-title"},"模型",-1)),w.value.length===0?(g(),m("p",ZT,"没有可用的模型")):(g(),m("ul",JT,[(g(!0),m(ee,null,Me(w.value,V=>(g(),m("li",{key:V.alias,class:fe(["list-row",{selected:V.alias===S.value}])},[d("div",XT,[d("span",QT,R(V.displayName||V.model),1),d("span",e2,R(V.provider)+" · "+R(V.alias)+" · "+R(V.maxContextSize),1)]),d("button",{class:"row-action",disabled:V.alias===S.value,onClick:ve=>$(V.alias)},R(V.alias===S.value?"使用中":"切换"),9,t2)],2))),128))]))])):l.value==="skills"?(g(),m("section",n2,[ae[6]||(ae[6]=d("h1",{class:"settings-title"},"技能",-1)),E.value.length===0?(g(),m("p",s2,"当前会话没有可用技能")):(g(),m("ul",o2,[(g(!0),m(ee,null,Me(E.value,V=>(g(),m("li",{key:V.name,class:"list-row"},[d("div",i2,[d("span",l2,R(V.name),1),d("span",r2,[Ce(R(V.description||"—")+" ",1),V.pluginId?(g(),m(ee,{key:0},[Ce("· 来自插件 "+R(V.pluginId),1)],64)):U("",!0)])]),d("div",a2,[d("button",{class:"row-action",disabled:L.value,onClick:ve=>Z(V.name)}," 激活 ",8,c2),d("button",{class:"row-action danger",disabled:L.value,onClick:ve=>j(V.name)}," 移除 ",8,u2)])]))),128))]))])):l.value==="plugins"?(g(),m("section",d2,[ae[9]||(ae[9]=d("h1",{class:"settings-title"},"插件",-1)),d("div",f2,[ae[8]||(ae[8]=d("h2",{class:"block-title"},"安装插件",-1)),d("div",h2,[it(d("input",{"onUpdate:modelValue":ae[0]||(ae[0]=V=>T.value=V),class:"like-input",placeholder:"本地路径 / zip URL / GitHub 地址","aria-label":"插件来源",spellcheck:"false"},null,512),[[ut,T.value]]),J(zn,{variant:"primary",disabled:D.value||!T.value.trim(),onClick:H},{default:Pt(()=>[...ae[7]||(ae[7]=[Ce(" 安装 ",-1)])]),_:1},8,["disabled"])]),I.value?(g(),m("p",p2,R(I.value),1)):U("",!0)]),C.value.length===0?(g(),m("p",g2,"还没有安装插件")):(g(),m("ul",m2,[(g(!0),m(ee,null,Me(C.value,V=>(g(),m("li",{key:V.id,class:"list-row"},[d("div",v2,[d("span",y2,[Ce(R(V.displayName)+" ",1),V.version?(g(),m("span",b2,"v"+R(V.version),1)):U("",!0)]),d("span",k2,R(V.skillCount)+" 技能 · "+R(V.enabledMcpServerCount)+"/"+R(V.mcpServerCount)+" MCP",1)]),d("button",{class:"row-action",disabled:x.value,onClick:ve=>y(V.id,!V.enabled)},R(V.enabled?"停用":"启用"),9,w2)]))),128))]))])):l.value==="mcp"?(g(),m("section",_2,[ae[10]||(ae[10]=d("h1",{class:"settings-title"},"MCP 服务器",-1)),te.value?(g(),m("p",S2,R(te.value),1)):U("",!0),O.value.length===0?(g(),m("p",$2,"没有配置 MCP 服务器")):(g(),m("ul",x2,[(g(!0),m(ee,null,Me(O.value,V=>(g(),m("li",{key:V.name,class:"list-row"},[d("div",C2,[d("span",T2,R(V.name),1),d("span",I2,R(V.transport)+" · "+R(V.toolCount)+" 工具",1),d("span",{class:fe(["status-pill",Fe(V.status)])},R(V.status),3)]),d("div",R2,[d("button",{class:"row-action",disabled:B.value,onClick:ve=>oe("reconnectMcpServer",V.name)},"重连",8,A2),d("button",{class:"row-action",disabled:B.value,onClick:ve=>oe("stopMcpServer",V.name)},"停止",8,M2),d("button",{class:"row-action danger",disabled:B.value,onClick:ve=>oe("removeMcpServer",V.name)},"移除",8,E2)])]))),128))]))])):l.value==="tasks"?(g(),m("section",P2,[ae[11]||(ae[11]=d("h1",{class:"settings-title"},"后台任务",-1)),Qe.value?(g(),m("p",L2,R(Qe.value),1)):U("",!0),_e.value.length===0?(g(),m("p",O2,"没有后台任务")):(g(),m("ul",D2,[(g(!0),m(ee,null,Me(_e.value,V=>(g(),m("li",{key:V.taskId,class:"list-row"},[d("div",N2,[d("span",B2,R(V.command),1),d("span",F2,R(V.description),1),d("span",{class:fe(["status-pill",Fe(V.status)])},R(V.status),3)]),d("div",j2,[d("button",{class:"row-action",disabled:je.value,onClick:ve=>he(V.taskId)},"输出",8,U2),V.status==="running"||V.status==="awaiting_approval"?(g(),m("button",{key:0,class:"row-action danger",disabled:je.value,onClick:ve=>ge(V.taskId)}," 停止 ",8,G2)):U("",!0)])]))),128))]))])):U("",!0)])])]))}}),H2=Ie(z2,[["__scopeId","data-v-76c28b05"]]),yc=F(""),al=F(new Set),W2=F("sessions");function q2(){function e(n){const s=new Set(al.value);s.has(n)?s.delete(n):s.add(n),al.value=s}function t(){yc.value=""}return{query:yc,collapsedSpaces:al,section:W2,toggleSpace:e,clearSearch:t}}const lf="scream-file-tree-expanded",V2=F("");function K2(){try{const e=localStorage.getItem(lf);if(!e)return{};const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t)){const n={};for(const[s,o]of Object.entries(t))Array.isArray(o)&&(n[s]=o.filter(i=>typeof i=="string"));return n}return{}}catch{return{}}}const Bn=F(K2()),Is=An(new Map),cl=F(null),ul=new Map;function Y2(){function e(a){return a?new Set(Bn.value[a]??[]):new Set}function t(a){if(!a)return;const c={...Bn.value};c[a]=[...e(a)],Bn.value=c;try{localStorage.setItem(lf,JSON.stringify(c))}catch{}}function n(a){cl.value!==a&&(cl.value=a)}function s(a,c){var u;return a?((u=Bn.value[a])==null?void 0:u.includes(c))??!1:!1}function o(a,c){if(!a)return!1;const u=Bn.value[a]??[],f=u.includes(c)?u.filter(h=>h!==c):[...u,c];return Bn.value={...Bn.value,[a]:f},t(a),!u.includes(c)}function i(a){return Is.get(a)??[]}async function l(a){const c=(ul.get(a)??0)+1;ul.set(a,c);const u=await td(a);return c!==(ul.get(a)??0)?Is.get(a)??[]:(u!==null&&Is.set(a,u),Is.get(a)??[])}function r(a){Is.delete(a)}return{activeWorkDir:cl,query:V2,isExpanded:s,toggleExpand:o,loadedChildren:i,loadChildren:l,invalidate:r,setRoot:n}}const Z2={class:"file-tree"},J2={key:0,class:"tree-toolbar"},X2={class:"tree-search"},Q2={key:1,class:"tree-empty"},eI={key:2,class:"tree-empty"},tI={key:3,class:"tree-empty"},nI={key:4,class:"tree-empty"},sI=["aria-label"],oI=["aria-expanded","onClick"],iI=["title"],lI=["aria-expanded","onClick"],rI=["title"],aI=Te({__name:"FileTree",props:{workDir:{},gitStatus:{},refreshGit:{type:Function}},setup(e){const t=e,{query:n,isExpanded:s,toggleExpand:o,loadedChildren:i,loadChildren:l,invalidate:r,setRoot:a}=Y2(),c=F(!1),u=F(!1);Ee(()=>t.workDir,j=>{a(j),j&&f(j)},{immediate:!0});async function f(j){c.value=!0,u.value=!1;try{(await l(j)).length===0&&(u.value=!0)}finally{c.value=!1}}async function h(j){const C=t.workDir;if(!C)return;o(C,j)&&await l(j)}function p(j,C){return`${j.replace(/\/+$/,"")}/${C}`}function v(j){const C=t.workDir;if(!C)return j;const x=C.replace(/\/+$/,"");return j===x?"":j.startsWith(`${x}/`)?j.slice(x.length+1):j}function k(j){var T;const C=(T=t.gitStatus)==null?void 0:T.files;if(!C||C.length===0)return null;const x=v(j),y=C.find(D=>(D.displayPath??D.path)===x);return y?y.status.includes("?")?"?":y.status.includes("A")?"A":y.status.includes("M")?"M":null:null}const w=q(()=>{const j=t.workDir;if(!j)return[];const C=[],x=(y,T)=>{for(const D of i(y)){const I=p(y,D.name);C.push({abs:I,name:D.name,rel:v(I),isDir:D.type==="dir",depth:T,git:k(I)}),D.type==="dir"&&s(j,I)&&x(I,T+1)}};return x(j,0),C}),S=q(()=>w.value),$=q(()=>{const j=n.value.trim();if(!j)return[];const C=new Map(S.value.map(x=>[x.rel,x]));return ed(S.value.map(x=>({path:x.rel,isDir:x.isDir})),j,50).map(x=>C.get(x.path)).filter(x=>x!==void 0)}),E=q(()=>n.value.trim().length>0);function L(j){j.isDir?h(j.abs):Zn(j.abs)}function Z(){var C;const j=t.workDir;j&&(r(j),jm(j),f(j),(C=t.refreshGit)==null||C.call(t))}return(j,C)=>(g(),m("div",Z2,[e.workDir?(g(),m("div",J2,[d("label",X2,[J(me,{name:"search",size:13}),it(d("input",{"onUpdate:modelValue":C[0]||(C[0]=x=>ht(n)?n.value=x:null),type:"text",placeholder:"过滤文件…","aria-label":"过滤文件",spellcheck:"false"},null,512),[[ut,W(n)]])]),d("button",{class:"tree-refresh",title:"刷新文件树与 Git 状态","aria-label":"刷新文件树与 Git 状态",onClick:Z},[J(me,{name:"refresh",size:13})])])):U("",!0),e.workDir?c.value&&w.value.length===0?(g(),m("div",eI,"加载中…")):u.value&&w.value.length===0?(g(),m("div",tI,"工作目录为空")):E.value&&$.value.length===0?(g(),m("div",nI,"没有匹配的文件")):(g(),m("div",{key:5,class:"tree-scroll",role:"tree","aria-label":"文件树 "+e.workDir},[E.value?(g(!0),m(ee,{key:0},Me($.value,x=>(g(),m("button",{key:x.abs,class:fe(["tree-row",{"is-dir":x.isDir}]),role:"treeitem","aria-expanded":x.isDir?W(s)(e.workDir,x.abs):void 0,onClick:y=>L(x)},[J(me,{name:x.isDir?"folder":"file",size:14,class:"row-icon"},null,8,["name"]),d("span",{class:"row-label mono",title:x.rel},R(x.rel),9,iI),x.git?(g(),m("span",{key:0,class:fe(["row-git",`g-${x.git}`])},R(x.git),3)):U("",!0)],10,oI))),128)):(g(!0),m(ee,{key:1},Me(w.value,x=>(g(),m("button",{key:x.abs,class:fe(["tree-row",{"is-dir":x.isDir}]),style:Nt({paddingLeft:`${8+x.depth*14}px`}),role:"treeitem","aria-expanded":x.isDir?W(s)(e.workDir,x.abs):void 0,onClick:y=>L(x)},[J(me,{name:x.isDir?W(s)(e.workDir,x.abs)?"chevron-down":"chevron-right":"file",size:13,class:"row-caret"},null,8,["name"]),J(me,{name:x.isDir?"folder":"file",size:14,class:"row-icon"},null,8,["name"]),d("span",{class:fe(["row-label",{mono:!x.isDir}]),title:x.rel},R(x.name),11,rI),x.git?(g(),m("span",{key:0,class:fe(["row-git",`g-${x.git}`])},R(x.git),3)):U("",!0)],14,lI))),128))],8,sI)):(g(),m("div",Q2,"当前会话没有工作目录"))]))}}),cI=Ie(aI,[["__scopeId","data-v-78dceb03"]]),rf=""+new URL("logo-v2-ChmPAIbI.svg",import.meta.url).href,uI={class:"sidebar-head"},dI=["src"],fI=["title","aria-label","aria-expanded"],hI=["title"],pI={key:0},gI={key:0,class:"section-switch",role:"tablist","aria-label":"侧栏分区"},mI=["aria-selected"],vI=["aria-selected"],yI={key:0,class:"side-search"},bI={class:"spaces"},kI=["title"],wI=["title","onClick"],_I={class:"space-name"},SI={class:"space-count"},$I={key:0,class:"space-sessions"},xI=["title","onClick","onDblclick"],CI={key:0,class:"session-run","aria-hidden":"true"},TI={class:"session-text"},II={key:0,class:"session-rename"},RI=["aria-label","onKeydown","onBlur"],AI={class:"session-title"},MI={class:"session-meta"},EI=["title","onClick","onKeydown"],PI={key:0,class:"spaces-empty"},LI={class:"sidebar-foot","aria-label":"功能区"},OI=["title"],DI={key:0},NI=["title"],BI={key:0},FI={class:"sidebar-identity"},jI={key:0,class:"identity-text"},UI=Te({__name:"Sidebar",props:{view:{},sessions:{},currentSessionId:{default:null},workDir:{default:null},gitStatus:{default:null},refreshGit:{type:Function,default:void 0},collapsed:{type:Boolean,default:!1},showCollapseToggle:{type:Boolean,default:!0}},emits:["navigate","switch-session","delete-session","create-session","toggle-collapse","open-file","rename-session"],setup(e,{expose:t,emit:n}){const s=e,o=n,i=F(null),{query:l,collapsedSpaces:r,section:a,toggleSpace:c}=q2();function u(){var x,y;(x=i.value)==null||x.focus(),(y=i.value)==null||y.select()}t({focusSearch:u});const f=q(()=>{const x=l.value.trim().toLowerCase();return x?s.sessions.filter(y=>C(y).toLowerCase().includes(x)||y.workDir.toLowerCase().includes(x)):s.sessions}),h=q(()=>{var T;const x=new Map;for(const D of f.value){const I=D.workDir||"默认空间",H=I.split(/[\\/]/).filter(Boolean),O=H.length>0?H[H.length-1]:I,B=x.get(I);B?B.items.push(D):x.set(I,{key:I,name:O,items:[D]})}const y=(T=s.sessions.find(D=>D.sessionId===s.currentSessionId))==null?void 0:T.workDir;return[...x.values()].sort((D,I)=>{var H,O;return D.key===y?-1:I.key===y?1:(((H=I.items[0])==null?void 0:H.createdAt)??0)-(((O=D.items[0])==null?void 0:O.createdAt)??0)})});function p(x){o("switch-session",x)}function v(x,y){window.confirm(`删除会话「${y}」?此操作不可恢复。`)&&o("delete-session",x)}function k(x){o("open-file",x)}const w=F(null),S=F(null),$=F("");function E(x){S.value=x.sessionId,$.value=C(x),ft(()=>{var y,T;(y=w.value)==null||y.focus(),(T=w.value)==null||T.select()})}function L(){S.value=null,$.value=""}function Z(x){const y=$.value.trim();if(S.value=null,$.value="",!y)return;const T=s.sessions.find(D=>D.sessionId===x);!T||y===C(T)||o("rename-session",x,y)}function j(x){if(!x)return"";const y=Date.now()-x;if(y<6e4)return"刚刚";if(y<36e5)return`${Math.floor(y/6e4)} 分钟前`;if(y<864e5)return`${Math.floor(y/36e5)} 小时前`;const T=new Date(x);return`${T.getMonth()+1}/${T.getDate()}`}function C(x){const y=(x.title||"").trim();return y&&y!=="新会话"&&y!=="New Session"?y:"未命名会话"}return(x,y)=>(g(),m("aside",{class:fe(["sidebar",{"is-collapsed":e.collapsed}])},[d("div",uI,[d("button",{class:"sidebar-brand",title:"回到新对话",onClick:y[0]||(y[0]=T=>o("navigate","home"))},[d("img",{class:"brand-logo",src:W(rf),alt:"scream"},null,8,dI)]),e.showCollapseToggle?(g(),m("button",{key:0,class:fe(["collapse-btn",{rotated:e.collapsed}]),title:e.collapsed?"展开侧栏":"折叠侧栏","aria-label":e.collapsed?"展开侧栏":"折叠侧栏","aria-expanded":!e.collapsed,onClick:y[1]||(y[1]=T=>o("toggle-collapse"))},[J(me,{name:"panel-left",size:15})],10,fI)):U("",!0)]),d("button",{class:"new-chat-btn",title:e.collapsed?"新建对话":void 0,onClick:y[2]||(y[2]=T=>o("create-session"))},[J(me,{name:"plus",size:16}),e.collapsed?U("",!0):(g(),m("span",pI,"新建对话"))],8,hI),e.collapsed?U("",!0):(g(),m("div",gI,[d("button",{class:fe(["section-tab",{active:W(a)==="sessions"}]),role:"tab","aria-selected":W(a)==="sessions",onClick:y[3]||(y[3]=T=>a.value="sessions")},[J(me,{name:"message-circle",size:13}),y[12]||(y[12]=d("span",null,"会话",-1))],10,mI),d("button",{class:fe(["section-tab",{active:W(a)==="files"}]),role:"tab","aria-selected":W(a)==="files",onClick:y[4]||(y[4]=T=>a.value="files")},[J(me,{name:"folder",size:13}),y[13]||(y[13]=d("span",null,"文件",-1))],10,vI)])),!e.collapsed&&W(a)==="files"?(g(),Xe(cI,{key:1,"work-dir":e.workDir,"git-status":e.gitStatus,"refresh-git":e.refreshGit,onOpenFile:k},null,8,["work-dir","git-status","refresh-git"])):U("",!0),e.collapsed||W(a)==="sessions"?(g(),m(ee,{key:2},[e.collapsed?U("",!0):(g(),m("label",yI,[J(me,{name:"search",size:15}),it(d("input",{ref_key:"searchRef",ref:i,"onUpdate:modelValue":y[5]||(y[5]=T=>ht(l)?l.value=T:null),type:"text",placeholder:"搜索会话… (⌘K)","aria-label":"搜索会话",spellcheck:"false"},null,512),[[ut,W(l)]])])),d("div",bI,[(g(!0),m(ee,null,Me(h.value,T=>(g(),m("div",{key:T.key,class:"space-group"},[e.collapsed?(g(),m("button",{key:0,class:fe(["space-dot",{active:T.items.some(D=>D.sessionId===e.currentSessionId)}]),title:T.name,onClick:y[6]||(y[6]=D=>o("toggle-collapse"))},R(T.name.slice(0,1).toUpperCase()),11,kI)):(g(),m(ee,{key:1},[d("button",{class:"space-head",title:T.key,onClick:D=>W(c)(T.key)},[J(me,{name:W(r).has(T.key)?"chevron-right":"chevron-down",size:14},null,8,["name"]),d("span",_I,R(T.name),1),d("span",SI,R(T.items.length),1)],8,wI),W(r).has(T.key)?U("",!0):(g(),m("div",$I,[(g(!0),m(ee,null,Me(T.items,D=>(g(),m("div",{key:D.sessionId,class:"session-item-wrap"},[d("button",{class:fe(["session-item",{active:D.sessionId===e.currentSessionId}]),title:C(D),onClick:I=>p(D.sessionId),onDblclick:I=>E(D)},[D.active?(g(),m("span",CI)):U("",!0),d("span",TI,[S.value===D.sessionId?(g(),m("span",II,[it(d("input",{ref_for:!0,ref_key:"renameInputRef",ref:w,"onUpdate:modelValue":y[7]||(y[7]=I=>$.value=I),class:"rename-input",spellcheck:"false","aria-label":`重命名会话 ${C(D)}`,onClick:y[8]||(y[8]=rt(()=>{},["stop"])),onKeydown:[Vn(rt(I=>Z(D.sessionId),["prevent"]),["enter"]),y[9]||(y[9]=Vn(rt(I=>L(),["prevent"]),["esc"]))],onBlur:I=>Z(D.sessionId)},null,40,RI),[[ut,$.value]])])):(g(),m(ee,{key:1},[d("span",AI,R(C(D)),1),d("span",MI,[d("span",null,R(j(D.createdAt)),1),y[14]||(y[14]=d("span",{class:"meta-sep","aria-hidden":"true"},"·",-1)),d("span",null,R(D.messageCount)+" 条",1)])],64))]),d("span",{class:"session-delete",role:"button",tabindex:"0",title:`删除会话 ${C(D)}`,"aria-label":"删除会话",onClick:rt(I=>v(D.sessionId,C(D)),["stop"]),onKeydown:Vn(rt(I=>v(D.sessionId,C(D)),["stop","prevent"]),["enter"])},[J(me,{name:"trash",size:14})],40,EI)],42,xI)]))),128))]))],64))]))),128)),!e.collapsed&&h.value.length===0?(g(),m("p",PI,R(W(l)?"没有匹配的会话":"还没有会话,点击上方「新建对话」开始"),1)):U("",!0)])],64)):U("",!0),d("nav",LI,[d("button",{class:fe(["foot-item",{active:e.view==="skills"}]),title:e.collapsed?"技能中心":void 0,onClick:y[10]||(y[10]=T=>o("navigate","skills"))},[J(me,{name:"sparkles",size:17}),e.collapsed?U("",!0):(g(),m("span",DI,"技能中心"))],10,OI),d("button",{class:fe(["foot-item",{active:e.view==="settings"}]),title:e.collapsed?"设置":void 0,onClick:y[11]||(y[11]=T=>o("navigate","settings"))},[J(me,{name:"settings",size:17}),e.collapsed?U("",!0):(g(),m("span",BI,"设置"))],10,NI),d("div",FI,[y[15]||(y[15]=d("span",{class:"identity-dot","aria-hidden":"true"},null,-1)),e.collapsed?U("",!0):(g(),m("span",jI,"scream web"))])])],2))}}),bc=Ie(UI,[["__scopeId","data-v-b028f75e"]]),GI={class:"skills"},zI={class:"skills-head"},HI={class:"skills-grid"},WI={class:"skill-card-head"},qI={class:"skill-cmd"},VI={class:"skill-desc"},KI={key:0,class:"skill-aliases"},YI=Te({__name:"SkillsView",emits:["create"],setup(e,{emit:t}){const n=t,s={backend:"服务端",local:"本地"};return(o,i)=>(g(),m("div",GI,[d("div",zI,[i[2]||(i[2]=d("div",null,[d("h1",{class:"skills-title"},"技能中心"),d("p",{class:"skills-sub"},[Ce("在输入框中输入 "),d("code",null,"/"),Ce(" 即可触发以下命令")])],-1)),J(zn,{variant:"primary",onClick:i[0]||(i[0]=l=>n("create"))},{default:Pt(()=>[J(me,{name:"plus",size:16}),i[1]||(i[1]=Ce(" 新建会话 ",-1))]),_:1})]),d("div",HI,[(g(!0),m(ee,null,Me(W(Si),l=>{var r;return g(),m("article",{key:l.name,class:"skill-card"},[d("div",WI,[d("span",qI,"/"+R(l.name),1),d("span",{class:fe(["skill-target",`target-${l.target}`])},R(s[l.target]),3)]),d("p",VI,R(l.description),1),(r=l.aliases)!=null&&r.length?(g(),m("p",KI," 别名:"+R(l.aliases.map(a=>`/${a}`).join(" ")),1)):U("",!0)])}),128))])]))}}),ZI=Ie(YI,[["__scopeId","data-v-35313e25"]]),JI=["aria-selected","title","onClick","onAuxclick"],XI={class:"tab-label"},QI=["title","aria-label","onClick"],eR=Te({__name:"TabBar",setup(e){const t=F(null);Ee(()=>$e.activeTabId,async()=>{var o;await ft();const s=(o=t.value)==null?void 0:o.querySelector(".tab-button.active");s==null||s.scrollIntoView({block:"nearest",inline:"nearest"})},{immediate:!0});function n(s,o){s.button===1&&(s.preventDefault(),s.stopPropagation(),Oa(o))}return(s,o)=>W($e).tabs.length>0?(g(),m("div",{key:0,ref_key:"barRef",ref:t,class:"tab-bar",role:"tablist","aria-label":"文件标签"},[(g(!0),m(ee,null,Me(W($e).tabs,i=>(g(),m("div",{key:i.id,class:fe(["tab-button",{active:i.id===W($e).activeTabId}]),role:"tab","aria-selected":i.id===W($e).activeTabId,title:i.filePath,onClick:l=>W(ym)(i.id),onMousedown:o[0]||(o[0]=l=>{l.button===1&&l.preventDefault()}),onAuxclick:l=>n(l,i.id)},[J(me,{name:"file",size:13,class:"tab-icon"}),d("span",XI,R(i.label),1),d("button",{class:"tab-close",title:`关闭 ${i.label}`,"aria-label":`关闭 ${i.label}`,onClick:rt(l=>W(Oa)(i.id),["stop"])},[J(me,{name:"x",size:11})],8,QI)],42,JI))),128))],512)):U("",!0)}}),tR=Ie(eR,[["__scopeId","data-v-cad2e90f"]]),nR={class:"mode-switch",role:"group","aria-label":"工作模式"},sR=["aria-pressed","onClick"],oR=Te({__name:"ModeSwitch",props:{modelValue:{default:"chat"}},emits:["update:modelValue"],setup(e,{emit:t}){const n=t,s=[{id:"chat",label:"智能工作"},{id:"goal",label:"任务模式"}];return(o,i)=>(g(),m("div",nR,[(g(),m(ee,null,Me(s,l=>d("button",{key:l.id,class:fe(["mode-pill",`is-${l.id}`,{active:e.modelValue===l.id}]),"aria-pressed":e.modelValue===l.id,onClick:r=>n("update:modelValue",l.id)},R(l.label),11,sR)),64))]))}}),iR=Ie(oR,[["__scopeId","data-v-c4ac7862"]]),lR={class:"workspace"},rR={class:"workspace-hero"},aR={class:"workspace-brand"},cR=["src"],uR={class:"mode-hint"},dR={class:"workspace-composer"},fR=Te({__name:"WorkspaceHome",props:{models:{},status:{default:void 0},busy:{type:Boolean},mode:{default:"chat"}},emits:["send","command","switch-model","switch-thinking","update:mode"],setup(e,{emit:t}){const n=e,s=t,o=q(()=>n.mode==="goal"),i=q(()=>o.value?"任务模式:提交后将创建执行目标(Goal),Agent 持续执行到完成或预算耗尽;抽屉「Goal 管理」可查看与暂停。":"直接对话:提问后 Agent 按需调用工具完成你的请求。");return(l,r)=>(g(),m("div",lR,[d("section",rR,[d("h1",aR,[d("img",{class:"brand-logo",src:W(rf),alt:"scream"},null,8,cR)]),r[5]||(r[5]=d("p",{class:"workspace-tagline"},"你的智能协作伙伴",-1)),J(iR,{class:"workspace-mode","model-value":n.mode,"onUpdate:modelValue":r[0]||(r[0]=a=>s("update:mode",a))},null,8,["model-value"]),d("p",uR,[(g(),m("span",{key:String(o.value),class:"hint-fade"},R(i.value),1))])]),d("section",dR,[J(od,{busy:e.busy,status:e.status,models:e.models,variant:"home",placeholder:o.value?"描述你要完成的目标,Enter 创建并开始执行…":"输入 @ 引用知识库 / 使用技能 / 或者直接提问...",onSend:r[1]||(r[1]=a=>s("send",a,n.mode)),onCommand:r[2]||(r[2]=(a,c)=>s("command",a,c)),onSwitchModel:r[3]||(r[3]=a=>s("switch-model",a)),onSwitchThinking:r[4]||(r[4]=a=>s("switch-thinking",a))},null,8,["busy","status","models","placeholder"])])]))}}),hR=Ie(fR,[["__scopeId","data-v-2f5f04ab"]]),pR=["aria-valuenow"],gR={key:2,class:"sidebar-mobile"},mR={class:"canvas"},vR={class:"topbar mobile-only"},yR={class:"topbar-left"},bR={key:0,class:"topbar-running",title:"Agent 运行中"},kR={class:"canvas-body"},wR=["aria-valuenow"],_R={class:"right-panel-head"},SR={class:"right-panel-body"},kc="scream-sidebar-collapsed",wc="scream-sidebar-width",So=180,$R=480,_c=288,Sc="scream-right-panel-width",$c="scream-workspace-mode",xR=Te({__name:"WebShell",setup(e){const t=rm(),{showToast:n}=ar(),{connectionStatus:s,status:o,isBusy:i,sessions:l,currentSessionId:r,workDir:a,gitStatus:c,models:u,like:f,sendPrompt:h,sendCommand:p,appendSystemMessage:v,createSession:k,switchSession:w,deleteSession:S,switchModel:$,switchThinking:E,fetchLike:L,fetchGitStatus:Z,abort:j}=t,C=F("home"),x=F(!1),y=F(null);function T(ne=8e3){return s.value==="connected"?Promise.resolve(!0):new Promise(be=>{const Et=Date.now(),Ye=window.setInterval(()=>{s.value==="connected"?(window.clearInterval(Ye),be(!0)):Date.now()-Et>ne&&(window.clearInterval(Ye),be(!1))},80)})}function D(ne){ne==="chat"?r.value?C.value="chat":I():C.value=ne,x.value=!1}function I(){x.value=!1,C.value="chat",k()}async function H(ne,be){if(x.value=!1,r.value||await k(),!!await T())if(C.value="chat",be==="goal")try{await t.createGoal({objective:ne,budgets:[]})}catch(Ye){v(`Goal 创建失败:${O(Ye)}。已保留对话模式,可重新发送。`),h(ne);return}else h(ne)}function O(ne){return ne instanceof Error?ne.message:String(ne)}function B(ne){x.value=!1,C.value="chat",w(ne)}function te(ne){Zn(ne)}function oe(ne,be){if(ne!==r.value){n("请先点击该会话,再双击重命名。","warning");return}p("title",be)}function _e(ne,be){switch(ne){case"compact":case"auto":case"yes":case"plan":case"fork":case"title":case"btw":if(!r.value){k().then(()=>p(ne,be));return}p(ne,be);break;case"clear":t.clearMessages();break;case"new":I();break;case"help":v(Yu());break;case"model":v(`当前模型:${o.value.model??"unknown"}`);break;case"status":case"usage":v("请在对话页查看会话详情");break;default:v(`未知命令:/${ne}`)}}const Se=F(!1);try{Se.value=localStorage.getItem(kc)==="1"}catch{}function je(){Se.value=!Se.value;try{localStorage.setItem(kc,Se.value?"1":"0")}catch{}}function Qe(){try{const ne=Number(localStorage.getItem(wc));if(Number.isFinite(ne)&&ne>=So&&ne<=$R)return Math.round(ne)}catch{}return _c}const ge=F(Qe()),he=F(!1);let Fe=null;function K(){try{localStorage.setItem(wc,String(ge.value))}catch{}}function ae(ne){if(!Se.value){ne.preventDefault(),he.value=!0,Fe=ne.pointerId;try{ne.currentTarget.setPointerCapture(ne.pointerId)}catch{}}}function V(ne){if(!he.value||ne.pointerId!==Fe)return;const be=Pa({viewportWidth:Pe.value,rightPanelOpen:$e.panelOpen,rightPanelWidth:Le.value});ge.value=Math.min(be,Math.max(So,Math.round(ne.clientX)))}function ve(ne){!he.value||ne.pointerId!==Fe||(he.value=!1,Fe=null,K())}function Oe(){ge.value=_c,K()}function Ue(ne){const be=ne.shiftKey?32:12,Et=Pa({viewportWidth:Pe.value,rightPanelOpen:$e.panelOpen,rightPanelWidth:Le.value});if(ne.key==="ArrowLeft")ne.preventDefault(),ge.value=Math.max(So,ge.value-be);else if(ne.key==="ArrowRight")ne.preventDefault(),ge.value=Math.min(Et,ge.value+be);else if(ne.key==="Home")ne.preventDefault(),ge.value=So;else if(ne.key==="End")ne.preventDefault(),ge.value=Et;else if(ne.key==="Enter")ne.preventDefault(),Oe();else return;K()}const Pe=F(window.innerWidth),_=q(()=>Pe.value>=cr);function M(){try{const ne=Number(localStorage.getItem(Sc));if(Number.isFinite(ne)&&ne>=Aa)return Math.round(ne)}catch{}return null}const G=F(M()??Ea(window.innerWidth)),Q=F(!1);let Y=null;function X(ne){const be=fm({viewportWidth:Pe.value,sidebarOpen:!Se.value,sidebarWidth:ge.value});return Ju(ne,Aa,be)}function ie(){try{localStorage.setItem(Sc,String(G.value))}catch{}}function ce(ne){ne.preventDefault(),Q.value=!0,Y=ne.pointerId;try{ne.currentTarget.setPointerCapture(ne.pointerId)}catch{}}function A(ne){!Q.value||ne.pointerId!==Y||(G.value=X(window.innerWidth-ne.clientX))}function N(ne){!Q.value||ne.pointerId!==Y||(Q.value=!1,Y=null,ie())}function ue(){G.value=X(Ea(Pe.value)),ie()}function de(ne){const be=ne.shiftKey?32:12;if(ne.key==="ArrowLeft")ne.preventDefault(),G.value=X(G.value+be);else if(ne.key==="ArrowRight")ne.preventDefault(),G.value=X(G.value-be);else if(ne.key==="Enter")ne.preventDefault(),ue();else return;ie()}function pe(){Qu(!1)}function ye(){Pe.value=window.innerWidth}Ee(_,()=>{Q.value&&(Q.value=!1,Y=null,ie())});const Le=q(()=>X(G.value)),De=q(()=>({"--sidebar-width":`${ge.value}px`,"--right-panel-width":`${Le.value}px`}));function Ne(){try{return localStorage.getItem($c)==="goal"?"goal":"chat"}catch{return"chat"}}const Ke=F(Ne());function ot(ne){Ke.value=ne;try{localStorage.setItem($c,ne)}catch{}}function bt(ne){if((ne.metaKey||ne.ctrlKey)&&ne.key==="k")ne.preventDefault(),Se.value&&je(),ft(()=>{var be;return(be=y.value)==null?void 0:be.focusSearch()});else if((ne.metaKey||ne.ctrlKey)&&ne.key==="n")ne.preventDefault(),I();else if(ne.key==="Escape"&&i.value){const be=ne.target;be&&(be.tagName==="TEXTAREA"||be.tagName==="INPUT")||(ne.preventDefault(),j())}}return ct(()=>{window.addEventListener("keydown",bt),window.addEventListener("resize",ye),L(),Z()}),Ct(()=>{window.removeEventListener("keydown",bt),window.removeEventListener("resize",ye)}),(ne,be)=>(g(),m("div",{class:fe(["shell",{"sidebar-collapsed":Se.value,resizing:he.value||Q.value,"right-panel-open":W($e).panelOpen&&_.value}]),style:Nt(De.value)},[J(bc,{ref_key:"sidebarRef",ref:y,view:C.value,sessions:W(l),"current-session-id":W(r),"work-dir":W(a),"git-status":W(c),"refresh-git":W(Z),collapsed:Se.value,onNavigate:D,onSwitchSession:B,onDeleteSession:W(S),onCreateSession:I,onToggleCollapse:je,onOpenFile:te,onRenameSession:oe},null,8,["view","sessions","current-session-id","work-dir","git-status","refresh-git","collapsed","onDeleteSession"]),Se.value?U("",!0):(g(),m("div",{key:0,class:fe(["sidebar-resize-handle",{resizing:he.value}]),role:"separator","aria-orientation":"vertical","aria-label":"调整侧栏宽度","aria-valuenow":ge.value,"aria-valuemin":"180","aria-valuemax":"480",tabindex:"0",title:"拖拽调整宽度 · 双击复位",onPointerdown:ae,onPointermove:V,onPointerup:ve,onPointercancel:ve,onDblclick:Oe,onKeydown:Ue},null,42,pR)),x.value?(g(),m("div",{key:1,class:"sidebar-backdrop","aria-hidden":"true",onClick:be[0]||(be[0]=Et=>x.value=!1)})):U("",!0),x.value?(g(),m("div",gR,[J(bc,{view:C.value,sessions:W(l),"current-session-id":W(r),"work-dir":W(a),"git-status":W(c),"refresh-git":W(Z),"show-collapse-toggle":!1,onNavigate:D,onSwitchSession:B,onDeleteSession:W(S),onCreateSession:I,onOpenFile:te,onRenameSession:oe},null,8,["view","sessions","current-session-id","work-dir","git-status","refresh-git","onDeleteSession"])])):U("",!0),d("main",mR,[d("header",vR,[d("div",yR,[d("button",{class:"topbar-icon mobile-menu",title:"菜单","aria-label":"打开菜单",onClick:be[1]||(be[1]=Et=>x.value=!0)},[J(me,{name:"menu",size:20})]),W(i)?(g(),m("span",bR,[...be[3]||(be[3]=[d("span",{class:"running-dot","aria-hidden":"true"},null,-1),d("span",{class:"running-text"},"运行中",-1)])])):U("",!0)])]),d("div",kR,[C.value==="home"?(g(),Xe(hR,{key:0,models:W(u),status:W(o),busy:W(i),mode:Ke.value,"onUpdate:mode":ot,onSend:H,onCommand:_e,onSwitchModel:W($),onSwitchThinking:W(E)},null,8,["models","status","busy","mode","onSwitchModel","onSwitchThinking"])):C.value==="chat"?(g(),Xe(nT,{key:1,client:W(t),onHome:be[2]||(be[2]=Et=>C.value="home")},null,8,["client"])):C.value==="skills"?(g(),Xe(ZI,{key:2,onCreate:I})):C.value==="settings"?(g(),Xe(H2,{key:3,like:W(f),client:W(t),onUpdateLike:W(t).updateLike},null,8,["like","client","onUpdateLike"])):U("",!0)])]),W($e).panelOpen&&!_.value?(g(),m("div",{key:3,class:"right-panel-backdrop","aria-hidden":"true",onClick:pe})):U("",!0),W($e).panelOpen&&_.value?(g(),m("div",{key:4,class:fe(["right-resize-handle",{resizing:Q.value}]),role:"separator","aria-orientation":"vertical","aria-label":"调整文件面板宽度","aria-valuenow":Le.value,tabindex:"0",title:"拖拽调整宽度 · 双击复位",onPointerdown:ce,onPointermove:A,onPointerup:N,onPointercancel:N,onDblclick:ue,onKeydown:de},null,42,wR)):U("",!0),W($e).panelOpen?(g(),m("aside",{key:5,class:fe(["right-panel",{overlay:!_.value}]),"aria-label":"文件面板"},[d("div",_R,[J(tR),d("button",{class:"right-panel-close",title:"收起文件面板","aria-label":"收起文件面板",onClick:pe},[J(me,{name:"chevron-right",size:16})])]),d("div",SR,[J(PT,{client:W(t)},null,8,["client"])])],2)):U("",!0)],6))}}),CR=Ie(xR,[["__scopeId","data-v-6c995f44"]]),TR=["src","alt"],IR={key:1,class:"lightbox-note",role:"alert"},RR=Te({__name:"ImageLightbox",setup(e){const t=F(null),n=F(!1);Ee(()=>In.open,i=>{const l=t.value;l&&(i?(n.value=!1,l.open||l.showModal()):l.open&&l.close())});function s(i){i.preventDefault(),ol()}function o(i){i.target===t.value&&ol()}return(i,l)=>(g(),m("dialog",{ref_key:"dialogRef",ref:t,class:"image-lightbox","aria-label":"图片预览",onCancel:s,onClick:o},[W(In).open?(g(),m("img",{key:0,class:"lightbox-img",src:W(In).src,alt:W(In).alt||"图片预览",onError:l[0]||(l[0]=r=>n.value=!0)},null,40,TR)):U("",!0),n.value?(g(),m("p",IR,"图片加载失败")):U("",!0),d("button",{type:"button",class:"lightbox-close","aria-label":"关闭预览",title:"关闭(Esc)",onClick:l[1]||(l[1]=r=>W(ol)())},[J(me,{name:"x",size:16})])],544))}}),AR=Ie(RR,[["__scopeId","data-v-7d7939d6"]]),MR={class:"toast-container"},ER=["onClick"],PR={class:"toast-icon"},LR={class:"toast-msg"},OR=Te({__name:"Toast",setup(e){const{toasts:t,removeToast:n}=ar(),s={info:"ℹ",success:"✓",error:"✗",warning:"⚠"};return(o,i)=>(g(),Xe(tr,{to:"body"},[d("div",MR,[J(Pg,{name:"toast"},{default:Pt(()=>[(g(!0),m(ee,null,Me(W(t),l=>(g(),m("div",{key:l.id,class:fe(["toast",`toast--${l.type}`]),onClick:r=>W(n)(l.id)},[d("span",PR,R(s[l.type]),1),d("span",LR,R(l.message),1)],10,ER))),128))]),_:1})])]))}}),DR=Ie(OR,[["__scopeId","data-v-a432e638"]]),NR={class:"app"},BR=Te({__name:"App",setup(e){const t=F("system"),n=F("dark");xo("effectiveTheme",n),xo("theme",t);const s={light:"#ffffff",dark:"#101113"};function o(){const a=document.documentElement,c=window.matchMedia("(prefers-color-scheme: dark)").matches,u=t.value==="system"?c?"dark":"light":t.value;n.value=u,a.dataset.theme=u;const f=document.querySelector('meta[name="theme-color"]');f&&f.setAttribute("content",s[u])}let i=null;function l(a){const c=t.value;t.value=a;try{localStorage.setItem("scream-theme",a)}catch{}if(c===a)return;const u=document.documentElement,f=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,h=()=>{u.classList.add("theme-transition"),o(),i!==null&&clearTimeout(i),i=window.setTimeout(()=>u.classList.remove("theme-transition"),320)},p=document;if(typeof p.startViewTransition=="function"&&!f){p.startViewTransition(()=>{o()}).finished.then(()=>u.classList.remove("theme-transition"),()=>{u.classList.remove("theme-transition")});return}h()}xo("setTheme",l),ct(()=>{try{const a=localStorage.getItem("scream-theme");(a==="light"||a==="dark"||a==="system")&&(t.value=a)}catch{}o()}),Ee(t,o);const r=window.matchMedia("(prefers-color-scheme: dark)");return r.addEventListener("change",o),Ct(()=>{r.removeEventListener("change",o),i!==null&&clearTimeout(i),document.documentElement.classList.remove("theme-transition")}),(a,c)=>(g(),m("div",NR,[J(CR),J(AR),J(DR)]))}}),FR=Ie(BR,[["__scopeId","data-v-5c26ee23"]]);Hg(FR).mount("#app");
|
|
96
|
-
//# sourceMappingURL=index-
|
|
96
|
+
//# sourceMappingURL=index-Bvn-ixUo.js.map
|