scream-code 0.16.9 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,7 @@ var tg=Object.defineProperty;var ng=Object.getPrototypeOf;var sg=Reflect.get;var
17
17
  * @license MIT
18
18
  **/let Fa;const Wu=typeof window<"u"&&window.trustedTypes;if(Wu)try{Fa=Wu.createPolicy("vue",{createHTML:e=>e})}catch{}const Xf=Fa?e=>Fa.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",ao="animation",Zs=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),y=g&&g[0],S=g&&g[1],{onBeforeEnter:k,onEnter:w,onEnterCancelled:b,onLeave:_,onLeaveCancelled:B,onBeforeAppear:D=k,onAppear:E=w,onAppearCancelled:M=b}=t,T=(j,te,I,A)=>{j._enterCancelled=A,Nn(j,te?c:a),Nn(j,te?u:i),I&&I()},Z=(j,te)=>{j._isLeaving=!1,Nn(j,d),Nn(j,p),Nn(j,f),te&&te()},W=j=>(te,I)=>{const A=j?E:w,V=()=>T(te,j,I);Qn(A,[te,V]),Ku(()=>{Nn(te,j?l:r),an(te,j?c:a),Vu(A)||Zu(te,s,y,V)})};return ct(t,{onBeforeEnter(j){Qn(k,[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,te){j._isLeaving=!0;const I=()=>Z(j,te);an(j,d),j._enterCancelled?(an(j,f),Ua(j)):(Ua(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(b,[j])},onAppearCancelled(j){T(j,!0,void 0,!0),Qn(M,[j])},onLeaveCancelled(j){Z(j),Qn(B,[j])}})}function sv(e){if(e==null)return null;if(qe(e))return[Ji(e.enter),Ji(e.leave)];{const t=Ji(e);return[t,t]}}function Ji(e){return ug(e)}function an(e,t){t.split(/\s+/).forEach(n=>n&&e.classList.add(n)),(e[Zs]||(e[Zs]=new Set)).add(t)}function Nn(e,t){t.split(/\s+/).forEach(s=>s&&e.classList.remove(s));const n=e[Zs];n&&(n.delete(t),n.size||(e[Zs]=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(`${ao}Delay`),l=s(`${ao}Duration`),u=Yu(a,l);let c=null,d=0,f=0;t===Ln?i>0&&(c=Ln,d=i,f=r.length):t===ao?u>0&&(c=ao,d=u,f=l.length):(d=Math.max(i,u),c=d>0?i>u?Ln:ao: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 Ua(e){return(e?e.ownerDocument:document).body.offsetHeight}function rv(e,t,n){const s=e[Zs];s&&(t=(t?[t,...s]:[...s]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}const Gr=Symbol("_vod"),Gl=Symbol("_vsh"),Br={name:"show",beforeMount(e,{value:t},{transition:n}){e[Gr]=e.style.display==="none"?"":e.style.display,n&&t?n.beforeEnter(e):lo(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),lo(e,!0),s.enter(e)):s.leave(e,()=>{lo(e,!1)}):lo(e,t))},beforeUnmount(e,{value:t}){lo(e,t)}};function lo(e,t){e.style.display=t?e[Gr]:"none",e[Gl]=!t}const nh=Symbol("");function iv(e){const t=xi();if(!t)return;const n=t.ut=(o=e(t.proxy))=>{Array.from(document.querySelectorAll(`[data-v-owner="${t.uid}"]`)).forEach(r=>Fr(r,o))},s=()=>{const o=e(t.proxy);t.ce?Fr(t.ce,o):ja(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 ja(e,t){if(e.shapeFlag&128){const n=e.suspense;e=n.activeBranch,n.pendingBranch&&!n.isHydrating&&n.effects.push(()=>{ja(n.activeBranch,t)})}for(;e.component;)e=e.component.subTree;if(e.shapeFlag&1&&e.el)Fr(e.el,t);else if(e.type===ne)e.children.forEach(n=>ja(n,t));else if(e.type===yr){let{el:n,anchor:s}=e;for(;n&&(Fr(n,t),n!==s);)n=n.nextSibling}}function Fr(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&&vo(s,a,"")}else for(const i in t)n[i]==null&&vo(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)||vo(s,i,a):vo(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");Gr in e&&(e[Gr]=r?s.display:"",e[Gl]&&(s.display="none"))}const Ju=/\s*!important$/;function vo(e,t,n){if(xe(n))n.forEach(s=>vo(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"],Qi={};function uv(e,t){const n=Qi[t];if(n)return n;let s=Lt(t);if(s!=="filter"&&s in e)return Qi[t]=s;s=mi(s);for(let o=0;o<Qu.length;o++){const r=Qu[o]+s;if(r in e)return Qi[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 is(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);is(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 ea=0;const mv=Promise.resolve(),vv=()=>ea||(mv.then(()=>ea=0),ea=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):fi(t)?hi(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,Ur=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=xi(),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);Ua(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[Ur]=f=>{f&&f.target!==u||(!f||f.propertyName.endsWith("transform"))&&(u.removeEventListener("transitionend",d),u[Ur]=null,Nn(u,i))};u.addEventListener("transitionend",d)}),o=[]}),()=>{const i=je(e),a=eh(i);let l=i.tag||ne;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),gs(c,Po(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&&gs(c,Po(c,a,s,n))}return X(l,null,r)}}}),$v=_v;function Cv(e){const t=e.el;t[Ur]&&t[Ur](),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[Zs];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 jr=e=>{const t=e.props["onUpdate:modelValue"]||!1;return xe(t)?n=>mr(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 js=Symbol("_assign");function ac(e,t,n){return t&&(e=e.trim()),n&&(e=vi(e)),e}const it={created(e,{modifiers:{lazy:t,trim:n,number:s}},o){e[js]=jr(o);const r=s||o.props&&o.props.type==="number";is(e,t?"change":"input",i=>{i.target.composing||e[js](ac(e.value,n,r))}),(n||r)&&is(e,"change",()=>{e.value=ac(e.value,n,r)}),t||(is(e,"compositionstart",Ev),is(e,"compositionend",ic),is(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[js]=jr(i),e.composing)return;const a=(r||e.type==="number")&&!/^0\d/.test(e.value)?vi(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,is(e,"change",()=>{const o=Array.prototype.filter.call(e.options,r=>r.selected).map(r=>n?vi(zr(r)):zr(r));e[js](e.multiple?pi(e._modelValue)?new Set(o):o:o[0]),e._assigning=!0,Fe(()=>{e._assigning=!1})}),e[js]=jr(s)},mounted(e,{value:t}){uc(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[js]=jr(n)},updated(e,{value:t}){e._assigning||uc(e,t)}};function uc(e,t){const n=e.multiple,s=xe(t);if(!(n&&!s&&!pi(t))){for(let o=0,r=e.options.length;o<r;o++){const i=e.options[o],a=zr(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(Wo(zr(i),t)){e.selectedIndex!==o&&(e.selectedIndex=o);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function zr(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 Hr=[{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"}],zs=O([]);function dc(e){zs.value=[...e]}const xo=O("");function Gv(e){xo.value=e.trim().toLowerCase()}function Bv(){xo.value=""}const Fv=8,ih=O(!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===""&&xo.value==="";ih.value=n;const s=Hr.filter(r=>fc(r,t)&&fc(r,xo.value)).filter(r=>!n||r.group!=="advanced"),o=zs.value.filter(r=>hc(r,t)&&hc(r,xo.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=Hr.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 zs.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=Hr.filter(o=>o.group!=="advanced"),n=Hr.filter(o=>o.group==="advanced"),s=["常用:",...t.map(e),"高级:",...n.map(e)];return zs.value.length>0&&s.push("",`技能 ${zs.value.length} 个(输入 / 后在菜单中查看,或前往技能中心):`,...zs.value.map(o=>`/${o.name} - ${o.description||"技能"}`)),["可用命令:",...s].join(`
19
19
  `)}let Wr=null;const Bl=Fg(null);function qv(e){Wr=e,Bl.value=e}function Vv(e){Wr===e&&(Wr=null,Bl.value=null)}function za(){return Wr}function Kv(){return{activeClient:Bl}}const Do=O([]);let Zv=0;function Yv(e,t="info",n=3500){const s=`toast_${++Zv}`;Do.value=[...Do.value,{id:s,type:t,message:e}],n>0&&setTimeout(()=>ah(s),n)}function ah(e){Do.value=Do.value.filter(t=>t.id!==e)}function Js(){return{toasts:Do,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 Ti(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=O("connecting"),t=O([]),n=O(!1),s=O(void 0),o=O([]),r=O({busy:!1}),i=O(null),a=O([]),l=O(!1),u=O(null),c=O(!1),d=O(null),f=O(null),p=O(null),g=O([]),y=O(null),S=O(!1),k=G(()=>r.value.busy||c.value),w=G(()=>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:k,sessions:g,currentSessionId:y,isArchived:w,gitStatus:O(null),models:O([]),modelsError:O(null),like:O({}),sessionPlan:O(null),skills:O([]),skillsError:O(null),plugins:O([]),pluginInfo:O(null),mcpServers:O([]),mcpStartupMetrics:O(null),backgroundTasks:O([]),backgroundTaskOutput:O(""),subagents:O([]),config:O(null),experimentalFlags:O(null),preflightOk:O(!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}=Js();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 kr(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 yo(e,t){const n=e[t];return typeof n=="string"&&n.length>0?n:void 0}function rr(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=yo(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."))return e;const s=t,o=yo(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=yo(s,"subagentName")??(i==null?void 0:i.name)??"agent",u=yo(s,"parentToolCallId")??(i==null?void 0:i.parentToolCallId)??"",c={subagentId:o,name:l,parentToolCallId:u,description:yo(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:rr(s,"contextTokens")??(i==null?void 0:i.contextTokens),turns:rr(s,"turns")??(i==null?void 0:i.turns),durationMs:rr(s,"durationMs")??(i==null?void 0:i.durationMs),toolCallCount:rr(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 No=new Map;function hy(e){No.set(e,Date.now())}function py(e){return No.get(e)}function gy(e){const t=No.get(e);return t!==void 0&&No.delete(e),t}function my(){No.clear()}function ta(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 a=r();if(!a){t.pendingAssistantDelta="",t.pendingThinkingDelta="",t.pendingToolProgress.clear();return}if(t.pendingAssistantDelta&&(a.content+=t.pendingAssistantDelta,t.pendingAssistantDelta=""),t.pendingThinkingDelta){const l=a.tools.find(u=>u.name==="thinking");l?l.output=(l.output??"")+t.pendingThinkingDelta:a.tools.push({toolCallId:"thinking",name:"thinking",output:t.pendingThinkingDelta}),t.pendingThinkingDelta=""}if(t.pendingToolProgress.size>0){for(const[l,u]of t.pendingToolProgress){const c=a.tools.find(d=>d.toolCallId===l);c&&(c.progress=u)}t.pendingToolProgress.clear()}}const s=vy(n);function o(a){var c;const l=fy(t.subagents.value,a);l!==t.subagents.value&&(t.subagents.value=l);const u=ry({goal:t.goal.value,todos:t.todos.value},a);switch(t.goal.value=u.goal,t.todos.value=u.todos,a.type==="goal.updated"&&t.goalAwaitingMutation!==null&&t.goalAwaitingMutation.generation===t.goalMutationGeneration&&(t.goalAwaitingMutation=null,t.snapshotRetryGoalGeneration=null,e.syncGoalRequestPending()),a.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(a.delta),s.schedule();break}case"thinking.delta":{t.turnFirstTokenAt===null&&(t.turnFirstTokenAt=Date.now()),t.pendingThinkingDelta+=String(a.delta),s.schedule();break}case"tool.call.started":{const d=r();d&&(d.tools.push({toolCallId:String(a.toolCallId),name:String(a.name),args:a.args}),d.turnStats&&(d.turnStats.step+=1)),hy(String(a.toolCallId));break}case"tool.result":{t.pendingToolProgress.delete(String(a.toolCallId));const d=gy(String(a.toolCallId));d!==void 0&&(t.activeToolMs+=Date.now()-d);const f=r();if(f){const p=f.tools.find(g=>g.toolCallId===a.toolCallId);p&&(p.output=String(a.output),p.isError=!!a.isError,p.progress=void 0,d!==void 0&&(p.durationMs=Date.now()-d))}break}case"tool.progress":{t.pendingToolProgress.set(String(a.toolCallId),String(a.message??a.output)),s.schedule();break}case"turn.ended":{if(s.flushNow(),t.status.value={...t.status.value,busy:!1},a.reason==="failed"){const y=r();y&&(y.isError=!0),t.error.value=gc(a.error,"Turn failed")}const d=r(),f=Date.now()-t.turnStartAt,p=(c=t.status.value.usage)==null?void 0:c.currentTurn,g=p?p.inputOther+p.output+p.inputCacheRead+p.inputCacheCreation:null;d&&d.turnStats&&(d.turnStats.status="done",d.turnStats.llmMs=f,d.turnStats.toolMs=t.activeToolMs,d.turnStats.firstTokenMs=t.turnFirstTokenAt!==null?t.turnFirstTokenAt-t.turnStartAt:null,d.turnStats.tokens=g,d.turnStats.tokensPerSec=g!==null&&f>0?Math.round(g/f*1e3):null),e.fetchSessions(),e.fetchGitStatus();break}case"session.meta.updated":{const d={};a.model!==void 0&&(d.model=a.model),a.contextTokens!==void 0&&(d.contextTokens=a.contextTokens),a.maxContextTokens!==void 0&&(d.maxContextTokens=a.maxContextTokens),a.contextUsage!==void 0&&(d.contextUsage=a.contextUsage),a.rlmMaxDepth!==void 0&&(d.rlmMaxDepth=a.rlmMaxDepth),t.status.value={...t.status.value,...d};break}case"agent.status.updated":{const d={};if(a.model!==void 0&&(d.model=a.model),a.thinkingLevel!==void 0&&(d.thinkingLevel=a.thinkingLevel),a.contextTokens!==void 0&&(d.contextTokens=a.contextTokens),a.maxContextTokens!==void 0&&(d.maxContextTokens=a.maxContextTokens),a.contextUsage!==void 0&&(d.contextUsage=a.contextUsage),a.usage!==void 0){d.usage=a.usage;const f=a.usage;if(f!=null&&f.currentTurn){const p=r(),g=f.currentTurn.inputOther+f.currentTurn.output+f.currentTurn.inputCacheRead+f.currentTurn.inputCacheCreation;p!=null&&p.turnStats&&p.turnStats.status==="done"&&p.turnStats.tokens===null&&(p.turnStats.tokens=g,p.turnStats.tokensPerSec=p.turnStats.llmMs?Math.round(g/p.turnStats.llmMs*1e3):null)}}t.status.value={...t.status.value,...d};break}case"web.history.undone":e.fetchSnapshot();break;case"error":{t.error.value=gc(a.error,"Unknown error");break}}}function r(){for(let a=t.messages.value.length-1;a>=0;a--)if(t.messages.value[a].role==="assistant")return t.messages.value[a];return null}Yt(t,"event",a=>{const l=oy(t.epoch,t.seq,a);if(l==="resync"){t.epoch=a.epoch,t.seq=0,t.journalGapCount=0,e.fetchSnapshot();return}if(l!=="duplicate"){if(l==="gap"){t.journalGapCount++;const u=t.journalGapCount>=3;(u?console.error:console.warn)(`[webClient] journal seq 缺口:epoch ${t.epoch} 内从 ${t.seq} 跳到 ${a.seq}(连续第 ${t.journalGapCount} 次${u?",超过阈值,流可能已持续损坏":""}),已触发快照补拉。`,a)}else t.journalGapCount=0;t.seq=a.seq,t.epoch=a.epoch,t.liveGeneration++,l==="gap"&&e.fetchSnapshot(),o(a.payload)}}),Yt(t,"resync_required",()=>{t.seq=0,e.fetchSnapshot()}),e.onEvent=o;function i(){t.streamDisposed=!0,s.dispose()}return{onEvent:o,disposeStreaming:i}}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 y=await fetch(`${Ge}/sessions/${a}/snapshot${l?`?tail=${l}`:""}`);if(!y.ok){i!==void 0&&((p=t.goalAwaitingMutation)==null?void 0:p.generation)===i&&(t.snapshotRetryGoalGeneration=i,s());return}const S=await y.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 y;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 k=(y=t.messages.value[S])==null?void 0:y.turnStats;if(k&&typeof k.turn=="number"&&k.turn>0){t.turnNumber=k.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 y=g.messages.map(S=>({...S,id:S.id??yn()}));return t.messages.value=[...y,...t.messages.value],t.oldestSeq.value=((f=y[0])==null?void 0:f.seq)??d,t.olderAvailable.value=g.hasMore,y.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}]}),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&&kr(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&&!Ti(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),y=g&&typeof g.message=="string"?g.message:"";n(`新建会话失败:${y||`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,y=++t.sessionMutationGeneration;try{const S=await fetch(`${Ge}/sessions/${f}/${u}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),k=await S.json();if(t.sessionId.value!==f||t.sessionGeneration!==p||t.connectionGeneration!==g||t.sessionMutationGeneration!==y)return;if(!S.ok){n(k.message??`请求失败(HTTP ${S.status})`,"error");return}k.status&&(t.status.value={...t.status.value,...k.status}),n(d,"success")}catch(S){if(t.sessionId.value!==f||t.sessionGeneration!==p||t.connectionGeneration!==g||t.sessionMutationGeneration!==y)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,y){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 k=t.sessionGeneration,w=++t.goalMutationGeneration;t.goalRequestInFlight=!0,n(),t.goalRequestError.value=null;try{const b=await fetch(`${Ge}/sessions/${S}/goal${f}`,{method:p,headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),_=await b.json().catch(()=>({}));return!kr(t.sessionId.value,t.sessionGeneration,S,k)||t.goalMutationGeneration!==w?null:b.ok?(y&&(t.goalAwaitingMutation={generation:w},t.snapshotRetryGoalGeneration=w),_):(t.goalRequestError.value=typeof _.message=="string"?_.message:`请求失败(HTTP ${b.status})`,null)}catch(b){return kr(t.sessionId.value,t.sessionGeneration,S,k)&&t.goalMutationGeneration===w&&(t.goalRequestError.value=`请求失败:${b instanceof Error?b.message:String(b)}`),null}finally{kr(t.sessionId.value,t.sessionGeneration,S,k)&&t.goalMutationGeneration===w&&(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&&Ti(t,_)}async function l(){const _=ft(t);if(!_)return;const B=++s;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/status`);if(!a(_)||B!==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 B=++o;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/usage`);if(!a(_)||B!==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 B=++r;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/context`);if(!a(_)||B!==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 B=++i;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/plan`);if(!a(_)||B!==i||!D.ok)return;t.sessionPlan.value=await D.json()}catch{}}async function f(){const _=ft(t);if(!_)return!1;const B=++i;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/plan/clear`,{method:"POST"});return!a(_)||B!==i||!D.ok?!1:(t.sessionPlan.value=null,!0)}catch{return!1}}async function p(_,B){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(B??{})});if(!a(D))return!1;if(!E.ok){const M=await E.json().catch(()=>({}));return a(D)&&n(M.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 B=t.sessionId.value,D=t.sessionGeneration,E=t.connectionGeneration,M=++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!==B||t.sessionGeneration!==D||t.connectionGeneration!==E||t.permissionMutationGeneration!==M||(t.status.value={...t.status.value,permission:T}),!1)}async function y(_,B){const D=await p("plan",{enabled:_,...B?{strategy:B}:{}});return D&&await l(),D}async function S(_){const B=await p("wolfpack",{enabled:_});return B&&await l(),B}async function k(_,B){const D=await p("rlm",{enabled:_,...B!==void 0?{maxDepth:B}:{}});return D&&await l(),D}async function w(_=1){return p("undo",{count:_})}async function b(_){return p("compact",_?{instruction:_}:{})}return e.postSessionAction=p,{fetchSessionStatus:l,fetchSessionUsage:u,fetchSessionContext:c,fetchSessionPlan:d,clearPlan:f,switchPermission:g,switchPlanMode:y,switchWolfpack:S,switchRlm:k,undoHistory:w,compact:b}}function Cy(e){const{s:t}=e;let n=0,s=0,o=0;function r(b){return b!==null&&Ti(t,b)}async function i(){const b=ft(t);if(!b)return;const _=++n;try{const B=await fetch(`${Ge}/sessions/${b.sessionId}/skills`);if(!r(b)||_!==n)return;if(!B.ok){t.skillsError.value=`技能列表加载失败(HTTP ${B.status})`;return}t.skills.value=await B.json(),t.skillsError.value=null}catch(B){if(!r(b)||_!==n)return;t.skillsError.value=`技能列表加载失败:${B instanceof Error?B.message:String(B)}`}}async function a(b,_){return e.postSessionAction(`skills/${encodeURIComponent(b)}/activate`,_?{args:_}:{})}async function l(b){const _=ft(t);if(!_)return!1;++n;try{const B=await fetch(`${Ge}/sessions/${_.sessionId}/skills/${encodeURIComponent(b)}`,{method:"DELETE"});return!r(_)||!B.ok?!1:(t.skills.value=t.skills.value.filter(D=>D.name!==b),!0)}catch{return!1}}async function u(){const b=ft(t);if(!b)return;const _=++s;try{const B=await fetch(`${Ge}/sessions/${b.sessionId}/plugins`);if(!r(b)||_!==s||!B.ok)return;t.plugins.value=await B.json()}catch{}}async function c(b){const _=ft(t);if(!_)return;const B=++o;try{const D=await fetch(`${Ge}/sessions/${_.sessionId}/plugins/${encodeURIComponent(b)}`);if(!r(_)||B!==o||!D.ok)return;t.pluginInfo.value=await D.json()}catch{}}async function d(b){const _=ft(t);if(!_)return null;++s;try{const B=await fetch(`${Ge}/sessions/${_.sessionId}/plugins/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:b})});if(!r(_)||!B.ok)return null;const D=await B.json();return await u(),r(_)?D:null}catch{return null}}async function f(b,_){return e.postSessionAction(`plugins/${encodeURIComponent(b)}/enable`,{enabled:_})}async function p(b,_,B){return e.postSessionAction(`plugins/${encodeURIComponent(b)}/mcp/${encodeURIComponent(_)}/enable`,{enabled:B})}async function g(b){const _=ft(t);if(!_)return!1;++s;try{const B=await fetch(`${Ge}/sessions/${_.sessionId}/plugins/${encodeURIComponent(b)}`,{method:"DELETE"});return!r(_)||!B.ok?!1:(t.plugins.value=t.plugins.value.filter(D=>D.id!==b),!0)}catch{return!1}}async function y(){const b=ft(t);if(!b)return null;++s;try{const _=await fetch(`${Ge}/sessions/${b.sessionId}/plugins/reload`,{method:"POST"});if(!r(b)||!_.ok)return null;const B=await _.json();return await u(),r(b)?B:null}catch{return null}}async function S(b){return e.postSessionAction(`plugins/${encodeURIComponent(b)}/activate`)}async function k(b){return e.postSessionAction(`plugins/${encodeURIComponent(b)}/deactivate`)}async function w(b){return e.postSessionAction(`plugins/${encodeURIComponent(b)}/inject`)}return{fetchSkills:i,activateSkill:a,removeSkill:l,fetchPlugins:u,fetchPluginInfo:c,installPlugin:d,setPluginEnabled:f,setPluginMcpServerEnabled:p,removePlugin:g,reloadPlugins:y,activatePlugin:S,deactivatePlugin:k,injectPlugin:w}}function xy(e){const{s:t}=e;let n=0,s=0,o=0,r=0;function i(S){return S!==null&&Ti(t,S)}async function a(){const S=ft(t);if(!S)return;const k=++n;try{const w=await fetch(`${Ge}/sessions/${S.sessionId}/mcp`);if(!i(S)||k!==n||!w.ok)return;t.mcpServers.value=await w.json()}catch{}}async function l(){const S=ft(t);if(!S)return;const k=++s;try{const w=await fetch(`${Ge}/sessions/${S.sessionId}/mcp/startup-metrics`);if(!i(S)||k!==s||!w.ok)return;t.mcpStartupMetrics.value=await w.json()}catch{}}async function u(S,k){return e.postSessionAction("mcp/add",{name:S,config:k})}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 k=ft(t);if(!k)return!1;try{const w=await fetch(`${Ge}/sessions/${k.sessionId}/mcp/${encodeURIComponent(S)}`,{method:"DELETE"});return!i(k)||!w.ok?!1:(t.mcpServers.value=t.mcpServers.value.filter(b=>b.name!==S),!0)}catch{return!1}}async function p(S,k){const w=ft(t);if(!w)return;const b=++o;try{const _=new URLSearchParams;S!==void 0&&_.set("activeOnly",String(S)),k!==void 0&&_.set("limit",String(k));const B=_.toString(),D=await fetch(`${Ge}/sessions/${w.sessionId}/tasks${B?`?${B}`:""}`);if(!i(w)||b!==o||!D.ok)return;t.backgroundTasks.value=await D.json()}catch{}}async function g(S,k){const w=ft(t);if(!w)return;const b=++r;try{const _=k!==void 0?`?tail=${k}`:"",B=await fetch(`${Ge}/sessions/${w.sessionId}/tasks/${encodeURIComponent(S)}/output${_}`);if(!i(w)||b!==r||!B.ok)return;const D=await B.json();t.backgroundTaskOutput.value=D.output}catch{}}async function y(S,k){return e.postSessionAction(`tasks/${encodeURIComponent(S)}/stop`,k?{reason:k}:{})}return{fetchMcpServers:a,fetchMcpStartupMetrics:l,addMcpServer:u,reconnectMcpServer:c,stopMcpServer:d,removeMcpServer:f,fetchBackgroundTasks:p,fetchBackgroundTaskOutput:g,stopBackgroundTask:y}}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 y=Number.isFinite(p)&&p>0?p:8e3;return new Promise(S=>{const k=Date.now(),w=window.setInterval(()=>{t.sessionId.value!==g?(window.clearInterval(w),S(!1)):t.connectionStatus.value==="connected"?(window.clearInterval(w),S(!0)):(t.connectionStatus.value==="idle"||t.disposed||Date.now()-k>=y)&&(window.clearInterval(w),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 y;if(Date.now()-t.lastPongAt>Xv){(y=t.ws)==null||y.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 y;try{y=JSON.parse(g.data)}catch{return}s(y)}}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 y=t.sessionGeneration,S=t.connectionGeneration,k=()=>t.sessionId.value===p.sessionId&&t.currentSessionId.value===p.sessionId&&t.sessionGeneration===y&&t.connectionGeneration===S,w=()=>{k()&&(e.fetchSnapshot().finally(()=>{var b;k()&&((b=e.refreshSessionResources)==null||b.call(e))}),e.fetchSessions(),e.fetchGitStatus())};p.active?w():e.activateSession(p.sessionId).then(b=>{k()&&(b&&t.sessionId.value===p.sessionId&&(t.sessionActive.value=!0),w())})}),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 y={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(y),st(()=>{Vv(y),dc([])}),y}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(t.length===0)return null;const n=Number(t);return Number.isInteger(n)&&n>=0&&Number.isSafeInteger(n)?n:null}function lh(e){const{showToast:t}=Js();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=za();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){e.appendSystemMessage("RLM 最大深度:请输入 /rlm-max-depth <N> 设置(0 = 无限)。");return}const p=Py(f);if(p===null){t("RLM 深度需为 0 或非负整数。","warning");return}const g=await n();if(!g)return;const y=g.status.value.rlmEnabled===!0;await s(()=>g.switchRlm(y,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",y=f==="off"?!1:f==="on"?!0:!g;await s(()=>p.switchPlanMode(y,y?"fusion":void 0),`融合计划模式已${y?"开启":"关闭"}`)}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(k,w)=>{const b=za();return b?await b.activateSkill(k,w):!1});let y=!1;try{y=await g(d,f)}catch(k){y=!1,t(`技能激活失败:${k instanceof Error?k.message:String(k)}`,"error");return}y?t(`技能已激活:/${d}`,"success"):t(`技能激活失败:/${d}`,"error")}async function c(d,f){var p,g,y;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(`当前模型:${((y=e.currentModel)==null?void 0:y.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,qr=420,Ny=288,wc=56,Ha=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,Ha,Math.round(e*uh))}function By(e){const{viewportWidth:t,rightPanelOpen:n,rightPanelWidth:s}=e;if(t<=Ly)return qr;const o=t<Fl,r=o?Oy:ch,i=!o&&n?s:0;return Math.min(qr,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 Vr(e){try{return localStorage.getItem(e)??void 0}catch{return}}function Kr(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=b=>typeof b=="function"?b():b,r=()=>o(e.maxWidth);function i(){var _;const b=Uy(t);return typeof b=="number"&&Number.isFinite(b)&&b>=n&&(((_=e.acceptStoredWidth)==null?void 0:_.call(e,b))??!0)?Math.round(b):o(e.defaultWidth)}const a=O(i()),l=O(!1);let u=null;function c(){jy(t,a.value)}function d(b){return s==="left"?b:window.innerWidth-b}function f(b){if(!(e.canDrag&&!e.canDrag())){b.preventDefault(),l.value=!0,u=b.pointerId;try{b.currentTarget.setPointerCapture(b.pointerId)}catch{}}}function p(b){!l.value||b.pointerId!==u||(a.value=ss(d(b.clientX),n,r()))}function g(b){!l.value||b.pointerId!==u||y()}function y(){l.value=!1,u=null,c()}function S(){a.value=ss(o(e.defaultWidth),n,r()),c()}function k(b){const _=b.shiftKey?32:12,B=s==="left"?1:-1;if(b.key==="ArrowLeft")b.preventDefault(),a.value=ss(a.value-B*_,n,r());else if(b.key==="ArrowRight")b.preventDefault(),a.value=ss(a.value+B*_,n,r());else if(b.key==="Home")b.preventDefault(),a.value=n;else if(b.key==="End")b.preventDefault(),a.value=ss(r(),n,r());else if(b.key==="Enter")b.preventDefault(),S();else return;c()}const w=G(()=>ss(a.value,n,r()));return{width:a,effectiveWidth:w,resizing:l,onPointerDown:f,onPointerMove:p,onPointerUp:g,onKeydown:k,reset:S,release:y}}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 Zr(e){return`dock-tab-${encodeURIComponent(e)}`}function Wa(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 Ko(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 Oo=Ky(),na=(Array.isArray(Oo.tabs)?Oo.tabs:[]).map(e=>Zy(e)).filter(e=>e!==null),_c=typeof Oo.activeTabId=="string"?Oo.activeTabId:null;var Od;const we=Wn({tabs:na,activeTabId:na.some(e=>e.id===_c)?_c:((Od=na.at(-1))==null?void 0:Od.id)??null,panelOpen:Oo.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 ms(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,Ko(we),s}function wr(e){const t=fh(e);return we.tabs=qy(we.tabs,e),we.activeTabId=t,we.panelOpen=!0,Ko(we),t}function Xy(e){we.tabs.some(t=>t.id===e)&&(we.activeTabId=e,Ko(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),Ko(we)}}function jl(e){we.panelOpen=e,e&&Yy(),Ko(we)}function Qy(){jl(!we.panelOpen)}const qa=()=>we.tabs.find(e=>e.id===we.activeTabId),eb=()=>{const e=qa();return e&&e.kind==="file"?e:void 0},Ei=O(!1);let Yr=0;function tb(){Yr++}function nb(){Yr=Math.max(0,Yr-1)}function sb(){return Yr>0}function ph(){return sb()?(Ei.value=!0,!0):!1}function ob(){Ei.value=!0}function Xr(){Ei.value=!1}function gh(){return{open:Ei,openSettingsModal:ob,closeSettingsModal:Xr,tryOpenSettingsModal:ph}}const mh="scream-workspace-preference",Ai=O(Vr(mh)||null),zl=O(null);let uo=null;function rb(e){Ai.value=e,Kr(mh,e??"")}async function ib(){return uo||(uo=(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{uo=null}})(),uo)}const ab=G(()=>Ai.value??zl.value??""),lb=G(()=>!!Ai.value);function Hl(){return{preferredWorkDir:Ai,serverWorkDir:zl,displayWorkDir:ab,hasPreference:lb,setPreferredWorkDir:rb,fetchServerWorkDir:ib}}function Va(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},[$o(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={class:"approval-action"},yb={key:0,class:"feedback-area"},bb={class:"approval-buttons"},kb={key:0,class:"busy-indicator","aria-label":"处理中"},wb=Ie({__name:"ApprovalCard",props:{approvals:{}},emits:["resolve"],setup(e,{emit:t}){const n=e,s=t,o=O(!1),r=O(!1),i=O(""),a=O(new Set),l=G(()=>n.approvals[0]);Se(()=>n.approvals.map(g=>g.id).join(","),()=>{r.value=!1,i.value="";const g=new Set(n.approvals.map(y=>y.id));a.value=new Set([...a.value].filter(y=>g.has(y)))});function u(g){return typeof g.display=="string"?g.display:g.display&&typeof g.display=="object"&&"description"in g.display?String(g.display.description??""):g.action??"执行该操作"}function c(g){return a.value.has(g)}function d(g,y,S){const k=l.value;!k||c(k.id)||(a.value=new Set([...a.value,k.id]),s("resolve",k.id,g,y,S))}function f(){const g=i.value.trim();g&&d("rejected",g)}function p(g){if(!l.value||o.value)return;const S=g.target;if(S&&(S.tagName==="TEXTAREA"||S.tagName==="INPUT")){r.value&&g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),f());return}switch(g.key){case"1":g.preventDefault(),d("approved",void 0,"once");break;case"2":g.preventDefault(),d("approved",void 0,"session");break;case"3":g.preventDefault(),d("rejected");break;case"4":g.preventDefault(),r.value=!r.value;break}}return et(()=>window.addEventListener("keydown",p)),st(()=>window.removeEventListener("keydown",p)),(g,y)=>e.approvals.length?(m(),v("div",db,[o.value?(m(),v("button",{key:0,class:"approval-minibar",onClick:y[0]||(y[0]=S=>o.value=!1)}," ⚠ "+C(e.approvals.length)+" 个待审批请求 — 点击展开 ",1)):l.value?(m(),v(ne,{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(u(l.value)),1)]),e.approvals.length>1?(m(),v("span",mb,"+"+C(e.approvals.length-1),1)):U("",!0),h("button",{class:"icon-btn",title:"最小化","aria-label":"最小化",onClick:y[1]||(y[1]=S=>o.value=!0)},"—")]),h("pre",vb,C(u(l.value)),1),r.value?(m(),v("div",yb,[Ze(h("textarea",{"onUpdate:modelValue":y[2]||(y[2]=S=>i.value=S),class:"feedback-input",rows:"2",name:"approval-feedback","aria-label":"拒绝反馈",placeholder:"输入反馈,Enter 提交(将作为拒绝原因反馈给 Agent)"},null,512),[[it,i.value]])])):U("",!0),h("div",bb,[X(Ht,{variant:"primary",disabled:c(l.value.id),onClick:y[3]||(y[3]=S=>d("approved",void 0,"once"))},{default:ot(()=>[...y[8]||(y[8]=[h("kbd",null,"1",-1),Ae(" 批准 ",-1)])]),_:1},8,["disabled"]),X(Ht,{variant:"secondary",disabled:c(l.value.id),onClick:y[4]||(y[4]=S=>d("approved",void 0,"session"))},{default:ot(()=>[...y[9]||(y[9]=[h("kbd",null,"2",-1),Ae(" 会话批准 ",-1)])]),_:1},8,["disabled"]),X(Ht,{variant:"danger",disabled:c(l.value.id),onClick:y[5]||(y[5]=S=>d("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:c(l.value.id),onClick:y[6]||(y[6]=S=>r.value=!r.value)},{default:ot(()=>[...y[11]||(y[11]=[h("kbd",null,"4",-1),Ae(" 反馈 ",-1)])]),_:1},8,["class","disabled"]),c(l.value.id)?(m(),v("span",kb,[...y[12]||(y[12]=[h("span",{class:"spinner"},null,-1),Ae(" 处理中… ",-1)])])):U("",!0)])],64)):U("",!0)])):U("",!0)}}),Sb=Te(wb,[["__scopeId","data-v-137fa416"]]);function _b(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 $b(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 Cb=20;function vh(e,t,n=Cb){const s=t.toLowerCase();if(!s)return e.slice(0,n);const o=[];for(const r of e){const i=$b(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 xb(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 Ib="/api/v1/files",Tb=3e4,Ka=new Map,Sr=new Map;async function Wl(e){const t=Ka.get(e);if(t&&Date.now()-t.at<Tb)return t.entries;const n=Sr.get(e);if(n)return n;const s=(async()=>{try{const o=await fetch(`${Ib}/list?path=${encodeURIComponent(e)}`);if(!o.ok)return null;const r=await o.json();return r.entries&&Ka.set(e,{entries:r.entries,at:Date.now()}),r.entries??null}catch{return null}finally{Sr.delete(e)}})();return Sr.set(e,s),s}function Eb(e){Ka.delete(e),Sr.delete(e)}function Ab(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 Mb(e,t,n){const s=O(null),o=O([]),r=O(!1),i=O(!1),a=O(0),l=O(!1),u=O(null),c=O("");let d=null;function f(){d||(d=(async()=>{var M;try{const T=await fetch("/api/v1/files/root"),Z=T.ok?await T.json():{};c.value=((M=Z.roots)==null?void 0:M[0])??""}catch{c.value=""}b()})())}const p=G(()=>{const M=u.value;if(!M)return[];const T=M.query.lastIndexOf("/"),Z=M.query.slice(T+1);return vh(o.value,Z)}),g=G(()=>u.value!==null&&!l.value&&(r.value||p.value.length>0));function y(M){const T=M.lastIndexOf("/");return T===-1?{dirRel:"",tail:M}:{dirRel:M.slice(0,T),tail:M.slice(T+1)}}let S=!1,k=0;async function w(M,T){const Z=++k;r.value=!0;try{const W=await Wl(M);if(W===null)throw new Error("listing failed");if(Z!==k)return;const j=T?`${T.replace(/\/+$/,"")}/`:"";o.value=W.map(te=>({path:`${j}${te.name}`,isDir:te.type==="dir"})),i.value=!1}catch{if(Z!==k)return;o.value=[],i.value=!0,s.value=null}finally{Z===k&&(r.value=!1)}}function b(){var A;if(S)return;const M=t.value;if(M&&M.value!==e.value){u.value=null;return}let T=(A=n.value)==null?void 0:A.trim();if(T||(f(),T=c.value),!M||!T){u.value=null;return}const Z=M.selectionStart??M.value.length,W=_b(M.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:te}=y(W.query),I=Ab(T,te);if(I===null){s.value=null,o.value=[],i.value=!0;return}s.value!==I&&(s.value=I,w(I,te))}function _(M){const T=p.value.length;T>0&&(a.value=(a.value+M+T)%T)}function B(M){const T=u.value,Z=M??p.value[a.value];if(!T||!Z)return!1;const W=t.value;if(!W)return!1;const j=W.selectionStart??W.value.length,te=xb(Z.path,Z.isDir),I=e.value.slice(0,T.start),A=e.value.slice(j);e.value=I+te.text+A,S=!0;const V=()=>{const ie=T.start+te.cursorOffset;W.focus(),W.setSelectionRange(ie,ie),S=!1,b()};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:b,move:_,confirm:B,dismiss:D,reset:E}}const yh=50;function Rb(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 Pb(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 Lb(){if(typeof navigator>"u")return"Ctrl";const e=`${navigator.platform??""} ${navigator.userAgent??""}`;return/Mac|iPhone|iPad|iPod/.test(e)?"⌘":"Ctrl"}const _r=Lb(),Db=["width","height"],Nb={key:0,d:"M4 7h16M4 12h16M4 17h16"},Ob={key:1,d:"M12 5v14M5 12h14"},Gb={key:5,d:"M4 6h16M7 12h10M10 18h4"},Bb={key:6,d:"M12 3v12m0 0 4-4m-4 4-4-4M5 20h14"},Fb={key:7,d:"M4 7h16M9 7V4h6v3m3 0-1 13H7L6 7m4 4v5m4-5v5"},Ub={key:8,d:"M3 12h4l2-7 4 14 2-7h6"},jb={key:10,d:"m15 18-6-6 6-6"},zb={key:11,d:"m9 18 6-6-6-6"},Hb={key:12,d:"m6 9 6 6 6-6"},Wb={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"},qb={key:18,d:"M5 9a11 11 0 0 1 14 0M8.5 12.5a6 6 0 0 1 7 0M12 17h.01"},Vb={key:19,d:"M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L8 18l-4 1 1-4Z"},Kb={key:20,d:"M12 16V4m0 0-4 4m4-4 4 4M5 20h14"},Zb={key:21,d:"m15 4 5 5M17.5 6.5 10 14m-2-2 4 4-3 4H3l1-6Z"},Yb={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"},Xb={key:24,d:"m22 2-7 20-4-9-9-4ZM22 2 11 13"},Jb={key:25,x:"6",y:"6",width:"12",height:"12",rx:"2"},Qb={key:26,d:"m8 3 4 4 4-4M8 21l4-4 4 4M12 7v10"},ek={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"},tk={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"},nk={key:31,d:"M20 13 13 20l-9-9V4h7ZM8.5 8.5h.01"},sk={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"},ok={key:34,d:"M3 6h7l2 2h9v11H3Z"},rk={key:35,d:"m5 12 4 4L19 6"},ik={key:39,d:"M21 12a9 9 0 1 1-2.6-6.4M21 3v6h-6"},ak={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"},lk={key:47,d:"M12 19V5m0 0-6 6m6-6 6 6"},uk={key:48,d:"M18 6 6 18M6 6l12 12"},ck={key:51,d:"M9 4H4v5M15 4h5v5M9 20H4v-5M15 20h5v-5"},dk={key:52,d:"M4 9h5V4M20 9h-5V4M4 15h5v5M20 15h-5v5"},fk={key:56,d:"M4 20V10M10 20V4M16 20v-7M21 20H3"},hk=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",Nb)):e.name==="plus"?(m(),v("path",Ob)):e.name==="panel-left"?(m(),v(ne,{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(ne,{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(ne,{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",Gb)):e.name==="download"?(m(),v("path",Bb)):e.name==="trash"?(m(),v("path",Fb)):e.name==="activity"?(m(),v("path",Ub)):e.name==="help"?(m(),v(ne,{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",jb)):e.name==="chevron-right"?(m(),v("path",zb)):e.name==="chevron-down"?(m(),v("path",Hb)):e.name==="bot"?(m(),v(ne,{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(ne,{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(ne,{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",Wb)):e.name==="monitor"?(m(),v(ne,{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",qb)):e.name==="edit"?(m(),v("path",Vb)):e.name==="upload"?(m(),v("path",Kb)):e.name==="broom"?(m(),v("path",Zb)):e.name==="command"?(m(),v("path",Yb)):e.name==="at"?(m(),v(ne,{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",Xb)):e.name==="stop"?(m(),v("rect",Jb)):e.name==="compact"?(m(),v("path",Qb)):e.name==="brain"?(m(),v("path",ek)):e.name==="clipboard"?(m(),v(ne,{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(ne,{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",tk)):e.name==="tag"?(m(),v("path",nk)):e.name==="sparkles"?(m(),v("path",sk)):e.name==="terminal"?(m(),v(ne,{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",ok)):e.name==="check"?(m(),v("path",rk)):e.name==="speaker"?(m(),v(ne,{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(ne,{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(ne,{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",ik)):e.name==="target"?(m(),v(ne,{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(ne,{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(ne,{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(ne,{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(ne,{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(ne,{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",ak)):e.name==="arrow-up"?(m(),v("path",lk)):e.name==="x"?(m(),v("path",uk)):e.name==="file"?(m(),v(ne,{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(ne,{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",ck)):e.name==="minimize"?(m(),v("path",dk)):e.name==="shield"?(m(),v(ne,{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(ne,{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(ne,{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",fk)):U("",!0)],8,Db))}}),ce=Te(hk,[["__scopeId","data-v-421b9da7"]]),pk={class:"at-menu",role:"listbox","aria-label":"文件提及"},gk={key:0,class:"at-status"},mk={key:1,class:"at-status"},vk=["data-active","aria-selected","onClick","onMousemove"],yk={class:"at-item-name"},bk={key:0,class:"at-item-dir"},kk={class:"at-hints"},wk={class:"at-hint"},Sk=["title"],_k=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=O(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",pk,[e.loading&&e.suggestions.length===0?(m(),v("div",gk,"加载文件列表…")):e.suggestions.length===0?(m(),v("div",mk,"无匹配文件")):(m(),v("ul",{key:2,ref_key:"listRef",ref:o,class:"at-list"},[(m(!0),v(ne,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",yk,C(i(d)),1),a(d)?(m(),v("span",bk,C(a(d)),1)):U("",!0)],42,vk)]))),128))],512)),h("div",kk,[u[1]||(u[1]=h("span",{class:"at-hint"},[h("kbd",null,"↑↓"),Ae("选择")],-1)),h("span",wk,[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,Sk)):U("",!0)])])}}}),$k=Te(_k,[["__scopeId","data-v-9c8e827b"]]),Ck=["title","aria-label"],xk=["width","height","viewBox"],Ik=["cx","cy","r"],Tk=["cx","cy","r","stroke-dasharray","stroke-dashoffset","transform"],sa=2,Ek=Ie({__name:"ContextRing",props:{usage:{default:void 0},size:{default:16}},setup(e){iv(l=>({v1d95ffa8:a.value}));const t=e,n=G(()=>{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=G(()=>Math.round(n.value*100)),o=G(()=>(t.size-sa)/2),r=G(()=>2*Math.PI*o.value),i=G(()=>r.value*(1-n.value)),a=G(()=>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":sa,fill:"none"},null,8,Ik),h("circle",{class:"ring-value",cx:e.size/2,cy:e.size/2,r:o.value,"stroke-width":sa,fill:"none","stroke-linecap":"round","stroke-dasharray":r.value,"stroke-dashoffset":i.value,transform:`rotate(-90 ${e.size/2} ${e.size/2})`},null,8,Tk)],8,xk))],8,Ck))}}),bh=Te(Ek,[["__scopeId","data-v-3ffc343b"]]),Ak=["data-goal-status"],Mk={class:"goal-status"},Rk=["title"],Pk={class:"goal-metric",title:"已用轮次"},Lk={class:"goal-actions"},Dk=["disabled","title"],Nk=["disabled","title"],Ok=["disabled","title"],Gk=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=G(()=>!!n.goal&&n.goal.status!=="complete"),i=G(()=>{var c;return((c=n.goal)==null?void 0:c.status)==="active"}),a=G(()=>{var c;return o[((c=n.goal)==null?void 0:c.status)??""]??"目标"}),l=G(()=>n.disabled?n.disabledReason||"当前不可操作":""),u=G(()=>{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",Mk,C(a.value),1),h("span",{class:"goal-objective",title:e.goal.objective},C(e.goal.objective),9,Rk),h("span",Pk,C(u.value),1),h("div",Lk,[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,Dk)):(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,Nk)),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,Ok)])],8,Ak)):U("",!0)}}),Bk=Te(Gk,[["__scopeId","data-v-c7806e90"]]),Fk={class:"history-menu",role:"listbox","aria-label":"输入历史"},Uk={class:"history-header",title:"输入历史"},jk=["data-active","aria-selected","onClick","onMousemove"],zk={class:"history-item-index"},Hk={class:"history-item-text"},Wk=Ie({__name:"HistoryMenu",props:{items:{},activeIndex:{}},emits:["apply","hover"],setup(e,{emit:t}){const n=e,s=t,o=O(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",Fk,[h("div",Uk,[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(ne,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",zk,C(l+1),1),h("span",Hk,C(a),1)],42,jk)]))),128))],512)]))}}),qk=Te(Wk,[["__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 Vk=["aria-label"],Kk={key:0,class:"menu-heading"},Zk={key:0,class:"menu-group-title"},Yk=["disabled","title","aria-current","onClick"],Xk={class:"entry-label"};let Ps=null;function Jk(e){Ps==null||Ps(),Ps=e}function xc(e){Ps===e&&(Ps=null)}const Qk=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=O(null),r=O({});function i(){n.open&&s("update:open",!1)}Se(()=>n.open,d=>{d?(Jk(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"},[$o(d.$slots,"default",{},void 0),(m(),De(Xs,{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",Kk,C(e.heading),1)):U("",!0),(m(!0),v(ne,null,Ce(e.groups,(p,g)=>(m(),v(ne,{key:`g${g}`},[p.title?(m(),v("p",Zk,C(p.title),1)):U("",!0),(m(!0),v(ne,null,Ce(p.entries,y=>(m(),v("button",{key:y.key,class:ue(["menu-entry",{"is-active":y.checked,"is-danger":y.tone==="danger"}]),role:"menuitem",type:"button",disabled:y.disabled,title:y.title??y.label,"aria-current":y.checked?"true":void 0,onClick:S=>s("select",y.key)},[y.icon?(m(),De(ce,{key:0,name:y.icon,size:14},null,8,["name"])):U("",!0),h("span",Xk,C(y.label),1),y.checked?(m(),De(ce,{key:1,name:"check",size:14,class:"entry-check"})):U("",!0)],10,Yk))),128))],64))),128))],14,Vk)):U("",!0)]))],512))}}),Ya=Te(Qk,[["__scopeId","data-v-e68e06d8"]]),e1=["onKeydown"],t1={key:0,class:"picker-empty"},n1={class:"picker-group-title"},s1=["onClick"],o1={class:"row-main"},r1={class:"row-name"},i1={class:"row-alias"},a1={class:"row-meta"},l1={key:0,class:"row-check"},u1={class:"picker-thinking"},c1={class:"thinking-options"},d1=["onClick"],f1=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=O(""),a=O(null),l=G(()=>{const I=i.value.trim().toLowerCase();return I?n.models.filter(A=>A.alias.toLowerCase().includes(I)||A.provider.toLowerCase().includes(I)||(A.displayName??"").toLowerCase().includes(I)):n.models}),u=G(()=>{const I=new Map;for(const A of l.value){const V=I.get(A.provider)??[];V.push(A),I.set(A.provider,V)}return[...I.entries()].map(([A,V])=>({provider:A,models:V}))}),c=G(()=>n.models.find(I=>I.alias===n.currentModel)),d=G(()=>{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 y=O(null),S=O(null),k=O({});function w(){s("close"),s("update:open",!1)}function b(){var ae;const I=y.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)`,k.value=_e}function _(I){const A=I.target;A instanceof Element&&A.closest(".model-select")||S.value&&!S.value.contains(A)&&w()}function B(I){var V;const A=I.target;A instanceof Node&&((V=S.value)!=null&&V.contains(A))||w()}function D(){document.addEventListener("scroll",B,!0),window.addEventListener("resize",B)}function E(){document.removeEventListener("scroll",B,!0),window.removeEventListener("resize",B)}et(()=>{var I;document.addEventListener("mousedown",_,!0),n.open&&((I=a.value)==null||I.focus(),b(),D())}),Se(()=>n.open,I=>{if(!I){E();return}D(),Fe(()=>{var A;b(),(A=a.value)==null||A.focus()})}),st(()=>{document.removeEventListener("mousedown",_,!0),E()});function M(I){I!==n.currentModel&&s("apply-model",I),w()}const T=O(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 A=Z();if(A.length===0)return;const V=A.indexOf(document.activeElement);I.preventDefault(),V===-1?(ie=A[0])==null||ie.focus():I.key==="ArrowDown"?(me=A[(V+1)%A.length])==null||me.focus():(_e=A[(V-1+A.length)%A.length])==null||_e.focus()}function te(I){I!==n.currentThinking&&s("apply-thinking",I)}return(I,A)=>(m(),v("span",{ref_key:"anchorRef",ref:y,class:"model-picker model-picker--anchor"},[(m(),De(Xs,{to:"body"},[e.open?(m(),v("div",{key:0,ref_key:"rootRef",ref:S,class:"model-picker",style:bt(k.value),role:"dialog","aria-label":"模型选择",onKeydown:A[1]||(A[1]=Vn(tt(V=>w(),["stop"]),["esc"]))},[Ze(h("input",{ref_key:"searchRef",ref:a,"onUpdate:modelValue":A[0]||(A[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,e1),[[it,i.value]]),h("div",{ref_key:"listRef",ref:T,class:"picker-list",onKeydown:j},[u.value.length===0?(m(),v("div",t1,"无匹配模型")):U("",!0),(m(!0),v(ne,null,Ce(u.value,V=>(m(),v("div",{key:V.provider,class:"picker-group"},[h("div",n1,C(V.provider),1),(m(!0),v(ne,null,Ce(V.models,ie=>(m(),v("button",{key:ie.alias,class:ue(["picker-row",{active:ie.alias===e.currentModel}]),onClick:me=>M(ie.alias)},[h("span",o1,[h("span",r1,C(g(ie)),1),h("span",i1,C(ie.alias),1)]),h("span",a1,C(p(ie.maxContextSize)),1),ie.alias===e.currentModel?(m(),v("span",l1,"✓")):U("",!0)],10,s1))),128))]))),128))],544),h("div",u1,[A[2]||(A[2]=h("span",{class:"thinking-label"},"思考强度",-1)),h("div",c1,[(m(!0),v(ne,null,Ce(d.value,V=>(m(),v("button",{key:V,class:ue(["thinking-btn",{active:V===e.currentThinking}]),onClick:ie=>te(V)},C(f(V)),11,d1))),128))])])],36)):U("",!0)]))],512))}}),h1=Te(f1,[["__scopeId","data-v-0271ee16"]]),p1={class:"slash-menu",role:"listbox","aria-label":"斜杠命令与技能"},g1={key:0,class:"slash-search"},m1=["value"],v1={class:"slash-list"},y1={key:0,class:"slash-group"},b1={class:"slash-group-label"},k1={key:0,class:"slash-group-hint"},w1=["aria-selected","onMousedown","onMouseenter"],S1={class:"slash-name"},_1={key:0,class:"slash-aliases"},$1={class:"slash-desc"},C1={key:0,class:"slash-badge slash-badge-source"},x1={key:0,class:"slash-badge slash-badge-input"},I1={key:1,class:"slash-badge"},T1=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=G(()=>{const d=[];let f="";return n.commands.forEach((p,g)=>{const y=p.kind==="skill"?"skills":p.group==="advanced"?"advanced":"commands";y!==f&&(f=y,d.push({type:"header",label:a[y]})),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=O(""),u=G(()=>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",p1,[u.value?(m(),v("div",g1,[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,m1)])):U("",!0),h("div",v1,[(m(!0),v(ne,null,Ce(i.value,(p,g)=>{var y;return m(),v(ne,{key:g},[p.type==="header"?(m(),v("div",y1,[h("span",b1,C(p.label),1),p.hint?(m(),v("span",k1,C(p.hint),1)):U("",!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",S1,[Ae("/"+C(p.cmd.name),1),(y=p.cmd.aliases)!=null&&y.length?(m(),v("span",_1,C(p.cmd.aliases.map(S=>`/${S}`).join(" ")),1)):U("",!0)]),h("span",$1,C(p.cmd.description),1),p.cmd.kind==="skill"?(m(),v(ne,{key:0},[p.cmd.source?(m(),v("span",C1,C(r(p.cmd.source)),1)):U("",!0),f[1]||(f[1]=h("span",{class:"slash-badge slash-badge-skill"},"技能",-1))],64)):(m(),v(ne,{key:1},[p.cmd.acceptsInput?(m(),v("span",x1,"输入参数")):U("",!0),p.cmd.target==="backend"?(m(),v("span",I1,"服务端")):U("",!0)],64))],42,w1))],64)}),128))]),f[2]||(f[2]=h("div",{class:"slash-hint"},"↑↓ 选择 · Enter/Tab 执行 · Esc 关闭",-1))]))}}),E1=Te(T1,[["__scopeId","data-v-b0de79ca"]]),A1=34;function $r(e){const t=e.split("/"),n=t.at(-1)??e;return t.length<=2?{dir:t.length===2?`${t[0]}/`:"",base:n}:e.length<=A1?{dir:`${t.slice(0,-1).join("/")}/`,base:n}:{dir:`…/${t.at(-2)}/`,base:n}}const M1={class:"picker-input-row"},R1=["placeholder","onKeydown"],P1=["disabled","title"],L1={key:0,class:"picker-warn"},D1={class:"picker-rows"},N1=["title","onClick"],O1={class:"row-base"},G1={class:"row-path"},B1={class:"picker-rows"},F1=["title","onClick"],U1={class:"row-base"},j1=Ie({__name:"WorkspacePicker",props:{current:{default:""},defaultDir:{default:""},recentWorkDirs:{default:()=>[]}},emits:["select","close"],setup(e,{emit:t}){const n=e,s=t,o=O(n.current||n.defaultDir),r=O(null),i=O(null),a=O(null),l=O({}),u=G(()=>o.value.trim().startsWith("/")),c=G(()=>u.value&&o.value.trim().length>0);function d(){c.value&&s("select",o.value.trim())}const f=O([]);let p;Se(o,w=>{clearTimeout(p);const b=w.trim();if(!b.startsWith("/")){f.value=[];return}p=setTimeout(async()=>{const _=await Wl(b);o.value.trim()===b&&(f.value=(_??[]).filter(B=>B.type==="dir").slice(0,8))},250)});function g(w){var b;o.value=w.path,(b=r.value)==null||b.focus()}function y(){var M;const w=i.value;if(!w)return;const _=(((M=w.closest(".chip-slot"))==null?void 0:M.querySelector(".workspace-select"))??document.querySelector(".workspace-select")??w).getBoundingClientRect(),B=6,D=8,E=ql(_,{placement:"top",align:"left",maxWidth:Math.min(360,window.innerWidth-D*2),gap:B,edge:D});E.maxHeight=`min(60vh, ${Math.max(240,_.top-B-D)}px)`,l.value=E}function S(w){const b=w.target;b instanceof Element&&b.closest(".workspace-select")||a.value&&!a.value.contains(b)&&s("close")}function k(w){var _;const b=w.target;b instanceof Node&&((_=a.value)!=null&&_.contains(b))||s("close")}return et(()=>{document.addEventListener("mousedown",S,!0),document.addEventListener("scroll",k,!0),window.addEventListener("resize",k),Fe(()=>{var w,b;y(),(w=r.value)==null||w.focus(),(b=r.value)==null||b.select()})}),st(()=>{document.removeEventListener("mousedown",S,!0),document.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k),clearTimeout(p)}),(w,b)=>(m(),v("span",{ref_key:"anchorRef",ref:i,class:"workspace-picker workspace-picker--anchor"},[(m(),De(Xs,{to:"body"},[h("div",{ref_key:"rootRef",ref:a,class:"workspace-picker",style:bt(l.value),role:"dialog","aria-label":"选择工作区",onKeydown:b[1]||(b[1]=Vn(tt(_=>s("close"),["stop"]),["esc"]))},[b[4]||(b[4]=h("p",{class:"picker-title"},"工作区(下一次新建)",-1)),h("div",M1,[Ze(h("input",{ref_key:"inputRef",ref:r,"onUpdate:modelValue":b[0]||(b[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,R1),[[it,o.value]]),h("button",{class:"picker-apply","data-testid":"workspace-apply",disabled:!c.value,title:c.value?"使用该目录新建会话":"工作区必须是绝对路径",onClick:d}," 选择 ",8,P1)]),o.value.trim()&&!u.value?(m(),v("p",L1,"需要绝对路径(以 / 开头)")):U("",!0),e.recentWorkDirs.length?(m(),v(ne,{key:1},[b[2]||(b[2]=h("p",{class:"picker-section"},"最近使用",-1)),h("div",D1,[(m(!0),v(ne,null,Ce(e.recentWorkDirs,_=>(m(),v("button",{key:_,class:"picker-row",title:_,onClick:B=>s("select",_)},[X(ce,{name:"folder",size:14}),h("span",O1,C(F(Va)(_)),1),h("span",G1,C(F($r)(_).dir),1)],8,N1))),128))])],64)):U("",!0),f.value.length?(m(),v(ne,{key:2},[b[3]||(b[3]=h("p",{class:"picker-section"},"子目录",-1)),h("div",B1,[(m(!0),v(ne,null,Ce(f.value,_=>(m(),v("button",{key:_.path,class:"picker-row",title:_.path,onClick:B=>g(_)},[X(ce,{name:"folder",size:14}),h("span",U1,C(_.name),1)],8,F1))),128))])],64)):U("",!0)],36)]))],512))}}),z1=Te(j1,[["__scopeId","data-v-a02cc634"]]),H1=["data-placeholder-state","placeholder"],W1={class:"composer-capsule-row"},q1={class:"composer-chips"},V1=["title"],K1={class:"chip-text"},Z1={key:1,class:"chip-slot"},Y1=["disabled","title","aria-haspopup","aria-expanded"],X1={class:"chip-text"},J1={key:2,class:"chip-slot"},Q1=["disabled","title","aria-haspopup","aria-expanded"],ew={class:"chip-text"},tw=["disabled","title","aria-expanded"],nw={class:"chip-text"},sw=["disabled","title","aria-expanded"],ow={class:"chip-text"},rw=["title"],iw={class:"chip-text"},aw=["title"],lw={class:"chip-text"},uw=["data-action","disabled","title","aria-label"],cw={key:0,class:"primary-label"},Ic=50,dw=5e3,fw=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=O(""),i=O(null),a=G(()=>s.workDir||void 0),l=Mb(r,i,a),u=O(0),c=O(!1),d=G(()=>{const L=r.value;return!L.startsWith("/")||L.includes(`
20
- `)||/\s/.test(L.slice(1))?null:L.slice(1)}),f=G(()=>d.value===null?[]:jv(d.value)),p=G(()=>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 y=O([]);Se(()=>s.sessionId,()=>{y.value=[]}),Se(()=>s.busy,L=>{if(!L&&y.value.length>0){const[re,...Me]=y.value;y.value=Me,re&&o("send",re)}});let S=0;const k=O([]),w=G(()=>Pb(k.value,Rb(s.messages??[]),Ic)),b=O(!1),_=O(0);function B(){return`scream-history:${s.sessionId??"default"}`}function D(){try{const L=localStorage.getItem(B());k.value=L?JSON.parse(L):[]}catch{k.value=[]}}function E(L){if(k.value.at(-1)!==L){k.value=[...k.value,L].slice(-Ic);try{localStorage.setItem(B(),JSON.stringify(k.value))}catch{}}}function M(L){r.value=L,b.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,w.value.length-1),b.value=!0}function Z(L){const re=w.value.length;re!==0&&(_.value=Math.min(re-1,Math.max(0,_.value+L)))}Se(()=>w.value.length,()=>{_.value>=w.value.length&&(_.value=Math.max(0,w.value.length-1))});function W(){return`scream-draft:${s.sessionId??"default"}`}let j=null,te;Se(r,()=>{I(),b.value=!1,l.refresh(),clearTimeout(te),te=setTimeout(()=>{try{r.value?localStorage.setItem(W(),r.value):localStorage.removeItem(W())}catch{}},300)}),Se(()=>s.sessionId,()=>{if(clearTimeout(te),D(),b.value=!1,_.value=0,j&&Date.now()-j.at<=dw){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 A(){l.refresh()}const V=O(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")||(b.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(),b.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),y.value=[...y.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(b.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(),b.value=!1;return}if((L.key==="Tab"||L.key==="Enter"&&!L.shiftKey)&&w.value[_.value]!==void 0){L.preventDefault(),M(w.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&&w.value.length>0&&(L.preventDefault(),T())}function oe(){y.value=[],o("abort")}function ge(L){r.value=L,b.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(),b.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=G(()=>{var L;return(L=s.status)==null?void 0:L.model}),Ke=G(()=>{var L;return(L=s.status)==null?void 0:L.permission}),Ye=G(()=>{var L;return(L=s.status)==null?void 0:L.contextUsage}),rt=G(()=>s.connectionStatus==="disconnected"||s.connectionStatus==="reconnecting"),Dt={offline:"连接已断开,正在重连 — 可以先打字,回车会把消息排队",plan:"计划模式:只做只读分析与方案输出,回车提交这个问题",queue:`已排队:回车继续排队下一条,${_r}S 立即注入`,busy:`回合进行中:现在打字然后回车,消息会排队随下一轮注入(${_r}S 立即注入)`,"no-workspace":"这个会话还没有工作目录:@ 文件提及暂不可用,可以直接提问",idle:"输入消息,@ 提及文件,/ 触发指令"},x=G(()=>{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=G(()=>x.value==="idle"&&s.placeholder?s.placeholder:Dt[x.value]),z={off:"关闭",low:"低",medium:"中",high:"高",xhigh:"超高",max:"最大"},ee=G(()=>{var re;const L=(re=s.status)==null?void 0:re.model;if(L)return s.models.find(Me=>Me.alias===L)}),J=G(()=>{var L;return((L=ee.value)==null?void 0:L.thinkingLevels)??[]}),R=G(()=>{var L;return(L=s.status)==null?void 0:L.thinkingLevel}),K=G(()=>{const L=R.value;return!L||L==="none"?"默认":z[L]??L}),N={manual:"手动",auto:"自动",yolo:"YOLO",bot:"无人值守",ask:"询问"},Q=["manual","auto","yolo","bot","ask"],$={manual:"每次工具调用都要你确认",auto:"安全操作自动放行,敏感操作仍要确认",yolo:"全部自动放行,不再打断",bot:"无人值守模式:批量接管确认",ask:"遇到需要决定的操作时询问你"},H=G(()=>N[Ke.value??""]??Ke.value??"手动"),q=G(()=>{switch(Ke.value){case"auto":return"perm-auto";case"yolo":return"perm-yolo";case"bot":return"perm-bot";default:return"perm-manual"}}),se=G(()=>{const L=Ye.value;return L===void 0?"":`${Math.round(L*100)}%`}),{preferredWorkDir:fe,serverWorkDir:ye,displayWorkDir:Ee,setPreferredWorkDir:ke}=Hl(),be=G(()=>{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?Va(s.workDir):"工作区",title:s.workDir?`工作区:${s.workDir} — 工作区随会话创建,不可中途更换`:"这个会话还没有工作目录",enabled:!1,visible:!0}:{label:Ee.value?Va(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=O(null);function lt(L){ke(L),Oe.value=null}function gt(L,re){re&&(b.value=!1,Oe.value=Oe.value===L?null:L)}function sn(L,re){re?Oe.value=L:Oe.value===L&&(Oe.value=null)}function ws(){return be.value.model.enabled?(Oe.value="model",!0):!1}const mt=G(()=>Oe.value==="model"),Nt=G(()=>Za(J.value.map(L=>({key:L,label:L==="off"||L==="none"?"关闭":z[L]??L,checked:R.value===L})),"思考力度")),Ss=G(()=>Za(Q.map(L=>({key:L,label:N[L]??L,checked:Ke.value===L,title:$[L]})),"权限模式"));function _s(L){o("switch-model",L),Oe.value=null}function so(L){o("switch-thinking",L),Oe.value=null}function Fi(L){o("switch-permission",L),Oe.value=null}const on=G(()=>s.busy?"stop":"send"),$s={send:{icon:"arrow-up",label:"发送",title:"发送(回车)"},stop:{icon:"stop",label:"停止",title:"停止当前回合"}},Ui=G(()=>$s[on.value].icon),oo=G(()=>$s[on.value].label),ji=G(()=>on.value==="stop"&&r.value.trim()?`${$s.stop.title}(回车把当前输入排队,${_r}S 立即注入)`:$s[on.value].title),Qo=G(()=>on.value==="send"&&!r.value.trim());function Cs(){if(on.value==="stop"){oe();return}he()}const er=G(()=>!!s.goal&&(s.goal.status==="active"||s.goal.status==="paused"||s.goal.status==="blocked")),de=G(()=>rt.value||!s.sessionId),ve=G(()=>rt.value?"连接已断开,正在重连":s.sessionId?"":"还没有打开会话");return t({insertText:ge,insertDraft:$e,openModelPicker:ws}),(L,re)=>(m(),v("div",{class:"composer",style:bt(V.value?{paddingBottom:V.value+"px"}:void 0)},[p.value?(m(),De(E1,{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"])):U("",!0),F(l).visible.value?(m(),De($k,{key:1,suggestions:F(l).suggestions.value,"active-index":F(l).index.value,loading:F(l).dirLoading.value,"work-dir":e.workDir,onSelect:re[1]||(re[1]=Me=>F(l).confirm(Me)),onHover:re[2]||(re[2]=Me=>F(l).index.value=Me)},null,8,["suggestions","active-index","loading","work-dir"])):U("",!0),b.value&&w.value.length>0?(m(),De(qk,{key:2,items:w.value,"active-index":_.value,onApply:M,onHover:re[3]||(re[3]=Me=>_.value=Me)},null,8,["items","active-index"])):U("",!0),er.value?(m(),De(Bk,{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"])):U("",!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:A,onKeyup:A},null,40,H1),[[it,r.value]]),h("div",W1,[h("div",q1,[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))])):U("",!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",K1,C(e.variant==="home"?"技能":"指令"),1)],8,V1),be.value.workspace.visible?(m(),v("span",Z1,[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",X1,C(be.value.workspace.label),1),be.value.workspace.enabled?(m(),De(ce,{key:0,name:"chevron-down",size:12})):U("",!0)],10,Y1),Oe.value==="workspace"?(m(),De(z1,{key:0,current:F(fe)??"","default-dir":F(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"])):U("",!0)])):U("",!0),be.value.model.visible?(m(),v("span",J1,[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",ew,C(be.value.model.label),1),be.value.model.enabled?(m(),De(ce,{key:0,name:"chevron-down",size:12})):U("",!0)],10,Q1),X(Ol,{name:"picker"},{default:ot(()=>[mt.value?(m(),De(h1,{key:0,models:e.models,"current-model":Ue.value,"current-thinking":R.value,onApplyModel:_s,onApplyThinking:so,onClose:re[15]||(re[15]=Me=>Oe.value=null)},null,8,["models","current-model","current-thinking"])):U("",!0)]),_:1})])):U("",!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:so},{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",nw,C(be.value.thinking.label),1),X(ce,{name:"chevron-down",size:12})],10,tw)]),_:1},8,["groups","open"])):U("",!0),be.value.permission.visible?(m(),De(Ya,{key:4,class:"chip-slot",label:"权限模式",groups:Ss.value,open:Oe.value==="permission",placement:"top",align:"left","onUpdate:open":re[19]||(re[19]=Me=>sn("permission",Me)),onSelect:Fi},{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",ow,C(be.value.permission.label),1),X(ce,{name:"chevron-down",size:12})],10,sw)]),_:1},8,["groups","open"])):U("",!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",iw,C(be.value.context.label),1)],8,rw)):U("",!0),y.value.length?(m(),v("span",{key:6,class:"composer-chip is-static","data-chip":"queue",title:`已排队 ${y.value.length} 条,当前回合结束后自动发送`},[X(ce,{name:"queue",size:14}),h("span",lw,"排队 "+C(y.value.length),1)],8,aw)):U("",!0)]),h("button",{class:"composer-primary","data-action":on.value,disabled:Qo.value,title:ji.value,"aria-label":oo.value,onClick:Cs},[X(ce,{name:Ui.value,size:16},null,8,["name"]),on.value!=="send"?(m(),v("span",cw,C(oo.value),1)):U("",!0)],8,uw)])],4))}}),kh=Te(fw,[["__scopeId","data-v-43f7193d"]]),hw={class:"conv-bar"},pw={class:"conv-bar-left"},gw=["title"],mw=["title"],vw={key:1,class:"title-text"},yw={class:"conv-bar-right"},bw=["title","aria-label","aria-expanded"],kw={key:0,class:"stats-metric mono"},ww={key:1,class:"stats-sep","aria-hidden":"true"},Sw={key:2,class:"stats-metric mono"},_w=["aria-expanded"],$w=["title","aria-label"],Cw=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=G(()=>we.panelOpen),r=G(()=>(n.turnCount??0)>0||(n.turnTokens??0)>0);function i(){we.panelOpen?jl(!1):wr("detail")}function a(k){return k===null||k<=0?"":k>=1e6?`${(k/1e6).toFixed(1)}M`:k>=1e3?`${(k/1e3).toFixed(1)}k`:String(k)}const l=O(!1),u=G(()=>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(k){l.value=!1,k==="controls"?s("controls"):k==="agents"?s("agents"):k==="export"?s("export"):k==="fork"?s("fork"):k==="clear"?s("clear"):k==="files"&&Qy()}const d=O(!1),f=O("");function p(){f.value=n.title??"",d.value=!0}function g(){const k=f.value.trim();d.value=!1,k&&k!==n.title&&s("rename",k)}function y(k){k.key==="Enter"?(k.preventDefault(),g()):k.key==="Escape"&&(k.preventDefault(),d.value=!1)}const S=G(()=>n.busy?"运行中":"就绪");return(k,w)=>(m(),v("header",hw,[h("div",pw,[h("button",{class:"ghost-btn back-btn",title:"返回工作台","aria-label":"返回工作台",onClick:w[0]||(w[0]=b=>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,gw),h("button",{class:"title-btn",title:d.value?"":"点击重命名",onClick:p},[d.value?Ze((m(),v("input",{key:0,"onUpdate:modelValue":w[1]||(w[1]=b=>f.value=b),class:"title-input","aria-label":"会话标题",onKeydown:y,onBlur:g,onClick:w[2]||(w[2]=tt(()=>{},["stop"]))},null,544)),[[it,f.value]]):(m(),v("span",vw,C(e.title||"新会话"),1))],8,mw)]),h("div",yw,[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:w[3]||(w[3]=tt(()=>{},["stop"])),onClick:w[4]||(w[4]=b=>s("toggle-stats"))},[X(ce,{name:"bar-chart",size:16}),e.turnCount?(m(),v("span",kw,C(e.turnCount)+" 轮",1)):U("",!0),e.turnCount&&a(e.turnTokens)?(m(),v("span",ww,"·")):U("",!0),a(e.turnTokens)?(m(),v("span",Sw,C(a(e.turnTokens)),1)):U("",!0)],42,bw),X(Ya,{open:l.value,"onUpdate:open":w[6]||(w[6]=b=>l.value=b),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:w[5]||(w[5]=b=>l.value=!l.value)},[X(ce,{name:"more",size:18})],10,_w)]),_: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,$w)])]))}}),xw=Te(Cw,[["__scopeId","data-v-8f306594"]]),Iw={key:0,class:"ui-dialog-header"},Tw={class:"ui-dialog-title"},Ew={class:"ui-dialog-body"},Aw={key:1,class:"ui-dialog-footer"},Mw='a[href], button:not([disabled]), textarea, input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',Rw=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=O(null);let r=null;function i(){const l=o.value;return l?Array.from(l.querySelectorAll(Mw)).filter(u=>u.offsetParent!==null||u===document.activeElement):[]}function a(l){var p,g,y;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||!((y=o.value)!=null&&y.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(Xs,{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",Iw,[$o(l.$slots,"header",{},()=>[h("span",Tw,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"))},"✕")):U("",!0)])):U("",!0),h("div",Ew,[$o(l.$slots,"default",{},void 0,!0)]),l.$slots.footer?(m(),v("div",Aw,[$o(l.$slots,"footer",{},void 0,!0)])):U("",!0)],4)])):U("",!0)]),_:3})]))}}),Vl=Te(Rw,[["__scopeId","data-v-396acebf"]]),Pw={class:"info-row"},Lw={class:"info-val mono"},Dw={class:"info-row"},Nw={class:"info-val mono"},Ow={class:"info-row"},Gw={class:"info-val"},Bw={class:"info-row"},Fw={class:"info-val"},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={key:0,class:"info-row"},e0={class:"info-val"},t0={key:1,class:"info-row"},n0={class:"info-val"},s0={class:"info-val mono"},o0={class:"info-val"},r0={key:3,class:"info-empty"},i0=Ie({__name:"InfoPanel",props:{mode:{},status:{},sessionId:{},workDir:{}},emits:["close"],setup(e,{emit:t}){const n=e,s=t,o=G(()=>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,y])=>({model:g,tokens:c(y),output:y.output,cacheRead:y.inputCacheRead})):[]}const f=G(()=>a(n.status.usage)||a(n.status.contextTokens));return(p,g)=>(m(),De(Vl,{open:!0,title:o.value,onClose:g[0]||(g[0]=y=>s("close"))},{default:ot(()=>{var y,S;return[e.mode==="status"?(m(),v(ne,{key:0},[h("div",Pw,[g[1]||(g[1]=h("span",{class:"info-key"},"会话 ID",-1)),h("span",Lw,C(e.sessionId??"-"),1)]),h("div",Dw,[g[2]||(g[2]=h("span",{class:"info-key"},"工作目录",-1)),h("span",Nw,C(e.workDir??"-"),1)]),h("div",Ow,[g[3]||(g[3]=h("span",{class:"info-key"},"模型",-1)),h("span",Gw,C(e.status.model??"-"),1)]),h("div",Bw,[g[4]||(g[4]=h("span",{class:"info-key"},"权限模式",-1)),h("span",Fw,C(r(e.status.permission)),1)]),h("div",Uw,[g[5]||(g[5]=h("span",{class:"info-key"},"思考级别",-1)),h("span",jw,C(e.status.thinkingLevel??"-"),1)]),h("div",zw,[g[6]||(g[6]=h("span",{class:"info-key"},"计划模式",-1)),h("span",Hw,C(i(e.status.planMode)),1)]),h("div",Ww,[g[7]||(g[7]=h("span",{class:"info-key"},"WolfPack 模式",-1)),h("span",qw,C(i(e.status.wolfpackMode)),1)]),h("div",Vw,[g[8]||(g[8]=h("span",{class:"info-key"},"上下文",-1)),h("span",Kw,C(l(e.status.contextTokens))+" / "+C(l(e.status.maxContextTokens))+" ("+C(u(e.status.contextUsage))+")",1)])],64)):(m(),v(ne,{key:1},[h("div",Zw,[g[9]||(g[9]=h("span",{class:"info-key"},"上下文 Token",-1)),h("span",Yw,C(l(e.status.contextTokens))+" / "+C(l(e.status.maxContextTokens)),1)]),h("div",Xw,[g[10]||(g[10]=h("span",{class:"info-key"},"上下文占比",-1)),h("span",Jw,C(u(e.status.contextUsage)),1)]),(y=e.status.usage)!=null&&y.total?(m(),v("div",Qw,[g[11]||(g[11]=h("span",{class:"info-key"},"累计 Token",-1)),h("span",e0,C(l(c(e.status.usage.total))),1)])):U("",!0),(S=e.status.usage)!=null&&S.currentTurn?(m(),v("div",t0,[g[12]||(g[12]=h("span",{class:"info-key"},"当前回合",-1)),h("span",n0,C(l(c(e.status.usage.currentTurn))),1)])):U("",!0),d(e.status.usage).length?(m(),v(ne,{key:2},[g[13]||(g[13]=h("div",{class:"info-subhead"},"按模型",-1)),(m(!0),v(ne,null,Ce(d(e.status.usage),k=>(m(),v("div",{key:k.model,class:"info-row info-row-model"},[h("span",s0,C(k.model),1),h("span",o0,C(l(k.tokens))+"(输出 "+C(l(k.output))+" · 缓存读 "+C(l(k.cacheRead))+")",1)]))),128))],64)):U("",!0),f.value?U("",!0):(m(),v("div",r0,"暂无用量数据"))],64))]}),_:1},8,["title"]))}}),wh=Te(i0,[["__scopeId","data-v-1555711d"]]);function a0(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 l0(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 u0(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 c0=new Set(["edit","str_replace","replace","write","multi_edit","create_file","edit_file","apply_patch"]);function Sh(e){return c0.has(e.toLowerCase())}function Mi(e,t=!0){return e.suspended?"suspended":e.isError?"error":e.output===void 0?t?"running":"unknown":"ok"}function d0(e,t=!0){const n=new Set(e.map(s=>Mi(s,t)));return n.has("running")?"running":n.has("error")?"error":n.has("suspended")?"suspended":n.has("unknown")?"unknown":"ok"}function f0(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 h0(e,t){const n=new Set,s=[];for(const o of e.tools){if(!Sh(o.name)||Mi(o,!1)!=="ok")continue;const r=f0(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 bs=Zl();function _h(e){bs=e}var Io={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")},p0=/^(?:[ \t]*(?:\n|$))+/,g0=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,m0=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Zo=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,v0=/^ {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(),y0=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]+)*)/,b0=/^[^\n]+/,Jl=/(?!\s*\])(?:\\.|[^\[\]\\])+/,k0=Ve(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Jl).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),w0=Ve(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Yl).getRegex(),Ri="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]*?(?:-->|$))/,S0=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",Ri).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),xh=Ve(Xl).replace("hr",Zo).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",Ri).getRegex(),_0=Ve(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",xh).getRegex(),eu={blockquote:_0,code:g0,def:k0,fences:m0,heading:v0,hr:Zo,html:S0,lheading:Ch,list:w0,newline:p0,paragraph:xh,table:Io,text:b0},Tc=Ve("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Zo).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",Ri).getRegex(),$0={...eu,lheading:y0,table:Tc,paragraph:Ve(Xl).replace("hr",Zo).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",Ri).getRegex()},C0={...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:Io,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ve(Xl).replace("hr",Zo).replace("heading",` *#{1,6} *[^
20
+ `)||/\s/.test(L.slice(1))?null:L.slice(1)}),f=G(()=>d.value===null?[]:jv(d.value)),p=G(()=>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 y=O([]);Se(()=>s.sessionId,()=>{y.value=[]}),Se(()=>s.busy,L=>{if(!L&&y.value.length>0){const[re,...Me]=y.value;y.value=Me,re&&o("send",re)}});let S=0;const k=O([]),w=G(()=>Pb(k.value,Rb(s.messages??[]),Ic)),b=O(!1),_=O(0);function B(){return`scream-history:${s.sessionId??"default"}`}function D(){try{const L=localStorage.getItem(B());k.value=L?JSON.parse(L):[]}catch{k.value=[]}}function E(L){if(k.value.at(-1)!==L){k.value=[...k.value,L].slice(-Ic);try{localStorage.setItem(B(),JSON.stringify(k.value))}catch{}}}function M(L){r.value=L,b.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,w.value.length-1),b.value=!0}function Z(L){const re=w.value.length;re!==0&&(_.value=Math.min(re-1,Math.max(0,_.value+L)))}Se(()=>w.value.length,()=>{_.value>=w.value.length&&(_.value=Math.max(0,w.value.length-1))});function W(){return`scream-draft:${s.sessionId??"default"}`}let j=null,te;Se(r,()=>{I(),b.value=!1,l.refresh(),clearTimeout(te),te=setTimeout(()=>{try{r.value?localStorage.setItem(W(),r.value):localStorage.removeItem(W())}catch{}},300)}),Se(()=>s.sessionId,()=>{if(clearTimeout(te),D(),b.value=!1,_.value=0,j&&Date.now()-j.at<=dw){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 A(){l.refresh()}const V=O(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")||(b.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(),b.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),y.value=[...y.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(b.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(),b.value=!1;return}if((L.key==="Tab"||L.key==="Enter"&&!L.shiftKey)&&w.value[_.value]!==void 0){L.preventDefault(),M(w.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&&w.value.length>0&&(L.preventDefault(),T())}function oe(){y.value=[],o("abort")}function ge(L){r.value=L,b.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(),b.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=G(()=>{var L;return(L=s.status)==null?void 0:L.model}),Ke=G(()=>{var L;return(L=s.status)==null?void 0:L.permission}),Ye=G(()=>{var L;return(L=s.status)==null?void 0:L.contextUsage}),rt=G(()=>s.connectionStatus==="disconnected"||s.connectionStatus==="reconnecting"),Dt={offline:"连接已断开,正在重连 — 可以先打字,回车会把消息排队",plan:"计划模式:只做只读分析与方案输出,回车提交这个问题",queue:`已排队:回车继续排队下一条,${_r}S 立即注入`,busy:`回合进行中:现在打字然后回车,消息会排队随下一轮注入(${_r}S 立即注入)`,"no-workspace":"这个会话还没有工作目录:@ 文件提及暂不可用,可以直接提问",idle:"输入消息,@ 提及文件,/ 触发指令"},x=G(()=>{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=G(()=>x.value==="idle"&&s.placeholder?s.placeholder:Dt[x.value]),z={off:"关闭",low:"低",medium:"中",high:"高",xhigh:"超高",max:"最大"},ee=G(()=>{var re;const L=(re=s.status)==null?void 0:re.model;if(L)return s.models.find(Me=>Me.alias===L)}),J=G(()=>{var L;return((L=ee.value)==null?void 0:L.thinkingLevels)??[]}),R=G(()=>{var L;return(L=s.status)==null?void 0:L.thinkingLevel}),K=G(()=>{const L=R.value;return!L||L==="none"?"默认":z[L]??L}),N={manual:"手动",auto:"自动",yolo:"YOLO",bot:"无人值守",ask:"询问"},Q=["manual","auto","yolo","bot","ask"],$={manual:"每次工具调用都要你确认",auto:"安全操作自动放行,敏感操作仍要确认",yolo:"全部自动放行,不再打断",bot:"无人值守模式:批量接管确认",ask:"遇到需要决定的操作时询问你"},H=G(()=>N[Ke.value??""]??Ke.value??"手动"),q=G(()=>{switch(Ke.value){case"auto":return"perm-auto";case"yolo":return"perm-yolo";case"bot":return"perm-bot";default:return"perm-manual"}}),se=G(()=>{const L=Ye.value;return L===void 0?"":`${Math.round(L*100)}%`}),{preferredWorkDir:fe,serverWorkDir:ye,displayWorkDir:Ee,setPreferredWorkDir:ke}=Hl(),be=G(()=>{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?Va(s.workDir):"工作区",title:s.workDir?`工作区:${s.workDir} — 工作区随会话创建,不可中途更换`:"这个会话还没有工作目录",enabled:!1,visible:!0}:{label:Ee.value?Va(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=O(null);function lt(L){ke(L),Oe.value=null}function gt(L,re){re&&(b.value=!1,Oe.value=Oe.value===L?null:L)}function sn(L,re){re?Oe.value=L:Oe.value===L&&(Oe.value=null)}function ws(){return be.value.model.enabled?(Oe.value="model",!0):!1}const mt=G(()=>Oe.value==="model"),Nt=G(()=>Za(J.value.map(L=>({key:L,label:L==="off"||L==="none"?"关闭":z[L]??L,checked:R.value===L})),"思考力度")),Ss=G(()=>Za(Q.map(L=>({key:L,label:N[L]??L,checked:Ke.value===L,title:$[L]})),"权限模式"));function _s(L){o("switch-model",L),Oe.value=null}function so(L){o("switch-thinking",L),Oe.value=null}function Fi(L){o("switch-permission",L),Oe.value=null}const on=G(()=>s.busy?"stop":"send"),$s={send:{icon:"arrow-up",label:"发送",title:"发送(回车)"},stop:{icon:"stop",label:"停止",title:"停止当前回合"}},Ui=G(()=>$s[on.value].icon),oo=G(()=>$s[on.value].label),ji=G(()=>on.value==="stop"&&r.value.trim()?`${$s.stop.title}(回车把当前输入排队,${_r}S 立即注入)`:$s[on.value].title),Qo=G(()=>on.value==="send"&&!r.value.trim());function Cs(){if(on.value==="stop"){oe();return}he()}const er=G(()=>!!s.goal&&(s.goal.status==="active"||s.goal.status==="paused"||s.goal.status==="blocked")),de=G(()=>rt.value||!s.sessionId),ve=G(()=>rt.value?"连接已断开,正在重连":s.sessionId?"":"还没有打开会话");return t({insertText:ge,insertDraft:$e,openModelPicker:ws}),(L,re)=>(m(),v("div",{class:"composer",style:bt(V.value?{paddingBottom:V.value+"px"}:void 0)},[p.value?(m(),De(E1,{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"])):U("",!0),F(l).visible.value?(m(),De($k,{key:1,suggestions:F(l).suggestions.value,"active-index":F(l).index.value,loading:F(l).dirLoading.value,"work-dir":e.workDir,onSelect:re[1]||(re[1]=Me=>F(l).confirm(Me)),onHover:re[2]||(re[2]=Me=>F(l).index.value=Me)},null,8,["suggestions","active-index","loading","work-dir"])):U("",!0),b.value&&w.value.length>0?(m(),De(qk,{key:2,items:w.value,"active-index":_.value,onApply:M,onHover:re[3]||(re[3]=Me=>_.value=Me)},null,8,["items","active-index"])):U("",!0),er.value?(m(),De(Bk,{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"])):U("",!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:A,onKeyup:A},null,40,H1),[[it,r.value]]),h("div",W1,[h("div",q1,[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))])):U("",!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",K1,C(e.variant==="home"?"技能":"指令"),1)],8,V1),be.value.workspace.visible?(m(),v("span",Z1,[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",X1,C(be.value.workspace.label),1),be.value.workspace.enabled?(m(),De(ce,{key:0,name:"chevron-down",size:12})):U("",!0)],10,Y1),Oe.value==="workspace"?(m(),De(z1,{key:0,current:F(fe)??"","default-dir":F(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"])):U("",!0)])):U("",!0),be.value.model.visible?(m(),v("span",J1,[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",ew,C(be.value.model.label),1),be.value.model.enabled?(m(),De(ce,{key:0,name:"chevron-down",size:12})):U("",!0)],10,Q1),X(Ol,{name:"picker"},{default:ot(()=>[mt.value?(m(),De(h1,{key:0,models:e.models,"current-model":Ue.value,"current-thinking":R.value,onApplyModel:_s,onApplyThinking:so,onClose:re[15]||(re[15]=Me=>Oe.value=null)},null,8,["models","current-model","current-thinking"])):U("",!0)]),_:1})])):U("",!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:so},{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",nw,C(be.value.thinking.label),1),X(ce,{name:"chevron-down",size:12})],10,tw)]),_:1},8,["groups","open"])):U("",!0),be.value.permission.visible?(m(),De(Ya,{key:4,class:"chip-slot",label:"权限模式",groups:Ss.value,open:Oe.value==="permission",placement:"top",align:"left","onUpdate:open":re[19]||(re[19]=Me=>sn("permission",Me)),onSelect:Fi},{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",ow,C(be.value.permission.label),1),X(ce,{name:"chevron-down",size:12})],10,sw)]),_:1},8,["groups","open"])):U("",!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",iw,C(be.value.context.label),1)],8,rw)):U("",!0),y.value.length?(m(),v("span",{key:6,class:"composer-chip is-static","data-chip":"queue",title:`已排队 ${y.value.length} 条,当前回合结束后自动发送`},[X(ce,{name:"queue",size:14}),h("span",lw,"排队 "+C(y.value.length),1)],8,aw)):U("",!0)]),h("button",{class:"composer-primary","data-action":on.value,disabled:Qo.value,title:ji.value,"aria-label":oo.value,onClick:Cs},[X(ce,{name:Ui.value,size:16},null,8,["name"]),on.value!=="send"?(m(),v("span",cw,C(oo.value),1)):U("",!0)],8,uw)])],4))}}),kh=Te(fw,[["__scopeId","data-v-f2ac71a6"]]),hw={class:"conv-bar"},pw={class:"conv-bar-left"},gw=["title"],mw=["title"],vw={key:1,class:"title-text"},yw={class:"conv-bar-right"},bw=["title","aria-label","aria-expanded"],kw={key:0,class:"stats-metric mono"},ww={key:1,class:"stats-sep","aria-hidden":"true"},Sw={key:2,class:"stats-metric mono"},_w=["aria-expanded"],$w=["title","aria-label"],Cw=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=G(()=>we.panelOpen),r=G(()=>(n.turnCount??0)>0||(n.turnTokens??0)>0);function i(){we.panelOpen?jl(!1):wr("detail")}function a(k){return k===null||k<=0?"":k>=1e6?`${(k/1e6).toFixed(1)}M`:k>=1e3?`${(k/1e3).toFixed(1)}k`:String(k)}const l=O(!1),u=G(()=>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(k){l.value=!1,k==="controls"?s("controls"):k==="agents"?s("agents"):k==="export"?s("export"):k==="fork"?s("fork"):k==="clear"?s("clear"):k==="files"&&Qy()}const d=O(!1),f=O("");function p(){f.value=n.title??"",d.value=!0}function g(){const k=f.value.trim();d.value=!1,k&&k!==n.title&&s("rename",k)}function y(k){k.key==="Enter"?(k.preventDefault(),g()):k.key==="Escape"&&(k.preventDefault(),d.value=!1)}const S=G(()=>n.busy?"运行中":"就绪");return(k,w)=>(m(),v("header",hw,[h("div",pw,[h("button",{class:"ghost-btn back-btn",title:"返回工作台","aria-label":"返回工作台",onClick:w[0]||(w[0]=b=>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,gw),h("button",{class:"title-btn",title:d.value?"":"点击重命名",onClick:p},[d.value?Ze((m(),v("input",{key:0,"onUpdate:modelValue":w[1]||(w[1]=b=>f.value=b),class:"title-input","aria-label":"会话标题",onKeydown:y,onBlur:g,onClick:w[2]||(w[2]=tt(()=>{},["stop"]))},null,544)),[[it,f.value]]):(m(),v("span",vw,C(e.title||"新会话"),1))],8,mw)]),h("div",yw,[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:w[3]||(w[3]=tt(()=>{},["stop"])),onClick:w[4]||(w[4]=b=>s("toggle-stats"))},[X(ce,{name:"bar-chart",size:16}),e.turnCount?(m(),v("span",kw,C(e.turnCount)+" 轮",1)):U("",!0),e.turnCount&&a(e.turnTokens)?(m(),v("span",ww,"·")):U("",!0),a(e.turnTokens)?(m(),v("span",Sw,C(a(e.turnTokens)),1)):U("",!0)],42,bw),X(Ya,{open:l.value,"onUpdate:open":w[6]||(w[6]=b=>l.value=b),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:w[5]||(w[5]=b=>l.value=!l.value)},[X(ce,{name:"more",size:18})],10,_w)]),_: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,$w)])]))}}),xw=Te(Cw,[["__scopeId","data-v-8f306594"]]),Iw={key:0,class:"ui-dialog-header"},Tw={class:"ui-dialog-title"},Ew={class:"ui-dialog-body"},Aw={key:1,class:"ui-dialog-footer"},Mw='a[href], button:not([disabled]), textarea, input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',Rw=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=O(null);let r=null;function i(){const l=o.value;return l?Array.from(l.querySelectorAll(Mw)).filter(u=>u.offsetParent!==null||u===document.activeElement):[]}function a(l){var p,g,y;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||!((y=o.value)!=null&&y.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(Xs,{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",Iw,[$o(l.$slots,"header",{},()=>[h("span",Tw,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"))},"✕")):U("",!0)])):U("",!0),h("div",Ew,[$o(l.$slots,"default",{},void 0,!0)]),l.$slots.footer?(m(),v("div",Aw,[$o(l.$slots,"footer",{},void 0,!0)])):U("",!0)],4)])):U("",!0)]),_:3})]))}}),Vl=Te(Rw,[["__scopeId","data-v-396acebf"]]),Pw={class:"info-row"},Lw={class:"info-val mono"},Dw={class:"info-row"},Nw={class:"info-val mono"},Ow={class:"info-row"},Gw={class:"info-val"},Bw={class:"info-row"},Fw={class:"info-val"},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={key:0,class:"info-row"},e0={class:"info-val"},t0={key:1,class:"info-row"},n0={class:"info-val"},s0={class:"info-val mono"},o0={class:"info-val"},r0={key:3,class:"info-empty"},i0=Ie({__name:"InfoPanel",props:{mode:{},status:{},sessionId:{},workDir:{}},emits:["close"],setup(e,{emit:t}){const n=e,s=t,o=G(()=>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,y])=>({model:g,tokens:c(y),output:y.output,cacheRead:y.inputCacheRead})):[]}const f=G(()=>a(n.status.usage)||a(n.status.contextTokens));return(p,g)=>(m(),De(Vl,{open:!0,title:o.value,onClose:g[0]||(g[0]=y=>s("close"))},{default:ot(()=>{var y,S;return[e.mode==="status"?(m(),v(ne,{key:0},[h("div",Pw,[g[1]||(g[1]=h("span",{class:"info-key"},"会话 ID",-1)),h("span",Lw,C(e.sessionId??"-"),1)]),h("div",Dw,[g[2]||(g[2]=h("span",{class:"info-key"},"工作目录",-1)),h("span",Nw,C(e.workDir??"-"),1)]),h("div",Ow,[g[3]||(g[3]=h("span",{class:"info-key"},"模型",-1)),h("span",Gw,C(e.status.model??"-"),1)]),h("div",Bw,[g[4]||(g[4]=h("span",{class:"info-key"},"权限模式",-1)),h("span",Fw,C(r(e.status.permission)),1)]),h("div",Uw,[g[5]||(g[5]=h("span",{class:"info-key"},"思考级别",-1)),h("span",jw,C(e.status.thinkingLevel??"-"),1)]),h("div",zw,[g[6]||(g[6]=h("span",{class:"info-key"},"计划模式",-1)),h("span",Hw,C(i(e.status.planMode)),1)]),h("div",Ww,[g[7]||(g[7]=h("span",{class:"info-key"},"WolfPack 模式",-1)),h("span",qw,C(i(e.status.wolfpackMode)),1)]),h("div",Vw,[g[8]||(g[8]=h("span",{class:"info-key"},"上下文",-1)),h("span",Kw,C(l(e.status.contextTokens))+" / "+C(l(e.status.maxContextTokens))+" ("+C(u(e.status.contextUsage))+")",1)])],64)):(m(),v(ne,{key:1},[h("div",Zw,[g[9]||(g[9]=h("span",{class:"info-key"},"上下文 Token",-1)),h("span",Yw,C(l(e.status.contextTokens))+" / "+C(l(e.status.maxContextTokens)),1)]),h("div",Xw,[g[10]||(g[10]=h("span",{class:"info-key"},"上下文占比",-1)),h("span",Jw,C(u(e.status.contextUsage)),1)]),(y=e.status.usage)!=null&&y.total?(m(),v("div",Qw,[g[11]||(g[11]=h("span",{class:"info-key"},"累计 Token",-1)),h("span",e0,C(l(c(e.status.usage.total))),1)])):U("",!0),(S=e.status.usage)!=null&&S.currentTurn?(m(),v("div",t0,[g[12]||(g[12]=h("span",{class:"info-key"},"当前回合",-1)),h("span",n0,C(l(c(e.status.usage.currentTurn))),1)])):U("",!0),d(e.status.usage).length?(m(),v(ne,{key:2},[g[13]||(g[13]=h("div",{class:"info-subhead"},"按模型",-1)),(m(!0),v(ne,null,Ce(d(e.status.usage),k=>(m(),v("div",{key:k.model,class:"info-row info-row-model"},[h("span",s0,C(k.model),1),h("span",o0,C(l(k.tokens))+"(输出 "+C(l(k.output))+" · 缓存读 "+C(l(k.cacheRead))+")",1)]))),128))],64)):U("",!0),f.value?U("",!0):(m(),v("div",r0,"暂无用量数据"))],64))]}),_:1},8,["title"]))}}),wh=Te(i0,[["__scopeId","data-v-1555711d"]]);function a0(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 l0(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 u0(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 c0=new Set(["edit","str_replace","replace","write","multi_edit","create_file","edit_file","apply_patch"]);function Sh(e){return c0.has(e.toLowerCase())}function Mi(e,t=!0){return e.suspended?"suspended":e.isError?"error":e.output===void 0?t?"running":"unknown":"ok"}function d0(e,t=!0){const n=new Set(e.map(s=>Mi(s,t)));return n.has("running")?"running":n.has("error")?"error":n.has("suspended")?"suspended":n.has("unknown")?"unknown":"ok"}function f0(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 h0(e,t){const n=new Set,s=[];for(const o of e.tools){if(!Sh(o.name)||Mi(o,!1)!=="ok")continue;const r=f0(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 bs=Zl();function _h(e){bs=e}var Io={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")},p0=/^(?:[ \t]*(?:\n|$))+/,g0=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,m0=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Zo=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,v0=/^ {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(),y0=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]+)*)/,b0=/^[^\n]+/,Jl=/(?!\s*\])(?:\\.|[^\[\]\\])+/,k0=Ve(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Jl).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),w0=Ve(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Yl).getRegex(),Ri="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]*?(?:-->|$))/,S0=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",Ri).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),xh=Ve(Xl).replace("hr",Zo).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",Ri).getRegex(),_0=Ve(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",xh).getRegex(),eu={blockquote:_0,code:g0,def:k0,fences:m0,heading:v0,hr:Zo,html:S0,lheading:Ch,list:w0,newline:p0,paragraph:xh,table:Io,text:b0},Tc=Ve("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Zo).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",Ri).getRegex(),$0={...eu,lheading:y0,table:Tc,paragraph:Ve(Xl).replace("hr",Zo).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",Ri).getRegex()},C0={...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:Io,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ve(Xl).replace("hr",Zo).replace("heading",` *#{1,6} *[^
21
21
  ]`).replace("lheading",Ch).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},x0=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,I0=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ih=/^( {2,}|\\)\n(?!\s*$)/,T0=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Pi=/[\p{P}\p{S}]/u,tu=/[\s\p{P}\p{S}]/u,Th=/[^\s\p{P}\p{S}]/u,E0=Ve(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,tu).getRegex(),Eh=/(?!~)[\p{P}\p{S}]/u,A0=/(?!~)[\s\p{P}\p{S}]/u,M0=/(?:[^\s\p{P}\p{S}]|~)/u,R0=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Ah=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,P0=Ve(Ah,"u").replace(/punct/g,Pi).getRegex(),L0=Ve(Ah,"u").replace(/punct/g,Eh).getRegex(),Mh="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",D0=Ve(Mh,"gu").replace(/notPunctSpace/g,Th).replace(/punctSpace/g,tu).replace(/punct/g,Pi).getRegex(),N0=Ve(Mh,"gu").replace(/notPunctSpace/g,M0).replace(/punctSpace/g,A0).replace(/punct/g,Eh).getRegex(),O0=Ve("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Th).replace(/punctSpace/g,tu).replace(/punct/g,Pi).getRegex(),G0=Ve(/\\(punct)/,"gu").replace(/punct/g,Pi).getRegex(),B0=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(),F0=Ve(Ql).replace("(?:-->|$)","-->").getRegex(),U0=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",F0).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Jr=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,j0=Ve(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Jr).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Rh=Ve(/^!?\[(label)\]\[(ref)\]/).replace("label",Jr).replace("ref",Jl).getRegex(),Ph=Ve(/^!?\[(ref)\](?:\[\])?/).replace("ref",Jl).getRegex(),z0=Ve("reflink|nolink(?!\\()","g").replace("reflink",Rh).replace("nolink",Ph).getRegex(),nu={_backpedal:Io,anyPunctuation:G0,autolink:B0,blockSkip:R0,br:Ih,code:I0,del:Io,emStrongLDelim:P0,emStrongRDelimAst:D0,emStrongRDelimUnd:O0,escape:x0,link:j0,nolink:Ph,punctuation:E0,reflink:Rh,reflinkSearch:z0,tag:U0,text:T0,url:Io},H0={...nu,link:Ve(/^!?\[(label)\]\((.*?)\)/).replace("label",Jr).getRegex(),reflink:Ve(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Jr).getRegex()},Xa={...nu,emStrongRDelimAst:N0,emStrongLDelim:L0,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.!#$%&'*+\/=?_`{\|}~-]+@)))/},W0={...Xa,br:Ve(Ih).replace("{2,}","*").getRegex(),text:Ve(Xa.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ir={normal:eu,gfm:$0,pedantic:C0},co={normal:nu,gfm:Xa,breaks:W0,pedantic:H0},q0={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ec=e=>q0[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 fo(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 V0(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 K0(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(`
23
23
  `)}var Qr=class{constructor(e){Y(this,"options");Y(this,"rules");Y(this,"lexer");this.options=e||bs}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:fo(n,`
@@ -237,4 +237,4 @@ XID_Start XIDS`.split(/\s/).map(e=>[Oi(e),e])),qC=new Map([["s",dt(383)],[dt(383
237
237
  `),s=t.split(`
238
238
  `);if(n.length+s.length>fI){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=hI(n,s);return pI(o,n,s,n.length,s.length)}function mI(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 vI=["old_string","oldString","old_str","old_text","oldText","old","search"],yI=["new_string","newString","new_str","new_text","newText","new","replace","content"],bI=["path","file_path","filePath","file","filename"];function ka(e,t){for(const n of t){const s=e[n];if(typeof s=="string"&&s.length>0)return s}}function kI(e){if(!e||typeof e!="object")return null;const t=e,n=ka(t,bI),s=ka(t,vI),o=ka(t,yI);if(!o&&!s)return null;const r=gI(s??"",o??""),i=mI(r);return{path:n,diff:r,stats:i}}const wI={class:"diff-lines"},SI={class:"dl-gutter old"},_I={class:"dl-gutter new"},$I={class:"dl-sign"},CI={class:"dl-text"},xI=Ie({__name:"DiffLines",props:{lines:{}},setup(e){return(t,n)=>(m(),v("div",wI,[(m(!0),v(ne,null,Ce(e.lines,(s,o)=>(m(),v("div",{key:o,class:ue(["dl",`dl-${s.type}`])},[h("span",SI,C(s.oldNo??""),1),h("span",_I,C(s.newNo??""),1),h("span",$I,C(s.type==="add"?"+":s.type==="del"?"−":" "),1),h("span",CI,C(s.text),1)],2))),128))]))}}),wu=Te(xI,[["__scopeId","data-v-e2e145aa"]]),II=["onKeydown"],TI={class:"tool-name"},EI=["title"],AI={key:1,class:"diff-chip"},MI={class:"tool-collapse-inner"},RI={class:"tool-body"},PI={key:1,class:"tool-result"},LI={key:2,class:"tool-running-hint"},DI=Ie({__name:"EditToolCard",props:{tool:{},live:{type:Boolean,default:!0},workDir:{default:""},sessionId:{default:""}},setup(e){const t=e,n=G(()=>Mi(t.tool,t.live)),s=G(()=>{switch(n.value){case"ok":return"✓";case"error":return"✗";default:return""}}),o=G(()=>kI(t.tool.args)),r=G(()=>{const y=o.value;if(!y||n.value==="error")return"";const{added:S,removed:k}=y.stats;return!S&&!k?"":`+${S} −${k}`}),i=G(()=>{var y;return(y=o.value)==null?void 0:y.path}),a=O(!1);let l=!1;Se(n,y=>{l||(a.value=y==="running")},{immediate:!0});function u(){l=!0,a.value=!a.value}const c=G(()=>{var y;return((y=o.value)==null?void 0:y.diff)??[]}),d=G(()=>c.value.length>0),f=zp(G(()=>t.tool),n,()=>t.live);function p(){const y=i.value;y&&ms(Kl(y,t.workDir||void 0),{modeHint:"diff",sessionId:t.sessionId||null})}const g=G(()=>{var k;const y=t.tool.progress;if(!y)return"";const S=y.split(`
239
239
  `).filter(w=>w.trim());return((k=S[S.length-1])==null?void 0:k.slice(0,60))??""});return(y,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(ne,{key:0},[Ae(C(s.value),1)],64)):U("",!0)],2),h("span",TI,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,EI)):U("",!0),r.value?(m(),v("span",AI,C(r.value),1)):U("",!0),F(f)?(m(),v("span",{key:2,class:ue(["tool-duration",{live:e.tool.durationMs===void 0}])},C(F(f)),3)):U("",!0),h("span",{class:ue(["tool-chevron",{open:a.value}])},"▸",2)],40,II),h("div",{class:ue(["tool-collapse",{open:a.value}])},[h("div",MI,[h("div",RI,[d.value?(m(),De(wu,{key:0,lines:c.value},null,8,["lines"])):U("",!0),e.tool.output!==void 0?(m(),v("pre",PI,[h("code",null,C(e.tool.output||"(无输出)"),1)])):(m(),v("div",LI,C(g.value||"执行中…"),1))])])],2)],2))}}),NI=Te(DI,[["__scopeId","data-v-a5355539"]]),OI=["aria-expanded"],GI={class:"process-label"},BI={class:"process-meta"},FI=["title"],UI={class:"process-collapse"},jI={class:"process-inner"},zI={key:0,class:"process-more"},HI=["aria-expanded"],wa=20,WI=Ie({__name:"ToolGroup",props:{name:{},tools:{},live:{type:Boolean,default:!0},workDir:{default:""},sessionId:{default:""}},setup(e){const t=e,n=O(!1),s=G(()=>d0(t.tools,t.live)),o=G(()=>t.tools.filter(c=>c.output!==void 0&&!c.isError).length),r=G(()=>s.value==="running"?"执行中":s.value==="error"?"含失败调用":s.value==="suspended"?"含挂起等待":s.value==="unknown"?"结果未持久化":`已完成 ${o.value} 项`);function i(){n.value=!n.value}const a=O(!1),l=G(()=>Math.max(0,t.tools.length-wa)),u=G(()=>a.value?t.tools:t.tools.slice(0,wa));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",GI,C(e.name),1),h("span",BI,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,FI)],8,OI),h("div",UI,[h("div",jI,[(m(!0),v(ne,null,Ce(u.value,f=>(m(),De(Tf(F(Sh)(f.name)?NI:dI),{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",zI,[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?`收起,只看前 ${wa} 条`:`还有 ${l.value} 条 · 显示全部`),9,HI)])):U("",!0)])])],2))}}),qI=Te(WI,[["__scopeId","data-v-4441817e"]]),VI={class:"thinking-block"},KI=["title"],ZI={class:"teaser-text"},YI={class:"teaser-open"},XI={key:1,class:"thinking-stream","data-state":"running"},JI={class:"thinking-panel",role:"dialog","aria-label":"思考过程"},QI={class:"panel-body"},eT=Ie({__name:"ThinkingBlock",props:{tool:{},active:{type:Boolean,default:!1},sessionId:{default:""},msgSeq:{default:void 0}},setup(e){const t=e,n=O(!1),s=O(null),o=O(!1),r=O(!1),i=O(t.tool.output??"");Se(()=>t.tool.output,f=>{f!==void 0&&!o.value&&!r.value&&(i.value=f)});const a=G(()=>!!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=G(()=>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",VI,[e.active?(m(),v("div",XI,[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",ZI,C(o.value?"加载完整思考…":u.value||"思考过程"),1),h("span",YI,C(a.value?"查看全文":"展开"),1)],8,KI)),(m(),De(Xs,{to:"body"},[n.value?(m(),v("div",{key:0,class:"thinking-overlay",onClick:tt(d,["self"])},[h("aside",JI,[h("header",{class:"panel-header"},[p[2]||(p[2]=h("span",null,"💭 思考过程",-1)),h("button",{class:"panel-close","aria-label":"关闭",onClick:d},"✕")]),h("div",QI,C(i.value||"(空)"),1)])])):U("",!0)]))]))}}),tT=Te(eT,[["__scopeId","data-v-9382b07d"]]),nT={key:0,class:"clock"},sT={class:"stat"},oT={class:"stat"},rT={class:"stat"},iT={class:"stat"},aT={class:"stat"},lT={class:"stat"},uT=Ie({__name:"TurnStats",props:{stats:{},inline:{type:Boolean}},setup(e){const t=e,n=O(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(ne,{key:0},[u[0]||(u[0]=h("span",{class:"badge-gradient"},"正在思考",-1)),n.value!==null?(m(),v("span",nT,C(i(n.value)),1)):U("",!0)],64)):(m(),v(ne,{key:1},[h("span",sT,C(e.stats.turn)+" 轮 · "+C(e.stats.step)+" 步",1),u[10]||(u[10]=h("span",{class:"dot"},"·",-1)),h("span",oT,[u[1]||(u[1]=h("span",{class:"k"},"LLM",-1)),Ae(" "+C(i(e.stats.llmMs)),1)]),e.stats.toolMs?(m(),v(ne,{key:0},[u[3]||(u[3]=h("span",{class:"dot"},"·",-1)),h("span",rT,[u[2]||(u[2]=h("span",{class:"k"},"工具",-1)),Ae(" "+C(i(e.stats.toolMs)),1)])],64)):U("",!0),e.stats.firstTokenMs!==null&&e.stats.firstTokenMs!==void 0?(m(),v(ne,{key:1},[u[5]||(u[5]=h("span",{class:"dot"},"·",-1)),h("span",iT,[u[4]||(u[4]=h("span",{class:"k"},"首token",-1)),Ae(" "+C(i(e.stats.firstTokenMs)),1)])],64)):U("",!0),e.stats.tokens!==null&&e.stats.tokens!==void 0?(m(),v(ne,{key:2},[u[7]||(u[7]=h("span",{class:"dot"},"·",-1)),h("span",aT,[u[6]||(u[6]=h("span",{class:"k"},"tokens",-1)),Ae(" "+C(a(e.stats.tokens)),1)])],64)):U("",!0),e.stats.tokensPerSec!==null&&e.stats.tokensPerSec!==void 0?(m(),v(ne,{key:3},[u[9]||(u[9]=h("span",{class:"dot"},"·",-1)),h("span",lT,[u[8]||(u[8]=h("span",{class:"k"},"tok/s",-1)),Ae(" "+C(e.stats.tokensPerSec),1)])],64)):U("",!0)],64))],2))}}),Cd=Te(uT,[["__scopeId","data-v-dad21b9b"]]),cT=["data-message-id","data-message-role"],dT={key:0,class:"user-wrap"},fT={class:"user-head"},hT={key:0,class:"meta-time"},pT={class:"user-avatar","aria-hidden":"true"},gT={class:"user-bubble"},mT=["title","onClick"],vT={key:0,class:"message-meta user-meta"},yT={key:1,class:"assistant-wrap"},bT={key:0,class:"assistant-brand"},kT=["title"],wT={key:1,class:"brand-streaming"},ST={key:3,class:"brand-time"},_T={class:"assistant-body"},$T={key:0,class:"degraded-note"},CT={key:4,class:"streaming-cursor","aria-label":"正在生成"},xT={key:6,class:"written-files",role:"group","aria-label":"本回合写入的文件"},IT=["title","onClick"],TT={class:"written-file-name"},ET={key:7,class:"message-meta"},AT=["title"],MT=["title"],RT=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=O(!1);let r=null;const i=G(()=>n.message.role==="user"),a=G(()=>n.message.role==="assistant"),l=G(()=>{var W;return((W=n.message.turnStats)==null?void 0:W.status)==="running"}),u=G(()=>n.message.tools.filter(W=>W.name==="thinking")),c=G(()=>n.message.tools.filter(W=>W.name!=="thinking")),d=G(()=>n.message.ts!==void 0?a0(n.message.ts):""),f=G(()=>{const W=n.message.model??"",j=W.lastIndexOf("/");return j>=0&&j<W.length-1?W.slice(j+1):W}),p=G(()=>i.value&&n.isLatestUser&&n.idle),g=G(()=>a.value&&!n.streaming?h0(n.message,n.workDir||void 0):[]);function y(W){return W.split("/").pop()||W}function S(W){ms(W,{sessionId:n.sessionId||void 0})}const k=/(^|\s)@("[^"\n]+"|[^\s"]+)/g;function w(W){if(!W||W.startsWith("/")||W.startsWith("~"))return W;const j=n.workDir.trim();if(!j)return W;let te=W;for(;te.startsWith("./");)te=te.slice(2);return`${j.replace(/\/+$/,"")}/${te}`}const b=G(()=>{const W=n.message.content;if(!i.value||!W||!W.includes("@"))return[];const j=[];let te=0;k.lastIndex=0;let I;for(;(I=k.exec(W))!==null;){const A=I.index+I[1].length;A>te&&j.push({text:W.slice(te,A),path:null});const V=I[2],ie=V.startsWith('"')?V.slice(1,-1):V;j.push({text:W.slice(A,A+1+V.length),path:w(ie)}),te=A+1+V.length}return te<W.length&&j.push({text:W.slice(te),path:null}),j});function _(W){ms(W,{sessionId:n.sessionId||void 0})}const B=In("showThinking",O(!0)),D=In("showTools",O(!0)),E=O(!1);let M=null;function T(){if(typeof window>"u"||!("speechSynthesis"in window))return;if(E.value){window.speechSynthesis.cancel(),E.value=!1,M=null;return}const W=n.message.content;if(!W)return;const j=new SpeechSynthesisUtterance(W);j.lang="zh-CN";const te=()=>{M===te&&(E.value=!1,M=null)};M=te,j.addEventListener("end",te),j.addEventListener("error",te),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",dT,[h("div",fT,[d.value?(m(),v("span",hT,C(d.value),1)):U("",!0),j[3]||(j[3]=h("span",{class:"head-name"},"你",-1)),h("span",pT,[X(ce,{name:"user",size:12})])]),h("div",gT,[b.value.length?(m(!0),v(ne,{key:0},Ce(b.value,(te,I)=>(m(),v(ne,{key:I},[te.path!==null?(m(),v("button",{key:0,class:"at-link",title:`在文件面板中打开 ${te.path}`,onClick:A=>_(te.path??"")},C(te.text),9,mT)):(m(),v(ne,{key:1},[Ae(C(te.text),1)],64))],64))),128)):(m(),v(ne,{key:1},[Ae(C(e.message.content),1)],64))]),p.value?(m(),v("div",vT,[h("button",{title:"编辑并重新发送",onClick:j[0]||(j[0]=te=>s("edit",e.message.content))},[X(ce,{name:"edit",size:12}),j[4]||(j[4]=Ae("编辑重发",-1))])])):U("",!0)])):(m(),v("div",yT,[a.value&&(e.message.model&&e.showModel||e.streaming||l.value||e.showTimestamp&&d.value)?(m(),v("div",bT,[e.message.model&&e.showModel?(m(),v("span",{key:0,class:"brand-model",title:e.message.model},C(f.value),9,kT)):U("",!0),e.streaming?(m(),v("span",wT,[...j[5]||(j[5]=[h("i",{"aria-hidden":"true"},null,-1),Ae("生成中",-1)])])):U("",!0),l.value?(m(),De(Cd,{key:2,stats:e.message.turnStats,inline:""},null,8,["stats"])):U("",!0),e.showTimestamp&&d.value?(m(),v("time",ST,C(d.value),1)):U("",!0)])):U("",!0),h("div",_T,[e.message.degraded?(m(),v("p",$T,"该回合早于持久化快照:正文与思考在服务重启后无法恢复(工具记录与消息结构已保留)。")):U("",!0),F(B)?(m(!0),v(ne,{key:1},Ce(u.value,te=>(m(),De(tT,{key:te.toolCallId,tool:te,active:e.streaming,"session-id":e.sessionId,"msg-seq":e.message.seq},null,8,["tool","active","session-id","msg-seq"]))),128)):U("",!0),c.value.length&&F(D)?(m(),De(qI,{key:2,name:"工具调用过程",tools:c.value,live:e.streaming,"work-dir":e.workDir,"session-id":e.sessionId},null,8,["tools","live","work-dir","session-id"])):U("",!0),e.message.content?(m(),De(jp,{key:3,class:"assistant-content",content:e.message.content,streaming:e.streaming},null,8,["content","streaming"])):e.streaming?(m(),v("span",CT)):U("",!0),e.message.turnStats&&e.message.turnStats.status!=="running"?(m(),De(Cd,{key:5,stats:e.message.turnStats},null,8,["stats"])):U("",!0),g.value.length?(m(),v("div",xT,[(m(!0),v(ne,null,Ce(g.value,te=>(m(),v("button",{key:te.filePath,type:"button",class:"written-file",title:`在文件面板中打开 ${te.filePath}`,onClick:I=>S(te.filePath)},[X(ce,{name:"file",size:12}),h("span",TT,C(y(te.filePath)),1)],8,IT))),128))])):U("",!0),e.message.content||e.message.isError&&!e.streaming||e.canFork?(m(),v("div",ET,[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,AT)):U("",!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,MT)):U("",!0),e.message.isError&&!e.streaming?(m(),v("button",{key:2,class:"retry-btn",title:"重发最后一条消息",onClick:j[1]||(j[1]=te=>s("retry"))},[X(ce,{name:"refresh",size:12}),j[6]||(j[6]=Ae("重试",-1))])):U("",!0),a.value&&e.canFork&&!e.streaming?(m(),v("button",{key:3,title:"以当前对话为起点创建一个新会话",onClick:j[2]||(j[2]=te=>s("fork"))},[X(ce,{name:"fork",size:12}),j[7]||(j[7]=Ae("Fork",-1))])):U("",!0)])):U("",!0)])]))],10,cT))}}),PT=Te(RT,[["__scopeId","data-v-c06917b6"]]),LT=["title","aria-label","onMouseenter","onClick"],DT={key:0,class:"minimap-tooltip"},NT="(min-width: 960px)",OT="(prefers-reduced-motion: reduce)",GT=24,BT=1e3,FT=Ie({__name:"ChatMinimap",props:{messages:{},host:{},revision:{},revealMessage:{type:Function}},setup(e){const t=e,n=O(null),s=typeof window.matchMedia=="function",o=s?window.matchMedia(NT):null,r=s?window.matchMedia(OT):null,i=O((o==null?void 0:o.matches)??!1),a=O((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=G(()=>{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=G(()=>d.value.reduce((oe,ge)=>oe+ge.ratio,0)||1),p=O({scrollTop:0,scrollHeight:0,clientHeight:0,trackHeight:0}),g=O(!1),y=O(!1),S=O(!1),k=O(null),w=G(()=>p.value.scrollHeight>p.value.clientHeight),b=G(()=>{const{scrollTop:oe,scrollHeight:ge,clientHeight:$e,trackHeight:Ne}=p.value;if(!g.value||!w.value||Ne<=0)return{};const Ue=Math.max(GT,$e/ge*Ne),Ke=Math.max(Ne-Ue,0);return{top:`${Math.min(Math.max(oe/ge*Ne,0),Ke)}px`,height:`${Ue}px`}}),_=G(()=>y.value||n.value!==null),B=G(()=>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},BT))}function M(){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=k.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 te(){y.value=!0,E()}function I(){y.value=!1,E()}let A=null;function V(){const oe=t.host;A==null||A.disconnect(),A=null,oe&&(oe.addEventListener("scroll",j,{passive:!0}),typeof ResizeObserver<"u"&&(A=new ResizeObserver(()=>W()),A.observe(oe)))}function ie(){var oe;(oe=t.host)==null||oe.removeEventListener("scroll",j),A==null||A.disconnect(),A=null}et(()=>{i.value&&(V(),E(),W())}),st(()=>{ie(),M(),T!==null&&(cancelAnimationFrame(T),T=null)}),Se([()=>t.host,i],()=>{ie(),g.value=!1,Fe(()=>{i.value&&(V(),W())})});const me=G(()=>{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(w,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&&w.value?(m(),v("div",{key:0,class:ue(["minimap",{"is-quiet":B.value,"is-hovered":_.value}]),role:"navigation","aria-label":"消息地图",onPointerenter:te,onPointerleave:I},[h("div",{ref_key:"trackRef",ref:k,class:"minimap-track"},[(m(!0),v(ne,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",DT,C(pe($e)),1)):U("",!0)],46,LT))),128)),h("div",{class:ue(["minimap-thumb",{"is-ready":g.value}]),style:bt(b.value),"aria-hidden":"true"},null,6)],512)],34)):U("",!0)}}),UT=Te(FT,[["__scopeId","data-v-b3335103"]]);function xd(e,t){return e-t}function Id(e,t){return Math.max(0,e-t)}const jT={class:"message-list-wrapper"},zT={key:0,class:"conn-banner",role:"status"},HT=["disabled"],WT={key:0,class:"day-divider",role:"separator"},qT={key:1,class:"turn-divider","aria-hidden":"true"},VT={key:1,class:"message-skeleton","aria-hidden":"true"},KT=["aria-label"],ZT={key:0,class:"scroll-badge"},YT=80,XT=40,JT=8,Td=24,QT=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=O(null),r=O(null);let i=null;const a=G(()=>{for(let $=n.messages.length-1;$>=0;$--)if(n.messages[$].role==="user")return n.messages[$].id;return null}),l=G(()=>{var $;return(($=n.messages.at(-1))==null?void 0:$.id)??null}),u=G(()=>{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||l0(q.ts,H.ts)?null:u0(H.ts)}const g={streaming:!1,isLatestUser:!1,canFork:!1,showTimestamp:!1,showModel:!1,idle:!0},y=G(()=>{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,$-YT)}const k=O(S(y.value.length)),w=G(()=>{const $=y.value.length,H=Math.min(Math.max(0,k.value),$);return y.value.slice(H)}),b=G(()=>k.value>0||n.olderAvailable);function _($){const H=y.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 B($){const H=_($);return H<0?!1:(H>=k.value||D(()=>{k.value=Math.max(0,H-JT)}),!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 M=G(()=>{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=O(!1),W=O(0);function j(){const $=o.value;return $?$.scrollHeight-$.scrollTop-$.clientHeight<Td:!0}function te(){return typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function I($){k.value=S(y.value.length),requestAnimationFrame(()=>{const H=o.value;if(!H)return;const q=te()?"auto":$;q==="smooth"&&_e(),H.scrollTo({top:H.scrollHeight,behavior:q})})}let A=!1,V=null,ie=null;function me(){const $=o.value;V&&$&&$.removeEventListener("scrollend",V),V=null,A=!1,ie!==null&&(clearTimeout(ie),ie=null)}function _e(){const $=o.value;$&&(me(),A=!0,V=()=>me(),$.addEventListener("scrollend",V),ie=setTimeout(me,1500))}function he(){const $=o.value;!A||!$||($.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(){k.value=S(y.value.length);const $=o.value;$&&($.scrollTop=$.scrollHeight)}async function z($,H){if(!B($))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&&k.value>0){k.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(()=>y.value.length,($,H)=>{const q=H??0;if(E){E=!1;return}k.value===S(q)&&!Z.value?k.value=S($):k.value>S($)&&D(()=>{k.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,k.value=S(y.value.length)}),Se(()=>[n.messages.length,M.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 N(){T=!0,Z.value=!1,W.value=0,I("smooth")}const Q=G(()=>!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&&(k.value>0&&D(()=>{k.value=Math.max(0,k.value-XT)}),k.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",jT,[!e.connected&&e.messages.length>0?(m(),v("div",zT,[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"))},"立即重试")])):U("",!0),h("div",{ref_key:"listRef",ref:o,class:"message-list"},[b.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,HT)):U("",!0)],512)):U("",!0),(m(!0),v(ne,null,Ce(w.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(ne,{key:q.key},[q.kind==="day-divider"?(m(),v("div",WT,[h("span",null,C(q.dividerText),1)])):q.kind==="turn-divider"?(m(),v("div",qT)):(m(),De(PT,{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",VT,[...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)])])):U("",!0)],512),X(UT,{messages:e.messages,host:o.value,revision:k.value,"reveal-message":B},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:N},[X(ce,{name:"chevron-down",size:18}),W.value>0?(m(),v("span",ZT,C(W.value>99?"99+":W.value),1)):U("",!0)],10,KT)):U("",!0)]),_:1})]))}}),eE=Te(QT,[["__scopeId","data-v-af6b9f2e"]]),tE={class:"stats-head"},nE={class:"stats-body"},sE={class:"stats-section"},oE={class:"stats-label-row"},rE={class:"stats-value mono"},iE=["aria-valuenow","aria-label"],aE={key:0,class:"stats-section"},lE={class:"stats-label-row"},uE={class:"stats-value mono"},cE={class:"stats-section"},dE={class:"stats-label-row"},fE={class:"stats-value mono"},hE={class:"stats-grid"},pE={class:"stats-cell-label"},gE={class:"stats-cell-value mono"},mE={key:1,class:"stats-section"},vE=["title"],yE={class:"model-tokens mono"},bE={class:"model-dims mono"},kE={key:1,class:"stats-empty"},wE=Ie({__name:"SessionStatsPanel",props:{status:{},fetchUsage:{type:Function},fetchContext:{type:Function}},emits:["close"],setup(e,{emit:t}){const n=e,s=t,o=O(null);et(()=>{n.fetchUsage(),n.fetchContext()});function r(w){const b=o.value;b&&!b.contains(w.target)&&s("close")}function i(w){w.key==="Escape"&&s("close")}et(()=>{document.addEventListener("pointerdown",r),window.addEventListener("keydown",i)}),st(()=>{document.removeEventListener("pointerdown",r),window.removeEventListener("keydown",i)});function a(w){return w?w.inputOther+w.output+w.inputCacheRead+w.inputCacheCreation:0}function l(w){return typeof w!="number"?"-":w>=1e6?`${(w/1e6).toFixed(1)}M`:w>=1e3?`${(w/1e3).toFixed(1)}k`:String(w)}function u(w){return typeof w=="number"?w.toLocaleString():"-"}const c=G(()=>{const w=n.status.contextUsage;if(typeof w=="number"&&Number.isFinite(w)){const B=w>1?w:w*100;return Math.max(0,Math.min(B,100))}const b=n.status.contextTokens??0,_=n.status.maxContextTokens??0;return _<=0?0:Math.max(0,Math.min(b/_*100,100))}),d=G(()=>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=G(()=>{var w;return(w=n.status.usage)==null?void 0:w.total}),p=G(()=>{var w;return(w=n.status.usage)==null?void 0:w.currentTurn}),g=G(()=>a(f.value)),y=G(()=>{var b;const w=(b=n.status.usage)==null?void 0:b.byModel;return w?Object.entries(w).map(([_,B])=>({model:_,tokens:a(B),input:B.inputOther,output:B.output,cacheRead:B.inputCacheRead,cacheCreation:B.inputCacheCreation})):[]}),S=G(()=>g.value>0||y.value.length>0||a(p.value)>0),k=G(()=>{var w,b,_,B;return[{key:"input",label:"输入",value:(w=f.value)==null?void 0:w.inputOther},{key:"output",label:"输出",value:(b=f.value)==null?void 0:b.output},{key:"cacheRead",label:"缓存读",value:(_=f.value)==null?void 0:_.inputCacheRead},{key:"cacheCreation",label:"缓存写",value:(B=f.value)==null?void 0:B.inputCacheCreation}]});return(w,b)=>(m(),v("div",{ref_key:"rootRef",ref:o,class:"stats-panel",role:"dialog","aria-label":"会话统计"},[h("div",tE,[b[1]||(b[1]=h("span",{class:"stats-title"},"会话统计",-1)),h("button",{class:"stats-close","aria-label":"关闭统计面板",onClick:b[0]||(b[0]=_=>s("close"))},[X(ce,{name:"x",size:14})])]),h("div",nE,[h("div",sE,[h("div",oE,[b[2]||(b[2]=h("span",{class:"stats-label"},"上下文水位",-1)),h("span",rE,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,iE)]),S.value?(m(),v(ne,{key:0},[a(p.value)>0?(m(),v("div",aE,[h("div",lE,[b[3]||(b[3]=h("span",{class:"stats-label"},"当前回合",-1)),h("span",uE,C(l(a(p.value)))+" tokens",1)])])):U("",!0),h("div",cE,[h("div",dE,[b[4]||(b[4]=h("span",{class:"stats-label"},"本会话累计",-1)),h("span",fE,C(l(g.value))+" tokens",1)]),h("div",hE,[(m(!0),v(ne,null,Ce(k.value,_=>(m(),v("div",{key:_.key,class:"stats-cell"},[h("span",pE,C(_.label),1),h("span",gE,C(u(_.value)),1)]))),128))])]),y.value.length>0?(m(),v("div",mE,[b[5]||(b[5]=h("div",{class:"stats-label"},"按模型",-1)),(m(!0),v(ne,null,Ce(y.value,_=>(m(),v("div",{key:_.model,class:"model-row"},[h("span",{class:"model-name",title:_.model},C(_.model),9,vE),h("span",yE,C(u(_.tokens)),1),h("span",bE," 入 "+C(u(_.input))+" · 出 "+C(u(_.output))+" · 缓存 "+C(u(_.cacheRead+_.cacheCreation)),1)]))),128))])):U("",!0)],64)):(m(),v("div",kE,"暂无用量数据"))])],512))}}),SE=Te(wE,[["__scopeId","data-v-631485c2"]]),_E={class:"conversation"},$E={key:1,class:"stats-anchor"},CE={class:"chat-stage"},xE={class:"chat-column"},IE={class:"composer-dock"},TE=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:y,appendSystemMessage:S,abort:k,resolveApproval:w,exportSession:b,fetchSnapshot:_,switchModel:B,switchThinking:D,switchPermission:E,goal:M,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 te=O(null),I=O(!1),A=O(!1),V=O("status"),ie=G(()=>{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=G(()=>{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=G(()=>{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=G(()=>i.value.length===0&&!d.value);function ae(P){var z;(z=te.value)==null||z.insertText(P)}function pe(P,z){return te.value?(te.value.insertDraft(P,z),!0):!1}t({insertDraft:pe});async function oe(){window.confirm("取消目标会让它进入已结束态,确定继续?")&&await W()}function ge(){wr("goal")}function $e(P){_(),V.value=P,A.value=!0}function Ne(){var P;return((P=te.value)==null?void 0:P.openModelPicker())??!1}const{onCommand:Ue}=lh({sendCommand:g,clearMessages:y,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=O(!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",_E,[he.value?U("",!0):(m(),De(xw,{key:0,title:me.value,busy:F(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=>F(u)&&F(b)(F(u))),onFork:x,onClear:F(y),onControls:z[2]||(z[2]=ee=>F(wr)("control")),onAgents:z[3]||(z[3]=ee=>F(wr)("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",$E,[X(SE,{status:F(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"])])):U("",!0),h("div",CE,[h("div",xE,[X(eE,{messages:F(i),busy:F(d),"work-dir":F(c),"session-id":F(u)??"",connected:F(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",IE,[X(Sb,{approvals:F(a),onResolve:F(w)},null,8,["approvals","onResolve"]),X(kh,{ref_key:"composerRef",ref:te,busy:F(d),status:F(l),"session-id":F(u),models:F(f),"work-dir":F(c)||"",messages:F(i),"connection-status":F(r),goal:F(M),onSend:F(p),onAbort:F(k),onCommand:F(Ue),onSwitchModel:F(B),onSwitchThinking:F(D),onSwitchPermission:F(E),onGoalPause:F(T),onGoalResume:F(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"])])])]),A.value?(m(),De(wh,{key:2,mode:V.value,status:F(l),"session-id":F(u),"work-dir":F(c),onClose:z[7]||(z[7]=ee=>A.value=!1)},null,8,["mode","status","session-id","work-dir"])):U("",!0)]))}}),EE=Te(TE,[["__scopeId","data-v-44a6943d"]]),AE=new Set(["png","jpg","jpeg","gif","webp","svg","avif","ico"]),ME=new Set(["mp3","wav","m4a","ogg"]),RE=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 PE(e){const t=Wp(e);return AE.has(t)?"image":ME.has(t)?"audio":RE.has(t)?"markdown":t==="pdf"?"pdf":"source"}const LE={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":LE[Wp(e)]??"text"}const DE={key:0,class:"file-viewer"},NE={class:"fv-toolbar"},OE=["title","aria-label"],GE={class:"fv-path-text"},BE={class:"fv-modes",role:"tablist","aria-label":"显示模式"},FE=["aria-selected","title","onClick"],UE={class:"fv-body"},jE={key:0,class:"fv-status"},zE={key:1,class:"fv-status fv-error"},HE={class:"fv-error-name"},WE={class:"fv-error-msg"},qE={key:0,class:"fv-scroll"},VE={key:1,class:"fv-status"},KE={key:0,class:"fv-media"},ZE=["src","alt"],YE={key:1,class:"fv-media"},XE=["src"],JE={key:2,class:"fv-media fv-pdf"},QE=["src","title"],eA={key:3,class:"fv-scroll fv-markdown"},tA={key:4,class:"fv-scroll"},nA={key:4,class:"fv-scroll"},sA={key:0,class:"fv-note"},oA={key:1,class:"fv-empty"},Sa="/api/v1",rA=Ie({__name:"FileViewer",props:{client:{}},setup(e){const t=e,n=[{id:"source",label:"源码"},{id:"preview",label:"预览"},{id:"diff",label:"Diff"}],s=G(()=>eb()),o=G(()=>s.value?Hy(s.value.viewerState,s.value.initialDisplayMode):"source"),r=G(()=>s.value?PE(s.value.filePath):"source"),i=O(0),a=G(()=>{if(!s.value)return"";const T=i.value>0?`&t=${i.value}`:"";return`${Sa}/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 te,I;const Z=(te=t.client)==null?void 0:te.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 A=Z.files.find(V=>(V.displayPath??V.path)===j);if(A)return A.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 te;const Z=[],W=I=>{I&&I!==T&&!Z.includes(I)&&Z.push(I)};W(d(T)),Z.push(T);const j=((te=t.client)==null?void 0:te.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 te=((Z=t.client)==null?void 0:Z.currentSessionId.value)??((W=t.client)==null?void 0:W.sessionId.value),I=new URLSearchParams({path:j});te&&I.set("sessionId",te);const A=await fetch(`${Sa}/git/diff?${I.toString()}`);if(!A.ok){u.set(T.filePath,{status:"error",message:await c(A)});return}const V=await A.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(`${Sa}/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 y=G(()=>{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=G(()=>s.value!==void 0&&y.value===void 0),k=G(()=>{var T;return((T=y.value)==null?void 0:T.status)==="error"?y.value:null}),w=G(()=>{const T=s.value?l.get(s.value.filePath):void 0;return(T==null?void 0:T.status)==="ok"?T.content:""}),b=G(()=>{const T=s.value?l.get(s.value.filePath):void 0;return(T==null?void 0:T.status)==="ok"?T.truncated:!1}),_=G(()=>{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 B(T){var j,te,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:((te=Z.viewerState)==null?void 0:te.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=O(!1);function M(){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",DE,[h("div",NE,[h("button",{class:"fv-path",title:E.value?"已复制路径":`复制路径:${s.value.filePath}`,"aria-label":`文件路径 ${s.value.filePath}`,onClick:M},[X(ce,{name:"copy",size:12,class:"fv-path-icon"}),h("span",GE,C(s.value.filePath),1)],8,OE),h("div",BE,[(m(),v(ne,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=>B(W.id)},C(W.label),11,FE)),64))]),h("button",{class:"fv-icon-btn",title:"刷新","aria-label":"刷新",onClick:D},[X(ce,{name:"refresh",size:14})])]),h("div",UE,[S.value?(m(),v("div",jE,[...Z[0]||(Z[0]=[h("span",{class:"fv-spinner","aria-hidden":"true"},null,-1),h("span",null,"加载中…",-1)])])):k.value?(m(),v("div",zE,[h("p",HE,C(s.value.label),1),h("p",WE,C(k.value.message),1),h("button",{class:"fv-retry",onClick:D},"重试")])):o.value==="diff"?(m(),v(ne,{key:2},[_.value.length>0?(m(),v("div",qE,[X(wu,{lines:_.value},null,8,["lines"])])):(m(),v("div",VE,"该文件没有未提交的改动。"))],64)):o.value==="preview"?(m(),v(ne,{key:3},[r.value==="image"?(m(),v("div",KE,[h("img",{src:a.value,alt:s.value.label},null,8,ZE)])):r.value==="audio"?(m(),v("div",YE,[h("audio",{class:"fv-audio",controls:"",src:a.value},null,8,XE)])):r.value==="pdf"?(m(),v("div",JE,[h("iframe",{class:"fv-pdf-frame",src:a.value,title:s.value.label},null,8,QE)])):r.value==="markdown"?(m(),v("div",eA,[X(jp,{content:w.value},null,8,["content"])])):(m(),v("div",tA,[Z[1]||(Z[1]=h("p",{class:"fv-note"},"该类型暂不支持预览,显示源码内容。",-1)),X(yl,{code:w.value,lang:F(Ed)(s.value.filePath)},null,8,["code","lang"])]))],64)):(m(),v("div",nA,[b.value?(m(),v("p",sA,"文件较大,仅显示前 256KB。")):U("",!0),X(yl,{code:w.value,lang:F(Ed)(s.value.filePath)},null,8,["code","lang"])]))])])):(m(),v("div",oA,"从工具卡片、文件浏览或消息中选择文件打开"))}}),iA=Te(rA,[["__scopeId","data-v-1f5a4490"]]),aA={class:"panel-head-row"},lA=["aria-expanded"],uA={class:"head-icon"},cA=["title"],dA={key:1,class:"head-hint"},fA={class:"head-tail"},hA={key:0,class:"head-count"},pA={class:"panel-body"},gA={key:0,class:"git-files"},mA=["title","onClick"],vA={class:"git-file-name"},yA={key:0,class:"git-file-dir"},bA={class:"git-file-base"},kA={key:0,class:"git-file-stat"},wA={key:0,class:"add"},SA={key:1,class:"del"},_A={key:2,class:"diff-body"},$A={key:3,class:"panel-empty"},CA={key:1,class:"diff-empty"},xA=8,Ad="scream-panel-git-open",IA=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=O(!1),a=O(!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=G(()=>{var g;const p=((g=n.gitStatus)==null?void 0:g.files)??[];return i.value?p:p.slice(0,xA)}),d=G(()=>{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=G(()=>{var S,k;const p=((S=n.gitStatus)==null?void 0:S.ahead)??0,g=((k=n.gitStatus)==null?void 0:k.behind)??0;if(!p&&!g)return"";const y=[];return p&&y.push(`↑${p}`),g&&y.push(`↓${g}`),` · ${y.join(" ")}`});return(p,g)=>{var y;return m(),v("section",{class:ue(["panel-section","git-panel",{"is-open":a.value}])},[h("div",aA,[h("button",{class:"panel-head","aria-expanded":a.value,onClick:l},[h("span",uA,[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,cA)):(m(),v("span",dA,"状态不可用")),h("span",fA,[e.gitStatus?(m(),v("span",hA,C(e.gitStatus.changed),1)):U("",!0),X(ce,{class:ue(["chevron",{rotated:a.value}]),name:"chevron-down",size:14},null,8,["class"])])],8,lA),h("button",{class:"icon-btn",title:"刷新","aria-label":"刷新 Git 状态",onClick:u},[X(ce,{name:"refresh",size:14})])]),Ze(h("div",pA,[e.gitStatus?(m(),v(ne,{key:0},[c.value.length?(m(),v("ul",gA,[(m(!0),v(ne,null,Ce(c.value,S=>(m(),v("li",{key:S.path},[h("button",{class:"git-file",title:`查看 ${S.displayPath??S.path} 的 diff`,onClick:k=>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",vA,[F($r)(S.displayPath??S.path).dir?(m(),v("span",yA,C(F($r)(S.displayPath??S.path).dir),1)):U("",!0),h("span",bA,C(F($r)(S.displayPath??S.path).base),1)]),S.adds!==void 0||S.dels!==void 0?(m(),v("span",kA,[S.adds?(m(),v("span",wA,"+"+C(S.adds),1)):U("",!0),S.dels?(m(),v("span",SA,"−"+C(S.dels),1)):U("",!0)])):U("",!0)],8,mA)]))),128))])):U("",!0),d.value?(m(),v("button",{key:1,class:"git-more",onClick:g[0]||(g[0]=S=>i.value=!i.value)},C(i.value?"收起列表":`显示全部 ${((y=e.gitStatus.files)==null?void 0:y.length)??0} 个文件`),1)):U("",!0),e.gitStatus.diffStat?(m(),v("pre",_A,C(e.gitStatus.diffStat),1)):c.value.length?U("",!0):(m(),v("div",$A,[X(ce,{name:"check",size:18}),g[2]||(g[2]=h("span",null,"工作区干净,没有变更",-1))]))],64)):(m(),v("div",CA,"读取 Git 状态失败,点右上角刷新重试。"))],512),[[Br,a.value]])],2)}}}),qp=Te(IA,[["__scopeId","data-v-39f0d843"]]),TA={class:"goal-panel panel-section"},EA={class:"section-heading"},AA={class:"head-icon"},MA=["title"],RA={key:0,class:"head-tail"},PA={class:"panel-body"},LA={key:0,class:"empty-state"},DA=["disabled"],NA={class:"refine-row"},OA=["disabled"],GA={key:0},BA=["disabled"],FA={class:"budget-grid"},UA=["disabled"],jA=["disabled"],zA={class:"time-budget"},HA=["disabled"],WA=["disabled"],qA=["disabled"],VA={key:0,class:"goal-summary"},KA={class:"objective"},ZA={class:"criterion"},YA={key:0,class:"reason"},XA={class:"goal-metrics"},JA={class:"goal-metric"},QA={key:0,class:"bar"},eM={class:"goal-metric"},tM={key:0,class:"bar"},nM={class:"goal-metric"},sM={key:0,class:"bar"},oM={key:1,class:"budget-warning"},rM={key:2,class:"notes"},iM={class:"panel-actions"},aM=["disabled"],lM=["disabled"],uM=["disabled"],cM=["disabled"],dM=["disabled"],fM={class:"budget-grid"},hM=["disabled"],pM=["disabled"],gM={class:"time-budget"},mM=["disabled"],vM=["disabled"],yM={class:"edit-actions"},bM=["disabled"],kM=["disabled"],wM={key:3,class:"form-error"},SM={key:4,class:"pending-copy"},_M=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=O(""),s=O(""),o=O(""),r=O(""),i=O(""),a=O("minutes"),l=O(!1),u=O(null),c=O(!1),d=G(()=>t.connectionStatus==="connected"),f=G(()=>!t.sessionId||!d.value||t.archived||t.pending),p=G(()=>f.value),g=G(()=>{var I;return{active:"进行中",paused:"已暂停",blocked:"受阻",complete:"已完成"}[((I=t.goal)==null?void 0:I.status)??"active"]}),y=G(()=>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,A)=>{l.value=!1,I!==A&&S()});function S(){n.value="",s.value="",o.value="",r.value="",i.value="",a.value="minutes",c.value=!1,u.value=null}function k(I,A){const V=I.trim();if(!V)return null;const ie=Number(V);if(!Number.isSafeInteger(ie)||ie<=0){u.value=`${A}必须是正整数。`;return}return ie}function w(){u.value=null;const I=k(o.value,"轮次预算");if(I===void 0)return null;const A=k(r.value,"Token 预算");if(A===void 0)return null;const V=k(i.value,"时间预算");if(V===void 0)return null;const ie=[];return I!==null&&ie.push({value:I,unit:"turns"}),A!==null&&ie.push({value:A,unit:"tokens"}),V!==null&&ie.push({value:V,unit:a.value}),ie}async function b(){const I=n.value.trim();if(!I){u.value="请先输入需要优化的目标描述。";return}u.value=null,c.value=!1;const A=await t.refineGoal(I);A!==null&&(n.value=A,c.value=!0)}async function _(){const I=n.value.trim();if(!I){u.value="目标内容不能为空。";return}const A=w();if(A===null)return;await t.createGoal({objective:I,completionCriterion:s.value.trim()||void 0,replace:!1,budgets:A})&&(c.value=!1)}function B(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),B(I.budget.wallClockBudgetMs),u.value=null,l.value=!0)}function E(I,A){return A==="hours"?I*36e5:A==="minutes"?I*6e4:A==="seconds"?I*1e3:I}async function M(){const I=t.goal;if(!I)return;const A=n.value.trim();if(!A){u.value="目标内容不能为空。";return}const V=w();if(V===null)return;const ie=k(o.value,"轮次预算"),me=k(r.value,"Token 预算"),_e=k(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=A===I.objective?void 0:A;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 A=Math.floor(I/1e3);if(A<60)return`${A} 秒`;const V=Math.floor(A/3600),ie=Math.floor(A%3600/60);return V>0?`${V} 小时 ${ie} 分钟`:`${ie} 分钟`}function j(I,A){return A===null||A<=0?0:Math.min(100,Math.round(I/A*100))}function te(I){return new Date(I).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}return(I,A)=>(m(),v("section",TA,[h("div",EA,[h("span",AA,[X(ce,{name:"target",size:14})]),A[15]||(A[15]=h("span",{class:"head-title"},"Goal 管理",-1)),h("span",{class:"head-hint",title:y.value},C(y.value),9,MA),e.goal?(m(),v("span",RA,[h("span",{class:ue(["status-pill",`is-${e.goal.status}`])},C(g.value),3)])):U("",!0)]),h("div",PA,[e.sessionId?e.goal?(m(),v(ne,{key:2},[l.value?(m(),v("form",{key:1,class:"goal-form edit-form",onSubmit:tt(M,["prevent"])},[h("label",null,[A[33]||(A[33]=h("span",null,"目标内容",-1)),Ze(h("textarea",{"onUpdate:modelValue":A[9]||(A[9]=V=>n.value=V),rows:"3",maxlength:"4000",disabled:f.value||e.busy},null,8,dM),[[it,n.value]])]),A[38]||(A[38]=h("div",{class:"budget-title"},[Ae("更新预算 "),h("small",null,"仅提交发生变化的预算")],-1)),h("div",fM,[h("label",null,[A[34]||(A[34]=h("span",null,"轮次",-1)),Ze(h("input",{"onUpdate:modelValue":A[10]||(A[10]=V=>o.value=V),type:"number",min:"1",step:"1",placeholder:"不限",disabled:f.value||e.busy},null,8,hM),[[it,o.value]])]),h("label",null,[A[35]||(A[35]=h("span",null,"Token",-1)),Ze(h("input",{"onUpdate:modelValue":A[11]||(A[11]=V=>r.value=V),type:"number",min:"1",step:"1",placeholder:"不限",disabled:f.value||e.busy},null,8,pM),[[it,r.value]])])]),h("div",gM,[h("label",null,[A[36]||(A[36]=h("span",null,"时间",-1)),Ze(h("input",{"onUpdate:modelValue":A[12]||(A[12]=V=>i.value=V),type:"number",min:"1",step:"1",placeholder:"不限",disabled:f.value||e.busy},null,8,mM),[[it,i.value]])]),Ze(h("select",{"onUpdate:modelValue":A[13]||(A[13]=V=>a.value=V),"aria-label":"时间预算单位",disabled:f.value||e.busy},[...A[37]||(A[37]=[h("option",{value:"minutes"},"分钟",-1),h("option",{value:"hours"},"小时",-1),h("option",{value:"seconds"},"秒",-1),h("option",{value:"milliseconds"},"毫秒",-1)])],8,vM),[[lc,a.value]])]),h("div",yM,[h("button",{type:"button",class:"secondary",disabled:e.pending,onClick:A[14]||(A[14]=V=>l.value=!1)},"返回",8,bM),h("button",{class:"primary small",type:"submit",disabled:f.value||e.busy},"保存修改",8,kM)])],32)):(m(),v("div",VA,[h("div",KA,[A[26]||(A[26]=h("small",null,"目标",-1)),h("p",null,C(e.goal.objective),1)]),h("div",ZA,[A[27]||(A[27]=h("small",null,"完成标准",-1)),h("p",null,C(e.goal.completionCriterion??"未设置,由 Agent 根据目标判断完成。"),1)]),e.goal.terminalReason?(m(),v("div",YA,[A[28]||(A[28]=h("strong",null,"状态原因",-1)),h("span",null,C(e.goal.terminalReason),1)])):U("",!0),h("dl",XA,[h("div",JA,[A[29]||(A[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",QA,[h("i",{style:bt({width:`${j(e.goal.turnsUsed,e.goal.budget.turnBudget)}%`})},null,4)])):U("",!0)]),h("div",eM,[A[30]||(A[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",tM,[h("i",{style:bt({width:`${j(e.goal.tokensUsed,e.goal.budget.tokenBudget)}%`})},null,4)])):U("",!0)]),h("div",nM,[A[31]||(A[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",sM,[h("i",{style:bt({width:`${j(e.goal.wallClockMs,e.goal.budget.wallClockBudgetMs)}%`})},null,4)])):U("",!0)])]),e.goal.budget.overBudget?(m(),v("div",oM,"已达到或超过执行预算。")):U("",!0),e.goal.notes.length?(m(),v("details",rM,[h("summary",null,"工作记录("+C(e.goal.notes.length)+")",1),h("ol",null,[(m(!0),v(ne,null,Ce(e.goal.notes,V=>(m(),v("li",{key:`${V.time}-${V.content}`},[h("time",null,C(te(V.time)),1),h("span",null,C(V.content),1)]))),128))])])):U("",!0),h("div",iM,[e.goal.status!=="complete"?(m(),v("button",{key:0,class:"secondary",disabled:f.value||e.busy,onClick:D},[X(ce,{name:"edit",size:14}),A[32]||(A[32]=Ae("编辑",-1))],8,aM)):U("",!0),e.goal.status==="active"?(m(),v("button",{key:1,class:"secondary",disabled:f.value,onClick:A[6]||(A[6]=V=>T("pause"))},"暂停",8,lM)):U("",!0),e.goal.status==="paused"||e.goal.status==="blocked"?(m(),v("button",{key:2,class:"primary small",disabled:f.value||e.busy,onClick:A[7]||(A[7]=V=>T("resume"))},"继续",8,uM)):U("",!0),h("button",{class:"danger",disabled:f.value,onClick:A[8]||(A[8]=V=>T("cancel"))},"取消 Goal",8,cM)])]))],64)):(m(),v("form",{key:1,class:"goal-form",onSubmit:tt(_,["prevent"])},[h("label",null,[A[18]||(A[18]=h("span",null,"目标内容",-1)),Ze(h("textarea",{"onUpdate:modelValue":A[0]||(A[0]=V=>n.value=V),rows:"3",maxlength:"4000",placeholder:"描述希望 Agent 持续完成的目标",disabled:p.value},null,8,DA),[[it,n.value]])]),h("div",NA,[h("button",{type:"button",class:"secondary",disabled:p.value||!n.value.trim(),onClick:b},[X(ce,{name:"sparkles",size:15}),A[19]||(A[19]=Ae(" AI 优化 ",-1))],8,OA),c.value?(m(),v("small",GA,"已优化,请确认或继续编辑后再创建。")):U("",!0)]),h("label",null,[A[20]||(A[20]=h("span",null,[Ae("完成标准 "),h("small",null,"可选")],-1)),Ze(h("textarea",{"onUpdate:modelValue":A[1]||(A[1]=V=>s.value=V),rows:"2",placeholder:"例如:聚焦测试、类型检查与 Web 构建全部通过",disabled:p.value},null,8,BA),[[it,s.value]])]),A[25]||(A[25]=h("div",{class:"budget-title"},[Ae("执行预算 "),h("small",null,"留空表示不限制")],-1)),h("div",FA,[h("label",null,[A[21]||(A[21]=h("span",null,"轮次",-1)),Ze(h("input",{"onUpdate:modelValue":A[2]||(A[2]=V=>o.value=V),type:"number",min:"1",step:"1",placeholder:"不限",disabled:p.value},null,8,UA),[[it,o.value]])]),h("label",null,[A[22]||(A[22]=h("span",null,"Token",-1)),Ze(h("input",{"onUpdate:modelValue":A[3]||(A[3]=V=>r.value=V),type:"number",min:"1",step:"1",placeholder:"不限",disabled:p.value},null,8,jA),[[it,r.value]])])]),h("div",zA,[h("label",null,[A[23]||(A[23]=h("span",null,"时间",-1)),Ze(h("input",{"onUpdate:modelValue":A[4]||(A[4]=V=>i.value=V),type:"number",min:"1",step:"1",placeholder:"不限",disabled:p.value},null,8,HA),[[it,i.value]])]),Ze(h("select",{"onUpdate:modelValue":A[5]||(A[5]=V=>a.value=V),"aria-label":"时间预算单位",disabled:p.value},[...A[24]||(A[24]=[h("option",{value:"minutes"},"分钟",-1),h("option",{value:"hours"},"小时",-1),h("option",{value:"seconds"},"秒",-1),h("option",{value:"milliseconds"},"毫秒",-1)])],8,WA),[[lc,a.value]])]),h("button",{class:"primary",type:"submit",disabled:p.value||!n.value.trim()},C(e.pending?"正在创建…":"创建并开始执行"),9,qA)],32)):(m(),v("div",LA,[X(ce,{name:"target",size:18}),A[16]||(A[16]=h("span",null,"暂无会话",-1)),A[17]||(A[17]=h("small",null,"选择或新建会话后即可配置目标。",-1))])),u.value||e.error?(m(),v("p",wM,C(u.value??e.error),1)):e.pending?(m(),v("p",SM,"请求处理中,状态将在核心事件到达后同步。")):U("",!0)])]))}}),Vp=Te(_M,[["__scopeId","data-v-cf530861"]]),$M={class:"nsm-body"},CM={class:"nsm-section"},xM=["placeholder"],IM={key:0,class:"nsm-error"},TM={key:1,class:"nsm-recents"},EM=["title","onClick"],AM={class:"nsm-section"},MM={class:"nsm-models",role:"radiogroup","aria-label":"选择模型"},RM=["aria-checked"],PM=["aria-checked","onClick"],LM={class:"nsm-model-name"},DM={class:"nsm-model-alias"},NM=Ie({__name:"NewSessionModal",props:{open:{type:Boolean},models:{},recentWorkDirs:{},defaultDir:{},currentModel:{}},emits:["close","confirm"],setup(e,{emit:t}){const n=e,s=t,o=O(n.defaultDir),r=O(n.currentModel||null);Se(()=>n.open,c=>{c&&(o.value=n.defaultDir,r.value=n.currentModel||null)},{immediate:!0});const i=G(()=>{const c=o.value.trim();return c?c.startsWith("/"):!0}),a=G(()=>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",$M,[h("section",CM,[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,xM),[[it,o.value]]),a.value?(m(),v("div",IM,C(a.value),1)):U("",!0),e.recentWorkDirs.length?(m(),v("div",TM,[(m(!0),v(ne,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,EM))),128))])):U("",!0)]),h("section",AM,[d[6]||(d[6]=h("div",{class:"nsm-label"},"模型",-1)),h("div",MM,[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,RM),(m(!0),v(ne,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",LM,C(f.displayName||f.model),1),h("span",DM,C(f.provider)+"/"+C(f.model),1)],10,PM))),128))])])])]),_:1},8,["open"]))}}),OM=Te(NM,[["__scopeId","data-v-7bb09c54"]]),GM={class:"panel-section like-section"},BM={class:"section-heading"},FM={class:"head-icon"},UM={class:"panel-body"},jM={class:"kv-rows"},zM={class:"dialog"},HM=["onUpdate:modelValue","placeholder"],WM={key:0,class:"dialog-error"},qM={class:"dialog-actions"},VM=["disabled"],KM=Ie({__name:"LikePanel",props:{like:{},updateLike:{type:Function}},setup(e){const t=e,n=O(!1),s=O(!1),o=O(""),r=O({}),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",GM,[h("div",BM,[h("span",FM,[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",UM,[h("dl",jM,[(m(),v(ne,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",zM,[c[4]||(c[4]=h("div",{class:"dialog-title"},"编辑用户偏好",-1)),(m(),v(ne,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,HM),[[it,r.value[d.key]]])])),64)),o.value?(m(),v("div",WM,C(o.value),1)):U("",!0),h("div",qM,[h("button",{onClick:c[0]||(c[0]=d=>n.value=!1)},"取消"),h("button",{disabled:s.value,onClick:l},C(s.value?"保存中…":"确认"),9,VM)])])])):U("",!0)]))}}),Kp=Te(KM,[["__scopeId","data-v-2eac026c"]]),ZM=["aria-expanded"],YM={class:"head-icon"},XM={class:"head-hint"},JM={class:"head-tail"},QM=["title"],eR={class:"panel-body"},tR={class:"stat-grid"},nR={class:"stat"},sR={class:"stat"},oR=["title"],rR={key:1,class:"faint"},iR={class:"stat wide"},aR={class:"mono"},Md="scream-panel-runstatus-open",lR=Ie({__name:"RunStatusPanel",props:{status:{},busy:{type:Boolean,default:!1},connectionStatus:{}},setup(e){const t=e,n=O(!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=G(()=>{const a=t.status.contextUsage;return a===void 0?null:Math.round((a>1?a/100:a)*100)}),r=G(()=>{var a,l;return`Tokens: ${((a=t.status.contextTokens)==null?void 0:a.toLocaleString())??"-"} / ${((l=t.status.maxContextTokens)==null?void 0:l.toLocaleString())??"-"}`}),i=G(()=>({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",YM,[X(ce,{name:"activity",size:14})]),l[0]||(l[0]=h("span",{class:"head-title"},"运行状态",-1)),h("span",XM,C(e.busy?"正在处理会话":"已就绪,等待任务"),1),h("span",JM,[h("span",{class:ue(["head-dot",{busy:e.busy}]),title:e.busy?"Agent 正在处理":"空闲"},null,10,QM),X(ce,{class:ue(["chevron",{rotated:n.value}]),name:"chevron-down",size:14},null,8,["class"])])],8,ZM),Ze(h("div",eR,[h("dl",tR,[h("div",nR,[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",sR,[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,oR)):(m(),v("dd",rR,"未知"))]),h("div",iR,[l[3]||(l[3]=h("dt",null,"Token(输入 / 上限)",-1)),h("dd",aR,C(((u=e.status.contextTokens)==null?void 0:u.toLocaleString())??"-")+" / "+C(((c=e.status.maxContextTokens)==null?void 0:c.toLocaleString())??"-"),1)])])],512),[[Br,n.value]])],2)}}}),Zp=Te(lR,[["__scopeId","data-v-59b0c4e7"]]),uR={class:"todo-panel panel-section"},cR={class:"section-heading"},dR={class:"head-icon"},fR={class:"head-hint"},hR={class:"head-tail"},pR={class:"head-count"},gR={key:0,class:"panel-body"},mR={class:"empty-state"},vR={key:1,class:"panel-body"},yR={class:"progress-row"},bR={class:"bar","aria-hidden":"true"},kR={class:"progress-value"},wR=["title"],SR={class:"todo-title"},_R=Ie({__name:"TodoPanel",props:{todos:{}},setup(e){const t=e,n=G(()=>iy(t.todos)),s=G(()=>t.todos.filter(u=>u.status==="done").length),o=G(()=>t.todos.filter(u=>u.status==="in_progress").length),r=G(()=>t.todos.filter(u=>u.status==="pending").length),i=G(()=>t.todos.length?Math.round(s.value/t.todos.length*100):0),a=G(()=>{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",uR,[h("div",cR,[h("span",dR,[X(ce,{name:"clipboard",size:14})]),c[0]||(c[0]=h("span",{class:"head-title"},"核心 Todo",-1)),h("span",fR,C(a.value),1),h("span",hR,[h("span",pR,C(s.value)+"/"+C(e.todos.length),1)])]),e.todos.length===0?(m(),v("div",gR,[h("div",mR,[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",vR,[h("div",yR,[h("i",bR,[h("i",{style:bt({width:`${i.value}%`})},null,4)]),h("span",kR,C(i.value)+"%",1)]),(m(!0),v(ne,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(ne,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,wR),h("span",SR,C(p.title),1),h("small",null,C(l[p.status].label),1)],2))),128))])]))),128))]))]))}}),Yp=Te(_R,[["__scopeId","data-v-6a025f22"]]),$R={class:"detail-view"},CR={class:"git-diff-head"},xR=["title"],IR={class:"git-diff-tools"},TR={key:0,class:"git-diff-stat"},ER={key:0,class:"add"},AR={key:1,class:"del"},MR={key:0,class:"git-diff-body"},RR={key:1,class:"git-diff-empty"},PR=Ie({__name:"SessionDetailView",props:{client:{}},setup(e){const t=e,n=O(null),s=O(null);let o=0;async function r(E){var W,j,te;const M=++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(M!==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(M!==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;(te=s.value)==null||te.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:y,gitStatus:S,refineGoal:k,createGoal:w,updateGoal:b,pauseGoal:_,resumeGoal:B,cancelGoal:D}=t.client;return(E,M)=>(m(),v("div",$R,[X(Zp,{status:F(a),busy:F(u),"connection-status":F(i)},null,8,["status","busy","connection-status"]),X(qp,{"git-status":F(S),onRefresh:M[0]||(M[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",CR,[h("span",{class:"git-diff-title",title:n.value.path},C(n.value.loading?"加载中…":n.value.display),9,xR),h("span",IR,[!n.value.loading&&(n.value.adds||n.value.dels)?(m(),v("span",TR,[n.value.adds?(m(),v("span",ER,"+"+C(n.value.adds),1)):U("",!0),n.value.dels?(m(),v("span",AR,"−"+C(n.value.dels),1)):U("",!0)])):U("",!0),h("button",{class:"git-diff-close",title:"关闭 diff","aria-label":"关闭 diff",onClick:M[1]||(M[1]=T=>n.value=null)},"✕")])]),n.value.lines.length?(m(),v("div",MR,[X(wu,{lines:n.value.lines},null,8,["lines"])])):n.value.loading?U("",!0):(m(),v("p",RR,"该文件无差异内容(可能是二进制文件或已被忽略)。"))],512)):U("",!0),X(Yp,{todos:F(f)},null,8,["todos"]),X(Kp,{like:F(y),"update-like":t.client.updateLike},null,8,["like","update-like"]),X(Vp,{goal:F(d),"session-id":F(l),"connection-status":F(i),busy:F(u),archived:F(c),pending:F(p),error:F(g),"refine-goal":F(k),"create-goal":F(w),"update-goal":F(b),"pause-goal":F(_),"resume-goal":F(B),"cancel-goal":F(D)},null,8,["goal","session-id","connection-status","busy","archived","pending","error","refine-goal","create-goal","update-goal","pause-goal","resume-goal","cancel-goal"])]))}}),LR=Te(PR,[["__scopeId","data-v-f2bcdf8d"]]),DR={class:"session-controls","aria-label":"会话控制"},NR={class:"controls-head"},OR={class:"controls-heading"},GR={class:"controls-icon"},BR=["disabled"],FR={class:"controls-body"},UR={class:"control-group","aria-label":"计划模式"},jR={class:"group-label"},zR={key:0,class:"mode-state"},HR={class:"segmented",role:"group","aria-label":"计划模式"},WR=["aria-pressed","disabled"],qR=["aria-pressed","disabled"],VR=["aria-pressed","disabled"],KR=["disabled"],ZR={class:"control-group","aria-label":"并行与递归模式"},YR={class:"switch-row"},XR=["checked","disabled"],JR={class:"switch-row"},QR=["checked","disabled"],e2={key:0,class:"depth-field"},t2=["disabled"],n2=["disabled"],s2={class:"control-group control-group--actions","aria-label":"会话操作"},o2=["disabled"],r2=["disabled"],i2=Ie({__name:"SessionControlsPanel",props:{client:{}},setup(e){const t=e,{showToast:n}=Js(),s=O(!1),o=O("0");let r=0;const i=G(()=>t.client.sessionId.value!==null),a=G(()=>t.client.isArchived.value),l=G(()=>t.client.isBusy.value),u=G(()=>i.value?a.value?"当前会话已归档,仅可查看记录":t.client.connectionStatus.value!=="connected"?"连接恢复后可调整控制项":l.value?"当前回合结束后可调整控制项":"":"打开会话后可调整控制项"),c=G(()=>!!u.value||s.value),d=G(()=>t.client.status.value.planMode===!0),f=G(()=>{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,M){if(c.value)return;const T=r;s.value=!0;try{await E()&&T===r&&await(M==null?void 0:M())}finally{if(T!==r)return;await p(),s.value=!1}}function y(E,M){g(()=>t.client.switchPlanMode(E,M))}function S(E){const M=E.currentTarget.checked;g(()=>t.client.switchWolfpack(M))}function k(){const E=o.value.trim();return/^\d+$/.test(E)?Number(E):(n("RLM 深度需为 0 或正整数","warning"),null)}function w(E){const M=E.currentTarget.checked;g(()=>t.client.switchRlm(M))}function b(){const E=k();E!==null&&g(()=>t.client.switchRlm(!0,E))}function _(){g(()=>t.client.clearPlan())}function B(){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,M)=>(m(),v("section",DR,[h("header",NR,[h("div",OR,[h("span",GR,[X(ce,{name:"wrench",size:16})]),h("div",null,[M[4]||(M[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,BR)]),h("div",FR,[h("section",UR,[h("div",jR,[M[5]||(M[5]=h("span",null,"计划",-1)),d.value?(m(),v("span",zR,C(f.value==="fusion"?"融合":"标准"),1)):U("",!0)]),h("div",HR,[h("button",{class:ue({active:!d.value}),"aria-pressed":!d.value,disabled:c.value,onClick:M[0]||(M[0]=T=>y(!1))},"关闭",10,WR),h("button",{class:ue({active:d.value&&f.value==="normal"}),"aria-pressed":d.value&&f.value==="normal",disabled:c.value,onClick:M[1]||(M[1]=T=>y(!0,"normal"))},"计划",10,qR),h("button",{class:ue({active:d.value&&f.value==="fusion"}),"aria-pressed":d.value&&f.value==="fusion",disabled:c.value,onClick:M[2]||(M[2]=T=>y(!0,"fusion"))},"融合",10,VR)]),t.client.sessionPlan.value?(m(),v("button",{key:0,class:"text-action",disabled:c.value,onClick:_},[X(ce,{name:"broom",size:14}),M[6]||(M[6]=Ae(" 清除计划 ",-1))],8,KR)):U("",!0)]),h("section",ZR,[h("label",YR,[M[7]||(M[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,XR),M[8]||(M[8]=h("i",{"aria-hidden":"true"},null,-1))]),M[12]||(M[12]=h("div",{class:"rule"},null,-1)),h("label",JR,[M[9]||(M[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:w},null,40,QR),M[10]||(M[10]=h("i",{"aria-hidden":"true"},null,-1))]),t.client.status.value.rlmEnabled?(m(),v("label",e2,[M[11]||(M[11]=h("span",null,"最大深度",-1)),h("div",null,[Ze(h("input",{"onUpdate:modelValue":M[3]||(M[3]=T=>o.value=T),inputmode:"numeric",min:"0",type:"number",disabled:c.value,"aria-label":"RLM 最大深度"},null,8,t2),[[it,o.value]]),h("button",{title:"保存 RLM 最大深度","aria-label":"保存 RLM 最大深度",disabled:c.value,onClick:b},[X(ce,{name:"check",size:14})],8,n2)])])):U("",!0)]),h("section",s2,[h("button",{class:"command-action",disabled:c.value,onClick:D},[X(ce,{name:"compact",size:16}),M[13]||(M[13]=h("span",null,"压缩上下文",-1))],8,o2),h("button",{class:"command-action danger",disabled:c.value,onClick:B},[X(ce,{name:"broom",size:16}),M[14]||(M[14]=h("span",null,"撤销上一轮",-1))],8,r2)])])]))}}),a2=Te(i2,[["__scopeId","data-v-bca142e2"]]),l2={class:"subagents-panel","aria-label":"协作代理"},u2={class:"agents-head"},c2={class:"agents-heading"},d2={class:"agents-icon"},f2={role:"status","aria-live":"polite"},h2=["aria-label"],p2={class:"agents-body"},g2={key:0,class:"agents-empty"},m2={key:1,class:"agent-list"},v2={class:"agent-row-head"},y2={class:"agent-title"},b2={key:0,class:"background-badge"},k2={key:1,class:"agent-description"},w2={key:0,class:"agent-result error"},S2={key:1,class:"agent-result"},_2={key:2,class:"agent-meta"},$2={key:0},C2={key:1},x2={key:2},I2={key:3},T2=Ie({__name:"SubagentPanel",props:{subagents:{}},setup(e){const t=e,n=G(()=>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",l2,[h("header",u2,[h("div",c2,[h("span",d2,[X(ce,{name:"bot",size:16})]),h("div",null,[l[0]||(l[0]=h("h2",null,"协作代理",-1)),h("p",f2,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,h2)):U("",!0)]),h("div",p2,[e.subagents.length===0?(m(),v("p",g2,"当前会话还没有子代理活动")):(m(),v("ol",m2,[(m(!0),v(ne,null,Ce(e.subagents,u=>(m(),v("li",{key:u.subagentId,class:"agent-row"},[h("div",v2,[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",y2,[h("strong",null,C(u.name),1),u.runInBackground?(m(),v("span",b2,"后台")):U("",!0),u.description?(m(),v("span",k2,C(u.description),1)):U("",!0)]),h("span",{class:ue(["agent-state",u.state])},C(s(u)),3)]),u.error?(m(),v("p",w2,C(u.error),1)):u.resultSummary?(m(),v("p",S2,C(u.resultSummary),1)):U("",!0),u.turns||u.toolCallCount||o(u.durationMs)||r(u)!==null?(m(),v("dl",_2,[u.turns?(m(),v("div",$2,[l[1]||(l[1]=h("dt",null,"回合",-1)),h("dd",null,C(u.turns),1)])):U("",!0),u.toolCallCount?(m(),v("div",C2,[l[2]||(l[2]=h("dt",null,"工具",-1)),h("dd",null,C(u.toolCallCount),1)])):U("",!0),o(u.durationMs)?(m(),v("div",x2,[l[3]||(l[3]=h("dt",null,"耗时",-1)),h("dd",null,C(o(u.durationMs)),1)])):U("",!0),r(u)!==null?(m(),v("div",I2,[l[4]||(l[4]=h("dt",null,"Token",-1)),h("dd",null,C(i(r(u))),1)])):U("",!0)])):U("",!0)]))),128))]))])]))}}),E2=Te(T2,[["__scopeId","data-v-7f938bff"]]),A2={class:"settings"},M2={class:"settings-layout"},R2={class:"rail","aria-label":"设置分区"},P2=["aria-current","onClick"],L2={class:"pane"},D2={key:0,class:"pane-section"},N2={class:"block"},O2={class:"theme-grid",role:"radiogroup","aria-label":"主题"},G2=["aria-checked","onClick"],B2={class:"block"},F2={class:"like-fields"},U2={class:"like-label"},j2=["onUpdate:modelValue","placeholder","aria-label"],z2={class:"like-actions"},H2={key:0,class:"saved-hint"},W2={key:1,class:"pane-section"},q2={key:0,class:"notice-bar"},V2={key:1,class:"error-row",role:"alert"},K2={class:"error-text"},Z2={key:2,class:"empty"},Y2={key:3,class:"list"},X2={class:"row-main"},J2={class:"row-title"},Q2={class:"row-sub"},eP=["disabled","onClick"],tP={key:2,class:"pane-section"},nP={key:0,class:"empty"},sP={key:1,class:"list"},oP={class:"row-main"},rP={class:"row-title"},iP={class:"row-sub"},aP={class:"row-actions"},lP=["disabled","onClick"],uP=["disabled","onClick"],cP={key:3,class:"pane-section"},dP={class:"block"},fP={class:"inline-form"},hP={key:0,class:"hint"},pP={key:0,class:"empty"},gP={key:1,class:"list"},mP={class:"row-main"},vP={class:"row-title"},yP={key:0,class:"version"},bP={class:"row-sub"},kP=["disabled","onClick"],wP={key:4,class:"pane-section"},SP={key:0,class:"hint"},_P={key:1,class:"empty"},$P={key:2,class:"list"},CP={class:"row-main"},xP={class:"row-title"},IP={class:"row-sub"},TP={class:"row-actions"},EP=["disabled","onClick"],AP=["disabled","onClick"],MP=["disabled","onClick"],RP={key:5,class:"pane-section"},PP={class:"task-title-row"},LP={key:0,class:"hint"},DP={key:1,class:"empty"},NP={key:2,class:"list"},OP={class:"row-main"},GP={class:"row-title"},BP={class:"row-sub"},FP={class:"row-actions"},UP=["disabled","onClick"],jP=["disabled","onClick"],zP={key:3,class:"task-inspector","aria-label":"任务输出"},HP={class:"task-inspector-head"},WP=["title"],qP={class:"task-inspector-actions"},VP=["disabled"],KP={key:0,class:"task-output"},ZP={key:1,class:"task-output-empty"},YP={class:"task-meta"},XP={key:0},JP={key:1},QP=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=O("general"),a=G(()=>n.client),l=In("theme",O("system")),u=In("setTheme",()=>{}),c=[{id:"light",label:"浅色",icon:"sun"},{id:"dark",label:"深色",icon:"moon"},{id:"system",label:"跟随系统",icon:"monitor"}],d=O({...n.like}),f=O(!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",y()),f.value=!0,setTimeout(()=>f.value=!1,1500)}function y(){const R={};for(const K of p){const N=d.value[K.key];typeof N=="string"&&N.trim()&&(R[K.key]=N.trim())}return R}const S=G(()=>{var R;return o((R=a.value)==null?void 0:R.models)??[]}),k=G(()=>{var R,K;return((K=o((R=a.value)==null?void 0:R.status))==null?void 0:K.model)??""}),w=G(()=>{var R;return o((R=a.value)==null?void 0:R.modelsError)??""}),b=G(()=>{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 B(R){var K,N;(N=(K=a.value)==null?void 0:K.switchModel)==null||N.call(K,R)}const D=G(()=>{var R;return o((R=a.value)==null?void 0:R.skills)??[]}),E=O(!1);async function M(R){var K,N,Q,$;E.value=!0;try{await((N=(K=a.value)==null?void 0:K.activateSkill)==null?void 0:N.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 N,Q,$,H;if(!window.confirm(`移除技能「${R}」?`))return;await((Q=(N=a.value)==null?void 0:N.removeSkill)==null?void 0:Q.call(N,R))&&await((H=($=a.value)==null?void 0:$.fetchSkills)==null?void 0:H.call($))}const Z=G(()=>{var R;return o((R=a.value)==null?void 0:R.plugins)??[]}),W=O(!1);async function j(R,K){var N,Q,$,H;W.value=!0;try{await((Q=(N=a.value)==null?void 0:N.setPluginEnabled)==null?void 0:Q.call(N,R,K))&&await((H=($=a.value)==null?void 0:$.fetchPlugins)==null?void 0:H.call($))}finally{W.value=!1}}const te=O(""),I=O(!1),A=O("");async function V(){var K,N;const R=te.value.trim();if(R){I.value=!0,A.value="";try{const Q=await((N=(K=a.value)==null?void 0:K.installPlugin)==null?void 0:N.call(K,R));A.value=Q?`已安装 ${Q.displayName}`:"安装失败",Q&&(te.value="")}finally{I.value=!1}}}const ie=G(()=>{var R;return o((R=a.value)==null?void 0:R.mcpServers)??[]}),me=O(!1),_e=O("");async function he(R,K){var N,Q,$,H;me.value=!0,_e.value="";try{const q=await((Q=(N=a.value)==null?void 0:N[R])==null?void 0:Q.call(N,K));_e.value=q?"操作成功":"操作失败",await((H=($=a.value)==null?void 0:$.fetchMcpServers)==null?void 0:H.call($))}finally{me.value=!1}}const ae=G(()=>{var R;return o((R=a.value)==null?void 0:R.backgroundTasks)??[]}),pe=O(""),oe=O(!1),ge=O(""),$e=O(null),Ne=O(!1);let Ue=0,Ke=null;const Ye=G(()=>$e.value?ae.value.find(R=>R.taskId===$e.value)??null:null),rt=G(()=>ae.value.some(R=>R.status==="running"||R.status==="awaiting_approval"));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 N,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=(N=a.value)==null?void 0:N.stopBackgroundTask)==null?void 0:Q.call(N,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 N=++Ue;Ne.value=!0,ge.value="";try{await(($=(Q=a.value)==null?void 0:Q.fetchBackgroundTaskOutput)==null?void 0:$.call(Q,R,200)),N===Ue&&$e.value===R&&(pe.value=o((H=a.value)==null?void 0:H.backgroundTaskOutput)??"")}finally{N===Ue&&(Ne.value=!1)}}et(()=>{var K,N,Q,$,H,q;const R=a.value;(K=R==null?void 0:R.fetchModels)==null||K.call(R),(N=R==null?void 0:R.fetchConfig)==null||N.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",A2,[h("div",M2,[h("nav",R2,[(m(),v(ne,null,Ce(r,N=>h("button",{key:N.id,class:ue(["rail-tab",{active:i.value===N.id}]),"aria-current":i.value===N.id?"page":void 0,onClick:Q=>i.value=N.id},[X(ce,{name:N.icon,size:16},null,8,["name"]),h("span",null,C(N.label),1)],10,P2)),64))]),h("div",L2,[i.value==="general"?(m(),v("section",D2,[K[6]||(K[6]=h("h1",{class:"settings-title"},"通用设置",-1)),h("div",N2,[K[3]||(K[3]=h("h2",{class:"block-title"},"外观",-1)),h("div",O2,[(m(),v(ne,null,Ce(c,N=>h("button",{key:N.id,role:"radio","aria-checked":F(l)===N.id,class:ue(["theme-option",{active:F(l)===N.id}]),onClick:Q=>F(u)(N.id)},[X(ce,{name:N.icon,size:20},null,8,["name"]),h("span",null,C(N.label),1)],10,G2)),64))])]),h("div",B2,[K[5]||(K[5]=h("h2",{class:"block-title"},"偏好设置",-1)),h("div",F2,[(m(),v(ne,null,Ce(p,N=>h("label",{key:N.key,class:"like-field"},[h("span",U2,C(N.label),1),Ze(h("input",{"onUpdate:modelValue":Q=>d.value[N.key]=Q,class:"like-input",placeholder:N.hint,"aria-label":N.label},null,8,j2),[[it,d.value[N.key]]])])),64)),h("div",z2,[X(Ht,{variant:"primary",onClick:g},{default:ot(()=>[...K[4]||(K[4]=[Ae("保存偏好",-1)])]),_:1}),f.value?(m(),v("span",H2,"已保存")):U("",!0)])])])])):i.value==="models"?(m(),v("section",W2,[K[7]||(K[7]=h("h1",{class:"settings-title"},"模型",-1)),b.value?U("",!0):(m(),v("p",q2,"打开一个会话后可在此切换模型")),w.value?(m(),v("div",V2,[h("span",K2,C(w.value),1),h("button",{class:"row-action",onClick:_},"重试")])):S.value.length===0?(m(),v("p",Z2,"没有可用的模型")):(m(),v("ul",Y2,[(m(!0),v(ne,null,Ce(S.value,N=>(m(),v("li",{key:N.alias,class:ue(["list-row",{selected:N.alias===k.value}])},[h("div",X2,[h("span",J2,C(N.displayName||N.model),1),h("span",Q2,C(N.provider)+" · "+C(N.alias)+" · "+C(N.maxContextSize),1)]),h("button",{class:"row-action",disabled:!b.value||N.alias===k.value,onClick:Q=>B(N.alias)},C(N.alias===k.value?"使用中":"切换"),9,eP)],2))),128))]))])):i.value==="skills"?(m(),v("section",tP,[K[8]||(K[8]=h("h1",{class:"settings-title"},"技能",-1)),D.value.length===0?(m(),v("p",nP,"当前会话没有可用技能")):(m(),v("ul",sP,[(m(!0),v(ne,null,Ce(D.value,N=>(m(),v("li",{key:N.name,class:"list-row"},[h("div",oP,[h("span",rP,C(N.name),1),h("span",iP,[Ae(C(N.description||"—")+" ",1),N.pluginId?(m(),v(ne,{key:0},[Ae("· 来自插件 "+C(N.pluginId),1)],64)):U("",!0)])]),h("div",aP,[h("button",{class:"row-action",disabled:E.value,onClick:Q=>M(N.name)}," 激活 ",8,lP),h("button",{class:"row-action danger",disabled:E.value,onClick:Q=>T(N.name)}," 移除 ",8,uP)])]))),128))]))])):i.value==="plugins"?(m(),v("section",cP,[K[11]||(K[11]=h("h1",{class:"settings-title"},"插件",-1)),h("div",dP,[K[10]||(K[10]=h("h2",{class:"block-title"},"安装插件",-1)),h("div",fP,[Ze(h("input",{"onUpdate:modelValue":K[0]||(K[0]=N=>te.value=N),class:"like-input",placeholder:"本地路径 / zip URL / GitHub 地址","aria-label":"插件来源",spellcheck:"false"},null,512),[[it,te.value]]),X(Ht,{variant:"primary",disabled:I.value||!te.value.trim(),onClick:V},{default:ot(()=>[...K[9]||(K[9]=[Ae(" 安装 ",-1)])]),_:1},8,["disabled"])]),A.value?(m(),v("p",hP,C(A.value),1)):U("",!0)]),Z.value.length===0?(m(),v("p",pP,"还没有安装插件")):(m(),v("ul",gP,[(m(!0),v(ne,null,Ce(Z.value,N=>(m(),v("li",{key:N.id,class:"list-row"},[h("div",mP,[h("span",vP,[Ae(C(N.displayName)+" ",1),N.version?(m(),v("span",yP,"v"+C(N.version),1)):U("",!0)]),h("span",bP,C(N.skillCount)+" 技能 · "+C(N.enabledMcpServerCount)+"/"+C(N.mcpServerCount)+" MCP",1)]),h("button",{class:"row-action",disabled:W.value,onClick:Q=>j(N.id,!N.enabled)},C(N.enabled?"停用":"启用"),9,kP)]))),128))]))])):i.value==="mcp"?(m(),v("section",wP,[K[12]||(K[12]=h("h1",{class:"settings-title"},"MCP 服务器",-1)),_e.value?(m(),v("p",SP,C(_e.value),1)):U("",!0),ie.value.length===0?(m(),v("p",_P,"没有配置 MCP 服务器")):(m(),v("ul",$P,[(m(!0),v(ne,null,Ce(ie.value,N=>(m(),v("li",{key:N.name,class:"list-row"},[h("div",CP,[h("span",xP,C(N.name),1),h("span",IP,C(N.transport)+" · "+C(N.toolCount)+" 工具",1),h("span",{class:ue(["status-pill",J(N.status)])},C(N.status),3)]),h("div",TP,[h("button",{class:"row-action",disabled:me.value,onClick:Q=>he("reconnectMcpServer",N.name)},"重连",8,EP),h("button",{class:"row-action",disabled:me.value,onClick:Q=>he("stopMcpServer",N.name)},"停止",8,AP),h("button",{class:"row-action danger",disabled:me.value,onClick:Q=>he("removeMcpServer",N.name)},"移除",8,MP)])]))),128))]))])):i.value==="tasks"?(m(),v("section",RP,[h("div",PP,[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",LP,C(ge.value),1)):U("",!0),ae.value.length===0?(m(),v("p",DP,"没有后台任务")):(m(),v("ul",NP,[(m(!0),v(ne,null,Ce(ae.value,N=>(m(),v("li",{key:N.taskId,class:"list-row"},[h("div",OP,[h("span",GP,C(N.command),1),h("span",BP,C(N.description),1),h("span",{class:ue(["status-pill",J(N.status)])},C(N.status),3)]),h("div",FP,[h("button",{class:"row-action",disabled:oe.value,onClick:Q=>ee(N.taskId)},"输出",8,UP),N.status==="running"||N.status==="awaiting_approval"?(m(),v("button",{key:0,class:"row-action danger",disabled:oe.value,onClick:Q=>z(N.taskId)}," 停止 ",8,jP)):U("",!0)])]))),128))])),Ye.value?(m(),v("section",zP,[h("header",HP,[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,WP)]),h("div",qP,[h("button",{title:"刷新输出","aria-label":"刷新输出",disabled:Ne.value,onClick:K[1]||(K[1]=N=>ee(Ye.value.taskId,!1))},[X(ce,{name:"refresh",size:14})],8,VP),h("button",{title:"关闭输出","aria-label":"关闭输出",onClick:K[2]||(K[2]=N=>$e.value=null)},[X(ce,{name:"x",size:14})])])]),pe.value?(m(),v("pre",KP,C(pe.value),1)):(m(),v("p",ZP,C(Ne.value?"正在读取输出…":"暂时没有输出"),1)),h("footer",YP,[h("span",null,"PID "+C(Ye.value.pid),1),Ye.value.exitCode!==null?(m(),v("span",XP,"退出码 "+C(Ye.value.exitCode),1)):(m(),v("span",JP,C(Ye.value.status),1))])])):U("",!0)])):U("",!0)])])]))}}),Xp=Te(QP,[["__scopeId","data-v-c9e30e98"]]),eL={class:"settings-modal-body"},tL=Ie({__name:"SettingsModal",setup(e){const{open:t}=gh(),n=G(()=>za()),s=G(()=>{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(),Xr()}),(r,i)=>(m(),De(Vl,{open:F(t),title:"设置","max-width":"920px",onClose:F(Xr)},{default:ot(()=>[h("div",eL,[n.value?(m(),De(Xp,{key:0,client:n.value,like:s.value,onUpdateLike:o},null,8,["client","like"])):U("",!0)])]),_:1},8,["open","onClose"]))}}),nL=Te(tL,[["__scopeId","data-v-890b7003"]]),Rd=O(""),_a=O(new Set),pr=O(new Set),sL=O("sessions"),$a=5;function oL(){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(pr.value);r.has(o)?r.delete(o):r.add(o),pr.value=r}function n(o){return pr.value.has(o)}function s(){Rd.value=""}return{query:Rd,collapsedSpaces:_a,expandedSpaces:pr,section:sL,toggleSpace:e,toggleSpaceExpanded:t,isSpaceExpanded:n,clearSearch:s}}const rL=1440*60*1e3,iL=7,aL="昨天";function Pd(e){const t=new Date(e);return Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())/rL}function lL(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),s=String(t.getMinutes()).padStart(2,"0");return`${n}:${s}`}function uL(e,t=Date.now()){if(!Number.isFinite(e)||e<=0)return"";const n=Pd(t)-Pd(e);if(n<=0)return lL(e);if(n===1)return aL;if(n<=iL)return`${n} 天前`;const s=new Date(e);return`${s.getMonth()+1}/${s.getDate()}`}const Jp="scream-file-tree-expanded",cL=O("");function dL(){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=O(dL()),po=Wn(new Map),Ca=O(null),xa=new Map;function fL(){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){Ca.value!==l&&(Ca.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 po.get(l)??[]}async function i(l){const u=(xa.get(l)??0)+1;xa.set(l,u);const c=await Wl(l);return u!==(xa.get(l)??0)?po.get(l)??[]:(c!==null&&po.set(l,c),po.get(l)??[])}function a(l){po.delete(l)}return{activeWorkDir:Ca,query:cL,isExpanded:s,toggleExpand:o,loadedChildren:r,loadChildren:i,invalidate:a,setRoot:n}}const hL={class:"file-tree"},pL={key:0,class:"tree-toolbar"},gL={class:"tree-search"},mL={key:1,class:"tree-empty"},vL={key:2,class:"tree-empty"},yL={key:3,class:"tree-empty"},bL={key:4,class:"tree-empty"},kL=["aria-label"],wL=["aria-expanded","onClick"],SL=["title"],_L=["aria-expanded","onClick"],$L=["title"],CL=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}=fL(),u=O(!1),c=O(!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 M=E.replace(/\/+$/,"");return D===M?"":D.startsWith(`${M}/`)?D.slice(M.length+1):D}function y(D){var Z;const E=(Z=t.gitStatus)==null?void 0:Z.files;if(!E||E.length===0)return null;const M=g(D),T=E.find(W=>(W.displayPath??W.path)===M);return T?T.status.includes("?")?"?":T.status.includes("A")?"A":T.status.includes("M")?"M":null:null}const S=G(()=>{const D=t.workDir;if(!D)return[];const E=[],M=(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:y(j)}),W.type==="dir"&&s(D,j)&&M(j,Z+1)}};return M(D,0),E}),k=G(()=>S.value),w=G(()=>{const D=n.value.trim();if(!D)return[];const E=new Map(k.value.map(M=>[M.rel,M]));return vh(k.value.map(M=>({path:M.rel,isDir:M.isDir})),D,50).map(M=>E.get(M.path)).filter(M=>M!==void 0)}),b=G(()=>n.value.trim().length>0);function _(D){D.isDir?f(D.abs):ms(D.abs)}function B(){var E;const D=t.workDir;D&&(a(D),Eb(D),d(D),(E=t.refreshGit)==null||E.call(t))}return(D,E)=>(m(),v("div",hL,[e.workDir?(m(),v("div",pL,[h("label",gL,[X(ce,{name:"search",size:13}),Ze(h("input",{"onUpdate:modelValue":E[0]||(E[0]=M=>ht(n)?n.value=M:null),type:"text",placeholder:"过滤文件…","aria-label":"过滤文件",spellcheck:"false"},null,512),[[it,F(n)]])]),h("button",{class:"tree-refresh",title:"刷新文件树与 Git 状态","aria-label":"刷新文件树与 Git 状态",onClick:B},[X(ce,{name:"refresh",size:13})])])):U("",!0),e.workDir?u.value&&S.value.length===0?(m(),v("div",vL,"加载中…")):c.value&&S.value.length===0?(m(),v("div",yL,"工作目录为空")):b.value&&w.value.length===0?(m(),v("div",bL,"没有匹配的文件")):(m(),v("div",{key:5,class:"tree-scroll",role:"tree","aria-label":"文件树 "+e.workDir},[b.value?(m(!0),v(ne,{key:0},Ce(w.value,M=>(m(),v("button",{key:M.abs,class:ue(["tree-row",{"is-dir":M.isDir}]),role:"treeitem","aria-expanded":M.isDir?F(s)(e.workDir,M.abs):void 0,onClick:T=>_(M)},[X(ce,{name:M.isDir?"folder":"file",size:14,class:"row-icon"},null,8,["name"]),h("span",{class:"row-label mono",title:M.rel},C(M.rel),9,SL),M.git?(m(),v("span",{key:0,class:ue(["row-git",`g-${M.git}`])},C(M.git),3)):U("",!0)],10,wL))),128)):(m(!0),v(ne,{key:1},Ce(S.value,M=>(m(),v("button",{key:M.abs,class:ue(["tree-row",{"is-dir":M.isDir}]),style:bt({paddingLeft:`${8+M.depth*14}px`}),role:"treeitem","aria-expanded":M.isDir?F(s)(e.workDir,M.abs):void 0,onClick:T=>_(M)},[X(ce,{name:M.isDir?F(s)(e.workDir,M.abs)?"chevron-down":"chevron-right":"file",size:13,class:"row-caret"},null,8,["name"]),X(ce,{name:M.isDir?"folder":"file",size:14,class:"row-icon"},null,8,["name"]),h("span",{class:ue(["row-label",{mono:!M.isDir}]),title:M.rel},C(M.name),11,$L),M.git?(m(),v("span",{key:0,class:ue(["row-git",`g-${M.git}`])},C(M.git),3)):U("",!0)],14,_L))),128))],8,kL)):(m(),v("div",mL,"当前会话没有工作目录"))]))}}),xL=Te(CL,[["__scopeId","data-v-f7cdf024"]]),Qp=""+new URL("logo-v2-ChmPAIbI.svg",import.meta.url).href,IL={class:"sidebar-head"},TL=["src"],EL=["title","aria-label","aria-expanded"],AL=["title"],ML={key:0},RL={key:0,class:"section-switch",role:"tablist","aria-label":"侧栏分区"},PL=["aria-selected"],LL=["aria-selected"],DL={key:0,class:"side-search"},NL=["placeholder"],OL={class:"spaces"},GL=["title"],BL=["title","onClick"],FL={class:"space-name"},UL={class:"space-count"},jL={key:0,class:"space-sessions"},zL=["title","onClick","onDblclick"],HL={key:0,class:"session-run","aria-hidden":"true"},WL={class:"session-text"},qL={key:0,class:"session-rename"},VL=["aria-label","onKeydown","onBlur"],KL={class:"session-title"},ZL={class:"session-meta"},YL={class:"session-actions"},XL=["disabled","title","aria-label","onClick"],JL=["title","aria-label","onClick"],QL=["aria-label"],eD={class:"delete-confirm-text"},tD={class:"delete-confirm-actions"},nD=["onClick"],sD=["title","onClick"],oD={key:0,class:"spaces-empty"},rD={class:"sidebar-foot","aria-label":"功能区"},iD=["title"],aD={key:0},lD=["title"],uD={key:0},cD={class:"sidebar-identity"},dD={key:0,class:"identity-text"},fD=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=O(null),{query:i,collapsedSpaces:a,section:l,toggleSpace:u,toggleSpaceExpanded:c,isSpaceExpanded:d}=oL();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 y=G(()=>{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=G(()=>{var pe;const he=new Map;for(const oe of y.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 k(he){return i.value.trim()||d(he.key)?he.items:he.items.length>$a?he.items.slice(0,$a):he.items}function w(he){return Math.max(0,he.items.length-$a)}function b(he){o("switch-session",he)}function _(he){return he.sessionId===s.currentSessionId}const B=O(null);function D(he){B.value=B.value===he.sessionId?null:he.sessionId}function E(){B.value=null}function M(he){E(),o("delete-session",he)}function T(he){if(!B.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=O(null);function j(he){W.value=he}const te=O(null),I=O("");function A(he){te.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(){te.value=null,I.value=""}function ie(he){const ae=I.value.trim();if(te.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 uL(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",IL,[h("button",{class:"sidebar-brand",title:"回到新对话",onClick:ae[0]||(ae[0]=pe=>o("navigate","home"))},[h("img",{class:"brand-logo",src:F(Qp),alt:"scream"},null,8,TL)]),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,EL)):U("",!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?U("",!0):(m(),v("span",ML,"新建对话"))],8,AL),e.collapsed?U("",!0):(m(),v("div",RL,[h("button",{class:ue(["section-tab",{active:F(l)==="sessions"}]),role:"tab","aria-selected":F(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,PL),h("button",{class:ue(["section-tab",{active:F(l)==="files"}]),role:"tab","aria-selected":F(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,LL)])),!e.collapsed&&F(l)==="files"?(m(),De(xL,{key:1,"work-dir":e.workDir,"git-status":e.gitStatus,"refresh-git":e.refreshGit,onOpenFile:Z},null,8,["work-dir","git-status","refresh-git"])):U("",!0),e.collapsed||F(l)==="sessions"?(m(),v(ne,{key:2},[e.collapsed?U("",!0):(m(),v("label",DL,[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:`搜索会话… (${F(_r)}K)`,"aria-label":"搜索会话",spellcheck:"false"},null,8,NL),[[it,F(i)]])])),h("div",OL,[(m(!0),v(ne,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,GL)):(m(),v(ne,{key:1},[h("button",{class:"space-head",title:pe.key,onClick:oe=>F(u)(pe.key)},[X(ce,{name:F(a).has(pe.key)?"chevron-right":"chevron-down",size:14},null,8,["name"]),h("span",FL,C(pe.name),1),h("span",UL,C(pe.items.length),1)],8,BL),F(a).has(pe.key)?U("",!0):(m(),v("div",jL,[(m(!0),v(ne,null,Ce(k(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=>b(oe.sessionId),onDblclick:ge=>A(oe)},[oe.active?(m(),v("span",HL)):U("",!0),h("span",WL,[te.value===oe.sessionId?(m(),v("span",qL,[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,VL),[[it,I.value]])])):(m(),v(ne,{key:1},[h("span",KL,C(_e(oe)),1),h("span",ZL,[h("span",null,C(me(oe.createdAt)),1),oe.messageCount>=0?(m(),v(ne,{key:0},[ae[13]||(ae[13]=h("span",{class:"meta-sep","aria-hidden":"true"},"·",-1)),h("span",null,C(oe.messageCount)+" 条",1)],64)):U("",!0)])],64))])],42,zL),h("div",YL,[h("button",{type:"button",class:"session-act",disabled:!_(oe),title:_(oe)?"重命名会话":"只有当前打开的会话能重命名","aria-label":`重命名会话:${_e(oe)}`,onClick:tt(ge=>A(oe),["stop"])},[X(ce,{name:"edit",size:14})],8,XL),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,JL),B.value===oe.sessionId?(m(),v("div",{key:0,class:"delete-confirm",role:"alertdialog","aria-label":`确认删除:${_e(oe)}`},[h("div",eD,"删除「"+C(_e(oe))+"」?不可恢复。",1),h("div",tD,[h("button",{type:"button",class:"dc-btn",onClick:tt(E,["stop"])},"取消"),h("button",{type:"button",class:"dc-btn dc-btn--danger",onClick:tt(ge=>M(oe.sessionId),["stop"])}," 确认删除 ",8,nD)])],8,QL)):U("",!0)])]))),128)),!F(i)&&w(pe)>0?(m(),v("button",{key:0,class:"space-more",type:"button",title:F(d)(pe.key)?"收起,只留最近几条":"展开这个空间的其余会话",onClick:oe=>F(c)(pe.key)},[X(ce,{name:"chevron-down",size:12,class:ue({"is-up":F(d)(pe.key)})},null,8,["class"]),h("span",null,C(F(d)(pe.key)?"收起":`显示更多 ${w(pe)} 条`),1)],8,sD)):U("",!0)]))],64))]))),128)),!e.collapsed&&S.value.length===0?(m(),v("p",oD,C(F(i)?"没有匹配的会话":"还没有会话,点击上方「新建对话」开始"),1)):U("",!0)])],64)):U("",!0),h("nav",rD,[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?U("",!0):(m(),v("span",aD,"技能中心"))],10,iD),h("button",{class:ue(["foot-item",{active:e.view==="settings"||F(p)}]),title:e.collapsed?"设置":void 0,onClick:g},[X(ce,{name:"settings",size:17}),e.collapsed?U("",!0):(m(),v("span",uD,"设置"))],10,lD),h("div",cD,[ae[14]||(ae[14]=h("span",{class:"identity-dot","aria-hidden":"true"},null,-1)),e.collapsed?U("",!0):(m(),v("span",dD,"scream web"))])])],2))}}),Ld=Te(fD,[["__scopeId","data-v-8f86aaa3"]]),hD={class:"skills"},pD={class:"skills-head"},gD={class:"skills-head-actions"},mD={key:0,class:"skills-error",role:"alert"},vD={key:1,class:"skills-grid","aria-hidden":"true"},yD={key:2,class:"skills-empty"},bD={class:"skills-empty-title"},kD={key:3,class:"skills-grid"},wD={class:"skill-card-head"},SD={class:"skill-cmd"},_D={class:"skill-source"},$D={class:"skill-desc"},CD={class:"skill-card-foot"},xD=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}=Js(),{activeClient:r}=Kv(),i=G(()=>n.client??r.value);function a(k){return k!==null&&typeof k=="object"&&k.__v_isRef===!0?k.value:k}const l=G(()=>{var k;return a((k=i.value)==null?void 0:k.skills)??[]}),u=G(()=>{var k;return a((k=i.value)==null?void 0:k.skillsError)??""}),c=G(()=>{var k,w;return!!a(((k=i.value)==null?void 0:k.currentSessionId)??((w=i.value)==null?void 0:w.sessionId))}),d=O(!1);async function f(){const k=i.value;if(k!=null&&k.fetchSkills){d.value=!0;try{await k.fetchSkills()}finally{d.value=!1}}}et(f);const p={builtin:"内置",user:"用户",extra:"扩展",project:"项目"};function g(k){return k.pluginId?`插件 ${k.pluginId}`:p[k.source]||k.source||"本地"}async function y(k){try{return await navigator.clipboard.writeText(k),!0}catch{return!1}}async function S(k){var B;const w=`/${k.name} `;let b=!1;try{b=!!await((B=n.injectDraft)==null?void 0:B.call(n,w))}catch{b=!1}if(b)return;const _=await y(w);s("create"),o(_?`已复制 ${w.trim()},在输入框粘贴后回车即可使用`:`在输入框输入 ${w.trim()} 并回车即可使用该技能`,"info")}return(k,w)=>(m(),v("div",hD,[h("div",pD,[w[4]||(w[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",gD,[X(Ht,{variant:"ghost",disabled:d.value||!c.value,onClick:f},{default:ot(()=>[X(ce,{name:"refresh",size:16}),w[2]||(w[2]=Ae(" 重新加载 ",-1))]),_:1},8,["disabled"]),X(Ht,{variant:"primary",onClick:w[0]||(w[0]=b=>s("create"))},{default:ot(()=>[X(ce,{name:"plus",size:16}),w[3]||(w[3]=Ae(" 新建会话 ",-1))]),_:1})])]),u.value?(m(),v("p",mD,[Ae(C(u.value)+" ",1),h("button",{class:"skills-retry",onClick:f},"重试")])):U("",!0),d.value&&l.value.length===0?(m(),v("div",vD,[(m(),v(ne,null,Ce(6,b=>h("div",{key:b,class:"skill-card skeleton"},[...w[5]||(w[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",yD,[X(ce,{name:"sparkles",size:28}),h("p",bD,C(c.value?"这个会话还没有可用技能":"打开会话后可查看技能"),1),w[7]||(w[7]=h("p",{class:"skills-empty-hint"}," 技能可以放在技能目录(用户 / 额外目录),或随插件安装进来;装好后点「重新加载」。 ",-1)),X(Ht,{variant:"primary",onClick:w[1]||(w[1]=b=>s("create"))},{default:ot(()=>[X(ce,{name:"plus",size:16}),w[6]||(w[6]=Ae(" 新建会话 ",-1))]),_:1})])):(m(),v("div",kD,[(m(!0),v(ne,null,Ce(l.value,b=>(m(),v("article",{key:b.name,class:"skill-card"},[h("div",wD,[h("span",SD,"/"+C(b.name),1),h("span",_D,C(g(b)),1)]),h("p",$D,C(b.description||"暂无描述"),1),h("div",CD,[X(Ht,{variant:"secondary",onClick:_=>S(b)},{default:ot(()=>[X(ce,{name:"send",size:14}),w[8]||(w[8]=Ae(" 试用 ",-1))]),_:1},8,["onClick"])])]))),128))]))]))}}),ID=Te(xD,[["__scopeId","data-v-60c38852"]]),TD={class:"dock-tabs",role:"tablist","aria-label":"右栏标签","aria-orientation":"horizontal"},ED=["onAuxclick"],AD=["id","aria-selected","aria-controls","tabindex","title","data-kind","onClick","onKeydown"],MD={class:"tab-label"},RD=["title","aria-label","onClick"],PD={class:"dock-chrome"},LD=["title","aria-label","aria-pressed"],DD=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=O(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(Zr(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 Wa(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 y=f[g];y&&i(y.id)}return(c,d)=>(m(),v("div",{ref_key:"barRef",ref:s,class:"tab-bar"},[h("div",TD,[(m(!0),v(ne,null,Ce(F(we).tabs,f=>(m(),v("div",{key:f.id,class:ue(["tab-entry",{active:f.id===F(we).activeTabId}]),role:"presentation",onAuxclick:p=>o(p,f.id)},[h("button",{id:F(Zr)(f.id),class:ue(["tab-button",{active:f.id===F(we).activeTabId}]),role:"tab","aria-selected":f.id===F(we).activeTabId,"aria-controls":l(f),tabindex:f.id===F(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:F(dh)(f.kind).icon,size:13,class:"tab-icon"},null,8,["name"]),h("span",MD,C(f.label),1)],42,AD),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,RD)],42,ED))),128))]),h("div",PD,[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,LD)):U("",!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))}}),ND=Te(DD,[["__scopeId","data-v-e9125a46"]]),OD={class:"mode-switch",role:"group","aria-label":"工作模式"},GD=["aria-pressed","onClick"],BD=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",OD,[(m(),v(ne,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,GD)),64))]))}}),FD=Te(BD,[["__scopeId","data-v-c4ac7862"]]),UD={class:"workspace"},jD={class:"workspace-hero"},zD={class:"workspace-brand"},HD=["src"],WD={class:"workspace-status","aria-label":"连接与模型状态"},qD={class:"status-item"},VD={class:"status-item status-model"},KD={class:"workspace-launch"},ZD={class:"mode-hint"},YD={class:"quick-start"},XD={class:"quick-label"},JD={class:"quick-chips"},QD=["title","onClick"],eN={class:"workspace-composer"},tN="scream-recent-prompts",nN=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=G(()=>s.mode==="goal"),i=G(()=>r.value?"任务模式:提交后将创建执行目标(Goal),Agent 持续执行到完成或预算耗尽;抽屉「Goal 管理」可查看与暂停。":"直接对话:提问后 Agent 按需调用工具完成你的请求。"),a=G(()=>s.status!==void 0),l=G(()=>{var k;return(k=s.status)==null?void 0:k.model}),u=O([]),{fetchServerWorkDir:c}=Hl();et(()=>{c();try{const k=localStorage.getItem(tN);if(k){const w=JSON.parse(k);Array.isArray(w)&&(u.value=w.filter(b=>typeof b=="string").slice(0,4))}}catch{u.value=[]}});const d={chat:["梳理当前项目结构","解释最近的代码改动","帮我排查一个报错"],goal:["修复构建并跑通测试","完成一次小型重构","整理项目文档"]},f=G(()=>u.value.length>0),p=G(()=>f.value?u.value:d[s.mode]),g=O(null);function y(k){var w;(w=g.value)==null||w.insertText(k)}function S(k){const w=g.value;return w?(w.insertDraft(k,{activate:!0}),!0):!1}return t({insertDraft:S}),(k,w)=>(m(),v("div",UD,[h("section",jD,[h("h1",zD,[h("img",{class:"brand-logo",src:F(Qp),alt:"scream"},null,8,HD)]),w[7]||(w[7]=h("p",{class:"workspace-tagline"},"你的智能协作伙伴",-1)),h("p",WD,[h("span",{class:ue(["status-dot",a.value?"on":"off"]),"aria-hidden":"true"},null,2),h("span",qD,C(a.value?"已连接":"等待连接"),1),l.value?(m(),v(ne,{key:0},[w[6]||(w[6]=h("span",{class:"status-sep"},"·",-1)),h("span",VD,C(l.value),1)],64)):U("",!0)])]),h("section",KD,[X(FD,{class:"workspace-mode","model-value":s.mode,"onUpdate:modelValue":w[0]||(w[0]=b=>o("update:mode",b))},null,8,["model-value"]),h("p",ZD,[(m(),v("span",{key:String(r.value),class:"hint-fade"},C(i.value),1))]),h("div",YD,[h("span",XD,C(f.value?"最近":"试试"),1),h("div",JD,[(m(!0),v(ne,null,Ce(p.value,(b,_)=>(m(),v("button",{key:`${_}-${b}`,class:"quick-chip",title:b,onClick:B=>y(b)},C(b),9,QD))),128))])])]),h("section",eN,[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:w[1]||(w[1]=b=>o("send",b,s.mode)),onAbort:w[2]||(w[2]=b=>o("abort")),onCommand:w[3]||(w[3]=(b,_)=>o("command",b,_)),onSwitchModel:w[4]||(w[4]=b=>o("switch-model",b)),onSwitchThinking:w[5]||(w[5]=b=>o("switch-thinking",b))},null,8,["busy","status","models","recent-work-dirs","placeholder"])])]))}}),sN=Te(nN,[["__scopeId","data-v-1f7fc15b"]]),oN=["aria-valuenow","aria-valuemin","aria-valuemax"],rN={key:2,class:"sidebar-mobile",role:"dialog","aria-modal":"true","aria-label":"导航菜单"},iN={class:"canvas"},aN={class:"topbar mobile-only"},lN={class:"topbar-left"},uN={key:0,class:"topbar-running",title:"Agent 运行中"},cN={class:"canvas-body"},dN=["aria-valuenow","aria-valuemin","aria-valuemax"],fN=["role","aria-modal"],hN={class:"right-panel-body"},pN=["id","aria-labelledby"],gN=["data-dock-tab","id","aria-labelledby"],Dd="scream-sidebar-collapsed",Nd="scream-workspace-mode",mN=Ie({__name:"WebShell",setup(e){var Cs,er;const t=Ay(),{showToast:n}=Js(),{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:y,switchSession:S,deleteSession:k,switchModel:w,switchThinking:b,fetchLike:_,fetchGitStatus:B,abort:D}=t,E=O("home"),M=O(!1),T=O(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,M.value=!1}function te(){M.value=!1,Xr(),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 y(de.workDir??void 0,()=>{E.value="chat"}),!(!a.value||a.value===ve)&&(L&&w(L),E.value="chat")}const{preferredWorkDir:A,serverWorkDir:V,setPreferredWorkDir:ie}=Hl(),me=O(!1),_e=G(()=>{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=O(null),ae=O(null);async function pe(de){var re,Me;M.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(M.value=!1,ge){oe(de);return}ge=!0;try{const L=a.value;if(await y(A.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){M.value=!1,E.value="chat",S(de)}function Ke(de){ms(de)}function Ye(de,ve){if(de!==a.value){n("请先点击该会话,再双击重命名。","warning");return}p("title",ve)}const rt=O(!1),Dt=O("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 y(A.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:te,showInfo:x,currentModel:()=>o.value.model}),z=O(Vr(Dd)==="1"),ee=`(max-width: ${Dy-1}px)`,J=(er=(Cs=globalThis.window)==null?void 0:Cs.matchMedia)==null?void 0:er.call(Cs,ee),R=O((J==null?void 0:J.matches)??!1);function K(de){R.value=de.matches}const N=G(()=>R.value||z.value);function Q(){if(R.value){M.value=!M.value;return}z.value=!z.value,Kr(Dd,z.value?"1":"0")}const $=O(window.innerWidth),H=G(()=>$.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:()=>!N.value,acceptStoredWidth:de=>de<=qr}),fe=se.width,ye=se.resizing,Ee=G(()=>Fy({viewportWidth:$.value,sidebarOpen:!z.value,sidebarWidth:N.value?wc:fe.value})),ke=Sc({storageKey:"scream-right-panel-width",minWidth:Ha,maxWidth:()=>Ee.value,defaultWidth:()=>Gy($.value),side:"right"}),be=ke.resizing,Oe=ke.effectiveWidth,lt=O(!1);function gt(){jl(!1)}Se(H,()=>{be.value&&ke.release()}),Se(N,()=>{N.value&&ye.value&&se.release()}),Se(R,de=>{de||(M.value=!1)}),Se(()=>we.panelOpen,de=>{de||(lt.value=!1)});const sn=G(()=>({"--sidebar-track":`${N.value?wc:fe.value}px`,"--sidebar-width":`${fe.value}px`,"--dock-track":`${we.panelOpen&&H.value&&!lt.value?Oe.value:0}px`})),ws={detail:LR,control:a2,agents:E2,run:Zp,git:qp,todo:Yp,goal:Vp,like:Kp},mt=G(()=>we.tabs.filter(de=>de.kind!=="file")),Nt=G(()=>{var de;return((de=qa())==null?void 0:de.kind)??"file"}),Ss=G(()=>{const de=qa();return de?Zr(de.id):void 0}),_s=Wa("file-pane"),so=G(()=>Nt.value==="file");function Fi(de){ms(de.path,{modeHint:"diff",label:de.display})}const on={refresh:()=>B(),diff:Fi};function $s(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 Ui(de){return de==="git"?on:{}}const oo=O(Vr(Nd)==="goal"?"goal":"chat");function ji(de){oo.value=de,Kr(Nd,de)}function Qo(de){if((de.metaKey||de.ctrlKey)&&de.key==="k")de.preventDefault(),N.value&&!M.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(),te();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",Qo),window.addEventListener("resize",q),(de=J==null?void 0:J.addEventListener)==null||de.call(J,"change",K),_(),B()}),st(()=>{var de;window.removeEventListener("keydown",Qo),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":N.value,resizing:F(ye)||F(be),"right-panel-open":F(we).panelOpen&&H.value,"dock-maximized":F(we).panelOpen&&lt.value}]),style:bt(sn.value)},[X(Ld,{ref_key:"sidebarRef",ref:T,view:E.value,sessions:F(i),"current-session-id":F(a),"work-dir":F(l),"git-status":F(u),"refresh-git":F(B),collapsed:N.value,onNavigate:j,onSwitchSession:Ue,onDeleteSession:F(k),onCreateSession:te,onToggleCollapse:Q,onOpenFile:Ke,onRenameSession:Ye},null,8,["view","sessions","current-session-id","work-dir","git-status","refresh-git","collapsed","onDeleteSession"]),N.value?U("",!0):(m(),v("div",{key:0,class:ue(["panel-resize-handle panel-resize-handle--left",{resizing:F(ye)}]),role:"separator","aria-orientation":"vertical","aria-label":"调整侧栏宽度","aria-valuenow":F(fe),"aria-valuemin":F(kc),"aria-valuemax":F(qr),tabindex:"0",title:"拖拽调整宽度 · 双击复位",onPointerdown:ve[0]||(ve[0]=(...L)=>F(se).onPointerDown&&F(se).onPointerDown(...L)),onPointermove:ve[1]||(ve[1]=(...L)=>F(se).onPointerMove&&F(se).onPointerMove(...L)),onPointerup:ve[2]||(ve[2]=(...L)=>F(se).onPointerUp&&F(se).onPointerUp(...L)),onPointercancel:ve[3]||(ve[3]=(...L)=>F(se).onPointerUp&&F(se).onPointerUp(...L)),onDblclick:ve[4]||(ve[4]=(...L)=>F(se).reset&&F(se).reset(...L)),onKeydown:ve[5]||(ve[5]=(...L)=>F(se).onKeydown&&F(se).onKeydown(...L))},null,42,oN)),M.value?(m(),v("div",{key:1,class:"sidebar-backdrop","aria-hidden":"true",onClick:ve[6]||(ve[6]=L=>M.value=!1)})):U("",!0),M.value?(m(),v("div",rN,[X(Ld,{view:E.value,sessions:F(i),"current-session-id":F(a),"work-dir":F(l),"git-status":F(u),"refresh-git":F(B),"show-collapse-toggle":!1,onNavigate:j,onSwitchSession:Ue,onDeleteSession:F(k),onCreateSession:te,onOpenFile:Ke,onRenameSession:Ye},null,8,["view","sessions","current-session-id","work-dir","git-status","refresh-git","onDeleteSession"])])):U("",!0),h("main",iN,[h("header",aN,[h("div",lN,[h("button",{class:"topbar-icon mobile-menu",title:"菜单","aria-label":"打开菜单",onClick:ve[7]||(ve[7]=L=>M.value=!0)},[X(ce,{name:"menu",size:20})]),F(r)?(m(),v("span",uN,[...ve[18]||(ve[18]=[h("span",{class:"running-dot","aria-hidden":"true"},null,-1),h("span",{class:"running-text"},"运行中",-1)])])):U("",!0)])]),h("div",cN,[E.value==="home"?(m(),De(sN,{key:0,ref_key:"workspaceHomeRef",ref:ae,models:F(c),status:F(o),busy:F(r),mode:oo.value,"recent-work-dirs":_e.value,"onUpdate:mode":ji,onSend:$e,onAbort:F(D),onCommand:F(P),onSwitchModel:F(w),onSwitchThinking:F(b)},null,8,["models","status","busy","mode","recent-work-dirs","onAbort","onCommand","onSwitchModel","onSwitchThinking"])):E.value==="chat"?(m(),De(EE,{key:1,ref_key:"conversationRef",ref:he,client:F(t),onHome:ve[8]||(ve[8]=L=>E.value="home")},null,8,["client"])):E.value==="skills"?(m(),De(ID,{key:2,"inject-draft":pe,onCreate:te})):E.value==="settings"?(m(),De(Xp,{key:3,like:F(d),client:F(t),onUpdateLike:F(t).updateLike},null,8,["like","client","onUpdateLike"])):U("",!0)])]),F(we).panelOpen&&!H.value?(m(),v("div",{key:3,class:"right-panel-backdrop","aria-hidden":"true",onClick:gt})):U("",!0),F(we).panelOpen&&H.value&&!lt.value?(m(),v("div",{key:4,class:ue(["panel-resize-handle panel-resize-handle--right",{resizing:F(be)}]),role:"separator","aria-orientation":"vertical","aria-label":"调整右栏宽度","aria-valuenow":F(Oe),"aria-valuemin":F(Ha),"aria-valuemax":Ee.value,tabindex:"0",title:"拖拽调整宽度 · 双击复位",onPointerdown:ve[9]||(ve[9]=(...L)=>F(ke).onPointerDown&&F(ke).onPointerDown(...L)),onPointermove:ve[10]||(ve[10]=(...L)=>F(ke).onPointerMove&&F(ke).onPointerMove(...L)),onPointerup:ve[11]||(ve[11]=(...L)=>F(ke).onPointerUp&&F(ke).onPointerUp(...L)),onPointercancel:ve[12]||(ve[12]=(...L)=>F(ke).onPointerUp&&F(ke).onPointerUp(...L)),onDblclick:ve[13]||(ve[13]=(...L)=>F(ke).reset&&F(ke).reset(...L)),onKeydown:ve[14]||(ve[14]=(...L)=>F(ke).onKeydown&&F(ke).onKeydown(...L))},null,42,dN)):U("",!0),F(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(ND,{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",hN,[Ze(h("div",{id:F(_s),class:"dock-pane dock-pane--file",role:"tabpanel","aria-labelledby":so.value?Ss.value:void 0,tabindex:"0"},[X(iA,{client:F(t)},null,8,["client"])],8,pN),[[Br,so.value]]),(m(!0),v(ne,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:F(Wa)(L.id),role:"tabpanel","aria-labelledby":F(Zr)(L.id),tabindex:"0"},[(m(),De(Tf(ws[L.kind]),Kf({ref_for:!0},$s(L.kind),hm(Ui(L.kind))),null,16))],10,gN)),[[Br,L.id===F(we).activeTabId]])),128))])],10,fN)):U("",!0),rt.value?(m(),De(wh,{key:6,mode:Dt.value,status:F(o),"session-id":F(a),"work-dir":F(l),onClose:ve[16]||(ve[16]=L=>rt.value=!1)},null,8,["mode","status","session-id","work-dir"])):U("",!0),X(nL),X(OM,{open:me.value,models:F(c),"recent-work-dirs":_e.value,"default-dir":F(V)??"","current-model":F(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))}}),vN=Te(mN,[["__scopeId","data-v-b626c063"]]),yN=["src","alt"],bN={key:1,class:"lightbox-note",role:"alert"},kN=Ie({__name:"ImageLightbox",setup(e){const t=O(null),n=O(!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(),ba()}function o(r){r.target===t.value&&ba()}return(r,i)=>(m(),v("dialog",{ref_key:"dialogRef",ref:t,class:"image-lightbox","aria-label":"图片预览",onCancel:s,onClick:o},[F(jn).open?(m(),v("img",{key:0,class:"lightbox-img",src:F(jn).src,alt:F(jn).alt||"图片预览",onError:i[0]||(i[0]=a=>n.value=!0)},null,40,yN)):U("",!0),n.value?(m(),v("p",bN,"图片加载失败")):U("",!0),h("button",{type:"button",class:"lightbox-close","aria-label":"关闭预览",title:"关闭(Esc)",onClick:i[1]||(i[1]=a=>F(ba)())},[X(ce,{name:"x",size:16})])],544))}}),wN=Te(kN,[["__scopeId","data-v-7d7939d6"]]),SN={class:"toast-container"},_N=["onClick"],$N={class:"toast-icon"},CN={class:"toast-msg"},xN=Ie({__name:"Toast",setup(e){const{toasts:t,removeToast:n}=Js(),s={info:"ℹ",success:"✓",error:"✗",warning:"⚠"};return(o,r)=>(m(),De(Xs,{to:"body"},[h("div",SN,[X($v,{name:"toast"},{default:ot(()=>[(m(!0),v(ne,null,Ce(F(t),i=>(m(),v("div",{key:i.id,class:ue(["toast",`toast--${i.type}`]),onClick:a=>F(n)(i.id)},[h("span",$N,C(s[i.type]),1),h("span",CN,C(i.message),1)],10,_N))),128))]),_:1})])]))}}),IN=Te(xN,[["__scopeId","data-v-a432e638"]]),TN={class:"app"},EN=Ie({__name:"App",setup(e){const t=O("system"),n=O("dark");vr("effectiveTheme",n),vr("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,Kr("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()}vr("setTheme",i),et(()=>{const l=Vr("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",TN,[X(vN),X(wN),X(IN)]))}}),AN=Te(EN,[["__scopeId","data-v-6c4eed55"]]);Dv(AN).mount("#app");
240
- //# sourceMappingURL=index-DMGV8LA-.js.map
240
+ //# sourceMappingURL=index-CKa_o5qA.js.map