@augmentcode/onison 0.0.21 → 1.0.76-prerelease.202608100950
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/auggie-v2.mjs +8474 -2061
- package/auggie-v2.mjs.d/extensions/manifest.json +8 -0
- package/auggie-v2.mjs.d/extensions/mcp/index.js +116 -55
- package/auggie-v2.mjs.d/extensions/migration/index.js +10 -0
- package/auggie-v2.mjs.d/extensions/otel/index.js +30 -0
- package/indexing-worker.mjs +234 -164
- package/package.json +2 -1
- package/vfs-prefetch-worker.mjs +35 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{createRequire as H4}from"node:module";var w=(Z,$)=>()=>($||Z(($={exports:{}}).exports,$),$.exports);var B=H4(import.meta.url);var v2=w((A4)=>{A4.supports=function(...$){let Y=$.reduce((q,X)=>Object.assign(q,X),{}),J=Y.implicitSnapshots||Y.snapshots||!1,Q=Y.explicitSnapshots||!1;return Object.assign(Y,{implicitSnapshots:J,explicitSnapshots:Q,snapshots:J,has:Y.has||!1,permanence:Y.permanence||!1,seek:Y.seek||!1,createIfMissing:Y.createIfMissing||!1,errorIfExists:Y.errorIfExists||!1,deferredOpen:Y.deferredOpen||!1,streams:Y.streams||!1,encodings:Object.assign({},Y.encodings),events:Object.assign({},Y.events),additionalMethods:Object.assign({},Y.additionalMethods),signals:Object.assign({},Y.signals)})}});var S=w((Y5,E2)=>{E2.exports=class extends Error{constructor($,Y){super($||"");if(typeof Y==="object"&&Y!==null){if(Y.code)this.code=String(Y.code);if(Y.expected)this.expected=!0;if(Y.transient)this.transient=!0;if(Y.cause)this.cause=Y.cause}if(Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}}});var m0=w((J5,m2)=>{var E0=null;m2.exports=function(){if(E0===null)E0={textEncoder:new TextEncoder,textDecoder:new TextDecoder};return E0}});var b0=w((C4)=>{var f0=S(),x4=new Set(["buffer","view","utf8"]);class f2{constructor(Z){if(this.encode=Z.encode||this.encode,this.decode=Z.decode||this.decode,this.name=Z.name||this.name,this.format=Z.format||this.format,typeof this.encode!=="function")throw TypeError("The 'encode' property must be a function");if(typeof this.decode!=="function")throw TypeError("The 'decode' property must be a function");if(this.encode=this.encode.bind(this),this.decode=this.decode.bind(this),typeof this.name!=="string"||this.name==="")throw TypeError("The 'name' property must be a string");if(typeof this.format!=="string"||!x4.has(this.format))throw TypeError("The 'format' property must be one of 'buffer', 'view', 'utf8'");if(Z.createViewTranscoder)this.createViewTranscoder=Z.createViewTranscoder;if(Z.createBufferTranscoder)this.createBufferTranscoder=Z.createBufferTranscoder;if(Z.createUTF8Transcoder)this.createUTF8Transcoder=Z.createUTF8Transcoder}get commonName(){return this.name.split("+")[0]}createBufferTranscoder(){throw new f0(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new f0(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new f0(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}}C4.Encoding=f2});var k0=w((F4)=>{var{Buffer:g0}=B("buffer")||{},{Encoding:y0}=b0(),I4=m0();class W0 extends y0{constructor(Z){super({...Z,format:"buffer"})}createViewTranscoder(){return new j0({encode:this.encode,decode:(Z)=>this.decode(g0.from(Z.buffer,Z.byteOffset,Z.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}}class j0 extends y0{constructor(Z){super({...Z,format:"view"})}createBufferTranscoder(){return new W0({encode:(Z)=>{let $=this.encode(Z);return g0.from($.buffer,$.byteOffset,$.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}}class b2 extends y0{constructor(Z){super({...Z,format:"utf8"})}createBufferTranscoder(){return new W0({encode:(Z)=>g0.from(this.encode(Z),"utf8"),decode:(Z)=>this.decode(Z.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:Z,textDecoder:$}=I4();return new j0({encode:(Y)=>Z.encode(this.encode(Y)),decode:(Y)=>this.decode($.decode(Y)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}}F4.BufferFormat=W0;F4.ViewFormat=j0;F4.UTF8Format=b2});var u2=w((m4)=>{var{Buffer:R}=B("buffer")||{Buffer:{isBuffer:()=>!1}},{textEncoder:y2,textDecoder:g2}=m0()(),{BufferFormat:i,ViewFormat:u0,UTF8Format:k2}=k0(),H0=(Z)=>Z;m4.utf8=new k2({encode:function(Z){return R.isBuffer(Z)?Z.toString("utf8"):ArrayBuffer.isView(Z)?g2.decode(Z):String(Z)},decode:H0,name:"utf8",createViewTranscoder(){return new u0({encode:function(Z){return ArrayBuffer.isView(Z)?Z:y2.encode(Z)},decode:function(Z){return g2.decode(Z)},name:`${this.name}+view`})},createBufferTranscoder(){return new i({encode:function(Z){return R.isBuffer(Z)?Z:ArrayBuffer.isView(Z)?R.from(Z.buffer,Z.byteOffset,Z.byteLength):R.from(String(Z),"utf8")},decode:function(Z){return Z.toString("utf8")},name:`${this.name}+buffer`})}});m4.json=new k2({encode:JSON.stringify,decode:JSON.parse,name:"json"});m4.buffer=new i({encode:function(Z){return R.isBuffer(Z)?Z:ArrayBuffer.isView(Z)?R.from(Z.buffer,Z.byteOffset,Z.byteLength):R.from(String(Z),"utf8")},decode:H0,name:"buffer",createViewTranscoder(){return new u0({encode:function(Z){return ArrayBuffer.isView(Z)?Z:R.from(String(Z),"utf8")},decode:function(Z){return R.from(Z.buffer,Z.byteOffset,Z.byteLength)},name:`${this.name}+view`})}});m4.view=new u0({encode:function(Z){return ArrayBuffer.isView(Z)?Z:y2.encode(Z)},decode:H0,name:"view",createBufferTranscoder(){return new i({encode:function(Z){return R.isBuffer(Z)?Z:ArrayBuffer.isView(Z)?R.from(Z.buffer,Z.byteOffset,Z.byteLength):R.from(String(Z),"utf8")},decode:H0,name:`${this.name}+buffer`})}});m4.hex=new i({encode:function(Z){return R.isBuffer(Z)?Z:R.from(String(Z),"hex")},decode:function(Z){return Z.toString("hex")},name:"hex"});m4.base64=new i({encode:function(Z){return R.isBuffer(Z)?Z:R.from(String(Z),"base64")},decode:function(Z){return Z.toString("base64")},name:"base64"})});var d2=w((e4)=>{var c2=S(),N0=u2(),{Encoding:c4}=b0(),{BufferFormat:l4,ViewFormat:d4,UTF8Format:p4}=k0(),n=Symbol("formats"),w0=Symbol("encodings"),a4=new Set(["buffer","view","utf8"]);class l2{constructor(Z){if(!Array.isArray(Z))throw TypeError("The first argument 'formats' must be an array");else if(!Z.every(($)=>a4.has($)))throw TypeError("Format must be one of 'buffer', 'view', 'utf8'");this[w0]=new Map,this[n]=new Set(Z);for(let $ in N0)try{this.encoding($)}catch(Y){if(Y.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw Y}}encodings(){return Array.from(new Set(this[w0].values()))}encoding(Z){let $=this[w0].get(Z);if($===void 0){if(typeof Z==="string"&&Z!==""){if($=r4[Z],!$)throw new c2(`Encoding '${Z}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else if(typeof Z!=="object"||Z===null)throw TypeError("First argument 'encoding' must be a string or object");else $=s4(Z);let{name:Y,format:J}=$;if(!this[n].has(J))if(this[n].has("view"))$=$.createViewTranscoder();else if(this[n].has("buffer"))$=$.createBufferTranscoder();else if(this[n].has("utf8"))$=$.createUTF8Transcoder();else throw new c2(`Encoding '${Y}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let Q of[Z,Y,$.name,$.commonName])this[w0].set(Q,$)}return $}}e4.Transcoder=l2;function s4(Z){if(Z instanceof c4)return Z;let $="type"in Z&&typeof Z.type==="string"?Z.type:void 0,Y=Z.name||$||`anonymous-${t4++}`;switch(i4(Z)){case"view":return new d4({...Z,name:Y});case"utf8":return new p4({...Z,name:Y});case"buffer":return new l4({...Z,name:Y});default:throw TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function i4(Z){if("format"in Z&&Z.format!==void 0)return Z.format;else if("buffer"in Z&&typeof Z.buffer==="boolean")return Z.buffer?"buffer":"utf8";else if("code"in Z&&Number.isInteger(Z.code))return"view";else return"buffer"}var n4={binary:N0.buffer,"utf-8":N0.utf8},r4={...N0,...n4},t4=0});var z0=w((W5,i2)=>{var p2=Symbol("kErrors");i2.exports=function(Z){if(Z=Z.filter(ZZ),Z.length===0)return;if(Z.length===1)return Z[0];return new s2(Z)};class s2 extends Error{constructor(Z){let $=new Set(Z.map($Z).filter(Boolean)),Y=Array.from($).join("; ");super(Y);a2(this,"name","CombinedError"),a2(this,p2,Z),c0(this,"stack",()=>Z.map(YZ).join(`
|
|
2
|
+
|
|
3
|
+
`)),c0(this,"transient",()=>Z.length>0&&Z.every(JZ)),c0(this,"expected",()=>Z.length>0&&Z.every(QZ))}[Symbol.iterator](){return this[p2][Symbol.iterator]()}}function a2(Z,$,Y){Object.defineProperty(Z,$,{value:Y})}function c0(Z,$,Y){Object.defineProperty(Z,$,{get:Y})}function ZZ(Z){return Z!=null}function $Z(Z){return Z.message}function YZ(Z){return Z.stack}function JZ(Z){return Z.transient===!0}function QZ(Z){return Z.expected===!0}});var F=w((XZ)=>{var qZ=S(),n2=new Set;XZ.getOptions=function(Z,$){if(typeof Z==="object"&&Z!==null)return Z;if($!==void 0)return $;return{}};XZ.emptyOptions=Object.freeze({});XZ.noop=function(){};XZ.resolvedPromise=Promise.resolve();XZ.deprecate=function(Z){if(!n2.has(Z)){n2.add(Z);let $=globalThis.console;if(typeof $<"u"&&typeof $.warn==="function")$.warn(new qZ(Z,{code:"LEVEL_LEGACY"}))}}});var l0=w((zZ)=>{var NZ=S();class r2 extends NZ{constructor(Z){super("Operation has been aborted",{code:"LEVEL_ABORTED",cause:Z})}get name(){return"AbortError"}}zZ.AbortError=r2});var v=w((RZ)=>{var r=S(),VZ=z0(),{getOptions:d0,emptyOptions:p0,noop:_Z}=F(),{AbortError:LZ}=l0(),V0=Symbol("decodeOne"),t=Symbol("decodeMany"),O=Symbol("keyEncoding"),f=Symbol("valueEncoding");class e{#Z=!1;#$=null;#Y=null;#q=0;#G;#J;#X;#Q;constructor(Z,$){if(typeof Z!=="object"||Z===null)throw TypeError(`The first argument must be an abstract-level database, received ${Z===null?"null":typeof Z}`);if(typeof $!=="object"||$===null)throw TypeError("The second argument must be an options object");this[O]=$[O],this[f]=$[f],this.#J=Number.isInteger($.limit)&&$.limit>=0?$.limit:1/0,this.#G=$.signal!=null?$.signal:null,this.#Q=$.snapshot!=null?$.snapshot:null,this.#X=!1,this.db=Z,this.db.attachResource(this)}get count(){return this.#q}get limit(){return this.#J}async next(){this.#j();try{if(this.#X||this.#q>=this.#J){this.#X=!0;return}let Z=await this._next();if(Z===void 0){this.#X=!0;return}try{Z=this[V0](Z)}catch($){throw new U0($)}return this.#q++,Z}finally{this.#W()}}async _next(){}async nextv(Z,$){if(!Number.isInteger(Z))throw TypeError("The first argument 'size' must be an integer");if($=d0($,p0),Z<1)Z=1;if(this.#J<1/0)Z=Math.min(Z,this.#J-this.#q);this.#j();try{if(this.#X||Z<=0)return this.#X=!0,[];let Y=await this._nextv(Z,$);if(Y.length===0)return this.#X=!0,Y;try{this[t](Y)}catch(J){throw new U0(J)}return this.#q+=Y.length,Y}finally{this.#W()}}async _nextv(Z,$){let Y=[];while(Y.length<Z){let J=await this._next($);if(J!==void 0)Y.push(J);else{this.#X=!0;break}}return Y}async all(Z){Z=d0(Z,p0),this.#j();try{if(this.#X||this.#q>=this.#J)return[];let $=await this._all(Z);try{this[t]($)}catch(Y){throw new U0(Y)}return this.#q+=$.length,$}catch($){this.#W(),await this.#N($)}finally{if(this.#X=!0,this.#Z)this.#W(),await this.close()}}async _all(Z){let $=this.#q,Y=[];while(!0){let J=this.#J<1/0?Math.min(1000,this.#J-$):1000;if(J<=0)return Y;let Q=await this._nextv(J,Z);if(Q.length===0)return Y;Y.push.apply(Y,Q),$+=Q.length}}seek(Z,$){if($=d0($,p0),this.#Y!==null);else if(this.#Z)throw new r("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});else{let Y=this.db.keyEncoding($.keyEncoding||this[O]),J=Y.format;if($.keyEncoding!==J)$={...$,keyEncoding:J};let Q=this.db.prefixKey(Y.encode(Z),J,!1);this._seek(Q,$),this.#X=!1}}_seek(Z,$){throw new r("Iterator does not implement seek()",{code:"LEVEL_NOT_SUPPORTED"})}async close(){if(this.#Y!==null)return this.#Y.catch(_Z);if(this.#Y=new Promise((Z,$)=>{this.#$=()=>{this.#$=null,this.#w().then(Z,$)}}),!this.#Z)this.#$();return this.#Y}async _close(){}async*[Symbol.asyncIterator](){try{let Z;while((Z=await this.next())!==void 0)yield Z}catch(Z){await this.#N(Z)}finally{await this.close()}}#j(){if(this.#Y!==null)throw new r("Iterator is not open: cannot read after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"});else if(this.#Z)throw new r("Iterator is busy: cannot read until previous read has completed",{code:"LEVEL_ITERATOR_BUSY"});else if(this.#G?.aborted)throw new LZ;this.#Q?.ref(),this.#Z=!0}#W(){this.#Z=!1,this.#$?.(),this.#Q?.unref()}async#w(){await this._close(),this.db.detachResource(this)}async#N(Z){try{await this.close()}catch($){throw VZ([Z,$])}throw Z}}if(typeof Symbol.asyncDispose==="symbol")e.prototype[Symbol.asyncDispose]=async function(){return this.close()};class _0 extends e{#Z;#$;constructor(Z,$){super(Z,$);this.#Z=$.keys!==!1,this.#$=$.values!==!1}[V0](Z){let $=Z[0],Y=Z[1];if($!==void 0)Z[0]=this.#Z?this[O].decode($):void 0;if(Y!==void 0)Z[1]=this.#$?this[f].decode(Y):void 0;return Z}[t](Z){let $=this[O],Y=this[f];for(let J of Z){let Q=J[0],q=J[1];if(Q!==void 0)J[0]=this.#Z?$.decode(Q):void 0;if(q!==void 0)J[1]=this.#$?Y.decode(q):void 0}}}class t2 extends e{[V0](Z){return this[O].decode(Z)}[t](Z){let $=this[O];for(let Y=0;Y<Z.length;Y++){let J=Z[Y];if(J!==void 0)Z[Y]=$.decode(J)}}}class e2 extends e{[V0](Z){return this[f].decode(Z)}[t](Z){let $=this[f];for(let Y=0;Y<Z.length;Y++){let J=Z[Y];if(J!==void 0)Z[Y]=$.decode(J)}}}class U0 extends r{constructor(Z){super("Iterator could not decode data",{code:"LEVEL_DECODE_ERROR",cause:Z})}}_0.keyEncoding=O;_0.valueEncoding=f;RZ.AbstractIterator=_0;RZ.AbstractKeyIterator=t2;RZ.AbstractValueIterator=e2});var o2=w((TZ)=>{var{AbstractKeyIterator:BZ,AbstractValueIterator:SZ}=v(),b=Symbol("iterator"),a0=Symbol("handleOne"),L0=Symbol("handleMany");class s0 extends BZ{constructor(Z,$){super(Z,$);this[b]=Z.iterator({...$,keys:!0,values:!1})}[a0](Z){return Z[0]}[L0](Z){for(let $=0;$<Z.length;$++)Z[$]=Z[$][0]}}class i0 extends SZ{constructor(Z,$){super(Z,$);this[b]=Z.iterator({...$,keys:!1,values:!0})}[a0](Z){return Z[1]}[L0](Z){for(let $=0;$<Z.length;$++)Z[$]=Z[$][1]}}for(let Z of[s0,i0])Z.prototype._next=async function(){let $=await this[b].next();return $===void 0?$:this[a0]($)},Z.prototype._nextv=async function($,Y){let J=await this[b].nextv($,Y);return this[L0](J),J},Z.prototype._all=async function($){let Y=await this[b].all($);return this[L0](Y),Y},Z.prototype._seek=function($,Y){this[b].seek($,Y)},Z.prototype._close=async function(){return this[b].close()};TZ.DefaultKeyIterator=s0;TZ.DefaultValueIterator=i0});var Z1=w((IZ)=>{var{AbstractIterator:xZ,AbstractKeyIterator:CZ,AbstractValueIterator:DZ}=v(),n0=S(),K=Symbol("nut"),R0=Symbol("undefer"),K0=Symbol("factory"),h=Symbol("signalOptions");class r0 extends xZ{constructor(Z,$){super(Z,$);this[K]=null,this[K0]=()=>Z.iterator($),this[h]={signal:$.signal},this.db.defer(()=>this[R0](),this[h])}}class t0 extends CZ{constructor(Z,$){super(Z,$);this[K]=null,this[K0]=()=>Z.keys($),this[h]={signal:$.signal},this.db.defer(()=>this[R0](),this[h])}}class e0 extends DZ{constructor(Z,$){super(Z,$);this[K]=null,this[K0]=()=>Z.values($),this[h]={signal:$.signal},this.db.defer(()=>this[R0](),this[h])}}for(let Z of[r0,t0,e0])Z.prototype[R0]=function(){if(this.db.status==="open")this[K]=this[K0]()},Z.prototype._next=async function(){if(this[K]!==null)return this[K].next();else if(this.db.status==="opening")return this.db.deferAsync(()=>this._next(),this[h]);else throw new n0("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})},Z.prototype._nextv=async function($,Y){if(this[K]!==null)return this[K].nextv($,Y);else if(this.db.status==="opening")return this.db.deferAsync(()=>this._nextv($,Y),this[h]);else throw new n0("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})},Z.prototype._all=async function($){if(this[K]!==null)return this[K].all();else if(this.db.status==="opening")return this.db.deferAsync(()=>this._all($),this[h]);else throw new n0("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})},Z.prototype._seek=function($,Y){if(this[K]!==null)this[K]._seek($,Y);else if(this.db.status==="opening")this.db.defer(()=>this._seek($,Y),this[h])},Z.prototype._close=async function(){if(this[K]!==null)return this[K].close();else if(this.db.status==="opening")return this.db.deferAsync(()=>this._close())};IZ.DeferredIterator=r0;IZ.DeferredKeyIterator=t0;IZ.DeferredValueIterator=e0});var P0=w((EZ)=>{EZ.prefixDescendantKey=function(Z,$,Y,J){while(Y!==null&&Y!==J)Z=Y.prefixKey(Z,$,!0),Y=Y.parent;return Z};EZ.isDescendant=function(Z,$){while(!0){if(Z.parent==null)return!1;if(Z.parent===$)return!0;Z=Z.parent}}});var o0=w((yZ)=>{var{prefixDescendantKey:bZ,isDescendant:gZ}=P0();class $1{#Z;#$;#Y;constructor(Z,$,Y){this.#Z=Z,this.#$=$,this.#Y=Y}add(Z){let $=Z.type==="put",Y=Z.sublevel!=null,J=Y?Z.sublevel:this.#Z;if(J._assertValidKey(Z.key),Z.keyEncoding=J.keyEncoding(Z.keyEncoding),$)J._assertValidValue(Z.value),Z.valueEncoding=J.valueEncoding(Z.valueEncoding);else if(Z.type!=="del")throw TypeError("A batch operation must have a type property that is 'put' or 'del'");let Q=Z.keyEncoding,q=Q.encode(Z.key),X=Q.format,j=Y&&!gZ(Z.sublevel,this.#Z)&&Z.sublevel!==this.#Z,W=Y&&!j?bZ(q,X,J,this.#Z):q;if(Y&&!j)Z.sublevel=null;let G=null;if(this.#Y!==null&&!j){if(G={...Z},G.encodedKey=W,Y)G.key=W,G.keyEncoding=this.#Z.keyEncoding(X);this.#Y.push(G)}if(Z.key=j?W:this.#Z.prefixKey(W,X,!0),Z.keyEncoding=X,$){let H=Z.valueEncoding,U=H.encode(Z.value),z=H.format;if(Z.value=U,Z.valueEncoding=z,G!==null){if(G.encodedValue=U,Y)G.value=U,G.valueEncoding=this.#Z.valueEncoding(z)}}return this.#$.push(Z),this}}yZ.PrewriteBatch=$1});var Y2=w((pZ)=>{var uZ=z0(),M0=S(),{getOptions:B0,emptyOptions:Z2,noop:cZ}=F(),{prefixDescendantKey:Y1,isDescendant:lZ}=P0(),{PrewriteBatch:dZ}=o0(),S0=Symbol("publicOperations"),o=Symbol("privateOperations");class $2{#Z="open";#$=0;#Y=null;#q;#G;#J;#X;#Q;constructor(Z,$){if(typeof Z!=="object"||Z===null)throw TypeError(`The first argument must be an abstract-level database, received ${Z===null?"null":typeof Z}`);let Y=Z.listenerCount("write")>0,J=!Z.hooks.prewrite.noop;if(this.#q=Y?[]:null,this.#Q=B0($,Z2).add===!0,J){let Q=new J1([],Y?[]:null);this.#X=Q,this.#J=new dZ(Z,Q[o],Q[S0]),this.#G=Z.hooks.prewrite.run}else this.#X=null,this.#J=null,this.#G=null;this.db=Z,this.db.attachResource(this)}get length(){if(this.#X!==null)return this.#$+this.#X.length;else return this.#$}put(Z,$,Y){this.#j(),Y=B0(Y,Z2);let J=Y.sublevel!=null,Q=J?Y.sublevel:this.db;Q._assertValidKey(Z),Q._assertValidValue($);let q={...Y,type:"put",key:Z,value:$,keyEncoding:Q.keyEncoding(Y.keyEncoding),valueEncoding:Q.valueEncoding(Y.valueEncoding)};if(this.#G!==null)try{this.#G(q,this.#J),q.keyEncoding=Q.keyEncoding(q.keyEncoding),q.valueEncoding=Q.valueEncoding(q.valueEncoding)}catch(V){throw new M0("The prewrite hook failed on batch.put()",{code:"LEVEL_HOOK_ERROR",cause:V})}let X=q.keyEncoding,j=X.encode(q.key),W=X.format,G=J&&!lZ(q.sublevel,this.db)&&q.sublevel!==this.db,H=J&&!G?Y1(j,W,Q,this.db):j,U=q.valueEncoding,z=U.encode(q.value),T=U.format;if(J&&!G)q.sublevel=null;if(this.#q!==null&&!G){let V={...q};if(V.encodedKey=H,V.encodedValue=z,J)V.key=H,V.value=z,V.keyEncoding=this.db.keyEncoding(W),V.valueEncoding=this.db.valueEncoding(T);this.#q.push(V)}if(q.key=G?H:this.db.prefixKey(H,W,!0),q.value=z,q.keyEncoding=W,q.valueEncoding=T,this.#Q)this._add(q);else this._put(q.key,z,q);return this.#$++,this}_put(Z,$,Y){}del(Z,$){this.#j(),$=B0($,Z2);let Y=$.sublevel!=null,J=Y?$.sublevel:this.db;J._assertValidKey(Z);let Q={...$,type:"del",key:Z,keyEncoding:J.keyEncoding($.keyEncoding)};if(this.#G!==null)try{this.#G(Q,this.#J),Q.keyEncoding=J.keyEncoding(Q.keyEncoding)}catch(G){throw new M0("The prewrite hook failed on batch.del()",{code:"LEVEL_HOOK_ERROR",cause:G})}let q=Q.keyEncoding,X=q.encode(Q.key),j=q.format,W=Y?Y1(X,j,J,this.db):X;if(Y)Q.sublevel=null;if(this.#q!==null){let G={...Q};if(G.encodedKey=W,Y)G.key=W,G.keyEncoding=this.db.keyEncoding(j);this.#q.push(G)}if(Q.key=this.db.prefixKey(W,j,!0),Q.keyEncoding=j,this.#Q)this._add(Q);else this._del(Q.key,Q);return this.#$++,this}_del(Z,$){}_add(Z){}clear(){if(this.#j(),this._clear(),this.#q!==null)this.#q=[];if(this.#X!==null)this.#X.clear();return this.#$=0,this}_clear(){}async write(Z){if(this.#j(),Z=B0(Z),this.#$===0)return this.close();else{this.#Z="writing";let $=this.#W();try{if(this.#X!==null){let Y=this.#X[S0],J=this.#X[o],Q=this.#X.length;for(let q=0;q<Q;q++){let X=J[q];if(this.#Q)this._add(X);else if(X.type==="put")this._put(X.key,X.value,X);else this._del(X.key,X)}if(Y!==null&&Q!==0)this.#q=this.#q.concat(Y)}await this._write(Z)}catch(Y){$();try{await this.#Y}catch(J){Y=uZ([Y,J])}throw Y}if($(),this.#q!==null)this.db.emit("write",this.#q);return this.#Y}}async _write(Z){}async close(){if(this.#Y!==null)return this.#Y.catch(cZ);else return this.#W()(),this.#Y}async _close(){}#j(){if(this.#Z!=="open")throw new M0("Batch is not open: cannot change operations after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});if(this.db.status!=="open")throw new M0("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})}#W(){let Z;return this.#Y=new Promise(($,Y)=>{Z=()=>{this.#w().then($,Y)}}),Z}async#w(){this.#Z="closing",await this._close(),this.db.detachResource(this)}}if(typeof Symbol.asyncDispose==="symbol")$2.prototype[Symbol.asyncDispose]=async function(){return this.close()};class J1{constructor(Z,$){this[o]=Z,this[S0]=$}get length(){return this[o].length}clear(){for(let Z of[S0,o]){let $=this[Z];if($!==null)$.splice(0,$.length)}}}pZ.AbstractChainedBatch=$2});var q1=w((iZ)=>{var{AbstractChainedBatch:sZ}=Y2();class Q1 extends sZ{#Z=[];constructor(Z){super(Z,{add:!0})}_add(Z){this.#Z.push(Z)}_clear(){this.#Z=[]}async _write(Z){return this.db._batch(this.#Z,Z)}}iZ.DefaultChainedBatch=Q1});var W1=w((tZ)=>{var{noop:rZ}=F();class G1{constructor(){this.postopen=new T0({async:!0}),this.prewrite=new T0({async:!1}),this.newsub=new T0({async:!1})}}class T0{#Z=new Set;#$;constructor(Z){this.#$=Z.async,this.noop=!0,this.run=this.#Y()}add(Z){X1(Z),this.#Z.add(Z),this.noop=!1,this.run=this.#Y()}delete(Z){X1(Z),this.#Z.delete(Z),this.noop=this.#Z.size===0,this.run=this.#Y()}#Y(){if(this.noop)return rZ;else if(this.#Z.size===1){let[Z]=this.#Z;return Z}else if(this.#$)return async function($,...Y){for(let J of $)await J(...Y)}.bind(null,Array.from(this.#Z));else return function($,...Y){for(let J of $)J(...Y)}.bind(null,Array.from(this.#Z))}}var X1=function(Z){if(typeof Z!=="function")throw TypeError(`The first argument must be a function, received ${Z===null?"null":typeof Z}`)};tZ.DatabaseHooks=G1});var j1=w((Z$)=>{var{deprecate:oZ}=F();Z$.EventMonitor=class{constructor($){this.write=!1;let Y=(Q)=>{if(Q==="write")this.write=!0;if(Q==="put"||Q==="del"||Q==="batch")oZ(`The '${Q}' event has been removed in favor of 'write'`)},J=(Q)=>{if(Q==="write")this.write=$.listenerCount("write")>0};$.on("newListener",Y),$.on("removeListener",J)}}});var N1=w((Q$)=>{var{getOptions:Y$,emptyOptions:J$}=F(),{AbortError:H1}=l0();class J2{constructor(Z,$){this.fn=Z,this.signal=$}}class w1{#Z;#$;constructor(){this.#Z=[],this.#$=new Set}add(Z,$){$=Y$($,J$);let Y=$.signal;if(Y==null){this.#Z.push(new J2(Z,null));return}if(Y.aborted){Z(new H1);return}if(!this.#$.has(Y))this.#$.add(Y),Y.addEventListener("abort",this.#Y,{once:!0});this.#Z.push(new J2(Z,Y))}drain(){let Z=this.#Z,$=this.#$;this.#Z=[],this.#$=new Set;for(let Y of $)Y.removeEventListener("abort",this.#Y);for(let Y of Z)Y.fn.call(null)}#Y=(Z)=>{let $=Z.target,Y=new H1,J=[];this.#Z=this.#Z.filter(function(Q){if(Q.signal!==null&&Q.signal===$)return J.push(Q),!1;else return!0}),this.#$.delete($);for(let Q of J)Q.fn.call(null,Y)}}Q$.DeferredQueue=w1});var U1=w((M5,z1)=>{var X$=Object.prototype.hasOwnProperty,G$=new Set(["lt","lte","gt","gte"]);z1.exports=function(Z,$){let Y={};for(let J in Z){if(!X$.call(Z,J))continue;if(J==="keyEncoding"||J==="valueEncoding")continue;if(G$.has(J))Y[J]=$.encode(Z[J]);else Y[J]=Z[J]}return Y.reverse=!!Y.reverse,Y.limit=Number.isInteger(Y.limit)&&Y.limit>=0?Y.limit:-1,Y}});var R1=w((w$)=>{var{AbstractIterator:W$,AbstractKeyIterator:j$,AbstractValueIterator:H$}=v();class V1 extends W${#Z;#$;constructor(Z,$,Y,J){super(Z,$);this.#Z=Y,this.#$=J}async _next(){let Z=await this.#Z.next();if(Z!==void 0){let $=Z[0];if($!==void 0)Z[0]=this.#$($)}return Z}async _nextv(Z,$){let Y=await this.#Z.nextv(Z,$),J=this.#$;for(let Q of Y){let q=Q[0];if(q!==void 0)Q[0]=J(q)}return Y}async _all(Z){let $=await this.#Z.all(Z),Y=this.#$;for(let J of $){let Q=J[0];if(Q!==void 0)J[0]=Y(Q)}return $}_seek(Z,$){this.#Z.seek(Z,$)}async _close(){return this.#Z.close()}}class _1 extends j${#Z;#$;constructor(Z,$,Y,J){super(Z,$);this.#Z=Y,this.#$=J}async _next(){let Z=await this.#Z.next();return Z===void 0?Z:this.#$(Z)}async _nextv(Z,$){let Y=await this.#Z.nextv(Z,$),J=this.#$;for(let Q=0;Q<Y.length;Q++){let q=Y[Q];if(q!==void 0)Y[Q]=J(q)}return Y}async _all(Z){let $=await this.#Z.all(Z),Y=this.#$;for(let J=0;J<$.length;J++){let Q=$[J];if(Q!==void 0)$[J]=Y(Q)}return $}_seek(Z,$){this.#Z.seek(Z,$)}async _close(){return this.#Z.close()}}class L1 extends H${#Z;constructor(Z,$,Y){super(Z,$);this.#Z=Y}async _next(){return this.#Z.next()}async _nextv(Z,$){return this.#Z.nextv(Z,$)}async _all(Z){return this.#Z.all(Z)}_seek(Z,$){this.#Z.seek(Z,$)}async _close(){return this.#Z.close()}}w$.AbstractSublevelIterator=V1;w$.AbstractSublevelKeyIterator=_1;w$.AbstractSublevelValueIterator=L1});var B1=w((S5,M1)=>{var V$=S(),{Buffer:q2}=B("buffer")||{},{AbstractSublevelIterator:_$,AbstractSublevelKeyIterator:L$,AbstractSublevelValueIterator:R$}=R1(),E=Symbol("root"),K1=new TextEncoder,K$={separator:"!"};M1.exports=function({AbstractLevel:Z}){class $ extends Z{#Z;#$;#Y;#q;#G;#J;#X;static defaults(Y){if(Y==null)return K$;else if(!Y.separator)return{...Y,separator:"!"};else return Y}constructor(Y,J,Q){let{separator:q,manifest:X,...j}=$.defaults(Q),W=[].concat(J).map((V)=>M$(V,q)),G=q.charCodeAt(0)+1,H=Y[E]||Y;if(!W.every((V)=>K1.encode(V).every((m)=>m>G&&m<127)))throw new V$(`Sublevel name must use bytes > ${G} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(P$(Y,X),j);let U=W.map((V)=>q+V+q).join(""),z=(Y.prefix||"")+U,T=z.slice(0,-1)+String.fromCharCode(G);this[E]=H,this.#J=Y,this.#Y=W,this.#q=Y.prefix?Y.path().concat(W):W,this.#Z=new A0(z),this.#G=new A0(T),this.#$=new A0(U),this.#X=new P1}prefixKey(Y,J,Q){let q=Q?this.#$:this.#Z;if(J==="utf8")return q.utf8+Y;else if(Y.byteLength===0)return q[J];else if(J==="view"){let X=q.view,j=new Uint8Array(X.byteLength+Y.byteLength);return j.set(X,0),j.set(Y,X.byteLength),j}else{let X=q.buffer;return q2.concat([X,Y],X.byteLength+Y.byteLength)}}#Q(Y,J){if(Y.gte!==void 0)Y.gte=this.prefixKey(Y.gte,J,!1);else if(Y.gt!==void 0)Y.gt=this.prefixKey(Y.gt,J,!1);else Y.gte=this.#Z[J];if(Y.lte!==void 0)Y.lte=this.prefixKey(Y.lte,J,!1);else if(Y.lt!==void 0)Y.lt=this.prefixKey(Y.lt,J,!1);else Y.lte=this.#G[J]}get prefix(){return this.#Z.utf8}get db(){return this[E]}get parent(){return this.#J}path(Y=!1){return Y?this.#Y:this.#q}async _open(Y){await this.#J.open({passive:!0}),this.#J.attachResource(this)}async _close(){this.#J.detachResource(this)}async _put(Y,J,Q){return this.#J.put(Y,J,Q)}async _get(Y,J){return this.#J.get(Y,J)}_getSync(Y,J){return this.#J.getSync(Y,J)}async _getMany(Y,J){return this.#J.getMany(Y,J)}async _has(Y,J){return this.#J.has(Y,J)}async _hasMany(Y,J){return this.#J.hasMany(Y,J)}async _del(Y,J){return this.#J.del(Y,J)}async _batch(Y,J){return this.#J.batch(Y,J)}async _clear(Y){return this.#Q(Y,Y.keyEncoding),this[E].clear(Y)}_iterator(Y){this.#Q(Y,Y.keyEncoding);let J=this[E].iterator(Y),Q=this.#X.get(this.#Z.utf8.length,Y.keyEncoding);return new _$(this,Y,J,Q)}_keys(Y){this.#Q(Y,Y.keyEncoding);let J=this[E].keys(Y),Q=this.#X.get(this.#Z.utf8.length,Y.keyEncoding);return new L$(this,Y,J,Q)}_values(Y){this.#Q(Y,Y.keyEncoding);let J=this[E].values(Y);return new R$(this,Y,J)}_snapshot(Y){return this[E].snapshot(Y)}}return{AbstractSublevel:$}};var P$=function(Z,$){return{...Z.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...$,encodings:{utf8:Q2(Z,"utf8"),buffer:Q2(Z,"buffer"),view:Q2(Z,"view")}}},Q2=function(Z,$){return Z.supports.encodings[$]?Z.keyEncoding($).name===$:!1};class A0{constructor(Z){this.utf8=Z,this.view=K1.encode(Z),this.buffer=q2?q2.from(this.view.buffer,0,this.view.byteLength):{}}}class P1{constructor(){this.cache=new Map}get(Z,$){let Y=this.cache.get($);if(Y===void 0){if($==="view")Y=function(J,Q){return Q.subarray(J)}.bind(null,Z);else Y=function(J,Q){return Q.slice(J)}.bind(null,Z);this.cache.set($,Y)}return Y}}var M$=function(Z,$){let Y=0,J=Z.length;while(Y<J&&Z[Y]===$)Y++;while(J>Y&&Z[J-1]===$)J--;return Z.slice(Y,J)}});var H2=w((k$)=>{var{supports:B$}=v2(),{Transcoder:S$}=d2(),{EventEmitter:T$}=B("events"),L=S(),X2=z0(),{AbstractIterator:g}=v(),{DefaultKeyIterator:A$,DefaultValueIterator:h$}=o2(),{DeferredIterator:x$,DeferredKeyIterator:C$,DeferredValueIterator:D$}=Z1(),{DefaultChainedBatch:I$}=q1(),{DatabaseHooks:F$}=W1(),{PrewriteBatch:O$}=o0(),{EventMonitor:v$}=j1(),{getOptions:x,noop:G2,emptyOptions:E$,resolvedPromise:S1}=F(),{prefixDescendantKey:m$,isDescendant:f$}=P0(),{DeferredQueue:b$}=N1(),h0=U1();class C0 extends T${#Z="opening";#$=!0;#Y=null;#q=!1;#G;#J;#X;#Q;#j;#W;#w;#N;constructor(Z,$){super();if(typeof Z!=="object"||Z===null)throw TypeError("The first argument 'manifest' must be an object");$=x($);let{keyEncoding:Y,valueEncoding:J,passive:Q,...q}=$;this.#G=new Set,this.#J=new b$,this.#X=q;let X=Z.snapshots!==!1&&Z.implicitSnapshots!==!1;this.hooks=new F$,this.supports=B$(Z,{deferredOpen:!0,seek:!0,implicitSnapshots:X,permanence:Z.permanence!==!1,encodings:Z.encodings||{},events:{...Z.events,opening:!0,open:!0,closing:!0,closed:!0,write:!0,clear:!0}}),this.#N=new v$(this),this.#j=new S$(g$(this)),this.#W=this.#j.encoding(Y||"utf8"),this.#w=this.#j.encoding(J||"utf8");for(let j of this.#j.encodings())if(!this.supports.encodings[j.commonName])this.supports.encodings[j.commonName]=!0;this.#Q={empty:E$,entry:Object.freeze({keyEncoding:this.#W.commonName,valueEncoding:this.#w.commonName}),entryFormat:Object.freeze({keyEncoding:this.#W.format,valueEncoding:this.#w.format}),key:Object.freeze({keyEncoding:this.#W.commonName}),keyFormat:Object.freeze({keyEncoding:this.#W.format}),owner:Object.freeze({owner:this})},queueMicrotask(()=>{if(this.#$)this.open({passive:!1}).catch(G2)})}get status(){return this.#Z}get parent(){return null}keyEncoding(Z){return this.#j.encoding(Z??this.#W)}valueEncoding(Z){return this.#j.encoding(Z??this.#w)}async open(Z){Z={...this.#X,...x(Z)},Z.createIfMissing=Z.createIfMissing!==!1,Z.errorIfExists=!!Z.errorIfExists;let $=this.hooks.postopen.noop?null:this.hooks.postopen.run,Y=Z.passive;if(Y&&this.#$)await void 0;this.#z();while(this.#Y!==null)await this.#Y.catch(G2);if(this.#z(),Y){if(this.#Z!=="open")throw new x0}else if(this.#Z==="closed"||this.#$){this.#$=!1,this.#Y=S1,this.#Y=(async()=>{this.#Z="opening";try{this.emit("opening"),await this._open(Z)}catch(J){this.#Z="closed",this.#J.drain();try{await this.#U()}catch(Q){J=X2([J,Q])}throw new x0(J)}if(this.#Z="open",$!==null){let J;try{this.#q=!0,await $(Z)}catch(Q){J=T1(Q)}finally{this.#q=!1}if(J){this.#Z="closing",this.#J.drain();try{await this.#U(),await this._close()}catch(Q){this.#q=!0,J=X2([J,Q])}throw this.#Z="closed",new L("The postopen hook failed on open()",{code:"LEVEL_HOOK_ERROR",cause:J})}}this.#J.drain(),this.emit("open")})();try{await this.#Y}finally{this.#Y=null}}else if(this.#Z!=="open")throw new x0}async _open(Z){}async close(){this.#z();while(this.#Y!==null)await this.#Y.catch(G2);if(this.#z(),this.#Z==="open"||this.#$){let Z=this.#$;this.#$=!1,this.#Y=S1,this.#Y=(async()=>{this.#Z="closing",this.#J.drain();try{if(this.emit("closing"),await this.#U(),!Z)await this._close()}catch($){throw this.#Z="open",this.#J.drain(),new j2($)}this.#Z="closed",this.#J.drain(),this.emit("closed")})();try{await this.#Y}finally{this.#Y=null}}else if(this.#Z!=="closed")throw new j2}async#U(){if(this.#G.size===0)return;let Z=Array.from(this.#G),$=Z.map(y$),Y=await Promise.allSettled($),J=[];for(let Q=0;Q<Y.length;Q++)if(Y[Q].status==="fulfilled")this.#G.delete(Z[Q]);else J.push(T1(Y[Q].reason));if(J.length>0)throw X2(J)}async _close(){}async get(Z,$){if($=x($,this.#Q.entry),this.#Z==="opening")return this.deferAsync(()=>this.get(Z,$));this.#H(),this._assertValidKey(Z);let Y=$.snapshot,J=this.keyEncoding($.keyEncoding),Q=this.valueEncoding($.valueEncoding),q=J.format,X=Q.format;if($===this.#Q.entry)$=this.#Q.entryFormat;else if($.keyEncoding!==q||$.valueEncoding!==X)$={...$,keyEncoding:q,valueEncoding:X};let j=J.encode(Z),W=this.prefixKey(j,q,!0);Y?.ref();let G;try{G=await this._get(W,$)}finally{Y?.unref()}try{return G===void 0?G:Q.decode(G)}catch(H){throw new L("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:H})}}async _get(Z,$){return}getSync(Z,$){if(this.status!=="open")throw new L("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});if(this._assertValidKey(Z),$==null){let H=this.#W.encode(Z),U=this.prefixKey(H,this.#W.format,!0),z=this._getSync(U,this.#Q.entryFormat);try{return z!==void 0?this.#w.decode(z):void 0}catch(T){throw new L("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:T})}}let Y=$.snapshot,J=this.keyEncoding($.keyEncoding),Q=this.valueEncoding($.valueEncoding),q=J.format,X=Q.format;if($.keyEncoding!==q||$.valueEncoding!==X)$={...$,keyEncoding:q,valueEncoding:X};let j=J.encode(Z),W=this.prefixKey(j,q,!0),G;Y?.ref();try{G=this._getSync(W,$)}finally{Y?.unref()}try{return G!==void 0?Q.decode(G):void 0}catch(H){throw new L("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:H})}}_getSync(Z,$){throw new L("Database does not support getSync()",{code:"LEVEL_NOT_SUPPORTED"})}async getMany(Z,$){if($=x($,this.#Q.entry),this.#Z==="opening")return this.deferAsync(()=>this.getMany(Z,$));if(this.#H(),!Array.isArray(Z))throw TypeError("The first argument 'keys' must be an array");if(Z.length===0)return[];let Y=$.snapshot,J=this.keyEncoding($.keyEncoding),Q=this.valueEncoding($.valueEncoding),q=J.format,X=Q.format;if($===this.#Q.entry)$=this.#Q.entryFormat;else if($.keyEncoding!==q||$.valueEncoding!==X)$={...$,keyEncoding:q,valueEncoding:X};let j=Array(Z.length);for(let G=0;G<Z.length;G++){let H=Z[G];this._assertValidKey(H),j[G]=this.prefixKey(J.encode(H),q,!0)}Y?.ref();let W;try{W=await this._getMany(j,$)}finally{Y?.unref()}try{for(let G=0;G<W.length;G++)if(W[G]!==void 0)W[G]=Q.decode(W[G])}catch(G){throw new L(`Could not decode one or more of ${W.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:G})}return W}async _getMany(Z,$){return Array(Z.length).fill(void 0)}async has(Z,$){if($=x($,this.#Q.key),this.#Z==="opening")return this.deferAsync(()=>this.has(Z,$));this.#H(),this._assertValidKey(Z);let Y=$.snapshot,J=this.keyEncoding($.keyEncoding),Q=J.format;if($===this.#Q.key)$=this.#Q.keyFormat;else if($.keyEncoding!==Q)$={...$,keyEncoding:Q};let q=J.encode(Z),X=this.prefixKey(q,Q,!0);Y?.ref();try{return this._has(X,$)}finally{Y?.unref()}}async _has(Z,$){throw new L("Database does not support has()",{code:"LEVEL_NOT_SUPPORTED"})}async hasMany(Z,$){if($=x($,this.#Q.key),this.#Z==="opening")return this.deferAsync(()=>this.hasMany(Z,$));if(this.#H(),!Array.isArray(Z))throw TypeError("The first argument 'keys' must be an array");if(Z.length===0)return[];let Y=$.snapshot,J=this.keyEncoding($.keyEncoding),Q=J.format;if($===this.#Q.key)$=this.#Q.keyFormat;else if($.keyEncoding!==Q)$={...$,keyEncoding:Q};let q=Array(Z.length);for(let X=0;X<Z.length;X++){let j=Z[X];this._assertValidKey(j),q[X]=this.prefixKey(J.encode(j),Q,!0)}Y?.ref();try{return this._hasMany(q,$)}finally{Y?.unref()}}async _hasMany(Z,$){throw new L("Database does not support hasMany()",{code:"LEVEL_NOT_SUPPORTED"})}async put(Z,$,Y){if(!this.hooks.prewrite.noop)return this.batch([{type:"put",key:Z,value:$}],Y);if(Y=x(Y,this.#Q.entry),this.#Z==="opening")return this.deferAsync(()=>this.put(Z,$,Y));this.#H(),this._assertValidKey(Z),this._assertValidValue($);let J=this.keyEncoding(Y.keyEncoding),Q=this.valueEncoding(Y.valueEncoding),q=J.format,X=Q.format,j=this.#N.write,W=Y;if(Y===this.#Q.entry)Y=this.#Q.entryFormat;else if(Y.keyEncoding!==q||Y.valueEncoding!==X)Y={...Y,keyEncoding:q,valueEncoding:X};let G=J.encode(Z),H=this.prefixKey(G,q,!0),U=Q.encode($);if(await this._put(H,U,Y),j){let z={...W,type:"put",key:Z,value:$,keyEncoding:J,valueEncoding:Q,encodedKey:G,encodedValue:U};this.emit("write",[z])}}async _put(Z,$,Y){}async del(Z,$){if(!this.hooks.prewrite.noop)return this.batch([{type:"del",key:Z}],$);if($=x($,this.#Q.key),this.#Z==="opening")return this.deferAsync(()=>this.del(Z,$));this.#H(),this._assertValidKey(Z);let Y=this.keyEncoding($.keyEncoding),J=Y.format,Q=this.#N.write,q=$;if($===this.#Q.key)$=this.#Q.keyFormat;else if($.keyEncoding!==J)$={...$,keyEncoding:J};let X=Y.encode(Z),j=this.prefixKey(X,J,!0);if(await this._del(j,$),Q){let W={...q,type:"del",key:Z,keyEncoding:Y,encodedKey:X};this.emit("write",[W])}}async _del(Z,$){}batch(Z,$){if(!arguments.length)return this.#H(),this._chainedBatch();return $=x($,this.#Q.empty),this.#V(Z,$)}async#V(Z,$){if(this.#Z==="opening")return this.deferAsync(()=>this.#V(Z,$));if(this.#H(),!Array.isArray(Z))throw TypeError("The first argument 'operations' must be an array");if(Z.length===0)return;let Y=Z.length,J=!this.hooks.prewrite.noop,Q=this.#N.write,q=Q?Array(Y):null,X=Array(Y),j=J?new O$(this,X,q):null;for(let W=0;W<Y;W++){let G={...$,...Z[W]},H=G.type==="put",U=G.sublevel!=null,z=U?G.sublevel:this;if(z._assertValidKey(G.key),G.keyEncoding=z.keyEncoding(G.keyEncoding),H)z._assertValidValue(G.value),G.valueEncoding=z.valueEncoding(G.valueEncoding);else if(G.type!=="del")throw TypeError("A batch operation must have a type property that is 'put' or 'del'");if(J)try{if(this.hooks.prewrite.run(G,j),G.keyEncoding=z.keyEncoding(G.keyEncoding),H)G.valueEncoding=z.valueEncoding(G.valueEncoding)}catch(X0){throw new L("The prewrite hook failed on batch()",{code:"LEVEL_HOOK_ERROR",cause:X0})}let T=G.keyEncoding,V=T.encode(G.key),m=T.format,d=U&&!f$(G.sublevel,this)&&G.sublevel!==this,q0=U&&!d?m$(V,m,z,this):V;if(U&&!d)G.sublevel=null;let I=null;if(Q&&!d){if(I={...G},I.encodedKey=q0,U)I.key=q0,I.keyEncoding=this.keyEncoding(m);q[W]=I}if(G.key=d?q0:this.prefixKey(q0,m,!0),G.keyEncoding=m,H){let X0=G.valueEncoding,O0=X0.encode(G.value),T2=X0.format;if(G.value=O0,G.valueEncoding=T2,Q&&!d){if(I.encodedValue=O0,U)I.value=O0,I.valueEncoding=this.valueEncoding(T2)}}X[W]=G}if(await this._batch(X,$),Q)this.emit("write",q)}async _batch(Z,$){}sublevel(Z,$){let Y=W2.defaults($),J=this._sublevel(Z,Y);if(!this.hooks.newsub.noop)try{this.hooks.newsub.run(J,Y)}catch(Q){throw new L("The newsub hook failed on sublevel()",{code:"LEVEL_HOOK_ERROR",cause:Q})}return J}_sublevel(Z,$){return new W2(this,Z,$)}prefixKey(Z,$,Y){return Z}async clear(Z){if(Z=x(Z,this.#Q.empty),this.#Z==="opening")return this.deferAsync(()=>this.clear(Z));this.#H();let $=Z,Y=this.keyEncoding(Z.keyEncoding),J=Z.snapshot;if(Z=h0(Z,Y),Z.keyEncoding=Y.format,Z.limit!==0){J?.ref();try{await this._clear(Z)}finally{J?.unref()}this.emit("clear",$)}}async _clear(Z){}iterator(Z){let $=this.keyEncoding(Z?.keyEncoding),Y=this.valueEncoding(Z?.valueEncoding);if(Z=h0(Z,$),Z.keys=Z.keys!==!1,Z.values=Z.values!==!1,Z[g.keyEncoding]=$,Z[g.valueEncoding]=Y,Z.keyEncoding=$.format,Z.valueEncoding=Y.format,this.#Z==="opening")return new x$(this,Z);return this.#H(),this._iterator(Z)}_iterator(Z){return new g(this,Z)}keys(Z){let $=this.keyEncoding(Z?.keyEncoding),Y=this.valueEncoding(Z?.valueEncoding);if(Z=h0(Z,$),Z[g.keyEncoding]=$,Z[g.valueEncoding]=Y,Z.keyEncoding=$.format,Z.valueEncoding=Y.format,this.#Z==="opening")return new C$(this,Z);return this.#H(),this._keys(Z)}_keys(Z){return new A$(this,Z)}values(Z){let $=this.keyEncoding(Z?.keyEncoding),Y=this.valueEncoding(Z?.valueEncoding);if(Z=h0(Z,$),Z[g.keyEncoding]=$,Z[g.valueEncoding]=Y,Z.keyEncoding=$.format,Z.valueEncoding=Y.format,this.#Z==="opening")return new D$(this,Z);return this.#H(),this._values(Z)}_values(Z){return new h$(this,Z)}snapshot(Z){if(this.#H(),typeof Z!=="object"||Z===null)Z=this.#Q.owner;else if(Z.owner==null)Z={...Z,owner:this};return this._snapshot(Z)}_snapshot(Z){throw new L("Database does not support explicit snapshots",{code:"LEVEL_NOT_SUPPORTED"})}defer(Z,$){if(typeof Z!=="function")throw TypeError("The first argument must be a function");this.#J.add(function(Y){if(!Y)Z()},$)}deferAsync(Z,$){if(typeof Z!=="function")throw TypeError("The first argument must be a function");return new Promise((Y,J)=>{this.#J.add(function(Q){if(Q)J(Q);else Z().then(Y,J)},$)})}attachResource(Z){if(typeof Z!=="object"||Z===null||typeof Z.close!=="function")throw TypeError("The first argument must be a resource object");this.#G.add(Z)}detachResource(Z){this.#G.delete(Z)}_chainedBatch(){return new I$(this)}_assertValidKey(Z){if(Z===null||Z===void 0)throw new L("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_assertValidValue(Z){if(Z===null||Z===void 0)throw new L("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}#H(){if(this.#Z!=="open")throw new L("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})}#z(){if(this.#q)throw new L("Database status is locked",{code:"LEVEL_STATUS_LOCKED"})}}var{AbstractSublevel:W2}=B1()({AbstractLevel:C0});k$.AbstractLevel=C0;k$.AbstractSublevel=W2;if(typeof Symbol.asyncDispose==="symbol")C0.prototype[Symbol.asyncDispose]=async function(){return this.close()};var g$=function(Z){return Object.keys(Z.supports.encodings).filter(($)=>!!Z.supports.encodings[$])},y$=function(Z){return Z.close()},T1=function(Z){if(Z instanceof Error)return Z;if(Object.prototype.toString.call(Z)==="[object Error]")return Z;return TypeError(`Promise rejection reason must be an Error, received ${Z===null?"null":typeof Z}`)};class x0 extends L{constructor(Z){super("Database failed to open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:Z})}}class j2 extends L{constructor(Z){super("Database failed to close",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:Z})}}});var A1=w((a$)=>{var l$=S(),{noop:d$}=F();class w2{#Z=!0;#$=0;#Y=null;#q=null;#G;constructor(Z){let $=Z.owner;if(typeof $!=="object"||$===null)throw TypeError(`Owner must be an abstract-level database, received ${$===null?"null":typeof $}`);this.#G=$,this.#G.attachResource(this)}ref(){if(!this.#Z)throw new l$("Snapshot is not open: cannot use snapshot after close()",{code:"LEVEL_SNAPSHOT_NOT_OPEN"});this.#$++}unref(){if(--this.#$===0)this.#Y?.()}async close(){if(this.#q!==null)return this.#q.catch(d$);if(this.#Z=!1,this.#q=new Promise((Z,$)=>{this.#Y=()=>{this.#Y=null,p$(this,this.#G).then(Z,$)}}),this.#$===0)this.#Y();return this.#q}async _close(){}}if(typeof Symbol.asyncDispose==="symbol")w2.prototype[Symbol.asyncDispose]=async function(){return this.close()};var p$=async function(Z,$){await Z._close(),$.detachResource(Z)};a$.AbstractSnapshot=w2});var D0=w((i$)=>{i$.AbstractLevel=H2().AbstractLevel;i$.AbstractSublevel=H2().AbstractSublevel;i$.AbstractIterator=v().AbstractIterator;i$.AbstractKeyIterator=v().AbstractKeyIterator;i$.AbstractValueIterator=v().AbstractValueIterator;i$.AbstractChainedBatch=Y2().AbstractChainedBatch;i$.AbstractSnapshot=A1().AbstractSnapshot});var u1=w((x5,k1)=>{var D1=B("fs"),D=B("path"),I1=B("os"),F1=typeof __webpack_require__==="function"?__non_webpack_require__:B,YY=process.config&&process.config.variables||{},JY=!!process.env.PREBUILDS_ONLY,h1=process.versions.modules,N2=XY()?"electron":qY()?"node-webkit":"node",z2=process.env.npm_config_arch||I1.arch(),U2=process.env.npm_config_platform||I1.platform(),O1=process.env.LIBC||(GY(U2)?"musl":"glibc"),V2=process.env.ARM_VERSION||(z2==="arm64"?"8":YY.arm_version)||"",v1=(process.versions.uv||"").split(".")[0];k1.exports=C;function C(Z){return F1(C.resolve(Z))}C.resolve=C.path=function(Z){Z=D.resolve(Z||".");try{var $=F1(D.join(Z,"package.json")).name.toUpperCase().replace(/-/g,"_");if(process.env[$+"_PREBUILD"])Z=process.env[$+"_PREBUILD"]}catch(W){}if(!JY){var Y=x1(D.join(Z,"build/Release"),C1);if(Y)return Y;var J=x1(D.join(Z,"build/Debug"),C1);if(J)return J}var Q=j(Z);if(Q)return Q;var q=j(D.dirname(process.execPath));if(q)return q;var X=["platform="+U2,"arch="+z2,"runtime="+N2,"abi="+h1,"uv="+v1,V2?"armv="+V2:"","libc="+O1,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"",typeof __webpack_require__==="function"?"webpack=true":""].filter(Boolean).join(" ");throw Error("No native build was found for "+X+`
|
|
4
|
+
loaded from: `+Z+`
|
|
5
|
+
`);function j(W){var G=_2(D.join(W,"prebuilds")).map(E1),H=G.filter(m1(U2,z2)).sort(f1)[0];if(!H)return;var U=D.join(W,"prebuilds",H.name),z=_2(U).map(b1),T=z.filter(g1(N2,h1)),V=T.sort(y1(N2))[0];if(V)return D.join(U,V.file)}};function _2(Z){try{return D1.readdirSync(Z)}catch($){return[]}}function x1(Z,$){var Y=_2(Z).filter($);return Y[0]&&D.join(Z,Y[0])}function C1(Z){return/\.node$/.test(Z)}function E1(Z){var $=Z.split("-");if($.length!==2)return;var Y=$[0],J=$[1].split("+");if(!Y)return;if(!J.length)return;if(!J.every(Boolean))return;return{name:Z,platform:Y,architectures:J}}function m1(Z,$){return function(Y){if(Y==null)return!1;if(Y.platform!==Z)return!1;return Y.architectures.includes($)}}function f1(Z,$){return Z.architectures.length-$.architectures.length}function b1(Z){var $=Z.split("."),Y=$.pop(),J={file:Z,specificity:0};if(Y!=="node")return;for(var Q=0;Q<$.length;Q++){var q=$[Q];if(q==="node"||q==="electron"||q==="node-webkit")J.runtime=q;else if(q==="napi")J.napi=!0;else if(q.slice(0,3)==="abi")J.abi=q.slice(3);else if(q.slice(0,2)==="uv")J.uv=q.slice(2);else if(q.slice(0,4)==="armv")J.armv=q.slice(4);else if(q==="glibc"||q==="musl")J.libc=q;else continue;J.specificity++}return J}function g1(Z,$){return function(Y){if(Y==null)return!1;if(Y.runtime&&Y.runtime!==Z&&!QY(Y))return!1;if(Y.abi&&Y.abi!==$&&!Y.napi)return!1;if(Y.uv&&Y.uv!==v1)return!1;if(Y.armv&&Y.armv!==V2)return!1;if(Y.libc&&Y.libc!==O1)return!1;return!0}}function QY(Z){return Z.runtime==="node"&&Z.napi}function y1(Z){return function($,Y){if($.runtime!==Y.runtime)return $.runtime===Z?-1:1;else if($.abi!==Y.abi)return $.abi?-1:1;else if($.specificity!==Y.specificity)return $.specificity>Y.specificity?-1:1;else return 0}}function qY(){return!!(process.versions&&process.versions.nw)}function XY(){if(process.versions&&process.versions.electron)return!0;if(process.env.ELECTRON_RUN_AS_NODE)return!0;return typeof window<"u"&&window.process&&window.process.type==="renderer"}function GY(Z){return Z==="linux"&&D1.existsSync("/etc/alpine-release")}C.parseTags=b1;C.matchTags=g1;C.compareTags=y1;C.parseTuple=E1;C.matchTuple=m1;C.compareTuples=f1});var c1=w((D5,R2)=>{var L2=typeof __webpack_require__==="function"?__non_webpack_require__:B;if(typeof L2.addon==="function")R2.exports=L2.addon.bind(L2);else R2.exports=u1()});var I0=w((F5,l1)=>{var __dirname="/home/runner/work/cosmos-agent/cosmos-agent/node_modules/.bun/classic-level@3.0.0/node_modules/classic-level";l1.exports=c1()(__dirname)});var p1=w((jY)=>{var{AbstractChainedBatch:WY}=D0(),Z0=I0(),$0=Symbol("context");class d1 extends WY{constructor(Z,$){super(Z);this[$0]=Z0.batch_init($)}_put(Z,$){Z0.batch_put(this[$0],Z,$)}_del(Z){Z0.batch_del(this[$0],Z)}_clear(){Z0.batch_clear(this[$0])}async _write(Z){return Z0.batch_write(this[$0],Z)}async _close(){}}jY.ChainedBatch=d1});var s1=w((NY)=>{var{AbstractIterator:wY}=D0(),y=I0(),k=Symbol("context"),M=Symbol("cache"),Y0=Symbol("first"),P=Symbol("position"),J0=Symbol("state"),u=Symbol("signal"),Q0=Symbol("abort"),K2=[];class a1 extends wY{constructor(Z,$,Y,J){super(Z,Y);if(this[J0]=new Uint8Array(1),this[k]=y.iterator_init($,this[J0],Y,J),this[Y0]=!0,this[M]=K2,this[P]=0,this[Q0]=this[Q0].bind(this),Y.signal!=null)this[u]=Y.signal,this[u].addEventListener("abort",this[Q0],{once:!0});else this[u]=null}_seek(Z,$){this[Y0]=!0,this[M]=K2,this[J0][0]&=-2,this[P]=0,y.iterator_seek(this[k],Z)}async _next(){if(this[P]<this[M].length)return this[M][this[P]++];if((this[J0][0]&1)!==0)return;if(this[Y0])this[Y0]=!1,this[M]=await y.iterator_nextv(this[k],1),this[P]=0;else this[M]=await y.iterator_nextv(this[k],1000),this[P]=0;if(this[P]<this[M].length)return this[M][this[P]++]}async _nextv(Z,$){if(this[Y0]=!1,this[P]<this[M].length){let Y=Math.min(Z,this[M].length-this[P]),J=this[M].slice(this[P],this[P]+Y);return this[P]+=Y,J}if((this[J0][0]&1)!==0)return[];return y.iterator_nextv(this[k],Z)}async _close(){if(this[M]=K2,this[u]!==null)this[u].removeEventListener("abort",this[Q0]),this[u]=null;y.iterator_close(this[k])}[Q0](){this[u]=null,y.iterator_abort(this[k])}get cached(){return this[M].length-this[P]}}NY.Iterator=a1});var e1=w((MY)=>{var{AbstractLevel:UY,AbstractSnapshot:VY}=D0(),P2=S(),_Y=B("fs/promises"),_=I0(),{ChainedBatch:LY}=p1(),{Iterator:RY}=s1(),N=Symbol("context"),F0=Symbol("location");class r1 extends UY{#Z=null;constructor(Z,$){if(typeof Z!=="string"||Z==="")throw TypeError("The first argument 'location' must be a non-empty string");super({encodings:{buffer:!0,utf8:!0,view:!0},has:!0,createIfMissing:!0,errorIfExists:!0,explicitSnapshots:!0,getSync:!0,additionalMethods:{approximateSize:!0,compactRange:!0},signals:{iterators:!0}},$);this[F0]=Z,this[N]=_.db_init()}get location(){return this[F0]}async _open(Z){if(Z.createIfMissing)await _Y.mkdir(this[F0],{recursive:!0});return _.db_open(this[N],this[F0],Z)}async _close(){return _.db_close(this[N])}async _put(Z,$,Y){return _.db_put(this[N],Z,$,Y)}async _get(Z,$){let Y=0;if($.fillCache!==!1)Y|=i1;if($.valueEncoding!=="utf8")Y|=n1;if($.keyEncoding!=="utf8"){if(Y|=KY,Z.buffer.resizable)Z=new Uint8Array(Z)}return _.db_get(this[N],Y,Z,$.snapshot?.[N])}_getSync(Z,$){let Y=0;if($.fillCache!==!1)Y|=i1;if($.valueEncoding!=="utf8")Y|=n1;if($.keyEncoding!=="utf8")return _.db_get_sync(this[N],Y,Z,$.snapshot?.[N]);else{let J;if(this.#Z===null)J=this.#$(Z);else if(J=this.#Z.write(Z),J===this.#Z.byteLength)J=this.#$(Z);return _.db_get_sync(this[N],Y|PY,J,$.snapshot?.[N])}}#$(Z){return this.#Z=Buffer.allocUnsafe(Buffer.byteLength(Z)+64),_.db_set_shared_buffer(this[N],this.#Z),this.#Z.write(Z)}async _getMany(Z,$){return _.db_get_many(this[N],Z,$,$.snapshot?.[N])}async _has(Z,$){return _.db_has(this[N],Z,$.fillCache,$.snapshot?.[N])}async _hasMany(Z,$){let Y=Z.length+32>>>5,J=new ArrayBuffer(Y*4),Q=new Uint32Array(J);await _.db_has_many(this[N],Z,$.fillCache,$.snapshot?.[N],J);let q=Array(Z.length);for(let X=0;X<q.length;X++)q[X]=(Q[X>>>5]&1<<(X&31))!==0;return q}async _del(Z,$){return _.db_del(this[N],Z,$)}async _clear(Z){return _.db_clear(this[N],Z,Z.snapshot?.[N])}_chainedBatch(){return new LY(this,this[N])}async _batch(Z,$){return _.batch_do(this[N],Z,$)}async approximateSize(Z,$,Y){if(arguments.length<2)throw TypeError("The arguments 'start' and 'end' are required");else if(typeof Y!=="object")Y=null;if(this.status==="opening")return this.deferAsync(()=>this.approximateSize(Z,$,Y));else if(this.status!=="open")throw new P2("Database is not open: cannot call approximateSize()",{code:"LEVEL_DATABASE_NOT_OPEN"});else{let J=this.keyEncoding(Y&&Y.keyEncoding);return Z=J.encode(Z),$=J.encode($),_.db_approximate_size(this[N],Z,$)}}async compactRange(Z,$,Y){if(arguments.length<2)throw TypeError("The arguments 'start' and 'end' are required");else if(typeof Y!=="object")Y=null;if(this.status==="opening")return this.deferAsync(()=>this.compactRange(Z,$,Y));else if(this.status!=="open")throw new P2("Database is not open: cannot call compactRange()",{code:"LEVEL_DATABASE_NOT_OPEN"});else{let J=this.keyEncoding(Y&&Y.keyEncoding);return Z=J.encode(Z),$=J.encode($),_.db_compact_range(this[N],Z,$)}}getProperty(Z){if(typeof Z!=="string")throw TypeError("The first argument 'property' must be a string");if(this.status!=="open")throw new P2("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return _.db_get_property(this[N],Z)}_iterator(Z){return new RY(this,this[N],Z,Z.snapshot?.[N])}_snapshot(Z){return new t1(this[N],Z)}static async destroy(Z){if(typeof Z!=="string"||Z==="")throw TypeError("The first argument 'location' must be a non-empty string");return _.destroy_db(Z)}static async repair(Z){if(typeof Z!=="string"||Z==="")throw TypeError("The first argument 'location' must be a non-empty string");return _.repair_db(Z)}}class t1 extends VY{constructor(Z,$){super($);this[N]=_.snapshot_init(Z)}async _close(){_.snapshot_close(this[N])}}MY.ClassicLevel=r1;var i1=1,KY=2,n1=4,PY=8});var A2="# IDE → Cosmos migration\n\nYou are the embedded migration agent. Your job is to migrate a developer's\nlocal Augment IDE context into their Cosmos user-scope VFS so it is available to\ntheir cloud agents. You do this by **reading** local context with the provided\ntools and **writing** concise, summarised Markdown into the user VFS.\n\nYou have exactly three tools available. Use only these; do not attempt any other\nfile, network, or shell access.\n\n- `read_local_threads({ kvStoreDir })` — reads the local conversation history\n (the augment-kv-store LevelDB). Returns\n `{ ok, threads: [{ id, metadata, exchanges: [{ uuid, value }] }], threadCount }`\n on success, or `{ ok: false, reason, error }` on failure.\n- `read_local_config({ homeDir, workspaceDirs? })` — scans local rules, skills,\n MCP servers, plugin marketplaces, and user guidelines. Always returns\n `{ ok, config: { userGuidelines, rules[], skills[], marketplaces[], mcpServers[], readErrors[] } }`.\n Each `rules`/`marketplaces`/`mcpServers` entry and `userGuidelines` is\n `{ path, scope: \"user\" | \"workspace\", content }`. Each `skills` entry is\n `{ dir, scope, root, files: [{ path, scope, content }] }`.\n- `write_user_vfs({ files: [{ path, content, overwrite? }] })` — commits UTF-8\n text into the user VFS. Returns `{ ok, committed[], newSeq?, skipped? }` or\n `{ ok: false, reason, error }`. By default each file is **skip-if-exists**\n (idempotent); pass `overwrite: true` only when you deliberately want to\n replace an existing file. A 4 MiB per-file cap truncates oversized content.\n\n## The prime directive: summarise, never dump raw\n\nYou are a summariser, not a copier. **Never** write a raw thread transcript,\nraw exchange JSON, or a raw LevelDB value into the VFS. For every thread you\nproduce a short, human-readable Markdown summary that captures what the\nconversation was about and what was decided or built — not a verbatim replay.\nA good thread summary is a handful of sentences plus a few bullet points, not\npages of transcript.\n\n## Idempotency\n\nThis migration may be re-run. Every `write_user_vfs` call must rely on the\ndefault **skip-if-exists** behaviour: do **not** pass `overwrite: true` unless\nyou have a specific reason to replace a file. A second run over an unchanged\nlocal context must produce no new writes and must not corrupt or duplicate\nanything already migrated. Treat the operation as safe to repeat.\n\n## Step 1 — Read local context\n\n1. Call `read_local_threads` with the `kvStoreDir` the host provides. If it\n returns `{ ok: false }`, record that the thread history was unavailable and\n continue with config migration — a missing store is not a fatal error.\n2. Call `read_local_config` with the `homeDir` (and `workspaceDirs` if the host\n provides them). This tool always succeeds; inspect `config.readErrors` for\n any files it could not read and note them in the manifest.\n\n## Step 2 — One Markdown summary per thread (v1: no clustering)\n\nFor **each** thread returned by `read_local_threads`, write **exactly one**\nMarkdown file. Do not cluster, merge, or split threads — one thread in, one\nsummary out.\n\n- Path: `.augment/migrated-context/threads/<thread-id>.md` (use the thread's\n `id` verbatim as the filename stem).\n- Content: a concise summary. Start with a short title line, then 2–5 sentences\n describing the topic and outcome of the conversation, then optionally a few\n bullets for concrete decisions, files, or follow-ups. Derive this from the\n thread's `metadata` and the ordered `exchanges`. Keep it tight; the reader\n wants the gist, not the transcript.\n\nIf a thread has no meaningful content (empty or trivial), still write a\none-line summary noting it was empty rather than skipping it, so the index\nstays complete.\n\n## Step 3 — Migrate config into conventional user locations\n\nWrite the discovered config into the standard user `.augment` locations, each\nvia `write_user_vfs` with default skip-if-exists:\n\n- **User guidelines** (`config.userGuidelines`): write its `content` to\n `.augment/user-guidelines.md`.\n- **Rules** (`config.rules[]`): write each rule's `content` to\n `.augment/rules/<basename>` using the source file's basename.\n- **Skills** (`config.skills[]`): for each skill, write each of its `files` to\n `.augment/skills/<skill-dir-basename>/<file-basename>`, preserving the skill's\n own directory grouping.\n- **MCP servers** (`config.mcpServers[]`): merge/write the MCP server\n definitions into the conventional user MCP config location under `.augment/`\n (e.g. `.augment/mcp.json`). Preserve the original server definitions; if\n multiple sources exist, combine them without dropping any.\n- **Marketplaces** (`config.marketplaces[]`): write each to\n `.augment/plugins/marketplaces/<basename>`.\n\nOnly migrate config surfaces that were actually found. Skip empty categories\nsilently.\n\n## Step 4 — Write the index and manifest\n\nFinally, write `.augment/migrated-context/index.md`. It must:\n\n- Link to every per-thread summary under `threads/` (a Markdown list of links\n using the thread ids).\n- Include a short **manifest** section listing what was migrated: the thread\n count, the config items migrated (counts per category), and any `readErrors`\n or unavailable sources encountered, so a human can see the migration was\n complete and where anything was skipped.\n\nWrite the index with default skip-if-exists like everything else. When you are\ndone, briefly report what you migrated (thread count and config categories) so\nthe outcome is visible in the event stream.\n";import{lstat as I2,readdir as w4,readFile as N4,realpath as z4}from"node:fs/promises";import{join as A}from"node:path";import{defineTool as U4}from"@augmentcode/auggie-v2";import{Type as p}from"@sinclair/typebox";var V4="read_local_config",s=".augment",_4=".claude",L4=".agents",R4=A(s,"user-guidelines.md"),K4=A(s,"rules"),P4=A(s,"plugins","marketplaces"),M4=["mcp-servers.json","mcp.json"],B4=[s,_4,L4],h2=64,S4=p.Object({homeDir:p.String({description:"The user's home directory to scan for user-scope config."}),workspaceDirs:p.Optional(p.Array(p.String(),{description:"Workspace directories to scan for workspace-scope config. May be empty."}))});function l(Z){if(Z instanceof Error){let $=Z.code;return $?`${$}: ${Z.message}`:Z.message}return String(Z)}function a(Z){return Z?.code==="ENOENT"}async function v0(Z,$,Y){try{let J=await N4(Z,"utf-8");return{path:Z,scope:$,content:J}}catch(J){if(a(J))return null;return Y.push({path:Z,error:l(J)}),null}}async function F2(Z,$){try{return await w4(Z)}catch(Y){if(a(Y))return[];return $.push({path:Z,error:l(Y)}),[]}}async function G0(Z,$,Y,J=new Set,Q=0){let q=[];if(Q>=h2)return Y.push({path:Z,error:`max directory depth (${h2}) exceeded; not descending further`}),q;try{let j=await z4(Z);if(J.has(j))return Y.push({path:Z,error:`symlink cycle detected (already visited ${j}); skipping`}),q;J.add(j)}catch(j){if(!a(j))Y.push({path:Z,error:l(j)})}let X=await F2(Z,Y);for(let j of X){let W=A(Z,j),G;try{G=await I2(W)}catch(H){if(!a(H))Y.push({path:W,error:l(H)});continue}if(G.isSymbolicLink())Y.push({path:W,error:"symlink skipped (not following to avoid cycles)"});else if(G.isDirectory())q.push(...await G0(W,$,Y,J,Q+1));else if(G.isFile()){let H=await v0(W,$,Y);if(H)q.push(H)}}return q}function x2(Z,$,Y){return G0(A(Z,K4),$,Y)}async function C2(Z,$,Y){let J=[];for(let Q of B4){let q=A(Z,Q,"skills"),X=await F2(q,Y);for(let j of X){let W=A(q,j),G;try{G=await I2(W)}catch(H){if(!a(H))Y.push({path:W,error:l(H)});continue}if(G.isSymbolicLink()){Y.push({path:W,error:"symlink skipped (not following to avoid cycles)"});continue}if(!G.isDirectory())continue;J.push({dir:W,scope:$,root:Q,files:await G0(W,$,Y)})}}return J}async function D2(Z,$,Y){let J=[];for(let Q of M4){let q=await v0(A(Z,s,Q),$,Y);if(q)J.push(q)}return J}async function T4(Z,$){let Y=[],J=await v0(A(Z,R4),"user",Y),Q=await x2(Z,"user",Y),q=await C2(Z,"user",Y),X=await G0(A(Z,P4),"user",Y),j=await D2(Z,"user",Y);for(let W of $)Q.push(...await x2(W,"workspace",Y)),q.push(...await C2(W,"workspace",Y)),j.push(...await D2(W,"workspace",Y));return{userGuidelines:J,rules:Q,skills:q,marketplaces:X,mcpServers:j,readErrors:Y}}function O2(Z){Z.registerTool(U4({name:V4,label:"Read Local Config",description:"Scan the local filesystem (no network) for the user's IDE agent config: user guidelines, user + workspace rules, skills across the .augment/.claude/.agents skill dirs, plugin marketplaces, and locally-defined MCP servers. Missing directories are treated as empty, not errors.",parameters:S4,async execute($,Y,J,Q,q){let{homeDir:X,workspaceDirs:j}=Y,W;try{W=await T4(X,j??[])}catch(H){W={userGuidelines:null,rules:[],skills:[],marketplaces:[],mcpServers:[],readErrors:[{path:X,error:l(H)}]}}return{content:[{type:"text",text:`Found ${W.rules.length} rule file(s), ${W.skills.length} skill(s), ${W.mcpServers.length} MCP config file(s), ${W.marketplaces.length} marketplace file(s)${W.userGuidelines?", and user guidelines":""}.`}],details:{ok:!0,config:W}}}}))}import{defineTool as SY}from"@augmentcode/auggie-v2";import{Type as o1}from"@sinclair/typebox";var M2=e1().ClassicLevel;var TY="read_local_threads",Z4="metadata:",$4="history:",Y4="exchange:",AY=o1.Object({kvStoreDir:o1.String({description:"Absolute path to the host-provided augment-kv-store LevelDB directory."})});function hY(Z){return{content:[{type:"text",text:Z}]}}function B2(Z){try{return JSON.parse(Z)}catch{return Z}}function xY(Z){if(!Array.isArray(Z))return[];let $=[];for(let Y of Z)if(typeof Y==="string")$.push(Y);else if(Y&&typeof Y==="object"&&typeof Y.uuid==="string")$.push(Y.uuid);return $}async function CY(Z){let $=new Map,Y=new Map,J=new Map;for await(let[X,j]of Z.iterator()){if(X.startsWith(Z4)){$.set(X.slice(Z4.length),B2(j));continue}if(X.startsWith($4)){Y.set(X.slice($4.length),xY(B2(j)));continue}if(X.startsWith(Y4)){let W=X.slice(Y4.length),G=W.lastIndexOf(":");if(G<=0)continue;let H=W.slice(0,G),U=W.slice(G+1),z=J.get(H)??[];z.push({uuid:U,value:B2(j)}),J.set(H,z)}}let Q=new Set([...$.keys(),...Y.keys(),...J.keys()]),q=[];for(let X of Q){let j=J.get(X)??[],W=Y.get(X)??[];q.push({id:X,metadata:$.get(X)??null,exchanges:DY(j,W)})}return q}function DY(Z,$){if($.length===0)return Z;let Y=new Map(Z.map((q)=>[q.uuid,q])),J=[],Q=new Set;for(let q of $){let X=Y.get(q);if(X)J.push(X),Q.add(q)}for(let q of Z)if(!Q.has(q.uuid))J.push(q);return J}async function IY(Z){if(typeof Z!=="string"||Z.length===0)return{ok:!1,reason:"invalid_params",error:"kvStoreDir must be a non-empty path string."};let $;try{$=new M2(Z,{createIfMissing:!1,errorIfExists:!1}),await $.open()}catch(Y){return await J4($),{ok:!1,reason:"db_unavailable",error:`Could not open augment-kv-store at "${Z}": ${Q4(Y)}`}}try{let Y=await CY($);return{ok:!0,threads:Y,threadCount:Y.length}}catch(Y){return{ok:!1,reason:"read_failed",error:`Failed reading threads from augment-kv-store: ${Q4(Y)}`}}finally{await J4($)}}async function J4(Z){if(!Z)return;try{if(Z.status==="open"||Z.status==="opening")await Z.close()}catch{}}function Q4(Z){if(Z instanceof Error){let $=Z.code;return $?`${$}: ${Z.message}`:Z.message}return String(Z)}function q4(Z){Z.registerTool(SY({name:TY,label:"Read Local Threads",description:"Read the host IDE's local conversation history from the augment-kv-store LevelDB (read-only). Returns structured threads reconstructed from the metadata/history/exchange keys. A locked or absent store is reported as an error result, not a crash.",parameters:AY,async execute($,Y,J,Q,q){let{kvStoreDir:X}=Y,j=await IY(X);if(j.ok)return{content:[{type:"text",text:`Read ${j.threadCount} thread(s) from the local augment-kv-store.`}],details:j};return{...hY(j.error),details:j}}}))}import{defineTool as FY,readAugmentCredentials as OY}from"@augmentcode/auggie-v2";import{Type as c}from"@sinclair/typebox";var vY="write_user_vfs",EY="/cloud-agents/vfs/commit-changes",mY="user",fY="migration-engine",X4=4194304,bY=-1,gY=0,yY=c.Object({files:c.Array(c.Object({path:c.String({description:"VFS-relative path within the user filesystem."}),content:c.String({description:"UTF-8 text content to write."}),overwrite:c.Optional(c.Boolean({description:"true → overwrite (base_seq 0); false/omitted → skip-if-exists (base_seq -1, idempotent)."}))}),{description:"Files to commit into the user-scope VFS."})}),W4=new TextEncoder;function S2(Z){return W4.encode(Z).length}function kY(Z){if(S2(Z)<=X4)return{content:Z,truncated:!1};let $=`
|
|
6
|
+
|
|
7
|
+
[migration: content truncated to fit the 4 MiB VFS limit]
|
|
8
|
+
`,Y=X4-S2($),J=Array.from(Z),Q=0,q=J.length;while(Q<q){let X=Math.ceil((Q+q)/2);if(S2(J.slice(0,X).join(""))<=Y)Q=X;else q=X-1}return{content:`${J.slice(0,Q).join("")}${$}`,truncated:!0}}function uY(Z){return`${Z.replace(/\/+$/,"")}${EY}`}function cY(Z){return{content:[{type:"text",text:Z}]}}function G4(Z,$){if($.length===0)return Z;return Z.split($).join("[redacted]")}async function lY(Z){if(!Array.isArray(Z)||Z.length===0)return{ok:!1,reason:"invalid_params",error:"files must be a non-empty array of {path, content}."};let $=await OY();if(!$)return{ok:!1,reason:"no_credentials",error:"No Augment credentials available (session.json / AUGMENT_SESSION_AUTH). Cannot write to the user VFS."};let Y=[],J=Z.map((Q)=>{let{content:q,truncated:X}=kY(Q.content),j=W4.encode(q);return Y.push({path:Q.path,truncated:X,bytes:j.length}),{path:Q.path,content:Array.from(j),deleted:!1,base_seq:Q.overwrite?gY:bY}});try{let Q=await fetch(uY($.apiUrl),{method:"POST",headers:{Authorization:`Bearer ${$.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({filesystem_id:mY,file_changes:J,modified_by:fY})});if(!Q.ok){let X=await dY(Q);return{ok:!1,reason:"commit_failed",error:G4(`commit-changes failed with HTTP ${Q.status}${X?`: ${X}`:""}`,$.apiKey)}}let q=await pY(Q);return{ok:!0,committed:Y,newSeq:q?.new_seq,skipped:q?.skipped_files}}catch(Q){let q=Q instanceof Error?Q.message:String(Q);return{ok:!1,reason:"commit_failed",error:G4(`commit-changes request failed: ${q}`,$.apiKey)}}}async function dY(Z){try{return(await Z.text()).slice(0,500)}catch{return""}}async function pY(Z){try{return await Z.json()}catch{return}}function j4(Z){Z.registerTool(FY({name:vY,label:"Write User VFS",description:"Commit summarised migration output into the user's Cosmos user-scope VFS. Enforces a 4 MiB/file cap by truncating oversized content (never rejecting). Uses base_seq -1 (skip-if-exists, idempotent) unless overwrite:true is set (base_seq 0). Auth comes from the existing session credentials; no new auth surface.",parameters:yY,async execute($,Y,J,Q,q){let{files:X}=Y,j=await lY(X);if(j.ok){let W=j.committed.filter((H)=>H.truncated).length,G=W>0?` (${W} truncated to the 4 MiB limit)`:"";return{content:[{type:"text",text:`Committed ${j.committed.length} file(s) to the user VFS${G}.`}],details:j}}return{...cY(j.error),details:j}}}))}function aY(Z){q4(Z),O2(Z),j4(Z)}function s5(){return A2}export{s5 as getMigrationPrompt,aY as default};
|
|
9
|
+
|
|
10
|
+
//# debugId=50A8810A5F53CAB964756E2164756E21
|