pi-webapp 0.1.57 → 0.1.58-alpha.1

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.
Files changed (42) hide show
  1. package/dist/extension.js +71 -71
  2. package/dist/hosted-recovery.js +2 -2
  3. package/dist/hosted-worker.js +2 -2
  4. package/docs/desktop.md +16 -5
  5. package/package.json +3 -2
  6. package/web/dist/.vite/manifest.json +80 -64
  7. package/web/dist/assets/{MarkdownText-Ca6_qCyr.js → MarkdownText-BmWua1fx.js} +11 -11
  8. package/web/dist/assets/WorkspacePanel.module-q1UBTZQr.js +2 -0
  9. package/web/dist/assets/app-Bl_vjH4f.js +53 -0
  10. package/web/dist/assets/app.css +1 -1
  11. package/web/dist/assets/app.js +4 -4
  12. package/web/dist/assets/{code-editor-B5kVAtku.js → code-editor-bWuZTiS2.js} +4 -4
  13. package/web/dist/assets/{icons-D8yiYkWB.js → code-file-types-BZAEsqNG.js} +3 -3
  14. package/web/dist/assets/{dist-CWWynAS-.js → dist-B8Mp_VTU.js} +2 -2
  15. package/web/dist/assets/{dist-o-4nubru.js → dist-BD_2QeWa.js} +2 -2
  16. package/web/dist/assets/{dist-Im2q9dJ0.js → dist-C2WSXtwq.js} +2 -2
  17. package/web/dist/assets/{dist-BRYLL4VU.js → dist-C7kRRV1b.js} +2 -2
  18. package/web/dist/assets/{dist-CaNhruaD.js → dist-CCfANS3F.js} +2 -2
  19. package/web/dist/assets/{dist-BFhI7cEI.js → dist-CP5SBgQB.js} +2 -2
  20. package/web/dist/assets/{dist-DAlictfL.js → dist-CmPE8_f_.js} +2 -2
  21. package/web/dist/assets/{dist-CszBAiM6.js → dist-D-nx7RRS.js} +2 -2
  22. package/web/dist/assets/{dist-BYJ4SXpR.js → dist-DFTCmV51.js} +2 -2
  23. package/web/dist/assets/{dist-CsFhAvz7.js → dist-Dr0qO3Zr.js} +2 -2
  24. package/web/dist/assets/{dist-CqXTRhJp.js → dist-Nlb4zANG.js} +2 -2
  25. package/web/dist/assets/{graphql-Cz1_wnUp.js → graphql-B5jxVvgN.js} +2 -2
  26. package/web/dist/assets/{http-CTlzQwRP.js → http-C6M1fy61.js} +2 -2
  27. package/web/dist/assets/{php-BHNgHgMp.js → php-B61pLHqK.js} +2 -2
  28. package/web/dist/assets/{plugin-D1z0mcl1.js → plugin-CE1WaS8V.js} +4 -4
  29. package/web/dist/assets/plugin-CsVaeNQM.js +6 -0
  30. package/web/dist/assets/plugin-Cyidq4oP.js +2 -0
  31. package/web/dist/assets/plugin-Gwwlx9MU.js +4 -0
  32. package/web/dist/assets/plugin.css +1 -1
  33. package/web/dist/assets/plugin2.css +1 -1
  34. package/web/dist/assets/plugin3.css +1 -0
  35. package/web/dist/assets/{rst-BdGjFUxD.js → rst-950N-2sy.js} +2 -2
  36. package/web/dist/assets/{ruby-D7-ny0V-.js → ruby-Qm2HAXfx.js} +2 -2
  37. package/web/dist/assets/{svelte-DoD3sicb.js → svelte-CoZSSs0h.js} +2 -2
  38. package/web/dist/assets/{vue-BYLUelN7.js → vue-as6FrWIW.js} +2 -2
  39. package/web/dist/assets/WorkspacePanel.module-V6gI-nG1.js +0 -2
  40. package/web/dist/assets/app-CIlV3hYO.js +0 -49
  41. package/web/dist/assets/plugin-CZx51rmJ.js +0 -6
  42. package/web/dist/assets/plugin-CvqNiFRV.js +0 -4
