scream-code 0.18.3 → 0.18.6

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.
@@ -16,7 +16,7 @@ var tg=Object.defineProperty;var ng=Object.getPrototypeOf;var sg=Reflect.get;var
16
16
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
17
17
  * @license MIT
18
18
  **/let Ua;const Wu=typeof window<"u"&&window.trustedTypes;if(Wu)try{Ua=Wu.createPolicy("vue",{createHTML:e=>e})}catch{}const Xf=Ua?e=>Ua.createHTML(e):e=>e,Qm="http://www.w3.org/2000/svg",ev="http://www.w3.org/1998/Math/MathML",mn=typeof document<"u"?document:null,qu=mn&&mn.createElement("template"),tv={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"?mn.createElementNS(Qm,e):t==="mathml"?mn.createElementNS(ev,e):n?mn.createElement(e,{is:n}):mn.createElement(e);return e==="select"&&s&&s.multiple!=null&&o.setAttribute("multiple",s.multiple),o},createText:e=>mn.createTextNode(e),createComment:e=>mn.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>mn.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,s,o,r){const i=n?n.previousSibling:t.lastChild;if(o&&(o===r||o.nextSibling))for(;t.insertBefore(o.cloneNode(!0),n),!(o===r||!(o=o.nextSibling)););else{qu.innerHTML=Xf(s==="svg"?`<svg>${e}</svg>`:s==="mathml"?`<math>${e}</math>`:e);const a=qu.content;if(s==="svg"||s==="mathml"){const l=a.firstChild;for(;l.firstChild;)a.appendChild(l.firstChild);a.removeChild(l)}t.insertBefore(a,n)}return[i?i.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},Ln="transition",lo="animation",Ys=Symbol("_vtc"),Jf={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},Qf=ct({},kf,Jf),nv=e=>(e.displayName="Transition",e.props=Qf,e),Ol=nv((e,{slots:t})=>ze(nm,eh(e),t)),Qn=(e,t=[])=>{xe(e)?e.forEach(n=>n(...t)):e&&e(...t)},Vu=e=>e?xe(e)?e.some(t=>t.length>1):e.length>1:!1;function eh(e){const t={};for(const j in e)j in Jf||(t[j]=e[j]);if(e.css===!1)return t;const{name:n="v",type:s,duration:o,enterFromClass:r=`${n}-enter-from`,enterActiveClass:i=`${n}-enter-active`,enterToClass:a=`${n}-enter-to`,appearFromClass:l=r,appearActiveClass:u=i,appearToClass:c=a,leaveFromClass:d=`${n}-leave-from`,leaveActiveClass:f=`${n}-leave-active`,leaveToClass:p=`${n}-leave-to`}=e,g=sv(o),b=g&&g[0],S=g&&g[1],{onBeforeEnter:w,onEnter:k,onEnterCancelled:y,onLeave:_,onLeaveCancelled:N,onBeforeAppear:D=w,onAppear:E=k,onAppearCancelled:A=y}=t,T=(j,ne,I,M)=>{j._enterCancelled=M,Nn(j,ne?c:a),Nn(j,ne?u:i),I&&I()},Z=(j,ne)=>{j._isLeaving=!1,Nn(j,d),Nn(j,p),Nn(j,f),ne&&ne()},W=j=>(ne,I)=>{const M=j?E:k,V=()=>T(ne,j,I);Qn(M,[ne,V]),Ku(()=>{Nn(ne,j?l:r),an(ne,j?c:a),Vu(M)||Zu(ne,s,b,V)})};return ct(t,{onBeforeEnter(j){Qn(w,[j]),an(j,r),an(j,i)},onBeforeAppear(j){Qn(D,[j]),an(j,l),an(j,u)},onEnter:W(!1),onAppear:W(!0),onLeave(j,ne){j._isLeaving=!0;const I=()=>Z(j,ne);an(j,d),j._enterCancelled?(an(j,f),ja(j)):(ja(j),an(j,f)),Ku(()=>{j._isLeaving&&(Nn(j,d),an(j,p),Vu(_)||Zu(j,s,S,I))}),Qn(_,[j,I])},onEnterCancelled(j){T(j,!1,void 0,!0),Qn(y,[j])},onAppearCancelled(j){T(j,!0,void 0,!0),Qn(A,[j])},onLeaveCancelled(j){Z(j),Qn(N,[j])}})}function sv(e){if(e==null)return null;if(qe(e))return[Qi(e.enter),Qi(e.leave)];{const t=Qi(e);return[t,t]}}function Qi(e){return ug(e)}function an(e,t){t.split(/\s+/).forEach(n=>n&&e.classList.add(n)),(e[Ys]||(e[Ys]=new Set)).add(t)}function Nn(e,t){t.split(/\s+/).forEach(s=>s&&e.classList.remove(s));const n=e[Ys];n&&(n.delete(t),n.size||(e[Ys]=void 0))}function Ku(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}let ov=0;function Zu(e,t,n,s){const o=e._endId=++ov,r=()=>{o===e._endId&&s()};if(n!=null)return setTimeout(r,n);const{type:i,timeout:a,propCount:l}=th(e,t);if(!i)return s();const u=i+"end";let c=0;const d=()=>{e.removeEventListener(u,f),r()},f=p=>{p.target===e&&++c>=l&&d()};setTimeout(()=>{c<l&&d()},a+1),e.addEventListener(u,f)}function th(e,t){const n=window.getComputedStyle(e),s=g=>(n[g]||"").split(", "),o=s(`${Ln}Delay`),r=s(`${Ln}Duration`),i=Yu(o,r),a=s(`${lo}Delay`),l=s(`${lo}Duration`),u=Yu(a,l);let c=null,d=0,f=0;t===Ln?i>0&&(c=Ln,d=i,f=r.length):t===lo?u>0&&(c=lo,d=u,f=l.length):(d=Math.max(i,u),c=d>0?i>u?Ln:lo:null,f=c?c===Ln?r.length:l.length:0);const p=c===Ln&&/\b(?:transform|all)(?:,|$)/.test(s(`${Ln}Property`).toString());return{type:c,timeout:d,propCount:f,hasTransform:p}}function Yu(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max(...t.map((n,s)=>Xu(n)+Xu(e[s])))}function Xu(e){return e==="auto"?0:Number(e.slice(0,-1).replace(",","."))*1e3}function ja(e){return(e?e.ownerDocument:document).body.offsetHeight}function rv(e,t,n){const s=e[Ys];s&&(t=(t?[t,...s]:[...s]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}const Br=Symbol("_vod"),Gl=Symbol("_vsh"),Fr={name:"show",beforeMount(e,{value:t},{transition:n}){e[Br]=e.style.display==="none"?"":e.style.display,n&&t?n.beforeEnter(e):uo(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),uo(e,!0),s.enter(e)):s.leave(e,()=>{uo(e,!1)}):uo(e,t))},beforeUnmount(e,{value:t}){uo(e,t)}};function uo(e,t){e.style.display=t?e[Br]:"none",e[Gl]=!t}const nh=Symbol("");function iv(e){const t=Ii();if(!t)return;const n=t.ut=(o=e(t.proxy))=>{Array.from(document.querySelectorAll(`[data-v-owner="${t.uid}"]`)).forEach(r=>Ur(r,o))},s=()=>{const o=e(t.proxy);t.ce?Ur(t.ce,o):za(t.subTree,o),n(o)};xf(()=>{df(s)}),et(()=>{Se(s,Jt,{flush:"post"});const o=new MutationObserver(s);o.observe(t.subTree.el.parentNode,{childList:!0}),$i(()=>o.disconnect())})}function za(e,t){if(e.shapeFlag&128){const n=e.suspense;e=n.activeBranch,n.pendingBranch&&!n.isHydrating&&n.effects.push(()=>{za(n.activeBranch,t)})}for(;e.component;)e=e.component.subTree;if(e.shapeFlag&1&&e.el)Ur(e.el,t);else if(e.type===te)e.children.forEach(n=>za(n,t));else if(e.type===br){let{el:n,anchor:s}=e;for(;n&&(Ur(n,t),n!==s);)n=n.nextSibling}}function Ur(e,t){if(e.nodeType===1){const n=e.style;let s="";for(const o in t){const r=yg(t[o]);n.setProperty(`--${o}`,r),s+=`--${o}: ${r};`}n[nh]=s}}const av=/(?:^|;)\s*display\s*:/;function lv(e,t,n){const s=e.style,o=nt(n);let r=!1;if(n&&!o){if(t)if(nt(t))for(const i of t.split(";")){const a=i.slice(0,i.indexOf(":")).trim();n[a]==null&&yo(s,a,"")}else for(const i in t)n[i]==null&&yo(s,i,"");for(const i in n){i==="display"&&(r=!0);const a=n[i];a!=null?cv(e,i,!nt(t)&&t?t[i]:void 0,a)||yo(s,i,a):yo(s,i,"")}}else if(o){if(t!==n){const i=s[nh];i&&(n+=";"+i),s.cssText=n,r=av.test(n)}}else t&&e.removeAttribute("style");Br in e&&(e[Br]=r?s.display:"",e[Gl]&&(s.display="none"))}const Ju=/\s*!important$/;function yo(e,t,n){if(xe(n))n.forEach(s=>yo(e,t,s));else if(n==null&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const s=uv(e,t);Ju.test(n)?e.setProperty(Kn(s),n.replace(Ju,""),"important"):e[s]=n}}const Qu=["Webkit","Moz","ms"],ea={};function uv(e,t){const n=ea[t];if(n)return n;let s=Lt(t);if(s!=="filter"&&s in e)return ea[t]=s;s=vi(s);for(let o=0;o<Qu.length;o++){const r=Qu[o]+s;if(r in e)return ea[t]=r}return t}function cv(e,t,n,s){return e.tagName==="TEXTAREA"&&(t==="width"||t==="height")&&nt(s)&&n===s}const ec="http://www.w3.org/1999/xlink";function tc(e,t,n,s,o,r=gg(t)){s&&t.startsWith("xlink:")?n==null?e.removeAttributeNS(ec,t.slice(6,t.length)):e.setAttributeNS(ec,t,n):n==null||r&&!zd(n)?e.removeAttribute(t):e.setAttribute(t,r?"":tn(n)?String(n):n)}function nc(e,t,n,s,o){if(t==="innerHTML"||t==="textContent"){n!=null&&(e[t]=t==="innerHTML"?Xf(n):n);return}const r=e.tagName;if(t==="value"&&r!=="PROGRESS"&&!r.includes("-")){const a=r==="OPTION"?e.getAttribute("value")||"":e.value,l=n==null?e.type==="checkbox"?"on":"":String(n);(a!==l||!("_value"in e))&&(e.value=l),n==null&&e.removeAttribute(t),e._value=n;return}let i=!1;if(n===""||n==null){const a=typeof e[t];a==="boolean"?n=zd(n):n==null&&a==="string"?(n="",i=!0):a==="number"&&(n=0,i=!0)}try{e[t]=n}catch{}i&&e.removeAttribute(o||t)}function as(e,t,n,s){e.addEventListener(t,n,s)}function dv(e,t,n,s){e.removeEventListener(t,n,s)}const sc=Symbol("_vei");function fv(e,t,n,s,o=null){const r=e[sc]||(e[sc]={}),i=r[t];if(s&&i)i.value=s;else{const[a,l]=gv(t);if(s){const u=r[t]=yv(s,o);as(e,a,u,l)}else i&&(dv(e,a,i,l),r[t]=void 0)}}const hv=/(Once|Passive|Capture)$/,pv=/^on:?(?:Once|Passive|Capture)$/;function gv(e){let t,n;for(;(n=e.match(hv))&&!pv.test(e);)t||(t={}),e=e.slice(0,e.length-n[1].length),t[n[1].toLowerCase()]=!0;return[e[2]===":"?e.slice(3):Kn(e.slice(2)),t]}let ta=0;const mv=Promise.resolve(),vv=()=>ta||(mv.then(()=>ta=0),ta=Date.now());function yv(e,t){const n=s=>{if(!s._vts)s._vts=Date.now();else if(s._vts<=n.attached)return;const o=n.value;if(xe(o)){const r=s.stopImmediatePropagation;s.stopImmediatePropagation=()=>{r.call(s),s._stopped=!0};const i=o.slice(),a=[s];for(let l=0;l<i.length&&!s._stopped;l++){const u=i[l];u&&Vt(u,t,5,a)}}else Vt(o,t,5,[s])};return n.value=e,n.attached=vv(),n}const oc=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,bv=(e,t,n,s,o,r)=>{const i=o==="svg";t==="class"?rv(e,s,i):t==="style"?lv(e,n,s):hi(t)?pi(t)||fv(e,t,n,s,r):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):kv(e,t,s,i))?(nc(e,t,s),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&tc(e,t,s,i,r,t!=="value")):e._isVueCE&&(wv(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!nt(s)))?nc(e,Lt(t),s,r,t):(t==="true-value"?e._trueValue=s:t==="false-value"&&(e._falseValue=s),tc(e,t,s,i))};function kv(e,t,n,s){if(s)return!!(t==="innerHTML"||t==="textContent"||t in e&&oc(t)&&Pe(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 oc(t)&&nt(n)?!1:t in e}function wv(e,t){const n=e._def.props;if(!n)return!1;const s=Lt(t);return Array.isArray(n)?n.some(o=>Lt(o)===s):Object.keys(n).some(o=>Lt(o)===s)}const sh=new WeakMap,oh=new WeakMap,jr=Symbol("_moveCb"),rc=Symbol("_enterCb"),Sv=e=>(delete e.props.mode,e),_v=Sv({name:"TransitionGroup",props:ct({},Qf,{tag:String,moveClass:String}),setup(e,{slots:t}){const n=Ii(),s=bf();let o,r;return Rl(()=>{if(!o.length)return;const i=e.moveClass||`${e.name||"v"}-move`;if(!Tv(o[0].el,n.vnode.el,i)){o=[];return}o.forEach(Cv),o.forEach(xv);const a=o.filter(Iv);ja(n.vnode.el),a.forEach(l=>{const u=l.el,c=u.style;an(u,i),c.transform=c.webkitTransform=c.transitionDuration="";const d=u[jr]=f=>{f&&f.target!==u||(!f||f.propertyName.endsWith("transform"))&&(u.removeEventListener("transitionend",d),u[jr]=null,Nn(u,i))};u.addEventListener("transitionend",d)}),o=[]}),()=>{const i=je(e),a=eh(i);let l=i.tag||te;if(o=[],r)for(let u=0;u<r.length;u++){const c=r[u];c.el&&c.el instanceof Element&&!c.el[Gl]&&(o.push(c),ms(c,Lo(c,a,s,n)),sh.set(c,rh(c.el)))}r=t.default?Ml(t.default()):[];for(let u=0;u<r.length;u++){const c=r[u];c.key!=null&&ms(c,Lo(c,a,s,n))}return X(l,null,r)}}}),$v=_v;function Cv(e){const t=e.el;t[jr]&&t[jr](),t[rc]&&t[rc]()}function xv(e){oh.set(e,rh(e.el))}function Iv(e){const t=sh.get(e),n=oh.get(e),s=t.left-n.left,o=t.top-n.top;if(s||o){const r=e.el,i=r.style,a=r.getBoundingClientRect();let l=1,u=1;return r.offsetWidth&&(l=a.width/r.offsetWidth),r.offsetHeight&&(u=a.height/r.offsetHeight),(!Number.isFinite(l)||l===0)&&(l=1),(!Number.isFinite(u)||u===0)&&(u=1),Math.abs(l-1)<.01&&(l=1),Math.abs(u-1)<.01&&(u=1),i.transform=i.webkitTransform=`translate(${s/l}px,${o/u}px)`,i.transitionDuration="0s",e}}function rh(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top}}function Tv(e,t,n){const s=e.cloneNode(),o=e[Ys];o&&o.forEach(a=>{a.split(/\s+/).forEach(l=>l&&s.classList.remove(l))}),n.split(/\s+/).forEach(a=>a&&s.classList.add(a)),s.style.display="none";const r=t.nodeType===1?t:t.parentNode;r.appendChild(s);const{hasTransform:i}=th(s);return r.removeChild(s),i}const zr=e=>{const t=e.props["onUpdate:modelValue"]||!1;return xe(t)?n=>vr(t,n):t};function Ev(e){e.target.composing=!0}function ic(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const zs=Symbol("_assign");function ac(e,t,n){return t&&(e=e.trim()),n&&(e=yi(e)),e}const it={created(e,{modifiers:{lazy:t,trim:n,number:s}},o){e[zs]=zr(o);const r=s||o.props&&o.props.type==="number";as(e,t?"change":"input",i=>{i.target.composing||e[zs](ac(e.value,n,r))}),(n||r)&&as(e,"change",()=>{e.value=ac(e.value,n,r)}),t||(as(e,"compositionstart",Ev),as(e,"compositionend",ic),as(e,"change",ic))},mounted(e,{value:t}){e.value=t??""},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:s,trim:o,number:r}},i){if(e[zs]=zr(i),e.composing)return;const a=(r||e.type==="number")&&!/^0\d/.test(e.value)?yi(e.value):e.value,l=t??"";if(a===l)return;const u=e.getRootNode();(u instanceof Document||u instanceof ShadowRoot)&&u.activeElement===e&&e.type!=="range"&&(s&&t===n||o&&e.value.trim()===l)||(e.value=l)}},lc={deep:!0,created(e,{value:t,modifiers:{number:n}},s){e._modelValue=t,as(e,"change",()=>{const o=Array.prototype.filter.call(e.options,r=>r.selected).map(r=>n?yi(Hr(r)):Hr(r));e[zs](e.multiple?gi(e._modelValue)?new Set(o):o:o[0]),e._assigning=!0,Fe(()=>{e._assigning=!1})}),e[zs]=zr(s)},mounted(e,{value:t}){uc(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[zs]=zr(n)},updated(e,{value:t}){e._assigning||uc(e,t)}};function uc(e,t){const n=e.multiple,s=xe(t);if(!(n&&!s&&!gi(t))){for(let o=0,r=e.options.length;o<r;o++){const i=e.options[o],a=Hr(i);if(n)if(s){const l=typeof a;l==="string"||l==="number"?i.selected=t.some(u=>String(u)===String(a)):i.selected=vg(t,a)>-1}else i.selected=t.has(a);else if(qo(Hr(i),t)){e.selectedIndex!==o&&(e.selectedIndex=o);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function Hr(e){return"_value"in e?e._value:e.value}const Av=["ctrl","shift","alt","meta"],Mv={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)=>Av.some(n=>e[`${n}Key`]&&!t.includes(n))},tt=(e,t)=>{if(!e)return e;const n=e._withMods||(e._withMods={}),s=t.join(".");return n[s]||(n[s]=((o,...r)=>{for(let i=0;i<t.length;i++){const a=Mv[t[i]];if(a&&a(o,t))return}return e(o,...r)}))},Rv={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 r=Kn(o.key);if(t.some(i=>i===r||Rv[i]===r))return e(o)}))},Pv=ct({patchProp:bv},tv);let cc;function Lv(){return cc||(cc=Dm(Pv))}const Dv=((...e)=>{const t=Lv().createApp(...e),{mount:n}=t;return t.mount=s=>{const o=Ov(s);if(!o)return;const r=t._component;!Pe(r)&&!r.render&&!r.template&&(r.template=o.innerHTML),o.nodeType===1&&(o.textContent="");const i=n(o,!1,Nv(o));return o instanceof Element&&(o.removeAttribute("v-cloak"),o.setAttribute("data-v-app","")),i},t});function Nv(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function Ov(e){return nt(e)?document.querySelector(e):e}const Wr=[{name:"model",description:"切换模型 / 思考强度",target:"local",group:"core"},{name:"new",description:"新建会话",target:"local",group:"core"},{name:"clear",description:"清空本地消息列表",target:"local",group:"core"},{name:"help",description:"显示可用命令",target:"local",group:"core"},{name:"compact",description:"压缩会话上下文",target:"backend",group:"core"},{name:"title",description:"重命名当前会话",target:"backend",aliases:["rename"],acceptsInput:!0,group:"core"},{name:"btw",description:"快速侧问(不打断当前回合)",target:"backend",acceptsInput:!0,group:"core"},{name:"auto",description:"切换为 auto 权限模式",target:"backend",group:"advanced"},{name:"ask",description:"切换为询问权限模式",target:"backend",group:"advanced"},{name:"yes",description:"切换为 yolo 权限模式",target:"backend",aliases:["yolo"],group:"advanced"},{name:"bot",description:"切换为 Bot 无人值守模式",target:"backend",group:"advanced"},{name:"plan",description:"切换计划模式",target:"backend",group:"advanced"},{name:"fusionplan",description:"切换融合计划模式",target:"local",aliases:["fp"],acceptsInput:!0,group:"advanced"},{name:"wolfpack",description:"切换 Wolfpack 多代理模式",target:"local",aliases:["wp"],acceptsInput:!0,group:"advanced"},{name:"rlm",description:"切换 RLM Python 内核模式",target:"local",acceptsInput:!0,group:"advanced"},{name:"rlm-max-depth",description:"设置 RLM 递归最大深度",target:"local",acceptsInput:!0,group:"advanced"},{name:"revoke",description:"撤销最近一轮消息",target:"local",acceptsInput:!0,group:"advanced"},{name:"fork",description:"复制当前会话为新分支",target:"backend",group:"advanced"},{name:"status",description:"查看会话状态",target:"local",group:"advanced"},{name:"usage",description:"查看 Token 用量",target:"local",group:"advanced"}],Hs=G([]);function dc(e){Hs.value=[...e]}const Io=G("");function Gv(e){Io.value=e.trim().toLowerCase()}function Bv(){Io.value=""}const Fv=8,ih=G(!1);function Uv(){return ih.value}function fc(e,t){var n;return t?e.name.startsWith(t)||((n=e.aliases)==null?void 0:n.some(s=>s.startsWith(t)))===!0||e.description.includes(t):!0}function hc(e,t){return t?e.name.toLowerCase().startsWith(t)||e.name.includes(t)||e.description.includes(t):!0}function jv(e){const t=(e||"").toLowerCase(),n=t===""&&Io.value==="";ih.value=n;const s=Wr.filter(r=>fc(r,t)&&fc(r,Io.value)).filter(r=>!n||r.group!=="advanced"),o=Hs.value.filter(r=>hc(r,t)&&hc(r,Io.value)).map(r=>({name:r.name,description:r.description||"技能",target:"local",acceptsInput:!0,kind:"skill",source:r.pluginId?`plugin:${r.pluginId}`:r.source}));return[...s,...o]}function zv(e){const t=e.toLowerCase(),n=Wr.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 Hv(e){const t=e.toLowerCase();return Hs.value.some(n=>n.name.toLowerCase()===t)}function Wv(){const e=o=>{var i;return`${(i=o.aliases)!=null&&i.length?[o.name,...o.aliases].map(a=>`/${a}`).join(", "):`/${o.name}`} - ${o.description}`},t=Wr.filter(o=>o.group!=="advanced"),n=Wr.filter(o=>o.group==="advanced"),s=["常用:",...t.map(e),"高级:",...n.map(e)];return Hs.value.length>0&&s.push("",`技能 ${Hs.value.length} 个(输入 / 后在菜单中查看,或前往技能中心):`,...Hs.value.map(o=>`/${o.name} - ${o.description||"技能"}`)),["可用命令:",...s].join(`
19
- `)}let qr=null;const Bl=Fg(null);function qv(e){qr=e,Bl.value=e}function Vv(e){qr===e&&(qr=null,Bl.value=null)}function Ha(){return qr}function Kv(){return{activeClient:Bl}}const No=G([]);let Zv=0;function Yv(e,t="info",n=3500){const s=`toast_${++Zv}`;No.value=[...No.value,{id:s,type:t,message:e}],n>0&&setTimeout(()=>ah(s),n)}function ah(e){No.value=No.value.filter(t=>t.id!==e)}function Qs(){return{toasts:No,showToast:Yv,removeToast:ah}}const Ge="/api/v1",Xv=2*3e4,pc=8;function ft(e){const t=e.sessionId.value;return t?{sessionId:t,sessionGeneration:e.sessionGeneration,connectionGeneration:e.connectionGeneration}:null}function Ei(e,t){return e.sessionId.value===t.sessionId&&e.sessionGeneration===t.sessionGeneration&&e.connectionGeneration===t.connectionGeneration}function Yt(e,t,n){e.wsHandlers.set(t,n)}function Jv(){const e=G("connecting"),t=G([]),n=G(!1),s=G(void 0),o=G([]),r=G({busy:!1}),i=G(null),a=G([]),l=G(!1),u=G(null),c=G(!1),d=G(null),f=G(null),p=G(null),g=G([]),b=G(null),S=G(!1),w=B(()=>r.value.busy||c.value),k=B(()=>f.value!==null&&!S.value);return{connectionStatus:e,messages:t,olderAvailable:n,oldestSeq:s,pendingApprovals:o,status:r,goal:i,todos:a,goalRequestPending:l,goalRequestError:u,promptPending:c,error:d,sessionId:f,workDir:p,isBusy:w,sessions:g,currentSessionId:b,isArchived:k,gitStatus:G(null),models:G([]),modelsError:G(null),like:G({}),sessionPlan:G(null),skills:G([]),skillsError:G(null),plugins:G([]),pluginInfo:G(null),mcpServers:G([]),mcpStartupMetrics:G(null),backgroundTasks:G([]),backgroundTaskOutput:G(""),subagents:G([]),config:G(null),experimentalFlags:G(null),preflightOk:G(!1),sessionActive:S,ws:null,heartbeatTimer:null,reconnectTimer:null,snapshotRetryTimer:null,lastPongAt:Date.now(),seq:0,epoch:0,reconnectAttempt:0,sessionGeneration:0,connectionGeneration:0,promptGeneration:0,liveGeneration:0,sessionMutationGeneration:0,goalMutationGeneration:0,permissionMutationGeneration:0,goalAwaitingMutation:null,goalRequestInFlight:!1,snapshotRetryGoalGeneration:null,pendingPromptAccepted:!1,disposed:!1,sentMessageIds:new Map,turnNumber:0,turnStartAt:0,turnFirstTokenAt:null,activeToolMs:0,streamDisposed:!1,pendingAssistantDelta:"",pendingThinkingDelta:"",pendingToolProgress:new Map,wsHandlers:new Map,wsUnknownFrames:0,journalGapCount:0}}function Qv(){const{showToast:e}=Qs();return{s:Jv(),showToast:e}}function yn(){return`msg_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function gc(e,t){if(e!==null&&typeof e=="object"){const n=e.message;if(typeof n=="string")return n}return t}const mc="scream-offline-prompt-queue",vc="scream-recent-prompts";function ey(e){const{s:t}=e;let n=[];try{const c=localStorage.getItem(mc);if(c){const d=JSON.parse(c);Array.isArray(d)&&(n=d.filter(f=>typeof f=="string"))}}catch{n=[]}function s(){try{localStorage.setItem(mc,JSON.stringify(n.slice(0,20)))}catch{}}function o(){if(n.length===0)return;const c=n[0],d=`client_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,f=yn();t.sentMessageIds.set(d,{messageId:f,connectionGeneration:t.connectionGeneration,queueText:c}),t.promptGeneration++,t.pendingPromptAccepted=!1,t.promptPending.value=!0,t.messages.value.push({id:f,role:"user",content:c,clientMessageId:d,tools:[],ts:Date.now()}),u(c),e.send({type:"prompt",text:c,clientMessageId:d})}function r(){n.length>0&&n.shift(),s(),o()}function i(c){n.push(c),s()}function a(c){const d=n.indexOf(c);d>=0&&(n.splice(d,1),s())}let l=[];try{const c=localStorage.getItem(vc);if(c){const d=JSON.parse(c);Array.isArray(d)&&(l=d.filter(f=>typeof f=="string"))}}catch{l=[]}function u(c){const d=c.trim();if(d){l=[d,...l.filter(f=>f!==d)].slice(0,8);try{localStorage.setItem(vc,JSON.stringify(l))}catch{}}}return e.flushQueue=o,e.flushQueueNext=r,e.enqueueOfflinePrompt=i,e.removeOfflineQueueItem=a,e.recordRecentPrompt=u,{enqueueOfflinePrompt:i,removeOfflineQueueItem:a,recordRecentPrompt:u,flushQueue:o,flushQueueNext:r}}function wr(e,t,n,s){return e===n&&t===s}function ty(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 ny(e){return{objective:e.objective,completionCriterion:e.completionCriterion,replace:e.replace,budgets:e.budgets}}function sy(e){return{objective:e.objective,budgets:e.budgets}}function oy(e,t,n){return e!==0&&n.epoch!==e?"resync":n.seq<=t?"duplicate":t!==0&&n.seq>t+1?"gap":"apply"}function ry(e,t){return t.type==="goal.updated"?{...e,goal:t.snapshot}:t.type==="todo.updated"?{...e,todos:t.todos}:e}function iy(e){const t=[],n=new Map;for(const s of e){const o=s.phase??null;let r=n.get(o);r===void 0&&(r=t.length,n.set(o,r),t.push({phase:o,items:[]})),t[r].items.push(s)}return t}const ay=24,ly=4e3;function bo(e,t){const n=e[t];return typeof n=="string"&&n.length>0?n:void 0}function ir(e,t){const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:void 0}function uy(e){const t=e.usage;if(!t||typeof t!="object")return;const n=t;if(!(typeof n.inputOther!="number"||typeof n.output!="number"||typeof n.inputCacheRead!="number"||typeof n.inputCacheCreation!="number"))return{inputOther:n.inputOther,output:n.output,inputCacheRead:n.inputCacheRead,inputCacheCreation:n.inputCacheCreation}}function yc(e,t){const n=bo(e,t);return n===void 0?void 0:n.slice(0,ly)}function cy(e,t){return e.type==="subagent.started"?"running":e.type==="subagent.completed"?"completed":e.type==="subagent.failed"?"failed":t}function dy(e){return[...e].toSorted((t,n)=>{const s=t.state==="spawning"||t.state==="running",o=n.state==="spawning"||n.state==="running";return s!==o?s?-1:1:n.updatedAt-t.updatedAt}).slice(0,ay)}function fy(e,t,n=Date.now()){if(!t.type.startsWith("subagent.")||t.type==="subagent.child_request")return e;const s=t,o=bo(s,"subagentId");if(!o)return e;const r=e.findIndex(f=>f.subagentId===o),i=r===-1?void 0:e[r],a=cy(s,(i==null?void 0:i.state)??"spawning"),l=bo(s,"subagentName")??(i==null?void 0:i.name)??"agent",u=bo(s,"parentToolCallId")??(i==null?void 0:i.parentToolCallId)??"",c={subagentId:o,name:l,parentToolCallId:u,description:bo(s,"description")??(i==null?void 0:i.description),runInBackground:typeof s.runInBackground=="boolean"?s.runInBackground:(i==null?void 0:i.runInBackground)??!1,state:a,updatedAt:n,resultSummary:yc(s,"resultSummary")??(i==null?void 0:i.resultSummary),error:yc(s,"error")??(i==null?void 0:i.error),usage:uy(s)??(i==null?void 0:i.usage),contextTokens:ir(s,"contextTokens")??(i==null?void 0:i.contextTokens),turns:ir(s,"turns")??(i==null?void 0:i.turns),durationMs:ir(s,"durationMs")??(i==null?void 0:i.durationMs),toolCallCount:ir(s,"toolCallCount")??(i==null?void 0:i.toolCallCount)},d=r===-1?[...e,c]:e.map((f,p)=>p===r?c:f);return dy(d)}const Oo=new Map;function hy(e){Oo.set(e,Date.now())}function py(e){return Oo.get(e)}function gy(e){const t=Oo.get(e);return t!==void 0&&Oo.delete(e),t}function my(){Oo.clear()}function na(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`}function vy(e){let t=null;return{schedule:()=>{if(t!==null)return;const r=i=>{if(i<=0){t=null,e();return}t=requestAnimationFrame(()=>r(i-1))};t=requestAnimationFrame(()=>r(2))},flushNow:()=>{t!==null&&(cancelAnimationFrame(t),t=null),e()},dispose:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}}function yy(e){const{s:t}=e;function n(){if(t.streamDisposed)return;const u=a();if(!u){t.pendingAssistantDelta="",t.pendingThinkingDelta="",t.pendingToolProgress.clear();return}if(t.pendingAssistantDelta&&(u.content+=t.pendingAssistantDelta,t.pendingAssistantDelta=""),t.pendingThinkingDelta){const c=u.tools.find(d=>d.name==="thinking");c?c.output=(c.output??"")+t.pendingThinkingDelta:u.tools.push({toolCallId:"thinking",name:"thinking",output:t.pendingThinkingDelta}),t.pendingThinkingDelta=""}if(t.pendingToolProgress.size>0){for(const[c,d]of t.pendingToolProgress){const f=u.tools.find(p=>p.toolCallId===c);f&&(f.progress=d)}t.pendingToolProgress.clear()}}const s=vy(n);let o=null;function r(){o===null&&(o=window.setTimeout(()=>{var u;o=null,(u=e.refreshBackgroundTasks)==null||u.call(e)},250))}function i(u){var f;const c=fy(t.subagents.value,u);c!==t.subagents.value&&(t.subagents.value=c);const d=ry({goal:t.goal.value,todos:t.todos.value},u);switch(t.goal.value=d.goal,t.todos.value=d.todos,u.type==="goal.updated"&&t.goalAwaitingMutation!==null&&t.goalAwaitingMutation.generation===t.goalMutationGeneration&&(t.goalAwaitingMutation=null,t.snapshotRetryGoalGeneration=null,e.syncGoalRequestPending()),u.type){case"turn.started":{t.pendingPromptAccepted&&(t.promptPending.value=!1,t.pendingPromptAccepted=!1,t.sentMessageIds.clear()),s.flushNow(),t.status.value={...t.status.value,busy:!0},t.turnNumber+=1,t.turnStartAt=Date.now(),t.turnFirstTokenAt=null,t.activeToolMs=0,my(),t.messages.value.push({id:yn(),role:"assistant",content:"",tools:[],ts:Date.now(),model:t.status.value.model,turnStats:{turn:t.turnNumber,step:0,status:"running",firstTokenMs:null,llmMs:0,toolMs:0,tokens:null,tokensPerSec:null}});break}case"assistant.delta":{t.turnFirstTokenAt===null&&(t.turnFirstTokenAt=Date.now()),t.pendingAssistantDelta+=String(u.delta),s.schedule();break}case"thinking.delta":{t.turnFirstTokenAt===null&&(t.turnFirstTokenAt=Date.now()),t.pendingThinkingDelta+=String(u.delta),s.schedule();break}case"tool.call.started":{const p=a();p&&(p.tools.push({toolCallId:String(u.toolCallId),name:String(u.name),args:u.args}),p.turnStats&&(p.turnStats.step+=1)),hy(String(u.toolCallId));break}case"tool.result":{t.pendingToolProgress.delete(String(u.toolCallId));const p=gy(String(u.toolCallId));p!==void 0&&(t.activeToolMs+=Date.now()-p);const g=a();if(g){const b=g.tools.find(S=>S.toolCallId===u.toolCallId);b&&(b.output=String(u.output),b.isError=!!u.isError,b.progress=void 0,p!==void 0&&(b.durationMs=Date.now()-p))}break}case"tool.progress":{t.pendingToolProgress.set(String(u.toolCallId),String(u.message??u.output)),s.schedule();break}case"background.task.started":case"background.task.updated":case"background.task.terminated":{if(u.agentId!==void 0&&u.agentId!=="main")break;r();break}case"turn.ended":{if(s.flushNow(),t.status.value={...t.status.value,busy:!1},u.reason==="failed"){const w=a();w&&(w.isError=!0),t.error.value=gc(u.error,"Turn failed")}const p=a(),g=Date.now()-t.turnStartAt,b=(f=t.status.value.usage)==null?void 0:f.currentTurn,S=b?b.inputOther+b.output+b.inputCacheRead+b.inputCacheCreation:null;p&&p.turnStats&&(p.turnStats.status="done",p.turnStats.llmMs=g,p.turnStats.toolMs=t.activeToolMs,p.turnStats.firstTokenMs=t.turnFirstTokenAt!==null?t.turnFirstTokenAt-t.turnStartAt:null,p.turnStats.tokens=S,p.turnStats.tokensPerSec=S!==null&&g>0?Math.round(S/g*1e3):null),e.fetchSessions(),e.fetchGitStatus();break}case"session.meta.updated":{const p={};u.model!==void 0&&(p.model=u.model),u.contextTokens!==void 0&&(p.contextTokens=u.contextTokens),u.maxContextTokens!==void 0&&(p.maxContextTokens=u.maxContextTokens),u.contextUsage!==void 0&&(p.contextUsage=u.contextUsage),t.status.value={...t.status.value,...p};break}case"agent.status.updated":{const p={};if(u.model!==void 0&&(p.model=u.model),u.thinkingLevel!==void 0&&(p.thinkingLevel=u.thinkingLevel),u.contextTokens!==void 0&&(p.contextTokens=u.contextTokens),u.maxContextTokens!==void 0&&(p.maxContextTokens=u.maxContextTokens),u.contextUsage!==void 0&&(p.contextUsage=u.contextUsage),(u.agentId===void 0||u.agentId==="main")&&(u.rlmEnabled!==void 0&&(p.rlmEnabled=u.rlmEnabled),u.rlmMaxDepth!==void 0&&(p.rlmMaxDepth=u.rlmMaxDepth)),u.usage!==void 0){p.usage=u.usage;const g=u.usage;if(g!=null&&g.currentTurn){const b=a(),S=g.currentTurn.inputOther+g.currentTurn.output+g.currentTurn.inputCacheRead+g.currentTurn.inputCacheCreation;b!=null&&b.turnStats&&b.turnStats.status==="done"&&b.turnStats.tokens===null&&(b.turnStats.tokens=S,b.turnStats.tokensPerSec=b.turnStats.llmMs?Math.round(S/b.turnStats.llmMs*1e3):null)}}t.status.value={...t.status.value,...p};break}case"web.history.undone":e.fetchSnapshot();break;case"error":{t.error.value=gc(u.error,"Unknown error");break}}}function a(){for(let u=t.messages.value.length-1;u>=0;u--)if(t.messages.value[u].role==="assistant")return t.messages.value[u];return null}Yt(t,"event",u=>{const c=oy(t.epoch,t.seq,u);if(c==="resync"){t.epoch=u.epoch,t.seq=0,t.journalGapCount=0,e.fetchSnapshot();return}if(c!=="duplicate"){if(c==="gap"){t.journalGapCount++;const d=t.journalGapCount>=3;(d?console.error:console.warn)(`[webClient] journal seq 缺口:epoch ${t.epoch} 内从 ${t.seq} 跳到 ${u.seq}(连续第 ${t.journalGapCount} 次${d?",超过阈值,流可能已持续损坏":""}),已触发快照补拉。`,u)}else t.journalGapCount=0;t.seq=u.seq,t.epoch=u.epoch,t.liveGeneration++,c==="gap"&&e.fetchSnapshot(),i(u.payload)}}),Yt(t,"resync_required",()=>{t.seq=0,e.fetchSnapshot()}),e.onEvent=i;function l(){t.streamDisposed=!0,o!==null&&(window.clearTimeout(o),o=null),s.dispose()}return{onEvent:i,disposeStreaming:l}}function by(e){const{s:t,showToast:n}=e;function s(){t.disposed||t.snapshotRetryTimer!==null||(t.snapshotRetryTimer=window.setTimeout(()=>{t.snapshotRetryTimer=null;const i=t.snapshotRetryGoalGeneration;t.snapshotRetryGoalGeneration=null,o(i??void 0)},250))}async function o(i){var p,g;const a=t.sessionId.value;if(!a)return;const l=t.messages.value.length===0?100:void 0,u=t.sessionGeneration,c=t.connectionGeneration,d=t.promptGeneration,f=t.liveGeneration;try{const b=await fetch(`${Ge}/sessions/${a}/snapshot${l?`?tail=${l}`:""}`);if(!b.ok){i!==void 0&&((p=t.goalAwaitingMutation)==null?void 0:p.generation)===i&&(t.snapshotRetryGoalGeneration=i,s());return}const S=await b.json();if(!ty({snapshot:S,targetSessionId:a,currentSessionId:t.sessionId.value,targetSessionGeneration:u,currentSessionGeneration:t.sessionGeneration,targetConnectionGeneration:c,currentConnectionGeneration:t.connectionGeneration,targetPromptGeneration:d,currentPromptGeneration:t.promptGeneration,targetLiveGeneration:f,currentLiveGeneration:t.liveGeneration,currentEpoch:t.epoch,currentSeq:t.seq})){i!==void 0&&(t.snapshotRetryGoalGeneration=i),s();return}r(S,i)}catch{i!==void 0&&((g=t.goalAwaitingMutation)==null?void 0:g.generation)===i&&(t.snapshotRetryGoalGeneration=i,s())}}function r(i,a){var b;t.pendingAssistantDelta="",t.pendingThinkingDelta="",t.pendingToolProgress.clear();const l=t.messages.value.filter(S=>S.local),u=t.sentMessageIds.keys().next().value,c=u?t.sentMessageIds.get(u):void 0,d=c?t.messages.value.find(S=>S.id===c.messageId):void 0,f=!!(u&&i.messages.some(S=>S.clientMessageId===u)),p=!!(c&&!f&&c.connectionGeneration<t.connectionGeneration);p&&d&&(d.isError=!0);const g=d&&!f?[d]:[];t.messages.value=[...i.messages.map(S=>({...S,id:S.id??yn()})),...l,...g];for(let S=t.messages.value.length-1;S>=0;S--){const w=(b=t.messages.value[S])==null?void 0:b.turnStats;if(w&&typeof w.turn=="number"&&w.turn>0){t.turnNumber=w.turn;break}}t.pendingApprovals.value=i.pendingApprovals,t.status.value={...i.status,busy:i.busy},t.olderAvailable.value=!!i.olderAvailable,t.oldestSeq.value=i.oldestSeq,t.goal.value=i.goal,t.todos.value=i.todos,a!==void 0&&t.goalAwaitingMutation!==null&&t.goalAwaitingMutation.generation===a&&t.goalMutationGeneration===a&&(t.goalAwaitingMutation=null,e.syncGoalRequestPending()),(f||p)&&(t.promptPending.value=!1,t.pendingPromptAccepted=!1,t.sentMessageIds.clear(),p&&n("消息未送达,已恢复连接。","error")),t.seq=i.seq,t.epoch=i.epoch,t.workDir.value=i.workDir}return e.fetchSnapshot=o,{fetchSnapshot:o}}function ky(e){const{s:t,showToast:n}=e;function s(c){if(!c)return;if(t.connectionStatus.value==="idle"){n("暂无会话,请先新建会话。","warning");return}if(t.connectionStatus.value!=="connected"){e.enqueueOfflinePrompt(c),n("连接已断开,消息已排队,重连后自动发送。","warning"),e.connect();return}if(t.isBusy.value)return;const d=`client_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,f=yn();t.sentMessageIds.set(d,{messageId:f,connectionGeneration:t.connectionGeneration}),t.promptGeneration++,t.pendingPromptAccepted=!1,t.promptPending.value=!0,t.messages.value.push({id:f,role:"user",content:c,clientMessageId:d,tools:[],ts:Date.now()}),e.recordRecentPrompt(c),e.send({type:"prompt",text:c,clientMessageId:d})}function o(c,d){if(t.connectionStatus.value==="idle"){n("暂无会话,请先新建会话。","warning");return}if(t.connectionStatus.value!=="connected"){n("连接已断开,命令未发送。","error"),e.connect();return}if(t.isBusy.value&&c!=="btw"){n(`会话忙碌中,无法执行 /${c},请稍后再试。`,"warning");return}const f=["compact","plan","auto","yes","fork","title"];let p=null;f.includes(c)&&(p=yn(),t.messages.value.push({id:p,role:"system",content:`正在执行 /${c}${d?` ${d}`:""}...`,tools:[],pending:!0,ts:Date.now(),local:!0})),e.send({type:"command",command:c,...d?{args:d}:{},...p?{pendingMsgId:p}:{}})}function r(){t.messages.value=[],t.pendingApprovals.value=[]}function i(c){t.messages.value.push({id:yn(),role:"system",content:c,tools:[],ts:Date.now(),local:!0})}function a(c,d,f,p){if(t.connectionStatus.value!=="connected"){n("连接已断开,审批结果未发送。","error"),e.connect();return}t.pendingApprovals.value=t.pendingApprovals.value.filter(g=>g.id!==c),e.send({type:"approval_response",id:c,decision:d,...f?{feedback:f}:{},...p?{scope:p}:{}})}function l(){e.send({type:"abort"})}async function u(){var f;const c=t.sessionId.value,d=t.oldestSeq.value;if(!c||d===void 0)return 0;try{const p=await fetch(`${Ge}/sessions/${c}/messages?before=${d}&tail=50`);if(!p.ok)return 0;const g=await p.json();if(g.messages.length===0)return 0;const b=g.messages.map(S=>({...S,id:S.id??yn()}));return t.messages.value=[...b,...t.messages.value],t.oldestSeq.value=((f=b[0])==null?void 0:f.seq)??d,t.olderAvailable.value=g.hasMore,b.length}catch{return 0}}return Yt(t,"user_message",c=>{var d;if(t.liveGeneration++,c.clientMessageId&&t.sentMessageIds.has(c.clientMessageId)){t.pendingPromptAccepted=!0,((d=t.sentMessageIds.get(c.clientMessageId))==null?void 0:d.queueText)!==void 0&&e.flushQueueNext();return}t.messages.value.push({id:yn(),role:"user",content:c.text,clientMessageId:c.clientMessageId,tools:[],ts:Date.now()})}),Yt(t,"approval_request",c=>{t.liveGeneration++,t.pendingApprovals.value=[...t.pendingApprovals.value,{id:c.id,toolName:c.toolName,action:c.action,display:c.display,sourceAgentId:c.sourceAgentId,sourceAgentName:c.sourceAgentName,sourceToolName:c.sourceToolName,sourceCapabilityMode:c.sourceCapabilityMode,reasons:c.reasons,grantOptions:c.grantOptions,requestSummary:c.requestSummary}]}),Yt(t,"approval_resolved",c=>{t.liveGeneration++,t.pendingApprovals.value=t.pendingApprovals.value.filter(d=>d.id!==c.id)}),Yt(t,"command_result",c=>{const d=c.pendingMsgId?t.messages.value.findIndex(p=>p.id===c.pendingMsgId):-1,f=d>=0;if(d>=0){const p=t.messages.value[d];t.messages.value[d]={...p,content:c.message,isError:!c.ok,pending:!1}}else t.messages.value.push({id:yn(),role:"system",content:c.message,tools:[],isError:!c.ok,ts:Date.now(),local:!0});(c.command==="fork"||c.command==="title")&&e.fetchSessions(),c.ok&&c.command==="fork"&&c.sessionId&&f&&e.switchSession(c.sessionId),c.ok&&c.command==="compact"&&e.fetchSnapshot()}),Yt(t,"error",c=>{if(t.error.value=c.message,c.clientMessageId){const d=t.sentMessageIds.get(c.clientMessageId);if(d){t.sentMessageIds.delete(c.clientMessageId),t.promptPending.value=!1,t.pendingPromptAccepted=!1;const f=t.messages.value.find(p=>p.id===d.messageId);f&&(f.isError=!0),n(`消息未发送:${c.message}`,"error"),d.queueText!==void 0&&e.removeOfflineQueueItem(d.queueText)}}}),e.appendSystemMessage=i,{sendPrompt:s,sendCommand:o,clearMessages:r,appendSystemMessage:i,abort:l,resolveApproval:a,loadOlderMessages:u}}function wy(e){const{s:t,showToast:n}=e;async function s(){try{const c=await fetch(`${Ge}/sessions`);if(!c.ok)return;t.sessions.value=await c.json()}catch{}}async function o(c){const d=t.sessionGeneration,f=t.connectionGeneration;try{return(await fetch(`${Ge}/sessions/${c}/activate`,{method:"POST"})).ok&&t.connectionGeneration===f&&wr(t.sessionId.value,t.sessionGeneration,c,d)}catch{return!1}}async function r(){const c=ft(t);try{const d=(c==null?void 0:c.sessionId)??t.currentSessionId.value,f=d?`?sessionId=${encodeURIComponent(d)}`:"",p=await fetch(`${Ge}/git/status${f}`);if(c&&!Ei(t,c)||!p.ok)return;const g=await p.json();t.gitStatus.value=g.isRepo?g:null}catch{}}async function i(c,d){try{const f=await fetch(`${Ge}/sessions`,{method:"POST",...c?{headers:{"Content-Type":"application/json"},body:JSON.stringify({workDir:c})}:{}});if(!f.ok){const g=await f.json().catch(()=>null),b=g&&typeof g.message=="string"?g.message:"";n(`新建会话失败:${b||`HTTP ${f.status}`}`,"error");return}const p=await f.json();t.sessions.value=[p,...t.sessions.value],d==null||d(p.sessionId),await a(p.sessionId)}catch(f){n(`新建会话失败:${f instanceof Error?f.message:String(f)}`,"error")}}async function a(c){t.currentSessionId.value===c&&t.connectionStatus.value==="connected"||(t.currentSessionId.value=c,t.sessionId.value=c,t.sessionGeneration++,e.resetGoalRequestState(),t.seq=0,t.epoch=0,t.journalGapCount=0,t.messages.value=[],t.pendingApprovals.value=[],t.status.value={busy:!1},t.gitStatus.value=null,t.workDir.value=null,t.goal.value=null,t.todos.value=[],t.sessionPlan.value=null,t.skills.value=[],t.skillsError.value=null,t.plugins.value=[],t.pluginInfo.value=null,t.mcpServers.value=[],t.mcpStartupMetrics.value=null,t.backgroundTasks.value=[],t.backgroundTaskOutput.value="",t.subagents.value=[],t.sessionActive.value=!1,t.promptPending.value=!1,t.pendingPromptAccepted=!1,t.sentMessageIds.clear(),t.reconnectTimer!==null&&(clearTimeout(t.reconnectTimer),t.reconnectTimer=null),t.snapshotRetryTimer!==null&&(clearTimeout(t.snapshotRetryTimer),t.snapshotRetryTimer=null),t.ws&&(t.ws.onclose=null,t.ws.close(),t.ws=null),e.stopHeartbeat(),e.connect())}async function l(c){try{const d=await fetch(`${Ge}/sessions/${c}`,{method:"DELETE"});if(!d.ok){n(`删除会话失败(HTTP ${d.status})`,"error");return}if(t.sessions.value=t.sessions.value.filter(f=>f.sessionId!==c),t.currentSessionId.value===c){const f=t.sessions.value[0];f?await a(f.sessionId):(t.sessionGeneration++,e.resetGoalRequestState(),t.sessionId.value=null,t.currentSessionId.value=null,t.sessionActive.value=!1,t.seq=0,t.epoch=0,t.journalGapCount=0,t.messages.value=[],t.pendingApprovals.value=[],t.status.value={busy:!1},t.gitStatus.value=null,t.workDir.value=null,t.goal.value=null,t.todos.value=[],t.sessionPlan.value=null,t.skills.value=[],t.skillsError.value=null,t.plugins.value=[],t.pluginInfo.value=null,t.mcpServers.value=[],t.mcpStartupMetrics.value=null,t.backgroundTasks.value=[],t.backgroundTaskOutput.value="",t.subagents.value=[],t.promptPending.value=!1,t.pendingPromptAccepted=!1,t.sentMessageIds.clear(),t.ws&&(t.ws.onclose=null,t.ws.close(),t.ws=null),e.stopHeartbeat(),e.setConnectionStatus("idle"))}}catch(d){n(`删除会话失败:${d instanceof Error?d.message:String(d)}`,"error")}}async function u(c){try{const d=await fetch(`${Ge}/sessions/${c}/export`);if(!d.ok){n(`导出会话失败(HTTP ${d.status})`,"error");return}const f=await d.blob(),p=URL.createObjectURL(f),g=document.createElement("a");g.href=p,g.download=`${c}.md`,g.click(),URL.revokeObjectURL(p)}catch(d){n(`导出会话失败:${d instanceof Error?d.message:String(d)}`,"error")}}return e.fetchSessions=s,e.switchSession=a,e.fetchGitStatus=r,e.activateSession=o,{fetchSessions:s,fetchGitStatus:r,createSession:i,switchSession:a,deleteSession:l,exportSession:u}}function Sy(e){const{s:t,showToast:n}=e;async function s(){try{const u=await fetch(`${Ge}/models`);if(!u.ok){t.modelsError.value=`模型列表加载失败(HTTP ${u.status})`;return}const c=await u.json();t.models.value=c.models,t.modelsError.value=null}catch(u){t.modelsError.value=`模型列表加载失败:${u instanceof Error?u.message:String(u)}`}}async function o(){try{const u=await fetch(`${Ge}/like`);if(!u.ok)return;t.like.value=await u.json()}catch{}}async function r(u){try{return(await fetch(`${Ge}/like`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)})).ok?(t.like.value=u,!0):!1}catch{return!1}}async function i(u,c,d){const f=t.sessionId.value;if(!f){n("请先打开一个会话","warning");return}const p=t.sessionGeneration,g=t.connectionGeneration,b=++t.sessionMutationGeneration;try{const S=await fetch(`${Ge}/sessions/${f}/${u}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),w=await S.json();if(t.sessionId.value!==f||t.sessionGeneration!==p||t.connectionGeneration!==g||t.sessionMutationGeneration!==b)return;if(!S.ok){n(w.message??`请求失败(HTTP ${S.status})`,"error");return}w.status&&(t.status.value={...t.status.value,...w.status}),n(d,"success")}catch(S){if(t.sessionId.value!==f||t.sessionGeneration!==p||t.connectionGeneration!==g||t.sessionMutationGeneration!==b)return;n(`请求失败:${S instanceof Error?S.message:String(S)}`,"error")}}async function a(u){u!==t.status.value.model&&await i("model",{model:u},`已切换模型:${u}`)}async function l(u){u!==t.status.value.thinkingLevel&&await i("thinking",{level:u},`思考强度已切换为 ${u}`)}return Yt(t,"status",u=>{t.liveGeneration++,t.status.value={...t.status.value,...u.status}}),e.fetchModels=s,{fetchModels:s,fetchLike:o,updateLike:r,switchModel:a,switchThinking:l}}function _y(e){const{s:t}=e;function n(){t.goalRequestPending.value=t.goalRequestInFlight||t.goalAwaitingMutation!==null}function s(){t.goalMutationGeneration++,t.goalAwaitingMutation=null,t.goalRequestInFlight=!1,t.snapshotRetryGoalGeneration=null,t.goalRequestPending.value=!1,t.goalRequestError.value=null}async function o(f,p,g,b){const S=t.sessionId.value;if(!S)return t.goalRequestError.value="暂无可操作的会话。",null;if(t.connectionStatus.value!=="connected")return t.goalRequestError.value="连接已断开,请等待重连后再试。",null;if(t.isArchived.value)return t.goalRequestError.value="当前会话已归档,无法修改 Goal。",null;if(t.goalRequestInFlight)return t.goalRequestError.value="正在处理上一个请求,请稍候。",null;t.goalAwaitingMutation!==null&&(t.goalAwaitingMutation=null,n());const w=t.sessionGeneration,k=++t.goalMutationGeneration;t.goalRequestInFlight=!0,n(),t.goalRequestError.value=null;try{const y=await fetch(`${Ge}/sessions/${S}/goal${f}`,{method:p,headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),_=await y.json().catch(()=>({}));return!wr(t.sessionId.value,t.sessionGeneration,S,w)||t.goalMutationGeneration!==k?null:y.ok?(b&&(t.goalAwaitingMutation={generation:k},t.snapshotRetryGoalGeneration=k),_):(t.goalRequestError.value=typeof _.message=="string"?_.message:`请求失败(HTTP ${y.status})`,null)}catch(y){return wr(t.sessionId.value,t.sessionGeneration,S,w)&&t.goalMutationGeneration===k&&(t.goalRequestError.value=`请求失败:${y instanceof Error?y.message:String(y)}`),null}finally{wr(t.sessionId.value,t.sessionGeneration,S,w)&&t.goalMutationGeneration===k&&(t.goalRequestInFlight=!1,n())}}async function r(f){const p=await o("/refine","POST",{description:f},!1);return typeof(p==null?void 0:p.objective)=="string"?p.objective:null}async function i(f){return await o("","POST",ny(f),!0)===null?!1:(t.goalAwaitingMutation!==null&&e.fetchSnapshot(t.goalAwaitingMutation.generation),!0)}async function a(f){return await o("","PATCH",sy(f),!0)===null?!1:(t.goalAwaitingMutation!==null&&e.fetchSnapshot(t.goalAwaitingMutation.generation),!0)}async function l(f){return await o(f,"POST",{},!0)===null?!1:(t.goalAwaitingMutation!==null&&e.fetchSnapshot(t.goalAwaitingMutation.generation),!0)}function u(){return l("/pause")}function c(){return l("/resume")}function d(){return l("/cancel")}return e.resetGoalRequestState=s,e.syncGoalRequestPending=n,{refineGoal:r,createGoal:i,updateGoal:a,pauseGoal:u,resumeGoal:c,cancelGoal:d}}function $y(e){const{s:t,showToast:n}=e;let s=0,o=0,r=0,i=0;function a(_){return _!==null&&Ei(t,_)}async function l(){const _=ft(t);if(!_)return;const N=++s;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/status`);if(!a(_)||N!==s||!D.ok)return;const E=await D.json();t.status.value={...t.status.value,...E}}catch{}}async function u(){const _=ft(t);if(!_)return;const N=++o;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/usage`);if(!a(_)||N!==o||!D.ok)return;const E=await D.json();t.status.value={...t.status.value,usage:E}}catch{}}async function c(){const _=ft(t);if(!_)return;const N=++r;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/context`);if(!a(_)||N!==r||!D.ok)return;const E=await D.json();E.tokenCount!==void 0&&(t.status.value={...t.status.value,contextTokens:E.tokenCount})}catch{}}async function d(){const _=ft(t);if(!_)return;const N=++i;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/plan`);if(!a(_)||N!==i||!D.ok)return;t.sessionPlan.value=await D.json()}catch{}}async function f(){const _=ft(t);if(!_)return!1;const N=++i;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/plan/clear`,{method:"POST"});return!a(_)||N!==i||!D.ok?!1:(t.sessionPlan.value=null,!0)}catch{return!1}}async function p(_,N){const D=ft(t);if(!D)return!1;if(t.connectionStatus.value!=="connected")return n("连接已断开,操作未发送。","error"),e.connect(),!1;try{const E=await fetch(`${Ge}/sessions/${D.sessionId}/${_}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N??{})});if(!a(D))return!1;if(!E.ok){const A=await E.json().catch(()=>({}));return a(D)&&n(A.message??`操作失败(HTTP ${E.status})`,"error"),!1}return!0}catch(E){return a(D)&&n(`操作失败:${E instanceof Error?E.message:String(E)}`,"error"),!1}}async function g(_){const N=t.sessionId.value,D=t.sessionGeneration,E=t.connectionGeneration,A=++t.permissionMutationGeneration,T=t.status.value.permission;return t.status.value={...t.status.value,permission:_},await p("permission",{mode:_})?(await l(),!0):(t.sessionId.value!==N||t.sessionGeneration!==D||t.connectionGeneration!==E||t.permissionMutationGeneration!==A||(t.status.value={...t.status.value,permission:T}),!1)}async function b(_,N){const D=await p("plan",{enabled:_,...N?{strategy:N}:{}});return D&&await l(),D}async function S(_){const N=await p("wolfpack",{enabled:_});return N&&await l(),N}async function w(_,N){const D=await p("rlm",{enabled:_,...N!==void 0?{maxDepth:N}:{}});return D&&await l(),D}async function k(_=1){return p("undo",{count:_})}async function y(_){return p("compact",_?{instruction:_}:{})}return e.postSessionAction=p,{fetchSessionStatus:l,fetchSessionUsage:u,fetchSessionContext:c,fetchSessionPlan:d,clearPlan:f,switchPermission:g,switchPlanMode:b,switchWolfpack:S,switchRlm:w,undoHistory:k,compact:y}}function Cy(e){const{s:t}=e;let n=0,s=0,o=0;function r(y){return y!==null&&Ei(t,y)}async function i(){const y=ft(t);if(!y)return;const _=++n;try{const N=await fetch(`${Ge}/sessions/${y.sessionId}/skills`);if(!r(y)||_!==n)return;if(!N.ok){t.skillsError.value=`技能列表加载失败(HTTP ${N.status})`;return}t.skills.value=await N.json(),t.skillsError.value=null}catch(N){if(!r(y)||_!==n)return;t.skillsError.value=`技能列表加载失败:${N instanceof Error?N.message:String(N)}`}}async function a(y,_){return e.postSessionAction(`skills/${encodeURIComponent(y)}/activate`,_?{args:_}:{})}async function l(y){const _=ft(t);if(!_)return!1;++n;try{const N=await fetch(`${Ge}/sessions/${_.sessionId}/skills/${encodeURIComponent(y)}`,{method:"DELETE"});return!r(_)||!N.ok?!1:(t.skills.value=t.skills.value.filter(D=>D.name!==y),!0)}catch{return!1}}async function u(){const y=ft(t);if(!y)return;const _=++s;try{const N=await fetch(`${Ge}/sessions/${y.sessionId}/plugins`);if(!r(y)||_!==s||!N.ok)return;t.plugins.value=await N.json()}catch{}}async function c(y){const _=ft(t);if(!_)return;const N=++o;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/plugins/${encodeURIComponent(y)}`);if(!r(_)||N!==o||!D.ok)return;t.pluginInfo.value=await D.json()}catch{}}async function d(y){const _=ft(t);if(!_)return null;++s;try{const N=await fetch(`${Ge}/sessions/${_.sessionId}/plugins/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:y})});if(!r(_)||!N.ok)return null;const D=await N.json();return await u(),r(_)?D:null}catch{return null}}async function f(y,_){return e.postSessionAction(`plugins/${encodeURIComponent(y)}/enable`,{enabled:_})}async function p(y,_,N){return e.postSessionAction(`plugins/${encodeURIComponent(y)}/mcp/${encodeURIComponent(_)}/enable`,{enabled:N})}async function g(y){const _=ft(t);if(!_)return!1;++s;try{const N=await fetch(`${Ge}/sessions/${_.sessionId}/plugins/${encodeURIComponent(y)}`,{method:"DELETE"});return!r(_)||!N.ok?!1:(t.plugins.value=t.plugins.value.filter(D=>D.id!==y),!0)}catch{return!1}}async function b(){const y=ft(t);if(!y)return null;++s;try{const _=await fetch(`${Ge}/sessions/${y.sessionId}/plugins/reload`,{method:"POST"});if(!r(y)||!_.ok)return null;const N=await _.json();return await u(),r(y)?N:null}catch{return null}}async function S(y){return e.postSessionAction(`plugins/${encodeURIComponent(y)}/activate`)}async function w(y){return e.postSessionAction(`plugins/${encodeURIComponent(y)}/deactivate`)}async function k(y){return e.postSessionAction(`plugins/${encodeURIComponent(y)}/inject`)}return{fetchSkills:i,activateSkill:a,removeSkill:l,fetchPlugins:u,fetchPluginInfo:c,installPlugin:d,setPluginEnabled:f,setPluginMcpServerEnabled:p,removePlugin:g,reloadPlugins:b,activatePlugin:S,deactivatePlugin:w,injectPlugin:k}}function xy(e){const{s:t}=e;let n=0,s=0,o=0,r=0;function i(S){return S!==null&&Ei(t,S)}async function a(){const S=ft(t);if(!S)return;const w=++n;try{const k=await fetch(`${Ge}/sessions/${S.sessionId}/mcp`);if(!i(S)||w!==n||!k.ok)return;t.mcpServers.value=await k.json()}catch{}}async function l(){const S=ft(t);if(!S)return;const w=++s;try{const k=await fetch(`${Ge}/sessions/${S.sessionId}/mcp/startup-metrics`);if(!i(S)||w!==s||!k.ok)return;t.mcpStartupMetrics.value=await k.json()}catch{}}async function u(S,w){return e.postSessionAction("mcp/add",{name:S,config:w})}async function c(S){return e.postSessionAction(`mcp/${encodeURIComponent(S)}/reconnect`)}async function d(S){return e.postSessionAction(`mcp/${encodeURIComponent(S)}/stop`)}async function f(S){const w=ft(t);if(!w)return!1;try{const k=await fetch(`${Ge}/sessions/${w.sessionId}/mcp/${encodeURIComponent(S)}`,{method:"DELETE"});return!i(w)||!k.ok?!1:(t.mcpServers.value=t.mcpServers.value.filter(y=>y.name!==S),!0)}catch{return!1}}async function p(S,w){const k=ft(t);if(!k)return;const y=++o;try{const _=new URLSearchParams;S!==void 0&&_.set("activeOnly",String(S)),w!==void 0&&_.set("limit",String(w));const N=_.toString(),D=await fetch(`${Ge}/sessions/${k.sessionId}/tasks${N?`?${N}`:""}`);if(!i(k)||y!==o||!D.ok)return;t.backgroundTasks.value=await D.json()}catch{}}async function g(S,w){const k=ft(t);if(!k)return;const y=++r;try{const _=w!==void 0?`?tail=${w}`:"",N=await fetch(`${Ge}/sessions/${k.sessionId}/tasks/${encodeURIComponent(S)}/output${_}`);if(!i(k)||y!==r||!N.ok)return;const D=await N.json();t.backgroundTaskOutput.value=D.output}catch{}}async function b(S,w){return e.postSessionAction(`tasks/${encodeURIComponent(S)}/stop`,w?{reason:w}:{})}return e.refreshBackgroundTasks=p,{fetchMcpServers:a,fetchMcpStartupMetrics:l,addMcpServer:u,reconnectMcpServer:c,stopMcpServer:d,removeMcpServer:f,fetchBackgroundTasks:p,fetchBackgroundTaskOutput:g,stopBackgroundTask:b}}function Iy(e){const{s:t}=e;async function n(){try{const a=await fetch(`${Ge}/config`);if(!a.ok)return;t.config.value=await a.json()}catch{}}async function s(a){try{const l=await fetch(`${Ge}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:a})});return l.ok?(t.config.value=await l.json(),!0):!1}catch{return!1}}async function o(a){try{return(await fetch(`${Ge}/config/providers/${encodeURIComponent(a)}`,{method:"DELETE"})).ok?(await n(),!0):!1}catch{return!1}}async function r(){try{const a=await fetch(`${Ge}/experimental-flags`);if(!a.ok)return;t.experimentalFlags.value=await a.json()}catch{}}async function i(){try{if(!(await fetch(`${Ge}/preflight`)).ok)return;t.preflightOk.value=!0}catch{}}return{fetchConfig:n,setConfig:s,removeProvider:o,fetchExperimentalFlags:r,preflight:i}}function Ty(e){const{s:t}=e;return function(s){const o=t.wsHandlers.get(s.type);if(o!==void 0){o(s);return}t.wsUnknownFrames++,console.error(`[webClient] 收到未注册的 WS 帧类型 "${s.type}"(第 ${t.wsUnknownFrames} 次),该帧已被丢弃;请在对应域模块用 onWsMessage 注册处理器。`,s)}}function Ey(e){const{s:t,showToast:n}=e,s=Ty(e);function o(){const g=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`;return t.currentSessionId.value?`${g}?sessionId=${encodeURIComponent(t.currentSessionId.value)}`:g}function r(p){t.connectionStatus.value=p}function i(p=8e3){if(t.connectionStatus.value==="connected")return Promise.resolve(!0);if(t.connectionStatus.value==="idle"||t.disposed)return Promise.resolve(!1);const g=t.sessionId.value;if(!g)return Promise.resolve(!1);const b=Number.isFinite(p)&&p>0?p:8e3;return new Promise(S=>{const w=Date.now(),k=window.setInterval(()=>{t.sessionId.value!==g?(window.clearInterval(k),S(!1)):t.connectionStatus.value==="connected"?(window.clearInterval(k),S(!0)):(t.connectionStatus.value==="idle"||t.disposed||Date.now()-w>=b)&&(window.clearInterval(k),S(!1))},50)})}function a(p){var g;((g=t.ws)==null?void 0:g.readyState)===WebSocket.OPEN&&t.ws.send(JSON.stringify(p))}function l(p){u();const g=Number.isFinite(p)&&p>=1e3&&p<=12e4?p:15e3;t.lastPongAt=Date.now(),t.heartbeatTimer=window.setInterval(()=>{var b;if(Date.now()-t.lastPongAt>Xv){(b=t.ws)==null||b.close();return}a({type:"ping"})},g)}function u(){t.heartbeatTimer!==null&&(clearInterval(t.heartbeatTimer),t.heartbeatTimer=null)}function c(){if(t.disposed||t.reconnectTimer!==null)return;if(t.reconnectAttempt>=pc){r("disconnected"),t.error.value=`连接失败:自动重试已达上限(${pc} 次),请手动重试`;return}r("reconnecting"),t.reconnectAttempt++;const p=Math.min(1e3*2**t.reconnectAttempt,3e4);t.reconnectTimer=window.setTimeout(()=>{t.reconnectTimer=null,f()},p)}function d(){if(!t.disposed){if(t.reconnectTimer!==null&&(clearTimeout(t.reconnectTimer),t.reconnectTimer=null),t.ws!==null){try{t.ws.close()}catch{}t.ws=null}t.reconnectAttempt=0,f()}}function f(){if(t.disposed||t.ws&&(t.ws.readyState===WebSocket.CONNECTING||t.ws.readyState===WebSocket.OPEN))return;r("connecting"),t.error.value=null,e.resetGoalRequestState(),t.connectionGeneration++;const p=new WebSocket(o());t.ws=p,p.onclose=g=>{if(t.ws===p&&(t.ws=null,u(),t.connectionStatus.value!=="idle")){if(g.code===1008){t.sessionGeneration++,e.resetGoalRequestState(),t.sessionId.value=null,t.currentSessionId.value=null,t.sessionActive.value=!1,t.goal.value=null,t.todos.value=[],t.subagents.value=[],t.sessionPlan.value=null,t.skills.value=[],t.skillsError.value=null,t.plugins.value=[],t.pluginInfo.value=null,t.mcpServers.value=[],t.mcpStartupMetrics.value=null,t.backgroundTasks.value=[],t.backgroundTaskOutput.value="",t.pendingApprovals.value=[],t.status.value={busy:!1},t.gitStatus.value=null,t.workDir.value=null,t.messages.value=[],t.error.value=null,t.promptPending.value=!1,t.sentMessageIds.clear(),r("idle"),g.reason!=="unauthorized"&&(n("会话不可用或已被删除","warning"),e.fetchSessions());return}r("disconnected"),c()}},p.onerror=()=>{t.ws===p&&r("reconnecting")},p.onmessage=g=>{if(t.ws!==p)return;t.lastPongAt=Date.now();let b;try{b=JSON.parse(g.data)}catch{return}s(b)}}return Yt(t,"server_hello",p=>{t.sessionId.value=p.sessionId,t.workDir.value=p.workDir,t.currentSessionId.value=p.sessionId,t.sessionActive.value=p.active;const g=t.epoch;t.epoch=p.epoch,l(p.heartbeat_ms),a({type:"client_hello",lastSeq:t.seq,epoch:g}),g!==0&&g!==p.epoch&&(t.seq=0),r("connected"),t.reconnectAttempt=0,e.flushQueue();const b=t.sessionGeneration,S=t.connectionGeneration,w=()=>t.sessionId.value===p.sessionId&&t.currentSessionId.value===p.sessionId&&t.sessionGeneration===b&&t.connectionGeneration===S,k=()=>{w()&&(e.fetchSnapshot().finally(()=>{var y;w()&&((y=e.refreshSessionResources)==null||y.call(e))}),e.fetchSessions(),e.fetchGitStatus())};p.active?k():e.activateSession(p.sessionId).then(y=>{w()&&(y&&t.sessionId.value===p.sessionId&&(t.sessionActive.value=!0),k())})}),Yt(t,"server_empty",()=>{r("idle")}),Yt(t,"pong",()=>{}),e.connect=f,e.waitForConnected=i,e.send=a,e.stopHeartbeat=u,e.setConnectionStatus=r,{connect:f,waitForConnected:i,send:a,reconnectNow:d,stopHeartbeat:u}}function Ay(){const e=Qv(),t=e.s;ey(e);const n=yy(e),s=by(e),o=ky(e),r=wy(e),i=Sy(e),a=_y(e),l=$y(e),u=Cy(e),c=xy(e),d=Iy(e),f=Ey(e);e.refreshSessionResources=async()=>{t.sessionId.value&&await Promise.all([l.fetchSessionStatus(),l.fetchSessionUsage(),l.fetchSessionContext(),l.fetchSessionPlan(),u.fetchSkills(),u.fetchPlugins(),c.fetchMcpServers(),c.fetchMcpStartupMetrics(),c.fetchBackgroundTasks()])},f.connect(),r.fetchSessions(),i.fetchModels();const p=()=>{f.connect()},g=()=>{!document.hidden&&t.connectionStatus.value!=="connected"&&f.connect()};window.addEventListener("online",p),document.addEventListener("visibilitychange",g),st(()=>{t.disposed=!0,n.disposeStreaming(),window.removeEventListener("online",p),document.removeEventListener("visibilitychange",g),f.stopHeartbeat(),t.reconnectTimer!==null&&(clearTimeout(t.reconnectTimer),t.reconnectTimer=null),t.snapshotRetryTimer!==null&&(clearTimeout(t.snapshotRetryTimer),t.snapshotRetryTimer=null),t.ws&&(t.ws.onclose=null,t.ws.close(),t.ws=null)}),Se(t.skills,S=>dc(S),{immediate:!0});const b={connectionStatus:t.connectionStatus,waitForConnected:f.waitForConnected,messages:t.messages,pendingApprovals:t.pendingApprovals,status:t.status,goal:t.goal,todos:t.todos,goalRequestPending:t.goalRequestPending,goalRequestError:t.goalRequestError,error:t.error,sessionId:t.sessionId,workDir:t.workDir,isBusy:t.isBusy,isArchived:t.isArchived,sessions:t.sessions,currentSessionId:t.currentSessionId,gitStatus:t.gitStatus,models:t.models,modelsError:t.modelsError,like:t.like,fetchLike:i.fetchLike,updateLike:i.updateLike,sendPrompt:o.sendPrompt,sendCommand:o.sendCommand,clearMessages:o.clearMessages,appendSystemMessage:o.appendSystemMessage,abort:o.abort,resolveApproval:o.resolveApproval,fetchSessions:r.fetchSessions,fetchGitStatus:r.fetchGitStatus,fetchModels:i.fetchModels,reconnectNow:f.reconnectNow,olderAvailable:t.olderAvailable,oldestSeq:t.oldestSeq,loadOlderMessages:o.loadOlderMessages,switchModel:i.switchModel,switchThinking:i.switchThinking,refineGoal:a.refineGoal,createGoal:a.createGoal,updateGoal:a.updateGoal,pauseGoal:a.pauseGoal,resumeGoal:a.resumeGoal,cancelGoal:a.cancelGoal,createSession:r.createSession,switchSession:r.switchSession,deleteSession:r.deleteSession,exportSession:r.exportSession,fetchSnapshot:s.fetchSnapshot,fetchSessionStatus:l.fetchSessionStatus,fetchSessionUsage:l.fetchSessionUsage,fetchSessionContext:l.fetchSessionContext,fetchSessionPlan:l.fetchSessionPlan,sessionPlan:t.sessionPlan,clearPlan:l.clearPlan,switchPermission:l.switchPermission,switchPlanMode:l.switchPlanMode,switchWolfpack:l.switchWolfpack,switchRlm:l.switchRlm,undoHistory:l.undoHistory,compact:l.compact,skills:t.skills,skillsError:t.skillsError,fetchSkills:u.fetchSkills,activateSkill:u.activateSkill,removeSkill:u.removeSkill,plugins:t.plugins,pluginInfo:t.pluginInfo,fetchPlugins:u.fetchPlugins,fetchPluginInfo:u.fetchPluginInfo,installPlugin:u.installPlugin,setPluginEnabled:u.setPluginEnabled,setPluginMcpServerEnabled:u.setPluginMcpServerEnabled,removePlugin:u.removePlugin,reloadPlugins:u.reloadPlugins,activatePlugin:u.activatePlugin,deactivatePlugin:u.deactivatePlugin,injectPlugin:u.injectPlugin,mcpServers:t.mcpServers,mcpStartupMetrics:t.mcpStartupMetrics,fetchMcpServers:c.fetchMcpServers,fetchMcpStartupMetrics:c.fetchMcpStartupMetrics,addMcpServer:c.addMcpServer,reconnectMcpServer:c.reconnectMcpServer,stopMcpServer:c.stopMcpServer,removeMcpServer:c.removeMcpServer,backgroundTasks:t.backgroundTasks,backgroundTaskOutput:t.backgroundTaskOutput,subagents:t.subagents,fetchBackgroundTasks:c.fetchBackgroundTasks,fetchBackgroundTaskOutput:c.fetchBackgroundTaskOutput,stopBackgroundTask:c.stopBackgroundTask,config:t.config,fetchConfig:d.fetchConfig,setConfig:d.setConfig,removeProvider:d.removeProvider,experimentalFlags:t.experimentalFlags,fetchExperimentalFlags:d.fetchExperimentalFlags,preflightOk:t.preflightOk,preflight:d.preflight};return qv(b),st(()=>{Vv(b),dc([])}),b}const My=["compact","auto","ask","yes","bot","plan","fork","title","btw"];function bc(e){const t=(e==null?void 0:e.trim().toLowerCase())??"";return t.length===0?"toggle":t==="on"?!0:t==="off"?!1:null}function Ry(e){const t=(e==null?void 0:e.trim())??"";if(t.length===0)return 1;if(!/^[1-9]\d*$/.test(t))return null;const n=Number(t);return Number.isSafeInteger(n)?n:null}function Py(e){const t=(e==null?void 0:e.trim())??"";if(!/^\d+$/.test(t))return null;const n=Number(t);return Number.isSafeInteger(n)?n:null}function lh(e){const{showToast:t}=Qs();async function n(){var f;try{if(await((f=e.ensureSession)==null?void 0:f.call(e))===!1)return null}catch(p){return t(`无法创建会话:${p instanceof Error?p.message:String(p)}`,"error"),null}const d=Ha();return!d||!d.sessionId.value?(t("请先创建或打开一个会话。","warning"),null):d}async function s(d,f){try{await d()&&t(f,"success")}catch(p){t(`操作失败:${p instanceof Error?p.message:String(p)}`,"error")}}async function o(d){const f=bc(d);if(f===null){t("用法:/wolfpack [on|off]","warning");return}const p=await n();if(!p)return;const g=f==="toggle"?p.status.value.wolfpackMode!==!0:f;await s(()=>p.switchWolfpack(g),`Wolfpack 模式已${g?"开启":"关闭"}`)}async function r(d){const f=bc(d);if(f===null){t("用法:/rlm [on|off]","warning");return}const p=await n();if(!p)return;const g=f==="toggle"?p.status.value.rlmEnabled!==!0:f;await s(()=>p.switchRlm(g),`RLM 模式已${g?"开启":"关闭"}`)}async function i(d){const f=(d==null?void 0:d.trim())??"";if(f.length===0){const S=await n();if(!S)return;const w=S.status.value.rlmMaxDepth??null;e.appendSystemMessage(w===null?"RLM 最大深度:无限(默认)。":`RLM 最大深度:${w}。`);return}const p=Py(f);if(p===null){t("RLM 深度需为 0 或非负整数。","warning");return}const g=await n();if(!g)return;const b=g.status.value.rlmEnabled===!0;await s(()=>g.switchRlm(b,p),p===0?"RLM 递归深度已设为无限。":`RLM 最大深度已设为 ${p}。`)}async function a(d){const f=(d==null?void 0:d.trim().toLowerCase())??"";if(f!==""&&f!=="on"&&f!=="off"){t("用法:/fusionplan [on|off]","warning");return}const p=await n();if(!p)return;const g=p.status.value.planMode===!0&&p.status.value.planStrategy==="fusion",b=f==="off"?!1:f==="on"?!0:!g;await s(()=>p.switchPlanMode(b,b?"fusion":void 0),`融合计划模式已${b?"开启":"关闭"}`)}async function l(d){const f=Ry(d);if(f===null){t("用法:/revoke [正整数轮数]","warning");return}const p=await n();if(p){if(p.isBusy.value){t("当前回合正在运行,无法撤销。","error");return}try{if(!await p.undoHistory(f))return;await p.fetchSnapshot(),t(`已撤销最近 ${f} 轮。`,"success")}catch(g){t(`撤销失败:${g instanceof Error?g.message:String(g)}`,"error")}}}async function u(d,f){var S;if(await((S=e.ensureSession)==null?void 0:S.call(e))===!1)return;const g=e.onSkill??(async(w,k)=>{const y=Ha();return y?await y.activateSkill(w,k):!1});let b=!1;try{b=await g(d,f)}catch(w){b=!1,t(`技能激活失败:${w instanceof Error?w.message:String(w)}`,"error");return}b?t(`技能已激活:/${d}`,"success"):t(`技能激活失败:/${d}`,"error")}async function c(d,f){var p,g,b;if(My.includes(d)){if(await((p=e.ensureSession)==null?void 0:p.call(e))===!1)return;e.sendCommand(d,f)}else d==="wolfpack"?await o(f):d==="rlm"?await r(f):d==="rlm-max-depth"?await i(f):d==="fusionplan"?await a(f):d==="revoke"?await l(f):d==="clear"?e.clearMessages():d==="new"?e.onNew():d==="help"?e.appendSystemMessage(Wv()):d==="model"?(g=e.openModelPicker)!=null&&g.call(e)||e.appendSystemMessage(`当前模型:${((b=e.currentModel)==null?void 0:b.call(e))??"unknown"}`):d==="status"||d==="usage"?e.showInfo?e.showInfo(d):e.appendSystemMessage("请在对话页查看会话详情"):Hv(d)?await u(d,f):t(`未知命令:/${d}`,"error")}return{onCommand:c}}const Ly=640,Dy=1024,Fl=768,kc=264,Vr=420,Ny=288,wc=56,Wa=300,uh=.7,Oy=320,ch=400;function ss(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 Gy(e){return ss(e*.45,Wa,Math.round(e*uh))}function By(e){const{viewportWidth:t,rightPanelOpen:n,rightPanelWidth:s}=e;if(t<=Ly)return Vr;const o=t<Fl,r=o?Oy:ch,i=!o&&n?s:0;return Math.min(Vr,t-r-i)}function Fy(e){const{viewportWidth:t,sidebarOpen:n,sidebarWidth:s}=e,o=Math.round(t*uh);if(t<Fl)return o;const r=n?s:0;return Math.min(o,t-ch-r)}function Kr(e){try{return localStorage.getItem(e)??void 0}catch{return}}function Zr(e,t){try{localStorage.setItem(e,t)}catch{}}function Uy(e){try{const t=localStorage.getItem(e);return t===null?void 0:JSON.parse(t)}catch{return}}function jy(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function Sc(e){const{storageKey:t,minWidth:n,side:s}=e,o=y=>typeof y=="function"?y():y,r=()=>o(e.maxWidth);function i(){var _;const y=Uy(t);return typeof y=="number"&&Number.isFinite(y)&&y>=n&&(((_=e.acceptStoredWidth)==null?void 0:_.call(e,y))??!0)?Math.round(y):o(e.defaultWidth)}const a=G(i()),l=G(!1);let u=null;function c(){jy(t,a.value)}function d(y){return s==="left"?y:window.innerWidth-y}function f(y){if(!(e.canDrag&&!e.canDrag())){y.preventDefault(),l.value=!0,u=y.pointerId;try{y.currentTarget.setPointerCapture(y.pointerId)}catch{}}}function p(y){!l.value||y.pointerId!==u||(a.value=ss(d(y.clientX),n,r()))}function g(y){!l.value||y.pointerId!==u||b()}function b(){l.value=!1,u=null,c()}function S(){a.value=ss(o(e.defaultWidth),n,r()),c()}function w(y){const _=y.shiftKey?32:12,N=s==="left"?1:-1;if(y.key==="ArrowLeft")y.preventDefault(),a.value=ss(a.value-N*_,n,r());else if(y.key==="ArrowRight")y.preventDefault(),a.value=ss(a.value+N*_,n,r());else if(y.key==="Home")y.preventDefault(),a.value=n;else if(y.key==="End")y.preventDefault(),a.value=ss(r(),n,r());else if(y.key==="Enter")y.preventDefault(),S();else return;c()}const k=B(()=>ss(a.value,n,r()));return{width:a,effectiveWidth:k,resizing:l,onPointerDown:f,onPointerMove:p,onPointerUp:g,onKeydown:w,reset:S,release:b}}const Ul=new Map;function Pn(e){return Ul.set(e.kind,e),e}function dh(e){const t=Ul.get(e);if(!t)throw new Error(`unregistered dock tab kind: ${e}`);return t}function zy(e){return typeof e=="string"&&Ul.has(e)}Pn({kind:"file",label:"文件",icon:"file",singleton:!1});Pn({kind:"detail",label:"会话详情",icon:"layers",singleton:!0});Pn({kind:"control",label:"会话控制",icon:"wrench",singleton:!0});Pn({kind:"agents",label:"协作代理",icon:"bot",singleton:!0});Pn({kind:"run",label:"运行状态",icon:"activity",singleton:!0});Pn({kind:"git",label:"Git",icon:"git-branch",singleton:!0});Pn({kind:"todo",label:"Todo",icon:"clipboard",singleton:!0});Pn({kind:"goal",label:"目标",icon:"target",singleton:!0});Pn({kind:"like",label:"偏好",icon:"user",singleton:!0});function fh(e){return`dock:${e}`}function Yr(e){return`dock-tab-${encodeURIComponent(e)}`}function qa(e){return`dock-panel-${encodeURIComponent(e)}`}function Hy(e,t){return(e==null?void 0:e.displayMode)??t??"source"}function Wy(e,t){const n=e.find(r=>r.id===t.tabId);if(!n)return[...e,{id:t.tabId,kind:"file",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}];if(n.kind!=="file")return e;const s=!!(t.sourceSessionId&&n.sourceSessionId!==t.sourceSessionId);return!s&&!t.modeHint?e:e.map(r=>{var a;if(r.id!==t.tabId||r.kind!=="file")return r;const i={...r};return s&&(i.sourceSessionId=t.sourceSessionId),t.modeHint?(i.initialDisplayMode=t.modeHint,i.viewerState={displayMode:t.modeHint,wrapLines:((a=r.viewerState)==null?void 0:a.wrapLines)??!1,scrollTop:0,scrollLeft:0},i.viewerRevision=(r.viewerRevision??0)+1):s&&(i.viewerRevision=(r.viewerRevision??0)+1),i})}function qy(e,t){const n=fh(t);return e.some(s=>s.id===n)?e:[...e,{id:n,kind:t,label:dh(t).label}]}function Vy(e,t,n,s){const o=e.findIndex(a=>a.id===t&&a.kind==="file");if(o===-1)return e;const r=e[o];if((r.viewerRevision??0)!==n)return e;const i=[...e];return i[o]={...r,viewerState:s},i}const hh="scream-file-tabs";function Ky(){try{const e=localStorage.getItem(hh);return e?JSON.parse(e):{}}catch{return{}}}function Zo(e){try{localStorage.setItem(hh,JSON.stringify(e))}catch{}}function Zy(e){return typeof e.id!="string"||typeof e.label!="string"?null:e.kind===void 0?typeof e.filePath=="string"?{...e,kind:"file"}:null:zy(e.kind)?e.kind==="file"?typeof e.filePath!="string"?null:e:{id:e.id,kind:e.kind,label:e.label}:null}const Go=Ky(),sa=(Array.isArray(Go.tabs)?Go.tabs:[]).map(e=>Zy(e)).filter(e=>e!==null),_c=typeof Go.activeTabId=="string"?Go.activeTabId:null;var Od;const we=Wn({tabs:sa,activeTabId:sa.some(e=>e.id===_c)?_c:((Od=sa.at(-1))==null?void 0:Od.id)??null,panelOpen:Go.panelOpen===!0});function Yy(){var e;if(we.tabs.length===0){we.activeTabId=null;return}we.tabs.some(t=>t.id===we.activeTabId)||(we.activeTabId=((e=we.tabs.at(-1))==null?void 0:e.id)??null)}function vs(e,t={}){const n=e.split("/").pop()||e,s=e;return we.tabs=Wy(we.tabs,{fileName:t.label??n,filePath:e,modeHint:t.modeHint,sourceSessionId:t.sessionId??null,tabId:s}),we.activeTabId=s,we.panelOpen=!0,Zo(we),s}function Sr(e){const t=fh(e);return we.tabs=qy(we.tabs,e),we.activeTabId=t,we.panelOpen=!0,Zo(we),t}function Xy(e){we.tabs.some(t=>t.id===e)&&(we.activeTabId=e,Zo(we))}function Jy(e){const t=we.tabs.findIndex(n=>n.id===e);if(t!==-1){if(we.tabs=we.tabs.filter(n=>n.id!==e),we.activeTabId===e){const n=we.tabs[t]??we.tabs[t-1]??null;we.activeTabId=n?n.id:null}we.tabs.length===0&&(we.panelOpen=!1,we.activeTabId=null),Zo(we)}}function jl(e){we.panelOpen=e,e&&Yy(),Zo(we)}function Qy(){jl(!we.panelOpen)}const Va=()=>we.tabs.find(e=>e.id===we.activeTabId),eb=()=>{const e=Va();return e&&e.kind==="file"?e:void 0},Ai=G(!1);let Xr=0;function tb(){Xr++}function nb(){Xr=Math.max(0,Xr-1)}function sb(){return Xr>0}function ph(){return sb()?(Ai.value=!0,!0):!1}function ob(){Ai.value=!0}function Jr(){Ai.value=!1}function gh(){return{open:Ai,openSettingsModal:ob,closeSettingsModal:Jr,tryOpenSettingsModal:ph}}const mh="scream-workspace-preference",Mi=G(Kr(mh)||null),zl=G(null);let co=null;function rb(e){Mi.value=e,Zr(mh,e??"")}async function ib(){return co||(co=(async()=>{try{const e=await fetch(`${Ge}/workdir`);if(!e.ok)return;const t=await e.json();typeof t.workDir=="string"&&t.workDir&&(zl.value=t.workDir)}catch{}finally{co=null}})(),co)}const ab=B(()=>Mi.value??zl.value??""),lb=B(()=>!!Mi.value);function Hl(){return{preferredWorkDir:Mi,serverWorkDir:zl,displayWorkDir:ab,hasPreference:lb,setPreferredWorkDir:rb,fetchServerWorkDir:ib}}function Ka(e){const t=e.replace(/[\\/]+$/,"");return t.split(/[\\/]/).filter(Boolean).at(-1)??t??e}const ub=["type","disabled"],cb=Ie({__name:"Button",props:{variant:{default:"primary"},size:{default:"md"},disabled:{type:Boolean},type:{default:"button"}},setup(e){return(t,n)=>(m(),v("button",{class:ue(["ui-btn",[`ui-btn--${e.variant}`,`ui-btn--${e.size}`]]),type:e.type,disabled:e.disabled},[Co(t.$slots,"default",{},void 0)],10,ub))}}),Te=(e,t)=>{const n=e.__vccOpts||e;for(const[s,o]of t)n[s]=o;return n},Ht=Te(cb,[["__scopeId","data-v-293d37e0"]]),db={key:0,class:"approval-card"},fb={class:"approval-header"},hb={class:"approval-title"},pb={class:"tool-name"},gb={class:"action-summary"},mb={key:0,class:"approval-count"},vb={key:0,class:"approval-source"},yb={key:1,class:"approval-summary"},bb={key:2,class:"approval-reasons"},kb={class:"approval-action"},wb={key:3,class:"feedback-area"},Sb={class:"approval-buttons"},_b={key:1,class:"busy-indicator","aria-label":"处理中"},$b=Ie({__name:"ApprovalCard",props:{approvals:{}},emits:["resolve"],setup(e,{emit:t}){const n=e,s=t,o=G(!1),r=G(!1),i=G(""),a=G(new Set),l=B(()=>n.approvals[0]),u=["once","session"],c=B(()=>{var k;return(((k=l.value)==null?void 0:k.grantOptions)??u).includes("session")});Se(()=>n.approvals.map(k=>k.id).join(","),()=>{r.value=!1,i.value="";const k=new Set(n.approvals.map(y=>y.id));a.value=new Set([...a.value].filter(y=>k.has(y)))});function d(k){return typeof k.display=="string"?k.display:k.display&&typeof k.display=="object"&&"description"in k.display?String(k.display.description??""):k.action??"执行该操作"}function f(k){const y=k.sourceAgentId,_=k.sourceAgentName,N=k.sourceToolName??k.toolName,D=_??y??"",E=y!==void 0&&y!==""&&y!==D?`${D}(${y})`:D,A=N!==void 0&&N!==""?` · ${N}`:"";return`来源:${E}${A}`}function p(k){return k!==void 0&&(k.sourceAgentId!==void 0||k.sourceAgentName!==void 0)}function g(k){return a.value.has(k)}function b(k,y,_){const N=l.value;!N||g(N.id)||(a.value=new Set([...a.value,N.id]),s("resolve",N.id,k,y,_))}function S(){const k=i.value.trim();k&&b("rejected",k)}function w(k){if(!l.value||o.value)return;const _=k.target;if(_&&(_.tagName==="TEXTAREA"||_.tagName==="INPUT")){r.value&&k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),S());return}switch(k.key){case"1":k.preventDefault(),b("approved",void 0,"once");break;case"2":if(!c.value)break;k.preventDefault(),b("approved",void 0,"session");break;case"3":k.preventDefault(),b("rejected");break;case"4":k.preventDefault(),r.value=!r.value;break}}return et(()=>window.addEventListener("keydown",w)),st(()=>window.removeEventListener("keydown",w)),(k,y)=>e.approvals.length?(m(),v("div",db,[o.value?(m(),v("button",{key:0,class:"approval-minibar",onClick:y[0]||(y[0]=_=>o.value=!1)}," ⚠ "+C(e.approvals.length)+" 个待审批请求 — 点击展开 ",1)):l.value?(m(),v(te,{key:1},[h("div",fb,[y[7]||(y[7]=h("span",{class:"approval-icon"},"⚠",-1)),h("span",hb,[h("span",pb,C(l.value.toolName),1),h("span",gb,C(d(l.value)),1)]),e.approvals.length>1?(m(),v("span",mb,"+"+C(e.approvals.length-1),1)):F("",!0),h("button",{class:"icon-btn",title:"最小化","aria-label":"最小化",onClick:y[1]||(y[1]=_=>o.value=!0)},"—")]),p(l.value)?(m(),v("p",vb,C(f(l.value)),1)):F("",!0),l.value.requestSummary?(m(),v("p",yb,C(l.value.requestSummary),1)):F("",!0),l.value.reasons&&l.value.reasons.length?(m(),v("ul",bb,[(m(!0),v(te,null,Ce(l.value.reasons,(_,N)=>(m(),v("li",{key:N},C(_),1))),128))])):F("",!0),h("pre",kb,C(d(l.value)),1),r.value?(m(),v("div",wb,[Ze(h("textarea",{"onUpdate:modelValue":y[2]||(y[2]=_=>i.value=_),class:"feedback-input",rows:"2",name:"approval-feedback","aria-label":"拒绝反馈",placeholder:"输入反馈,Enter 提交(将作为拒绝原因反馈给 Agent)"},null,512),[[it,i.value]])])):F("",!0),h("div",Sb,[X(Ht,{variant:"primary",disabled:g(l.value.id),onClick:y[3]||(y[3]=_=>b("approved",void 0,"once"))},{default:ot(()=>[...y[8]||(y[8]=[h("kbd",null,"1",-1),Ae(" 批准 ",-1)])]),_:1},8,["disabled"]),c.value?(m(),De(Ht,{key:0,variant:"secondary",disabled:g(l.value.id),onClick:y[4]||(y[4]=_=>b("approved",void 0,"session"))},{default:ot(()=>[...y[9]||(y[9]=[h("kbd",null,"2",-1),Ae(" 会话批准 ",-1)])]),_:1},8,["disabled"])):F("",!0),X(Ht,{variant:"danger",disabled:g(l.value.id),onClick:y[5]||(y[5]=_=>b("rejected"))},{default:ot(()=>[...y[10]||(y[10]=[h("kbd",null,"3",-1),Ae(" 拒绝 ",-1)])]),_:1},8,["disabled"]),X(Ht,{variant:"secondary",class:ue({"feedback-active":r.value}),disabled:g(l.value.id),onClick:y[6]||(y[6]=_=>r.value=!r.value)},{default:ot(()=>[...y[11]||(y[11]=[h("kbd",null,"4",-1),Ae(" 反馈 ",-1)])]),_:1},8,["class","disabled"]),g(l.value.id)?(m(),v("span",_b,[...y[12]||(y[12]=[h("span",{class:"spinner"},null,-1),Ae(" 处理中… ",-1)])])):F("",!0)])],64)):F("",!0)])):F("",!0)}}),Cb=Te($b,[["__scopeId","data-v-d8a705ce"]]);function xb(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 $c(e){let t=0;for(let n=0;n<e.length;n++)e[n]==="/"&&t++;return t}function Cc(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 Ib(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:Cc(t,n)&&(s=10);else{const o=n.lastIndexOf("/"),r=o===-1?n:n.slice(o+1);r===t?s=100:r.startsWith(t)?s=80:r.includes(t)?s=50:n.includes(t)?s=30:Cc(t,n)&&(s=10)}return e.isDir&&s>0&&(s+=10),s}const Tb=20;function vh(e,t,n=Tb){const s=t.toLowerCase();if(!s)return e.slice(0,n);const o=[];for(const r of e){const i=Ib(r,s);i>0&&o.push({entry:r,score:i})}return o.sort((r,i)=>i.score-r.score||$c(r.entry.path)-$c(i.entry.path)||r.entry.path.localeCompare(i.entry.path)),o.slice(0,n).map(r=>r.entry)}function Eb(e,t){const n=t?`${e}/`:e,s=n.includes(" ");if(t){const r=s?`@"${n}"`:`@${n}`;return{text:r,cursorOffset:s?r.length-1:r.length}}const o=s?`@"${n}" `:`@${n} `;return{text:o,cursorOffset:o.length}}const Ab="/api/v1/files",Mb=3e4,Rb=200,os=new Map,_r=new Map;async function Wl(e){const t=os.get(e);if(t){if(Date.now()-t.at<Mb)return t.entries;os.delete(e)}const n=_r.get(e);if(n)return n;const s=(async()=>{try{const o=await fetch(`${Ab}/list?path=${encodeURIComponent(e)}`);if(!o.ok)return null;const r=await o.json();if(r.entries)for(os.set(e,{entries:r.entries,at:Date.now()});os.size>Rb;){const i=os.keys().next().value;if(i===void 0)break;os.delete(i)}return r.entries??null}catch{return null}finally{_r.delete(e)}})();return _r.set(e,s),s}function Pb(e){os.delete(e),_r.delete(e)}function Lb(e,t){const n=e.replace(/\/+$/,""),s=n.split("/").filter(Boolean),o=[...s];for(const i of t.split("/"))if(!(!i||i===".")){if(i===".."){if(o.length<=s.length)return null;o.pop();continue}o.push(i)}const r=`/${o.join("/")}`;return r===n||r.startsWith(`${n}/`)?r:null}function Db(e,t,n){const s=G(null),o=G([]),r=G(!1),i=G(!1),a=G(0),l=G(!1),u=G(null),c=G("");let d=null;function f(){d||(d=(async()=>{var A;try{const T=await fetch("/api/v1/files/root"),Z=T.ok?await T.json():{};c.value=((A=Z.roots)==null?void 0:A[0])??""}catch{c.value=""}y()})())}const p=B(()=>{const A=u.value;if(!A)return[];const T=A.query.lastIndexOf("/"),Z=A.query.slice(T+1);return vh(o.value,Z)}),g=B(()=>u.value!==null&&!l.value&&(r.value||p.value.length>0));function b(A){const T=A.lastIndexOf("/");return T===-1?{dirRel:"",tail:A}:{dirRel:A.slice(0,T),tail:A.slice(T+1)}}let S=!1,w=0;async function k(A,T){const Z=++w;r.value=!0;try{const W=await Wl(A);if(W===null)throw new Error("listing failed");if(Z!==w)return;const j=T?`${T.replace(/\/+$/,"")}/`:"";o.value=W.map(ne=>({path:`${j}${ne.name}`,isDir:ne.type==="dir"})),i.value=!1}catch{if(Z!==w)return;o.value=[],i.value=!0,s.value=null}finally{Z===w&&(r.value=!1)}}function y(){var M;if(S)return;const A=t.value;if(A&&A.value!==e.value){u.value=null;return}let T=(M=n.value)==null?void 0:M.trim();if(T||(f(),T=c.value),!A||!T){u.value=null;return}const Z=A.selectionStart??A.value.length,W=xb(A.value.slice(0,Z));if(!W){u.value=null,l.value=!1;return}const j=u.value;(!j||j.start!==W.start||j.query!==W.query)&&(l.value=!1),u.value=W,a.value=0;const{dirRel:ne}=b(W.query),I=Lb(T,ne);if(I===null){s.value=null,o.value=[],i.value=!0;return}s.value!==I&&(s.value=I,k(I,ne))}function _(A){const T=p.value.length;T>0&&(a.value=(a.value+A+T)%T)}function N(A){const T=u.value,Z=A??p.value[a.value];if(!T||!Z)return!1;const W=t.value;if(!W)return!1;const j=W.selectionStart??W.value.length,ne=Eb(Z.path,Z.isDir),I=e.value.slice(0,T.start),M=e.value.slice(j);e.value=I+ne.text+M,S=!0;const V=()=>{const ie=T.start+ne.cursorOffset;W.focus(),W.setSelectionRange(ie,ie),S=!1,y()};return typeof requestAnimationFrame=="function"?requestAnimationFrame(V):Promise.resolve().then(V),!0}function D(){l.value=!0}function E(){u.value=null,l.value=!1,a.value=0}return{visible:g,suggestions:p,index:a,dirLoading:r,dirMissing:i,refresh:y,move:_,confirm:N,dismiss:D,reset:E}}const yh=50;function Nb(e,t=yh){const n=new Set,s=[];for(let o=e.length-1;o>=0&&s.length<t;o-=1){const r=e[o];if(!r||r.role!=="user"||r.local)continue;const i=(r.content??"").trim();!i||n.has(i)||(n.add(i),s.push(i))}return s}function Ob(e,t,n=yh){const s=new Set,o=[],r=i=>{const a=i.trim();!a||s.has(a)||(s.add(a),o.push(a))};for(const i of t)r(i);for(let i=e.length-1;i>=0;i-=1){const a=e[i];a!==void 0&&r(a)}return o.slice(0,n).toReversed()}function Za(e,t){return[{title:t,entries:e}]}function Gb(){if(typeof navigator>"u")return"Ctrl";const e=`${navigator.platform??""} ${navigator.userAgent??""}`;return/Mac|iPhone|iPad|iPod/.test(e)?"⌘":"Ctrl"}const $r=Gb(),Bb=["width","height"],Fb={key:0,d:"M4 7h16M4 12h16M4 17h16"},Ub={key:1,d:"M12 5v14M5 12h14"},jb={key:5,d:"M4 6h16M7 12h10M10 18h4"},zb={key:6,d:"M12 3v12m0 0 4-4m-4 4-4-4M5 20h14"},Hb={key:7,d:"M4 7h16M9 7V4h6v3m3 0-1 13H7L6 7m4 4v5m4-5v5"},Wb={key:8,d:"M3 12h4l2-7 4 14 2-7h6"},qb={key:10,d:"m15 18-6-6 6-6"},Vb={key:11,d:"m9 18 6-6-6-6"},Kb={key:12,d:"m6 9 6 6 6-6"},Zb={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"},Yb={key:18,d:"M5 9a11 11 0 0 1 14 0M8.5 12.5a6 6 0 0 1 7 0M12 17h.01"},Xb={key:19,d:"M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L8 18l-4 1 1-4Z"},Jb={key:20,d:"M12 16V4m0 0-4 4m4-4 4 4M5 20h14"},Qb={key:21,d:"m15 4 5 5M17.5 6.5 10 14m-2-2 4 4-3 4H3l1-6Z"},ek={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"},tk={key:24,d:"m22 2-7 20-4-9-9-4ZM22 2 11 13"},nk={key:25,x:"6",y:"6",width:"12",height:"12",rx:"2"},sk={key:26,d:"m8 3 4 4 4-4M8 21l4-4 4 4M12 7v10"},ok={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"},rk={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"},ik={key:31,d:"M20 13 13 20l-9-9V4h7ZM8.5 8.5h.01"},ak={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"},lk={key:34,d:"M3 6h7l2 2h9v11H3Z"},uk={key:35,d:"m5 12 4 4L19 6"},ck={key:39,d:"M21 12a9 9 0 1 1-2.6-6.4M21 3v6h-6"},dk={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"},fk={key:47,d:"M12 19V5m0 0-6 6m6-6 6 6"},hk={key:48,d:"M18 6 6 18M6 6l12 12"},pk={key:51,d:"M9 4H4v5M15 4h5v5M9 20H4v-5M15 20h5v-5"},gk={key:52,d:"M4 9h5V4M20 9h-5V4M4 15h5v5M20 15h-5v5"},mk={key:56,d:"M4 20V10M10 20V4M16 20v-7M21 20H3"},vk=Ie({__name:"SvgIcon",props:{name:{},size:{default:20}},setup(e){return(t,n)=>(m(),v("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"?(m(),v("path",Fb)):e.name==="plus"?(m(),v("path",Ub)):e.name==="panel-left"?(m(),v(te,{key:2},[n[0]||(n[0]=h("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"},null,-1)),n[1]||(n[1]=h("path",{d:"M9 4v16"},null,-1))],64)):e.name==="panel-right"?(m(),v(te,{key:3},[n[2]||(n[2]=h("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"},null,-1)),n[3]||(n[3]=h("path",{d:"M15 4v16"},null,-1))],64)):e.name==="search"?(m(),v(te,{key:4},[n[4]||(n[4]=h("circle",{cx:"11",cy:"11",r:"7"},null,-1)),n[5]||(n[5]=h("path",{d:"m20 20-4-4"},null,-1))],64)):e.name==="filter"?(m(),v("path",jb)):e.name==="download"?(m(),v("path",zb)):e.name==="trash"?(m(),v("path",Hb)):e.name==="activity"?(m(),v("path",Wb)):e.name==="help"?(m(),v(te,{key:9},[n[6]||(n[6]=h("circle",{cx:"12",cy:"12",r:"9"},null,-1)),n[7]||(n[7]=h("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"?(m(),v("path",qb)):e.name==="chevron-right"?(m(),v("path",Vb)):e.name==="chevron-down"?(m(),v("path",Kb)):e.name==="bot"?(m(),v(te,{key:13},[n[8]||(n[8]=h("rect",{x:"4",y:"7",width:"16",height:"12",rx:"3"},null,-1)),n[9]||(n[9]=h("path",{d:"M12 3v4M8 12h.01M16 12h.01M9 16h6"},null,-1))],64)):e.name==="git-branch"?(m(),v(te,{key:14},[n[10]||(n[10]=h("circle",{cx:"6",cy:"5",r:"2"},null,-1)),n[11]||(n[11]=h("circle",{cx:"18",cy:"7",r:"2"},null,-1)),n[12]||(n[12]=h("circle",{cx:"6",cy:"19",r:"2"},null,-1)),n[13]||(n[13]=h("path",{d:"M6 7v10M8 10c5 0 3-3 8-3"},null,-1))],64)):e.name==="sun"?(m(),v(te,{key:15},[n[14]||(n[14]=h("circle",{cx:"12",cy:"12",r:"4"},null,-1)),n[15]||(n[15]=h("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"?(m(),v("path",Zb)):e.name==="monitor"?(m(),v(te,{key:17},[n[16]||(n[16]=h("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"},null,-1)),n[17]||(n[17]=h("path",{d:"M8 21h8M12 17v4"},null,-1))],64)):e.name==="wifi"?(m(),v("path",Yb)):e.name==="edit"?(m(),v("path",Xb)):e.name==="upload"?(m(),v("path",Jb)):e.name==="broom"?(m(),v("path",Qb)):e.name==="command"?(m(),v("path",ek)):e.name==="at"?(m(),v(te,{key:23},[n[18]||(n[18]=h("circle",{cx:"12",cy:"12",r:"4"},null,-1)),n[19]||(n[19]=h("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"?(m(),v("path",tk)):e.name==="stop"?(m(),v("rect",nk)):e.name==="compact"?(m(),v("path",sk)):e.name==="brain"?(m(),v("path",ok)):e.name==="clipboard"?(m(),v(te,{key:28},[n[20]||(n[20]=h("rect",{x:"5",y:"4",width:"14",height:"17",rx:"2"},null,-1)),n[21]||(n[21]=h("path",{d:"M9 4V2h6v2M9 10h6M9 14h6"},null,-1))],64)):e.name==="fork"?(m(),v(te,{key:29},[n[22]||(n[22]=h("circle",{cx:"6",cy:"4",r:"2"},null,-1)),n[23]||(n[23]=h("circle",{cx:"18",cy:"6",r:"2"},null,-1)),n[24]||(n[24]=h("circle",{cx:"6",cy:"20",r:"2"},null,-1)),n[25]||(n[25]=h("path",{d:"M6 6v12M8 10c6 0 4-4 8-4"},null,-1))],64)):e.name==="message-circle"?(m(),v("path",rk)):e.name==="tag"?(m(),v("path",ik)):e.name==="sparkles"?(m(),v("path",ak)):e.name==="terminal"?(m(),v(te,{key:33},[n[26]||(n[26]=h("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"},null,-1)),n[27]||(n[27]=h("path",{d:"m7 9 3 3-3 3m5 0h5"},null,-1))],64)):e.name==="folder"?(m(),v("path",lk)):e.name==="check"?(m(),v("path",uk)):e.name==="speaker"?(m(),v(te,{key:36},[n[28]||(n[28]=h("path",{d:"M11 5 6 9H3v6h3l5 4V5z"},null,-1)),n[29]||(n[29]=h("path",{d:"M15.5 8.5a5 5 0 0 1 0 7"},null,-1)),n[30]||(n[30]=h("path",{d:"M18 6a8.5 8.5 0 0 1 0 12"},null,-1))],64)):e.name==="speaker-off"?(m(),v(te,{key:37},[n[31]||(n[31]=h("path",{d:"M11 5 6 9H3v6h3l5 4V5z"},null,-1)),n[32]||(n[32]=h("path",{d:"m16 9 5 6M21 9l-5 6"},null,-1))],64)):e.name==="copy"?(m(),v(te,{key:38},[n[33]||(n[33]=h("rect",{x:"8",y:"8",width:"12",height:"12",rx:"2"},null,-1)),n[34]||(n[34]=h("path",{d:"M16 8V4H4v12h4"},null,-1))],64)):e.name==="refresh"?(m(),v("path",ck)):e.name==="target"?(m(),v(te,{key:40},[n[35]||(n[35]=h("circle",{cx:"12",cy:"12",r:"9"},null,-1)),n[36]||(n[36]=h("circle",{cx:"12",cy:"12",r:"5"},null,-1)),n[37]||(n[37]=h("circle",{cx:"12",cy:"12",r:"1"},null,-1))],64)):e.name==="settings"?(m(),v(te,{key:41},[n[38]||(n[38]=h("circle",{cx:"12",cy:"12",r:"3"},null,-1)),n[39]||(n[39]=h("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"?(m(),v(te,{key:42},[n[40]||(n[40]=h("path",{d:"M3 10.5 12 3l9 7.5"},null,-1)),n[41]||(n[41]=h("path",{d:"M5 9.5V21h14V9.5"},null,-1))],64)):e.name==="bell"?(m(),v(te,{key:43},[n[42]||(n[42]=h("path",{d:"M6 9a6 6 0 1 1 12 0c0 5 2 6 2 6H4s2-1 2-6"},null,-1)),n[43]||(n[43]=h("path",{d:"M10 19a2 2 0 0 0 4 0"},null,-1))],64)):e.name==="book"?(m(),v(te,{key:44},[n[44]||(n[44]=h("path",{d:"M4 5a2 2 0 0 1 2-2h13v18H6a2 2 0 0 0-2 2Z"},null,-1)),n[45]||(n[45]=h("path",{d:"M6 3v18"},null,-1))],64)):e.name==="layers"?(m(),v(te,{key:45},[n[46]||(n[46]=h("path",{d:"m12 3 9 5-9 5-9-5Z"},null,-1)),n[47]||(n[47]=h("path",{d:"m3 13 9 5 9-5"},null,-1))],64)):e.name==="wrench"?(m(),v("path",dk)):e.name==="arrow-up"?(m(),v("path",fk)):e.name==="x"?(m(),v("path",hk)):e.name==="file"?(m(),v(te,{key:49},[n[48]||(n[48]=h("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]=h("path",{d:"M14 2v6h6"},null,-1))],64)):e.name==="user"?(m(),v(te,{key:50},[n[50]||(n[50]=h("circle",{cx:"12",cy:"8",r:"3.5"},null,-1)),n[51]||(n[51]=h("path",{d:"M5 20a7 7 0 0 1 14 0"},null,-1))],64)):e.name==="expand"?(m(),v("path",pk)):e.name==="minimize"?(m(),v("path",gk)):e.name==="shield"?(m(),v(te,{key:53},[n[52]||(n[52]=h("path",{d:"M12 3 5 6v5.5c0 4.2 2.9 7.6 7 9.5 4.1-1.9 7-5.3 7-9.5V6Z"},null,-1)),n[53]||(n[53]=h("path",{d:"M9.5 12.2 11.3 14l3.4-3.6"},null,-1))],64)):e.name==="queue"?(m(),v(te,{key:54},[n[54]||(n[54]=h("path",{d:"M4 7h11M4 12h11M4 17h7"},null,-1)),n[55]||(n[55]=h("path",{d:"M17.5 15.5 20 18l2.5-2.5M20 18v-6"},null,-1))],64)):e.name==="more"?(m(),v(te,{key:55},[n[56]||(n[56]=h("circle",{cx:"5.5",cy:"12",r:"1.4"},null,-1)),n[57]||(n[57]=h("circle",{cx:"12",cy:"12",r:"1.4"},null,-1)),n[58]||(n[58]=h("circle",{cx:"18.5",cy:"12",r:"1.4"},null,-1))],64)):e.name==="bar-chart"?(m(),v("path",mk)):F("",!0)],8,Bb))}}),ce=Te(vk,[["__scopeId","data-v-421b9da7"]]),yk={class:"at-menu",role:"listbox","aria-label":"文件提及"},bk={key:0,class:"at-status"},kk={key:1,class:"at-status"},wk=["data-active","aria-selected","onClick","onMousemove"],Sk={class:"at-item-name"},_k={key:0,class:"at-item-dir"},$k={class:"at-hints"},Ck={class:"at-hint"},xk=["title"],Ik=Ie({__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=G(null);Se(()=>n.activeIndex,async()=>{var u;await Fe();const l=(u=o.value)==null?void 0:u.querySelector('[data-active="true"]');l==null||l.scrollIntoView({block:"nearest"})});const r=l=>l.split("/").pop()||l;function i(l){return r(l.path)}function a(l){const u=l.path.lastIndexOf("/");return u===-1?"":l.path.slice(0,u)}return(l,u)=>{var c;return m(),v("div",yk,[e.loading&&e.suggestions.length===0?(m(),v("div",bk,"加载文件列表…")):e.suggestions.length===0?(m(),v("div",kk,"无匹配文件")):(m(),v("ul",{key:2,ref_key:"listRef",ref:o,class:"at-list"},[(m(!0),v(te,null,Ce(e.suggestions,(d,f)=>(m(),v("li",{key:d.path},[h("button",{class:ue(["at-item",{selected:f===e.activeIndex}]),"data-active":f===e.activeIndex?"true":void 0,role:"option","aria-selected":f===e.activeIndex,onClick:p=>s("select",d),onMousemove:p=>s("hover",f)},[h("span",{class:ue(["at-item-icon",{"is-dir":d.isDir}])},[X(ce,{name:d.isDir?"folder":"file",size:14},null,8,["name"])],2),h("span",Sk,C(i(d)),1),a(d)?(m(),v("span",_k,C(a(d)),1)):F("",!0)],42,wk)]))),128))],512)),h("div",$k,[u[1]||(u[1]=h("span",{class:"at-hint"},[h("kbd",null,"↑↓"),Ae("选择")],-1)),h("span",Ck,[u[0]||(u[0]=h("kbd",null,"Tab/Enter",-1)),Ae(C((c=e.suggestions[e.activeIndex])!=null&&c.isDir?"进入目录":"插入引用"),1)]),u[2]||(u[2]=h("span",{class:"at-hint"},[h("kbd",null,"Esc"),Ae("关闭")],-1)),e.workDir?(m(),v("span",{key:0,class:"at-root",title:e.workDir},"根:"+C(r(e.workDir)),9,xk)):F("",!0)])])}}}),Tk=Te(Ik,[["__scopeId","data-v-9c8e827b"]]),Ek=["title","aria-label"],Ak=["width","height","viewBox"],Mk=["cx","cy","r"],Rk=["cx","cy","r","stroke-dasharray","stroke-dashoffset","transform"],oa=2,Pk=Ie({__name:"ContextRing",props:{usage:{default:void 0},size:{default:16}},setup(e){iv(l=>({v1d95ffa8:a.value}));const t=e,n=B(()=>{if(t.usage===void 0||Number.isNaN(t.usage))return 0;const l=t.usage>1?t.usage/100:t.usage;return Math.min(1,Math.max(0,l))}),s=B(()=>Math.round(n.value*100)),o=B(()=>(t.size-oa)/2),r=B(()=>2*Math.PI*o.value),i=B(()=>r.value*(1-n.value)),a=B(()=>n.value>=.9?"var(--color-danger)":n.value>=.7?"var(--color-warning)":"var(--color-accent)");return(l,u)=>(m(),v("span",{class:"context-ring",role:"img",title:`上下文占用 ${s.value}%`,"aria-label":`上下文占用 ${s.value}%`},[(m(),v("svg",{width:e.size,height:e.size,viewBox:`0 0 ${e.size} ${e.size}`},[h("circle",{class:"ring-track",cx:e.size/2,cy:e.size/2,r:o.value,"stroke-width":oa,fill:"none"},null,8,Mk),h("circle",{class:"ring-value",cx:e.size/2,cy:e.size/2,r:o.value,"stroke-width":oa,fill:"none","stroke-linecap":"round","stroke-dasharray":r.value,"stroke-dashoffset":i.value,transform:`rotate(-90 ${e.size/2} ${e.size/2})`},null,8,Rk)],8,Ak))],8,Ek))}}),bh=Te(Pk,[["__scopeId","data-v-3ffc343b"]]),Lk=["data-goal-status"],Dk={class:"goal-status"},Nk=["title"],Ok={class:"goal-metric",title:"已用轮次"},Gk={class:"goal-actions"},Bk=["disabled","title"],Fk=["disabled","title"],Uk=["disabled","title"],jk=Ie({__name:"GoalBar",props:{goal:{},disabled:{type:Boolean,default:!1},disabledReason:{default:""},busy:{type:Boolean,default:!1},pending:{type:Boolean,default:!1}},emits:["pause","resume","cancel","edit"],setup(e,{emit:t}){const n=e,s=t,o={active:"进行中",paused:"已暂停",blocked:"受阻",complete:"已完成"},r=B(()=>!!n.goal&&n.goal.status!=="complete"),i=B(()=>{var c;return((c=n.goal)==null?void 0:c.status)==="active"}),a=B(()=>{var c;return o[((c=n.goal)==null?void 0:c.status)??""]??"目标"}),l=B(()=>n.disabled?n.disabledReason||"当前不可操作":""),u=B(()=>{var f;const c=n.goal;if(!c)return"";const d=(f=c.budget)==null?void 0:f.turnBudget;return d?`${c.turnsUsed}/${d} 轮`:`${c.turnsUsed} 轮`});return(c,d)=>r.value&&e.goal?(m(),v("div",{key:0,class:"goal-bar","data-goal-bar":"","data-goal-status":e.goal.status},[X(ce,{name:"target",size:14,class:"goal-icon"}),h("span",Dk,C(a.value),1),h("span",{class:"goal-objective",title:e.goal.objective},C(e.goal.objective),9,Nk),h("span",Ok,C(u.value),1),h("div",Gk,[h("button",{class:"goal-action",type:"button",title:"编辑目标与预算(在右栏 Goal 面板)","aria-label":"编辑目标",onClick:d[0]||(d[0]=f=>s("edit"))},[X(ce,{name:"edit",size:13}),d[4]||(d[4]=h("span",null,"编辑",-1))]),i.value?(m(),v("button",{key:0,class:"goal-action",type:"button",disabled:e.disabled||e.busy||e.pending,title:e.disabled||e.pending?l.value:"暂停目标执行","aria-label":"暂停目标",onClick:d[1]||(d[1]=f=>s("pause"))},[...d[5]||(d[5]=[h("span",null,"暂停",-1)])],8,Bk)):(m(),v("button",{key:1,class:"goal-action",type:"button",disabled:e.disabled||e.busy||e.pending,title:e.disabled||e.pending?l.value:"继续目标执行","aria-label":"继续目标",onClick:d[2]||(d[2]=f=>s("resume"))},[...d[6]||(d[6]=[h("span",null,"继续",-1)])],8,Fk)),h("button",{class:"goal-action is-danger",type:"button",disabled:e.disabled||e.pending,title:e.disabled?l.value:"取消目标(可在右栏 Goal 面板查看结果)","aria-label":"取消目标",onClick:d[3]||(d[3]=f=>s("cancel"))}," 清除 ",8,Uk)])],8,Lk)):F("",!0)}}),zk=Te(jk,[["__scopeId","data-v-c7806e90"]]),Hk={class:"history-menu",role:"listbox","aria-label":"输入历史"},Wk={class:"history-header",title:"输入历史"},qk=["data-active","aria-selected","onClick","onMousemove"],Vk={class:"history-item-index"},Kk={class:"history-item-text"},Zk=Ie({__name:"HistoryMenu",props:{items:{},activeIndex:{}},emits:["apply","hover"],setup(e,{emit:t}){const n=e,s=t,o=G(null);return Se(()=>n.activeIndex,async()=>{var i;await Fe();const r=(i=o.value)==null?void 0:i.querySelector('[data-active="true"]');r==null||r.scrollIntoView({block:"nearest"})}),et(async()=>{var i;await Fe();const r=(i=o.value)==null?void 0:i.querySelector('[data-active="true"]');r==null||r.scrollIntoView({block:"nearest"})}),(r,i)=>(m(),v("div",Hk,[h("div",Wk,[X(ce,{name:"refresh",size:14}),i[0]||(i[0]=h("span",{class:"history-hints"},[h("span",{class:"history-hint"},[h("kbd",null,"↑↓"),Ae("选择")]),h("span",{class:"history-hint"},[h("kbd",null,"Tab/Enter"),Ae("填入")]),h("span",{class:"history-hint"},[h("kbd",null,"Esc"),Ae("关闭")])],-1))]),h("ul",{ref_key:"listRef",ref:o,class:"history-list"},[(m(!0),v(te,null,Ce(e.items,(a,l)=>(m(),v("li",{key:`${l}:${a}`},[h("button",{class:ue(["history-item",{selected:l===e.activeIndex}]),"data-active":l===e.activeIndex?"true":void 0,role:"option","aria-selected":l===e.activeIndex,onClick:u=>s("apply",a),onMousemove:u=>s("hover",l)},[h("span",Vk,C(l+1),1),h("span",Kk,C(a),1)],42,qk)]))),128))],512)]))}}),Yk=Te(Zk,[["__scopeId","data-v-41efc12f"]]);function ql(e,t){const n=t.gap??6,s=t.edge??8,o={position:"fixed",maxWidth:`${t.maxWidth}px`};return t.placement==="top"?o.bottom=`${window.innerHeight-e.top+n}px`:o.top=`${e.bottom+n}px`,t.align==="right"?o.right=`${Math.max(s,window.innerWidth-e.right)}px`:o.left=`${Math.min(Math.max(s,e.left),Math.max(s,window.innerWidth-t.maxWidth-s))}px`,o}const Xk=["aria-label"],Jk={key:0,class:"menu-heading"},Qk={key:0,class:"menu-group-title"},e1=["disabled","title","aria-current","onClick"],t1={class:"entry-label"};let Ls=null;function n1(e){Ls==null||Ls(),Ls=e}function xc(e){Ls===e&&(Ls=null)}const s1=Ie({__name:"MenuPopover",props:{label:{},groups:{},open:{type:Boolean},align:{default:"right"},placement:{default:"top"},maxWidth:{default:300},heading:{default:void 0}},emits:["select","update:open"],setup(e,{emit:t}){const n=e,s=t,o=G(null),r=G({});function i(){n.open&&s("update:open",!1)}Se(()=>n.open,d=>{d?(n1(i),a(),document.addEventListener("scroll",c,!0),window.addEventListener("resize",c)):(xc(i),document.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c))});function a(){const d=o.value;d&&(r.value=ql(d.getBoundingClientRect(),{placement:n.placement,align:n.align,maxWidth:n.maxWidth}))}function l(d){const f=d.target;if(!(f instanceof Node))return;const p=o.value;p!=null&&p.contains(f)||f instanceof Element&&f.closest("[data-menu-popover]")||i()}function u(d){d.key==="Escape"&&n.open&&(d.stopPropagation(),i())}function c(){i()}return et(()=>{document.addEventListener("pointerdown",l,!0),window.addEventListener("keydown",u,!0),n.open&&(a(),document.addEventListener("scroll",c,!0),window.addEventListener("resize",c))}),st(()=>{xc(i),document.removeEventListener("pointerdown",l,!0),window.removeEventListener("keydown",u,!0),document.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}),(d,f)=>(m(),v("span",{ref_key:"rootRef",ref:o,class:"menu-root"},[Co(d.$slots,"default",{},void 0),(m(),De(Js,{to:"body"},[e.open?(m(),v("div",{key:0,class:ue(["menu-popover",[`is-align-${e.align}`,`is-placement-${e.placement}`]]),style:bt(r.value),role:"menu","aria-label":e.label,"data-menu-popover":""},[e.heading?(m(),v("p",Jk,C(e.heading),1)):F("",!0),(m(!0),v(te,null,Ce(e.groups,(p,g)=>(m(),v(te,{key:`g${g}`},[p.title?(m(),v("p",Qk,C(p.title),1)):F("",!0),(m(!0),v(te,null,Ce(p.entries,b=>(m(),v("button",{key:b.key,class:ue(["menu-entry",{"is-active":b.checked,"is-danger":b.tone==="danger"}]),role:"menuitem",type:"button",disabled:b.disabled,title:b.title??b.label,"aria-current":b.checked?"true":void 0,onClick:S=>s("select",b.key)},[b.icon?(m(),De(ce,{key:0,name:b.icon,size:14},null,8,["name"])):F("",!0),h("span",t1,C(b.label),1),b.checked?(m(),De(ce,{key:1,name:"check",size:14,class:"entry-check"})):F("",!0)],10,e1))),128))],64))),128))],14,Xk)):F("",!0)]))],512))}}),Ya=Te(s1,[["__scopeId","data-v-e68e06d8"]]),o1=["onKeydown"],r1={key:0,class:"picker-empty"},i1={class:"picker-group-title"},a1=["onClick"],l1={class:"row-main"},u1={class:"row-name"},c1={class:"row-alias"},d1={class:"row-meta"},f1={key:0,class:"row-check"},h1={class:"picker-thinking"},p1={class:"thinking-options"},g1=["onClick"],m1=Ie({__name:"ModelPicker",props:{models:{},currentModel:{},currentThinking:{},open:{type:Boolean,default:!0}},emits:["apply-model","apply-thinking","close","update:open"],setup(e,{emit:t}){const n=e,s=t,o=["off","low","medium","high"],r={off:"关闭",low:"低",medium:"中",high:"高",xhigh:"超高",max:"最大"},i=G(""),a=G(null),l=B(()=>{const I=i.value.trim().toLowerCase();return I?n.models.filter(M=>M.alias.toLowerCase().includes(I)||M.provider.toLowerCase().includes(I)||(M.displayName??"").toLowerCase().includes(I)):n.models}),u=B(()=>{const I=new Map;for(const M of l.value){const V=I.get(M.provider)??[];V.push(M),I.set(M.provider,V)}return[...I.entries()].map(([M,V])=>({provider:M,models:V}))}),c=B(()=>n.models.find(I=>I.alias===n.currentModel)),d=B(()=>{var I;return((I=c.value)==null?void 0:I.thinkingLevels)??o});function f(I){return r[I]??I}function p(I){return I>=1e3?`${Math.round(I/1e3)}k`:String(I)}function g(I){return I.displayName??I.model}const b=G(null),S=G(null),w=G({});function k(){s("close"),s("update:open",!1)}function y(){var ae;const I=b.value;if(!I)return;const V=(((ae=I.closest(".chip-slot"))==null?void 0:ae.querySelector(".model-select"))??document.querySelector(".model-select")??I).getBoundingClientRect(),ie=6,me=8,_e=ql(V,{placement:"top",align:"right",maxWidth:Math.min(320,window.innerWidth-me*2),gap:ie,edge:me}),he=Math.max(240,V.top-ie-me);_e.maxHeight=`min(60vh, ${he}px)`,w.value=_e}function _(I){const M=I.target;M instanceof Element&&M.closest(".model-select")||S.value&&!S.value.contains(M)&&k()}function N(I){var V;const M=I.target;M instanceof Node&&((V=S.value)!=null&&V.contains(M))||k()}function D(){document.addEventListener("scroll",N,!0),window.addEventListener("resize",N)}function E(){document.removeEventListener("scroll",N,!0),window.removeEventListener("resize",N)}et(()=>{var I;document.addEventListener("mousedown",_,!0),n.open&&((I=a.value)==null||I.focus(),y(),D())}),Se(()=>n.open,I=>{if(!I){E();return}D(),Fe(()=>{var M;y(),(M=a.value)==null||M.focus()})}),st(()=>{document.removeEventListener("mousedown",_,!0),E()});function A(I){I!==n.currentModel&&s("apply-model",I),k()}const T=G(null);function Z(){const I=T.value;return I?Array.from(I.querySelectorAll(".picker-row")):[]}function W(){var I;(I=Z()[0])==null||I.focus()}function j(I){var ie,me,_e;if(I.key!=="ArrowDown"&&I.key!=="ArrowUp")return;const M=Z();if(M.length===0)return;const V=M.indexOf(document.activeElement);I.preventDefault(),V===-1?(ie=M[0])==null||ie.focus():I.key==="ArrowDown"?(me=M[(V+1)%M.length])==null||me.focus():(_e=M[(V-1+M.length)%M.length])==null||_e.focus()}function ne(I){I!==n.currentThinking&&s("apply-thinking",I)}return(I,M)=>(m(),v("span",{ref_key:"anchorRef",ref:b,class:"model-picker model-picker--anchor"},[(m(),De(Js,{to:"body"},[e.open?(m(),v("div",{key:0,ref_key:"rootRef",ref:S,class:"model-picker",style:bt(w.value),role:"dialog","aria-label":"模型选择",onKeydown:M[1]||(M[1]=Vn(tt(V=>k(),["stop"]),["esc"]))},[Ze(h("input",{ref_key:"searchRef",ref:a,"onUpdate:modelValue":M[0]||(M[0]=V=>i.value=V),class:"picker-search",type:"text",placeholder:"搜索模型…",id:"model-search-input",name:"model-search",autocomplete:"off",spellcheck:"false",onKeydown:Vn(tt(W,["prevent"]),["arrow-down"])},null,40,o1),[[it,i.value]]),h("div",{ref_key:"listRef",ref:T,class:"picker-list",onKeydown:j},[u.value.length===0?(m(),v("div",r1,"无匹配模型")):F("",!0),(m(!0),v(te,null,Ce(u.value,V=>(m(),v("div",{key:V.provider,class:"picker-group"},[h("div",i1,C(V.provider),1),(m(!0),v(te,null,Ce(V.models,ie=>(m(),v("button",{key:ie.alias,class:ue(["picker-row",{active:ie.alias===e.currentModel}]),onClick:me=>A(ie.alias)},[h("span",l1,[h("span",u1,C(g(ie)),1),h("span",c1,C(ie.alias),1)]),h("span",d1,C(p(ie.maxContextSize)),1),ie.alias===e.currentModel?(m(),v("span",f1,"✓")):F("",!0)],10,a1))),128))]))),128))],544),h("div",h1,[M[2]||(M[2]=h("span",{class:"thinking-label"},"思考强度",-1)),h("div",p1,[(m(!0),v(te,null,Ce(d.value,V=>(m(),v("button",{key:V,class:ue(["thinking-btn",{active:V===e.currentThinking}]),onClick:ie=>ne(V)},C(f(V)),11,g1))),128))])])],36)):F("",!0)]))],512))}}),v1=Te(m1,[["__scopeId","data-v-0271ee16"]]),y1={class:"slash-menu",role:"listbox","aria-label":"斜杠命令与技能"},b1={key:0,class:"slash-search"},k1=["value"],w1={class:"slash-list"},S1={key:0,class:"slash-group"},_1={class:"slash-group-label"},$1={key:0,class:"slash-group-hint"},C1=["aria-selected","onMousedown","onMouseenter"],x1={class:"slash-name"},I1={key:0,class:"slash-aliases"},T1={class:"slash-desc"},E1={key:0,class:"slash-badge slash-badge-source"},A1={key:0,class:"slash-badge slash-badge-input"},M1={key:1,class:"slash-badge"},R1=Ie({__name:"SlashMenu",props:{commands:{},activeIndex:{}},emits:["select","hover"],setup(e,{emit:t}){const n=e,s=t,o={builtin:"内置",user:"用户",extra:"扩展",project:"项目"};function r(d){return d?d.startsWith("plugin:")?`插件 ${d.slice(7)}`:o[d]||d:""}const i=B(()=>{const d=[];let f="";return n.commands.forEach((p,g)=>{const b=p.kind==="skill"?"skills":p.group==="advanced"?"advanced":"commands";b!==f&&(f=b,d.push({type:"header",label:a[b]})),d.push({type:"item",cmd:p,index:g})}),f!=="advanced"&&Uv()&&d.push({type:"header",label:a.advanced,hint:"输入继续筛选"}),d}),a={commands:"命令",advanced:"高级",skills:"技能"},l=G(""),u=B(()=>n.commands.length>Fv||l.value!=="");function c(d){l.value=d.target.value,Gv(l.value)}return st(()=>{l.value&&(l.value="",Bv())}),(d,f)=>(m(),v("div",y1,[u.value?(m(),v("div",b1,[h("input",{class:"slash-search-input",type:"text",value:l.value,placeholder:"筛选命令与技能…","aria-label":"筛选命令与技能",onInput:c,onMousedown:f[0]||(f[0]=tt(()=>{},["stop"]))},null,40,k1)])):F("",!0),h("div",w1,[(m(!0),v(te,null,Ce(i.value,(p,g)=>{var b;return m(),v(te,{key:g},[p.type==="header"?(m(),v("div",S1,[h("span",_1,C(p.label),1),p.hint?(m(),v("span",$1,C(p.hint),1)):F("",!0)])):(m(),v("button",{key:1,class:ue(["slash-item",{active:p.index===e.activeIndex}]),role:"option","aria-selected":p.index===e.activeIndex,onMousedown:tt(S=>s("select",p.cmd),["prevent"]),onMouseenter:S=>s("hover",p.index)},[h("span",x1,[Ae("/"+C(p.cmd.name),1),(b=p.cmd.aliases)!=null&&b.length?(m(),v("span",I1,C(p.cmd.aliases.map(S=>`/${S}`).join(" ")),1)):F("",!0)]),h("span",T1,C(p.cmd.description),1),p.cmd.kind==="skill"?(m(),v(te,{key:0},[p.cmd.source?(m(),v("span",E1,C(r(p.cmd.source)),1)):F("",!0),f[1]||(f[1]=h("span",{class:"slash-badge slash-badge-skill"},"技能",-1))],64)):(m(),v(te,{key:1},[p.cmd.acceptsInput?(m(),v("span",A1,"输入参数")):F("",!0),p.cmd.target==="backend"?(m(),v("span",M1,"服务端")):F("",!0)],64))],42,C1))],64)}),128))]),f[2]||(f[2]=h("div",{class:"slash-hint"},"↑↓ 选择 · Enter/Tab 执行 · Esc 关闭",-1))]))}}),P1=Te(R1,[["__scopeId","data-v-b0de79ca"]]),L1=34;function Cr(e){const t=e.split("/"),n=t.at(-1)??e;return t.length<=2?{dir:t.length===2?`${t[0]}/`:"",base:n}:e.length<=L1?{dir:`${t.slice(0,-1).join("/")}/`,base:n}:{dir:`…/${t.at(-2)}/`,base:n}}const D1={class:"picker-input-row"},N1=["placeholder","onKeydown"],O1=["disabled","title"],G1={key:0,class:"picker-warn"},B1={class:"picker-rows"},F1=["title","onClick"],U1={class:"row-base"},j1={class:"row-path"},z1={class:"picker-rows"},H1=["title","onClick"],W1={class:"row-base"},q1=Ie({__name:"WorkspacePicker",props:{current:{default:""},defaultDir:{default:""},recentWorkDirs:{default:()=>[]}},emits:["select","close"],setup(e,{emit:t}){const n=e,s=t,o=G(n.current||n.defaultDir),r=G(null),i=G(null),a=G(null),l=G({}),u=B(()=>o.value.trim().startsWith("/")),c=B(()=>u.value&&o.value.trim().length>0);function d(){c.value&&s("select",o.value.trim())}const f=G([]);let p;Se(o,k=>{clearTimeout(p);const y=k.trim();if(!y.startsWith("/")){f.value=[];return}p=setTimeout(async()=>{const _=await Wl(y);o.value.trim()===y&&(f.value=(_??[]).filter(N=>N.type==="dir").slice(0,8))},250)});function g(k){var y;o.value=k.path,(y=r.value)==null||y.focus()}function b(){var A;const k=i.value;if(!k)return;const _=(((A=k.closest(".chip-slot"))==null?void 0:A.querySelector(".workspace-select"))??document.querySelector(".workspace-select")??k).getBoundingClientRect(),N=6,D=8,E=ql(_,{placement:"top",align:"left",maxWidth:Math.min(360,window.innerWidth-D*2),gap:N,edge:D});E.maxHeight=`min(60vh, ${Math.max(240,_.top-N-D)}px)`,l.value=E}function S(k){const y=k.target;y instanceof Element&&y.closest(".workspace-select")||a.value&&!a.value.contains(y)&&s("close")}function w(k){var _;const y=k.target;y instanceof Node&&((_=a.value)!=null&&_.contains(y))||s("close")}return et(()=>{document.addEventListener("mousedown",S,!0),document.addEventListener("scroll",w,!0),window.addEventListener("resize",w),Fe(()=>{var k,y;b(),(k=r.value)==null||k.focus(),(y=r.value)==null||y.select()})}),st(()=>{document.removeEventListener("mousedown",S,!0),document.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w),clearTimeout(p)}),(k,y)=>(m(),v("span",{ref_key:"anchorRef",ref:i,class:"workspace-picker workspace-picker--anchor"},[(m(),De(Js,{to:"body"},[h("div",{ref_key:"rootRef",ref:a,class:"workspace-picker",style:bt(l.value),role:"dialog","aria-label":"选择工作区",onKeydown:y[1]||(y[1]=Vn(tt(_=>s("close"),["stop"]),["esc"]))},[y[4]||(y[4]=h("p",{class:"picker-title"},"工作区(下一次新建)",-1)),h("div",D1,[Ze(h("input",{ref_key:"inputRef",ref:r,"onUpdate:modelValue":y[0]||(y[0]=_=>o.value=_),class:"picker-path-input","data-testid":"workspace-path-input",placeholder:e.defaultDir||"输入绝对路径,如 /Users/you/project",spellcheck:"false",onKeydown:Vn(tt(d,["prevent"]),["enter"])},null,40,N1),[[it,o.value]]),h("button",{class:"picker-apply","data-testid":"workspace-apply",disabled:!c.value,title:c.value?"使用该目录新建会话":"工作区必须是绝对路径",onClick:d}," 选择 ",8,O1)]),o.value.trim()&&!u.value?(m(),v("p",G1,"需要绝对路径(以 / 开头)")):F("",!0),e.recentWorkDirs.length?(m(),v(te,{key:1},[y[2]||(y[2]=h("p",{class:"picker-section"},"最近使用",-1)),h("div",B1,[(m(!0),v(te,null,Ce(e.recentWorkDirs,_=>(m(),v("button",{key:_,class:"picker-row",title:_,onClick:N=>s("select",_)},[X(ce,{name:"folder",size:14}),h("span",U1,C(U(Ka)(_)),1),h("span",j1,C(U(Cr)(_).dir),1)],8,F1))),128))])],64)):F("",!0),f.value.length?(m(),v(te,{key:2},[y[3]||(y[3]=h("p",{class:"picker-section"},"子目录",-1)),h("div",z1,[(m(!0),v(te,null,Ce(f.value,_=>(m(),v("button",{key:_.path,class:"picker-row",title:_.path,onClick:N=>g(_)},[X(ce,{name:"folder",size:14}),h("span",W1,C(_.name),1)],8,H1))),128))])],64)):F("",!0)],36)]))],512))}}),V1=Te(q1,[["__scopeId","data-v-a02cc634"]]),K1=["data-placeholder-state","placeholder"],Z1={class:"composer-capsule-row"},Y1={class:"composer-chips"},X1=["title"],J1={class:"chip-text"},Q1={key:1,class:"chip-slot"},ew=["disabled","title","aria-haspopup","aria-expanded"],tw={class:"chip-text"},nw={key:2,class:"chip-slot"},sw=["disabled","title","aria-haspopup","aria-expanded"],ow={class:"chip-text"},rw=["disabled","title","aria-expanded"],iw={class:"chip-text"},aw=["disabled","title","aria-expanded"],lw={class:"chip-text"},uw=["title"],cw={class:"chip-text"},dw=["title"],fw={class:"chip-text"},hw=["data-action","disabled","title","aria-label"],pw={key:0,class:"primary-label"},Ic=50,gw=5e3,mw=Ie({__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:{},connectionStatus:{default:"idle"},goal:{default:null},recentWorkDirs:{default:()=>[]}},emits:["send","abort","command","switch-model","switch-thinking","switch-permission","goal-pause","goal-resume","goal-cancel","goal-edit"],setup(e,{expose:t,emit:n}){const s=e,o=n,r=G(""),i=G(null),a=B(()=>s.workDir||void 0),l=Db(r,i,a),u=G(0),c=G(!1),d=B(()=>{const L=r.value;return!L.startsWith("/")||L.includes(`
19
+ `)}let qr=null;const Bl=Fg(null);function qv(e){qr=e,Bl.value=e}function Vv(e){qr===e&&(qr=null,Bl.value=null)}function Ha(){return qr}function Kv(){return{activeClient:Bl}}const No=G([]);let Zv=0;function Yv(e,t="info",n=3500){const s=`toast_${++Zv}`;No.value=[...No.value,{id:s,type:t,message:e}],n>0&&setTimeout(()=>ah(s),n)}function ah(e){No.value=No.value.filter(t=>t.id!==e)}function Qs(){return{toasts:No,showToast:Yv,removeToast:ah}}const Ge="/api/v1",Xv=2*3e4,pc=8;function ft(e){const t=e.sessionId.value;return t?{sessionId:t,sessionGeneration:e.sessionGeneration,connectionGeneration:e.connectionGeneration}:null}function Ei(e,t){return e.sessionId.value===t.sessionId&&e.sessionGeneration===t.sessionGeneration&&e.connectionGeneration===t.connectionGeneration}function Yt(e,t,n){e.wsHandlers.set(t,n)}function Jv(){const e=G("connecting"),t=G([]),n=G(!1),s=G(void 0),o=G([]),r=G({busy:!1}),i=G(null),a=G([]),l=G(!1),u=G(null),c=G(!1),d=G(null),f=G(null),p=G(null),g=G([]),b=G(null),S=G(!1),w=B(()=>r.value.busy||c.value),k=B(()=>f.value!==null&&!S.value);return{connectionStatus:e,messages:t,olderAvailable:n,oldestSeq:s,pendingApprovals:o,status:r,goal:i,todos:a,goalRequestPending:l,goalRequestError:u,promptPending:c,error:d,sessionId:f,workDir:p,isBusy:w,sessions:g,currentSessionId:b,isArchived:k,gitStatus:G(null),models:G([]),modelsError:G(null),like:G({}),sessionPlan:G(null),skills:G([]),skillsError:G(null),plugins:G([]),pluginInfo:G(null),mcpServers:G([]),mcpStartupMetrics:G(null),backgroundTasks:G([]),backgroundTaskOutput:G(""),subagents:G([]),config:G(null),experimentalFlags:G(null),preflightOk:G(!1),sessionActive:S,ws:null,heartbeatTimer:null,reconnectTimer:null,snapshotRetryTimer:null,lastPongAt:Date.now(),seq:0,epoch:0,reconnectAttempt:0,sessionGeneration:0,connectionGeneration:0,promptGeneration:0,liveGeneration:0,sessionMutationGeneration:0,goalMutationGeneration:0,permissionMutationGeneration:0,goalAwaitingMutation:null,goalRequestInFlight:!1,snapshotRetryGoalGeneration:null,pendingPromptAccepted:!1,disposed:!1,sentMessageIds:new Map,turnNumber:0,turnStartAt:0,turnFirstTokenAt:null,activeToolMs:0,streamDisposed:!1,pendingAssistantDelta:"",pendingThinkingDelta:"",pendingToolProgress:new Map,wsHandlers:new Map,wsUnknownFrames:0,journalGapCount:0}}function Qv(){const{showToast:e}=Qs();return{s:Jv(),showToast:e}}function yn(){return`msg_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function gc(e,t){if(e!==null&&typeof e=="object"){const n=e.message;if(typeof n=="string")return n}return t}const mc="scream-offline-prompt-queue",vc="scream-recent-prompts";function ey(e){const{s:t}=e;let n=[];try{const c=localStorage.getItem(mc);if(c){const d=JSON.parse(c);Array.isArray(d)&&(n=d.filter(f=>typeof f=="string"))}}catch{n=[]}function s(){try{localStorage.setItem(mc,JSON.stringify(n.slice(0,20)))}catch{}}function o(){if(n.length===0)return;const c=n[0],d=`client_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,f=yn();t.sentMessageIds.set(d,{messageId:f,connectionGeneration:t.connectionGeneration,queueText:c}),t.promptGeneration++,t.pendingPromptAccepted=!1,t.promptPending.value=!0,t.messages.value.push({id:f,role:"user",content:c,clientMessageId:d,tools:[],ts:Date.now()}),u(c),e.send({type:"prompt",text:c,clientMessageId:d})}function r(){n.length>0&&n.shift(),s(),o()}function i(c){n.push(c),s()}function a(c){const d=n.indexOf(c);d>=0&&(n.splice(d,1),s())}let l=[];try{const c=localStorage.getItem(vc);if(c){const d=JSON.parse(c);Array.isArray(d)&&(l=d.filter(f=>typeof f=="string"))}}catch{l=[]}function u(c){const d=c.trim();if(d){l=[d,...l.filter(f=>f!==d)].slice(0,8);try{localStorage.setItem(vc,JSON.stringify(l))}catch{}}}return e.flushQueue=o,e.flushQueueNext=r,e.enqueueOfflinePrompt=i,e.removeOfflineQueueItem=a,e.recordRecentPrompt=u,{enqueueOfflinePrompt:i,removeOfflineQueueItem:a,recordRecentPrompt:u,flushQueue:o,flushQueueNext:r}}function wr(e,t,n,s){return e===n&&t===s}function ty(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 ny(e){return{objective:e.objective,completionCriterion:e.completionCriterion,replace:e.replace,budgets:e.budgets}}function sy(e){return{objective:e.objective,budgets:e.budgets}}function oy(e,t,n){return e!==0&&n.epoch!==e?"resync":n.seq<=t?"duplicate":t!==0&&n.seq>t+1?"gap":"apply"}function ry(e,t){return t.type==="goal.updated"?{...e,goal:t.snapshot}:t.type==="todo.updated"?{...e,todos:t.todos}:e}function iy(e){const t=[],n=new Map;for(const s of e){const o=s.phase??null;let r=n.get(o);r===void 0&&(r=t.length,n.set(o,r),t.push({phase:o,items:[]})),t[r].items.push(s)}return t}const ay=24,ly=4e3;function bo(e,t){const n=e[t];return typeof n=="string"&&n.length>0?n:void 0}function ir(e,t){const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:void 0}function uy(e){const t=e.usage;if(!t||typeof t!="object")return;const n=t;if(!(typeof n.inputOther!="number"||typeof n.output!="number"||typeof n.inputCacheRead!="number"||typeof n.inputCacheCreation!="number"))return{inputOther:n.inputOther,output:n.output,inputCacheRead:n.inputCacheRead,inputCacheCreation:n.inputCacheCreation}}function yc(e,t){const n=bo(e,t);return n===void 0?void 0:n.slice(0,ly)}function cy(e,t){return e.type==="subagent.started"?"running":e.type==="subagent.completed"?"completed":e.type==="subagent.failed"?"failed":t}function dy(e){return[...e].toSorted((t,n)=>{const s=t.state==="spawning"||t.state==="running",o=n.state==="spawning"||n.state==="running";return s!==o?s?-1:1:n.updatedAt-t.updatedAt}).slice(0,ay)}function fy(e,t,n=Date.now()){if(!t.type.startsWith("subagent.")||t.type==="subagent.child_request")return e;const s=t,o=bo(s,"subagentId");if(!o)return e;const r=e.findIndex(f=>f.subagentId===o),i=r===-1?void 0:e[r],a=cy(s,(i==null?void 0:i.state)??"spawning"),l=bo(s,"subagentName")??(i==null?void 0:i.name)??"agent",u=bo(s,"parentToolCallId")??(i==null?void 0:i.parentToolCallId)??"",c={subagentId:o,name:l,parentToolCallId:u,description:bo(s,"description")??(i==null?void 0:i.description),runInBackground:typeof s.runInBackground=="boolean"?s.runInBackground:(i==null?void 0:i.runInBackground)??!1,state:a,updatedAt:n,resultSummary:yc(s,"resultSummary")??(i==null?void 0:i.resultSummary),error:yc(s,"error")??(i==null?void 0:i.error),usage:uy(s)??(i==null?void 0:i.usage),contextTokens:ir(s,"contextTokens")??(i==null?void 0:i.contextTokens),turns:ir(s,"turns")??(i==null?void 0:i.turns),durationMs:ir(s,"durationMs")??(i==null?void 0:i.durationMs),toolCallCount:ir(s,"toolCallCount")??(i==null?void 0:i.toolCallCount)},d=r===-1?[...e,c]:e.map((f,p)=>p===r?c:f);return dy(d)}const Oo=new Map;function hy(e){Oo.set(e,Date.now())}function py(e){return Oo.get(e)}function gy(e){const t=Oo.get(e);return t!==void 0&&Oo.delete(e),t}function my(){Oo.clear()}function na(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`}function vy(e){let t=null;return{schedule:()=>{if(t!==null)return;const r=i=>{if(i<=0){t=null,e();return}t=requestAnimationFrame(()=>r(i-1))};t=requestAnimationFrame(()=>r(2))},flushNow:()=>{t!==null&&(cancelAnimationFrame(t),t=null),e()},dispose:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}}function yy(e){const{s:t}=e;function n(){if(t.streamDisposed)return;const u=a();if(!u){t.pendingAssistantDelta="",t.pendingThinkingDelta="",t.pendingToolProgress.clear();return}if(t.pendingAssistantDelta&&(u.content+=t.pendingAssistantDelta,t.pendingAssistantDelta=""),t.pendingThinkingDelta){const c=u.tools.find(d=>d.name==="thinking");c?c.output=(c.output??"")+t.pendingThinkingDelta:u.tools.push({toolCallId:"thinking",name:"thinking",output:t.pendingThinkingDelta}),t.pendingThinkingDelta=""}if(t.pendingToolProgress.size>0){for(const[c,d]of t.pendingToolProgress){const f=u.tools.find(p=>p.toolCallId===c);f&&(f.progress=d)}t.pendingToolProgress.clear()}}const s=vy(n);let o=null;function r(){o===null&&(o=window.setTimeout(()=>{var u;o=null,(u=e.refreshBackgroundTasks)==null||u.call(e)},250))}function i(u){var f;const c=fy(t.subagents.value,u);c!==t.subagents.value&&(t.subagents.value=c);const d=ry({goal:t.goal.value,todos:t.todos.value},u);switch(t.goal.value=d.goal,t.todos.value=d.todos,u.type==="goal.updated"&&t.goalAwaitingMutation!==null&&t.goalAwaitingMutation.generation===t.goalMutationGeneration&&(t.goalAwaitingMutation=null,t.snapshotRetryGoalGeneration=null,e.syncGoalRequestPending()),u.type){case"turn.started":{t.pendingPromptAccepted&&(t.promptPending.value=!1,t.pendingPromptAccepted=!1,t.sentMessageIds.clear()),s.flushNow(),t.status.value={...t.status.value,busy:!0},t.turnNumber+=1,t.turnStartAt=Date.now(),t.turnFirstTokenAt=null,t.activeToolMs=0,my(),t.messages.value.push({id:yn(),role:"assistant",content:"",tools:[],ts:Date.now(),model:t.status.value.model,turnStats:{turn:t.turnNumber,step:0,status:"running",firstTokenMs:null,llmMs:0,toolMs:0,tokens:null,tokensPerSec:null}});break}case"assistant.delta":{t.turnFirstTokenAt===null&&(t.turnFirstTokenAt=Date.now()),t.pendingAssistantDelta+=String(u.delta),s.schedule();break}case"thinking.delta":{t.turnFirstTokenAt===null&&(t.turnFirstTokenAt=Date.now()),t.pendingThinkingDelta+=String(u.delta),s.schedule();break}case"tool.call.started":{const p=a();p&&(p.tools.push({toolCallId:String(u.toolCallId),name:String(u.name),args:u.args}),p.turnStats&&(p.turnStats.step+=1)),hy(String(u.toolCallId));break}case"tool.result":{t.pendingToolProgress.delete(String(u.toolCallId));const p=gy(String(u.toolCallId));p!==void 0&&(t.activeToolMs+=Date.now()-p);const g=a();if(g){const b=g.tools.find(S=>S.toolCallId===u.toolCallId);b&&(b.output=String(u.output),b.isError=!!u.isError,b.progress=void 0,p!==void 0&&(b.durationMs=Date.now()-p))}break}case"tool.progress":{t.pendingToolProgress.set(String(u.toolCallId),String(u.message??u.output)),s.schedule();break}case"background.task.started":case"background.task.updated":case"background.task.terminated":{if(u.agentId!==void 0&&u.agentId!=="main")break;r();break}case"turn.ended":{if(s.flushNow(),t.status.value={...t.status.value,busy:!1},u.reason==="failed"){const w=a();w&&(w.isError=!0),t.error.value=gc(u.error,"Turn failed")}const p=a(),g=Date.now()-t.turnStartAt,b=(f=t.status.value.usage)==null?void 0:f.currentTurn,S=b?b.inputOther+b.output+b.inputCacheRead+b.inputCacheCreation:null;p&&p.turnStats&&(p.turnStats.status="done",p.turnStats.llmMs=g,p.turnStats.toolMs=t.activeToolMs,p.turnStats.firstTokenMs=t.turnFirstTokenAt!==null?t.turnFirstTokenAt-t.turnStartAt:null,p.turnStats.tokens=S,p.turnStats.tokensPerSec=S!==null&&g>0?Math.round(S/g*1e3):null),e.fetchSessions(),e.fetchGitStatus();break}case"session.meta.updated":{const p={};u.model!==void 0&&(p.model=u.model),u.contextTokens!==void 0&&(p.contextTokens=u.contextTokens),u.maxContextTokens!==void 0&&(p.maxContextTokens=u.maxContextTokens),u.contextUsage!==void 0&&(p.contextUsage=u.contextUsage),t.status.value={...t.status.value,...p};break}case"agent.status.updated":{const p={};if(u.model!==void 0&&(p.model=u.model),u.thinkingLevel!==void 0&&(p.thinkingLevel=u.thinkingLevel),u.contextTokens!==void 0&&(p.contextTokens=u.contextTokens),u.maxContextTokens!==void 0&&(p.maxContextTokens=u.maxContextTokens),u.contextUsage!==void 0&&(p.contextUsage=u.contextUsage),(u.agentId===void 0||u.agentId==="main")&&(u.rlmEnabled!==void 0&&(p.rlmEnabled=u.rlmEnabled),u.rlmMaxDepth!==void 0&&(p.rlmMaxDepth=u.rlmMaxDepth)),u.usage!==void 0){p.usage=u.usage;const g=u.usage;if(g!=null&&g.currentTurn){const b=a(),S=g.currentTurn.inputOther+g.currentTurn.output+g.currentTurn.inputCacheRead+g.currentTurn.inputCacheCreation;b!=null&&b.turnStats&&b.turnStats.status==="done"&&b.turnStats.tokens===null&&(b.turnStats.tokens=S,b.turnStats.tokensPerSec=b.turnStats.llmMs?Math.round(S/b.turnStats.llmMs*1e3):null)}}t.status.value={...t.status.value,...p};break}case"web.history.undone":e.fetchSnapshot();break;case"error":{t.error.value=gc(u.error,"Unknown error");break}}}function a(){for(let u=t.messages.value.length-1;u>=0;u--)if(t.messages.value[u].role==="assistant")return t.messages.value[u];return null}Yt(t,"event",u=>{const c=oy(t.epoch,t.seq,u);if(c==="resync"){t.epoch=u.epoch,t.seq=0,t.journalGapCount=0,e.fetchSnapshot();return}if(c!=="duplicate"){if(c==="gap"){t.journalGapCount++;const d=t.journalGapCount>=3;(d?console.error:console.warn)(`[webClient] journal seq 缺口:epoch ${t.epoch} 内从 ${t.seq} 跳到 ${u.seq}(连续第 ${t.journalGapCount} 次${d?",超过阈值,流可能已持续损坏":""}),已触发快照补拉。`,u)}else t.journalGapCount=0;t.seq=u.seq,t.epoch=u.epoch,t.liveGeneration++,c==="gap"&&e.fetchSnapshot(),i(u.payload)}}),Yt(t,"resync_required",()=>{t.seq=0,e.fetchSnapshot()}),e.onEvent=i;function l(){t.streamDisposed=!0,o!==null&&(window.clearTimeout(o),o=null),s.dispose()}return{onEvent:i,disposeStreaming:l}}function by(e){const{s:t,showToast:n}=e;function s(){t.disposed||t.snapshotRetryTimer!==null||(t.snapshotRetryTimer=window.setTimeout(()=>{t.snapshotRetryTimer=null;const i=t.snapshotRetryGoalGeneration;t.snapshotRetryGoalGeneration=null,o(i??void 0)},250))}async function o(i){var p,g;const a=t.sessionId.value;if(!a)return;const l=t.messages.value.length===0?100:void 0,u=t.sessionGeneration,c=t.connectionGeneration,d=t.promptGeneration,f=t.liveGeneration;try{const b=await fetch(`${Ge}/sessions/${a}/snapshot${l?`?tail=${l}`:""}`);if(!b.ok){i!==void 0&&((p=t.goalAwaitingMutation)==null?void 0:p.generation)===i&&(t.snapshotRetryGoalGeneration=i,s());return}const S=await b.json();if(!ty({snapshot:S,targetSessionId:a,currentSessionId:t.sessionId.value,targetSessionGeneration:u,currentSessionGeneration:t.sessionGeneration,targetConnectionGeneration:c,currentConnectionGeneration:t.connectionGeneration,targetPromptGeneration:d,currentPromptGeneration:t.promptGeneration,targetLiveGeneration:f,currentLiveGeneration:t.liveGeneration,currentEpoch:t.epoch,currentSeq:t.seq})){i!==void 0&&(t.snapshotRetryGoalGeneration=i),s();return}r(S,i)}catch{i!==void 0&&((g=t.goalAwaitingMutation)==null?void 0:g.generation)===i&&(t.snapshotRetryGoalGeneration=i,s())}}function r(i,a){var b;t.pendingAssistantDelta="",t.pendingThinkingDelta="",t.pendingToolProgress.clear();const l=t.messages.value.filter(S=>S.local),u=t.sentMessageIds.keys().next().value,c=u?t.sentMessageIds.get(u):void 0,d=c?t.messages.value.find(S=>S.id===c.messageId):void 0,f=!!(u&&i.messages.some(S=>S.clientMessageId===u)),p=!!(c&&!f&&c.connectionGeneration<t.connectionGeneration);p&&d&&(d.isError=!0);const g=d&&!f?[d]:[];t.messages.value=[...i.messages.map(S=>({...S,id:S.id??yn()})),...l,...g];for(let S=t.messages.value.length-1;S>=0;S--){const w=(b=t.messages.value[S])==null?void 0:b.turnStats;if(w&&typeof w.turn=="number"&&w.turn>0){t.turnNumber=w.turn;break}}t.pendingApprovals.value=i.pendingApprovals,t.status.value={...i.status,busy:i.busy},t.olderAvailable.value=!!i.olderAvailable,t.oldestSeq.value=i.oldestSeq,t.goal.value=i.goal,t.todos.value=i.todos,a!==void 0&&t.goalAwaitingMutation!==null&&t.goalAwaitingMutation.generation===a&&t.goalMutationGeneration===a&&(t.goalAwaitingMutation=null,e.syncGoalRequestPending()),(f||p)&&(t.promptPending.value=!1,t.pendingPromptAccepted=!1,t.sentMessageIds.clear(),p&&n("消息未送达,已恢复连接。","error")),t.seq=i.seq,t.epoch=i.epoch,t.workDir.value=i.workDir}return e.fetchSnapshot=o,{fetchSnapshot:o}}function ky(e){const{s:t,showToast:n}=e;function s(c){if(!c)return;if(t.connectionStatus.value==="idle"){n("暂无会话,请先新建会话。","warning");return}if(t.connectionStatus.value!=="connected"){e.enqueueOfflinePrompt(c),n("连接已断开,消息已排队,重连后自动发送。","warning"),e.connect();return}if(t.isBusy.value)return;const d=`client_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,f=yn();t.sentMessageIds.set(d,{messageId:f,connectionGeneration:t.connectionGeneration}),t.promptGeneration++,t.pendingPromptAccepted=!1,t.promptPending.value=!0,t.messages.value.push({id:f,role:"user",content:c,clientMessageId:d,tools:[],ts:Date.now()}),e.recordRecentPrompt(c),e.send({type:"prompt",text:c,clientMessageId:d})}function o(c,d){if(t.connectionStatus.value==="idle"){n("暂无会话,请先新建会话。","warning");return}if(t.connectionStatus.value!=="connected"){n("连接已断开,命令未发送。","error"),e.connect();return}if(t.isBusy.value&&c!=="btw"){n(`会话忙碌中,无法执行 /${c},请稍后再试。`,"warning");return}const f=["compact","plan","auto","yes","fork","title"];let p=null;f.includes(c)&&(p=yn(),t.messages.value.push({id:p,role:"system",content:`正在执行 /${c}${d?` ${d}`:""}...`,tools:[],pending:!0,ts:Date.now(),local:!0})),e.send({type:"command",command:c,...d?{args:d}:{},...p?{pendingMsgId:p}:{}})}function r(){t.messages.value=[],t.pendingApprovals.value=[]}function i(c){t.messages.value.push({id:yn(),role:"system",content:c,tools:[],ts:Date.now(),local:!0})}function a(c,d,f,p){if(t.connectionStatus.value!=="connected"){n("连接已断开,审批结果未发送。","error"),e.connect();return}t.pendingApprovals.value=t.pendingApprovals.value.filter(g=>g.id!==c),e.send({type:"approval_response",id:c,decision:d,...f?{feedback:f}:{},...p?{scope:p}:{}})}function l(){e.send({type:"abort"})}async function u(){var f;const c=t.sessionId.value,d=t.oldestSeq.value;if(!c||d===void 0)return 0;try{const p=await fetch(`${Ge}/sessions/${c}/messages?before=${d}&tail=50`);if(!p.ok)return 0;const g=await p.json();if(g.messages.length===0)return 0;const b=g.messages.map(S=>({...S,id:S.id??yn()}));return t.messages.value=[...b,...t.messages.value],t.oldestSeq.value=((f=b[0])==null?void 0:f.seq)??d,t.olderAvailable.value=g.hasMore,b.length}catch{return 0}}return Yt(t,"user_message",c=>{var d;if(t.liveGeneration++,c.clientMessageId&&t.sentMessageIds.has(c.clientMessageId)){t.pendingPromptAccepted=!0,((d=t.sentMessageIds.get(c.clientMessageId))==null?void 0:d.queueText)!==void 0&&e.flushQueueNext();return}t.messages.value.push({id:yn(),role:"user",content:c.text,clientMessageId:c.clientMessageId,tools:[],ts:Date.now()})}),Yt(t,"approval_request",c=>{t.liveGeneration++,t.pendingApprovals.value=[...t.pendingApprovals.value,{id:c.id,toolName:c.toolName,action:c.action,display:c.display,sourceAgentId:c.sourceAgentId,sourceAgentName:c.sourceAgentName,sourceToolName:c.sourceToolName,sourceCapabilityMode:c.sourceCapabilityMode,reasons:c.reasons,grantOptions:c.grantOptions,requestSummary:c.requestSummary}]}),Yt(t,"approval_resolved",c=>{t.liveGeneration++,t.pendingApprovals.value=t.pendingApprovals.value.filter(d=>d.id!==c.id)}),Yt(t,"command_result",c=>{const d=c.pendingMsgId?t.messages.value.findIndex(p=>p.id===c.pendingMsgId):-1,f=d>=0;if(d>=0){const p=t.messages.value[d];t.messages.value[d]={...p,content:c.message,isError:!c.ok,pending:!1}}else t.messages.value.push({id:yn(),role:"system",content:c.message,tools:[],isError:!c.ok,ts:Date.now(),local:!0});(c.command==="fork"||c.command==="title")&&e.fetchSessions(),c.ok&&c.command==="fork"&&c.sessionId&&f&&e.switchSession(c.sessionId),c.ok&&c.command==="compact"&&e.fetchSnapshot()}),Yt(t,"error",c=>{if(t.error.value=c.message,c.clientMessageId){const d=t.sentMessageIds.get(c.clientMessageId);if(d){t.sentMessageIds.delete(c.clientMessageId),t.promptPending.value=!1,t.pendingPromptAccepted=!1;const f=t.messages.value.find(p=>p.id===d.messageId);f&&(f.isError=!0),n(`消息未发送:${c.message}`,"error"),d.queueText!==void 0&&e.removeOfflineQueueItem(d.queueText)}}}),e.appendSystemMessage=i,{sendPrompt:s,sendCommand:o,clearMessages:r,appendSystemMessage:i,abort:l,resolveApproval:a,loadOlderMessages:u}}function wy(e){const{s:t,showToast:n}=e;async function s(){try{const c=await fetch(`${Ge}/sessions`);if(!c.ok)return;t.sessions.value=await c.json()}catch{}}async function o(c){const d=t.sessionGeneration,f=t.connectionGeneration;try{return(await fetch(`${Ge}/sessions/${c}/activate`,{method:"POST"})).ok&&t.connectionGeneration===f&&wr(t.sessionId.value,t.sessionGeneration,c,d)}catch{return!1}}async function r(){const c=ft(t);try{const d=(c==null?void 0:c.sessionId)??t.currentSessionId.value,f=d?`?sessionId=${encodeURIComponent(d)}`:"",p=await fetch(`${Ge}/git/status${f}`);if(c&&!Ei(t,c)||!p.ok)return;const g=await p.json();t.gitStatus.value=g.isRepo?g:null}catch{}}async function i(c,d){try{const f=await fetch(`${Ge}/sessions`,{method:"POST",...c?{headers:{"Content-Type":"application/json"},body:JSON.stringify({workDir:c})}:{}});if(!f.ok){const g=await f.json().catch(()=>null),b=g&&typeof g.message=="string"?g.message:"";n(`新建会话失败:${b||`HTTP ${f.status}`}`,"error");return}const p=await f.json();t.sessions.value=[p,...t.sessions.value],d==null||d(p.sessionId),await a(p.sessionId)}catch(f){n(`新建会话失败:${f instanceof Error?f.message:String(f)}`,"error")}}async function a(c){t.currentSessionId.value===c&&t.connectionStatus.value==="connected"||(t.currentSessionId.value=c,t.sessionId.value=c,t.sessionGeneration++,e.resetGoalRequestState(),t.seq=0,t.epoch=0,t.journalGapCount=0,t.messages.value=[],t.pendingApprovals.value=[],t.status.value={busy:!1},t.gitStatus.value=null,t.workDir.value=null,t.goal.value=null,t.todos.value=[],t.sessionPlan.value=null,t.skills.value=[],t.skillsError.value=null,t.plugins.value=[],t.pluginInfo.value=null,t.mcpServers.value=[],t.mcpStartupMetrics.value=null,t.backgroundTasks.value=[],t.backgroundTaskOutput.value="",t.subagents.value=[],t.sessionActive.value=!1,t.promptPending.value=!1,t.pendingPromptAccepted=!1,t.sentMessageIds.clear(),t.reconnectTimer!==null&&(clearTimeout(t.reconnectTimer),t.reconnectTimer=null),t.snapshotRetryTimer!==null&&(clearTimeout(t.snapshotRetryTimer),t.snapshotRetryTimer=null),t.ws&&(t.ws.onclose=null,t.ws.close(),t.ws=null),e.stopHeartbeat(),e.connect())}async function l(c){try{const d=await fetch(`${Ge}/sessions/${c}`,{method:"DELETE"});if(!d.ok){n(`删除会话失败(HTTP ${d.status})`,"error");return}if(t.sessions.value=t.sessions.value.filter(f=>f.sessionId!==c),t.currentSessionId.value===c){const f=t.sessions.value[0];f?await a(f.sessionId):(t.sessionGeneration++,e.resetGoalRequestState(),t.sessionId.value=null,t.currentSessionId.value=null,t.sessionActive.value=!1,t.seq=0,t.epoch=0,t.journalGapCount=0,t.messages.value=[],t.pendingApprovals.value=[],t.status.value={busy:!1},t.gitStatus.value=null,t.workDir.value=null,t.goal.value=null,t.todos.value=[],t.sessionPlan.value=null,t.skills.value=[],t.skillsError.value=null,t.plugins.value=[],t.pluginInfo.value=null,t.mcpServers.value=[],t.mcpStartupMetrics.value=null,t.backgroundTasks.value=[],t.backgroundTaskOutput.value="",t.subagents.value=[],t.promptPending.value=!1,t.pendingPromptAccepted=!1,t.sentMessageIds.clear(),t.ws&&(t.ws.onclose=null,t.ws.close(),t.ws=null),e.stopHeartbeat(),e.setConnectionStatus("idle"))}}catch(d){n(`删除会话失败:${d instanceof Error?d.message:String(d)}`,"error")}}async function u(c){try{const d=await fetch(`${Ge}/sessions/${c}/export`);if(!d.ok){n(`导出会话失败(HTTP ${d.status})`,"error");return}const f=await d.blob(),p=URL.createObjectURL(f),g=document.createElement("a");g.href=p,g.download=`${c}.md`,g.click(),URL.revokeObjectURL(p)}catch(d){n(`导出会话失败:${d instanceof Error?d.message:String(d)}`,"error")}}return e.fetchSessions=s,e.switchSession=a,e.fetchGitStatus=r,e.activateSession=o,{fetchSessions:s,fetchGitStatus:r,createSession:i,switchSession:a,deleteSession:l,exportSession:u}}function Sy(e){const{s:t,showToast:n}=e;async function s(){try{const u=await fetch(`${Ge}/models`);if(!u.ok){t.modelsError.value=`模型列表加载失败(HTTP ${u.status})`;return}const c=await u.json();t.models.value=c.models,t.modelsError.value=null}catch(u){t.modelsError.value=`模型列表加载失败:${u instanceof Error?u.message:String(u)}`}}async function o(){try{const u=await fetch(`${Ge}/like`);if(!u.ok)return;t.like.value=await u.json()}catch{}}async function r(u){try{return(await fetch(`${Ge}/like`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)})).ok?(t.like.value=u,!0):!1}catch{return!1}}async function i(u,c,d){const f=t.sessionId.value;if(!f){n("请先打开一个会话","warning");return}const p=t.sessionGeneration,g=t.connectionGeneration,b=++t.sessionMutationGeneration;try{const S=await fetch(`${Ge}/sessions/${f}/${u}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),w=await S.json();if(t.sessionId.value!==f||t.sessionGeneration!==p||t.connectionGeneration!==g||t.sessionMutationGeneration!==b)return;if(!S.ok){n(w.message??`请求失败(HTTP ${S.status})`,"error");return}w.status&&(t.status.value={...t.status.value,...w.status}),n(d,"success")}catch(S){if(t.sessionId.value!==f||t.sessionGeneration!==p||t.connectionGeneration!==g||t.sessionMutationGeneration!==b)return;n(`请求失败:${S instanceof Error?S.message:String(S)}`,"error")}}async function a(u){u!==t.status.value.model&&await i("model",{model:u},`已切换模型:${u}`)}async function l(u){u!==t.status.value.thinkingLevel&&await i("thinking",{level:u},`思考强度已切换为 ${u}`)}return Yt(t,"status",u=>{t.liveGeneration++,t.status.value={...t.status.value,...u.status}}),e.fetchModels=s,{fetchModels:s,fetchLike:o,updateLike:r,switchModel:a,switchThinking:l}}function _y(e){const{s:t}=e;function n(){t.goalRequestPending.value=t.goalRequestInFlight||t.goalAwaitingMutation!==null}function s(){t.goalMutationGeneration++,t.goalAwaitingMutation=null,t.goalRequestInFlight=!1,t.snapshotRetryGoalGeneration=null,t.goalRequestPending.value=!1,t.goalRequestError.value=null}async function o(f,p,g,b){const S=t.sessionId.value;if(!S)return t.goalRequestError.value="暂无可操作的会话。",null;if(t.connectionStatus.value!=="connected")return t.goalRequestError.value="连接已断开,请等待重连后再试。",null;if(t.isArchived.value)return t.goalRequestError.value="当前会话已归档,无法修改 Goal。",null;if(t.goalRequestInFlight)return t.goalRequestError.value="正在处理上一个请求,请稍候。",null;t.goalAwaitingMutation!==null&&(t.goalAwaitingMutation=null,n());const w=t.sessionGeneration,k=++t.goalMutationGeneration;t.goalRequestInFlight=!0,n(),t.goalRequestError.value=null;try{const y=await fetch(`${Ge}/sessions/${S}/goal${f}`,{method:p,headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),_=await y.json().catch(()=>({}));return!wr(t.sessionId.value,t.sessionGeneration,S,w)||t.goalMutationGeneration!==k?null:y.ok?(b&&(t.goalAwaitingMutation={generation:k},t.snapshotRetryGoalGeneration=k),_):(t.goalRequestError.value=typeof _.message=="string"?_.message:`请求失败(HTTP ${y.status})`,null)}catch(y){return wr(t.sessionId.value,t.sessionGeneration,S,w)&&t.goalMutationGeneration===k&&(t.goalRequestError.value=`请求失败:${y instanceof Error?y.message:String(y)}`),null}finally{wr(t.sessionId.value,t.sessionGeneration,S,w)&&t.goalMutationGeneration===k&&(t.goalRequestInFlight=!1,n())}}async function r(f){const p=await o("/refine","POST",{description:f},!1);return typeof(p==null?void 0:p.objective)=="string"?p.objective:null}async function i(f){return await o("","POST",ny(f),!0)===null?!1:(t.goalAwaitingMutation!==null&&e.fetchSnapshot(t.goalAwaitingMutation.generation),!0)}async function a(f){return await o("","PATCH",sy(f),!0)===null?!1:(t.goalAwaitingMutation!==null&&e.fetchSnapshot(t.goalAwaitingMutation.generation),!0)}async function l(f){return await o(f,"POST",{},!0)===null?!1:(t.goalAwaitingMutation!==null&&e.fetchSnapshot(t.goalAwaitingMutation.generation),!0)}function u(){return l("/pause")}function c(){return l("/resume")}function d(){return l("/cancel")}return e.resetGoalRequestState=s,e.syncGoalRequestPending=n,{refineGoal:r,createGoal:i,updateGoal:a,pauseGoal:u,resumeGoal:c,cancelGoal:d}}function $y(e){const{s:t,showToast:n}=e;let s=0,o=0,r=0,i=0;function a(_){return _!==null&&Ei(t,_)}async function l(){const _=ft(t);if(!_)return;const N=++s;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/status`);if(!a(_)||N!==s||!D.ok)return;const E=await D.json();t.status.value={...t.status.value,...E}}catch{}}async function u(){const _=ft(t);if(!_)return;const N=++o;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/usage`);if(!a(_)||N!==o||!D.ok)return;const E=await D.json();t.status.value={...t.status.value,usage:E}}catch{}}async function c(){const _=ft(t);if(!_)return;const N=++r;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/context`);if(!a(_)||N!==r||!D.ok)return;const E=await D.json();E.tokenCount!==void 0&&(t.status.value={...t.status.value,contextTokens:E.tokenCount})}catch{}}async function d(){const _=ft(t);if(!_)return;const N=++i;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/plan`);if(!a(_)||N!==i||!D.ok)return;t.sessionPlan.value=await D.json()}catch{}}async function f(){const _=ft(t);if(!_)return!1;const N=++i;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/plan/clear`,{method:"POST"});return!a(_)||N!==i||!D.ok?!1:(t.sessionPlan.value=null,!0)}catch{return!1}}async function p(_,N){const D=ft(t);if(!D)return!1;if(t.connectionStatus.value!=="connected")return n("连接已断开,操作未发送。","error"),e.connect(),!1;try{const E=await fetch(`${Ge}/sessions/${D.sessionId}/${_}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N??{})});if(!a(D))return!1;if(!E.ok){const A=await E.json().catch(()=>({}));return a(D)&&n(A.message??`操作失败(HTTP ${E.status})`,"error"),!1}return!0}catch(E){return a(D)&&n(`操作失败:${E instanceof Error?E.message:String(E)}`,"error"),!1}}async function g(_){const N=t.sessionId.value,D=t.sessionGeneration,E=t.connectionGeneration,A=++t.permissionMutationGeneration,T=t.status.value.permission;return t.status.value={...t.status.value,permission:_},await p("permission",{mode:_})?(await l(),!0):(t.sessionId.value!==N||t.sessionGeneration!==D||t.connectionGeneration!==E||t.permissionMutationGeneration!==A||(t.status.value={...t.status.value,permission:T}),!1)}async function b(_,N){const D=await p("plan",{enabled:_,...N?{strategy:N}:{}});return D&&await l(),D}async function S(_){const N=await p("wolfpack",{enabled:_});return N&&await l(),N}async function w(_,N){const D=await p("rlm",{enabled:_,...N!==void 0?{maxDepth:N}:{}});return D&&await l(),D}async function k(_=1){return p("undo",{count:_})}async function y(_){return p("compact",_?{instruction:_}:{})}return e.postSessionAction=p,{fetchSessionStatus:l,fetchSessionUsage:u,fetchSessionContext:c,fetchSessionPlan:d,clearPlan:f,switchPermission:g,switchPlanMode:b,switchWolfpack:S,switchRlm:w,undoHistory:k,compact:y}}function Cy(e){const{s:t}=e;let n=0,s=0,o=0;function r(y){return y!==null&&Ei(t,y)}async function i(){const y=ft(t);if(!y)return;const _=++n;try{const N=await fetch(`${Ge}/sessions/${y.sessionId}/skills`);if(!r(y)||_!==n)return;if(!N.ok){t.skillsError.value=`技能列表加载失败(HTTP ${N.status})`;return}t.skills.value=await N.json(),t.skillsError.value=null}catch(N){if(!r(y)||_!==n)return;t.skillsError.value=`技能列表加载失败:${N instanceof Error?N.message:String(N)}`}}async function a(y,_){return e.postSessionAction(`skills/${encodeURIComponent(y)}/activate`,_?{args:_}:{})}async function l(y){const _=ft(t);if(!_)return!1;++n;try{const N=await fetch(`${Ge}/sessions/${_.sessionId}/skills/${encodeURIComponent(y)}`,{method:"DELETE"});return!r(_)||!N.ok?!1:(t.skills.value=t.skills.value.filter(D=>D.name!==y),!0)}catch{return!1}}async function u(){const y=ft(t);if(!y)return;const _=++s;try{const N=await fetch(`${Ge}/sessions/${y.sessionId}/plugins`);if(!r(y)||_!==s||!N.ok)return;t.plugins.value=await N.json()}catch{}}async function c(y){const _=ft(t);if(!_)return;const N=++o;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/plugins/${encodeURIComponent(y)}`);if(!r(_)||N!==o||!D.ok)return;t.pluginInfo.value=await D.json()}catch{}}async function d(y){const _=ft(t);if(!_)return null;++s;try{const N=await fetch(`${Ge}/sessions/${_.sessionId}/plugins/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:y})});if(!r(_)||!N.ok)return null;const D=await N.json();return await u(),r(_)?D:null}catch{return null}}async function f(y,_){return e.postSessionAction(`plugins/${encodeURIComponent(y)}/enable`,{enabled:_})}async function p(y,_,N){return e.postSessionAction(`plugins/${encodeURIComponent(y)}/mcp/${encodeURIComponent(_)}/enable`,{enabled:N})}async function g(y){const _=ft(t);if(!_)return!1;++s;try{const N=await fetch(`${Ge}/sessions/${_.sessionId}/plugins/${encodeURIComponent(y)}`,{method:"DELETE"});return!r(_)||!N.ok?!1:(t.plugins.value=t.plugins.value.filter(D=>D.id!==y),!0)}catch{return!1}}async function b(){const y=ft(t);if(!y)return null;++s;try{const _=await fetch(`${Ge}/sessions/${y.sessionId}/plugins/reload`,{method:"POST"});if(!r(y)||!_.ok)return null;const N=await _.json();return await u(),r(y)?N:null}catch{return null}}async function S(y){return e.postSessionAction(`plugins/${encodeURIComponent(y)}/activate`)}async function w(y){return e.postSessionAction(`plugins/${encodeURIComponent(y)}/deactivate`)}async function k(y){return e.postSessionAction(`plugins/${encodeURIComponent(y)}/inject`)}return{fetchSkills:i,activateSkill:a,removeSkill:l,fetchPlugins:u,fetchPluginInfo:c,installPlugin:d,setPluginEnabled:f,setPluginMcpServerEnabled:p,removePlugin:g,reloadPlugins:b,activatePlugin:S,deactivatePlugin:w,injectPlugin:k}}function xy(e){const{s:t}=e;let n=0,s=0,o=0,r=0;function i(S){return S!==null&&Ei(t,S)}async function a(){const S=ft(t);if(!S)return;const w=++n;try{const k=await fetch(`${Ge}/sessions/${S.sessionId}/mcp`);if(!i(S)||w!==n||!k.ok)return;t.mcpServers.value=await k.json()}catch{}}async function l(){const S=ft(t);if(!S)return;const w=++s;try{const k=await fetch(`${Ge}/sessions/${S.sessionId}/mcp/startup-metrics`);if(!i(S)||w!==s||!k.ok)return;t.mcpStartupMetrics.value=await k.json()}catch{}}async function u(S,w){return e.postSessionAction("mcp/add",{name:S,config:w})}async function c(S){return e.postSessionAction(`mcp/${encodeURIComponent(S)}/reconnect`)}async function d(S){return e.postSessionAction(`mcp/${encodeURIComponent(S)}/stop`)}async function f(S){const w=ft(t);if(!w)return!1;try{const k=await fetch(`${Ge}/sessions/${w.sessionId}/mcp/${encodeURIComponent(S)}`,{method:"DELETE"});return!i(w)||!k.ok?!1:(t.mcpServers.value=t.mcpServers.value.filter(y=>y.name!==S),!0)}catch{return!1}}async function p(S,w){const k=ft(t);if(!k)return;const y=++o;try{const _=new URLSearchParams;S!==void 0&&_.set("activeOnly",String(S)),w!==void 0&&_.set("limit",String(w));const N=_.toString(),D=await fetch(`${Ge}/sessions/${k.sessionId}/tasks${N?`?${N}`:""}`);if(!i(k)||y!==o||!D.ok)return;t.backgroundTasks.value=await D.json()}catch{}}async function g(S,w){const k=ft(t);if(!k)return;const y=++r;try{const _=w!==void 0?`?tail=${w}`:"",N=await fetch(`${Ge}/sessions/${k.sessionId}/tasks/${encodeURIComponent(S)}/output${_}`);if(!i(k)||y!==r||!N.ok)return;const D=await N.json();t.backgroundTaskOutput.value=D.output}catch{}}async function b(S,w){return e.postSessionAction(`tasks/${encodeURIComponent(S)}/stop`,w?{reason:w}:{})}return e.refreshBackgroundTasks=p,{fetchMcpServers:a,fetchMcpStartupMetrics:l,addMcpServer:u,reconnectMcpServer:c,stopMcpServer:d,removeMcpServer:f,fetchBackgroundTasks:p,fetchBackgroundTaskOutput:g,stopBackgroundTask:b}}function Iy(e){const{s:t}=e;async function n(){try{const a=await fetch(`${Ge}/config`);if(!a.ok)return;t.config.value=await a.json()}catch{}}async function s(a){try{const l=await fetch(`${Ge}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:a})});return l.ok?(t.config.value=await l.json(),!0):!1}catch{return!1}}async function o(a){try{return(await fetch(`${Ge}/config/providers/${encodeURIComponent(a)}`,{method:"DELETE"})).ok?(await n(),!0):!1}catch{return!1}}async function r(){try{const a=await fetch(`${Ge}/experimental-flags`);if(!a.ok)return;t.experimentalFlags.value=await a.json()}catch{}}async function i(){try{if(!(await fetch(`${Ge}/preflight`)).ok)return;t.preflightOk.value=!0}catch{}}return{fetchConfig:n,setConfig:s,removeProvider:o,fetchExperimentalFlags:r,preflight:i}}function Ty(e){const{s:t}=e;return function(s){const o=t.wsHandlers.get(s.type);if(o!==void 0){o(s);return}t.wsUnknownFrames++,console.error(`[webClient] 收到未注册的 WS 帧类型 "${s.type}"(第 ${t.wsUnknownFrames} 次),该帧已被丢弃;请在对应域模块用 onWsMessage 注册处理器。`,s)}}function Ey(e){const{s:t,showToast:n}=e,s=Ty(e);function o(){const g=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`;return t.currentSessionId.value?`${g}?sessionId=${encodeURIComponent(t.currentSessionId.value)}`:g}function r(p){t.connectionStatus.value=p}function i(p=8e3){if(t.connectionStatus.value==="connected")return Promise.resolve(!0);if(t.connectionStatus.value==="idle"||t.disposed)return Promise.resolve(!1);const g=t.sessionId.value;if(!g)return Promise.resolve(!1);const b=Number.isFinite(p)&&p>0?p:8e3;return new Promise(S=>{const w=Date.now(),k=window.setInterval(()=>{t.sessionId.value!==g?(window.clearInterval(k),S(!1)):t.connectionStatus.value==="connected"?(window.clearInterval(k),S(!0)):(t.connectionStatus.value==="idle"||t.disposed||Date.now()-w>=b)&&(window.clearInterval(k),S(!1))},50)})}function a(p){var g;((g=t.ws)==null?void 0:g.readyState)===WebSocket.OPEN&&t.ws.send(JSON.stringify(p))}function l(p){u();const g=Number.isFinite(p)&&p>=1e3&&p<=12e4?p:15e3;t.lastPongAt=Date.now(),t.heartbeatTimer=window.setInterval(()=>{var b;if(Date.now()-t.lastPongAt>Xv){(b=t.ws)==null||b.close();return}a({type:"ping"})},g)}function u(){t.heartbeatTimer!==null&&(clearInterval(t.heartbeatTimer),t.heartbeatTimer=null)}function c(){if(t.disposed||t.reconnectTimer!==null)return;if(t.reconnectAttempt>=pc){r("disconnected"),t.error.value=`连接失败:自动重试已达上限(${pc} 次),请手动重试`;return}r("reconnecting"),t.reconnectAttempt++;const p=Math.min(1e3*2**t.reconnectAttempt,3e4);t.reconnectTimer=window.setTimeout(()=>{t.reconnectTimer=null,f()},p)}function d(){if(!t.disposed){if(t.reconnectTimer!==null&&(clearTimeout(t.reconnectTimer),t.reconnectTimer=null),t.ws!==null){try{t.ws.close()}catch{}t.ws=null}t.reconnectAttempt=0,f()}}function f(){if(t.disposed||t.ws&&(t.ws.readyState===WebSocket.CONNECTING||t.ws.readyState===WebSocket.OPEN))return;r("connecting"),t.error.value=null,e.resetGoalRequestState(),t.connectionGeneration++;const p=new WebSocket(o());t.ws=p,p.onclose=g=>{if(t.ws===p&&(t.ws=null,u(),t.connectionStatus.value!=="idle")){if(g.code===1008){t.sessionGeneration++,e.resetGoalRequestState(),t.sessionId.value=null,t.currentSessionId.value=null,t.sessionActive.value=!1,t.goal.value=null,t.todos.value=[],t.subagents.value=[],t.sessionPlan.value=null,t.skills.value=[],t.skillsError.value=null,t.plugins.value=[],t.pluginInfo.value=null,t.mcpServers.value=[],t.mcpStartupMetrics.value=null,t.backgroundTasks.value=[],t.backgroundTaskOutput.value="",t.pendingApprovals.value=[],t.status.value={busy:!1},t.gitStatus.value=null,t.workDir.value=null,t.messages.value=[],t.error.value=null,t.promptPending.value=!1,t.sentMessageIds.clear(),r("idle"),g.reason!=="unauthorized"&&(n("会话不可用或已被删除","warning"),e.fetchSessions());return}r("disconnected"),c()}},p.onerror=()=>{t.ws===p&&r("reconnecting")},p.onmessage=g=>{if(t.ws!==p)return;t.lastPongAt=Date.now();let b;try{b=JSON.parse(g.data)}catch{return}s(b)}}return Yt(t,"server_hello",p=>{t.sessionId.value=p.sessionId,t.workDir.value=p.workDir,t.currentSessionId.value=p.sessionId,t.sessionActive.value=p.active;const g=t.epoch;t.epoch=p.epoch,l(p.heartbeat_ms),a({type:"client_hello",lastSeq:t.seq,epoch:g}),g!==0&&g!==p.epoch&&(t.seq=0),r("connected"),t.reconnectAttempt=0,e.flushQueue();const b=t.sessionGeneration,S=t.connectionGeneration,w=()=>t.sessionId.value===p.sessionId&&t.currentSessionId.value===p.sessionId&&t.sessionGeneration===b&&t.connectionGeneration===S,k=()=>{w()&&(e.fetchSnapshot().finally(()=>{var y;w()&&((y=e.refreshSessionResources)==null||y.call(e))}),e.fetchSessions(),e.fetchGitStatus())};p.active?k():e.activateSession(p.sessionId).then(y=>{w()&&(y&&t.sessionId.value===p.sessionId&&(t.sessionActive.value=!0),k())})}),Yt(t,"server_empty",()=>{r("idle")}),Yt(t,"pong",()=>{}),e.connect=f,e.waitForConnected=i,e.send=a,e.stopHeartbeat=u,e.setConnectionStatus=r,{connect:f,waitForConnected:i,send:a,reconnectNow:d,stopHeartbeat:u}}function Ay(){const e=Qv(),t=e.s;ey(e);const n=yy(e),s=by(e),o=ky(e),r=wy(e),i=Sy(e),a=_y(e),l=$y(e),u=Cy(e),c=xy(e),d=Iy(e),f=Ey(e);e.refreshSessionResources=async()=>{t.sessionId.value&&await Promise.all([l.fetchSessionStatus(),l.fetchSessionUsage(),l.fetchSessionContext(),l.fetchSessionPlan(),u.fetchSkills(),u.fetchPlugins(),c.fetchMcpServers(),c.fetchMcpStartupMetrics(),c.fetchBackgroundTasks()])},f.connect(),r.fetchSessions(),i.fetchModels();const p=()=>{f.connect()},g=()=>{!document.hidden&&t.connectionStatus.value!=="connected"&&f.connect()};window.addEventListener("online",p),document.addEventListener("visibilitychange",g),st(()=>{t.disposed=!0,n.disposeStreaming(),window.removeEventListener("online",p),document.removeEventListener("visibilitychange",g),f.stopHeartbeat(),t.reconnectTimer!==null&&(clearTimeout(t.reconnectTimer),t.reconnectTimer=null),t.snapshotRetryTimer!==null&&(clearTimeout(t.snapshotRetryTimer),t.snapshotRetryTimer=null),t.ws&&(t.ws.onclose=null,t.ws.close(),t.ws=null)}),Se(t.skills,S=>dc(S),{immediate:!0});const b={connectionStatus:t.connectionStatus,waitForConnected:f.waitForConnected,messages:t.messages,pendingApprovals:t.pendingApprovals,status:t.status,goal:t.goal,todos:t.todos,goalRequestPending:t.goalRequestPending,goalRequestError:t.goalRequestError,error:t.error,sessionId:t.sessionId,workDir:t.workDir,isBusy:t.isBusy,isArchived:t.isArchived,sessions:t.sessions,currentSessionId:t.currentSessionId,gitStatus:t.gitStatus,models:t.models,modelsError:t.modelsError,like:t.like,fetchLike:i.fetchLike,updateLike:i.updateLike,sendPrompt:o.sendPrompt,sendCommand:o.sendCommand,clearMessages:o.clearMessages,appendSystemMessage:o.appendSystemMessage,abort:o.abort,resolveApproval:o.resolveApproval,fetchSessions:r.fetchSessions,fetchGitStatus:r.fetchGitStatus,fetchModels:i.fetchModels,reconnectNow:f.reconnectNow,olderAvailable:t.olderAvailable,oldestSeq:t.oldestSeq,loadOlderMessages:o.loadOlderMessages,switchModel:i.switchModel,switchThinking:i.switchThinking,refineGoal:a.refineGoal,createGoal:a.createGoal,updateGoal:a.updateGoal,pauseGoal:a.pauseGoal,resumeGoal:a.resumeGoal,cancelGoal:a.cancelGoal,createSession:r.createSession,switchSession:r.switchSession,deleteSession:r.deleteSession,exportSession:r.exportSession,fetchSnapshot:s.fetchSnapshot,fetchSessionStatus:l.fetchSessionStatus,fetchSessionUsage:l.fetchSessionUsage,fetchSessionContext:l.fetchSessionContext,fetchSessionPlan:l.fetchSessionPlan,sessionPlan:t.sessionPlan,clearPlan:l.clearPlan,switchPermission:l.switchPermission,switchPlanMode:l.switchPlanMode,switchWolfpack:l.switchWolfpack,switchRlm:l.switchRlm,undoHistory:l.undoHistory,compact:l.compact,skills:t.skills,skillsError:t.skillsError,fetchSkills:u.fetchSkills,activateSkill:u.activateSkill,removeSkill:u.removeSkill,plugins:t.plugins,pluginInfo:t.pluginInfo,fetchPlugins:u.fetchPlugins,fetchPluginInfo:u.fetchPluginInfo,installPlugin:u.installPlugin,setPluginEnabled:u.setPluginEnabled,setPluginMcpServerEnabled:u.setPluginMcpServerEnabled,removePlugin:u.removePlugin,reloadPlugins:u.reloadPlugins,activatePlugin:u.activatePlugin,deactivatePlugin:u.deactivatePlugin,injectPlugin:u.injectPlugin,mcpServers:t.mcpServers,mcpStartupMetrics:t.mcpStartupMetrics,fetchMcpServers:c.fetchMcpServers,fetchMcpStartupMetrics:c.fetchMcpStartupMetrics,addMcpServer:c.addMcpServer,reconnectMcpServer:c.reconnectMcpServer,stopMcpServer:c.stopMcpServer,removeMcpServer:c.removeMcpServer,backgroundTasks:t.backgroundTasks,backgroundTaskOutput:t.backgroundTaskOutput,subagents:t.subagents,fetchBackgroundTasks:c.fetchBackgroundTasks,fetchBackgroundTaskOutput:c.fetchBackgroundTaskOutput,stopBackgroundTask:c.stopBackgroundTask,config:t.config,fetchConfig:d.fetchConfig,setConfig:d.setConfig,removeProvider:d.removeProvider,experimentalFlags:t.experimentalFlags,fetchExperimentalFlags:d.fetchExperimentalFlags,preflightOk:t.preflightOk,preflight:d.preflight};return qv(b),st(()=>{Vv(b),dc([])}),b}const My=["compact","auto","ask","yes","bot","plan","fork","title","btw"];function bc(e){const t=(e==null?void 0:e.trim().toLowerCase())??"";return t.length===0?"toggle":t==="on"?!0:t==="off"?!1:null}function Ry(e){const t=(e==null?void 0:e.trim())??"";if(t.length===0)return 1;if(!/^[1-9]\d*$/.test(t))return null;const n=Number(t);return Number.isSafeInteger(n)?n:null}function Py(e){const t=(e==null?void 0:e.trim())??"";if(!/^\d+$/.test(t))return null;const n=Number(t);return Number.isSafeInteger(n)?n:null}function lh(e){const{showToast:t}=Qs();async function n(){var f;try{if(await((f=e.ensureSession)==null?void 0:f.call(e))===!1)return null}catch(p){return t(`无法创建会话:${p instanceof Error?p.message:String(p)}`,"error"),null}const d=Ha();return!d||!d.sessionId.value?(t("请先创建或打开一个会话。","warning"),null):d}async function s(d,f){try{await d()&&t(f,"success")}catch(p){t(`操作失败:${p instanceof Error?p.message:String(p)}`,"error")}}async function o(d){const f=bc(d);if(f===null){t("用法:/wolfpack [on|off]","warning");return}const p=await n();if(!p)return;const g=f==="toggle"?p.status.value.wolfpackMode!==!0:f;await s(()=>p.switchWolfpack(g),`Wolfpack 模式已${g?"开启":"关闭"}`)}async function r(d){const f=bc(d);if(f===null){t("用法:/rlm [on|off]","warning");return}const p=await n();if(!p)return;const g=f==="toggle"?p.status.value.rlmEnabled!==!0:f;await s(()=>p.switchRlm(g),`RLM 模式已${g?"开启":"关闭"}`)}async function i(d){const f=(d==null?void 0:d.trim())??"";if(f.length===0){const S=await n();if(!S)return;const w=S.status.value.rlmMaxDepth??null;e.appendSystemMessage(w===null?"RLM 最大深度:无限(默认)。":`RLM 最大深度:${w}。`);return}const p=Py(f);if(p===null){t("RLM 深度需为 0 或非负整数。","warning");return}const g=await n();if(!g)return;const b=g.status.value.rlmEnabled===!0;await s(()=>g.switchRlm(b,p),p===0?"RLM 递归深度已设为无限。":`RLM 最大深度已设为 ${p}。`)}async function a(d){const f=(d==null?void 0:d.trim().toLowerCase())??"";if(f!==""&&f!=="on"&&f!=="off"){t("用法:/fusionplan [on|off]","warning");return}const p=await n();if(!p)return;const g=p.status.value.planMode===!0&&p.status.value.planStrategy==="fusion",b=f==="off"?!1:f==="on"?!0:!g;await s(()=>p.switchPlanMode(b,b?"fusion":void 0),`融合计划模式已${b?"开启":"关闭"}`)}async function l(d){const f=Ry(d);if(f===null){t("用法:/revoke [正整数轮数]","warning");return}const p=await n();if(p){if(p.isBusy.value){t("当前回合正在运行,无法撤销。","error");return}try{if(!await p.undoHistory(f))return;await p.fetchSnapshot(),t(`已撤销最近 ${f} 轮。`,"success")}catch(g){t(`撤销失败:${g instanceof Error?g.message:String(g)}`,"error")}}}async function u(d,f){var S;if(await((S=e.ensureSession)==null?void 0:S.call(e))===!1)return;const g=e.onSkill??(async(w,k)=>{const y=Ha();return y?await y.activateSkill(w,k):!1});let b=!1;try{b=await g(d,f)}catch(w){b=!1,t(`技能激活失败:${w instanceof Error?w.message:String(w)}`,"error");return}b?t(`技能已激活:/${d}`,"success"):t(`技能激活失败:/${d}`,"error")}async function c(d,f){var p,g,b;if(My.includes(d)){if(await((p=e.ensureSession)==null?void 0:p.call(e))===!1)return;e.sendCommand(d,f)}else d==="wolfpack"?await o(f):d==="rlm"?await r(f):d==="rlm-max-depth"?await i(f):d==="fusionplan"?await a(f):d==="revoke"?await l(f):d==="clear"?e.clearMessages():d==="new"?e.onNew():d==="help"?e.appendSystemMessage(Wv()):d==="model"?(g=e.openModelPicker)!=null&&g.call(e)||e.appendSystemMessage(`当前模型:${((b=e.currentModel)==null?void 0:b.call(e))??"unknown"}`):d==="status"||d==="usage"?e.showInfo?e.showInfo(d):e.appendSystemMessage("请在对话页查看会话详情"):Hv(d)?await u(d,f):t(`未知命令:/${d}`,"error")}return{onCommand:c}}const Ly=640,Dy=1024,Fl=768,kc=264,Vr=420,Ny=288,wc=56,Wa=300,uh=.7,Oy=320,ch=400;function ss(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 Gy(e){return ss(e*.45,Wa,Math.round(e*uh))}function By(e){const{viewportWidth:t,rightPanelOpen:n,rightPanelWidth:s}=e;if(t<=Ly)return Vr;const o=t<Fl,r=o?Oy:ch,i=!o&&n?s:0;return Math.min(Vr,t-r-i)}function Fy(e){const{viewportWidth:t,sidebarOpen:n,sidebarWidth:s}=e,o=Math.round(t*uh);if(t<Fl)return o;const r=n?s:0;return Math.min(o,t-ch-r)}function Kr(e){try{return localStorage.getItem(e)??void 0}catch{return}}function Zr(e,t){try{localStorage.setItem(e,t)}catch{}}function Uy(e){try{const t=localStorage.getItem(e);return t===null?void 0:JSON.parse(t)}catch{return}}function jy(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function Sc(e){const{storageKey:t,minWidth:n,side:s}=e,o=y=>typeof y=="function"?y():y,r=()=>o(e.maxWidth);function i(){var _;const y=Uy(t);return typeof y=="number"&&Number.isFinite(y)&&y>=n&&(((_=e.acceptStoredWidth)==null?void 0:_.call(e,y))??!0)?Math.round(y):o(e.defaultWidth)}const a=G(i()),l=G(!1);let u=null;function c(){jy(t,a.value)}function d(y){return s==="left"?y:window.innerWidth-y}function f(y){if(!(e.canDrag&&!e.canDrag())){y.preventDefault(),l.value=!0,u=y.pointerId;try{y.currentTarget.setPointerCapture(y.pointerId)}catch{}}}function p(y){!l.value||y.pointerId!==u||(a.value=ss(d(y.clientX),n,r()))}function g(y){!l.value||y.pointerId!==u||b()}function b(){l.value=!1,u=null,c()}function S(){a.value=ss(o(e.defaultWidth),n,r()),c()}function w(y){const _=y.shiftKey?32:12,N=s==="left"?1:-1;if(y.key==="ArrowLeft")y.preventDefault(),a.value=ss(a.value-N*_,n,r());else if(y.key==="ArrowRight")y.preventDefault(),a.value=ss(a.value+N*_,n,r());else if(y.key==="Home")y.preventDefault(),a.value=n;else if(y.key==="End")y.preventDefault(),a.value=ss(r(),n,r());else if(y.key==="Enter")y.preventDefault(),S();else return;c()}const k=B(()=>ss(a.value,n,r()));return{width:a,effectiveWidth:k,resizing:l,onPointerDown:f,onPointerMove:p,onPointerUp:g,onKeydown:w,reset:S,release:b}}const Ul=new Map;function Pn(e){return Ul.set(e.kind,e),e}function dh(e){const t=Ul.get(e);if(!t)throw new Error(`unregistered dock tab kind: ${e}`);return t}function zy(e){return typeof e=="string"&&Ul.has(e)}Pn({kind:"file",label:"文件",icon:"file",singleton:!1});Pn({kind:"detail",label:"会话详情",icon:"layers",singleton:!0});Pn({kind:"control",label:"会话控制",icon:"wrench",singleton:!0});Pn({kind:"agents",label:"协作代理",icon:"bot",singleton:!0});Pn({kind:"run",label:"运行状态",icon:"activity",singleton:!0});Pn({kind:"git",label:"Git",icon:"git-branch",singleton:!0});Pn({kind:"todo",label:"Todo",icon:"clipboard",singleton:!0});Pn({kind:"goal",label:"目标",icon:"target",singleton:!0});Pn({kind:"like",label:"偏好",icon:"user",singleton:!0});function fh(e){return`dock:${e}`}function Yr(e){return`dock-tab-${encodeURIComponent(e)}`}function qa(e){return`dock-panel-${encodeURIComponent(e)}`}function Hy(e,t){return(e==null?void 0:e.displayMode)??t??"source"}function Wy(e,t){const n=e.find(r=>r.id===t.tabId);if(!n)return[...e,{id:t.tabId,kind:"file",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}];if(n.kind!=="file")return e;const s=!!(t.sourceSessionId&&n.sourceSessionId!==t.sourceSessionId);return!s&&!t.modeHint?e:e.map(r=>{var a;if(r.id!==t.tabId||r.kind!=="file")return r;const i={...r};return s&&(i.sourceSessionId=t.sourceSessionId),t.modeHint?(i.initialDisplayMode=t.modeHint,i.viewerState={displayMode:t.modeHint,wrapLines:((a=r.viewerState)==null?void 0:a.wrapLines)??!1,scrollTop:0,scrollLeft:0},i.viewerRevision=(r.viewerRevision??0)+1):s&&(i.viewerRevision=(r.viewerRevision??0)+1),i})}function qy(e,t){const n=fh(t);return e.some(s=>s.id===n)?e:[...e,{id:n,kind:t,label:dh(t).label}]}function Vy(e,t,n,s){const o=e.findIndex(a=>a.id===t&&a.kind==="file");if(o===-1)return e;const r=e[o];if((r.viewerRevision??0)!==n)return e;const i=[...e];return i[o]={...r,viewerState:s},i}const hh="scream-file-tabs";function Ky(){try{const e=localStorage.getItem(hh);return e?JSON.parse(e):{}}catch{return{}}}function Zo(e){try{localStorage.setItem(hh,JSON.stringify(e))}catch{}}function Zy(e){return typeof e.id!="string"||typeof e.label!="string"?null:e.kind===void 0?typeof e.filePath=="string"?{...e,kind:"file"}:null:zy(e.kind)?e.kind==="file"?typeof e.filePath!="string"?null:e:{id:e.id,kind:e.kind,label:e.label}:null}const Go=Ky(),sa=(Array.isArray(Go.tabs)?Go.tabs:[]).map(e=>Zy(e)).filter(e=>e!==null),_c=typeof Go.activeTabId=="string"?Go.activeTabId:null;var Od;const we=Wn({tabs:sa,activeTabId:sa.some(e=>e.id===_c)?_c:((Od=sa.at(-1))==null?void 0:Od.id)??null,panelOpen:Go.panelOpen===!0});function Yy(){var e;if(we.tabs.length===0){we.activeTabId=null;return}we.tabs.some(t=>t.id===we.activeTabId)||(we.activeTabId=((e=we.tabs.at(-1))==null?void 0:e.id)??null)}function vs(e,t={}){const n=e.split("/").pop()||e,s=e;return we.tabs=Wy(we.tabs,{fileName:t.label??n,filePath:e,modeHint:t.modeHint,sourceSessionId:t.sessionId??null,tabId:s}),we.activeTabId=s,we.panelOpen=!0,Zo(we),s}function Sr(e){const t=fh(e);return we.tabs=qy(we.tabs,e),we.activeTabId=t,we.panelOpen=!0,Zo(we),t}function Xy(e){we.tabs.some(t=>t.id===e)&&(we.activeTabId=e,Zo(we))}function Jy(e){const t=we.tabs.findIndex(n=>n.id===e);if(t!==-1){if(we.tabs=we.tabs.filter(n=>n.id!==e),we.activeTabId===e){const n=we.tabs[t]??we.tabs[t-1]??null;we.activeTabId=n?n.id:null}we.tabs.length===0&&(we.panelOpen=!1,we.activeTabId=null),Zo(we)}}function jl(e){we.panelOpen=e,e&&Yy(),Zo(we)}function Qy(){jl(!we.panelOpen)}const Va=()=>we.tabs.find(e=>e.id===we.activeTabId),eb=()=>{const e=Va();return e&&e.kind==="file"?e:void 0},Ai=G(!1);let Xr=0;function tb(){Xr++}function nb(){Xr=Math.max(0,Xr-1)}function sb(){return Xr>0}function ph(){return sb()?(Ai.value=!0,!0):!1}function ob(){Ai.value=!0}function Jr(){Ai.value=!1}function gh(){return{open:Ai,openSettingsModal:ob,closeSettingsModal:Jr,tryOpenSettingsModal:ph}}const mh="scream-workspace-preference",Mi=G(Kr(mh)||null),zl=G(null);let co=null;function rb(e){Mi.value=e,Zr(mh,e??"")}async function ib(){return co||(co=(async()=>{try{const e=await fetch(`${Ge}/workdir`);if(!e.ok)return;const t=await e.json();typeof t.workDir=="string"&&t.workDir&&(zl.value=t.workDir)}catch{}finally{co=null}})(),co)}const ab=B(()=>Mi.value??zl.value??""),lb=B(()=>!!Mi.value);function Hl(){return{preferredWorkDir:Mi,serverWorkDir:zl,displayWorkDir:ab,hasPreference:lb,setPreferredWorkDir:rb,fetchServerWorkDir:ib}}function Ka(e){const t=e.replace(/[\\/]+$/,"");return t.split(/[\\/]/).filter(Boolean).at(-1)??t??e}const ub=["type","disabled"],cb=Ie({__name:"Button",props:{variant:{default:"primary"},size:{default:"md"},disabled:{type:Boolean},type:{default:"button"}},setup(e){return(t,n)=>(m(),v("button",{class:ue(["ui-btn",[`ui-btn--${e.variant}`,`ui-btn--${e.size}`]]),type:e.type,disabled:e.disabled},[Co(t.$slots,"default",{},void 0)],10,ub))}}),Te=(e,t)=>{const n=e.__vccOpts||e;for(const[s,o]of t)n[s]=o;return n},Ht=Te(cb,[["__scopeId","data-v-293d37e0"]]),db={key:0,class:"approval-card"},fb={class:"approval-header"},hb={class:"approval-title"},pb={class:"tool-name"},gb={class:"action-summary"},mb={key:0,class:"approval-count"},vb={key:0,class:"approval-source"},yb={key:1,class:"approval-summary"},bb={key:2,class:"approval-reasons"},kb={class:"approval-action"},wb={key:3,class:"feedback-area"},Sb={class:"approval-buttons"},_b={key:1,class:"busy-indicator","aria-label":"处理中"},$b=Ie({__name:"ApprovalCard",props:{approvals:{}},emits:["resolve"],setup(e,{emit:t}){const n=e,s=t,o=G(!1),r=G(!1),i=G(""),a=G(new Set),l=B(()=>n.approvals[0]),u=["once","session"],c=B(()=>{var k;return(((k=l.value)==null?void 0:k.grantOptions)??u).includes("session")});Se(()=>n.approvals.map(k=>k.id).join(","),()=>{r.value=!1,i.value="";const k=new Set(n.approvals.map(y=>y.id));a.value=new Set([...a.value].filter(y=>k.has(y)))});function d(k){return typeof k.display=="string"?k.display:k.display&&typeof k.display=="object"&&"description"in k.display?String(k.display.description??""):k.action??"执行该操作"}function f(k){const y=k.sourceAgentId,_=k.sourceAgentName,N=k.sourceToolName??k.toolName,D=_??y??"",E=y!==void 0&&y!==""&&y!==D?`${D}(${y})`:D,A=N!==void 0&&N!==""?` · ${N}`:"";return`来源:${E}${A}`}function p(k){return k!==void 0&&(k.sourceAgentId!==void 0||k.sourceAgentName!==void 0)}function g(k){return a.value.has(k)}function b(k,y,_){const N=l.value;!N||g(N.id)||(a.value=new Set([...a.value,N.id]),s("resolve",N.id,k,y,_))}function S(){const k=i.value.trim();k&&b("rejected",k)}function w(k){if(!l.value||o.value)return;const _=k.target;if(_&&(_.tagName==="TEXTAREA"||_.tagName==="INPUT")){r.value&&k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),S());return}switch(k.key){case"1":k.preventDefault(),b("approved",void 0,"once");break;case"2":if(!c.value)break;k.preventDefault(),b("approved",void 0,"session");break;case"3":k.preventDefault(),b("rejected");break;case"4":k.preventDefault(),r.value=!r.value;break}}return et(()=>window.addEventListener("keydown",w)),st(()=>window.removeEventListener("keydown",w)),(k,y)=>e.approvals.length?(m(),v("div",db,[o.value?(m(),v("button",{key:0,class:"approval-minibar",onClick:y[0]||(y[0]=_=>o.value=!1)}," ⚠ "+C(e.approvals.length)+" 个待审批请求 — 点击展开 ",1)):l.value?(m(),v(te,{key:1},[h("div",fb,[y[7]||(y[7]=h("span",{class:"approval-icon"},"⚠",-1)),h("span",hb,[h("span",pb,C(l.value.toolName),1),h("span",gb,C(d(l.value)),1)]),e.approvals.length>1?(m(),v("span",mb,"+"+C(e.approvals.length-1),1)):F("",!0),h("button",{class:"icon-btn",title:"最小化","aria-label":"最小化",onClick:y[1]||(y[1]=_=>o.value=!0)},"—")]),p(l.value)?(m(),v("p",vb,C(f(l.value)),1)):F("",!0),l.value.requestSummary?(m(),v("p",yb,C(l.value.requestSummary),1)):F("",!0),l.value.reasons&&l.value.reasons.length?(m(),v("ul",bb,[(m(!0),v(te,null,Ce(l.value.reasons,(_,N)=>(m(),v("li",{key:N},C(_),1))),128))])):F("",!0),h("pre",kb,C(d(l.value)),1),r.value?(m(),v("div",wb,[Ze(h("textarea",{"onUpdate:modelValue":y[2]||(y[2]=_=>i.value=_),class:"feedback-input",rows:"2",name:"approval-feedback","aria-label":"拒绝反馈",placeholder:"输入反馈,Enter 提交(将作为拒绝原因反馈给 Agent)"},null,512),[[it,i.value]])])):F("",!0),h("div",Sb,[X(Ht,{variant:"primary",disabled:g(l.value.id),onClick:y[3]||(y[3]=_=>b("approved",void 0,"once"))},{default:ot(()=>[...y[8]||(y[8]=[h("kbd",null,"1",-1),Ae(" 批准 ",-1)])]),_:1},8,["disabled"]),c.value?(m(),De(Ht,{key:0,variant:"secondary",disabled:g(l.value.id),onClick:y[4]||(y[4]=_=>b("approved",void 0,"session"))},{default:ot(()=>[...y[9]||(y[9]=[h("kbd",null,"2",-1),Ae(" 会话批准 ",-1)])]),_:1},8,["disabled"])):F("",!0),X(Ht,{variant:"danger",disabled:g(l.value.id),onClick:y[5]||(y[5]=_=>b("rejected"))},{default:ot(()=>[...y[10]||(y[10]=[h("kbd",null,"3",-1),Ae(" 拒绝 ",-1)])]),_:1},8,["disabled"]),X(Ht,{variant:"secondary",class:ue({"feedback-active":r.value}),disabled:g(l.value.id),onClick:y[6]||(y[6]=_=>r.value=!r.value)},{default:ot(()=>[...y[11]||(y[11]=[h("kbd",null,"4",-1),Ae(" 反馈 ",-1)])]),_:1},8,["class","disabled"]),g(l.value.id)?(m(),v("span",_b,[...y[12]||(y[12]=[h("span",{class:"spinner"},null,-1),Ae(" 处理中… ",-1)])])):F("",!0)])],64)):F("",!0)])):F("",!0)}}),Cb=Te($b,[["__scopeId","data-v-ec91b005"]]);function xb(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 $c(e){let t=0;for(let n=0;n<e.length;n++)e[n]==="/"&&t++;return t}function Cc(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 Ib(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:Cc(t,n)&&(s=10);else{const o=n.lastIndexOf("/"),r=o===-1?n:n.slice(o+1);r===t?s=100:r.startsWith(t)?s=80:r.includes(t)?s=50:n.includes(t)?s=30:Cc(t,n)&&(s=10)}return e.isDir&&s>0&&(s+=10),s}const Tb=20;function vh(e,t,n=Tb){const s=t.toLowerCase();if(!s)return e.slice(0,n);const o=[];for(const r of e){const i=Ib(r,s);i>0&&o.push({entry:r,score:i})}return o.sort((r,i)=>i.score-r.score||$c(r.entry.path)-$c(i.entry.path)||r.entry.path.localeCompare(i.entry.path)),o.slice(0,n).map(r=>r.entry)}function Eb(e,t){const n=t?`${e}/`:e,s=n.includes(" ");if(t){const r=s?`@"${n}"`:`@${n}`;return{text:r,cursorOffset:s?r.length-1:r.length}}const o=s?`@"${n}" `:`@${n} `;return{text:o,cursorOffset:o.length}}const Ab="/api/v1/files",Mb=3e4,Rb=200,os=new Map,_r=new Map;async function Wl(e){const t=os.get(e);if(t){if(Date.now()-t.at<Mb)return t.entries;os.delete(e)}const n=_r.get(e);if(n)return n;const s=(async()=>{try{const o=await fetch(`${Ab}/list?path=${encodeURIComponent(e)}`);if(!o.ok)return null;const r=await o.json();if(r.entries)for(os.set(e,{entries:r.entries,at:Date.now()});os.size>Rb;){const i=os.keys().next().value;if(i===void 0)break;os.delete(i)}return r.entries??null}catch{return null}finally{_r.delete(e)}})();return _r.set(e,s),s}function Pb(e){os.delete(e),_r.delete(e)}function Lb(e,t){const n=e.replace(/\/+$/,""),s=n.split("/").filter(Boolean),o=[...s];for(const i of t.split("/"))if(!(!i||i===".")){if(i===".."){if(o.length<=s.length)return null;o.pop();continue}o.push(i)}const r=`/${o.join("/")}`;return r===n||r.startsWith(`${n}/`)?r:null}function Db(e,t,n){const s=G(null),o=G([]),r=G(!1),i=G(!1),a=G(0),l=G(!1),u=G(null),c=G("");let d=null;function f(){d||(d=(async()=>{var A;try{const T=await fetch("/api/v1/files/root"),Z=T.ok?await T.json():{};c.value=((A=Z.roots)==null?void 0:A[0])??""}catch{c.value=""}y()})())}const p=B(()=>{const A=u.value;if(!A)return[];const T=A.query.lastIndexOf("/"),Z=A.query.slice(T+1);return vh(o.value,Z)}),g=B(()=>u.value!==null&&!l.value&&(r.value||p.value.length>0));function b(A){const T=A.lastIndexOf("/");return T===-1?{dirRel:"",tail:A}:{dirRel:A.slice(0,T),tail:A.slice(T+1)}}let S=!1,w=0;async function k(A,T){const Z=++w;r.value=!0;try{const W=await Wl(A);if(W===null)throw new Error("listing failed");if(Z!==w)return;const j=T?`${T.replace(/\/+$/,"")}/`:"";o.value=W.map(ne=>({path:`${j}${ne.name}`,isDir:ne.type==="dir"})),i.value=!1}catch{if(Z!==w)return;o.value=[],i.value=!0,s.value=null}finally{Z===w&&(r.value=!1)}}function y(){var M;if(S)return;const A=t.value;if(A&&A.value!==e.value){u.value=null;return}let T=(M=n.value)==null?void 0:M.trim();if(T||(f(),T=c.value),!A||!T){u.value=null;return}const Z=A.selectionStart??A.value.length,W=xb(A.value.slice(0,Z));if(!W){u.value=null,l.value=!1;return}const j=u.value;(!j||j.start!==W.start||j.query!==W.query)&&(l.value=!1),u.value=W,a.value=0;const{dirRel:ne}=b(W.query),I=Lb(T,ne);if(I===null){s.value=null,o.value=[],i.value=!0;return}s.value!==I&&(s.value=I,k(I,ne))}function _(A){const T=p.value.length;T>0&&(a.value=(a.value+A+T)%T)}function N(A){const T=u.value,Z=A??p.value[a.value];if(!T||!Z)return!1;const W=t.value;if(!W)return!1;const j=W.selectionStart??W.value.length,ne=Eb(Z.path,Z.isDir),I=e.value.slice(0,T.start),M=e.value.slice(j);e.value=I+ne.text+M,S=!0;const V=()=>{const ie=T.start+ne.cursorOffset;W.focus(),W.setSelectionRange(ie,ie),S=!1,y()};return typeof requestAnimationFrame=="function"?requestAnimationFrame(V):Promise.resolve().then(V),!0}function D(){l.value=!0}function E(){u.value=null,l.value=!1,a.value=0}return{visible:g,suggestions:p,index:a,dirLoading:r,dirMissing:i,refresh:y,move:_,confirm:N,dismiss:D,reset:E}}const yh=50;function Nb(e,t=yh){const n=new Set,s=[];for(let o=e.length-1;o>=0&&s.length<t;o-=1){const r=e[o];if(!r||r.role!=="user"||r.local)continue;const i=(r.content??"").trim();!i||n.has(i)||(n.add(i),s.push(i))}return s}function Ob(e,t,n=yh){const s=new Set,o=[],r=i=>{const a=i.trim();!a||s.has(a)||(s.add(a),o.push(a))};for(const i of t)r(i);for(let i=e.length-1;i>=0;i-=1){const a=e[i];a!==void 0&&r(a)}return o.slice(0,n).toReversed()}function Za(e,t){return[{title:t,entries:e}]}function Gb(){if(typeof navigator>"u")return"Ctrl";const e=`${navigator.platform??""} ${navigator.userAgent??""}`;return/Mac|iPhone|iPad|iPod/.test(e)?"⌘":"Ctrl"}const $r=Gb(),Bb=["width","height"],Fb={key:0,d:"M4 7h16M4 12h16M4 17h16"},Ub={key:1,d:"M12 5v14M5 12h14"},jb={key:5,d:"M4 6h16M7 12h10M10 18h4"},zb={key:6,d:"M12 3v12m0 0 4-4m-4 4-4-4M5 20h14"},Hb={key:7,d:"M4 7h16M9 7V4h6v3m3 0-1 13H7L6 7m4 4v5m4-5v5"},Wb={key:8,d:"M3 12h4l2-7 4 14 2-7h6"},qb={key:10,d:"m15 18-6-6 6-6"},Vb={key:11,d:"m9 18 6-6-6-6"},Kb={key:12,d:"m6 9 6 6 6-6"},Zb={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"},Yb={key:18,d:"M5 9a11 11 0 0 1 14 0M8.5 12.5a6 6 0 0 1 7 0M12 17h.01"},Xb={key:19,d:"M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L8 18l-4 1 1-4Z"},Jb={key:20,d:"M12 16V4m0 0-4 4m4-4 4 4M5 20h14"},Qb={key:21,d:"m15 4 5 5M17.5 6.5 10 14m-2-2 4 4-3 4H3l1-6Z"},ek={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"},tk={key:24,d:"m22 2-7 20-4-9-9-4ZM22 2 11 13"},nk={key:25,x:"6",y:"6",width:"12",height:"12",rx:"2"},sk={key:26,d:"m8 3 4 4 4-4M8 21l4-4 4 4M12 7v10"},ok={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"},rk={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"},ik={key:31,d:"M20 13 13 20l-9-9V4h7ZM8.5 8.5h.01"},ak={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"},lk={key:34,d:"M3 6h7l2 2h9v11H3Z"},uk={key:35,d:"m5 12 4 4L19 6"},ck={key:39,d:"M21 12a9 9 0 1 1-2.6-6.4M21 3v6h-6"},dk={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"},fk={key:47,d:"M12 19V5m0 0-6 6m6-6 6 6"},hk={key:48,d:"M18 6 6 18M6 6l12 12"},pk={key:51,d:"M9 4H4v5M15 4h5v5M9 20H4v-5M15 20h5v-5"},gk={key:52,d:"M4 9h5V4M20 9h-5V4M4 15h5v5M20 15h-5v5"},mk={key:56,d:"M4 20V10M10 20V4M16 20v-7M21 20H3"},vk=Ie({__name:"SvgIcon",props:{name:{},size:{default:20}},setup(e){return(t,n)=>(m(),v("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"?(m(),v("path",Fb)):e.name==="plus"?(m(),v("path",Ub)):e.name==="panel-left"?(m(),v(te,{key:2},[n[0]||(n[0]=h("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"},null,-1)),n[1]||(n[1]=h("path",{d:"M9 4v16"},null,-1))],64)):e.name==="panel-right"?(m(),v(te,{key:3},[n[2]||(n[2]=h("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"},null,-1)),n[3]||(n[3]=h("path",{d:"M15 4v16"},null,-1))],64)):e.name==="search"?(m(),v(te,{key:4},[n[4]||(n[4]=h("circle",{cx:"11",cy:"11",r:"7"},null,-1)),n[5]||(n[5]=h("path",{d:"m20 20-4-4"},null,-1))],64)):e.name==="filter"?(m(),v("path",jb)):e.name==="download"?(m(),v("path",zb)):e.name==="trash"?(m(),v("path",Hb)):e.name==="activity"?(m(),v("path",Wb)):e.name==="help"?(m(),v(te,{key:9},[n[6]||(n[6]=h("circle",{cx:"12",cy:"12",r:"9"},null,-1)),n[7]||(n[7]=h("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"?(m(),v("path",qb)):e.name==="chevron-right"?(m(),v("path",Vb)):e.name==="chevron-down"?(m(),v("path",Kb)):e.name==="bot"?(m(),v(te,{key:13},[n[8]||(n[8]=h("rect",{x:"4",y:"7",width:"16",height:"12",rx:"3"},null,-1)),n[9]||(n[9]=h("path",{d:"M12 3v4M8 12h.01M16 12h.01M9 16h6"},null,-1))],64)):e.name==="git-branch"?(m(),v(te,{key:14},[n[10]||(n[10]=h("circle",{cx:"6",cy:"5",r:"2"},null,-1)),n[11]||(n[11]=h("circle",{cx:"18",cy:"7",r:"2"},null,-1)),n[12]||(n[12]=h("circle",{cx:"6",cy:"19",r:"2"},null,-1)),n[13]||(n[13]=h("path",{d:"M6 7v10M8 10c5 0 3-3 8-3"},null,-1))],64)):e.name==="sun"?(m(),v(te,{key:15},[n[14]||(n[14]=h("circle",{cx:"12",cy:"12",r:"4"},null,-1)),n[15]||(n[15]=h("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"?(m(),v("path",Zb)):e.name==="monitor"?(m(),v(te,{key:17},[n[16]||(n[16]=h("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"},null,-1)),n[17]||(n[17]=h("path",{d:"M8 21h8M12 17v4"},null,-1))],64)):e.name==="wifi"?(m(),v("path",Yb)):e.name==="edit"?(m(),v("path",Xb)):e.name==="upload"?(m(),v("path",Jb)):e.name==="broom"?(m(),v("path",Qb)):e.name==="command"?(m(),v("path",ek)):e.name==="at"?(m(),v(te,{key:23},[n[18]||(n[18]=h("circle",{cx:"12",cy:"12",r:"4"},null,-1)),n[19]||(n[19]=h("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"?(m(),v("path",tk)):e.name==="stop"?(m(),v("rect",nk)):e.name==="compact"?(m(),v("path",sk)):e.name==="brain"?(m(),v("path",ok)):e.name==="clipboard"?(m(),v(te,{key:28},[n[20]||(n[20]=h("rect",{x:"5",y:"4",width:"14",height:"17",rx:"2"},null,-1)),n[21]||(n[21]=h("path",{d:"M9 4V2h6v2M9 10h6M9 14h6"},null,-1))],64)):e.name==="fork"?(m(),v(te,{key:29},[n[22]||(n[22]=h("circle",{cx:"6",cy:"4",r:"2"},null,-1)),n[23]||(n[23]=h("circle",{cx:"18",cy:"6",r:"2"},null,-1)),n[24]||(n[24]=h("circle",{cx:"6",cy:"20",r:"2"},null,-1)),n[25]||(n[25]=h("path",{d:"M6 6v12M8 10c6 0 4-4 8-4"},null,-1))],64)):e.name==="message-circle"?(m(),v("path",rk)):e.name==="tag"?(m(),v("path",ik)):e.name==="sparkles"?(m(),v("path",ak)):e.name==="terminal"?(m(),v(te,{key:33},[n[26]||(n[26]=h("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"},null,-1)),n[27]||(n[27]=h("path",{d:"m7 9 3 3-3 3m5 0h5"},null,-1))],64)):e.name==="folder"?(m(),v("path",lk)):e.name==="check"?(m(),v("path",uk)):e.name==="speaker"?(m(),v(te,{key:36},[n[28]||(n[28]=h("path",{d:"M11 5 6 9H3v6h3l5 4V5z"},null,-1)),n[29]||(n[29]=h("path",{d:"M15.5 8.5a5 5 0 0 1 0 7"},null,-1)),n[30]||(n[30]=h("path",{d:"M18 6a8.5 8.5 0 0 1 0 12"},null,-1))],64)):e.name==="speaker-off"?(m(),v(te,{key:37},[n[31]||(n[31]=h("path",{d:"M11 5 6 9H3v6h3l5 4V5z"},null,-1)),n[32]||(n[32]=h("path",{d:"m16 9 5 6M21 9l-5 6"},null,-1))],64)):e.name==="copy"?(m(),v(te,{key:38},[n[33]||(n[33]=h("rect",{x:"8",y:"8",width:"12",height:"12",rx:"2"},null,-1)),n[34]||(n[34]=h("path",{d:"M16 8V4H4v12h4"},null,-1))],64)):e.name==="refresh"?(m(),v("path",ck)):e.name==="target"?(m(),v(te,{key:40},[n[35]||(n[35]=h("circle",{cx:"12",cy:"12",r:"9"},null,-1)),n[36]||(n[36]=h("circle",{cx:"12",cy:"12",r:"5"},null,-1)),n[37]||(n[37]=h("circle",{cx:"12",cy:"12",r:"1"},null,-1))],64)):e.name==="settings"?(m(),v(te,{key:41},[n[38]||(n[38]=h("circle",{cx:"12",cy:"12",r:"3"},null,-1)),n[39]||(n[39]=h("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"?(m(),v(te,{key:42},[n[40]||(n[40]=h("path",{d:"M3 10.5 12 3l9 7.5"},null,-1)),n[41]||(n[41]=h("path",{d:"M5 9.5V21h14V9.5"},null,-1))],64)):e.name==="bell"?(m(),v(te,{key:43},[n[42]||(n[42]=h("path",{d:"M6 9a6 6 0 1 1 12 0c0 5 2 6 2 6H4s2-1 2-6"},null,-1)),n[43]||(n[43]=h("path",{d:"M10 19a2 2 0 0 0 4 0"},null,-1))],64)):e.name==="book"?(m(),v(te,{key:44},[n[44]||(n[44]=h("path",{d:"M4 5a2 2 0 0 1 2-2h13v18H6a2 2 0 0 0-2 2Z"},null,-1)),n[45]||(n[45]=h("path",{d:"M6 3v18"},null,-1))],64)):e.name==="layers"?(m(),v(te,{key:45},[n[46]||(n[46]=h("path",{d:"m12 3 9 5-9 5-9-5Z"},null,-1)),n[47]||(n[47]=h("path",{d:"m3 13 9 5 9-5"},null,-1))],64)):e.name==="wrench"?(m(),v("path",dk)):e.name==="arrow-up"?(m(),v("path",fk)):e.name==="x"?(m(),v("path",hk)):e.name==="file"?(m(),v(te,{key:49},[n[48]||(n[48]=h("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]=h("path",{d:"M14 2v6h6"},null,-1))],64)):e.name==="user"?(m(),v(te,{key:50},[n[50]||(n[50]=h("circle",{cx:"12",cy:"8",r:"3.5"},null,-1)),n[51]||(n[51]=h("path",{d:"M5 20a7 7 0 0 1 14 0"},null,-1))],64)):e.name==="expand"?(m(),v("path",pk)):e.name==="minimize"?(m(),v("path",gk)):e.name==="shield"?(m(),v(te,{key:53},[n[52]||(n[52]=h("path",{d:"M12 3 5 6v5.5c0 4.2 2.9 7.6 7 9.5 4.1-1.9 7-5.3 7-9.5V6Z"},null,-1)),n[53]||(n[53]=h("path",{d:"M9.5 12.2 11.3 14l3.4-3.6"},null,-1))],64)):e.name==="queue"?(m(),v(te,{key:54},[n[54]||(n[54]=h("path",{d:"M4 7h11M4 12h11M4 17h7"},null,-1)),n[55]||(n[55]=h("path",{d:"M17.5 15.5 20 18l2.5-2.5M20 18v-6"},null,-1))],64)):e.name==="more"?(m(),v(te,{key:55},[n[56]||(n[56]=h("circle",{cx:"5.5",cy:"12",r:"1.4"},null,-1)),n[57]||(n[57]=h("circle",{cx:"12",cy:"12",r:"1.4"},null,-1)),n[58]||(n[58]=h("circle",{cx:"18.5",cy:"12",r:"1.4"},null,-1))],64)):e.name==="bar-chart"?(m(),v("path",mk)):F("",!0)],8,Bb))}}),ce=Te(vk,[["__scopeId","data-v-421b9da7"]]),yk={class:"at-menu",role:"listbox","aria-label":"文件提及"},bk={key:0,class:"at-status"},kk={key:1,class:"at-status"},wk=["data-active","aria-selected","onClick","onMousemove"],Sk={class:"at-item-name"},_k={key:0,class:"at-item-dir"},$k={class:"at-hints"},Ck={class:"at-hint"},xk=["title"],Ik=Ie({__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=G(null);Se(()=>n.activeIndex,async()=>{var u;await Fe();const l=(u=o.value)==null?void 0:u.querySelector('[data-active="true"]');l==null||l.scrollIntoView({block:"nearest"})});const r=l=>l.split("/").pop()||l;function i(l){return r(l.path)}function a(l){const u=l.path.lastIndexOf("/");return u===-1?"":l.path.slice(0,u)}return(l,u)=>{var c;return m(),v("div",yk,[e.loading&&e.suggestions.length===0?(m(),v("div",bk,"加载文件列表…")):e.suggestions.length===0?(m(),v("div",kk,"无匹配文件")):(m(),v("ul",{key:2,ref_key:"listRef",ref:o,class:"at-list"},[(m(!0),v(te,null,Ce(e.suggestions,(d,f)=>(m(),v("li",{key:d.path},[h("button",{class:ue(["at-item",{selected:f===e.activeIndex}]),"data-active":f===e.activeIndex?"true":void 0,role:"option","aria-selected":f===e.activeIndex,onClick:p=>s("select",d),onMousemove:p=>s("hover",f)},[h("span",{class:ue(["at-item-icon",{"is-dir":d.isDir}])},[X(ce,{name:d.isDir?"folder":"file",size:14},null,8,["name"])],2),h("span",Sk,C(i(d)),1),a(d)?(m(),v("span",_k,C(a(d)),1)):F("",!0)],42,wk)]))),128))],512)),h("div",$k,[u[1]||(u[1]=h("span",{class:"at-hint"},[h("kbd",null,"↑↓"),Ae("选择")],-1)),h("span",Ck,[u[0]||(u[0]=h("kbd",null,"Tab/Enter",-1)),Ae(C((c=e.suggestions[e.activeIndex])!=null&&c.isDir?"进入目录":"插入引用"),1)]),u[2]||(u[2]=h("span",{class:"at-hint"},[h("kbd",null,"Esc"),Ae("关闭")],-1)),e.workDir?(m(),v("span",{key:0,class:"at-root",title:e.workDir},"根:"+C(r(e.workDir)),9,xk)):F("",!0)])])}}}),Tk=Te(Ik,[["__scopeId","data-v-9c8e827b"]]),Ek=["title","aria-label"],Ak=["width","height","viewBox"],Mk=["cx","cy","r"],Rk=["cx","cy","r","stroke-dasharray","stroke-dashoffset","transform"],oa=2,Pk=Ie({__name:"ContextRing",props:{usage:{default:void 0},size:{default:16}},setup(e){iv(l=>({v1d95ffa8:a.value}));const t=e,n=B(()=>{if(t.usage===void 0||Number.isNaN(t.usage))return 0;const l=t.usage>1?t.usage/100:t.usage;return Math.min(1,Math.max(0,l))}),s=B(()=>Math.round(n.value*100)),o=B(()=>(t.size-oa)/2),r=B(()=>2*Math.PI*o.value),i=B(()=>r.value*(1-n.value)),a=B(()=>n.value>=.9?"var(--color-danger)":n.value>=.7?"var(--color-warning)":"var(--color-accent)");return(l,u)=>(m(),v("span",{class:"context-ring",role:"img",title:`上下文占用 ${s.value}%`,"aria-label":`上下文占用 ${s.value}%`},[(m(),v("svg",{width:e.size,height:e.size,viewBox:`0 0 ${e.size} ${e.size}`},[h("circle",{class:"ring-track",cx:e.size/2,cy:e.size/2,r:o.value,"stroke-width":oa,fill:"none"},null,8,Mk),h("circle",{class:"ring-value",cx:e.size/2,cy:e.size/2,r:o.value,"stroke-width":oa,fill:"none","stroke-linecap":"round","stroke-dasharray":r.value,"stroke-dashoffset":i.value,transform:`rotate(-90 ${e.size/2} ${e.size/2})`},null,8,Rk)],8,Ak))],8,Ek))}}),bh=Te(Pk,[["__scopeId","data-v-3ffc343b"]]),Lk=["data-goal-status"],Dk={class:"goal-status"},Nk=["title"],Ok={class:"goal-metric",title:"已用轮次"},Gk={class:"goal-actions"},Bk=["disabled","title"],Fk=["disabled","title"],Uk=["disabled","title"],jk=Ie({__name:"GoalBar",props:{goal:{},disabled:{type:Boolean,default:!1},disabledReason:{default:""},busy:{type:Boolean,default:!1},pending:{type:Boolean,default:!1}},emits:["pause","resume","cancel","edit"],setup(e,{emit:t}){const n=e,s=t,o={active:"进行中",paused:"已暂停",blocked:"受阻",complete:"已完成"},r=B(()=>!!n.goal&&n.goal.status!=="complete"),i=B(()=>{var c;return((c=n.goal)==null?void 0:c.status)==="active"}),a=B(()=>{var c;return o[((c=n.goal)==null?void 0:c.status)??""]??"目标"}),l=B(()=>n.disabled?n.disabledReason||"当前不可操作":""),u=B(()=>{var f;const c=n.goal;if(!c)return"";const d=(f=c.budget)==null?void 0:f.turnBudget;return d?`${c.turnsUsed}/${d} 轮`:`${c.turnsUsed} 轮`});return(c,d)=>r.value&&e.goal?(m(),v("div",{key:0,class:"goal-bar","data-goal-bar":"","data-goal-status":e.goal.status},[X(ce,{name:"target",size:14,class:"goal-icon"}),h("span",Dk,C(a.value),1),h("span",{class:"goal-objective",title:e.goal.objective},C(e.goal.objective),9,Nk),h("span",Ok,C(u.value),1),h("div",Gk,[h("button",{class:"goal-action",type:"button",title:"编辑目标与预算(在右栏 Goal 面板)","aria-label":"编辑目标",onClick:d[0]||(d[0]=f=>s("edit"))},[X(ce,{name:"edit",size:13}),d[4]||(d[4]=h("span",null,"编辑",-1))]),i.value?(m(),v("button",{key:0,class:"goal-action",type:"button",disabled:e.disabled||e.busy||e.pending,title:e.disabled||e.pending?l.value:"暂停目标执行","aria-label":"暂停目标",onClick:d[1]||(d[1]=f=>s("pause"))},[...d[5]||(d[5]=[h("span",null,"暂停",-1)])],8,Bk)):(m(),v("button",{key:1,class:"goal-action",type:"button",disabled:e.disabled||e.busy||e.pending,title:e.disabled||e.pending?l.value:"继续目标执行","aria-label":"继续目标",onClick:d[2]||(d[2]=f=>s("resume"))},[...d[6]||(d[6]=[h("span",null,"继续",-1)])],8,Fk)),h("button",{class:"goal-action is-danger",type:"button",disabled:e.disabled||e.pending,title:e.disabled?l.value:"取消目标(可在右栏 Goal 面板查看结果)","aria-label":"取消目标",onClick:d[3]||(d[3]=f=>s("cancel"))}," 清除 ",8,Uk)])],8,Lk)):F("",!0)}}),zk=Te(jk,[["__scopeId","data-v-c7806e90"]]),Hk={class:"history-menu",role:"listbox","aria-label":"输入历史"},Wk={class:"history-header",title:"输入历史"},qk=["data-active","aria-selected","onClick","onMousemove"],Vk={class:"history-item-index"},Kk={class:"history-item-text"},Zk=Ie({__name:"HistoryMenu",props:{items:{},activeIndex:{}},emits:["apply","hover"],setup(e,{emit:t}){const n=e,s=t,o=G(null);return Se(()=>n.activeIndex,async()=>{var i;await Fe();const r=(i=o.value)==null?void 0:i.querySelector('[data-active="true"]');r==null||r.scrollIntoView({block:"nearest"})}),et(async()=>{var i;await Fe();const r=(i=o.value)==null?void 0:i.querySelector('[data-active="true"]');r==null||r.scrollIntoView({block:"nearest"})}),(r,i)=>(m(),v("div",Hk,[h("div",Wk,[X(ce,{name:"refresh",size:14}),i[0]||(i[0]=h("span",{class:"history-hints"},[h("span",{class:"history-hint"},[h("kbd",null,"↑↓"),Ae("选择")]),h("span",{class:"history-hint"},[h("kbd",null,"Tab/Enter"),Ae("填入")]),h("span",{class:"history-hint"},[h("kbd",null,"Esc"),Ae("关闭")])],-1))]),h("ul",{ref_key:"listRef",ref:o,class:"history-list"},[(m(!0),v(te,null,Ce(e.items,(a,l)=>(m(),v("li",{key:`${l}:${a}`},[h("button",{class:ue(["history-item",{selected:l===e.activeIndex}]),"data-active":l===e.activeIndex?"true":void 0,role:"option","aria-selected":l===e.activeIndex,onClick:u=>s("apply",a),onMousemove:u=>s("hover",l)},[h("span",Vk,C(l+1),1),h("span",Kk,C(a),1)],42,qk)]))),128))],512)]))}}),Yk=Te(Zk,[["__scopeId","data-v-41efc12f"]]);function ql(e,t){const n=t.gap??6,s=t.edge??8,o={position:"fixed",maxWidth:`${t.maxWidth}px`};return t.placement==="top"?o.bottom=`${window.innerHeight-e.top+n}px`:o.top=`${e.bottom+n}px`,t.align==="right"?o.right=`${Math.max(s,window.innerWidth-e.right)}px`:o.left=`${Math.min(Math.max(s,e.left),Math.max(s,window.innerWidth-t.maxWidth-s))}px`,o}const Xk=["aria-label"],Jk={key:0,class:"menu-heading"},Qk={key:0,class:"menu-group-title"},e1=["disabled","title","aria-current","onClick"],t1={class:"entry-label"};let Ls=null;function n1(e){Ls==null||Ls(),Ls=e}function xc(e){Ls===e&&(Ls=null)}const s1=Ie({__name:"MenuPopover",props:{label:{},groups:{},open:{type:Boolean},align:{default:"right"},placement:{default:"top"},maxWidth:{default:300},heading:{default:void 0}},emits:["select","update:open"],setup(e,{emit:t}){const n=e,s=t,o=G(null),r=G({});function i(){n.open&&s("update:open",!1)}Se(()=>n.open,d=>{d?(n1(i),a(),document.addEventListener("scroll",c,!0),window.addEventListener("resize",c)):(xc(i),document.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c))});function a(){const d=o.value;d&&(r.value=ql(d.getBoundingClientRect(),{placement:n.placement,align:n.align,maxWidth:n.maxWidth}))}function l(d){const f=d.target;if(!(f instanceof Node))return;const p=o.value;p!=null&&p.contains(f)||f instanceof Element&&f.closest("[data-menu-popover]")||i()}function u(d){d.key==="Escape"&&n.open&&(d.stopPropagation(),i())}function c(){i()}return et(()=>{document.addEventListener("pointerdown",l,!0),window.addEventListener("keydown",u,!0),n.open&&(a(),document.addEventListener("scroll",c,!0),window.addEventListener("resize",c))}),st(()=>{xc(i),document.removeEventListener("pointerdown",l,!0),window.removeEventListener("keydown",u,!0),document.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}),(d,f)=>(m(),v("span",{ref_key:"rootRef",ref:o,class:"menu-root"},[Co(d.$slots,"default",{},void 0),(m(),De(Js,{to:"body"},[e.open?(m(),v("div",{key:0,class:ue(["menu-popover",[`is-align-${e.align}`,`is-placement-${e.placement}`]]),style:bt(r.value),role:"menu","aria-label":e.label,"data-menu-popover":""},[e.heading?(m(),v("p",Jk,C(e.heading),1)):F("",!0),(m(!0),v(te,null,Ce(e.groups,(p,g)=>(m(),v(te,{key:`g${g}`},[p.title?(m(),v("p",Qk,C(p.title),1)):F("",!0),(m(!0),v(te,null,Ce(p.entries,b=>(m(),v("button",{key:b.key,class:ue(["menu-entry",{"is-active":b.checked,"is-danger":b.tone==="danger"}]),role:"menuitem",type:"button",disabled:b.disabled,title:b.title??b.label,"aria-current":b.checked?"true":void 0,onClick:S=>s("select",b.key)},[b.icon?(m(),De(ce,{key:0,name:b.icon,size:14},null,8,["name"])):F("",!0),h("span",t1,C(b.label),1),b.checked?(m(),De(ce,{key:1,name:"check",size:14,class:"entry-check"})):F("",!0)],10,e1))),128))],64))),128))],14,Xk)):F("",!0)]))],512))}}),Ya=Te(s1,[["__scopeId","data-v-e68e06d8"]]),o1=["onKeydown"],r1={key:0,class:"picker-empty"},i1={class:"picker-group-title"},a1=["onClick"],l1={class:"row-main"},u1={class:"row-name"},c1={class:"row-alias"},d1={class:"row-meta"},f1={key:0,class:"row-check"},h1={class:"picker-thinking"},p1={class:"thinking-options"},g1=["onClick"],m1=Ie({__name:"ModelPicker",props:{models:{},currentModel:{},currentThinking:{},open:{type:Boolean,default:!0}},emits:["apply-model","apply-thinking","close","update:open"],setup(e,{emit:t}){const n=e,s=t,o=["off","low","medium","high"],r={off:"关闭",low:"低",medium:"中",high:"高",xhigh:"超高",max:"最大"},i=G(""),a=G(null),l=B(()=>{const I=i.value.trim().toLowerCase();return I?n.models.filter(M=>M.alias.toLowerCase().includes(I)||M.provider.toLowerCase().includes(I)||(M.displayName??"").toLowerCase().includes(I)):n.models}),u=B(()=>{const I=new Map;for(const M of l.value){const V=I.get(M.provider)??[];V.push(M),I.set(M.provider,V)}return[...I.entries()].map(([M,V])=>({provider:M,models:V}))}),c=B(()=>n.models.find(I=>I.alias===n.currentModel)),d=B(()=>{var I;return((I=c.value)==null?void 0:I.thinkingLevels)??o});function f(I){return r[I]??I}function p(I){return I>=1e3?`${Math.round(I/1e3)}k`:String(I)}function g(I){return I.displayName??I.model}const b=G(null),S=G(null),w=G({});function k(){s("close"),s("update:open",!1)}function y(){var ae;const I=b.value;if(!I)return;const V=(((ae=I.closest(".chip-slot"))==null?void 0:ae.querySelector(".model-select"))??document.querySelector(".model-select")??I).getBoundingClientRect(),ie=6,me=8,_e=ql(V,{placement:"top",align:"right",maxWidth:Math.min(320,window.innerWidth-me*2),gap:ie,edge:me}),he=Math.max(240,V.top-ie-me);_e.maxHeight=`min(60vh, ${he}px)`,w.value=_e}function _(I){const M=I.target;M instanceof Element&&M.closest(".model-select")||S.value&&!S.value.contains(M)&&k()}function N(I){var V;const M=I.target;M instanceof Node&&((V=S.value)!=null&&V.contains(M))||k()}function D(){document.addEventListener("scroll",N,!0),window.addEventListener("resize",N)}function E(){document.removeEventListener("scroll",N,!0),window.removeEventListener("resize",N)}et(()=>{var I;document.addEventListener("mousedown",_,!0),n.open&&((I=a.value)==null||I.focus(),y(),D())}),Se(()=>n.open,I=>{if(!I){E();return}D(),Fe(()=>{var M;y(),(M=a.value)==null||M.focus()})}),st(()=>{document.removeEventListener("mousedown",_,!0),E()});function A(I){I!==n.currentModel&&s("apply-model",I),k()}const T=G(null);function Z(){const I=T.value;return I?Array.from(I.querySelectorAll(".picker-row")):[]}function W(){var I;(I=Z()[0])==null||I.focus()}function j(I){var ie,me,_e;if(I.key!=="ArrowDown"&&I.key!=="ArrowUp")return;const M=Z();if(M.length===0)return;const V=M.indexOf(document.activeElement);I.preventDefault(),V===-1?(ie=M[0])==null||ie.focus():I.key==="ArrowDown"?(me=M[(V+1)%M.length])==null||me.focus():(_e=M[(V-1+M.length)%M.length])==null||_e.focus()}function ne(I){I!==n.currentThinking&&s("apply-thinking",I)}return(I,M)=>(m(),v("span",{ref_key:"anchorRef",ref:b,class:"model-picker model-picker--anchor"},[(m(),De(Js,{to:"body"},[e.open?(m(),v("div",{key:0,ref_key:"rootRef",ref:S,class:"model-picker",style:bt(w.value),role:"dialog","aria-label":"模型选择",onKeydown:M[1]||(M[1]=Vn(tt(V=>k(),["stop"]),["esc"]))},[Ze(h("input",{ref_key:"searchRef",ref:a,"onUpdate:modelValue":M[0]||(M[0]=V=>i.value=V),class:"picker-search",type:"text",placeholder:"搜索模型…",id:"model-search-input",name:"model-search",autocomplete:"off",spellcheck:"false",onKeydown:Vn(tt(W,["prevent"]),["arrow-down"])},null,40,o1),[[it,i.value]]),h("div",{ref_key:"listRef",ref:T,class:"picker-list",onKeydown:j},[u.value.length===0?(m(),v("div",r1,"无匹配模型")):F("",!0),(m(!0),v(te,null,Ce(u.value,V=>(m(),v("div",{key:V.provider,class:"picker-group"},[h("div",i1,C(V.provider),1),(m(!0),v(te,null,Ce(V.models,ie=>(m(),v("button",{key:ie.alias,class:ue(["picker-row",{active:ie.alias===e.currentModel}]),onClick:me=>A(ie.alias)},[h("span",l1,[h("span",u1,C(g(ie)),1),h("span",c1,C(ie.alias),1)]),h("span",d1,C(p(ie.maxContextSize)),1),ie.alias===e.currentModel?(m(),v("span",f1,"✓")):F("",!0)],10,a1))),128))]))),128))],544),h("div",h1,[M[2]||(M[2]=h("span",{class:"thinking-label"},"思考强度",-1)),h("div",p1,[(m(!0),v(te,null,Ce(d.value,V=>(m(),v("button",{key:V,class:ue(["thinking-btn",{active:V===e.currentThinking}]),onClick:ie=>ne(V)},C(f(V)),11,g1))),128))])])],36)):F("",!0)]))],512))}}),v1=Te(m1,[["__scopeId","data-v-0271ee16"]]),y1={class:"slash-menu",role:"listbox","aria-label":"斜杠命令与技能"},b1={key:0,class:"slash-search"},k1=["value"],w1={class:"slash-list"},S1={key:0,class:"slash-group"},_1={class:"slash-group-label"},$1={key:0,class:"slash-group-hint"},C1=["aria-selected","onMousedown","onMouseenter"],x1={class:"slash-name"},I1={key:0,class:"slash-aliases"},T1={class:"slash-desc"},E1={key:0,class:"slash-badge slash-badge-source"},A1={key:0,class:"slash-badge slash-badge-input"},M1={key:1,class:"slash-badge"},R1=Ie({__name:"SlashMenu",props:{commands:{},activeIndex:{}},emits:["select","hover"],setup(e,{emit:t}){const n=e,s=t,o={builtin:"内置",user:"用户",extra:"扩展",project:"项目"};function r(d){return d?d.startsWith("plugin:")?`插件 ${d.slice(7)}`:o[d]||d:""}const i=B(()=>{const d=[];let f="";return n.commands.forEach((p,g)=>{const b=p.kind==="skill"?"skills":p.group==="advanced"?"advanced":"commands";b!==f&&(f=b,d.push({type:"header",label:a[b]})),d.push({type:"item",cmd:p,index:g})}),f!=="advanced"&&Uv()&&d.push({type:"header",label:a.advanced,hint:"输入继续筛选"}),d}),a={commands:"命令",advanced:"高级",skills:"技能"},l=G(""),u=B(()=>n.commands.length>Fv||l.value!=="");function c(d){l.value=d.target.value,Gv(l.value)}return st(()=>{l.value&&(l.value="",Bv())}),(d,f)=>(m(),v("div",y1,[u.value?(m(),v("div",b1,[h("input",{class:"slash-search-input",type:"text",value:l.value,placeholder:"筛选命令与技能…","aria-label":"筛选命令与技能",onInput:c,onMousedown:f[0]||(f[0]=tt(()=>{},["stop"]))},null,40,k1)])):F("",!0),h("div",w1,[(m(!0),v(te,null,Ce(i.value,(p,g)=>{var b;return m(),v(te,{key:g},[p.type==="header"?(m(),v("div",S1,[h("span",_1,C(p.label),1),p.hint?(m(),v("span",$1,C(p.hint),1)):F("",!0)])):(m(),v("button",{key:1,class:ue(["slash-item",{active:p.index===e.activeIndex}]),role:"option","aria-selected":p.index===e.activeIndex,onMousedown:tt(S=>s("select",p.cmd),["prevent"]),onMouseenter:S=>s("hover",p.index)},[h("span",x1,[Ae("/"+C(p.cmd.name),1),(b=p.cmd.aliases)!=null&&b.length?(m(),v("span",I1,C(p.cmd.aliases.map(S=>`/${S}`).join(" ")),1)):F("",!0)]),h("span",T1,C(p.cmd.description),1),p.cmd.kind==="skill"?(m(),v(te,{key:0},[p.cmd.source?(m(),v("span",E1,C(r(p.cmd.source)),1)):F("",!0),f[1]||(f[1]=h("span",{class:"slash-badge slash-badge-skill"},"技能",-1))],64)):(m(),v(te,{key:1},[p.cmd.acceptsInput?(m(),v("span",A1,"输入参数")):F("",!0),p.cmd.target==="backend"?(m(),v("span",M1,"服务端")):F("",!0)],64))],42,C1))],64)}),128))]),f[2]||(f[2]=h("div",{class:"slash-hint"},"↑↓ 选择 · Enter/Tab 执行 · Esc 关闭",-1))]))}}),P1=Te(R1,[["__scopeId","data-v-b0de79ca"]]),L1=34;function Cr(e){const t=e.split("/"),n=t.at(-1)??e;return t.length<=2?{dir:t.length===2?`${t[0]}/`:"",base:n}:e.length<=L1?{dir:`${t.slice(0,-1).join("/")}/`,base:n}:{dir:`…/${t.at(-2)}/`,base:n}}const D1={class:"picker-input-row"},N1=["placeholder","onKeydown"],O1=["disabled","title"],G1={key:0,class:"picker-warn"},B1={class:"picker-rows"},F1=["title","onClick"],U1={class:"row-base"},j1={class:"row-path"},z1={class:"picker-rows"},H1=["title","onClick"],W1={class:"row-base"},q1=Ie({__name:"WorkspacePicker",props:{current:{default:""},defaultDir:{default:""},recentWorkDirs:{default:()=>[]}},emits:["select","close"],setup(e,{emit:t}){const n=e,s=t,o=G(n.current||n.defaultDir),r=G(null),i=G(null),a=G(null),l=G({}),u=B(()=>o.value.trim().startsWith("/")),c=B(()=>u.value&&o.value.trim().length>0);function d(){c.value&&s("select",o.value.trim())}const f=G([]);let p;Se(o,k=>{clearTimeout(p);const y=k.trim();if(!y.startsWith("/")){f.value=[];return}p=setTimeout(async()=>{const _=await Wl(y);o.value.trim()===y&&(f.value=(_??[]).filter(N=>N.type==="dir").slice(0,8))},250)});function g(k){var y;o.value=k.path,(y=r.value)==null||y.focus()}function b(){var A;const k=i.value;if(!k)return;const _=(((A=k.closest(".chip-slot"))==null?void 0:A.querySelector(".workspace-select"))??document.querySelector(".workspace-select")??k).getBoundingClientRect(),N=6,D=8,E=ql(_,{placement:"top",align:"left",maxWidth:Math.min(360,window.innerWidth-D*2),gap:N,edge:D});E.maxHeight=`min(60vh, ${Math.max(240,_.top-N-D)}px)`,l.value=E}function S(k){const y=k.target;y instanceof Element&&y.closest(".workspace-select")||a.value&&!a.value.contains(y)&&s("close")}function w(k){var _;const y=k.target;y instanceof Node&&((_=a.value)!=null&&_.contains(y))||s("close")}return et(()=>{document.addEventListener("mousedown",S,!0),document.addEventListener("scroll",w,!0),window.addEventListener("resize",w),Fe(()=>{var k,y;b(),(k=r.value)==null||k.focus(),(y=r.value)==null||y.select()})}),st(()=>{document.removeEventListener("mousedown",S,!0),document.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w),clearTimeout(p)}),(k,y)=>(m(),v("span",{ref_key:"anchorRef",ref:i,class:"workspace-picker workspace-picker--anchor"},[(m(),De(Js,{to:"body"},[h("div",{ref_key:"rootRef",ref:a,class:"workspace-picker",style:bt(l.value),role:"dialog","aria-label":"选择工作区",onKeydown:y[1]||(y[1]=Vn(tt(_=>s("close"),["stop"]),["esc"]))},[y[4]||(y[4]=h("p",{class:"picker-title"},"工作区(下一次新建)",-1)),h("div",D1,[Ze(h("input",{ref_key:"inputRef",ref:r,"onUpdate:modelValue":y[0]||(y[0]=_=>o.value=_),class:"picker-path-input","data-testid":"workspace-path-input",placeholder:e.defaultDir||"输入绝对路径,如 /Users/you/project",spellcheck:"false",onKeydown:Vn(tt(d,["prevent"]),["enter"])},null,40,N1),[[it,o.value]]),h("button",{class:"picker-apply","data-testid":"workspace-apply",disabled:!c.value,title:c.value?"使用该目录新建会话":"工作区必须是绝对路径",onClick:d}," 选择 ",8,O1)]),o.value.trim()&&!u.value?(m(),v("p",G1,"需要绝对路径(以 / 开头)")):F("",!0),e.recentWorkDirs.length?(m(),v(te,{key:1},[y[2]||(y[2]=h("p",{class:"picker-section"},"最近使用",-1)),h("div",B1,[(m(!0),v(te,null,Ce(e.recentWorkDirs,_=>(m(),v("button",{key:_,class:"picker-row",title:_,onClick:N=>s("select",_)},[X(ce,{name:"folder",size:14}),h("span",U1,C(U(Ka)(_)),1),h("span",j1,C(U(Cr)(_).dir),1)],8,F1))),128))])],64)):F("",!0),f.value.length?(m(),v(te,{key:2},[y[3]||(y[3]=h("p",{class:"picker-section"},"子目录",-1)),h("div",z1,[(m(!0),v(te,null,Ce(f.value,_=>(m(),v("button",{key:_.path,class:"picker-row",title:_.path,onClick:N=>g(_)},[X(ce,{name:"folder",size:14}),h("span",W1,C(_.name),1)],8,H1))),128))])],64)):F("",!0)],36)]))],512))}}),V1=Te(q1,[["__scopeId","data-v-a02cc634"]]),K1=["data-placeholder-state","placeholder"],Z1={class:"composer-capsule-row"},Y1={class:"composer-chips"},X1=["title"],J1={class:"chip-text"},Q1={key:1,class:"chip-slot"},ew=["disabled","title","aria-haspopup","aria-expanded"],tw={class:"chip-text"},nw={key:2,class:"chip-slot"},sw=["disabled","title","aria-haspopup","aria-expanded"],ow={class:"chip-text"},rw=["disabled","title","aria-expanded"],iw={class:"chip-text"},aw=["disabled","title","aria-expanded"],lw={class:"chip-text"},uw=["title"],cw={class:"chip-text"},dw=["title"],fw={class:"chip-text"},hw=["data-action","disabled","title","aria-label"],pw={key:0,class:"primary-label"},Ic=50,gw=5e3,mw=Ie({__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:{},connectionStatus:{default:"idle"},goal:{default:null},recentWorkDirs:{default:()=>[]}},emits:["send","abort","command","switch-model","switch-thinking","switch-permission","goal-pause","goal-resume","goal-cancel","goal-edit"],setup(e,{expose:t,emit:n}){const s=e,o=n,r=G(""),i=G(null),a=B(()=>s.workDir||void 0),l=Db(r,i,a),u=G(0),c=G(!1),d=B(()=>{const L=r.value;return!L.startsWith("/")||L.includes(`
20
20
  `)||/\s/.test(L.slice(1))?null:L.slice(1)}),f=B(()=>d.value===null?[]:jv(d.value)),p=B(()=>d.value!==null&&f.value.length>0&&!c.value);Se(d,()=>{u.value=0,c.value=!1});function g(L){const re=L??f.value[u.value];if(re){if(re.acceptsInput){r.value=`/${re.name} `,c.value=!0,Fe(()=>{var Me;(Me=i.value)==null||Me.focus(),I()});return}E(`/${re.name}`),_e(),o("command",re.name)}}const b=G([]);Se(()=>s.sessionId,()=>{b.value=[]}),Se(()=>s.busy,L=>{if(!L&&b.value.length>0){const[re,...Me]=b.value;b.value=Me,re&&o("send",re)}});let S=0;const w=G([]),k=B(()=>Ob(w.value,Nb(s.messages??[]),Ic)),y=G(!1),_=G(0);function N(){return`scream-history:${s.sessionId??"default"}`}function D(){try{const L=localStorage.getItem(N());w.value=L?JSON.parse(L):[]}catch{w.value=[]}}function E(L){if(w.value.at(-1)!==L){w.value=[...w.value,L].slice(-Ic);try{localStorage.setItem(N(),JSON.stringify(w.value))}catch{}}}function A(L){r.value=L,y.value=!1,Fe(()=>{const re=i.value;re&&(re.focus(),re.setSelectionRange(re.value.length,re.value.length),I(),l.reset())})}function T(){c.value=!0,l.dismiss(),_.value=Math.max(0,k.value.length-1),y.value=!0}function Z(L){const re=k.value.length;re!==0&&(_.value=Math.min(re-1,Math.max(0,_.value+L)))}Se(()=>k.value.length,()=>{_.value>=k.value.length&&(_.value=Math.max(0,k.value.length-1))});function W(){return`scream-draft:${s.sessionId??"default"}`}let j=null,ne;Se(r,()=>{I(),y.value=!1,l.refresh(),clearTimeout(ne),ne=setTimeout(()=>{try{r.value?localStorage.setItem(W(),r.value):localStorage.removeItem(W())}catch{}},300)}),Se(()=>s.sessionId,()=>{if(clearTimeout(ne),D(),y.value=!1,_.value=0,j&&Date.now()-j.at<=gw){r.value=j.text,j=null,Fe(I);return}j=null;let L="";try{L=localStorage.getItem(W())??""}catch{L=""}r.value=L,Fe(I)},{immediate:!0});function I(){const L=i.value;if(!L)return;L.style.height="auto";const re=Math.round(window.innerHeight*.25);L.style.height=`${Math.min(Math.max(L.scrollHeight,36),re)}px`}function M(){l.refresh()}const V=G(0);function ie(){const L=window.visualViewport;if(!L)return;const re=Math.round(window.innerHeight-L.height-L.offsetTop);V.value=re>120?re:0}"visualViewport"in window&&(et(()=>{var L;(L=window.visualViewport)==null||L.addEventListener("resize",ie),ie()}),st(()=>{var L;(L=window.visualViewport)==null||L.removeEventListener("resize",ie),V.value=0}));function me(L){const re=L.target;re instanceof Element&&(re.closest(".history-menu")||re.closest("#composer-input")||(y.value=!1,p.value&&!re.closest(".composer-chips")&&(c.value=!0)))}et(()=>document.addEventListener("mousedown",me)),st(()=>document.removeEventListener("mousedown",me));function _e(){r.value="",l.reset(),y.value=!1,Fe(()=>{i.value&&(i.value.style.height="auto")})}function he(){const L=r.value.trim();if(L){if(L.startsWith("/")){const re=L.indexOf(" "),Me=(re===-1?L.slice(1):L.slice(1,re)).toLowerCase(),Zn=zv(Me),eg=re===-1?"":L.slice(re+1).trim();E(L),o("command",Zn,eg),_e();return}if(s.busy){ae();return}E(L),o("send",L),_e()}}function ae(){const L=r.value.trim();L&&(E(L),b.value=[...b.value,L],_e())}function pe(L){if(l.visible.value){if(L.key==="ArrowDown"){L.preventDefault(),l.move(1);return}if(L.key==="ArrowUp"){L.preventDefault(),l.move(-1);return}if((L.key==="Tab"||L.key==="Enter"&&!L.shiftKey)&&(L.isComposing||(L.preventDefault(),l.dirLoading.value)||l.confirm()))return;if(L.key==="Escape"){L.preventDefault(),l.dismiss();return}}if(p.value){if(L.key==="ArrowUp"){L.preventDefault(),u.value=(u.value-1+f.value.length)%f.value.length;return}if(L.key==="ArrowDown"){L.preventDefault(),u.value=(u.value+1)%f.value.length;return}if(L.key==="Tab"||L.key==="Enter"&&!L.shiftKey){if(L.key==="Enter"&&L.isComposing)return;L.preventDefault(),g();return}if(L.key==="Escape"){L.preventDefault(),c.value=!0;return}}if((L.ctrlKey||L.metaKey)&&L.key.toLowerCase()==="s"){L.preventDefault(),s.busy?ae():he();return}if(y.value&&!L.isComposing){if(L.key==="ArrowDown"){L.preventDefault(),Z(1);return}if(L.key==="ArrowUp"){L.preventDefault(),Z(-1);return}if(L.key==="Escape"){L.preventDefault(),y.value=!1;return}if((L.key==="Tab"||L.key==="Enter"&&!L.shiftKey)&&k.value[_.value]!==void 0){L.preventDefault(),A(k.value[_.value]);return}}if(L.key==="Enter"&&!L.shiftKey){if(L.isComposing||Date.now()-S<100)return;L.preventDefault(),he();return}L.key==="ArrowUp"&&!L.isComposing&&!s.busy&&r.value.trim().length===0&&k.value.length>0&&(L.preventDefault(),T())}function oe(){b.value=[],o("abort")}function ge(L){r.value=L,y.value=!1,Fe(()=>{var re;I(),(re=i.value)==null||re.focus()})}function $e(L,re={}){const Me=re.activate!==!1;j={text:L,at:Date.now()},r.value=L,c.value=!0,l.dismiss(),y.value=!1,Fe(()=>{I();const Zn=i.value;!Zn||!Me||(Zn.focus(),Zn.setSelectionRange(Zn.value.length,Zn.value.length))})}function Ne(L){r.value+=L,Fe(()=>{var re;I(),(re=i.value)==null||re.focus()})}const Ue=B(()=>{var L;return(L=s.status)==null?void 0:L.model}),Ke=B(()=>{var L;return(L=s.status)==null?void 0:L.permission}),Ye=B(()=>{var L;return(L=s.status)==null?void 0:L.contextUsage}),rt=B(()=>s.connectionStatus==="disconnected"||s.connectionStatus==="reconnecting"),Dt={offline:"连接已断开,正在重连 — 可以先打字,回车会把消息排队",plan:"计划模式:只做只读分析与方案输出,回车提交这个问题",queue:`已排队:回车继续排队下一条,${$r}S 立即注入`,busy:`回合进行中:现在打字然后回车,消息会排队随下一轮注入(${$r}S 立即注入)`,"no-workspace":"这个会话还没有工作目录:@ 文件提及暂不可用,可以直接提问",idle:"输入消息,@ 提及文件,/ 触发指令"},x=B(()=>{var L;return rt.value?"offline":s.busy?r.value.trim()?"queue":"busy":(L=s.status)!=null&&L.planMode?"plan":s.variant==="chat"&&!s.workDir?"no-workspace":"idle"}),P=B(()=>x.value==="idle"&&s.placeholder?s.placeholder:Dt[x.value]),z={off:"关闭",low:"低",medium:"中",high:"高",xhigh:"超高",max:"最大"},ee=B(()=>{var re;const L=(re=s.status)==null?void 0:re.model;if(L)return s.models.find(Me=>Me.alias===L)}),J=B(()=>{var L;return((L=ee.value)==null?void 0:L.thinkingLevels)??[]}),R=B(()=>{var L;return(L=s.status)==null?void 0:L.thinkingLevel}),K=B(()=>{const L=R.value;return!L||L==="none"?"默认":z[L]??L}),O={manual:"手动",auto:"自动",yolo:"YOLO",bot:"无人值守",ask:"询问"},Q=["manual","auto","yolo","bot","ask"],$={manual:"每次工具调用都要你确认",auto:"安全操作自动放行,敏感操作仍要确认",yolo:"全部自动放行,不再打断",bot:"无人值守模式:批量接管确认",ask:"遇到需要决定的操作时询问你"},H=B(()=>O[Ke.value??""]??Ke.value??"手动"),q=B(()=>{switch(Ke.value){case"auto":return"perm-auto";case"yolo":return"perm-yolo";case"bot":return"perm-bot";default:return"perm-manual"}}),se=B(()=>{const L=Ye.value;return L===void 0?"":`${Math.round(L*100)}%`}),{preferredWorkDir:fe,serverWorkDir:ye,displayWorkDir:Ee,setPreferredWorkDir:ke}=Hl(),be=B(()=>{const re=s.variant==="chat"?rt.value?"连接已断开,正在重连 — 重连后可以切换":s.sessionId?"":"还没有打开会话,先新建或选择一个会话":"",Me=s.models.length===0?"后端没有返回可选模型,暂时不能切换":"";return{model:{label:s.variant==="home"?"通用智能体":Ue.value??"",title:Me||re||(Ue.value?`当前模型:${Ue.value},点击切换`:"会话状态还没回来"),enabled:!Me&&!re,visible:!!Ue.value||s.variant==="home"},thinking:{label:`思考 · ${K.value}`,title:re||`思考力度:${K.value},点击调整(可选:${J.value.join(" / ")})`,enabled:!re,visible:s.variant==="chat"&&J.value.length>0},permission:{label:Ke.value?H.value:"权限",title:re||(Ke.value?`权限模式:${H.value},点击切换(会记录到会话日志)`:"权限模式:点击切换(会记录到会话日志)"),enabled:!re,visible:s.variant==="chat"},workspace:s.variant==="chat"?{label:s.workDir?Ka(s.workDir):"工作区",title:s.workDir?`工作区:${s.workDir} — 工作区随会话创建,不可中途更换`:"这个会话还没有工作目录",enabled:!1,visible:!0}:{label:Ee.value?Ka(Ee.value):"默认工作区",title:Ee.value?`工作区:${Ee.value},点击为下一次新建选择目录`:"还没拿到服务器默认工作区,点击可手动输入目录",enabled:!0,visible:!0},context:{label:se.value,title:Ye.value===void 0?"上下文占用还没回来":`上下文占用 ${(Ye.value*100).toFixed(1)}%`,enabled:!1,visible:Ye.value!==void 0}}}),Oe=G(null);function lt(L){ke(L),Oe.value=null}function gt(L,re){re&&(y.value=!1,Oe.value=Oe.value===L?null:L)}function sn(L,re){re?Oe.value=L:Oe.value===L&&(Oe.value=null)}function Ss(){return be.value.model.enabled?(Oe.value="model",!0):!1}const mt=B(()=>Oe.value==="model"),Nt=B(()=>Za(J.value.map(L=>({key:L,label:L==="off"||L==="none"?"关闭":z[L]??L,checked:R.value===L})),"思考力度")),_s=B(()=>Za(Q.map(L=>({key:L,label:O[L]??L,checked:Ke.value===L,title:$[L]})),"权限模式"));function $s(L){o("switch-model",L),Oe.value=null}function oo(L){o("switch-thinking",L),Oe.value=null}function Ui(L){o("switch-permission",L),Oe.value=null}const on=B(()=>s.busy?"stop":"send"),Cs={send:{icon:"arrow-up",label:"发送",title:"发送(回车)"},stop:{icon:"stop",label:"停止",title:"停止当前回合"}},ji=B(()=>Cs[on.value].icon),ro=B(()=>Cs[on.value].label),zi=B(()=>on.value==="stop"&&r.value.trim()?`${Cs.stop.title}(回车把当前输入排队,${$r}S 立即注入)`:Cs[on.value].title),er=B(()=>on.value==="send"&&!r.value.trim());function xs(){if(on.value==="stop"){oe();return}he()}const tr=B(()=>!!s.goal&&(s.goal.status==="active"||s.goal.status==="paused"||s.goal.status==="blocked")),de=B(()=>rt.value||!s.sessionId),ve=B(()=>rt.value?"连接已断开,正在重连":s.sessionId?"":"还没有打开会话");return t({insertText:ge,insertDraft:$e,openModelPicker:Ss}),(L,re)=>(m(),v("div",{class:"composer",style:bt(V.value?{paddingBottom:V.value+"px"}:void 0)},[p.value?(m(),De(P1,{key:0,commands:f.value,"active-index":u.value,onSelect:g,onHover:re[0]||(re[0]=Me=>u.value=Me)},null,8,["commands","active-index"])):F("",!0),U(l).visible.value?(m(),De(Tk,{key:1,suggestions:U(l).suggestions.value,"active-index":U(l).index.value,loading:U(l).dirLoading.value,"work-dir":e.workDir,onSelect:re[1]||(re[1]=Me=>U(l).confirm(Me)),onHover:re[2]||(re[2]=Me=>U(l).index.value=Me)},null,8,["suggestions","active-index","loading","work-dir"])):F("",!0),y.value&&k.value.length>0?(m(),De(Yk,{key:2,items:k.value,"active-index":_.value,onApply:A,onHover:re[3]||(re[3]=Me=>_.value=Me)},null,8,["items","active-index"])):F("",!0),tr.value?(m(),De(zk,{key:3,goal:e.goal??null,busy:e.busy,disabled:de.value,"disabled-reason":ve.value,onPause:re[4]||(re[4]=Me=>o("goal-pause")),onResume:re[5]||(re[5]=Me=>o("goal-resume")),onCancel:re[6]||(re[6]=Me=>o("goal-cancel")),onEdit:re[7]||(re[7]=Me=>o("goal-edit"))},null,8,["goal","busy","disabled","disabled-reason"])):F("",!0),Ze(h("textarea",{ref_key:"textareaRef",ref:i,"onUpdate:modelValue":re[8]||(re[8]=Me=>r.value=Me),id:"composer-input",name:"message",class:"composer-input",rows:"1","data-placeholder-state":x.value,placeholder:P.value,onKeydown:pe,onCompositionend:re[9]||(re[9]=Me=>ht(S)?S.value=Date.now():S=Date.now()),onClick:M,onKeyup:M},null,40,K1),[[it,r.value]]),h("div",Z1,[h("div",Y1,[e.variant==="chat"?(m(),v("button",{key:0,class:"composer-chip","data-chip":"mention",title:"插入 @ 提及文件",onClick:re[10]||(re[10]=Me=>Ne("@"))},[X(ce,{name:"at",size:14}),re[20]||(re[20]=h("span",{class:"chip-text"},"提及",-1))])):F("",!0),h("button",{class:"composer-chip","data-chip":"slash",title:e.variant==="home"?"插入 / 触发技能":"插入 / 触发指令",onClick:re[11]||(re[11]=Me=>Ne("/"))},[X(ce,{name:"command",size:14}),h("span",J1,C(e.variant==="home"?"技能":"指令"),1)],8,X1),be.value.workspace.visible?(m(),v("span",Q1,[h("button",{class:ue(["composer-chip workspace-select",{"is-clickable":be.value.workspace.enabled}]),"data-chip":"workspace",disabled:!be.value.workspace.enabled,title:be.value.workspace.title,"aria-haspopup":be.value.workspace.enabled?"dialog":void 0,"aria-expanded":Oe.value==="workspace"?"true":"false",onClick:re[12]||(re[12]=Me=>gt("workspace",be.value.workspace.enabled))},[X(ce,{name:"folder",size:14}),h("span",tw,C(be.value.workspace.label),1),be.value.workspace.enabled?(m(),De(ce,{key:0,name:"chevron-down",size:12})):F("",!0)],10,ew),Oe.value==="workspace"?(m(),De(V1,{key:0,current:U(fe)??"","default-dir":U(ye)??"","recent-work-dirs":e.recentWorkDirs,onSelect:lt,onClose:re[13]||(re[13]=Me=>Oe.value=null)},null,8,["current","default-dir","recent-work-dirs"])):F("",!0)])):F("",!0),be.value.model.visible?(m(),v("span",nw,[h("button",{class:ue(["composer-chip model-select",{"is-clickable":be.value.model.enabled}]),"data-chip":"model",disabled:!be.value.model.enabled,title:be.value.model.title,"aria-haspopup":be.value.model.enabled?"dialog":void 0,"aria-expanded":mt.value?"true":"false",onClick:re[14]||(re[14]=Me=>gt("model",be.value.model.enabled))},[X(ce,{name:"brain",size:14}),h("span",ow,C(be.value.model.label),1),be.value.model.enabled?(m(),De(ce,{key:0,name:"chevron-down",size:12})):F("",!0)],10,sw),X(Ol,{name:"picker"},{default:ot(()=>[mt.value?(m(),De(v1,{key:0,models:e.models,"current-model":Ue.value,"current-thinking":R.value,onApplyModel:$s,onApplyThinking:oo,onClose:re[15]||(re[15]=Me=>Oe.value=null)},null,8,["models","current-model","current-thinking"])):F("",!0)]),_:1})])):F("",!0),be.value.thinking.visible?(m(),De(Ya,{key:3,class:"chip-slot",label:"思考力度",heading:"思考力度",groups:Nt.value,open:Oe.value==="thinking",placement:"top",align:"left","onUpdate:open":re[17]||(re[17]=Me=>sn("thinking",Me)),onSelect:oo},{default:ot(()=>[h("button",{class:ue(["composer-chip",{"is-clickable":be.value.thinking.enabled}]),"data-chip":"thinking",disabled:!be.value.thinking.enabled,title:be.value.thinking.title,"aria-haspopup":"menu","aria-expanded":Oe.value==="thinking"?"true":"false",onClick:re[16]||(re[16]=Me=>gt("thinking",be.value.thinking.enabled))},[X(ce,{name:"activity",size:14}),h("span",iw,C(be.value.thinking.label),1),X(ce,{name:"chevron-down",size:12})],10,rw)]),_:1},8,["groups","open"])):F("",!0),be.value.permission.visible?(m(),De(Ya,{key:4,class:"chip-slot",label:"权限模式",groups:_s.value,open:Oe.value==="permission",placement:"top",align:"left","onUpdate:open":re[19]||(re[19]=Me=>sn("permission",Me)),onSelect:Ui},{default:ot(()=>[h("button",{class:ue(["composer-chip",["is-clickable",q.value]]),"data-chip":"permission",disabled:!be.value.permission.enabled,title:be.value.permission.title,"aria-haspopup":"menu","aria-expanded":Oe.value==="permission"?"true":"false",onClick:re[18]||(re[18]=Me=>gt("permission",be.value.permission.enabled))},[X(ce,{name:"shield",size:14}),h("span",lw,C(be.value.permission.label),1),X(ce,{name:"chevron-down",size:12})],10,aw)]),_:1},8,["groups","open"])):F("",!0),be.value.context.visible?(m(),v("span",{key:5,class:"composer-chip is-static","data-chip":"context",title:be.value.context.title},[X(bh,{usage:Ye.value,size:14},null,8,["usage"]),h("span",cw,C(be.value.context.label),1)],8,uw)):F("",!0),b.value.length?(m(),v("span",{key:6,class:"composer-chip is-static","data-chip":"queue",title:`已排队 ${b.value.length} 条,当前回合结束后自动发送`},[X(ce,{name:"queue",size:14}),h("span",fw,"排队 "+C(b.value.length),1)],8,dw)):F("",!0)]),h("button",{class:"composer-primary","data-action":on.value,disabled:er.value,title:zi.value,"aria-label":ro.value,onClick:xs},[X(ce,{name:ji.value,size:16},null,8,["name"]),on.value!=="send"?(m(),v("span",pw,C(ro.value),1)):F("",!0)],8,hw)])],4))}}),kh=Te(mw,[["__scopeId","data-v-f2ac71a6"]]),vw={class:"conv-bar"},yw={class:"conv-bar-left"},bw=["title"],kw=["title"],ww={key:1,class:"title-text"},Sw={class:"conv-bar-right"},_w=["title","aria-label","aria-expanded"],$w={key:0,class:"stats-metric mono"},Cw={key:1,class:"stats-sep","aria-hidden":"true"},xw={key:2,class:"stats-metric mono"},Iw=["aria-expanded"],Tw=["title","aria-label"],Ew=Ie({__name:"ConversationHeader",props:{title:{default:null},busy:{type:Boolean,default:!1},statsOpen:{type:Boolean,default:!1},turnTokens:{default:null},turnCount:{default:null}},emits:["home","rename","export","fork","clear","controls","agents","toggle-stats"],setup(e,{emit:t}){const n=e,s=t,o=B(()=>we.panelOpen),r=B(()=>(n.turnCount??0)>0||(n.turnTokens??0)>0);function i(){we.panelOpen?jl(!1):Sr("detail")}function a(w){return w===null||w<=0?"":w>=1e6?`${(w/1e6).toFixed(1)}M`:w>=1e3?`${(w/1e3).toFixed(1)}k`:String(w)}const l=G(!1),u=B(()=>Za([{key:"controls",label:"会话控制",icon:"wrench",title:"打开会话控制面板"},{key:"agents",label:"协作代理",icon:"bot",title:"查看子代理执行状态"},{key:"export",label:"导出 Markdown",icon:"download",disabled:!r.value,title:r.value?"把当前会话导出成 Markdown 文件":"还没有消息可导出"},{key:"fork",label:"分叉会话",icon:"fork",disabled:!r.value,title:r.value?"从当前会话分叉出新会话":"还没有消息可分叉"},{key:"clear",label:"清空本地消息",icon:"broom",tone:"danger",disabled:!r.value,title:r.value?"清空本地 journal(服务端记录不受影响)":"还没有消息可清空"},{key:"files",label:o.value?"收起文件面板":"打开文件面板",icon:"file",title:o.value?"收起右侧面板":"在右侧面板打开文件视图"}]));function c(w){l.value=!1,w==="controls"?s("controls"):w==="agents"?s("agents"):w==="export"?s("export"):w==="fork"?s("fork"):w==="clear"?s("clear"):w==="files"&&Qy()}const d=G(!1),f=G("");function p(){f.value=n.title??"",d.value=!0}function g(){const w=f.value.trim();d.value=!1,w&&w!==n.title&&s("rename",w)}function b(w){w.key==="Enter"?(w.preventDefault(),g()):w.key==="Escape"&&(w.preventDefault(),d.value=!1)}const S=B(()=>n.busy?"运行中":"就绪");return(w,k)=>(m(),v("header",vw,[h("div",yw,[h("button",{class:"ghost-btn back-btn",title:"返回工作台","aria-label":"返回工作台",onClick:k[0]||(k[0]=y=>s("home"))},[X(ce,{name:"chevron-left",size:20})]),h("span",{class:ue(["status-dot",{busy:e.busy}]),title:S.value,"aria-hidden":"true"},null,10,bw),h("button",{class:"title-btn",title:d.value?"":"点击重命名",onClick:p},[d.value?Ze((m(),v("input",{key:0,"onUpdate:modelValue":k[1]||(k[1]=y=>f.value=y),class:"title-input","aria-label":"会话标题",onKeydown:b,onBlur:g,onClick:k[2]||(k[2]=tt(()=>{},["stop"]))},null,544)),[[it,f.value]]):(m(),v("span",ww,C(e.title||"新会话"),1))],8,kw)]),h("div",Sw,[h("button",{class:ue(["ghost-btn stats-btn",{active:e.statsOpen}]),title:e.statsOpen?"收起会话统计":"会话统计:轮次与 token 用量","aria-label":e.statsOpen?"收起会话统计":"会话统计","aria-expanded":e.statsOpen,"data-stats-pill":"",onPointerdown:k[3]||(k[3]=tt(()=>{},["stop"])),onClick:k[4]||(k[4]=y=>s("toggle-stats"))},[X(ce,{name:"bar-chart",size:16}),e.turnCount?(m(),v("span",$w,C(e.turnCount)+" 轮",1)):F("",!0),e.turnCount&&a(e.turnTokens)?(m(),v("span",Cw,"·")):F("",!0),a(e.turnTokens)?(m(),v("span",xw,C(a(e.turnTokens)),1)):F("",!0)],42,_w),X(Ya,{open:l.value,"onUpdate:open":k[6]||(k[6]=y=>l.value=y),label:"更多会话操作",groups:u.value,placement:"bottom",align:"right",onSelect:c},{default:ot(()=>[h("button",{class:ue(["ghost-btn more-btn",{active:l.value}]),title:"更多操作","aria-label":"更多操作","aria-haspopup":"menu","aria-expanded":l.value,onClick:k[5]||(k[5]=y=>l.value=!l.value)},[X(ce,{name:"more",size:18})],10,Iw)]),_:1},8,["open","groups"]),h("button",{class:ue(["ghost-btn",{active:o.value}]),title:o.value?"收起右栏":"打开右栏","aria-label":o.value?"收起右栏":"打开右栏",onClick:i},[X(ce,{name:"panel-right",size:18})],10,Tw)])]))}}),Aw=Te(Ew,[["__scopeId","data-v-8f306594"]]),Mw={key:0,class:"ui-dialog-header"},Rw={class:"ui-dialog-title"},Pw={class:"ui-dialog-body"},Lw={key:1,class:"ui-dialog-footer"},Dw='a[href], button:not([disabled]), textarea, input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',Nw=Ie({__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=G(null);let r=null;function i(){const l=o.value;return l?Array.from(l.querySelectorAll(Dw)).filter(u=>u.offsetParent!==null||u===document.activeElement):[]}function a(l){var p,g,b;if(!n.open)return;if(l.key==="Escape"&&n.closable!==!1){l.stopPropagation(),s("close");return}if(l.key!=="Tab")return;const u=i();if(u.length===0){l.preventDefault(),(p=o.value)==null||p.focus();return}const c=u[0],d=u[u.length-1],f=document.activeElement;l.shiftKey?(f===c||!((g=o.value)!=null&&g.contains(f)))&&(l.preventDefault(),d.focus()):(f===d||!((b=o.value)!=null&&b.contains(f)))&&(l.preventDefault(),c.focus())}return Se(()=>n.open,l=>{l?(r=document.activeElement instanceof HTMLElement?document.activeElement:null,Fe(()=>{const u=i()[0]??o.value;u==null||u.focus()})):r&&(r.focus(),r=null)},{immediate:!1}),et(()=>window.addEventListener("keydown",a,!0)),st(()=>window.removeEventListener("keydown",a,!0)),(l,u)=>(m(),De(Js,{to:"body"},[X(Ol,{name:"dialog"},{default:ot(()=>[e.open?(m(),v("div",{key:0,class:"ui-dialog-overlay",onClick:u[1]||(u[1]=tt(c=>e.closable!==!1&&s("close"),["self"]))},[h("div",{ref_key:"dialogRef",ref:o,class:"ui-dialog",style:bt(e.maxWidth?{maxWidth:e.maxWidth}:void 0),role:"dialog","aria-modal":"true",tabindex:"-1"},[e.title||l.$slots.header?(m(),v("div",Mw,[Co(l.$slots,"header",{},()=>[h("span",Rw,C(e.title),1)],!0),e.closable!==!1?(m(),v("button",{key:0,class:"ui-dialog-close","aria-label":"关闭",onClick:u[0]||(u[0]=c=>s("close"))},"✕")):F("",!0)])):F("",!0),h("div",Pw,[Co(l.$slots,"default",{},void 0,!0)]),l.$slots.footer?(m(),v("div",Lw,[Co(l.$slots,"footer",{},void 0,!0)])):F("",!0)],4)])):F("",!0)]),_:3})]))}}),Vl=Te(Nw,[["__scopeId","data-v-396acebf"]]),Ow={class:"info-row"},Gw={class:"info-val mono"},Bw={class:"info-row"},Fw={class:"info-val mono"},Uw={class:"info-row"},jw={class:"info-val"},zw={class:"info-row"},Hw={class:"info-val"},Ww={class:"info-row"},qw={class:"info-val"},Vw={class:"info-row"},Kw={class:"info-val"},Zw={class:"info-row"},Yw={class:"info-val"},Xw={class:"info-row"},Jw={class:"info-val"},Qw={class:"info-row"},e0={class:"info-val"},t0={class:"info-row"},n0={class:"info-val"},s0={key:0,class:"info-row"},o0={class:"info-val"},r0={key:1,class:"info-row"},i0={class:"info-val"},a0={class:"info-val mono"},l0={class:"info-val"},u0={key:3,class:"info-empty"},c0=Ie({__name:"InfoPanel",props:{mode:{},status:{},sessionId:{},workDir:{}},emits:["close"],setup(e,{emit:t}){const n=e,s=t,o=B(()=>n.mode==="status"?"会话状态":"Token 用量");function r(p){switch(p){case"auto":return"自动 (auto)";case"yolo":return"YOLO";case"manual":return"手动 (manual)";default:return p??"-"}}function i(p){return p?"开启":"关闭"}function a(p){return p!=null}function l(p){return typeof p=="number"?p.toLocaleString():"-"}function u(p){return typeof p!="number"?"-":`${(p>1?p:p*100).toFixed(1)}%`}function c(p){return p?p.inputOther+p.output+p.inputCacheRead+p.inputCacheCreation:0}function d(p){return p!=null&&p.byModel?Object.entries(p.byModel).map(([g,b])=>({model:g,tokens:c(b),output:b.output,cacheRead:b.inputCacheRead})):[]}const f=B(()=>a(n.status.usage)||a(n.status.contextTokens));return(p,g)=>(m(),De(Vl,{open:!0,title:o.value,onClose:g[0]||(g[0]=b=>s("close"))},{default:ot(()=>{var b,S;return[e.mode==="status"?(m(),v(te,{key:0},[h("div",Ow,[g[1]||(g[1]=h("span",{class:"info-key"},"会话 ID",-1)),h("span",Gw,C(e.sessionId??"-"),1)]),h("div",Bw,[g[2]||(g[2]=h("span",{class:"info-key"},"工作目录",-1)),h("span",Fw,C(e.workDir??"-"),1)]),h("div",Uw,[g[3]||(g[3]=h("span",{class:"info-key"},"模型",-1)),h("span",jw,C(e.status.model??"-"),1)]),h("div",zw,[g[4]||(g[4]=h("span",{class:"info-key"},"权限模式",-1)),h("span",Hw,C(r(e.status.permission)),1)]),h("div",Ww,[g[5]||(g[5]=h("span",{class:"info-key"},"思考级别",-1)),h("span",qw,C(e.status.thinkingLevel??"-"),1)]),h("div",Vw,[g[6]||(g[6]=h("span",{class:"info-key"},"计划模式",-1)),h("span",Kw,C(i(e.status.planMode)),1)]),h("div",Zw,[g[7]||(g[7]=h("span",{class:"info-key"},"WolfPack 模式",-1)),h("span",Yw,C(i(e.status.wolfpackMode)),1)]),h("div",Xw,[g[8]||(g[8]=h("span",{class:"info-key"},"上下文",-1)),h("span",Jw,C(l(e.status.contextTokens))+" / "+C(l(e.status.maxContextTokens))+" ("+C(u(e.status.contextUsage))+")",1)])],64)):(m(),v(te,{key:1},[h("div",Qw,[g[9]||(g[9]=h("span",{class:"info-key"},"上下文 Token",-1)),h("span",e0,C(l(e.status.contextTokens))+" / "+C(l(e.status.maxContextTokens)),1)]),h("div",t0,[g[10]||(g[10]=h("span",{class:"info-key"},"上下文占比",-1)),h("span",n0,C(u(e.status.contextUsage)),1)]),(b=e.status.usage)!=null&&b.total?(m(),v("div",s0,[g[11]||(g[11]=h("span",{class:"info-key"},"累计 Token",-1)),h("span",o0,C(l(c(e.status.usage.total))),1)])):F("",!0),(S=e.status.usage)!=null&&S.currentTurn?(m(),v("div",r0,[g[12]||(g[12]=h("span",{class:"info-key"},"当前回合",-1)),h("span",i0,C(l(c(e.status.usage.currentTurn))),1)])):F("",!0),d(e.status.usage).length?(m(),v(te,{key:2},[g[13]||(g[13]=h("div",{class:"info-subhead"},"按模型",-1)),(m(!0),v(te,null,Ce(d(e.status.usage),w=>(m(),v("div",{key:w.model,class:"info-row info-row-model"},[h("span",a0,C(w.model),1),h("span",l0,C(l(w.tokens))+"(输出 "+C(l(w.output))+" · 缓存读 "+C(l(w.cacheRead))+")",1)]))),128))],64)):F("",!0),f.value?F("",!0):(m(),v("div",u0,"暂无用量数据"))],64))]}),_:1},8,["title"]))}}),wh=Te(c0,[["__scopeId","data-v-1555711d"]]);function d0(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 f0(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 h0(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 p0=new Set(["edit","str_replace","replace","write","multi_edit","create_file","edit_file","apply_patch"]);function Sh(e){return p0.has(e.toLowerCase())}function Ri(e,t=!0){return e.suspended?"suspended":e.isError?"error":e.output===void 0?t?"running":"unknown":"ok"}function g0(e,t=!0){const n=new Set(e.map(s=>Ri(s,t)));return n.has("running")?"running":n.has("error")?"error":n.has("suspended")?"suspended":n.has("unknown")?"unknown":"ok"}function m0(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 Kl(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 v0(e,t){const n=new Set,s=[];for(const o of e.tools){if(!Sh(o.name)||Ri(o,!1)!=="ok")continue;const r=m0(o.args);if(!r)continue;const i=Kl(r,t);n.has(i)||(n.add(i),s.push({filePath:i,toolName:o.name}))}return s}function Zl(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ks=Zl();function _h(e){ks=e}var To={exec:()=>null};function Ve(e,t=""){let n=typeof e=="string"?e:e.source;const s={replace:(o,r)=>{let i=typeof r=="string"?r:r.source;return i=i.replace(Pt.caret,"$1"),n=n.replace(o,i),s},getRegex:()=>new RegExp(n,t)};return s}var Pt={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")},y0=/^(?:[ \t]*(?:\n|$))+/,b0=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,k0=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Yo=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,w0=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Yl=/(?:[*+-]|\d{1,9}[.)])/,$h=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ch=Ve($h).replace(/bull/g,Yl).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(),S0=Ve($h).replace(/bull/g,Yl).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(),Xl=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,_0=/^[^\n]+/,Jl=/(?!\s*\])(?:\\.|[^\[\]\\])+/,$0=Ve(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Jl).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),C0=Ve(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Yl).getRegex(),Pi="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",Ql=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,x0=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",Ql).replace("tag",Pi).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),xh=Ve(Xl).replace("hr",Yo).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",Pi).getRegex(),I0=Ve(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",xh).getRegex(),eu={blockquote:I0,code:b0,def:$0,fences:k0,heading:w0,hr:Yo,html:x0,lheading:Ch,list:C0,newline:y0,paragraph:xh,table:To,text:_0},Tc=Ve("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Yo).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",Pi).getRegex(),T0={...eu,lheading:S0,table:Tc,paragraph:Ve(Xl).replace("hr",Yo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Tc).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",Pi).getRegex()},E0={...eu,html:Ve(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ql).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:To,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ve(Xl).replace("hr",Yo).replace("heading",` *#{1,6} *[^
21
21
  ]`).replace("lheading",Ch).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},A0=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,M0=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ih=/^( {2,}|\\)\n(?!\s*$)/,R0=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Li=/[\p{P}\p{S}]/u,tu=/[\s\p{P}\p{S}]/u,Th=/[^\s\p{P}\p{S}]/u,P0=Ve(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,tu).getRegex(),Eh=/(?!~)[\p{P}\p{S}]/u,L0=/(?!~)[\s\p{P}\p{S}]/u,D0=/(?:[^\s\p{P}\p{S}]|~)/u,N0=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Ah=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,O0=Ve(Ah,"u").replace(/punct/g,Li).getRegex(),G0=Ve(Ah,"u").replace(/punct/g,Eh).getRegex(),Mh="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",B0=Ve(Mh,"gu").replace(/notPunctSpace/g,Th).replace(/punctSpace/g,tu).replace(/punct/g,Li).getRegex(),F0=Ve(Mh,"gu").replace(/notPunctSpace/g,D0).replace(/punctSpace/g,L0).replace(/punct/g,Eh).getRegex(),U0=Ve("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Th).replace(/punctSpace/g,tu).replace(/punct/g,Li).getRegex(),j0=Ve(/\\(punct)/,"gu").replace(/punct/g,Li).getRegex(),z0=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(),H0=Ve(Ql).replace("(?:-->|$)","-->").getRegex(),W0=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",H0).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Qr=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,q0=Ve(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Qr).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Rh=Ve(/^!?\[(label)\]\[(ref)\]/).replace("label",Qr).replace("ref",Jl).getRegex(),Ph=Ve(/^!?\[(ref)\](?:\[\])?/).replace("ref",Jl).getRegex(),V0=Ve("reflink|nolink(?!\\()","g").replace("reflink",Rh).replace("nolink",Ph).getRegex(),nu={_backpedal:To,anyPunctuation:j0,autolink:z0,blockSkip:N0,br:Ih,code:M0,del:To,emStrongLDelim:O0,emStrongRDelimAst:B0,emStrongRDelimUnd:U0,escape:A0,link:q0,nolink:Ph,punctuation:P0,reflink:Rh,reflinkSearch:V0,tag:W0,text:R0,url:To},K0={...nu,link:Ve(/^!?\[(label)\]\((.*?)\)/).replace("label",Qr).getRegex(),reflink:Ve(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Qr).getRegex()},Xa={...nu,emStrongRDelimAst:F0,emStrongLDelim:G0,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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Z0={...Xa,br:Ve(Ih).replace("{2,}","*").getRegex(),text:Ve(Xa.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ar={normal:eu,gfm:T0,pedantic:E0},fo={normal:nu,gfm:Xa,breaks:Z0,pedantic:K0},Y0={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ec=e=>Y0[e];function ln(e,t){if(t){if(Pt.escapeTest.test(e))return e.replace(Pt.escapeReplace,Ec)}else if(Pt.escapeTestNoEncode.test(e))return e.replace(Pt.escapeReplaceNoEncode,Ec);return e}function Ac(e){try{e=encodeURI(e).replace(Pt.percentDecode,"%")}catch{return null}return e}function Mc(e,t){var r;const n=e.replace(Pt.findPipe,(i,a,l)=>{let u=!1,c=a;for(;--c>=0&&l[c]==="\\";)u=!u;return u?"|":" |"}),s=n.split(Pt.splitPipe);let o=0;if(s[0].trim()||s.shift(),s.length>0&&!((r=s.at(-1))!=null&&r.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(Pt.slashPipe,"|");return s}function ho(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 X0(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 Rc(e,t,n,s,o){const r=t.href,i=t.title||null,a=e[1].replace(o.other.outputLinkReplace,"$1");s.state.inLink=!0;const l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:r,title:i,text:a,tokens:s.inlineTokens(a)};return s.state.inLink=!1,l}function J0(e,t,n){const s=e.match(n.other.indentCodeCompensation);if(s===null)return t;const o=s[1];return t.split(`
22
22
  `).map(r=>{const i=r.match(n.other.beginningSpace);if(i===null)return r;const[a]=i;return a.length>=o.length?r.slice(o.length):r}).join(`
@@ -237,4 +237,4 @@ XID_Start XIDS`.split(/\s/).map(e=>[Gi(e),e])),YC=new Map([["s",dt(383)],[dt(383
237
237
  `),s=t.split(`
238
238
  `);if(n.length+s.length>mI){const r=[];return n.forEach((i,a)=>r.push({type:"del",text:i,oldNo:a+1})),s.forEach((i,a)=>r.push({type:"add",text:i,newNo:a+1})),r}const o=vI(n,s);return yI(o,n,s,n.length,s.length)}function kI(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 wI=["old_string","oldString","old_str","old_text","oldText","old","search"],SI=["new_string","newString","new_str","new_text","newText","new","replace","content"],_I=["path","file_path","filePath","file","filename"];function wa(e,t){for(const n of t){const s=e[n];if(typeof s=="string"&&s.length>0)return s}}function $I(e){if(!e||typeof e!="object")return null;const t=e,n=wa(t,_I),s=wa(t,wI),o=wa(t,SI);if(!o&&!s)return null;const r=bI(s??"",o??""),i=kI(r);return{path:n,diff:r,stats:i}}const CI={class:"diff-lines"},xI={class:"dl-gutter old"},II={class:"dl-gutter new"},TI={class:"dl-sign"},EI={class:"dl-text"},AI=Ie({__name:"DiffLines",props:{lines:{}},setup(e){return(t,n)=>(m(),v("div",CI,[(m(!0),v(te,null,Ce(e.lines,(s,o)=>(m(),v("div",{key:o,class:ue(["dl",`dl-${s.type}`])},[h("span",xI,C(s.oldNo??""),1),h("span",II,C(s.newNo??""),1),h("span",TI,C(s.type==="add"?"+":s.type==="del"?"−":" "),1),h("span",EI,C(s.text),1)],2))),128))]))}}),wu=Te(AI,[["__scopeId","data-v-e2e145aa"]]),MI=["onKeydown"],RI={class:"tool-name"},PI=["title"],LI={key:1,class:"diff-chip"},DI={class:"tool-collapse-inner"},NI={class:"tool-body"},OI={key:1,class:"tool-result"},GI={key:2,class:"tool-running-hint"},BI=Ie({__name:"EditToolCard",props:{tool:{},live:{type:Boolean,default:!0},workDir:{default:""},sessionId:{default:""}},setup(e){const t=e,n=B(()=>Ri(t.tool,t.live)),s=B(()=>{switch(n.value){case"ok":return"✓";case"error":return"✗";default:return""}}),o=B(()=>$I(t.tool.args)),r=B(()=>{const b=o.value;if(!b||n.value==="error")return"";const{added:S,removed:w}=b.stats;return!S&&!w?"":`+${S} −${w}`}),i=B(()=>{var b;return(b=o.value)==null?void 0:b.path}),a=G(!1);let l=!1;Se(n,b=>{l||(a.value=b==="running")},{immediate:!0});function u(){l=!0,a.value=!a.value}const c=B(()=>{var b;return((b=o.value)==null?void 0:b.diff)??[]}),d=B(()=>c.value.length>0),f=zp(B(()=>t.tool),n,()=>t.live);function p(){const b=i.value;b&&vs(Kl(b,t.workDir||void 0),{modeHint:"diff",sessionId:t.sessionId||null})}const g=B(()=>{var w;const b=t.tool.progress;if(!b)return"";const S=b.split(`
239
239
  `).filter(k=>k.trim());return((w=S[S.length-1])==null?void 0:w.slice(0,60))??""});return(b,S)=>(m(),v("div",{class:ue(["tool-card",`is-${n.value}`,"edit-tool-card"])},[h("div",{class:"tool-header",role:"button",tabindex:"0",onClick:u,onKeydown:Vn(tt(u,["prevent"]),["enter"])},[h("span",{class:ue(["status-dot",n.value])},[s.value?(m(),v(te,{key:0},[Ae(C(s.value),1)],64)):F("",!0)],2),h("span",RI,C(e.tool.name),1),i.value?(m(),v("button",{key:0,class:"tool-filepath",title:`在文件面板中打开(diff) ${i.value}`,onClick:tt(p,["stop"])},C(i.value),9,PI)):F("",!0),r.value?(m(),v("span",LI,C(r.value),1)):F("",!0),U(f)?(m(),v("span",{key:2,class:ue(["tool-duration",{live:e.tool.durationMs===void 0}])},C(U(f)),3)):F("",!0),h("span",{class:ue(["tool-chevron",{open:a.value}])},"▸",2)],40,MI),h("div",{class:ue(["tool-collapse",{open:a.value}])},[h("div",DI,[h("div",NI,[d.value?(m(),De(wu,{key:0,lines:c.value},null,8,["lines"])):F("",!0),e.tool.output!==void 0?(m(),v("pre",OI,[h("code",null,C(e.tool.output||"(无输出)"),1)])):(m(),v("div",GI,C(g.value||"执行中…"),1))])])],2)],2))}}),FI=Te(BI,[["__scopeId","data-v-a5355539"]]),UI=["aria-expanded"],jI={class:"process-label"},zI={class:"process-meta"},HI=["title"],WI={class:"process-collapse"},qI={class:"process-inner"},VI={key:0,class:"process-more"},KI=["aria-expanded"],Sa=20,ZI=Ie({__name:"ToolGroup",props:{name:{},tools:{},live:{type:Boolean,default:!0},workDir:{default:""},sessionId:{default:""}},setup(e){const t=e,n=G(!1),s=B(()=>g0(t.tools,t.live)),o=B(()=>t.tools.filter(c=>c.output!==void 0&&!c.isError).length),r=B(()=>s.value==="running"?"执行中":s.value==="error"?"含失败调用":s.value==="suspended"?"含挂起等待":s.value==="unknown"?"结果未持久化":`已完成 ${o.value} 项`);function i(){n.value=!n.value}const a=G(!1),l=B(()=>Math.max(0,t.tools.length-Sa)),u=B(()=>a.value?t.tools:t.tools.slice(0,Sa));return(c,d)=>(m(),v("section",{class:ue(["tool-process",{open:n.value,running:s.value==="running",error:s.value==="error"}])},[h("button",{class:"process-head",type:"button","aria-expanded":n.value,onClick:i},[X(ce,{name:"chevron-down",size:12,class:"chevron"}),h("span",{class:ue(["process-dot",s.value]),"aria-hidden":"true"},null,2),h("span",jI,C(e.name),1),h("span",zI,C(r.value)+" · "+C(e.tools.length)+" 步",1),h("span",{class:"process-names",title:e.tools.map(f=>f.name).join("、")},C(e.tools.map(f=>f.name).join(" · ")),9,HI)],8,UI),h("div",WI,[h("div",qI,[(m(!0),v(te,null,Ce(u.value,f=>(m(),De(Tf(U(Sh)(f.name)?FI:gI),{key:f.toolCallId,tool:f,live:e.live,"work-dir":e.workDir,"session-id":e.sessionId},null,8,["tool","live","work-dir","session-id"]))),128)),n.value&&l.value>0?(m(),v("div",VI,[h("button",{type:"button",class:"process-more-btn","aria-expanded":a.value,onClick:d[0]||(d[0]=f=>a.value=!a.value)},C(a.value?`收起,只看前 ${Sa} 条`:`还有 ${l.value} 条 · 显示全部`),9,KI)])):F("",!0)])])],2))}}),YI=Te(ZI,[["__scopeId","data-v-4441817e"]]),XI={class:"thinking-block"},JI=["title"],QI={class:"teaser-text"},eT={class:"teaser-open"},tT={key:1,class:"thinking-stream","data-state":"running"},nT={class:"thinking-panel",role:"dialog","aria-label":"思考过程"},sT={class:"panel-body"},oT=Ie({__name:"ThinkingBlock",props:{tool:{},active:{type:Boolean,default:!1},sessionId:{default:""},msgSeq:{default:void 0}},setup(e){const t=e,n=G(!1),s=G(null),o=G(!1),r=G(!1),i=G(t.tool.output??"");Se(()=>t.tool.output,f=>{f!==void 0&&!o.value&&!r.value&&(i.value=f)});const a=B(()=>!!t.tool.truncated);async function l(){if(!(!a.value||r.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&&(i.value=p.output,r.value=!0)}catch{}finally{o.value=!1}}}const u=B(()=>i.value.split(/\n+/).map(p=>p.trim()).filter(Boolean).at(-1)??"");Se(i,()=>{t.active&&Fe(()=>{const f=s.value;f&&(f.scrollTop=f.scrollHeight)})});function c(){l(),n.value=!0}function d(){n.value=!1}return(f,p)=>(m(),v("div",XI,[e.active?(m(),v("div",tT,[p[1]||(p[1]=h("div",{class:"stream-header"},[h("span",{class:"stream-icon"},"💭"),h("span",{class:"stream-title"},"思考中…"),h("span",{class:"stream-dot"})],-1)),h("div",{ref_key:"streamRef",ref:s,class:"stream-body"},C(i.value),513)])):(m(),v("button",{key:0,class:"thinking-teaser",title:a.value?"思考较长,点击查看完整思考过程":"点击查看完整思考过程",onClick:c},[p[0]||(p[0]=h("span",{class:"teaser-icon"},"💭",-1)),h("span",QI,C(o.value?"加载完整思考…":u.value||"思考过程"),1),h("span",eT,C(a.value?"查看全文":"展开"),1)],8,JI)),(m(),De(Js,{to:"body"},[n.value?(m(),v("div",{key:0,class:"thinking-overlay",onClick:tt(d,["self"])},[h("aside",nT,[h("header",{class:"panel-header"},[p[2]||(p[2]=h("span",null,"💭 思考过程",-1)),h("button",{class:"panel-close","aria-label":"关闭",onClick:d},"✕")]),h("div",sT,C(i.value||"(空)"),1)])])):F("",!0)]))]))}}),rT=Te(oT,[["__scopeId","data-v-9382b07d"]]),iT={key:0,class:"clock"},aT={class:"stat"},lT={class:"stat"},uT={class:"stat"},cT={class:"stat"},dT={class:"stat"},fT={class:"stat"},hT=Ie({__name:"TurnStats",props:{stats:{},inline:{type:Boolean}},setup(e){const t=e,n=G(null);let s=null;function o(){s!==null&&(clearInterval(s),s=null)}function r(){o();const l=t.stats.llmMs??0,u=Date.now();n.value=l,s=setInterval(()=>{n.value=l+(Date.now()-u)},300)}Se(()=>t.stats.status,l=>{l==="running"?r():o()},{immediate:!0}),st(o);function i(l){return l==null?"—":l<1e3?`${Math.round(l)}ms`:`${(l/1e3).toFixed(1)}s`}function a(l){return l==null?"—":l>=1e3?`${(l/1e3).toFixed(1)}k`:`${l}`}return(l,u)=>(m(),v("div",{class:ue(["turn-stats",[`is-${e.stats.status}`,{"is-inline":e.inline}]]),"aria-live":"polite"},[e.stats.status==="running"?(m(),v(te,{key:0},[u[0]||(u[0]=h("span",{class:"badge-gradient"},"正在思考",-1)),n.value!==null?(m(),v("span",iT,C(i(n.value)),1)):F("",!0)],64)):(m(),v(te,{key:1},[h("span",aT,C(e.stats.turn)+" 轮 · "+C(e.stats.step)+" 步",1),u[10]||(u[10]=h("span",{class:"dot"},"·",-1)),h("span",lT,[u[1]||(u[1]=h("span",{class:"k"},"LLM",-1)),Ae(" "+C(i(e.stats.llmMs)),1)]),e.stats.toolMs?(m(),v(te,{key:0},[u[3]||(u[3]=h("span",{class:"dot"},"·",-1)),h("span",uT,[u[2]||(u[2]=h("span",{class:"k"},"工具",-1)),Ae(" "+C(i(e.stats.toolMs)),1)])],64)):F("",!0),e.stats.firstTokenMs!==null&&e.stats.firstTokenMs!==void 0?(m(),v(te,{key:1},[u[5]||(u[5]=h("span",{class:"dot"},"·",-1)),h("span",cT,[u[4]||(u[4]=h("span",{class:"k"},"首token",-1)),Ae(" "+C(i(e.stats.firstTokenMs)),1)])],64)):F("",!0),e.stats.tokens!==null&&e.stats.tokens!==void 0?(m(),v(te,{key:2},[u[7]||(u[7]=h("span",{class:"dot"},"·",-1)),h("span",dT,[u[6]||(u[6]=h("span",{class:"k"},"tokens",-1)),Ae(" "+C(a(e.stats.tokens)),1)])],64)):F("",!0),e.stats.tokensPerSec!==null&&e.stats.tokensPerSec!==void 0?(m(),v(te,{key:3},[u[9]||(u[9]=h("span",{class:"dot"},"·",-1)),h("span",fT,[u[8]||(u[8]=h("span",{class:"k"},"tok/s",-1)),Ae(" "+C(e.stats.tokensPerSec),1)])],64)):F("",!0)],64))],2))}}),Cd=Te(hT,[["__scopeId","data-v-dad21b9b"]]),pT=["data-message-id","data-message-role"],gT={key:0,class:"user-wrap"},mT={class:"user-head"},vT={key:0,class:"meta-time"},yT={class:"user-avatar","aria-hidden":"true"},bT={class:"user-bubble"},kT=["title","onClick"],wT={key:0,class:"message-meta user-meta"},ST={key:1,class:"assistant-wrap"},_T={key:0,class:"assistant-brand"},$T=["title"],CT={key:1,class:"brand-streaming"},xT={key:3,class:"brand-time"},IT={class:"assistant-body"},TT={key:0,class:"degraded-note"},ET={key:4,class:"streaming-cursor","aria-label":"正在生成"},AT={key:6,class:"written-files",role:"group","aria-label":"本回合写入的文件"},MT=["title","onClick"],RT={class:"written-file-name"},PT={key:7,class:"message-meta"},LT=["title"],DT=["title"],NT=Ie({__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},showModel:{type:Boolean,default:!0},sessionId:{default:""},workDir:{default:""}},emits:["edit","retry","fork"],setup(e,{emit:t}){const n=e,s=t,o=G(!1);let r=null;const i=B(()=>n.message.role==="user"),a=B(()=>n.message.role==="assistant"),l=B(()=>{var W;return((W=n.message.turnStats)==null?void 0:W.status)==="running"}),u=B(()=>n.message.tools.filter(W=>W.name==="thinking")),c=B(()=>n.message.tools.filter(W=>W.name!=="thinking")),d=B(()=>n.message.ts!==void 0?d0(n.message.ts):""),f=B(()=>{const W=n.message.model??"",j=W.lastIndexOf("/");return j>=0&&j<W.length-1?W.slice(j+1):W}),p=B(()=>i.value&&n.isLatestUser&&n.idle),g=B(()=>a.value&&!n.streaming?v0(n.message,n.workDir||void 0):[]);function b(W){return W.split("/").pop()||W}function S(W){vs(W,{sessionId:n.sessionId||void 0})}const w=/(^|\s)@("[^"\n]+"|[^\s"]+)/g;function k(W){if(!W||W.startsWith("/")||W.startsWith("~"))return W;const j=n.workDir.trim();if(!j)return W;let ne=W;for(;ne.startsWith("./");)ne=ne.slice(2);return`${j.replace(/\/+$/,"")}/${ne}`}const y=B(()=>{const W=n.message.content;if(!i.value||!W||!W.includes("@"))return[];const j=[];let ne=0;w.lastIndex=0;let I;for(;(I=w.exec(W))!==null;){const M=I.index+I[1].length;M>ne&&j.push({text:W.slice(ne,M),path:null});const V=I[2],ie=V.startsWith('"')?V.slice(1,-1):V;j.push({text:W.slice(M,M+1+V.length),path:k(ie)}),ne=M+1+V.length}return ne<W.length&&j.push({text:W.slice(ne),path:null}),j});function _(W){vs(W,{sessionId:n.sessionId||void 0})}const N=In("showThinking",G(!0)),D=In("showTools",G(!0)),E=G(!1);let A=null;function T(){if(typeof window>"u"||!("speechSynthesis"in window))return;if(E.value){window.speechSynthesis.cancel(),E.value=!1,A=null;return}const W=n.message.content;if(!W)return;const j=new SpeechSynthesisUtterance(W);j.lang="zh-CN";const ne=()=>{A===ne&&(E.value=!1,A=null)};A=ne,j.addEventListener("end",ne),j.addEventListener("error",ne),window.speechSynthesis.cancel(),requestAnimationFrame(()=>{window.speechSynthesis.speak(j)}),E.value=!0}st(()=>{E.value&&"speechSynthesis"in window&&window.speechSynthesis.cancel()});async function Z(){try{await navigator.clipboard.writeText(n.message.content)}catch{const W=document.createElement("textarea");W.value=n.message.content,document.body.append(W),W.select(),document.execCommand("copy"),W.remove()}o.value=!0,r!==null&&clearTimeout(r),r=window.setTimeout(()=>{o.value=!1},1500)}return(W,j)=>(m(),v("article",{class:ue(["message",e.message.role,{error:e.message.isError}]),"data-message-id":e.message.id,"data-message-role":e.message.role},[i.value?(m(),v("div",gT,[h("div",mT,[d.value?(m(),v("span",vT,C(d.value),1)):F("",!0),j[3]||(j[3]=h("span",{class:"head-name"},"你",-1)),h("span",yT,[X(ce,{name:"user",size:12})])]),h("div",bT,[y.value.length?(m(!0),v(te,{key:0},Ce(y.value,(ne,I)=>(m(),v(te,{key:I},[ne.path!==null?(m(),v("button",{key:0,class:"at-link",title:`在文件面板中打开 ${ne.path}`,onClick:M=>_(ne.path??"")},C(ne.text),9,kT)):(m(),v(te,{key:1},[Ae(C(ne.text),1)],64))],64))),128)):(m(),v(te,{key:1},[Ae(C(e.message.content),1)],64))]),p.value?(m(),v("div",wT,[h("button",{title:"编辑并重新发送",onClick:j[0]||(j[0]=ne=>s("edit",e.message.content))},[X(ce,{name:"edit",size:12}),j[4]||(j[4]=Ae("编辑重发",-1))])])):F("",!0)])):(m(),v("div",ST,[a.value&&(e.message.model&&e.showModel||e.streaming||l.value||e.showTimestamp&&d.value)?(m(),v("div",_T,[e.message.model&&e.showModel?(m(),v("span",{key:0,class:"brand-model",title:e.message.model},C(f.value),9,$T)):F("",!0),e.streaming?(m(),v("span",CT,[...j[5]||(j[5]=[h("i",{"aria-hidden":"true"},null,-1),Ae("生成中",-1)])])):F("",!0),l.value?(m(),De(Cd,{key:2,stats:e.message.turnStats,inline:""},null,8,["stats"])):F("",!0),e.showTimestamp&&d.value?(m(),v("time",xT,C(d.value),1)):F("",!0)])):F("",!0),h("div",IT,[e.message.degraded?(m(),v("p",TT,"该回合早于持久化快照:正文与思考在服务重启后无法恢复(工具记录与消息结构已保留)。")):F("",!0),U(N)?(m(!0),v(te,{key:1},Ce(u.value,ne=>(m(),De(rT,{key:ne.toolCallId,tool:ne,active:e.streaming,"session-id":e.sessionId,"msg-seq":e.message.seq},null,8,["tool","active","session-id","msg-seq"]))),128)):F("",!0),c.value.length&&U(D)?(m(),De(YI,{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"])):F("",!0),e.message.content?(m(),De(jp,{key:3,class:"assistant-content",content:e.message.content,streaming:e.streaming},null,8,["content","streaming"])):e.streaming?(m(),v("span",ET)):F("",!0),e.message.turnStats&&e.message.turnStats.status!=="running"?(m(),De(Cd,{key:5,stats:e.message.turnStats},null,8,["stats"])):F("",!0),g.value.length?(m(),v("div",AT,[(m(!0),v(te,null,Ce(g.value,ne=>(m(),v("button",{key:ne.filePath,type:"button",class:"written-file",title:`在文件面板中打开 ${ne.filePath}`,onClick:I=>S(ne.filePath)},[X(ce,{name:"file",size:12}),h("span",RT,C(b(ne.filePath)),1)],8,MT))),128))])):F("",!0),e.message.content||e.message.isError&&!e.streaming||e.canFork?(m(),v("div",PT,[e.message.content?(m(),v("button",{key:0,title:o.value?"已复制":"复制内容",onClick:Z},[X(ce,{name:o.value?"check":"copy",size:12},null,8,["name"]),Ae(C(o.value?"已复制":"复制"),1)],8,LT)):F("",!0),e.message.content?(m(),v("button",{key:1,title:E.value?"停止朗读":"朗读",onClick:T},[X(ce,{name:E.value?"speaker-off":"speaker",size:12},null,8,["name"]),Ae(C(E.value?"停止":"朗读"),1)],8,DT)):F("",!0),e.message.isError&&!e.streaming?(m(),v("button",{key:2,class:"retry-btn",title:"重发最后一条消息",onClick:j[1]||(j[1]=ne=>s("retry"))},[X(ce,{name:"refresh",size:12}),j[6]||(j[6]=Ae("重试",-1))])):F("",!0),a.value&&e.canFork&&!e.streaming?(m(),v("button",{key:3,title:"以当前对话为起点创建一个新会话",onClick:j[2]||(j[2]=ne=>s("fork"))},[X(ce,{name:"fork",size:12}),j[7]||(j[7]=Ae("Fork",-1))])):F("",!0)])):F("",!0)])]))],10,pT))}}),OT=Te(NT,[["__scopeId","data-v-c06917b6"]]),GT=["title","aria-label","onMouseenter","onClick"],BT={key:0,class:"minimap-tooltip"},FT="(min-width: 960px)",UT="(prefers-reduced-motion: reduce)",jT=24,zT=1e3,HT=Ie({__name:"ChatMinimap",props:{messages:{},host:{},revision:{},revealMessage:{type:Function}},setup(e){const t=e,n=G(null),s=typeof window.matchMedia=="function",o=s?window.matchMedia(FT):null,r=s?window.matchMedia(UT):null,i=G((o==null?void 0:o.matches)??!1),a=G((r==null?void 0:r.matches)??!1);function l(oe){i.value=oe.matches}function u(oe){a.value=oe.matches}et(()=>o==null?void 0:o.addEventListener("change",l)),st(()=>o==null?void 0:o.removeEventListener("change",l)),et(()=>r==null?void 0:r.addEventListener("change",u)),st(()=>r==null?void 0:r.removeEventListener("change",u));function c(oe){var $e;const ge=(($e=oe.content)==null?void 0:$e.length)??0;return ge<=0?.2:.2+.8*(1-1/(1+ge/200))}const d=B(()=>{let oe=0;return t.messages.map((ge,$e)=>{const Ne=c(ge),Ue={id:ge.id??`seq-${$e}`,seq:ge.seq??$e,role:ge.role??"tool",ratio:Ne,offset:oe};return oe+=Ne,Ue})}),f=B(()=>d.value.reduce((oe,ge)=>oe+ge.ratio,0)||1),p=G({scrollTop:0,scrollHeight:0,clientHeight:0,trackHeight:0}),g=G(!1),b=G(!1),S=G(!1),w=G(null),k=B(()=>p.value.scrollHeight>p.value.clientHeight),y=B(()=>{const{scrollTop:oe,scrollHeight:ge,clientHeight:$e,trackHeight:Ne}=p.value;if(!g.value||!k.value||Ne<=0)return{};const Ue=Math.max(jT,$e/ge*Ne),Ke=Math.max(Ne-Ue,0);return{top:`${Math.min(Math.max(oe/ge*Ne,0),Ke)}px`,height:`${Ue}px`}}),_=B(()=>b.value||n.value!==null),N=B(()=>S.value&&!_.value&&!a.value);let D=null;function E(){S.value=!1,!a.value&&(D!==null&&clearTimeout(D),D=setTimeout(()=>{D=null,S.value=!0},zT))}function A(){D!==null&&(clearTimeout(D),D=null)}let T=null;function Z(){var $e;const oe=t.host;if(!oe){g.value=!1;return}const ge=(($e=w.value)==null?void 0:$e.clientHeight)??0;p.value={scrollTop:oe.scrollTop,scrollHeight:oe.scrollHeight,clientHeight:oe.clientHeight,trackHeight:ge||oe.clientHeight},g.value=oe.scrollHeight>0}function W(){T===null&&(T=requestAnimationFrame(()=>{T=null,Z()}))}function j(){E(),W()}function ne(){b.value=!0,E()}function I(){b.value=!1,E()}let M=null;function V(){const oe=t.host;M==null||M.disconnect(),M=null,oe&&(oe.addEventListener("scroll",j,{passive:!0}),typeof ResizeObserver<"u"&&(M=new ResizeObserver(()=>W()),M.observe(oe)))}function ie(){var oe;(oe=t.host)==null||oe.removeEventListener("scroll",j),M==null||M.disconnect(),M=null}et(()=>{i.value&&(V(),E(),W())}),st(()=>{ie(),A(),T!==null&&(cancelAnimationFrame(T),T=null)}),Se([()=>t.host,i],()=>{ie(),g.value=!1,Fe(()=>{i.value&&(V(),W())})});const me=B(()=>{var oe,ge;return`${((oe=t.messages[0])==null?void 0:oe.id)??""}|${((ge=t.messages.at(-1))==null?void 0:ge.id)??""}`});let _e="",he="";Se(me,oe=>{const[ge,$e]=oe.split("|"),Ne=_e!==""&&ge!==_e&&$e!==he;_e=ge??"",he=$e??"",Ne&&(g.value=!1),W()},{immediate:!0}),Se(k,oe=>{oe&&Fe(W)}),Se([()=>t.messages.length,()=>t.revision,f,i],()=>{W()});function ae(oe){var Ue;const ge=t.host;if(!ge)return;(Ue=t.revealMessage)==null||Ue.call(t,oe);const $e=`[data-message-id="${CSS.escape(oe)}"]`,Ne=()=>{var Ke;(Ke=ge.querySelector($e))==null||Ke.scrollIntoView({behavior:"smooth",block:"start"})};ge.querySelector($e)?Ne():Fe(Ne)}function pe(oe){const ge=oe.role==="user"?"用户":oe.role==="assistant"?"助手":"工具";return`#${oe.seq} ${ge}`}return(oe,ge)=>i.value&&d.value.length>0&&k.value?(m(),v("div",{key:0,class:ue(["minimap",{"is-quiet":N.value,"is-hovered":_.value}]),role:"navigation","aria-label":"消息地图",onPointerenter:ne,onPointerleave:I},[h("div",{ref_key:"trackRef",ref:w,class:"minimap-track"},[(m(!0),v(te,null,Ce(d.value,$e=>(m(),v("button",{key:$e.id,class:ue(["minimap-block",`role-${$e.role}`]),style:bt({top:`${$e.offset/f.value*100}%`,height:`${Math.max($e.ratio/f.value*100,2)}%`}),title:pe($e),"aria-label":pe($e),onMouseenter:Ne=>n.value=$e.seq,onMouseleave:ge[0]||(ge[0]=Ne=>n.value=null),onClick:Ne=>ae($e.id)},[n.value===$e.seq?(m(),v("span",BT,C(pe($e)),1)):F("",!0)],46,GT))),128)),h("div",{class:ue(["minimap-thumb",{"is-ready":g.value}]),style:bt(y.value),"aria-hidden":"true"},null,6)],512)],34)):F("",!0)}}),WT=Te(HT,[["__scopeId","data-v-b3335103"]]);function xd(e,t){return e-t}function Id(e,t){return Math.max(0,e-t)}const qT={class:"message-list-wrapper"},VT={key:0,class:"conn-banner",role:"status"},KT=["disabled"],ZT={key:0,class:"day-divider",role:"separator"},YT={key:1,class:"turn-divider","aria-hidden":"true"},XT={key:1,class:"message-skeleton","aria-hidden":"true"},JT=["aria-label"],QT={key:0,class:"scroll-badge"},eE=80,tE=40,nE=8,Td=24,sE=Ie({__name:"MessageList",props:{messages:{},busy:{type:Boolean,default:!1},workDir:{default:null},sessionId:{default:""},connected:{type:Boolean,default:!1},olderAvailable:{type:Boolean,default:!1},olderLoading:{type:Boolean,default:!1}},emits:["edit","retry-connection","retry-message","load-older","fork"],setup(e,{emit:t}){const n=e,s=t,o=G(null),r=G(null);let i=null;const a=B(()=>{for(let $=n.messages.length-1;$>=0;$--)if(n.messages[$].role==="user")return n.messages[$].id;return null}),l=B(()=>{var $;return(($=n.messages.at(-1))==null?void 0:$.id)??null}),u=B(()=>{var $;return(($=[...n.messages].reverse().find(H=>H.role==="assistant"))==null?void 0:$.id)??null});function c($){const H=n.messages[$];if(!H)return!1;if(H.role!=="assistant")return!0;const q=n.messages[$+1];return!q||q.role!=="assistant"||H.ts!==void 0&&q.ts!==void 0&&q.ts-H.ts>300*1e3}function d($){const H=n.messages[$];if(!H||H.role!=="assistant"||!H.model)return!1;const q=n.messages[$-1];return!q||q.role!=="assistant"?!0:q.model!==H.model}function f($){const H=n.messages[$];return!!H&&$>0&&H.role==="user"}function p($){const H=n.messages[$],q=$>0?n.messages[$-1]:void 0;return!H||!q||H.ts===void 0||q.ts===void 0||f0(q.ts,H.ts)?null:h0(H.ts)}const g={streaming:!1,isLatestUser:!1,canFork:!1,showTimestamp:!1,showModel:!1,idle:!0},b=B(()=>{const $=a.value,H=l.value,q=u.value,se=[];return n.messages.forEach((fe,ye)=>{const Ee=p(ye);Ee!==null?se.push({kind:"day-divider",key:`${fe.id}-divider`,dividerText:Ee,flags:g}):f(ye)&&se.push({kind:"turn-divider",key:`${fe.id}-divider`,dividerText:null,flags:g}),se.push({kind:"message",key:fe.id,message:fe,dividerText:null,flags:{streaming:n.busy&&fe.id===H&&fe.role==="assistant",isLatestUser:fe.id===$,canFork:!n.busy&&fe.id===q,showTimestamp:c(ye),showModel:d(ye),idle:!n.busy}})}),se});function S($){return Math.max(0,$-eE)}const w=G(S(b.value.length)),k=B(()=>{const $=b.value.length,H=Math.min(Math.max(0,w.value),$);return b.value.slice(H)}),y=B(()=>w.value>0||n.olderAvailable);function _($){const H=b.value;for(let q=0;q<H.length;q++){const se=H[q];if(se.kind==="message"&&se.message.id===$)return q}return-1}function N($){const H=_($);return H<0?!1:(H>=w.value||D(()=>{w.value=Math.max(0,H-nE)}),!0)}function D($){const H=o.value;if(!H){$();return}const q=xd(H.scrollHeight,H.scrollTop);$(),Fe(()=>{const se=o.value;se&&(se.scrollTop=Id(se.scrollHeight,q))})}let E=!1;const A=B(()=>{var q;const $=n.messages.at(-1);if(!$)return 0;let H=$.content.length;for(const se of $.tools)H+=((q=se.output)==null?void 0:q.length)??0;return H});let T=!1;const Z=G(!1),W=G(0);function j(){const $=o.value;return $?$.scrollHeight-$.scrollTop-$.clientHeight<Td:!0}function ne(){return typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function I($){w.value=S(b.value.length),requestAnimationFrame(()=>{const H=o.value;if(!H)return;const q=ne()?"auto":$;q==="smooth"&&_e(),H.scrollTo({top:H.scrollHeight,behavior:q})})}let M=!1,V=null,ie=null;function me(){const $=o.value;V&&$&&$.removeEventListener("scrollend",V),V=null,M=!1,ie!==null&&(clearTimeout(ie),ie=null)}function _e(){const $=o.value;$&&(me(),M=!0,V=()=>me(),$.addEventListener("scrollend",V),ie=setTimeout(me,1500))}function he(){const $=o.value;!M||!$||($.scrollTo({top:$.scrollTop,behavior:"auto"}),me())}let ae=null,pe=null,oe=0,ge=null;const $e=new Set;function Ne(){const $=pe,H=o.value;if(!$||!H)return;const q=new Set(Array.from(H.children));for(const se of Array.from($e))q.has(se)||($.unobserve(se),$e.delete(se));for(const se of q)$e.has(se)||($.observe(se),$e.add(se))}function Ue(){const $=o.value;if(!$)return;const H=$.scrollHeight,q=H>oe;oe=H,q&&(J||E||(T||j())&&ge===null&&(ge=requestAnimationFrame(()=>{ge=null,I("auto")})))}function Ke($){return $.seq!==void 0?`${$.role}:${$.seq}`:`id:${$.id}`}function Ye($){for(const H of n.messages)if(Ke(H)===$)return H;return null}function rt($){const H=$.querySelectorAll("[data-message-id]");for(const q of H)if(q.offsetTop+q.offsetHeight>$.scrollTop){const se=q.dataset.messageId;if(se)return{id:se,offsetTop:q.offsetTop}}return null}function Dt(){const $=o.value,H=n.sessionId;!$||!H||ae===null&&(ae=requestAnimationFrame(()=>{ae=null;try{const q=rt($);if(!q)return;const se=n.messages.find(ye=>ye.id===q.id),fe=se?Ke(se):`id:${q.id}`;localStorage.setItem(`scream-scroll:${H}`,`v3:${fe}:${Math.round(q.offsetTop-$.scrollTop)}`)}catch{}}))}function x($){try{return localStorage.getItem(`scream-scroll:${$}`)!==null}catch{return!1}}function P(){w.value=S(b.value.length);const $=o.value;$&&($.scrollTop=$.scrollHeight)}async function z($,H){if(!N($))return"unusable";await Fe();const q=o.value;if(!q)return"unusable";const se=Array.from(q.querySelectorAll("[data-message-id]")).find(fe=>fe.dataset.messageId===$);return se?(q.scrollTop=se.offsetTop-H,"restored"):"unusable"}async function ee(){const $=o.value,H=n.sessionId;if(!$||!H)return"missing";let q=null;try{q=localStorage.getItem(`scream-scroll:${H}`)}catch{}if(!q)return"missing";if(q.startsWith("v3:")){const fe=q.slice(3),ye=fe.lastIndexOf(":");if(ye<=0)return"unusable";const Ee=fe.slice(0,ye),ke=Number(fe.slice(ye+1));if(!Number.isFinite(ke))return"unusable";const be=Ye(Ee);return be?z(be.id,ke):"unusable"}if(q.startsWith("v2:")){const fe=q.split(":"),ye=fe[1],Ee=Number(fe[2]);return!ye||!Number.isFinite(Ee)||!n.messages.some(ke=>ke.id===ye)?"unusable":z(ye,Ee)}const se=Number(q);if(!Number.isFinite(se))return"unusable";if(!(se>0))return"restored";if(se>$.scrollHeight-$.clientHeight&&w.value>0){w.value=0,await Fe();const fe=o.value;return fe&&(fe.scrollTop=se),"restored"}return $.scrollTop=se,"restored"}let J=!1;Se(()=>{var $;return[(($=n.messages[0])==null?void 0:$.id)??null,n.messages.length,n.sessionId]},([$,H,q],[se,fe,ye])=>{const Ee=H>0&&$!==null&&se!==null&&$!==se&&H>(fe??0)&&q===ye;if(J=Ee,!Ee)return;E=!0;const ke=o.value;if(!ke)return;const be=xd(ke.scrollHeight,ke.scrollTop);Fe(()=>{ke.scrollTop=Id(ke.scrollHeight,be)})}),Se(()=>b.value.length,($,H)=>{const q=H??0;if(E){E=!1;return}w.value===S(q)&&!Z.value?w.value=S($):w.value>S($)&&D(()=>{w.value=S($)})});function R(){const $=o.value;if(!$)return;const H=$.scrollHeight-$.scrollTop-$.clientHeight>Td;Z.value=H,H||(W.value=0),H&&T&&(T=!1),n.busy||Dt()}let K="";Se(()=>n.sessionId,()=>{K="",W.value=0,J=!1,w.value=S(b.value.length)}),Se(()=>[n.messages.length,A.value],([$],[H])=>{if($!==H){const q=J;if(J=!1,$>0&&K!==n.sessionId){K=n.sessionId;const se=(H??0)===0;if(se&&!x(n.sessionId)){Fe(P);return}requestAnimationFrame(()=>requestAnimationFrame(async()=>{const fe=await ee();fe!=="restored"&&(se||fe==="unusable")&&P()}));return}if(q)return;if(!j()){W.value=Math.max(0,W.value+Math.max(0,$-(H??0)));return}T=!0,Z.value=!1,I("smooth");return}!T&&!j()||I("auto")}),Se(()=>n.busy,$=>{$||(T=!1)});function O(){T=!0,Z.value=!1,W.value=0,I("smooth")}const Q=B(()=>!n.busy||n.messages.length===0?!1:n.messages.at(-1).role==="user");return et(()=>{var $,H,q,se;($=o.value)==null||$.addEventListener("scroll",R,{passive:!0}),(H=o.value)==null||H.addEventListener("wheel",he,{passive:!0}),(q=o.value)==null||q.addEventListener("touchstart",he,{passive:!0}),typeof IntersectionObserver<"u"&&(i=new IntersectionObserver(fe=>{var ye;(ye=fe[0])!=null&&ye.isIntersecting&&(w.value>0&&D(()=>{w.value=Math.max(0,w.value-tE)}),w.value===0&&n.olderAvailable&&!n.olderLoading&&n.messages.length>0&&s("load-older"))},{root:o.value,rootMargin:"120px 0px 0px 0px"}),r.value&&i.observe(r.value)),typeof ResizeObserver<"u"&&(oe=((se=o.value)==null?void 0:se.scrollHeight)??0,pe=new ResizeObserver(Ue),Ne()),Rl(()=>Ne()),requestAnimationFrame(()=>requestAnimationFrame(async()=>{await ee()==="unusable"&&P()}))}),$i(()=>{var $,H,q;($=o.value)==null||$.removeEventListener("scroll",R),(H=o.value)==null||H.removeEventListener("wheel",he),(q=o.value)==null||q.removeEventListener("touchstart",he),i==null||i.disconnect(),i=null,pe==null||pe.disconnect(),pe=null,$e.clear(),ge!==null&&(cancelAnimationFrame(ge),ge=null),me(),ae!==null&&(cancelAnimationFrame(ae),ae=null)}),Se(r,$=>{i&&(i.disconnect(),$&&i.observe($))}),($,H)=>(m(),v("div",qT,[!e.connected&&e.messages.length>0?(m(),v("div",VT,[H[7]||(H[7]=h("span",{class:"conn-dot","aria-hidden":"true"},null,-1)),H[8]||(H[8]=h("span",null,"连接中断,自动恢复中…",-1)),h("button",{class:"conn-retry",onClick:H[0]||(H[0]=q=>s("retry-connection"))},"立即重试")])):F("",!0),h("div",{ref_key:"listRef",ref:o,class:"message-list"},[y.value?(m(),v("div",{key:0,ref_key:"topSentinelRef",ref:r,class:"load-older-row"},[e.olderAvailable?(m(),v("button",{key:0,class:"load-older-btn",disabled:e.olderLoading,onClick:H[1]||(H[1]=q=>s("load-older"))},C(e.olderLoading?"加载中…":"加载更早消息"),9,KT)):F("",!0)],512)):F("",!0),(m(!0),v(te,null,Ce(k.value,(q,se,fe,ye)=>{const Ee=[q.message,q.flags.streaming,q.flags.isLatestUser,q.flags.canFork,q.flags.showTimestamp,q.flags.showModel,q.flags.idle,q.dividerText,e.busy,e.sessionId,e.workDir];if(ye&&ye.el&&ye.key===q.key&&Xm(ye,Ee))return ye;const ke=(m(),v(te,{key:q.key},[q.kind==="day-divider"?(m(),v("div",ZT,[h("span",null,C(q.dividerText),1)])):q.kind==="turn-divider"?(m(),v("div",YT)):(m(),De(OT,{key:2,message:q.message,"is-latest-user":q.flags.isLatestUser,idle:q.flags.idle,streaming:q.flags.streaming,"session-id":e.sessionId,"can-fork":q.flags.canFork,"show-timestamp":q.flags.showTimestamp,"show-model":q.flags.showModel,"work-dir":e.workDir??void 0,onEdit:H[2]||(H[2]=be=>s("edit",be)),onRetry:H[3]||(H[3]=be=>s("retry-message")),onFork:H[4]||(H[4]=be=>s("fork"))},null,8,["message","is-latest-user","idle","streaming","session-id","can-fork","show-timestamp","show-model","work-dir"]))],64));return ke.memo=Ee,ke},H,5),128)),Q.value?(m(),v("div",XT,[...H[9]||(H[9]=[h("div",{class:"sk-body"},[h("div",{class:"sk-line sk-w-60"}),h("div",{class:"sk-line sk-w-90"}),h("div",{class:"sk-line sk-w-40"})],-1)])])):F("",!0)],512),X(WT,{messages:e.messages,host:o.value,revision:w.value,"reveal-message":N},null,8,["messages","host","revision"]),X(Ol,{name:"scroll-btn"},{default:ot(()=>[Z.value?(m(),v("button",{key:0,class:ue(["scroll-to-bottom",{streaming:e.busy}]),title:"滚动到最新消息","aria-label":W.value>0?`滚动到最新消息,${W.value} 条新消息`:"滚动到最新消息",onClick:O},[X(ce,{name:"chevron-down",size:18}),W.value>0?(m(),v("span",QT,C(W.value>99?"99+":W.value),1)):F("",!0)],10,JT)):F("",!0)]),_:1})]))}}),oE=Te(sE,[["__scopeId","data-v-af6b9f2e"]]),rE={class:"stats-head"},iE={class:"stats-body"},aE={class:"stats-section"},lE={class:"stats-label-row"},uE={class:"stats-value mono"},cE=["aria-valuenow","aria-label"],dE={key:0,class:"stats-section"},fE={class:"stats-label-row"},hE={class:"stats-value mono"},pE={class:"stats-section"},gE={class:"stats-label-row"},mE={class:"stats-value mono"},vE={class:"stats-grid"},yE={class:"stats-cell-label"},bE={class:"stats-cell-value mono"},kE={key:1,class:"stats-section"},wE=["title"],SE={class:"model-tokens mono"},_E={class:"model-dims mono"},$E={key:1,class:"stats-empty"},CE=Ie({__name:"SessionStatsPanel",props:{status:{},fetchUsage:{type:Function},fetchContext:{type:Function}},emits:["close"],setup(e,{emit:t}){const n=e,s=t,o=G(null);et(()=>{n.fetchUsage(),n.fetchContext()});function r(k){const y=o.value;y&&!y.contains(k.target)&&s("close")}function i(k){k.key==="Escape"&&s("close")}et(()=>{document.addEventListener("pointerdown",r),window.addEventListener("keydown",i)}),st(()=>{document.removeEventListener("pointerdown",r),window.removeEventListener("keydown",i)});function a(k){return k?k.inputOther+k.output+k.inputCacheRead+k.inputCacheCreation:0}function l(k){return typeof k!="number"?"-":k>=1e6?`${(k/1e6).toFixed(1)}M`:k>=1e3?`${(k/1e3).toFixed(1)}k`:String(k)}function u(k){return typeof k=="number"?k.toLocaleString():"-"}const c=B(()=>{const k=n.status.contextUsage;if(typeof k=="number"&&Number.isFinite(k)){const N=k>1?k:k*100;return Math.max(0,Math.min(N,100))}const y=n.status.contextTokens??0,_=n.status.maxContextTokens??0;return _<=0?0:Math.max(0,Math.min(y/_*100,100))}),d=B(()=>typeof n.status.contextTokens=="number"&&typeof n.status.maxContextTokens=="number"?`${u(n.status.contextTokens)} / ${u(n.status.maxContextTokens)}`:c.value>0?`${c.value.toFixed(1)}%`:"-"),f=B(()=>{var k;return(k=n.status.usage)==null?void 0:k.total}),p=B(()=>{var k;return(k=n.status.usage)==null?void 0:k.currentTurn}),g=B(()=>a(f.value)),b=B(()=>{var y;const k=(y=n.status.usage)==null?void 0:y.byModel;return k?Object.entries(k).map(([_,N])=>({model:_,tokens:a(N),input:N.inputOther,output:N.output,cacheRead:N.inputCacheRead,cacheCreation:N.inputCacheCreation})):[]}),S=B(()=>g.value>0||b.value.length>0||a(p.value)>0),w=B(()=>{var k,y,_,N;return[{key:"input",label:"输入",value:(k=f.value)==null?void 0:k.inputOther},{key:"output",label:"输出",value:(y=f.value)==null?void 0:y.output},{key:"cacheRead",label:"缓存读",value:(_=f.value)==null?void 0:_.inputCacheRead},{key:"cacheCreation",label:"缓存写",value:(N=f.value)==null?void 0:N.inputCacheCreation}]});return(k,y)=>(m(),v("div",{ref_key:"rootRef",ref:o,class:"stats-panel",role:"dialog","aria-label":"会话统计"},[h("div",rE,[y[1]||(y[1]=h("span",{class:"stats-title"},"会话统计",-1)),h("button",{class:"stats-close","aria-label":"关闭统计面板",onClick:y[0]||(y[0]=_=>s("close"))},[X(ce,{name:"x",size:14})])]),h("div",iE,[h("div",aE,[h("div",lE,[y[2]||(y[2]=h("span",{class:"stats-label"},"上下文水位",-1)),h("span",uE,C(d.value),1)]),h("div",{class:"ctx-track",role:"progressbar","aria-valuenow":Math.round(c.value),"aria-valuemin":"0","aria-valuemax":"100","aria-label":`上下文 ${c.value.toFixed(1)}%`},[h("div",{class:"ctx-fill",style:bt({width:`${c.value}%`})},null,4)],8,cE)]),S.value?(m(),v(te,{key:0},[a(p.value)>0?(m(),v("div",dE,[h("div",fE,[y[3]||(y[3]=h("span",{class:"stats-label"},"当前回合",-1)),h("span",hE,C(l(a(p.value)))+" tokens",1)])])):F("",!0),h("div",pE,[h("div",gE,[y[4]||(y[4]=h("span",{class:"stats-label"},"本会话累计",-1)),h("span",mE,C(l(g.value))+" tokens",1)]),h("div",vE,[(m(!0),v(te,null,Ce(w.value,_=>(m(),v("div",{key:_.key,class:"stats-cell"},[h("span",yE,C(_.label),1),h("span",bE,C(u(_.value)),1)]))),128))])]),b.value.length>0?(m(),v("div",kE,[y[5]||(y[5]=h("div",{class:"stats-label"},"按模型",-1)),(m(!0),v(te,null,Ce(b.value,_=>(m(),v("div",{key:_.model,class:"model-row"},[h("span",{class:"model-name",title:_.model},C(_.model),9,wE),h("span",SE,C(u(_.tokens)),1),h("span",_E," 入 "+C(u(_.input))+" · 出 "+C(u(_.output))+" · 缓存 "+C(u(_.cacheRead+_.cacheCreation)),1)]))),128))])):F("",!0)],64)):(m(),v("div",$E,"暂无用量数据"))])],512))}}),xE=Te(CE,[["__scopeId","data-v-631485c2"]]),IE={class:"conversation"},TE={key:1,class:"stats-anchor"},EE={class:"chat-stage"},AE={class:"chat-column"},ME={class:"composer-dock"},RE=Ie({__name:"ConversationView",props:{client:{}},emits:["home"],setup(e,{expose:t,emit:n}){const s=e,o=n,{connectionStatus:r,messages:i,pendingApprovals:a,status:l,sessionId:u,workDir:c,isBusy:d,models:f,sendPrompt:p,sendCommand:g,clearMessages:b,appendSystemMessage:S,abort:w,resolveApproval:k,exportSession:y,fetchSnapshot:_,switchModel:N,switchThinking:D,switchPermission:E,goal:A,pauseGoal:T,resumeGoal:Z,cancelGoal:W}=s.client;async function j(){var ee,J;const P=s.client.sessionId.value;return!P||s.client.connectionStatus.value==="idle"?!1:await(((J=(ee=s.client).waitForConnected)==null?void 0:J.call(ee))??Promise.resolve(s.client.connectionStatus.value==="connected"))&&s.client.sessionId.value===P&&s.client.connectionStatus.value==="connected"}const ne=G(null),I=G(!1),M=G(!1),V=G("status"),ie=B(()=>{var ee;const P=(ee=l.value.usage)==null?void 0:ee.currentTurn;if(!P)return null;const z=P.inputOther+P.output+P.inputCacheRead+P.inputCacheCreation;return z>0?z:null}),me=B(()=>{const P=s.client.sessions.value.find(J=>J.sessionId===s.client.currentSessionId.value),z=P==null?void 0:P.title;if(z&&z!=="新会话"&&z!=="New Session")return z;const ee=i.value.find(J=>J.role==="user");if(ee){const J=ee.content.replace(/\s+/g," ").trim();if(J)return J.length>24?`${J.slice(0,24)}…`:J}return z??null}),_e=B(()=>{var P,z;for(let ee=i.value.length-1;ee>=0;ee-=1){const J=(z=(P=i.value[ee])==null?void 0:P.turnStats)==null?void 0:z.turn;if(J)return J}return i.value.filter(ee=>ee.role==="user").length}),he=B(()=>i.value.length===0&&!d.value);function ae(P){var z;(z=ne.value)==null||z.insertText(P)}function pe(P,z){return ne.value?(ne.value.insertDraft(P,z),!0):!1}t({insertDraft:pe});async function oe(){window.confirm("取消目标会让它进入已结束态,确定继续?")&&await W()}function ge(){Sr("goal")}function $e(P){_(),V.value=P,M.value=!0}function Ne(){var P;return((P=ne.value)==null?void 0:P.openModelPicker())??!1}const{onCommand:Ue}=lh({sendCommand:g,clearMessages:b,appendSystemMessage:S,ensureSession:j,onNew:()=>o("home"),openModelPicker:Ne,showInfo:$e,currentModel:()=>l.value.model});function Ke(P){g("title",P)}function Ye(){if(d.value||!r.value)return;const P=[...i.value].reverse().find(z=>z.role==="user");P&&p(P.content)}const rt=G(!1);async function Dt(){rt.value=!0,await s.client.loadOlderMessages(),rt.value=!1}function x(){d.value||g("fork")}return(P,z)=>(m(),v("div",IE,[he.value?F("",!0):(m(),De(Aw,{key:0,title:me.value,busy:U(d),"stats-open":I.value,"turn-tokens":ie.value,"turn-count":_e.value,onHome:z[0]||(z[0]=ee=>o("home")),onRename:Ke,onExport:z[1]||(z[1]=ee=>U(u)&&U(y)(U(u))),onFork:x,onClear:U(b),onControls:z[2]||(z[2]=ee=>U(Sr)("control")),onAgents:z[3]||(z[3]=ee=>U(Sr)("agents")),onToggleStats:z[4]||(z[4]=ee=>I.value=!I.value)},null,8,["title","busy","stats-open","turn-tokens","turn-count","onClear"])),I.value?(m(),v("div",TE,[X(xE,{status:U(l),"fetch-usage":s.client.fetchSessionUsage,"fetch-context":s.client.fetchSessionContext,onClose:z[5]||(z[5]=ee=>I.value=!1)},null,8,["status","fetch-usage","fetch-context"])])):F("",!0),h("div",EE,[h("div",AE,[X(oE,{messages:U(i),busy:U(d),"work-dir":U(c),"session-id":U(u)??"",connected:U(r)==="connected","older-available":s.client.olderAvailable.value,"older-loading":rt.value,onEdit:ae,onRetryConnection:z[6]||(z[6]=ee=>s.client.reconnectNow()),onRetryMessage:Ye,onLoadOlder:Dt,onFork:x},null,8,["messages","busy","work-dir","session-id","connected","older-available","older-loading"]),h("div",ME,[X(Cb,{approvals:U(a),onResolve:U(k)},null,8,["approvals","onResolve"]),X(kh,{ref_key:"composerRef",ref:ne,busy:U(d),status:U(l),"session-id":U(u),models:U(f),"work-dir":U(c)||"",messages:U(i),"connection-status":U(r),goal:U(A),onSend:U(p),onAbort:U(w),onCommand:U(Ue),onSwitchModel:U(N),onSwitchThinking:U(D),onSwitchPermission:U(E),onGoalPause:U(T),onGoalResume:U(Z),onGoalCancel:oe,onGoalEdit:ge},null,8,["busy","status","session-id","models","work-dir","messages","connection-status","goal","onSend","onAbort","onCommand","onSwitchModel","onSwitchThinking","onSwitchPermission","onGoalPause","onGoalResume"])])])]),M.value?(m(),De(wh,{key:2,mode:V.value,status:U(l),"session-id":U(u),"work-dir":U(c),onClose:z[7]||(z[7]=ee=>M.value=!1)},null,8,["mode","status","session-id","work-dir"])):F("",!0)]))}}),PE=Te(RE,[["__scopeId","data-v-44a6943d"]]),LE=new Set(["png","jpg","jpeg","gif","webp","svg","avif","ico"]),DE=new Set(["mp3","wav","m4a","ogg"]),NE=new Set(["md","markdown"]);function Wp(e){const t=e.split(/[\\/]/).pop()??e,n=t.lastIndexOf(".");return n>0?t.slice(n+1).toLowerCase():""}function OE(e){const t=Wp(e);return LE.has(t)?"image":DE.has(t)?"audio":NE.has(t)?"markdown":t==="pdf"?"pdf":"source"}const GE={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 Ed(e){const t=(e.split(/[\\/]/).pop()??"").toLowerCase();return t==="dockerfile"?"docker":t==="makefile"?"make":GE[Wp(e)]??"text"}const BE={key:0,class:"file-viewer"},FE={class:"fv-toolbar"},UE=["title","aria-label"],jE={class:"fv-path-text"},zE={class:"fv-modes",role:"tablist","aria-label":"显示模式"},HE=["aria-selected","title","onClick"],WE={class:"fv-body"},qE={key:0,class:"fv-status"},VE={key:1,class:"fv-status fv-error"},KE={class:"fv-error-name"},ZE={class:"fv-error-msg"},YE={key:0,class:"fv-scroll"},XE={key:1,class:"fv-status"},JE={key:0,class:"fv-media"},QE=["src","alt"],eA={key:1,class:"fv-media"},tA=["src"],nA={key:2,class:"fv-media fv-pdf"},sA=["src","title"],oA={key:3,class:"fv-scroll fv-markdown"},rA={key:4,class:"fv-scroll"},iA={key:4,class:"fv-scroll"},aA={key:0,class:"fv-note"},lA={key:1,class:"fv-empty"},_a="/api/v1",uA=Ie({__name:"FileViewer",props:{client:{}},setup(e){const t=e,n=[{id:"source",label:"源码"},{id:"preview",label:"预览"},{id:"diff",label:"Diff"}],s=B(()=>eb()),o=B(()=>s.value?Hy(s.value.viewerState,s.value.initialDisplayMode):"source"),r=B(()=>s.value?OE(s.value.filePath):"source"),i=G(0),a=B(()=>{if(!s.value)return"";const T=i.value>0?`&t=${i.value}`:"";return`${_a}/files/raw?path=${encodeURIComponent(s.value.filePath)}${T}`}),l=Wn(new Map),u=Wn(new Map);async function c(T){try{const Z=await T.json();return Z.message??Z.error??`HTTP ${T.status}`}catch{return`HTTP ${T.status}`}}function d(T){var ne,I;const Z=(ne=t.client)==null?void 0:ne.gitStatus.value,W=((I=t.client)==null?void 0:I.workDir.value)??"";if(!(Z!=null&&Z.files)||Z.files.length===0)return null;const j=W&&T.startsWith(`${W}/`)?T.slice(W.length+1):T.startsWith("/")?null:T;if(j){const M=Z.files.find(V=>(V.displayPath??V.path)===j);if(M)return M.path;for(const V of Z.files){const ie=V.displayPath??V.path;if(ie&&V.path.endsWith(ie))return V.path.slice(0,V.path.length-ie.length)+j}}return null}function f(T){var ne;const Z=[],W=I=>{I&&I!==T&&!Z.includes(I)&&Z.push(I)};W(d(T)),Z.push(T);const j=((ne=t.client)==null?void 0:ne.workDir.value)??"";return j&&T.startsWith(`${j}/`)&&W(T.slice(j.length+1)),Z}async function p(){var Z,W;const T=s.value;if(!(!T||u.has(T.filePath)))try{for(const j of f(T.filePath)){const ne=((Z=t.client)==null?void 0:Z.currentSessionId.value)??((W=t.client)==null?void 0:W.sessionId.value),I=new URLSearchParams({path:j});ne&&I.set("sessionId",ne);const M=await fetch(`${_a}/git/diff?${I.toString()}`);if(!M.ok){u.set(T.filePath,{status:"error",message:await c(M)});return}const V=await M.json();if((V.patch??"")!==""){u.set(T.filePath,{status:"ok",patch:V.patch??""});return}}u.set(T.filePath,{status:"ok",patch:""})}catch(j){u.set(T.filePath,{status:"error",message:j instanceof Error?j.message:String(j)})}}async function g(){const T=s.value;if(T){if(o.value==="diff"){await p();return}if(!(o.value==="preview"&&(r.value==="image"||r.value==="audio"||r.value==="pdf"))&&!l.has(T.filePath))try{const Z=await fetch(`${_a}/files/read?path=${encodeURIComponent(T.filePath)}`);if(!Z.ok)l.set(T.filePath,{status:"error",message:await c(Z)});else{const W=await Z.json();l.set(T.filePath,{status:"ok",content:W.content,truncated:W.truncated===!0})}}catch(Z){l.set(T.filePath,{status:"error",message:Z instanceof Error?Z.message:String(Z)})}}}Se(()=>{var T;return[(T=s.value)==null?void 0:T.id,o.value]},()=>{g()},{immediate:!0});const b=B(()=>{const T=s.value;if(T)return o.value==="diff"?u.get(T.filePath):o.value==="preview"&&(r.value==="image"||r.value==="audio"||r.value==="pdf")?{status:"ok"}:l.get(T.filePath)}),S=B(()=>s.value!==void 0&&b.value===void 0),w=B(()=>{var T;return((T=b.value)==null?void 0:T.status)==="error"?b.value:null}),k=B(()=>{const T=s.value?l.get(s.value.filePath):void 0;return(T==null?void 0:T.status)==="ok"?T.content:""}),y=B(()=>{const T=s.value?l.get(s.value.filePath):void 0;return(T==null?void 0:T.status)==="ok"?T.truncated:!1}),_=B(()=>{const T=s.value?u.get(s.value.filePath):void 0;return(T==null?void 0:T.status)==="ok"&&T.patch.trim()!==""?Hp(T.patch):[]});function N(T){var j,ne,I;const Z=s.value;if(!Z||o.value===T)return;const W={displayMode:T,wrapLines:((j=Z.viewerState)==null?void 0:j.wrapLines)??!1,scrollTop:((ne=Z.viewerState)==null?void 0:ne.scrollTop)??0,scrollLeft:((I=Z.viewerState)==null?void 0:I.scrollLeft)??0};we.tabs=Vy(we.tabs,Z.id,Z.viewerRevision??0,W)}function D(){const T=s.value;if(T){if(o.value==="diff")u.delete(T.filePath);else if(o.value==="preview"&&(r.value==="image"||r.value==="audio"||r.value==="pdf")){i.value+=1;return}else l.delete(T.filePath);g()}}const E=G(!1);function A(){var Z;const T=s.value;T&&((Z=navigator.clipboard)==null||Z.writeText(T.filePath).then(()=>{E.value=!0,setTimeout(()=>E.value=!1,1500)}).catch(()=>{}))}return(T,Z)=>s.value?(m(),v("div",BE,[h("div",FE,[h("button",{class:"fv-path",title:E.value?"已复制路径":`复制路径:${s.value.filePath}`,"aria-label":`文件路径 ${s.value.filePath}`,onClick:A},[X(ce,{name:"copy",size:12,class:"fv-path-icon"}),h("span",jE,C(s.value.filePath),1)],8,UE),h("div",zE,[(m(),v(te,null,Ce(n,W=>h("button",{key:W.id,class:ue(["fv-mode",{active:o.value===W.id}]),role:"tab","aria-selected":o.value===W.id,title:`${W.label}模式`,onClick:j=>N(W.id)},C(W.label),11,HE)),64))]),h("button",{class:"fv-icon-btn",title:"刷新","aria-label":"刷新",onClick:D},[X(ce,{name:"refresh",size:14})])]),h("div",WE,[S.value?(m(),v("div",qE,[...Z[0]||(Z[0]=[h("span",{class:"fv-spinner","aria-hidden":"true"},null,-1),h("span",null,"加载中…",-1)])])):w.value?(m(),v("div",VE,[h("p",KE,C(s.value.label),1),h("p",ZE,C(w.value.message),1),h("button",{class:"fv-retry",onClick:D},"重试")])):o.value==="diff"?(m(),v(te,{key:2},[_.value.length>0?(m(),v("div",YE,[X(wu,{lines:_.value},null,8,["lines"])])):(m(),v("div",XE,"该文件没有未提交的改动。"))],64)):o.value==="preview"?(m(),v(te,{key:3},[r.value==="image"?(m(),v("div",JE,[h("img",{src:a.value,alt:s.value.label},null,8,QE)])):r.value==="audio"?(m(),v("div",eA,[h("audio",{class:"fv-audio",controls:"",src:a.value},null,8,tA)])):r.value==="pdf"?(m(),v("div",nA,[h("iframe",{class:"fv-pdf-frame",src:a.value,title:s.value.label},null,8,sA)])):r.value==="markdown"?(m(),v("div",oA,[X(jp,{content:k.value},null,8,["content"])])):(m(),v("div",rA,[Z[1]||(Z[1]=h("p",{class:"fv-note"},"该类型暂不支持预览,显示源码内容。",-1)),X(yl,{code:k.value,lang:U(Ed)(s.value.filePath)},null,8,["code","lang"])]))],64)):(m(),v("div",iA,[y.value?(m(),v("p",aA,"文件较大,仅显示前 256KB。")):F("",!0),X(yl,{code:k.value,lang:U(Ed)(s.value.filePath)},null,8,["code","lang"])]))])])):(m(),v("div",lA,"从工具卡片、文件浏览或消息中选择文件打开"))}}),cA=Te(uA,[["__scopeId","data-v-1f5a4490"]]),dA={class:"panel-head-row"},fA=["aria-expanded"],hA={class:"head-icon"},pA=["title"],gA={key:1,class:"head-hint"},mA={class:"head-tail"},vA={key:0,class:"head-count"},yA={class:"panel-body"},bA={key:0,class:"git-files"},kA=["title","onClick"],wA={class:"git-file-name"},SA={key:0,class:"git-file-dir"},_A={class:"git-file-base"},$A={key:0,class:"git-file-stat"},CA={key:0,class:"add"},xA={key:1,class:"del"},IA={key:2,class:"diff-body"},TA={key:3,class:"panel-empty"},EA={key:1,class:"diff-empty"},AA=8,Ad="scream-panel-git-open",MA=Ie({__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","??":"?","?":"?"},r={D:"danger",A:"success",R:"success",U:"danger","??":"warning","?":"warning"},i=G(!1),a=G(!0);try{a.value=localStorage.getItem(Ad)!=="0"}catch{}function l(){a.value=!a.value;try{localStorage.setItem(Ad,a.value?"1":"0")}catch{}}function u(){s("refresh")}const c=B(()=>{var g;const p=((g=n.gitStatus)==null?void 0:g.files)??[];return i.value?p:p.slice(0,AA)}),d=B(()=>{var p,g;return Math.max(0,(((g=(p=n.gitStatus)==null?void 0:p.files)==null?void 0:g.length)??0)-c.value.length)}),f=B(()=>{var S,w;const p=((S=n.gitStatus)==null?void 0:S.ahead)??0,g=((w=n.gitStatus)==null?void 0:w.behind)??0;if(!p&&!g)return"";const b=[];return p&&b.push(`↑${p}`),g&&b.push(`↓${g}`),` · ${b.join(" ")}`});return(p,g)=>{var b;return m(),v("section",{class:ue(["panel-section","git-panel",{"is-open":a.value}])},[h("div",dA,[h("button",{class:"panel-head","aria-expanded":a.value,onClick:l},[h("span",hA,[X(ce,{name:"git-branch",size:14})]),g[1]||(g[1]=h("span",{class:"head-title"},"Git 变更",-1)),e.gitStatus?(m(),v("span",{key:0,class:"head-hint",title:`${e.gitStatus.branch??"detached"}${f.value}`},C(e.gitStatus.branch??"detached")+C(f.value),9,pA)):(m(),v("span",gA,"状态不可用")),h("span",mA,[e.gitStatus?(m(),v("span",vA,C(e.gitStatus.changed),1)):F("",!0),X(ce,{class:ue(["chevron",{rotated:a.value}]),name:"chevron-down",size:14},null,8,["class"])])],8,fA),h("button",{class:"icon-btn",title:"刷新","aria-label":"刷新 Git 状态",onClick:u},[X(ce,{name:"refresh",size:14})])]),Ze(h("div",yA,[e.gitStatus?(m(),v(te,{key:0},[c.value.length?(m(),v("ul",bA,[(m(!0),v(te,null,Ce(c.value,S=>(m(),v("li",{key:S.path},[h("button",{class:"git-file",title:`查看 ${S.displayPath??S.path} 的 diff`,onClick:w=>s("diff",{path:S.path,display:S.displayPath??S.path,adds:S.adds,dels:S.dels})},[h("span",{class:ue(["git-file-status",r[S.status]??""])},C(o[S.status]??S.status),3),h("span",wA,[U(Cr)(S.displayPath??S.path).dir?(m(),v("span",SA,C(U(Cr)(S.displayPath??S.path).dir),1)):F("",!0),h("span",_A,C(U(Cr)(S.displayPath??S.path).base),1)]),S.adds!==void 0||S.dels!==void 0?(m(),v("span",$A,[S.adds?(m(),v("span",CA,"+"+C(S.adds),1)):F("",!0),S.dels?(m(),v("span",xA,"−"+C(S.dels),1)):F("",!0)])):F("",!0)],8,kA)]))),128))])):F("",!0),d.value?(m(),v("button",{key:1,class:"git-more",onClick:g[0]||(g[0]=S=>i.value=!i.value)},C(i.value?"收起列表":`显示全部 ${((b=e.gitStatus.files)==null?void 0:b.length)??0} 个文件`),1)):F("",!0),e.gitStatus.diffStat?(m(),v("pre",IA,C(e.gitStatus.diffStat),1)):c.value.length?F("",!0):(m(),v("div",TA,[X(ce,{name:"check",size:18}),g[2]||(g[2]=h("span",null,"工作区干净,没有变更",-1))]))],64)):(m(),v("div",EA,"读取 Git 状态失败,点右上角刷新重试。"))],512),[[Fr,a.value]])],2)}}}),qp=Te(MA,[["__scopeId","data-v-39f0d843"]]),RA={class:"goal-panel panel-section"},PA={class:"section-heading"},LA={class:"head-icon"},DA=["title"],NA={key:0,class:"head-tail"},OA={class:"panel-body"},GA={key:0,class:"empty-state"},BA=["disabled"],FA={class:"refine-row"},UA=["disabled"],jA={key:0},zA=["disabled"],HA={class:"budget-grid"},WA=["disabled"],qA=["disabled"],VA={class:"time-budget"},KA=["disabled"],ZA=["disabled"],YA=["disabled"],XA={key:0,class:"goal-summary"},JA={class:"objective"},QA={class:"criterion"},eM={key:0,class:"reason"},tM={class:"goal-metrics"},nM={class:"goal-metric"},sM={key:0,class:"bar"},oM={class:"goal-metric"},rM={key:0,class:"bar"},iM={class:"goal-metric"},aM={key:0,class:"bar"},lM={key:1,class:"budget-warning"},uM={key:2,class:"notes"},cM={class:"panel-actions"},dM=["disabled"],fM=["disabled"],hM=["disabled"],pM=["disabled"],gM=["disabled"],mM={class:"budget-grid"},vM=["disabled"],yM=["disabled"],bM={class:"time-budget"},kM=["disabled"],wM=["disabled"],SM={class:"edit-actions"},_M=["disabled"],$M=["disabled"],CM={key:3,class:"form-error"},xM={key:4,class:"pending-copy"},IM=Ie({__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=G(""),s=G(""),o=G(""),r=G(""),i=G(""),a=G("minutes"),l=G(!1),u=G(null),c=G(!1),d=B(()=>t.connectionStatus==="connected"),f=B(()=>!t.sessionId||!d.value||t.archived||t.pending),p=B(()=>f.value),g=B(()=>{var I;return{active:"进行中",paused:"已暂停",blocked:"受阻",complete:"已完成"}[((I=t.goal)==null?void 0:I.status)??"active"]}),b=B(()=>t.sessionId?t.archived?"归档会话为只读状态":d.value?t.pending?"正在提交请求…":t.goal?"状态由核心事件实时同步":"创建后 Agent 将自动开始执行":"连接恢复后可继续管理":"选择或新建会话后即可配置");Se(()=>t.sessionId,()=>{l.value=!1,S()}),Se(()=>{var I;return(I=t.goal)==null?void 0:I.goalId},(I,M)=>{l.value=!1,I!==M&&S()});function S(){n.value="",s.value="",o.value="",r.value="",i.value="",a.value="minutes",c.value=!1,u.value=null}function w(I,M){const V=I.trim();if(!V)return null;const ie=Number(V);if(!Number.isSafeInteger(ie)||ie<=0){u.value=`${M}必须是正整数。`;return}return ie}function k(){u.value=null;const I=w(o.value,"轮次预算");if(I===void 0)return null;const M=w(r.value,"Token 预算");if(M===void 0)return null;const V=w(i.value,"时间预算");if(V===void 0)return null;const ie=[];return I!==null&&ie.push({value:I,unit:"turns"}),M!==null&&ie.push({value:M,unit:"tokens"}),V!==null&&ie.push({value:V,unit:a.value}),ie}async function y(){const I=n.value.trim();if(!I){u.value="请先输入需要优化的目标描述。";return}u.value=null,c.value=!1;const M=await t.refineGoal(I);M!==null&&(n.value=M,c.value=!0)}async function _(){const I=n.value.trim();if(!I){u.value="目标内容不能为空。";return}const M=k();if(M===null)return;await t.createGoal({objective:I,completionCriterion:s.value.trim()||void 0,replace:!1,budgets:M})&&(c.value=!1)}function N(I){I===null?(i.value="",a.value="minutes"):I%36e5===0?(i.value=String(I/36e5),a.value="hours"):I%6e4===0?(i.value=String(I/6e4),a.value="minutes"):I%1e3===0?(i.value=String(I/1e3),a.value="seconds"):(i.value=String(I),a.value="milliseconds")}function D(){const I=t.goal;I&&(n.value=I.objective,o.value=I.budget.turnBudget===null?"":String(I.budget.turnBudget),r.value=I.budget.tokenBudget===null?"":String(I.budget.tokenBudget),N(I.budget.wallClockBudgetMs),u.value=null,l.value=!0)}function E(I,M){return M==="hours"?I*36e5:M==="minutes"?I*6e4:M==="seconds"?I*1e3:I}async function A(){const I=t.goal;if(!I)return;const M=n.value.trim();if(!M){u.value="目标内容不能为空。";return}const V=k();if(V===null)return;const ie=w(o.value,"轮次预算"),me=w(r.value,"Token 预算"),_e=w(i.value,"时间预算");if(ie===void 0||me===void 0||_e===void 0)return;if(I.budget.turnBudget!==null&&ie===null){u.value="当前协议不支持清除已有轮次预算,请填写新的正整数。";return}if(I.budget.tokenBudget!==null&&me===null){u.value="当前协议不支持清除已有 Token 预算,请填写新的正整数。";return}if(I.budget.wallClockBudgetMs!==null&&_e===null){u.value="当前协议不支持清除已有时间预算,请填写新的正整数。";return}const he=V.filter(oe=>oe.unit==="turns"?oe.value!==I.budget.turnBudget:oe.unit==="tokens"?oe.value!==I.budget.tokenBudget:E(oe.value,oe.unit)!==I.budget.wallClockBudgetMs),ae=M===I.objective?void 0:M;if(ae===void 0&&he.length===0){u.value="目标与预算没有变化。";return}await t.updateGoal({objective:ae,budgets:he})&&(l.value=!1)}async function T(I){u.value=null,!(I==="cancel"&&!window.confirm("确定取消当前 Goal?当前 Goal 状态将被清除。"))&&(I==="pause"?await t.pauseGoal():I==="resume"?await t.resumeGoal():await t.cancelGoal())}function Z(I){return I.toLocaleString("zh-CN")}function W(I){if(I<1e3)return`${I} 毫秒`;const M=Math.floor(I/1e3);if(M<60)return`${M} 秒`;const V=Math.floor(M/3600),ie=Math.floor(M%3600/60);return V>0?`${V} 小时 ${ie} 分钟`:`${ie} 分钟`}function j(I,M){return M===null||M<=0?0:Math.min(100,Math.round(I/M*100))}function ne(I){return new Date(I).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}return(I,M)=>(m(),v("section",RA,[h("div",PA,[h("span",LA,[X(ce,{name:"target",size:14})]),M[15]||(M[15]=h("span",{class:"head-title"},"Goal 管理",-1)),h("span",{class:"head-hint",title:b.value},C(b.value),9,DA),e.goal?(m(),v("span",NA,[h("span",{class:ue(["status-pill",`is-${e.goal.status}`])},C(g.value),3)])):F("",!0)]),h("div",OA,[e.sessionId?e.goal?(m(),v(te,{key:2},[l.value?(m(),v("form",{key:1,class:"goal-form edit-form",onSubmit:tt(A,["prevent"])},[h("label",null,[M[33]||(M[33]=h("span",null,"目标内容",-1)),Ze(h("textarea",{"onUpdate:modelValue":M[9]||(M[9]=V=>n.value=V),rows:"3",maxlength:"4000",disabled:f.value||e.busy},null,8,gM),[[it,n.value]])]),M[38]||(M[38]=h("div",{class:"budget-title"},[Ae("更新预算 "),h("small",null,"仅提交发生变化的预算")],-1)),h("div",mM,[h("label",null,[M[34]||(M[34]=h("span",null,"轮次",-1)),Ze(h("input",{"onUpdate:modelValue":M[10]||(M[10]=V=>o.value=V),type:"number",min:"1",step:"1",placeholder:"不限",disabled:f.value||e.busy},null,8,vM),[[it,o.value]])]),h("label",null,[M[35]||(M[35]=h("span",null,"Token",-1)),Ze(h("input",{"onUpdate:modelValue":M[11]||(M[11]=V=>r.value=V),type:"number",min:"1",step:"1",placeholder:"不限",disabled:f.value||e.busy},null,8,yM),[[it,r.value]])])]),h("div",bM,[h("label",null,[M[36]||(M[36]=h("span",null,"时间",-1)),Ze(h("input",{"onUpdate:modelValue":M[12]||(M[12]=V=>i.value=V),type:"number",min:"1",step:"1",placeholder:"不限",disabled:f.value||e.busy},null,8,kM),[[it,i.value]])]),Ze(h("select",{"onUpdate:modelValue":M[13]||(M[13]=V=>a.value=V),"aria-label":"时间预算单位",disabled:f.value||e.busy},[...M[37]||(M[37]=[h("option",{value:"minutes"},"分钟",-1),h("option",{value:"hours"},"小时",-1),h("option",{value:"seconds"},"秒",-1),h("option",{value:"milliseconds"},"毫秒",-1)])],8,wM),[[lc,a.value]])]),h("div",SM,[h("button",{type:"button",class:"secondary",disabled:e.pending,onClick:M[14]||(M[14]=V=>l.value=!1)},"返回",8,_M),h("button",{class:"primary small",type:"submit",disabled:f.value||e.busy},"保存修改",8,$M)])],32)):(m(),v("div",XA,[h("div",JA,[M[26]||(M[26]=h("small",null,"目标",-1)),h("p",null,C(e.goal.objective),1)]),h("div",QA,[M[27]||(M[27]=h("small",null,"完成标准",-1)),h("p",null,C(e.goal.completionCriterion??"未设置,由 Agent 根据目标判断完成。"),1)]),e.goal.terminalReason?(m(),v("div",eM,[M[28]||(M[28]=h("strong",null,"状态原因",-1)),h("span",null,C(e.goal.terminalReason),1)])):F("",!0),h("dl",tM,[h("div",nM,[M[29]||(M[29]=h("dt",null,"轮次",-1)),h("dd",null,C(e.goal.turnsUsed)+" / "+C(e.goal.budget.turnBudget??"不限"),1),e.goal.budget.turnBudget!==null?(m(),v("i",sM,[h("i",{style:bt({width:`${j(e.goal.turnsUsed,e.goal.budget.turnBudget)}%`})},null,4)])):F("",!0)]),h("div",oM,[M[30]||(M[30]=h("dt",null,"Token",-1)),h("dd",null,C(Z(e.goal.tokensUsed))+" / "+C(e.goal.budget.tokenBudget===null?"不限":Z(e.goal.budget.tokenBudget)),1),e.goal.budget.tokenBudget!==null?(m(),v("i",rM,[h("i",{style:bt({width:`${j(e.goal.tokensUsed,e.goal.budget.tokenBudget)}%`})},null,4)])):F("",!0)]),h("div",iM,[M[31]||(M[31]=h("dt",null,"时间",-1)),h("dd",null,C(W(e.goal.wallClockMs))+" / "+C(e.goal.budget.wallClockBudgetMs===null?"不限":W(e.goal.budget.wallClockBudgetMs)),1),e.goal.budget.wallClockBudgetMs!==null?(m(),v("i",aM,[h("i",{style:bt({width:`${j(e.goal.wallClockMs,e.goal.budget.wallClockBudgetMs)}%`})},null,4)])):F("",!0)])]),e.goal.budget.overBudget?(m(),v("div",lM,"已达到或超过执行预算。")):F("",!0),e.goal.notes.length?(m(),v("details",uM,[h("summary",null,"工作记录("+C(e.goal.notes.length)+")",1),h("ol",null,[(m(!0),v(te,null,Ce(e.goal.notes,V=>(m(),v("li",{key:`${V.time}-${V.content}`},[h("time",null,C(ne(V.time)),1),h("span",null,C(V.content),1)]))),128))])])):F("",!0),h("div",cM,[e.goal.status!=="complete"?(m(),v("button",{key:0,class:"secondary",disabled:f.value||e.busy,onClick:D},[X(ce,{name:"edit",size:14}),M[32]||(M[32]=Ae("编辑",-1))],8,dM)):F("",!0),e.goal.status==="active"?(m(),v("button",{key:1,class:"secondary",disabled:f.value,onClick:M[6]||(M[6]=V=>T("pause"))},"暂停",8,fM)):F("",!0),e.goal.status==="paused"||e.goal.status==="blocked"?(m(),v("button",{key:2,class:"primary small",disabled:f.value||e.busy,onClick:M[7]||(M[7]=V=>T("resume"))},"继续",8,hM)):F("",!0),h("button",{class:"danger",disabled:f.value,onClick:M[8]||(M[8]=V=>T("cancel"))},"取消 Goal",8,pM)])]))],64)):(m(),v("form",{key:1,class:"goal-form",onSubmit:tt(_,["prevent"])},[h("label",null,[M[18]||(M[18]=h("span",null,"目标内容",-1)),Ze(h("textarea",{"onUpdate:modelValue":M[0]||(M[0]=V=>n.value=V),rows:"3",maxlength:"4000",placeholder:"描述希望 Agent 持续完成的目标",disabled:p.value},null,8,BA),[[it,n.value]])]),h("div",FA,[h("button",{type:"button",class:"secondary",disabled:p.value||!n.value.trim(),onClick:y},[X(ce,{name:"sparkles",size:15}),M[19]||(M[19]=Ae(" AI 优化 ",-1))],8,UA),c.value?(m(),v("small",jA,"已优化,请确认或继续编辑后再创建。")):F("",!0)]),h("label",null,[M[20]||(M[20]=h("span",null,[Ae("完成标准 "),h("small",null,"可选")],-1)),Ze(h("textarea",{"onUpdate:modelValue":M[1]||(M[1]=V=>s.value=V),rows:"2",placeholder:"例如:聚焦测试、类型检查与 Web 构建全部通过",disabled:p.value},null,8,zA),[[it,s.value]])]),M[25]||(M[25]=h("div",{class:"budget-title"},[Ae("执行预算 "),h("small",null,"留空表示不限制")],-1)),h("div",HA,[h("label",null,[M[21]||(M[21]=h("span",null,"轮次",-1)),Ze(h("input",{"onUpdate:modelValue":M[2]||(M[2]=V=>o.value=V),type:"number",min:"1",step:"1",placeholder:"不限",disabled:p.value},null,8,WA),[[it,o.value]])]),h("label",null,[M[22]||(M[22]=h("span",null,"Token",-1)),Ze(h("input",{"onUpdate:modelValue":M[3]||(M[3]=V=>r.value=V),type:"number",min:"1",step:"1",placeholder:"不限",disabled:p.value},null,8,qA),[[it,r.value]])])]),h("div",VA,[h("label",null,[M[23]||(M[23]=h("span",null,"时间",-1)),Ze(h("input",{"onUpdate:modelValue":M[4]||(M[4]=V=>i.value=V),type:"number",min:"1",step:"1",placeholder:"不限",disabled:p.value},null,8,KA),[[it,i.value]])]),Ze(h("select",{"onUpdate:modelValue":M[5]||(M[5]=V=>a.value=V),"aria-label":"时间预算单位",disabled:p.value},[...M[24]||(M[24]=[h("option",{value:"minutes"},"分钟",-1),h("option",{value:"hours"},"小时",-1),h("option",{value:"seconds"},"秒",-1),h("option",{value:"milliseconds"},"毫秒",-1)])],8,ZA),[[lc,a.value]])]),h("button",{class:"primary",type:"submit",disabled:p.value||!n.value.trim()},C(e.pending?"正在创建…":"创建并开始执行"),9,YA)],32)):(m(),v("div",GA,[X(ce,{name:"target",size:18}),M[16]||(M[16]=h("span",null,"暂无会话",-1)),M[17]||(M[17]=h("small",null,"选择或新建会话后即可配置目标。",-1))])),u.value||e.error?(m(),v("p",CM,C(u.value??e.error),1)):e.pending?(m(),v("p",xM,"请求处理中,状态将在核心事件到达后同步。")):F("",!0)])]))}}),Vp=Te(IM,[["__scopeId","data-v-cf530861"]]),TM={class:"nsm-body"},EM={class:"nsm-section"},AM=["placeholder"],MM={key:0,class:"nsm-error"},RM={key:1,class:"nsm-recents"},PM=["title","onClick"],LM={class:"nsm-section"},DM={class:"nsm-models",role:"radiogroup","aria-label":"选择模型"},NM=["aria-checked"],OM=["aria-checked","onClick"],GM={class:"nsm-model-name"},BM={class:"nsm-model-alias"},FM=Ie({__name:"NewSessionModal",props:{open:{type:Boolean},models:{},recentWorkDirs:{},defaultDir:{},currentModel:{}},emits:["close","confirm"],setup(e,{emit:t}){const n=e,s=t,o=G(n.defaultDir),r=G(n.currentModel||null);Se(()=>n.open,c=>{c&&(o.value=n.defaultDir,r.value=n.currentModel||null)},{immediate:!0});const i=B(()=>{const c=o.value.trim();return c?c.startsWith("/"):!0}),a=B(()=>o.value.trim()&&!i.value?"请输入绝对路径(如 /home/user/projects)":"");function l(c){o.value=c}function u(){const c=o.value.trim();s("confirm",{workDir:c||null,model:r.value})}return(c,d)=>(m(),De(Vl,{open:e.open,title:"新建会话","max-width":"480px",onClose:d[3]||(d[3]=f=>s("close"))},{footer:ot(()=>[X(Ht,{variant:"ghost",onClick:d[2]||(d[2]=f=>s("close"))},{default:ot(()=>[...d[7]||(d[7]=[Ae("取消",-1)])]),_:1}),X(Ht,{variant:"primary",disabled:!i.value,onClick:u},{default:ot(()=>[...d[8]||(d[8]=[Ae("进入新会话",-1)])]),_:1},8,["disabled"])]),default:ot(()=>[h("div",TM,[h("section",EM,[d[4]||(d[4]=h("div",{class:"nsm-label"},"工作区",-1)),Ze(h("input",{"onUpdate:modelValue":d[0]||(d[0]=f=>o.value=f),class:ue(["nsm-input",{"is-invalid":!!a.value}]),type:"text",spellcheck:"false",placeholder:e.defaultDir||"服务器默认工作区"},null,10,AM),[[it,o.value]]),a.value?(m(),v("div",MM,C(a.value),1)):F("",!0),e.recentWorkDirs.length?(m(),v("div",RM,[(m(!0),v(te,null,Ce(e.recentWorkDirs,f=>(m(),v("button",{key:f,type:"button",class:ue(["nsm-recent",{"is-active":o.value===f}]),title:f,onClick:p=>l(f)},C(f.split("/").filter(Boolean).pop()||f),11,PM))),128))])):F("",!0)]),h("section",LM,[d[6]||(d[6]=h("div",{class:"nsm-label"},"模型",-1)),h("div",DM,[h("button",{type:"button",class:ue(["nsm-model",{"is-active":r.value===null}]),role:"radio","aria-checked":r.value===null,onClick:d[1]||(d[1]=f=>r.value=null)},[...d[5]||(d[5]=[h("span",{class:"nsm-model-name"},"跟随服务器默认",-1)])],10,NM),(m(!0),v(te,null,Ce(e.models,f=>(m(),v("button",{key:f.alias,type:"button",class:ue(["nsm-model",{"is-active":r.value===f.alias}]),role:"radio","aria-checked":r.value===f.alias,onClick:p=>r.value=f.alias},[h("span",GM,C(f.displayName||f.model),1),h("span",BM,C(f.provider)+"/"+C(f.model),1)],10,OM))),128))])])])]),_:1},8,["open"]))}}),UM=Te(FM,[["__scopeId","data-v-7bb09c54"]]),jM={class:"panel-section like-section"},zM={class:"section-heading"},HM={class:"head-icon"},WM={class:"panel-body"},qM={class:"kv-rows"},VM={class:"dialog"},KM=["onUpdate:modelValue","placeholder"],ZM={key:0,class:"dialog-error"},YM={class:"dialog-actions"},XM=["disabled"],JM=Ie({__name:"LikePanel",props:{like:{},updateLike:{type:Function}},setup(e){const t=e,n=G(!1),s=G(!1),o=G(""),r=G({}),i=[{key:"nickname",label:"昵称",placeholder:"用户称呼,如:老板"},{key:"tone",label:"语气",placeholder:"AI 风格,如:专业不拖沓"},{key:"other",label:"偏好",placeholder:"其他用户偏好"},{key:"doNot",label:"禁止",placeholder:"用户明确不让做的事"}];function a(){r.value={...t.like},o.value="",n.value=!0}async function l(){s.value=!0,o.value="";const u=await t.updateLike(r.value);s.value=!1,u?n.value=!1:o.value="保存失败"}return(u,c)=>(m(),v("section",jM,[h("div",zM,[h("span",HM,[X(ce,{name:"settings",size:14})]),c[2]||(c[2]=h("span",{class:"head-title"},"偏好设置",-1)),c[3]||(c[3]=h("span",{class:"head-hint"},"/like 用户偏好",-1))]),h("div",WM,[h("dl",qM,[(m(),v(te,null,Ce(i,d=>h("div",{key:d.key,class:"kv-row"},[h("dt",null,C(d.label),1),h("dd",null,C((e.like[d.key]??"").trim()||"未设置"),1)])),64))]),h("div",{class:"panel-actions"},[h("button",{class:"like-edit",onClick:a},"编辑偏好")])]),n.value?(m(),v("div",{key:0,class:"dialog-overlay",onClick:c[1]||(c[1]=tt(d=>n.value=!1,["self"]))},[h("div",VM,[c[4]||(c[4]=h("div",{class:"dialog-title"},"编辑用户偏好",-1)),(m(),v(te,null,Ce(i,d=>h("label",{key:d.key,class:"dialog-field"},[h("span",null,C(d.label),1),Ze(h("input",{"onUpdate:modelValue":f=>r.value[d.key]=f,placeholder:d.placeholder},null,8,KM),[[it,r.value[d.key]]])])),64)),o.value?(m(),v("div",ZM,C(o.value),1)):F("",!0),h("div",YM,[h("button",{onClick:c[0]||(c[0]=d=>n.value=!1)},"取消"),h("button",{disabled:s.value,onClick:l},C(s.value?"保存中…":"确认"),9,XM)])])])):F("",!0)]))}}),Kp=Te(JM,[["__scopeId","data-v-2eac026c"]]),QM=["aria-expanded"],eR={class:"head-icon"},tR={class:"head-hint"},nR={class:"head-tail"},sR=["title"],oR={class:"panel-body"},rR={class:"stat-grid"},iR={class:"stat"},aR={class:"stat"},lR=["title"],uR={key:1,class:"faint"},cR={class:"stat wide"},dR={class:"mono"},Md="scream-panel-runstatus-open",fR=Ie({__name:"RunStatusPanel",props:{status:{},busy:{type:Boolean,default:!1},connectionStatus:{}},setup(e){const t=e,n=G(!0);try{n.value=localStorage.getItem(Md)!=="0"}catch{}function s(){n.value=!n.value;try{localStorage.setItem(Md,n.value?"1":"0")}catch{}}const o=B(()=>{const a=t.status.contextUsage;return a===void 0?null:Math.round((a>1?a/100:a)*100)}),r=B(()=>{var a,l;return`Tokens: ${((a=t.status.contextTokens)==null?void 0:a.toLocaleString())??"-"} / ${((l=t.status.maxContextTokens)==null?void 0:l.toLocaleString())??"-"}`}),i=B(()=>({connected:"已连接",connecting:"连接中",reconnecting:"重连中",disconnected:"已断开",idle:"空闲"})[t.connectionStatus]??"空闲");return Se(()=>t.busy,()=>{t.busy&&!n.value&&(n.value=!0)}),(a,l)=>{var u,c;return m(),v("section",{class:ue(["panel-section","run-status",{"is-open":n.value}])},[h("button",{class:"panel-head","aria-expanded":n.value,onClick:s},[h("span",eR,[X(ce,{name:"activity",size:14})]),l[0]||(l[0]=h("span",{class:"head-title"},"运行状态",-1)),h("span",tR,C(e.busy?"正在处理会话":"已就绪,等待任务"),1),h("span",nR,[h("span",{class:ue(["head-dot",{busy:e.busy}]),title:e.busy?"Agent 正在处理":"空闲"},null,10,sR),X(ce,{class:ue(["chevron",{rotated:n.value}]),name:"chevron-down",size:14},null,8,["class"])])],8,QM),Ze(h("div",oR,[h("dl",rR,[h("div",iR,[l[1]||(l[1]=h("dt",null,"连接",-1)),h("dd",null,[h("span",{class:ue(["conn-dot",e.connectionStatus]),"aria-hidden":"true"},null,2),h("span",{class:ue(["conn",e.connectionStatus])},C(i.value),3)])]),h("div",aR,[l[2]||(l[2]=h("dt",null,"上下文占用",-1)),o.value!==null?(m(),v("dd",{key:0,title:r.value},[X(bh,{usage:e.status.contextUsage,size:14},null,8,["usage"]),Ae(C(o.value)+"% ",1)],8,lR)):(m(),v("dd",uR,"未知"))]),h("div",cR,[l[3]||(l[3]=h("dt",null,"Token(输入 / 上限)",-1)),h("dd",dR,C(((u=e.status.contextTokens)==null?void 0:u.toLocaleString())??"-")+" / "+C(((c=e.status.maxContextTokens)==null?void 0:c.toLocaleString())??"-"),1)])])],512),[[Fr,n.value]])],2)}}}),Zp=Te(fR,[["__scopeId","data-v-59b0c4e7"]]),hR={class:"todo-panel panel-section"},pR={class:"section-heading"},gR={class:"head-icon"},mR={class:"head-hint"},vR={class:"head-tail"},yR={class:"head-count"},bR={key:0,class:"panel-body"},kR={class:"empty-state"},wR={key:1,class:"panel-body"},SR={class:"progress-row"},_R={class:"bar","aria-hidden":"true"},$R={class:"progress-value"},CR=["title"],xR={class:"todo-title"},IR=Ie({__name:"TodoPanel",props:{todos:{}},setup(e){const t=e,n=B(()=>iy(t.todos)),s=B(()=>t.todos.filter(u=>u.status==="done").length),o=B(()=>t.todos.filter(u=>u.status==="in_progress").length),r=B(()=>t.todos.filter(u=>u.status==="pending").length),i=B(()=>t.todos.length?Math.round(s.value/t.todos.length*100):0),a=B(()=>{if(!t.todos.length)return"直接来自 Agent 核心状态";if(s.value===t.todos.length)return"全部完成";const u=[];return o.value&&u.push(`进行中 ${o.value}`),r.value&&u.push(`待处理 ${r.value}`),u.join(" · ")||"直接来自 Agent 核心状态"}),l={pending:{label:"待处理",symbol:"○"},in_progress:{label:"进行中",symbol:"●"},done:{label:"已完成",symbol:"✓"}};return(u,c)=>(m(),v("section",hR,[h("div",pR,[h("span",gR,[X(ce,{name:"clipboard",size:14})]),c[0]||(c[0]=h("span",{class:"head-title"},"核心 Todo",-1)),h("span",mR,C(a.value),1),h("span",vR,[h("span",yR,C(s.value)+"/"+C(e.todos.length),1)])]),e.todos.length===0?(m(),v("div",bR,[h("div",kR,[X(ce,{name:"check",size:18}),c[1]||(c[1]=h("span",null,"暂无 Todo",-1)),c[2]||(c[2]=h("small",null,"Agent 创建任务清单后会在这里实时显示。",-1))])])):(m(),v("div",wR,[h("div",SR,[h("i",_R,[h("i",{style:bt({width:`${i.value}%`})},null,4)]),h("span",$R,C(i.value)+"%",1)]),(m(!0),v(te,null,Ce(n.value,(d,f)=>(m(),v("section",{key:d.phase??`unphased-${f}`,class:"todo-group"},[h("h4",null,C(d.phase??"未分阶段"),1),h("ol",null,[(m(!0),v(te,null,Ce(d.items,(p,g)=>(m(),v("li",{key:`${f}-${g}-${p.title}`,class:ue(`is-${p.status}`)},[h("span",{class:"status-symbol",title:l[p.status].label},C(l[p.status].symbol),9,CR),h("span",xR,C(p.title),1),h("small",null,C(l[p.status].label),1)],2))),128))])]))),128))]))]))}}),Yp=Te(IR,[["__scopeId","data-v-6a025f22"]]),TR={class:"detail-view"},ER={class:"git-diff-head"},AR=["title"],MR={class:"git-diff-tools"},RR={key:0,class:"git-diff-stat"},PR={key:0,class:"add"},LR={key:1,class:"del"},DR={key:0,class:"git-diff-body"},NR={key:1,class:"git-diff-empty"},OR=Ie({__name:"SessionDetailView",props:{client:{}},setup(e){const t=e,n=G(null),s=G(null);let o=0;async function r(E){var W,j,ne;const A=++o,T=t.client.currentSessionId.value??t.client.sessionId.value;n.value={...E,lines:[],loading:!0};try{const I=new URLSearchParams({path:E.path});T&&I.set("sessionId",T);const V=await(await fetch(`/api/v1/git/diff?${I.toString()}`)).json();if(A!==o||T!==(t.client.currentSessionId.value??t.client.sessionId.value))return;const ie=Hp(V.patch??""),me=E.adds??(E.dels===void 0?ie.filter(_e=>_e.type==="add").length:void 0);n.value={...E,adds:me,lines:ie,loading:!1}}catch{if(A!==o)return;n.value={...E,lines:[],loading:!1}}await Fe();const Z=((j=(W=globalThis.window)==null?void 0:W.matchMedia)==null?void 0:j.call(W,"(prefers-reduced-motion: reduce)").matches)===!0;(ne=s.value)==null||ne.scrollIntoView({block:"start",behavior:Z?"auto":"smooth"})}Se(()=>t.client.currentSessionId.value??t.client.sessionId.value,()=>{o++,n.value=null});const{connectionStatus:i,status:a,sessionId:l,isBusy:u,isArchived:c,goal:d,todos:f,goalRequestPending:p,goalRequestError:g,like:b,gitStatus:S,refineGoal:w,createGoal:k,updateGoal:y,pauseGoal:_,resumeGoal:N,cancelGoal:D}=t.client;return(E,A)=>(m(),v("div",TR,[X(Zp,{status:U(a),busy:U(u),"connection-status":U(i)},null,8,["status","busy","connection-status"]),X(qp,{"git-status":U(S),onRefresh:A[0]||(A[0]=T=>t.client.fetchGitStatus()),onDiff:r},null,8,["git-status"]),n.value?(m(),v("div",{key:0,ref_key:"diffRef",ref:s,class:"git-diff-view"},[h("div",ER,[h("span",{class:"git-diff-title",title:n.value.path},C(n.value.loading?"加载中…":n.value.display),9,AR),h("span",MR,[!n.value.loading&&(n.value.adds||n.value.dels)?(m(),v("span",RR,[n.value.adds?(m(),v("span",PR,"+"+C(n.value.adds),1)):F("",!0),n.value.dels?(m(),v("span",LR,"−"+C(n.value.dels),1)):F("",!0)])):F("",!0),h("button",{class:"git-diff-close",title:"关闭 diff","aria-label":"关闭 diff",onClick:A[1]||(A[1]=T=>n.value=null)},"✕")])]),n.value.lines.length?(m(),v("div",DR,[X(wu,{lines:n.value.lines},null,8,["lines"])])):n.value.loading?F("",!0):(m(),v("p",NR,"该文件无差异内容(可能是二进制文件或已被忽略)。"))],512)):F("",!0),X(Yp,{todos:U(f)},null,8,["todos"]),X(Kp,{like:U(b),"update-like":t.client.updateLike},null,8,["like","update-like"]),X(Vp,{goal:U(d),"session-id":U(l),"connection-status":U(i),busy:U(u),archived:U(c),pending:U(p),error:U(g),"refine-goal":U(w),"create-goal":U(k),"update-goal":U(y),"pause-goal":U(_),"resume-goal":U(N),"cancel-goal":U(D)},null,8,["goal","session-id","connection-status","busy","archived","pending","error","refine-goal","create-goal","update-goal","pause-goal","resume-goal","cancel-goal"])]))}}),GR=Te(OR,[["__scopeId","data-v-f2bcdf8d"]]),BR={class:"session-controls","aria-label":"会话控制"},FR={class:"controls-head"},UR={class:"controls-heading"},jR={class:"controls-icon"},zR=["disabled"],HR={class:"controls-body"},WR={class:"control-group","aria-label":"计划模式"},qR={class:"group-label"},VR={key:0,class:"mode-state"},KR={class:"segmented",role:"group","aria-label":"计划模式"},ZR=["aria-pressed","disabled"],YR=["aria-pressed","disabled"],XR=["aria-pressed","disabled"],JR=["disabled"],QR={class:"control-group","aria-label":"并行与递归模式"},e2={class:"switch-row"},t2=["checked","disabled"],n2={class:"switch-row"},s2=["checked","disabled"],o2={key:0,class:"depth-field"},r2=["disabled"],i2=["disabled"],a2={class:"control-group control-group--actions","aria-label":"会话操作"},l2=["disabled"],u2=["disabled"],c2=Ie({__name:"SessionControlsPanel",props:{client:{}},setup(e){const t=e,{showToast:n}=Qs(),s=G(!1),o=G("0");let r=0;const i=B(()=>t.client.sessionId.value!==null),a=B(()=>t.client.isArchived.value),l=B(()=>t.client.isBusy.value),u=B(()=>i.value?a.value?"当前会话已归档,仅可查看记录":t.client.connectionStatus.value!=="connected"?"连接恢复后可调整控制项":l.value?"当前回合结束后可调整控制项":"":"打开会话后可调整控制项"),c=B(()=>!!u.value||s.value),d=B(()=>t.client.status.value.planMode===!0),f=B(()=>{var E;return t.client.status.value.planStrategy??((E=t.client.sessionPlan.value)==null?void 0:E.strategy)??"normal"});async function p(){if(!i.value||a.value||t.client.connectionStatus.value!=="connected")return;await Promise.all([t.client.fetchSessionStatus(),t.client.fetchSessionPlan()]);const E=t.client.status.value.rlmMaxDepth;o.value=E==null?"0":String(E)}async function g(E,A){if(c.value)return;const T=r;s.value=!0;try{await E()&&T===r&&await(A==null?void 0:A())}finally{if(T!==r)return;await p(),s.value=!1}}function b(E,A){g(()=>t.client.switchPlanMode(E,A))}function S(E){const A=E.currentTarget.checked;g(()=>t.client.switchWolfpack(A))}function w(){const E=String(o.value).trim();return/^\d+$/.test(E)?Number(E):(n("RLM 深度需为 0 或正整数","warning"),null)}function k(E){const A=E.currentTarget.checked;g(()=>t.client.switchRlm(A))}function y(){const E=w();if(E===null)return;const A=t.client.status.value.rlmEnabled??!0;g(()=>t.client.switchRlm(A,E))}function _(){g(()=>t.client.clearPlan())}function N(){g(()=>t.client.undoHistory(),async()=>{await t.client.fetchSnapshot()})}function D(){g(()=>t.client.compact())}return et(()=>{p()}),Se(()=>t.client.sessionId.value,()=>{r++,s.value=!1,o.value="0",p()}),(E,A)=>(m(),v("section",BR,[h("header",FR,[h("div",UR,[h("span",jR,[X(ce,{name:"wrench",size:16})]),h("div",null,[A[4]||(A[4]=h("h2",null,"会话控制",-1)),h("p",null,C(u.value||"已就绪"),1)])]),h("button",{class:"icon-button",title:"刷新会话状态","aria-label":"刷新会话状态",disabled:s.value||!i.value||a.value,onClick:p},[X(ce,{name:"refresh",size:15})],8,zR)]),h("div",HR,[h("section",WR,[h("div",qR,[A[5]||(A[5]=h("span",null,"计划",-1)),d.value?(m(),v("span",VR,C(f.value==="fusion"?"融合":"标准"),1)):F("",!0)]),h("div",KR,[h("button",{class:ue({active:!d.value}),"aria-pressed":!d.value,disabled:c.value,onClick:A[0]||(A[0]=T=>b(!1))},"关闭",10,ZR),h("button",{class:ue({active:d.value&&f.value==="normal"}),"aria-pressed":d.value&&f.value==="normal",disabled:c.value,onClick:A[1]||(A[1]=T=>b(!0,"normal"))},"计划",10,YR),h("button",{class:ue({active:d.value&&f.value==="fusion"}),"aria-pressed":d.value&&f.value==="fusion",disabled:c.value,onClick:A[2]||(A[2]=T=>b(!0,"fusion"))},"融合",10,XR)]),t.client.sessionPlan.value?(m(),v("button",{key:0,class:"text-action",disabled:c.value,onClick:_},[X(ce,{name:"broom",size:14}),A[6]||(A[6]=Ae(" 清除计划 ",-1))],8,JR)):F("",!0)]),h("section",QR,[h("label",e2,[A[7]||(A[7]=h("span",null,[h("strong",null,"Wolfpack"),h("small",null,"并行协作")],-1)),h("input",{type:"checkbox",checked:t.client.status.value.wolfpackMode===!0,disabled:c.value,onChange:S},null,40,t2),A[8]||(A[8]=h("i",{"aria-hidden":"true"},null,-1))]),A[12]||(A[12]=h("div",{class:"rule"},null,-1)),h("label",n2,[A[9]||(A[9]=h("span",null,[h("strong",null,"RLM"),h("small",null,"持久 Python")],-1)),h("input",{type:"checkbox",checked:t.client.status.value.rlmEnabled===!0,disabled:c.value,onChange:k},null,40,s2),A[10]||(A[10]=h("i",{"aria-hidden":"true"},null,-1))]),t.client.status.value.rlmEnabled?(m(),v("label",o2,[A[11]||(A[11]=h("span",null,"最大深度",-1)),h("div",null,[Ze(h("input",{"onUpdate:modelValue":A[3]||(A[3]=T=>o.value=T),inputmode:"numeric",min:"0",type:"number",disabled:c.value,"aria-label":"RLM 最大深度"},null,8,r2),[[it,o.value]]),h("button",{title:"保存 RLM 最大深度","aria-label":"保存 RLM 最大深度",disabled:c.value,onClick:y},[X(ce,{name:"check",size:14})],8,i2)])])):F("",!0)]),h("section",a2,[h("button",{class:"command-action",disabled:c.value,onClick:D},[X(ce,{name:"compact",size:16}),A[13]||(A[13]=h("span",null,"压缩上下文",-1))],8,l2),h("button",{class:"command-action danger",disabled:c.value,onClick:N},[X(ce,{name:"broom",size:16}),A[14]||(A[14]=h("span",null,"撤销上一轮",-1))],8,u2)])])]))}}),d2=Te(c2,[["__scopeId","data-v-0ca4191d"]]),f2={class:"subagents-panel","aria-label":"协作代理"},h2={class:"agents-head"},p2={class:"agents-heading"},g2={class:"agents-icon"},m2={role:"status","aria-live":"polite"},v2=["aria-label"],y2={class:"agents-body"},b2={key:0,class:"agents-empty"},k2={key:1,class:"agent-list"},w2={class:"agent-row-head"},S2={class:"agent-title"},_2={key:0,class:"background-badge"},$2={key:1,class:"agent-description"},C2={key:0,class:"agent-result error"},x2={key:1,class:"agent-result"},I2={key:2,class:"agent-meta"},T2={key:0},E2={key:1},A2={key:2},M2={key:3},R2=Ie({__name:"SubagentPanel",props:{subagents:{}},setup(e){const t=e,n=B(()=>t.subagents.filter(a=>a.state==="spawning"||a.state==="running").length);function s(a){return a.state==="spawning"?a.runInBackground?"后台排队":"准备中":a.state==="running"?a.runInBackground?"后台运行":"运行中":a.state==="completed"?"已完成":"失败"}function o(a){return a===void 0||a<0?null:a<1e3?"< 1 秒":a<6e4?`${(a/1e3).toFixed(a<1e4?1:0)} 秒`:`${Math.floor(a/6e4)} 分 ${Math.round(a%6e4/1e3)} 秒`}function r(a){const l=a.usage;return l?l.inputOther+l.output+l.inputCacheRead+l.inputCacheCreation:null}function i(a){return a.toLocaleString()}return(a,l)=>(m(),v("section",f2,[h("header",h2,[h("div",p2,[h("span",g2,[X(ce,{name:"bot",size:16})]),h("div",null,[l[0]||(l[0]=h("h2",null,"协作代理",-1)),h("p",m2,C(n.value>0?`${n.value} 个正在执行`:"最近的子代理执行记录"),1)])]),n.value>0?(m(),v("span",{key:0,class:"active-count","aria-label":`${n.value} 个代理正在执行`},C(n.value),9,v2)):F("",!0)]),h("div",y2,[e.subagents.length===0?(m(),v("p",b2,"当前会话还没有子代理活动")):(m(),v("ol",k2,[(m(!0),v(te,null,Ce(e.subagents,u=>(m(),v("li",{key:u.subagentId,class:"agent-row"},[h("div",w2,[h("span",{class:ue(["agent-mark",u.state]),"aria-hidden":"true"},[X(ce,{name:u.state==="failed"?"x":u.state==="completed"?"check":"bot",size:14},null,8,["name"])],2),h("div",S2,[h("strong",null,C(u.name),1),u.runInBackground?(m(),v("span",_2,"后台")):F("",!0),u.description?(m(),v("span",$2,C(u.description),1)):F("",!0)]),h("span",{class:ue(["agent-state",u.state])},C(s(u)),3)]),u.error?(m(),v("p",C2,C(u.error),1)):u.resultSummary?(m(),v("p",x2,C(u.resultSummary),1)):F("",!0),u.turns||u.toolCallCount||o(u.durationMs)||r(u)!==null?(m(),v("dl",I2,[u.turns?(m(),v("div",T2,[l[1]||(l[1]=h("dt",null,"回合",-1)),h("dd",null,C(u.turns),1)])):F("",!0),u.toolCallCount?(m(),v("div",E2,[l[2]||(l[2]=h("dt",null,"工具",-1)),h("dd",null,C(u.toolCallCount),1)])):F("",!0),o(u.durationMs)?(m(),v("div",A2,[l[3]||(l[3]=h("dt",null,"耗时",-1)),h("dd",null,C(o(u.durationMs)),1)])):F("",!0),r(u)!==null?(m(),v("div",M2,[l[4]||(l[4]=h("dt",null,"Token",-1)),h("dd",null,C(i(r(u))),1)])):F("",!0)])):F("",!0)]))),128))]))])]))}}),P2=Te(R2,[["__scopeId","data-v-7f938bff"]]),L2={class:"settings"},D2={class:"settings-layout"},N2={class:"rail","aria-label":"设置分区"},O2=["aria-current","onClick"],G2={class:"pane"},B2={key:0,class:"pane-section"},F2={class:"block"},U2={class:"theme-grid",role:"radiogroup","aria-label":"主题"},j2=["aria-checked","onClick"],z2={class:"block"},H2={class:"like-fields"},W2={class:"like-label"},q2=["onUpdate:modelValue","placeholder","aria-label"],V2={class:"like-actions"},K2={key:0,class:"saved-hint"},Z2={key:1,class:"pane-section"},Y2={key:0,class:"notice-bar"},X2={key:1,class:"error-row",role:"alert"},J2={class:"error-text"},Q2={key:2,class:"empty"},eP={key:3,class:"list"},tP={class:"row-main"},nP={class:"row-title"},sP={class:"row-sub"},oP=["disabled","onClick"],rP={key:2,class:"pane-section"},iP={key:0,class:"empty"},aP={key:1,class:"list"},lP={class:"row-main"},uP={class:"row-title"},cP={class:"row-sub"},dP={class:"row-actions"},fP=["disabled","onClick"],hP=["disabled","onClick"],pP={key:3,class:"pane-section"},gP={class:"block"},mP={class:"inline-form"},vP={key:0,class:"hint"},yP={key:0,class:"empty"},bP={key:1,class:"list"},kP={class:"row-main"},wP={class:"row-title"},SP={key:0,class:"version"},_P={class:"row-sub"},$P=["disabled","onClick"],CP={key:4,class:"pane-section"},xP={key:0,class:"hint"},IP={key:1,class:"empty"},TP={key:2,class:"list"},EP={class:"row-main"},AP={class:"row-title"},MP={class:"row-sub"},RP={class:"row-actions"},PP=["disabled","onClick"],LP=["disabled","onClick"],DP=["disabled","onClick"],NP={key:5,class:"pane-section"},OP={class:"task-title-row"},GP={key:0,class:"hint"},BP={key:1,class:"empty"},FP={key:2,class:"list"},UP={class:"row-main"},jP={class:"row-title"},zP={class:"row-sub"},HP={class:"row-actions"},WP=["disabled","onClick"],qP=["disabled","onClick"],VP={key:3,class:"task-inspector","aria-label":"任务输出"},KP={class:"task-inspector-head"},ZP=["title"],YP={class:"task-inspector-actions"},XP=["disabled"],JP={key:0,class:"task-output"},QP={key:1,class:"task-output-empty"},eL={class:"task-meta"},tL={key:0},nL={key:1},sL=Ie({__name:"SettingsView",props:{like:{default:()=>({})},client:{}},emits:["update-like"],setup(e,{emit:t}){const n=e,s=t;function o(R){return R!==null&&typeof R=="object"&&R.__v_isRef===!0?R.value:R}const r=[{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"}],i=G("general"),a=B(()=>n.client),l=In("theme",G("system")),u=In("setTheme",()=>{}),c=[{id:"light",label:"浅色",icon:"sun"},{id:"dark",label:"深色",icon:"moon"},{id:"system",label:"跟随系统",icon:"monitor"}],d=G({...n.like}),f=G(!1);Se(()=>n.like,R=>{d.value={...R}});const p=[{key:"nickname",label:"称呼",hint:"AI 如何称呼你"},{key:"tone",label:"语气",hint:"回复的语气风格"},{key:"other",label:"偏好",hint:"其他偏好说明"},{key:"doNot",label:"禁止事项",hint:"明确禁止的行为"}];function g(){s("update-like",b()),f.value=!0,setTimeout(()=>f.value=!1,1500)}function b(){const R={};for(const K of p){const O=d.value[K.key];typeof O=="string"&&O.trim()&&(R[K.key]=O.trim())}return R}const S=B(()=>{var R;return o((R=a.value)==null?void 0:R.models)??[]}),w=B(()=>{var R,K;return((K=o((R=a.value)==null?void 0:R.status))==null?void 0:K.model)??""}),k=B(()=>{var R;return o((R=a.value)==null?void 0:R.modelsError)??""}),y=B(()=>{var R;return!!o((R=a.value)==null?void 0:R.currentSessionId)});function _(){var R,K;(K=(R=a.value)==null?void 0:R.fetchModels)==null||K.call(R)}function N(R){var K,O;(O=(K=a.value)==null?void 0:K.switchModel)==null||O.call(K,R)}const D=B(()=>{var R;return o((R=a.value)==null?void 0:R.skills)??[]}),E=G(!1);async function A(R){var K,O,Q,$;E.value=!0;try{await((O=(K=a.value)==null?void 0:K.activateSkill)==null?void 0:O.call(K,R))&&await(($=(Q=a.value)==null?void 0:Q.fetchSkills)==null?void 0:$.call(Q))}finally{E.value=!1}}async function T(R){var O,Q,$,H;if(!window.confirm(`移除技能「${R}」?`))return;await((Q=(O=a.value)==null?void 0:O.removeSkill)==null?void 0:Q.call(O,R))&&await((H=($=a.value)==null?void 0:$.fetchSkills)==null?void 0:H.call($))}const Z=B(()=>{var R;return o((R=a.value)==null?void 0:R.plugins)??[]}),W=G(!1);async function j(R,K){var O,Q,$,H;W.value=!0;try{await((Q=(O=a.value)==null?void 0:O.setPluginEnabled)==null?void 0:Q.call(O,R,K))&&await((H=($=a.value)==null?void 0:$.fetchPlugins)==null?void 0:H.call($))}finally{W.value=!1}}const ne=G(""),I=G(!1),M=G("");async function V(){var K,O;const R=ne.value.trim();if(R){I.value=!0,M.value="";try{const Q=await((O=(K=a.value)==null?void 0:K.installPlugin)==null?void 0:O.call(K,R));M.value=Q?`已安装 ${Q.displayName}`:"安装失败",Q&&(ne.value="")}finally{I.value=!1}}}const ie=B(()=>{var R;return o((R=a.value)==null?void 0:R.mcpServers)??[]}),me=G(!1),_e=G("");async function he(R,K){var O,Q,$,H;me.value=!0,_e.value="";try{const q=await((Q=(O=a.value)==null?void 0:O[R])==null?void 0:Q.call(O,K));_e.value=q?"操作成功":"操作失败",await((H=($=a.value)==null?void 0:$.fetchMcpServers)==null?void 0:H.call($))}finally{me.value=!1}}const ae=B(()=>{var R;return o((R=a.value)==null?void 0:R.backgroundTasks)??[]}),pe=G(""),oe=G(!1),ge=G(""),$e=G(null),Ne=G(!1);let Ue=0,Ke=null;const Ye=B(()=>$e.value?ae.value.find(R=>R.taskId===$e.value)??null:null),rt=B(()=>ae.value.some(R=>R.status==="running"));async function Dt(){var R,K;await((K=(R=a.value)==null?void 0:R.fetchBackgroundTasks)==null?void 0:K.call(R))}function x(){Ke!==null&&(window.clearInterval(Ke),Ke=null)}function P(){if(i.value!=="tasks"||!rt.value){x();return}Ke===null&&(Ke=window.setInterval(()=>{Dt(),Ye.value&&ee(Ye.value.taskId,!1)},3e3))}async function z(R){var O,Q;const K=ae.value.find($=>$.taskId===R);if(window.confirm(`停止后台任务「${(K==null?void 0:K.command)??R}」?`)){oe.value=!0,ge.value="";try{const $=await((Q=(O=a.value)==null?void 0:O.stopBackgroundTask)==null?void 0:Q.call(O,R));ge.value=$?"已停止":"取消失败",await Dt(),$e.value===R&&await ee(R,!1)}finally{oe.value=!1}}}async function ee(R,K=!0){var Q,$,H;K&&($e.value=R,pe.value="");const O=++Ue;Ne.value=!0,ge.value="";try{await(($=(Q=a.value)==null?void 0:Q.fetchBackgroundTaskOutput)==null?void 0:$.call(Q,R,200)),O===Ue&&$e.value===R&&(pe.value=o((H=a.value)==null?void 0:H.backgroundTaskOutput)??"")}finally{O===Ue&&(Ne.value=!1)}}et(()=>{var K,O,Q,$,H,q;const R=a.value;(K=R==null?void 0:R.fetchModels)==null||K.call(R),(O=R==null?void 0:R.fetchConfig)==null||O.call(R),(Q=R==null?void 0:R.fetchSkills)==null||Q.call(R),($=R==null?void 0:R.fetchPlugins)==null||$.call(R),(H=R==null?void 0:R.fetchMcpServers)==null||H.call(R),(q=R==null?void 0:R.fetchBackgroundTasks)==null||q.call(R)}),st(()=>{x()}),Se([i,rt],([R])=>{R==="tasks"&&Dt(),P()},{immediate:!0});function J(R){return R==="connected"||R==="completed"?"ok":R==="failed"||R==="killed"?"bad":R==="running"||R==="pending"?"run":"muted"}return(R,K)=>(m(),v("div",L2,[h("div",D2,[h("nav",N2,[(m(),v(te,null,Ce(r,O=>h("button",{key:O.id,class:ue(["rail-tab",{active:i.value===O.id}]),"aria-current":i.value===O.id?"page":void 0,onClick:Q=>i.value=O.id},[X(ce,{name:O.icon,size:16},null,8,["name"]),h("span",null,C(O.label),1)],10,O2)),64))]),h("div",G2,[i.value==="general"?(m(),v("section",B2,[K[6]||(K[6]=h("h1",{class:"settings-title"},"通用设置",-1)),h("div",F2,[K[3]||(K[3]=h("h2",{class:"block-title"},"外观",-1)),h("div",U2,[(m(),v(te,null,Ce(c,O=>h("button",{key:O.id,role:"radio","aria-checked":U(l)===O.id,class:ue(["theme-option",{active:U(l)===O.id}]),onClick:Q=>U(u)(O.id)},[X(ce,{name:O.icon,size:20},null,8,["name"]),h("span",null,C(O.label),1)],10,j2)),64))])]),h("div",z2,[K[5]||(K[5]=h("h2",{class:"block-title"},"偏好设置",-1)),h("div",H2,[(m(),v(te,null,Ce(p,O=>h("label",{key:O.key,class:"like-field"},[h("span",W2,C(O.label),1),Ze(h("input",{"onUpdate:modelValue":Q=>d.value[O.key]=Q,class:"like-input",placeholder:O.hint,"aria-label":O.label},null,8,q2),[[it,d.value[O.key]]])])),64)),h("div",V2,[X(Ht,{variant:"primary",onClick:g},{default:ot(()=>[...K[4]||(K[4]=[Ae("保存偏好",-1)])]),_:1}),f.value?(m(),v("span",K2,"已保存")):F("",!0)])])])])):i.value==="models"?(m(),v("section",Z2,[K[7]||(K[7]=h("h1",{class:"settings-title"},"模型",-1)),y.value?F("",!0):(m(),v("p",Y2,"打开一个会话后可在此切换模型")),k.value?(m(),v("div",X2,[h("span",J2,C(k.value),1),h("button",{class:"row-action",onClick:_},"重试")])):S.value.length===0?(m(),v("p",Q2,"没有可用的模型")):(m(),v("ul",eP,[(m(!0),v(te,null,Ce(S.value,O=>(m(),v("li",{key:O.alias,class:ue(["list-row",{selected:O.alias===w.value}])},[h("div",tP,[h("span",nP,C(O.displayName||O.model),1),h("span",sP,C(O.provider)+" · "+C(O.alias)+" · "+C(O.maxContextSize),1)]),h("button",{class:"row-action",disabled:!y.value||O.alias===w.value,onClick:Q=>N(O.alias)},C(O.alias===w.value?"使用中":"切换"),9,oP)],2))),128))]))])):i.value==="skills"?(m(),v("section",rP,[K[8]||(K[8]=h("h1",{class:"settings-title"},"技能",-1)),D.value.length===0?(m(),v("p",iP,"当前会话没有可用技能")):(m(),v("ul",aP,[(m(!0),v(te,null,Ce(D.value,O=>(m(),v("li",{key:O.name,class:"list-row"},[h("div",lP,[h("span",uP,C(O.name),1),h("span",cP,[Ae(C(O.description||"—")+" ",1),O.pluginId?(m(),v(te,{key:0},[Ae("· 来自插件 "+C(O.pluginId),1)],64)):F("",!0)])]),h("div",dP,[h("button",{class:"row-action",disabled:E.value,onClick:Q=>A(O.name)}," 激活 ",8,fP),h("button",{class:"row-action danger",disabled:E.value,onClick:Q=>T(O.name)}," 移除 ",8,hP)])]))),128))]))])):i.value==="plugins"?(m(),v("section",pP,[K[11]||(K[11]=h("h1",{class:"settings-title"},"插件",-1)),h("div",gP,[K[10]||(K[10]=h("h2",{class:"block-title"},"安装插件",-1)),h("div",mP,[Ze(h("input",{"onUpdate:modelValue":K[0]||(K[0]=O=>ne.value=O),class:"like-input",placeholder:"本地路径 / zip URL / GitHub 地址","aria-label":"插件来源",spellcheck:"false"},null,512),[[it,ne.value]]),X(Ht,{variant:"primary",disabled:I.value||!ne.value.trim(),onClick:V},{default:ot(()=>[...K[9]||(K[9]=[Ae(" 安装 ",-1)])]),_:1},8,["disabled"])]),M.value?(m(),v("p",vP,C(M.value),1)):F("",!0)]),Z.value.length===0?(m(),v("p",yP,"还没有安装插件")):(m(),v("ul",bP,[(m(!0),v(te,null,Ce(Z.value,O=>(m(),v("li",{key:O.id,class:"list-row"},[h("div",kP,[h("span",wP,[Ae(C(O.displayName)+" ",1),O.version?(m(),v("span",SP,"v"+C(O.version),1)):F("",!0)]),h("span",_P,C(O.skillCount)+" 技能 · "+C(O.enabledMcpServerCount)+"/"+C(O.mcpServerCount)+" MCP",1)]),h("button",{class:"row-action",disabled:W.value,onClick:Q=>j(O.id,!O.enabled)},C(O.enabled?"停用":"启用"),9,$P)]))),128))]))])):i.value==="mcp"?(m(),v("section",CP,[K[12]||(K[12]=h("h1",{class:"settings-title"},"MCP 服务器",-1)),_e.value?(m(),v("p",xP,C(_e.value),1)):F("",!0),ie.value.length===0?(m(),v("p",IP,"没有配置 MCP 服务器")):(m(),v("ul",TP,[(m(!0),v(te,null,Ce(ie.value,O=>(m(),v("li",{key:O.name,class:"list-row"},[h("div",EP,[h("span",AP,C(O.name),1),h("span",MP,C(O.transport)+" · "+C(O.toolCount)+" 工具",1),h("span",{class:ue(["status-pill",J(O.status)])},C(O.status),3)]),h("div",RP,[h("button",{class:"row-action",disabled:me.value,onClick:Q=>he("reconnectMcpServer",O.name)},"重连",8,PP),h("button",{class:"row-action",disabled:me.value,onClick:Q=>he("stopMcpServer",O.name)},"停止",8,LP),h("button",{class:"row-action danger",disabled:me.value,onClick:Q=>he("removeMcpServer",O.name)},"移除",8,DP)])]))),128))]))])):i.value==="tasks"?(m(),v("section",NP,[h("div",OP,[K[13]||(K[13]=h("h1",{class:"settings-title"},"后台任务",-1)),h("button",{class:"icon-refresh",title:"刷新后台任务","aria-label":"刷新后台任务",onClick:Dt},[X(ce,{name:"refresh",size:16})])]),ge.value?(m(),v("p",GP,C(ge.value),1)):F("",!0),ae.value.length===0?(m(),v("p",BP,"没有后台任务")):(m(),v("ul",FP,[(m(!0),v(te,null,Ce(ae.value,O=>(m(),v("li",{key:O.taskId,class:"list-row"},[h("div",UP,[h("span",jP,C(O.command),1),h("span",zP,C(O.description),1),h("span",{class:ue(["status-pill",J(O.status)])},C(O.status),3)]),h("div",HP,[h("button",{class:"row-action",disabled:oe.value,onClick:Q=>ee(O.taskId)},"输出",8,WP),O.status==="running"?(m(),v("button",{key:0,class:"row-action danger",disabled:oe.value,onClick:Q=>z(O.taskId)}," 停止 ",8,qP)):F("",!0)])]))),128))])),Ye.value?(m(),v("section",VP,[h("header",KP,[h("div",null,[K[14]||(K[14]=h("span",{class:"task-inspector-label"},"输出",-1)),h("strong",{title:Ye.value.command},C(Ye.value.command),9,ZP)]),h("div",YP,[h("button",{title:"刷新输出","aria-label":"刷新输出",disabled:Ne.value,onClick:K[1]||(K[1]=O=>ee(Ye.value.taskId,!1))},[X(ce,{name:"refresh",size:14})],8,XP),h("button",{title:"关闭输出","aria-label":"关闭输出",onClick:K[2]||(K[2]=O=>$e.value=null)},[X(ce,{name:"x",size:14})])])]),pe.value?(m(),v("pre",JP,C(pe.value),1)):(m(),v("p",QP,C(Ne.value?"正在读取输出…":"暂时没有输出"),1)),h("footer",eL,[h("span",null,"PID "+C(Ye.value.pid),1),Ye.value.exitCode!==null?(m(),v("span",tL,"退出码 "+C(Ye.value.exitCode),1)):(m(),v("span",nL,C(Ye.value.status),1))])])):F("",!0)])):F("",!0)])])]))}}),Xp=Te(sL,[["__scopeId","data-v-9c87c20d"]]),oL={class:"settings-modal-body"},rL=Ie({__name:"SettingsModal",setup(e){const{open:t}=gh(),n=B(()=>Ha()),s=B(()=>{var r;return((r=n.value)==null?void 0:r.like.value)??{}});function o(r){var i;(i=n.value)==null||i.updateLike(r)}return et(tb),st(()=>{nb(),Jr()}),(r,i)=>(m(),De(Vl,{open:U(t),title:"设置","max-width":"920px",onClose:U(Jr)},{default:ot(()=>[h("div",oL,[n.value?(m(),De(Xp,{key:0,client:n.value,like:s.value,onUpdateLike:o},null,8,["client","like"])):F("",!0)])]),_:1},8,["open","onClose"]))}}),iL=Te(rL,[["__scopeId","data-v-890b7003"]]),Rd=G(""),$a=G(new Set),gr=G(new Set),aL=G("sessions"),Ca=5;function lL(){function e(o){const r=new Set($a.value);r.has(o)?r.delete(o):r.add(o),$a.value=r}function t(o){const r=new Set(gr.value);r.has(o)?r.delete(o):r.add(o),gr.value=r}function n(o){return gr.value.has(o)}function s(){Rd.value=""}return{query:Rd,collapsedSpaces:$a,expandedSpaces:gr,section:aL,toggleSpace:e,toggleSpaceExpanded:t,isSpaceExpanded:n,clearSearch:s}}const uL=1440*60*1e3,cL=7,dL="昨天";function Pd(e){const t=new Date(e);return Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())/uL}function fL(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),s=String(t.getMinutes()).padStart(2,"0");return`${n}:${s}`}function hL(e,t=Date.now()){if(!Number.isFinite(e)||e<=0)return"";const n=Pd(t)-Pd(e);if(n<=0)return fL(e);if(n===1)return dL;if(n<=cL)return`${n} 天前`;const s=new Date(e);return`${s.getMonth()+1}/${s.getDate()}`}const Jp="scream-file-tree-expanded",pL=G("");function gL(){try{const e=localStorage.getItem(Jp);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(r=>typeof r=="string"));return n}return{}}catch{return{}}}const ts=G(gL()),go=Wn(new Map),xa=G(null),Ia=new Map;function mL(){function e(l){return l?new Set(ts.value[l]??[]):new Set}function t(l){if(!l)return;const u={...ts.value};u[l]=[...e(l)],ts.value=u;try{localStorage.setItem(Jp,JSON.stringify(u))}catch{}}function n(l){xa.value!==l&&(xa.value=l)}function s(l,u){var c;return l?((c=ts.value[l])==null?void 0:c.includes(u))??!1:!1}function o(l,u){if(!l)return!1;const c=ts.value[l]??[],d=c.includes(u)?c.filter(f=>f!==u):[...c,u];return ts.value={...ts.value,[l]:d},t(l),!c.includes(u)}function r(l){return go.get(l)??[]}async function i(l){const u=(Ia.get(l)??0)+1;Ia.set(l,u);const c=await Wl(l);return u!==(Ia.get(l)??0)?go.get(l)??[]:(c!==null&&go.set(l,c),go.get(l)??[])}function a(l){go.delete(l)}return{activeWorkDir:xa,query:pL,isExpanded:s,toggleExpand:o,loadedChildren:r,loadChildren:i,invalidate:a,setRoot:n}}const vL={class:"file-tree"},yL={key:0,class:"tree-toolbar"},bL={class:"tree-search"},kL={key:1,class:"tree-empty"},wL={key:2,class:"tree-empty"},SL={key:3,class:"tree-empty"},_L={key:4,class:"tree-empty"},$L=["aria-label"],CL=["aria-expanded","onClick"],xL=["title"],IL=["aria-expanded","onClick"],TL=["title"],EL=Ie({__name:"FileTree",props:{workDir:{},gitStatus:{},refreshGit:{type:Function}},setup(e){const t=e,{query:n,isExpanded:s,toggleExpand:o,loadedChildren:r,loadChildren:i,invalidate:a,setRoot:l}=mL(),u=G(!1),c=G(!1);Se(()=>t.workDir,D=>{l(D),D&&d(D)},{immediate:!0});async function d(D){u.value=!0,c.value=!1;try{(await i(D)).length===0&&(c.value=!0)}finally{u.value=!1}}async function f(D){const E=t.workDir;if(!E)return;o(E,D)&&await i(D)}function p(D,E){return`${D.replace(/\/+$/,"")}/${E}`}function g(D){const E=t.workDir;if(!E)return D;const A=E.replace(/\/+$/,"");return D===A?"":D.startsWith(`${A}/`)?D.slice(A.length+1):D}function b(D){var Z;const E=(Z=t.gitStatus)==null?void 0:Z.files;if(!E||E.length===0)return null;const A=g(D),T=E.find(W=>(W.displayPath??W.path)===A);return T?T.status.includes("?")?"?":T.status.includes("A")?"A":T.status.includes("M")?"M":null:null}const S=B(()=>{const D=t.workDir;if(!D)return[];const E=[],A=(T,Z)=>{for(const W of r(T)){const j=p(T,W.name);E.push({abs:j,name:W.name,rel:g(j),isDir:W.type==="dir",depth:Z,git:b(j)}),W.type==="dir"&&s(D,j)&&A(j,Z+1)}};return A(D,0),E}),w=B(()=>S.value),k=B(()=>{const D=n.value.trim();if(!D)return[];const E=new Map(w.value.map(A=>[A.rel,A]));return vh(w.value.map(A=>({path:A.rel,isDir:A.isDir})),D,50).map(A=>E.get(A.path)).filter(A=>A!==void 0)}),y=B(()=>n.value.trim().length>0);function _(D){D.isDir?f(D.abs):vs(D.abs)}function N(){var E;const D=t.workDir;D&&(a(D),Pb(D),d(D),(E=t.refreshGit)==null||E.call(t))}return(D,E)=>(m(),v("div",vL,[e.workDir?(m(),v("div",yL,[h("label",bL,[X(ce,{name:"search",size:13}),Ze(h("input",{"onUpdate:modelValue":E[0]||(E[0]=A=>ht(n)?n.value=A:null),type:"text",placeholder:"过滤文件…","aria-label":"过滤文件",spellcheck:"false"},null,512),[[it,U(n)]])]),h("button",{class:"tree-refresh",title:"刷新文件树与 Git 状态","aria-label":"刷新文件树与 Git 状态",onClick:N},[X(ce,{name:"refresh",size:13})])])):F("",!0),e.workDir?u.value&&S.value.length===0?(m(),v("div",wL,"加载中…")):c.value&&S.value.length===0?(m(),v("div",SL,"工作目录为空")):y.value&&k.value.length===0?(m(),v("div",_L,"没有匹配的文件")):(m(),v("div",{key:5,class:"tree-scroll",role:"tree","aria-label":"文件树 "+e.workDir},[y.value?(m(!0),v(te,{key:0},Ce(k.value,A=>(m(),v("button",{key:A.abs,class:ue(["tree-row",{"is-dir":A.isDir}]),role:"treeitem","aria-expanded":A.isDir?U(s)(e.workDir,A.abs):void 0,onClick:T=>_(A)},[X(ce,{name:A.isDir?"folder":"file",size:14,class:"row-icon"},null,8,["name"]),h("span",{class:"row-label mono",title:A.rel},C(A.rel),9,xL),A.git?(m(),v("span",{key:0,class:ue(["row-git",`g-${A.git}`])},C(A.git),3)):F("",!0)],10,CL))),128)):(m(!0),v(te,{key:1},Ce(S.value,A=>(m(),v("button",{key:A.abs,class:ue(["tree-row",{"is-dir":A.isDir}]),style:bt({paddingLeft:`${8+A.depth*14}px`}),role:"treeitem","aria-expanded":A.isDir?U(s)(e.workDir,A.abs):void 0,onClick:T=>_(A)},[X(ce,{name:A.isDir?U(s)(e.workDir,A.abs)?"chevron-down":"chevron-right":"file",size:13,class:"row-caret"},null,8,["name"]),X(ce,{name:A.isDir?"folder":"file",size:14,class:"row-icon"},null,8,["name"]),h("span",{class:ue(["row-label",{mono:!A.isDir}]),title:A.rel},C(A.name),11,TL),A.git?(m(),v("span",{key:0,class:ue(["row-git",`g-${A.git}`])},C(A.git),3)):F("",!0)],14,IL))),128))],8,$L)):(m(),v("div",kL,"当前会话没有工作目录"))]))}}),AL=Te(EL,[["__scopeId","data-v-f7cdf024"]]),Qp=""+new URL("logo-v2-ChmPAIbI.svg",import.meta.url).href,ML={class:"sidebar-head"},RL=["src"],PL=["title","aria-label","aria-expanded"],LL=["title"],DL={key:0},NL={key:0,class:"section-switch",role:"tablist","aria-label":"侧栏分区"},OL=["aria-selected"],GL=["aria-selected"],BL={key:0,class:"side-search"},FL=["placeholder"],UL={class:"spaces"},jL=["title"],zL=["title","onClick"],HL={class:"space-name"},WL={class:"space-count"},qL={key:0,class:"space-sessions"},VL=["title","onClick","onDblclick"],KL={key:0,class:"session-run","aria-hidden":"true"},ZL={class:"session-text"},YL={key:0,class:"session-rename"},XL=["aria-label","onKeydown","onBlur"],JL={class:"session-title"},QL={class:"session-meta"},eD={class:"session-actions"},tD=["disabled","title","aria-label","onClick"],nD=["title","aria-label","onClick"],sD=["aria-label"],oD={class:"delete-confirm-text"},rD={class:"delete-confirm-actions"},iD=["onClick"],aD=["title","onClick"],lD={key:0,class:"spaces-empty"},uD={class:"sidebar-foot","aria-label":"功能区"},cD=["title"],dD={key:0},fD=["title"],hD={key:0},pD={class:"sidebar-identity"},gD={key:0,class:"identity-text"},mD=Ie({__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,r=G(null),{query:i,collapsedSpaces:a,section:l,toggleSpace:u,toggleSpaceExpanded:c,isSpaceExpanded:d}=lL();function f(){var he,ae;(he=r.value)==null||he.focus(),(ae=r.value)==null||ae.select()}const{open:p}=gh();function g(){ph()||o("navigate","settings")}t({focusSearch:f});const b=B(()=>{const he=i.value.trim().toLowerCase();return he?s.sessions.filter(ae=>_e(ae).toLowerCase().includes(he)||ae.workDir.toLowerCase().includes(he)):s.sessions}),S=B(()=>{var pe;const he=new Map;for(const oe of b.value){const ge=oe.workDir||"默认空间",$e=ge.split(/[\\/]/).filter(Boolean),Ne=$e.length>0?$e[$e.length-1]:ge,Ue=he.get(ge);Ue?Ue.items.push(oe):he.set(ge,{key:ge,name:Ne,items:[oe]})}const ae=(pe=s.sessions.find(oe=>oe.sessionId===s.currentSessionId))==null?void 0:pe.workDir;return[...he.values()].sort((oe,ge)=>{var $e,Ne;return oe.key===ae?-1:ge.key===ae?1:((($e=ge.items[0])==null?void 0:$e.createdAt)??0)-(((Ne=oe.items[0])==null?void 0:Ne.createdAt)??0)})});function w(he){return i.value.trim()||d(he.key)?he.items:he.items.length>Ca?he.items.slice(0,Ca):he.items}function k(he){return Math.max(0,he.items.length-Ca)}function y(he){o("switch-session",he)}function _(he){return he.sessionId===s.currentSessionId}const N=G(null);function D(he){N.value=N.value===he.sessionId?null:he.sessionId}function E(){N.value=null}function A(he){E(),o("delete-session",he)}function T(he){if(!N.value)return;const ae=he.target;ae&&typeof ae.closest=="function"&&ae.closest(".session-actions")||E()}et(()=>document.addEventListener("pointerdown",T)),st(()=>document.removeEventListener("pointerdown",T));function Z(he){o("open-file",he)}const W=G(null);function j(he){W.value=he}const ne=G(null),I=G("");function M(he){ne.value=he.sessionId,I.value=_e(he),Fe(()=>{var ae,pe;(ae=W.value)==null||ae.focus(),(pe=W.value)==null||pe.select()})}function V(){ne.value=null,I.value=""}function ie(he){const ae=I.value.trim();if(ne.value=null,I.value="",!ae)return;const pe=s.sessions.find(oe=>oe.sessionId===he);!pe||ae===_e(pe)||o("rename-session",he,ae)}function me(he){return hL(he)}function _e(he){const ae=(he.title||"").trim();return ae&&ae!=="新会话"&&ae!=="New Session"?ae:"未命名会话"}return(he,ae)=>(m(),v("aside",{class:ue(["sidebar",{"is-collapsed":e.collapsed}])},[h("div",ML,[h("button",{class:"sidebar-brand",title:"回到新对话",onClick:ae[0]||(ae[0]=pe=>o("navigate","home"))},[h("img",{class:"brand-logo",src:U(Qp),alt:"scream"},null,8,RL)]),e.showCollapseToggle?(m(),v("button",{key:0,class:ue(["collapse-btn",{rotated:e.collapsed}]),title:e.collapsed?"展开侧栏":"折叠侧栏","aria-label":e.collapsed?"展开侧栏":"折叠侧栏","aria-expanded":!e.collapsed,onClick:ae[1]||(ae[1]=pe=>o("toggle-collapse"))},[X(ce,{name:"panel-left",size:15})],10,PL)):F("",!0)]),h("button",{class:"new-chat-btn",title:e.collapsed?"新建对话":void 0,onClick:ae[2]||(ae[2]=pe=>o("create-session"))},[X(ce,{name:"plus",size:16}),e.collapsed?F("",!0):(m(),v("span",DL,"新建对话"))],8,LL),e.collapsed?F("",!0):(m(),v("div",NL,[h("button",{class:ue(["section-tab",{active:U(l)==="sessions"}]),role:"tab","aria-selected":U(l)==="sessions",onClick:ae[3]||(ae[3]=pe=>l.value="sessions")},[X(ce,{name:"message-circle",size:13}),ae[11]||(ae[11]=h("span",null,"会话",-1))],10,OL),h("button",{class:ue(["section-tab",{active:U(l)==="files"}]),role:"tab","aria-selected":U(l)==="files",onClick:ae[4]||(ae[4]=pe=>l.value="files")},[X(ce,{name:"folder",size:13}),ae[12]||(ae[12]=h("span",null,"文件",-1))],10,GL)])),!e.collapsed&&U(l)==="files"?(m(),De(AL,{key:1,"work-dir":e.workDir,"git-status":e.gitStatus,"refresh-git":e.refreshGit,onOpenFile:Z},null,8,["work-dir","git-status","refresh-git"])):F("",!0),e.collapsed||U(l)==="sessions"?(m(),v(te,{key:2},[e.collapsed?F("",!0):(m(),v("label",BL,[X(ce,{name:"search",size:15}),Ze(h("input",{ref_key:"searchRef",ref:r,"onUpdate:modelValue":ae[5]||(ae[5]=pe=>ht(i)?i.value=pe:null),type:"text",placeholder:`搜索会话… (${U($r)}K)`,"aria-label":"搜索会话",spellcheck:"false"},null,8,FL),[[it,U(i)]])])),h("div",UL,[(m(!0),v(te,null,Ce(S.value,pe=>(m(),v("div",{key:pe.key,class:"space-group"},[e.collapsed?(m(),v("button",{key:0,class:ue(["space-dot",{active:pe.items.some(oe=>oe.sessionId===e.currentSessionId)}]),title:pe.name,onClick:ae[6]||(ae[6]=oe=>o("toggle-collapse"))},C(pe.name.slice(0,1).toUpperCase()),11,jL)):(m(),v(te,{key:1},[h("button",{class:"space-head",title:pe.key,onClick:oe=>U(u)(pe.key)},[X(ce,{name:U(a).has(pe.key)?"chevron-right":"chevron-down",size:14},null,8,["name"]),h("span",HL,C(pe.name),1),h("span",WL,C(pe.items.length),1)],8,zL),U(a).has(pe.key)?F("",!0):(m(),v("div",qL,[(m(!0),v(te,null,Ce(w(pe),oe=>(m(),v("div",{key:oe.sessionId,class:"session-item-wrap"},[h("button",{class:ue(["session-item",{active:oe.sessionId===e.currentSessionId}]),title:_e(oe),onClick:ge=>y(oe.sessionId),onDblclick:ge=>M(oe)},[oe.active?(m(),v("span",KL)):F("",!0),h("span",ZL,[ne.value===oe.sessionId?(m(),v("span",YL,[Ze(h("input",{ref_for:!0,ref:j,"onUpdate:modelValue":ae[7]||(ae[7]=ge=>I.value=ge),class:"rename-input",spellcheck:"false","aria-label":`重命名会话 ${_e(oe)}`,onClick:ae[8]||(ae[8]=tt(()=>{},["stop"])),onKeydown:[Vn(tt(ge=>ie(oe.sessionId),["prevent"]),["enter"]),ae[9]||(ae[9]=Vn(tt(ge=>V(),["prevent"]),["esc"]))],onBlur:ge=>ie(oe.sessionId)},null,40,XL),[[it,I.value]])])):(m(),v(te,{key:1},[h("span",JL,C(_e(oe)),1),h("span",QL,[h("span",null,C(me(oe.createdAt)),1),oe.messageCount>=0?(m(),v(te,{key:0},[ae[13]||(ae[13]=h("span",{class:"meta-sep","aria-hidden":"true"},"·",-1)),h("span",null,C(oe.messageCount)+" 条",1)],64)):F("",!0)])],64))])],42,VL),h("div",eD,[h("button",{type:"button",class:"session-act",disabled:!_(oe),title:_(oe)?"重命名会话":"只有当前打开的会话能重命名","aria-label":`重命名会话:${_e(oe)}`,onClick:tt(ge=>M(oe),["stop"])},[X(ce,{name:"edit",size:14})],8,tD),h("button",{type:"button",class:"session-act session-act--danger",title:`删除会话:${_e(oe)}`,"aria-label":`删除会话:${_e(oe)}`,onClick:tt(ge=>D(oe),["stop"])},[X(ce,{name:"trash",size:14})],8,nD),N.value===oe.sessionId?(m(),v("div",{key:0,class:"delete-confirm",role:"alertdialog","aria-label":`确认删除:${_e(oe)}`},[h("div",oD,"删除「"+C(_e(oe))+"」?不可恢复。",1),h("div",rD,[h("button",{type:"button",class:"dc-btn",onClick:tt(E,["stop"])},"取消"),h("button",{type:"button",class:"dc-btn dc-btn--danger",onClick:tt(ge=>A(oe.sessionId),["stop"])}," 确认删除 ",8,iD)])],8,sD)):F("",!0)])]))),128)),!U(i)&&k(pe)>0?(m(),v("button",{key:0,class:"space-more",type:"button",title:U(d)(pe.key)?"收起,只留最近几条":"展开这个空间的其余会话",onClick:oe=>U(c)(pe.key)},[X(ce,{name:"chevron-down",size:12,class:ue({"is-up":U(d)(pe.key)})},null,8,["class"]),h("span",null,C(U(d)(pe.key)?"收起":`显示更多 ${k(pe)} 条`),1)],8,aD)):F("",!0)]))],64))]))),128)),!e.collapsed&&S.value.length===0?(m(),v("p",lD,C(U(i)?"没有匹配的会话":"还没有会话,点击上方「新建对话」开始"),1)):F("",!0)])],64)):F("",!0),h("nav",uD,[h("button",{class:ue(["foot-item",{active:e.view==="skills"}]),title:e.collapsed?"技能中心":void 0,onClick:ae[10]||(ae[10]=pe=>o("navigate","skills"))},[X(ce,{name:"sparkles",size:17}),e.collapsed?F("",!0):(m(),v("span",dD,"技能中心"))],10,cD),h("button",{class:ue(["foot-item",{active:e.view==="settings"||U(p)}]),title:e.collapsed?"设置":void 0,onClick:g},[X(ce,{name:"settings",size:17}),e.collapsed?F("",!0):(m(),v("span",hD,"设置"))],10,fD),h("div",pD,[ae[14]||(ae[14]=h("span",{class:"identity-dot","aria-hidden":"true"},null,-1)),e.collapsed?F("",!0):(m(),v("span",gD,"scream web"))])])],2))}}),Ld=Te(mD,[["__scopeId","data-v-8f86aaa3"]]),vD={class:"skills"},yD={class:"skills-head"},bD={class:"skills-head-actions"},kD={key:0,class:"skills-error",role:"alert"},wD={key:1,class:"skills-grid","aria-hidden":"true"},SD={key:2,class:"skills-empty"},_D={class:"skills-empty-title"},$D={key:3,class:"skills-grid"},CD={class:"skill-card-head"},xD={class:"skill-cmd"},ID={class:"skill-source"},TD={class:"skill-desc"},ED={class:"skill-card-foot"},AD=Ie({__name:"SkillsView",props:{client:{default:void 0},injectDraft:{type:Function,default:void 0}},emits:["create"],setup(e,{emit:t}){const n=e,s=t,{showToast:o}=Qs(),{activeClient:r}=Kv(),i=B(()=>n.client??r.value);function a(w){return w!==null&&typeof w=="object"&&w.__v_isRef===!0?w.value:w}const l=B(()=>{var w;return a((w=i.value)==null?void 0:w.skills)??[]}),u=B(()=>{var w;return a((w=i.value)==null?void 0:w.skillsError)??""}),c=B(()=>{var w,k;return!!a(((w=i.value)==null?void 0:w.currentSessionId)??((k=i.value)==null?void 0:k.sessionId))}),d=G(!1);async function f(){const w=i.value;if(w!=null&&w.fetchSkills){d.value=!0;try{await w.fetchSkills()}finally{d.value=!1}}}et(f);const p={builtin:"内置",user:"用户",extra:"扩展",project:"项目"};function g(w){return w.pluginId?`插件 ${w.pluginId}`:p[w.source]||w.source||"本地"}async function b(w){try{return await navigator.clipboard.writeText(w),!0}catch{return!1}}async function S(w){var N;const k=`/${w.name} `;let y=!1;try{y=!!await((N=n.injectDraft)==null?void 0:N.call(n,k))}catch{y=!1}if(y)return;const _=await b(k);s("create"),o(_?`已复制 ${k.trim()},在输入框粘贴后回车即可使用`:`在输入框输入 ${k.trim()} 并回车即可使用该技能`,"info")}return(w,k)=>(m(),v("div",vD,[h("div",yD,[k[4]||(k[4]=h("div",null,[h("h1",{class:"skills-title"},"技能中心"),h("p",{class:"skills-sub"},[Ae(" 当前会话的可用技能;在输入框输入 "),h("code",null,"/"),Ae(" 可从菜单调用,命令帮助见 "),h("code",null,"/help")])],-1)),h("div",bD,[X(Ht,{variant:"ghost",disabled:d.value||!c.value,onClick:f},{default:ot(()=>[X(ce,{name:"refresh",size:16}),k[2]||(k[2]=Ae(" 重新加载 ",-1))]),_:1},8,["disabled"]),X(Ht,{variant:"primary",onClick:k[0]||(k[0]=y=>s("create"))},{default:ot(()=>[X(ce,{name:"plus",size:16}),k[3]||(k[3]=Ae(" 新建会话 ",-1))]),_:1})])]),u.value?(m(),v("p",kD,[Ae(C(u.value)+" ",1),h("button",{class:"skills-retry",onClick:f},"重试")])):F("",!0),d.value&&l.value.length===0?(m(),v("div",wD,[(m(),v(te,null,Ce(6,y=>h("div",{key:y,class:"skill-card skeleton"},[...k[5]||(k[5]=[h("span",{class:"skeleton-line skeleton-line-title"},null,-1),h("span",{class:"skeleton-line"},null,-1),h("span",{class:"skeleton-line skeleton-line-short"},null,-1)])])),64))])):l.value.length===0&&!u.value?(m(),v("div",SD,[X(ce,{name:"sparkles",size:28}),h("p",_D,C(c.value?"这个会话还没有可用技能":"打开会话后可查看技能"),1),k[7]||(k[7]=h("p",{class:"skills-empty-hint"}," 技能可以放在技能目录(用户 / 额外目录),或随插件安装进来;装好后点「重新加载」。 ",-1)),X(Ht,{variant:"primary",onClick:k[1]||(k[1]=y=>s("create"))},{default:ot(()=>[X(ce,{name:"plus",size:16}),k[6]||(k[6]=Ae(" 新建会话 ",-1))]),_:1})])):(m(),v("div",$D,[(m(!0),v(te,null,Ce(l.value,y=>(m(),v("article",{key:y.name,class:"skill-card"},[h("div",CD,[h("span",xD,"/"+C(y.name),1),h("span",ID,C(g(y)),1)]),h("p",TD,C(y.description||"暂无描述"),1),h("div",ED,[X(Ht,{variant:"secondary",onClick:_=>S(y)},{default:ot(()=>[X(ce,{name:"send",size:14}),k[8]||(k[8]=Ae(" 试用 ",-1))]),_:1},8,["onClick"])])]))),128))]))]))}}),MD=Te(AD,[["__scopeId","data-v-60c38852"]]),RD={class:"dock-tabs",role:"tablist","aria-label":"右栏标签","aria-orientation":"horizontal"},PD=["onAuxclick"],LD=["id","aria-selected","aria-controls","tabindex","title","data-kind","onClick","onKeydown"],DD={class:"tab-label"},ND=["title","aria-label","onClick"],OD={class:"dock-chrome"},GD=["title","aria-label","aria-pressed"],BD=Ie({__name:"TabBar",props:{maximized:{type:Boolean,default:!1},showMaximize:{type:Boolean,default:!0}},emits:["update:maximized","collapse"],setup(e,{emit:t}){const n=t,s=G(null);Se(()=>we.activeTabId,async()=>{var d,f;await Fe();const c=(d=s.value)==null?void 0:d.querySelector(".tab-button.active");(f=c==null?void 0:c.scrollIntoView)==null||f.call(c,{block:"nearest",inline:"nearest"})},{immediate:!0});function o(c,d){c.button===1&&(c.preventDefault(),c.stopPropagation(),a(d))}function r(c){c&&Fe(()=>{var d;return(d=document.getElementById(Yr(c)))==null?void 0:d.focus()})}function i(c){Xy(c),r(c)}function a(c){const d=we.activeTabId===c;Jy(c),d&&r(we.activeTabId)}function l(c){return qa(c.kind==="file"?"file-pane":c.id)}function u(c,d){const f=we.tabs,p=f.findIndex(S=>S.id===d);if(p<0)return;if(c.key==="Enter"||c.key===" "){c.preventDefault(),i(d);return}let g=-1;if(c.key==="ArrowRight"?g=(p+1)%f.length:c.key==="ArrowLeft"?g=(p-1+f.length)%f.length:c.key==="Home"?g=0:c.key==="End"&&(g=f.length-1),g<0)return;c.preventDefault();const b=f[g];b&&i(b.id)}return(c,d)=>(m(),v("div",{ref_key:"barRef",ref:s,class:"tab-bar"},[h("div",RD,[(m(!0),v(te,null,Ce(U(we).tabs,f=>(m(),v("div",{key:f.id,class:ue(["tab-entry",{active:f.id===U(we).activeTabId}]),role:"presentation",onAuxclick:p=>o(p,f.id)},[h("button",{id:U(Yr)(f.id),class:ue(["tab-button",{active:f.id===U(we).activeTabId}]),role:"tab","aria-selected":f.id===U(we).activeTabId,"aria-controls":l(f),tabindex:f.id===U(we).activeTabId?0:-1,title:f.kind==="file"?f.filePath:f.label,"data-kind":f.kind,onClick:p=>i(f.id),onKeydown:p=>u(p,f.id),onMousedown:d[0]||(d[0]=p=>{p.button===1&&p.preventDefault()})},[X(ce,{name:U(dh)(f.kind).icon,size:13,class:"tab-icon"},null,8,["name"]),h("span",DD,C(f.label),1)],42,LD),h("button",{class:"tab-close",title:`关闭 ${f.label}`,"aria-label":`关闭 ${f.label}`,onClick:tt(p=>a(f.id),["stop"])},[X(ce,{name:"x",size:11})],8,ND)],42,PD))),128))]),h("div",OD,[e.showMaximize?(m(),v("button",{key:0,class:"dock-chrome-btn dock-chrome-maximize",title:e.maximized?"退出全屏":"全屏","aria-label":e.maximized?"退出全屏":"全屏","aria-pressed":e.maximized,onClick:d[1]||(d[1]=f=>n("update:maximized",!e.maximized))},[X(ce,{name:e.maximized?"minimize":"expand",size:14},null,8,["name"])],8,GD)):F("",!0),h("button",{class:"dock-chrome-btn dock-chrome-collapse",title:"折叠右栏","aria-label":"折叠右栏",onClick:d[2]||(d[2]=f=>n("collapse"))},[X(ce,{name:"panel-right",size:14})])])],512))}}),FD=Te(BD,[["__scopeId","data-v-e9125a46"]]),UD={class:"mode-switch",role:"group","aria-label":"工作模式"},jD=["aria-pressed","onClick"],zD=Ie({__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,r)=>(m(),v("div",UD,[(m(),v(te,null,Ce(s,i=>h("button",{key:i.id,class:ue(["mode-pill",`is-${i.id}`,{active:e.modelValue===i.id}]),"aria-pressed":e.modelValue===i.id,onClick:a=>n("update:modelValue",i.id)},C(i.label),11,jD)),64))]))}}),HD=Te(zD,[["__scopeId","data-v-c4ac7862"]]),WD={class:"workspace"},qD={class:"workspace-hero"},VD={class:"workspace-brand"},KD=["src"],ZD={class:"workspace-status","aria-label":"连接与模型状态"},YD={class:"status-item"},XD={class:"status-item status-model"},JD={class:"workspace-launch"},QD={class:"mode-hint"},eN={class:"quick-start"},tN={class:"quick-label"},nN={class:"quick-chips"},sN=["title","onClick"],oN={class:"workspace-composer"},rN="scream-recent-prompts",iN=Ie({__name:"WorkspaceHome",props:{models:{},status:{default:void 0},busy:{type:Boolean},mode:{default:"chat"},recentWorkDirs:{default:()=>[]}},emits:["send","command","switch-model","switch-thinking","update:mode","abort"],setup(e,{expose:t,emit:n}){const s=e,o=n,r=B(()=>s.mode==="goal"),i=B(()=>r.value?"任务模式:提交后将创建执行目标(Goal),Agent 持续执行到完成或预算耗尽;抽屉「Goal 管理」可查看与暂停。":"直接对话:提问后 Agent 按需调用工具完成你的请求。"),a=B(()=>s.status!==void 0),l=B(()=>{var w;return(w=s.status)==null?void 0:w.model}),u=G([]),{fetchServerWorkDir:c}=Hl();et(()=>{c();try{const w=localStorage.getItem(rN);if(w){const k=JSON.parse(w);Array.isArray(k)&&(u.value=k.filter(y=>typeof y=="string").slice(0,4))}}catch{u.value=[]}});const d={chat:["梳理当前项目结构","解释最近的代码改动","帮我排查一个报错"],goal:["修复构建并跑通测试","完成一次小型重构","整理项目文档"]},f=B(()=>u.value.length>0),p=B(()=>f.value?u.value:d[s.mode]),g=G(null);function b(w){var k;(k=g.value)==null||k.insertText(w)}function S(w){const k=g.value;return k?(k.insertDraft(w,{activate:!0}),!0):!1}return t({insertDraft:S}),(w,k)=>(m(),v("div",WD,[h("section",qD,[h("h1",VD,[h("img",{class:"brand-logo",src:U(Qp),alt:"scream"},null,8,KD)]),k[7]||(k[7]=h("p",{class:"workspace-tagline"},"你的智能协作伙伴",-1)),h("p",ZD,[h("span",{class:ue(["status-dot",a.value?"on":"off"]),"aria-hidden":"true"},null,2),h("span",YD,C(a.value?"已连接":"等待连接"),1),l.value?(m(),v(te,{key:0},[k[6]||(k[6]=h("span",{class:"status-sep"},"·",-1)),h("span",XD,C(l.value),1)],64)):F("",!0)])]),h("section",JD,[X(HD,{class:"workspace-mode","model-value":s.mode,"onUpdate:modelValue":k[0]||(k[0]=y=>o("update:mode",y))},null,8,["model-value"]),h("p",QD,[(m(),v("span",{key:String(r.value),class:"hint-fade"},C(i.value),1))]),h("div",eN,[h("span",tN,C(f.value?"最近":"试试"),1),h("div",nN,[(m(!0),v(te,null,Ce(p.value,(y,_)=>(m(),v("button",{key:`${_}-${y}`,class:"quick-chip",title:y,onClick:N=>b(y)},C(y),9,sN))),128))])])]),h("section",oN,[X(kh,{ref_key:"composerRef",ref:g,busy:e.busy,status:e.status,models:e.models,"recent-work-dirs":e.recentWorkDirs,variant:"home",placeholder:r.value?"描述你要完成的目标,Enter 创建并开始执行…":"输入 @ 引用知识库 / 使用技能 / 或者直接提问...",onSend:k[1]||(k[1]=y=>o("send",y,s.mode)),onAbort:k[2]||(k[2]=y=>o("abort")),onCommand:k[3]||(k[3]=(y,_)=>o("command",y,_)),onSwitchModel:k[4]||(k[4]=y=>o("switch-model",y)),onSwitchThinking:k[5]||(k[5]=y=>o("switch-thinking",y))},null,8,["busy","status","models","recent-work-dirs","placeholder"])])]))}}),aN=Te(iN,[["__scopeId","data-v-1f7fc15b"]]),lN=["aria-valuenow","aria-valuemin","aria-valuemax"],uN={key:2,class:"sidebar-mobile",role:"dialog","aria-modal":"true","aria-label":"导航菜单"},cN={class:"canvas"},dN={class:"topbar mobile-only"},fN={class:"topbar-left"},hN={key:0,class:"topbar-running",title:"Agent 运行中"},pN={class:"canvas-body"},gN=["aria-valuenow","aria-valuemin","aria-valuemax"],mN=["role","aria-modal"],vN={class:"right-panel-body"},yN=["id","aria-labelledby"],bN=["data-dock-tab","id","aria-labelledby"],Dd="scream-sidebar-collapsed",Nd="scream-workspace-mode",kN=Ie({__name:"WebShell",setup(e){var xs,tr;const t=Ay(),{showToast:n}=Qs(),{connectionStatus:s,status:o,isBusy:r,sessions:i,currentSessionId:a,workDir:l,gitStatus:u,models:c,like:d,sendPrompt:f,sendCommand:p,appendSystemMessage:g,createSession:b,switchSession:S,deleteSession:w,switchModel:k,switchThinking:y,fetchLike:_,fetchGitStatus:N,abort:D}=t,E=G("home"),A=G(!1),T=G(null),Z=t.waitForConnected??((de=0)=>Promise.resolve(s.value==="connected")),W=()=>s.value==="connected";function j(de){de==="chat"?E.value=a.value?"chat":"home":E.value=de,A.value=!1}function ne(){A.value=!1,Jr(),me.value=!0}async function I(de){me.value=!1,ie(de.workDir);const ve=a.value,L=de.model&&de.model!==o.value.model?de.model:null;await b(de.workDir??void 0,()=>{E.value="chat"}),!(!a.value||a.value===ve)&&(L&&k(L),E.value="chat")}const{preferredWorkDir:M,serverWorkDir:V,setPreferredWorkDir:ie}=Hl(),me=G(!1),_e=B(()=>{const de=new Set,ve=[];for(const L of i.value){const re=L.workDir;if(!(!re||de.has(re))&&(de.add(re),ve.push(re),ve.length>=6))break}return ve}),he=G(null),ae=G(null);async function pe(de){var re,Me;A.value=!1;const ve=!a.value;E.value=ve?"home":"chat",await Fe(),await Fe();const L=ve?((re=ae.value)==null?void 0:re.insertDraft(de))??!1:((Me=he.value)==null?void 0:Me.insertDraft(de,{activate:!0}))??!1;return L&&n(`已把 ${de.trim()} 放进输入框,补参数后回车`,"success"),L}function oe(de){Fe(()=>{var ve;return(ve=ae.value)==null?void 0:ve.insertDraft(de)})}let ge=!1;async function $e(de,ve){if(A.value=!1,ge){oe(de);return}ge=!0;try{const L=a.value;if(await b(M.value??void 0),a.value===L){oe(de);return}if(!await Z()){oe(de);return}if(E.value="chat",ve==="goal")try{await t.createGoal({objective:de,budgets:[]})}catch(Me){g(`Goal 创建失败:${Ne(Me)}。已保留对话模式,可重新发送。`),f(de);return}else f(de)}finally{ge=!1}}function Ne(de){return de instanceof Error?de.message:String(de)}function Ue(de){A.value=!1,E.value="chat",S(de)}function Ke(de){vs(de)}function Ye(de,ve){if(de!==a.value){n("请先点击该会话,再双击重命名。","warning");return}p("title",ve)}const rt=G(!1),Dt=G("status");function x(de){t.fetchSnapshot(),Dt.value=de,rt.value=!0}const{onCommand:P}=lh({sendCommand:p,clearMessages:t.clearMessages,appendSystemMessage:g,ensureSession:async()=>{a.value||await b(M.value??void 0);const de=a.value;return de?s.value!=="connected"&&(!await Z()||a.value!==de||!W())?(n("会话连接尚未就绪,请稍后重试。","warning"),!1):a.value===de&&W():!1},onNew:ne,showInfo:x,currentModel:()=>o.value.model}),z=G(Kr(Dd)==="1"),ee=`(max-width: ${Dy-1}px)`,J=(tr=(xs=globalThis.window)==null?void 0:xs.matchMedia)==null?void 0:tr.call(xs,ee),R=G((J==null?void 0:J.matches)??!1);function K(de){R.value=de.matches}const O=B(()=>R.value||z.value);function Q(){if(R.value){A.value=!A.value;return}z.value=!z.value,Zr(Dd,z.value?"1":"0")}const $=G(window.innerWidth),H=B(()=>$.value>=Fl);function q(){$.value=window.innerWidth}const se=Sc({storageKey:"scream-sidebar-width",minWidth:kc,maxWidth:()=>By({viewportWidth:$.value,rightPanelOpen:we.panelOpen,rightPanelWidth:Oe.value}),defaultWidth:Ny,side:"left",canDrag:()=>!O.value,acceptStoredWidth:de=>de<=Vr}),fe=se.width,ye=se.resizing,Ee=B(()=>Fy({viewportWidth:$.value,sidebarOpen:!z.value,sidebarWidth:O.value?wc:fe.value})),ke=Sc({storageKey:"scream-right-panel-width",minWidth:Wa,maxWidth:()=>Ee.value,defaultWidth:()=>Gy($.value),side:"right"}),be=ke.resizing,Oe=ke.effectiveWidth,lt=G(!1);function gt(){jl(!1)}Se(H,()=>{be.value&&ke.release()}),Se(O,()=>{O.value&&ye.value&&se.release()}),Se(R,de=>{de||(A.value=!1)}),Se(()=>we.panelOpen,de=>{de||(lt.value=!1)});const sn=B(()=>({"--sidebar-track":`${O.value?wc:fe.value}px`,"--sidebar-width":`${fe.value}px`,"--dock-track":`${we.panelOpen&&H.value&&!lt.value?Oe.value:0}px`})),Ss={detail:GR,control:d2,agents:P2,run:Zp,git:qp,todo:Yp,goal:Vp,like:Kp},mt=B(()=>we.tabs.filter(de=>de.kind!=="file")),Nt=B(()=>{var de;return((de=Va())==null?void 0:de.kind)??"file"}),_s=B(()=>{const de=Va();return de?Yr(de.id):void 0}),$s=qa("file-pane"),oo=B(()=>Nt.value==="file");function Ui(de){vs(de.path,{modeHint:"diff",label:de.display})}const on={refresh:()=>N(),diff:Ui};function Cs(de){switch(de){case"detail":return{client:t};case"control":return{client:t};case"agents":return{subagents:t.subagents.value};case"run":return{status:t.status.value,busy:t.isBusy.value,connectionStatus:t.connectionStatus.value};case"git":return{gitStatus:t.gitStatus.value};case"todo":return{todos:t.todos.value};case"like":return{like:t.like.value,updateLike:t.updateLike};case"goal":return{goal:t.goal.value,sessionId:t.sessionId.value,connectionStatus:t.connectionStatus.value,busy:t.isBusy.value,archived:t.isArchived.value,pending:t.goalRequestPending.value,error:t.goalRequestError.value,refineGoal:t.refineGoal,createGoal:t.createGoal,updateGoal:t.updateGoal,pauseGoal:t.pauseGoal,resumeGoal:t.resumeGoal,cancelGoal:t.cancelGoal}}}function ji(de){return de==="git"?on:{}}const ro=G(Kr(Nd)==="goal"?"goal":"chat");function zi(de){ro.value=de,Zr(Nd,de)}function er(de){if((de.metaKey||de.ctrlKey)&&de.key==="k")de.preventDefault(),O.value&&!A.value&&Q(),Fe(()=>{var ve,L;return(L=(ve=T.value)==null?void 0:ve.focusSearch)==null?void 0:L.call(ve)});else if((de.metaKey||de.ctrlKey)&&de.key==="n")de.preventDefault(),ne();else if(de.key==="Escape"&&r.value){const ve=de.target;ve&&(ve.tagName==="TEXTAREA"||ve.tagName==="INPUT")||(de.preventDefault(),D())}}return et(()=>{var de;window.addEventListener("keydown",er),window.addEventListener("resize",q),(de=J==null?void 0:J.addEventListener)==null||de.call(J,"change",K),_(),N()}),st(()=>{var de;window.removeEventListener("keydown",er),window.removeEventListener("resize",q),(de=J==null?void 0:J.removeEventListener)==null||de.call(J,"change",K)}),(de,ve)=>(m(),v("div",{class:ue(["shell",{"sidebar-collapsed":O.value,resizing:U(ye)||U(be),"right-panel-open":U(we).panelOpen&&H.value,"dock-maximized":U(we).panelOpen&&lt.value}]),style:bt(sn.value)},[X(Ld,{ref_key:"sidebarRef",ref:T,view:E.value,sessions:U(i),"current-session-id":U(a),"work-dir":U(l),"git-status":U(u),"refresh-git":U(N),collapsed:O.value,onNavigate:j,onSwitchSession:Ue,onDeleteSession:U(w),onCreateSession:ne,onToggleCollapse:Q,onOpenFile:Ke,onRenameSession:Ye},null,8,["view","sessions","current-session-id","work-dir","git-status","refresh-git","collapsed","onDeleteSession"]),O.value?F("",!0):(m(),v("div",{key:0,class:ue(["panel-resize-handle panel-resize-handle--left",{resizing:U(ye)}]),role:"separator","aria-orientation":"vertical","aria-label":"调整侧栏宽度","aria-valuenow":U(fe),"aria-valuemin":U(kc),"aria-valuemax":U(Vr),tabindex:"0",title:"拖拽调整宽度 · 双击复位",onPointerdown:ve[0]||(ve[0]=(...L)=>U(se).onPointerDown&&U(se).onPointerDown(...L)),onPointermove:ve[1]||(ve[1]=(...L)=>U(se).onPointerMove&&U(se).onPointerMove(...L)),onPointerup:ve[2]||(ve[2]=(...L)=>U(se).onPointerUp&&U(se).onPointerUp(...L)),onPointercancel:ve[3]||(ve[3]=(...L)=>U(se).onPointerUp&&U(se).onPointerUp(...L)),onDblclick:ve[4]||(ve[4]=(...L)=>U(se).reset&&U(se).reset(...L)),onKeydown:ve[5]||(ve[5]=(...L)=>U(se).onKeydown&&U(se).onKeydown(...L))},null,42,lN)),A.value?(m(),v("div",{key:1,class:"sidebar-backdrop","aria-hidden":"true",onClick:ve[6]||(ve[6]=L=>A.value=!1)})):F("",!0),A.value?(m(),v("div",uN,[X(Ld,{view:E.value,sessions:U(i),"current-session-id":U(a),"work-dir":U(l),"git-status":U(u),"refresh-git":U(N),"show-collapse-toggle":!1,onNavigate:j,onSwitchSession:Ue,onDeleteSession:U(w),onCreateSession:ne,onOpenFile:Ke,onRenameSession:Ye},null,8,["view","sessions","current-session-id","work-dir","git-status","refresh-git","onDeleteSession"])])):F("",!0),h("main",cN,[h("header",dN,[h("div",fN,[h("button",{class:"topbar-icon mobile-menu",title:"菜单","aria-label":"打开菜单",onClick:ve[7]||(ve[7]=L=>A.value=!0)},[X(ce,{name:"menu",size:20})]),U(r)?(m(),v("span",hN,[...ve[18]||(ve[18]=[h("span",{class:"running-dot","aria-hidden":"true"},null,-1),h("span",{class:"running-text"},"运行中",-1)])])):F("",!0)])]),h("div",pN,[E.value==="home"?(m(),De(aN,{key:0,ref_key:"workspaceHomeRef",ref:ae,models:U(c),status:U(o),busy:U(r),mode:ro.value,"recent-work-dirs":_e.value,"onUpdate:mode":zi,onSend:$e,onAbort:U(D),onCommand:U(P),onSwitchModel:U(k),onSwitchThinking:U(y)},null,8,["models","status","busy","mode","recent-work-dirs","onAbort","onCommand","onSwitchModel","onSwitchThinking"])):E.value==="chat"?(m(),De(PE,{key:1,ref_key:"conversationRef",ref:he,client:U(t),onHome:ve[8]||(ve[8]=L=>E.value="home")},null,8,["client"])):E.value==="skills"?(m(),De(MD,{key:2,"inject-draft":pe,onCreate:ne})):E.value==="settings"?(m(),De(Xp,{key:3,like:U(d),client:U(t),onUpdateLike:U(t).updateLike},null,8,["like","client","onUpdateLike"])):F("",!0)])]),U(we).panelOpen&&!H.value?(m(),v("div",{key:3,class:"right-panel-backdrop","aria-hidden":"true",onClick:gt})):F("",!0),U(we).panelOpen&&H.value&&!lt.value?(m(),v("div",{key:4,class:ue(["panel-resize-handle panel-resize-handle--right",{resizing:U(be)}]),role:"separator","aria-orientation":"vertical","aria-label":"调整右栏宽度","aria-valuenow":U(Oe),"aria-valuemin":U(Wa),"aria-valuemax":Ee.value,tabindex:"0",title:"拖拽调整宽度 · 双击复位",onPointerdown:ve[9]||(ve[9]=(...L)=>U(ke).onPointerDown&&U(ke).onPointerDown(...L)),onPointermove:ve[10]||(ve[10]=(...L)=>U(ke).onPointerMove&&U(ke).onPointerMove(...L)),onPointerup:ve[11]||(ve[11]=(...L)=>U(ke).onPointerUp&&U(ke).onPointerUp(...L)),onPointercancel:ve[12]||(ve[12]=(...L)=>U(ke).onPointerUp&&U(ke).onPointerUp(...L)),onDblclick:ve[13]||(ve[13]=(...L)=>U(ke).reset&&U(ke).reset(...L)),onKeydown:ve[14]||(ve[14]=(...L)=>U(ke).onKeydown&&U(ke).onKeydown(...L))},null,42,gN)):F("",!0),U(we).panelOpen?(m(),v("aside",{key:5,class:ue(["right-panel",{overlay:!H.value,maximized:lt.value}]),role:H.value?void 0:"dialog","aria-modal":H.value?void 0:"true","aria-label":"右栏"},[X(FD,{maximized:lt.value,"show-maximize":H.value,"onUpdate:maximized":ve[15]||(ve[15]=L=>lt.value=L),onCollapse:gt},null,8,["maximized","show-maximize"]),h("div",vN,[Ze(h("div",{id:U($s),class:"dock-pane dock-pane--file",role:"tabpanel","aria-labelledby":oo.value?_s.value:void 0,tabindex:"0"},[X(cA,{client:U(t)},null,8,["client"])],8,yN),[[Fr,oo.value]]),(m(!0),v(te,null,Ce(mt.value,L=>Ze((m(),v("div",{key:L.id,class:ue(["dock-pane",`dock-pane--${L.kind}`]),"data-dock-tab":L.kind,id:U(qa)(L.id),role:"tabpanel","aria-labelledby":U(Yr)(L.id),tabindex:"0"},[(m(),De(Tf(Ss[L.kind]),Kf({ref_for:!0},Cs(L.kind),hm(ji(L.kind))),null,16))],10,bN)),[[Fr,L.id===U(we).activeTabId]])),128))])],10,mN)):F("",!0),rt.value?(m(),De(wh,{key:6,mode:Dt.value,status:U(o),"session-id":U(a),"work-dir":U(l),onClose:ve[16]||(ve[16]=L=>rt.value=!1)},null,8,["mode","status","session-id","work-dir"])):F("",!0),X(iL),X(UM,{open:me.value,models:U(c),"recent-work-dirs":_e.value,"default-dir":U(V)??"","current-model":U(o).model??"",onClose:ve[17]||(ve[17]=L=>me.value=!1),onConfirm:I},null,8,["open","models","recent-work-dirs","default-dir","current-model"])],6))}}),wN=Te(kN,[["__scopeId","data-v-b626c063"]]),SN=["src","alt"],_N={key:1,class:"lightbox-note",role:"alert"},$N=Ie({__name:"ImageLightbox",setup(e){const t=G(null),n=G(!1);Se(()=>jn.open,r=>{const i=t.value;i&&(r?(n.value=!1,i.open||i.showModal()):i.open&&i.close())});function s(r){r.preventDefault(),ka()}function o(r){r.target===t.value&&ka()}return(r,i)=>(m(),v("dialog",{ref_key:"dialogRef",ref:t,class:"image-lightbox","aria-label":"图片预览",onCancel:s,onClick:o},[U(jn).open?(m(),v("img",{key:0,class:"lightbox-img",src:U(jn).src,alt:U(jn).alt||"图片预览",onError:i[0]||(i[0]=a=>n.value=!0)},null,40,SN)):F("",!0),n.value?(m(),v("p",_N,"图片加载失败")):F("",!0),h("button",{type:"button",class:"lightbox-close","aria-label":"关闭预览",title:"关闭(Esc)",onClick:i[1]||(i[1]=a=>U(ka)())},[X(ce,{name:"x",size:16})])],544))}}),CN=Te($N,[["__scopeId","data-v-7d7939d6"]]),xN={class:"toast-container"},IN=["onClick"],TN={class:"toast-icon"},EN={class:"toast-msg"},AN=Ie({__name:"Toast",setup(e){const{toasts:t,removeToast:n}=Qs(),s={info:"ℹ",success:"✓",error:"✗",warning:"⚠"};return(o,r)=>(m(),De(Js,{to:"body"},[h("div",xN,[X($v,{name:"toast"},{default:ot(()=>[(m(!0),v(te,null,Ce(U(t),i=>(m(),v("div",{key:i.id,class:ue(["toast",`toast--${i.type}`]),onClick:a=>U(n)(i.id)},[h("span",TN,C(s[i.type]),1),h("span",EN,C(i.message),1)],10,IN))),128))]),_:1})])]))}}),MN=Te(AN,[["__scopeId","data-v-a432e638"]]),RN={class:"app"},PN=Ie({__name:"App",setup(e){const t=G("system"),n=G("dark");yr("effectiveTheme",n),yr("theme",t);const s={light:"#ffffff",dark:"#101113"};function o(){const l=document.documentElement,u=window.matchMedia("(prefers-color-scheme: dark)").matches,c=t.value==="system"?u?"dark":"light":t.value;n.value=c,l.dataset.theme=c;const d=document.querySelector('meta[name="theme-color"]');d&&d.setAttribute("content",s[c])}let r=null;function i(l){const u=t.value;if(t.value=l,Zr("scream-theme",l),u===l)return;const c=document.documentElement,d=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,f=()=>{c.classList.add("theme-transition"),o(),r!==null&&clearTimeout(r),r=window.setTimeout(()=>c.classList.remove("theme-transition"),320)},p=document;if(typeof p.startViewTransition=="function"&&!d){p.startViewTransition(()=>{o()}).finished.then(()=>c.classList.remove("theme-transition"),()=>{c.classList.remove("theme-transition")});return}f()}yr("setTheme",i),et(()=>{const l=Kr("scream-theme");(l==="light"||l==="dark"||l==="system")&&(t.value=l),o()}),Se(t,o);const a=window.matchMedia("(prefers-color-scheme: dark)");return a.addEventListener("change",o),st(()=>{a.removeEventListener("change",o),r!==null&&clearTimeout(r),document.documentElement.classList.remove("theme-transition")}),(l,u)=>(m(),v("div",RN,[X(wN),X(CN),X(MN)]))}}),LN=Te(PN,[["__scopeId","data-v-6c4eed55"]]);Dv(LN).mount("#app");
240
- //# sourceMappingURL=index-BsmGEP9G.js.map
240
+ //# sourceMappingURL=index-BIs_1Cpx.js.map