@vincenthanxiaodu/pi-web 1.202608.48 → 1.202608.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{CodeViewer-BsmhyjB3.js → CodeViewer-BNqqpXU2.js} +1 -1
- package/dist/client/assets/{TerminalPanel-DsEoManU.js → TerminalPanel-D0BZl86M.js} +1 -1
- package/dist/client/assets/{index-CMyoPJxb.js → index-WereAjrc.js} +211 -203
- package/dist/client/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CodeViewer-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CodeViewer-BNqqpXU2.js","./vendor-editor-core-CXO8gGab.js","./vendor-editor-languages-CpW4sJsX.js","./vendor-editor-legacy-CYBnW6ZU.js","./TerminalPanel-D0BZl86M.js","./vendor-terminal-D8k4UKM2.js","./vendor-terminal-BrP-ENHg.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{$ as e,A as t,J as n,P as r,Q as i,S as a,Y as o,Z as s,d as c,et as l,f as u,j as d,l as f,p,q as m,u as ee}from"./vendor-editor-core-CXO8gGab.js";import{a as te,o as ne,s as re}from"./vendor-editor-languages-CpW4sJsX.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var ie=globalThis,ae=ie.ShadowRoot&&(ie.ShadyCSS===void 0||ie.ShadyCSS.nativeShadow)&&`adoptedStyleSheets`in Document.prototype&&`replace`in CSSStyleSheet.prototype,oe=Symbol(),se=new WeakMap,ce=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==oe)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(ae&&e===void 0){let n=t!==void 0&&t.length===1;n&&(e=se.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&se.set(t,e))}return e}toString(){return this.cssText}},le=e=>new ce(typeof e==`string`?e:e+``,void 0,oe),h=(e,...t)=>new ce(e.length===1?e[0]:t.reduce((t,n,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if(typeof e==`number`)return e;throw Error(`Value passed to 'css' function must be a 'css' function result: `+e+`. Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.`)})(n)+e[r+1],e[0]),e,oe),ue=(e,t)=>{if(ae)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let n of t){let t=document.createElement(`style`),r=ie.litNonce;r!==void 0&&t.setAttribute(`nonce`,r),t.textContent=n.cssText,e.appendChild(t)}},de=ae?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t=``;for(let n of e.cssRules)t+=n.cssText;return le(t)})(e):e,{is:fe,defineProperty:pe,getOwnPropertyDescriptor:me,getOwnPropertyNames:he,getOwnPropertySymbols:ge,getPrototypeOf:_e}=Object,ve=globalThis,ye=ve.trustedTypes,be=ye?ye.emptyScript:``,xe=ve.reactiveElementPolyfillSupport,Se=(e,t)=>e,Ce={toAttribute(e,t){switch(t){case Boolean:e=e?be:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},we=(e,t)=>!fe(e,t),Te={attribute:!0,type:String,converter:Ce,reflect:!1,useDefault:!1,hasChanged:we};Symbol.metadata??=Symbol(`metadata`),ve.litPropertyMetadata??=new WeakMap;var Ee=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Te){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let n=Symbol(),r=this.getPropertyDescriptor(e,n,t);r!==void 0&&pe(this.prototype,e,r)}}static getPropertyDescriptor(e,t,n){let{get:r,set:i}=me(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:r,set(t){let a=r?.call(this);i?.call(this,t),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Te}static _$Ei(){if(this.hasOwnProperty(Se(`elementProperties`)))return;let e=_e(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Se(`finalized`)))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Se(`properties`))){let e=this.properties,t=[...he(e),...ge(e)];for(let n of t)this.createProperty(n,e[n])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let n=this._$Eu(e,t);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let e of n)t.unshift(de(e))}else e!==void 0&&t.push(de(e));return t}static _$Eu(e,t){let n=t.attribute;return!1===n?void 0:typeof n==`string`?n:typeof e==`string`?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return ue(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){let n=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,n);if(r!==void 0&&!0===n.reflect){let i=(n.converter?.toAttribute===void 0?Ce:n.converter).toAttribute(t,n.type);this._$Em=e,i==null?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(e,t){let n=this.constructor,r=n._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let e=n.getPropertyOptions(r),i=typeof e.converter==`function`?{fromAttribute:e.converter}:e.converter?.fromAttribute===void 0?Ce:e.converter;this._$Em=r;let a=i.fromAttribute(t,e.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,n,r=!1,i){if(e!==void 0){let a=this.constructor;if(!1===r&&(i=this[e]),n??=a.getPropertyOptions(e),!((n.hasChanged??we)(i,t)||n.useDefault&&n.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(a._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:n,reflect:r,wrapped:i},a){n&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,a??t??this[e]),!0!==i||a!==void 0)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===r&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}let e=this.constructor.elementProperties;if(e.size>0)for(let[t,n]of e){let{wrapped:e}=n,r=this[t];!0!==e||this._$AL.has(t)||r===void 0||this.C(t,void 0,n,r)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}};Ee.elementStyles=[],Ee.shadowRootOptions={mode:`open`},Ee[Se(`elementProperties`)]=new Map,Ee[Se(`finalized`)]=new Map,xe?.({ReactiveElement:Ee}),(ve.reactiveElementVersions??=[]).push(`2.1.2`);var De=globalThis,Oe=e=>e,ke=De.trustedTypes,Ae=ke?ke.createPolicy(`lit-html`,{createHTML:e=>e}):void 0,je=`$lit$`,Me=`lit$${Math.random().toFixed(9).slice(2)}$`,Ne=`?`+Me,Pe=`<${Ne}>`,Fe=document,Ie=()=>Fe.createComment(``),Le=e=>e===null||typeof e!=`object`&&typeof e!=`function`,Re=Array.isArray,ze=e=>Re(e)||typeof e?.[Symbol.iterator]==`function`,Be=`[
|
|
3
3
|
\f\r]`,Ve=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,He=/-->/g,Ue=/>/g,We=RegExp(`>|${Be}(?:([^\\s"'>=/]+)(${Be}*=${Be}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),Ge=/'/g,Ke=/"/g,qe=/^(?:script|style|textarea|title)$/i,Je=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),g=Je(1),Ye=Je(2),Xe=Symbol.for(`lit-noChange`),_=Symbol.for(`lit-nothing`),Ze=new WeakMap,Qe=Fe.createTreeWalker(Fe,129);function $e(e,t){if(!Re(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return Ae===void 0?t:Ae.createHTML(t)}var et=(e,t)=>{let n=e.length-1,r=[],i,a=t===2?`<svg>`:t===3?`<math>`:``,o=Ve;for(let t=0;t<n;t++){let n=e[t],s,c,l=-1,u=0;for(;u<n.length&&(o.lastIndex=u,c=o.exec(n),c!==null);)u=o.lastIndex,o===Ve?c[1]===`!--`?o=He:c[1]===void 0?c[2]===void 0?c[3]!==void 0&&(o=We):(qe.test(c[2])&&(i=RegExp(`</`+c[2],`g`)),o=We):o=Ue:o===We?c[0]===`>`?(o=i??Ve,l=-1):c[1]===void 0?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=c[3]===void 0?We:c[3]===`"`?Ke:Ge):o===Ke||o===Ge?o=We:o===He||o===Ue?o=Ve:(o=We,i=void 0);let d=o===We&&e[t+1].startsWith(`/>`)?` `:``;a+=o===Ve?n+Pe:l>=0?(r.push(s),n.slice(0,l)+je+n.slice(l)+Me+d):n+Me+(l===-2?t:d)}return[$e(e,a+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},tt=class e{constructor({strings:t,_$litType$:n},r){let i;this.parts=[];let a=0,o=0,s=t.length-1,c=this.parts,[l,u]=et(t,n);if(this.el=e.createElement(l,r),Qe.currentNode=this.el.content,n===2||n===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(i=Qe.nextNode())!==null&&c.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let e of i.getAttributeNames())if(e.endsWith(je)){let t=u[o++],n=i.getAttribute(e).split(Me),r=/([.?@])?(.*)/.exec(t);c.push({type:1,index:a,name:r[2],strings:n,ctor:r[1]===`.`?ot:r[1]===`?`?st:r[1]===`@`?ct:at}),i.removeAttribute(e)}else e.startsWith(Me)&&(c.push({type:6,index:a}),i.removeAttribute(e));if(qe.test(i.tagName)){let e=i.textContent.split(Me),t=e.length-1;if(t>0){i.textContent=ke?ke.emptyScript:``;for(let n=0;n<t;n++)i.append(e[n],Ie()),Qe.nextNode(),c.push({type:2,index:++a});i.append(e[t],Ie())}}}else if(i.nodeType===8)if(i.data===Ne)c.push({type:2,index:a});else{let e=-1;for(;(e=i.data.indexOf(Me,e+1))!==-1;)c.push({type:7,index:a}),e+=Me.length-1}a++}}static createElement(e,t){let n=Fe.createElement(`template`);return n.innerHTML=e,n}};function nt(e,t,n=e,r){if(t===Xe)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=Le(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,r)),r===void 0?n._$Cl=i:(n._$Co??=[])[r]=i),i!==void 0&&(t=nt(e,i._$AS(e,t.values),i,r)),t}var rt=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,r=(e?.creationScope??Fe).importNode(t,!0);Qe.currentNode=r;let i=Qe.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new it(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new lt(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=Qe.nextNode(),a++)}return Qe.currentNode=Fe,r}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings===void 0?n._$AI(e[t]):(n._$AI(e,n,t),t+=n.strings.length-2)),t++}},it=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=_,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=nt(this,e,t),Le(e)?e===_||e==null||e===``?(this._$AH!==_&&this._$AR(),this._$AH=_):e!==this._$AH&&e!==Xe&&this._(e):e._$litType$===void 0?e.nodeType===void 0?ze(e)?this.k(e):this._(e):this.T(e):this.$(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==_&&Le(this._$AH)?this._$AA.nextSibling.data=e:this.T(Fe.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,r=typeof n==`number`?this._$AC(e):(n.el===void 0&&(n.el=tt.createElement($e(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new rt(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=Ze.get(e.strings);return t===void 0&&Ze.set(e.strings,t=new tt(e)),t}k(t){Re(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let a of t)i===n.length?n.push(r=new e(this.O(Ie()),this.O(Ie()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let t=Oe(e).nextSibling;Oe(e).remove(),e=t}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},at=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=_,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||n[0]!==``||n[1]!==``?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=_}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=nt(this,e,t,0),a=!Le(e)||e!==this._$AH&&e!==Xe,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=nt(this,r[n+o],t,o),s===Xe&&(s=this._$AH[o]),a||=!Le(s)||s!==this._$AH[o],s===_?e=_:e!==_&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===_?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},ot=class extends at{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===_?void 0:e}},st=class extends at{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==_)}},ct=class extends at{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=nt(this,e,t,0)??_)===Xe)return;let n=this._$AH,r=e===_&&n!==_||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==_&&(n===_||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH==`function`?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},lt=class{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){nt(this,e)}},ut={M:je,P:Me,A:Ne,C:1,L:et,R:rt,D:ze,V:nt,I:it,H:at,N:st,U:ct,B:ot,F:lt},dt=De.litHtmlPolyfillSupport;dt?.(tt,it),(De.litHtmlVersions??=[]).push(`3.3.3`);var ft=(e,t,n)=>{let r=n?.renderBefore??t,i=r._$litPart$;if(i===void 0){let e=n?.renderBefore??null;r._$litPart$=i=new it(t.insertBefore(Ie(),e),e,void 0,n??{})}return i._$AI(e),i},pt=globalThis,v=class extends Ee{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=ft(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Xe}};v._$litElement$=!0,v.finalized=!0,pt.litElementHydrateSupport?.({LitElement:v});var mt=pt.litElementPolyfillSupport;mt?.({LitElement:v}),(pt.litElementVersions??=[]).push(`4.2.2`);function ht(e){return e.placeholderOutstanding===!0?`replace`:e.lastWriteAt===void 0?`push`:e.now-e.lastWriteAt<400?`replace`:`push`}var gt,_t=!1;function vt(){_t=!0}function yt(){_t=!1}function bt(e,t,n=Date.now()){let r=t?`replace`:ht({lastWriteAt:gt,now:n,placeholderOutstanding:_t});gt=n,_t=!1,r===`replace`?window.history.replaceState({},``,e):window.history.pushState({},``,e)}var xt=1500;function St(e){if(e.next!==``)return{kind:`show`,text:e.next};if(e.shownAt===void 0)return{kind:`hide`};let t=e.now-e.shownAt;return t>=1500?{kind:`hide`}:{kind:`hold`,retryInMs:xt-t}}function Ct(e,t,n){return e.machine===t.machine&&e.project===t.project&&e.workspace===t.workspace&&e.session===t.session&&(e.view??n)===(t.view??n)}var wt=[`(display-mode: standalone)`,`(display-mode: fullscreen)`,`(display-mode: minimal-ui)`];function Tt(){return typeof window>`u`||!(`matchMedia`in window)?[]:wt.map(e=>window.matchMedia(e))}function Et(e,t=Dt()){return e.some(e=>e.matches)||Ot(t)}function Dt(){return typeof navigator>`u`?void 0:navigator}function Ot(e){return e!==void 0&&`standalone`in e&&e.standalone===!0}var kt=class{constructor(e=At()){this.scheduler=e}repair(e){if(!e){this.clear();return}this.resetViewportScroll(),this.repairFrame!==void 0&&this.scheduler.cancelAnimationFrame(this.repairFrame),this.repairFrame=this.scheduler.requestAnimationFrame(()=>{this.repairFrame=void 0,this.resetViewportScroll(),this.repairFrame=this.scheduler.requestAnimationFrame(()=>{this.repairFrame=void 0,this.resetViewportScroll()})}),this.repairTimer!==void 0&&this.scheduler.clearTimeout(this.repairTimer),this.repairTimer=this.scheduler.setTimeout(()=>{this.repairTimer=void 0,this.resetViewportScroll()},250)}clear(){this.repairFrame!==void 0&&(this.scheduler.cancelAnimationFrame(this.repairFrame),this.repairFrame=void 0),this.repairTimer!==void 0&&(this.scheduler.clearTimeout(this.repairTimer),this.repairTimer=void 0)}resetViewportScroll(){this.scheduler.scrollTo(0,0);let e=this.scheduler.documentElement;e!==void 0&&(e.scrollTop=0);let t=this.scheduler.body;t!==void 0&&(t.scrollTop=0)}};function At(){return{requestAnimationFrame(e){return window.requestAnimationFrame(e)},cancelAnimationFrame(e){window.cancelAnimationFrame(e)},setTimeout(e,t){return window.setTimeout(e,t)},clearTimeout(e){window.clearTimeout(e)},scrollTo(e,t){window.scrollTo(e,t)},get documentElement(){return typeof document>`u`?void 0:document.documentElement},get body(){return typeof document>`u`?void 0:document.body}}}var jt=`(max-width: 760px)`,Mt=class{constructor(e,t={}){this.host=e,this.onMobileNavigationMediaChange=e=>{this.isMobileNavigationLayout!==e.matches&&(this.isMobileNavigationLayout=e.matches,this.host.requestUpdate())},this.onPwaDisplayModeChange=()=>{let e=Et(this.pwaDisplayModeMedia);this.isPwaDisplayMode!==e&&(this.isPwaDisplayMode=e,this.host.requestUpdate())},e.addController(this),this.mobileNavigationMedia=t.mobileNavigationMedia??Nt(),this.pwaDisplayModeMedia=t.pwaDisplayModeMedia??Tt(),this.viewportPositionRepairer=t.viewportPositionRepairer??new kt,this.isMobileNavigationLayout=this.mobileNavigationMedia?.matches??!1,this.isPwaDisplayMode=Et(this.pwaDisplayModeMedia)}hostConnected(){this.mobileNavigationMedia?.addEventListener(`change`,this.onMobileNavigationMediaChange);for(let e of this.pwaDisplayModeMedia)e.addEventListener(`change`,this.onPwaDisplayModeChange)}hostDisconnected(){this.mobileNavigationMedia?.removeEventListener(`change`,this.onMobileNavigationMediaChange);for(let e of this.pwaDisplayModeMedia)e.removeEventListener(`change`,this.onPwaDisplayModeChange);this.viewportPositionRepairer.clear()}shouldAutoFocusPrompt(){return!this.isMobileNavigationLayout&&!this.isPwaDisplayMode}shouldShowAppRefreshInHeader(){return this.isPwaDisplayMode&&!this.isMobileNavigationLayout}shouldShowAppRefreshInContextBar(){return this.isPwaDisplayMode&&this.isMobileNavigationLayout}defaultRouteView(e={}){return Pt(this.isMobileNavigationLayout,e)}repairViewportPosition(){this.viewportPositionRepairer.repair(this.shouldRepairViewportPosition())}shouldRepairViewportPosition(){return this.isMobileNavigationLayout||this.isPwaDisplayMode}};function Nt(){if(!(typeof window>`u`||!(`matchMedia`in window)))return window.matchMedia(jt)}function Pt(e,t){return e&&(t.sessionId??``)===``?`navigation`:`chat`}function Ft(e){return!e.touchPrimary&&!e.modalOpen}var It=new Set([`text`,`search`,`email`,`url`,`tel`,`password`,`number`,void 0]);function Lt(e){if(e===void 0)return!1;if(e.isContentEditable===!0)return!0;let t=e.tagName.toUpperCase();return t===`TEXTAREA`||t===`INPUT`&&It.has(e.type)}function Rt(e=document){let t=e.activeElement;t!==null&&Lt({tagName:t.tagName,...t instanceof HTMLInputElement?{type:t.type}:{},...t instanceof HTMLElement?{isContentEditable:t.isContentEditable}:{}})&&t instanceof HTMLElement&&t.blur()}function zt(e){return e.touchPrimary?void 0:`input`}function Bt(e=window){return typeof e.matchMedia==`function`&&e.matchMedia(`(pointer: coarse)`).matches}var y=e=>(t,n)=>{n===void 0?customElements.define(e,t):n.addInitializer(()=>{customElements.define(e,t)})},Vt={attribute:!0,type:String,converter:Ce,reflect:!1,hasChanged:we},Ht=(e=Vt,t,n)=>{let{kind:r,metadata:i}=n,a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),r===`setter`&&((e=Object.create(e)).wrapped=!0),a.set(n.name,e),r===`accessor`){let{name:r}=n;return{set(n){let i=t.get.call(this);t.set.call(this,n),this.requestUpdate(r,i,e,!0,n)},init(t){return t!==void 0&&this.C(r,void 0,e,t),t}}}if(r===`setter`){let{name:r}=n;return function(n){let i=this[r];t.call(this,n),this.requestUpdate(r,i,e,!0,n)}}throw Error(`Unsupported decorator location: `+r)};function b(e){return(t,n)=>typeof n==`object`?Ht(e,t,n):((e,t,n)=>{let r=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),r?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}function x(e){return b({...e,state:!0,attribute:!1})}var Ut=(e,t,n)=>(n.configurable=!0,n.enumerable=!0,Reflect.decorate&&typeof t!=`object`&&Object.defineProperty(e,t,n),n);function S(e,t){return(n,r,i)=>{let a=t=>t.renderRoot?.querySelector(e)??null;if(t){let{get:e,set:t}=typeof r==`object`?n:i??(()=>{let e=Symbol();return{get(){return this[e]},set(t){this[e]=t}}})();return Ut(n,r,{get(){let n=e.call(this);return n===void 0&&(n=a(this),(n!==null||this.hasUpdated)&&t.call(this,n)),n}})}return Ut(n,r,{get(){return a(this)}})}}function Wt(e,t=Kt()){let n=new URL(t.viteBaseUrl,t.documentBaseUrl);return new URL(qt(e),n).toString()}function Gt(e,t=Kt()){let n=new URL(Wt(e,t));if(n.protocol===`http:`)n.protocol=`ws:`;else if(n.protocol===`https:`)n.protocol=`wss:`;else throw Error(`Cannot create a WebSocket URL from ${n.protocol}`);return n.toString()}function Kt(){return{viteBaseUrl:`./`,documentBaseUrl:document.baseURI}}function qt(e){return e.startsWith(`/`)?`.${e}`:e}var Jt;function Yt(e){Jt=e}function Xt(){let e=Jt;if(e!==void 0)try{e()}catch{}}var Zt=class extends Error{constructor(e,t){super(e),this.status=t,this.name=`HttpError`}};function Qt(e){return e instanceof Zt&&e.status===404}async function C(e,t,n){let r=new Headers(n?.headers);n?.body!==void 0&&!r.has(`content-type`)&&r.set(`content-type`,`application/json`);let i=await fetch(Wt(e),{...n,headers:r});if(!i.ok)throw new Zt($t(await i.json().catch(()=>({})))??i.statusText,i.status);let a=await i.json();return Xt(),t(a)}function $t(e){if(en(e))return typeof e.error==`string`?e.error:void 0}function en(e){return typeof e==`object`&&!!e}var tn={pluginLifecycle:`plugins.lifecycle`},nn=1e3,rn=32*1024,an=8*1024,on=1e3,sn=4e3,cn=1e3,ln=8e3,un=4e3,dn=1e4,fn={working:`core:working`,terminal:`core:terminal`,unread:`core:unread`};function pn(e){if(!gn(e))return;let t=e.epochId,n=e.revision,r=e.generatedAt,i=mn(e.machine),a=mn(e.unattributed),o=hn(e.projects),s=hn(e.workspaces);if(!(typeof t!=`string`||t===``)&&!(typeof n!=`number`||!Number.isFinite(n))&&!(typeof r!=`string`||r===``)&&!(i===void 0||a===void 0)&&!(o===void 0||s===void 0))return{epochId:t,revision:n,machine:i,projects:o,workspaces:s,unattributed:a,generatedAt:r}}function mn(e){if(!gn(e))return;let t=new Map;for(let[n,r]of Object.entries(e))typeof r==`boolean`&&t.set(n,r);return Object.fromEntries(t)}function hn(e){if(!gn(e))return;let t=new Map;for(let[n,r]of Object.entries(e)){let e=mn(r);e!==void 0&&t.set(n,e)}return Object.fromEntries(t)}function gn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var _n=Object.values(tn),vn=new Set(_n);tn.pluginLifecycle,tn.pluginLifecycle;function yn(e){return typeof e==`string`&&vn.has(e)}function bn(e,t){return e?.capabilities?.includes(t)===!0}function xn(e){if(!(!Array.isArray(e)||!e.every(e=>typeof e==`string`)))return e.filter(yn)}function Sn(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(!Cn(n))continue;let e=n.source,r=n.name,i=n.replacement;e!==`environment`&&e!==`config`||typeof r!=`string`||r===``||i!==void 0&&(typeof i!=`string`||i===``)||t.push({source:e,name:r,...i===void 0?{}:{replacement:i}})}return t}function Cn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var wn=/^[a-z][a-z0-9.-]*$/u,Tn=new Set([`core`,`themes`]),En=`machine.`;function Dn(e){return wn.test(e)}function On(e){return Tn.has(e)||e.startsWith(En)}var kn=Object.freeze({showSafeStart:`pi-web plugins safe-start show`,bundledOnly:`pi-web plugins safe-start set bundled-only --restart`,noServerPlugins:`pi-web plugins safe-start set none --restart`,clearSafeStart:`pi-web plugins safe-start clear --restart`});function An(e){if(!Dn(e))throw Error(`Invalid PI WEB plugin id: ${e}`);return`pi-web plugins disable ${e} --restart`}function w(e){return typeof e==`object`&&!!e}function T(e){if(!w(e))throw Error(`Expected object response`);return e}function E(e,t){let n=e[t];if(typeof n!=`string`)throw Error(`Expected string field: ${t}`);return n}function D(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`string`)throw Error(`Expected optional string field: ${t}`);return n}}function O(e,t){let n=e[t];if(typeof n!=`number`)throw Error(`Expected number field: ${t}`);return n}function k(e,t){let n=e[t];if(typeof n!=`boolean`)throw Error(`Expected boolean field: ${t}`);return n}function A(e){return t=>{if(!Array.isArray(t))throw Error(`Expected array response`);return t.map(e)}}function jn(e){if(!Array.isArray(e))throw Error(`Expected array response`);return e}function Mn(e,t){if(!Array.isArray(e)||!e.every(e=>typeof e==`string`))throw Error(`Expected string array field: ${t}`);return e}function Nn(e){let t=T(e);return{messages:jn(t.messages),start:O(t,`start`),total:O(t,`total`)}}function Pn(e){let t=T(e);return A(Fn)(t.machines)}function Fn(e){let t=T(e),n=zn(t,`kind`),r=D(t,`baseUrl`),i=Bn(t,`status`),a=D(t,`statusMessage`);return{id:E(t,`id`),name:E(t,`name`),kind:n,...r===void 0?{}:{baseUrl:r},createdAt:E(t,`createdAt`),updatedAt:E(t,`updatedAt`),...i===void 0?{}:{status:i},...a===void 0?{}:{statusMessage:a}}}function In(e){let t=T(e),n=Bn(t,`status`),r=D(t,`error`);return{machineId:E(t,`machineId`),ok:k(t,`ok`),checkedAt:E(t,`checkedAt`),...n===void 0?{}:{status:n},...t.web===void 0?{}:{web:qa(t.web)},...t.sessiond===void 0?{}:{sessiond:qa(t.sessiond)},...r===void 0?{}:{error:r}}}function Ln(e){let t=T(e),n=D(t,`error`);return{machineId:E(t,`machineId`),ok:k(t,`ok`),checkedAt:E(t,`checkedAt`),...M(`packageName`,D(t,`packageName`)),...M(`generatedAt`,D(t,`generatedAt`)),...t.components===void 0?{}:{components:Ga(t.components)},...t.capabilities===void 0?{}:{capabilities:$a(t.capabilities)},...t.deprecatedAgentInputs===void 0?{}:{deprecatedAgentInputs:Rn(t.deprecatedAgentInputs)},...n===void 0?{}:{error:n}}}function Rn(e){let t=Sn(e);if(t===void 0)throw Error(`Invalid PI WEB deprecated agent inputs`);return t}function zn(e,t){let n=E(e,t);if(n!==`local`&&n!==`remote`)throw Error(`Expected machine kind field: ${t}`);return n}function Bn(e,t){let n=D(e,t);if(n!==void 0){if(n!==`unknown`&&n!==`online`&&n!==`offline`&&n!==`error`)throw Error(`Expected machine status field: ${t}`);return n}}function Vn(e){let t=T(e);return{id:E(t,`id`),name:E(t,`name`),path:E(t,`path`),createdAt:E(t,`createdAt`)}}function Hn(e){let t=T(e);return Object.freeze({id:E(t,`id`),projectId:E(t,`projectId`),path:E(t,`path`),label:E(t,`label`),isMain:k(t,`isMain`),...M(`provider`,Jn(t.provider)),...M(`removal`,Yn(t.removal)),effectiveConfig:Qn(t.effectiveConfig)})}function Un(e){let t=T(e),n=Wn(t.status),r=E(t,`projectId`),i=D(t,`ownerPluginId`);if(n===`provider`&&i===void 0)throw Error(`Provider workspace resolution is missing ownerPluginId`);if(n===`folder`&&i!==void 0)throw Error(`Folder workspace resolution must not include ownerPluginId`);let a=A(Hn)(t.workspaces);if(a.length===0||a.some(e=>e.projectId!==r))throw Error(`Workspace resolution contains invalid project workspaces`);let o=A(Gn)(t.diagnostics);return Object.freeze({status:n,projectId:r,...i===void 0?{}:{ownerPluginId:i},workspaces:Object.freeze(a),diagnostics:Object.freeze(o)})}function Wn(e){if(e===`provider`||e===`folder`||e===`degraded`)return e;throw Error(`Invalid workspace provider resolution status`)}function Gn(e){let t=T(e),n=D(t,`pluginId`),r=t.pluginIds===void 0?void 0:Mn(t.pluginIds,`pluginIds`);return Object.freeze({code:Kn(t.code),message:E(t,`message`),tier:qn(t.tier),...n===void 0?{}:{pluginId:n},...r===void 0?{}:{pluginIds:Object.freeze(r)}})}function Kn(e){if(e===`probe-failed`||e===`claim-conflict`||e===`list-failed`)return e;throw Error(`Invalid workspace provider diagnostic code`)}function qn(e){if(e===`primary`||e===`fallback`)return e;throw Error(`Invalid workspace provider diagnostic tier`)}function Jn(e){if(e===void 0)return;if(!w(e)||Array.isArray(e))throw Error(`Invalid workspace provider field`);let t=e.capabilities;if(!w(t)||Array.isArray(t))throw Error(`Invalid workspace provider capabilities field`);let n=e.metadata;return Object.freeze({pluginId:E(e,`pluginId`),capabilities:Object.freeze({request:k(t,`request`),remove:k(t,`remove`)}),...M(`metadata`,n===void 0?void 0:Xn(n,`workspace provider metadata`))})}function Yn(e){if(e!==void 0){if(!w(e)||Array.isArray(e))throw Error(`Invalid workspace removal field`);return Object.freeze({actionLabel:j(e,`actionLabel`),confirmation:j(e,`confirmation`),precondition:j(e,`precondition`)})}}function Xn(e,t){if(!w(e)||Array.isArray(e))throw Error(`Invalid ${t} field`);return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Zn(n,t)])))}function Zn(e,t){if(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e))return e;if(Array.isArray(e))return Object.freeze(e.map(e=>Zn(e,t)));if(w(e))return Xn(e,t);throw Error(`Invalid ${t} field`)}function Qn(e){if(!w(e)||Array.isArray(e))throw Error(`Expected workspace effectiveConfig field`);let t=xa(e.uploads);return Object.freeze({...M(`uploads`,t===void 0?void 0:Object.freeze({...t}))})}function $n(e){let t=T(e),n=D(t,`name`),r=Va(t.persisted,`persisted`),i=D(t,`parentSessionPath`),a=D(t,`archivedAt`);return{id:E(t,`id`),path:E(t,`path`),cwd:E(t,`cwd`),...r===void 0?{}:{persisted:r},...n===void 0?{}:{name:n},created:E(t,`created`),modified:E(t,`modified`),messageCount:O(t,`messageCount`),firstMessage:E(t,`firstMessage`),...i===void 0?{}:{parentSessionPath:i},...t.archived===!0?{archived:!0}:{},...a===void 0?{}:{archivedAt:a}}}function er(e){if(e!==`info`&&e!==`warning`&&e!==`error`)throw Error(`Invalid session warning severity`);return e}function tr(e){if(e!==void 0)return{id:E(T(e),`id`)}}function nr(e){let t=T(e),n=tr(t.dismiss);return{severity:er(t.severity),message:E(t,`message`),...M(`source`,D(t,`source`)),...M(`path`,D(t,`path`)),...n===void 0?{}:{dismiss:n}}}function rr(e){return e===void 0?{}:{warnings:A(nr)(e)}}function ir(e){let t=T(e);return{value:qr(t,`value`,128),label:qr(t,`label`,on),...M(`detail`,Jr(t,`detail`,on))}}function ar(e){let t=T(e),n=ai(t.options,ir,12,`options`);hr(n.map(e=>e.value),`ask option value`);let r=Va(t.multiple,`multiple`);return{id:qr(t,`id`,128),question:qr(t,`question`,on),...M(`detail`,Jr(t,`detail`,on)),options:n,...r===void 0?{}:{multiple:r}}}function or(e){let t=T(e),n=ai(t.questions,ar,20,`questions`);if(n.length===0)throw Error(`Pending ask has no questions`);return hr(n.map(e=>e.id),`ask question id`),{askId:qr(t,`askId`,128),askedAt:j(t,`askedAt`),questions:n}}function sr(e){return e===void 0?{}:{pendingAsk:or(e)}}function cr(e){let t=T(e);if(t.type!==`ask.opened`)throw Error(`Invalid ask opened event type`);return{type:`ask.opened`,ask:or(t.ask)}}function lr(e){let t=T(e);if(t.type!==`ask.closed`)throw Error(`Invalid ask closed event type`);return{type:`ask.closed`,askId:qr(t,`askId`,128),reason:ur(t.reason)}}function ur(e){if(e!==`submitted`&&e!==`superseded`&&e!==`cancelled`)throw Error(`Invalid ask close reason`);return e}function dr(e){let t=T(e),n=ar(t.question),r=ai(t.values,oi,12,`values`),i=new Set(n.options.map(e=>e.value));if(r.some(e=>!i.has(e)))throw Error(`Ask answer selected an option the question never offered`);let a=Jr(t,`otherText`,sn),o=k(t,`answered`);if(o!==(r.length>0||a!==void 0))throw Error(`Ask answer contradicts its answered flag`);return{question:n,answered:o,values:r,...a===void 0?{}:{otherText:a}}}function fr(e){let t=T(e),n=ai(t.questions,dr,20,`questions`),r=si(t,`answeredCount`),i=Mn(t.unansweredIds,`unansweredIds`),a=n.filter(e=>!e.answered).map(e=>e.question.id);if(r!==n.length-a.length)throw Error(`Ask outcome answered count mismatch`);if(i.length!==a.length||i.some((e,t)=>e!==a[t]))throw Error(`Ask outcome unanswered ids mismatch`);return{askId:qr(t,`askId`,128),reason:ur(t.reason),askedAt:j(t,`askedAt`),closedAt:j(t,`closedAt`),questions:n,answeredCount:r,unansweredIds:i,summary:j(t,`summary`)}}function pr(e){let t=T(e),n=t.result;if(n!==`closed`&&n!==`stale`)throw Error(`Invalid ask close result`);let r=t.outcome===void 0?void 0:fr(t.outcome);if(n===`closed`!=(r!==void 0))throw Error(`Ask close response outcome mismatch`);return{result:n,...r===void 0?{}:{outcome:r},sessionStatus:Er(t.sessionStatus)}}function mr(e){let t=T(e),n=t.result;if(n!==`closed`&&n!==`stale`)throw Error(`Invalid dialog close result`);let r=t.outcome===void 0?void 0:wr(t.outcome);if(n===`closed`!=(r!==void 0))throw Error(`Dialog close response outcome mismatch`);return{result:n,...r===void 0?{}:{outcome:r},sessionStatus:Er(t.sessionStatus)}}function hr(e,t){if(new Set(e).size!==e.length)throw Error(`Duplicate ${t}`)}function gr(e){if(e!==`confirm`&&e!==`select`&&e!==`input`)throw Error(`Invalid extension dialog kind`);return e}function _r(e){if(e!==`answered`&&e!==`cancelled`&&e!==`timeout`&&e!==`aborted`&&e!==`session-ended`)throw Error(`Invalid extension dialog close reason`);return e}function vr(e){if(typeof e==`boolean`||typeof e==`string`&&e.length<=4e3)return e;throw Error(`Invalid extension dialog answer`)}function yr(e){let t=oi(e);if(t.length>1e3)throw Error(`String field exceeds limit: option`);return t}function br(e){let t=T(e),n=gr(t.kind),r=t.options===void 0?void 0:ai(t.options,yr,24,`options`);if(r!==void 0&&hr(r,`dialog option`),n===`select`&&(r===void 0||r.length===0))throw Error(`Select dialog has no options`);return{dialogId:qr(t,`dialogId`,128),kind:n,title:qr(t,`title`,ln),...M(`message`,Jr(t,`message`,ln)),...r===void 0?{}:{options:r},...M(`placeholder`,Jr(t,`placeholder`,cn)),askedAt:j(t,`askedAt`),...M(`timeoutAt`,Tr(t,`timeoutAt`)),runScoped:k(t,`runScoped`)}}function xr(e){if(e===void 0)return{};let t=A(br)(e);return hr(t.map(e=>e.dialogId),`dialog id`),{pendingDialogs:t}}function Sr(e){let t=T(e);if(t.type!==`dialog.opened`)throw Error(`Invalid dialog opened event type`);return{type:`dialog.opened`,dialog:br(t.dialog)}}function Cr(e){let t=T(e);if(t.type!==`dialog.closed`)throw Error(`Invalid dialog closed event type`);let n=_r(t.reason),r=t.answer===void 0?void 0:vr(t.answer);if(n===`answered`!=(r!==void 0))throw Error(`Dialog closed event answer mismatch`);return{type:`dialog.closed`,dialogId:qr(t,`dialogId`,128),reason:n,...r===void 0?{}:{answer:r}}}function wr(e){let t=T(e),n=_r(t.reason),r=t.answer===void 0?void 0:vr(t.answer);if(n===`answered`!=(r!==void 0))throw Error(`Dialog outcome answer mismatch`);return{dialogId:qr(t,`dialogId`,128),reason:n,...r===void 0?{}:{answer:r},askedAt:j(t,`askedAt`),closedAt:j(t,`closedAt`)}}function Tr(e,t){let n=D(e,t);if(n!==void 0){if(n===``)throw Error(`Expected non-empty string field: ${t}`);return n}}function Er(e){let t=T(e);return{sessionId:E(t,`sessionId`),...M(`persisted`,Va(t.persisted,`persisted`)),isStreaming:k(t,`isStreaming`),isCompacting:k(t,`isCompacting`),isBashRunning:k(t,`isBashRunning`),pendingMessageCount:O(t,`pendingMessageCount`),...M(`backgroundRunCount`,To(t,`backgroundRunCount`)),queuedMessages:t.queuedMessages===void 0?[]:A(bi)(t.queuedMessages),...M(`messageCount`,To(t,`messageCount`)),tokens:xi(t.tokens),cost:O(t,`cost`),...Ci(t.model),...Ui(t.contextUsage),...M(`thinkingLevel`,D(t,`thinkingLevel`)),...rr(t.warnings),...sr(t.pendingAsk),...xr(t.pendingDialogs)}}function Dr(e){let t=T(e);return{seq:O(t,`seq`),partial:t.partial??null}}function Or(e){let t=T(e),n=t.subtasks===void 0?[]:A(Or)(t.subtasks);return{id:E(t,`id`),title:E(t,`title`),status:E(t,`status`),...M(`verificationContract`,D(t,`verificationContract`)),...n.length===0?{}:{subtasks:n}}}function kr(e){let t=T(e);return{id:E(t,`id`),objective:E(t,`objective`),status:E(t,`status`),path:E(t,`path`),sisyphus:k(t,`sisyphus`),autoContinue:k(t,`autoContinue`),...M(`createdAt`,D(t,`createdAt`)),...M(`updatedAt`,D(t,`updatedAt`)),...M(`currentTaskId`,D(t,`currentTaskId`)),...M(`stopReason`,D(t,`stopReason`)),...M(`pauseReason`,D(t,`pauseReason`)),...M(`verificationContract`,D(t,`verificationContract`)),...M(`tokensUsed`,To(t,`tokensUsed`)),...M(`activeSeconds`,To(t,`activeSeconds`)),tasks:A(Or)(t.tasks),completedTaskCount:O(t,`completedTaskCount`),totalTaskCount:O(t,`totalTaskCount`)}}function Ar(e){let t=T(e);return{goals:A(kr)(t.goals),directory:E(t,`directory`),generatedAt:E(t,`generatedAt`)}}function jr(e){let t=T(e),n=A(Er)(t.statuses),r=new Set;for(let e of n){if(r.has(e.sessionId))throw Error(`Duplicate session status in catalog`);r.add(e.sessionId)}return{statuses:n,generatedAt:E(t,`generatedAt`)}}function Mr(e){let t=T(e),n=si(t,`catalogRevision`),r=ai(t.sessions,Wr,nn,`sessions`);if(Gr(r),Kr(r),r.some(e=>e.completionOrder>n))throw Error(`Session unread completion order exceeds catalog revision`);return{catalogId:qr(t,`catalogId`,512),catalogRevision:n,sessions:r}}function Nr(e){let t=T(e);if(t.type!==`sessions.unread`)throw Error(`Invalid session unread event type`);let n=qr(t,`sessionId`,512),r=qr(t,`cwd`,rn),i=Yr(t,`catalogRevision`),a=t.unread===null?null:Wr(t.unread);if(a!==null&&(a.sessionId!==n||a.cwd!==r))throw Error(`Session unread event identity mismatch`);if(a!==null&&a.completionOrder>i)throw Error(`Session unread completion order exceeds catalog revision`);return{type:`sessions.unread`,catalogId:qr(t,`catalogId`,512),catalogRevision:i,sessionId:n,cwd:r,unread:a}}function Pr(e){let t=T(e);if(t.type!==`session.startup`)throw Error(`Invalid session startup event type`);let n=D(t,`startupToken`);if(n===``)throw Error(`Expected non-empty string field: startupToken`);return{type:`session.startup`,...M(`startupToken`,n),activity:Fr(t.activity)}}function Fr(e){let t=T(e);return{sessionId:j(t,`sessionId`),phase:Lr(t,`phase`),label:j(t,`label`),...M(`detail`,D(t,`detail`)),at:j(t,`at`),...M(`startup`,Ir(t))}}function Ir(e){let t=e.startup;if(t!==void 0){if(typeof t!=`boolean`)throw Error(`Expected optional boolean field: startup`);return t}}function Lr(e,t){let n=E(e,t);if(n!==`active`&&n!==`idle`&&n!==`error`)throw Error(`Expected session activity phase field: ${t}`);return n}function Rr(e){let t=T(e);switch(t.type){case`message.append`:return{type:`message.append`,message:Br(t,`message`),...M(`clientMessageId`,D(t,`clientMessageId`)),...t.echo===!0?{echo:!0}:{}};case`assistant.delta`:return{type:`assistant.delta`,text:E(t,`text`)};case`assistant.thinking.delta`:return{type:`assistant.thinking.delta`,text:E(t,`text`)};case`tool.start`:return{type:`tool.start`,toolName:E(t,`toolName`),toolCallId:E(t,`toolCallId`),summary:E(t,`summary`),...M(`args`,t.args)};case`tool.update`:return{type:`tool.update`,toolName:E(t,`toolName`),toolCallId:E(t,`toolCallId`),text:E(t,`text`),...M(`content`,t.content),...M(`details`,t.details)};case`tool.end`:return{type:`tool.end`,toolName:E(t,`toolName`),toolCallId:E(t,`toolCallId`),text:E(t,`text`),isError:k(t,`isError`),...M(`content`,t.content),...M(`details`,t.details)};case`shell.start`:return{type:`shell.start`,command:E(t,`command`),...M(`excludeFromContext`,Va(t.excludeFromContext,`excludeFromContext`))};case`shell.chunk`:return{type:`shell.chunk`,chunk:E(t,`chunk`)};case`shell.end`:return{type:`shell.end`,...M(`output`,D(t,`output`)),...M(`exitCode`,Vr(t,`exitCode`)),...M(`cancelled`,Va(t.cancelled,`cancelled`)),...M(`truncated`,Va(t.truncated,`truncated`)),...M(`fullOutputPath`,D(t,`fullOutputPath`)),...M(`isError`,Va(t.isError,`isError`))};case`agent.start`:return{type:`agent.start`};case`agent.end`:return{type:`agent.end`};case`message.end`:return{type:`message.end`,...M(`message`,t.message)};case`status.update`:return{type:`status.update`,status:Er(t.status)};case`activity.update`:return{type:`activity.update`,activity:Fr(t.activity)};case`command.output`:return Hr(t);case`session.error`:return{type:`session.error`,message:E(t,`message`)};case`session.name`:return Ur(t);case`session.created`:return{type:`session.created`,session:$n(t.session)};case`pi.event`:return{type:`pi.event`,eventType:E(t,`eventType`)};default:throw Error(`Unsupported session stream event type`)}}function zr(e){let t=T(e);switch(t.type){case`status.update`:return{type:`status.update`,status:Er(t.status)};case`activity.update`:return{type:`activity.update`,activity:Fr(t.activity)};case`session.name`:return Ur(t);case`session.created`:return{type:`session.created`,session:$n(t.session)};case`terminal.created`:return{type:`terminal.created`,terminal:ea(t.terminal)};case`terminal.exited`:return{type:`terminal.exited`,terminal:ea(t.terminal)};case`terminal.closed`:return{type:`terminal.closed`,terminalId:j(t,`terminalId`),cwd:j(t,`cwd`)};case`machine.status`:return{type:`machine.status`,status:ia(t.status)};default:throw Error(`Unsupported realtime stream event type`)}}function Br(e,t){let n=e[t];if(n===void 0)throw Error(`Expected field: ${t}`);return n}function Vr(e,t){let n=e[t];if(n!==void 0){if(n===null)return null;if(typeof n!=`number`)throw Error(`Expected optional number|null field: ${t}`);return n}}function Hr(e){let t=E(e,`level`);if(t!==`info`&&t!==`success`&&t!==`error`)throw Error(`Invalid command output level`);return{type:`command.output`,level:t,message:E(e,`message`)}}function Ur(e){return{type:`session.name`,sessionId:j(e,`sessionId`),...M(`name`,D(e,`name`))}}function Wr(e){let t=T(e),n=qr(t,`completedAt`,64),r=new Date(n);if(!Number.isFinite(r.getTime())||r.toISOString()!==n)throw Error(`Invalid canonical session unread completion time`);return{sessionId:qr(t,`sessionId`,512),cwd:qr(t,`cwd`,rn),completionOrder:Yr(t,`completionOrder`),completedAt:n}}function Gr(e){let t=e.map(e=>JSON.stringify([e.sessionId,e.cwd]));if(new Set(t).size!==t.length)throw Error(`Duplicate session unread identity`);let n=e.map(e=>e.completionOrder);if(new Set(n).size!==n.length)throw Error(`Duplicate session unread completion order`)}function Kr(e){for(let t=1;t<e.length;t+=1){let n=e[t-1],r=e[t];if(n===void 0||r===void 0||n.completionOrder<=r.completionOrder)throw Error(`Session unread summaries are not newest-first`)}}function qr(e,t,n){let r=j(e,t);if(r.length>n)throw Error(`String field exceeds limit: ${t}`);return r}function Jr(e,t,n){let r=D(e,t);if(r!==void 0){if(r===``)throw Error(`Expected non-empty string field: ${t}`);if(r.length>n)throw Error(`String field exceeds limit: ${t}`);return r}}function Yr(e,t){let n=si(e,t);if(n===0)throw Error(`Expected positive safe integer field: ${t}`);return n}function Xr(e){let t=T(e),n=Qr(t.summary),r=ai(t.notifications,$r,100,`notifications`);if(ci(r),li(r),n.retainedCount!==r.length)throw Error(`Notification snapshot retained count mismatch`);if(n.highestSeverity!==di(r))throw Error(`Notification snapshot severity mismatch`);let i=ei(t.dismissThrough),a=r[0]?.order??0;if(i.order!==a)throw Error(`Notification snapshot dismiss cutoff mismatch`);if(i.overflowWatermark<n.discardedCount)throw Error(`Notification snapshot overflow cutoff mismatch`);return{daemonInstanceId:j(t,`daemonInstanceId`),catalogRevision:si(t,`catalogRevision`),summary:n,notifications:r,dismissThrough:i}}function Zr(e){let t=T(e);if(t.type!==`notifications.inbox`)throw Error(`Invalid notification inbox event type`);let n=Qr(t.summary),r=ei(t.dismissThrough);if(r.overflowWatermark<n.discardedCount)throw Error(`Notification event overflow cutoff mismatch`);let i=ti(t.delta);if(i.kind===`cleared`&&!ui(n))throw Error(`Notification clear event summary mismatch`);if(i.kind===`added`&&n.retainedCount===0)throw Error(`Notification add event summary mismatch`);return{type:`notifications.inbox`,daemonInstanceId:j(t,`daemonInstanceId`),catalogRevision:si(t,`catalogRevision`),summary:n,dismissThrough:r,delta:i}}function Qr(e){let t=T(e),n=si(t,`retainedCount`);if(n>100)throw Error(`Notification retained count exceeds limit`);let r=si(t,`discardedCount`),i=ri(t.highestSeverity);if(n===0!=(i===void 0))throw Error(`Notification summary severity mismatch`);return{sessionId:j(t,`sessionId`),cwd:j(t,`cwd`),inboxRevision:si(t,`inboxRevision`),retainedCount:n,discardedCount:r,...i===void 0?{}:{highestSeverity:i}}}function $r(e){let t=T(e),n=E(t,`message`);if(new TextEncoder().encode(n).byteLength>8192)throw Error(`Notification message exceeds byte limit`);let r=E(t,`receivedAt`);if(!Number.isFinite(Date.parse(r)))throw Error(`Invalid notification receive time`);let i=si(t,`order`);if(i===0)throw Error(`Invalid notification order`);return{id:j(t,`id`),message:n,truncated:k(t,`truncated`),severity:ni(t.severity),receivedAt:r,order:i}}function ei(e){let t=T(e);return{order:si(t,`order`),overflowWatermark:si(t,`overflowWatermark`)}}function ti(e){let t=T(e);switch(t.kind){case`added`:{let e=D(t,`evictedNotificationId`);return{kind:`added`,notification:$r(t.notification),...e===void 0?{}:{evictedNotificationId:e}}}case`dismissed`:{let e=ai(t.notificationIds,oi,100,`notificationIds`);if(new Set(e).size!==e.length)throw Error(`Duplicate dismissed notification id`);return{kind:`dismissed`,notificationIds:e}}case`cleared`:return{kind:`cleared`,reason:ii(t.reason)};case`resync`:return{kind:`resync`};default:throw Error(`Invalid notification inbox delta`)}}function ni(e){if(e!==`info`&&e!==`warning`&&e!==`error`)throw Error(`Invalid notification severity`);return e}function ri(e){return e===void 0?void 0:ni(e)}function ii(e){switch(e){case`runtime-close`:case`archive`:case`delete`:case`restore`:case`archive-reconcile`:case`replacement`:case`initialization-failed`:case`service-dispose`:return e;default:throw Error(`Invalid notification clear reason`)}}function ai(e,t,n,r){if(!Array.isArray(e))throw Error(`Expected array field: ${r}`);if(e.length>n)throw Error(`Array field exceeds limit: ${r}`);return e.map(t)}function oi(e){if(typeof e!=`string`||e===``)throw Error(`Expected non-empty string`);return e}function j(e,t){let n=E(e,t);if(n===``)throw Error(`Expected non-empty string field: ${t}`);return n}function si(e,t){let n=e[t];if(typeof n!=`number`||!Number.isSafeInteger(n)||n<0)throw Error(`Expected non-negative safe integer field: ${t}`);return n}function ci(e){if(new Set(e.map(e=>e.id)).size!==e.length)throw Error(`Duplicate notification id`);if(new Set(e.map(e=>e.order)).size!==e.length)throw Error(`Duplicate notification order`)}function li(e){for(let t=1;t<e.length;t+=1){let n=e[t-1],r=e[t];if(n===void 0||r===void 0||n.order<=r.order)throw Error(`Notifications are not newest-first`)}}function ui(e){return e.retainedCount===0&&e.discardedCount===0}function di(e){let t;for(let n of e){if(n.severity===`error`)return`error`;n.severity===`warning`?t=`warning`:t??=`info`}return t}function fi(e){let t=T(e),n=t.skippedBusySessionIds===void 0?void 0:Mn(t.skippedBusySessionIds,`skippedBusySessionIds`);return{generatedAt:E(t,`generatedAt`),thresholds:_i(t.thresholds),projects:A(vi)(t.projects),totals:yi(t.totals),...n===void 0?{}:{skippedBusySessionIds:n}}}function pi(e){let t=T(e);return{...fi(t),archivedSessionIds:Mn(t.archivedSessionIds,`archivedSessionIds`),deletedSessionIds:Mn(t.deletedSessionIds,`deletedSessionIds`)}}function mi(e){let t=T(e);if(t.archived!==!0)throw Error(`Expected bulk archived response`);return{archived:!0,archivedSessionIds:Mn(t.archivedSessionIds,`archivedSessionIds`),failures:A(gi)(t.failures),generatedAt:E(t,`generatedAt`)}}function hi(e){let t=T(e);if(t.deleted!==!0)throw Error(`Expected bulk deleted response`);return{deleted:!0,deletedSessionIds:Mn(t.deletedSessionIds,`deletedSessionIds`),failures:A(gi)(t.failures),generatedAt:E(t,`generatedAt`)}}function gi(e){let t=T(e);return{sessionId:E(t,`sessionId`),error:E(t,`error`)}}function _i(e){let t=T(e);return{...M(`archiveIdleDays`,To(t,`archiveIdleDays`)),...M(`deleteArchivedDays`,To(t,`deleteArchivedDays`))}}function vi(e){let t=T(e);return{cwd:E(t,`cwd`),archiveCount:O(t,`archiveCount`),deleteCount:O(t,`deleteCount`)}}function yi(e){let t=T(e);return{archiveCount:O(t,`archiveCount`),deleteCount:O(t,`deleteCount`)}}function bi(e){let t=T(e),n=E(t,`kind`);if(n!==`steer`&&n!==`followUp`)throw Error(`Invalid queued message kind`);return{kind:n,text:E(t,`text`),...M(`clientMessageId`,D(t,`clientMessageId`))}}function xi(e){let t=T(e);return{input:O(t,`input`),output:O(t,`output`),cacheRead:O(t,`cacheRead`),cacheWrite:O(t,`cacheWrite`),total:O(t,`total`)}}function Si(e){let t=T(e);return{...M(`provider`,D(t,`provider`)),...M(`id`,D(t,`id`)),...M(`name`,D(t,`name`)),...M(`contextWindow`,To(t,`contextWindow`)),...M(`reasoning`,t.reasoning)}}function Ci(e){return e===void 0?{}:{model:Si(e)}}function wi(e){let t=T(e);return{models:A(Si)(t.models)}}function Ti(e){let t=T(e);return{provider:E(t,`provider`),id:E(t,`id`),...M(`name`,D(t,`name`)),...M(`contextWindow`,To(t,`contextWindow`)),...M(`reasoning`,t.reasoning),enabled:k(t,`enabled`)}}function Ei(e){let t=T(e);return{models:A(Ti)(t.models)}}function Di(e){if(typeof e!=`string`)throw Error(`Invalid thinking level`);return e}function Oi(e){let t=T(e);return{levels:A(Di)(t.levels)}}function ki(e){if(e!==`oauth`&&e!==`api_key`)throw Error(`Invalid auth type`);return e}function Ai(e){if(e!==`stored`&&e!==`runtime`&&e!==`environment`&&e!==`fallback`&&e!==`models_json_key`&&e!==`models_json_command`)throw Error(`Invalid auth status source`);return e}function ji(e){let t=T(e),n=t.source===void 0?void 0:Ai(t.source);return{configured:k(t,`configured`),...M(`source`,n),...M(`label`,D(t,`label`))}}function Mi(e){let t=T(e),n=t.loginFlow;if(n!==void 0&&n!==`interactive`)throw Error(`Invalid auth provider login flow`);return{id:E(t,`id`),name:E(t,`name`),authType:ki(t.authType),status:ji(t.status),...n===void 0?{}:{loginFlow:n}}}function Ni(e){let t=T(e);return{providers:A(Mi)(t.providers)}}function Pi(e){let t=T(e);return{flowId:E(t,`flowId`),providerId:E(t,`providerId`),providerName:E(t,`providerName`),status:Fi(t.status),progress:A(e=>{if(typeof e!=`string`)throw Error(`Expected progress item string`);return e})(t.progress),...M(`error`,D(t,`error`)),...M(`auth`,Ii(t.auth)),...M(`prompt`,Ri(t.prompt)),...M(`select`,Bi(t.select)),...M(`info`,Vi(t.info))}}function Fi(e){if(e!==`running`&&e!==`complete`&&e!==`error`&&e!==`cancelled`)throw Error(`Invalid OAuth flow status`);return e}function Ii(e){if(e===void 0)return;let t=T(e);return{url:E(t,`url`),...M(`instructions`,D(t,`instructions`)),...M(`deviceCode`,Li(t.deviceCode))}}function Li(e){if(e===void 0)return;let t=T(e);return{userCode:E(t,`userCode`),...M(`intervalSeconds`,To(t,`intervalSeconds`)),...M(`expiresInSeconds`,To(t,`expiresInSeconds`))}}function Ri(e){if(e===void 0)return;let t=T(e);return{requestId:E(t,`requestId`),message:E(t,`message`),promptType:zi(t.promptType),...M(`placeholder`,D(t,`placeholder`)),...M(`allowEmpty`,wo(t,`allowEmpty`))}}function zi(e){if(e!==`text`&&e!==`secret`&&e!==`manual_code`)throw Error(`Invalid OAuth prompt type`);return e}function Bi(e){if(e===void 0)return;let t=T(e);return{requestId:E(t,`requestId`),message:E(t,`message`),options:A(fo)(t.options)}}function Vi(e){if(e!==void 0)return A(e=>{let t=T(e);return{message:E(t,`message`),...M(`links`,t.links===void 0?void 0:A(Hi)(t.links))}})(e)}function Hi(e){let t=T(e);return{url:E(t,`url`),...M(`label`,D(t,`label`))}}function Ui(e){if(e===void 0)return{};let t=T(e);return{contextUsage:{tokens:Eo(t,`tokens`),contextWindow:O(t,`contextWindow`),percent:Eo(t,`percent`)}}}function Wi(e){let t=T(e),n=E(t,`source`);if(n!==`extension`&&n!==`prompt`&&n!==`skill`&&n!==`builtin`)throw Error(`Invalid command source`);return{name:E(t,`name`),source:n,...M(`description`,D(t,`description`))}}function Gi(e){let t=T(e),n=E(t,`kind`);if(n!==`tracked`&&n!==`untracked`&&n!==`other`)throw Error(`Invalid file kind`);return{path:E(t,`path`),kind:n}}function Ki(e){let t=T(e);return{path:E(t,`path`),entries:A(qi)(t.entries),scannedAt:E(t,`scannedAt`),truncated:k(t,`truncated`)}}function qi(e){let t=T(e),n=E(t,`type`);if(n!==`file`&&n!==`directory`&&n!==`symlink`)throw Error(`Invalid file tree entry type`);return{name:E(t,`name`),path:E(t,`path`),type:n,...M(`size`,To(t,`size`)),...M(`modifiedAt`,D(t,`modifiedAt`))}}function Ji(e){let t=T(e),n=E(t,`encoding`);if(n!==`utf8`)throw Error(`Invalid file encoding`);return{path:E(t,`path`),...M(`language`,D(t,`language`)),...M(`mediaType`,Qi(t.mediaType)),...M(`mimeType`,D(t,`mimeType`)),encoding:n,size:O(t,`size`),modifiedAt:E(t,`modifiedAt`),content:E(t,`content`),truncated:k(t,`truncated`),binary:k(t,`binary`)}}function Yi(e){let t=T(e);return{path:E(t,`path`),size:O(t,`size`),modifiedAt:E(t,`modifiedAt`),created:k(t,`created`)}}function Xi(e){let t=T(e);return{path:E(t,`path`),existed:k(t,`existed`)}}function Zi(e){let t=T(e);return{fromPath:E(t,`fromPath`),toPath:E(t,`toPath`),size:O(t,`size`),modifiedAt:E(t,`modifiedAt`)}}function Qi(e){if(e!==void 0){if(e!==`image`&&e!==`html`&&e!==`pdf`&&e!==`markdown`)throw Error(`Invalid file media type`);return e}}function $i(e){let t=T(e),n=t.decision;if(n!==!0&&n!==!1&&n!==null)throw Error(`Invalid workspace trust decision`);return{path:E(t,`path`),decision:n,trusted:k(t,`trusted`)}}function ea(e){let t=T(e);return{id:E(t,`id`),cwd:E(t,`cwd`),name:E(t,`name`),createdAt:E(t,`createdAt`),exited:k(t,`exited`),...M(`exitCode`,To(t,`exitCode`)),...M(`commandRunId`,D(t,`commandRunId`))}}function ta(e){let t=T(e);return{id:E(t,`id`),origin:E(t,`origin`),projectId:E(t,`projectId`),workspaceId:E(t,`workspaceId`),terminalId:E(t,`terminalId`),title:E(t,`title`),command:E(t,`command`),status:na(t.status),...M(`exitCode`,To(t,`exitCode`)),createdAt:E(t,`createdAt`),...M(`startedAt`,D(t,`startedAt`)),...M(`completedAt`,D(t,`completedAt`)),metadata:ra(t.metadata,`metadata`)}}function na(e){if(e!==`queued`&&e!==`running`&&e!==`succeeded`&&e!==`failed`)throw Error(`Invalid terminal command run status`);return e}function ra(e,t){let n=T(e);return Object.fromEntries(Object.entries(n).map(([e,n])=>{if(typeof n!=`string`)throw Error(`Expected string record field: ${t}.${e}`);return[e,n]}))}function ia(e){let t=pn(e);if(t===void 0)throw Error(`Expected machine status snapshot`);return t}function aa(e){let t=T(e),n=t.enabled===!0,r=typeof t.disabledReason==`string`?t.disabledReason:void 0,i=typeof t.latest==`string`?t.latest:void 0,a=typeof t.branch==`string`?t.branch:void 0;return n?{enabled:!0,current:E(t,`current`),latest:i,available:t.available===!0,branch:a,checkedAt:E(t,`checkedAt`)}:{enabled:!1,current:``,latest:i,available:!1,branch:a,checkedAt:E(t,`checkedAt`),...r===void 0?{}:{disabledReason:r}}}function oa(e){let t=T(e);return{goalId:E(t,`goalId`),archivedPath:typeof t.archivedPath==`string`?t.archivedPath:``,alreadyArchived:t.alreadyArchived===!0,agentMayRecreate:t.agentMayRecreate===!0}}function sa(e){let t=T(e);return{hub:la(t.hub),machines:A(ua)(t.machines)}}function ca(e){let t=T(e),n=E(t,`operation`);if(n!==`restart`&&n!==`update`)throw Error(`Invalid fleet operation`);return{operation:n,hub:la(t.hub),outcomes:A(da)(t.outcomes)}}function la(e){let t=T(e);return{machineId:E(t,`machineId`),name:E(t,`name`)}}function ua(e){let t=T(e),n=E(t,`kind`);if(n!==`local`&&n!==`remote`)throw Error(`Invalid machine kind`);return{...la(e),kind:n,online:t.online===!0,...M(`version`,D(t,`version`)),...M(`piVersion`,D(t,`piVersion`)),...M(`error`,D(t,`error`))}}function da(e){let t=T(e);return{...la(e),started:t.started===!0,...M(`error`,D(t,`error`))}}function fa(e){let t=T(e);return{path:E(t,`path`),exists:k(t,`exists`),config:pa(t.config),effectiveConfig:pa(t.effectiveConfig),envOverrides:Ea(t.envOverrides)}}function pa(e){let t=T(e);return{...M(`host`,D(t,`host`)),...M(`port`,To(t,`port`)),...M(`allowedHosts`,va(t.allowedHosts)),...M(`shortcuts`,wa(t.shortcuts)),...M(`plugins`,Ta(t.plugins)),...M(`pathAccess`,ya(t.pathAccess)),...M(`uploads`,xa(t.uploads)),...M(`maxUploadBytes`,To(t,`maxUploadBytes`)),...M(`agent`,_a(t.agent)),...M(`spawnSessions`,wo(t,`spawnSessions`)),...M(`subsessions`,wo(t,`subsessions`)),...M(`askUser`,wo(t,`askUser`)),...M(`speechToText`,ha(t.speechToText)),...M(`environmentFacts`,wo(t,`environmentFacts`)),...M(`extensionDialogsTimeoutMs`,To(t,`extensionDialogsTimeoutMs`))}}var ma=[`browser`,`openai-realtime`,`deepgram`,`azure-speech`];function ha(e){if(e===void 0)return;if(!w(e)||Array.isArray(e))throw Error(`Invalid PI WEB speechToText field`);let t=e.endpoint;if(typeof t!=`string`||t.trim()===``)throw Error(`Invalid PI WEB speechToText field`);return{endpoint:t,...M(`model`,D(e,`model`)),...M(`language`,D(e,`language`)),...M(`streaming`,ga(e.streaming))}}function ga(e){if(e===void 0)return;if(!w(e)||Array.isArray(e))throw Error(`Invalid PI WEB speechToText.streaming field`);let t=ma.find(t=>t===e.protocol);if(t===void 0)throw Error(`Invalid PI WEB speechToText.streaming field`);return{protocol:t,...M(`url`,D(e,`url`)),...M(`model`,D(e,`model`)),...M(`tokenEndpoint`,D(e,`tokenEndpoint`))}}function _a(e){if(e!==void 0){if(!w(e)||Array.isArray(e))throw Error(`Invalid PI WEB agent field`);return{...M(`command`,D(e,`command`)),...M(`dir`,D(e,`dir`))}}}function va(e){if(e!==void 0){if(e===!0)return!0;if(Sa(e))return e;throw Error(`Invalid PI WEB allowedHosts field`)}}function ya(e){if(e===void 0)return;if(!w(e))throw Error(`Invalid PI WEB pathAccess field`);let t=e.allowedPaths;return{...M(`allowedPaths`,ba(t,`pathAccess.allowedPaths`))}}function ba(e,t){if(e!==void 0){if(Ca(e))return e;throw Error(`Invalid PI WEB ${t} field`)}}function xa(e){if(e!==void 0){if(!w(e)||Array.isArray(e))throw Error(`Invalid PI WEB uploads field`);return{...M(`defaultFolder`,D(e,`defaultFolder`))}}}function Sa(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Ca(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`&&e!==``)}function wa(e){if(e!==void 0){if(!w(e)||Array.isArray(e))throw Error(`Invalid PI WEB shortcuts field`);return Object.fromEntries(Object.entries(e).map(([e,t])=>{if(t!==null&&(typeof t!=`string`||t===``))throw Error(`Invalid PI WEB shortcut field`);return[e,t]}))}}function Ta(e){if(e!==void 0){if(!w(e)||Array.isArray(e))throw Error(`Invalid PI WEB plugins field`);return Object.fromEntries(Object.entries(e).map(([e,t])=>{if(!w(t)||Array.isArray(t))throw Error(`Invalid PI WEB plugin config field`);let n=t.enabled;if(n!==void 0&&typeof n!=`boolean`)throw Error(`Invalid PI WEB plugin enabled field`);let r=t.settings;if(r!==void 0&&(!w(r)||Array.isArray(r)))throw Error(`Invalid PI WEB plugin settings field`);return[e,t]}))}}function Ea(e){let t=T(e);return{host:k(t,`host`),port:k(t,`port`),allowedHosts:k(t,`allowedHosts`),spawnSessions:k(t,`spawnSessions`),subsessions:k(t,`subsessions`),askUser:k(t,`askUser`)}}function Da(e){let t=T(e);return{packages:A(ka)(t.packages)}}function Oa(e){let t=T(e),n=D(t,`source`),r=t.scope===void 0?void 0:Aa(t.scope),i=Va(t.removed,`removed`);return{action:ja(t.action),...M(`source`,n),...M(`scope`,r),...M(`removed`,i),packages:A(ka)(t.packages)}}function ka(e){let t=T(e);return{source:E(t,`source`),scope:Aa(t.scope),filtered:k(t,`filtered`),...M(`installedPath`,D(t,`installedPath`))}}function Aa(e){if(e!==`user`&&e!==`project`)throw Error(`Invalid Pi package scope`);return e}function ja(e){if(e!==`install`&&e!==`remove`&&e!==`update`)throw Error(`Invalid Pi package mutation action`);return e}function Ma(e){let t=T(e),n=A(Na)(t.plugins);if(t.lifecycleVersion===void 0)return{lifecycleVersion:1,plugins:n,diagnostics:[],serverRuntime:{status:`incompatible`,restartRequired:!1,message:`PI WEB does not support plugin lifecycle diagnostics. Update and restart PI WEB, then try again.`,recovery:za()}};if(t.lifecycleVersion!==1)throw Error(`Unsupported PI WEB plugin lifecycle version`);return{lifecycleVersion:1,plugins:n,diagnostics:A(Ia)(t.diagnostics),serverRuntime:La(t.serverRuntime)}}function Na(e){let t=T(e),n=E(t,`id`),r=t.server===void 0?void 0:Pa(t.server,n);return{id:n,...M(`module`,D(t,`module`)),source:E(t,`source`),scope:Ba(t.scope),machineSpecific:Va(t.machineSpecific,`machineSpecific`)??!1,enabled:k(t,`enabled`),discovered:Va(t.discovered,`discovered`)??!0,conflict:Va(t.conflict,`conflict`)??!1,...r===void 0?{}:{server:r}}}function Pa(e,t){let n=T(e),r=n.state,i=n.phase;if(r!==`active`&&r!==`failed`&&r!==`incompatible`&&r!==`disabled`&&r!==`missing`&&r!==`unknown`)throw Error(`Invalid PI WEB server plugin state`);if(i!==void 0&&i!==`import`&&i!==`activate`&&i!==`validate`&&i!==`start`&&i!==`health`&&i!==`stop`)throw Error(`Invalid PI WEB server plugin phase`);let a=n.health===void 0?void 0:Fa(n.health),o=E(n,`disableCommand`);if(o!==An(t))throw Error(`Invalid PI WEB server plugin recovery command`);return{state:r,...M(`desiredRevision`,D(n,`desiredRevision`)),...M(`activeRevision`,D(n,`activeRevision`)),...i===void 0?{}:{phase:i},...M(`message`,D(n,`message`)),...a===void 0?{}:{health:a},staleRevision:k(n,`staleRevision`),restartRequired:k(n,`restartRequired`),disableCommand:o}}function Fa(e){let t=T(e),n=t.status;if(n!==`healthy`&&n!==`degraded`&&n!==`unhealthy`)throw Error(`Invalid PI WEB server plugin health status`);return{status:n,...M(`message`,D(t,`message`))}}function Ia(e){let t=T(e),n=t.kind,r=t.snapshot;if(n!==`conflict`&&n!==`discovery`)throw Error(`Invalid PI WEB plugin diagnostic kind`);if(r!==`desired`&&r!==`active`)throw Error(`Invalid PI WEB plugin diagnostic snapshot`);return{kind:n,snapshot:r,source:E(t,`source`),message:E(t,`message`),...M(`pluginId`,D(t,`pluginId`))}}function La(e){let t=T(e),n=t.status,r=t.safeStart,i=t.desiredSafeStart;if(n!==`available`&&n!==`unavailable`&&n!==`incompatible`)throw Error(`Invalid PI WEB server-plugin runtime status`);if(r!==void 0&&r!==`bundled-only`&&r!==`none`)throw Error(`Invalid PI WEB server-plugin safe-start state`);if(i!==void 0&&i!==`off`&&i!==`bundled-only`&&i!==`none`)throw Error(`Invalid desired PI WEB server-plugin safe-start state`);return{status:n,...r===void 0?{}:{safeStart:r},...i===void 0?{}:{desiredSafeStart:i},restartRequired:k(t,`restartRequired`),...M(`message`,D(t,`message`)),recovery:Ra(t.recovery)}}function Ra(e){let t=T(e),n={showSafeStart:E(t,`showSafeStart`),bundledOnly:E(t,`bundledOnly`),noServerPlugins:E(t,`noServerPlugins`),clearSafeStart:E(t,`clearSafeStart`)};if(n.showSafeStart!==kn.showSafeStart||n.bundledOnly!==kn.bundledOnly||n.noServerPlugins!==kn.noServerPlugins||n.clearSafeStart!==kn.clearSafeStart)throw Error(`Invalid PI WEB server plugin recovery commands`);return n}function za(){return{...kn}}function Ba(e){if(e!==`bundled`&&e!==`local`&&e!==`user`&&e!==`project`)throw Error(`Invalid PI WEB plugin scope`);return e}function Va(e,t){if(e!==void 0){if(typeof e!=`boolean`)throw Error(`Expected optional boolean field: ${t}`);return e}}function Ha(e){let t=T(e);return{packageName:E(t,`packageName`),generatedAt:E(t,`generatedAt`),components:Wa(t.components),release:Ya(t.release),commands:Xa(t.commands),messages:A(Za)(t.messages)}}function Ua(e){let t=T(e);return{packageName:E(t,`packageName`),generatedAt:E(t,`generatedAt`),components:Ga(t.components),capabilities:$a(t.capabilities)}}function Wa(e){let t=T(e);return{web:qa(t.web),sessiond:qa(t.sessiond)}}function Ga(e){let t=T(e);return{web:Ka(t.web),sessiond:Ka(t.sessiond)}}function Ka(e){let t=T(e);return{component:Qa(t.component),label:E(t,`label`),...M(`runtimeVersion`,D(t,`runtimeVersion`)),...M(`piVersion`,D(t,`piVersion`)),available:k(t,`available`),capabilities:$a(t.capabilities),...M(`error`,D(t,`error`))}}function qa(e){let t=T(e);return{component:Qa(t.component),label:E(t,`label`),...M(`runtimeVersion`,D(t,`runtimeVersion`)),...M(`installedVersion`,D(t,`installedVersion`)),...M(`piVersion`,D(t,`piVersion`)),stale:k(t,`stale`),available:k(t,`available`),...M(`installation`,Ja(t.installation)),...M(`error`,D(t,`error`))}}function Ja(e){if(e===void 0)return;let t=T(e),n=E(t,`kind`);if(n!==`pi-package`&&n!==`npm-global`&&n!==`local`&&n!==`docker`&&n!==`unknown`)throw Error(`Invalid PI WEB installation kind`);let r=t.scope;if(r!==void 0&&r!==`user`&&r!==`project`)throw Error(`Invalid PI WEB installation scope`);let i=t.dockerMode;if(i!==void 0&&i!==`runtime`&&i!==`dev`)throw Error(`Invalid PI WEB Docker mode`);return{kind:n,...M(`path`,D(t,`path`)),...M(`source`,D(t,`source`)),...r===void 0?{}:{scope:r},...M(`npmRoot`,D(t,`npmRoot`)),...i===void 0?{}:{dockerMode:i}}}function Ya(e){let t=T(e);return{packageName:E(t,`packageName`),...M(`latestVersion`,D(t,`latestVersion`)),updateAvailable:k(t,`updateAvailable`),...M(`checkedAt`,D(t,`checkedAt`)),...t.skipped===!0?{skipped:!0}:{},...M(`error`,D(t,`error`))}}function Xa(e){let t=T(e);return{...M(`update`,D(t,`update`)),...M(`restart`,D(t,`restart`)),...M(`restartWeb`,D(t,`restartWeb`)),...M(`restartSessiond`,D(t,`restartSessiond`)),...M(`status`,D(t,`status`))}}function Za(e){let t=T(e);return{id:E(t,`id`),severity:eo(t.severity),title:E(t,`title`),body:E(t,`body`),...M(`command`,D(t,`command`))}}function Qa(e){if(e!==`web`&&e!==`sessiond`)throw Error(`Invalid PI WEB service component`);return e}function $a(e){let t=xn(e);if(t===void 0)throw Error(`Invalid PI WEB capabilities`);return t}function eo(e){if(e!==`info`&&e!==`warning`&&e!==`error`)throw Error(`Invalid PI WEB status severity`);return e}function to(e){let t=T(e),n=E(t,`type`);if(n===`unsupported`)return{type:n,message:E(t,`message`)};if(n===`select`)return{type:n,requestId:E(t,`requestId`),title:E(t,`title`),options:A(fo)(t.options)};if(n===`tree`)return{type:n,tree:no(t.tree)};if(n===`done`)return{type:n,...M(`message`,D(t,`message`)),...po(t.session),...M(`promptDraft`,D(t,`promptDraft`))};throw Error(`Invalid command result type`)}function no(e){let t=T(e),n=A(ro)(t.nodes),r=new Set(n.map(e=>e.id));if(r.size!==n.length)throw Error(`Duplicate session tree node id`);let i=co(t,`activeLeafId`);if(i!==null&&!r.has(i))throw Error(`Invalid session tree activeLeafId`);return{nodes:n,activeLeafId:i,activePathIds:uo(t.activePathIds,`activePathIds`)}}function ro(e){let t=T(e);return{id:lo(t,`id`),parentId:co(t,`parentId`),kind:io(t.kind),summary:E(t,`summary`),...M(`timestamp`,D(t,`timestamp`)),...M(`label`,D(t,`label`))}}function io(e){switch(e){case`user`:case`assistant`:case`tool-result`:case`bash`:case`custom-message`:case`compaction`:case`branch-summary`:case`model-change`:case`thinking-level-change`:case`session-info`:case`label`:case`custom`:case`other`:return e;default:throw Error(`Invalid session tree node kind`)}}function ao(e){let t=T(e),n=k(t,`cancelled`);if(Object.hasOwn(t,`summaryEntry`))throw Error(`Invalid session tree navigation result field: summaryEntry`);if(n){so(t,`editorText`,`session tree cancellation result`);let e=t.aborted;if(e!==void 0&&typeof e!=`boolean`)throw Error(`Expected optional boolean field: aborted`);return{cancelled:n,...e===void 0?{}:{aborted:e}}}return so(t,`aborted`,`session tree navigation result`),{cancelled:n,...M(`editorText`,D(t,`editorText`))}}function oo(e){let t=T(e),n=k(t,`cancelled`);return n?(so(t,`session`,`session tree fork cancellation result`),so(t,`promptDraft`,`session tree fork cancellation result`),{cancelled:n}):{cancelled:n,session:$n(t.session),...M(`promptDraft`,D(t,`promptDraft`))}}function so(e,t,n){if(Object.hasOwn(e,t))throw Error(`Invalid ${n} field: ${t}`)}function co(e,t){let n=e[t];if(n!==null&&typeof n!=`string`)throw Error(`Expected string or null field: ${t}`);if(typeof n==`string`&&n.trim()===``)throw Error(`Expected non-blank string or null field: ${t}`);return n}function lo(e,t){let n=E(e,t);if(n.trim()===``)throw Error(`Expected non-blank string field: ${t}`);return n}function uo(e,t){let n=Mn(e,t);if(n.some(e=>e.trim()===``))throw Error(`Expected non-blank string array field: ${t}`);return n}function fo(e){let t=T(e);return{value:E(t,`value`),label:E(t,`label`),...M(`description`,D(t,`description`))}}function po(e){return e===void 0?{}:{session:$n(e)}}function mo(e){if(T(e).accepted!==!0)throw Error(`Expected accepted response`);return{accepted:!0}}function ho(e){let t=T(e);return A(go)(t.attachments)}function go(e){let t=T(e);return{path:E(t,`path`),mimeType:E(t,`mimeType`),size:O(t,`size`)}}function _o(e){if(T(e).closed!==!0)throw Error(`Expected closed response`);return{closed:!0}}function vo(e){let t=T(e);if(t.aborted!==!0)throw Error(`Expected aborted response`);let n=t.discarded;return{aborted:!0,discarded:Array.isArray(n)?A(bi)(n):[]}}function yo(e){if(T(e).stopped!==!0)throw Error(`Expected stopped response`);return{stopped:!0}}function bo(e){let t=T(e);if(t.archived!==!0)throw Error(`Expected archived response`);let n=t.sessionIds===void 0?void 0:Mn(t.sessionIds,`sessionIds`),r=To(t,`archivedCount`),i=To(t,`skippedAlreadyArchivedCount`);return{archived:!0,...n===void 0?{}:{sessionIds:n},...r===void 0?{}:{archivedCount:r},...i===void 0?{}:{skippedAlreadyArchivedCount:i}}}function xo(e){if(T(e).restored!==!0)throw Error(`Expected restored response`);return{restored:!0}}function So(e){if(T(e).detached!==!0)throw Error(`Expected detached response`);return{detached:!0}}function Co(e){if(T(e).reloaded!==!0)throw Error(`Expected reloaded response`);return{reloaded:!0}}function wo(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`boolean`)throw Error(`Invalid PI WEB ${t} field`);return n}}function To(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`number`)throw Error(`Expected optional number field: ${t}`);return n}}function Eo(e,t){let n=e[t];if(n===null)return null;if(typeof n!=`number`)throw Error(`Expected number|null field: ${t}`);return n}function M(e,t){return t===void 0?{}:{[e]:t}}function Do(e){if(!w(e))return{runs:[]};let t=e.runs;if(!Array.isArray(t))return{runs:[]};let n=[];for(let e of t){if(!w(e))continue;let t=e.sessionId,r=e.cwd,i=e.interruptedAt;typeof t!=`string`||t===``||typeof r!=`string`||typeof i!=`string`||n.push({sessionId:t,cwd:r,interruptedAt:i})}return{runs:n}}function Oo(e){if(!w(e))return{subsessions:[],toolRuns:[]};let t=[],n=e.subsessions;if(Array.isArray(n))for(let e of n){if(!w(e))continue;let n=e.sessionId,r=e.cwd,i=e.status;typeof n!=`string`||n===``||typeof r==`string`&&(i!==`working`&&i!==`idle`&&i!==`error`&&i!==`unknown`||t.push({sessionId:n,cwd:r,status:i}))}return{subsessions:t,toolRuns:No(e.toolRuns)}}function ko(e){let t=Er(e);return{recalled:w(e)&&e.recalled===!0,status:t}}function Ao(e){if(!w(e)||!Array.isArray(e.tasks))return[];let t=[];for(let n of e.tasks){if(!w(n))continue;let e=n.id,r=n.name,i=n.status;typeof e!=`string`||e===``||t.push({id:e,name:typeof r==`string`&&r!==``?r:e,command:typeof n.command==`string`?n.command:``,status:typeof i==`string`?i:`unknown`,...typeof n.startedAt==`string`?{startedAt:n.startedAt}:{},...typeof n.endedAt==`string`?{endedAt:n.endedAt}:{},...typeof n.durationMs==`number`?{durationMs:n.durationMs}:{},...typeof n.exitCode==`number`?{exitCode:n.exitCode}:{},bytesWritten:typeof n.bytesWritten==`number`?n.bytesWritten:0,hasOutput:n.hasOutput===!0})}return t}function jo(e){if(!w(e))return``;let t=e.output;return typeof t==`string`?t:``}function Mo(e){if(!w(e))return``;let t=e.output;return typeof t==`string`?t:``}function No(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!w(n))continue;let e=n.runId,r=n.agent,i=n.status,a=n.elapsedMs,o=n.startedAt;if(typeof e!=`string`||e===``||typeof r!=`string`||r===``||i!==`running`&&i!==`done`&&i!==`failed`&&i!==`lost`&&i!==`unknown`||typeof a!=`number`||typeof o!=`string`)continue;let s=n.lastActivity,c=n.task,l=n.model,u=n.toolCount;t.push({runId:e,agent:r,status:i,elapsedMs:a,startedAt:o,...typeof s==`string`&&s!==``?{lastActivity:s}:{},...typeof c==`string`&&c!==``?{task:c}:{},...typeof l==`string`&&l!==``?{model:l}:{},...typeof u==`number`?{toolCount:u}:{},hasOutput:n.hasOutput===!0})}return t}function Po(e){return typeof e==`string`?e:e.id}function Fo(e){return typeof e==`string`?void 0:e.cwd}function Io(e,t,n=`local`){let r=new URLSearchParams,i=Fo(e);i!==void 0&&i!==``&&r.set(`cwd`,i),t?.limit!==void 0&&r.set(`limit`,String(t.limit)),t?.before!==void 0&&r.set(`before`,String(t.before));let a=r.toString();return`api/machines/${encodeURIComponent(n)}/sessions/${encodeURIComponent(Po(e))}/messages${a===``?``:`?${a}`}`}function Lo(e,t,n,r){let i=new URLSearchParams({path:n});return r?.createDirs===!1&&i.set(`createDirs`,`false`),r?.overwrite===!1&&i.set(`overwrite`,`false`),Wt(`${`api/machines/${encodeURIComponent(r?.machineId??`local`)}`}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${i.toString()}`)}function Ro(e,t,n,r){let i=new URLSearchParams;return i.set(`path`,n),r?.modifiedAt!==void 0&&i.set(`v`,r.modifiedAt),r?.download===!0&&i.set(`download`,`1`),`${`api/machines/${encodeURIComponent(r?.machineId??`local`)}`}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file/preview?${i.toString()}`}function zo(e,t,n,r){return Wt(Ro(e,t,n,r))}var N=(e=`local`)=>`api/machines/${encodeURIComponent(e)}`;function Bo(e,t=`local`){return`${N(t)}/sessions/${encodeURIComponent(e.id)}`}function P(e,t,n=`local`){return`${Bo(e,n)}/${t}`}function Vo(e,t,n=`local`){return`${P(e,t,n)}${Ho(e)}`}function Ho(e){return`?${new URLSearchParams({cwd:e.cwd}).toString()}`}function F(e,t={}){return JSON.stringify({cwd:e.cwd,...t})}function Uo(e){return JSON.stringify({sessions:e.map(Wo)})}function Wo(e){return{id:e.id,cwd:e.cwd}}function Go(e){return e===`local`?`api/pi-web/status`:`${N(e)}/pi-web/status`}var Ko={piWebStatus:(e=`local`)=>C(Go(e),Ha),checkForUpdates:(e=`local`)=>C(`${Go(e)}?refresh=1`,Ha,{cache:`no-store`}),piWebRuntime:()=>C(`api/pi-web/runtime`,Ua)},qo={machines:()=>C(`api/machines`,Pn),addMachine:e=>C(`api/machines`,Fn,{method:`POST`,body:JSON.stringify(e)}),deleteMachine:e=>C(`api/machines/${encodeURIComponent(e)}`,e=>e,{method:`DELETE`}),updateMachine:(e,t)=>C(`api/machines/${encodeURIComponent(e)}`,Fn,{method:`PATCH`,body:JSON.stringify(t)}),health:e=>C(`api/machines/${encodeURIComponent(e)}/health`,In),runtime:(e,t=!1)=>C(`api/machines/${encodeURIComponent(e)}/runtime${t?`?refresh=1`:``}`,Ln,t?{cache:`no-store`}:{})};function Jo(e){return e===void 0?`api/config`:`${N(e)}/config`}function Yo(e){return e===void 0?`api/plugins`:`${N(e)}/plugins`}var Xo={config:e=>C(Jo(e),fa),saveConfig:(e,t)=>C(Jo(t),fa,{method:`PUT`,body:JSON.stringify({config:e})})};function Zo(e){let t=hs(e)?e:{},n=t.started===!0,r=typeof t.error==`string`?t.error:void 0;return r===void 0?{started:n}:{started:n,error:r}}var Qo={plugins:e=>C(Yo(e),Ma)},$o={status:()=>C(`api/pi-web/update/status`,aa,{cache:`no-store`}),apply:()=>C(`api/pi-web/update/apply`,Zo,{method:`POST`,body:JSON.stringify({})})},es={report:()=>C(`api/pi-web/fleet`,sa,{cache:`no-store`}),run:(e,t)=>C(`api/pi-web/fleet/run`,ca,{method:`POST`,body:JSON.stringify({operation:e,...t===void 0?{}:{machineIds:t}})})};function ts(e=``,t){let n=t===void 0?`api/pi-packages`:`${N(t)}/pi-packages`;return e===``?n:`${n}/${e}`}var ns={packages:e=>C(ts(``,e),Da),install:(e,t)=>{let n={source:e};return C(ts(`install`,t),Oa,{method:`POST`,body:JSON.stringify(n)})},remove:(e,t,n)=>{let r=t===void 0?{source:e}:{source:e,scope:t};return C(ts(`remove`,n),Oa,{method:`POST`,body:JSON.stringify(r)})},update:(e,t)=>{let n=e===void 0?void 0:{source:e};return C(ts(`update`,t),Oa,{method:`POST`,...n===void 0?{}:{body:JSON.stringify(n)}})}},rs={machineStatus:(e=`local`)=>C(`${N(e)}/status`,ia)},is={projects:(e=`local`)=>C(`${N(e)}/projects`,A(Vn)),addProject:(e,t,n,r=`local`)=>C(`${N(r)}/projects`,Vn,{method:`POST`,body:JSON.stringify({path:e,name:t,create:n})}),closeProject:(e,t=`local`)=>C(`${N(t)}/projects/${encodeURIComponent(e)}`,_o,{method:`DELETE`}),projectDirectories:(e,t=`local`)=>C(`${N(t)}/project-directories?q=${encodeURIComponent(e)}`,A(Gi))};function as(e,t=`local`){return C(`${N(t)}/projects/${encodeURIComponent(e)}/workspaces`,t=>{let n=Un(t);if(n.projectId!==e)throw Error(`Workspace resolution did not match the requested project`);return n})}var os={workspaceResolution:as,workspaces:async(e,t=`local`)=>[...(await as(e,t)).workspaces],deleteWorkspace:(e,t,n,r=`local`)=>{let i={precondition:n};return C(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}`,ta,{method:`DELETE`,body:JSON.stringify(i)})},archiveWorkspaceGoal:(e,t,n,r=`local`)=>C(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/goals/${encodeURIComponent(n)}/archive`,oa,{method:`POST`,body:JSON.stringify({})}),workspaceGoals:(e,t,n=`local`)=>C(`${N(n)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/goals`,Ar,{cache:`no-store`}),workspaceTree:(e,t,n=``,r=`local`)=>C(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/tree?path=${encodeURIComponent(n)}`,Ki),workspaceFile:(e,t,n,r=`local`)=>C(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?path=${encodeURIComponent(n)}`,Ji),writeWorkspaceFile:(e,t,n,r,i,a=`local`)=>{let o=new URLSearchParams({path:n});i?.createDirs===!1&&o.set(`createDirs`,`false`),i?.overwrite===!1&&o.set(`overwrite`,`false`);let s=r instanceof Uint8Array,c=s?new Uint8Array(r):new TextEncoder().encode(r);return C(`${N(a)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${o.toString()}`,Yi,{method:`PUT`,body:c,headers:{"Content-Type":s?`application/octet-stream`:`text/plain`}})},deleteWorkspaceFile:(e,t,n,r=`local`)=>{let i=new URLSearchParams({path:n});return C(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${i.toString()}`,Xi,{method:`DELETE`})},moveWorkspaceFile:(e,t,n,r,i,a=`local`)=>{let o=new URLSearchParams({fromPath:n,toPath:r});return i?.createDirs===!1&&o.set(`createDirs`,`false`),i?.overwrite===!0&&o.set(`overwrite`,`true`),C(`${N(a)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file/move?${o.toString()}`,Zi,{method:`POST`})}},ss={sessions:(e,t=`local`)=>C(`${N(t)}/sessions?cwd=${encodeURIComponent(e)}`,A($n)),unreadCatalog:(e=`local`)=>C(`${N(e)}/sessions/unread`,Mr,{cache:`no-store`}),statusCatalog:(e=`local`)=>C(`${N(e)}/sessions/statuses`,jr,{cache:`no-store`}),interruptedRuns:(e=`local`)=>C(`${N(e)}/sessions/interrupted`,Do,{cache:`no-store`}),subsessions:(e,t=`local`)=>C(`${P(e,`subsessions`,t)}?cwd=${encodeURIComponent(e.cwd)}`,Oo,{cache:`no-store`}),acknowledgeUnread:(e,t,n,r=`local`)=>{let i={cwd:e.cwd,catalogId:t,throughCompletionOrder:n};return C(P(e,`unread/acknowledge`,r),Mr,{method:`POST`,body:JSON.stringify(i)})},notificationInbox:(e,t=`local`)=>C(Vo(e,`notifications`,t),Xr),dismissNotification:(e,t,n,r=`local`)=>C(P(e,`notifications/dismiss`,r),Xr,{method:`POST`,body:F(e,{daemonInstanceId:t,notificationId:n})}),dismissAllNotifications:(e,t,n,r=`local`)=>C(P(e,`notifications/dismiss-all`,r),Xr,{method:`POST`,body:F(e,{daemonInstanceId:t,throughOrder:n.order,throughOverflowWatermark:n.overflowWatermark})}),startSession:(e,t=`local`,n)=>C(`${N(t)}/sessions`,$n,{method:`POST`,body:JSON.stringify(n===void 0?{cwd:e}:{cwd:e,startupToken:n})}),cleanupPreview:(e,t=`local`)=>C(`${N(t)}/sessions/cleanup/preview`,fi,{method:`POST`,body:JSON.stringify(e)}),cleanup:(e,t=`local`)=>C(`${N(t)}/sessions/cleanup`,pi,{method:`POST`,body:JSON.stringify(e)}),archiveMany:(e,t=`local`)=>C(`${N(t)}/sessions/bulk/archive`,mi,{method:`POST`,body:Uo(e)}),deleteArchivedMany:(e,t=`local`)=>C(`${N(t)}/sessions/bulk/delete-archived`,hi,{method:`POST`,body:Uo(e)}),messages:(e,t,n=`local`)=>C(Io(e,t,n),Nn),status:(e,t=`local`)=>C(Vo(e,`status`,t),Er),streamSnapshot:(e,t=`local`)=>C(Vo(e,`stream-snapshot`,t),Dr),backgroundTasks:(e,t=`local`)=>C(`${P(e,`background-tasks`,t)}?cwd=${encodeURIComponent(e.cwd)}`,Ao,{cache:`no-store`}),backgroundTaskOutput:(e,t,n=`local`)=>C(`${P(e,`background-tasks/${encodeURIComponent(t)}/output`,n)}?cwd=${encodeURIComponent(e.cwd)}`,jo,{cache:`no-store`}),subagentRunOutput:(e,t,n=`local`)=>C(`${P(e,`subagent-runs/${encodeURIComponent(t)}/output`,n)}?cwd=${encodeURIComponent(e.cwd)}`,Mo,{cache:`no-store`}),clearQueue:(e,t=`local`)=>C(P(e,`queue/clear`,t),Er,{method:`POST`,body:F(e)}),recallQueuedMessage:(e,t,n=`local`)=>C(P(e,`queue/clear`,n),ko,{method:`POST`,body:F(e,{text:t.text,kind:t.kind,...t.clientMessageId===void 0?{}:{clientMessageId:t.clientMessageId}})}),dismissWarning:(e,t,n=`local`)=>C(P(e,`warnings/dismiss`,n),Er,{method:`POST`,body:F(e,{dismissId:t})}),submitAsk:(e,t,n,r=`local`)=>C(P(e,`ask/submit`,r),pr,{method:`POST`,body:F(e,{askId:t,answers:n.answers})}),cancelAsk:(e,t,n=`local`)=>C(P(e,`ask/cancel`,n),pr,{method:`POST`,body:F(e,{askId:t})}),answerDialog:(e,t,n,r=`local`)=>C(P(e,`dialogs/answer`,r),mr,{method:`POST`,body:F(e,{dialogId:t,value:n})}),cancelDialog:(e,t,n=`local`)=>C(P(e,`dialogs/cancel`,n),mr,{method:`POST`,body:F(e,{dialogId:t})}),models:(e,t=`local`)=>C(Vo(e,`models`,t),wi),modelCatalog:(e,t=`local`)=>C(Vo(e,`models/catalog`,t),Ei),setModelEnabled:(e,t,n,r,i=`local`)=>C(P(e,`models/enabled`,i),Ei,{method:`POST`,body:F(e,{provider:t,modelId:n,enabled:r})}),setModel:(e,t,n,r=`local`)=>C(P(e,`model`,r),Er,{method:`POST`,body:F(e,{provider:t,modelId:n})}),cycleModel:(e,t,n=`local`)=>C(P(e,`model/cycle`,n),Er,{method:`POST`,body:F(e,{direction:t})}),thinkingLevels:(e,t=`local`)=>C(Vo(e,`thinking-levels`,t),Oi),setThinkingLevel:(e,t,n=`local`)=>C(P(e,`thinking-level`,n),Er,{method:`POST`,body:F(e,{level:t})}),cycleThinkingLevel:(e,t=`local`)=>C(P(e,`thinking-level/cycle`,t),Er,{method:`POST`,body:F(e)}),commands:(e,t=`local`)=>C(Vo(e,`commands`,t),A(Wi)),prompt:(e,t,n,r=`local`,i,a)=>C(P(e,`prompt`,r),mo,{method:`POST`,body:F(e,{text:t,...n===void 0?{}:{streamingBehavior:n},...i!==void 0&&i.length>0?{attachments:i}:{},...a===void 0?{}:{clientMessageId:a}})}),saveAttachments:(e,t,n=`local`,r)=>C(P(e,`attachments`,n),ho,{method:`POST`,body:F(e,{attachments:t,...r===void 0?{}:{folder:r}})}),shell:(e,t,n=`local`)=>C(P(e,`shell`,n),mo,{method:`POST`,body:F(e,{text:t})}),runCommand:(e,t,n=`local`)=>C(P(e,`commands/run`,n),to,{method:`POST`,body:F(e,{text:t})}),respondToCommand:(e,t,n,r=`local`)=>C(P(e,`commands/respond`,r),to,{method:`POST`,body:F(e,{requestId:t,value:n})}),navigateTree:(e,t,n=`local`)=>C(P(e,`tree/navigate`,n),ao,{method:`POST`,body:F(e,{targetId:t.targetId,expectedLeafId:t.expectedLeafId,summary:t.summary})}),forkTree:(e,t,n=`local`)=>us(e,t,n),abort:(e,t=`local`)=>C(P(e,`abort`,t),vo,{method:`POST`,body:F(e)}),stop:(e,t=`local`)=>C(P(e,`stop`,t),yo,{method:`POST`,body:F(e)}),archive:(e,t=`local`)=>C(P(e,`archive`,t),bo,{method:`POST`,body:F(e)}),archiveWithDescendants:(e,t=`local`)=>C(P(e,`archive-tree`,t),bo,{method:`POST`,body:F(e)}),restore:(e,t=`local`)=>C(P(e,`restore`,t),xo,{method:`POST`,body:F(e)}),detachParent:(e,t=`local`)=>C(P(e,`detach-parent`,t),So,{method:`POST`,body:F(e)}),reloadSession:(e,t=`local`)=>C(P(e,`reload`,t),Co,{method:`POST`,body:F(e)}),authProviders:e=>{let t=new URLSearchParams;e?.mode!==void 0&&t.set(`mode`,e.mode),e?.authType!==void 0&&t.set(`authType`,e.authType);let n=t.toString();return C(`${N(e?.machineId)}/auth/providers${n===``?``:`?${n}`}`,Ni)},startInteractiveApiKeyLogin:(e,t=`local`)=>C(`${N(t)}/auth/api-key/interactive`,Pi,{method:`POST`,body:JSON.stringify({providerId:e})}),logoutProvider:(e,t=`local`)=>C(`${N(t)}/auth/logout`,mo,{method:`POST`,body:JSON.stringify({providerId:e})}),startOAuthLogin:(e,t=`local`)=>C(`${N(t)}/auth/oauth`,Pi,{method:`POST`,body:JSON.stringify({providerId:e})}),oauthFlow:(e,t=`local`)=>C(`${N(t)}/auth/oauth/${encodeURIComponent(e)}`,Pi),respondOAuthFlow:(e,t,n,r=`local`)=>C(`${N(r)}/auth/oauth/${encodeURIComponent(e)}/respond`,Pi,{method:`POST`,body:JSON.stringify({requestId:t,value:n})}),cancelOAuthFlow:(e,t=`local`)=>C(`${N(t)}/auth/oauth/${encodeURIComponent(e)}/cancel`,Pi,{method:`POST`})},cs={terminals:(e,t,n=`local`)=>C(`${N(n)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,A(ea)),startTerminal:(e,t,n,r=`local`)=>C(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,ea,{method:`POST`,body:JSON.stringify(n??{})}),closeWorkspaceTerminals:(e,t,n=`local`)=>C(`${N(n)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,_o,{method:`DELETE`}),closeTerminal:(e,t,n,r=`local`)=>C(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(n)}`,_o,{method:`DELETE`}),continueTerminal:(e,t,n,r=`local`)=>C(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(n)}/continue`,ea,{method:`POST`}),runTerminalCommand:(e,t,n=`local`)=>C(`${N(n)}/projects/${encodeURIComponent(t.workspace.projectId)}/workspaces/${encodeURIComponent(t.workspace.id)}/terminal-command-runs`,ta,{method:`POST`,body:JSON.stringify({origin:e,title:t.title,command:t.command,metadata:t.metadata??{}})}),listCommandRuns:(e,t=`local`)=>C(`${N(t)}/terminal-command-runs${ps(e)}`,A(ta)),getCommandRun:(e,t=`local`)=>fs(e,t),cancelCommandRun:(e,t=`local`)=>C(`${N(t)}/terminal-command-runs/${encodeURIComponent(e)}/cancel`,ta,{method:`POST`})},ls=class extends Error{constructor(){super(`Fork from the session tree is unavailable. Restart the session daemon to enable it.`),this.name=`SessionTreeForkUnavailableError`}};async function us(e,t,n){let r=await fetch(Wt(P(e,`tree/fork`,n)),{method:`POST`,headers:{"content-type":`application/json`},body:F(e,{entryId:t.entryId,expectedLeafId:t.expectedLeafId})});if(!r.ok){let e=await r.json().catch(()=>({}));throw ds(r.status,e)?new ls:Error(ms(e)??r.statusText)}return oo(await r.json())}function ds(e,t){if(e!==404||!hs(t)||t.statusCode!==404||t.error!==`Not Found`)return!1;let n=t.message;return typeof n==`string`&&/^Route POST:.*\/tree\/fork not found$/i.test(n)}async function fs(e,t){let n=await fetch(Wt(`${N(t)}/terminal-command-runs/${encodeURIComponent(e)}`));if(n.status!==404){if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(ms(e)??n.statusText)}return ta(await n.json())}}function ps(e){if(e===void 0)return``;let t=new URLSearchParams;e.projectId!==void 0&&t.set(`projectId`,e.projectId),e.workspaceId!==void 0&&t.set(`workspaceId`,e.workspaceId),e.terminalId!==void 0&&t.set(`terminalId`,e.terminalId),e.statuses!==void 0&&e.statuses.length>0&&t.set(`statuses`,e.statuses.join(`,`)),e.metadata!==void 0&&Object.keys(e.metadata).length>0&&t.set(`metadata`,JSON.stringify(e.metadata));let n=t.toString();return n===``?``:`?${n}`}function ms(e){if(!hs(e))return;let t=e.error;return typeof t==`string`?t:void 0}function hs(e){return typeof e==`object`&&!!e}var gs={files:(e,t)=>{let n=new URLSearchParams({q:e});return t.kind!==void 0&&n.set(`kind`,t.kind),t.mode!==void 0&&n.set(`mode`,t.mode),t.scope!==void 0&&n.set(`scope`,t.scope),C(`${N(t.machineId)}/projects/${encodeURIComponent(t.projectId)}/workspaces/${encodeURIComponent(t.workspaceId)}/files?${n.toString()}`,A(Gi))}},_s=(e,t,n)=>`${N(e)}/projects/${encodeURIComponent(t)}/workspaces/${encodeURIComponent(n)}/trust`,vs=(e,t)=>{let n=new URLSearchParams({path:t});return`${N(e)}/projects/trust?${n.toString()}`},ys={projectTrust:(e,t=`local`)=>C(vs(t,e),$i),workspaceTrust:(e,t,n=`local`)=>C(_s(n,e,t),$i),setWorkspaceTrust:(e,t,n,r=`local`)=>C(_s(r,e,t),$i,{method:`PUT`,body:JSON.stringify({trusted:n})})},I={...Ko,...qo,...Xo,...Qo,...ns,...is,...os,...ss,...cs,...gs,...ys},bs=256*1024,xs=8*1024*1024,Ss=266240,Cs=8392704,ws=/^[a-z][a-z0-9.-]*$/u,Ts=64;function Es(e){return e.length<=128&&ws.test(e)}function Ds(e){if(!Es(e))throw Error(`Plugin backend operation must match ${String(ws)} and be at most 128 characters`);return e}function Os(e){if(typeof e!=`string`||e===``||e.length>512)throw Error(`Plugin backend revision must be a non-empty string of at most 512 characters`);return e}function ks(e,t,n=bs){let r=Ms(e,new Set,t,0);if(js(JSON.stringify(r))>n)throw Error(`${t} exceeds the ${String(n)} byte limit`);return r}function As(e,t,n=bs){if(js(e)>n)throw Error(`${t} exceeds the ${String(n)} byte limit`);let r;try{r=JSON.parse(e)}catch(e){throw Error(`${t} must be valid JSON`,{cause:e})}return ks(r,t,n)}function js(e){return new TextEncoder().encode(e).byteLength}function Ms(e,t,n,r){if(r>Ts)throw Error(`${n} exceeds the maximum JSON depth of ${String(Ts)}`);if(e===null||typeof e==`string`||typeof e==`boolean`)return e;if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`${n} must contain only finite JSON numbers`);return e}if(Array.isArray(e)){if(t.has(e))throw Error(`${n} must not contain cycles`);t.add(e);let i=e.map(e=>Ms(e,t,n,r+1));return t.delete(e),Object.freeze(i),i}if(!Ps(e))throw Error(`${n} must contain only JSON values`);if(t.has(e))throw Error(`${n} must not contain cycles`);t.add(e);let i={};for(let[a,o]of Object.entries(e))Ns(i,a,Ms(o,t,n,r+1));return t.delete(e),Object.freeze(i)}function Ns(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function Ps(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Fs(e,t){if(!Dn(e.pluginId))throw Error(`Invalid PI WEB plugin id: ${e.pluginId}`);if(e.machineId===``)throw Error(`Machine id is required`);if(e.projectId===``)throw Error(`Project id is required`);if(e.workspaceId===``)throw Error(`Workspace id is required`);let n=Ds(t);return`${e.machineId===`local`?`api`:`api/machines/${encodeURIComponent(e.machineId)}`}/plugin-backends/${encodeURIComponent(e.pluginId)}/projects/${encodeURIComponent(e.projectId)}/workspaces/${encodeURIComponent(e.workspaceId)}/${encodeURIComponent(n)}`}function Is(e,t,n){let r=Fs(e,t);return n===void 0?Wt(r):Wt(r,n)}async function Ls(e,t,n){let r=Os(e.backendRevision),i=ks(n,`Plugin backend request input`),a=JSON.stringify({revision:r,input:i});if(js(a)>266240)throw Error(`Plugin backend request exceeds the ${String(Ss)} byte wire limit`);let o;try{o=await fetch(Is(e,t),{method:`POST`,headers:{"content-type":`application/json`},body:a})}catch(e){throw Error(`Plugin backend request unavailable: ${Vs(e)}`,{cause:e})}let s=await Rs(o);if(!o.ok)throw Error(Bs(s)??`Plugin backend request returned HTTP ${String(o.status)}`);return As(s,`Plugin backend response`,xs)}async function Rs(e){let t=e.headers.get(`content-length`);if(t!==null&&/^\d+$/u.test(t)&&Number(t)>8392704)throw await e.body?.cancel(),Error(`Plugin backend response exceeds the ${String(Cs)} byte wire limit`);if(e.body===null){let t=await e.text();if(js(t)>8392704)throw zs();return t}let n=e.body.getReader(),r=new TextDecoder,i=0,a=``;try{let e=await n.read();for(;!e.done;){if(i+=e.value.byteLength,i>8392704)throw await n.cancel(),zs();a+=r.decode(e.value,{stream:!0}),e=await n.read()}return a+r.decode()}finally{n.releaseLock()}}function zs(){return Error(`Plugin backend response exceeds the ${String(Cs)} byte wire limit`)}function Bs(e){try{let t=JSON.parse(e);return Hs(t)&&typeof t.error==`string`?t.error:void 0}catch{return}}function Vs(e){return e instanceof Error?e.message:String(e)}function Hs(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Us(e,t=`local`){let n=`?${new URLSearchParams({cwd:e.cwd}).toString()}`;return new WebSocket(Gt(`${Ks(t)}/sessions/${encodeURIComponent(e.id)}/events${n}`))}function Ws(e,t,n,r,i=`local`){let a=r===void 0?``:`?${new URLSearchParams({cols:String(r.cols),rows:String(r.rows)}).toString()}`;return new WebSocket(Gt(`${Ks(i)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(n)}/socket${a}`))}function Gs(e=`local`){return new WebSocket(Gt(`${Ks(e)}/events`))}function Ks(e){return`api/machines/${encodeURIComponent(e)}`}var qs=`.pi-web/uploads`,Js=class extends Error{constructor(e=`Workspace upload cancelled`){super(e),this.name=`WorkspaceUploadCancelledError`}},Ys=class extends Error{constructor(e,t){super(oc(e)),this.name=`WorkspaceUploadBatchError`,this.failures=e.map(e=>({...e})),this.responses=t.map(e=>({...e}))}};function Xs(e){return e?.uploads?.defaultFolder??`.pi-web/uploads`}function Zs(e,t){return e.uploads?.defaultFolder??t}function Qs(e,t){let n=lc(e,`upload destination`,{allowEmpty:!0}),r=lc(t,`upload file name`,{allowEmpty:!1});return n===``?r:`${n}/${r}`}function $s(e,t,n,r={}){let i=r.xhrFactory?.()??new XMLHttpRequest,a=!1,o=!1;return{promise:new Promise((s,c)=>{let l=e=>{a||(a=!0,c(e))},u=e=>{a||(a=!0,s(e))};i.open(`PUT`,Lo(e,t,n.path,nc(r)),!0),i.responseType=`json`,i.setRequestHeader(`Content-Type`,(n.contentType??n.file.type)||`application/octet-stream`),i.upload.onprogress=e=>{r.onProgress?.(rc(e,n.file.size))},i.onload=()=>{if(i.status>=200&&i.status<300){try{r.onProgress?.({loaded:n.file.size,total:n.file.size,percent:1,lengthComputable:!0}),u(Yi(dc(i)))}catch(e){l(e instanceof Error?e:Error(String(e)))}return}l(Error(fc(i)))},i.onerror=()=>{l(Error(`Workspace upload failed`))},i.onabort=()=>{l(new Js(o?void 0:`Workspace upload aborted`))},i.send(n.file)}),cancel:()=>{a||(o=!0,i.abort())}}}function ec(e,t,n,r={}){let i=r.destinationFolder??`.pi-web/uploads`,a=n.map((e,t)=>({index:t,name:e.name,path:Qs(i,e.name),loaded:0,total:e.size,percent:ac(0,e.size),lengthComputable:!0,done:!1})),o,s=0,c={requested:!1},l=()=>{r.onProgress?.(ic(a,s,a.every(e=>e.done)))};return{promise:(async()=>{let i=[],u=[];for(let d=0;d<n.length;d+=1){if(c.requested)throw new Js;s=d;let f=n[d],p=a[d];if(!(f===void 0||p===void 0)){o=$s(e,t,{path:p.path,file:f},{...tc(r),onProgress:e=>{p.total=e.total,p.loaded=Math.min(e.loaded,p.total),p.percent=e.percent,p.lengthComputable=e.lengthComputable,l()}});try{let e=await o.promise;p.loaded=p.total,p.percent=1,p.lengthComputable=!0,p.done=!0,i.push(e),l()}catch(e){if(cc(e,c))throw e;let t=sc(e);p.loaded=p.total,p.percent=1,p.lengthComputable=!0,p.done=!0,p.error=t,u.push({index:d,name:f.name,path:p.path,error:t}),l()}finally{o=void 0}}}if(u.length>0)throw new Ys(u,i);return i})(),cancel:()=>{c.requested=!0,o?.cancel()}}}function tc(e){return{...e.createDirs===void 0?{}:{createDirs:e.createDirs},...e.overwrite===void 0?{}:{overwrite:e.overwrite},...e.machineId===void 0?{}:{machineId:e.machineId},...e.xhrFactory===void 0?{}:{xhrFactory:e.xhrFactory}}}function nc(e){return{...e.createDirs===void 0?{}:{createDirs:e.createDirs},...e.overwrite===void 0?{}:{overwrite:e.overwrite},...e.machineId===void 0?{}:{machineId:e.machineId}}}function rc(e,t){let n=e.lengthComputable?e.total:t;return{loaded:e.loaded,total:n,percent:ac(e.loaded,n),lengthComputable:e.lengthComputable}}function ic(e,t,n){let r=e.reduce((e,t)=>e+t.total,0),i=e.reduce((e,t)=>e+t.loaded,0);return{currentFileIndex:t,files:e.map(e=>({...e})),loaded:i,total:r,percent:ac(i,r),done:n}}function ac(e,t){return t<=0?e<=0?0:1:Math.max(0,Math.min(1,e/t))}function oc(e){return e.length===1?e[0]?.error??`Workspace upload failed`:`${String(e.length)} files failed to upload`}function sc(e){return e instanceof Error?e.message:String(e)}function cc(e,t){return t.requested||e instanceof Js}function lc(e,t,n){let r=e.trim();if(r===``){if(n.allowEmpty)return``;throw Error(`${t} must not be empty`)}if(uc(r))throw Error(`${t} must be workspace-relative`);let i=r.split(/[\\/]+/u).filter(e=>e!==``&&e!==`.`);if(i.length===0){if(n.allowEmpty)return``;throw Error(`${t} must not be empty`)}if(i.some(e=>e===`..`))throw Error(`${t} must not contain path traversal`);return i.join(`/`)}function uc(e){let t=e.replace(/\\/g,`/`);return t.startsWith(`/`)||/^[A-Za-z]:\//u.test(t)}function dc(e){return e.response!==void 0&&e.response!==null&&e.response!==``?e.response:e.responseText===``?{}:JSON.parse(e.responseText)}function fc(e){let t=pc(e);return mc(t)&&typeof t.error==`string`?t.error:e.statusText||`HTTP ${String(e.status)}`}function pc(e){try{return dc(e)}catch{return}}function mc(e){return typeof e==`object`&&!!e}function hc(e,t){return{title:e,text:t,empty:t.trim()===``}}function gc(){return{sessions:[],workspaceGoals:[],workspaceGoalsLoading:!1,clientQueuedSessionMessages:{},startingSessionCount:0,selectedNotificationInbox:void 0,treeDialog:void 0,fileTree:[],expandedDirs:{},selectedFilePath:void 0,selectedFileContent:void 0,selectedFileLoadError:void 0,fileTreeStale:!1,selectedTerminalId:void 0,error:``}}function _c(){return{machines:[],selfUpdate:void 0,selfUpdateApplying:!1,selectedMachine:void 0,isLoadingMachines:!1,machineStatuses:{},machineRuntimes:{},machineStatusSnapshots:{},projects:[],workspaces:[],sessions:[],messages:[],messagePageStart:0,messagePageEnd:0,messagePageTotal:0,isLoadingEarlierMessages:!1,sendingPrompts:{},clientQueuedSessionMessages:{},startingSessionCount:0,isLoadingProjects:!1,isLoadingWorkspaces:!1,selectedProject:void 0,selectedWorkspace:void 0,selectedSession:void 0,subagents:[],backgroundTasks:[],subagentRuns:[],activityOutput:void 0,status:void 0,activity:void 0,pendingAsk:void 0,pendingDialogs:[],closedDialogs:[],availableThinkingLevels:[],workspaceGoals:[],workspaceGoalsLoading:!1,sessionStatuses:{},sessionActivities:{},selectedNotificationInbox:void 0,workspacesByProjectId:{},workspaceDeletionRuns:{},commandDialog:void 0,treeDialog:void 0,modelDialog:void 0,thinkingDialog:void 0,themeDialog:void 0,authDialog:void 0,actionPaletteOpen:!1,projectDialogOpen:!1,machineDialogOpen:!1,workspaceTool:`core:workspace.files`,mainView:`chat`,fileTree:[],expandedDirs:{},selectedFilePath:void 0,selectedFileContent:void 0,selectedFileLoadError:void 0,fileTreeStale:!1,workspaceUploadBatches:{},activeTerminalCount:0,selectedTerminalId:void 0,piWebStatus:void 0,error:``}}function vc(e,t){return t?.phase===`active`&&t.startup!==!0||e?.isStreaming===!0||e?.isBashRunning===!0||e?.isCompacting===!0||(e?.pendingMessageCount??0)>0}var yc=`machine.`;function bc(e,t){if(e===``)throw Error(`Machine id is required`);if(!Dn(t))throw Error(`Invalid PI WEB plugin id: ${t}`);if(On(t))throw Error(`Reserved PI WEB plugin id: ${t}`);return`${yc}${xc(e)}.${t}`}function xc(e){return[...new TextEncoder().encode(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}function Sc(e,t){return`${e}:${t}`}function Cc(e,t){return`${e}:${t}`}function L(e){return e.selectedMachine?.id??`local`}var wc=class{constructor(e,t,n,r={}){this.getState=e,this.setState=t,this.applyStatus=n,this.authOperationGeneration=0,this.pollGeneration=0,this.api=r.api??I,this.pollIntervalMs=r.pollIntervalMs??1e3}dispose(){this.advanceAuthOperation()}handleSlashCommand(e){let t=Dc(e);return t===void 0?!1:(t.command===`login`?this.openLogin(t.providerId):this.openLogout(t.providerId),!0)}async openLogin(e){let t=this.advanceAuthOperation(),n=L(this.getState());if(e!==void 0&&e!==``){await this.openLoginProvider(e,n,t);return}this.setState({authDialog:{step:`method`,machineId:n}})}async chooseLoginMethod(e){let t=this.getState().authDialog;if(t?.step!==`method`)return;let n=this.authOperationGeneration,{machineId:r}=t;try{let{providers:i}=await this.api.authProviders({mode:`login`,authType:e,machineId:r});if(!this.isCurrentAuthOperation(n)||this.getState().authDialog!==t)return;this.setState({authDialog:{step:`providers`,mode:`login`,machineId:r,authType:e,providers:i}})}catch(e){this.isCurrentAuthOperation(n)&&this.getState().authDialog===t&&this.setState({error:String(e)})}}async selectLoginProvider(e,t){let n=this.getState().authDialog;if(n?.step!==`providers`)return;let r=n.providers.find(n=>n.id===e&&(t===void 0||n.authType===t));if(r!==void 0&&(r.authType===`oauth`||r.loginFlow===`interactive`)){let e=this.advanceAuthOperation();await this.startLoginFlow(r,n.machineId,e)}}async openLogout(e){let t=this.advanceAuthOperation(),n=L(this.getState());try{let{providers:r}=await this.api.authProviders({mode:`logout`,machineId:n});if(!this.isCurrentAuthOperation(t))return;if(e!==void 0&&e!==``){let i=r.find(t=>t.id===e);i===void 0?this.setState({error:`No stored credentials for ${e}`}):await this.logoutProviderOnMachine(i.id,n,t);return}this.setState({authDialog:{step:`logout`,machineId:n,providers:r}})}catch(e){this.isCurrentAuthOperation(t)&&this.setState({error:String(e)})}}async logoutProvider(e){let t=this.getState().authDialog;if(t?.step!==`logout`)return;let n=this.advanceAuthOperation();await this.logoutProviderOnMachine(e,t.machineId,n)}updateOAuthInput(e){let t=this.getState().authDialog;if(t?.step!==`oauth`)return;let n={...t};delete n.error,this.setState({authDialog:{...n,inputValue:e}})}async respondOAuth(e){let t=this.getState().authDialog;if(t?.step!==`oauth`)return;let n=t.flow.prompt??t.flow.select;if(n===void 0)return;let r=this.authOperationGeneration,i=t.flow.flowId,a=n.requestId,o={flowId:i,requestId:a};if(Tc(this.inFlightResponse,o))return;let s=e??t.inputValue??``,c={...t};delete c.error,this.inFlightResponse=o,this.setState({authDialog:{...c,responding:!0}});try{let e=await this.api.respondOAuthFlow(i,a,s,t.machineId),n=this.currentOAuthDialog(r,i);if(e.flowId!==i||n===void 0||Ec(n.flow)!==a)return;this.updateOAuthFlow(e,n.machineId)}catch(e){let t=this.currentOAuthDialog(r,i);if(t===void 0||Ec(t.flow)!==a)return;this.setState({authDialog:{...t,responding:!1,error:String(e)}})}finally{Tc(this.inFlightResponse,o)&&(this.inFlightResponse=void 0)}}async cancelOAuth(){let e=this.getState().authDialog;if(e?.step!==`oauth`){this.closeDialog();return}let t=e.flow.flowId,n=e.machineId;this.closeDialog();try{await this.api.cancelOAuthFlow(t,n)}catch{}}closeDialog(){this.advanceAuthOperation(),this.setState({authDialog:void 0})}async openLoginProvider(e,t,n){try{let{providers:r}=await this.api.authProviders({mode:`login`,machineId:t});if(!this.isCurrentAuthOperation(n))return;let i=r.filter(t=>t.id===e);if(i.length===0){this.setState({error:`Auth provider not found: ${e}`});return}if(i.length>1){this.setState({authDialog:{step:`providers`,mode:`login`,machineId:t,providers:i}});return}let a=i[0];if(a===void 0)return;(a.authType===`oauth`||a.loginFlow===`interactive`)&&await this.startLoginFlow(a,t,n)}catch(e){this.isCurrentAuthOperation(n)&&this.setState({error:String(e)})}}async logoutProviderOnMachine(e,t,n){if(this.isCurrentAuthOperation(n))try{if(await this.api.logoutProvider(e,t),!this.isCurrentAuthOperation(n))return;this.closeDialog(),this.refreshStatus(t)}catch(e){this.isCurrentAuthOperation(n)&&this.setState({error:String(e)})}}async startLoginFlow(e,t,n){if(this.isCurrentAuthOperation(n))try{let r=e.authType===`oauth`?await this.api.startOAuthLogin(e.id,t):await this.api.startInteractiveApiKeyLogin(e.id,t);if(!this.isCurrentAuthOperation(n)){if(r.status===`running`)try{await this.api.cancelOAuthFlow(r.flowId,t)}catch{}return}this.updateOAuthFlow(r,t),r.status===`running`&&this.startPolling(r.flowId,t)}catch(e){this.isCurrentAuthOperation(n)&&this.setState({error:String(e)})}}updateOAuthFlow(e,t){if(e.status===`complete`){this.stopPolling(),this.closeDialog(),this.refreshStatus(t);return}(e.status===`error`||e.status===`cancelled`)&&this.advanceAuthOperation();let n=this.getState().authDialog,r=n?.step===`oauth`&&n.flow.flowId===e.flowId?n.inputValue??``:``,i=n?.step===`oauth`?Ec(n.flow):void 0,a=Ec(e),o=i!==void 0&&i===a,s=o?r:``,c=o&&n?.step===`oauth`?n.responding===!0:!1;this.setState({authDialog:{step:`oauth`,flow:e,machineId:t,inputValue:s,responding:c}})}startPolling(e,t){this.stopPolling();let n=this.authOperationGeneration,r=this.pollGeneration;this.pollTimer=window.setInterval(()=>{this.poll(e,t,n,r)},this.pollIntervalMs)}stopPolling(){this.pollGeneration+=1,this.pollTimer!==void 0&&(window.clearInterval(this.pollTimer),this.pollTimer=void 0)}async poll(e,t,n,r){if(r!==this.pollGeneration)return;let i=this.currentOAuthDialog(n,e);if(i?.machineId!==t){this.stopPolling();return}let a=Ec(i.flow);try{let i=await this.api.oauthFlow(e,t),o=this.currentOAuthDialog(n,e);if(i.flowId!==e||r!==this.pollGeneration||o?.machineId!==t||Ec(o.flow)!==a)return;this.updateOAuthFlow(i,t)}catch(i){let o=this.currentOAuthDialog(n,e);if(r!==this.pollGeneration||o?.machineId!==t||Ec(o.flow)!==a)return;this.stopPolling(),this.setState({authDialog:{...o,error:String(i)}})}}advanceAuthOperation(){return this.authOperationGeneration+=1,this.stopPolling(),this.authOperationGeneration}isCurrentAuthOperation(e){return e===this.authOperationGeneration}currentOAuthDialog(e,t){if(!this.isCurrentAuthOperation(e))return;let n=this.getState().authDialog;return n?.step===`oauth`&&n.flow.flowId===t?n:void 0}async refreshStatus(e=L(this.getState())){let t=this.selectedSessionForMachine(e);if(t!==void 0)try{let n=await this.api.status(t,e),r=this.selectedSessionForMachine(e);if(r?.id!==t.id||r.cwd!==t.cwd)return;this.applyStatus(n)}catch{}}selectedSessionForMachine(e){let t=this.getState();if(L(t)!==e)return;let n=t.selectedSession;if(!(n===void 0||n.archived===!0))return n}};function Tc(e,t){return e?.flowId===t.flowId&&e.requestId===t.requestId}function Ec(e){return e.prompt?.requestId??e.select?.requestId}function Dc(e){let t=e.trim(),n=/^\/(login|logout)(?:\s+(\S+))?\s*$/u.exec(t);if(n===null)return;let r=n[1];if(r!==`login`&&r!==`logout`)return;let i=n[2];return i===void 0||i===``?{command:r}:{command:r,providerId:i}}function Oc(e){return e.replaceAll(`:`,`.`)}function kc(e){let t=new URLSearchParams(window.location.search),n=`${e}--`,r={};for(let[e,i]of t.entries()){if(!e.startsWith(n))continue;let t=e.slice(n.length),a=r[t];a===void 0?r[t]=i:Array.isArray(a)?a.push(i):r[t]=[a,i]}return r}function Ac(e,t){let n=kc(e)[t];return Array.isArray(n)?n[0]:n===``?void 0:n}function jc(e,t,n,r){let i=new URL(window.location.href),a=`${e}--${t}`;if(i.searchParams.delete(a),n!=null&&n!==``)if(Array.isArray(n))for(let e of n)i.searchParams.append(a,String(e));else i.searchParams.set(a,String(n));Mc(i,r)}function Mc(e,t){`${e.pathname}${e.search}${e.hash}`!=`${window.location.pathname}${window.location.search}${window.location.hash}`&&bt(String(e),t?.replace===!0)}function Nc(e){let t=e.files.map((t,n)=>{let r=t.size;return{index:n,name:t.name,path:Qs(e.destinationFolder,t.name),size:t.size,loaded:0,total:r,percent:zc(0,r),lengthComputable:!0,status:n===0?`uploading`:`pending`}}),n=t.reduce((e,t)=>e+t.total,0);return{id:e.id,projectId:e.projectId,workspaceId:e.workspaceId,machineId:e.machineId,destinationFolder:e.destinationFolder,overwrite:e.overwrite,createDirs:e.createDirs,files:t,currentFileIndex:t.length===0?-1:0,loaded:0,total:n,percent:zc(0,n),status:`uploading`,startedAt:e.startedAt}}function Pc(e,t){let n=new Map(t.files.map(e=>[e.index,e])),r=e.files.map(e=>{let r=n.get(e.index);if(r===void 0)return e;let i={...e,path:r.path,loaded:r.loaded,total:r.total,percent:r.percent,lengthComputable:r.lengthComputable,status:r.error===void 0?r.done?`completed`:t.currentFileIndex===e.index?`uploading`:e.status:`error`};return r.error===void 0?delete i.error:i.error=r.error,i});return{...e,files:r,currentFileIndex:t.currentFileIndex,loaded:t.loaded,total:t.total,percent:t.percent}}function Fc(e,t,n){let r=e.files.map((e,n)=>{let r=t[n];return{...e,...r===void 0?{}:{path:r.path,response:r},loaded:e.total,percent:1,lengthComputable:!0,status:`completed`}}),i=Rc(r);return{...e,files:r,currentFileIndex:r.length===0?-1:r.length-1,...i,status:`completed`,completedAt:n}}function Ic(e,t,n){let r=e.files.map(n=>n.status===`completed`||n.status===`error`?n:n.status===`uploading`||n.index===e.currentFileIndex?{...n,status:`error`,error:t}:{...n,status:`cancelled`,error:`Not uploaded because an earlier file failed.`});return{...e,files:r,...Rc(r),status:`error`,error:t,completedAt:n}}function Lc(e,t){let n=`Upload cancelled`,r=e.files.map(e=>e.status===`completed`||e.status===`error`?e:{...e,status:`cancelled`,error:n});return{...e,files:r,...Rc(r),status:`cancelled`,error:n,completedAt:t}}function Rc(e){let t=e.reduce((e,t)=>e+t.total,0);return{loaded:t,total:t,percent:e.length===0?0:1}}function zc(e,t){return t<=0?e<=0?0:1:Math.max(0,Math.min(1,e/t))}var Bc=class{constructor(e,t){this.getState=e,this.setState=t}report(e){this.reported=e,this.setState({error:e})}clear(){let e=this.reported;this.reported=void 0,!(e===void 0||this.getState().error!==e)&&this.setState({error:``})}},Vc=Oc(`core:workspace.files`),Hc=class{constructor(e,t,n,r={}){this.getState=e,this.setState=t,this.updateUrl=n,this.uploadTasks=new Map,this.uploadBatchSequence=0,this.fileRequestGeneration=0,this.reportedError=new Bc(e,t),this.api=r.api??I,this.uploadWorkspaceFiles=r.uploadWorkspaceFiles??ec,this.createUploadBatchId=r.createUploadBatchId??(()=>(this.uploadBatchSequence+=1,`workspace-upload-${String(this.uploadBatchSequence)}`)),this.now=r.now??(()=>new Date().toISOString())}async refreshFiles(){let e=this.getState().selectedProject,t=this.getState().selectedWorkspace;if(!(e===void 0||t===void 0))try{let n=L(this.getState()),r=await this.api.workspaceTree(e.id,t.id,``,n),i={...this.getState().expandedDirs};await Promise.all(Object.keys(i).map(async r=>{i[r]=(await this.api.workspaceTree(e.id,t.id,r,n)).entries})),this.setState({fileTree:r.entries,expandedDirs:i,fileTreeStale:!1}),this.reportedError.clear()}catch(e){this.reportedError.report(String(e))}}async expandDir(e){let t=this.getState().selectedProject,n=this.getState().selectedWorkspace;if(!(t===void 0||n===void 0)){if(this.getState().expandedDirs[e]!==void 0){this.setState({expandedDirs:Gc(this.getState().expandedDirs,e)});return}try{let r=await this.api.workspaceTree(t.id,n.id,e,L(this.getState()));this.setState({expandedDirs:{...this.getState().expandedDirs,[e]:r.entries}}),this.reportedError.clear()}catch(e){this.reportedError.report(String(e))}}}async selectFile(e){this.setState({selectedFilePath:e,selectedFileContent:void 0,selectedFileLoadError:void 0,workspaceTool:`core:workspace.files`,mainView:this.getState().mainView===`chat`?`chat`:`core:workspace.files`}),jc(Vc,`file`,e),this.updateUrl({replace:!0}),await this.restoreFile(e)}async restoreFile(e){let t=++this.fileRequestGeneration,n=this.getState(),r=n.selectedProject,i=n.selectedWorkspace;if(r===void 0||i===void 0)return;let a={generation:t,machineId:L(n),projectId:r.id,workspaceId:i.id,path:e};this.setState({selectedFilePath:e,selectedFileContent:void 0,selectedFileLoadError:void 0});try{let e=await this.api.workspaceFile(a.projectId,a.workspaceId,a.path,a.machineId);if(!this.isCurrentFileRequest(a))return;this.setState({selectedFileContent:e,selectedFileLoadError:void 0}),this.reportedError.clear()}catch(e){if(!this.isCurrentFileRequest(a))return;this.setState({selectedFileContent:void 0,selectedFileLoadError:Wc(e)})}}isCurrentFileRequest(e){let t=this.getState();return e.generation===this.fileRequestGeneration&&t.selectedFilePath===e.path&&t.selectedProject?.id===e.projectId&&t.selectedWorkspace?.id===e.workspaceId&&L(t)===e.machineId}startWorkspaceUpload(e,t){let n=this.getState().selectedProject,r=this.getState().selectedWorkspace;if(n===void 0||r===void 0){this.reportedError.report(`Select a workspace before uploading files.`);return}if(e.length===0)return;let i=L(this.getState()),a=t.overwrite??!1,o=t.createDirs??!0,s;try{s=Nc({id:this.createUploadBatchId(),projectId:n.id,workspaceId:r.id,machineId:i,destinationFolder:t.destinationFolder,overwrite:a,createDirs:o,files:e,startedAt:this.now()})}catch(e){this.reportedError.report(String(e));return}this.setUploadBatch(s);let c;try{c=this.uploadWorkspaceFiles(n.id,r.id,e,{destinationFolder:t.destinationFolder,machineId:i,overwrite:a,createDirs:o,onProgress:e=>{this.updateUploadProgress(s.id,e)}})}catch(e){return this.failUploadBatch(s.id,e),{batchId:s.id,done:Promise.resolve()}}this.uploadTasks.set(s.id,c);let l=c.promise.then(async e=>{await this.completeUploadBatch(s.id,e,t)}).catch(async e=>{await this.handleUploadFailure(s.id,e,t)}).finally(()=>{this.uploadTasks.delete(s.id)});return{batchId:s.id,done:l}}cancelWorkspaceUpload(e){let t=this.getUploadBatch(e);t?.status===`uploading`&&(this.setUploadBatch(Lc(t,this.now())),this.uploadTasks.get(e)?.cancel())}clearWorkspaceUpload(e){this.uploadTasks.get(e)?.cancel(),this.uploadTasks.delete(e),this.setState({workspaceUploadBatches:Gc(this.getState().workspaceUploadBatches,e)})}updateUploadProgress(e,t){let n=this.getUploadBatch(e);n?.status===`uploading`&&this.setUploadBatch(Pc(n,t))}async completeUploadBatch(e,t,n){let r=this.getUploadBatch(e);if(r?.status!==`uploading`||(this.setUploadBatch(Fc(r,t,this.now())),this.reportedError.clear(),!this.isCurrentWorkspaceBatch(r)))return;await this.refreshFiles();let i=t[0]?.path;n.selectUploadedFile!==!1&&i!==void 0&&this.isCurrentWorkspaceBatch(r)&&await this.selectFile(i)}async handleUploadFailure(e,t,n){let r=this.failUploadBatch(e,t);if(!(t instanceof Ys)||t.responses.length===0||r===void 0||!this.isCurrentWorkspaceBatch(r))return;await this.refreshFiles();let i=t.responses[0]?.path;n.selectUploadedFile!==!1&&i!==void 0&&this.isCurrentWorkspaceBatch(r)&&await this.selectFile(i)}failUploadBatch(e,t){let n=this.getUploadBatch(e);if(n?.status!==`uploading`)return;if(Uc(t)){let e=Lc(n,this.now());return this.setUploadBatch(e),e}let r=Wc(t),i=Ic(n,r,this.now());return this.setUploadBatch(i),this.reportedError.report(r),i}getUploadBatch(e){return this.getState().workspaceUploadBatches[e]}setUploadBatch(e){this.setState({workspaceUploadBatches:{...this.getState().workspaceUploadBatches,[e.id]:e}})}isCurrentWorkspaceBatch(e){let t=this.getState();return t.selectedProject?.id===e.projectId&&t.selectedWorkspace?.id===e.workspaceId&&L(t)===e.machineId}};function Uc(e){return e instanceof Js}function Wc(e){return e instanceof Error?e.message:String(e)}function Gc(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}var Kc=class{constructor(e,t,n,r){this.getState=e,this.setState=t,this.updateUrl=n,this.projects=r,this.runtimeRefreshSeqByMachine=new Map}async loadMachines(e){this.setState({error:``,isLoadingMachines:!0});try{let t=await I.machines(),n=await this.selectInitialMachine(t,e),r=new Set(t.map(e=>e.id));this.setState({machines:t,selectedMachine:n,machineRuntimes:Jc(this.getState().machineRuntimes,r),machineStatusSnapshots:Jc(this.getState().machineStatusSnapshots,r)}),this.refreshMachineHealthFor(t),this.refreshMachineRuntimeFor(t)}catch(e){this.setState({error:String(e)})}finally{this.setState({isLoadingMachines:!1})}}async selectMachine(e,t={}){this.getState().selectedMachine?.id!==e.id&&(this.setState({selectedMachine:e,projects:[],workspaces:[],isLoadingWorkspaces:!1,selectedProject:void 0,selectedWorkspace:void 0,selectedSession:void 0,messages:[],messagePageStart:0,messagePageTotal:0,status:void 0,activity:void 0,sessionStatuses:{},sessionActivities:{},sendingPrompts:{},workspacesByProjectId:{},workspaceDeletionRuns:{},activeTerminalCount:0,...gc()}),t.updateUrl!==!1&&this.updateUrl(),await this.projects.loadProjects(),this.refreshMachineHealth(e.id),this.refreshMachineRuntime(e.id))}async updateMachine(e,t){this.setState({error:``});try{let n=await I.updateMachine(e.id,t);return this.setState({machines:this.getState().machines.map(e=>e.id===n.id?n:e)}),n}catch(e){this.setState({error:String(e)});return}}async addMachine(e){this.setState({error:``});try{let t=await I.addMachine(e);return this.setState({machines:[...this.getState().machines.filter(e=>e.id!==t.id),t]}),await this.selectMachine(t),t}catch(e){this.setState({error:String(e)});return}}async deleteMachine(e=this.getState().selectedMachine,t={}){if(e!==void 0){if(e.kind===`local`){this.setState({error:`The local machine cannot be removed.`});return}try{let n=this.getState().selectedMachine?.id===e.id;await I.deleteMachine(e.id);let r=this.getState().machines.filter(t=>t.id!==e.id),i=r.find(e=>e.id===`local`)??r[0];return this.setState({machines:r,machineStatuses:qc(this.getState().machineStatuses,e.id),machineRuntimes:qc(this.getState().machineRuntimes,e.id),machineStatusSnapshots:qc(this.getState().machineStatusSnapshots,e.id)}),n&&i!==void 0?(t.selectFallback===!1||await this.selectMachine(i),i):void 0}catch(e){this.setState({error:String(e)});return}}}async refreshMachineHealth(e=this.getState().selectedMachine?.id??`local`){try{let t=await I.health(e);return this.setState({machineStatuses:{...this.getState().machineStatuses,[t.machineId]:t}}),t}catch(e){this.setState({error:String(e)});return}}async refreshMachineRuntime(e=this.getState().selectedMachine?.id??`local`){let t=(this.runtimeRefreshSeqByMachine.get(e)??0)+1;this.runtimeRefreshSeqByMachine.set(e,t);try{let n=await I.runtime(e,!0);return this.runtimeRefreshSeqByMachine.get(e)===t?(this.setState({machineRuntimes:{...this.getState().machineRuntimes,[n.machineId]:n}}),n):void 0}catch(n){this.runtimeRefreshSeqByMachine.get(e)===t&&this.setState({error:String(n)});return}}async selectInitialMachine(e,t){let n=e.find(e=>e.id===(t??`local`));if(n===void 0)return this.localMachine(e);if(n.kind!==`remote`)return n;let r=await this.safeRemoteHealth(n);return this.setState({machineStatuses:{...this.getState().machineStatuses,[r.machineId]:r},...r.ok?{}:{error:`${n.name} is unavailable; reconnecting…`}}),n}async safeRemoteHealth(e){try{return await I.health(e.id)}catch(t){return{machineId:e.id,ok:!1,checkedAt:new Date().toISOString(),status:`offline`,error:t instanceof Error?t.message:String(t)}}}localMachine(e){return e.find(e=>e.id===`local`)??e[0]}async refreshMachineHealthFor(e){let t=await Promise.allSettled(e.map(e=>I.health(e.id))),n=Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[[e.value.machineId,e.value]]:[]));Object.keys(n).length>0&&this.setState({machineStatuses:{...this.getState().machineStatuses,...n}})}async refreshMachineRuntimeFor(e){let t=await Promise.allSettled(e.map(e=>I.runtime(e.id))),n=Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[[e.value.machineId,e.value]]:[]));Object.keys(n).length>0&&this.setState({machineRuntimes:{...this.getState().machineRuntimes,...n}})}};function qc(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}function Jc(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>t.has(e)))}var Yc=class{constructor(e=0){if(this.debounceMs=e,this.pendingByKey=new Map,!Number.isInteger(e)||e<0)throw Error(`debounceMs must be a non-negative integer`)}request(e,t){let n=this.pendingByKey.get(e);if(n!==void 0)return n.latestRefresh=t,n.phase===`running`?n.trailing=!0:this.rescheduleDebounce(n),n.promise;let r={promise:Promise.resolve(),latestRefresh:t,phase:`debouncing`,trailing:!1,debounceTimer:void 0,finishDebounce:void 0};return r.promise=Promise.resolve().then(async()=>{let e,t;do{r.trailing=!1,r.phase=`debouncing`,this.debounceMs>0&&await this.waitForDebounce(r),r.phase=`running`;let n=r.latestRefresh;t=!1;try{await n()}catch(n){e=n,t=!0}}while(this.hasTrailingRequest(r));if(t)throw e}).finally(()=>{this.cancelDebounce(r),this.pendingByKey.get(e)===r&&this.pendingByKey.delete(e)}),this.pendingByKey.set(e,r),r.promise}hasTrailingRequest(e){return e.trailing}waitForDebounce(e){return new Promise(t=>{e.finishDebounce=t,this.rescheduleDebounce(e)})}rescheduleDebounce(e){e.finishDebounce!==void 0&&(e.debounceTimer!==void 0&&globalThis.clearTimeout(e.debounceTimer),e.debounceTimer=globalThis.setTimeout(()=>{let t=e.finishDebounce;e.debounceTimer=void 0,e.finishDebounce=void 0,e.phase=`running`,t?.()},this.debounceMs))}cancelDebounce(e){e.debounceTimer!==void 0&&globalThis.clearTimeout(e.debounceTimer),e.debounceTimer=void 0,e.finishDebounce=void 0}},Xc=class{constructor(e,t,n={}){this.getState=e,this.setState=t,this.refreshes=new Yc,this.api=n.api??rs}refresh(e){return this.refreshes.request(e,async()=>{this.apply(e,await this.api.machineStatus(e))})}apply(e,t){let n=this.getState().machineStatusSnapshots;Zc(n[e],t)&&this.setState({machineStatusSnapshots:{...n,[e]:t}})}};function Zc(e,t){return e===void 0||e.epochId!==t.epochId||t.revision>e.revision}var Qc=class{constructor(e,t,n,r={}){this.getState=e,this.setState=t,this.workspaces=n,this.api=r.api??I}async loadProjects(){let e=L(this.getState());this.setState({error:``,isLoadingProjects:!0});try{let t=await this.api.projects(e);if(L(this.getState())!==e)return;let n=new Set(t.map(e=>e.id)),r=Object.fromEntries(Object.entries(this.getState().workspacesByProjectId).filter(([e])=>n.has(e)));this.setState({projects:t,workspacesByProjectId:r})}catch(t){L(this.getState())===e&&this.setState({error:String(t)})}finally{L(this.getState())===e&&this.setState({isLoadingProjects:!1})}}async addProject(e,t,n){if(e.trim()===``)return;let r=L(this.getState());try{let i=await this.api.addProject(e.trim(),void 0,t,r);if(L(this.getState())!==r)return;let a=this.getState().projects;this.setState({projects:[...a.filter(e=>e.id!==i.id),i],projectDialogOpen:!1}),await this.workspaces.selectProject(i),n?.changed===!0&&await this.applyTrustChoice(i,n.trusted,r);return}catch(e){return $c(e)}}async applyTrustChoice(e,t,n){let r=this.getState().workspaces.find(e=>e.isMain);r!==void 0&&await this.api.setWorkspaceTrust(e.id,r.id,t,n)}async closeProject(e){let t=L(this.getState());try{if(await this.api.closeProject(e,t),L(this.getState())!==t)return;this.workspaces.forgetProject(e);let n=this.getState();this.setState({projects:n.projects.filter(t=>t.id!==e)}),n.selectedProject?.id===e&&this.workspaces.clearSelection()}catch(e){L(this.getState())===t&&this.setState({error:String(e)})}}};function $c(e){let t=e instanceof Error?e.message:String(e);return/ENOENT|no such file or directory/u.test(t)?`That folder does not exist. Tick “Create the folder if it does not exist” to make it, or correct the path.`:t.includes(`ENOTDIR`)?`That path is a file, not a folder.`:/EACCES|EPERM/u.test(t)?`That folder cannot be read with this account's permissions.`:t.replace(/^Error:\s*/u,``)}var el=class{constructor(e,t,n={}){this.getState=e,this.setState=t,this.requestSequence=0,this.api=n.api??Ko,this.onRefreshError=n.onRefreshError??(()=>void 0)}async refresh(){let e=L(this.getState());if(this.pendingUpdateCheck?.machineId===e)return;let t=++this.requestSequence;try{let n=await this.api.piWebStatus(e);this.isCurrent(e,t)&&this.setState({piWebStatus:n})}catch(n){if(!this.isCurrent(e,t))return;this.setState({piWebStatus:void 0}),this.onRefreshError(e,n)}}checkForUpdates(){let e=L(this.getState()),t=this.pendingUpdateCheck;if(t?.machineId===e)return t.promise;let n=++this.requestSequence,r=this.api.checkForUpdates(e).then(t=>{this.isCurrent(e,n)&&(this.setState({piWebStatus:t}),tl(t))}).catch(t=>{if(this.isCurrent(e,n))throw t}).finally(()=>{this.pendingUpdateCheck?.requestSequence===n&&(this.pendingUpdateCheck=void 0)});return this.pendingUpdateCheck={machineId:e,requestSequence:n,promise:r},r}isCurrent(e,t){return L(this.getState())===e&&t===this.requestSequence}};function tl(e){if(e.release.error!==void 0)throw Error(`PI WEB update check failed: ${e.release.error}`);if(e.release.skipped===!0)throw Error(`PI WEB update check was skipped because remote version checks are disabled by offline/version-check settings`)}function nl(e,t){let n=e.cwd;if(n===void 0||n===``)return;let r=t.workspaces.find(e=>e.path===n);if(r===void 0)return;let i=t.projects.find(e=>e.id===r.projectId);if(i!==void 0)return{workspace:r,project:i}}function rl(e){return e.selectedSessionCwd!==void 0&&e.selectedSessionCwd===e.refreshedWorkspacePath}var il=`pi-web:cached-new-sessions:v1`,al=`browserCachedNew`,ol=`local`;function sl(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function cl(e,t=ol,n=sl()){if(e.messageCount!==0||e.archived===!0)return;let r=ml(n).filter(n=>n.id!==e.id||n.machineId!==t);hl([ll(e,t),...r],n)}function ll(e,t=ol){return{...e,browserCachedNew:!0,machineId:t}}function ul(e,t=ol,n=sl()){hl(ml(n).filter(n=>n.id!==e||n.machineId!==t),n)}function dl(e,t,n=ol,r=sl()){let i=new Set(t.map(e=>e.id)),a=ml(r),o=a.filter(e=>e.machineId!==n||!i.has(e.id));return o.length!==a.length&&hl(o,r),[...o.filter(t=>t.machineId===n&&t.cwd===e),...t]}function fl(e){return e!==void 0&&_l(e)&&e.browserCachedNew===!0}function pl(e){return{id:e.id,path:e.path,cwd:e.cwd,...e.persisted===void 0?{}:{persisted:e.persisted},...e.name===void 0?{}:{name:e.name},created:e.created,modified:e.modified,messageCount:e.messageCount,firstMessage:e.firstMessage,...e.parentSessionPath===void 0?{}:{parentSessionPath:e.parentSessionPath},...`machineId`in e&&typeof e.machineId==`string`?{machineId:e.machineId}:{machineId:ol},...e.archived===!0?{archived:!0}:{},...e.archivedAt===void 0?{}:{archivedAt:e.archivedAt}}}function ml(e=sl()){try{let t=e?.getItem(il);if(t==null||t===``)return[];let n=JSON.parse(t);return Array.isArray(n)?n.flatMap(e=>gl(e)):[]}catch{return[]}}function hl(e,t=sl()){try{e.length===0?t?.removeItem(il):t?.setItem(il,JSON.stringify(e))}catch{}}function gl(e){if(!vl(e))return[];let t=yl(e,`id`),n=yl(e,`path`),r=yl(e,`cwd`),i=yl(e,`created`),a=yl(e,`modified`),o=yl(e,`firstMessage`),s=xl(e,`messageCount`);if(t===void 0||n===void 0||r===void 0||i===void 0||a===void 0||o===void 0||s!==0)return[];let c=bl(e,`name`),l=bl(e,`parentSessionPath`),u=bl(e,`machineId`)??ol;return[{id:t,path:n,cwd:r,...c===void 0?{}:{name:c},created:i,modified:a,messageCount:s,firstMessage:o,...l===void 0?{}:{parentSessionPath:l},machineId:u,browserCachedNew:!0}]}function _l(e){return al in e}function vl(e){return typeof e==`object`&&!!e}function yl(e,t){let n=e[t];return typeof n==`string`?n:void 0}function bl(e,t){let n=e[t];return n===void 0||typeof n!=`string`?void 0:n}function xl(e,t){let n=e[t];return typeof n==`number`?n:void 0}function Sl(e){return Kl(e.flatMap(Dl)).filter(e=>e.parts.length>0)}function Cl(e,t){return{role:e,parts:[{type:`text`,text:t}]}}function wl(e,t){let n=Fl(t);return n===void 0?e:{...e,meta:n}}function Tl(e,t,n){if(n===``)return e;let r=e.at(-1),i=r?.parts.at(-1);return r?.role===t&&i?.type===`text`?[...e.slice(0,-1),{...r,parts:[...r.parts.slice(0,-1),{...i,text:i.text+n}]}]:r?.role===t?[...e.slice(0,-1),{...r,parts:[...r.parts,{type:`text`,text:n}]}]:[...e,Cl(t,n)]}function El(e,t){if(t===``)return e;let n=e.at(-1),r=n?.parts.at(-1);return n?.role===`assistant`&&r?.type===`thinking`?[...e.slice(0,-1),{...n,parts:[...n.parts.slice(0,-1),{...r,text:r.text+t}]}]:n?.role===`assistant`?[...e.slice(0,-1),{...n,parts:[...n.parts,{type:`thinking`,text:t}]}]:[...e,{role:`assistant`,parts:[{type:`thinking`,text:t}]}]}function Dl(e){if(jl(e))return[e];if(R(e,`role`)===`bashExecution`)return[wl(Rl(e),e)];let t=R(e,`role`),n=zl(t),r=Bl(eu(e,`content`),e),i=t===`toolResult`?Hl(R(e,`toolName`)??``,eu(e,`details`)):void 0,a=i===void 0?r:[...r,i],o=n===`user`?Ml(a):void 0;if(o!==void 0)return o.map(t=>wl(t,e));let s=Pl(e);if(n===`tool`)return[wl({role:n,parts:a,...s===void 0?{}:{source:s}},e)];let c=a.filter(e=>e.type!==`empty`),l=n===`assistant`&&c.length>0&&c.every(e=>e.type===`skillRead`)?`skill`:n,u=c.length>0?[wl({role:l,parts:c,...s===void 0?{}:{source:s}},e)]:[],d=Ol(e);return d===void 0?u:[...u,wl(d,e)]}function Ol(e){if(R(e,`role`)!==`assistant`||R(e,`stopReason`)!==`error`)return;let t=R(e,`errorMessage`)?.trim();return Cl(`system`,`Model response failed: ${kl(t===void 0||t===``?`The model returned an error.`:t,e)}`)}function kl(e,t){if(!/aborted/iu.test(e))return e;let n=Al(t);return n===void 0?`${e} (the turn was stopped before it finished)`:`${e} (stopped while running ${n})`}function Al(e){let t=eu(e,`content`);if(Array.isArray(t))for(let e=t.length-1;e>=0;--e){let n=t[e],r=R(n,`type`);if(r!==`toolCall`&&r!==`toolExecution`)continue;let i=R(n,`name`)??R(n,`toolName`);if(i!==void 0&&i!==``)return i}}function jl(e){let t=R(e,`role`);return(t===`user`||t===`assistant`||t===`tool`||t===`system`||t===`bash`||t===`skill`)&&Array.isArray(eu(e,`parts`))}function Ml(e){if(e.length!==1||e[0]?.type!==`text`)return;let t=Nl(e[0].text);if(t!==void 0)return[{role:`user`,parts:[{type:`skillInvocation`,name:t.name,location:t.location,content:t.content}]},...t.userMessage===void 0?[]:[{role:`user`,parts:[{type:`text`,text:t.userMessage}]}]]}function Nl(e){let t=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/.exec(e);if(t===null)return;let n=t[4]?.trim();return{name:t[1]??`skill`,location:t[2]??``,content:t[3]??``,...n===void 0||n===``?{}:{userMessage:n}}}function Pl(e){let t=R(e,`source`);if(t===`compaction`||t===`branch_summary`)return t}function Fl(e){let t=Il(eu(e,`timestamp`)),n=Ll(e),r=R(e,`thinkingLevel`);if(!(t===void 0&&n===void 0&&(r===void 0||r===``)))return{...t===void 0?{}:{timestamp:t},...n===void 0?{}:{model:n},...r===void 0||r===``?{}:{thinkingLevel:r}}}function Il(e){if(typeof e==`number`&&Number.isFinite(e))return new Date(e).toISOString();if(typeof e!=`string`||e===``)return;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():void 0}function Ll(e){if(R(e,`role`)!==`assistant`)return;let t=R(e,`provider`),n=R(e,`model`),r=R(e,`responseModel`);if(!((t===void 0||t===``)&&(n===void 0||n===``)&&(r===void 0||r===``)))return{...t===void 0||t===``?{}:{provider:t},...n===void 0||n===``?{}:{id:n},...r===void 0||r===``?{}:{responseId:r}}}function Rl(e){let t=R(e,`command`)??``,n=tu(e,`excludeFromContext`)===!0?[`excluded from context`,``,`$ ${t}`]:[`$ ${t}`],r=eu(e,`output`);r!=null&&n.push(``,ru(r));let i=eu(e,`exitCode`);i!=null&&n.push(``,`exit ${ru(i)}`),tu(e,`cancelled`)===!0&&n.push(``,`cancelled`),tu(e,`truncated`)===!0&&n.push(``,`output truncated`);let a=R(e,`fullOutputPath`);return a!==void 0&&a!==``&&n.push(``,`full output: ${a}`),{role:`bash`,parts:[{type:`text`,text:n.join(`
|
|
4
|
-
`)}]}}function zl(e){return e===`assistant`?`assistant`:e===`user`?`user`:e===`toolResult`?`tool`:`system`}function Bl(e,t){let n=Vl(t);return n===void 0?typeof e==`string`?e===``?[]:[{type:`text`,text:e}]:Array.isArray(e)?e.flatMap(e=>{let t=R(e,`type`),n=R(e,`text`);if(t===`text`)return n!==void 0&&n!==``?[{type:`text`,text:n}]:[];if(t===`thinking`){let t=R(e,`thinking`)??n;return t!==void 0&&t!==``?[{type:`thinking`,text:t}]:[]}if(t===`toolCall`){let t=R(e,`name`)??`tool`,n=eu(e,`arguments`),r=R(e,`id`),i=t===`read`?Gl(R(n,`path`)):void 0;return i===void 0?[{type:`toolCall`,...r===void 0?{}:{toolCallId:r},toolName:t,summary:Zl(n),...n===void 0?{}:{args:n}}]:[{type:`skillRead`,...i,...r===void 0?{}:{toolCallId:r}}]}if(t===`image`){let t=R(e,`data`),n=R(e,`mimeType`);return t!==void 0&&t!==``&&n!==void 0&&n!==``?[{type:`image`,mimeType:n,data:t}]:[{type:`text`,text:`[image]`}]}return Xl(e)}).map(e=>e.type===`text`&&R(t,`role`)===`toolResult`?Wl(e.text,t):e):Xl(e):[n]}function Vl(e){if(!(R(e,`role`)!==`custom`||R(e,`customType`)!==`pi-web.ask.answers`))return Ul(eu(e,`details`))}function Hl(e,t){if(e===`ask_user`)return Ul(eu(t,`superseded`))}function Ul(e){try{return{type:`askUserRecord`,outcome:fr(e)}}catch{return}}function Wl(e,t){let n=R(t,`toolCallId`),r=eu(t,`content`),i=eu(t,`details`);return{type:`toolResult`,...n===void 0?{}:{toolCallId:n},toolName:R(t,`toolName`)??`tool`,text:e,...r===void 0?{}:{content:r},...i===void 0?{}:{details:i},isError:tu(t,`isError`)===!0}}function Gl(e){if(e===void 0||e===``)return;let t=e.replace(/\\/g,`/`);if(!t.endsWith(`/SKILL.md`)&&t!==`SKILL.md`)return;let n=t.split(`/`).at(-2);if(!(n===void 0||n===``))return{name:n,path:e}}function Kl(e){let t=[],n=new Map;for(let r of e){let e=[],i={...r.source===void 0?{}:{source:r.source},...r.meta===void 0?{}:{meta:r.meta}},a=()=>{e.length!==0&&(t.push({role:r.role,parts:e,...i}),e=[])};for(let o of r.parts){if(o.type===`toolCall`){a();let e=ql(o),r=t.length;t.push({role:`tool`,parts:[e],...i}),e.toolCallId!==void 0&&n.set(e.toolCallId,{lineIndex:r,partIndex:0});continue}if(o.type===`toolResult`){let e=o.toolCallId===void 0?void 0:n.get(o.toolCallId);if(e!==void 0&&Jl(t,e,o)){n.delete(o.toolCallId??``);continue}}e.push(o)}a()}return t}function ql(e){return{type:`toolExecution`,...e.toolCallId===void 0?{}:{toolCallId:e.toolCallId},toolName:e.toolName,summary:e.summary,...e.args===void 0?{}:{args:e.args},status:`pending`}}function Jl(e,t,n){let r=e[t.lineIndex],i=r?.parts[t.partIndex];if(r===void 0||i?.type!==`toolExecution`)return!1;let a=Yl(n.details)??i.preview,o={...i,status:n.isError?`error`:`success`,resultText:n.text,...n.content===void 0?{}:{content:n.content},...n.details===void 0?{}:{details:n.details},...a===void 0?{}:{preview:a}};return e[t.lineIndex]={...r,parts:[...r.parts.slice(0,t.partIndex),o,...r.parts.slice(t.partIndex+1)]},!0}function Yl(e){let t=eu(e,`preview`);if(!$l(t))return;let n=R(t,`diff`),r=R(t,`error`),i=nu(t,`firstChangedLine`);if(!(n===void 0&&r===void 0&&i===void 0))return{...n===void 0?{}:{diff:n},...r===void 0?{}:{error:r},...i===void 0?{}:{firstChangedLine:i}}}function Xl(e){return e==null?[]:typeof e==`object`?[{type:`text`,text:Zl(e)}]:[{type:`text`,text:ru(e)}]}function Zl(e){if(!$l(e))return ru(e);let t=R(e,`command`);if(t!==void 0)return t;let n=R(e,`path`);if(n!==void 0)return n;if(typeof e.oldText==`string`&&typeof e.newText==`string`)return`edit text replacement`;let r=e.edits;return Array.isArray(r)?`${String(r.length)} edit${r.length===1?``:`s`}`:Object.entries(e).filter(([,e])=>e!=null).slice(0,3).map(([e,t])=>`${e}: ${Ql(t)}`).join(` · `)}function Ql(e){return typeof e==`string`?e.length>80?`${e.slice(0,77)}…`:e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?`${String(e.length)} item${e.length===1?``:`s`}`:typeof e==`object`&&e?`object`:``}function $l(e){return typeof e==`object`&&!!e}function eu(e,t){return $l(e)?e[t]:void 0}function R(e,t){let n=eu(e,t);return typeof n==`string`?n:void 0}function tu(e,t){let n=eu(e,t);return typeof n==`boolean`?n:void 0}function nu(e,t){let n=eu(e,t);return typeof n==`number`&&Number.isFinite(n)?n:void 0}function ru(e){return e==null?``:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`?String(e):``}var iu=`pi-web:prompt-draft:`;function au(e){return`${iu}${e}`}function ou(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function su(e,t=ou()){try{return t?.getItem(au(e))??``}catch{return``}}function cu(e,t,n=ou()){try{t?n?.setItem(au(e),t):n?.removeItem(au(e))}catch{}}function lu(e,t=ou()){try{t?.removeItem(au(e))}catch{}}function uu(e,t,n=ou()){let r=su(e,n);r!==``&&(cu(t,r,n),lu(e,n))}function du(e){return!e.hasRendered||e.sessionChanged||e.machineChanged}function fu(e){return e.hasRendered}var pu=`pi-web:ask-draft:`;function mu(e,t){return`${pu}${e}:${t}`}function hu(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function gu(e,t,n=hu()){try{let r=n?.getItem(mu(e,t));return r==null?{}:yu(r)}catch{return{}}}function _u(e,t,n,r=hu()){try{let i=Object.entries(n).filter(([,e])=>e.values.length>0||(e.otherText??``)!==``);i.length===0?r?.removeItem(mu(e,t)):r?.setItem(mu(e,t),JSON.stringify(Object.fromEntries(i)))}catch{}}function vu(e,t,n=hu()){try{n?.removeItem(mu(e,t))}catch{}}function yu(e){let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t)){let t=bu(r);t!==void 0&&(n[e]=t)}return n}function bu(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t={...e},n=t.values,r=t.otherText;if(!(!Array.isArray(n)||!n.every(e=>typeof e==`string`))&&!(r!==void 0&&typeof r!=`string`))return{values:[...n],...r===void 0?{}:{otherText:r}}}function xu(e,t){return e.filter(e=>wu(e,t[e.id])!==void 0).length}function Su(e,t){return e.filter(e=>wu(e,t[e.id])===void 0)}function Cu(e,t){let n=[];for(let r of e){let e=wu(r,t[r.id]);e!==void 0&&n.push(e)}return{answers:n}}function wu(e,t){if(t===void 0)return;let n=new Set(e.options.map(e=>e.value)),r=[...new Set(t.values)].filter(e=>n.has(e)),i=Tu(t.otherText);if(e.multiple!==!0&&r.length+(i===void 0?0:1)>1){let t=r[0];return t===void 0?i===void 0?void 0:{id:e.id,values:[],otherText:i}:{id:e.id,values:[t]}}if(!(r.length===0&&i===void 0))return{id:e.id,values:r,...i===void 0?{}:{otherText:i}}}function Tu(e){if(e===void 0)return;let t=e.trim().slice(0,sn);return t===``?void 0:t}function Eu(e,t){if(t.role===`user`)return[...e,t];let n=Du(t);if(n===void 0)return[...e,t];let r=e.length;for(;r>0;){let t=e[r-1],i=t===void 0?void 0:Du(t);if(i===void 0||i<=n)break;--r}return r===e.length?[...e,t]:[...e.slice(0,r),t,...e.slice(r)]}function Du(e){let t=e.meta?.timestamp;if(t===void 0||t===``)return;let n=Date.parse(t);return Number.isNaN(n)?void 0:n}function Ou(){let e=globalThis.crypto.randomUUID?.();return e===void 0?`cm-${String(Date.now())}-${Math.random().toString(36).slice(2,10)}`:e}function ku(e,t,n=[]){let r=n.filter(e=>e.kind===`image`).map(e=>({type:`image`,mimeType:e.mimeType,data:e.data}));return{role:`user`,parts:e===``?[...r]:[{type:`text`,text:e},...r],meta:{delivery:{clientMessageId:t,state:`sending`}}}}function Au(e,t){if(t.length===0)return[...e];let n=new Map,r=[];for(let t of e){let e=t.meta?.delivery;e===void 0||e.state===`delivered`||e.state===`failed`||(n.set(e.clientMessageId,t),r.push(t))}let i=[];for(let e of t){let t=(e.clientMessageId===void 0?void 0:n.get(e.clientMessageId))??r.find(t=>t.meta?.delivery?.kind===e.kind&&ju(t)===e.text);t!==void 0&&r.splice(r.indexOf(t),1),i.push(t??Mu(e))}let a=new Set(i);return[...e.filter(e=>!a.has(e)),...i]}function ju(e){return e.parts.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function Mu(e){let t=e.clientMessageId??`queued:${e.kind}:${e.text}`;return{role:`user`,parts:[{type:`text`,text:e.text}],meta:{delivery:{clientMessageId:t,state:`queued`,kind:e.kind}}}}function Nu(e,t){return e.findIndex(e=>e.meta?.delivery?.clientMessageId===t)}function Pu(e,t,n,r){let i=Nu(e,t);if(i===-1)return e;let a=e[i],o=a?.meta?.delivery;if(a===void 0||o===void 0||!Lu(o.state,n)&&!Fu(o.kind,r,o.state,n))return e;let s=[...e],c=Lu(o.state,n)?n:o.state,l=r??o.kind;return s[i]={...a,meta:{...a.meta,delivery:{clientMessageId:t,state:c,...l===void 0?{}:{kind:l}}}},s}function Fu(e,t,n,r){return t!==void 0&&t!==e&&n===`queued`&&r===`queued`}var Iu={failed:-1,sending:0,received:1,queued:2,delivered:3};function Lu(e,t){return e===t?!1:t===`failed`?e!==`delivered`:e!==`failed`&&Iu[t]>Iu[e]}function Ru(e,t){let n=Nu(e,t);if(n===-1)return[...e];let r=e[n];if(r?.meta?.delivery?.state!==`failed`)return[...e];let i=r.meta.delivery,a=[...e];return a[n]={...r,meta:{...r.meta,delivery:{clientMessageId:t,state:`sending`,...i.kind===void 0?{}:{kind:i.kind}}}},a}function zu(e,t){let n=Nu(e,t);return n===-1?[...e]:[...e.slice(0,n),...e.slice(n+1)]}function Bu(e,t){let n=e,r=new Map;for(let e of t)e.clientMessageId!==void 0&&r.set(e.clientMessageId,e.kind);for(let t of e){let e=t.meta?.delivery;if(e===void 0)continue;let i=r.get(e.clientMessageId);if(i!==void 0){n=Pu(n,e.clientMessageId,`queued`,i);continue}(e.state===`received`||e.state===`queued`)&&(n=Pu(n,e.clientMessageId,`delivered`))}return n}function Vu(e,t){return t!==void 0&&Nu(e,t)!==-1}function Hu(e,t){let n=e.meta?.delivery;return n===void 0?t:{...t,meta:{...t.meta,delivery:{...n,state:n.state===`failed`?n.state:`delivered`}}}}function Uu(e,t){return t===``?-1:e.findIndex(e=>e.role===`user`&&e.meta?.delivery!==void 0&&Wu(e)===t)}function Wu(e){return e.parts.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
4
|
+
`)}]}}function zl(e){return e===`assistant`?`assistant`:e===`user`?`user`:e===`toolResult`?`tool`:`system`}function Bl(e,t){let n=Vl(t);return n===void 0?typeof e==`string`?e===``?[]:[{type:`text`,text:e}]:Array.isArray(e)?e.flatMap(e=>{let t=R(e,`type`),n=R(e,`text`);if(t===`text`)return n!==void 0&&n!==``?[{type:`text`,text:n}]:[];if(t===`thinking`){let t=R(e,`thinking`)??n;return t!==void 0&&t!==``?[{type:`thinking`,text:t}]:[]}if(t===`toolCall`){let t=R(e,`name`)??`tool`,n=eu(e,`arguments`),r=R(e,`id`),i=t===`read`?Gl(R(n,`path`)):void 0;return i===void 0?[{type:`toolCall`,...r===void 0?{}:{toolCallId:r},toolName:t,summary:Zl(n),...n===void 0?{}:{args:n}}]:[{type:`skillRead`,...i,...r===void 0?{}:{toolCallId:r}}]}if(t===`image`){let t=R(e,`data`),n=R(e,`mimeType`);return t!==void 0&&t!==``&&n!==void 0&&n!==``?[{type:`image`,mimeType:n,data:t}]:[{type:`text`,text:`[image]`}]}return Xl(e)}).map(e=>e.type===`text`&&R(t,`role`)===`toolResult`?Wl(e.text,t):e):Xl(e):[n]}function Vl(e){if(!(R(e,`role`)!==`custom`||R(e,`customType`)!==`pi-web.ask.answers`))return Ul(eu(e,`details`))}function Hl(e,t){if(e===`ask_user`)return Ul(eu(t,`superseded`))}function Ul(e){try{return{type:`askUserRecord`,outcome:fr(e)}}catch{return}}function Wl(e,t){let n=R(t,`toolCallId`),r=eu(t,`content`),i=eu(t,`details`);return{type:`toolResult`,...n===void 0?{}:{toolCallId:n},toolName:R(t,`toolName`)??`tool`,text:e,...r===void 0?{}:{content:r},...i===void 0?{}:{details:i},isError:tu(t,`isError`)===!0}}function Gl(e){if(e===void 0||e===``)return;let t=e.replace(/\\/g,`/`);if(!t.endsWith(`/SKILL.md`)&&t!==`SKILL.md`)return;let n=t.split(`/`).at(-2);if(!(n===void 0||n===``))return{name:n,path:e}}function Kl(e){let t=[],n=new Map;for(let r of e){let e=[],i={...r.source===void 0?{}:{source:r.source},...r.meta===void 0?{}:{meta:r.meta}},a=()=>{e.length!==0&&(t.push({role:r.role,parts:e,...i}),e=[])};for(let o of r.parts){if(o.type===`toolCall`){a();let e=ql(o),r=t.length;t.push({role:`tool`,parts:[e],...i}),e.toolCallId!==void 0&&n.set(e.toolCallId,{lineIndex:r,partIndex:0});continue}if(o.type===`toolResult`){let e=o.toolCallId===void 0?void 0:n.get(o.toolCallId);if(e!==void 0&&Jl(t,e,o)){n.delete(o.toolCallId??``);continue}}e.push(o)}a()}return t}function ql(e){return{type:`toolExecution`,...e.toolCallId===void 0?{}:{toolCallId:e.toolCallId},toolName:e.toolName,summary:e.summary,...e.args===void 0?{}:{args:e.args},status:`pending`}}function Jl(e,t,n){let r=e[t.lineIndex],i=r?.parts[t.partIndex];if(r===void 0||i?.type!==`toolExecution`)return!1;let a=Yl(n.details)??i.preview,o={...i,status:n.isError?`error`:`success`,resultText:n.text,...n.content===void 0?{}:{content:n.content},...n.details===void 0?{}:{details:n.details},...a===void 0?{}:{preview:a}};return e[t.lineIndex]={...r,parts:[...r.parts.slice(0,t.partIndex),o,...r.parts.slice(t.partIndex+1)]},!0}function Yl(e){let t=eu(e,`preview`);if(!$l(t))return;let n=R(t,`diff`),r=R(t,`error`),i=nu(t,`firstChangedLine`);if(!(n===void 0&&r===void 0&&i===void 0))return{...n===void 0?{}:{diff:n},...r===void 0?{}:{error:r},...i===void 0?{}:{firstChangedLine:i}}}function Xl(e){return e==null?[]:typeof e==`object`?[{type:`text`,text:Zl(e)}]:[{type:`text`,text:ru(e)}]}function Zl(e){if(!$l(e))return ru(e);let t=R(e,`command`);if(t!==void 0)return t;let n=R(e,`path`);if(n!==void 0)return n;if(typeof e.oldText==`string`&&typeof e.newText==`string`)return`edit text replacement`;let r=e.edits;return Array.isArray(r)?`${String(r.length)} edit${r.length===1?``:`s`}`:Object.entries(e).filter(([,e])=>e!=null).slice(0,3).map(([e,t])=>`${e}: ${Ql(t)}`).join(` · `)}function Ql(e){return typeof e==`string`?e.length>80?`${e.slice(0,77)}…`:e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?`${String(e.length)} item${e.length===1?``:`s`}`:typeof e==`object`&&e?`object`:``}function $l(e){return typeof e==`object`&&!!e}function eu(e,t){return $l(e)?e[t]:void 0}function R(e,t){let n=eu(e,t);return typeof n==`string`?n:void 0}function tu(e,t){let n=eu(e,t);return typeof n==`boolean`?n:void 0}function nu(e,t){let n=eu(e,t);return typeof n==`number`&&Number.isFinite(n)?n:void 0}function ru(e){return e==null?``:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`?String(e):``}var iu=`pi-web:prompt-draft:`;function au(e){return`${iu}${e}`}function ou(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function su(e,t=ou()){try{return t?.getItem(au(e))??``}catch{return``}}function cu(e,t,n=ou()){try{t?n?.setItem(au(e),t):n?.removeItem(au(e))}catch{}}function lu(e,t=ou()){try{t?.removeItem(au(e))}catch{}}function uu(e,t,n=ou()){let r=su(e,n);r!==``&&(cu(t,r,n),lu(e,n))}function du(e){return!e.hasRendered||e.sessionChanged||e.machineChanged}function fu(e){return e.hasRendered}var pu=`pi-web:ask-draft:`;function mu(e,t){return`${pu}${e}:${t}`}function hu(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function gu(e,t,n=hu()){try{let r=n?.getItem(mu(e,t));return r==null?{}:yu(r)}catch{return{}}}function _u(e,t,n,r=hu()){try{let i=Object.entries(n).filter(([,e])=>e.values.length>0||(e.otherText??``)!==``);i.length===0?r?.removeItem(mu(e,t)):r?.setItem(mu(e,t),JSON.stringify(Object.fromEntries(i)))}catch{}}function vu(e,t,n=hu()){try{n?.removeItem(mu(e,t))}catch{}}function yu(e){let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t)){let t=bu(r);t!==void 0&&(n[e]=t)}return n}function bu(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t={...e},n=t.values,r=t.otherText;if(!(!Array.isArray(n)||!n.every(e=>typeof e==`string`))&&!(r!==void 0&&typeof r!=`string`))return{values:[...n],...r===void 0?{}:{otherText:r}}}function xu(e,t){return e.filter(e=>wu(e,t[e.id])!==void 0).length}function Su(e,t){return e.filter(e=>wu(e,t[e.id])===void 0)}function Cu(e,t){let n=[];for(let r of e){let e=wu(r,t[r.id]);e!==void 0&&n.push(e)}return{answers:n}}function wu(e,t){if(t===void 0)return;let n=new Set(e.options.map(e=>e.value)),r=[...new Set(t.values)].filter(e=>n.has(e)),i=Tu(t.otherText);if(e.multiple!==!0&&r.length+(i===void 0?0:1)>1){let t=r[0];return t===void 0?i===void 0?void 0:{id:e.id,values:[],otherText:i}:{id:e.id,values:[t]}}if(!(r.length===0&&i===void 0))return{id:e.id,values:r,...i===void 0?{}:{otherText:i}}}function Tu(e){if(e===void 0)return;let t=e.trim().slice(0,sn);return t===``?void 0:t}function Eu(e,t){if(t.role===`user`)return[...e,t];let n=Du(t);if(n===void 0)return[...e,t];let r=e.length;for(;r>0;){let t=e[r-1],i=t===void 0?void 0:Du(t);if(i===void 0||i<=n)break;--r}return r===e.length?[...e,t]:[...e.slice(0,r),t,...e.slice(r)]}function Du(e){let t=e.meta?.timestamp;if(t===void 0||t===``)return;let n=Date.parse(t);return Number.isNaN(n)?void 0:n}function Ou(){let e=globalThis.crypto.randomUUID?.();return e===void 0?`cm-${String(Date.now())}-${Math.random().toString(36).slice(2,10)}`:e}function ku(e,t,n=[]){let r=n.filter(e=>e.kind===`image`).map(e=>({type:`image`,mimeType:e.mimeType,data:e.data}));return{role:`user`,parts:e===``?[...r]:[{type:`text`,text:e},...r],meta:{timestamp:new Date().toISOString(),delivery:{clientMessageId:t,state:`sending`}}}}function Au(e,t){if(t.length===0)return[...e];let n=new Map,r=[];for(let t of e){let e=t.meta?.delivery;e===void 0||e.state===`delivered`||e.state===`failed`||(n.set(e.clientMessageId,t),r.push(t))}let i=[];for(let e of t){let t=(e.clientMessageId===void 0?void 0:n.get(e.clientMessageId))??r.find(t=>t.meta?.delivery?.kind===e.kind&&ju(t)===e.text);t!==void 0&&r.splice(r.indexOf(t),1),i.push(t??Mu(e))}let a=new Set(i);return[...e.filter(e=>!a.has(e)),...i]}function ju(e){return e.parts.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function Mu(e){let t=e.clientMessageId??`queued:${e.kind}:${e.text}`;return{role:`user`,parts:[{type:`text`,text:e.text}],meta:{delivery:{clientMessageId:t,state:`queued`,kind:e.kind}}}}function Nu(e,t){return e.findIndex(e=>e.meta?.delivery?.clientMessageId===t)}function Pu(e,t,n,r){let i=Nu(e,t);if(i===-1)return e;let a=e[i],o=a?.meta?.delivery;if(a===void 0||o===void 0||!Lu(o.state,n)&&!Fu(o.kind,r,o.state,n))return e;let s=[...e],c=Lu(o.state,n)?n:o.state,l=r??o.kind;return s[i]={...a,meta:{...a.meta,delivery:{clientMessageId:t,state:c,...l===void 0?{}:{kind:l}}}},s}function Fu(e,t,n,r){return t!==void 0&&t!==e&&n===`queued`&&r===`queued`}var Iu={failed:-1,sending:0,received:1,queued:2,delivered:3};function Lu(e,t){return e===t?!1:t===`failed`?e!==`delivered`:e!==`failed`&&Iu[t]>Iu[e]}function Ru(e,t){let n=Nu(e,t);if(n===-1)return[...e];let r=e[n];if(r?.meta?.delivery?.state!==`failed`)return[...e];let i=r.meta.delivery,a=[...e];return a[n]={...r,meta:{...r.meta,delivery:{clientMessageId:t,state:`sending`,...i.kind===void 0?{}:{kind:i.kind}}}},a}function zu(e,t){let n=Nu(e,t);return n===-1?[...e]:[...e.slice(0,n),...e.slice(n+1)]}function Bu(e,t){let n=e,r=new Map;for(let e of t)e.clientMessageId!==void 0&&r.set(e.clientMessageId,e.kind);for(let t of e){let e=t.meta?.delivery;if(e===void 0)continue;let i=r.get(e.clientMessageId);if(i!==void 0){n=Pu(n,e.clientMessageId,`queued`,i);continue}(e.state===`received`||e.state===`queued`)&&(n=Pu(n,e.clientMessageId,`delivered`))}return n}function Vu(e,t){return t!==void 0&&Nu(e,t)!==-1}function Hu(e,t){let n=e.meta?.delivery;return n===void 0?t:{...t,meta:{...t.meta,delivery:{...n,state:n.state===`failed`?n.state:`delivered`}}}}function Uu(e,t){return t===``?-1:e.findIndex(e=>e.role===`user`&&e.meta?.delivery!==void 0&&Wu(e)===t)}function Wu(e){return e.parts.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
5
5
|
|
|
6
6
|
`)}function Gu(e,t){return Cl(`bash`,`${t===!0?`excluded from context
|
|
7
7
|
|
|
@@ -476,9 +476,15 @@ import{$ as e,A as t,J as n,P as r,Q as i,S as a,Y as o,Z as s,d as c,et as l,f
|
|
|
476
476
|
above the 24px minimum target without becoming a second composer. */
|
|
477
477
|
/* Top right, not bottom right: the bottom edge already carries the composer
|
|
478
478
|
controls and the activity dock, and a round button among round buttons
|
|
479
|
-
read as one more of them.
|
|
479
|
+
read as one more of them.
|
|
480
|
+
|
|
481
|
+
Its edges come from the conversation rather than from the panel. A fixed
|
|
482
|
+
offset from the panel measured correctly here, where the scrollbar floats
|
|
483
|
+
over the content, and sat on top of a real scrollbar elsewhere. */
|
|
480
484
|
.jump-to-bottom {
|
|
481
|
-
position: absolute;
|
|
485
|
+
position: absolute;
|
|
486
|
+
right: calc(var(--pi-chat-gutter) + var(--pi-chat-scrollbar, 0px));
|
|
487
|
+
top: var(--pi-space-9); z-index: 4;
|
|
482
488
|
display: flex; align-items: center; justify-content: center;
|
|
483
489
|
width: 40px; height: 40px; padding: 0;
|
|
484
490
|
border: 1px solid var(--pi-border); border-radius: var(--pi-radius-md);
|
|
@@ -529,8 +535,10 @@ import{$ as e,A as t,J as n,P as r,Q as i,S as a,Y as o,Z as s,d as c,et as l,f
|
|
|
529
535
|
/* A section that shortens stays reachable. Refusing to shrink pushed the
|
|
530
536
|
others off a narrow screen, where the selected one scrolled into view and
|
|
531
537
|
took the rest out of sight - which read as the strip disappearing. */
|
|
532
|
-
|
|
533
|
-
|
|
538
|
+
/* A section name is short and carries a count; cutting it to "ACTIVITY (..."
|
|
539
|
+
loses the number, which is the part worth reading. The names keep their
|
|
540
|
+
width and the running summary beside them gives way instead. */
|
|
541
|
+
.drawer-tab { flex: 0 0 auto; display: inline-flex; align-items: center; gap: var(--pi-space-3); box-sizing: border-box; min-height: 28px; padding: var(--pi-space-2) var(--pi-space-5); border: 1px solid transparent; border-radius: var(--pi-radius-pill); background: transparent; color: var(--pi-muted); font: inherit; font-size: var(--pi-text-2xs); font-weight: 600; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
534
542
|
.drawer-tab:hover { color: var(--pi-text-bright); }
|
|
535
543
|
.drawer-tab:focus-visible { outline: var(--pi-focus-ring-width) solid var(--pi-accent); outline-offset: 1px; }
|
|
536
544
|
.drawer-tab, .activity-filter, .activity-history-toggle { transition: background-color var(--pi-motion-fast) var(--pi-ease), border-color var(--pi-motion-fast) var(--pi-ease), color var(--pi-motion-fast) var(--pi-ease); }
|
|
@@ -940,15 +948,11 @@ import{$ as e,A as t,J as n,P as r,Q as i,S as a,Y as o,Z as s,d as c,et as l,f
|
|
|
940
948
|
.stop-button:not(:disabled) { color: var(--pi-danger); }
|
|
941
949
|
.select-thinking .prompt-thinking-gauge .gauge-bar { fill: currentColor; stroke: none; opacity: .28; }
|
|
942
950
|
.select-thinking .prompt-thinking-gauge .gauge-bar-active { opacity: 1; }
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
.editor-dictate { position: absolute; right: 44px; bottom: 8px; z-index: 2; width: 30px; height: 30px; font-size: var(--pi-text-2xs); }
|
|
951
|
+
/* Both live in the control row now: nothing floats over the text. */
|
|
952
|
+
.editor-dictate { font-size: var(--pi-text-2xs); }
|
|
946
953
|
.editor-dictate.listening { color: var(--pi-danger); border-color: var(--pi-danger); }
|
|
947
|
-
.editor-attach .prompt-action-icon { width: 16px; height: 16px; }
|
|
948
954
|
textarea, .markdown-editor .cm-editor { box-sizing: border-box; width: 100%; min-height: 54px; max-height: 220px; resize: none; overflow: hidden; border-radius: var(--pi-radius-md); border: 1px solid var(--pi-border); background: var(--pi-bg); color: var(--pi-text); font: var(--pi-control-font-size, 16px)/1.4 var(--pi-control-font-family, system-ui, sans-serif); }
|
|
949
|
-
|
|
950
|
-
text has to be paid room for them or it runs underneath. */
|
|
951
|
-
textarea { overflow-y: auto; padding: var(--pi-space-4); padding-right: calc(var(--pi-space-4) + 74px); }
|
|
955
|
+
textarea { overflow-y: auto; padding: var(--pi-space-4); }
|
|
952
956
|
/* A phone with the keyboard open leaves roughly 400px of viewport, and a
|
|
953
957
|
composer sized for a full screen took 119px of it - the transcript was
|
|
954
958
|
left with about two lines. The composer keeps a floor so it stays usable
|
|
@@ -1223,7 +1227,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
1223
1227
|
.viewer-header { align-items: flex-start; flex-direction: column; }
|
|
1224
1228
|
.viewer-actions { width: 100%; flex-wrap: wrap; }
|
|
1225
1229
|
}
|
|
1226
|
-
`]}};H([b({attribute:!1})],py.prototype,`machineId`,void 0),H([b({attribute:!1})],py.prototype,`projectId`,void 0),H([b({attribute:!1})],py.prototype,`workspaceId`,void 0),H([b({attribute:!1})],py.prototype,`selectedPath`,void 0),H([b({attribute:!1})],py.prototype,`file`,void 0),H([b({attribute:!1})],py.prototype,`loadError`,void 0),H([b({attribute:!1})],py.prototype,`previewUrlBuilder`,void 0),H([b({attribute:!1})],py.prototype,`modeStore`,void 0),py=H([y(`workspace-file-viewer`)],py);function my(e){return JSON.stringify([e.machineId,e.projectId,e.workspaceId,e.selectedPath??null,e.file?.path??null,e.file?.modifiedAt??null,e.file?.mediaType??null])}function hy(e){return e.mediaType===`image`?`image`:e.mediaType===`html`?`html`:e.mediaType===`pdf`?`pdf`:e.mediaType===`markdown`?`markdown`:e.binary?`download`:`code`}function gy(e,t){return t!==`code`&&t!==`download`&&!e.binary}function _y(e){return e===`html`?``:void 0}function vy(e){return e===`image`||e===`html`||e===`pdf`}function yy(e,t){return`${t===`code`?e.language??`text`:t===`download`?e.mimeType??`binary`:t===`markdown`?`markdown`:e.mimeType??t} · ${Sg(e.size)}${e.truncated?` · truncated`:``}`}function by(){fy(()=>import(`./CodeViewer-
|
|
1230
|
+
`]}};H([b({attribute:!1})],py.prototype,`machineId`,void 0),H([b({attribute:!1})],py.prototype,`projectId`,void 0),H([b({attribute:!1})],py.prototype,`workspaceId`,void 0),H([b({attribute:!1})],py.prototype,`selectedPath`,void 0),H([b({attribute:!1})],py.prototype,`file`,void 0),H([b({attribute:!1})],py.prototype,`loadError`,void 0),H([b({attribute:!1})],py.prototype,`previewUrlBuilder`,void 0),H([b({attribute:!1})],py.prototype,`modeStore`,void 0),py=H([y(`workspace-file-viewer`)],py);function my(e){return JSON.stringify([e.machineId,e.projectId,e.workspaceId,e.selectedPath??null,e.file?.path??null,e.file?.modifiedAt??null,e.file?.mediaType??null])}function hy(e){return e.mediaType===`image`?`image`:e.mediaType===`html`?`html`:e.mediaType===`pdf`?`pdf`:e.mediaType===`markdown`?`markdown`:e.binary?`download`:`code`}function gy(e,t){return t!==`code`&&t!==`download`&&!e.binary}function _y(e){return e===`html`?``:void 0}function vy(e){return e===`image`||e===`html`||e===`pdf`}function yy(e,t){return`${t===`code`?e.language??`text`:t===`download`?e.mimeType??`binary`:t===`markdown`?`markdown`:e.mimeType??t} · ${Sg(e.size)}${e.truncated?` · truncated`:``}`}function by(){fy(()=>import(`./CodeViewer-BNqqpXU2.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)}var xy=class extends v{constructor(...e){super(...e),this.destinationFolder=``,this.overwrite=!1,this.createDirs=!0,this.formError=``,this.dragActive=!1,this.dragDepth=0,this.openFilePicker=()=>{this.uploadInput?.click()},this.handleFileInputChange=e=>{let t=e.currentTarget instanceof HTMLInputElement?e.currentTarget:void 0,n=Dy(t?.files);t!==void 0&&(t.value=``),n.length>0&&this.openUploadReview(n)},this.handleDragEnter=e=>{Oy(e)&&(e.preventDefault(),this.dragDepth+=1,this.dragActive=!0)},this.handleDragOver=e=>{Oy(e)&&(e.preventDefault(),e.dataTransfer!==null&&(e.dataTransfer.dropEffect=`copy`),this.dragActive=!0)},this.handleDragLeave=e=>{Oy(e)&&(e.preventDefault(),this.dragDepth=Math.max(0,this.dragDepth-1),this.dragDepth===0&&(this.dragActive=!1))},this.handleDrop=e=>{if(!Oy(e))return;e.preventDefault(),this.dragDepth=0,this.dragActive=!1;let t=Dy(e.dataTransfer?.files),n=this.context;t.length>0&&n!==void 0&&Ty(n,t)},this.handleDestinationInput=e=>{let t=e.currentTarget instanceof HTMLInputElement?e.currentTarget:void 0;this.destinationFolder=t?.value??``,this.formError=``},this.handleCreateDirsChange=e=>{let t=e.currentTarget instanceof HTMLInputElement?e.currentTarget:void 0;this.createDirs=t?.checked??!0},this.handleOverwriteChange=e=>{let t=e.currentTarget instanceof HTMLInputElement?e.currentTarget:void 0;this.overwrite=t?.checked??!1},this.handleDialogKeyDown=e=>{e.key===`Escape`&&(e.preventDefault(),this.closeUploadDialog())}}willUpdate(e){if(!e.has(`context`))return;let t=e.get(`context`);t!==void 0&&this.context!==void 0&&Ey(t)!==Ey(this.context)&&this.resetPendingUpload()}updated(){this.syncUploadModal()}disconnectedCallback(){this.releaseUploadModal(),super.disconnectedCallback()}render(){let e=this.context;return e===void 0?g`<p class="muted">Files unavailable.</p>`:g`
|
|
1227
1231
|
<section
|
|
1228
1232
|
class=${this.dragActive?`files-panel dragging`:`files-panel`}
|
|
1229
1233
|
@dragenter=${this.handleDragEnter}
|
|
@@ -1393,7 +1397,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
1393
1397
|
.review-file span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1394
1398
|
.dialog-error { border: 1px solid var(--pi-danger); border-radius: 8px; background: color-mix(in srgb, var(--pi-danger) 10%, transparent); color: var(--pi-danger); padding: 9px; line-height: 1.35; overflow-wrap: anywhere; }
|
|
1395
1399
|
footer { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
|
|
1396
|
-
`]}};H([b({attribute:!1})],xy.prototype,`context`,void 0),H([S(`#workspace-upload-input`)],xy.prototype,`uploadInput`,void 0),H([S(`.dialog-backdrop`)],xy.prototype,`uploadDialogBackdrop`,void 0),H([S(`.upload-dialog`)],xy.prototype,`uploadDialog`,void 0),H([x()],xy.prototype,`pendingUpload`,void 0),H([x()],xy.prototype,`destinationFolder`,void 0),H([x()],xy.prototype,`overwrite`,void 0),H([x()],xy.prototype,`createDirs`,void 0),H([x()],xy.prototype,`formError`,void 0),H([x()],xy.prototype,`dragActive`,void 0),xy=H([y(`workspace-files-panel`)],xy);function Sy(e,t){return Object.values(e).filter(e=>e.projectId===t.projectId&&e.workspaceId===t.workspaceId&&e.machineId===t.machineId).sort((e,t)=>t.startedAt.localeCompare(e.startedAt))}function Cy(e,t){if(e.length===0)return`Choose at least one file to upload.`;for(let n of e)try{Qs(t,n.name)}catch(e){return e instanceof Error?e.message:String(e)}}function wy(e){return{destinationFolder:e,createDirs:!0,overwrite:!1}}function Ty(e,t){if(t.length!==0)return e.onStartWorkspaceUpload(t,{destinationFolder:e.workspaceUploadDefaultFolder,createDirs:!0,overwrite:!1,selectUploadedFile:!0})}function Ey(e){return`${e.machine.id}:${e.workspace.projectId}:${e.workspace.id}`}function Dy(e){return e==null?[]:Array.from(e)}function Oy(e){return Array.from(e.dataTransfer?.types??[]).includes(`Files`)}function ky(e){let t=e.getRootNode();return t instanceof ShadowRoot&&t.host instanceof HTMLElement?t.host:e}function Ay(e){let t=e.filter(e=>e.status===`uploading`).length;return t===0?`${String(e.length)} recent`:`${String(t)} uploading`}function jy(e){let t=e.files.length,n=t===1?`file`:`files`;switch(e.status){case`completed`:return`Uploaded ${String(t)} ${n}`;case`error`:return`Upload failed for ${String(t)} ${n}`;case`cancelled`:return`Upload cancelled for ${String(t)} ${n}`;case`uploading`:return`Uploading ${String(t)} ${n}`}}function My(e){switch(e.status){case`completed`:return`Done`;case`error`:return`Failed`;case`cancelled`:return`Cancelled`;case`uploading`:return Iy(e.percent)}}function Ny(e){return e.status===`uploading`?e.percent:1}function Py(e){switch(e.status){case`pending`:return`Pending`;case`uploading`:return Iy(e.percent);case`completed`:return`Done`;case`error`:return`Error`;case`cancelled`:return`Cancelled`}}function Fy(e){return e.error===void 0?e.response===void 0?`${e.path} · ${Sg(e.loaded)} / ${Sg(e.total)}`:`Wrote ${e.response.path}`:e.error}function Iy(e){return`${String(Math.round(Math.max(0,Math.min(1,e))*100))}%`}function Ly(){return[{id:`workspace.files`,title:`Files`,icon:yg(`files`),order:10,routeAliases:[`files`],render:Ry},{id:`workspace.terminal`,title:`Terminal`,icon:yg(`terminal`),order:30,badge:e=>e.activeTerminalCount>0?e.activeTerminalCount:void 0,render:zy}]}function Ry(e){return g`<workspace-files-panel .context=${e}></workspace-files-panel>`}function zy(e){return By(),g`<terminal-panel .workspace=${e.workspace} .machineId=${e.machine.id} .selectedTerminalId=${e.selectedTerminalId} .autoStart=${e.terminalAutoStart} .onSelectTerminal=${e.onSelectTerminal}></terminal-panel>`}function By(){fy(()=>import(`./TerminalPanel-DsEoManU.js`),__vite__mapDeps([4,5,6]),import.meta.url)}var Vy={apiVersion:2,name:`PI WEB Core`,activate:()=>({contributions:{actions:dg(),workspacePanels:Ly()}})},Hy={"--pi-bg":`#0d1117`,"--pi-surface":`#161b22`,"--pi-surface-hover":`#21262d`,"--pi-terminal-bg":`#05070a`,"--pi-terminal-text":`#e6edf3`,"--pi-border":`#30363d`,"--pi-border-muted":`#21262d`,"--pi-text":`#e6edf3`,"--pi-text-secondary":`#c9d1d9`,"--pi-text-bright":`#f0f6fc`,"--pi-muted":`#8b949e`,"--pi-dim":`#6e7681`,"--pi-accent":`#58a6ff`,"--pi-accent-border":`#2f81f7`,"--pi-selection-bg":`#0d2847`,"--pi-success":`#3fb950`,"--pi-success-border":`#238636`,"--pi-success-bg":`#0f1b12`,"--pi-success-surface":`#0f2a16`,"--pi-success-ring":`#3fb95055`,"--pi-warning":`#d29922`,"--pi-warning-border":`#6e5200`,"--pi-warning-surface":`#1f1a10`,"--pi-danger":`#ff7b72`,"--pi-purple":`#d2a8ff`,"--pi-purple-border":`#a371f7`,"--pi-purple-surface":`#21132f`,"--pi-overlay":`#0008`,"--pi-shadow-soft":`#0006`,"--pi-shadow":`#0008`,"--pi-shadow-strong":`#000b`,"--pi-bg-overlay-soft":`#0d1117dd`,"--pi-bg-overlay":`#0d1117e6`,"--pi-success-bg-overlay":`#0f1b12ee`,"--pi-terminal-selection":`#264f78`},Uy={"--pi-bg":`#070912`,"--pi-surface":`#101527`,"--pi-surface-hover":`#151b31`,"--pi-terminal-bg":`#050710`,"--pi-terminal-text":`#f7f4ff`,"--pi-border":`#26304f`,"--pi-border-muted":`#26304f`,"--pi-text":`#f7f4ff`,"--pi-text-secondary":`#aaa4bd`,"--pi-text-bright":`#ffffff`,"--pi-muted":`#aaa4bd`,"--pi-dim":`#817a99`,"--pi-accent":`#7c3cff`,"--pi-accent-border":`#5a47b0`,"--pi-selection-bg":`#1d2547`,"--pi-success":`#00f0d8`,"--pi-success-border":`#00f0d8`,"--pi-success-bg":`#071e22`,"--pi-success-surface":`#092d31`,"--pi-success-ring":`#00f0d855`,"--pi-warning":`#ffb000`,"--pi-warning-border":`#ffb000`,"--pi-warning-surface":`#16140d`,"--pi-danger":`#ff4f7b`,"--pi-purple":`#b7a2ff`,"--pi-purple-border":`#7c3cff`,"--pi-purple-surface":`#181026`,"--pi-overlay":`#0008`,"--pi-shadow-soft":`#0006`,"--pi-shadow":`#0008`,"--pi-shadow-strong":`#000b`,"--pi-bg-overlay-soft":`#070912dd`,"--pi-bg-overlay":`#070912e6`,"--pi-success-bg-overlay":`#071e22ee`,"--pi-terminal-selection":`#3d4a78`},Wy={"--pi-bg":`#f7f1e6`,"--pi-surface":`#fff9ee`,"--pi-surface-hover":`#f0e6d6`,"--pi-terminal-bg":`#15131b`,"--pi-terminal-text":`#fff9ee`,"--pi-border":`#c9bca8`,"--pi-border-muted":`#d8cdbc`,"--pi-text":`#15131b`,"--pi-text-secondary":`#15131b`,"--pi-text-bright":`#15131b`,"--pi-muted":`#5f586a`,"--pi-dim":`#766f7e`,"--pi-accent":`#6430d8`,"--pi-accent-border":`#6430d8`,"--pi-selection-bg":`#eadff8`,"--pi-success":`#008c82`,"--pi-success-border":`#008c82`,"--pi-success-bg":`#e1f4ef`,"--pi-success-surface":`#d7f0ec`,"--pi-success-ring":`#008c8255`,"--pi-warning":`#b05f00`,"--pi-warning-border":`#b05f00`,"--pi-warning-surface":`#fff2d2`,"--pi-danger":`#b51d49`,"--pi-purple":`#6430d8`,"--pi-purple-border":`#6430d8`,"--pi-purple-surface":`#eadff8`,"--pi-overlay":`#15131b66`,"--pi-shadow-soft":`#15131b22`,"--pi-shadow":`#15131b33`,"--pi-shadow-strong":`#15131b44`,"--pi-bg-overlay-soft":`#f7f1e6dd`,"--pi-bg-overlay":`#f7f1e6e6`,"--pi-success-bg-overlay":`#e1f4efee`,"--pi-terminal-selection":`#8d7b64`},Gy={"--pi-bg":`#000000`,"--pi-surface":`#0d0d0d`,"--pi-surface-hover":`#1a1a1a`,"--pi-terminal-bg":`#000000`,"--pi-terminal-text":`#ffffff`,"--pi-border":`#5c5c5c`,"--pi-border-muted":`#3d3d3d`,"--pi-text":`#ffffff`,"--pi-text-secondary":`#e6e6e6`,"--pi-text-bright":`#ffffff`,"--pi-muted":`#b3b3b3`,"--pi-dim":`#8f8f8f`,"--pi-accent":`#4dc3ff`,"--pi-accent-border":`#4dc3ff`,"--pi-selection-bg":`#00263a`,"--pi-success":`#3ff05a`,"--pi-success-border":`#3ff05a`,"--pi-success-bg":`#001a06`,"--pi-success-surface":`#00280b`,"--pi-success-ring":`#3ff05a66`,"--pi-warning":`#ffcc33`,"--pi-warning-border":`#ffcc33`,"--pi-warning-surface":`#251c00`,"--pi-danger":`#ff6b6b`,"--pi-purple":`#c9a3ff`,"--pi-purple-border":`#c9a3ff`,"--pi-purple-surface":`#180d29`,"--pi-overlay":`#000000cc`,"--pi-shadow-soft":`#00000099`,"--pi-shadow":`#000000bb`,"--pi-shadow-strong":`#000000e6`,"--pi-bg-overlay-soft":`#000000dd`,"--pi-bg-overlay":`#000000f2`,"--pi-success-bg-overlay":`#001a06ee`,"--pi-terminal-selection":`#00456b`},Ky={"--pi-bg":`#14110e`,"--pi-surface":`#1d1915`,"--pi-surface-hover":`#26211b`,"--pi-terminal-bg":`#100d0b`,"--pi-terminal-text":`#e8ddcc`,"--pi-border":`#3a3229`,"--pi-border-muted":`#2b2520`,"--pi-text":`#e8ddcc`,"--pi-text-secondary":`#cbbfad`,"--pi-text-bright":`#fff4e0`,"--pi-muted":`#9c9081`,"--pi-dim":`#7a6f62`,"--pi-accent":`#e0a35c`,"--pi-accent-border":`#b8813f`,"--pi-selection-bg":`#2e2415`,"--pi-success":`#8fbf6f`,"--pi-success-border":`#6d9954`,"--pi-success-bg":`#161c12`,"--pi-success-surface":`#1e2718`,"--pi-success-ring":`#8fbf6f55`,"--pi-warning":`#d9a441`,"--pi-warning-border":`#9c7429`,"--pi-warning-surface":`#241c0f`,"--pi-danger":`#d97b6c`,"--pi-purple":`#b79ad1`,"--pi-purple-border":`#8d74a8`,"--pi-purple-surface":`#221a2b`,"--pi-overlay":`#0a0806cc`,"--pi-shadow-soft":`#00000055`,"--pi-shadow":`#00000077`,"--pi-shadow-strong":`#000000aa`,"--pi-bg-overlay-soft":`#14110edd`,"--pi-bg-overlay":`#14110ee6`,"--pi-success-bg-overlay":`#161c12ee`,"--pi-terminal-selection":`#3d3121`},qy={"--pi-bg":`#fbfbf9`,"--pi-surface":`#ffffff`,"--pi-surface-hover":`#f1f1ee`,"--pi-terminal-bg":`#1c1c1a`,"--pi-terminal-text":`#fbfbf9`,"--pi-border":`#c7c7c1`,"--pi-border-muted":`#e0e0da`,"--pi-text":`#1c1c1a`,"--pi-text-secondary":`#33332f`,"--pi-text-bright":`#000000`,"--pi-muted":`#5e5e58`,"--pi-dim":`#7c7c75`,"--pi-accent":`#1f5fd0`,"--pi-accent-border":`#1f5fd0`,"--pi-selection-bg":`#e2ecfb`,"--pi-success":`#0f7a4a`,"--pi-success-border":`#0f7a4a`,"--pi-success-bg":`#e6f5ed`,"--pi-success-surface":`#d9efe3`,"--pi-success-ring":`#0f7a4a55`,"--pi-warning":`#8a5a00`,"--pi-warning-border":`#8a5a00`,"--pi-warning-surface":`#fdf0d5`,"--pi-danger":`#b02020`,"--pi-purple":`#5b3fc7`,"--pi-purple-border":`#5b3fc7`,"--pi-purple-surface":`#ece7fb`,"--pi-overlay":`#1c1c1a66`,"--pi-shadow-soft":`#1c1c1a1a`,"--pi-shadow":`#1c1c1a2b`,"--pi-shadow-strong":`#1c1c1a40`,"--pi-bg-overlay-soft":`#fbfbf9dd`,"--pi-bg-overlay":`#fbfbf9e6`,"--pi-success-bg-overlay":`#e6f5edee`,"--pi-terminal-selection":`#9ab4d8`},Jy={apiVersion:2,name:`PI WEB Themes`,activate:()=>({contributions:{themes:[{id:`pi-web-dark`,name:`PI WEB Dark`,description:`Dark PI WEB palette.`,order:10,colorScheme:`dark`,tokens:Uy},{id:`pi-web-light`,name:`PI WEB Light`,description:`Light PI WEB palette.`,order:20,colorScheme:`light`,tokens:Wy},{id:`classic`,name:`PI WEB Classic`,description:`The original PI WEB dark palette.`,order:30,colorScheme:`dark`,tokens:Hy},{id:`high-contrast`,name:`High Contrast`,description:`Near-black behind near-white, for bright rooms and tired eyes.`,order:40,colorScheme:`dark`,tokens:Gy},{id:`night`,name:`Night`,description:`Warm and dim, with an amber accent instead of blue light.`,order:50,colorScheme:`dark`,tokens:Ky},{id:`paper`,name:`Paper`,description:`Untinted ink on paper, for daylight and for screenshots.`,order:60,colorScheme:`light`,tokens:qy}],themePairs:[{id:`pi-web`,name:`PI WEB`,description:`Follow the system light/dark preference with PI WEB themes.`,order:10,light:`pi-web-light`,dark:`pi-web-dark`}]}})};async function Yy(e=`pi-web-plugins/manifest.json`,t={}){let n=Wt(e),r=await Qy(n);if(r===void 0)return{registrations:[],failures:[]};let i=[],a=[];for(let e of r.plugins)if(t.shouldLoadPlugin?.(e)!==!1)try{let r=Xy(e.module,n),a=rb(await(t.moduleLoader??Zy)(r),r);i.push({id:t.machineId===void 0?e.id:bc(t.machineId,e.id),plugin:a,machineSpecific:e.machineSpecific,...e.backendRevision===void 0?{}:{backendRevision:e.backendRevision},...t.machineId===void 0?{}:{machineId:t.machineId,sourcePluginId:e.id}})}catch(t){a.push({entry:e,error:t})}return{registrations:i,failures:a}}function Xy(e,t,n){return e.startsWith(`/`)?n===void 0?Wt(e):Wt(e,n):new URL(e,t).toString()}async function Zy(e){return fy(()=>import(e),[],import.meta.url)}async function Qy(e){let t=await fetch(e,{cache:`no-store`});if(t.status!==404){if(!t.ok)throw Error(await eb(t));return $y(await t.json())}}function $y(e){if(!ab(e)||!Array.isArray(e.plugins))throw Error(`Invalid plugin manifest`);let t=e.plugins.map(e=>{if(!ab(e)||typeof e.id!=`string`||typeof e.module!=`string`||e.module===``)throw Error(`Invalid plugin manifest entry`);let t=e.id;if(!Dn(t))throw Error(`Invalid plugin manifest id: ${t}`);if(On(t))throw Error(`Reserved plugin manifest id: ${t}`);return{id:t,module:e.module,...tb(e.backendRevision),machineSpecific:nb(e.machineSpecific)}}),n=new Set;for(let e of t){if(n.has(e.id))throw Error(`Duplicate plugin manifest id: ${e.id}`);n.add(e.id)}return{plugins:t}}async function eb(e){let t;try{let n=await e.json();if(ab(n)){let e=n.error,r=n.detail;t=typeof r==`string`?`${typeof e==`string`?`${e}: `:``}${r}`:typeof e==`string`?e:void 0}}catch{}return`Failed to load plugin manifest (${`${String(e.status)}${e.statusText===``?``:` ${e.statusText}`}`})${t===void 0?``:`: ${t}`}`}function tb(e){if(e===void 0)return{};try{return{backendRevision:Os(e)}}catch{throw Error(`Invalid plugin manifest entry`)}}function nb(e){if(e===void 0)return!1;if(typeof e!=`boolean`)throw Error(`Invalid plugin manifest entry`);return e}function rb(e,t){if(!ab(e))throw Error(`Plugin module ${t} did not export an object`);let n=e.default;if(ab(n)&&n.apiVersion!==2)throw Error(`Unsupported browser plugin API version for ${t}: ${String(n.apiVersion)} (expected 2)`);if(!ib(n))throw Error(`Plugin module ${t} default export is not a PiWebPlugin`);return n}function ib(e){return ab(e)&&e.apiVersion===2&&typeof e.name==`string`&&typeof e.activate==`function`}function ab(e){return typeof e==`object`&&!!e}var ob=/^[a-z][a-z0-9.-]*$/u,sb=/^[a-z][a-z0-9.-]*$/u,cb=/^[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$/u,lb=/^[a-z][a-z0-9.-]*(?::[a-z][a-z0-9.-]*)?$/u,ub=new WeakMap,db=new WeakMap,fb=new WeakMap,pb=class{constructor(){this.actions=[],this.workspacePanels=[],this.workspaceLabels=[],this.themes=[],this.themePairs=[],this.pluginIds=new Set,this.registeringPluginIds=new Set,this.gatewayPluginIds=new Set,this.gatewayMachineSpecificPluginIds=new Set,this.remoteMachineSpecificPluginIds=new Map,this.contributionIds=new Set}register(e){let{plugin:t}=e,n=e.id,r=e.sourcePluginId??n;this.validatePluginId(n),this.validatePluginId(r);let i=this.parseMachineSpecific(n,e.machineSpecific),a=this.parseBackendRevision(n,e.backendRevision);if(this.pluginIds.has(n)||this.registeringPluginIds.has(n))throw Error(`Duplicate plugin id: ${n}`);if(!this.isRemoteDuplicateHiddenByGateway(e.sourcePluginId,e.machineId,i)){this.registeringPluginIds.add(n);try{let o=t.apiVersion;if(o!==2)throw Error(`Unsupported browser plugin API version for ${r}: ${String(o)} (expected 2)`);let s=t.activate(Object.freeze({apiVersion:2,pluginId:r,runtimePluginId:n,html:g,svg:Ye})).contributions,c=new Set,l=(s.actions??[]).map(t=>this.qualifyAction(n,t,e.machineId,e.sourcePluginId,c)),u=(s.workspacePanels??[]).map(t=>this.qualifyWorkspacePanel(n,t,e.machineId,e.sourcePluginId,a,c)),d=(s.workspaceLabels??[]).map(t=>this.qualifyWorkspaceLabelContribution(n,t,e.machineId,e.sourcePluginId,a,c)),f=e.machineId===void 0?(s.themes??[]).map(e=>this.qualifyTheme(n,e,c)):[],p=e.machineId===void 0?(s.themePairs??[]).map(e=>this.qualifyThemePair(n,e,c)):[];this.pluginIds.add(n);for(let e of c)this.contributionIds.add(e);this.actions.push(...l),this.workspacePanels.push(...u),this.workspaceLabels.push(...d),this.themes.push(...f),this.themePairs.push(...p),e.machineId===void 0?(this.gatewayPluginIds.add(n),i&&this.gatewayMachineSpecificPluginIds.add(n)):e.sourcePluginId!==void 0&&i&&xb(this.remoteMachineSpecificPluginIds,e.sourcePluginId,e.machineId)}finally{this.registeringPluginIds.delete(n)}}}hasPlugin(e){return this.pluginIds.has(e)}shouldLoadRemotePlugin(e,t=!1){return!this.gatewayPluginIds.has(e)||this.gatewayMachineSpecificPluginIds.has(e)||t}getActions(e){let t=wb(e);return this.actions.filter(e=>this.isContributionActive(e.pluginId,e.machineId,t,e.sourcePluginId)).map(t=>{let n=mb(e,t.pluginId),r=t.enabled?.(n),i=r===!1?t.disabledReason?.(n):void 0,a={id:t.id,pluginId:t.pluginId,localId:t.localId,...t.machineId===void 0?{}:{machineId:t.machineId},title:t.title,run:()=>t.run(n)};return t.description!==void 0&&(a.description=t.description),t.shortcut!==void 0&&(a.shortcut=t.shortcut),t.shortcutAliases!==void 0&&(a.shortcutAliases=[...t.shortcutAliases]),t.group!==void 0&&(a.group=t.group),r!==void 0&&(a.enabled=r),i!==void 0&&i!==``&&(a.disabledReason=i),a})}getWorkspacePanels(){return[...this.workspacePanels].sort((e,t)=>(e.order??1e3)-(t.order??1e3)||e.title.localeCompare(t.title))}resolveWorkspacePanelRouteId(e,t){let n=this.workspacePanels.filter(e=>this.isContributionActive(e.pluginId,e.machineId,t,e.sourcePluginId)),r=n.find(t=>t.id===e);if(r!==void 0)return r.id;let i=n.filter(t=>t.routeAliases?.includes(e)===!0);if(i.length===1)return i[0]?.id;i.length>1&&console.warn(`Ambiguous PI WEB workspace panel route: ${e}`)}async invalidateWorkspacePanels(e,t){await Promise.all(this.workspacePanels.map(async n=>{if(!(n.onInvalidate===void 0||t!==void 0&&n.id!==t))try{await n.onInvalidate(e)}catch(e){console.warn(`Failed to invalidate PI WEB plugin panel ${n.id}`,e)}}))}getThemes(){return[...this.themes].sort((e,t)=>(e.order??1e3)-(t.order??1e3)||e.name.localeCompare(t.name))}getThemePairs(){return[...this.themePairs].sort((e,t)=>(e.order??1e3)-(t.order??1e3)||e.name.localeCompare(t.name))}getWorkspaceLabelItems(e){return[...this.workspaceLabels].sort((e,t)=>(e.order??1e3)-(t.order??1e3)||e.id.localeCompare(t.id)).flatMap(t=>t.visible?.(e)===!1?[]:t.items(e))}qualifyAction(e,t,n,r,i){let a=this.qualify(e,t.id,i),o=`${r??e}:${t.id}`,s=this.parseShortcutAliases(a,t.shortcutAliases,o);return{...t,id:a,pluginId:e,localId:t.id,...s.length===0?{}:{shortcutAliases:s},...n===void 0?{}:{machineId:n},...r===void 0?{}:{sourcePluginId:r}}}qualifyWorkspacePanel(e,t,n,r,i,a){let o=this.qualify(e,t.id,a),s=t.badge,c=t.visible,l=t.onInvalidate,u=bb(e,r,i),d=`${r??e}:${t.id}`,f=this.parseRouteAliases(o,t.routeAliases,d);return{...t,id:o,pluginId:e,localId:t.id,...f.length===0?{}:{routeAliases:f},...n===void 0?{}:{machineId:n},...r===void 0?{}:{sourcePluginId:r},visible:t=>this.isContributionActive(e,n,t.machine.id,r)&&(c?.(hb(t,u))??!0),...s===void 0?{}:{badge:t=>this.isContributionActive(e,n,t.machine.id,r)?s(hb(t,u)):void 0},...l===void 0?{}:{onInvalidate:t=>this.isContributionActive(e,n,t.machine.id,r)?l(hb(t,u)):void 0},render:e=>t.render(hb(e,u))}}qualifyWorkspaceLabelContribution(e,t,n,r,i,a){let o=this.qualify(e,t.id,a),s=t.visible,c=t.items,l=bb(e,r,i);return{...t,id:o,pluginId:e,localId:t.id,...n===void 0?{}:{machineId:n},visible:t=>this.isContributionActive(e,n,t.machine.id,r)&&(s?.(gb(t,l))??!0),items:t=>this.isContributionActive(e,n,t.machine.id,r)?c(gb(t,l)):[]}}qualifyTheme(e,t,n){let r=this.qualify(e,t.id,n);return{...t,id:r,pluginId:e,localId:t.id}}qualifyThemePair(e,t,n){let r=this.qualify(e,t.id,n);return{...t,id:r,pluginId:e,localId:t.id,light:this.qualifyReference(e,t.light),dark:this.qualifyReference(e,t.dark)}}qualify(e,t,n){this.validateLocalId(t);let r=`${e}:${t}`;if(this.contributionIds.has(r)||n.has(r))throw Error(`Duplicate contribution id: ${r}`);return n.add(r),r}qualifyReference(e,t){return this.validateLocalId(t),`${e}:${t}`}isContributionActive(e,t,n,r){return t===void 0?!this.isGatewayPluginHiddenForMachine(e,n):t===n&&!this.isRemotePluginHiddenByGateway(r,t)}isRemoteDuplicateHiddenByGateway(e,t,n){return e!==void 0&&t!==void 0&&this.gatewayPluginIds.has(e)&&!this.gatewayMachineSpecificPluginIds.has(e)&&!n}isRemotePluginHiddenByGateway(e,t){return e===void 0||this.gatewayMachineSpecificPluginIds.has(e)||this.remoteMachineSpecificPluginIds.get(e)?.has(t)===!0?!1:this.gatewayPluginIds.has(e)}isGatewayPluginHiddenForMachine(e,t){return t!==`local`&&(this.gatewayMachineSpecificPluginIds.has(e)||this.remoteMachineSpecificPluginIds.get(e)?.has(t)===!0)}parseShortcutAliases(e,t,n){let r=[...new Set([...t??[],n])].filter(t=>t!==e),i=r.find(e=>!Sb(e));if(i!==void 0)throw Error(`Invalid shortcut alias for ${e}: ${i}`);return r.filter(Sb)}parseRouteAliases(e,t,n){let r=[...new Set([...t??[],n])].filter(t=>t!==e);for(let t of r)if(!lb.test(t))throw Error(`Invalid workspace panel route alias for ${e}: ${t}`);return r}validatePluginId(e){if(!ob.test(e))throw Error(`Invalid plugin id: ${e}`)}validateLocalId(e){if(!sb.test(e))throw Error(`Invalid contribution id: ${e}`)}parseBackendRevision(e,t){if(t!==void 0)try{return Os(t)}catch{throw Error(`Invalid plugin backend revision for ${e}`)}}parseMachineSpecific(e,t){if(t===void 0)return!1;if(typeof t!=`boolean`)throw Error(`Invalid plugin machineSpecific value for ${e}: ${Cb(t)}`);return t}};function mb(e,t){return ub.get(e)?.(t)??e}function hb(e,t){return db.get(e)?.(t)??e}function gb(e,t){return fb.get(e)?.(t)??e}function _b(e,t){return ub.set(e,t),e}function vb(e,t){return db.set(e,t),e}function yb(e,t){return fb.set(e,t),e}function bb(e,t,n){return Object.freeze({registrationPluginId:e,sourcePluginId:t??e,...n===void 0?{}:{backendRevision:n}})}function xb(e,t,n){let r=e.get(t);r===void 0?e.set(t,new Set([n])):r.add(n)}function Sb(e){return cb.test(e)}function Cb(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||typeof e==`symbol`||typeof e==`function`||e==null)return String(e);try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}}function wb(e){return e.state.selectedMachine?.id??`local`}function Tb(e,t,n,r=Ls){let i=e.backendRevision;if(i!==void 0)return{request:(a,o)=>r({pluginId:e.sourcePluginId,backendRevision:i,machineId:n,projectId:t.projectId,workspaceId:t.id},a,o)}}function Eb(e,t,n,r){return{readFile:r=>e.workspaceFile(t.projectId,t.id,r,n),listFiles:r=>e.workspaceTree(t.projectId,t.id,r,n),writeFile:async(i,a,o)=>{let s=await e.writeWorkspaceFile(t.projectId,t.id,i,a,o,n);return r?.(),s},deleteFile:async i=>{let a=await e.deleteWorkspaceFile(t.projectId,t.id,i,n);return r?.(),a},moveFile:async(i,a,o)=>{let s=await e.moveWorkspaceFile(t.projectId,t.id,i,a,o,n);return r?.(),s}}}var Db=class{constructor(e,t={}){this.callbacks=e,this.refreshes=new Yc,this.connected=!1,this.onFocus=()=>{this.handleResumeSignal()},this.onVisibilityChange=()=>{this.isDocumentVisible()&&this.handleResumeSignal()},this.windowTarget=t.windowTarget??Ob(),this.documentTarget=t.documentTarget??kb(),this.isDocumentVisible=t.isDocumentVisible??Ab,this.scheduleFrame=t.scheduleFrame??jb}connect(){this.connected||(this.connected=!0,this.windowTarget?.addEventListener(`focus`,this.onFocus),this.documentTarget?.addEventListener(`visibilitychange`,this.onVisibilityChange))}disconnect(){this.connected&&(this.connected=!1,this.windowTarget?.removeEventListener(`focus`,this.onFocus),this.documentTarget?.removeEventListener(`visibilitychange`,this.onVisibilityChange),this.scheduledRefresh?.cancel(),this.scheduledRefresh=void 0)}handleResumeSignal(){this.callbacks.onResumeSignal(),this.scheduledRefresh===void 0&&(this.scheduledRefresh=this.scheduleFrame(()=>{this.scheduledRefresh=void 0,this.connected&&this.refreshes.request(`browser-resume`,async()=>{this.connected&&await this.callbacks.refreshAfterResume()}).catch(e=>{this.callbacks.onRefreshError(e)})}))}};function Ob(){return typeof window>`u`?void 0:window}function kb(){return typeof document>`u`?void 0:document}function Ab(){return typeof document>`u`||document.visibilityState===`visible`}function jb(e){if(typeof window<`u`&&typeof window.requestAnimationFrame==`function`){let t=window.requestAnimationFrame(()=>{e()});return{cancel:()=>{window.cancelAnimationFrame(t)}}}let t=globalThis.setTimeout(e,0);return{cancel:()=>{globalThis.clearTimeout(t)}}}var Mb=[`machines`,`projects`,`workspaces`,`sessions`];function Nb(e){return e.selectedWorkspace===void 0?e.selectedProject===void 0?`projects`:`workspaces`:`sessions`}function Pb(e,t){if(e!==`none`)return e??Nb(t)}function Fb(e,t){return Pb(t.expanded,t.state)!==e}function Ib(e,t,n){return Pb(e,n.state)===t?`none`:t}function Lb(e){return e.workspaceCount===1?`sessions`:`workspaces`}function Rb(e){return Mb[Mb.indexOf(e)+1]}var zb=class{hostConnected(){}constructor(e,t){this.host=e,this.getState=t,e.addController(this)}expandedSection(){return Pb(this.expanded,this.getState())}isCollapsed(e){return Fb(e,{expanded:this.expanded,state:this.getState()})}toggle(e){this.setExpanded(Ib(this.expanded,e,{state:this.getState()}))}expand(e){this.setExpanded(e)}advanceAfterSelection(e,t){let n=e===`projects`?Lb({workspaceCount:t?.workspaceCount}):Rb(e);n!==void 0&&this.expand(n)}open(e,t){this.expand(e),t()}setExpanded(e){this.expanded!==e&&(this.expanded=e,this.host.requestUpdate())}},Bb=class{hostConnected(){}constructor(e){this.host=e,this.navigationPanelCollapsed=!1,this.workspacePanelCollapsed=!1,e.addController(this)}toggleNavigationPanel(){this.navigationPanelCollapsed=!this.navigationPanelCollapsed,this.host.requestUpdate()}toggleWorkspacePanel(){this.workspacePanelCollapsed=!this.workspacePanelCollapsed,this.host.requestUpdate()}expandNavigationPanel(){this.navigationPanelCollapsed&&(this.navigationPanelCollapsed=!1,this.host.requestUpdate())}expandWorkspacePanel(){this.workspacePanelCollapsed&&(this.workspacePanelCollapsed=!1,this.host.requestUpdate())}shellClass(e,t=!0){return[`shell`,Hb(e),...this.navigationPanelCollapsed?[`navigation-panel-collapsed`]:[],...Vb(this.workspacePanelCollapsed,t)?[]:[`workspace-panel-collapsed`]].join(` `)}};function Vb(e,t){return!e&&t}function Hb(e){return e===`navigation`?`navigation-view`:e===`chat`?`chat-view`:`workspace-view`}var Ub=`pi-web:panel-sizes:v1`,Wb={navigation:{minWidth:180,maxWidth:4096,defaultWidth:340,keyboardStep:24,largeKeyboardStep:72},workspace:{minWidth:240,maxWidth:4096,defaultWidth:480,keyboardStep:24,largeKeyboardStep:72}},Gb=class{constructor(e,t={}){this.host=e,e.addController(this),this.storage=t.storage??ax(),this.panelSizes=Zb(this.storage)}hostConnected(){}constraints(e){return Kb(e)}panelWidth(e,t){return Xb(e,t??this.storedPanelWidth(e)??this.constraints(e).defaultWidth)}resizePanel(e,t,n={}){let r=Xb(e,t);this.storedPanelWidth(e)!==r&&(this.panelSizes=tx(this.panelSizes,e,r),n.persist!==!1&&this.persistPanelSizes(),this.host.requestUpdate())}resetPanel(e,t={}){this.storedPanelWidth(e)!==void 0&&(this.panelSizes=nx(this.panelSizes,e),t.persist!==!1&&this.persistPanelSizes(),this.host.requestUpdate())}resetPanels(e={}){this.panelSizes.navigationPanelWidth===void 0&&this.panelSizes.workspacePanelWidth===void 0||(this.panelSizes={},e.persist!==!1&&this.persistPanelSizes(),this.host.requestUpdate())}persistPanelSizes(){Qb(this.panelSizes,this.storage)}shellStyle(e={}){let t=[];return this.panelSizes.navigationPanelWidth!==void 0&&t.push(`--navigation-panel-size: ${ix(Xb(`navigation`,this.panelSizes.navigationPanelWidth,e.navigation))};`),this.panelSizes.workspacePanelWidth!==void 0&&t.push(`--workspace-panel-size: ${ix(Xb(`workspace`,this.panelSizes.workspacePanelWidth,e.workspace))};`),t.join(` `)}storedPanelWidth(e){return e===`navigation`?this.panelSizes.navigationPanelWidth:this.panelSizes.workspacePanelWidth}};function Kb(e){return Wb[e]}function qb(e,t,n){return e===`navigation`?n-t:t-n}function Jb(e,t,n,r,i=Kb(e)){return Xb(e,t+qb(e,n,r),i)}function Yb(e,t,n,r={}){let i=r.constraints??Kb(e);if(n===`Home`)return i.minWidth;if(n===`End`)return i.maxWidth;let a=rx(e,n,r.largeStep===!0?i.largeKeyboardStep:i.keyboardStep);if(a!==void 0)return Xb(e,t+a,i)}function Xb(e,t,n=Kb(e)){return Number.isFinite(t)?Math.round(Math.min(Math.max(t,n.minWidth),n.maxWidth)):n.defaultWidth}function Zb(e=ax()){try{let t=e?.getItem(Ub);return t==null||t===``?{}:$b(JSON.parse(t))}catch{return{}}}function Qb(e,t=ax()){if(t!==void 0)try{if(e.navigationPanelWidth===void 0&&e.workspacePanelWidth===void 0){t.removeItem(Ub);return}let n={version:1};e.navigationPanelWidth!==void 0&&(n.navigationPanelWidth=Xb(`navigation`,e.navigationPanelWidth)),e.workspacePanelWidth!==void 0&&(n.workspacePanelWidth=Xb(`workspace`,e.workspacePanelWidth)),t.setItem(Ub,JSON.stringify(n))}catch{}}function $b(e){if(!ox(e)||e.version!==1)return{};let t={},n=ex(e.navigationPanelWidth),r=ex(e.workspacePanelWidth);return n!==void 0&&(t.navigationPanelWidth=Xb(`navigation`,n)),r!==void 0&&(t.workspacePanelWidth=Xb(`workspace`,r)),t}function ex(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function tx(e,t,n){return t===`navigation`?{...e,navigationPanelWidth:n}:{...e,workspacePanelWidth:n}}function nx(e,t){return t===`navigation`?e.workspacePanelWidth===void 0?{}:{workspacePanelWidth:e.workspacePanelWidth}:e.navigationPanelWidth===void 0?{}:{navigationPanelWidth:e.navigationPanelWidth}}function rx(e,t,n){if(e===`navigation`)return t===`ArrowRight`?n:t===`ArrowLeft`?-n:void 0;if(t===`ArrowLeft`)return n;if(t===`ArrowRight`)return-n}function ix(e){return`${String(Math.round(e))}px`}function ax(){try{return typeof window>`u`?void 0:window.localStorage}catch{return}}function ox(e){return typeof e==`object`&&!!e}function sx(){let e=new URLSearchParams(window.location.search);return{machineId:dx(e.get(`machine`)),projectId:dx(e.get(`project`)),workspaceId:dx(e.get(`workspace`)),sessionId:dx(e.get(`session`)),tool:dx(e.get(`tool`)),view:dx(e.get(`view`))}}function cx(e,t){return{machineId:e.machineId,projectId:e.projectId,workspaceId:e.workspaceId,sessionId:e.sessionId,tool:e.tool===void 0?void 0:lx(e.tool,t),view:e.view===`chat`?`chat`:e.view===void 0?void 0:lx(e.view,t)}}function lx(e,t){return t(e)??(fx(e)?e:void 0)}function ux(e,t){let n=new URL(window.location.href);n.searchParams.delete(`machine`),n.searchParams.delete(`project`),n.searchParams.delete(`workspace`),n.searchParams.delete(`session`),n.searchParams.delete(`tool`),n.searchParams.delete(`view`),e.machineId!==void 0&&e.machineId!==``&&e.machineId!==`local`&&n.searchParams.set(`machine`,e.machineId),e.projectId!==void 0&&e.projectId!==``&&n.searchParams.set(`project`,e.projectId),e.workspaceId!==void 0&&e.workspaceId!==``&&n.searchParams.set(`workspace`,e.workspaceId),e.sessionId!==void 0&&e.sessionId!==``&&n.searchParams.set(`session`,e.sessionId),e.tool!==void 0&&e.tool!==``&&n.searchParams.set(`tool`,e.tool),e.view!==void 0&&e.view!==``&&n.searchParams.set(`view`,e.view),`${n.pathname}${n.search}${n.hash}`!=`${window.location.pathname}${window.location.search}${window.location.hash}`&&bt(String(n),t?.replace===!0)}function dx(e){return e===null||e===``?void 0:e}function fx(e){return/^[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$/u.test(e)}function px(){return hx(new URLSearchParams(window.location.search).get(`settings`))}function mx(e,t){let n=new URL(window.location.href);e===void 0?n.searchParams.delete(`settings`):n.searchParams.set(`settings`,e),`${n.pathname}${n.search}${n.hash}`!=`${window.location.pathname}${window.location.search}${window.location.hash}`&&bt(String(n),t?.replace===!0)}function hx(e){if(e===`general`)return`general`;if(e===`appearance`||e===`theme`||e===`themes`)return`appearance`;if(e===`sessiond`||e===`sessions`)return`sessiond`;if(e===`machines`)return`machines`;if(e===`packages`||e===`pi-packages`)return`packages`;if(e===`plugins`)return`plugins`;if(e===`shortcuts`||e===`keyboard`||e===`keyboard-shortcuts`)return`shortcuts`}function gx(e,t){return t===void 0?e:e.map(e=>vx(e,t))}function _x(e,t){let n=new Set(wm(e,t,{enabledOnly:!0}).filter(e=>e.active).map(e=>e.action.id));return gx(e,t).map(e=>e.shortcut!==void 0&&!n.has(e.id)?yx(e):e)}function vx(e,t){let n=jm(e,t);return n===void 0?e:n===null?yx(e):{...e,shortcut:n}}function yx(e){let t={...e};return delete t.shortcut,t}function bx(e,t){let n=t.api??cs,r=t.pollIntervalMs??1e3,i=t.setTimeout??Cx(),a=t.clearTimeout??wx();return{async runCommand(o){let s=await n.runTerminalCommand(e,o);return o.open===!0&&t.openTerminal(o.workspace,{terminalId:s.terminalId}),{run:s,completed:xx(s,n,r,i,a)}},listCommandRuns:e=>n.listCommandRuns(e),getCommandRun:e=>n.getCommandRun(e),open:e=>{t.openTerminal(void 0,e)}}}function xx(e,t,n,r,i){return Sx(e)?Promise.resolve(e):new Promise((a,o)=>{let s,c=!1,l=e=>{c||(c=!0,s!==void 0&&i(s),a(e))},u=e=>{c||(c=!0,s!==void 0&&i(s),o(e instanceof Error?e:Error(String(e))))},d=()=>{t.getCommandRun(e.id).then(e=>{if(e!==void 0&&Sx(e)){l(e);return}s=r(d,n)}).catch(u)};s=r(d,n)})}function Sx(e){return e.status===`succeeded`||e.status===`failed`}function Cx(){return(e,t)=>globalThis.setTimeout(e,t)}function wx(){return e=>{globalThis.clearTimeout(e)}}var Tx=class{constructor(e){this.callbacks=e,this.fired=!1}start(e){this.cancel(),this.origin=e,this.fired=!1,this.handle=this.callbacks.setTimer(()=>{this.handle=void 0,this.fired=!0,this.callbacks.onLongPress()},500)}move(e){if(this.origin===void 0)return;let t=Math.abs(e.clientX-this.origin.clientX),n=Math.abs(e.clientY-this.origin.clientY);(t>10||n>10)&&this.cancel()}cancel(){this.handle!==void 0&&this.callbacks.clearTimer(this.handle),this.handle=void 0,this.origin=void 0}consumeSuppressedClick(){let e=this.fired;return this.fired=!1,e}},Ex=class{constructor(e){this.open=e,this.longPress=new Tx({onLongPress:()=>{this.heldId!==void 0&&this.open(this.heldId,this.heldAnchor??null)},setTimer:(e,t)=>window.setTimeout(e,t),clearTimer:e=>{window.clearTimeout(e)}})}pointerDown(e,t){t.pointerType!==`mouse`&&(this.heldId=e,this.heldAnchor=t.currentTarget,this.longPress.start(t))}pointerMove(e){this.longPress.move(e)}cancel(){this.longPress.cancel(),this.heldId=void 0,this.heldAnchor=void 0}consumeSuppressedClick(){return this.longPress.consumeSuppressedClick()}contextMenu(e,t){t.preventDefault(),this.open(e,t.currentTarget)}};function Dx(e){return`${e.label}\n${e.path}`}function Ox(e,t){return sf(e,t,Dx)}function kx(e,t){return sf(e,t,e=>e.name)}function Ax(e,t){return e>=8||af(t).length>0}var jx=0,Mx=120;function Nx(e,t={}){if(typeof HTMLElement>`u`||typeof window>`u`||!(e instanceof HTMLElement))return``;let n=e.getBoundingClientRect(),r=t.constrainTo===`viewport`?Fx():Px(e),i=window.innerWidth,a=window.innerHeight,o=Math.max(0,r.left),s=Math.min(i,r.right),c=Math.max(0,r.top),l=Math.min(a,r.bottom),u=Math.min(n.right,s),d=l-n.bottom-jx,f=n.top-c-jx;return[...d<Mx&&f>d?[`bottom: ${Ix(a-n.top+jx)};`,`max-height: ${Ix(Math.max(0,f))};`]:[`top: ${Ix(n.bottom+jx)};`,`max-height: ${Ix(Math.max(0,d))};`],`right: ${Ix(Math.max(0,i-u))};`,`max-width: ${Ix(Math.max(0,u-o))};`].join(` `)}function Px(e){let t=e.getRootNode();return typeof ShadowRoot<`u`&&t instanceof ShadowRoot&&t.host instanceof HTMLElement?t.host.getBoundingClientRect():Fx()}function Fx(){return{top:0,right:window.innerWidth,bottom:window.innerHeight,left:0}}function Ix(e){return`${String(Math.round(e))}px`}function Lx(e,t=`Active`,n){if(e===void 0)return n===void 0?void 0:g`<span class="activity-indicator unread" role="img" aria-label=${n} title=${n}></span>`;if(n===void 0)return g`<span class=${`activity-indicator ${e}`} role="img" aria-label=${t} title=${t}></span>`;let r=`${n} · ${t}`;return g`<span class="unread-ring" role="img" aria-label=${r} title=${r}><span class=${`activity-indicator ${e}`} aria-hidden="true"></span></span>`}function Rx(e){if(e!==void 0)return e[fn.working]===!0?`session`:e[fn.terminal]===!0?`terminal`:Object.entries(e).some(([e,t])=>t&&e!==fn.unread)?`session`:void 0}function zx(e){return e?.[fn.unread]===!0}var Bx={working:`Session is working`,background:`Turn ended; background work still running`,idle:`Session is done`,asking:`Waiting for your answer`,error:`Session hit an error`};function Vx(e,t){if(e===void 0)return t===void 0?void 0:g`<span class="session-state unread" role="img" aria-label=${t} title=${t}></span>`;let n=e===`sending`?`Sending message`:Bx[e],r=t===void 0?n:`${t} · ${n}`;if(e===`idle`)return g`<span class=${t===void 0?`session-state idle`:`session-state idle unread`} role="img" aria-label=${r} title=${r}></span>`;if(e===`working`||e===`sending`){let i=e===`working`?[0,1,2].map(e=>g`<span class="state-dot working-dot" style=${`animation-delay:${(e*.14).toFixed(2)}s`}></span>`):null;return t===void 0?g`<span class="session-state working" role="img" aria-label=${n} title=${n}><span class="state-dots">${i}</span></span>`:g`<span class="unread-ring" role="img" aria-label=${r} title=${r}><span class="session-state working" aria-hidden="true"><span class="state-dots">${i}</span></span></span>`}return t===void 0?g`<span class=${`session-state ${e}`} role="img" aria-label=${n} title=${n}></span>`:g`<span class="unread-ring" role="img" aria-label=${r} title=${r}><span class=${`session-state ${e}`} aria-hidden="true"></span></span>`}function Hx(e,t=`Active`,n){let r=Lx(e,t,n);if(r!==void 0)return g`<span class="action-activity">${r}</span>`}var Ux=[`a[href]`,`button`,`input`,`select`,`textarea`,`summary`,`[role='button']`,`[role='link']`,`[contenteditable='true']`].join(`,`);function Wx(e){return e.composedPath().some(e=>Gx(e,Ux))}function Gx(e,t){if(typeof Element<`u`&&e instanceof Element)return e.matches(t);if(!(`matches`in e))return!1;let{matches:n}=e;return typeof n==`function`&&n.call(e,t)===!0}function Kx(e,t){return Wx(e)?!1:e.key===`Enter`||e.key===` `?(e.preventDefault(),t.activate(),!0):e.key===`ArrowUp`?Jx(e,()=>{Yx(e.currentTarget,-1)}):e.key===`ArrowDown`?Jx(e,()=>{Yx(e.currentTarget,1)}):e.key===`Home`?Jx(e,()=>{Xx(e.currentTarget,0)}):e.key===`End`?Jx(e,()=>{Xx(e.currentTarget,-1)}):e.key===`ArrowLeft`&&t.previousSection!==void 0?Jx(e,t.previousSection):e.key===`ArrowRight`&&t.nextSection!==void 0?Jx(e,t.nextSection):e.key===`Escape`&&t.cancel!==void 0&&Jx(e,t.cancel)}function qx(e,t={}){let n=e.querySelector(`.action-row.selected`)??e.querySelector(`.action-row`)??(t.fallbackSelector===void 0?void 0:e.querySelector(t.fallbackSelector));return n==null?!1:(n.focus(),n.scrollIntoView({block:`nearest`}),!0)}function Jx(e,t){return e.preventDefault(),e.stopPropagation?.(),t(),!0}function Yx(e,t){let n=Qx(e),r=eS(e);if(r===void 0||n.length===0)return;let i=n.indexOf(r);i<0||Zx(n,i+t)}function Xx(e,t){let n=Qx(e);n.length!==0&&Zx(n,t<0?n.length-1:t)}function Zx(e,t){let n=e[Math.min(Math.max(t,0),e.length-1)];n?.focus(),n?.scrollIntoView({block:`nearest`})}function Qx(e){let t=eS(e)?.getRootNode();return t===void 0||!$x(t)?[]:Array.from(t.querySelectorAll(`.action-row`))}function $x(e){return typeof Document<`u`&&e instanceof Document||typeof DocumentFragment<`u`&&e instanceof DocumentFragment}function eS(e){if(!(typeof HTMLElement>`u`||!(e instanceof HTMLElement)))return e.closest(`.action-row`)??void 0}var U=class extends v{constructor(...e){super(...e),this.machines=[],this.searchQuery=``,this.statuses={},this.statusSnapshots={},this.collapsible=!1,this.collapsed=!1,this.gestures=new Ex((e,t)=>{this.openMenu(e,t)}),this.menuStyle=``,this.onDocumentClick=e=>{e.composedPath().includes(this)||(this.openMenuMachineId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this.onDocumentClick)}disconnectedCallback(){document.removeEventListener(`click`,this.onDocumentClick),super.disconnectedCallback()}updated(e){e.has(`machines`)&&this.openMenuMachineId!==void 0&&!this.machines.some(e=>e.id===this.openMenuMachineId)&&(this.openMenuMachineId=void 0),e.has(`collapsed`)&&this.collapsed&&(this.openMenuMachineId=void 0)}async focusSelectedOrFirst(){return await this.updateComplete,qx(this.renderRoot,{fallbackSelector:`.section-toggle`})}renderSearch(){if(!Ax(this.machines.length,this.searchQuery))return null;let e=this.searchQuery!==``;return g`
|
|
1400
|
+
`]}};H([b({attribute:!1})],xy.prototype,`context`,void 0),H([S(`#workspace-upload-input`)],xy.prototype,`uploadInput`,void 0),H([S(`.dialog-backdrop`)],xy.prototype,`uploadDialogBackdrop`,void 0),H([S(`.upload-dialog`)],xy.prototype,`uploadDialog`,void 0),H([x()],xy.prototype,`pendingUpload`,void 0),H([x()],xy.prototype,`destinationFolder`,void 0),H([x()],xy.prototype,`overwrite`,void 0),H([x()],xy.prototype,`createDirs`,void 0),H([x()],xy.prototype,`formError`,void 0),H([x()],xy.prototype,`dragActive`,void 0),xy=H([y(`workspace-files-panel`)],xy);function Sy(e,t){return Object.values(e).filter(e=>e.projectId===t.projectId&&e.workspaceId===t.workspaceId&&e.machineId===t.machineId).sort((e,t)=>t.startedAt.localeCompare(e.startedAt))}function Cy(e,t){if(e.length===0)return`Choose at least one file to upload.`;for(let n of e)try{Qs(t,n.name)}catch(e){return e instanceof Error?e.message:String(e)}}function wy(e){return{destinationFolder:e,createDirs:!0,overwrite:!1}}function Ty(e,t){if(t.length!==0)return e.onStartWorkspaceUpload(t,{destinationFolder:e.workspaceUploadDefaultFolder,createDirs:!0,overwrite:!1,selectUploadedFile:!0})}function Ey(e){return`${e.machine.id}:${e.workspace.projectId}:${e.workspace.id}`}function Dy(e){return e==null?[]:Array.from(e)}function Oy(e){return Array.from(e.dataTransfer?.types??[]).includes(`Files`)}function ky(e){let t=e.getRootNode();return t instanceof ShadowRoot&&t.host instanceof HTMLElement?t.host:e}function Ay(e){let t=e.filter(e=>e.status===`uploading`).length;return t===0?`${String(e.length)} recent`:`${String(t)} uploading`}function jy(e){let t=e.files.length,n=t===1?`file`:`files`;switch(e.status){case`completed`:return`Uploaded ${String(t)} ${n}`;case`error`:return`Upload failed for ${String(t)} ${n}`;case`cancelled`:return`Upload cancelled for ${String(t)} ${n}`;case`uploading`:return`Uploading ${String(t)} ${n}`}}function My(e){switch(e.status){case`completed`:return`Done`;case`error`:return`Failed`;case`cancelled`:return`Cancelled`;case`uploading`:return Iy(e.percent)}}function Ny(e){return e.status===`uploading`?e.percent:1}function Py(e){switch(e.status){case`pending`:return`Pending`;case`uploading`:return Iy(e.percent);case`completed`:return`Done`;case`error`:return`Error`;case`cancelled`:return`Cancelled`}}function Fy(e){return e.error===void 0?e.response===void 0?`${e.path} · ${Sg(e.loaded)} / ${Sg(e.total)}`:`Wrote ${e.response.path}`:e.error}function Iy(e){return`${String(Math.round(Math.max(0,Math.min(1,e))*100))}%`}function Ly(){return[{id:`workspace.files`,title:`Files`,icon:yg(`files`),order:10,routeAliases:[`files`],render:Ry},{id:`workspace.terminal`,title:`Terminal`,icon:yg(`terminal`),order:30,badge:e=>e.activeTerminalCount>0?e.activeTerminalCount:void 0,render:zy}]}function Ry(e){return g`<workspace-files-panel .context=${e}></workspace-files-panel>`}function zy(e){return By(),g`<terminal-panel .workspace=${e.workspace} .machineId=${e.machine.id} .selectedTerminalId=${e.selectedTerminalId} .autoStart=${e.terminalAutoStart} .onSelectTerminal=${e.onSelectTerminal}></terminal-panel>`}function By(){fy(()=>import(`./TerminalPanel-D0BZl86M.js`),__vite__mapDeps([4,5,6]),import.meta.url)}var Vy={apiVersion:2,name:`PI WEB Core`,activate:()=>({contributions:{actions:dg(),workspacePanels:Ly()}})},Hy={"--pi-bg":`#0d1117`,"--pi-surface":`#161b22`,"--pi-surface-hover":`#21262d`,"--pi-terminal-bg":`#05070a`,"--pi-terminal-text":`#e6edf3`,"--pi-border":`#30363d`,"--pi-border-muted":`#21262d`,"--pi-text":`#e6edf3`,"--pi-text-secondary":`#c9d1d9`,"--pi-text-bright":`#f0f6fc`,"--pi-muted":`#8b949e`,"--pi-dim":`#6e7681`,"--pi-accent":`#58a6ff`,"--pi-accent-border":`#2f81f7`,"--pi-selection-bg":`#0d2847`,"--pi-success":`#3fb950`,"--pi-success-border":`#238636`,"--pi-success-bg":`#0f1b12`,"--pi-success-surface":`#0f2a16`,"--pi-success-ring":`#3fb95055`,"--pi-warning":`#d29922`,"--pi-warning-border":`#6e5200`,"--pi-warning-surface":`#1f1a10`,"--pi-danger":`#ff7b72`,"--pi-purple":`#d2a8ff`,"--pi-purple-border":`#a371f7`,"--pi-purple-surface":`#21132f`,"--pi-overlay":`#0008`,"--pi-shadow-soft":`#0006`,"--pi-shadow":`#0008`,"--pi-shadow-strong":`#000b`,"--pi-bg-overlay-soft":`#0d1117dd`,"--pi-bg-overlay":`#0d1117e6`,"--pi-success-bg-overlay":`#0f1b12ee`,"--pi-terminal-selection":`#264f78`},Uy={"--pi-bg":`#070912`,"--pi-surface":`#101527`,"--pi-surface-hover":`#151b31`,"--pi-terminal-bg":`#050710`,"--pi-terminal-text":`#f7f4ff`,"--pi-border":`#26304f`,"--pi-border-muted":`#26304f`,"--pi-text":`#f7f4ff`,"--pi-text-secondary":`#aaa4bd`,"--pi-text-bright":`#ffffff`,"--pi-muted":`#aaa4bd`,"--pi-dim":`#817a99`,"--pi-accent":`#7c3cff`,"--pi-accent-border":`#5a47b0`,"--pi-selection-bg":`#1d2547`,"--pi-success":`#00f0d8`,"--pi-success-border":`#00f0d8`,"--pi-success-bg":`#071e22`,"--pi-success-surface":`#092d31`,"--pi-success-ring":`#00f0d855`,"--pi-warning":`#ffb000`,"--pi-warning-border":`#ffb000`,"--pi-warning-surface":`#16140d`,"--pi-danger":`#ff4f7b`,"--pi-purple":`#b7a2ff`,"--pi-purple-border":`#7c3cff`,"--pi-purple-surface":`#181026`,"--pi-overlay":`#0008`,"--pi-shadow-soft":`#0006`,"--pi-shadow":`#0008`,"--pi-shadow-strong":`#000b`,"--pi-bg-overlay-soft":`#070912dd`,"--pi-bg-overlay":`#070912e6`,"--pi-success-bg-overlay":`#071e22ee`,"--pi-terminal-selection":`#3d4a78`},Wy={"--pi-bg":`#f7f1e6`,"--pi-surface":`#fff9ee`,"--pi-surface-hover":`#f0e6d6`,"--pi-terminal-bg":`#15131b`,"--pi-terminal-text":`#fff9ee`,"--pi-border":`#c9bca8`,"--pi-border-muted":`#d8cdbc`,"--pi-text":`#15131b`,"--pi-text-secondary":`#15131b`,"--pi-text-bright":`#15131b`,"--pi-muted":`#5f586a`,"--pi-dim":`#766f7e`,"--pi-accent":`#6430d8`,"--pi-accent-border":`#6430d8`,"--pi-selection-bg":`#eadff8`,"--pi-success":`#008c82`,"--pi-success-border":`#008c82`,"--pi-success-bg":`#e1f4ef`,"--pi-success-surface":`#d7f0ec`,"--pi-success-ring":`#008c8255`,"--pi-warning":`#b05f00`,"--pi-warning-border":`#b05f00`,"--pi-warning-surface":`#fff2d2`,"--pi-danger":`#b51d49`,"--pi-purple":`#6430d8`,"--pi-purple-border":`#6430d8`,"--pi-purple-surface":`#eadff8`,"--pi-overlay":`#15131b66`,"--pi-shadow-soft":`#15131b22`,"--pi-shadow":`#15131b33`,"--pi-shadow-strong":`#15131b44`,"--pi-bg-overlay-soft":`#f7f1e6dd`,"--pi-bg-overlay":`#f7f1e6e6`,"--pi-success-bg-overlay":`#e1f4efee`,"--pi-terminal-selection":`#8d7b64`},Gy={"--pi-bg":`#000000`,"--pi-surface":`#0d0d0d`,"--pi-surface-hover":`#1a1a1a`,"--pi-terminal-bg":`#000000`,"--pi-terminal-text":`#ffffff`,"--pi-border":`#5c5c5c`,"--pi-border-muted":`#3d3d3d`,"--pi-text":`#ffffff`,"--pi-text-secondary":`#e6e6e6`,"--pi-text-bright":`#ffffff`,"--pi-muted":`#b3b3b3`,"--pi-dim":`#8f8f8f`,"--pi-accent":`#4dc3ff`,"--pi-accent-border":`#4dc3ff`,"--pi-selection-bg":`#00263a`,"--pi-success":`#3ff05a`,"--pi-success-border":`#3ff05a`,"--pi-success-bg":`#001a06`,"--pi-success-surface":`#00280b`,"--pi-success-ring":`#3ff05a66`,"--pi-warning":`#ffcc33`,"--pi-warning-border":`#ffcc33`,"--pi-warning-surface":`#251c00`,"--pi-danger":`#ff6b6b`,"--pi-purple":`#c9a3ff`,"--pi-purple-border":`#c9a3ff`,"--pi-purple-surface":`#180d29`,"--pi-overlay":`#000000cc`,"--pi-shadow-soft":`#00000099`,"--pi-shadow":`#000000bb`,"--pi-shadow-strong":`#000000e6`,"--pi-bg-overlay-soft":`#000000dd`,"--pi-bg-overlay":`#000000f2`,"--pi-success-bg-overlay":`#001a06ee`,"--pi-terminal-selection":`#00456b`},Ky={"--pi-bg":`#14110e`,"--pi-surface":`#1d1915`,"--pi-surface-hover":`#26211b`,"--pi-terminal-bg":`#100d0b`,"--pi-terminal-text":`#e8ddcc`,"--pi-border":`#3a3229`,"--pi-border-muted":`#2b2520`,"--pi-text":`#e8ddcc`,"--pi-text-secondary":`#cbbfad`,"--pi-text-bright":`#fff4e0`,"--pi-muted":`#9c9081`,"--pi-dim":`#7a6f62`,"--pi-accent":`#e0a35c`,"--pi-accent-border":`#b8813f`,"--pi-selection-bg":`#2e2415`,"--pi-success":`#8fbf6f`,"--pi-success-border":`#6d9954`,"--pi-success-bg":`#161c12`,"--pi-success-surface":`#1e2718`,"--pi-success-ring":`#8fbf6f55`,"--pi-warning":`#d9a441`,"--pi-warning-border":`#9c7429`,"--pi-warning-surface":`#241c0f`,"--pi-danger":`#d97b6c`,"--pi-purple":`#b79ad1`,"--pi-purple-border":`#8d74a8`,"--pi-purple-surface":`#221a2b`,"--pi-overlay":`#0a0806cc`,"--pi-shadow-soft":`#00000055`,"--pi-shadow":`#00000077`,"--pi-shadow-strong":`#000000aa`,"--pi-bg-overlay-soft":`#14110edd`,"--pi-bg-overlay":`#14110ee6`,"--pi-success-bg-overlay":`#161c12ee`,"--pi-terminal-selection":`#3d3121`},qy={"--pi-bg":`#fbfbf9`,"--pi-surface":`#ffffff`,"--pi-surface-hover":`#f1f1ee`,"--pi-terminal-bg":`#1c1c1a`,"--pi-terminal-text":`#fbfbf9`,"--pi-border":`#c7c7c1`,"--pi-border-muted":`#e0e0da`,"--pi-text":`#1c1c1a`,"--pi-text-secondary":`#33332f`,"--pi-text-bright":`#000000`,"--pi-muted":`#5e5e58`,"--pi-dim":`#7c7c75`,"--pi-accent":`#1f5fd0`,"--pi-accent-border":`#1f5fd0`,"--pi-selection-bg":`#e2ecfb`,"--pi-success":`#0f7a4a`,"--pi-success-border":`#0f7a4a`,"--pi-success-bg":`#e6f5ed`,"--pi-success-surface":`#d9efe3`,"--pi-success-ring":`#0f7a4a55`,"--pi-warning":`#8a5a00`,"--pi-warning-border":`#8a5a00`,"--pi-warning-surface":`#fdf0d5`,"--pi-danger":`#b02020`,"--pi-purple":`#5b3fc7`,"--pi-purple-border":`#5b3fc7`,"--pi-purple-surface":`#ece7fb`,"--pi-overlay":`#1c1c1a66`,"--pi-shadow-soft":`#1c1c1a1a`,"--pi-shadow":`#1c1c1a2b`,"--pi-shadow-strong":`#1c1c1a40`,"--pi-bg-overlay-soft":`#fbfbf9dd`,"--pi-bg-overlay":`#fbfbf9e6`,"--pi-success-bg-overlay":`#e6f5edee`,"--pi-terminal-selection":`#9ab4d8`},Jy={apiVersion:2,name:`PI WEB Themes`,activate:()=>({contributions:{themes:[{id:`pi-web-dark`,name:`PI WEB Dark`,description:`Dark PI WEB palette.`,order:10,colorScheme:`dark`,tokens:Uy},{id:`pi-web-light`,name:`PI WEB Light`,description:`Light PI WEB palette.`,order:20,colorScheme:`light`,tokens:Wy},{id:`classic`,name:`PI WEB Classic`,description:`The original PI WEB dark palette.`,order:30,colorScheme:`dark`,tokens:Hy},{id:`high-contrast`,name:`High Contrast`,description:`Near-black behind near-white, for bright rooms and tired eyes.`,order:40,colorScheme:`dark`,tokens:Gy},{id:`night`,name:`Night`,description:`Warm and dim, with an amber accent instead of blue light.`,order:50,colorScheme:`dark`,tokens:Ky},{id:`paper`,name:`Paper`,description:`Untinted ink on paper, for daylight and for screenshots.`,order:60,colorScheme:`light`,tokens:qy}],themePairs:[{id:`pi-web`,name:`PI WEB`,description:`Follow the system light/dark preference with PI WEB themes.`,order:10,light:`pi-web-light`,dark:`pi-web-dark`}]}})};async function Yy(e=`pi-web-plugins/manifest.json`,t={}){let n=Wt(e),r=await Qy(n);if(r===void 0)return{registrations:[],failures:[]};let i=[],a=[];for(let e of r.plugins)if(t.shouldLoadPlugin?.(e)!==!1)try{let r=Xy(e.module,n),a=rb(await(t.moduleLoader??Zy)(r),r);i.push({id:t.machineId===void 0?e.id:bc(t.machineId,e.id),plugin:a,machineSpecific:e.machineSpecific,...e.backendRevision===void 0?{}:{backendRevision:e.backendRevision},...t.machineId===void 0?{}:{machineId:t.machineId,sourcePluginId:e.id}})}catch(t){a.push({entry:e,error:t})}return{registrations:i,failures:a}}function Xy(e,t,n){return e.startsWith(`/`)?n===void 0?Wt(e):Wt(e,n):new URL(e,t).toString()}async function Zy(e){return fy(()=>import(e),[],import.meta.url)}async function Qy(e){let t=await fetch(e,{cache:`no-store`});if(t.status!==404){if(!t.ok)throw Error(await eb(t));return $y(await t.json())}}function $y(e){if(!ab(e)||!Array.isArray(e.plugins))throw Error(`Invalid plugin manifest`);let t=e.plugins.map(e=>{if(!ab(e)||typeof e.id!=`string`||typeof e.module!=`string`||e.module===``)throw Error(`Invalid plugin manifest entry`);let t=e.id;if(!Dn(t))throw Error(`Invalid plugin manifest id: ${t}`);if(On(t))throw Error(`Reserved plugin manifest id: ${t}`);return{id:t,module:e.module,...tb(e.backendRevision),machineSpecific:nb(e.machineSpecific)}}),n=new Set;for(let e of t){if(n.has(e.id))throw Error(`Duplicate plugin manifest id: ${e.id}`);n.add(e.id)}return{plugins:t}}async function eb(e){let t;try{let n=await e.json();if(ab(n)){let e=n.error,r=n.detail;t=typeof r==`string`?`${typeof e==`string`?`${e}: `:``}${r}`:typeof e==`string`?e:void 0}}catch{}return`Failed to load plugin manifest (${`${String(e.status)}${e.statusText===``?``:` ${e.statusText}`}`})${t===void 0?``:`: ${t}`}`}function tb(e){if(e===void 0)return{};try{return{backendRevision:Os(e)}}catch{throw Error(`Invalid plugin manifest entry`)}}function nb(e){if(e===void 0)return!1;if(typeof e!=`boolean`)throw Error(`Invalid plugin manifest entry`);return e}function rb(e,t){if(!ab(e))throw Error(`Plugin module ${t} did not export an object`);let n=e.default;if(ab(n)&&n.apiVersion!==2)throw Error(`Unsupported browser plugin API version for ${t}: ${String(n.apiVersion)} (expected 2)`);if(!ib(n))throw Error(`Plugin module ${t} default export is not a PiWebPlugin`);return n}function ib(e){return ab(e)&&e.apiVersion===2&&typeof e.name==`string`&&typeof e.activate==`function`}function ab(e){return typeof e==`object`&&!!e}var ob=/^[a-z][a-z0-9.-]*$/u,sb=/^[a-z][a-z0-9.-]*$/u,cb=/^[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$/u,lb=/^[a-z][a-z0-9.-]*(?::[a-z][a-z0-9.-]*)?$/u,ub=new WeakMap,db=new WeakMap,fb=new WeakMap,pb=class{constructor(){this.actions=[],this.workspacePanels=[],this.workspaceLabels=[],this.themes=[],this.themePairs=[],this.pluginIds=new Set,this.registeringPluginIds=new Set,this.gatewayPluginIds=new Set,this.gatewayMachineSpecificPluginIds=new Set,this.remoteMachineSpecificPluginIds=new Map,this.contributionIds=new Set}register(e){let{plugin:t}=e,n=e.id,r=e.sourcePluginId??n;this.validatePluginId(n),this.validatePluginId(r);let i=this.parseMachineSpecific(n,e.machineSpecific),a=this.parseBackendRevision(n,e.backendRevision);if(this.pluginIds.has(n)||this.registeringPluginIds.has(n))throw Error(`Duplicate plugin id: ${n}`);if(!this.isRemoteDuplicateHiddenByGateway(e.sourcePluginId,e.machineId,i)){this.registeringPluginIds.add(n);try{let o=t.apiVersion;if(o!==2)throw Error(`Unsupported browser plugin API version for ${r}: ${String(o)} (expected 2)`);let s=t.activate(Object.freeze({apiVersion:2,pluginId:r,runtimePluginId:n,html:g,svg:Ye})).contributions,c=new Set,l=(s.actions??[]).map(t=>this.qualifyAction(n,t,e.machineId,e.sourcePluginId,c)),u=(s.workspacePanels??[]).map(t=>this.qualifyWorkspacePanel(n,t,e.machineId,e.sourcePluginId,a,c)),d=(s.workspaceLabels??[]).map(t=>this.qualifyWorkspaceLabelContribution(n,t,e.machineId,e.sourcePluginId,a,c)),f=e.machineId===void 0?(s.themes??[]).map(e=>this.qualifyTheme(n,e,c)):[],p=e.machineId===void 0?(s.themePairs??[]).map(e=>this.qualifyThemePair(n,e,c)):[];this.pluginIds.add(n);for(let e of c)this.contributionIds.add(e);this.actions.push(...l),this.workspacePanels.push(...u),this.workspaceLabels.push(...d),this.themes.push(...f),this.themePairs.push(...p),e.machineId===void 0?(this.gatewayPluginIds.add(n),i&&this.gatewayMachineSpecificPluginIds.add(n)):e.sourcePluginId!==void 0&&i&&xb(this.remoteMachineSpecificPluginIds,e.sourcePluginId,e.machineId)}finally{this.registeringPluginIds.delete(n)}}}hasPlugin(e){return this.pluginIds.has(e)}shouldLoadRemotePlugin(e,t=!1){return!this.gatewayPluginIds.has(e)||this.gatewayMachineSpecificPluginIds.has(e)||t}getActions(e){let t=wb(e);return this.actions.filter(e=>this.isContributionActive(e.pluginId,e.machineId,t,e.sourcePluginId)).map(t=>{let n=mb(e,t.pluginId),r=t.enabled?.(n),i=r===!1?t.disabledReason?.(n):void 0,a={id:t.id,pluginId:t.pluginId,localId:t.localId,...t.machineId===void 0?{}:{machineId:t.machineId},title:t.title,run:()=>t.run(n)};return t.description!==void 0&&(a.description=t.description),t.shortcut!==void 0&&(a.shortcut=t.shortcut),t.shortcutAliases!==void 0&&(a.shortcutAliases=[...t.shortcutAliases]),t.group!==void 0&&(a.group=t.group),r!==void 0&&(a.enabled=r),i!==void 0&&i!==``&&(a.disabledReason=i),a})}getWorkspacePanels(){return[...this.workspacePanels].sort((e,t)=>(e.order??1e3)-(t.order??1e3)||e.title.localeCompare(t.title))}resolveWorkspacePanelRouteId(e,t){let n=this.workspacePanels.filter(e=>this.isContributionActive(e.pluginId,e.machineId,t,e.sourcePluginId)),r=n.find(t=>t.id===e);if(r!==void 0)return r.id;let i=n.filter(t=>t.routeAliases?.includes(e)===!0);if(i.length===1)return i[0]?.id;i.length>1&&console.warn(`Ambiguous PI WEB workspace panel route: ${e}`)}async invalidateWorkspacePanels(e,t){await Promise.all(this.workspacePanels.map(async n=>{if(!(n.onInvalidate===void 0||t!==void 0&&n.id!==t))try{await n.onInvalidate(e)}catch(e){console.warn(`Failed to invalidate PI WEB plugin panel ${n.id}`,e)}}))}getThemes(){return[...this.themes].sort((e,t)=>(e.order??1e3)-(t.order??1e3)||e.name.localeCompare(t.name))}getThemePairs(){return[...this.themePairs].sort((e,t)=>(e.order??1e3)-(t.order??1e3)||e.name.localeCompare(t.name))}getWorkspaceLabelItems(e){return[...this.workspaceLabels].sort((e,t)=>(e.order??1e3)-(t.order??1e3)||e.id.localeCompare(t.id)).flatMap(t=>t.visible?.(e)===!1?[]:t.items(e))}qualifyAction(e,t,n,r,i){let a=this.qualify(e,t.id,i),o=`${r??e}:${t.id}`,s=this.parseShortcutAliases(a,t.shortcutAliases,o);return{...t,id:a,pluginId:e,localId:t.id,...s.length===0?{}:{shortcutAliases:s},...n===void 0?{}:{machineId:n},...r===void 0?{}:{sourcePluginId:r}}}qualifyWorkspacePanel(e,t,n,r,i,a){let o=this.qualify(e,t.id,a),s=t.badge,c=t.visible,l=t.onInvalidate,u=bb(e,r,i),d=`${r??e}:${t.id}`,f=this.parseRouteAliases(o,t.routeAliases,d);return{...t,id:o,pluginId:e,localId:t.id,...f.length===0?{}:{routeAliases:f},...n===void 0?{}:{machineId:n},...r===void 0?{}:{sourcePluginId:r},visible:t=>this.isContributionActive(e,n,t.machine.id,r)&&(c?.(hb(t,u))??!0),...s===void 0?{}:{badge:t=>this.isContributionActive(e,n,t.machine.id,r)?s(hb(t,u)):void 0},...l===void 0?{}:{onInvalidate:t=>this.isContributionActive(e,n,t.machine.id,r)?l(hb(t,u)):void 0},render:e=>t.render(hb(e,u))}}qualifyWorkspaceLabelContribution(e,t,n,r,i,a){let o=this.qualify(e,t.id,a),s=t.visible,c=t.items,l=bb(e,r,i);return{...t,id:o,pluginId:e,localId:t.id,...n===void 0?{}:{machineId:n},visible:t=>this.isContributionActive(e,n,t.machine.id,r)&&(s?.(gb(t,l))??!0),items:t=>this.isContributionActive(e,n,t.machine.id,r)?c(gb(t,l)):[]}}qualifyTheme(e,t,n){let r=this.qualify(e,t.id,n);return{...t,id:r,pluginId:e,localId:t.id}}qualifyThemePair(e,t,n){let r=this.qualify(e,t.id,n);return{...t,id:r,pluginId:e,localId:t.id,light:this.qualifyReference(e,t.light),dark:this.qualifyReference(e,t.dark)}}qualify(e,t,n){this.validateLocalId(t);let r=`${e}:${t}`;if(this.contributionIds.has(r)||n.has(r))throw Error(`Duplicate contribution id: ${r}`);return n.add(r),r}qualifyReference(e,t){return this.validateLocalId(t),`${e}:${t}`}isContributionActive(e,t,n,r){return t===void 0?!this.isGatewayPluginHiddenForMachine(e,n):t===n&&!this.isRemotePluginHiddenByGateway(r,t)}isRemoteDuplicateHiddenByGateway(e,t,n){return e!==void 0&&t!==void 0&&this.gatewayPluginIds.has(e)&&!this.gatewayMachineSpecificPluginIds.has(e)&&!n}isRemotePluginHiddenByGateway(e,t){return e===void 0||this.gatewayMachineSpecificPluginIds.has(e)||this.remoteMachineSpecificPluginIds.get(e)?.has(t)===!0?!1:this.gatewayPluginIds.has(e)}isGatewayPluginHiddenForMachine(e,t){return t!==`local`&&(this.gatewayMachineSpecificPluginIds.has(e)||this.remoteMachineSpecificPluginIds.get(e)?.has(t)===!0)}parseShortcutAliases(e,t,n){let r=[...new Set([...t??[],n])].filter(t=>t!==e),i=r.find(e=>!Sb(e));if(i!==void 0)throw Error(`Invalid shortcut alias for ${e}: ${i}`);return r.filter(Sb)}parseRouteAliases(e,t,n){let r=[...new Set([...t??[],n])].filter(t=>t!==e);for(let t of r)if(!lb.test(t))throw Error(`Invalid workspace panel route alias for ${e}: ${t}`);return r}validatePluginId(e){if(!ob.test(e))throw Error(`Invalid plugin id: ${e}`)}validateLocalId(e){if(!sb.test(e))throw Error(`Invalid contribution id: ${e}`)}parseBackendRevision(e,t){if(t!==void 0)try{return Os(t)}catch{throw Error(`Invalid plugin backend revision for ${e}`)}}parseMachineSpecific(e,t){if(t===void 0)return!1;if(typeof t!=`boolean`)throw Error(`Invalid plugin machineSpecific value for ${e}: ${Cb(t)}`);return t}};function mb(e,t){return ub.get(e)?.(t)??e}function hb(e,t){return db.get(e)?.(t)??e}function gb(e,t){return fb.get(e)?.(t)??e}function _b(e,t){return ub.set(e,t),e}function vb(e,t){return db.set(e,t),e}function yb(e,t){return fb.set(e,t),e}function bb(e,t,n){return Object.freeze({registrationPluginId:e,sourcePluginId:t??e,...n===void 0?{}:{backendRevision:n}})}function xb(e,t,n){let r=e.get(t);r===void 0?e.set(t,new Set([n])):r.add(n)}function Sb(e){return cb.test(e)}function Cb(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||typeof e==`symbol`||typeof e==`function`||e==null)return String(e);try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}}function wb(e){return e.state.selectedMachine?.id??`local`}function Tb(e,t,n,r=Ls){let i=e.backendRevision;if(i!==void 0)return{request:(a,o)=>r({pluginId:e.sourcePluginId,backendRevision:i,machineId:n,projectId:t.projectId,workspaceId:t.id},a,o)}}function Eb(e,t,n,r){return{readFile:r=>e.workspaceFile(t.projectId,t.id,r,n),listFiles:r=>e.workspaceTree(t.projectId,t.id,r,n),writeFile:async(i,a,o)=>{let s=await e.writeWorkspaceFile(t.projectId,t.id,i,a,o,n);return r?.(),s},deleteFile:async i=>{let a=await e.deleteWorkspaceFile(t.projectId,t.id,i,n);return r?.(),a},moveFile:async(i,a,o)=>{let s=await e.moveWorkspaceFile(t.projectId,t.id,i,a,o,n);return r?.(),s}}}var Db=class{constructor(e,t={}){this.callbacks=e,this.refreshes=new Yc,this.connected=!1,this.onFocus=()=>{this.handleResumeSignal()},this.onVisibilityChange=()=>{this.isDocumentVisible()&&this.handleResumeSignal()},this.windowTarget=t.windowTarget??Ob(),this.documentTarget=t.documentTarget??kb(),this.isDocumentVisible=t.isDocumentVisible??Ab,this.scheduleFrame=t.scheduleFrame??jb}connect(){this.connected||(this.connected=!0,this.windowTarget?.addEventListener(`focus`,this.onFocus),this.documentTarget?.addEventListener(`visibilitychange`,this.onVisibilityChange))}disconnect(){this.connected&&(this.connected=!1,this.windowTarget?.removeEventListener(`focus`,this.onFocus),this.documentTarget?.removeEventListener(`visibilitychange`,this.onVisibilityChange),this.scheduledRefresh?.cancel(),this.scheduledRefresh=void 0)}handleResumeSignal(){this.callbacks.onResumeSignal(),this.scheduledRefresh===void 0&&(this.scheduledRefresh=this.scheduleFrame(()=>{this.scheduledRefresh=void 0,this.connected&&this.refreshes.request(`browser-resume`,async()=>{this.connected&&await this.callbacks.refreshAfterResume()}).catch(e=>{this.callbacks.onRefreshError(e)})}))}};function Ob(){return typeof window>`u`?void 0:window}function kb(){return typeof document>`u`?void 0:document}function Ab(){return typeof document>`u`||document.visibilityState===`visible`}function jb(e){if(typeof window<`u`&&typeof window.requestAnimationFrame==`function`){let t=window.requestAnimationFrame(()=>{e()});return{cancel:()=>{window.cancelAnimationFrame(t)}}}let t=globalThis.setTimeout(e,0);return{cancel:()=>{globalThis.clearTimeout(t)}}}var Mb=[`machines`,`projects`,`workspaces`,`sessions`];function Nb(e){return e.selectedWorkspace===void 0?e.selectedProject===void 0?`projects`:`workspaces`:`sessions`}function Pb(e,t){if(e!==`none`)return e??Nb(t)}function Fb(e,t){return Pb(t.expanded,t.state)!==e}function Ib(e,t,n){return Pb(e,n.state)===t?`none`:t}function Lb(e){return e.workspaceCount===1?`sessions`:`workspaces`}function Rb(e){return Mb[Mb.indexOf(e)+1]}var zb=class{hostConnected(){}constructor(e,t){this.host=e,this.getState=t,e.addController(this)}expandedSection(){return Pb(this.expanded,this.getState())}isCollapsed(e){return Fb(e,{expanded:this.expanded,state:this.getState()})}toggle(e){this.setExpanded(Ib(this.expanded,e,{state:this.getState()}))}expand(e){this.setExpanded(e)}advanceAfterSelection(e,t){let n=e===`projects`?Lb({workspaceCount:t?.workspaceCount}):Rb(e);n!==void 0&&this.expand(n)}open(e,t){this.expand(e),t()}setExpanded(e){this.expanded!==e&&(this.expanded=e,this.host.requestUpdate())}},Bb=class{hostConnected(){}constructor(e){this.host=e,this.navigationPanelCollapsed=!1,this.workspacePanelCollapsed=!1,e.addController(this)}toggleNavigationPanel(){this.navigationPanelCollapsed=!this.navigationPanelCollapsed,this.host.requestUpdate()}toggleWorkspacePanel(){this.workspacePanelCollapsed=!this.workspacePanelCollapsed,this.host.requestUpdate()}expandNavigationPanel(){this.navigationPanelCollapsed&&(this.navigationPanelCollapsed=!1,this.host.requestUpdate())}expandWorkspacePanel(){this.workspacePanelCollapsed&&(this.workspacePanelCollapsed=!1,this.host.requestUpdate())}shellClass(e,t=!0){return[`shell`,Hb(e),...this.navigationPanelCollapsed?[`navigation-panel-collapsed`]:[],...Vb(this.workspacePanelCollapsed,t)?[]:[`workspace-panel-collapsed`]].join(` `)}};function Vb(e,t){return!e&&t}function Hb(e){return e===`navigation`?`navigation-view`:e===`chat`?`chat-view`:`workspace-view`}var Ub=`pi-web:panel-sizes:v1`,Wb={navigation:{minWidth:180,maxWidth:4096,defaultWidth:340,keyboardStep:24,largeKeyboardStep:72},workspace:{minWidth:240,maxWidth:4096,defaultWidth:480,keyboardStep:24,largeKeyboardStep:72}},Gb=class{constructor(e,t={}){this.host=e,e.addController(this),this.storage=t.storage??ax(),this.panelSizes=Zb(this.storage)}hostConnected(){}constraints(e){return Kb(e)}panelWidth(e,t){return Xb(e,t??this.storedPanelWidth(e)??this.constraints(e).defaultWidth)}resizePanel(e,t,n={}){let r=Xb(e,t);this.storedPanelWidth(e)!==r&&(this.panelSizes=tx(this.panelSizes,e,r),n.persist!==!1&&this.persistPanelSizes(),this.host.requestUpdate())}resetPanel(e,t={}){this.storedPanelWidth(e)!==void 0&&(this.panelSizes=nx(this.panelSizes,e),t.persist!==!1&&this.persistPanelSizes(),this.host.requestUpdate())}resetPanels(e={}){this.panelSizes.navigationPanelWidth===void 0&&this.panelSizes.workspacePanelWidth===void 0||(this.panelSizes={},e.persist!==!1&&this.persistPanelSizes(),this.host.requestUpdate())}persistPanelSizes(){Qb(this.panelSizes,this.storage)}shellStyle(e={}){let t=[];return this.panelSizes.navigationPanelWidth!==void 0&&t.push(`--navigation-panel-size: ${ix(Xb(`navigation`,this.panelSizes.navigationPanelWidth,e.navigation))};`),this.panelSizes.workspacePanelWidth!==void 0&&t.push(`--workspace-panel-size: ${ix(Xb(`workspace`,this.panelSizes.workspacePanelWidth,e.workspace))};`),t.join(` `)}storedPanelWidth(e){return e===`navigation`?this.panelSizes.navigationPanelWidth:this.panelSizes.workspacePanelWidth}};function Kb(e){return Wb[e]}function qb(e,t,n){return e===`navigation`?n-t:t-n}function Jb(e,t,n,r,i=Kb(e)){return Xb(e,t+qb(e,n,r),i)}function Yb(e,t,n,r={}){let i=r.constraints??Kb(e);if(n===`Home`)return i.minWidth;if(n===`End`)return i.maxWidth;let a=rx(e,n,r.largeStep===!0?i.largeKeyboardStep:i.keyboardStep);if(a!==void 0)return Xb(e,t+a,i)}function Xb(e,t,n=Kb(e)){return Number.isFinite(t)?Math.round(Math.min(Math.max(t,n.minWidth),n.maxWidth)):n.defaultWidth}function Zb(e=ax()){try{let t=e?.getItem(Ub);return t==null||t===``?{}:$b(JSON.parse(t))}catch{return{}}}function Qb(e,t=ax()){if(t!==void 0)try{if(e.navigationPanelWidth===void 0&&e.workspacePanelWidth===void 0){t.removeItem(Ub);return}let n={version:1};e.navigationPanelWidth!==void 0&&(n.navigationPanelWidth=Xb(`navigation`,e.navigationPanelWidth)),e.workspacePanelWidth!==void 0&&(n.workspacePanelWidth=Xb(`workspace`,e.workspacePanelWidth)),t.setItem(Ub,JSON.stringify(n))}catch{}}function $b(e){if(!ox(e)||e.version!==1)return{};let t={},n=ex(e.navigationPanelWidth),r=ex(e.workspacePanelWidth);return n!==void 0&&(t.navigationPanelWidth=Xb(`navigation`,n)),r!==void 0&&(t.workspacePanelWidth=Xb(`workspace`,r)),t}function ex(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function tx(e,t,n){return t===`navigation`?{...e,navigationPanelWidth:n}:{...e,workspacePanelWidth:n}}function nx(e,t){return t===`navigation`?e.workspacePanelWidth===void 0?{}:{workspacePanelWidth:e.workspacePanelWidth}:e.navigationPanelWidth===void 0?{}:{navigationPanelWidth:e.navigationPanelWidth}}function rx(e,t,n){if(e===`navigation`)return t===`ArrowRight`?n:t===`ArrowLeft`?-n:void 0;if(t===`ArrowLeft`)return n;if(t===`ArrowRight`)return-n}function ix(e){return`${String(Math.round(e))}px`}function ax(){try{return typeof window>`u`?void 0:window.localStorage}catch{return}}function ox(e){return typeof e==`object`&&!!e}function sx(){let e=new URLSearchParams(window.location.search);return{machineId:dx(e.get(`machine`)),projectId:dx(e.get(`project`)),workspaceId:dx(e.get(`workspace`)),sessionId:dx(e.get(`session`)),tool:dx(e.get(`tool`)),view:dx(e.get(`view`))}}function cx(e,t){return{machineId:e.machineId,projectId:e.projectId,workspaceId:e.workspaceId,sessionId:e.sessionId,tool:e.tool===void 0?void 0:lx(e.tool,t),view:e.view===`chat`?`chat`:e.view===void 0?void 0:lx(e.view,t)}}function lx(e,t){return t(e)??(fx(e)?e:void 0)}function ux(e,t){let n=new URL(window.location.href);n.searchParams.delete(`machine`),n.searchParams.delete(`project`),n.searchParams.delete(`workspace`),n.searchParams.delete(`session`),n.searchParams.delete(`tool`),n.searchParams.delete(`view`),e.machineId!==void 0&&e.machineId!==``&&e.machineId!==`local`&&n.searchParams.set(`machine`,e.machineId),e.projectId!==void 0&&e.projectId!==``&&n.searchParams.set(`project`,e.projectId),e.workspaceId!==void 0&&e.workspaceId!==``&&n.searchParams.set(`workspace`,e.workspaceId),e.sessionId!==void 0&&e.sessionId!==``&&n.searchParams.set(`session`,e.sessionId),e.tool!==void 0&&e.tool!==``&&n.searchParams.set(`tool`,e.tool),e.view!==void 0&&e.view!==``&&n.searchParams.set(`view`,e.view),`${n.pathname}${n.search}${n.hash}`!=`${window.location.pathname}${window.location.search}${window.location.hash}`&&bt(String(n),t?.replace===!0)}function dx(e){return e===null||e===``?void 0:e}function fx(e){return/^[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$/u.test(e)}function px(){return hx(new URLSearchParams(window.location.search).get(`settings`))}function mx(e,t){let n=new URL(window.location.href);e===void 0?n.searchParams.delete(`settings`):n.searchParams.set(`settings`,e),`${n.pathname}${n.search}${n.hash}`!=`${window.location.pathname}${window.location.search}${window.location.hash}`&&bt(String(n),t?.replace===!0)}function hx(e){if(e===`general`)return`general`;if(e===`appearance`||e===`theme`||e===`themes`)return`appearance`;if(e===`sessiond`||e===`sessions`)return`sessiond`;if(e===`machines`)return`machines`;if(e===`packages`||e===`pi-packages`)return`packages`;if(e===`plugins`)return`plugins`;if(e===`shortcuts`||e===`keyboard`||e===`keyboard-shortcuts`)return`shortcuts`}function gx(e,t){return t===void 0?e:e.map(e=>vx(e,t))}function _x(e,t){let n=new Set(wm(e,t,{enabledOnly:!0}).filter(e=>e.active).map(e=>e.action.id));return gx(e,t).map(e=>e.shortcut!==void 0&&!n.has(e.id)?yx(e):e)}function vx(e,t){let n=jm(e,t);return n===void 0?e:n===null?yx(e):{...e,shortcut:n}}function yx(e){let t={...e};return delete t.shortcut,t}function bx(e,t){let n=t.api??cs,r=t.pollIntervalMs??1e3,i=t.setTimeout??Cx(),a=t.clearTimeout??wx();return{async runCommand(o){let s=await n.runTerminalCommand(e,o);return o.open===!0&&t.openTerminal(o.workspace,{terminalId:s.terminalId}),{run:s,completed:xx(s,n,r,i,a)}},listCommandRuns:e=>n.listCommandRuns(e),getCommandRun:e=>n.getCommandRun(e),open:e=>{t.openTerminal(void 0,e)}}}function xx(e,t,n,r,i){return Sx(e)?Promise.resolve(e):new Promise((a,o)=>{let s,c=!1,l=e=>{c||(c=!0,s!==void 0&&i(s),a(e))},u=e=>{c||(c=!0,s!==void 0&&i(s),o(e instanceof Error?e:Error(String(e))))},d=()=>{t.getCommandRun(e.id).then(e=>{if(e!==void 0&&Sx(e)){l(e);return}s=r(d,n)}).catch(u)};s=r(d,n)})}function Sx(e){return e.status===`succeeded`||e.status===`failed`}function Cx(){return(e,t)=>globalThis.setTimeout(e,t)}function wx(){return e=>{globalThis.clearTimeout(e)}}var Tx=class{constructor(e){this.callbacks=e,this.fired=!1}start(e){this.cancel(),this.origin=e,this.fired=!1,this.handle=this.callbacks.setTimer(()=>{this.handle=void 0,this.fired=!0,this.callbacks.onLongPress()},500)}move(e){if(this.origin===void 0)return;let t=Math.abs(e.clientX-this.origin.clientX),n=Math.abs(e.clientY-this.origin.clientY);(t>10||n>10)&&this.cancel()}cancel(){this.handle!==void 0&&this.callbacks.clearTimer(this.handle),this.handle=void 0,this.origin=void 0}consumeSuppressedClick(){let e=this.fired;return this.fired=!1,e}},Ex=class{constructor(e){this.open=e,this.longPress=new Tx({onLongPress:()=>{this.heldId!==void 0&&this.open(this.heldId,this.heldAnchor??null)},setTimer:(e,t)=>window.setTimeout(e,t),clearTimer:e=>{window.clearTimeout(e)}})}pointerDown(e,t){t.pointerType!==`mouse`&&(this.heldId=e,this.heldAnchor=t.currentTarget,this.longPress.start(t))}pointerMove(e){this.longPress.move(e)}cancel(){this.longPress.cancel(),this.heldId=void 0,this.heldAnchor=void 0}consumeSuppressedClick(){return this.longPress.consumeSuppressedClick()}contextMenu(e,t){t.preventDefault(),this.open(e,t.currentTarget)}};function Dx(e){return`${e.label}\n${e.path}`}function Ox(e,t){return sf(e,t,Dx)}function kx(e,t){return sf(e,t,e=>e.name)}function Ax(e,t){return e>=8||af(t).length>0}var jx=0,Mx=120;function Nx(e,t={}){if(typeof HTMLElement>`u`||typeof window>`u`||!(e instanceof HTMLElement))return``;let n=e.getBoundingClientRect(),r=t.constrainTo===`viewport`?Fx():Px(e),i=window.innerWidth,a=window.innerHeight,o=Math.max(0,r.left),s=Math.min(i,r.right),c=Math.max(0,r.top),l=Math.min(a,r.bottom),u=Math.min(n.right,s),d=l-n.bottom-jx,f=n.top-c-jx;return[...d<Mx&&f>d?[`bottom: ${Ix(a-n.top+jx)};`,`max-height: ${Ix(Math.max(0,f))};`]:[`top: ${Ix(n.bottom+jx)};`,`max-height: ${Ix(Math.max(0,d))};`],`right: ${Ix(Math.max(0,i-u))};`,`max-width: ${Ix(Math.max(0,u-o))};`].join(` `)}function Px(e){let t=e.getRootNode();return typeof ShadowRoot<`u`&&t instanceof ShadowRoot&&t.host instanceof HTMLElement?t.host.getBoundingClientRect():Fx()}function Fx(){return{top:0,right:window.innerWidth,bottom:window.innerHeight,left:0}}function Ix(e){return`${String(Math.round(e))}px`}function Lx(e,t=`Active`,n){if(e===void 0)return n===void 0?void 0:g`<span class="activity-indicator unread" role="img" aria-label=${n} title=${n}></span>`;if(n===void 0)return g`<span class=${`activity-indicator ${e}`} role="img" aria-label=${t} title=${t}></span>`;let r=`${n} · ${t}`;return g`<span class="unread-ring" role="img" aria-label=${r} title=${r}><span class=${`activity-indicator ${e}`} aria-hidden="true"></span></span>`}function Rx(e){if(e!==void 0)return e[fn.working]===!0?`session`:e[fn.terminal]===!0?`terminal`:Object.entries(e).some(([e,t])=>t&&e!==fn.unread)?`session`:void 0}function zx(e){return e?.[fn.unread]===!0}var Bx={working:`Session is working`,background:`Turn ended; background work still running`,idle:`Session is done`,asking:`Waiting for your answer`,error:`Session hit an error`};function Vx(e,t){if(e===void 0)return t===void 0?void 0:g`<span class="session-state unread" role="img" aria-label=${t} title=${t}></span>`;let n=e===`sending`?`Sending message`:Bx[e],r=t===void 0?n:`${t} · ${n}`;if(e===`idle`)return g`<span class=${t===void 0?`session-state idle`:`session-state idle unread`} role="img" aria-label=${r} title=${r}></span>`;if(e===`working`||e===`sending`){let i=e===`working`?[0,1,2].map(e=>g`<span class="state-dot working-dot" style=${`animation-delay:${(e*.14).toFixed(2)}s`}></span>`):null;return t===void 0?g`<span class="session-state working" role="img" aria-label=${n} title=${n}><span class="state-dots">${i}</span></span>`:g`<span class="unread-ring" role="img" aria-label=${r} title=${r}><span class="session-state working" aria-hidden="true"><span class="state-dots">${i}</span></span></span>`}return t===void 0?g`<span class=${`session-state ${e}`} role="img" aria-label=${n} title=${n}></span>`:g`<span class="unread-ring" role="img" aria-label=${r} title=${r}><span class=${`session-state ${e}`} aria-hidden="true"></span></span>`}function Hx(e,t=`Active`,n){let r=Lx(e,t,n);if(r!==void 0)return g`<span class="action-activity">${r}</span>`}var Ux=[`a[href]`,`button`,`input`,`select`,`textarea`,`summary`,`[role='button']`,`[role='link']`,`[contenteditable='true']`].join(`,`);function Wx(e){return e.composedPath().some(e=>Gx(e,Ux))}function Gx(e,t){if(typeof Element<`u`&&e instanceof Element)return e.matches(t);if(!(`matches`in e))return!1;let{matches:n}=e;return typeof n==`function`&&n.call(e,t)===!0}function Kx(e,t){return Wx(e)?!1:e.key===`Enter`||e.key===` `?(e.preventDefault(),t.activate(),!0):e.key===`ArrowUp`?Jx(e,()=>{Yx(e.currentTarget,-1)}):e.key===`ArrowDown`?Jx(e,()=>{Yx(e.currentTarget,1)}):e.key===`Home`?Jx(e,()=>{Xx(e.currentTarget,0)}):e.key===`End`?Jx(e,()=>{Xx(e.currentTarget,-1)}):e.key===`ArrowLeft`&&t.previousSection!==void 0?Jx(e,t.previousSection):e.key===`ArrowRight`&&t.nextSection!==void 0?Jx(e,t.nextSection):e.key===`Escape`&&t.cancel!==void 0&&Jx(e,t.cancel)}function qx(e,t={}){let n=e.querySelector(`.action-row.selected`)??e.querySelector(`.action-row`)??(t.fallbackSelector===void 0?void 0:e.querySelector(t.fallbackSelector));return n==null?!1:(n.focus(),n.scrollIntoView({block:`nearest`}),!0)}function Jx(e,t){return e.preventDefault(),e.stopPropagation?.(),t(),!0}function Yx(e,t){let n=Qx(e),r=eS(e);if(r===void 0||n.length===0)return;let i=n.indexOf(r);i<0||Zx(n,i+t)}function Xx(e,t){let n=Qx(e);n.length!==0&&Zx(n,t<0?n.length-1:t)}function Zx(e,t){let n=e[Math.min(Math.max(t,0),e.length-1)];n?.focus(),n?.scrollIntoView({block:`nearest`})}function Qx(e){let t=eS(e)?.getRootNode();return t===void 0||!$x(t)?[]:Array.from(t.querySelectorAll(`.action-row`))}function $x(e){return typeof Document<`u`&&e instanceof Document||typeof DocumentFragment<`u`&&e instanceof DocumentFragment}function eS(e){if(!(typeof HTMLElement>`u`||!(e instanceof HTMLElement)))return e.closest(`.action-row`)??void 0}var U=class extends v{constructor(...e){super(...e),this.machines=[],this.searchQuery=``,this.statuses={},this.statusSnapshots={},this.collapsible=!1,this.collapsed=!1,this.gestures=new Ex((e,t)=>{this.openMenu(e,t)}),this.menuStyle=``,this.onDocumentClick=e=>{e.composedPath().includes(this)||(this.openMenuMachineId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this.onDocumentClick)}disconnectedCallback(){document.removeEventListener(`click`,this.onDocumentClick),super.disconnectedCallback()}updated(e){e.has(`machines`)&&this.openMenuMachineId!==void 0&&!this.machines.some(e=>e.id===this.openMenuMachineId)&&(this.openMenuMachineId=void 0),e.has(`collapsed`)&&this.collapsed&&(this.openMenuMachineId=void 0)}async focusSelectedOrFirst(){return await this.updateComplete,qx(this.renderRoot,{fallbackSelector:`.section-toggle`})}renderSearch(){if(!Ax(this.machines.length,this.searchQuery))return null;let e=this.searchQuery!==``;return g`
|
|
1397
1401
|
<div class="list-search">
|
|
1398
1402
|
<input
|
|
1399
1403
|
class="list-search-input"
|
|
@@ -2299,9 +2303,9 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2299
2303
|
.custom-focus, .validation-error { margin-inline-start: 0; }
|
|
2300
2304
|
footer { flex-wrap: wrap; }
|
|
2301
2305
|
}
|
|
2302
|
-
`}};H([b({attribute:!1})],mC.prototype,`tree`,void 0),H([b({attribute:!1})],mC.prototype,`onNavigate`,void 0),H([b({attribute:!1})],mC.prototype,`onFork`,void 0),H([b({attribute:!1})],mC.prototype,`onAbort`,void 0),H([b({attribute:!1})],mC.prototype,`onCancel`,void 0),H([x()],mC.prototype,`selectedId`,void 0),H([x()],mC.prototype,`foldedIds`,void 0),H([x()],mC.prototype,`step`,void 0),H([x()],mC.prototype,`operation`,void 0),H([x()],mC.prototype,`summaryMode`,void 0),H([x()],mC.prototype,`customInstructions`,void 0),H([x()],mC.prototype,`busy`,void 0),H([x()],mC.prototype,`aborting`,void 0),H([x()],mC.prototype,`error`,void 0),H([x()],mC.prototype,`statusMessage`,void 0),mC=H([y(`session-tree-navigator`)],mC);function hC(e){return Math.min(Math.max(0,e),fC)}function gC(e){return e===`user`||e===`custom-message`}function _C(e){return pC[e]}function vC(e){return e instanceof Error?e.message:String(e)}function yC(e){return e.wasWorking&&!e.working}var bC=`pi-web:chat-scroll:`,xC=180,SC=48,CC=2,wC={getItem(e){return typeof localStorage>`u`?null:localStorage.getItem(e)},setItem(e,t){typeof localStorage>`u`||localStorage.setItem(e,t)},removeItem(e){typeof localStorage>`u`||localStorage.removeItem(e)}},TC={setTimeout(e,t){return window.setTimeout(e,t)},clearTimeout(e){window.clearTimeout(e)}},EC=class{constructor(e=wC,t=TC){this.storage=e,this.scheduler=t}dispose(){this.clearScheduledSave()}clearScheduledSave(){this.saveTimer!==void 0&&(this.scheduler.clearTimeout(this.saveTimer),this.saveTimer=void 0)}scheduleSave(e,t,n=xC){this.clearScheduledSave(),this.saveTimer=this.scheduler.setTimeout(()=>{this.saveTimer=void 0,t(e)},n)}savePosition(e,t,n,r=CC){if(e===``||t===void 0||!kC(t))return`skipped`;try{if(jC(t,r))return this.storage.setItem(DC(e),JSON.stringify({mode:`bottom`})),`saved`;let i=NC(t,n);if(i===void 0)return`skipped`;let a=MC(t,i);return this.storage.setItem(DC(e),JSON.stringify(a)),`saved`}catch{return`skipped`}}restorePosition(e,t,n,r){let i=this.readPosition(e);return i===void 0?this.scrollToBottom(t):this.restoreExplicitPosition(i,t,n,r)}restoreExplicitPosition(e,t,n,r){if(e.mode===`bottom`)return this.scrollToBottom(t);if(t===void 0||!kC(t))return{status:`skipped`};let i=FC(n,e.anchorId);if(i===void 0)return r?.fallbackToBottom===!1?{status:`missing`,position:e}:this.scrollToBottom(t);let a=t.getBoundingClientRect().top,o=i.getBoundingClientRect().top-a;return t.scrollTop+=o-e.offset,{status:`restored`}}readPosition(e){if(e!==``)try{let t=this.storage.getItem(DC(e));if(t===null||t===``)return;let n=JSON.parse(t);return OC(n)?n:void 0}catch{return}}scrollToBottom(e){return e===void 0||!kC(e)?{status:`skipped`}:(e.scrollTop=e.scrollHeight,{status:`bottom`})}};function DC(e){return`${bC}${e}`}function OC(e){return typeof e!=`object`||!e||!(`mode`in e)?!1:e.mode===`bottom`||e.mode===`anchor`&&`anchorId`in e&&typeof e.anchorId==`string`&&e.anchorId!==``&&`offset`in e&&typeof e.offset==`number`}function kC(e){return e.clientHeight>0&&e.scrollHeight>0}function AC(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function jC(e,t=SC){return AC(e)<t}function MC(e,t){let n=e.getBoundingClientRect().top;return{mode:`anchor`,anchorId:IC(t)??``,offset:t.getBoundingClientRect().top-n}}function NC(e,t){let n=e.getBoundingClientRect(),r,i=-1/0,a,o=1/0;for(let e of t){if(IC(e)===void 0)continue;let t=e.getBoundingClientRect();if(t.bottom<=t.top||t.bottom<n.top||t.top>n.bottom)continue;let s=t.top-n.top;s<=0&&s>=i?(r=e,i=s):s>0&&s<o&&(a=e,o=s)}return r??a}function PC(e,t){let n=e.getBoundingClientRect();return t.find(e=>{let t=e.getBoundingClientRect();return t.bottom>=n.top&&t.top<=n.bottom})}function FC(e,t){return e.find(e=>IC(e)===t)}function IC(e){return e.dataset.scrollAnchorId!==void 0&&e.dataset.scrollAnchorId!==``?e.dataset.scrollAnchorId:void 0}function LC(e){return AC(e)>=e.clientHeight*1}var{I:RC}=ut,zC=e=>e,BC=()=>document.createComment(``),VC=(e,t,n)=>{let r=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0)n=new RC(r.insertBefore(BC(),i),r.insertBefore(BC(),i),e,e.options);else{let t=n._$AB.nextSibling,a=n._$AM,o=a!==e;if(o){let t;n._$AQ?.(e),n._$AM=e,n._$AP!==void 0&&(t=e._$AU)!==a._$AU&&n._$AP(t)}if(t!==i||o){let e=n._$AA;for(;e!==t;){let t=zC(e).nextSibling;zC(r).insertBefore(e,i),e=t}}}return n},HC=(e,t,n=e)=>(e._$AI(t,n),e),UC={},WC=(e,t=UC)=>e._$AH=t,GC=e=>e._$AH,KC=e=>{e._$AR(),e._$AA.remove()},qC=(e,t,n)=>{let r=new Map;for(let i=t;i<=n;i++)r.set(e[i],i);return r},JC=t_(class extends n_{constructor(e){if(super(e),e.type!==e_.CHILD)throw Error(`repeat() can only be used in text expressions`)}dt(e,t,n){let r;n===void 0?n=t:t!==void 0&&(r=t);let i=[],a=[],o=0;for(let t of e)i[o]=r?r(t,o):o,a[o]=n(t,o),o++;return{values:a,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,r]){let i=GC(e),{values:a,keys:o}=this.dt(t,n,r);if(!Array.isArray(i))return this.ut=o,a;let s=this.ut??=[],c=[],l,u,d=0,f=i.length-1,p=0,m=a.length-1;for(;d<=f&&p<=m;)if(i[d]===null)d++;else if(i[f]===null)f--;else if(s[d]===o[p])c[p]=HC(i[d],a[p]),d++,p++;else if(s[f]===o[m])c[m]=HC(i[f],a[m]),f--,m--;else if(s[d]===o[m])c[m]=HC(i[d],a[m]),VC(e,c[m+1],i[d]),d++,m--;else if(s[f]===o[p])c[p]=HC(i[f],a[p]),VC(e,i[d],i[f]),f--,p++;else if(l===void 0&&(l=qC(o,p,m),u=qC(s,d,f)),l.has(s[d]))if(l.has(s[f])){let t=u.get(o[p]),n=t===void 0?null:i[t];if(n===null){let t=VC(e,i[d]);HC(t,a[p]),c[p]=t}else c[p]=HC(n,a[p]),VC(e,i[d],n),i[t]=null;p++}else KC(i[f]),f--;else KC(i[d]),d++;for(;p<=m;){let t=VC(e,c[m+1]);HC(t,a[p]),c[p++]=t}for(;d<=f;){let e=i[d++];e!==null&&KC(e)}return this.ut=o,WC(e,c),Xe}}),YC=`pi-web:chat-groups:`,XC={read(e){try{if(typeof localStorage>`u`)return;let t=localStorage.getItem(QC(e));return t===null||t===``?void 0:$C(JSON.parse(t))}catch{return}},write(e,t){try{if(typeof localStorage>`u`)return;localStorage.setItem(QC(e),JSON.stringify(t))}catch{}}},ZC=class{constructor(e=XC){this.storage=e,this.sessionId=``,this.openGroupKeys=new Set,this.closedDefaultOpenGroupKeys=new Set}syncSession(e){if(this.sessionId===e)return;this.sessionId=e;let t=e===``?void 0:this.storage.read(e);this.openGroupKeys=new Set(t?.open??[]),this.closedDefaultOpenGroupKeys=new Set(t?.closedDefaultOpen??[])}isOpen(e,t){return t?!this.closedDefaultOpenGroupKeys.has(e):this.openGroupKeys.has(e)}applyToggle(e,t,n){let r=this.isOpen(e,n),i=new Set(this.openGroupKeys),a=new Set(this.closedDefaultOpenGroupKeys);return n?(i.delete(e),t?a.delete(e):a.add(e)):(a.delete(e),t?i.add(e):i.delete(e)),(n?!a.has(e):i.has(e))===r&&tw(i,this.openGroupKeys)&&tw(a,this.closedDefaultOpenGroupKeys)?!1:(this.openGroupKeys=i,this.closedDefaultOpenGroupKeys=a,this.persist(),!0)}snapshot(){return{open:[...this.openGroupKeys],closedDefaultOpen:[...this.closedDefaultOpenGroupKeys]}}persist(){this.sessionId!==``&&this.storage.write(this.sessionId,this.snapshot())}};function QC(e){return`${YC}${e}`}function $C(e){if(Array.isArray(e))return{open:ew(e),closedDefaultOpen:[]};if(nw(e))return{open:Array.isArray(e.open)?ew(e.open):[],closedDefaultOpen:Array.isArray(e.closedDefaultOpen)?ew(e.closedDefaultOpen):[]}}function ew(e){return e.filter(e=>typeof e==`string`)}function tw(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function nw(e){return typeof e==`object`&&!!e}function rw(e,t=0){let n=[],r=[],i=0,a=(e,t)=>{r.length||(i=t),r.push(e)},o=()=>{r.length&&(n.push({kind:`group`,messages:r,startIndex:i,endIndex:i+r.length-1}),r=[])};return e.forEach((e,r)=>{let i=e.parts.filter(t=>sw(e,t)),s=e.parts.filter(t=>!sw(e,t)),c=t+r,l={...e.source===void 0?{}:{source:e.source},...e.meta===void 0?{}:{meta:e.meta}};if(s.length&&a({role:e.role,parts:s,...l},c),i.length){o();let t={role:i.every(e=>e.type===`skillRead`)?`skill`:e.role,parts:i,...l};if(aw(t)){let e=ow(s);n.push({kind:`tool-image`,message:t,index:c,...e===void 0?{}:{toolName:e}})}else n.push({kind:`message`,message:t,index:c})}}),o(),n}function iw(e){if(e.every(e=>e.source===`compaction`))return`${String(e.length)} history compaction ${e.length===1?`summary`:`summaries`}`;if(e.every(e=>e.source===`branch_summary`))return`${String(e.length)} branch ${e.length===1?`summary`:`summaries`}`;let t=e.reduce((e,t)=>(e[t.role]=(e[t.role]??0)+1,e),{}),n=Object.entries(t).map(([e,t])=>`${String(t)} ${e}`).join(` · `);return`${String(e.length)} ${e.length===1?`event`:`events`}${n===``?``:` · ${n}`}`}function aw(e){return e.role===`tool`&&e.parts.length>0&&e.parts.every(e=>e.type===`image`)}function ow(e){for(let t of e)if((t.type===`toolCall`||t.type===`toolExecution`||t.type===`toolResult`)&&t.toolName!==``)return t.toolName}function sw(e,t){return e.source===`compaction`||e.source===`branch_summary`?!1:t.type===`skillInvocation`||t.type===`skillRead`||t.type===`image`||t.type===`askUserRecord`||t.type===`text`&&(e.role===`user`||e.role===`assistant`||e.role===`system`||e.role===`bash`)}function cw(e,t,n){let r=e.length;if(r===0||t.length===0||n.length!==r+1||n[r-1]!==e[r-1])return;let i=n[r],a=e[r-1];if(i===void 0||a===void 0)return;let o=t.at(-1);if(o===void 0)return;let s=t.slice(0,-1),c,l;o.kind===`group`?(c=o.startIndex,l=[...o.messages,i]):(c=o.index,l=[a,i]);let u=rw(l,c);return[...s,...u]}function lw(e,t){let n=dw(mw(e,t)),r={distanceFromBottom:e.scrollHeight-e.scrollTop};return n===void 0?r:{...r,markerId:n.id,markerOffset:n.offset}}function uw(e,t,n){if(n!==void 0&&t.markerOffset!==void 0){let r=n.getBoundingClientRect().top-e.getBoundingClientRect().top;e.scrollTop+=fw(r,t.markerOffset);return}e.scrollTop=pw(e.scrollHeight,t.distanceFromBottom)}function dw(e){let t,n=-1/0,r,i=1/0;for(let a of e)a.offset<=0&&a.offset>=n?(t=a,n=a.offset):a.offset>0&&a.offset<i&&(r=a,i=a.offset);return t??r}function fw(e,t){return e-t}function pw(e,t){return Math.max(0,e-t)}function mw(e,t){let n=e.getBoundingClientRect().top;return t.flatMap(e=>{let t=e.dataset.markerId;return t===void 0?[]:[{id:t,offset:e.getBoundingClientRect().top-n}]})}var hw=600,gw=1;function _w(e){return!e.hasMore||e.loadingMore||!e.canRequest||e.clientHeight<=0?!1:vw(e)||yw(e)}function vw(e){return e.scrollTop<(e.topThreshold??Math.max(hw,e.clientHeight))}function yw(e){return e.scrollHeight<=e.clientHeight+gw}var bw={left:!1,right:!1},xw=1;function Sw(e){if(e===void 0)return bw;let t=Math.max(0,e.scrollWidth-e.clientWidth);return{left:e.scrollLeft>xw,right:t-e.scrollLeft>xw}}function Cw(e){return`${e.left?` can-scroll-left`:``}${e.right?` can-scroll-right`:``}`}var ww=e=>{if(!(typeof ResizeObserver>`u`))return new ResizeObserver(()=>{e()})},Tw=class{constructor(e,t=ww){this.onChange=e,this.createObserver=t,this.current=bw}get edges(){return this.current}observe(e){if(this.element!==e&&(this.observer?.disconnect(),this.observer=void 0,this.element=e,e!==void 0)){let t=this.createObserver(()=>{this.refresh()});t!==void 0&&(t.observe(e),this.observer=t)}this.refresh()}refresh(){let e=Sw(this.element);e.left===this.current.left&&e.right===this.current.right||(this.current=e,this.onChange())}dispose(){this.observer?.disconnect(),this.observer=void 0,this.element=void 0,this.current=bw}};function Ew(e){return e.role===`user`&&Dw(e)!==void 0}function Dw(e){if(e.role!==`user`)return;let t=[],n=[];for(let r of e.parts){if(Ow(r)){r.text!==``&&t.push(r.text);continue}r.type===`image`&&r.data!==``&&r.mimeType!==``&&n.push({kind:`image`,mimeType:r.mimeType,data:r.data})}let r=t.join(`
|
|
2306
|
+
`}};H([b({attribute:!1})],mC.prototype,`tree`,void 0),H([b({attribute:!1})],mC.prototype,`onNavigate`,void 0),H([b({attribute:!1})],mC.prototype,`onFork`,void 0),H([b({attribute:!1})],mC.prototype,`onAbort`,void 0),H([b({attribute:!1})],mC.prototype,`onCancel`,void 0),H([x()],mC.prototype,`selectedId`,void 0),H([x()],mC.prototype,`foldedIds`,void 0),H([x()],mC.prototype,`step`,void 0),H([x()],mC.prototype,`operation`,void 0),H([x()],mC.prototype,`summaryMode`,void 0),H([x()],mC.prototype,`customInstructions`,void 0),H([x()],mC.prototype,`busy`,void 0),H([x()],mC.prototype,`aborting`,void 0),H([x()],mC.prototype,`error`,void 0),H([x()],mC.prototype,`statusMessage`,void 0),mC=H([y(`session-tree-navigator`)],mC);function hC(e){return Math.min(Math.max(0,e),fC)}function gC(e){return e===`user`||e===`custom-message`}function _C(e){return pC[e]}function vC(e){return e instanceof Error?e.message:String(e)}function yC(e){return e===void 0?0:Math.max(0,e.offsetWidth-e.clientWidth)}function bC(e){return e.wasWorking&&!e.working}var xC=`pi-web:chat-scroll:`,SC=180,CC=48,wC=2,TC={getItem(e){return typeof localStorage>`u`?null:localStorage.getItem(e)},setItem(e,t){typeof localStorage>`u`||localStorage.setItem(e,t)},removeItem(e){typeof localStorage>`u`||localStorage.removeItem(e)}},EC={setTimeout(e,t){return window.setTimeout(e,t)},clearTimeout(e){window.clearTimeout(e)}},DC=class{constructor(e=TC,t=EC){this.storage=e,this.scheduler=t}dispose(){this.clearScheduledSave()}clearScheduledSave(){this.saveTimer!==void 0&&(this.scheduler.clearTimeout(this.saveTimer),this.saveTimer=void 0)}scheduleSave(e,t,n=SC){this.clearScheduledSave(),this.saveTimer=this.scheduler.setTimeout(()=>{this.saveTimer=void 0,t(e)},n)}savePosition(e,t,n,r=wC){if(e===``||t===void 0||!AC(t))return`skipped`;try{if(MC(t,r))return this.storage.setItem(OC(e),JSON.stringify({mode:`bottom`})),`saved`;let i=PC(t,n);if(i===void 0)return`skipped`;let a=NC(t,i);return this.storage.setItem(OC(e),JSON.stringify(a)),`saved`}catch{return`skipped`}}restorePosition(e,t,n,r){let i=this.readPosition(e);return i===void 0?this.scrollToBottom(t):this.restoreExplicitPosition(i,t,n,r)}restoreExplicitPosition(e,t,n,r){if(e.mode===`bottom`)return this.scrollToBottom(t);if(t===void 0||!AC(t))return{status:`skipped`};let i=IC(n,e.anchorId);if(i===void 0)return r?.fallbackToBottom===!1?{status:`missing`,position:e}:this.scrollToBottom(t);let a=t.getBoundingClientRect().top,o=i.getBoundingClientRect().top-a;return t.scrollTop+=o-e.offset,{status:`restored`}}readPosition(e){if(e!==``)try{let t=this.storage.getItem(OC(e));if(t===null||t===``)return;let n=JSON.parse(t);return kC(n)?n:void 0}catch{return}}scrollToBottom(e){return e===void 0||!AC(e)?{status:`skipped`}:(e.scrollTop=e.scrollHeight,{status:`bottom`})}};function OC(e){return`${xC}${e}`}function kC(e){return typeof e!=`object`||!e||!(`mode`in e)?!1:e.mode===`bottom`||e.mode===`anchor`&&`anchorId`in e&&typeof e.anchorId==`string`&&e.anchorId!==``&&`offset`in e&&typeof e.offset==`number`}function AC(e){return e.clientHeight>0&&e.scrollHeight>0}function jC(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function MC(e,t=CC){return jC(e)<t}function NC(e,t){let n=e.getBoundingClientRect().top;return{mode:`anchor`,anchorId:LC(t)??``,offset:t.getBoundingClientRect().top-n}}function PC(e,t){let n=e.getBoundingClientRect(),r,i=-1/0,a,o=1/0;for(let e of t){if(LC(e)===void 0)continue;let t=e.getBoundingClientRect();if(t.bottom<=t.top||t.bottom<n.top||t.top>n.bottom)continue;let s=t.top-n.top;s<=0&&s>=i?(r=e,i=s):s>0&&s<o&&(a=e,o=s)}return r??a}function FC(e,t){let n=e.getBoundingClientRect();return t.find(e=>{let t=e.getBoundingClientRect();return t.bottom>=n.top&&t.top<=n.bottom})}function IC(e,t){return e.find(e=>LC(e)===t)}function LC(e){return e.dataset.scrollAnchorId!==void 0&&e.dataset.scrollAnchorId!==``?e.dataset.scrollAnchorId:void 0}function RC(e){return jC(e)>=e.clientHeight*1}var{I:zC}=ut,BC=e=>e,VC=()=>document.createComment(``),HC=(e,t,n)=>{let r=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0)n=new zC(r.insertBefore(VC(),i),r.insertBefore(VC(),i),e,e.options);else{let t=n._$AB.nextSibling,a=n._$AM,o=a!==e;if(o){let t;n._$AQ?.(e),n._$AM=e,n._$AP!==void 0&&(t=e._$AU)!==a._$AU&&n._$AP(t)}if(t!==i||o){let e=n._$AA;for(;e!==t;){let t=BC(e).nextSibling;BC(r).insertBefore(e,i),e=t}}}return n},UC=(e,t,n=e)=>(e._$AI(t,n),e),WC={},GC=(e,t=WC)=>e._$AH=t,KC=e=>e._$AH,qC=e=>{e._$AR(),e._$AA.remove()},JC=(e,t,n)=>{let r=new Map;for(let i=t;i<=n;i++)r.set(e[i],i);return r},YC=t_(class extends n_{constructor(e){if(super(e),e.type!==e_.CHILD)throw Error(`repeat() can only be used in text expressions`)}dt(e,t,n){let r;n===void 0?n=t:t!==void 0&&(r=t);let i=[],a=[],o=0;for(let t of e)i[o]=r?r(t,o):o,a[o]=n(t,o),o++;return{values:a,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,r]){let i=KC(e),{values:a,keys:o}=this.dt(t,n,r);if(!Array.isArray(i))return this.ut=o,a;let s=this.ut??=[],c=[],l,u,d=0,f=i.length-1,p=0,m=a.length-1;for(;d<=f&&p<=m;)if(i[d]===null)d++;else if(i[f]===null)f--;else if(s[d]===o[p])c[p]=UC(i[d],a[p]),d++,p++;else if(s[f]===o[m])c[m]=UC(i[f],a[m]),f--,m--;else if(s[d]===o[m])c[m]=UC(i[d],a[m]),HC(e,c[m+1],i[d]),d++,m--;else if(s[f]===o[p])c[p]=UC(i[f],a[p]),HC(e,i[d],i[f]),f--,p++;else if(l===void 0&&(l=JC(o,p,m),u=JC(s,d,f)),l.has(s[d]))if(l.has(s[f])){let t=u.get(o[p]),n=t===void 0?null:i[t];if(n===null){let t=HC(e,i[d]);UC(t,a[p]),c[p]=t}else c[p]=UC(n,a[p]),HC(e,i[d],n),i[t]=null;p++}else qC(i[f]),f--;else qC(i[d]),d++;for(;p<=m;){let t=HC(e,c[m+1]);UC(t,a[p]),c[p++]=t}for(;d<=f;){let e=i[d++];e!==null&&qC(e)}return this.ut=o,GC(e,c),Xe}}),XC=`pi-web:chat-groups:`,ZC={read(e){try{if(typeof localStorage>`u`)return;let t=localStorage.getItem($C(e));return t===null||t===``?void 0:ew(JSON.parse(t))}catch{return}},write(e,t){try{if(typeof localStorage>`u`)return;localStorage.setItem($C(e),JSON.stringify(t))}catch{}}},QC=class{constructor(e=ZC){this.storage=e,this.sessionId=``,this.openGroupKeys=new Set,this.closedDefaultOpenGroupKeys=new Set}syncSession(e){if(this.sessionId===e)return;this.sessionId=e;let t=e===``?void 0:this.storage.read(e);this.openGroupKeys=new Set(t?.open??[]),this.closedDefaultOpenGroupKeys=new Set(t?.closedDefaultOpen??[])}isOpen(e,t){return t?!this.closedDefaultOpenGroupKeys.has(e):this.openGroupKeys.has(e)}applyToggle(e,t,n){let r=this.isOpen(e,n),i=new Set(this.openGroupKeys),a=new Set(this.closedDefaultOpenGroupKeys);return n?(i.delete(e),t?a.delete(e):a.add(e)):(a.delete(e),t?i.add(e):i.delete(e)),(n?!a.has(e):i.has(e))===r&&nw(i,this.openGroupKeys)&&nw(a,this.closedDefaultOpenGroupKeys)?!1:(this.openGroupKeys=i,this.closedDefaultOpenGroupKeys=a,this.persist(),!0)}snapshot(){return{open:[...this.openGroupKeys],closedDefaultOpen:[...this.closedDefaultOpenGroupKeys]}}persist(){this.sessionId!==``&&this.storage.write(this.sessionId,this.snapshot())}};function $C(e){return`${XC}${e}`}function ew(e){if(Array.isArray(e))return{open:tw(e),closedDefaultOpen:[]};if(rw(e))return{open:Array.isArray(e.open)?tw(e.open):[],closedDefaultOpen:Array.isArray(e.closedDefaultOpen)?tw(e.closedDefaultOpen):[]}}function tw(e){return e.filter(e=>typeof e==`string`)}function nw(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function rw(e){return typeof e==`object`&&!!e}function iw(e,t=0){let n=[],r=[],i=0,a=(e,t)=>{r.length||(i=t),r.push(e)},o=()=>{r.length&&(n.push({kind:`group`,messages:r,startIndex:i,endIndex:i+r.length-1}),r=[])};return e.forEach((e,r)=>{let i=e.parts.filter(t=>cw(e,t)),s=e.parts.filter(t=>!cw(e,t)),c=t+r,l={...e.source===void 0?{}:{source:e.source},...e.meta===void 0?{}:{meta:e.meta}};if(s.length&&a({role:e.role,parts:s,...l},c),i.length){o();let t={role:i.every(e=>e.type===`skillRead`)?`skill`:e.role,parts:i,...l};if(ow(t)){let e=sw(s);n.push({kind:`tool-image`,message:t,index:c,...e===void 0?{}:{toolName:e}})}else n.push({kind:`message`,message:t,index:c})}}),o(),n}function aw(e){if(e.every(e=>e.source===`compaction`))return`${String(e.length)} history compaction ${e.length===1?`summary`:`summaries`}`;if(e.every(e=>e.source===`branch_summary`))return`${String(e.length)} branch ${e.length===1?`summary`:`summaries`}`;let t=e.reduce((e,t)=>(e[t.role]=(e[t.role]??0)+1,e),{}),n=Object.entries(t).map(([e,t])=>`${String(t)} ${e}`).join(` · `);return`${String(e.length)} ${e.length===1?`event`:`events`}${n===``?``:` · ${n}`}`}function ow(e){return e.role===`tool`&&e.parts.length>0&&e.parts.every(e=>e.type===`image`)}function sw(e){for(let t of e)if((t.type===`toolCall`||t.type===`toolExecution`||t.type===`toolResult`)&&t.toolName!==``)return t.toolName}function cw(e,t){return e.source===`compaction`||e.source===`branch_summary`?!1:t.type===`skillInvocation`||t.type===`skillRead`||t.type===`image`||t.type===`askUserRecord`||t.type===`text`&&(e.role===`user`||e.role===`assistant`||e.role===`system`||e.role===`bash`)}function lw(e,t,n){let r=e.length;if(r===0||t.length===0||n.length!==r+1||n[r-1]!==e[r-1])return;let i=n[r],a=e[r-1];if(i===void 0||a===void 0)return;let o=t.at(-1);if(o===void 0)return;let s=t.slice(0,-1),c,l;o.kind===`group`?(c=o.startIndex,l=[...o.messages,i]):(c=o.index,l=[a,i]);let u=iw(l,c);return[...s,...u]}function uw(e,t){let n=fw(hw(e,t)),r={distanceFromBottom:e.scrollHeight-e.scrollTop};return n===void 0?r:{...r,markerId:n.id,markerOffset:n.offset}}function dw(e,t,n){if(n!==void 0&&t.markerOffset!==void 0){let r=n.getBoundingClientRect().top-e.getBoundingClientRect().top;e.scrollTop+=pw(r,t.markerOffset);return}e.scrollTop=mw(e.scrollHeight,t.distanceFromBottom)}function fw(e){let t,n=-1/0,r,i=1/0;for(let a of e)a.offset<=0&&a.offset>=n?(t=a,n=a.offset):a.offset>0&&a.offset<i&&(r=a,i=a.offset);return t??r}function pw(e,t){return e-t}function mw(e,t){return Math.max(0,e-t)}function hw(e,t){let n=e.getBoundingClientRect().top;return t.flatMap(e=>{let t=e.dataset.markerId;return t===void 0?[]:[{id:t,offset:e.getBoundingClientRect().top-n}]})}var gw=600,_w=1;function vw(e){return!e.hasMore||e.loadingMore||!e.canRequest||e.clientHeight<=0?!1:yw(e)||bw(e)}function yw(e){return e.scrollTop<(e.topThreshold??Math.max(gw,e.clientHeight))}function bw(e){return e.scrollHeight<=e.clientHeight+_w}var xw={left:!1,right:!1},Sw=1;function Cw(e){if(e===void 0)return xw;let t=Math.max(0,e.scrollWidth-e.clientWidth);return{left:e.scrollLeft>Sw,right:t-e.scrollLeft>Sw}}function ww(e){return`${e.left?` can-scroll-left`:``}${e.right?` can-scroll-right`:``}`}var Tw=e=>{if(!(typeof ResizeObserver>`u`))return new ResizeObserver(()=>{e()})},Ew=class{constructor(e,t=Tw){this.onChange=e,this.createObserver=t,this.current=xw}get edges(){return this.current}observe(e){if(this.element!==e&&(this.observer?.disconnect(),this.observer=void 0,this.element=e,e!==void 0)){let t=this.createObserver(()=>{this.refresh()});t!==void 0&&(t.observe(e),this.observer=t)}this.refresh()}refresh(){let e=Cw(this.element);e.left===this.current.left&&e.right===this.current.right||(this.current=e,this.onChange())}dispose(){this.observer?.disconnect(),this.observer=void 0,this.element=void 0,this.current=xw}};function Dw(e){return e.role===`user`&&Ow(e)!==void 0}function Ow(e){if(e.role!==`user`)return;let t=[],n=[];for(let r of e.parts){if(kw(r)){r.text!==``&&t.push(r.text);continue}r.type===`image`&&r.data!==``&&r.mimeType!==``&&n.push({kind:`image`,mimeType:r.mimeType,data:r.data})}let r=t.join(`
|
|
2303
2307
|
|
|
2304
|
-
`).trim();if(!(r===``&&n.length===0))return{text:r,attachments:n}}function
|
|
2308
|
+
`).trim();if(!(r===``&&n.length===0))return{text:r,attachments:n}}function kw(e){return e.type===`text`}function Aw(e){return e.status===`complete`||e.status===`completed`||e.status===`abandoned`}function jw(e){return e.status===`paused`||e.status===`blocked`||e.status===`budget_limited`}function Mw(e){return e.totalTaskCount<=0?0:Math.min(1,Math.max(0,e.completedTaskCount/e.totalTaskCount))}function Nw(e){return e.totalTaskCount<=0?`No tasks`:`${String(e.completedTaskCount)}/${String(e.totalTaskCount)}`}function Pw(e){switch(e){case`active`:return`Active`;case`paused`:return`Paused`;case`blocked`:return`Blocked`;case`complete`:case`completed`:return`Complete`;case`abandoned`:return`Abandoned`;case`budget_limited`:return`Budget reached`;default:return e.replace(/_/gu,` `)}}function Fw(e){if(e.currentTaskId!==void 0)return Iw(e.tasks,e.currentTaskId)}function Iw(e,t){for(let n of e){if(n.id===t)return n;let e=n.subtasks===void 0?void 0:Iw(n.subtasks,t);if(e!==void 0)return e}}function Lw(e,t=0){let n=[];for(let r of e)n.push({task:r,depth:t}),r.subtasks!==void 0&&n.push(...Lw(r.subtasks,t+1));return n}function Rw(e){if(!(e===void 0||e<=0))return e>=1e6?`${(e/1e6).toFixed(1)}M tokens`:e>=1e3?`${String(Math.round(e/1e3))}k tokens`:`${String(e)} tokens`}function zw(e){if(Aw(e))return[];let t=jw(e)?[{label:`Resume`,command:`/goal-resume`,description:`Resume this goal in the focused session`,destructive:!1}]:[{label:`Pause`,command:`/goal-pause`,description:`Pause this goal`,destructive:!1}];return t.push({label:`Abandon`,command:`/goal-clear`,description:`Archive this goal after confirmation`,destructive:!0}),t}var Bw=class extends v{constructor(...e){super(...e),this.goals=[],this.loading=!1,this.canRunCommands=!0,this.expanded=new Set}render(){return g`
|
|
2305
2309
|
<section>
|
|
2306
2310
|
<h2>
|
|
2307
2311
|
Goals
|
|
@@ -2317,7 +2321,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2317
2321
|
</h2>
|
|
2318
2322
|
${this.goals.length===0?this.renderEmpty():g`<div class="goal-list">${this.goals.map(e=>this.renderGoal(e))}</div>`}
|
|
2319
2323
|
</section>
|
|
2320
|
-
`}openGoalsLabel(){let e=this.goals.filter(e=>!
|
|
2324
|
+
`}openGoalsLabel(){let e=this.goals.filter(e=>!Aw(e)).length;return e===0?``:`${String(e)} open`}renderCommands(e){let t=zw(e);return t.length===0?null:g`
|
|
2321
2325
|
<div class="goal-commands">
|
|
2322
2326
|
${t.map(t=>g`
|
|
2323
2327
|
<button
|
|
@@ -2329,7 +2333,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2329
2333
|
>${t.label}</button>
|
|
2330
2334
|
`)}
|
|
2331
2335
|
</div>
|
|
2332
|
-
`}renderEmpty(){return g`<p class="empty">${this.loading?`Loading goals…`:`No goals recorded for this workspace.`}</p>`}renderGoal(e){let t=this.expanded.has(e.id),n=
|
|
2336
|
+
`}renderEmpty(){return g`<p class="empty">${this.loading?`Loading goals…`:`No goals recorded for this workspace.`}</p>`}renderGoal(e){let t=this.expanded.has(e.id),n=Mw(e),r=Rw(e.tokensUsed),i=Fw(e),a=Aw(e)?`done`:jw(e)?`blocked`:`active`;return g`
|
|
2333
2337
|
<article class=${`goal ${a}`}>
|
|
2334
2338
|
<button
|
|
2335
2339
|
class="goal-header"
|
|
@@ -2340,8 +2344,8 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2340
2344
|
>
|
|
2341
2345
|
<span class="goal-caret" aria-hidden="true">${t?`▾`:`▸`}</span>
|
|
2342
2346
|
<span class="goal-objective">${e.objective}</span>
|
|
2343
|
-
<span class=${`goal-status ${a}`}>${
|
|
2344
|
-
<span class="goal-ratio">${
|
|
2347
|
+
<span class=${`goal-status ${a}`}>${Pw(e.status)}</span>
|
|
2348
|
+
<span class="goal-ratio">${Nw(e)}</span>
|
|
2345
2349
|
</button>
|
|
2346
2350
|
<div
|
|
2347
2351
|
class="goal-bar"
|
|
@@ -2349,7 +2353,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2349
2353
|
aria-valuemin="0"
|
|
2350
2354
|
aria-valuemax=${String(e.totalTaskCount)}
|
|
2351
2355
|
aria-valuenow=${String(e.completedTaskCount)}
|
|
2352
|
-
aria-label=${`${e.objective}: ${
|
|
2356
|
+
aria-label=${`${e.objective}: ${Nw(e)} tasks complete`}
|
|
2353
2357
|
>
|
|
2354
2358
|
<span class="goal-bar-fill" style=${`transform: scaleX(${String(n)})`}></span>
|
|
2355
2359
|
</div>
|
|
@@ -2362,7 +2366,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2362
2366
|
${r===void 0?_:g`<span class="goal-reason">${r}</span>`}
|
|
2363
2367
|
${n===void 0?_:g`<span class="goal-tokens">${n}</span>`}
|
|
2364
2368
|
</p>
|
|
2365
|
-
`}renderDetail(e,t,n){let r=
|
|
2369
|
+
`}renderDetail(e,t,n){let r=Lw(e.tasks);return g`
|
|
2366
2370
|
<div class="goal-detail">
|
|
2367
2371
|
${e.pauseReason===void 0?_:g`<p class="goal-reason detail">${e.pauseReason}</p>`}
|
|
2368
2372
|
${e.verificationContract===void 0?_:g`<p class="goal-contract"><span class="label">Verification</span>${e.verificationContract}</p>`}
|
|
@@ -2471,7 +2475,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2471
2475
|
@container (max-width: 580px) {
|
|
2472
2476
|
.goal-header, .refresh-entry { min-height: 42px; }
|
|
2473
2477
|
}
|
|
2474
|
-
`]}};H([b({attribute:!1})],
|
|
2478
|
+
`]}};H([b({attribute:!1})],Bw.prototype,`goals`,void 0),H([b({type:Boolean})],Bw.prototype,`loading`,void 0),H([b({attribute:!1})],Bw.prototype,`onRefresh`,void 0),H([b({attribute:!1})],Bw.prototype,`onArchive`,void 0),H([b({attribute:!1})],Bw.prototype,`onRunCommand`,void 0),H([b({type:Boolean})],Bw.prototype,`canRunCommands`,void 0),H([x()],Bw.prototype,`expanded`,void 0),H([x()],Bw.prototype,`confirmingArchiveId`,void 0),Bw=H([y(`goal-panel`)],Bw);function Vw(e){let t=e?.trim();if(t===void 0||t===``)return;let n=t.indexOf(`/`),r=n===-1?void 0:t.slice(0,n),i=n===-1?t:t.slice(n+1),a=i.lastIndexOf(`:`),o=a===-1?i:i.slice(0,a),s=a===-1?void 0:i.slice(a+1);if(o!==``)return{...r===void 0||r===``?{}:{provider:r},model:o,...s===void 0||s===``?{}:{thinking:s},label:s===void 0||s===``?o:`${o} · ${s}`}}function Hw(e){typeof CSS<`u`&&CSS.supports(`field-sizing`,`content`)||(e.style.height=`auto`,e.style.height=`${String(e.scrollHeight)}px`)}var Uw=class extends v{constructor(...e){super(...e),this.draftSessionId=``,this.answers={},this.step=0,this.confirmingPartialSubmit=!1,this.submitting=!1}willUpdate(e){if(!e.has(`ask`)&&!e.has(`outcome`)&&!e.has(`draftSessionId`))return;let t=this.currentModelIdentity();t!==this.modelIdentity&&(this.modelIdentity=t,this.answers=this.loadCurrentDraft(),this.confirmingPartialSubmit=!1,this.submitting=!1)}render(){return this.outcome===void 0?this.ask===void 0?null:this.renderOpenAsk(this.ask):this.renderRecord(this.outcome)}renderOpenAsk(e){let t=xu(e.questions,this.answers),n=Su(e.questions,this.answers);return g`
|
|
2475
2479
|
<article class="card open-card" aria-labelledby="ask-user-heading">
|
|
2476
2480
|
<header class="card-header">
|
|
2477
2481
|
<h2 id="ask-user-heading">Questions</h2>
|
|
@@ -2594,7 +2598,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2594
2598
|
${r.fromDraft?g`<p class="draft-note">Draft answer · not sent</p>`:null}
|
|
2595
2599
|
`}
|
|
2596
2600
|
</section>
|
|
2597
|
-
`}changeOption(e,t,n){let r=n.currentTarget;if(!(r instanceof HTMLInputElement))return;if(e.multiple!==!0){r.checked&&this.setAnswer(e,{values:[t]});return}let i=this.answers[e.id],a=r.checked?[...new Set([...i?.values??[],t])]:(i?.values??[]).filter(e=>e!==t);this.setAnswer(e,{values:a,...i?.otherText===void 0?{}:{otherText:i.otherText}})}changeOther(e,t,n){let r=n.currentTarget;if(!(r instanceof HTMLInputElement))return;let i=this.answers[e.id];e.multiple===!0?this.setAnswer(e,{values:[...i?.values??[]],...r.checked?{otherText:i?.otherText??``}:{}}):r.checked&&this.setAnswer(e,{values:[],otherText:this.isOtherSelected(e,i)?i?.otherText??``:``}),r.checked&&this.focusOtherInput(t)}changeOtherText(e,t){let n=t.currentTarget;if(!(n instanceof HTMLTextAreaElement))return;
|
|
2601
|
+
`}changeOption(e,t,n){let r=n.currentTarget;if(!(r instanceof HTMLInputElement))return;if(e.multiple!==!0){r.checked&&this.setAnswer(e,{values:[t]});return}let i=this.answers[e.id],a=r.checked?[...new Set([...i?.values??[],t])]:(i?.values??[]).filter(e=>e!==t);this.setAnswer(e,{values:a,...i?.otherText===void 0?{}:{otherText:i.otherText}})}changeOther(e,t,n){let r=n.currentTarget;if(!(r instanceof HTMLInputElement))return;let i=this.answers[e.id];e.multiple===!0?this.setAnswer(e,{values:[...i?.values??[]],...r.checked?{otherText:i?.otherText??``}:{}}):r.checked&&this.setAnswer(e,{values:[],otherText:this.isOtherSelected(e,i)?i?.otherText??``:``}),r.checked&&this.focusOtherInput(t)}changeOtherText(e,t){let n=t.currentTarget;if(!(n instanceof HTMLTextAreaElement))return;Hw(n);let r=this.answers[e.id];this.setAnswer(e,{values:[...r?.values??[]],otherText:n.value.slice(0,sn)})}setAnswer(e,t){let n=t.values.length===0&&t.otherText===void 0?Object.fromEntries(Object.entries(this.answers).filter(([t])=>t!==e.id)):{...this.answers,[e.id]:t};this.answers=n,this.confirmingPartialSubmit=!1,this.ask!==void 0&&this.draftSessionId!==``&&_u(this.draftSessionId,this.ask.askId,n)}handleSubmit(e,t){if(e.preventDefault(),!this.submitting){if(Su(t.questions,this.answers).length>0){this.showPartialSubmitConfirmation();return}this.submitAnswers(t)}}submitAnswers(e){if(this.submitting)return;this.submitting=!0;let t=this.onSubmit;if(t===void 0){this.submitting=!1;return}let n=e.askId;Promise.resolve().then(()=>t(n,Cu(e.questions,this.answers))).catch(()=>{}).finally(()=>{this.ask?.askId===n&&(this.submitting=!1)})}async showPartialSubmitConfirmation(){this.confirmingPartialSubmit=!0,await this.updateComplete,this.renderRoot.querySelector(`.send-anyway`)?.focus()}keepEditing(e,t){this.confirmingPartialSubmit=!1;let n=t[0];n!==void 0&&this.focusQuestion(e.questions.indexOf(n))}focusQuestion(e){e<0||this.updateComplete.then(()=>{let t=this.renderRoot.querySelector(`#${this.questionFieldsetId(e)}`);(t?.querySelector(`input, textarea`)??t)?.focus()})}async focusOtherInput(e){await this.updateComplete,this.renderRoot.querySelector(`#${this.otherInputId(e)}`)?.focus()}isOtherSelected(e,t){return t?.otherText===void 0?!1:e.multiple===!0||t.values.length===0}displayedRecordAnswer(e,t){if(t.answered)return{values:[...t.values],...t.otherText===void 0?{}:{otherText:t.otherText},fromDraft:!1};if(e.reason!==`superseded`)return;let n=Cu([t.question],this.answers).answers[0];if(n!==void 0)return{values:[...n.values],...n.otherText===void 0?{}:{otherText:n.otherText},fromDraft:!0}}optionLabel(e,t){return e.options.find(e=>e.value===t)?.label??t}currentModelIdentity(){if(this.outcome!==void 0)return`record:${this.draftSessionId}:${this.outcome.askId}`;if(this.ask!==void 0)return`open:${this.draftSessionId}:${this.ask.askId}`}loadCurrentDraft(){let e=this.outcome?.askId??this.ask?.askId;return e===void 0||this.draftSessionId===``?{}:gu(this.draftSessionId,e)}questionGroupName(e,t){return`ask-user:${e.askId}:${t.id}`}questionFieldsetId(e){return`ask-user-question-${String(e)}`}questionDetailId(e){return`ask-user-question-detail-${String(e)}`}otherInputId(e){return`ask-user-other-${String(e)}`}recordQuestionHeadingId(e){return`ask-user-record-question-${String(e)}`}static{this.styles=h`
|
|
2598
2602
|
:host {
|
|
2599
2603
|
display: block;
|
|
2600
2604
|
box-sizing: border-box;
|
|
@@ -2777,9 +2781,9 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2777
2781
|
.confirmation-actions { justify-content: flex-end; }
|
|
2778
2782
|
.primary-action { min-height: 42px; }
|
|
2779
2783
|
}
|
|
2780
|
-
`}};H([b({attribute:!1})],
|
|
2784
|
+
`}};H([b({attribute:!1})],Uw.prototype,`ask`,void 0),H([b({attribute:!1})],Uw.prototype,`outcome`,void 0),H([b({attribute:!1})],Uw.prototype,`draftSessionId`,void 0),H([b({attribute:!1})],Uw.prototype,`onSubmit`,void 0),H([x()],Uw.prototype,`answers`,void 0),H([x()],Uw.prototype,`step`,void 0),H([x()],Uw.prototype,`confirmingPartialSubmit`,void 0),H([x()],Uw.prototype,`submitting`,void 0),Uw=H([y(`ask-user-card`)],Uw);var Ww=1e3,Gw=120;function Kw(e){let t=e.replace(/\r\n/g,`
|
|
2781
2785
|
`).replace(/^\n+/,``).trimEnd(),n=t.indexOf(`
|
|
2782
|
-
`);if(n===-1)return t.length<=
|
|
2786
|
+
`);if(n===-1)return t.length<=Gw?{heading:t}:{heading:`${t.slice(0,Gw).trimEnd()}\u2026`,body:t};let r=t.slice(0,n).trimEnd(),i=r.length<=Gw,a=i?r:`${r.slice(0,Gw).trimEnd()}\u2026`,o=i?t.slice(n+1).replace(/\n+$/,``):t;return o.trim()===``?{heading:a}:{heading:a,body:o}}function qw(e){switch(e){case`answered`:return`Answered`;case`cancelled`:return`Cancelled`;case`timeout`:return`Timed out`;case`aborted`:return`Aborted`;case`session-ended`:return`Session ended`}}function Jw(e){switch(e.reason){case`answered`:{let t=e.answer;return t===void 0?`Closed without an answer.`:typeof t==`boolean`?`Answered: ${t?`Yes`:`No`}`:t===``?`Answered with an empty response.`:`Answered: ${t}`}case`cancelled`:return`Dismissed without an answer.`;case`timeout`:return`No answer was given before the dialog timed out.`;case`aborted`:return`The run ended before this dialog was answered.`;case`session-ended`:return`The session ended before this dialog was answered.`}}function Yw(e,t){if(e===void 0)return;let n=Date.parse(e);if(!Number.isFinite(n))return;let r=n-t;if(r<=0)return`Auto-cancel imminent`;let i=Math.ceil(r/1e3);if(i>=3600){let e=Math.floor(i/3600),t=Math.floor(i%3600/60);return`Auto-cancels in ${String(e)}h ${String(t)}m`}if(i>=60){let e=Math.floor(i/60);return`Auto-cancels in ${String(e)}m ${String(i%60)}s`}return`Auto-cancels in ${String(i)}s`}var Xw=class extends v{constructor(...e){super(...e),this.inputValue=``,this.closing=!1,this.countdownNow=0}connectedCallback(){super.connectedCallback(),this.syncCountdownTimer()}disconnectedCallback(){this.stopCountdownTimer(),super.disconnectedCallback()}willUpdate(e){if(!e.has(`dialog`)&&!e.has(`outcome`))return;let t=this.currentIdentity();t!==this.dialogIdentity&&(this.dialogIdentity=t,this.inputValue=``,this.closing=!1),this.syncCountdownTimer()}render(){return this.outcome===void 0?this.dialog===void 0?null:this.renderOpen(this.dialog):this.renderClosed(this.outcome)}renderOpen(e){let t=Yw(e.timeoutAt,this.countdownNow===0?Date.now():this.countdownNow),{heading:n,body:r}=Kw(e.title);return g`
|
|
2783
2787
|
<article class="card open-card" aria-labelledby="extension-dialog-heading">
|
|
2784
2788
|
<header class="card-header">
|
|
2785
2789
|
<h2 id="extension-dialog-heading">${n}</h2>
|
|
@@ -2825,15 +2829,15 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2825
2829
|
`}renderClosed(e){return g`
|
|
2826
2830
|
<article class="card closed-card" aria-labelledby="extension-dialog-closed-heading">
|
|
2827
2831
|
<header class="card-header">
|
|
2828
|
-
<h2 id="extension-dialog-closed-heading">${
|
|
2829
|
-
<span class=${`header-status ${e.reason}`}>${
|
|
2832
|
+
<h2 id="extension-dialog-closed-heading">${Kw(e.dialog.title).heading}</h2>
|
|
2833
|
+
<span class=${`header-status ${e.reason}`}>${qw(e.reason)}</span>
|
|
2830
2834
|
</header>
|
|
2831
|
-
<p class="closed-summary">${
|
|
2835
|
+
<p class="closed-summary">${Jw(e)}</p>
|
|
2832
2836
|
<footer class="dialog-footer">
|
|
2833
2837
|
<button class="secondary-action" type="button" @click=${()=>{this.dismissClosed(e)}}>Dismiss</button>
|
|
2834
2838
|
</footer>
|
|
2835
2839
|
</article>
|
|
2836
|
-
`}answerDialog(e,t){this.closeWith(e,()=>this.onAnswer?.(e.dialogId,t))}cancelDialog(e){this.closeWith(e,()=>this.onCancel?.(e.dialogId))}submitInput(e,t){e.preventDefault(),this.answerDialog(t,this.inputValue)}closeWith(e,t){if(this.closing)return;this.closing=!0;let n=e.dialogId;Promise.resolve().then(t).catch(()=>{}).finally(()=>{this.dialog?.dialogId===n&&(this.closing=!1)})}changeInput(e){let t=e.currentTarget;t instanceof HTMLInputElement&&(this.inputValue=t.value)}dismissClosed(e){this.onDismiss?.(e.dialog.dialogId)}currentIdentity(){if(this.outcome!==void 0)return`closed:${this.outcome.dialog.dialogId}`;if(this.dialog!==void 0)return`open:${this.dialog.dialogId}`}syncCountdownTimer(){let e=this.isConnected&&this.outcome===void 0&&this.dialog?.timeoutAt!==void 0;if(e&&this.countdownTimer===void 0){this.countdownNow=Date.now(),this.countdownTimer=window.setInterval(()=>{this.countdownNow=Date.now()},
|
|
2840
|
+
`}answerDialog(e,t){this.closeWith(e,()=>this.onAnswer?.(e.dialogId,t))}cancelDialog(e){this.closeWith(e,()=>this.onCancel?.(e.dialogId))}submitInput(e,t){e.preventDefault(),this.answerDialog(t,this.inputValue)}closeWith(e,t){if(this.closing)return;this.closing=!0;let n=e.dialogId;Promise.resolve().then(t).catch(()=>{}).finally(()=>{this.dialog?.dialogId===n&&(this.closing=!1)})}changeInput(e){let t=e.currentTarget;t instanceof HTMLInputElement&&(this.inputValue=t.value)}dismissClosed(e){this.onDismiss?.(e.dialog.dialogId)}currentIdentity(){if(this.outcome!==void 0)return`closed:${this.outcome.dialog.dialogId}`;if(this.dialog!==void 0)return`open:${this.dialog.dialogId}`}syncCountdownTimer(){let e=this.isConnected&&this.outcome===void 0&&this.dialog?.timeoutAt!==void 0;if(e&&this.countdownTimer===void 0){this.countdownNow=Date.now(),this.countdownTimer=window.setInterval(()=>{this.countdownNow=Date.now()},Ww);return}e||this.stopCountdownTimer()}stopCountdownTimer(){this.countdownTimer!==void 0&&(window.clearInterval(this.countdownTimer),this.countdownTimer=void 0)}static{this.styles=h`
|
|
2837
2841
|
:host {
|
|
2838
2842
|
display: block;
|
|
2839
2843
|
box-sizing: border-box;
|
|
@@ -2974,7 +2978,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2974
2978
|
does not fit. */
|
|
2975
2979
|
.dialog-detail { max-height: min(40vh, 320px); overflow-y: auto; overscroll-behavior: contain; }
|
|
2976
2980
|
}
|
|
2977
|
-
`}};H([b({attribute:!1})],
|
|
2981
|
+
`}};H([b({attribute:!1})],Xw.prototype,`dialog`,void 0),H([b({attribute:!1})],Xw.prototype,`outcome`,void 0),H([b({attribute:!1})],Xw.prototype,`onAnswer`,void 0),H([b({attribute:!1})],Xw.prototype,`onCancel`,void 0),H([b({attribute:!1})],Xw.prototype,`onDismiss`,void 0),H([x()],Xw.prototype,`inputValue`,void 0),H([x()],Xw.prototype,`closing`,void 0),H([x()],Xw.prototype,`countdownNow`,void 0),Xw=H([y(`extension-dialog-card`)],Xw);var Zw=class extends v{constructor(...e){super(...e),this.positionPercent=0,this.loadedPercent=100}render(){let e=Qw(this.positionPercent),t=Qw(this.loadedPercent),n=`Message position: about ${String(Math.round(e))}% through conversation. ${String(Math.round(t))}% of messages loaded.`;return g`
|
|
2978
2982
|
<div
|
|
2979
2983
|
class="meter"
|
|
2980
2984
|
style=${`--position:${e.toFixed(2)}%;`}
|
|
@@ -2997,18 +3001,18 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2997
3001
|
.track { position: relative; height: 4px; margin-top: 4px; border-radius: 999px; background: color-mix(in srgb, var(--pi-border-muted) 34%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--pi-bg) 55%, transparent); }
|
|
2998
3002
|
.progress { position: absolute; left: 0; width: var(--position); top: 0; bottom: 0; border-radius: 999px; background: color-mix(in srgb, var(--pi-accent) 42%, var(--pi-border-muted)); }
|
|
2999
3003
|
.marker { position: absolute; left: var(--position); top: 50%; width: 10px; height: 10px; border: 2px solid var(--pi-bg); border-radius: 50%; background: var(--pi-accent); box-shadow: 0 2px 8px var(--pi-shadow); transform: translate(-50%, -50%); }
|
|
3000
|
-
`}};H([b({type:Number})],
|
|
3004
|
+
`}};H([b({type:Number})],Zw.prototype,`positionPercent`,void 0),H([b({type:Number})],Zw.prototype,`loadedPercent`,void 0),Zw=H([y(`conversation-meter`)],Zw);function Qw(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}var $w=new B.Renderer;$w.html=({text:e})=>rT(e);var eT=300,tT=new Map;function nT(e){let t=tT.get(e);if(t!==void 0)return t;let n=aT(B.parse(e,{async:!1,breaks:!0,gfm:!0,renderer:$w}));if(tT.set(e,n),tT.size>eT){let e=tT.keys().next().value;e!==void 0&&tT.delete(e)}return n}function rT(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}var iT=`table-scroll`;function aT(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content.querySelectorAll(`script, style, iframe, object, embed`).forEach(e=>{e.remove()}),t.content.querySelectorAll(`*`).forEach(e=>{for(let t of[...e.attributes]){let n=t.name.toLowerCase();n.startsWith(`on`)&&e.removeAttribute(t.name),(n===`href`||n===`src`)&&!sT(t.value)&&e.removeAttribute(t.name)}e.tagName===`A`&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noreferrer noopener`))}),oT(t.content),t.innerHTML}function oT(e){e.querySelectorAll(`table`).forEach(e=>{if(e.parentElement?.classList.contains(iT)===!0)return;let t=document.createElement(`div`);t.className=iT,t.setAttribute(`role`,`region`),t.setAttribute(`aria-label`,`Table`),t.setAttribute(`tabindex`,`0`),e.before(t),t.append(e)})}function sT(e){if(e.startsWith(`#`)||e.startsWith(`/`))return!0;try{return[`http:`,`https:`,`mailto:`].includes(new URL(e).protocol)}catch{return!1}}var cT=class extends v{constructor(...e){super(...e),this.text=``,this.parsedText=``,this.parsedHtml=``,this.enhancedForHtml=``,this.streamingSuffix=``,this.onFormattedClick=e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`.code-copy-button`);if(!(t instanceof HTMLButtonElement))return;let n=t.closest(`.code-block-wrapper`);if(!(n instanceof HTMLElement))return;let r=n.querySelector(`pre code`);r instanceof HTMLElement&&this.copyCode(r.textContent,t)}}render(){if(!(this.parsedText.length>0&&this.text.startsWith(this.parsedText)&&this.text.length>this.parsedText.length))return this.text!==this.parsedText&&(this.parsedHtml=nT(this.text),this.parsedText=this.text),this.settleTimer=void 0,this.streamingSuffix=``,g`<div class="formatted" dir="auto" @click=${this.onFormattedClick}>${i_(this.parsedHtml)}</div>`;let e=this.text.slice(this.parsedText.length);return this.streamingSuffix=e,this.scheduleSettleParse(),g`<div class="formatted" dir="auto" @click=${this.onFormattedClick}>${i_(this.parsedHtml)}${e===``?``:g`<span class="stream-suffix">${e}</span>`}</div>`}updated(){this.enhancedForHtml!==this.parsedHtml&&(this.enhancedForHtml=this.parsedHtml,this.enhanceCodeBlocks())}scheduleSettleParse(){this.settleTimer===void 0&&(this.settleTimer=setTimeout(()=>{this.settleTimer=void 0,this.parsedText!==this.text&&(this.parsedHtml=nT(this.text),this.parsedText=this.text,this.streamingSuffix=``,this.requestUpdate())},350))}enhanceCodeBlocks(){this.renderRoot.querySelectorAll(`pre`).forEach(e=>{if(!(e instanceof HTMLPreElement)||e.parentElement?.classList.contains(`code-block-wrapper`)===!0||!(e.querySelector(`code`)instanceof HTMLElement))return;let t=document.createElement(`div`);t.className=`code-block-wrapper`;let n=document.createElement(`button`);n.type=`button`,n.className=`code-copy-button`,n.title=`Copy code block`,n.setAttribute(`aria-label`,`Copy code block`);let r=document.createElement(`span`);r.setAttribute(`aria-hidden`,`true`),r.textContent=`⧉`,n.append(r),e.before(t),t.append(e,n)})}async copyCode(e,t){let n=await cS(e);this.setCopyButtonState(t,n?`copied`:`failed`),window.setTimeout(()=>{this.setCopyButtonState(t,`idle`)},1200)}setCopyButtonState(e,t){let n=e.querySelector(`span`);n!==null&&(n.textContent=t===`copied`?`✓`:`⧉`);let r=t===`copied`?`Copied code block`:t===`failed`?`Failed to copy code block`:`Copy code block`;e.title=r,e.setAttribute(`aria-label`,r)}static{this.styles=Yg}};H([b()],cT.prototype,`text`,void 0),cT=H([y(`formatted-text`)],cT);var lT=180,uT=class extends v{constructor(...e){super(...e),this.showFullDiff=!1,this.copied=!1,this.diffOpen=!0}render(){let e=this.execution;if(e===void 0)return null;let t=fT(e.args),n=mT(e.details),r=e.preview,i=n??r?.diff,a=i===void 0?void 0:hT(i),o=n!==void 0&&r?.diff!==void 0&&n!==r.diff,s=e.status===`error`?e.resultText:r?.error,c=i===void 0?e.resultText:void 0,l=dT(e,t);return g`
|
|
3001
3005
|
<section class=${`tool-card ${e.status}`}>
|
|
3002
3006
|
<div class="tool-header">
|
|
3003
3007
|
<div class="tool-title">
|
|
3004
|
-
<span class="status-icon" aria-hidden="true">${
|
|
3008
|
+
<span class="status-icon" aria-hidden="true">${yT(e.status)}</span>
|
|
3005
3009
|
<strong>${e.toolName}</strong>
|
|
3006
3010
|
${this.renderHeaderTarget(l)}
|
|
3007
3011
|
</div>
|
|
3008
3012
|
<div class="tool-meta">
|
|
3009
|
-
${
|
|
3013
|
+
${pT(e)===void 0?null:g`<span>${pT(e)}</span>`}
|
|
3010
3014
|
${a===void 0?null:g`<span class="diff-stats"><b class="added">+${a.added}</b><span>/</span><b class="removed">-${a.removed}</b></span>`}
|
|
3011
|
-
<span class="status-label">${
|
|
3015
|
+
<span class="status-label">${bT(e.status)}</span>
|
|
3012
3016
|
</div>
|
|
3013
3017
|
</div>
|
|
3014
3018
|
|
|
@@ -3033,7 +3037,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3033
3037
|
`}
|
|
3034
3038
|
</details>
|
|
3035
3039
|
`}renderDiffBody(e,t,n){let r=e.split(`
|
|
3036
|
-
`),i=!this.showFullDiff&&r.length>
|
|
3040
|
+
`),i=!this.showFullDiff&&r.length>lT,a=i?r.slice(0,lT):r;return g`
|
|
3037
3041
|
<details class="diff-details" ?open=${this.diffOpen} @toggle=${e=>{this.onDiffToggle(e)}}>
|
|
3038
3042
|
<summary>
|
|
3039
3043
|
<span>${t}</span>
|
|
@@ -3044,7 +3048,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3044
3048
|
<span>${i?`Showing ${String(a.length)} of ${String(r.length)} lines`:`Full diff`}</span>
|
|
3045
3049
|
<button type="button" @click=${()=>{this.copyDiff(e)}}>${this.copied?`Copied`:`Copy diff`}</button>
|
|
3046
3050
|
</div>
|
|
3047
|
-
<pre class="diff" aria-label=${t}><code class="diff-content">${a.map(e=>g`<span class=${
|
|
3051
|
+
<pre class="diff" aria-label=${t}><code class="diff-content">${a.map(e=>g`<span class=${gT(e)}>${e}</span>`)}</code></pre>
|
|
3048
3052
|
${i?g`
|
|
3049
3053
|
<button class="show-more" type="button" @click=${()=>{this.showFullDiff=!0}}>
|
|
3050
3054
|
Show all ${String(r.length)} diff lines
|
|
@@ -3095,24 +3099,24 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3095
3099
|
.diff .added { background: color-mix(in srgb, var(--pi-success) 12%, transparent); }
|
|
3096
3100
|
.diff .removed { background: color-mix(in srgb, var(--pi-danger) 12%, transparent); }
|
|
3097
3101
|
.show-more { justify-self: start; }
|
|
3098
|
-
`}};H([b({attribute:!1})],
|
|
3099
|
-
`))
|
|
3102
|
+
`}};H([b({attribute:!1})],uT.prototype,`execution`,void 0),H([x()],uT.prototype,`showFullDiff`,void 0),H([x()],uT.prototype,`copied`,void 0),H([x()],uT.prototype,`diffOpen`,void 0),uT=H([y(`tool-execution-view`)],uT);function dT(e,t){if(t!==void 0&&t!==``)return{label:`File`,text:t};let n=CT(e.args,`command`);if(n!==void 0&&n!==``)return{label:`Command`,text:n};if(e.summary!==``)return{label:`Input`,text:e.summary}}function fT(e){return CT(e,`path`)??CT(e,`file_path`)}function pT(e){if(e.toolName!==`edit`)return;let t=ST(e.args,`edits`);if(Array.isArray(t))return`${String(t.length)} edit${t.length===1?``:`s`}`;if(typeof ST(e.args,`oldText`)==`string`&&typeof ST(e.args,`newText`)==`string`)return`1 edit`}function mT(e){return CT(e,`diff`)}function hT(e){let t=0,n=0;for(let r of e.split(`
|
|
3103
|
+
`))_T(r)?t++:vT(r)&&n++;return{added:t,removed:n}}function gT(e){return _T(e)?`added`:vT(e)?`removed`:e.startsWith(`@@`)?`hunk`:e.startsWith(`+++`)||e.startsWith(`---`)?`file`:e.startsWith(`diff `)||e.startsWith(`index `)?`meta`:`context`}function _T(e){return e.startsWith(`+`)&&!e.startsWith(`+++`)}function vT(e){return e.startsWith(`-`)&&!e.startsWith(`---`)}function yT(e){return e===`success`?`✓`:e===`error`?`✖`:e===`running`?`●`:`○`}function bT(e){return e===`success`?`done`:e===`error`?`failed`:e===`running`?`running`:`pending`}function xT(e){return typeof e==`object`&&!!e}function ST(e,t){return xT(e)?e[t]:void 0}function CT(e,t){let n=ST(e,t);return typeof n==`string`?n:void 0}var wT=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),TT=new Intl.DateTimeFormat(void 0,{timeStyle:`short`});function ET(e){if(typeof e!=`object`||!e)return;let t=Reflect.get(e,`queuedMessages`);if(Array.isArray(t))return{queuedMessages:t}}function DT(e){return g`
|
|
3100
3104
|
<svg class=${`notification-icon notification-disclosure-icon${e?``:` expanded`}`} viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
3101
3105
|
<path d="m9 18 6-6-6-6"></path>
|
|
3102
3106
|
</svg>
|
|
3103
|
-
`}function
|
|
3107
|
+
`}function OT(){return g`
|
|
3104
3108
|
<svg class="notification-icon notification-close-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
3105
3109
|
<path d="M6 6l12 12"></path>
|
|
3106
3110
|
<path d="M18 6 6 18"></path>
|
|
3107
3111
|
</svg>
|
|
3108
|
-
`}function
|
|
3112
|
+
`}function kT(e){return typeof e==`object`&&!!e&&typeof Reflect.get(e,`machineId`)==`string`&&typeof Reflect.get(e,`cwd`)==`string`&&typeof Reflect.get(e,`sessionId`)==`string`}function AT(e){return jT(e,0,100)}function jT(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,e)):t}function MT(e){return e!==void 0&&e.state!==`delivered`}function NT(e){if(e.state===`sending`)return{glyph:`◌`,text:`Sending`,label:`Sending`,tone:`pending`};if(e.state===`failed`)return{glyph:`!`,text:`Not sent`,label:`Not sent - the server never received this message`,tone:`failed`};if(e.state===`queued`){let t=e.kind===`steer`?`Queued to steer`:`Queued`;return{glyph:`✓`,text:t,label:`${t} - the server has this message and the agent will take it next`,tone:`received`}}return e.state===`received`?{glyph:`✓`,text:`Sent`,label:`Sent - the server received this message`,tone:`received`}:{glyph:`✓✓`,text:`Read`,label:`Read - the agent took this message into the conversation`,tone:`delivered`}}function PT(e){return{src:`data:${e.mimeType};base64,${e.data}`,alt:`attached image`}}function FT(e){return e===void 0||e===``?`tool output`:`${e} output`}function IT(e){return`m:${String(e)}`}function LT(e){return`g:${String(e)}`}function RT(e){return`e:${String(e)}`}function zT(e){return`g:${String(e)}`}function BT(e){return e?`msg event-group live`:`msg event-group`}function VT(e){return e?`live events`:`events`}function HT(e){return(e?.warnings??[]).map(e=>({severity:e.severity,severityClass:`session-warning ${e.severity}`,message:e.message,...e.source===void 0?{}:{source:e.source},...e.path===void 0?{}:{path:e.path},...e.dismiss===void 0?{}:{dismissId:e.dismiss.id}}))}function UT(e){let t=e.meta?.timestamp;return[t===void 0?void 0:WT(t),GT(e),e.meta?.thinkingLevel].filter(e=>e!==void 0&&e!==``).join(` · `)}function WT(e){let t=new Date(e);if(Number.isFinite(t.getTime()))return wT.format(t)}function GT(e){let t=e.meta?.model;if(t===void 0)return;let n=t.responseId??t.id;return n===void 0||n===``?t.provider:t.provider!==void 0&&t.provider!==``?`${t.provider}/${n}`:n}var K=class extends v{constructor(...e){super(...e),this.messages=[],this.sessionId=``,this.messageStart=0,this.messageEnd=0,this.messageTotal=0,this.hasMore=!1,this.loadingMore=!1,this.isSendingPrompt=!1,this.isCompacting=!1,this.pendingMessageCount=0,this.clientQueuedMessages=[],this.askDraftSessionId=``,this.pendingDialogs=[],this.closedDialogs=[],this.warningsVisible=!0,this.pinnedToBottom=!0,this.jumpToBottomVisible=!1,this.zoomedImage=void 0,this.collapsedTopDrawerKeys=new Set,this.expandedTopDrawerKeys=new Set,this.drawerWorkWasRunning=!1,this.goals=[],this.activityFilter=`all`,this.activityScope=`active`,this.turnNowMs=0,this.disclosures=new QC,this.scrollController=new DC,this.drawerTabEdgeTracker=new Ew(()=>{this.requestUpdate()}),this.suppressScrollSave=!1,this.suppressLoadMoreRequests=!1,this.groupedMessagesStart=0,this.groupedMessagesCache=[],this.messageMetaCache=new WeakMap,this.messageCopyTextCache=new WeakMap,this.lastScrollTop=0,this.lastClientHeight=0,this.prependRestoreToken=0,this.loadMoreRequested=!1,this.onViewportResize=()=>{this.pinnedToBottom?this.scrollToBottom():this.lastClientHeight=this.chat?.clientHeight??0},this.onImageLoad=()=>{this.pinnedToBottom&&this.scrollToBottom()},this.openImageZoom=(e,t)=>{this.zoomedImage={src:e,alt:t}},this.closeImageZoom=()=>{this.zoomedImage!==void 0&&(this.zoomedImage=void 0)},this.onImageZoomDialogClick=e=>{e.target===this.imageZoomDialog&&this.closeImageZoom()},this.onPageHide=()=>{this.saveScrollPosition()},this.handleClearServerQueue=()=>{this.onClearServerQueue?.(this.status?.queuedMessages??[])},this.handleToggleWarnings=()=>{this.onToggleWarnings?.()},this.closeActivityOutput=()=>{this.activityOutput!==void 0&&this.onCloseActivityOutput?.()},this.onActivityOutputDialogClick=e=>{e.target===this.activityOutputDialog&&this.closeActivityOutput()}}connectedCallback(){super.connectedCallback(),window.addEventListener(`resize`,this.onViewportResize),window.addEventListener(`pagehide`,this.onPageHide),window.visualViewport?.addEventListener(`resize`,this.onViewportResize)}firstUpdated(){this.lastClientHeight=this.chat?.clientHeight??0}disconnectedCallback(){this.stopTurnClock(),this.saveScrollPosition(),this.scrollController.dispose(),this.drawerTabEdgeTracker.dispose(),this.releaseImageZoomModal(),this.releaseActivityOutputModal(),this.prependRestoreToken+=1,this.restoreScrollFrame!==void 0&&cancelAnimationFrame(this.restoreScrollFrame),this.loadMoreCheckFrame!==void 0&&cancelAnimationFrame(this.loadMoreCheckFrame),this.scrollToBottomFrame!==void 0&&cancelAnimationFrame(this.scrollToBottomFrame),this.scrollToOpenAskFrame!==void 0&&(cancelAnimationFrame(this.scrollToOpenAskFrame),this.scrollToOpenAskFrame=void 0),this.scrollToOpenDialogFrame!==void 0&&(cancelAnimationFrame(this.scrollToOpenDialogFrame),this.scrollToOpenDialogFrame=void 0),this.conversationRailFrame!==void 0&&cancelAnimationFrame(this.conversationRailFrame),window.removeEventListener(`resize`,this.onViewportResize),window.removeEventListener(`pagehide`,this.onPageHide),window.visualViewport?.removeEventListener(`resize`,this.onViewportResize),super.disconnectedCallback()}savePreviousSessionScrollPosition(e){typeof e!=`string`||e===``||e===this.sessionId||this.saveScrollPosition(e)}prepareSessionUiState(){this.turnStartedAtMs=void 0,this.disclosures.syncSession(this.sessionId),this.pendingNotificationFocus=void 0,this.retainedEmptyNotificationTrayTargetKey=void 0,this.scrollController.clearScheduledSave(),this.suppressScrollSave=!1,this.suppressLoadMoreRequests=!1,this.pendingScrollRestoreSessionId=void 0,this.pendingScrollRestorePosition=void 0,this.prependRestoreToken+=1,this.restoreScrollFrame!==void 0&&(cancelAnimationFrame(this.restoreScrollFrame),this.restoreScrollFrame=void 0),this.scrollToOpenAskFrame!==void 0&&(cancelAnimationFrame(this.scrollToOpenAskFrame),this.scrollToOpenAskFrame=void 0),this.scrollToOpenDialogFrame!==void 0&&(cancelAnimationFrame(this.scrollToOpenDialogFrame),this.scrollToOpenDialogFrame=void 0)}willUpdate(e){this.foldDrawerAsWorkFinishes(),e.has(`sessionId`)?(this.savePreviousSessionScrollPosition(e.get(`sessionId`)),this.prepareSessionUiState()):e.has(`notificationInbox`)&&this.notificationTargetChanged(e.get(`notificationInbox`))&&(this.pendingNotificationFocus=void 0,this.retainedEmptyNotificationTrayTargetKey=void 0),(e.has(`messages`)||e.has(`pendingAsk`)||e.has(`pendingDialogs`)||e.has(`closedDialogs`))&&(this.pinnedToBottom=this.pinnedToBottom&&(this.didChatHeightChange()||this.isNearBottom()))}update(e){let t=this.isPrependingMessages(e)?this.capturePrependScrollAnchor():void 0;super.update(e),t!==void 0&&this.restorePrependScrollAnchor(t)}updated(e){e.has(`loadingMore`)&&!this.loadingMore&&(this.loadMoreRequested=!1),e.has(`hasMore`)&&!this.hasMore&&(this.loadMoreRequested=!1),e.has(`sessionId`)&&this.restoreScrollPosition();let t=e.has(`pendingAsk`)&&this.isNewPendingAsk(e.get(`pendingAsk`)),n=e.has(`pendingDialogs`)&&this.isNewOpenDialog(e.get(`pendingDialogs`));!e.has(`sessionId`)&&t&&this.pinnedToBottom?this.scrollToOpenAsk():!e.has(`sessionId`)&&n&&this.pinnedToBottom?this.scrollToOpenDialog():!e.has(`sessionId`)&&(e.has(`messages`)||this.queueGrew(e.get(`status`))||e.has(`pendingAsk`)||e.has(`pendingDialogs`)||e.has(`closedDialogs`))&&this.pinnedToBottom&&this.scrollToBottom(),(e.has(`messages`)||e.has(`messageStart`)||e.has(`messageTotal`)||e.has(`hasMore`)||e.has(`loadingMore`))&&this.scheduleConversationRailUpdate(),(e.has(`messages`)||e.has(`messageStart`)||e.has(`hasMore`)||e.has(`loadingMore`)||e.has(`pendingAsk`)||e.has(`pendingDialogs`)||e.has(`closedDialogs`))&&this.continuePendingScrollRestore(),(e.has(`messages`)||e.has(`hasMore`)||e.has(`loadingMore`))&&this.requestLoadMoreIfNeeded(),e.has(`notificationInbox`)&&this.pendingNotificationFocus!==void 0&&this.focusPendingNotificationTarget(),e.has(`zoomedImage`)&&this.syncImageZoomDialog(),e.has(`activityOutput`)&&this.syncActivityOutputDialog(),this.drawerTabEdgeTracker.observe(this.drawerTabs??void 0),this.publishScrollbarWidth(),(e.has(`status`)||e.has(`activity`)||e.has(`isSendingPrompt`))&&this.syncTurnClock()}publishScrollbarWidth(){let e=yC(this.chat);this.style.setProperty(`--pi-chat-scrollbar`,`${String(e)}px`)}syncImageZoomDialog(){let e=this.imageZoomDialog;if(e!==void 0){if(this.zoomedImage!==void 0){if(this.imageZoomModalRegistration===void 0){let t=Dg({element:e,nativeTopLayer:!0,focus:()=>{(this.renderRoot.querySelector(`.image-zoom-close`)??e).focus()}});this.imageZoomModalRegistration=t;try{e.open||e.showModal()}catch(e){throw this.imageZoomModalRegistration=void 0,t.unregister(),e}}this.imageZoomModalRegistration.focus();return}e.open&&e.close(),this.releaseImageZoomModal()}}syncActivityOutputDialog(){let e=this.activityOutputDialog;if(e!==void 0){if(this.activityOutput!==void 0){if(this.activityOutputModalRegistration===void 0){let t=Dg({element:e,nativeTopLayer:!0,focus:()=>{(this.renderRoot.querySelector(`.activity-output-close`)??e).focus()}});this.activityOutputModalRegistration=t;try{e.open||e.showModal()}catch(e){throw this.activityOutputModalRegistration=void 0,t.unregister(),e}}this.activityOutputModalRegistration.focus();return}e.open&&e.close(),this.releaseActivityOutputModal()}}releaseActivityOutputModal(){let e=this.activityOutputModalRegistration;this.activityOutputModalRegistration=void 0,e?.unregister()}releaseImageZoomModal(){let e=this.imageZoomModalRegistration;this.imageZoomModalRegistration=void 0,e?.unregister()}notificationTargetChanged(e){let t=this.notificationInbox;return!kT(e)||t===void 0?e!==t:Pp(e)!==Pp(t)}render(){let e=this.groupedMessages();return g`
|
|
3109
3113
|
${this.renderTopNotices()}
|
|
3110
3114
|
${this.renderNotificationLiveRegions()}
|
|
3111
3115
|
<div class="chat-wrap">
|
|
3112
3116
|
${this.renderConversationRail()}
|
|
3113
3117
|
<div class="chat" @scroll=${()=>{this.onScroll()}} @wheel=${e=>{this.onWheel(e)}} @touchstart=${e=>{this.onTouchStart(e)}} @touchmove=${e=>{this.onTouchMove(e)}}>
|
|
3114
3118
|
${this.renderHistoryBoundary()}
|
|
3115
|
-
${
|
|
3119
|
+
${YC(e,e=>e.kind===`group`?this.groupRenderKey(e.startIndex):this.messageAnchorKey(e.index),(t,n)=>t.kind===`group`?this.renderMessageGroup(t.messages,t.startIndex,t.endIndex,this.isLiveTailGroup(e,n)):t.kind===`tool-image`?this.renderToolImageOutput(t.message,t.index,t.toolName):this.renderMessage(t.message,t.index))}
|
|
3116
3120
|
${this.renderSessionActivity()}
|
|
3117
3121
|
${this.renderQueuedMessages()}
|
|
3118
3122
|
${this.renderOpenAsk()}
|
|
@@ -3131,7 +3135,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3131
3135
|
aria-label="Jump to the newest message"
|
|
3132
3136
|
@click=${()=>{this.pinnedToBottom=!0,this.scrollToBottom(),this.jumpToBottomVisible=!1}}
|
|
3133
3137
|
>↓</button>
|
|
3134
|
-
`:null}renderTopNotices(){let e=this.renderWarnings(),t=this.renderTopDrawer();return e===null&&t===null?null:g`<div class="top-notices">${e}${t}</div>`}renderTopDrawer(){let e=this.activityPanelState(),t=this.visibleNotificationInbox();if(e===void 0&&t===void 0&&this.goals.length===0)return null;let n=
|
|
3138
|
+
`:null}renderTopNotices(){let e=this.renderWarnings(),t=this.renderTopDrawer();return e===null&&t===null?null:g`<div class="top-notices">${e}${t}</div>`}renderTopDrawer(){let e=this.activityPanelState(),t=this.visibleNotificationInbox();if(e===void 0&&t===void 0&&this.goals.length===0)return null;let n=oE({activity:e!==void 0,notifications:t!==void 0,goals:this.goals.length>0},this.topDrawerTab),r=this.topDrawerKey(),i=this.expandedTopDrawerKeys.has(r)?!1:this.collapsedTopDrawerKeys.has(r)||!aE(),a=i?`Show session activity and notifications`:`Hide session activity and notifications`,o=t===void 0?0:Ap(t);return g`
|
|
3135
3139
|
<section
|
|
3136
3140
|
class=${`top-drawer${i?` collapsed`:``}`}
|
|
3137
3141
|
role="region"
|
|
@@ -3139,7 +3143,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3139
3143
|
@focusout=${e=>{this.releaseEmptyNotificationTray(e)}}
|
|
3140
3144
|
>
|
|
3141
3145
|
<header class="drawer-header" data-notification-focus="header" tabindex="-1">
|
|
3142
|
-
<div class=${`drawer-tabs-frame${
|
|
3146
|
+
<div class=${`drawer-tabs-frame${ww(this.drawerTabEdgeTracker.edges)}`}>
|
|
3143
3147
|
<div class="drawer-tabs" role="tablist" aria-label="Session drawer sections" @scroll=${()=>{this.drawerTabEdgeTracker.refresh()}} @keydown=${e=>{this.onDrawerTabsKeydown(e)}}>
|
|
3144
3148
|
${e===void 0?null:g`
|
|
3145
3149
|
<button
|
|
@@ -3153,7 +3157,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3153
3157
|
@click=${()=>{this.selectTopDrawerTab(`activity`,i)}}
|
|
3154
3158
|
>
|
|
3155
3159
|
${e.summary.working?g`<span class="subagent-dot working" aria-hidden="true"></span>`:null}
|
|
3156
|
-
<span class="drawer-tab-label">${
|
|
3160
|
+
<span class="drawer-tab-label">${eE({active:e.activeCount,total:e.total})}</span>
|
|
3157
3161
|
</button>
|
|
3158
3162
|
`}
|
|
3159
3163
|
${t===void 0?null:g`
|
|
@@ -3206,7 +3210,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3206
3210
|
aria-expanded=${String(!i)}
|
|
3207
3211
|
aria-controls=${n===`activity`?`session-activity-list`:`session-notification-list`}
|
|
3208
3212
|
@click=${()=>{this.toggleTopDrawer(i)}}
|
|
3209
|
-
>${
|
|
3213
|
+
>${DT(i)}</button>
|
|
3210
3214
|
</div>
|
|
3211
3215
|
</header>
|
|
3212
3216
|
<div class="drawer-body" ?hidden=${i}>
|
|
@@ -3223,7 +3227,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3223
3227
|
`:null}
|
|
3224
3228
|
</div>
|
|
3225
3229
|
</section>
|
|
3226
|
-
`}visibleNotificationInbox(){let e=this.notificationInbox;if(e?.sessionId!==this.sessionId)return;let t=e.pendingDismissedIds.size>0||e.dismissAllPending,n=this.retainedEmptyNotificationTrayTargetKey===Pp(e);if(!(Ap(e)===0&&!t&&!n))return e}topDrawerKey(){let e=this.notificationInbox;return e?.sessionId===this.sessionId?Pp(e):JSON.stringify([null,null,this.sessionId])}toggleTopDrawer(e){let t=this.topDrawerKey(),n=new Set(this.collapsedTopDrawerKeys),r=new Set(this.expandedTopDrawerKeys);e?(n.delete(t),r.add(t)):(r.delete(t),n.add(t)),this.collapsedTopDrawerKeys=n,this.expandedTopDrawerKeys=r}selectTopDrawerTab(e,t){this.topDrawerTab=e,t&&this.toggleTopDrawer(t)}renderActivityFilters(e,t){let n=
|
|
3230
|
+
`}visibleNotificationInbox(){let e=this.notificationInbox;if(e?.sessionId!==this.sessionId)return;let t=e.pendingDismissedIds.size>0||e.dismissAllPending,n=this.retainedEmptyNotificationTrayTargetKey===Pp(e);if(!(Ap(e)===0&&!t&&!n))return e}topDrawerKey(){let e=this.notificationInbox;return e?.sessionId===this.sessionId?Pp(e):JSON.stringify([null,null,this.sessionId])}toggleTopDrawer(e){let t=this.topDrawerKey(),n=new Set(this.collapsedTopDrawerKeys),r=new Set(this.expandedTopDrawerKeys);e?(n.delete(t),r.add(t)):(r.delete(t),n.add(t)),this.collapsedTopDrawerKeys=n,this.expandedTopDrawerKeys=r}selectTopDrawerTab(e,t){this.topDrawerTab=e,t&&this.toggleTopDrawer(t)}renderActivityFilters(e,t){let n=tE(e);return n.length<=1?null:g`
|
|
3227
3231
|
<div class="activity-filters" role="group" aria-label="Filter session activity">
|
|
3228
3232
|
${n.map(e=>g`
|
|
3229
3233
|
<button
|
|
@@ -3234,9 +3238,9 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3234
3238
|
>${e.label} <span class="activity-filter-count">${String(e.count)}</span></button>
|
|
3235
3239
|
`)}
|
|
3236
3240
|
</div>
|
|
3237
|
-
`}activityPanelState(){let e=this.subagents??[],t=this.subagentRuns??[],n=this.backgroundTasks??[];if(e.length===0&&t.length===0&&n.length===0)return;let r=
|
|
3241
|
+
`}activityPanelState(){let e=this.subagents??[],t=this.subagentRuns??[],n=this.backgroundTasks??[];if(e.length===0&&t.length===0&&n.length===0)return;let r=lE(e),i=qT(t),a=JT(n),o=sE([...r.map(e=>e.status),...i.map(e=>e.status),...a.map(e=>e.status)]),s=[...r,...i,...a].filter(e=>QT(e.status)).length;return{rows:r,runRows:i,taskRows:a,summary:o,total:r.length+i.length+a.length,activeCount:s}}renderActivityPanel(e){let t=nE(this.activityFilter,e),n=e.activeCount===0&&this.activityScope===`active`?`empty-active`:this.activityScope,r=YT([...e.rows.map((e,t)=>({kind:`subagents`,index:t,status:e.status,row:e})),...e.runRows.map((e,t)=>({kind:`runs`,index:t,status:e.status,startedAt:e.run.startedAt,row:e})),...e.taskRows.map((e,t)=>({kind:`tasks`,index:t,status:e.status,startedAt:e.task.startedAt,row:e}))]).filter(e=>t===`all`||t===e.kind),i=r.filter(e=>n===`all`||!$T(e.status)),a=r.filter(e=>$T(e.status)).length;return g`
|
|
3238
3242
|
<div class="subagents-list" id="session-activity-list" role="tabpanel" aria-labelledby="drawer-tab-activity">
|
|
3239
|
-
${e.total===0||n===`empty-active`?g`<p class="drawer-hint">${
|
|
3243
|
+
${e.total===0||n===`empty-active`?g`<p class="drawer-hint">${rE}</p>`:null}
|
|
3240
3244
|
${this.renderActivityFilters(e,t)}
|
|
3241
3245
|
${n===`empty-active`?g`<p class="activity-empty">Nothing running right now.</p>`:null}
|
|
3242
3246
|
${i.map(e=>this.renderActivityEntry(e))}
|
|
@@ -3308,7 +3312,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3308
3312
|
<div class="notification-metadata">
|
|
3309
3313
|
<strong class="notification-severity">${n}</strong>
|
|
3310
3314
|
<span aria-hidden="true">·</span>
|
|
3311
|
-
<time datetime=${t.receivedAt}>${
|
|
3315
|
+
<time datetime=${t.receivedAt}>${TT.format(new Date(t.receivedAt))}</time>
|
|
3312
3316
|
</div>
|
|
3313
3317
|
<p class="notification-message" dir="auto">${t.message}</p>
|
|
3314
3318
|
${r===void 0?null:g`<p class="notification-truncated">${r}</p>`}
|
|
@@ -3327,15 +3331,15 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3327
3331
|
title="Dismiss notification"
|
|
3328
3332
|
?disabled=${e.pendingDismissedIds.has(t.id)||e.dismissAllPending||this.onDismissNotification===void 0}
|
|
3329
3333
|
@click=${()=>{this.dismissNotification(t.id)}}
|
|
3330
|
-
>${
|
|
3334
|
+
>${OT()}</button>
|
|
3331
3335
|
</div>
|
|
3332
3336
|
</article>
|
|
3333
3337
|
`})}
|
|
3334
3338
|
</div>
|
|
3335
3339
|
`}renderNotificationLiveRegions(){let e=this.notificationInbox?.sessionId===this.sessionId?this.notificationInbox.announcements:[],t=e.filter(e=>e.severity!==`error`),n=e.filter(e=>e.severity===`error`);return g`
|
|
3336
|
-
<div class="visually-hidden notification-live" aria-live="polite" aria-atomic="false">${
|
|
3337
|
-
<div class="visually-hidden notification-live" aria-live="assertive" aria-atomic="false">${
|
|
3338
|
-
`}dismissNotification(e){let t=this.notificationInbox;if(t===void 0||this.onDismissNotification===void 0)return;let n=Np(t.notifications,e),r=Pp(t);this.pendingNotificationFocus={chatKey:r,focusTarget:n},n.kind===`header`&&(this.retainedEmptyNotificationTrayTargetKey=r),this.onDismissNotification(e)}dismissAllNotifications(){let e=this.notificationInbox;if(e===void 0||this.onDismissAllNotifications===void 0)return;let t=Pp(e);this.pendingNotificationFocus={chatKey:t,focusTarget:{kind:`header`}},this.retainedEmptyNotificationTrayTargetKey=t,this.onDismissAllNotifications()}releaseEmptyNotificationTray(e){let t=e.currentTarget,n=e.relatedTarget;if(t instanceof HTMLElement&&n instanceof Node&&t.contains(n)||this.pendingNotificationFocus!==void 0)return;let r=this.notificationInbox;r!==void 0&&this.retainedEmptyNotificationTrayTargetKey===Pp(r)&&Ap(r)===0&&(this.retainedEmptyNotificationTrayTargetKey=void 0)}focusPendingNotificationTarget(){let e=this.pendingNotificationFocus;this.pendingNotificationFocus=void 0;let t=this.notificationInbox;if(e===void 0||t===void 0||Pp(t)!==e.chatKey)return;let n=e.focusTarget;if(n.kind===`header`){this.renderRoot.querySelector(`[data-notification-focus='header']`)?.focus();return}let r=Array.from(this.renderRoot.querySelectorAll(`[data-notification-id]`)).find(e=>e.dataset.notificationId===n.notificationId);if(r!==void 0){r.focus();return}Ap(t)===0&&(this.retainedEmptyNotificationTrayTargetKey=e.chatKey),this.renderRoot.querySelector(`[data-notification-focus='header']`)?.focus()}renderWarnings(){let e=
|
|
3340
|
+
<div class="visually-hidden notification-live" aria-live="polite" aria-atomic="false">${YC(t,e=>e.id,e=>g`<span data-announcement-id=${e.id}>${kp(e)}</span>`)}</div>
|
|
3341
|
+
<div class="visually-hidden notification-live" aria-live="assertive" aria-atomic="false">${YC(n,e=>e.id,e=>g`<span data-announcement-id=${e.id}>${kp(e)}</span>`)}</div>
|
|
3342
|
+
`}dismissNotification(e){let t=this.notificationInbox;if(t===void 0||this.onDismissNotification===void 0)return;let n=Np(t.notifications,e),r=Pp(t);this.pendingNotificationFocus={chatKey:r,focusTarget:n},n.kind===`header`&&(this.retainedEmptyNotificationTrayTargetKey=r),this.onDismissNotification(e)}dismissAllNotifications(){let e=this.notificationInbox;if(e===void 0||this.onDismissAllNotifications===void 0)return;let t=Pp(e);this.pendingNotificationFocus={chatKey:t,focusTarget:{kind:`header`}},this.retainedEmptyNotificationTrayTargetKey=t,this.onDismissAllNotifications()}releaseEmptyNotificationTray(e){let t=e.currentTarget,n=e.relatedTarget;if(t instanceof HTMLElement&&n instanceof Node&&t.contains(n)||this.pendingNotificationFocus!==void 0)return;let r=this.notificationInbox;r!==void 0&&this.retainedEmptyNotificationTrayTargetKey===Pp(r)&&Ap(r)===0&&(this.retainedEmptyNotificationTrayTargetKey=void 0)}focusPendingNotificationTarget(){let e=this.pendingNotificationFocus;this.pendingNotificationFocus=void 0;let t=this.notificationInbox;if(e===void 0||t===void 0||Pp(t)!==e.chatKey)return;let n=e.focusTarget;if(n.kind===`header`){this.renderRoot.querySelector(`[data-notification-focus='header']`)?.focus();return}let r=Array.from(this.renderRoot.querySelectorAll(`[data-notification-id]`)).find(e=>e.dataset.notificationId===n.notificationId);if(r!==void 0){r.focus();return}Ap(t)===0&&(this.retainedEmptyNotificationTrayTargetKey=e.chatKey),this.renderRoot.querySelector(`[data-notification-focus='header']`)?.focus()}renderWarnings(){let e=HT(this.status);return!this.warningsVisible||e.length===0?null:g`
|
|
3339
3343
|
<aside class="session-warnings" role="alert" aria-live="polite">
|
|
3340
3344
|
${this.onToggleWarnings===void 0?null:g`
|
|
3341
3345
|
<div class="session-warnings-controls">
|
|
@@ -3392,12 +3396,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3392
3396
|
<img class="image-zoom-full" src=${this.zoomedImage.src} alt=${this.zoomedImage.alt} />
|
|
3393
3397
|
`}
|
|
3394
3398
|
</dialog>
|
|
3395
|
-
`}transcriptMessages(){return Au(this.messages,[...this.clientQueuedMessages,...this.status?.queuedMessages??[]])}queueGrew(e){let t=
|
|
3399
|
+
`}transcriptMessages(){return Au(this.messages,[...this.clientQueuedMessages,...this.status?.queuedMessages??[]])}queueGrew(e){let t=ET(e)?.queuedMessages?.length??0;return(this.status?.queuedMessages??[]).length>t}groupedMessages(){let e=this.transcriptMessages();if(this.groupedMessagesInput===e&&this.groupedMessagesStart===this.messageStart)return this.groupedMessagesCache;let t=this.groupedMessagesInput;if(this.groupedMessagesStart===this.messageStart&&t!==void 0){let n=lw(t,this.groupedMessagesCache,e);if(n!==void 0)return this.groupedMessagesInput=e,this.groupedMessagesCache=n,n}return this.groupedMessagesInput=e,this.groupedMessagesStart=this.messageStart,this.groupedMessagesCache=iw(e,this.messageStart),this.groupedMessagesCache}isLiveTailGroup(e,t){return t===e.length-1&&this.isSessionLive()}isSessionLive(){return this.isSendingPrompt||this.status?.isStreaming===!0||this.status?.isCompacting===!0||this.status?.isBashRunning===!0||this.activity?.phase===`active`}syncTurnClock(){if(!this.isSessionLive()){this.turnStartedAtMs=void 0,this.stopTurnClock();return}this.turnStartedAtMs??=Date.now(),this.turnNowMs=Date.now(),this.turnClockTimer===void 0&&(this.turnClockTimer=window.setInterval(()=>{this.turnNowMs=Date.now()},1e3))}stopTurnClock(){this.turnClockTimer!==void 0&&(window.clearInterval(this.turnClockTimer),this.turnClockTimer=void 0)}renderActivityDock(){if(this.pendingAsk!==void 0)return null;if(this.isSendingPrompt)return g`
|
|
3396
3400
|
<div class="activity-dock sending" aria-live="polite">
|
|
3397
3401
|
<span class="state-dots"><span class="state-dot"></span><span class="state-dot"></span><span class="state-dot"></span></span>
|
|
3398
3402
|
<span class="activity-text">Sending your message…</span>
|
|
3399
3403
|
</div>
|
|
3400
|
-
`;let e=this.activityState();if(e===void 0)return null;let t=this.activityCategory(e),n=
|
|
3404
|
+
`;let e=this.activityState();if(e===void 0)return null;let t=this.activityCategory(e),n=iE(this.activityPanelState());if(n!==void 0&&(t===`idle`||t===void 0))return g`
|
|
3401
3405
|
<button
|
|
3402
3406
|
type="button"
|
|
3403
3407
|
class="activity-dock background"
|
|
@@ -3409,13 +3413,13 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3409
3413
|
<span class="activity-text">${n}</span>
|
|
3410
3414
|
<span class="subagent-chevron" aria-hidden="true">›</span>
|
|
3411
3415
|
</button>
|
|
3412
|
-
`;let r=t===`working`?
|
|
3416
|
+
`;let r=t===`working`?ZT(this.turnStartedAtMs,this.turnNowMs):void 0;return g`
|
|
3413
3417
|
<div class=${`activity-dock ${t??``}${r?.long===!0?` long-running`:``}`} aria-live="polite">
|
|
3414
3418
|
${t===`working`?g`<span class="state-dots"><span class="state-dot"></span><span class="state-dot"></span><span class="state-dot"></span></span>`:g`<span class="dot"></span>`}
|
|
3415
3419
|
<span class="activity-text">${this.activityText(e)}</span>
|
|
3416
3420
|
${r===void 0?null:g`<span class="activity-elapsed" aria-hidden="true">${r.text}</span>`}
|
|
3417
3421
|
</div>
|
|
3418
|
-
`}foldDrawerAsWorkFinishes(){let e=this.activityPanelState()?.summary.working===!0,t=
|
|
3422
|
+
`}foldDrawerAsWorkFinishes(){let e=this.activityPanelState()?.summary.working===!0,t=bC({wasWorking:this.drawerWorkWasRunning,working:e});if(this.drawerWorkWasRunning=e,!t)return;let n=this.topDrawerKey();if(!this.expandedTopDrawerKeys.has(n))return;let r=new Set(this.expandedTopDrawerKeys);r.delete(n),this.expandedTopDrawerKeys=r}revealActivity(){let e=this.topDrawerKey(),t=new Set(this.collapsedTopDrawerKeys);t.delete(e);let n=new Set(this.expandedTopDrawerKeys);n.add(e),this.collapsedTopDrawerKeys=t,this.expandedTopDrawerKeys=n,this.topDrawerTab=`activity`,this.activityScope=`active`}renderDeliveryMark(e){let t=e.meta?.delivery;if(!MT(t)||t===void 0)return null;let n=NT(t);return g`
|
|
3419
3423
|
<div class=${`delivery-mark ${n.tone}`} role="status" aria-label=${n.label}>
|
|
3420
3424
|
<span class="delivery-glyph" aria-hidden="true">${n.glyph}</span>
|
|
3421
3425
|
<span class="delivery-text">${n.text}</span>
|
|
@@ -3435,7 +3439,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3435
3439
|
.onSubmit=${this.onSubmitAsk}
|
|
3436
3440
|
></ask-user-card>
|
|
3437
3441
|
`}renderExtensionDialogs(){let e=this.pendingDialogs[0];if(e===void 0&&this.closedDialogs.length===0)return null;let t=this.pendingDialogs.length-1;return g`
|
|
3438
|
-
${
|
|
3442
|
+
${YC(this.closedDialogs,e=>e.dialog.dialogId,e=>g`
|
|
3439
3443
|
<extension-dialog-card
|
|
3440
3444
|
class="closed-dialog-card"
|
|
3441
3445
|
data-scroll-anchor-id=${`closed-dialog:${e.dialog.dialogId}`}
|
|
@@ -3459,7 +3463,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3459
3463
|
<span>The agent is summarizing earlier context. New prompts will be queued until compaction finishes.</span>
|
|
3460
3464
|
${this.pendingMessageCount>0?g`<small>${this.pendingMessageCount} queued ${this.pendingMessageCount===1?`message`:`messages`}</small>`:null}
|
|
3461
3465
|
</aside>
|
|
3462
|
-
`:null}activityState(){let e=this.status;return e===void 0?this.activity?.label:e.isCompacting?`compacting`:e.isBashRunning?`bash`:e.isStreaming?`running`:e.pendingMessageCount>0?`queued`:`idle`}activityCategory(e){return this.activity?.phase===`error`?`error`:e===`idle`||e===`undefined`?nh(this.status)?`asking`:`idle`:nh(this.status)?`asking`:`working`}activityText(e){let t=this.activity;return t===void 0||e!==`idle`&&t.phase===`idle`?e:t.detail!==void 0&&t.detail!==``?`${t.label}: ${t.detail}`:t.label}renderConversationRail(){if(!this.messages.length||this.messageTotal<=0)return null;let e=this.conversationDisplayTotal();return g`<conversation-meter .positionPercent=${this.conversationPositionPercent(e)} .loadedPercent=${this.hasMore?
|
|
3466
|
+
`:null}activityState(){let e=this.status;return e===void 0?this.activity?.label:e.isCompacting?`compacting`:e.isBashRunning?`bash`:e.isStreaming?`running`:e.pendingMessageCount>0?`queued`:`idle`}activityCategory(e){return this.activity?.phase===`error`?`error`:e===`idle`||e===`undefined`?nh(this.status)?`asking`:`idle`:nh(this.status)?`asking`:`working`}activityText(e){let t=this.activity;return t===void 0||e!==`idle`&&t.phase===`idle`?e:t.detail!==void 0&&t.detail!==``?`${t.label}: ${t.detail}`:t.label}renderConversationRail(){if(!this.messages.length||this.messageTotal<=0)return null;let e=this.conversationDisplayTotal();return g`<conversation-meter .positionPercent=${this.conversationPositionPercent(e)} .loadedPercent=${this.hasMore?AT(this.messages.length/e*100):100}></conversation-meter>`}conversationDisplayTotal(){return!this.hasMore&&this.messageStart===0?Math.max(1,this.messages.length):Math.max(1,this.messageTotal,this.messageStart+this.messages.length)}conversationPositionPercent(e=this.conversationDisplayTotal()){if(e<=1)return 100;let t=this.pinnedToBottom?this.messageStart+this.messages.length-1:this.messageStart;return AT(jT(this.currentConversationIndex??t,0,e-1)/(e-1)*100)}renderHistoryBoundary(){let e=this.historyRangeLabel();return this.loadingMore?g`<div class="history-boundary"><span>Loading earlier messages…</span>${e}</div>`:this.hasMore?g`
|
|
3463
3467
|
<div class="history-boundary">
|
|
3464
3468
|
<button type="button" class="history-load-button" ?disabled=${this.loadMoreRequested} @click=${()=>{this.requestLoadMore()}}>Load earlier messages</button>
|
|
3465
3469
|
<span>Scroll up to load earlier messages</span>
|
|
@@ -3472,7 +3476,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3472
3476
|
${e.parts.map(t=>this.renderPart(t,e))}
|
|
3473
3477
|
${this.renderDeliveryMark(e)}
|
|
3474
3478
|
</article>
|
|
3475
|
-
`}renderToolImageOutput(e,t,n){let r=
|
|
3479
|
+
`}renderToolImageOutput(e,t,n){let r=FT(n);return g`
|
|
3476
3480
|
${this.renderScrollMarker(this.messageScrollMarkerId(t))}
|
|
3477
3481
|
<article class="msg tool-image-output" data-index=${t} data-scroll-anchor-id=${this.messageAnchorKey(t)}>
|
|
3478
3482
|
${this.renderMessageHeader(e,String(t),r)}
|
|
@@ -3480,10 +3484,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3480
3484
|
</article>
|
|
3481
3485
|
`}isToolExecutionOnlyMessage(e){return e.role===`tool`&&e.parts.length>0&&e.parts.every(e=>e.type===`toolExecution`)}isAskUserRecordOnlyMessage(e){return e.parts.length>0&&e.parts.every(e=>e.type===`askUserRecord`)}renderMessageGroup(e,t,n,r){let i=this.groupDisclosureKey(t,n,r),a=this.disclosures.isOpen(i,r);return g`
|
|
3482
3486
|
${this.renderScrollMarker(this.groupScrollMarkerId(n))}
|
|
3483
|
-
<details class=${
|
|
3487
|
+
<details class=${BT(r)} data-index=${t} data-scroll-anchor-id=${this.groupAnchorKey(t)} ?open=${a} @toggle=${e=>{this.onGroupToggle(i,e,r)}}>
|
|
3484
3488
|
<summary>
|
|
3485
|
-
<b class="label">${
|
|
3486
|
-
<span>${
|
|
3489
|
+
<b class="label">${VT(r)}</b>
|
|
3490
|
+
<span>${aw(e)}</span>
|
|
3487
3491
|
</summary>
|
|
3488
3492
|
${a?this.renderMessageGroupBody(e,t):null}
|
|
3489
3493
|
</details>
|
|
@@ -3506,7 +3510,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3506
3510
|
</div>
|
|
3507
3511
|
`}queueEntryFor(e){let t=e.meta?.delivery?.clientMessageId;if(t===void 0)return;let n=this.status?.queuedMessages??[],r=n.find(e=>e.clientMessageId===t);if(r!==void 0)return r;let i=/^queued:([^:]+):(.*)$/.exec(t);if(i===null)return;let[,a,o]=i;return n.find(e=>e.kind===a&&e.text===o)}isQueuedLine(e){return this.queueEntryFor(e)!==void 0}renderQueuedBubbleRecall(e){if(this.onRecallQueuedMessage===void 0)return null;let t=this.queueEntryFor(e);return t===void 0?null:g`<button type="button" class="msg-action" data-action="recall" title="Recall: take this message back and put it in the composer" aria-label="Recall this queued message into the composer" @click=${()=>{this.onRecallQueuedMessage?.(t)}}>
|
|
3508
3512
|
<span aria-hidden="true">↩</span>
|
|
3509
|
-
</button>`}renderMessageActions(e,t){let n=this.onResendMessage!==void 0&&
|
|
3513
|
+
</button>`}renderMessageActions(e,t){let n=this.onResendMessage!==void 0&&Dw(e),r=this.renderQueuedBubbleRecall(e);if(!this.isCopyableMessage(e)&&!n&&r===null)return null;let i=this.copiedMessageKey===t;return g`
|
|
3510
3514
|
<div class="msg-actions" aria-label="Message actions">
|
|
3511
3515
|
${r}
|
|
3512
3516
|
${n?g`<button type="button" class="msg-action" title="Edit and send again" aria-label="Put this message back in the composer to send again" @click=${t=>{this.resendMessage(e,t)}}>
|
|
@@ -3516,9 +3520,9 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3516
3520
|
<span aria-hidden="true">${i?`✓`:`⧉`}</span>
|
|
3517
3521
|
</button>`:null}
|
|
3518
3522
|
</div>
|
|
3519
|
-
`}resendMessage(e,t){t.stopPropagation();let n=
|
|
3523
|
+
`}resendMessage(e,t){t.stopPropagation();let n=Ow(e);n!==void 0&&this.onResendMessage?.(n)}onMetaKeydown(e,t,n){e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),this.expandedMetaKey=n?void 0:t)}isCopyableMessage(e){return(e.role===`user`||e.role===`assistant`)&&this.messageCopyText(e)!==``}messageCopyText(e){let t=this.messageCopyTextCache.get(e);if(t!==void 0)return t;let n=e.parts.filter(e=>e.type===`text`).map(e=>e.text.trim()).filter(e=>e!==``).join(`
|
|
3520
3524
|
|
|
3521
|
-
`);return this.messageCopyTextCache.set(e,n),n}async copyNotification(e){if(!await cS(e.message))return;let t=e.id;this.copiedNotificationId=t,setTimeout(()=>{this.copiedNotificationId===t&&(this.copiedNotificationId=void 0)},1200)}async copyMessage(e,t,n){n.stopPropagation(),await cS(this.messageCopyText(e))&&(this.copiedMessageKey=t,window.setTimeout(()=>{this.copiedMessageKey===t&&(this.copiedMessageKey=void 0)},1200))}messageMetaLabel(e){let t=this.messageMetaCache.get(e);if(t!==void 0)return t;let n=
|
|
3525
|
+
`);return this.messageCopyTextCache.set(e,n),n}async copyNotification(e){if(!await cS(e.message))return;let t=e.id;this.copiedNotificationId=t,setTimeout(()=>{this.copiedNotificationId===t&&(this.copiedNotificationId=void 0)},1200)}async copyMessage(e,t,n){n.stopPropagation(),await cS(this.messageCopyText(e))&&(this.copiedMessageKey=t,window.setTimeout(()=>{this.copiedMessageKey===t&&(this.copiedMessageKey=void 0)},1200))}messageMetaLabel(e){let t=this.messageMetaCache.get(e);if(t!==void 0)return t;let n=UT(e);return this.messageMetaCache.set(e,n),n}renderPart(e,t){if(e.type===`text`&&t?.role===`bash`)return g`<pre class="part shell-output">${e.text}</pre>`;if(e.type===`text`)return g`<formatted-text class="part" .text=${e.text}></formatted-text>`;if(e.type===`thinking`)return g`<details class="part"><summary>thinking</summary><formatted-text .text=${e.text}></formatted-text></details>`;if(e.type===`skillInvocation`)return g`
|
|
3522
3526
|
<details class="part skill-invocation">
|
|
3523
3527
|
<summary><b>[skill]</b> ${e.name}</summary>
|
|
3524
3528
|
<small>${e.location}</small>
|
|
@@ -3535,46 +3539,46 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3535
3539
|
.outcome=${e.outcome}
|
|
3536
3540
|
.draftSessionId=${this.askDraftSessionId}
|
|
3537
3541
|
></ask-user-card>
|
|
3538
|
-
`;if(e.type===`image`){let{src:t,alt:n}=
|
|
3542
|
+
`;if(e.type===`image`){let{src:t,alt:n}=PT(e);return g`<img class="part chat-image" src=${t} alt=${n} loading="lazy" role="button" tabindex="0" title="Click to enlarge" @load=${this.onImageLoad} @click=${()=>{this.openImageZoom(t,n)}} @keydown=${e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this.openImageZoom(t,n))}} />`}return e.type===`toolCall`?g`<div class="part tool-line">▶ ${e.toolName}<span class="summary">${e.summary}</span></div>`:e.type===`toolExecution`?g`<tool-execution-view class="part" .execution=${e}></tool-execution-view>`:e.type===`toolResult`?g`
|
|
3539
3543
|
<details class="part" ?open=${e.isError}>
|
|
3540
3544
|
<summary>${e.isError?`✖`:`✓`} ${e.toolName} result</summary>
|
|
3541
3545
|
<formatted-text .text=${e.text}></formatted-text>
|
|
3542
3546
|
</details>
|
|
3543
|
-
`:null}onGroupToggle(e,t,n){let r=t.currentTarget;r instanceof HTMLDetailsElement&&this.disclosures.applyToggle(e,r.open,n)&&this.requestUpdate()}onScroll(){this.requestLoadMoreIfNeeded(),this.updatePinnedToBottomFromScroll(),this.scheduleConversationRailUpdate(),this.suppressScrollSave||this.scheduleScrollPositionSave()}onWheel(e){e.deltaY<0&&this.canScrollUp()&&(this.pinnedToBottom=!1)}onTouchStart(e){this.touchStartY=e.touches[0]?.clientY}onTouchMove(e){let t=e.touches[0]?.clientY;this.touchStartY!==void 0&&t!==void 0&&t>this.touchStartY&&this.canScrollUp()&&(this.pinnedToBottom=!1)}updatePinnedToBottomFromScroll(){let e=this.chat;if(!e)return;let t=this.didChatHeightChange(),n=this.pinnedToBottom,r=e.scrollTop<this.lastScrollTop;if(t&&n){this.lastClientHeight=e.clientHeight,this.scrollToBottom();return}this.isAtBottom()?this.pinnedToBottom=!0:r?this.pinnedToBottom=!1:this.pinnedToBottom=this.isNearBottom(),this.jumpToBottomVisible=LC(e),this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight}didChatHeightChange(){let e=this.chat;return e!==void 0&&this.lastClientHeight!==0&&e.clientHeight!==this.lastClientHeight}isPrependingMessages(e){let t=e.get(`messageStart`);return typeof t==`number`&&this.messageStart<t}requestLoadMoreIfNeeded(){this.loadMoreCheckFrame===void 0&&(this.loadMoreCheckFrame=requestAnimationFrame(()=>{if(this.loadMoreCheckFrame=void 0,this.suppressLoadMoreRequests)return;let e=this.chat;e&&_w({hasMore:this.hasMore,loadingMore:this.loadingMore||this.loadMoreRequested,canRequest:this.onLoadMore!==void 0,scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight})&&this.requestLoadMore()}))}requestLoadMore(){this.loadMoreRequested||!this.hasMore||this.loadingMore||this.onLoadMore===void 0||(this.loadMoreRequested=!0,this.onLoadMore())}isNearBottom(){let e=this.chat;return!e||jC(e)}isAtBottom(){let e=this.chat;return!e||AC(e)<2}canScrollUp(){let e=this.chat;return e!==void 0&&e.scrollTop>0}scrollToBottom(){this.scrollToBottomFrame===void 0&&(this.scrollToBottomFrame=requestAnimationFrame(()=>{this.scrollToBottomFrame=void 0;let e=this.chat;e&&this.withSuppressedScrollSave(()=>{e.scrollTop=e.scrollHeight,this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight})}))}isNewPendingAsk(e){return this.pendingAsk!==void 0&&(typeof e!=`object`||!e||Reflect.get(e,`askId`)!==this.pendingAsk.askId)}isNewOpenDialog(e){let t=this.pendingDialogs[0];if(t===void 0)return!1;if(!Array.isArray(e))return!0;let n=e[0];return typeof n!=`object`||!n||Reflect.get(n,`dialogId`)!==t.dialogId}scrollToOpenAsk(){this.scrollToOpenAskFrame===void 0&&(this.scrollToBottomFrame!==void 0&&(cancelAnimationFrame(this.scrollToBottomFrame),this.scrollToBottomFrame=void 0),this.scrollToOpenAskFrame=requestAnimationFrame(()=>{this.scrollToOpenAskFrame=void 0,this.withSuppressedScrollSave(()=>{this.alignOpenAskToTop()})}))}alignOpenAskToTop(){let e=this.chat,t=this.renderRoot.querySelector(`.chat > ask-user-card`);return e===void 0||t===null?!1:(e.scrollTop+=t.getBoundingClientRect().top-e.getBoundingClientRect().top,this.syncScrollMetrics(),this.pinnedToBottom=this.isNearBottom(),!0)}scrollToOpenDialog(){this.scrollToOpenDialogFrame===void 0&&(this.scrollToBottomFrame!==void 0&&(cancelAnimationFrame(this.scrollToBottomFrame),this.scrollToBottomFrame=void 0),this.scrollToOpenDialogFrame=requestAnimationFrame(()=>{this.scrollToOpenDialogFrame=void 0,this.withSuppressedScrollSave(()=>{this.alignOpenDialogToTop()})}))}alignOpenDialogToTop(){let e=this.chat,t=this.renderRoot.querySelector(`.chat > extension-dialog-card.open-dialog-card`);return e===void 0||t===null?!1:(e.scrollTop+=t.getBoundingClientRect().top-e.getBoundingClientRect().top,this.syncScrollMetrics(),this.pinnedToBottom=this.isNearBottom(),!0)}restoreScrollPosition(){let e=this.sessionId;this.restoreScrollFrame!==void 0&&cancelAnimationFrame(this.restoreScrollFrame),this.restoreScrollFrame=requestAnimationFrame(()=>{this.restoreScrollFrame=void 0,this.sessionId===e&&this.withSuppressedScrollSave(()=>{if(this.pendingAsk!==void 0&&this.scrollController.readPosition(e)===void 0&&this.alignOpenAskToTop()||this.pendingDialogs.length>0&&this.scrollController.readPosition(e)===void 0&&this.alignOpenDialogToTop())return;let t=this.scrollController.restorePosition(e,this.chat,this.scrollAnchorElements(),{fallbackToBottom:this.shouldFallbackToBottomForMissingAnchor()});this.handleScrollRestoreResult(e,t)})})}continuePendingScrollRestore(){let e=this.pendingScrollRestoreSessionId,t=this.pendingScrollRestorePosition;e===void 0||t===void 0||e!==this.sessionId||this.restoreScrollFrame!==void 0||(this.restoreScrollFrame=requestAnimationFrame(()=>{this.restoreScrollFrame=void 0,this.sessionId===e&&this.withSuppressedScrollSave(()=>{let n=this.scrollController.restoreExplicitPosition(t,this.chat,this.scrollAnchorElements(),{fallbackToBottom:this.shouldFallbackToBottomForMissingAnchor()});this.handleScrollRestoreResult(e,n)})}))}handleScrollRestoreResult(e,t){if(this.syncScrollMetrics(),t.status!==`missing`){this.updatePinnedToBottomAfterRestore(t.status),(t.status===`restored`||t.status===`bottom`)&&this.cancelPrependRestore(),this.pendingScrollRestoreSessionId=void 0,this.pendingScrollRestorePosition=void 0;return}this.pinnedToBottom=!1,this.pendingScrollRestoreSessionId=e,this.pendingScrollRestorePosition=t.position;let n=this.chat;n===void 0||!this.hasMore||this.loadingMore||(n.scrollTop=0,this.syncScrollMetrics(),this.requestLoadMore())}shouldFallbackToBottomForMissingAnchor(){return!this.hasMore}updatePinnedToBottomAfterRestore(e){e===`bottom`?this.pinnedToBottom=!0:e===`restored`&&(this.pinnedToBottom=this.isNearBottom())}syncScrollMetrics(){let e=this.chat;e!==void 0&&(this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight)}cancelPrependRestore(){this.prependRestoreToken+=1,this.suppressLoadMoreRequests=!1}capturePrependScrollAnchor(){let e=this.chat;if(e)return lw(e,this.scrollMarkers())}restorePrependScrollAnchor(e){if(!this.chat||!e)return;this.suppressLoadMoreRequests=!0,this.suppressScrollSave=!0;let t=this.prependRestoreToken+1;this.prependRestoreToken=t;let n=0,r=()=>{let i=this.chat;if(!(!i||t!==this.prependRestoreToken)){if(uw(i,e,e.markerId===void 0?void 0:this.scrollMarkerAt(e.markerId)),this.lastScrollTop=i.scrollTop,n+=1,n<30){requestAnimationFrame(r);return}requestAnimationFrame(()=>{t===this.prependRestoreToken&&(this.suppressScrollSave=!1,this.suppressLoadMoreRequests=!1)})}};r()}saveScrollPosition(e=this.sessionId){e&&this.scrollController.savePosition(e,this.chat,this.scrollAnchorElements())}scheduleScrollPositionSave(){let e=this.sessionId;this.scrollController.scheduleSave(e,e=>{this.sessionId===e&&this.saveScrollPosition(e)})}scheduleConversationRailUpdate(){this.conversationRailFrame===void 0&&(this.conversationRailFrame=requestAnimationFrame(()=>{this.conversationRailFrame=void 0,this.updateConversationRailPosition()}))}updateConversationRailPosition(){if(!this.messages.length||this.messageTotal<=0){this.currentConversationIndex=void 0;return}let e=this.conversationDisplayTotal(),t=this.firstVisibleArticle(),n=Number(t?.dataset.index);if(Number.isFinite(n)){this.currentConversationIndex=AT(n,0,Math.max(0,e-1));return}this.currentConversationIndex=AT(this.pinnedToBottom?this.messageStart+this.messages.length-1:this.messageStart,0,Math.max(0,e-1))}scrollMarkers(){return Array.from(this.renderRoot.querySelectorAll(`.scroll-marker`))}scrollMarkerAt(e){return this.scrollMarkers().find(t=>t.dataset.markerId===e)}firstVisibleArticle(){let e=this.chat;if(e!==void 0)return PC(e,Array.from(this.renderRoot.querySelectorAll(`article.msg`)))??PC(e,this.articles())}articles(){return Array.from(this.renderRoot.querySelectorAll(`article.msg, details.msg`))}scrollAnchorElements(){return Array.from(this.renderRoot.querySelectorAll(`[data-scroll-anchor-id]`))}withSuppressedScrollSave(e){this.suppressScrollSave=!0,e(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.suppressScrollSave=!1})})}groupDisclosureKey(e,t,n){return n?`${this.sessionId}:live:${String(e)}`:`${this.sessionId}:${String(t)}`}messageAnchorKey(e){return FT(e)}groupRenderKey(e){return IT(e)}groupAnchorKey(e){return IT(e)}eventAnchorKey(e){return LT(e)}messageScrollMarkerId(e){return FT(e)}groupScrollMarkerId(e){return RT(e)}static{this.styles=Jg}};H([b({attribute:!1})],K.prototype,`messages`,void 0),H([b()],K.prototype,`sessionId`,void 0),H([b({type:Number})],K.prototype,`messageStart`,void 0),H([b({type:Number})],K.prototype,`messageEnd`,void 0),H([b({type:Number})],K.prototype,`messageTotal`,void 0),H([b({type:Boolean})],K.prototype,`hasMore`,void 0),H([b({type:Boolean})],K.prototype,`loadingMore`,void 0),H([b({type:Boolean})],K.prototype,`isSendingPrompt`,void 0),H([b({type:Boolean})],K.prototype,`isCompacting`,void 0),H([b({type:Number})],K.prototype,`pendingMessageCount`,void 0),H([b({attribute:!1})],K.prototype,`clientQueuedMessages`,void 0),H([b({attribute:!1})],K.prototype,`status`,void 0),H([b({attribute:!1})],K.prototype,`activity`,void 0),H([b({attribute:!1})],K.prototype,`pendingAsk`,void 0),H([b({attribute:!1})],K.prototype,`askDraftSessionId`,void 0),H([b({attribute:!1})],K.prototype,`onSubmitAsk`,void 0),H([b({attribute:!1})],K.prototype,`pendingDialogs`,void 0),H([b({attribute:!1})],K.prototype,`closedDialogs`,void 0),H([b({attribute:!1})],K.prototype,`onAnswerDialog`,void 0),H([b({attribute:!1})],K.prototype,`onCancelDialog`,void 0),H([b({attribute:!1})],K.prototype,`onDismissClosedDialog`,void 0),H([b({attribute:!1})],K.prototype,`onResendMessage`,void 0),H([b({attribute:!1})],K.prototype,`notificationInbox`,void 0),H([b({attribute:!1})],K.prototype,`subagents`,void 0),H([b({attribute:!1})],K.prototype,`subagentRuns`,void 0),H([b({attribute:!1})],K.prototype,`backgroundTasks`,void 0),H([b({attribute:!1})],K.prototype,`onOpenBackgroundTask`,void 0),H([b({attribute:!1})],K.prototype,`onOpenSubagentRun`,void 0),H([b({attribute:!1})],K.prototype,`onOpenSubagent`,void 0),H([b({attribute:!1})],K.prototype,`onClearServerQueue`,void 0),H([b({attribute:!1})],K.prototype,`onRecallQueuedMessage`,void 0),H([b({attribute:!1})],K.prototype,`onDismissWarning`,void 0),H([b({attribute:!1})],K.prototype,`onDismissNotification`,void 0),H([b({attribute:!1})],K.prototype,`onDismissAllNotifications`,void 0),H([b({type:Boolean})],K.prototype,`warningsVisible`,void 0),H([b({attribute:!1})],K.prototype,`onToggleWarnings`,void 0),H([b({attribute:!1})],K.prototype,`onLoadMore`,void 0),H([b({attribute:!1})],K.prototype,`activityOutput`,void 0),H([b({attribute:!1})],K.prototype,`onCloseActivityOutput`,void 0),H([S(`.chat`)],K.prototype,`chat`,void 0),H([S(`.drawer-tabs`)],K.prototype,`drawerTabs`,void 0),H([S(`dialog.image-zoom`)],K.prototype,`imageZoomDialog`,void 0),H([S(`dialog.activity-output`)],K.prototype,`activityOutputDialog`,void 0),H([x()],K.prototype,`pinnedToBottom`,void 0),H([x()],K.prototype,`jumpToBottomVisible`,void 0),H([x()],K.prototype,`zoomedImage`,void 0),H([x()],K.prototype,`expandedMetaKey`,void 0),H([x()],K.prototype,`copiedNotificationId`,void 0),H([x()],K.prototype,`copiedMessageKey`,void 0),H([x()],K.prototype,`currentConversationIndex`,void 0),H([x()],K.prototype,`collapsedTopDrawerKeys`,void 0),H([x()],K.prototype,`expandedTopDrawerKeys`,void 0),H([b({attribute:!1})],K.prototype,`goals`,void 0),H([b({attribute:!1})],K.prototype,`onRunGoalCommand`,void 0),H([x()],K.prototype,`topDrawerTab`,void 0),H([x()],K.prototype,`activityFilter`,void 0),H([x()],K.prototype,`activityScope`,void 0),H([x()],K.prototype,`turnStartedAtMs`,void 0),H([x()],K.prototype,`turnNowMs`,void 0),H([x()],K.prototype,`retainedEmptyNotificationTrayTargetKey`,void 0),H([x()],K.prototype,`loadMoreRequested`,void 0),K=H([y(`chat-view`)],K);function GT(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${String(t)}s`;let n=Math.floor(t/60);return n<60?`${String(n)}m ${String(t%60)}s`:`${String(Math.floor(n/60))}h ${String(n%60)}m`}function KT(e){return e.map(e=>{let t=e.status===`running`?`Running`:e.status===`done`?`Done`:e.status===`failed`?`Failed`:e.status===`lost`?`Lost`:`Unknown`,n=GT(e.elapsedMs),r=e.status===`running`?e.lastActivity??`working`:e.task??``,i=Bw(e.model);return{run:e,status:e.status,statusLabel:t,duration:n,detail:r,...i===void 0?{}:{modelLabel:i.label,modelTitle:e.model??i.label},ariaLabel:`${t} ${e.agent} subagent, ${n}`+(i===void 0?``:`, on ${i.label}`)+(r===``?``:`, ${r}`)}})}function qT(e){return e.map(e=>{let t=e.status===`running`?`running`:e.status===`completed`?`done`:e.status===`killed`?`stopped`:e.status===`failed`?`failed`:e.status===`lost`?`lost`:`unknown`,n=e.status===`completed`?`Done`:e.status===`running`?`Running`:e.status===`killed`?`Stopped`:e.status===`lost`?`Lost`:e.status.charAt(0).toUpperCase()+e.status.slice(1),r=GT(e.durationMs??0),i=t===`running`?e.command.slice(0,60):e.exitCode===void 0?``:`exit ${String(e.exitCode)}`;return{task:e,status:t,statusLabel:n,duration:r,detail:i,ariaLabel:`${n} background task ${e.name}, ${r}${i===``?``:`, ${i}`}`}})}function JT(e){return[...e].sort((e,t)=>{let n=Number(ZT(t.status))-Number(ZT(e.status));if(n!==0)return n;let r=Number(QT(e.status))-Number(QT(t.status));if(r!==0)return r;let i=(t.startedAt??``).localeCompare(e.startedAt??``);return i===0?e.kind.localeCompare(t.kind):i})}var YT=600*1e3;function XT(e,t){if(e===void 0)return;let n=Math.max(0,t-e);if(!(n<5e3))return{text:GT(n),long:n>=YT}}function ZT(e){return e===`working`||e===`running`}function QT(e){return e===`done`||e===`failed`||e===`error`||e===`lost`||e===`stopped`}function $T(e){return e.active>0?`Activity · ${String(e.active)} running`:`Activity (${String(e.total)})`}function eE(e){let t=[{id:`subagents`,label:`Subagents`,count:e.rows.length},{id:`runs`,label:`Agent runs`,count:e.runRows.length},{id:`tasks`,label:`Tasks`,count:e.taskRows.length}].filter(e=>e.count>0);return t.length<=1?t.length===0?[]:t:[{id:`all`,label:`All`,count:e.rows.length+e.runRows.length+e.taskRows.length},...t]}function tE(e,t){return e===`subagents`&&t.rows.length>0?`subagents`:e===`runs`&&t.runRows.length>0?`runs`:e===`tasks`&&t.taskRows.length>0?`tasks`:`all`}var nE=`Work this chat started in the background: subagents, agent tool runs and terminal tasks. Open one to read its output.`;function rE(e){if(e===void 0)return;let t=[...e.rows,...e.runRows,...e.taskRows].filter(e=>e.status===`working`||e.status===`running`).length;if(t!==0)return t===1?`idle · 1 background run`:`idle · ${String(t)} background runs`}function iE(){return!1}function aE(e,t){return t===`activity`&&e.activity?`activity`:t===`notifications`&&e.notifications?`notifications`:t===`goals`&&e.goals===!0?`goals`:e.notifications?`notifications`:e.activity?`activity`:e.goals===!0?`goals`:`activity`}function oE(e){let t=t=>e.filter(t).length,n=t(e=>e===`working`||e===`running`),r=t(e=>e===`error`||e===`failed`),i=t(e=>e===`stopped`),a=t(e=>e===`lost`),o=e.length-n-r-i-a,s=[];return n>0&&s.push(`${String(n)} running`),r>0&&s.push(`${String(r)} failed`),o>0&&s.push(`${String(o)} done`),i>0&&s.push(`${String(i)} stopped`),a>0&&s.push(`${String(a)} lost`),{label:s.join(` · `),working:n>0,failed:r>0}}function sE(e){return e===``?`Unknown`:e.charAt(0).toUpperCase()+e.slice(1)}function cE(e){return e.map(e=>{let t=e.status,n=e.sessionId.slice(-8),r=sE(t);return{subagent:e,shortId:n,status:t,statusLabel:r,cwd:e.cwd,ariaLabel:`${r} subagent ${n}`}})}var lE=new Set([`image/jpeg`,`image/png`,`image/gif`,`image/webp`]);function uE(e){return typeof e==`string`&&lE.has(e)}function dE(e){switch(e){case`image/jpeg`:return`jpg`;case`image/png`:return`png`;case`image/gif`:return`gif`;case`image/webp`:return`webp`;default:return`bin`}}var fE=`application/octet-stream`,pE=`Failed to read an attachment.`;async function mE(e,t){let n=[],r;for(let i of e)try{let e=await t(i);n.push(vE(i,e))}catch{r=pE}return{attachments:n,...r===void 0?{}:{error:r}}}function hE(e){return e.kind===`image`&&uE(e.mimeType)}function gE(e){return e.every(e=>hE(e))}function _E(e,t){return gE(t)?e:`folder`}function vE(e,t){return uE(e.type)?{kind:`image`,name:bE(e),mimeType:e.type,data:t,size:e.size}:{kind:`file`,name:bE(e),mimeType:yE(e),data:t,size:e.size}}function yE(e){let t=e.type.trim();return t===``?fE:t}function bE(e){return e.name===``?uE(e.type)?`pasted-image.${dE(e.type)}`:`pasted-file.bin`:e.name}var xE=50,SE=`pi-web:prompt-history:`;function CE(e){return`${SE}${e}`}function wE(e){try{let t=localStorage.getItem(CE(e));if(t===null||t===``)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.trim()!==``):[]}catch{return[]}}function TE(e,t){try{localStorage.setItem(CE(e),JSON.stringify(t.slice(0,xE)))}catch{}}function EE(e,t){let n=t.trim();if(n===``)return wE(e);let r=[n,...wE(e).filter(e=>e!==n)].slice(0,xE);return TE(e,r),r}function DE(e,t){let n=wE(e),r=t.trim().toLowerCase();if(r===``)return n;let i=r.split(/\s+/u).filter(Boolean);return n.filter(e=>{let t=e.toLowerCase();return i.every(e=>t.includes(e)||OE(e,t))})}function OE(e,t){let n=0;for(let r of e){if(n=t.indexOf(r,n),n===-1)return!1;n+=r.length}return!0}function kE(e){return e===`older`?1:-1}var AE=`(pointer: coarse), (max-width: 760px)`,jE=`pi-web.promptEnterPreference`;function ME(){return typeof window<`u`&&`matchMedia`in window?window.matchMedia(AE):void 0}function NE(e){return e===`send`||e===`newline`?e:`auto`}function PE(e=zE()){if(e===void 0)return`auto`;try{return NE(e.getItem(jE))}catch{return`auto`}}function FE(e,t=zE()){if(t!==void 0)try{t.setItem(jE,e)}catch{}}function IE(e=ME(),t=PE()){return t===`send`||t!==`newline`&&e?.matches!==!0}function LE(e,t,n=ME()){return e?n?.matches!==!0||t:!1}function RE(e,t=ME(),n=PE()){let r=IE(t,n);return e?!r:r}function zE(){if(!(typeof window>`u`))try{return window.localStorage}catch{return}}var BE=100;function VE(){let e,t,n,r,i=[],a=()=>{r!==void 0&&(window.clearInterval(r),r=void 0),e?.getTracks().forEach(e=>{e.stop()}),e=void 0,n?.close().catch(()=>void 0),n=void 0,t=void 0};return{async start(a){i=[],e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=new MediaRecorder(e),t.addEventListener(`dataavailable`,e=>{e.data.size>0&&i.push(e.data)}),t.start(),n=new AudioContext;let o=n.createMediaStreamSource(e),s=n.createAnalyser();s.fftSize=512,o.connect(s);let c=new Uint8Array(s.fftSize);r=window.setInterval(()=>{s.getByteTimeDomainData(c),a(HE(c),BE)},BE)},stop(){let e=t;return e===void 0?(a(),Promise.resolve(new Blob([]))):new Promise(t=>{e.addEventListener(`stop`,()=>{let e=i[0]?.type??`audio/webm`,n=new Blob(i,{type:e});a(),t(n)},{once:!0}),e.stop()})},cancel(){i=[],t?.state===`recording`&&t.stop(),a()}}}function HE(e){let t=0;for(let n of e){let e=Math.abs(n-128)/128;e>t&&(t=e)}return t}function UE(e){return e!==void 0&&e.endpoint.trim()!==``}async function WE(e,t,n){if(!UE(t))return{ok:!1,message:`Dictation is not configured.`};if(e.size===0)return{ok:!1,message:`Nothing was recorded.`};let r=new FormData;r.append(`file`,e,`speech.webm`),t.model!==void 0&&t.model!==``&&r.append(`model`,t.model),t.language!==void 0&&t.language!==``&&r.append(`language`,t.language);let i;try{i=await n.fetch(t.endpoint,{method:`POST`,body:r,...n.signal===void 0?{}:{signal:n.signal}})}catch(e){return{ok:!1,message:`Could not reach the transcription service: ${qE(e)}`}}if(!i.ok)return{ok:!1,message:`Transcription failed (${String(i.status)}).`};let a;try{a=await i.json()}catch{return{ok:!1,message:`The transcription service returned a response that could not be read.`}}let o=GE(a);if(o===void 0)return{ok:!1,message:`The transcription service returned no text.`};let s=o.trim();return s===``?{ok:!1,message:`No speech was recognised.`}:{ok:!0,text:s}}function GE(e){if(typeof e==`string`)return e;let t=KE(e);if(t===void 0)return;for(let e of[`text`,`transcript`,`transcription`]){let n=t[e];if(typeof n==`string`)return n}let n=t.segments;if(!Array.isArray(n))return;let r=n.map(e=>KE(e)?.text).filter(e=>typeof e==`string`).join(` `);return r.trim()===``?void 0:r}function KE(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e))t[n]=r;return t}function qE(e){return e instanceof Error?e.message:String(e)}var JE={"openai-realtime":`append`,deepgram:`replace`,"azure-speech":`replace`};function YE(e){if(e===void 0)return{kind:`unavailable`,reason:`Live transcription is not configured.`};if(e.protocol===`browser`)return{kind:`browser`};let t=e.url?.trim();if(t===void 0||t===``)return{kind:`unavailable`,reason:`Streaming transcription needs a socket url.`};let n=e.tokenEndpoint?.trim();return n===void 0||n===``?{kind:`unavailable`,reason:`Streaming transcription needs a token endpoint so the account key stays on the server.`}:{kind:`socket`,protocol:e.protocol,url:t,tokenEndpoint:n,deltaMode:JE[e.protocol]}}var XE={trailingSilenceMs:900,speechThreshold:.02,maxUtteranceMs:12e4};function ZE(e,t,n,r=XE){if(e.kind!==`listening`&&e.kind!==`speaking`&&e.kind!==`trailing`)return e;if(n>=r.maxUtteranceMs)return e.kind===`listening`?{kind:`idle`}:{kind:`transcribing`};let i=t.level>=r.speechThreshold;if(e.kind===`listening`)return i?{kind:`speaking`}:e;if(e.kind===`speaking`)return i?e:{kind:`trailing`,silenceMs:t.elapsedMs};if(i)return{kind:`speaking`};let a=e.silenceMs+t.elapsedMs;return a>=r.trailingSilenceMs?{kind:`transcribing`}:{kind:`trailing`,silenceMs:a}}function QE(e){switch(e.kind){case`idle`:case`denied`:case`error`:return{kind:`listening`};case`listening`:return{kind:`idle`};case`speaking`:case`trailing`:return{kind:`transcribing`};case`transcribing`:case`unavailable`:return e}}function $E(e){return e.kind===`listening`||e.kind===`speaking`||e.kind===`trailing`}function eD(e,t){switch(e.kind){case`idle`:return t?.streaming===!0?`Dictate live`:`Dictate`;case`listening`:return`Listening…`;case`speaking`:return`Listening…`;case`trailing`:return`Listening…`;case`transcribing`:return`Transcribing…`;case`denied`:return`Microphone permission denied`;case`unavailable`:return e.reason;case`error`:return e.message}}var tD=class{constructor(e,t){this.deps=e,this.callbacks=t,this.state={kind:`idle`},this.elapsedMs=0}getState(){return this.state}async toggle(e){if(!UE(e)){this.setState({kind:`unavailable`,reason:`Dictation is not configured.`});return}let t=QE(this.state);if(t.kind===`listening`&&!$E(this.state)){await this.startListening(e);return}if(t.kind===`idle`){this.deps.recorder.cancel(),this.setState({kind:`idle`});return}if(t.kind===`transcribing`){await this.finish(e);return}this.setState(t)}async startListening(e){this.activeConfig=e,this.elapsedMs=0,this.setState({kind:`listening`});try{await this.deps.recorder.start((e,t)=>{this.onFrame(e,t)})}catch(e){this.setState(nD(e)?{kind:`denied`}:{kind:`error`,message:`Microphone unavailable: ${rD(e)}`})}}onFrame(e,t){if(!$E(this.state))return;this.elapsedMs+=t;let n=ZE(this.state,{level:e,elapsedMs:t},this.elapsedMs,this.deps.captureConfig??XE);if(n!==this.state){if(n.kind===`transcribing`){this.finish(this.activeConfig);return}n.kind===`idle`&&this.deps.recorder.cancel(),this.setState(n)}}async finish(e){this.setState({kind:`transcribing`});let t;try{t=await this.deps.recorder.stop()}catch(e){this.setState({kind:`error`,message:`Recording failed: ${rD(e)}`});return}if(!UE(e)){this.setState({kind:`unavailable`,reason:`Dictation is not configured.`});return}let n=await(this.deps.transcribe??WE)(t,e,{fetch:this.deps.fetch??globalThis.fetch});if(!n.ok){this.setState({kind:`error`,message:n.message});return}this.callbacks.onTranscript(n.text),this.setState({kind:`idle`})}setState(e){this.state=e,this.callbacks.onState(e)}};function nD(e){if(typeof e!=`object`||!e)return!1;let t=`name`in e?e.name:void 0;return t===`NotAllowedError`||t===`SecurityError`}function rD(e){return e instanceof Error?e.message:String(e)}function iD(){return Ye`
|
|
3547
|
+
`:null}onGroupToggle(e,t,n){let r=t.currentTarget;r instanceof HTMLDetailsElement&&this.disclosures.applyToggle(e,r.open,n)&&this.requestUpdate()}onScroll(){this.requestLoadMoreIfNeeded(),this.updatePinnedToBottomFromScroll(),this.scheduleConversationRailUpdate(),this.suppressScrollSave||this.scheduleScrollPositionSave()}onWheel(e){e.deltaY<0&&this.canScrollUp()&&(this.pinnedToBottom=!1)}onTouchStart(e){this.touchStartY=e.touches[0]?.clientY}onTouchMove(e){let t=e.touches[0]?.clientY;this.touchStartY!==void 0&&t!==void 0&&t>this.touchStartY&&this.canScrollUp()&&(this.pinnedToBottom=!1)}updatePinnedToBottomFromScroll(){let e=this.chat;if(!e)return;let t=this.didChatHeightChange(),n=this.pinnedToBottom,r=e.scrollTop<this.lastScrollTop;if(t&&n){this.lastClientHeight=e.clientHeight,this.scrollToBottom();return}this.isAtBottom()?this.pinnedToBottom=!0:r?this.pinnedToBottom=!1:this.pinnedToBottom=this.isNearBottom(),this.jumpToBottomVisible=RC(e),this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight}didChatHeightChange(){let e=this.chat;return e!==void 0&&this.lastClientHeight!==0&&e.clientHeight!==this.lastClientHeight}isPrependingMessages(e){let t=e.get(`messageStart`);return typeof t==`number`&&this.messageStart<t}requestLoadMoreIfNeeded(){this.loadMoreCheckFrame===void 0&&(this.loadMoreCheckFrame=requestAnimationFrame(()=>{if(this.loadMoreCheckFrame=void 0,this.suppressLoadMoreRequests)return;let e=this.chat;e&&vw({hasMore:this.hasMore,loadingMore:this.loadingMore||this.loadMoreRequested,canRequest:this.onLoadMore!==void 0,scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight})&&this.requestLoadMore()}))}requestLoadMore(){this.loadMoreRequested||!this.hasMore||this.loadingMore||this.onLoadMore===void 0||(this.loadMoreRequested=!0,this.onLoadMore())}isNearBottom(){let e=this.chat;return!e||MC(e)}isAtBottom(){let e=this.chat;return!e||jC(e)<2}canScrollUp(){let e=this.chat;return e!==void 0&&e.scrollTop>0}scrollToBottom(){this.scrollToBottomFrame===void 0&&(this.scrollToBottomFrame=requestAnimationFrame(()=>{this.scrollToBottomFrame=void 0;let e=this.chat;e&&this.withSuppressedScrollSave(()=>{e.scrollTop=e.scrollHeight,this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight})}))}isNewPendingAsk(e){return this.pendingAsk!==void 0&&(typeof e!=`object`||!e||Reflect.get(e,`askId`)!==this.pendingAsk.askId)}isNewOpenDialog(e){let t=this.pendingDialogs[0];if(t===void 0)return!1;if(!Array.isArray(e))return!0;let n=e[0];return typeof n!=`object`||!n||Reflect.get(n,`dialogId`)!==t.dialogId}scrollToOpenAsk(){this.scrollToOpenAskFrame===void 0&&(this.scrollToBottomFrame!==void 0&&(cancelAnimationFrame(this.scrollToBottomFrame),this.scrollToBottomFrame=void 0),this.scrollToOpenAskFrame=requestAnimationFrame(()=>{this.scrollToOpenAskFrame=void 0,this.withSuppressedScrollSave(()=>{this.alignOpenAskToTop()})}))}alignOpenAskToTop(){let e=this.chat,t=this.renderRoot.querySelector(`.chat > ask-user-card`);return e===void 0||t===null?!1:(e.scrollTop+=t.getBoundingClientRect().top-e.getBoundingClientRect().top,this.syncScrollMetrics(),this.pinnedToBottom=this.isNearBottom(),!0)}scrollToOpenDialog(){this.scrollToOpenDialogFrame===void 0&&(this.scrollToBottomFrame!==void 0&&(cancelAnimationFrame(this.scrollToBottomFrame),this.scrollToBottomFrame=void 0),this.scrollToOpenDialogFrame=requestAnimationFrame(()=>{this.scrollToOpenDialogFrame=void 0,this.withSuppressedScrollSave(()=>{this.alignOpenDialogToTop()})}))}alignOpenDialogToTop(){let e=this.chat,t=this.renderRoot.querySelector(`.chat > extension-dialog-card.open-dialog-card`);return e===void 0||t===null?!1:(e.scrollTop+=t.getBoundingClientRect().top-e.getBoundingClientRect().top,this.syncScrollMetrics(),this.pinnedToBottom=this.isNearBottom(),!0)}restoreScrollPosition(){let e=this.sessionId;this.restoreScrollFrame!==void 0&&cancelAnimationFrame(this.restoreScrollFrame),this.restoreScrollFrame=requestAnimationFrame(()=>{this.restoreScrollFrame=void 0,this.sessionId===e&&this.withSuppressedScrollSave(()=>{if(this.pendingAsk!==void 0&&this.scrollController.readPosition(e)===void 0&&this.alignOpenAskToTop()||this.pendingDialogs.length>0&&this.scrollController.readPosition(e)===void 0&&this.alignOpenDialogToTop())return;let t=this.scrollController.restorePosition(e,this.chat,this.scrollAnchorElements(),{fallbackToBottom:this.shouldFallbackToBottomForMissingAnchor()});this.handleScrollRestoreResult(e,t)})})}continuePendingScrollRestore(){let e=this.pendingScrollRestoreSessionId,t=this.pendingScrollRestorePosition;e===void 0||t===void 0||e!==this.sessionId||this.restoreScrollFrame!==void 0||(this.restoreScrollFrame=requestAnimationFrame(()=>{this.restoreScrollFrame=void 0,this.sessionId===e&&this.withSuppressedScrollSave(()=>{let n=this.scrollController.restoreExplicitPosition(t,this.chat,this.scrollAnchorElements(),{fallbackToBottom:this.shouldFallbackToBottomForMissingAnchor()});this.handleScrollRestoreResult(e,n)})}))}handleScrollRestoreResult(e,t){if(this.syncScrollMetrics(),t.status!==`missing`){this.updatePinnedToBottomAfterRestore(t.status),(t.status===`restored`||t.status===`bottom`)&&this.cancelPrependRestore(),this.pendingScrollRestoreSessionId=void 0,this.pendingScrollRestorePosition=void 0;return}this.pinnedToBottom=!1,this.pendingScrollRestoreSessionId=e,this.pendingScrollRestorePosition=t.position;let n=this.chat;n===void 0||!this.hasMore||this.loadingMore||(n.scrollTop=0,this.syncScrollMetrics(),this.requestLoadMore())}shouldFallbackToBottomForMissingAnchor(){return!this.hasMore}updatePinnedToBottomAfterRestore(e){e===`bottom`?this.pinnedToBottom=!0:e===`restored`&&(this.pinnedToBottom=this.isNearBottom())}syncScrollMetrics(){let e=this.chat;e!==void 0&&(this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight)}cancelPrependRestore(){this.prependRestoreToken+=1,this.suppressLoadMoreRequests=!1}capturePrependScrollAnchor(){let e=this.chat;if(e)return uw(e,this.scrollMarkers())}restorePrependScrollAnchor(e){if(!this.chat||!e)return;this.suppressLoadMoreRequests=!0,this.suppressScrollSave=!0;let t=this.prependRestoreToken+1;this.prependRestoreToken=t;let n=0,r=()=>{let i=this.chat;if(!(!i||t!==this.prependRestoreToken)){if(dw(i,e,e.markerId===void 0?void 0:this.scrollMarkerAt(e.markerId)),this.lastScrollTop=i.scrollTop,n+=1,n<30){requestAnimationFrame(r);return}requestAnimationFrame(()=>{t===this.prependRestoreToken&&(this.suppressScrollSave=!1,this.suppressLoadMoreRequests=!1)})}};r()}saveScrollPosition(e=this.sessionId){e&&this.scrollController.savePosition(e,this.chat,this.scrollAnchorElements())}scheduleScrollPositionSave(){let e=this.sessionId;this.scrollController.scheduleSave(e,e=>{this.sessionId===e&&this.saveScrollPosition(e)})}scheduleConversationRailUpdate(){this.conversationRailFrame===void 0&&(this.conversationRailFrame=requestAnimationFrame(()=>{this.conversationRailFrame=void 0,this.updateConversationRailPosition()}))}updateConversationRailPosition(){if(!this.messages.length||this.messageTotal<=0){this.currentConversationIndex=void 0;return}let e=this.conversationDisplayTotal(),t=this.firstVisibleArticle(),n=Number(t?.dataset.index);if(Number.isFinite(n)){this.currentConversationIndex=jT(n,0,Math.max(0,e-1));return}this.currentConversationIndex=jT(this.pinnedToBottom?this.messageStart+this.messages.length-1:this.messageStart,0,Math.max(0,e-1))}scrollMarkers(){return Array.from(this.renderRoot.querySelectorAll(`.scroll-marker`))}scrollMarkerAt(e){return this.scrollMarkers().find(t=>t.dataset.markerId===e)}firstVisibleArticle(){let e=this.chat;if(e!==void 0)return FC(e,Array.from(this.renderRoot.querySelectorAll(`article.msg`)))??FC(e,this.articles())}articles(){return Array.from(this.renderRoot.querySelectorAll(`article.msg, details.msg`))}scrollAnchorElements(){return Array.from(this.renderRoot.querySelectorAll(`[data-scroll-anchor-id]`))}withSuppressedScrollSave(e){this.suppressScrollSave=!0,e(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.suppressScrollSave=!1})})}groupDisclosureKey(e,t,n){return n?`${this.sessionId}:live:${String(e)}`:`${this.sessionId}:${String(t)}`}messageAnchorKey(e){return IT(e)}groupRenderKey(e){return LT(e)}groupAnchorKey(e){return LT(e)}eventAnchorKey(e){return RT(e)}messageScrollMarkerId(e){return IT(e)}groupScrollMarkerId(e){return zT(e)}static{this.styles=Jg}};H([b({attribute:!1})],K.prototype,`messages`,void 0),H([b()],K.prototype,`sessionId`,void 0),H([b({type:Number})],K.prototype,`messageStart`,void 0),H([b({type:Number})],K.prototype,`messageEnd`,void 0),H([b({type:Number})],K.prototype,`messageTotal`,void 0),H([b({type:Boolean})],K.prototype,`hasMore`,void 0),H([b({type:Boolean})],K.prototype,`loadingMore`,void 0),H([b({type:Boolean})],K.prototype,`isSendingPrompt`,void 0),H([b({type:Boolean})],K.prototype,`isCompacting`,void 0),H([b({type:Number})],K.prototype,`pendingMessageCount`,void 0),H([b({attribute:!1})],K.prototype,`clientQueuedMessages`,void 0),H([b({attribute:!1})],K.prototype,`status`,void 0),H([b({attribute:!1})],K.prototype,`activity`,void 0),H([b({attribute:!1})],K.prototype,`pendingAsk`,void 0),H([b({attribute:!1})],K.prototype,`askDraftSessionId`,void 0),H([b({attribute:!1})],K.prototype,`onSubmitAsk`,void 0),H([b({attribute:!1})],K.prototype,`pendingDialogs`,void 0),H([b({attribute:!1})],K.prototype,`closedDialogs`,void 0),H([b({attribute:!1})],K.prototype,`onAnswerDialog`,void 0),H([b({attribute:!1})],K.prototype,`onCancelDialog`,void 0),H([b({attribute:!1})],K.prototype,`onDismissClosedDialog`,void 0),H([b({attribute:!1})],K.prototype,`onResendMessage`,void 0),H([b({attribute:!1})],K.prototype,`notificationInbox`,void 0),H([b({attribute:!1})],K.prototype,`subagents`,void 0),H([b({attribute:!1})],K.prototype,`subagentRuns`,void 0),H([b({attribute:!1})],K.prototype,`backgroundTasks`,void 0),H([b({attribute:!1})],K.prototype,`onOpenBackgroundTask`,void 0),H([b({attribute:!1})],K.prototype,`onOpenSubagentRun`,void 0),H([b({attribute:!1})],K.prototype,`onOpenSubagent`,void 0),H([b({attribute:!1})],K.prototype,`onClearServerQueue`,void 0),H([b({attribute:!1})],K.prototype,`onRecallQueuedMessage`,void 0),H([b({attribute:!1})],K.prototype,`onDismissWarning`,void 0),H([b({attribute:!1})],K.prototype,`onDismissNotification`,void 0),H([b({attribute:!1})],K.prototype,`onDismissAllNotifications`,void 0),H([b({type:Boolean})],K.prototype,`warningsVisible`,void 0),H([b({attribute:!1})],K.prototype,`onToggleWarnings`,void 0),H([b({attribute:!1})],K.prototype,`onLoadMore`,void 0),H([b({attribute:!1})],K.prototype,`activityOutput`,void 0),H([b({attribute:!1})],K.prototype,`onCloseActivityOutput`,void 0),H([S(`.chat`)],K.prototype,`chat`,void 0),H([S(`.drawer-tabs`)],K.prototype,`drawerTabs`,void 0),H([S(`dialog.image-zoom`)],K.prototype,`imageZoomDialog`,void 0),H([S(`dialog.activity-output`)],K.prototype,`activityOutputDialog`,void 0),H([x()],K.prototype,`pinnedToBottom`,void 0),H([x()],K.prototype,`jumpToBottomVisible`,void 0),H([x()],K.prototype,`zoomedImage`,void 0),H([x()],K.prototype,`expandedMetaKey`,void 0),H([x()],K.prototype,`copiedNotificationId`,void 0),H([x()],K.prototype,`copiedMessageKey`,void 0),H([x()],K.prototype,`currentConversationIndex`,void 0),H([x()],K.prototype,`collapsedTopDrawerKeys`,void 0),H([x()],K.prototype,`expandedTopDrawerKeys`,void 0),H([b({attribute:!1})],K.prototype,`goals`,void 0),H([b({attribute:!1})],K.prototype,`onRunGoalCommand`,void 0),H([x()],K.prototype,`topDrawerTab`,void 0),H([x()],K.prototype,`activityFilter`,void 0),H([x()],K.prototype,`activityScope`,void 0),H([x()],K.prototype,`turnStartedAtMs`,void 0),H([x()],K.prototype,`turnNowMs`,void 0),H([x()],K.prototype,`retainedEmptyNotificationTrayTargetKey`,void 0),H([x()],K.prototype,`loadMoreRequested`,void 0),K=H([y(`chat-view`)],K);function KT(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${String(t)}s`;let n=Math.floor(t/60);return n<60?`${String(n)}m ${String(t%60)}s`:`${String(Math.floor(n/60))}h ${String(n%60)}m`}function qT(e){return e.map(e=>{let t=e.status===`running`?`Running`:e.status===`done`?`Done`:e.status===`failed`?`Failed`:e.status===`lost`?`Lost`:`Unknown`,n=KT(e.elapsedMs),r=e.status===`running`?e.lastActivity??`working`:e.task??``,i=Vw(e.model);return{run:e,status:e.status,statusLabel:t,duration:n,detail:r,...i===void 0?{}:{modelLabel:i.label,modelTitle:e.model??i.label},ariaLabel:`${t} ${e.agent} subagent, ${n}`+(i===void 0?``:`, on ${i.label}`)+(r===``?``:`, ${r}`)}})}function JT(e){return e.map(e=>{let t=e.status===`running`?`running`:e.status===`completed`?`done`:e.status===`killed`?`stopped`:e.status===`failed`?`failed`:e.status===`lost`?`lost`:`unknown`,n=e.status===`completed`?`Done`:e.status===`running`?`Running`:e.status===`killed`?`Stopped`:e.status===`lost`?`Lost`:e.status.charAt(0).toUpperCase()+e.status.slice(1),r=KT(e.durationMs??0),i=t===`running`?e.command.slice(0,60):e.exitCode===void 0?``:`exit ${String(e.exitCode)}`;return{task:e,status:t,statusLabel:n,duration:r,detail:i,ariaLabel:`${n} background task ${e.name}, ${r}${i===``?``:`, ${i}`}`}})}function YT(e){return[...e].sort((e,t)=>{let n=Number(QT(t.status))-Number(QT(e.status));if(n!==0)return n;let r=Number($T(e.status))-Number($T(t.status));if(r!==0)return r;let i=(t.startedAt??``).localeCompare(e.startedAt??``);return i===0?e.kind.localeCompare(t.kind):i})}var XT=600*1e3;function ZT(e,t){if(e===void 0)return;let n=Math.max(0,t-e);if(!(n<5e3))return{text:KT(n),long:n>=XT}}function QT(e){return e===`working`||e===`running`}function $T(e){return e===`done`||e===`failed`||e===`error`||e===`lost`||e===`stopped`}function eE(e){return e.active>0?`Activity · ${String(e.active)} running`:`Activity (${String(e.total)})`}function tE(e){let t=[{id:`subagents`,label:`Subagents`,count:e.rows.length},{id:`runs`,label:`Agent runs`,count:e.runRows.length},{id:`tasks`,label:`Tasks`,count:e.taskRows.length}].filter(e=>e.count>0);return t.length<=1?t.length===0?[]:t:[{id:`all`,label:`All`,count:e.rows.length+e.runRows.length+e.taskRows.length},...t]}function nE(e,t){return e===`subagents`&&t.rows.length>0?`subagents`:e===`runs`&&t.runRows.length>0?`runs`:e===`tasks`&&t.taskRows.length>0?`tasks`:`all`}var rE=`Work this chat started in the background: subagents, agent tool runs and terminal tasks. Open one to read its output.`;function iE(e){if(e===void 0)return;let t=[...e.rows,...e.runRows,...e.taskRows].filter(e=>e.status===`working`||e.status===`running`).length;if(t!==0)return t===1?`idle · 1 background run`:`idle · ${String(t)} background runs`}function aE(){return!1}function oE(e,t){return t===`activity`&&e.activity?`activity`:t===`notifications`&&e.notifications?`notifications`:t===`goals`&&e.goals===!0?`goals`:e.notifications?`notifications`:e.activity?`activity`:e.goals===!0?`goals`:`activity`}function sE(e){let t=t=>e.filter(t).length,n=t(e=>e===`working`||e===`running`),r=t(e=>e===`error`||e===`failed`),i=t(e=>e===`stopped`),a=t(e=>e===`lost`),o=e.length-n-r-i-a,s=[];return n>0&&s.push(`${String(n)} running`),r>0&&s.push(`${String(r)} failed`),o>0&&s.push(`${String(o)} done`),i>0&&s.push(`${String(i)} stopped`),a>0&&s.push(`${String(a)} lost`),{label:s.join(` · `),working:n>0,failed:r>0}}function cE(e){return e===``?`Unknown`:e.charAt(0).toUpperCase()+e.slice(1)}function lE(e){return e.map(e=>{let t=e.status,n=e.sessionId.slice(-8),r=cE(t);return{subagent:e,shortId:n,status:t,statusLabel:r,cwd:e.cwd,ariaLabel:`${r} subagent ${n}`}})}var uE=new Set([`image/jpeg`,`image/png`,`image/gif`,`image/webp`]);function dE(e){return typeof e==`string`&&uE.has(e)}function fE(e){switch(e){case`image/jpeg`:return`jpg`;case`image/png`:return`png`;case`image/gif`:return`gif`;case`image/webp`:return`webp`;default:return`bin`}}var pE=`application/octet-stream`,mE=`Failed to read an attachment.`;async function hE(e,t){let n=[],r;for(let i of e)try{let e=await t(i);n.push(yE(i,e))}catch{r=mE}return{attachments:n,...r===void 0?{}:{error:r}}}function gE(e){return e.kind===`image`&&dE(e.mimeType)}function _E(e){return e.every(e=>gE(e))}function vE(e,t){return _E(t)?e:`folder`}function yE(e,t){return dE(e.type)?{kind:`image`,name:xE(e),mimeType:e.type,data:t,size:e.size}:{kind:`file`,name:xE(e),mimeType:bE(e),data:t,size:e.size}}function bE(e){let t=e.type.trim();return t===``?pE:t}function xE(e){return e.name===``?dE(e.type)?`pasted-image.${fE(e.type)}`:`pasted-file.bin`:e.name}var SE=50,CE=`pi-web:prompt-history:`;function wE(e){return`${CE}${e}`}function TE(e){try{let t=localStorage.getItem(wE(e));if(t===null||t===``)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.trim()!==``):[]}catch{return[]}}function EE(e,t){try{localStorage.setItem(wE(e),JSON.stringify(t.slice(0,SE)))}catch{}}function DE(e,t){let n=t.trim();if(n===``)return TE(e);let r=[n,...TE(e).filter(e=>e!==n)].slice(0,SE);return EE(e,r),r}function OE(e,t){let n=TE(e),r=t.trim().toLowerCase();if(r===``)return n;let i=r.split(/\s+/u).filter(Boolean);return n.filter(e=>{let t=e.toLowerCase();return i.every(e=>t.includes(e)||kE(e,t))})}function kE(e,t){let n=0;for(let r of e){if(n=t.indexOf(r,n),n===-1)return!1;n+=r.length}return!0}function AE(e){return e===`older`?1:-1}var jE=`(pointer: coarse), (max-width: 760px)`,ME=`pi-web.promptEnterPreference`;function NE(){return typeof window<`u`&&`matchMedia`in window?window.matchMedia(jE):void 0}function PE(e){return e===`send`||e===`newline`?e:`auto`}function FE(e=BE()){if(e===void 0)return`auto`;try{return PE(e.getItem(ME))}catch{return`auto`}}function IE(e,t=BE()){if(t!==void 0)try{t.setItem(ME,e)}catch{}}function LE(e=NE(),t=FE()){return t===`send`||t!==`newline`&&e?.matches!==!0}function RE(e,t,n=NE()){return e?n?.matches!==!0||t:!1}function zE(e,t=NE(),n=FE()){let r=LE(t,n);return e?!r:r}function BE(){if(!(typeof window>`u`))try{return window.localStorage}catch{return}}var VE=100;function HE(){let e,t,n,r,i=[],a=()=>{r!==void 0&&(window.clearInterval(r),r=void 0),e?.getTracks().forEach(e=>{e.stop()}),e=void 0,n?.close().catch(()=>void 0),n=void 0,t=void 0};return{async start(a){i=[],e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=new MediaRecorder(e),t.addEventListener(`dataavailable`,e=>{e.data.size>0&&i.push(e.data)}),t.start(),n=new AudioContext;let o=n.createMediaStreamSource(e),s=n.createAnalyser();s.fftSize=512,o.connect(s);let c=new Uint8Array(s.fftSize);r=window.setInterval(()=>{s.getByteTimeDomainData(c),a(UE(c),VE)},VE)},stop(){let e=t;return e===void 0?(a(),Promise.resolve(new Blob([]))):new Promise(t=>{e.addEventListener(`stop`,()=>{let e=i[0]?.type??`audio/webm`,n=new Blob(i,{type:e});a(),t(n)},{once:!0}),e.stop()})},cancel(){i=[],t?.state===`recording`&&t.stop(),a()}}}function UE(e){let t=0;for(let n of e){let e=Math.abs(n-128)/128;e>t&&(t=e)}return t}function WE(e){return e!==void 0&&e.endpoint.trim()!==``}async function GE(e,t,n){if(!WE(t))return{ok:!1,message:`Dictation is not configured.`};if(e.size===0)return{ok:!1,message:`Nothing was recorded.`};let r=new FormData;r.append(`file`,e,`speech.webm`),t.model!==void 0&&t.model!==``&&r.append(`model`,t.model),t.language!==void 0&&t.language!==``&&r.append(`language`,t.language);let i;try{i=await n.fetch(t.endpoint,{method:`POST`,body:r,...n.signal===void 0?{}:{signal:n.signal}})}catch(e){return{ok:!1,message:`Could not reach the transcription service: ${JE(e)}`}}if(!i.ok)return{ok:!1,message:`Transcription failed (${String(i.status)}).`};let a;try{a=await i.json()}catch{return{ok:!1,message:`The transcription service returned a response that could not be read.`}}let o=KE(a);if(o===void 0)return{ok:!1,message:`The transcription service returned no text.`};let s=o.trim();return s===``?{ok:!1,message:`No speech was recognised.`}:{ok:!0,text:s}}function KE(e){if(typeof e==`string`)return e;let t=qE(e);if(t===void 0)return;for(let e of[`text`,`transcript`,`transcription`]){let n=t[e];if(typeof n==`string`)return n}let n=t.segments;if(!Array.isArray(n))return;let r=n.map(e=>qE(e)?.text).filter(e=>typeof e==`string`).join(` `);return r.trim()===``?void 0:r}function qE(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e))t[n]=r;return t}function JE(e){return e instanceof Error?e.message:String(e)}var YE={"openai-realtime":`append`,deepgram:`replace`,"azure-speech":`replace`};function XE(e){if(e===void 0)return{kind:`unavailable`,reason:`Live transcription is not configured.`};if(e.protocol===`browser`)return{kind:`browser`};let t=e.url?.trim();if(t===void 0||t===``)return{kind:`unavailable`,reason:`Streaming transcription needs a socket url.`};let n=e.tokenEndpoint?.trim();return n===void 0||n===``?{kind:`unavailable`,reason:`Streaming transcription needs a token endpoint so the account key stays on the server.`}:{kind:`socket`,protocol:e.protocol,url:t,tokenEndpoint:n,deltaMode:YE[e.protocol]}}var ZE={trailingSilenceMs:900,speechThreshold:.02,maxUtteranceMs:12e4};function QE(e,t,n,r=ZE){if(e.kind!==`listening`&&e.kind!==`speaking`&&e.kind!==`trailing`)return e;if(n>=r.maxUtteranceMs)return e.kind===`listening`?{kind:`idle`}:{kind:`transcribing`};let i=t.level>=r.speechThreshold;if(e.kind===`listening`)return i?{kind:`speaking`}:e;if(e.kind===`speaking`)return i?e:{kind:`trailing`,silenceMs:t.elapsedMs};if(i)return{kind:`speaking`};let a=e.silenceMs+t.elapsedMs;return a>=r.trailingSilenceMs?{kind:`transcribing`}:{kind:`trailing`,silenceMs:a}}function $E(e){switch(e.kind){case`idle`:case`denied`:case`error`:return{kind:`listening`};case`listening`:return{kind:`idle`};case`speaking`:case`trailing`:return{kind:`transcribing`};case`transcribing`:case`unavailable`:return e}}function eD(e){return e.kind===`listening`||e.kind===`speaking`||e.kind===`trailing`}function tD(e,t){switch(e.kind){case`idle`:return t?.streaming===!0?`Dictate live`:`Dictate`;case`listening`:return`Listening…`;case`speaking`:return`Listening…`;case`trailing`:return`Listening…`;case`transcribing`:return`Transcribing…`;case`denied`:return`Microphone permission denied`;case`unavailable`:return e.reason;case`error`:return e.message}}var nD=class{constructor(e,t){this.deps=e,this.callbacks=t,this.state={kind:`idle`},this.elapsedMs=0}getState(){return this.state}async toggle(e){if(!WE(e)){this.setState({kind:`unavailable`,reason:`Dictation is not configured.`});return}let t=$E(this.state);if(t.kind===`listening`&&!eD(this.state)){await this.startListening(e);return}if(t.kind===`idle`){this.deps.recorder.cancel(),this.setState({kind:`idle`});return}if(t.kind===`transcribing`){await this.finish(e);return}this.setState(t)}async startListening(e){this.activeConfig=e,this.elapsedMs=0,this.setState({kind:`listening`});try{await this.deps.recorder.start((e,t)=>{this.onFrame(e,t)})}catch(e){this.setState(rD(e)?{kind:`denied`}:{kind:`error`,message:`Microphone unavailable: ${iD(e)}`})}}onFrame(e,t){if(!eD(this.state))return;this.elapsedMs+=t;let n=QE(this.state,{level:e,elapsedMs:t},this.elapsedMs,this.deps.captureConfig??ZE);if(n!==this.state){if(n.kind===`transcribing`){this.finish(this.activeConfig);return}n.kind===`idle`&&this.deps.recorder.cancel(),this.setState(n)}}async finish(e){this.setState({kind:`transcribing`});let t;try{t=await this.deps.recorder.stop()}catch(e){this.setState({kind:`error`,message:`Recording failed: ${iD(e)}`});return}if(!WE(e)){this.setState({kind:`unavailable`,reason:`Dictation is not configured.`});return}let n=await(this.deps.transcribe??GE)(t,e,{fetch:this.deps.fetch??globalThis.fetch});if(!n.ok){this.setState({kind:`error`,message:n.message});return}this.callbacks.onTranscript(n.text),this.setState({kind:`idle`})}setState(e){this.state=e,this.callbacks.onState(e)}};function rD(e){if(typeof e!=`object`||!e)return!1;let t=`name`in e?e.name:void 0;return t===`NotAllowedError`||t===`SecurityError`}function iD(e){return e instanceof Error?e.message:String(e)}function aD(){return Ye`
|
|
3544
3548
|
<svg class="prompt-action-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
3545
3549
|
<path d="M20 11.5 12.5 19a4 4 0 0 1-5.66-5.66l7.07-7.07a2.5 2.5 0 0 1 3.54 3.54l-7.07 7.07a1 1 0 0 1-1.42-1.42l6.37-6.36"></path>
|
|
3546
3550
|
</svg>
|
|
3547
|
-
`}function
|
|
3551
|
+
`}function oD(){return Ye`
|
|
3548
3552
|
<svg class="prompt-action-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
3549
3553
|
<path d="M21 3 13.5 21l-2-8.5L3 10.5Z"></path>
|
|
3550
3554
|
<path d="M21 3 11.5 12.5"></path>
|
|
3551
3555
|
</svg>
|
|
3552
|
-
`}function
|
|
3556
|
+
`}function sD(){return Ye`
|
|
3553
3557
|
<svg class="prompt-action-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
3554
3558
|
<path d="M4 7h11"></path>
|
|
3555
3559
|
<path d="M4 12h7"></path>
|
|
3556
3560
|
<path d="M4 17h7"></path>
|
|
3557
3561
|
<path d="m15 14 5 3-5 3z"></path>
|
|
3558
3562
|
</svg>
|
|
3559
|
-
`}function
|
|
3563
|
+
`}function cD(){return oD()}function lD(){return Ye`
|
|
3560
3564
|
<svg class="prompt-action-icon prompt-action-icon-filled" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
3561
3565
|
<rect x="6.5" y="6.5" width="11" height="11" rx="2"></rect>
|
|
3562
3566
|
</svg>
|
|
3563
|
-
`}function
|
|
3567
|
+
`}function uD(e){let t=Math.max(e.total,1),n=t>1?1.2:0,r=(18-n*(t-1))/t;return Ye`
|
|
3564
3568
|
<svg class="prompt-thinking-gauge" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
3565
3569
|
${Array.from({length:t},(i,a)=>{let o=3+a*(r+n),s=4+(a+1)/t*12,c=20-s;return Ye`<rect class=${a<e.filled?`gauge-bar gauge-bar-active`:`gauge-bar`} x=${o} y=${c} width=${r} height=${s} rx="1"></rect>`})}
|
|
3566
3570
|
</svg>
|
|
3567
|
-
`}var
|
|
3571
|
+
`}var dD=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function fD(e){return e===void 0||e===``?`off`:e}function pD(e,t){let n=t.length>=2?t:dD,r=n.length-1,i=fD(e),a=n.indexOf(i);return{total:r,filled:a<=0?0:Math.min(a,r)}}var mD=t_(class extends n_{constructor(e){super(e),this.wasSelected=!1,this.isElementPart=e.type===e_.ELEMENT}update(e,[t,n]){if(!this.isElementPart)throw Error(`scrollWhenSelected must be used on an element`);if(t&&(!this.wasSelected||n!==this.previousKey)){let t=`element`in e?e.element:void 0;requestAnimationFrame(()=>{t instanceof HTMLElement&&t.scrollIntoView({block:`nearest`})})}this.wasSelected=t,this.previousKey=n}render(e,t){}}),hD=class extends v{constructor(...e){super(...e),this.items=[],this.selectedIndex=0}render(){return this.items.length?g`
|
|
3568
3572
|
<div class="menu">
|
|
3569
3573
|
${this.items.map((e,t)=>g`
|
|
3570
|
-
<button class=${t===this.selectedIndex?`selected`:``} ${
|
|
3574
|
+
<button class=${t===this.selectedIndex?`selected`:``} ${mD(t===this.selectedIndex,e)} @mousedown=${t=>{t.preventDefault(),this.onPick?.(e)}}>
|
|
3571
3575
|
<strong>${e.insertText}</strong>
|
|
3572
3576
|
<span>${e.detail}</span>
|
|
3573
3577
|
${e.description!==void 0&&e.description!==``?g`<small>${e.description}</small>`:null}
|
|
3574
3578
|
</button>
|
|
3575
3579
|
`)}
|
|
3576
3580
|
</div>
|
|
3577
|
-
`:null}static{this.styles=Zg}};H([b({attribute:!1})],
|
|
3581
|
+
`:null}static{this.styles=Zg}};H([b({attribute:!1})],hD.prototype,`items`,void 0),H([b({type:Number})],hD.prototype,`selectedIndex`,void 0),H([b({attribute:!1})],hD.prototype,`onPick`,void 0),hD=H([y(`autocomplete-menu`)],hD);var q=class extends v{constructor(...e){super(...e),this.disabled=!1,this.machineId=`local`,this.canSteer=!1,this.isCompacting=!1,this.canStop=!1,this.sending=!1,this.collapsed=!1,this.availableThinkingLevels=[],this.draft=``,this.hasRenderedOnce=!1,this.currentInputMode={kind:`normal`},this.completions=[],this.selectedIndex=0,this.voiceState={kind:`idle`},this.attachments=[],this.attachmentError=void 0,this.attachingCount=0,this.attachingSettled=Promise.resolve(),this.attachmentSeq=0,this.requestVersion=0,this.historyDraftBeforeBrowse=``,this.editableCompartment=new i,this.readOnlyCompartment=new i,this.mobilePromptEnterMedia=NE(),this.explicitShiftKeyActive=!1,this.pendingPrompts=[],this.openAttachmentZoom=(e,t)=>{this.zoomedAttachment={src:e,alt:t}},this.closeAttachmentZoom=()=>{this.zoomedAttachment=void 0},this.onAttachmentZoomDialogClick=e=>{e.target===this.attachmentZoomDialog&&this.closeAttachmentZoom()},this.flushPendingPrompts=()=>{if(!navigator.onLine)return;let e=Cc(this.machineId,this.sessionId??``);if(e===``)return;let t=tf(e);if(t.length===0)return;let n=t;(async()=>{let t=[],r=!1;for(let e of n)try{await this.onSend?.(e.text,e.behavior,e.attachments,e.attachments===void 0?void 0:this.effectiveAttachmentDelivery(),e.clientMessageId===void 0?void 0:{clientMessageId:e.clientMessageId})===!1&&t.push(e)}catch(n){r||=$d(n),t.push(e)}t.length===0?rf(e):r||rf(e),this.pendingPrompts=t.length===0?[]:t,n=t})()}}willUpdate(e){let t=e.has(`sessionId`),n=e.has(`machineId`),r=this.hasRenderedOnce;if(!du({hasRendered:r,sessionChanged:t,machineChanged:n}))return;this.hasRenderedOnce=!0;let i=t?e.get(`sessionId`):this.sessionId,a=_D(n?e.get(`machineId`):this.machineId,i);a!==void 0&&fu({hasRendered:r})&&cu(a,this.draft);let o=_D(this.machineId,this.sessionId);this.draft=o===void 0?``:su(o),this.currentInputMode=xf(this.draft),this.completions=[],this.selectedIndex=0}shouldUpdate(e){return e.has(`status`)&&e.size===1?!gD(e.get(`status`),this.status):!0}firstUpdated(){this.createEditor(),this.pendingPrompts=this.pendingPromptsForSession(),window.addEventListener(`online`,this.flushPendingPrompts)}connectedCallback(){super.connectedCallback(),this.pendingPrompts=this.pendingPromptsForSession()}updated(e){e.has(`collapsed`)&&(this.collapsed?(this.editor?.destroy(),this.editor=void 0):this.createEditor()),e.has(`disabled`)&&this.updateEditorDisabledState(),(e.has(`sessionId`)||e.has(`machineId`))&&this.syncEditorDoc(),this.syncAttachmentZoomDialog()}disconnectedCallback(){window.removeEventListener(`online`,this.flushPendingPrompts),this.editor?.destroy(),this.editor=void 0,super.disconnectedCallback()}render(){if(this.collapsed)return this.renderCollapsed();let e=this.currentInputMode.kind===`shell`?this.currentInputMode:void 0,t=e!==void 0,n=this.canSteer||this.isCompacting,r=this.disabled||this.sending;return g`
|
|
3578
3582
|
<footer class=${t?`shell-mode`:``} @paste=${e=>{this.handlePaste(e)}} @dragover=${e=>{this.handleDragOver(e)}} @drop=${e=>{this.handleDrop(e)}}>
|
|
3579
3583
|
<input class="attachment-input" type="file" multiple hidden @change=${e=>{this.handleFileInput(e)}} />
|
|
3580
3584
|
${this.renderAttachments()}
|
|
@@ -3583,21 +3587,17 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3583
3587
|
${this.isCompacting&&!t?g`<div class="mode-hint">Compacting history · message will be queued</div>`:null}
|
|
3584
3588
|
<div
|
|
3585
3589
|
class=${`markdown-editor${this.disabled?` markdown-editor-disabled`:``}`}
|
|
3586
|
-
aria-label="Message pi
|
|
3590
|
+
aria-label="Message pi"
|
|
3587
3591
|
aria-disabled=${this.disabled?`true`:`false`}
|
|
3588
|
-
@pointerdown=${e=>{this.disabled||this.holdToDictate.start({clientX:e.clientX,clientY:e.clientY})}}
|
|
3589
|
-
@pointermove=${e=>{this.holdToDictate.move({clientX:e.clientX,clientY:e.clientY})}}
|
|
3590
|
-
@pointerup=${()=>{this.holdToDictate.cancel()}}
|
|
3591
|
-
@pointercancel=${()=>{this.holdToDictate.cancel()}}
|
|
3592
3592
|
></div>
|
|
3593
3593
|
<autocomplete-menu .items=${this.completions} .selectedIndex=${this.selectedIndex} .onPick=${e=>{this.pick(e)}}></autocomplete-menu>
|
|
3594
3594
|
</div>
|
|
3595
3595
|
<div class="actions">
|
|
3596
3596
|
${this.renderCompactStatus()}
|
|
3597
|
-
<button class="icon-button" ?disabled=${r} title="Attach files" aria-label="Attach files" @click=${()=>{this.attachmentInput?.click()}}>${
|
|
3597
|
+
<button class="icon-button" ?disabled=${r} title="Attach files" aria-label="Attach files" @click=${()=>{this.attachmentInput?.click()}}>${aD()}</button>
|
|
3598
3598
|
${this.renderDictateButton(r)}
|
|
3599
|
-
<button class="icon-button send-button" ?disabled=${r} title=${n?`Steer — joins the current turn at the next safe point`:`Send message`} aria-label=${n?`Steer current response (queued if busy)`:`Send message`} @click=${()=>{this.send(this.canSteer?`steer`:`followUp`)}}>${this.canSteer?
|
|
3600
|
-
<button class="icon-button stop-button" ?disabled=${this.disabled||!this.canStop} title=${this.canStop?`Stop current work and clear queued messages`:`Nothing running`} aria-label="Stop current work" @click=${()=>this.onStop?.()}>${
|
|
3599
|
+
<button class="icon-button send-button" ?disabled=${r} title=${n?`Steer — joins the current turn at the next safe point`:`Send message`} aria-label=${n?`Steer current response (queued if busy)`:`Send message`} @click=${()=>{this.send(this.canSteer?`steer`:`followUp`)}}>${this.canSteer?cD():n?sD():oD()}</button>
|
|
3600
|
+
<button class="icon-button stop-button" ?disabled=${this.disabled||!this.canStop} title=${this.canStop?`Stop current work and clear queued messages`:`Nothing running`} aria-label="Stop current work" @click=${()=>this.onStop?.()}>${lD()}</button>
|
|
3601
3601
|
</div>
|
|
3602
3602
|
</footer>
|
|
3603
3603
|
${this.renderAttachmentZoom()}
|
|
@@ -3615,22 +3615,22 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3615
3615
|
${this.draftPreview===``?null:g`<span class="expand-composer-draft" dir="auto">${this.draftPreview}</span>`}
|
|
3616
3616
|
</button>
|
|
3617
3617
|
</footer>
|
|
3618
|
-
`}get draftPreview(){let e=(this.editor?.state.doc.toString()??this.draft).trim().replace(/\s+/gu,` `);return e.length>60?`${e.slice(0,59)}…`:e}focusInput(){this.editor?.focus()}restorePrompt(e){this.attachmentError=void 0,this.attachments=e.attachments.filter(e=>e.kind===`image`).map((e,t)=>(this.attachmentSeq+=1,{id:`restored-${String(this.attachmentSeq)}`,kind:`image`,name:e.name??`image-${String(t+1)}`,mimeType:e.mimeType,data:e.data,size:Math.floor(e.data.length*3/4)})),this.replaceText(e.text),this.focusInput()}replaceText(t){this.draft=t;let n=
|
|
3618
|
+
`}get draftPreview(){let e=(this.editor?.state.doc.toString()??this.draft).trim().replace(/\s+/gu,` `);return e.length>60?`${e.slice(0,59)}…`:e}focusInput(){this.editor?.focus()}restorePrompt(e){this.attachmentError=void 0,this.attachments=e.attachments.filter(e=>e.kind===`image`).map((e,t)=>(this.attachmentSeq+=1,{id:`restored-${String(this.attachmentSeq)}`,kind:`image`,name:e.name??`image-${String(t+1)}`,mimeType:e.mimeType,data:e.data,size:Math.floor(e.data.length*3/4)})),this.replaceText(e.text),this.focusInput()}replaceText(t){this.draft=t;let n=_D(this.machineId,this.sessionId);n!==void 0&&cu(n,t);let r=this.editor;if(r!==void 0){let n=r.state.doc.toString();r.dispatch({...n===t?{}:{changes:{from:0,to:n.length,insert:t}},selection:e.cursor(t.length)})}this.requestVersion+=1,this.currentInputMode=xf(t),this.completions=[],this.selectedIndex=0}get view(){return this.editor}renderCompactStatus(){let e=this.status;if(e===void 0)return null;let t=e.model?.id??`no model`,n=e.model?.provider!==void 0&&e.model.provider!==``?`${e.model.provider}/`:``;return g`
|
|
3619
3619
|
<div class="compact-status" aria-label="Session status">
|
|
3620
3620
|
<button class="select-model" title=${`Select model: ${n}${t}`} @click=${()=>this.onSelectModel?.()}>${n===``?null:g`<span class="select-model-provider">${n}</span>`}<span class="select-model-id">${t}</span></button>
|
|
3621
|
-
<button class="select-thinking icon-button" title=${`Thinking level: ${
|
|
3621
|
+
<button class="select-thinking icon-button" title=${`Thinking level: ${fD(e.thinkingLevel)}`} aria-label=${`Thinking level: ${fD(e.thinkingLevel)}`} @click=${()=>this.onSelectThinking?.()}>${uD(pD(e.thinkingLevel,this.availableThinkingLevels))}</button>
|
|
3622
3622
|
</div>
|
|
3623
3623
|
`}renderAttachments(){return this.attachments.length===0&&this.attachmentError===void 0?null:g`
|
|
3624
3624
|
<div class="attachments" aria-label="Pending attachments">
|
|
3625
3625
|
${this.attachments.map(e=>g`
|
|
3626
|
-
<div class=${`attachment-chip ${
|
|
3626
|
+
<div class=${`attachment-chip ${gE(e)?`attachment-chip-image`:`attachment-chip-file`}`} title=${e.name}>
|
|
3627
3627
|
${this.renderAttachmentPreview(e)}
|
|
3628
3628
|
<button type="button" class="attachment-remove" title="Remove attachment" aria-label=${`Remove ${e.name}`} @click=${()=>{this.removeAttachment(e.id)}}>×</button>
|
|
3629
3629
|
</div>
|
|
3630
3630
|
`)}
|
|
3631
3631
|
${this.attachmentError===void 0?null:g`<div class="attachment-error">${this.attachmentError}</div>`}
|
|
3632
3632
|
</div>
|
|
3633
|
-
`}renderAttachmentPreview(e){if(
|
|
3633
|
+
`}renderAttachmentPreview(e){if(gE(e)){let t=`data:${e.mimeType};base64,${e.data}`;return g`<img
|
|
3634
3634
|
src=${t}
|
|
3635
3635
|
alt=${e.name}
|
|
3636
3636
|
role="button"
|
|
@@ -3639,7 +3639,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3639
3639
|
@click=${()=>{this.openAttachmentZoom(t,e.name)}}
|
|
3640
3640
|
@keydown=${n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),this.openAttachmentZoom(t,e.name))}}
|
|
3641
3641
|
/>`}return g`
|
|
3642
|
-
<div class="attachment-file-preview" aria-hidden="true">${
|
|
3642
|
+
<div class="attachment-file-preview" aria-hidden="true">${wD(e.name)}</div>
|
|
3643
3643
|
<span class="attachment-file-name">${e.name}</span>
|
|
3644
3644
|
`}removeAttachment(e){this.attachments=this.attachments.filter(t=>t.id!==e)}syncAttachmentZoomDialog(){let e=this.attachmentZoomDialog;if(e!==void 0){if(this.zoomedAttachment!==void 0){try{e.open||e.showModal()}catch{this.zoomedAttachment=void 0;return}(this.renderRoot.querySelector(`.attachment-zoom-close`)??e).focus();return}e.open&&e.close()}}renderAttachmentZoom(){let e=this.zoomedAttachment;return g`
|
|
3645
3645
|
<dialog class="attachment-zoom" @click=${this.onAttachmentZoomDialogClick} @close=${this.closeAttachmentZoom} @cancel=${this.closeAttachmentZoom}>
|
|
@@ -3648,7 +3648,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3648
3648
|
<img class="attachment-zoom-full" src=${e.src} alt=${e.alt} />
|
|
3649
3649
|
`}
|
|
3650
3650
|
</dialog>
|
|
3651
|
-
`}async handlePaste(e){let t=
|
|
3651
|
+
`}async handlePaste(e){let t=xD(e.clipboardData);t.length!==0&&(e.preventDefault(),await this.addAttachmentFiles(t))}handleDragOver(e){e.dataTransfer!==null&&SD(e.dataTransfer)&&e.preventDefault()}async handleDrop(e){let t=xD(e.dataTransfer);t.length!==0&&(e.preventDefault(),await this.addAttachmentFiles(t))}async handleFileInput(e){if(!(e.target instanceof HTMLInputElement)||e.target.files===null)return;let t=Array.from(e.target.files);e.target.value=``,await this.addAttachmentFiles(t)}async addAttachmentFiles(e){this.attachmentError=void 0,this.attachingCount+=1;let t=hE(e,TD);this.attachingSettled=this.attachingSettled.then(async()=>{await t}).catch(()=>void 0);let n;try{n=await t}finally{--this.attachingCount}let{attachments:r,error:i}=n;r.length>0&&(this.attachments=[...this.attachments,...r.map(e=>({id:`attachment-${String(++this.attachmentSeq)}`,...e}))]),i!==void 0&&(this.attachmentError=i)}currentAttachments(){return this.attachments.map(e=>CD(e))}renderDictateButton(e){if(!WE(this.speechToText))return null;let t=XE(this.speechToText.streaming).kind!==`unavailable`,n=tD(this.voiceState,{streaming:t}),r=eD(this.voiceState);return g`
|
|
3652
3652
|
<button
|
|
3653
3653
|
class=${`editor-dictate icon-button${r?` listening`:``}`}
|
|
3654
3654
|
type="button"
|
|
@@ -3658,8 +3658,8 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3658
3658
|
aria-pressed=${String(r)}
|
|
3659
3659
|
@click=${()=>{this.toggleDictation()}}
|
|
3660
3660
|
>${r?`■`:`●`}</button>
|
|
3661
|
-
`}async toggleDictation(){this.voice??=new
|
|
3662
|
-
`)?``:` `;this.replaceText(`${t}${n}${e}`)}effectiveAttachmentDelivery(){return _E(`inline`,this.attachments)}createEditor(){!this.editorHost||this.editor!==void 0||(this.editor=new m({parent:this.editorHost,state:l.create({doc:this.draft,extensions:[ee(),re(),t(),d.of(` `),r(a,{fallback:!0}),m.lineWrapping,n(),m.contentAttributes.of(e=>DD(e.state.sliceDoc(0,e.state.selection.main.head))),m.domEventHandlers({keyup:e=>this.handleEditorKeyUp(e),blur:()=>this.resetEditorModifierState()}),s(OD()),this.editableCompartment.of(m.editable.of(!this.disabled)),this.readOnlyCompartment.of(l.readOnly.of(this.disabled)),m.updateListener.of(e=>{e.docChanged&&this.updateDraft(e.state.doc.toString())}),o.of([{any:(e,t)=>this.handleEditorKeyDown(t,e)},{key:`ArrowDown`,run:e=>this.handleEditorArrow(e,`newer`)},{key:`ArrowUp`,run:e=>this.handleEditorArrow(e,`older`)},{key:`Escape`,run:()=>this.closeCompletions()},{key:`Tab`,run:e=>this.handleEditorTab(e)},{key:`Shift-Tab`,run:e=>u.shift?.(e)??!1},{key:`Backspace`,run:e=>te(e)},...c,...f])]})}))}syncEditorDoc(){let t=this.editor;if(!t)return;let n=t.state.doc.toString();n!==this.draft&&t.dispatch({changes:{from:0,to:n.length,insert:this.draft},selection:e.cursor(this.draft.length)})}updateEditorDisabledState(){this.editor?.dispatch({effects:[this.editableCompartment.reconfigure(m.editable.of(!this.disabled)),this.readOnlyCompartment.reconfigure(l.readOnly.of(this.disabled))]})}updateDraft(e){this.draft=e;let t=gD(this.machineId,this.sessionId);t!==void 0&&cu(t,this.draft);let n=xf(this.draft);Cf(n,this.currentInputMode)||(this.currentInputMode=n),this.refreshCompletions()}async refreshCompletions(){let e=this.currentTrigger(),t=++this.requestVersion;if(this.selectedIndex=0,e===void 0){this.completions=[];return}if(e.kind===`command`&&this.sessionId!==void 0&&this.sessionId!==``&&this.cwd!==void 0&&this.cwd!==``){let n=await I.commands({id:this.sessionId,cwd:this.cwd},this.machineId).catch(_D);if(t!==this.requestVersion)return;this.completions=n.filter(t=>t.name.toLowerCase().includes(e.query.toLowerCase())).slice(0,12).map(t=>({kind:`command`,replaceFrom:e.from,replaceTo:e.to,insertText:`/${t.name}`,detail:t.source,...t.description===void 0?{}:{description:t.description}}))}else if(e.kind===`file`&&this.projectId!==void 0&&this.workspaceId!==void 0){let n=await I.files(e.query,{scope:e.fileScope,machineId:this.machineId,projectId:this.projectId,workspaceId:this.workspaceId}).catch(vD);if(t!==this.requestVersion)return;this.completions=n.slice(0,12).map(t=>{let n=gf(t.path,e.quoted===!0,t.path.endsWith(`/`)?e.allPrefix:void 0);return{kind:`file`,replaceFrom:e.from,replaceTo:e.to,insertText:n,detail:t.kind,...t.path.endsWith(`/`)&&n.endsWith(`"`)?{cursorOffset:n.length-1}:{}}})}else if(e.kind===`model`&&this.sessionId!==void 0&&this.sessionId!==``&&this.cwd!==void 0&&this.cwd!==``){let n=await I.models({id:this.sessionId,cwd:this.cwd},this.machineId).then(e=>e.models).catch(yD);if(t!==this.requestVersion)return;this.completions=pf(n,e.query).map(t=>({kind:`model`,replaceFrom:e.from,replaceTo:e.to,...t}))}}currentTrigger(){return df(this.draft,this.editor?.state.selection.main.head??this.draft.length)}moveCompletion(e){return this.completions.length?(this.selectedIndex=(this.selectedIndex+e+this.completions.length)%this.completions.length,!0):!1}handleEditorArrow(e,t){return this.completions.length?this.moveCompletion(t===`older`?-1:1):this.browsePromptHistory(e,kE(t))}browsePromptHistory(e,t){let n=gD(this.machineId,this.sessionId);if(n===void 0)return!1;let r=wE(n);if(r.length===0)return!1;let i=e.state.selection.main.head,a=e.state.selection.main.empty,o=e.state.doc.toString();if(this.historyIndex===void 0){if(!(a&&i===o.length&&o.trim()===``))return!1;this.historyDraftBeforeBrowse=o,this.historyIndex=0}else{let e=this.historyIndex+t;if(e<0)return!0;if(e>=r.length)return this.historyIndex=void 0,this.replaceText(this.historyDraftBeforeBrowse),!0;this.historyIndex=e}let s=r[this.historyIndex]??this.historyDraftBeforeBrowse;return this.replaceText(s),!0}closeCompletions(){return this.completions.length?(this.completions=[],!0):!1}handleEditorKeyDown(e,t){if(e.key===`Shift`)return this.explicitShiftKeyActive=!0,!1;if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`r`)return e.preventDefault(),this.openPromptHistoryPicker();if(e.key!==`Enter`)return this.explicitShiftKeyActive=!1,e.key!==`ArrowUp`&&e.key!==`ArrowDown`&&(this.historyIndex=void 0),!1;if(e.defaultPrevented||e.isComposing||t.composing)return!1;let n=LE(e.shiftKey,this.explicitShiftKeyActive,this.mobilePromptEnterMedia);return this.explicitShiftKeyActive=!1,this.handleEditorEnter(t,n)}handleEditorKeyUp(e){return e.key===`Shift`&&(this.explicitShiftKeyActive=!1),!1}resetEditorModifierState(){return this.explicitShiftKeyActive=!1,!1}handleEditorEnter(e,t){if(!t&&this.completions.length){let e=this.completions[this.selectedIndex];return e!==void 0&&this.pick(e),!0}return RE(t,this.mobilePromptEnterMedia,PE())?(this.send(this.canSteer?`steer`:`followUp`),!0):ne(e)||p(e)}handleEditorTab(e){if(this.completions.length){let e=this.completions[this.selectedIndex];return e!==void 0&&this.pick(e),!0}return this.currentTrigger()?.kind===`file`?(this.refreshCompletions(),!0):u.run?.(e)??!1}pick(t){let n=this.editor;if(!n)return;if(t.kind===`history`){this.historyIndex=void 0,this.replaceText(t.insertText),this.completions=[];return}let r=t.kind===`file`&&(t.insertText.endsWith(`/`)||t.cursorOffset!==void 0)?``:` `,i=t.replaceFrom+(t.cursorOffset??t.insertText.length)+r.length,a=t.insertText.endsWith(`"`)&&this.draft.slice(t.replaceTo).startsWith(`"`)?t.replaceTo+1:t.replaceTo;n.dispatch({changes:{from:t.replaceFrom,to:a,insert:`${t.insertText}${r}`},selection:e.cursor(i),scrollIntoView:!0}),this.completions=[]}openPromptHistoryPicker(){let e=gD(this.machineId,this.sessionId);if(e===void 0)return!1;let t=DE(e,this.draft).slice(0,12);return t.length===0?!1:(this.selectedIndex=0,this.completions=t.map(e=>({kind:`history`,replaceFrom:0,replaceTo:this.draft.length,insertText:e,detail:`history`,description:e})),!0)}pendingPromptsForSession(){let e=Cc(this.machineId,this.sessionId??``);return e===``?[]:tf(e)}send(e){if(this.disabled||this.sending)return;if(this.attachingCount>0){this.attachingSettled.then(()=>{this.send(e)});return}let t=this.draft.trim(),n=this.attachments;if(t===``&&n.length===0)return;let r=this.canSteer||this.isCompacting?e:void 0,i=n.length>0?this.currentAttachments():void 0,a=this.effectiveAttachmentDelivery(),o=gD(this.machineId,this.sessionId);o!==void 0&&t!==``&&EE(o,t);let s={text:this.draft,attachments:n};this.resetComposer(),this.deliverAndRestoreOnFailure(t,r,i,a,s)}async deliverAndRestoreOnFailure(e,t,n,r,i){let a,o;try{a=await this.onSend?.(e,t,n,n===void 0?void 0:r)}catch(e){a=!1,o=e}if(a===!1){if($d(o)){let r=Cc(this.machineId,this.sessionId??``);if(r!==``){let i=o instanceof ef?o.clientMessageId:void 0;nf(r,{text:e,...t===void 0?{}:{behavior:t},...i===void 0?{}:{clientMessageId:i},...n===void 0||n.length===0?{}:{attachments:n},at:new Date().toISOString()}),this.pendingPrompts=tf(r);return}}(this.editor?.state.doc.toString()??this.draft).trim()===``&&(this.attachments=i.attachments,this.replaceText(i.text))}}resetComposer(){this.draft=``,this.currentInputMode={kind:`normal`};let e=gD(this.machineId,this.sessionId);e!==void 0&&lu(e),this.completions=[],this.attachments=[],this.attachmentError=void 0,this.syncEditorDoc()}static{this.styles=Qg}};H([b({type:Boolean})],q.prototype,`disabled`,void 0),H([b()],q.prototype,`sessionId`,void 0),H([b()],q.prototype,`cwd`,void 0),H([b()],q.prototype,`machineId`,void 0),H([b()],q.prototype,`projectId`,void 0),H([b()],q.prototype,`workspaceId`,void 0),H([b({type:Boolean})],q.prototype,`canSteer`,void 0),H([b({type:Boolean})],q.prototype,`isCompacting`,void 0),H([b({type:Boolean})],q.prototype,`canStop`,void 0),H([b({attribute:!1})],q.prototype,`status`,void 0),H([b({type:Boolean})],q.prototype,`sending`,void 0),H([b({type:Boolean,reflect:!0})],q.prototype,`collapsed`,void 0),H([b({attribute:!1})],q.prototype,`onSend`,void 0),H([b({attribute:!1})],q.prototype,`onStop`,void 0),H([b({attribute:!1})],q.prototype,`onSelectModel`,void 0),H([b({attribute:!1})],q.prototype,`onSelectThinking`,void 0),H([b({attribute:!1})],q.prototype,`onExpand`,void 0),H([b({attribute:!1})],q.prototype,`availableThinkingLevels`,void 0),H([S(`.markdown-editor`)],q.prototype,`editorHost`,void 0),H([S(`.attachment-input`)],q.prototype,`attachmentInput`,void 0),H([S(`dialog.attachment-zoom`)],q.prototype,`attachmentZoomDialog`,void 0),H([x()],q.prototype,`currentInputMode`,void 0),H([x()],q.prototype,`completions`,void 0),H([x()],q.prototype,`selectedIndex`,void 0),H([b({attribute:!1})],q.prototype,`speechToText`,void 0),H([x()],q.prototype,`voiceState`,void 0),H([x()],q.prototype,`zoomedAttachment`,void 0),H([x()],q.prototype,`attachments`,void 0),H([x()],q.prototype,`attachmentError`,void 0),H([x()],q.prototype,`attachingCount`,void 0),H([x()],q.prototype,`pendingPrompts`,void 0),q=H([y(`prompt-editor`)],q);function hD(e,t){return e===t?!0:e===void 0||t===void 0?!1:e.model?.id===t.model?.id&&e.model?.provider===t.model?.provider&&e.thinkingLevel===t.thinkingLevel}function gD(e,t){if(!(typeof e!=`string`||e===``)&&!(typeof t!=`string`||t===``))return Cc(e,t)}function _D(){return[]}function vD(){return[]}function yD(){return[]}function bD(e){return e===null?[]:Array.from(e.files)}function xD(e){let t=Array.from(e.items);return t.length>0?t.some(e=>e.kind===`file`):Array.from(e.types).includes(`Files`)}function SD(e){return e.kind===`image`?{kind:`image`,mimeType:e.mimeType,data:e.data,name:e.name}:{kind:`file`,mimeType:e.mimeType,data:e.data,name:e.name}}function CD(e){let t=e.trim(),n=t.lastIndexOf(`.`);return n>=0&&n<t.length-1?t.slice(n+1,n+5).toUpperCase():`FILE`}function wD(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>{n(r.error??Error(`Failed to read file`))},r.onload=()=>{let e=r.result;if(typeof e!=`string`){n(Error(`Unexpected file reader result`));return}let i=e.indexOf(`,`);t(i===-1?e:e.slice(i+1))},r.readAsDataURL(e)})}var TD={spellcheck:`true`,autocorrect:`on`,autocapitalize:`sentences`,writingsuggestions:`true`,dir:`auto`},ED={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,dir:`auto`};function DD(e){return xf(e).kind===`normal`?TD:ED}function OD(){let e=document.createElement(`span`);e.className=`composer-placeholder`;let t=document.createElement(`span`);t.className=`composer-placeholder-label`,t.textContent=`Message pi…`;let n=document.createElement(`span`);return n.className=`composer-placeholder-hints`,n.textContent=`/ @ #`,e.append(t,n),e}function kD(e,t){if(!Number.isInteger(e)||e<=0)return;let n=`${String(e)} ${e===1?`warning`:`warnings`}`;return{countText:String(e),accessibleLabel:t?`Minimise ${n}`:`Show ${n} in the warning area`}}var AD=class extends v{constructor(...e){super(...e),this.warningCount=0,this.warningsExpanded=!1,this.handleToggleWarnings=()=>{this.onToggleWarnings?.()}}render(){let e=this.status;if(e===void 0)return g`<div class="bar muted">No session status yet</div>`;let t=e.contextUsage,n=t?t.percent==null?`context ${xg(t.contextWindow)}`:`${t.percent.toFixed(1)}%/${xg(t.contextWindow)}`:`context unknown`,r=e.tokens,i=kD(this.warningCount,this.warningsExpanded);return g`
|
|
3661
|
+
`}async toggleDictation(){this.voice??=new nD({recorder:HE()},{onState:e=>{this.voiceState=e},onTranscript:e=>{this.insertDictatedText(e)}}),await this.voice.toggle(this.speechToText)}insertDictatedText(e){let t=this.editor?.state.doc.toString()??this.draft,n=t===``||t.endsWith(` `)||t.endsWith(`
|
|
3662
|
+
`)?``:` `;this.replaceText(`${t}${n}${e}`)}effectiveAttachmentDelivery(){return vE(`inline`,this.attachments)}createEditor(){!this.editorHost||this.editor!==void 0||(this.editor=new m({parent:this.editorHost,state:l.create({doc:this.draft,extensions:[ee(),re(),t(),d.of(` `),r(a,{fallback:!0}),m.lineWrapping,n(),m.contentAttributes.of(e=>OD(e.state.sliceDoc(0,e.state.selection.main.head))),m.domEventHandlers({keyup:e=>this.handleEditorKeyUp(e),blur:()=>this.resetEditorModifierState()}),s(kD()),this.editableCompartment.of(m.editable.of(!this.disabled)),this.readOnlyCompartment.of(l.readOnly.of(this.disabled)),m.updateListener.of(e=>{e.docChanged&&this.updateDraft(e.state.doc.toString())}),o.of([{any:(e,t)=>this.handleEditorKeyDown(t,e)},{key:`ArrowDown`,run:e=>this.handleEditorArrow(e,`newer`)},{key:`ArrowUp`,run:e=>this.handleEditorArrow(e,`older`)},{key:`Escape`,run:()=>this.closeCompletions()},{key:`Tab`,run:e=>this.handleEditorTab(e)},{key:`Shift-Tab`,run:e=>u.shift?.(e)??!1},{key:`Backspace`,run:e=>te(e)},...c,...f])]})}))}syncEditorDoc(){let t=this.editor;if(!t)return;let n=t.state.doc.toString();n!==this.draft&&t.dispatch({changes:{from:0,to:n.length,insert:this.draft},selection:e.cursor(this.draft.length)})}updateEditorDisabledState(){this.editor?.dispatch({effects:[this.editableCompartment.reconfigure(m.editable.of(!this.disabled)),this.readOnlyCompartment.reconfigure(l.readOnly.of(this.disabled))]})}updateDraft(e){this.draft=e;let t=_D(this.machineId,this.sessionId);t!==void 0&&cu(t,this.draft);let n=xf(this.draft);Cf(n,this.currentInputMode)||(this.currentInputMode=n),this.refreshCompletions()}async refreshCompletions(){let e=this.currentTrigger(),t=++this.requestVersion;if(this.selectedIndex=0,e===void 0){this.completions=[];return}if(e.kind===`command`&&this.sessionId!==void 0&&this.sessionId!==``&&this.cwd!==void 0&&this.cwd!==``){let n=await I.commands({id:this.sessionId,cwd:this.cwd},this.machineId).catch(vD);if(t!==this.requestVersion)return;this.completions=n.filter(t=>t.name.toLowerCase().includes(e.query.toLowerCase())).slice(0,12).map(t=>({kind:`command`,replaceFrom:e.from,replaceTo:e.to,insertText:`/${t.name}`,detail:t.source,...t.description===void 0?{}:{description:t.description}}))}else if(e.kind===`file`&&this.projectId!==void 0&&this.workspaceId!==void 0){let n=await I.files(e.query,{scope:e.fileScope,machineId:this.machineId,projectId:this.projectId,workspaceId:this.workspaceId}).catch(yD);if(t!==this.requestVersion)return;this.completions=n.slice(0,12).map(t=>{let n=gf(t.path,e.quoted===!0,t.path.endsWith(`/`)?e.allPrefix:void 0);return{kind:`file`,replaceFrom:e.from,replaceTo:e.to,insertText:n,detail:t.kind,...t.path.endsWith(`/`)&&n.endsWith(`"`)?{cursorOffset:n.length-1}:{}}})}else if(e.kind===`model`&&this.sessionId!==void 0&&this.sessionId!==``&&this.cwd!==void 0&&this.cwd!==``){let n=await I.models({id:this.sessionId,cwd:this.cwd},this.machineId).then(e=>e.models).catch(bD);if(t!==this.requestVersion)return;this.completions=pf(n,e.query).map(t=>({kind:`model`,replaceFrom:e.from,replaceTo:e.to,...t}))}}currentTrigger(){return df(this.draft,this.editor?.state.selection.main.head??this.draft.length)}moveCompletion(e){return this.completions.length?(this.selectedIndex=(this.selectedIndex+e+this.completions.length)%this.completions.length,!0):!1}handleEditorArrow(e,t){return this.completions.length?this.moveCompletion(t===`older`?-1:1):this.browsePromptHistory(e,AE(t))}browsePromptHistory(e,t){let n=_D(this.machineId,this.sessionId);if(n===void 0)return!1;let r=TE(n);if(r.length===0)return!1;let i=e.state.selection.main.head,a=e.state.selection.main.empty,o=e.state.doc.toString();if(this.historyIndex===void 0){if(!(a&&i===o.length&&o.trim()===``))return!1;this.historyDraftBeforeBrowse=o,this.historyIndex=0}else{let e=this.historyIndex+t;if(e<0)return!0;if(e>=r.length)return this.historyIndex=void 0,this.replaceText(this.historyDraftBeforeBrowse),!0;this.historyIndex=e}let s=r[this.historyIndex]??this.historyDraftBeforeBrowse;return this.replaceText(s),!0}closeCompletions(){return this.completions.length?(this.completions=[],!0):!1}handleEditorKeyDown(e,t){if(e.key===`Shift`)return this.explicitShiftKeyActive=!0,!1;if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`r`)return e.preventDefault(),this.openPromptHistoryPicker();if(e.key!==`Enter`)return this.explicitShiftKeyActive=!1,e.key!==`ArrowUp`&&e.key!==`ArrowDown`&&(this.historyIndex=void 0),!1;if(e.defaultPrevented||e.isComposing||t.composing)return!1;let n=RE(e.shiftKey,this.explicitShiftKeyActive,this.mobilePromptEnterMedia);return this.explicitShiftKeyActive=!1,this.handleEditorEnter(t,n)}handleEditorKeyUp(e){return e.key===`Shift`&&(this.explicitShiftKeyActive=!1),!1}resetEditorModifierState(){return this.explicitShiftKeyActive=!1,!1}handleEditorEnter(e,t){if(!t&&this.completions.length){let e=this.completions[this.selectedIndex];return e!==void 0&&this.pick(e),!0}return zE(t,this.mobilePromptEnterMedia,FE())?(this.send(this.canSteer?`steer`:`followUp`),!0):ne(e)||p(e)}handleEditorTab(e){if(this.completions.length){let e=this.completions[this.selectedIndex];return e!==void 0&&this.pick(e),!0}return this.currentTrigger()?.kind===`file`?(this.refreshCompletions(),!0):u.run?.(e)??!1}pick(t){let n=this.editor;if(!n)return;if(t.kind===`history`){this.historyIndex=void 0,this.replaceText(t.insertText),this.completions=[];return}let r=t.kind===`file`&&(t.insertText.endsWith(`/`)||t.cursorOffset!==void 0)?``:` `,i=t.replaceFrom+(t.cursorOffset??t.insertText.length)+r.length,a=t.insertText.endsWith(`"`)&&this.draft.slice(t.replaceTo).startsWith(`"`)?t.replaceTo+1:t.replaceTo;n.dispatch({changes:{from:t.replaceFrom,to:a,insert:`${t.insertText}${r}`},selection:e.cursor(i),scrollIntoView:!0}),this.completions=[]}openPromptHistoryPicker(){let e=_D(this.machineId,this.sessionId);if(e===void 0)return!1;let t=OE(e,this.draft).slice(0,12);return t.length===0?!1:(this.selectedIndex=0,this.completions=t.map(e=>({kind:`history`,replaceFrom:0,replaceTo:this.draft.length,insertText:e,detail:`history`,description:e})),!0)}pendingPromptsForSession(){let e=Cc(this.machineId,this.sessionId??``);return e===``?[]:tf(e)}send(e){if(this.disabled||this.sending)return;if(this.attachingCount>0){this.attachingSettled.then(()=>{this.send(e)});return}let t=this.draft.trim(),n=this.attachments;if(t===``&&n.length===0)return;let r=this.canSteer||this.isCompacting?e:void 0,i=n.length>0?this.currentAttachments():void 0,a=this.effectiveAttachmentDelivery(),o=_D(this.machineId,this.sessionId);o!==void 0&&t!==``&&DE(o,t);let s={text:this.draft,attachments:n};this.resetComposer(),this.deliverAndRestoreOnFailure(t,r,i,a,s)}async deliverAndRestoreOnFailure(e,t,n,r,i){let a,o;try{a=await this.onSend?.(e,t,n,n===void 0?void 0:r)}catch(e){a=!1,o=e}if(a===!1){if($d(o)){let r=Cc(this.machineId,this.sessionId??``);if(r!==``){let i=o instanceof ef?o.clientMessageId:void 0;nf(r,{text:e,...t===void 0?{}:{behavior:t},...i===void 0?{}:{clientMessageId:i},...n===void 0||n.length===0?{}:{attachments:n},at:new Date().toISOString()}),this.pendingPrompts=tf(r);return}}(this.editor?.state.doc.toString()??this.draft).trim()===``&&(this.attachments=i.attachments,this.replaceText(i.text))}}resetComposer(){this.draft=``,this.currentInputMode={kind:`normal`};let e=_D(this.machineId,this.sessionId);e!==void 0&&lu(e),this.completions=[],this.attachments=[],this.attachmentError=void 0,this.syncEditorDoc()}static{this.styles=Qg}};H([b({type:Boolean})],q.prototype,`disabled`,void 0),H([b()],q.prototype,`sessionId`,void 0),H([b()],q.prototype,`cwd`,void 0),H([b()],q.prototype,`machineId`,void 0),H([b()],q.prototype,`projectId`,void 0),H([b()],q.prototype,`workspaceId`,void 0),H([b({type:Boolean})],q.prototype,`canSteer`,void 0),H([b({type:Boolean})],q.prototype,`isCompacting`,void 0),H([b({type:Boolean})],q.prototype,`canStop`,void 0),H([b({attribute:!1})],q.prototype,`status`,void 0),H([b({type:Boolean})],q.prototype,`sending`,void 0),H([b({type:Boolean,reflect:!0})],q.prototype,`collapsed`,void 0),H([b({attribute:!1})],q.prototype,`onSend`,void 0),H([b({attribute:!1})],q.prototype,`onStop`,void 0),H([b({attribute:!1})],q.prototype,`onSelectModel`,void 0),H([b({attribute:!1})],q.prototype,`onSelectThinking`,void 0),H([b({attribute:!1})],q.prototype,`onExpand`,void 0),H([b({attribute:!1})],q.prototype,`availableThinkingLevels`,void 0),H([S(`.markdown-editor`)],q.prototype,`editorHost`,void 0),H([S(`.attachment-input`)],q.prototype,`attachmentInput`,void 0),H([S(`dialog.attachment-zoom`)],q.prototype,`attachmentZoomDialog`,void 0),H([x()],q.prototype,`currentInputMode`,void 0),H([x()],q.prototype,`completions`,void 0),H([x()],q.prototype,`selectedIndex`,void 0),H([b({attribute:!1})],q.prototype,`speechToText`,void 0),H([x()],q.prototype,`voiceState`,void 0),H([x()],q.prototype,`zoomedAttachment`,void 0),H([x()],q.prototype,`attachments`,void 0),H([x()],q.prototype,`attachmentError`,void 0),H([x()],q.prototype,`attachingCount`,void 0),H([x()],q.prototype,`pendingPrompts`,void 0),q=H([y(`prompt-editor`)],q);function gD(e,t){return e===t?!0:e===void 0||t===void 0?!1:e.model?.id===t.model?.id&&e.model?.provider===t.model?.provider&&e.thinkingLevel===t.thinkingLevel}function _D(e,t){if(!(typeof e!=`string`||e===``)&&!(typeof t!=`string`||t===``))return Cc(e,t)}function vD(){return[]}function yD(){return[]}function bD(){return[]}function xD(e){return e===null?[]:Array.from(e.files)}function SD(e){let t=Array.from(e.items);return t.length>0?t.some(e=>e.kind===`file`):Array.from(e.types).includes(`Files`)}function CD(e){return e.kind===`image`?{kind:`image`,mimeType:e.mimeType,data:e.data,name:e.name}:{kind:`file`,mimeType:e.mimeType,data:e.data,name:e.name}}function wD(e){let t=e.trim(),n=t.lastIndexOf(`.`);return n>=0&&n<t.length-1?t.slice(n+1,n+5).toUpperCase():`FILE`}function TD(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>{n(r.error??Error(`Failed to read file`))},r.onload=()=>{let e=r.result;if(typeof e!=`string`){n(Error(`Unexpected file reader result`));return}let i=e.indexOf(`,`);t(i===-1?e:e.slice(i+1))},r.readAsDataURL(e)})}var ED={spellcheck:`true`,autocorrect:`on`,autocapitalize:`sentences`,writingsuggestions:`true`,dir:`auto`},DD={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,dir:`auto`};function OD(e){return xf(e).kind===`normal`?ED:DD}function kD(){let e=document.createElement(`span`);e.className=`composer-placeholder`;let t=document.createElement(`span`);t.className=`composer-placeholder-label`,t.textContent=`Message pi…`;let n=document.createElement(`span`);return n.className=`composer-placeholder-hints`,n.textContent=`/ @ #`,e.append(t,n),e}function AD(e,t){if(!Number.isInteger(e)||e<=0)return;let n=`${String(e)} ${e===1?`warning`:`warnings`}`;return{countText:String(e),accessibleLabel:t?`Minimise ${n}`:`Show ${n} in the warning area`}}var jD=class extends v{constructor(...e){super(...e),this.warningCount=0,this.warningsExpanded=!1,this.handleToggleWarnings=()=>{this.onToggleWarnings?.()}}render(){let e=this.status;if(e===void 0)return g`<div class="bar muted">No session status yet</div>`;let t=e.contextUsage,n=t?t.percent==null?`context ${xg(t.contextWindow)}`:`${t.percent.toFixed(1)}%/${xg(t.contextWindow)}`:`context unknown`,r=e.tokens,i=AD(this.warningCount,this.warningsExpanded);return g`
|
|
3663
3663
|
<div class="bar">
|
|
3664
3664
|
${i===void 0||this.onToggleWarnings===void 0?null:g`
|
|
3665
3665
|
<button
|
|
@@ -3680,7 +3680,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3680
3680
|
<span>${wg(e.cost)}</span>
|
|
3681
3681
|
${e.pendingMessageCount>0?g`<span>${String(e.pendingMessageCount)} queued</span>`:null}
|
|
3682
3682
|
</div>
|
|
3683
|
-
`}static{this.styles=Xg}};H([b({attribute:!1})],
|
|
3683
|
+
`}static{this.styles=Xg}};H([b({attribute:!1})],jD.prototype,`status`,void 0),H([b({type:Number})],jD.prototype,`warningCount`,void 0),H([b({type:Boolean})],jD.prototype,`warningsExpanded`,void 0),H([b({attribute:!1})],jD.prototype,`onToggleWarnings`,void 0),jD=H([y(`status-bar`)],jD);function MD(e){return e.composedPath().some(e=>e instanceof HTMLButtonElement||e instanceof HTMLAnchorElement&&e.hasAttribute(`href`))}var ND=class extends v{constructor(...e){super(...e),this.title=`Select`,this.searchable=!1,this.options=[],this.selectedIndex=0,this.query=``}render(){let e=this.filteredOptions();return g`
|
|
3684
3684
|
<modal-surface
|
|
3685
3685
|
.onClose=${()=>this.onCancel?.()}
|
|
3686
3686
|
.initialFocus=${this.searchable?`input`:`.options`}
|
|
@@ -3697,7 +3697,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3697
3697
|
<button
|
|
3698
3698
|
class=${t===this.selectedIndex?`selected`:``}
|
|
3699
3699
|
aria-current=${t===this.selectedIndex?`true`:_}
|
|
3700
|
-
${
|
|
3700
|
+
${mD(t===this.selectedIndex,e.value)}
|
|
3701
3701
|
@focus=${()=>{this.selectedIndex=t}}
|
|
3702
3702
|
@click=${()=>this.onPick?.(e.value)}
|
|
3703
3703
|
>
|
|
@@ -3708,7 +3708,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3708
3708
|
${e.length===0?g`<div class="empty">No matching options</div>`:null}
|
|
3709
3709
|
</div>
|
|
3710
3710
|
</modal-surface>
|
|
3711
|
-
`}firstUpdated(){this.selectInitialValue()}selectInitialValue(){if(this.selectedValue===void 0)return;let e=this.filteredOptions().findIndex(e=>e.value===this.selectedValue);e>=0&&(this.selectedIndex=e)}handleSearchInput(e){e.target instanceof HTMLInputElement&&(this.query=e.target.value,this.selectedIndex=0)}filteredOptions(){return sf(this.options,this.query,e=>`${e.label} ${e.description??``} ${e.value}`)}handleKeyDown(e){if(
|
|
3711
|
+
`}firstUpdated(){this.selectInitialValue()}selectInitialValue(){if(this.selectedValue===void 0)return;let e=this.filteredOptions().findIndex(e=>e.value===this.selectedValue);e>=0&&(this.selectedIndex=e)}handleSearchInput(e){e.target instanceof HTMLInputElement&&(this.query=e.target.value,this.selectedIndex=0)}filteredOptions(){return sf(this.options,this.query,e=>`${e.label} ${e.description??``} ${e.value}`)}handleKeyDown(e){if(MD(e))return;let t=this.filteredOptions();if(e.key===`ArrowDown`)e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex+1)%t.length);else if(e.key===`ArrowUp`)e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex-1+t.length)%t.length);else if(e.key===`Enter`){e.preventDefault();let n=t[this.selectedIndex];n&&this.onPick?.(n.value)}}static{this.styles=h`
|
|
3712
3712
|
:host { position: fixed; inset: 0; z-index: var(--pi-layer-popover); color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
3713
3713
|
modal-surface { --modal-surface-width: min(720px, calc(100vw - 40px)); --modal-surface-max-height: min(640px, calc(100vh - 40px)); }
|
|
3714
3714
|
header { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-bottom: 1px solid var(--pi-border); }
|
|
@@ -3724,7 +3724,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3724
3724
|
.options button.selected, .options button:hover { background: var(--pi-selection-bg); }
|
|
3725
3725
|
small { display: block; margin-top: 4px; color: var(--pi-muted); }
|
|
3726
3726
|
.empty { padding: 24px; color: var(--pi-muted); text-align: center; }
|
|
3727
|
-
`}};H([b()],
|
|
3727
|
+
`}};H([b()],ND.prototype,`title`,void 0),H([b({type:Boolean})],ND.prototype,`searchable`,void 0),H([b({attribute:!1})],ND.prototype,`options`,void 0),H([b({attribute:!1})],ND.prototype,`selectedValue`,void 0),H([b({attribute:!1})],ND.prototype,`onPick`,void 0),H([b({attribute:!1})],ND.prototype,`onCancel`,void 0),H([x()],ND.prototype,`selectedIndex`,void 0),H([x()],ND.prototype,`query`,void 0),ND=H([y(`command-picker`)],ND);function PD(e,t){let n=e.toLowerCase();return t.split(/\s+/).every(e=>n.includes(e))}function FD(e){return e.trim().toLowerCase()}function ID(e){return`${e.provider}/${e.id}`}function LD(e,t){let n=FD(t);return n===``?[...e]:e.filter(e=>PD(`${e.label} ${e.description??``} ${e.value}`,n))}function RD(e,t){let n=FD(t),r=n===``?[...e]:e.filter(e=>PD(`${e.provider} ${e.id} ${e.name??``}`,n));return{rows:r,showGroupHeaders:n===``&&r.some(e=>e.enabled)&&r.some(e=>!e.enabled)}}var zD=class extends v{constructor(...e){super(...e),this.title=`Select Model`,this.options=[],this.catalog=[],this.mode=`enabled`,this.selectedIndex=0,this.query=``,this.pendingToggles=new Set}render(){let e=this.visibleRows();return g`
|
|
3728
3728
|
<modal-surface
|
|
3729
3729
|
.onClose=${()=>this.onCancel?.()}
|
|
3730
3730
|
.initialFocus=${`input.search`}
|
|
@@ -3745,19 +3745,19 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3745
3745
|
${e.length===0?g`<div class="empty">No matching options</div>`:null}
|
|
3746
3746
|
</div>
|
|
3747
3747
|
</modal-surface>
|
|
3748
|
-
`}firstUpdated(){this.anchorSelectionToSelectedValue()}willUpdate(e){if(!e.has(`catalog`)||this.mode!==`all`)return;let t=e.get(`catalog`);if(t===void 0)return;let n=
|
|
3748
|
+
`}firstUpdated(){this.anchorSelectionToSelectedValue()}willUpdate(e){if(!e.has(`catalog`)||this.mode!==`all`)return;let t=e.get(`catalog`);if(t===void 0)return;let n=RD(t,this.query).rows[this.selectedIndex],r=RD(this.catalog,this.query).rows,i=n===void 0?void 0:ID(n),a=i===void 0?-1:r.findIndex(e=>ID(e)===i);this.selectedIndex=a>=0?a:Math.min(this.selectedIndex,Math.max(r.length-1,0))}renderScopeToggleButton(e,t){return g`<button aria-pressed=${this.mode===e?`true`:`false`} @click=${()=>{this.selectMode(e)}}>${t}</button>`}renderEnabledList(){return LD(this.options,this.query).map((e,t)=>g`
|
|
3749
3749
|
<button
|
|
3750
3750
|
class=${t===this.selectedIndex?`selected`:``}
|
|
3751
3751
|
aria-current=${t===this.selectedIndex?`true`:_}
|
|
3752
|
-
${
|
|
3752
|
+
${mD(t===this.selectedIndex,e.value)}
|
|
3753
3753
|
@focus=${()=>{this.selectedIndex=t}}
|
|
3754
3754
|
@click=${()=>this.onPick?.(e.value)}
|
|
3755
3755
|
>
|
|
3756
3756
|
<span>${e.label}</span>
|
|
3757
3757
|
${e.description!==void 0&&e.description!==``?g`<small>${e.description}</small>`:null}
|
|
3758
3758
|
</button>
|
|
3759
|
-
`)}renderCatalogList(){let e=
|
|
3760
|
-
<div class="catalog-row ${r?`selected`:``}" ${
|
|
3759
|
+
`)}renderCatalogList(){let e=RD(this.catalog,this.query),t=[],n;return e.rows.forEach((r,i)=>{e.showGroupHeaders&&r.enabled!==n&&t.push(g`<div class="group-header">${r.enabled?`Enabled`:`Other models`}</div>`),n=r.enabled,t.push(this.renderCatalogRow(r,i))}),t}renderCatalogRow(e,t){let n=ID(e),r=t===this.selectedIndex,i=this.pendingToggles.has(n);return g`
|
|
3760
|
+
<div class="catalog-row ${r?`selected`:``}" ${mD(r,n)}>
|
|
3761
3761
|
<input
|
|
3762
3762
|
type="checkbox"
|
|
3763
3763
|
.checked=${e.enabled}
|
|
@@ -3775,7 +3775,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3775
3775
|
<small>${e.provider}</small>
|
|
3776
3776
|
</button>
|
|
3777
3777
|
</div>
|
|
3778
|
-
`}visibleRows(){return this.mode===`all`?
|
|
3778
|
+
`}visibleRows(){return this.mode===`all`?RD(this.catalog,this.query).rows.map(e=>({value:ID(e),entry:e})):LD(this.options,this.query).map(e=>({value:e.value}))}anchorSelectionToSelectedValue(){if(this.selectedValue===void 0){this.selectedIndex=0;return}let e=this.visibleRows().findIndex(e=>e.value===this.selectedValue);this.selectedIndex=e>=0?e:0}selectMode(e){e!==this.mode&&(this.mode=e,this.anchorSelectionToSelectedValue())}handleSearchInput(e){e.target instanceof HTMLInputElement&&(this.query=e.target.value,this.selectedIndex=0)}handleKeyDown(e){if(MD(e))return;let t=this.visibleRows();if(e.key===`ArrowDown`)e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex+1)%t.length);else if(e.key===`ArrowUp`)e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex-1+t.length)%t.length);else if(e.key===`Enter`){e.preventDefault();let n=t[this.selectedIndex];n!==void 0&&this.onPick?.(n.value)}else if(e.key===` `&&this.mode===`all`){if(e.composedPath().some(e=>e instanceof HTMLInputElement))return;let n=t[this.selectedIndex];if(n?.entry===void 0)return;e.preventDefault(),this.requestEnabledToggle(n.entry)}}handleEnableToggleClick(e,t){t.preventDefault(),t.currentTarget instanceof HTMLInputElement&&(t.currentTarget.checked=e.enabled),this.requestEnabledToggle(e)}requestEnabledToggle(e){let t=ID(e);if(this.pendingToggles.has(t))return;let n=new Set(this.pendingToggles);n.add(t),this.pendingToggles=n,this.settleEnabledToggle(t,e)}async settleEnabledToggle(e,t){try{await this.onToggleEnabled?.(t.provider,t.id,!t.enabled)}catch(t){console.warn(`Failed to toggle model ${e}`,t)}finally{let t=new Set(this.pendingToggles);t.delete(e),this.pendingToggles=t}}static{this.styles=h`
|
|
3779
3779
|
:host { position: fixed; inset: 0; z-index: var(--pi-layer-popover); color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
3780
3780
|
modal-surface { --modal-surface-width: min(720px, calc(100vw - 40px)); --modal-surface-max-height: min(640px, calc(100vh - 40px)); }
|
|
3781
3781
|
header { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-bottom: 1px solid var(--pi-border); }
|
|
@@ -3796,7 +3796,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3796
3796
|
.group-header { padding: 8px 12px 4px; color: var(--pi-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
|
|
3797
3797
|
small { display: block; margin-top: 4px; color: var(--pi-muted); }
|
|
3798
3798
|
.empty { padding: 24px; color: var(--pi-muted); text-align: center; }
|
|
3799
|
-
`}};H([b()],
|
|
3799
|
+
`}};H([b()],zD.prototype,`title`,void 0),H([b({attribute:!1})],zD.prototype,`options`,void 0),H([b({attribute:!1})],zD.prototype,`catalog`,void 0),H([b({attribute:!1})],zD.prototype,`selectedValue`,void 0),H([b({attribute:!1})],zD.prototype,`onPick`,void 0),H([b({attribute:!1})],zD.prototype,`onCancel`,void 0),H([b({attribute:!1})],zD.prototype,`onToggleEnabled`,void 0),H([x()],zD.prototype,`mode`,void 0),H([x()],zD.prototype,`selectedIndex`,void 0),H([x()],zD.prototype,`query`,void 0),H([x()],zD.prototype,`pendingToggles`,void 0),zD=H([y(`model-picker`)],zD);var BD=class extends v{constructor(...e){super(...e),this.actions=[],this.queryText=``,this.selectedIndex=0}render(){let e=this.filteredActions();return g`
|
|
3800
3800
|
<modal-surface
|
|
3801
3801
|
.onClose=${()=>this.onCancel?.()}
|
|
3802
3802
|
.initialFocus=${`input`}
|
|
@@ -3818,7 +3818,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3818
3818
|
?disabled=${e.enabled===!1}
|
|
3819
3819
|
title=${e.disabledReason??e.title}
|
|
3820
3820
|
aria-current=${t===this.selectedIndex?`true`:_}
|
|
3821
|
-
${
|
|
3821
|
+
${mD(t===this.selectedIndex,e.id)}
|
|
3822
3822
|
@focus=${()=>{this.selectedIndex=t}}
|
|
3823
3823
|
@click=${()=>{this.run(e)}}
|
|
3824
3824
|
>
|
|
@@ -3833,7 +3833,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3833
3833
|
`)}
|
|
3834
3834
|
</div>
|
|
3835
3835
|
</modal-surface>
|
|
3836
|
-
`}updated(e){if(!e.has(`actions`)&&!e.has(`queryText`))return;let t=Math.max(0,this.filteredActions().length-1);this.selectedIndex>t&&(this.selectedIndex=t)}filteredActions(){return
|
|
3836
|
+
`}updated(e){if(!e.has(`actions`)&&!e.has(`queryText`))return;let t=Math.max(0,this.filteredActions().length-1);this.selectedIndex>t&&(this.selectedIndex=t)}filteredActions(){return VD(this.actions,this.queryText)}handleKeyDown(e){if(MD(e))return;let t=this.filteredActions();if(e.key===`ArrowDown`)e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex+1)%t.length);else if(e.key===`ArrowUp`)e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex-1+t.length)%t.length);else if(e.key===`Enter`){e.preventDefault();let n=t[this.selectedIndex];n!==void 0&&this.run(n)}}run(e){e.enabled!==!1&&this.onRun?.(e)}static{this.styles=h`
|
|
3837
3837
|
:host { position: fixed; inset: 0; z-index: var(--pi-layer-overlay); color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
3838
3838
|
modal-surface { --palette-top: min(12dvh, 90px); --palette-bottom: max(20px, env(safe-area-inset-bottom)); --modal-surface-place-items: start center; --modal-surface-backdrop-padding: var(--palette-top) 20px var(--palette-bottom); --modal-surface-max-height: min(640px, calc(100dvh - var(--palette-top) - var(--palette-bottom))); }
|
|
3839
3839
|
header { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px; border-bottom: 1px solid var(--pi-border); }
|
|
@@ -3855,7 +3855,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3855
3855
|
.group { grid-column: 1 / -1; font-size: 12px; }
|
|
3856
3856
|
kbd { align-self: center; border: 1px solid var(--pi-border); border-radius: 6px; background: var(--pi-surface); color: var(--pi-muted); padding: 2px 6px; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }
|
|
3857
3857
|
.empty { padding: 24px; color: var(--pi-muted); text-align: center; }
|
|
3858
|
-
`}};H([b({attribute:!1})],
|
|
3858
|
+
`}};H([b({attribute:!1})],BD.prototype,`actions`,void 0),H([b({attribute:!1})],BD.prototype,`onRun`,void 0),H([b({attribute:!1})],BD.prototype,`onCancel`,void 0),H([x()],BD.prototype,`queryText`,void 0),H([x()],BD.prototype,`selectedIndex`,void 0),BD=H([y(`action-palette`)],BD);function VD(e,t){let n=FD(t);return e.filter(e=>e.enabled!==!1||e.disabledReason!==void 0).filter(e=>n===``||PD([e.title,e.description??``,e.disabledReason??``,e.group??``,e.shortcut??``].join(` `),n))}var HD=[`error`,`waiting`,`interrupted`,`active`,`unread`,`pinned`,`today`,`yesterday`,`earlier`],UD={error:`Needs attention`,waiting:`Waiting for you`,interrupted:`Interrupted`,active:`Working`,unread:`Finished`,pinned:`Pinned`,today:`Today`,yesterday:`Yesterday`,earlier:`Earlier`},WD=1440*60*1e3,GD=new Set;function KD(e){let t=e.sessions.filter(e=>e.archived!==!0).filter(t=>DS(t,e.query)),n=new Map;for(let r of t){let t=qD(r,{active:e.activeSessionIds,error:e.errorSessionIds??GD,waiting:e.waitingSessionIds??GD,unread:e.unreadSessionIds??GD,interrupted:e.interruptedSessionIds??GD,pinned:e.pinnedSessionIds??GD},e.now),i=n.get(t)??[];i.push(r),n.set(t,i)}let r=[];for(let e of HD){let t=n.get(e);t===void 0||t.length===0||r.push({id:e,title:UD[e],sessions:t.sort(JD)})}return{groups:r,matchCount:t.length}}function qD(e,t,n){if(t.error.has(e.id))return`error`;if(t.waiting.has(e.id))return`waiting`;if(t.interrupted.has(e.id)&&!t.active.has(e.id))return`interrupted`;if(t.active.has(e.id))return`active`;if(t.unread.has(e.id))return`unread`;if(t.pinned.has(e.id))return`pinned`;let r=Date.parse(e.modified);if(Number.isNaN(r))return`earlier`;let i=n-r;return i<WD?`today`:i<2*WD?`yesterday`:`earlier`}function JD(e,t){return YD(t.modified)-YD(e.modified)}function YD(e){let t=Date.parse(e);return Number.isNaN(t)?0:t}function XD(e,t,n){let r=new Set(n.filter(e=>e.projectId===t.projectId).map(e=>e.path)),i=t.projectId===void 0||r.size===0?void 0:r;return e.filter(e=>!(t.workspacePath!==void 0&&e.cwd!==t.workspacePath||i!==void 0&&!i.has(e.cwd)))}function ZD(e){return e.machineId!==void 0||e.projectId!==void 0||e.workspacePath!==void 0}function QD(e,t){let n=t.trim().toLowerCase().split(/\s+/u).filter(Boolean);return n.length===0?[...e]:e.filter(e=>{let t=`${e.label}\n${e.path}`.toLowerCase();return n.every(e=>t.includes(e))})}function $D(e,t){let n=t.find(t=>t.path===e.cwd),r=`${String(e.messageCount)} ${e.messageCount===1?`message`:`messages`}`;return n===void 0?r:`${n.label} · ${r}`}function eO(e,t,n){return e.some(e=>e.id===t)?e.map(e=>e.id===t?{...e,name:n}:e):e}function tO(e,t,n){let r=new Map;for(let i of e){let e=th(t[i.id],n[i.id]);e!==void 0&&r.set(i.id,e)}return r}function nO(e){return e}var J=class extends v{constructor(...e){super(...e),this.loading=!1,this.sessions=[],this.workspaces=[],this.activeSessionIds=new Set,this.waitingSessionIds=new Set,this.unreadSessionIds=new Set,this.interruptedSessionIds=new Set,this.errorSessionIds=new Set,this.pinnedSessionIds=new Set,this.projects=[],this.sessionStates=new Map,this.canStartSession=!1,this.query=``,this.filter={},this.renameDraft=``,this.longPress=new Tx({onLongPress:()=>{this.openMenuSessionId=this.heldSession?.id},setTimer:(e,t)=>window.setTimeout(e,t),clearTimer:e=>{window.clearTimeout(e)}})}render(){let e=this.model(),t=QD(this.workspaces,this.query).filter(e=>e.id!==this.selectedWorkspace?.id);return g`
|
|
3859
3859
|
<modal-surface
|
|
3860
3860
|
.onClose=${()=>this.onClose?.()}
|
|
3861
3861
|
.initialFocus=${zt({touchPrimary:Bt()})}
|
|
@@ -3918,7 +3918,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3918
3918
|
<button
|
|
3919
3919
|
class=${`row session-row ${t?`selected`:``} ${n?`unread`:``}`}
|
|
3920
3920
|
aria-current=${t?`true`:_}
|
|
3921
|
-
${
|
|
3921
|
+
${mD(t,e.id)}
|
|
3922
3922
|
@click=${()=>{this.openSession(e)}}
|
|
3923
3923
|
@contextmenu=${t=>{t.preventDefault(),this.openMenuSessionId=e.id}}
|
|
3924
3924
|
@pointerdown=${t=>{this.heldSession=e,this.longPress.start(t)}}
|
|
@@ -3927,7 +3927,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3927
3927
|
@pointercancel=${()=>{this.longPress.cancel()}}
|
|
3928
3928
|
>
|
|
3929
3929
|
<span class="row-title" dir="auto">${r?g`<span class="pin-mark" title="Pinned" aria-label="Pinned">${`⚑`}</span> `:_}${SS(e)}</span>
|
|
3930
|
-
<span class="row-subtitle">${
|
|
3930
|
+
<span class="row-subtitle">${$D(e,this.workspaces)}</span>
|
|
3931
3931
|
<span class="row-state">${Vx(o,n&&o===void 0?`Unread activity`:void 0)}</span>
|
|
3932
3932
|
${a?g`<span class="row-flag interrupted" title="A restart interrupted this run" aria-label="A restart interrupted this run"></span>`:null}
|
|
3933
3933
|
${o===void 0&&!a&&n?g`<span class="row-flag unread" title="Unread activity" aria-label="Unread activity"></span>`:null}
|
|
@@ -3962,7 +3962,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3962
3962
|
<button type="button" title="Cancel rename" aria-label="Cancel rename" @click=${()=>{this.renamingSessionId=void 0}}>${`×`}</button>
|
|
3963
3963
|
</div>
|
|
3964
3964
|
</form>
|
|
3965
|
-
`}togglePin(e){this.openMenuSessionId=void 0,this.onTogglePin?.(e)}startRename(e){this.openMenuSessionId=void 0,this.renameDraft=SS(e),this.renamingSessionId=e.id}async confirmRename(e){let t=this.renameDraft.trim();this.renamingSessionId=void 0,!(t===``||t===SS(e))&&await this.onRenameSession?.(e,t)}handleKeyDown(e){if(e.key!==`Enter`||
|
|
3965
|
+
`}togglePin(e){this.openMenuSessionId=void 0,this.onTogglePin?.(e)}startRename(e){this.openMenuSessionId=void 0,this.renameDraft=SS(e),this.renamingSessionId=e.id}async confirmRename(e){let t=this.renameDraft.trim();this.renamingSessionId=void 0,!(t===``||t===SS(e))&&await this.onRenameSession?.(e,t)}handleKeyDown(e){if(e.key!==`Enter`||MD(e))return;let t=this.model().groups[0]?.sessions[0];t!==void 0&&(e.preventDefault(),this.openSession(t))}model(){return KD({sessions:XD(this.sessions,this.filter,this.workspaces),activeSessionIds:this.activeSessionIds,errorSessionIds:this.errorSessionIds,waitingSessionIds:this.waitingSessionIds,unreadSessionIds:this.unreadSessionIds,interruptedSessionIds:this.interruptedSessionIds,pinnedSessionIds:this.pinnedSessionIds,query:this.query,now:Date.now()})}renderFilters(){let e=nO(this.projects);if(e.length===0&&this.workspaces.length<2)return _;let t=ZD(this.filter);return g`
|
|
3966
3966
|
<div class="filters" role="group" aria-label="Filter sessions by context">
|
|
3967
3967
|
<button
|
|
3968
3968
|
type="button"
|
|
@@ -4066,7 +4066,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4066
4066
|
.empty { margin: var(--pi-space-7) var(--pi-space-2); color: var(--pi-muted); }
|
|
4067
4067
|
footer { flex: 0 0 auto; padding: var(--pi-space-5); padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--pi-border); }
|
|
4068
4068
|
footer button { width: 100%; min-height: 44px; border: 1px solid var(--pi-border); border-radius: var(--pi-radius-lg); background: var(--pi-surface); color: var(--pi-text); cursor: pointer; }
|
|
4069
|
-
`]}};H([b({type:Boolean})],J.prototype,`loading`,void 0),H([b({attribute:!1})],J.prototype,`sessions`,void 0),H([b({attribute:!1})],J.prototype,`workspaces`,void 0),H([b({attribute:!1})],J.prototype,`selectedSession`,void 0),H([b({attribute:!1})],J.prototype,`selectedWorkspace`,void 0),H([b({attribute:!1})],J.prototype,`activeSessionIds`,void 0),H([b({attribute:!1})],J.prototype,`waitingSessionIds`,void 0),H([b({attribute:!1})],J.prototype,`unreadSessionIds`,void 0),H([b({attribute:!1})],J.prototype,`interruptedSessionIds`,void 0),H([b({attribute:!1})],J.prototype,`errorSessionIds`,void 0),H([b({attribute:!1})],J.prototype,`pinnedSessionIds`,void 0),H([b({attribute:!1})],J.prototype,`projects`,void 0),H([b({attribute:!1})],J.prototype,`sessionStates`,void 0),H([b({type:Boolean})],J.prototype,`canStartSession`,void 0),H([b({attribute:!1})],J.prototype,`onCreateSession`,void 0),H([b({attribute:!1})],J.prototype,`onOpenSession`,void 0),H([b({attribute:!1})],J.prototype,`onSelectWorkspace`,void 0),H([b({attribute:!1})],J.prototype,`onBrowse`,void 0),H([b({attribute:!1})],J.prototype,`onClose`,void 0),H([b({attribute:!1})],J.prototype,`onTogglePin`,void 0),H([b({attribute:!1})],J.prototype,`onRenameSession`,void 0),H([x()],J.prototype,`query`,void 0),H([x()],J.prototype,`filter`,void 0),H([x()],J.prototype,`openMenuSessionId`,void 0),H([x()],J.prototype,`renamingSessionId`,void 0),J=H([y(`quick-switcher`)],J);var
|
|
4069
|
+
`]}};H([b({type:Boolean})],J.prototype,`loading`,void 0),H([b({attribute:!1})],J.prototype,`sessions`,void 0),H([b({attribute:!1})],J.prototype,`workspaces`,void 0),H([b({attribute:!1})],J.prototype,`selectedSession`,void 0),H([b({attribute:!1})],J.prototype,`selectedWorkspace`,void 0),H([b({attribute:!1})],J.prototype,`activeSessionIds`,void 0),H([b({attribute:!1})],J.prototype,`waitingSessionIds`,void 0),H([b({attribute:!1})],J.prototype,`unreadSessionIds`,void 0),H([b({attribute:!1})],J.prototype,`interruptedSessionIds`,void 0),H([b({attribute:!1})],J.prototype,`errorSessionIds`,void 0),H([b({attribute:!1})],J.prototype,`pinnedSessionIds`,void 0),H([b({attribute:!1})],J.prototype,`projects`,void 0),H([b({attribute:!1})],J.prototype,`sessionStates`,void 0),H([b({type:Boolean})],J.prototype,`canStartSession`,void 0),H([b({attribute:!1})],J.prototype,`onCreateSession`,void 0),H([b({attribute:!1})],J.prototype,`onOpenSession`,void 0),H([b({attribute:!1})],J.prototype,`onSelectWorkspace`,void 0),H([b({attribute:!1})],J.prototype,`onBrowse`,void 0),H([b({attribute:!1})],J.prototype,`onClose`,void 0),H([b({attribute:!1})],J.prototype,`onTogglePin`,void 0),H([b({attribute:!1})],J.prototype,`onRenameSession`,void 0),H([x()],J.prototype,`query`,void 0),H([x()],J.prototype,`filter`,void 0),H([x()],J.prototype,`openMenuSessionId`,void 0),H([x()],J.prototype,`renamingSessionId`,void 0),J=H([y(`quick-switcher`)],J);var rO=class extends v{constructor(...e){super(...e),this.selectedIndex=0,this.query=``}render(){let e=this.state;return e===void 0?null:g`
|
|
4070
4070
|
<modal-surface
|
|
4071
4071
|
.onClose=${()=>{this.cancel()}}
|
|
4072
4072
|
.initialFocus=${this.initialFocusTarget(e)}
|
|
@@ -4079,7 +4079,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4079
4079
|
</header>
|
|
4080
4080
|
${this.renderBody(e)}
|
|
4081
4081
|
</modal-surface>
|
|
4082
|
-
`}optionsFor(e){switch(e.step){case`method`:return[{key:`oauth`,title:`Use a subscription`,detail:`ChatGPT Plus/Pro, Claude Pro/Max, or GitHub Copilot`,searchText:`Use a subscription`,run:()=>{this.onChooseMethod?.(`oauth`)}},{key:`api_key`,title:`Use provider credentials`,detail:`Configure an API key or provider-specific credentials in the active Pi-compatible profile's auth.json`,searchText:`Use provider credentials`,run:()=>{this.onChooseMethod?.(`api_key`)}}];case`providers`:return e.providers.map(e=>({key:e.id,title:g`${e.name}${e.status.source===void 0?null:g` <em>${
|
|
4082
|
+
`}optionsFor(e){switch(e.step){case`method`:return[{key:`oauth`,title:`Use a subscription`,detail:`ChatGPT Plus/Pro, Claude Pro/Max, or GitHub Copilot`,searchText:`Use a subscription`,run:()=>{this.onChooseMethod?.(`oauth`)}},{key:`api_key`,title:`Use provider credentials`,detail:`Configure an API key or provider-specific credentials in the active Pi-compatible profile's auth.json`,searchText:`Use provider credentials`,run:()=>{this.onChooseMethod?.(`api_key`)}}];case`providers`:return e.providers.map(e=>({key:e.id,title:g`${e.name}${e.status.source===void 0?null:g` <em>${fO(e)}</em>`}`,detail:`${e.id} · ${cO(e.authType)}`,searchText:e.name,run:()=>{this.onSelectProvider?.(e.id,e.authType)}}));case`logout`:return e.providers.map(e=>({key:e.id,title:e.name,detail:`${e.id} · ${cO(e.authType)}`,searchText:e.name,run:()=>{this.onLogoutProvider?.(e.id)}}));case`oauth`:return}}initialFocusTarget(e){if(e.step===`oauth`)return e.flow.prompt===void 0?void 0:`input`;if(e.step===`providers`||e.step===`logout`)return e.providers.length>0?`input`:void 0}stepHasSearch(e){return e.step===`providers`||e.step===`logout`}handleSearchInput(e){e.target instanceof HTMLInputElement&&(this.query=e.target.value,this.selectedIndex=0)}filteredOptions(e){let t=FD(this.query);return t===``?e:e.filter(e=>PD(`${e.searchText} ${e.detail} ${e.key}`,t))}visibleOptions(e){let t=this.optionsFor(e);return t===void 0?[]:this.filteredOptions(t)}willUpdate(e){if(!e.has(`state`))return;if(dO(e.get(`state`))!==this.state?.step){this.selectedIndex=0,this.query=``;return}let t=this.state===void 0?void 0:this.visibleOptions(this.state);t!==void 0&&(this.selectedIndex=Math.min(this.selectedIndex,Math.max(0,t.length-1)))}updated(e){if(!e.has(`state`))return;let t=dO(e.get(`state`));if(t===void 0)return;let n=this.state?.step,r=t!==n,i=t===`oauth`&&n===`oauth`&&lO(e.get(`state`))!==lO(this.state);(r||i)&&this.surface?.focusDialog()}dialogTitle(e){switch(e.step){case`method`:return`Configure provider authentication`;case`providers`:return e.authType===void 0?`Select provider authentication`:e.authType===`oauth`?`Select subscription provider`:`Select credential provider`;case`oauth`:return`Login to ${e.flow.providerName}`;case`logout`:return`Remove stored provider authentication`}}renderBody(e){if(e.step===`oauth`)return this.renderOAuth(e);let t=this.optionsFor(e)??[],n=this.filteredOptions(t);return g`
|
|
4083
4083
|
${this.stepHasSearch(e)&&t.length>0?g`
|
|
4084
4084
|
<input aria-label="Search providers" placeholder="Search providers" .value=${this.query} @input=${e=>{this.handleSearchInput(e)}}>
|
|
4085
4085
|
`:null}
|
|
@@ -4088,7 +4088,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4088
4088
|
<button
|
|
4089
4089
|
class=${t===this.selectedIndex?`selected`:``}
|
|
4090
4090
|
aria-current=${t===this.selectedIndex?`true`:_}
|
|
4091
|
-
${
|
|
4091
|
+
${mD(t===this.selectedIndex,e.key)}
|
|
4092
4092
|
@focus=${()=>{this.selectedIndex=t}}
|
|
4093
4093
|
@click=${()=>{e.run()}}
|
|
4094
4094
|
>
|
|
@@ -4097,7 +4097,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4097
4097
|
</button>
|
|
4098
4098
|
`)}
|
|
4099
4099
|
</div>
|
|
4100
|
-
`}renderOAuth(e){let t=e.flow,n=t.prompt,r=t.select,i=n===void 0?void 0:
|
|
4100
|
+
`}renderOAuth(e){let t=e.flow,n=t.prompt,r=t.select,i=n===void 0?void 0:iO(n.promptType),a=sO(e.machineId,window.location.hostname)&&t.status===`running`&&n?.promptType===`manual_code`;return g`
|
|
4101
4101
|
<div class="form">
|
|
4102
4102
|
${t.auth===void 0?g`<p>Starting login flow…</p>`:g`
|
|
4103
4103
|
<p>Open this authorization link:</p>
|
|
@@ -4131,7 +4131,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4131
4131
|
${t.status===`error`||t.status===`cancelled`?g`<div class="error-text">${t.error??t.status}</div><div class="actions"><button @click=${()=>{this.cancel()}}>Close</button></div>`:null}
|
|
4132
4132
|
${n===void 0&&r===void 0&&t.status===`running`?g`<div class="actions"><button @click=${()=>{this.onOAuthCancel?.()}}>Cancel</button></div>`:null}
|
|
4133
4133
|
</div>
|
|
4134
|
-
`}handleKeyDown(e){let t=this.state;if(t===void 0||
|
|
4134
|
+
`}handleKeyDown(e){let t=this.state;if(t===void 0||MD(e))return;if(e.key===`ArrowDown`||e.key===`ArrowUp`){let n=this.visibleOptions(t);if(n.length===0)return;e.preventDefault();let r=e.key===`ArrowDown`?1:-1;this.selectedIndex=(this.selectedIndex+r+n.length)%n.length;return}if(e.key!==`Enter`)return;if(t.step===`oauth`){if(t.flow.prompt===void 0)return;e.preventDefault(),this.onOAuthRespond?.();return}let n=this.visibleOptions(t)[this.selectedIndex];n!==void 0&&(e.preventDefault(),n.run())}cancel(){this.state?.step===`oauth`?this.onOAuthCancel?.():this.onCancel?.()}static{this.styles=[h`
|
|
4135
4135
|
:host { position: fixed; inset: 0; z-index: var(--pi-layer-blocking); color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
4136
4136
|
modal-surface { --modal-surface-width: min(720px, calc(100vw - 40px)); --modal-surface-max-height: min(640px, calc(100vh - 40px)); }
|
|
4137
4137
|
header { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-bottom: 1px solid var(--pi-border); }
|
|
@@ -4166,7 +4166,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4166
4166
|
.inline-options button { display: grid; gap: 2px; text-align: left; }
|
|
4167
4167
|
.inline-options small { color: var(--pi-muted); }
|
|
4168
4168
|
em { color: var(--pi-success); font-style: normal; font-size: 12px; }
|
|
4169
|
-
`]}};H([b({attribute:!1})],
|
|
4169
|
+
`]}};H([b({attribute:!1})],rO.prototype,`state`,void 0),H([b({attribute:!1})],rO.prototype,`onChooseMethod`,void 0),H([b({attribute:!1})],rO.prototype,`onSelectProvider`,void 0),H([b({attribute:!1})],rO.prototype,`onLogoutProvider`,void 0),H([b({attribute:!1})],rO.prototype,`onOAuthInput`,void 0),H([b({attribute:!1})],rO.prototype,`onOAuthRespond`,void 0),H([b({attribute:!1})],rO.prototype,`onOAuthCancel`,void 0),H([b({attribute:!1})],rO.prototype,`onCancel`,void 0),H([S(`modal-surface`)],rO.prototype,`surface`,void 0),H([x()],rO.prototype,`selectedIndex`,void 0),H([x()],rO.prototype,`query`,void 0),rO=H([y(`auth-dialog`)],rO);function iO(e){return e===`secret`?`password`:`text`}var aO=new Set([`localhost`,`127.0.0.1`,`::1`]);function oO(e){return aO.has(e.trim().replace(/^\[|\]$/g,``).toLowerCase())}function sO(e,t){return e!==`local`||!oO(t)}function cO(e){return e===`oauth`?`subscription`:`credentials`}function lO(e){if(dO(e)!==`oauth`||typeof e!=`object`||!e||!(`flow`in e))return;let t=e.flow;if(typeof t!=`object`||!t)return;let n=`flowId`in t&&typeof t.flowId==`string`?t.flowId:``,r=`prompt`in t?uO(t.prompt):void 0;if(r!==void 0)return`${n}:prompt:${r}:${`responding`in e&&e.responding===!0?`responding`:`ready`}`;let i=`select`in t?uO(t.select):void 0;return i===void 0?`${n}:waiting:${`status`in t&&typeof t.status==`string`?t.status:`unknown`}`:`${n}:select:${i}`}function uO(e){if(!(typeof e!=`object`||!e||!(`requestId`in e)))return typeof e.requestId==`string`?e.requestId:void 0}function dO(e){if(!(typeof e!=`object`||!e||!(`step`in e)))switch(e.step){case`method`:case`providers`:case`oauth`:case`logout`:return e.step;default:return}}function fO(e){if(e.status.source===void 0)return``;switch(e.status.source){case`stored`:return`✓ configured`;case`environment`:return`✓ env${e.status.label===void 0?``:`: ${e.status.label}`}`;case`runtime`:return`✓ runtime`;case`fallback`:return`✓ custom key`;case`models_json_key`:return`✓ models.json key`;case`models_json_command`:return`✓ models.json command`;default:return``}}var pO=120,mO=class extends v{constructor(...e){super(...e),this.machineId=`local`,this.path=``,this.createMissing=!0,this.submitError=void 0,this.submitting=!1,this.suggestions=[],this.selected=0,this.loading=!1,this.trustTouched=!1,this.suggestionRequestId=0,this.trustRequestId=0}connectedCallback(){super.connectedCallback(),this.loadSuggestions()}disconnectedCallback(){this.cancelPendingSuggestions(),super.disconnectedCallback()}scheduleSuggestions(){this.cancelPendingSuggestions(),this.suggestionTimer=setTimeout(()=>{this.suggestionTimer=void 0,this.loadSuggestions()},pO)}cancelPendingSuggestions(){this.suggestionTimer!==void 0&&(clearTimeout(this.suggestionTimer),this.suggestionTimer=void 0)}async loadSuggestions(){let e=++this.suggestionRequestId;this.loading=!0;try{let t=await I.projectDirectories(this.path,this.machineId);if(e!==this.suggestionRequestId)return;this.suggestions=t,this.selected=Math.min(this.selected,Math.max(0,t.length-1))}catch{e===this.suggestionRequestId&&(this.suggestions=[])}finally{e===this.suggestionRequestId&&(this.loading=!1)}}setPath(e){this.path=e,this.selected=0,this.scheduleSuggestions(),this.trustTouched=!1,this.loadTrust()}pick(e){this.path=e.path,this.selected=0,this.cancelPendingSuggestions(),this.loadSuggestions()}submit(){this.path.trim()===``||this.submitting||(this.submitError=void 0,this.submitting=!0,(async()=>{try{let e=await this.onSubmit?.(this.path,this.createMissing,this.trust===void 0?void 0:{trusted:this.trust.trusted,changed:this.trustTouched});this.submitError=typeof e==`string`&&e!==``?e:void 0}finally{this.submitting=!1}})())}onPathInput(e){e.target instanceof HTMLInputElement&&this.setPath(e.target.value)}onCreateMissingChange(e){e.target instanceof HTMLInputElement&&(this.createMissing=e.target.checked)}async loadTrust(){let e=++this.trustRequestId,t=this.path.trim();if(t===``){e===this.trustRequestId&&(this.trust=void 0);return}e===this.trustRequestId&&(this.trust={...this.trust??{path:t,decision:null,trusted:!1},path:t,loading:!0});try{let n=await ys.projectTrust(t,this.machineId);if(e!==this.trustRequestId||this.trustTouched)return;this.trust={path:n.path,decision:n.decision,trusted:n.trusted,loading:!1}}catch(n){if(e!==this.trustRequestId||this.trustTouched)return;this.trust={path:t,decision:null,trusted:!1,loading:!1,error:n instanceof Error?n.message:String(n)}}}onTrustChange(e){this.trustTouched=!0,this.trust!==void 0&&(this.trust={...this.trust,trusted:e,loading:!1})}renderTrustChoice(){let e=this.trust===void 0||this.trust.loading||this.trust.error!==void 0;return g`
|
|
4170
4170
|
<label class="check">
|
|
4171
4171
|
<input type="checkbox" .checked=${this.trust?.trusted??!1} ?disabled=${e} @change=${e=>{e.target instanceof HTMLInputElement&&this.onTrustChange(e.target.checked)}} />
|
|
4172
4172
|
<span>Trust this project</span>
|
|
@@ -4253,7 +4253,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4253
4253
|
header button { border: 0; background: transparent; color: var(--pi-muted); font-size: 22px; padding: 0 8px; }
|
|
4254
4254
|
.primary { border-color: var(--pi-success-border); background: var(--pi-success-border); }
|
|
4255
4255
|
button:disabled { opacity: .5; cursor: not-allowed; }
|
|
4256
|
-
`}};H([b({attribute:!1})],
|
|
4256
|
+
`}};H([b({attribute:!1})],mO.prototype,`onSubmit`,void 0),H([b({attribute:!1})],mO.prototype,`onCancel`,void 0),H([b()],mO.prototype,`machineId`,void 0),H([x()],mO.prototype,`path`,void 0),H([x()],mO.prototype,`createMissing`,void 0),H([x()],mO.prototype,`submitError`,void 0),H([x()],mO.prototype,`submitting`,void 0),H([x()],mO.prototype,`suggestions`,void 0),H([x()],mO.prototype,`selected`,void 0),H([x()],mO.prototype,`loading`,void 0),H([x()],mO.prototype,`trust`,void 0),H([x()],mO.prototype,`trustTouched`,void 0),H([S(`input`)],mO.prototype,`pathInput`,void 0),mO=H([y(`project-dialog`)],mO);var hO=class extends v{constructor(...e){super(...e),this.error=``,this.url=``,this.name=``,this.token=``,this.submitting=!1,this.nameEdited=!1,this.previousSuggestedName=``}handleUrlInput(e){if(!(e.target instanceof HTMLInputElement))return;let t=e.target.value,n=gO(t);(!this.nameEdited||this.name.trim()===``||this.name===this.previousSuggestedName)&&(this.name=n),this.previousSuggestedName=n,this.url=t}handleNameInput(e){e.target instanceof HTMLInputElement&&(this.nameEdited=!0,this.name=e.target.value)}handleTokenInput(e){e.target instanceof HTMLInputElement&&(this.token=e.target.value)}handleKeyDown(e){e.key===`Enter`&&e.target instanceof HTMLInputElement&&e.target.name===`baseUrl`&&_O(this.url)===void 0&&(e.preventDefault(),this.updateComplete.then(()=>{this.nameInput?.focus(),this.nameInput?.select()}))}handleSubmit(e){e.preventDefault(),this.submit()}async submit(){let e=this.validInput();if(!(e===void 0||this.submitting)){this.submitting=!0;try{await this.onSubmit?.(e)}finally{this.isConnected&&(this.submitting=!1)}}}validInput(){let e=this.url.trim(),t=this.name.trim();if(e===``||t===``||_O(e)!==void 0)return;let n=this.token.trim();return{name:t,baseUrl:e,...n===``?{}:{token:n}}}render(){let e=this.url.trim()!==``,t=e?_O(this.url):void 0,n=this.validInput()!==void 0&&!this.submitting;return g`
|
|
4257
4257
|
<modal-surface
|
|
4258
4258
|
.onClose=${()=>this.onCancel?.()}
|
|
4259
4259
|
.initialFocus=${`input[name='baseUrl']`}
|
|
@@ -4312,7 +4312,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4312
4312
|
header button { border: 0; background: transparent; color: var(--pi-muted); font-size: 22px; padding: 0 8px; }
|
|
4313
4313
|
.primary { border-color: var(--pi-success-border); background: var(--pi-success-border); }
|
|
4314
4314
|
button:disabled { opacity: .5; cursor: not-allowed; }
|
|
4315
|
-
`}};H([b({attribute:!1})],
|
|
4315
|
+
`}};H([b({attribute:!1})],hO.prototype,`onSubmit`,void 0),H([b({attribute:!1})],hO.prototype,`onCancel`,void 0),H([b()],hO.prototype,`error`,void 0),H([x()],hO.prototype,`url`,void 0),H([x()],hO.prototype,`name`,void 0),H([x()],hO.prototype,`token`,void 0),H([x()],hO.prototype,`submitting`,void 0),H([S(`input[name='name']`)],hO.prototype,`nameInput`,void 0),hO=H([y(`machine-dialog`)],hO);function gO(e){let t=e.trim();if(t===``)return``;let n=vO(t)??vO(`http://${t.replace(/^\/+/u,``)}`);return n!==void 0&&n.hostname!==``?n.hostname.replace(/^\[(.*)\]$/u,`$1`):yO(t)}function _O(e){let t=e.trim();if(t===``)return`Remote PI WEB URL is required.`;let n;try{n=new URL(t)}catch{return`Enter a valid URL including http:// or https://.`}if(n.protocol!==`http:`&&n.protocol!==`https:`)return`Use an http:// or https:// URL.`;if(n.username!==``||n.password!==``)return`Do not include credentials in the machine URL.`;if(n.search!==``||n.hash!==``)return`Do not include a query string or fragment.`}function vO(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t:void 0}catch{return}}function yO(e){let t=e.replace(/^[a-z][a-z\d+.-]*:\/\//iu,``),n=t.slice(t.lastIndexOf(`@`)+1).split(/[/?#]/u)[0]??``;return n.startsWith(`[`)&&n.includes(`]`)?n.slice(1,n.indexOf(`]`)):n.replace(/:\d+$/u,``)}var bO=class extends v{constructor(...e){super(...e),this.themes=[],this.followSystem=!1,this.uiScale=1}render(){return g`
|
|
4316
4316
|
<settings-panel-frame>
|
|
4317
4317
|
<div class="heading">
|
|
4318
4318
|
<div>
|
|
@@ -4429,7 +4429,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4429
4429
|
.theme-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--pi-space-4); }
|
|
4430
4430
|
.preview { height: 64px; }
|
|
4431
4431
|
}
|
|
4432
|
-
`}};H([b({attribute:!1})],
|
|
4432
|
+
`}};H([b({attribute:!1})],bO.prototype,`themes`,void 0),H([b({attribute:!1})],bO.prototype,`selectedThemeId`,void 0),H([b({attribute:!1})],bO.prototype,`activeThemeId`,void 0),H([b({type:Boolean})],bO.prototype,`followSystem`,void 0),H([b({attribute:!1})],bO.prototype,`onSelectTheme`,void 0),H([b({attribute:!1})],bO.prototype,`onToggleFollowSystem`,void 0),H([b({type:Number})],bO.prototype,`uiScale`,void 0),H([b({attribute:!1})],bO.prototype,`onChangeUiScale`,void 0),bO=H([y(`settings-appearance-panel`)],bO);var xO={availability:`error`,error:`error`,success:`success`,security:`warning`,warning:`warning`,info:`info`};function SO(e){return e.tone??xO[e.type]}var CO=class extends v{constructor(...e){super(...e),this.heading=``,this.description=``,this.actionLabel=``,this.actionTitle=``,this.actionDisabled=!1,this.notices=[]}render(){return g`
|
|
4433
4433
|
<section class="panel" aria-label=${this.heading||`Settings panel`}>
|
|
4434
4434
|
<header class="section-heading">
|
|
4435
4435
|
<div class="heading-copy">
|
|
@@ -4452,7 +4452,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4452
4452
|
<div class="notice-stack" aria-label="Settings notices">
|
|
4453
4453
|
${this.notices.map(e=>this.renderNotice(e))}
|
|
4454
4454
|
</div>
|
|
4455
|
-
`}renderNotice(e){let t=
|
|
4455
|
+
`}renderNotice(e){let t=SO(e),n=e.role??wO(t),r=e.title;return g`
|
|
4456
4456
|
<article class=${`notice ${t}`} role=${n}>
|
|
4457
4457
|
${r===void 0||r===``?_:g`<strong class="notice-title">${r}</strong>`}
|
|
4458
4458
|
<div class="notice-content">${e.content}</div>
|
|
@@ -4485,13 +4485,13 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4485
4485
|
.section-heading { display: grid; gap: 12px; }
|
|
4486
4486
|
.heading-actions { justify-self: start; }
|
|
4487
4487
|
}
|
|
4488
|
-
`}};H([b()],
|
|
4489
|
-
`):``}}function
|
|
4490
|
-
`)??``,uploadDefaultFolder:e.uploads?.defaultFolder??``}}function
|
|
4491
|
-
`).map(e=>e.trim()).filter(e=>e!==``),n=t.find(e=>!
|
|
4488
|
+
`}};H([b()],CO.prototype,`heading`,void 0),H([b({attribute:!1})],CO.prototype,`description`,void 0),H([b()],CO.prototype,`actionLabel`,void 0),H([b()],CO.prototype,`actionTitle`,void 0),H([b({type:Boolean})],CO.prototype,`actionDisabled`,void 0),H([b({attribute:!1})],CO.prototype,`notices`,void 0),H([b({attribute:!1})],CO.prototype,`onAction`,void 0),CO=H([y(`settings-panel-frame`)],CO);function wO(e){switch(e){case`error`:return`alert`;case`success`:return`status`;case`warning`:case`info`:return`note`}}function TO(){return{host:``,port:``,allowedHostsMode:`list`,allowedHostsText:``}}function EO(){return{allowedPathsText:``,uploadDefaultFolder:``}}function DO(e){return{host:e.host??``,port:e.port===void 0?``:String(e.port),allowedHostsMode:e.allowedHosts===!0?`all`:`list`,allowedHostsText:Array.isArray(e.allowedHosts)?e.allowedHosts.join(`
|
|
4489
|
+
`):``}}function OO(e){return{allowedPathsText:e.pathAccess?.allowedPaths?.join(`
|
|
4490
|
+
`)??``,uploadDefaultFolder:e.uploads?.defaultFolder??``}}function kO(e,t={}){let n=jO(t),r=e.host.trim(),i=e.port.trim();if(r!==``&&(n.host=r),i!==``){let e=Number(i);if(!Number.isInteger(e)||e<1||e>65535)throw Error(`Port must be an integer from 1 to 65535.`);n.port=e}return n.allowedHosts=e.allowedHostsMode===`all`||MO(e.allowedHostsText),n}function AO(e){let t=NO(e.allowedPathsText),n=PO(e.uploadDefaultFolder);return{pathAccess:{allowedPaths:t},uploads:n===``?{}:{defaultFolder:n}}}function jO(e){return{...e.shortcuts===void 0?{}:{shortcuts:e.shortcuts},...e.plugins===void 0?{}:{plugins:e.plugins},...e.pathAccess===void 0?{}:{pathAccess:e.pathAccess},...e.uploads===void 0?{}:{uploads:e.uploads},...e.maxUploadBytes===void 0?{}:{maxUploadBytes:e.maxUploadBytes},...e.spawnSessions===void 0?{}:{spawnSessions:e.spawnSessions},...e.subsessions===void 0?{}:{subsessions:e.subsessions},...e.askUser===void 0?{}:{askUser:e.askUser},...e.agent===void 0?{}:{agent:e.agent}}}function MO(e){return e.split(/[\n,]/u).map(e=>e.trim()).filter(e=>e!==``)}function NO(e){let t=e.split(`
|
|
4491
|
+
`).map(e=>e.trim()).filter(e=>e!==``),n=t.find(e=>!FO(e));if(n!==void 0)throw Error(`Allowed external paths must be absolute paths or start with ~: ${n}`);return t}function PO(e){let t=e.trim();if(t===``)return``;if(IO(t))throw Error(`Upload default folder must be workspace-relative.`);let n=t.split(/[\\/]+/u).filter(e=>e!==``&&e!==`.`);if(n.length===0)return``;if(n.some(e=>e===`..`))throw Error(`Upload default folder must not contain path traversal.`);return n.join(`/`)}function FO(e){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)||e.startsWith(`/`)||e.startsWith(`\\`)||/^[A-Za-z]:[\\/]/u.test(e)}function IO(e){let t=e.replace(/\\/g,`/`);return t.startsWith(`/`)||/^[A-Za-z]:\//u.test(t)}function LO(e){return g`Gateway server fields edit this local gateway. File access and upload defaults edit ${e}.`}var Y=class extends v{constructor(...e){super(...e),this.loading=!1,this.machineLoading=!1,this.saving=!1,this.error=``,this.machineError=``,this.savedMessage=``,this.targetLabel=`selected machine`,this.gatewayDraft=TO(),this.machineDraft=EO(),this.gatewayLocalError=``,this.machineLocalError=``}willUpdate(e){e.has(`configResponse`)&&this.configResponse!==void 0&&(this.gatewayDraft=DO(this.configResponse.config),this.gatewayLocalError=``),e.has(`machineConfigResponse`)&&this.machineConfigResponse!==void 0&&(this.machineDraft=OO(this.machineConfigResponse.config),this.machineLocalError=``)}render(){return g`
|
|
4492
4492
|
<settings-panel-frame
|
|
4493
4493
|
heading="General configuration"
|
|
4494
|
-
.description=${
|
|
4494
|
+
.description=${LO(this.targetLabel)}
|
|
4495
4495
|
actionLabel="Reload"
|
|
4496
4496
|
.actionDisabled=${this.loading||this.machineLoading}
|
|
4497
4497
|
.notices=${this.panelNotices()}
|
|
@@ -4520,7 +4520,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4520
4520
|
<span>Host</span>
|
|
4521
4521
|
${this.renderOverrideBadge(`host`)}
|
|
4522
4522
|
</span>
|
|
4523
|
-
<input .value=${this.gatewayDraft.host} placeholder="127.0.0.1" autocomplete="off" spellcheck="false" @input=${e=>{this.updateGatewayDraft({host:
|
|
4523
|
+
<input .value=${this.gatewayDraft.host} placeholder="127.0.0.1" autocomplete="off" spellcheck="false" @input=${e=>{this.updateGatewayDraft({host:BO(e)})}}>
|
|
4524
4524
|
<small>Address the web server should bind to. Leave empty to use PI WEB's default.</small>
|
|
4525
4525
|
</label>
|
|
4526
4526
|
|
|
@@ -4529,7 +4529,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4529
4529
|
<span>Port</span>
|
|
4530
4530
|
${this.renderOverrideBadge(`port`)}
|
|
4531
4531
|
</span>
|
|
4532
|
-
<input .value=${this.gatewayDraft.port} inputmode="numeric" pattern="[0-9]*" placeholder="8504" autocomplete="off" @input=${e=>{this.updateGatewayDraft({port:
|
|
4532
|
+
<input .value=${this.gatewayDraft.port} inputmode="numeric" pattern="[0-9]*" placeholder="8504" autocomplete="off" @input=${e=>{this.updateGatewayDraft({port:BO(e)})}}>
|
|
4533
4533
|
<small>TCP port from 1 to 65535. Leave empty to use PI WEB's default.</small>
|
|
4534
4534
|
</label>
|
|
4535
4535
|
|
|
@@ -4538,11 +4538,11 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4538
4538
|
<span>Allowed hosts</span>
|
|
4539
4539
|
${this.renderOverrideBadge(`allowedHosts`)}
|
|
4540
4540
|
</span>
|
|
4541
|
-
<select .value=${this.gatewayDraft.allowedHostsMode} @change=${e=>{this.updateGatewayDraft({allowedHostsMode:
|
|
4541
|
+
<select .value=${this.gatewayDraft.allowedHostsMode} @change=${e=>{this.updateGatewayDraft({allowedHostsMode:VO(e)===`all`?`all`:`list`})}}>
|
|
4542
4542
|
<option value="list">Only listed hosts</option>
|
|
4543
4543
|
<option value="all">Allow every host</option>
|
|
4544
4544
|
</select>
|
|
4545
|
-
<textarea .value=${this.gatewayDraft.allowedHostsText} ?disabled=${this.gatewayDraft.allowedHostsMode===`all`} rows="4" placeholder="example.local 192.168.1.20" spellcheck="false" @input=${e=>{this.updateGatewayDraft({allowedHostsText:
|
|
4545
|
+
<textarea .value=${this.gatewayDraft.allowedHostsText} ?disabled=${this.gatewayDraft.allowedHostsMode===`all`} rows="4" placeholder="example.local 192.168.1.20" spellcheck="false" @input=${e=>{this.updateGatewayDraft({allowedHostsText:HO(e)})}}></textarea>
|
|
4546
4546
|
<small>Enter one host per line, or choose “Allow every host” to write <code>true</code>.</small>
|
|
4547
4547
|
</div>
|
|
4548
4548
|
|
|
@@ -4572,7 +4572,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4572
4572
|
<span class="field-heading">
|
|
4573
4573
|
<span>External filesystem roots</span>
|
|
4574
4574
|
</span>
|
|
4575
|
-
<textarea .value=${this.machineDraft.allowedPathsText} rows="4" placeholder="~/SDKs /opt/reference" spellcheck="false" @input=${e=>{this.updateMachineDraft({allowedPathsText:
|
|
4575
|
+
<textarea .value=${this.machineDraft.allowedPathsText} rows="4" placeholder="~/SDKs /opt/reference" spellcheck="false" @input=${e=>{this.updateMachineDraft({allowedPathsText:HO(e)})}}></textarea>
|
|
4576
4576
|
<small>Allowlist for absolute <code>@</code> completions and file explorer reads outside a workspace on ${this.targetLabel}. Enter one absolute path, Windows absolute path, or <code>~</code>-prefixed path per line. Leave empty to deny external paths by default.</small>
|
|
4577
4577
|
</label>
|
|
4578
4578
|
|
|
@@ -4580,7 +4580,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4580
4580
|
<span class="field-heading">
|
|
4581
4581
|
<span>Default upload folder</span>
|
|
4582
4582
|
</span>
|
|
4583
|
-
<input .value=${this.machineDraft.uploadDefaultFolder} placeholder=${qs} autocomplete="off" spellcheck="false" @input=${e=>{this.updateMachineDraft({uploadDefaultFolder:
|
|
4583
|
+
<input .value=${this.machineDraft.uploadDefaultFolder} placeholder=${qs} autocomplete="off" spellcheck="false" @input=${e=>{this.updateMachineDraft({uploadDefaultFolder:BO(e)})}}>
|
|
4584
4584
|
<small>Workspace-relative folder for manual file uploads on ${this.targetLabel}. Leave empty to use PI WEB's default <code>${qs}</code>.</small>
|
|
4585
4585
|
</label>
|
|
4586
4586
|
|
|
@@ -4598,18 +4598,18 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4598
4598
|
<dl>
|
|
4599
4599
|
<div><dt>Host</dt><dd>${e.host??g`<span class="muted">127.0.0.1 default</span>`}</dd></div>
|
|
4600
4600
|
<div><dt>Port</dt><dd>${e.port??g`<span class="muted">8504 default</span>`}</dd></div>
|
|
4601
|
-
<div><dt>Allowed hosts</dt><dd>${
|
|
4601
|
+
<div><dt>Allowed hosts</dt><dd>${RO(e.allowedHosts)}</dd></div>
|
|
4602
4602
|
</dl>
|
|
4603
4603
|
</section>
|
|
4604
4604
|
`}renderMachineEffectiveConfig(){let e=this.machineConfigResponse?.effectiveConfig??{};return g`
|
|
4605
4605
|
<section class="effective-card" aria-label="Effective selected machine file access and upload summary">
|
|
4606
4606
|
<h3>Effective selected-machine settings</h3>
|
|
4607
4607
|
<dl>
|
|
4608
|
-
<div><dt>External roots</dt><dd>${
|
|
4608
|
+
<div><dt>External roots</dt><dd>${zO(e.pathAccess?.allowedPaths)}</dd></div>
|
|
4609
4609
|
<div><dt>Upload folder</dt><dd>${e.uploads?.defaultFolder??g`<span class="muted">${`.pi-web/uploads`} default</span>`}</dd></div>
|
|
4610
4610
|
</dl>
|
|
4611
4611
|
</section>
|
|
4612
|
-
`}reloadAll(){this.onReload?.(),this.onReloadMachine?.()}async saveGatewayConfig(e){e.preventDefault(),this.gatewayLocalError=``;try{await this.onSave?.(
|
|
4612
|
+
`}reloadAll(){this.onReload?.(),this.onReloadMachine?.()}async saveGatewayConfig(e){e.preventDefault(),this.gatewayLocalError=``;try{await this.onSave?.(kO(this.gatewayDraft,this.configResponse?.config??{}))}catch(e){this.gatewayLocalError=UO(e)}}async saveMachineAccessConfig(e){e.preventDefault(),this.machineLocalError=``;try{await this.onSaveMachineConfig?.(AO(this.machineDraft))}catch(e){this.machineLocalError=UO(e)}}updateGatewayDraft(e){this.gatewayDraft={...this.gatewayDraft,...e},this.gatewayLocalError=``}updateMachineDraft(e){this.machineDraft={...this.machineDraft,...e},this.machineLocalError=``}static{this.styles=h`
|
|
4613
4613
|
:host { display: block; }
|
|
4614
4614
|
.card-heading { display: grid; gap: 6px; min-width: 0; }
|
|
4615
4615
|
h3, p { margin: 0; }
|
|
@@ -4648,7 +4648,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4648
4648
|
@media (max-width: 760px) {
|
|
4649
4649
|
.effective-card dl > div { grid-template-columns: minmax(0, 1fr); gap: 3px; }
|
|
4650
4650
|
}
|
|
4651
|
-
`}};H([b({attribute:!1})],Y.prototype,`configResponse`,void 0),H([b({attribute:!1})],Y.prototype,`machineConfigResponse`,void 0),H([b({type:Boolean})],Y.prototype,`loading`,void 0),H([b({type:Boolean})],Y.prototype,`machineLoading`,void 0),H([b({type:Boolean})],Y.prototype,`saving`,void 0),H([b()],Y.prototype,`error`,void 0),H([b()],Y.prototype,`machineError`,void 0),H([b()],Y.prototype,`savedMessage`,void 0),H([b()],Y.prototype,`targetLabel`,void 0),H([b({attribute:!1})],Y.prototype,`onReload`,void 0),H([b({attribute:!1})],Y.prototype,`onReloadMachine`,void 0),H([b({attribute:!1})],Y.prototype,`onSave`,void 0),H([b({attribute:!1})],Y.prototype,`onSaveMachineConfig`,void 0),H([x()],Y.prototype,`gatewayDraft`,void 0),H([x()],Y.prototype,`machineDraft`,void 0),H([x()],Y.prototype,`gatewayLocalError`,void 0),H([x()],Y.prototype,`machineLocalError`,void 0),Y=H([y(`settings-general-panel`)],Y);function
|
|
4651
|
+
`}};H([b({attribute:!1})],Y.prototype,`configResponse`,void 0),H([b({attribute:!1})],Y.prototype,`machineConfigResponse`,void 0),H([b({type:Boolean})],Y.prototype,`loading`,void 0),H([b({type:Boolean})],Y.prototype,`machineLoading`,void 0),H([b({type:Boolean})],Y.prototype,`saving`,void 0),H([b()],Y.prototype,`error`,void 0),H([b()],Y.prototype,`machineError`,void 0),H([b()],Y.prototype,`savedMessage`,void 0),H([b()],Y.prototype,`targetLabel`,void 0),H([b({attribute:!1})],Y.prototype,`onReload`,void 0),H([b({attribute:!1})],Y.prototype,`onReloadMachine`,void 0),H([b({attribute:!1})],Y.prototype,`onSave`,void 0),H([b({attribute:!1})],Y.prototype,`onSaveMachineConfig`,void 0),H([x()],Y.prototype,`gatewayDraft`,void 0),H([x()],Y.prototype,`machineDraft`,void 0),H([x()],Y.prototype,`gatewayLocalError`,void 0),H([x()],Y.prototype,`machineLocalError`,void 0),Y=H([y(`settings-general-panel`)],Y);function RO(e){return e===!0?`Any host`:Array.isArray(e)?e.length===0?g`<span class="muted">None listed</span>`:e.join(`, `):g`<span class="muted">Unset</span>`}function zO(e){return e===void 0||e.length===0?g`<span class="muted">External paths denied</span>`:e.join(`, `)}function BO(e){return e.target instanceof HTMLInputElement?e.target.value:``}function VO(e){return e.target instanceof HTMLSelectElement?e.target.value:``}function HO(e){return e.target instanceof HTMLTextAreaElement?e.target.value:``}function UO(e){return e instanceof Error?e.message:String(e)}var WO=class extends v{constructor(...e){super(...e),this.loading=!1}render(){let e=this.report?.machines??[];return g`
|
|
4652
4652
|
<section class="fleet">
|
|
4653
4653
|
<header>
|
|
4654
4654
|
<div>
|
|
@@ -4730,7 +4730,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4730
4730
|
.machine { grid-template-columns: auto minmax(0, 1fr); }
|
|
4731
4731
|
.machine .row-actions { grid-row: auto; grid-column: 1 / -1; }
|
|
4732
4732
|
}
|
|
4733
|
-
`}};H([b({attribute:!1})],
|
|
4733
|
+
`}};H([b({attribute:!1})],WO.prototype,`report`,void 0),H([b({type:Boolean})],WO.prototype,`loading`,void 0),H([b({attribute:!1})],WO.prototype,`error`,void 0),H([b({attribute:!1})],WO.prototype,`onRefresh`,void 0),H([b({attribute:!1})],WO.prototype,`onRun`,void 0),H([x()],WO.prototype,`running`,void 0),H([x()],WO.prototype,`lastRun`,void 0),WO=H([y(`settings-fleet-section`)],WO);var GO=class extends v{constructor(...e){super(...e),this.machines=[],this.machineStatuses={},this.fleetLoading=!1,this.draftName=``}render(){return g`
|
|
4734
4734
|
<settings-panel-frame>
|
|
4735
4735
|
<div class="machines-heading">
|
|
4736
4736
|
<div>
|
|
@@ -4803,10 +4803,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4803
4803
|
.machine-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--pi-space-3); }
|
|
4804
4804
|
.machine-card { min-height: 88px; padding: var(--pi-space-4); }
|
|
4805
4805
|
}
|
|
4806
|
-
`}};H([b({attribute:!1})],
|
|
4806
|
+
`}};H([b({attribute:!1})],GO.prototype,`machines`,void 0),H([b({attribute:!1})],GO.prototype,`machineStatuses`,void 0),H([b({attribute:!1})],GO.prototype,`onAdd`,void 0),H([b({attribute:!1})],GO.prototype,`onRename`,void 0),H([b({attribute:!1})],GO.prototype,`onRemove`,void 0),H([b({attribute:!1})],GO.prototype,`fleetReport`,void 0),H([b({type:Boolean})],GO.prototype,`fleetLoading`,void 0),H([b({attribute:!1})],GO.prototype,`fleetError`,void 0),H([b({attribute:!1})],GO.prototype,`onRefreshFleet`,void 0),H([b({attribute:!1})],GO.prototype,`onRunFleet`,void 0),H([x()],GO.prototype,`renamingId`,void 0),H([x()],GO.prototype,`draftName`,void 0),GO=H([y(`settings-machines-panel`)],GO);function KO(e){return{spawnSessions:e}}function qO(e){return{subsessions:e}}function JO(e){return{askUser:e}}function YO(e,t){return{...e,config:{...e.config,...t.config},effectiveConfig:{...e.effectiveConfig,...t.effectiveConfig},envOverrides:{...e.envOverrides,spawnSessions:t.envOverrides.spawnSessions,subsessions:t.envOverrides.subsessions,askUser:t.envOverrides.askUser}}}var XO=class extends v{constructor(...e){super(...e),this.loading=!1,this.saving=!1,this.error=``,this.savedMessage=``,this.targetLabel=`local (local gateway)`}render(){let e=this.configResponse,t=e?.envOverrides.spawnSessions===!0,n=e?.effectiveConfig.spawnSessions!==!1,r=e?.envOverrides.subsessions===!0,i=e?.effectiveConfig.subsessions===!0&&n,a=e?.envOverrides.askUser===!0,o=e?.effectiveConfig.askUser===!0;return g`
|
|
4807
4807
|
<settings-panel-frame
|
|
4808
4808
|
heading="Session daemon"
|
|
4809
|
-
.description=${
|
|
4809
|
+
.description=${ZO(this.targetLabel)}
|
|
4810
4810
|
actionLabel="Reload"
|
|
4811
4811
|
.actionDisabled=${this.loading}
|
|
4812
4812
|
.notices=${this.panelNotices()}
|
|
@@ -4876,7 +4876,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4876
4876
|
</section>
|
|
4877
4877
|
`}
|
|
4878
4878
|
</settings-panel-frame>
|
|
4879
|
-
`}panelNotices(){return
|
|
4879
|
+
`}panelNotices(){return QO({error:this.error,savedMessage:this.savedMessage})}renderUnavailableConfigState(){return g`<div class="loading-card">${this.loading?`Loading configuration…`:`Configuration is unavailable. Reload to try again.`}</div>`}async toggleSpawnSessions(e){let t=e.target instanceof HTMLInputElement&&e.target.checked;await this.onSave?.(KO(t))}async toggleSubsessions(e){let t=e.target instanceof HTMLInputElement&&e.target.checked;await this.onSave?.(qO(t))}async toggleAskUser(e){let t=e.target instanceof HTMLInputElement&&e.target.checked;await this.onSave?.(JO(t))}static{this.styles=h`
|
|
4880
4880
|
:host { display: block; }
|
|
4881
4881
|
h3 { margin: 0; font-size: 13px; line-height: 1.3; }
|
|
4882
4882
|
.loading-card, .config-path-card, .effective-card { border: 1px solid var(--pi-border); border-radius: 10px; background: var(--pi-surface); padding: 12px; }
|
|
@@ -4900,10 +4900,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4900
4900
|
@media (max-width: 760px) {
|
|
4901
4901
|
.effective-card dl > div { grid-template-columns: minmax(0, 1fr); gap: 3px; }
|
|
4902
4902
|
}
|
|
4903
|
-
`}};H([b({attribute:!1})],
|
|
4903
|
+
`}};H([b({attribute:!1})],XO.prototype,`configResponse`,void 0),H([b({type:Boolean})],XO.prototype,`loading`,void 0),H([b({type:Boolean})],XO.prototype,`saving`,void 0),H([b()],XO.prototype,`error`,void 0),H([b()],XO.prototype,`savedMessage`,void 0),H([b()],XO.prototype,`targetLabel`,void 0),H([b({attribute:!1})],XO.prototype,`onReload`,void 0),H([b({attribute:!1})],XO.prototype,`onSave`,void 0),XO=H([y(`settings-sessiond-panel`)],XO);function ZO(e){return`Agent tool capabilities for sessions on ${e}. Changes are saved immediately but only take effect after the session daemon on that machine restarts.`}function QO(e){let t=[];return e.error!==``&&t.push({type:`error`,content:e.error}),e.savedMessage!==``&&t.push({type:`success`,content:e.savedMessage}),t}function $O(e){return e===void 0?{id:`local`,name:`local`,kind:`local`}:{id:e.id,name:e.name,kind:e.kind}}function ek(e){return e.kind===`local`?`${e.name} (local gateway)`:`${e.name} (remote machine)`}function tk(e){return e.kind===`local`}function nk(e){return e.trim()}function rk(e){if(nk(e)===``)return`Enter a Pi package source accepted by Pi, such as npm:@scope/package, a git/URL source, or a local path.`}function ik(e){return e.scope===`project`?`Project scope`:`User scope`}function ak(e){return e.filtered?`Filtered by current Pi package settings`:`Available in this PI WEB process`}function ok(e){return e.installedPath??`Installed path not reported by Pi`}function sk(e){return e.scope===`user`}function ck(e){if(!sk(e))return`Project-scope Pi packages are listed for visibility, but PI WEB only updates user-scope Pi packages safely from this view.`}function lk(e){return e.length>0&&e.every(sk)}function uk(e){if(e.length===0)return`No Pi packages are configured yet.`;if(!lk(e))return`Update all is disabled while project-scope Pi packages are listed; update user-scope packages individually.`}function dk(e,t,n){return e?.kind===t?n===void 0||e.source===n:!1}function fk(e,t=$O(void 0)){return`Pi package ${e===`install`?`installed`:e===`remove`?`removed`:`updated`}${t.kind===`local`?``:` on ${t.name}`}. Type /reload in ${t.kind===`local`?`each idle PI WEB session`:`each idle PI WEB session on ${t.name}`} to rediscover Pi runtime resources: extensions, skills, prompt templates, themes, and context/system prompt files. Reload the browser page separately for ${t.kind===`local`?`PI WEB browser plugin changes`:`PI WEB browser plugin changes served by ${t.name}`}.`}function pk(e,t){let n=e.trim();return t.kind===`remote`?n===`Remote machine timeout`?`Timed out while contacting ${t.name} for Pi package management. The package operation may still be running remotely; reload the package list before retrying.`:n===`Remote machine unavailable`?`Could not reach ${t.name} for Pi package management. Check the machine connection and try again.`:n:n}var mk=class extends v{constructor(...e){super(...e),this.loading=!1,this.error=``,this.operationMessage=``,this.installSource=``,this.validationMessage=``}render(){let e=this.packagesResponse?.packages??[],t=this.packageTarget,n=ek(t),r=this.packagesResponse!==void 0;return g`
|
|
4904
4904
|
<settings-panel-frame
|
|
4905
4905
|
heading="Pi packages"
|
|
4906
|
-
.description=${
|
|
4906
|
+
.description=${hk(n)}
|
|
4907
4907
|
actionLabel="Reload"
|
|
4908
4908
|
actionTitle=${`Reload Pi packages from ${n}`}
|
|
4909
4909
|
.actionDisabled=${this.loading||this.isOperating}
|
|
@@ -4920,12 +4920,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4920
4920
|
<label for="package-source">Pi package source</label>
|
|
4921
4921
|
<div class="install-row">
|
|
4922
4922
|
<input id="package-source" .value=${this.installSource} ?disabled=${this.isOperating} placeholder="npm:@scope/package, git URL, or local path" @input=${e=>{this.updateInstallSource(e)}}>
|
|
4923
|
-
<button type="submit" title="Install this Pi package" ?disabled=${this.isOperating}>${
|
|
4923
|
+
<button type="submit" title="Install this Pi package" ?disabled=${this.isOperating}>${dk(this.operation,`install`)?`Installing…`:`Install`}</button>
|
|
4924
4924
|
</div>
|
|
4925
4925
|
${this.validationMessage===``?null:g`<div class="field-error">${this.validationMessage}</div>`}
|
|
4926
4926
|
<small>Installs run on ${e} and use Pi's default package location, equivalent to <code>pi install <source></code>. PI WEB does not ask you to choose an install location.</small>
|
|
4927
4927
|
</form>
|
|
4928
|
-
`}renderPackageList(e,t){let n
|
|
4928
|
+
`}renderPackageList(e,t){let n=ek(t),r=uk(e),i=r!==void 0&&e.length>0;return g`
|
|
4929
4929
|
<section class="package-section" aria-label="Configured Pi packages">
|
|
4930
4930
|
<div class="package-toolbar">
|
|
4931
4931
|
<div>
|
|
@@ -4933,7 +4933,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4933
4933
|
<p>This list comes from Pi's package manager settings on ${n}.</p>
|
|
4934
4934
|
</div>
|
|
4935
4935
|
<button class="secondary" title=${r??`Update all user-scope Pi packages`} ?disabled=${this.isOperating||r!==void 0} @click=${()=>{this.updatePackage()}}>
|
|
4936
|
-
${
|
|
4936
|
+
${dk(this.operation,`update-all`)?`Updating…`:`Update all`}
|
|
4937
4937
|
</button>
|
|
4938
4938
|
</div>
|
|
4939
4939
|
${i?g`<div class="action-note">${r}</div>`:null}
|
|
@@ -4944,12 +4944,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4944
4944
|
<div class="package-list">
|
|
4945
4945
|
${e.map(e=>this.renderPackage(e))}
|
|
4946
4946
|
</div>
|
|
4947
|
-
`}renderPackage(e){let t=
|
|
4947
|
+
`}renderPackage(e){let t=ck(e),n=dk(this.operation,`update`,e.source),r=dk(this.operation,`remove`,e.source);return g`
|
|
4948
4948
|
<article class=${`package-card${e.filtered?` filtered`:``}`}>
|
|
4949
4949
|
<div class="package-main">
|
|
4950
4950
|
<strong>${e.source}</strong>
|
|
4951
|
-
<small>${
|
|
4952
|
-
<small>Installed path: <code>${
|
|
4951
|
+
<small>${ik(e)} · ${ak(e)}</small>
|
|
4952
|
+
<small>Installed path: <code>${ok(e)}</code></small>
|
|
4953
4953
|
${t===void 0?null:g`<small class="action-note">${t}</small>`}
|
|
4954
4954
|
</div>
|
|
4955
4955
|
<div class="package-actions">
|
|
@@ -4957,7 +4957,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4957
4957
|
<button class="danger" title="Remove this Pi package" ?disabled=${this.isOperating} @click=${()=>{this.removePackage(e)}}>${r?`Removing…`:`Remove`}</button>
|
|
4958
4958
|
</div>
|
|
4959
4959
|
</article>
|
|
4960
|
-
`}updateInstallSource(e){this.installSource=e.target instanceof HTMLInputElement?e.target.value:``,this.validationMessage=``}async installPackage(e){e.preventDefault();let t=
|
|
4960
|
+
`}updateInstallSource(e){this.installSource=e.target instanceof HTMLInputElement?e.target.value:``,this.validationMessage=``}async installPackage(e){e.preventDefault();let t=rk(this.installSource);if(t!==void 0){this.validationMessage=t;return}let n=nk(this.installSource);try{await this.onInstallPackage?.(n),this.installSource=``,this.validationMessage=``}catch{}}async removePackage(e){try{await this.onRemovePackage?.(e.source,e.scope)}catch{}}async updatePackage(e){try{await this.onUpdatePackage?.(e)}catch{}}get packageTarget(){return this.targetMachine??$O(void 0)}get isOperating(){return this.operation!==void 0}static{this.styles=h`
|
|
4961
4961
|
:host { display: block; }
|
|
4962
4962
|
.package-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
|
|
4963
4963
|
.package-toolbar > div, .package-main { display: grid; gap: 6px; min-width: 0; }
|
|
@@ -4992,10 +4992,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4992
4992
|
.package-actions { justify-self: start; flex-wrap: wrap; }
|
|
4993
4993
|
.package-main strong, .package-main small { white-space: normal; }
|
|
4994
4994
|
}
|
|
4995
|
-
`}};H([b({attribute:!1})],
|
|
4995
|
+
`}};H([b({attribute:!1})],mk.prototype,`packagesResponse`,void 0),H([b({type:Boolean})],mk.prototype,`loading`,void 0),H([b({attribute:!1})],mk.prototype,`operation`,void 0),H([b({attribute:!1})],mk.prototype,`targetMachine`,void 0),H([b()],mk.prototype,`error`,void 0),H([b()],mk.prototype,`operationMessage`,void 0),H([b({attribute:!1})],mk.prototype,`onReload`,void 0),H([b({attribute:!1})],mk.prototype,`onInstallPackage`,void 0),H([b({attribute:!1})],mk.prototype,`onRemovePackage`,void 0),H([b({attribute:!1})],mk.prototype,`onUpdatePackage`,void 0),H([x()],mk.prototype,`installSource`,void 0),H([x()],mk.prototype,`validationMessage`,void 0),mk=H([y(`settings-packages-panel`)],mk);function hk(e){return g`Managing Pi packages on <strong>${e}</strong>. Install, remove, and update packages managed by Pi on the selected machine. Pi packages can provide extensions, skills, prompt templates, themes, context/system prompt files, and PI WEB browser plugins.`}var gk=class extends v{constructor(...e){super(...e),this.loading=!1,this.saving=!1,this.recoveryCommandsSupported=!1,this.error=``,this.savedMessage=``,this.targetLabel=`local (local gateway)`}render(){let e=_k(this.pluginsResponse,this.configResponse),t=this.pluginsResponse!==void 0;return g`
|
|
4996
4996
|
<settings-panel-frame
|
|
4997
4997
|
heading="PI WEB plugins"
|
|
4998
|
-
.description=${
|
|
4998
|
+
.description=${xk(this.targetLabel)}
|
|
4999
4999
|
actionLabel="Reload"
|
|
5000
5000
|
actionTitle=${`Reload PI WEB plugins from ${this.targetLabel}`}
|
|
5001
5001
|
.actionDisabled=${this.loading}
|
|
@@ -5034,11 +5034,11 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5034
5034
|
</article>
|
|
5035
5035
|
`}renderPluginStatuses(e){let t=e.server;return g`
|
|
5036
5036
|
<div class="status-list" aria-label=${`${e.id} plugin states`}>
|
|
5037
|
-
${t===void 0?g`<span class="status neutral">${e.configOnly?`Configured only`:`Browser only`}</span>`:g`<span class=${`status ${
|
|
5037
|
+
${t===void 0?g`<span class="status neutral">${e.configOnly?`Configured only`:`Browser only`}</span>`:g`<span class=${`status ${yk(t.state)}`}>${vk(t.state)}</span>`}
|
|
5038
5038
|
${e.conflict?g`<span class="status error">Conflict</span>`:_}
|
|
5039
5039
|
${t?.staleRevision===!0?g`<span class="status warning">Stale revision</span>`:_}
|
|
5040
5040
|
${t?.restartRequired===!0?g`<span class="status warning">Restart required</span>`:_}
|
|
5041
|
-
${t?.health===void 0?_:g`<span class=${`status ${
|
|
5041
|
+
${t?.health===void 0?_:g`<span class=${`status ${bk(t.health.status)}`}>Health ${t.health.status}</span>`}
|
|
5042
5042
|
</div>
|
|
5043
5043
|
`}renderRecoveryCommands(){let e=this.pluginsResponse?.serverRuntime,t=(e?.status===`incompatible`&&!this.recoveryCommandsSupported?void 0:e?.recovery)??(this.recoveryCommandsSupported?kn:void 0);return t===void 0?_:g`
|
|
5044
5044
|
<aside class="recovery" aria-label="Offline server-plugin recovery commands">
|
|
@@ -5079,10 +5079,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5079
5079
|
.plugin-card { grid-template-columns: minmax(0, 1fr); align-items: start; }
|
|
5080
5080
|
.toggle { justify-self: start; }
|
|
5081
5081
|
}
|
|
5082
|
-
`}};H([b({attribute:!1})],
|
|
5082
|
+
`}};H([b({attribute:!1})],gk.prototype,`pluginsResponse`,void 0),H([b({attribute:!1})],gk.prototype,`configResponse`,void 0),H([b({type:Boolean})],gk.prototype,`loading`,void 0),H([b({type:Boolean})],gk.prototype,`saving`,void 0),H([b({type:Boolean})],gk.prototype,`recoveryCommandsSupported`,void 0),H([b()],gk.prototype,`error`,void 0),H([b()],gk.prototype,`savedMessage`,void 0),H([b()],gk.prototype,`targetLabel`,void 0),H([b({attribute:!1})],gk.prototype,`onReload`,void 0),H([b({attribute:!1})],gk.prototype,`onTogglePlugin`,void 0),gk=H([y(`settings-plugins-panel`)],gk);function _k(e,t){let n=t?.config.plugins??{},r=(e?.plugins??[]).map(e=>{let t=n[e.id],r=t?.enabled??e.enabled;return{...e,enabled:r,configOnly:!1,editable:e.discovered||t!==void 0}}),i=new Set(r.map(({id:e})=>e));for(let[e,t]of Object.entries(n))i.has(e)||r.push({id:e,source:`config`,scope:`local`,machineSpecific:!1,enabled:t.enabled!==!1,discovered:!1,conflict:!1,configOnly:!0,editable:!0});return r.sort((e,t)=>e.id.localeCompare(t.id))}function vk(e){switch(e){case`active`:return`Active`;case`failed`:return`Failed`;case`incompatible`:return`Incompatible`;case`disabled`:return`Disabled`;case`missing`:return`Not active`;case`unknown`:return`Active state unavailable`}}function yk(e){switch(e){case`active`:return`success`;case`disabled`:case`missing`:return`warning`;case`failed`:case`incompatible`:return`error`;case`unknown`:return`neutral`}}function bk(e){switch(e){case`healthy`:return`success`;case`degraded`:return`warning`;case`unhealthy`:return`error`}}function xk(e){return g`Compare desired plugin config with the active sessiond startup snapshot on <strong>${e}</strong>. This is separate from installing Pi packages.`}var Sk={capture:!0},Ck=[{value:`auto`,label:`Auto/default`,description:`Desktop-like Enter sends; mobile, coarse pointer, or narrow screens insert a new line.`},{value:`send`,label:`Enter sends message`,description:`Enter sends the chat message; Shift+Enter adds a new line when supported.`},{value:`newline`,label:`Enter inserts new line`,description:`Enter adds a line break; Shift+Enter sends the chat message when supported.`}];function wk(){return g`Edit app shortcuts by action. Type a shortcut such as <code>mod+k</code> or <code>mod+g p</code>, record one from the keyboard, disable it with None, or reset it to the default. When shortcuts conflict, custom shortcuts win before defaults; ties are resolved by action id, and shorter shortcuts shadow longer sequences with the same prefix.`}var Tk=class extends v{constructor(...e){super(...e),this.actions=[],this.loading=!1,this.saving=!1,this.error=``,this.savedMessage=``,this.drafts={},this.localError=``,this.promptEnterPreference=FE(),this.recordingListenerActive=!1,this.onRecordKeyDown=e=>{let t=this.recording;if(t===void 0)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){this.stopRecording();return}let n=Om(e);if(n===void 0){this.localError=`Press a letter, number, punctuation, function, or navigation key. Press Esc to cancel recording.`;return}if(t.tokens.length===0&&!km(n)){this.localError=`Start shortcuts with Ctrl/⌘ or Alt so normal typing is not captured.`;return}let r=[...t.tokens,n];this.localError=``,this.drafts={[t.actionId]:r.join(` `)},this.recording={actionId:t.actionId,tokens:r},this.armRecordingTimer()}}willUpdate(e){e.has(`configResponse`)&&this.configResponse!==void 0&&(this.drafts={},this.localError=``,this.stopRecording())}disconnectedCallback(){this.stopRecording(),super.disconnectedCallback()}render(){let e=kk(this.actions),t=this.shortcutResolutions();return g`
|
|
5083
5083
|
<settings-panel-frame
|
|
5084
5084
|
heading="Keyboard shortcuts"
|
|
5085
|
-
.description=${
|
|
5085
|
+
.description=${wk()}
|
|
5086
5086
|
actionLabel="Reload"
|
|
5087
5087
|
.actionDisabled=${this.loading}
|
|
5088
5088
|
.notices=${this.panelNotices()}
|
|
@@ -5113,7 +5113,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5113
5113
|
<p>Choose what Enter does in this browser. Shift+Enter does the opposite when supported; automatic touch-keyboard capitalization is ignored to avoid accidental sends.</p>
|
|
5114
5114
|
</div>
|
|
5115
5115
|
<div class="prompt-enter-options" role="radiogroup" aria-label="Enter and Shift Enter behavior in the chat composer">
|
|
5116
|
-
${
|
|
5116
|
+
${Ck.map(e=>g`
|
|
5117
5117
|
<label class="prompt-enter-option">
|
|
5118
5118
|
<input
|
|
5119
5119
|
type="radio"
|
|
@@ -5130,8 +5130,8 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5130
5130
|
`)}
|
|
5131
5131
|
</div>
|
|
5132
5132
|
</section>
|
|
5133
|
-
`}updatePromptEnterPreference(e){this.promptEnterPreference=e,
|
|
5134
|
-
<article class=${
|
|
5133
|
+
`}updatePromptEnterPreference(e){this.promptEnterPreference=e,IE(e)}renderShortcutRow(e,t){let n=this.configResponse?.config.shortcuts,r=jm(e,n),i=Nk(e,n),a=this.shortcutInputText(e),o=a.trim()===``?void 0:Tm(a),s=o?.ok===!0?o.shortcut:Mk(e,n),c=r!==void 0,l=this.drafts[e.id]!==void 0,u=l&&a.trim()!==``?`custom`:i,d=this.recordingHint(e.id),f=Ok(t);return g`
|
|
5134
|
+
<article class=${Ek(t)}>
|
|
5135
5135
|
<div class="shortcut-main">
|
|
5136
5136
|
<strong>${e.title}</strong>
|
|
5137
5137
|
${e.description!==void 0&&e.description!==``?g`<small>${e.description}</small>`:null}
|
|
@@ -5141,8 +5141,8 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5141
5141
|
<div class="shortcut-editor">
|
|
5142
5142
|
<div class="shortcut-status">
|
|
5143
5143
|
${s!==void 0&&s!==``?g`<kbd>${Dm(s)}</kbd>`:g`<span class="unassigned">${i===`disabled`?`Disabled`:`Unassigned`}</span>`}
|
|
5144
|
-
<small class=${u}>${
|
|
5145
|
-
${f===void 0?null:g`<small class=${
|
|
5144
|
+
<small class=${u}>${Pk(u)}${l?` · Unsaved`:``}</small>
|
|
5145
|
+
${f===void 0?null:g`<small class=${Dk(t)}>${f}</small>`}
|
|
5146
5146
|
</div>
|
|
5147
5147
|
<label class="shortcut-input-label">
|
|
5148
5148
|
<span>Shortcut</span>
|
|
@@ -5155,7 +5155,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5155
5155
|
autocapitalize="off"
|
|
5156
5156
|
spellcheck="false"
|
|
5157
5157
|
?disabled=${this.saving}
|
|
5158
|
-
@input=${t=>{this.updateDraft(e.id,
|
|
5158
|
+
@input=${t=>{this.updateDraft(e.id,Fk(t))}}
|
|
5159
5159
|
>
|
|
5160
5160
|
</label>
|
|
5161
5161
|
${d===``?null:g`<small class="recording-hint">${d}</small>`}
|
|
@@ -5167,7 +5167,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5167
5167
|
</div>
|
|
5168
5168
|
</div>
|
|
5169
5169
|
</article>
|
|
5170
|
-
`}shortcutInputText(e){let t=this.drafts[e.id];if(t!==void 0)return t;let n=jm(e,this.configResponse?.config.shortcuts);return n===null?``:n??e.shortcut??``}recordingHint(e){let t=this.recording;return t?.actionId===e?t.tokens.length===0?`Recording: press Ctrl/⌘ or Alt with a key. Press Esc to cancel.`:`Recording: ${Dm(t.tokens.join(` `))}. Press another key to add a sequence, or wait to finish.`:``}updateDraft(e,t){this.drafts={[e]:t},this.localError=``}async saveShortcut(e){this.stopRecording();let t=Tm(this.shortcutInputText(e).trim());if(!t.ok){this.localError=t.message;return}this.localError=``,await this.saveShortcutPreference(e,t.shortcut)}async setShortcutNone(e){this.stopRecording(),this.localError=``,await this.saveShortcutPreference(e,null)}async resetShortcut(e){this.stopRecording(),this.localError=``,await this.saveShortcutPreference(e,void 0)}async saveShortcutPreference(e,t){let n={...this.configResponse?.config??{}},r=
|
|
5170
|
+
`}shortcutInputText(e){let t=this.drafts[e.id];if(t!==void 0)return t;let n=jm(e,this.configResponse?.config.shortcuts);return n===null?``:n??e.shortcut??``}recordingHint(e){let t=this.recording;return t?.actionId===e?t.tokens.length===0?`Recording: press Ctrl/⌘ or Alt with a key. Press Esc to cancel.`:`Recording: ${Dm(t.tokens.join(` `))}. Press another key to add a sequence, or wait to finish.`:``}updateDraft(e,t){this.drafts={[e]:t},this.localError=``}async saveShortcut(e){this.stopRecording();let t=Tm(this.shortcutInputText(e).trim());if(!t.ok){this.localError=t.message;return}this.localError=``,await this.saveShortcutPreference(e,t.shortcut)}async setShortcutNone(e){this.stopRecording(),this.localError=``,await this.saveShortcutPreference(e,null)}async resetShortcut(e){this.stopRecording(),this.localError=``,await this.saveShortcutPreference(e,void 0)}async saveShortcutPreference(e,t){let n={...this.configResponse?.config??{}},r=jk(n.shortcuts??{},[e.id,...e.shortcutAliases??[]]),i=t===void 0?r:{...r,[e.id]:t};Object.keys(i).length===0?delete n.shortcuts:n.shortcuts=i,await this.onSave?.(n)}shortcutResolutions(){return new Map(wm(this.actions,this.previewShortcutConfig(),{enabledOnly:!0}).map(e=>[e.action.id,e]))}previewShortcutConfig(){let e={...this.configResponse?.config.shortcuts??{}};for(let[t,n]of Object.entries(this.drafts)){let r=n.trim();if(r===``)continue;let i=Tm(r);i.ok&&(e[t]=i.shortcut)}return Object.keys(e).length===0?void 0:e}async toggleRecording(e){if(this.recording?.actionId===e){this.stopRecording();return}this.stopRecording(),this.localError=``,this.recording={actionId:e,tokens:[]},this.ensureRecordingListener(),await this.updateComplete,this.focusShortcutInput(e)}focusShortcutInput(e){for(let t of this.renderRoot.querySelectorAll(`.shortcut-input`))if(t.dataset.actionId===e){t.focus(),t.select();return}}armRecordingTimer(){this.clearRecordingTimer(),this.recordingTimer=window.setTimeout(()=>{this.recordingTimer=void 0,this.stopRecording()},xm)}stopRecording(){this.clearRecordingTimer(),this.removeRecordingListener(),this.recording=void 0}clearRecordingTimer(){this.recordingTimer!==void 0&&(window.clearTimeout(this.recordingTimer),this.recordingTimer=void 0)}ensureRecordingListener(){this.recordingListenerActive||=(window.addEventListener(`keydown`,this.onRecordKeyDown,Sk),!0)}removeRecordingListener(){this.recordingListenerActive&&=(window.removeEventListener(`keydown`,this.onRecordKeyDown,Sk),!1)}static{this.styles=h`
|
|
5171
5171
|
:host { display: block; }
|
|
5172
5172
|
h3, p { margin: 0; }
|
|
5173
5173
|
h3 { font-size: 13px; line-height: 1.3; }
|
|
@@ -5223,7 +5223,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5223
5223
|
.shortcut-row { grid-template-columns: minmax(0, 1fr); align-items: start; }
|
|
5224
5224
|
.shortcut-status, .shortcut-actions { justify-content: flex-start; }
|
|
5225
5225
|
}
|
|
5226
|
-
`}};H([b({attribute:!1})],
|
|
5226
|
+
`}};H([b({attribute:!1})],Tk.prototype,`actions`,void 0),H([b({attribute:!1})],Tk.prototype,`configResponse`,void 0),H([b({type:Boolean})],Tk.prototype,`loading`,void 0),H([b({type:Boolean})],Tk.prototype,`saving`,void 0),H([b()],Tk.prototype,`error`,void 0),H([b()],Tk.prototype,`savedMessage`,void 0),H([b({attribute:!1})],Tk.prototype,`onReload`,void 0),H([b({attribute:!1})],Tk.prototype,`onSave`,void 0),H([x()],Tk.prototype,`drafts`,void 0),H([x()],Tk.prototype,`localError`,void 0),H([x()],Tk.prototype,`promptEnterPreference`,void 0),H([x()],Tk.prototype,`recording`,void 0),Tk=H([y(`settings-shortcuts-panel`)],Tk);function Ek(e){return e?.active===!1?`shortcut-row shadowed`:e?.active===!0&&e.shadows.length>0?`shortcut-row shadowing`:`shortcut-row`}function Dk(e){return e?.active===!1?`conflict shadowed`:`conflict shadowing`}function Ok(e){if(e===void 0)return;if(!e.active)return`Shadowed by ${e.shadowedBy?.action.title??`another action`}`;let t=e.shadows.length;if(t===0)return;let n=e.shadows.slice(0,2).map(e=>e.action.title).join(`, `),r=t>2?`, +${String(t-2)} more`:``;return`Shadows ${String(t)} ${t===1?`action`:`actions`}: ${n}${r}`}function kk(e){let t=new Map;for(let n of[...e].sort(Ak)){let e=n.group??`Other`;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>({name:e,actions:t}))}function Ak(e,t){return(e.group??`Other`).localeCompare(t.group??`Other`)||e.title.localeCompare(t.title)}function jk(e,t){let n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([e])=>!n.has(e)))}function Mk(e,t){let n=jm(e,t);if(n!==null)return n??e.shortcut}function Nk(e,t){let n=jm(e,t);return n===null?`disabled`:n===void 0?e.shortcut===void 0||e.shortcut===``?`unassigned`:`default`:`custom`}function Pk(e){switch(e){case`default`:return`Default`;case`custom`:return`Custom`;case`disabled`:return`Disabled`;case`unassigned`:return`No default`}}function Fk(e){return e.target instanceof HTMLInputElement?e.target.value:``}async function Ik(e){let[t,n]=await Promise.allSettled([e.loadConfig(),e.loadPlugins()]),r={error:``},i=[];return t.status===`fulfilled`?r.config=t.value:i.push(`config: ${Rk(t.reason)}`),n.status===`fulfilled`?r.plugins=n.value:i.push(`PI WEB plugins: ${Rk(n.reason)}`),i.length>0&&(r.error=`Failed to load settings: ${i.join(`; `)}`),r}async function Lk(e,t){try{return{packagesResponse:await t(e.id),error:``}}catch(t){return{error:`Failed to load Pi packages from ${ek(e)}: ${pk(Rk(t),e)}`}}}function Rk(e){return e instanceof Error?e.message:String(e)}function zk(e,t){return{...e,config:Bk(e.config,t.config),effectiveConfig:Bk(e.effectiveConfig,t.effectiveConfig)}}function Bk(e,t){return{...e,...t.pathAccess===void 0?{}:{pathAccess:t.pathAccess},...t.uploads===void 0?{}:{uploads:t.uploads},...t.maxUploadBytes===void 0?{}:{maxUploadBytes:t.maxUploadBytes}}}function Vk(e){return e===void 0?{id:`local`,name:`local`,kind:`local`}:{id:e.id,name:e.name,kind:e.kind}}function Hk(e){return e.kind===`local`?`${e.name} (local gateway)`:`${e.name} (remote machine)`}function Uk(e,t){return e.kind===`local`?{state:`supported`}:t?.ok===!0?bn(t,tn.pluginLifecycle)?{state:`supported`}:{state:`unsupported`,message:Kk(e)}:{state:`unknown`}}function Wk(e){return`${e.state}:${e.message??``}`}function Gk(e){return e?.state===`unsupported`}function Kk(e){return`Plugin lifecycle diagnostics are not available on ${e.name}. Update and restart PI WEB on that machine before loading server-backed plugins.`}function qk(e,t){let n=e.trim();return t.kind===`remote`?n===`Remote machine timeout`?`Timed out while contacting ${t.name} for selected-machine settings. The operation may still be running remotely; reload before retrying.`:n===`Remote machine unavailable`?`Could not reach ${t.name} for selected-machine settings. Check the machine connection and try again.`:n:n}function Jk(e,t,n){let r=e.plugins??{},i=r[t]??{};return{plugins:{...r,[t]:{...i,enabled:n}}}}function Yk(e,t){return{...e,config:Xk(e.config,t.config),effectiveConfig:Xk(e.effectiveConfig,t.effectiveConfig)}}function Xk(e,t){return t.plugins===void 0?e:{...e,plugins:t.plugins}}var X=class extends v{constructor(...e){super(...e),this.section=`general`,this.actions=[],this.machines=[],this.machineStatuses={},this.themes=[],this.followSystemTheme=!1,this.uiScale=1,this.fleetLoading=!1,this.loading=!0,this.accessLoading=!0,this.sessiondLoading=!0,this.pluginLoading=!0,this.packageLoading=!0,this.saving=!1,this.error=``,this.accessError=``,this.sessiondError=``,this.pluginError=``,this.packageError=``,this.savedMessage=``,this.packageMessage=``,this.loadRequestSeq=0,this.accessLoadRequestSeq=0,this.sessiondLoadRequestSeq=0,this.pluginLoadRequestSeq=0,this.packageLoadRequestSeq=0,this.packageMutationSeq=0}connectedCallback(){super.connectedCallback(),this.loadConfig(),this.loadAccessConfigForTarget(),this.reloadSessiondState(),this.loadPluginsForTarget(),this.loadPackagesForTarget()}disconnectedCallback(){this.savedMessageTimer!==void 0&&window.clearTimeout(this.savedMessageTimer),this.savedMessageTimer=void 0,super.disconnectedCallback()}updated(e){let t=this.settingsTarget();if(e.has(`machine`)&&Vk(e.get(`machine`)).id!==t.id){this.resetAccessStateForTargetChange(),this.isConnected&&this.loadAccessConfigForTarget(t),this.resetSessiondStateForTargetChange(),this.isConnected&&this.loadSessiondConfigForTarget(t),this.resetPluginStateForTargetChange(),this.isConnected&&this.loadPluginsForTarget(t),this.resetPackageStateForTargetChange(),this.isConnected&&this.loadPackagesForTarget(t);return}e.has(`machineRuntime`)&&this.pluginLifecycleSupportNeedsReload(e.get(`machineRuntime`),t)&&(this.resetPluginStateForTargetChange(),this.isConnected&&this.loadPluginsForTarget(t))}render(){return g`
|
|
5227
5227
|
<modal-surface .onClose=${()=>this.onClose?.()} .label=${`PI WEB settings`}>
|
|
5228
5228
|
<header class="settings-header">
|
|
5229
5229
|
<div>
|
|
@@ -5278,7 +5278,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5278
5278
|
.saving=${this.saving}
|
|
5279
5279
|
.error=${this.sessiondError}
|
|
5280
5280
|
.savedMessage=${this.savedMessage}
|
|
5281
|
-
.targetLabel=${
|
|
5281
|
+
.targetLabel=${Hk(this.settingsTarget())}
|
|
5282
5282
|
.onReload=${()=>this.reloadSessiondState()}
|
|
5283
5283
|
.onSave=${e=>this.saveSessiondConfig(e)}
|
|
5284
5284
|
></settings-sessiond-panel>
|
|
@@ -5315,7 +5315,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5315
5315
|
.recoveryCommandsSupported=${this.pluginLifecycleSupport().state===`supported`}
|
|
5316
5316
|
.error=${this.pluginError}
|
|
5317
5317
|
.savedMessage=${this.savedMessage}
|
|
5318
|
-
.targetLabel=${
|
|
5318
|
+
.targetLabel=${Hk(this.settingsTarget())}
|
|
5319
5319
|
.onReload=${()=>this.loadPluginsForTarget()}
|
|
5320
5320
|
.onTogglePlugin=${(e,t)=>this.togglePlugin(e,t)}
|
|
5321
5321
|
></settings-plugins-panel>
|
|
@@ -5329,7 +5329,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5329
5329
|
.error=${this.error}
|
|
5330
5330
|
.machineError=${this.accessError}
|
|
5331
5331
|
.savedMessage=${this.savedMessage}
|
|
5332
|
-
.targetLabel=${
|
|
5332
|
+
.targetLabel=${Hk(this.settingsTarget())}
|
|
5333
5333
|
.onReload=${()=>this.loadConfig()}
|
|
5334
5334
|
.onReloadMachine=${()=>this.loadAccessConfigForTarget()}
|
|
5335
5335
|
.onSave=${e=>this.saveConfig(e)}
|
|
@@ -5340,7 +5340,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5340
5340
|
<strong>${t}</strong>
|
|
5341
5341
|
<small>${n}</small>
|
|
5342
5342
|
</button>
|
|
5343
|
-
`}navigate(e){this.onNavigate?.(e)}async loadConfig(){let e=++this.loadRequestSeq;this.loading=!0,this.error=``;try{let t=await
|
|
5343
|
+
`}navigate(e){this.onNavigate?.(e)}async loadConfig(){let e=++this.loadRequestSeq;this.loading=!0,this.error=``;try{let t=await Ik({loadConfig:()=>Xo.config(),loadPlugins:()=>Qo.plugins()});if(!this.isCurrentLoad(e))return;t.config!==void 0&&(this.configResponse=t.config),t.plugins!==void 0&&(this.pluginsResponse=t.plugins),this.error=t.error}finally{this.isCurrentLoad(e)&&(this.loading=!1)}}async loadAccessConfigForTarget(e=this.settingsTarget()){let t=++this.accessLoadRequestSeq;this.accessLoading=!0,this.accessError=``;try{let n=await Xo.config(e.id);if(!this.isCurrentAccessLoad(t,e))return;this.accessConfigResponse=n}catch(n){this.isCurrentAccessLoad(t,e)&&(this.accessError=`Failed to load file access/upload config from ${Hk(e)}: ${qk(Zk(n),e)}`)}finally{this.isCurrentAccessLoad(t,e)&&(this.accessLoading=!1)}}async reloadSessiondState(e=this.settingsTarget()){await Promise.all([this.loadSessiondConfigForTarget(e),this.onRefreshMachineRuntime?.(e.id)])}async loadSessiondConfigForTarget(e=this.settingsTarget()){let t=++this.sessiondLoadRequestSeq;this.sessiondLoading=!0,this.sessiondError=``;try{let n=await Xo.config(e.id);if(!this.isCurrentSessiondLoad(t,e))return;this.sessiondConfigResponse=n}catch(n){this.isCurrentSessiondLoad(t,e)&&(this.sessiondError=`Failed to load session-daemon config from ${Hk(e)}: ${qk(Zk(n),e)}`)}finally{this.isCurrentSessiondLoad(t,e)&&(this.sessiondLoading=!1)}}async loadPluginsForTarget(e=this.settingsTarget()){let t=++this.pluginLoadRequestSeq;this.pluginLoading=!0,this.pluginError=``;try{let n=this.pluginLifecycleSupport(e);if(Gk(n)){try{let r=await Xo.config(e.id);if(!this.isCurrentPluginLoad(t,e))return;this.selectedPluginConfigResponse=r,this.selectedPluginsResponse=void 0,this.pluginError=n.message??`Plugin lifecycle diagnostics are not available on ${Hk(e)}.`}catch(r){if(!this.isCurrentPluginLoad(t,e))return;this.pluginError=`Failed to load PI WEB plugin config from ${Hk(e)}: ${qk(Zk(r),e)}; ${n.message??`plugin lifecycle diagnostics are unsupported`}`}return}let[r,i]=await Promise.allSettled([Xo.config(e.id),Qo.plugins(e.id)]);if(!this.isCurrentPluginLoad(t,e))return;let a=[];r.status===`fulfilled`?this.selectedPluginConfigResponse=r.value:a.push(`config: ${qk(Zk(r.reason),e)}`),i.status===`fulfilled`?this.selectedPluginsResponse=i.value:a.push(`PI WEB plugins: ${qk(Zk(i.reason),e)}`),this.pluginError=a.length===0?``:`Failed to load PI WEB plugin settings from ${Hk(e)}: ${a.join(`; `)}`}finally{this.isCurrentPluginLoad(t,e)&&(this.pluginLoading=!1)}}async loadPackagesForTarget(e=this.packageTarget()){let t=++this.packageLoadRequestSeq;this.packageLoading=!0,this.packageError=``,this.packageMessage=``;try{let n=await Lk(e,e=>ns.packages(e));if(!this.isCurrentPackageLoad(t,e))return;this.packagesResponse=n.packagesResponse,this.packageError=n.error}finally{this.isCurrentPackageLoad(t,e)&&(this.packageLoading=!1)}}async togglePlugin(e,t){if(this.saving)return;let n=this.settingsTarget(),r=this.pluginLifecycleSupport(n);if(this.selectedPluginConfigResponse===void 0){this.pluginError=`Plugin config is not loaded for ${Hk(n)}. Reload before changing plugin enablement.`;return}let i=Jk(this.selectedPluginConfigResponse.config,e,t);this.saving=!0,this.pluginError=``,this.savedMessage=``;try{let e=await Xo.saveConfig(i,n.id);if(!this.isCurrentSettingsTarget(n))return;this.selectedPluginConfigResponse=e,n.kind===`local`&&this.configResponse!==void 0&&(this.configResponse=Yk(this.configResponse,e),this.onConfigSaved?.(this.configResponse.effectiveConfig));let t;if(Gk(r)?(this.selectedPluginsResponse=void 0,t=r.message??`Plugin lifecycle diagnostics are not available on ${Hk(n)}.`):t=await this.refreshPluginsForTarget(n),!this.isCurrentSettingsTarget(n))return;t!==void 0&&(this.pluginError=t),this.showSavedMessage()}catch(e){this.isCurrentSettingsTarget(n)&&(this.pluginError=`Failed to save PI WEB plugin config on ${Hk(n)}: ${qk(Zk(e),n)}`)}finally{this.saving=!1}}async saveConfig(e){if(!this.saving){this.saving=!0,this.error=``,this.savedMessage=``;try{let t=await Xo.saveConfig(e);this.configResponse=t,this.onConfigSaved?.(t.effectiveConfig),this.showSavedMessage()}catch(e){this.error=`Failed to save config: ${Zk(e)}`}finally{this.saving=!1}}}async saveMachineAccessConfig(e){if(this.saving)return;let t=this.settingsTarget();this.saving=!0,this.accessError=``,this.savedMessage=``;try{let n=await Xo.saveConfig(e,t.id);if(!this.isCurrentSettingsTarget(t))return;this.accessConfigResponse=n,t.kind===`local`&&this.configResponse!==void 0&&(this.configResponse=zk(this.configResponse,n),this.onConfigSaved?.(this.configResponse.effectiveConfig)),this.showSavedMessage()}catch(e){this.isCurrentSettingsTarget(t)&&(this.accessError=`Failed to save file access/upload config on ${Hk(t)}: ${qk(Zk(e),t)}`)}finally{this.saving=!1}}async saveSessiondConfig(e){if(this.saving)return;let t=this.settingsTarget();this.saving=!0,this.sessiondError=``,this.savedMessage=``;try{let n=await Xo.saveConfig(e,t.id);if(!this.isCurrentSettingsTarget(t))return;this.sessiondConfigResponse=n,t.kind===`local`&&this.configResponse!==void 0&&(this.configResponse=YO(this.configResponse,n)),this.showSavedMessage()}catch(e){this.isCurrentSettingsTarget(t)&&(this.sessiondError=`Failed to save session-daemon config on ${Hk(t)}: ${qk(Zk(e),t)}`)}finally{this.saving=!1}}async installPiPackage(e){let t=this.packageTarget();await this.runPiPackageMutation({kind:`install`,source:e},`install Pi package`,t,()=>ns.install(e,t.id))}async removePiPackage(e,t){let n=this.packageTarget();await this.runPiPackageMutation({kind:`remove`,source:e},`remove Pi package`,n,()=>ns.remove(e,t,n.id))}async updatePiPackage(e){let t=this.packageTarget();await this.runPiPackageMutation(e===void 0?{kind:`update-all`}:{kind:`update`,source:e},`update Pi packages`,t,()=>ns.update(e,t.id))}async runPiPackageMutation(e,t,n,r){if(this.saving)throw Error(`A settings operation is already running.`);let i=++this.packageMutationSeq;this.packageLoadRequestSeq+=1,this.packageLoading=!1,this.saving=!0,this.packageOperation=e,this.packageError=``,this.packageMessage=``;try{let e=await r();if(!this.isCurrentPackageMutation(i,n))return;this.packagesResponse={packages:e.packages};let t=tk(n)?await this.refreshGatewayPlugins():void 0;if(!this.isCurrentPackageMutation(i,n))return;t!==void 0&&(this.packageError=t),this.packageMessage=fk(e.action,n)}catch(e){throw this.isCurrentPackageMutation(i,n)&&(this.packageError=`Failed to ${t} on ${ek(n)}: ${pk(Zk(e),n)}`),e}finally{this.packageMutationSeq===i&&(this.packageOperation=void 0,this.saving=!1)}}async refreshGatewayPlugins(){try{this.pluginsResponse=await Qo.plugins();return}catch(e){return`Failed to refresh gateway PI WEB plugins: ${Zk(e)}`}}async refreshPluginsForTarget(e){try{let t=await Qo.plugins(e.id);this.isCurrentSettingsTarget(e)&&(this.selectedPluginsResponse=t);return}catch(t){return this.isCurrentSettingsTarget(e)&&(this.selectedPluginsResponse=void 0),`Config saved, but failed to refresh PI WEB plugins from ${Hk(e)}: ${qk(Zk(t),e)}`}}settingsTarget(){return Vk(this.machine)}packageTarget(){return this.settingsTarget()}pluginLifecycleSupport(e=this.settingsTarget()){return Uk(e,this.machineRuntime)}pluginLifecycleSupportNeedsReload(e,t){let n=Uk(t,e),r=this.pluginLifecycleSupport(t);return Wk(n)!==Wk(r)}isCurrentLoad(e){return e===this.loadRequestSeq}isCurrentAccessLoad(e,t){return e===this.accessLoadRequestSeq&&this.isCurrentSettingsTarget(t)}isCurrentSessiondLoad(e,t){return e===this.sessiondLoadRequestSeq&&this.isCurrentSettingsTarget(t)}isCurrentPluginLoad(e,t){return e===this.pluginLoadRequestSeq&&this.isCurrentSettingsTarget(t)}isCurrentPackageLoad(e,t){return e===this.packageLoadRequestSeq&&this.isCurrentPackageTarget(t)}isCurrentPackageMutation(e,t){return e===this.packageMutationSeq&&this.isCurrentPackageTarget(t)}isCurrentPackageTarget(e){return this.packageTarget().id===e.id}isCurrentSettingsTarget(e){return this.settingsTarget().id===e.id}resetAccessStateForTargetChange(){this.accessLoadRequestSeq+=1,this.accessLoading=!1,this.accessError=``,this.accessConfigResponse=void 0,this.savedMessage=``}resetSessiondStateForTargetChange(){this.sessiondLoadRequestSeq+=1,this.sessiondLoading=!1,this.sessiondError=``,this.sessiondConfigResponse=void 0,this.savedMessage=``}resetPluginStateForTargetChange(){this.pluginLoadRequestSeq+=1,this.pluginLoading=!1,this.pluginError=``,this.selectedPluginConfigResponse=void 0,this.selectedPluginsResponse=void 0,this.savedMessage=``}resetPackageStateForTargetChange(){let e=this.packageOperation!==void 0;this.packageLoadRequestSeq+=1,this.packageMutationSeq+=1,this.packageLoading=!1,this.packageOperation=void 0,this.packageMessage=``,this.packageError=``,this.packagesResponse=void 0,e&&(this.saving=!1)}showSavedMessage(){this.savedMessage=`Config saved.`,this.savedMessageTimer!==void 0&&window.clearTimeout(this.savedMessageTimer),this.savedMessageTimer=window.setTimeout(()=>{this.savedMessage===`Config saved.`&&(this.savedMessage=``),this.savedMessageTimer=void 0},3e3)}static{this.styles=h`
|
|
5344
5344
|
:host { position: fixed; inset: 0; z-index: var(--pi-layer-dialog); color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
5345
5345
|
modal-surface { --modal-surface-backdrop-padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); --modal-surface-width: min(980px, 100%); --modal-surface-max-height: min(760px, 100%); --modal-surface-min-height: min(620px, 100%); --modal-surface-radius: 14px; }
|
|
5346
5346
|
.settings-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--pi-border); }
|
|
@@ -5365,7 +5365,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5365
5365
|
.settings-nav button { flex: 0 0 auto; width: auto; min-width: 128px; margin: 0; }
|
|
5366
5366
|
.settings-content { padding: 14px 12px calc(18px + env(safe-area-inset-bottom)); }
|
|
5367
5367
|
}
|
|
5368
|
-
`}};H([b({attribute:!1})],X.prototype,`section`,void 0),H([b({attribute:!1})],X.prototype,`actions`,void 0),H([b({attribute:!1})],X.prototype,`machine`,void 0),H([b({attribute:!1})],X.prototype,`machineRuntime`,void 0),H([b({attribute:!1})],X.prototype,`machines`,void 0),H([b({attribute:!1})],X.prototype,`machineStatuses`,void 0),H([b({attribute:!1})],X.prototype,`onAddMachine`,void 0),H([b({attribute:!1})],X.prototype,`onRenameMachine`,void 0),H([b({attribute:!1})],X.prototype,`onRemoveMachine`,void 0),H([b({attribute:!1})],X.prototype,`themes`,void 0),H([b({attribute:!1})],X.prototype,`selectedThemeId`,void 0),H([b({attribute:!1})],X.prototype,`activeThemeId`,void 0),H([b({type:Boolean})],X.prototype,`followSystemTheme`,void 0),H([b({attribute:!1})],X.prototype,`onSelectTheme`,void 0),H([b({attribute:!1})],X.prototype,`onToggleFollowSystem`,void 0),H([b({type:Number})],X.prototype,`uiScale`,void 0),H([b({attribute:!1})],X.prototype,`onChangeUiScale`,void 0),H([b({attribute:!1})],X.prototype,`fleetReport`,void 0),H([b({type:Boolean})],X.prototype,`fleetLoading`,void 0),H([b({attribute:!1})],X.prototype,`fleetError`,void 0),H([b({attribute:!1})],X.prototype,`onRefreshFleet`,void 0),H([b({attribute:!1})],X.prototype,`onRunFleet`,void 0),H([b({attribute:!1})],X.prototype,`onNavigate`,void 0),H([b({attribute:!1})],X.prototype,`onClose`,void 0),H([b({attribute:!1})],X.prototype,`onConfigSaved`,void 0),H([b({attribute:!1})],X.prototype,`onRefreshMachineRuntime`,void 0),H([x()],X.prototype,`configResponse`,void 0),H([x()],X.prototype,`accessConfigResponse`,void 0),H([x()],X.prototype,`sessiondConfigResponse`,void 0),H([x()],X.prototype,`pluginsResponse`,void 0),H([x()],X.prototype,`selectedPluginConfigResponse`,void 0),H([x()],X.prototype,`selectedPluginsResponse`,void 0),H([x()],X.prototype,`packagesResponse`,void 0),H([x()],X.prototype,`loading`,void 0),H([x()],X.prototype,`accessLoading`,void 0),H([x()],X.prototype,`sessiondLoading`,void 0),H([x()],X.prototype,`pluginLoading`,void 0),H([x()],X.prototype,`packageLoading`,void 0),H([x()],X.prototype,`saving`,void 0),H([x()],X.prototype,`packageOperation`,void 0),H([x()],X.prototype,`error`,void 0),H([x()],X.prototype,`accessError`,void 0),H([x()],X.prototype,`sessiondError`,void 0),H([x()],X.prototype,`pluginError`,void 0),H([x()],X.prototype,`packageError`,void 0),H([x()],X.prototype,`savedMessage`,void 0),H([x()],X.prototype,`packageMessage`,void 0),X=H([y(`settings-dialog`)],X);function
|
|
5368
|
+
`}};H([b({attribute:!1})],X.prototype,`section`,void 0),H([b({attribute:!1})],X.prototype,`actions`,void 0),H([b({attribute:!1})],X.prototype,`machine`,void 0),H([b({attribute:!1})],X.prototype,`machineRuntime`,void 0),H([b({attribute:!1})],X.prototype,`machines`,void 0),H([b({attribute:!1})],X.prototype,`machineStatuses`,void 0),H([b({attribute:!1})],X.prototype,`onAddMachine`,void 0),H([b({attribute:!1})],X.prototype,`onRenameMachine`,void 0),H([b({attribute:!1})],X.prototype,`onRemoveMachine`,void 0),H([b({attribute:!1})],X.prototype,`themes`,void 0),H([b({attribute:!1})],X.prototype,`selectedThemeId`,void 0),H([b({attribute:!1})],X.prototype,`activeThemeId`,void 0),H([b({type:Boolean})],X.prototype,`followSystemTheme`,void 0),H([b({attribute:!1})],X.prototype,`onSelectTheme`,void 0),H([b({attribute:!1})],X.prototype,`onToggleFollowSystem`,void 0),H([b({type:Number})],X.prototype,`uiScale`,void 0),H([b({attribute:!1})],X.prototype,`onChangeUiScale`,void 0),H([b({attribute:!1})],X.prototype,`fleetReport`,void 0),H([b({type:Boolean})],X.prototype,`fleetLoading`,void 0),H([b({attribute:!1})],X.prototype,`fleetError`,void 0),H([b({attribute:!1})],X.prototype,`onRefreshFleet`,void 0),H([b({attribute:!1})],X.prototype,`onRunFleet`,void 0),H([b({attribute:!1})],X.prototype,`onNavigate`,void 0),H([b({attribute:!1})],X.prototype,`onClose`,void 0),H([b({attribute:!1})],X.prototype,`onConfigSaved`,void 0),H([b({attribute:!1})],X.prototype,`onRefreshMachineRuntime`,void 0),H([x()],X.prototype,`configResponse`,void 0),H([x()],X.prototype,`accessConfigResponse`,void 0),H([x()],X.prototype,`sessiondConfigResponse`,void 0),H([x()],X.prototype,`pluginsResponse`,void 0),H([x()],X.prototype,`selectedPluginConfigResponse`,void 0),H([x()],X.prototype,`selectedPluginsResponse`,void 0),H([x()],X.prototype,`packagesResponse`,void 0),H([x()],X.prototype,`loading`,void 0),H([x()],X.prototype,`accessLoading`,void 0),H([x()],X.prototype,`sessiondLoading`,void 0),H([x()],X.prototype,`pluginLoading`,void 0),H([x()],X.prototype,`packageLoading`,void 0),H([x()],X.prototype,`saving`,void 0),H([x()],X.prototype,`packageOperation`,void 0),H([x()],X.prototype,`error`,void 0),H([x()],X.prototype,`accessError`,void 0),H([x()],X.prototype,`sessiondError`,void 0),H([x()],X.prototype,`pluginError`,void 0),H([x()],X.prototype,`packageError`,void 0),H([x()],X.prototype,`savedMessage`,void 0),H([x()],X.prototype,`packageMessage`,void 0),X=H([y(`settings-dialog`)],X);function Zk(e){return e instanceof Error?e.message:String(e)}var Qk=class extends v{constructor(...e){super(...e),this.tool=`core:workspace.files`,this.panels=[],this.hideToolTabs=!1,this.onSelectTool=()=>void 0,this.workspaceHeaderEdges=new Ew(()=>{this.requestUpdate()}),this.onWorkspaceHeaderScroll=()=>{this.workspaceHeaderEdges.refresh()}}updated(){this.workspaceHeaderEdges.observe(this.workspaceHeaderStripElement())}disconnectedCallback(){this.workspaceHeaderEdges.dispose(),super.disconnectedCallback()}render(){if(this.workspace===void 0)return this.renderEmptyState(this.emptyState??{title:`Select a workspace`,body:`Choose a workspace to use its tools.`});let e=this.panelContext;if(e===void 0)return this.renderEmptyState({title:`Workspace tools unavailable`,body:`Try selecting the workspace again.`});let t=this.panels,n=t.find(e=>e.id===this.tool)??t[0];return g`
|
|
5369
5369
|
${this.hideToolTabs?null:g`
|
|
5370
5370
|
<header>
|
|
5371
5371
|
<div class=${this.workspaceHeaderFrameClass()}>
|
|
@@ -5395,12 +5395,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5395
5395
|
<h2>${e.title}</h2>
|
|
5396
5396
|
${e.body===void 0?null:g`<p>${e.body}</p>`}
|
|
5397
5397
|
</section>
|
|
5398
|
-
`}workspaceHeaderFrameClass(){return`workspace-header-scroll-frame${
|
|
5398
|
+
`}workspaceHeaderFrameClass(){return`workspace-header-scroll-frame${ww(this.workspaceHeaderEdges.edges)}`}workspaceHeaderStripElement(){let e=this.workspaceHeaderStrip;return e instanceof HTMLElement?e:void 0}static{this.styles=Kg}};H([b({attribute:!1})],Qk.prototype,`workspace`,void 0),H([b({attribute:!1})],Qk.prototype,`panelContext`,void 0),H([b({attribute:!1})],Qk.prototype,`emptyState`,void 0),H([b()],Qk.prototype,`tool`,void 0),H([b({attribute:!1})],Qk.prototype,`panels`,void 0),H([b({type:Boolean})],Qk.prototype,`hideToolTabs`,void 0),H([b({attribute:!1})],Qk.prototype,`onSelectTool`,void 0),H([S(`.workspace-header-strip`)],Qk.prototype,`workspaceHeaderStrip`,void 0),Qk=H([y(`workspace-panel`)],Qk);function $k(e){return e===`chat`?`sessions`:`conversation`}var Z=class extends v{constructor(...e){super(...e),this.machines=[],this.mainView=`chat`,this.isWorking=!1,this.emphasizeSession=!1,this.renamingSession=!1,this.renameSeed=``,this.renameInputSeeded=!1,this.canScrollLeft=!1,this.canScrollRight=!1,this.onContextScroll=()=>{this.updateScrollState()}}disconnectedCallback(){this.contextItemsResizeObserver?.disconnect(),this.contextItemsResizeObserver=void 0,this.observedContextItems=void 0,super.disconnectedCallback()}firstUpdated(){this.observeContextItems(),this.updateScrollState()}updated(){this.observeContextItems(),this.updateScrollState();let e=this.renderRoot.querySelector(`.context-session-input`);e!==null&&!this.renameInputSeeded?(this.renameInputSeeded=!0,e.select()):e===null&&(this.renameInputSeeded=!1)}render(){return this.emphasizeSession&&this.session!==void 0?this.renderSessionLed():this.renderLocationTrail()}renderSessionLed(){let e=sA(this.workspace,this.project,this.machine,this.machines),t=lA(this.session);return g`
|
|
5399
5399
|
<nav class=${this.contextBarClass()} aria-label="Current session">
|
|
5400
5400
|
<button
|
|
5401
5401
|
type="button"
|
|
5402
5402
|
class="context-breadcrumb"
|
|
5403
|
-
title=${
|
|
5403
|
+
title=${cA(this.workspace,this.project)}
|
|
5404
5404
|
aria-label=${`Location: ${e}. Open navigation.`}
|
|
5405
5405
|
@click=${()=>{this.onOpenSection?.(this.breadcrumbSection())}}
|
|
5406
5406
|
>${e}</button>
|
|
@@ -5435,7 +5435,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5435
5435
|
</span>`:g`<button
|
|
5436
5436
|
type="button"
|
|
5437
5437
|
class="context-session-title"
|
|
5438
|
-
title=${
|
|
5438
|
+
title=${uA(this.session)}
|
|
5439
5439
|
aria-label=${`Session: ${t}. Open session selection.`}
|
|
5440
5440
|
@click=${()=>{this.openSessions()}}
|
|
5441
5441
|
>${t}</button>`}
|
|
@@ -5454,33 +5454,33 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5454
5454
|
>✎</button>`}
|
|
5455
5455
|
${this.hasContextActions()?g`<div class="context-actions inline">${this.renderQuickSwitchButton()}${this.renderToolsButton()}${this.renderActionsButton()}${this.refreshControl}</div>`:null}
|
|
5456
5456
|
</nav>
|
|
5457
|
-
`}onRenameKeydown(e){if(e.key===`Escape`){e.preventDefault(),this.renamingSession=!1;return}e.key===`Enter`&&(e.preventDefault(),this.commitRename())}commitRename(){let e=(this.renderRoot.querySelector(`.context-session-input`)?.value??``).trim();this.renamingSession=!1,!(e===``||e===this.renameSeed||e===this.session?.name)&&this.onRenameSession?.(e)}breadcrumbSection(){return this.workspace===void 0?this.project===void 0
|
|
5457
|
+
`}onRenameKeydown(e){if(e.key===`Escape`){e.preventDefault(),this.renamingSession=!1;return}e.key===`Enter`&&(e.preventDefault(),this.commitRename())}commitRename(){let e=(this.renderRoot.querySelector(`.context-session-input`)?.value??``).trim();this.renamingSession=!1,!(e===``||e===this.renameSeed||e===this.session?.name)&&this.onRenameSession?.(e)}breadcrumbSection(){return this.workspace===void 0?this.project===void 0&&eA(this.machines)?`machines`:`projects`:`workspaces`}renderLocationTrail(){let e=eA(this.machines),t=tA(this.machine),n=rA(this.project),r=aA(this.workspace),i=lA(this.session),a=this.session!==void 0;return g`
|
|
5458
5458
|
<nav class=${this.contextBarClass()} aria-label="Current location">
|
|
5459
5459
|
<span class="context-bar-label">Location</span>
|
|
5460
5460
|
<ol class="context-items" @scroll=${this.onContextScroll}>
|
|
5461
5461
|
${e?g`
|
|
5462
5462
|
<li class="context-item">
|
|
5463
|
-
<button type="button" class=${this.machine===void 0?`context-chip empty`:`context-chip`} title=${
|
|
5463
|
+
<button type="button" class=${this.machine===void 0?`context-chip empty`:`context-chip`} title=${nA(this.machine)} aria-label=${`Machine: ${t}. Open machine selection.`} @click=${()=>{this.onOpenSection?.(`machines`)}}>
|
|
5464
5464
|
<span class="context-kind">Machine</span>
|
|
5465
5465
|
<span class="context-value">${t}</span>
|
|
5466
5466
|
</button>
|
|
5467
5467
|
</li>
|
|
5468
5468
|
`:null}
|
|
5469
5469
|
<li class="context-item">
|
|
5470
|
-
<button type="button" class=${this.project===void 0?`context-chip empty`:`context-chip`} title=${
|
|
5470
|
+
<button type="button" class=${this.project===void 0?`context-chip empty`:`context-chip`} title=${iA(this.project)} aria-label=${`Project: ${n}. Open project selection.`} @click=${()=>{this.onOpenSection?.(`projects`)}}>
|
|
5471
5471
|
<span class="context-kind">Project</span>
|
|
5472
5472
|
<span class="context-value">${n}</span>
|
|
5473
5473
|
</button>
|
|
5474
5474
|
</li>
|
|
5475
5475
|
<li class="context-item">
|
|
5476
|
-
<button type="button" class=${this.workspace===void 0?`context-chip empty`:`context-chip`} title=${
|
|
5476
|
+
<button type="button" class=${this.workspace===void 0?`context-chip empty`:`context-chip`} title=${oA(this.workspace)} aria-label=${`Workspace: ${r}. Open workspace selection.`} @click=${()=>{this.onOpenSection?.(`workspaces`)}}>
|
|
5477
5477
|
<span class="context-kind">Workspace</span>
|
|
5478
5478
|
<span class="context-value">${r}</span>
|
|
5479
5479
|
</button>
|
|
5480
5480
|
</li>
|
|
5481
5481
|
${a?g`
|
|
5482
5482
|
<li class="context-item">
|
|
5483
|
-
<button type="button" class="context-chip" title=${
|
|
5483
|
+
<button type="button" class="context-chip" title=${uA(this.session)} aria-label=${`Session: ${i}. ${$k(this.mainView)===`conversation`?`Back to the conversation.`:`Open session selection.`}`} @click=${()=>{this.followSessionChip()}}>
|
|
5484
5484
|
<span class="context-kind">Session</span>
|
|
5485
5485
|
<span class="context-value session-value">${i}</span>
|
|
5486
5486
|
</button>
|
|
@@ -5489,7 +5489,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5489
5489
|
</ol>
|
|
5490
5490
|
${this.hasContextActions()?g`<div class="context-actions">${this.renderQuickSwitchButton()}${this.renderToolsButton()}${this.renderActionsButton()}${this.refreshControl}</div>`:null}
|
|
5491
5491
|
</nav>
|
|
5492
|
-
`}followSessionChip(){if(
|
|
5492
|
+
`}followSessionChip(){if($k(this.mainView)===`conversation`&&this.onShowConversation!==void 0){this.onShowConversation();return}this.openSessions()}openSessions(){if(this.onQuickSwitch!==void 0){this.onQuickSwitch();return}this.onOpenSection?.(`sessions`)}renderQuickSwitchButton(){return this.onQuickSwitch===void 0?null:g`
|
|
5493
5493
|
<button type="button" class="context-action-button" title="Sessions" aria-label="Open sessions" @click=${e=>{e.stopPropagation(),this.onQuickSwitch?.()}}>
|
|
5494
5494
|
<svg class="context-action-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
5495
5495
|
<path d="M4 6h16M4 12h16M4 18h10"></path>
|
|
@@ -5553,6 +5553,14 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5553
5553
|
.context-bar.has-context-actions-double .context-items { padding-right: 102px; scroll-padding-inline: 8px 102px; }
|
|
5554
5554
|
.context-item { flex: 0 0 auto; min-width: 0; display: flex; }
|
|
5555
5555
|
.context-actions { position: absolute; top: 6px; right: 0; bottom: 6px; z-index: 3; display: flex; align-items: center; gap: var(--pi-space-3); padding: 0 var(--pi-space-4); background: var(--pi-bg); pointer-events: none; }
|
|
5556
|
+
/* Measured at 393px the bar was exactly full: 60px of location, 163px of
|
|
5557
|
+
session name - both already cut short - 34px of rename, and 136px of
|
|
5558
|
+
actions. The actions keep their size whatever the screen does, so every
|
|
5559
|
+
pixel they take comes out of the words that say where you are. */
|
|
5560
|
+
@media (max-width: 430px) {
|
|
5561
|
+
.context-actions { gap: var(--pi-space-2); }
|
|
5562
|
+
.context-actions .context-action-button { width: 32px; height: 32px; min-width: 32px; min-height: 32px; }
|
|
5563
|
+
}
|
|
5556
5564
|
.context-actions::before { content: ""; position: absolute; top: 0; bottom: 0; left: -24px; z-index: 0; width: 24px; background: linear-gradient(90deg, transparent, var(--pi-bg)); pointer-events: none; }
|
|
5557
5565
|
app-refresh-control, .context-action-button { position: relative; z-index: 1; pointer-events: auto; }
|
|
5558
5566
|
.context-action-button { box-sizing: border-box; width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--pi-border); border-radius: var(--pi-radius-pill); background: var(--pi-surface); color: var(--pi-text); padding: 0; line-height: 1; }
|
|
@@ -5626,7 +5634,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5626
5634
|
The row scrolls, so the extra width costs the others nothing. */
|
|
5627
5635
|
.context-value.session-value { max-width: min(70vw, 32ch); }
|
|
5628
5636
|
button { cursor: pointer; }
|
|
5629
|
-
`}};H([b({attribute:!1})],Z.prototype,`machines`,void 0),H([b({attribute:!1})],Z.prototype,`machine`,void 0),H([b({attribute:!1})],Z.prototype,`project`,void 0),H([b({attribute:!1})],Z.prototype,`workspace`,void 0),H([b({attribute:!1})],Z.prototype,`session`,void 0),H([b({attribute:!1})],Z.prototype,`refreshControl`,void 0),H([b({attribute:!1})],Z.prototype,`onOpenSection`,void 0),H([b({attribute:!1})],Z.prototype,`onShowActions`,void 0),H([b({attribute:!1})],Z.prototype,`onQuickSwitch`,void 0),H([b({attribute:!1})],Z.prototype,`mainView`,void 0),H([b({attribute:!1})],Z.prototype,`onShowConversation`,void 0),H([b({attribute:!1})],Z.prototype,`onOpenTools`,void 0),H([b({attribute:!1})],Z.prototype,`onRenameSession`,void 0),H([b({type:Boolean})],Z.prototype,`isWorking`,void 0),H([b({type:Boolean})],Z.prototype,`emphasizeSession`,void 0),H([S(`.context-items`)],Z.prototype,`contextItems`,void 0),H([x()],Z.prototype,`renamingSession`,void 0),H([x()],Z.prototype,`renameSeed`,void 0),H([x()],Z.prototype,`canScrollLeft`,void 0),H([x()],Z.prototype,`canScrollRight`,void 0),Z=H([y(`app-context-bar`)],Z);function
|
|
5637
|
+
`}};H([b({attribute:!1})],Z.prototype,`machines`,void 0),H([b({attribute:!1})],Z.prototype,`machine`,void 0),H([b({attribute:!1})],Z.prototype,`project`,void 0),H([b({attribute:!1})],Z.prototype,`workspace`,void 0),H([b({attribute:!1})],Z.prototype,`session`,void 0),H([b({attribute:!1})],Z.prototype,`refreshControl`,void 0),H([b({attribute:!1})],Z.prototype,`onOpenSection`,void 0),H([b({attribute:!1})],Z.prototype,`onShowActions`,void 0),H([b({attribute:!1})],Z.prototype,`onQuickSwitch`,void 0),H([b({attribute:!1})],Z.prototype,`mainView`,void 0),H([b({attribute:!1})],Z.prototype,`onShowConversation`,void 0),H([b({attribute:!1})],Z.prototype,`onOpenTools`,void 0),H([b({attribute:!1})],Z.prototype,`onRenameSession`,void 0),H([b({type:Boolean})],Z.prototype,`isWorking`,void 0),H([b({type:Boolean})],Z.prototype,`emphasizeSession`,void 0),H([S(`.context-items`)],Z.prototype,`contextItems`,void 0),H([x()],Z.prototype,`renamingSession`,void 0),H([x()],Z.prototype,`renameSeed`,void 0),H([x()],Z.prototype,`canScrollLeft`,void 0),H([x()],Z.prototype,`canScrollRight`,void 0),Z=H([y(`app-context-bar`)],Z);function eA(e){return e.length>0}function tA(e){return e===void 0?`No machine`:`${e.name}${e.kind===`remote`?` · remote`:``}`}function nA(e){return e===void 0?`No machine selected`:e.baseUrl??e.name}function rA(e){return e?.name??`No project`}function iA(e){return e===void 0?`No project selected`:`${e.name} — ${e.path}`}function aA(e){return e===void 0?`No workspace`:`${e.label}${e.isMain?` · main`:``}`}function oA(e){return e===void 0?`No workspace selected`:`${e.label}${e.isMain?` · main`:``} — ${e.path}`}function sA(e,t,n,r){let i=eA(r)&&n!==void 0?`${n.name} / `:``;return e===void 0?t===void 0?i===``?`No workspace`:i.replace(/ \/ $/u,``):`${i}${t.name}`:`${i}${e.isMain&&t!==void 0?t.name:e.label}`}function cA(e,t){return e===void 0?t===void 0?`No workspace selected`:t.path:e.path}function lA(e){let t=e?.name?.trim(),n=e?.firstMessage.trim();return t!==void 0&&t!==``?t:n!==void 0&&n!==``?n:e===void 0?`No session`:xS(e.id)}function uA(e){return e===void 0?`No session selected`:e.path}var dA=class extends v{constructor(...e){super(...e),this.tabs=[]}render(){return g`
|
|
5630
5638
|
<modal-surface .onClose=${()=>this.onClose?.()} .label=${`Views`} .initialFocus=${`button`}>
|
|
5631
5639
|
<header><h2>Go to</h2></header>
|
|
5632
5640
|
<div class="body">
|
|
@@ -5665,7 +5673,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5665
5673
|
.tool-badge { min-width: 20px; border-radius: var(--pi-radius-pill); background: var(--pi-surface-hover); color: var(--pi-text-secondary); padding: 1px var(--pi-space-4); font-size: var(--pi-text-xs); text-align: center; }
|
|
5666
5674
|
.tool-badge.unread { background: var(--pi-selection-bg); color: var(--pi-accent); }
|
|
5667
5675
|
.tool-check { color: var(--pi-accent); }
|
|
5668
|
-
`}};H([b({attribute:!1})],
|
|
5676
|
+
`}};H([b({attribute:!1})],dA.prototype,`tabs`,void 0),H([b({attribute:!1})],dA.prototype,`selectedView`,void 0),H([b({attribute:!1})],dA.prototype,`onSelect`,void 0),H([b({attribute:!1})],dA.prototype,`onClose`,void 0),dA=H([y(`app-mobile-tool-sheet`)],dA);var fA=`PI WEB`;function pA(e){let t=e?.label.trim();if(!(t===void 0||t===``))return t.split(`/`).filter(e=>e!==``).pop()??t}function mA(e){if(e.mainView===`chat`&&e.selectedSession!==void 0){let t=SS(e.selectedSession).trim();if(t!==``)return t}let t=pA(e.selectedWorkspace);if(t!==void 0)return t;let n=e.selectedProject?.name.trim();if(n!==void 0&&n!==``)return n;let r=e.selectedMachine;if(r!==void 0&&r.kind!==`local`){let e=r.name.trim();if(e!==``)return e}return fA}function hA(e,t=40){let n=mA(e);return n.length<=t?n:`${n.slice(0,t-1).trimEnd()}…`}var gA=class extends v{constructor(...e){super(...e),this.machines=[]}render(){return g`
|
|
5669
5677
|
<nav aria-label="Current context">
|
|
5670
5678
|
${this.machines.length>0?this.renderStep(`machines`,`Machine`,this.selectedMachine?.name,this.onAddMachine,`Add machine`):_}
|
|
5671
5679
|
${this.renderStep(`projects`,`Project`,this.selectedProject?.name,this.onAddProject,`Add project`)}
|
|
@@ -5717,12 +5725,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5717
5725
|
.step.open .add { border-left-color: color-mix(in srgb, var(--pi-accent) 40%, var(--pi-border)); }
|
|
5718
5726
|
@media (pointer: coarse) { .add { width: 40px; } }
|
|
5719
5727
|
.add:hover { color: var(--pi-text); }
|
|
5720
|
-
`}};H([b({attribute:!1})],
|
|
5728
|
+
`}};H([b({attribute:!1})],gA.prototype,`machines`,void 0),H([b({attribute:!1})],gA.prototype,`selectedMachine`,void 0),H([b({attribute:!1})],gA.prototype,`selectedProject`,void 0),H([b({attribute:!1})],gA.prototype,`selectedWorkspace`,void 0),H([b({attribute:!1})],gA.prototype,`openSection`,void 0),H([b({attribute:!1})],gA.prototype,`onOpenSection`,void 0),H([b({attribute:!1})],gA.prototype,`onAddMachine`,void 0),H([b({attribute:!1})],gA.prototype,`onAddProject`,void 0),gA=H([y(`app-context-switcher`)],gA);var _A=class extends v{constructor(...e){super(...e),this.machines=[],this.statuses={},this.statusSnapshots={},this.open=!1,this.menuStyle=``,this.actionMenuStyle=``,this.onDocumentClick=e=>{e.composedPath().includes(this)||(this.open=!1,this.openActionsMachineId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this.onDocumentClick)}disconnectedCallback(){document.removeEventListener(`click`,this.onDocumentClick),super.disconnectedCallback()}updated(e){e.has(`machines`)&&this.open&&this.selectedMachine()===void 0&&(this.open=!1),e.has(`machines`)&&this.openActionsMachineId!==void 0&&!this.machines.some(e=>e.id===this.openActionsMachineId)&&(this.openActionsMachineId=void 0)}async focusSelectedOrFirst(){let e=this.switcherButton();return e!==null&&await this.openMenuAndFocusOption(e)}render(){let e=this.selectedMachine();if(e===void 0)return null;let t=vA(e,this.statuses),n=e.name;return g`
|
|
5721
5729
|
<div class="machine-switcher">
|
|
5722
5730
|
<button
|
|
5723
5731
|
type="button"
|
|
5724
5732
|
class="machine-switcher-button"
|
|
5725
|
-
title=${
|
|
5733
|
+
title=${bA(e)}
|
|
5726
5734
|
aria-label=${this.machineSwitcherAriaLabel(e)}
|
|
5727
5735
|
aria-expanded=${String(this.open)}
|
|
5728
5736
|
@click=${e=>{this.toggleMenu(e.currentTarget)}}
|
|
@@ -5733,7 +5741,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5733
5741
|
<span class="machine-switcher-kicker">Machine</span>
|
|
5734
5742
|
<span class="machine-switcher-label">${n}</span>
|
|
5735
5743
|
</span>
|
|
5736
|
-
<span class=${`machine-status ${t}`}>${
|
|
5744
|
+
<span class=${`machine-status ${t}`}>${yA(t)}</span>
|
|
5737
5745
|
<span class="machine-chevron" aria-hidden="true">▾</span>
|
|
5738
5746
|
</button>
|
|
5739
5747
|
${this.open?g`
|
|
@@ -5742,17 +5750,17 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5742
5750
|
</div>
|
|
5743
5751
|
`:null}
|
|
5744
5752
|
</div>
|
|
5745
|
-
`}renderMachineOption(e){let t=this.selected?.id===e.id,n=
|
|
5753
|
+
`}renderMachineOption(e){let t=this.selected?.id===e.id,n=vA(e,this.statuses),r=tS(e)&&this.onRemove!==void 0,i=this.openActionsMachineId===e.id;return g`
|
|
5746
5754
|
<div class=${`machine-option ${t?`selected`:``} ${r?``:`no-actions`}`}>
|
|
5747
5755
|
<button
|
|
5748
5756
|
type="button"
|
|
5749
5757
|
class="machine-option-main"
|
|
5750
|
-
title=${
|
|
5758
|
+
title=${bA(e)}
|
|
5751
5759
|
data-machine-id=${e.id}
|
|
5752
5760
|
@click=${()=>{this.select(e)}}
|
|
5753
5761
|
@keydown=${e=>{this.handleMachineOptionKeydown(e)}}
|
|
5754
5762
|
>
|
|
5755
|
-
<span class="machine-option-name">${this.renderActivity(e)}<span>${e.name}</span><span class=${`machine-option-status ${n}`}><span class="dot" aria-hidden="true"></span>${
|
|
5763
|
+
<span class="machine-option-name">${this.renderActivity(e)}<span>${e.name}</span><span class=${`machine-option-status ${n}`}><span class="dot" aria-hidden="true"></span>${yA(n)}</span></span>
|
|
5756
5764
|
<small>${e.kind===`local`?`Local Pi Web`:e.baseUrl??`Remote Pi Web`}</small>
|
|
5757
5765
|
</button>
|
|
5758
5766
|
${r?g`
|
|
@@ -5773,7 +5781,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5773
5781
|
</div>
|
|
5774
5782
|
`:null}
|
|
5775
5783
|
</div>
|
|
5776
|
-
`}renderActivity(e){let t=this.statusSnapshots[e.id]?.machine,n=
|
|
5784
|
+
`}renderActivity(e){let t=this.statusSnapshots[e.id]?.machine,n=vA(e,this.statuses),r=n===`offline`||n===`error`?void 0:Rx(t),i=zx(t)?`Unread sessions on this machine`:void 0;return Lx(r,r===`terminal`?`Machine terminal active`:`Machine active`,i)}selectedMachine(){return this.selected??this.machines.find(e=>e.id===`local`)??this.machines[0]}machineSwitcherAriaLabel(e){return`Machine: ${e.name}. Switch machine.`}switcherButton(){return this.renderRoot.querySelector(`.machine-switcher-button`)}handleSwitcherButtonKeydown(e){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),e.stopPropagation(),this.openMenuAndFocusOption(e.currentTarget);return}if(e.key===`ArrowRight`&&this.onFocusNextSection!==void 0){e.preventDefault(),e.stopPropagation(),this.onFocusNextSection();return}e.key===`Escape`&&this.onCancelKeyboardNavigation!==void 0&&(e.preventDefault(),e.stopPropagation(),this.onCancelKeyboardNavigation())}handleMachineOptionKeydown(e){if(e.key===`ArrowUp`){this.focusRelativeMachineOption(e.currentTarget,-1,e);return}if(e.key===`ArrowDown`){this.focusRelativeMachineOption(e.currentTarget,1,e);return}if(e.key===`Home`){this.focusIndexedMachineOption(0,e);return}if(e.key===`End`){this.focusIndexedMachineOption(-1,e);return}if(e.key===`ArrowRight`&&this.onFocusNextSection!==void 0){e.preventDefault(),e.stopPropagation(),this.open=!1,this.onFocusNextSection();return}(e.key===`ArrowLeft`||e.key===`Escape`)&&(e.preventDefault(),e.stopPropagation(),this.open=!1,this.updateComplete.then(()=>{this.focusSwitcherButton()}))}toggleMenu(e){this.menuStyle=xA(e),this.open=!this.open,this.openActionsMachineId=void 0}focusSwitcherButton(){let e=this.switcherButton();return e===null?!1:(e.focus(),!0)}async openMenuAndFocusOption(e){return this.menuStyle=xA(e),this.open=!0,this.openActionsMachineId=void 0,await this.updateComplete,this.focusSelectedMachineOption()}focusSelectedMachineOption(){let e=this.renderRoot.querySelector(`.machine-option.selected .machine-option-main`),t=this.machineOptionButtons()[0],n=e??t;return n===void 0?!1:(n.focus(),n.scrollIntoView({block:`nearest`}),!0)}focusRelativeMachineOption(e,t,n){n.preventDefault(),n.stopPropagation();let r=this.machineOptionButtons();if(r.length===0||!(e instanceof HTMLElement))return;let i=r.indexOf(e);i<0||this.focusMachineOptionAt(i+t)}focusIndexedMachineOption(e,t){t.preventDefault(),t.stopPropagation(),this.focusMachineOptionAt(e<0?this.machineOptionButtons().length-1:e)}focusMachineOptionAt(e){let t=this.machineOptionButtons(),n=t[Math.min(Math.max(e,0),t.length-1)];n?.focus(),n?.scrollIntoView({block:`nearest`})}machineOptionButtons(){return Array.from(this.renderRoot.querySelectorAll(`.machine-option-main`))}toggleActionsMenu(e,t){if(this.openActionsMachineId===e){this.openActionsMachineId=void 0;return}this.actionMenuStyle=Nx(t,{constrainTo:`viewport`}),this.openActionsMachineId=e}select(e){this.open=!1,this.openActionsMachineId=void 0,this.onSelect?.(e)}removeMachine(e){this.open=!1,this.openActionsMachineId=void 0,this.onRemove?.(e)}static{this.styles=h`
|
|
5777
5785
|
:host { min-width: 0; display: block; }
|
|
5778
5786
|
/* A display rule on :host outranks the HTML hidden attribute, so an element
|
|
5779
5787
|
rendered with the hidden attribute stays on screen unless this says so.
|
|
@@ -5825,7 +5833,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5825
5833
|
.machine-option-actions-panel button:hover, .machine-option-actions-panel button:focus-visible { background: var(--pi-selection-bg); }
|
|
5826
5834
|
.machine-option-actions-panel button.danger:hover, .machine-option-actions-panel button.danger:focus-visible { background: color-mix(in srgb, var(--pi-danger) 14%, transparent); }
|
|
5827
5835
|
@keyframes pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
|
|
5828
|
-
`}};H([b({attribute:!1})],
|
|
5836
|
+
`}};H([b({attribute:!1})],_A.prototype,`machines`,void 0),H([b({attribute:!1})],_A.prototype,`selected`,void 0),H([b({attribute:!1})],_A.prototype,`statuses`,void 0),H([b({attribute:!1})],_A.prototype,`statusSnapshots`,void 0),H([b({attribute:!1})],_A.prototype,`onSelect`,void 0),H([b({attribute:!1})],_A.prototype,`onRemove`,void 0),H([b({attribute:!1})],_A.prototype,`onFocusNextSection`,void 0),H([b({attribute:!1})],_A.prototype,`onCancelKeyboardNavigation`,void 0),H([x()],_A.prototype,`open`,void 0),H([x()],_A.prototype,`menuStyle`,void 0),H([x()],_A.prototype,`openActionsMachineId`,void 0),H([x()],_A.prototype,`actionMenuStyle`,void 0),_A=H([y(`machine-switcher`)],_A);function vA(e,t){return t[e.id]?.status??e.status??`unknown`}function yA(e){return e===`online`?`online`:e===`offline`?`offline`:e===`error`?`error`:`unknown`}function bA(e){return e.baseUrl??e.name}function xA(e){if(typeof HTMLElement>`u`||typeof window>`u`||!(e instanceof HTMLElement))return``;let t=e.getBoundingClientRect(),n=Math.min(280,Math.max(0,window.innerWidth-16)),r=Math.min(Math.max(8,t.left),Math.max(8,window.innerWidth-8-n)),i=Math.max(0,window.innerHeight-t.bottom-8);return[`top: ${SA(t.bottom)};`,`left: ${SA(r)};`,`width: ${SA(n)};`,`max-height: ${SA(i)};`].join(` `)}function SA(e){return`${String(Math.round(e))}px`}var Q=class extends v{constructor(...e){super(...e),this.machines=[],this.machineStatuses={},this.machineStatusSnapshots={},this.projects=[],this.workspaces=[],this.sessions=[],this.sessionActivities={},this.sessionStatuses={},this.sendingPrompts={},this.unreadSessionIds=new Set,this.deletingWorkspaceIds=[],this.workspaceLabelItems=()=>[],this.collapsible=!1,this.compact=!1,this.machinesCollapsed=!1,this.projectsCollapsed=!1,this.workspacesCollapsed=!1,this.sessionsCollapsed=!1,this.startingSessionCount=0,this.canStartSession=!1,this.goals=[],this.goalsLoading=!1}async focusSection(e){switch(await this.updateComplete,e){case`machines`:return await this.focusNavigableSection(this.compact?this.machineList:this.machineSwitcher);case`projects`:return await this.focusNavigableSection(this.projectList);case`workspaces`:return await this.focusNavigableSection(this.workspaceList);case`sessions`:return await this.focusNavigableSection(this.sessionList)}}headerName(){return mA({mainView:this.selectedSession===void 0?`navigation`:`chat`,selectedMachine:this.selectedMachine,selectedProject:this.selectedProject,selectedWorkspace:this.selectedWorkspace,selectedSession:this.selectedSession})}render(){if(this.compact)return this.renderCompact();let e=this.compactVisibleSection();return g`
|
|
5829
5837
|
<header>
|
|
5830
5838
|
<strong title=${this.headerName()}>${this.headerName()}</strong>
|
|
5831
5839
|
<div class="header-actions">
|
|
@@ -5851,7 +5859,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5851
5859
|
${e===`sessions`?this.renderGoalPanel():null}
|
|
5852
5860
|
`}renderCompact(){return g`
|
|
5853
5861
|
<div class="compact-shell">
|
|
5854
|
-
${
|
|
5862
|
+
${CA(this.machines)?g`
|
|
5855
5863
|
<machine-switcher
|
|
5856
5864
|
hidden
|
|
5857
5865
|
.machines=${this.machines}
|
|
@@ -5883,7 +5891,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5883
5891
|
${this.renderWorkspaceList(!1,e!==`workspaces`)}
|
|
5884
5892
|
${this.renderSessionList(!1,e!==`sessions`)}
|
|
5885
5893
|
${e===`sessions`?this.renderGoalPanel():null}
|
|
5886
|
-
`}openSection(e){e===`machines`?this.onToggleMachines?.():e===`projects`?this.onToggleProjects?.():e===`workspaces`?this.onToggleWorkspaces?.():this.onToggleSessions?.()}compactVisibleSection(){return
|
|
5894
|
+
`}openSection(e){e===`machines`?this.onToggleMachines?.():e===`projects`?this.onToggleProjects?.():e===`workspaces`?this.onToggleWorkspaces?.():this.onToggleSessions?.()}compactVisibleSection(){return CA(this.machines)&&!this.machinesCollapsed?`machines`:this.projectsCollapsed?this.workspacesCollapsed?!this.sessionsCollapsed||this.selectedWorkspace!==void 0?`sessions`:this.selectedProject===void 0?`projects`:`workspaces`:`workspaces`:`projects`}renderMachineList(e,t=!1){return CA(this.machines)?g`
|
|
5887
5895
|
<machine-list
|
|
5888
5896
|
?hidden=${t}
|
|
5889
5897
|
.machines=${this.machines}
|
|
@@ -5982,7 +5990,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5982
5990
|
.onFocusNextSection=${()=>{this.focusNextFrom(`sessions`)}}
|
|
5983
5991
|
.onCancelKeyboardNavigation=${()=>{this.cancelKeyboardNavigation()}}
|
|
5984
5992
|
></session-list>
|
|
5985
|
-
`}selectedMachineStatusSnapshot(){return this.machineStatusSnapshots[L({selectedMachine:this.selectedMachine})]}async focusNavigableSection(e){return e!==void 0&&await e.focusSelectedOrFirst()}runMaybeAsync(e){e?.()instanceof Promise}focusPreviousFrom(e){let t=
|
|
5993
|
+
`}selectedMachineStatusSnapshot(){return this.machineStatusSnapshots[L({selectedMachine:this.selectedMachine})]}async focusNavigableSection(e){return e!==void 0&&await e.focusSelectedOrFirst()}runMaybeAsync(e){e?.()instanceof Promise}focusPreviousFrom(e){let t=wA(e,this.machines);t!==void 0&&this.onFocusNavigationTarget?.(t)}focusNextFrom(e){this.onFocusNavigationTarget?.(TA(e,this.machines))}cancelKeyboardNavigation(){this.onCancelKeyboardNavigation?.()}static{this.styles=h`
|
|
5986
5994
|
|
|
5987
5995
|
/* Shell styles do not cross a shadow boundary, so the tap-highlight
|
|
5988
5996
|
suppression is repeated for components that define their own. */
|
|
@@ -6014,7 +6022,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6014
6022
|
task list cannot push the sessions it belongs to off-screen. */
|
|
6015
6023
|
goal-panel { flex: 0 1 auto; min-height: 0; max-height: var(--pi-nav-goals-max-height, 26vh); overflow: auto; border-top: 1px solid var(--pi-border-muted); }
|
|
6016
6024
|
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
6017
|
-
`}};H([b({attribute:!1})],Q.prototype,`machines`,void 0),H([b({attribute:!1})],Q.prototype,`selectedMachine`,void 0),H([b({attribute:!1})],Q.prototype,`machineStatuses`,void 0),H([b({attribute:!1})],Q.prototype,`machineStatusSnapshots`,void 0),H([b({attribute:!1})],Q.prototype,`projects`,void 0),H([b({attribute:!1})],Q.prototype,`selectedProject`,void 0),H([b({attribute:!1})],Q.prototype,`workspaces`,void 0),H([b({attribute:!1})],Q.prototype,`selectedWorkspace`,void 0),H([b({attribute:!1})],Q.prototype,`sessions`,void 0),H([b({attribute:!1})],Q.prototype,`selectedSession`,void 0),H([b({attribute:!1})],Q.prototype,`sessionActivities`,void 0),H([b({attribute:!1})],Q.prototype,`sessionStatuses`,void 0),H([b({attribute:!1})],Q.prototype,`sendingPrompts`,void 0),H([b({attribute:!1})],Q.prototype,`unreadSessionIds`,void 0),H([b({attribute:!1})],Q.prototype,`deletingWorkspaceIds`,void 0),H([b({attribute:!1})],Q.prototype,`workspaceLabelItems`,void 0),H([b({attribute:!1})],Q.prototype,`refreshControl`,void 0),H([b({type:Boolean,reflect:!0})],Q.prototype,`collapsible`,void 0),H([b({type:Boolean,reflect:!0})],Q.prototype,`compact`,void 0),H([b({type:Boolean})],Q.prototype,`machinesCollapsed`,void 0),H([b({type:Boolean})],Q.prototype,`projectsCollapsed`,void 0),H([b({type:Boolean})],Q.prototype,`workspacesCollapsed`,void 0),H([b({type:Boolean})],Q.prototype,`sessionsCollapsed`,void 0),H([b({type:Number})],Q.prototype,`startingSessionCount`,void 0),H([b({type:Boolean})],Q.prototype,`canStartSession`,void 0),H([b({attribute:!1})],Q.prototype,`onShowActions`,void 0),H([b({attribute:!1})],Q.prototype,`onOpenSettings`,void 0),H([b({attribute:!1})],Q.prototype,`onAddMachine`,void 0),H([b({attribute:!1})],Q.prototype,`onOpenSessionTree`,void 0),H([b({attribute:!1})],Q.prototype,`onRefreshMachine`,void 0),H([b({attribute:!1})],Q.prototype,`onRenameMachine`,void 0),H([b({attribute:!1})],Q.prototype,`onOpenMachine`,void 0),H([b({attribute:!1})],Q.prototype,`onQuickSwitch`,void 0),H([b({attribute:!1})],Q.prototype,`onAddProject`,void 0),H([b({attribute:!1})],Q.prototype,`onToggleMachines`,void 0),H([b({attribute:!1})],Q.prototype,`onToggleProjects`,void 0),H([b({attribute:!1})],Q.prototype,`onToggleWorkspaces`,void 0),H([b({attribute:!1})],Q.prototype,`onToggleSessions`,void 0),H([b({attribute:!1})],Q.prototype,`onSelectProject`,void 0),H([b({attribute:!1})],Q.prototype,`onCloseProject`,void 0),H([b({attribute:!1})],Q.prototype,`onSelectWorkspace`,void 0),H([b({attribute:!1})],Q.prototype,`onDeleteWorkspace`,void 0),H([b({attribute:!1})],Q.prototype,`onStartSession`,void 0),H([b({attribute:!1})],Q.prototype,`onSelectSession`,void 0),H([b({attribute:!1})],Q.prototype,`onArchiveSession`,void 0),H([b({attribute:!1})],Q.prototype,`onArchiveSessionWithDescendants`,void 0),H([b({attribute:!1})],Q.prototype,`onArchiveSessions`,void 0),H([b({attribute:!1})],Q.prototype,`onRestoreSession`,void 0),H([b({attribute:!1})],Q.prototype,`onDeleteCachedNewSession`,void 0),H([b({attribute:!1})],Q.prototype,`onDeleteArchivedSession`,void 0),H([b({attribute:!1})],Q.prototype,`onDeleteArchivedSessions`,void 0),H([b({attribute:!1})],Q.prototype,`onDetachParentSession`,void 0),H([b({attribute:!1})],Q.prototype,`onRenameSession`,void 0),H([b({attribute:!1})],Q.prototype,`goals`,void 0),H([b({type:Boolean})],Q.prototype,`goalsLoading`,void 0),H([b({attribute:!1})],Q.prototype,`onRefreshGoals`,void 0),H([b({attribute:!1})],Q.prototype,`onArchiveGoal`,void 0),H([b({attribute:!1})],Q.prototype,`onRunGoalCommand`,void 0),H([b({attribute:!1})],Q.prototype,`onMarkSessionRead`,void 0),H([b({attribute:!1})],Q.prototype,`onMarkSessionsRead`,void 0),H([b({attribute:!1})],Q.prototype,`onReloadSession`,void 0),H([b({attribute:!1})],Q.prototype,`onCleanupSessions`,void 0),H([b({attribute:!1})],Q.prototype,`onArchivedCollapsed`,void 0),H([b({attribute:!1})],Q.prototype,`onSelectMachine`,void 0),H([b({attribute:!1})],Q.prototype,`onRemoveMachine`,void 0),H([b({attribute:!1})],Q.prototype,`onFocusNavigationTarget`,void 0),H([b({attribute:!1})],Q.prototype,`onCancelKeyboardNavigation`,void 0),H([S(`machine-list`)],Q.prototype,`machineList`,void 0),H([S(`machine-switcher`)],Q.prototype,`machineSwitcher`,void 0),H([S(`project-list`)],Q.prototype,`projectList`,void 0),H([S(`workspace-list`)],Q.prototype,`workspaceList`,void 0),H([S(`session-list`)],Q.prototype,`sessionList`,void 0),Q=H([y(`app-navigation-panel`)],Q);function
|
|
6025
|
+
`}};H([b({attribute:!1})],Q.prototype,`machines`,void 0),H([b({attribute:!1})],Q.prototype,`selectedMachine`,void 0),H([b({attribute:!1})],Q.prototype,`machineStatuses`,void 0),H([b({attribute:!1})],Q.prototype,`machineStatusSnapshots`,void 0),H([b({attribute:!1})],Q.prototype,`projects`,void 0),H([b({attribute:!1})],Q.prototype,`selectedProject`,void 0),H([b({attribute:!1})],Q.prototype,`workspaces`,void 0),H([b({attribute:!1})],Q.prototype,`selectedWorkspace`,void 0),H([b({attribute:!1})],Q.prototype,`sessions`,void 0),H([b({attribute:!1})],Q.prototype,`selectedSession`,void 0),H([b({attribute:!1})],Q.prototype,`sessionActivities`,void 0),H([b({attribute:!1})],Q.prototype,`sessionStatuses`,void 0),H([b({attribute:!1})],Q.prototype,`sendingPrompts`,void 0),H([b({attribute:!1})],Q.prototype,`unreadSessionIds`,void 0),H([b({attribute:!1})],Q.prototype,`deletingWorkspaceIds`,void 0),H([b({attribute:!1})],Q.prototype,`workspaceLabelItems`,void 0),H([b({attribute:!1})],Q.prototype,`refreshControl`,void 0),H([b({type:Boolean,reflect:!0})],Q.prototype,`collapsible`,void 0),H([b({type:Boolean,reflect:!0})],Q.prototype,`compact`,void 0),H([b({type:Boolean})],Q.prototype,`machinesCollapsed`,void 0),H([b({type:Boolean})],Q.prototype,`projectsCollapsed`,void 0),H([b({type:Boolean})],Q.prototype,`workspacesCollapsed`,void 0),H([b({type:Boolean})],Q.prototype,`sessionsCollapsed`,void 0),H([b({type:Number})],Q.prototype,`startingSessionCount`,void 0),H([b({type:Boolean})],Q.prototype,`canStartSession`,void 0),H([b({attribute:!1})],Q.prototype,`onShowActions`,void 0),H([b({attribute:!1})],Q.prototype,`onOpenSettings`,void 0),H([b({attribute:!1})],Q.prototype,`onAddMachine`,void 0),H([b({attribute:!1})],Q.prototype,`onOpenSessionTree`,void 0),H([b({attribute:!1})],Q.prototype,`onRefreshMachine`,void 0),H([b({attribute:!1})],Q.prototype,`onRenameMachine`,void 0),H([b({attribute:!1})],Q.prototype,`onOpenMachine`,void 0),H([b({attribute:!1})],Q.prototype,`onQuickSwitch`,void 0),H([b({attribute:!1})],Q.prototype,`onAddProject`,void 0),H([b({attribute:!1})],Q.prototype,`onToggleMachines`,void 0),H([b({attribute:!1})],Q.prototype,`onToggleProjects`,void 0),H([b({attribute:!1})],Q.prototype,`onToggleWorkspaces`,void 0),H([b({attribute:!1})],Q.prototype,`onToggleSessions`,void 0),H([b({attribute:!1})],Q.prototype,`onSelectProject`,void 0),H([b({attribute:!1})],Q.prototype,`onCloseProject`,void 0),H([b({attribute:!1})],Q.prototype,`onSelectWorkspace`,void 0),H([b({attribute:!1})],Q.prototype,`onDeleteWorkspace`,void 0),H([b({attribute:!1})],Q.prototype,`onStartSession`,void 0),H([b({attribute:!1})],Q.prototype,`onSelectSession`,void 0),H([b({attribute:!1})],Q.prototype,`onArchiveSession`,void 0),H([b({attribute:!1})],Q.prototype,`onArchiveSessionWithDescendants`,void 0),H([b({attribute:!1})],Q.prototype,`onArchiveSessions`,void 0),H([b({attribute:!1})],Q.prototype,`onRestoreSession`,void 0),H([b({attribute:!1})],Q.prototype,`onDeleteCachedNewSession`,void 0),H([b({attribute:!1})],Q.prototype,`onDeleteArchivedSession`,void 0),H([b({attribute:!1})],Q.prototype,`onDeleteArchivedSessions`,void 0),H([b({attribute:!1})],Q.prototype,`onDetachParentSession`,void 0),H([b({attribute:!1})],Q.prototype,`onRenameSession`,void 0),H([b({attribute:!1})],Q.prototype,`goals`,void 0),H([b({type:Boolean})],Q.prototype,`goalsLoading`,void 0),H([b({attribute:!1})],Q.prototype,`onRefreshGoals`,void 0),H([b({attribute:!1})],Q.prototype,`onArchiveGoal`,void 0),H([b({attribute:!1})],Q.prototype,`onRunGoalCommand`,void 0),H([b({attribute:!1})],Q.prototype,`onMarkSessionRead`,void 0),H([b({attribute:!1})],Q.prototype,`onMarkSessionsRead`,void 0),H([b({attribute:!1})],Q.prototype,`onReloadSession`,void 0),H([b({attribute:!1})],Q.prototype,`onCleanupSessions`,void 0),H([b({attribute:!1})],Q.prototype,`onArchivedCollapsed`,void 0),H([b({attribute:!1})],Q.prototype,`onSelectMachine`,void 0),H([b({attribute:!1})],Q.prototype,`onRemoveMachine`,void 0),H([b({attribute:!1})],Q.prototype,`onFocusNavigationTarget`,void 0),H([b({attribute:!1})],Q.prototype,`onCancelKeyboardNavigation`,void 0),H([S(`machine-list`)],Q.prototype,`machineList`,void 0),H([S(`machine-switcher`)],Q.prototype,`machineSwitcher`,void 0),H([S(`project-list`)],Q.prototype,`projectList`,void 0),H([S(`workspace-list`)],Q.prototype,`workspaceList`,void 0),H([S(`session-list`)],Q.prototype,`sessionList`,void 0),Q=H([y(`app-navigation-panel`)],Q);function CA(e){return e.length>0}function wA(e,t){let n=EA(t);return n[n.indexOf(e)-1]}function TA(e,t){let n=EA(t);return n[n.indexOf(e)+1]??`chat`}function EA(e){return Mb.filter(t=>t!==`machines`||CA(e))}var DA=new Set([`ArrowLeft`,`ArrowRight`,`Home`,`End`]),OA=420,kA=4,AA=class extends v{constructor(...e){super(...e),this.side=`navigation`,this.collapsed=!1,this.resizable=!1,this.controls=``,this.resizeLabel=`Resize panel`,this.expandLabel=`Expand panel`,this.collapseLabel=`Collapse panel`,this.lastTapAt=0}disconnectedCallback(){this.finishActiveResize(),super.disconnectedCallback()}render(){let e=this.collapsed?this.expandLabel:this.collapseLabel;return g`
|
|
6018
6026
|
${this.renderResizeHandle()}
|
|
6019
6027
|
<button
|
|
6020
6028
|
type="button"
|
|
@@ -6044,7 +6052,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6044
6052
|
@dblclick=${e=>{this.onResizeDoubleClick(e)}}
|
|
6045
6053
|
@keydown=${e=>{this.onResizeKeyDown(e)}}
|
|
6046
6054
|
></div>
|
|
6047
|
-
`}resizeAriaValueNow(){return this.panelWidth===void 0?_:String(Math.round(this.panelWidth))}renderIcon(){return g`<svg class="edge-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d=${this.iconDirection()===`left`?`M15 18l-6-6 6-6`:`M9 18l6-6-6-6`}/></svg>`}iconDirection(){return this.side===`navigation`?this.collapsed?`right`:`left`:this.collapsed?`left`:`right`}onResizePointerDown(e){if(!this.resizable||e.button!==0)return;let t=e.currentTarget;if(!(t instanceof HTMLElement))return;let n=this.resizeStartWidth();n!==void 0&&(e.preventDefault(),e.stopPropagation(),t.setPointerCapture(e.pointerId),this.activeResize={pointerId:e.pointerId,startClientX:e.clientX,startWidth:n,handle:t,moved:!1},this.toggleAttribute(`resizing`,!0))}onResizePointerMove(e){let t=this.activeResize;t?.pointerId===e.pointerId&&(e.preventDefault(),!(Math.abs(e.clientX-t.startClientX)<=
|
|
6055
|
+
`}resizeAriaValueNow(){return this.panelWidth===void 0?_:String(Math.round(this.panelWidth))}renderIcon(){return g`<svg class="edge-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d=${this.iconDirection()===`left`?`M15 18l-6-6 6-6`:`M9 18l6-6-6-6`}/></svg>`}iconDirection(){return this.side===`navigation`?this.collapsed?`right`:`left`:this.collapsed?`left`:`right`}onResizePointerDown(e){if(!this.resizable||e.button!==0)return;let t=e.currentTarget;if(!(t instanceof HTMLElement))return;let n=this.resizeStartWidth();n!==void 0&&(e.preventDefault(),e.stopPropagation(),t.setPointerCapture(e.pointerId),this.activeResize={pointerId:e.pointerId,startClientX:e.clientX,startWidth:n,handle:t,moved:!1},this.toggleAttribute(`resizing`,!0))}onResizePointerMove(e){let t=this.activeResize;t?.pointerId===e.pointerId&&(e.preventDefault(),!(Math.abs(e.clientX-t.startClientX)<=kA)&&(t.moved=!0,this.commitPanelWidth(Jb(this.side,t.startWidth,t.startClientX,e.clientX,this.resizeConstraints()))))}onResizePointerUp(e){let t=this.activeResize;t?.pointerId===e.pointerId&&(e.preventDefault(),this.finishActiveResize(),t.moved||this.registerTapForReset())}onResizePointerCancel(e){this.activeResize?.pointerId===e.pointerId&&this.finishActiveResize()}onResizeDoubleClick(e){e.preventDefault(),e.stopPropagation(),this.resetPanelSize()}onResizeKeyDown(e){if(!this.resizable||!DA.has(e.key))return;let t=this.resizeStartWidth();if(t===void 0)return;let n=Yb(this.side,t,e.key,{largeStep:e.shiftKey,constraints:this.resizeConstraints()});n!==void 0&&(e.preventDefault(),e.stopPropagation(),this.commitPanelWidth(n),this.onResizeEnd?.())}registerTapForReset(){let e=Date.now();if(e-this.lastTapAt<=OA){this.lastTapAt=0,this.resetPanelSize();return}this.lastTapAt=e}resetPanelSize(){this.finishActiveResize(),this.onReset?.()}resizeStartWidth(){let e=this.onResizeStart?.()??this.panelWidth;if(e!==void 0)return Xb(this.side,e,this.resizeConstraints())}commitPanelWidth(e){this.onResize?.(Xb(this.side,e,this.resizeConstraints()))}finishActiveResize(){let e=this.activeResize;if(e!==void 0){try{e.handle.releasePointerCapture(e.pointerId)}catch{}this.activeResize=void 0,this.toggleAttribute(`resizing`,!1),this.onResizeEnd?.()}}resizeConstraints(){let e=Kb(this.side);return{...e,minWidth:this.minWidth??e.minWidth,maxWidth:this.maxWidth??e.maxWidth}}static{this.styles=h`
|
|
6048
6056
|
:host { position: relative; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: visible; background: var(--pi-border-muted); z-index: 2; }
|
|
6049
6057
|
:host([side="navigation"]) { grid-column: 2; }
|
|
6050
6058
|
:host([side="workspace"]) { grid-column: 4; }
|
|
@@ -6071,7 +6079,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6071
6079
|
@media (max-width: 760px) {
|
|
6072
6080
|
:host([side="navigation"]) { display: none; }
|
|
6073
6081
|
}
|
|
6074
|
-
`}};H([b({reflect:!0})],
|
|
6082
|
+
`}};H([b({reflect:!0})],AA.prototype,`side`,void 0),H([b({type:Boolean,reflect:!0})],AA.prototype,`collapsed`,void 0),H([b({type:Boolean})],AA.prototype,`resizable`,void 0),H([b({type:Number})],AA.prototype,`panelWidth`,void 0),H([b({type:Number})],AA.prototype,`minWidth`,void 0),H([b({type:Number})],AA.prototype,`maxWidth`,void 0),H([b()],AA.prototype,`controls`,void 0),H([b()],AA.prototype,`resizeLabel`,void 0),H([b()],AA.prototype,`expandLabel`,void 0),H([b()],AA.prototype,`collapseLabel`,void 0),H([b({attribute:!1})],AA.prototype,`onToggle`,void 0),H([b({attribute:!1})],AA.prototype,`onResizeStart`,void 0),H([b({attribute:!1})],AA.prototype,`onResize`,void 0),H([b({attribute:!1})],AA.prototype,`onResizeEnd`,void 0),H([b({attribute:!1})],AA.prototype,`onReset`,void 0),AA=H([y(`app-panel-edge-control`)],AA);var jA=class extends v{constructor(...e){super(...e),this.onReloadClick=e=>{e.stopPropagation(),this.onReload?.()}}render(){let e=`Full page reload`;return g`
|
|
6075
6083
|
<button
|
|
6076
6084
|
class="app-refresh-button"
|
|
6077
6085
|
title=${e}
|
|
@@ -6090,12 +6098,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6090
6098
|
:host, :host * { -webkit-user-select: none; user-select: none; }
|
|
6091
6099
|
.app-refresh-button { box-sizing: border-box; width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--pi-border); border-radius: 999px; background: var(--pi-surface); color: var(--pi-text); padding: 0; line-height: 1; cursor: pointer; touch-action: manipulation; -webkit-touch-callout: none; }
|
|
6092
6100
|
.app-refresh-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
|
6093
|
-
`}};H([b({attribute:!1})],
|
|
6101
|
+
`}};H([b({attribute:!1})],jA.prototype,`onReload`,void 0),jA=H([y(`app-refresh-control`)],jA);var MA=`pi-web.pinnedSessions`;function NA(e=IA()){if(e===void 0)return new Set;try{let t=e.getItem(MA);if(t===null||t===``)return new Set;let n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function PA(e,t=IA()){if(t!==void 0)try{t.setItem(MA,JSON.stringify([...e]))}catch{}}function FA(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function IA(){if(!(typeof window>`u`))try{return window.localStorage}catch{return}}function LA(e,t){if(e===``)return null;let n=BA(e);return g`<div class=${`error${n===void 0?``:` transient`}`} role=${n===void 0?`alert`:`status`}>
|
|
6094
6102
|
<span class="error-text">${n??e}</span>
|
|
6095
6103
|
<button type="button" class="error-dismiss" aria-label="Dismiss error" title="Dismiss error" @click=${()=>{t()}}>✕</button>
|
|
6096
|
-
</div>`}function
|
|
6097
|
-
${e.map(e=>g`<p class="deprecation-notice-text">${
|
|
6098
|
-
</div>`}var WA=900*1e3,GA=4e3,KA=15e3;function qA(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.addEventListener==`function`&&typeof t.removeEventListener==`function`}var JA=750,YA=[1e3,3e3,8e3,15e3,3e4],XA={capture:!0},ZA=`auto:on`,QA=`auto:off`,$A=`theme:`,ej=Oc(`core:workspace.files`),tj=Oc(`core:workspace.terminal`),nj=320,rj=2,ij=`(min-width: 1181px)`,$=class extends v{constructor(...e){super(...e),this.state=_c(),this.sessionUnread=new gh({onChange:e=>{L(this.state)===e&&(this.syncUnreadSessionIds(),this.syncSelectedSessionReadState())},onBackgroundError:(e,t,n)=>{console.warn(`Failed to ${e} session unread state for ${t}`,n)}}),this.interruptedSessionIds=new Set,this.unreadSessionIds=this.sessionUnread.unreadSessionIds(L(this.state),this.state.sessions),this.unreadConnected=!1,this.notifications=new Wp(()=>this.state,e=>{this.setState(e)},{onBackgroundError:(e,t)=>{console.warn(e,t)}}),this.sessions=new rp(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},new qf,{notifications:this.notifications,onSelectedSessionIdle:()=>{this.workspaces.refreshWorkspaceGoals()},onSelectedSessionReady:({machineId:e,session:t})=>{this.commitReadyChatAfterRender(e,t),this.refreshSelfUpdate()},replacePromptEditorText:async({machineId:e,sessionId:t,text:n})=>{await this.updateComplete,!(L(this.state)!==e||this.state.selectedSession?.id!==t)&&this.promptEditor?.replaceText(n)}}),this.machineStatus=new Xc(()=>this.state,e=>{this.setState(e)}),this.auth=new wc(()=>this.state,e=>{this.setState(e)},e=>{this.sessions.applySessionStatus(e)}),this.workspaces=new $p(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},this.sessions,new Xp),this.projects=new Qc(()=>this.state,e=>{this.setState(e)},this.workspaces),this.machines=new Kc(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},this.projects),this.piWebStatusController=new el(()=>this.state,e=>{this.setState(e)},{onRefreshError:(e,t)=>{console.warn(`Failed to refresh PI WEB status for ${e}`,t)}}),this.files=new Hc(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.keyboard=new Cm,this.realtime=new Of,this.machineRealtimeSockets=new Map,this.activeTerminalIds=new Set,this.machineNavigation=new am,this.terminalSelection=new vm,this.appShell=new Mt(this),this.browserResume=new Db({onResumeSignal:()=>{this.handleBrowserResumeSignal()},refreshAfterResume:()=>this.refreshAfterBrowserResume(),onRefreshError:e=>{console.warn(`Failed to refresh after browser resume`,e)}}),this.panelCollapse=new Bb(this),this.panelResize=new Gb(this),this.navigationSections=new zb(this,()=>this.state),this.systemLightThemeMedia=typeof window<`u`&&`matchMedia`in window?window.matchMedia(`(prefers-color-scheme: light)`):void 0,this.refreshingWorkspaceDeletionRuns=!1,this.handledWorkspaceDeletionRunIds=new Set,this.terminalCommandRunRuntimes=new Map,this.machineNavigationRestoreSeq=0,this.navigationSelectionSeq=0,this.routeRestoreSeq=0,this.routeRestoreDepth=0,this.remoteRouteRestoreAttempt=0,this.remoteRouteRestoreInProgress=!1,this.plugins=aj(),this.loadedMachinePluginIds=new Set,this.machinePluginLoadPromises=new Map,this.themePreference=Fh()??jh,this.uiScale=Zh()??1,this.activeThemeId=Ah,this.isRefreshingApp=!1,this.heldErrorBanner=null,this.lastScheduledError=``,this.quickSwitcherOpen=!1,this.composerCollapsed=!1,this.mobileToolSheetOpen=!1,this.quickSwitcherLoading=!1,this.quickSwitcherSessions=[],this.pinnedSessionIds=MA(),this.quickSwitcherWorkspaces=[],this.settingsSection=px(),this.fleetLoading=!1,this.fleetSectionShown=!1,this.shortcutConfig={},this.workspaceUploadDefaultFolder=Xs(void 0),this.sessionWarningVisibility=wh(),this.onPopState=()=>{if(this.modalLayerOpen()){yt(),this.closeModalLayer();return}this.currentRouteMatchesUrl()||this.withChatScrollTransition(async()=>{this.restoreSettingsRoute(),await this.restoreRoute(!1)})},this.onPageShow=()=>{this.sessionUnread.refreshAll(),this.appShell.repairViewportPosition(),this.retryPendingRemoteRouteRestoreSoon()},this.onBrowserOnline=()=>{this.realtime.reconnectNow(),this.sessions.reconnectSocketNow(),this.checkSocketLiveness()},this.onFocusIn=e=>{this.composerCollapsed=Zm(e.composedPath())},this.onFocusOut=e=>{let t=e.relatedTarget;t!==null&&(this.composerCollapsed=Zm(Qm(t)))},this.onDocumentVisibilityChange=()=>{this.updateSubagentPolling(),document.visibilityState===`visible`&&this.refreshSubagents()},this.onSystemLightThemeChange=()=>{this.themePreference.auto&&this.applyPreferredTheme(!1)},this.onKeyDown=e=>{this.isRenderedModalOpen()||this.keyboard.handle(e,this.getDefaultActions(),{shortcuts:this.shortcutConfig})&&(e.preventDefault(),e.stopPropagation())},this.selfUpdateCooldownUntil=0,this.onVisualViewportChange=()=>{let e=Ym(window.innerHeight,window.visualViewport??void 0);this.style.setProperty(`--pi-app-keyboard-inset`,`${String(Math.round(e))}px`)},this.handleSendPrompt=(e,t,n,r,i)=>this.sendPrompt(e,t,n,r,i),this.handleStopActiveWork=()=>{this.sessions.stopActiveWork().then(e=>{this.restoreToComposer(e)})},this.handleClearServerQueue=e=>{this.restoreToComposer(e),this.sessions.clearServerQueue()},this.handleOpenSubagentRun=e=>{this.sessions.openSubagentRunOutput(e)},this.handleOpenBackgroundTask=e=>{e.hasOutput&&this.sessions.openBackgroundTaskOutput(e)},this.handleCloseActivityOutput=()=>{this.sessions.closeActivityOutput()},this.handleOpenSubagentSession=e=>{this.openSubagent(e)},this.handleRecallQueuedMessage=e=>{this.sessions.recallQueuedMessage(e).then(t=>{t&&this.restoreToComposer([e])})},this.handleDismissWarning=e=>{this.sessions.dismissWarning(e)},this.handleSubmitAsk=(e,t)=>this.sessions.submitAsk(e,t),this.handleAnswerDialog=(e,t)=>this.sessions.answerDialog(e,t),this.handleCancelDialog=e=>this.sessions.cancelDialog(e),this.handleDismissClosedDialog=e=>{this.sessions.dismissClosedDialog(e)},this.handleDismissNotification=e=>{this.notifications.dismissNotification(e)},this.handleDismissAllNotifications=()=>{this.notifications.dismissAll()},this.handleToggleWarnings=()=>{let e=kh(this.sessionWarningVisibility);e!==this.sessionWarningVisibility&&(this.sessionWarningVisibility=e,this.requestUpdate())},this.handleResendMessage=e=>{this.promptEditor?.restorePrompt(e)},this.handleSelectModel=()=>{this.openModelDialog()},this.handleToggleModelEnabled=async(e,t,n)=>{let r=await this.sessions.setModelEnabled(e,t,n),i=this.state.modelDialog;r===void 0||i===void 0||this.setState({modelDialog:{...i,catalog:r,options:this.modelDialogOptions(r.filter(e=>e.enabled))}})},this.handleSelectThinking=()=>{this.openThinkingDialog()}}currentRouteMatchesUrl(){let e=this.state,t=new URL(window.location.href),n=e=>{let n=t.searchParams.get(e);return n===null||n===``?void 0:n},r=e.selectedMachine===void 0?void 0:e.selectedMachine.id;return n(`machine`)===(r===`local`?void 0:r)&&Ct({project:n(`project`),workspace:n(`workspace`),session:n(`session`),view:n(`view`)},{project:e.selectedProject?.id,workspace:e.selectedWorkspace?.id,session:e.selectedSession?.id,view:e.mainView},this.appShell.defaultRouteView({sessionId:e.selectedSession?.id}))}closeModalLayer(){if(this.mobileToolSheetOpen){this.mobileToolSheetOpen=!1;return}if(this.quickSwitcherOpen){this.quickSwitcherOpen=!1;return}let e=this.state;if(e.actionPaletteOpen){this.setState({actionPaletteOpen:!1});return}if(e.projectDialogOpen){this.setState({projectDialogOpen:!1});return}if(e.machineDialogOpen){this.setState({machineDialogOpen:!1});return}if(e.commandDialog!==void 0){this.sessions.cancelCommand();return}if(e.modelDialog!==void 0){this.setState({modelDialog:void 0});return}if(e.thinkingDialog!==void 0){this.setState({thinkingDialog:void 0});return}if(e.themeDialog!==void 0){this.setState({themeDialog:void 0});return}if(this.sessionCleanupDialog!==void 0){this.sessionCleanupDialog=void 0;return}}listenForFormFocus(e){let t=this.renderRoot;if(qA(t)){if(e===`add`){t.addEventListener(`focusin`,this.onFocusIn),t.addEventListener(`focusout`,this.onFocusOut);return}t.removeEventListener(`focusin`,this.onFocusIn),t.removeEventListener(`focusout`,this.onFocusOut)}}get routeRestoreInProgress(){return this.routeRestoreDepth>0}willUpdate(){this.toggleAttribute(`pwa-display-mode`,this.appShell.isPwaDisplayMode),this.syncSessionWarningVisibility()}updated(){this.committedChatIdentity=lj(this.state),this.syncSelectedSessionReadState(),this.syncFleetOnSettingsSection(),this.syncDocumentTitle()}syncDocumentTitle(){let e=this.state,t=mA({mainView:e.mainView,selectedMachine:e.selectedMachine,selectedProject:e.selectedProject,selectedWorkspace:e.selectedWorkspace,selectedSession:e.selectedSession});document.title!==t&&(document.title=t)}syncFleetOnSettingsSection(){let e=this.settingsSection===`machines`;e&&!this.fleetSectionShown&&this.refreshFleet(),this.fleetSectionShown=e}syncSessionWarningVisibility(){let e=this.state.selectedSession;this.sessionWarningVisibility=Eh(this.sessionWarningVisibility,e===void 0?void 0:Cc(L(this.state),e.id),this.state.status===void 0?void 0:this.state.status.warnings??[])}syncSelectedSessionReadState(){let e=this.state.selectedSession;if(e===void 0)return;let t=L(this.state);this.isSessionSeen(t,e)&&this.sessionUnread.acknowledge(t,e)}markSessionsRead(e){let t=L(this.state);for(let n of e)this.sessionUnread.acknowledge(t,n)}async commitReadyChatAfterRender(e,t){let n=cj(e,t);await this.updateComplete,!(!this.unreadConnected||lj(this.state)!==n)&&(this.readyChatIdentity=n,this.syncSelectedSessionReadState())}refreshInterruptedRuns(e){this.sessions.loadInterruptedRuns(e).then(e=>{this.interruptedSessionIds=e})}updateSubagentPolling(){let e=eh({hasSelectedSession:this.state.selectedSession!==void 0,documentVisible:document.visibilityState===`visible`});if(e&&this.subagentPollTimer===void 0){this.subagentPollTimer=window.setInterval(()=>{this.refreshSubagents()},GA);return}!e&&this.subagentPollTimer!==void 0&&(window.clearInterval(this.subagentPollTimer),this.subagentPollTimer=void 0)}openSubagent(e){let t=this.quickSwitcherSessions.find(t=>t.id===e.sessionId)??this.state.sessions.find(t=>t.id===e.sessionId);t!==void 0&&this.selectNavigationItem(`sessions`,`chat`,()=>this.sessions.selectSession(t))}async refreshSubagents(){let e=this.state.selectedSession;if(e!==void 0)try{let t=L(this.state),[n,r]=await Promise.all([ss.subsessions(e,t),ss.backgroundTasks(e,t).catch(()=>this.state.backgroundTasks)]);if(this.state.selectedSession?.id!==e.id||L(this.state)!==t)return;let i=!gj(n.subsessions,this.state.subagents),a=!_j(n.toolRuns,this.state.subagentRuns),o=!hj(r,this.state.backgroundTasks);if(!i&&!a&&!o)return;this.setState({subagents:n.subsessions,subagentRuns:n.toolRuns,backgroundTasks:r})}catch{}}async refreshSelfUpdate(){if(!(Date.now()<this.selfUpdateCooldownUntil)){this.selfUpdateCooldownUntil=Date.now()+6e4;try{let e=await $o.status();this.setState({selfUpdate:e})}catch(e){console.warn(`Self-update status check failed`,e)}}}async applySelfUpdate(){if(!this.state.selfUpdateApplying){this.setState({selfUpdateApplying:!0});try{let e=await $o.apply();e.started||(this.setState({selfUpdateApplying:!1}),e.error!==void 0&&(this.setState({error:`Update failed: ${e.error}`}),this.scheduleTransientErrorDismissal(`Update failed: ${e.error}`)))}catch{this.setState({selfUpdateApplying:!1}),this.setState({error:`Update request failed`}),this.scheduleTransientErrorDismissal(`Update request failed`)}}}skipSelfUpdate(){let e=this.state.selfUpdate?.latest;if(e!==void 0){try{window.localStorage.setItem(`piWebSelfUpdateSkipped`,e)}catch{}this.setState({selfUpdate:void 0})}}renderSelfUpdateBanner(){let e=this.state.selfUpdate;if(e===void 0||!e.enabled||!e.available)return null;if(this.state.selfUpdateApplying)return g`
|
|
6104
|
+
</div>`}function RA(e){return BA(e)!==void 0}var zA=6e3;function BA(e){if(/session daemon\b.*\bunavailable: connect (enoent|econnrefused)/i.test(e)&&/sessiond\.sock/i.test(e))return`Reconnecting to the session daemon…`;if(/\boperation was aborted\b/i.test(e))return`Previous request was interrupted. Retry if the message did not finish.`;if(/remote machine request cancelled/i.test(e))return`Connection changed while the request was in flight. Retrying is usually enough.`;if(/failed to fetch|load failed|networkerror when attempting to fetch/i.test(e))return`Lost connection to PI WEB. Reconnecting…`}function VA(e,t){let n=[];for(let r of e){let e=t[r.id]?.deprecatedAgentInputs;e===void 0||e.length===0||n.push({machineId:r.id,machineName:r.name,inputs:e})}return n}function HA(e){let t=e.inputs.map(UA).join(`; `);return`${e.machineName}: ${t}. Support for deprecated agent configuration inputs will be removed in a future release.`}function UA(e){let t=e.source===`config`?`config key ${e.name}`:`environment variable ${e.name}`;return e.replacement===void 0?`${t} is deprecated and ignored; remove it, there is no replacement`:`${t} is deprecated; set ${e.replacement} instead`}function WA(e){return e.length===0?null:g`<div class="deprecation-notice" role="alert">
|
|
6105
|
+
${e.map(e=>g`<p class="deprecation-notice-text">${HA(e)}</p>`)}
|
|
6106
|
+
</div>`}var GA=900*1e3,KA=4e3,qA=15e3;function JA(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.addEventListener==`function`&&typeof t.removeEventListener==`function`}var YA=750,XA=[1e3,3e3,8e3,15e3,3e4],ZA={capture:!0},QA=`auto:on`,$A=`auto:off`,ej=`theme:`,tj=Oc(`core:workspace.files`),nj=Oc(`core:workspace.terminal`),rj=320,ij=2,aj=`(min-width: 1181px)`,$=class extends v{constructor(...e){super(...e),this.state=_c(),this.sessionUnread=new gh({onChange:e=>{L(this.state)===e&&(this.syncUnreadSessionIds(),this.syncSelectedSessionReadState())},onBackgroundError:(e,t,n)=>{console.warn(`Failed to ${e} session unread state for ${t}`,n)}}),this.interruptedSessionIds=new Set,this.unreadSessionIds=this.sessionUnread.unreadSessionIds(L(this.state),this.state.sessions),this.unreadConnected=!1,this.notifications=new Wp(()=>this.state,e=>{this.setState(e)},{onBackgroundError:(e,t)=>{console.warn(e,t)}}),this.sessions=new rp(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},new qf,{notifications:this.notifications,onSelectedSessionIdle:()=>{this.workspaces.refreshWorkspaceGoals()},onSelectedSessionReady:({machineId:e,session:t})=>{this.commitReadyChatAfterRender(e,t),this.refreshSelfUpdate()},replacePromptEditorText:async({machineId:e,sessionId:t,text:n})=>{await this.updateComplete,!(L(this.state)!==e||this.state.selectedSession?.id!==t)&&this.promptEditor?.replaceText(n)}}),this.machineStatus=new Xc(()=>this.state,e=>{this.setState(e)}),this.auth=new wc(()=>this.state,e=>{this.setState(e)},e=>{this.sessions.applySessionStatus(e)}),this.workspaces=new $p(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},this.sessions,new Xp),this.projects=new Qc(()=>this.state,e=>{this.setState(e)},this.workspaces),this.machines=new Kc(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},this.projects),this.piWebStatusController=new el(()=>this.state,e=>{this.setState(e)},{onRefreshError:(e,t)=>{console.warn(`Failed to refresh PI WEB status for ${e}`,t)}}),this.files=new Hc(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.keyboard=new Cm,this.realtime=new Of,this.machineRealtimeSockets=new Map,this.activeTerminalIds=new Set,this.machineNavigation=new am,this.terminalSelection=new vm,this.appShell=new Mt(this),this.browserResume=new Db({onResumeSignal:()=>{this.handleBrowserResumeSignal()},refreshAfterResume:()=>this.refreshAfterBrowserResume(),onRefreshError:e=>{console.warn(`Failed to refresh after browser resume`,e)}}),this.panelCollapse=new Bb(this),this.panelResize=new Gb(this),this.navigationSections=new zb(this,()=>this.state),this.systemLightThemeMedia=typeof window<`u`&&`matchMedia`in window?window.matchMedia(`(prefers-color-scheme: light)`):void 0,this.refreshingWorkspaceDeletionRuns=!1,this.handledWorkspaceDeletionRunIds=new Set,this.terminalCommandRunRuntimes=new Map,this.machineNavigationRestoreSeq=0,this.navigationSelectionSeq=0,this.routeRestoreSeq=0,this.routeRestoreDepth=0,this.remoteRouteRestoreAttempt=0,this.remoteRouteRestoreInProgress=!1,this.plugins=oj(),this.loadedMachinePluginIds=new Set,this.machinePluginLoadPromises=new Map,this.themePreference=Fh()??jh,this.uiScale=Zh()??1,this.activeThemeId=Ah,this.isRefreshingApp=!1,this.heldErrorBanner=null,this.lastScheduledError=``,this.quickSwitcherOpen=!1,this.composerCollapsed=!1,this.mobileToolSheetOpen=!1,this.quickSwitcherLoading=!1,this.quickSwitcherSessions=[],this.pinnedSessionIds=NA(),this.quickSwitcherWorkspaces=[],this.settingsSection=px(),this.fleetLoading=!1,this.fleetSectionShown=!1,this.shortcutConfig={},this.workspaceUploadDefaultFolder=Xs(void 0),this.sessionWarningVisibility=wh(),this.onPopState=()=>{if(this.modalLayerOpen()){yt(),this.closeModalLayer();return}this.currentRouteMatchesUrl()||this.withChatScrollTransition(async()=>{this.restoreSettingsRoute(),await this.restoreRoute(!1)})},this.onPageShow=()=>{this.sessionUnread.refreshAll(),this.appShell.repairViewportPosition(),this.retryPendingRemoteRouteRestoreSoon()},this.onBrowserOnline=()=>{this.realtime.reconnectNow(),this.sessions.reconnectSocketNow(),this.checkSocketLiveness()},this.onFocusIn=e=>{this.composerCollapsed=Zm(e.composedPath())},this.onFocusOut=e=>{let t=e.relatedTarget;t!==null&&(this.composerCollapsed=Zm(Qm(t)))},this.onDocumentVisibilityChange=()=>{this.updateSubagentPolling(),document.visibilityState===`visible`&&this.refreshSubagents()},this.onSystemLightThemeChange=()=>{this.themePreference.auto&&this.applyPreferredTheme(!1)},this.onKeyDown=e=>{this.isRenderedModalOpen()||this.keyboard.handle(e,this.getDefaultActions(),{shortcuts:this.shortcutConfig})&&(e.preventDefault(),e.stopPropagation())},this.selfUpdateCooldownUntil=0,this.onVisualViewportChange=()=>{let e=Ym(window.innerHeight,window.visualViewport??void 0);this.style.setProperty(`--pi-app-keyboard-inset`,`${String(Math.round(e))}px`)},this.handleSendPrompt=(e,t,n,r,i)=>this.sendPrompt(e,t,n,r,i),this.handleStopActiveWork=()=>{this.sessions.stopActiveWork().then(e=>{this.restoreToComposer(e)})},this.handleClearServerQueue=e=>{this.restoreToComposer(e),this.sessions.clearServerQueue()},this.handleOpenSubagentRun=e=>{this.sessions.openSubagentRunOutput(e)},this.handleOpenBackgroundTask=e=>{e.hasOutput&&this.sessions.openBackgroundTaskOutput(e)},this.handleCloseActivityOutput=()=>{this.sessions.closeActivityOutput()},this.handleOpenSubagentSession=e=>{this.openSubagent(e)},this.handleRecallQueuedMessage=e=>{this.sessions.recallQueuedMessage(e).then(t=>{t&&this.restoreToComposer([e])})},this.handleDismissWarning=e=>{this.sessions.dismissWarning(e)},this.handleSubmitAsk=(e,t)=>this.sessions.submitAsk(e,t),this.handleAnswerDialog=(e,t)=>this.sessions.answerDialog(e,t),this.handleCancelDialog=e=>this.sessions.cancelDialog(e),this.handleDismissClosedDialog=e=>{this.sessions.dismissClosedDialog(e)},this.handleDismissNotification=e=>{this.notifications.dismissNotification(e)},this.handleDismissAllNotifications=()=>{this.notifications.dismissAll()},this.handleToggleWarnings=()=>{let e=kh(this.sessionWarningVisibility);e!==this.sessionWarningVisibility&&(this.sessionWarningVisibility=e,this.requestUpdate())},this.handleResendMessage=e=>{this.promptEditor?.restorePrompt(e)},this.handleSelectModel=()=>{this.openModelDialog()},this.handleToggleModelEnabled=async(e,t,n)=>{let r=await this.sessions.setModelEnabled(e,t,n),i=this.state.modelDialog;r===void 0||i===void 0||this.setState({modelDialog:{...i,catalog:r,options:this.modelDialogOptions(r.filter(e=>e.enabled))}})},this.handleSelectThinking=()=>{this.openThinkingDialog()}}currentRouteMatchesUrl(){let e=this.state,t=new URL(window.location.href),n=e=>{let n=t.searchParams.get(e);return n===null||n===``?void 0:n},r=e.selectedMachine===void 0?void 0:e.selectedMachine.id;return n(`machine`)===(r===`local`?void 0:r)&&Ct({project:n(`project`),workspace:n(`workspace`),session:n(`session`),view:n(`view`)},{project:e.selectedProject?.id,workspace:e.selectedWorkspace?.id,session:e.selectedSession?.id,view:e.mainView},this.appShell.defaultRouteView({sessionId:e.selectedSession?.id}))}closeModalLayer(){if(this.mobileToolSheetOpen){this.mobileToolSheetOpen=!1;return}if(this.quickSwitcherOpen){this.quickSwitcherOpen=!1;return}let e=this.state;if(e.actionPaletteOpen){this.setState({actionPaletteOpen:!1});return}if(e.projectDialogOpen){this.setState({projectDialogOpen:!1});return}if(e.machineDialogOpen){this.setState({machineDialogOpen:!1});return}if(e.commandDialog!==void 0){this.sessions.cancelCommand();return}if(e.modelDialog!==void 0){this.setState({modelDialog:void 0});return}if(e.thinkingDialog!==void 0){this.setState({thinkingDialog:void 0});return}if(e.themeDialog!==void 0){this.setState({themeDialog:void 0});return}if(this.sessionCleanupDialog!==void 0){this.sessionCleanupDialog=void 0;return}}listenForFormFocus(e){let t=this.renderRoot;if(JA(t)){if(e===`add`){t.addEventListener(`focusin`,this.onFocusIn),t.addEventListener(`focusout`,this.onFocusOut);return}t.removeEventListener(`focusin`,this.onFocusIn),t.removeEventListener(`focusout`,this.onFocusOut)}}get routeRestoreInProgress(){return this.routeRestoreDepth>0}willUpdate(){this.toggleAttribute(`pwa-display-mode`,this.appShell.isPwaDisplayMode),this.syncSessionWarningVisibility()}updated(){this.committedChatIdentity=uj(this.state),this.syncSelectedSessionReadState(),this.syncFleetOnSettingsSection(),this.syncDocumentTitle()}syncDocumentTitle(){let e=this.state,t=hA({mainView:e.mainView,selectedMachine:e.selectedMachine,selectedProject:e.selectedProject,selectedWorkspace:e.selectedWorkspace,selectedSession:e.selectedSession});document.title!==t&&(document.title=t)}syncFleetOnSettingsSection(){let e=this.settingsSection===`machines`;e&&!this.fleetSectionShown&&this.refreshFleet(),this.fleetSectionShown=e}syncSessionWarningVisibility(){let e=this.state.selectedSession;this.sessionWarningVisibility=Eh(this.sessionWarningVisibility,e===void 0?void 0:Cc(L(this.state),e.id),this.state.status===void 0?void 0:this.state.status.warnings??[])}syncSelectedSessionReadState(){let e=this.state.selectedSession;if(e===void 0)return;let t=L(this.state);this.isSessionSeen(t,e)&&this.sessionUnread.acknowledge(t,e)}markSessionsRead(e){let t=L(this.state);for(let n of e)this.sessionUnread.acknowledge(t,n)}async commitReadyChatAfterRender(e,t){let n=lj(e,t);await this.updateComplete,!(!this.unreadConnected||uj(this.state)!==n)&&(this.readyChatIdentity=n,this.syncSelectedSessionReadState())}refreshInterruptedRuns(e){this.sessions.loadInterruptedRuns(e).then(e=>{this.interruptedSessionIds=e})}updateSubagentPolling(){let e=eh({hasSelectedSession:this.state.selectedSession!==void 0,documentVisible:document.visibilityState===`visible`});if(e&&this.subagentPollTimer===void 0){this.subagentPollTimer=window.setInterval(()=>{this.refreshSubagents()},KA);return}!e&&this.subagentPollTimer!==void 0&&(window.clearInterval(this.subagentPollTimer),this.subagentPollTimer=void 0)}openSubagent(e){let t=this.quickSwitcherSessions.find(t=>t.id===e.sessionId)??this.state.sessions.find(t=>t.id===e.sessionId);t!==void 0&&this.selectNavigationItem(`sessions`,`chat`,()=>this.sessions.selectSession(t))}async refreshSubagents(){let e=this.state.selectedSession;if(e!==void 0)try{let t=L(this.state),[n,r]=await Promise.all([ss.subsessions(e,t),ss.backgroundTasks(e,t).catch(()=>this.state.backgroundTasks)]);if(this.state.selectedSession?.id!==e.id||L(this.state)!==t)return;let i=!_j(n.subsessions,this.state.subagents),a=!vj(n.toolRuns,this.state.subagentRuns),o=!gj(r,this.state.backgroundTasks);if(!i&&!a&&!o)return;this.setState({subagents:n.subsessions,subagentRuns:n.toolRuns,backgroundTasks:r})}catch{}}async refreshSelfUpdate(){if(!(Date.now()<this.selfUpdateCooldownUntil)){this.selfUpdateCooldownUntil=Date.now()+6e4;try{let e=await $o.status();this.setState({selfUpdate:e})}catch(e){console.warn(`Self-update status check failed`,e)}}}async applySelfUpdate(){if(!this.state.selfUpdateApplying){this.setState({selfUpdateApplying:!0});try{let e=await $o.apply();e.started||(this.setState({selfUpdateApplying:!1}),e.error!==void 0&&(this.setState({error:`Update failed: ${e.error}`}),this.scheduleTransientErrorDismissal(`Update failed: ${e.error}`)))}catch{this.setState({selfUpdateApplying:!1}),this.setState({error:`Update request failed`}),this.scheduleTransientErrorDismissal(`Update request failed`)}}}skipSelfUpdate(){let e=this.state.selfUpdate?.latest;if(e!==void 0){try{window.localStorage.setItem(`piWebSelfUpdateSkipped`,e)}catch{}this.setState({selfUpdate:void 0})}}renderSelfUpdateBanner(){let e=this.state.selfUpdate;if(e===void 0||!e.enabled||!e.available)return null;if(this.state.selfUpdateApplying)return g`
|
|
6099
6107
|
<div class="self-update-banner applying" role="status" aria-live="polite">
|
|
6100
6108
|
<span class="state-dots"><span class="state-dot"></span><span class="state-dot"></span><span class="state-dot"></span></span>
|
|
6101
6109
|
<span>正在更新 pi-web(${e.current} → ${e.latest??`new`})… 重启后页面将自动重连。</span>
|
|
@@ -6104,7 +6112,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6104
6112
|
<span>pi-web 有新版本:${e.current} → ${e.latest??`new`}</span>
|
|
6105
6113
|
<button type="button" @click=${()=>{this.applySelfUpdate()}}>Update now</button>
|
|
6106
6114
|
<button type="button" class="skip" @click=${()=>{this.skipSelfUpdate()}}>Skip</button>
|
|
6107
|
-
</div>`}syncUnreadSessionIds(){let e=this.sessionUnread.unreadSessionIds(L(this.state),this.state.sessions);vj(e,this.unreadSessionIds)||(this.unreadSessionIds=e)}isSessionSeen(e,t){if(!this.unreadConnected)return!1;let n=cj(e,t);return lj(this.state)!==n||this.committedChatIdentity!==n||this.readyChatIdentity!==n||typeof document<`u`&&(document.visibilityState!==`visible`||typeof document.hasFocus==`function`&&!document.hasFocus())||this.isRenderedModalOpen()?!1:this.state.mainView===`chat`?!0:this.state.mainView===`navigation`?!this.appShell.isMobileNavigationLayout:this.isDesktopSideBySideLayout()}isRenderedModalOpen(){return Og(this.ownerDocument)}connectedCallback(){super.connectedCallback(),Yt(()=>{this.clearTransientError()}),this.unreadConnected=!0,window.visualViewport?.addEventListener(`resize`,this.onVisualViewportChange),window.visualViewport?.addEventListener(`scroll`,this.onVisualViewportChange),this.onVisualViewportChange(),window.addEventListener(`popstate`,this.onPopState),window.addEventListener(`pageshow`,this.onPageShow),this.browserResume.connect(),window.addEventListener(`keydown`,this.onKeyDown,XA),this.systemLightThemeMedia?.addEventListener(`change`,this.onSystemLightThemeChange),this.applyPreferredTheme(!1),$h(this.uiScale),this.connectRealtime(),this.syncSessionUnreadMachines(),this.piWebStatusTimer=window.setInterval(()=>{this.schedulePiWebStatusRefresh()},WA),document.addEventListener(`visibilitychange`,this.onDocumentVisibilityChange),this.listenForFormFocus(`add`),this.livenessTimer=window.setInterval(()=>{this.checkSocketLiveness()},KA),window.addEventListener(`online`,this.onBrowserOnline),this.updateSubagentPolling(),this.loadClientConfig(),this.refreshSelfUpdate(),this.ensureGatewayPluginsLoaded(),this.loadProjectsAndRestoreRoute().finally(()=>{this.schedulePiWebStatusRefresh()})}clearTransientError(){this.state.error===``||!LA(this.state.error)||(this.transientErrorTimer!==void 0&&(window.clearTimeout(this.transientErrorTimer),this.transientErrorTimer=void 0),this.setState({error:``}))}scheduleTransientErrorDismissal(e){this.transientErrorTimer!==void 0&&(window.clearTimeout(this.transientErrorTimer),this.transientErrorTimer=void 0),LA(e)&&(this.transientErrorTimer=window.setTimeout(()=>{this.transientErrorTimer=void 0,this.state.error===e&&this.setState({error:``})},RA))}disconnectedCallback(){Yt(void 0),this.transientErrorTimer!==void 0&&window.clearTimeout(this.transientErrorTimer),window.visualViewport?.removeEventListener(`resize`,this.onVisualViewportChange),window.visualViewport?.removeEventListener(`scroll`,this.onVisualViewportChange),this.unreadConnected=!1,this.committedChatIdentity=void 0,this.readyChatIdentity=void 0,this.sessionUnread.retainMachines(new Set),window.removeEventListener(`popstate`,this.onPopState),window.removeEventListener(`pageshow`,this.onPageShow),this.browserResume.disconnect(),window.removeEventListener(`keydown`,this.onKeyDown,XA),this.systemLightThemeMedia?.removeEventListener(`change`,this.onSystemLightThemeChange),this.keyboard.reset(),this.auth.dispose(),this.sessions.dispose(),this.notifications.dispose(),this.realtime.close(),this.closeMachineActivitySockets(),this.piWebStatusTimer!==void 0&&window.clearInterval(this.piWebStatusTimer),this.piWebStatusTimer=void 0,this.clearScheduledPiWebStatusRefresh(),this.workspaceDeletionPollTimer!==void 0&&window.clearInterval(this.workspaceDeletionPollTimer),this.workspaceDeletionPollTimer=void 0,this.subagentPollTimer!==void 0&&window.clearInterval(this.subagentPollTimer),this.subagentPollTimer=void 0,this.livenessTimer!==void 0&&window.clearInterval(this.livenessTimer),this.livenessTimer=void 0,window.removeEventListener(`online`,this.onBrowserOnline),document.removeEventListener(`visibilitychange`,this.onDocumentVisibilityChange),this.listenForFormFocus(`remove`),this.clearPendingRemoteRouteRestore(),super.disconnectedCallback()}setState(e){if(!mj(this.state,e))return;let t=this.state;this.state={...this.state,...e},lj(t)!==lj(this.state)&&(this.committedChatIdentity=void 0,this.readyChatIdentity=void 0),uj(t,this.state)&&this.syncSessionUnreadMachines(),this.syncUnreadSessionIds(),this.handleActivityTransition(t,this.state),this.handleWorkspaceChange(t,this.state),this.handleMachineChange(t,this.state),dj(t,this.state)&&this.syncMachineActivitySubscriptions(),this.notifications.syncEnvironment(t,this.state),t.selectedSession?.id!==this.state.selectedSession?.id&&this.updateSubagentPolling(),this.composerCollapsed&&this.state.pendingAsk===void 0&&this.state.pendingDialogs.length===0&&(this.composerCollapsed=!1)}async loadProjectsAndRestoreRoute(){this.restoreSettingsRoute();let e=sx();await this.machines.loadMachines(e.machineId);let t=this.routeForSelectedMachine(e),n=this.state.machineStatuses[t.machineId??`local`];t!==e&&this.replaceRouteAndClearWorkspaceQuery(t),await this.projects.loadProjects(),await this.withChatScrollTransition(()=>this.restoreRouteFor(t,!1)),this.shouldDeferRemoteRouteRestore(t,n)?this.deferRemoteRouteRestore(t):(this.clearPendingRemoteRouteRestore(),this.rememberCurrentMachineNavigation()),await this.refreshWorkspaceDeletionRuns()}checkSocketLiveness(){document.visibilityState===`visible`&&(this.realtime.checkLiveness(),this.sessions.checkSocketLiveness())}handleBrowserResumeSignal(){this.appShell.repairViewportPosition(),this.realtime.checkLiveness(),this.sessions.checkSocketLiveness(),this.schedulePiWebStatusRefresh(),this.retryPendingRemoteRouteRestoreSoon()}async refreshAfterBrowserResume(){await this.sessionUnread.refreshAll(),await Promise.all([this.sessions.refreshSelectedSession(),this.refreshMachineStatusSnapshots(),this.refreshWorkspaceDeletionRuns(),this.refreshCurrentWorkspaceSurface(),this.workspaces.refreshSelectedProjectTopology()])}schedulePiWebStatusRefresh(e=JA){this.clearScheduledPiWebStatusRefresh(),this.piWebStatusDeferredTimer=window.setTimeout(()=>{this.piWebStatusDeferredTimer=void 0,this.piWebStatusController.refresh()},e)}clearScheduledPiWebStatusRefresh(){this.piWebStatusDeferredTimer!==void 0&&(window.clearTimeout(this.piWebStatusDeferredTimer),this.piWebStatusDeferredTimer=void 0)}async refreshMachineStatusSnapshots(){await Promise.all(this.refreshableMachineIds().map(async e=>{try{await this.machineStatus.refresh(e)}catch(t){console.warn(`Failed to refresh machine status for ${e}`,t)}}))}refreshableMachineIds(){return this.state.machines.length===0?[L(this.state)]:this.state.machines.filter(e=>pj(e,this.state.machineStatuses[e.id])).map(e=>e.id)}async loadClientConfig(){try{this.applyClientConfig((await Xo.config()).effectiveConfig)}catch(e){console.warn(`Failed to load PI WEB config`,e)}}applyClientConfig(e){this.shortcutConfig=e.shortcuts??{},this.workspaceUploadDefaultFolder=Xs(e),this.speechToTextConfig=e.speechToText}async refreshAppData(){if(!this.isRefreshingApp){this.isRefreshingApp=!0;try{await Promise.all([this.sessions.refreshSelectedSession(),this.refreshMachineStatusSnapshots(),this.loadClientConfig(),this.refreshWorkspaceDeletionRuns(),this.refreshCurrentWorkspaceSurface(),this.workspaces.refreshSelectedProjectTopology()]),this.schedulePiWebStatusRefresh()}finally{this.isRefreshingApp=!1}}}async refreshCurrentWorkspaceSurface(){let e=this.state.selectedWorkspace,t=this.state.mainView!==`chat`&&this.state.mainView!==`navigation`?this.state.mainView:this.state.workspaceTool;t===`core:workspace.files`?await this.files.refreshFiles():t===`core:workspace.terminal`&&e!==void 0?await this.refreshActiveTerminals(e):await this.invalidateWorkspacePanels(t)}hardReloadApp(){window.location.reload()}async restoreRoute(e){await this.restoreRouteFor(sx(),e),this.rememberCurrentMachineNavigation()}async restoreRouteFor(e,t,n=this.readWorkspaceRouteSurface(e),r){let i=L(this.state),a=e.projectId===void 0||e.projectId===``?Sj():n,o=++this.routeRestoreSeq;this.routeRestoreDepth+=1,this.restoringRouteTerminalId=a.selectedTerminalId;try{if(await this.restoreRouteMachine(e,!1),await this.loadPluginsForSelectedMachine(),!this.isCurrentRouteRestore(o))return;let n=cx(e,e=>this.plugins.resolveWorkspacePanelRouteId(e,L(this.state)));if(this.setState({workspaceTool:n.tool??this.state.workspaceTool,mainView:this.resolveRestoredMainView(r)??n.view??this.defaultRouteView(n),selectedFilePath:a.selectedFilePath,selectedTerminalId:a.selectedTerminalId}),n.projectId===void 0||n.projectId===``){t&&this.updateUrl();return}if(this.routeMatchesCurrentSelection(n)){a.selectedTerminalId!==void 0&&this.rememberSelectedTerminal(a.selectedTerminalId),await this.refreshRestoredWorkspaceTool(n.tool,a.selectedFilePath),t&&this.updateUrl();return}let i=this.state.projects.find(e=>e.id===n.projectId);if(!i){this.setState({selectedFilePath:void 0,selectedTerminalId:void 0}),t&&this.updateUrl();return}if(await this.workspaces.selectProject(i,{workspaceId:n.workspaceId,sessionId:n.sessionId,updateUrl:!1}),!this.isCurrentRouteRestore(o))return;this.setState({selectedFilePath:a.selectedFilePath,selectedTerminalId:a.selectedTerminalId}),a.selectedTerminalId!==void 0&&this.rememberSelectedTerminal(a.selectedTerminalId),await this.refreshRestoredWorkspaceTool(n.tool,a.selectedFilePath),t&&this.updateUrl()}finally{this.routeRestoreDepth=Math.max(0,this.routeRestoreDepth-1),this.routeRestoreDepth===0&&(this.restoringRouteTerminalId=void 0),L(this.state)!==i&&this.schedulePiWebStatusRefresh()}}isCurrentRouteRestore(e){return e===this.routeRestoreSeq}readWorkspaceRouteSurface(e){return e.projectId===void 0||e.projectId===``?Sj():{selectedFilePath:Ac(ej,`file`),selectedTerminalId:Ac(tj,`terminal`)}}routeForSelectedMachine(e){let t=this.state.selectedMachine?.id??`local`;return(e.machineId??`local`)===t?e:{machineId:t,projectId:void 0,workspaceId:void 0,sessionId:void 0,tool:void 0,view:void 0}}replaceRouteAndClearWorkspaceQuery(e){ux(e,{replace:!0}),jc(ej,`file`,void 0,{replace:!0}),jc(tj,`terminal`,void 0,{replace:!0})}shouldDeferRemoteRouteRestore(e,t=this.state.machineStatuses[e.machineId??`local`]){let n=e.machineId??`local`,r=this.state.selectedMachine;return n===`local`||r?.id!==n||r.kind!==`remote`||t?.ok!==!1?!1:e.projectId===void 0||e.projectId===``?this.state.projects.length===0:this.state.selectedProject?.id!==e.projectId}deferRemoteRouteRestore(e){this.pendingRemoteRouteRestore=e,this.remoteRouteRestoreAttempt=0,this.setRemoteRouteRestoreMessage(e),this.schedulePendingRemoteRouteRestore()}retryPendingRemoteRouteRestoreSoon(){this.pendingRemoteRouteRestore!==void 0&&this.schedulePendingRemoteRouteRestore(0)}schedulePendingRemoteRouteRestore(e=wj(this.remoteRouteRestoreAttempt)){this.pendingRemoteRouteRestore!==void 0&&(this.clearPendingRemoteRouteRestoreTimer(),this.remoteRouteRestoreTimer=window.setTimeout(()=>{this.remoteRouteRestoreTimer=void 0,this.retryPendingRemoteRouteRestore()},e))}async retryPendingRemoteRouteRestore(){if(this.remoteRouteRestoreInProgress)return;let e=this.pendingRemoteRouteRestore;if(e!==void 0){if(!this.pendingRemoteRouteRestoreStillCurrent(e)){this.clearPendingRemoteRouteRestore();return}this.remoteRouteRestoreInProgress=!0;try{let t=e.machineId??`local`,n=await this.machines.refreshMachineHealth(t);if(!this.pendingRemoteRouteRestoreStillCurrent(e))return;if(n?.ok!==!0){this.scheduleNextRemoteRouteRestoreAttempt(e);return}if(await this.machines.refreshMachineRuntime(t),!this.pendingRemoteRouteRestoreStillCurrent(e)||(await this.projects.loadProjects(),!this.pendingRemoteRouteRestoreStillCurrent(e)))return;if(this.state.error!==``){this.scheduleNextRemoteRouteRestoreAttempt(e);return}if(await this.withChatScrollTransition(()=>this.restoreRouteFor(e,!1)),!this.pendingRemoteRouteRestoreStillCurrent(e))return;this.clearPendingRemoteRouteRestore(),this.rememberCurrentMachineNavigation(),await this.refreshWorkspaceDeletionRuns()}finally{this.remoteRouteRestoreInProgress=!1}}}scheduleNextRemoteRouteRestoreAttempt(e){if(this.remoteRouteRestoreAttempt+=1,this.remoteRouteRestoreAttempt>=YA.length){this.setRemoteRouteRestoreMessage(e,{exhausted:!0}),this.clearPendingRemoteRouteRestore();return}this.setRemoteRouteRestoreMessage(e),this.schedulePendingRemoteRouteRestore()}setRemoteRouteRestoreMessage(e,t={}){let n=e.machineId??`local`,r=this.state.machines.find(e=>e.id===n)?.name??this.state.selectedMachine?.name??`Remote machine`,i=this.state.machineStatuses[n]?.error??(this.state.error===``?void 0:this.state.error),a=t.exhausted===!0?`${r} is still unavailable.`:`${r} is unavailable; reconnecting…`;this.setState({error:`${a}${i===void 0?``:` ${i}`}`})}pendingRemoteRouteRestoreStillCurrent(e){let t=e.machineId??`local`;return t!==`local`&&this.pendingRemoteRouteRestore===e&&this.state.selectedMachine?.id===t&&this.state.machines.some(e=>e.id===t)}clearPendingRemoteRouteRestore(){this.clearPendingRemoteRouteRestoreTimer(),this.pendingRemoteRouteRestore=void 0,this.remoteRouteRestoreAttempt=0}clearPendingRemoteRouteRestoreTimer(){this.remoteRouteRestoreTimer!==void 0&&(window.clearTimeout(this.remoteRouteRestoreTimer),this.remoteRouteRestoreTimer=void 0)}async restoreRouteMachine(e,t){let n=e.machineId??`local`;if(this.state.selectedMachine?.id===n)return;let r=this.state.machines.find(e=>e.id===n);r!==void 0&&await this.machines.selectMachine(r,{updateUrl:t})}routeMatchesCurrentSelection(e){return(e.machineId??`local`)===(this.state.selectedMachine?.id??`local`)&&e.workspaceId!==void 0&&e.workspaceId!==``&&this.state.selectedProject?.id===e.projectId&&this.state.selectedWorkspace?.id===e.workspaceId&&this.state.selectedSession?.id===e.sessionId}async refreshRestoredWorkspaceTool(e,t){e===`core:workspace.files`?(await this.files.refreshFiles(),t!==void 0&&await this.files.restoreFile(t)):e!==void 0&&e!==`core:workspace.terminal`&&await this.invalidateWorkspacePanels(e)}resolveRestoredMainView(e){return e===void 0||e===`chat`||e===`navigation`?e:lx(e,e=>this.plugins.resolveWorkspacePanelRouteId(e,L(this.state)))}async withChatScrollTransition(e,t=()=>!0){this.chatView?.saveScrollPosition(),await e(),t()&&(await this.updateComplete,t()&&(await this.chatView?.updateComplete,t()&&(await Dj(),t()&&(this.chatView?.restoreScrollPosition(),this.shouldAutoFocusPrompt()&&this.promptEditor?.focusInput()))))}shouldAutoFocusPrompt(){return Ft({touchPrimary:Bt(),modalOpen:this.isRenderedModalOpen()})&&this.appShell.shouldAutoFocusPrompt()}async withChatPrependTransition(e){await e(),await this.updateComplete,await this.chatView?.updateComplete}defaultRouteView(e={}){return this.appShell.defaultRouteView(e)}updateUrl(e){this.rememberCurrentMachineNavigation(),ux({machineId:this.state.selectedMachine?.id,projectId:this.state.selectedProject?.id,workspaceId:this.state.selectedWorkspace?.id,sessionId:this.state.selectedSession?.id,tool:this.state.workspaceTool,view:this.state.mainView===`navigation`?void 0:this.state.mainView},e),this.syncWorkspaceRouteSurfaceToUrl()}rememberCurrentMachineNavigation(){this.machineNavigation.remember(sm(this.state))}syncWorkspaceRouteSurfaceToUrl(){this.writeWorkspaceRouteSurfaceToUrl(sm(this.state).surface)}writeMachineNavigationSnapshotToUrl(e,t){ux(cm(e),t),this.writeWorkspaceRouteSurfaceToUrl(e.surface)}writeWorkspaceRouteSurfaceToUrl(e){jc(ej,`file`,e.selectedFilePath,{replace:!0}),jc(tj,`terminal`,e.selectedTerminalId,{replace:!0})}async selectMachineWithMemory(e,t={}){if(this.state.selectedMachine?.id===e.id)return;t.rememberCurrent!==!1&&!this.routeRestoreInProgress&&this.rememberCurrentMachineNavigation();let n=++this.machineNavigationRestoreSeq,r=this.machineNavigation.latest(e.id)??om(e.id);if(await this.restoreRouteFor(cm(r),!1,r.surface,r.view),!(n!==this.machineNavigationRestoreSeq||this.state.selectedMachine?.id!==e.id)){if(this.shouldPreserveUnrestoredMachineNavigation(r)){this.machineNavigation.remember(r),this.writeMachineNavigationSnapshotToUrl(r);return}this.updateUrl()}}shouldPreserveUnrestoredMachineNavigation(e){return e.projectId!==void 0&&this.state.selectedProject?.id!==e.projectId&&this.state.error!==``}openWorkspaceTool(e){e===`core:workspace.terminal`&&(this.terminalAutoStartWorkspaceId=this.state.selectedWorkspace?.id),this.setState({workspaceTool:e,mainView:e}),this.updateUrl(),this.refreshSelectedWorkspaceTool(e)}openTerminal(e){e?.terminalId!==void 0&&this.selectTerminal(e.terminalId,{replace:!0}),this.openWorkspaceTool(`core:workspace.terminal`)}terminalCommandRunsForOrigin(e,t=L(this.state)){let n=Cj(t,e),r=this.terminalCommandRunRuntimes.get(n);if(r!==void 0)return r;let i=bx(e,{api:{runTerminalCommand:(e,n)=>cs.runTerminalCommand(e,n,t),listCommandRuns:e=>cs.listCommandRuns(e,t),getCommandRun:e=>cs.getCommandRun(e,t)},openTerminal:(e,n)=>{this.openRuntimeTerminal(t,e,n)}});return this.terminalCommandRunRuntimes.set(n,i),i}async openRuntimeTerminal(e,t,n){if((L(this.state)!==e||t!==void 0&&(this.state.selectedWorkspace?.id!==t.id||this.state.selectedProject?.id!==t.projectId))&&(this.routeRestoreInProgress||this.rememberCurrentMachineNavigation(),await this.restoreRouteFor({machineId:e,projectId:t?.projectId,workspaceId:t?.id,sessionId:void 0,tool:`core:workspace.terminal`,view:`core:workspace.terminal`},!1,{selectedTerminalId:n?.terminalId},`core:workspace.terminal`),L(this.state)!==e)){this.setState({error:`Machine not found for terminal command run`});return}this.openTerminal(n)}selectTerminal(e,t){this.rememberSelectedTerminal(e),this.setState({selectedTerminalId:e}),this.rememberCurrentMachineNavigation(),this.writeSelectedTerminalToUrl(e,t)}rememberSelectedTerminal(e){let t=this.state.selectedWorkspace;t!==void 0&&(e===void 0?this.terminalSelection.forgetWorkspace(this.terminalWorkspaceKey(t)):this.terminalSelection.rememberTerminal(this.terminalWorkspaceKey(t),e))}writeSelectedTerminalToUrl(e,t){jc(tj,`terminal`,e,t)}terminalWorkspaceKey(e){return`${L(this.state)}:${e.path}`}selectMainView(e){if(e!==`navigation`&&e!==`chat`){this.openWorkspaceTool(e);return}this.setState({mainView:e}),this.updateUrl()}openSettings(e=`general`){this.settingsSection=e,mx(e)}async refreshFleet(){this.fleetLoading=!0,this.fleetError=void 0;try{this.fleetReport=await es.report()}catch(e){this.fleetError=e instanceof Error?e.message:String(e)}finally{this.fleetLoading=!1}}async runFleetOperation(e,t){this.fleetError=void 0;try{return await es.run(e,t)}catch(e){this.fleetError=e instanceof Error?e.message:String(e);return}finally{this.refreshFleet()}}closeSettings(){this.settingsSection=void 0,mx(void 0)}navigateSettings(e){this.settingsSection=e,mx(e)}restoreSettingsRoute(){this.settingsSection=px()}handleWorkspaceChange(e,t){if(e.selectedWorkspace?.id===t.selectedWorkspace?.id)return;this.terminalAutoStartWorkspaceId=void 0,this.activeTerminalIds.clear();let n=this.routeRestoreInProgress?this.restoringRouteTerminalId:t.selectedWorkspace===void 0?void 0:this.terminalSelection.latestTerminalId(this.terminalWorkspaceKey(t.selectedWorkspace));this.setState({activeTerminalCount:0,selectedTerminalId:n}),this.routeRestoreInProgress||(this.rememberCurrentMachineNavigation(),this.writeSelectedTerminalToUrl(n,{replace:!0})),t.selectedWorkspace!==void 0&&(this.refreshActiveTerminals(t.selectedWorkspace),this.refreshWorkspaceDeletionRuns(),this.refreshSelectedWorkspaceTool(t.workspaceTool))}syncSessionUnreadMachines(){if(!this.unreadConnected){this.sessionUnread.retainMachines(new Set);return}let e=new Set(this.state.machines.map(e=>e.id));e.add(L(this.state)),this.sessionUnread.retainMachines(e);for(let t of e)this.sessionUnread.projection(t)===void 0&&this.sessionUnread.refresh(t)}connectRealtime(){let e=L(this.state);this.refreshInterruptedRuns(e),this.realtime.connect(t=>{this.handleRealtimeEvent(e,t)},()=>{this.clearTransientError(),this.sessionUnread.refresh(e),this.sessions.hydrateSessionStatuses(e,{replaceKnown:!0}),this.sessions.refreshCurrentWorkspaceSessions(e),this.refreshInterruptedRuns(e);let t=this.state.selectedWorkspace;t!==void 0&&this.refreshActiveTerminals(t)},e)}syncMachineActivitySubscriptions(){let e=this.machineActivitySubscriptionIds();for(let[t,n]of this.machineRealtimeSockets.entries())e.has(t)||(n.close(),this.machineRealtimeSockets.delete(t));for(let t of e){if(this.machineRealtimeSockets.has(t))continue;let e=new Of;e.connect(e=>{this.handleMachineActivityEvent(t,e)},()=>{this.sessionUnread.refresh(t)},t),this.machineRealtimeSockets.set(t,e)}}closeMachineActivitySockets(){for(let e of this.machineRealtimeSockets.values())e.close();this.machineRealtimeSockets.clear()}machineActivitySubscriptionIds(){let e=L(this.state);return new Set(this.state.machines.filter(t=>t.id!==e).filter(e=>fj(e,this.state.machineStatuses[e.id])).map(e=>e.id))}handleMachineActivityEvent(e,t){t.type===`sessions.unread`?this.sessionUnread.applyEvent(e,t):t.type===`machine.status`&&this.machineStatus.apply(e,t.status)}handleRealtimeEvent(e,t){t.type===`sessions.unread`?this.sessionUnread.applyEvent(e,t):t.type===`machine.status`?this.machineStatus.apply(e,t.status):xj(t)?(this.applyTerminalEvent(t),t.type===`terminal.exited`&&this.refreshWorkspaceDeletionRuns()):this.sessions.applyGlobalEvent(t)}applyTerminalEvent(e){let t=this.state.selectedWorkspace;t!==void 0&&(e.type===`terminal.closed`?e.cwd:e.terminal.cwd)===t.path&&(e.type===`terminal.created`&&!e.terminal.exited?this.activeTerminalIds.add(e.terminal.id):this.activeTerminalIds.delete(e.type===`terminal.closed`?e.terminalId:e.terminal.id),e.type===`terminal.closed`&&(this.terminalSelection.forgetTerminal(e.terminalId),this.state.selectedTerminalId===e.terminalId&&this.selectTerminal(void 0,{replace:!0})),this.setState({activeTerminalCount:this.activeTerminalIds.size}))}async refreshActiveTerminals(e){let t=L(this.state);try{let n=await cs.terminals(e.projectId,e.id,t);if(L(this.state)!==t||this.state.selectedWorkspace?.id!==e.id)return;this.activeTerminalIds.clear();for(let e of n)e.exited||this.activeTerminalIds.add(e.id);this.setState({activeTerminalCount:this.activeTerminalIds.size})}catch(e){this.setState({error:String(e)})}}handleActivityTransition(e,t){let n=bj(e),r=bj(t);n&&!r&&(this.setState({fileTreeStale:!0}),this.refreshSelectedWorkspaceTool(this.state.workspaceTool))}handleMachineChange(e,t){(e.selectedMachine?.id??`local`)!==(t.selectedMachine?.id??`local`)&&((this.pendingRemoteRouteRestore?.machineId??`local`)!==(t.selectedMachine?.id??`local`)&&this.clearPendingRemoteRouteRestore(),this.sessions.clearActiveSession(),this.realtime.close(),this.connectRealtime(),this.activeTerminalIds.clear(),this.sessionCleanupDialog=void 0,this.setState({piWebStatus:void 0}),this.loadPluginsForSelectedMachine())}refreshSelectedWorkspaceTool(e){e===`core:workspace.files`?this.files.refreshFiles():e!==`core:workspace.terminal`&&this.invalidateWorkspacePanels(e)}renderWorkspacePanel(){let e=this.state.selectedWorkspace;return g`
|
|
6115
|
+
</div>`}syncUnreadSessionIds(){let e=this.sessionUnread.unreadSessionIds(L(this.state),this.state.sessions);yj(e,this.unreadSessionIds)||(this.unreadSessionIds=e)}isSessionSeen(e,t){if(!this.unreadConnected)return!1;let n=lj(e,t);return uj(this.state)!==n||this.committedChatIdentity!==n||this.readyChatIdentity!==n||typeof document<`u`&&(document.visibilityState!==`visible`||typeof document.hasFocus==`function`&&!document.hasFocus())||this.isRenderedModalOpen()?!1:this.state.mainView===`chat`?!0:this.state.mainView===`navigation`?!this.appShell.isMobileNavigationLayout:this.isDesktopSideBySideLayout()}isRenderedModalOpen(){return Og(this.ownerDocument)}connectedCallback(){super.connectedCallback(),Yt(()=>{this.clearTransientError()}),this.unreadConnected=!0,window.visualViewport?.addEventListener(`resize`,this.onVisualViewportChange),window.visualViewport?.addEventListener(`scroll`,this.onVisualViewportChange),window.addEventListener(`resize`,this.onVisualViewportChange),window.addEventListener(`orientationchange`,this.onVisualViewportChange),this.onVisualViewportChange(),requestAnimationFrame(()=>{this.onVisualViewportChange()}),window.setTimeout(()=>{this.onVisualViewportChange()},400),window.addEventListener(`popstate`,this.onPopState),window.addEventListener(`pageshow`,this.onPageShow),this.browserResume.connect(),window.addEventListener(`keydown`,this.onKeyDown,ZA),this.systemLightThemeMedia?.addEventListener(`change`,this.onSystemLightThemeChange),this.applyPreferredTheme(!1),$h(this.uiScale),this.connectRealtime(),this.syncSessionUnreadMachines(),this.piWebStatusTimer=window.setInterval(()=>{this.schedulePiWebStatusRefresh()},GA),document.addEventListener(`visibilitychange`,this.onDocumentVisibilityChange),this.listenForFormFocus(`add`),this.livenessTimer=window.setInterval(()=>{this.checkSocketLiveness()},qA),window.addEventListener(`online`,this.onBrowserOnline),this.updateSubagentPolling(),this.loadClientConfig(),this.refreshSelfUpdate(),this.ensureGatewayPluginsLoaded(),this.loadProjectsAndRestoreRoute().finally(()=>{this.schedulePiWebStatusRefresh()})}clearTransientError(){this.state.error===``||!RA(this.state.error)||(this.transientErrorTimer!==void 0&&(window.clearTimeout(this.transientErrorTimer),this.transientErrorTimer=void 0),this.setState({error:``}))}scheduleTransientErrorDismissal(e){this.transientErrorTimer!==void 0&&(window.clearTimeout(this.transientErrorTimer),this.transientErrorTimer=void 0),RA(e)&&(this.transientErrorTimer=window.setTimeout(()=>{this.transientErrorTimer=void 0,this.state.error===e&&this.setState({error:``})},zA))}disconnectedCallback(){Yt(void 0),this.transientErrorTimer!==void 0&&window.clearTimeout(this.transientErrorTimer),window.removeEventListener(`resize`,this.onVisualViewportChange),window.removeEventListener(`orientationchange`,this.onVisualViewportChange),window.visualViewport?.removeEventListener(`resize`,this.onVisualViewportChange),window.visualViewport?.removeEventListener(`scroll`,this.onVisualViewportChange),this.unreadConnected=!1,this.committedChatIdentity=void 0,this.readyChatIdentity=void 0,this.sessionUnread.retainMachines(new Set),window.removeEventListener(`popstate`,this.onPopState),window.removeEventListener(`pageshow`,this.onPageShow),this.browserResume.disconnect(),window.removeEventListener(`keydown`,this.onKeyDown,ZA),this.systemLightThemeMedia?.removeEventListener(`change`,this.onSystemLightThemeChange),this.keyboard.reset(),this.auth.dispose(),this.sessions.dispose(),this.notifications.dispose(),this.realtime.close(),this.closeMachineActivitySockets(),this.piWebStatusTimer!==void 0&&window.clearInterval(this.piWebStatusTimer),this.piWebStatusTimer=void 0,this.clearScheduledPiWebStatusRefresh(),this.workspaceDeletionPollTimer!==void 0&&window.clearInterval(this.workspaceDeletionPollTimer),this.workspaceDeletionPollTimer=void 0,this.subagentPollTimer!==void 0&&window.clearInterval(this.subagentPollTimer),this.subagentPollTimer=void 0,this.livenessTimer!==void 0&&window.clearInterval(this.livenessTimer),this.livenessTimer=void 0,window.removeEventListener(`online`,this.onBrowserOnline),document.removeEventListener(`visibilitychange`,this.onDocumentVisibilityChange),this.listenForFormFocus(`remove`),this.clearPendingRemoteRouteRestore(),super.disconnectedCallback()}setState(e){if(!hj(this.state,e))return;let t=this.state;this.state={...this.state,...e},uj(t)!==uj(this.state)&&(this.committedChatIdentity=void 0,this.readyChatIdentity=void 0),dj(t,this.state)&&this.syncSessionUnreadMachines(),this.syncUnreadSessionIds(),this.handleActivityTransition(t,this.state),this.handleWorkspaceChange(t,this.state),this.handleMachineChange(t,this.state),fj(t,this.state)&&this.syncMachineActivitySubscriptions(),this.notifications.syncEnvironment(t,this.state),t.selectedSession?.id!==this.state.selectedSession?.id&&this.updateSubagentPolling(),this.composerCollapsed&&this.state.pendingAsk===void 0&&this.state.pendingDialogs.length===0&&(this.composerCollapsed=!1)}async loadProjectsAndRestoreRoute(){this.restoreSettingsRoute();let e=sx();await this.machines.loadMachines(e.machineId);let t=this.routeForSelectedMachine(e),n=this.state.machineStatuses[t.machineId??`local`];t!==e&&this.replaceRouteAndClearWorkspaceQuery(t),await this.projects.loadProjects(),await this.withChatScrollTransition(()=>this.restoreRouteFor(t,!1)),this.shouldDeferRemoteRouteRestore(t,n)?this.deferRemoteRouteRestore(t):(this.clearPendingRemoteRouteRestore(),this.rememberCurrentMachineNavigation()),await this.refreshWorkspaceDeletionRuns()}checkSocketLiveness(){document.visibilityState===`visible`&&(this.realtime.checkLiveness(),this.sessions.checkSocketLiveness())}handleBrowserResumeSignal(){this.appShell.repairViewportPosition(),this.realtime.checkLiveness(),this.sessions.checkSocketLiveness(),this.schedulePiWebStatusRefresh(),this.retryPendingRemoteRouteRestoreSoon()}async refreshAfterBrowserResume(){await this.sessionUnread.refreshAll(),await Promise.all([this.sessions.refreshSelectedSession(),this.refreshMachineStatusSnapshots(),this.refreshWorkspaceDeletionRuns(),this.refreshCurrentWorkspaceSurface(),this.workspaces.refreshSelectedProjectTopology()])}schedulePiWebStatusRefresh(e=YA){this.clearScheduledPiWebStatusRefresh(),this.piWebStatusDeferredTimer=window.setTimeout(()=>{this.piWebStatusDeferredTimer=void 0,this.piWebStatusController.refresh()},e)}clearScheduledPiWebStatusRefresh(){this.piWebStatusDeferredTimer!==void 0&&(window.clearTimeout(this.piWebStatusDeferredTimer),this.piWebStatusDeferredTimer=void 0)}async refreshMachineStatusSnapshots(){await Promise.all(this.refreshableMachineIds().map(async e=>{try{await this.machineStatus.refresh(e)}catch(t){console.warn(`Failed to refresh machine status for ${e}`,t)}}))}refreshableMachineIds(){return this.state.machines.length===0?[L(this.state)]:this.state.machines.filter(e=>mj(e,this.state.machineStatuses[e.id])).map(e=>e.id)}async loadClientConfig(){try{this.applyClientConfig((await Xo.config()).effectiveConfig)}catch(e){console.warn(`Failed to load PI WEB config`,e)}}applyClientConfig(e){this.shortcutConfig=e.shortcuts??{},this.workspaceUploadDefaultFolder=Xs(e),this.speechToTextConfig=e.speechToText}async refreshAppData(){if(!this.isRefreshingApp){this.isRefreshingApp=!0;try{await Promise.all([this.sessions.refreshSelectedSession(),this.refreshMachineStatusSnapshots(),this.loadClientConfig(),this.refreshWorkspaceDeletionRuns(),this.refreshCurrentWorkspaceSurface(),this.workspaces.refreshSelectedProjectTopology()]),this.schedulePiWebStatusRefresh()}finally{this.isRefreshingApp=!1}}}async refreshCurrentWorkspaceSurface(){let e=this.state.selectedWorkspace,t=this.state.mainView!==`chat`&&this.state.mainView!==`navigation`?this.state.mainView:this.state.workspaceTool;t===`core:workspace.files`?await this.files.refreshFiles():t===`core:workspace.terminal`&&e!==void 0?await this.refreshActiveTerminals(e):await this.invalidateWorkspacePanels(t)}hardReloadApp(){window.location.reload()}async restoreRoute(e){await this.restoreRouteFor(sx(),e),this.rememberCurrentMachineNavigation()}async restoreRouteFor(e,t,n=this.readWorkspaceRouteSurface(e),r){let i=L(this.state),a=e.projectId===void 0||e.projectId===``?Cj():n,o=++this.routeRestoreSeq;this.routeRestoreDepth+=1,this.restoringRouteTerminalId=a.selectedTerminalId;try{if(await this.restoreRouteMachine(e,!1),await this.loadPluginsForSelectedMachine(),!this.isCurrentRouteRestore(o))return;let n=cx(e,e=>this.plugins.resolveWorkspacePanelRouteId(e,L(this.state)));if(this.setState({workspaceTool:n.tool??this.state.workspaceTool,mainView:this.resolveRestoredMainView(r)??n.view??this.defaultRouteView(n),selectedFilePath:a.selectedFilePath,selectedTerminalId:a.selectedTerminalId}),n.projectId===void 0||n.projectId===``){t&&this.updateUrl();return}if(this.routeMatchesCurrentSelection(n)){a.selectedTerminalId!==void 0&&this.rememberSelectedTerminal(a.selectedTerminalId),await this.refreshRestoredWorkspaceTool(n.tool,a.selectedFilePath),t&&this.updateUrl();return}let i=this.state.projects.find(e=>e.id===n.projectId);if(!i){this.setState({selectedFilePath:void 0,selectedTerminalId:void 0}),t&&this.updateUrl();return}if(await this.workspaces.selectProject(i,{workspaceId:n.workspaceId,sessionId:n.sessionId,updateUrl:!1}),!this.isCurrentRouteRestore(o))return;this.setState({selectedFilePath:a.selectedFilePath,selectedTerminalId:a.selectedTerminalId}),a.selectedTerminalId!==void 0&&this.rememberSelectedTerminal(a.selectedTerminalId),await this.refreshRestoredWorkspaceTool(n.tool,a.selectedFilePath),t&&this.updateUrl()}finally{this.routeRestoreDepth=Math.max(0,this.routeRestoreDepth-1),this.routeRestoreDepth===0&&(this.restoringRouteTerminalId=void 0),L(this.state)!==i&&this.schedulePiWebStatusRefresh()}}isCurrentRouteRestore(e){return e===this.routeRestoreSeq}readWorkspaceRouteSurface(e){return e.projectId===void 0||e.projectId===``?Cj():{selectedFilePath:Ac(tj,`file`),selectedTerminalId:Ac(nj,`terminal`)}}routeForSelectedMachine(e){let t=this.state.selectedMachine?.id??`local`;return(e.machineId??`local`)===t?e:{machineId:t,projectId:void 0,workspaceId:void 0,sessionId:void 0,tool:void 0,view:void 0}}replaceRouteAndClearWorkspaceQuery(e){ux(e,{replace:!0}),jc(tj,`file`,void 0,{replace:!0}),jc(nj,`terminal`,void 0,{replace:!0})}shouldDeferRemoteRouteRestore(e,t=this.state.machineStatuses[e.machineId??`local`]){let n=e.machineId??`local`,r=this.state.selectedMachine;return n===`local`||r?.id!==n||r.kind!==`remote`||t?.ok!==!1?!1:e.projectId===void 0||e.projectId===``?this.state.projects.length===0:this.state.selectedProject?.id!==e.projectId}deferRemoteRouteRestore(e){this.pendingRemoteRouteRestore=e,this.remoteRouteRestoreAttempt=0,this.setRemoteRouteRestoreMessage(e),this.schedulePendingRemoteRouteRestore()}retryPendingRemoteRouteRestoreSoon(){this.pendingRemoteRouteRestore!==void 0&&this.schedulePendingRemoteRouteRestore(0)}schedulePendingRemoteRouteRestore(e=Tj(this.remoteRouteRestoreAttempt)){this.pendingRemoteRouteRestore!==void 0&&(this.clearPendingRemoteRouteRestoreTimer(),this.remoteRouteRestoreTimer=window.setTimeout(()=>{this.remoteRouteRestoreTimer=void 0,this.retryPendingRemoteRouteRestore()},e))}async retryPendingRemoteRouteRestore(){if(this.remoteRouteRestoreInProgress)return;let e=this.pendingRemoteRouteRestore;if(e!==void 0){if(!this.pendingRemoteRouteRestoreStillCurrent(e)){this.clearPendingRemoteRouteRestore();return}this.remoteRouteRestoreInProgress=!0;try{let t=e.machineId??`local`,n=await this.machines.refreshMachineHealth(t);if(!this.pendingRemoteRouteRestoreStillCurrent(e))return;if(n?.ok!==!0){this.scheduleNextRemoteRouteRestoreAttempt(e);return}if(await this.machines.refreshMachineRuntime(t),!this.pendingRemoteRouteRestoreStillCurrent(e)||(await this.projects.loadProjects(),!this.pendingRemoteRouteRestoreStillCurrent(e)))return;if(this.state.error!==``){this.scheduleNextRemoteRouteRestoreAttempt(e);return}if(await this.withChatScrollTransition(()=>this.restoreRouteFor(e,!1)),!this.pendingRemoteRouteRestoreStillCurrent(e))return;this.clearPendingRemoteRouteRestore(),this.rememberCurrentMachineNavigation(),await this.refreshWorkspaceDeletionRuns()}finally{this.remoteRouteRestoreInProgress=!1}}}scheduleNextRemoteRouteRestoreAttempt(e){if(this.remoteRouteRestoreAttempt+=1,this.remoteRouteRestoreAttempt>=XA.length){this.setRemoteRouteRestoreMessage(e,{exhausted:!0}),this.clearPendingRemoteRouteRestore();return}this.setRemoteRouteRestoreMessage(e),this.schedulePendingRemoteRouteRestore()}setRemoteRouteRestoreMessage(e,t={}){let n=e.machineId??`local`,r=this.state.machines.find(e=>e.id===n)?.name??this.state.selectedMachine?.name??`Remote machine`,i=this.state.machineStatuses[n]?.error??(this.state.error===``?void 0:this.state.error),a=t.exhausted===!0?`${r} is still unavailable.`:`${r} is unavailable; reconnecting…`;this.setState({error:`${a}${i===void 0?``:` ${i}`}`})}pendingRemoteRouteRestoreStillCurrent(e){let t=e.machineId??`local`;return t!==`local`&&this.pendingRemoteRouteRestore===e&&this.state.selectedMachine?.id===t&&this.state.machines.some(e=>e.id===t)}clearPendingRemoteRouteRestore(){this.clearPendingRemoteRouteRestoreTimer(),this.pendingRemoteRouteRestore=void 0,this.remoteRouteRestoreAttempt=0}clearPendingRemoteRouteRestoreTimer(){this.remoteRouteRestoreTimer!==void 0&&(window.clearTimeout(this.remoteRouteRestoreTimer),this.remoteRouteRestoreTimer=void 0)}async restoreRouteMachine(e,t){let n=e.machineId??`local`;if(this.state.selectedMachine?.id===n)return;let r=this.state.machines.find(e=>e.id===n);r!==void 0&&await this.machines.selectMachine(r,{updateUrl:t})}routeMatchesCurrentSelection(e){return(e.machineId??`local`)===(this.state.selectedMachine?.id??`local`)&&e.workspaceId!==void 0&&e.workspaceId!==``&&this.state.selectedProject?.id===e.projectId&&this.state.selectedWorkspace?.id===e.workspaceId&&this.state.selectedSession?.id===e.sessionId}async refreshRestoredWorkspaceTool(e,t){e===`core:workspace.files`?(await this.files.refreshFiles(),t!==void 0&&await this.files.restoreFile(t)):e!==void 0&&e!==`core:workspace.terminal`&&await this.invalidateWorkspacePanels(e)}resolveRestoredMainView(e){return e===void 0||e===`chat`||e===`navigation`?e:lx(e,e=>this.plugins.resolveWorkspacePanelRouteId(e,L(this.state)))}async withChatScrollTransition(e,t=()=>!0){this.chatView?.saveScrollPosition(),await e(),t()&&(await this.updateComplete,t()&&(await this.chatView?.updateComplete,t()&&(await Oj(),t()&&(this.chatView?.restoreScrollPosition(),this.shouldAutoFocusPrompt()&&this.promptEditor?.focusInput()))))}shouldAutoFocusPrompt(){return Ft({touchPrimary:Bt(),modalOpen:this.isRenderedModalOpen()})&&this.appShell.shouldAutoFocusPrompt()}async withChatPrependTransition(e){await e(),await this.updateComplete,await this.chatView?.updateComplete}defaultRouteView(e={}){return this.appShell.defaultRouteView(e)}updateUrl(e){this.rememberCurrentMachineNavigation(),ux({machineId:this.state.selectedMachine?.id,projectId:this.state.selectedProject?.id,workspaceId:this.state.selectedWorkspace?.id,sessionId:this.state.selectedSession?.id,tool:this.state.workspaceTool,view:this.state.mainView===`navigation`?void 0:this.state.mainView},e),this.syncWorkspaceRouteSurfaceToUrl()}rememberCurrentMachineNavigation(){this.machineNavigation.remember(sm(this.state))}syncWorkspaceRouteSurfaceToUrl(){this.writeWorkspaceRouteSurfaceToUrl(sm(this.state).surface)}writeMachineNavigationSnapshotToUrl(e,t){ux(cm(e),t),this.writeWorkspaceRouteSurfaceToUrl(e.surface)}writeWorkspaceRouteSurfaceToUrl(e){jc(tj,`file`,e.selectedFilePath,{replace:!0}),jc(nj,`terminal`,e.selectedTerminalId,{replace:!0})}async selectMachineWithMemory(e,t={}){if(this.state.selectedMachine?.id===e.id)return;t.rememberCurrent!==!1&&!this.routeRestoreInProgress&&this.rememberCurrentMachineNavigation();let n=++this.machineNavigationRestoreSeq,r=this.machineNavigation.latest(e.id)??om(e.id);if(await this.restoreRouteFor(cm(r),!1,r.surface,r.view),!(n!==this.machineNavigationRestoreSeq||this.state.selectedMachine?.id!==e.id)){if(this.shouldPreserveUnrestoredMachineNavigation(r)){this.machineNavigation.remember(r),this.writeMachineNavigationSnapshotToUrl(r);return}this.updateUrl()}}shouldPreserveUnrestoredMachineNavigation(e){return e.projectId!==void 0&&this.state.selectedProject?.id!==e.projectId&&this.state.error!==``}openWorkspaceTool(e){e===`core:workspace.terminal`&&(this.terminalAutoStartWorkspaceId=this.state.selectedWorkspace?.id),this.setState({workspaceTool:e,mainView:e}),this.updateUrl(),this.refreshSelectedWorkspaceTool(e)}openTerminal(e){e?.terminalId!==void 0&&this.selectTerminal(e.terminalId,{replace:!0}),this.openWorkspaceTool(`core:workspace.terminal`)}terminalCommandRunsForOrigin(e,t=L(this.state)){let n=wj(t,e),r=this.terminalCommandRunRuntimes.get(n);if(r!==void 0)return r;let i=bx(e,{api:{runTerminalCommand:(e,n)=>cs.runTerminalCommand(e,n,t),listCommandRuns:e=>cs.listCommandRuns(e,t),getCommandRun:e=>cs.getCommandRun(e,t)},openTerminal:(e,n)=>{this.openRuntimeTerminal(t,e,n)}});return this.terminalCommandRunRuntimes.set(n,i),i}async openRuntimeTerminal(e,t,n){if((L(this.state)!==e||t!==void 0&&(this.state.selectedWorkspace?.id!==t.id||this.state.selectedProject?.id!==t.projectId))&&(this.routeRestoreInProgress||this.rememberCurrentMachineNavigation(),await this.restoreRouteFor({machineId:e,projectId:t?.projectId,workspaceId:t?.id,sessionId:void 0,tool:`core:workspace.terminal`,view:`core:workspace.terminal`},!1,{selectedTerminalId:n?.terminalId},`core:workspace.terminal`),L(this.state)!==e)){this.setState({error:`Machine not found for terminal command run`});return}this.openTerminal(n)}selectTerminal(e,t){this.rememberSelectedTerminal(e),this.setState({selectedTerminalId:e}),this.rememberCurrentMachineNavigation(),this.writeSelectedTerminalToUrl(e,t)}rememberSelectedTerminal(e){let t=this.state.selectedWorkspace;t!==void 0&&(e===void 0?this.terminalSelection.forgetWorkspace(this.terminalWorkspaceKey(t)):this.terminalSelection.rememberTerminal(this.terminalWorkspaceKey(t),e))}writeSelectedTerminalToUrl(e,t){jc(nj,`terminal`,e,t)}terminalWorkspaceKey(e){return`${L(this.state)}:${e.path}`}selectMainView(e){if(e!==`navigation`&&e!==`chat`){this.openWorkspaceTool(e);return}this.setState({mainView:e}),this.updateUrl()}openSettings(e=`general`){this.settingsSection=e,mx(e)}async refreshFleet(){this.fleetLoading=!0,this.fleetError=void 0;try{this.fleetReport=await es.report()}catch(e){this.fleetError=e instanceof Error?e.message:String(e)}finally{this.fleetLoading=!1}}async runFleetOperation(e,t){this.fleetError=void 0;try{return await es.run(e,t)}catch(e){this.fleetError=e instanceof Error?e.message:String(e);return}finally{this.refreshFleet()}}closeSettings(){this.settingsSection=void 0,mx(void 0)}navigateSettings(e){this.settingsSection=e,mx(e)}restoreSettingsRoute(){this.settingsSection=px()}handleWorkspaceChange(e,t){if(e.selectedWorkspace?.id===t.selectedWorkspace?.id)return;this.terminalAutoStartWorkspaceId=void 0,this.activeTerminalIds.clear();let n=this.routeRestoreInProgress?this.restoringRouteTerminalId:t.selectedWorkspace===void 0?void 0:this.terminalSelection.latestTerminalId(this.terminalWorkspaceKey(t.selectedWorkspace));this.setState({activeTerminalCount:0,selectedTerminalId:n}),this.routeRestoreInProgress||(this.rememberCurrentMachineNavigation(),this.writeSelectedTerminalToUrl(n,{replace:!0})),t.selectedWorkspace!==void 0&&(this.refreshActiveTerminals(t.selectedWorkspace),this.refreshWorkspaceDeletionRuns(),this.refreshSelectedWorkspaceTool(t.workspaceTool))}syncSessionUnreadMachines(){if(!this.unreadConnected){this.sessionUnread.retainMachines(new Set);return}let e=new Set(this.state.machines.map(e=>e.id));e.add(L(this.state)),this.sessionUnread.retainMachines(e);for(let t of e)this.sessionUnread.projection(t)===void 0&&this.sessionUnread.refresh(t)}connectRealtime(){let e=L(this.state);this.refreshInterruptedRuns(e),this.realtime.connect(t=>{this.handleRealtimeEvent(e,t)},()=>{this.clearTransientError(),this.sessionUnread.refresh(e),this.sessions.hydrateSessionStatuses(e,{replaceKnown:!0}),this.sessions.refreshCurrentWorkspaceSessions(e),this.refreshInterruptedRuns(e);let t=this.state.selectedWorkspace;t!==void 0&&this.refreshActiveTerminals(t)},e)}syncMachineActivitySubscriptions(){let e=this.machineActivitySubscriptionIds();for(let[t,n]of this.machineRealtimeSockets.entries())e.has(t)||(n.close(),this.machineRealtimeSockets.delete(t));for(let t of e){if(this.machineRealtimeSockets.has(t))continue;let e=new Of;e.connect(e=>{this.handleMachineActivityEvent(t,e)},()=>{this.sessionUnread.refresh(t)},t),this.machineRealtimeSockets.set(t,e)}}closeMachineActivitySockets(){for(let e of this.machineRealtimeSockets.values())e.close();this.machineRealtimeSockets.clear()}machineActivitySubscriptionIds(){let e=L(this.state);return new Set(this.state.machines.filter(t=>t.id!==e).filter(e=>pj(e,this.state.machineStatuses[e.id])).map(e=>e.id))}handleMachineActivityEvent(e,t){t.type===`sessions.unread`?this.sessionUnread.applyEvent(e,t):t.type===`machine.status`&&this.machineStatus.apply(e,t.status)}handleRealtimeEvent(e,t){t.type===`sessions.unread`?this.sessionUnread.applyEvent(e,t):t.type===`machine.status`?this.machineStatus.apply(e,t.status):Sj(t)?(this.applyTerminalEvent(t),t.type===`terminal.exited`&&this.refreshWorkspaceDeletionRuns()):this.sessions.applyGlobalEvent(t)}applyTerminalEvent(e){let t=this.state.selectedWorkspace;t!==void 0&&(e.type===`terminal.closed`?e.cwd:e.terminal.cwd)===t.path&&(e.type===`terminal.created`&&!e.terminal.exited?this.activeTerminalIds.add(e.terminal.id):this.activeTerminalIds.delete(e.type===`terminal.closed`?e.terminalId:e.terminal.id),e.type===`terminal.closed`&&(this.terminalSelection.forgetTerminal(e.terminalId),this.state.selectedTerminalId===e.terminalId&&this.selectTerminal(void 0,{replace:!0})),this.setState({activeTerminalCount:this.activeTerminalIds.size}))}async refreshActiveTerminals(e){let t=L(this.state);try{let n=await cs.terminals(e.projectId,e.id,t);if(L(this.state)!==t||this.state.selectedWorkspace?.id!==e.id)return;this.activeTerminalIds.clear();for(let e of n)e.exited||this.activeTerminalIds.add(e.id);this.setState({activeTerminalCount:this.activeTerminalIds.size})}catch(e){this.setState({error:String(e)})}}handleActivityTransition(e,t){let n=xj(e),r=xj(t);n&&!r&&(this.setState({fileTreeStale:!0}),this.refreshSelectedWorkspaceTool(this.state.workspaceTool))}handleMachineChange(e,t){(e.selectedMachine?.id??`local`)!==(t.selectedMachine?.id??`local`)&&((this.pendingRemoteRouteRestore?.machineId??`local`)!==(t.selectedMachine?.id??`local`)&&this.clearPendingRemoteRouteRestore(),this.sessions.clearActiveSession(),this.realtime.close(),this.connectRealtime(),this.activeTerminalIds.clear(),this.sessionCleanupDialog=void 0,this.setState({piWebStatus:void 0}),this.loadPluginsForSelectedMachine())}refreshSelectedWorkspaceTool(e){e===`core:workspace.files`?this.files.refreshFiles():e!==`core:workspace.terminal`&&this.invalidateWorkspacePanels(e)}renderWorkspacePanel(){let e=this.state.selectedWorkspace;return g`
|
|
6108
6116
|
<workspace-panel
|
|
6109
6117
|
id="workspace-panel"
|
|
6110
6118
|
.workspace=${e}
|
|
@@ -6150,7 +6158,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6150
6158
|
.onResizeEnd=${()=>{this.panelResize.persistPanelSizes()}}
|
|
6151
6159
|
.onReset=${()=>{this.resetResizablePanel(`workspace`)}}
|
|
6152
6160
|
></app-panel-edge-control>
|
|
6153
|
-
`}startPanelResize(e){return e===`navigation`?this.panelCollapse.expandNavigationPanel():this.panelCollapse.expandWorkspacePanel(),this.measuredPanelWidth(e)??this.panelResize.panelWidth(e)}resizablePanelConstraints(e){let t=this.panelResize.constraints(e);return{...t,maxWidth:this.resizablePanelMaxWidth(e,t)}}resizablePanelMaxWidth(e,t){let n=this.getBoundingClientRect().width||(typeof window>`u`?0:window.innerWidth);if(n<=0)return t.maxWidth;let r=this.oppositeResizablePanelWidth(e),i=Math.floor(n-r-rj
|
|
6161
|
+
`}startPanelResize(e){return e===`navigation`?this.panelCollapse.expandNavigationPanel():this.panelCollapse.expandWorkspacePanel(),this.measuredPanelWidth(e)??this.panelResize.panelWidth(e)}resizablePanelConstraints(e){let t=this.panelResize.constraints(e);return{...t,maxWidth:this.resizablePanelMaxWidth(e,t)}}resizablePanelMaxWidth(e,t){let n=this.getBoundingClientRect().width||(typeof window>`u`?0:window.innerWidth);if(n<=0)return t.maxWidth;let r=this.oppositeResizablePanelWidth(e),i=Math.floor(n-r-ij-rj);return Math.max(t.minWidth,Math.min(t.maxWidth,i))}oppositeResizablePanelWidth(e){let t=e===`navigation`?`workspace`:`navigation`;return this.isResizablePanelCollapsedOrStacked(t)?0:this.measuredPanelWidth(t)??this.panelResize.panelWidth(t)}isResizablePanelCollapsedOrStacked(e){return e===`navigation`?this.panelCollapse.navigationPanelCollapsed:this.panelCollapse.workspacePanelCollapsed||!this.isDesktopSideBySideLayout()}isDesktopSideBySideLayout(){return typeof window>`u`||!(`matchMedia`in window)||window.matchMedia(aj).matches}measuredPanelWidth(e){let t=(e===`navigation`?this.navigationPanelFrame:this.workspacePanelFrame)?.getBoundingClientRect().width;return t===void 0||t<=0?void 0:t}resetResizablePanel(e){this.panelResize.resetPanel(e)}resetResizablePanels(){this.panelResize.resetPanels()}selectedMachineRuntime(){return this.state.machineRuntimes[L(this.state)]}openSessionCleanupDialog(){this.sessionCleanupDialog={error:``}}closeSessionCleanupDialog(){this.sessionCleanupDialog=void 0}async previewSessionCleanup(e){let t=L(this.state);this.sessionCleanupDialog={...this.sessionCleanupDialog??{},loading:!0,error:``,preview:void 0,previewRequest:void 0,result:void 0};try{let n=await ss.cleanupPreview(e,t);if(L(this.state)!==t)return;this.sessionCleanupDialog={...this.sessionCleanupDialog,preview:n,previewRequest:e,result:void 0,loading:!1,error:``}}catch(e){L(this.state)===t&&(this.sessionCleanupDialog={...this.sessionCleanupDialog,loading:!1,error:`Failed to preview cleanup: ${Ej(e)}`})}}async runSessionCleanup(e){let t=this.sessionCleanupDialog;if(t?.preview===void 0||ah(t.previewRequest)!==ah(e)){this.sessionCleanupDialog={...t??{},error:`Preview cleanup before running it.`};return}let n=L(this.state);this.sessionCleanupDialog={...t,running:!0,error:``};try{let t=await ss.cleanup(e,n);if(L(this.state)!==n)return;this.sessionCleanupDialog={...this.sessionCleanupDialog,preview:t,previewRequest:e,result:t,running:!1,error:``},await this.sessions.applySessionCleanupResult(t,n)}catch(e){L(this.state)===n&&(this.sessionCleanupDialog={...this.sessionCleanupDialog,running:!1,error:`Failed to run cleanup: ${Ej(e)}`})}}renderNavigationPanel(){return g`
|
|
6154
6162
|
<app-navigation-panel
|
|
6155
6163
|
.machines=${this.state.machines}
|
|
6156
6164
|
.selectedMachine=${this.state.selectedMachine}
|
|
@@ -6220,7 +6228,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6220
6228
|
.onFocusNavigationTarget=${e=>{this.focusNavigationTarget(e)}}
|
|
6221
6229
|
.onCancelKeyboardNavigation=${()=>{this.focusChatComposer()}}
|
|
6222
6230
|
></app-navigation-panel>
|
|
6223
|
-
`}openNavigationSection(e){this.navigationSections.open(e,()=>{this.selectMainView(`navigation`)})}async selectNavigationItem(e,t,n){let r=++this.navigationSelectionSeq,i=()=>r===this.navigationSelectionSeq;if(await this.withChatScrollTransition(async()=>{this.navigationSections.advanceAfterSelection(e),await n()},i),!i())return;let a=t;e===`projects`&&(this.navigationSections.advanceAfterSelection(`projects`,{workspaceCount:this.state.workspaces.length}),this.state.workspaces.length===1&&this.state.selectedWorkspace!==void 0&&(a=`sessions`)),await this.focusNavigationTarget(a)}async startSessionFromNavigation(){let e=++this.navigationSelectionSeq;this.navigationSections.advanceAfterSelection(`sessions`),await this.startSessionAndOpenChat(()=>e===this.navigationSelectionSeq)}canStartSession(){return this.state.selectedWorkspace!==void 0}activeSessionIds(){let e=new Set;for(let t of this.quickSwitcherSessions)vc(this.state.sessionStatuses[t.id],this.state.sessionActivities[t.id])&&e.add(t.id);return e}sessionStateKinds(){return
|
|
6231
|
+
`}openNavigationSection(e){this.navigationSections.open(e,()=>{this.selectMainView(`navigation`)})}async selectNavigationItem(e,t,n){let r=++this.navigationSelectionSeq,i=()=>r===this.navigationSelectionSeq;if(await this.withChatScrollTransition(async()=>{this.navigationSections.advanceAfterSelection(e),await n()},i),!i())return;let a=t;e===`projects`&&(this.navigationSections.advanceAfterSelection(`projects`,{workspaceCount:this.state.workspaces.length}),this.state.workspaces.length===1&&this.state.selectedWorkspace!==void 0&&(a=`sessions`)),await this.focusNavigationTarget(a)}async startSessionFromNavigation(){let e=++this.navigationSelectionSeq;this.navigationSections.advanceAfterSelection(`sessions`),await this.startSessionAndOpenChat(()=>e===this.navigationSelectionSeq)}canStartSession(){return this.state.selectedWorkspace!==void 0}activeSessionIds(){let e=new Set;for(let t of this.quickSwitcherSessions)vc(this.state.sessionStatuses[t.id],this.state.sessionActivities[t.id])&&e.add(t.id);return e}sessionStateKinds(){return tO(this.quickSwitcherSessions,this.state.sessionStatuses,this.state.sessionActivities)}errorSessionIds(){let e=new Set;for(let[t,n]of this.sessionStateKinds())n===`error`&&e.add(t);return e}togglePinnedSession(e){this.pinnedSessionIds=FA(this.pinnedSessionIds,e.id),PA(this.pinnedSessionIds)}waitingSessionIds(){let e=new Set;for(let t of this.quickSwitcherSessions)nh(this.state.sessionStatuses[t.id])&&e.add(t.id);return e}modalLayerOpen(){return this.quickSwitcherOpen||this.mobileToolSheetOpen||this.state.actionPaletteOpen||this.state.projectDialogOpen||this.state.machineDialogOpen||this.state.commandDialog!==void 0||this.state.modelDialog!==void 0||this.state.thinkingDialog!==void 0||this.state.themeDialog!==void 0||this.sessionCleanupDialog!==void 0}pushModalLayerFrame(){window.history.pushState({},``),vt()}openActionPalette(){this.pushModalLayerFrame(),this.setState({actionPaletteOpen:!0})}openProjectDialog(){this.pushModalLayerFrame(),this.setState({projectDialogOpen:!0})}openQuickSwitcher(){Rt(),this.quickSwitcherOpen=!0,this.pushModalLayerFrame(),this.loadQuickSwitcherData(this.quickSwitcherSessions.length>0);let e=L(this.state);e!==``&&this.refreshInterruptedRuns(e)}applyRenameToQuickSwitcher(e,t){this.quickSwitcherSessions=eO(this.quickSwitcherSessions,e,t)}async loadQuickSwitcherData(e=!1){let t=L(this.state);if(!(!e&&this.quickSwitcherMachineId===t&&(this.quickSwitcherSessions.length>0||this.quickSwitcherWorkspaces.length>0||this.quickSwitcherLoading))){this.quickSwitcherLoading=!0;try{let e=this.state.projects.length>0?this.state.projects:await is.projects(t),n=bj((await Promise.all(e.map(async e=>{try{return await os.workspaces(e.id,t)}catch{return[]}}))).flat()),r=await Promise.all(n.map(async e=>{try{return await ss.sessions(e.path,t)}catch{return[]}}));this.quickSwitcherMachineId=t,this.quickSwitcherWorkspaces=n,this.quickSwitcherSessions=bj(r.flat()).sort((e,t)=>Date.parse(t.modified)-Date.parse(e.modified))}catch(e){L(this.state)===t&&this.setState({error:`Failed to load sessions: ${Ej(e)}`})}finally{L(this.state)===t&&(this.quickSwitcherLoading=!1)}}}async openSessionFromQuickSwitcher(e){await this.sessions.selectSession(e),await this.focusChatComposer()}async startSessionAndOpenChat(e=()=>!0){this.sessions.startSession().catch(t=>{e()&&this.setState({error:String(t)})}),e()&&await this.focusChatComposer()}async focusNavigationTarget(e){if(e===`chat`){await this.focusChatComposer();return}await this.focusNavigationSection(e)}async focusNavigationSection(e){if(e===`machines`&&!CA(this.state.machines)){await this.focusNavigationSection(`projects`);return}this.panelCollapse.expandNavigationPanel(),this.appShell.isMobileNavigationLayout&&this.selectMainView(`navigation`),this.navigationSections.expand(e),await this.updateComplete,await Oj(),await this.navigationPanel?.focusSection(e)}async focusChatComposer(){this.state.mainView!==`chat`&&this.selectMainView(`chat`),await this.updateComplete,await Oj(),!this.isRenderedModalOpen()&&this.shouldAutoFocusPrompt()&&this.promptEditor?.focusInput()}async navigateSessionTree(e,t){let n=L(this.state),r=this.state.selectedSession?.id,i=await this.sessions.navigateTree(e,t);return!i.cancelled&&r!==void 0&&L(this.state)===n&&this.state.selectedSession?.id===r&&await this.focusChatComposer(),i}async forkSessionTree(e){return this.sessions.forkFromTree(e)}async openSessionTree(e){this.state.selectedSession?.id!==e.id&&await this.sessions.selectSession(e),await this.sessions.runCommand(`/tree`)}closeSessionTreeNavigator(){this.sessions.closeTreeDialog(),this.focusChatComposer()}renderSessionTreeNavigator(e){return e.treeDialog===void 0?null:g`
|
|
6224
6232
|
<session-tree-navigator
|
|
6225
6233
|
.tree=${e.treeDialog}
|
|
6226
6234
|
.onNavigate=${(e,t)=>this.navigateSessionTree(e,t)}
|
|
@@ -6228,13 +6236,13 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6228
6236
|
.onAbort=${()=>this.sessions.abortTreeNavigation()}
|
|
6229
6237
|
.onCancel=${()=>{this.closeSessionTreeNavigator()}}
|
|
6230
6238
|
></session-tree-navigator>
|
|
6231
|
-
`}visibleWorkspacePanels(){let e=this.state.selectedWorkspace;if(e===void 0)return[];let t=this.createWorkspacePanelContext(e);return this.plugins.getWorkspacePanels().filter(e=>e.visible?.(t)??!0)}workspacePanelEmptyState(){let e=this.state.selectedProject;return this.state.isLoadingProjects?{title:`Loading projects…`,body:`Looking for projects you have added to PI WEB.`}:e===void 0?this.state.projects.length===0?{title:`No projects yet`,body:`Use Actions → Add Project to add a folder. Workspace tools will appear here after you choose a workspace.`}:{title:`Select a project`,body:`Choose a project from the sidebar, then select a workspace to use its tools.`}:this.state.isLoadingWorkspaces?{title:`Loading workspaces…`,body:`Preparing workspace tools for ${e.name}.`}:this.state.workspaces.length===0?{title:`No workspaces found`,body:`${e.name} does not have any available workspaces. Try selecting the project again or re-adding it.`}:{title:`Select a workspace`,body:`Choose a workspace in ${e.name} to use its tools.`}}sessionEmptyMessage(){return this.state.isLoadingProjects?`Loading projects…`:this.state.selectedWorkspace===void 0?this.state.selectedProject===void 0?this.state.projects.length===0?`Add a project to start a session.`:`Select a project and workspace to start a session.`:`Select a workspace to start a session.`:`Select or start a session.`}mobilePanelBadge(e){let t=this.state.selectedWorkspace;if(t!==void 0)return e.badge?.(this.createWorkspacePanelContext(t))}workspaceLabelItems(e){return this.plugins.getWorkspaceLabelItems(this.createWorkspaceLabelContext(e))}createWorkspaceLabelContext(e){let t=sj(this.state),n=r=>{let i=Tb(r,e,t.id);return yb({machine:t,workspace:e,state:this.state,files:this.createWorkspaceFiles(e,t.id),...i===void 0?{}:{backend:i},host:this.createWorkspaceHost()},n)};return n(oj())}createWorkspaceFiles(e,t){return Eb(os,e,t,()=>{this.files.refreshFiles()})}createWorkspaceHost(){return{requestRender:()=>{this.requestUpdate()}}}createWorkspacePanelContext(e){let t=sj(this.state),n=t.id,r=i=>{let a=this.terminalCommandRunsForOrigin(i.registrationPluginId,n),o=Tb(i,e,n);return vb({machine:t,workspace:e,state:this.state,files:this.createWorkspaceFiles(e,n),...o===void 0?{}:{backend:o},prompt:this.createPromptEditor(),terminal:{open:t=>{this.openRuntimeTerminal(n,e,t)},runCommand:t=>a.runCommand({...t,workspace:e})},openTerminal:t=>{this.openRuntimeTerminal(n,e,t)},host:this.createWorkspaceHost(),piWebUnstable:{terminalCommandRuns:a},fileTree:this.state.fileTree,expandedDirs:this.state.expandedDirs,selectedFilePath:this.state.selectedFilePath,selectedFileContent:this.state.selectedFileContent,selectedFileLoadError:this.state.selectedFileLoadError,fileTreeStale:this.state.fileTreeStale,activeTerminalCount:this.state.activeTerminalCount,selectedTerminalId:this.state.selectedTerminalId,terminalAutoStart:this.terminalAutoStartWorkspaceId===e.id,workspaceUploadDefaultFolder:Zs(e.effectiveConfig,this.workspaceUploadDefaultFolder),onRefreshFiles:()=>{this.files.refreshFiles()},onExpandDir:e=>{this.files.expandDir(e)},onSelectFile:e=>{this.files.selectFile(e)},onStartWorkspaceUpload:(e,t)=>this.files.startWorkspaceUpload(e,t),onCancelWorkspaceUpload:e=>{this.files.cancelWorkspaceUpload(e)},onClearWorkspaceUpload:e=>{this.files.clearWorkspaceUpload(e)},onSelectTerminal:(e,t)=>{this.selectTerminal(e,t)}},r)};return r(oj())}invalidateWorkspacePanels(e){let t=this.state.selectedWorkspace;return t===void 0?Promise.resolve():this.plugins.invalidateWorkspacePanels(this.createWorkspacePanelContext(t),e)}getActions(){return _x(this.getDefaultActions(),this.shortcutConfig)}getDefaultActions(){return[...this.plugins.getActions(this.createPluginRuntimeContext()),...this.workspaceSurfaceActions(),...this.sessionActions(),...this.navigationFocusActions(),...this.panelLayoutActions()]}workspaceSurfaceActions(){return[{id:`core:workspace.refresh-current`,title:`Refresh Current Panel`,shortcut:`mod+shift+r`,group:`Workspace`,enabled:this.state.selectedWorkspace!==void 0,run:()=>this.refreshCurrentWorkspaceSurface()}]}sessionActions(){return[{id:`app.sessions.quick-switch`,title:`Open Session`,description:`Search and open a session, or start a new one, without walking the navigation panel`,shortcut:`mod+p`,group:`Sessions`,run:()=>{this.openQuickSwitcher()}},{id:`app.sessions.new`,title:`New Session`,description:`Start a session in the selected workspace`,shortcut:`mod+shift+n`,group:`Sessions`,enabled:this.canStartSession(),...this.canStartSession()?{}:{disabledReason:`Select a workspace first`},run:()=>{this.startSessionAndOpenChat()}},{id:`app.sessions.cleanup`,title:`Clean Up Sessions`,description:`Preview and manually clean up idle or archived sessions on the selected machine`,group:`Sessions`,run:()=>{this.openSessionCleanupDialog()}}]}panelLayoutActions(){return[{id:`app.layout.reset-navigation-panel-size`,title:`Reset Navigation Panel Size`,description:`Restore the navigation panel to its default width`,group:`View`,run:()=>{this.resetResizablePanel(`navigation`)}},{id:`app.layout.reset-workspace-panel-size`,title:`Reset Workspace Panel Size`,description:`Restore the workspace panel to its default width`,group:`View`,run:()=>{this.resetResizablePanel(`workspace`)}},{id:`app.layout.reset-panel-sizes`,title:`Reset Panel Sizes`,description:`Restore all side panels to their default widths`,group:`View`,run:()=>{this.resetResizablePanels()}}]}navigationFocusActions(){return[{id:`app.navigation.focus-machines`,title:`Focus Machines`,description:`Move keyboard focus to the machine selector`,shortcut:`mod+g m`,group:`Navigation`,run:()=>this.focusNavigationSection(`machines`)},{id:`app.navigation.focus-projects`,title:`Focus Projects`,description:`Move keyboard focus to the projects list`,shortcut:`mod+g p`,group:`Navigation`,run:()=>this.focusNavigationSection(`projects`)},{id:`app.navigation.focus-workspaces`,title:`Focus Workspaces`,description:`Move keyboard focus to the workspaces list`,shortcut:`mod+g w`,group:`Navigation`,run:()=>this.focusNavigationSection(`workspaces`)},{id:`app.navigation.focus-sessions`,title:`Focus Sessions`,description:`Move keyboard focus to the sessions list`,shortcut:`mod+g s`,group:`Navigation`,run:()=>this.focusNavigationSection(`sessions`)}]}ensureGatewayPluginsLoaded(){let e=this.gatewayPluginLoadPromise;if(e!==void 0)return e;let t=this.loadExternalPlugins().then(e=>{!e&&this.gatewayPluginLoadPromise===t&&(this.gatewayPluginLoadPromise=void 0)});return this.gatewayPluginLoadPromise=t,t}loadExternalPlugins(){return this.registerExternalPlugins(`PI WEB plugins`,()=>Yy(`pi-web-plugins/manifest.json`,{shouldLoadPlugin:e=>!this.plugins.hasPlugin(e.id)}))}async loadPluginsForSelectedMachine(){await this.ensureGatewayPluginsLoaded();let e=this.state.selectedMachine;e?.kind===`remote`&&await this.loadPluginsForMachine(e)}async loadPluginsForMachine(e){if(await this.ensureGatewayPluginsLoaded(),e.kind!==`remote`||this.loadedMachinePluginIds.has(e.id))return;let t=this.state.machineRuntimes[e.id];if(t?.ok===!0&&!bn(t,tn.pluginLifecycle)){console.warn(`PI WEB plugins from ${e.name} require a matching plugin lifecycle capability; update and restart PI WEB on that machine`);return}let n=this.machinePluginLoadPromises.get(e.id);if(n!==void 0)return n;let r=this.registerExternalPlugins(`PI WEB plugins from ${e.name}`,()=>Yy(`api/machines/${encodeURIComponent(e.id)}/pi-web-plugins/manifest.json`,{machineId:e.id,shouldLoadPlugin:t=>!this.plugins.hasPlugin(bc(e.id,t.id))&&this.plugins.shouldLoadRemotePlugin(t.id,t.machineSpecific)})).then(t=>{t&&this.loadedMachinePluginIds.add(e.id)}).finally(()=>{this.machinePluginLoadPromises.delete(e.id)});this.machinePluginLoadPromises.set(e.id,r),await r}async registerExternalPlugins(e,t){try{let e=await t(),n=e.failures.length===0;for(let t of e.failures)console.warn(`Failed to load PI WEB plugin ${t.entry.id} (${t.entry.module})`,t.error);for(let t of e.registrations)if(!this.plugins.hasPlugin(t.id))try{this.plugins.register(t)}catch(e){n=!1,console.warn(`Failed to register PI WEB plugin ${t.id}`,e)}return this.applyPreferredTheme(!1),this.requestUpdate(),n}catch(t){return console.warn(`Failed to load ${e}`,t),!1}}createPromptEditor(){return{insertText:e=>{let t=this.promptEditor?.view;if(!t)return;t.hasFocus||t.focus();let n=t.state.selection.main;t.dispatch({changes:{from:n.from,to:n.to,insert:e},selection:{anchor:n.from+e.length}})},getText:()=>this.promptEditor?.view?.state.doc.toString()??``,getSelection:()=>{let e=this.promptEditor?.view;if(!e)return null;let t=e.state.selection.main;return t.empty?null:{start:t.from,end:t.to,text:e.state.sliceDoc(t.from,t.to)}}}}createPluginRuntimeContext(){let e=t=>_b({state:this.state,prompt:this.createPromptEditor(),piWebUnstable:{terminalCommandRuns:this.terminalCommandRunsForOrigin(t),openSettings:e=>{this.openSettings(e)}},openActionPalette:()=>{this.openActionPalette()},focusPrompt:()=>{this.focusChatComposer()},addProject:()=>{this.openProjectDialog()},addMachine:()=>{this.openMachineDialog()},refreshSelectedMachine:async()=>{await Promise.all([this.machines.refreshMachineHealth(),this.machines.refreshMachineRuntime()])},removeSelectedMachine:()=>this.removeMachine(),openSelectedMachine:()=>{this.openSelectedMachine()},configureAuth:()=>this.auth.openLogin(),logoutAuth:()=>this.auth.openLogout(),openThemePicker:()=>{this.openThemeDialog()},openModelPicker:()=>this.openModelDialog(),openThinkingLevelPicker:()=>this.openThinkingDialog(),selectMainView:e=>{this.selectMainView(e)},selectWorkspaceTool:e=>{this.openWorkspaceTool(e)},openTerminal:e=>{this.openTerminal(e)},refreshFiles:()=>this.files.refreshFiles(),refreshWorkspacePanels:e=>this.invalidateWorkspacePanels(e),refreshAppData:()=>this.refreshAppData(),checkForPiWebUpdates:()=>this.piWebStatusController.checkForUpdates(),reloadPage:()=>{this.hardReloadApp()},deleteWorkspace:e=>this.deleteWorkspace(e),startSession:()=>this.withChatScrollTransition(()=>this.startSessionAndOpenChat()),archiveSession:()=>this.sessions.archiveSession(),reloadSession:()=>this.sessions.reloadSession(),deleteCachedNewSession:()=>this.sessions.deleteCachedNewSession(),stopActiveWork:async()=>{await this.sessions.stopActiveWork()}},e);return e(`core`)}async deleteWorkspace(e=this.state.selectedWorkspace){if(e===void 0)return;if(!rg(e)){this.setState({error:`Workspace removal is not available`});return}if(cg(this.state,e))return;let t=e.removal,n=ig(e);if(t===void 0||n===void 0||!confirm(n))return;let r=L(this.state);try{let n=await os.deleteWorkspace(e.projectId,e.id,t.precondition,r);if(L(this.state)!==r)return;this.recordWorkspaceDeletionRun(n,r);let i=await this.workspaceForCommandRun(n);if(L(this.state)!==r)return;i!==void 0&&this.openRuntimeTerminal(r,i,{terminalId:n.terminalId})}catch(e){L(this.state)===r&&this.setState({error:`Failed to start workspace removal: ${Tj(e)}`})}}async workspaceForCommandRun(e){let t=this.state.selectedProject?.id===e.projectId?this.state.workspaces:this.state.workspacesByProjectId[e.projectId];return(t===void 0||t.length===0)&&(t=await this.workspaces.refreshProjectWorkspaces(e.projectId)),t.find(t=>t.id===e.workspaceId)}recordWorkspaceDeletionRun(e,t){if(L(this.state)!==t)return;let n=lg(e);n!==void 0&&(this.setState({workspaceDeletionRuns:{...this.state.workspaceDeletionRuns,[n]:e}}),this.updateWorkspaceDeletionPolling())}async refreshWorkspaceDeletionRuns(){if(this.refreshingWorkspaceDeletionRuns)return;let e=L(this.state),t=this.state.selectedProject;if(t===void 0){this.setState({workspaceDeletionRuns:{}}),this.updateWorkspaceDeletionPolling();return}this.refreshingWorkspaceDeletionRuns=!0;try{let n=await this.terminalCommandRunsForOrigin(`core`,e).listCommandRuns(ag(t.id));if(L(this.state)!==e)return;let r=og(n);this.setState({workspaceDeletionRuns:r});for(let t of Object.values(r))ug(t)||await this.handleCompletedWorkspaceDeletionRun(t,e)}catch(e){console.warn(`Failed to refresh workspace deletion runs`,e)}finally{this.refreshingWorkspaceDeletionRuns=!1,this.updateWorkspaceDeletionPolling()}}updateWorkspaceDeletionPolling(){let e=Object.values(this.state.workspaceDeletionRuns).some(ug);if(e&&this.workspaceDeletionPollTimer===void 0){this.workspaceDeletionPollTimer=window.setInterval(()=>{this.refreshWorkspaceDeletionRuns()},1e3);return}!e&&this.workspaceDeletionPollTimer!==void 0&&(window.clearInterval(this.workspaceDeletionPollTimer),this.workspaceDeletionPollTimer=void 0)}async handleCompletedWorkspaceDeletionRun(e,t=L(this.state)){if(L(this.state)!==t)return;let n=Cj(t,e.id);if(this.handledWorkspaceDeletionRunIds.has(n))return;let r=lg(e);if(r!==void 0){if(this.handledWorkspaceDeletionRunIds.add(n),e.status===`succeeded`){if(await this.workspaces.refreshAfterWorkspaceDeleted(e.projectId,r),L(this.state)!==t)return;this.setState({workspaceDeletionRuns:Ej(this.state.workspaceDeletionRuns,r)}),this.updateWorkspaceDeletionPolling();return}e.status===`failed`&&(this.setState({error:`Workspace removal failed. See terminal output.`}),this.updateWorkspaceDeletionPolling())}}async focusPromptEditorSoon(){await this.updateComplete,this.shouldAutoFocusPrompt()&&this.promptEditor?.focusInput()}openMachineDialog(){this.pushModalLayerFrame(),this.setState({machineDialogOpen:!0,error:``})}async submitMachineDialog(e){await this.machines.addMachine(e)!==void 0&&(this.setState({machineDialogOpen:!1}),this.schedulePiWebStatusRefresh())}async renameMachine(e,t){let n=t.trim();n===``||n===e.name||await this.machines.updateMachine(e,{name:n})}async removeMachine(e=this.state.selectedMachine){if(e===void 0||e.kind===`local`||!window.confirm(`Remove ${e.name}?\n\nThis only removes it from this PI WEB gateway.`))return;let t=this.state.selectedMachine?.id===e.id;t&&this.rememberCurrentMachineNavigation();let n=await this.machines.deleteMachine(e,{selectFallback:!t});this.state.machines.some(t=>t.id===e.id)||this.machineNavigation.forget(e.id),t&&n!==void 0&&await this.selectMachineWithMemory(n,{rememberCurrent:!1})}openSelectedMachine(){let e=this.state.selectedMachine;e?.kind!==`remote`||e.baseUrl===void 0||window.open(e.baseUrl,`_blank`,`noopener,noreferrer`)}runAction(e){Promise.resolve().then(()=>e.run()).catch(t=>{let n=t instanceof Error?t.message:String(t);console.warn(`Action failed: ${e.id}`,t),this.setState({error:`Action failed: ${n}`})})}async openModelDialog(){let[e,t]=await Promise.all([this.sessions.listModels(),this.sessions.listModelCatalog()]),n=this.currentModelValue();this.setState({modelDialog:{title:`Select Model`,...n===void 0?{}:{selectedValue:n},options:this.modelDialogOptions(e),catalog:t}})}currentModelValue(){let e=this.state.status?.model?.provider,t=this.state.status?.model?.id;return e!==void 0&&t!==void 0?`${e}/${t}`:void 0}modelDialogOptions(e){let t=this.currentModelValue();return e.map(e=>{let n=e.provider??``,r=e.id??``,i=`${n}/${r}`;return{value:i,label:`${r}${i===t?` ✓ current`:``}`,description:n}})}async pickModel(e){this.setState({modelDialog:void 0});let t=e.indexOf(`/`);t<=0||await this.sessions.setModel(e.slice(0,t),e.slice(t+1))}openThemeDialog(){let e=this.plugins.getThemes(),t=this.resolveCurrentThemePreference(e),n=t.selectedTheme?.id,r=this.themePreference.auto?QA:ZA;this.pushModalLayerFrame(),this.setState({themeDialog:{title:`Select Theme`,selectedValue:n===void 0?r:`${$A}${n}`,options:[{value:r,label:`Auto ${this.themePreference.auto?`✓ on`:`off`}`,description:this.autoThemeDescription(t)},...e.map(e=>({value:`${$A}${e.id}`,label:this.themeOptionLabel(e,n),description:this.themeOptionDescription(e)}))]}})}setUiScale(e){this.uiScale=Yh(e),$h(this.uiScale),Qh(this.uiScale)}selectTheme(e){let t=this.plugins.getThemes().find(t=>t.id===e);t!==void 0&&(this.themePreference={themeId:t.id,auto:this.themePreference.auto},this.applyPreferredTheme(!0))}setFollowSystemTheme(e){this.themePreference={themeId:this.themePreference.themeId,auto:e},this.applyPreferredTheme(!0)}pickTheme(e){if(this.setState({themeDialog:void 0}),e===ZA||e===QA){let t=this.resolveCurrentThemePreference().selectedTheme?.id;if(t===void 0)return;this.themePreference={themeId:t,auto:e===ZA},this.applyPreferredTheme(!0);return}if(!e.startsWith($A))return;let t=e.slice(6),n=this.plugins.getThemes().find(e=>e.id===t);n!==void 0&&(this.themePreference={themeId:n.id,auto:this.themePreference.auto},this.applyPreferredTheme(!0))}applyPreferredTheme(e){let t=this.resolveCurrentThemePreference().activeTheme;t!==void 0&&(this.activeThemeId=t.id,Lh(t),e&&Ih(this.themePreference))}resolveCurrentThemePreference(e=this.plugins.getThemes()){return Rh({themes:e,themePairs:this.plugins.getThemePairs(),preference:this.themePreference,prefersLight:this.systemPrefersLight()})}themePairForTheme(e){return Bh(this.plugins.getThemePairs(),e)}systemPrefersLight(){return this.systemLightThemeMedia?.matches??!1}autoThemeDescription(e){return!this.themePreference.auto||e.selectedTheme===void 0?`Follow the system light/dark preference when the selected theme has a pair.`:e.selectedThemePair===void 0?`On, but the selected theme has no light/dark pair, so it will stay selected.`:`On · ${e.selectedThemePair.name} follows the system ${this.systemPrefersLight()?`light`:`dark`} preference.`}themeOptionLabel(e,t){let n=[...e.id===t?[`selected`]:[],...e.id===this.activeThemeId&&e.id!==t?[`active`]:[]];return n.length===0?e.name:`${e.name} ✓ ${n.join(` · `)}`}themeOptionDescription(e){let t=[e.colorScheme];return this.themePairForTheme(e.id)!==void 0&&t.push(`auto pair`),e.description!==void 0&&t.push(e.description),t.join(` · `)}async openThinkingDialog(){let e=await this.sessions.listThinkingLevels(),t=this.state.status?.thinkingLevel??`off`;this.pushModalLayerFrame(),this.setState({thinkingDialog:{title:`Select Thinking Level`,selectedValue:t,options:e.map(e=>{let n=Oj(e);return{value:e,label:`${e}${e===t?` ✓ current`:``}`,...n===void 0?{}:{description:n}}})}})}async pickThinking(e){this.setState({thinkingDialog:void 0}),e!==``&&await this.sessions.setThinkingLevel(e)}async runGoalCommand(e){this.state.selectedSession!==void 0&&await this.sendPrompt(e)}async sendPrompt(e,t,n,r,i){return!(n!==void 0&&n.length>0)&&t===void 0&&this.auth.handleSlashCommand(e)?!0:await this.sessions.send(e,t,n,r,i)}restoreToComposer(e){let t=e.map(e=>e.text).filter(e=>e.trim()!==``);t.length!==0&&(this.promptEditor?.replaceText(t.join(`
|
|
6239
|
+
`}visibleWorkspacePanels(){let e=this.state.selectedWorkspace;if(e===void 0)return[];let t=this.createWorkspacePanelContext(e);return this.plugins.getWorkspacePanels().filter(e=>e.visible?.(t)??!0)}workspacePanelEmptyState(){let e=this.state.selectedProject;return this.state.isLoadingProjects?{title:`Loading projects…`,body:`Looking for projects you have added to PI WEB.`}:e===void 0?this.state.projects.length===0?{title:`No projects yet`,body:`Use Actions → Add Project to add a folder. Workspace tools will appear here after you choose a workspace.`}:{title:`Select a project`,body:`Choose a project from the sidebar, then select a workspace to use its tools.`}:this.state.isLoadingWorkspaces?{title:`Loading workspaces…`,body:`Preparing workspace tools for ${e.name}.`}:this.state.workspaces.length===0?{title:`No workspaces found`,body:`${e.name} does not have any available workspaces. Try selecting the project again or re-adding it.`}:{title:`Select a workspace`,body:`Choose a workspace in ${e.name} to use its tools.`}}sessionEmptyMessage(){return this.state.isLoadingProjects?`Loading projects…`:this.state.selectedWorkspace===void 0?this.state.selectedProject===void 0?this.state.projects.length===0?`Add a project to start a session.`:`Select a project and workspace to start a session.`:`Select a workspace to start a session.`:`Select or start a session.`}mobilePanelBadge(e){let t=this.state.selectedWorkspace;if(t!==void 0)return e.badge?.(this.createWorkspacePanelContext(t))}workspaceLabelItems(e){return this.plugins.getWorkspaceLabelItems(this.createWorkspaceLabelContext(e))}createWorkspaceLabelContext(e){let t=cj(this.state),n=r=>{let i=Tb(r,e,t.id);return yb({machine:t,workspace:e,state:this.state,files:this.createWorkspaceFiles(e,t.id),...i===void 0?{}:{backend:i},host:this.createWorkspaceHost()},n)};return n(sj())}createWorkspaceFiles(e,t){return Eb(os,e,t,()=>{this.files.refreshFiles()})}createWorkspaceHost(){return{requestRender:()=>{this.requestUpdate()}}}createWorkspacePanelContext(e){let t=cj(this.state),n=t.id,r=i=>{let a=this.terminalCommandRunsForOrigin(i.registrationPluginId,n),o=Tb(i,e,n);return vb({machine:t,workspace:e,state:this.state,files:this.createWorkspaceFiles(e,n),...o===void 0?{}:{backend:o},prompt:this.createPromptEditor(),terminal:{open:t=>{this.openRuntimeTerminal(n,e,t)},runCommand:t=>a.runCommand({...t,workspace:e})},openTerminal:t=>{this.openRuntimeTerminal(n,e,t)},host:this.createWorkspaceHost(),piWebUnstable:{terminalCommandRuns:a},fileTree:this.state.fileTree,expandedDirs:this.state.expandedDirs,selectedFilePath:this.state.selectedFilePath,selectedFileContent:this.state.selectedFileContent,selectedFileLoadError:this.state.selectedFileLoadError,fileTreeStale:this.state.fileTreeStale,activeTerminalCount:this.state.activeTerminalCount,selectedTerminalId:this.state.selectedTerminalId,terminalAutoStart:this.terminalAutoStartWorkspaceId===e.id,workspaceUploadDefaultFolder:Zs(e.effectiveConfig,this.workspaceUploadDefaultFolder),onRefreshFiles:()=>{this.files.refreshFiles()},onExpandDir:e=>{this.files.expandDir(e)},onSelectFile:e=>{this.files.selectFile(e)},onStartWorkspaceUpload:(e,t)=>this.files.startWorkspaceUpload(e,t),onCancelWorkspaceUpload:e=>{this.files.cancelWorkspaceUpload(e)},onClearWorkspaceUpload:e=>{this.files.clearWorkspaceUpload(e)},onSelectTerminal:(e,t)=>{this.selectTerminal(e,t)}},r)};return r(sj())}invalidateWorkspacePanels(e){let t=this.state.selectedWorkspace;return t===void 0?Promise.resolve():this.plugins.invalidateWorkspacePanels(this.createWorkspacePanelContext(t),e)}getActions(){return _x(this.getDefaultActions(),this.shortcutConfig)}getDefaultActions(){return[...this.plugins.getActions(this.createPluginRuntimeContext()),...this.workspaceSurfaceActions(),...this.sessionActions(),...this.navigationFocusActions(),...this.panelLayoutActions()]}workspaceSurfaceActions(){return[{id:`core:workspace.refresh-current`,title:`Refresh Current Panel`,shortcut:`mod+shift+r`,group:`Workspace`,enabled:this.state.selectedWorkspace!==void 0,run:()=>this.refreshCurrentWorkspaceSurface()}]}sessionActions(){return[{id:`app.sessions.quick-switch`,title:`Open Session`,description:`Search and open a session, or start a new one, without walking the navigation panel`,shortcut:`mod+p`,group:`Sessions`,run:()=>{this.openQuickSwitcher()}},{id:`app.sessions.new`,title:`New Session`,description:`Start a session in the selected workspace`,shortcut:`mod+shift+n`,group:`Sessions`,enabled:this.canStartSession(),...this.canStartSession()?{}:{disabledReason:`Select a workspace first`},run:()=>{this.startSessionAndOpenChat()}},{id:`app.sessions.cleanup`,title:`Clean Up Sessions`,description:`Preview and manually clean up idle or archived sessions on the selected machine`,group:`Sessions`,run:()=>{this.openSessionCleanupDialog()}}]}panelLayoutActions(){return[{id:`app.layout.reset-navigation-panel-size`,title:`Reset Navigation Panel Size`,description:`Restore the navigation panel to its default width`,group:`View`,run:()=>{this.resetResizablePanel(`navigation`)}},{id:`app.layout.reset-workspace-panel-size`,title:`Reset Workspace Panel Size`,description:`Restore the workspace panel to its default width`,group:`View`,run:()=>{this.resetResizablePanel(`workspace`)}},{id:`app.layout.reset-panel-sizes`,title:`Reset Panel Sizes`,description:`Restore all side panels to their default widths`,group:`View`,run:()=>{this.resetResizablePanels()}}]}navigationFocusActions(){return[{id:`app.navigation.focus-machines`,title:`Focus Machines`,description:`Move keyboard focus to the machine selector`,shortcut:`mod+g m`,group:`Navigation`,run:()=>this.focusNavigationSection(`machines`)},{id:`app.navigation.focus-projects`,title:`Focus Projects`,description:`Move keyboard focus to the projects list`,shortcut:`mod+g p`,group:`Navigation`,run:()=>this.focusNavigationSection(`projects`)},{id:`app.navigation.focus-workspaces`,title:`Focus Workspaces`,description:`Move keyboard focus to the workspaces list`,shortcut:`mod+g w`,group:`Navigation`,run:()=>this.focusNavigationSection(`workspaces`)},{id:`app.navigation.focus-sessions`,title:`Focus Sessions`,description:`Move keyboard focus to the sessions list`,shortcut:`mod+g s`,group:`Navigation`,run:()=>this.focusNavigationSection(`sessions`)}]}ensureGatewayPluginsLoaded(){let e=this.gatewayPluginLoadPromise;if(e!==void 0)return e;let t=this.loadExternalPlugins().then(e=>{!e&&this.gatewayPluginLoadPromise===t&&(this.gatewayPluginLoadPromise=void 0)});return this.gatewayPluginLoadPromise=t,t}loadExternalPlugins(){return this.registerExternalPlugins(`PI WEB plugins`,()=>Yy(`pi-web-plugins/manifest.json`,{shouldLoadPlugin:e=>!this.plugins.hasPlugin(e.id)}))}async loadPluginsForSelectedMachine(){await this.ensureGatewayPluginsLoaded();let e=this.state.selectedMachine;e?.kind===`remote`&&await this.loadPluginsForMachine(e)}async loadPluginsForMachine(e){if(await this.ensureGatewayPluginsLoaded(),e.kind!==`remote`||this.loadedMachinePluginIds.has(e.id))return;let t=this.state.machineRuntimes[e.id];if(t?.ok===!0&&!bn(t,tn.pluginLifecycle)){console.warn(`PI WEB plugins from ${e.name} require a matching plugin lifecycle capability; update and restart PI WEB on that machine`);return}let n=this.machinePluginLoadPromises.get(e.id);if(n!==void 0)return n;let r=this.registerExternalPlugins(`PI WEB plugins from ${e.name}`,()=>Yy(`api/machines/${encodeURIComponent(e.id)}/pi-web-plugins/manifest.json`,{machineId:e.id,shouldLoadPlugin:t=>!this.plugins.hasPlugin(bc(e.id,t.id))&&this.plugins.shouldLoadRemotePlugin(t.id,t.machineSpecific)})).then(t=>{t&&this.loadedMachinePluginIds.add(e.id)}).finally(()=>{this.machinePluginLoadPromises.delete(e.id)});this.machinePluginLoadPromises.set(e.id,r),await r}async registerExternalPlugins(e,t){try{let e=await t(),n=e.failures.length===0;for(let t of e.failures)console.warn(`Failed to load PI WEB plugin ${t.entry.id} (${t.entry.module})`,t.error);for(let t of e.registrations)if(!this.plugins.hasPlugin(t.id))try{this.plugins.register(t)}catch(e){n=!1,console.warn(`Failed to register PI WEB plugin ${t.id}`,e)}return this.applyPreferredTheme(!1),this.requestUpdate(),n}catch(t){return console.warn(`Failed to load ${e}`,t),!1}}createPromptEditor(){return{insertText:e=>{let t=this.promptEditor?.view;if(!t)return;t.hasFocus||t.focus();let n=t.state.selection.main;t.dispatch({changes:{from:n.from,to:n.to,insert:e},selection:{anchor:n.from+e.length}})},getText:()=>this.promptEditor?.view?.state.doc.toString()??``,getSelection:()=>{let e=this.promptEditor?.view;if(!e)return null;let t=e.state.selection.main;return t.empty?null:{start:t.from,end:t.to,text:e.state.sliceDoc(t.from,t.to)}}}}createPluginRuntimeContext(){let e=t=>_b({state:this.state,prompt:this.createPromptEditor(),piWebUnstable:{terminalCommandRuns:this.terminalCommandRunsForOrigin(t),openSettings:e=>{this.openSettings(e)}},openActionPalette:()=>{this.openActionPalette()},focusPrompt:()=>{this.focusChatComposer()},addProject:()=>{this.openProjectDialog()},addMachine:()=>{this.openMachineDialog()},refreshSelectedMachine:async()=>{await Promise.all([this.machines.refreshMachineHealth(),this.machines.refreshMachineRuntime()])},removeSelectedMachine:()=>this.removeMachine(),openSelectedMachine:()=>{this.openSelectedMachine()},configureAuth:()=>this.auth.openLogin(),logoutAuth:()=>this.auth.openLogout(),openThemePicker:()=>{this.openThemeDialog()},openModelPicker:()=>this.openModelDialog(),openThinkingLevelPicker:()=>this.openThinkingDialog(),selectMainView:e=>{this.selectMainView(e)},selectWorkspaceTool:e=>{this.openWorkspaceTool(e)},openTerminal:e=>{this.openTerminal(e)},refreshFiles:()=>this.files.refreshFiles(),refreshWorkspacePanels:e=>this.invalidateWorkspacePanels(e),refreshAppData:()=>this.refreshAppData(),checkForPiWebUpdates:()=>this.piWebStatusController.checkForUpdates(),reloadPage:()=>{this.hardReloadApp()},deleteWorkspace:e=>this.deleteWorkspace(e),startSession:()=>this.withChatScrollTransition(()=>this.startSessionAndOpenChat()),archiveSession:()=>this.sessions.archiveSession(),reloadSession:()=>this.sessions.reloadSession(),deleteCachedNewSession:()=>this.sessions.deleteCachedNewSession(),stopActiveWork:async()=>{await this.sessions.stopActiveWork()}},e);return e(`core`)}async deleteWorkspace(e=this.state.selectedWorkspace){if(e===void 0)return;if(!rg(e)){this.setState({error:`Workspace removal is not available`});return}if(cg(this.state,e))return;let t=e.removal,n=ig(e);if(t===void 0||n===void 0||!confirm(n))return;let r=L(this.state);try{let n=await os.deleteWorkspace(e.projectId,e.id,t.precondition,r);if(L(this.state)!==r)return;this.recordWorkspaceDeletionRun(n,r);let i=await this.workspaceForCommandRun(n);if(L(this.state)!==r)return;i!==void 0&&this.openRuntimeTerminal(r,i,{terminalId:n.terminalId})}catch(e){L(this.state)===r&&this.setState({error:`Failed to start workspace removal: ${Ej(e)}`})}}async workspaceForCommandRun(e){let t=this.state.selectedProject?.id===e.projectId?this.state.workspaces:this.state.workspacesByProjectId[e.projectId];return(t===void 0||t.length===0)&&(t=await this.workspaces.refreshProjectWorkspaces(e.projectId)),t.find(t=>t.id===e.workspaceId)}recordWorkspaceDeletionRun(e,t){if(L(this.state)!==t)return;let n=lg(e);n!==void 0&&(this.setState({workspaceDeletionRuns:{...this.state.workspaceDeletionRuns,[n]:e}}),this.updateWorkspaceDeletionPolling())}async refreshWorkspaceDeletionRuns(){if(this.refreshingWorkspaceDeletionRuns)return;let e=L(this.state),t=this.state.selectedProject;if(t===void 0){this.setState({workspaceDeletionRuns:{}}),this.updateWorkspaceDeletionPolling();return}this.refreshingWorkspaceDeletionRuns=!0;try{let n=await this.terminalCommandRunsForOrigin(`core`,e).listCommandRuns(ag(t.id));if(L(this.state)!==e)return;let r=og(n);this.setState({workspaceDeletionRuns:r});for(let t of Object.values(r))ug(t)||await this.handleCompletedWorkspaceDeletionRun(t,e)}catch(e){console.warn(`Failed to refresh workspace deletion runs`,e)}finally{this.refreshingWorkspaceDeletionRuns=!1,this.updateWorkspaceDeletionPolling()}}updateWorkspaceDeletionPolling(){let e=Object.values(this.state.workspaceDeletionRuns).some(ug);if(e&&this.workspaceDeletionPollTimer===void 0){this.workspaceDeletionPollTimer=window.setInterval(()=>{this.refreshWorkspaceDeletionRuns()},1e3);return}!e&&this.workspaceDeletionPollTimer!==void 0&&(window.clearInterval(this.workspaceDeletionPollTimer),this.workspaceDeletionPollTimer=void 0)}async handleCompletedWorkspaceDeletionRun(e,t=L(this.state)){if(L(this.state)!==t)return;let n=wj(t,e.id);if(this.handledWorkspaceDeletionRunIds.has(n))return;let r=lg(e);if(r!==void 0){if(this.handledWorkspaceDeletionRunIds.add(n),e.status===`succeeded`){if(await this.workspaces.refreshAfterWorkspaceDeleted(e.projectId,r),L(this.state)!==t)return;this.setState({workspaceDeletionRuns:Dj(this.state.workspaceDeletionRuns,r)}),this.updateWorkspaceDeletionPolling();return}e.status===`failed`&&(this.setState({error:`Workspace removal failed. See terminal output.`}),this.updateWorkspaceDeletionPolling())}}async focusPromptEditorSoon(){await this.updateComplete,this.shouldAutoFocusPrompt()&&this.promptEditor?.focusInput()}openMachineDialog(){this.pushModalLayerFrame(),this.setState({machineDialogOpen:!0,error:``})}async submitMachineDialog(e){await this.machines.addMachine(e)!==void 0&&(this.setState({machineDialogOpen:!1}),this.schedulePiWebStatusRefresh())}async renameMachine(e,t){let n=t.trim();n===``||n===e.name||await this.machines.updateMachine(e,{name:n})}async removeMachine(e=this.state.selectedMachine){if(e===void 0||e.kind===`local`||!window.confirm(`Remove ${e.name}?\n\nThis only removes it from this PI WEB gateway.`))return;let t=this.state.selectedMachine?.id===e.id;t&&this.rememberCurrentMachineNavigation();let n=await this.machines.deleteMachine(e,{selectFallback:!t});this.state.machines.some(t=>t.id===e.id)||this.machineNavigation.forget(e.id),t&&n!==void 0&&await this.selectMachineWithMemory(n,{rememberCurrent:!1})}openSelectedMachine(){let e=this.state.selectedMachine;e?.kind!==`remote`||e.baseUrl===void 0||window.open(e.baseUrl,`_blank`,`noopener,noreferrer`)}runAction(e){Promise.resolve().then(()=>e.run()).catch(t=>{let n=t instanceof Error?t.message:String(t);console.warn(`Action failed: ${e.id}`,t),this.setState({error:`Action failed: ${n}`})})}async openModelDialog(){let[e,t]=await Promise.all([this.sessions.listModels(),this.sessions.listModelCatalog()]),n=this.currentModelValue();this.setState({modelDialog:{title:`Select Model`,...n===void 0?{}:{selectedValue:n},options:this.modelDialogOptions(e),catalog:t}})}currentModelValue(){let e=this.state.status?.model?.provider,t=this.state.status?.model?.id;return e!==void 0&&t!==void 0?`${e}/${t}`:void 0}modelDialogOptions(e){let t=this.currentModelValue();return e.map(e=>{let n=e.provider??``,r=e.id??``,i=`${n}/${r}`;return{value:i,label:`${r}${i===t?` ✓ current`:``}`,description:n}})}async pickModel(e){this.setState({modelDialog:void 0});let t=e.indexOf(`/`);t<=0||await this.sessions.setModel(e.slice(0,t),e.slice(t+1))}openThemeDialog(){let e=this.plugins.getThemes(),t=this.resolveCurrentThemePreference(e),n=t.selectedTheme?.id,r=this.themePreference.auto?$A:QA;this.pushModalLayerFrame(),this.setState({themeDialog:{title:`Select Theme`,selectedValue:n===void 0?r:`${ej}${n}`,options:[{value:r,label:`Auto ${this.themePreference.auto?`✓ on`:`off`}`,description:this.autoThemeDescription(t)},...e.map(e=>({value:`${ej}${e.id}`,label:this.themeOptionLabel(e,n),description:this.themeOptionDescription(e)}))]}})}setUiScale(e){this.uiScale=Yh(e),$h(this.uiScale),Qh(this.uiScale)}selectTheme(e){let t=this.plugins.getThemes().find(t=>t.id===e);t!==void 0&&(this.themePreference={themeId:t.id,auto:this.themePreference.auto},this.applyPreferredTheme(!0))}setFollowSystemTheme(e){this.themePreference={themeId:this.themePreference.themeId,auto:e},this.applyPreferredTheme(!0)}pickTheme(e){if(this.setState({themeDialog:void 0}),e===QA||e===$A){let t=this.resolveCurrentThemePreference().selectedTheme?.id;if(t===void 0)return;this.themePreference={themeId:t,auto:e===QA},this.applyPreferredTheme(!0);return}if(!e.startsWith(ej))return;let t=e.slice(6),n=this.plugins.getThemes().find(e=>e.id===t);n!==void 0&&(this.themePreference={themeId:n.id,auto:this.themePreference.auto},this.applyPreferredTheme(!0))}applyPreferredTheme(e){let t=this.resolveCurrentThemePreference().activeTheme;t!==void 0&&(this.activeThemeId=t.id,Lh(t),e&&Ih(this.themePreference))}resolveCurrentThemePreference(e=this.plugins.getThemes()){return Rh({themes:e,themePairs:this.plugins.getThemePairs(),preference:this.themePreference,prefersLight:this.systemPrefersLight()})}themePairForTheme(e){return Bh(this.plugins.getThemePairs(),e)}systemPrefersLight(){return this.systemLightThemeMedia?.matches??!1}autoThemeDescription(e){return!this.themePreference.auto||e.selectedTheme===void 0?`Follow the system light/dark preference when the selected theme has a pair.`:e.selectedThemePair===void 0?`On, but the selected theme has no light/dark pair, so it will stay selected.`:`On · ${e.selectedThemePair.name} follows the system ${this.systemPrefersLight()?`light`:`dark`} preference.`}themeOptionLabel(e,t){let n=[...e.id===t?[`selected`]:[],...e.id===this.activeThemeId&&e.id!==t?[`active`]:[]];return n.length===0?e.name:`${e.name} ✓ ${n.join(` · `)}`}themeOptionDescription(e){let t=[e.colorScheme];return this.themePairForTheme(e.id)!==void 0&&t.push(`auto pair`),e.description!==void 0&&t.push(e.description),t.join(` · `)}async openThinkingDialog(){let e=await this.sessions.listThinkingLevels(),t=this.state.status?.thinkingLevel??`off`;this.pushModalLayerFrame(),this.setState({thinkingDialog:{title:`Select Thinking Level`,selectedValue:t,options:e.map(e=>{let n=kj(e);return{value:e,label:`${e}${e===t?` ✓ current`:``}`,...n===void 0?{}:{description:n}}})}})}async pickThinking(e){this.setState({thinkingDialog:void 0}),e!==``&&await this.sessions.setThinkingLevel(e)}async runGoalCommand(e){this.state.selectedSession!==void 0&&await this.sendPrompt(e)}async sendPrompt(e,t,n,r,i){return!(n!==void 0&&n.length>0)&&t===void 0&&this.auth.handleSlashCommand(e)?!0:await this.sessions.send(e,t,n,r,i)}restoreToComposer(e){let t=e.map(e=>e.text).filter(e=>e.trim()!==``);t.length!==0&&(this.promptEditor?.replaceText(t.join(`
|
|
6232
6240
|
|
|
6233
6241
|
`)),this.shouldAutoFocusPrompt()&&this.promptEditor?.focusInput())}renderChatView(e,t){return g`
|
|
6234
6242
|
<chat-view .goals=${this.state.workspaceGoals} .onRunGoalCommand=${(e,t)=>this.runGoalCommand(t)} .sessionId=${t.id} .messages=${e.messages} .messageStart=${e.messagePageStart} .messageEnd=${e.messagePageEnd} .messageTotal=${e.messagePageTotal} .hasMore=${e.messagePageStart>0} .loadingMore=${e.isLoadingEarlierMessages} .isSendingPrompt=${e.sendingPrompts[t.id]===!0} .isCompacting=${e.status?.isCompacting===!0} .pendingMessageCount=${e.status?.pendingMessageCount??0} .clientQueuedMessages=${e.clientQueuedSessionMessages[t.id]??[]} .status=${e.status} .activity=${e.activity} .pendingAsk=${e.pendingAsk} .pendingDialogs=${e.pendingDialogs} .closedDialogs=${e.closedDialogs} .onAnswerDialog=${this.handleAnswerDialog} .onCancelDialog=${this.handleCancelDialog} .onDismissClosedDialog=${this.handleDismissClosedDialog} .onResendMessage=${this.handleResendMessage} .askDraftSessionId=${Cc(L(e),t.id)} .onSubmitAsk=${this.handleSubmitAsk} .notificationInbox=${Dp(e.selectedNotificationInbox)} .subagents=${e.subagents} .subagentRuns=${e.subagentRuns} .backgroundTasks=${e.backgroundTasks} .activityOutput=${e.activityOutput} .onCloseActivityOutput=${this.handleCloseActivityOutput} .onOpenSubagent=${this.handleOpenSubagentSession} .onOpenSubagentRun=${this.handleOpenSubagentRun} .onOpenBackgroundTask=${this.handleOpenBackgroundTask} .onClearServerQueue=${this.handleClearServerQueue} .onRecallQueuedMessage=${this.handleRecallQueuedMessage} .onDismissWarning=${this.handleDismissWarning} .onDismissNotification=${this.handleDismissNotification} .onDismissAllNotifications=${this.handleDismissAllNotifications} .warningsVisible=${!this.sessionWarningVisibility.collapsed} .onToggleWarnings=${this.handleToggleWarnings} .onLoadMore=${()=>this.withChatPrependTransition(()=>this.sessions.loadEarlierMessages())}></chat-view>
|
|
6235
6243
|
`}renderStatusBar(e){let t=this.sessionWarningVisibility.warningCount;return g`
|
|
6236
6244
|
<status-bar .status=${e.status} .warningCount=${t} .warningsExpanded=${t>0&&!this.sessionWarningVisibility.collapsed} .onToggleWarnings=${this.handleToggleWarnings}></status-bar>
|
|
6237
|
-
`}renderErrorBanner(e){let t=St({shownAt:this.bannerShownAt,now:Date.now(),next:e});return t.kind===`hold`?(this.bannerHoldTimer!==void 0&&window.clearTimeout(this.bannerHoldTimer),this.bannerHoldTimer=window.setTimeout(()=>{this.bannerHoldTimer=void 0,this.requestUpdate()},t.retryInMs),this.heldErrorBanner):t.kind===`hide`?(this.bannerShownAt=void 0,this.heldErrorBanner=null,null):(this.bannerShownAt??=Date.now(),e!==this.lastScheduledError&&(this.lastScheduledError=e,this.scheduleTransientErrorDismissal(e)),this.heldErrorBanner=
|
|
6245
|
+
`}renderErrorBanner(e){let t=St({shownAt:this.bannerShownAt,now:Date.now(),next:e});return t.kind===`hold`?(this.bannerHoldTimer!==void 0&&window.clearTimeout(this.bannerHoldTimer),this.bannerHoldTimer=window.setTimeout(()=>{this.bannerHoldTimer=void 0,this.requestUpdate()},t.retryInMs),this.heldErrorBanner):t.kind===`hide`?(this.bannerShownAt=void 0,this.heldErrorBanner=null,null):(this.bannerShownAt??=Date.now(),e!==this.lastScheduledError&&(this.lastScheduledError=e,this.scheduleTransientErrorDismissal(e)),this.heldErrorBanner=LA(e,()=>{this.setState({error:``})}),this.heldErrorBanner)}renderContextBar(){return this.appShell.isMobileNavigationLayout?g`
|
|
6238
6246
|
<app-context-bar
|
|
6239
6247
|
.machines=${this.state.machines}
|
|
6240
6248
|
.machine=${this.state.selectedMachine}
|
|
@@ -6242,7 +6250,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6242
6250
|
.workspace=${this.state.selectedWorkspace}
|
|
6243
6251
|
.session=${this.state.selectedSession}
|
|
6244
6252
|
?emphasizeSession=${this.state.mainView===`chat`}
|
|
6245
|
-
?isWorking=${this.state.mainView===`chat`&&this.state.selectedSession!==void 0&&
|
|
6253
|
+
?isWorking=${this.state.mainView===`chat`&&this.state.selectedSession!==void 0&&xj(this.state)}
|
|
6246
6254
|
.refreshControl=${this.appShell.shouldShowAppRefreshInContextBar()?this.renderAppRefresh():void 0}
|
|
6247
6255
|
.mainView=${this.state.mainView}
|
|
6248
6256
|
.onShowConversation=${()=>{this.selectMainView(`chat`)}}
|
|
@@ -6268,7 +6276,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6268
6276
|
|
|
6269
6277
|
${this.renderErrorBanner(e.error)}
|
|
6270
6278
|
${this.renderSelfUpdateBanner()}
|
|
6271
|
-
${
|
|
6279
|
+
${WA(VA(e.machines,e.machineRuntimes))}
|
|
6272
6280
|
<div class="mobile-navigation-panel">${this.appShell.isMobileNavigationLayout?this.renderNavigationPanel():null}</div>
|
|
6273
6281
|
${e.selectedSession?g`
|
|
6274
6282
|
${this.renderChatView(e,e.selectedSession)}
|
|
@@ -6314,4 +6322,4 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6314
6322
|
${e.themeDialog===void 0?null:g`<command-picker title=${e.themeDialog.title} .options=${e.themeDialog.options} .selectedValue=${e.themeDialog.selectedValue} .onPick=${e=>{this.pickTheme(e)}} .onCancel=${()=>{this.setState({themeDialog:void 0})}}></command-picker>`}
|
|
6315
6323
|
${this.settingsSection===void 0?null:g`<settings-dialog .section=${this.settingsSection} .machine=${e.selectedMachine} .machineRuntime=${this.selectedMachineRuntime()} .actions=${this.getDefaultActions()} .onNavigate=${e=>{this.navigateSettings(e)}} .onClose=${()=>{this.closeSettings()}} .onConfigSaved=${e=>{this.applyClientConfig(e)}} .onRefreshMachineRuntime=${async e=>{await this.machines.refreshMachineRuntime(e)}} .machines=${e.machines} .machineStatuses=${e.machineStatuses} .onAddMachine=${()=>{this.openMachineDialog()}} .onRenameMachine=${async(e,t)=>{await this.renameMachine(e,t)}} .onRemoveMachine=${e=>{this.removeMachine(e)}} .fleetReport=${this.fleetReport} ?fleetLoading=${this.fleetLoading} .fleetError=${this.fleetError} .onRefreshFleet=${()=>this.refreshFleet()} .onRunFleet=${(e,t)=>this.runFleetOperation(e,t)} .themes=${this.plugins.getThemes()} .selectedThemeId=${this.resolveCurrentThemePreference().selectedTheme?.id} .activeThemeId=${this.activeThemeId} ?followSystemTheme=${this.themePreference.auto} .onSelectTheme=${e=>{this.selectTheme(e)}} .onToggleFollowSystem=${e=>{this.setFollowSystemTheme(e)}} .uiScale=${this.uiScale} .onChangeUiScale=${e=>{this.setUiScale(e)}}></settings-dialog>`}
|
|
6316
6324
|
</div>
|
|
6317
|
-
`}static{this.styles=Gg}};H([x()],$.prototype,`state`,void 0),H([S(`chat-view`)],$.prototype,`chatView`,void 0),H([S(`prompt-editor`)],$.prototype,`promptEditor`,void 0),H([S(`app-navigation-panel`)],$.prototype,`navigationPanel`,void 0),H([S(`#navigation-panel`)],$.prototype,`navigationPanelFrame`,void 0),H([S(`#workspace-panel`)],$.prototype,`workspacePanelFrame`,void 0),H([x()],$.prototype,`interruptedSessionIds`,void 0),H([x()],$.prototype,`unreadSessionIds`,void 0),H([x()],$.prototype,`uiScale`,void 0),H([x()],$.prototype,`activeThemeId`,void 0),H([x()],$.prototype,`isRefreshingApp`,void 0),H([x()],$.prototype,`quickSwitcherOpen`,void 0),H([x()],$.prototype,`composerCollapsed`,void 0),H([x()],$.prototype,`mobileToolSheetOpen`,void 0),H([x()],$.prototype,`quickSwitcherLoading`,void 0),H([x()],$.prototype,`quickSwitcherSessions`,void 0),H([x()],$.prototype,`pinnedSessionIds`,void 0),H([x()],$.prototype,`quickSwitcherWorkspaces`,void 0),H([x()],$.prototype,`sessionCleanupDialog`,void 0),H([x()],$.prototype,`settingsSection`,void 0),H([x()],$.prototype,`fleetReport`,void 0),H([x()],$.prototype,`fleetLoading`,void 0),H([x()],$.prototype,`fleetError`,void 0),H([x()],$.prototype,`shortcutConfig`,void 0),H([x()],$.prototype,`workspaceUploadDefaultFolder`,void 0),H([x()],$.prototype,`speechToTextConfig`,void 0),$=H([y(`pi-web-app`)],$);function
|
|
6325
|
+
`}static{this.styles=Gg}};H([x()],$.prototype,`state`,void 0),H([S(`chat-view`)],$.prototype,`chatView`,void 0),H([S(`prompt-editor`)],$.prototype,`promptEditor`,void 0),H([S(`app-navigation-panel`)],$.prototype,`navigationPanel`,void 0),H([S(`#navigation-panel`)],$.prototype,`navigationPanelFrame`,void 0),H([S(`#workspace-panel`)],$.prototype,`workspacePanelFrame`,void 0),H([x()],$.prototype,`interruptedSessionIds`,void 0),H([x()],$.prototype,`unreadSessionIds`,void 0),H([x()],$.prototype,`uiScale`,void 0),H([x()],$.prototype,`activeThemeId`,void 0),H([x()],$.prototype,`isRefreshingApp`,void 0),H([x()],$.prototype,`quickSwitcherOpen`,void 0),H([x()],$.prototype,`composerCollapsed`,void 0),H([x()],$.prototype,`mobileToolSheetOpen`,void 0),H([x()],$.prototype,`quickSwitcherLoading`,void 0),H([x()],$.prototype,`quickSwitcherSessions`,void 0),H([x()],$.prototype,`pinnedSessionIds`,void 0),H([x()],$.prototype,`quickSwitcherWorkspaces`,void 0),H([x()],$.prototype,`sessionCleanupDialog`,void 0),H([x()],$.prototype,`settingsSection`,void 0),H([x()],$.prototype,`fleetReport`,void 0),H([x()],$.prototype,`fleetLoading`,void 0),H([x()],$.prototype,`fleetError`,void 0),H([x()],$.prototype,`shortcutConfig`,void 0),H([x()],$.prototype,`workspaceUploadDefaultFolder`,void 0),H([x()],$.prototype,`speechToTextConfig`,void 0),$=H([y(`pi-web-app`)],$);function oj(){let e=new pb;return e.register({id:`core`,plugin:Vy}),e.register({id:`themes`,plugin:Jy}),e}function sj(){return{registrationPluginId:`core`,sourcePluginId:`core`}}function cj(e){let t=e.selectedMachine;return t===void 0?{id:`local`,name:`local`,kind:`local`}:{id:t.id,name:t.name,kind:t.kind}}function lj(e,t){return JSON.stringify([e,t.id,t.cwd])}function uj(e){let t=e.selectedSession;return t===void 0?void 0:lj(L(e),t)}function dj(e,t){return e.machines!==t.machines}function fj(e,t){return e.machines!==t.machines||e.machineStatuses!==t.machineStatuses||(e.selectedMachine?.id??`local`)!==(t.selectedMachine?.id??`local`)}function pj(e,t){return mj(e,t)}function mj(e,t){if(e.kind===`local`)return!0;let n=t?.status??e.status;return n===void 0||n===`unknown`||n===`online`}function hj(e,t){return Object.entries(t).some(([t,n])=>Reflect.get(e,t)!==n)}function gj(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return r?.id===e.id&&r.status===e.status&&r.exitCode===e.exitCode&&r.durationMs===e.durationMs})}function _j(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return r?.sessionId===e.sessionId&&r.status===e.status})}function vj(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return r?.runId===e.runId&&r.status===e.status&&r.elapsedMs===e.elapsedMs&&r.lastActivity===e.lastActivity})}function yj(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function bj(e){let t=new Set,n=[];for(let r of e)t.has(r.id)||(t.add(r.id),n.push(r));return n}function xj(e){return vc(e.status,e.activity)}function Sj(e){return e.type===`terminal.created`||e.type===`terminal.exited`||e.type===`terminal.closed`}function Cj(){return{}}function wj(e,t){return JSON.stringify([e,t])}function Tj(e){return XA[Math.min(e,XA.length-1)]??3e4}function Ej(e){return e instanceof Error?e.message:String(e)}function Dj(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}function Oj(){return new Promise(e=>requestAnimationFrame(()=>{e()}))}function kj(e){switch(e){case`off`:return`No reasoning`;case`minimal`:return`Very brief reasoning (~1k tokens)`;case`low`:return`Light reasoning (~2k tokens)`;case`medium`:return`Moderate reasoning (~8k tokens)`;case`high`:return`Deep reasoning (~16k tokens)`;case`xhigh`:return`Maximum reasoning (~32k tokens)`;default:return}}export{h as _,e_ as a,Ws as c,x as d,b as f,g,Xe as h,n_ as i,cs as l,v as m,H as n,bm as o,y as p,t_ as r,ym as s,cS as t,S as u};
|