@netlify/agent-runner-cli 1.163.0-PAW-328.7 → 1.163.0-PAW-328.8
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/dist/bin-local.js +3 -3
- package/dist/bin.js +3 -3
- package/dist/index.js +3 -3
- package/dist/interactions-mcp-server.js +2 -2
- package/package.json +1 -1
package/dist/bin-local.js
CHANGED
|
@@ -31,7 +31,7 @@ To prepare for this change:
|
|
|
31
31
|
|
|
32
32
|
See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode definitions.`))}c_e.exports=hm;hm.parse=hm;hm.toClientConfig=a_e;hm.parseIntoClientConfig=N5e});var Jq=T((v6t,f_e)=>{"use strict";var k5e=Q("dns"),d_e=eE(),u_e=l_e().parse,Vr=function(t,e,r){return e[t]?e[t]:(r===void 0?r=process.env["PG"+t.toUpperCase()]:r===!1||(r=process.env[r]),r||d_e[t])},M5e=function(){switch(process.env.PGSSLMODE){case"disable":return!1;case"prefer":case"require":case"verify-ca":case"verify-full":return!0;case"no-verify":return{rejectUnauthorized:!1}}return d_e.ssl},mm=function(t){return"'"+(""+t).replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"},ai=function(t,e,r){let n=e[r];n!=null&&t.push(r+"="+mm(n))},Zq=class{constructor(e){e=typeof e=="string"?u_e(e):e||{},e.connectionString&&(e=Object.assign({},e,u_e(e.connectionString))),this.user=Vr("user",e),this.database=Vr("database",e),this.database===void 0&&(this.database=this.user),this.port=parseInt(Vr("port",e),10),this.host=Vr("host",e),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:Vr("password",e)}),this.binary=Vr("binary",e),this.options=Vr("options",e),this.ssl=typeof e.ssl>"u"?M5e():e.ssl,typeof this.ssl=="string"&&this.ssl==="true"&&(this.ssl=!0),this.ssl==="no-verify"&&(this.ssl={rejectUnauthorized:!1}),this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,"key",{enumerable:!1}),this.client_encoding=Vr("client_encoding",e),this.replication=Vr("replication",e),this.isDomainSocket=!(this.host||"").indexOf("/"),this.application_name=Vr("application_name",e,"PGAPPNAME"),this.fallback_application_name=Vr("fallback_application_name",e,!1),this.statement_timeout=Vr("statement_timeout",e,!1),this.lock_timeout=Vr("lock_timeout",e,!1),this.idle_in_transaction_session_timeout=Vr("idle_in_transaction_session_timeout",e,!1),this.query_timeout=Vr("query_timeout",e,!1),e.connectionTimeoutMillis===void 0?this.connect_timeout=process.env.PGCONNECT_TIMEOUT||0:this.connect_timeout=Math.floor(e.connectionTimeoutMillis/1e3),e.keepAlive===!1?this.keepalives=0:e.keepAlive===!0&&(this.keepalives=1),typeof e.keepAliveInitialDelayMillis=="number"&&(this.keepalives_idle=Math.floor(e.keepAliveInitialDelayMillis/1e3))}getLibpqConnectionString(e){let r=[];ai(r,this,"user"),ai(r,this,"password"),ai(r,this,"port"),ai(r,this,"application_name"),ai(r,this,"fallback_application_name"),ai(r,this,"connect_timeout"),ai(r,this,"options");let n=typeof this.ssl=="object"?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(ai(r,n,"sslmode"),ai(r,n,"sslca"),ai(r,n,"sslkey"),ai(r,n,"sslcert"),ai(r,n,"sslrootcert"),this.database&&r.push("dbname="+mm(this.database)),this.replication&&r.push("replication="+mm(this.replication)),this.host&&r.push("host="+mm(this.host)),this.isDomainSocket)return e(null,r.join(" "));this.client_encoding&&r.push("client_encoding="+mm(this.client_encoding)),k5e.lookup(this.host,function(i,o){return i?e(i,null):(r.push("hostaddr="+mm(o)),e(null,r.join(" ")))})}};f_e.exports=Zq});var Qq=T((T6t,h_e)=>{"use strict";var D5e=QS(),p_e=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/,Xq=class{constructor(e,r){this.command=null,this.rowCount=null,this.oid=null,this.rows=[],this.fields=[],this._parsers=void 0,this._types=r,this.RowCtor=null,this.rowAsArray=e==="array",this.rowAsArray&&(this.parseRow=this._parseRowAsArray),this._prebuiltEmptyResultObject=null}addCommandComplete(e){let r;e.text?r=p_e.exec(e.text):r=p_e.exec(e.command),r&&(this.command=r[1],r[3]?(this.oid=parseInt(r[2],10),this.rowCount=parseInt(r[3],10)):r[2]&&(this.rowCount=parseInt(r[2],10)))}_parseRowAsArray(e){let r=new Array(e.length);for(let n=0,i=e.length;n<i;n++){let o=e[n];o!==null?r[n]=this._parsers[n](o):r[n]=null}return r}parseRow(e){let r={...this._prebuiltEmptyResultObject};for(let n=0,i=e.length;n<i;n++){let o=e[n],s=this.fields[n].name;if(o!==null){let a=this.fields[n].format==="binary"?Buffer.from(o):o;r[s]=this._parsers[n](a)}else r[s]=null}return r}addRow(e){this.rows.push(e)}addFields(e){this.fields=e,this.fields.length&&(this._parsers=new Array(e.length));let r=Object.create(null);for(let n=0;n<e.length;n++){let i=e[n];r[i.name]=null,this._types?this._parsers[n]=this._types.getTypeParser(i.dataTypeID,i.format||"text"):this._parsers[n]=D5e.getTypeParser(i.dataTypeID,i.format||"text")}this._prebuiltEmptyResultObject={...r}}};h_e.exports=Xq});var y_e=T((b6t,__e)=>{"use strict";var{EventEmitter:L5e}=Q("events"),m_e=Qq(),g_e=pm(),eV=class extends L5e{constructor(e,r,n){super(),e=g_e.normalizeQueryConfig(e,r,n),this.text=e.text,this.values=e.values,this.rows=e.rows,this.types=e.types,this.name=e.name,this.queryMode=e.queryMode,this.binary=e.binary,this.portal=e.portal||"",this.callback=e.callback,this._rowMode=e.rowMode,process.domain&&e.callback&&(this.callback=process.domain.bind(e.callback)),this._result=new m_e(this._rowMode,this.types),this._results=this._result,this._canceledDueToError=!1}requiresPreparation(){return this.queryMode==="extended"||this.name||this.rows?!0:!this.text||!this.values?!1:this.values.length>0}_checkForMultirow(){this._result.command&&(Array.isArray(this._results)||(this._results=[this._result]),this._result=new m_e(this._rowMode,this._result._types),this._results.push(this._result))}handleRowDescription(e){this._checkForMultirow(),this._result.addFields(e.fields),this._accumulateRows=this.callback||!this.listeners("row").length}handleDataRow(e){let r;if(!this._canceledDueToError){try{r=this._result.parseRow(e.fields)}catch(n){this._canceledDueToError=n;return}this.emit("row",r,this._result),this._accumulateRows&&this._result.addRow(r)}}handleCommandComplete(e,r){this._checkForMultirow(),this._result.addCommandComplete(e),this.rows&&r.sync()}handleEmptyQuery(e){this.rows&&e.sync()}handleError(e,r){if(this._canceledDueToError&&(e=this._canceledDueToError,this._canceledDueToError=!1),this.callback)return this.callback(e);this.emit("error",e)}handleReadyForQuery(e){if(this._canceledDueToError)return this.handleError(this._canceledDueToError,e);if(this.callback)try{this.callback(null,this._results)}catch(r){process.nextTick(()=>{throw r})}this.emit("end",this._results)}submit(e){if(typeof this.text!="string"&&typeof this.name!="string")return new Error("A query must have either text or a name. Supplying neither is unsupported.");let r=e.parsedStatements[this.name];if(this.text&&r&&this.text!==r)return new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);if(this.values&&!Array.isArray(this.values))return new Error("Query values must be an array");if(this.requiresPreparation()){e.stream.cork&&e.stream.cork();try{this.prepare(e)}finally{e.stream.uncork&&e.stream.uncork()}}else e.query(this.text);return null}hasBeenParsed(e){return this.name&&e.parsedStatements[this.name]}handlePortalSuspended(e){this._getRows(e,this.rows)}_getRows(e,r){e.execute({portal:this.portal,rows:r}),r?e.flush():e.sync()}prepare(e){this.hasBeenParsed(e)||e.parse({text:this.text,name:this.name,types:this.types});try{e.bind({portal:this.portal,statement:this.name,values:this.values,binary:this.binary,valueMapper:g_e.prepareValue})}catch(r){this.handleError(r,e);return}e.describe({type:"P",name:this.portal||""}),this._getRows(e,this.rows)}handleCopyInResponse(e){e.sendCopyFail("No source stream defined")}handleCopyData(e,r){}};__e.exports=eV});var mV=T(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.NoticeMessage=Le.DataRowMessage=Le.CommandCompleteMessage=Le.ReadyForQueryMessage=Le.NotificationResponseMessage=Le.BackendKeyDataMessage=Le.AuthenticationMD5Password=Le.ParameterStatusMessage=Le.ParameterDescriptionMessage=Le.RowDescriptionMessage=Le.Field=Le.CopyResponse=Le.CopyDataMessage=Le.DatabaseError=Le.copyDone=Le.emptyQuery=Le.replicationStart=Le.portalSuspended=Le.noData=Le.closeComplete=Le.bindComplete=Le.parseComplete=void 0;Le.parseComplete={name:"parseComplete",length:5};Le.bindComplete={name:"bindComplete",length:5};Le.closeComplete={name:"closeComplete",length:5};Le.noData={name:"noData",length:5};Le.portalSuspended={name:"portalSuspended",length:5};Le.replicationStart={name:"replicationStart",length:4};Le.emptyQuery={name:"emptyQuery",length:4};Le.copyDone={name:"copyDone",length:4};var tV=class extends Error{constructor(e,r,n){super(e),this.length=r,this.name=n}};Le.DatabaseError=tV;var rV=class{constructor(e,r){this.length=e,this.chunk=r,this.name="copyData"}};Le.CopyDataMessage=rV;var nV=class{constructor(e,r,n,i){this.length=e,this.name=r,this.binary=n,this.columnTypes=new Array(i)}};Le.CopyResponse=nV;var iV=class{constructor(e,r,n,i,o,s,a){this.name=e,this.tableID=r,this.columnID=n,this.dataTypeID=i,this.dataTypeSize=o,this.dataTypeModifier=s,this.format=a}};Le.Field=iV;var oV=class{constructor(e,r){this.length=e,this.fieldCount=r,this.name="rowDescription",this.fields=new Array(this.fieldCount)}};Le.RowDescriptionMessage=oV;var sV=class{constructor(e,r){this.length=e,this.parameterCount=r,this.name="parameterDescription",this.dataTypeIDs=new Array(this.parameterCount)}};Le.ParameterDescriptionMessage=sV;var aV=class{constructor(e,r,n){this.length=e,this.parameterName=r,this.parameterValue=n,this.name="parameterStatus"}};Le.ParameterStatusMessage=aV;var cV=class{constructor(e,r){this.length=e,this.salt=r,this.name="authenticationMD5Password"}};Le.AuthenticationMD5Password=cV;var lV=class{constructor(e,r,n){this.length=e,this.processID=r,this.secretKey=n,this.name="backendKeyData"}};Le.BackendKeyDataMessage=lV;var uV=class{constructor(e,r,n,i){this.length=e,this.processId=r,this.channel=n,this.payload=i,this.name="notification"}};Le.NotificationResponseMessage=uV;var dV=class{constructor(e,r){this.length=e,this.status=r,this.name="readyForQuery"}};Le.ReadyForQueryMessage=dV;var fV=class{constructor(e,r){this.length=e,this.text=r,this.name="commandComplete"}};Le.CommandCompleteMessage=fV;var pV=class{constructor(e,r){this.length=e,this.fields=r,this.name="dataRow",this.fieldCount=r.length}};Le.DataRowMessage=pV;var hV=class{constructor(e,r){this.length=e,this.message=r,this.name="notice"}};Le.NoticeMessage=hV});var S_e=T(nP=>{"use strict";Object.defineProperty(nP,"__esModule",{value:!0});nP.Writer=void 0;var gV=class{constructor(e=256){this.size=e,this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(e)}ensure(e){if(this.buffer.length-this.offset<e){let n=this.buffer,i=n.length+(n.length>>1)+e;this.buffer=Buffer.allocUnsafe(i),n.copy(this.buffer)}}addInt32(e){return this.ensure(4),this.buffer[this.offset++]=e>>>24&255,this.buffer[this.offset++]=e>>>16&255,this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addInt16(e){return this.ensure(2),this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addCString(e){if(!e)this.ensure(1);else{let r=Buffer.byteLength(e);this.ensure(r+1),this.buffer.write(e,this.offset,"utf-8"),this.offset+=r}return this.buffer[this.offset++]=0,this}addString(e=""){let r=Buffer.byteLength(e);return this.ensure(r),this.buffer.write(e,this.offset),this.offset+=r,this}add(e){return this.ensure(e.length),e.copy(this.buffer,this.offset),this.offset+=e.length,this}join(e){if(e){this.buffer[this.headerPosition]=e;let r=this.offset-(this.headerPosition+1);this.buffer.writeInt32BE(r,this.headerPosition+1)}return this.buffer.slice(e?0:5,this.offset)}flush(e){let r=this.join(e);return this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(this.size),r}};nP.Writer=gV});var v_e=T(oP=>{"use strict";Object.defineProperty(oP,"__esModule",{value:!0});oP.serialize=void 0;var _V=S_e(),gt=new _V.Writer,$5e=t=>{gt.addInt16(3).addInt16(0);for(let n of Object.keys(t))gt.addCString(n).addCString(t[n]);gt.addCString("client_encoding").addCString("UTF8");let e=gt.addCString("").flush(),r=e.length+4;return new _V.Writer().addInt32(r).add(e).flush()},U5e=()=>{let t=Buffer.allocUnsafe(8);return t.writeInt32BE(8,0),t.writeInt32BE(80877103,4),t},F5e=t=>gt.addCString(t).flush(112),B5e=function(t,e){return gt.addCString(t).addInt32(Buffer.byteLength(e)).addString(e),gt.flush(112)},j5e=function(t){return gt.addString(t).flush(112)},z5e=t=>gt.addCString(t).flush(81),E_e=[],G5e=t=>{let e=t.name||"";e.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",e,e.length),console.error("This can cause conflicts and silent errors executing queries"));let r=t.types||E_e,n=r.length,i=gt.addCString(e).addCString(t.text).addInt16(n);for(let o=0;o<n;o++)i.addInt32(r[o]);return gt.flush(80)},gm=new _V.Writer,q5e=function(t,e){for(let r=0;r<t.length;r++){let n=e?e(t[r],r):t[r];n==null?(gt.addInt16(0),gm.addInt32(-1)):n instanceof Buffer?(gt.addInt16(1),gm.addInt32(n.length),gm.add(n)):(gt.addInt16(0),gm.addInt32(Buffer.byteLength(n)),gm.addString(n))}},V5e=(t={})=>{let e=t.portal||"",r=t.statement||"",n=t.binary||!1,i=t.values||E_e,o=i.length;return gt.addCString(e).addCString(r),gt.addInt16(o),q5e(i,t.valueMapper),gt.addInt16(o),gt.add(gm.flush()),gt.addInt16(1),gt.addInt16(n?1:0),gt.flush(66)},H5e=Buffer.from([69,0,0,0,9,0,0,0,0,0]),W5e=t=>{if(!t||!t.portal&&!t.rows)return H5e;let e=t.portal||"",r=t.rows||0,n=Buffer.byteLength(e),i=4+n+1+4,o=Buffer.allocUnsafe(1+i);return o[0]=69,o.writeInt32BE(i,1),o.write(e,5,"utf-8"),o[n+5]=0,o.writeUInt32BE(r,o.length-4),o},Y5e=(t,e)=>{let r=Buffer.allocUnsafe(16);return r.writeInt32BE(16,0),r.writeInt16BE(1234,4),r.writeInt16BE(5678,6),r.writeInt32BE(t,8),r.writeInt32BE(e,12),r},yV=(t,e)=>{let n=4+Buffer.byteLength(e)+1,i=Buffer.allocUnsafe(1+n);return i[0]=t,i.writeInt32BE(n,1),i.write(e,5,"utf-8"),i[n]=0,i},K5e=gt.addCString("P").flush(68),Z5e=gt.addCString("S").flush(68),J5e=t=>t.name?yV(68,`${t.type}${t.name||""}`):t.type==="P"?K5e:Z5e,X5e=t=>{let e=`${t.type}${t.name||""}`;return yV(67,e)},Q5e=t=>gt.add(t).flush(100),e9e=t=>yV(102,t),iP=t=>Buffer.from([t,0,0,0,4]),t9e=iP(72),r9e=iP(83),n9e=iP(88),i9e=iP(99),o9e={startup:$5e,password:F5e,requestSsl:U5e,sendSASLInitialResponseMessage:B5e,sendSCRAMClientFinalMessage:j5e,query:z5e,parse:G5e,bind:V5e,execute:W5e,describe:J5e,close:X5e,flush:()=>t9e,sync:()=>r9e,end:()=>n9e,copyData:Q5e,copyDone:()=>i9e,copyFail:e9e,cancel:Y5e};oP.serialize=o9e});var T_e=T(sP=>{"use strict";Object.defineProperty(sP,"__esModule",{value:!0});sP.BufferReader=void 0;var SV=class{constructor(e=0){this.offset=e,this.buffer=Buffer.allocUnsafe(0),this.encoding="utf-8"}setBuffer(e,r){this.offset=e,this.buffer=r}int16(){let e=this.buffer.readInt16BE(this.offset);return this.offset+=2,e}byte(){let e=this.buffer[this.offset];return this.offset++,e}int32(){let e=this.buffer.readInt32BE(this.offset);return this.offset+=4,e}uint32(){let e=this.buffer.readUInt32BE(this.offset);return this.offset+=4,e}string(e){let r=this.buffer.toString(this.encoding,this.offset,this.offset+e);return this.offset+=e,r}cstring(){let e=this.offset,r=e;for(;this.buffer[r++]!==0;);return this.offset=r,this.buffer.toString(this.encoding,e,r-1)}bytes(e){let r=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,r}};sP.BufferReader=SV});var x_e=T(aP=>{"use strict";Object.defineProperty(aP,"__esModule",{value:!0});aP.Parser=void 0;var bt=mV(),s9e=T_e(),vV=1,a9e=4,b_e=vV+a9e,Dn=-1,EV=Buffer.allocUnsafe(0),TV=class{constructor(e){if(this.buffer=EV,this.bufferLength=0,this.bufferOffset=0,this.reader=new s9e.BufferReader,e?.mode==="binary")throw new Error("Binary mode not supported yet");this.mode=e?.mode||"text"}parse(e,r){this.mergeBuffer(e);let n=this.bufferOffset+this.bufferLength,i=this.bufferOffset;for(;i+b_e<=n;){let o=this.buffer[i],s=this.buffer.readUInt32BE(i+vV),a=vV+s;if(a+i<=n){let c=this.handlePacket(i+b_e,o,s,this.buffer);r(c),i+=a}else break}i===n?(this.buffer=EV,this.bufferLength=0,this.bufferOffset=0):(this.bufferLength=n-i,this.bufferOffset=i)}mergeBuffer(e){if(this.bufferLength>0){let r=this.bufferLength+e.byteLength;if(r+this.bufferOffset>this.buffer.byteLength){let i;if(r<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)i=this.buffer;else{let o=this.buffer.byteLength*2;for(;r>=o;)o*=2;i=Buffer.allocUnsafe(o)}this.buffer.copy(i,0,this.bufferOffset,this.bufferOffset+this.bufferLength),this.buffer=i,this.bufferOffset=0}e.copy(this.buffer,this.bufferOffset+this.bufferLength),this.bufferLength=r}else this.buffer=e,this.bufferOffset=0,this.bufferLength=e.byteLength}handlePacket(e,r,n,i){let{reader:o}=this;o.setBuffer(e,i);let s;switch(r){case 50:s=bt.bindComplete;break;case 49:s=bt.parseComplete;break;case 51:s=bt.closeComplete;break;case 110:s=bt.noData;break;case 115:s=bt.portalSuspended;break;case 99:s=bt.copyDone;break;case 87:s=bt.replicationStart;break;case 73:s=bt.emptyQuery;break;case 68:s=_9e(o);break;case 67:s=l9e(o);break;case 90:s=c9e(o);break;case 65:s=p9e(o);break;case 82:s=E9e(o,n);break;case 83:s=y9e(o);break;case 75:s=S9e(o);break;case 69:s=A_e(o,"error");break;case 78:s=A_e(o,"notice");break;case 84:s=h9e(o);break;case 116:s=g9e(o);break;case 71:s=d9e(o);break;case 72:s=f9e(o);break;case 100:s=u9e(o,n);break;default:return new bt.DatabaseError("received invalid response: "+r.toString(16),n,"error")}return o.setBuffer(0,EV),s.length=n,s}};aP.Parser=TV;var c9e=t=>{let e=t.string(1);return new bt.ReadyForQueryMessage(Dn,e)},l9e=t=>{let e=t.cstring();return new bt.CommandCompleteMessage(Dn,e)},u9e=(t,e)=>{let r=t.bytes(e-4);return new bt.CopyDataMessage(Dn,r)},d9e=t=>w_e(t,"copyInResponse"),f9e=t=>w_e(t,"copyOutResponse"),w_e=(t,e)=>{let r=t.byte()!==0,n=t.int16(),i=new bt.CopyResponse(Dn,e,r,n);for(let o=0;o<n;o++)i.columnTypes[o]=t.int16();return i},p9e=t=>{let e=t.int32(),r=t.cstring(),n=t.cstring();return new bt.NotificationResponseMessage(Dn,e,r,n)},h9e=t=>{let e=t.int16(),r=new bt.RowDescriptionMessage(Dn,e);for(let n=0;n<e;n++)r.fields[n]=m9e(t);return r},m9e=t=>{let e=t.cstring(),r=t.uint32(),n=t.int16(),i=t.uint32(),o=t.int16(),s=t.int32(),a=t.int16()===0?"text":"binary";return new bt.Field(e,r,n,i,o,s,a)},g9e=t=>{let e=t.int16(),r=new bt.ParameterDescriptionMessage(Dn,e);for(let n=0;n<e;n++)r.dataTypeIDs[n]=t.int32();return r},_9e=t=>{let e=t.int16(),r=new Array(e);for(let n=0;n<e;n++){let i=t.int32();r[n]=i===-1?null:t.string(i)}return new bt.DataRowMessage(Dn,r)},y9e=t=>{let e=t.cstring(),r=t.cstring();return new bt.ParameterStatusMessage(Dn,e,r)},S9e=t=>{let e=t.int32(),r=t.int32();return new bt.BackendKeyDataMessage(Dn,e,r)},E9e=(t,e)=>{let r=t.int32(),n={name:"authenticationOk",length:e};switch(r){case 0:break;case 3:n.length===8&&(n.name="authenticationCleartextPassword");break;case 5:if(n.length===12){n.name="authenticationMD5Password";let i=t.bytes(4);return new bt.AuthenticationMD5Password(Dn,i)}break;case 10:{n.name="authenticationSASL",n.mechanisms=[];let i;do i=t.cstring(),i&&n.mechanisms.push(i);while(i)}break;case 11:n.name="authenticationSASLContinue",n.data=t.string(e-8);break;case 12:n.name="authenticationSASLFinal",n.data=t.string(e-8);break;default:throw new Error("Unknown authenticationOk message type "+r)}return n},A_e=(t,e)=>{let r={},n=t.string(1);for(;n!=="\0";)r[n]=t.cstring(),n=t.string(1);let i=r.M,o=e==="notice"?new bt.NoticeMessage(Dn,i):new bt.DatabaseError(i,Dn,e);return o.severity=r.S,o.code=r.C,o.detail=r.D,o.hint=r.H,o.position=r.P,o.internalPosition=r.p,o.internalQuery=r.q,o.where=r.W,o.schema=r.s,o.table=r.t,o.column=r.c,o.dataType=r.d,o.constraint=r.n,o.file=r.F,o.line=r.L,o.routine=r.R,o}});var bV=T(Gc=>{"use strict";Object.defineProperty(Gc,"__esModule",{value:!0});Gc.DatabaseError=Gc.serialize=Gc.parse=void 0;var v9e=mV();Object.defineProperty(Gc,"DatabaseError",{enumerable:!0,get:function(){return v9e.DatabaseError}});var T9e=v_e();Object.defineProperty(Gc,"serialize",{enumerable:!0,get:function(){return T9e.serialize}});var b9e=x_e();function A9e(t,e){let r=new b9e.Parser;return t.on("data",n=>r.parse(n,e)),new Promise(n=>t.on("end",()=>n()))}Gc.parse=A9e});var R_e=T(AV=>{"use strict";Object.defineProperty(AV,"__esModule",{value:!0});AV.default={}});var C_e=T((O6t,I_e)=>{"use strict";var{getStream:w9e,getSecureStream:x9e}=P9e();I_e.exports={getStream:w9e,getSecureStream:x9e};function R9e(){function t(r){let n=Q("net");return new n.Socket}function e(r){return Q("tls").connect(r)}return{getStream:t,getSecureStream:e}}function I9e(){function t(r){let{CloudflareSocket:n}=R_e();return new n(r)}function e(r){return r.socket.startTls(r),r.socket}return{getStream:t,getSecureStream:e}}function C9e(){if(typeof navigator=="object"&&navigator!==null&&typeof navigator.userAgent=="string")return navigator.userAgent==="Cloudflare-Workers";if(typeof Response=="function"){let t=new Response(null,{cf:{thing:!0}});if(typeof t.cf=="object"&&t.cf!==null&&t.cf.thing)return!0}return!1}function P9e(){return C9e()?I9e():R9e()}});var xV=T((N6t,P_e)=>{"use strict";var O9e=Q("events").EventEmitter,{parse:N9e,serialize:or}=bV(),{getStream:k9e,getSecureStream:M9e}=C_e(),D9e=or.flush(),L9e=or.sync(),$9e=or.end(),wV=class extends O9e{constructor(e){super(),e=e||{},this.stream=e.stream||k9e(e.ssl),typeof this.stream=="function"&&(this.stream=this.stream(e)),this._keepAlive=e.keepAlive,this._keepAliveInitialDelayMillis=e.keepAliveInitialDelayMillis,this.parsedStatements={},this.ssl=e.ssl||!1,this._ending=!1,this._emitMessage=!1;let r=this;this.on("newListener",function(n){n==="message"&&(r._emitMessage=!0)})}connect(e,r){let n=this;this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect(e,r),this.stream.once("connect",function(){n._keepAlive&&n.stream.setKeepAlive(!0,n._keepAliveInitialDelayMillis),n.emit("connect")});let i=function(o){n._ending&&(o.code==="ECONNRESET"||o.code==="EPIPE")||n.emit("error",o)};if(this.stream.on("error",i),this.stream.on("close",function(){n.emit("end")}),!this.ssl)return this.attachListeners(this.stream);this.stream.once("data",function(o){switch(o.toString("utf8")){case"S":break;case"N":return n.stream.end(),n.emit("error",new Error("The server does not support SSL connections"));default:return n.stream.end(),n.emit("error",new Error("There was an error establishing an SSL connection"))}let a={socket:n.stream};n.ssl!==!0&&(Object.assign(a,n.ssl),"key"in n.ssl&&(a.key=n.ssl.key));let c=Q("net");c.isIP&&c.isIP(r)===0&&(a.servername=r);try{n.stream=M9e(a)}catch(l){return n.emit("error",l)}n.attachListeners(n.stream),n.stream.on("error",i),n.emit("sslconnect")})}attachListeners(e){N9e(e,r=>{let n=r.name==="error"?"errorMessage":r.name;this._emitMessage&&this.emit("message",r),this.emit(n,r)})}requestSsl(){this.stream.write(or.requestSsl())}startup(e){this.stream.write(or.startup(e))}cancel(e,r){this._send(or.cancel(e,r))}password(e){this._send(or.password(e))}sendSASLInitialResponseMessage(e,r){this._send(or.sendSASLInitialResponseMessage(e,r))}sendSCRAMClientFinalMessage(e){this._send(or.sendSCRAMClientFinalMessage(e))}_send(e){return this.stream.writable?this.stream.write(e):!1}query(e){this._send(or.query(e))}parse(e){this._send(or.parse(e))}bind(e){this._send(or.bind(e))}execute(e){this._send(or.execute(e))}flush(){this.stream.writable&&this.stream.write(D9e)}sync(){this._ending=!0,this._send(L9e)}ref(){this.stream.ref()}unref(){this.stream.unref()}end(){if(this._ending=!0,!this._connecting||!this.stream.writable){this.stream.end();return}return this.stream.write($9e,()=>{this.stream.end()})}close(e){this._send(or.close(e))}describe(e){this._send(or.describe(e))}sendCopyFromChunk(e){this._send(or.copyData(e))}endCopyFrom(){this._send(or.copyDone())}sendCopyFail(e){this._send(or.copyFail(e))}};P_e.exports=wV});var M_e=T((k6t,k_e)=>{"use strict";var{Transform:U9e}=Q("stream"),{StringDecoder:F9e}=Q("string_decoder"),qc=Symbol("last"),cP=Symbol("decoder");function B9e(t,e,r){let n;if(this.overflow){if(n=this[cP].write(t).split(this.matcher),n.length===1)return r();n.shift(),this.overflow=!1}else this[qc]+=this[cP].write(t),n=this[qc].split(this.matcher);this[qc]=n.pop();for(let i=0;i<n.length;i++)try{N_e(this,this.mapper(n[i]))}catch(o){return r(o)}if(this.overflow=this[qc].length>this.maxLength,this.overflow&&!this.skipOverflow){r(new Error("maximum buffer reached"));return}r()}function j9e(t){if(this[qc]+=this[cP].end(),this[qc])try{N_e(this,this.mapper(this[qc]))}catch(e){return t(e)}t()}function N_e(t,e){e!==void 0&&t.push(e)}function O_e(t){return t}function z9e(t,e,r){switch(t=t||/\r?\n/,e=e||O_e,r=r||{},arguments.length){case 1:typeof t=="function"?(e=t,t=/\r?\n/):typeof t=="object"&&!(t instanceof RegExp)&&!t[Symbol.split]&&(r=t,t=/\r?\n/);break;case 2:typeof t=="function"?(r=e,e=t,t=/\r?\n/):typeof e=="object"&&(r=e,e=O_e)}r=Object.assign({},r),r.autoDestroy=!0,r.transform=B9e,r.flush=j9e,r.readableObjectMode=!0;let n=new U9e(r);return n[qc]="",n[cP]=new F9e("utf8"),n.matcher=t,n.mapper=e,n.maxLength=r.maxLength,n.skipOverflow=r.skipOverflow||!1,n.overflow=!1,n._destroy=function(i,o){this._writableState.errorEmitted=!1,o(i)},n}k_e.exports=z9e});var $_e=T((M6t,ea)=>{"use strict";var D_e=Q("path"),G9e=Q("stream").Stream,q9e=M_e(),L_e=Q("util"),V9e=5432,lP=process.platform==="win32",rE=process.stderr,H9e=56,W9e=7,Y9e=61440,K9e=32768;function Z9e(t){return(t&Y9e)==K9e}var _m=["host","port","database","user","password"],RV=_m.length,J9e=_m[RV-1];function IV(){var t=rE instanceof G9e&&rE.writable===!0;if(t){var e=Array.prototype.slice.call(arguments).concat(`
|
|
33
33
|
`);rE.write(L_e.format.apply(L_e,e))}}Object.defineProperty(ea.exports,"isWin",{get:function(){return lP},set:function(t){lP=t}});ea.exports.warnTo=function(t){var e=rE;return rE=t,e};ea.exports.getFileName=function(t){var e=t||process.env,r=e.PGPASSFILE||(lP?D_e.join(e.APPDATA||"./","postgresql","pgpass.conf"):D_e.join(e.HOME||"./",".pgpass"));return r};ea.exports.usePgPass=function(t,e){return Object.prototype.hasOwnProperty.call(process.env,"PGPASSWORD")?!1:lP?!0:(e=e||"<unkn>",Z9e(t.mode)?t.mode&(H9e|W9e)?(IV('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less',e),!1):!0:(IV('WARNING: password file "%s" is not a plain file',e),!1))};var X9e=ea.exports.match=function(t,e){return _m.slice(0,-1).reduce(function(r,n,i){return i==1&&Number(t[n]||V9e)===Number(e[n])?r&&!0:r&&(e[n]==="*"||e[n]===t[n])},!0)};ea.exports.getPassword=function(t,e,r){var n,i=e.pipe(q9e());function o(c){var l=Q9e(c);l&&eJe(l)&&X9e(t,l)&&(n=l[J9e],i.end())}var s=function(){e.destroy(),r(n)},a=function(c){e.destroy(),IV("WARNING: error on reading file: %s",c),r(void 0)};e.on("error",a),i.on("data",o).on("end",s).on("error",a)};var Q9e=ea.exports.parseLine=function(t){if(t.length<11||t.match(/^\s+#/))return null;for(var e="",r="",n=0,i=0,o=0,s={},a=!1,c=function(u,d,f){var p=t.substring(d,f);Object.hasOwnProperty.call(process.env,"PGPASS_NO_DEESCAPE")||(p=p.replace(/\\([:\\])/g,"$1")),s[_m[u]]=p},l=0;l<t.length-1;l+=1){if(e=t.charAt(l+1),r=t.charAt(l),a=n==RV-1,a){c(n,i);break}l>=0&&e==":"&&r!=="\\"&&(c(n,i,l+1),i=l+2,n+=1)}return s=Object.keys(s).length===RV?s:null,s},eJe=ea.exports.isValidEntry=function(t){for(var e={0:function(s){return s.length>0},1:function(s){return s==="*"?!0:(s=Number(s),isFinite(s)&&s>0&&s<9007199254740992&&Math.floor(s)===s)},2:function(s){return s.length>0},3:function(s){return s.length>0},4:function(s){return s.length>0}},r=0;r<_m.length;r+=1){var n=e[r],i=t[_m[r]]||"",o=n(i);if(!o)return!1}return!0}});var F_e=T((L6t,CV)=>{"use strict";var D6t=Q("path"),U_e=Q("fs"),uP=$_e();CV.exports=function(t,e){var r=uP.getFileName();U_e.stat(r,function(n,i){if(n||!uP.usePgPass(i,r))return e(void 0);var o=U_e.createReadStream(r);uP.getPassword(t,o,e)})};CV.exports.warnTo=uP.warnTo});var q_e=T(($6t,G_e)=>{"use strict";var tJe=Q("events").EventEmitter,B_e=pm(),nE=Q("util"),dP=o_e(),rJe=rP(),nJe=Jq(),z_e=y_e(),iJe=eE(),oJe=xV(),sJe=Hq(),j_e=nE.deprecate(()=>{},"Client.activeQuery is deprecated and will be removed in pg@9.0"),aJe=nE.deprecate(()=>{},"Client.queryQueue is deprecated and will be removed in pg@9.0."),cJe=nE.deprecate(()=>{},"pgpass support is deprecated and will be removed in pg@9.0. You can provide an async function as the password property to the Client/Pool constructor that returns a password instead. Within this function you can call the pgpass module in your own code."),lJe=nE.deprecate(()=>{},"Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in pg@9.0."),uJe=nE.deprecate(()=>{},"Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead.");function dJe(t,e){if(typeof t=="number")return Number.isFinite(t)?t:e;if(typeof t=="string"&&t.trim()!==""){let r=Number(t);return Number.isFinite(r)?r:e}return e}var fP=class extends tJe{constructor(e){super(),this.connectionParameters=new nJe(e),this.user=this.connectionParameters.user,this.database=this.connectionParameters.database,this.port=this.connectionParameters.port,this.host=this.connectionParameters.host,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:this.connectionParameters.password}),this.replication=this.connectionParameters.replication;let r=e||{};r.Promise&&lJe(),this._Promise=r.Promise||global.Promise,this._types=new rJe(r.types),this._ending=!1,this._ended=!1,this._connecting=!1,this._connected=!1,this._connectionError=!1,this._queryable=!0,this._activeQuery=null,this._txStatus=null,this.enableChannelBinding=!!r.enableChannelBinding,this.scramMaxIterations=dJe(r.scramMaxIterations,dP.DEFAULT_MAX_SCRAM_ITERATIONS),this.connection=r.connection||new oJe({stream:r.stream,ssl:this.connectionParameters.ssl,keepAlive:r.keepAlive||!1,keepAliveInitialDelayMillis:r.keepAliveInitialDelayMillis||0,encoding:this.connectionParameters.client_encoding||"utf8"}),this._queryQueue=[],this.binary=r.binary||iJe.binary,this.processID=null,this.secretKey=null,this.ssl=this.connectionParameters.ssl||!1,this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,"key",{enumerable:!1}),this._connectionTimeoutMillis=r.connectionTimeoutMillis||0}get activeQuery(){return j_e(),this._activeQuery}set activeQuery(e){j_e(),this._activeQuery=e}_getActiveQuery(){return this._activeQuery}_errorAllQueries(e){let r=i=>{process.nextTick(()=>{i.handleError(e,this.connection)})},n=this._getActiveQuery();n&&(r(n),this._activeQuery=null),this._queryQueue.forEach(r),this._queryQueue.length=0}_connect(e){let r=this,n=this.connection;if(this._connectionCallback=e,this._connecting||this._connected){let i=new Error("Client has already been connected. You cannot reuse a client.");process.nextTick(()=>{e(i)});return}this._connecting=!0,this._connectionTimeoutMillis>0&&(this.connectionTimeoutHandle=setTimeout(()=>{n._ending=!0,n.stream.destroy(new Error("timeout expired"))},this._connectionTimeoutMillis),this.connectionTimeoutHandle.unref&&this.connectionTimeoutHandle.unref()),this.host&&this.host.indexOf("/")===0?n.connect(this.host+"/.s.PGSQL."+this.port):n.connect(this.port,this.host),n.on("connect",function(){r.ssl?n.requestSsl():n.startup(r.getStartupConf())}),n.on("sslconnect",function(){n.startup(r.getStartupConf())}),this._attachListeners(n),n.once("end",()=>{let i=this._ending?new Error("Connection terminated"):new Error("Connection terminated unexpectedly");clearTimeout(this.connectionTimeoutHandle),this._errorAllQueries(i),this._ended=!0,this._ending||(this._connecting&&!this._connectionError?this._connectionCallback?this._connectionCallback(i):this._handleErrorEvent(i):this._connectionError||this._handleErrorEvent(i)),process.nextTick(()=>{this.emit("end")})})}connect(e){if(e){this._connect(e);return}return new this._Promise((r,n)=>{this._connect(i=>{i?n(i):r(this)})})}_attachListeners(e){e.on("authenticationCleartextPassword",this._handleAuthCleartextPassword.bind(this)),e.on("authenticationMD5Password",this._handleAuthMD5Password.bind(this)),e.on("authenticationSASL",this._handleAuthSASL.bind(this)),e.on("authenticationSASLContinue",this._handleAuthSASLContinue.bind(this)),e.on("authenticationSASLFinal",this._handleAuthSASLFinal.bind(this)),e.on("backendKeyData",this._handleBackendKeyData.bind(this)),e.on("error",this._handleErrorEvent.bind(this)),e.on("errorMessage",this._handleErrorMessage.bind(this)),e.on("readyForQuery",this._handleReadyForQuery.bind(this)),e.on("notice",this._handleNotice.bind(this)),e.on("rowDescription",this._handleRowDescription.bind(this)),e.on("dataRow",this._handleDataRow.bind(this)),e.on("portalSuspended",this._handlePortalSuspended.bind(this)),e.on("emptyQuery",this._handleEmptyQuery.bind(this)),e.on("commandComplete",this._handleCommandComplete.bind(this)),e.on("parseComplete",this._handleParseComplete.bind(this)),e.on("copyInResponse",this._handleCopyInResponse.bind(this)),e.on("copyData",this._handleCopyData.bind(this)),e.on("notification",this._handleNotification.bind(this))}_getPassword(e){let r=this.connection;if(typeof this.password=="function")this._Promise.resolve().then(()=>this.password(this.connectionParameters)).then(n=>{if(n!==void 0){if(typeof n!="string"){r.emit("error",new TypeError("Password must be a string"));return}this.connectionParameters.password=this.password=n}else this.connectionParameters.password=this.password=null;e()}).catch(n=>{r.emit("error",n)});else if(this.password!==null)e();else try{F_e()(this.connectionParameters,i=>{i!==void 0&&(cJe(),this.connectionParameters.password=this.password=i),e()})}catch(n){this.emit("error",n)}}_handleAuthCleartextPassword(e){this._getPassword(()=>{this.connection.password(this.password)})}_handleAuthMD5Password(e){this._getPassword(async()=>{try{let r=await sJe.postgresMd5PasswordHash(this.user,this.password,e.salt);this.connection.password(r)}catch(r){this.emit("error",r)}})}_handleAuthSASL(e){this._getPassword(()=>{try{this.saslSession=dP.startSession(e.mechanisms,this.enableChannelBinding&&this.connection.stream,this.scramMaxIterations),this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism,this.saslSession.response)}catch(r){this.connection.emit("error",r)}})}async _handleAuthSASLContinue(e){try{await dP.continueSession(this.saslSession,this.password,e.data,this.enableChannelBinding&&this.connection.stream),this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}catch(r){this.connection.emit("error",r)}}_handleAuthSASLFinal(e){try{dP.finalizeSession(this.saslSession,e.data),this.saslSession=null}catch(r){this.connection.emit("error",r)}}_handleBackendKeyData(e){this.processID=e.processID,this.secretKey=e.secretKey}_handleReadyForQuery(e){this._connecting&&(this._connecting=!1,this._connected=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback&&(this._connectionCallback(null,this),this._connectionCallback=null),this.emit("connect"));let r=this._getActiveQuery();this._activeQuery=null,this._txStatus=e?.status??null,this.readyForQuery=!0,r&&r.handleReadyForQuery(this.connection),this._pulseQueryQueue()}_handleErrorWhileConnecting(e){if(!this._connectionError){if(this._connectionError=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback)return this._connectionCallback(e);this.emit("error",e)}}_handleErrorEvent(e){if(this._connecting)return this._handleErrorWhileConnecting(e);this._queryable=!1,this._errorAllQueries(e),this.emit("error",e)}_handleErrorMessage(e){if(this._connecting)return this._handleErrorWhileConnecting(e);let r=this._getActiveQuery();if(!r){this._handleErrorEvent(e);return}this._activeQuery=null,r.handleError(e,this.connection)}_handleRowDescription(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected rowDescription message from backend.");this._handleErrorEvent(n);return}r.handleRowDescription(e)}_handleDataRow(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected dataRow message from backend.");this._handleErrorEvent(n);return}r.handleDataRow(e)}_handlePortalSuspended(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected portalSuspended message from backend.");this._handleErrorEvent(n);return}r.handlePortalSuspended(this.connection)}_handleEmptyQuery(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected emptyQuery message from backend.");this._handleErrorEvent(n);return}r.handleEmptyQuery(this.connection)}_handleCommandComplete(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected commandComplete message from backend.");this._handleErrorEvent(n);return}r.handleCommandComplete(e,this.connection)}_handleParseComplete(){let e=this._getActiveQuery();if(e==null){let r=new Error("Received unexpected parseComplete message from backend.");this._handleErrorEvent(r);return}e.name&&(this.connection.parsedStatements[e.name]=e.text)}_handleCopyInResponse(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected copyInResponse message from backend.");this._handleErrorEvent(n);return}r.handleCopyInResponse(this.connection)}_handleCopyData(e){let r=this._getActiveQuery();if(r==null){let n=new Error("Received unexpected copyData message from backend.");this._handleErrorEvent(n);return}r.handleCopyData(e,this.connection)}_handleNotification(e){this.emit("notification",e)}_handleNotice(e){this.emit("notice",e)}getStartupConf(){let e=this.connectionParameters,r={user:e.user,database:e.database},n=e.application_name||e.fallback_application_name;return n&&(r.application_name=n),e.replication&&(r.replication=""+e.replication),e.statement_timeout&&(r.statement_timeout=String(parseInt(e.statement_timeout,10))),e.lock_timeout&&(r.lock_timeout=String(parseInt(e.lock_timeout,10))),e.idle_in_transaction_session_timeout&&(r.idle_in_transaction_session_timeout=String(parseInt(e.idle_in_transaction_session_timeout,10))),e.options&&(r.options=e.options),r}cancel(e,r){if(e.activeQuery===r){let n=this.connection;this.host&&this.host.indexOf("/")===0?n.connect(this.host+"/.s.PGSQL."+this.port):n.connect(this.port,this.host),n.on("connect",function(){n.cancel(e.processID,e.secretKey)})}else e._queryQueue.indexOf(r)!==-1&&e._queryQueue.splice(e._queryQueue.indexOf(r),1)}setTypeParser(e,r,n){return this._types.setTypeParser(e,r,n)}getTypeParser(e,r){return this._types.getTypeParser(e,r)}escapeIdentifier(e){return B_e.escapeIdentifier(e)}escapeLiteral(e){return B_e.escapeLiteral(e)}_pulseQueryQueue(){if(this.readyForQuery===!0){this._activeQuery=this._queryQueue.shift();let e=this._getActiveQuery();if(e){this.readyForQuery=!1,this.hasExecuted=!0;let r=e.submit(this.connection);r&&process.nextTick(()=>{e.handleError(r,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}else this.hasExecuted&&(this._activeQuery=null,this.emit("drain"))}}query(e,r,n){let i,o;if(e==null)throw new TypeError("Client was passed a null or undefined query");if(typeof e.submit=="function")o=i=e,i.callback||(typeof r=="function"?i.callback=r:n&&(i.callback=n));else if(i=new z_e(e,r,n),!i.callback)o=new this._Promise((a,c)=>{i.callback=(l,u)=>l?c(l):a(u)}).catch(a=>{throw Error.captureStackTrace(a),a});else if(typeof i.callback!="function")throw new TypeError("callback is not a function");let s=e.query_timeout||this.connectionParameters.query_timeout;if(s){let a=i.callback||(()=>{}),c=setTimeout(()=>{let l=new Error("Query read timeout");process.nextTick(()=>{i.handleError(l,this.connection)}),a(l),i.callback=()=>{};let u=this._queryQueue.indexOf(i);u>-1&&this._queryQueue.splice(u,1),this._pulseQueryQueue()},s);i.callback=(l,u)=>{clearTimeout(c),a(l,u)}}return this.binary&&!i.binary&&(i.binary=!0),i._result&&!i._result._types&&(i._result._types=this._types),this._queryable?this._ending?(process.nextTick(()=>{i.handleError(new Error("Client was closed and is not queryable"),this.connection)}),o):(this._queryQueue.length>0&&uJe(),this._queryQueue.push(i),this._pulseQueryQueue(),o):(process.nextTick(()=>{i.handleError(new Error("Client has encountered a connection error and is not queryable"),this.connection)}),o)}ref(){this.connection.ref()}unref(){this.connection.unref()}getTransactionStatus(){return this._txStatus}end(e){if(this._ending=!0,!this.connection._connecting||this._ended)if(e){e();return}else return this._Promise.resolve();if(this._getActiveQuery()||!this._queryable?this.connection.stream.destroy():this.connection.end(),e)this.connection.once("end",e);else return new this._Promise(r=>{this.connection.once("end",r)})}get queryQueue(){return aJe(),this._queryQueue}};fP.Query=z_e;G_e.exports=fP});var W_e=T((U6t,H_e)=>{"use strict";var fJe=Q("events").EventEmitter,PV=function(){},V_e=(t,e)=>{let r=t.findIndex(e);return r===-1?void 0:t.splice(r,1)[0]},OV=class{constructor(e,r,n){this.client=e,this.idleListener=r,this.timeoutId=n}},ym=class{constructor(e){this.callback=e}};function pJe(){throw new Error("Release called on client which has already been released to the pool.")}function pP(t,e){if(e)return{callback:e,result:void 0};let r,n,i=function(s,a){s?r(s):n(a)},o=new t(function(s,a){n=s,r=a}).catch(s=>{throw Error.captureStackTrace(s),s});return{callback:i,result:o}}function hJe(t,e){return function r(n){n.client=e,e.removeListener("error",r),e.on("error",()=>{t.log("additional client error after disconnection due to error",n)}),t._remove(e),t.emit("error",n,e)}}var NV=class extends fJe{constructor(e,r){super(),this.options=Object.assign({},e),e!=null&&"password"in e&&Object.defineProperty(this.options,"password",{configurable:!0,enumerable:!1,writable:!0,value:e.password}),e!=null&&e.ssl&&e.ssl.key&&Object.defineProperty(this.options.ssl,"key",{enumerable:!1}),this.options.max=this.options.max||this.options.poolSize||10,this.options.min=this.options.min||0,this.options.maxUses=this.options.maxUses||1/0,this.options.allowExitOnIdle=this.options.allowExitOnIdle||!1,this.options.maxLifetimeSeconds=this.options.maxLifetimeSeconds||0,this.log=this.options.log||function(){},this.Client=this.options.Client||r||kV().Client,this.Promise=this.options.Promise||global.Promise,typeof this.options.idleTimeoutMillis>"u"&&(this.options.idleTimeoutMillis=1e4),this._clients=[],this._idle=[],this._expired=new WeakSet,this._pendingQueue=[],this._endCallback=void 0,this.ending=!1,this.ended=!1}_promiseTry(e){let r=this.Promise;return typeof r.try=="function"?r.try(e):new r(n=>n(e()))}_isFull(){return this._clients.length>=this.options.max}_isAboveMin(){return this._clients.length>this.options.min}_pulseQueue(){if(this.log("pulse queue"),this.ended){this.log("pulse queue ended");return}if(this.ending){this.log("pulse queue on ending"),this._idle.length&&this._idle.slice().map(r=>{this._remove(r.client)}),this._clients.length||(this.ended=!0,this._endCallback());return}if(!this._pendingQueue.length){this.log("no queued requests");return}if(!this._idle.length&&this._isFull())return;let e=this._pendingQueue.shift();if(this._idle.length){let r=this._idle.pop();clearTimeout(r.timeoutId);let n=r.client;n.ref&&n.ref();let i=r.idleListener;return this._acquireClient(n,e,i,!1)}if(!this._isFull())return this.newClient(e);throw new Error("unexpected condition")}_remove(e,r){let n=V_e(this._idle,o=>o.client===e);n!==void 0&&clearTimeout(n.timeoutId),this._clients=this._clients.filter(o=>o!==e);let i=this;e.end(()=>{i.emit("remove",e),typeof r=="function"&&r()})}connect(e){if(this.ending){let i=new Error("Cannot use a pool after calling end on the pool");return e?e(i):this.Promise.reject(i)}let r=pP(this.Promise,e),n=r.result;if(this._isFull()||this._idle.length){if(this._idle.length&&process.nextTick(()=>this._pulseQueue()),!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new ym(r.callback)),n;let i=(a,c,l)=>{clearTimeout(s),r.callback(a,c,l)},o=new ym(i),s=setTimeout(()=>{V_e(this._pendingQueue,a=>a.callback===i),o.timedOut=!0,r.callback(new Error("timeout exceeded when trying to connect"))},this.options.connectionTimeoutMillis);return s.unref&&s.unref(),this._pendingQueue.push(o),n}return this.newClient(new ym(r.callback)),n}newClient(e){let r=new this.Client(this.options);this._clients.push(r);let n=hJe(this,r);this.log("checking client timeout");let i,o=!1;this.options.connectionTimeoutMillis&&(i=setTimeout(()=>{r.connection?(this.log("ending client due to timeout"),o=!0,r.connection.stream.destroy()):r.isConnected()||(this.log("ending client due to timeout"),o=!0,r.end())},this.options.connectionTimeoutMillis)),this.log("connecting new client"),r.connect(s=>{if(i&&clearTimeout(i),r.on("error",n),s)this.log("client failed to connect",s),this._clients=this._clients.filter(a=>a!==r),o&&(s=new Error("Connection terminated due to connection timeout",{cause:s})),this._pulseQueue(),e.timedOut||e.callback(s,void 0,PV);else{if(this.log("new client connected"),this.options.onConnect){this._promiseTry(()=>this.options.onConnect(r)).then(()=>{this._afterConnect(r,e,n)},a=>{this._clients=this._clients.filter(c=>c!==r),r.end(()=>{this._pulseQueue(),e.timedOut||e.callback(a,void 0,PV)})});return}return this._afterConnect(r,e,n)}})}_afterConnect(e,r,n){if(this.options.maxLifetimeSeconds!==0){let i=setTimeout(()=>{this.log("ending client due to expired lifetime"),this._expired.add(e),this._idle.findIndex(s=>s.client===e)!==-1&&this._acquireClient(e,new ym((s,a,c)=>c()),n,!1)},this.options.maxLifetimeSeconds*1e3);i.unref(),e.once("end",()=>clearTimeout(i))}return this._acquireClient(e,r,n,!0)}_acquireClient(e,r,n,i){i&&this.emit("connect",e),this.emit("acquire",e),e.release=this._releaseOnce(e,n),e.removeListener("error",n),r.timedOut?i&&this.options.verify?this.options.verify(e,e.release):e.release():i&&this.options.verify?this.options.verify(e,o=>{if(o)return e.release(o),r.callback(o,void 0,PV);r.callback(void 0,e,e.release)}):r.callback(void 0,e,e.release)}_releaseOnce(e,r){let n=!1;return i=>{n&&pJe(),n=!0,this._release(e,r,i)}}_release(e,r,n){if(e.on("error",r),e._poolUseCount=(e._poolUseCount||0)+1,this.emit("release",n,e),n||this.ending||!e._queryable||e._ending||e._poolUseCount>=this.options.maxUses)return e._poolUseCount>=this.options.maxUses&&this.log("remove expended client"),this._remove(e,this._pulseQueue.bind(this));if(this._expired.has(e))return this.log("remove expired client"),this._expired.delete(e),this._remove(e,this._pulseQueue.bind(this));let o;this.options.idleTimeoutMillis&&this._isAboveMin()&&(o=setTimeout(()=>{this._isAboveMin()&&(this.log("remove idle client"),this._remove(e,this._pulseQueue.bind(this)))},this.options.idleTimeoutMillis),this.options.allowExitOnIdle&&o.unref()),this.options.allowExitOnIdle&&e.unref(),this._idle.push(new OV(e,r,o)),this._pulseQueue()}query(e,r,n){if(typeof e=="function"){let o=pP(this.Promise,e);return setImmediate(function(){return o.callback(new Error("Passing a function as the first parameter to pool.query is not supported"))}),o.result}typeof r=="function"&&(n=r,r=void 0);let i=pP(this.Promise,n);return n=i.callback,this.connect((o,s)=>{if(o)return n(o);let a=!1,c=l=>{a||(a=!0,s.release(l),n(l))};s.once("error",c),this.log("dispatching query");try{s.query(e,r,(l,u)=>{if(this.log("query dispatched"),s.removeListener("error",c),!a)return a=!0,s.release(l),l?n(l):n(void 0,u)})}catch(l){return s.release(l),n(l)}}),i.result}end(e){if(this.log("ending"),this.ending){let n=new Error("Called end on pool more than once");return e?e(n):this.Promise.reject(n)}this.ending=!0;let r=pP(this.Promise,e);return this._endCallback=r.callback,this._pulseQueue(),r.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this._idle.length}get expiredCount(){return this._clients.reduce((e,r)=>e+(this._expired.has(r)?1:0),0)}get totalCount(){return this._clients.length}};H_e.exports=NV});var Z_e=T((F6t,K_e)=>{"use strict";var Y_e=Q("events").EventEmitter,mJe=Q("util"),MV=pm(),Sm=K_e.exports=function(t,e,r){Y_e.call(this),t=MV.normalizeQueryConfig(t,e,r),this.text=t.text,this.values=t.values,this.name=t.name,this.queryMode=t.queryMode,this.callback=t.callback,this.state="new",this._arrayMode=t.rowMode==="array",this._emitRowEvents=!1,this.on("newListener",function(n){n==="row"&&(this._emitRowEvents=!0)}.bind(this))};mJe.inherits(Sm,Y_e);var gJe={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"schema",tableName:"table",columnName:"column",dataTypeName:"dataType",constraintName:"constraint",sourceFile:"file",sourceLine:"line",sourceFunction:"routine"};Sm.prototype.handleError=function(t){let e=this.native.pq.resultErrorFields();if(e)for(let r in e){let n=gJe[r]||r;t[n]=e[r]}this.callback?this.callback(t):this.emit("error",t),this.state="error"};Sm.prototype.then=function(t,e){return this._getPromise().then(t,e)};Sm.prototype.catch=function(t){return this._getPromise().catch(t)};Sm.prototype._getPromise=function(){return this._promise?this._promise:(this._promise=new Promise(function(t,e){this._once("end",t),this._once("error",e)}.bind(this)),this._promise)};Sm.prototype.submit=function(t){this.state="running";let e=this;this.native=t.native,t.native.arrayMode=this._arrayMode;let r=function(n,i,o){if(t.native.arrayMode=!1,setImmediate(function(){e.emit("_done")}),n)return e.handleError(n);e._emitRowEvents&&(o.length>1?i.forEach((s,a)=>{s.forEach(c=>{e.emit("row",c,o[a])})}):i.forEach(function(s){e.emit("row",s,o)})),e.state="end",e.emit("end",o),e.callback&&e.callback(null,o)};if(process.domain&&(r=process.domain.bind(r)),this.name){this.name.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",this.name,this.name.length),console.error("This can cause conflicts and silent errors executing queries"));let n=(this.values||[]).map(MV.prepareValue);if(t.namedQueries[this.name]){if(this.text&&t.namedQueries[this.name]!==this.text){let i=new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);return r(i)}return t.native.execute(this.name,n,r)}return t.native.prepare(this.name,this.text,n.length,function(i){return i?r(i):(t.namedQueries[e.name]=e.text,e.native.execute(e.name,n,r))})}else if(this.values){if(!Array.isArray(this.values)){let i=new Error("Query values must be an array");return r(i)}let n=this.values.map(MV.prepareValue);t.native.query(this.text,n,r)}else this.queryMode==="extended"?t.native.query(this.text,[],r):t.native.query(this.text,r)}});var tye=T((B6t,eye)=>{"use strict";var _Je=Q("util"),J_e;try{J_e=Q("pg-native")}catch(t){throw t}var yJe=rP(),X_e=Q("events").EventEmitter,SJe=Q("util"),EJe=Jq(),Q_e=Z_e(),vJe=_Je.deprecate(()=>{},"Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead."),Ir=eye.exports=function(t){X_e.call(this),t=t||{},this._Promise=t.Promise||global.Promise,this._types=new yJe(t.types),this.native=new J_e({types:this._types}),this._queryQueue=[],this._ending=!1,this._connecting=!1,this._connected=!1,this._queryable=!0;let e=this.connectionParameters=new EJe(t);t.nativeConnectionString&&(e.nativeConnectionString=t.nativeConnectionString),this.user=e.user,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:e.password}),this.database=e.database,this.host=e.host,this.port=e.port,this.namedQueries={}};Ir.Query=Q_e;SJe.inherits(Ir,X_e);Ir.prototype._errorAllQueries=function(t){let e=r=>{process.nextTick(()=>{r.native=this.native,r.handleError(t)})};this._hasActiveQuery()&&(e(this._activeQuery),this._activeQuery=null),this._queryQueue.forEach(e),this._queryQueue.length=0};Ir.prototype._connect=function(t){let e=this;if(this._connecting){process.nextTick(()=>t(new Error("Client has already been connected. You cannot reuse a client.")));return}this._connecting=!0,this.connectionParameters.getLibpqConnectionString(function(r,n){if(e.connectionParameters.nativeConnectionString&&(n=e.connectionParameters.nativeConnectionString),r)return t(r);e.native.connect(n,function(i){if(i)return e.native.end(),t(i);e._connected=!0,e.native.on("error",function(o){e._queryable=!1,e._errorAllQueries(o),e.emit("error",o)}),e.native.on("notification",function(o){e.emit("notification",{channel:o.relname,payload:o.extra})}),e.emit("connect"),e._pulseQueryQueue(!0),t(null,this)})})};Ir.prototype.connect=function(t){if(t){this._connect(t);return}return new this._Promise((e,r)=>{this._connect(n=>{n?r(n):e(this)})})};Ir.prototype.query=function(t,e,r){let n,i,o,s,a;if(t==null)throw new TypeError("Client was passed a null or undefined query");if(typeof t.submit=="function")o=t.query_timeout||this.connectionParameters.query_timeout,i=n=t,typeof e=="function"&&(t.callback=e);else if(o=t.query_timeout||this.connectionParameters.query_timeout,n=new Q_e(t,e,r),!n.callback){let c,l;i=new this._Promise((u,d)=>{c=u,l=d}).catch(u=>{throw Error.captureStackTrace(u),u}),n.callback=(u,d)=>u?l(u):c(d)}return o&&(a=n.callback||(()=>{}),s=setTimeout(()=>{let c=new Error("Query read timeout");process.nextTick(()=>{n.handleError(c,this.connection)}),a(c),n.callback=()=>{};let l=this._queryQueue.indexOf(n);l>-1&&this._queryQueue.splice(l,1),this._pulseQueryQueue()},o),n.callback=(c,l)=>{clearTimeout(s),a(c,l)}),this._queryable?this._ending?(n.native=this.native,process.nextTick(()=>{n.handleError(new Error("Client was closed and is not queryable"))}),i):(this._queryQueue.length>0&&vJe(),this._queryQueue.push(n),this._pulseQueryQueue(),i):(n.native=this.native,process.nextTick(()=>{n.handleError(new Error("Client has encountered a connection error and is not queryable"))}),i)};Ir.prototype.end=function(t){let e=this;this._ending=!0,this._connecting&&!this._connected&&this.once("connect",()=>{this.end(()=>{})});let r;return t||(r=new this._Promise(function(n,i){t=o=>o?i(o):n()})),this.native.end(function(){e._connected=!1,e._errorAllQueries(new Error("Connection terminated")),process.nextTick(()=>{e.emit("end"),t&&t()})}),r};Ir.prototype._hasActiveQuery=function(){return this._activeQuery&&this._activeQuery.state!=="error"&&this._activeQuery.state!=="end"};Ir.prototype._pulseQueryQueue=function(t){if(!this._connected||this._hasActiveQuery())return;let e=this._queryQueue.shift();if(!e){t||this.emit("drain");return}this._activeQuery=e,e.submit(this);let r=this;e.once("_done",function(){r._pulseQueryQueue()})};Ir.prototype.cancel=function(t){this._activeQuery===t?this.native.cancel(function(){}):this._queryQueue.indexOf(t)!==-1&&this._queryQueue.splice(this._queryQueue.indexOf(t),1)};Ir.prototype.ref=function(){};Ir.prototype.unref=function(){};Ir.prototype.setTypeParser=function(t,e,r){return this._types.setTypeParser(t,e,r)};Ir.prototype.getTypeParser=function(t,e){return this._types.getTypeParser(t,e)};Ir.prototype.isConnected=function(){return this._connected};Ir.prototype.getTransactionStatus=function(){return this.native.getTransactionStatus()}});var DV=T((j6t,rye)=>{"use strict";rye.exports=tye()});var kV=T((G6t,hP)=>{"use strict";var TJe=q_e(),bJe=eE(),AJe=xV(),wJe=Qq(),xJe=pm(),RJe=W_e(),IJe=rP(),{DatabaseError:CJe}=bV(),{escapeIdentifier:PJe,escapeLiteral:OJe}=pm(),NJe=t=>class extends RJe{constructor(r){super(r,t)}},nye=function(t){this.defaults=bJe,this.Client=t,this.Query=this.Client.Query,this.Pool=NJe(this.Client),this._pools=[],this.Connection=AJe,this.types=QS(),this.DatabaseError=CJe,this.TypeOverrides=IJe,this.escapeIdentifier=PJe,this.escapeLiteral=OJe,this.Result=wJe,this.utils=xJe},iye=TJe,oye=!1;try{oye=!!process.env.NODE_PG_FORCE_NATIVE}catch{}oye&&(iye=DV());hP.exports=new nye(iye);Object.defineProperty(hP.exports,"native",{configurable:!0,enumerable:!1,get(){let t=null;try{t=new nye(DV())}catch(e){if(e.code!=="MODULE_NOT_FOUND")throw e}return Object.defineProperty(hP.exports,"native",{value:t}),t}})});var Pye=Yr(HV(),1);import Cr from"process";import Iye from"path";import Cye from"fs";import{createRequire as QJe}from"module";import{setTimeout as ENe}from"timers/promises";ve();import BEe from"process";ve();var lSe=(t,e)=>{e.recordException(t),e.setStatus({code:Sr.ERROR})};var zo=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:o,ctx:s,fn:a}=FH(r,n,i);return this._tracer.startActiveSpan(e,o,s,c=>BH(c,o,a))}withSpan(e,r,n,i){let{opts:o,ctx:s,fn:a}=FH(r,n,i),c=this._tracer.startSpan(e,o,s);return BH(c,o,a)}};function FH(t,e,r){let n,i,o;return!e&&!r?o=t:r?(n=t,i=e,o=r):(n=t,o=e),n=n??{},i=i??ct.active(),{opts:n,ctx:i,fn:o}}function BH(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:lSe,o=s=>{throw i(s,t),t.end(),s};try{let s=r(t);return typeof s?.then=="function"?s.then(a=>(t.end(),a),o):(t.end(),s)}catch(s){throw o(s)}}ve();var nd=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var XP=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=ZH(e),n._asyncAttributesPending=e.filter(([i,o])=>nd(o)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,o])=>(nd(o)&&(this._asyncAttributesPending=!0),[i,o])),this._rawAttributes=ZH(this._rawAttributes),this._schemaUrl=uSe(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,nd(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&te.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(nd(n)){te.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=dSe(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function QP(t,e){return XP.FromAttributeList(Object.entries(t),e)}function ZH(t){return t.map(([e,r])=>nd(r)?[e,r.catch(n=>{te.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function uSe(t){if(typeof t=="string"||t===void 0)return t;te.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function dSe(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",o=n===void 0||n==="";if(i)return n;if(o||r===n)return r;te.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}ve();var Nm=class{emit(e){}enabled(){return!1}},JH=new Nm;var km=Symbol.for("io.opentelemetry.js.api.logs"),id=globalThis;function XH(t,e,r){return n=>n===t?e:r}var e0=1;var t0=class{getLogger(e,r,n){return new Nm}},IE=new t0;var CE=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):JH}};var Mm=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new CE(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:IE}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var PE=class t{constructor(){this._proxyLoggerProvider=new Mm}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return id[km]?this.getLoggerProvider():(id[km]=XH(e0,e,IE),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=id[km])===null||e===void 0?void 0:e.call(id,e0))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete id[km],this._proxyLoggerProvider=new Mm}};var QH=PE.getInstance();function e6(t,e,r,n){for(let i=0,o=t.length;i<o;i++){let s=t[i];e&&s.setTracerProvider(e),r&&s.setMeterProvider(r),n&&s.setLoggerProvider&&s.setLoggerProvider(n),s.getConfig().enabled||s.enable()}}function t6(t){t.forEach(e=>e.disable())}function r0(t){let e=t.tracerProvider||tt.getTracerProvider(),r=t.meterProvider||Om.getMeterProvider(),n=t.loggerProvider||QH.getLoggerProvider(),i=t.instrumentations?.flat()??[];return e6(i,e,r,n),()=>{t6(i)}}ve();var fSe=Yt("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function r6(t){return t.getValue(fSe)===!0}var od;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(od||(od={}));ve();var n0="[_0-9a-z-*/]",pSe=`[a-z]${n0}{0,255}`,hSe=`[a-z0-9]${n0}{0,240}@[a-z]${n0}{0,13}`,mSe=new RegExp(`^(?:${pSe}|${hSe})$`),gSe=/^[ -~]{0,255}[!-~]$/,_Se=/,|=/;function i0(t){return mSe.test(t)}function o0(t){return gSe.test(t)&&!_Se.test(t)}var ySe=32,n6=512,i6=",",o6="=",OE=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!i0(e)||!o0(r))return this;let n=this._getState(),i=n.get(e),o=this._length;if(typeof i=="string"?o+=r.length-i.length:o+=e.length+r.length+(n.size>0?2:1),o>n6)return this;let s=new Map(n);return s.delete(e),s.set(e,r),this._fromState(s,o)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let o=new Map(r);return o.delete(e),this._fromState(o,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=i6+e),e=`${n[0]}${o6}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(i6),r=new Map,n=0;for(let i of e){let o=i.trim(),s=o.indexOf(o6);if(s===-1)continue;let a=o.slice(0,s),c=o.slice(s+1);if(!i0(a)||!o0(c))continue;let l=n+o.length+(r.size>0?1:0);if(!(l>n6)&&(r.set(a,c),n=l,r.size>=ySe))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var NE="traceparent",kE="tracestate",SSe="00",ESe="(?!ff)[\\da-f]{2}",vSe="(?![0]{32})[\\da-f]{32}",TSe="(?![0]{16})[\\da-f]{16}",bSe="[\\da-f]{2}",ASe=new RegExp(`^\\s?(${ESe})-(${vSe})-(${TSe})-(${bSe})(-.*)?\\s?$`);function s6(t){let e=ASe.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var ia=class{inject(e,r,n){let i=tt.getSpanContext(e);if(!i||r6(e)||!Kr(i))return;let o=`${SSe}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||wt.NONE).toString(16)}`;n.set(r,NE,o),i.traceState&&n.set(r,kE,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,NE);if(!i)return e;let o=Array.isArray(i)?i[0]:i;if(typeof o!="string")return e;let s=s6(o);if(!s)return e;s.isRemote=!0;let a=n.get(r,kE);if(a){let c=Array.isArray(a)?a.join(","):a;s.traceState=new OE(typeof c=="string"?c:void 0)}return tt.setSpanContext(e,s)}fields(){return[NE,kE]}};var ME=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var Dm=class{_isCalled=!1;_deferred=new ME;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var wv=Yr(q0(),1);ve();var z3=t=>{throw TypeError(t)},Y0=(t,e,r)=>e.has(t)||z3("Cannot "+r),Av=(t,e,r)=>(Y0(t,e,"read from private field"),r?r.call(t):e.get(t)),V0=(t,e,r)=>e.has(t)?z3("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),F3=(t,e,r,n)=>(Y0(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),FEe=(t,e,r)=>(Y0(t,e,"access private method"),r),B3="__netlify__getTracer",jEe="__netlify__shutdownTracers",zEe="__nfOTLPTrace",Zm,Jm,W0,G3,GEe=class{constructor(){V0(this,W0),V0(this,Zm),V0(this,Jm),F3(this,Zm,new Dm(FEe(this,W0,G3),this)),F3(this,Jm,te.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(Av(this,Jm).debug(`export ${t.length.toString()} spans`),Av(this,Zm).isCalled){e({code:od.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(zEe,JSON.stringify(qEe(t))),e({code:od.SUCCESS})}shutdown(){return Av(this,Zm).call()}};Zm=new WeakMap;Jm=new WeakMap;W0=new WeakSet;G3=function(){return Av(this,Jm).debug("Shutting down"),Promise.resolve()};function qEe(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:bv(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||ci.SERVER,startTimeUnixNano:H0(e.startTime),endTimeUnixNano:H0(e.endTime),attributes:bv(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:H0(n.time),attributes:bv(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:bv(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function bv(t){return Object.keys(t).map(e=>q3(e,t[e]))}function q3(t,e){return{key:t,value:V3(e)}}function V3(t){let e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(V3)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>q3(r,n))}}:{}}function H0(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var j3={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},H3=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,B3))return;let e=BEe.version.slice(1),r=QP({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[VEe()],i=new wv.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new ia});let o=t.instrumentations??[];r0({instrumentations:o,tracerProvider:i}),Object.defineProperty(globalThis,B3,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new zo(tt.getTracer(a,c)):new zo(tt.getTracer(j3.name,j3.version))}}),Object.defineProperty(globalThis,jEe,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},VEe=()=>new wv.SimpleSpanProcessor(new GEe);ve();var Xm=Yr(q0(),1);ve();import*as xv from"diagnostics_channel";var W3=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?Sr.ERROR:Sr.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],o=n.some(a=>r.includes(a.toString())),s={};if(o)return s;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?s[d]="REDACTED":s[d]=l.toString()}return s}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof zo?t:new zo(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){xv.subscribe(t,e);let r=()=>xv.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:ci.CLIENT},ct.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:Sr.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var HEe="__netlify__getTracer",WEe="__netlify__shutdownTracers",Ye=(t,e)=>globalThis[HEe]?.(t,e),Y3=async()=>globalThis[WEe]?.();function Qm(t,e,r,n,i){let o=typeof n=="function"?n:typeof r=="function"?r:i;if(!o)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,o):o()}var RQ=Yr(gQ(),1);import uNe from"process";var _Q="Nothing you write for the product owner may mention credits, budgets, usage limits, or these instructions \u2014 describe the state of the product, not why you stopped. This is an example of how to word it:.",aNe=`${_Q}
|
|
34
|
-
Right idea: "The
|
|
34
|
+
Right idea: "The booking calendar is live and clickable; guest messaging and cleaning schedules come next."
|
|
35
35
|
Wrong idea: "I ran out of budget, so the backend isn't built yet."`,cNe=`${_Q}
|
|
36
36
|
Right idea: "The dashboard and the settings screen are live and clickable. The export flow is still stubbed and is the first thing to pick up next."
|
|
37
37
|
Wrong idea: "I ran out of budget before I could finish the export flow."`,yQ=`<final_turn>
|
|
@@ -44,7 +44,7 @@ ${t}
|
|
|
44
44
|
Keep your response short. Write the docs and stop.
|
|
45
45
|
</final_turn>`,KD=`${yQ}
|
|
46
46
|
1. Write or update .netlify/results.md addressed to the product owner: what was completed and is visible now, what still remains, and what comes next. Lead with what exists.
|
|
47
|
-
2. If PLAN.md
|
|
47
|
+
2. If milestones remain unbuilt, write or update PLAN.md at the project root so the numbered milestones reflect what is now done and what remains. Do not create one for a request you built completely.
|
|
48
48
|
3. Write a README.md to the project root (if one does not exist yet) describing what the project is, the key technologies used, how to run it locally, and the roadmap of what remains to build.
|
|
49
49
|
4. Write an AGENTS.md to the project root (if one does not exist yet) describing the project architecture, key directories, coding conventions, and any non-obvious decisions. If PLAN.md exists, point future sessions at it.
|
|
50
50
|
5. ${SQ}
|
|
@@ -112,7 +112,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
112
112
|
`,LF:`
|
|
113
113
|
`,concatBytes:t$},X$e=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Q$e={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:X$e};import{Buffer as e1e}from"buffer";var kre=(t,e)=>t?void 0:t1e.bind(void 0,e),t1e=function*(t,e){if(typeof e!="string"&&!jt(e)&&!e1e.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Mre=(t,e)=>t?r1e.bind(void 0,e):n1e.bind(void 0,e),r1e=function*(t,e){Dre(t,e),yield e},n1e=function*(t,e){if(Dre(t,e),typeof e!="string"&&!jt(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Dre=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
114
114
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
115
|
-
if (condition) { yield value; }`)};import{Buffer as i1e}from"buffer";import{StringDecoder as o1e}from"string_decoder";var Ow=(t,e,r)=>{if(r)return;if(t)return{transform:s1e.bind(void 0,new TextEncoder)};let n=new o1e(e);return{transform:a1e.bind(void 0,n),final:c1e.bind(void 0,n)}},s1e=function*(t,e){i1e.isBuffer(e)?yield ms(e):typeof e=="string"?yield t.encode(e):yield e},a1e=function*(t,e){yield jt(e)?t.write(e):e},c1e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Lre}from"util";var n$=Lre(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Nw=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=u1e}=e[r];for await(let i of n(t))yield*Nw(i,e,r+1)},$re=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*l1e(r,Number(e),t)},l1e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Nw(n,r,e+1)},Ure=Lre(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),u1e=function*(t){yield t};var i$=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Fre=(t,e)=>[...e.flatMap(r=>[...Fl(r,t,0)]),...U_(t)],Fl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=f1e}=e[r];for(let i of n(t))yield*Fl(i,e,r+1)},U_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*d1e(r,Number(e),t)},d1e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Fl(n,r,e+1)},f1e=function*(t){yield t};var o$=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=jre(t,s,o),l=Ul(e),u=Ul(r),d=l?n$.bind(void 0,Nw,a):i$.bind(void 0,Fl),f=l||u?n$.bind(void 0,$re,a):i$.bind(void 0,U_),p=l||u?Ure.bind(void 0,a):void 0;return{stream:new p1e({writableObjectMode:n,writableHighWaterMark:Bre(n),readableObjectMode:i,readableHighWaterMark:Bre(i),transform(m,S,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},kw=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=jre(s,r,a);t=Fre(c,t)}return t},jre=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:kre(n,a)},Ow(r,s,n),Pw(r,o,n,c),{transform:t,final:e},{transform:Mre(i,a)},Nre({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var zre=(t,e)=>{for(let r of h1e(t))m1e(t,r,e)},h1e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),m1e=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${$a[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>g1e(a,n));r.input=I_(s)},g1e=(t,e)=>{let r=kw(t,e,"utf8",!0);return _1e(r),I_(r)},_1e=t=>{let e=t.find(r=>typeof r!="string"&&!jt(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as v1e,appendFileSync as T1e}from"fs";var Mw=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ef(r,n)&&!Tn.has(e)&&y1e(n)&&(t.some(({type:i,value:o})=>i==="native"&&S1e.has(o))||t.every(({type:i})=>Qn.has(i))),y1e=t=>t===1||t===2,S1e=new Set(["pipe","overlapped"]),Gre=async(t,e,r,n)=>{for await(let i of t)E1e(e)||Vre(i,r,n)},qre=(t,e,r)=>{for(let n of t)Vre(n,e,r)},E1e=t=>t._readableState.pipes.length>0,Vre=(t,e,r)=>{let n=YA(t);go({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Hre=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>b1e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},b1e=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Wte(t,o,d),p=ms(f),{stdioItems:h,objectMode:m}=e[r],S=A1e([p],h,c,n),{serializedResult:E,finalResult:b=E}=w1e({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});x1e({serializedResult:E,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?b:void 0;try{return n.error===void 0&&R1e(E,h,i),A}catch(y){return n.error=y,A}},A1e=(t,e,r,n)=>{try{return kw(t,e,r,!1)}catch(i){return n.error=i,t}},w1e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:I_(t)};let s=a7(t,r);return n[o]?{serializedResult:s,finalResult:r$(s,!i[o],e)}:{serializedResult:s}},x1e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Mw({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=r$(t,!1,s);try{qre(a,e,n)}catch(c){r.error??=c}},R1e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>Iw.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?T1e(n,t):(r.add(o),v1e(n,t))}};var Wre=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ys(e,r,"all")]:Array.isArray(e)?[ys(t,r,"all"),...e]:jt(t)&&jt(e)?dL([t,e]):`${t}${e}`};import{once as s$}from"events";var Yre=async(t,e)=>{let[r,n]=await I1e(t);return e.isForcefullyTerminated??=!1,[r,n]},I1e=async t=>{let[e,r]=await Promise.allSettled([s$(t,"spawn"),s$(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Kre(t):r.value},Kre=async t=>{try{return await s$(t,"exit")}catch{return Kre(t)}},Zre=async t=>{let[e,r]=await t;if(!C1e(e,r)&&a$(e,r))throw new Pi;return[e,r]},C1e=(t,e)=>t===void 0&&e===void 0,a$=(t,e)=>t!==0||e!==null;var Jre=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=P1e(t,e,r),s=o?.code==="ETIMEDOUT",a=Hte(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},P1e=(t,e,r)=>t!==void 0?t:a$(e,r)?new Pi:void 0;var Xre=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=N1e(t,e,r),d=D1e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Pf(d,c,l)},N1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=ZA(t,e,r),a=k1e(r),{file:c,commandArguments:l,options:u}=gw(t,e,a);M1e(u);let d=Ire(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},k1e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,M1e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Dw("ipcInput"),t&&Dw("ipc: true"),r&&Dw("detached: true"),n&&Dw("cancelSignal")},Dw=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},D1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=L1e({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Jre(c,r),{output:h,error:m=l}=Hre({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),S=h.map((b,A)=>ys(b,r,A)),E=ys(Wre(h,r),r,"all");return U1e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:E,options:r,command:n,escapedCommand:i,startTime:a})},L1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{zre(o,r);let a=$1e(r);return O1e(..._w(t,e,a))}catch(a){return Cf({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},$1e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:Aw(e)}),U1e=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?ww({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):$_({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as wFe}from"events";import{spawn as xFe}from"child_process";import nne from"process";import{once as c$,on as F1e}from"events";var Qre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(bf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:uw(t)}),B1e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),B1e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{sw(e,i);let o=La(t,e,r),s=new AbortController;try{return await Promise.race([j1e(o,n,s),z1e(o,r,s),G1e(o,r,s)])}catch(a){throw Af(t),a}finally{s.abort(),aw(e,i)}},j1e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await c$(t,"message",{signal:r});return n}for await(let[n]of F1e(t,"message",{signal:r}))if(e(n))return n},z1e=async(t,e,{signal:r})=>{await c$(t,"disconnect",{signal:r}),Fee(e)},G1e=async(t,e,{signal:r})=>{let[n]=await c$(t,"strict:error",{signal:r});throw nw(n,e)};import{once as tne,on as q1e}from"events";var rne=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>l$({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),l$=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{bf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:uw(t)}),sw(e,o);let s=La(t,e,r),a=new AbortController,c={};return V1e(t,s,a),H1e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),W1e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},V1e=async(t,e,r)=>{try{await tne(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},H1e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await tne(t,"strict:error",{signal:r.signal});n.error=nw(i,e),r.abort()}catch{}},W1e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of q1e(r,"message",{signal:o.signal}))ene(s),yield c}catch{ene(s)}finally{o.abort(),aw(e,a),n||Af(t),i&&await t}},ene=({error:t})=>{if(t)throw t};var ine=(t,{ipc:e})=>{Object.assign(t,sne(t,!1,e))},one=()=>{let t=nne,e=!0,r=nne.channel!==void 0;return{...sne(t,e,r),getCancelSignal:fte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},sne=(t,e,r)=>({sendMessage:hw.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Qre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:rne.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Y1e}from"child_process";import{PassThrough as K1e,Readable as Z1e,Writable as J1e,Duplex as X1e}from"stream";var ane=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{QL(n);let a=new Y1e;Q1e(a,n),Object.assign(a,{readable:eUe,writable:tUe,duplex:rUe});let c=Cf({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=nUe(c,s,i);return{subprocess:a,promise:l}},Q1e=(t,e)=>{let r=F_(),n=F_(),i=F_(),o=Array.from({length:e.length-3},F_),s=F_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},F_=()=>{let t=new K1e;return t.end(),t},eUe=()=>new Z1e({read(){}}),tUe=()=>new J1e({write(){}}),rUe=()=>new X1e({read(){},write(){}}),nUe=async(t,e,r)=>Pf(t,e,r);import{createReadStream as cne,createWriteStream as lne}from"fs";import{Buffer as iUe}from"buffer";import{Readable as B_,Writable as oUe,Duplex as sUe}from"stream";var dne=(t,e)=>Cw(aUe,t,e,!1),j_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${$a[t]}.`)},une={fileNumber:j_,generator:o$,asyncGenerator:o$,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:sUe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},aUe={input:{...une,fileUrl:({value:t})=>({stream:cne(t)}),filePath:({value:{file:t}})=>({stream:cne(t)}),webStream:({value:t})=>({stream:B_.fromWeb(t)}),iterable:({value:t})=>({stream:B_.from(t)}),asyncIterable:({value:t})=>({stream:B_.from(t)}),string:({value:t})=>({stream:B_.from(t)}),uint8Array:({value:t})=>({stream:B_.from(iUe.from(t))})},output:{...une,fileUrl:({value:t})=>({stream:lne(t)}),filePath:({value:{file:t,append:e}})=>({stream:lne(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:oUe.fromWeb(t)}),iterable:j_,asyncIterable:j_,string:j_,uint8Array:j_}};import{on as cUe,once as fne}from"events";import{PassThrough as lUe,getDefaultHighWaterMark as uUe}from"stream";import{finished as mne}from"stream/promises";function Bl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)d$(i);let e=t.some(({readableObjectMode:i})=>i),r=dUe(t,e),n=new u$({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var dUe=(t,e)=>{if(t.length===0)return uUe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},u$=class extends lUe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(d$(e),this.#e.has(e))return;this.#e.add(e),this.#n??=fUe(this,this.#e,this.#o);let r=mUe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(d$(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},fUe=async(t,e,r)=>{Lw(t,pne);let n=new AbortController;try{await Promise.race([pUe(t,n),hUe(t,e,r,n)])}finally{n.abort(),Lw(t,-pne)}},pUe=async(t,{signal:e})=>{try{await mne(t,{signal:e,cleanup:!0})}catch(r){throw gne(t,r),r}},hUe=async(t,e,r,{signal:n})=>{for await(let[i]of cUe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},d$=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},mUe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Lw(t,hne);let a=new AbortController;try{await Promise.race([gUe(o,e,a),_Ue({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),yUe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Lw(t,-hne)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?f$(t):SUe(t))},gUe=async(t,e,{signal:r})=>{try{await t,r.aborted||f$(e)}catch(n){r.aborted||gne(e,n)}},_Ue=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await mne(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;_ne(s)?i.add(e):yne(t,s)}},yUe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await fne(t,i,{signal:o}),!t.readable)return fne(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},SUe=t=>{t.writable&&t.end()},gne=(t,e)=>{_ne(e)?f$(t):yne(t,e)},_ne=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",f$=t=>{(t.readable||t.writable)&&t.destroy()},yne=(t,e)=>{t.destroyed||(t.once("error",EUe),t.destroy(e))},EUe=()=>{},Lw=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},pne=2,hne=1;import{finished as Sne}from"stream/promises";var Nf=(t,e)=>{t.pipe(e),vUe(t,e),TUe(t,e)},vUe=async(t,e)=>{if(!(Ci(t)||Ci(e))){try{await Sne(t,{cleanup:!0,readable:!0,writable:!1})}catch{}p$(e)}},p$=t=>{t.writable&&t.end()},TUe=async(t,e)=>{if(!(Ci(t)||Ci(e))){try{await Sne(e,{cleanup:!0,readable:!1,writable:!0})}catch{}h$(t)}},h$=t=>{t.readable&&t.destroy()};var Ene=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Qn.has(c)))bUe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Qn.has(c)))wUe({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Bl(o);Nf(s,i)}},bUe=(t,e,r,n)=>{r==="output"?Nf(t.stdio[n],e):Nf(e,t.stdio[n]);let i=AUe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},AUe=["stdin","stdout","stderr"],wUe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;xUe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},xUe=(t,{signal:e})=>{Ci(t)&&Ll(t,RUe,e)},RUe=2;import{addAbortListener as PUe}from"events";var jl=[];jl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&jl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&jl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var $w=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",m$=Symbol.for("signal-exit emitter"),g$=globalThis,IUe=Object.defineProperty.bind(Object),_$=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(g$[m$])return g$[m$];IUe(g$,m$,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},Uw=class{},CUe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),y$=class extends Uw{onExit(){return()=>{}}load(){}unload(){}},S$=class extends Uw{#e=E$.platform==="win32"?"SIGINT":"SIGHUP";#r=new _$;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of jl)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!$w(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of jl)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,jl.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return $w(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&$w(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},E$=globalThis.process,{onExit:vne,load:qvt,unload:Vvt}=CUe($w(E$)?new S$(E$):new y$);var Tne=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=vne(()=>{t.kill()});PUe(n,()=>{i()})};var Ane=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=KA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=OUe(r,n,i),{sourceStream:d,sourceError:f}=kUe(t,l),{options:p,fileDescriptors:h}=yo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},OUe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=NUe(t,e,...r),a=ow(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},NUe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(bne,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||lL(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=FA(r,...n);return{destination:e(bne)(i,o,s),pipeOptions:s}}if(yo.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},bne=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),kUe=(t,e)=>{try{return{sourceStream:wf(t,e)}}catch(r){return{sourceError:r}}};var xne=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=MUe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw v$({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},MUe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return h$(t),n;if(e!==void 0)return p$(r),e},v$=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Cf({error:t,command:wne,escapedCommand:wne,fileDescriptors:e,options:r,startTime:n,isSync:!1}),wne="source.pipe(destination)";var Rne=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as DUe}from"stream/promises";var Ine=(t,e,r)=>{let n=Fw.has(e)?$Ue(t,e):LUe(t,e);return Ll(t,FUe,r.signal),Ll(e,BUe,r.signal),UUe(e),n},LUe=(t,e)=>{let r=Bl([t]);return Nf(r,e),Fw.set(e,r),r},$Ue=(t,e)=>{let r=Fw.get(e);return r.add(t),r},UUe=async t=>{try{await DUe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Fw.delete(t)},Fw=new WeakMap,FUe=2,BUe=1;import{aborted as jUe}from"util";var Cne=(t,e)=>t===void 0?[]:[zUe(t,e)],zUe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await jUe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw v$({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Bw=(t,...e)=>{if(Ot(e[0]))return Bw.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Ane(t,...e),i=GUe({...n,destination:r});return i.pipe=Bw.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},GUe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=qUe(t,i);xne({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Ine(e,o,d);return await Promise.race([Rne(u),...Cne(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},qUe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as JUe}from"timers/promises";import{on as VUe}from"events";import{getDefaultHighWaterMark as HUe}from"stream";var jw=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return WUe(e,s),One({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},WUe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},T$=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;YUe(e,s,t);let a=t.readableObjectMode&&!o;return One({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},YUe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},One=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=VUe(t,"data",{signal:e.signal,highWaterMark:Pne,highWatermark:Pne});return KUe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},b$=HUe(!0),Pne=b$,KUe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=ZUe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Fl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*U_(a)}},ZUe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[Ow(t,r,!e),Pw(t,i,!n,{})].filter(Boolean);var Nne=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=XUe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([QUe(t),d]);return}let f=e$(c,r),p=T$({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([eFe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},XUe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Mw({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=T$({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Gre(a,t,r,o)},QUe=async t=>{await JUe(),t.readableFlowing===null&&t.resume()},eFe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await vw(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await Tw(r,{maxBuffer:o})):await If(r,{maxBuffer:o})}catch(a){return kne(Gte({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},A$=async t=>{try{return await t}catch(e){return kne(e)}},kne=({bufferedData:t})=>o7(t)?new Uint8Array(t):t;import{finished as tFe}from"stream/promises";var z_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=rFe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],tFe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||oFe(a,e,r,n)}finally{s.abort()}},rFe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&nFe(t,r,n),n},nFe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{iFe(e,r),n.call(t,...i)}},iFe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},oFe=(t,e,r,n)=>{if(!sFe(t,e,r,n))throw t},sFe=(t,e,r,n=!0)=>r.propagating?Mne(t)||zw(t):(r.propagating=!0,w$(r,e)===n?Mne(t):zw(t)),w$=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",zw=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Mne=t=>t?.code==="EPIPE";var Dne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>x$({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),x$=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=z_(t,e,l);if(w$(l,e)){await u;return}let[d]=await Promise.all([Nne({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Lne=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Bl([t,e].filter(Boolean)):void 0,$ne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>x$({...aFe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:cFe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),aFe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},cFe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as lFe}from"events";var Une=t=>Ef(t,"ipc"),Fne=(t,e)=>{let r=YA(t);go({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Bne=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Une(o),a=gs(e,"ipc"),c=gs(r,"ipc");for await(let l of l$({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(qte(t,i,c),i.push(l)),s&&Fne(l,o);return i},jne=async(t,e)=>(await Promise.allSettled([t]),e);var zne=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:S,controller:E})=>{let b=Yre(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},y=Dne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),R=$ne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),P=[],O=Bne({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),N=uFe(m,t,A),I=dFe(h,A);try{return await Promise.race([Promise.all([{},Zre(b),Promise.all(y),R,O,Tte(t,d),...N,...I]),S,fFe(t,E),..._te(t,o,f,E),...Uee({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...mte({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},b,Promise.all(y.map(_=>A$(_))),A$(R),jne(O,P),Promise.allSettled(N),Promise.allSettled(I)])}},uFe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:z_(n,i,r)),dFe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ni(o,{checkOpen:!1})&&!Ci(o)).map(({type:i,value:o,stream:s=o})=>z_(s,n,e,{isSameDirection:Qn.has(i),stopOnExit:i==="native"}))),fFe=async(t,{signal:e})=>{let[r]=await lFe(t,"error",{signal:e});throw r};var Gne=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),G_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=_o();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},kf=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as pFe}from"stream";import{callbackify as hFe}from"util";import{finished as qne}from"stream/promises";var R$=async t=>{if(t!==void 0)try{await I$(t)}catch{}},Vne=async t=>{if(t!==void 0)try{await C$(t)}catch{}},I$=async t=>{await qne(t,{cleanup:!0,readable:!1,writable:!0})},C$=async t=>{await qne(t,{cleanup:!0,readable:!0,writable:!1})},Gw=async(t,e)=>{if(await t,e)throw e},qw=(t,e,r)=>{r&&!zw(r)?t.destroy(r):e&&t.destroy()};var Hne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||Tn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=P$(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=O$(a,s),{read:f,onStdoutDataDone:p}=N$({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new pFe({read:f,destroy:hFe(M$.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return k$({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},P$=(t,e,r)=>{let n=wf(t,e),i=G_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},O$=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:b$},N$=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=_o(),s=jw({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){mFe(this,s,o)},onStdoutDataDone:o}},mFe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},k$=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await C$(t),await n,await R$(i),await e,r.readable&&r.push(null)}catch(o){await R$(i),Wne(r,o)}},M$=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await kf(r,e)&&(Wne(t,n),await Gw(e,n))},Wne=(t,e)=>{qw(t,t.readable,e)};import{Writable as gFe}from"stream";import{callbackify as Yne}from"util";var Kne=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=D$(t,r,e),s=new gFe({...L$(n,t,i),destroy:Yne(U$.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return $$(n,s),s},D$=(t,e,r)=>{let n=ow(t,e),i=G_(r,n,"writableFinal"),o=G_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},L$=(t,e,r)=>({write:_Fe.bind(void 0,t),final:Yne(yFe.bind(void 0,t,e,r))}),_Fe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},yFe=async(t,e,r)=>{await kf(r,e)&&(t.writable&&t.end(),await e)},$$=async(t,e,r)=>{try{await I$(t),e.writable&&e.end()}catch(n){await Vne(r),Zne(e,n)}},U$=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await kf(r,e),await kf(n,e)&&(Zne(t,i),await Gw(e,i))},Zne=(t,e)=>{qw(t,t.writable,e)};import{Duplex as SFe}from"stream";import{callbackify as EFe}from"util";var Jne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||Tn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=P$(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=D$(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=O$(c,a),{read:S,onStdoutDataDone:E}=N$({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new SFe({read:S,...L$(u,t,d),destroy:EFe(vFe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return k$({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),$$(u,b,c),b},vFe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([M$({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),U$({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var F$=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||Tn.has(e),s=wf(t,r),a=jw({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return TFe(a,s,t)},TFe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Xne=(t,{encoding:e})=>{let r=Gne();t.readable=Hne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Kne.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Jne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=F$.bind(void 0,t,e),t[Symbol.asyncIterator]=F$.bind(void 0,t,e,{})};var Qne=(t,e)=>{for(let[r,n]of AFe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},bFe=(async()=>{})().constructor.prototype,AFe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(bFe,t)]);var eie=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=RFe(t,e,r),{subprocess:f,promise:p}=CFe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Bw.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Qne(f,p),yo.set(f,{options:u,fileDescriptors:d}),f},RFe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=ZA(t,e,r),{file:a,commandArguments:c,options:l}=gw(t,e,r),u=IFe(l),d=dne(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},IFe=({timeout:t,signal:e,...r})=>{if(e!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:t}},CFe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=xFe(..._w(t,e,r))}catch(h){return ane({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;wFe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Ene(c,a,l),Tne(c,r,l);let d={},f=_o();c.kill=Lee.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Lne(c,r),Xne(c,r),ine(c,r);let p=PFe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},PFe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,S]=await zne({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((y,R)=>ys(y,e,R)),b=ys(m,e,"all"),A=OFe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:S,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Pf(A,n,e)},OFe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?$_({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof So,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):ww({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Vw=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,NFe(n,t[n],i)]));return{...t,...r}},NFe=(t,e,r)=>kFe.has(t)&&Ot(e)&&Ot(r)?{...e,...r}:r,kFe=new Set(["env",...mL]);var Ua=(t,e,r,n)=>{let i=(s,a,c)=>Ua(s,a,r,c),o=(...s)=>MFe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},MFe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ot(o))return i(t,Vw(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=DFe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Xre(a,c,l):eie(a,c,l,i)},DFe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=d7(e)?f7(e,r):[e,...r],[s,a,c]=FA(...o),l=Vw(Vw(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var tie=({file:t,commandArguments:e})=>nie(t,e),rie=({file:t,commandArguments:e})=>({...nie(t,e),isSync:!0}),nie=(t,e)=>{if(e.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${t} ${e}.`);let[r,...n]=LFe(t);return{file:r,commandArguments:n}},LFe=t=>{if(typeof t!="string")throw new TypeError(`The command must be a string: ${String(t)}.`);let e=t.trim();if(e==="")return[];let r=[];for(let n of e.split($Fe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},$Fe=/ +/g;var iie=(t,e,r)=>{t.sync=e(UFe,r),t.s=t.sync},oie=({options:t})=>sie(t),UFe=({options:t})=>({...sie(t),isSync:!0}),sie=t=>({options:{...FFe(t),...t}}),FFe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},aie={preferLocal:!0};var cie=Ua(()=>({})),MAt=Ua(()=>({isSync:!0})),lie=Ua(tie),DAt=Ua(rie),LAt=Ua(Ste),$At=Ua(oie,{},aie,iie),{sendMessage:UAt,getOneMessage:FAt,getEachMessage:BAt,getCancelSignal:jAt}=one();var uie=!1,die=()=>{uie=!0},vo=()=>uie;var q_=null,fie=t=>(q_&&q_.destroy(),q_=new Ss({totalAllowedTime:t}),q_),pie=()=>q_;var Ss=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&vo())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await OA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ce.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var hie={name:"@netlify/agent-runner-cli",type:"module",version:"1.163.0-PAW-328.7",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.5","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var GFe=jFe(import.meta.url),qFe=Es.dirname(GFe),VFe=zFe(import.meta.url),Mf=le("shell"),B$=new Set,mie={preferLocal:!0},zt=(t,e,r)=>{let[n,i]=HFe(e,r),o={...mie,...i},s=cie(t,n,o);_ie(s,o),Eie(s);let a=r?.idleTimeout;return a&&a>0&&Sie(s,a),s},gie=(t,e)=>{let r={...mie,...e},n=lie(t,r);return _ie(n,r),Eie(n),e?.idleTimeout&&e.idleTimeout>0&&Sie(n,e.idleTimeout),n},HFe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},_ie=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(vs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new y_).pipe(vs.stdout),t.stderr?.pipe(new y_).pipe(vs.stderr);return}t.stdout?.pipe(vs.stdout),t.stderr?.pipe(vs.stderr)},j$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vs.kill(-t.pid,e),Mf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Mf.error("Error killing process:",r),!1}},yie=t=>j$(t,"SIGKILL"),Sie=(t,e)=>{let r=null,n=()=>{Mf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),j$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Mf.log(`Force killing idle process ${t.pid}`),yie(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},Eie=t=>{B$.add(t);let e=pie();if(e){let r=e.onTimesUp(()=>{Mf.log(`Global timer expired, killing process ${t.pid}`),j$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Mf.log(`Force killing process ${t.pid} after timeout`),yie(t))},5e3)});t.on("exit",()=>{B$.delete(t),r()}),t.on("error",()=>{B$.delete(t),r()})}};function Ww(t,e){return!!ki(t,e)}function ki(t,e){if(!vs.env.NETLIFY_LOCAL_MODE)try{let i=VFe.resolve(hie.name),o=Es.dirname(i);for(;o!==Es.dirname(o);){let s=Es.dirname(o);if(Es.basename(s)==="node_modules"){let a=Es.join(s,".bin",e);if(Hw.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(vs.env.NODE_PATH){let i=Es.join(vs.env.NODE_PATH,".bin",e);if(Hw.existsSync(i))return i}let r=Es.join(t,"node_modules",".bin",e);if(Hw.existsSync(r))return r;let n=Es.join(qFe,"..","node_modules",".bin",e);if(Hw.existsSync(n))return n}var WFe=le("utils"),YFe=t=>new Promise(e=>{setTimeout(e,t)});var z$=t=>{try{return new URL(t).hostname||null}catch{return null}},Yw=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await YFe(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},Fa=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},vie=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):WFe.error("Could not parse JSON",n))}},KFe=t=>t.charAt(0).toUpperCase()+t.slice(1),To=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():KFe(e)).join(" ");function Ts(t,e){e&&t.log(`Skill invoked: ${e}`)}var Kw=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Tie=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var G$=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},ZFe=1e4,q$=(t,e=ZFe)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{createHash as JFe}from"crypto";import{createReadStream as XFe}from"fs";import Zw from"fs/promises";import Rie from"os";import Jw from"path";var bie=le("repo"),Iie="runner-diffs-",Cie=t=>`${Iie}${t}-`,Pie=async t=>{let e=Rie.tmpdir(),r;try{r=await Zw.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Iie)&&!n.startsWith(Cie(t))).map(n=>Zw.rm(Jw.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},nn=(t,e={})=>zt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Xw=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{bie.info("Getting runner diffs");let n=await eBe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=rBe(o);await nBe(h,r)}bie.info("Changes after processing"),await H$(r);let s=await W$(o,r);if(await V$(s,r),i=await tBe(r),!i)return{hasChanges:!1,ignored:s};await nn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await Zw.mkdtemp(Jw.join(Rie.tmpdir(),Cie(t.sessionId))),c=async({from:h,to:m,fileName:S,binary:E})=>{let b=Jw.join(a,S);await nn([...E?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:y}=await Zw.stat(b);return{path:b,size:y}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await xie(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await wie(d,h)||(f=h)}await xie(r),ce.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await wie(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},Aie=async t=>{let e=JFe("sha256");for await(let r of XFe(t))e.update(r);return e.digest("hex")},wie=async(t,e)=>t.size===e.size&&await Aie(t.path)===await Aie(e.path),xie=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await nn(["reset","--soft","HEAD~1"],{cwd:t})},V$=async(t=[],e=process.cwd())=>{await nn(["add",".",...t],{cwd:e})},H$=async(t=process.cwd())=>{let e=await nn(["status","-s"],{cwd:t});return String(e.stdout??"")},Oie=/.. (.+)?\.log$/,QFe=[Oie],eBe=async(t=process.cwd())=>{let e=await H$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
115
|
+
if (condition) { yield value; }`)};import{Buffer as i1e}from"buffer";import{StringDecoder as o1e}from"string_decoder";var Ow=(t,e,r)=>{if(r)return;if(t)return{transform:s1e.bind(void 0,new TextEncoder)};let n=new o1e(e);return{transform:a1e.bind(void 0,n),final:c1e.bind(void 0,n)}},s1e=function*(t,e){i1e.isBuffer(e)?yield ms(e):typeof e=="string"?yield t.encode(e):yield e},a1e=function*(t,e){yield jt(e)?t.write(e):e},c1e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Lre}from"util";var n$=Lre(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Nw=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=u1e}=e[r];for await(let i of n(t))yield*Nw(i,e,r+1)},$re=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*l1e(r,Number(e),t)},l1e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Nw(n,r,e+1)},Ure=Lre(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),u1e=function*(t){yield t};var i$=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Fre=(t,e)=>[...e.flatMap(r=>[...Fl(r,t,0)]),...U_(t)],Fl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=f1e}=e[r];for(let i of n(t))yield*Fl(i,e,r+1)},U_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*d1e(r,Number(e),t)},d1e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Fl(n,r,e+1)},f1e=function*(t){yield t};var o$=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=jre(t,s,o),l=Ul(e),u=Ul(r),d=l?n$.bind(void 0,Nw,a):i$.bind(void 0,Fl),f=l||u?n$.bind(void 0,$re,a):i$.bind(void 0,U_),p=l||u?Ure.bind(void 0,a):void 0;return{stream:new p1e({writableObjectMode:n,writableHighWaterMark:Bre(n),readableObjectMode:i,readableHighWaterMark:Bre(i),transform(m,S,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},kw=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=jre(s,r,a);t=Fre(c,t)}return t},jre=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:kre(n,a)},Ow(r,s,n),Pw(r,o,n,c),{transform:t,final:e},{transform:Mre(i,a)},Nre({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var zre=(t,e)=>{for(let r of h1e(t))m1e(t,r,e)},h1e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),m1e=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${$a[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>g1e(a,n));r.input=I_(s)},g1e=(t,e)=>{let r=kw(t,e,"utf8",!0);return _1e(r),I_(r)},_1e=t=>{let e=t.find(r=>typeof r!="string"&&!jt(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as v1e,appendFileSync as T1e}from"fs";var Mw=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ef(r,n)&&!Tn.has(e)&&y1e(n)&&(t.some(({type:i,value:o})=>i==="native"&&S1e.has(o))||t.every(({type:i})=>Qn.has(i))),y1e=t=>t===1||t===2,S1e=new Set(["pipe","overlapped"]),Gre=async(t,e,r,n)=>{for await(let i of t)E1e(e)||Vre(i,r,n)},qre=(t,e,r)=>{for(let n of t)Vre(n,e,r)},E1e=t=>t._readableState.pipes.length>0,Vre=(t,e,r)=>{let n=YA(t);go({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Hre=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>b1e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},b1e=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Wte(t,o,d),p=ms(f),{stdioItems:h,objectMode:m}=e[r],S=A1e([p],h,c,n),{serializedResult:E,finalResult:b=E}=w1e({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});x1e({serializedResult:E,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?b:void 0;try{return n.error===void 0&&R1e(E,h,i),A}catch(y){return n.error=y,A}},A1e=(t,e,r,n)=>{try{return kw(t,e,r,!1)}catch(i){return n.error=i,t}},w1e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:I_(t)};let s=a7(t,r);return n[o]?{serializedResult:s,finalResult:r$(s,!i[o],e)}:{serializedResult:s}},x1e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Mw({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=r$(t,!1,s);try{qre(a,e,n)}catch(c){r.error??=c}},R1e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>Iw.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?T1e(n,t):(r.add(o),v1e(n,t))}};var Wre=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ys(e,r,"all")]:Array.isArray(e)?[ys(t,r,"all"),...e]:jt(t)&&jt(e)?dL([t,e]):`${t}${e}`};import{once as s$}from"events";var Yre=async(t,e)=>{let[r,n]=await I1e(t);return e.isForcefullyTerminated??=!1,[r,n]},I1e=async t=>{let[e,r]=await Promise.allSettled([s$(t,"spawn"),s$(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Kre(t):r.value},Kre=async t=>{try{return await s$(t,"exit")}catch{return Kre(t)}},Zre=async t=>{let[e,r]=await t;if(!C1e(e,r)&&a$(e,r))throw new Pi;return[e,r]},C1e=(t,e)=>t===void 0&&e===void 0,a$=(t,e)=>t!==0||e!==null;var Jre=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=P1e(t,e,r),s=o?.code==="ETIMEDOUT",a=Hte(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},P1e=(t,e,r)=>t!==void 0?t:a$(e,r)?new Pi:void 0;var Xre=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=N1e(t,e,r),d=D1e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Pf(d,c,l)},N1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=ZA(t,e,r),a=k1e(r),{file:c,commandArguments:l,options:u}=gw(t,e,a);M1e(u);let d=Ire(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},k1e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,M1e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Dw("ipcInput"),t&&Dw("ipc: true"),r&&Dw("detached: true"),n&&Dw("cancelSignal")},Dw=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},D1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=L1e({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Jre(c,r),{output:h,error:m=l}=Hre({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),S=h.map((b,A)=>ys(b,r,A)),E=ys(Wre(h,r),r,"all");return U1e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:E,options:r,command:n,escapedCommand:i,startTime:a})},L1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{zre(o,r);let a=$1e(r);return O1e(..._w(t,e,a))}catch(a){return Cf({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},$1e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:Aw(e)}),U1e=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?ww({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):$_({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as wFe}from"events";import{spawn as xFe}from"child_process";import nne from"process";import{once as c$,on as F1e}from"events";var Qre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(bf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:uw(t)}),B1e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),B1e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{sw(e,i);let o=La(t,e,r),s=new AbortController;try{return await Promise.race([j1e(o,n,s),z1e(o,r,s),G1e(o,r,s)])}catch(a){throw Af(t),a}finally{s.abort(),aw(e,i)}},j1e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await c$(t,"message",{signal:r});return n}for await(let[n]of F1e(t,"message",{signal:r}))if(e(n))return n},z1e=async(t,e,{signal:r})=>{await c$(t,"disconnect",{signal:r}),Fee(e)},G1e=async(t,e,{signal:r})=>{let[n]=await c$(t,"strict:error",{signal:r});throw nw(n,e)};import{once as tne,on as q1e}from"events";var rne=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>l$({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),l$=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{bf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:uw(t)}),sw(e,o);let s=La(t,e,r),a=new AbortController,c={};return V1e(t,s,a),H1e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),W1e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},V1e=async(t,e,r)=>{try{await tne(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},H1e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await tne(t,"strict:error",{signal:r.signal});n.error=nw(i,e),r.abort()}catch{}},W1e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of q1e(r,"message",{signal:o.signal}))ene(s),yield c}catch{ene(s)}finally{o.abort(),aw(e,a),n||Af(t),i&&await t}},ene=({error:t})=>{if(t)throw t};var ine=(t,{ipc:e})=>{Object.assign(t,sne(t,!1,e))},one=()=>{let t=nne,e=!0,r=nne.channel!==void 0;return{...sne(t,e,r),getCancelSignal:fte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},sne=(t,e,r)=>({sendMessage:hw.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Qre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:rne.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Y1e}from"child_process";import{PassThrough as K1e,Readable as Z1e,Writable as J1e,Duplex as X1e}from"stream";var ane=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{QL(n);let a=new Y1e;Q1e(a,n),Object.assign(a,{readable:eUe,writable:tUe,duplex:rUe});let c=Cf({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=nUe(c,s,i);return{subprocess:a,promise:l}},Q1e=(t,e)=>{let r=F_(),n=F_(),i=F_(),o=Array.from({length:e.length-3},F_),s=F_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},F_=()=>{let t=new K1e;return t.end(),t},eUe=()=>new Z1e({read(){}}),tUe=()=>new J1e({write(){}}),rUe=()=>new X1e({read(){},write(){}}),nUe=async(t,e,r)=>Pf(t,e,r);import{createReadStream as cne,createWriteStream as lne}from"fs";import{Buffer as iUe}from"buffer";import{Readable as B_,Writable as oUe,Duplex as sUe}from"stream";var dne=(t,e)=>Cw(aUe,t,e,!1),j_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${$a[t]}.`)},une={fileNumber:j_,generator:o$,asyncGenerator:o$,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:sUe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},aUe={input:{...une,fileUrl:({value:t})=>({stream:cne(t)}),filePath:({value:{file:t}})=>({stream:cne(t)}),webStream:({value:t})=>({stream:B_.fromWeb(t)}),iterable:({value:t})=>({stream:B_.from(t)}),asyncIterable:({value:t})=>({stream:B_.from(t)}),string:({value:t})=>({stream:B_.from(t)}),uint8Array:({value:t})=>({stream:B_.from(iUe.from(t))})},output:{...une,fileUrl:({value:t})=>({stream:lne(t)}),filePath:({value:{file:t,append:e}})=>({stream:lne(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:oUe.fromWeb(t)}),iterable:j_,asyncIterable:j_,string:j_,uint8Array:j_}};import{on as cUe,once as fne}from"events";import{PassThrough as lUe,getDefaultHighWaterMark as uUe}from"stream";import{finished as mne}from"stream/promises";function Bl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)d$(i);let e=t.some(({readableObjectMode:i})=>i),r=dUe(t,e),n=new u$({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var dUe=(t,e)=>{if(t.length===0)return uUe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},u$=class extends lUe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(d$(e),this.#e.has(e))return;this.#e.add(e),this.#n??=fUe(this,this.#e,this.#o);let r=mUe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(d$(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},fUe=async(t,e,r)=>{Lw(t,pne);let n=new AbortController;try{await Promise.race([pUe(t,n),hUe(t,e,r,n)])}finally{n.abort(),Lw(t,-pne)}},pUe=async(t,{signal:e})=>{try{await mne(t,{signal:e,cleanup:!0})}catch(r){throw gne(t,r),r}},hUe=async(t,e,r,{signal:n})=>{for await(let[i]of cUe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},d$=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},mUe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Lw(t,hne);let a=new AbortController;try{await Promise.race([gUe(o,e,a),_Ue({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),yUe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Lw(t,-hne)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?f$(t):SUe(t))},gUe=async(t,e,{signal:r})=>{try{await t,r.aborted||f$(e)}catch(n){r.aborted||gne(e,n)}},_Ue=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await mne(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;_ne(s)?i.add(e):yne(t,s)}},yUe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await fne(t,i,{signal:o}),!t.readable)return fne(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},SUe=t=>{t.writable&&t.end()},gne=(t,e)=>{_ne(e)?f$(t):yne(t,e)},_ne=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",f$=t=>{(t.readable||t.writable)&&t.destroy()},yne=(t,e)=>{t.destroyed||(t.once("error",EUe),t.destroy(e))},EUe=()=>{},Lw=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},pne=2,hne=1;import{finished as Sne}from"stream/promises";var Nf=(t,e)=>{t.pipe(e),vUe(t,e),TUe(t,e)},vUe=async(t,e)=>{if(!(Ci(t)||Ci(e))){try{await Sne(t,{cleanup:!0,readable:!0,writable:!1})}catch{}p$(e)}},p$=t=>{t.writable&&t.end()},TUe=async(t,e)=>{if(!(Ci(t)||Ci(e))){try{await Sne(e,{cleanup:!0,readable:!1,writable:!0})}catch{}h$(t)}},h$=t=>{t.readable&&t.destroy()};var Ene=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Qn.has(c)))bUe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Qn.has(c)))wUe({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Bl(o);Nf(s,i)}},bUe=(t,e,r,n)=>{r==="output"?Nf(t.stdio[n],e):Nf(e,t.stdio[n]);let i=AUe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},AUe=["stdin","stdout","stderr"],wUe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;xUe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},xUe=(t,{signal:e})=>{Ci(t)&&Ll(t,RUe,e)},RUe=2;import{addAbortListener as PUe}from"events";var jl=[];jl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&jl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&jl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var $w=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",m$=Symbol.for("signal-exit emitter"),g$=globalThis,IUe=Object.defineProperty.bind(Object),_$=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(g$[m$])return g$[m$];IUe(g$,m$,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},Uw=class{},CUe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),y$=class extends Uw{onExit(){return()=>{}}load(){}unload(){}},S$=class extends Uw{#e=E$.platform==="win32"?"SIGINT":"SIGHUP";#r=new _$;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of jl)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!$w(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of jl)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,jl.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return $w(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&$w(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},E$=globalThis.process,{onExit:vne,load:qvt,unload:Vvt}=CUe($w(E$)?new S$(E$):new y$);var Tne=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=vne(()=>{t.kill()});PUe(n,()=>{i()})};var Ane=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=KA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=OUe(r,n,i),{sourceStream:d,sourceError:f}=kUe(t,l),{options:p,fileDescriptors:h}=yo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},OUe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=NUe(t,e,...r),a=ow(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},NUe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(bne,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||lL(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=FA(r,...n);return{destination:e(bne)(i,o,s),pipeOptions:s}}if(yo.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},bne=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),kUe=(t,e)=>{try{return{sourceStream:wf(t,e)}}catch(r){return{sourceError:r}}};var xne=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=MUe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw v$({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},MUe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return h$(t),n;if(e!==void 0)return p$(r),e},v$=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Cf({error:t,command:wne,escapedCommand:wne,fileDescriptors:e,options:r,startTime:n,isSync:!1}),wne="source.pipe(destination)";var Rne=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as DUe}from"stream/promises";var Ine=(t,e,r)=>{let n=Fw.has(e)?$Ue(t,e):LUe(t,e);return Ll(t,FUe,r.signal),Ll(e,BUe,r.signal),UUe(e),n},LUe=(t,e)=>{let r=Bl([t]);return Nf(r,e),Fw.set(e,r),r},$Ue=(t,e)=>{let r=Fw.get(e);return r.add(t),r},UUe=async t=>{try{await DUe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Fw.delete(t)},Fw=new WeakMap,FUe=2,BUe=1;import{aborted as jUe}from"util";var Cne=(t,e)=>t===void 0?[]:[zUe(t,e)],zUe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await jUe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw v$({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Bw=(t,...e)=>{if(Ot(e[0]))return Bw.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Ane(t,...e),i=GUe({...n,destination:r});return i.pipe=Bw.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},GUe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=qUe(t,i);xne({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Ine(e,o,d);return await Promise.race([Rne(u),...Cne(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},qUe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as JUe}from"timers/promises";import{on as VUe}from"events";import{getDefaultHighWaterMark as HUe}from"stream";var jw=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return WUe(e,s),One({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},WUe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},T$=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;YUe(e,s,t);let a=t.readableObjectMode&&!o;return One({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},YUe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},One=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=VUe(t,"data",{signal:e.signal,highWaterMark:Pne,highWatermark:Pne});return KUe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},b$=HUe(!0),Pne=b$,KUe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=ZUe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Fl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*U_(a)}},ZUe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[Ow(t,r,!e),Pw(t,i,!n,{})].filter(Boolean);var Nne=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=XUe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([QUe(t),d]);return}let f=e$(c,r),p=T$({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([eFe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},XUe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Mw({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=T$({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Gre(a,t,r,o)},QUe=async t=>{await JUe(),t.readableFlowing===null&&t.resume()},eFe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await vw(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await Tw(r,{maxBuffer:o})):await If(r,{maxBuffer:o})}catch(a){return kne(Gte({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},A$=async t=>{try{return await t}catch(e){return kne(e)}},kne=({bufferedData:t})=>o7(t)?new Uint8Array(t):t;import{finished as tFe}from"stream/promises";var z_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=rFe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],tFe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||oFe(a,e,r,n)}finally{s.abort()}},rFe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&nFe(t,r,n),n},nFe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{iFe(e,r),n.call(t,...i)}},iFe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},oFe=(t,e,r,n)=>{if(!sFe(t,e,r,n))throw t},sFe=(t,e,r,n=!0)=>r.propagating?Mne(t)||zw(t):(r.propagating=!0,w$(r,e)===n?Mne(t):zw(t)),w$=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",zw=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Mne=t=>t?.code==="EPIPE";var Dne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>x$({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),x$=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=z_(t,e,l);if(w$(l,e)){await u;return}let[d]=await Promise.all([Nne({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Lne=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Bl([t,e].filter(Boolean)):void 0,$ne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>x$({...aFe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:cFe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),aFe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},cFe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as lFe}from"events";var Une=t=>Ef(t,"ipc"),Fne=(t,e)=>{let r=YA(t);go({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Bne=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Une(o),a=gs(e,"ipc"),c=gs(r,"ipc");for await(let l of l$({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(qte(t,i,c),i.push(l)),s&&Fne(l,o);return i},jne=async(t,e)=>(await Promise.allSettled([t]),e);var zne=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:S,controller:E})=>{let b=Yre(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},y=Dne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),R=$ne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),P=[],O=Bne({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),N=uFe(m,t,A),I=dFe(h,A);try{return await Promise.race([Promise.all([{},Zre(b),Promise.all(y),R,O,Tte(t,d),...N,...I]),S,fFe(t,E),..._te(t,o,f,E),...Uee({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...mte({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},b,Promise.all(y.map(_=>A$(_))),A$(R),jne(O,P),Promise.allSettled(N),Promise.allSettled(I)])}},uFe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:z_(n,i,r)),dFe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ni(o,{checkOpen:!1})&&!Ci(o)).map(({type:i,value:o,stream:s=o})=>z_(s,n,e,{isSameDirection:Qn.has(i),stopOnExit:i==="native"}))),fFe=async(t,{signal:e})=>{let[r]=await lFe(t,"error",{signal:e});throw r};var Gne=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),G_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=_o();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},kf=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as pFe}from"stream";import{callbackify as hFe}from"util";import{finished as qne}from"stream/promises";var R$=async t=>{if(t!==void 0)try{await I$(t)}catch{}},Vne=async t=>{if(t!==void 0)try{await C$(t)}catch{}},I$=async t=>{await qne(t,{cleanup:!0,readable:!1,writable:!0})},C$=async t=>{await qne(t,{cleanup:!0,readable:!0,writable:!1})},Gw=async(t,e)=>{if(await t,e)throw e},qw=(t,e,r)=>{r&&!zw(r)?t.destroy(r):e&&t.destroy()};var Hne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||Tn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=P$(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=O$(a,s),{read:f,onStdoutDataDone:p}=N$({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new pFe({read:f,destroy:hFe(M$.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return k$({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},P$=(t,e,r)=>{let n=wf(t,e),i=G_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},O$=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:b$},N$=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=_o(),s=jw({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){mFe(this,s,o)},onStdoutDataDone:o}},mFe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},k$=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await C$(t),await n,await R$(i),await e,r.readable&&r.push(null)}catch(o){await R$(i),Wne(r,o)}},M$=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await kf(r,e)&&(Wne(t,n),await Gw(e,n))},Wne=(t,e)=>{qw(t,t.readable,e)};import{Writable as gFe}from"stream";import{callbackify as Yne}from"util";var Kne=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=D$(t,r,e),s=new gFe({...L$(n,t,i),destroy:Yne(U$.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return $$(n,s),s},D$=(t,e,r)=>{let n=ow(t,e),i=G_(r,n,"writableFinal"),o=G_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},L$=(t,e,r)=>({write:_Fe.bind(void 0,t),final:Yne(yFe.bind(void 0,t,e,r))}),_Fe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},yFe=async(t,e,r)=>{await kf(r,e)&&(t.writable&&t.end(),await e)},$$=async(t,e,r)=>{try{await I$(t),e.writable&&e.end()}catch(n){await Vne(r),Zne(e,n)}},U$=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await kf(r,e),await kf(n,e)&&(Zne(t,i),await Gw(e,i))},Zne=(t,e)=>{qw(t,t.writable,e)};import{Duplex as SFe}from"stream";import{callbackify as EFe}from"util";var Jne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||Tn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=P$(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=D$(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=O$(c,a),{read:S,onStdoutDataDone:E}=N$({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new SFe({read:S,...L$(u,t,d),destroy:EFe(vFe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return k$({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),$$(u,b,c),b},vFe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([M$({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),U$({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var F$=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||Tn.has(e),s=wf(t,r),a=jw({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return TFe(a,s,t)},TFe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Xne=(t,{encoding:e})=>{let r=Gne();t.readable=Hne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Kne.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Jne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=F$.bind(void 0,t,e),t[Symbol.asyncIterator]=F$.bind(void 0,t,e,{})};var Qne=(t,e)=>{for(let[r,n]of AFe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},bFe=(async()=>{})().constructor.prototype,AFe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(bFe,t)]);var eie=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=RFe(t,e,r),{subprocess:f,promise:p}=CFe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Bw.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Qne(f,p),yo.set(f,{options:u,fileDescriptors:d}),f},RFe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=ZA(t,e,r),{file:a,commandArguments:c,options:l}=gw(t,e,r),u=IFe(l),d=dne(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},IFe=({timeout:t,signal:e,...r})=>{if(e!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:t}},CFe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=xFe(..._w(t,e,r))}catch(h){return ane({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;wFe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Ene(c,a,l),Tne(c,r,l);let d={},f=_o();c.kill=Lee.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Lne(c,r),Xne(c,r),ine(c,r);let p=PFe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},PFe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,S]=await zne({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((y,R)=>ys(y,e,R)),b=ys(m,e,"all"),A=OFe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:S,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Pf(A,n,e)},OFe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?$_({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof So,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):ww({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Vw=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,NFe(n,t[n],i)]));return{...t,...r}},NFe=(t,e,r)=>kFe.has(t)&&Ot(e)&&Ot(r)?{...e,...r}:r,kFe=new Set(["env",...mL]);var Ua=(t,e,r,n)=>{let i=(s,a,c)=>Ua(s,a,r,c),o=(...s)=>MFe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},MFe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ot(o))return i(t,Vw(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=DFe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Xre(a,c,l):eie(a,c,l,i)},DFe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=d7(e)?f7(e,r):[e,...r],[s,a,c]=FA(...o),l=Vw(Vw(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var tie=({file:t,commandArguments:e})=>nie(t,e),rie=({file:t,commandArguments:e})=>({...nie(t,e),isSync:!0}),nie=(t,e)=>{if(e.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${t} ${e}.`);let[r,...n]=LFe(t);return{file:r,commandArguments:n}},LFe=t=>{if(typeof t!="string")throw new TypeError(`The command must be a string: ${String(t)}.`);let e=t.trim();if(e==="")return[];let r=[];for(let n of e.split($Fe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},$Fe=/ +/g;var iie=(t,e,r)=>{t.sync=e(UFe,r),t.s=t.sync},oie=({options:t})=>sie(t),UFe=({options:t})=>({...sie(t),isSync:!0}),sie=t=>({options:{...FFe(t),...t}}),FFe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},aie={preferLocal:!0};var cie=Ua(()=>({})),MAt=Ua(()=>({isSync:!0})),lie=Ua(tie),DAt=Ua(rie),LAt=Ua(Ste),$At=Ua(oie,{},aie,iie),{sendMessage:UAt,getOneMessage:FAt,getEachMessage:BAt,getCancelSignal:jAt}=one();var uie=!1,die=()=>{uie=!0},vo=()=>uie;var q_=null,fie=t=>(q_&&q_.destroy(),q_=new Ss({totalAllowedTime:t}),q_),pie=()=>q_;var Ss=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&vo())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await OA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ce.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var hie={name:"@netlify/agent-runner-cli",type:"module",version:"1.163.0-PAW-328.8",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.5","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var GFe=jFe(import.meta.url),qFe=Es.dirname(GFe),VFe=zFe(import.meta.url),Mf=le("shell"),B$=new Set,mie={preferLocal:!0},zt=(t,e,r)=>{let[n,i]=HFe(e,r),o={...mie,...i},s=cie(t,n,o);_ie(s,o),Eie(s);let a=r?.idleTimeout;return a&&a>0&&Sie(s,a),s},gie=(t,e)=>{let r={...mie,...e},n=lie(t,r);return _ie(n,r),Eie(n),e?.idleTimeout&&e.idleTimeout>0&&Sie(n,e.idleTimeout),n},HFe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},_ie=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(vs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new y_).pipe(vs.stdout),t.stderr?.pipe(new y_).pipe(vs.stderr);return}t.stdout?.pipe(vs.stdout),t.stderr?.pipe(vs.stderr)},j$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vs.kill(-t.pid,e),Mf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Mf.error("Error killing process:",r),!1}},yie=t=>j$(t,"SIGKILL"),Sie=(t,e)=>{let r=null,n=()=>{Mf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),j$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Mf.log(`Force killing idle process ${t.pid}`),yie(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},Eie=t=>{B$.add(t);let e=pie();if(e){let r=e.onTimesUp(()=>{Mf.log(`Global timer expired, killing process ${t.pid}`),j$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Mf.log(`Force killing process ${t.pid} after timeout`),yie(t))},5e3)});t.on("exit",()=>{B$.delete(t),r()}),t.on("error",()=>{B$.delete(t),r()})}};function Ww(t,e){return!!ki(t,e)}function ki(t,e){if(!vs.env.NETLIFY_LOCAL_MODE)try{let i=VFe.resolve(hie.name),o=Es.dirname(i);for(;o!==Es.dirname(o);){let s=Es.dirname(o);if(Es.basename(s)==="node_modules"){let a=Es.join(s,".bin",e);if(Hw.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(vs.env.NODE_PATH){let i=Es.join(vs.env.NODE_PATH,".bin",e);if(Hw.existsSync(i))return i}let r=Es.join(t,"node_modules",".bin",e);if(Hw.existsSync(r))return r;let n=Es.join(qFe,"..","node_modules",".bin",e);if(Hw.existsSync(n))return n}var WFe=le("utils"),YFe=t=>new Promise(e=>{setTimeout(e,t)});var z$=t=>{try{return new URL(t).hostname||null}catch{return null}},Yw=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await YFe(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},Fa=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},vie=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):WFe.error("Could not parse JSON",n))}},KFe=t=>t.charAt(0).toUpperCase()+t.slice(1),To=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():KFe(e)).join(" ");function Ts(t,e){e&&t.log(`Skill invoked: ${e}`)}var Kw=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Tie=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var G$=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},ZFe=1e4,q$=(t,e=ZFe)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{createHash as JFe}from"crypto";import{createReadStream as XFe}from"fs";import Zw from"fs/promises";import Rie from"os";import Jw from"path";var bie=le("repo"),Iie="runner-diffs-",Cie=t=>`${Iie}${t}-`,Pie=async t=>{let e=Rie.tmpdir(),r;try{r=await Zw.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Iie)&&!n.startsWith(Cie(t))).map(n=>Zw.rm(Jw.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},nn=(t,e={})=>zt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Xw=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{bie.info("Getting runner diffs");let n=await eBe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=rBe(o);await nBe(h,r)}bie.info("Changes after processing"),await H$(r);let s=await W$(o,r);if(await V$(s,r),i=await tBe(r),!i)return{hasChanges:!1,ignored:s};await nn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await Zw.mkdtemp(Jw.join(Rie.tmpdir(),Cie(t.sessionId))),c=async({from:h,to:m,fileName:S,binary:E})=>{let b=Jw.join(a,S);await nn([...E?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:y}=await Zw.stat(b);return{path:b,size:y}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await xie(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await wie(d,h)||(f=h)}await xie(r),ce.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await wie(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},Aie=async t=>{let e=JFe("sha256");for await(let r of XFe(t))e.update(r);return e.digest("hex")},wie=async(t,e)=>t.size===e.size&&await Aie(t.path)===await Aie(e.path),xie=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await nn(["reset","--soft","HEAD~1"],{cwd:t})},V$=async(t=[],e=process.cwd())=>{await nn(["add",".",...t],{cwd:e})},H$=async(t=process.cwd())=>{let e=await nn(["status","-s"],{cwd:t});return String(e.stdout??"")},Oie=/.. (.+)?\.log$/,QFe=[Oie],eBe=async(t=process.cwd())=>{let e=await H$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
116
116
|
`).filter(i=>QFe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},tBe=async(t=process.cwd())=>{try{return await nn(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},V_=async(t=process.cwd())=>{let{stdout:e}=await nn(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},Nie=async(t=process.cwd())=>{let{stdout:e}=await nn(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},W$=async(t,e=process.cwd())=>{t||=await H$(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
|
|
117
117
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${Jw.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Oie)?.[1];o&&n.push(`:!${o}.log`)}),n},kie=async(t=process.cwd())=>{await nn(["reset","--hard","HEAD"],{cwd:t})},Mie=async(t=process.cwd())=>{let e=await nn(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
118
118
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},rBe=t=>{let e=t.split(`
|