@longzai-intelligence-agent-tools/cli 0.0.11 → 0.0.12
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/index.js +41 -40
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import{createRequire as e}from"node:module";import{existsSync as t}from"node:fs";import{basename as n,dirname as r,isAbsolute as i,join as a,resolve as o}from"node:path";import"node:url";import{AsyncLocalStorage as s}from"node:async_hooks";import c,{stdin as l,stdout as u}from"node:process";import{stripVTControlCharacters as d}from"node:util";import*as f from"node:readline";import p from"node:readline";import{Writable as m}from"node:stream";import{mkdir as h,rm as g,stat as _}from"node:fs/promises";var v=Object.create,y=Object.defineProperty,b=Object.getOwnPropertyDescriptor,x=Object.getOwnPropertyNames,S=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty,w=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),ee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=x(t),a=0,o=i.length,s;a<o;a++)s=i[a],!C.call(e,s)&&s!==n&&y(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=b(t,s))||r.enumerable});return e},
|
|
2
|
+
import{createRequire as e}from"node:module";import{existsSync as t}from"node:fs";import{basename as n,dirname as r,isAbsolute as i,join as a,resolve as o}from"node:path";import"node:url";import{AsyncLocalStorage as s}from"node:async_hooks";import c,{stdin as l,stdout as u}from"node:process";import{stripVTControlCharacters as d}from"node:util";import*as f from"node:readline";import p from"node:readline";import{Writable as m}from"node:stream";import{mkdir as h,rm as g,stat as _}from"node:fs/promises";var v=Object.create,y=Object.defineProperty,b=Object.getOwnPropertyDescriptor,x=Object.getOwnPropertyNames,S=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty,w=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),ee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=x(t),a=0,o=i.length,s;a<o;a++)s=i[a],!C.call(e,s)&&s!==n&&y(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=b(t,s))||r.enumerable});return e},te=(e,t,n)=>(n=e==null?{}:v(S(e)),ee(t||!e||!e.__esModule||!C.call(e,`default`)?y(n,`default`,{value:e,enumerable:!0}):n,e)),T=/* @__PURE__ */ e(import.meta.url),E=/* @__PURE__ */ w(((e,t)=>{let n=e=>e&&typeof e.message==`string`,r=e=>{if(!e)return;let t=e.cause;if(typeof t==`function`){let t=e.cause();return n(t)?t:void 0}return n(t)?t:void 0},i=(e,t)=>{if(!n(e))return``;let a=e.stack||``;if(t.has(e))return a+`
|
|
3
3
|
causes have become circular...`;let o=r(e);return o?(t.add(e),a+`
|
|
4
|
-
caused by: `+i(o,t)):a},a=e=>i(e,/* @__PURE__ */ new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?``:e.message||``;if(t.has(e))return a+`: ...`;let s=r(e);if(s){t.add(e);let n=typeof e.cause==`function`;return a+(n?``:`: `)+o(s,t,n)}return a};t.exports={isErrorLike:n,getErrorCause:r,stackWithCauses:a,messageWithCauses:e=>o(e,/* @__PURE__ */ new Set)}})),D=/* @__PURE__ */ w(((e,t)=>{let n=Symbol(`circular-ref-tag`),r=Symbol(`pino-raw-err-ref`),i=Object.create({},{type:{enumerable:!0,writable:!0,value:void 0},message:{enumerable:!0,writable:!0,value:void 0},stack:{enumerable:!0,writable:!0,value:void 0},aggregateErrors:{enumerable:!0,writable:!0,value:void 0},raw:{enumerable:!1,get:function(){return this[r]},set:function(e){this[r]=e}}});Object.defineProperty(i,r,{writable:!0,value:{}}),t.exports={pinoErrProto:i,pinoErrorSymbols:{seen:n,rawSymbol:r}}})),O=/* @__PURE__ */ w(((e,t)=>{t.exports=l;let{messageWithCauses:n,stackWithCauses:r,isErrorLike:i}=te(),{pinoErrProto:a,pinoErrorSymbols:o}=D(),{seen:s}=o,{toString:c}=Object.prototype;function l(e){if(!i(e))return e;e[s]=void 0;let t=Object.create(a);t.type=c.call(e.constructor)===`[object Function]`?e.constructor.name:e.name,t.message=n(e),t.stack=r(e),Array.isArray(e.errors)&&(t.aggregateErrors=e.errors.map(e=>l(e)));for(let n in e)if(t[n]===void 0){let r=e[n];i(r)?n!==`cause`&&!Object.prototype.hasOwnProperty.call(r,s)&&(t[n]=l(r)):t[n]=r}return delete e[s],t.raw=e,t}})),k=/* @__PURE__ */ w(((e,t)=>{t.exports=s;let{isErrorLike:n}=te(),{pinoErrProto:r,pinoErrorSymbols:i}=D(),{seen:a}=i,{toString:o}=Object.prototype;function s(e){if(!n(e))return e;e[a]=void 0;let t=Object.create(r);t.type=o.call(e.constructor)===`[object Function]`?e.constructor.name:e.name,t.message=e.message,t.stack=e.stack,Array.isArray(e.errors)&&(t.aggregateErrors=e.errors.map(e=>s(e))),n(e.cause)&&!Object.prototype.hasOwnProperty.call(e.cause,a)&&(t.cause=s(e.cause));for(let r in e)if(t[r]===void 0){let i=e[r];n(i)?Object.prototype.hasOwnProperty.call(i,a)||(t[r]=s(i)):t[r]=i}return delete e[a],t.raw=e,t}})),ne=/* @__PURE__ */ w(((e,t)=>{t.exports={mapHttpRequest:a,reqSerializer:i};let n=Symbol(`pino-raw-req-ref`),r=Object.create({},{id:{enumerable:!0,writable:!0,value:``},method:{enumerable:!0,writable:!0,value:``},url:{enumerable:!0,writable:!0,value:``},query:{enumerable:!0,writable:!0,value:``},params:{enumerable:!0,writable:!0,value:``},headers:{enumerable:!0,writable:!0,value:{}},remoteAddress:{enumerable:!0,writable:!0,value:``},remotePort:{enumerable:!0,writable:!0,value:``},raw:{enumerable:!1,get:function(){return this[n]},set:function(e){this[n]=e}}});Object.defineProperty(r,n,{writable:!0,value:{}});function i(e){let t=e.info||e.socket,n=Object.create(r);if(n.id=typeof e.id==`function`?e.id():e.id||(e.info?e.info.id:void 0),n.method=e.method,e.originalUrl)n.url=e.originalUrl;else{let t=e.path;n.url=typeof t==`string`?t:e.url?e.url.path||e.url:void 0}return e.query&&(n.query=e.query),e.params&&(n.params=e.params),n.headers=e.headers,n.remoteAddress=t&&t.remoteAddress,n.remotePort=t&&t.remotePort,n.raw=e.raw||e,n}function a(e){return{req:i(e)}}})),re=/* @__PURE__ */ w(((e,t)=>{t.exports={mapHttpResponse:a,resSerializer:i};let n=Symbol(`pino-raw-res-ref`),r=Object.create({},{statusCode:{enumerable:!0,writable:!0,value:0},headers:{enumerable:!0,writable:!0,value:``},raw:{enumerable:!1,get:function(){return this[n]},set:function(e){this[n]=e}}});Object.defineProperty(r,n,{writable:!0,value:{}});function i(e){let t=Object.create(r);return t.statusCode=e.headersSent?e.statusCode:null,t.headers=e.getHeaders?e.getHeaders():e._headers,t.raw=e,t}function a(e){return{res:i(e)}}})),ie=/* @__PURE__ */ w(((e,t)=>{let n=O(),r=k(),i=ne(),a=re();t.exports={err:n,errWithCause:r,mapHttpRequest:i.mapHttpRequest,mapHttpResponse:a.mapHttpResponse,req:i.reqSerializer,res:a.resSerializer,wrapErrorSerializer:function(e){return e===n?e:function(t){return e(n(t))}},wrapRequestSerializer:function(e){return e===i.reqSerializer?e:function(t){return e(i.reqSerializer(t))}},wrapResponseSerializer:function(e){return e===a.resSerializer?e:function(t){return e(a.resSerializer(t))}}}})),A=/* @__PURE__ */ w(((e,t)=>{function n(e,t){return t}t.exports=function(){let e=Error.prepareStackTrace;Error.prepareStackTrace=n;let t=(/* @__PURE__ */ Error()).stack;if(Error.prepareStackTrace=e,!Array.isArray(t))return;let r=t.slice(2),i=[];for(let e of r)e&&i.push(e.getFileName());return i}})),ae=/* @__PURE__ */ w(((e,t)=>{function n(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof Array){let t=[];for(let r=0;r<e.length;r++)t[r]=n(e[r]);return t}if(typeof e==`object`){let t=Object.create(Object.getPrototypeOf(e));for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=n(e[r]));return t}return e}function r(e){let t=[],n=``,r=!1,i=!1,a=``;for(let o=0;o<e.length;o++){let s=e[o];!r&&s===`.`?n&&=(t.push(n),``):s===`[`?(n&&=(t.push(n),``),r=!0):s===`]`&&r?(t.push(n),n=``,r=!1,i=!1):(s===`"`||s===`'`)&&r?i?s===a?(i=!1,a=``):n+=s:(i=!0,a=s):n+=s}return n&&t.push(n),t}function i(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){let n=t[e];if(typeof r!=`object`||!r||!(n in r)||typeof r[n]!=`object`||r[n]===null)return!1;r=r[n]}let i=t[t.length-1];if(i===`*`){if(Array.isArray(r))for(let e=0;e<r.length;e++)r[e]=n;else if(typeof r==`object`&&r)for(let e in r)Object.prototype.hasOwnProperty.call(r,e)&&(r[e]=n)}else typeof r==`object`&&r&&i in r&&Object.prototype.hasOwnProperty.call(r,i)&&(r[i]=n);return!0}function a(e,t){let n=e;for(let e=0;e<t.length-1;e++){let r=t[e];if(typeof n!=`object`||!n||!(r in n)||typeof n[r]!=`object`||n[r]===null)return!1;n=n[r]}let r=t[t.length-1];if(r===`*`){if(Array.isArray(n))for(let e=0;e<n.length;e++)n[e]=void 0;else if(typeof n==`object`&&n)for(let e in n)Object.prototype.hasOwnProperty.call(n,e)&&delete n[e]}else typeof n==`object`&&n&&r in n&&Object.prototype.hasOwnProperty.call(n,r)&&delete n[r];return!0}let o=Symbol(`PATH_NOT_FOUND`);function s(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n||!n||!(e in n))return o;n=n[e]}return n}function c(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n||!n)return;n=n[e]}return n}function l(e,t,n,c=!1){for(let l of t){let t=r(l);if(t.includes(`*`))u(e,t,n,l,c);else if(c)a(e,t);else{let r=s(e,t);if(r===o)continue;i(e,t,typeof n==`function`?n(r,t):n)}}}function u(e,t,n,r,i=!1){let a=t.indexOf(`*`);if(a===t.length-1){let r=t.slice(0,-1),a=e;for(let e of r){if(typeof a!=`object`||!a||!a)return;a=a[e]}if(Array.isArray(a)){if(i)for(let e=0;e<a.length;e++)a[e]=void 0;else for(let e=0;e<a.length;e++){let t=[...r,e.toString()],i=typeof n==`function`?n(a[e],t):n;a[e]=i}}else if(typeof a==`object`&&a){if(i){let e=[];for(let t in a)Object.prototype.hasOwnProperty.call(a,t)&&e.push(t);for(let t of e)delete a[t]}else for(let e in a){let t=[...r,e],i=typeof n==`function`?n(a[e],t):n;a[e]=i}}}else d(e,t,n,a,r,i)}function d(e,t,n,r,o,s=!1){let l=t.slice(0,r),d=t.slice(r+1),f=[];function p(e,t){if(t===l.length){if(Array.isArray(e))for(let n=0;n<e.length;n++)f[t]=n.toString(),p(e[n],t+1);else if(typeof e==`object`&&e)for(let n in e)f[t]=n,p(e[n],t+1)}else if(t<l.length){let n=l[t];e&&typeof e==`object`&&e&&n in e&&(f[t]=n,p(e[n],t+1))}else if(d.includes(`*`))u(e,d,typeof n==`function`?(e,r)=>n(e,[...f.slice(0,t),...r]):n,o,s);else if(s)a(e,d);else{let r=typeof n==`function`?n(c(e,d),[...f.slice(0,t),...d]):n;i(e,d,r)}}if(l.length===0)p(e,0);else{let t=e;for(let e=0;e<l.length;e++){let n=l[e];if(typeof t!=`object`||!t||!t)return;t=t[n],f[e]=n}t!=null&&p(t,l.length)}}function f(e){if(e.length===0)return null;let t=/* @__PURE__ */ new Map;for(let n of e){let e=r(n),i=t;for(let t=0;t<e.length;t++){let n=e[t];i.has(n)||i.set(n,/* @__PURE__ */ new Map),i=i.get(n)}}return t}function p(e,t){if(!t)return e;function n(e,t,r=0){if(!t||t.size===0||typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let r=[];for(let i=0;i<e.length;i++){let a=i.toString();t.has(a)||t.has(`*`)?r[i]=n(e[i],t.get(a)||t.get(`*`)):r[i]=e[i]}return r}let i=Object.create(Object.getPrototypeOf(e));for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=t.has(r)||t.has(`*`)?n(e[r],t.get(r)||t.get(`*`)):e[r]);return i}return n(e,t)}function m(e){if(typeof e!=`string`)throw Error(`Paths must be (non-empty) strings`);if(e===``)throw Error(`Invalid redaction path ()`);if(e.includes(`..`)||e.includes(`,`))throw Error(`Invalid redaction path (${e})`);let t=0,n=!1,r=``;for(let i=0;i<e.length;i++){let a=e[i];if((a===`"`||a===`'`)&&t>0)n?a===r&&(n=!1,r=``):(n=!0,r=a);else if(a===`[`&&!n)t++;else if(a===`]`&&!n&&(t--,t<0))throw Error(`Invalid redaction path (${e})`)}if(t!==0)throw Error(`Invalid redaction path (${e})`)}function h(e){if(!Array.isArray(e))throw TypeError(`paths must be an array`);for(let t of e)m(t)}function g(e={}){let{paths:t=[],censor:r=`[REDACTED]`,serialize:i=JSON.stringify,strict:a=!0,remove:o=!1}=e;h(t);let s=f(t);return function(e){if(a&&(typeof e!=`object`||!e)&&(typeof e!=`object`||!e))return i?i(e):e;let c=p(e,s),u=e,d=r;return typeof r==`function`&&(d=r),l(c,t,d,o),i===!1?(c.restore=function(){return n(u)},c):typeof i==`function`?i(c):JSON.stringify(c)}}t.exports=g})),oe=/* @__PURE__ */ w(((e,t)=>{let n=Symbol(`pino.setLevel`),r=Symbol(`pino.getLevel`),i=Symbol(`pino.levelVal`),a=Symbol(`pino.levelComp`),o=Symbol(`pino.useLevelLabels`),s=Symbol(`pino.useOnlyCustomLevels`),c=Symbol(`pino.mixin`),l=Symbol(`pino.lsCache`),u=Symbol(`pino.chindings`),d=Symbol(`pino.asJson`),f=Symbol(`pino.write`),p=Symbol(`pino.redactFmt`),m=Symbol(`pino.time`),h=Symbol(`pino.timeSliceIndex`),g=Symbol(`pino.stream`),_=Symbol(`pino.stringify`),v=Symbol(`pino.stringifySafe`),y=Symbol(`pino.stringifiers`),b=Symbol(`pino.end`),x=Symbol(`pino.formatOpts`),S=Symbol(`pino.messageKey`),C=Symbol(`pino.errorKey`),w=Symbol(`pino.nestedKey`),ee=Symbol(`pino.nestedKeyStr`),T=Symbol(`pino.mixinMergeStrategy`),E=Symbol(`pino.msgPrefix`),te=Symbol(`pino.wildcardFirst`),D=Symbol.for(`pino.serializers`),O=Symbol.for(`pino.formatters`),k=Symbol.for(`pino.hooks`);t.exports={setLevelSym:n,getLevelSym:r,levelValSym:i,levelCompSym:a,useLevelLabelsSym:o,mixinSym:c,lsCacheSym:l,chindingsSym:u,asJsonSym:d,writeSym:f,serializersSym:D,redactFmtSym:p,timeSym:m,timeSliceIndexSym:h,streamSym:g,stringifySym:_,stringifySafeSym:v,stringifiersSym:y,endSym:b,formatOptsSym:x,messageKeySym:S,errorKeySym:C,nestedKeySym:w,wildcardFirstSym:te,needsMetadataGsym:Symbol.for(`pino.metadata`),useOnlyCustomLevelsSym:s,formattersSym:O,hooksSym:k,nestedKeyStrSym:ee,mixinMergeStrategySym:T,msgPrefixSym:E}})),se=/* @__PURE__ */ w(((e,t)=>{let n=ae(),{redactFmtSym:r,wildcardFirstSym:i}=oe(),a=/[^.[\]]+|\[([^[\]]*?)\]/g,o=`[Redacted]`;function s(e,t){let{paths:o,censor:s,remove:l}=c(e),u=o.reduce((e,t)=>{a.lastIndex=0;let n=a.exec(t),r=a.exec(t),o=n[1]===void 0?n[0]:n[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/,`$1`);if(o===`*`&&(o=i),r===null)return e[o]=null,e;if(e[o]===null)return e;let{index:s}=r,c=`${t.substr(s,t.length-1)}`;return e[o]=e[o]||[],o!==i&&e[o].length===0&&e[o].push(...e[i]||[]),o===i&&Object.keys(e).forEach(function(t){e[t]&&e[t].push(c)}),e[o].push(c),e},{}),d={[r]:n({paths:o,censor:s,serialize:t,strict:!1,remove:l})},f=(...e)=>t(typeof s==`function`?s(...e):s);return[...Object.keys(u),...Object.getOwnPropertySymbols(u)].reduce((e,r)=>{if(u[r]===null)e[r]=e=>f(e,[r]);else{let i=typeof s==`function`?(e,t)=>s(e,[r,...t]):s;e[r]=n({paths:u[r],censor:i,serialize:t,strict:!1,remove:l})}return e},d)}function c(e){if(Array.isArray(e))return e={paths:e,censor:o},e;let{paths:t,censor:n=o,remove:r}=e;if(Array.isArray(t)===!1)throw Error(`pino – redact must contain an array of strings`);return r===!0&&(n=void 0),{paths:t,censor:n,remove:r}}t.exports=s})),j=/* @__PURE__ */ w(((e,t)=>{let n=()=>``,r=()=>`,"time":${Date.now()}`,i=()=>`,"time":${Math.round(Date.now()/1e3)}`,a=()=>`,"time":"${new Date(Date.now()).toISOString()}"`,o=1000000000n,s=BigInt(Date.now())*1000000n,c=process.hrtime.bigint();t.exports={nullTime:n,epochTime:r,unixTime:i,isoTime:a,isoTimeNano:()=>{let e=process.hrtime.bigint()-c,t=s+e,n=t/o,r=t%o,i=Number(n*1000n+r/1000000n),a=new Date(i);return`,"time":"${a.getUTCFullYear()}-${(a.getUTCMonth()+1).toString().padStart(2,`0`)}-${a.getUTCDate().toString().padStart(2,`0`)}T${a.getUTCHours().toString().padStart(2,`0`)}:${a.getUTCMinutes().toString().padStart(2,`0`)}:${a.getUTCSeconds().toString().padStart(2,`0`)}.${r.toString().padStart(9,`0`)}Z"`}}})),ce=/* @__PURE__ */ w(((e,t)=>{function n(e){try{return JSON.stringify(e)}catch{return`"[Circular]"`}}t.exports=r;function r(e,t,r){var i=r&&r.stringify||n,a=1;if(typeof e==`object`&&e){var o=t.length+a;if(o===1)return e;var s=Array(o);s[0]=i(e);for(var c=1;c<o;c++)s[c]=i(t[c]);return s.join(` `)}if(typeof e!=`string`)return e;var l=t.length;if(l===0)return e;for(var u=``,d=1-a,f=-1,p=e&&e.length||0,m=0;m<p;){if(e.charCodeAt(m)===37&&m+1<p){switch(f=f>-1?f:0,e.charCodeAt(m+1)){case 100:case 102:if(d>=l||t[d]==null)break;f<m&&(u+=e.slice(f,m)),u+=Number(t[d]),f=m+2,m++;break;case 105:if(d>=l||t[d]==null)break;f<m&&(u+=e.slice(f,m)),u+=Math.floor(Number(t[d])),f=m+2,m++;break;case 79:case 111:case 106:if(d>=l||t[d]===void 0)break;f<m&&(u+=e.slice(f,m));var h=typeof t[d];if(h===`string`){u+=`'`+t[d]+`'`,f=m+2,m++;break}if(h===`function`){u+=t[d].name||`<anonymous>`,f=m+2,m++;break}u+=i(t[d]),f=m+2,m++;break;case 115:if(d>=l)break;f<m&&(u+=e.slice(f,m)),u+=String(t[d]),f=m+2,m++;break;case 37:f<m&&(u+=e.slice(f,m)),u+=`%`,f=m+2,m++,d--}++d}++m}return f===-1?e:(f<p&&(u+=e.slice(f)),u)}})),le=/* @__PURE__ */ w(((e,t)=>{if(typeof SharedArrayBuffer<`u`&&typeof Atomics<`u`){let e=new Int32Array(new SharedArrayBuffer(4));function n(t){if(!(t>0&&t<1/0))throw typeof t!=`number`&&typeof t!=`bigint`?TypeError(`sleep: ms must be a number`):RangeError(`sleep: ms must be a number that is greater than 0 but less than Infinity`);Atomics.wait(e,0,0,Number(t))}t.exports=n}else{function e(e){if(!(e>0&&e<1/0))throw typeof e!=`number`&&typeof e!=`bigint`?TypeError(`sleep: ms must be a number`):RangeError(`sleep: ms must be a number that is greater than 0 but less than Infinity`);let t=Date.now()+Number(e);for(;t>Date.now(););}t.exports=e}})),ue=/* @__PURE__ */ w(((e,t)=>{let n=E(`fs`),r=E(`events`),i=E(`util`).inherits,a=E(`path`),o=le(),s=E(`assert`),c=Buffer.allocUnsafe(0),l=`buffer`,u=`utf8`,[d,f]=(process.versions.node||`0.0`).split(`.`).map(Number),p=d>=22&&f>=7;function m(e,t){t._opening=!0,t._writing=!0,t._asyncDrainScheduled=!1;function r(n,r){if(n){t._reopening=!1,t._writing=!1,t._opening=!1,t.sync?process.nextTick(()=>{t.listenerCount(`error`)>0&&t.emit(`error`,n)}):t.emit(`error`,n);return}let i=t._reopening;t.fd=r,t.file=e,t._reopening=!1,t._opening=!1,t._writing=!1,t.sync?process.nextTick(()=>t.emit(`ready`)):t.emit(`ready`),!t.destroyed&&(!t._writing&&t._len>t.minLength||t._flushPending?t._actualWrite():i&&process.nextTick(()=>t.emit(`drain`)))}let i=t.append?`a`:`w`,o=t.mode;if(t.sync)try{t.mkdir&&n.mkdirSync(a.dirname(e),{recursive:!0}),r(null,n.openSync(e,i,o))}catch(e){throw r(e),e}else t.mkdir?n.mkdir(a.dirname(e),{recursive:!0},t=>{if(t)return r(t);n.open(e,i,o,r)}):n.open(e,i,o,r)}function h(e){if(!(this instanceof h))return new h(e);let{fd:t,dest:r,minLength:i,maxLength:a,maxWrite:s,periodicFlush:d,sync:f,append:p=!0,mkdir:v,retryEAGAIN:x,fsync:E,contentMode:O,mode:k}=e||{};t||=r,this._len=0,this.fd=-1,this._bufs=[],this._lens=[],this._writing=!1,this._ending=!1,this._reopening=!1,this._asyncDrainScheduled=!1,this._flushPending=!1,this._hwm=Math.max(i||0,16387),this.file=null,this.destroyed=!1,this.minLength=i||0,this.maxLength=a||0,this.maxWrite=s||16384,this._periodicFlush=d||0,this._periodicFlushTimer=void 0,this.sync=f||!1,this.writable=!0,this._fsync=E||!1,this.append=p||!1,this.mode=k,this.retryEAGAIN=x||(()=>!0),this.mkdir=v||!1;let ne,re;if(O===l)this._writingBuf=c,this.write=b,this.flush=C,this.flushSync=ee,this._actualWrite=te,ne=()=>n.writeSync(this.fd,this._writingBuf),re=()=>n.write(this.fd,this._writingBuf,this.release);else if(O===void 0||O===u)this._writingBuf=``,this.write=y,this.flush=S,this.flushSync=w,this._actualWrite=T,ne=()=>Buffer.isBuffer(this._writingBuf)?n.writeSync(this.fd,this._writingBuf):n.writeSync(this.fd,this._writingBuf,`utf8`),re=()=>Buffer.isBuffer(this._writingBuf)?n.write(this.fd,this._writingBuf,this.release):n.write(this.fd,this._writingBuf,`utf8`,this.release);else throw Error(`SonicBoom supports "${u}" and "${l}", but passed ${O}`);if(typeof t==`number`)this.fd=t,process.nextTick(()=>this.emit(`ready`));else if(typeof t==`string`)m(t,this);else throw Error(`SonicBoom supports only file descriptors and files`);if(this.minLength>=this.maxWrite)throw Error(`minLength should be smaller than maxWrite (${this.maxWrite})`);this.release=(e,t)=>{if(e){if((e.code===`EAGAIN`||e.code===`EBUSY`)&&this.retryEAGAIN(e,this._writingBuf.length,this._len-this._writingBuf.length)){if(this.sync)try{o(100),this.release(void 0,0)}catch(e){this.release(e)}else setTimeout(re,100)}else this._writing=!1,this.emit(`error`,e);return}this.emit(`write`,t);let r=g(this._writingBuf,this._len,t);if(this._len=r.len,this._writingBuf=r.writingBuf,this._writingBuf.length){if(!this.sync){re();return}try{do{let e=ne(),t=g(this._writingBuf,this._len,e);this._len=t.len,this._writingBuf=t.writingBuf}while(this._writingBuf.length)}catch(e){this.release(e);return}}this._fsync&&n.fsyncSync(this.fd);let i=this._len;this._reopening?(this._writing=!1,this._reopening=!1,this.reopen()):i>this.minLength?this._actualWrite():this._ending?i>0?this._actualWrite():(this._writing=!1,D(this)):(this._writing=!1,this.sync?this._asyncDrainScheduled||(this._asyncDrainScheduled=!0,process.nextTick(_,this)):this.emit(`drain`))},this.on(`newListener`,function(e){e===`drain`&&(this._asyncDrainScheduled=!1)}),this._periodicFlush!==0&&(this._periodicFlushTimer=setInterval(()=>this.flush(null),this._periodicFlush),this._periodicFlushTimer.unref())}function g(e,t,n){return typeof e==`string`&&(e=Buffer.from(e)),t=Math.max(t-n,0),e=e.subarray(n),{writingBuf:e,len:t}}function _(e){e.listenerCount(`drain`)>0&&(e._asyncDrainScheduled=!1,e.emit(`drain`))}i(h,r);function v(e,t){return e.length===0?c:e.length===1?e[0]:Buffer.concat(e,t)}function y(e){if(this.destroyed)throw Error(`SonicBoom destroyed`);e=``+e;let t=Buffer.byteLength(e),n=this._len+t,r=this._bufs;return this.maxLength&&n>this.maxLength?(this.emit(`drop`,e),this._len<this._hwm):(r.length===0||Buffer.byteLength(r[r.length-1])+t>this.maxWrite?r.push(e):r[r.length-1]+=e,this._len=n,!this._writing&&this._len>=this.minLength&&this._actualWrite(),this._len<this._hwm)}function b(e){if(this.destroyed)throw Error(`SonicBoom destroyed`);let t=this._len+e.length,n=this._bufs,r=this._lens;return this.maxLength&&t>this.maxLength?(this.emit(`drop`,e),this._len<this._hwm):(n.length===0||r[r.length-1]+e.length>this.maxWrite?(n.push([e]),r.push(e.length)):(n[n.length-1].push(e),r[r.length-1]+=e.length),this._len=t,!this._writing&&this._len>=this.minLength&&this._actualWrite(),this._len<this._hwm)}function x(e){this._flushPending=!0;let t=()=>{if(this._fsync)this._flushPending=!1,e();else try{n.fsync(this.fd,t=>{this._flushPending=!1,e(t)})}catch(t){e(t)}this.off(`error`,r)},r=n=>{this._flushPending=!1,e(n),this.off(`drain`,t)};this.once(`drain`,t),this.once(`error`,r)}function S(e){if(e!=null&&typeof e!=`function`)throw Error(`flush cb must be a function`);if(this.destroyed){let t=/* @__PURE__ */ Error(`SonicBoom destroyed`);if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}e&&x.call(this,e),!this._writing&&(this._bufs.length===0&&this._bufs.push(``),this._actualWrite())}function C(e){if(e!=null&&typeof e!=`function`)throw Error(`flush cb must be a function`);if(this.destroyed){let t=/* @__PURE__ */ Error(`SonicBoom destroyed`);if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}e&&x.call(this,e),!this._writing&&(this._bufs.length===0&&(this._bufs.push([]),this._lens.push(0)),this._actualWrite())}h.prototype.reopen=function(e){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this._opening){this.once(`ready`,()=>{this.reopen(e)});return}if(this._ending)return;if(!this.file)throw Error(`Unable to reopen a file descriptor, you must pass a file to SonicBoom`);if(e&&(this.file=e),this._reopening=!0,this._writing)return;let t=this.fd;this.once(`ready`,()=>{t!==this.fd&&n.close(t,e=>{if(e)return this.emit(`error`,e)})}),m(this.file,this)},h.prototype.end=function(){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this._opening){this.once(`ready`,()=>{this.end()});return}this._ending||(this._ending=!0,!this._writing&&(this._len>0&&this.fd>=0?this._actualWrite():D(this)))};function w(){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this.fd<0)throw Error(`sonic boom is not ready yet`);!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift(this._writingBuf),this._writingBuf=``);let e=``;for(;this._bufs.length||e.length;){e.length<=0&&(e=this._bufs[0]);try{let t=Buffer.isBuffer(e)?n.writeSync(this.fd,e):n.writeSync(this.fd,e,`utf8`),r=g(e,this._len,t);e=r.writingBuf,this._len=r.len,e.length<=0&&this._bufs.shift()}catch(t){if((t.code===`EAGAIN`||t.code===`EBUSY`)&&!this.retryEAGAIN(t,e.length,this._len-e.length))throw t;o(100)}}try{n.fsyncSync(this.fd)}catch{}}function ee(){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this.fd<0)throw Error(`sonic boom is not ready yet`);!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift([this._writingBuf]),this._writingBuf=c);let e=c;for(;this._bufs.length||e.length;){e.length<=0&&(e=v(this._bufs[0],this._lens[0]));try{let t=n.writeSync(this.fd,e);e=e.subarray(t),this._len=Math.max(this._len-t,0),e.length<=0&&(this._bufs.shift(),this._lens.shift())}catch(t){if((t.code===`EAGAIN`||t.code===`EBUSY`)&&!this.retryEAGAIN(t,e.length,this._len-e.length))throw t;o(100)}}}h.prototype.destroy=function(){this.destroyed||D(this)};function T(){let e=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:this._bufs.shift()||``,this.sync)try{e(null,Buffer.isBuffer(this._writingBuf)?n.writeSync(this.fd,this._writingBuf):n.writeSync(this.fd,this._writingBuf,`utf8`))}catch(t){e(t)}else n.write(this.fd,this._writingBuf,e)}function te(){let e=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:v(this._bufs.shift(),this._lens.shift()),this.sync)try{e(null,n.writeSync(this.fd,this._writingBuf))}catch(t){e(t)}else p&&(this._writingBuf=Buffer.from(this._writingBuf)),n.write(this.fd,this._writingBuf,e)}function D(e){if(e.fd===-1){e.once(`ready`,D.bind(null,e));return}e._periodicFlushTimer!==void 0&&clearInterval(e._periodicFlushTimer),e.destroyed=!0,e._bufs=[],e._lens=[],s(typeof e.fd==`number`,`sonic.fd must be a number, got ${typeof e.fd}`);try{n.fsync(e.fd,t)}catch{}function t(){e.fd!==1&&e.fd!==2?n.close(e.fd,r):r()}function r(t){if(t){e.emit(`error`,t);return}e._ending&&!e._writing&&e.emit(`finish`),e.emit(`close`)}}h.SonicBoom=h,h.default=h,t.exports=h})),de=/* @__PURE__ */ w(((e,t)=>{let n={exit:[],beforeExit:[]},r={exit:c,beforeExit:l},i;function a(){i===void 0&&(i=new FinalizationRegistry(d))}function o(e){n[e].length>0||process.on(e,r[e])}function s(e){n[e].length>0||(process.removeListener(e,r[e]),n.exit.length===0&&n.beforeExit.length===0&&(i=void 0))}function c(){u(`exit`)}function l(){u(`beforeExit`)}function u(e){for(let t of n[e]){let n=t.deref(),r=t.fn;
|
|
4
|
+
caused by: `+i(o,t)):a},a=e=>i(e,/* @__PURE__ */ new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?``:e.message||``;if(t.has(e))return a+`: ...`;let s=r(e);if(s){t.add(e);let n=typeof e.cause==`function`;return a+(n?``:`: `)+o(s,t,n)}return a};t.exports={isErrorLike:n,getErrorCause:r,stackWithCauses:a,messageWithCauses:e=>o(e,/* @__PURE__ */ new Set)}})),D=/* @__PURE__ */ w(((e,t)=>{let n=Symbol(`circular-ref-tag`),r=Symbol(`pino-raw-err-ref`),i=Object.create({},{type:{enumerable:!0,writable:!0,value:void 0},message:{enumerable:!0,writable:!0,value:void 0},stack:{enumerable:!0,writable:!0,value:void 0},aggregateErrors:{enumerable:!0,writable:!0,value:void 0},raw:{enumerable:!1,get:function(){return this[r]},set:function(e){this[r]=e}}});Object.defineProperty(i,r,{writable:!0,value:{}}),t.exports={pinoErrProto:i,pinoErrorSymbols:{seen:n,rawSymbol:r}}})),O=/* @__PURE__ */ w(((e,t)=>{t.exports=l;let{messageWithCauses:n,stackWithCauses:r,isErrorLike:i}=E(),{pinoErrProto:a,pinoErrorSymbols:o}=D(),{seen:s}=o,{toString:c}=Object.prototype;function l(e){if(!i(e))return e;e[s]=void 0;let t=Object.create(a);t.type=c.call(e.constructor)===`[object Function]`?e.constructor.name:e.name,t.message=n(e),t.stack=r(e),Array.isArray(e.errors)&&(t.aggregateErrors=e.errors.map(e=>l(e)));for(let n in e)if(t[n]===void 0){let r=e[n];i(r)?n!==`cause`&&!Object.prototype.hasOwnProperty.call(r,s)&&(t[n]=l(r)):t[n]=r}return delete e[s],t.raw=e,t}})),k=/* @__PURE__ */ w(((e,t)=>{t.exports=s;let{isErrorLike:n}=E(),{pinoErrProto:r,pinoErrorSymbols:i}=D(),{seen:a}=i,{toString:o}=Object.prototype;function s(e){if(!n(e))return e;e[a]=void 0;let t=Object.create(r);t.type=o.call(e.constructor)===`[object Function]`?e.constructor.name:e.name,t.message=e.message,t.stack=e.stack,Array.isArray(e.errors)&&(t.aggregateErrors=e.errors.map(e=>s(e))),n(e.cause)&&!Object.prototype.hasOwnProperty.call(e.cause,a)&&(t.cause=s(e.cause));for(let r in e)if(t[r]===void 0){let i=e[r];n(i)?Object.prototype.hasOwnProperty.call(i,a)||(t[r]=s(i)):t[r]=i}return delete e[a],t.raw=e,t}})),ne=/* @__PURE__ */ w(((e,t)=>{t.exports={mapHttpRequest:a,reqSerializer:i};let n=Symbol(`pino-raw-req-ref`),r=Object.create({},{id:{enumerable:!0,writable:!0,value:``},method:{enumerable:!0,writable:!0,value:``},url:{enumerable:!0,writable:!0,value:``},query:{enumerable:!0,writable:!0,value:``},params:{enumerable:!0,writable:!0,value:``},headers:{enumerable:!0,writable:!0,value:{}},remoteAddress:{enumerable:!0,writable:!0,value:``},remotePort:{enumerable:!0,writable:!0,value:``},raw:{enumerable:!1,get:function(){return this[n]},set:function(e){this[n]=e}}});Object.defineProperty(r,n,{writable:!0,value:{}});function i(e){let t=e.info||e.socket,n=Object.create(r);if(n.id=typeof e.id==`function`?e.id():e.id||(e.info?e.info.id:void 0),n.method=e.method,e.originalUrl)n.url=e.originalUrl;else{let t=e.path;n.url=typeof t==`string`?t:e.url?e.url.path||e.url:void 0}return e.query&&(n.query=e.query),e.params&&(n.params=e.params),n.headers=e.headers,n.remoteAddress=t&&t.remoteAddress,n.remotePort=t&&t.remotePort,n.raw=e.raw||e,n}function a(e){return{req:i(e)}}})),re=/* @__PURE__ */ w(((e,t)=>{t.exports={mapHttpResponse:a,resSerializer:i};let n=Symbol(`pino-raw-res-ref`),r=Object.create({},{statusCode:{enumerable:!0,writable:!0,value:0},headers:{enumerable:!0,writable:!0,value:``},raw:{enumerable:!1,get:function(){return this[n]},set:function(e){this[n]=e}}});Object.defineProperty(r,n,{writable:!0,value:{}});function i(e){let t=Object.create(r);return t.statusCode=e.headersSent?e.statusCode:null,t.headers=e.getHeaders?e.getHeaders():e._headers,t.raw=e,t}function a(e){return{res:i(e)}}})),ie=/* @__PURE__ */ w(((e,t)=>{let n=O(),r=k(),i=ne(),a=re();t.exports={err:n,errWithCause:r,mapHttpRequest:i.mapHttpRequest,mapHttpResponse:a.mapHttpResponse,req:i.reqSerializer,res:a.resSerializer,wrapErrorSerializer:function(e){return e===n?e:function(t){return e(n(t))}},wrapRequestSerializer:function(e){return e===i.reqSerializer?e:function(t){return e(i.reqSerializer(t))}},wrapResponseSerializer:function(e){return e===a.resSerializer?e:function(t){return e(a.resSerializer(t))}}}})),A=/* @__PURE__ */ w(((e,t)=>{function n(e,t){return t}t.exports=function(){let e=Error.prepareStackTrace;Error.prepareStackTrace=n;let t=(/* @__PURE__ */ Error()).stack;if(Error.prepareStackTrace=e,!Array.isArray(t))return;let r=t.slice(2),i=[];for(let e of r)e&&i.push(e.getFileName());return i}})),ae=/* @__PURE__ */ w(((e,t)=>{function n(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof Array){let t=[];for(let r=0;r<e.length;r++)t[r]=n(e[r]);return t}if(typeof e==`object`){let t=Object.create(Object.getPrototypeOf(e));for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=n(e[r]));return t}return e}function r(e){let t=[],n=``,r=!1,i=!1,a=``;for(let o=0;o<e.length;o++){let s=e[o];!r&&s===`.`?n&&=(t.push(n),``):s===`[`?(n&&=(t.push(n),``),r=!0):s===`]`&&r?(t.push(n),n=``,r=!1,i=!1):(s===`"`||s===`'`)&&r?i?s===a?(i=!1,a=``):n+=s:(i=!0,a=s):n+=s}return n&&t.push(n),t}function i(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){let n=t[e];if(typeof r!=`object`||!r||!(n in r)||typeof r[n]!=`object`||r[n]===null)return!1;r=r[n]}let i=t[t.length-1];if(i===`*`){if(Array.isArray(r))for(let e=0;e<r.length;e++)r[e]=n;else if(typeof r==`object`&&r)for(let e in r)Object.prototype.hasOwnProperty.call(r,e)&&(r[e]=n)}else typeof r==`object`&&r&&i in r&&Object.prototype.hasOwnProperty.call(r,i)&&(r[i]=n);return!0}function a(e,t){let n=e;for(let e=0;e<t.length-1;e++){let r=t[e];if(typeof n!=`object`||!n||!(r in n)||typeof n[r]!=`object`||n[r]===null)return!1;n=n[r]}let r=t[t.length-1];if(r===`*`){if(Array.isArray(n))for(let e=0;e<n.length;e++)n[e]=void 0;else if(typeof n==`object`&&n)for(let e in n)Object.prototype.hasOwnProperty.call(n,e)&&delete n[e]}else typeof n==`object`&&n&&r in n&&Object.prototype.hasOwnProperty.call(n,r)&&delete n[r];return!0}let o=Symbol(`PATH_NOT_FOUND`);function s(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n||!n||!(e in n))return o;n=n[e]}return n}function c(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n||!n)return;n=n[e]}return n}function l(e,t,n,c=!1){for(let l of t){let t=r(l);if(t.includes(`*`))u(e,t,n,l,c);else if(c)a(e,t);else{let r=s(e,t);if(r===o)continue;i(e,t,typeof n==`function`?n(r,t):n)}}}function u(e,t,n,r,i=!1){let a=t.indexOf(`*`);if(a===t.length-1){let r=t.slice(0,-1),a=e;for(let e of r){if(typeof a!=`object`||!a||!a)return;a=a[e]}if(Array.isArray(a)){if(i)for(let e=0;e<a.length;e++)a[e]=void 0;else for(let e=0;e<a.length;e++){let t=[...r,e.toString()],i=typeof n==`function`?n(a[e],t):n;a[e]=i}}else if(typeof a==`object`&&a){if(i){let e=[];for(let t in a)Object.prototype.hasOwnProperty.call(a,t)&&e.push(t);for(let t of e)delete a[t]}else for(let e in a){let t=[...r,e],i=typeof n==`function`?n(a[e],t):n;a[e]=i}}}else d(e,t,n,a,r,i)}function d(e,t,n,r,o,s=!1){let l=t.slice(0,r),d=t.slice(r+1),f=[];function p(e,t){if(t===l.length){if(Array.isArray(e))for(let n=0;n<e.length;n++)f[t]=n.toString(),p(e[n],t+1);else if(typeof e==`object`&&e)for(let n in e)f[t]=n,p(e[n],t+1)}else if(t<l.length){let n=l[t];e&&typeof e==`object`&&e&&n in e&&(f[t]=n,p(e[n],t+1))}else if(d.includes(`*`))u(e,d,typeof n==`function`?(e,r)=>n(e,[...f.slice(0,t),...r]):n,o,s);else if(s)a(e,d);else{let r=typeof n==`function`?n(c(e,d),[...f.slice(0,t),...d]):n;i(e,d,r)}}if(l.length===0)p(e,0);else{let t=e;for(let e=0;e<l.length;e++){let n=l[e];if(typeof t!=`object`||!t||!t)return;t=t[n],f[e]=n}t!=null&&p(t,l.length)}}function f(e){if(e.length===0)return null;let t=/* @__PURE__ */ new Map;for(let n of e){let e=r(n),i=t;for(let t=0;t<e.length;t++){let n=e[t];i.has(n)||i.set(n,/* @__PURE__ */ new Map),i=i.get(n)}}return t}function p(e,t){if(!t)return e;function n(e,t,r=0){if(!t||t.size===0||typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let r=[];for(let i=0;i<e.length;i++){let a=i.toString();t.has(a)||t.has(`*`)?r[i]=n(e[i],t.get(a)||t.get(`*`)):r[i]=e[i]}return r}let i=Object.create(Object.getPrototypeOf(e));for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=t.has(r)||t.has(`*`)?n(e[r],t.get(r)||t.get(`*`)):e[r]);return i}return n(e,t)}function m(e){if(typeof e!=`string`)throw Error(`Paths must be (non-empty) strings`);if(e===``)throw Error(`Invalid redaction path ()`);if(e.includes(`..`)||e.includes(`,`))throw Error(`Invalid redaction path (${e})`);let t=0,n=!1,r=``;for(let i=0;i<e.length;i++){let a=e[i];if((a===`"`||a===`'`)&&t>0)n?a===r&&(n=!1,r=``):(n=!0,r=a);else if(a===`[`&&!n)t++;else if(a===`]`&&!n&&(t--,t<0))throw Error(`Invalid redaction path (${e})`)}if(t!==0)throw Error(`Invalid redaction path (${e})`)}function h(e){if(!Array.isArray(e))throw TypeError(`paths must be an array`);for(let t of e)m(t)}function g(e={}){let{paths:t=[],censor:r=`[REDACTED]`,serialize:i=JSON.stringify,strict:a=!0,remove:o=!1}=e;h(t);let s=f(t);return function(e){if(a&&(typeof e!=`object`||!e)&&(typeof e!=`object`||!e))return i?i(e):e;let c=p(e,s),u=e,d=r;return typeof r==`function`&&(d=r),l(c,t,d,o),i===!1?(c.restore=function(){return n(u)},c):typeof i==`function`?i(c):JSON.stringify(c)}}t.exports=g})),oe=/* @__PURE__ */ w(((e,t)=>{let n=Symbol(`pino.setLevel`),r=Symbol(`pino.getLevel`),i=Symbol(`pino.levelVal`),a=Symbol(`pino.levelComp`),o=Symbol(`pino.useLevelLabels`),s=Symbol(`pino.useOnlyCustomLevels`),c=Symbol(`pino.mixin`),l=Symbol(`pino.lsCache`),u=Symbol(`pino.chindings`),d=Symbol(`pino.asJson`),f=Symbol(`pino.write`),p=Symbol(`pino.redactFmt`),m=Symbol(`pino.time`),h=Symbol(`pino.timeSliceIndex`),g=Symbol(`pino.stream`),_=Symbol(`pino.stringify`),v=Symbol(`pino.stringifySafe`),y=Symbol(`pino.stringifiers`),b=Symbol(`pino.end`),x=Symbol(`pino.formatOpts`),S=Symbol(`pino.messageKey`),C=Symbol(`pino.errorKey`),w=Symbol(`pino.nestedKey`),ee=Symbol(`pino.nestedKeyStr`),te=Symbol(`pino.mixinMergeStrategy`),T=Symbol(`pino.msgPrefix`),E=Symbol(`pino.wildcardFirst`),D=Symbol.for(`pino.serializers`),O=Symbol.for(`pino.formatters`),k=Symbol.for(`pino.hooks`);t.exports={setLevelSym:n,getLevelSym:r,levelValSym:i,levelCompSym:a,useLevelLabelsSym:o,mixinSym:c,lsCacheSym:l,chindingsSym:u,asJsonSym:d,writeSym:f,serializersSym:D,redactFmtSym:p,timeSym:m,timeSliceIndexSym:h,streamSym:g,stringifySym:_,stringifySafeSym:v,stringifiersSym:y,endSym:b,formatOptsSym:x,messageKeySym:S,errorKeySym:C,nestedKeySym:w,wildcardFirstSym:E,needsMetadataGsym:Symbol.for(`pino.metadata`),useOnlyCustomLevelsSym:s,formattersSym:O,hooksSym:k,nestedKeyStrSym:ee,mixinMergeStrategySym:te,msgPrefixSym:T}})),se=/* @__PURE__ */ w(((e,t)=>{let n=ae(),{redactFmtSym:r,wildcardFirstSym:i}=oe(),a=/[^.[\]]+|\[([^[\]]*?)\]/g,o=`[Redacted]`;function s(e,t){let{paths:o,censor:s,remove:l}=c(e),u=o.reduce((e,t)=>{a.lastIndex=0;let n=a.exec(t),r=a.exec(t),o=n[1]===void 0?n[0]:n[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/,`$1`);if(o===`*`&&(o=i),r===null)return e[o]=null,e;if(e[o]===null)return e;let{index:s}=r,c=`${t.substr(s,t.length-1)}`;return e[o]=e[o]||[],o!==i&&e[o].length===0&&e[o].push(...e[i]||[]),o===i&&Object.keys(e).forEach(function(t){e[t]&&e[t].push(c)}),e[o].push(c),e},{}),d={[r]:n({paths:o,censor:s,serialize:t,strict:!1,remove:l})},f=(...e)=>t(typeof s==`function`?s(...e):s);return[...Object.keys(u),...Object.getOwnPropertySymbols(u)].reduce((e,r)=>{if(u[r]===null)e[r]=e=>f(e,[r]);else{let i=typeof s==`function`?(e,t)=>s(e,[r,...t]):s;e[r]=n({paths:u[r],censor:i,serialize:t,strict:!1,remove:l})}return e},d)}function c(e){if(Array.isArray(e))return e={paths:e,censor:o},e;let{paths:t,censor:n=o,remove:r}=e;if(Array.isArray(t)===!1)throw Error(`pino – redact must contain an array of strings`);return r===!0&&(n=void 0),{paths:t,censor:n,remove:r}}t.exports=s})),j=/* @__PURE__ */ w(((e,t)=>{let n=()=>``,r=()=>`,"time":${Date.now()}`,i=()=>`,"time":${Math.round(Date.now()/1e3)}`,a=()=>`,"time":"${new Date(Date.now()).toISOString()}"`,o=1000000000n,s=BigInt(Date.now())*1000000n,c=process.hrtime.bigint();t.exports={nullTime:n,epochTime:r,unixTime:i,isoTime:a,isoTimeNano:()=>{let e=process.hrtime.bigint()-c,t=s+e,n=t/o,r=t%o,i=Number(n*1000n+r/1000000n),a=new Date(i);return`,"time":"${a.getUTCFullYear()}-${(a.getUTCMonth()+1).toString().padStart(2,`0`)}-${a.getUTCDate().toString().padStart(2,`0`)}T${a.getUTCHours().toString().padStart(2,`0`)}:${a.getUTCMinutes().toString().padStart(2,`0`)}:${a.getUTCSeconds().toString().padStart(2,`0`)}.${r.toString().padStart(9,`0`)}Z"`}}})),ce=/* @__PURE__ */ w(((e,t)=>{function n(e){try{return JSON.stringify(e)}catch{return`"[Circular]"`}}t.exports=r;function r(e,t,r){var i=r&&r.stringify||n,a=1;if(typeof e==`object`&&e){var o=t.length+a;if(o===1)return e;var s=Array(o);s[0]=i(e);for(var c=1;c<o;c++)s[c]=i(t[c]);return s.join(` `)}if(typeof e!=`string`)return e;var l=t.length;if(l===0)return e;for(var u=``,d=1-a,f=-1,p=e&&e.length||0,m=0;m<p;){if(e.charCodeAt(m)===37&&m+1<p){switch(f=f>-1?f:0,e.charCodeAt(m+1)){case 100:case 102:if(d>=l||t[d]==null)break;f<m&&(u+=e.slice(f,m)),u+=Number(t[d]),f=m+2,m++;break;case 105:if(d>=l||t[d]==null)break;f<m&&(u+=e.slice(f,m)),u+=Math.floor(Number(t[d])),f=m+2,m++;break;case 79:case 111:case 106:if(d>=l||t[d]===void 0)break;f<m&&(u+=e.slice(f,m));var h=typeof t[d];if(h===`string`){u+=`'`+t[d]+`'`,f=m+2,m++;break}if(h===`function`){u+=t[d].name||`<anonymous>`,f=m+2,m++;break}u+=i(t[d]),f=m+2,m++;break;case 115:if(d>=l)break;f<m&&(u+=e.slice(f,m)),u+=String(t[d]),f=m+2,m++;break;case 37:f<m&&(u+=e.slice(f,m)),u+=`%`,f=m+2,m++,d--}++d}++m}return f===-1?e:(f<p&&(u+=e.slice(f)),u)}})),le=/* @__PURE__ */ w(((e,t)=>{if(typeof SharedArrayBuffer<`u`&&typeof Atomics<`u`){let e=new Int32Array(new SharedArrayBuffer(4));function n(t){if(!(t>0&&t<1/0))throw typeof t!=`number`&&typeof t!=`bigint`?TypeError(`sleep: ms must be a number`):RangeError(`sleep: ms must be a number that is greater than 0 but less than Infinity`);Atomics.wait(e,0,0,Number(t))}t.exports=n}else{function e(e){if(!(e>0&&e<1/0))throw typeof e!=`number`&&typeof e!=`bigint`?TypeError(`sleep: ms must be a number`):RangeError(`sleep: ms must be a number that is greater than 0 but less than Infinity`);let t=Date.now()+Number(e);for(;t>Date.now(););}t.exports=e}})),ue=/* @__PURE__ */ w(((e,t)=>{let n=T(`fs`),r=T(`events`),i=T(`util`).inherits,a=T(`path`),o=le(),s=T(`assert`),c=Buffer.allocUnsafe(0),l=`buffer`,u=`utf8`,[d,f]=(process.versions.node||`0.0`).split(`.`).map(Number),p=d>=22&&f>=7;function m(e,t){t._opening=!0,t._writing=!0,t._asyncDrainScheduled=!1;function r(n,r){if(n){t._reopening=!1,t._writing=!1,t._opening=!1,t.sync?process.nextTick(()=>{t.listenerCount(`error`)>0&&t.emit(`error`,n)}):t.emit(`error`,n);return}let i=t._reopening;t.fd=r,t.file=e,t._reopening=!1,t._opening=!1,t._writing=!1,t.sync?process.nextTick(()=>t.emit(`ready`)):t.emit(`ready`),!t.destroyed&&(!t._writing&&t._len>t.minLength||t._flushPending?t._actualWrite():i&&process.nextTick(()=>t.emit(`drain`)))}let i=t.append?`a`:`w`,o=t.mode;if(t.sync)try{t.mkdir&&n.mkdirSync(a.dirname(e),{recursive:!0}),r(null,n.openSync(e,i,o))}catch(e){throw r(e),e}else t.mkdir?n.mkdir(a.dirname(e),{recursive:!0},t=>{if(t)return r(t);n.open(e,i,o,r)}):n.open(e,i,o,r)}function h(e){if(!(this instanceof h))return new h(e);let{fd:t,dest:r,minLength:i,maxLength:a,maxWrite:s,periodicFlush:d,sync:f,append:p=!0,mkdir:v,retryEAGAIN:x,fsync:T,contentMode:O,mode:k}=e||{};t||=r,this._len=0,this.fd=-1,this._bufs=[],this._lens=[],this._writing=!1,this._ending=!1,this._reopening=!1,this._asyncDrainScheduled=!1,this._flushPending=!1,this._hwm=Math.max(i||0,16387),this.file=null,this.destroyed=!1,this.minLength=i||0,this.maxLength=a||0,this.maxWrite=s||16384,this._periodicFlush=d||0,this._periodicFlushTimer=void 0,this.sync=f||!1,this.writable=!0,this._fsync=T||!1,this.append=p||!1,this.mode=k,this.retryEAGAIN=x||(()=>!0),this.mkdir=v||!1;let ne,re;if(O===l)this._writingBuf=c,this.write=b,this.flush=C,this.flushSync=ee,this._actualWrite=E,ne=()=>n.writeSync(this.fd,this._writingBuf),re=()=>n.write(this.fd,this._writingBuf,this.release);else if(O===void 0||O===u)this._writingBuf=``,this.write=y,this.flush=S,this.flushSync=w,this._actualWrite=te,ne=()=>Buffer.isBuffer(this._writingBuf)?n.writeSync(this.fd,this._writingBuf):n.writeSync(this.fd,this._writingBuf,`utf8`),re=()=>Buffer.isBuffer(this._writingBuf)?n.write(this.fd,this._writingBuf,this.release):n.write(this.fd,this._writingBuf,`utf8`,this.release);else throw Error(`SonicBoom supports "${u}" and "${l}", but passed ${O}`);if(typeof t==`number`)this.fd=t,process.nextTick(()=>this.emit(`ready`));else if(typeof t==`string`)m(t,this);else throw Error(`SonicBoom supports only file descriptors and files`);if(this.minLength>=this.maxWrite)throw Error(`minLength should be smaller than maxWrite (${this.maxWrite})`);this.release=(e,t)=>{if(e){if((e.code===`EAGAIN`||e.code===`EBUSY`)&&this.retryEAGAIN(e,this._writingBuf.length,this._len-this._writingBuf.length)){if(this.sync)try{o(100),this.release(void 0,0)}catch(e){this.release(e)}else setTimeout(re,100)}else this._writing=!1,this.emit(`error`,e);return}this.emit(`write`,t);let r=g(this._writingBuf,this._len,t);if(this._len=r.len,this._writingBuf=r.writingBuf,this._writingBuf.length){if(!this.sync){re();return}try{do{let e=ne(),t=g(this._writingBuf,this._len,e);this._len=t.len,this._writingBuf=t.writingBuf}while(this._writingBuf.length)}catch(e){this.release(e);return}}this._fsync&&n.fsyncSync(this.fd);let i=this._len;this._reopening?(this._writing=!1,this._reopening=!1,this.reopen()):i>this.minLength?this._actualWrite():this._ending?i>0?this._actualWrite():(this._writing=!1,D(this)):(this._writing=!1,this.sync?this._asyncDrainScheduled||(this._asyncDrainScheduled=!0,process.nextTick(_,this)):this.emit(`drain`))},this.on(`newListener`,function(e){e===`drain`&&(this._asyncDrainScheduled=!1)}),this._periodicFlush!==0&&(this._periodicFlushTimer=setInterval(()=>this.flush(null),this._periodicFlush),this._periodicFlushTimer.unref())}function g(e,t,n){return typeof e==`string`&&(e=Buffer.from(e)),t=Math.max(t-n,0),e=e.subarray(n),{writingBuf:e,len:t}}function _(e){e.listenerCount(`drain`)>0&&(e._asyncDrainScheduled=!1,e.emit(`drain`))}i(h,r);function v(e,t){return e.length===0?c:e.length===1?e[0]:Buffer.concat(e,t)}function y(e){if(this.destroyed)throw Error(`SonicBoom destroyed`);e=``+e;let t=Buffer.byteLength(e),n=this._len+t,r=this._bufs;return this.maxLength&&n>this.maxLength?(this.emit(`drop`,e),this._len<this._hwm):(r.length===0||Buffer.byteLength(r[r.length-1])+t>this.maxWrite?r.push(e):r[r.length-1]+=e,this._len=n,!this._writing&&this._len>=this.minLength&&this._actualWrite(),this._len<this._hwm)}function b(e){if(this.destroyed)throw Error(`SonicBoom destroyed`);let t=this._len+e.length,n=this._bufs,r=this._lens;return this.maxLength&&t>this.maxLength?(this.emit(`drop`,e),this._len<this._hwm):(n.length===0||r[r.length-1]+e.length>this.maxWrite?(n.push([e]),r.push(e.length)):(n[n.length-1].push(e),r[r.length-1]+=e.length),this._len=t,!this._writing&&this._len>=this.minLength&&this._actualWrite(),this._len<this._hwm)}function x(e){this._flushPending=!0;let t=()=>{if(this._fsync)this._flushPending=!1,e();else try{n.fsync(this.fd,t=>{this._flushPending=!1,e(t)})}catch(t){e(t)}this.off(`error`,r)},r=n=>{this._flushPending=!1,e(n),this.off(`drain`,t)};this.once(`drain`,t),this.once(`error`,r)}function S(e){if(e!=null&&typeof e!=`function`)throw Error(`flush cb must be a function`);if(this.destroyed){let t=/* @__PURE__ */ Error(`SonicBoom destroyed`);if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}e&&x.call(this,e),!this._writing&&(this._bufs.length===0&&this._bufs.push(``),this._actualWrite())}function C(e){if(e!=null&&typeof e!=`function`)throw Error(`flush cb must be a function`);if(this.destroyed){let t=/* @__PURE__ */ Error(`SonicBoom destroyed`);if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}e&&x.call(this,e),!this._writing&&(this._bufs.length===0&&(this._bufs.push([]),this._lens.push(0)),this._actualWrite())}h.prototype.reopen=function(e){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this._opening){this.once(`ready`,()=>{this.reopen(e)});return}if(this._ending)return;if(!this.file)throw Error(`Unable to reopen a file descriptor, you must pass a file to SonicBoom`);if(e&&(this.file=e),this._reopening=!0,this._writing)return;let t=this.fd;this.once(`ready`,()=>{t!==this.fd&&n.close(t,e=>{if(e)return this.emit(`error`,e)})}),m(this.file,this)},h.prototype.end=function(){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this._opening){this.once(`ready`,()=>{this.end()});return}this._ending||(this._ending=!0,!this._writing&&(this._len>0&&this.fd>=0?this._actualWrite():D(this)))};function w(){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this.fd<0)throw Error(`sonic boom is not ready yet`);!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift(this._writingBuf),this._writingBuf=``);let e=``;for(;this._bufs.length||e.length;){e.length<=0&&(e=this._bufs[0]);try{let t=Buffer.isBuffer(e)?n.writeSync(this.fd,e):n.writeSync(this.fd,e,`utf8`),r=g(e,this._len,t);e=r.writingBuf,this._len=r.len,e.length<=0&&this._bufs.shift()}catch(t){if((t.code===`EAGAIN`||t.code===`EBUSY`)&&!this.retryEAGAIN(t,e.length,this._len-e.length))throw t;o(100)}}try{n.fsyncSync(this.fd)}catch{}}function ee(){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this.fd<0)throw Error(`sonic boom is not ready yet`);!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift([this._writingBuf]),this._writingBuf=c);let e=c;for(;this._bufs.length||e.length;){e.length<=0&&(e=v(this._bufs[0],this._lens[0]));try{let t=n.writeSync(this.fd,e);e=e.subarray(t),this._len=Math.max(this._len-t,0),e.length<=0&&(this._bufs.shift(),this._lens.shift())}catch(t){if((t.code===`EAGAIN`||t.code===`EBUSY`)&&!this.retryEAGAIN(t,e.length,this._len-e.length))throw t;o(100)}}}h.prototype.destroy=function(){this.destroyed||D(this)};function te(){let e=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:this._bufs.shift()||``,this.sync)try{e(null,Buffer.isBuffer(this._writingBuf)?n.writeSync(this.fd,this._writingBuf):n.writeSync(this.fd,this._writingBuf,`utf8`))}catch(t){e(t)}else n.write(this.fd,this._writingBuf,e)}function E(){let e=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:v(this._bufs.shift(),this._lens.shift()),this.sync)try{e(null,n.writeSync(this.fd,this._writingBuf))}catch(t){e(t)}else p&&(this._writingBuf=Buffer.from(this._writingBuf)),n.write(this.fd,this._writingBuf,e)}function D(e){if(e.fd===-1){e.once(`ready`,D.bind(null,e));return}e._periodicFlushTimer!==void 0&&clearInterval(e._periodicFlushTimer),e.destroyed=!0,e._bufs=[],e._lens=[],s(typeof e.fd==`number`,`sonic.fd must be a number, got ${typeof e.fd}`);try{n.fsync(e.fd,t)}catch{}function t(){e.fd!==1&&e.fd!==2?n.close(e.fd,r):r()}function r(t){if(t){e.emit(`error`,t);return}e._ending&&!e._writing&&e.emit(`finish`),e.emit(`close`)}}h.SonicBoom=h,h.default=h,t.exports=h})),de=/* @__PURE__ */ w(((e,t)=>{let n={exit:[],beforeExit:[]},r={exit:c,beforeExit:l},i;function a(){i===void 0&&(i=new FinalizationRegistry(d))}function o(e){n[e].length>0||process.on(e,r[e])}function s(e){n[e].length>0||(process.removeListener(e,r[e]),n.exit.length===0&&n.beforeExit.length===0&&(i=void 0))}function c(){u(`exit`)}function l(){u(`beforeExit`)}function u(e){for(let t of n[e]){let n=t.deref(),r=t.fn;
|
|
5
5
|
/* istanbul ignore else */
|
|
6
|
-
n!==void 0&&r(n,e)}n[e]=[]}function d(e){for(let t of[`exit`,`beforeExit`]){let r=n[t].indexOf(e);n[t].splice(r,r+1),s(t)}}function f(e,t,r){if(t===void 0)throw Error(`the object can't be undefined`);o(e);let s=new WeakRef(t);s.fn=r,a(),i.register(t,s),n[e].push(s)}function p(e,t){f(`exit`,e,t)}function m(e,t){f(`beforeExit`,e,t)}function h(e){if(i!==void 0){i.unregister(e);for(let t of[`exit`,`beforeExit`])n[t]=n[t].filter(t=>{let n=t.deref();return n&&n!==e}),s(t)}}t.exports={register:p,registerBeforeExit:m,unregister:h}})),fe=/* @__PURE__ */ w(((e,t)=>{t.exports={name:`thread-stream`,version:`4.2.0`,description:`A streaming way to send data to a Node.js Worker Thread`,main:`index.js`,types:`index.d.ts`,engines:{node:`>=20`},dependencies:{"real-require":`^1.0.0`},devDependencies:{"@types/node":`^25.0.2`,"@yao-pkg/pkg":`^6.0.0`,borp:`^1.0.0`,desm:`^1.3.0`,eslint:`^9.39.1`,fastbench:`^1.0.1`,neostandard:`^0.13.0`,"pino-elasticsearch":`^9.0.0`,"sonic-boom":`^5.0.0`,"ts-node":`^10.8.0`,typescript:`~5.7.3`},scripts:{build:`tsc --noEmit`,lint:`eslint`,test:`npm run lint && npm run build && npm run transpile && borp --pattern "test/*.test.{js,mjs}"`,"test:ci":`npm run lint && npm run transpile && borp --pattern "test/*.test.{js,mjs}"`,"test:yarn":`npm run transpile && borp --pattern "test/*.test.js"`,transpile:`sh ./test/ts/transpile.sh`},repository:{type:`git`,url:`git+https://github.com/mcollina/thread-stream.git`},keywords:[`worker`,`thread`,`threads`,`stream`],author:`Matteo Collina <hello@matteocollina.com>`,license:`MIT`,bugs:{url:`https://github.com/mcollina/thread-stream/issues`},homepage:`https://github.com/mcollina/thread-stream#readme`}})),pe=/* @__PURE__ */ w(((e,t)=>{let n=1e4;function r(e,t,r,i,a){let o=i===1/0?1/0:Date.now()+i,s=()=>{let i=Atomics.load(e,t);if(i===r){a(null,`ok`);return}if(o!==1/0&&Date.now()>o){a(null,`timed-out`);return}let c=o===1/0?n:Math.min(n,Math.max(1,o-Date.now())),l=Atomics.waitAsync(e,t,i,c);l.async?l.value.then(s):setImmediate(s)};s()}function i(e,t,r,i,a){let o=i===1/0?1/0:Date.now()+i,s=()=>{if(Atomics.load(e,t)!==r){a(null,`ok`);return}if(o!==1/0&&Date.now()>o){a(null,`timed-out`);return}let i=o===1/0?n:Math.min(n,Math.max(1,o-Date.now())),c=Atomics.waitAsync(e,t,r,i);c.async?c.value.then(e=>{if(e===`ok`){a(null,`ok`);return}s()}):setImmediate(s)};s()}t.exports={wait:r,waitDiff:i}})),me=/* @__PURE__ */ w(((e,t)=>{t.exports={WRITE_INDEX:4,READ_INDEX:8,SEQ_INDEX:2}})),he=/* @__PURE__ */ w(((e,t)=>{let{version:n}=fe(),{EventEmitter:r}=E(`events`),{Worker:i}=E(`worker_threads`),{join:a}=E(`path`),{pathToFileURL:o}=E(`url`),{wait:s}=pe(),{WRITE_INDEX:c,READ_INDEX:l,SEQ_INDEX:u}=me(),d=E(`buffer`),f=E(`assert`),p=Symbol(`kImpl`),m=d.constants.MAX_STRING_LENGTH;function h(){}function g(e,t){Atomics.add(e[p].state,u,1),t(),Atomics.add(e[p].state,u,1),Atomics.notify(e[p].state,u)}function _(e){g(e,()=>{Atomics.store(e[p].state,l,0),Atomics.store(e[p].state,c,0)})}var v=class{constructor(e){this._value=e}deref(){return this._value}},y=class{register(){}unregister(){}};let b=process.env.NODE_V8_COVERAGE?y:global.FinalizationRegistry||y,x=process.env.NODE_V8_COVERAGE?v:global.WeakRef||v,S=new b(e=>{e.exited||e.terminate()});function C(e,t){let{filename:r,workerData:s}=t,c=(`__bundlerPathsOverrides`in globalThis?globalThis.__bundlerPathsOverrides:{})[`thread-stream-worker`]||a(__dirname,`lib`,`worker.js`),l=new i(c,{...t.workerOpts,name:t.workerOpts?.name||`thread-stream`,trackUnmanagedFds:!1,workerData:{filename:r.indexOf(`file://`)===0?r:o(r).href,dataBuf:e[p].dataBuf,stateBuf:e[p].stateBuf,workerData:{$context:{threadStreamVersion:n},...s}}});return l.stream=new v(e),l.on(`message`,T),l.on(`exit`,te),S.register(e,l),l}function w(e){f(!e[p].sync),e[p].needDrain&&(e[p].needDrain=!1,e.emit(`drain`))}function ee(e){for(;;){let t=Atomics.load(e[p].state,c),n=e[p].data.length-t;if(n>0){if(e[p].bufLen===0){e[p].flushing=!1,e[p].ending?oe(e):e[p].needDrain&&process.nextTick(w,e);return}ae(e,n,h);continue}if(n===0){if(t===0&&e[p].bufLen===0)return;k(e,()=>{e.destroyed||(_(e),ee(e))});return}A(e,/* @__PURE__ */ Error(`overwritten`));return}}function T(e){let t=this.stream.deref();if(t===void 0){this.exited=!0,this.terminate();return}if(e?.code!=null)switch(e.code){case`READY`:this.stream=new x(t),k(t,()=>{t[p].ready=!0,t.emit(`ready`)});break;case`ERROR`:A(t,e.err);break;case`EVENT`:Array.isArray(e.args)?t.emit(e.name,...e.args):t.emit(e.name,e.args);break;case`FLUSHED`:{if(e.context!==`thread-stream`){A(t,/* @__PURE__ */ Error(`this should not happen: `+e.code));break}let n=t[p].flushCallbacks.get(e.id);n&&(t[p].flushCallbacks.delete(e.id),process.nextTick(n));break}case`WARNING`:process.emitWarning(e.err);break;default:A(t,/* @__PURE__ */ Error(`this should not happen: `+e.code))}}function te(e){let t=this.stream.deref();t!==void 0&&(S.unregister(t),t.worker.exited=!0,t.worker.off(`exit`,te),A(t,e===0?null:/* @__PURE__ */ Error(`the worker thread exited`)))}var D=class extends r{constructor(e={}){if(super(),e.bufferSize<4)throw Error(`bufferSize must at least fit a 4-byte utf-8 char`);this[p]={},this[p].stateBuf=new SharedArrayBuffer(128),this[p].state=new Int32Array(this[p].stateBuf),this[p].dataBuf=new SharedArrayBuffer(e.bufferSize||4194304),this[p].data=Buffer.from(this[p].dataBuf),this[p].sync=e.sync||!1,this[p].ending=!1,this[p].ended=!1,this[p].needDrain=!1,this[p].destroyed=!1,this[p].flushing=!1,this[p].ready=!1,this[p].finished=!1,this[p].errored=null,this[p].closed=!1,this[p].buf=[],this[p].bufHead=0,this[p].bufLen=0,this[p].flushCallbacks=/* @__PURE__ */ new Map,this[p].nextFlushId=0,this.worker=C(this,e),this.on(`message`,(e,t)=>{this.worker.postMessage(e,t)})}write(e){let t=Buffer.isBuffer(e)?e:Buffer.from(e);if(this[p].destroyed)return ie(this,/* @__PURE__ */ Error(`the worker has exited`)),!1;if(this[p].ending)return ie(this,/* @__PURE__ */ Error(`the worker is ending`)),!1;if(this[p].flushing&&this[p].bufLen+t.length>=m)try{se(this),this[p].flushing=!0}catch(e){return A(this,e),!1}if(this[p].buf.push(t),this[p].bufLen+=t.length,this[p].sync)try{return se(this),!0}catch(e){return A(this,e),!1}return this[p].flushing||(this[p].flushing=!0,setImmediate(ee,this)),this[p].needDrain=this[p].data.length-this[p].bufLen-Atomics.load(this[p].state,c)<=0,!this[p].needDrain}end(){this[p].destroyed||(this[p].ending=!0,oe(this))}flush(e){e=typeof e==`function`?e:h,O(this,t=>{if(t){process.nextTick(e,t);return}ne(this,e)})}flushSync(){this[p].destroyed||(se(this),j(this))}unref(){this.worker.unref()}ref(){this.worker.ref()}get ready(){return this[p].ready}get destroyed(){return this[p].destroyed}get closed(){return this[p].closed}get writable(){return!this[p].destroyed&&!this[p].ending}get writableEnded(){return this[p].ending}get writableFinished(){return this[p].finished}get writableNeedDrain(){return this[p].needDrain}get writableObjectMode(){return!1}get writableErrored(){return this[p].errored}};function O(e,t){if(e[p].destroyed){process.nextTick(t,/* @__PURE__ */ Error(`the worker has exited`));return}if(!e[p].sync&&(e[p].flushing||e[p].bufLen>0)){setImmediate(O,e,t);return}k(e,t)}function k(e,t){let n=Atomics.load(e[p].state,c);s(e[p].state,l,n,1/0,(n,r)=>{if(n){A(e,n),t(n);return}if(r!==`ok`){k(e,t);return}t()})}function ne(e,t){if(e[p].destroyed){process.nextTick(t,/* @__PURE__ */ Error(`the worker has exited`));return}if(!e[p].ready){let n=()=>{i(),ne(e,t)},r=()=>{i(),process.nextTick(t,/* @__PURE__ */ Error(`the worker has exited`))},i=()=>{e.off(`ready`,n),e.off(`close`,r)};e.once(`ready`,n),e.once(`close`,r);return}let n=++e[p].nextFlushId;e[p].flushCallbacks.set(n,t);try{e.worker.postMessage({code:`FLUSH`,context:`thread-stream`,id:n})}catch(r){e[p].flushCallbacks.delete(n),A(e,r),process.nextTick(t,r)}}function re(e,t){let n=e[p].flushCallbacks;if(n.size===0)return;let r=t||/* @__PURE__ */ Error(`the worker has exited`);for(let e of n.values())process.nextTick(e,r);n.clear()}function ie(e,t){setImmediate(()=>{e.emit(`error`,t)})}function A(e,t){e[p].destroyed||(e[p].destroyed=!0,re(e,t),t&&(e[p].errored=t,ie(e,t)),e.worker.exited?setImmediate(()=>{e[p].closed=!0,e.emit(`close`)}):e.worker.terminate().catch(()=>{}).then(()=>{e[p].closed=!0,e.emit(`close`)}))}function ae(e,t,n){let r=Atomics.load(e[p].state,c),i=t;for(;i>0&&e[p].bufLen!==0;){let t=e[p].bufHead,n=e[p].buf[t];if(n.length<=i){n.copy(e[p].data,r),r+=n.length,i-=n.length,e[p].bufLen-=n.length,e[p].bufHead=t+1,e[p].bufHead===e[p].buf.length?(e[p].buf.length=0,e[p].bufHead=0):e[p].bufHead>=1024&&e[p].bufHead*2>=e[p].buf.length&&(e[p].buf.splice(0,e[p].bufHead),e[p].bufHead=0);continue}n.copy(e[p].data,r,0,i),e[p].buf[t]=n.subarray(i),e[p].bufLen-=i,r+=i,i=0}return g(e,()=>{Atomics.store(e[p].state,c,r)}),n(),!0}function oe(e){if(!(e[p].ended||!e[p].ending||e[p].flushing)){e[p].ended=!0;try{e.flushSync();let t=Atomics.load(e[p].state,l);g(e,()=>{Atomics.store(e[p].state,c,-1)});let n=0;for(;t!==-1;){if(Atomics.wait(e[p].state,l,t,1e3),t=Atomics.load(e[p].state,l),t===-2){A(e,/* @__PURE__ */ Error(`end() failed`));return}if(++n===10){A(e,/* @__PURE__ */ Error(`end() took too long (10s)`));return}}process.nextTick(()=>{e[p].finished=!0,e.emit(`finish`)})}catch(t){A(e,t)}}}function se(e){let t=()=>{e[p].ending?oe(e):e[p].needDrain&&process.nextTick(w,e)};for(e[p].flushing=!1;e[p].bufLen!==0;){let n=Atomics.load(e[p].state,c),r=e[p].data.length-n;if(r===0){j(e),_(e);continue}if(r<0)throw Error(`overwritten`);ae(e,r,t)}}function j(e){if(e[p].flushing)throw Error(`unable to flush while flushing`);let t=Atomics.load(e[p].state,c),n=0;for(;;){let r=Atomics.load(e[p].state,l);if(r===-2)throw Error(`_flushSync failed`);if(r!==t)Atomics.wait(e[p].state,l,r,1e3);else break;if(++n===10)throw Error(`_flushSync took too long (10s)`)}}t.exports=D})),ge=/* @__PURE__ */ w(((e,t)=>{let{createRequire:n}=E(`module`),{existsSync:r}=E(`node:fs`),i=A(),{join:a,isAbsolute:o,sep:s}=E(`node:path`),{fileURLToPath:c}=E(`node:url`),l=le(),u=de(),d=he();function f(e){u.register(e,v),u.registerBeforeExit(e,y),e.on(`close`,function(){u.unregister(e)})}function p(){let e=process.execArgv;for(let t=0;t<e.length;t++){let n=e[t];if(n===`--import`||n===`--require`||n===`-r`||n.startsWith(`--import=`)||n.startsWith(`--require=`)||n.startsWith(`-r=`))return!0}return!1}function m(e){let t=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);if(!t)return e;let n=[],r=!1;for(let e=0;e<t.length;e++){let i=t[e];if(i===`--require`||i===`-r`||i===`--import`){let a=t[e+1];if(a&&h(a)){r=!0,e++;continue}n.push(i),a&&(n.push(a),e++);continue}if((i.startsWith(`--require=`)||i.startsWith(`-r=`)||i.startsWith(`--import=`))&&h(i.slice(i.indexOf(`=`)+1))){r=!0;continue}n.push(i)}return r?n.join(` `):e}function h(e){let t=g(e);if(!t)return!1;let n=t;if(n.startsWith(`file://`))try{n=c(n)}catch{return!1}return o(n)&&!r(n)}function g(e){let t=e[0],n=e[e.length-1];return t===`"`&&n===`"`||t===`'`&&n===`'`?e.slice(1,-1):e}function _(e,t,n,r,i){if(!n.execArgv&&p()&&E.main===void 0&&(n={...n,execArgv:[]}),!n.env&&process.env.NODE_OPTIONS){let e=m(process.env.NODE_OPTIONS);e!==process.env.NODE_OPTIONS&&(n={...n,env:{...process.env,NODE_OPTIONS:e}})}n={...n,name:i};let a=new d({filename:e,workerData:t,workerOpts:n,sync:r});a.on(`ready`,o),a.on(`close`,function(){process.removeListener(`exit`,s)}),process.on(`exit`,s);function o(){process.removeListener(`exit`,s),a.unref(),n.autoEnd!==!1&&f(a)}function s(){a.closed||(a.flushSync(),l(100),a.end())}return a}function v(e){e.ref(),e.flushSync(),e.end(),e.once(`close`,function(){e.unref()})}function y(e){e.flushSync()}function b(e){let{pipeline:t,targets:r,levels:c,dedupe:l,worker:u={},caller:d=i(),sync:f=!1}=e,p={...e.options},m=typeof d==`string`?[d]:d,h=typeof globalThis==`object`&&Object.prototype.hasOwnProperty.call(globalThis,`__bundlerPathsOverrides`)&&globalThis.__bundlerPathsOverrides&&typeof globalThis.__bundlerPathsOverrides==`object`?globalThis.__bundlerPathsOverrides:Object.create(null),g=e.target;if(g&&r)throw Error(`only one of target or targets can be specified`);r?(g=h[`pino-worker`]||a(__dirname,`worker.js`),p.targets=r.filter(e=>e.target).map(e=>({...e,target:y(e.target)})),p.pipelines=r.filter(e=>e.pipeline).map(e=>e.pipeline.map(t=>({...t,level:e.level,target:y(t.target)})))):t&&(g=h[`pino-worker`]||a(__dirname,`worker.js`),p.pipelines=[t.map(e=>({...e,target:y(e.target)}))]),c&&(p.levels=c),l&&(p.dedupe=l),p.pinoWillSendConfig=!0;let v=r||t?`pino.transport`:g;return _(y(g),p,u,f,v);function y(e){if(e=h[e]||e,o(e)||e.indexOf(`file://`)===0)return e;if(e===`pino/file`)return a(__dirname,`..`,`file.js`);let t;for(let r of m)try{let i=r===`node:repl`?process.cwd()+s:r;t=n(i).resolve(e);break}catch{continue}if(!t)throw Error(`unable to determine transport target for "${e}"`);return t}}t.exports=b})),_e=/* @__PURE__ */ w(((e,t)=>{let n=E(`node:diagnostics_channel`),r=ce(),{mapHttpRequest:i,mapHttpResponse:a}=ie(),o=ue(),s=de(),{lsCacheSym:c,chindingsSym:l,writeSym:u,serializersSym:d,formatOptsSym:f,endSym:p,stringifiersSym:m,stringifySym:h,stringifySafeSym:g,wildcardFirstSym:_,nestedKeySym:v,formattersSym:y,messageKeySym:b,errorKeySym:x,nestedKeyStrSym:S,msgPrefixSym:C}=oe(),{isMainThread:w}=E(`worker_threads`),ee=ge(),[T]=process.versions.node.split(`.`).map(e=>Number(e)),te=n.tracingChannel(`pino_asJson`),D=T>=25?e=>JSON.stringify(e):ne;function O(){}function k(e,t){return t?function(...r){t.call(this,r,n,e)}:n;function n(t,...n){if(typeof t==`object`){let o=t;t!==null&&(t.method&&t.headers&&t.socket?t=i(t):typeof t.setHeader==`function`&&(t=a(t)));let s;o===null&&n.length===0?s=[null]:(o=n.shift(),s=n),typeof this[C]==`string`&&o!=null&&(o=this[C]+o),this[u](t,r(o,s,this[f]),e)}else{let i=t===void 0?n.shift():t;typeof this[C]==`string`&&i!=null&&(i=this[C]+i),this[u](null,r(i,n,this[f]),e)}}}function ne(e){let t=``,n=0,r=!1,i=255,a=e.length;if(a>100)return JSON.stringify(e);for(var o=0;o<a&&i>=32;o++)i=e.charCodeAt(o),(i===34||i===92)&&(t+=e.slice(n,o)+`\\`,n=o,r=!0);return r?t+=e.slice(n):t=e,i<32?JSON.stringify(e):`"`+t+`"`}function re(e,t,n,r){if(te.hasSubscribers===!1)return A.call(this,e,t,n,r);let i={instance:this,arguments};return te.traceSync(A,i,this,e,t,n,r)}function A(e,t,n,r){let i=this[h],a=this[g],o=this[m],s=this[p],u=this[l],f=this[d],C=this[y],w=this[b],ee=this[x],T=this[c][n]+r;T+=u;let E;C.log&&(e=C.log(e));let te=o[_],O=``;for(let t in e)if(E=e[t],Object.prototype.hasOwnProperty.call(e,t)&&E!==void 0){f[t]?E=f[t](E):t===ee&&f.err&&(E=f.err(E));let e=o[t]||te;switch(typeof E){case`undefined`:case`function`:continue;case`number`:Number.isFinite(E)===!1&&(E=null);case`boolean`:e&&(E=e(E));break;case`string`:E=(e||D)(E);break;default:E=(e||i)(E,a)}if(E===void 0)continue;let n=D(t);O+=`,`+n+`:`+E}let k=``;if(t!==void 0){E=f[w]?f[w](t):t;let e=o[w]||te;switch(typeof E){case`function`:break;case`number`:Number.isFinite(E)===!1&&(E=null);case`boolean`:e&&(E=e(E)),k=`,"`+w+`":`+E;break;case`string`:E=(e||D)(E),k=`,"`+w+`":`+E;break;default:E=(e||i)(E,a),k=`,"`+w+`":`+E}}return this[v]&&O?T+this[S]+O.slice(1)+`}`+k+s:T+O+k+s}function ae(e,t){let n,r=e[l],i=e[h],a=e[g],o=e[m],s=o[_],c=e[d],u=e[y].bindings;t=u(t);for(let e in t)if(n=t[e],((e.length<5||e!==`level`&&e!==`serializers`&&e!==`formatters`&&e!==`customLevels`)&&t.hasOwnProperty(e)&&n!==void 0)===!0){if(n=c[e]?c[e](n):n,n=(o[e]||s||i)(n,a),n===void 0)continue;r+=`,"`+e+`":`+n}return r}function se(e){return e.write!==e.constructor.prototype.write}function j(e){let t=new o(e);return t.on(`error`,n),!e.sync&&w&&(s.register(t,le),t.on(`close`,function(){s.unregister(t)})),t;function n(e){
|
|
6
|
+
n!==void 0&&r(n,e)}n[e]=[]}function d(e){for(let t of[`exit`,`beforeExit`]){let r=n[t].indexOf(e);n[t].splice(r,r+1),s(t)}}function f(e,t,r){if(t===void 0)throw Error(`the object can't be undefined`);o(e);let s=new WeakRef(t);s.fn=r,a(),i.register(t,s),n[e].push(s)}function p(e,t){f(`exit`,e,t)}function m(e,t){f(`beforeExit`,e,t)}function h(e){if(i!==void 0){i.unregister(e);for(let t of[`exit`,`beforeExit`])n[t]=n[t].filter(t=>{let n=t.deref();return n&&n!==e}),s(t)}}t.exports={register:p,registerBeforeExit:m,unregister:h}})),fe=/* @__PURE__ */ w(((e,t)=>{t.exports={name:`thread-stream`,version:`4.2.0`,description:`A streaming way to send data to a Node.js Worker Thread`,main:`index.js`,types:`index.d.ts`,engines:{node:`>=20`},dependencies:{"real-require":`^1.0.0`},devDependencies:{"@types/node":`^25.0.2`,"@yao-pkg/pkg":`^6.0.0`,borp:`^1.0.0`,desm:`^1.3.0`,eslint:`^9.39.1`,fastbench:`^1.0.1`,neostandard:`^0.13.0`,"pino-elasticsearch":`^9.0.0`,"sonic-boom":`^5.0.0`,"ts-node":`^10.8.0`,typescript:`~5.7.3`},scripts:{build:`tsc --noEmit`,lint:`eslint`,test:`npm run lint && npm run build && npm run transpile && borp --pattern "test/*.test.{js,mjs}"`,"test:ci":`npm run lint && npm run transpile && borp --pattern "test/*.test.{js,mjs}"`,"test:yarn":`npm run transpile && borp --pattern "test/*.test.js"`,transpile:`sh ./test/ts/transpile.sh`},repository:{type:`git`,url:`git+https://github.com/mcollina/thread-stream.git`},keywords:[`worker`,`thread`,`threads`,`stream`],author:`Matteo Collina <hello@matteocollina.com>`,license:`MIT`,bugs:{url:`https://github.com/mcollina/thread-stream/issues`},homepage:`https://github.com/mcollina/thread-stream#readme`}})),pe=/* @__PURE__ */ w(((e,t)=>{let n=1e4;function r(e,t,r,i,a){let o=i===1/0?1/0:Date.now()+i,s=()=>{let i=Atomics.load(e,t);if(i===r){a(null,`ok`);return}if(o!==1/0&&Date.now()>o){a(null,`timed-out`);return}let c=o===1/0?n:Math.min(n,Math.max(1,o-Date.now())),l=Atomics.waitAsync(e,t,i,c);l.async?l.value.then(s):setImmediate(s)};s()}function i(e,t,r,i,a){let o=i===1/0?1/0:Date.now()+i,s=()=>{if(Atomics.load(e,t)!==r){a(null,`ok`);return}if(o!==1/0&&Date.now()>o){a(null,`timed-out`);return}let i=o===1/0?n:Math.min(n,Math.max(1,o-Date.now())),c=Atomics.waitAsync(e,t,r,i);c.async?c.value.then(e=>{if(e===`ok`){a(null,`ok`);return}s()}):setImmediate(s)};s()}t.exports={wait:r,waitDiff:i}})),me=/* @__PURE__ */ w(((e,t)=>{t.exports={WRITE_INDEX:4,READ_INDEX:8,SEQ_INDEX:2}})),he=/* @__PURE__ */ w(((e,t)=>{let{version:n}=fe(),{EventEmitter:r}=T(`events`),{Worker:i}=T(`worker_threads`),{join:a}=T(`path`),{pathToFileURL:o}=T(`url`),{wait:s}=pe(),{WRITE_INDEX:c,READ_INDEX:l,SEQ_INDEX:u}=me(),d=T(`buffer`),f=T(`assert`),p=Symbol(`kImpl`),m=d.constants.MAX_STRING_LENGTH;function h(){}function g(e,t){Atomics.add(e[p].state,u,1),t(),Atomics.add(e[p].state,u,1),Atomics.notify(e[p].state,u)}function _(e){g(e,()=>{Atomics.store(e[p].state,l,0),Atomics.store(e[p].state,c,0)})}var v=class{constructor(e){this._value=e}deref(){return this._value}},y=class{register(){}unregister(){}};let b=process.env.NODE_V8_COVERAGE?y:global.FinalizationRegistry||y,x=process.env.NODE_V8_COVERAGE?v:global.WeakRef||v,S=new b(e=>{e.exited||e.terminate()});function C(e,t){let{filename:r,workerData:s}=t,c=(`__bundlerPathsOverrides`in globalThis?globalThis.__bundlerPathsOverrides:{})[`thread-stream-worker`]||a(__dirname,`lib`,`worker.js`),l=new i(c,{...t.workerOpts,name:t.workerOpts?.name||`thread-stream`,trackUnmanagedFds:!1,workerData:{filename:r.indexOf(`file://`)===0?r:o(r).href,dataBuf:e[p].dataBuf,stateBuf:e[p].stateBuf,workerData:{$context:{threadStreamVersion:n},...s}}});return l.stream=new v(e),l.on(`message`,te),l.on(`exit`,E),S.register(e,l),l}function w(e){f(!e[p].sync),e[p].needDrain&&(e[p].needDrain=!1,e.emit(`drain`))}function ee(e){for(;;){let t=Atomics.load(e[p].state,c),n=e[p].data.length-t;if(n>0){if(e[p].bufLen===0){e[p].flushing=!1,e[p].ending?oe(e):e[p].needDrain&&process.nextTick(w,e);return}ae(e,n,h);continue}if(n===0){if(t===0&&e[p].bufLen===0)return;k(e,()=>{e.destroyed||(_(e),ee(e))});return}A(e,/* @__PURE__ */ Error(`overwritten`));return}}function te(e){let t=this.stream.deref();if(t===void 0){this.exited=!0,this.terminate();return}if(e?.code!=null)switch(e.code){case`READY`:this.stream=new x(t),k(t,()=>{t[p].ready=!0,t.emit(`ready`)});break;case`ERROR`:A(t,e.err);break;case`EVENT`:Array.isArray(e.args)?t.emit(e.name,...e.args):t.emit(e.name,e.args);break;case`FLUSHED`:{if(e.context!==`thread-stream`){A(t,/* @__PURE__ */ Error(`this should not happen: `+e.code));break}let n=t[p].flushCallbacks.get(e.id);n&&(t[p].flushCallbacks.delete(e.id),process.nextTick(n));break}case`WARNING`:process.emitWarning(e.err);break;default:A(t,/* @__PURE__ */ Error(`this should not happen: `+e.code))}}function E(e){let t=this.stream.deref();t!==void 0&&(S.unregister(t),t.worker.exited=!0,t.worker.off(`exit`,E),A(t,e===0?null:/* @__PURE__ */ Error(`the worker thread exited`)))}var D=class extends r{constructor(e={}){if(super(),e.bufferSize<4)throw Error(`bufferSize must at least fit a 4-byte utf-8 char`);this[p]={},this[p].stateBuf=new SharedArrayBuffer(128),this[p].state=new Int32Array(this[p].stateBuf),this[p].dataBuf=new SharedArrayBuffer(e.bufferSize||4194304),this[p].data=Buffer.from(this[p].dataBuf),this[p].sync=e.sync||!1,this[p].ending=!1,this[p].ended=!1,this[p].needDrain=!1,this[p].destroyed=!1,this[p].flushing=!1,this[p].ready=!1,this[p].finished=!1,this[p].errored=null,this[p].closed=!1,this[p].buf=[],this[p].bufHead=0,this[p].bufLen=0,this[p].flushCallbacks=/* @__PURE__ */ new Map,this[p].nextFlushId=0,this.worker=C(this,e),this.on(`message`,(e,t)=>{this.worker.postMessage(e,t)})}write(e){let t=Buffer.isBuffer(e)?e:Buffer.from(e);if(this[p].destroyed)return ie(this,/* @__PURE__ */ Error(`the worker has exited`)),!1;if(this[p].ending)return ie(this,/* @__PURE__ */ Error(`the worker is ending`)),!1;if(this[p].flushing&&this[p].bufLen+t.length>=m)try{se(this),this[p].flushing=!0}catch(e){return A(this,e),!1}if(this[p].buf.push(t),this[p].bufLen+=t.length,this[p].sync)try{return se(this),!0}catch(e){return A(this,e),!1}return this[p].flushing||(this[p].flushing=!0,setImmediate(ee,this)),this[p].needDrain=this[p].data.length-this[p].bufLen-Atomics.load(this[p].state,c)<=0,!this[p].needDrain}end(){this[p].destroyed||(this[p].ending=!0,oe(this))}flush(e){e=typeof e==`function`?e:h,O(this,t=>{if(t){process.nextTick(e,t);return}ne(this,e)})}flushSync(){this[p].destroyed||(se(this),j(this))}unref(){this.worker.unref()}ref(){this.worker.ref()}get ready(){return this[p].ready}get destroyed(){return this[p].destroyed}get closed(){return this[p].closed}get writable(){return!this[p].destroyed&&!this[p].ending}get writableEnded(){return this[p].ending}get writableFinished(){return this[p].finished}get writableNeedDrain(){return this[p].needDrain}get writableObjectMode(){return!1}get writableErrored(){return this[p].errored}};function O(e,t){if(e[p].destroyed){process.nextTick(t,/* @__PURE__ */ Error(`the worker has exited`));return}if(!e[p].sync&&(e[p].flushing||e[p].bufLen>0)){setImmediate(O,e,t);return}k(e,t)}function k(e,t){let n=Atomics.load(e[p].state,c);s(e[p].state,l,n,1/0,(n,r)=>{if(n){A(e,n),t(n);return}if(r!==`ok`){k(e,t);return}t()})}function ne(e,t){if(e[p].destroyed){process.nextTick(t,/* @__PURE__ */ Error(`the worker has exited`));return}if(!e[p].ready){let n=()=>{i(),ne(e,t)},r=()=>{i(),process.nextTick(t,/* @__PURE__ */ Error(`the worker has exited`))},i=()=>{e.off(`ready`,n),e.off(`close`,r)};e.once(`ready`,n),e.once(`close`,r);return}let n=++e[p].nextFlushId;e[p].flushCallbacks.set(n,t);try{e.worker.postMessage({code:`FLUSH`,context:`thread-stream`,id:n})}catch(r){e[p].flushCallbacks.delete(n),A(e,r),process.nextTick(t,r)}}function re(e,t){let n=e[p].flushCallbacks;if(n.size===0)return;let r=t||/* @__PURE__ */ Error(`the worker has exited`);for(let e of n.values())process.nextTick(e,r);n.clear()}function ie(e,t){setImmediate(()=>{e.emit(`error`,t)})}function A(e,t){e[p].destroyed||(e[p].destroyed=!0,re(e,t),t&&(e[p].errored=t,ie(e,t)),e.worker.exited?setImmediate(()=>{e[p].closed=!0,e.emit(`close`)}):e.worker.terminate().catch(()=>{}).then(()=>{e[p].closed=!0,e.emit(`close`)}))}function ae(e,t,n){let r=Atomics.load(e[p].state,c),i=t;for(;i>0&&e[p].bufLen!==0;){let t=e[p].bufHead,n=e[p].buf[t];if(n.length<=i){n.copy(e[p].data,r),r+=n.length,i-=n.length,e[p].bufLen-=n.length,e[p].bufHead=t+1,e[p].bufHead===e[p].buf.length?(e[p].buf.length=0,e[p].bufHead=0):e[p].bufHead>=1024&&e[p].bufHead*2>=e[p].buf.length&&(e[p].buf.splice(0,e[p].bufHead),e[p].bufHead=0);continue}n.copy(e[p].data,r,0,i),e[p].buf[t]=n.subarray(i),e[p].bufLen-=i,r+=i,i=0}return g(e,()=>{Atomics.store(e[p].state,c,r)}),n(),!0}function oe(e){if(!(e[p].ended||!e[p].ending||e[p].flushing)){e[p].ended=!0;try{e.flushSync();let t=Atomics.load(e[p].state,l);g(e,()=>{Atomics.store(e[p].state,c,-1)});let n=0;for(;t!==-1;){if(Atomics.wait(e[p].state,l,t,1e3),t=Atomics.load(e[p].state,l),t===-2){A(e,/* @__PURE__ */ Error(`end() failed`));return}if(++n===10){A(e,/* @__PURE__ */ Error(`end() took too long (10s)`));return}}process.nextTick(()=>{e[p].finished=!0,e.emit(`finish`)})}catch(t){A(e,t)}}}function se(e){let t=()=>{e[p].ending?oe(e):e[p].needDrain&&process.nextTick(w,e)};for(e[p].flushing=!1;e[p].bufLen!==0;){let n=Atomics.load(e[p].state,c),r=e[p].data.length-n;if(r===0){j(e),_(e);continue}if(r<0)throw Error(`overwritten`);ae(e,r,t)}}function j(e){if(e[p].flushing)throw Error(`unable to flush while flushing`);let t=Atomics.load(e[p].state,c),n=0;for(;;){let r=Atomics.load(e[p].state,l);if(r===-2)throw Error(`_flushSync failed`);if(r!==t)Atomics.wait(e[p].state,l,r,1e3);else break;if(++n===10)throw Error(`_flushSync took too long (10s)`)}}t.exports=D})),ge=/* @__PURE__ */ w(((e,t)=>{let{createRequire:n}=T(`module`),{existsSync:r}=T(`node:fs`),i=A(),{join:a,isAbsolute:o,sep:s}=T(`node:path`),{fileURLToPath:c}=T(`node:url`),l=le(),u=de(),d=he();function f(e){u.register(e,v),u.registerBeforeExit(e,y),e.on(`close`,function(){u.unregister(e)})}function p(){let e=process.execArgv;for(let t=0;t<e.length;t++){let n=e[t];if(n===`--import`||n===`--require`||n===`-r`||n.startsWith(`--import=`)||n.startsWith(`--require=`)||n.startsWith(`-r=`))return!0}return!1}function m(e){let t=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);if(!t)return e;let n=[],r=!1;for(let e=0;e<t.length;e++){let i=t[e];if(i===`--require`||i===`-r`||i===`--import`){let a=t[e+1];if(a&&h(a)){r=!0,e++;continue}n.push(i),a&&(n.push(a),e++);continue}if((i.startsWith(`--require=`)||i.startsWith(`-r=`)||i.startsWith(`--import=`))&&h(i.slice(i.indexOf(`=`)+1))){r=!0;continue}n.push(i)}return r?n.join(` `):e}function h(e){let t=g(e);if(!t)return!1;let n=t;if(n.startsWith(`file://`))try{n=c(n)}catch{return!1}return o(n)&&!r(n)}function g(e){let t=e[0],n=e[e.length-1];return t===`"`&&n===`"`||t===`'`&&n===`'`?e.slice(1,-1):e}function _(e,t,n,r,i){if(!n.execArgv&&p()&&T.main===void 0&&(n={...n,execArgv:[]}),!n.env&&process.env.NODE_OPTIONS){let e=m(process.env.NODE_OPTIONS);e!==process.env.NODE_OPTIONS&&(n={...n,env:{...process.env,NODE_OPTIONS:e}})}n={...n,name:i};let a=new d({filename:e,workerData:t,workerOpts:n,sync:r});a.on(`ready`,o),a.on(`close`,function(){process.removeListener(`exit`,s)}),process.on(`exit`,s);function o(){process.removeListener(`exit`,s),a.unref(),n.autoEnd!==!1&&f(a)}function s(){a.closed||(a.flushSync(),l(100),a.end())}return a}function v(e){e.ref(),e.flushSync(),e.end(),e.once(`close`,function(){e.unref()})}function y(e){e.flushSync()}function b(e){let{pipeline:t,targets:r,levels:c,dedupe:l,worker:u={},caller:d=i(),sync:f=!1}=e,p={...e.options},m=typeof d==`string`?[d]:d,h=typeof globalThis==`object`&&Object.prototype.hasOwnProperty.call(globalThis,`__bundlerPathsOverrides`)&&globalThis.__bundlerPathsOverrides&&typeof globalThis.__bundlerPathsOverrides==`object`?globalThis.__bundlerPathsOverrides:Object.create(null),g=e.target;if(g&&r)throw Error(`only one of target or targets can be specified`);r?(g=h[`pino-worker`]||a(__dirname,`worker.js`),p.targets=r.filter(e=>e.target).map(e=>({...e,target:y(e.target)})),p.pipelines=r.filter(e=>e.pipeline).map(e=>e.pipeline.map(t=>({...t,level:e.level,target:y(t.target)})))):t&&(g=h[`pino-worker`]||a(__dirname,`worker.js`),p.pipelines=[t.map(e=>({...e,target:y(e.target)}))]),c&&(p.levels=c),l&&(p.dedupe=l),p.pinoWillSendConfig=!0;let v=r||t?`pino.transport`:g;return _(y(g),p,u,f,v);function y(e){if(e=h[e]||e,o(e)||e.indexOf(`file://`)===0)return e;if(e===`pino/file`)return a(__dirname,`..`,`file.js`);let t;for(let r of m)try{let i=r===`node:repl`?process.cwd()+s:r;t=n(i).resolve(e);break}catch{continue}if(!t)throw Error(`unable to determine transport target for "${e}"`);return t}}t.exports=b})),_e=/* @__PURE__ */ w(((e,t)=>{let n=T(`node:diagnostics_channel`),r=ce(),{mapHttpRequest:i,mapHttpResponse:a}=ie(),o=ue(),s=de(),{lsCacheSym:c,chindingsSym:l,writeSym:u,serializersSym:d,formatOptsSym:f,endSym:p,stringifiersSym:m,stringifySym:h,stringifySafeSym:g,wildcardFirstSym:_,nestedKeySym:v,formattersSym:y,messageKeySym:b,errorKeySym:x,nestedKeyStrSym:S,msgPrefixSym:C}=oe(),{isMainThread:w}=T(`worker_threads`),ee=ge(),[te]=process.versions.node.split(`.`).map(e=>Number(e)),E=n.tracingChannel(`pino_asJson`),D=te>=25?e=>JSON.stringify(e):ne;function O(){}function k(e,t){return t?function(...r){t.call(this,r,n,e)}:n;function n(t,...n){if(typeof t==`object`){let o=t;t!==null&&(t.method&&t.headers&&t.socket?t=i(t):typeof t.setHeader==`function`&&(t=a(t)));let s;o===null&&n.length===0?s=[null]:(o=n.shift(),s=n),typeof this[C]==`string`&&o!=null&&(o=this[C]+o),this[u](t,r(o,s,this[f]),e)}else{let i=t===void 0?n.shift():t;typeof this[C]==`string`&&i!=null&&(i=this[C]+i),this[u](null,r(i,n,this[f]),e)}}}function ne(e){let t=``,n=0,r=!1,i=255,a=e.length;if(a>100)return JSON.stringify(e);for(var o=0;o<a&&i>=32;o++)i=e.charCodeAt(o),(i===34||i===92)&&(t+=e.slice(n,o)+`\\`,n=o,r=!0);return r?t+=e.slice(n):t=e,i<32?JSON.stringify(e):`"`+t+`"`}function re(e,t,n,r){if(E.hasSubscribers===!1)return A.call(this,e,t,n,r);let i={instance:this,arguments};return E.traceSync(A,i,this,e,t,n,r)}function A(e,t,n,r){let i=this[h],a=this[g],o=this[m],s=this[p],u=this[l],f=this[d],C=this[y],w=this[b],ee=this[x],te=this[c][n]+r;te+=u;let T;C.log&&(e=C.log(e));let E=o[_],O=``;for(let t in e)if(T=e[t],Object.prototype.hasOwnProperty.call(e,t)&&T!==void 0){f[t]?T=f[t](T):t===ee&&f.err&&(T=f.err(T));let e=o[t]||E;switch(typeof T){case`undefined`:case`function`:continue;case`number`:Number.isFinite(T)===!1&&(T=null);case`boolean`:e&&(T=e(T));break;case`string`:T=(e||D)(T);break;default:T=(e||i)(T,a)}if(T===void 0)continue;let n=D(t);O+=`,`+n+`:`+T}let k=``;if(t!==void 0){T=f[w]?f[w](t):t;let e=o[w]||E;switch(typeof T){case`function`:break;case`number`:Number.isFinite(T)===!1&&(T=null);case`boolean`:e&&(T=e(T)),k=`,"`+w+`":`+T;break;case`string`:T=(e||D)(T),k=`,"`+w+`":`+T;break;default:T=(e||i)(T,a),k=`,"`+w+`":`+T}}return this[v]&&O?te+this[S]+O.slice(1)+`}`+k+s:te+O+k+s}function ae(e,t){let n,r=e[l],i=e[h],a=e[g],o=e[m],s=o[_],c=e[d],u=e[y].bindings;t=u(t);for(let e in t)if(n=t[e],((e.length<5||e!==`level`&&e!==`serializers`&&e!==`formatters`&&e!==`customLevels`)&&t.hasOwnProperty(e)&&n!==void 0)===!0){if(n=c[e]?c[e](n):n,n=(o[e]||s||i)(n,a),n===void 0)continue;r+=`,"`+e+`":`+n}return r}function se(e){return e.write!==e.constructor.prototype.write}function j(e){let t=new o(e);return t.on(`error`,n),!e.sync&&w&&(s.register(t,le),t.on(`close`,function(){s.unregister(t)})),t;function n(e){
|
|
7
7
|
/* istanbul ignore next */
|
|
8
8
|
if(e.code===`EPIPE`){t.write=O,t.end=O,t.flushSync=O,t.destroy=O;return}t.removeListener(`error`,n),t.emit(`error`,e)}}function le(e,t){e.destroyed||(t===`beforeExit`?(e.flush(),e.on(`drain`,function(){e.end()})):
|
|
9
9
|
/* istanbul ignore next */
|
|
10
|
-
e.flushSync())}function fe(e){return function(t,n,r={},i){if(typeof r==`string`)i=j({dest:r}),r={};else if(typeof i==`string`){if(r&&r.transport)throw Error(`only one of option.transport or stream can be specified`);i=j({dest:i})}else if(r instanceof o||r.writable||r._writableState)i=r,r={};else if(r.transport){if(r.transport instanceof o||r.transport.writable||r.transport._writableState)throw Error(`option.transport do not allow stream, please pass to option directly. e.g. pino(transport)`);if(r.transport.targets&&r.transport.targets.length&&r.formatters&&typeof r.formatters.level==`function`)throw Error(`option.transport.targets do not allow custom level formatters`);let e;r.customLevels&&(e=r.useOnlyCustomLevels?r.customLevels:Object.assign({},r.levels,r.customLevels)),i=ee({caller:n,...r.transport,levels:e})}if(r=Object.assign({},e,r),r.serializers=Object.assign({},e.serializers,r.serializers),r.formatters=Object.assign({},e.formatters,r.formatters),r.prettyPrint)throw Error(`prettyPrint option is no longer supported, see the pino-pretty package (https://github.com/pinojs/pino-pretty)`);let{enabled:a,onChild:s}=r;return a===!1&&(r.level=`silent`),s||(r.onChild=O),i||=se(process.stdout)?process.stdout:j({fd:process.stdout.fd||1}),{opts:r,stream:i}}}function pe(e,t){try{return JSON.stringify(e)}catch{try{return(t||this[g])(e)}catch{return`"[unable to serialize, circular reference is too complex to analyze]"`}}}function me(e,t,n){return{level:e,bindings:t,log:n}}function he(e){let t=Number(e);return typeof e==`string`&&Number.isFinite(t)?t:e===void 0?1:e}t.exports={noop:O,buildSafeSonicBoom:j,asChindings:ae,asJson:re,genLog:k,createArgsNormalizer:fe,stringify:pe,buildFormatters:me,normalizeDestFileDescriptor:he}})),ve=/* @__PURE__ */ w(((e,t)=>{t.exports={DEFAULT_LEVELS:{trace:10,debug:20,info:30,warn:40,error:50,fatal:60},SORTING_ORDER:{ASC:`ASC`,DESC:`DESC`}}})),ye=/* @__PURE__ */ w(((e,t)=>{let{lsCacheSym:n,levelValSym:r,useOnlyCustomLevelsSym:i,streamSym:a,formattersSym:o,hooksSym:s,levelCompSym:c}=oe(),{noop:l,genLog:u}=_e(),{DEFAULT_LEVELS:d,SORTING_ORDER:f}=ve(),p={fatal:e=>{let t=u(d.fatal,e);return function(...e){let n=this[a];if(t.call(this,...e),typeof n.flushSync==`function`)try{n.flushSync()}catch{}}},error:e=>u(d.error,e),warn:e=>u(d.warn,e),info:e=>u(d.info,e),debug:e=>u(d.debug,e),trace:e=>u(d.trace,e)},m=Object.keys(d).reduce((e,t)=>(e[d[t]]=t,e),{}),h=Object.keys(m).reduce((e,t)=>(e[t]=`{"level":`+Number(t),e),{});function g(e){let t=e[o].level,{labels:r}=e.levels,i={};for(let e in r){let n=t(r[e],Number(e));i[e]=JSON.stringify(n).slice(0,-1)}return e[n]=i,e}function _(e,t){if(t)return!1;switch(e){case`fatal`:case`error`:case`warn`:case`info`:case`debug`:case`trace`:return!0;default:return!1}}function v(e){let{labels:t,values:n}=this.levels;if(typeof e==`number`){if(t[e]===void 0)throw Error(`unknown level value`+e);e=t[e]}if(n[e]===void 0)throw Error(`unknown level `+e);let a=this[r],o=this[r]=n[e],d=this[i],f=this[c],m=this[s].logMethod;for(let e in n){if(f(n[e],o)===!1){this[e]=l;continue}this[e]=_(e,d)?p[e](m):u(n[e],m)}this.emit(`level-change`,e,o,t[a],a,this)}function y(e){let{levels:t,levelVal:n}=this;return t&&t.labels?t.labels[n]:``}function b(e){let{values:t}=this.levels,n=t[e];return n!==void 0&&this[c](n,this[r])}function x(e,t,n){return e===f.DESC?t<=n:t>=n}function S(e){return typeof e==`string`?x.bind(null,e):e}function C(e=null,t=!1){let n=e?Object.keys(e).reduce((t,n)=>(t[e[n]]=n,t),{}):null;return{labels:Object.assign(Object.create(Object.prototype,{Infinity:{value:`silent`}}),t?null:m,n),values:Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),t?null:d,e)}}function w(e,t,n){if(typeof e==`number`){if(![].concat(Object.keys(t||{}).map(e=>t[e]),n?[]:Object.keys(m).map(e=>+e),1/0).includes(e))throw Error(`default level:${e} must be included in custom levels`);return}if(!(e in Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),n?null:d,t)))throw Error(`default level:${e} must be included in custom levels`)}function ee(e,t){let{labels:n,values:r}=e;for(let e in t){if(e in r)throw Error(`levels cannot be overridden`);if(t[e]in n)throw Error(`pre-existing level values cannot be used for new levels`)}}function T(e){if(typeof e!=`function`&&!(typeof e==`string`&&Object.values(f).includes(e)))throw Error(`Levels comparison should be one of "ASC", "DESC" or "function" type`)}t.exports={initialLsCache:h,genLsCache:g,levelMethods:p,getLevel:y,setLevel:v,isLevelEnabled:b,mappings:C,assertNoLevelCollisions:ee,assertDefaultLevelFound:w,genLevelComparison:S,assertLevelComparison:T}})),be=/* @__PURE__ */ w(((e,t)=>{t.exports={version:`10.3.1`}})),xe=/* @__PURE__ */ w(((e,t)=>{let{EventEmitter:n}=E(`node:events`),{lsCacheSym:r,levelValSym:i,setLevelSym:a,getLevelSym:o,chindingsSym:s,mixinSym:c,asJsonSym:l,writeSym:u,mixinMergeStrategySym:d,timeSym:f,timeSliceIndexSym:p,streamSym:m,serializersSym:h,formattersSym:g,errorKeySym:_,messageKeySym:v,useOnlyCustomLevelsSym:y,needsMetadataGsym:b,redactFmtSym:x,stringifySym:S,formatOptsSym:C,stringifiersSym:w,msgPrefixSym:ee,hooksSym:T}=oe(),{getLevel:te,setLevel:D,isLevelEnabled:O,mappings:k,initialLsCache:ne,genLsCache:re,assertNoLevelCollisions:ie}=ye(),{asChindings:A,asJson:ae,buildFormatters:j,stringify:ce,noop:le}=_e(),{version:ue}=be(),de=se(),fe={constructor:class{},child:me,bindings:he,setBindings:ge,flush:Se,isLevelEnabled:O,version:ue,get level(){return this[o]()},set level(e){this[a](e)},get levelVal(){return this[i]},set levelVal(e){throw Error(`levelVal is read-only`)},get msgPrefix(){return this[ee]},get[Symbol.toStringTag](){return`Pino`},[r]:ne,[u]:xe,[l]:ae,[o]:te,[a]:D};Object.setPrototypeOf(fe,n.prototype),t.exports=function(){return Object.create(fe)};let pe=e=>e;function me(e,t){if(!e)throw Error(`missing bindings for child Pino`);let n=this[h],r=this[g],i=Object.create(this);if(t==null)return i[g].bindings!==pe&&(i[g]=j(r.level,pe,r.log)),i[s]=A(i,e),this.onChild!==le&&this.onChild(i),i;if(t.hasOwnProperty(`serializers`)===!0){i[h]=Object.create(null);for(let e in n)i[h][e]=n[e];let e=Object.getOwnPropertySymbols(n);for(var o=0;o<e.length;o++){let t=e[o];i[h][t]=n[t]}for(let e in t.serializers)i[h][e]=t.serializers[e];let r=Object.getOwnPropertySymbols(t.serializers);for(var c=0;c<r.length;c++){let e=r[c];i[h][e]=t.serializers[e]}}else i[h]=n;if(t.hasOwnProperty(`formatters`)){let{level:e,bindings:n,log:a}=t.formatters;i[g]=j(e||r.level,n||pe,a||r.log)}else i[g]=j(r.level,pe,r.log);if(t.hasOwnProperty(`customLevels`)===!0&&(ie(this.levels,t.customLevels),i.levels=k(t.customLevels,i[y]),re(i)),typeof t.redact==`object`&&t.redact!==null||Array.isArray(t.redact)){i.redact=t.redact;let e=de(i.redact,ce),n={stringify:e[x]};i[S]=ce,i[w]=e,i[C]=n}if(typeof t.msgPrefix==`string`&&(i[ee]=(this[ee]||``)+t.msgPrefix),i[s]=A(i,e),t.level!==void 0&&t.level!==this.level||t.hasOwnProperty(`customLevels`)){let e=t.level||this.level;i[a](e)}return this.onChild(i),i}function he(){let e=`{${this[s].substr(1)}}`,t=JSON.parse(e);return delete t.pid,delete t.hostname,t}function ge(e){let t=A(this,e);this[s]=t}function ve(e,t){return Object.assign(t,e)}function xe(e,t,n){let r=this[f](),i=this[c],a=this[_],o=this[v],s=this[d]||ve,u,h=this[T].streamWrite;e==null?u={}:e instanceof Error?(u={[a]:e},t===void 0&&(t=e.message)):(u=e,t===void 0&&e[o]===void 0&&e[a]&&(t=e[a].message)),i&&(u=s(u,i(u,n,this)));let g=this[l](u,t,n,r),y=this[m];y[b]===!0&&(y.lastLevel=n,y.lastObj=u,y.lastMsg=t,y.lastTime=r.slice(this[p]),y.lastLogger=this),y.write(h?h(g):g)}function Se(e){if(e!=null&&typeof e!=`function`)throw Error(`callback must be a function`);let t=this[m];typeof t.flush==`function`?t.flush(e||le):e&&e()}})),Se=/* @__PURE__ */ w(((e,t)=>{let{hasOwnProperty:n}=Object.prototype,r=_();r.configure=_,r.stringify=r,r.default=r,e.stringify=r,e.configure=_,t.exports=r;let i=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function a(e){return e.length<5e3&&!i.test(e)?`"${e}"`:JSON.stringify(e)}function o(e,t){if(e.length>200||t)return e.sort(t);for(let t=1;t<e.length;t++){let n=e[t],r=t;for(;r!==0&&e[r-1]>n;)e[r]=e[r-1],r--;e[r]=n}return e}let s=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(/* @__PURE__ */ new Int8Array)),Symbol.toStringTag).get;function c(e){return s.call(e)!==void 0&&e.length!==0}function l(e,t,n){e.length<n&&(n=e.length);let r=t===`,`?``:` `,i=`"0":${r}${e[0]}`;for(let a=1;a<n;a++)i+=`${t}"${a}":${r}${e[a]}`;return i}function u(e){if(n.call(e,`circularValue`)){let t=e.circularValue;if(typeof t==`string`)return`"${t}"`;if(t==null)return t;if(t===Error||t===TypeError)return{toString(){throw TypeError(`Converting circular structure to JSON`)}};throw TypeError(`The "circularValue" argument must be of type string or the value null or undefined`)}return`"[Circular]"`}function d(e){let t;if(n.call(e,`deterministic`)&&(t=e.deterministic,typeof t!=`boolean`&&typeof t!=`function`))throw TypeError(`The "deterministic" argument must be of type boolean or comparator function`);return t===void 0||t}function f(e,t){let r;if(n.call(e,t)&&(r=e[t],typeof r!=`boolean`))throw TypeError(`The "${t}" argument must be of type boolean`);return r===void 0||r}function p(e,t){let r;if(n.call(e,t)){if(r=e[t],typeof r!=`number`)throw TypeError(`The "${t}" argument must be of type number`);if(!Number.isInteger(r))throw TypeError(`The "${t}" argument must be an integer`);if(r<1)throw RangeError(`The "${t}" argument must be >= 1`)}return r===void 0?1/0:r}function m(e){return e===1?`1 item`:`${e} items`}function h(e){let t=/* @__PURE__ */ new Set;for(let n of e)(typeof n==`string`||typeof n==`number`)&&t.add(String(n));return t}function g(e){if(n.call(e,`strict`)){let t=e.strict;if(typeof t!=`boolean`)throw TypeError(`The "strict" argument must be of type boolean`);if(t)return e=>{let t=`Object can not safely be stringified. Received type ${typeof e}`;throw typeof e!=`function`&&(t+=` (${e.toString()})`),Error(t)}}}function _(e){e={...e};let t=g(e);t&&(e.bigint===void 0&&(e.bigint=!1),`circularValue`in e||(e.circularValue=Error));let n=u(e),r=f(e,`bigint`),i=d(e),s=typeof i==`function`?i:void 0,_=p(e,`maximumDepth`),v=p(e,`maximumBreadth`);function y(e,l,u,d,f,p){let h=l[e];switch(typeof h==`object`&&h&&typeof h.toJSON==`function`&&(h=h.toJSON(e)),h=d.call(l,e,h),typeof h){case`string`:return a(h);case`object`:{if(h===null)return`null`;if(u.indexOf(h)!==-1)return n;let e=``,t=`,`,r=p;if(Array.isArray(h)){if(h.length===0)return`[]`;if(_<u.length+1)return`"[Array]"`;u.push(h),f!==``&&(p+=f,e+=`\n${p}`,t=`,\n${p}`);let n=Math.min(h.length,v),i=0;for(;i<n-1;i++){let n=y(String(i),h,u,d,f,p);e+=n===void 0?`null`:n,e+=t}let a=y(String(i),h,u,d,f,p);if(e+=a===void 0?`null`:a,h.length-1>v){let n=h.length-v-1;e+=`${t}"... ${m(n)} not stringified"`}return f!==``&&(e+=`\n${r}`),u.pop(),`[${e}]`}let l=Object.keys(h),g=l.length;if(g===0)return`{}`;if(_<u.length+1)return`"[Object]"`;let b=``,x=``;f!==``&&(p+=f,t=`,\n${p}`,b=` `);let S=Math.min(g,v);i&&!c(h)&&(l=o(l,s)),u.push(h);for(let n=0;n<S;n++){let r=l[n],i=y(r,h,u,d,f,p);i!==void 0&&(e+=`${x}${a(r)}:${b}${i}`,x=t)}if(g>v){let n=g-v;e+=`${x}"...":${b}"${m(n)} not stringified"`,x=t}return f!==``&&x.length>1&&(e=`\n${p}${e}\n${r}`),u.pop(),`{${e}}`}case`number`:return isFinite(h)?String(h):t?t(h):`null`;case`boolean`:return h===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(h);default:return t?t(h):void 0}}function b(e,i,o,s,c,l){switch(typeof i==`object`&&i&&typeof i.toJSON==`function`&&(i=i.toJSON(e)),typeof i){case`string`:return a(i);case`object`:{if(i===null)return`null`;if(o.indexOf(i)!==-1)return n;let e=l,t=``,r=`,`;if(Array.isArray(i)){if(i.length===0)return`[]`;if(_<o.length+1)return`"[Array]"`;o.push(i),c!==``&&(l+=c,t+=`\n${l}`,r=`,\n${l}`);let n=Math.min(i.length,v),a=0;for(;a<n-1;a++){let e=b(String(a),i[a],o,s,c,l);t+=e===void 0?`null`:e,t+=r}let u=b(String(a),i[a],o,s,c,l);if(t+=u===void 0?`null`:u,i.length-1>v){let e=i.length-v-1;t+=`${r}"... ${m(e)} not stringified"`}return c!==``&&(t+=`\n${e}`),o.pop(),`[${t}]`}o.push(i);let u=``;c!==``&&(l+=c,r=`,\n${l}`,u=` `);let d=``;for(let e of s){let n=b(e,i[e],o,s,c,l);n!==void 0&&(t+=`${d}${a(e)}:${u}${n}`,d=r)}return c!==``&&d.length>1&&(t=`\n${l}${t}\n${e}`),o.pop(),`{${t}}`}case`number`:return isFinite(i)?String(i):t?t(i):`null`;case`boolean`:return i===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(i);default:return t?t(i):void 0}}function x(e,u,d,f,p){switch(typeof u){case`string`:return a(u);case`object`:{if(u===null)return`null`;if(typeof u.toJSON==`function`){if(u=u.toJSON(e),typeof u!=`object`)return x(e,u,d,f,p);if(u===null)return`null`}if(d.indexOf(u)!==-1)return n;let t=p;if(Array.isArray(u)){if(u.length===0)return`[]`;if(_<d.length+1)return`"[Array]"`;d.push(u),p+=f;let e=`\n${p}`,n=`,\n${p}`,r=Math.min(u.length,v),i=0;for(;i<r-1;i++){let t=x(String(i),u[i],d,f,p);e+=t===void 0?`null`:t,e+=n}let a=x(String(i),u[i],d,f,p);if(e+=a===void 0?`null`:a,u.length-1>v){let t=u.length-v-1;e+=`${n}"... ${m(t)} not stringified"`}return e+=`\n${t}`,d.pop(),`[${e}]`}let r=Object.keys(u),h=r.length;if(h===0)return`{}`;if(_<d.length+1)return`"[Object]"`;p+=f;let g=`,\n${p}`,y=``,b=``,S=Math.min(h,v);c(u)&&(y+=l(u,g,v),r=r.slice(u.length),S-=u.length,b=g),i&&(r=o(r,s)),d.push(u);for(let e=0;e<S;e++){let t=r[e],n=x(t,u[t],d,f,p);n!==void 0&&(y+=`${b}${a(t)}: ${n}`,b=g)}if(h>v){let e=h-v;y+=`${b}"...": "${m(e)} not stringified"`,b=g}return b!==``&&(y=`\n${p}${y}\n${t}`),d.pop(),`{${y}}`}case`number`:return isFinite(u)?String(u):t?t(u):`null`;case`boolean`:return u===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(u);default:return t?t(u):void 0}}function S(e,u,d){switch(typeof u){case`string`:return a(u);case`object`:{if(u===null)return`null`;if(typeof u.toJSON==`function`){if(u=u.toJSON(e),typeof u!=`object`)return S(e,u,d);if(u===null)return`null`}if(d.indexOf(u)!==-1)return n;let t=``,r=u.length!==void 0;if(r&&Array.isArray(u)){if(u.length===0)return`[]`;if(_<d.length+1)return`"[Array]"`;d.push(u);let e=Math.min(u.length,v),n=0;for(;n<e-1;n++){let e=S(String(n),u[n],d);t+=e===void 0?`null`:e,t+=`,`}let r=S(String(n),u[n],d);if(t+=r===void 0?`null`:r,u.length-1>v){let e=u.length-v-1;t+=`,"... ${m(e)} not stringified"`}return d.pop(),`[${t}]`}let f=Object.keys(u),p=f.length;if(p===0)return`{}`;if(_<d.length+1)return`"[Object]"`;let h=``,g=Math.min(p,v);r&&c(u)&&(t+=l(u,`,`,v),f=f.slice(u.length),g-=u.length,h=`,`),i&&(f=o(f,s)),d.push(u);for(let e=0;e<g;e++){let n=f[e],r=S(n,u[n],d);r!==void 0&&(t+=`${h}${a(n)}:${r}`,h=`,`)}if(p>v){let e=p-v;t+=`${h}"...":"${m(e)} not stringified"`}return d.pop(),`{${t}}`}case`number`:return isFinite(u)?String(u):t?t(u):`null`;case`boolean`:return u===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(u);default:return t?t(u):void 0}}function C(e,t,n){if(arguments.length>1){let r=``;if(typeof n==`number`?r=` `.repeat(Math.min(n,10)):typeof n==`string`&&(r=n.slice(0,10)),t!=null){if(typeof t==`function`)return y(``,{"":e},[],t,r,``);if(Array.isArray(t))return b(``,e,[],h(t),r,``)}if(r.length!==0)return x(``,e,[],r,``)}return S(``,e,[])}return C}})),Ce=/* @__PURE__ */ w(((e,t)=>{let n=Symbol.for(`pino.metadata`),{DEFAULT_LEVELS:r}=ve(),i=r.info;function a(e,t){e||=[],t||={dedupe:!1};let a=Object.create(r);a.silent=1/0,t.levels&&typeof t.levels==`object`&&Object.keys(t.levels).forEach(e=>{a[e]=t.levels[e]});let u={write:d,add:m,remove:h,emit:f,flushSync:p,end:g,minLevel:0,lastId:0,streams:[],clone:_,[n]:!0,streamLevels:a};return Array.isArray(e)?e.forEach(m,u):m.call(u,e),e=null,u;function d(e){let r,i=this.lastLevel,{streams:a}=this,o=0,u;for(let d=s(a.length,t.dedupe);l(d,a.length,t.dedupe);d=c(d,t.dedupe))if(r=a[d],r.level<=i){if(o!==0&&o!==r.level)break;if(u=r.stream,u[n]){let{lastTime:e,lastMsg:t,lastObj:n,lastLogger:r}=this;u.lastLevel=i,u.lastTime=e,u.lastMsg=t,u.lastObj=n,u.lastLogger=r}u.write(e),t.dedupe&&(o=r.level)}else if(!t.dedupe)break}function f(...e){for(let{stream:t}of this.streams)typeof t.emit==`function`&&t.emit(...e)}function p(){for(let{stream:e}of this.streams)typeof e.flushSync==`function`&&e.flushSync()}function m(e){if(!e)return u;let t=typeof e.write==`function`||e.stream,n=e.write?e:e.stream;if(!t)throw Error(`stream object needs to implement either StreamEntry or DestinationStream interface`);let{streams:r,streamLevels:a}=this,s;s=typeof e.levelVal==`number`?e.levelVal:typeof e.level==`string`?a[e.level]:typeof e.level==`number`?e.level:i;let c={stream:n,level:s,levelVal:void 0,id:++u.lastId};return r.unshift(c),r.sort(o),this.minLevel=r[0].level,u}function h(e){let{streams:t}=this,n=t.findIndex(t=>t.id===e);return n>=0&&(t.splice(n,1),t.sort(o),this.minLevel=t.length>0?t[0].level:-1),u}function g(){for(let{stream:e}of this.streams)typeof e.flushSync==`function`&&e.flushSync(),e.end()}function _(e){let t=Array(this.streams.length);for(let n=0;n<t.length;n++)t[n]={level:e,stream:this.streams[n].stream};return{write:d,add:m,remove:h,minLevel:e,streams:t,clone:_,emit:f,flushSync:p,[n]:!0}}}function o(e,t){return e.level-t.level}function s(e,t){return t?e-1:0}function c(e,t){return t?e-1:e+1}function l(e,t,n){return n?e>=0:e<t}t.exports=a})),we=/* @__PURE__ */ T((/* @__PURE__ */ w(((e,t)=>{let n=E(`node:os`),r=ie(),i=A(),a=se(),o=j(),s=xe(),c=oe(),{configure:l}=Se(),{assertDefaultLevelFound:u,mappings:d,genLsCache:f,genLevelComparison:p,assertLevelComparison:m}=ye(),{DEFAULT_LEVELS:h,SORTING_ORDER:g}=ve(),{createArgsNormalizer:_,asChindings:v,buildSafeSonicBoom:y,buildFormatters:b,stringify:x,normalizeDestFileDescriptor:S,noop:C}=_e(),{version:w}=be(),{chindingsSym:ee,redactFmtSym:T,serializersSym:te,timeSym:D,timeSliceIndexSym:O,streamSym:k,stringifySym:ne,stringifySafeSym:re,stringifiersSym:ae,setLevelSym:ce,endSym:le,formatOptsSym:ue,messageKeySym:de,errorKeySym:fe,nestedKeySym:pe,mixinSym:me,levelCompSym:he,useOnlyCustomLevelsSym:we,formattersSym:Te,hooksSym:Ee,nestedKeyStrSym:De,mixinMergeStrategySym:Oe,msgPrefixSym:ke}=c,{epochTime:Ae,nullTime:je}=o,{pid:Me}=process,Ne=n.hostname(),Pe=r.err,Fe=_({level:`info`,levelComparison:g.ASC,levels:h,messageKey:`msg`,errorKey:`err`,nestedKey:null,enabled:!0,base:{pid:Me,hostname:Ne},serializers:Object.assign(Object.create(null),{err:Pe}),formatters:Object.assign(Object.create(null),{bindings(e){return e},level(e,t){return{level:t}}}),hooks:{logMethod:void 0,streamWrite:void 0},timestamp:Ae,name:void 0,redact:null,customLevels:null,useOnlyCustomLevels:!1,depthLimit:5,edgeLimit:100}),Ie=Object.assign(Object.create(null),r);function Le(...e){let t={},{opts:n,stream:r}=Fe(t,i(),...e);n.level&&typeof n.level==`string`&&h[n.level.toLowerCase()]!==void 0&&(n.level=n.level.toLowerCase());let{redact:o,crlf:c,serializers:g,timestamp:_,messageKey:y,errorKey:S,nestedKey:w,base:E,name:ie,level:A,customLevels:oe,levelComparison:se,mixin:j,mixinMergeStrategy:ge,useOnlyCustomLevels:_e,formatters:ve,hooks:ye,depthLimit:be,edgeLimit:xe,onChild:Se,msgPrefix:Ce}=n,Me=l({maximumDepth:be,maximumBreadth:xe}),Ne=b(ve.level,ve.bindings,ve.log),Pe=x.bind({[re]:Me}),Ie=o?a(o,Pe):{},Le=o?{stringify:Ie[T]}:{stringify:Pe},Re=`}`+(c?`\r
|
|
10
|
+
e.flushSync())}function fe(e){return function(t,n,r={},i){if(typeof r==`string`)i=j({dest:r}),r={};else if(typeof i==`string`){if(r&&r.transport)throw Error(`only one of option.transport or stream can be specified`);i=j({dest:i})}else if(r instanceof o||r.writable||r._writableState)i=r,r={};else if(r.transport){if(r.transport instanceof o||r.transport.writable||r.transport._writableState)throw Error(`option.transport do not allow stream, please pass to option directly. e.g. pino(transport)`);if(r.transport.targets&&r.transport.targets.length&&r.formatters&&typeof r.formatters.level==`function`)throw Error(`option.transport.targets do not allow custom level formatters`);let e;r.customLevels&&(e=r.useOnlyCustomLevels?r.customLevels:Object.assign({},r.levels,r.customLevels)),i=ee({caller:n,...r.transport,levels:e})}if(r=Object.assign({},e,r),r.serializers=Object.assign({},e.serializers,r.serializers),r.formatters=Object.assign({},e.formatters,r.formatters),r.prettyPrint)throw Error(`prettyPrint option is no longer supported, see the pino-pretty package (https://github.com/pinojs/pino-pretty)`);let{enabled:a,onChild:s}=r;return a===!1&&(r.level=`silent`),s||(r.onChild=O),i||=se(process.stdout)?process.stdout:j({fd:process.stdout.fd||1}),{opts:r,stream:i}}}function pe(e,t){try{return JSON.stringify(e)}catch{try{return(t||this[g])(e)}catch{return`"[unable to serialize, circular reference is too complex to analyze]"`}}}function me(e,t,n){return{level:e,bindings:t,log:n}}function he(e){let t=Number(e);return typeof e==`string`&&Number.isFinite(t)?t:e===void 0?1:e}t.exports={noop:O,buildSafeSonicBoom:j,asChindings:ae,asJson:re,genLog:k,createArgsNormalizer:fe,stringify:pe,buildFormatters:me,normalizeDestFileDescriptor:he}})),ve=/* @__PURE__ */ w(((e,t)=>{t.exports={DEFAULT_LEVELS:{trace:10,debug:20,info:30,warn:40,error:50,fatal:60},SORTING_ORDER:{ASC:`ASC`,DESC:`DESC`}}})),ye=/* @__PURE__ */ w(((e,t)=>{let{lsCacheSym:n,levelValSym:r,useOnlyCustomLevelsSym:i,streamSym:a,formattersSym:o,hooksSym:s,levelCompSym:c}=oe(),{noop:l,genLog:u}=_e(),{DEFAULT_LEVELS:d,SORTING_ORDER:f}=ve(),p={fatal:e=>{let t=u(d.fatal,e);return function(...e){let n=this[a];if(t.call(this,...e),typeof n.flushSync==`function`)try{n.flushSync()}catch{}}},error:e=>u(d.error,e),warn:e=>u(d.warn,e),info:e=>u(d.info,e),debug:e=>u(d.debug,e),trace:e=>u(d.trace,e)},m=Object.keys(d).reduce((e,t)=>(e[d[t]]=t,e),{}),h=Object.keys(m).reduce((e,t)=>(e[t]=`{"level":`+Number(t),e),{});function g(e){let t=e[o].level,{labels:r}=e.levels,i={};for(let e in r){let n=t(r[e],Number(e));i[e]=JSON.stringify(n).slice(0,-1)}return e[n]=i,e}function _(e,t){if(t)return!1;switch(e){case`fatal`:case`error`:case`warn`:case`info`:case`debug`:case`trace`:return!0;default:return!1}}function v(e){let{labels:t,values:n}=this.levels;if(typeof e==`number`){if(t[e]===void 0)throw Error(`unknown level value`+e);e=t[e]}if(n[e]===void 0)throw Error(`unknown level `+e);let a=this[r],o=this[r]=n[e],d=this[i],f=this[c],m=this[s].logMethod;for(let e in n){if(f(n[e],o)===!1){this[e]=l;continue}this[e]=_(e,d)?p[e](m):u(n[e],m)}this.emit(`level-change`,e,o,t[a],a,this)}function y(e){let{levels:t,levelVal:n}=this;return t&&t.labels?t.labels[n]:``}function b(e){let{values:t}=this.levels,n=t[e];return n!==void 0&&this[c](n,this[r])}function x(e,t,n){return e===f.DESC?t<=n:t>=n}function S(e){return typeof e==`string`?x.bind(null,e):e}function C(e=null,t=!1){let n=e?Object.keys(e).reduce((t,n)=>(t[e[n]]=n,t),{}):null;return{labels:Object.assign(Object.create(Object.prototype,{Infinity:{value:`silent`}}),t?null:m,n),values:Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),t?null:d,e)}}function w(e,t,n){if(typeof e==`number`){if(![].concat(Object.keys(t||{}).map(e=>t[e]),n?[]:Object.keys(m).map(e=>+e),1/0).includes(e))throw Error(`default level:${e} must be included in custom levels`);return}if(!(e in Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),n?null:d,t)))throw Error(`default level:${e} must be included in custom levels`)}function ee(e,t){let{labels:n,values:r}=e;for(let e in t){if(e in r)throw Error(`levels cannot be overridden`);if(t[e]in n)throw Error(`pre-existing level values cannot be used for new levels`)}}function te(e){if(typeof e!=`function`&&!(typeof e==`string`&&Object.values(f).includes(e)))throw Error(`Levels comparison should be one of "ASC", "DESC" or "function" type`)}t.exports={initialLsCache:h,genLsCache:g,levelMethods:p,getLevel:y,setLevel:v,isLevelEnabled:b,mappings:C,assertNoLevelCollisions:ee,assertDefaultLevelFound:w,genLevelComparison:S,assertLevelComparison:te}})),be=/* @__PURE__ */ w(((e,t)=>{t.exports={version:`10.3.1`}})),xe=/* @__PURE__ */ w(((e,t)=>{let{EventEmitter:n}=T(`node:events`),{lsCacheSym:r,levelValSym:i,setLevelSym:a,getLevelSym:o,chindingsSym:s,mixinSym:c,asJsonSym:l,writeSym:u,mixinMergeStrategySym:d,timeSym:f,timeSliceIndexSym:p,streamSym:m,serializersSym:h,formattersSym:g,errorKeySym:_,messageKeySym:v,useOnlyCustomLevelsSym:y,needsMetadataGsym:b,redactFmtSym:x,stringifySym:S,formatOptsSym:C,stringifiersSym:w,msgPrefixSym:ee,hooksSym:te}=oe(),{getLevel:E,setLevel:D,isLevelEnabled:O,mappings:k,initialLsCache:ne,genLsCache:re,assertNoLevelCollisions:ie}=ye(),{asChindings:A,asJson:ae,buildFormatters:j,stringify:ce,noop:le}=_e(),{version:ue}=be(),de=se(),fe={constructor:class{},child:me,bindings:he,setBindings:ge,flush:Se,isLevelEnabled:O,version:ue,get level(){return this[o]()},set level(e){this[a](e)},get levelVal(){return this[i]},set levelVal(e){throw Error(`levelVal is read-only`)},get msgPrefix(){return this[ee]},get[Symbol.toStringTag](){return`Pino`},[r]:ne,[u]:xe,[l]:ae,[o]:E,[a]:D};Object.setPrototypeOf(fe,n.prototype),t.exports=function(){return Object.create(fe)};let pe=e=>e;function me(e,t){if(!e)throw Error(`missing bindings for child Pino`);let n=this[h],r=this[g],i=Object.create(this);if(t==null)return i[g].bindings!==pe&&(i[g]=j(r.level,pe,r.log)),i[s]=A(i,e),this.onChild!==le&&this.onChild(i),i;if(t.hasOwnProperty(`serializers`)===!0){i[h]=Object.create(null);for(let e in n)i[h][e]=n[e];let e=Object.getOwnPropertySymbols(n);for(var o=0;o<e.length;o++){let t=e[o];i[h][t]=n[t]}for(let e in t.serializers)i[h][e]=t.serializers[e];let r=Object.getOwnPropertySymbols(t.serializers);for(var c=0;c<r.length;c++){let e=r[c];i[h][e]=t.serializers[e]}}else i[h]=n;if(t.hasOwnProperty(`formatters`)){let{level:e,bindings:n,log:a}=t.formatters;i[g]=j(e||r.level,n||pe,a||r.log)}else i[g]=j(r.level,pe,r.log);if(t.hasOwnProperty(`customLevels`)===!0&&(ie(this.levels,t.customLevels),i.levels=k(t.customLevels,i[y]),re(i)),typeof t.redact==`object`&&t.redact!==null||Array.isArray(t.redact)){i.redact=t.redact;let e=de(i.redact,ce),n={stringify:e[x]};i[S]=ce,i[w]=e,i[C]=n}if(typeof t.msgPrefix==`string`&&(i[ee]=(this[ee]||``)+t.msgPrefix),i[s]=A(i,e),t.level!==void 0&&t.level!==this.level||t.hasOwnProperty(`customLevels`)){let e=t.level||this.level;i[a](e)}return this.onChild(i),i}function he(){let e=`{${this[s].substr(1)}}`,t=JSON.parse(e);return delete t.pid,delete t.hostname,t}function ge(e){let t=A(this,e);this[s]=t}function ve(e,t){return Object.assign(t,e)}function xe(e,t,n){let r=this[f](),i=this[c],a=this[_],o=this[v],s=this[d]||ve,u,h=this[te].streamWrite;e==null?u={}:e instanceof Error?(u={[a]:e},t===void 0&&(t=e.message)):(u=e,t===void 0&&e[o]===void 0&&e[a]&&(t=e[a].message)),i&&(u=s(u,i(u,n,this)));let g=this[l](u,t,n,r),y=this[m];y[b]===!0&&(y.lastLevel=n,y.lastObj=u,y.lastMsg=t,y.lastTime=r.slice(this[p]),y.lastLogger=this),y.write(h?h(g):g)}function Se(e){if(e!=null&&typeof e!=`function`)throw Error(`callback must be a function`);let t=this[m];typeof t.flush==`function`?t.flush(e||le):e&&e()}})),Se=/* @__PURE__ */ w(((e,t)=>{let{hasOwnProperty:n}=Object.prototype,r=_();r.configure=_,r.stringify=r,r.default=r,e.stringify=r,e.configure=_,t.exports=r;let i=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function a(e){return e.length<5e3&&!i.test(e)?`"${e}"`:JSON.stringify(e)}function o(e,t){if(e.length>200||t)return e.sort(t);for(let t=1;t<e.length;t++){let n=e[t],r=t;for(;r!==0&&e[r-1]>n;)e[r]=e[r-1],r--;e[r]=n}return e}let s=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(/* @__PURE__ */ new Int8Array)),Symbol.toStringTag).get;function c(e){return s.call(e)!==void 0&&e.length!==0}function l(e,t,n){e.length<n&&(n=e.length);let r=t===`,`?``:` `,i=`"0":${r}${e[0]}`;for(let a=1;a<n;a++)i+=`${t}"${a}":${r}${e[a]}`;return i}function u(e){if(n.call(e,`circularValue`)){let t=e.circularValue;if(typeof t==`string`)return`"${t}"`;if(t==null)return t;if(t===Error||t===TypeError)return{toString(){throw TypeError(`Converting circular structure to JSON`)}};throw TypeError(`The "circularValue" argument must be of type string or the value null or undefined`)}return`"[Circular]"`}function d(e){let t;if(n.call(e,`deterministic`)&&(t=e.deterministic,typeof t!=`boolean`&&typeof t!=`function`))throw TypeError(`The "deterministic" argument must be of type boolean or comparator function`);return t===void 0||t}function f(e,t){let r;if(n.call(e,t)&&(r=e[t],typeof r!=`boolean`))throw TypeError(`The "${t}" argument must be of type boolean`);return r===void 0||r}function p(e,t){let r;if(n.call(e,t)){if(r=e[t],typeof r!=`number`)throw TypeError(`The "${t}" argument must be of type number`);if(!Number.isInteger(r))throw TypeError(`The "${t}" argument must be an integer`);if(r<1)throw RangeError(`The "${t}" argument must be >= 1`)}return r===void 0?1/0:r}function m(e){return e===1?`1 item`:`${e} items`}function h(e){let t=/* @__PURE__ */ new Set;for(let n of e)(typeof n==`string`||typeof n==`number`)&&t.add(String(n));return t}function g(e){if(n.call(e,`strict`)){let t=e.strict;if(typeof t!=`boolean`)throw TypeError(`The "strict" argument must be of type boolean`);if(t)return e=>{let t=`Object can not safely be stringified. Received type ${typeof e}`;throw typeof e!=`function`&&(t+=` (${e.toString()})`),Error(t)}}}function _(e){e={...e};let t=g(e);t&&(e.bigint===void 0&&(e.bigint=!1),`circularValue`in e||(e.circularValue=Error));let n=u(e),r=f(e,`bigint`),i=d(e),s=typeof i==`function`?i:void 0,_=p(e,`maximumDepth`),v=p(e,`maximumBreadth`);function y(e,l,u,d,f,p){let h=l[e];switch(typeof h==`object`&&h&&typeof h.toJSON==`function`&&(h=h.toJSON(e)),h=d.call(l,e,h),typeof h){case`string`:return a(h);case`object`:{if(h===null)return`null`;if(u.indexOf(h)!==-1)return n;let e=``,t=`,`,r=p;if(Array.isArray(h)){if(h.length===0)return`[]`;if(_<u.length+1)return`"[Array]"`;u.push(h),f!==``&&(p+=f,e+=`\n${p}`,t=`,\n${p}`);let n=Math.min(h.length,v),i=0;for(;i<n-1;i++){let n=y(String(i),h,u,d,f,p);e+=n===void 0?`null`:n,e+=t}let a=y(String(i),h,u,d,f,p);if(e+=a===void 0?`null`:a,h.length-1>v){let n=h.length-v-1;e+=`${t}"... ${m(n)} not stringified"`}return f!==``&&(e+=`\n${r}`),u.pop(),`[${e}]`}let l=Object.keys(h),g=l.length;if(g===0)return`{}`;if(_<u.length+1)return`"[Object]"`;let b=``,x=``;f!==``&&(p+=f,t=`,\n${p}`,b=` `);let S=Math.min(g,v);i&&!c(h)&&(l=o(l,s)),u.push(h);for(let n=0;n<S;n++){let r=l[n],i=y(r,h,u,d,f,p);i!==void 0&&(e+=`${x}${a(r)}:${b}${i}`,x=t)}if(g>v){let n=g-v;e+=`${x}"...":${b}"${m(n)} not stringified"`,x=t}return f!==``&&x.length>1&&(e=`\n${p}${e}\n${r}`),u.pop(),`{${e}}`}case`number`:return isFinite(h)?String(h):t?t(h):`null`;case`boolean`:return h===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(h);default:return t?t(h):void 0}}function b(e,i,o,s,c,l){switch(typeof i==`object`&&i&&typeof i.toJSON==`function`&&(i=i.toJSON(e)),typeof i){case`string`:return a(i);case`object`:{if(i===null)return`null`;if(o.indexOf(i)!==-1)return n;let e=l,t=``,r=`,`;if(Array.isArray(i)){if(i.length===0)return`[]`;if(_<o.length+1)return`"[Array]"`;o.push(i),c!==``&&(l+=c,t+=`\n${l}`,r=`,\n${l}`);let n=Math.min(i.length,v),a=0;for(;a<n-1;a++){let e=b(String(a),i[a],o,s,c,l);t+=e===void 0?`null`:e,t+=r}let u=b(String(a),i[a],o,s,c,l);if(t+=u===void 0?`null`:u,i.length-1>v){let e=i.length-v-1;t+=`${r}"... ${m(e)} not stringified"`}return c!==``&&(t+=`\n${e}`),o.pop(),`[${t}]`}o.push(i);let u=``;c!==``&&(l+=c,r=`,\n${l}`,u=` `);let d=``;for(let e of s){let n=b(e,i[e],o,s,c,l);n!==void 0&&(t+=`${d}${a(e)}:${u}${n}`,d=r)}return c!==``&&d.length>1&&(t=`\n${l}${t}\n${e}`),o.pop(),`{${t}}`}case`number`:return isFinite(i)?String(i):t?t(i):`null`;case`boolean`:return i===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(i);default:return t?t(i):void 0}}function x(e,u,d,f,p){switch(typeof u){case`string`:return a(u);case`object`:{if(u===null)return`null`;if(typeof u.toJSON==`function`){if(u=u.toJSON(e),typeof u!=`object`)return x(e,u,d,f,p);if(u===null)return`null`}if(d.indexOf(u)!==-1)return n;let t=p;if(Array.isArray(u)){if(u.length===0)return`[]`;if(_<d.length+1)return`"[Array]"`;d.push(u),p+=f;let e=`\n${p}`,n=`,\n${p}`,r=Math.min(u.length,v),i=0;for(;i<r-1;i++){let t=x(String(i),u[i],d,f,p);e+=t===void 0?`null`:t,e+=n}let a=x(String(i),u[i],d,f,p);if(e+=a===void 0?`null`:a,u.length-1>v){let t=u.length-v-1;e+=`${n}"... ${m(t)} not stringified"`}return e+=`\n${t}`,d.pop(),`[${e}]`}let r=Object.keys(u),h=r.length;if(h===0)return`{}`;if(_<d.length+1)return`"[Object]"`;p+=f;let g=`,\n${p}`,y=``,b=``,S=Math.min(h,v);c(u)&&(y+=l(u,g,v),r=r.slice(u.length),S-=u.length,b=g),i&&(r=o(r,s)),d.push(u);for(let e=0;e<S;e++){let t=r[e],n=x(t,u[t],d,f,p);n!==void 0&&(y+=`${b}${a(t)}: ${n}`,b=g)}if(h>v){let e=h-v;y+=`${b}"...": "${m(e)} not stringified"`,b=g}return b!==``&&(y=`\n${p}${y}\n${t}`),d.pop(),`{${y}}`}case`number`:return isFinite(u)?String(u):t?t(u):`null`;case`boolean`:return u===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(u);default:return t?t(u):void 0}}function S(e,u,d){switch(typeof u){case`string`:return a(u);case`object`:{if(u===null)return`null`;if(typeof u.toJSON==`function`){if(u=u.toJSON(e),typeof u!=`object`)return S(e,u,d);if(u===null)return`null`}if(d.indexOf(u)!==-1)return n;let t=``,r=u.length!==void 0;if(r&&Array.isArray(u)){if(u.length===0)return`[]`;if(_<d.length+1)return`"[Array]"`;d.push(u);let e=Math.min(u.length,v),n=0;for(;n<e-1;n++){let e=S(String(n),u[n],d);t+=e===void 0?`null`:e,t+=`,`}let r=S(String(n),u[n],d);if(t+=r===void 0?`null`:r,u.length-1>v){let e=u.length-v-1;t+=`,"... ${m(e)} not stringified"`}return d.pop(),`[${t}]`}let f=Object.keys(u),p=f.length;if(p===0)return`{}`;if(_<d.length+1)return`"[Object]"`;let h=``,g=Math.min(p,v);r&&c(u)&&(t+=l(u,`,`,v),f=f.slice(u.length),g-=u.length,h=`,`),i&&(f=o(f,s)),d.push(u);for(let e=0;e<g;e++){let n=f[e],r=S(n,u[n],d);r!==void 0&&(t+=`${h}${a(n)}:${r}`,h=`,`)}if(p>v){let e=p-v;t+=`${h}"...":"${m(e)} not stringified"`}return d.pop(),`{${t}}`}case`number`:return isFinite(u)?String(u):t?t(u):`null`;case`boolean`:return u===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(u);default:return t?t(u):void 0}}function C(e,t,n){if(arguments.length>1){let r=``;if(typeof n==`number`?r=` `.repeat(Math.min(n,10)):typeof n==`string`&&(r=n.slice(0,10)),t!=null){if(typeof t==`function`)return y(``,{"":e},[],t,r,``);if(Array.isArray(t))return b(``,e,[],h(t),r,``)}if(r.length!==0)return x(``,e,[],r,``)}return S(``,e,[])}return C}})),Ce=/* @__PURE__ */ w(((e,t)=>{let n=Symbol.for(`pino.metadata`),{DEFAULT_LEVELS:r}=ve(),i=r.info;function a(e,t){e||=[],t||={dedupe:!1};let a=Object.create(r);a.silent=1/0,t.levels&&typeof t.levels==`object`&&Object.keys(t.levels).forEach(e=>{a[e]=t.levels[e]});let u={write:d,add:m,remove:h,emit:f,flushSync:p,end:g,minLevel:0,lastId:0,streams:[],clone:_,[n]:!0,streamLevels:a};return Array.isArray(e)?e.forEach(m,u):m.call(u,e),e=null,u;function d(e){let r,i=this.lastLevel,{streams:a}=this,o=0,u;for(let d=s(a.length,t.dedupe);l(d,a.length,t.dedupe);d=c(d,t.dedupe))if(r=a[d],r.level<=i){if(o!==0&&o!==r.level)break;if(u=r.stream,u[n]){let{lastTime:e,lastMsg:t,lastObj:n,lastLogger:r}=this;u.lastLevel=i,u.lastTime=e,u.lastMsg=t,u.lastObj=n,u.lastLogger=r}u.write(e),t.dedupe&&(o=r.level)}else if(!t.dedupe)break}function f(...e){for(let{stream:t}of this.streams)typeof t.emit==`function`&&t.emit(...e)}function p(){for(let{stream:e}of this.streams)typeof e.flushSync==`function`&&e.flushSync()}function m(e){if(!e)return u;let t=typeof e.write==`function`||e.stream,n=e.write?e:e.stream;if(!t)throw Error(`stream object needs to implement either StreamEntry or DestinationStream interface`);let{streams:r,streamLevels:a}=this,s;s=typeof e.levelVal==`number`?e.levelVal:typeof e.level==`string`?a[e.level]:typeof e.level==`number`?e.level:i;let c={stream:n,level:s,levelVal:void 0,id:++u.lastId};return r.unshift(c),r.sort(o),this.minLevel=r[0].level,u}function h(e){let{streams:t}=this,n=t.findIndex(t=>t.id===e);return n>=0&&(t.splice(n,1),t.sort(o),this.minLevel=t.length>0?t[0].level:-1),u}function g(){for(let{stream:e}of this.streams)typeof e.flushSync==`function`&&e.flushSync(),e.end()}function _(e){let t=Array(this.streams.length);for(let n=0;n<t.length;n++)t[n]={level:e,stream:this.streams[n].stream};return{write:d,add:m,remove:h,minLevel:e,streams:t,clone:_,emit:f,flushSync:p,[n]:!0}}}function o(e,t){return e.level-t.level}function s(e,t){return t?e-1:0}function c(e,t){return t?e-1:e+1}function l(e,t,n){return n?e>=0:e<t}t.exports=a})),we=/* @__PURE__ */ te((/* @__PURE__ */ w(((e,t)=>{let n=T(`node:os`),r=ie(),i=A(),a=se(),o=j(),s=xe(),c=oe(),{configure:l}=Se(),{assertDefaultLevelFound:u,mappings:d,genLsCache:f,genLevelComparison:p,assertLevelComparison:m}=ye(),{DEFAULT_LEVELS:h,SORTING_ORDER:g}=ve(),{createArgsNormalizer:_,asChindings:v,buildSafeSonicBoom:y,buildFormatters:b,stringify:x,normalizeDestFileDescriptor:S,noop:C}=_e(),{version:w}=be(),{chindingsSym:ee,redactFmtSym:te,serializersSym:E,timeSym:D,timeSliceIndexSym:O,streamSym:k,stringifySym:ne,stringifySafeSym:re,stringifiersSym:ae,setLevelSym:ce,endSym:le,formatOptsSym:ue,messageKeySym:de,errorKeySym:fe,nestedKeySym:pe,mixinSym:me,levelCompSym:he,useOnlyCustomLevelsSym:we,formattersSym:Te,hooksSym:Ee,nestedKeyStrSym:De,mixinMergeStrategySym:Oe,msgPrefixSym:ke}=c,{epochTime:Ae,nullTime:je}=o,{pid:Me}=process,Ne=n.hostname(),Pe=r.err,Fe=_({level:`info`,levelComparison:g.ASC,levels:h,messageKey:`msg`,errorKey:`err`,nestedKey:null,enabled:!0,base:{pid:Me,hostname:Ne},serializers:Object.assign(Object.create(null),{err:Pe}),formatters:Object.assign(Object.create(null),{bindings(e){return e},level(e,t){return{level:t}}}),hooks:{logMethod:void 0,streamWrite:void 0},timestamp:Ae,name:void 0,redact:null,customLevels:null,useOnlyCustomLevels:!1,depthLimit:5,edgeLimit:100}),Ie=Object.assign(Object.create(null),r);function Le(...e){let t={},{opts:n,stream:r}=Fe(t,i(),...e);n.level&&typeof n.level==`string`&&h[n.level.toLowerCase()]!==void 0&&(n.level=n.level.toLowerCase());let{redact:o,crlf:c,serializers:g,timestamp:_,messageKey:y,errorKey:S,nestedKey:w,base:T,name:ie,level:A,customLevels:oe,levelComparison:se,mixin:j,mixinMergeStrategy:ge,useOnlyCustomLevels:_e,formatters:ve,hooks:ye,depthLimit:be,edgeLimit:xe,onChild:Se,msgPrefix:Ce}=n,Me=l({maximumDepth:be,maximumBreadth:xe}),Ne=b(ve.level,ve.bindings,ve.log),Pe=x.bind({[re]:Me}),Ie=o?a(o,Pe):{},Le=o?{stringify:Ie[te]}:{stringify:Pe},Re=`}`+(c?`\r
|
|
11
11
|
`:`
|
|
12
|
-
`),ze=v.bind(null,{[ee]:``,[te]:g,[ae]:Ie,[ne]:x,[re]:Me,[Te]:Ne}),Be=``;E!==null&&(Be=ze(ie===void 0?E:Object.assign({},E,{name:ie})));let Ve=_ instanceof Function?_:_?Ae:je,He=Ve().indexOf(`:`)+1;if(_e&&!oe)throw Error(`customLevels is required if useOnlyCustomLevels is set true`);if(j&&typeof j!=`function`)throw Error(`Unknown mixin type "${typeof j}" - expected "function"`);if(Ce&&typeof Ce!=`string`)throw Error(`Unknown msgPrefix type "${typeof Ce}" - expected "string"`);u(A,oe,_e);let Ue=d(oe,_e);typeof r.emit==`function`&&r.emit(`message`,{code:`PINO_CONFIG`,config:{levels:Ue,messageKey:y,errorKey:S}}),m(se);let We=p(se);return Object.assign(t,{levels:Ue,[he]:We,[we]:_e,[k]:r,[D]:Ve,[O]:He,[ne]:x,[re]:Me,[ae]:Ie,[le]:Re,[ue]:Le,[de]:y,[fe]:S,[pe]:w,[De]:w?`,${JSON.stringify(w)}:{`:``,[te]:g,[me]:j,[Oe]:ge,[ee]:Be,[Te]:Ne,[Ee]:ye,silent:C,onChild:Se,[ke]:Ce}),Object.setPrototypeOf(t,s()),f(t),t[ce](A),t}t.exports=Le,t.exports.destination=(e=process.stdout.fd)=>typeof e==`object`?(e.dest=S(e.dest||process.stdout.fd),y(e)):y({dest:S(e),minLength:0}),t.exports.transport=ge(),t.exports.multistream=Ce(),t.exports.levels=d(),t.exports.stdSerializers=Ie,t.exports.stdTimeFunctions=Object.assign({},o),t.exports.symbols=c,t.exports.version=w,t.exports.default=Le,t.exports.pino=Le})))(),1);const Te={debug:0,info:1,warn:2,error:3};function Ee(e){return{level:e}}function De(){return`,"time":"${(/* @__PURE__ */ new Date()).toISOString()}"`}let Oe={minLevel:`info`,enableConsole:!0,autoTracing:!1,pinoOptions:{level:`info`,base:{},formatters:{level:Ee},timestamp:De}};function ke(){return Oe}function Ae(){return 0}const je={debug:`debug`,info:`info`,warn:`warn`,error:`error`};function Me(e){return{level:e}}function Ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pe(){return`,"time":"${(/* @__PURE__ */ new Date()).toISOString()}"`}const Fe={minLevel:`info`,enableConsole:!0,autoTracing:!1,pinoOptions:{level:`info`,formatters:{level:Me},timestamp:Pe}};var Ie=class e{context;config;hasExplicitConfig;builtConfigVersion;pinoLogger;constructor(e,t={},n,r){this.context={module:e,operation:n,trace:r};let i=Object.keys(t).length===0,a=t===ke();this.hasExplicitConfig=!i&&!a,this.config=this.hasExplicitConfig?{...Fe,...t}:{...Fe,...ke()},this.builtConfigVersion=Ae(),this.pinoLogger=this.buildPinoLogger(this.config)}buildPinoLogger(e){let t={...e.pinoOptions,level:e.minLevel},n=e.pinoOptions?.base;return t.base={...Ne(n)?n:{},module:this.context.module},e.transport&&(t.transport=e.transport),(0,we.default)(t)}getActivePinoLogger(){if(this.hasExplicitConfig)return this.pinoLogger;let e=Ae();return e!==this.builtConfigVersion&&(this.config.minLevel=ke().minLevel??Fe.minLevel,this.config.transport=ke().transport,this.pinoLogger=this.buildPinoLogger(this.config),this.builtConfigVersion=e),this.pinoLogger}debug(e,t){this.log(`debug`,e,t)}info(e,t){this.log(`info`,e,t)}warn(e,t){this.log(`warn`,e,t)}error(e,t,n){this.log(`error`,e,n,t)}withOperation(t){return this.hasExplicitConfig?new e(this.context.module,this.config,t,this.context.trace):new e(this.context.module,{},t,this.context.trace)}withTrace(t){return this.hasExplicitConfig?new e(this.context.module,this.config,this.context.operation,t):new e(this.context.module,{},this.context.operation,t)}flush(){return new Promise(e=>{this.getActivePinoLogger().flush(()=>e())})}log(e,t,n,r){if(!this.shouldLog(e))return;let i={...n},a=this.context.operation;a&&(i.operation=a);let o=this.context.trace;o&&(i.traceId=o.traceId,i.spanId=o.spanId),r&&(i.error={name:r.name,message:r.message,stack:r.stack});let s=je[e],c=`[${this.context.module}${a?`:${a}`:``}] ${t}`;Object.keys(i).length>0?this.getActivePinoLogger()[s](i,c):this.getActivePinoLogger()[s](c)}shouldLog(e){return Te[e]>=Te[this.hasExplicitConfig?this.config.minLevel:ke().minLevel??Fe.minLevel]}getPinoLogger(){return this.getActivePinoLogger()}};function Le(e){return new Ie(e,ke())}Le(`App`),new s;var Re=class{module;constructor(e=`Noop`){this.module=e}debug(e,t){}info(e,t){}warn(e,t){}error(e,t,n){}withOperation(e){return this}withTrace(e){return this}flush(){return Promise.resolve()}getModule(){return this.module}};function ze(e=`Noop`){return new Re(e)}ze(`App`);function Be(e){return Le(e)}Be(`App`);var Ve=/* @__PURE__ */ w((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),He=/* @__PURE__ */ w((e=>{let{InvalidArgumentError:t}=Ve();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),Ue=/* @__PURE__ */ w((e=>{let{humanReadableArgName:t}=He();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=/* @__PURE__ */ new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
|
|
12
|
+
`),ze=v.bind(null,{[ee]:``,[E]:g,[ae]:Ie,[ne]:x,[re]:Me,[Te]:Ne}),Be=``;T!==null&&(Be=ze(ie===void 0?T:Object.assign({},T,{name:ie})));let Ve=_ instanceof Function?_:_?Ae:je,He=Ve().indexOf(`:`)+1;if(_e&&!oe)throw Error(`customLevels is required if useOnlyCustomLevels is set true`);if(j&&typeof j!=`function`)throw Error(`Unknown mixin type "${typeof j}" - expected "function"`);if(Ce&&typeof Ce!=`string`)throw Error(`Unknown msgPrefix type "${typeof Ce}" - expected "string"`);u(A,oe,_e);let Ue=d(oe,_e);typeof r.emit==`function`&&r.emit(`message`,{code:`PINO_CONFIG`,config:{levels:Ue,messageKey:y,errorKey:S}}),m(se);let We=p(se);return Object.assign(t,{levels:Ue,[he]:We,[we]:_e,[k]:r,[D]:Ve,[O]:He,[ne]:x,[re]:Me,[ae]:Ie,[le]:Re,[ue]:Le,[de]:y,[fe]:S,[pe]:w,[De]:w?`,${JSON.stringify(w)}:{`:``,[E]:g,[me]:j,[Oe]:ge,[ee]:Be,[Te]:Ne,[Ee]:ye,silent:C,onChild:Se,[ke]:Ce}),Object.setPrototypeOf(t,s()),f(t),t[ce](A),t}t.exports=Le,t.exports.destination=(e=process.stdout.fd)=>typeof e==`object`?(e.dest=S(e.dest||process.stdout.fd),y(e)):y({dest:S(e),minLength:0}),t.exports.transport=ge(),t.exports.multistream=Ce(),t.exports.levels=d(),t.exports.stdSerializers=Ie,t.exports.stdTimeFunctions=Object.assign({},o),t.exports.symbols=c,t.exports.version=w,t.exports.default=Le,t.exports.pino=Le})))(),1);const Te={debug:0,info:1,warn:2,error:3};function Ee(e){return{level:e}}function De(){return`,"time":"${(/* @__PURE__ */ new Date()).toISOString()}"`}let Oe={minLevel:`info`,enableConsole:!0,autoTracing:!1,pinoOptions:{level:`info`,base:{},formatters:{level:Ee},timestamp:De}};function ke(){return Oe}function Ae(){return 0}const je={debug:`debug`,info:`info`,warn:`warn`,error:`error`};function Me(e){return{level:e}}function Ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pe(){return`,"time":"${(/* @__PURE__ */ new Date()).toISOString()}"`}const Fe={minLevel:`info`,enableConsole:!0,autoTracing:!1,pinoOptions:{level:`info`,formatters:{level:Me},timestamp:Pe}};var Ie=class e{context;config;hasExplicitConfig;builtConfigVersion;pinoLogger;constructor(e,t={},n,r){this.context={module:e,operation:n,trace:r};let i=Object.keys(t).length===0,a=t===ke();this.hasExplicitConfig=!i&&!a,this.config=this.hasExplicitConfig?{...Fe,...t}:{...Fe,...ke()},this.builtConfigVersion=Ae(),this.pinoLogger=this.buildPinoLogger(this.config)}buildPinoLogger(e){let t={...e.pinoOptions,level:e.minLevel},n=e.pinoOptions?.base;return t.base={...Ne(n)?n:{},module:this.context.module},e.transport&&(t.transport=e.transport),(0,we.default)(t)}getActivePinoLogger(){if(this.hasExplicitConfig)return this.pinoLogger;let e=Ae();return e!==this.builtConfigVersion&&(this.config.minLevel=ke().minLevel??Fe.minLevel,this.config.transport=ke().transport,this.pinoLogger=this.buildPinoLogger(this.config),this.builtConfigVersion=e),this.pinoLogger}debug(e,t){this.log(`debug`,e,t)}info(e,t){this.log(`info`,e,t)}warn(e,t){this.log(`warn`,e,t)}error(e,t,n){this.log(`error`,e,n,t)}withOperation(t){return this.hasExplicitConfig?new e(this.context.module,this.config,t,this.context.trace):new e(this.context.module,{},t,this.context.trace)}withTrace(t){return this.hasExplicitConfig?new e(this.context.module,this.config,this.context.operation,t):new e(this.context.module,{},this.context.operation,t)}flush(){return new Promise(e=>{this.getActivePinoLogger().flush(()=>e())})}log(e,t,n,r){if(!this.shouldLog(e))return;let i={...n},a=this.context.operation;a&&(i.operation=a);let o=this.context.trace;o&&(i.traceId=o.traceId,i.spanId=o.spanId),r&&(i.error={name:r.name,message:r.message,stack:r.stack});let s=je[e],c=`[${this.context.module}${a?`:${a}`:``}] ${t}`;Object.keys(i).length>0?this.getActivePinoLogger()[s](i,c):this.getActivePinoLogger()[s](c)}shouldLog(e){return Te[e]>=Te[this.hasExplicitConfig?this.config.minLevel:ke().minLevel??Fe.minLevel]}getPinoLogger(){return this.getActivePinoLogger()}};function Le(e){return new Ie(e,ke())}Le(`App`),new s;var Re=class{module;constructor(e=`Noop`){this.module=e}debug(e,t){}info(e,t){}warn(e,t){}error(e,t,n){}withOperation(e){return this}withTrace(e){return this}flush(){return Promise.resolve()}getModule(){return this.module}};function ze(e=`Noop`){return new Re(e)}ze(`App`);function Be(e){return Le(e)}Be(`App`);var Ve=/* @__PURE__ */ w((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),He=/* @__PURE__ */ w((e=>{let{InvalidArgumentError:t}=Ve();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),Ue=/* @__PURE__ */ w((e=>{let{humanReadableArgName:t}=He();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=/* @__PURE__ */ new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
|
|
13
13
|
`)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
|
|
14
14
|
`+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
|
|
15
15
|
`)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),We=/* @__PURE__ */ w((e=>{let{InvalidArgumentError:t}=Ve();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=/* @__PURE__ */ new Map,this.negativeOptions=/* @__PURE__ */ new Map,this.dualOptions=/* @__PURE__ */ new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r!==void 0&&r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
|
|
@@ -18,7 +18,7 @@ e.flushSync())}function fe(e){return function(t,n,r={},i){if(typeof r==`string`)
|
|
|
18
18
|
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):r.test(t)?Error(`${n}
|
|
19
19
|
- too many short flags`):i.test(t)?Error(`${n}
|
|
20
20
|
- too many long flags`):Error(`${n}
|
|
21
|
-
- unrecognised flag format`)}if(t===void 0&&n===void 0)throw Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:n}}e.Option=n,e.DualOptions=r})),Ge=/* @__PURE__ */ w((e=>{function t(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let n=[];for(let t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=t.length;r++)for(let i=1;i<=e.length;i++){let a=1;a=e[i-1]===t[r-1]?0:1,n[i][r]=Math.min(n[i-1][r]+1,n[i][r-1]+1,n[i-1][r-1]+a),i>1&&r>1&&e[i-1]===t[r-2]&&e[i-2]===t[r-1]&&(n[i][r]=Math.min(n[i][r],n[i-2][r-2]+1))}return n[e.length][t.length]}function n(e,n){if(!n||n.length===0)return``;n=Array.from(new Set(n));let r=e.startsWith(`--`);r&&(e=e.slice(2),n=n.map(e=>e.slice(2)));let i=[],a=3;return n.forEach(n=>{if(n.length<=1)return;let r=t(e,n),o=Math.max(e.length,n.length);(o-r)/o>.4&&(r<a?(a=r,i=[n]):r===a&&i.push(n))}),i.sort((e,t)=>e.localeCompare(t)),r&&(i=i.map(e=>`--${e}`)),i.length>1?`\n(Did you mean one of ${i.join(`, `)}?)`:i.length===1?`\n(Did you mean ${i[0]}?)`:``}e.suggestSimilar=n})),Ke=/* @__PURE__ */ w((e=>{let t=
|
|
21
|
+
- unrecognised flag format`)}if(t===void 0&&n===void 0)throw Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:n}}e.Option=n,e.DualOptions=r})),Ge=/* @__PURE__ */ w((e=>{function t(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let n=[];for(let t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=t.length;r++)for(let i=1;i<=e.length;i++){let a=1;a=e[i-1]===t[r-1]?0:1,n[i][r]=Math.min(n[i-1][r]+1,n[i][r-1]+1,n[i-1][r-1]+a),i>1&&r>1&&e[i-1]===t[r-2]&&e[i-2]===t[r-1]&&(n[i][r]=Math.min(n[i][r],n[i-2][r-2]+1))}return n[e.length][t.length]}function n(e,n){if(!n||n.length===0)return``;n=Array.from(new Set(n));let r=e.startsWith(`--`);r&&(e=e.slice(2),n=n.map(e=>e.slice(2)));let i=[],a=3;return n.forEach(n=>{if(n.length<=1)return;let r=t(e,n),o=Math.max(e.length,n.length);(o-r)/o>.4&&(r<a?(a=r,i=[n]):r===a&&i.push(n))}),i.sort((e,t)=>e.localeCompare(t)),r&&(i=i.map(e=>`--${e}`)),i.length>1?`\n(Did you mean one of ${i.join(`, `)}?)`:i.length===1?`\n(Did you mean ${i[0]}?)`:``}e.suggestSimilar=n})),Ke=/* @__PURE__ */ w((e=>{let t=T(`node:events`).EventEmitter,n=T(`node:child_process`),r=T(`node:path`),i=T(`node:fs`),a=T(`node:process`),{Argument:o,humanReadableArgName:s}=He(),{CommanderError:c}=Ve(),{Help:l,stripColor:u}=Ue(),{Option:d,DualOptions:f}=We(),{suggestSimilar:p}=Ge();var m=class e extends t{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||``,this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description=``,this._summary=``,this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:e=>a.stdout.write(e),writeErr:e=>a.stderr.write(e),outputError:(e,t)=>t(e),getOutHelpWidth:()=>a.stdout.isTTY?a.stdout.columns:void 0,getErrHelpWidth:()=>a.stderr.isTTY?a.stderr.columns:void 0,getOutHasColors:()=>g()??(a.stdout.isTTY&&a.stdout.hasColors?.()),getErrHasColors:()=>g()??(a.stderr.isTTY&&a.stderr.hasColors?.()),stripColor:e=>u(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let r=t,i=n;typeof r==`object`&&r&&(i=r,r=null),i||={};let[,a,o]=e.match(/([^ ]+) *(.*)/),s=this.createCommand(a);return r&&(s.description(r),s._executableHandler=!0),i.isDefault&&(this._defaultCommandName=s._name),s._hidden=!!(i.noHelp||i.hidden),s._executableFile=i.executableFile||null,o&&s.arguments(o),this._registerCommand(s),s.parent=this,s.copyInheritedSettings(this),r?this:s}createCommand(t){return new e(t)}createHelp(){return Object.assign(new l,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!=`string`&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw Error(`Command passed to .addCommand() must have a name
|
|
22
22
|
- specify the name in Command constructor or using .name()`);return t||={},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new o(e,t)}argument(e,t,n,r){let i=this.createArgument(e,t);return typeof n==`function`?i.default(r).argParser(n):i.default(n),this.addArgument(i),this}arguments(e){return e.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e==`boolean`)return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let[,n,r]=(e??`help [command]`).match(/([^ ]+) *(.*)/),i=t??`display help for command`,a=this.createCommand(n);return a.helpOption(!1),r&&a.arguments(r),i&&a.description(i),this._addImplicitHelpCommand=!0,this._helpCommand=a,(e||t)&&this._initCommandGroup(a),this}addHelpCommand(e,t){return typeof e==`object`?(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this):(this.helpCommand(e,t),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand(`help`))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let n=[`preSubcommand`,`preAction`,`postAction`];if(!n.includes(e))throw Error(`Unexpected value for event passed to hook : '${e}'.
|
|
23
23
|
Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return this._exitCallback=e||(e=>{if(e.code!==`commander.executeSubCommandAsync`)throw e}),this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new c(e,t,n)),a.exit(e)}action(e){let t=t=>{let n=this.registeredArguments.length,r=t.slice(0,n);return r[n]=this._storeOptionsAsProperties?this:this.opts(),r.push(this),e.apply(this,r)};return this._actionHandler=t,this}createOption(e,t){return new d(e,t)}_callParseArg(e,t,n,r){try{return e.parseArg(t,n)}catch(e){if(e.code===`commander.invalidArgument`){let t=`${r} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
|
|
24
24
|
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=e=>[e.name()].concat(e.aliases()),n=t(e).find(e=>this._findCommand(e));if(n){let r=t(this._findCommand(n)).join(`|`),i=t(e).join(`|`);throw Error(`cannot add command '${i}' as already have command '${r}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();if(e.negate){let t=e.long.replace(/^--no-/,`--`);this._findOption(t)||this.setOptionValueWithSource(n,e.defaultValue===void 0||e.defaultValue,`default`)}else e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,`default`);let r=(t,r,i)=>{t==null&&e.presetArg!==void 0&&(t=e.presetArg);let a=this.getOptionValue(n);t!==null&&e.parseArg?t=this._callParseArg(e,t,a,r):t!==null&&e.variadic&&(t=e._collectValue(t,a)),t??=e.negate?!1:e.isBoolean()||e.optional?!0:``,this.setOptionValueWithSource(n,t,i)};return this.on(`option:`+t,t=>{let n=`error: option '${e.flags}' argument '${t}' is invalid.`;r(t,n,`cli`)}),e.envVar&&this.on(`optionEnv:`+t,t=>{let n=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;r(t,n,`env`)}),this}_optionEx(e,t,n,r,i){if(typeof t==`object`&&t instanceof d)throw Error(`To add an Option object use addOption() instead of option() or requiredOption()`);let a=this.createOption(t,n);if(a.makeOptionMandatory(!!e.mandatory),typeof r==`function`)a.default(i).argParser(r);else if(r instanceof RegExp){let e=r;r=(t,n)=>{let r=e.exec(t);return r?r[0]:n},a.default(i).argParser(r)}else a.default(r);return this.addOption(a)}option(e,t,n,r){return this._optionEx({},e,t,n,r)}requiredOption(e,t,n,r){return this._optionEx({mandatory:!0},e,t,n,r)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw Error(`call .storeOptionsAsProperties() before adding options`);if(Object.keys(this._optionValues).length)throw Error(`call .storeOptionsAsProperties() before setting option values`);return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw Error(`first parameter to parse must be array or undefined`);if(t||={},e===void 0&&t.from===void 0){a.versions?.electron&&(t.from=`electron`);let e=a.execArgv??[];(e.includes(`-e`)||e.includes(`--eval`)||e.includes(`-p`)||e.includes(`--print`))&&(t.from=`eval`)}e===void 0&&(e=a.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case`node`:this._scriptPath=e[1],n=e.slice(2);break;case`electron`:a.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case`user`:n=e.slice(0);break;case`eval`:n=e.slice(1);break;default:throw Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||`program`,n}parse(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
@@ -27,7 +27,7 @@ Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._life
|
|
|
27
27
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
28
28
|
- ${t?`searched for local subcommand relative to directory '${t}'`:`no directory for search for local subcommand, use .executableDir() to supply a custom directory`}`;throw Error(r)}_executeSubCommand(e,t){t=t.slice();let o=!1,s=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function l(e,t){let n=r.resolve(e,t);if(i.existsSync(n))return n;if(s.includes(r.extname(t)))return;let a=s.find(e=>i.existsSync(`${n}${e}`));if(a)return`${n}${a}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let u=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||``;if(this._scriptPath){let e;try{e=i.realpathSync(this._scriptPath)}catch{e=this._scriptPath}d=r.resolve(r.dirname(e),d)}if(d){let t=l(d,u);if(!t&&!e._executableFile&&this._scriptPath){let n=r.basename(this._scriptPath,r.extname(this._scriptPath));n!==this._name&&(t=l(d,`${n}-${e._name}`))}u=t||u}o=s.includes(r.extname(u));let f;a.platform===`win32`?(this._checkForMissingExecutable(u,d,e._name),t.unshift(u),t=h(a.execArgv).concat(t),f=n.spawn(a.execPath,t,{stdio:`inherit`})):o?(t.unshift(u),t=h(a.execArgv).concat(t),f=n.spawn(a.argv[0],t,{stdio:`inherit`})):f=n.spawn(u,t,{stdio:`inherit`}),f.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{a.on(e,()=>{f.killed===!1&&f.exitCode===null&&f.kill(e)})});let p=this._exitCallback;f.on(`close`,e=>{e??=1,p?p(new c(e,`commander.executeSubCommandAsync`,`(close)`)):a.exit(e)}),f.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(u,d,e._name);else if(t.code===`EACCES`)throw Error(`'${u}' not executable`);if(!p)a.exit(1);else{let e=new c(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,p(e)}}),this.runningCommand=f}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??`--help`])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand(`*`))return this._dispatchSubcommand(`*`,e,t);this.listenerCount(`command:*`)?this.emit(`command:*`,e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(e=>{let t=e.attributeName();return this.getOptionValue(t)!==void 0&&this.getOptionValueSource(t)!=="default"});e.filter(e=>e.conflictsWith.length>0).forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(e){return e.length>1&&e[0]===`-`}let a=e=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,o=null,s=null,c=0;for(;c<e.length||s;){let l=s??e[c++];if(s=null,l===`--`){r===n&&r.push(l),r.push(...e.slice(c));break}if(o&&(!i(l)||a(l))){this.emit(`option:${o.name()}`,l);continue}if(o=null,i(l)){let t=this._findOption(l);if(t){if(t.required){let n=e[c++];n===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,n)}else if(t.optional){let n=null;c<e.length&&(!i(e[c])||a(e[c]))&&(n=e[c++]),this.emit(`option:${t.name()}`,n)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(l.length>2&&l[0]===`-`&&l[1]!==`-`){let e=this._findOption(`-${l[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,l.slice(2)):(this.emit(`option:${e.name()}`),s=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let e=l.indexOf(`=`),t=this._findOption(l.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,l.slice(e+1));continue}}if(r===t&&i(l)&&!(this.commands.length===0&&a(l))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){r.push(l,...e.slice(c));break}r.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
29
29
|
`),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in a.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,a.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new f(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`implied`)})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:`commander.missingArgument`})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:`commander.optionMissingArgument`})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:`commander.missingMandatoryOptionValue`})}_conflictingOption(e,t){let n=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName();return this.getOptionValueSource(r)===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=p(e,n)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:`commander.unknownOption`})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?``:`s`,r=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=p(e,n)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:`commander.unknownCommand`})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t||=`-V, --version`,n||=`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,`commander.version`,e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>s(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=r.basename(e,r.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e||={};let t=!!e.error,n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(a.exitCode??0);t===0&&e&&typeof e!=`function`&&e.error&&(t=1),this._exit(t,`commander.help`,`(outputHelp)`)}addHelpText(e,t){let n=[`beforeAll`,`before`,`after`,`afterAll`];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
|
|
30
|
-
Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function h(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function g(){if(a.env.NO_COLOR||a.env.FORCE_COLOR===`0`||a.env.FORCE_COLOR===`false`)return!1;if(a.env.FORCE_COLOR||a.env.CLICOLOR_FORCE!==void 0)return!0}e.Command=m,e.useColor=g}));const{program:qe,createCommand:Je,createArgument:Ye,createOption:Xe,CommanderError:Ze,InvalidArgumentError:Qe,InvalidOptionArgumentError:$e,Command:et,Argument:tt,Option:nt,Help:rt}=(/* @__PURE__ */ T((/* @__PURE__ */ w((e=>{let{Argument:t}=He(),{Command:n}=Ke(),{CommanderError:r,InvalidArgumentError:i}=Ve(),{Help:a}=Ue(),{Option:o}=We();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i})))(),1)).default,it=Be(`@longzai-intelligence-cli/core/provider`),at={red:e=>e,green:e=>e,yellow:e=>e,blue:e=>e,cyan:e=>e,magenta:e=>e,gray:e=>e,bold:e=>e,dim:e=>e};let ot={select:async(e,t)=>t[0]?.value??``,textInput:async(e,t)=>t?.defaultValue??``,confirm:async(e,t)=>t?.defaultValue??!1,spinner:()=>({start:e=>it.info(e),stop:e=>it.info(e)}),note:(e,t)=>{t?it.info(`${t}: ${e}`):it.info(e)},log:{info:e=>it.info(e),success:e=>it.info(e),warn:e=>it.warn(e),error:e=>it.error(e),step:e=>it.info(e)}},st=at;function ct(e){ot=e}function lt(e){st=e}function ut(){return ot}function dt(){return st}const ft=()=>`0.0.8`;function pt(e){let t=e.version??ft();e.interaction&&ct(e.interaction),e.color&<(e.color);let n=new et;return n.name(e.name).version(t,`-v, --version`,`输出 ${e.name} 的版本号`),e.description&&n.description(e.description),n}Be(`@longzai-intelligence-cli/core/output`),Be(`@longzai-intelligence-cli/core/progress`);const mt=Be(`@longzai-intelligence-cli/core/define-command`);function ht(e,t){let n=e.command(t.name);t.description&&n.description(t.description);for(let e of t.arguments??[])e.description?n.argument(e.signature,e.description):n.argument(e.signature);for(let e of t.options??[])e.defaultValue===void 0?n.option(e.flags,e.description??``):n.option(e.flags,e.description??``,e.defaultValue);n.action(async(...e)=>{let n=e[e.length-1];if(!(n instanceof et))return;let r=n.opts(),i=n.args,a=t.schema.safeParse(r);if(!a.success){let e=a.error.issues.map(e=>e.message).join(`, `);mt.error(dt().red(`参数校验失败: ${e}`)),ut().log.error(`参数校验失败: ${e}`),process.exit(1)}await t.action(a.data,i)})}var gt=/* @__PURE__ */ w(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),_t=/* @__PURE__ */ w(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),M=gt(),N=/* @__PURE__ */ T(_t(),1);function vt({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}const yt=vt();function bt(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(yt,``)}function xt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var St={exports:{}};(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-+(u==2)){if(o+u<=i)a+=l;else break}o+=u}return a}})(St);var Ct=St.exports;const wt=xt(Ct),Tt=xt(function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g});function Et(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=bt(e),e.length===0))return 0;e=e.replace(Tt(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(wt.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}const Dt=(e=0)=>t=>`\x1B[${t+e}m`,Ot=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,kt=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,P={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(P.modifier);const At=Object.keys(P.color),jt=Object.keys(P.bgColor);[...At,...jt];function Mt(){let e=/* @__PURE__ */ new Map;for(let[t,n]of Object.entries(P)){for(let[t,r]of Object.entries(n))P[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=P[t],e.set(r[0],r[1]);Object.defineProperty(P,t,{value:n,enumerable:!1})}return Object.defineProperty(P,"codes",{value:e,enumerable:!1}),P.color.close=`\x1B[39m`,P.bgColor.close=`\x1B[49m`,P.color.ansi=Dt(),P.color.ansi256=Ot(),P.color.ansi16m=kt(),P.bgColor.ansi=Dt(10),P.bgColor.ansi256=Ot(10),P.bgColor.ansi16m=kt(10),Object.defineProperties(P,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>P.rgbToAnsi256(...P.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>P.ansi256ToAnsi(P.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>P.ansi256ToAnsi(P.hexToAnsi256(e)),enumerable:!1}}),P}const Nt=Mt(),Pt=/* @__PURE__ */ new Set([`\x1B`,``]),Ft=`]8;;`,It=e=>`${Pt.values().next().value}[${e}m`,Lt=e=>`${Pt.values().next().value}${Ft}${e}`,Rt=e=>e.split(` `).map(e=>Et(e)),zt=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=Et(bt(e[e.length-1]));for(let[t,s]of r.entries()){let c=Et(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),Pt.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(Ft)),i){a?s===`\x07`&&(i=!1,a=!1):s===`m`&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Bt=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(Et(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Vt=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=Rt(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=Et(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),zt(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){zt(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){zt(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>Bt(e)));let c=[...s.join(`
|
|
30
|
+
Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function h(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function g(){if(a.env.NO_COLOR||a.env.FORCE_COLOR===`0`||a.env.FORCE_COLOR===`false`)return!1;if(a.env.FORCE_COLOR||a.env.CLICOLOR_FORCE!==void 0)return!0}e.Command=m,e.useColor=g}));const{program:qe,createCommand:Je,createArgument:Ye,createOption:Xe,CommanderError:Ze,InvalidArgumentError:Qe,InvalidOptionArgumentError:$e,Command:et,Argument:tt,Option:nt,Help:rt}=(/* @__PURE__ */ te((/* @__PURE__ */ w((e=>{let{Argument:t}=He(),{Command:n}=Ke(),{CommanderError:r,InvalidArgumentError:i}=Ve(),{Help:a}=Ue(),{Option:o}=We();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i})))(),1)).default,it=Be(`@longzai-intelligence-cli/core/provider`),at={red:e=>e,green:e=>e,yellow:e=>e,blue:e=>e,cyan:e=>e,magenta:e=>e,gray:e=>e,bold:e=>e,dim:e=>e};let ot={select:async(e,t)=>t[0]?.value??``,textInput:async(e,t)=>t?.defaultValue??``,confirm:async(e,t)=>t?.defaultValue??!1,spinner:()=>({start:e=>it.info(e),stop:e=>it.info(e)}),note:(e,t)=>{t?it.info(`${t}: ${e}`):it.info(e)},log:{info:e=>it.info(e),success:e=>it.info(e),warn:e=>it.warn(e),error:e=>it.error(e),step:e=>it.info(e)}},st=at;function ct(e){ot=e}function lt(e){st=e}function ut(){return ot}function dt(){return st}const ft=()=>`0.0.8`;function pt(e){let t=e.version??ft();e.interaction&&ct(e.interaction),e.color&<(e.color);let n=new et;return n.name(e.name).version(t,`-v, --version`,`输出 ${e.name} 的版本号`),e.description&&n.description(e.description),n}Be(`@longzai-intelligence-cli/core/output`),Be(`@longzai-intelligence-cli/core/progress`);const mt=Be(`@longzai-intelligence-cli/core/define-command`);function ht(e,t){let n=e.command(t.name);t.description&&n.description(t.description);for(let e of t.arguments??[])e.description?n.argument(e.signature,e.description):n.argument(e.signature);for(let e of t.options??[])e.defaultValue===void 0?n.option(e.flags,e.description??``):n.option(e.flags,e.description??``,e.defaultValue);n.action(async(...e)=>{let n=e[e.length-1];if(!(n instanceof et))return;let r=n.opts(),i=n.args,a=t.schema.safeParse(r);if(!a.success){let e=a.error.issues.map(e=>e.message).join(`, `);mt.error(dt().red(`参数校验失败: ${e}`)),ut().log.error(`参数校验失败: ${e}`),process.exit(1)}await t.action(a.data,i)})}var gt=/* @__PURE__ */ w(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),_t=/* @__PURE__ */ w(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),M=gt(),N=/* @__PURE__ */ te(_t(),1);function vt({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}const yt=vt();function bt(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(yt,``)}function xt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var St={exports:{}};(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-+(u==2)){if(o+u<=i)a+=l;else break}o+=u}return a}})(St);var Ct=St.exports;const wt=xt(Ct),Tt=xt(function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g});function Et(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=bt(e),e.length===0))return 0;e=e.replace(Tt(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(wt.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}const Dt=(e=0)=>t=>`\x1B[${t+e}m`,Ot=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,kt=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,P={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(P.modifier);const At=Object.keys(P.color),jt=Object.keys(P.bgColor);[...At,...jt];function Mt(){let e=/* @__PURE__ */ new Map;for(let[t,n]of Object.entries(P)){for(let[t,r]of Object.entries(n))P[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=P[t],e.set(r[0],r[1]);Object.defineProperty(P,t,{value:n,enumerable:!1})}return Object.defineProperty(P,"codes",{value:e,enumerable:!1}),P.color.close=`\x1B[39m`,P.bgColor.close=`\x1B[49m`,P.color.ansi=Dt(),P.color.ansi256=Ot(),P.color.ansi16m=kt(),P.bgColor.ansi=Dt(10),P.bgColor.ansi256=Ot(10),P.bgColor.ansi16m=kt(10),Object.defineProperties(P,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>P.rgbToAnsi256(...P.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>P.ansi256ToAnsi(P.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>P.ansi256ToAnsi(P.hexToAnsi256(e)),enumerable:!1}}),P}const Nt=Mt(),Pt=/* @__PURE__ */ new Set([`\x1B`,``]),Ft=`]8;;`,It=e=>`${Pt.values().next().value}[${e}m`,Lt=e=>`${Pt.values().next().value}${Ft}${e}`,Rt=e=>e.split(` `).map(e=>Et(e)),zt=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=Et(bt(e[e.length-1]));for(let[t,s]of r.entries()){let c=Et(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),Pt.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(Ft)),i){a?s===`\x07`&&(i=!1,a=!1):s===`m`&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Bt=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(Et(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Vt=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=Rt(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=Et(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),zt(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){zt(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){zt(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>Bt(e)));let c=[...s.join(`
|
|
31
31
|
`)];for(let[e,t]of c.entries()){if(r+=t,Pt.has(t)){let{groups:t}=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ft}(?<uri>.*))`).exec(c.slice(e).join(``))||{groups:{}};if(t.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}let n=Nt.codes.get(Number(i));c[e+1]===`
|
|
32
32
|
`?(a&&(r+=Lt(``)),i&&n&&(r+=It(n))):t===`
|
|
33
33
|
`&&(i&&n&&(r+=It(i)),a&&(r+=Lt(a)))}return r};function Ht(e,t,n){return String(e).normalize().replace(/\r\n/g,`
|
|
@@ -222,9 +222,10 @@ IDE 差异化诉求请写在 agent.claude.md(仅进 CLAUDE.md)。
|
|
|
222
222
|
# frontmatter 各 IDE 不同(claude paths / trae alwaysApply+globs),见 docs/vendors/
|
|
223
223
|
`,"skills/.gitkeep":`# 此目录存放技能真源
|
|
224
224
|
# 命名约定:<base>.md(共同)+ <base>.<type>.md(某 IDE 独有)
|
|
225
|
-
`},q=`.lzi`,ku=`agents/agent.md`,Au=`agents/items`,ju
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
`},q=`.lzi`,ku=`agents/agent.md`,Au=`agents/items`,ju=e=>e===`agents`?`agents/items`:`rules`,Mu=(e,t)=>e===`agents`?`${q}/${Au}/${t}`:`${q}/${e}/${t}`,Nu=`registry/projects`,Pu=`# BEGIN Lzi Agent Tools Shared(工具维护,请勿手改)`,Fu=`# END Lzi Agent Tools Shared`,Iu={claude:`.claude`,trae:`.trae`,zcode:`.zcode`},Lu={claude:[{output:`CLAUDE.md`,commonSource:ku,agentSource:`agents/agent.claude.md`}],trae:[{output:`CLAUDE.md`,commonSource:ku,agentSource:`agents/agent.claude.md`},{output:`AGENTS.md`,commonSource:ku,agentSource:`agents/agent.trae.md`}],zcode:[{output:`AGENTS.md`,commonSource:ku,agentSource:`agents/agent.zcode.md`}]},Ru={commands:{claude:{ideRoot:Iu.claude,mode:`append`},trae:{ideRoot:Iu.trae,mode:`append`},zcode:{ideRoot:Iu.zcode,mode:`append`}},rules:{claude:{ideRoot:Iu.claude,mode:`prepend`},trae:{ideRoot:Iu.trae,mode:`prepend`},zcode:{ideRoot:Iu.zcode,mode:`prepend`}},skills:{claude:{ideRoot:Iu.claude,mode:`append`},trae:{ideRoot:Iu.trae,mode:`append`},zcode:{ideRoot:Iu.zcode,mode:`append`}}},zu=[`claude`,`trae`,`zcode`],Bu={DATE:()=>(/* @__PURE__ */ new Date()).toISOString().slice(0,10),PROJECT_NAME:()=>process.cwd().split(`/`).pop()??``},Vu=`auto`,Hu=async e=>{try{return await _(e),!0}catch{return!1}},Uu=async e=>{let t=a(e,q);if(!await Hu(t))return[];let n=[];for(let e of zu){let r=Lu[e];(await Promise.all(r.map(async e=>Hu(a(t,e.agentSource))))).some(e=>e)&&n.push(e)}return n},Wu=e=>`'${e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}'`,Gu=e=>`[${e.map(e=>Wu(e)).join(`, `)}]`,Ku=e=>{let t=e.subscriptions.map(e=>` {
|
|
226
|
+
category: ${Wu(e.category)},
|
|
227
|
+
namespace: ${Wu(e.namespace)},
|
|
228
|
+
include: ${e.include===null?`null`:Gu(e.include)},
|
|
228
229
|
},`);return`// @generated by lzi-agent-cli shared(工具生成,请勿手改;变更请运行 shared register / shared unregister)
|
|
229
230
|
import type { SharedPromptsRegistration } from './registration.types.js';
|
|
230
231
|
|
|
@@ -232,36 +233,36 @@ import type { SharedPromptsRegistration } from './registration.types.js';
|
|
|
232
233
|
* ${e.name} 的注册记录(机器生成,禁止手工编辑)
|
|
233
234
|
*/
|
|
234
235
|
const registration: SharedPromptsRegistration = {
|
|
235
|
-
name: ${
|
|
236
|
-
monorepo: ${
|
|
236
|
+
name: ${Wu(e.name)},
|
|
237
|
+
monorepo: ${Wu(e.monorepo)},
|
|
237
238
|
subscriptions: [
|
|
238
239
|
${t.join(`
|
|
239
240
|
`)}
|
|
240
241
|
],
|
|
241
|
-
registeredAt: ${
|
|
242
|
-
toolVersion: ${
|
|
242
|
+
registeredAt: ${Wu(e.registeredAt)},
|
|
243
|
+
toolVersion: ${Wu(e.toolVersion)},
|
|
243
244
|
};
|
|
244
245
|
|
|
245
246
|
export default registration;
|
|
246
|
-
`},J={HEAD_LINES:30,COMMON_MAX_LINES:400,COMMON_MAX_TOKENS:5e3,CODE_BLOCK_MAX_LINES:40,DUPLICATE_MIN_CHARS:60,SIMILARITY_THRESHOLD:.85,CATEGORY_INDEX_MIN_FILES:5,AGENT_SPLIT_MIN_ROLES:3},
|
|
247
|
+
`},J={HEAD_LINES:30,COMMON_MAX_LINES:400,COMMON_MAX_TOKENS:5e3,CODE_BLOCK_MAX_LINES:40,DUPLICATE_MIN_CHARS:60,SIMILARITY_THRESHOLD:.85,CATEGORY_INDEX_MIN_FILES:5,AGENT_SPLIT_MIN_ROLES:3},qu={"volatile-prefix":{id:`volatile-prefix`,severity:`high`,title:`易变占位符位于文件头部,破坏稳定前缀`,reference:`原文优化八:稳定前缀设计(实测收益 >85%,对费用影响最大)`},"oversized-common":{id:`oversized-common`,severity:`medium`,title:`公共源文件过大,应渐进式披露拆分`,reference:`原文优化一:渐进式披露(实测收益 >10%)`},"low-freq-section":{id:`low-freq-section`,severity:`low`,title:`低频段落常驻公共文件,建议下沉为按需加载的独立文件`,reference:`原文优化一:渐进式披露,L2 按需层(实测收益 >10%)`},"type-content-in-common":{id:`type-content-in-common`,severity:`medium`,title:`公共文件包含类型专属内容,应移入 agent.<type>.md`,reference:`原文优化六:Agent 专属配置;原则二:减少不相关的`},"cross-type-duplicate":{id:`cross-type-duplicate`,severity:`medium`,title:`各类型独有文件间存在重复段落,建议上移公共文件`,reference:`原文优化九:避免重复加载 Skill(消除隐性重复膨胀);原则三:减少重复的`},"inline-code-block":{id:`inline-code-block`,severity:`low`,title:`大段内联代码块,建议改为文件引用`,reference:`原文优化一:渐进式披露,工具列表用扁平链接替代说明文档搬运`},"missing-tools-whitelist":{id:`missing-tools-whitelist`,severity:`low`,title:`command 源文件未声明 allowed-tools 白名单`,reference:`原文优化六:Agent 专属配置,tools 白名单`},"missing-index":{id:`missing-index`,severity:`low`,title:`类别目录文件较多且无 INDEX.md 索引`,reference:`原文优化四:长期记忆按需索引加载(实测收益 >10%)`},"sequential-instruction":{id:`sequential-instruction`,severity:`low`,title:`指令要求逐个/串行执行,建议固化为脚本或改为并行`,reference:`原文优化二:确定性操作由脚本执行;原文优化十一:工具调用并行化`},"multi-step-git-ops":{id:`multi-step-git-ops`,severity:`medium`,title:`指令要求 Agent 逐步执行 git 流程,建议改用专用工具一次调用`,reference:`原文优化二:确定性操作由脚本执行,一次脚本调用替代多轮模型交互(实测收益 >10%);原文优化十一:串行工具调用每次携带完整上下文`},"mcp-over-cli":{id:`mcp-over-cli`,severity:`medium`,title:`指令指示通过 MCP 工具执行操作,CLI 优先更省 token`,reference:`原文优化二:CLI 优先于 MCP——MCP 的 JSON 结构化返回往往比纯文本 CLI 输出消耗更多 token(实测收益 >10%)`},"mcp-data-subagent":{id:`mcp-data-subagent`,severity:`medium`,title:`指令让主 Agent 直接经 MCP 获取大数据,应数据获取子 Agent 化`,reference:`原文优化三:MCP 数据获取子 Agent 化——数据获取子 Agent 压缩归纳后只把结论返回主 Agent(实测单次交互 message tokens 从 800KB 降到 5K,降幅 90%+)`},"agent-split":{id:`agent-split`,severity:`medium`,title:`公共指令承载多个职能且体量过大,建议按职能拆分为多 Agent`,reference:`原文优化五:单 Agent 拆分为多 Agent——每个 Agent 的 system prompt 与工具集最小化,拆分后总账更优(降低单次交互成本)`},"blind-search":{id:`blind-search`,severity:`low`,title:`指令要求 Agent 盲搜定位代码,建议图谱查询或精确路径引用`,reference:`原文优化七:代码图谱替代盲搜——grep/glob 暴力遍历搜索范围大、读取文件多(实测任务平均耗时降低 30%+,graphify 已在 10+ 项目落地)`},"verbose-cli-output":{id:`verbose-cli-output`,severity:`low`,title:`指令包含高输出 CLI 命令,建议接入 rtk 输出压缩代理`,reference:`原文优化十:rtk 压缩 CLI 输出——构建日志、测试报告、文件列表经 rtk 压缩后再进入模型上下文(实测压缩率 85% 左右)`}},Ju=[`high`,`medium`,`low`],Y=(e,t,n,r)=>({rule:qu[e],file:t,line:n,detail:r}),X={RED:`\x1B[0;31m`,GREEN:`\x1B[0;32m`,YELLOW:`\x1B[1;33m`,BLUE:`\x1B[0;34m`,RESET:`\x1B[0m`};function Yu(e){return e.map(e=>{if(typeof e==`string`)return e;if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch{return String(e)}}).join(` `)}function Z(...e){process.stdout.write(`${Yu(e)}\n`)}function Q(...e){process.stderr.write(`${Yu(e)}\n`)}const Xu=e=>zu.some(t=>t===e),Zu=e=>{let t=new Set(Object.keys(Ou));if(e===void 0)return t;let n=/* @__PURE__ */ new Set;n.add(`agents/agent.md`);for(let t of Lu[e])n.add(`agents/${t.agentSource.split(`/`).pop()}`);for(let e of t)(!e.startsWith(`agents/`)||e.startsWith(`agents/items/`))&&n.add(e);return n},Qu=async e=>{let t=e.agent===void 0?void 0:Xu(e.agent)?e.agent:null;t===null&&(Z(`${X.RED}错误: --agent 值 '${e.agent}' 无效,合法值: ${zu.join(`, `)}${X.RESET}`),process.exit(1));let n=process.cwd(),r=a(n,q),i=Zu(t);Z(`${X.BLUE}初始化 Agent Tools 源文件结构...${X.RESET}\n`),e.dryRun&&Z(`${X.YELLOW}[预览模式] 将创建以下文件:${X.RESET}`);let o=[],s=[];for(let[t,n]of Object.entries(Ou)){if(!i.has(t))continue;let c=a(r,t);if(await Bun.file(c).exists()){o.push(t),e.dryRun||Z(` ${X.YELLOW}跳过${X.RESET} ${t}(已存在)`);continue}if(s.push(t),e.dryRun){Z(` ${X.GREEN}将创建${X.RESET} ${q}/${t}`);continue}await Bun.write(c,n,{createPath:!0}),Z(` ${X.GREEN}已创建${X.RESET} ${q}/${t}`)}Z(``),Z(`${X.BLUE}后续步骤:${X.RESET}`),Z(` 1. 编辑 ${q}/agents/agent.md,填写共同指令与 {{KEY}} 占位符`),Z(` 2. 按需编辑 ${q}/agents/agent.<type>.md,填写各 Agent 专属指令`),Z(` 3. 按需在 ${q}/agents/items/ 下拆分条目(frontmatter order 定序,<type>.md 变体/独有)`),Z(` 4. 在 ${q}/commands/ rules/ skills/ 下按命名约定添加类别配置`),Z(` 5. 运行 lzi-agent-cli sync 同步生成 CLAUDE.md / AGENTS.md 并分发类别配置`),Z(` 默认 auto:按 ${q}/agents/agent.<type>.md 真源自动推断为所有存在的类型生成`),Z(` 定向同步:lzi-agent-cli sync --agent <${zu.join(`|`)}> 或设 LZI_AGENT_TYPE`),Z(` 占位符:可选设置 ${q}/../.env 的 LZI_PLACEHOLDER_<KEY>=<value>`),Z(` 6. 运行 lzi-agent-cli status 查看真源与产物存在性`),o.length>0&&(Z(``),Z(`${X.YELLOW}提示: ${o.length} 个文件已存在被跳过${X.RESET}`))},$u=/[\u3400-\u4dbf\u4e00-\u9fff]/g,ed=e=>{let t=e.match($u),n=t?t.length:0,r=e.length-n;return n+Math.ceil(r/3.5)},td=e=>{let t=e.split(`
|
|
247
248
|
`),n=[],r=[],i=1;for(let[e,a]of t.entries()){let t=e+1;(a.trim()===``||/^#{1,6}\s/.test(a))&&r.length>0&&(n.push({text:r.join(`
|
|
248
249
|
`),startLine:i}),r=[]),a.trim()!==``&&(r.length===0&&(i=t),r.push(a))}return r.length>0&&n.push({text:r.join(`
|
|
249
|
-
`),startLine:i}),n},
|
|
250
|
-
`).slice(0,J.HEAD_LINES);for(let[n,r]of t.entries())if(
|
|
251
|
-
`).length,n
|
|
252
|
-
`).length;return Y(`low-freq-section`,e.relPath,n,`第 ${n} 行的标题「${t[2]}」属于低频内容(FAQ/排障/部署类)。建议:整段拆为独立文件(L2 按需层),公共文件保留一行链接引用,Agent 按任务需要再读取。`)},
|
|
253
|
-
`).length;return Y(`type-content-in-common`,e.relPath,n,`第 ${n} 行出现「${t[0]}」相关内容。公共文件会合成进所有类型的产物,单类型适用的内容属于其他类型的无关上下文。建议:移入对应的 agent.<type>.md 独有文件。`)},
|
|
254
|
-
`),r=null;for(let[i,a]of n.entries()){let n=i+1;if(a.trimStart().startsWith("```")){if(r===null)r=n;else{let i=n-r+1;i>J.CODE_BLOCK_MAX_LINES&&t.push(Y(`inline-code-block`,e.relPath,r,`第 ${r} 行的代码块共 ${i} 行,超过阈值 ${J.CODE_BLOCK_MAX_LINES} 行。建议:整段抽为独立文件(脚本或文档),指令中改为扁平链接引用("参考 scripts/xxx.sh")。`)),r=null}}}return t},
|
|
255
|
-
`);for(let[r,i]of n.entries())
|
|
256
|
-
`);for(let[r,i]of n.entries()){let n=i.match(/\bgit\s+(add|commit|push|pull|checkout|merge|rebase)\b/g),a=/(批量|逐个|依次|所有仓库|每个仓库|全部仓库|逐仓库)[^。\n]{0,40}git\s+(add|commit|push|pull)/.test(i)||/git\s+(push|pull|commit)[^。\n]{0,40}(批量|逐个|依次|所有仓库|每个仓库)/.test(i);n!==null&&n.length>=2?t.push(Y(`multi-step-git-ops`,e.relPath,r+1,`第 ${r+1} 行让 Agent 按序列执行 ${n.join(` → `)},每一步都是一轮携带完整上下文的模型交互。建议:把该 git 序列固化为脚本或改用专用 git 工具,一次调用完成全部步骤。`)):a&&t.push(Y(`multi-step-git-ops`,e.relPath,r+1,`第 ${r+1} 行要求对多个仓库逐个执行 git 操作,逐仓库调用意味着调用次数与输出随仓库数线性增长。建议:改用一次调用的专用工具(如 lzi-dev-cli push-all)或循环脚本。`))}return t},
|
|
257
|
-
`);for(let[r,i]of n.entries())(/\bmcp__[a-zA-Z0-9_-]+/.test(i)||/(使用|调用|通过|配置)\s*(了)?\s*MCP/.test(i))&&t.push(Y(`mcp-over-cli`,e.relPath,r+1,`第 ${r+1} 行指示通过 MCP 工具执行操作。MCP 的 JSON 结构化返回通常比纯文本 CLI 输出消耗更多 token。建议:改用等效 CLI 命令(一个工具只做一件事、输出可组合可管道),文本处理/文件操作/查询类操作优先 CLI。`));return t},
|
|
258
|
-
`);for(let[r,i]of n.entries())(/(Figma|设计稿|原型图|长列表|原始数据|全量数据|解析结果)[^。\n]{0,40}(MCP|mcp__)/.test(i)||/(MCP|mcp__)[^。\n]{0,40}(Figma|设计稿|原型图|长列表|原始数据|全量数据|解析结果)/.test(i))&&t.push(Y(`mcp-data-subagent`,e.relPath,r+1,`第 ${r+1} 行让主 Agent 直接经 MCP 获取大数据(返回量不可控,实测单次可达 800KB)。建议:数据获取子 Agent 化——指定高性价比模型作为专职子 Agent 调用 MCP 获取原始数据,压缩归纳后只把结论返回主 Agent(实测单次交互 message tokens 从 800KB 降到 5K 左右)。`));return t},
|
|
259
|
-
`).length,n
|
|
260
|
-
`);for(let[r,i]of n.entries())/(全局)?搜索(代码|代码库|项目|仓库)|遍历(文件|目录|代码库)|查找(相关)?(文件|代码|定义|实现)|\bgrep\s+-[a-zA-Z]*r|\bglob\s+(扫描|遍历)/.test(i)&&t.push(Y(`blind-search`,e.relPath,r+1,`第 ${r+1} 行要求 Agent 通过搜索/遍历定位代码。盲搜在多包仓库中搜索范围大、读取文件多。建议:指令中直接给出精确文件路径或模块位置;或用代码图谱(graphify,代码库转知识图谱后自然语言查询精确位置,实测任务平均耗时降低 30%+)替代盲搜。`));return t},
|
|
261
|
-
`);for(let[r,i]of n.entries())/(npm|pnpm|bun|yarn)\s+(install|run\s+(build|test|dev))|npm\s+ls|\bls\s+-[a-zA-Z]*R/.test(i)&&t.push(Y(`verbose-cli-output`,e.relPath,r+1,`第 ${r+1} 行包含高输出 CLI 命令(构建/安装/测试/递归列表),原始输出常含大量冗余。建议:接入 rtk 输出压缩代理(CLI 输出经 rtk 压缩后再进入模型上下文,实测压缩率 85% 左右)。`));return t},
|
|
250
|
+
`),startLine:i}),n},nd=(e,t)=>{let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set;for(let t=0;t<e.length-1;t+=1)n.add(e.slice(t,t+2));for(let e=0;e<t.length-1;e+=1)r.add(t.slice(e,e+2));if(n.size===0||r.size===0)return 0;let i=0;for(let e of n)r.has(e)&&(i+=1);let a=n.size+r.size-i;return a===0?0:i/a},rd=e=>e.trim().replace(/\s+/g,` `),id=/\{\{DATE\}\}/,ad=/^(#{1,6})\s*(.*(?:FAQ|常见问题|疑难|排障|故障|部署|发布|回滚|迁移).*)$/im,od=/Claude\s*Code|Trae|ZCode/i,sd=/(逐个|依次|串行|逐一)[^。\n;;]{0,12}(执行|调用|运行|处理|截图)|(批量)[^。\n;;]{0,12}(处理|替换|截图|重命名|修改|执行)/,cd=e=>{let t=e.content.split(`
|
|
251
|
+
`).slice(0,J.HEAD_LINES);for(let[n,r]of t.entries())if(id.test(r))return Y(`volatile-prefix`,e.relPath,n+1,`第 ${n+1} 行的 {{DATE}} 位于文件头部。该文件合成后位于产物前缀,头部易变内容会使 KV Cache 持续失效。建议:时间戳类占位符移至文件尾部,或移入对应 agent.<type>.md 专属文件。`);return null},ld=e=>{let t=e.content.split(`
|
|
252
|
+
`).length,n=ed(e.content);return t>J.COMMON_MAX_LINES||n>J.COMMON_MAX_TOKENS?Y(`oversized-common`,e.relPath,1,`公共源文件 ${t} 行、估算约 ${n} token,超过阈值(${J.COMMON_MAX_LINES} 行 / ${J.COMMON_MAX_TOKENS} token)。该文件内容会进入全部 IDE 产物的常驻上下文,每次请求重复计费。建议:低频内容拆为独立文件(如 faq.md),公共文件只保留最高频内容并用扁平链接引用("参考 xxx.md")。`):null},ud=e=>{let t=e.content.match(ad);if(t===null)return null;let n=e.content.slice(0,t.index??0).split(`
|
|
253
|
+
`).length;return Y(`low-freq-section`,e.relPath,n,`第 ${n} 行的标题「${t[2]}」属于低频内容(FAQ/排障/部署类)。建议:整段拆为独立文件(L2 按需层),公共文件保留一行链接引用,Agent 按任务需要再读取。`)},dd=e=>{let t=e.content.match(od);if(t===null)return null;let n=e.content.slice(0,t.index??0).split(`
|
|
254
|
+
`).length;return Y(`type-content-in-common`,e.relPath,n,`第 ${n} 行出现「${t[0]}」相关内容。公共文件会合成进所有类型的产物,单类型适用的内容属于其他类型的无关上下文。建议:移入对应的 agent.<type>.md 独有文件。`)},fd=e=>{let t=[],n=e.content.split(`
|
|
255
|
+
`),r=null;for(let[i,a]of n.entries()){let n=i+1;if(a.trimStart().startsWith("```")){if(r===null)r=n;else{let i=n-r+1;i>J.CODE_BLOCK_MAX_LINES&&t.push(Y(`inline-code-block`,e.relPath,r,`第 ${r} 行的代码块共 ${i} 行,超过阈值 ${J.CODE_BLOCK_MAX_LINES} 行。建议:整段抽为独立文件(脚本或文档),指令中改为扁平链接引用("参考 scripts/xxx.sh")。`)),r=null}}}return t},pd=e=>{let t=[],n=e.content.split(`
|
|
256
|
+
`);for(let[r,i]of n.entries())sd.test(i)&&t.push(Y(`sequential-instruction`,e.relPath,r+1,`第 ${r+1} 行要求逐个/批量执行确定性操作。建议:能写成脚本的固化为脚本,模型一次调用执行;互不依赖的工具调用改为并行。`));return t},md=e=>{let t=[],n=e.content.split(`
|
|
257
|
+
`);for(let[r,i]of n.entries()){let n=i.match(/\bgit\s+(add|commit|push|pull|checkout|merge|rebase)\b/g),a=/(批量|逐个|依次|所有仓库|每个仓库|全部仓库|逐仓库)[^。\n]{0,40}git\s+(add|commit|push|pull)/.test(i)||/git\s+(push|pull|commit)[^。\n]{0,40}(批量|逐个|依次|所有仓库|每个仓库)/.test(i);n!==null&&n.length>=2?t.push(Y(`multi-step-git-ops`,e.relPath,r+1,`第 ${r+1} 行让 Agent 按序列执行 ${n.join(` → `)},每一步都是一轮携带完整上下文的模型交互。建议:把该 git 序列固化为脚本或改用专用 git 工具,一次调用完成全部步骤。`)):a&&t.push(Y(`multi-step-git-ops`,e.relPath,r+1,`第 ${r+1} 行要求对多个仓库逐个执行 git 操作,逐仓库调用意味着调用次数与输出随仓库数线性增长。建议:改用一次调用的专用工具(如 lzi-dev-cli push-all)或循环脚本。`))}return t},hd=e=>{let t=[],n=e.content.split(`
|
|
258
|
+
`);for(let[r,i]of n.entries())(/\bmcp__[a-zA-Z0-9_-]+/.test(i)||/(使用|调用|通过|配置)\s*(了)?\s*MCP/.test(i))&&t.push(Y(`mcp-over-cli`,e.relPath,r+1,`第 ${r+1} 行指示通过 MCP 工具执行操作。MCP 的 JSON 结构化返回通常比纯文本 CLI 输出消耗更多 token。建议:改用等效 CLI 命令(一个工具只做一件事、输出可组合可管道),文本处理/文件操作/查询类操作优先 CLI。`));return t},gd=e=>{let t=[],n=e.content.split(`
|
|
259
|
+
`);for(let[r,i]of n.entries())(/(Figma|设计稿|原型图|长列表|原始数据|全量数据|解析结果)[^。\n]{0,40}(MCP|mcp__)/.test(i)||/(MCP|mcp__)[^。\n]{0,40}(Figma|设计稿|原型图|长列表|原始数据|全量数据|解析结果)/.test(i))&&t.push(Y(`mcp-data-subagent`,e.relPath,r+1,`第 ${r+1} 行让主 Agent 直接经 MCP 获取大数据(返回量不可控,实测单次可达 800KB)。建议:数据获取子 Agent 化——指定高性价比模型作为专职子 Agent 调用 MCP 获取原始数据,压缩归纳后只把结论返回主 Agent(实测单次交互 message tokens 从 800KB 降到 5K 左右)。`));return t},_d=e=>{let t=e.content.split(`
|
|
260
|
+
`).length,n=ed(e.content);if(t<=J.COMMON_MAX_LINES&&n<=J.COMMON_MAX_TOKENS)return null;let r=[`前端`,`后端`,`移动端`,`小程序`,`测试`,`QA`,`部署`,`运维`,`数据库`,`性能`,`安全`,`架构`].filter(t=>e.content.includes(t));return r.length<J.AGENT_SPLIT_MIN_ROLES?null:Y(`agent-split`,e.relPath,1,`公共文件 ${t} 行(估算 ${n} token)且覆盖 ${r.length} 个职能(${r.join(`、`)})。单 Agent 承载多职能意味着每次交互都为用不上的能力付费。建议:按职能拆分为多个子 Agent,每个子 Agent 的 system prompt 与工具集最小化(拆分后单 Agent 交互频次可能增多,但每次成本降得更低,总账更优)。`)},vd=e=>{let t=[],n=e.content.split(`
|
|
261
|
+
`);for(let[r,i]of n.entries())/(全局)?搜索(代码|代码库|项目|仓库)|遍历(文件|目录|代码库)|查找(相关)?(文件|代码|定义|实现)|\bgrep\s+-[a-zA-Z]*r|\bglob\s+(扫描|遍历)/.test(i)&&t.push(Y(`blind-search`,e.relPath,r+1,`第 ${r+1} 行要求 Agent 通过搜索/遍历定位代码。盲搜在多包仓库中搜索范围大、读取文件多。建议:指令中直接给出精确文件路径或模块位置;或用代码图谱(graphify,代码库转知识图谱后自然语言查询精确位置,实测任务平均耗时降低 30%+)替代盲搜。`));return t},yd=e=>{let t=[],n=e.content.split(`
|
|
262
|
+
`);for(let[r,i]of n.entries())/(npm|pnpm|bun|yarn)\s+(install|run\s+(build|test|dev))|npm\s+ls|\bls\s+-[a-zA-Z]*R/.test(i)&&t.push(Y(`verbose-cli-output`,e.relPath,r+1,`第 ${r+1} 行包含高输出 CLI 命令(构建/安装/测试/递归列表),原始输出常含大量冗余。建议:接入 rtk 输出压缩代理(CLI 输出经 rtk 压缩后再进入模型上下文,实测压缩率 85% 左右)。`));return t},bd=e=>{let t=-1;if(e.content.startsWith(`---`)){let n=e.content.split(`
|
|
262
263
|
`);for(let[e,r]of n.entries())if(e>0&&r.trim()===`---`){t=e;break}}if(t===-1)return Y(`missing-tools-whitelist`,e.relPath,1,`该 command 没有 frontmatter。建议:添加 frontmatter 并声明 allowed-tools 白名单,只预批准该命令必需的工具,收敛执行期工具暴露面。`);let n=e.content.split(`
|
|
263
264
|
`).slice(1,t).join(`
|
|
264
|
-
`);return/^allowed-tools:/m.test(n)?null:Y(`missing-tools-whitelist`,e.relPath,1,`frontmatter 未声明 allowed-tools。建议:补充 allowed-tools 白名单,只预批准该命令必需的工具,收敛执行期工具暴露面。`)},
|
|
265
|
+
`);return/^allowed-tools:/m.test(n)?null:Y(`missing-tools-whitelist`,e.relPath,1,`frontmatter 未声明 allowed-tools。建议:补充 allowed-tools 白名单,只预批准该命令必需的工具,收敛执行期工具暴露面。`)},xd=e=>e.mdFileCount>J.CATEGORY_INDEX_MIN_FILES&&!e.hasIndex?Y(`missing-index`,`${e.category}/`,1,`${e.category}/ 目录下有 ${e.mdFileCount} 个 .md 文件,无 INDEX.md 索引。建议:建立 INDEX.md 索引各文件用途,Agent 先读索引再按需加载具体文件,避免全量读取。`):null,Sd=e=>{let t=[];for(let[n,r]of e.entries())for(let[i,a]of e.entries()){if(i<=n)continue;let e=td(r.content),o=td(a.content);for(let n of e){let e=rd(n.text);if(!(e.length<J.DUPLICATE_MIN_CHARS))for(let i of o){let o=rd(i.text);if(o.length<J.DUPLICATE_MIN_CHARS)continue;let s=e===o,c=s?1:nd(e,o);(s||c>=J.SIMILARITY_THRESHOLD)&&t.push(Y(`cross-type-duplicate`,a.relPath,i.startLine,`与 ${r.relPath} 第 ${n.startLine} 行起的段落${s?`完全重复`:`高度相似(相似度 ${c.toFixed(2)})`}。重复段落会在多个产物中重复计费。建议:上移到 agents/agent.md 公共文件,只维护一份。`))}}}return t},Cd=e=>{let t=[],n=[...e.commonSource===null?[]:[e.commonSource],...e.typeSources];for(let e of n){let n=cd(e);n!==null&&t.push(n),t.push(...fd(e),...pd(e),...md(e),...hd(e),...gd(e),...vd(e),...yd(e))}if(e.commonSource!==null){let n=ld(e.commonSource),r=ud(e.commonSource),i=dd(e.commonSource),a=_d(e.commonSource);n!==null&&t.push(n),r!==null&&t.push(r),i!==null&&t.push(i),a!==null&&t.push(a)}t.push(...Sd(e.typeSources));for(let n of e.commandFiles){let e=bd(n);e!==null&&t.push(e),t.push(...fd(n),...pd(n),...md(n),...hd(n),...gd(n),...vd(n),...yd(n))}for(let n of e.categoryInfos){let e=xd(n);e!==null&&t.push(e)}return[...t].sort((e,t)=>{let n=Ju.indexOf(e.rule.severity)-Ju.indexOf(t.rule.severity);if(n!==0)return n;let r=e.file.localeCompare(t.file);return r===0?e.line-t.line:r})},wd=zu.flatMap(e=>Lu[e].map(e=>e.agentSource)).filter((e,t,n)=>n.indexOf(e)===t),Td=async e=>{try{return await _(e),!0}catch{return!1}},Ed=async e=>await Bun.file(e).exists()?Bun.file(e).text():null,Dd=async(e,t)=>{if(!await Td(e))return null;let n=[],r=new Bun.Glob(`**/*.md`);for await(let t of r.scan({cwd:e,onlyFiles:!0}))n.push(t);return n.length===0?null:{category:t,mdFileCount:n.length,hasIndex:n.some(e=>e.toLowerCase()===`index.md`)}},Od=async()=>{let e=process.cwd(),t=a(e,q);if(Z(`${X.BLUE}=== Agent Tools 优化分析(只读) ===${X.RESET}\n`),!await Td(t)){Z(`${X.YELLOW}未找到 ${t},请先运行 lzi-agent-cli init${X.RESET}\n`);return}let n=await Ed(a(t,ku)),r=n===null?null:{relPath:ku,content:n},i=[];for(let e of wd){let n=await Ed(a(t,e));n!==null&&i.push({relPath:e,content:n})}let o=[],s=a(t,`commands`);if(await Td(s)){let e=new Bun.Glob(`**/*.md`);for await(let t of e.scan({cwd:s,onlyFiles:!0})){let e=await Bun.file(a(s,t)).text();o.push({relPath:`commands/${t}`,content:e})}}let c=[];for(let e of Object.keys(Ru).filter(e=>e!==`commands`)){let n=await Dd(a(t,e),e);n!==null&&c.push(n)}let l=Cd({commonSource:r,typeSources:i,commandFiles:o,categoryInfos:c});if(Z(`分析对象:${t}(源文件 ${(r===null?0:1)+i.length+o.length+c.length} 个)\n`),l.length===0){Z(`${X.GREEN}未发现可优化项,源文件状态良好。${X.RESET}\n`);return}let u={high:X.RED,medium:X.YELLOW,low:X.BLUE};for(let[e,t]of l.entries()){let n=`${u[t.rule.severity]}[${t.rule.severity}]${X.RESET}`;e>0&&Z(``),Z(`${n} ${t.file}:${t.line} ${t.rule.title}`),Z(` ${t.detail}`),Z(` 依据:${t.rule.reference}`)}Z(``);let d=Ju.map(e=>`${e} ${l.filter(t=>t.rule.severity===e).length}`);Z(`共 ${l.length} 条建议(${d.join(` / `)})`),Z(`${X.BLUE}本命令为只读分析,未修改任何文件;请按建议手工调整 .lzi/ 真源。${X.RESET}\n`)},kd=`lzi-agent-tools.config.ts`,$={AGENT_TYPE:`LZI_AGENT_TYPE`,PLACEHOLDER_PREFIX:`LZI_PLACEHOLDER_`,SHARED_PROMPTS_ROOT:`LZI_AGENT_TOOLS_SHARED_PROMPTS_ROOT`},Ad=e=>`'${e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}'`,jd=e=>`[${e.map(e=>Ad(e)).join(`, `)}]`,Md=e=>`/**
|
|
265
266
|
* agent-tools 专属配置(shared-config 标准组合:本文件 > lzi.config.ts 的 agentTools 字段)
|
|
266
267
|
*
|
|
267
268
|
* 由 lzi-agent-cli 维护:shared register / shared unregister 以解析值整文件再生,
|
|
@@ -272,25 +273,25 @@ export default registration;
|
|
|
272
273
|
import type { AgentToolsConfig } from '@longzai-intelligence-agent-tools/config';
|
|
273
274
|
|
|
274
275
|
const config: AgentToolsConfig = {
|
|
275
|
-
${e.agentType===void 0?``:` agentType: ${
|
|
276
|
-
`)}\n },\n`}${e.sharedPrompts===void 0||e.sharedPrompts.subscriptions.length===0?``:` sharedPrompts: {\n subscriptions: [\n${e.sharedPrompts.subscriptions.map(e=>` {\n name: ${
|
|
276
|
+
${e.agentType===void 0?``:` agentType: ${Ad(e.agentType)},\n`}${e.placeholders===void 0?``:` placeholders: {\n${Object.keys(e.placeholders).sort().map(t=>` ${Ad(t)}: ${Ad(e.placeholders?.[t]??``)},`).join(`
|
|
277
|
+
`)}\n },\n`}${e.sharedPrompts===void 0||e.sharedPrompts.subscriptions.length===0?``:` sharedPrompts: {\n subscriptions: [\n${e.sharedPrompts.subscriptions.map(e=>` {\n name: ${Ad(e.name)},\n category: ${Ad(e.category??`agents`)},\n namespace: ${Ad(e.namespace)},\n include: ${e.include===null?`null`:jd(e.include)},\n exclude: ${e.exclude===null?`null`:jd(e.exclude)},\n },`).join(`
|
|
277
278
|
`)}\n ],\n },\n`}};
|
|
278
279
|
|
|
279
280
|
export default config;
|
|
280
|
-
`,
|
|
281
|
+
`,Nd=G().regex(/^[a-z][a-z0-9-]*$/,`名称须为小写字母开头的小写字母/数字/连字符`),Pd=ru([`agents`,`rules`]).default(`agents`),Fd=ql(G().min(1,`glob 不可为空`).refine(e=>!i(e),`禁止绝对路径形态的 glob`).refine(e=>!e.split(`/`).includes(`..`),`glob 禁止 .. 路径段`)).min(1,`glob 列表至少一条`),Id=ql(Xl({name:Nd,category:Pd,namespace:Nd,include:Fd.nullable(),exclude:Fd.nullable()})),Ld=Xl({category:Pd,namespace:Nd,include:Fd.nullable()}),Rd=Xl({name:Nd,monorepo:G().min(1,`monorepo 不可为空`),subscriptions:ql(Ld).min(1,`订阅列表至少一条`),registeredAt:G().regex(/^\d{4}-\d{2}-\d{2}$/,`registeredAt 须为 YYYY-MM-DD`),toolVersion:G().min(1,`toolVersion 不可为空`)}),zd=e=>{if(!Nd.safeParse(e).success)throw Error(`命名空间 '${e}' 非法:须为小写字母开头的小写字母/数字/连字符(如 shared)`);return e},Bd=e=>{if(e!==`agents`&&e!==`rules`)throw Error(`类别 '${e}' 非法:仅支持 agents / rules(见 docs/issues/0011)`);return e},Vd=e=>e.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `),Hd=(e,t)=>{let n=Id.safeParse(e);if(!n.success)throw Error(`共享提示词订阅配置 ${t} 校验失败(以 zod 为运行时权威): ${Vd(n.error)}`);return n.data},Ud=(e,t)=>{let n=Rd.safeParse(e);if(!n.success)throw Error(`注册记录 ${t} 校验失败(以 zod 为运行时权威): ${Vd(n.error)}`);return n.data};var Wd=class extends Error{configPath;constructor(e,t){super(e),this.name=`SharedConfigError`,this.configPath=t}},Gd=class extends Wd{searchFrom;constructor(e){super(`未在 ${e} 及其上级目录中找到 lzi.config.ts 配置文件`,e),this.name=`SharedConfigNotFoundError`,this.searchFrom=e}},Kd=class extends Wd{cause;constructor(e,t){super(`加载配置文件 ${e} 失败`,e),this.name=`SharedConfigLoadError`,this.cause=t}};function qd(e=process.cwd()){let n=o(e);for(;;){let e=a(n,`lzi.config.ts`);if(t(e))return e;let i=r(n);if(i===n)return null;n=i}}async function Jd(e={}){let t=e.cwd??process.cwd(),n=qd(t);if(n===null)throw new Gd(t);let r=o(n,`..`);try{return{config:(await import(n)).default,configPath:r,configFilePath:n}}catch(e){throw new Kd(n,e)}}function Yd(e,n=process.cwd()){let i=Array.isArray(e)?e:[e],s=o(n);for(;;){for(let e of i){let n=a(s,e);if(t(n))return n}let e=r(s);if(e===s)return null;s=e}}async function Xd(e={}){let t=e.cwd??o(process.cwd());if(e.standaloneFile){let n=Yd(e.standaloneFile,t);if(n)try{let e=await import(n);return{success:!0,config:e.default??e,source:`standalone`,configFilePath:n}}catch(e){throw new Kd(n,e)}}if(e.unifiedField)try{let{config:n,configFilePath:r}=await Jd({cwd:t}),i=n?.[e.unifiedField];if(i!==void 0)return{success:!0,config:i,source:`unified`,configFilePath:r}}catch{}return{success:!1,configFilePath:null}}const Zd=e=>zu.some(t=>t===e),Qd=async(e,t)=>{let n=e.split(`,`),r=n.includes(Vu),i=n.filter(e=>e!==Vu&&e!==``);if(r&&i.length>0)throw Error(`${$.AGENT_TYPE} 值 '${e}' 非法:auto 与显式类型不可混用,请单独使用 auto 或逗号分隔的类型列表`);if(r)return[...await Uu(t)];if(i.length===0)return[];let a=/* @__PURE__ */ new Set;for(let e of i){if(!Zd(e))throw Error(`${$.AGENT_TYPE} 值 '${e}' 无效,合法值: ${zu.join(`, `)}, ${Vu}`);if(a.has(e))throw Error(`${$.AGENT_TYPE} 值 '${e}' 重复,多值不可重复`);a.add(e)}return zu.filter(e=>a.has(e))},$d=()=>{let e=process.env[$.AGENT_TYPE];return e===void 0||e===``?null:e},ef=async e=>{let t=await Xd({standaloneFile:kd,unifiedField:`agentTools`,...e===void 0?{}:{cwd:e}});return t.success?t.config:void 0},tf=async(e={})=>{let t=process.cwd(),n=await ef(),r=e.agent??$d()??n?.agentType??``,i=r===``?[...await Uu(t)]:await Qd(r,t);return i.length===0&&(Q(`错误: 未指定目标 Agent 类型,且 auto 未推断到任何真源`),Q(`请运行 lzi-agent-cli init 创建 .lzi/ 骨架,或用 --agent / ${$.AGENT_TYPE} 指定类型`),Q(`合法值: ${zu.join(`, `)}, ${Vu}`),process.exit(1)),{agentTypes:i,placeholders:n?.placeholders}},nf=async e=>{try{return await _(e),!0}catch{return!1}},rf=async(e,t)=>await nf(e)?t((await import(`${e}?lzi=${Date.now()}`)).default,e):null,af=e=>a(e,kd),of=(e,t)=>a(e,Nu,`${t}.ts`),sf=async e=>await ef(e)??null,cf=async(e,t)=>{await Bun.write(af(e),Md(t))},lf=async e=>{await g(af(e),{force:!0})},uf=async e=>{let t=(await ef(e))?.sharedPrompts?.subscriptions;return t===void 0||t.length===0?[]:Hd(t,kd)},df=async(e,t)=>rf(of(e,t),Ud),ff=async(e,t)=>{let n=a(e,Nu);await h(n,{recursive:!0}),await Bun.write(of(e,t.name),Ku(t))},pf=async(e,t)=>{await g(of(e,t),{force:!0})},mf=async e=>{let t=a(e,Nu);if(!await nf(t))return[];let n=new Bun.Glob(`*.ts`),r=[];for await(let e of n.scan({cwd:t,onlyFiles:!0}))e!==`registration.types.ts`&&r.push(e);let i=[];for(let e of r.sort()){let n=await rf(a(t,e),Ud);n!==null&&i.push(n)}return i},hf=e=>({name:n(e),monorepo:n(a(e,`..`))}),gf=/\{\{([A-Z][A-Z0-9_]*)\}\}/g,_f=()=>{let e={};for(let[t,n]of Object.entries(process.env))if(t.startsWith($.PLACEHOLDER_PREFIX)&&n!==void 0){let r=t.slice($.PLACEHOLDER_PREFIX.length);e[r]=n}return e},vf=()=>{let e={};for(let[t,n]of Object.entries(Bu))e[t]=n();return e},yf=e=>{let t=vf(),n=_f();return{...t,...n,...e}},bf=(e,t)=>e.replace(gf,(e,n)=>t[n]??e),xf=async e=>{let t=Bun.file(e);return await t.exists()?t.text():null},Sf=async e=>{try{return await _(e),!0}catch{return!1}},Cf=async(e,t,n)=>{let r=new Bun.Glob(t),i=[];for await(let t of r.scan({cwd:e,onlyFiles:n}))i.push(t);return i.sort()},wf=e=>{let t=e.replace(/\.md$/,``);for(let e of zu){let n=`.${e}`;if(t.endsWith(n))return{baseRelPath:`${t.slice(0,-n.length)}.md`,isSpecific:!0,specificType:e}}return{baseRelPath:e,isSpecific:!1,specificType:null}},Tf=(e,t,n)=>e===``&&t===``?``:t===``?`${e.trimEnd()}\n`:e===``?`${t.trimEnd()}\n`:n===`prepend`?`${t.trimEnd()}\n\n${e.trimEnd()}\n`:`${e.trimEnd()}\n\n${t.trimEnd()}\n`,Ef=async(e,t,n,r)=>{let i=Ru[e];if(!i)return[];let o=i[t];if(!o)return[];let s=a(n,q,e);if(!await Sf(s))return[];let c=await Cf(s,`**/*.md`,!0),l=/* @__PURE__ */ new Map;for(let e of c){let{baseRelPath:t,isSpecific:n,specificType:r}=wf(e);l.has(t)||l.set(t,{common:null,specifics:/* @__PURE__ */ new Map});let i=l.get(t);i!==void 0&&(n&&r?i.specifics.set(r,e):i.common=e)}let u=[];for(let[n,{common:i,specifics:c}]of l){let l=c.get(t)??null,d=i===null?null:a(s,i),f=l===null?null:a(s,l);if(d===null&&f===null)continue;let p=d===null?``:await xf(d)??``,m=f===null?``:await xf(f)??``,h=Tf(p,m,o.mode),g=bf(h,r),_=a(o.ideRoot,e,n);u.push({category:e,agentType:t,output:_,content:g,commonSourcePath:d,agentSourcePath:f})}return u},Df=async(e,t,n)=>{let r=a(t,q);if(!await Sf(r))return[];let i=(await Cf(r,`*/`,!1)).map(e=>e.replace(/\/$/,``)),o=[];for(let r of i){if(!Ru[r])continue;let i=await Ef(r,e,t,n);o.push(...i)}return o},Of=`<!-- BEGIN Lzi Generated(工具维护,请勿手改;修改请编辑 .lzi/ 真源后运行 sync) -->`,kf=`<!-- END Lzi Generated -->`,Af=e=>{let t=e.trimEnd();return`${Of}\n${t}\n${kf}`},jf=(e,t)=>{let n=Af(t);if(e===null)return`${n}\n`;let r=e.indexOf(Of),i=e.indexOf(kf);if(r===-1||i===-1||i<r)return`${n}\n\n${e.replace(/\n+$/,``)}\n`;let a=e.slice(i+26);return`${e.slice(0,r)}${n}${a}`},Mf=e=>{let t=e.indexOf(Of),n=e.indexOf(kf);return t===-1||n===-1||n<t?null:e.slice(t+62,n).replace(/^\n+/,``).trimEnd()},Nf=e=>{let t=e.replace(/\r\n/g,`
|
|
281
282
|
`),n=t.split(`
|
|
282
283
|
`);if(n[0]!==`---`)return{frontmatter:``,body:t};for(let e=1;e<n.length;e+=1)if(n[e]===`---`)return{frontmatter:n.slice(0,e+1).join(`
|
|
283
284
|
`),body:n.slice(e+1).join(`
|
|
284
|
-
`).replace(/^\n+/,``)};return{frontmatter:``,body:t}},
|
|
285
|
-
`).slice(1,-1),r=null;for(let e of n){let n=e.trim();if(n===``)continue;let i=/^([^\s:]+):\s*(.*)$/.exec(n);if(i===null)throw Error(`条目 ${t} frontmatter 存在无法解析的行: '${n}'`);let a=i[1]??``,o=i[2]??``;if(!
|
|
285
|
+
`).replace(/^\n+/,``)};return{frontmatter:``,body:t}},Pf=(e,t)=>{let{frontmatter:n,body:r}=Nf(t),i=e===null?null:Nf(e).body,a=jf(i,r);return n===``?a:`${n}\n\n${a}`},Ff=(e,t)=>{let{frontmatter:n,body:r}=Nf(t),{frontmatter:i,body:a}=Nf(e);return i===n&&Mf(a)===r.trimEnd()},If=/* @__PURE__ */ new Set([`order`]),Lf=async e=>{try{return await _(e),!0}catch{return!1}},Rf=async e=>Bun.file(e).text(),zf=async e=>{let t=new Bun.Glob(`**/*.md`),n=[];for await(let r of t.scan({cwd:e,onlyFiles:!0}))n.push(r);return n.sort()},Bf=(e,t)=>{if(e===``)return null;let n=e.split(`
|
|
286
|
+
`).slice(1,-1),r=null;for(let e of n){let n=e.trim();if(n===``)continue;let i=/^([^\s:]+):\s*(.*)$/.exec(n);if(i===null)throw Error(`条目 ${t} frontmatter 存在无法解析的行: '${n}'`);let a=i[1]??``,o=i[2]??``;if(!If.has(a))throw Error(`条目 ${t} frontmatter 含未知元数据键 '${a}'(v1 仅支持 order)`);let s=o.trim();if(s===``)throw Error(`条目 ${t} 的 order 值为空`);if(r!==null)throw Error(`条目 ${t} frontmatter 重复声明 order`);let c=Number(s);if(!Number.isFinite(c))throw Error(`条目 ${t} 的 order 值 '${s}' 不是有限数值`);r=c}return r},Vf=e=>`${q}/${Au}/${e}`,Hf=(e,t)=>{let n=e.order??1/0,r=t.order??1/0;return n===r?e.baseRelPath===t.baseRelPath?0:e.baseRelPath<t.baseRelPath?-1:1:n-r},Uf=async e=>{let t=a(e,q,Au);if(!await Lf(t))return/* @__PURE__ */ new Map;let n=await zf(t),r=/* @__PURE__ */ new Map;for(let e of n){let{baseRelPath:t,isSpecific:n,specificType:i}=wf(e);r.has(t)||r.set(t,{common:null,specifics:/* @__PURE__ */ new Map});let a=r.get(t);a!==void 0&&(n&&i?a.specifics.set(i,e):a.common===null&&(a.common=e))}return r},Wf=async(e,t)=>{let n=await Uf(t),r=a(t,q,Au),i=[];for(let[t,o]of n){let n=o.specifics.get(e)??null,s=n??o.common;if(s===null)continue;let c=a(r,s),l=await Rf(c),{frontmatter:u,body:d}=Nf(l),f=Bf(u,Vf(s)),p=f;if(o.common!==null&&n!==null){if(f!==null)throw Error(`条目 ${Vf(t)} 的变体 ${n} 不得声明 order(条目定位由共同版唯一决定)`);let e=await Rf(a(r,o.common)),{frontmatter:i}=Nf(e);p=Bf(i,Vf(o.common))}d.trim()!==``&&i.push({baseRelPath:t,order:p,content:d.trimEnd()})}return i.sort(Hf)},Gf=async(e,t)=>{let n=await Wf(e,t);return{content:n.map(e=>e.content).join(`
|
|
286
287
|
|
|
287
|
-
`),sources:n.map(e=>e.baseRelPath)}},
|
|
288
|
-
`)}\n请在项目 .env 中设置 ${$.SHARED_PROMPTS_ROOT}=<hub 根绝对路径>(机器本地,不进 git),或确认 hub 已 clone 到约定位置 ../${e}`)},
|
|
288
|
+
`),sources:n.map(e=>e.baseRelPath)}},Kf=async e=>{try{return(await _(e)).isDirectory()}catch{return!1}},qf=async(e,t,n={})=>{let r=process.env[$.SHARED_PROMPTS_ROOT],i=[...r!==void 0&&r!==``?[{source:`env`,path:o(r)}]:[],...n.explicitPath===void 0?[]:[{source:`explicit`,path:o(t,n.explicitPath)}],{source:`convention`,path:o(t,`..`,e)}],a=[];for(let e of i)if(a.push(`${e.source}: ${e.path}`),await Kf(e.path))return{hubRoot:e.path,source:e.source};throw Error(`共享提示词中心仓 '${e}' 定位失败,已尝试:\n ${a.join(`
|
|
289
|
+
`)}\n请在项目 .env 中设置 ${$.SHARED_PROMPTS_ROOT}=<hub 根绝对路径>(机器本地,不进 git),或确认 hub 已 clone 到约定位置 ../${e}`)},Jf=async(e,t)=>{let n=ju(t.category),r=a(e,n),i=[];try{let e=new Bun.Glob(`**/*.md`);for await(let t of e.scan({cwd:r,onlyFiles:!0}))i.push(t)}catch{throw Error(`hub ${t.category} 类别条目库目录不存在: ${r}`)}return i.sort().filter(e=>t.include===null||t.include.some(t=>new Bun.Glob(t).match(e))?!(t.exclude!==null&&t.exclude.some(t=>new Bun.Glob(t).match(e))):!1)},Yf=async(e,t,n)=>{if(t.category!==`agents`)return;let r=await Bun.file(a(e,ju(t.category),n)).text(),{frontmatter:i}=Nf(r);Bf(i,`<hub>/${ju(t.category)}/${n}`)},Xf=(e,t,n)=>a(e,Mu(t,n)),Zf=async(e,t)=>{let n=await uf(e);if(n.length===0)return{skipped:!0,results:[],hasError:!1,hasDrift:!1};let r=[];for(let i of n){let n=await(async()=>{try{let{hubRoot:n}=await qf(i.name,e),r=await Jf(n,i),o=Xf(e,i.category,i.namespace);if(t===`plan`)return{subscription:i,hubRoot:n,matchedCount:r.length,status:`planned`,drift:[],message:null};let s=/* @__PURE__ */ new Map;for(let e of r){let t=await Bun.file(a(n,ju(i.category),e)).text();s.set(e,t)}if(t===`write`){for(let e of r)await Yf(n,i,e);await g(o,{recursive:!0,force:!0}),await h(o,{recursive:!0});for(let[e,t]of s)await Bun.write(a(o,e),t);return{subscription:i,hubRoot:n,matchedCount:r.length,status:`materialized`,drift:[],message:null}}let c=[],l=/* @__PURE__ */ new Map,u=new Bun.Glob(`**/*`);for await(let e of u.scan({cwd:o,onlyFiles:!0}))l.set(e,await Bun.file(a(o,e)).text());for(let[e,t]of s)l.has(e)?l.get(e)!==t&&c.push(`changed: ${e}`):c.push(`missing: ${e}`);for(let e of l.keys())s.has(e)||c.push(`extra: ${e}`);return{subscription:i,hubRoot:n,matchedCount:r.length,status:c.length>0?`drifted`:`clean`,drift:c.sort(),message:null}}catch(e){return{subscription:i,hubRoot:null,matchedCount:0,status:`error`,drift:[],message:e instanceof Error?e.message:String(e)}}})();r.push(n)}return{skipped:!1,results:r,hasError:r.some(e=>e.status===`error`),hasDrift:r.some(e=>e.status===`drifted`)}},Qf=e=>{for(;e.length>0&&e[e.length-1]===``;)e.pop();return e},$f=(e,t)=>{let n=[...new Set(t)].sort(),r=n.length>0;if(e===null)return r?`${[Pu,...n,Fu].join(`
|
|
289
290
|
`)}\n`:null;let i=e.replace(/\r\n/g,`
|
|
290
291
|
`).split(`
|
|
291
|
-
`),a=i.indexOf(
|
|
292
|
-
`)}\n`},
|
|
292
|
+
`),a=i.indexOf(Pu),o=i.indexOf(Fu),s=a!==-1&&o!==-1&&o>=a;if(!r&&!s)return e;let c=r?[Pu,...n,Fu]:[],l=s?[...i.slice(0,!r&&a>0&&i[a-1]===``?a-1:a),...c,...i.slice(o+1)]:[...Qf([...i]),``,...c];return`${Qf(l).join(`
|
|
293
|
+
`)}\n`},ep=e=>{if(e===null)return[];let t=e.replace(/\r\n/g,`
|
|
293
294
|
`).split(`
|
|
294
|
-
`),n=t.indexOf(Nu),r=t.indexOf(Pu);return n===-1||r===-1||r<n?[]:t.slice(n+1,r).filter(e=>e.trim()!==``)},Qf=Yl({version:G()}),$f=async()=>{let e=Qf.safeParse(await Bun.file(a(import.meta.dir,`../../../package.json`)).json());if(!e.success)throw Error(`apps/cli/package.json 缺少 version 字段(CLI 包描述异常)`);return e.data.version},ep=e=>{if(e===void 0)return null;let t=e.split(`,`).map(e=>e.trim()).filter(e=>e!==``);return t.length>0?t:null},tp=async e=>{let t=a(e,`.gitignore`),n=Bun.file(t);return await n.exists()?n.text():null},np=async(e,t)=>{let n=t.map(e=>`${q}/${Au}/${e}/`),r=await tp(e),i=Xf(r,n);i!==null&&i!==r&&await Bun.write(a(e,`.gitignore`),i)},rp=async(e,t)=>{let n=Bun.file(a(e,`.env`)),r=await n.exists()?await n.text():null,i=`${$.SHARED_PROMPTS_ROOT}=${t}`;if(r===null){await Bun.write(a(e,`.env`),`${i}\n`);return}let o=RegExp(`^${$.SHARED_PROMPTS_ROOT}=.*$`,`m`);if(o.test(r)){let t=r.replace(o,i);t!==r&&await Bun.write(a(e,`.env`),t);return}await Bun.write(a(e,`.env`),`${r.replace(/\n+$/,``)}\n${i}\n`)},ip=async e=>{let t=Bun.file(a(e,`.env.example`)),n=await t.exists()?await t.text():null,r=`${$.SHARED_PROMPTS_ROOT}=/absolute/path/to/longzai-intelligence-agent-prompts`;if(!(n!==null&&n.includes(`${$.SHARED_PROMPTS_ROOT}=`))){if(n===null){await Bun.write(a(e,`.env.example`),`${r}\n`);return}await Bun.write(a(e,`.env.example`),`${n.replace(/\n+$/,``)}\n${r}\n`)}},ap=async e=>{for(let t of[`.env`,`.env.example`]){let n=Bun.file(a(e,t));if(!await n.exists())continue;let r=await n.text(),i=r.replace(RegExp(`^${$.SHARED_PROMPTS_ROOT}=.*\\n?`,`m`),``);i!==r&&await Bun.write(a(e,t),i)}},op=async e=>{let t;try{t=await Bun.file(a(e,`package.json`)).json()}catch{return}let n={...t.dependencies,...t.devDependencies};`@longzai-intelligence-agent-tools/config`in n||`@longzai-intelligence-agent-tools/core`in n||`@longzai-intelligence-agent-tools/cli`in n||Z(`${X.YELLOW}提示: 项目未声明 @longzai-intelligence-agent-tools/config 依赖,配置文件的 IDE 静态检查不可用(运行不受影响,type-only import 运行时擦除)${X.RESET}`)},sp=async(e,t)=>{let n=qf(e,t),r=new Bun.Glob(`**/*.md`),i=0;try{for await(let e of r.scan({cwd:n,onlyFiles:!0}))i+=1}catch{return!1}return i!==0&&!Zf(await tp(e)).includes(`${q}/${Au}/${t}/`)},cp=(e,t)=>({...e?.agentType===void 0?{}:{agentType:e.agentType},...e?.placeholders===void 0?{}:{placeholders:e.placeholders},...t.length===0?{}:{sharedPrompts:{subscriptions:t}}}),lp=async e=>{let t=process.cwd(),{name:n,monorepo:r}=ff(t),i=e.hub??`longzai-intelligence-agent-prompts`,o=Ld(e.namespace??`shared`),s=await rf(t),c=await sf(t),l=c.find(e=>e.name!==i);if(l!==void 0)throw Error(`v1 每项目仅支持订阅单一 hub,当前已订阅 '${l.name}';多 hub 支持规划中`);let u=c.find(e=>e.name===i&&e.namespace===o)??null;if(u===null&&await sp(t,o))throw Error(`命名空间目录 ${q}/${Au}/${o}/ 已存在本地手工条目,物化整目录重建会将其抹掉。请换用 --namespace 指定其他命名空间,或先迁移/删除该目录`);let{hubRoot:d,source:f}=await Wf(i,t,{explicitPath:e.path});await rp(t,d),await ip(t),await Uf(a(d,ju))||Z(`${X.YELLOW}提示: hub 条目库目录 ${ju}/ 不存在,本次订阅将物化 0 个条目${X.RESET}`);let p={name:i,namespace:o,include:ep(e.include),exclude:ep(e.exclude)},m=[...c.filter(e=>e.name!==i||e.namespace!==o),p],h=await cf(d,n);await af(t,cp(s,m)),await lf(d,{name:n,monorepo:r,subscriptions:m.map(e=>({namespace:e.namespace,include:e.include})),registeredAt:h?.registeredAt??(/* @__PURE__ */ new Date()).toISOString().slice(0,10),toolVersion:await $f()}),await np(t,m.map(e=>e.namespace)),await op(t);let g=u===null?`已注册`:`已更新`;Z(``),Z(`${X.GREEN}✓ ${g}共享提示词订阅${X.RESET}`),Z(` hub: ${i}(定位: ${f})`),Z(` 命名空间: ${o} → ${q}/${Au}/${o}/`),Z(` 范围: ${p.include===null?`全部条目`:p.include.join(`, `)}${p.exclude===null?``:`(排除 ${p.exclude.join(`, `)})`}`),Z(` 双端写入: ${Od} + ${i}/registry/projects/${n}.ts`),Z(` 位置固化: .env ${$.SHARED_PROMPTS_ROOT}(机器本地,不进 git)+ .env.example 占位条目`),Z(`${X.YELLOW}运行 lzi-agent-cli sync 物化共享条目并合成${X.RESET}`)},up=async e=>{let t=process.cwd(),n=await sf(t);if(n.length===0){Z(`当前项目未注册共享提示词订阅`);return}let r;if(e.namespace!==void 0){let t=n.filter(t=>t.namespace===e.namespace);if(t.length===0)throw Error(`命名空间 '${e.namespace}' 未订阅;当前订阅: `+n.map(e=>e.namespace).join(`, `));r=t}else if(n.length===1)r=n;else throw Error(`存在多个订阅,请用 --namespace 指定: `+n.map(e=>e.namespace).join(`, `));let i=n.filter(e=>!r.includes(e));for(let e of r)await g(qf(t,e.namespace),{recursive:!0,force:!0});for(let e of r)try{let{hubRoot:n}=await Wf(e.name,t),r=i.filter(t=>t.name===e.name);if(r.length===0)await uf(n,ff(t).name);else{let{name:e,monorepo:i}=ff(t),a=await cf(n,e);await lf(n,{name:e,monorepo:i,subscriptions:r.map(e=>({namespace:e.namespace,include:e.include})),registeredAt:a?.registeredAt??(/* @__PURE__ */ new Date()).toISOString().slice(0,10),toolVersion:await $f()})}}catch(t){Q(`${X.YELLOW}提示: hub '${e.name}' 不可达,hub 侧注册记录未清理(${t instanceof Error?t.message:String(t)})${X.RESET}`)}let a=await Bun.file(tf(t)).exists(),o=await rf(t),s=cp(o,i),c=s.agentType===void 0&&s.placeholders===void 0&&s.sharedPrompts===void 0;c&&!a||(c?await of(t):await af(t,s)),await np(t,i.map(e=>e.namespace)),i.length===0&&await ap(t),Z(``),Z(`${X.GREEN}✓ 已注销共享提示词订阅${X.RESET}`),Z(` 移除命名空间: ${r.map(e=>e.namespace).join(`, `)}`),i.length>0&&Z(` 保留订阅: ${i.map(e=>e.namespace).join(`, `)}`)},dp=e=>e===`clean`?`${X.GREEN}物化一致${X.RESET}`:e===`drifted`?`${X.RED}存在漂移${X.RESET}`:e===`planned`?`待物化`:`${X.RED}定位失败${X.RESET}`,fp=async()=>{let e=process.cwd(),t=await Uf(a(e,Mu));if(t){let t=await df(e);Z(`${X.BLUE}=== 共享提示词中心仓注册表(${t.length} 个项目) ===${X.RESET}\n`);for(let e of t)Z(`${X.GREEN}${e.name}${X.RESET}(${e.monorepo},注册于 ${e.registeredAt},工具 ${e.toolVersion})`),Z(` 订阅: ${e.subscriptions.map(e=>`${e.namespace}${e.include===null?`(全部)`:`(${e.include.join(`, `)})`}`).join(`; `)}`);t.length===0&&Z(` (尚无项目注册)`)}let n=await sf(e);if(n.length===0){t||Z(`当前项目未注册共享提示词订阅(运行 lzi-agent-cli shared register 注册)`);return}Z(`${X.BLUE}=== 共享提示词订阅(${n.length} 个) ===${X.RESET}\n`);let r=await Jf(e,`check`);for(let e of r.results){let t=e.subscription.include===null?`全部条目`:e.subscription.include.join(`, `);Z(`${X.GREEN}${e.subscription.namespace}${X.RESET} ← ${e.subscription.name}(${t})`),Z(` 状态: ${dp(e.status)},命中 ${e.matchedCount} 个条目${e.hubRoot===null?``:`,hub: ${e.hubRoot}`}`),e.status===`error`&&e.message!==null&&Z(` ${X.RED}${e.message}${X.RESET}`);for(let t of e.drift)Z(` ${X.RED}${t}${X.RESET}`)}r.hasDrift&&(Z(``),Z(`${X.YELLOW}存在物化漂移:运行 lzi-agent-cli sync 重建共享条目${X.RESET}`))},pp=Zl({hub:G().optional(),namespace:G().optional(),include:G().optional(),exclude:G().optional(),path:G().optional()}),mp=Zl({namespace:G().optional()}),hp=e=>{let t=e.command(`shared`).description(`共享提示词中心仓订阅管理`);ht(t,{name:`register`,description:`注册/更新当前项目对共享提示词中心仓的订阅(双端写入)`,options:[{flags:`--hub <name>`,description:`hub 仓库名(默认 longzai-intelligence-agent-prompts)`},{flags:`--namespace <name>`,description:`物化命名空间(默认 shared)`},{flags:`--include <globs>`,description:`订阅范围 glob(逗号分隔,如 lang/**,git/**;缺省全部)`},{flags:`--exclude <globs>`,description:`排除 glob(逗号分隔)`},{flags:`--path <path>`,description:`hub 相对路径(相对项目根;缺省走解析链)`}],schema:pp,action:async e=>{let t={hub:e.hub,namespace:e.namespace,include:e.include,exclude:e.exclude,path:e.path};await lp(t)}}),ht(t,{name:`unregister`,description:`注销订阅(双端移除 + 物化目录清理)`,options:[{flags:`--namespace <name>`,description:`待移除的命名空间(多订阅时必填)`}],schema:mp,action:async e=>{let t={namespace:e.namespace};await up(t)}}),ht(t,{name:`status`,description:`查看订阅健康度(项目根)或注册项目汇总(hub 根)`,schema:Yl({}),action:async()=>{await fp()}})},gp=`${X.GREEN}存在${X.RESET}`,_p=`${X.RED}缺失${X.RESET}`,vp=e=>Ru.some(t=>t===e),yp=async e=>Bun.file(e).exists(),bp=async()=>{let e=process.cwd(),t=a(e,q),n=process.env[$.AGENT_TYPE];Z(`${X.BLUE}=== Agent Tools 状态 ===${X.RESET}\n`);let r;n===void 0||n===``?(r=await Hu(e),r.length>0?Z(`当前 Agent: ${X.GREEN}auto → ${r.join(`, `)}${X.RESET}(默认,按真源推断)`):Z(`当前 Agent: ${X.YELLOW}auto → 未推断到真源${X.RESET}(请运行 lzi-agent-cli init)`)):vp(n)?(r=[n],Z(`当前 Agent: ${X.GREEN}${n}${X.RESET}(环境变量 ${$.AGENT_TYPE})`)):(r=await Hu(e),Z(`当前 Agent: ${X.RED}${n}(无效,合法值: ${Ru.join(`, `)})${X.RESET}`)),Z(``),Z(`${X.BLUE}源文件(${t}):${X.RESET}`);let i=/* @__PURE__ */ new Set;i.add(ku);for(let e of r)for(let t of Iu[e])i.add(t.agentSource);for(let e of i){let n=a(t,e);Z(` ${e}: ${await yp(n)?gp:_p}`)}if(Z(``),r.length>0){Z(`${X.BLUE}输出目标(将覆盖):${X.RESET}`);let t=/* @__PURE__ */ new Set;for(let e of r)for(let n of Iu[e])t.add(n.output);for(let n of t){let t=a(e,n);Z(` ${n}: ${await yp(t)?gp:_p}`)}}else Z(`${X.YELLOW}Agent 类型未配置,无法显示输出目标${X.RESET}`);Z(``),Z(`${X.BLUE}类别配置目录(${t} 下):${X.RESET}`);for(let e of Object.keys(Lu)){let n=a(t,e);Z(` ${e}/: ${await yp(n)?gp:_p}`)}},xp=e=>{let t=[],n=new Set(e[0]?.itemsSources??[]);for(let r of e){let e=new Set(r.itemsSources);for(let n of e)t.includes(n)||t.push(n);for(let t of n)e.has(t)||n.delete(t)}return t.filter(e=>!n.has(e))},Sp=e=>{let t=/* @__PURE__ */ new Map;for(let n of e){let e=t.get(n.output);e===void 0?t.set(n.output,[n]):e.push(n)}let n=[];for(let[e,r]of t){let t=r[0];t!==void 0&&r.some(e=>e.content.trimEnd()!==t.content.trimEnd())&&n.push({output:e,entries:r,differingItems:xp(r)})}return n},Cp=async e=>{let t=Bun.file(e);return await t.exists()?t.text():null},wp=e=>Ru.some(t=>t===e),Tp=e=>{let t=(e.split(`/`).pop()??``).replace(/\.md$/,``).split(`.`).pop()??``;if(!wp(t))throw Error(`合成规则源文件 '${e}' 缺少合法 .<type> 后缀`);return t},Ep=async(e,t,n)=>{let r=a(t,q,e.commonSource),i=a(t,q,e.agentSource),o=await Cp(r);if(o===null)throw Error(`共同部分源文件不存在: ${r}`);let s=await Cp(i);if(s===null)throw Error(`独有部分源文件不存在: ${i}`);let c=await Hf(Tp(e.agentSource),t),l=`${[o.trimEnd(),c.content,s.trimEnd()].filter(e=>e!==``).join(`
|
|
295
|
+
`),n=t.indexOf(Pu),r=t.indexOf(Fu);return n===-1||r===-1||r<n?[]:t.slice(n+1,r).filter(e=>e.trim()!==``)},tp=Yl({version:G()}),np=async()=>{let e=tp.safeParse(await Bun.file(a(import.meta.dir,`../../../package.json`)).json());if(!e.success)throw Error(`apps/cli/package.json 缺少 version 字段(CLI 包描述异常)`);return e.data.version},rp=e=>{if(e===void 0)return null;let t=e.split(`,`).map(e=>e.trim()).filter(e=>e!==``);return t.length>0?t:null},ip=async e=>{let t=a(e,`.gitignore`),n=Bun.file(t);return await n.exists()?n.text():null},ap=async(e,t)=>{let n=t.map(e=>`${Mu(e.category,e.namespace)}/`),r=await ip(e),i=$f(r,n);i!==null&&i!==r&&await Bun.write(a(e,`.gitignore`),i)},op=async(e,t)=>{let n=Bun.file(a(e,`.env`)),r=await n.exists()?await n.text():null,i=`${$.SHARED_PROMPTS_ROOT}=${t}`;if(r===null){await Bun.write(a(e,`.env`),`${i}\n`);return}let o=RegExp(`^${$.SHARED_PROMPTS_ROOT}=.*$`,`m`);if(o.test(r)){let t=r.replace(o,i);t!==r&&await Bun.write(a(e,`.env`),t);return}await Bun.write(a(e,`.env`),`${r.replace(/\n+$/,``)}\n${i}\n`)},sp=async e=>{let t=Bun.file(a(e,`.env.example`)),n=await t.exists()?await t.text():null,r=`${$.SHARED_PROMPTS_ROOT}=/absolute/path/to/longzai-intelligence-agent-prompts`;if(!(n!==null&&n.includes(`${$.SHARED_PROMPTS_ROOT}=`))){if(n===null){await Bun.write(a(e,`.env.example`),`${r}\n`);return}await Bun.write(a(e,`.env.example`),`${n.replace(/\n+$/,``)}\n${r}\n`)}},cp=async e=>{for(let t of[`.env`,`.env.example`]){let n=Bun.file(a(e,t));if(!await n.exists())continue;let r=await n.text(),i=r.replace(RegExp(`^${$.SHARED_PROMPTS_ROOT}=.*\\n?`,`m`),``);i!==r&&await Bun.write(a(e,t),i)}},lp=async e=>{let t;try{t=await Bun.file(a(e,`package.json`)).json()}catch{return}let n={...t.dependencies,...t.devDependencies};`@longzai-intelligence-agent-tools/config`in n||`@longzai-intelligence-agent-tools/core`in n||`@longzai-intelligence-agent-tools/cli`in n||Z(`${X.YELLOW}提示: 项目未声明 @longzai-intelligence-agent-tools/config 依赖,配置文件的 IDE 静态检查不可用(运行不受影响,type-only import 运行时擦除)${X.RESET}`)},up=async(e,t,n)=>{let r=Xf(e,t,n),i=new Bun.Glob(`**/*.md`),a=0;try{for await(let e of i.scan({cwd:r,onlyFiles:!0}))a+=1}catch{return!1}return a!==0&&!ep(await ip(e)).includes(`${Mu(t,n)}/`)},dp=(e,t)=>({...e?.agentType===void 0?{}:{agentType:e.agentType},...e?.placeholders===void 0?{}:{placeholders:e.placeholders},...t.length===0?{}:{sharedPrompts:{subscriptions:t}}}),fp=async e=>{let t=process.cwd(),{name:n,monorepo:r}=hf(t),i=e.hub??`longzai-intelligence-agent-prompts`,o=Bd(e.category??`agents`),s=zd(e.namespace??`shared`),c=await sf(t),l=await uf(t),u=l.find(e=>e.name!==i);if(u!==void 0)throw Error(`v1 每项目仅支持订阅单一 hub,当前已订阅 '${u.name}';多 hub 支持规划中`);let d=l.find(e=>e.name===i&&e.category===o&&e.namespace===s)??null;if(d===null&&await up(t,o,s))throw Error(`命名空间目录 ${Mu(o,s)}/ 已存在本地手工内容,物化整目录重建会将其抹掉。请换用 --namespace 指定其他命名空间,或先迁移/删除该目录`);let{hubRoot:f,source:p}=await qf(i,t,{explicitPath:e.path});await op(t,f),await sp(t),await Kf(a(f,ju(o)))||Z(`${X.YELLOW}提示: hub ${o} 类别条目库目录 ${ju(o)}/ 不存在,本次订阅将物化 0 个条目${X.RESET}`);let m={name:i,category:o,namespace:s,include:rp(e.include),exclude:rp(e.exclude)},h=[...l.filter(e=>e.name!==i||e.category!==o||e.namespace!==s),m],g=await df(f,n);await cf(t,dp(c,h)),await ff(f,{name:n,monorepo:r,subscriptions:h.map(e=>({category:e.category,namespace:e.namespace,include:e.include})),registeredAt:g?.registeredAt??(/* @__PURE__ */ new Date()).toISOString().slice(0,10),toolVersion:await np()}),await ap(t,h),await lp(t);let _=d===null?`已注册`:`已更新`;Z(``),Z(`${X.GREEN}✓ ${_}共享提示词订阅${X.RESET}`),Z(` hub: ${i}(定位: ${p})`),Z(` 类别: ${o}`),Z(` 命名空间: ${s} → ${Mu(o,s)}/`),Z(` 范围: ${m.include===null?`全部条目`:m.include.join(`, `)}${m.exclude===null?``:`(排除 ${m.exclude.join(`, `)})`}`),Z(` 双端写入: ${kd} + ${i}/registry/projects/${n}.ts`),Z(` 位置固化: .env ${$.SHARED_PROMPTS_ROOT}(机器本地,不进 git)+ .env.example 占位条目`),Z(`${X.YELLOW}运行 lzi-agent-cli sync 物化共享条目并合成${X.RESET}`)},pp=async e=>{let t=process.cwd(),n=e.category===void 0?void 0:Bd(e.category),r=await uf(t);if(r.length===0){Z(`当前项目未注册共享提示词订阅`);return}let i=e=>`${e.category}/${e.namespace}`,a;if(e.namespace!==void 0){let t=r.filter(t=>t.namespace===e.namespace&&(n===void 0||t.category===n));if(t.length===0)throw Error(`命名空间 '${e.namespace}' 未订阅(类别 ${n??`任意`});当前订阅: `+r.map(i).join(`, `));if(t.length>1)throw Error(`命名空间 '${e.namespace}' 存在多类别订阅,请用 --category 指定: `+t.map(i).join(`, `));a=t}else if(n!==void 0)a=r.filter(e=>e.category===n);else if(r.length===1)a=r;else throw Error(`存在多个订阅,请用 --namespace(必要时加 --category)指定: `+r.map(i).join(`, `));let o=r.filter(e=>!a.includes(e));for(let e of a)await g(Xf(t,e.category,e.namespace),{recursive:!0,force:!0});for(let e of a)try{let{hubRoot:n}=await qf(e.name,t),r=o.filter(t=>t.name===e.name);if(r.length===0)await pf(n,hf(t).name);else{let{name:e,monorepo:i}=hf(t),a=await df(n,e);await ff(n,{name:e,monorepo:i,subscriptions:r.map(e=>({category:e.category,namespace:e.namespace,include:e.include})),registeredAt:a?.registeredAt??(/* @__PURE__ */ new Date()).toISOString().slice(0,10),toolVersion:await np()})}}catch(t){Q(`${X.YELLOW}提示: hub '${e.name}' 不可达,hub 侧注册记录未清理(${t instanceof Error?t.message:String(t)})${X.RESET}`)}let s=await Bun.file(af(t)).exists(),c=await sf(t),l=dp(c,o),u=l.agentType===void 0&&l.placeholders===void 0&&l.sharedPrompts===void 0;u&&!s||(u?await lf(t):await cf(t,l)),await ap(t,o),o.length===0&&await cp(t),Z(``),Z(`${X.GREEN}✓ 已注销共享提示词订阅${X.RESET}`),Z(` 移除订阅: ${a.map(i).join(`, `)}`),o.length>0&&Z(` 保留订阅: ${o.map(i).join(`, `)}`)},mp=e=>e===`clean`?`${X.GREEN}物化一致${X.RESET}`:e===`drifted`?`${X.RED}存在漂移${X.RESET}`:e===`planned`?`待物化`:`${X.RED}定位失败${X.RESET}`,hp=async()=>{let e=process.cwd(),t=await Kf(a(e,Nu));if(t){let t=await mf(e);Z(`${X.BLUE}=== 共享提示词中心仓注册表(${t.length} 个项目) ===${X.RESET}\n`);for(let e of t)Z(`${X.GREEN}${e.name}${X.RESET}(${e.monorepo},注册于 ${e.registeredAt},工具 ${e.toolVersion})`),Z(` 订阅: ${e.subscriptions.map(e=>`${e.category}/${e.namespace}${e.include===null?`(全部)`:`(${e.include.join(`, `)})`}`).join(`; `)}`);t.length===0&&Z(` (尚无项目注册)`)}let n=await uf(e);if(n.length===0){t||Z(`当前项目未注册共享提示词订阅(运行 lzi-agent-cli shared register 注册)`);return}Z(`${X.BLUE}=== 共享提示词订阅(${n.length} 个) ===${X.RESET}\n`);let r=await Zf(e,`check`);for(let e of r.results){let t=e.subscription.include===null?`全部条目`:e.subscription.include.join(`, `);Z(`${X.GREEN}${e.subscription.category}/${e.subscription.namespace}${X.RESET} ← ${e.subscription.name}(${t})`),Z(` 状态: ${mp(e.status)},命中 ${e.matchedCount} 个条目${e.hubRoot===null?``:`,hub: ${e.hubRoot}`}`),e.status===`error`&&e.message!==null&&Z(` ${X.RED}${e.message}${X.RESET}`);for(let t of e.drift)Z(` ${X.RED}${t}${X.RESET}`)}r.hasDrift&&(Z(``),Z(`${X.YELLOW}存在物化漂移:运行 lzi-agent-cli sync 重建共享条目${X.RESET}`))},gp=Zl({hub:G().optional(),category:G().optional(),namespace:G().optional(),include:G().optional(),exclude:G().optional(),path:G().optional()}),_p=Zl({category:G().optional(),namespace:G().optional()}),vp=e=>{let t=e.command(`shared`).description(`共享提示词中心仓订阅管理`);ht(t,{name:`register`,description:`注册/更新当前项目对共享提示词中心仓的订阅(双端写入)`,options:[{flags:`--hub <name>`,description:`hub 仓库名(默认 longzai-intelligence-agent-prompts)`},{flags:`--category <category>`,description:`订阅类别:agents = 根指令条目(默认);rules = 项目规则(.trae/rules 真源集中化)`},{flags:`--namespace <name>`,description:`物化命名空间(默认 shared)`},{flags:`--include <globs>`,description:`订阅范围 glob(逗号分隔,如 lang/**,git/**;缺省全部)`},{flags:`--exclude <globs>`,description:`排除 glob(逗号分隔)`},{flags:`--path <path>`,description:`hub 相对路径(相对项目根;缺省走解析链)`}],schema:gp,action:async e=>{let t={hub:e.hub,category:e.category,namespace:e.namespace,include:e.include,exclude:e.exclude,path:e.path};await fp(t)}}),ht(t,{name:`unregister`,description:`注销订阅(双端移除 + 物化目录清理)`,options:[{flags:`--namespace <name>`,description:`待移除的命名空间(多订阅时必填)`},{flags:`--category <category>`,description:`订阅类别(agents/rules;同命名空间跨类别订阅时用于消歧)`}],schema:_p,action:async e=>{let t={category:e.category,namespace:e.namespace};await pp(t)}}),ht(t,{name:`status`,description:`查看订阅健康度(项目根)或注册项目汇总(hub 根)`,schema:Yl({}),action:async()=>{await hp()}})},yp=`${X.GREEN}存在${X.RESET}`,bp=`${X.RED}缺失${X.RESET}`,xp=e=>zu.some(t=>t===e),Sp=async e=>Bun.file(e).exists(),Cp=async()=>{let e=process.cwd(),t=a(e,q),n=process.env[$.AGENT_TYPE];Z(`${X.BLUE}=== Agent Tools 状态 ===${X.RESET}\n`);let r;n===void 0||n===``?(r=await Uu(e),r.length>0?Z(`当前 Agent: ${X.GREEN}auto → ${r.join(`, `)}${X.RESET}(默认,按真源推断)`):Z(`当前 Agent: ${X.YELLOW}auto → 未推断到真源${X.RESET}(请运行 lzi-agent-cli init)`)):xp(n)?(r=[n],Z(`当前 Agent: ${X.GREEN}${n}${X.RESET}(环境变量 ${$.AGENT_TYPE})`)):(r=await Uu(e),Z(`当前 Agent: ${X.RED}${n}(无效,合法值: ${zu.join(`, `)})${X.RESET}`)),Z(``),Z(`${X.BLUE}源文件(${t}):${X.RESET}`);let i=/* @__PURE__ */ new Set;i.add(ku);for(let e of r)for(let t of Lu[e])i.add(t.agentSource);for(let e of i){let n=a(t,e);Z(` ${e}: ${await Sp(n)?yp:bp}`)}if(Z(``),r.length>0){Z(`${X.BLUE}输出目标(将覆盖):${X.RESET}`);let t=/* @__PURE__ */ new Set;for(let e of r)for(let n of Lu[e])t.add(n.output);for(let n of t){let t=a(e,n);Z(` ${n}: ${await Sp(t)?yp:bp}`)}}else Z(`${X.YELLOW}Agent 类型未配置,无法显示输出目标${X.RESET}`);Z(``),Z(`${X.BLUE}类别配置目录(${t} 下):${X.RESET}`);for(let e of Object.keys(Ru)){let n=a(t,e);Z(` ${e}/: ${await Sp(n)?yp:bp}`)}},wp=e=>{let t=[],n=new Set(e[0]?.itemsSources??[]);for(let r of e){let e=new Set(r.itemsSources);for(let n of e)t.includes(n)||t.push(n);for(let t of n)e.has(t)||n.delete(t)}return t.filter(e=>!n.has(e))},Tp=e=>{let t=/* @__PURE__ */ new Map;for(let n of e){let e=t.get(n.output);e===void 0?t.set(n.output,[n]):e.push(n)}let n=[];for(let[e,r]of t){let t=r[0];t!==void 0&&r.some(e=>e.content.trimEnd()!==t.content.trimEnd())&&n.push({output:e,entries:r,differingItems:wp(r)})}return n},Ep=async e=>{let t=Bun.file(e);return await t.exists()?t.text():null},Dp=e=>zu.some(t=>t===e),Op=e=>{let t=(e.split(`/`).pop()??``).replace(/\.md$/,``).split(`.`).pop()??``;if(!Dp(t))throw Error(`合成规则源文件 '${e}' 缺少合法 .<type> 后缀`);return t},kp=async(e,t,n)=>{let r=a(t,q,e.commonSource),i=a(t,q,e.agentSource),o=await Ep(r);if(o===null)throw Error(`共同部分源文件不存在: ${r}`);let s=await Ep(i);if(s===null)throw Error(`独有部分源文件不存在: ${i}`);let c=await Gf(Op(e.agentSource),t),l=`${[o.trimEnd(),c.content,s.trimEnd()].filter(e=>e!==``).join(`
|
|
295
296
|
|
|
296
|
-
`)}\n`,u=
|
|
297
|
+
`)}\n`,u=bf(l,n);return{output:e.output,content:u,commonSourcePath:r,agentSourcePath:i,itemsSources:c.sources}},Ap=async(e,t,n)=>{let r=Lu[e],i=[];for(let e of r){let r=await kp(e,t,n);i.push(r)}return i},jp=async(e,t)=>{let n=a(e,t),r=Bun.file(n);return await r.exists()?r.text():null},Mp=e=>e.itemsSources.length>0?`${e.commonSourcePath} + items(${e.itemsSources.length}) + ${e.agentSourcePath}`:`${e.commonSourcePath} + ${e.agentSourcePath}`,Np=(e,t)=>{let n=e.map(e=>({output:e.output,content:e.content,sourceLabel:Mp(e),kind:`root`})),r=t.map(e=>{let t=[];return e.commonSourcePath&&t.push(e.commonSourcePath),e.agentSourcePath&&t.push(e.agentSourcePath),{output:e.output,content:e.content,sourceLabel:t.join(` + `),kind:`category`}});return[...n,...r]},Pp=e=>{Z(`${X.BLUE}=== 预览模式(不写入文件) ===${X.RESET}\n`);for(let t of e)Z(`${X.GREEN}--- ${t.output} ---${X.RESET}`),Z(`${X.YELLOW}源: ${t.sourceLabel}${X.RESET}`),Z(``),Z(t.content),Z(``)},Fp=e=>{let t=[e.commonSourcePath,e.agentSourcePath].filter(e=>e!==null),n=`类别 ${e.category}(${e.agentType})`;return t.length>0?`${n}: ${t.join(` + `)}`:n},Ip=e=>{if(e.length!==0){Q(`${X.RED}✗ 同一产物文件被多条规则合成且内容不一致:${X.RESET}`);for(let t of e){Q(` ${X.RED}${t.output}${X.RESET}`);for(let e of t.entries)Q(` - ${e.label}`);t.differingItems.length>0?Q(` 差异条目(flavor 差异,仅部分规则检出): ${X.YELLOW}${t.differingItems.join(`, `)}${X.RESET}`):Q(` ${X.YELLOW}条目集合一致:差异来自变体正文或独有段(agent.<type>.md)内容${X.RESET}`)}Q(``),Q(`${X.YELLOW}共享同一产物文件的规则合成内容必须一致(见 docs/issues/0008)${X.RESET}`),Q(`${X.YELLOW}IDE 差异化诉求请移至 CLAUDE.md 侧(<path>.claude.md 变体 / agent.claude.md 独有段)${X.RESET}`),process.exit(1)}},Lp=async(e,t)=>{Z(`${X.BLUE}=== 校验模式(比对产物与真源) ===${X.RESET}\n`);let n=[],r=0;for(let i of t){let t=await jp(e,i.output);if(t===null){n.push(`${i.output} (产物缺失)`);continue}if(i.kind===`root`){Mf(t)===i.content.trimEnd()?r+=1:n.push(`${i.output} (内容不一致)`);continue}Ff(t,i.content)?r+=1:n.push(`${i.output} (内容不一致)`)}if(n.length===0){Z(`${X.GREEN}✓ 所有产物与真源一致${X.RESET}(${r} 个文件)`);return}Z(`${X.RED}✗ 检测到 ${n.length} 处漂移:${X.RESET}`);for(let e of n)Z(` ${X.RED}${e}${X.RESET}`);Z(``),Z(`${X.YELLOW}请运行 lzi-agent-cli sync 重新生成产物${X.RESET}`),process.exit(1)},Rp=async(e,t)=>{let n=a(e,t.output);if(t.kind===`root`){let r=await jp(e,t.output),i=jf(r,t.content);await Bun.write(n,i),Z(`${X.GREEN} ✓${X.RESET} ${t.output}`);return}let r=await jp(e,t.output),i=Pf(r,t.content);await Bun.write(n,i),Z(`${X.GREEN} ✓${X.RESET} ${t.output}`)},zp=e=>{Z(`${X.BLUE}=== 共享提示词物化 ===${X.RESET}`);for(let t of e.results){if(Z(` ${t.subscription.category}/${t.subscription.namespace} ← ${t.subscription.name}`),t.status===`materialized`){Z(` ${X.GREEN}✓ 已物化 ${t.matchedCount} 个条目${X.RESET}`);continue}if(t.status===`clean`){Z(` ${X.GREEN}✓ 物化一致(${t.matchedCount} 个条目)${X.RESET}`);continue}if(t.status===`planned`){Z(` ${X.YELLOW}○ 将物化 ${t.matchedCount} 个条目(dry-run 不落盘)${X.RESET}`);continue}if(t.status===`drifted`){Z(` ${X.RED}✗ 物化漂移:${X.RESET}`);for(let e of t.drift)Z(` ${X.RED}${e}${X.RESET}`);continue}Z(` ${X.RED}✗ ${t.message??`物化失败`}${X.RESET}`)}Z(``)},Bp=async e=>{let t=await tf({agent:e.agent}),n=process.cwd(),r=await Zf(n,e.check?`check`:e.dryRun?`plan`:`write`);r.skipped||(zp(r),r.hasError&&(Q(`${X.RED}✗ 共享提示词物化失败(hub 定位或条目非法),已中止 sync${X.RESET}`),process.exit(1)),e.check&&r.hasDrift&&(Q(`${X.RED}✗ 共享条目物化漂移:hub 内容与本地物化目录不一致${X.RESET}`),Q(`${X.YELLOW}请运行 lzi-agent-cli sync 重建共享条目${X.RESET}`),process.exit(1)));let i=yf(t.placeholders),a=[],o=[];for(let e of t.agentTypes){let t=await Ap(e,n,i);a.push(...t);let r=await Df(e,n,i);o.push(...r)}let s=[...a.map(e=>({output:e.output,content:e.content,label:Mp(e),itemsSources:e.itemsSources})),...o.map(e=>({output:e.output,content:e.content,label:Fp(e),itemsSources:[]}))];Ip(Tp(s));let c=Np(a,o);if(e.check){await Lp(n,c);return}if(e.dryRun){Pp(c);return}Z(``),Z(`${X.BLUE}正在写入...${X.RESET}`);for(let e of c)await Rp(n,e);Z(`\n${X.GREEN}同步完成${X.RESET} (Agent: ${t.agentTypes.join(`, `)},共 ${c.length} 个文件)`)},Vp=Yl({dryRun:Vl().optional(),agent:G().optional()}),Hp=Zl({dryRun:Vl().optional(),force:Vl().optional(),check:Vl().optional(),agent:G().optional()});function Up(e){ht(e,{name:`init`,description:`创建 .lzi/ 目录和源文件骨架`,options:[{flags:`--dry-run`,description:`仅预览将创建的文件`},{flags:`--agent <v>`,description:`仅生成指定 Agent 的骨架(claude/trae/zcode),默认全套`}],schema:Vp,action:async e=>{await Qu({dryRun:!!e.dryRun,agent:e.agent})}}),ht(e,{name:`sync`,description:`合成根指令文件 + 分发类别配置,同步覆盖目标文件`,options:[{flags:`--dry-run`,description:`仅预览,不写入文件`},{flags:`--force`,description:`跳过覆盖确认`},{flags:`--check`,description:`仅校验:产物与真源不一致则退出码 1(CI 守门)`},{flags:`--agent <v>`,description:`目标 Agent 类型(单值/多值/auto),默认 auto`}],schema:Hp,action:async e=>{await Bp({dryRun:!!e.dryRun,force:!!e.force,check:!!e.check,agent:e.agent})}}),ht(e,{name:`status`,description:`显示当前 Agent 类型、源文件存在性、输出目标`,schema:Yl({}),action:async()=>{await Cp()}}),ht(e,{name:`optimize`,description:`只读分析 .lzi/ 源文件,输出 token 成本优化建议(不修改文件)`,schema:Yl({}),action:async()=>{await Od()}}),vp(e)}async function Wp(){let e=pt({name:`lzi-agent-cli`,description:`Longzai Intelligence Agent Tools CLI`,interaction:Fn,color:Pn});Up(e),await e.parseAsync(process.argv)}await Wp();export{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longzai-intelligence-agent-tools/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "Longzai Intelligence Agent Tools CLI",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"bin": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"clean": "lzi-dev-cli clean"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@longzai-intelligence-agent-tools/config": "0.0.
|
|
38
|
-
"@longzai-intelligence-agent-tools/core": "0.0.
|
|
37
|
+
"@longzai-intelligence-agent-tools/config": "0.0.12",
|
|
38
|
+
"@longzai-intelligence-agent-tools/core": "0.0.12",
|
|
39
39
|
"@longzai-intelligence-cli/core": "^0.0.8",
|
|
40
40
|
"@longzai-intelligence-cli/standard": "^0.0.8",
|
|
41
41
|
"@longzai-intelligence-shared-config/core": "^0.0.5",
|