@preventive/triage 1.0.0-alpha.57 → 1.0.0-alpha.59

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/out/view.js CHANGED
@@ -1,4 +1,4 @@
1
- import"./chunk-R3NZFXVR.js";import{a as e,b as t,c as n,f as r,g as i,h as a,j as o}from"./chunk-AUFEBLQ2.js";import{$b as s,$c as c,Ab as l,Ac as u,Ae as d,Af as f,Ba as p,Bb as m,Bc as h,Be as g,Bf as _,C as v,Cc as ee,Ce as te,Cf as ne,D as re,Dc as ie,De as ae,Df as oe,Ec as se,Ef as ce,Fc as le,Fe as ue,G as y,Gd as de,Ge as fe,H as pe,Hd as me,He as he,I as ge,Ib as _e,Id as ve,Jd as ye,K as be,Kb as xe,Kd as Se,L as b,Mb as Ce,N as we,Ob as Te,P as Ee,Pb as De,Pd as Oe,Q as ke,Qb as Ae,Qc as je,Qd as Me,Qe as Ne,R as Pe,Rb as Fe,Rc as Ie,Re as Le,S as Re,Sb as ze,T as x,Tb as Be,Ua as Ve,Ub as He,V as Ue,Va as We,Vb as Ge,Wa as Ke,Wc as qe,Xa as Je,Xb as S,Xc as Ye,Ya as Xe,Yb as Ze,Yc as Qe,Zb as $e,Zc as et,_b as tt,_c as nt,ac as rt,ad as it,bc as at,bd as ot,c as st,cb as ct,cc as C,d as w,db as lt,dc as ut,dd as dt,e as ft,eb as pt,ec as mt,ed as ht,f as gt,fc as _t,fd as vt,gb as yt,gc as T,h as bt,hb as E,hc as xt,i as St,ia as Ct,ib as wt,ic as Tt,ja as Et,jb as Dt,jc as Ot,k as kt,ka as At,kc as jt,l as Mt,la as Nt,lb as Pt,lc as Ft,m as It,ma as Lt,mb as Rt,mc as zt,me as Bt,na as Vt,nc as Ht,ne as Ut,o as Wt,oa as Gt,oc as Kt,oe as qt,p as Jt,pc as Yt,pf as Xt,q as Zt,qc as Qt,qe as $t,qf as en,r as tn,ra as nn,rc as rn,re as an,rf as on,s as sn,sc as D,sd as cn,se as ln,sf as un,t as dn,tc as O,te as k,tf as fn,ue as pn,uf as mn,v as hn,vb as gn,ve as _n,vf as A,w as j,wb as vn,we as yn,wf as bn,x as M,xb as xn,xc as Sn,xe as Cn,xf as wn,y as Tn,yb as En,yc as Dn,ye as N,zb as On,zc as kn,ze as An}from"./chunk-5CIDV6RK.js";import"./chunk-JCIIBLKR.js";import"./chunk-E3LFSUDJ.js";import"./chunk-JMG5DXII.js";import{d as jn}from"./chunk-J2FWBXFV.js";import{D as Mn,L as Nn,N as Pn,T as Fn,Y as In,_ as P,b as Ln,ba as Rn,ea as zn,n as Bn,t as Vn,u as Hn,v as Un,x as Wn,y as Gn}from"./chunk-6V6Q5CF7.js";import{g as Kn,h as qn}from"./chunk-AHKPZTAN.js";import"./chunk-NRPC74AM.js";import"./chunk-7BKKYVWR.js";import{f as F}from"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import"./chunk-VFWMQ3LG.js";import{$ as Jn,E as Yn,F as Xn,M as Zn,N as Qn,P as $n,Y as er,a as I,d as tr,da as nr,ea as rr,f as L,g as R,h as ir,ka as ar,l as or,ma as sr,oa as cr,t as lr,w as ur}from"./chunk-4TQKM3JC.js";import{g as dr}from"./chunk-IZ6MYRYB.js";import"./chunk-WCPJDAYA.js";import"./chunk-IYPY47MC.js";import{a as fr,d as pr}from"./chunk-PWFUOLZK.js";import{a as mr,i as hr,j as gr,p as _r,r as vr,t as yr}from"./chunk-PTFQKLKO.js";import{B as br,I as xr,l as Sr}from"./chunk-QRKFPLA4.js";import{d as Cr,i as wr,k as Tr,l as Er,r as Dr,x as Or}from"./chunk-74AEKRES.js";import"./chunk-C4Z6ZBXV.js";import{a as z,b as kr,c as B,g as V,i as Ar,j as H}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var jr={attach:{title:`Synced triage on report attach`,intro:`have triage from your workspace that disagrees with your local view on`,trailingNote:`Other findings in this report whose chain value didn't conflict were applied automatically; this list only covers disagreements. Pick which side to keep.`,importedSideLabel:`Apply from chain`,applyButton:`Apply`},chain:{title:`Triage conflict from peer update`,intro:`were changed by a peer (or by another tab) in a way that disagrees with your local triage on`,trailingNote:`Other findings whose remote value didn't conflict were applied automatically; this list only covers disagreements. Pick which side to keep for each — a "keep current" pick re-publishes your local value to the chain on your next save.`,importedSideLabel:`Apply from chain`,applyButton:`Apply`}};function Mr(){m(async(e,t,n)=>{let r=Ee(e);try{return await gn(e,r,jr[n]??jr.attach)}catch{let t=e.length;return alert(`${n===`attach`?`A report attach`:`A workspace sync`} had ${t} triage disagreement${t===1?``:`s`} with your local view. Kept your local values because another dialog is open. ${n===`attach`?`Detach and re-attach the report to pick again.`:`Your local values will re-publish to the chain on the next change.`}`),null}})}var Nr=class extends Pt{static properties={retry:{type:Boolean},_value:{state:!0}};constructor(){super(),this.retry=!1,this._value=``}_finish(e){this._value=``,super._finish(e)}_onCancel=()=>this._finish(null);_onInput=e=>{this._value=e.target.value};_onSubmit=()=>{let e=this._value??``;e&&this._finish(e)};_onKeydown=e=>{e.key===`Enter`&&(e.preventDefault(),this._onSubmit())};render(){let e=(this._value??``).length>0,t=this.retry?`That password didn't match. Try again, or cancel to leave the workspace unsynced for now.`:`This sync server requires a password before it accepts a new workspace. Enter it to create the workspace on the server.`;return B`<dialog @close="${this._onClose}"><header><h3>Sync server password</h3></header><p class="nwd-intro">${t}</p><input type="password" class="nwd-input" placeholder="Password" autocomplete="off" data-1p-ignore="true" data-lpignore="true" data-bwignore="true" data-form-type="other" name="dv-sync-auth" maxlength="4096" .value="${this._value}" @input="${this._onInput}" @keydown="${this._onKeydown}"><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!e}" @click="${this._onSubmit}">${this.retry?`Retry`:`Authenticate`}</button></footer></dialog>`}};customElements.define(`sync-auth-dialog`,Nr);function Pr({retry:e=!1}={}){return Rt(`sync-auth-dialog`,{retry:!!e})}function Fr(){l(async({retry:e})=>{try{return await Pr({retry:e})}catch(e){return console.warn(`Sync auth dialog failed to open:`,e),null}})}var Ir=`https://triage.space/`,Lr=[{hostname:`deepaudit.dev`,pathPrefix:`/`,supportsSync:!0},{hostname:`chalker.github.io`,pathPrefix:`/deepview/`,supportsSync:!1}];function Rr(){for(let e of Lr)if(location.hostname===e.hostname&&location.pathname.startsWith(e.pathPrefix))return e;return null}var zr=[`deepview.triage`,`deepview.triage.pending`],Br=`deepview.repoUrls`;function Vr(){try{for(let e of zr)if(localStorage.getItem(e))return!0}catch{return!0}try{let e=localStorage.getItem(Br);if(e){let t=JSON.parse(e);if(t&&typeof t==`object`&&Object.keys(t).length>0)return!0}}catch{return!0}return!1}async function Hr(){if(Vr())return!0;let e=[];try{e=await Tn()}catch{return!0}if(e.length>0)return!0;try{if(b().length>0)return!0}catch{return!0}try{return await v()}catch{return!0}}var Ur=class extends H{static properties={supportsSync:{attribute:!1}};createRenderRoot(){return this}constructor(){super(),this.supportsSync=!1}firstUpdated(){let e=this.querySelector(`dialog`);e&&e.showModal();let t=this.querySelector(`button.om-stay`);t&&t.focus()}_finish(e){if(this._settled)return;this._settled=!0;let t=this.querySelector(`dialog`);t&&t.close(),this.dispatchEvent(new CustomEvent(`resolve`,{detail:e}))}_onClose=()=>this._finish(!1);_onStay=()=>this._finish(!1);_onMigrate=()=>this._finish(!0);render(){let e=()=>B`<a class="om-link" href="${Ir}" target="_blank" rel="noopener noreferrer">${Ir}</a>`;return B`<dialog class="origin-migration-dialog" @close="${this._onClose}"><header class="om-head"><h3>This deepview build has moved</h3><p><code>${location.host}${location.pathname}</code> has moved to ${e()}.</p></header><section class="om-body"><p>Workspaces and reports don't migrate automatically — they live in this origin's browser storage (OPFS where available, localStorage as a fallback) and have to be re-imported on ${e()}.</p>${this.supportsSync?B`<p>For each workspace, use the <strong>Export workspace</strong> button in the sidebar to download a <code>.gz</code> bundle (workspace + its reports + its triage), then drop that file on ${e()}. Workspaces that had sync configured will pick their triage state back up from the sync server once you re-import them with the same key.</p><p>For triage attached to loose reports (or as a top-up after re-importing workspaces), call <code>DeepView.export()</code> in the browser console — that downloads just the triage entries plus saved repo URLs, no reports or workspaces.</p>`:B`<p>This build has no sync layer. For each workspace, use the <strong>Export workspace</strong> button in the sidebar to download a <code>.gz</code> bundle (workspace + its reports + its triage), then drop that file on ${e()}.</p><p>For triage attached to loose reports, call <code>DeepView.export()</code> in the browser console — that downloads just the triage entries plus saved repo URLs, no reports or workspaces. Reports themselves need to be re-dropped from their original JSON on the new origin.</p>`}</section><footer class="om-actions"><button type="button" class="om-stay" @click="${this._onStay}">Keep editing on ${location.host}</button> <button type="button" class="primary om-go" @click="${this._onMigrate}">Switch to triage.space</button></footer></dialog>`}};customElements.define(`origin-migration-dialog`,Ur);function Wr(e){return new Promise(t=>{let n=document.createElement(`origin-migration-dialog`);n.supportsSync=e.supportsSync,n.addEventListener(`resolve`,e=>{n.remove(),t(!!e.detail)}),document.body.append(n)})}async function Gr(){let e=Rr();return e?await Hr()?await Wr(e)?(location.assign(Ir),!0):!1:(location.replace(Ir),!0):!1}var U=null,Kr=!1,qr=null;function Jr(e){if(!e)return`Could not unlock. Try again.`;switch(e.name??``){case`NotAllowedError`:case`AbortError`:return``;case`SecurityError`:return`The site identity does not match the one this passkey was registered for. If you opened DeepView through a different URL (different subdomain, different port), reload via the original URL.`;case`InvalidStateError`:return`The passkey state on this device is inconsistent. Try reloading the page or removing and re-creating the passkey.`;case`NotSupportedError`:return`This browser does not support the WebAuthn PRF extension this site needs. Try a recent Chrome, Safari, or Edge with a platform authenticator.`;case`NetworkError`:return`A network error prevented the passkey from completing. Check your connection and try again.`;case`UnknownError`:return`The authenticator returned an unknown error. Try again, or use a different passkey.`;default:{let t=e.message??String(e);return t.length>200?t.slice(0,197)+`…`:t}}}function Yr(){if(U)return U;U=document.createElement(`div`),U.id=`lock-overlay`,U.setAttribute(`role`,`dialog`),U.setAttribute(`aria-modal`,`true`),U.setAttribute(`aria-label`,`Unlock DeepView`),Ar(B`<div class="lock-overlay-card"><div class="lock-overlay-icon" aria-hidden="true"><svg viewBox="0 0 32 32" width="40" height="40" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="15" width="18" height="12" rx="1.5"/><path d="M11 15v-4a5 5 0 0 1 10 0v4"/></svg></div><h2 class="lock-overlay-title">DeepView is locked</h2><p class="lock-overlay-body">Your triage data and reports are encrypted with a passkey on this device. Unlock to continue.</p><p class="lock-overlay-error" hidden></p><button type="button" class="lock-overlay-button primary">Unlock with passkey</button><p class="lock-overlay-footer">Lost your passkey? <a href="#" class="lock-overlay-wipe">Wipe local data and start over</a></p></div>`,U);let e=U.querySelector(`button`),t=U.querySelector(`.lock-overlay-error`);return e.addEventListener(`click`,async()=>{if(!Kr&&Xr()){Kr=!0,t.hidden=!0,t.textContent=``,e.disabled=!0,e.textContent=`Waiting…`,qr=new AbortController;try{await St({signal:qr.signal})}catch(e){let n=Jr(e);t.textContent=n,t.hidden=!n}finally{Kr=!1,qr=null,e.disabled=!1,e.textContent=`Unlock with passkey`}}}),U.querySelector(`.lock-overlay-wipe`).addEventListener(`click`,async e=>{if(e.preventDefault(),!Kr&&Xr()&&confirm(`Wipe ALL local DeepView data and start over?
1
+ import"./chunk-R3NZFXVR.js";import{a as e,b as t,c as n,f as r,g as i,h as a,j as o}from"./chunk-2SY4PYUQ.js";import{$b as s,$c as c,Ab as l,Ac as u,Ae as d,Af as f,Ba as p,Bb as m,Bc as h,Be as g,Bf as _,C as v,Cc as ee,Ce as te,Cf as ne,D as re,Dc as ie,De as ae,Df as oe,Ec as se,Ef as ce,Fc as le,Fe as ue,G as y,Gd as de,Ge as fe,H as pe,Hd as me,He as he,I as ge,Ib as _e,Id as ve,Jd as ye,K as be,Kb as xe,Kd as Se,L as b,Mb as Ce,N as we,Ob as Te,P as Ee,Pb as De,Pd as Oe,Q as ke,Qb as Ae,Qc as je,Qd as Me,Qe as Ne,R as Pe,Rb as Fe,Rc as Ie,Re as Le,S as Re,Sb as ze,T as x,Tb as Be,Ua as Ve,Ub as He,V as Ue,Va as We,Vb as Ge,Wa as Ke,Wc as qe,Xa as Je,Xb as S,Xc as Ye,Ya as Xe,Yb as Ze,Yc as Qe,Zb as $e,Zc as et,_b as tt,_c as nt,ac as rt,ad as it,bc as at,bd as ot,c as st,cb as ct,cc as C,d as w,db as lt,dc as ut,dd as dt,e as ft,eb as pt,ec as mt,ed as ht,f as gt,fc as _t,fd as vt,gb as yt,gc as T,h as bt,hb as E,hc as xt,i as St,ia as Ct,ib as wt,ic as Tt,ja as Et,jb as Dt,jc as Ot,k as kt,ka as At,kc as jt,l as Mt,la as Nt,lb as Pt,lc as Ft,m as It,ma as Lt,mb as Rt,mc as zt,me as Bt,na as Vt,nc as Ht,ne as Ut,o as Wt,oa as Gt,oc as Kt,oe as qt,p as Jt,pc as Yt,pf as Xt,q as Zt,qc as Qt,qe as $t,qf as en,r as tn,ra as nn,rc as rn,re as an,rf as on,s as sn,sc as D,sd as cn,se as ln,sf as un,t as dn,tc as O,te as k,tf as fn,ue as pn,uf as mn,v as hn,vb as gn,ve as _n,vf as A,w as j,wb as vn,we as yn,wf as bn,x as M,xb as xn,xc as Sn,xe as Cn,xf as wn,y as Tn,yb as En,yc as Dn,ye as N,zb as On,zc as kn,ze as An}from"./chunk-OFPDMZJF.js";import"./chunk-JCIIBLKR.js";import"./chunk-E3LFSUDJ.js";import"./chunk-JMG5DXII.js";import{d as jn}from"./chunk-J2FWBXFV.js";import{D as Mn,L as Nn,N as Pn,T as Fn,Y as In,_ as P,b as Ln,ba as Rn,ea as zn,n as Bn,t as Vn,u as Hn,v as Un,x as Wn,y as Gn}from"./chunk-TZS7KERJ.js";import{g as Kn,h as qn}from"./chunk-HNQNDNIE.js";import"./chunk-NRPC74AM.js";import"./chunk-7BKKYVWR.js";import{f as F}from"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import"./chunk-VFWMQ3LG.js";import{$ as Jn,E as Yn,F as Xn,M as Zn,N as Qn,P as $n,Y as er,a as I,d as tr,da as nr,ea as rr,f as L,g as R,h as ir,ka as ar,l as or,ma as sr,oa as cr,t as lr,w as ur}from"./chunk-4TQKM3JC.js";import{g as dr}from"./chunk-IZ6MYRYB.js";import"./chunk-WCPJDAYA.js";import"./chunk-IYPY47MC.js";import{a as fr,d as pr}from"./chunk-PWFUOLZK.js";import{a as mr,i as hr,j as gr,p as _r,r as vr,t as yr}from"./chunk-PTFQKLKO.js";import{B as br,I as xr,l as Sr}from"./chunk-QRKFPLA4.js";import{d as Cr,i as wr,k as Tr,l as Er,r as Dr,x as Or}from"./chunk-74AEKRES.js";import"./chunk-C4Z6ZBXV.js";import{a as z,b as kr,c as B,g as V,i as Ar,j as H}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var jr={attach:{title:`Synced triage on report attach`,intro:`have triage from your workspace that disagrees with your local view on`,trailingNote:`Other findings in this report whose chain value didn't conflict were applied automatically; this list only covers disagreements. Pick which side to keep.`,importedSideLabel:`Apply from chain`,applyButton:`Apply`},chain:{title:`Triage conflict from peer update`,intro:`were changed by a peer (or by another tab) in a way that disagrees with your local triage on`,trailingNote:`Other findings whose remote value didn't conflict were applied automatically; this list only covers disagreements. Pick which side to keep for each — a "keep current" pick re-publishes your local value to the chain on your next save.`,importedSideLabel:`Apply from chain`,applyButton:`Apply`}};function Mr(){m(async(e,t,n)=>{let r=Ee(e);try{return await gn(e,r,jr[n]??jr.attach)}catch{let t=e.length;return alert(`${n===`attach`?`A report attach`:`A workspace sync`} had ${t} triage disagreement${t===1?``:`s`} with your local view. Kept your local values because another dialog is open. ${n===`attach`?`Detach and re-attach the report to pick again.`:`Your local values will re-publish to the chain on the next change.`}`),null}})}var Nr=class extends Pt{static properties={retry:{type:Boolean},_value:{state:!0}};constructor(){super(),this.retry=!1,this._value=``}_finish(e){this._value=``,super._finish(e)}_onCancel=()=>this._finish(null);_onInput=e=>{this._value=e.target.value};_onSubmit=()=>{let e=this._value??``;e&&this._finish(e)};_onKeydown=e=>{e.key===`Enter`&&(e.preventDefault(),this._onSubmit())};render(){let e=(this._value??``).length>0,t=this.retry?`That password didn't match. Try again, or cancel to leave the workspace unsynced for now.`:`This sync server requires a password before it accepts a new workspace. Enter it to create the workspace on the server.`;return B`<dialog @close="${this._onClose}"><header><h3>Sync server password</h3></header><p class="nwd-intro">${t}</p><input type="password" class="nwd-input" placeholder="Password" autocomplete="off" data-1p-ignore="true" data-lpignore="true" data-bwignore="true" data-form-type="other" name="dv-sync-auth" maxlength="4096" .value="${this._value}" @input="${this._onInput}" @keydown="${this._onKeydown}"><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!e}" @click="${this._onSubmit}">${this.retry?`Retry`:`Authenticate`}</button></footer></dialog>`}};customElements.define(`sync-auth-dialog`,Nr);function Pr({retry:e=!1}={}){return Rt(`sync-auth-dialog`,{retry:!!e})}function Fr(){l(async({retry:e})=>{try{return await Pr({retry:e})}catch(e){return console.warn(`Sync auth dialog failed to open:`,e),null}})}var Ir=`https://triage.space/`,Lr=[{hostname:`deepaudit.dev`,pathPrefix:`/`,supportsSync:!0},{hostname:`chalker.github.io`,pathPrefix:`/deepview/`,supportsSync:!1}];function Rr(){for(let e of Lr)if(location.hostname===e.hostname&&location.pathname.startsWith(e.pathPrefix))return e;return null}var zr=[`deepview.triage`,`deepview.triage.pending`],Br=`deepview.repoUrls`;function Vr(){try{for(let e of zr)if(localStorage.getItem(e))return!0}catch{return!0}try{let e=localStorage.getItem(Br);if(e){let t=JSON.parse(e);if(t&&typeof t==`object`&&Object.keys(t).length>0)return!0}}catch{return!0}return!1}async function Hr(){if(Vr())return!0;let e=[];try{e=await Tn()}catch{return!0}if(e.length>0)return!0;try{if(b().length>0)return!0}catch{return!0}try{return await v()}catch{return!0}}var Ur=class extends H{static properties={supportsSync:{attribute:!1}};createRenderRoot(){return this}constructor(){super(),this.supportsSync=!1}firstUpdated(){let e=this.querySelector(`dialog`);e&&e.showModal();let t=this.querySelector(`button.om-stay`);t&&t.focus()}_finish(e){if(this._settled)return;this._settled=!0;let t=this.querySelector(`dialog`);t&&t.close(),this.dispatchEvent(new CustomEvent(`resolve`,{detail:e}))}_onClose=()=>this._finish(!1);_onStay=()=>this._finish(!1);_onMigrate=()=>this._finish(!0);render(){let e=()=>B`<a class="om-link" href="${Ir}" target="_blank" rel="noopener noreferrer">${Ir}</a>`;return B`<dialog class="origin-migration-dialog" @close="${this._onClose}"><header class="om-head"><h3>This deepview build has moved</h3><p><code>${location.host}${location.pathname}</code> has moved to ${e()}.</p></header><section class="om-body"><p>Workspaces and reports don't migrate automatically — they live in this origin's browser storage (OPFS where available, localStorage as a fallback) and have to be re-imported on ${e()}.</p>${this.supportsSync?B`<p>For each workspace, use the <strong>Export workspace</strong> button in the sidebar to download a <code>.gz</code> bundle (workspace + its reports + its triage), then drop that file on ${e()}. Workspaces that had sync configured will pick their triage state back up from the sync server once you re-import them with the same key.</p><p>For triage attached to loose reports (or as a top-up after re-importing workspaces), call <code>DeepView.export()</code> in the browser console — that downloads just the triage entries plus saved repo URLs, no reports or workspaces.</p>`:B`<p>This build has no sync layer. For each workspace, use the <strong>Export workspace</strong> button in the sidebar to download a <code>.gz</code> bundle (workspace + its reports + its triage), then drop that file on ${e()}.</p><p>For triage attached to loose reports, call <code>DeepView.export()</code> in the browser console — that downloads just the triage entries plus saved repo URLs, no reports or workspaces. Reports themselves need to be re-dropped from their original JSON on the new origin.</p>`}</section><footer class="om-actions"><button type="button" class="om-stay" @click="${this._onStay}">Keep editing on ${location.host}</button> <button type="button" class="primary om-go" @click="${this._onMigrate}">Switch to triage.space</button></footer></dialog>`}};customElements.define(`origin-migration-dialog`,Ur);function Wr(e){return new Promise(t=>{let n=document.createElement(`origin-migration-dialog`);n.supportsSync=e.supportsSync,n.addEventListener(`resolve`,e=>{n.remove(),t(!!e.detail)}),document.body.append(n)})}async function Gr(){let e=Rr();return e?await Hr()?await Wr(e)?(location.assign(Ir),!0):!1:(location.replace(Ir),!0):!1}var U=null,Kr=!1,qr=null;function Jr(e){if(!e)return`Could not unlock. Try again.`;switch(e.name??``){case`NotAllowedError`:case`AbortError`:return``;case`SecurityError`:return`The site identity does not match the one this passkey was registered for. If you opened DeepView through a different URL (different subdomain, different port), reload via the original URL.`;case`InvalidStateError`:return`The passkey state on this device is inconsistent. Try reloading the page or removing and re-creating the passkey.`;case`NotSupportedError`:return`This browser does not support the WebAuthn PRF extension this site needs. Try a recent Chrome, Safari, or Edge with a platform authenticator.`;case`NetworkError`:return`A network error prevented the passkey from completing. Check your connection and try again.`;case`UnknownError`:return`The authenticator returned an unknown error. Try again, or use a different passkey.`;default:{let t=e.message??String(e);return t.length>200?t.slice(0,197)+`…`:t}}}function Yr(){if(U)return U;U=document.createElement(`div`),U.id=`lock-overlay`,U.setAttribute(`role`,`dialog`),U.setAttribute(`aria-modal`,`true`),U.setAttribute(`aria-label`,`Unlock DeepView`),Ar(B`<div class="lock-overlay-card"><div class="lock-overlay-icon" aria-hidden="true"><svg viewBox="0 0 32 32" width="40" height="40" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="15" width="18" height="12" rx="1.5"/><path d="M11 15v-4a5 5 0 0 1 10 0v4"/></svg></div><h2 class="lock-overlay-title">DeepView is locked</h2><p class="lock-overlay-body">Your triage data and reports are encrypted with a passkey on this device. Unlock to continue.</p><p class="lock-overlay-error" hidden></p><button type="button" class="lock-overlay-button primary">Unlock with passkey</button><p class="lock-overlay-footer">Lost your passkey? <a href="#" class="lock-overlay-wipe">Wipe local data and start over</a></p></div>`,U);let e=U.querySelector(`button`),t=U.querySelector(`.lock-overlay-error`);return e.addEventListener(`click`,async()=>{if(!Kr&&Xr()){Kr=!0,t.hidden=!0,t.textContent=``,e.disabled=!0,e.textContent=`Waiting…`,qr=new AbortController;try{await St({signal:qr.signal})}catch(e){let n=Jr(e);t.textContent=n,t.hidden=!n}finally{Kr=!1,qr=null,e.disabled=!1,e.textContent=`Unlock with passkey`}}}),U.querySelector(`.lock-overlay-wipe`).addEventListener(`click`,async e=>{if(e.preventDefault(),!Kr&&Xr()&&confirm(`Wipe ALL local DeepView data and start over?
2
2
 
