@jmfederico/pi-web 1.202605.5 → 1.202605.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -9
- package/dist/client/assets/{CodeViewer-Bmvokzvu.js → CodeViewer-CbO-Cu6v.js} +1 -1
- package/dist/client/assets/{TerminalPanel-BmVVdLnC.js → TerminalPanel-D4bhXEax.js} +1 -1
- package/dist/client/assets/{index-BOQGR99X.js → index-C0G9UyhD.js} +4 -4
- package/dist/client/index.html +1 -1
- package/extensions/pi-web.ts +1 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -166,15 +166,6 @@ pi-web-sessiond
|
|
|
166
166
|
PI_WEB_PORT=8504 pi-web-server
|
|
167
167
|
```
|
|
168
168
|
|
|
169
|
-
To install directly from the GitHub repository instead of npm:
|
|
170
|
-
|
|
171
|
-
```bash
|
|
172
|
-
npm install -g github:jmfederico/pi-web#main
|
|
173
|
-
pi-web install
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
For git installs, `dist/` must already be present in the repository because npm does not run the package's `prepack` script for git dependencies.
|
|
177
|
-
|
|
178
169
|
## Development quick start
|
|
179
170
|
|
|
180
171
|
```bash
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as a,J as d,$ as h,A as f,X as m,U as g,_ as v,a0 as y}from"./vendor-editor-core-B4Sq6exx.js";import{g as w,r as b,p as C,h as j,c as x,m as _,j as k,a as u}from"./vendor-editor-languages-DznYbTkJ.js";import{d as E}from"./vendor-editor-legacy-B4QLsWF8.js";import{i as H,b as O,a as S,n as p,e as P,t as L}from"./index-
|
|
1
|
+
import{w as a,J as d,$ as h,A as f,X as m,U as g,_ as v,a0 as y}from"./vendor-editor-core-B4Sq6exx.js";import{g as w,r as b,p as C,h as j,c as x,m as _,j as k,a as u}from"./vendor-editor-languages-DznYbTkJ.js";import{d as E}from"./vendor-editor-legacy-B4QLsWF8.js";import{i as H,b as O,a as S,n as p,e as P,t as L}from"./index-C0G9UyhD.js";var D=Object.defineProperty,F=Object.getOwnPropertyDescriptor,n=(e,o,i,s)=>{for(var t=s>1?void 0:s?F(o,i):o,c=e.length-1,l;c>=0;c--)(l=e[c])&&(t=(s?l(o,i,t):l(t))||t);return s&&t&&D(o,i,t),t};let r=class extends H{constructor(){super(...arguments),this.content=""}firstUpdated(){this.recreateEditor()}updated(e){(e.has("content")||e.has("language"))&&this.recreateEditor()}disconnectedCallback(){this.view?.destroy(),this.view=void 0,super.disconnectedCallback()}render(){return O`<div class="host"></div>`}recreateEditor(){this.editorHost&&(this.view?.destroy(),this.view=new a({parent:this.editorHost,state:d.create({doc:this.content,extensions:[h(),f.of(m),g(v,{fallback:!0}),d.readOnly.of(!0),a.editable.of(!1),a.lineWrapping,M,...R(this.language)]})}))}};r.styles=S`
|
|
2
2
|
:host { display: block; min-height: 0; height: 100%; }
|
|
3
3
|
.host { height: 100%; min-height: 0; overflow: auto; }
|
|
4
4
|
`;n([p()],r.prototype,"content",2);n([p()],r.prototype,"language",2);n([P(".host")],r.prototype,"editorHost",2);r=n([L("code-viewer")],r);const M=a.theme({"&":{height:"100%",color:"#e6edf3",backgroundColor:"#0d1117",fontSize:"12px"},".cm-scroller":{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",lineHeight:"1.45"},".cm-gutters":{backgroundColor:"#0d1117",color:"#6e7681",borderRight:"1px solid #21262d"},".cm-activeLineGutter":{backgroundColor:"transparent"},".cm-activeLine":{backgroundColor:"transparent"},".cm-content":{caretColor:"transparent"},"&.cm-focused":{outline:"none"}});function R(e){if(e===void 0)return[];switch(e){case"typescript":return[u({typescript:!0})];case"javascript":return[u()];case"json":return[k()];case"markdown":return[_()];case"css":return[x()];case"html":return[j()];case"python":return[C()];case"rust":return[b()];case"go":return[w()];case"diff":return[y.define(E)];default:return[]}}export{r as CodeViewer};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as v,c as p,d as w,b as c,a as g,n as b,e as x,r as d,t as y}from"./index-
|
|
1
|
+
import{i as v,c as p,d as w,b as c,a as g,n as b,e as x,r as d,t as y}from"./index-C0G9UyhD.js";import{D as h,o as m}from"./vendor-terminal-DjQ08hXu.js";import"./vendor-editor-core-B4Sq6exx.js";import"./vendor-editor-languages-DznYbTkJ.js";var T=Object.defineProperty,k=Object.getOwnPropertyDescriptor,a=(e,t,i,r)=>{for(var s=r>1?void 0:r?k(t,i):t,o=e.length-1,l;o>=0;o--)(l=e[o])&&(s=(r?l(t,i,s):l(s))||s);return r&&s&&T(t,i,s),s};const u={cursorBlink:!0,convertEol:!0,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:13,theme:{background:"#05070a",foreground:"#e6edf3",cursor:"#58a6ff",selectionBackground:"#264f78"}},S={cols:100,rows:30};let n=class extends v{constructor(){super(...arguments),this.autoStart=!1,this.terminals=[],this.loading=!1,this.visible=!1,this.suppressTerminalInput=!1}firstUpdated(){this.intersectionObserver=new IntersectionObserver(e=>{this.visible=e[0]?.isIntersecting===!0}),this.intersectionObserver.observe(this)}disconnectedCallback(){this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.disposeTerminalView(),super.disconnectedCallback()}willUpdate(){const e=this.workspace?.path;e!==this.observedCwd&&(this.observedCwd=e,this.loadedCwd=void 0,this.terminals=[],this.selectedId=void 0,this.disposeTerminalView())}updated(){this.loadVisibleWorkspaceTerminals(),this.ensureTerminalView()}loadVisibleWorkspaceTerminals(){const e=this.workspace?.path;!this.visible||e===void 0||e===this.loadedCwd||(this.loadedCwd=e,this.loadTerminals())}async loadTerminals(){this.loading=!0,this.error=void 0;try{if(this.workspace===void 0)return;const e=await p.terminals(this.workspace.projectId,this.workspace.id);this.terminals=e,this.selectedId=e.find(t=>!t.exited)?.id??e[0]?.id,e.length===0&&this.autoStart&&await this.startTerminal()}catch(e){this.error=e instanceof Error?e.message:String(e)}finally{this.loading=!1}}async startTerminal(){if(this.workspace!==void 0){this.error=void 0;try{const e=this.measureTerminalSize()??S,t=await p.startTerminal(this.workspace.projectId,this.workspace.id,e);this.terminals=[...this.terminals,t],this.selectTerminal(t.id)}catch(e){this.error=e instanceof Error?e.message:String(e)}}}async closeTerminal(e,t){t.stopPropagation();try{if(this.workspace===void 0)return;await p.closeTerminal(this.workspace.projectId,this.workspace.id,e);const i=this.terminals.filter(r=>r.id!==e);this.terminals=i,this.selectedId===e&&(this.selectedId=i[0]?.id,this.disposeTerminalView())}catch(i){this.error=i instanceof Error?i.message:String(i)}}selectTerminal(e){this.selectedId!==e&&(this.selectedId=e,this.disposeTerminalView())}ensureTerminalView(){const e=this.workspace;if(!this.visible||this.terminal!==void 0||this.selectedId===void 0||this.terminalHost===void 0||e===void 0)return;const t=new h(u),i=new m;t.loadAddon(i),t.open(this.terminalHost),this.terminal=t,this.fitAddon=i,this.resizeObserver=new ResizeObserver(()=>{this.fitAndNotify()}),this.resizeObserver.observe(this.terminalHost),t.onData(s=>{if(this.suppressTerminalInput)return;const o=z(s);o!==""&&this.send({type:"input",data:o})});const r=this.fitTerminal();this.connectSocket(e.projectId,e.id,this.selectedId,t,r),requestAnimationFrame(()=>{this.fitAndNotify()}),t.focus()}connectSocket(e,t,i,r,s){const o=w(e,t,i,s);o.binaryType="arraybuffer",this.socket=o,o.addEventListener("open",()=>{this.fitAndNotify()}),o.addEventListener("message",l=>{this.handleSocketMessage(l.data,i,r)}),o.addEventListener("close",()=>{this.socket===o&&(this.socket=void 0)})}async handleSocketMessage(e,t,i){try{const r=I(await O(e));r.type==="output"&&this.writeTerminalOutput(i,r.data,r.replay===!0),r.type==="exit"&&(i.writeln(`\r
|
|
2
2
|
[process exited${r.exitCode===void 0?"":` with code ${String(r.exitCode)}`}]`),this.terminals=this.terminals.map(s=>s.id===t?{...s,exited:!0,...r.exitCode===void 0?{}:{exitCode:r.exitCode}}:s)),r.type==="error"&&i.writeln(`\r
|
|
3
3
|
[terminal error: ${r.message}]`)}catch(r){i.writeln(`\r
|
|
4
4
|
[terminal error: ${r instanceof Error?r.message:String(r)}]`)}}writeTerminalOutput(e,t,i){if(!i){e.write(t);return}this.suppressTerminalInput=!0,e.write(t,()=>{this.suppressTerminalInput=!1})}fitAndNotify(){const e=this.fitTerminal();e!==void 0&&this.send({type:"resize",...e})}fitTerminal(){if(this.fitAddon===void 0||this.terminal===void 0)return;const e=this.fitAddon.proposeDimensions(),t=f(e);if(t!==void 0)return this.fitAddon.fit(),t}measureTerminalSize(){const e=this.fitTerminal();if(e!==void 0)return e;if(this.terminal!==void 0||this.terminalHost===void 0)return;const t=new h(u),i=new m;t.loadAddon(i),t.open(this.terminalHost);const r=f(i.proposeDimensions());return t.dispose(),r}send(e){this.socket?.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify(e))}disposeTerminalView(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.socket?.close(),this.socket=void 0,this.terminal?.dispose(),this.terminal=void 0,this.fitAddon=void 0}render(){return c`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CodeViewer-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CodeViewer-CbO-Cu6v.js","assets/vendor-editor-core-B4Sq6exx.js","assets/vendor-editor-languages-DznYbTkJ.js","assets/vendor-editor-legacy-B4QLsWF8.js","assets/TerminalPanel-D4bhXEax.js","assets/vendor-terminal-DjQ08hXu.js","assets/vendor-terminal-DDGTF8rc.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{Q as Kt,w as Te,J as ft,R as Ci,S as Ai,G as Mi,U as Ei,V as Ii,A as Ri,W as _i,X as Di,Y as Li,Z as Qt,x as Zt,_ as ji}from"./vendor-editor-core-B4Sq6exx.js";import{m as Oi,i as qi,d as Fi}from"./vendor-editor-languages-DznYbTkJ.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const n of o.addedNodes)n.tagName==="LINK"&&n.rel==="modulepreload"&&i(n)}).observe(document,{childList:!0,subtree:!0});function s(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(r){if(r.ep)return;r.ep=!0;const o=s(r);fetch(r.href,o)}})();const Ve=globalThis,St=Ve.ShadowRoot&&(Ve.ShadyCSS===void 0||Ve.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,$t=Symbol(),Jt=new WeakMap;let Ws=class{constructor(e,s,i){if(this._$cssResult$=!0,i!==$t)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=s}get styleSheet(){let e=this.o;const s=this.t;if(St&&e===void 0){const i=s!==void 0&&s.length===1;i&&(e=Jt.get(s)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&Jt.set(s,e))}return e}toString(){return this.cssText}};const zi=t=>new Ws(typeof t=="string"?t:t+"",void 0,$t),G=(t,...e)=>{const s=t.length===1?t[0]:e.reduce((i,r,o)=>i+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+t[o+1],t[0]);return new Ws(s,t,$t)},Wi=(t,e)=>{if(St)t.adoptedStyleSheets=e.map(s=>s instanceof CSSStyleSheet?s:s.styleSheet);else for(const s of e){const i=document.createElement("style"),r=Ve.litNonce;r!==void 0&&i.setAttribute("nonce",r),i.textContent=s.cssText,t.appendChild(i)}},Yt=St?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let s="";for(const i of e.cssRules)s+=i.cssText;return zi(s)})(t):t;const{is:Ni,defineProperty:Ui,getOwnPropertyDescriptor:Bi,getOwnPropertyNames:Hi,getOwnPropertySymbols:Vi,getPrototypeOf:Gi}=Object,nt=globalThis,Xt=nt.trustedTypes,Ki=Xt?Xt.emptyScript:"",Qi=nt.reactiveElementPolyfillSupport,De=(t,e)=>t,Ke={toAttribute(t,e){switch(e){case Boolean:t=t?Ki:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=t!==null;break;case Number:s=t===null?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch{s=null}}return s}},Pt=(t,e)=>!Ni(t,e),es={attribute:!0,type:String,converter:Ke,reflect:!1,useDefault:!1,hasChanged:Pt};Symbol.metadata??=Symbol("metadata"),nt.litPropertyMetadata??=new WeakMap;let be=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,s=es){if(s.state&&(s.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((s=Object.create(s)).wrapped=!0),this.elementProperties.set(e,s),!s.noAccessor){const i=Symbol(),r=this.getPropertyDescriptor(e,i,s);r!==void 0&&Ui(this.prototype,e,r)}}static getPropertyDescriptor(e,s,i){const{get:r,set:o}=Bi(this.prototype,e)??{get(){return this[s]},set(n){this[s]=n}};return{get:r,set(n){const a=r?.call(this);o?.call(this,n),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??es}static _$Ei(){if(this.hasOwnProperty(De("elementProperties")))return;const e=Gi(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(De("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(De("properties"))){const s=this.properties,i=[...Hi(s),...Vi(s)];for(const r of i)this.createProperty(r,s[r])}const e=this[Symbol.metadata];if(e!==null){const s=litPropertyMetadata.get(e);if(s!==void 0)for(const[i,r]of s)this.elementProperties.set(i,r)}this._$Eh=new Map;for(const[s,i]of this.elementProperties){const r=this._$Eu(s,i);r!==void 0&&this._$Eh.set(r,s)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const s=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const r of i)s.unshift(Yt(r))}else e!==void 0&&s.push(Yt(e));return s}static _$Eu(e,s){const i=s.attribute;return i===!1?void 0:typeof i=="string"?i: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_(){const e=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Wi(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,s,i){this._$AK(e,i)}_$ET(e,s){const i=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,i);if(r!==void 0&&i.reflect===!0){const o=(i.converter?.toAttribute!==void 0?i.converter:Ke).toAttribute(s,i.type);this._$Em=e,o==null?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}_$AK(e,s){const i=this.constructor,r=i._$Eh.get(e);if(r!==void 0&&this._$Em!==r){const o=i.getPropertyOptions(r),n=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:Ke;this._$Em=r;const a=n.fromAttribute(s,o.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,s,i,r=!1,o){if(e!==void 0){const n=this.constructor;if(r===!1&&(o=this[e]),i??=n.getPropertyOptions(e),!((i.hasChanged??Pt)(o,s)||i.useDefault&&i.reflect&&o===this._$Ej?.get(e)&&!this.hasAttribute(n._$Eu(e,i))))return;this.C(e,s,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,s,{useDefault:i,reflect:r,wrapped:o},n){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,n??s??this[e]),o!==!0||n!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(s=void 0),this._$AL.set(e,s)),r===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(s){Promise.reject(s)}const 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(const[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[r,o]of i){const{wrapped:n}=o,a=this[r];n!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,o,a)}}let e=!1;const s=this._$AL;try{e=this.shouldUpdate(s),e?(this.willUpdate(s),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(s)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(s)}willUpdate(e){}_$AE(e){this._$EO?.forEach(s=>s.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(s=>this._$ET(s,this[s])),this._$EM()}updated(e){}firstUpdated(e){}};be.elementStyles=[],be.shadowRootOptions={mode:"open"},be[De("elementProperties")]=new Map,be[De("finalized")]=new Map,Qi?.({ReactiveElement:be}),(nt.reactiveElementVersions??=[]).push("2.1.2");const Tt=globalThis,ts=t=>t,Qe=Tt.trustedTypes,ss=Qe?Qe.createPolicy("lit-html",{createHTML:t=>t}):void 0,Ns="$lit$",te=`lit$${Math.random().toFixed(9).slice(2)}$`,Us="?"+te,Zi=`<${Us}>`,le=document,Le=()=>le.createComment(""),je=t=>t===null||typeof t!="object"&&typeof t!="function",Ct=Array.isArray,Ji=t=>Ct(t)||typeof t?.[Symbol.iterator]=="function",gt=`[
|
|
3
3
|
\f\r]`,Ce=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,is=/-->/g,rs=/>/g,re=RegExp(`>|${gt}(?:([^\\s"'>=/]+)(${gt}*=${gt}*(?:[^
|
|
4
4
|
\f\r"'\`<>=]|("|')|))|$)`,"g"),os=/'/g,ns=/"/g,Bs=/^(?:script|style|textarea|title)$/i,Yi=t=>(e,...s)=>({_$litType$:t,strings:e,values:s}),p=Yi(1),se=Symbol.for("lit-noChange"),C=Symbol.for("lit-nothing"),as=new WeakMap,ae=le.createTreeWalker(le,129);function Hs(t,e){if(!Ct(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return ss!==void 0?ss.createHTML(e):e}const Xi=(t,e)=>{const s=t.length-1,i=[];let r,o=e===2?"<svg>":e===3?"<math>":"",n=Ce;for(let a=0;a<s;a++){const l=t[a];let c,u,d=-1,f=0;for(;f<l.length&&(n.lastIndex=f,u=n.exec(l),u!==null);)f=n.lastIndex,n===Ce?u[1]==="!--"?n=is:u[1]!==void 0?n=rs:u[2]!==void 0?(Bs.test(u[2])&&(r=RegExp("</"+u[2],"g")),n=re):u[3]!==void 0&&(n=re):n===re?u[0]===">"?(n=r??Ce,d=-1):u[1]===void 0?d=-2:(d=n.lastIndex-u[2].length,c=u[1],n=u[3]===void 0?re:u[3]==='"'?ns:os):n===ns||n===os?n=re:n===is||n===rs?n=Ce:(n=re,r=void 0);const g=n===re&&t[a+1].startsWith("/>")?" ":"";o+=n===Ce?l+Zi:d>=0?(i.push(c),l.slice(0,d)+Ns+l.slice(d)+te+g):l+te+(d===-2?a:g)}return[Hs(t,o+(t[s]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]};class Oe{constructor({strings:e,_$litType$:s},i){let r;this.parts=[];let o=0,n=0;const a=e.length-1,l=this.parts,[c,u]=Xi(e,s);if(this.el=Oe.createElement(c,i),ae.currentNode=this.el.content,s===2||s===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(r=ae.nextNode())!==null&&l.length<a;){if(r.nodeType===1){if(r.hasAttributes())for(const d of r.getAttributeNames())if(d.endsWith(Ns)){const f=u[n++],g=r.getAttribute(d).split(te),m=/([.?@])?(.*)/.exec(f);l.push({type:1,index:o,name:m[2],strings:g,ctor:m[1]==="."?tr:m[1]==="?"?sr:m[1]==="@"?ir:at}),r.removeAttribute(d)}else d.startsWith(te)&&(l.push({type:6,index:o}),r.removeAttribute(d));if(Bs.test(r.tagName)){const d=r.textContent.split(te),f=d.length-1;if(f>0){r.textContent=Qe?Qe.emptyScript:"";for(let g=0;g<f;g++)r.append(d[g],Le()),ae.nextNode(),l.push({type:2,index:++o});r.append(d[f],Le())}}}else if(r.nodeType===8)if(r.data===Us)l.push({type:2,index:o});else{let d=-1;for(;(d=r.data.indexOf(te,d+1))!==-1;)l.push({type:7,index:o}),d+=te.length-1}o++}}static createElement(e,s){const i=le.createElement("template");return i.innerHTML=e,i}}function ye(t,e,s=t,i){if(e===se)return e;let r=i!==void 0?s._$Co?.[i]:s._$Cl;const o=je(e)?void 0:e._$litDirective$;return r?.constructor!==o&&(r?._$AO?.(!1),o===void 0?r=void 0:(r=new o(t),r._$AT(t,s,i)),i!==void 0?(s._$Co??=[])[i]=r:s._$Cl=r),r!==void 0&&(e=ye(t,r._$AS(t,e.values),r,i)),e}class er{constructor(e,s){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=s}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:s},parts:i}=this._$AD,r=(e?.creationScope??le).importNode(s,!0);ae.currentNode=r;let o=ae.nextNode(),n=0,a=0,l=i[0];for(;l!==void 0;){if(n===l.index){let c;l.type===2?c=new ke(o,o.nextSibling,this,e):l.type===1?c=new l.ctor(o,l.name,l.strings,this,e):l.type===6&&(c=new rr(o,this,e)),this._$AV.push(c),l=i[++a]}n!==l?.index&&(o=ae.nextNode(),n++)}return ae.currentNode=le,r}p(e){let s=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,s),s+=i.strings.length-2):i._$AI(e[s])),s++}}class ke{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,s,i,r){this.type=2,this._$AH=C,this._$AN=void 0,this._$AA=e,this._$AB=s,this._$AM=i,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const s=this._$AM;return s!==void 0&&e?.nodeType===11&&(e=s.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,s=this){e=ye(this,e,s),je(e)?e===C||e==null||e===""?(this._$AH!==C&&this._$AR(),this._$AH=C):e!==this._$AH&&e!==se&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Ji(e)?this.k(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!==C&&je(this._$AH)?this._$AA.nextSibling.data=e:this.T(le.createTextNode(e)),this._$AH=e}$(e){const{values:s,_$litType$:i}=e,r=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=Oe.createElement(Hs(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===r)this._$AH.p(s);else{const o=new er(r,this),n=o.u(this.options);o.p(s),this.T(n),this._$AH=o}}_$AC(e){let s=as.get(e.strings);return s===void 0&&as.set(e.strings,s=new Oe(e)),s}k(e){Ct(this._$AH)||(this._$AH=[],this._$AR());const s=this._$AH;let i,r=0;for(const o of e)r===s.length?s.push(i=new ke(this.O(Le()),this.O(Le()),this,this.options)):i=s[r],i._$AI(o),r++;r<s.length&&(this._$AR(i&&i._$AB.nextSibling,r),s.length=r)}_$AR(e=this._$AA.nextSibling,s){for(this._$AP?.(!1,!0,s);e!==this._$AB;){const i=ts(e).nextSibling;ts(e).remove(),e=i}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}}let at=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,s,i,r,o){this.type=1,this._$AH=C,this._$AN=void 0,this.element=e,this.name=s,this._$AM=r,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=C}_$AI(e,s=this,i,r){const o=this.strings;let n=!1;if(o===void 0)e=ye(this,e,s,0),n=!je(e)||e!==this._$AH&&e!==se,n&&(this._$AH=e);else{const a=e;let l,c;for(e=o[0],l=0;l<o.length-1;l++)c=ye(this,a[i+l],s,l),c===se&&(c=this._$AH[l]),n||=!je(c)||c!==this._$AH[l],c===C?e=C:e!==C&&(e+=(c??"")+o[l+1]),this._$AH[l]=c}n&&!r&&this.j(e)}j(e){e===C?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},tr=class extends at{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===C?void 0:e}},sr=class extends at{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==C)}},ir=class extends at{constructor(e,s,i,r,o){super(e,s,i,r,o),this.type=5}_$AI(e,s=this){if((e=ye(this,e,s,0)??C)===se)return;const i=this._$AH,r=e===C&&i!==C||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,o=e!==C&&(i===C||r);r&&this.element.removeEventListener(this.name,this,i),o&&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)}};class rr{constructor(e,s,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=s,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){ye(this,e)}}const or={I:ke},nr=Tt.litHtmlPolyfillSupport;nr?.(Oe,ke),(Tt.litHtmlVersions??=[]).push("3.3.2");const ar=(t,e,s)=>{const i=s?.renderBefore??e;let r=i._$litPart$;if(r===void 0){const o=s?.renderBefore??null;i._$litPart$=r=new ke(e.insertBefore(Le(),o),o,void 0,s??{})}return r._$AI(t),r};const At=globalThis;let _=class extends be{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const s=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=ar(s,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return se}};_._$litElement$=!0,_.finalized=!0,At.litElementHydrateSupport?.({LitElement:_});const lr=At.litElementPolyfillSupport;lr?.({LitElement:_});(At.litElementVersions??=[]).push("4.2.2");const W=t=>(e,s)=>{s!==void 0?s.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)};const cr={attribute:!0,type:String,converter:Ke,reflect:!1,hasChanged:Pt},dr=(t=cr,e,s)=>{const{kind:i,metadata:r}=s;let o=globalThis.litPropertyMetadata.get(r);if(o===void 0&&globalThis.litPropertyMetadata.set(r,o=new Map),i==="setter"&&((t=Object.create(t)).wrapped=!0),o.set(s.name,t),i==="accessor"){const{name:n}=s;return{set(a){const l=e.get.call(this);e.set.call(this,a),this.requestUpdate(n,l,t,!0,a)},init(a){return a!==void 0&&this.C(n,void 0,t,a),a}}}if(i==="setter"){const{name:n}=s;return function(a){const l=this[n];e.call(this,a),this.requestUpdate(n,l,t,!0,a)}}throw Error("Unsupported decorator location: "+i)};function h(t){return(e,s)=>typeof s=="object"?dr(t,e,s):((i,r,o)=>{const n=r.hasOwnProperty(o);return r.constructor.createProperty(o,i),n?Object.getOwnPropertyDescriptor(r,o):void 0})(t,e,s)}function $(t){return h({...t,state:!0,attribute:!1})}const pr=(t,e,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&typeof e!="object"&&Object.defineProperty(t,e,s),s);function ve(t,e){return(s,i,r)=>{const o=n=>n.renderRoot?.querySelector(t)??null;return pr(s,i,{get(){return o(this)}})}}async function x(t,e,s){const i=new Headers(s?.headers);s?.body!==void 0&&i.set("content-type","application/json");const r=await fetch(t,{...s,headers:i});if(!r.ok){const n=await r.json().catch(()=>({}));throw new Error(hr(n)??r.statusText)}const o=await r.json();return e(o)}function hr(t){if(ur(t))return typeof t.error=="string"?t.error:void 0}function ur(t){return typeof t=="object"&&t!==null}function fr(t){return typeof t=="object"&&t!==null}function v(t){if(!fr(t))throw new Error("Expected object response");return t}function b(t,e){const s=t[e];if(typeof s!="string")throw new Error(`Expected string field: ${e}`);return s}function D(t,e){const s=t[e];if(s!==void 0){if(typeof s!="string")throw new Error(`Expected optional string field: ${e}`);return s}}function N(t,e){const s=t[e];if(typeof s!="number")throw new Error(`Expected number field: ${e}`);return s}function F(t,e){const s=t[e];if(typeof s!="boolean")throw new Error(`Expected boolean field: ${e}`);return s}function z(t){return e=>{if(!Array.isArray(e))throw new Error("Expected array response");return e.map(t)}}function gr(t){if(!Array.isArray(t))throw new Error("Expected array response");return t}function mr(t){if(Array.isArray(t))return{messages:t,start:0,total:t.length};const e=v(t);return{messages:gr(e.messages),start:N(e,"start"),total:N(e,"total")}}function ls(t){const e=v(t);return{id:b(e,"id"),name:b(e,"name"),path:b(e,"path"),createdAt:b(e,"createdAt")}}function br(t){const e=v(t),s=D(e,"branch");return{id:b(e,"id"),projectId:b(e,"projectId"),path:b(e,"path"),label:b(e,"label"),...s===void 0?{}:{branch:s},isMain:F(e,"isMain"),isGitRepo:F(e,"isGitRepo"),isGitWorktree:F(e,"isGitWorktree")}}function bt(t){const e=v(t),s=D(e,"name"),i=D(e,"parentSessionPath"),r=D(e,"archivedAt");return{id:b(e,"id"),path:b(e,"path"),cwd:b(e,"cwd"),...s===void 0?{}:{name:s},created:b(e,"created"),modified:b(e,"modified"),messageCount:N(e,"messageCount"),firstMessage:b(e,"firstMessage"),...i===void 0?{}:{parentSessionPath:i},...e.archived===!0?{archived:!0}:{},...r===void 0?{}:{archivedAt:r}}}function Ae(t){const e=v(t);return{sessionId:b(e,"sessionId"),isStreaming:F(e,"isStreaming"),isCompacting:F(e,"isCompacting"),isBashRunning:F(e,"isBashRunning"),pendingMessageCount:N(e,"pendingMessageCount"),queuedMessages:e.queuedMessages===void 0?[]:z(yr)(e.queuedMessages),tokens:wr(e.tokens),cost:N(e,"cost"),...xr(e.model),...$r(e.contextUsage),...E("thinkingLevel",D(e,"thinkingLevel"))}}function yr(t){const e=v(t),s=b(e,"kind");if(s!=="steer"&&s!=="followUp")throw new Error("Invalid queued message kind");return{kind:s,text:b(e,"text")}}function wr(t){const e=v(t);return{input:N(e,"input"),output:N(e,"output"),cacheRead:N(e,"cacheRead"),cacheWrite:N(e,"cacheWrite"),total:N(e,"total")}}function Vs(t){const e=v(t);return{...E("provider",D(e,"provider")),...E("id",D(e,"id")),...E("name",D(e,"name")),...E("contextWindow",qe(e,"contextWindow")),...E("reasoning",e.reasoning)}}function xr(t){return t===void 0?{}:{model:Vs(t)}}function kr(t){const e=v(t);return{models:z(Vs)(e.models)}}function vr(t){if(t!=="off"&&t!=="minimal"&&t!=="low"&&t!=="medium"&&t!=="high"&&t!=="xhigh")throw new Error("Invalid thinking level");return t}function Sr(t){const e=v(t);return{levels:z(vr)(e.levels)}}function $r(t){if(t===void 0)return{};const e=v(t);return{contextUsage:{tokens:us(e,"tokens"),contextWindow:N(e,"contextWindow"),percent:us(e,"percent")}}}function Pr(t){const e=v(t),s=b(e,"source");if(s!=="extension"&&s!=="prompt"&&s!=="skill"&&s!=="builtin")throw new Error("Invalid command source");return{name:b(e,"name"),source:s,...E("description",D(e,"description"))}}function Gs(t){const e=v(t),s=b(e,"kind");if(s!=="tracked"&&s!=="untracked"&&s!=="other")throw new Error("Invalid file kind");return{path:b(e,"path"),kind:s}}function Tr(t){const e=v(t);return{path:b(e,"path"),entries:z(Cr)(e.entries),scannedAt:b(e,"scannedAt"),truncated:F(e,"truncated")}}function Cr(t){const e=v(t),s=b(e,"type");if(s!=="file"&&s!=="directory"&&s!=="symlink")throw new Error("Invalid file tree entry type");return{name:b(e,"name"),path:b(e,"path"),type:s,...E("size",qe(e,"size")),...E("modifiedAt",D(e,"modifiedAt"))}}function Ar(t){const e=v(t),s=b(e,"encoding");if(s!=="utf8")throw new Error("Invalid file encoding");return{path:b(e,"path"),...E("language",D(e,"language")),encoding:s,size:N(e,"size"),modifiedAt:b(e,"modifiedAt"),content:b(e,"content"),truncated:F(e,"truncated"),binary:F(e,"binary")}}function Mr(t){const e=v(t);return{isGitRepo:F(e,"isGitRepo"),hash:b(e,"hash"),...E("branch",D(e,"branch")),...E("upstream",D(e,"upstream")),...E("ahead",qe(e,"ahead")),...E("behind",qe(e,"behind")),files:z(Er)(e.files)}}function Er(t){const e=v(t);return{path:b(e,"path"),...E("oldPath",D(e,"oldPath")),index:cs(e.index),workingTree:cs(e.workingTree)}}function cs(t){switch(t){case"unmodified":case"modified":case"added":case"deleted":case"renamed":case"copied":case"untracked":case"ignored":case"conflicted":return t;default:throw new Error("Invalid git file state")}}function Ir(t){const e=v(t);return{...E("path",D(e,"path")),staged:F(e,"staged"),hash:b(e,"hash"),diff:b(e,"diff"),truncated:F(e,"truncated")}}function ds(t){const e=v(t);return{id:b(e,"id"),cwd:b(e,"cwd"),name:b(e,"name"),createdAt:b(e,"createdAt"),exited:F(e,"exited"),...E("exitCode",qe(e,"exitCode"))}}function ps(t){const e=v(t),s=b(e,"type");if(s==="unsupported")return{type:s,message:b(e,"message")};if(s==="select")return{type:s,requestId:b(e,"requestId"),title:b(e,"title"),options:z(Rr)(e.options)};if(s==="done")return{type:s,...E("message",D(e,"message")),..._r(e.session)};throw new Error("Invalid command result type")}function Rr(t){const e=v(t);return{value:b(e,"value"),label:b(e,"label"),...E("description",D(e,"description"))}}function _r(t){return t===void 0?{}:{session:bt(t)}}function hs(t){if(v(t).accepted!==!0)throw new Error("Expected accepted response");return{accepted:!0}}function Ks(t){if(v(t).closed!==!0)throw new Error("Expected closed response");return{closed:!0}}function Dr(t){if(v(t).aborted!==!0)throw new Error("Expected aborted response");return{aborted:!0}}function Lr(t){if(v(t).stopped!==!0)throw new Error("Expected stopped response");return{stopped:!0}}function jr(t){if(v(t).archived!==!0)throw new Error("Expected archived response");return{archived:!0}}function Or(t){if(v(t).restored!==!0)throw new Error("Expected restored response");return{restored:!0}}function qr(t){if(v(t).detached!==!0)throw new Error("Expected detached response");return{detached:!0}}function qe(t,e){const s=t[e];if(s!==void 0){if(typeof s!="number")throw new Error(`Expected optional number field: ${e}`);return s}}function us(t,e){const s=t[e];if(s===null)return null;if(typeof s!="number")throw new Error(`Expected number|null field: ${e}`);return s}function E(t,e){return e===void 0?{}:{[t]:e}}function Fr(t,e,s){const i=new URLSearchParams;s?.path!==void 0&&i.set("path",s.path),s?.staged===!0&&i.set("staged","true");const r=i.toString();return`/api/projects/${encodeURIComponent(t)}/workspaces/${encodeURIComponent(e)}/git/diff${r?`?${r}`:""}`}function zr(t,e){const s=new URLSearchParams;e?.limit!==void 0&&s.set("limit",String(e.limit)),e?.before!==void 0&&s.set("before",String(e.before));const i=s.toString();return`/api/sessions/${t}/messages${i?`?${i}`:""}`}const Wr={projects:()=>x("/api/projects",z(ls)),addProject:(t,e,s)=>x("/api/projects",ls,{method:"POST",body:JSON.stringify({path:t,name:e,create:s})}),closeProject:t=>x(`/api/projects/${encodeURIComponent(t)}`,Ks,{method:"DELETE"}),projectDirectories:t=>x(`/api/project-directories?q=${encodeURIComponent(t)}`,z(Gs))},Nr={workspaces:t=>x(`/api/projects/${t}/workspaces`,z(br)),workspaceTree:(t,e,s="")=>x(`/api/projects/${encodeURIComponent(t)}/workspaces/${encodeURIComponent(e)}/tree?path=${encodeURIComponent(s)}`,Tr),workspaceFile:(t,e,s)=>x(`/api/projects/${encodeURIComponent(t)}/workspaces/${encodeURIComponent(e)}/file?path=${encodeURIComponent(s)}`,Ar)},Ur={sessions:t=>x(`/api/sessions?cwd=${encodeURIComponent(t)}`,z(bt)),startSession:t=>x("/api/sessions",bt,{method:"POST",body:JSON.stringify({cwd:t})}),messages:(t,e)=>x(zr(t,e),mr),status:t=>x(`/api/sessions/${t}/status`,Ae),models:t=>x(`/api/sessions/${t}/models`,kr),setModel:(t,e,s)=>x(`/api/sessions/${t}/model`,Ae,{method:"POST",body:JSON.stringify({provider:e,modelId:s})}),cycleModel:(t,e)=>x(`/api/sessions/${t}/model/cycle`,Ae,{method:"POST",body:JSON.stringify({direction:e})}),thinkingLevels:t=>x(`/api/sessions/${t}/thinking-levels`,Sr),setThinkingLevel:(t,e)=>x(`/api/sessions/${t}/thinking-level`,Ae,{method:"POST",body:JSON.stringify({level:e})}),cycleThinkingLevel:t=>x(`/api/sessions/${t}/thinking-level/cycle`,Ae,{method:"POST"}),commands:t=>x(`/api/sessions/${t}/commands`,z(Pr)),prompt:(t,e,s)=>x(`/api/sessions/${t}/prompt`,hs,{method:"POST",body:JSON.stringify(s===void 0?{text:e}:{text:e,streamingBehavior:s})}),shell:(t,e)=>x(`/api/sessions/${t}/shell`,hs,{method:"POST",body:JSON.stringify({text:e})}),runCommand:(t,e)=>x(`/api/sessions/${t}/commands/run`,ps,{method:"POST",body:JSON.stringify({text:e})}),respondToCommand:(t,e,s)=>x(`/api/sessions/${t}/commands/respond`,ps,{method:"POST",body:JSON.stringify({requestId:e,value:s})}),abort:t=>x(`/api/sessions/${t}/abort`,Dr,{method:"POST"}),stop:t=>x(`/api/sessions/${t}/stop`,Lr,{method:"POST"}),archive:t=>x(`/api/sessions/${t}/archive`,jr,{method:"POST"}),restore:t=>x(`/api/sessions/${t}/restore`,Or,{method:"POST"}),detachParent:t=>x(`/api/sessions/${t}/detach-parent`,qr,{method:"POST"})},Qs={terminals:(t,e)=>x(`/api/projects/${encodeURIComponent(t)}/workspaces/${encodeURIComponent(e)}/terminals`,z(ds)),startTerminal:(t,e,s)=>x(`/api/projects/${encodeURIComponent(t)}/workspaces/${encodeURIComponent(e)}/terminals`,ds,{method:"POST",body:JSON.stringify(s??{})}),closeTerminal:(t,e,s)=>x(`/api/projects/${encodeURIComponent(t)}/workspaces/${encodeURIComponent(e)}/terminals/${encodeURIComponent(s)}`,Ks,{method:"DELETE"})},Br={files:(t,e,s,i)=>x(`/api/files?cwd=${encodeURIComponent(t)}&q=${encodeURIComponent(e)}${s!==void 0?`&kind=${encodeURIComponent(s)}`:""}${i!==void 0?`&mode=${encodeURIComponent(i)}`:""}`,z(Gs))},Hr={gitStatus:(t,e)=>x(`/api/projects/${encodeURIComponent(t)}/workspaces/${encodeURIComponent(e)}/git/status`,Mr),gitDiff:(t,e,s)=>x(Fr(t,e,s),Ir)},y={...Wr,...Nr,...Ur,...Qs,...Br,...Hr};function Vr(t){return new WebSocket(`${Mt()}/api/sessions/${t}/events`)}function lc(t,e,s,i){const r=i===void 0?"":`?cols=${encodeURIComponent(String(i.cols))}&rows=${encodeURIComponent(String(i.rows))}`;return new WebSocket(`${Mt()}/api/projects/${encodeURIComponent(t)}/workspaces/${encodeURIComponent(e)}/terminals/${encodeURIComponent(s)}/socket${r}`)}function Gr(){return new WebSocket(`${Mt()}/api/events`)}function Mt(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}`}function Kr(){return{projects:[],workspaces:[],sessions:[],messages:[],messagePageStart:0,messagePageTotal:0,isLoadingEarlierMessages:!1,isReceivingPartialStream:!1,selectedProject:void 0,selectedWorkspace:void 0,selectedSession:void 0,status:void 0,activity:void 0,sessionStatuses:{},sessionActivities:{},commandDialog:void 0,modelDialog:void 0,thinkingDialog:void 0,actionPaletteOpen:!1,projectDialogOpen:!1,workspaceTool:"core:workspace.files",mainView:"chat",fileTree:[],expandedDirs:{},selectedFilePath:void 0,selectedFileContent:void 0,fileTreeStale:!1,gitStatus:void 0,selectedDiffPath:void 0,selectedDiff:void 0,selectedStagedDiff:void 0,gitStale:!1,activeTerminalCount:0,error:""}}function Ze(t){return t.replaceAll(":",".")}function Qr(t){const e=new URLSearchParams(window.location.search),s=`${t}--`,i={};for(const[r,o]of e.entries()){if(!r.startsWith(s))continue;const n=r.slice(s.length),a=i[n];a===void 0?i[n]=o:Array.isArray(a)?a.push(o):i[n]=[a,o]}return i}function fs(t,e){const s=Qr(t)[e];return Array.isArray(s)?s[0]:s===""?void 0:s}function Je(t,e,s,i){const r=new URL(window.location.href),o=`${t}--${e}`;if(r.searchParams.delete(o),s!=null&&s!=="")if(Array.isArray(s))for(const n of s)r.searchParams.append(o,String(n));else r.searchParams.set(o,String(s));Zr(r,i)}function Zr(t,e){const s=`${t.pathname}${t.search}${t.hash}`,i=`${window.location.pathname}${window.location.search}${window.location.hash}`;s!==i&&(e?.replace===!0?window.history.replaceState({},"",t):window.history.pushState({},"",t))}const gs=Ze("core:workspace.files");class Jr{constructor(e,s,i){this.getState=e,this.setState=s,this.updateUrl=i}async refreshFiles(){const e=this.getState().selectedProject,s=this.getState().selectedWorkspace;if(!(e===void 0||s===void 0))try{const i=await y.workspaceTree(e.id,s.id),r={...this.getState().expandedDirs};await Promise.all(Object.keys(r).map(async o=>{r[o]=(await y.workspaceTree(e.id,s.id,o)).entries})),this.setState({fileTree:i.entries,expandedDirs:r,fileTreeStale:!1,error:""})}catch(i){this.setState({error:String(i)})}}async expandDir(e){const s=this.getState().selectedProject,i=this.getState().selectedWorkspace;if(!(s===void 0||i===void 0)){if(this.getState().expandedDirs[e]!==void 0){this.setState({expandedDirs:Xr(this.getState().expandedDirs,e)});return}try{const r=await y.workspaceTree(s.id,i.id,e);this.setState({expandedDirs:{...this.getState().expandedDirs,[e]:r.entries},error:""})}catch(r){this.setState({error:String(r)})}}}async selectFile(e){this.setState({selectedFilePath:e,selectedFileContent:void 0,workspaceTool:"core:workspace.files",mainView:this.getState().mainView==="chat"?"chat":"core:workspace.files"}),Je(gs,"file",e),this.updateUrl({replace:!0}),await this.restoreFile(e)}async restoreFile(e){const s=this.getState().selectedProject,i=this.getState().selectedWorkspace;if(!(s===void 0||i===void 0)){this.setState({selectedFilePath:e,selectedFileContent:void 0});try{const r=await y.workspaceFile(s.id,i.id,e);this.getState().selectedFilePath===e&&this.setState({selectedFileContent:r,error:""})}catch(r){if(this.getState().selectedFilePath!==e)return;if(Yr(r)){this.setState({selectedFilePath:void 0,selectedFileContent:void 0,error:""}),Je(gs,"file",void 0,{replace:!0}),this.updateUrl({replace:!0});return}this.setState({error:String(r)})}}}}function Yr(t){const e=String(t);return e.includes("Path does not exist")||e.includes("ENOENT")||e.includes("no such file or directory")}function Xr(t,e){return Object.fromEntries(Object.entries(t).filter(([s])=>s!==e))}const ms=Ze("core:workspace.git");class eo{constructor(e,s,i){this.getState=e,this.setState=s,this.updateUrl=i}dispose(){this.pollTimer!==void 0&&window.clearInterval(this.pollTimer),this.pollTimer=void 0}async refreshGit(){const e=this.getState().selectedProject,s=this.getState().selectedWorkspace;if(!(e===void 0||s===void 0))try{const i=await y.gitStatus(e.id,s.id);this.setState({gitStatus:i,gitStale:!1,error:""});const r=this.getState().selectedDiffPath;r!==void 0&&(i.files.some(o=>o.path===r)?await this.refreshDiff(r):(this.setState({selectedDiffPath:void 0,selectedDiff:void 0,selectedStagedDiff:void 0}),Je(ms,"diff",void 0,{replace:!0})))}catch(i){this.setState({error:String(i)})}}async selectDiff(e){this.setState({selectedDiffPath:e,selectedDiff:void 0,selectedStagedDiff:void 0,workspaceTool:"core:workspace.git",mainView:this.getState().mainView==="chat"?"chat":"core:workspace.git"}),Je(ms,"diff",e),this.updateUrl({replace:!0}),await this.refreshDiff(e)}async restoreDiff(e){this.setState({selectedDiffPath:e,selectedDiff:void 0,selectedStagedDiff:void 0}),await this.refreshDiff(e)}async refreshDiff(e){const s=this.getState().selectedProject,i=this.getState().selectedWorkspace;if(!(s===void 0||i===void 0))try{const[r,o]=await Promise.all([y.gitDiff(s.id,i.id,{path:e}),y.gitDiff(s.id,i.id,{path:e,staged:!0})]);this.setState({selectedDiff:r,selectedStagedDiff:o,error:""})}catch(r){this.setState({error:String(r)})}}updatePolling(){this.dispose();const e=this.getState();(e.workspaceTool==="core:workspace.git"||e.mainView==="core:workspace.git")&&(this.pollTimer=window.setInterval(()=>{this.refreshGit()},8e3))}}class to{constructor(e,s,i){this.getState=e,this.setState=s,this.workspaces=i}async loadProjects(){this.setState({error:""});try{this.setState({projects:await y.projects()})}catch(e){this.setState({error:String(e)})}}async addProject(e,s){if(e.trim()!=="")try{const i=await y.addProject(e.trim(),void 0,s),r=this.getState().projects;this.setState({projects:[...r.filter(o=>o.id!==i.id),i],projectDialogOpen:!1}),await this.workspaces.selectProject(i)}catch(i){this.setState({error:String(i)})}}async closeProject(e){try{await y.closeProject(e),this.workspaces.forgetProject(e);const s=this.getState();this.setState({projects:s.projects.filter(i=>i.id!==e)}),s.selectedProject?.id===e&&this.workspaces.clearSelection()}catch(s){this.setState({error:String(s)})}}}function me(t){return t.flatMap(lt).filter(e=>e.parts.length>0)}function Q(t,e){return{role:t,parts:[{type:"text",text:e}]}}function Ne(t,e){const s=lo(e);return s===void 0?t:{...t,meta:s}}function so(t,e,s){if(s==="")return t;const i=t.at(-1),r=i?.parts.at(-1);return i?.role===e&&r?.type==="text"?[...t.slice(0,-1),{...i,parts:[...i.parts.slice(0,-1),{...r,text:r.text+s}]}]:i?.role===e?[...t.slice(0,-1),{...i,parts:[...i.parts,{type:"text",text:s}]}]:[...t,Q(e,s)]}function io(t,e){if(e==="")return t;const s=t.at(-1),i=s?.parts.at(-1);return s?.role==="assistant"&&i?.type==="thinking"?[...t.slice(0,-1),{...s,parts:[...s.parts.slice(0,-1),{...i,text:i.text+e}]}]:s?.role==="assistant"?[...t.slice(0,-1),{...s,parts:[...s.parts,{type:"thinking",text:e}]}]:[...t,{role:"assistant",parts:[{type:"thinking",text:e}]}]}function lt(t){if(ro(t))return[t];if(M(t,"role")==="bashExecution")return[Ne(ho(t),t)];const e=uo(M(t,"role")),s=fo(ie(t,"content"),t),i=e==="user"?oo(s):void 0;if(i!==void 0)return i.map(a=>Ne(a,t));const r=ao(t);if(e==="tool")return[Ne({role:e,parts:s,...r===void 0?{}:{source:r}},t)];const o=s.filter(a=>a.type!=="empty"),n=e==="assistant"&&o.length>0&&o.every(a=>a.type==="skillRead")?"skill":e;return o.length>0?[Ne({role:n,parts:o,...r===void 0?{}:{source:r}},t)]:[]}function ro(t){const e=M(t,"role");return(e==="user"||e==="assistant"||e==="tool"||e==="system"||e==="bash"||e==="skill")&&Array.isArray(ie(t,"parts"))}function oo(t){if(t.length!==1||t[0]?.type!=="text")return;const e=no(t[0].text);if(e!==void 0)return[{role:"user",parts:[{type:"skillInvocation",name:e.name,location:e.location,content:e.content}]},...e.userMessage===void 0?[]:[{role:"user",parts:[{type:"text",text:e.userMessage}]}]]}function no(t){const e=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/.exec(t);if(e===null)return;const s=e[4]?.trim();return{name:e[1]??"skill",location:e[2]??"",content:e[3]??"",...s===void 0||s===""?{}:{userMessage:s}}}function ao(t){const e=M(t,"source");if(e==="compaction"||e==="branch_summary")return e}function lo(t){const e=co(ie(t,"timestamp")),s=po(t);if(!(e===void 0&&s===void 0))return{...e===void 0?{}:{timestamp:e},...s===void 0?{}:{model:s}}}function co(t){if(typeof t=="number"&&Number.isFinite(t))return new Date(t).toISOString();if(typeof t!="string"||t==="")return;const e=Date.parse(t);return Number.isFinite(e)?new Date(e).toISOString():void 0}function po(t){if(M(t,"role")!=="assistant")return;const e=M(t,"provider"),s=M(t,"model"),i=M(t,"responseModel");if(!((e===void 0||e==="")&&(s===void 0||s==="")&&(i===void 0||i==="")))return{...e===void 0||e===""?{}:{provider:e},...s===void 0||s===""?{}:{id:s},...i===void 0||i===""?{}:{responseId:i}}}function ho(t){const e=M(t,"command")??"",s=Ge(t,"excludeFromContext")===!0?["excluded from context","",`$ ${e}`]:[`$ ${e}`],i=ie(t,"output");i!=null&&s.push("",Ye(i));const r=ie(t,"exitCode");r!=null&&s.push("",`exit ${Ye(r)}`),Ge(t,"cancelled")===!0&&s.push("","cancelled"),Ge(t,"truncated")===!0&&s.push("","output truncated");const o=M(t,"fullOutputPath");return o!==void 0&&o!==""&&s.push("",`full output: ${o}`),{role:"bash",parts:[{type:"text",text:s.join(`
|
|
@@ -70,7 +70,7 @@ ${r.join(`
|
|
|
70
70
|
<div class="viewer-header"><strong>${t.path??"diff"}</strong><small>${t.staged?"staged":"unstaged"}${t.truncated?" · truncated":""}</small></div>
|
|
71
71
|
<code-viewer .content=${t.diff} .language=${"diff"}></code-viewer>
|
|
72
72
|
</section>
|
|
73
|
-
`}function ai(){oi(()=>import("./CodeViewer-
|
|
73
|
+
`}function ai(){oi(()=>import("./CodeViewer-CbO-Cu6v.js"),__vite__mapDeps([0,1,2,3]))}function bn(){oi(()=>import("./TerminalPanel-D4bhXEax.js"),__vite__mapDeps([4,5,6,1,2]))}function yn(t){const e=t.branch??"detached",s=t.ahead??0,i=t.behind??0;return s===0&&i===0?e:`${e} · ↑${String(s)} ↓${String(i)}`}function wn(t,e){return(e!=="unmodified"?e:t).slice(0,1).toUpperCase()}const xn={id:"core",name:"Pi Web Core",activate:()=>({actions:on(),workspacePanels:cn()})};async function kn(t="/pi-web-plugins/manifest.json"){window.piWebPluginApi={apiVersion:1,html:p};const e=await vn(t);if(e===void 0)return[];const s=[];for(const i of e.plugins)try{const r=new URL(i.module,new URL(t,window.location.href)).toString(),o=await import(r),n=$n(o,r);n!==void 0&&s.push(n)}catch(r){console.warn(`Failed to load Pi Web plugin ${i.module}`,r)}return s}async function vn(t){const e=await fetch(t,{cache:"no-store"});if(e.status!==404){if(!e.ok)throw new Error(`Failed to load plugin manifest: ${e.statusText}`);return Sn(await e.json())}}function Sn(t){if(!et(t)||!Array.isArray(t.plugins))throw new Error("Invalid plugin manifest");return{plugins:t.plugins.map(e=>{if(!et(e)||typeof e.module!="string"||e.module==="")throw new Error("Invalid plugin manifest entry");return{module:e.module}})}}function $n(t,e){if(!et(t))throw new Error(`Plugin module ${e} did not export an object`);const s=t.default;if(!Pn(s))throw new Error(`Plugin module ${e} default export is not a PiWebPlugin`);return s}function Pn(t){return et(t)&&typeof t.id=="string"&&typeof t.name=="string"&&typeof t.activate=="function"}function et(t){return typeof t=="object"&&t!==null}const Tn=/^[a-z][a-z0-9.-]*$/u,Cn=/^[a-z][a-z0-9.-]*$/u;class An{constructor(){this.actions=[],this.workspacePanels=[],this.workspaceLabelContributions=[],this.pluginIds=new Set,this.contributionIds=new Set}register(e){if(this.validatePluginId(e.id),this.pluginIds.has(e.id))throw new Error(`Duplicate plugin id: ${e.id}`);this.pluginIds.add(e.id);const s=e.activate({apiVersion:1});for(const i of s.actions??[])this.actions.push(this.qualifyAction(e.id,i));for(const i of s.workspacePanels??[])this.workspacePanels.push(this.qualifyWorkspacePanel(e.id,i));for(const i of s.workspaceLabelContributions??[])this.workspaceLabelContributions.push(this.qualifyWorkspaceLabelContribution(e.id,i))}getActions(e){return this.actions.map(s=>{const i=typeof s.enabled=="function"?s.enabled(e):s.enabled,r={id:s.id,pluginId:s.pluginId,localId:s.localId,title:s.title,run:()=>s.run(e)};return s.description!==void 0&&(r.description=s.description),s.shortcut!==void 0&&(r.shortcut=s.shortcut),s.group!==void 0&&(r.group=s.group),i!==void 0&&(r.enabled=i),r})}getWorkspacePanels(){return[...this.workspacePanels].sort((e,s)=>(e.order??1e3)-(s.order??1e3)||e.title.localeCompare(s.title))}getWorkspaceLabelItems(e,s){const i={state:e,workspace:s};return[...this.workspaceLabelContributions].sort((r,o)=>(r.order??1e3)-(o.order??1e3)||r.id.localeCompare(o.id)).flatMap(r=>{if(r.visible?.(i)===!1)return[];const o=r.items(i);return o===void 0?[]:Array.isArray(o)?o:[o]})}qualifyAction(e,s){const i=this.qualify(e,s.id);return{...s,id:i,pluginId:e,localId:s.id}}qualifyWorkspacePanel(e,s){const i=this.qualify(e,s.id);return{...s,id:i,pluginId:e,localId:s.id}}qualifyWorkspaceLabelContribution(e,s){const i=this.qualify(e,s.id);return{...s,id:i,pluginId:e,localId:s.id}}qualify(e,s){this.validateLocalId(s);const i=`${e}:${s}`;if(this.contributionIds.has(i))throw new Error(`Duplicate contribution id: ${i}`);return this.contributionIds.add(i),i}validatePluginId(e){if(!Tn.test(e))throw new Error(`Invalid plugin id: ${e}`)}validateLocalId(e){if(!Cn.test(e))throw new Error(`Invalid contribution id: ${e}`)}}function Mn(){const t=new URLSearchParams(window.location.search);return{projectId:t.get("project")??void 0,workspaceId:t.get("workspace")??void 0,sessionId:t.get("session")??void 0,tool:In(t.get("tool")),view:Rn(t.get("view"))}}function En(t,e){const s=new URL(window.location.href);s.searchParams.delete("project"),s.searchParams.delete("workspace"),s.searchParams.delete("session"),s.searchParams.delete("tool"),s.searchParams.delete("view"),t.projectId!==void 0&&t.projectId!==""&&s.searchParams.set("project",t.projectId),t.workspaceId!==void 0&&t.workspaceId!==""&&s.searchParams.set("workspace",t.workspaceId),t.sessionId!==void 0&&t.sessionId!==""&&s.searchParams.set("session",t.sessionId),t.tool!==void 0&&s.searchParams.set("tool",t.tool),t.view!==void 0&&s.searchParams.set("view",t.view);const i=`${s.pathname}${s.search}${s.hash}`,r=`${window.location.pathname}${window.location.search}${window.location.hash}`;i!==r&&(e?.replace===!0?window.history.replaceState({},"",s):window.history.pushState({},"",s))}function In(t){return t==="files"?"core:workspace.files":t==="git"?"core:workspace.git":li(t)?t:void 0}function Rn(t){return t==="chat"?"chat":t==="files"?"core:workspace.files":t==="git"?"core:workspace.git":li(t)?t:void 0}function li(t){return t!==null&&/^[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$/u.test(t)}const _n=["a[href]","button","input","select","textarea","summary","[role='button']","[role='link']","[contenteditable='true']"].join(",");function ci(t){return t.composedPath().some(e=>Dn(e,_n))}function Dn(t,e){if(typeof Element<"u"&&t instanceof Element)return t.matches(e);if(!("matches"in t))return!1;const{matches:s}=t;return typeof s=="function"&&s.call(t,e)===!0}function It(t,e){ci(t)||e()}function Rt(t,e){t.key!=="Enter"&&t.key!==" "||ci(t)||(t.preventDefault(),e())}const Ln=G`
|
|
74
74
|
:host { display: block; height: 100dvh; box-sizing: border-box; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); color: #e6edf3; background: #0d1117; font: 14px system-ui, sans-serif; }
|
|
75
75
|
.shell { display: grid; grid-template-columns: 340px minmax(420px, 1fr) minmax(360px, 42vw); height: 100%; min-height: 0; }
|
|
76
76
|
aside { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid #30363d; overflow: hidden; }
|
|
@@ -768,13 +768,13 @@ Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error
|
|
|
768
768
|
${s.render(i)}
|
|
769
769
|
</div>
|
|
770
770
|
`}
|
|
771
|
-
`}renderPanelTitle(t,e){const s=t.badge?.(e);return s===void 0||s===""?p`${t.title}`:p`${t.title} <span class="tab-badge">${s}</span>`}createPanelContext(t){return{workspace:t,fileTree:this.fileTree,expandedDirs:this.expandedDirs,selectedFilePath:this.selectedFilePath,selectedFileContent:this.selectedFileContent,fileTreeStale:this.fileTreeStale,gitStatus:this.gitStatus,selectedDiffPath:this.selectedDiffPath,selectedDiff:this.selectedDiff,selectedStagedDiff:this.selectedStagedDiff,gitStale:this.gitStale,activeTerminalCount:this.activeTerminalCount,terminalAutoStart:this.terminalAutoStart,onRefreshFiles:this.onRefreshFiles,onExpandDir:this.onExpandDir,onSelectFile:this.onSelectFile,onRefreshGit:this.onRefreshGit,onSelectDiff:this.onSelectDiff}}};S.styles=jn;P([h({attribute:!1})],S.prototype,"workspace",2);P([h()],S.prototype,"tool",2);P([h({attribute:!1})],S.prototype,"panels",2);P([h({attribute:!1})],S.prototype,"workspaceLabelItems",2);P([h({type:Boolean})],S.prototype,"hideToolTabs",2);P([h({attribute:!1})],S.prototype,"fileTree",2);P([h({attribute:!1})],S.prototype,"expandedDirs",2);P([h({attribute:!1})],S.prototype,"selectedFilePath",2);P([h({attribute:!1})],S.prototype,"selectedFileContent",2);P([h({type:Boolean})],S.prototype,"fileTreeStale",2);P([h({attribute:!1})],S.prototype,"gitStatus",2);P([h({attribute:!1})],S.prototype,"selectedDiffPath",2);P([h({attribute:!1})],S.prototype,"selectedDiff",2);P([h({attribute:!1})],S.prototype,"selectedStagedDiff",2);P([h({type:Boolean})],S.prototype,"gitStale",2);P([h({attribute:!1})],S.prototype,"onSelectTool",2);P([h({attribute:!1})],S.prototype,"onRefreshFiles",2);P([h({attribute:!1})],S.prototype,"onExpandDir",2);P([h({attribute:!1})],S.prototype,"onSelectFile",2);P([h({attribute:!1})],S.prototype,"onRefreshGit",2);P([h({attribute:!1})],S.prototype,"onSelectDiff",2);P([h({type:Number})],S.prototype,"activeTerminalCount",2);P([h({type:Boolean})],S.prototype,"terminalAutoStart",2);S=P([W("workspace-panel")],S);var Hl=Object.defineProperty,Vl=Object.getOwnPropertyDescriptor,We=(t,e,s,i)=>{for(var r=i>1?void 0:i?Vl(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(r=(i?n(e,s,r):n(r))||r);return i&&r&&Hl(e,s,r),r};let pe=class extends _{constructor(){super(...arguments),this.state=Kr(),this.sessions=new Vo(()=>this.state,t=>{this.setState(t)},()=>{this.updateUrl()}),this.workspaces=new Jo(()=>this.state,t=>{this.setState(t)},()=>{this.updateUrl()},this.sessions),this.projects=new to(()=>this.state,t=>{this.setState(t)},this.workspaces),this.files=new Jr(()=>this.state,t=>{this.setState(t)},()=>{this.updateUrl()}),this.git=new eo(()=>this.state,t=>{this.setState(t)},()=>{this.updateUrl()}),this.keyboard=new Xo,this.realtime=new Oo,this.activeTerminalIds=new Set,this.mobileNavigationMedia=typeof window<"u"&&"matchMedia"in window?window.matchMedia("(max-width: 760px)"):void 0,this.plugins=Gl(),this.isMobileNavigationLayout=this.mobileNavigationMedia?.matches??!1,this.onPopState=()=>{this.withChatScrollTransition(()=>this.restoreRoute(!1))},this.onFocus=()=>{this.sessions.refreshSelectedSession()},this.onVisibilityChange=()=>{document.visibilityState==="visible"&&this.sessions.refreshSelectedSession()},this.onMobileNavigationMediaChange=t=>{this.isMobileNavigationLayout=t.matches},this.onKeyDown=t=>{this.keyboard.handle(t,this.getActions())&&(t.preventDefault(),t.stopPropagation())}}connectedCallback(){super.connectedCallback(),window.addEventListener("popstate",this.onPopState),window.addEventListener("focus",this.onFocus),document.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("keydown",this.onKeyDown),this.mobileNavigationMedia?.addEventListener("change",this.onMobileNavigationMediaChange),this.connectRealtime(),this.loadExternalPlugins(),this.loadProjectsAndRestoreRoute()}disconnectedCallback(){window.removeEventListener("popstate",this.onPopState),window.removeEventListener("focus",this.onFocus),document.removeEventListener("visibilitychange",this.onVisibilityChange),window.removeEventListener("keydown",this.onKeyDown),this.mobileNavigationMedia?.removeEventListener("change",this.onMobileNavigationMediaChange),this.keyboard.reset(),this.sessions.dispose(),this.realtime.close(),this.git.dispose(),super.disconnectedCallback()}setState(t){if(!Kl(this.state,t))return;const e=this.state;this.state={...this.state,...t},this.handleActivityTransition(e,this.state),this.handleWorkspaceChange(e,this.state)}async loadProjectsAndRestoreRoute(){await this.projects.loadProjects(),await this.withChatScrollTransition(()=>this.restoreRoute(!1))}async restoreRoute(t){const e=Mn(),s=fs(Ze("core:workspace.files"),"file"),i=fs(Ze("core:workspace.git"),"diff");if(this.setState({workspaceTool:e.tool??this.state.workspaceTool,mainView:e.view??this.
|
|
771
|
+
`}renderPanelTitle(t,e){const s=t.badge?.(e);return s===void 0||s===""?p`${t.title}`:p`${t.title} <span class="tab-badge">${s}</span>`}createPanelContext(t){return{workspace:t,fileTree:this.fileTree,expandedDirs:this.expandedDirs,selectedFilePath:this.selectedFilePath,selectedFileContent:this.selectedFileContent,fileTreeStale:this.fileTreeStale,gitStatus:this.gitStatus,selectedDiffPath:this.selectedDiffPath,selectedDiff:this.selectedDiff,selectedStagedDiff:this.selectedStagedDiff,gitStale:this.gitStale,activeTerminalCount:this.activeTerminalCount,terminalAutoStart:this.terminalAutoStart,onRefreshFiles:this.onRefreshFiles,onExpandDir:this.onExpandDir,onSelectFile:this.onSelectFile,onRefreshGit:this.onRefreshGit,onSelectDiff:this.onSelectDiff}}};S.styles=jn;P([h({attribute:!1})],S.prototype,"workspace",2);P([h()],S.prototype,"tool",2);P([h({attribute:!1})],S.prototype,"panels",2);P([h({attribute:!1})],S.prototype,"workspaceLabelItems",2);P([h({type:Boolean})],S.prototype,"hideToolTabs",2);P([h({attribute:!1})],S.prototype,"fileTree",2);P([h({attribute:!1})],S.prototype,"expandedDirs",2);P([h({attribute:!1})],S.prototype,"selectedFilePath",2);P([h({attribute:!1})],S.prototype,"selectedFileContent",2);P([h({type:Boolean})],S.prototype,"fileTreeStale",2);P([h({attribute:!1})],S.prototype,"gitStatus",2);P([h({attribute:!1})],S.prototype,"selectedDiffPath",2);P([h({attribute:!1})],S.prototype,"selectedDiff",2);P([h({attribute:!1})],S.prototype,"selectedStagedDiff",2);P([h({type:Boolean})],S.prototype,"gitStale",2);P([h({attribute:!1})],S.prototype,"onSelectTool",2);P([h({attribute:!1})],S.prototype,"onRefreshFiles",2);P([h({attribute:!1})],S.prototype,"onExpandDir",2);P([h({attribute:!1})],S.prototype,"onSelectFile",2);P([h({attribute:!1})],S.prototype,"onRefreshGit",2);P([h({attribute:!1})],S.prototype,"onSelectDiff",2);P([h({type:Number})],S.prototype,"activeTerminalCount",2);P([h({type:Boolean})],S.prototype,"terminalAutoStart",2);S=P([W("workspace-panel")],S);var Hl=Object.defineProperty,Vl=Object.getOwnPropertyDescriptor,We=(t,e,s,i)=>{for(var r=i>1?void 0:i?Vl(e,s):e,o=t.length-1,n;o>=0;o--)(n=t[o])&&(r=(i?n(e,s,r):n(r))||r);return i&&r&&Hl(e,s,r),r};let pe=class extends _{constructor(){super(...arguments),this.state=Kr(),this.sessions=new Vo(()=>this.state,t=>{this.setState(t)},()=>{this.updateUrl()}),this.workspaces=new Jo(()=>this.state,t=>{this.setState(t)},()=>{this.updateUrl()},this.sessions),this.projects=new to(()=>this.state,t=>{this.setState(t)},this.workspaces),this.files=new Jr(()=>this.state,t=>{this.setState(t)},()=>{this.updateUrl()}),this.git=new eo(()=>this.state,t=>{this.setState(t)},()=>{this.updateUrl()}),this.keyboard=new Xo,this.realtime=new Oo,this.activeTerminalIds=new Set,this.mobileNavigationMedia=typeof window<"u"&&"matchMedia"in window?window.matchMedia("(max-width: 760px)"):void 0,this.plugins=Gl(),this.isMobileNavigationLayout=this.mobileNavigationMedia?.matches??!1,this.onPopState=()=>{this.withChatScrollTransition(()=>this.restoreRoute(!1))},this.onFocus=()=>{this.sessions.refreshSelectedSession()},this.onVisibilityChange=()=>{document.visibilityState==="visible"&&this.sessions.refreshSelectedSession()},this.onMobileNavigationMediaChange=t=>{this.isMobileNavigationLayout=t.matches},this.onKeyDown=t=>{this.keyboard.handle(t,this.getActions())&&(t.preventDefault(),t.stopPropagation())}}connectedCallback(){super.connectedCallback(),window.addEventListener("popstate",this.onPopState),window.addEventListener("focus",this.onFocus),document.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("keydown",this.onKeyDown),this.mobileNavigationMedia?.addEventListener("change",this.onMobileNavigationMediaChange),this.connectRealtime(),this.loadExternalPlugins(),this.loadProjectsAndRestoreRoute()}disconnectedCallback(){window.removeEventListener("popstate",this.onPopState),window.removeEventListener("focus",this.onFocus),document.removeEventListener("visibilitychange",this.onVisibilityChange),window.removeEventListener("keydown",this.onKeyDown),this.mobileNavigationMedia?.removeEventListener("change",this.onMobileNavigationMediaChange),this.keyboard.reset(),this.sessions.dispose(),this.realtime.close(),this.git.dispose(),super.disconnectedCallback()}setState(t){if(!Kl(this.state,t))return;const e=this.state;this.state={...this.state,...t},this.handleActivityTransition(e,this.state),this.handleWorkspaceChange(e,this.state)}async loadProjectsAndRestoreRoute(){await this.projects.loadProjects(),await this.withChatScrollTransition(()=>this.restoreRoute(!1))}async restoreRoute(t){const e=Mn(),s=fs(Ze("core:workspace.files"),"file"),i=fs(Ze("core:workspace.git"),"diff");if(this.setState({workspaceTool:e.tool??this.state.workspaceTool,mainView:e.view??this.defaultRouteView(),selectedFilePath:s,selectedDiffPath:i}),e.projectId===void 0||e.projectId==="")return;const r=this.state.projects.find(o=>o.id===e.projectId);r&&(await this.workspaces.selectProject(r,{workspaceId:e.workspaceId,sessionId:e.sessionId,updateUrl:t}),this.setState({selectedFilePath:s,selectedDiffPath:i}),e.tool==="core:workspace.files"&&await this.files.refreshFiles(),e.tool==="core:workspace.files"&&s!==void 0&&await this.files.restoreFile(s),e.tool==="core:workspace.git"&&await this.git.refreshGit(),this.git.updatePolling())}async withChatScrollTransition(t){this.chatView?.saveScrollPosition(),await t(),await this.updateComplete,await this.chatView?.updateComplete,await Zl(),this.chatView?.restoreScrollPosition(),this.promptEditor?.focusInput()}async withChatPrependTransition(t){await t(),await this.updateComplete,await this.chatView?.updateComplete}defaultRouteView(){return this.isMobileNavigationLayout?"navigation":"chat"}updateUrl(t){En({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},t)}openWorkspaceTool(t){t==="core:workspace.terminal"&&(this.terminalAutoStartWorkspaceId=this.state.selectedWorkspace?.id),this.setState({workspaceTool:t,mainView:t}),this.updateUrl(),this.refreshSelectedWorkspaceTool(t),this.git.updatePolling()}selectMainView(t){if(t!=="navigation"&&t!=="chat"){this.openWorkspaceTool(t);return}this.setState({mainView:t}),this.updateUrl(),this.git.updatePolling()}handleWorkspaceChange(t,e){t.selectedWorkspace?.id!==e.selectedWorkspace?.id&&(this.terminalAutoStartWorkspaceId=void 0,this.activeTerminalIds.clear(),this.setState({activeTerminalCount:0}),e.selectedWorkspace!==void 0&&(this.refreshActiveTerminals(e.selectedWorkspace),this.refreshSelectedWorkspaceTool(e.workspaceTool),this.git.updatePolling()))}connectRealtime(){this.realtime.connect(t=>{this.handleRealtimeEvent(t)},()=>{const t=this.state.selectedWorkspace;t!==void 0&&this.refreshActiveTerminals(t)})}handleRealtimeEvent(t){Ql(t)?this.applyTerminalEvent(t):this.sessions.applyGlobalEvent(t)}applyTerminalEvent(t){const e=this.state.selectedWorkspace;e===void 0||(t.type==="terminal.closed"?t.cwd:t.terminal.cwd)!==e.path||(t.type==="terminal.created"&&!t.terminal.exited?this.activeTerminalIds.add(t.terminal.id):this.activeTerminalIds.delete(t.type==="terminal.closed"?t.terminalId:t.terminal.id),this.setState({activeTerminalCount:this.activeTerminalIds.size}))}async refreshActiveTerminals(t){try{const e=await Qs.terminals(t.projectId,t.id);if(this.state.selectedWorkspace?.id!==t.id)return;this.activeTerminalIds.clear();for(const s of e)s.exited||this.activeTerminalIds.add(s.id);this.setState({activeTerminalCount:this.activeTerminalIds.size})}catch(e){this.setState({error:String(e)})}}handleActivityTransition(t,e){const s=zs(t.status),i=zs(e.status);s&&!i&&(this.setState({fileTreeStale:!0,gitStale:!0}),this.refreshSelectedWorkspaceTool(this.state.workspaceTool))}refreshSelectedWorkspaceTool(t){t==="core:workspace.files"&&this.files.refreshFiles(),t==="core:workspace.git"&&this.git.refreshGit()}renderWorkspacePanel(){const t=this.state.selectedWorkspace===void 0?[]:this.plugins.getWorkspaceLabelItems(this.state,this.state.selectedWorkspace);return p`<workspace-panel .workspace=${this.state.selectedWorkspace} .tool=${this.state.workspaceTool} .panels=${this.visibleWorkspacePanels()} .workspaceLabelItems=${t} .fileTree=${this.state.fileTree} .expandedDirs=${this.state.expandedDirs} .selectedFilePath=${this.state.selectedFilePath} .selectedFileContent=${this.state.selectedFileContent} .fileTreeStale=${this.state.fileTreeStale} .gitStatus=${this.state.gitStatus} .selectedDiffPath=${this.state.selectedDiffPath} .selectedDiff=${this.state.selectedDiff} .selectedStagedDiff=${this.state.selectedStagedDiff} .gitStale=${this.state.gitStale} .activeTerminalCount=${this.state.activeTerminalCount} .terminalAutoStart=${this.terminalAutoStartWorkspaceId===this.state.selectedWorkspace?.id} .onSelectTool=${e=>{this.openWorkspaceTool(e)}} .onRefreshFiles=${()=>this.files.refreshFiles()} .onExpandDir=${e=>this.files.expandDir(e)} .onSelectFile=${e=>this.files.selectFile(e)} .onRefreshGit=${()=>this.git.refreshGit()} .onSelectDiff=${e=>this.git.selectDiff(e)}></workspace-panel>`}renderNavigationPanel(t){const e=s=>this.withChatScrollTransition(async()=>{await s(),t&&this.setState({mainView:"chat"}),t&&this.updateUrl()});return p`
|
|
772
772
|
<header>
|
|
773
773
|
<strong>Pi Web</strong>
|
|
774
774
|
<button title="Show Actions" aria-label="Show Actions" @click=${()=>{this.setState({actionPaletteOpen:!0})}}>Actions</button>
|
|
775
775
|
</header>
|
|
776
776
|
<project-list .projects=${this.state.projects} .selected=${this.state.selectedProject} .onSelect=${s=>this.withChatScrollTransition(()=>this.workspaces.selectProject(s))} .onClose=${s=>this.projects.closeProject(s.id)}></project-list>
|
|
777
|
-
<workspace-list .workspaces=${this.state.workspaces} .selected=${this.state.selectedWorkspace} .workspaceLabelItems=${s=>this.plugins.getWorkspaceLabelItems(this.state,s)} .onSelect=${s=>
|
|
777
|
+
<workspace-list .workspaces=${this.state.workspaces} .selected=${this.state.selectedWorkspace} .workspaceLabelItems=${s=>this.plugins.getWorkspaceLabelItems(this.state,s)} .onSelect=${s=>this.withChatScrollTransition(()=>this.workspaces.selectWorkspace(s))}></workspace-list>
|
|
778
778
|
<session-list .sessions=${this.state.sessions} .statuses=${this.state.sessionStatuses} .activities=${this.state.sessionActivities} .selected=${this.state.selectedSession} .canStart=${!!this.state.selectedWorkspace} .onStart=${()=>e(()=>this.sessions.startSession())} .onSelect=${s=>e(()=>this.sessions.selectSession(s))} .onArchive=${s=>this.sessions.archiveSession(s)} .onRestore=${s=>e(()=>this.sessions.restoreSession(s))} .onDetachParent=${s=>this.sessions.detachParent(s)}></session-list>
|
|
779
779
|
`}visibleWorkspacePanels(){const t=this.state.selectedWorkspace;return this.plugins.getWorkspacePanels().filter(e=>t===void 0||(e.visible?.(t)??!0))}renderMobilePanelTitle(t){const e=this.state.selectedWorkspace;if(e===void 0)return t.title;const s=t.badge?.(this.createWorkspacePanelContext(e));return s===void 0||s===""?t.title:p`${t.title} <span class="tab-badge">${s}</span>`}createWorkspacePanelContext(t){return{workspace:t,fileTree:this.state.fileTree,expandedDirs:this.state.expandedDirs,selectedFilePath:this.state.selectedFilePath,selectedFileContent:this.state.selectedFileContent,fileTreeStale:this.state.fileTreeStale,gitStatus:this.state.gitStatus,selectedDiffPath:this.state.selectedDiffPath,selectedDiff:this.state.selectedDiff,selectedStagedDiff:this.state.selectedStagedDiff,gitStale:this.state.gitStale,activeTerminalCount:this.state.activeTerminalCount,terminalAutoStart:this.terminalAutoStartWorkspaceId===t.id,onRefreshFiles:()=>{this.files.refreshFiles()},onExpandDir:e=>{this.files.expandDir(e)},onSelectFile:e=>{this.files.selectFile(e)},onRefreshGit:()=>{this.git.refreshGit()},onSelectDiff:e=>{this.git.selectDiff(e)}}}getActions(){return this.plugins.getActions(this.createPluginRuntimeContext())}async loadExternalPlugins(){try{for(const t of await kn())this.plugins.register(t);this.requestUpdate()}catch(t){console.warn("Failed to load external Pi Web plugins",t)}}createPluginRuntimeContext(){return{state:this.state,openActionPalette:()=>{this.setState({actionPaletteOpen:!0})},focusPrompt:()=>{this.promptEditor?.focusInput()},addProject:()=>{this.setState({projectDialogOpen:!0})},selectMainView:t=>{this.selectMainView(t)},selectWorkspaceTool:t=>{this.openWorkspaceTool(t)},refreshFiles:()=>this.files.refreshFiles(),refreshGit:()=>this.git.refreshGit(),startSession:()=>this.withChatScrollTransition(()=>this.sessions.startSession()),archiveSession:()=>this.sessions.archiveSession(),stopActiveWork:()=>this.sessions.stopActiveWork()}}runAction(t){const e=this.getActions().find(s=>s.id===t&&s.enabled!==!1);e!==void 0&&e.run()}async openModelDialog(){const t=await this.sessions.listModels(),e=this.state.status?.model?.provider,s=this.state.status?.model?.id;this.setState({modelDialog:{title:"Select Model",...e!==void 0&&s!==void 0?{selectedValue:`${e}/${s}`}:{},options:t.map(i=>{const r=i.provider??"",o=i.id??"",n=r===e&&o===s;return{value:`${r}/${o}`,label:`${o}${n?" ✓ current":""}`,description:r}})}})}async pickModel(t){this.setState({modelDialog:void 0});const e=t.indexOf("/");e<=0||await this.sessions.setModel(t.slice(0,e),t.slice(e+1))}async openThinkingDialog(){const t=await this.sessions.listThinkingLevels(),e=this.state.status?.thinkingLevel??"off";this.setState({thinkingDialog:{title:"Select Thinking Level",selectedValue:e,options:t.map(s=>({value:s,label:`${s}${s===e?" ✓ current":""}`,description:Yl(s)}))}})}async pickThinking(t){this.setState({thinkingDialog:void 0}),Jl(t)&&await this.sessions.setThinkingLevel(t)}render(){const t=this.state;return p`
|
|
780
780
|
<div class=${`shell ${t.mainView==="navigation"?"navigation-view":t.mainView==="chat"?"chat-view":"workspace-view"}`}>
|
package/dist/client/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
html, body { margin: 0; height: 100%; overflow: hidden; }
|
|
9
9
|
body { min-height: 100dvh; }
|
|
10
10
|
</style>
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-C0G9UyhD.js"></script>
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/vendor-editor-core-B4Sq6exx.js">
|
|
13
13
|
<link rel="modulepreload" crossorigin href="/assets/vendor-editor-languages-DznYbTkJ.js">
|
|
14
14
|
</head>
|
package/extensions/pi-web.ts
CHANGED
|
@@ -6,8 +6,6 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
|
6
6
|
|
|
7
7
|
const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
8
8
|
const cliPath = join(packageRoot, "dist", "cli.js");
|
|
9
|
-
const serverPath = join(packageRoot, "dist", "server", "index.js");
|
|
10
|
-
const sessiondPath = join(packageRoot, "dist", "server", "sessiond.js");
|
|
11
9
|
const serviceNames = ["pi-web-sessiond.service", "pi-web.service"];
|
|
12
10
|
|
|
13
11
|
const subcommands = [
|
|
@@ -25,14 +23,6 @@ const subcommands = [
|
|
|
25
23
|
|
|
26
24
|
type Subcommand = (typeof subcommands)[number];
|
|
27
25
|
|
|
28
|
-
function shellSingleQuote(value: string): string {
|
|
29
|
-
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function nodeCommand(scriptPath: string): string {
|
|
33
|
-
return `${shellSingleQuote(process.execPath)} ${shellSingleQuote(scriptPath)}`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
26
|
function parseArgs(args: string): string[] {
|
|
37
27
|
return args.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g)?.map((part) => {
|
|
38
28
|
if ((part.startsWith('"') && part.endsWith('"')) || (part.startsWith("'") && part.endsWith("'"))) {
|
|
@@ -85,14 +75,6 @@ function isSubcommand(value: string): value is Subcommand {
|
|
|
85
75
|
return subcommands.some((command) => command === value);
|
|
86
76
|
}
|
|
87
77
|
|
|
88
|
-
function installEnv(): NodeJS.ProcessEnv {
|
|
89
|
-
if (!existsSync(serverPath) || !existsSync(sessiondPath)) return {};
|
|
90
|
-
return {
|
|
91
|
-
PI_WEB_SERVER_EXEC: nodeCommand(serverPath),
|
|
92
|
-
PI_WEB_SESSIOND_EXEC: nodeCommand(sessiondPath),
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
78
|
async function boundedLogs(): Promise<{ code: number; output: string }> {
|
|
97
79
|
return run("journalctl", ["--user", "-u", serviceNames[0] ?? "", "-u", serviceNames[1] ?? "", "-n", "100", "--no-pager"]);
|
|
98
80
|
}
|
|
@@ -137,8 +119,7 @@ export default function piWebExtension(pi: ExtensionAPI): void {
|
|
|
137
119
|
return;
|
|
138
120
|
}
|
|
139
121
|
|
|
140
|
-
|
|
141
|
-
showResult(ctx, `pi-web ${subcommand}`, await runPiWeb([subcommand, ...rest], env));
|
|
122
|
+
showResult(ctx, `pi-web ${subcommand}`, await runPiWeb([subcommand, ...rest]));
|
|
142
123
|
},
|
|
143
124
|
});
|
|
144
125
|
}
|
package/package.json
CHANGED