@@ -1,4 +1,4 @@
1
- (function(){try{var t=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="f5e92d57-a779-445f-8ea1-b9439fffc663",t._sentryDebugIdIdentifier="sentry-dbid-f5e92d57-a779-445f-8ea1-b9439fffc663")}catch{}})();import{resolve as Me}from"node:path";import{lstat as le,mkdir as Ce,readdir as Fe,rename as de}from"node:fs/promises";import{join as k}from"node:path";import{createHash as me}from"node:crypto";var s=class extends Error{code;status;reason;constructor(e,n,r={}){super(n),this.name="HostedPluginError",this.code=e,this.status=r.status,this.reason=r.reason}};var $=t=>t.code==="ENOENT";var rt={files:4096,total:128*1024*1024,js:16*1024*1024,css:4*1024*1024,font:8*1024*1024,wasm:16*1024*1024,other:2*1024*1024};var v=t=>me("sha256").update(t).digest("hex");import{constants as J}from"node:fs";import{DatabaseSync as ye}from"node:sqlite";import{lstat as Y,mkdir as ve,open as N,rename as be,unlink as Z}from"node:fs/promises";import{dirname as ke,join as X,resolve as Ie}from"node:path";import{randomUUID as _e}from"node:crypto";import{setTimeout as xe}from"node:timers/promises";async function O(t){await ve(t,{recursive:!0,mode:448});let e=await Y(t);if(!e.isDirectory()||e.isSymbolicLink())throw new s("invalid_storage","Plugin storage must be a real directory")}async function w(t,e){let n;try{n=await N(t,J.O_RDONLY|J.O_NONBLOCK|(J.O_NOFOLLOW??0))}catch(r){if($(r))return null;throw r}try{let r=await n.stat();if(!r.isFile()||r.nlink>1||r.size>e)throw new s("invalid_storage","Invalid storage record size or type");let o=Buffer.alloc(Math.min(r.size+1,e+1)),i=0;for(;i<o.length;){let a=await n.read(o,i,o.length-i,i);if(!a.bytesRead)break;i+=a.bytesRead}if(i>e||i!==r.size)throw new s("invalid_storage","Storage record changed during read");return o.subarray(0,i)}finally{await n.close()}}async function A(t,e=2*1024*1024){let n=await w(t,e);if(!n)return null;try{return JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(n))}catch{throw new s("invalid_storage","Invalid JSON storage record; original bytes preserved")}}async function I(t){let e=await w(t,2097152);if(e===null)return null;let n;try{n=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e))}catch{throw new s("gc_recovery_required",`Invalid journal ${t}; stop all owners and inspect original bytes`)}if(!n||typeof n!="object"||Array.isArray(n))throw new s("gc_recovery_required",`Invalid journal ${t}; original bytes preserved`);return n}async function b(t,e){let n=`${t}.${_e()}.tmp`,r=await N(n,"wx",384);try{try{await r.writeFile(JSON.stringify(e)),await r.sync()}finally{await r.close()}await be(n,t);let o;try{o=await N(ke(t),"r"),await o.sync()}catch(i){if(!["EINVAL","EPERM","EACCES","EISDIR","ENOTSUP","EBADF"].includes(i.code??""))throw i}finally{await o?.close()}}finally{await Z(n).catch(()=>{})}}var Q='{"version":2,"mechanism":"sqlite-exclusive"}',C=t=>t.toString("utf8")===Q,L=new Set;async function Se(t,e,n=0){await O(t);let r=X(t,`${e}.lock`),o=X(t,`${e}.ownership.sqlite`),i=e==="runtime"?"runtime_owned":"storage_busy",a=()=>new s(i,"Another host owns this plugin storage or a legacy ownership lock remains; stop all owners and verify a backup before offline recovery"),c;try{c=await N(o,"wx",384)}catch(p){if(p.code!=="EEXIST")throw p}finally{await c?.close()}let d=await Y(o);if(!d.isFile()||d.isSymbolicLink()||d.nlink!==1||d.size>1024*1024)throw new s("invalid_storage","Ownership database must be a small, single-link regular file");let l=new ye(o,{allowExtension:!1}),u=Ie(o),h=Date.now()+n,m=!1;try{for(;;){if(!L.has(u))try{l.exec("BEGIN EXCLUSIVE"),L.add(u),m=!0;break}catch(y){if(y.errcode!==5)throw y}if(Date.now()>=h)throw new s(i,"Another host owns this plugin storage; wait for it to stop before retrying");await xe(10)}let p=await w(r,4096);if(p===null){let y;try{y=await N(r,"wx",384),await y.writeFile(Q),await y.sync()}catch(_){if(_.code!=="EEXIST")throw _}finally{await y?.close()}p=await w(r,4096)}if(p===null||!C(p))throw a()}catch(p){throw l.close(),m&&L.delete(u),p}let g=!1;return async()=>{if(g)return;let p=await w(r,4096);if(p===null||!C(p))throw new s("invalid_storage","Ownership fence changed while held; preserve custody and inspect storage");await Z(r),l.close(),L.delete(u),g=!0}}async function x(t,e,n=2e3){let r=await Se(t,"transaction",n);try{return await e()}finally{await r()}}import{readdir as pt,realpath as ht,rename as Pe,stat as Re}from"node:fs/promises";import{join as U}from"node:path";var F=t=>U(t,"host-pair");var yt=10*6e4;async function Ee(t){await Pe(t,`${t}.corrupt-${Date.now()}`).catch(e=>{if(e.code!=="ENOENT")throw e})}var Oe=t=>t.schema===1&&/^[a-f0-9-]{36}$/.test(t.id)&&typeof t.version=="string"&&typeof t.packageRoot=="string"&&/^[a-f0-9]{64}$/.test(t.hostDigest)&&/^[a-f0-9]{64}$/.test(t.fingerprint)&&Array.isArray(t.selections)&&!t.selections.some(e=>!e||typeof e.id!="string"||typeof e.version!="string"||!/^[a-f0-9]{64}$/.test(e.digest)||!Object.hasOwn(e,"before"))&&!(t.selection&&(typeof t.selection.path!="string"||!/^[a-f0-9]{64}$/.test(t.selection.digest)))&&["prepared","selecting","selected","restart-requested","reconciled","cancelled","required-action"].includes(t.phase);async function ee(t){let e=U(F(t),"intent.json"),n,r=!0;try{n=await I(e)}catch{n=null,r=!1}if(!r||n&&!Oe(n))return await Ee(e),null;if(n){let{lifecyclePhase:o,...i}=n,a=typeof i.updatedAt=="string"&&!Number.isNaN(Date.parse(i.updatedAt))?i.updatedAt:await Re(e).then(c=>c.mtime.toISOString(),()=>new Date(0).toISOString());n={...i,updatedAt:a,phase:i.phase==="selected"&&o==="restart-requested"?"restart-requested":i.phase==="reconciled"&&o==="cancelled"?"cancelled":i.phase==="reconciled"&&o==="required-action"?"required-action":i.phase}}return n}async function te(t,e){let{lifecyclePhase:n,...r}={...e,selections:[],updatedAt:new Date().toISOString()},o=r.phase==="cancelled"?{...r,phase:"reconciled",lifecyclePhase:"cancelled"}:r.phase==="required-action"?{...r,phase:"reconciled",lifecyclePhase:"required-action"}:r.phase==="restart-requested"?{...r,phase:"selected",lifecyclePhase:"restart-requested"}:r;await b(U(F(t),"intent.json"),o)}import{lstat as M,mkdir as Ae,open as ne,realpath as ie,readdir as B,link as je,rename as Ne,unlink as S,copyFile as He,rm as Te}from"node:fs/promises";import{dirname as De,isAbsolute as oe,join as f,relative as se,resolve as qe,sep as z,win32 as $e}from"node:path";import{randomUUID as G}from"node:crypto";var kt=64*1024*1024,re=Object.freeze([Object.freeze({extension:".excalidraw",binary:!1,maxBytes:512*1024,createDirectory:"diagrams"})]);var H=192*1024*1024,At=512*1024,ce=t=>typeof t=="string"&&/^[a-f0-9-]{36}$/.test(t);function Le(t){if(!t||typeof t!="object"||Array.isArray(t))throw new s("invalid_input","Expected object input");return t}function ae(t){if(typeof t!="string"||!/^[\w.-]{1,160}$/.test(t)||t==="."||t==="..")throw new s("invalid_input","Invalid state key");return t}function T(t){if(t&&(!ce(t.stateRef)||typeof t.version!="string"||!Number.isSafeInteger(t.generation)||t.generation<1||!Number.isSafeInteger(t.schema)||t.schema<1||typeof t.enabled!="boolean"||typeof t.operationId!="string"))throw new s("invalid_storage","Invalid active plugin record");return t}var D=class{root;pluginId;legacy;checkpoint;files;constructor(e,n,r,o,i=re){this.root=f(e,v(n)),this.pluginId=n,this.legacy=r,this.checkpoint=o,this.files=i}rule(e){let n=typeof e=="string"?this.files.find(r=>e.toLowerCase().endsWith(r.extension)):void 0;if(!n)throw new s("invalid_path",`Use a workspace-relative ${this.files.map(r=>r.extension).join("/")} path`);return n}active(){return A(f(this.root,"active.json")).then(T)}async recover(){return x(this.root,async()=>{let e=await this.active(),n=await I(f(this.root,"transition.json"));if(!n)return{active:e,recovered:"none"};if(!n.next||!Object.hasOwn(n,"before")||Object.keys(n).some(a=>!["version","before","next"].includes(a))||Object.hasOwn(n,"version")&&n.version!==1)throw new s("invalid_storage","Invalid activation journal; stop all owners and inspect transition.json");T(n.next),T(n.before);let r=e?.operationId===n.next.operationId?"committed":"not_committed";if(!((a,c)=>a===null||c===null?a===c:["version","generation","stateRef","schema","enabled","operationId"].every(d=>a[d]===c[d]))(e,r==="committed"?n.next:n.before))throw new s("gc_recovery_required","Activation journal does not match the active pointer; original bytes preserved");let i=n.before;if(r==="committed"&&i&&i.stateRef!==e.stateRef&&await b(f(this.root,"previous.json"),i),r==="committed"){let a=await I(f(this.root,"fork.json"));a?.version===1&&a.stateRef===e.stateRef&&Object.keys(a).every(c=>["version","stateRef"].includes(c))&&await S(f(this.root,"fork.json"))}return await S(f(this.root,"transition.json")),{active:e,recovered:r}})}async activate(e,n){return x(this.root,async()=>{let r=await this.active();if((r?.generation??0)!==e)throw new s("stale_generation","Plugin activation changed concurrently");let o=await I(f(this.root,"fork.json"));if(o&&(o.version!==1||o.stateRef!==n.stateRef||Object.keys(o).some(a=>!["version","stateRef"].includes(a))))throw new s("gc_recovery_required","Activation refused: unresolved fork.json belongs to another target; stop all owners and inspect it");let i=T({...n,generation:e+1,operationId:G()});await O(f(this.root,"states")),await O(f(this.root,"states",i.stateRef)),await b(f(this.root,"transition.json"),{version:1,before:r,next:i}),await this.checkpoint?.("prepared");try{await b(f(this.root,"active.json"),i)}catch(a){if((await this.active())?.operationId!==i.operationId)throw a}await this.checkpoint?.("committed");try{r&&r.stateRef!==i.stateRef&&await b(f(this.root,"previous.json"),r),await S(f(this.root,"transition.json")),await S(f(this.root,"fork.json")).catch(()=>{})}catch{}return await this.checkpoint?.("cleaned"),i})}async forkState(e){return x(this.root,async()=>{let n=await this.assertGeneration(e,!1),r=G(),o=f(this.root,"states",r);if(await I(f(this.root,"fork.json")))throw new s("gc_recovery_required","Unresolved fork.json; stop all owners and inspect the reserved state before retrying");await b(f(this.root,"fork.json"),{version:1,stateRef:r}),await O(o);let i=f(this.root,"states",n.stateRef);for(let a of await B(i)){if(!/^[a-f0-9]{64}\.json$/.test(a))throw new s("invalid_storage","Unexpected state file");if(!await w(f(i,a),H))throw new s("invalid_storage","Missing state file");await He(f(i,a),f(o,a))}return await this.checkpoint?.("forked"),r})}async collect(e){return x(this.root,async()=>{for(let l of["transition.json","fork.json"])if(await w(f(this.root,l),2*1024*1024))throw new s("gc_recovery_required",`GC refused: unresolved ${l}; stop all owners and inspect recovery references`);let n=await this.active(),r=T(await I(f(this.root,"previous.json")));if(!n&&await w(f(this.root,"active.json"),2*1024*1024))throw new s("gc_recovery_required","GC refused: null active pointer; restore activation metadata before cleanup");let o=[n,r].filter(l=>!!l),i=f(this.root,"states");await O(i);let a=await B(i),c=new Set(o.map(l=>l.stateRef));for(let l of a){if(!ce(l))throw new s("gc_recovery_required","GC refused: unexpected state directory; inspect states before cleanup");let u=f(i,l),h=await M(u);if(!h.isDirectory()||h.isSymbolicLink())throw new s("gc_recovery_required","GC refused: linked/non-directory state snapshot");for(let m of await B(u)){let g=await M(f(u,m));if(!/^[a-f0-9]{64}\.json$/.test(m)||!g.isFile()||g.isSymbolicLink()||g.nlink!==1)throw new s("gc_recovery_required","GC refused: unexpected snapshot content; original bytes preserved");if(!c.has(l)){let p=await A(f(u,m),H);if(!p)throw new s("gc_recovery_required","GC refused: missing snapshot record");if(Object.hasOwn(p,"committed")){let y=p;if(Object.keys(y).some(_=>!["requestId","inputHash","nextHash","committed"].includes(_))||y.committed!==!0||!/^[a-f0-9]{64}$/.test(y.inputHash)||!/^[a-f0-9]{64}$/.test(y.nextHash)||typeof y.requestId!="string")throw new s("gc_recovery_required",`GC refused: unresolved file intent in states/${l}; reconcile the workspace save before cleanup`)}else{if(Object.keys(p).some(y=>!["revision","schema","value","requestId","inputHash"].includes(y)))throw new s("gc_recovery_required","GC refused: unknown snapshot envelope; original bytes preserved");this.validateState(p)}}}}for(let l of c)if(!a.includes(l))throw new s("gc_recovery_required","GC refused: referenced snapshot is missing; restore recovery data first");let d=await e(o);for(let l of a)c.has(l)||await Te(f(i,l),{recursive:!0,force:!0});return d})}async assertGeneration(e,n=!0){let r=await this.active();if(!r||r.generation!==e||n&&!r.enabled)throw new s("stale_generation","Plugin generation is no longer active");return r}scopeKey(e){if(!e.scope||typeof e.scope.cwd!="string"||!e.scope.cwd||typeof e.scope.sessionId!="string"||!e.scope.sessionId||typeof e.scope.workspaceId!="string"||!e.scope.workspaceId)throw new s("invalid_scope","Missing authenticated plugin scope");return JSON.stringify([e.scope.workspaceId,e.scope.cwd,e.scope.sessionId])}statePath(e,n,r,o="session"){if(o!=="session"&&o!=="workspace")throw new s("invalid_input","Invalid state scope");let i=o==="workspace"?(this.scopeKey(n),JSON.stringify([n.scope.workspaceId,n.scope.cwd])):this.scopeKey(n);return f(this.root,"states",e.stateRef,`${v(i+":state:"+r)}.json`)}async call(e,n,r){if(!Number.isSafeInteger(e.generation)||!/^[\w-]{1,160}$/.test(e.requestId))throw new s("invalid_lease","Invalid invocation lease");this.scopeKey(e);let o=Le(r);return x(this.root,async()=>{let i=await this.assertGeneration(e.generation);switch(n){case"state.read":{let a=await A(this.statePath(i,e,ae(o.key),o.scope),H);return a?(this.validateState(a),{revision:a.revision,schema:a.schema,value:a.value}):null}case"state.compareAndSwap":{let a=this.statePath(i,e,ae(o.key),o.scope);if(!Number.isSafeInteger(o.expectedRevision)||o.expectedRevision<0||o.schema!==i.schema||!Object.hasOwn(o,"value"))throw new s("invalid_input","Invalid state revision or schema");if(JSON.stringify(o.value)===void 0)throw new s("invalid_input","State value must be JSON serializable");let c=JSON.stringify(o);if(Buffer.byteLength(c)>H)throw new s("state_too_large","Plugin state exceeds limit");let d=await A(a,H);d&&this.validateState(d);let l=v(c);if(d?.requestId===e.requestId&&d.inputHash===l)return{revision:d.revision,schema:d.schema,value:d.value};if((d?.revision??0)!==o.expectedRevision)throw new s("revision_conflict","Plugin state changed concurrently");let u={revision:o.expectedRevision+1,schema:i.schema,value:o.value,requestId:e.requestId,inputHash:l};return await b(a,u),{revision:u.revision,schema:u.schema,value:u.value}}case"workspace.read":{let a=this.rule(o.path),{target:c}=await this.fileTarget(e.scope.cwd,o.path),d=o.maxBytes===void 0?a.maxBytes:o.maxBytes;if(!Number.isSafeInteger(d)||d<=0||d>a.maxBytes)throw new s("invalid_input","Invalid workspace read limit");if(o.encoding!==void 0&&o.encoding!==(a.binary?"base64":"utf-8"))throw new s("invalid_input","Encoding does not match the reviewed file rule");let l=await w(c,d);return l?a.binary?{base64:l.toString("base64"),bytes:l.length,hash:v(l)}:{text:new TextDecoder("utf-8",{fatal:!0}).decode(l),hash:v(l)}:null}case"workspace.commit":return this.commitFile(i,e,o);case"legacy.read":return this.legacy?this.legacy(e):null;default:throw new s("method_denied","Unknown host broker method")}})}validateState(e){if(!Number.isSafeInteger(e.revision)||e.revision<1||!Number.isSafeInteger(e.schema)||e.schema<1||!Object.hasOwn(e,"value")||typeof e.requestId!="string"||!/^[a-f0-9]{64}$/.test(e.inputHash))throw new s("invalid_storage","Invalid plugin state; original bytes preserved")}async fileTarget(e,n,r=!1){let o=this.rule(n);if(typeof n!="string"||n.length>4096||n.includes("\\")||n.includes("\0")||oe(n)||$e.isAbsolute(n))throw new s("invalid_path",`Use a workspace-relative ${o.extension} path`);let i=await ie(e),a=qe(i,n),c=se(i,a);if(!c||c===".."||c.startsWith(`..${z}`)||oe(c))throw new s("invalid_path","Workspace path escapes root");let d=i,l=c.split(z);for(let h=0;h<l.length;h++){d=f(d,l[h]);let m;try{m=await M(d)}catch(g){if(!$(g))throw g;if(h<l.length-1){if(!r||!o.createDirectory||se(i,d)!==o.createDirectory)throw new s("invalid_path","Workspace directory does not exist");try{await Ae(d,{mode:448})}catch(p){if(p.code!=="EEXIST")throw p}m=await M(d)}}if(m&&(m.isSymbolicLink()||(h<l.length-1?!m.isDirectory():!m.isFile()||m.nlink!==1)))throw new s("invalid_path","Workspace path contains a link or non-regular file")}let u=await ie(De(a));if(u!==i&&!u.startsWith(i+z))throw new s("invalid_path","Workspace directory changed");return{target:a,parent:u}}async commitFile(e,n,r){let o=this.rule(r.path),i=o.binary?typeof r.base64=="string"&&r.text===void 0&&/^[A-Za-z0-9+/]*={0,2}$/.test(r.base64)?Buffer.from(r.base64,"base64"):null:typeof r.text=="string"&&r.base64===void 0?Buffer.from(r.text):null;if(!i||i.length>o.maxBytes||!(r.expectedHash===null||typeof r.expectedHash=="string"&&/^[a-f0-9]{64}$/.test(r.expectedHash)))throw new s("invalid_input","Invalid file content or expected hash");let{target:a,parent:c}=await this.fileTarget(n.scope.cwd,r.path,!0),d=f(this.root,"states",e.stateRef,`${v(this.scopeKey(n)+":file:"+n.requestId+":"+String(r.path))}.json`),l=v(JSON.stringify(r)),u=v(i),h=await A(d);if(h&&(h.requestId!==n.requestId||h.inputHash!==l||h.nextHash!==u))throw new s("duplicate_request","Request ID was reused with different content");let m;try{m=await ne(`${a}.lock`,"wx",384)}catch(p){throw p.code==="EEXIST"?new s("file_busy","Workspace file is locked; original file preserved"):p}let g;try{await m.writeFile(JSON.stringify({pid:process.pid,requestId:n.requestId}));let p=await w(a,o.maxBytes),y=p?v(p):null;if(h&&y===u)return{hash:u};if(h?.committed||y!==r.expectedHash)throw new s("file_conflict","Workspace file already exists or changed externally");await b(d,{requestId:n.requestId,inputHash:l,nextHash:u,committed:!1}),g=f(c,`.plugin-${G()}.tmp`);let _=await ne(g,"wx",384);try{await _.writeFile(i),await _.sync()}finally{await _.close()}if((await this.fileTarget(n.scope.cwd,r.path)).parent!==c)throw new s("file_conflict","Workspace directory changed during save");let K=await w(a,o.maxBytes);if((K?v(K):null)!==r.expectedHash)throw new s("file_conflict","Workspace file changed during save");if(await this.assertGeneration(n.generation),r.expectedHash===null){try{await je(g,a)}catch(V){throw V.code==="EEXIST"?new s("file_conflict","Workspace file was created concurrently"):V}await S(g),g=void 0}else await Ne(g,a),g=void 0;return await b(d,{requestId:n.requestId,inputHash:l,nextHash:u,committed:!0}),{hash:u}}finally{g&&await S(g).catch(()=>{}),await m.close(),await S(`${a}.lock`)}}};var W="ALL_HOSTS_AND_PLUGIN_WORKERS_STOPPED_AND_BACKUP_VERIFIED";async function j(t){let e=[];async function n(r,o=""){let i=await le(r);if(!i.isDirectory()||i.isSymbolicLink())throw new s("invalid_storage","Recovery refuses linked/non-directory storage");for(let a of(await Fe(r)).sort()){let c=k(r,a),d=o+a,l=await le(c);if(l.isSymbolicLink())throw new s("invalid_storage","Recovery refuses links");if(l.isDirectory())await n(c,d+"/");else{if(e.length>=1e4)throw new s("invalid_storage","Recovery inspection budget exceeded");let u=await w(c,192*1024*1024);if(!u)throw new s("invalid_storage","Recovery input disappeared");e.push({path:d,bytes:u.length,sha256:v(u)})}}}return await n(t),{fingerprint:v(JSON.stringify(e)),files:e,warning:"Offline only: externally stop/fence ALL hosts and plugin workers, back up storage and workspace files. Never infer stopped ownership from PID alone."}}async function fe(t,e,n,r){let o=new D(t,e),i=await j(o.root);if(r!==W)throw new s("confirmation_required","Explicit stopped-owner and verified-backup confirmation required");if(i.fingerprint!==n)throw new s("recovery_changed","Storage changed since inspection");return o.recover()}async function ue(t,e,n,r){let o=new D(t,e),i=o.root;if(r!==W)throw new s("confirmation_required","Explicit stopped-owner and verified-backup confirmation required");let a=await j(i);if(a.fingerprint!==n)throw new s("recovery_changed","Storage changed since inspection");if(await w(k(i,"transition.json"),2*1024*1024))throw new s("gc_recovery_required","Reconcile transition.json using broker.recover before resolving a fork");let c=await I(k(i,"fork.json")),d=await o.active(),l=await I(k(i,"previous.json"));if(!c||c.version!==1||!/^[a-f0-9-]{36}$/.test(c.stateRef)||Object.keys(c).some(h=>!["version","stateRef"].includes(h))||!d||l&&typeof l.stateRef!="string"||[d?.stateRef,l?.stateRef].includes(c.stateRef))throw new s("gc_recovery_required","Fork is unknown or referenced by active/previous; original bytes preserved");let u=`recovered-${n}-fork.json`;if(a.files.some(h=>h.path===u))throw new s("recovery_changed","Recovery evidence already exists");return await de(k(i,"fork.json"),k(i,u)),{recovered:"fork.json",stateRef:c.stateRef,fingerprint:n}}async function pe(t,e,n){if(n!==W||!/^[a-f0-9]{64}$/.test(e))throw new s("confirmation_required","Explicit stopped-owner and verified-backup confirmation required");let r=await j(t);if(r.fingerprint!==e)throw new s("recovery_changed","Storage changed since inspection; nothing recovered, inspect again");let o=[];for(let i of r.files.filter(a=>["runtime.lock","transaction.lock"].includes(a.path))){let a=await w(k(t,i.path),2097152);a&&!C(a)&&o.push(i)}for(let i of o){let a=`recovered-${e}-${i.path}.json`;if(r.files.some(c=>c.path===a))throw new s("recovery_changed","Recovery evidence already exists")}for(let i of o)await de(k(t,i.path),k(t,`recovered-${e}-${i.path}.json`));return await b(k(t,`recovery-${e}.json`),{version:1,fingerprint:e,locks:o,confirmation:n,recoveredAt:new Date().toISOString()}),{recovered:o.map(i=>i.path),fingerprint:e}}async function he(t,e,n){if(n!==W||!/^[a-f0-9]{64}$/.test(e))throw new s("confirmation_required","Explicit stopped-owner and verified-backup confirmation required");let r=F(t),o=await j(r);if(o.fingerprint!==e)throw new s("recovery_changed","Storage changed since inspection; nothing settled, inspect again");let i=o.files.find(a=>a.path==="intent.json");if(!i)throw new s("invalid_input","No host pair journal to settle");return x(r,async()=>{let a=await w(k(r,"intent.json"),2097152);if(!a||v(a)!==i.sha256)throw new s("recovery_changed","Host pair journal changed since inspection; nothing settled, inspect again");let c=await ee(t);if(c?.phase!=="required-action")throw new s("invalid_input",`Only a required-action journal can be settled offline (found ${c?.phase??"unreadable journal, now quarantined"})`);let d=k(r,"history",`${c.id}-settled-${e}.json`);if(await w(d,2*1024*1024))throw new s("recovery_changed","Recovery evidence already exists");return await Ce(k(r,"history"),{recursive:!0,mode:448}),await b(d,c),await te(t,{...c,phase:"reconciled",message:`Settled offline by operator; current host and plugin data retained. Was: ${c.message??"no message"}`}),await b(k(r,`recovery-${e}.json`),{version:1,fingerprint:e,settled:c.id,confirmation:n,recoveredAt:new Date().toISOString()}),{settled:c.id,version:c.version,fingerprint:e}})}var[P,ge,R,E,q,...We]=process.argv.slice(2),Je=ge&&!We.length&&(P==="inspect"&&!R&&!E&&!q||["recover-locks","settle-pair"].includes(P??"")&&R&&E&&!q||["recover-fork","reconcile-transition"].includes(P??"")&&R&&E&&q);if(!Je)console.error(`Offline only. Usage: node --experimental-strip-types scripts/hosted-stopped-recovery.ts
1
+ (function(){try{var t=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="b1113d25-9c3d-414f-8025-3daa437e752d",t._sentryDebugIdIdentifier="sentry-dbid-b1113d25-9c3d-414f-8025-3daa437e752d")}catch{}})();import{resolve as Me}from"node:path";import{lstat as le,mkdir as Ce,readdir as Fe,rename as de}from"node:fs/promises";import{join as k}from"node:path";import{createHash as me}from"node:crypto";var s=class extends Error{code;status;reason;constructor(e,n,r={}){super(n),this.name="HostedPluginError",this.code=e,this.status=r.status,this.reason=r.reason}};var $=t=>t.code==="ENOENT";var rt={files:4096,total:128*1024*1024,js:16*1024*1024,css:4*1024*1024,font:8*1024*1024,wasm:16*1024*1024,other:2*1024*1024};var v=t=>me("sha256").update(t).digest("hex");import{constants as J}from"node:fs";import{DatabaseSync as ye}from"node:sqlite";import{lstat as Y,mkdir as ve,open as N,rename as be,unlink as Z}from"node:fs/promises";import{dirname as ke,join as X,resolve as Ie}from"node:path";import{randomUUID as _e}from"node:crypto";import{setTimeout as xe}from"node:timers/promises";async function O(t){await ve(t,{recursive:!0,mode:448});let e=await Y(t);if(!e.isDirectory()||e.isSymbolicLink())throw new s("invalid_storage","Plugin storage must be a real directory")}async function w(t,e){let n;try{n=await N(t,J.O_RDONLY|J.O_NONBLOCK|(J.O_NOFOLLOW??0))}catch(r){if($(r))return null;throw r}try{let r=await n.stat();if(!r.isFile()||r.nlink>1||r.size>e)throw new s("invalid_storage","Invalid storage record size or type");let o=Buffer.alloc(Math.min(r.size+1,e+1)),i=0;for(;i<o.length;){let a=await n.read(o,i,o.length-i,i);if(!a.bytesRead)break;i+=a.bytesRead}if(i>e||i!==r.size)throw new s("invalid_storage","Storage record changed during read");return o.subarray(0,i)}finally{await n.close()}}async function A(t,e=2*1024*1024){let n=await w(t,e);if(!n)return null;try{return JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(n))}catch{throw new s("invalid_storage","Invalid JSON storage record; original bytes preserved")}}async function I(t){let e=await w(t,2097152);if(e===null)return null;let n;try{n=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e))}catch{throw new s("gc_recovery_required",`Invalid journal ${t}; stop all owners and inspect original bytes`)}if(!n||typeof n!="object"||Array.isArray(n))throw new s("gc_recovery_required",`Invalid journal ${t}; original bytes preserved`);return n}async function b(t,e){let n=`${t}.${_e()}.tmp`,r=await N(n,"wx",384);try{try{await r.writeFile(JSON.stringify(e)),await r.sync()}finally{await r.close()}await be(n,t);let o;try{o=await N(ke(t),"r"),await o.sync()}catch(i){if(!["EINVAL","EPERM","EACCES","EISDIR","ENOTSUP","EBADF"].includes(i.code??""))throw i}finally{await o?.close()}}finally{await Z(n).catch(()=>{})}}var Q='{"version":2,"mechanism":"sqlite-exclusive"}',C=t=>t.toString("utf8")===Q,L=new Set;async function Se(t,e,n=0){await O(t);let r=X(t,`${e}.lock`),o=X(t,`${e}.ownership.sqlite`),i=e==="runtime"?"runtime_owned":"storage_busy",a=()=>new s(i,"Another host owns this plugin storage or a legacy ownership lock remains; stop all owners and verify a backup before offline recovery"),c;try{c=await N(o,"wx",384)}catch(p){if(p.code!=="EEXIST")throw p}finally{await c?.close()}let d=await Y(o);if(!d.isFile()||d.isSymbolicLink()||d.nlink!==1||d.size>1024*1024)throw new s("invalid_storage","Ownership database must be a small, single-link regular file");let l=new ye(o,{allowExtension:!1}),u=Ie(o),h=Date.now()+n,m=!1;try{for(;;){if(!L.has(u))try{l.exec("BEGIN EXCLUSIVE"),L.add(u),m=!0;break}catch(y){if(y.errcode!==5)throw y}if(Date.now()>=h)throw new s(i,"Another host owns this plugin storage; wait for it to stop before retrying");await xe(10)}let p=await w(r,4096);if(p===null){let y;try{y=await N(r,"wx",384),await y.writeFile(Q),await y.sync()}catch(_){if(_.code!=="EEXIST")throw _}finally{await y?.close()}p=await w(r,4096)}if(p===null||!C(p))throw a()}catch(p){throw l.close(),m&&L.delete(u),p}let g=!1;return async()=>{if(g)return;let p=await w(r,4096);if(p===null||!C(p))throw new s("invalid_storage","Ownership fence changed while held; preserve custody and inspect storage");await Z(r),l.close(),L.delete(u),g=!0}}async function x(t,e,n=2e3){let r=await Se(t,"transaction",n);try{return await e()}finally{await r()}}import{readdir as pt,realpath as ht,rename as Pe,stat as Re}from"node:fs/promises";import{join as U}from"node:path";var F=t=>U(t,"host-pair");var yt=10*6e4;async function Ee(t){await Pe(t,`${t}.corrupt-${Date.now()}`).catch(e=>{if(e.code!=="ENOENT")throw e})}var Oe=t=>t.schema===1&&/^[a-f0-9-]{36}$/.test(t.id)&&typeof t.version=="string"&&typeof t.packageRoot=="string"&&/^[a-f0-9]{64}$/.test(t.hostDigest)&&/^[a-f0-9]{64}$/.test(t.fingerprint)&&Array.isArray(t.selections)&&!t.selections.some(e=>!e||typeof e.id!="string"||typeof e.version!="string"||!/^[a-f0-9]{64}$/.test(e.digest)||!Object.hasOwn(e,"before"))&&!(t.selection&&(typeof t.selection.path!="string"||!/^[a-f0-9]{64}$/.test(t.selection.digest)))&&["prepared","selecting","selected","restart-requested","reconciled","cancelled","required-action"].includes(t.phase);async function ee(t){let e=U(F(t),"intent.json"),n,r=!0;try{n=await I(e)}catch{n=null,r=!1}if(!r||n&&!Oe(n))return await Ee(e),null;if(n){let{lifecyclePhase:o,...i}=n,a=typeof i.updatedAt=="string"&&!Number.isNaN(Date.parse(i.updatedAt))?i.updatedAt:await Re(e).then(c=>c.mtime.toISOString(),()=>new Date(0).toISOString());n={...i,updatedAt:a,phase:i.phase==="selected"&&o==="restart-requested"?"restart-requested":i.phase==="reconciled"&&o==="cancelled"?"cancelled":i.phase==="reconciled"&&o==="required-action"?"required-action":i.phase}}return n}async function te(t,e){let{lifecyclePhase:n,...r}={...e,selections:[],updatedAt:new Date().toISOString()},o=r.phase==="cancelled"?{...r,phase:"reconciled",lifecyclePhase:"cancelled"}:r.phase==="required-action"?{...r,phase:"reconciled",lifecyclePhase:"required-action"}:r.phase==="restart-requested"?{...r,phase:"selected",lifecyclePhase:"restart-requested"}:r;await b(U(F(t),"intent.json"),o)}import{lstat as M,mkdir as Ae,open as ne,realpath as ie,readdir as B,link as je,rename as Ne,unlink as S,copyFile as He,rm as Te}from"node:fs/promises";import{dirname as De,isAbsolute as oe,join as f,relative as se,resolve as qe,sep as z,win32 as $e}from"node:path";import{randomUUID as G}from"node:crypto";var kt=64*1024*1024,re=Object.freeze([Object.freeze({extension:".excalidraw",binary:!1,maxBytes:512*1024,createDirectory:"diagrams"})]);var H=192*1024*1024,At=512*1024,ce=t=>typeof t=="string"&&/^[a-f0-9-]{36}$/.test(t);function Le(t){if(!t||typeof t!="object"||Array.isArray(t))throw new s("invalid_input","Expected object input");return t}function ae(t){if(typeof t!="string"||!/^[\w.-]{1,160}$/.test(t)||t==="."||t==="..")throw new s("invalid_input","Invalid state key");return t}function T(t){if(t&&(!ce(t.stateRef)||typeof t.version!="string"||!Number.isSafeInteger(t.generation)||t.generation<1||!Number.isSafeInteger(t.schema)||t.schema<1||typeof t.enabled!="boolean"||typeof t.operationId!="string"))throw new s("invalid_storage","Invalid active plugin record");return t}var D=class{root;pluginId;legacy;checkpoint;files;constructor(e,n,r,o,i=re){this.root=f(e,v(n)),this.pluginId=n,this.legacy=r,this.checkpoint=o,this.files=i}rule(e){let n=typeof e=="string"?this.files.find(r=>e.toLowerCase().endsWith(r.extension)):void 0;if(!n)throw new s("invalid_path",`Use a workspace-relative ${this.files.map(r=>r.extension).join("/")} path`);return n}active(){return A(f(this.root,"active.json")).then(T)}async recover(){return x(this.root,async()=>{let e=await this.active(),n=await I(f(this.root,"transition.json"));if(!n)return{active:e,recovered:"none"};if(!n.next||!Object.hasOwn(n,"before")||Object.keys(n).some(a=>!["version","before","next"].includes(a))||Object.hasOwn(n,"version")&&n.version!==1)throw new s("invalid_storage","Invalid activation journal; stop all owners and inspect transition.json");T(n.next),T(n.before);let r=e?.operationId===n.next.operationId?"committed":"not_committed";if(!((a,c)=>a===null||c===null?a===c:["version","generation","stateRef","schema","enabled","operationId"].every(d=>a[d]===c[d]))(e,r==="committed"?n.next:n.before))throw new s("gc_recovery_required","Activation journal does not match the active pointer; original bytes preserved");let i=n.before;if(r==="committed"&&i&&i.stateRef!==e.stateRef&&await b(f(this.root,"previous.json"),i),r==="committed"){let a=await I(f(this.root,"fork.json"));a?.version===1&&a.stateRef===e.stateRef&&Object.keys(a).every(c=>["version","stateRef"].includes(c))&&await S(f(this.root,"fork.json"))}return await S(f(this.root,"transition.json")),{active:e,recovered:r}})}async activate(e,n){return x(this.root,async()=>{let r=await this.active();if((r?.generation??0)!==e)throw new s("stale_generation","Plugin activation changed concurrently");let o=await I(f(this.root,"fork.json"));if(o&&(o.version!==1||o.stateRef!==n.stateRef||Object.keys(o).some(a=>!["version","stateRef"].includes(a))))throw new s("gc_recovery_required","Activation refused: unresolved fork.json belongs to another target; stop all owners and inspect it");let i=T({...n,generation:e+1,operationId:G()});await O(f(this.root,"states")),await O(f(this.root,"states",i.stateRef)),await b(f(this.root,"transition.json"),{version:1,before:r,next:i}),await this.checkpoint?.("prepared");try{await b(f(this.root,"active.json"),i)}catch(a){if((await this.active())?.operationId!==i.operationId)throw a}await this.checkpoint?.("committed");try{r&&r.stateRef!==i.stateRef&&await b(f(this.root,"previous.json"),r),await S(f(this.root,"transition.json")),await S(f(this.root,"fork.json")).catch(()=>{})}catch{}return await this.checkpoint?.("cleaned"),i})}async forkState(e){return x(this.root,async()=>{let n=await this.assertGeneration(e,!1),r=G(),o=f(this.root,"states",r);if(await I(f(this.root,"fork.json")))throw new s("gc_recovery_required","Unresolved fork.json; stop all owners and inspect the reserved state before retrying");await b(f(this.root,"fork.json"),{version:1,stateRef:r}),await O(o);let i=f(this.root,"states",n.stateRef);for(let a of await B(i)){if(!/^[a-f0-9]{64}\.json$/.test(a))throw new s("invalid_storage","Unexpected state file");if(!await w(f(i,a),H))throw new s("invalid_storage","Missing state file");await He(f(i,a),f(o,a))}return await this.checkpoint?.("forked"),r})}async collect(e){return x(this.root,async()=>{for(let l of["transition.json","fork.json"])if(await w(f(this.root,l),2*1024*1024))throw new s("gc_recovery_required",`GC refused: unresolved ${l}; stop all owners and inspect recovery references`);let n=await this.active(),r=T(await I(f(this.root,"previous.json")));if(!n&&await w(f(this.root,"active.json"),2*1024*1024))throw new s("gc_recovery_required","GC refused: null active pointer; restore activation metadata before cleanup");let o=[n,r].filter(l=>!!l),i=f(this.root,"states");await O(i);let a=await B(i),c=new Set(o.map(l=>l.stateRef));for(let l of a){if(!ce(l))throw new s("gc_recovery_required","GC refused: unexpected state directory; inspect states before cleanup");let u=f(i,l),h=await M(u);if(!h.isDirectory()||h.isSymbolicLink())throw new s("gc_recovery_required","GC refused: linked/non-directory state snapshot");for(let m of await B(u)){let g=await M(f(u,m));if(!/^[a-f0-9]{64}\.json$/.test(m)||!g.isFile()||g.isSymbolicLink()||g.nlink!==1)throw new s("gc_recovery_required","GC refused: unexpected snapshot content; original bytes preserved");if(!c.has(l)){let p=await A(f(u,m),H);if(!p)throw new s("gc_recovery_required","GC refused: missing snapshot record");if(Object.hasOwn(p,"committed")){let y=p;if(Object.keys(y).some(_=>!["requestId","inputHash","nextHash","committed"].includes(_))||y.committed!==!0||!/^[a-f0-9]{64}$/.test(y.inputHash)||!/^[a-f0-9]{64}$/.test(y.nextHash)||typeof y.requestId!="string")throw new s("gc_recovery_required",`GC refused: unresolved file intent in states/${l}; reconcile the workspace save before cleanup`)}else{if(Object.keys(p).some(y=>!["revision","schema","value","requestId","inputHash"].includes(y)))throw new s("gc_recovery_required","GC refused: unknown snapshot envelope; original bytes preserved");this.validateState(p)}}}}for(let l of c)if(!a.includes(l))throw new s("gc_recovery_required","GC refused: referenced snapshot is missing; restore recovery data first");let d=await e(o);for(let l of a)c.has(l)||await Te(f(i,l),{recursive:!0,force:!0});return d})}async assertGeneration(e,n=!0){let r=await this.active();if(!r||r.generation!==e||n&&!r.enabled)throw new s("stale_generation","Plugin generation is no longer active");return r}scopeKey(e){if(!e.scope||typeof e.scope.cwd!="string"||!e.scope.cwd||typeof e.scope.sessionId!="string"||!e.scope.sessionId||typeof e.scope.workspaceId!="string"||!e.scope.workspaceId)throw new s("invalid_scope","Missing authenticated plugin scope");return JSON.stringify([e.scope.workspaceId,e.scope.cwd,e.scope.sessionId])}statePath(e,n,r,o="session"){if(o!=="session"&&o!=="workspace")throw new s("invalid_input","Invalid state scope");let i=o==="workspace"?(this.scopeKey(n),JSON.stringify([n.scope.workspaceId,n.scope.cwd])):this.scopeKey(n);return f(this.root,"states",e.stateRef,`${v(i+":state:"+r)}.json`)}async call(e,n,r){if(!Number.isSafeInteger(e.generation)||!/^[\w-]{1,160}$/.test(e.requestId))throw new s("invalid_lease","Invalid invocation lease");this.scopeKey(e);let o=Le(r);return x(this.root,async()=>{let i=await this.assertGeneration(e.generation);switch(n){case"state.read":{let a=await A(this.statePath(i,e,ae(o.key),o.scope),H);return a?(this.validateState(a),{revision:a.revision,schema:a.schema,value:a.value}):null}case"state.compareAndSwap":{let a=this.statePath(i,e,ae(o.key),o.scope);if(!Number.isSafeInteger(o.expectedRevision)||o.expectedRevision<0||o.schema!==i.schema||!Object.hasOwn(o,"value"))throw new s("invalid_input","Invalid state revision or schema");if(JSON.stringify(o.value)===void 0)throw new s("invalid_input","State value must be JSON serializable");let c=JSON.stringify(o);if(Buffer.byteLength(c)>H)throw new s("state_too_large","Plugin state exceeds limit");let d=await A(a,H);d&&this.validateState(d);let l=v(c);if(d?.requestId===e.requestId&&d.inputHash===l)return{revision:d.revision,schema:d.schema,value:d.value};if((d?.revision??0)!==o.expectedRevision)throw new s("revision_conflict","Plugin state changed concurrently");let u={revision:o.expectedRevision+1,schema:i.schema,value:o.value,requestId:e.requestId,inputHash:l};return await b(a,u),{revision:u.revision,schema:u.schema,value:u.value}}case"workspace.read":{let a=this.rule(o.path),{target:c}=await this.fileTarget(e.scope.cwd,o.path),d=o.maxBytes===void 0?a.maxBytes:o.maxBytes;if(!Number.isSafeInteger(d)||d<=0||d>a.maxBytes)throw new s("invalid_input","Invalid workspace read limit");if(o.encoding!==void 0&&o.encoding!==(a.binary?"base64":"utf-8"))throw new s("invalid_input","Encoding does not match the reviewed file rule");let l=await w(c,d);return l?a.binary?{base64:l.toString("base64"),bytes:l.length,hash:v(l)}:{text:new TextDecoder("utf-8",{fatal:!0}).decode(l),hash:v(l)}:null}case"workspace.commit":return this.commitFile(i,e,o);case"legacy.read":return this.legacy?this.legacy(e):null;default:throw new s("method_denied","Unknown host broker method")}})}validateState(e){if(!Number.isSafeInteger(e.revision)||e.revision<1||!Number.isSafeInteger(e.schema)||e.schema<1||!Object.hasOwn(e,"value")||typeof e.requestId!="string"||!/^[a-f0-9]{64}$/.test(e.inputHash))throw new s("invalid_storage","Invalid plugin state; original bytes preserved")}async fileTarget(e,n,r=!1){let o=this.rule(n);if(typeof n!="string"||n.length>4096||n.includes("\\")||n.includes("\0")||oe(n)||$e.isAbsolute(n))throw new s("invalid_path",`Use a workspace-relative ${o.extension} path`);let i=await ie(e),a=qe(i,n),c=se(i,a);if(!c||c===".."||c.startsWith(`..${z}`)||oe(c))throw new s("invalid_path","Workspace path escapes root");let d=i,l=c.split(z);for(let h=0;h<l.length;h++){d=f(d,l[h]);let m;try{m=await M(d)}catch(g){if(!$(g))throw g;if(h<l.length-1){if(!r||!o.createDirectory||se(i,d)!==o.createDirectory)throw new s("invalid_path","Workspace directory does not exist");try{await Ae(d,{mode:448})}catch(p){if(p.code!=="EEXIST")throw p}m=await M(d)}}if(m&&(m.isSymbolicLink()||(h<l.length-1?!m.isDirectory():!m.isFile()||m.nlink!==1)))throw new s("invalid_path","Workspace path contains a link or non-regular file")}let u=await ie(De(a));if(u!==i&&!u.startsWith(i+z))throw new s("invalid_path","Workspace directory changed");return{target:a,parent:u}}async commitFile(e,n,r){let o=this.rule(r.path),i=o.binary?typeof r.base64=="string"&&r.text===void 0&&/^[A-Za-z0-9+/]*={0,2}$/.test(r.base64)?Buffer.from(r.base64,"base64"):null:typeof r.text=="string"&&r.base64===void 0?Buffer.from(r.text):null;if(!i||i.length>o.maxBytes||!(r.expectedHash===null||typeof r.expectedHash=="string"&&/^[a-f0-9]{64}$/.test(r.expectedHash)))throw new s("invalid_input","Invalid file content or expected hash");let{target:a,parent:c}=await this.fileTarget(n.scope.cwd,r.path,!0),d=f(this.root,"states",e.stateRef,`${v(this.scopeKey(n)+":file:"+n.requestId+":"+String(r.path))}.json`),l=v(JSON.stringify(r)),u=v(i),h=await A(d);if(h&&(h.requestId!==n.requestId||h.inputHash!==l||h.nextHash!==u))throw new s("duplicate_request","Request ID was reused with different content");let m;try{m=await ne(`${a}.lock`,"wx",384)}catch(p){throw p.code==="EEXIST"?new s("file_busy","Workspace file is locked; original file preserved"):p}let g;try{await m.writeFile(JSON.stringify({pid:process.pid,requestId:n.requestId}));let p=await w(a,o.maxBytes),y=p?v(p):null;if(h&&y===u)return{hash:u};if(h?.committed||y!==r.expectedHash)throw new s("file_conflict","Workspace file already exists or changed externally");await b(d,{requestId:n.requestId,inputHash:l,nextHash:u,committed:!1}),g=f(c,`.plugin-${G()}.tmp`);let _=await ne(g,"wx",384);try{await _.writeFile(i),await _.sync()}finally{await _.close()}if((await this.fileTarget(n.scope.cwd,r.path)).parent!==c)throw new s("file_conflict","Workspace directory changed during save");let K=await w(a,o.maxBytes);if((K?v(K):null)!==r.expectedHash)throw new s("file_conflict","Workspace file changed during save");if(await this.assertGeneration(n.generation),r.expectedHash===null){try{await je(g,a)}catch(V){throw V.code==="EEXIST"?new s("file_conflict","Workspace file was created concurrently"):V}await S(g),g=void 0}else await Ne(g,a),g=void 0;return await b(d,{requestId:n.requestId,inputHash:l,nextHash:u,committed:!0}),{hash:u}}finally{g&&await S(g).catch(()=>{}),await m.close(),await S(`${a}.lock`)}}};var W="ALL_HOSTS_AND_PLUGIN_WORKERS_STOPPED_AND_BACKUP_VERIFIED";async function j(t){let e=[];async function n(r,o=""){let i=await le(r);if(!i.isDirectory()||i.isSymbolicLink())throw new s("invalid_storage","Recovery refuses linked/non-directory storage");for(let a of(await Fe(r)).sort()){let c=k(r,a),d=o+a,l=await le(c);if(l.isSymbolicLink())throw new s("invalid_storage","Recovery refuses links");if(l.isDirectory())await n(c,d+"/");else{if(e.length>=1e4)throw new s("invalid_storage","Recovery inspection budget exceeded");let u=await w(c,192*1024*1024);if(!u)throw new s("invalid_storage","Recovery input disappeared");e.push({path:d,bytes:u.length,sha256:v(u)})}}}return await n(t),{fingerprint:v(JSON.stringify(e)),files:e,warning:"Offline only: externally stop/fence ALL hosts and plugin workers, back up storage and workspace files. Never infer stopped ownership from PID alone."}}async function fe(t,e,n,r){let o=new D(t,e),i=await j(o.root);if(r!==W)throw new s("confirmation_required","Explicit stopped-owner and verified-backup confirmation required");if(i.fingerprint!==n)throw new s("recovery_changed","Storage changed since inspection");return o.recover()}async function ue(t,e,n,r){let o=new D(t,e),i=o.root;if(r!==W)throw new s("confirmation_required","Explicit stopped-owner and verified-backup confirmation required");let a=await j(i);if(a.fingerprint!==n)throw new s("recovery_changed","Storage changed since inspection");if(await w(k(i,"transition.json"),2*1024*1024))throw new s("gc_recovery_required","Reconcile transition.json using broker.recover before resolving a fork");let c=await I(k(i,"fork.json")),d=await o.active(),l=await I(k(i,"previous.json"));if(!c||c.version!==1||!/^[a-f0-9-]{36}$/.test(c.stateRef)||Object.keys(c).some(h=>!["version","stateRef"].includes(h))||!d||l&&typeof l.stateRef!="string"||[d?.stateRef,l?.stateRef].includes(c.stateRef))throw new s("gc_recovery_required","Fork is unknown or referenced by active/previous; original bytes preserved");let u=`recovered-${n}-fork.json`;if(a.files.some(h=>h.path===u))throw new s("recovery_changed","Recovery evidence already exists");return await de(k(i,"fork.json"),k(i,u)),{recovered:"fork.json",stateRef:c.stateRef,fingerprint:n}}async function pe(t,e,n){if(n!==W||!/^[a-f0-9]{64}$/.test(e))throw new s("confirmation_required","Explicit stopped-owner and verified-backup confirmation required");let r=await j(t);if(r.fingerprint!==e)throw new s("recovery_changed","Storage changed since inspection; nothing recovered, inspect again");let o=[];for(let i of r.files.filter(a=>["runtime.lock","transaction.lock"].includes(a.path))){let a=await w(k(t,i.path),2097152);a&&!C(a)&&o.push(i)}for(let i of o){let a=`recovered-${e}-${i.path}.json`;if(r.files.some(c=>c.path===a))throw new s("recovery_changed","Recovery evidence already exists")}for(let i of o)await de(k(t,i.path),k(t,`recovered-${e}-${i.path}.json`));return await b(k(t,`recovery-${e}.json`),{version:1,fingerprint:e,locks:o,confirmation:n,recoveredAt:new Date().toISOString()}),{recovered:o.map(i=>i.path),fingerprint:e}}async function he(t,e,n){if(n!==W||!/^[a-f0-9]{64}$/.test(e))throw new s("confirmation_required","Explicit stopped-owner and verified-backup confirmation required");let r=F(t),o=await j(r);if(o.fingerprint!==e)throw new s("recovery_changed","Storage changed since inspection; nothing settled, inspect again");let i=o.files.find(a=>a.path==="intent.json");if(!i)throw new s("invalid_input","No host pair journal to settle");return x(r,async()=>{let a=await w(k(r,"intent.json"),2097152);if(!a||v(a)!==i.sha256)throw new s("recovery_changed","Host pair journal changed since inspection; nothing settled, inspect again");let c=await ee(t);if(c?.phase!=="required-action")throw new s("invalid_input",`Only a required-action journal can be settled offline (found ${c?.phase??"unreadable journal, now quarantined"})`);let d=k(r,"history",`${c.id}-settled-${e}.json`);if(await w(d,2*1024*1024))throw new s("recovery_changed","Recovery evidence already exists");return await Ce(k(r,"history"),{recursive:!0,mode:448}),await b(d,c),await te(t,{...c,phase:"reconciled",message:`Settled offline by operator; current host and plugin data retained. Was: ${c.message??"no message"}`}),await b(k(r,`recovery-${e}.json`),{version:1,fingerprint:e,settled:c.id,confirmation:n,recoveredAt:new Date().toISOString()}),{settled:c.id,version:c.version,fingerprint:e}})}var[P,ge,R,E,q,...We]=process.argv.slice(2),Je=ge&&!We.length&&(P==="inspect"&&!R&&!E&&!q||["recover-locks","settle-pair"].includes(P??"")&&R&&E&&!q||["recover-fork","reconcile-transition"].includes(P??"")&&R&&E&&q);if(!Je)console.error(`Offline only. Usage: node --experimental-strip-types scripts/hosted-stopped-recovery.ts
2
2
  inspect BROKER_ROOT | HOSTED_ROOT/host-pair
3
3
  recover-locks BROKER_ROOT FINGERPRINT CONFIRMATION
4
4
  reconcile-transition DATA_ROOT PLUGIN_ID FINGERPRINT CONFIRMATION
@@ -6,4 +6,4 @@
6
6
  settle-pair HOSTED_ROOT FINGERPRINT CONFIRMATION
7
7
  CONFIRMATION = ALL_HOSTS_AND_PLUGIN_WORKERS_STOPPED_AND_BACKUP_VERIFIED`),process.exitCode=2;else try{let t=Me(ge),e=P==="inspect"?await j(t):P==="recover-locks"?await pe(t,R,E):P==="settle-pair"?await he(t,R,E):P==="recover-fork"?await ue(t,R,E,q):await fe(t,R,E,q);console.log(JSON.stringify(e,null,2))}catch(t){console.error(t instanceof Error?t.message:"Recovery failed"),process.exitCode=1}var Jt=void 0;export{Jt as default};
8
8
 
9
- //# debugId=f5e92d57-a779-445f-8ea1-b9439fffc663
9
+ //# debugId=b1113d25-9c3d-414f-8025-3daa437e752d
@@ -1,3 +1,3 @@
1
- (function(){try{var t=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="0fd7edf7-686a-41e8-8f96-baa9fed28107",t._sentryDebugIdIdentifier="sentry-dbid-0fd7edf7-686a-41e8-8f96-baa9fed28107")}catch{}})();import{AsyncLocalStorage as y}from"node:async_hooks";import{pathToFileURL as b}from"node:url";function c(t){let e=t&&typeof t=="object"?t:{};return{code:typeof e.code=="string"&&/^[\w.-]{1,80}$/.test(e.code)?e.code:"plugin_failed",message:t instanceof Error?t.message:"Plugin operation failed",...Number.isInteger(e.status)&&Number(e.status)>=400&&Number(e.status)<=599?{status:Number(e.status)}:{},...typeof e.reason=="string"&&/^[\w.-]{1,80}$/.test(e.reason)?{reason:e.reason}:{}}}var f=new y,s=new Map,v=0,n,a=t=>{process.connected&&process.send?.(t)};process.on("message",t=>{if(!t||typeof t!="object")return;let e=t;if(e.type==="broker-response"&&typeof e.id=="string"){let r=s.get(e.id);if(!r)return;if(s.delete(e.id),e.ok)r.resolve(e.value);else{let o=e.error;r.reject(Object.assign(new Error(o?.message??"Host broker rejected request"),{code:o?.code,status:o?.status,reason:o?.reason}))}return}if(e.type!=="request"||typeof e.id!="string"||typeof e.method!="string")return;let i=e.id;(async()=>{switch(e.method){case"initialize":{if(n)throw new Error("Already initialized");let r=e.input,o=await import(b(r.entry).href);if(typeof o.createRuntime!="function")throw new Error("Missing createRuntime export");return n=await o.createRuntime({pluginId:r.pluginId,version:r.version,generation:r.generation,broker:{call(p,g){let u=f.getStore();if(!u)return Promise.reject(new Error("Broker calls require an active invocation"));if(s.size>=64)return Promise.reject(new Error("Too many broker requests"));let d=`b${++v}`;return new Promise((m,w)=>{s.set(d,{resolve:m,reject:w}),a({type:"broker-request",id:d,invocationId:u.requestId,method:p,input:g})})}}}),{initialized:!0}}case"describe":if(!n)throw new Error("Not initialized");return n.describe();case"health":if(!n)throw new Error("Not initialized");return n.health();case"invoke":{if(!n)throw new Error("Not initialized");let r=e.input;return f.run(r,()=>n.invoke(r))}case"dispose":return await n?.dispose?.(),{disposed:!0};default:throw new Error("Unknown runtime operation")}})().then(r=>a({type:"response",id:i,ok:!0,value:r}),r=>a({type:"response",id:i,ok:!1,error:c(r)}))});process.on("disconnect",()=>{for(let t of s.values())t.reject(new Error("Host disconnected"));s.clear(),process.exitCode=1,Promise.resolve(n?.dispose?.()).finally(()=>process.exit(1))});var H=void 0;export{H as default};
1
+ (function(){try{var t=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="e07510f7-475e-4753-82ff-49b9741b776b",t._sentryDebugIdIdentifier="sentry-dbid-e07510f7-475e-4753-82ff-49b9741b776b")}catch{}})();import{AsyncLocalStorage as b}from"node:async_hooks";import{pathToFileURL as y}from"node:url";function c(t){let e=t&&typeof t=="object"?t:{};return{code:typeof e.code=="string"&&/^[\w.-]{1,80}$/.test(e.code)?e.code:"plugin_failed",message:t instanceof Error?t.message:"Plugin operation failed",...Number.isInteger(e.status)&&Number(e.status)>=400&&Number(e.status)<=599?{status:Number(e.status)}:{},...typeof e.reason=="string"&&/^[\w.-]{1,80}$/.test(e.reason)?{reason:e.reason}:{}}}var f=new b,s=new Map,v=0,n,a=t=>{process.connected&&process.send?.(t)};process.on("message",t=>{if(!t||typeof t!="object")return;let e=t;if(e.type==="broker-response"&&typeof e.id=="string"){let r=s.get(e.id);if(!r)return;if(s.delete(e.id),e.ok)r.resolve(e.value);else{let o=e.error;r.reject(Object.assign(new Error(o?.message??"Host broker rejected request"),{code:o?.code,status:o?.status,reason:o?.reason}))}return}if(e.type!=="request"||typeof e.id!="string"||typeof e.method!="string")return;let i=e.id;(async()=>{switch(e.method){case"initialize":{if(n)throw new Error("Already initialized");let r=e.input,o=await import(y(r.entry).href);if(typeof o.createRuntime!="function")throw new Error("Missing createRuntime export");return n=await o.createRuntime({pluginId:r.pluginId,version:r.version,generation:r.generation,broker:{call(p,g){let u=f.getStore();if(!u)return Promise.reject(new Error("Broker calls require an active invocation"));if(s.size>=64)return Promise.reject(new Error("Too many broker requests"));let d=`b${++v}`;return new Promise((m,w)=>{s.set(d,{resolve:m,reject:w}),a({type:"broker-request",id:d,invocationId:u.requestId,method:p,input:g})})}}}),{initialized:!0}}case"describe":if(!n)throw new Error("Not initialized");return n.describe();case"health":if(!n)throw new Error("Not initialized");return n.health();case"invoke":{if(!n)throw new Error("Not initialized");let r=e.input;return f.run(r,()=>n.invoke(r))}case"dispose":return await n?.dispose?.(),{disposed:!0};default:throw new Error("Unknown runtime operation")}})().then(r=>a({type:"response",id:i,ok:!0,value:r}),r=>a({type:"response",id:i,ok:!1,error:c(r)}))});process.on("disconnect",()=>{for(let t of s.values())t.reject(new Error("Host disconnected"));s.clear(),process.exitCode=1,Promise.resolve(n?.dispose?.()).finally(()=>process.exit(1))});var H=void 0;export{H as default};
2
2
 
3
- //# debugId=0fd7edf7-686a-41e8-8f96-baa9fed28107
3
+ //# debugId=e07510f7-475e-4753-82ff-49b9741b776b
package/docs/desktop.md CHANGED
@@ -37,11 +37,22 @@ The staging directory is `.desktop/runtime/`:
37
37
  including Pi. It is outside ASAR, so Node and native PTY helpers run normally.
38
38
  - `build-info.json`: app/runtime versions, platform, architecture and Node checksum.
39
39
 
40
- Electron's renderer has no Node integration or preload bridge. It loads the same
41
- loopback HTTP page as a browser, with sandboxing, context isolation, normal CSP,
42
- and the existing bearer-token authentication. External HTTP(S) links require a
43
- native confirmation and open in the default browser. Other OS protocols, webviews,
44
- page-created windows, permission requests and downloads are not enabled.
40
+ Electron's renderer has no Node integration. It loads the same loopback HTTP
41
+ page as a browser, with sandboxing, context isolation, normal CSP, and the
42
+ existing bearer-token authentication. Its preload exposes only the Web Preview
43
+ controls, with sender checks in the main process. Previewed pages run in a
44
+ separate, in-memory session without that bridge. They can load HTTP(S) resources
45
+ and WebSockets, but the Pi backend port is reserved across hostnames and URL
46
+ aliases. The preview uses Chromium's normal network and certificate checks;
47
+ popups, downloads and permission requests are blocked. The Pi workbench's
48
+ external HTTP(S) links still go to the default browser.
49
+
50
+ After `npm run desktop:prepare`, run `npm run desktop:smoke:web-preview` on a
51
+ machine with a GUI to exercise the preview in a real Electron window using a
52
+ temporary profile and a local development server. The omnibox smoke verifies
53
+ query routing and result navigation with a fixture. Set `PI_WEB_PREVIEW_SMOKE_PUBLIC=1`
54
+ to check a live public page, or `PI_WEB_PREVIEW_SMOKE_GOOGLE=1` to check live
55
+ access to Google (which depends on your system network and Google's response).
45
56
 
46
57
  ## Create an installer
47
58
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-webapp",
3
- "version": "0.1.57",
3
+ "version": "0.1.58-alpha.1",
4
4
  "type": "module",
5
5
  "piWebappDesktopProtocol": 1,
6
6
  "piWebappDataVersion": 1,
@@ -40,7 +40,7 @@
40
40
  "pi-webapp": "./bin/pi-webapp.mjs"
41
41
  },
42
42
  "pi": {
43
- "image": "https://cdn.jsdelivr.net/npm/pi-webapp@0.1.57/assets/cover-webapp.png",
43
+ "image": "https://cdn.jsdelivr.net/npm/pi-webapp@0.1.58-alpha.1/assets/cover-webapp.png",
44
44
  "extensions": [
45
45
  "./dist/extension.js"
46
46
  ]
@@ -84,6 +84,7 @@
84
84
  "desktop:prepare": "npm run build && node scripts/prepare-desktop.mjs",
85
85
  "desktop:start": "electron desktop",
86
86
  "desktop:smoke": "node scripts/smoke-desktop.mjs",
87
+ "desktop:smoke:web-preview": "node scripts/smoke-desktop-web-preview.mjs",
87
88
  "desktop:smoke:handoff": "node scripts/smoke-desktop-handoff.mjs",
88
89
  "desktop:smoke:legacy": "node scripts/smoke-desktop-legacy.mjs",
89
90
  "desktop:package": "node scripts/package-desktop.mjs",
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "../../node_modules/@codemirror/lang-angular/dist/index.js": {
3
- "file": "assets/dist-CqXTRhJp.js",
3
+ "file": "assets/dist-Nlb4zANG.js",
4
4
  "name": "dist",
5
5
  "src": "../../node_modules/@codemirror/lang-angular/dist/index.js",
6
6
  "isDynamicEntry": true,
7
7
  "imports": [
8
8
  "_dist-IkQ96Etc.js",
9
9
  "../../node_modules/@codemirror/lang-html/dist/index.js",
10
- "_dist-Im2q9dJ0.js",
10
+ "_dist-C2WSXtwq.js",
11
11
  "_dist-DTWmF6Zy.js"
12
12
  ]
13
13
  },
@@ -22,7 +22,7 @@
22
22
  ]
23
23
  },
24
24
  "../../node_modules/@codemirror/lang-go/dist/index.js": {
25
- "file": "assets/dist-BRYLL4VU.js",
25
+ "file": "assets/dist-C7kRRV1b.js",
26
26
  "name": "dist",
27
27
  "src": "../../node_modules/@codemirror/lang-go/dist/index.js",
28
28
  "isDynamicEntry": true,
@@ -33,7 +33,7 @@
33
33
  ]
34
34
  },
35
35
  "../../node_modules/@codemirror/lang-html/dist/index.js": {
36
- "file": "assets/dist-DAlictfL.js",
36
+ "file": "assets/dist-CmPE8_f_.js",
37
37
  "name": "dist",
38
38
  "src": "../../node_modules/@codemirror/lang-html/dist/index.js",
39
39
  "isDynamicEntry": true,
@@ -41,7 +41,7 @@
41
41
  "_dist-DTWmF6Zy.js",
42
42
  "_dist-IkQ96Etc.js",
43
43
  "_dist-RJnNnBqa.js",
44
- "_dist-Im2q9dJ0.js"
44
+ "_dist-C2WSXtwq.js"
45
45
  ]
46
46
  },
47
47
  "../../node_modules/@codemirror/lang-java/dist/index.js": {
@@ -55,7 +55,7 @@
55
55
  ]
56
56
  },
57
57
  "../../node_modules/@codemirror/lang-jinja/dist/index.js": {
58
- "file": "assets/dist-o-4nubru.js",
58
+ "file": "assets/dist-BD_2QeWa.js",
59
59
  "name": "dist",
60
60
  "src": "../../node_modules/@codemirror/lang-jinja/dist/index.js",
61
61
  "isDynamicEntry": true,
@@ -87,7 +87,7 @@
87
87
  ]
88
88
  },
89
89
  "../../node_modules/@codemirror/lang-liquid/dist/index.js": {
90
- "file": "assets/dist-BYJ4SXpR.js",
90
+ "file": "assets/dist-DFTCmV51.js",
91
91
  "name": "dist",
92
92
  "src": "../../node_modules/@codemirror/lang-liquid/dist/index.js",
93
93
  "isDynamicEntry": true,
@@ -98,7 +98,7 @@
98
98
  ]
99
99
  },
100
100
  "../../node_modules/@codemirror/lang-markdown/dist/index.js": {
101
- "file": "assets/dist-CaNhruaD.js",
101
+ "file": "assets/dist-CCfANS3F.js",
102
102
  "name": "dist",
103
103
  "src": "../../node_modules/@codemirror/lang-markdown/dist/index.js",
104
104
  "isDynamicEntry": true,
@@ -109,7 +109,7 @@
109
109
  ]
110
110
  },
111
111
  "../../node_modules/@codemirror/lang-php/dist/index.js": {
112
- "file": "assets/dist-CszBAiM6.js",
112
+ "file": "assets/dist-D-nx7RRS.js",
113
113
  "name": "dist",
114
114
  "src": "../../node_modules/@codemirror/lang-php/dist/index.js",
115
115
  "isDynamicEntry": true,
@@ -120,7 +120,7 @@
120
120
  ]
121
121
  },
122
122
  "../../node_modules/@codemirror/lang-python/dist/index.js": {
123
- "file": "assets/dist-CsFhAvz7.js",
123
+ "file": "assets/dist-Dr0qO3Zr.js",
124
124
  "name": "dist",
125
125
  "src": "../../node_modules/@codemirror/lang-python/dist/index.js",
126
126
  "isDynamicEntry": true,
@@ -152,7 +152,7 @@
152
152
  ]
153
153
  },
154
154
  "../../node_modules/@codemirror/lang-sql/dist/index.js": {
155
- "file": "assets/dist-BFhI7cEI.js",
155
+ "file": "assets/dist-CP5SBgQB.js",
156
156
  "name": "dist",
157
157
  "src": "../../node_modules/@codemirror/lang-sql/dist/index.js",
158
158
  "isDynamicEntry": true,
@@ -163,14 +163,14 @@
163
163
  ]
164
164
  },
165
165
  "../../node_modules/@codemirror/lang-vue/dist/index.js": {
166
- "file": "assets/dist-CWWynAS-.js",
166
+ "file": "assets/dist-B8Mp_VTU.js",
167
167
  "name": "dist",
168
168
  "src": "../../node_modules/@codemirror/lang-vue/dist/index.js",
169
169
  "isDynamicEntry": true,
170
170
  "imports": [
171
171
  "_dist-IkQ96Etc.js",
172
172
  "../../node_modules/@codemirror/lang-html/dist/index.js",
173
- "_dist-Im2q9dJ0.js",
173
+ "_dist-C2WSXtwq.js",
174
174
  "_dist-DTWmF6Zy.js"
175
175
  ]
176
176
  },
@@ -907,14 +907,14 @@
907
907
  "isDynamicEntry": true
908
908
  },
909
909
  "../../node_modules/@shikijs/langs/dist/http.mjs": {
910
- "file": "assets/http-CTlzQwRP.js",
910
+ "file": "assets/http-C6M1fy61.js",
911
911
  "name": "http",
912
912
  "src": "../../node_modules/@shikijs/langs/dist/http.mjs",
913
913
  "isDynamicEntry": true,
914
914
  "imports": [
915
915
  "ui/shared/primitives/markdown/MarkdownText.tsx",
916
916
  "_xml-BOIvddFt.js",
917
- "_graphql-Cz1_wnUp.js"
917
+ "_graphql-B5jxVvgN.js"
918
918
  ]
919
919
  },
920
920
  "../../node_modules/@shikijs/langs/dist/ini.mjs": {
@@ -1001,7 +1001,7 @@
1001
1001
  ]
1002
1002
  },
1003
1003
  "../../node_modules/@shikijs/langs/dist/php.mjs": {
1004
- "file": "assets/php-BHNgHgMp.js",
1004
+ "file": "assets/php-B61pLHqK.js",
1005
1005
  "name": "php",
1006
1006
  "src": "../../node_modules/@shikijs/langs/dist/php.mjs",
1007
1007
  "isDynamicEntry": true,
@@ -1033,7 +1033,7 @@
1033
1033
  "isDynamicEntry": true
1034
1034
  },
1035
1035
  "../../node_modules/@shikijs/langs/dist/rst.mjs": {
1036
- "file": "assets/rst-BdGjFUxD.js",
1036
+ "file": "assets/rst-950N-2sy.js",
1037
1037
  "name": "rst",
1038
1038
  "src": "../../node_modules/@shikijs/langs/dist/rst.mjs",
1039
1039
  "isDynamicEntry": true,
@@ -1049,7 +1049,7 @@
1049
1049
  ]
1050
1050
  },
1051
1051
  "../../node_modules/@shikijs/langs/dist/ruby.mjs": {
1052
- "file": "assets/ruby-D7-ny0V-.js",
1052
+ "file": "assets/ruby-Qm2HAXfx.js",
1053
1053
  "name": "ruby",
1054
1054
  "src": "../../node_modules/@shikijs/langs/dist/ruby.mjs",
1055
1055
  "isDynamicEntry": true,
@@ -1059,7 +1059,7 @@
1059
1059
  "_css-TMM_5IvK.js",
1060
1060
  "_xml-BOIvddFt.js",
1061
1061
  "_sql-r_e_QA5-.js",
1062
- "_graphql-Cz1_wnUp.js",
1062
+ "_graphql-B5jxVvgN.js",
1063
1063
  "../../node_modules/@shikijs/langs/dist/cpp.mjs",
1064
1064
  "_c-vzw8O3dF.js",
1065
1065
  "ui/shared/primitives/markdown/MarkdownText.tsx",
@@ -1089,7 +1089,7 @@
1089
1089
  ]
1090
1090
  },
1091
1091
  "../../node_modules/@shikijs/langs/dist/svelte.mjs": {
1092
- "file": "assets/svelte-DoD3sicb.js",
1092
+ "file": "assets/svelte-CoZSSs0h.js",
1093
1093
  "name": "svelte",
1094
1094
  "src": "../../node_modules/@shikijs/langs/dist/svelte.mjs",
1095
1095
  "isDynamicEntry": true,
@@ -1130,7 +1130,7 @@
1130
1130
  "isDynamicEntry": true
1131
1131
  },
1132
1132
  "../../node_modules/@shikijs/langs/dist/vue.mjs": {
1133
- "file": "assets/vue-BYLUelN7.js",
1133
+ "file": "assets/vue-as6FrWIW.js",
1134
1134
  "name": "vue",
1135
1135
  "src": "../../node_modules/@shikijs/langs/dist/vue.mjs",
1136
1136
  "isDynamicEntry": true,
@@ -1385,23 +1385,24 @@
1385
1385
  "src": "../../node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.woff2"
1386
1386
  },
1387
1387
  "../../src/host/client/app.tsx": {
1388
- "file": "assets/app-CIlV3hYO.js",
1388
+ "file": "assets/app-Bl_vjH4f.js",
1389
1389
  "name": "app",
1390
1390
  "src": "../../src/host/client/app.tsx",
1391
1391
  "isDynamicEntry": true,
1392
1392
  "imports": [
1393
1393
  "_rolldown-runtime-CgmABjMJ.js",
1394
1394
  "_react-CLFE7TFE.js",
1395
- "_icons-D8yiYkWB.js",
1395
+ "_code-file-types-BZAEsqNG.js",
1396
1396
  "index.html",
1397
1397
  "_clsx-DQAHfk8w.js",
1398
- "_WorkspacePanel.module-V6gI-nG1.js"
1398
+ "_WorkspacePanel.module-q1UBTZQr.js"
1399
1399
  ],
1400
1400
  "dynamicImports": [
1401
1401
  "ui/shared/primitives/markdown/MarkdownText.tsx",
1402
1402
  "../../src/plugins/builtin/files/client/plugin.tsx",
1403
1403
  "../../src/plugins/builtin/terminal/client/plugin.tsx",
1404
- "../../src/plugins/builtin/git/client/plugin.tsx"
1404
+ "../../src/plugins/builtin/git/client/plugin.tsx",
1405
+ "../../src/plugins/builtin/web-preview/client/plugin.tsx"
1405
1406
  ],
1406
1407
  "css": [
1407
1408
  "assets/app.css"
@@ -1417,7 +1418,7 @@
1417
1418
  ]
1418
1419
  },
1419
1420
  "../../src/plugins/builtin/files/client/code-editor.ts": {
1420
- "file": "assets/code-editor-B5kVAtku.js",
1421
+ "file": "assets/code-editor-bWuZTiS2.js",
1421
1422
  "name": "code-editor",
1422
1423
  "src": "../../src/plugins/builtin/files/client/code-editor.ts",
1423
1424
  "isDynamicEntry": true,
@@ -1434,7 +1435,7 @@
1434
1435
  "../../node_modules/@codemirror/lang-go/dist/index.js",
1435
1436
  "../../node_modules/@codemirror/lang-html/dist/index.js",
1436
1437
  "../../node_modules/@codemirror/lang-java/dist/index.js",
1437
- "_dist-Im2q9dJ0.js",
1438
+ "_dist-C2WSXtwq.js",
1438
1439
  "../../node_modules/@codemirror/lang-jinja/dist/index.js",
1439
1440
  "../../node_modules/@codemirror/lang-json/dist/index.js",
1440
1441
  "../../node_modules/@codemirror/lang-less/dist/index.js",
@@ -1546,43 +1547,42 @@
1546
1547
  ]
1547
1548
  },
1548
1549
  "../../src/plugins/builtin/files/client/plugin.tsx": {
1549
- "file": "assets/plugin-CZx51rmJ.js",
1550
+ "file": "assets/plugin-CsVaeNQM.js",
1550
1551
  "name": "plugin",
1551
1552
  "src": "../../src/plugins/builtin/files/client/plugin.tsx",
1552
1553
  "isDynamicEntry": true,
1553
1554
  "imports": [
1554
1555
  "_rolldown-runtime-CgmABjMJ.js",
1555
1556
  "../../src/host/client/app.tsx",
1556
- "_WorkspacePanel.module-V6gI-nG1.js",
1557
+ "_WorkspacePanel.module-q1UBTZQr.js",
1557
1558
  "_react-CLFE7TFE.js",
1558
- "_icons-D8yiYkWB.js",
1559
1559
  "index.html",
1560
- "_clsx-DQAHfk8w.js"
1560
+ "_clsx-DQAHfk8w.js",
1561
+ "_code-file-types-BZAEsqNG.js"
1561
1562
  ],
1562
1563
  "dynamicImports": [
1563
1564
  "../../src/plugins/builtin/files/client/code-editor.ts"
1564
1565
  ]
1565
1566
  },
1566
1567
  "../../src/plugins/builtin/git/client/plugin.tsx": {
1567
- "file": "assets/plugin-CvqNiFRV.js",
1568
+ "file": "assets/plugin-Gwwlx9MU.js",
1568
1569
  "name": "plugin",
1569
1570
  "src": "../../src/plugins/builtin/git/client/plugin.tsx",
1570
1571
  "isDynamicEntry": true,
1571
1572
  "imports": [
1572
1573
  "_rolldown-runtime-CgmABjMJ.js",
1573
1574
  "../../src/host/client/app.tsx",
1574
- "_icons-D8yiYkWB.js",
1575
1575
  "_react-CLFE7TFE.js",
1576
- "_WorkspacePanel.module-V6gI-nG1.js",
1576
+ "_WorkspacePanel.module-q1UBTZQr.js",
1577
1577
  "index.html",
1578
1578
  "_clsx-DQAHfk8w.js"
1579
1579
  ],
1580
1580
  "css": [
1581
- "assets/plugin.css"
1581
+ "assets/plugin2.css"
1582
1582
  ]
1583
1583
  },
1584
1584
  "../../src/plugins/builtin/terminal/client/plugin.tsx": {
1585
- "file": "assets/plugin-D1z0mcl1.js",
1585
+ "file": "assets/plugin-CE1WaS8V.js",
1586
1586
  "name": "plugin",
1587
1587
  "src": "../../src/plugins/builtin/terminal/client/plugin.tsx",
1588
1588
  "isDynamicEntry": true,
@@ -1594,20 +1594,36 @@
1594
1594
  "_clsx-DQAHfk8w.js"
1595
1595
  ],
1596
1596
  "css": [
1597
- "assets/plugin2.css"
1597
+ "assets/plugin3.css"
1598
+ ]
1599
+ },
1600
+ "../../src/plugins/builtin/web-preview/client/plugin.tsx": {
1601
+ "file": "assets/plugin-Cyidq4oP.js",
1602
+ "name": "plugin",
1603
+ "src": "../../src/plugins/builtin/web-preview/client/plugin.tsx",
1604
+ "isDynamicEntry": true,
1605
+ "imports": [
1606
+ "_rolldown-runtime-CgmABjMJ.js",
1607
+ "../../src/host/client/app.tsx",
1608
+ "index.html",
1609
+ "_react-CLFE7TFE.js",
1610
+ "_clsx-DQAHfk8w.js"
1611
+ ],
1612
+ "css": [
1613
+ "assets/plugin.css"
1598
1614
  ]
1599
1615
  },
1600
1616
  "_WorkspacePanel.css": {
1601
1617
  "file": "assets/WorkspacePanel.css",
1602
1618
  "src": "_WorkspacePanel.css"
1603
1619
  },
1604
- "_WorkspacePanel.module-V6gI-nG1.js": {
1605
- "file": "assets/WorkspacePanel.module-V6gI-nG1.js",
1620
+ "_WorkspacePanel.module-q1UBTZQr.js": {
1621
+ "file": "assets/WorkspacePanel.module-q1UBTZQr.js",
1606
1622
  "name": "WorkspacePanel.module",
1607
1623
  "imports": [
1608
1624
  "_rolldown-runtime-CgmABjMJ.js",
1609
1625
  "_react-CLFE7TFE.js",
1610
- "_icons-D8yiYkWB.js",
1626
+ "_code-file-types-BZAEsqNG.js",
1611
1627
  "_clsx-DQAHfk8w.js"
1612
1628
  ],
1613
1629
  "css": [
@@ -1628,6 +1644,15 @@
1628
1644
  "_rolldown-runtime-CgmABjMJ.js"
1629
1645
  ]
1630
1646
  },
1647
+ "_code-file-types-BZAEsqNG.js": {
1648
+ "file": "assets/code-file-types-BZAEsqNG.js",
1649
+ "name": "code-file-types",
1650
+ "imports": [
1651
+ "_rolldown-runtime-CgmABjMJ.js",
1652
+ "_react-CLFE7TFE.js",
1653
+ "_clsx-DQAHfk8w.js"
1654
+ ]
1655
+ },
1631
1656
  "_css-TMM_5IvK.js": {
1632
1657
  "file": "assets/css-TMM_5IvK.js",
1633
1658
  "name": "css",
@@ -1635,6 +1660,16 @@
1635
1660
  "_rolldown-runtime-CgmABjMJ.js"
1636
1661
  ]
1637
1662
  },
1663
+ "_dist-C2WSXtwq.js": {
1664
+ "file": "assets/dist-C2WSXtwq.js",
1665
+ "name": "dist",
1666
+ "imports": [
1667
+ "_rolldown-runtime-CgmABjMJ.js",
1668
+ "_dist-DTWmF6Zy.js",
1669
+ "_dist-IkQ96Etc.js",
1670
+ "../../src/plugins/builtin/files/client/code-editor.ts"
1671
+ ]
1672
+ },
1638
1673
  "_dist-DTWmF6Zy.js": {
1639
1674
  "file": "assets/dist-DTWmF6Zy.js",
1640
1675
  "name": "dist",
@@ -1646,16 +1681,6 @@
1646
1681
  "file": "assets/dist-IkQ96Etc.js",
1647
1682
  "name": "dist"
1648
1683
  },
1649
- "_dist-Im2q9dJ0.js": {
1650
- "file": "assets/dist-Im2q9dJ0.js",
1651
- "name": "dist",
1652
- "imports": [
1653
- "_rolldown-runtime-CgmABjMJ.js",
1654
- "_dist-DTWmF6Zy.js",
1655
- "_dist-IkQ96Etc.js",
1656
- "../../src/plugins/builtin/files/client/code-editor.ts"
1657
- ]
1658
- },
1659
1684
  "_dist-RJnNnBqa.js": {
1660
1685
  "file": "assets/dist-RJnNnBqa.js",
1661
1686
  "name": "dist",
@@ -1665,8 +1690,8 @@
1665
1690
  "_dist-IkQ96Etc.js"
1666
1691
  ]
1667
1692
  },
1668
- "_graphql-Cz1_wnUp.js": {
1669
- "file": "assets/graphql-Cz1_wnUp.js",
1693
+ "_graphql-B5jxVvgN.js": {
1694
+ "file": "assets/graphql-B5jxVvgN.js",
1670
1695
  "name": "graphql",
1671
1696
  "imports": [
1672
1697
  "_rolldown-runtime-CgmABjMJ.js",
@@ -1690,15 +1715,6 @@
1690
1715
  "_html-CFUZAbjn.js"
1691
1716
  ]
1692
1717
  },
1693
- "_icons-D8yiYkWB.js": {
1694
- "file": "assets/icons-D8yiYkWB.js",
1695
- "name": "icons",
1696
- "imports": [
1697
- "_rolldown-runtime-CgmABjMJ.js",
1698
- "_react-CLFE7TFE.js",
1699
- "_clsx-DQAHfk8w.js"
1700
- ]
1701
- },
1702
1718
  "_java-BLj8-EuU.js": {
1703
1719
  "file": "assets/java-BLj8-EuU.js",
1704
1720
  "name": "java",
@@ -1766,7 +1782,7 @@
1766
1782
  ]
1767
1783
  },
1768
1784
  "ui/shared/primitives/markdown/MarkdownText.tsx": {
1769
- "file": "assets/MarkdownText-Ca6_qCyr.js",
1785
+ "file": "assets/MarkdownText-BmWua1fx.js",
1770
1786
  "name": "MarkdownText",
1771
1787
  "src": "ui/shared/primitives/markdown/MarkdownText.tsx",
1772
1788
  "isDynamicEntry": true,
@@ -1774,7 +1790,7 @@
1774
1790
  "_rolldown-runtime-CgmABjMJ.js",
1775
1791
  "_react-CLFE7TFE.js",
1776
1792
  "_clsx-DQAHfk8w.js",
1777
- "_icons-D8yiYkWB.js",
1793
+ "_code-file-types-BZAEsqNG.js",
1778
1794
  "../../src/host/client/app.tsx",
1779
1795
  "index.html"
1780
1796
  ],
@@ -1827,7 +1843,7 @@
1827
1843
  "../../node_modules/@shikijs/langs/dist/perl.mjs",
1828
1844
  "../../node_modules/@shikijs/langs/dist/verilog.mjs",
1829
1845
  "../../node_modules/@shikijs/langs/dist/system-verilog.mjs",
1830
- "_graphql-Cz1_wnUp.js",
1846
+ "_graphql-B5jxVvgN.js",
1831
1847
  "../../node_modules/@shikijs/langs/dist/proto.mjs",
1832
1848
  "../../node_modules/@shikijs/langs/dist/hcl.mjs",
1833
1849
  "../../node_modules/@shikijs/langs/dist/nix.mjs",