3
3
  This deletes your encrypted triage, all reports, and the passkey registration on this device. The data CANNOT be recovered after this — there is no backup.
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@preventive/triage",
3
- "version": "1.0.0-alpha.57",
3
+ "version": "1.0.0-alpha.59",
4
4
  "description": "Client & relay server for triaging of automated reports",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "author": {
@@ -424,9 +424,9 @@
424
424
  "typescript": "^7.0.2"
425
425
  },
426
426
  "dependencies": {
427
- "@exodus/stasis": "1.0.0-rc.0",
428
- "@exodus/stasis-core": "1.0.0-rc.0",
429
- "@preventive/archive": "^1.4.0",
427
+ "@exodus/stasis": "1.0.0-rc.1",
428
+ "@exodus/stasis-core": "1.0.0-rc.1",
429
+ "@preventive/archive": "^1.4.1",
430
430
  "@preventive/compare": "^1.2.11",
431
431
  "@preventive/diff": "^1.1.0",
432
432
  "@preventive/lockfile": "^1.3.0",
@@ -9,6 +9,10 @@ import { githubBundleFilename } from './bundle-build.ts'
9
9
  import { bundleBuildDiagnostic } from './bundle-build-diagnostics.js'
10
10
  import { MAX_STASIS_CONFIG_BYTES, STASIS_CONFIG, namesLockfiles, parseStasisConfig } from './stasis-config.ts'
11
11
 
12
+ // A bundle's JSON, before compression, at most: a project producing it is
13
+ // what a build's heap is sized for (bundle-build.ts buildHeapLimitMib).
14
+ export const MAX_SERIALIZED_BYTES = 512 * 1024 * 1024
15
+
12
16
  const regularFile = entry => entry.type === 'blob' && ['100644', '100755'].includes(entry.mode)
13
17
  const parentOf = path => posix.dirname(path).replace(/^\.$/u, '')
14
18
 
@@ -141,8 +145,14 @@ export async function buildStasisBundle({ input, github, token, maxBytes, scopes
141
145
  // narrower team grant: the storage location must cover the actual bundle.
142
146
  if (!allowed(directory)) throw new Error('build-scope')
143
147
  progress('serialize')
144
- const serialized = bundle.serialize()
145
- if (Buffer.byteLength(serialized) > 200 * 1024 * 1024) throw new Error('too-large')
148
+ // Its JSON as bytes, a module at a time, never one string on the heap; a
149
+ // module too large for V8 to hold as one is too large too.
150
+ let serialized
151
+ try { serialized = bundle.serializedBytes() } catch (error) {
152
+ if (error instanceof RangeError) throw new Error('too-large', { cause: error })
153
+ throw error
154
+ }
155
+ if (serialized.length > MAX_SERIALIZED_BYTES) throw new Error('too-large')
146
156
  progress('compress')
147
157
  const bytes = brotliCompressSync(serialized, brotliOptions())
148
158
  if (bytes.length > maxBytes) throw new Error('too-large')
@@ -1,5 +1,6 @@
1
1
  import { Buffer } from 'node:buffer'
2
2
  import { createHash, randomUUID } from 'node:crypto'
3
+ import { totalmem } from 'node:os'
3
4
  import { posix } from 'node:path'
4
5
  import { Worker } from 'node:worker_threads'
5
6
  import { BUNDLE_BUILD_TIMEOUT_MS, type BundleBuildLeaseStore } from './bundle-build-leases.ts'
@@ -111,8 +112,26 @@ export interface BuildRequest {
111
112
  // none, as on Vercel. Resolved here: the worker's env holds NPM_TOKEN alone.
112
113
  cacheDir: string | null
113
114
  }
114
- // An extra per-process ceiling; admission must also hold the shared DB lease.
115
+ // An extra per-process ceiling, one build at a time, its worker given the heap
116
+ // buildHeapLimitMib sizes; admission must also hold the shared DB lease.
115
117
  const active = new Set<string>()
118
+ const MAX_ACTIVE_BUILDS = 1
119
+
120
+ // What a build's worker may take of the JS heap, in MiB: what a project
121
+ // producing the largest bundle a build serializes (512 MiB of JSON, the
122
+ // worker's MAX_SERIALIZED_BYTES) takes to build, its tree laid out, scanned
123
+ // and held in memory, its JSON written as bytes off the heap: one of about
124
+ // 500 MiB of small modules builds within 1 GiB, a real tree's taking more,
125
+ // with room to spare; less only where the memory the process may use, its
126
+ // container's limit else the machine's, leaves less once the server keeps
127
+ // SERVER_RESERVE_MIB, down to the 512 MiB a build always had. Past it, Node
128
+ // terminates the worker (build-memory), not the process.
129
+ const BUILD_HEAP_MIB = 2048
130
+ const SERVER_RESERVE_MIB = 512
131
+ const MIN_BUILD_HEAP_MIB = 512
132
+ export function buildHeapLimitMib(memory = Math.min(process.constrainedMemory() || Infinity, totalmem())): number {
133
+ return Math.min(BUILD_HEAP_MIB, Math.max(MIN_BUILD_HEAP_MIB, Math.floor(memory / 1024 ** 2) - SERVER_RESERVE_MIB))
134
+ }
116
135
 
117
136
  export async function withBundleBuildLease<T>(db: BundleBuildLeaseStore, userId: string, signal: AbortSignal,
118
137
  work: (signal: AbortSignal) => Promise<T>): Promise<T> {
@@ -145,15 +164,16 @@ export async function withBundleBuildLease<T>(db: BundleBuildLeaseStore, userId:
145
164
  // Cap concurrent builds, terminate disconnected/timed-out work, and share no
146
165
  // credentials or mutable Stasis state between requests.
147
166
  export async function buildRepositoryBundle(userId: string, request: BuildRequest, signal: AbortSignal): Promise<BuiltBundle> {
148
- if (active.has(userId) || active.size >= 2) throw new BundleBuildError(429, 'build-busy')
167
+ if (active.has(userId) || active.size >= MAX_ACTIVE_BUILDS) throw new BundleBuildError(429, 'build-busy')
149
168
  signal.throwIfAborted()
150
169
  active.add(userId)
151
170
  let worker: Worker | undefined
152
171
  let workerUrl: URL | undefined
153
172
  let stage: BundleBuildStage = 'worker-start'
154
173
  const buildId = randomUUID(), started = performance.now()
174
+ const heapLimitMib = buildHeapLimitMib()
155
175
  const context = { buildId, repoId: request.input.repoId, github: request.github, commit: request.input.commit,
156
- directory: request.input.directory, entryCount: request.input.entries.length, node: process.version }
176
+ directory: request.input.directory, entryCount: request.input.entries.length, node: process.version, heapLimitMib }
157
177
  const log = (event: string, details: Record<string, unknown> = {}) => {
158
178
  const write = event === 'failed' ? console.error : console.info
159
179
  write('managed-bundle-build:', JSON.stringify({ ...context, workerUrl: workerUrl?.href, event, stage, elapsedMs: Math.round(performance.now() - started), ...details }))
@@ -166,7 +186,7 @@ export async function buildRepositoryBundle(userId: string, request: BuildReques
166
186
  const npmToken = process.env['NPM_TOKEN']
167
187
  const env = npmToken ? { NPM_TOKEN: npmToken } : {}
168
188
  worker = new Worker(workerUrl, {
169
- workerData: { ...request, type: 'managed-bundle-build' }, env, execArgv: [], resourceLimits: { maxOldGenerationSizeMb: 512 },
189
+ workerData: { ...request, type: 'managed-bundle-build' }, env, execArgv: [], resourceLimits: { maxOldGenerationSizeMb: heapLimitMib },
170
190
  })
171
191
  const running = worker
172
192
  return await new Promise((resolve, reject) => {
@@ -194,7 +214,11 @@ export async function buildRepositoryBundle(userId: string, request: BuildReques
194
214
  const { bytes } = message
195
215
  resolve({ bytes: Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength), directory: message.directory, filename: message.filename })
196
216
  })
197
- running.once('error', error => fail(422, 'build-failed', { diagnostic: bundleBuildDiagnostic(error, request.token) }))
217
+ // Past its heap (heapLimitMib), Node terminates the worker with ERR_WORKER_OUT_OF_MEMORY.
218
+ running.once('error', error => {
219
+ const outOfMemory = (error as { code?: unknown }).code === 'ERR_WORKER_OUT_OF_MEMORY'
220
+ fail(outOfMemory ? 413 : 422, outOfMemory ? 'build-memory' : 'build-failed', { diagnostic: bundleBuildDiagnostic(error, request.token) })
221
+ })
198
222
  running.once('exit', exitCode => fail(422, 'build-failed', { exitCode }))
199
223
  if (signal.aborted) abort()
200
224
  })
@@ -1 +0,0 @@
1
- function e(e=null){let t=[`anthropic/claude-opus-5.5`,`anthropic/claude-fable-5.1`,`anthropic/claude-sonnet-5.5`,`anthropic/claude-haiku-5.5`,`openai/gpt-6-astra`,`openai/gpt-6-astra-pro`,`openai/gpt-6.1-sol`,`openai/gpt-6.1-sol-pro`,`openai/gpt-6.1-terra`,`openai/gpt-6.1-terra-pro`,`openai/gpt-6-luna`,`openai/gpt-6-luna-pro`,`moonshotai/kimi-k3`,`moonshotai/kimi-k3.1-pro`,`google/gemini-4-argon`,`google/gemma-4-31b-it`,`x-ai/grok-4.7`,`z-ai/glm-5.3`,`qwen/qwen3.8-max`,`deepseek/deepseek-v4.1-flash`,`deepseek/deepseek-v4-pro`,`mistralai/mistral-large-4-0`],n=e===`moonshot`?`moonshotai`:e,r=t.filter(t=>![`anthropic`,`openai`,`moonshot`].includes(e??``)||t.startsWith(`${n}/`)).map(e=>({id:e,efforts:[`low`,`medium`,`high`,`xhigh`,`max`]}));return{models:r,defaultModel:r[0].id}}export{e as a};