@warmhub/sdk-ts 0.87.0 → 0.88.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import {C as C$1,B as B$1,D as D$1,H as H$1,z as z$1,E as E$1,F,G as G$1,A as A$1}from'./chunk-2SDARM7P.js';import {mkdtemp,chmod,rm,open}from'fs/promises';import {tmpdir}from'os';import {join}from'path';import {createHash}from'crypto';import {Writable}from'stream';import {pipeline}from'stream/promises';import {createInflateRaw,crc32}from'zlib';import {once}from'events';import {createWriteStream,createReadStream}from'fs';var u=class extends Error{constructor(e){super(tt(e));this.reason=e;}reason;name="RepositoryCheckpointVerificationError"};function tt(r){switch(r){case "source_failed":return "Repository checkpoint source could not be read";case "archive_invalid":return "Repository checkpoint archive is invalid";case "archive_integrity_mismatch":return "Repository checkpoint archive integrity does not match";case "manifest_invalid":return "Repository checkpoint manifest is invalid";case "chunk_invalid":return "Repository checkpoint chunk is invalid";case "duplicate_durable_id":return "Repository checkpoint contains a duplicate durable identity";case "scratch_cleanup_failed":return "Repository checkpoint verifier scratch cleanup failed"}}var z=67324752,ot=33639248,at=134695760,ct=101075792,ht=117853008,dt=101010256,H=2056,Y=8,A=45,Z=813,D=65535,l=4294967295,q=33,ut=33188,L=64*1024,ft=new RegExp(`^records/[0-9a-f]{64}/part-\\d{${A$1}}\\.jsonl$`),yt=new TextDecoder("utf-8",{fatal:true}),w=class extends Error{};async function W(r,t){let e=new S(r);try{let i=[],n=new Set,s=!1;for(;await e.peekU32()===z;){if(s)throw new Error("manifest must be the final entry");let a=BigInt(e.position),d=await e.readExact(30);wt(d);let o=d.readUInt16LE(26),y=d.readUInt16LE(28);if(o===0||y!==20)throw new Error("local entry metadata is invalid");let c=G(await e.readExact(o));if(bt(c),n.has(c))throw new Error("archive entry is duplicated");n.add(c),s=c===B$1,Et(await e.readExact(y));let p=t(c),P=await lt(e,p),Q=await e.readExact(24);gt(Q,P),await p.finish(),i.push({name:c,localOffset:a,...P});}if(!s||i.length===0)throw new Error("archive manifest entry is missing");return await mt(e,i),{...await e.finish(),entryNames:i.map(a=>a.name)}}finally{await e.close();}}async function lt(r,t){let e=createInflateRaw({chunkSize:L}),i=0n,n=0n,s=0,h=new Writable({highWaterMark:L,write(o,y,c){t.write(o).then(()=>{s=crc32(o,s),n+=BigInt(o.byteLength),c();}).catch(p=>{c(p instanceof Error?p:new Error("checkpoint sink failed"));});}}),a=pipeline(e,h),d=a.then(()=>new Promise(()=>{}),o=>Promise.reject(o));d.catch(()=>{});try{for(;!e.readableEnded;){let o=await r.readSome(L);if(!o)throw new Error("archive entry is truncated");let y=e.bytesWritten;await pt(e,o,d);let c=e.bytesWritten-y;if(!Number.isSafeInteger(c)||c<0||c>o.byteLength)throw new Error("archive inflater consumed invalid input");if(i+=BigInt(c),c<o.byteLength&&r.unread(o.subarray(c)),e.readableEnded)break;if(c===0)throw new Error("archive inflater made no progress")}return await a,{crc:s>>>0,compressedSize:i,uncompressedSize:n}}finally{e.destroyed||e.destroy(),await a.catch(()=>{});}}async function pt(r,t,e){let i=new Promise((n,s)=>{r.write(t,h=>{h?s(h):n();});});await Promise.race([i,e]);}async function mt(r,t){let e=BigInt(r.position);for(let d of t){let o=await r.readExact(46);vt(o,d);let y=o.readUInt16LE(28),c=o.readUInt16LE(30);if(c!==28||o.readUInt16LE(32)!==0)throw new Error("central entry metadata is invalid");if(G(await r.readExact(y))!==d.name)throw new Error("central entry order differs");It(await r.readExact(c),d);}let i=BigInt(r.position)-e,n=BigInt(r.position),s=await r.readExact(56);if(m(s,0,ct),s.readBigUInt64LE(4)!==44n||s.readUInt16LE(12)!==Z||s.readUInt16LE(14)!==A||s.readUInt32LE(16)!==0||s.readUInt32LE(20)!==0||s.readBigUInt64LE(24)!==BigInt(t.length)||s.readBigUInt64LE(32)!==BigInt(t.length)||s.readBigUInt64LE(40)!==i||s.readBigUInt64LE(48)!==e)throw new Error("ZIP64 end record is invalid");let h=await r.readExact(20);if(m(h,0,ht),h.readUInt32LE(4)!==0||h.readBigUInt64LE(8)!==n||h.readUInt32LE(16)!==1)throw new Error("ZIP64 locator is invalid");let a=await r.readExact(22);if(m(a,0,dt),a.readUInt16LE(4)!==0||a.readUInt16LE(6)!==0||a.readUInt16LE(8)!==D||a.readUInt16LE(10)!==D||a.readUInt32LE(12)!==l||a.readUInt32LE(16)!==l||a.readUInt16LE(20)!==0)throw new Error("classic ZIP end record is invalid")}function wt(r){if(m(r,0,z),r.readUInt16LE(4)!==A||r.readUInt16LE(6)!==H||r.readUInt16LE(8)!==Y||r.readUInt16LE(10)!==0||r.readUInt16LE(12)!==q||r.readUInt32LE(14)!==0||r.readUInt32LE(18)!==l||r.readUInt32LE(22)!==l)throw new Error("local entry header is invalid")}function Et(r){if(r.readUInt16LE(0)!==1||r.readUInt16LE(2)!==16||r.readBigUInt64LE(4)!==0n||r.readBigUInt64LE(12)!==0n)throw new Error("local ZIP64 extra is invalid")}function gt(r,t){if(m(r,0,at),r.readUInt32LE(4)!==t.crc||r.readBigUInt64LE(8)!==t.compressedSize||r.readBigUInt64LE(16)!==t.uncompressedSize)throw new Error("archive data descriptor is invalid")}function vt(r,t){if(m(r,0,ot),r.readUInt16LE(4)!==Z||r.readUInt16LE(6)!==A||r.readUInt16LE(8)!==H||r.readUInt16LE(10)!==Y||r.readUInt16LE(12)!==0||r.readUInt16LE(14)!==q||r.readUInt32LE(16)!==t.crc||r.readUInt32LE(20)!==l||r.readUInt32LE(24)!==l||r.readUInt16LE(34)!==0||r.readUInt16LE(36)!==0||(r.readUInt32LE(38)>>>16&65535)!==ut||r.readUInt32LE(42)!==l)throw new Error("central entry header is invalid")}function It(r,t){if(r.readUInt16LE(0)!==1||r.readUInt16LE(2)!==24||r.readBigUInt64LE(4)!==t.uncompressedSize||r.readBigUInt64LE(12)!==t.compressedSize||r.readBigUInt64LE(20)!==t.localOffset)throw new Error("central ZIP64 extra is invalid")}function bt(r){if(r!==B$1&&!ft.test(r))throw new Error("archive entry name is invalid")}function G(r){let t=yt.decode(r);if(Buffer.byteLength(t,"utf8")!==r.byteLength)throw new Error("archive entry name is not canonical UTF-8");return t}function m(r,t,e){if(r.readUInt32LE(t)!==e)throw new Error("archive signature is invalid")}var S=class{#i;#e=createHash("sha256");#t=[];#r=0;#n=false;#o=0;position=0;constructor(t){this.#i=kt(t)[Symbol.asyncIterator]();}async peekU32(){let t=await this.readExact(4);return this.unread(t),t.readUInt32LE(0)}async readExact(t){let e=Buffer.allocUnsafe(t),i=0;for(;i<t;){let n=await this.readSome(t-i);if(!n)throw new Error("archive is truncated");e.set(n,i),i+=n.byteLength;}return e}async readSome(t){for(;this.#t.length===0;)if(!await this.#s())return;let e=this.#t[0],i=e.byteLength-this.#r,n=Math.min(t,i),s=e.subarray(this.#r,this.#r+n);return this.#r+=n,this.position+=n,this.#r===e.byteLength&&(this.#t.shift(),this.#r=0),s}unread(t){if(t.byteLength!==0){if(this.#r>0){let e=this.#t[0].subarray(this.#r);this.#t[0]=e,this.#r=0;}this.#t.unshift(t),this.position-=t.byteLength;}}async finish(){if(this.#t.length>0||await this.#s())throw new Error("archive contains trailing bytes");return {byteLength:this.#o,sha256:this.#e.digest("hex")}}async close(){try{await this.#i.return?.();}catch{}}async#s(){if(this.#n)return false;for(;;){let t;try{t=await this.#i.next();}catch{throw new w}if(t.done)return this.#n=true,false;if(!(t.value instanceof Uint8Array))throw new w;if(t.value.byteLength!==0){if(this.#e.update(t.value),this.#o+=t.value.byteLength,!Number.isSafeInteger(this.#o))throw new Error("archive byte length is unsafe");return this.#t.push(t.value),true}}}};function kt(r){return Symbol.asyncIterator in r?r:{async*[Symbol.asyncIterator](){let t=r.getReader(),e=false;try{for(;;){let{value:i,done:n}=await t.read();if(n){e=!0;return}yield i;}}finally{e||await t.cancel().catch(()=>{}),t.releaseLock();}}}}var _t=4*1024*1024,Bt=8,K=64*1024,Pt=16*1024,f=4,j=4,Nt=1,xt=f+Nt,J=xt+j,E=class extends Error{},b=class{#i;#e;#t=[];#r=0;#n;constructor(t,e={}){this.#i=t;let i=e.sortBudgetBytes??_t;if(this.#n=e.mergeFanIn??Bt,!Number.isSafeInteger(i)||i<J||!Number.isSafeInteger(this.#n)||this.#n<2)throw new Error("checkpoint identity sort limits are invalid");this.#e=new R(i);}add(t){let e=Buffer.byteLength(t,"utf8");if(!this.#e.canFit(e))throw new Error("checkpoint durable identity exceeds the sort budget");if(this.#e.canAdd(e)){this.#e.add(t,e);return}return this.#o(t,e)}async finish(){if(this.#t.length===0){this.#e.sortAndAssertUnique(),this.#e.clear();return}for(this.#e.isEmpty||await this.#o();this.#t.length>this.#n;){let e=[];for(let i=0;i<this.#t.length;i+=this.#n){let n=this.#t.slice(i,i+this.#n),s=this.#s();await Vt(n,s),await Promise.all(n.map(h=>rm(h,{force:true}))),e.push(s);}this.#t=e;}let t;await X(this.#t,e=>{if(t&&_(t,e)===0)throw new E;t=e;});}async#o(t,e){let i=this.#s();this.#e.sortAndAssertUnique(),await Tt(i,this.#e),this.#t.push(i),this.#e.clear(),t!==void 0&&e!==void 0&&this.#e.add(t,e);}#s(){let t=join(this.#i,`identity-run-${String(this.#r).padStart(8,"0")}.bin`);return this.#r+=1,t}},R=class{byteBudget;#i;#e;#t=0;#r=0;constructor(t){this.byteBudget=t;let e=Math.floor(t/J);this.#e=new Uint32Array(e),this.#i=Buffer.allocUnsafe(t-e*j);}get isEmpty(){return this.#r===0}canAdd(t){return this.canFit(t)&&this.#r<this.#e.length&&this.#t+f+t<=this.#i.length}canFit(t){return t<=4294967295&&this.#e.length>0&&f+t<=this.#i.length}add(t,e){if(!this.canAdd(e))throw new Error("checkpoint durable identity exceeds the sort budget");let i=this.#t;this.#e[this.#r]=i,this.#i.writeUInt32BE(e,i),this.#i.write(t,i+f,e,"utf8"),this.#t+=f+e,this.#r+=1;}sortAndAssertUnique(){let t=this.#e.subarray(0,this.#r);t.sort((e,i)=>this.#n(e,i));for(let e=1;e<t.length;e+=1)if(this.#n(t[e-1],t[e])===0)throw new E}clear(){this.#t=0,this.#r=0;}forEachSorted(t){return Ot(this.#e.subarray(0,this.#r),e=>t(this.#s(e)))}#n(t,e){return _(this.#o(t),this.#o(e))}#o(t){let e=this.#i.readUInt32BE(t);return this.#i.subarray(t+f,t+f+e)}#s(t){let e=this.#i.readUInt32BE(t);return this.#i.subarray(t,t+f+e)}};async function Tt(r,t){await $(r,async e=>{let i=new k(e);await t.forEachSorted(n=>i.write(n)),await i.finish();});}async function Vt(r,t){await $(t,async e=>{let i=new k(e);await X(r,n=>i.writeValue(n)),await i.finish();});}async function $(r,t){await(await open(r,"wx",384)).close();let i=createWriteStream(r,{flags:"a",mode:384,highWaterMark:K});try{await t(i),i.end(),await once(i,"close");}catch(n){throw i.destroy(),n}}var k=class{#i;#e=Buffer.allocUnsafe(K);#t=0;constructor(t){this.#i=t;}write(t){if(t.byteLength>this.#e.length)return this.#r(t);if(this.#t+t.byteLength>this.#e.length)return this.#n(t);this.#e.set(t,this.#t),this.#t+=t.byteLength;}writeValue(t){let e=f+t.byteLength;if(e>this.#e.length)return this.#o(t);if(this.#t+e>this.#e.length)return this.#s(t);this.#c(t);}async finish(){await this.#a();}async#r(t){await this.#a(),await I(this.#i,t);}async#n(t){await this.#a(),this.#e.set(t,this.#t),this.#t+=t.byteLength;}async#o(t){await this.#a();let e=Buffer.allocUnsafe(f);e.writeUInt32BE(t.byteLength,0),await I(this.#i,e),await I(this.#i,t);}async#s(t){await this.#a(),this.#c(t);}async#a(){if(this.#t===0)return;let t=this.#e.subarray(0,this.#t);await I(this.#i,t),this.#t=0;}#c(t){this.#e.writeUInt32BE(t.byteLength,this.#t),this.#e.set(t,this.#t+f),this.#t+=f+t.byteLength;}};async function X(r,t){let e=r.map(i=>new C(i));try{for(await Promise.all(e.map(i=>i.advance()));;){let i;for(let s of e)s.current&&(!i||_(s.current,i.current)<0)&&(i=s);if(!i?.current)return;let n=t(i.current);n&&await n,await i.advance();}}finally{for(let i of e)i.close();}}var C=class{#i;#e;#t=Buffer.alloc(0);#r=0;current;constructor(t){this.#i=createReadStream(t,{highWaterMark:Pt}),this.#e=this.#i[Symbol.asyncIterator]();}async advance(){let t=await this.#n(f);if(!t){this.current=void 0;return}let e=t.readUInt32BE(0);if(e===0)throw new Error("checkpoint identity run is invalid");let i=await this.#n(e);if(!i)throw new Error("checkpoint identity run is truncated");this.current=i;}close(){this.#i.destroy();}async#n(t){if(t===0)return Buffer.alloc(0);if(this.#t.length-this.#r>=t){let n=this.#t.subarray(this.#r,this.#r+t);return this.#r+=t,n}let e=Buffer.allocUnsafe(t),i=0;for(;i<t;){if(this.#r<this.#t.length){let s=Math.min(t-i,this.#t.length-this.#r);this.#t.copy(e,i,this.#r,this.#r+s),this.#r+=s,i+=s;continue}let n=await this.#e.next();if(n.done){if(i===0)return;throw new Error("checkpoint identity run is truncated")}this.#t=n.value,this.#r=0;}return e}};async function Ot(r,t){for(let e of r){let i=t(e);i&&await i;}}async function I(r,t){await new Promise((e,i)=>{r.write(t,n=>{n?i(n):e();});});}function _(r,t){let e=Math.min(r.length,t.length);for(let i=0;i<e;i+=1){let n=r[i]-t[i];if(n!==0)return n}return r.length-t.length}var U=class{#i;#e=new Map;#t=new Map;#r=[];#n;constructor(t,e={}){this.#i=new b(t,{sortBudgetBytes:e.identitySortBudgetBytes,mergeFanIn:e.identityMergeFanIn});}openEntry(t){if(t===B$1){let e=[];return {write:async i=>{e.push(i.slice());},finish:async()=>{this.#n=Buffer.concat(e);}}}return new B(t,this.#e,this.#t,this.#i,e=>this.#r.push(e))}async finish(){if(!this.#n)throw new Error("checkpoint manifest is missing");let t=await D$1(this.#n),e=t.streams.flatMap(i=>i.chunks.map(n=>({...n,shapeName:i.shapeName})));if(e.length!==this.#r.length)throw new Error("checkpoint chunk inventory does not match");for(let[i,n]of e.entries()){let s=this.#r[i];if(s.path!==n.path||s.shapeName!==n.shapeName||s.recordCount!==n.recordCount||s.byteLength!==n.byteLength||s.sha256!==n.sha256)throw new Error("checkpoint chunk integrity does not match")}for(let i of t.streams){let n=this.#e.get(i.shapeName);if(!n||H$1(n)!==i.recordCount)throw new Error("checkpoint stream does not match its manifest")}if(this.#e.size!==t.streams.length)throw new Error("checkpoint contains an undeclared stream");return await this.#i.finish(),{manifest:t,chunkCount:e.length}}},B=class{#i;#e;#t;#r;#n;#o=createHash("sha256");#s=[];#a=0;#c;#h=0;#d=0;constructor(t,e,i,n,s){this.#i=t,this.#e=e,this.#t=i,this.#r=n,this.#n=s;}async write(t){if(this.#o.update(t),this.#d+=t.byteLength,!Number.isSafeInteger(this.#d))throw new Error("checkpoint chunk byte length is unsafe");let e=0;for(;e<t.byteLength;){let i=t.indexOf(10,e);if(i<0)break;let n=this.#u(this.#y(t.subarray(e,i+1)));n&&await n,e=i+1;}e<t.byteLength&&this.#f(t.subarray(e));}async finish(){if(this.#s.length!==0||this.#h===0||!this.#c)throw new Error("checkpoint chunk framing is invalid");if(this.#d>z$1&&this.#h!==1)throw new Error("oversized checkpoint chunk has multiple rows");this.#n({path:this.#i,shapeName:this.#c,recordCount:this.#h,byteLength:this.#d,sha256:this.#o.digest("hex")});let t=this.#t.get(this.#c);if(!t)throw new Error("checkpoint stream chunk state is missing");t.previous={byteLength:this.#d};}#u(t){let e=E$1(t),i=e.kind==="shape"?e.wref:e.shapeName;if(this.#c!==void 0&&this.#c!==i)throw new Error("checkpoint chunk mixes Shape streams");this.#c=i,this.#h===0&&this.#l(i,t.byteLength);let n=this.#e.get(i)??F(i);this.#e.set(i,n),G$1(n,e);let s=this.#r.add(e.durableId);if(this.#h+=1,!Number.isSafeInteger(this.#h))throw new Error("checkpoint chunk row count is unsafe");return s}#f(t){if(t.byteLength!==0&&(this.#s.push(t.slice()),this.#a+=t.byteLength,!Number.isSafeInteger(this.#a)))throw new Error("checkpoint row byte length is unsafe")}#y(t){if(this.#s.length===0)return t;let e=Buffer.concat([...this.#s,t],this.#a+t.byteLength);return this.#s=[],this.#a=0,e}#l(t,e){let i=Number(this.#i.match(/part-(\d{10})\.jsonl$/)?.[1]??-1),n=this.#t.get(t)??{nextPart:0};if(i!==n.nextPart)throw new Error("checkpoint stream chunk parts are not contiguous");if(n.previous&&n.previous.byteLength<=z$1&&n.previous.byteLength+e<=z$1)throw new Error("checkpoint stream chunk closed before the byte limit");n.nextPart+=1,this.#t.set(t,n);}};async function Zt(r,t){return qt(r,t)}async function qt(r,t,e={}){let i=await mkdtemp(join(e.scratchParent??tmpdir(),"warmhub-checkpoint-verify-"));await chmod(i,448);let n,s;try{let h=new U(i,e),a=await W(r,y=>h.openEntry(y)),{manifest:d,chunkCount:o}=await h.finish();Wt(t,a,d),n={valid:!0,checkpointId:d.checkpointId,repoSeq:d.repoSeq,recordCount:d.recordCount,chunkCount:o,totalBytes:a.byteLength,rootDigest:d.contentSha256,archiveDigest:a.sha256};}catch(h){s=Gt(h);}try{await rm(i,{recursive:!0,force:!0});}catch{s??=new u("scratch_cleanup_failed");}if(s)throw s;if(!n)throw new u("archive_invalid");return n}function Wt(r,t,e){if(r&&(C$1.parse(r.sha256),r.checkpointId!==e.checkpointId||r.repoSeq!==e.repoSeq||r.byteLength!==t.byteLength||r.sha256!==t.sha256))throw new u("archive_integrity_mismatch")}function Gt(r){if(r instanceof u)return r;if(r instanceof w)return new u("source_failed");if(r instanceof E)return new u("duplicate_durable_id");let t=r instanceof Error?r.message:"";return t.includes("manifest")?new u("manifest_invalid"):t.includes("chunk")||t.includes("row")||t.includes("Shape stream")?new u("chunk_invalid"):new u("archive_invalid")}export{u as RepositoryCheckpointVerificationError,Zt as verifyRepositoryCheckpointArchive};//# sourceMappingURL=checkpoint.js.map
1
+ import {G as G$1,F,H as H$1,L as L$1,D as D$1,I as I$1,J as J$1,K as K$1,E as E$1}from'./chunk-YWDIWGQP.js';import {mkdtemp,chmod,rm,open}from'fs/promises';import {tmpdir}from'os';import {join}from'path';import {createHash}from'crypto';import {Writable}from'stream';import {pipeline}from'stream/promises';import {createInflateRaw,crc32}from'zlib';import {once}from'events';import {createWriteStream,createReadStream}from'fs';var u=class extends Error{constructor(e){super(tt(e));this.reason=e;}reason;name="RepositoryCheckpointVerificationError"};function tt(r){switch(r){case "source_failed":return "Repository checkpoint source could not be read";case "archive_invalid":return "Repository checkpoint archive is invalid";case "archive_integrity_mismatch":return "Repository checkpoint archive integrity does not match";case "manifest_invalid":return "Repository checkpoint manifest is invalid";case "chunk_invalid":return "Repository checkpoint chunk is invalid";case "duplicate_durable_id":return "Repository checkpoint contains a duplicate durable identity";case "scratch_cleanup_failed":return "Repository checkpoint verifier scratch cleanup failed"}}var z=67324752,ot=33639248,at=134695760,ct=101075792,ht=117853008,dt=101010256,H=2056,Y=8,A=45,Z=813,D=65535,l=4294967295,q=33,ut=33188,L=64*1024,ft=new RegExp(`^records/[0-9a-f]{64}/part-\\d{${E$1}}\\.jsonl$`),yt=new TextDecoder("utf-8",{fatal:true}),w=class extends Error{};async function W(r,t){let e=new S(r);try{let i=[],n=new Set,s=!1;for(;await e.peekU32()===z;){if(s)throw new Error("manifest must be the final entry");let a=BigInt(e.position),d=await e.readExact(30);wt(d);let o=d.readUInt16LE(26),y=d.readUInt16LE(28);if(o===0||y!==20)throw new Error("local entry metadata is invalid");let c=G(await e.readExact(o));if(bt(c),n.has(c))throw new Error("archive entry is duplicated");n.add(c),s=c===F,Et(await e.readExact(y));let p=t(c),P=await lt(e,p),Q=await e.readExact(24);gt(Q,P),await p.finish(),i.push({name:c,localOffset:a,...P});}if(!s||i.length===0)throw new Error("archive manifest entry is missing");return await mt(e,i),{...await e.finish(),entryNames:i.map(a=>a.name)}}finally{await e.close();}}async function lt(r,t){let e=createInflateRaw({chunkSize:L}),i=0n,n=0n,s=0,h=new Writable({highWaterMark:L,write(o,y,c){t.write(o).then(()=>{s=crc32(o,s),n+=BigInt(o.byteLength),c();}).catch(p=>{c(p instanceof Error?p:new Error("checkpoint sink failed"));});}}),a=pipeline(e,h),d=a.then(()=>new Promise(()=>{}),o=>Promise.reject(o));d.catch(()=>{});try{for(;!e.readableEnded;){let o=await r.readSome(L);if(!o)throw new Error("archive entry is truncated");let y=e.bytesWritten;await pt(e,o,d);let c=e.bytesWritten-y;if(!Number.isSafeInteger(c)||c<0||c>o.byteLength)throw new Error("archive inflater consumed invalid input");if(i+=BigInt(c),c<o.byteLength&&r.unread(o.subarray(c)),e.readableEnded)break;if(c===0)throw new Error("archive inflater made no progress")}return await a,{crc:s>>>0,compressedSize:i,uncompressedSize:n}}finally{e.destroyed||e.destroy(),await a.catch(()=>{});}}async function pt(r,t,e){let i=new Promise((n,s)=>{r.write(t,h=>{h?s(h):n();});});await Promise.race([i,e]);}async function mt(r,t){let e=BigInt(r.position);for(let d of t){let o=await r.readExact(46);vt(o,d);let y=o.readUInt16LE(28),c=o.readUInt16LE(30);if(c!==28||o.readUInt16LE(32)!==0)throw new Error("central entry metadata is invalid");if(G(await r.readExact(y))!==d.name)throw new Error("central entry order differs");It(await r.readExact(c),d);}let i=BigInt(r.position)-e,n=BigInt(r.position),s=await r.readExact(56);if(m(s,0,ct),s.readBigUInt64LE(4)!==44n||s.readUInt16LE(12)!==Z||s.readUInt16LE(14)!==A||s.readUInt32LE(16)!==0||s.readUInt32LE(20)!==0||s.readBigUInt64LE(24)!==BigInt(t.length)||s.readBigUInt64LE(32)!==BigInt(t.length)||s.readBigUInt64LE(40)!==i||s.readBigUInt64LE(48)!==e)throw new Error("ZIP64 end record is invalid");let h=await r.readExact(20);if(m(h,0,ht),h.readUInt32LE(4)!==0||h.readBigUInt64LE(8)!==n||h.readUInt32LE(16)!==1)throw new Error("ZIP64 locator is invalid");let a=await r.readExact(22);if(m(a,0,dt),a.readUInt16LE(4)!==0||a.readUInt16LE(6)!==0||a.readUInt16LE(8)!==D||a.readUInt16LE(10)!==D||a.readUInt32LE(12)!==l||a.readUInt32LE(16)!==l||a.readUInt16LE(20)!==0)throw new Error("classic ZIP end record is invalid")}function wt(r){if(m(r,0,z),r.readUInt16LE(4)!==A||r.readUInt16LE(6)!==H||r.readUInt16LE(8)!==Y||r.readUInt16LE(10)!==0||r.readUInt16LE(12)!==q||r.readUInt32LE(14)!==0||r.readUInt32LE(18)!==l||r.readUInt32LE(22)!==l)throw new Error("local entry header is invalid")}function Et(r){if(r.readUInt16LE(0)!==1||r.readUInt16LE(2)!==16||r.readBigUInt64LE(4)!==0n||r.readBigUInt64LE(12)!==0n)throw new Error("local ZIP64 extra is invalid")}function gt(r,t){if(m(r,0,at),r.readUInt32LE(4)!==t.crc||r.readBigUInt64LE(8)!==t.compressedSize||r.readBigUInt64LE(16)!==t.uncompressedSize)throw new Error("archive data descriptor is invalid")}function vt(r,t){if(m(r,0,ot),r.readUInt16LE(4)!==Z||r.readUInt16LE(6)!==A||r.readUInt16LE(8)!==H||r.readUInt16LE(10)!==Y||r.readUInt16LE(12)!==0||r.readUInt16LE(14)!==q||r.readUInt32LE(16)!==t.crc||r.readUInt32LE(20)!==l||r.readUInt32LE(24)!==l||r.readUInt16LE(34)!==0||r.readUInt16LE(36)!==0||(r.readUInt32LE(38)>>>16&65535)!==ut||r.readUInt32LE(42)!==l)throw new Error("central entry header is invalid")}function It(r,t){if(r.readUInt16LE(0)!==1||r.readUInt16LE(2)!==24||r.readBigUInt64LE(4)!==t.uncompressedSize||r.readBigUInt64LE(12)!==t.compressedSize||r.readBigUInt64LE(20)!==t.localOffset)throw new Error("central ZIP64 extra is invalid")}function bt(r){if(r!==F&&!ft.test(r))throw new Error("archive entry name is invalid")}function G(r){let t=yt.decode(r);if(Buffer.byteLength(t,"utf8")!==r.byteLength)throw new Error("archive entry name is not canonical UTF-8");return t}function m(r,t,e){if(r.readUInt32LE(t)!==e)throw new Error("archive signature is invalid")}var S=class{#i;#e=createHash("sha256");#t=[];#r=0;#n=false;#o=0;position=0;constructor(t){this.#i=kt(t)[Symbol.asyncIterator]();}async peekU32(){let t=await this.readExact(4);return this.unread(t),t.readUInt32LE(0)}async readExact(t){let e=Buffer.allocUnsafe(t),i=0;for(;i<t;){let n=await this.readSome(t-i);if(!n)throw new Error("archive is truncated");e.set(n,i),i+=n.byteLength;}return e}async readSome(t){for(;this.#t.length===0;)if(!await this.#s())return;let e=this.#t[0],i=e.byteLength-this.#r,n=Math.min(t,i),s=e.subarray(this.#r,this.#r+n);return this.#r+=n,this.position+=n,this.#r===e.byteLength&&(this.#t.shift(),this.#r=0),s}unread(t){if(t.byteLength!==0){if(this.#r>0){let e=this.#t[0].subarray(this.#r);this.#t[0]=e,this.#r=0;}this.#t.unshift(t),this.position-=t.byteLength;}}async finish(){if(this.#t.length>0||await this.#s())throw new Error("archive contains trailing bytes");return {byteLength:this.#o,sha256:this.#e.digest("hex")}}async close(){try{await this.#i.return?.();}catch{}}async#s(){if(this.#n)return false;for(;;){let t;try{t=await this.#i.next();}catch{throw new w}if(t.done)return this.#n=true,false;if(!(t.value instanceof Uint8Array))throw new w;if(t.value.byteLength!==0){if(this.#e.update(t.value),this.#o+=t.value.byteLength,!Number.isSafeInteger(this.#o))throw new Error("archive byte length is unsafe");return this.#t.push(t.value),true}}}};function kt(r){return Symbol.asyncIterator in r?r:{async*[Symbol.asyncIterator](){let t=r.getReader(),e=false;try{for(;;){let{value:i,done:n}=await t.read();if(n){e=!0;return}yield i;}}finally{e||await t.cancel().catch(()=>{}),t.releaseLock();}}}}var _t=4*1024*1024,Bt=8,K=64*1024,Pt=16*1024,f=4,j=4,Nt=1,xt=f+Nt,J=xt+j,E=class extends Error{},b=class{#i;#e;#t=[];#r=0;#n;constructor(t,e={}){this.#i=t;let i=e.sortBudgetBytes??_t;if(this.#n=e.mergeFanIn??Bt,!Number.isSafeInteger(i)||i<J||!Number.isSafeInteger(this.#n)||this.#n<2)throw new Error("checkpoint identity sort limits are invalid");this.#e=new R(i);}add(t){let e=Buffer.byteLength(t,"utf8");if(!this.#e.canFit(e))throw new Error("checkpoint durable identity exceeds the sort budget");if(this.#e.canAdd(e)){this.#e.add(t,e);return}return this.#o(t,e)}async finish(){if(this.#t.length===0){this.#e.sortAndAssertUnique(),this.#e.clear();return}for(this.#e.isEmpty||await this.#o();this.#t.length>this.#n;){let e=[];for(let i=0;i<this.#t.length;i+=this.#n){let n=this.#t.slice(i,i+this.#n),s=this.#s();await Vt(n,s),await Promise.all(n.map(h=>rm(h,{force:true}))),e.push(s);}this.#t=e;}let t;await X(this.#t,e=>{if(t&&_(t,e)===0)throw new E;t=e;});}async#o(t,e){let i=this.#s();this.#e.sortAndAssertUnique(),await Tt(i,this.#e),this.#t.push(i),this.#e.clear(),t!==void 0&&e!==void 0&&this.#e.add(t,e);}#s(){let t=join(this.#i,`identity-run-${String(this.#r).padStart(8,"0")}.bin`);return this.#r+=1,t}},R=class{byteBudget;#i;#e;#t=0;#r=0;constructor(t){this.byteBudget=t;let e=Math.floor(t/J);this.#e=new Uint32Array(e),this.#i=Buffer.allocUnsafe(t-e*j);}get isEmpty(){return this.#r===0}canAdd(t){return this.canFit(t)&&this.#r<this.#e.length&&this.#t+f+t<=this.#i.length}canFit(t){return t<=4294967295&&this.#e.length>0&&f+t<=this.#i.length}add(t,e){if(!this.canAdd(e))throw new Error("checkpoint durable identity exceeds the sort budget");let i=this.#t;this.#e[this.#r]=i,this.#i.writeUInt32BE(e,i),this.#i.write(t,i+f,e,"utf8"),this.#t+=f+e,this.#r+=1;}sortAndAssertUnique(){let t=this.#e.subarray(0,this.#r);t.sort((e,i)=>this.#n(e,i));for(let e=1;e<t.length;e+=1)if(this.#n(t[e-1],t[e])===0)throw new E}clear(){this.#t=0,this.#r=0;}forEachSorted(t){return Ot(this.#e.subarray(0,this.#r),e=>t(this.#s(e)))}#n(t,e){return _(this.#o(t),this.#o(e))}#o(t){let e=this.#i.readUInt32BE(t);return this.#i.subarray(t+f,t+f+e)}#s(t){let e=this.#i.readUInt32BE(t);return this.#i.subarray(t,t+f+e)}};async function Tt(r,t){await $(r,async e=>{let i=new k(e);await t.forEachSorted(n=>i.write(n)),await i.finish();});}async function Vt(r,t){await $(t,async e=>{let i=new k(e);await X(r,n=>i.writeValue(n)),await i.finish();});}async function $(r,t){await(await open(r,"wx",384)).close();let i=createWriteStream(r,{flags:"a",mode:384,highWaterMark:K});try{await t(i),i.end(),await once(i,"close");}catch(n){throw i.destroy(),n}}var k=class{#i;#e=Buffer.allocUnsafe(K);#t=0;constructor(t){this.#i=t;}write(t){if(t.byteLength>this.#e.length)return this.#r(t);if(this.#t+t.byteLength>this.#e.length)return this.#n(t);this.#e.set(t,this.#t),this.#t+=t.byteLength;}writeValue(t){let e=f+t.byteLength;if(e>this.#e.length)return this.#o(t);if(this.#t+e>this.#e.length)return this.#s(t);this.#c(t);}async finish(){await this.#a();}async#r(t){await this.#a(),await I(this.#i,t);}async#n(t){await this.#a(),this.#e.set(t,this.#t),this.#t+=t.byteLength;}async#o(t){await this.#a();let e=Buffer.allocUnsafe(f);e.writeUInt32BE(t.byteLength,0),await I(this.#i,e),await I(this.#i,t);}async#s(t){await this.#a(),this.#c(t);}async#a(){if(this.#t===0)return;let t=this.#e.subarray(0,this.#t);await I(this.#i,t),this.#t=0;}#c(t){this.#e.writeUInt32BE(t.byteLength,this.#t),this.#e.set(t,this.#t+f),this.#t+=f+t.byteLength;}};async function X(r,t){let e=r.map(i=>new C(i));try{for(await Promise.all(e.map(i=>i.advance()));;){let i;for(let s of e)s.current&&(!i||_(s.current,i.current)<0)&&(i=s);if(!i?.current)return;let n=t(i.current);n&&await n,await i.advance();}}finally{for(let i of e)i.close();}}var C=class{#i;#e;#t=Buffer.alloc(0);#r=0;current;constructor(t){this.#i=createReadStream(t,{highWaterMark:Pt}),this.#e=this.#i[Symbol.asyncIterator]();}async advance(){let t=await this.#n(f);if(!t){this.current=void 0;return}let e=t.readUInt32BE(0);if(e===0)throw new Error("checkpoint identity run is invalid");let i=await this.#n(e);if(!i)throw new Error("checkpoint identity run is truncated");this.current=i;}close(){this.#i.destroy();}async#n(t){if(t===0)return Buffer.alloc(0);if(this.#t.length-this.#r>=t){let n=this.#t.subarray(this.#r,this.#r+t);return this.#r+=t,n}let e=Buffer.allocUnsafe(t),i=0;for(;i<t;){if(this.#r<this.#t.length){let s=Math.min(t-i,this.#t.length-this.#r);this.#t.copy(e,i,this.#r,this.#r+s),this.#r+=s,i+=s;continue}let n=await this.#e.next();if(n.done){if(i===0)return;throw new Error("checkpoint identity run is truncated")}this.#t=n.value,this.#r=0;}return e}};async function Ot(r,t){for(let e of r){let i=t(e);i&&await i;}}async function I(r,t){await new Promise((e,i)=>{r.write(t,n=>{n?i(n):e();});});}function _(r,t){let e=Math.min(r.length,t.length);for(let i=0;i<e;i+=1){let n=r[i]-t[i];if(n!==0)return n}return r.length-t.length}var U=class{#i;#e=new Map;#t=new Map;#r=[];#n;constructor(t,e={}){this.#i=new b(t,{sortBudgetBytes:e.identitySortBudgetBytes,mergeFanIn:e.identityMergeFanIn});}openEntry(t){if(t===F){let e=[];return {write:async i=>{e.push(i.slice());},finish:async()=>{this.#n=Buffer.concat(e);}}}return new B(t,this.#e,this.#t,this.#i,e=>this.#r.push(e))}async finish(){if(!this.#n)throw new Error("checkpoint manifest is missing");let t=await H$1(this.#n),e=t.streams.flatMap(i=>i.chunks.map(n=>({...n,shapeName:i.shapeName})));if(e.length!==this.#r.length)throw new Error("checkpoint chunk inventory does not match");for(let[i,n]of e.entries()){let s=this.#r[i];if(s.path!==n.path||s.shapeName!==n.shapeName||s.recordCount!==n.recordCount||s.byteLength!==n.byteLength||s.sha256!==n.sha256)throw new Error("checkpoint chunk integrity does not match")}for(let i of t.streams){let n=this.#e.get(i.shapeName);if(!n||L$1(n)!==i.recordCount)throw new Error("checkpoint stream does not match its manifest")}if(this.#e.size!==t.streams.length)throw new Error("checkpoint contains an undeclared stream");return await this.#i.finish(),{manifest:t,chunkCount:e.length}}},B=class{#i;#e;#t;#r;#n;#o=createHash("sha256");#s=[];#a=0;#c;#h=0;#d=0;constructor(t,e,i,n,s){this.#i=t,this.#e=e,this.#t=i,this.#r=n,this.#n=s;}async write(t){if(this.#o.update(t),this.#d+=t.byteLength,!Number.isSafeInteger(this.#d))throw new Error("checkpoint chunk byte length is unsafe");let e=0;for(;e<t.byteLength;){let i=t.indexOf(10,e);if(i<0)break;let n=this.#u(this.#y(t.subarray(e,i+1)));n&&await n,e=i+1;}e<t.byteLength&&this.#f(t.subarray(e));}async finish(){if(this.#s.length!==0||this.#h===0||!this.#c)throw new Error("checkpoint chunk framing is invalid");if(this.#d>D$1&&this.#h!==1)throw new Error("oversized checkpoint chunk has multiple rows");this.#n({path:this.#i,shapeName:this.#c,recordCount:this.#h,byteLength:this.#d,sha256:this.#o.digest("hex")});let t=this.#t.get(this.#c);if(!t)throw new Error("checkpoint stream chunk state is missing");t.previous={byteLength:this.#d};}#u(t){let e=I$1(t),i=e.kind==="shape"?e.wref:e.shapeName;if(this.#c!==void 0&&this.#c!==i)throw new Error("checkpoint chunk mixes Shape streams");this.#c=i,this.#h===0&&this.#l(i,t.byteLength);let n=this.#e.get(i)??J$1(i);this.#e.set(i,n),K$1(n,e);let s=this.#r.add(e.durableId);if(this.#h+=1,!Number.isSafeInteger(this.#h))throw new Error("checkpoint chunk row count is unsafe");return s}#f(t){if(t.byteLength!==0&&(this.#s.push(t.slice()),this.#a+=t.byteLength,!Number.isSafeInteger(this.#a)))throw new Error("checkpoint row byte length is unsafe")}#y(t){if(this.#s.length===0)return t;let e=Buffer.concat([...this.#s,t],this.#a+t.byteLength);return this.#s=[],this.#a=0,e}#l(t,e){let i=Number(this.#i.match(/part-(\d{10})\.jsonl$/)?.[1]??-1),n=this.#t.get(t)??{nextPart:0};if(i!==n.nextPart)throw new Error("checkpoint stream chunk parts are not contiguous");if(n.previous&&n.previous.byteLength<=D$1&&n.previous.byteLength+e<=D$1)throw new Error("checkpoint stream chunk closed before the byte limit");n.nextPart+=1,this.#t.set(t,n);}};async function Zt(r,t){return qt(r,t)}async function qt(r,t,e={}){let i=await mkdtemp(join(e.scratchParent??tmpdir(),"warmhub-checkpoint-verify-"));await chmod(i,448);let n,s;try{let h=new U(i,e),a=await W(r,y=>h.openEntry(y)),{manifest:d,chunkCount:o}=await h.finish();Wt(t,a,d),n={valid:!0,checkpointId:d.checkpointId,repoSeq:d.repoSeq,recordCount:d.recordCount,chunkCount:o,totalBytes:a.byteLength,rootDigest:d.contentSha256,archiveDigest:a.sha256};}catch(h){s=Gt(h);}try{await rm(i,{recursive:!0,force:!0});}catch{s??=new u("scratch_cleanup_failed");}if(s)throw s;if(!n)throw new u("archive_invalid");return n}function Wt(r,t,e){if(r&&(G$1.parse(r.sha256),r.checkpointId!==e.checkpointId||r.repoSeq!==e.repoSeq||r.byteLength!==t.byteLength||r.sha256!==t.sha256))throw new u("archive_integrity_mismatch")}function Gt(r){if(r instanceof u)return r;if(r instanceof w)return new u("source_failed");if(r instanceof E)return new u("duplicate_durable_id");let t=r instanceof Error?r.message:"";return t.includes("manifest")?new u("manifest_invalid"):t.includes("chunk")||t.includes("row")||t.includes("Shape stream")?new u("chunk_invalid"):new u("archive_invalid")}export{u as RepositoryCheckpointVerificationError,Zt as verifyRepositoryCheckpointArchive};//# sourceMappingURL=checkpoint.js.map
2
2
  //# sourceMappingURL=checkpoint.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/repository-checkpoint/types.ts","../src/repository-checkpoint/archive-reader.ts","../src/repository-checkpoint/identity-sort.ts","../src/repository-checkpoint/content-verifier.ts","../src/repository-checkpoint/verify.ts"],"names":["RepositoryCheckpointVerificationError","reason","messageForReason","LOCAL_SIGNATURE","CENTRAL_SIGNATURE","DESCRIPTOR_SIGNATURE","ZIP64_END_SIGNATURE","ZIP64_LOCATOR_SIGNATURE","CLASSIC_END_SIGNATURE","ZIP_FLAGS","ZIP_METHOD_DEFLATE","ZIP_VERSION_45","ZIP_VERSION_MADE_BY_UNIX","ZIP64_SENTINEL_16","ZIP64_SENTINEL_32","DOS_EPOCH_DATE","REGULAR_FILE_0644","INFLATE_INPUT_BYTES","CHUNK_PATH","CHECKPOINT_PART_DIGITS","utf8Decoder","CheckpointSourceReadError","readCheckpointZip64Archive","source","openEntry","reader","StreamingByteReader","entries","names","manifestSeen","localOffset","header","assertLocalHeader","nameLength","extraLength","name","decodeEntryName","assertEntryName","CHECKPOINT_MANIFEST_NAME","assertLocalExtra","sink","inflated","inflateEntry","descriptor","assertDescriptor","readCentralDirectory","entry","inflater","createInflateRaw","compressedSize","uncompressedSize","crc","output","Writable","bytes","_encoding","done","crc32","error","completed","pipeline","failed","input","before","writeInflateInput","consumed","written","resolve","reject","centralOffset","expected","assertCentralHeader","assertCentralExtra","centralSize","zip64Offset","end","requireU32","locator","classic","extra","offset","value","#iterator","#hash","createHash","#queue","#queueOffset","#sourceDone","#loadedBytes","toAsyncIterable","length","result","chunk","limit","#load","head","available","current","CHECKPOINT_IDENTITY_SORT_BUDGET_BYTES","CHECKPOINT_IDENTITY_MERGE_FAN_IN","RUN_BUFFER_BYTES","RUN_READ_BUFFER_BYTES","IDENTITY_LENGTH_BYTES","OFFSET_BYTES","MINIMUM_IDENTITY_BYTES","MINIMUM_RECORD_BYTES","MINIMUM_RESIDENT_BYTES","DuplicateCheckpointDurableIdError","CheckpointIdentitySorter","#scratchPath","#resident","#runs","#nextRun","#mergeFanIn","scratchPath","options","sortBudgetBytes","ResidentDurableIds","durableId","byteLength","#flushRun","nextRuns","group","#runPath","writeMergedRun","path","rm","previous","mergeRuns","compareUtf8Bytes","nextDurableId","nextByteLength","writeResidentRun","join","#records","#offsets","#recordBytes","#count","byteBudget","offsetCapacity","offsets","left","right","#compareAt","index","consume","each","#recordAt","leftOffset","rightOffset","#valueAt","resident","writeRun","writer","BufferedRunWriter","record","inputs","outputPath","produce","open","createWriteStream","once","#output","#buffer","#length","#flushThenWrite","#flushThenBuffer","recordLength","#flushThenWriteValue","#flushThenBufferValue","#writeValue","#flush","writeChunk","batch","paths","cursors","RunCursor","cursor","selected","#stream","#chunk","#offset","createReadStream","#readExactly","copied","next","values","sharedLength","difference","CheckpointContentVerifier","#identitySorter","#streamStates","#streamChunks","#observedChunks","#manifestBytes","chunks","CheckpointChunkSink","manifest","parseCheckpointManifest","declared","stream","observed","state","finishCheckpointStreamValidation","#path","#completed","#lineFragments","#lineFragmentBytes","#shapeName","#recordCount","#byteLength","streamStates","streamChunks","identitySorter","lf","#consumeRow","#takeLine","#appendLineFragment","CHECKPOINT_CHUNK_BYTE_LIMIT","row","parseCheckpointRowLine","shapeName","#startChunk","createCheckpointStreamValidationState","validateCheckpointStreamRow","flushed","tail","line","firstRowBytes","part","verifyRepositoryCheckpointArchive","verifyRepositoryCheckpointArchiveWithOptions","mkdtemp","tmpdir","chmod","failure","content","archive","chunkCount","assertExpected","mapVerificationError","checkpointSha256Schema","message"],"mappings":"yaAeO,IAAMA,CAAAA,CAAN,cAAoD,KAAM,CAG/D,WAAA,CAAqBC,EAAqD,CACxE,KAAA,CAAMC,EAAAA,CAAiBD,CAAM,CAAC,CAAA,CADX,YAAAA,EAErB,CAFqB,MAAA,CAFH,IAAA,CAAO,uCAK3B,EAmCA,SAASC,EAAAA,CACPD,CAAAA,CACQ,CACR,OAAQA,CAAAA,EACN,KAAK,gBACH,OAAO,gDAAA,CACT,KAAK,iBAAA,CACH,OAAO,0CAAA,CACT,KAAK,4BAAA,CACH,OAAO,wDAAA,CACT,KAAK,kBAAA,CACH,OAAO,4CACT,KAAK,eAAA,CACH,OAAO,wCAAA,CACT,KAAK,sBAAA,CACH,OAAO,6DAAA,CACT,KAAK,wBAAA,CACH,OAAO,uDACX,CACF,CCjEA,IAAME,CAAAA,CAAkB,SAClBC,EAAAA,CAAoB,QAAA,CACpBC,EAAAA,CAAuB,SAAA,CACvBC,EAAAA,CAAsB,SAAA,CACtBC,GAA0B,SAAA,CAC1BC,EAAAA,CAAwB,SAAA,CACxBC,CAAAA,CAAY,IAAA,CACZC,CAAAA,CAAqB,CAAA,CACrBC,CAAAA,CAAiB,EAAA,CACjBC,CAAAA,CAA2B,GAAA,CAC3BC,CAAAA,CAAoB,KAAA,CACpBC,CAAAA,CAAoB,WACpBC,CAAAA,CAAiB,EAAA,CACjBC,EAAAA,CAAoB,KAAA,CACpBC,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AAA,CAAsC,sBAAsB,CAAA,CAEzE,IAAMkP,CAAAA,CAAUxL,CAAAA,YAAiB,KAAA,CAAQA,CAAAA,CAAM,OAAA,CAAU,EAAA,CACzD,OAAIwL,CAAAA,CAAQ,QAAA,CAAS,UAAU,CAAA,CACtB,IAAIlP,CAAAA,CAAsC,kBAAkB,CAAA,CAGnEkP,CAAAA,CAAQ,QAAA,CAAS,OAAO,CAAA,EACxBA,CAAAA,CAAQ,QAAA,CAAS,KAAK,CAAA,EACtBA,CAAAA,CAAQ,QAAA,CAAS,cAAc,CAAA,CAExB,IAAIlP,CAAAA,CAAsC,eAAe,CAAA,CAE3D,IAAIA,CAAAA,CAAsC,iBAAiB,CACpE","file":"checkpoint.js"}
1
+ {"version":3,"sources":["../src/repository-checkpoint/types.ts","../src/repository-checkpoint/archive-reader.ts","../src/repository-checkpoint/identity-sort.ts","../src/repository-checkpoint/content-verifier.ts","../src/repository-checkpoint/verify.ts"],"names":["RepositoryCheckpointVerificationError","reason","messageForReason","LOCAL_SIGNATURE","CENTRAL_SIGNATURE","DESCRIPTOR_SIGNATURE","ZIP64_END_SIGNATURE","ZIP64_LOCATOR_SIGNATURE","CLASSIC_END_SIGNATURE","ZIP_FLAGS","ZIP_METHOD_DEFLATE","ZIP_VERSION_45","ZIP_VERSION_MADE_BY_UNIX","ZIP64_SENTINEL_16","ZIP64_SENTINEL_32","DOS_EPOCH_DATE","REGULAR_FILE_0644","INFLATE_INPUT_BYTES","CHUNK_PATH","CHECKPOINT_PART_DIGITS","utf8Decoder","CheckpointSourceReadError","readCheckpointZip64Archive","source","openEntry","reader","StreamingByteReader","entries","names","manifestSeen","localOffset","header","assertLocalHeader","nameLength","extraLength","name","decodeEntryName","assertEntryName","CHECKPOINT_MANIFEST_NAME","assertLocalExtra","sink","inflated","inflateEntry","descriptor","assertDescriptor","readCentralDirectory","entry","inflater","createInflateRaw","compressedSize","uncompressedSize","crc","output","Writable","bytes","_encoding","done","crc32","error","completed","pipeline","failed","input","before","writeInflateInput","consumed","written","resolve","reject","centralOffset","expected","assertCentralHeader","assertCentralExtra","centralSize","zip64Offset","end","requireU32","locator","classic","extra","offset","value","#iterator","#hash","createHash","#queue","#queueOffset","#sourceDone","#loadedBytes","toAsyncIterable","length","result","chunk","limit","#load","head","available","current","CHECKPOINT_IDENTITY_SORT_BUDGET_BYTES","CHECKPOINT_IDENTITY_MERGE_FAN_IN","RUN_BUFFER_BYTES","RUN_READ_BUFFER_BYTES","IDENTITY_LENGTH_BYTES","OFFSET_BYTES","MINIMUM_IDENTITY_BYTES","MINIMUM_RECORD_BYTES","MINIMUM_RESIDENT_BYTES","DuplicateCheckpointDurableIdError","CheckpointIdentitySorter","#scratchPath","#resident","#runs","#nextRun","#mergeFanIn","scratchPath","options","sortBudgetBytes","ResidentDurableIds","durableId","byteLength","#flushRun","nextRuns","group","#runPath","writeMergedRun","path","rm","previous","mergeRuns","compareUtf8Bytes","nextDurableId","nextByteLength","writeResidentRun","join","#records","#offsets","#recordBytes","#count","byteBudget","offsetCapacity","offsets","left","right","#compareAt","index","consume","each","#recordAt","leftOffset","rightOffset","#valueAt","resident","writeRun","writer","BufferedRunWriter","record","inputs","outputPath","produce","open","createWriteStream","once","#output","#buffer","#length","#flushThenWrite","#flushThenBuffer","recordLength","#flushThenWriteValue","#flushThenBufferValue","#writeValue","#flush","writeChunk","batch","paths","cursors","RunCursor","cursor","selected","#stream","#chunk","#offset","createReadStream","#readExactly","copied","next","values","sharedLength","difference","CheckpointContentVerifier","#identitySorter","#streamStates","#streamChunks","#observedChunks","#manifestBytes","chunks","CheckpointChunkSink","manifest","parseCheckpointManifest","declared","stream","observed","state","finishCheckpointStreamValidation","#path","#completed","#lineFragments","#lineFragmentBytes","#shapeName","#recordCount","#byteLength","streamStates","streamChunks","identitySorter","lf","#consumeRow","#takeLine","#appendLineFragment","CHECKPOINT_CHUNK_BYTE_LIMIT","row","parseCheckpointRowLine","shapeName","#startChunk","createCheckpointStreamValidationState","validateCheckpointStreamRow","flushed","tail","line","firstRowBytes","part","verifyRepositoryCheckpointArchive","verifyRepositoryCheckpointArchiveWithOptions","mkdtemp","tmpdir","chmod","failure","content","archive","chunkCount","assertExpected","mapVerificationError","checkpointSha256Schema","message"],"mappings":"yaAeO,IAAMA,CAAAA,CAAN,cAAoD,KAAM,CAG/D,WAAA,CAAqBC,EAAqD,CACxE,KAAA,CAAMC,EAAAA,CAAiBD,CAAM,CAAC,CAAA,CADX,YAAAA,EAErB,CAFqB,MAAA,CAFH,IAAA,CAAO,uCAK3B,EAmCA,SAASC,EAAAA,CACPD,CAAAA,CACQ,CACR,OAAQA,CAAAA,EACN,KAAK,gBACH,OAAO,gDAAA,CACT,KAAK,iBAAA,CACH,OAAO,0CAAA,CACT,KAAK,4BAAA,CACH,OAAO,wDAAA,CACT,KAAK,kBAAA,CACH,OAAO,4CACT,KAAK,eAAA,CACH,OAAO,wCAAA,CACT,KAAK,sBAAA,CACH,OAAO,6DAAA,CACT,KAAK,wBAAA,CACH,OAAO,uDACX,CACF,CCjEA,IAAME,CAAAA,CAAkB,SAClBC,EAAAA,CAAoB,QAAA,CACpBC,EAAAA,CAAuB,SAAA,CACvBC,EAAAA,CAAsB,SAAA,CACtBC,GAA0B,SAAA,CAC1BC,EAAAA,CAAwB,SAAA,CACxBC,CAAAA,CAAY,IAAA,CACZC,CAAAA,CAAqB,CAAA,CACrBC,CAAAA,CAAiB,EAAA,CACjBC,CAAAA,CAA2B,GAAA,CAC3BC,CAAAA,CAAoB,KAAA,CACpBC,CAAAA,CAAoB,WACpBC,CAAAA,CAAiB,EAAA,CACjBC,EAAAA,CAAoB,KAAA,CACpBC,CAAAA,CAAsB,EAAA,CAAK,KAC3BC,EAAAA,CAAa,IAAI,MAAA,CACrB,CAAA,+BAAA,EAAkCC,GAAsB,CAAA,UAAA,CAC1D,EACMC,EAAAA,CAAc,IAAI,WAAA,CAAY,OAAA,CAAS,CAAE,KAAA,CAAO,IAAK,CAAC,CAAA,CAE/CC,CAAAA,CA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EkP,CAAAA,CAAQ,QAAA,CAAS,OAAO,CAAA,EACxBA,CAAAA,CAAQ,QAAA,CAAS,KAAK,CAAA,EACtBA,CAAAA,CAAQ,QAAA,CAAS,cAAc,CAAA,CAExB,IAAIlP,CAAAA,CAAsC,eAAe,CAAA,CAE3D,IAAIA,CAAAA,CAAsC,iBAAiB,CACpE","file":"checkpoint.js"}
@@ -0,0 +1,8 @@
1
+ import {C,m,p,n,o,q as q$1,M as M$1,B,t,u,b,f,e,i,a as a$1,d as d$1,l,A,x as x$1,O,N as N$1,j,c,k as k$1,g,h}from'./chunk-YWDIWGQP.js';import {TRPCClientError,createTRPCProxyClient,splitLink,httpBatchLink,httpLink}from'@trpc/client';import {observable}from'@trpc/server/observable';function ze(n,e){return {create:async(t,r,i)=>{try{return await n().grant.create.mutate({orgName:t,repoName:r,...i})}catch(o){throw e(o)}},get:async(t,r,i)=>{try{return await n().grant.get.query({orgName:t,repoName:r,grantId:i})}catch(o){throw e(o)}},list:async(t,r,i)=>{try{return await n().grant.list.query({orgName:t,repoName:r,limit:i?.limit,cursor:i?.cursor})}catch(o){throw e(o)}},revoke:async(t,r,i,o)=>{try{return await n().grant.revoke.mutate({orgName:t,repoName:r,grantId:i,reason:o?.reason})}catch(s){throw e(s)}}}}function te(n){return {...n,createdAt:new Date(n.createdAt),updatedAt:new Date(n.updatedAt),runStartedAt:new Date(n.runStartedAt),...n.state==="complete"||n.state==="failed"?{completedAt:new Date(n.completedAt)}:{}}}function _t(n){return {...n,expiresAt:new Date(n.expiresAt)}}function je(n){if(typeof n.checkpointId=="string"&&typeof n.repoSeq!="number")return {by:"id",checkpointId:n.checkpointId};if(typeof n.repoSeq=="number"&&typeof n.checkpointId!="string")return {by:"repoSeq",repoSeq:n.repoSeq};throw new TypeError("Repository checkpoint selector must contain exactly one of checkpointId or repoSeq")}function Ye(n,e){return {generate:async(t,r,i)=>{try{let o=await n().repo.checkpoint.generate.mutate({orgName:t,repoName:r,atLeastRepoSeq:i?.atLeastRepoSeq});return te(o.checkpoint)}catch(o){throw e(o)}},status:async(t,r,i)=>{try{let o=await n().repo.checkpoint.status.query({orgName:t,repoName:r,selector:je(i)});return te(o)}catch(o){throw e(o)}},latest:async(t,r)=>{try{let i=await n().repo.checkpoint.latest.query({orgName:t,repoName:r});return i.checkpoint?te(i.checkpoint):null}catch(i){throw e(i)}},getAccess:async(t,r,i)=>{try{let o=await n().repo.checkpoint.access.query({orgName:t,repoName:r,selector:i.checkpoint==="latest"?{by:"latest"}:je(i.checkpoint),artifact:i.artifact==="archive"||i.artifact==="manifest"?{kind:i.artifact}:{kind:"chunk",path:i.artifact.chunkPath}});return _t(o)}catch(o){throw e(o)}},retry:async(t,r,i)=>{try{let o=await n().repo.checkpoint.retry.mutate({orgName:t,repoName:r,checkpointId:i});return te(o.checkpoint)}catch(o){throw e(o)}}}}function V(n,e,t){let r=O(e,t==="revise"?{allowUnsafeFieldNamePaths:N$1(e)}:void 0);return r.valid?null:`Invalid shape definition for "${n}": ${r.errors.join("; ")}`}var Pt="003e7e6c-2f1e-53ea-9dfa-627edd04a8cc",Lt=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;function Qe(n){if(!Lt.test(n))throw new Error("Operation-event submission ID must be a canonical UUID");let e=n.toLowerCase().replaceAll("-","");return Uint8Array.from({length:16},(t,r)=>Number.parseInt(e.slice(r*2,r*2+2),16))}function we(n,e){return (n<<e|n>>>32-e)>>>0}function Dt(n){let e=n.length*8,t=Math.ceil((n.length+9)/64)*64,r=new Uint8Array(t);r.set(n),r[n.length]=128;let i=new DataView(r.buffer);i.setUint32(t-8,Math.floor(e/4294967296)),i.setUint32(t-4,e>>>0);let o=1732584193,s=4023233417,p=2562383102,c=271733878,u=3285377520,l=new Uint32Array(80);for(let h=0;h<t;h+=64){for(let y=0;y<16;y+=1)l[y]=i.getUint32(h+y*4);for(let y=16;y<80;y+=1)l[y]=we(l[y-3]^l[y-8]^l[y-14]^l[y-16],1);let C=o,g=s,R=p,b=c,A=u;for(let y=0;y<80;y+=1){let O,v;y<20?(O=g&R|~g&b,v=1518500249):y<40?(O=g^R^b,v=1859775393):y<60?(O=g&R|g&b|R&b,v=2400959708):(O=g^R^b,v=3395469782);let T=we(C,5)+O+A+v+l[y]>>>0;A=b,b=R,R=we(g,30),g=C,C=T;}o=o+C>>>0,s=s+g>>>0,p=p+R>>>0,c=c+b>>>0,u=u+A>>>0;}let m=new Uint8Array(20),f=new DataView(m.buffer);for(let[h,C]of [o,s,p,c,u].entries())f.setUint32(h*4,C);return m}function Mt(n){let e=Array.from(n,t=>t.toString(16).padStart(2,"0")).join("").slice(0,32);return `${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}function re(){let n=globalThis.crypto?.randomUUID?.();if(!n)throw new Error("This runtime cannot mint a cryptographically secure UUID");return n.toLowerCase()}var qt=re;function Se(n,e){if(!Number.isInteger(e)||e<0||e>2147483647)throw new Error("Stream chunk ordinal must be an integer from 0 through 2147483647");Qe(n);let t=n.toLowerCase(),r=Qe(Pt),i=new TextEncoder().encode(`${t}:${e}`),o=Dt(Uint8Array.from([...r,...i])).slice(0,16);return o[6]=o[6]&15|80,o[8]=o[8]&63|128,Mt(o)}var Bt=new Set(["arc","bond","pair","set","list"]);function H(n,e){let t=Je(n,e,"add");return {operation:"add",kind:"collection",name:t.name,type:t.type,members:t.members,...n.skipExisting===true?{skipExisting:true}:{}}}function ne(n,e){let t=Je(n,e,"revise");if(!t.name)throw new Error(`${e}: collection revise requires a target name`);return {operation:"revise",kind:"collection",name:t.name,type:t.type,members:t.members,...typeof n.expectedVersion=="number"?{expectedVersion:n.expectedVersion}:{},...typeof n.leaseId=="string"&&n.leaseId.length>0?{leaseId:n.leaseId}:{}}}function Je(n,e,t){let r=B({operation:t,kind:"collection",name:typeof n.name=="string"?n.name:void 0,type:typeof n.type=="string"?n.type:void 0,members:Array.isArray(n.members)?n.members:void 0},0);if(r.length>0)throw new Error(`${e}: ${r.map(s=>s.message).join("; ")}`);let i=Vt(n.type);if(!i)throw new Error(`${e}: collection ${t} requires 'type'. Use one of: arc, bond, set, list`);if(!Array.isArray(n.members))throw new Error(`${e}: collection ${t} requires a 'members' array`);let o=Ht(n.name);if(!o)throw new Error(`${e}: collection ${t} name must be a non-empty string`);return Ut(n,e,t),{name:o,type:i,members:n.members}}function Ut(n,e,t){let r=["about","aboutWref","shapeWref","data",...t==="revise"?["skipExisting"]:[]].filter(i=>n[i]!==void 0);if(r.length>0)throw new Error(`${e}: collection ${t} does not support ${r.map(i=>`'${i}'`).join(", ")}`)}function Vt(n){if(typeof n!="string")return;let e=n.trim();if(Bt.has(e))return e}function Ht(n){if(typeof n=="string"&&!(n.length===0||n.trim()!==n))return n}function F(n){if(n.expectedVersion!==void 0&&n.operation!=="revise"&&n.operation!=="retract"&&n.operation!=="reaffirm")throw new Error("expectedVersion is only valid on revise, retract, or reaffirm operations \u2014 set an explicit operation discriminator");if(n.operation==="retract")return {operation:"retract",name:n.name,...n.kind?{kind:n.kind}:{},...n.reason?{reason:n.reason}:{},...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.leaseId?{leaseId:n.leaseId}:{}};if(n.operation==="reaffirm")return {operation:"reaffirm",name:n.name,...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.kind?{kind:n.kind}:{},...n.add?{add:n.add}:{},...n.remove?{remove:n.remove}:{},...n.leaseId?{leaseId:n.leaseId}:{}};if(n.operation==="rename")return {operation:"rename",name:n.name,newName:n.newName,...n.kind?{kind:n.kind}:{}};if(n.operation==="revise"){let r=n.name??n.wref;if(!r)throw new Error("revise operation requires a target");let i=l({kind:n.kind,name:r});if(Object.hasOwn(n,"active"))throw new Error(`${i} revise operation no longer supports 'active' \u2014 use retract('${r}') instead`);if(i!=="assertion"&&n.affirmedTargets!==void 0)throw new Error(`${i} revise operation does not support 'affirmedTargets' \u2014 it applies only to assertions; set kind: 'assertion' explicitly`);if(i==="collection")return ne(n,"commit.apply");if(n.data===void 0)throw new Error(`${i} revise operation requires 'data'`);return i==="assertion"?{operation:"revise",kind:"assertion",name:r,data:n.data,...n.affirmedTargets?{affirmedTargets:n.affirmedTargets}:{},...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.leaseId?{leaseId:n.leaseId}:{}}:{operation:"revise",kind:i,name:r,data:n.data,...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.leaseId?{leaseId:n.leaseId}:{}}}let e=l(n),t="skipExisting"in n?n.skipExisting:void 0;if(e!=="collection"&&("type"in n&&n.type!==void 0||"members"in n&&n.members!==void 0))throw new Error(`add operation '${n.name??""}' has collection fields but resolved kind '${e}' \u2014 collection adds require both 'type' and 'members', or set kind: 'collection'`);if(e!=="assertion"&&n.affirmedTargets!==void 0)throw new Error(`${e} add operation does not support 'affirmedTargets' \u2014 it applies only to assertions; set kind: 'assertion' explicitly`);if(e==="collection")return H({...n,skipExisting:t},"commit.apply");if(!n.name)throw new Error("add operation requires a name");if(e==="assertion"){if(!("about"in n)||n.about===void 0)throw new Error("assertion add operation requires 'about'");if(typeof n.about!="string")throw new Error(A);if(n.data===void 0)throw new Error("assertion add operation requires 'data'");return {operation:"add",kind:"assertion",name:n.name,about:n.about,data:n.data,...n.affirmedTargets?{affirmedTargets:n.affirmedTargets}:{},...t===true?{skipExisting:t}:{}}}if(n.data===void 0)throw new Error(`${e} add operation requires 'data'`);return {operation:"add",kind:e,name:n.name,data:n.data,...t===true?{skipExisting:t}:{}}}var ie=1e3,oe=1e4,k=class extends Error{code="PARTIAL_STREAM_SUBMISSION";completedReceipts;completedOperations;submissionId;eventRequestId;chunkOrdinal;pendingOutcome;acknowledgedOperationCount;lastAcknowledgedRepoSeq;attemptedAppendOutcome;cause;constructor(e){super(e.pendingOutcome==="unknown"?`Stream submission outcome is unknown for event request ${e.eventRequestId}. Look up its immutable receipt before retrying.`:`Stream submission stopped at event request ${e.eventRequestId} after earlier chunks committed.`),this.name="WarmHubError",this.cause=e.cause,this.completedReceipts=e.completedReceipts,this.completedOperations=e.completedOperations??[],this.submissionId=e.submissionId,this.eventRequestId=e.eventRequestId,this.chunkOrdinal=e.chunkOrdinal,this.pendingOutcome=e.pendingOutcome,this.acknowledgedOperationCount=e.acknowledgedOperationCount??e.completedReceipts.length,this.attemptedAppendOutcome=e.attemptedAppendOutcome,e.lastAcknowledgedRepoSeq!==void 0&&(this.lastAcknowledgedRepoSeq=e.lastAcknowledgedRepoSeq);}},x=class extends Error{code="STREAM_ALL_OPERATIONS_FAILED";receipts;result;operations;statusCounts;cause;constructor(e){let t=e.operations.find(r=>r.error!==void 0)?.error;super(t?`All ${e.operationCount} stream operations failed: ${t.message}`:`All ${e.operationCount} stream operations failed.`),this.name="WarmHubError",this.cause=t,this.result=e,this.receipts=e.receipts,this.operations=e.operations,this.statusCounts=e.statusCounts??{applied:0,noop:0,error:e.operationCount};}};function W(n){let e="status"in n?n.status:void 0;return e==="failed"?"error":e==="noop"||n.operation==="noop"?"noop":"applied"}function se(n){let e={applied:0,noop:0,error:0};for(let t of n)e[W(t)]++;return e}var Ft={maxAttempts:3,baseDelayMs:250,maxDelayMs:8e3},Wt=10,Xe=6e4;function Oe(n){if(n===false)return false;let e={};n!==void 0&&(Number.isFinite(n.maxAttempts)&&(e.maxAttempts=n.maxAttempts),Number.isFinite(n.baseDelayMs)&&(e.baseDelayMs=n.baseDelayMs),Number.isFinite(n.maxDelayMs)&&(e.maxDelayMs=n.maxDelayMs));let t={...Ft,...e};return {maxAttempts:Math.min(Wt,Math.max(1,Math.trunc(t.maxAttempts))),baseDelayMs:Math.min(Xe,Math.max(0,Math.trunc(t.baseDelayMs))),maxDelayMs:Math.min(Xe,Math.max(0,Math.trunc(t.maxDelayMs)))}}var Gt=new Set(["BAD_REQUEST","METHOD_NOT_SUPPORTED","PARSE_ERROR","PAYLOAD_TOO_LARGE","PRECONDITION_FAILED","UNAUTHORIZED","UNPROCESSABLE_CONTENT","UNSUPPORTED_MEDIA_TYPE","UNAUTHENTICATED","FORBIDDEN","VALIDATION_ERROR","SHAPE_MISMATCH","RESERVED_NAME","ILLEGAL_OP_SEQUENCE","NOT_FOUND","KIND_MISMATCH","CONFLICT","ALREADY_RETRACTED","ARCHIVED","RATE_LIMITED","TOO_MANY_REQUESTS","UNRESOLVED_TOKEN"]),$t=new Set(["COMMIT_OUTCOME_UNKNOWN"]);function et(n){if(!n||typeof n!="object")return;let e=n.code;if(typeof e=="string")return e;let t=n.data,r=t?.warmhub?.code;if(typeof r=="string")return r;let i=t?.code;if(typeof i=="string")return i}function Kt(n){if(!n||typeof n!="object")return;let e=n.data?.httpStatus;if(typeof e=="number")return e;let t=n.data?.warmhub?.status;if(typeof t=="number")return t;let r=n.status;return typeof r=="number"?r:void 0}function zt(n){return n!==void 0&&n>=400&&n<500&&n!==408}function tt(n){let e=et(n);return e!==void 0&&$t.has(e)}function G(n){if(tt(n))return false;let e=et(n);return e!==void 0&&Gt.has(e)||zt(Kt(n))}function Ie(n){if(tt(n)||G(n))return false;if(Ze(n))return true;if(n instanceof TypeError||n instanceof SyntaxError)return false;let e=n?.cause;return Ze(e)?true:!(e instanceof TypeError||e instanceof SyntaxError)}function Ze(n){return n instanceof TypeError&&/fetch/i.test(n.message)}function Ae(n,e){let t=e.baseDelayMs*2**Math.max(0,n-1),r=Math.random()*e.baseDelayMs;return Math.min(e.maxDelayMs,t+r)}function ve(n){return new Promise(e=>setTimeout(e,n))}var $=class extends Error{code;status=400;constructor(e,t="VALIDATION_ERROR"){super(e),this.code=t,this.name="WarmHubError";}};async function L(n,e){if(e.operations.length===0)throw new $("At least one operation is required for stream submission.");let t=e.operations.map((g,R)=>{let b;try{b=F(g);}catch(A){let y=A instanceof Error?A.message:String(A);throw new $(`Invalid operation at index ${R}: ${y}`)}return e.skipExisting===true&&b.operation==="add"?{...b,skipExisting:true}:b});Yt(t);let r=Jt(e.chunkSize),i=e.submissionId??re(),o=e.streamId??i,s=Oe(e.retry),p=[],c,u,l=[],m=[],f=0,h;for(let[g,R]of Xt(t,r).entries()){let b=Se(i,g),A=1,y=false;for(;;)try{let O=await n.stream.append({allocatedTokenRanges:p,chunkOrdinal:g,orgName:e.orgName,repoName:e.repoName,streamId:o,submissionId:i,componentRef:e.componentRef,committer:e.committer,message:e.message,...e.returnRepoSeq!==void 0?{returnRepoSeq:e.returnRepoSeq}:{},operations:R.operations}),v=O.receipt;m.push(v),p=O.allocatedTokenRanges,c=O.createdByEmail??c,u=O.repoSeq??u,l.push(...ke(O.results,R.start)),f+=R.operations.length;let T=jt(v);T!==void 0&&(h=T);break}catch(O){let v=G(O);if(m.length===0&&!y&&v)throw O;if(s!==false&&A<s.maxAttempts&&Ie(O)){await ve(Ae(A,s)),A+=1,y=true;continue}let T=y||!v?"unknown":"absent";throw new k({cause:O,completedReceipts:m,completedOperations:Ee(ae({committer:e.committer,createdByEmail:c,message:e.message,operations:t,repoSeq:u,receipts:m,results:l})),acknowledgedOperationCount:f,lastAcknowledgedRepoSeq:h,attemptedAppendOutcome:T==="absent"?"not_applied":"unknown",submissionId:i,eventRequestId:b,chunkOrdinal:g,pendingOutcome:T})}}let C=ae({committer:e.committer,createdByEmail:c,message:e.message,operations:t,repoSeq:u,receipts:m,results:l});if(C.operations.length>0&&C.operations.every(g=>g.status==="error"))throw new x(C);return C}function jt(n){let e=n.event?.repoSeq;if(e===void 0)return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}function Yt(n){let t=C(n).filter(r=>!Qt(r))[0];if(t)throw new $(`Invalid operation at index ${t.operationIndex}: ${t.message}`,t.code)}function Qt(n){return n.code==="ILLEGAL_OP_SEQUENCE"&&n.message.includes("Cannot revise then add ")}function Jt(n){return Number.isFinite(n)?Math.max(1,Math.min(oe,Math.trunc(n))):ie}function Xt(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push({operations:n.slice(r,r+e),start:r});return t}function ke(n,e){return n.map((t,r)=>({...t,opIndex:e+(t.opIndex??r)}))}function ae(n){let e=se(n.results),t=e.error>0;return {...n.committer!==void 0?{committer:n.committer}:{},...n.createdByEmail!==void 0?{createdByEmail:n.createdByEmail}:{},message:n.message,operationCount:n.results.length,...n.repoSeq!==void 0?{repoSeq:n.repoSeq}:{},...t?{partial:t,statusCounts:e}:{},operations:n.results.map(r=>({...r.opIndex!==void 0?{opIndex:r.opIndex}:{},name:r.name??"",operation:r.operation==="revise"||r.operation==="retract"||r.operation==="reaffirm"||r.operation==="rename"||r.operation==="noop"?r.operation:"add",dataHash:r.dataHash??"",version:r.version??0,status:W(r),error:r.error,...r.affirmations?{affirmations:r.affirmations}:{},...r.status==="failed"&&r.opIndex!==void 0&&n.operations[r.opIndex]?.name!==void 0?{submittedName:n.operations[r.opIndex]?.name}:{},...r.resolvedName!==void 0?{resolvedName:r.resolvedName}:{},...r.retryable!==void 0?{retryable:r.retryable}:{},...r.warnings?{warnings:r.warnings}:{}})),receipts:n.receipts}}function Ee(n){return n.operations.filter(e=>e.status!=="error")}var Zt="0.0.0-development";function D(n){return n===Zt}var xe="0.88.0";var rt=1;function er(n){return n===g?"Run: wh update --yes":n===f?"Run: npm install @warmhub/sdk-ts@latest (or your package manager's equivalent).":n===h?"Run: pip install --upgrade warmhub":`Deploy a released ${n} build that satisfies the backend compatibility contract.`}function nt(n,e){if(typeof n?.minSupportedClients!="object"||n.minSupportedClients===null||!Number.isSafeInteger(n.writeContractVersion)||n.writeContractVersion<1)return {message:"The backend does not advertise valid per-client write compatibility data.",hint:"Upgrade the WarmHub backend before retrying this write."};let t$1=n.minSupportedClients[e.name],r=typeof t$1=="string"?t(t$1):null;if(!r)return {message:`The backend does not advertise a valid compatibility floor for ${e.name}.`,hint:"Upgrade the WarmHub backend or register this first-party client family before writing."};if(!D(e.version)){let i=t(e.version);if(!i)return {message:`${e.name} reported malformed version "${e.version}".`,hint:"Use a released WarmHub client with a SemVer package version."};if(u(i,r)<0)return {message:`${e.name} ${e.version} is older than the backend's minimum supported version ${r}.`,hint:er(e.name)}}if(n.writeContractVersion<rt)return {message:`${e.name} requires write contract ${rt}, but the backend provides ${n.writeContractVersion}.`,hint:"Upgrade the WarmHub backend before retrying this write."}}function Te(n,e){try{return new URL(n).origin===new URL(e).origin}catch{return false}}var tr=new Set(["GET","POST","PUT","PATCH","DELETE"]),I=class extends Error{reason;constructor(e,t){super(t),this.name="CliCallVerificationError",this.reason=e;}};async function rr(n$1,e,t){let r=n$1.method.toUpperCase();if(!tr.has(r))throw new I("unsupported-method",`Unsupported HTTP method "${n$1.method}" \u2014 component CLI dispatch only emits GET, POST, PUT, or PATCH`);let i=r,o$1=n$1.headers.get(m);if(!o$1)throw new I("missing-install-repo",`Missing ${m} header`);let s=M(e.CLI_SIGNING_SECRET),p$1=M(e.CLI_BEARER_TOKEN),c=M(e.CLI_API_KEY),u=M(e.CLI_BASIC_USERNAME)&&M(e.CLI_BASIC_PASSWORD);if(!s&&!p$1&&!c&&!u)throw new I("no-scheme-configured","no-scheme-configured: need at least one of CLI_SIGNING_SECRET, CLI_BEARER_TOKEN, CLI_API_KEY, or CLI_BASIC_USERNAME + CLI_BASIC_PASSWORD");if(p$1&&u)throw new I("no-scheme-configured","unsupported-scheme-combination: CLI_BEARER_TOKEN and CLI_BASIC_USERNAME + CLI_BASIC_PASSWORD both use the Authorization header and cannot be configured together");let l=new URL(n$1.url),m$1=l.pathname,f,h,C;if(p(i)?f={}:(f=Object.fromEntries(l.searchParams.entries()),h="",C={...f}),s){let g=n$1.headers.get(n);if(!g)throw new I("missing-signature",`Missing ${n} header`);let R=n$1.headers.get(o);if(!R)throw new I("missing-timestamp",`Missing ${o} header`);let b=Number(R);if(!Number.isFinite(b)||!Number.isInteger(b))throw new I("invalid-timestamp",`${o} must be an integer unix seconds value; got "${R}"`);h=await it(n$1,i,h);let A=await q$1({secret:e.CLI_SIGNING_SECRET,method:i,path:m$1,query:f,installRepo:o$1,body:h,signature:g,timestamp:b,nowUnixSeconds:t?.nowUnixSeconds??Math.floor(Date.now()/1e3),toleranceSec:t?.toleranceSec});if(!A.ok)throw new I(A.reason,`HMAC verification failed: ${A.reason}`)}if(p$1){let g=`Bearer ${e.CLI_BEARER_TOKEN}`,R=n$1.headers.get("authorization")??"";if(!await Ne(R,g))throw new I("invalid-bearer","invalid-bearer: bearer token mismatch")}if(c){let g=M(e.CLI_API_KEY_HEADER)?e.CLI_API_KEY_HEADER:"X-API-Key",R=n$1.headers.get(g)??"";if(!await Ne(R,e.CLI_API_KEY))throw new I("invalid-api-key",`invalid-api-key: mismatch on header "${g}"`)}if(u){let g=`Basic ${btoa(`${e.CLI_BASIC_USERNAME}:${e.CLI_BASIC_PASSWORD}`)}`,R=n$1.headers.get("authorization")??"";if(!await Ne(R,g))throw new I("invalid-basic","invalid-basic: basic auth mismatch")}return C===void 0&&(h=await it(n$1,i,h),C=nr(h)),{method:i,installRepo:o$1,args:C}}async function it(n,e,t){return p(e)?t!==void 0?t:n.text():""}function nr(n){let e;try{e=JSON.parse(n);}catch{throw new I("invalid-body","POST body is not valid JSON")}if(!ir(e))throw new I("invalid-body","POST body must be a JSON object of primitive args (string / number / boolean)");return e}function M(n){return typeof n=="string"&&n.length>0}function ir(n){if(typeof n!="object"||n===null||Array.isArray(n))return false;for(let e of Object.values(n))if(e!==void 0&&typeof e!="string"&&typeof e!="number"&&typeof e!="boolean")return false;return true}async function Ne(n,e){let[t,r]=await Promise.all([ot(n),ot(e)]),i=0;for(let o=0;o<t.length;o++)i|=t[o]^r[o];return i===0}async function ot(n){return new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n)))}function Pe(n){if(n.includes("/"))return n.split("/")[0]}function at(n){if("shapeWref"in n&&typeof n.shapeWref=="string")return n.shapeWref;if(n.name)return Pe(n.name)}function _e(n){if(typeof n!="string")return;let e=n.trim();return e.length>0?e:void 0}function q(n){return l({kind:n.kind,name:n.name,about:ue(n),type:ce(n),members:pe(n)})}function ue(n){if("about"in n&&n.about!==void 0)return n.about;if("aboutWref"in n)return n.aboutWref}function Le(n){return "data"in n?n.data:void 0}function ce(n){return "type"in n?n.type:void 0}function pe(n){return "members"in n?n.members:void 0}function K(n,e){return l({kind:n.kind,name:e})}function st(n){return n.data??{}}function ct(n){if(n.operation==="retract")return F(n);if(n.operation==="reaffirm")return F({operation:"reaffirm",name:n.name,...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.kind?{kind:n.kind}:{},...n.add?{add:[...n.add]}:{},...n.remove?{remove:[...n.remove]}:{},...n.leaseId?{leaseId:n.leaseId}:{}});if(n.operation==="add"){let r=q(n);if(r==="collection")return H(n,"OperationBuilder");let i=n,o=st(i),s=_e(i.name);if(!s)throw new Error("OperationBuilder: add operation missing name");if(r==="assertion"){let p=ue(i);if(p===void 0)throw new Error(`OperationBuilder: assertion add '${s}' missing required 'about'`);if(typeof p!="string")throw new Error(A);return {operation:"add",kind:r,name:s,about:p,data:o,...i.affirmedTargets?{affirmedTargets:[...i.affirmedTargets]}:{},...i.skipExisting===true?{skipExisting:true}:{}}}return {operation:"add",kind:r,name:s,data:o,...i.skipExisting===true?{skipExisting:true}:{}}}let e=_e(n.name)??_e(n.wref);if(!e)throw new Error("OperationBuilder: revise operation missing required target ('name' or 'wref')");let t=K(n,e);if(t==="collection")return ne({...n,name:e},"OperationBuilder");if(t==="assertion")return {operation:"revise",kind:t,name:e,data:n.data??{},...n.affirmedTargets?{affirmedTargets:[...n.affirmedTargets]}:{},...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.leaseId?{leaseId:n.leaseId}:{}};if(n.affirmedTargets!==void 0)throw new Error(`OperationBuilder: REVISE '${e}' has affirmedTargets but inferred kind '${t}' \u2014 affirmedTargets applies only to assertions; set kind: 'assertion'`);return {operation:"revise",kind:t,name:e,data:st(n),...n.expectedVersion!==void 0?{expectedVersion:n.expectedVersion}:{},...n.leaseId?{leaseId:n.leaseId}:{}}}function N(n,e){return n.operation==="add"?{operation:n.operation,kind:e,name:n.name,about:ue(n),type:ce(n),members:pe(n)}:{operation:n.operation,kind:e,name:n.name??n.wref,type:ce(n),members:pe(n)}}function pt(n){if(n.length!==0)throw new Error(n.join("; "))}function ut(n,e,t,r){let i=[];if((e==="thing"||e==="assertion"||e==="collection"&&n==="REVISE")&&(k$1(t)||i.push(`${n} ${e} name must be a local path (Shape/name), got: "${t}"`)),e==="shape"&&(n==="ADD"||n==="REVISE")&&r!==void 0){let s=V(t,r,n==="REVISE"?"revise":"add");s&&i.push(s);}return i}function lt(n,e){let t=[];if(n.name&&t.push(...ut("ADD",e,n.name,Le(n))),e==="assertion"&&ue(n)===void 0&&t.push(`ADD assertion '${n.name}' missing required 'about' \u2014 for hierarchical thing names set kind: 'thing' explicitly`),e!=="collection"&&(ce(n)!==void 0||pe(n)!==void 0)&&t.push(`ADD '${n.name}' has collection fields but inferred kind '${e}' \u2014 collection adds require both 'type' and 'members', or set kind: 'collection'`),e!=="assertion"&&"affirmedTargets"in n&&n.affirmedTargets!==void 0&&t.push(`ADD '${n.name}' has affirmedTargets but inferred kind '${e}' \u2014 affirmedTargets applies only to assertions; set kind: 'assertion'`),e==="collection")try{H(n,"OperationBuilder");}catch(r){t.push(r instanceof Error?r.message:String(r));}for(let r of B(N(n,e),0))t.push(r.message);pt(t);}function dt(n,e,t){let r=[];n!=="collection"&&t.data===void 0&&r.push(`OperationBuilder: ${n} revise requires 'data'`),n!=="assertion"&&t.affirmedTargets!==void 0&&r.push(`REVISE '${e}' has affirmedTargets but inferred kind '${n}' \u2014 affirmedTargets applies only to assertions; set kind: 'assertion'`),r.push(...ut("REVISE",n,e,t.data),...B(N({...t,name:e},n),0).map(i=>i.message)),pt(r);}var le=class{ops=[];pendingNames=new Set;shapes;wrefToShape=new Map;submitted=false;inFlight=false;constructor(e){this.shapes=e?.shapes;}add(e){this.assertCanModify();let t={...e};delete t.operation;let r=at(t),i=Le(t);if(this.shapes&&r&&i!==void 0){let c=this.shapes[r];if(c){let u=M$1(i,c);if(!u.valid)throw new Error(`Shape validation failed for '${t.name}' (shape: ${r}): ${u.errors.join("; ")}`)}}let o={operation:"add",...t},s=q(o);(o.name||s==="collection")&&lt(o,s);let p=Object.freeze({operation:"add",...t});return this.ops.push(p),t.name&&(this.pendingNames.add(t.name),r&&this.wrefToShape.set(t.name,r)),this}revise(e){this.assertCanModify();let t={...e};delete t.operation;let r=t.name??t.wref;if(this.shapes&&r&&t.data!==void 0){let o=this.wrefToShape.get(r)??Pe(r);if(o){let s=this.shapes[o];if(s){let p=M$1(t.data,s);if(!p.valid)throw new Error(`Shape validation failed for revise '${r}' (shape: ${o}): ${p.errors.join("; ")}`)}}}if(r){let o=K({...t},r);dt(o,r,{operation:"revise",...t});}let i=Object.freeze({operation:"revise",...t});return this.ops.push(i),this}retract(e){this.assertCanModify();let t=Object.freeze(typeof e=="string"?{operation:"retract",name:e}:{operation:"retract",name:e.name,...e.kind?{kind:e.kind}:{},...e.reason?{reason:e.reason}:{},...e.expectedVersion!==void 0?{expectedVersion:e.expectedVersion}:{},...e.leaseId?{leaseId:e.leaseId}:{}});return this.ops.push(t),this}reaffirm(e){this.assertCanModify();let t=Object.freeze({operation:"reaffirm",name:e.name,...e.expectedVersion!==void 0?{expectedVersion:e.expectedVersion}:{},...e.kind?{kind:e.kind}:{},...e.add?{add:Object.freeze([...e.add])}:{},...e.remove?{remove:Object.freeze([...e.remove])}:{},...e.leaseId?{leaseId:e.leaseId}:{}});return this.ops.push(t),this}get operations(){return Object.freeze([...this.ops])}get size(){return this.ops.length}has(e){return this.pendingNames.has(e)}validate(){let e=[],t=[],r=new Set,i=new Set;for(let c=0;c<this.ops.length;c+=1){let u=this.ops[c];if(u){if(u.operation==="add"){let l=q(u);!u.name&&l!=="collection"?e.push({code:"MISSING_NAME",operationIndex:c,message:`Add operation at index ${c} is missing required 'name' field`}):u.name&&(r.has(u.name)&&e.push({code:"DUPLICATE_NAME",operationIndex:c,message:`Duplicate name '${u.name}' at index ${c} (already added earlier in commit)`}),r.add(u.name));}if(u.operation==="revise"){let l=u.name??u.wref;l?i.has(l)?e.push({code:"REVISE_AFTER_RETRACT",operationIndex:c,message:`Revise at index ${c} targets '${l}' which was already retracted in this commit`}):r.has(l)||t.push({code:"REVISE_UNKNOWN_WREF",operationIndex:c,message:`Revise at index ${c} references '${l}' which was not added in this commit (assuming it exists server-side)`}):e.push({code:"MISSING_WREF",operationIndex:c,message:`Revise operation at index ${c} is missing required target ('name' or 'wref')`});}u.operation==="retract"&&(u.name?i.has(u.name)?t.push({code:"RETRACT_AFTER_RETRACT",operationIndex:c,message:`Retract at index ${c} targets '${u.name}' which was already retracted in this commit`}):(r.has(u.name)||t.push({code:"RETRACT_UNKNOWN_WREF",operationIndex:c,message:`Retract at index ${c} references '${u.name}' which was not added in this commit (assuming it exists server-side)`}),i.add(u.name)):e.push({code:"MISSING_NAME",operationIndex:c,message:`Retract operation at index ${c} is missing required 'name' field`}));}}let o=this.ops.flatMap((c,u)=>{if(c.operation==="add")return B(N(c,q(c)),u);if(c.operation==="revise"){let l=c.name??c.wref;return B(N(c,l?K(c,l):"thing"),u)}return B({operation:"retract",kind:c.kind,name:c.name},u)});for(let c of o)e.push({code:c.code,operationIndex:c.operationIndex,message:c.message});let s=this.ops.flatMap((c,u)=>{if(c.operation==="retract"||c.operation==="reaffirm")return [];if(c.operation==="add")return [{op:N(c,q(c)),operationIndex:u}];let l=c.name??c.wref;return [{op:N(c,l?K(c,l):"thing"),operationIndex:u}]}),p=C(s.map(({op:c})=>c),{checkAddAdd:false,sourceOperationIndexes:s.map(({operationIndex:c})=>c)});for(let c of p)e.push({code:c.code,operationIndex:c.operationIndex,message:c.message});return this.ops.length===0&&e.push({code:"EMPTY_COMMIT",operationIndex:-1,message:"OperationBuilder has no operations"}),{valid:e.length===0,errors:e,warnings:t}}async commit(e){if(this.assertNotSubmitted(),this.inFlight)throw new Error("OperationBuilder: stream submission already in flight");let t=this.validate();if(!t.valid){let r=t.errors.map(i=>i.message).join("; ");throw new Error(`OperationBuilder validation failed: ${r}`)}this.inFlight=true;try{let r=this.ops.map(o=>ct(o)),i=await L(e.client,{orgName:e.orgName,repoName:e.repoName,committer:e.committer,message:e.message,chunkSize:e.chunkSize,streamId:e.streamId,submissionId:e.submissionId,returnRepoSeq:e.returnRepoSeq,retry:e.retry,operations:r});return this.submitted=!0,i}catch(r){throw r instanceof k&&(this.submitted=true),r}finally{this.inFlight=false;}}assertNotSubmitted(){if(this.submitted)throw new Error("OperationBuilder: already submitted, cannot modify")}assertCanModify(){if(this.assertNotSubmitted(),this.inFlight)throw new Error("OperationBuilder: stream submission already in flight, cannot modify")}};function Vn(n){return n.replace(/@(?:v\d+|HEAD|ALL)$/i,"")}var vt=["apiUrl","fetch","accessToken","auth","functionLogs","client","clientFlags"],dr=new Set(vt),mr=new Set(["token","apiKey","bearer"]);function gr(n){if(n)for(let e of Object.keys(n)){if(dr.has(e))continue;let t=mr.has(e)?'; did you mean "accessToken"?':`. Valid options are: ${vt.join(", ")}.`;throw new TypeError(`Unknown WarmHubClient option "${e}"${t}`)}}function hr(n){if(!n||n.length===0)return [];for(let e of n)if(!c(e))throw new TypeError(`Invalid client flag "${e}": expected lowercase tokens matching [a-z0-9-]+.`);return [...new Set(n)].sort()}var De="https://api.warmhub.ai",yr=new Set(["repo.shapeInstanceCounts","thing.getMany","thing.headVersions"]),mt=500,gt=500,ht=1,yt=8;function ge(n){return {...n,actionContainer:void 0,actionContainerConfig:void 0}}function fr(n){return n.map(e=>ge(e))}function kt(n,e,t){if(e===n||t.has(e))throw new d("VALIDATION_ERROR","Paginated result cursor did not advance")}function ft(n){if(n===void 0)throw new d("VALIDATION_ERROR","sinceRepoSeq is required for an incremental read")}async function*Et(n,e){let t=e,r=new Set;for(;;){t&&r.add(t);let i=await n(t);if(yield i,!i.nextCursor)return;kt(t,i.nextCursor,r),t=i.nextCursor;}}async function*w(n,e,t){for await(let r of Et(n,t))yield*e(r);}async function S(n,e,t,r){if(t!==void 0&&(!Number.isFinite(t)||Math.trunc(t)!==t||t<0))throw new d("VALIDATION_ERROR","max must be a nonnegative integer");let i=[];for await(let o of Et(n,r)){let s=e(o);if(t!==void 0&&i.length+s.length>t)throw new d("VALIDATION_ERROR",`Paginated result exceeded max=${t}`);i.push(...s);}return i}function Rt(n){if(n?.slugs!==void 0)throw new d("VALIDATION_ERROR","repo.explore pagination helpers do not support slugs mode")}async function bt(n){let e=[],t,r=new Set;for(;;){t&&r.add(t);let i=await n(t);if(e.push(...i.items),!i.nextCursor){if(i.repoSeq===void 0)throw new d("VALIDATION_ERROR","Incremental read completed without repoSeq");return {items:e,repoSeq:i.repoSeq}}kt(t,i.nextCursor,r),t=i.nextCursor;}}function de(n,e,t){return Number.isFinite(n)?Math.max(1,Math.min(t,Math.trunc(n))):e}function Ct(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}function me(n){return n!==void 0&&j.includes(n)?n:void 0}function z(n){let[e,t,r]=n;return typeof e=="string"?{orgName:e,repoName:t,name:r}:e}function Rr(n){let[e,t]=n;return typeof e=="string"?{orgName:e,repoName:t}:e}function br(n){let[e,t,r,i]=n;return typeof e=="string"?{orgName:e,repoName:t,subscriptionName:r,credentialSetName:i}:e}function Cr(n){let[e,t,r]=n;return typeof e=="string"?{orgName:e,repoName:t,subscriptionName:r}:e}function wr(n){let{actionContainer:e,actionContainerConfig:t,...r}=n;return r}function Sr(n){let{actionContainer:e,actionContainerConfig:t,...r}=n;return r}function he(n){return !!n&&(!!n.shape||!!n.kind||!!n.about||!!n.match||!!n.componentRef||n.excludeComponents===true||(n.where?.length??0)>0)}function ye(n){return !!n&&(!!n.shape||!!n.about||!!n.match||!!n.componentRef||(n.where?.length??0)>0)}function xt(n){let e=n.members;return Array.isArray(e)&&e.length>0}function Or(n){let t=n.replace(/^wh:[^/]+\/[^/]+\//,"").replace(/@(?:HEAD|ALL|v\d+)$/,"").split("/")[0]?.toLowerCase();return t==="arc"||t==="bond"||t==="pair"||t==="set"||t==="list"?t:void 0}function Ir(n,e){if(he(e.query)&&!ye(e.query))throw new d("VALIDATION_ERROR","Selector-backed collection sources require shape, about, match, componentRef, or where; kind and excludeComponents only narrow an existing selector.");if(e.sourceRepo&&!ye(e.query))throw new d("VALIDATION_ERROR","sourceRepo requires a selector-backed collection query");if(e.sourceRepo&&xt(e))throw new d("VALIDATION_ERROR","sourceRepo cannot be combined with explicit members; use canonical wh:org/repo/... member wrefs or omit sourceRepo.");if(he(e.query)&&n!=="set")throw new d("VALIDATION_ERROR","Selector-backed collection sources are only supported for set collections")}function Hn(n){return n??"off"}function Ar(n){switch(n){case "BAD_REQUEST":case "PARSE_ERROR":case "PAYLOAD_TOO_LARGE":case "UNPROCESSABLE_CONTENT":case "UNSUPPORTED_MEDIA_TYPE":return "VALIDATION_ERROR";case "METHOD_NOT_SUPPORTED":return "NOT_FOUND";case "UNAUTHORIZED":return "UNAUTHENTICATED";case "FORBIDDEN":return "FORBIDDEN";case "NOT_FOUND":return "NOT_FOUND";case "CONFLICT":return "CONFLICT";case "PRECONDITION_FAILED":return "PRECONDITION_FAILED";case "TOO_MANY_REQUESTS":return "RATE_LIMITED";default:return}}function vr(n){if(n===void 0||n===408)return;if(n===405)return "NOT_FOUND";if(n===412)return "PRECONDITION_FAILED";if(n===422)return "VALIDATION_ERROR";let e=Nt(n);return e!=="BACKEND"?e:n>=400&&n<500?"VALIDATION_ERROR":e}var kr=[/\bselect\b.+?\bfrom\b/i,/\binsert\b.+?\binto\b/i,/\bupdate\b.+?\bset\b/i,/\bdelete\b.+?\bfrom\b/i,/\bparams:\s/i,/\.ts\(\d+,\d+\)/,/at\s+\S+\s+\(.*:\d+:\d+\)/,/node_modules\//,/drizzle/i];function Me(n){for(let e of kr)if(e.test(n))return "An internal error occurred. Please try again or contact support.";return n}var d=class extends Error{code;status;hint;retryAfter;errorCode;backendCode;details;constructor(e,t,r,i,o,s,p){super(t),this.name="WarmHubError",this.code=e,this.status=r,this.hint=i,this.retryAfter=o,this.errorCode=s,this.backendCode=s,this.details=p;}get kind(){return this.code}};function wt(n,e){if(typeof e!="string")return;let t=x$1(n,e);if(t)throw new d("VALIDATION_ERROR",t)}function a(n){if(n instanceof d)return n;if(n instanceof TRPCClientError){if(n.cause instanceof d)return n.cause;let e=n.data,t=e?.warmhub?.code,r=typeof e?.code=="string"?Ar(e.code):void 0,i=vr(e?.httpStatus),o=e?.warmhub?.message??Me(n.message);return new d(t??r??i??"BACKEND",o,e?.warmhub?.status??e?.httpStatus,e?.warmhub?.hint,e?.warmhub?.retryAfter??e?.retryAfter,t,e?.warmhub?.details)}if(n instanceof Error){let e=n;return n.name==="WarmHubError"&&typeof e.code=="string"?new d(e.code,Me(n.message),typeof e.status=="number"?e.status:void 0,typeof e.hint=="string"?e.hint:void 0,typeof e.retryAfter=="number"?e.retryAfter:void 0,typeof e.errorCode=="string"?e.errorCode:typeof e.backendCode=="string"?e.backendCode:void 0,e.details):n.name==="AbortError"?new d("CANCELLED",n.message):n instanceof TypeError&&/fetch/i.test(n.message)?new d("NETWORK",n.message):new d("BACKEND",Me(n.message))}return new d("BACKEND","Unknown SDK error")}function Er(n){return n instanceof d}function Fn(n){let e=a(n);return e.kind==="NETWORK"||e.kind==="CANCELLED"||e.kind==="BACKEND"||e.kind==="RATE_LIMITED"}var xr=new Set(["ConnectionRefused","ECONNREFUSED","ENOTFOUND","ETIMEDOUT","EAI_AGAIN"]);function Tr(n){if(n instanceof TypeError&&/fetch/i.test(n.message))return true;if(n&&typeof n=="object"){let e=n.code;if(typeof e=="string"&&xr.has(e))return true}return false}function Nr(n){return `Unable to connect to ${n}. Is the computer able to access the url?`}function Wn(n,e){if(D(n))return false;let t$1=t(n),r=t(e);return !t$1||!r?false:u(t$1,r)<0}function Tt(n,e){return new d("CLIENT_INCOMPATIBLE",n,412,e)}function _r(n,e){let t=nt(n,e);if(t)throw Tt(t.message,t.hint)}var St=class n{apiUrl;fetchImpl;accessToken;clientIdentity;clientFlags;functionLogMode;getToken;compatibilityCheck;overrideNoticePrinted=false;noteCompatibilityOverride(){this.overrideNoticePrinted||(this.overrideNoticePrinted=true,console.error(`warmhub: compatibility checks overridden by client flag ${b}; the server remains authoritative.`));}assertWriteCompatible(){return this.clientFlags.includes(b)?(this.noteCompatibilityOverride(),Promise.resolve()):D(this.clientIdentity.version)&&Te(this.apiUrl,De)?Promise.reject(Tt(`Development client ${this.clientIdentity.name}/${this.clientIdentity.version} cannot write to production.`,"Install a released WarmHub client artifact before writing to api.warmhub.ai.")):D(this.clientIdentity.version)&&!Te(this.apiUrl,De)?Promise.resolve():this.diagnostics.assertCompatible()}createCompatibilityLink(){return ()=>({op:e,next:t})=>e.type!=="mutation"?t(e):observable(r=>{let i=false,o;return this.assertWriteCompatible().then(()=>{i||(o=t(e).subscribe(r));}).catch(s=>{i||r.error(TRPCClientError.from(s));}),()=>{i=true,o?.unsubscribe();}})}auth={getClientId:async()=>{try{return await this.trpc.auth.getClientId.query()}catch(e){throw a(e)}},sync:async()=>{try{return await this.trpc.auth.sync.mutate()}catch(e){throw a(e)}},currentUser:async()=>{try{return await this.trpc.auth.currentUser.query()}catch(e){throw a(e)}},whoami:async()=>{try{return await this.trpc.auth.whoami.query()}catch(e){throw a(e)}}};homepage={featuredLists:async()=>{try{return await this.trpc.homepage.featuredLists.query()}catch(e){throw a(e)}}};access={resolve:async e=>{try{return await this.trpc.access.resolve.query(e)}catch(t){throw a(t)}}};diagnostics={ping:async()=>{let e=await this.fetchWithAuth(`${this.apiUrl.replace(/\/$/,"")}/health`);if(!e.ok)throw new d("BACKEND",`Health request failed with status ${e.status}`,e.status);return await e.json()},capabilities:async()=>{try{return await this.trpc.diagnostics.capabilities.query()}catch(e){throw a(e)}},assertCompatible:()=>{if(this.compatibilityCheck)return this.compatibilityCheck;let e=(async()=>{let t=await this.diagnostics.capabilities();_r(t,this.clientIdentity);})();return this.compatibilityCheck=e,e.catch(t=>{Er(t)&&t.code==="CLIENT_INCOMPATIBLE"||this.compatibilityCheck===e&&(this.compatibilityCheck=void 0);}),e}};component={list:async(e,t,r)=>{try{return await this.trpc.component.list.query({orgName:e,repoName:t,limit:r?.limit,cursor:r?.cursor})}catch(i){throw a(i)}},listIter:(e,t,r)=>w(i=>this.component.list(e,t,{...r,cursor:i}),i=>i.items,r?.cursor),listAll:async(e,t,r)=>{let{max:i,...o}=r??{};return await S(s=>this.component.list(e,t,{...o,cursor:s}),s=>s.items,i,o.cursor)},search:async(e,t)=>{try{return await this.trpc.component.search.query({query:e,limit:t?.limit,cursor:t?.cursor})}catch(r){throw a(r)}},searchIter:(e,t)=>w(r=>this.component.search(e,{...t,cursor:r}),r=>r.items,t?.cursor),searchAll:async(e,t)=>{let{max:r,...i}=t??{};return await S(o=>this.component.search(e,{...i,cursor:o}),o=>o.items,r,i.cursor)},get:async(e,t,r)=>{try{return await this.trpc.component.get.query({orgName:e,repoName:t,componentRef:r})}catch(i){throw a(i)}},history:async(e,t,r)=>{try{return await this.trpc.component.history.query({orgName:e,repoName:t,componentRef:r?.componentRef,limit:r?.limit})}catch(i){throw a(i)}},install:async(e,t,r,i)=>{try{return await this.trpc.component.install.mutate({orgName:e,repoName:t,componentRef:r,submissionId:i.submissionId})}catch(o){throw a(o)}},uninstall:async(e,t,r,i)=>{try{return await this.trpc.component.uninstall.mutate({orgName:e,repoName:t,componentRef:r,submissionId:i.submissionId})}catch(o){throw a(o)}},registry:{register:async(e,t,r)=>{try{return await this.trpc.component.registry.register.mutate({orgName:e,componentName:t,...r})}catch(i){throw a(i)}},unregister:async(e,t)=>{try{return await this.trpc.component.registry.unregister.mutate({orgName:e,componentName:t})}catch(r){throw a(r)}},list:async e=>{try{return await this.trpc.component.registry.list.query({orgName:e})}catch(t){throw a(t)}},view:async(e,t)=>{try{return await this.trpc.component.registry.view.query({orgName:e,componentName:t})}catch(r){throw a(r)}},update:async(e,t,r)=>{try{return await this.trpc.component.registry.update.mutate({orgName:e,componentName:t,...r})}catch(i){throw a(i)}},resolve:async(e,t,r)=>await this.requestJson(`/api/component-registry/${encodeURIComponent(e)}/${encodeURIComponent(t)}/resolve`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({installRepo:r})}),setupCall:async(e,t,r)=>(await this.assertWriteCompatible(),await this.requestJson(`/api/component-registry/${encodeURIComponent(e)}/${encodeURIComponent(t)}/setup-call`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r)}))},cli:{call:async(e,t,r,i)=>(await this.assertWriteCompatible(),await this.requestJson(`/api/component-registry/${encodeURIComponent(e)}/${encodeURIComponent(t)}/cli/${encodeURIComponent(r)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)}))}};commit={apply:async(e,t,r,i,o)=>{try{return await L(this,{orgName:e,repoName:t,committer:o?.committer,message:r,componentRef:o?.componentRef,chunkSize:o?.chunkSize,skipExisting:o?.skipExisting,streamId:o?.streamId,submissionId:o?.submissionId,returnRepoSeq:o?.returnRepoSeq,retry:o?.retry,operations:i})}catch(s){throw s instanceof k||s instanceof x?s:a(s)}},getReceipt:async(e,t,r)=>{try{return await this.trpc.commit.getReceipt.query({orgName:e,repoName:t,eventRequestId:r})}catch(i){throw a(i)}}};org={get:async e=>{try{return await this.trpc.org.get.query({orgName:e})}catch(t){throw a(t)}},getCallerRole:async e=>{try{return await this.trpc.org.getCallerRole.query({orgName:e})}catch(t){throw a(t)}},list:async e=>{try{return {items:await this.trpc.org.list.query({includeArchived:e?.includeArchived})}}catch(t){throw a(t)}},create:async(e,t,r)=>{try{return await this.trpc.org.create.mutate({name:e,displayName:t,description:r})}catch(i){throw a(i)}},setDescription:async(e,t)=>{try{return await this.trpc.org.setDescription.mutate({orgName:e,description:t})}catch(r){throw a(r)}},setDisplayName:async(e,t)=>{try{return await this.trpc.org.setDisplayName.mutate({orgName:e,displayName:t})}catch(r){throw a(r)}},rename:async(e,t)=>{try{return await this.trpc.org.rename.mutate({orgName:e,newName:t})}catch(r){throw a(r)}},update:async e=>{try{return await this.trpc.org.update.mutate(e)}catch(t){throw a(t)}},addMember:async(e,t,r="editor")=>{try{return await this.trpc.org.addMember.mutate({orgName:e,email:t,role:r})}catch(i){throw a(i)}},removeMember:async(e,t)=>{try{await this.trpc.org.removeMember.mutate({orgName:e,email:t});}catch(r){throw a(r)}},leave:async e=>{try{await this.trpc.org.leave.mutate({orgName:e});}catch(t){throw a(t)}},changeMemberRole:async(e,t,r)=>{try{return await this.trpc.org.changeMemberRole.mutate({orgName:e,email:t,role:r})}catch(i){throw a(i)}},setMemberScopes:async(e,t,r)=>{try{await this.trpc.org.setMemberScopes.mutate({orgName:e,email:t,scopes:r});}catch(i){throw a(i)}},clearMemberScopes:async(e,t)=>{try{await this.trpc.org.clearMemberScopes.mutate({orgName:e,email:t});}catch(r){throw a(r)}},listMembers:async(e,t)=>{try{return await this.trpc.org.listMembers.query({orgName:e,pending:t?.pending})}catch(r){throw a(r)}},archive:async e=>{try{return await this.trpc.org.archive.mutate({orgName:e})}catch(t){throw a(t)}},unarchive:async e=>{try{return await this.trpc.org.unarchive.mutate({orgName:e})}catch(t){throw a(t)}}};repo={checkpoint:Ye(()=>this.trpc,a),get:async(e,t)=>{try{return await this.trpc.repo.get.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getStats:async(e,t)=>{try{return await this.trpc.repo.stats.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getStatsBatch:async(e,t)=>{try{return await this.trpc.repo.statsBatch.query({orgName:e,repoNames:t})}catch(r){throw a(r)}},getConfigureStats:async(e,t)=>{try{return await this.trpc.repo.configureStats.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getShapeInstanceCounts:async(e,t)=>{try{return await this.trpc.repo.shapeInstanceCounts.query({orgName:e,repoName:t})}catch(r){throw a(r)}},list:async(e,t)=>{try{return await this.trpc.repo.list.query({orgName:e,limit:t?.limit,cursor:t?.cursor,includeArchived:t?.includeArchived,search:t?.search,sort:t?.sort})}catch(r){throw a(r)}},listIter:(e,t)=>w(r=>this.repo.list(e,{...t,cursor:r}),r=>r.items,t?.cursor),listAll:async(e,t)=>{let{max:r,...i}=t??{};return await S(o=>this.repo.list(e,{...i,cursor:o}),o=>o.items,r,i.cursor)},search:async(e,t)=>{try{return await this.trpc.repo.search.query({query:e,limit:t?.limit,cursor:t?.cursor})}catch(r){throw a(r)}},searchIter:(e,t)=>w(r=>this.repo.search(e,{...t,cursor:r}),r=>r.items,t?.cursor),searchAll:async(e,t)=>{let{max:r,...i}=t??{};return await S(o=>this.repo.search(e,{...i,cursor:o}),o=>o.items,r,i.cursor)},create:async(e,t,r,i,o)=>{try{return await this.trpc.repo.create.mutate({orgName:e,repoName:t,description:r,visibility:i,displayName:o})}catch(s){throw a(s)}},setDescription:async(e,t,r)=>{try{return await this.trpc.repo.setDescription.mutate({orgName:e,repoName:t,description:r})}catch(i){throw a(i)}},setDisplayName:async(e,t,r)=>{try{return await this.trpc.repo.setDisplayName.mutate({orgName:e,repoName:t,displayName:r})}catch(i){throw a(i)}},setVisibility:async(e,t,r)=>{try{return await this.trpc.repo.setVisibility.mutate({orgName:e,repoName:t,visibility:r})}catch(i){throw a(i)}},rename:async(e,t,r)=>{try{return await this.trpc.repo.rename.mutate({orgName:e,repoName:t,newName:r})}catch(i){throw a(i)}},update:async e=>{try{return await this.trpc.repo.update.mutate(e)}catch(t){throw a(t)}},archive:async(e,t)=>{try{return await this.trpc.repo.archive.mutate({orgName:e,repoName:t})}catch(r){throw a(r)}},unarchive:async(e,t)=>{try{return await this.trpc.repo.unarchive.mutate({orgName:e,repoName:t})}catch(r){throw a(r)}},delete:async(e,t)=>{try{let r=await this.trpc.repo.delete.mutate({orgName:e,repoName:t});return {graceExpiresAt:new Date(r.graceExpiresAt)}}catch(r){throw a(r)}},listPage:async(e,t)=>{try{return await this.trpc.repo.listPage.query({orgName:e,limit:t?.limit,cursor:t?.cursor,includeArchived:t?.includeArchived,search:t?.search,sort:t?.sort})}catch(r){throw a(r)}},listPageIter:(e,t)=>w(r=>this.repo.listPage(e,{...t,cursor:r}),r=>r.items,t?.cursor),listPageAll:async(e,t)=>{let{max:r,...i}=t??{};return await S(o=>this.repo.listPage(e,{...i,cursor:o}),o=>o.items,r,i.cursor)},listForCaller:async e=>{try{return await this.trpc.repo.listForCaller.query({limit:e?.limit,sort:e?.sort})}catch(t){throw a(t)}},explore:async e=>{try{return await this.trpc.repo.explore.query({search:e?.search,org:e?.org,activity:e?.activity,hasSubscriptions:e?.hasSubscriptions,minThings:e?.minThings,sort:e?.sort,limit:e?.limit,cursor:e?.cursor,slugs:e?.slugs})}catch(t){throw a(t)}},exploreIter:e=>(Rt(e),w(t=>this.repo.explore({...e,cursor:t}),t=>t.items,e?.cursor)),exploreAll:async e=>{Rt(e);let{max:t,...r}=e??{};return await S(i=>this.repo.explore({...r,cursor:i}),i=>i.items,t,r.cursor)},getReadme:async(e,t)=>{try{return await this.trpc.repo.getReadme.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getAgents:async(e,t)=>{try{return await this.trpc.repo.getAgents.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getLicense:async(e,t)=>{try{return await this.trpc.repo.getLicense.query({orgName:e,repoName:t})}catch(r){throw a(r)}},describe:async(e,t)=>{try{return await this.trpc.repo.describe.query({orgName:e,repoName:t})}catch(r){throw a(r)}},setReadme:async(e,t,r,i)=>{try{return wt("Content/Readme.content",r),await this.trpc.repo.setReadme.mutate({orgName:e,repoName:t,eventRequestId:i.eventRequestId,content:r})}catch(o){throw a(o)}},setAgents:async(e,t,r,i)=>{try{return wt("Content/Agents.content",r),await this.trpc.repo.setAgents.mutate({orgName:e,repoName:t,eventRequestId:i.eventRequestId,content:r})}catch(o){throw a(o)}},getLlmsTxt:async(e,t)=>{try{return await this.trpc.repo.getLlmsTxt.query({orgName:e,repoName:t})}catch(r){throw a(r)}},index:{describe:async(e,t)=>{try{return await this.trpc.repo.index.describe.query({orgName:e,repoName:t})}catch(r){throw a(r)}}}};shape={list:async(e,t,r)=>{try{return await this.trpc.shape.list.query({orgName:e,repoName:t,match:r?.match,componentRef:r?.componentRef,excludeComponents:r?.excludeComponents,includeRetracted:r?.includeRetracted})}catch(i){throw a(i)}},get:async(e,t,r,i)=>{try{return await this.trpc.shape.get.query({orgName:e,repoName:t,shapeName:r,includeRetracted:i?.includeRetracted})}catch(o){throw a(o)}},create:async(e,t,r,i,o)=>{let s=V(r,{fields:i,...o.description!==void 0?{description:o.description}:{}},"add");if(s)throw new d("VALIDATION_ERROR",s);try{return await this.trpc.shape.create.mutate({orgName:e,repoName:t,shapeName:r,fields:i,eventRequestId:o.eventRequestId,description:o.description})}catch(p){throw a(p)}},revise:async(e,t,r,i,o)=>{let s=V(r,{fields:i,...o.description!==void 0?{description:o.description}:{}},"revise");if(s)throw new d("VALIDATION_ERROR",s);try{return await this.trpc.shape.revise.mutate({orgName:e,repoName:t,shapeName:r,newFields:i,eventRequestId:o.eventRequestId,description:o.description})}catch(p){throw a(p)}},remove:async(e,t,r,i)=>{try{return await this.trpc.shape.remove.mutate({orgName:e,repoName:t,shapeName:r,eventRequestId:i.eventRequestId})}catch(o){throw a(o)}},rename:async(e,t,r,i,o)=>{try{return await this.trpc.shape.rename.mutate({orgName:e,repoName:t,oldName:r,newName:i,eventRequestId:o.eventRequestId})}catch(s){throw a(s)}},history:async(e,t,r,i={})=>{try{return await this.trpc.shape.history.query({orgName:e,repoName:t,name:r,includeRetracted:i.includeRetracted,limit:i.limit,cursor:i.cursor})}catch(o){throw a(o)}},historyIter:(e,t,r,i={})=>w(o=>this.shape.history(e,t,r,{...i,cursor:o}),o=>o.versions,i.cursor),historyAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await S(p=>this.shape.history(e,t,r,{...s,cursor:p}),p=>p.versions,o,s.cursor)}};subscription={create:async e=>{try{let t=await this.trpc.subscription.create.mutate(wr(e));return ge(t)}catch(t){throw a(t)}},get:async(...e)=>{try{let t=await this.trpc.subscription.get.query(z(e));return ge(t)}catch(t){throw a(t)}},reveal:async(...e)=>{try{return await this.trpc.subscription.reveal.query(z(e))}catch(t){throw a(t)}},list:async(...e)=>{try{let t=await this.trpc.subscription.list.query(Rr(e));return fr(t)}catch(t){throw a(t)}},update:async e=>{try{let t=await this.trpc.subscription.update.mutate(Sr(e));return ge(t)}catch(t){throw a(t)}},pause:async(...e)=>{try{return await this.trpc.subscription.pause.mutate(z(e))}catch(t){throw a(t)}},resume:async(...e)=>{try{return await this.trpc.subscription.resume.mutate(z(e))}catch(t){throw a(t)}},remove:async(...e)=>{try{return await this.trpc.subscription.remove.mutate(z(e))}catch(t){throw a(t)}},bindCredentials:async(...e)=>{try{return await this.trpc.subscription.bindCredentials.mutate(br(e))}catch(t){throw a(t)}},unbindCredentials:async(...e)=>{try{return await this.trpc.subscription.unbindCredentials.mutate(Cr(e))}catch(t){throw a(t)}}};action={acquireLease:async(e,t,r,i,o,s)=>{try{return await this.trpc.action.acquireLease.mutate({orgName:e,repoName:t,subscriptionName:r,holderId:i,holderType:o,graceMs:s?.graceMs,ttlMs:s?.ttlMs})}catch(p){throw a(p)}},heartbeatLease:async(e,t,r,i,o)=>{try{return await this.trpc.action.heartbeatLease.mutate({orgName:e,repoName:t,subscriptionName:r,holderId:i,ttlMs:o})}catch(s){throw a(s)}},releaseLease:async(e,t,r,i)=>{try{return await this.trpc.action.releaseLease.mutate({orgName:e,repoName:t,subscriptionName:r,holderId:i})}catch(o){throw a(o)}},claimDelivery:async(e,t,r,i)=>{let o=typeof r=="string"?{runId:r}:r;try{return await this.trpc.action.claimDelivery.mutate({orgName:e,repoName:t,...o,holderId:i})}catch(s){throw a(s)}},completeDelivery:async(e,t,r,i)=>{let o=typeof r=="string"?{runId:r}:r;try{return await this.trpc.action.completeDelivery.mutate({orgName:e,repoName:t,...o,holderId:i})}catch(s){throw a(s)}},liveFeed:async(e,t,r,i)=>{try{return await this.trpc.action.liveFeed.query({orgName:e,repoName:t,subscriptionName:r,limit:i?.limit,cursor:i?.cursor})}catch(o){throw a(o)}},liveFeedIter:(e,t,r,i)=>w(o=>this.action.liveFeed(e,t,r,{...i,cursor:o}),o=>o.items,i?.cursor),liveFeedAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await S(p=>this.action.liveFeed(e,t,r,{...s,cursor:p}),p=>p.items,o,s.cursor)},listRuns:async(e,t,r)=>{try{return await this.trpc.action.listRuns.query({orgName:e,repoName:t,runId:r?.runId,subscriptionName:r?.subscriptionName,status:r?.status,outcome:r?.outcome,since:r?.since,cursor:r?.cursor,limit:r?.limit})}catch(i){throw a(i)}},listRunsIter:(e,t,r)=>w(i=>this.action.listRuns(e,t,{...r,since:i===void 0?r?.since:void 0,cursor:i}),i=>i.items,r?.cursor),listRunsAll:async(e,t,r)=>{let{max:i,...o}=r??{};return await S(s=>this.action.listRuns(e,t,{...o,since:s===void 0?o.since:void 0,cursor:s}),s=>s.items,i,o.cursor)},latestRuns:async(e,t)=>{try{return await this.trpc.action.latestRuns.query({orgName:e,repoName:t})}catch(r){throw a(r)}},runStats:async(e,t,r)=>{try{return await this.trpc.action.runStats.query({orgName:e,repoName:t,subscriptionName:r?.subscriptionName,since:r?.since})}catch(i){throw a(i)}},getRunAttempts:async(e,t,r)=>{try{return await this.trpc.action.getRunAttempts.query({orgName:e,repoName:t,runId:r})}catch(i){throw a(i)}},listNotifications:async(e,t,r)=>{try{return await this.trpc.action.listNotifications.query({orgName:e,repoName:t,since:r?.since,limit:r?.limit})}catch(i){throw a(i)}}};collection={create:async(e,t,r)=>{try{return Ir(r.type,r),await this.trpc.collection.create.mutate({orgName:e,repoName:t,eventRequestId:r.eventRequestId,type:r.type,name:r.name,members:r.members,from:r.from,add:r.add,remove:r.remove,replaceMembers:r.replaceMembers,query:r.query,sourceOrgName:r.sourceRepo?.orgName,sourceRepoName:r.sourceRepo?.repoName,skipExisting:r.skipExisting,message:r.message,committer:r.committer})}catch(i){throw a(i)}},members:async(e,t,r,i)=>{try{return await this.trpc.collection.members.query({orgName:e,repoName:t,wref:r,version:i?.version,limit:i?.limit,cursor:i?.cursor})}catch(o){throw a(o)}},membersIter:(e,t,r,i)=>{let o=i?.version;return w(async s=>{let p=await this.collection.members(e,t,r,{...i,version:o,cursor:s});return o??=p.version,p},s=>s.items,i?.cursor)},membersAll:async(e,t,r,i)=>{let{max:o,...s}=i??{},p=s.version;return await S(async c=>{let u=await this.collection.members(e,t,r,{...s,version:p,cursor:c});return p??=u.version,u},c=>c.items,o,s.cursor)},contains:async(e,t,r,i,o)=>{try{return await this.trpc.collection.contains.query({orgName:e,repoName:t,wref:r,version:o?.version,members:i,position:o?.position})}catch(s){throw a(s)}},diff:async(e,t,r,i,o)=>{try{return await this.trpc.collection.diff.query({orgName:e,repoName:t,leftWref:r,rightWref:i,leftVersion:o?.leftVersion,rightVersion:o?.rightVersion,mode:o?.mode})}catch(s){throw a(s)}},revise:async(e,t,r,i)=>{try{let o=Or(r);if(he(i.query)&&!ye(i.query))throw new d("VALIDATION_ERROR","Selector-backed collection sources require shape, about, match, componentRef, or where; kind and excludeComponents only narrow an existing selector.");if(i.sourceRepo&&!ye(i.query))throw new d("VALIDATION_ERROR","sourceRepo requires a selector-backed collection query");if(i.sourceRepo&&xt(i))throw new d("VALIDATION_ERROR","sourceRepo cannot be combined with explicit members; use canonical wh:org/repo/... member wrefs or omit sourceRepo.");if(he(i.query)&&o&&o!=="set")throw new d("VALIDATION_ERROR","Selector-backed revise requires a Set/<name> target wref");return await this.trpc.collection.revise.mutate({orgName:e,repoName:t,eventRequestId:i.eventRequestId,wref:r,members:i.members,add:i.add,remove:i.remove,query:i.query,sourceOrgName:i.sourceRepo?.orgName,sourceRepoName:i.sourceRepo?.repoName,message:i.message,committer:i.committer})}catch(o){throw a(o)}},stats:async(e,t,r,i)=>{try{return await this.trpc.collection.stats.query({orgName:e,repoName:t,wref:r,version:i?.version})}catch(o){throw a(o)}}};view={evaluate:async(e,t,r,i)=>{try{return await this.trpc.view.evaluate.query({orgName:e,repoName:t,wref:r,limit:i?.limit,cursor:i?.cursor})}catch(o){throw a(o)}},evaluateIter:(e,t,r,i)=>w(o=>this.view.evaluate(e,t,r,{...i,cursor:o}),o=>o.items,i?.cursor),evaluateAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await S(p=>this.view.evaluate(e,t,r,{...s,cursor:p}),p=>p.items,o,s.cursor)}};grant=ze(()=>this.trpc,a);thing={head:async(e,t,r)=>{try{return await this.trpc.thing.head.query({orgName:e,repoName:t,shape:r?.shape,kind:me(r?.kind),match:r?.match,dataMode:r?.dataMode,includeRetracted:r?.includeRetracted,limit:r?.limit,cursor:r?.cursor,componentRef:r?.componentRef,excludeComponents:r?.excludeComponents,excludeInfraShapes:r?.excludeInfraShapes,where:r?.where,sinceRepoSeq:r?.sinceRepoSeq})}catch(i){throw a(i)}},headIter:(e,t,r)=>w(i=>this.thing.head(e,t,{...r,cursor:i}),i=>i.items,r?.cursor),headAll:async(e,t,r)=>{let{max:i,...o}=r??{};return await S(s=>this.thing.head(e,t,{...o,cursor:s}),s=>s.items,i,o.cursor)},headChanges:async(e,t,r)=>(ft(r?.sinceRepoSeq),await bt(i=>this.thing.head(e,t,{...r,includeRetracted:true,cursor:i}))),get:async(e,t,r,i,o)=>{try{return await this.trpc.thing.get.query({orgName:e,repoName:t,wref:r,version:i,includeRetracted:o?.includeRetracted,dataMode:o?.dataMode})}catch(s){throw a(s)}},getWithLease:async(e,t,r,i)=>{try{return await this.trpc.thing.getWithLease.mutate({orgName:e,repoName:t,wref:r,ttlMs:i?.ttlMs})}catch(o){throw a(o)}},releaseLease:async(e,t,r,i)=>{try{await this.trpc.thing.releaseLease.mutate({orgName:e,repoName:t,wref:r,leaseId:i});}catch(o){throw a(o)}},graph:async(e,t,r,i)=>{try{return await this.trpc.thing.graph.query({orgName:e,repoName:t,wref:r,version:i?.version,depth:i?.depth,limit:i?.limit})}catch(o){throw a(o)}},getMany:async(e,t,r,i,o)=>{try{if(r.length===0)return {requested:0,items:[],missing:[]};let s=de(o?.chunkSize,mt,gt),p=de(o?.chunkConcurrency,ht,yt),c=async m=>await this.trpc.thing.getMany.query({orgName:e,repoName:t,wrefs:m,version:i,includeRetracted:o?.includeRetracted,dataMode:o?.dataMode});if(r.length<=s)return await c(r);let u=Ct(r,s),l=[];for(let m=0;m<u.length;m+=p){let f=u.slice(m,m+p),h=await Promise.all(f.map(c));l.push(...h);}return {requested:r.length,items:l.flatMap(m=>m.items),missing:l.flatMap(m=>m.missing)}}catch(s){throw a(s)}},headVersions:async(e,t,r,i)=>{try{if(r.length===0)return {requested:0,items:[],missing:[]};let o=de(i?.chunkSize,mt,gt),s=de(i?.chunkConcurrency,ht,yt),p=async l=>await this.trpc.thing.headVersions.query({orgName:e,repoName:t,wrefs:l});if(r.length<=o)return await p(r);let c=Ct(r,o),u=[];for(let l=0;l<c.length;l+=s){let m=c.slice(l,l+s),f=await Promise.all(m.map(p));u.push(...f);}return {requested:r.length,items:u.flatMap(l=>l.items),missing:u.flatMap(l=>l.missing)}}catch(o){throw a(o)}},history:async(e,t,r)=>{try{return await this.trpc.thing.history.query({orgName:e,repoName:t,wref:r.wref,shape:r.shape,about:r.about,includeRetracted:r.includeRetracted,resolveCollections:r.resolveCollections,match:r.match,limit:r.limit,cursor:r.cursor})}catch(i){throw a(i)}},historyIter:(e,t,r)=>w(i=>this.thing.history(e,t,{...r,cursor:i}),i=>i.versions,r.cursor),historyAll:async(e,t,r)=>{let{max:i,...o}=r;return await S(s=>this.thing.history(e,t,{...o,cursor:s}),s=>s.versions,i,o.cursor)},rename:async(e,t,r,i,o,s)=>{try{return await this.trpc.thing.rename.mutate({orgName:e,repoName:t,shapeName:r,oldName:i,newName:o,eventRequestId:s.eventRequestId})}catch(p){throw a(p)}},resolve:async(e,t,r)=>{try{return await this.trpc.thing.resolve.query({orgName:e,repoName:t,wref:r})}catch(i){throw a(i)}},about:async(e,t,r,i)=>{try{return await this.trpc.thing.about.query({orgName:e,repoName:t,wref:r,shape:i?.shape,match:i?.match,includeRetracted:i?.includeRetracted,depth:i?.depth,resolveCollections:i?.resolveCollections,role:i?.role,limit:i?.limit,cursor:i?.cursor,where:i?.where})}catch(o){throw a(o)}},aboutIter:(e,t,r,i)=>w(o=>this.thing.about(e,t,r,{...i,cursor:o}),o=>o.assertions,i?.cursor),aboutAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await S(p=>this.thing.about(e,t,r,{...s,cursor:p}),p=>p.assertions,o,s.cursor)},query:async(e,t,r)=>{try{return await this.trpc.thing.query.query({orgName:e,repoName:t,shape:r?.shape,about:r?.about,affirmedAbout:r?.affirmedAbout,kind:me(r?.kind),match:r?.match,includeRetracted:r?.includeRetracted,resolveCollections:r?.resolveCollections,role:r?.role,limit:r?.limit,cursor:r?.cursor,componentRef:r?.componentRef,excludeComponents:r?.excludeComponents,excludeInfraShapes:r?.excludeInfraShapes,where:r?.where,sinceRepoSeq:r?.sinceRepoSeq})}catch(i){throw a(i)}},queryIter:(e,t,r)=>w(i=>this.thing.query(e,t,{...r,cursor:i}),i=>i.items,r?.cursor),queryAll:async(e,t,r)=>{let{max:i,...o}=r??{};return await S(s=>this.thing.query(e,t,{...o,cursor:s}),s=>s.items,i,o.cursor)},queryChanges:async(e,t,r)=>(ft(r?.sinceRepoSeq),await bt(i=>this.thing.query(e,t,{...r,includeRetracted:true,cursor:i}))),search:async(e,t,r,i)=>{try{return await this.trpc.thing.search.query({orgName:e,repoName:t,query:r,shape:i?.shape,about:i?.about,kind:me(i?.kind),match:i?.match,includeRetracted:i?.includeRetracted,resolveCollections:i?.resolveCollections,limit:i?.limit,cursor:i?.cursor,componentRef:i?.componentRef,excludeComponents:i?.excludeComponents,excludeInfraShapes:i?.excludeInfraShapes,mode:i?.mode,nameMatch:i?.nameMatch})}catch(o){throw a(o)}},searchIter:(e,t,r,i)=>w(o=>this.thing.search(e,t,r,{...i,cursor:o}),o=>o.items,i?.cursor),searchAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await S(p=>this.thing.search(e,t,r,{...s,cursor:p}),p=>p.items,o,s.cursor)},count:async(e,t,r)=>{try{return await this.trpc.thing.count.query({orgName:e,repoName:t,shape:r?.shape,about:r?.about,kind:me(r?.kind),match:r?.match,includeRetracted:r?.includeRetracted,resolveCollections:r?.resolveCollections,componentRef:r?.componentRef,excludeComponents:r?.excludeComponents,excludeInfraShapes:r?.excludeInfraShapes,where:r?.where,sinceRepoSeq:r?.sinceRepoSeq})}catch(i){throw a(i)}},refs:async(e,t,r,i)=>{try{return await this.trpc.thing.refs.query({orgName:e,repoName:t,wref:r,direction:i?.direction,fieldPath:i?.fieldPath,limit:i?.limit,cursor:i?.cursor})}catch(o){throw a(o)}},refsIter:(e,t,r,i)=>w(o=>this.thing.refs(e,t,r,{...i,cursor:o}),o=>o.items,i?.cursor),refsAll:async(e,t,r,i)=>{let{max:o,...s}=i??{};return await S(p=>this.thing.refs(e,t,r,{...s,cursor:p}),p=>p.items,o,s.cursor)}};live={thingHead:async(e,t,r,i)=>this.watchRepoQuery(e,t,r?.signal,()=>this.thing.head(e,t,{shape:r?.shape,kind:r?.kind,match:r?.match,dataMode:r?.dataMode,limit:r?.limit,cursor:r?.cursor,includeRetracted:r?.includeRetracted,where:r?.where}),i),thingHistory:async(e,t,r,i)=>this.watchRepoQuery(e,t,r.signal,()=>this.thing.history(e,t,{wref:r.wref,limit:r.limit,cursor:r.cursor,includeRetracted:r.includeRetracted}),i),subscriptionLog:async(e,t,r,i,o)=>this.watchRepoQuery(e,t,i?.signal,()=>this.action.liveFeed(e,t,r,{limit:i?.limit,cursor:i?.cursor}),o),subscribe:async(e,t,r,i)=>{let o=new AbortController,s=It(r?.signal,o),p=0,c=(async()=>{let u=await this.trpc.live.issueTicket.mutate({orgName:e,repoName:t}),l=await this.openSse(u.ticket,s,async m=>{if(m.type!=="invalidate")return;let f=m.data;p++,await i({topic:f.topic,affectedShapes:f.affectedShapes,affectedThings:f.affectedThings,affectedTargets:f.affectedTargets,hasNewCommit:f.hasNewCommit});});return await l.ready,s.aborted?{updates:p}:(await l.closed,{updates:p})})();return {close(){o.abort();},closed:c}}};token={create:async e=>{try{return await this.trpc.token.create.mutate(e)}catch(t){throw a(t)}},list:async e=>{try{return await this.trpc.token.list.query(e?.includeInactive?{includeInactive:!0}:void 0)}catch(t){throw a(t)}},get:async e=>{try{return await this.trpc.token.get.query({name:e})}catch(t){throw a(t)}},revoke:async e=>{try{return await this.trpc.token.revoke.mutate({name:e})}catch(t){throw a(t)}}};stream={append:async e=>{try{return await this.trpc.stream.append.mutate(e)}catch(t){throw a(t)}}};credential={createSet:async(e,t,r,i)=>{try{return await this.trpc.credential.createSet.mutate({orgName:e,repoName:t,name:r,scope:i?.scope??"repo",description:i?.description})}catch(o){throw a(o)}},listSets:async(e,t)=>{try{return await this.trpc.credential.listSets.query({orgName:e,repoName:t})}catch(r){throw a(r)}},getSet:async(e,t,r)=>{try{return await this.trpc.credential.getSet.query({orgName:e,repoName:t,name:r})}catch(i){throw a(i)}},setKey:async(e,t,r,i,o)=>{try{return await this.trpc.credential.setKey.mutate({orgName:e,repoName:t,setName:r,keyName:i,value:o})}catch(s){throw a(s)}},setKeys:async(e,t,r,i)=>{try{return await this.trpc.credential.setKeys.mutate({orgName:e,repoName:t,setName:r,secrets:i})}catch(o){throw a(o)}},unsetKey:async(e,t,r,i)=>{try{return await this.trpc.credential.unsetKey.mutate({orgName:e,repoName:t,setName:r,keyName:i})}catch(o){throw a(o)}},deleteSet:async(e,t,r)=>{try{return await this.trpc.credential.deleteSet.mutate({orgName:e,repoName:t,setName:r})}catch(i){throw a(i)}},listAuditLog:async(e,t,r,i)=>{try{return await this.trpc.credential.listAuditLog.query({orgName:e,repoName:t,setName:r,limit:i?.limit})}catch(o){throw a(o)}},revokeSet:async(e,t,r,i)=>{try{return await this.trpc.credential.revokeSet.mutate({orgName:e,repoName:t,setName:r,reason:i?.reason})}catch(o){throw a(o)}}};credentials=this.credential;constructor(e,t){let r=typeof e=="string"?t:e;gr(r);let i=typeof e=="string"?e:e?.apiUrl??De;if(this.apiUrl=i,this.fetchImpl=r?.fetch,this.accessToken=r?.accessToken??r?.auth?.getToken,this.functionLogMode=r?.functionLogs??"off",this.clientIdentity={name:r?.client?.name??f,version:r?.client?.version??xe},this.clientFlags=hr(r?.clientFlags),typeof this.accessToken=="function"){let p=this.accessToken;this.getToken=async()=>await p();}else if(this.accessToken){let p=this.accessToken;this.getToken=async()=>p;}let o=`${i.replace(/\/$/,"")}/trpc`,s=((p,c)=>this.fetchWithAuth(p,c));Object.defineProperty(this,"trpc",{value:createTRPCProxyClient({links:[this.createCompatibilityLink(),splitLink({condition:p=>yr.has(p.path),true:httpLink({url:o,fetch:s,methodOverride:"POST"}),false:httpBatchLink({url:o,fetch:s,methodOverride:"POST"})})]}),enumerable:false,writable:false,configurable:true});}withAccessToken(e){return new n({apiUrl:this.apiUrl,fetch:this.fetchImpl,accessToken:e,client:this.clientIdentity,clientFlags:this.clientFlags})}actions=this.action;async openSse(e,t,r){let i=await this.fetchWithAuth(`${this.apiUrl.replace(/\/$/,"")}/sse?ticket=${encodeURIComponent(e)}`,{headers:{accept:"text/event-stream"},signal:t});if(!i.ok)throw new d("BACKEND",`SSE request failed with status ${i.status}`,i.status);let o=i.body?.getReader();if(!o)throw new d("BACKEND","SSE response body is missing");let s=()=>{},p=new Promise(u=>{s=u;}),c=(async()=>{let u=new TextDecoder,l="";try{for(;;){let{done:m,value:f}=await o.read();if(m)break;for(l+=u.decode(f,{stream:!0}).replaceAll(`\r
2
+ `,`
3
+ `);;){let h=l.indexOf(`
4
+
5
+ `);if(h===-1)break;let C=l.slice(0,h);l=l.slice(h+2);let g=Pr(C);if(g){if(g.type==="ready"){s();continue}await r(g);}}}}catch(m){if(Lr(m)||t.aborted)return;throw m}finally{s(),o.releaseLock();}})();return {ready:p,closed:c}}applyClientHeader(e$1){e$1.has(e)||e$1.set(e,i(this.clientIdentity.name,this.clientIdentity.version)),this.clientFlags.length>0&&!e$1.has(a$1)&&e$1.set(a$1,d$1(this.clientFlags));}async fetchWithAuth(e,t){let r=this.fetchImpl??globalThis.fetch,i=new Headers(t?.headers),o=await Ot(this.accessToken);o&&i.set("authorization",`Bearer ${o}`),this.applyClientHeader(i);let s=async c=>{try{return await r(e,c)}catch(u){throw Tr(u)?new d("NETWORK",Nr(this.apiUrl)):u}},p=await s({...t,headers:i});if(p.status===401&&typeof this.accessToken=="function"){let c=await Ot(this.accessToken);if(c&&c!==o){let u=new Headers(t?.headers);return u.set("authorization",`Bearer ${c}`),this.applyClientHeader(u),s({...t,headers:u})}}return p}async requestResponse(e,t){let r=await this.fetchWithAuth(`${this.apiUrl.replace(/\/$/,"")}${e}`,t);if(!r.ok){let i=`Request failed with status ${r.status}`,o=Nt(r.status),s,p,c;try{let u=await r.json();typeof u.error?.message=="string"&&(i=u.error.message),typeof u.error?.code=="string"&&(o=u.error.code,s=u.error.code),typeof u.error?.hint=="string"&&(p=u.error.hint),typeof u.error?.retryAfter=="number"&&(c=u.error.retryAfter);}catch{}throw new d(o,i,r.status,p,c,s)}return r}async requestJson(e,t){return await(await this.requestResponse(e,t)).json()}async watchRepoQuery(e,t,r,i,o){let s=new AbortController,p=It(r,s),c=0,u=(async()=>{let l=async()=>{let h=await i();c+=1,await o(h);},m=await this.trpc.live.issueTicket.mutate({orgName:e,repoName:t}),f=await this.openSse(m.ticket,p,async h=>{h.type==="invalidate"&&await l();});return await f.ready,p.aborted?{updates:c}:(await l(),await f.closed,{updates:c})})();return {close(){s.abort();},closed:u}}};function Nt(n){switch(n){case 400:return "VALIDATION_ERROR";case 401:return "UNAUTHENTICATED";case 403:return "FORBIDDEN";case 404:return "NOT_FOUND";case 409:return "CONFLICT";case 429:return "RATE_LIMITED";default:return "BACKEND"}}async function Ot(n){if(n)return typeof n=="string"?n:n()}function It(n,e){return n?n.aborted?(e.abort(),e.signal):(n.addEventListener("abort",()=>e.abort(),{once:true}),e.signal):e.signal}function Pr(n){let e="message",t=[];for(let i of n.split(`
6
+ `))if(!(!i||i.startsWith(":"))){if(i.startsWith("event:")){e=i.slice(6).trim();continue}i.startsWith("data:")&&t.push(i.slice(5).trim());}if(t.length===0)return null;let r=t.join(`
7
+ `);return {type:e,data:JSON.parse(r)}}function Lr(n){return n instanceof Error&&n.name==="AbortError"}export{Tr as A,Nr as B,Wn as C,St as D,re as a,qt as b,Se as c,ie as d,oe as e,k as f,x as g,W as h,se as i,G as j,L as k,ke as l,ae as m,Ee as n,xe as o,I as p,rr as q,le as r,Vn as s,De as t,Hn as u,Me as v,d as w,a as x,Er as y,Fn as z};//# sourceMappingURL=chunk-CZI7BWOX.js.map
8
+ //# sourceMappingURL=chunk-CZI7BWOX.js.map