@doubao-dev/cli 1.0.0-rc.12 → 1.0.0-rc.14

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/691.js CHANGED
@@ -26,7 +26,7 @@ ${e}`})(tQ(e)&&tJ in e?e.originalMessage:String(e?.message??e),t));return""===r?
26
26
  ${E}`,w=`${F}: ${s}${C}`,_=[w,...void 0===t?[e[2],e[1]]:[t],...e.slice(3),r.map(e=>{let t;return"string"==typeof(t=e)?t:S(t)}).join("\n")].map(e=>{let t;return tp(nw(Array.isArray(t=e)?t.map(e=>nw(n0(e))).filter(Boolean).join("\n"):n0(t)))}).filter(Boolean).join("\n\n");return{originalMessage:E,shortMessage:w,message:_}})({stdio:d,all:p,ipcOutput:f,originalError:e,signal:w,signalDescription:_,exitCode:C,escapedCommand:r,timedOut:o,isCanceled:u,isGracefullyCanceled:a,isMaxBuffer:s,isForcefullyTerminated:l,forceKillAfterDelay:b,killSignal:y,maxBuffer:F,timeout:m,cwd:g}),A=new(E?tZ:tX)(T,e instanceof tK?{}:{cause:e});return Object.assign(A,n3({error:A,command:t,escapedCommand:r,startTime:n,timedOut:o,isCanceled:u,isGracefullyCanceled:a,isMaxBuffer:s,isForcefullyTerminated:l,exitCode:C,signal:w,signalDescription:_,stdio:d,all:p,ipcOutput:f,cwd:g,originalMessage:v,shortMessage:B})),A},n3=({error:e,command:t,escapedCommand:r,startTime:n,timedOut:o,isCanceled:u,isGracefullyCanceled:a,isMaxBuffer:s,isForcefullyTerminated:l,exitCode:D,signal:c,signalDescription:d,stdio:p,all:f,ipcOutput:h,cwd:m,originalMessage:b,shortMessage:y})=>n6({shortMessage:y,originalMessage:b,command:t,escapedCommand:r,cwd:m,durationMs:tz(n),failed:!0,timedOut:o,isCanceled:u,isGracefullyCanceled:a,isTerminated:void 0!==c,isMaxBuffer:s,isForcefullyTerminated:l,exitCode:D,signal:c,signalDescription:d,code:e.cause?.code,stdout:p[1],stderr:p[2],all:f,stdio:p,ipcOutput:h,pipedFrom:[]}),n6=e=>Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e)),n9=(e,t)=>{let r=null===t?void 0:t,n=void 0===r?void 0:ro(t);return{exitCode:null===e?void 0:e,signal:r,signalDescription:n}},n7=e=>Number.isFinite(e)?e:0,n4=24n*60n*60n*1000n,n5=(e,t,{reject:r})=>{if((({verbose:e})=>"none"!==tl(e,void 0))(t)){var n,o;e.failed&&tI({type:"error",verboseMessage:e.shortMessage,verboseInfo:t,result:e}),n=e,o=t,tI({type:"duration",verboseMessage:`(done in ${function(e,t){let r="bigint"==typeof e;if(!r&&!Number.isFinite(e))throw TypeError("Expected a finite number or bigint");t={...t};let n=e<0?"-":"";e=e<0?-e:e,t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.unitCount=1,t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);let o=[],u=(e,r,n,u)=>{if(!((0===o.length||!t.colonNotation)&&(0===e||0n===e))||t.colonNotation&&"m"===n){if(u??=String(e),t.colonNotation){let e=u.includes(".")?u.split(".")[0].length:u.length,t=o.length>0?2:1;u="0".repeat(Math.max(0,t-e))+u}else u+=t.verbose?" "+(1===e||1n===e?r:`${r}s`):n;o.push(u)}},a=function(e){switch(typeof e){case"number":if(Number.isFinite(e))return{days:Math.trunc(e/864e5),hours:Math.trunc(e/36e5%24),minutes:Math.trunc(e/6e4%60),seconds:Math.trunc(e/1e3%60),milliseconds:Math.trunc(e%1e3),microseconds:Math.trunc(n7(1e3*e)%1e3),nanoseconds:Math.trunc(n7(1e6*e)%1e3)};break;case"bigint":return{days:e/86400000n,hours:e/3600000n%24n,minutes:e/60000n%60n,seconds:e/1000n%60n,milliseconds:e%1000n,microseconds:0n,nanoseconds:0n}}throw TypeError("Expected a finite number or bigint")}(e),s=BigInt(a.days);if(t.hideYearAndDays?u(24n*BigInt(s)+BigInt(a.hours),"hour","h"):(t.hideYear?u(s,"day","d"):(u(s/365n,"year","y"),u(s%365n,"day","d")),u(Number(a.hours),"hour","h")),u(Number(a.minutes),"minute","m"),!t.hideSeconds)if(t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3&&!t.subSecondsAsDecimals){let e=Number(a.seconds),r=Number(a.milliseconds),n=Number(a.microseconds),o=Number(a.nanoseconds);if(u(e,"second","s"),t.formatSubMilliseconds)u(r,"millisecond","ms"),u(n,"microsecond","\xb5s"),u(o,"nanosecond","ns");else{let e=r+n/1e3+o/1e6,a="number"==typeof t.millisecondsDecimalDigits?t.millisecondsDecimalDigits:0,s=e>=1?Math.round(e):Math.ceil(e),l=a?e.toFixed(a):s;u(Number.parseFloat(l),"millisecond","ms",l)}}else{let n=(r?Number(e%n4):e)/1e3%60,o="number"==typeof t.secondsDecimalDigits?t.secondsDecimalDigits:1,a=(Math.round(Math.floor(n*10**o+1e-7))/10**o).toFixed(o),s=t.keepDecimalsOnWholeSeconds?a:a.replace(/\.0+$/,"");u(Number.parseFloat(s),"second","s",s)}if(0===o.length)return n+"0"+(t.verbose?" milliseconds":"ms");let l=t.colonNotation?":":" ";return"number"==typeof t.unitCount&&(o=o.slice(0,Math.max(t.unitCount,1))),n+o.join(l)}(n.durationMs)})`,verboseInfo:o,result:n})}if(e.failed&&r)throw e;return e},oe=(e,t)=>(or(e,t,"Duplex stream"),"duplex"),ot=(e,t)=>(or(e,t,"web TransformStream"),"webTransform"),or=({final:e,binary:t,objectMode:r},n,o)=>{on(e,`${n}.final`,o),on(t,`${n}.binary`,o),oi(r,`${n}.objectMode`)},on=(e,t,r)=>{if(void 0!==e)throw TypeError(`The \`${t}\` option can only be defined when using a generator, not a ${r}.`)},oo=({transform:e,final:t,binary:r,objectMode:n},o)=>{if(void 0!==e&&!ou(e))throw TypeError(`The \`${o}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(n$(t,{checkOpen:!1}))throw TypeError(`The \`${o}.final\` option must not be a Duplex stream.`);if(oh(t))throw TypeError(`The \`${o}.final\` option must not be a web TransformStream.`);if(void 0!==t&&!ou(t))throw TypeError(`The \`${o}.final\` option must be a generator.`);return oi(r,`${o}.binary`),oi(n,`${o}.objectMode`),oa(e)||oa(t)?"asyncGenerator":"generator"},oi=(e,t)=>{if(void 0!==e&&"boolean"!=typeof e)throw TypeError(`The \`${t}\` option must use a boolean.`)},ou=e=>oa(e)||os(e),oa=e=>"[object AsyncGeneratorFunction]"===Object.prototype.toString.call(e),os=e=>"[object GeneratorFunction]"===Object.prototype.toString.call(e),ol=e=>"[object URL]"===Object.prototype.toString.call(e),oD=new Set(["file","append"]),oc=e=>"string"==typeof e,od=new Set(["ipc","ignore","inherit","overlapped","pipe"]),op=e=>"[object ReadableStream]"===Object.prototype.toString.call(e),of=e=>"[object WritableStream]"===Object.prototype.toString.call(e),oh=e=>op(e?.readable)&&of(e?.writable),om=e=>"object"==typeof e&&null!==e,ob=new Set(["generator","asyncGenerator","duplex","webTransform"]),oy=new Set(["fileUrl","filePath","fileNumber"]),og=new Set(["fileUrl","filePath"]),oF=new Set([...og,"webStream","nodeStream"]),oE=new Set(["webTransform","duplex"]),oC={generator:"a generator",asyncGenerator:"an async generator",fileUrl:"a file URL",filePath:"a file path string",fileNumber:"a file descriptor number",webStream:"a web stream",nodeStream:"a Node.js stream",webTransform:"a web TransformStream",duplex:"a Duplex stream",native:"any value",iterable:"an iterable",asyncIterable:"an async iterable",string:"a string",uint8Array:"a Uint8Array"},ow=(e,t,r,n)=>"output"===n?o_(e,t,r):ov(e,t,r),o_=(e,t,r)=>{let n=0!==t&&r[t-1].value.readableObjectMode;return{writableObjectMode:n,readableObjectMode:e??n}},ov=(e,t,r)=>{let n=0===t?!0===e:r[t-1].value.readableObjectMode,o=t!==r.length-1&&(e??n);return{writableObjectMode:n,readableObjectMode:o}},oS=({stdioItem:e,stdioItem:{type:t},index:r,newTransforms:n,optionName:o,direction:u,encoding:a})=>"duplex"===t?oB({stdioItem:e,optionName:o}):"webTransform"===t?oT({stdioItem:e,index:r,newTransforms:n,direction:u}):oA({stdioItem:e,index:r,newTransforms:n,direction:u,encoding:a}),oB=({stdioItem:e,stdioItem:{value:{transform:t,transform:{writableObjectMode:r,readableObjectMode:n},objectMode:o=n}},optionName:u})=>{if(o&&!n)throw TypeError(`The \`${u}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!o&&n)throw TypeError(`The \`${u}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...e,value:{transform:t,writableObjectMode:r,readableObjectMode:n}}},oT=({stdioItem:e,stdioItem:{value:t},index:r,newTransforms:n,direction:o})=>{let{transform:u,objectMode:a}=e$(t)?t:{transform:t},{writableObjectMode:s,readableObjectMode:l}=ow(a,r,n,o);return{...e,value:{transform:u,writableObjectMode:s,readableObjectMode:l}}},oA=({stdioItem:e,stdioItem:{value:t},index:r,newTransforms:n,direction:o,encoding:u})=>{let{transform:a,final:s,binary:l=!1,preserveNewlines:D=!1,objectMode:c}=e$(t)?t:{transform:t},d=l||np.has(u),{writableObjectMode:p,readableObjectMode:f}=ow(c,r,n,o);return{...e,value:{transform:a,final:s,binary:d,preserveNewlines:D,writableObjectMode:p,readableObjectMode:f}}},oR=(e,t)=>"input"===t?e.reverse():e,ox=["input","output","output"],oP=()=>void 0,o$=()=>"input",oO={generator:oP,asyncGenerator:oP,fileUrl:oP,filePath:oP,iterable:o$,asyncIterable:o$,uint8Array:o$,webStream:e=>of(e)?"output":"input",nodeStream:e=>nP(e,{checkOpen:!1})?nx(e,{checkOpen:!1})?void 0:"input":"output",webTransform:oP,duplex:oP,native(e){let t=ok(e);return void 0!==t?t:nR(e,{checkOpen:!1})?oO.nodeStream(e):void 0}},ok=e=>[0,R.stdin].includes(e)?"input":[1,2,R.stdout,R.stderr].includes(e)?"output":void 0,oj=e=>e8.some(t=>void 0!==e[t]),oI=(e,t)=>Array.isArray(e)?e.map(e=>oI(e,t)):null==e?t>=e8.length?"ignore":"pipe":e,oL=e=>"pipe"===e||Array.isArray(e)&&e.every(e=>"pipe"===e),oM=({value:e,optionName:t,fdNumber:r,direction:n})=>{let o=oU(e,r);if(void 0!==o){if("output"===n)return{type:"fileNumber",value:o,optionName:t};if(I.isatty(o))throw TypeError(`The \`${t}: ${r$(e)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:eN(et(o)),optionName:t}}},oU=(e,t)=>{if("inherit"===e)return t;if("number"==typeof e)return e;let r=e1.indexOf(e);if(-1!==r)return r},oN=(e,t,r)=>{let n=e1[e];if(void 0===n)throw TypeError(`The \`${r}: ${t}\` option is invalid: no such standard stream.`);return n},oW=e=>{if(nP(e,{checkOpen:!1}))return"nodeStream";if("string"==typeof e)return"string";if(eU(e))return"uint8Array";throw Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},oq=e=>{if(ol(e))return{type:"fileUrl",value:e};if(oc(e))return{type:"filePath",value:{file:e}};throw Error("The `inputFile` option must be a file path string or a file URL.")},oz=({otherStdioItems:e,type:t,value:r,optionName:n,direction:o})=>{let u=e.filter(e=>oH(e,r));if(0!==u.length)return oG(u.find(e=>e.direction!==o),n,t),"output"===o?u[0].stream:void 0},oH=({type:e,value:t},r)=>"filePath"===e?t.file===r.file:"fileUrl"===e?t.href===r.href:t===r,oG=(e,t,r)=>{if(void 0!==e)throw TypeError(`The \`${e.optionName}\` and \`${t}\` options must not target ${oC[r]} that is the same.`)},oV=(e,t,r,n)=>{let o=o1({initialFileDescriptors:(({stdio:e,ipc:t,buffer:r,...n},o,u)=>{let a,s,l,D=((e,t)=>{if(void 0===e)return e8.map(e=>t[e]);if(oj(t))throw Error(`It's not possible to provide \`stdio\` in combination with one of ${e8.map(e=>`\`${e}\``).join(", ")}`);if("string"==typeof e)return[e,e,e];if(!Array.isArray(e))throw TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof e}\``);return Array.from({length:Math.max(e.length,e8.length)},(t,r)=>e[r])})(e,n).map((e,t)=>oI(e,t));return u?(a=D,s=r,l=o,a.map((e,t)=>!s[t]&&0!==t&&!ts(l,t)&&oL(e)?"ignore":e)):t&&!D.includes("ipc")?[...D,"ipc"]:D})(t,r,n).map((e,r)=>oK({stdioOption:e,fdNumber:r,options:t,isSync:n})),addProperties:e,options:t,isSync:n});return t.stdio=o.map(({stdioItems:e})=>o9(e)),o},oK=({stdioOption:e,fdNumber:t,options:r,isSync:n})=>{let o,u,a=e3(t),{stdioItems:s,isStdioArray:l}=oY({stdioOption:e,fdNumber:t,options:r,optionName:a}),D=((e,t,r)=>{let n=e.map(e=>(({type:e,value:t},r)=>ox[r]??oO[e](t))(e,t));if(n.includes("input")&&n.includes("output"))throw TypeError(`The \`${r}\` option must not be an array of both readable and writable values.`);return n.find(Boolean)??"output"})(s,t,a),c=(o=s.map(e=>(({stdioItem:e,stdioItem:{type:t},isStdioArray:r,fdNumber:n,direction:o,isSync:u})=>r&&"native"===t?u?(({stdioItem:e,stdioItem:{value:t,optionName:r},fdNumber:n,direction:o})=>{let u=oM({value:t,optionName:r,fdNumber:n,direction:o});if(void 0!==u)return u;if(nR(t,{checkOpen:!1}))throw TypeError(`The \`${r}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return e})({stdioItem:e,fdNumber:n,direction:o}):(({stdioItem:e,stdioItem:{value:t,optionName:r},fdNumber:n})=>"inherit"===t?{type:"nodeStream",value:oN(n,t,r),optionName:r}:"number"==typeof t?{type:"nodeStream",value:oN(t,t,r),optionName:r}:nR(t,{checkOpen:!1})?{type:"nodeStream",value:t,optionName:r}:e)({stdioItem:e,fdNumber:n}):e)({stdioItem:e,isStdioArray:l,fdNumber:t,direction:D,isSync:n})),[...o.filter(({type:e})=>!ob.has(e)),...((e,t,r,{encoding:n})=>{let o=e.filter(({type:e})=>ob.has(e)),u=Array.from({length:o.length});for(let[e,a]of Object.entries(o))u[e]=oS({stdioItem:a,index:Number(e),newTransforms:u,optionName:t,direction:r,encoding:n});return oR(u,r)})(o,a,D,r)]),d=void 0!==(u=c.findLast(({type:e})=>ob.has(e)))&&("input"===D?u.value.writableObjectMode:u.value.readableObjectMode);return o2(c,d),{direction:D,objectMode:d,stdioItems:c}},oY=({stdioOption:e,fdNumber:t,options:r,optionName:n})=>{let o,u=(o=[...(Array.isArray(e)?e:[e]).map(e=>oJ(e,n)),...(({input:e,inputFile:t},r)=>{let n,o;return 0===r?[...void 0===(n=e)?[]:[{type:oW(n),value:n,optionName:"input"}],...void 0===(o=t)?[]:[{...oq(o),optionName:"inputFile"}]]:[]})(r,t)]).filter((e,t)=>o.every((r,n)=>e.value!==r.value||t>=n||"generator"===e.type||"asyncGenerator"===e.type)),a=u.length>1;return oQ(u,a,n),oZ(u),{stdioItems:u,isStdioArray:a}},oJ=(e,t)=>{let r,n,o,u,a,s,l;return{type:oa(e)?"asyncGenerator":os(e)?"generator":ol(e)?"fileUrl":e$(r=e)&&Object.keys(r).length>0&&Object.keys(r).every(e=>oD.has(e))&&oc(r.file)?"filePath":op(n=e)||of(n)?"webStream":nR(e,{checkOpen:!1})?"native":eU(e)?"uint8Array":om(o=e)&&"function"==typeof o[Symbol.asyncIterator]?"asyncIterable":om(u=e)&&"function"==typeof u[Symbol.iterator]?"iterable":oh(e)?ot({transform:e},t):e$(a=e)&&(void 0!==a.transform||void 0!==a.final)?(s=e,l=t,n$(s.transform,{checkOpen:!1})?oe(s,l):oh(s.transform)?ot(s,l):oo(s,l)):"native",value:e,optionName:t}},oQ=(e,t,r)=>{if(0===e.length)throw TypeError(`The \`${r}\` option must not be an empty array.`);if(t){for(let{value:t,optionName:r}of e)if(oX.has(t))throw Error(`The \`${r}\` option must not include \`${t}\`.`)}},oX=new Set(["ignore","ipc"]),oZ=e=>{for(let t of e)o0(t)},o0=({type:e,value:t,optionName:r})=>{if(ol(t)&&"file:"!==t.protocol)throw TypeError(`The \`${r}: URL\` option must use the \`file:\` scheme.
27
27
  For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if("native"===e&&"string"==typeof t&&!od.has(t))throw TypeError(`The \`${r}: { file: '...' }\` option must be used instead of \`${r}: '...'\`.`)},o2=(e,t)=>{if(!t)return;let r=e.find(({type:e})=>oy.has(e));if(void 0!==r)throw TypeError(`The \`${r.optionName}\` option cannot use both files and transforms in objectMode.`)},o1=({initialFileDescriptors:e,addProperties:t,options:r,isSync:n})=>{let o=[];try{for(let u of e)o.push(o8({fileDescriptor:u,fileDescriptors:o,addProperties:t,options:r,isSync:n}));return o}catch(e){throw o6(o),e}},o8=({fileDescriptor:{direction:e,objectMode:t,stdioItems:r},fileDescriptors:n,addProperties:o,options:u,isSync:a})=>{let s=r.map(t=>o3({stdioItem:t,addProperties:o,direction:e,options:u,fileDescriptors:n,isSync:a}));return{direction:e,objectMode:t,stdioItems:s}},o3=({stdioItem:e,addProperties:t,direction:r,options:n,fileDescriptors:o,isSync:u})=>{let a=(({stdioItem:{type:e,value:t,optionName:r},direction:n,fileDescriptors:o,isSync:u})=>{let a,s,l=(a=o,s=e,a.flatMap(({direction:e,stdioItems:t})=>t.filter(e=>e.type===s).map(t=>({...t,direction:e}))));if(0!==l.length){if(u)return void(({otherStdioItems:e,type:t,value:r,optionName:n,direction:o})=>{og.has(t)&&oz({otherStdioItems:e,type:t,value:r,optionName:n,direction:o})})({otherStdioItems:l,type:e,value:t,optionName:r,direction:n});if(oF.has(e))return oz({otherStdioItems:l,type:e,value:t,optionName:r,direction:n});oE.has(e)&&(({otherStdioItems:e,type:t,value:r,optionName:n})=>{oG(e.find(({value:{transform:e}})=>e===r.transform),n,t)})({otherStdioItems:l,type:e,value:t,optionName:r})}})({stdioItem:e,direction:r,fileDescriptors:o,isSync:u});return void 0!==a?{...e,stream:a}:{...e,...t[r][e.type](e,n)}},o6=e=>{for(let{stdioItems:t}of e)for(let{stream:e}of t)void 0===e||e2(e)||e.destroy()},o9=e=>{if(e.length>1)return e.some(({value:e})=>"overlapped"===e)?"overlapped":"pipe";let[{type:t,value:r}]=e;return"native"===t?r:"pipe"},o7=({type:e,optionName:t})=>{o4(t,oC[e])},o4=(e,t)=>{throw TypeError(`The \`${e}\` option cannot be ${t} with synchronous methods.`)},o5={generator(){},asyncGenerator:o7,webStream:o7,nodeStream:o7,webTransform:o7,duplex:o7,asyncIterable:o7,native:({optionName:e,value:t})=>(("ipc"===t||"overlapped"===t)&&o4(e,`"${t}"`),{})},ie={input:{...o5,fileUrl:({value:e})=>({contents:[eN(et(e))]}),filePath:({value:{file:e}})=>({contents:[eN(et(e))]}),fileNumber:o7,iterable:({value:e})=>({contents:[...e]}),string:({value:e})=>({contents:[e]}),uint8Array:({value:e})=>({contents:[e]})},output:{...o5,fileUrl:({value:e})=>({path:e}),filePath:({value:{file:e,append:t}})=>({path:e,append:t}),fileNumber:({value:e})=>({path:e}),iterable:o7,string:o7,uint8Array:o7}},it=(e,{stripFinalNewline:t},r)=>ir(t,r)&&void 0!==e&&!Array.isArray(e)?nw(e):e,ir=(e,t)=>"all"===t?e[1]||e[2]:e[t],io=(e,t,r,n)=>e||r?void 0:ia(t,n),ii=(e,t,r)=>r?e.flatMap(e=>iu(e,t)):iu(e,t),iu=(e,t)=>{let{transform:r,final:n}=ia(t,{});return[...r(e),...n()]},ia=(e,t)=>(t.previousChunks="",{transform:is.bind(void 0,t,e),final:iD.bind(void 0,t)}),is=function*(e,t,r){if("string"!=typeof r)return void(yield r);let{previousChunks:n}=e,o=-1;for(let u=0;u<r.length;u+=1)if("\n"===r[u]){let a=il(r,u,t,e),s=r.slice(o+1,u+1-a);n.length>0&&(s=id(n,s),n=""),yield s,o=u}o!==r.length-1&&(n=id(n,r.slice(o+1))),e.previousChunks=n},il=(e,t,r,n)=>r?0:(n.isWindowsNewline=0!==t&&"\r"===e[t-1],n.isWindowsNewline?2:1),iD=function*({previousChunks:e}){e.length>0&&(yield e)},ic=function*({isWindowsNewline:e=!1},t){let{unixNewline:r,windowsNewline:n,LF:o,concatBytes:u}="string"==typeof t?ip:ih;t.at(-1)===o?yield t:yield u(t,e?n:r)},id=(e,t)=>`${e}${t}`,ip={windowsNewline:"\r\n",unixNewline:"\n",LF:"\n",concatBytes:id},ih={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:(e,t)=>{let r=new Uint8Array(e.length+t.length);return r.set(e,0),r.set(t,e.length),r}},im=function*(e,t){if("string"!=typeof t&&!eU(t)&&!ed.isBuffer(t))throw TypeError(`The \`${e}\` option's transform must use "objectMode: true" to receive as input: ${typeof t}.`);yield t},ib=function*(e,t){ig(e,t),yield t},iy=function*(e,t){if(ig(e,t),"string"!=typeof t&&!eU(t))throw TypeError(`The \`${e}\` option's function must yield a string or an Uint8Array, not ${typeof t}.`);yield t},ig=(e,t)=>{if(null==t)throw TypeError(`The \`${e}\` option's function must not call \`yield ${t}\`.
28
28
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
29
- if (condition) { yield value; }`)},iF=(e,t,r)=>{if(r)return;if(e)return{transform:iE.bind(void 0,new TextEncoder)};let n=new E(t);return{transform:iC.bind(void 0,n),final:iw.bind(void 0,n)}},iE=function*(e,t){ed.isBuffer(t)?yield eN(t):"string"==typeof t?yield e.encode(t):yield t},iC=function*(e,t){yield eU(t)?e.write(t):t},iw=function*(e){let t=e.end();""!==t&&(yield t)},i_=w(async(e,t,r,n)=>{t.currentIterable=e(...r);try{for await(let e of t.currentIterable)n.push(e)}finally{delete t.currentIterable}}),iv=async function*(e,t,r){if(r===t.length)return void(yield e);let{transform:n=iA}=t[r];for await(let o of n(e))yield*iv(o,t,r+1)},iS=async function*(e){for(let[t,{final:r}]of Object.entries(e))yield*iB(r,Number(t),e)},iB=async function*(e,t,r){if(void 0!==e)for await(let n of e())yield*iv(n,r,t+1)},iT=w(async({currentIterable:e},t)=>{if(void 0!==e)return void await (t?e.throw(t):e.return());if(t)throw t}),iA=function*(e){yield e},iR=(e,t,r,n)=>{try{for(let n of e(...t))r.push(n);n()}catch(e){n(e)}},ix=(e,t)=>[...t.flatMap(t=>[...iP(t,e,0)]),...i$(e)],iP=function*(e,t,r){if(r===t.length)return void(yield e);let{transform:n=ik}=t[r];for(let o of n(e))yield*iP(o,t,r+1)},i$=function*(e){for(let[t,{final:r}]of Object.entries(e))yield*iO(r,Number(t),e)},iO=function*(e,t,r){if(void 0!==e)for(let n of e())yield*iP(n,r,t+1)},ik=function*(e){yield e},ij=({value:e,value:{transform:t,final:r,writableObjectMode:n,readableObjectMode:o},optionName:u},{encoding:a})=>{let s={},l=iL(e,a,u),D=oa(t),c=oa(r),d=D?i_.bind(void 0,iv,s):iR.bind(void 0,iP),p=D||c?i_.bind(void 0,iS,s):iR.bind(void 0,i$),f=D||c?iT.bind(void 0,s):void 0;return{stream:new es({writableObjectMode:n,writableHighWaterMark:eD(n),readableObjectMode:o,readableHighWaterMark:eD(o),transform(e,t,r){d([e,l,0],this,r)},flush(e){p([l],this,e)},destroy:f})}},iI=(e,t,r,n)=>{let o=t.filter(({type:e})=>"generator"===e);for(let{value:t,optionName:u}of n?o.reverse():o)e=ix(iL(t,r,u),e);return e},iL=({transform:e,final:t,binary:r,writableObjectMode:n,readableObjectMode:o,preserveNewlines:u},a,s)=>{let l={};return[{transform:n?void 0:im.bind(void 0,s)},iF(r,a,n),io(r,u,n,l),{transform:e,final:t},{transform:o?ib.bind(void 0,s):iy.bind(void 0,s)},(({binary:e,preserveNewlines:t,readableObjectMode:r,state:n})=>e||t||r?void 0:{transform:ic.bind(void 0,n)})({binary:r,preserveNewlines:u,readableObjectMode:o,state:l})].filter(Boolean)},iM=(e,t,r)=>{let{stdioItems:n}=e[t],o=n.filter(({contents:e})=>void 0!==e);if(0!==o.length){if(0!==t){let[{type:e,optionName:t}]=o;throw TypeError(`Only the \`stdin\` option, not \`${t}\`, can be ${oC[e]} with synchronous methods.`)}r.input=ez(o.map(({contents:e})=>e).map(e=>iU(e,n)))}},iU=(e,t)=>{let r=iI(e,t,"utf8",!0);return iN(r),ez(r)},iN=e=>{let t=e.find(e=>"string"!=typeof e&&!eU(e));if(void 0!==t)throw TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${t}.`)},iW=({stdioItems:e,encoding:t,verboseInfo:r,fdNumber:n})=>"all"!==n&&ts(r,n)&&!np.has(t)&&iq(n)&&(e.some(({type:e,value:t})=>"native"===e&&iz.has(t))||e.every(({type:e})=>ob.has(e))),iq=e=>1===e||2===e,iz=new Set(["pipe","overlapped"]),iH=async(e,t,r,n)=>{for await(let o of e)iG(t)||iV(o,r,n)},iG=e=>e._readableState.pipes.length>0,iV=(e,t,r)=>{tI({type:"output",verboseMessage:tN(e),fdNumber:t,verboseInfo:r})},iK=(e,t,r,n)=>{try{return iI(e,t,r,!1)}catch(t){return n.error=t,e}},iY=({chunks:e,objectMode:t,encoding:r,lines:n,stripFinalNewline:o,fdNumber:u})=>{if(t)return{serializedResult:e};if("buffer"===r)return{serializedResult:ez(e)};let a=((e,t)=>{if("utf8"===t&&e.every(e=>"string"==typeof e))return e;let r=new E(t),n=e.map(e=>"string"==typeof e?eW.encode(e):e).map(e=>r.write(e)),o=r.end();return""===o?n:[...n,o]})(e,r).join("");return n[u]?{serializedResult:a,finalResult:ii(a,!o[u],t)}:{serializedResult:a}},iJ=({serializedResult:e,fdNumber:t,state:r,verboseInfo:n,encoding:o,stdioItems:u,objectMode:a})=>{if(!iW({stdioItems:u,encoding:o,verboseInfo:n,fdNumber:t}))return;let s=ii(e,!1,a);try{for(let e of s)iV(e,t,n)}catch(e){r.error??=e}},iQ=(e,t,r)=>{for(let{path:n,append:o}of t.filter(({type:e})=>oy.has(e))){let t="string"==typeof n?n:n.toString();o||r.has(t)?Q(n,e):(r.add(t),en(n,e))}},iX=async(e,t)=>{let[r,n]=await iZ(e);return t.isForcefullyTerminated??=!1,[r,n]},iZ=async e=>{let[t,r]=await Promise.allSettled([V(e,"spawn"),V(e,"exit")]);return"rejected"===t.status?[]:"rejected"===r.status?i0(e):r.value},i0=async e=>{try{return await V(e,"exit")}catch{return i0(e)}},i2=async e=>{let[t,r]=await e;if(!i1(t,r)&&i8(t,r))throw new tK;return[t,r]},i1=(e,t)=>void 0===e&&void 0===t,i8=(e,t)=>0!==e||null!==t,i3=e=>e.node&&!e.ipc?{...e,ipc:!1}:e,i6=({ipc:e,ipcInput:t,detached:r,cancelSignal:n})=>{t&&i9("ipcInput"),e&&i9("ipc: true"),r&&i9("detached: true"),n&&i9("cancelSignal")},i9=e=>{throw TypeError(`The "${e}" option cannot be used with synchronous methods.`)},i7=({file:e,commandArguments:t,options:r,command:n,escapedCommand:o,fileDescriptors:u,startTime:a})=>{try{let n;for(let e of(n=u,new Set(Object.entries(n).filter(([,{direction:e}])=>"input"===e).map(([e])=>Number(e)))))iM(u,e,r);let o=i4(r);return F(...nC(e,t,o))}catch(e){return n1({error:e,command:n,escapedCommand:o,fileDescriptors:u,options:r,startTime:a,isSync:!0})}},i4=({encoding:e,maxBuffer:t,...r})=>({...r,encoding:"buffer",maxBuffer:(([,e])=>e)(t)}),i5=({error:e,exitCode:t,signal:r,timedOut:n,isMaxBuffer:o,stdio:u,all:a,options:s,command:l,escapedCommand:D,startTime:c})=>void 0===e?n2({command:l,escapedCommand:D,stdio:u,all:a,ipcOutput:[],options:s,startTime:c}):n8({error:e,command:l,escapedCommand:D,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:o,isForcefullyTerminated:!1,exitCode:t,signal:r,stdio:u,all:a,ipcOutput:[],options:s,startTime:c,isSync:!0}),ue=({anyProcess:e,channel:t,isSubprocess:r,ipc:n},{reference:o=!0,filter:u}={})=>(rd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:rH(e)}),ut({anyProcess:e,channel:t,isSubprocess:r,filter:u,reference:o})),ut=async({anyProcess:e,channel:t,isSubprocess:r,filter:n,reference:o})=>{rk(t,o);let u=rW(e,t,r),a=new AbortController;try{return await Promise.race([ur(u,n,a),un(u,r,a),uo(u,r,a)])}catch(t){throw rE(e),t}finally{a.abort(),rI(t,o)}},ur=async(e,t,{signal:r})=>{if(void 0===t){let[t]=await V(e,"message",{signal:r});return t}for await(let[n]of G(e,"message",{signal:r}))if(t(n))return n},un=async(e,t,{signal:r})=>{await V(e,"disconnect",{signal:r});throw Error(`${ry("getOneMessage",t)} could not complete: the ${rF(t)} exited or disconnected.`)},uo=async(e,t,{signal:r})=>{let[n]=await V(e,"strict:error",{signal:r});throw rh(n,t)},ui=({anyProcess:e,channel:t,isSubprocess:r,ipc:n},{reference:o=!0}={})=>uu({anyProcess:e,channel:t,isSubprocess:r,ipc:n,shouldAwait:!r,reference:o}),uu=({anyProcess:e,channel:t,isSubprocess:r,ipc:n,shouldAwait:o,reference:u})=>{rd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:rH(e)}),rk(t,u);let a=rW(e,t,r),s=new AbortController,l={};return ua(e,a,s),us({ipcEmitter:a,isSubprocess:r,controller:s,state:l}),ul({anyProcess:e,channel:t,ipcEmitter:a,isSubprocess:r,shouldAwait:o,controller:s,state:l,reference:u})},ua=async(e,t,r)=>{try{await V(t,"disconnect",{signal:r.signal}),r.abort()}catch{}},us=async({ipcEmitter:e,isSubprocess:t,controller:r,state:n})=>{try{let[o]=await V(e,"strict:error",{signal:r.signal});n.error=rh(o,t),r.abort()}catch{}},ul=async function*({anyProcess:e,channel:t,ipcEmitter:r,isSubprocess:n,shouldAwait:o,controller:u,state:a,reference:s}){try{for await(let[e]of G(r,"message",{signal:u.signal}))uD(a),yield e}catch{uD(a)}finally{u.abort(),rI(t,s),n||rE(e),o&&await e}},uD=({error:e})=>{if(e)throw e},uc=(e,t,r)=>({sendMessage:r6.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r}),getOneMessage:ue.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r}),getEachMessage:ui.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r})}),ud=()=>{let e=new eu;return e.end(),e},up=()=>new ea({read(){}}),uf=()=>new el({write(){}}),uh=()=>new ei({read(){},write(){}}),um=async(e,t,r)=>n5(e,t,r),ub=({type:e,optionName:t})=>{throw TypeError(`The \`${t}\` option cannot be ${oC[e]}.`)},uy={fileNumber:ub,generator:ij,asyncGenerator:ij,nodeStream:({value:e})=>({stream:e}),webTransform:({value:{transform:e,writableObjectMode:t,readableObjectMode:r}})=>({stream:ei.fromWeb(e,{objectMode:t||r})}),duplex:({value:{transform:e}})=>({stream:e}),native(){}},ug={input:{...uy,fileUrl:({value:e})=>({stream:X(e)}),filePath:({value:{file:e}})=>({stream:X(e)}),webStream:({value:e})=>({stream:ea.fromWeb(e)}),iterable:({value:e})=>({stream:ea.from(e)}),asyncIterable:({value:e})=>({stream:ea.from(e)}),string:({value:e})=>({stream:ea.from(e)}),uint8Array:({value:e})=>({stream:ea.from(ed.from(e))})},output:{...uy,fileUrl:({value:e})=>({stream:Z(e)}),filePath:({value:{file:e,append:t}})=>({stream:Z(e,t?{flags:"a"}:{})}),webStream:({value:e})=>({stream:el.fromWeb(e)}),iterable:ub,asyncIterable:ub,string:ub,uint8Array:ub}};function uF(e){if(!Array.isArray(e))throw TypeError(`Expected an array, got \`${typeof e}\`.`);for(let t of e)uS(t);let t=e.some(({readableObjectMode:e})=>e),r=uE(e,t),n=new uC({objectMode:t,writableHighWaterMark:r,readableHighWaterMark:r});for(let t of e)n.add(t);return n}let uE=(e,t)=>0===e.length?eD(t):Math.max(...e.filter(({readableObjectMode:e})=>e===t).map(({readableHighWaterMark:e})=>e));class uC extends eu{#u=new Set([]);#a=new Set([]);#s=new Set([]);#l;#D=Symbol("unpipe");#c=new WeakMap;add(e){if(uS(e),this.#u.has(e))return;this.#u.add(e),this.#l??=uw(this,this.#u,this.#D);let t=uB({passThroughStream:this,stream:e,streams:this.#u,ended:this.#a,aborted:this.#s,onFinished:this.#l,unpipeEvent:this.#D});this.#c.set(e,t),e.pipe(this,{end:!1})}async remove(e){if(uS(e),!this.#u.has(e))return!1;let t=this.#c.get(e);return void 0!==t&&(this.#c.delete(e),e.unpipe(this),await t,!0)}}let uw=async(e,t,r)=>{uI(e,uL);let n=new AbortController;try{await Promise.race([u_(e,n),uv(e,t,r,n)])}finally{n.abort(),uI(e,-uL)}},u_=async(e,{signal:t})=>{try{await ep(e,{signal:t,cleanup:!0})}catch(t){throw uP(e,t),t}},uv=async(e,t,r,{signal:n})=>{for await(let[o]of G(e,"unpipe",{signal:n}))t.has(o)&&o.emit(r)},uS=e=>{if("function"!=typeof e?.pipe)throw TypeError(`Expected a readable stream, got: \`${typeof e}\`.`)},uB=async({passThroughStream:e,stream:t,streams:r,ended:n,aborted:o,onFinished:u,unpipeEvent:a})=>{uI(e,uM);let s=new AbortController;try{await Promise.race([uT(u,t,s),uA({passThroughStream:e,stream:t,streams:r,ended:n,aborted:o,controller:s}),uR({stream:t,streams:r,ended:n,aborted:o,unpipeEvent:a,controller:s})])}finally{s.abort(),uI(e,-uM)}r.size>0&&r.size===n.size+o.size&&(0===n.size&&o.size>0?uO(e):ux(e))},uT=async(e,t,{signal:r})=>{try{await e,r.aborted||uO(t)}catch(e){r.aborted||uP(t,e)}},uA=async({passThroughStream:e,stream:t,streams:r,ended:n,aborted:o,controller:{signal:u}})=>{try{await ep(t,{signal:u,cleanup:!0,readable:!0,writable:!1}),r.has(t)&&n.add(t)}catch(n){if(u.aborted||!r.has(t))return;u$(n)?o.add(t):uk(e,n)}},uR=async({stream:e,streams:t,ended:r,aborted:n,unpipeEvent:o,controller:{signal:u}})=>{if(await V(e,o,{signal:u}),!e.readable)return V(u,"abort",{signal:u});t.delete(e),r.delete(e),n.delete(e)},ux=e=>{e.writable&&e.end()},uP=(e,t)=>{u$(t)?uO(e):uk(e,t)},u$=e=>e?.code==="ERR_STREAM_PREMATURE_CLOSE",uO=e=>{(e.readable||e.writable)&&e.destroy()},uk=(e,t)=>{e.destroyed||(e.once("error",uj),e.destroy(t))},uj=()=>{},uI=(e,t)=>{let r=e.getMaxListeners();0!==r&&r!==1/0&&e.setMaxListeners(r+t)},uL=2,uM=1,uU=(e,t)=>{e.pipe(t),uN(e,t),uq(e,t)},uN=async(e,t)=>{if(!(e2(e)||e2(t))){try{await ep(e,{cleanup:!0,readable:!0,writable:!1})}catch{}uW(t)}},uW=e=>{e.writable&&e.end()},uq=async(e,t)=>{if(!(e2(e)||e2(t))){try{await ep(t,{cleanup:!0,readable:!1,writable:!0})}catch{}uz(e)}},uz=e=>{e.readable&&e.destroy()},uH=(e,t,r,n)=>{"output"===r?uU(e.stdio[n],t):uU(t,e.stdio[n]);let o=uG[n];void 0!==o&&(e[o]=t),e.stdio[n]=t},uG=["stdin","stdout","stderr"],uV=({subprocess:e,stream:t,direction:r,fdNumber:n,pipeGroups:o,controller:u})=>{if(void 0===t)return;uK(t,u);let[a,s]="output"===r?[t,e.stdio[n]]:[e.stdio[n],t],l=o.get(a)??[];o.set(a,[...l,s])},uK=(e,{signal:t})=>{e2(e)&&rO(e,uY,t)},uY=2,uJ=[];uJ.push("SIGHUP","SIGINT","SIGTERM"),"win32"!==process.platform&&uJ.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),"linux"===process.platform&&uJ.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");let uQ=e=>!!e&&"object"==typeof e&&"function"==typeof e.removeListener&&"function"==typeof e.emit&&"function"==typeof e.reallyExit&&"function"==typeof e.listeners&&"function"==typeof e.kill&&"number"==typeof e.pid&&"function"==typeof e.on,uX=Symbol.for("signal-exit emitter"),uZ=globalThis,u0=Object.defineProperty.bind(Object);class u2{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(uZ[uX])return uZ[uX];u0(uZ,uX,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let r=this.listeners[e],n=r.indexOf(t);-1!==n&&(0===n&&1===r.length?r.length=0:r.splice(n,1))}emit(e,t,r){if(this.emitted[e])return!1;this.emitted[e]=!0;let n=!1;for(let o of this.listeners[e])n=!0===o(t,r)||n;return"exit"===e&&(n=this.emit("afterExit",t,r)||n),n}}class u1{}class u8 extends u1{#d="win32"===u3.platform?"SIGINT":"SIGHUP";#p=new u2;#f;#h;#m;#b={};#y=!1;constructor(e){for(let t of(super(),this.#f=e,this.#b={},uJ))this.#b[t]=()=>{let r=this.#f.listeners(t),{count:n}=this.#p;if("object"==typeof e.__signal_exit_emitter__&&"number"==typeof e.__signal_exit_emitter__.count&&(n+=e.__signal_exit_emitter__.count),r.length===n){this.unload();let r=this.#p.emit("exit",null,t),n="SIGHUP"===t?this.#d:t;r||e.kill(e.pid,n)}};this.#m=e.reallyExit,this.#h=e.emit}onExit(e,t){if(!uQ(this.#f))return()=>{};!1===this.#y&&this.load();let r=t?.alwaysLast?"afterExit":"exit";return this.#p.on(r,e),()=>{this.#p.removeListener(r,e),0===this.#p.listeners.exit.length&&0===this.#p.listeners.afterExit.length&&this.unload()}}load(){if(!this.#y){for(let e of(this.#y=!0,this.#p.count+=1,uJ))try{let t=this.#b[e];t&&this.#f.on(e,t)}catch(e){}this.#f.emit=(e,...t)=>this.#g(e,...t),this.#f.reallyExit=e=>this.#F(e)}}unload(){this.#y&&(this.#y=!1,uJ.forEach(e=>{let t=this.#b[e];if(!t)throw Error("Listener not defined for signal: "+e);try{this.#f.removeListener(e,t)}catch(e){}}),this.#f.emit=this.#h,this.#f.reallyExit=this.#m,this.#p.count-=1)}#F(e){return uQ(this.#f)?(this.#f.exitCode=e||0,this.#p.emit("exit",this.#f.exitCode,null),this.#m.call(this.#f,this.#f.exitCode)):0}#g(e,...t){let r=this.#h;if(!("exit"===e&&uQ(this.#f)))return r.call(this.#f,e,...t);{"number"==typeof t[0]&&(this.#f.exitCode=t[0]);let n=r.call(this.#f,e,...t);return this.#p.emit("exit",this.#f.exitCode,null),n}}}let u3=globalThis.process,{onExit:u6,load:u9,unload:u7}=(r=uQ(u3)?new u8(u3):new class extends u1{onExit(){return()=>{}}load(){}unload(){}},{onExit:(e,t)=>r.onExit(e,t),load:()=>r.load(),unload:()=>r.unload()}),u4=(e,t,r,...n)=>{if(Array.isArray(r))return{destination:t(u5,e)(r,...n),pipeOptions:e};if("string"==typeof r||r instanceof URL||ej(r)){if(Object.keys(e).length>0)throw TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[o,u,a]=eL(r,...n);return{destination:t(u5)(o,u,a),pipeOptions:a}}if(rv.has(r)){if(Object.keys(e).length>0)throw TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},u5=({options:e})=>({options:{...e,stdin:"pipe",piped:!0}}),ae=({error:e,fileDescriptors:t,sourceOptions:r,startTime:n})=>n1({error:e,command:at,escapedCommand:at,fileDescriptors:t,options:r,startTime:n,isSync:!1}),at="source.pipe(destination)",ar=async e=>{let[{status:t,reason:r,value:n=r},{status:o,reason:u,value:a=u}]=await e;if(a.pipedFrom.includes(n)||a.pipedFrom.push(n),"rejected"===o)throw a;if("rejected"===t)throw n;return a},an=async e=>{try{await ep(e,{cleanup:!0,readable:!1,writable:!0})}catch{}ao.delete(e)},ao=new WeakMap,ai=async(e,{sourceStream:t,mergedStream:r,fileDescriptors:n,sourceOptions:o,startTime:u})=>{throw await C(e,t),await r.remove(t),ae({error:Error("Pipe canceled by `unpipeSignal` option."),fileDescriptors:n,sourceOptions:o,startTime:u})},au=(e,...t)=>{if(e$(t[0]))return au.bind(void 0,{...e,boundOptions:{...e.boundOptions,...t[0]}});let{destination:r,...n}=(({source:e,sourcePromise:t,boundOptions:r,createNested:n},...o)=>{let u=$.bigint(),{destination:a,destinationStream:s,destinationError:l,from:D,unpipeSignal:c}=((e,t,r)=>{try{let{destination:n,pipeOptions:{from:o,to:u,unpipeSignal:a}={}}=u4(e,t,...r),s=rw(n,u);return{destination:n,destinationStream:s,from:o,unpipeSignal:a}}catch(e){return{destinationError:e}}})(r,n,o),{sourceStream:d,sourceError:p}=((e,t)=>{try{return{sourceStream:r_(e,t)}}catch(e){return{sourceError:e}}})(e,D),{options:f,fileDescriptors:h}=rv.get(e);return{sourcePromise:t,sourceStream:d,sourceOptions:f,sourceError:p,destination:a,destinationStream:s,destinationError:l,unpipeSignal:c,fileDescriptors:h,startTime:u}})(e,...t),o=aa({...n,destination:r});return o.pipe=au.bind(void 0,{...e,source:r,sourcePromise:o,boundOptions:{}}),o},aa=async({sourcePromise:e,sourceStream:t,sourceOptions:r,sourceError:n,destination:o,destinationStream:u,destinationError:a,unpipeSignal:s,fileDescriptors:l,startTime:D})=>{let c=as(e,o);(({sourceStream:e,sourceError:t,destinationStream:r,destinationError:n,fileDescriptors:o,sourceOptions:u,startTime:a})=>{let s=(({sourceStream:e,sourceError:t,destinationStream:r,destinationError:n})=>void 0!==t&&void 0!==n?n:void 0!==n?(uz(e),n):void 0!==t?(uW(r),t):void 0)({sourceStream:e,sourceError:t,destinationStream:r,destinationError:n});if(void 0!==s)throw ae({error:s,fileDescriptors:o,sourceOptions:u,startTime:a})})({sourceStream:t,sourceError:n,destinationStream:u,destinationError:a,fileDescriptors:l,sourceOptions:r,startTime:D});let d=new AbortController;try{var p,f,h,m;let e,n,o,a,b=(o=ao.has(u)?(p=t,f=u,(e=ao.get(f)).add(p),e):(h=t,m=u,n=uF([h]),uU(n,m),ao.set(m,n),n),rO(t,2,d.signal),rO(u,1,d.signal),an(u),o);return await Promise.race([ar(c),...(a={sourceStream:t,mergedStream:b,sourceOptions:r,fileDescriptors:l,startTime:D},void 0===s?[]:[ai(s,a)])])}finally{d.abort()}},as=(e,t)=>Promise.allSettled([e,t]),al=e=>e,aD=()=>void 0,ac=({contents:e})=>e,ad=e=>{throw Error(`Streams in object mode are not supported: ${String(e)}`)},ap=e=>e.length;async function af(e,t){return nH(e,ah,t)}let ah={init:()=>({contents:[]}),convertChunk:{string:al,buffer:al,arrayBuffer:al,dataView:al,typedArray:al,others:al},getSize:()=>1,truncateChunk:aD,addChunk:(e,{contents:t})=>(t.push(e),t),getFinalChunk:aD,finalize:ac};async function am(e,t){return nH(e,aC,t)}let ab=new TextEncoder,ay=e=>new Uint8Array(e),ag=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),aF=e=>aE**Math.ceil(Math.log(e)/Math.log(aE)),aE=2,aC={init:()=>({contents:new ArrayBuffer(0)}),convertChunk:{string:e=>ab.encode(e),buffer:ay,arrayBuffer:ay,dataView:ag,typedArray:ag,others:ad},getSize:ap,truncateChunk:(e,t)=>e.slice(0,t),addChunk:(e,{contents:t,length:r},n)=>{let o="resize"in ArrayBuffer.prototype?((e,t)=>{if(t<=e.maxByteLength)return e.resize(t),e;let r=new ArrayBuffer(t,{maxByteLength:aF(t)});return new Uint8Array(r).set(new Uint8Array(e),0),r})(t,n):((e,t)=>{if(t<=e.byteLength)return e;let r=new ArrayBuffer(aF(t));return new Uint8Array(r).set(new Uint8Array(e),0),r})(t,n);return new Uint8Array(o).set(e,r),o},getFinalChunk:aD,finalize:({contents:e,length:t})=>"resize"in ArrayBuffer.prototype?e:e.slice(0,t)};async function aw(e,t){return nH(e,av,t)}let a_=(e,{textDecoder:t})=>t.decode(e,{stream:!0}),av={init:()=>({contents:"",textDecoder:new TextDecoder}),convertChunk:{string:al,buffer:a_,arrayBuffer:a_,dataView:a_,typedArray:a_,others:ad},getSize:ap,truncateChunk:(e,t)=>e.slice(0,t),addChunk:(e,{contents:t})=>t+e,getFinalChunk:({textDecoder:e})=>{let t=e.decode();return""===t?void 0:t},finalize:ac},aS=({subprocessStdout:e,subprocess:t,binary:r,shouldEncode:n,encoding:o,preserveNewlines:u})=>{let a=new AbortController;return aB(t,a),aR({stream:e,controller:a,binary:r,shouldEncode:!e.readableObjectMode&&n,encoding:o,shouldSplit:!e.readableObjectMode,preserveNewlines:u})},aB=async(e,t)=>{try{await e}catch{}finally{t.abort()}},aT=({stream:e,onStreamEnd:t,lines:r,encoding:n,stripFinalNewline:o,allMixed:u})=>{let a=new AbortController;aA(t,a,e);let s=e.readableObjectMode&&!u;return aR({stream:e,controller:a,binary:"buffer"===n,shouldEncode:!s,encoding:n,shouldSplit:!s&&r,preserveNewlines:!o})},aA=async(e,t,r)=>{try{await e}catch{r.destroy()}finally{t.abort()}},aR=({stream:e,controller:t,binary:r,shouldEncode:n,encoding:o,shouldSplit:u,preserveNewlines:a})=>a$({onStdoutChunk:G(e,"data",{signal:t.signal,highWaterMark:aP,highWatermark:aP}),controller:t,binary:r,shouldEncode:n,encoding:o,shouldSplit:u,preserveNewlines:a}),ax=eD(!0),aP=ax,a$=async function*({onStdoutChunk:e,controller:t,binary:r,shouldEncode:n,encoding:o,shouldSplit:u,preserveNewlines:a}){let s=aO({binary:r,shouldEncode:n,encoding:o,shouldSplit:u,preserveNewlines:a});try{for await(let[t]of e)yield*iP(t,s,0)}catch(e){if(!t.signal.aborted)throw e}finally{yield*i$(s)}},aO=({binary:e,shouldEncode:t,encoding:r,shouldSplit:n,preserveNewlines:o})=>[iF(e,r,!t),io(e,o,!n,{})].filter(Boolean),ak=async({stream:e,onStreamEnd:t,fdNumber:r,encoding:n,buffer:o,maxBuffer:u,lines:a,allMixed:s,stripFinalNewline:l,verboseInfo:D,streamInfo:c})=>{let d=aj({stream:e,onStreamEnd:t,fdNumber:r,encoding:n,allMixed:s,verboseInfo:D,streamInfo:c});if(!o)return void await Promise.all([aI(e),d]);let p=aT({stream:e,onStreamEnd:t,lines:a,encoding:n,stripFinalNewline:ir(l,r),allMixed:s}),[f]=await Promise.all([aL({stream:e,iterable:p,fdNumber:r,encoding:n,maxBuffer:u,lines:a}),d]);return f},aj=async({stream:e,onStreamEnd:t,fdNumber:r,encoding:n,allMixed:o,verboseInfo:u,streamInfo:{fileDescriptors:a}})=>{if(!iW({stdioItems:a[r]?.stdioItems,encoding:n,verboseInfo:u,fdNumber:r}))return;let s=aT({stream:e,onStreamEnd:t,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:o});await iH(s,e,r,u)},aI=async e=>{await M(),null===e.readableFlowing&&e.resume()},aL=async({stream:e,stream:{readableObjectMode:t},iterable:r,fdNumber:n,encoding:o,maxBuffer:u,lines:a})=>{try{if(t||a)return await af(r,{maxBuffer:u});if("buffer"===o)return new Uint8Array(await am(r,{maxBuffer:u}));return await aw(r,{maxBuffer:u})}catch(r){return aU((({error:e,stream:t,readableObjectMode:r,lines:n,encoding:o,fdNumber:u})=>{let a,s,l;if(!(e instanceof nQ))throw e;if("all"===u)return e;throw e.maxBufferInfo={fdNumber:u,unit:(a=r,s=n,l=o,a?"objects":s?"lines":"buffer"===l?"bytes":"characters")},t.destroy(),e})({error:r,stream:e,readableObjectMode:t,lines:a,encoding:o,fdNumber:n}))}},aM=async e=>{try{return await e}catch(e){return aU(e)}},aU=({bufferedData:e})=>"[object ArrayBuffer]"===eM.call(e)?new Uint8Array(e):e,aN=async(e,t,r,{isSameDirection:n,stopOnExit:o=!1}={})=>{let u=aW(e,r),a=new AbortController;try{await Promise.race([...o?[r.exitPromise]:[],ep(e,{cleanup:!0,signal:a.signal})])}catch(e){u.stdinCleanedUp||aH(e,t,r,n)}finally{a.abort()}},aW=(e,{originalStreams:[t],subprocess:r})=>{let n={stdinCleanedUp:!1};return e===t&&aq(e,r,n),n},aq=(e,t,r)=>{let{_destroy:n}=e;e._destroy=(...o)=>{az(t,r),n.call(e,...o)}},az=({exitCode:e,signalCode:t},r)=>{(null!==e||null!==t)&&(r.stdinCleanedUp=!0)},aH=(e,t,r,n)=>{if(!aG(e,t,r,n))throw e},aG=(e,t,r,n=!0)=>r.propagating?aY(e)||aK(e):(r.propagating=!0,aV(r,t)===n?aY(e):aK(e)),aV=({fileDescriptors:e},t)=>"all"!==t&&"input"===e[t].direction,aK=e=>e?.code==="ERR_STREAM_PREMATURE_CLOSE",aY=e=>e?.code==="EPIPE",aJ=async({stream:e,fdNumber:t,encoding:r,buffer:n,maxBuffer:o,lines:u,allMixed:a,stripFinalNewline:s,verboseInfo:l,streamInfo:D})=>{if(!e)return;let c=aN(e,t,D);if(aV(D,t))return void await c;let[d]=await Promise.all([ak({stream:e,onStreamEnd:c,fdNumber:t,encoding:r,buffer:n,maxBuffer:o,lines:u,allMixed:a,stripFinalNewline:s,verboseInfo:l,streamInfo:D}),c]);return d},aQ=(e,t)=>{tI({type:"ipc",verboseMessage:tN(e),fdNumber:"ipc",verboseInfo:t})},aX=async({subprocess:e,buffer:t,maxBuffer:r,ipc:n,ipcOutput:o,verboseInfo:u})=>{if(!n)return o;let a=ts(u,"ipc"),s=ta(t,"ipc"),l=ta(r,"ipc");for await(let t of uu({anyProcess:e,channel:e.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))s&&(nX(e,o,l),o.push(t)),a&&aQ(t,u);return o},aZ=async(e,t)=>(await Promise.allSettled([e]),t),a0=async({subprocess:e,options:{encoding:t,buffer:r,maxBuffer:n,lines:o,timeoutDuration:u,cancelSignal:a,gracefulCancel:s,forceKillAfterDelay:l,stripFinalNewline:D,ipc:c,ipcInput:d},context:p,verboseInfo:f,fileDescriptors:h,originalStreams:m,onInternalError:b,controller:y})=>{let g=iX(e,p),F={originalStreams:m,fileDescriptors:h,subprocess:e,exitPromise:g,propagating:!1},E=(({subprocess:e,encoding:t,buffer:r,maxBuffer:n,lines:o,stripFinalNewline:u,verboseInfo:a,streamInfo:s})=>e.stdio.map((e,l)=>aJ({stream:e,fdNumber:l,encoding:t,buffer:r[l],maxBuffer:n[l],lines:o[l],allMixed:!1,stripFinalNewline:u,verboseInfo:a,streamInfo:s})))({subprocess:e,encoding:t,buffer:r,maxBuffer:n,lines:o,stripFinalNewline:D,verboseInfo:f,streamInfo:F}),C=(({subprocess:e,encoding:t,buffer:r,maxBuffer:n,lines:o,stripFinalNewline:u,verboseInfo:a,streamInfo:s})=>aJ({...(({stdout:e,stderr:t,all:r},[,n,o])=>{let u=n||o;return u?n?o?{stream:r,buffer:u}:{stream:e,buffer:u}:{stream:t,buffer:u}:{stream:r,buffer:u}})(e,r),fdNumber:"all",encoding:t,maxBuffer:n[1]+n[2],lines:o[1]||o[2],allMixed:(({all:e,stdout:t,stderr:r})=>e&&t&&r&&t.readableObjectMode!==r.readableObjectMode)(e),stripFinalNewline:u,verboseInfo:a,streamInfo:s}))({subprocess:e,encoding:t,buffer:r,maxBuffer:n,lines:o,stripFinalNewline:D,verboseInfo:f,streamInfo:F}),w=[],_=aX({subprocess:e,buffer:r,maxBuffer:n,ipc:c,ipcOutput:w,verboseInfo:f}),v=a2(m,e,F),S=a1(h,F);try{return await Promise.race([Promise.all([{},i2(g),Promise.all(E),C,_,nc(e,d),...v,...S]),b,a8(e,y),...0===u||void 0===u?[]:[nl(e,u,p,y)],...(({subprocess:e,cancelSignal:t,gracefulCancel:r,context:n,controller:o})=>void 0===t||r?[]:[rc(e,t,n,o)])({subprocess:e,cancelSignal:a,gracefulCancel:s,context:p,controller:y}),...(({subprocess:e,cancelSignal:t,gracefulCancel:r,forceKillAfterDelay:n,context:o,controller:u})=>r?[na({subprocess:e,cancelSignal:t,forceKillAfterDelay:n,context:o,controller:u})]:[])({subprocess:e,cancelSignal:a,gracefulCancel:s,forceKillAfterDelay:l,context:p,controller:y})])}catch(e){return p.terminationReason??="other",Promise.all([{error:e},g,Promise.all(E.map(e=>aM(e))),aM(C),aZ(_,w),Promise.allSettled(v),Promise.allSettled(S)])}},a2=(e,t,r)=>e.map((e,n)=>e===t.stdio[n]?void 0:aN(e,n,r)),a1=(e,t)=>e.flatMap(({stdioItems:e},r)=>e.filter(({value:e,stream:t=e})=>nR(t,{checkOpen:!1})&&!e2(t)).map(({type:e,value:n,stream:o=n})=>aN(o,r,t,{isSameDirection:ob.has(e),stopOnExit:"native"===e}))),a8=async(e,{signal:t})=>{let[r]=await V(e,"error",{signal:t});throw r},a3=(e,t,r)=>{let n=e[r];n.has(t)||n.set(t,[]);let o=n.get(t),u=rC();return o.push(u),{resolve:u.resolve.bind(u),promises:o}},a6=async({resolve:e,promises:t},r)=>{e();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...t])]);return!n},a9=async e=>{if(void 0!==e)try{await a4(e)}catch{}},a7=async e=>{if(void 0!==e)try{await a5(e)}catch{}},a4=async e=>{await ep(e,{cleanup:!0,readable:!1,writable:!0})},a5=async e=>{await ep(e,{cleanup:!0,readable:!0,writable:!1})},se=async(e,t)=>{if(await e,t)throw t},st=(e,t,r)=>{r&&!aK(r)?e.destroy(r):t&&e.destroy()},sr=({subprocess:e,concurrentStreams:t,encoding:r},{from:n,binary:o=!0,preserveNewlines:u=!0}={})=>{let a=o||np.has(r),{subprocessStdout:s,waitReadableDestroy:l}=sn(e,n,t),{readableEncoding:D,readableObjectMode:c,readableHighWaterMark:d}=so(s,a),{read:p,onStdoutDataDone:f}=si({subprocessStdout:s,subprocess:e,binary:a,encoding:r,preserveNewlines:u}),h=new ea({read:p,destroy:w(ss.bind(void 0,{subprocessStdout:s,subprocess:e,waitReadableDestroy:l})),highWaterMark:d,objectMode:c,encoding:D});return sa({subprocessStdout:s,onStdoutDataDone:f,readable:h,subprocess:e}),h},sn=(e,t,r)=>{let n=r_(e,t),o=a3(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:o}},so=({readableEncoding:e,readableObjectMode:t,readableHighWaterMark:r},n)=>n?{readableEncoding:e,readableObjectMode:t,readableHighWaterMark:r}:{readableEncoding:e,readableObjectMode:!0,readableHighWaterMark:ax},si=({subprocessStdout:e,subprocess:t,binary:r,encoding:n,preserveNewlines:o})=>{let u=rC(),a=aS({subprocessStdout:e,subprocess:t,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:o});return{read(){su(this,a,u)},onStdoutDataDone:u}},su=async(e,t,r)=>{try{let{value:n,done:o}=await t.next();o?r.resolve():e.push(n)}catch{}},sa=async({subprocessStdout:e,onStdoutDataDone:t,readable:r,subprocess:n,subprocessStdin:o})=>{try{await a5(e),await n,await a9(o),await t,r.readable&&r.push(null)}catch(e){await a9(o),sl(r,e)}},ss=async({subprocessStdout:e,subprocess:t,waitReadableDestroy:r},n)=>{await a6(r,t)&&(sl(e,n),await se(t,n))},sl=(e,t)=>{st(e,e.readable,t)},sD=({subprocess:e,concurrentStreams:t},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:o,waitWritableDestroy:u}=sc(e,r,t),a=new el({...sd(n,e,o),destroy:w(sm.bind(void 0,{subprocessStdin:n,subprocess:e,waitWritableFinal:o,waitWritableDestroy:u})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return sh(n,a),a},sc=(e,t,r)=>{let n=rw(e,t),o=a3(r,n,"writableFinal"),u=a3(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:o,waitWritableDestroy:u}},sd=(e,t,r)=>({write:sp.bind(void 0,e),final:w(sf.bind(void 0,e,t,r))}),sp=(e,t,r,n)=>{e.write(t,r)?n():e.once("drain",n)},sf=async(e,t,r)=>{await a6(r,t)&&(e.writable&&e.end(),await t)},sh=async(e,t,r)=>{try{await a4(e),t.writable&&t.end()}catch(e){await a7(r),sb(t,e)}},sm=async({subprocessStdin:e,subprocess:t,waitWritableFinal:r,waitWritableDestroy:n},o)=>{await a6(r,t),await a6(n,t)&&(sb(e,o),await se(t,o))},sb=(e,t)=>{st(e,e.writable,t)},sy=({subprocess:e,concurrentStreams:t,encoding:r},{from:n,to:o,binary:u=!0,preserveNewlines:a=!0}={})=>{let s=u||np.has(r),{subprocessStdout:l,waitReadableDestroy:D}=sn(e,n,t),{subprocessStdin:c,waitWritableFinal:d,waitWritableDestroy:p}=sc(e,o,t),{readableEncoding:f,readableObjectMode:h,readableHighWaterMark:m}=so(l,s),{read:b,onStdoutDataDone:y}=si({subprocessStdout:l,subprocess:e,binary:s,encoding:r,preserveNewlines:a}),g=new ei({read:b,...sd(c,e,d),destroy:w(sg.bind(void 0,{subprocessStdout:l,subprocessStdin:c,subprocess:e,waitReadableDestroy:D,waitWritableFinal:d,waitWritableDestroy:p})),readableHighWaterMark:m,writableHighWaterMark:c.writableHighWaterMark,readableObjectMode:h,writableObjectMode:c.writableObjectMode,encoding:f});return sa({subprocessStdout:l,onStdoutDataDone:y,readable:g,subprocess:e,subprocessStdin:c}),sh(c,g,l),g},sg=async({subprocessStdout:e,subprocessStdin:t,subprocess:r,waitReadableDestroy:n,waitWritableFinal:o,waitWritableDestroy:u},a)=>{await Promise.all([ss({subprocessStdout:e,subprocess:r,waitReadableDestroy:n},a),sm({subprocessStdin:t,subprocess:r,waitWritableFinal:o,waitWritableDestroy:u},a)])},sF=(e,t,{from:r,binary:n=!1,preserveNewlines:o=!1}={})=>{let u=n||np.has(t),a=r_(e,r);return sE(aS({subprocessStdout:a,subprocess:e,binary:u,shouldEncode:!0,encoding:t,preserveNewlines:o}),a,e)},sE=async function*(e,t,r){try{yield*e}finally{t.readable&&t.destroy(),await r}},sC=(async()=>{})().constructor.prototype,sw=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(sC,e)]),s_=({timeout:e,signal:t,...r})=>{if(void 0!==t)throw TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:e}},sv=async({subprocess:e,options:t,startTime:r,verboseInfo:n,fileDescriptors:o,originalStreams:u,command:a,escapedCommand:s,context:l,onInternalError:D,controller:c})=>{let[d,[p,f],h,m,b]=await a0({subprocess:e,options:t,context:l,verboseInfo:n,fileDescriptors:o,originalStreams:u,onInternalError:D,controller:c});c.abort(),D.resolve();let y=sS({errorInfo:d,exitCode:p,signal:f,stdio:h.map((e,r)=>it(e,t,r)),all:it(m,t,"all"),ipcOutput:b,context:l,options:t,command:a,escapedCommand:s,startTime:r});return n5(y,n,t)},sS=({errorInfo:e,exitCode:t,signal:r,stdio:n,all:o,ipcOutput:u,context:a,options:s,command:l,escapedCommand:D,startTime:c})=>"error"in e?n8({error:e.error,command:l,escapedCommand:D,timedOut:"timeout"===a.terminationReason,isCanceled:"cancel"===a.terminationReason||"gracefulCancel"===a.terminationReason,isGracefullyCanceled:"gracefulCancel"===a.terminationReason,isMaxBuffer:e.error instanceof nQ,isForcefullyTerminated:a.isForcefullyTerminated,exitCode:t,signal:r,stdio:n,all:o,ipcOutput:u,options:s,startTime:c,isSync:!1}):n2({command:l,escapedCommand:D,stdio:n,all:o,ipcOutput:u,options:s,startTime:c}),sB=(e,t)=>{let r=Object.fromEntries(Object.entries(t).map(([t,r])=>[t,sT(t,e[t],r)]));return{...e,...r}},sT=(e,t,r)=>sA.has(e)&&e$(t)&&e$(r)?{...t,...r}:r,sA=new Set(["env",...tu]),sR=(e,t,r,n)=>{let o=(e,t,n)=>sR(e,t,r,n),u=(...u)=>sx({mapArguments:e,deepOptions:r,boundOptions:t,setBoundExeca:n,createNested:o},...u);return void 0!==n&&n(u,o,t),u},sx=({mapArguments:e,deepOptions:t={},boundOptions:r={},setBoundExeca:n,createNested:o},u,...a)=>{if(e$(u))return o(e,sB(r,u),n);let{file:s,commandArguments:l,options:D,isSync:c}=sP({mapArguments:e,firstArgument:u,nextArguments:a,deepOptions:t,boundOptions:r});return c?((e,t,r)=>{let{file:n,commandArguments:o,command:u,escapedCommand:a,startTime:s,verboseInfo:l,options:D,fileDescriptors:c}=((e,t,r)=>{let{command:n,escapedCommand:o,startTime:u,verboseInfo:a}=tH(e,t,r),{file:s,commandArguments:l,options:D}=ng(e,t,i3(r));i6(D);let c=oV(ie,D,a,!0);return{file:s,commandArguments:l,command:n,escapedCommand:o,startTime:u,verboseInfo:a,options:D,fileDescriptors:c}})(e,t,r);return n5((({file:e,commandArguments:t,options:r,command:n,escapedCommand:o,verboseInfo:u,fileDescriptors:a,startTime:s})=>{let l=i7({file:e,commandArguments:t,options:r,command:n,escapedCommand:o,fileDescriptors:a,startTime:s});if(l.failed)return l;let{resultError:D,exitCode:c,signal:d,timedOut:p,isMaxBuffer:f}=(({error:e,status:t,signal:r,output:n},{maxBuffer:o})=>{let u,a,s,l=(u=e,a=t,s=r,void 0!==u?u:i8(a,s)?new tK:void 0),D=l?.code==="ETIMEDOUT",c=l?.code==="ENOBUFS"&&null!==n&&n.some(e=>null!==e&&e.length>(([,e])=>e)(o));return{resultError:l,exitCode:t,signal:r,timedOut:D,isMaxBuffer:c}})(l,r),{output:h,error:m=D}=(({fileDescriptors:e,syncResult:{output:t},options:r,isMaxBuffer:n,verboseInfo:o})=>{if(null===t)return{output:Array.from({length:3})};let u={},a=new Set([]);return{output:t.map((t,s)=>(({result:e,fileDescriptors:t,fdNumber:r,state:n,outputFiles:o,isMaxBuffer:u,verboseInfo:a},{buffer:s,encoding:l,lines:D,stripFinalNewline:c,maxBuffer:d})=>{if(null===e)return;let p=eN(((e,t,r)=>{if(!t)return e;let n=(([,e])=>e)(r);return e.length>n?e.slice(0,n):e})(e,u,d)),{stdioItems:f,objectMode:h}=t[r],{serializedResult:m,finalResult:b=m}=iY({chunks:iK([p],f,l,n),objectMode:h,encoding:l,lines:D,stripFinalNewline:c,fdNumber:r});iJ({serializedResult:m,fdNumber:r,state:n,verboseInfo:a,encoding:l,stdioItems:f,objectMode:h});let y=s[r]?b:void 0;try{return void 0===n.error&&iQ(m,f,o),y}catch(e){return n.error=e,y}})({result:t,fileDescriptors:e,fdNumber:s,state:u,outputFiles:a,isMaxBuffer:n,verboseInfo:o},r)),...u}})({fileDescriptors:a,syncResult:l,options:r,isMaxBuffer:f,verboseInfo:u});return i5({error:m,exitCode:c,signal:d,timedOut:p,isMaxBuffer:f,stdio:h.map((e,t)=>it(e,r,t)),all:it((([,e,t],r)=>{if(r.all)return void 0===e?t:void 0===t?e:Array.isArray(e)?Array.isArray(t)?[...e,...t]:[...e,it(t,r,"all")]:Array.isArray(t)?[it(e,r,"all"),...t]:eU(e)&&eU(t)?eG([e,t]):`${e}${t}`})(h,r),r,"all"),options:r,command:n,escapedCommand:o,startTime:s})})({file:n,commandArguments:o,options:D,command:u,escapedCommand:a,verboseInfo:l,fileDescriptors:c,startTime:s}),l,D)})(s,l,D):((e,t,r,n)=>{let{file:o,commandArguments:u,command:a,escapedCommand:s,startTime:l,verboseInfo:D,options:c,fileDescriptors:d}=((e,t,r)=>{let{command:n,escapedCommand:o,startTime:u,verboseInfo:a}=tH(e,t,r),{file:s,commandArguments:l,options:D}=ng(e,t,r),c=s_(D),d=oV(ug,c,a,!1);return{file:s,commandArguments:l,command:n,escapedCommand:o,startTime:u,verboseInfo:a,options:c,fileDescriptors:d}})(e,t,r),{subprocess:p,promise:f}=(({file:e,commandArguments:t,options:r,startTime:n,verboseInfo:o,command:u,escapedCommand:a,fileDescriptors:s})=>{let l;try{l=g(...nC(e,t,r))}catch(e){return(({error:e,command:t,escapedCommand:r,fileDescriptors:n,options:o,startTime:u,verboseInfo:a})=>{var s,l;let D,c,d,p,f,h;o6(n);let m=new b;return s=m,l=n,D=ud(),c=ud(),d=ud(),p=Array.from({length:l.length-3},ud),f=ud(),h=[D,c,d,...p],Object.assign(s,{stdin:D,stdout:c,stderr:d,all:f,stdio:h}),Object.assign(m,{readable:up,writable:uf,duplex:uh}),{subprocess:m,promise:um(n1({error:e,command:t,escapedCommand:r,fileDescriptors:n,options:o,startTime:u,isSync:!1}),a,o)}})({error:e,command:u,escapedCommand:a,fileDescriptors:s,options:r,startTime:n,verboseInfo:o})}let D=new AbortController;K(1/0,D.signal);let c=[...l.stdio];var d=l;let p=new Map;for(let[e,{stdioItems:t,direction:r}]of Object.entries(s)){for(let{stream:n}of t.filter(({type:e})=>ob.has(e)))uH(d,n,r,e);for(let{stream:n}of t.filter(({type:e})=>!ob.has(e)))uV({subprocess:d,stream:n,direction:r,fdNumber:e,pipeGroups:p,controller:D})}for(let[e,t]of p.entries())uU(1===t.length?t[0]:uF(t),e);((e,{cleanup:t,detached:r},{signal:n})=>{if(!t||r)return;let o=u6(()=>{e.kill()});H(n,()=>{o()})})(l,r,D);let f={},h=rC();l.kill=ri.bind(void 0,{kill:l.kill.bind(l),options:r,onInternalError:h,context:f,controller:D}),l.all=(({stdout:e,stderr:t},{all:r})=>r&&(e||t)?uF([e,t].filter(Boolean)):void 0)(l,r),((e,{encoding:t})=>{let r={readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap};e.readable=sr.bind(void 0,{subprocess:e,concurrentStreams:r,encoding:t}),e.writable=sD.bind(void 0,{subprocess:e,concurrentStreams:r}),e.duplex=sy.bind(void 0,{subprocess:e,concurrentStreams:r,encoding:t}),e.iterable=sF.bind(void 0,e,t),e[Symbol.asyncIterator]=sF.bind(void 0,e,t,{})})(l,r),((e,{ipc:t})=>{Object.assign(e,uc(e,!1,t))})(l,r);let m=sv({subprocess:l,options:r,startTime:n,verboseInfo:o,fileDescriptors:s,originalStreams:c,command:u,escapedCommand:a,context:f,onInternalError:h,controller:D});return{subprocess:l,promise:m}})({file:o,commandArguments:u,options:c,startTime:l,verboseInfo:D,command:a,escapedCommand:s,fileDescriptors:d});p.pipe=au.bind(void 0,{source:p,sourcePromise:f,boundOptions:{},createNested:n});for(let[e,t]of sw){let r=t.value.bind(f);Reflect.defineProperty(p,e,{...t,value:r})}return rv.set(p,{options:c,fileDescriptors:d}),p})(s,l,D,o)},sP=({mapArguments:e,firstArgument:t,nextArguments:r,deepOptions:n,boundOptions:o})=>{let[u,a,s]=eL(...Array.isArray(t)&&Array.isArray(t.raw)?((e,t)=>{let r=[];for(let[n,o]of e.entries())r=eK({templates:e,expressions:t,tokens:r,index:n,template:o});if(0===r.length)throw TypeError("Template script must not be empty");let[n,...o]=r;return[n,o,{}]})(t,r):[t,...r]),l=sB(sB(n,o),s),{file:D=u,commandArguments:c=a,options:d=l,isSync:p=!1}=e({file:u,commandArguments:a,options:l});return{file:D,commandArguments:c,options:d,isSync:p}},s$=(e,t)=>{if(t.length>0)throw TypeError(`The command and its arguments must be passed as a single string: ${e} ${t}.`);let[r,...n]=sO(e);return{file:r,commandArguments:n}},sO=e=>{if("string"!=typeof e)throw TypeError(`The command must be a string: ${String(e)}.`);let t=e.trim();if(""===t)return[];let r=[];for(let e of t.split(sk)){let t=r.at(-1);t&&t.endsWith("\\")?r[r.length-1]=`${t.slice(0,-1)} ${e}`:r.push(e)}return r},sk=/ +/g,sj=({options:e})=>({...sI(e),isSync:!0}),sI=e=>({options:{...sL(e),...e}}),sL=({input:e,inputFile:t,stdio:r})=>void 0===e&&void 0===t&&void 0===r?{stdin:"inherit"}:{},sM=sR(()=>({}));sR(()=>({isSync:!0})),sR(({file:e,commandArguments:t})=>s$(e,t)),sR(({file:e,commandArguments:t})=>({...s$(e,t),isSync:!0})),sR(({options:e})=>{if(!1===e.node)throw TypeError('The "node" option cannot be false with `execaNode()`.');return{options:{...e,node:!0}}}),sR(({options:e})=>sI(e),{},{preferLocal:!0},(e,t,r)=>{e.sync=t(sj,r),e.s=e.sync});let{sendMessage:sU,getOneMessage:sN,getEachMessage:sW,getCancelSignal:sq}=(n=void 0!==R.channel,{...uc(R,!0,n),getCancelSignal:ne.bind(void 0,{anyProcess:R,channel:R.channel,isSubprocess:!0,ipc:n})});var sz,sH,sG,sV,sK,sY=JSON.parse('{"UU":"@doubao-dev/cli","rE":"1.0.0-rc.12","h_":"Doubao Plugins CLI"}');let sJ={name:sY.UU,version:sY.rE,description:sY.h_,registry:"https://registry.npmjs.org",appDev:{name:"@doubao-dev/plugin-app-dev",version:sY.rE},kit:{name:"@doubao-dev/kit",version:process.env.DBX_KIT_VERSION?.trim()||"0.10.0",lockCdn:{version:"0.10.0",url:"https://lf3-static.bytednsdoc.com/obj/eden-cn/rkz-zwwh-vhibvk/ljhwZthlaukjlkulzlp/kit-locks/public/0.10.0/091c4691ab009d55ae4930e0bd6c000079ea49fe0d388ee52a2d7afc03c8a7aa/package-lock.json",sha256:"091c4691ab009d55ae4930e0bd6c000079ea49fe0d388ee52a2d7afc03c8a7aa"}??void 0},auth:{baseUrl:"https://open.doubao.com",verificationUrl:"https://open.doubao.com/apps-plugin/oauth/device"},apiUrl:"https://open.doubao.com",apiHeaders:{"User-Agent":`doubao-dev-cli-${sY.rE}`},deviceApiUrl:"https://developer.doubao.com",consoleUrl:"https://open.doubao.com/console/plugins/"},sQ=l.join(N.homedir(),".dbx","token"),sX=l.join(N.homedir(),".doubao","token"),sZ={};function s0(e={}){let t={...sZ,...e},r=s1(t.baseUrl??"https://developer.doubao.com","baseUrl"),n=t.tokenPath??sQ;return{...t,baseUrl:r,verificationUrl:s1(t.verificationUrl??new URL("/oauth/device",r).href,"verificationUrl"),allowedOrigins:function(e,t){let r=new Set([new URL(t).origin]);for(let t of e??[]){let e;try{e=new URL(t)}catch{throw Error(`allowedOrigins 中的来源必须是完整的 HTTPS 地址:${t}`)}if("https:"!==e.protocol)throw Error(`allowedOrigins 中的来源必须使用 HTTPS:${t}`);r.add(e.origin)}return[...r]}(t.allowedOrigins,r),tokenPath:n,legacyTokenPath:t.tokenPath?void 0:sX,requestHeaders:new Headers(t.requestHeaders)}}function s2(e){return e.replace(/\/+$/,"")}function s1(e,t){let r;try{r=new URL(s2(e))}catch{throw Error(`${t} 必须是完整的 HTTPS URL`)}if("https:"!==r.protocol)throw Error(`${t} 必须使用 HTTPS`);return s2(r.toString())}let s8=B(y),s3="byted-doubao-open-dbx-cli",s6="dbx-cli",s9="aes-256-gcm";class s7 extends Error{constructor(e){super(e),this.name="CredentialStoreError"}}class s4 extends s7{constructor(){super("无法读取本地登录凭证:用于解密凭证的密钥文件 master.key 已丢失。请运行 dbx auth login 重新登录。")}}class s5{constructor(e,t){this.primary=e,this.fallback=t}async get(e){let t;if(await this.isFallbackAuthoritative(e))return this.fallback.get(e);try{let t=await this.primary.get(e);if(t)return t}catch(e){t=e}try{let t=await this.fallback.get(e);if(t)return t}catch(e){if(t)throw new s7(`从系统凭证存储读取登录凭证失败(${lc(t)});从备用加密文件读取也失败:${lc(e)}`);throw e}if(t)throw t instanceof Error?t:new s7(`从系统凭证存储读取登录凭证失败:${String(t)}`)}async set(e,t){let r;try{await this.primary.set(e,t)}catch(e){r=e}try{await this.fallback.set(e,t)}catch(t){if(r)throw new s7(`向系统凭证存储写入登录凭证失败(${lc(r)}),写入备用加密文件也失败(${lc(t)})`);throw await this.removeStaleFallbackAfterPrimaryWrite(e,t),t}r?await this.markFallbackAuthoritative(e):await this.clearFallbackAuthority(e)}async delete(e){let t;try{await this.primary.delete(e)}catch(e){t=e}try{await this.fallback.delete(e)}catch(e){if(t)throw new s7(`从系统凭证存储删除登录凭证失败(${lc(t)}),从备用加密文件删除也失败(${lc(e)})`);throw e}t?await this.markFallbackAuthoritativeOrThrow(e,t):await this.clearFallbackAuthority(e)}async isFallbackAuthoritative(e){return!!li(this.fallback)&&this.fallback.isFallbackAuthoritative(e)}async markFallbackAuthoritative(e){li(this.fallback)&&await this.fallback.markFallbackAuthoritative(e)}async markFallbackAuthoritativeOrThrow(e,t){if(!li(this.fallback))throw t instanceof Error?t:new s7(`系统凭证删除失败,且备用存储无法记录删除状态:${String(t)}`);try{await this.fallback.markFallbackAuthoritative(e)}catch(e){throw new s7(`系统凭证删除失败(${lc(t)}),且无法记录备用凭证删除状态:${lc(e)}`)}}async clearFallbackAuthority(e){li(this.fallback)&&await this.fallback.clearFallbackAuthority(e)}async removeStaleFallbackAfterPrimaryWrite(e,t){let r=[];try{await this.fallback.delete(e)}catch(e){r.push(e)}try{await this.clearFallbackAuthority(e)}catch(e){r.push(e)}if(r.length>0)throw new s7(`系统凭证已写入,但备用加密文件写入失败(${lc(t)}),且清理旧备用凭证失败:${r.map(lc).join(";")}`)}}class le{constructor(e={}){this.baseDir=e.baseDir??("darwin"===process.platform?l.join(N.homedir(),"Library","Application Support",s6):"win32"===process.platform?l.join(process.env.APPDATA||l.join(N.homedir(),"AppData","Roaming"),s6):l.join(process.env.XDG_DATA_HOME||l.join(N.homedir(),".local","share"),s6))}async get(e){var t,r;let n,o,u=this.credentialFilePath(e);try{n=await ee.readFile(u,"utf8")}catch(e){if(lD(e)&&"ENOENT"===e.code)return;throw new s7(`读取加密凭证文件失败:${lc(e)}`)}try{o=JSON.parse(n)}catch(e){throw new s7(`加密凭证文件不是有效的 JSON:${lc(e)}`)}if(!((t=o)&&"object"==typeof t&&1===t.version&&t.algorithm===s9&&"string"==typeof t.iv&&"string"==typeof t.authTag&&"string"==typeof t.ciphertext))throw new s7("无法读取本地登录凭证:当前 CLI 不支持凭证文件中的格式或字段。");let a=await this.readMasterKey();try{let t=eh.createDecipheriv(s9,a,Buffer.from(o.iv,"base64url"));return t.setAAD(Buffer.from((r=e,`${s3}:${r}`),"utf8")),t.setAuthTag(Buffer.from(o.authTag,"base64url")),Buffer.concat([t.update(Buffer.from(o.ciphertext,"base64url")),t.final()]).toString("utf8")}catch(e){throw new s7(`解密凭证文件失败:${lc(e)}`)}}async set(e,t){var r;let n=await this.readOrCreateMasterKey(),o=eh.randomBytes(12),u=eh.createCipheriv(s9,n,o);u.setAAD(Buffer.from((r=e,`${s3}:${r}`),"utf8"));let a=Buffer.concat([u.update(t,"utf8"),u.final()]),s={version:1,algorithm:s9,iv:o.toString("base64url"),authTag:u.getAuthTag().toString("base64url"),ciphertext:a.toString("base64url")};await ln(this.credentialFilePath(e),`${JSON.stringify(s,null,2)}
29
+ if (condition) { yield value; }`)},iF=(e,t,r)=>{if(r)return;if(e)return{transform:iE.bind(void 0,new TextEncoder)};let n=new E(t);return{transform:iC.bind(void 0,n),final:iw.bind(void 0,n)}},iE=function*(e,t){ed.isBuffer(t)?yield eN(t):"string"==typeof t?yield e.encode(t):yield t},iC=function*(e,t){yield eU(t)?e.write(t):t},iw=function*(e){let t=e.end();""!==t&&(yield t)},i_=w(async(e,t,r,n)=>{t.currentIterable=e(...r);try{for await(let e of t.currentIterable)n.push(e)}finally{delete t.currentIterable}}),iv=async function*(e,t,r){if(r===t.length)return void(yield e);let{transform:n=iA}=t[r];for await(let o of n(e))yield*iv(o,t,r+1)},iS=async function*(e){for(let[t,{final:r}]of Object.entries(e))yield*iB(r,Number(t),e)},iB=async function*(e,t,r){if(void 0!==e)for await(let n of e())yield*iv(n,r,t+1)},iT=w(async({currentIterable:e},t)=>{if(void 0!==e)return void await (t?e.throw(t):e.return());if(t)throw t}),iA=function*(e){yield e},iR=(e,t,r,n)=>{try{for(let n of e(...t))r.push(n);n()}catch(e){n(e)}},ix=(e,t)=>[...t.flatMap(t=>[...iP(t,e,0)]),...i$(e)],iP=function*(e,t,r){if(r===t.length)return void(yield e);let{transform:n=ik}=t[r];for(let o of n(e))yield*iP(o,t,r+1)},i$=function*(e){for(let[t,{final:r}]of Object.entries(e))yield*iO(r,Number(t),e)},iO=function*(e,t,r){if(void 0!==e)for(let n of e())yield*iP(n,r,t+1)},ik=function*(e){yield e},ij=({value:e,value:{transform:t,final:r,writableObjectMode:n,readableObjectMode:o},optionName:u},{encoding:a})=>{let s={},l=iL(e,a,u),D=oa(t),c=oa(r),d=D?i_.bind(void 0,iv,s):iR.bind(void 0,iP),p=D||c?i_.bind(void 0,iS,s):iR.bind(void 0,i$),f=D||c?iT.bind(void 0,s):void 0;return{stream:new es({writableObjectMode:n,writableHighWaterMark:eD(n),readableObjectMode:o,readableHighWaterMark:eD(o),transform(e,t,r){d([e,l,0],this,r)},flush(e){p([l],this,e)},destroy:f})}},iI=(e,t,r,n)=>{let o=t.filter(({type:e})=>"generator"===e);for(let{value:t,optionName:u}of n?o.reverse():o)e=ix(iL(t,r,u),e);return e},iL=({transform:e,final:t,binary:r,writableObjectMode:n,readableObjectMode:o,preserveNewlines:u},a,s)=>{let l={};return[{transform:n?void 0:im.bind(void 0,s)},iF(r,a,n),io(r,u,n,l),{transform:e,final:t},{transform:o?ib.bind(void 0,s):iy.bind(void 0,s)},(({binary:e,preserveNewlines:t,readableObjectMode:r,state:n})=>e||t||r?void 0:{transform:ic.bind(void 0,n)})({binary:r,preserveNewlines:u,readableObjectMode:o,state:l})].filter(Boolean)},iM=(e,t,r)=>{let{stdioItems:n}=e[t],o=n.filter(({contents:e})=>void 0!==e);if(0!==o.length){if(0!==t){let[{type:e,optionName:t}]=o;throw TypeError(`Only the \`stdin\` option, not \`${t}\`, can be ${oC[e]} with synchronous methods.`)}r.input=ez(o.map(({contents:e})=>e).map(e=>iU(e,n)))}},iU=(e,t)=>{let r=iI(e,t,"utf8",!0);return iN(r),ez(r)},iN=e=>{let t=e.find(e=>"string"!=typeof e&&!eU(e));if(void 0!==t)throw TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${t}.`)},iW=({stdioItems:e,encoding:t,verboseInfo:r,fdNumber:n})=>"all"!==n&&ts(r,n)&&!np.has(t)&&iq(n)&&(e.some(({type:e,value:t})=>"native"===e&&iz.has(t))||e.every(({type:e})=>ob.has(e))),iq=e=>1===e||2===e,iz=new Set(["pipe","overlapped"]),iH=async(e,t,r,n)=>{for await(let o of e)iG(t)||iV(o,r,n)},iG=e=>e._readableState.pipes.length>0,iV=(e,t,r)=>{tI({type:"output",verboseMessage:tN(e),fdNumber:t,verboseInfo:r})},iK=(e,t,r,n)=>{try{return iI(e,t,r,!1)}catch(t){return n.error=t,e}},iY=({chunks:e,objectMode:t,encoding:r,lines:n,stripFinalNewline:o,fdNumber:u})=>{if(t)return{serializedResult:e};if("buffer"===r)return{serializedResult:ez(e)};let a=((e,t)=>{if("utf8"===t&&e.every(e=>"string"==typeof e))return e;let r=new E(t),n=e.map(e=>"string"==typeof e?eW.encode(e):e).map(e=>r.write(e)),o=r.end();return""===o?n:[...n,o]})(e,r).join("");return n[u]?{serializedResult:a,finalResult:ii(a,!o[u],t)}:{serializedResult:a}},iJ=({serializedResult:e,fdNumber:t,state:r,verboseInfo:n,encoding:o,stdioItems:u,objectMode:a})=>{if(!iW({stdioItems:u,encoding:o,verboseInfo:n,fdNumber:t}))return;let s=ii(e,!1,a);try{for(let e of s)iV(e,t,n)}catch(e){r.error??=e}},iQ=(e,t,r)=>{for(let{path:n,append:o}of t.filter(({type:e})=>oy.has(e))){let t="string"==typeof n?n:n.toString();o||r.has(t)?Q(n,e):(r.add(t),en(n,e))}},iX=async(e,t)=>{let[r,n]=await iZ(e);return t.isForcefullyTerminated??=!1,[r,n]},iZ=async e=>{let[t,r]=await Promise.allSettled([V(e,"spawn"),V(e,"exit")]);return"rejected"===t.status?[]:"rejected"===r.status?i0(e):r.value},i0=async e=>{try{return await V(e,"exit")}catch{return i0(e)}},i2=async e=>{let[t,r]=await e;if(!i1(t,r)&&i8(t,r))throw new tK;return[t,r]},i1=(e,t)=>void 0===e&&void 0===t,i8=(e,t)=>0!==e||null!==t,i3=e=>e.node&&!e.ipc?{...e,ipc:!1}:e,i6=({ipc:e,ipcInput:t,detached:r,cancelSignal:n})=>{t&&i9("ipcInput"),e&&i9("ipc: true"),r&&i9("detached: true"),n&&i9("cancelSignal")},i9=e=>{throw TypeError(`The "${e}" option cannot be used with synchronous methods.`)},i7=({file:e,commandArguments:t,options:r,command:n,escapedCommand:o,fileDescriptors:u,startTime:a})=>{try{let n;for(let e of(n=u,new Set(Object.entries(n).filter(([,{direction:e}])=>"input"===e).map(([e])=>Number(e)))))iM(u,e,r);let o=i4(r);return F(...nC(e,t,o))}catch(e){return n1({error:e,command:n,escapedCommand:o,fileDescriptors:u,options:r,startTime:a,isSync:!0})}},i4=({encoding:e,maxBuffer:t,...r})=>({...r,encoding:"buffer",maxBuffer:(([,e])=>e)(t)}),i5=({error:e,exitCode:t,signal:r,timedOut:n,isMaxBuffer:o,stdio:u,all:a,options:s,command:l,escapedCommand:D,startTime:c})=>void 0===e?n2({command:l,escapedCommand:D,stdio:u,all:a,ipcOutput:[],options:s,startTime:c}):n8({error:e,command:l,escapedCommand:D,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:o,isForcefullyTerminated:!1,exitCode:t,signal:r,stdio:u,all:a,ipcOutput:[],options:s,startTime:c,isSync:!0}),ue=({anyProcess:e,channel:t,isSubprocess:r,ipc:n},{reference:o=!0,filter:u}={})=>(rd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:rH(e)}),ut({anyProcess:e,channel:t,isSubprocess:r,filter:u,reference:o})),ut=async({anyProcess:e,channel:t,isSubprocess:r,filter:n,reference:o})=>{rk(t,o);let u=rW(e,t,r),a=new AbortController;try{return await Promise.race([ur(u,n,a),un(u,r,a),uo(u,r,a)])}catch(t){throw rE(e),t}finally{a.abort(),rI(t,o)}},ur=async(e,t,{signal:r})=>{if(void 0===t){let[t]=await V(e,"message",{signal:r});return t}for await(let[n]of G(e,"message",{signal:r}))if(t(n))return n},un=async(e,t,{signal:r})=>{await V(e,"disconnect",{signal:r});throw Error(`${ry("getOneMessage",t)} could not complete: the ${rF(t)} exited or disconnected.`)},uo=async(e,t,{signal:r})=>{let[n]=await V(e,"strict:error",{signal:r});throw rh(n,t)},ui=({anyProcess:e,channel:t,isSubprocess:r,ipc:n},{reference:o=!0}={})=>uu({anyProcess:e,channel:t,isSubprocess:r,ipc:n,shouldAwait:!r,reference:o}),uu=({anyProcess:e,channel:t,isSubprocess:r,ipc:n,shouldAwait:o,reference:u})=>{rd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:rH(e)}),rk(t,u);let a=rW(e,t,r),s=new AbortController,l={};return ua(e,a,s),us({ipcEmitter:a,isSubprocess:r,controller:s,state:l}),ul({anyProcess:e,channel:t,ipcEmitter:a,isSubprocess:r,shouldAwait:o,controller:s,state:l,reference:u})},ua=async(e,t,r)=>{try{await V(t,"disconnect",{signal:r.signal}),r.abort()}catch{}},us=async({ipcEmitter:e,isSubprocess:t,controller:r,state:n})=>{try{let[o]=await V(e,"strict:error",{signal:r.signal});n.error=rh(o,t),r.abort()}catch{}},ul=async function*({anyProcess:e,channel:t,ipcEmitter:r,isSubprocess:n,shouldAwait:o,controller:u,state:a,reference:s}){try{for await(let[e]of G(r,"message",{signal:u.signal}))uD(a),yield e}catch{uD(a)}finally{u.abort(),rI(t,s),n||rE(e),o&&await e}},uD=({error:e})=>{if(e)throw e},uc=(e,t,r)=>({sendMessage:r6.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r}),getOneMessage:ue.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r}),getEachMessage:ui.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r})}),ud=()=>{let e=new eu;return e.end(),e},up=()=>new ea({read(){}}),uf=()=>new el({write(){}}),uh=()=>new ei({read(){},write(){}}),um=async(e,t,r)=>n5(e,t,r),ub=({type:e,optionName:t})=>{throw TypeError(`The \`${t}\` option cannot be ${oC[e]}.`)},uy={fileNumber:ub,generator:ij,asyncGenerator:ij,nodeStream:({value:e})=>({stream:e}),webTransform:({value:{transform:e,writableObjectMode:t,readableObjectMode:r}})=>({stream:ei.fromWeb(e,{objectMode:t||r})}),duplex:({value:{transform:e}})=>({stream:e}),native(){}},ug={input:{...uy,fileUrl:({value:e})=>({stream:X(e)}),filePath:({value:{file:e}})=>({stream:X(e)}),webStream:({value:e})=>({stream:ea.fromWeb(e)}),iterable:({value:e})=>({stream:ea.from(e)}),asyncIterable:({value:e})=>({stream:ea.from(e)}),string:({value:e})=>({stream:ea.from(e)}),uint8Array:({value:e})=>({stream:ea.from(ed.from(e))})},output:{...uy,fileUrl:({value:e})=>({stream:Z(e)}),filePath:({value:{file:e,append:t}})=>({stream:Z(e,t?{flags:"a"}:{})}),webStream:({value:e})=>({stream:el.fromWeb(e)}),iterable:ub,asyncIterable:ub,string:ub,uint8Array:ub}};function uF(e){if(!Array.isArray(e))throw TypeError(`Expected an array, got \`${typeof e}\`.`);for(let t of e)uS(t);let t=e.some(({readableObjectMode:e})=>e),r=uE(e,t),n=new uC({objectMode:t,writableHighWaterMark:r,readableHighWaterMark:r});for(let t of e)n.add(t);return n}let uE=(e,t)=>0===e.length?eD(t):Math.max(...e.filter(({readableObjectMode:e})=>e===t).map(({readableHighWaterMark:e})=>e));class uC extends eu{#u=new Set([]);#a=new Set([]);#s=new Set([]);#l;#D=Symbol("unpipe");#c=new WeakMap;add(e){if(uS(e),this.#u.has(e))return;this.#u.add(e),this.#l??=uw(this,this.#u,this.#D);let t=uB({passThroughStream:this,stream:e,streams:this.#u,ended:this.#a,aborted:this.#s,onFinished:this.#l,unpipeEvent:this.#D});this.#c.set(e,t),e.pipe(this,{end:!1})}async remove(e){if(uS(e),!this.#u.has(e))return!1;let t=this.#c.get(e);return void 0!==t&&(this.#c.delete(e),e.unpipe(this),await t,!0)}}let uw=async(e,t,r)=>{uI(e,uL);let n=new AbortController;try{await Promise.race([u_(e,n),uv(e,t,r,n)])}finally{n.abort(),uI(e,-uL)}},u_=async(e,{signal:t})=>{try{await ep(e,{signal:t,cleanup:!0})}catch(t){throw uP(e,t),t}},uv=async(e,t,r,{signal:n})=>{for await(let[o]of G(e,"unpipe",{signal:n}))t.has(o)&&o.emit(r)},uS=e=>{if("function"!=typeof e?.pipe)throw TypeError(`Expected a readable stream, got: \`${typeof e}\`.`)},uB=async({passThroughStream:e,stream:t,streams:r,ended:n,aborted:o,onFinished:u,unpipeEvent:a})=>{uI(e,uM);let s=new AbortController;try{await Promise.race([uT(u,t,s),uA({passThroughStream:e,stream:t,streams:r,ended:n,aborted:o,controller:s}),uR({stream:t,streams:r,ended:n,aborted:o,unpipeEvent:a,controller:s})])}finally{s.abort(),uI(e,-uM)}r.size>0&&r.size===n.size+o.size&&(0===n.size&&o.size>0?uO(e):ux(e))},uT=async(e,t,{signal:r})=>{try{await e,r.aborted||uO(t)}catch(e){r.aborted||uP(t,e)}},uA=async({passThroughStream:e,stream:t,streams:r,ended:n,aborted:o,controller:{signal:u}})=>{try{await ep(t,{signal:u,cleanup:!0,readable:!0,writable:!1}),r.has(t)&&n.add(t)}catch(n){if(u.aborted||!r.has(t))return;u$(n)?o.add(t):uk(e,n)}},uR=async({stream:e,streams:t,ended:r,aborted:n,unpipeEvent:o,controller:{signal:u}})=>{if(await V(e,o,{signal:u}),!e.readable)return V(u,"abort",{signal:u});t.delete(e),r.delete(e),n.delete(e)},ux=e=>{e.writable&&e.end()},uP=(e,t)=>{u$(t)?uO(e):uk(e,t)},u$=e=>e?.code==="ERR_STREAM_PREMATURE_CLOSE",uO=e=>{(e.readable||e.writable)&&e.destroy()},uk=(e,t)=>{e.destroyed||(e.once("error",uj),e.destroy(t))},uj=()=>{},uI=(e,t)=>{let r=e.getMaxListeners();0!==r&&r!==1/0&&e.setMaxListeners(r+t)},uL=2,uM=1,uU=(e,t)=>{e.pipe(t),uN(e,t),uq(e,t)},uN=async(e,t)=>{if(!(e2(e)||e2(t))){try{await ep(e,{cleanup:!0,readable:!0,writable:!1})}catch{}uW(t)}},uW=e=>{e.writable&&e.end()},uq=async(e,t)=>{if(!(e2(e)||e2(t))){try{await ep(t,{cleanup:!0,readable:!1,writable:!0})}catch{}uz(e)}},uz=e=>{e.readable&&e.destroy()},uH=(e,t,r,n)=>{"output"===r?uU(e.stdio[n],t):uU(t,e.stdio[n]);let o=uG[n];void 0!==o&&(e[o]=t),e.stdio[n]=t},uG=["stdin","stdout","stderr"],uV=({subprocess:e,stream:t,direction:r,fdNumber:n,pipeGroups:o,controller:u})=>{if(void 0===t)return;uK(t,u);let[a,s]="output"===r?[t,e.stdio[n]]:[e.stdio[n],t],l=o.get(a)??[];o.set(a,[...l,s])},uK=(e,{signal:t})=>{e2(e)&&rO(e,uY,t)},uY=2,uJ=[];uJ.push("SIGHUP","SIGINT","SIGTERM"),"win32"!==process.platform&&uJ.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),"linux"===process.platform&&uJ.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");let uQ=e=>!!e&&"object"==typeof e&&"function"==typeof e.removeListener&&"function"==typeof e.emit&&"function"==typeof e.reallyExit&&"function"==typeof e.listeners&&"function"==typeof e.kill&&"number"==typeof e.pid&&"function"==typeof e.on,uX=Symbol.for("signal-exit emitter"),uZ=globalThis,u0=Object.defineProperty.bind(Object);class u2{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(uZ[uX])return uZ[uX];u0(uZ,uX,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let r=this.listeners[e],n=r.indexOf(t);-1!==n&&(0===n&&1===r.length?r.length=0:r.splice(n,1))}emit(e,t,r){if(this.emitted[e])return!1;this.emitted[e]=!0;let n=!1;for(let o of this.listeners[e])n=!0===o(t,r)||n;return"exit"===e&&(n=this.emit("afterExit",t,r)||n),n}}class u1{}class u8 extends u1{#d="win32"===u3.platform?"SIGINT":"SIGHUP";#p=new u2;#f;#h;#m;#b={};#y=!1;constructor(e){for(let t of(super(),this.#f=e,this.#b={},uJ))this.#b[t]=()=>{let r=this.#f.listeners(t),{count:n}=this.#p;if("object"==typeof e.__signal_exit_emitter__&&"number"==typeof e.__signal_exit_emitter__.count&&(n+=e.__signal_exit_emitter__.count),r.length===n){this.unload();let r=this.#p.emit("exit",null,t),n="SIGHUP"===t?this.#d:t;r||e.kill(e.pid,n)}};this.#m=e.reallyExit,this.#h=e.emit}onExit(e,t){if(!uQ(this.#f))return()=>{};!1===this.#y&&this.load();let r=t?.alwaysLast?"afterExit":"exit";return this.#p.on(r,e),()=>{this.#p.removeListener(r,e),0===this.#p.listeners.exit.length&&0===this.#p.listeners.afterExit.length&&this.unload()}}load(){if(!this.#y){for(let e of(this.#y=!0,this.#p.count+=1,uJ))try{let t=this.#b[e];t&&this.#f.on(e,t)}catch(e){}this.#f.emit=(e,...t)=>this.#g(e,...t),this.#f.reallyExit=e=>this.#F(e)}}unload(){this.#y&&(this.#y=!1,uJ.forEach(e=>{let t=this.#b[e];if(!t)throw Error("Listener not defined for signal: "+e);try{this.#f.removeListener(e,t)}catch(e){}}),this.#f.emit=this.#h,this.#f.reallyExit=this.#m,this.#p.count-=1)}#F(e){return uQ(this.#f)?(this.#f.exitCode=e||0,this.#p.emit("exit",this.#f.exitCode,null),this.#m.call(this.#f,this.#f.exitCode)):0}#g(e,...t){let r=this.#h;if(!("exit"===e&&uQ(this.#f)))return r.call(this.#f,e,...t);{"number"==typeof t[0]&&(this.#f.exitCode=t[0]);let n=r.call(this.#f,e,...t);return this.#p.emit("exit",this.#f.exitCode,null),n}}}let u3=globalThis.process,{onExit:u6,load:u9,unload:u7}=(r=uQ(u3)?new u8(u3):new class extends u1{onExit(){return()=>{}}load(){}unload(){}},{onExit:(e,t)=>r.onExit(e,t),load:()=>r.load(),unload:()=>r.unload()}),u4=(e,t,r,...n)=>{if(Array.isArray(r))return{destination:t(u5,e)(r,...n),pipeOptions:e};if("string"==typeof r||r instanceof URL||ej(r)){if(Object.keys(e).length>0)throw TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[o,u,a]=eL(r,...n);return{destination:t(u5)(o,u,a),pipeOptions:a}}if(rv.has(r)){if(Object.keys(e).length>0)throw TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},u5=({options:e})=>({options:{...e,stdin:"pipe",piped:!0}}),ae=({error:e,fileDescriptors:t,sourceOptions:r,startTime:n})=>n1({error:e,command:at,escapedCommand:at,fileDescriptors:t,options:r,startTime:n,isSync:!1}),at="source.pipe(destination)",ar=async e=>{let[{status:t,reason:r,value:n=r},{status:o,reason:u,value:a=u}]=await e;if(a.pipedFrom.includes(n)||a.pipedFrom.push(n),"rejected"===o)throw a;if("rejected"===t)throw n;return a},an=async e=>{try{await ep(e,{cleanup:!0,readable:!1,writable:!0})}catch{}ao.delete(e)},ao=new WeakMap,ai=async(e,{sourceStream:t,mergedStream:r,fileDescriptors:n,sourceOptions:o,startTime:u})=>{throw await C(e,t),await r.remove(t),ae({error:Error("Pipe canceled by `unpipeSignal` option."),fileDescriptors:n,sourceOptions:o,startTime:u})},au=(e,...t)=>{if(e$(t[0]))return au.bind(void 0,{...e,boundOptions:{...e.boundOptions,...t[0]}});let{destination:r,...n}=(({source:e,sourcePromise:t,boundOptions:r,createNested:n},...o)=>{let u=$.bigint(),{destination:a,destinationStream:s,destinationError:l,from:D,unpipeSignal:c}=((e,t,r)=>{try{let{destination:n,pipeOptions:{from:o,to:u,unpipeSignal:a}={}}=u4(e,t,...r),s=rw(n,u);return{destination:n,destinationStream:s,from:o,unpipeSignal:a}}catch(e){return{destinationError:e}}})(r,n,o),{sourceStream:d,sourceError:p}=((e,t)=>{try{return{sourceStream:r_(e,t)}}catch(e){return{sourceError:e}}})(e,D),{options:f,fileDescriptors:h}=rv.get(e);return{sourcePromise:t,sourceStream:d,sourceOptions:f,sourceError:p,destination:a,destinationStream:s,destinationError:l,unpipeSignal:c,fileDescriptors:h,startTime:u}})(e,...t),o=aa({...n,destination:r});return o.pipe=au.bind(void 0,{...e,source:r,sourcePromise:o,boundOptions:{}}),o},aa=async({sourcePromise:e,sourceStream:t,sourceOptions:r,sourceError:n,destination:o,destinationStream:u,destinationError:a,unpipeSignal:s,fileDescriptors:l,startTime:D})=>{let c=as(e,o);(({sourceStream:e,sourceError:t,destinationStream:r,destinationError:n,fileDescriptors:o,sourceOptions:u,startTime:a})=>{let s=(({sourceStream:e,sourceError:t,destinationStream:r,destinationError:n})=>void 0!==t&&void 0!==n?n:void 0!==n?(uz(e),n):void 0!==t?(uW(r),t):void 0)({sourceStream:e,sourceError:t,destinationStream:r,destinationError:n});if(void 0!==s)throw ae({error:s,fileDescriptors:o,sourceOptions:u,startTime:a})})({sourceStream:t,sourceError:n,destinationStream:u,destinationError:a,fileDescriptors:l,sourceOptions:r,startTime:D});let d=new AbortController;try{var p,f,h,m;let e,n,o,a,b=(o=ao.has(u)?(p=t,f=u,(e=ao.get(f)).add(p),e):(h=t,m=u,n=uF([h]),uU(n,m),ao.set(m,n),n),rO(t,2,d.signal),rO(u,1,d.signal),an(u),o);return await Promise.race([ar(c),...(a={sourceStream:t,mergedStream:b,sourceOptions:r,fileDescriptors:l,startTime:D},void 0===s?[]:[ai(s,a)])])}finally{d.abort()}},as=(e,t)=>Promise.allSettled([e,t]),al=e=>e,aD=()=>void 0,ac=({contents:e})=>e,ad=e=>{throw Error(`Streams in object mode are not supported: ${String(e)}`)},ap=e=>e.length;async function af(e,t){return nH(e,ah,t)}let ah={init:()=>({contents:[]}),convertChunk:{string:al,buffer:al,arrayBuffer:al,dataView:al,typedArray:al,others:al},getSize:()=>1,truncateChunk:aD,addChunk:(e,{contents:t})=>(t.push(e),t),getFinalChunk:aD,finalize:ac};async function am(e,t){return nH(e,aC,t)}let ab=new TextEncoder,ay=e=>new Uint8Array(e),ag=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),aF=e=>aE**Math.ceil(Math.log(e)/Math.log(aE)),aE=2,aC={init:()=>({contents:new ArrayBuffer(0)}),convertChunk:{string:e=>ab.encode(e),buffer:ay,arrayBuffer:ay,dataView:ag,typedArray:ag,others:ad},getSize:ap,truncateChunk:(e,t)=>e.slice(0,t),addChunk:(e,{contents:t,length:r},n)=>{let o="resize"in ArrayBuffer.prototype?((e,t)=>{if(t<=e.maxByteLength)return e.resize(t),e;let r=new ArrayBuffer(t,{maxByteLength:aF(t)});return new Uint8Array(r).set(new Uint8Array(e),0),r})(t,n):((e,t)=>{if(t<=e.byteLength)return e;let r=new ArrayBuffer(aF(t));return new Uint8Array(r).set(new Uint8Array(e),0),r})(t,n);return new Uint8Array(o).set(e,r),o},getFinalChunk:aD,finalize:({contents:e,length:t})=>"resize"in ArrayBuffer.prototype?e:e.slice(0,t)};async function aw(e,t){return nH(e,av,t)}let a_=(e,{textDecoder:t})=>t.decode(e,{stream:!0}),av={init:()=>({contents:"",textDecoder:new TextDecoder}),convertChunk:{string:al,buffer:a_,arrayBuffer:a_,dataView:a_,typedArray:a_,others:ad},getSize:ap,truncateChunk:(e,t)=>e.slice(0,t),addChunk:(e,{contents:t})=>t+e,getFinalChunk:({textDecoder:e})=>{let t=e.decode();return""===t?void 0:t},finalize:ac},aS=({subprocessStdout:e,subprocess:t,binary:r,shouldEncode:n,encoding:o,preserveNewlines:u})=>{let a=new AbortController;return aB(t,a),aR({stream:e,controller:a,binary:r,shouldEncode:!e.readableObjectMode&&n,encoding:o,shouldSplit:!e.readableObjectMode,preserveNewlines:u})},aB=async(e,t)=>{try{await e}catch{}finally{t.abort()}},aT=({stream:e,onStreamEnd:t,lines:r,encoding:n,stripFinalNewline:o,allMixed:u})=>{let a=new AbortController;aA(t,a,e);let s=e.readableObjectMode&&!u;return aR({stream:e,controller:a,binary:"buffer"===n,shouldEncode:!s,encoding:n,shouldSplit:!s&&r,preserveNewlines:!o})},aA=async(e,t,r)=>{try{await e}catch{r.destroy()}finally{t.abort()}},aR=({stream:e,controller:t,binary:r,shouldEncode:n,encoding:o,shouldSplit:u,preserveNewlines:a})=>a$({onStdoutChunk:G(e,"data",{signal:t.signal,highWaterMark:aP,highWatermark:aP}),controller:t,binary:r,shouldEncode:n,encoding:o,shouldSplit:u,preserveNewlines:a}),ax=eD(!0),aP=ax,a$=async function*({onStdoutChunk:e,controller:t,binary:r,shouldEncode:n,encoding:o,shouldSplit:u,preserveNewlines:a}){let s=aO({binary:r,shouldEncode:n,encoding:o,shouldSplit:u,preserveNewlines:a});try{for await(let[t]of e)yield*iP(t,s,0)}catch(e){if(!t.signal.aborted)throw e}finally{yield*i$(s)}},aO=({binary:e,shouldEncode:t,encoding:r,shouldSplit:n,preserveNewlines:o})=>[iF(e,r,!t),io(e,o,!n,{})].filter(Boolean),ak=async({stream:e,onStreamEnd:t,fdNumber:r,encoding:n,buffer:o,maxBuffer:u,lines:a,allMixed:s,stripFinalNewline:l,verboseInfo:D,streamInfo:c})=>{let d=aj({stream:e,onStreamEnd:t,fdNumber:r,encoding:n,allMixed:s,verboseInfo:D,streamInfo:c});if(!o)return void await Promise.all([aI(e),d]);let p=aT({stream:e,onStreamEnd:t,lines:a,encoding:n,stripFinalNewline:ir(l,r),allMixed:s}),[f]=await Promise.all([aL({stream:e,iterable:p,fdNumber:r,encoding:n,maxBuffer:u,lines:a}),d]);return f},aj=async({stream:e,onStreamEnd:t,fdNumber:r,encoding:n,allMixed:o,verboseInfo:u,streamInfo:{fileDescriptors:a}})=>{if(!iW({stdioItems:a[r]?.stdioItems,encoding:n,verboseInfo:u,fdNumber:r}))return;let s=aT({stream:e,onStreamEnd:t,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:o});await iH(s,e,r,u)},aI=async e=>{await M(),null===e.readableFlowing&&e.resume()},aL=async({stream:e,stream:{readableObjectMode:t},iterable:r,fdNumber:n,encoding:o,maxBuffer:u,lines:a})=>{try{if(t||a)return await af(r,{maxBuffer:u});if("buffer"===o)return new Uint8Array(await am(r,{maxBuffer:u}));return await aw(r,{maxBuffer:u})}catch(r){return aU((({error:e,stream:t,readableObjectMode:r,lines:n,encoding:o,fdNumber:u})=>{let a,s,l;if(!(e instanceof nQ))throw e;if("all"===u)return e;throw e.maxBufferInfo={fdNumber:u,unit:(a=r,s=n,l=o,a?"objects":s?"lines":"buffer"===l?"bytes":"characters")},t.destroy(),e})({error:r,stream:e,readableObjectMode:t,lines:a,encoding:o,fdNumber:n}))}},aM=async e=>{try{return await e}catch(e){return aU(e)}},aU=({bufferedData:e})=>"[object ArrayBuffer]"===eM.call(e)?new Uint8Array(e):e,aN=async(e,t,r,{isSameDirection:n,stopOnExit:o=!1}={})=>{let u=aW(e,r),a=new AbortController;try{await Promise.race([...o?[r.exitPromise]:[],ep(e,{cleanup:!0,signal:a.signal})])}catch(e){u.stdinCleanedUp||aH(e,t,r,n)}finally{a.abort()}},aW=(e,{originalStreams:[t],subprocess:r})=>{let n={stdinCleanedUp:!1};return e===t&&aq(e,r,n),n},aq=(e,t,r)=>{let{_destroy:n}=e;e._destroy=(...o)=>{az(t,r),n.call(e,...o)}},az=({exitCode:e,signalCode:t},r)=>{(null!==e||null!==t)&&(r.stdinCleanedUp=!0)},aH=(e,t,r,n)=>{if(!aG(e,t,r,n))throw e},aG=(e,t,r,n=!0)=>r.propagating?aY(e)||aK(e):(r.propagating=!0,aV(r,t)===n?aY(e):aK(e)),aV=({fileDescriptors:e},t)=>"all"!==t&&"input"===e[t].direction,aK=e=>e?.code==="ERR_STREAM_PREMATURE_CLOSE",aY=e=>e?.code==="EPIPE",aJ=async({stream:e,fdNumber:t,encoding:r,buffer:n,maxBuffer:o,lines:u,allMixed:a,stripFinalNewline:s,verboseInfo:l,streamInfo:D})=>{if(!e)return;let c=aN(e,t,D);if(aV(D,t))return void await c;let[d]=await Promise.all([ak({stream:e,onStreamEnd:c,fdNumber:t,encoding:r,buffer:n,maxBuffer:o,lines:u,allMixed:a,stripFinalNewline:s,verboseInfo:l,streamInfo:D}),c]);return d},aQ=(e,t)=>{tI({type:"ipc",verboseMessage:tN(e),fdNumber:"ipc",verboseInfo:t})},aX=async({subprocess:e,buffer:t,maxBuffer:r,ipc:n,ipcOutput:o,verboseInfo:u})=>{if(!n)return o;let a=ts(u,"ipc"),s=ta(t,"ipc"),l=ta(r,"ipc");for await(let t of uu({anyProcess:e,channel:e.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))s&&(nX(e,o,l),o.push(t)),a&&aQ(t,u);return o},aZ=async(e,t)=>(await Promise.allSettled([e]),t),a0=async({subprocess:e,options:{encoding:t,buffer:r,maxBuffer:n,lines:o,timeoutDuration:u,cancelSignal:a,gracefulCancel:s,forceKillAfterDelay:l,stripFinalNewline:D,ipc:c,ipcInput:d},context:p,verboseInfo:f,fileDescriptors:h,originalStreams:m,onInternalError:b,controller:y})=>{let g=iX(e,p),F={originalStreams:m,fileDescriptors:h,subprocess:e,exitPromise:g,propagating:!1},E=(({subprocess:e,encoding:t,buffer:r,maxBuffer:n,lines:o,stripFinalNewline:u,verboseInfo:a,streamInfo:s})=>e.stdio.map((e,l)=>aJ({stream:e,fdNumber:l,encoding:t,buffer:r[l],maxBuffer:n[l],lines:o[l],allMixed:!1,stripFinalNewline:u,verboseInfo:a,streamInfo:s})))({subprocess:e,encoding:t,buffer:r,maxBuffer:n,lines:o,stripFinalNewline:D,verboseInfo:f,streamInfo:F}),C=(({subprocess:e,encoding:t,buffer:r,maxBuffer:n,lines:o,stripFinalNewline:u,verboseInfo:a,streamInfo:s})=>aJ({...(({stdout:e,stderr:t,all:r},[,n,o])=>{let u=n||o;return u?n?o?{stream:r,buffer:u}:{stream:e,buffer:u}:{stream:t,buffer:u}:{stream:r,buffer:u}})(e,r),fdNumber:"all",encoding:t,maxBuffer:n[1]+n[2],lines:o[1]||o[2],allMixed:(({all:e,stdout:t,stderr:r})=>e&&t&&r&&t.readableObjectMode!==r.readableObjectMode)(e),stripFinalNewline:u,verboseInfo:a,streamInfo:s}))({subprocess:e,encoding:t,buffer:r,maxBuffer:n,lines:o,stripFinalNewline:D,verboseInfo:f,streamInfo:F}),w=[],_=aX({subprocess:e,buffer:r,maxBuffer:n,ipc:c,ipcOutput:w,verboseInfo:f}),v=a2(m,e,F),S=a1(h,F);try{return await Promise.race([Promise.all([{},i2(g),Promise.all(E),C,_,nc(e,d),...v,...S]),b,a8(e,y),...0===u||void 0===u?[]:[nl(e,u,p,y)],...(({subprocess:e,cancelSignal:t,gracefulCancel:r,context:n,controller:o})=>void 0===t||r?[]:[rc(e,t,n,o)])({subprocess:e,cancelSignal:a,gracefulCancel:s,context:p,controller:y}),...(({subprocess:e,cancelSignal:t,gracefulCancel:r,forceKillAfterDelay:n,context:o,controller:u})=>r?[na({subprocess:e,cancelSignal:t,forceKillAfterDelay:n,context:o,controller:u})]:[])({subprocess:e,cancelSignal:a,gracefulCancel:s,forceKillAfterDelay:l,context:p,controller:y})])}catch(e){return p.terminationReason??="other",Promise.all([{error:e},g,Promise.all(E.map(e=>aM(e))),aM(C),aZ(_,w),Promise.allSettled(v),Promise.allSettled(S)])}},a2=(e,t,r)=>e.map((e,n)=>e===t.stdio[n]?void 0:aN(e,n,r)),a1=(e,t)=>e.flatMap(({stdioItems:e},r)=>e.filter(({value:e,stream:t=e})=>nR(t,{checkOpen:!1})&&!e2(t)).map(({type:e,value:n,stream:o=n})=>aN(o,r,t,{isSameDirection:ob.has(e),stopOnExit:"native"===e}))),a8=async(e,{signal:t})=>{let[r]=await V(e,"error",{signal:t});throw r},a3=(e,t,r)=>{let n=e[r];n.has(t)||n.set(t,[]);let o=n.get(t),u=rC();return o.push(u),{resolve:u.resolve.bind(u),promises:o}},a6=async({resolve:e,promises:t},r)=>{e();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...t])]);return!n},a9=async e=>{if(void 0!==e)try{await a4(e)}catch{}},a7=async e=>{if(void 0!==e)try{await a5(e)}catch{}},a4=async e=>{await ep(e,{cleanup:!0,readable:!1,writable:!0})},a5=async e=>{await ep(e,{cleanup:!0,readable:!0,writable:!1})},se=async(e,t)=>{if(await e,t)throw t},st=(e,t,r)=>{r&&!aK(r)?e.destroy(r):t&&e.destroy()},sr=({subprocess:e,concurrentStreams:t,encoding:r},{from:n,binary:o=!0,preserveNewlines:u=!0}={})=>{let a=o||np.has(r),{subprocessStdout:s,waitReadableDestroy:l}=sn(e,n,t),{readableEncoding:D,readableObjectMode:c,readableHighWaterMark:d}=so(s,a),{read:p,onStdoutDataDone:f}=si({subprocessStdout:s,subprocess:e,binary:a,encoding:r,preserveNewlines:u}),h=new ea({read:p,destroy:w(ss.bind(void 0,{subprocessStdout:s,subprocess:e,waitReadableDestroy:l})),highWaterMark:d,objectMode:c,encoding:D});return sa({subprocessStdout:s,onStdoutDataDone:f,readable:h,subprocess:e}),h},sn=(e,t,r)=>{let n=r_(e,t),o=a3(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:o}},so=({readableEncoding:e,readableObjectMode:t,readableHighWaterMark:r},n)=>n?{readableEncoding:e,readableObjectMode:t,readableHighWaterMark:r}:{readableEncoding:e,readableObjectMode:!0,readableHighWaterMark:ax},si=({subprocessStdout:e,subprocess:t,binary:r,encoding:n,preserveNewlines:o})=>{let u=rC(),a=aS({subprocessStdout:e,subprocess:t,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:o});return{read(){su(this,a,u)},onStdoutDataDone:u}},su=async(e,t,r)=>{try{let{value:n,done:o}=await t.next();o?r.resolve():e.push(n)}catch{}},sa=async({subprocessStdout:e,onStdoutDataDone:t,readable:r,subprocess:n,subprocessStdin:o})=>{try{await a5(e),await n,await a9(o),await t,r.readable&&r.push(null)}catch(e){await a9(o),sl(r,e)}},ss=async({subprocessStdout:e,subprocess:t,waitReadableDestroy:r},n)=>{await a6(r,t)&&(sl(e,n),await se(t,n))},sl=(e,t)=>{st(e,e.readable,t)},sD=({subprocess:e,concurrentStreams:t},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:o,waitWritableDestroy:u}=sc(e,r,t),a=new el({...sd(n,e,o),destroy:w(sm.bind(void 0,{subprocessStdin:n,subprocess:e,waitWritableFinal:o,waitWritableDestroy:u})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return sh(n,a),a},sc=(e,t,r)=>{let n=rw(e,t),o=a3(r,n,"writableFinal"),u=a3(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:o,waitWritableDestroy:u}},sd=(e,t,r)=>({write:sp.bind(void 0,e),final:w(sf.bind(void 0,e,t,r))}),sp=(e,t,r,n)=>{e.write(t,r)?n():e.once("drain",n)},sf=async(e,t,r)=>{await a6(r,t)&&(e.writable&&e.end(),await t)},sh=async(e,t,r)=>{try{await a4(e),t.writable&&t.end()}catch(e){await a7(r),sb(t,e)}},sm=async({subprocessStdin:e,subprocess:t,waitWritableFinal:r,waitWritableDestroy:n},o)=>{await a6(r,t),await a6(n,t)&&(sb(e,o),await se(t,o))},sb=(e,t)=>{st(e,e.writable,t)},sy=({subprocess:e,concurrentStreams:t,encoding:r},{from:n,to:o,binary:u=!0,preserveNewlines:a=!0}={})=>{let s=u||np.has(r),{subprocessStdout:l,waitReadableDestroy:D}=sn(e,n,t),{subprocessStdin:c,waitWritableFinal:d,waitWritableDestroy:p}=sc(e,o,t),{readableEncoding:f,readableObjectMode:h,readableHighWaterMark:m}=so(l,s),{read:b,onStdoutDataDone:y}=si({subprocessStdout:l,subprocess:e,binary:s,encoding:r,preserveNewlines:a}),g=new ei({read:b,...sd(c,e,d),destroy:w(sg.bind(void 0,{subprocessStdout:l,subprocessStdin:c,subprocess:e,waitReadableDestroy:D,waitWritableFinal:d,waitWritableDestroy:p})),readableHighWaterMark:m,writableHighWaterMark:c.writableHighWaterMark,readableObjectMode:h,writableObjectMode:c.writableObjectMode,encoding:f});return sa({subprocessStdout:l,onStdoutDataDone:y,readable:g,subprocess:e,subprocessStdin:c}),sh(c,g,l),g},sg=async({subprocessStdout:e,subprocessStdin:t,subprocess:r,waitReadableDestroy:n,waitWritableFinal:o,waitWritableDestroy:u},a)=>{await Promise.all([ss({subprocessStdout:e,subprocess:r,waitReadableDestroy:n},a),sm({subprocessStdin:t,subprocess:r,waitWritableFinal:o,waitWritableDestroy:u},a)])},sF=(e,t,{from:r,binary:n=!1,preserveNewlines:o=!1}={})=>{let u=n||np.has(t),a=r_(e,r);return sE(aS({subprocessStdout:a,subprocess:e,binary:u,shouldEncode:!0,encoding:t,preserveNewlines:o}),a,e)},sE=async function*(e,t,r){try{yield*e}finally{t.readable&&t.destroy(),await r}},sC=(async()=>{})().constructor.prototype,sw=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(sC,e)]),s_=({timeout:e,signal:t,...r})=>{if(void 0!==t)throw TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:e}},sv=async({subprocess:e,options:t,startTime:r,verboseInfo:n,fileDescriptors:o,originalStreams:u,command:a,escapedCommand:s,context:l,onInternalError:D,controller:c})=>{let[d,[p,f],h,m,b]=await a0({subprocess:e,options:t,context:l,verboseInfo:n,fileDescriptors:o,originalStreams:u,onInternalError:D,controller:c});c.abort(),D.resolve();let y=sS({errorInfo:d,exitCode:p,signal:f,stdio:h.map((e,r)=>it(e,t,r)),all:it(m,t,"all"),ipcOutput:b,context:l,options:t,command:a,escapedCommand:s,startTime:r});return n5(y,n,t)},sS=({errorInfo:e,exitCode:t,signal:r,stdio:n,all:o,ipcOutput:u,context:a,options:s,command:l,escapedCommand:D,startTime:c})=>"error"in e?n8({error:e.error,command:l,escapedCommand:D,timedOut:"timeout"===a.terminationReason,isCanceled:"cancel"===a.terminationReason||"gracefulCancel"===a.terminationReason,isGracefullyCanceled:"gracefulCancel"===a.terminationReason,isMaxBuffer:e.error instanceof nQ,isForcefullyTerminated:a.isForcefullyTerminated,exitCode:t,signal:r,stdio:n,all:o,ipcOutput:u,options:s,startTime:c,isSync:!1}):n2({command:l,escapedCommand:D,stdio:n,all:o,ipcOutput:u,options:s,startTime:c}),sB=(e,t)=>{let r=Object.fromEntries(Object.entries(t).map(([t,r])=>[t,sT(t,e[t],r)]));return{...e,...r}},sT=(e,t,r)=>sA.has(e)&&e$(t)&&e$(r)?{...t,...r}:r,sA=new Set(["env",...tu]),sR=(e,t,r,n)=>{let o=(e,t,n)=>sR(e,t,r,n),u=(...u)=>sx({mapArguments:e,deepOptions:r,boundOptions:t,setBoundExeca:n,createNested:o},...u);return void 0!==n&&n(u,o,t),u},sx=({mapArguments:e,deepOptions:t={},boundOptions:r={},setBoundExeca:n,createNested:o},u,...a)=>{if(e$(u))return o(e,sB(r,u),n);let{file:s,commandArguments:l,options:D,isSync:c}=sP({mapArguments:e,firstArgument:u,nextArguments:a,deepOptions:t,boundOptions:r});return c?((e,t,r)=>{let{file:n,commandArguments:o,command:u,escapedCommand:a,startTime:s,verboseInfo:l,options:D,fileDescriptors:c}=((e,t,r)=>{let{command:n,escapedCommand:o,startTime:u,verboseInfo:a}=tH(e,t,r),{file:s,commandArguments:l,options:D}=ng(e,t,i3(r));i6(D);let c=oV(ie,D,a,!0);return{file:s,commandArguments:l,command:n,escapedCommand:o,startTime:u,verboseInfo:a,options:D,fileDescriptors:c}})(e,t,r);return n5((({file:e,commandArguments:t,options:r,command:n,escapedCommand:o,verboseInfo:u,fileDescriptors:a,startTime:s})=>{let l=i7({file:e,commandArguments:t,options:r,command:n,escapedCommand:o,fileDescriptors:a,startTime:s});if(l.failed)return l;let{resultError:D,exitCode:c,signal:d,timedOut:p,isMaxBuffer:f}=(({error:e,status:t,signal:r,output:n},{maxBuffer:o})=>{let u,a,s,l=(u=e,a=t,s=r,void 0!==u?u:i8(a,s)?new tK:void 0),D=l?.code==="ETIMEDOUT",c=l?.code==="ENOBUFS"&&null!==n&&n.some(e=>null!==e&&e.length>(([,e])=>e)(o));return{resultError:l,exitCode:t,signal:r,timedOut:D,isMaxBuffer:c}})(l,r),{output:h,error:m=D}=(({fileDescriptors:e,syncResult:{output:t},options:r,isMaxBuffer:n,verboseInfo:o})=>{if(null===t)return{output:Array.from({length:3})};let u={},a=new Set([]);return{output:t.map((t,s)=>(({result:e,fileDescriptors:t,fdNumber:r,state:n,outputFiles:o,isMaxBuffer:u,verboseInfo:a},{buffer:s,encoding:l,lines:D,stripFinalNewline:c,maxBuffer:d})=>{if(null===e)return;let p=eN(((e,t,r)=>{if(!t)return e;let n=(([,e])=>e)(r);return e.length>n?e.slice(0,n):e})(e,u,d)),{stdioItems:f,objectMode:h}=t[r],{serializedResult:m,finalResult:b=m}=iY({chunks:iK([p],f,l,n),objectMode:h,encoding:l,lines:D,stripFinalNewline:c,fdNumber:r});iJ({serializedResult:m,fdNumber:r,state:n,verboseInfo:a,encoding:l,stdioItems:f,objectMode:h});let y=s[r]?b:void 0;try{return void 0===n.error&&iQ(m,f,o),y}catch(e){return n.error=e,y}})({result:t,fileDescriptors:e,fdNumber:s,state:u,outputFiles:a,isMaxBuffer:n,verboseInfo:o},r)),...u}})({fileDescriptors:a,syncResult:l,options:r,isMaxBuffer:f,verboseInfo:u});return i5({error:m,exitCode:c,signal:d,timedOut:p,isMaxBuffer:f,stdio:h.map((e,t)=>it(e,r,t)),all:it((([,e,t],r)=>{if(r.all)return void 0===e?t:void 0===t?e:Array.isArray(e)?Array.isArray(t)?[...e,...t]:[...e,it(t,r,"all")]:Array.isArray(t)?[it(e,r,"all"),...t]:eU(e)&&eU(t)?eG([e,t]):`${e}${t}`})(h,r),r,"all"),options:r,command:n,escapedCommand:o,startTime:s})})({file:n,commandArguments:o,options:D,command:u,escapedCommand:a,verboseInfo:l,fileDescriptors:c,startTime:s}),l,D)})(s,l,D):((e,t,r,n)=>{let{file:o,commandArguments:u,command:a,escapedCommand:s,startTime:l,verboseInfo:D,options:c,fileDescriptors:d}=((e,t,r)=>{let{command:n,escapedCommand:o,startTime:u,verboseInfo:a}=tH(e,t,r),{file:s,commandArguments:l,options:D}=ng(e,t,r),c=s_(D),d=oV(ug,c,a,!1);return{file:s,commandArguments:l,command:n,escapedCommand:o,startTime:u,verboseInfo:a,options:c,fileDescriptors:d}})(e,t,r),{subprocess:p,promise:f}=(({file:e,commandArguments:t,options:r,startTime:n,verboseInfo:o,command:u,escapedCommand:a,fileDescriptors:s})=>{let l;try{l=g(...nC(e,t,r))}catch(e){return(({error:e,command:t,escapedCommand:r,fileDescriptors:n,options:o,startTime:u,verboseInfo:a})=>{var s,l;let D,c,d,p,f,h;o6(n);let m=new b;return s=m,l=n,D=ud(),c=ud(),d=ud(),p=Array.from({length:l.length-3},ud),f=ud(),h=[D,c,d,...p],Object.assign(s,{stdin:D,stdout:c,stderr:d,all:f,stdio:h}),Object.assign(m,{readable:up,writable:uf,duplex:uh}),{subprocess:m,promise:um(n1({error:e,command:t,escapedCommand:r,fileDescriptors:n,options:o,startTime:u,isSync:!1}),a,o)}})({error:e,command:u,escapedCommand:a,fileDescriptors:s,options:r,startTime:n,verboseInfo:o})}let D=new AbortController;K(1/0,D.signal);let c=[...l.stdio];var d=l;let p=new Map;for(let[e,{stdioItems:t,direction:r}]of Object.entries(s)){for(let{stream:n}of t.filter(({type:e})=>ob.has(e)))uH(d,n,r,e);for(let{stream:n}of t.filter(({type:e})=>!ob.has(e)))uV({subprocess:d,stream:n,direction:r,fdNumber:e,pipeGroups:p,controller:D})}for(let[e,t]of p.entries())uU(1===t.length?t[0]:uF(t),e);((e,{cleanup:t,detached:r},{signal:n})=>{if(!t||r)return;let o=u6(()=>{e.kill()});H(n,()=>{o()})})(l,r,D);let f={},h=rC();l.kill=ri.bind(void 0,{kill:l.kill.bind(l),options:r,onInternalError:h,context:f,controller:D}),l.all=(({stdout:e,stderr:t},{all:r})=>r&&(e||t)?uF([e,t].filter(Boolean)):void 0)(l,r),((e,{encoding:t})=>{let r={readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap};e.readable=sr.bind(void 0,{subprocess:e,concurrentStreams:r,encoding:t}),e.writable=sD.bind(void 0,{subprocess:e,concurrentStreams:r}),e.duplex=sy.bind(void 0,{subprocess:e,concurrentStreams:r,encoding:t}),e.iterable=sF.bind(void 0,e,t),e[Symbol.asyncIterator]=sF.bind(void 0,e,t,{})})(l,r),((e,{ipc:t})=>{Object.assign(e,uc(e,!1,t))})(l,r);let m=sv({subprocess:l,options:r,startTime:n,verboseInfo:o,fileDescriptors:s,originalStreams:c,command:u,escapedCommand:a,context:f,onInternalError:h,controller:D});return{subprocess:l,promise:m}})({file:o,commandArguments:u,options:c,startTime:l,verboseInfo:D,command:a,escapedCommand:s,fileDescriptors:d});p.pipe=au.bind(void 0,{source:p,sourcePromise:f,boundOptions:{},createNested:n});for(let[e,t]of sw){let r=t.value.bind(f);Reflect.defineProperty(p,e,{...t,value:r})}return rv.set(p,{options:c,fileDescriptors:d}),p})(s,l,D,o)},sP=({mapArguments:e,firstArgument:t,nextArguments:r,deepOptions:n,boundOptions:o})=>{let[u,a,s]=eL(...Array.isArray(t)&&Array.isArray(t.raw)?((e,t)=>{let r=[];for(let[n,o]of e.entries())r=eK({templates:e,expressions:t,tokens:r,index:n,template:o});if(0===r.length)throw TypeError("Template script must not be empty");let[n,...o]=r;return[n,o,{}]})(t,r):[t,...r]),l=sB(sB(n,o),s),{file:D=u,commandArguments:c=a,options:d=l,isSync:p=!1}=e({file:u,commandArguments:a,options:l});return{file:D,commandArguments:c,options:d,isSync:p}},s$=(e,t)=>{if(t.length>0)throw TypeError(`The command and its arguments must be passed as a single string: ${e} ${t}.`);let[r,...n]=sO(e);return{file:r,commandArguments:n}},sO=e=>{if("string"!=typeof e)throw TypeError(`The command must be a string: ${String(e)}.`);let t=e.trim();if(""===t)return[];let r=[];for(let e of t.split(sk)){let t=r.at(-1);t&&t.endsWith("\\")?r[r.length-1]=`${t.slice(0,-1)} ${e}`:r.push(e)}return r},sk=/ +/g,sj=({options:e})=>({...sI(e),isSync:!0}),sI=e=>({options:{...sL(e),...e}}),sL=({input:e,inputFile:t,stdio:r})=>void 0===e&&void 0===t&&void 0===r?{stdin:"inherit"}:{},sM=sR(()=>({}));sR(()=>({isSync:!0})),sR(({file:e,commandArguments:t})=>s$(e,t)),sR(({file:e,commandArguments:t})=>({...s$(e,t),isSync:!0})),sR(({options:e})=>{if(!1===e.node)throw TypeError('The "node" option cannot be false with `execaNode()`.');return{options:{...e,node:!0}}}),sR(({options:e})=>sI(e),{},{preferLocal:!0},(e,t,r)=>{e.sync=t(sj,r),e.s=e.sync});let{sendMessage:sU,getOneMessage:sN,getEachMessage:sW,getCancelSignal:sq}=(n=void 0!==R.channel,{...uc(R,!0,n),getCancelSignal:ne.bind(void 0,{anyProcess:R,channel:R.channel,isSubprocess:!0,ipc:n})});var sz,sH,sG,sV,sK,sY=JSON.parse('{"UU":"@doubao-dev/cli","rE":"1.0.0-rc.14","h_":"Doubao Plugins CLI"}');let sJ={name:sY.UU,version:sY.rE,description:sY.h_,registry:"https://registry.npmjs.org",appDev:{name:"@doubao-dev/plugin-app-dev",version:sY.rE},kit:{name:"@doubao-dev/kit",version:process.env.DBX_KIT_VERSION?.trim()||"0.10.0",lockCdn:{version:"0.10.0",url:"https://lf3-static.bytednsdoc.com/obj/eden-cn/rkz-zwwh-vhibvk/ljhwZthlaukjlkulzlp/kit-locks/public/0.10.0/b9a6e37aa01033f8a0e66224310b6d02c7205c3ad57c8e46467b3b1e21fd8416/package-lock.json",sha256:"b9a6e37aa01033f8a0e66224310b6d02c7205c3ad57c8e46467b3b1e21fd8416"}??void 0},auth:{baseUrl:"https://open.doubao.com",verificationUrl:"https://open.doubao.com/apps-plugin/oauth/device"},apiUrl:"https://open.doubao.com",apiHeaders:{"User-Agent":`doubao-dev-cli-${sY.rE}`},deviceApiUrl:"https://developer.doubao.com",consoleUrl:"https://open.doubao.com/console/plugins/"},sQ=l.join(N.homedir(),".dbx","token"),sX=l.join(N.homedir(),".doubao","token"),sZ={};function s0(e={}){let t={...sZ,...e},r=s1(t.baseUrl??"https://developer.doubao.com","baseUrl"),n=t.tokenPath??sQ;return{...t,baseUrl:r,verificationUrl:s1(t.verificationUrl??new URL("/oauth/device",r).href,"verificationUrl"),allowedOrigins:function(e,t){let r=new Set([new URL(t).origin]);for(let t of e??[]){let e;try{e=new URL(t)}catch{throw Error(`allowedOrigins 中的来源必须是完整的 HTTPS 地址:${t}`)}if("https:"!==e.protocol)throw Error(`allowedOrigins 中的来源必须使用 HTTPS:${t}`);r.add(e.origin)}return[...r]}(t.allowedOrigins,r),tokenPath:n,legacyTokenPath:t.tokenPath?void 0:sX,requestHeaders:new Headers(t.requestHeaders)}}function s2(e){return e.replace(/\/+$/,"")}function s1(e,t){let r;try{r=new URL(s2(e))}catch{throw Error(`${t} 必须是完整的 HTTPS URL`)}if("https:"!==r.protocol)throw Error(`${t} 必须使用 HTTPS`);return s2(r.toString())}let s8=B(y),s3="byted-doubao-open-dbx-cli",s6="dbx-cli",s9="aes-256-gcm";class s7 extends Error{constructor(e){super(e),this.name="CredentialStoreError"}}class s4 extends s7{constructor(){super("无法读取本地登录凭证:用于解密凭证的密钥文件 master.key 已丢失。请运行 dbx auth login 重新登录。")}}class s5{constructor(e,t){this.primary=e,this.fallback=t}async get(e){let t;if(await this.isFallbackAuthoritative(e))return this.fallback.get(e);try{let t=await this.primary.get(e);if(t)return t}catch(e){t=e}try{let t=await this.fallback.get(e);if(t)return t}catch(e){if(t)throw new s7(`从系统凭证存储读取登录凭证失败(${lc(t)});从备用加密文件读取也失败:${lc(e)}`);throw e}if(t)throw t instanceof Error?t:new s7(`从系统凭证存储读取登录凭证失败:${String(t)}`)}async set(e,t){let r;try{await this.primary.set(e,t)}catch(e){r=e}try{await this.fallback.set(e,t)}catch(t){if(r)throw new s7(`向系统凭证存储写入登录凭证失败(${lc(r)}),写入备用加密文件也失败(${lc(t)})`);throw await this.removeStaleFallbackAfterPrimaryWrite(e,t),t}r?await this.markFallbackAuthoritative(e):await this.clearFallbackAuthority(e)}async delete(e){let t;try{await this.primary.delete(e)}catch(e){t=e}try{await this.fallback.delete(e)}catch(e){if(t)throw new s7(`从系统凭证存储删除登录凭证失败(${lc(t)}),从备用加密文件删除也失败(${lc(e)})`);throw e}t?await this.markFallbackAuthoritativeOrThrow(e,t):await this.clearFallbackAuthority(e)}async isFallbackAuthoritative(e){return!!li(this.fallback)&&this.fallback.isFallbackAuthoritative(e)}async markFallbackAuthoritative(e){li(this.fallback)&&await this.fallback.markFallbackAuthoritative(e)}async markFallbackAuthoritativeOrThrow(e,t){if(!li(this.fallback))throw t instanceof Error?t:new s7(`系统凭证删除失败,且备用存储无法记录删除状态:${String(t)}`);try{await this.fallback.markFallbackAuthoritative(e)}catch(e){throw new s7(`系统凭证删除失败(${lc(t)}),且无法记录备用凭证删除状态:${lc(e)}`)}}async clearFallbackAuthority(e){li(this.fallback)&&await this.fallback.clearFallbackAuthority(e)}async removeStaleFallbackAfterPrimaryWrite(e,t){let r=[];try{await this.fallback.delete(e)}catch(e){r.push(e)}try{await this.clearFallbackAuthority(e)}catch(e){r.push(e)}if(r.length>0)throw new s7(`系统凭证已写入,但备用加密文件写入失败(${lc(t)}),且清理旧备用凭证失败:${r.map(lc).join(";")}`)}}class le{constructor(e={}){this.baseDir=e.baseDir??("darwin"===process.platform?l.join(N.homedir(),"Library","Application Support",s6):"win32"===process.platform?l.join(process.env.APPDATA||l.join(N.homedir(),"AppData","Roaming"),s6):l.join(process.env.XDG_DATA_HOME||l.join(N.homedir(),".local","share"),s6))}async get(e){var t,r;let n,o,u=this.credentialFilePath(e);try{n=await ee.readFile(u,"utf8")}catch(e){if(lD(e)&&"ENOENT"===e.code)return;throw new s7(`读取加密凭证文件失败:${lc(e)}`)}try{o=JSON.parse(n)}catch(e){throw new s7(`加密凭证文件不是有效的 JSON:${lc(e)}`)}if(!((t=o)&&"object"==typeof t&&1===t.version&&t.algorithm===s9&&"string"==typeof t.iv&&"string"==typeof t.authTag&&"string"==typeof t.ciphertext))throw new s7("无法读取本地登录凭证:当前 CLI 不支持凭证文件中的格式或字段。");let a=await this.readMasterKey();try{let t=eh.createDecipheriv(s9,a,Buffer.from(o.iv,"base64url"));return t.setAAD(Buffer.from((r=e,`${s3}:${r}`),"utf8")),t.setAuthTag(Buffer.from(o.authTag,"base64url")),Buffer.concat([t.update(Buffer.from(o.ciphertext,"base64url")),t.final()]).toString("utf8")}catch(e){throw new s7(`解密凭证文件失败:${lc(e)}`)}}async set(e,t){var r;let n=await this.readOrCreateMasterKey(),o=eh.randomBytes(12),u=eh.createCipheriv(s9,n,o);u.setAAD(Buffer.from((r=e,`${s3}:${r}`),"utf8"));let a=Buffer.concat([u.update(t,"utf8"),u.final()]),s={version:1,algorithm:s9,iv:o.toString("base64url"),authTag:u.getAuthTag().toString("base64url"),ciphertext:a.toString("base64url")};await ln(this.credentialFilePath(e),`${JSON.stringify(s,null,2)}
30
30
  `)}async delete(e){try{await ee.unlink(this.credentialFilePath(e))}catch(e){if(!lD(e)||"ENOENT"!==e.code)throw new s7(`删除加密凭证文件失败:${lc(e)}`)}}async isFallbackAuthoritative(e){try{let t=await ee.readFile(this.authorityFilePath(e),"utf8"),r=JSON.parse(t);return 1===r.version&&"fallback"===r.authority}catch(e){if(lD(e)&&"ENOENT"===e.code)return!1;throw new s7(`读取登录凭证权威副本标记失败:${lc(e)}`)}}async markFallbackAuthoritative(e){await ln(this.authorityFilePath(e),`${JSON.stringify({version:1,authority:"fallback"},null,2)}
31
31
  `)}async clearFallbackAuthority(e){try{await ee.unlink(this.authorityFilePath(e))}catch(e){if(!lD(e)||"ENOENT"!==e.code)throw new s7(`清理登录凭证权威副本标记失败:${lc(e)}`)}}masterKeyPath(){return l.join(this.baseDir,"master.key")}credentialFilePath(e){let t=eh.createHash("sha256").update(e).digest("hex");return l.join(this.baseDir,"credentials",`${t}.json`)}authorityFilePath(e){let t=eh.createHash("sha256").update(e).digest("hex");return l.join(this.baseDir,"authorities",`${t}.json`)}async readMasterKey(){try{var e=await ee.readFile(this.masterKeyPath(),"utf8");let t=Buffer.from(e.trim(),"base64url");if(32!==t.length)throw new s7("无法读取本地登录凭证:密钥文件 master.key 的内容无法解析为 32 字节密钥。");return t}catch(e){if(lD(e)&&"ENOENT"===e.code)throw new s4;if(e instanceof s7)throw e;throw new s7(`无法读取用于解密本地登录凭证的密钥文件 master.key:${lc(e)}`)}}async readOrCreateMasterKey(){try{return await this.readMasterKey()}catch(e){if(!(e instanceof s4))throw e}let e=eh.randomBytes(32);try{return await lo(this.masterKeyPath(),`${e.toString("base64url")}
32
32
  `)?e:this.readMasterKey()}catch(e){throw new s7(`无法保存用于加密本地登录凭证的密钥文件 master.key:${lc(e)}`)}}}class lt{async get(e){try{let{stdout:t}=await s8("security",["find-generic-password","-a",e,"-s",s3,"-w"]);return String(t).replace(/\n$/,"")}catch(e){if(lu(e))return;throw new s7(`从 macOS 钥匙串读取登录凭证失败:${lc(e)}`)}}async set(e,t){try{await s8("security",["add-generic-password","-a",e,"-s",s3,"-w",t,"-U"])}catch(e){throw new s7(`向 macOS 钥匙串写入登录凭证失败:${lc(e)}`)}}async delete(e){try{await s8("security",["delete-generic-password","-a",e,"-s",s3])}catch(e){if(lu(e))return;throw new s7(`从 macOS 钥匙串删除登录凭证失败:${lc(e)}`)}}}class lr{async get(e){try{let{stdout:t}=await s8("secret-tool",["lookup","service",s3,"account",e]);return String(t).replace(/\n$/,"")}catch(e){if(la(e))return;throw new s7(`从 Secret Service 读取登录凭证失败:${lc(e)}`)}}async set(e,t){try{var r,n,o;await (r="secret-tool",n=["store","--label","Doubao Open CLI 登录凭证","service",s3,"account",e],o=t,new Promise((e,t)=>{let u=g(r,n,{stdio:["pipe","ignore","pipe"]}),a="";u.stderr.setEncoding("utf8"),u.stderr.on("data",e=>{a+=String(e)}),u.on("error",t),u.on("close",n=>{0===n?e():t(Error(a.trim()||`${r} 已退出,退出码为 ${n}`))}),u.stdin.end(o)}))}catch(e){throw new s7(`向 Secret Service 写入登录凭证失败:${lc(e)}`)}}async delete(e){try{await s8("secret-tool",["clear","service",s3,"account",e])}catch(e){if(la(e))return;throw new s7(`从 Secret Service 删除登录凭证失败:${lc(e)}`)}}}async function ln(e,t){let r=l.dirname(e);await ee.mkdir(r,{recursive:!0,mode:448}),"win32"!==process.platform&&await ee.chmod(r,448);let n=l.join(r,`.${l.basename(e)}.${process.pid}.${Date.now()}.tmp`);try{await ee.writeFile(n,t,{mode:384,flag:"wx"}),"win32"!==process.platform&&await ee.chmod(n,384),await ee.rename(n,e),"win32"!==process.platform&&await ee.chmod(e,384)}finally{try{await ee.unlink(n)}catch{}}}async function lo(e,t){let r=l.dirname(e);await ee.mkdir(r,{recursive:!0,mode:448}),"win32"!==process.platform&&await ee.chmod(r,448);let n=l.join(r,`.${l.basename(e)}.${process.pid}.${Date.now()}.${eh.randomBytes(8).toString("hex")}.tmp`);try{await ee.writeFile(n,t,{mode:384,flag:"wx"}),"win32"!==process.platform&&await ee.chmod(n,384);try{return await ee.link(n,e),"win32"!==process.platform&&await ee.chmod(e,384),!0}catch(e){if(lD(e)&&"EEXIST"===e.code)return!1;throw e}}finally{try{await ee.unlink(n)}catch{}}}function li(e){return"function"==typeof e.isFallbackAuthoritative&&"function"==typeof e.markFallbackAuthoritative&&"function"==typeof e.clearFallbackAuthority}function lu(e){let t=ls(e),r=ll(e);return(1===t||44===t)&&(r.includes("could not be found")||r.includes("The specified item could not be found"))}function la(e){let t=ls(e),r=ll(e);return 1===t&&(r.includes("could not be found")||r.includes("No matching items")||""===r.trim())}function ls(e){return"object"==typeof e&&null!==e&&"code"in e?e.code:void 0}function ll(e){return"object"==typeof e&&null!==e&&"stderr"in e?String(e.stderr??""):""}function lD(e){return e instanceof Error&&"code"in e}function lc(e){if("object"==typeof e&&null!==e&&"stderr"in e){let t=String(e.stderr??"").trim();if(t)return t}return e instanceof Error&&e.message?e.message:String(e)}class ld extends Error{constructor(e,t){super(e),this.code=t,this.name="AuthError"}}class lp extends ld{constructor(e="尚未登录,请运行 dbx auth login 完成登录。"){super(e,"NOT_LOGGED_IN"),this.name="NotLoggedInError"}}class lf extends ld{constructor(e="登录凭证已过期,请运行 dbx auth login 重新登录。"){super(e,"TOKEN_EXPIRED"),this.name="TokenExpiredError"}}class lh extends ld{constructor(e,t="DEVICE_AUTH_FAILED",r={}){super(e,t),this.name="DeviceAuthError",this.logId=r.logId}}async function lm(e,t={}){let r,n=process.env.DBX_ACCESS_TOKEN?.trim()||void 0;if(n)return{accessToken:n,tokenType:"Bearer",expiresAt:0xf4865700,baseUrl:t.envTokenBaseUrl??""};let o=await lC(e);if(void 0===o)return lw(e,t);try{r=JSON.parse(o)}catch(e){return}if(lE(r)){if(!t.allowExpired&&lg(r))return void await ly(e,t);let n=await l_(t).get(r.credentialAccount);if(!n)throw new s7("已找到登录记录,但登录凭证缺失或无法访问。请在能够访问凭证存储的终端中重新运行 dbx auth login。");return{accessToken:n,tokenType:r.tokenType,expiresAt:r.expiresAt,baseUrl:r.baseUrl}}if(lF(r))return!t.allowExpired&&lg(r)?void await ly(e,t):(await lb(e,r,t),r)}async function lb(e,t,r={}){let n={version:2,storage:"keychain",credentialAccount:lv(e),tokenType:t.tokenType,expiresAt:t.expiresAt,baseUrl:t.baseUrl};await l_(r).set(n.credentialAccount,t.accessToken),await ee.mkdir(l.dirname(e),{recursive:!0,mode:448}),"win32"!==process.platform&&await ee.chmod(l.dirname(e),448);let o=`${e}.${process.pid}.${Date.now()}.tmp`;await ee.writeFile(o,`${JSON.stringify(n,null,2)}
package/dist/command~3.js CHANGED
@@ -1,2 +1,2 @@
1
- import{join as e,resolve as i}from"node:path";import{Option as t}from"commander";import{STANDARD_TEMPLATE_DIRECTORY as r,publicationTypeSchema as a,TEMPLATES_DIRECTORY as o,log as n,PUBLICATION_TYPE_LABELS as l,error_errorMessage as p,syncProjectSkill as s,TEMPLATE_SUFFIX as c,dist_he as f,dist_xe as u,projectNameSchema as m,collectHooks as y,dist_ve as d,dist_ye as w,PLUGIN_NAME_PLACEHOLDER as b,pD as _,isInteractive as h,getCurrentUser as S}from"./691.js";import{PluginProject as g,copySync as E}from"./plugin.js";import{ensureLogin as C}from"./command~1.js";import*as v from"node:fs";async function P(i,t){let{name:n,directory:l}=i,p=a.parse(String(i.options.type??"public").toUpperCase()),f=v.lstatSync(l,{throwIfNoEntry:!1});if(f&&(!f.isDirectory()||v.readdirSync(l).length>0))throw Error(`目标路径已存在且不是空目录:${l}`);let u=[e(import.meta.dirname,o,r)];for(let e of(u.push(...await y(t.prepareTemplates,i)),u))E(e,l);(function i(t,r){for(let a of v.readdirSync(t,{withFileTypes:!0})){let o=e(t,a.name),n=e(t,a.name.replaceAll(b,r));if(a.isDirectory())i(o,r);else if(a.isFile()&&a.name.endsWith(c)){n=n.slice(0,-c.length),v.writeFileSync(n,v.readFileSync(o,"utf8").replaceAll(b,r)),v.unlinkSync(o);continue}n!==o&&v.renameSync(o,n)}})(l,n),!0!==i.options.workbench&&v.mkdirSync(e(l,"skills"),{recursive:!0});let m=new g(l);await m.updatePublicationType(p),await s(m,t)}async function N(e,r,a){if(!0===r.app&&!0===r.workbench)throw Error("不能同时创建 app 和工作台,请分开创建");let o={...r},s=h(),c=!e;if(!e){if(!s)throw Error("请指定项目名称,例如 dbx init my-plugin");let i=await f({message:"项目名称",placeholder:"my-plugin",defaultValue:"my-plugin",validate:e=>m.safeParse(e||"my-plugin").error?.issues[0]?.message});if(_(i)){u("已取消创建。"),process.exitCode=130;return}e=i}let y=m.safeParse(e);if(!y.success)throw Error(`${y.error.issues[0].message}
2
- 有效名称示例:mcp-app-test`);if(void 0===o.type&&!0===o.app&&(o={...o,type:"public"}),!0!==o.app&&("enterprise"===o.type||void 0===o.type&&s)){let e;await C(s);let i=await S();if(!1===i.is_enterprise?e="当前账号不是企业账号,无法创建企业专属插件":i.is_enterprise_blocked?e="受企业管控限制,当前账号不允许创建企业专属插件":i.is_enterprise_publication_access||(e="当前账号没有创建企业插件权限,无法创建企业专属插件"),e){if("enterprise"===o.type)throw Error(e);n.info(`${e}。将创建公开项目`),o={...o,type:"public"}}}if(void 0===o.type&&s){let e=await d({message:"请选择发布类型,首次创建平台草稿后不可切换",options:[{value:"public",label:l.PUBLIC},{value:"enterprise",label:l.ENTERPRISE}],initialValue:"public"});if(_(e)){u("已取消创建。"),process.exitCode=130;return}o={...o,type:e}}o={...o,type:o.type??"public"};let b=i(e);if(c){let i={name:e,directory:b,options:o},r=a.initOptions.filter(({capability:e})=>"function"==typeof e?e(i):e).map(({flags:e,description:i})=>({value:new t(e).attributeName(),label:i}));if(r.length&&r.every(({value:e})=>void 0===o[e])){let e=await d({message:"请选择项目类型",options:[{value:"plugin",label:"普通插件"},...r],initialValue:"plugin"});if(_(e)){u("已取消创建。"),process.exitCode=130;return}o={...o,...Object.fromEntries(r.map(({value:i})=>[i,e===i]))}}for(let{flags:i,prompt:r}of a.initOptions){let a=new t(i).attributeName();if(!r||void 0!==o[a])continue;let n="function"==typeof r?r({name:e,directory:b,options:o}):r;if(!n)continue;let l=await w({message:n,initialValue:!1});if(_(l)){u("已取消创建。"),process.exitCode=130;return}o={...o,[a]:l}}}let g={name:e,directory:b,options:o};await P(g,a);let E=o.workbench?"定制工作台":o.app?"应用插件":"普通插件";for(let i of(n.success(`已创建${E}:${e}`),n.info(`发布类型:${"enterprise"===o.type?l.ENTERPRISE:l.PUBLIC}`),a.afterCreate))try{await i.callback(g)}catch(e){n.warn(`[${i.pluginName}] 项目已创建,后续处理失败:${p(e)}`)}}export{N as runInit};
1
+ import{join as e,resolve as i}from"node:path";import{Option as t}from"commander";import{STANDARD_TEMPLATE_DIRECTORY as r,publicationTypeSchema as a,TEMPLATES_DIRECTORY as o,log as n,PUBLICATION_TYPE_LABELS as p,error_errorMessage as l,syncProjectSkill as s,TEMPLATE_SUFFIX as c,dist_he as f,dist_xe as u,projectNameSchema as m,collectHooks as y,dist_ve as d,dist_ye as w,PLUGIN_NAME_PLACEHOLDER as _,pD as b,isInteractive as h,getCurrentUser as S}from"./691.js";import{PluginProject as g,copySync as E}from"./plugin.js";import{ensureLogin as C}from"./command~1.js";import*as v from"node:fs";async function P(i,t){let{name:n,directory:p}=i,l=a.parse(String(i.options.type??"public").toUpperCase()),f=v.lstatSync(p,{throwIfNoEntry:!1});if(f&&(!f.isDirectory()||v.readdirSync(p).length>0))throw Error(`目标路径已存在且不是空目录:${p}`);let u=[e(import.meta.dirname,o,r)];for(let e of(u.push(...await y(t.prepareTemplates,i)),u))E(e,p);(function i(t,r){for(let a of v.readdirSync(t,{withFileTypes:!0})){let o=e(t,a.name),n=e(t,a.name.replaceAll(_,r));if(a.isDirectory())i(o,r);else if(a.isFile()&&a.name.endsWith(c)){n=n.slice(0,-c.length),v.writeFileSync(n,v.readFileSync(o,"utf8").replaceAll(_,r)),v.unlinkSync(o);continue}n!==o&&v.renameSync(o,n)}})(p,n),!0!==i.options.workbench&&v.mkdirSync(e(p,"skills"),{recursive:!0});let m=new g(p);await m.updatePublicationType(l),await s(m,t)}async function N(e,r,a){if(!0===r.app&&!0===r.workbench)throw Error("不能同时创建 app 和工作台,请分开创建");let o={...r},s=h(),c=!e;if(!e){if(!s)throw Error("请指定项目名称,例如 dbx init my-plugin");let i=await f({message:"项目名称",placeholder:"my-plugin",defaultValue:"my-plugin",validate:e=>m.safeParse(e||"my-plugin").error?.issues[0]?.message});if(b(i)){u("已取消创建。"),process.exitCode=130;return}e=i}let y=m.safeParse(e);if(!y.success)throw Error(`${y.error.issues[0].message}
2
+ 有效名称示例:mcp-app-test`);if(void 0===o.type&&!0===o.app&&(o={...o,type:"public"}),!0!==o.app&&("enterprise"===o.type||void 0===o.type&&s)){let e;await C(s);let i=await S(),t=i.is_enterprise_blocked?!0===i.is_enterprise:i.is_enterprise_publication_access;if(!1===i.is_enterprise?e="当前账号不是企业账号,无法创建企业专属插件":t||(e="当前账号没有创建企业插件权限,无法创建企业专属插件"),e){if("enterprise"===o.type)throw Error(e);n.info(`${e}。将创建公开项目`),o={...o,type:"public"}}}if(void 0===o.type&&s){let e=await d({message:"请选择发布类型,首次创建平台草稿后不可切换",options:[{value:"public",label:p.PUBLIC},{value:"enterprise",label:p.ENTERPRISE}],initialValue:"public"});if(b(e)){u("已取消创建。"),process.exitCode=130;return}o={...o,type:e}}o={...o,type:o.type??"public"};let _=i(e);if(c){let i={name:e,directory:_,options:o},r=a.initOptions.filter(({capability:e})=>"function"==typeof e?e(i):e).map(({flags:e,description:i})=>({value:new t(e).attributeName(),label:i}));if(r.length&&r.every(({value:e})=>void 0===o[e])){let e=await d({message:"请选择项目类型",options:[{value:"plugin",label:"普通插件"},...r],initialValue:"plugin"});if(b(e)){u("已取消创建。"),process.exitCode=130;return}o={...o,...Object.fromEntries(r.map(({value:i})=>[i,e===i]))}}for(let{flags:i,prompt:r}of a.initOptions){let a=new t(i).attributeName();if(!r||void 0!==o[a])continue;let n="function"==typeof r?r({name:e,directory:_,options:o}):r;if(!n)continue;let p=await w({message:n,initialValue:!1});if(b(p)){u("已取消创建。"),process.exitCode=130;return}o={...o,[a]:p}}}let g={name:e,directory:_,options:o};await P(g,a);let E=o.workbench?"定制工作台":o.app?"应用插件":"普通插件";for(let i of(n.success(`已创建${E}:${e}`),n.info(`发布类型:${"enterprise"===o.type?p.ENTERPRISE:p.PUBLIC}`),a.afterCreate))try{await i.callback(g)}catch(e){n.warn(`[${i.pluginName}] 项目已创建,后续处理失败:${l(e)}`)}}export{N as runInit};
package/dist/draft.js CHANGED
@@ -1,2 +1,2 @@
1
- import{upsertPluginDraft as i,upsertWorkbenchDraft as a,VISIBILITY_TYPE_LABELS as t,resolvePublicationType as e,validateWorkbenchMaterial as r,log as o,validateMaterial as n,PUBLICATION_TYPE_LABELS as l,uploadPackage as p,projectIdentity as _}from"./691.js";import{withProgress as c}from"./progress.js";function s(i,a){if(i.passed)return;let t=i.issues?.map(i=>{let a=[i.path,i.field_path].filter(Boolean).join(":"),t=i.message||i.code||"未知问题";return`- ${a?`${a}:`:""}${t}`}).join("\n");throw Error(`${a}${t?`
2
- ${t}`:""}`)}async function d(d,u){let{project:w,options:y}=d,{name:$,id:f}=w.plugin,b=w.hasWorkbench,E=b?"定制工作台":"应用插件",h=f?await c("核对发布类型",()=>e(w)):await e(w),g=l[h];o.info(`发布类型:${g}${!f?";首次创建平台草稿后不可切换":""}`);let k={..._(w),publication_type:h},{version:m}=y,S=await c("打包项目",()=>w.pack({version:m,exclude:u})),A=`${$}-${Date.now()}.zip`,C=await c(`上传${E}包`,async()=>{let{package_id:i}=await p(A,S,{workbench:b});if(!i)throw Error("上传失败:服务端未返回 package_id");return i});await c("校验物料",async()=>{let i={package_id:C,...k,validate_list:["PACKAGE_PARSE"]};s(b?await r(i):await n(i),"物料校验未通过")});let D=await c("保存草稿",async()=>{let t=b?a:i,{draft:e}=await t({package_id:C,...k});if(!e?.name||!e.ability_id)throw Error(`草稿保存失败:服务端未返回${E}名称或 ID`);return{...e,ability_id:e.ability_id}}),K=D.ability_id;o.success(`${E} ID:${K}`);try{await w.updateManifest(({$schema:i,name:a,id:t,publicationType:e,...r})=>({$schema:i,name:a,id:K,publicationType:h,...r}))}catch(i){throw Error(`草稿已保存,但本地关联写入失败,请将 ID ${K} 和 publicationType ${h} 保存到 plugin.json`,{cause:i})}if("ENTERPRISE"===h){let i=D.visibility_config?.type,a=void 0===i?void 0:t[i];o.info(`草稿可见范围:${a??"由平台保存,首次默认仅本人"}`)}return{packageId:C,draft:D,isWorkbench:b,identity:{ability_id:K,publication_type:h}}}export{s as assertMaterialValidation,d as uploadDraft};
1
+ import{upsertPluginDraft as i,upsertWorkbenchDraft as a,VISIBILITY_TYPE_LABELS as t,resolvePublicationType as e,validateWorkbenchMaterial as r,log as o,validateMaterial as n,PUBLICATION_TYPE_LABELS as l,uploadPackage as p,projectIdentity as _,getCurrentUser as c}from"./691.js";import{withProgress as s}from"./progress.js";function d(i,a){if(i.passed)return;let t=i.issues?.map(i=>{let a=[i.path,i.field_path].filter(Boolean).join(":"),t=i.message||i.code||"未知问题";return`- ${a?`${a}:`:""}${t}`}).join("\n");throw Error(`${a}${t?`
2
+ ${t}`:""}`)}async function w(w,u){let{project:y,options:$}=w,{name:f,id:E}=y.plugin,b=y.hasWorkbench,h=b?"定制工作台":"应用插件",g=E?await s("核对发布类型",()=>e(y)):await e(y),k=l[g];if(o.info(`发布类型:${k}${!E?";首次创建平台草稿后不可切换":""}`),"ENTERPRISE"===g&&(await c()).is_enterprise_blocked)throw Error("受企业管控限制,当前账号不允许发布企业专属插件,请咨询企业管理员处理");let m={..._(y),publication_type:g},{version:R}=$,S=await s("打包项目",()=>y.pack({version:R,exclude:u})),P=`${f}-${Date.now()}.zip`,A=await s(`上传${h}包`,async()=>{let{package_id:i}=await p(P,S,{workbench:b});if(!i)throw Error("上传失败:服务端未返回 package_id");return i});await s("校验物料",async()=>{let i={package_id:A,...m,validate_list:["PACKAGE_PARSE"]};d(b?await r(i):await n(i),"物料校验未通过")});let C=await s("保存草稿",async()=>{let t=b?a:i,{draft:e}=await t({package_id:A,...m});if(!e?.name||!e.ability_id)throw Error(`草稿保存失败:服务端未返回${h}名称或 ID`);return{...e,ability_id:e.ability_id}}),D=C.ability_id;o.success(`${h} ID:${D}`);try{await y.updateManifest(({$schema:i,name:a,id:t,publicationType:e,...r})=>({$schema:i,name:a,id:D,publicationType:g,...r}))}catch(i){throw Error(`草稿已保存,但本地关联写入失败,请将 ID ${D} 和 publicationType ${g} 保存到 plugin.json`,{cause:i})}if("ENTERPRISE"===g){let i=C.visibility_config?.type,a=void 0===i?void 0:t[i];o.info(`草稿可见范围:${a??"由平台保存,首次默认仅本人"}`)}return{packageId:A,draft:C,isWorkbench:b,identity:{ability_id:D,publication_type:g}}}export{d as assertMaterialValidation,w as uploadDraft};
@@ -85,7 +85,7 @@ CLI 通过 `com.doubao/workbench/manifest.json` 识别工作台,初始化骨
85
85
  | `dbx init <name> --workbench` | 定制工作台骨架,目录见 [定制工作台](#定制工作台) |
86
86
  | `dbx init <name> --app` | 应用插件骨架:增加 App、本地商品搜索端工具、业务 Skill、页面和卡片 |
87
87
 
88
- 目标目录须不存在或为空。用 `--type public|enterprise` 明确发布类型;未指定时,`--app` 或非 TTY 默认使用 PUBLIC,其他交互场景按 CLI 提示选择。企业专属插件需要发布权限,暂不支持 App。交互模式可选择普通插件、应用插件或定制工作台。`--app` 和 `--workbench` 互斥。
88
+ 目标目录须不存在或为空。用 `--type public|enterprise` 明确发布类型;未指定时,`--app` 或非 TTY 默认使用 PUBLIC,其他交互场景按 CLI 提示选择。企业专属插件暂不支持 App。交互模式可选择普通插件、应用插件或定制工作台。`--app` 和 `--workbench` 互斥。
89
89
 
90
90
  ### 确定发布类型
91
91
 
@@ -99,7 +99,7 @@ CLI 通过 `com.doubao/workbench/manifest.json` 识别工作台,初始化骨
99
99
 
100
100
  通用插件与应用插件在首次创建平台草稿前确认尚未明确的类型;非交互初始化显式传 `--type public` 或 `--type enterprise`。同时要求 App 和企业专属时,确认改为公开插件还是移除 App。
101
101
 
102
- 企业专属创建失败时,按提示区分个人账号、企业管控限制和其他发布准入限制。显式指定 `--type enterprise` 时,先处理企业准入或由用户选择公开发布。
102
+ 受租户发布管控的企业账号可以创建企业专属普通插件或定制工作台,并用 `dbx dev` 安装到当前账号调试。
103
103
 
104
104
  ### 依赖与开发指引
105
105
 
@@ -21,6 +21,8 @@
21
21
 
22
22
  从 CLI 输出取得实际版本号与平台链接。部分步骤失败可能已有草稿或版本保存,按错误说明和平台入口核实后恢复。
23
23
 
24
+ 上传企业专属插件或工作台前,CLI 会检查当前账号的租户管控状态。命中管控时,在打包前停止;若服务端在保存草稿时拒绝,也会停止。向开发者转达实际提示,保留项目的企业专属类型。
25
+
24
26
  应用插件在非 TTY 模式生成预览后输出文本二维码和预览链接。上传成功不能替代 App 构建或预览成功。内容未变且预览链接仍对应目标版本时复用;内容变更或链接失效后按已有授权重新上传。预览状态未知时先查询,不自行改写链接。
25
27
 
26
28
  审核中服务端锁定当前草稿,`upload --version` 也受限制。等待审核结束后再上传,或在用户要求时撤回审核。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doubao-dev/cli",
3
- "version": "1.0.0-rc.12",
3
+ "version": "1.0.0-rc.14",
4
4
  "description": "Doubao Plugins CLI",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
@@ -36,9 +36,9 @@
36
36
  "ofetch": "1.5.1",
37
37
  "open": "10.1.0",
38
38
  "ora": "8.1.0",
39
- "@byted-doubao-apps/cli": "1.0.0-rc.12",
39
+ "@byted-doubao-apps/cli": "1.0.0-rc.14",
40
40
  "@doubao-dev/kit": "0.10.0",
41
- "@doubao-dev/plugin-app-dev": "1.0.0-rc.12",
41
+ "@doubao-dev/plugin-app-dev": "1.0.0-rc.14",
42
42
  "@rslib/core": "1.0.0-beta.1",
43
43
  "@types/node": "22.20.4",
44
44
  "@types/qrcode": "1.5.6",