Merge pull request #169 from yunyingk/codex/improve-update-feedback

Move enterprise workflows into domains
This commit is contained in:
yunyingk authored and GitHub committed 2026-09-22 15:11:24 +08:00
commit c6d0f3e82c
56 files changed
+2836 -2458

No files matched your search

+1 -1
View File
@@ -107,7 +107,7 @@ Recent commits use concise imperative subjects, often `Add ...` or `Refine ...`,
## Security & Configuration Tips
Never commit real enterprise credentials, Seal tokens, service logs, or local generated state. Use `enterprises/example.hose.json` or `enterprises/example.direct.json` as templates, then place real configs in `enterprises/local.json` or `~/.config/seal-use/enterprises` (with legacy fallback to `~/.config/seal-home/enterprises`). For auth or tenant changes, verify with `bun run probe` or `seal-use auth diagnose`.
Never commit real enterprise credentials, Seal tokens, service logs, or local generated state. Use `enterprises/example.hose.json` or `enterprises/example.seal.json` as templates, then place real configs in `enterprises/local.json` or `~/.config/seal-use/enterprises` (with legacy fallback to `~/.config/seal-home/enterprises`). For auth or tenant changes, verify with `bun run probe` or `seal-use auth diagnose`.
Credential files are written `0600`; a config placed by hand keeps the `0o644` default, so run `seal-use doctor` and act on its `credential_permissions` check before sharing a machine or a backup. See `SECURITY.md` for the trust model (local HTTP adapter, self-update, custom linters).
+18 -8
View File
@@ -9,9 +9,9 @@ Bun + TypeScript CLI and optional local service for pulling Seal enterprise appr
The first provider is Hose/合思: `key`, `password`, `corpId`, `staffId`, and an optional Hose domain. The provider exchanges those credentials for a Seal enterprise session, then the Seal domain tools can read and maintain approval rules, approval documents, and approval style preferences.
Seal-native enterprise pages can be added with a Seal Bearer token. The older `direct` source remains available for existing configs that already provide a Seal Bearer token.
Seal-native enterprise pages can be added with a Seal Bearer token.
An incoming Hose/合思 `thirdparty.html` assistance link can be imported directly; the CLI exchanges its temporary token through Seal SSO, verifies the tenant, and stores a short-lived local Seal session.
An incoming Hose/合思 `thirdparty.html` assistance link can be imported directly; the CLI exchanges its temporary token through Seal SSO, verifies the tenant, and stores the Hose web-session source (`closeToken` plus `staffId`). The Seal Bearer is runtime-only.
## Quick Install (Standalone Binary)
@@ -46,7 +46,7 @@ seal-use update # Future self-update directly from GitHub Release
For local development from source with Bun:
For an already-authenticated Seal-native source, use `seal-use corps add-seal` or copy `enterprises/example.seal.json`. Existing `direct` configs remain supported via `enterprises/example.direct.json`.
For an already-authenticated Seal-native source, use `seal-use corps add-seal-bearer` or copy `enterprises/example.seal.json`.
## Public Usage
@@ -79,21 +79,31 @@ Create a user-level Hose enterprise config that works from any directory:
```bash
mkdir -p ~/.config/seal-use/enterprises
seal-use corps add-hose --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}'
seal-use corps add-hose-persistent --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}'
seal-use auth diagnose --corp <corpId>
seal-use tools list
```
`corps add-hose` verifies by default before writing the config. It uses the Hose OpenAPI credential response to derive the corporation ID, then checks provisional auth, Seal SSO, and Seal `whoami`. Pass `"force":true` or `"verify":false` only when you intentionally want to write a config that may fail later.
`corps add-hose-persistent` verifies by default before writing the config. It uses the Hose OpenAPI credential response to derive the corporation ID, then checks provisional auth, Seal SSO, and Seal `whoami`. Pass `"force":true` or `"verify":false` only when you intentionally want to write a config that may fail later. The old `add-hose` spelling remains a compatibility alias.
Create a user-level Seal-native enterprise config from an already signed-in Seal Use page:
```bash
seal-use corps add-seal --json '{"sealUrl":"https://tenant.staging.sealai.cc","token":"seal-bearer-token"}'
seal-use corps add-seal-bearer --json '{"sealUrl":"https://tenant.staging.sealai.cc","token":"seal-bearer-token"}'
seal-use auth diagnose --corp tenant
```
`corps add-seal` verifies `/api/v1/auth/me` by default and writes the tenant slug, tenant ID, tenant name, and provider user ID into local config metadata. Pass `"force":true` or `"verify":false` only when writing an offline config intentionally.
`corps add-seal-bearer` verifies `/api/v1/auth/me` by default and writes the tenant slug, tenant ID, tenant name, and provider user ID into local config metadata. Pass `"force":true` or `"verify":false` only when writing an offline config intentionally. The old `add-seal` spelling remains a compatibility alias.
短期 Seal 配置会同时记录 `expiresIn`(秒数 TTL)和 `expiresAt`(UTC 秒精度,例如 `2026-09-22T05:30:00Z`);Hose 持久化配置则以 `source.type: "hose"` 和 `appKey/appSecurity` 表示,不写入这两个会话过期字段。
When the Agent receives a cURL copied from an authenticated Hose page, it first attempts to extract durable OpenAPI credentials. If that is not possible, it can import the normalized Hose web session and retain its `closeToken` plus `staffId`; Seal access is exchanged at runtime:
```bash
seal-use corps add-hose-web-session --json '{"baseUrl":"https://wx2.ekuaibao.com","corpId":"...","accessToken":"..."}'
```
The Hose `accessToken` is not a Seal Bearer Token and must not be passed to `add-seal-bearer` directly. `add-hose-web-session` stores it as a Hose `closeToken` together with the Hose `staffId`; Seal Bearer is obtained only as a runtime SSO session. It does not create or persist Hose OpenAPI credentials.
Import a Hose/合思 assistance link when you do not have OpenAPI app credentials:
@@ -101,7 +111,7 @@ Import a Hose/合思 assistance link when you do not have OpenAPI app credential
seal-use corps add-link "https://wx2.ekuaibao.com/web/thirdparty.html?accessToken=<temporary-token>&ekbCorpId=<corpId>&pageType=home" [--name "企业名称"]
```
The command accepts HTTPS links from the supported Hose domains, verifies the Seal tenant with `/api/v1/auth/me`, and writes a `seal` source with `provider: "hosecloud"`. The incoming token is never printed, but the resulting session is temporary and must be renewed after it expires. Use `--overwrite` to replace an existing config explicitly.
The command accepts HTTPS links from the supported Hose domains, verifies the Seal tenant with `/api/v1/auth/me`, and writes a Hose source with `provider: "hosecloud"`, `closeToken`, and `staffId`. The incoming token is never printed. Use `--overwrite` to replace an existing config explicitly.
To generate a Seal delegation link directly from the same incoming Hose link without saving a config:
+260 -230
View File
@@ -1,7 +1,7 @@
import{createRequire as ly0}from"node:module";var fy0=Object.create;var{getPrototypeOf:uy0,defineProperty:IT,getOwnPropertyNames:by0}=Object;var iy0=Object.prototype.hasOwnProperty;function ny0($){return this[$]}var cy0,py0,J6=($,Y,z)=>{var U=$!=null&&typeof $==="object";if(U){var Q=Y?cy0??=new WeakMap:py0??=new WeakMap,J=Q.get($);if(J)return J}z=$!=null?fy0(uy0($)):{};let I=Y||!$||!$.__esModule?IT(z,"default",{value:$,enumerable:!0}):z;for(let K of by0($))if(!iy0.call(I,K))IT(I,K,{get:ny0.bind($,K),enumerable:!0});if(U)Q.set($,I);return I};var E=($,Y)=>()=>(Y||$((Y={exports:{}}).exports,Y),Y.exports);var dy0=($)=>$;function my0($,Y){this[$]=dy0.bind(null,Y)}var D8=($,Y)=>{for(var z in Y)IT($,z,{get:Y[z],enumerable:!0,configurable:!0,set:my0.bind(Y,z)})};var m=($,Y)=>()=>($&&(Y=$($=0)),Y);var I0=ly0(import.meta.url);var oy0,rq,ry0,sy0,ay0,ty0,C0=($,Y)=>()=>(Y||$((Y={exports:{}}).exports,Y),Y.exports),Gr=($,Y)=>{let z={};for(var U in $)rq(z,U,{get:$[U],enumerable:!0});if(Y)rq(z,Symbol.toStringTag,{value:"Module"});return z},ey0=($,Y,z,U)=>{if(Y&&typeof Y==="object"||typeof Y==="function"){for(var Q=sy0(Y),J=0,I=Q.length,K;J<I;J++)if(K=Q[J],!ty0.call($,K)&&K!==z)rq($,K,{get:((G)=>Y[G]).bind(null,K),enumerable:!(U=ry0(Y,K))||U.enumerable})}return $},sq=($,Y,z)=>(z=$!=null?oy0(ay0($)):{},ey0(Y||!$||!$.__esModule?rq(z,"default",{value:$,enumerable:!0}):z,$));var KT=m(()=>{oy0=Object.create,rq=Object.defineProperty,ry0=Object.getOwnPropertyDescriptor,sy0=Object.getOwnPropertyNames,ay0=Object.getPrototypeOf,ty0=Object.prototype.hasOwnProperty});function Wr($){return typeof $==="string"&&Hr.has($.replace(/#$/,""))}function Xr($,Y){if(!("$schema"in $)||typeof $.$schema!=="string")return"2020-12";let z=$.$schema.replace(/#$/,"");if($k0.has(z))return"2020-12";if(Hr.has(z))return"2019-09";if(Yk0.has(z)||zk0.has(z))return"draft-7";throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${$.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${Y}`)}var $k0,Hr,Yk0,zk0;var GT=m(()=>{$k0=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),Hr=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),Yk0=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),zk0=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"])});function W0($,Y,z){function U(K,G){if(!K._zod)Object.defineProperty(K,"_zod",{value:{def:G,constr:I,traits:new Set},enumerable:!1});if(K._zod.traits.has($))return;K._zod.traits.add($),Y(K,G);let H=I.prototype,W=Object.keys(H);for(let X=0;X<W.length;X++){let Z=W[X];if(!(Z in K))K[Z]=H[Z].bind(K)}}let Q=z?.Parent??Object;class J extends Q{}Object.defineProperty(J,"name",{value:$});function I(K){var G;let H=z?.Parent?new J:this;U(H,K),(G=H._zod).deferred??(G.deferred=[]);for(let W of H._zod.deferred)W();return H}return Object.defineProperty(I,"init",{value:U}),Object.defineProperty(I,Symbol.hasInstance,{value:(K)=>{if(z?.Parent&&K instanceof z.Parent)return!0;return K?._zod?.traits?.has($)}}),Object.defineProperty(I,"name",{value:$}),I}function a4($){if($)Object.assign(jY,$);return jY}var Zr,sK,HT,n5,TY,jY;var EY=m(()=>{sK=Object.freeze({status:"aborted"});HT=Symbol("zod_brand");n5=class n5 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};TY=class TY extends Error{constructor($){super(`Encountered unidirectional transform during encode: ${$}`);this.name="ZodEncodeError"}};(Zr=globalThis).__zod_globalConfig??(Zr.__zod_globalConfig={});jY=globalThis.__zod_globalConfig});var y0={};D8(y0,{unwrapMessage:()=>aK,uint8ArrayToHex:()=>Ek0,uint8ArrayToBase64url:()=>jk0,uint8ArrayToBase64:()=>Lr,stringifyPrimitive:()=>v0,slugify:()=>ZT,shallowClone:()=>VT,safeExtend:()=>Mk0,required:()=>Ak0,randomString:()=>Zk0,propertyKeyTypes:()=>$G,promiseAllObject:()=>Xk0,primitiveTypes:()=>LT,prefixIssues:()=>f8,pick:()=>Fk0,partial:()=>Dk0,parsedType:()=>S0,optionalKeys:()=>FT,omit:()=>Ok0,objectClone:()=>Gk0,numKeys:()=>qk0,nullish:()=>G7,normalizeParams:()=>u0,mergeDefs:()=>p9,merge:()=>Nk0,jsonStringifyReplacer:()=>dU,joinValues:()=>M0,issue:()=>lU,isPlainObject:()=>W7,isObject:()=>CY,hexToUint8Array:()=>Tk0,getSizableOrigin:()=>YG,getParsedType:()=>Vk0,getLengthableOrigin:()=>zG,getEnumValues:()=>tK,getElementAtPath:()=>Wk0,floatSafeRemainder:()=>XT,finalizeIssue:()=>B8,extend:()=>wk0,explicitlyAborted:()=>MT,escapeRegex:()=>A$,esc:()=>aq,defineLazy:()=>E1,createTransparentProxy:()=>Lk0,cloneDef:()=>Hk0,clone:()=>A8,cleanRegex:()=>eK,cleanEnum:()=>Bk0,captureStackTrace:()=>tq,cached:()=>mU,base64urlToUint8Array:()=>Pk0,base64ToUint8Array:()=>Vr,assignProp:()=>H7,assertNotEqual:()=>Qk0,assertNever:()=>Ik0,assertIs:()=>Jk0,assertEqual:()=>Uk0,assert:()=>Kk0,allowsEval:()=>qT,aborted:()=>X7,NUMBER_FORMAT_RANGES:()=>OT,Class:()=>FrLine truncated
`)}var Or=($,Y)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:Y,enumerable:!1}),$.message=JSON.stringify(Y,dU,2),Object.defineProperty($,"toString",{value:()=>$.message,enumerable:!1})},UG,u8;var AT=m(()=>{EY();Y1();UG=W0("$ZodError",Or),u8=W0("$ZodError",Or,{Parent:Error})});var oU=($)=>(Y,z,U,Q)=>{let J=U?{...U,async:!1}:{async:!1},I=Y._zod.run({value:z,issues:[]},J);if(I instanceof Promise)throw new n5;if(I.issues.length){let K=new(Q?.Err??$)(I.issues.map((G)=>B8(G,J,a4())));throw tq(K,Q?.callee),K}return I.value},eq,rU=($)=>async(Y,z,U,Q)=>{let J=U?{...U,async:!0}:{async:!0},I=Y._zod.run({value:z,issues:[]},J);if(I instanceof Promise)I=await I;if(I.issues.length){let K=new(Q?.Err??$)(I.issues.map((G)=>B8(G,J,a4())));throw tq(K,Q?.callee),K}return I.value},$V,sU=($)=>(Y,z,U)=>{let Q=U?{...U,async:!1}:{async:!1},J=Y._zod.run({value:z,issues:[]},Q);if(J instanceof Promise)throw new n5;return J.issues.length?{success:!1,error:new($??UG)(J.issues.map((I)=>B8(I,Q,a4())))}:{success:!0,data:J.value}},BT,aU=($)=>async(Y,z,U)=>{let Q=U?{...U,async:!0}:{async:!0},J=Y._zod.run({value:z,issues:[]},Q);if(J instanceof Promise)J=await J;return J.issues.length?{success:!1,error:new $(J.issues.map((I)=>B8(I,Q,a4())))}:{success:!0,data:J.value}},PT,YV=($)=>(Y,z,U)=>{let Q=U?{...U,direction:"backward"}:{direction:"backward"};return oU($)(Y,z,Q)},Rk0,zV=($)=>(Y,z,U)=>{return oU($)(Y,z,U)},_k0,UV=($)=>async(Y,z,U)=>{let Q=U?{...U,direction:"backward"}:{direction:"backward"};return rU($)(Y,z,Q)},vk0,QV=($)=>async(Y,z,U)=>{return rU($)(Y,z,U)},hk0,JV=($)=>(Y,z,U)=>{let Q=U?{...U,direction:"backward"}:{direction:"backward"};return sU($)(Y,z,Q)},Sk0,IV=($)=>(Y,z,U)=>{return sU($)(Y,z,U)},gk0,KV=($)=>async(Y,z,U)=>{let Q=U?{...U,direction:"backward"}:{direction:"backward"};return aU($)(Y,z,Q)},yk0,GV=($)=>async(Y,z,U)=>{return aU($)(Y,z,U)},kk0;var jT=m(()=>{EY();AT();Y1();eq=oU(u8),$V=rU(u8),BT=sU(u8),PT=aU(u8),Rk0=YV(u8),_k0=zV(u8),vk0=UV(u8),hk0=QV(u8),Sk0=JV(u8),gk0=IV(u8),yk0=KV(u8),kk0=GV(u8)});var z$={};D8(z$,{xid:()=>RT,uuid7:()=>bk0,uuid6:()=>uk0,uuid4:()=>fk0,uuid:()=>RY,uppercase:()=>$E,unicodeEmail:()=>Mr,undefined:()=>tT,ulid:()=>CT,time:()=>dT,string:()=>lT,sha512_hex:()=>Kx0,sha512_base64url:()=>Hx0,sha512_base64:()=>Gx0,sha384_hex:()=>Qx0,sha384_base64url:()=>Ix0,sha384_base64:()=>Jx0,sha256_hex:()=>Yx0,sha256_base64url:()=>Ux0,sha256_base64:()=>zx0,sha1_hex:()=>tk0,sha1_base64url:()=>$x0,sha1_base64:()=>ek0,rfc5322Email:()=>nk0,number:()=>IG,null:()=>aT,nanoid:()=>vT,md5_hex:()=>rk0,md5_base64url:()=>ak0,md5_base64:()=>sk0,mac:()=>fT,lowercase:()=>eT,ksuid:()=>_T,ipv6:()=>xT,ipv4:()=>kT,integer:()=>rT,idnEmail:()=>ck0,httpProtocol:()=>nT,html5Email:()=>ik0,hostname:()=>mk0,hex:()=>ok0,guid:()=>ST,extendedDuration:()=>xk0,emoji:()=>yT,email:()=>gT,e164:()=>cT,duration:()=>hT,domain:()=>lk0,datetime:()=>mT,date:()=>pT,cuid2:()=>ET,cuid:()=>TT,cidrv6:()=>bT,cidrv4:()=>uT,browserEmail:()=>pk0,boolean:()=>sT,bigint:()=>oT,base64url:()=>HV,base64:()=>iT});function yT(){return new RegExp(dk0,"u")}function Dr($){return typeof $.precision==="number"?$.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":$.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${$.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function dT($){return new RegExp(`^${Dr($)}$`)}function mT($){let Y=Dr({precision:$.precision}),z=["Z"];if($.local)z.push("");if($.offset)z.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let U=`${Y}(?:${z.join("|")})`;return new RegExp(`^${Nr}T(?:${U})$`)}function KG($,Y){return new RegExp(`^[A-Za-z0-9+/]{${$}}${Y}$`)}function GG($){return new RegExp(`^[A-Za-z0-9_-]{${$}}$`)}var TT,ET,CT,RT,_T,vT,hT,xk0,ST,RY=($)=>{if(!$)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${$}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},fk0,uk0,bk0,gT,ik0,nk0,Mr,ck0,pk0,dk0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",kT,xT,fT=($)=>{let Y=A$($??":");return new RegExp(`^(?:[0-9A-F]{2}${Y}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${Y}){5}[0-9a-f]{2}$`)},uT,bT,iT,HV,mk0,lk0,nT,cT,Nr="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",pT,lT=($)=>{let Y=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${Y}$`)},oT,rT,IG,sT,aT,tT,eT,$E,ok0,rk0,sk0,ak0,tk0,ek0,$x0,Yx0,zx0,Ux0,Qx0,Jx0,Ix0,Kx0,Gx0,Hx0;var WV=m(()=>{Y1();TT=/^[cC][0-9a-z]{6,}$/,ET=/^[0-9a-z]+$/,CT=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,RT=/^[0-9a-vA-V]{20}$/,_T=/^[A-Za-z0-9]{27}$/,vT=/^[a-zA-Z0-9_-]{21}$/,hT=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\dLine truncated
`).filter((J)=>J),U=Math.min(...z.map((J)=>J.length-J.trimStart().length)),Q=z.map((J)=>J.slice(U)).map((J)=>" ".repeat(this.indent*2)+J);for(let J of Q)this.content.push(J)}compile(){let $=Function,Y=this?.args,U=[...(this?.content??[""]).map((Q)=>` ${Q}`)];return new $(...Y,U.join(`
`))}}var ME;var NE=m(()=>{ME={major:4,minor:4,patch:3}});function nE($){if($==="")return!0;if(/\s/.test($))return!1;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}function ur($){if(!HV.test($))return!1;let Y=$.replace(/[-_]/g,(U)=>U==="-"?"+":"/"),z=Y.padEnd(Math.ceil(Y.length/4)*4,"=");return nE(z)}function br($,Y=null){try{let z=$.split(".");if(z.length!==3)return!1;let[U]=z;if(!U)return!1;let Q=JSON.parse(atob(U));if("typ"in Q&&Q?.typ!=="JWT")return!1;if(!Q.alg)return!1;if(Y&&(!("alg"in Q)||Q.alg!==Y))return!1;return!0}catch{return!1}}function jr($,Y,z){if($.issues.length)Y.issues.push(...f8(z,$.issues));Y.value[z]=$.value}function wV($,Y,z,U,Q,J){let I=z in U;if($.issues.length){if(Q&&J&&!I)return;Y.issues.push(...f8(z,$.issues))}if(!I&&!Q){if(!$.issues.length)Y.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[z]});return}if($.value===void 0){if(I)Y.value[z]=void 0}else Y.value[z]=$.value}function ir($){let Y=Object.keys($.shape);for(let U of Y)if(!$.shape?.[U]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${U}": expected a Zod schema`);let z=FT($.shape);return{...$,keys:Y,keySet:new Set(Y),numKeys:Y.length,optionalKeys:new Set(z)}}function nr($,Y,z,U,Q,J){let I=[],K=Q.keySet,G=Q.catchall._zod,H=G.def.type,W=G.optin==="optional",X=G.optout==="optional";for(let Z in Y){if(Z==="__proto__")continue;if(K.has(Z))continue;if(H==="never"){I.push(Z);continue}let q=G.run({value:Y[Z],issues:[]},U);if(q instanceof Promise)$.push(q.then((V)=>wV(V,z,Z,Y,W,X)));else wV(q,z,Z,Y,W,X)}if(I.length)z.issues.push({code:"unrecognized_keys",keys:I,input:Y,inst:J});if(!$.length)return z;return Promise.all($).then(()=>{return z})}function Tr($,Y,z,U){for(let J of $)if(J.issues.length===0)return Y.value=J.value,Y;let Q=$.filter((J)=>!X7(J));if(Q.length===1)return Y.value=Q[0].value,Q[0];return Y.issues.push({code:"invalid_union",input:Y.value,inst:z,errors:$.map((J)=>J.issues.map((I)=>B8(I,U,a4())))}),Y}function Er($,Y,z,U){let Q=$.filter((J)=>J.issues.length===0);if(Q.length===1)return Y.value=Q[0].value,Y;if(Q.length===0)Y.issues.push({code:"invalid_union",input:Y.value,inst:z,errors:$.map((J)=>J.issues.map((I)=>B8(I,U,a4())))});else Y.issues.push({code:"invalid_union",input:Y.value,inst:z,errors:[],inclusive:!1});return Y}function DE($,Y){if($===Y)return{valid:!0,data:$};if($ instanceof Date&&Y instanceof Date&&+$===+Y)return{valid:!0,data:$};if(W7($)&&W7(Y)){let z=Object.keys(Y),U=Object.keys($).filter((J)=>z.indexOf(J)!==-1),Q={...$,...Y};for(let J of U){let I=DE($[J],Y[J]);if(!I.valid)return{valid:!1,mergeErrorPath:[J,...I.mergeErrorPath]};Q[J]=I.data}return{valid:!0,data:Q}}if(Array.isArray($)&&Array.isArray(Y)){if($.length!==Y.length)return{valid:!1,mergeErrorPath:[]};let z=[];for(let U=0;U<$.length;U++){let Q=$[U],J=Y[U],I=DE(Q,J);if(!I.valid)return{valid:!1,mergeErrorPath:[U,...I.mergeErrorPath]};z.push(I.data)}return{valid:!0,data:z}}return{valid:!1,mergeErrorPath:[]}}function Cr($,Y,z){let U=new Map,Q;for(let K of Y.issues)if(K.code==="unrecognized_keys"){Q??(Q=K);for(let G of K.keys){if(!U.has(G))U.set(G,{});U.get(G).l=!0}}else $.issues.push(K);for(let K of z.issues)if(K.code==="unrecognized_keys")for(let G of K.keys){if(!U.has(G))U.set(G,{});U.get(G).r=!0}else $.issues.push(K);let J=[...U].filter(([,K])=>K.l&&K.r).map(([K])=>K);if(J.length&&Q)$.issues.push({...Q,keys:J});if(X7($))return $;let I=DE(Y.value,z.value);if(!I.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(I.mergeErrorPath)}`);return $.value=I.data,$}function Rr($,Y){for(let z=$.length-1;z>=0;z--)if($[z]._zod[Y]!=="optional")return z+1;return 0}function _r($,Y,z){if($.issues.length)Y.issues.push(...f8(z,$.issues));Y.value[z]=$.value}function vr($,Y,z,U,Q){for(let J=0;J<z.length;J++){let I=$[J],K=J<U.length;if(I.issues.length){if(!K&&J>=Q){Y.value.length=J;break}Y.issues.push(...f8(J,I.issues))}Y.value[J]=I.value}for(let J=Y.value.length-1;J>=U.length;J--)if(z[J]._zod.optout==="optional"&&Y.value[J]===void 0)Y.value.length=J;else break;return Y}function hr($,Y,z,U,Q,J,I){if($.issues.length)if($G.has(typeof U))z.issues.push(...f8(U,$.issues));else z.issues.push({code:"invalid_key",origin:"map",input:Q,inst:J,issues:$.issues.map((K)=>B8(K,I,a4()))});if(Y.issues.length)if($G.has(typeof U))z.issues.push(...f8(U,Y.issues));else z.issues.push({origin:"map",code:"invalid_element",input:Q,inst:J,key:U,issues:Y.issues.map((K)=>B8(K,I,a4()))});z.value.set($.value,Y.value)}function Sr($,Y){if($.issues.length)Y.issues.push(...$.issues);Y.value.add($.value)}function gr($,Y){if(Y===void 0&&($.issues.length||$.fallback))return{issues:[],value:void 0};return $}function yr($,Y){if($.value===void 0)$.value=Y.defaultValue;return $}function kr($,Y){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:Y});return $}function LV($,Y,z){if($.issues.length)return $.aborted=!0,$;return Y._zod.run({value:$.value,issues:$.issues,fa Line truncated
import{createRequire as Ak0}from"node:module";var qk0=Object.create;var{getPrototypeOf:Vk0,defineProperty:Oj,getOwnPropertyNames:Lk0}=Object;var wk0=Object.prototype.hasOwnProperty;function Fk0($){return this[$]}var Mk0,Ok0,I6=($,U,Y)=>{var z=$!=null&&typeof $==="object";if(z){var I=U?Mk0??=new WeakMap:Ok0??=new WeakMap,Q=I.get($);if(Q)return Q}Y=$!=null?qk0(Vk0($)):{};let J=U||!$||!$.__esModule?Oj(Y,"default",{value:$,enumerable:!0}):Y;for(let K of Lk0($))if(!wk0.call(J,K))Oj(J,K,{get:Fk0.bind($,K),enumerable:!0});if(z)I.set($,J);return J};var E=($,U)=>()=>(U||$((U={exports:{}}).exports,U),U.exports);var Nk0=($)=>$;function Dk0($,U){this[$]=Nk0.bind(null,U)}var T8=($,U)=>{for(var Y in U)Oj($,Y,{get:U[Y],enumerable:!0,configurable:!0,set:Dk0.bind(U,Y)})};var m=($,U)=>()=>($&&(U=$($=0)),U);var J0=Ak0(import.meta.url);var Bk0,UV,Pk0,Tk0,jk0,Ek0,E0=($,U)=>()=>(U||$((U={exports:{}}).exports,U),U.exports),Nr=($,U)=>{let Y={};for(var z in $)UV(Y,z,{get:$[z],enumerable:!0});if(U)UV(Y,Symbol.toStringTag,{value:"Module"});return Y},Ck0=($,U,Y,z)=>{if(U&&typeof U==="object"||typeof U==="function"){for(var I=Tk0(U),Q=0,J=I.length,K;Q<J;Q++)if(K=I[Q],!Ek0.call($,K)&&K!==Y)UV($,K,{get:((G)=>U[G]).bind(null,K),enumerable:!(z=Pk0(U,K))||z.enumerable})}return $},YV=($,U,Y)=>(Y=$!=null?Bk0(jk0($)):{},Ck0(U||!$||!$.__esModule?UV(Y,"default",{value:$,enumerable:!0}):Y,$));var Nj=m(()=>{Bk0=Object.create,UV=Object.defineProperty,Pk0=Object.getOwnPropertyDescriptor,Tk0=Object.getOwnPropertyNames,jk0=Object.getPrototypeOf,Ek0=Object.prototype.hasOwnProperty});function Ar($){return typeof $==="string"&&Dr.has($.replace(/#$/,""))}function Br($,U){if(!("$schema"in $)||typeof $.$schema!=="string")return"2020-12";let Y=$.$schema.replace(/#$/,"");if(Rk0.has(Y))return"2020-12";if(Dr.has(Y))return"2019-09";if(_k0.has(Y)||vk0.has(Y))return"draft-7";throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${$.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${U}`)}var Rk0,Dr,_k0,vk0;var Dj=m(()=>{Rk0=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),Dr=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),_k0=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),vk0=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"])});function H0($,U,Y){function z(K,G){if(!K._zod)Object.defineProperty(K,"_zod",{value:{def:G,constr:J,traits:new Set},enumerable:!1});if(K._zod.traits.has($))return;K._zod.traits.add($),U(K,G);let H=J.prototype,W=Object.keys(H);for(let X=0;X<W.length;X++){let Z=W[X];if(!(Z in K))K[Z]=H[Z].bind(K)}}let I=Y?.Parent??Object;class Q extends I{}Object.defineProperty(Q,"name",{value:$});function J(K){var G;let H=Y?.Parent?new Q:this;z(H,K),(G=H._zod).deferred??(G.deferred=[]);for(let W of H._zod.deferred)W();return H}return Object.defineProperty(J,"init",{value:z}),Object.defineProperty(J,Symbol.hasInstance,{value:(K)=>{if(Y?.Parent&&K instanceof Y.Parent)return!0;return K?._zod?.traits?.has($)}}),Object.defineProperty(J,"name",{value:$}),J}function s4($){if($)Object.assign(TU,$);return TU}var Pr,aK,Aj,d5,jU,TU;var EU=m(()=>{aK=Object.freeze({status:"aborted"});Aj=Symbol("zod_brand");d5=class d5 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};jU=class jU extends Error{constructor($){super(`Encountered unidirectional transform during encode: ${$}`);this.name="ZodEncodeError"}};(Pr=globalThis).__zod_globalConfig??(Pr.__zod_globalConfig={});TU=globalThis.__zod_globalConfig});var k0={};T8(k0,{unwrapMessage:()=>tK,uint8ArrayToHex:()=>Yx0,uint8ArrayToBase64url:()=>$x0,uint8ArrayToBase64:()=>Er,stringifyPrimitive:()=>_0,slugify:()=>Tj,shallowClone:()=>Ej,safeExtend:()=>ok0,required:()=>ak0,randomString:()=>ik0,propertyKeyTypes:()=>UG,promiseAllObject:()=>bk0,primitiveTypes:()=>Cj,prefixIssues:()=>b8,pick:()=>pk0,partial:()=>sk0,parsedType:()=>S0,optionalKeys:()=>Rj,omit:()=>mk0,objectClone:()=>xk0,numKeys:()=>nk0,nullish:()=>W7,normalizeParams:()=>f0,mergeDefs:()=>l9,merge:()=>rk0,jsonStringifyReplacer:()=>mz,joinValues:()=>M0,issue:()=>oz,isPlainObject:()=>Z7,isObject:()=>CU,hexToUint8Array:()=>Ux0,getSizableOrigin:()=>YG,getParsedType:()=>ck0,getLengthableOrigin:()=>zG,getEnumValues:()=>eK,getElementAtPath:()=>uk0,floatSafeRemainder:()=>Pj,finalizeIssue:()=>E8,extend:()=>lk0,explicitlyAborted:()=>hj,escapeRegex:()=>B$,esc:()=>zV,defineLazy:()=>E1,createTransparentProxy:()=>dk0,cloneDef:()=>fk0,clone:()=>j8,cleanRegex:()=>$G,cleanEnum:()=>tk0,captureStackTrace:()=>IV,cached:()=>lz,base64urlToUint8Array:()=>ek0,base64ToUint8Array:()=>jr,assignProp:()=>X7,assertNotEqual:()=>Sk0,assertNever:()=>yk0,assertIs:()=>gk0,assertEqual:()=>hk0,assert:()=>kk0,allowsEval:()=>jj,aborted:()=>q7,NUMBER_FORMAT_RANGES:()=>_j,Class:()=>CrLine truncated
`)}var Rr=($,U)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:U,enumerable:!1}),$.message=JSON.stringify(U,mz,2),Object.defineProperty($,"toString",{value:()=>$.message,enumerable:!1})},IG,i8;var yj=m(()=>{EU();$1();IG=H0("$ZodError",Rr),i8=H0("$ZodError",Rr,{Parent:Error})});var rz=($)=>(U,Y,z,I)=>{let Q=z?{...z,async:!1}:{async:!1},J=U._zod.run({value:Y,issues:[]},Q);if(J instanceof Promise)throw new d5;if(J.issues.length){let K=new(I?.Err??$)(J.issues.map((G)=>E8(G,Q,s4())));throw IV(K,I?.callee),K}return J.value},QV,sz=($)=>async(U,Y,z,I)=>{let Q=z?{...z,async:!0}:{async:!0},J=U._zod.run({value:Y,issues:[]},Q);if(J instanceof Promise)J=await J;if(J.issues.length){let K=new(I?.Err??$)(J.issues.map((G)=>E8(G,Q,s4())));throw IV(K,I?.callee),K}return J.value},JV,az=($)=>(U,Y,z)=>{let I=z?{...z,async:!1}:{async:!1},Q=U._zod.run({value:Y,issues:[]},I);if(Q instanceof Promise)throw new d5;return Q.issues.length?{success:!1,error:new($??IG)(Q.issues.map((J)=>E8(J,I,s4())))}:{success:!0,data:Q.value}},kj,tz=($)=>async(U,Y,z)=>{let I=z?{...z,async:!0}:{async:!0},Q=U._zod.run({value:Y,issues:[]},I);if(Q instanceof Promise)Q=await Q;return Q.issues.length?{success:!1,error:new $(Q.issues.map((J)=>E8(J,I,s4())))}:{success:!0,data:Q.value}},xj,KV=($)=>(U,Y,z)=>{let I=z?{...z,direction:"backward"}:{direction:"backward"};return rz($)(U,Y,I)},Ix0,GV=($)=>(U,Y,z)=>{return rz($)(U,Y,z)},Qx0,HV=($)=>async(U,Y,z)=>{let I=z?{...z,direction:"backward"}:{direction:"backward"};return sz($)(U,Y,I)},Jx0,WV=($)=>async(U,Y,z)=>{return sz($)(U,Y,z)},Kx0,XV=($)=>(U,Y,z)=>{let I=z?{...z,direction:"backward"}:{direction:"backward"};return az($)(U,Y,I)},Gx0,ZV=($)=>(U,Y,z)=>{return az($)(U,Y,z)},Hx0,qV=($)=>async(U,Y,z)=>{let I=z?{...z,direction:"backward"}:{direction:"backward"};return tz($)(U,Y,I)},Wx0,VV=($)=>async(U,Y,z)=>{return tz($)(U,Y,z)},Xx0;var fj=m(()=>{EU();yj();$1();QV=rz(i8),JV=sz(i8),kj=az(i8),xj=tz(i8),Ix0=KV(i8),Qx0=GV(i8),Jx0=HV(i8),Kx0=WV(i8),Gx0=XV(i8),Hx0=ZV(i8),Wx0=qV(i8),Xx0=VV(i8)});var z$={};T8(z$,{xid:()=>nj,uuid7:()=>Lx0,uuid6:()=>Vx0,uuid4:()=>qx0,uuid:()=>RU,uppercase:()=>qE,unicodeEmail:()=>vr,undefined:()=>XE,ulid:()=>ij,time:()=>IE,string:()=>JE,sha512_hex:()=>kx0,sha512_base64url:()=>fx0,sha512_base64:()=>xx0,sha384_hex:()=>Sx0,sha384_base64url:()=>yx0,sha384_base64:()=>gx0,sha256_hex:()=>_x0,sha256_base64url:()=>hx0,sha256_base64:()=>vx0,sha1_hex:()=>Ex0,sha1_base64url:()=>Rx0,sha1_base64:()=>Cx0,rfc5322Email:()=>Fx0,number:()=>KG,null:()=>WE,nanoid:()=>dj,md5_hex:()=>Px0,md5_base64url:()=>jx0,md5_base64:()=>Tx0,mac:()=>aj,lowercase:()=>ZE,ksuid:()=>cj,ipv6:()=>sj,ipv4:()=>rj,integer:()=>GE,idnEmail:()=>Mx0,httpProtocol:()=>UE,html5Email:()=>wx0,hostname:()=>Dx0,hex:()=>Bx0,guid:()=>mj,extendedDuration:()=>Zx0,emoji:()=>oj,email:()=>lj,e164:()=>YE,duration:()=>pj,domain:()=>Ax0,datetime:()=>QE,date:()=>zE,cuid2:()=>bj,cuid:()=>uj,cidrv6:()=>ej,cidrv4:()=>tj,browserEmail:()=>Ox0,boolean:()=>HE,bigint:()=>KE,base64url:()=>LV,base64:()=>$E});function oj(){return new RegExp(Nx0,"u")}function Sr($){return typeof $.precision==="number"?$.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":$.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${$.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function IE($){return new RegExp(`^${Sr($)}$`)}function QE($){let U=Sr({precision:$.precision}),Y=["Z"];if($.local)Y.push("");if($.offset)Y.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let z=`${U}(?:${Y.join("|")})`;return new RegExp(`^${hr}T(?:${z})$`)}function GG($,U){return new RegExp(`^[A-Za-z0-9+/]{${$}}${U}$`)}function HG($){return new RegExp(`^[A-Za-z0-9_-]{${$}}$`)}var uj,bj,ij,nj,cj,dj,pj,Zx0,mj,RU=($)=>{if(!$)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${$}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},qx0,Vx0,Lx0,lj,wx0,Fx0,vr,Mx0,Ox0,Nx0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",rj,sj,aj=($)=>{let U=B$($??":");return new RegExp(`^(?:[0-9A-F]{2}${U}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${U}){5}[0-9a-f]{2}$`)},tj,ej,$E,LV,Dx0,Ax0,UE,YE,hr="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",zE,JE=($)=>{let U=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${U}$`)},KE,GE,KG,HE,WE,XE,ZE,qE,Bx0,Px0,Tx0,jx0,Ex0,Cx0,Rx0,_x0,vx0,hx0,Sx0,gx0,yx0,kx0,xx0,fx0;var wV=m(()=>{$1();uj=/^[cC][0-9a-z]{6,}$/,bj=/^[0-9a-z]+$/,ij=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,nj=/^[0-9a-vA-V]{20}$/,cj=/^[A-Za-z0-9]{27}$/,dj=/^[a-zA-Z0-9_-]{21}$/,pj=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\dLine truncated
`).filter((Q)=>Q),z=Math.min(...Y.map((Q)=>Q.length-Q.trimStart().length)),I=Y.map((Q)=>Q.slice(z)).map((Q)=>" ".repeat(this.indent*2)+Q);for(let Q of I)this.content.push(Q)}compile(){let $=Function,U=this?.args,z=[...(this?.content??[""]).map((I)=>` ${I}`)];return new $(...U,z.join(`
`))}}var hE;var SE=m(()=>{hE={major:4,minor:4,patch:3}});function UC($){if($==="")return!0;if(/\s/.test($))return!1;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}function ar($){if(!LV.test($))return!1;let U=$.replace(/[-_]/g,(z)=>z==="-"?"+":"/"),Y=U.padEnd(Math.ceil(U.length/4)*4,"=");return UC(Y)}function tr($,U=null){try{let Y=$.split(".");if(Y.length!==3)return!1;let[z]=Y;if(!z)return!1;let I=JSON.parse(atob(z));if("typ"in I&&I?.typ!=="JWT")return!1;if(!I.alg)return!1;if(U&&(!("alg"in I)||I.alg!==U))return!1;return!0}catch{return!1}}function xr($,U,Y){if($.issues.length)U.issues.push(...b8(Y,$.issues));U.value[Y]=$.value}function PV($,U,Y,z,I,Q){let J=Y in z;if($.issues.length){if(I&&Q&&!J)return;U.issues.push(...b8(Y,$.issues))}if(!J&&!I){if(!$.issues.length)U.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[Y]});return}if($.value===void 0){if(J)U.value[Y]=void 0}else U.value[Y]=$.value}function er($){let U=Object.keys($.shape);for(let z of U)if(!$.shape?.[z]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${z}": expected a Zod schema`);let Y=Rj($.shape);return{...$,keys:U,keySet:new Set(U),numKeys:U.length,optionalKeys:new Set(Y)}}function $s($,U,Y,z,I,Q){let J=[],K=I.keySet,G=I.catchall._zod,H=G.def.type,W=G.optin==="optional",X=G.optout==="optional";for(let Z in U){if(Z==="__proto__")continue;if(K.has(Z))continue;if(H==="never"){J.push(Z);continue}let q=G.run({value:U[Z],issues:[]},z);if(q instanceof Promise)$.push(q.then((V)=>PV(V,Y,Z,U,W,X)));else PV(q,Y,Z,U,W,X)}if(J.length)Y.issues.push({code:"unrecognized_keys",keys:J,input:U,inst:Q});if(!$.length)return Y;return Promise.all($).then(()=>{return Y})}function fr($,U,Y,z){for(let Q of $)if(Q.issues.length===0)return U.value=Q.value,U;let I=$.filter((Q)=>!q7(Q));if(I.length===1)return U.value=I[0].value,I[0];return U.issues.push({code:"invalid_union",input:U.value,inst:Y,errors:$.map((Q)=>Q.issues.map((J)=>E8(J,z,s4())))}),U}function ur($,U,Y,z){let I=$.filter((Q)=>Q.issues.length===0);if(I.length===1)return U.value=I[0].value,U;if(I.length===0)U.issues.push({code:"invalid_union",input:U.value,inst:Y,errors:$.map((Q)=>Q.issues.map((J)=>E8(J,z,s4())))});else U.issues.push({code:"invalid_union",input:U.value,inst:Y,errors:[],inclusive:!1});return U}function gE($,U){if($===U)return{valid:!0,data:$};if($ instanceof Date&&U instanceof Date&&+$===+U)return{valid:!0,data:$};if(Z7($)&&Z7(U)){let Y=Object.keys(U),z=Object.keys($).filter((Q)=>Y.indexOf(Q)!==-1),I={...$,...U};for(let Q of z){let J=gE($[Q],U[Q]);if(!J.valid)return{valid:!1,mergeErrorPath:[Q,...J.mergeErrorPath]};I[Q]=J.data}return{valid:!0,data:I}}if(Array.isArray($)&&Array.isArray(U)){if($.length!==U.length)return{valid:!1,mergeErrorPath:[]};let Y=[];for(let z=0;z<$.length;z++){let I=$[z],Q=U[z],J=gE(I,Q);if(!J.valid)return{valid:!1,mergeErrorPath:[z,...J.mergeErrorPath]};Y.push(J.data)}return{valid:!0,data:Y}}return{valid:!1,mergeErrorPath:[]}}function br($,U,Y){let z=new Map,I;for(let K of U.issues)if(K.code==="unrecognized_keys"){I??(I=K);for(let G of K.keys){if(!z.has(G))z.set(G,{});z.get(G).l=!0}}else $.issues.push(K);for(let K of Y.issues)if(K.code==="unrecognized_keys")for(let G of K.keys){if(!z.has(G))z.set(G,{});z.get(G).r=!0}else $.issues.push(K);let Q=[...z].filter(([,K])=>K.l&&K.r).map(([K])=>K);if(Q.length&&I)$.issues.push({...I,keys:Q});if(q7($))return $;let J=gE(U.value,Y.value);if(!J.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(J.mergeErrorPath)}`);return $.value=J.data,$}function ir($,U){for(let Y=$.length-1;Y>=0;Y--)if($[Y]._zod[U]!=="optional")return Y+1;return 0}function nr($,U,Y){if($.issues.length)U.issues.push(...b8(Y,$.issues));U.value[Y]=$.value}function cr($,U,Y,z,I){for(let Q=0;Q<Y.length;Q++){let J=$[Q],K=Q<z.length;if(J.issues.length){if(!K&&Q>=I){U.value.length=Q;break}U.issues.push(...b8(Q,J.issues))}U.value[Q]=J.value}for(let Q=U.value.length-1;Q>=z.length;Q--)if(Y[Q]._zod.optout==="optional"&&U.value[Q]===void 0)U.value.length=Q;else break;return U}function dr($,U,Y,z,I,Q,J){if($.issues.length)if(UG.has(typeof z))Y.issues.push(...b8(z,$.issues));else Y.issues.push({code:"invalid_key",origin:"map",input:I,inst:Q,issues:$.issues.map((K)=>E8(K,J,s4()))});if(U.issues.length)if(UG.has(typeof z))Y.issues.push(...b8(z,U.issues));else Y.issues.push({origin:"map",code:"invalid_element",input:I,inst:Q,key:z,issues:U.issues.map((K)=>E8(K,J,s4()))});Y.value.set($.value,U.value)}function pr($,U){if($.issues.length)U.issues.push(...$.issues);U.value.add($.value)}function mr($,U){if(U===void 0&&($.issues.length||$.fallback))return{issues:[],value:void 0};return $}function lr($,U){if($.value===void 0)$.value=U.defaultValue;return $}function or($,U){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:U});return $}function DV($,U,Y){if($.issues.length)return $.aborted=!0,$;return U._zod.run({value:$.value,issues:$.issues,fa Line truncated
if (${D}.issues.length) {
if (${P} in input) {
payload.issues = payload.issues.concat(${D}.issues.map(iss => ({
@@ -60,108 +60,108 @@ import{createRequire as ly0}from"node:module";var fy0=Object.create;var{getProto
newResult[${P}] = ${D}.value;
}
`)}q.write("payload.value = newResult;"),q.write("return payload;");let N=q.compile();return(M,D)=>N(Z,M,D)},J,I=CY,K=!jY.jitless,H=K&&qT.value,W=Y.catchall,X;$._zod.parse=(Z,q)=>{X??(X=U.value);let V=Z.value;if(!I(V))return Z.issues.push({expected:"object",code:"invalid_type",input:V,inst:$}),Z;if(K&&H&&q?.async===!1&&q.jitless!==!0){if(!J)J=Q(Y.shape);if(Z=J(Z,q),!W)return Z;return nr([],V,Z,q,X,$)}return z(Z,q)}});WG=W0("$ZodUnion",($,Y)=>{V1.init($,Y),E1($._zod,"optin",()=>Y.options.some((U)=>U._zod.optin==="optional")?"optional":void 0),E1($._zod,"optout",()=>Y.options.some((U)=>U._zod.optout==="optional")?"optional":void 0),E1($._zod,"values",()=>{if(Y.options.every((U)=>U._zod.values))return new Set(Y.options.flatMap((U)=>Array.from(U._zod.values)));return}),E1($._zod,"pattern",()=>{if(Y.options.every((U)=>U._zod.pattern)){let U=Y.options.map((Q)=>Q._zod.pattern);return new RegExp(`^(${U.map((Q)=>eK(Q.source)).join("|")})$`)}return});let z=Y.options.length===1?Y.options[0]._zod.run:null;$._zod.parse=(U,Q)=>{if(z)return z(U,Q);let J=!1,I=[];for(let K of Y.options){let G=K._zod.run({value:U.value,issues:[]},Q);if(G instanceof Promise)I.push(G),J=!0;else{if(G.issues.length===0)return G;I.push(G)}}if(!J)return Tr(I,U,$,Q);return Promise.all(I).then((K)=>{return Tr(K,U,$,Q)})}});IC=W0("$ZodXor",($,Y)=>{WG.init($,Y),Y.inclusive=!1;let z=Y.options.length===1?Y.options[0]._zod.run:null;$._zod.parse=(U,Q)=>{if(z)return z(U,Q);let J=!1,I=[];for(let K of Y.options){let G=K._zod.run({value:U.value,issues:[]},Q);if(G instanceof Promise)I.push(G),J=!0;else I.push(G)}if(!J)return Er(I,U,$,Q);return Promise.all(I).then((K)=>{return Er(K,U,$,Q)})}}),KC=W0("$ZodDiscriminatedUnion",($,Y)=>{Y.inclusive=!1,WG.init($,Y);let z=$._zod.parse;E1($._zod,"propValues",()=>{let Q={};for(let J of Y.options){let I=J._zod.propValues;if(!I||Object.keys(I).length===0)throw Error(`Invalid discriminated union option at index "${Y.options.indexOf(J)}"`);for(let[K,G]of Object.entries(I)){if(!Q[K])Q[K]=new Set;for(let H of G)Q[K].add(H)}}return Q});let U=mU(()=>{let Q=Y.options,J=new Map;for(let I of Q){let K=I._zod.propValues?.[Y.discriminator];if(!K||K.size===0)throw Error(`Invalid discriminated union option at index "${Y.options.indexOf(I)}"`);for(let G of K){if(J.has(G))throw Error(`Duplicate discriminator value "${String(G)}"`);J.set(G,I)}}return J});$._zod.parse=(Q,J)=>{let I=Q.value;if(!CY(I))return Q.issues.push({code:"invalid_type",expected:"object",input:I,inst:$}),Q;let K=U.value.get(I?.[Y.discriminator]);if(K)return K._zod.run(Q,J);if(Y.unionFallback||J.direction==="backward")return z(Q,J);return Q.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:Y.discriminator,options:Array.from(U.value.keys()),input:I,path:[Y.discriminator],inst:$}),Q}}),GC=W0("$ZodIntersection",($,Y)=>{V1.init($,Y),$._zod.parse=(z,U)=>{let Q=z.value,J=Y.left._zod.run({value:Q,issues:[]},U),I=Y.right._zod.run({value:Q,issues:[]},U);if(J instanceof Promise||I instanceof Promise)return Promise.all([J,I]).then(([G,H])=>{return Cr(z,G,H)});return Cr(z,J,I)}});DV=W0("$ZodTuple",($,Y)=>{V1.init($,Y);let z=Y.items;$._zod.parse=(U,Q)=>{let J=U.value;if(!Array.isArray(J))return U.issues.push({input:J,inst:$,expected:"tuple",code:"invalid_type"}),U;U.value=[];let I=[],K=Rr(z,"optin"),G=Rr(z,"optout");if(!Y.rest){if(J.length<K)return U.issues.push({code:"too_small",minimum:K,inclusive:!0,input:J,inst:$,origin:"array"}),U;if(J.length>z.length)U.issues.push({code:"too_big",maximum:z.length,inclusive:!0,input:J,inst:$,origin:"array"})}let H=Array(z.length);for(let W=0;W<z.length;W++){let X=z[W]._zod.run({value:J[W],issues:[]},Q);if(X instanceof Promise)I.push(X.then((Z)=>{H[W]=Z}));else H[W]=X}if(Y.rest){let W=z.length-1,X=J.slice(z.length);for(let Z of X){W++;let q=Y.rest._zod.run({value:Z,issues:[]},Q);if(q instanceof Promise)I.push(q.then((V)=>_r(V,U,W)));else _r(q,U,W)}}if(I.length)return Promise.all(I).then(()=>vr(H,U,z,J,G));return vr(H,U,z,J,G)}});HC=W0("$ZodRecord",($,Y)=>{V1.init($,Y),$._zod.parse=(z,U)=>{let Q=z.value;if(!W7(Q))return z.issues.push({expected:"record",code:"invalid_type",input:Q,inst:$}),z;let J=[],I=Y.keyType._zod.values;if(I){z.value={};let K=new Set;for(let H of I)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){K.add(typeof H==="number"?H.toString():H);let W=Y.keyType._zod.run({value:H,issues:[]},U);if(W instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(W.issues.length){z.issues.push({code:"invalid_key",origin:"record",issues:W.issues.map((q)=>B8(q,U,a4())),input:H,path:[H],inst:$});continue}let X=W.value,Z=Y.valueType._zod.run({value:Q[H],issues:[]},U);if(Z instanceof Promise)J.push(Z.then((q)=>{if(q.issues.length)z.issues.push(...f8(H,q.issues));z.value[X]=q.value}));else{if(Z.issues.length)z.issues.push(...f8(H,Z.issues));z.value[X]=Z.value}}let G;for(let H in Q)if(!K.has(H))G=G??[],G.push(H);if(G&&G.length>0)z.issues.push({code:"unrec Line truncated
`)}q.write("payload.value = newResult;"),q.write("return payload;");let N=q.compile();return(O,D)=>N(Z,O,D)},Q,J=CU,K=!TU.jitless,H=K&&jj.value,W=U.catchall,X;$._zod.parse=(Z,q)=>{X??(X=z.value);let V=Z.value;if(!J(V))return Z.issues.push({expected:"object",code:"invalid_type",input:V,inst:$}),Z;if(K&&H&&q?.async===!1&&q.jitless!==!0){if(!Q)Q=I(U.shape);if(Z=Q(Z,q),!W)return Z;return $s([],V,Z,q,X,$)}return Y(Z,q)}});XG=H0("$ZodUnion",($,U)=>{V1.init($,U),E1($._zod,"optin",()=>U.options.some((z)=>z._zod.optin==="optional")?"optional":void 0),E1($._zod,"optout",()=>U.options.some((z)=>z._zod.optout==="optional")?"optional":void 0),E1($._zod,"values",()=>{if(U.options.every((z)=>z._zod.values))return new Set(U.options.flatMap((z)=>Array.from(z._zod.values)));return}),E1($._zod,"pattern",()=>{if(U.options.every((z)=>z._zod.pattern)){let z=U.options.map((I)=>I._zod.pattern);return new RegExp(`^(${z.map((I)=>$G(I.source)).join("|")})$`)}return});let Y=U.options.length===1?U.options[0]._zod.run:null;$._zod.parse=(z,I)=>{if(Y)return Y(z,I);let Q=!1,J=[];for(let K of U.options){let G=K._zod.run({value:z.value,issues:[]},I);if(G instanceof Promise)J.push(G),Q=!0;else{if(G.issues.length===0)return G;J.push(G)}}if(!Q)return fr(J,z,$,I);return Promise.all(J).then((K)=>{return fr(K,z,$,I)})}});OC=H0("$ZodXor",($,U)=>{XG.init($,U),U.inclusive=!1;let Y=U.options.length===1?U.options[0]._zod.run:null;$._zod.parse=(z,I)=>{if(Y)return Y(z,I);let Q=!1,J=[];for(let K of U.options){let G=K._zod.run({value:z.value,issues:[]},I);if(G instanceof Promise)J.push(G),Q=!0;else J.push(G)}if(!Q)return ur(J,z,$,I);return Promise.all(J).then((K)=>{return ur(K,z,$,I)})}}),NC=H0("$ZodDiscriminatedUnion",($,U)=>{U.inclusive=!1,XG.init($,U);let Y=$._zod.parse;E1($._zod,"propValues",()=>{let I={};for(let Q of U.options){let J=Q._zod.propValues;if(!J||Object.keys(J).length===0)throw Error(`Invalid discriminated union option at index "${U.options.indexOf(Q)}"`);for(let[K,G]of Object.entries(J)){if(!I[K])I[K]=new Set;for(let H of G)I[K].add(H)}}return I});let z=lz(()=>{let I=U.options,Q=new Map;for(let J of I){let K=J._zod.propValues?.[U.discriminator];if(!K||K.size===0)throw Error(`Invalid discriminated union option at index "${U.options.indexOf(J)}"`);for(let G of K){if(Q.has(G))throw Error(`Duplicate discriminator value "${String(G)}"`);Q.set(G,J)}}return Q});$._zod.parse=(I,Q)=>{let J=I.value;if(!CU(J))return I.issues.push({code:"invalid_type",expected:"object",input:J,inst:$}),I;let K=z.value.get(J?.[U.discriminator]);if(K)return K._zod.run(I,Q);if(U.unionFallback||Q.direction==="backward")return Y(I,Q);return I.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:U.discriminator,options:Array.from(z.value.keys()),input:J,path:[U.discriminator],inst:$}),I}}),DC=H0("$ZodIntersection",($,U)=>{V1.init($,U),$._zod.parse=(Y,z)=>{let I=Y.value,Q=U.left._zod.run({value:I,issues:[]},z),J=U.right._zod.run({value:I,issues:[]},z);if(Q instanceof Promise||J instanceof Promise)return Promise.all([Q,J]).then(([G,H])=>{return br(Y,G,H)});return br(Y,Q,J)}});EV=H0("$ZodTuple",($,U)=>{V1.init($,U);let Y=U.items;$._zod.parse=(z,I)=>{let Q=z.value;if(!Array.isArray(Q))return z.issues.push({input:Q,inst:$,expected:"tuple",code:"invalid_type"}),z;z.value=[];let J=[],K=ir(Y,"optin"),G=ir(Y,"optout");if(!U.rest){if(Q.length<K)return z.issues.push({code:"too_small",minimum:K,inclusive:!0,input:Q,inst:$,origin:"array"}),z;if(Q.length>Y.length)z.issues.push({code:"too_big",maximum:Y.length,inclusive:!0,input:Q,inst:$,origin:"array"})}let H=Array(Y.length);for(let W=0;W<Y.length;W++){let X=Y[W]._zod.run({value:Q[W],issues:[]},I);if(X instanceof Promise)J.push(X.then((Z)=>{H[W]=Z}));else H[W]=X}if(U.rest){let W=Y.length-1,X=Q.slice(Y.length);for(let Z of X){W++;let q=U.rest._zod.run({value:Z,issues:[]},I);if(q instanceof Promise)J.push(q.then((V)=>nr(V,z,W)));else nr(q,z,W)}}if(J.length)return Promise.all(J).then(()=>cr(H,z,Y,Q,G));return cr(H,z,Y,Q,G)}});AC=H0("$ZodRecord",($,U)=>{V1.init($,U),$._zod.parse=(Y,z)=>{let I=Y.value;if(!Z7(I))return Y.issues.push({expected:"record",code:"invalid_type",input:I,inst:$}),Y;let Q=[],J=U.keyType._zod.values;if(J){Y.value={};let K=new Set;for(let H of J)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){K.add(typeof H==="number"?H.toString():H);let W=U.keyType._zod.run({value:H,issues:[]},z);if(W instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(W.issues.length){Y.issues.push({code:"invalid_key",origin:"record",issues:W.issues.map((q)=>E8(q,z,s4())),input:H,path:[H],inst:$});continue}let X=W.value,Z=U.valueType._zod.run({value:I[H],issues:[]},z);if(Z instanceof Promise)Q.push(Z.then((q)=>{if(q.issues.length)Y.issues.push(...b8(H,q.issues));Y.value[X]=q.value}));else{if(Z.issues.length)Y.issues.push(...b8(H,Z.issues));Y.value[X]=Z.value}}let G;for(let H in I)if(!K.has(H))G=G??[],G.push(H);if(G&&G.length>0)Y.issues.push({code:"unrec Line truncated
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let I of $.seen.entries()){let K=I[1];if(Y===I[0]){J(I);continue}if($.external){let H=$.external.registry.get(I[0])?.id;if(Y!==I[0]&&H){J(I);continue}}if($.metadataRegistry.get(I[0])?.id){J(I);continue}if(K.cycle){J(I);continue}if(K.count>1){if($.reused==="ref"){J(I);continue}}}}function F7($,Y){let z=$.seen.get(Y);if(!z)throw Error("Unprocessed schema. This is a bug in Zod.");let U=(K)=>{let G=$.seen.get(K);if(G.ref===null)return;let H=G.def??G.schema,W={...H},X=G.ref;if(G.ref=null,X){U(X);let q=$.seen.get(X),V=q.schema;if(V.$ref&&($.target==="draft-07"||$.target==="draft-04"||$.target==="openapi-3.0"))H.allOf=H.allOf??[],H.allOf.push(V);else Object.assign(H,V);if(Object.assign(H,W),K._zod.parent===X)for(let w in H){if(w==="$ref"||w==="allOf")continue;if(!(w in W))delete H[w]}if(V.$ref&&q.def)for(let w in H){if(w==="$ref"||w==="allOf")continue;if(w in q.def&&JSON.stringify(H[w])===JSON.stringify(q.def[w]))delete H[w]}}let Z=K._zod.parent;if(Z&&Z!==X){U(Z);let q=$.seen.get(Z);if(q?.schema.$ref){if(H.$ref=q.schema.$ref,q.def)for(let V in H){if(V==="$ref"||V==="allOf")continue;if(V in q.def&&JSON.stringify(H[V])===JSON.stringify(q.def[V]))delete H[V]}}}$.override({zodSchema:K,jsonSchema:H,path:G.path??[]})};for(let K of[...$.seen.entries()].reverse())U(K[0]);let Q={};if($.target==="draft-2020-12")Q.$schema="https://json-schema.org/draft/2020-12/schema";else if($.target==="draft-07")Q.$schema="http://json-schema.org/draft-07/schema#";else if($.target==="draft-04")Q.$schema="http://json-schema.org/draft-04/schema#";else if($.target==="openapi-3.0");if($.external?.uri){let K=$.external.registry.get(Y)?.id;if(!K)throw Error("Schema is missing an `id` property");Q.$id=$.external.uri(K)}Object.assign(Q,z.def??z.schema);let J=$.metadataRegistry.get(Y)?.id;if(J!==void 0&&Q.id===J)delete Q.id;let I=$.external?.defs??{};for(let K of $.seen.entries()){let G=K[1];if(G.def&&G.defId){if(G.def.id===G.defId)delete G.def.id;I[G.defId]=G.def}}if($.external);else if(Object.keys(I).length>0)if($.target==="draft-2020-12")Q.$defs=I;else Q.definitions=I;try{let K=JSON.parse(JSON.stringify(Q));return Object.defineProperty(K,"~standard",{value:{...Y["~standard"],jsonSchema:{input:qQ(Y,"input",$.processors),output:qQ(Y,"output",$.processors)}},enumerable:!1,writable:!1}),K}catch(K){throw Error("Error converting schema to JSON.")}}function j8($,Y){let z=Y??{seen:new Set};if(z.seen.has($))return!1;z.seen.add($);let U=$._zod.def;if(U.type==="transform")return!0;if(U.type==="array")return j8(U.element,z);if(U.type==="set")return j8(U.valueType,z);if(U.type==="lazy")return j8(U.getter(),z);if(U.type==="promise"||U.type==="optional"||U.type==="nonoptional"||U.type==="nullable"||U.type==="readonly"||U.type==="default"||U.type==="prefault")return j8(U.innerType,z);if(U.type==="intersection")return j8(U.left,z)||j8(U.right,z);if(U.type==="record"||U.type==="map")return j8(U.keyType,z)||j8(U.valueType,z);if(U.type==="pipe"){if($._zod.traits.has("$ZodCodec"))return!0;return j8(U.in,z)||j8(U.out,z)}if(U.type==="object"){for(let Q in U.shape)if(j8(U.shape[Q],z))return!0;return!1}if(U.type==="union"){for(let Q of U.options)if(j8(Q,z))return!0;return!1}if(U.type==="tuple"){for(let Q of U.items)if(j8(Q,z))return!0;if(U.rest&&j8(U.rest,z))return!0;return!1}return!1}var M_=($,Y={})=>(z)=>{let U=V7({...z,processors:Y});return J4($,U),L7(U,$),F7(U,$)},qQ=($,Y,z={})=>(U)=>{let{libraryOptions:Q,target:J}=U??{},I=V7({...Q??{},target:J,io:Y,processors:z});return J4($,I),L7(I,$),F7(I,$)};var NG=m(()=>{OG()});function gY($,Y){if("_idmap"in $){let U=$,Q=V7({...Y,processors:sV}),J={};for(let G of U._idmap.entries()){let[H,W]=G;J4(W,Q)}let I={},K={registry:U,uri:Y?.uri,defs:J};Q.external=K;for(let G of U._idmap.entries()){let[H,W]=G;L7(Q,W),I[H]=F7(Q,W)}if(Object.keys(J).length>0){let G=Q.target==="draft-2020-12"?"$defs":"definitions";I.__shared={[G]:J}}return{schemas:I}}let z=V7({...Y,processors:sV});return J4($,z),L7(z,$),F7(z,$)}var vf0,N_=($,Y,z,U)=>{let Q=z;Q.type="string";let{minimum:J,maximum:I,format:K,patterns:G,contentEncoding:H}=$._zod.bag;if(typeof J==="number")Q.minLength=J;if(typeof I==="number")Q.maxLength=I;if(K){if(Q.format=vf0[K]??K,Q.format==="")delete Q.format;if(K==="time")delete Q.format}if(H)Q.contentEncoding=H;if(G&&G.size>0){let W=[...G];if(W.length===1)Q.pattern=W[0].source;else if(W.length>1)Q.allOf=[...W.map((X)=>({...Y.target==="draft-07"||Y.target==="draft-04"||Y.target==="openapi-3.0"?{type:"string"}:{},pattern:X.source}))]}},D_=($,Y,z,U)=>{let Q=z,{minimum:J,maximum:I,format:K,multipleOf:G,exclusiveMaximum:H,exclusiveMinimum:W}=$._zod.bag;if(typeof K==="string"&&K.includes("int"))Q.type="integer";else Q.type="number";let X=typeof W==="number"&&W>=(J??Number.NEGATIVE_INFINITY),Z=typeof H==="number"&&H<=(I??Number.POSITIVE_INFINITY),q=Y.target==="draft-04"||Y.target==="openapi-3.0";if(X)if(q)Q.minimum=W,Q.exclusiveMinimum=!0;else Q.exclusiveMinimuLine truncated
`}function Xb0($){let Y=[];if($.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if($.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${$.length})`]};if($.includes(" "))Y.push("Tool name contains spaces, which may cause parsing issues");if($.includes(","))Y.push("Tool name contains commas, which may cause parsing issues");if($.startsWith("-")||$.endsWith("-"))Y.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts");if($.startsWith(".")||$.endsWith("."))Y.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts");if(!Wb0.test($)){let z=[...$].filter((U)=>!/[A-Za-z0-9._-]/.test(U)).filter((U,Q,J)=>J.indexOf(U)===Q);return Y.push(`Tool name contains invalid characters: ${z.map((U)=>`"${U}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:Y}}return{isValid:!0,warnings:Y}}function Zb0($,Y){if(Y.length>0){console.warn(`Tool name validation warning for "${$}":`);for(let z of Y)console.warn(` - ${z}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function FS($){let Y=Xb0($);return Zb0($,Y.warnings),Y.isValid}function qb0($){return typeof $==="object"&&$!==null&&"_zod"in $}function Vb0($){return typeof $==="object"&&$!==null&&!("_zod"in $)&&"_def"in $&&typeof $._def?.typeName==="string"}function Lb0($){if(typeof $!=="object"||$===null)return!1;if(kQ($))return!1;let Y=Object.getPrototypeOf($);if(Y!==Object.prototype&&Y!==null)return!1;return Object.values($).every((z)=>qb0(z))}function kO($){if($===void 0)return;if(Lb0($))return z0($);if(typeof $==="object"&&$!==null&&!kQ($)&&Object.values($).some((Y)=>Vb0(Y)))throw TypeError("Raw-shape inputSchema/outputSchema/argsSchema fields must be Zod v4 schemas. Got a Zod v3 field schema. Import from `zod/v4` (or upgrade your zod import), or wrap with `z.object({...})` yourself.");if(!kQ($))throw TypeError("inputSchema/outputSchema/argsSchema must be a Standard Schema (e.g. z.object({...})) or a raw Zod shape ({ field: z.string() }).");return $}var ph,lf0,B1,L1,of0,kt="2026-07-28",R7,ut,af0,tf0,ef0,nt,ct,Yu0,NO,su1,au1,Pt,th,Ku0,Gu0,gQ,c0,J1,RO,mt,fQ,_O,Xu0=0,Zu0="private",qu0,Du0,AO,zS,rt,tu1,eu1,Eu0,Cu0,US,BO,LH="2026-07-28",tt,vu0,B$=($)=>iG.safeParse($).success,_7=($)=>nG.safeParse($).success,qH=($)=>BQ.safeParse($).success,gO=($)=>PQ.safeParse($).success,t9=($)=>typeof $==="object"&&$!==null&&!Array.isArray($)&&$.resultType==="input_required",Rt="x-mcp-header",hu0,Su0,gu0,yu0,TO=-32020,$b1,ku0,_t=!1,mh="draft-2020-12",uu0,pu0,du0,vt,mu0,tu0,Ye=250,eu0,$b0,Je,Ie,Yb0,zb0,Ge=60000,Qb0,Jb0,Ib0,He,ZS,Hb0,Yb1,We=10485760,VS=class{_buffer;_maxBufferSize;constructor($){this._maxBufferSize=$?.maxBufferSize??We}append($){if((this._buffer?.length??0)+$.length>this._maxBufferSize)throw this.clear(),Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,$]):$}readMessage(){while(this._buffer){let $=this._buffer.indexOf(`
`);if($===-1)return null;let Y=this._buffer.toString("utf8",0,$).replace(/\r$/,"");this._buffer=this._buffer.subarray($+1);try{return Xe(Y)}catch(z){if(z instanceof SyntaxError)continue;throw z}}return null}clear(){this._buffer=void 0}},Wb0;var xO=m(()=>{KT();GT();Dt();Hh();ph=Symbol.for("mcp.sdk.errorBrands");lf0=class $ extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](Y){return yQ(this,Y)}static isInstance(Y){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return yQ(this,Y)}constructor(Y,z,U){super(z);this.code=Y,this.errorUri=U,this.name="OAuthError",oh(this,new.target)}toResponseObject(){let Y={error:this.code,error_description:this.message};if(this.errorUri)Y.error_uri=this.errorUri;return Y}static fromResponse(Y){return new $(Y.error,Y.error_description??Y.error,Y.error_uri)}},B1=function($){return $.NotConnected="NOT_CONNECTED",$.AlreadyConnected="ALREADY_CONNECTED",$.NotInitialized="NOT_INITIALIZED",$.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",$.RequestTimeout="REQUEST_TIMEOUT",$.ConnectionClosed="CONNECTION_CLOSED",$.SendFailed="SEND_FAILED",$.InvalidResult="INVALID_RESULT",$.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",$.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",$.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",$.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",$.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",$.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",$.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",$.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",$.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",$.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",$.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",$}({}),L1=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance]($){return yQ(this,$)}static isInstance($){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return yQ(this,$)}constructor($,Y,z){super(Y);this.code=$,this.data=z,this.name="SdkError",oh(this,new.target)}},of0=class extends L1{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor($,Y,z){super($,Y,z);this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};R7=[kt];ut=["task","inputRequests","requestState"];tf0=new Set(["const","enum","default","examples"]),ef0=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);nt={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},ct={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},Yu0={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null};su1=Object.keys(nt),au1=Object.keys(ct);Pt={ok:!1,reason:"not-in-era"};th={era:"2025-11-25",hasRequestMethod:pt,hasNotificationMethod:dt,validateRequest:($,Y)=>DO(Qu0($),Y),validateResult:($,Y)=>DO(Uu0($),Y),validateNotification:($,Y)=>DO(Ju0($),Y),hasInputRequestMethod:()=>!1,validateInputRequest:()=>Pt,validateInputResponse:()=>Pt,samplingResultVariant:($,Y)=>{let z=bt();return DO($?z.CreateMessageResultWithToolsSchema:z.CreateMessageResultSchema,Y)},outboundEnvelope:($)=>{return},validateEnvelopeMeta:($)=>[],projectCallToolResult($,Y){let z=ft($),U=z.structuredContent;if(U===void 0)return z;let Q=typeof U!=="object"||U===null||Array.isArray(U),J=Y!==void 0&&it(Y);if(!Q&&!J)return z;return{...z,structuredContent:{result:U}}},decodeResult($,Y){if(dh(Y)&&"resultType"in Y){let z={...Y};return delete z.resultType,{kind:"complete",result:Tt(z)}}return{kind:"complete",result:Tt(Y)}},encodeResult($,Y){if($!=="tools/list")return Y;l Line truncated
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let J of $.seen.entries()){let K=J[1];if(U===J[0]){Q(J);continue}if($.external){let H=$.external.registry.get(J[0])?.id;if(U!==J[0]&&H){Q(J);continue}}if($.metadataRegistry.get(J[0])?.id){Q(J);continue}if(K.cycle){Q(J);continue}if(K.count>1){if($.reused==="ref"){Q(J);continue}}}}function M7($,U){let Y=$.seen.get(U);if(!Y)throw Error("Unprocessed schema. This is a bug in Zod.");let z=(K)=>{let G=$.seen.get(K);if(G.ref===null)return;let H=G.def??G.schema,W={...H},X=G.ref;if(G.ref=null,X){z(X);let q=$.seen.get(X),V=q.schema;if(V.$ref&&($.target==="draft-07"||$.target==="draft-04"||$.target==="openapi-3.0"))H.allOf=H.allOf??[],H.allOf.push(V);else Object.assign(H,V);if(Object.assign(H,W),K._zod.parent===X)for(let M in H){if(M==="$ref"||M==="allOf")continue;if(!(M in W))delete H[M]}if(V.$ref&&q.def)for(let M in H){if(M==="$ref"||M==="allOf")continue;if(M in q.def&&JSON.stringify(H[M])===JSON.stringify(q.def[M]))delete H[M]}}let Z=K._zod.parent;if(Z&&Z!==X){z(Z);let q=$.seen.get(Z);if(q?.schema.$ref){if(H.$ref=q.schema.$ref,q.def)for(let V in H){if(V==="$ref"||V==="allOf")continue;if(V in q.def&&JSON.stringify(H[V])===JSON.stringify(q.def[V]))delete H[V]}}}$.override({zodSchema:K,jsonSchema:H,path:G.path??[]})};for(let K of[...$.seen.entries()].reverse())z(K[0]);let I={};if($.target==="draft-2020-12")I.$schema="https://json-schema.org/draft/2020-12/schema";else if($.target==="draft-07")I.$schema="http://json-schema.org/draft-07/schema#";else if($.target==="draft-04")I.$schema="http://json-schema.org/draft-04/schema#";else if($.target==="openapi-3.0");if($.external?.uri){let K=$.external.registry.get(U)?.id;if(!K)throw Error("Schema is missing an `id` property");I.$id=$.external.uri(K)}Object.assign(I,Y.def??Y.schema);let Q=$.metadataRegistry.get(U)?.id;if(Q!==void 0&&I.id===Q)delete I.id;let J=$.external?.defs??{};for(let K of $.seen.entries()){let G=K[1];if(G.def&&G.defId){if(G.def.id===G.defId)delete G.def.id;J[G.defId]=G.def}}if($.external);else if(Object.keys(J).length>0)if($.target==="draft-2020-12")I.$defs=J;else I.definitions=J;try{let K=JSON.parse(JSON.stringify(I));return Object.defineProperty(K,"~standard",{value:{...U["~standard"],jsonSchema:{input:VI(U,"input",$.processors),output:VI(U,"output",$.processors)}},enumerable:!1,writable:!1}),K}catch(K){throw Error("Error converting schema to JSON.")}}function R8($,U){let Y=U??{seen:new Set};if(Y.seen.has($))return!1;Y.seen.add($);let z=$._zod.def;if(z.type==="transform")return!0;if(z.type==="array")return R8(z.element,Y);if(z.type==="set")return R8(z.valueType,Y);if(z.type==="lazy")return R8(z.getter(),Y);if(z.type==="promise"||z.type==="optional"||z.type==="nonoptional"||z.type==="nullable"||z.type==="readonly"||z.type==="default"||z.type==="prefault")return R8(z.innerType,Y);if(z.type==="intersection")return R8(z.left,Y)||R8(z.right,Y);if(z.type==="record"||z.type==="map")return R8(z.keyType,Y)||R8(z.valueType,Y);if(z.type==="pipe"){if($._zod.traits.has("$ZodCodec"))return!0;return R8(z.in,Y)||R8(z.out,Y)}if(z.type==="object"){for(let I in z.shape)if(R8(z.shape[I],Y))return!0;return!1}if(z.type==="union"){for(let I of z.options)if(R8(I,Y))return!0;return!1}if(z.type==="tuple"){for(let I of z.items)if(R8(I,Y))return!0;if(z.rest&&R8(z.rest,Y))return!0;return!1}return!1}var h_=($,U={})=>(Y)=>{let z=w7({...Y,processors:U});return K4($,z),F7(z,$),M7(z,$)},VI=($,U,Y={})=>(z)=>{let{libraryOptions:I,target:Q}=z??{},J=w7({...I??{},target:Q,io:U,processors:Y});return K4($,J),F7(J,$),M7(J,$)};var DG=m(()=>{MG()});function gU($,U){if("_idmap"in $){let z=$,I=w7({...U,processors:YL}),Q={};for(let G of z._idmap.entries()){let[H,W]=G;K4(W,I)}let J={},K={registry:z,uri:U?.uri,defs:Q};I.external=K;for(let G of z._idmap.entries()){let[H,W]=G;F7(I,W),J[H]=M7(I,W)}if(Object.keys(Q).length>0){let G=I.target==="draft-2020-12"?"$defs":"definitions";J.__shared={[G]:Q}}return{schemas:J}}let Y=w7({...U,processors:YL});return K4($,Y),F7(Y,$),M7(Y,$)}var Ju0,S_=($,U,Y,z)=>{let I=Y;I.type="string";let{minimum:Q,maximum:J,format:K,patterns:G,contentEncoding:H}=$._zod.bag;if(typeof Q==="number")I.minLength=Q;if(typeof J==="number")I.maxLength=J;if(K){if(I.format=Ju0[K]??K,I.format==="")delete I.format;if(K==="time")delete I.format}if(H)I.contentEncoding=H;if(G&&G.size>0){let W=[...G];if(W.length===1)I.pattern=W[0].source;else if(W.length>1)I.allOf=[...W.map((X)=>({...U.target==="draft-07"||U.target==="draft-04"||U.target==="openapi-3.0"?{type:"string"}:{},pattern:X.source}))]}},g_=($,U,Y,z)=>{let I=Y,{minimum:Q,maximum:J,format:K,multipleOf:G,exclusiveMaximum:H,exclusiveMinimum:W}=$._zod.bag;if(typeof K==="string"&&K.includes("int"))I.type="integer";else I.type="number";let X=typeof W==="number"&&W>=(Q??Number.NEGATIVE_INFINITY),Z=typeof H==="number"&&H<=(J??Number.POSITIVE_INFINITY),q=U.target==="draft-04"||U.target==="openapi-3.0";if(X)if(q)I.minimum=W,I.exclusiveMinimum=!0;else I.exclusiveMinimuLine truncated
`}function bb0($){let U=[];if($.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if($.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${$.length})`]};if($.includes(" "))U.push("Tool name contains spaces, which may cause parsing issues");if($.includes(","))U.push("Tool name contains commas, which may cause parsing issues");if($.startsWith("-")||$.endsWith("-"))U.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts");if($.startsWith(".")||$.endsWith("."))U.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts");if(!ub0.test($)){let Y=[...$].filter((z)=>!/[A-Za-z0-9._-]/.test(z)).filter((z,I,Q)=>Q.indexOf(z)===I);return U.push(`Tool name contains invalid characters: ${Y.map((z)=>`"${z}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:U}}return{isValid:!0,warnings:U}}function ib0($,U){if(U.length>0){console.warn(`Tool name validation warning for "${$}":`);for(let Y of U)console.warn(` - ${Y}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function RS($){let U=bb0($);return ib0($,U.warnings),U.isValid}function nb0($){return typeof $==="object"&&$!==null&&"_zod"in $}function cb0($){return typeof $==="object"&&$!==null&&!("_zod"in $)&&"_def"in $&&typeof $._def?.typeName==="string"}function db0($){if(typeof $!=="object"||$===null)return!1;if(xI($))return!1;let U=Object.getPrototypeOf($);if(U!==Object.prototype&&U!==null)return!1;return Object.values($).every((Y)=>nb0(Y))}function nF($){if($===void 0)return;if(db0($))return Y0($);if(typeof $==="object"&&$!==null&&!xI($)&&Object.values($).some((U)=>cb0(U)))throw TypeError("Raw-shape inputSchema/outputSchema/argsSchema fields must be Zod v4 schemas. Got a Zod v3 field schema. Import from `zod/v4` (or upgrade your zod import), or wrap with `z.object({...})` yourself.");if(!xI($))throw TypeError("inputSchema/outputSchema/argsSchema must be a Standard Schema (e.g. z.object({...})) or a raw Zod shape ({ field: z.string() }).");return $}var zS,Au0,T1,L1,Bu0,ot="2026-07-28",v7,at,ju0,Eu0,Cu0,$e,Ue,_u0,jF,Cb1,Rb1,kt,XS,ku0,xu0,yI,i0,I1,yF,Ie,uI,kF,bu0=0,iu0="private",nu0,su0,CF,LS,Ke,_b1,vb1,Yb0,zb0,wS,RF,wH="2026-07-28",We,Jb0,P$=($)=>nG.safeParse($).success,h7=($)=>cG.safeParse($).success,VH=($)=>PI.safeParse($).success,bF=($)=>TI.safeParse($).success,U3=($)=>typeof $==="object"&&$!==null&&!Array.isArray($)&&$.resultType==="input_required",it="x-mcp-header",Kb0,Gb0,Hb0,Wb0,hF=-32020,hb1,Xb0,nt=!1,QS="draft-2020-12",Vb0,Ob0,Nb0,ct,Db0,Eb0,qe=250,Cb0,Rb0,Fe,Me,_b0,vb0,Ne=60000,Sb0,gb0,yb0,De,TS,fb0,Sb1,Ae=10485760,ES=class{_buffer;_maxBufferSize;constructor($){this._maxBufferSize=$?.maxBufferSize??Ae}append($){if((this._buffer?.length??0)+$.length>this._maxBufferSize)throw this.clear(),Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,$]):$}readMessage(){while(this._buffer){let $=this._buffer.indexOf(`
`);if($===-1)return null;let U=this._buffer.toString("utf8",0,$).replace(/\r$/,"");this._buffer=this._buffer.subarray($+1);try{return Be(U)}catch(Y){if(Y instanceof SyntaxError)continue;throw Y}}return null}clear(){this._buffer=void 0}},ub0;var cF=m(()=>{Nj();Dj();St();Ah();zS=Symbol.for("mcp.sdk.errorBrands");Au0=class $ extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](U){return kI(this,U)}static isInstance(U){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return kI(this,U)}constructor(U,Y,z){super(Y);this.code=U,this.errorUri=z,this.name="OAuthError",KS(this,new.target)}toResponseObject(){let U={error:this.code,error_description:this.message};if(this.errorUri)U.error_uri=this.errorUri;return U}static fromResponse(U){return new $(U.error,U.error_description??U.error,U.error_uri)}},T1=function($){return $.NotConnected="NOT_CONNECTED",$.AlreadyConnected="ALREADY_CONNECTED",$.NotInitialized="NOT_INITIALIZED",$.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",$.RequestTimeout="REQUEST_TIMEOUT",$.ConnectionClosed="CONNECTION_CLOSED",$.SendFailed="SEND_FAILED",$.InvalidResult="INVALID_RESULT",$.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",$.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",$.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",$.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",$.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",$.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",$.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",$.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",$.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",$.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",$.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",$}({}),L1=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance]($){return kI(this,$)}static isInstance($){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return kI(this,$)}constructor($,U,Y){super(U);this.code=$,this.data=Y,this.name="SdkError",KS(this,new.target)}},Bu0=class extends L1{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor($,U,Y){super($,U,Y);this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};v7=[ot];at=["task","inputRequests","requestState"];Eu0=new Set(["const","enum","default","examples"]),Cu0=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);$e={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Ue={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},_u0={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null};Cb1=Object.keys($e),Rb1=Object.keys(Ue);kt={ok:!1,reason:"not-in-era"};XS={era:"2025-11-25",hasRequestMethod:Ye,hasNotificationMethod:ze,validateRequest:($,U)=>EF(Su0($),U),validateResult:($,U)=>EF(hu0($),U),validateNotification:($,U)=>EF(gu0($),U),hasInputRequestMethod:()=>!1,validateInputRequest:()=>kt,validateInputResponse:()=>kt,samplingResultVariant:($,U)=>{let Y=tt();return EF($?Y.CreateMessageResultWithToolsSchema:Y.CreateMessageResultSchema,U)},outboundEnvelope:($)=>{return},validateEnvelopeMeta:($)=>[],projectCallToolResult($,U){let Y=st($),z=Y.structuredContent;if(z===void 0)return Y;let I=typeof z!=="object"||z===null||Array.isArray(z),Q=U!==void 0&&et(U);if(!I&&!Q)return Y;return{...Y,structuredContent:{result:z}}},decodeResult($,U){if(IS(U)&&"resultType"in U){let Y={...U};return delete Y.resultType,{kind:"complete",result:ft(Y)}}return{kind:"complete",result:ft(U)}},encodeResult($,U){if($!=="tools/list")return U;l Line truncated
* content-type
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/Hb0=C0(($)=>{var Y=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,z=/\\([\u000b\u0020-\u00ff])/g,U=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;$.parse=Q;function Q(K){if(!K)throw TypeError("argument string is required");var G=typeof K==="object"?J(K):K;if(typeof G!=="string")throw TypeError("argument string is required to be a string");var H=G.indexOf(";"),W=H!==-1?G.slice(0,H).trim():G.trim();if(!U.test(W))throw TypeError("invalid media type");var X=new I(W.toLowerCase());if(H!==-1){var Z,q,V;Y.lastIndex=H;while(q=Y.exec(G)){if(q.index!==H)throw TypeError("invalid parameter format");if(H+=q[0].length,Z=q[1].toLowerCase(),V=q[2],V.charCodeAt(0)===34){if(V=V.slice(1,-1),V.indexOf("\\")!==-1)V=V.replace(z,"$1")}X.parameters[Z]=V}if(H!==G.length)throw TypeError("invalid parameter format")}return X}function J(K){var G;if(typeof K.getHeader==="function")G=K.getHeader("content-type");else if(typeof K.headers==="object")G=K.headers&&K.headers["content-type"];if(typeof G!=="string")throw TypeError("content-type header is missing from object");return G}function I(K){this.parameters=Object.create(null),this.type=K}}),Yb1=sq(Hb0(),1);Wb0=/^[A-Za-z0-9._-]{1,128}$/});function OS($){let Y=new $({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return vi0(Y),Y}var fO,Ze,F1,v1,Q5,bO,Fb0,qe,Ve,uO,Ob0,J5,wb0,Mb0,Le,Nb0,iO,uQ,OH,bQ,nO,Db0,Fe,Ab0,Bb0,Pb0,wS,jb0,MS,Oe,Tb0,Eb0,Cb0,Rb0,_b0,vb0,hb0,Sb0,NS,gb0,yb0,kb0,we,Me,Ne,xb0,fb0,ub0,DS,bb0,De,ib0,nb0,cb0,pb0,db0,mb0,lb0,ob0,Ae,rb0,Be,Pe,je,sb0,AS,ab0,Te,Ee,Ce,tb0,eb0,Re,$i0,Yi0,zi0,_e,Ui0,Qi0,ve,Ji0,Ii0,Ki0,Gi0,Hi0,Wi0,Xi0,Zi0,qi0,Vi0,Li0,Fi0,Oi0,wi0,Mi0,Ni0,Di0,Ai0,Bi0,Pi0,ji0,Ti0,Ei0,he,Ci0,Ri0,_i0,vi0,cO=class{_ajv;_ajvDraft7;_ajv2019;_userAjv;constructor($){this._userAjv=$!==void 0,this._ajv=$}get ajv(){return this._ajv??=OS(Ri0.Ajv2020)}_engineFor($){if(this._userAjv)return this.ajv;let Y=Xr($,"pass a pre-configured Ajv instance to AjvJsonSchemaValidator(ajv) to validate other dialects.");if(Y==="2020-12")return this.ajv;if(Y==="2019-09")return this._ajv2019??=OS(Ci0.Ajv2019);return this._ajvDraft7??=OS(he.Ajv)}getValidator($){let Y=this._engineFor($),z="$id"in $&&typeof $.$id==="string"?Y.getSchema($.$id)??Y.compile($):Y.compile($);return(U)=>{return z(U)?{valid:!0,data:U,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:Y.errorsText(z.errors)}}}},qb1;var Se=m(()=>{KT();GT();fO=C0(($)=>{Object.defineProperty($,"__esModule",{value:!0}),$.regexpCode=$.getEsmExportName=$.getProperty=$.safeStringify=$.stringify=$.strConcat=$.addCodeArg=$.str=$._=$.nil=$._Code=$.Name=$.IDENTIFIER=$._CodeOrName=void 0;var Y=class{};$._CodeOrName=Y,$.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var z=class extends Y{constructor(O){super();if(!$.IDENTIFIER.test(O))throw Error("CodeGen: name must be a valid identifier");this.str=O}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};$.Name=z;var U=class extends Y{constructor(O){super();this._items=typeof O==="string"?[O]:O}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let O=this._items[0];return O===""||O==='""'}get str(){var O;return(O=this._str)!==null&&O!==void 0?O:this._str=this._items.reduce((N,M)=>`${N}${M}`,"")}get names(){var O;return(O=this._names)!==null&&O!==void 0?O:this._names=this._items.reduce((N,M)=>{if(M instanceof z)N[M.str]=(N[M.str]||0)+1;return N},{})}};$._Code=U,$.nil=new U("");function Q(O,...N){let M=[O[0]],D=0;while(D<N.length)K(M,N[D]),M.push(O[++D]);return new U(M)}$._=Q;let J=new U("+");function I(O,...N){let M=[q(O[0])],D=0;while(D<N.length)M.push(J),K(M,N[D]),M.push(J,q(O[++D]));return G(M),new U(M)}$.str=I;function K(O,N){if(N instanceof U)O.push(...N._items);else if(N instanceof z)O.push(N);else O.push(X(N))}$.addCodeArg=K;function G(O){let N=1;while(N<O.length-1){if(O[N]===J){let M=H(O[N-1],O[N+1]);if(M!==void 0){O.splice(N-1,3,M);continue}O[N++]="+"}N++}}function H(O,N){if(N==='""')return O;if(O==='""')return N;if(typeof O=="string"){if(N instanceof z||O[O.length-1]!=='"')return;if(typeof N!="string")return`${O.slice(0,-1)}${N}"`;if(N[0]==='"')return O.slice(0,-1)+N.slice(1);return}if(typeof N=="string"&&N[0]==='"'&&!(O instanceof z))return`"${O}${N.slice(1)}`}function W(O,N){return N.emptyStr()?O:O.emptyStr()?N:I`${O}${N}`}$.strConcat=W;function X(O){return typeof O=="number"||typeof O=="boolean"||O===null?O:q(Array.isArray(O)?O.join(","):O)}function Z(O){return new U(q(O))}$.stringify=Z;function q(O){return JSON.stringify(O).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}$.safeStringify=q;function V(O){return typeof O=="string"&&$.IDENTIFIER.test(O)?new U(`.${O}`):Q`[${O}]`}$.getProperty=V;function F(O){if(typeof O=="string"&&$.IDENTIFIER.test(O))return new U(`${O}`);throw Error(`CodeGen: invalid export name: ${O}, use explicit $id name mapping`)}$.getEsmExportName=F;function w(O){return new U(O.toStringLine truncated
`:""},this._extScope=y,this._scope=new z.Scope({parent:y}),this._nodes=[new F]}toString(){return this._root.render(this.opts)}name(y){return this._scope.name(y)}scopeName(y){return this._extScope.name(y)}scopeValue(y,r){let $0=this._extScope.value(y,r);return(this._values[$0.prefix]||(this._values[$0.prefix]=new Set)).add($0),$0}getScopeValue(y,r){return this._extScope.getValue(y,r)}scopeRefs(y){return this._extScope.scopeRefs(y,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(y,r,$0,N0){let T0=this._scope.toName(r);if($0!==void 0&&N0)this._constants[T0.str]=$0;return this._leafNode(new I(y,T0,$0)),T0}const(y,r,$0){return this._def(z.varKinds.const,y,r,$0)}let(y,r,$0){return this._def(z.varKinds.let,y,r,$0)}var(y,r,$0){return this._def(z.varKinds.var,y,r,$0)}assign(y,r,$0){return this._leafNode(new K(y,r,$0))}add(y,r){return this._leafNode(new G(y,$.operators.ADD,r))}code(y){if(typeof y=="function")y();else if(y!==Y.nil)this._leafNode(new Z(y));return this}object(...y){let r=["{"];for(let[$0,N0]of y){if(r.length>1)r.push(",");if(r.push($0),$0!==N0||this.opts.es5)r.push(":"),(0,Y.addCodeArg)(r,N0)}return r.push("}"),new Y._Code(r)}if(y,r,$0){if(this._blockNode(new O(y)),r&&$0)this.code(r).else().code($0).endIf();else if(r)this.code(r).endIf();else if($0)throw Error('CodeGen: "else" body without "then" body');return this}elseIf(y){return this._elseNode(new O(y))}else(){return this._elseNode(new w)}endIf(){return this._endBlockNode(O,w)}_for(y,r){if(this._blockNode(y),r)this.code(r).endFor();return this}for(y,r){return this._for(new M(y),r)}forRange(y,r,$0,N0,T0=this.opts.es5?z.varKinds.var:z.varKinds.let){let _0=this._scope.toName(y);return this._for(new D(T0,_0,r,$0),()=>N0(_0))}forOf(y,r,$0,N0=z.varKinds.const){let T0=this._scope.toName(y);if(this.opts.es5){let _0=r instanceof Y.Name?r:this.var("_arr",r);return this.forRange("_i",0,Y._`${_0}.length`,(G0)=>{this.var(T0,Y._`${_0}[${G0}]`),$0(T0)})}return this._for(new P("of",N0,T0,r),()=>$0(T0))}forIn(y,r,$0,N0=this.opts.es5?z.varKinds.var:z.varKinds.const){if(this.opts.ownProperties)return this.forOf(y,Y._`Object.keys(${r})`,$0);let T0=this._scope.toName(y);return this._for(new P("in",N0,T0,r),()=>$0(T0))}endFor(){return this._endBlockNode(N)}label(y){return this._leafNode(new H(y))}break(y){return this._leafNode(new W(y))}return(y){let r=new A;if(this._blockNode(r),this.code(y),r.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(A)}try(y,r,$0){if(!r&&!$0)throw Error('CodeGen: "try" without "catch" and "finally"');let N0=new T;if(this._blockNode(N0),this.code(y),r){let T0=this.name("e");this._currNode=N0.catch=new C(T0),r(T0)}if($0)this._currNode=N0.finally=new b,this.code($0);return this._endBlockNode(C,b)}throw(y){return this._leafNode(new X(y))}block(y,r){if(this._blockStarts.push(this._nodes.length),y)this.code(y).endBlock(r);return this}endBlock(y){let r=this._blockStarts.pop();if(r===void 0)throw Error("CodeGen: not in self-balancing block");let $0=this._nodes.length-r;if($0<0||y!==void 0&&$0!==y)throw Error(`CodeGen: wrong number of nodes: ${$0} vs ${y} expected`);return this._nodes.length=r,this}func(y,r=Y.nil,$0,N0){if(this._blockNode(new j(y,r,$0)),N0)this.code(N0).endFunc();return this}endFunc(){return this._endBlockNode(j)}optimize(y=1){while(y-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(y){return this._currNode.nodes.push(y),this}_blockNode(y){this._currNode.nodes.push(y),this._nodes.push(y)}_endBlockNode(y,r){let $0=this._currNode;if($0 instanceof y||r&&$0 instanceof r)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${r?`${y.kind}/${r.kind}`:y.kind}"`)}_elseNode(y){let r=this._currNode;if(!(r instanceof O))throw Error('CodeGen: "else" without "if"');return this._currNode=r.else=y,this}get _root(){return this._nodes[0]}get _currNode(){let y=this._nodes;return y[y.length-1]}set _currNode(y){let r=this._nodes;r[r.length-1]=y}};$.CodeGen=k;function S(y,r){for(let $0 in r)y[$0]=(y[$0]||0)+(r[$0]||0);return y}function i(y,r){return r instanceof Y._CodeOrName?S(y,r.names):y}function n(y,r,$0){if(y instanceof Y.Name)return N0(y);if(!T0(y))return y;return new Y._Code(y._items.reduce((_0,G0)=>{if(G0 instanceof Y.Name)G0=N0(G0);if(G0 instanceof Y._Code)_0.push(...G0._items);else _0.push(G0);return _0},[]));function N0(_0){let G0=$0[_0.str];if(G0===void 0||r[_0.str]!==1)return _0;return delete r[_0.str],G0}function T0(_0){return _0 instanceof Y._Code&&_0._items.some((G0)=>G0 instanceof Y.Name&&r[G0.str]===1&&$0[G0.str]!==void 0)}}function U0(y,r){for(let $0 in r)y[$0]=(y[$0]||0)-(r[$0]||0)}function x(y){return typeof y=="boolean"||typeof y=="number"||y===null?!y:Y._`!${Y0(y)}`}$.not=x;let d=p($.operators.AND);function t(...y){return y.reduce(d)}$.and=t;let e=p($.operators.OR);function g(...y){return y.reduce(e)}$.or=g;function p(y){return(r,$0)=>r===Y.nil?$0:$0===Y.nil?r:Y._`${Y0(r)} ${y} ${Y0($0)}`}function Line truncated
|| (${C} == "string" && ${A} && ${A} == +${A})`).assign(b,Q._`+${A}`);return;case"integer":j.elseIf(Q._`${C} === "boolean" || ${A} === null
|| (${C} === "string" && ${A} && ${A} == +${A} && !(${A} % 1))`).assign(b,Q._`+${A}`);return;case"boolean":j.elseIf(Q._`${A} === "false" || ${A} === 0 || ${A} === null`).assign(b,!1).elseIf(Q._`${A} === "true" || ${A} === 1`).assign(b,!0);return;case"null":j.elseIf(Q._`${A} === "" || ${A} === 0 || ${A} === false`),j.assign(b,null);return;case"array":j.elseIf(Q._`${C} === "string" || ${C} === "number"
|| ${C} === "boolean" || ${A} === null`).assign(b,Q._`[${A}]`)}}}function q({gen:M,parentData:D,parentDataProperty:P},j){M.if(Q._`${D} !== undefined`,()=>M.assign(Q._`${D}[${P}]`,j))}function V(M,D,P,j=I.Correct){let A=j===I.Correct?Q.operators.EQ:Q.operators.NEQ,T;switch(M){case"null":return Q._`${D} ${A} null`;case"array":T=Q._`Array.isArray(${D})`;break;case"object":T=Q._`${D} && typeof ${D} == "object" && !Array.isArray(${D})`;break;case"integer":T=C(Q._`!(${D} % 1) && !isNaN(${D})`);break;case"number":T=C();break;default:return Q._`typeof ${D} ${A} ${M}`}return j===I.Correct?T:(0,Q.not)(T);function C(b=Q.nil){return(0,Q.and)(Q._`typeof ${D} == "number"`,b,P?Q._`isFinite(${D})`:Q.nil)}}$.checkDataType=V;function F(M,D,P,j){if(M.length===1)return V(M[0],D,P,j);let A,T=(0,J.toHash)(M);if(T.array&&T.object){let C=Q._`typeof ${D} != "object"`;A=T.null?C:Q._`!${D} || ${C}`,delete T.null,delete T.array,delete T.object}else A=Q.nil;if(T.number)delete T.integer;for(let C in T)A=(0,Q.and)(A,V(C,D,P,j));return A}$.checkDataTypes=F;let w={message:({schema:M})=>`must be ${M}`,params:({schema:M,schemaValue:D})=>typeof M=="string"?Q._`{type: ${M}}`:Q._`{type: ${D}}`};function O(M){let D=N(M);(0,U.reportError)(D,w)}$.reportTypeError=O;function N(M){let{gen:D,data:P,schema:j}=M,A=(0,J.schemaRefOrVal)(M,j,"type");return{gen:D,keyword:"type",data:P,schema:j.type,schemaCode:A,schemaValue:A,parentSchema:j,params:{},it:M}}}),Ob0=C0(($)=>{Object.defineProperty($,"__esModule",{value:!0}),$.assignDefaults=void 0;let Y=F1(),z=v1();function U(J,I){let{properties:K,items:G}=J.schema;if(I==="object"&&K)for(let H in K)Q(J,H,K[H].default);else if(I==="array"&&Array.isArray(G))G.forEach((H,W)=>Q(J,W,H.default))}$.assignDefaults=U;function Q(J,I,K){let{gen:G,compositeRule:H,data:W,opts:X}=J;if(K===void 0)return;let Z=Y._`${W}${(0,Y.getProperty)(I)}`;if(H){(0,z.checkStrictMode)(J,`default is ignored for: ${Z}`);return}let q=Y._`${Z} === undefined`;if(X.useDefaults==="empty")q=Y._`${q} || ${Z} === null || ${Z} === ""`;G.if(q,Y._`${Z} = ${(0,Y.stringify)(K)}`)}}),J5=C0(($)=>{Object.defineProperty($,"__esModule",{value:!0}),$.validateUnion=$.validateArray=$.usePattern=$.callValidateCode=$.schemaProperties=$.allSchemaProperties=$.noPropertyInData=$.propertyInData=$.isOwnProperty=$.hasPropFunc=$.reportMissingProp=$.checkMissingProp=$.checkReportMissingProp=void 0;let Y=F1(),z=v1(),U=Q5(),Q=v1();function J(M,D){let{gen:P,data:j,it:A}=M;P.if(X(P,j,D,A.opts.ownProperties),()=>{M.setParams({missingProperty:Y._`${D}`},!0),M.error()})}$.checkReportMissingProp=J;function I({gen:M,data:D,it:{opts:P}},j,A){return(0,Y.or)(...j.map((T)=>(0,Y.and)(X(M,D,T,P.ownProperties),Y._`${A} = ${T}`)))}$.checkMissingProp=I;function K(M,D){M.setParams({missingProperty:D},!0),M.error()}$.reportMissingProp=K;function G(M){return M.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:Y._`Object.prototype.hasOwnProperty`})}$.hasPropFunc=G;function H(M,D,P){return Y._`${G(M)}.call(${D}, ${P})`}$.isOwnProperty=H;function W(M,D,P,j){let A=Y._`${D}${(0,Y.getProperty)(P)} !== undefined`;return j?Y._`${A} && ${H(M,D,P)}`:A}$.propertyInData=W;function X(M,D,P,j){let A=Y._`${D}${(0,Y.getProperty)(P)} === undefined`;return j?(0,Y.or)(A,(0,Y.not)(H(M,D,P))):A}$.noPropertyInData=X;function Z(M){return M?Object.keys(M).filter((D)=>D!=="__proto__"):[]}$.allSchemaProperties=Z;function q(M,D){return Z(D).filter((P)=>!(0,z.alwaysValidSchema)(M,D[P]))}$.schemaProperties=q;function V({schemaCode:M,data:D,it:{gen:P,topSchemaRef:j,schemaPath:A,errorPath:T},it:C},b,k,S){let i=S?Y._`${M}, ${D}, ${j}${A}`:D,n=[[U.default.instancePath,(0,Y.strConcat)(U.default.instancePath,T)],[U.default.parentData,C.parentData],[U.default.parentDataProperty,C.parentDataProperty],[U.default.rootData,U.default.rootData]];if(C.opts.dynamicRef)n.push([U.default.dynamicAnchors,U.default.dynamicAnchors]);let U0=Y._`${i}, ${P.object(...n)}`;return k!==Y.nil?Y._`${b}.call(${k}, ${U0})`:Y._`${b}(${U0})`}$.callValidateCode=V;let F=Y._`new RegExp`;function w({gen:M,it:{opts:D}},P){let j=D.unicodeRegExp?"u":"",{regExp:A}=D.code,T=A(P,j);return M.scopeValue("pattern",{key:T.toString(),ref:T,code:Y._`${A.code==="new RegExp"?F:(0,Q.useFunc)(M,A)}(${P}, ${j})`})}$.usePattern=w;function O(M){let{gen:D,data:P,keyword:j,it:A}=M,T=D.name("valid");if(A.allErrors){let b=D.let("valid",!0);return C(()=>D.assign(b,!1)),b}return D.var(T,!0),C(()=>D.break()),T;function C(b){let k=D.const("len",Y._`${P}.length`);D.forRange("i",0,k,(S)=>{M.subschema({keyword:j,dataProp:S,dataPropType:z.Type.Num},T),D.if((0,Y.not)(T),b)})}}$.validateArray=O;function N(M){let{gen:D,schema:P,keyword:j,it:A}=M;if(!Array.isArray(P))throw Error("ajv implementation error");if(P.some((b)=>(0,z.alwaysValidSchema)(A,b))&&!A.opts.unevaluated)return;let T=D.let("valid",!1),C=D.name("_valid");D.block(()=>P.forEach((b,k)=>{let S=M.subschema({keyword:j,schemaProp:k,compositeRule:!0},C);if(D.assign(T,Y._`${T} || ${C}`),!M.mergeValidEvaluated(S,C) Line truncated
*/fb0=E0(($)=>{var U=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,Y=/\\([\u000b\u0020-\u00ff])/g,z=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;$.parse=I;function I(K){if(!K)throw TypeError("argument string is required");var G=typeof K==="object"?Q(K):K;if(typeof G!=="string")throw TypeError("argument string is required to be a string");var H=G.indexOf(";"),W=H!==-1?G.slice(0,H).trim():G.trim();if(!z.test(W))throw TypeError("invalid media type");var X=new J(W.toLowerCase());if(H!==-1){var Z,q,V;U.lastIndex=H;while(q=U.exec(G)){if(q.index!==H)throw TypeError("invalid parameter format");if(H+=q[0].length,Z=q[1].toLowerCase(),V=q[2],V.charCodeAt(0)===34){if(V=V.slice(1,-1),V.indexOf("\\")!==-1)V=V.replace(Y,"$1")}X.parameters[Z]=V}if(H!==G.length)throw TypeError("invalid parameter format")}return X}function Q(K){var G;if(typeof K.getHeader==="function")G=K.getHeader("content-type");else if(typeof K.headers==="object")G=K.headers&&K.headers["content-type"];if(typeof G!=="string")throw TypeError("content-type header is missing from object");return G}function J(K){this.parameters=Object.create(null),this.type=K}}),Sb1=YV(fb0(),1);ub0=/^[A-Za-z0-9._-]{1,128}$/});function _S($){let U=new $({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return Jn0(U),U}var dF,Pe,w1,v1,K5,mF,pb0,Te,je,pF,mb0,G5,lb0,ob0,Ee,rb0,lF,bI,MH,iI,oF,sb0,Ce,ab0,tb0,eb0,vS,$i0,hS,Re,Ui0,Yi0,zi0,Ii0,Qi0,Ji0,Ki0,Gi0,SS,Hi0,Wi0,Xi0,_e,ve,he,Zi0,qi0,Vi0,gS,Li0,Se,wi0,Fi0,Mi0,Oi0,Ni0,Di0,Ai0,Bi0,ge,Pi0,ye,ke,xe,Ti0,yS,ji0,fe,ue,be,Ei0,Ci0,ie,Ri0,_i0,vi0,ne,hi0,Si0,ce,gi0,yi0,ki0,xi0,fi0,ui0,bi0,ii0,ni0,ci0,di0,pi0,mi0,li0,oi0,ri0,si0,ai0,ti0,ei0,$n0,Un0,Yn0,de,zn0,In0,Qn0,Jn0,rF=class{_ajv;_ajvDraft7;_ajv2019;_userAjv;constructor($){this._userAjv=$!==void 0,this._ajv=$}get ajv(){return this._ajv??=_S(In0.Ajv2020)}_engineFor($){if(this._userAjv)return this.ajv;let U=Br($,"pass a pre-configured Ajv instance to AjvJsonSchemaValidator(ajv) to validate other dialects.");if(U==="2020-12")return this.ajv;if(U==="2019-09")return this._ajv2019??=_S(zn0.Ajv2019);return this._ajvDraft7??=_S(de.Ajv)}getValidator($){let U=this._engineFor($),Y="$id"in $&&typeof $.$id==="string"?U.getSchema($.$id)??U.compile($):U.compile($);return(z)=>{return Y(z)?{valid:!0,data:z,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:U.errorsText(Y.errors)}}}},pb1;var pe=m(()=>{Nj();Dj();dF=E0(($)=>{Object.defineProperty($,"__esModule",{value:!0}),$.regexpCode=$.getEsmExportName=$.getProperty=$.safeStringify=$.stringify=$.strConcat=$.addCodeArg=$.str=$._=$.nil=$._Code=$.Name=$.IDENTIFIER=$._CodeOrName=void 0;var U=class{};$._CodeOrName=U,$.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Y=class extends U{constructor(w){super();if(!$.IDENTIFIER.test(w))throw Error("CodeGen: name must be a valid identifier");this.str=w}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};$.Name=Y;var z=class extends U{constructor(w){super();this._items=typeof w==="string"?[w]:w}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let w=this._items[0];return w===""||w==='""'}get str(){var w;return(w=this._str)!==null&&w!==void 0?w:this._str=this._items.reduce((N,O)=>`${N}${O}`,"")}get names(){var w;return(w=this._names)!==null&&w!==void 0?w:this._names=this._items.reduce((N,O)=>{if(O instanceof Y)N[O.str]=(N[O.str]||0)+1;return N},{})}};$._Code=z,$.nil=new z("");function I(w,...N){let O=[w[0]],D=0;while(D<N.length)K(O,N[D]),O.push(w[++D]);return new z(O)}$._=I;let Q=new z("+");function J(w,...N){let O=[q(w[0])],D=0;while(D<N.length)O.push(Q),K(O,N[D]),O.push(Q,q(w[++D]));return G(O),new z(O)}$.str=J;function K(w,N){if(N instanceof z)w.push(...N._items);else if(N instanceof Y)w.push(N);else w.push(X(N))}$.addCodeArg=K;function G(w){let N=1;while(N<w.length-1){if(w[N]===Q){let O=H(w[N-1],w[N+1]);if(O!==void 0){w.splice(N-1,3,O);continue}w[N++]="+"}N++}}function H(w,N){if(N==='""')return w;if(w==='""')return N;if(typeof w=="string"){if(N instanceof Y||w[w.length-1]!=='"')return;if(typeof N!="string")return`${w.slice(0,-1)}${N}"`;if(N[0]==='"')return w.slice(0,-1)+N.slice(1);return}if(typeof N=="string"&&N[0]==='"'&&!(w instanceof Y))return`"${w}${N.slice(1)}`}function W(w,N){return N.emptyStr()?w:w.emptyStr()?N:J`${w}${N}`}$.strConcat=W;function X(w){return typeof w=="number"||typeof w=="boolean"||w===null?w:q(Array.isArray(w)?w.join(","):w)}function Z(w){return new z(q(w))}$.stringify=Z;function q(w){return JSON.stringify(w).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}$.safeStringify=q;function V(w){return typeof w=="string"&&$.IDENTIFIER.test(w)?new z(`.${w}`):I`[${w}]`}$.getProperty=V;function F(w){if(typeof w=="string"&&$.IDENTIFIER.test(w))return new z(`${w}`);throw Error(`CodeGen: invalid export name: ${w}, use explicit $id name mapping`)}$.getEsmExportName=F;function M(w){return new z(w.toStringLine truncated
`:""},this._extScope=R,this._scope=new Y.Scope({parent:R}),this._nodes=[new F]}toString(){return this._root.render(this.opts)}name(R){return this._scope.name(R)}scopeName(R){return this._extScope.name(R)}scopeValue(R,o){let e=this._extScope.value(R,o);return(this._values[e.prefix]||(this._values[e.prefix]=new Set)).add(e),e}getScopeValue(R,o){return this._extScope.getValue(R,o)}scopeRefs(R){return this._extScope.scopeRefs(R,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(R,o,e,O0){let T0=this._scope.toName(o);if(e!==void 0&&O0)this._constants[T0.str]=e;return this._leafNode(new J(R,T0,e)),T0}const(R,o,e){return this._def(Y.varKinds.const,R,o,e)}let(R,o,e){return this._def(Y.varKinds.let,R,o,e)}var(R,o,e){return this._def(Y.varKinds.var,R,o,e)}assign(R,o,e){return this._leafNode(new K(R,o,e))}add(R,o){return this._leafNode(new G(R,$.operators.ADD,o))}code(R){if(typeof R=="function")R();else if(R!==U.nil)this._leafNode(new Z(R));return this}object(...R){let o=["{"];for(let[e,O0]of R){if(o.length>1)o.push(",");if(o.push(e),e!==O0||this.opts.es5)o.push(":"),(0,U.addCodeArg)(o,O0)}return o.push("}"),new U._Code(o)}if(R,o,e){if(this._blockNode(new w(R)),o&&e)this.code(o).else().code(e).endIf();else if(o)this.code(o).endIf();else if(e)throw Error('CodeGen: "else" body without "then" body');return this}elseIf(R){return this._elseNode(new w(R))}else(){return this._elseNode(new M)}endIf(){return this._endBlockNode(w,M)}_for(R,o){if(this._blockNode(R),o)this.code(o).endFor();return this}for(R,o){return this._for(new O(R),o)}forRange(R,o,e,O0,T0=this.opts.es5?Y.varKinds.var:Y.varKinds.let){let y0=this._scope.toName(R);return this._for(new D(T0,y0,o,e),()=>O0(y0))}forOf(R,o,e,O0=Y.varKinds.const){let T0=this._scope.toName(R);if(this.opts.es5){let y0=o instanceof U.Name?o:this.var("_arr",o);return this.forRange("_i",0,U._`${y0}.length`,(v0)=>{this.var(T0,U._`${y0}[${v0}]`),e(T0)})}return this._for(new P("of",O0,T0,o),()=>e(T0))}forIn(R,o,e,O0=this.opts.es5?Y.varKinds.var:Y.varKinds.const){if(this.opts.ownProperties)return this.forOf(R,U._`Object.keys(${o})`,e);let T0=this._scope.toName(R);return this._for(new P("in",O0,T0,o),()=>e(T0))}endFor(){return this._endBlockNode(N)}label(R){return this._leafNode(new H(R))}break(R){return this._leafNode(new W(R))}return(R){let o=new A;if(this._blockNode(o),this.code(R),o.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(A)}try(R,o,e){if(!o&&!e)throw Error('CodeGen: "try" without "catch" and "finally"');let O0=new j;if(this._blockNode(O0),this.code(R),o){let T0=this.name("e");this._currNode=O0.catch=new C(T0),o(T0)}if(e)this._currNode=O0.finally=new b,this.code(e);return this._endBlockNode(C,b)}throw(R){return this._leafNode(new X(R))}block(R,o){if(this._blockStarts.push(this._nodes.length),R)this.code(R).endBlock(o);return this}endBlock(R){let o=this._blockStarts.pop();if(o===void 0)throw Error("CodeGen: not in self-balancing block");let e=this._nodes.length-o;if(e<0||R!==void 0&&e!==R)throw Error(`CodeGen: wrong number of nodes: ${e} vs ${R} expected`);return this._nodes.length=o,this}func(R,o=U.nil,e,O0){if(this._blockNode(new T(R,o,e)),O0)this.code(O0).endFunc();return this}endFunc(){return this._endBlockNode(T)}optimize(R=1){while(R-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(R){return this._currNode.nodes.push(R),this}_blockNode(R){this._currNode.nodes.push(R),this._nodes.push(R)}_endBlockNode(R,o){let e=this._currNode;if(e instanceof R||o&&e instanceof o)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${o?`${R.kind}/${o.kind}`:R.kind}"`)}_elseNode(R){let o=this._currNode;if(!(o instanceof w))throw Error('CodeGen: "else" without "if"');return this._currNode=o.else=R,this}get _root(){return this._nodes[0]}get _currNode(){let R=this._nodes;return R[R.length-1]}set _currNode(R){let o=this._nodes;o[o.length-1]=R}};$.CodeGen=x;function g(R,o){for(let e in o)R[e]=(R[e]||0)+(o[e]||0);return R}function i(R,o){return o instanceof U._CodeOrName?g(R,o.names):R}function n(R,o,e){if(R instanceof U.Name)return O0(R);if(!T0(R))return R;return new U._Code(R._items.reduce((y0,v0)=>{if(v0 instanceof U.Name)v0=O0(v0);if(v0 instanceof U._Code)y0.push(...v0._items);else y0.push(v0);return y0},[]));function O0(y0){let v0=e[y0.str];if(v0===void 0||o[y0.str]!==1)return y0;return delete o[y0.str],v0}function T0(y0){return y0 instanceof U._Code&&y0._items.some((v0)=>v0 instanceof U.Name&&o[v0.str]===1&&e[v0.str]!==void 0)}}function z0(R,o){for(let e in o)R[e]=(R[e]||0)-(o[e]||0)}function k(R){return typeof R=="boolean"||typeof R=="number"||R===null?!R:U._`!${U0(R)}`}$.not=k;let p=d($.operators.AND);function a(...R){return R.reduce(p)}$.and=a;let $0=d($.operators.OR);function y(...R){return R.reduce($0)}$.or=y;function d(R){return(o,e)=>o===U.nil?e:e===U.nil?o:U._`${U0(o)} ${R} ${U0(e)}`}function U0(R){return R instanceof U.Name?R:U._`(${R})`}}),v1=E0(( Line truncated
|| (${C} == "string" && ${A} && ${A} == +${A})`).assign(b,I._`+${A}`);return;case"integer":T.elseIf(I._`${C} === "boolean" || ${A} === null
|| (${C} === "string" && ${A} && ${A} == +${A} && !(${A} % 1))`).assign(b,I._`+${A}`);return;case"boolean":T.elseIf(I._`${A} === "false" || ${A} === 0 || ${A} === null`).assign(b,!1).elseIf(I._`${A} === "true" || ${A} === 1`).assign(b,!0);return;case"null":T.elseIf(I._`${A} === "" || ${A} === 0 || ${A} === false`),T.assign(b,null);return;case"array":T.elseIf(I._`${C} === "string" || ${C} === "number"
|| ${C} === "boolean" || ${A} === null`).assign(b,I._`[${A}]`)}}}function q({gen:O,parentData:D,parentDataProperty:P},T){O.if(I._`${D} !== undefined`,()=>O.assign(I._`${D}[${P}]`,T))}function V(O,D,P,T=J.Correct){let A=T===J.Correct?I.operators.EQ:I.operators.NEQ,j;switch(O){case"null":return I._`${D} ${A} null`;case"array":j=I._`Array.isArray(${D})`;break;case"object":j=I._`${D} && typeof ${D} == "object" && !Array.isArray(${D})`;break;case"integer":j=C(I._`!(${D} % 1) && !isNaN(${D})`);break;case"number":j=C();break;default:return I._`typeof ${D} ${A} ${O}`}return T===J.Correct?j:(0,I.not)(j);function C(b=I.nil){return(0,I.and)(I._`typeof ${D} == "number"`,b,P?I._`isFinite(${D})`:I.nil)}}$.checkDataType=V;function F(O,D,P,T){if(O.length===1)return V(O[0],D,P,T);let A,j=(0,Q.toHash)(O);if(j.array&&j.object){let C=I._`typeof ${D} != "object"`;A=j.null?C:I._`!${D} || ${C}`,delete j.null,delete j.array,delete j.object}else A=I.nil;if(j.number)delete j.integer;for(let C in j)A=(0,I.and)(A,V(C,D,P,T));return A}$.checkDataTypes=F;let M={message:({schema:O})=>`must be ${O}`,params:({schema:O,schemaValue:D})=>typeof O=="string"?I._`{type: ${O}}`:I._`{type: ${D}}`};function w(O){let D=N(O);(0,z.reportError)(D,M)}$.reportTypeError=w;function N(O){let{gen:D,data:P,schema:T}=O,A=(0,Q.schemaRefOrVal)(O,T,"type");return{gen:D,keyword:"type",data:P,schema:T.type,schemaCode:A,schemaValue:A,parentSchema:T,params:{},it:O}}}),mb0=E0(($)=>{Object.defineProperty($,"__esModule",{value:!0}),$.assignDefaults=void 0;let U=w1(),Y=v1();function z(Q,J){let{properties:K,items:G}=Q.schema;if(J==="object"&&K)for(let H in K)I(Q,H,K[H].default);else if(J==="array"&&Array.isArray(G))G.forEach((H,W)=>I(Q,W,H.default))}$.assignDefaults=z;function I(Q,J,K){let{gen:G,compositeRule:H,data:W,opts:X}=Q;if(K===void 0)return;let Z=U._`${W}${(0,U.getProperty)(J)}`;if(H){(0,Y.checkStrictMode)(Q,`default is ignored for: ${Z}`);return}let q=U._`${Z} === undefined`;if(X.useDefaults==="empty")q=U._`${q} || ${Z} === null || ${Z} === ""`;G.if(q,U._`${Z} = ${(0,U.stringify)(K)}`)}}),G5=E0(($)=>{Object.defineProperty($,"__esModule",{value:!0}),$.validateUnion=$.validateArray=$.usePattern=$.callValidateCode=$.schemaProperties=$.allSchemaProperties=$.noPropertyInData=$.propertyInData=$.isOwnProperty=$.hasPropFunc=$.reportMissingProp=$.checkMissingProp=$.checkReportMissingProp=void 0;let U=w1(),Y=v1(),z=K5(),I=v1();function Q(O,D){let{gen:P,data:T,it:A}=O;P.if(X(P,T,D,A.opts.ownProperties),()=>{O.setParams({missingProperty:U._`${D}`},!0),O.error()})}$.checkReportMissingProp=Q;function J({gen:O,data:D,it:{opts:P}},T,A){return(0,U.or)(...T.map((j)=>(0,U.and)(X(O,D,j,P.ownProperties),U._`${A} = ${j}`)))}$.checkMissingProp=J;function K(O,D){O.setParams({missingProperty:D},!0),O.error()}$.reportMissingProp=K;function G(O){return O.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:U._`Object.prototype.hasOwnProperty`})}$.hasPropFunc=G;function H(O,D,P){return U._`${G(O)}.call(${D}, ${P})`}$.isOwnProperty=H;function W(O,D,P,T){let A=U._`${D}${(0,U.getProperty)(P)} !== undefined`;return T?U._`${A} && ${H(O,D,P)}`:A}$.propertyInData=W;function X(O,D,P,T){let A=U._`${D}${(0,U.getProperty)(P)} === undefined`;return T?(0,U.or)(A,(0,U.not)(H(O,D,P))):A}$.noPropertyInData=X;function Z(O){return O?Object.keys(O).filter((D)=>D!=="__proto__"):[]}$.allSchemaProperties=Z;function q(O,D){return Z(D).filter((P)=>!(0,Y.alwaysValidSchema)(O,D[P]))}$.schemaProperties=q;function V({schemaCode:O,data:D,it:{gen:P,topSchemaRef:T,schemaPath:A,errorPath:j},it:C},b,x,g){let i=g?U._`${O}, ${D}, ${T}${A}`:D,n=[[z.default.instancePath,(0,U.strConcat)(z.default.instancePath,j)],[z.default.parentData,C.parentData],[z.default.parentDataProperty,C.parentDataProperty],[z.default.rootData,z.default.rootData]];if(C.opts.dynamicRef)n.push([z.default.dynamicAnchors,z.default.dynamicAnchors]);let z0=U._`${i}, ${P.object(...n)}`;return x!==U.nil?U._`${b}.call(${x}, ${z0})`:U._`${b}(${z0})`}$.callValidateCode=V;let F=U._`new RegExp`;function M({gen:O,it:{opts:D}},P){let T=D.unicodeRegExp?"u":"",{regExp:A}=D.code,j=A(P,T);return O.scopeValue("pattern",{key:j.toString(),ref:j,code:U._`${A.code==="new RegExp"?F:(0,I.useFunc)(O,A)}(${P}, ${T})`})}$.usePattern=M;function w(O){let{gen:D,data:P,keyword:T,it:A}=O,j=D.name("valid");if(A.allErrors){let b=D.let("valid",!0);return C(()=>D.assign(b,!1)),b}return D.var(j,!0),C(()=>D.break()),j;function C(b){let x=D.const("len",U._`${P}.length`);D.forRange("i",0,x,(g)=>{O.subschema({keyword:T,dataProp:g,dataPropType:Y.Type.Num},j),D.if((0,U.not)(j),b)})}}$.validateArray=w;function N(O){let{gen:D,schema:P,keyword:T,it:A}=O;if(!Array.isArray(P))throw Error("ajv implementation error");if(P.some((b)=>(0,Y.alwaysValidSchema)(A,b))&&!A.opts.unevaluated)return;let j=D.let("valid",!1),C=D.name("_valid");D.block(()=>P.forEach((b,x)=>{let g=O.subschema({keyword:T,schemaProp:x,compositeRule:!0},C);if(D.assign(j,U._`${j} || ${C}`),!O.mergeValidEvaluated(g,C) Line truncated
missingProperty: ${X},
depsCount: ${H},
deps: ${W}}`};let Q={keyword:"dependencies",type:"object",schemaType:"object",error:$.error,code(G){let[H,W]=J(G);I(G,H),K(G,W)}};function J({schema:G}){let H={},W={};for(let X in G){if(X==="__proto__")continue;let Z=Array.isArray(G[X])?H:W;Z[X]=G[X]}return[H,W]}function I(G,H=G.schema){let{gen:W,data:X,it:Z}=G;if(Object.keys(H).length===0)return;let q=W.let("missing");for(let V in H){let F=H[V];if(F.length===0)continue;let w=(0,U.propertyInData)(W,X,V,Z.opts.ownProperties);if(G.setParams({property:V,depsCount:F.length,deps:F.join(", ")}),Z.allErrors)W.if(w,()=>{for(let O of F)(0,U.checkReportMissingProp)(G,O)});else W.if(Y._`${w} && (${(0,U.checkMissingProp)(G,F,q)})`),(0,U.reportMissingProp)(G,q),W.else()}}$.validatePropertyDeps=I;function K(G,H=G.schema){let{gen:W,data:X,keyword:Z,it:q}=G,V=W.name("valid");for(let F in H){if((0,z.alwaysValidSchema)(q,H[F]))continue;W.if((0,U.propertyInData)(W,X,F,q.opts.ownProperties),()=>{let w=G.subschema({keyword:Z,schemaProp:F},V);G.mergeValidEvaluated(w,V)},()=>W.var(V,!0)),G.ok(V)}}$.validateSchemaDeps=K,$.default=Q}),bb0=C0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let Y=F1(),z=v1(),U={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:Q})=>Y._`{propertyName: ${Q.propertyName}}`},code(Q){let{gen:J,schema:I,data:K,it:G}=Q;if((0,z.alwaysValidSchema)(G,I))return;let H=J.name("valid");J.forIn("key",K,(W)=>{Q.setParams({propertyName:W}),Q.subschema({keyword:"propertyNames",data:W,dataTypes:["string"],propertyName:W,compositeRule:!0},H),J.if((0,Y.not)(H),()=>{if(Q.error(!0),!G.allErrors)J.break()})}),Q.ok(H)}};$.default=U}),De=C0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let Y=J5(),z=F1(),U=Q5(),Q=v1(),J={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:I})=>z._`{additionalProperty: ${I.additionalProperty}}`},code(I){let{gen:K,schema:G,parentSchema:H,data:W,errsCount:X,it:Z}=I;if(!X)throw Error("ajv implementation error");let{allErrors:q,opts:V}=Z;if(Z.props=!0,V.removeAdditional!=="all"&&(0,Q.alwaysValidSchema)(Z,G))return;let F=(0,Y.allSchemaProperties)(H.properties),w=(0,Y.allSchemaProperties)(H.patternProperties);O(),I.ok(z._`${X} === ${U.default.errors}`);function O(){K.forIn("key",W,(j)=>{if(!F.length&&!w.length)D(j);else K.if(N(j),()=>D(j))})}function N(j){let A;if(F.length>8){let T=(0,Q.schemaRefOrVal)(Z,H.properties,"properties");A=(0,Y.isOwnProperty)(K,T,j)}else if(F.length)A=(0,z.or)(...F.map((T)=>z._`${j} === ${T}`));else A=z.nil;if(w.length)A=(0,z.or)(A,...w.map((T)=>z._`${(0,Y.usePattern)(I,T)}.test(${j})`));return(0,z.not)(A)}function M(j){K.code(z._`delete ${W}[${j}]`)}function D(j){if(V.removeAdditional==="all"||V.removeAdditional&&G===!1){M(j);return}if(G===!1){if(I.setParams({additionalProperty:j}),I.error(),!q)K.break();return}if(typeof G=="object"&&!(0,Q.alwaysValidSchema)(Z,G)){let A=K.name("valid");if(V.removeAdditional==="failing")P(j,A,!1),K.if((0,z.not)(A),()=>{I.reset(),M(j)});else if(P(j,A),!q)K.if((0,z.not)(A),()=>K.break())}}function P(j,A,T){let C={keyword:"additionalProperties",dataProp:j,dataPropType:Q.Type.Str};if(T===!1)Object.assign(C,{compositeRule:!0,createErrors:!1,allErrors:!1});I.subschema(C,A)}}};$.default=J}),ib0=C0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let Y=uQ(),z=J5(),U=v1(),Q=De(),J={keyword:"properties",type:"object",schemaType:"object",code(I){let{gen:K,schema:G,parentSchema:H,data:W,it:X}=I;if(X.opts.removeAdditional==="all"&&H.additionalProperties===void 0)Q.default.code(new Y.KeywordCxt(X,Q.default,"additionalProperties"));let Z=(0,z.allSchemaProperties)(G);for(let O of Z)X.definedProperties.add(O);if(X.opts.unevaluated&&Z.length&&X.props!==!0)X.props=U.mergeEvaluated.props(K,(0,U.toHash)(Z),X.props);let q=Z.filter((O)=>!(0,U.alwaysValidSchema)(X,G[O]));if(q.length===0)return;let V=K.name("valid");for(let O of q){if(F(O))w(O);else{if(K.if((0,z.propertyInData)(K,W,O,X.opts.ownProperties)),w(O),!X.allErrors)K.else().var(V,!0);K.endIf()}I.it.definedProperties.add(O),I.ok(V)}function F(O){return X.opts.useDefaults&&!X.compositeRule&&G[O].default!==void 0}function w(O){I.subschema({keyword:"properties",schemaProp:O,dataProp:O},V)}}};$.default=J}),nb0=C0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let Y=J5(),z=F1(),U=v1(),Q=v1(),J={keyword:"patternProperties",type:"object",schemaType:"object",code(I){let{gen:K,schema:G,data:H,parentSchema:W,it:X}=I,{opts:Z}=X,q=(0,Y.allSchemaProperties)(G),V=q.filter((P)=>(0,U.alwaysValidSchema)(X,G[P]));if(q.length===0||V.length===q.length&&(!X.opts.unevaluated||X.props===!0))return;let F=Z.strictSchema&&!Z.allowMatchingProperties&&W.properties,w=K.name("valid");if(X.props!==!0&&!(X.props instanceof z.Name))X.props=(0,Q.evaluatedPropsToName)(K,X.props);let{props:O}=X;N();function N(){for(let P of q){if(F)M(P);if(X.allErrors) Line truncated
\x00`,k+=N4(T,2),k+=K.magic,k+=N4(w,2),k+=N4(O,2),k+=N4(A.crc32,4),k+=N4(A.compressedSize,4),k+=N4(A.uncompressedSize,4),k+=N4(H.length,2),k+=N4(N.length,2);var S=EM.LOCAL_FILE_HEADER+k+H+N,i=EM.CENTRAL_FILE_HEADER+N4(b,2)+k+N4(Z.length,2)+"\x00\x00\x00\x00"+N4(C,4)+N4(U,4)+H+N+Z;return{fileRecord:S,dirRecord:i}},dr0=function($,Y,z,U,Q){var J="",I=NJ.transformTo("string",Q(U));return J=EM.CENTRAL_DIRECTORY_END+"\x00\x00\x00\x00"+N4($,2)+N4($,2)+N4(Y,4)+N4(z,4)+N4(I.length,2)+I,J},mr0=function($){var Y="";return Y=EM.DATA_DESCRIPTOR+N4($.crc32,4)+N4($.compressedSize,4)+N4($.uncompressedSize,4),Y};function Z5($,Y,z,U){DJ.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=Y,this.zipPlatform=z,this.encodeFileName=U,this.streamFiles=$,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}NJ.inherits(Z5,DJ);Z5.prototype.push=function($){var Y=$.meta.percent||0,z=this.entriesCount,U=this._sources.length;if(this.accumulate)this.contentBuffer.push($);else this.bytesWritten+=$.data.length,DJ.prototype.push.call(this,{data:$.data,meta:{currentFile:this.currentFile,percent:z?(Y+100*(z-U-1))/z:100}})};Z5.prototype.openedSource=function($){this.currentSourceOffset=this.bytesWritten,this.currentFile=$.file.name;var Y=this.streamFiles&&!$.file.dir;if(Y){var z=e50($,Y,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:z.fileRecord,meta:{percent:0}})}else this.accumulate=!0};Z5.prototype.closedSource=function($){this.accumulate=!1;var Y=this.streamFiles&&!$.file.dir,z=e50($,Y,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(z.dirRecord),Y)this.push({data:mr0($),meta:{percent:100}});else{this.push({data:z.fileRecord,meta:{percent:0}});while(this.contentBuffer.length)this.push(this.contentBuffer.shift())}this.currentFile=null};Z5.prototype.flush=function(){var $=this.bytesWritten;for(var Y=0;Y<this.dirRecords.length;Y++)this.push({data:this.dirRecords[Y],meta:{percent:100}});var z=this.bytesWritten-$,U=dr0(this.dirRecords.length,z,$,this.zipComment,this.encodeFileName);this.push({data:U,meta:{percent:100}})};Z5.prototype.prepareNextSource=function(){if(this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused)this.previous.pause();else this.previous.resume()};Z5.prototype.registerPrevious=function($){this._sources.push($);var Y=this;return $.on("data",function(z){Y.processChunk(z)}),$.on("end",function(){if(Y.closedSource(Y.previous.streamInfo),Y._sources.length)Y.prepareNextSource();else Y.end()}),$.on("error",function(z){Y.error(z)}),this};Z5.prototype.resume=function(){if(!DJ.prototype.resume.call(this))return!1;if(!this.previous&&this._sources.length)return this.prepareNextSource(),!0;if(!this.previous&&!this._sources.length&&!this.generatedError)return this.end(),!0};Z5.prototype.error=function($){var Y=this._sources;if(!DJ.prototype.error.call(this,$))return!1;for(var z=0;z<Y.length;z++)try{Y[z].error($)}catch(U){}return!0};Z5.prototype.lock=function(){DJ.prototype.lock.call(this);var $=this._sources;for(var Y=0;Y<$.length;Y++)$[Y].lock()};$90.exports=Z5});var z90=E((sr0)=>{var lr0=ay(),or0=Y90(),rr0=function($,Y){var z=$||Y,U=lr0[z];if(!U)throw Error(z+" is not a valid compression method !");return U};sr0.generateWorker=function($,Y,z){var U=new or0(Y.streamFiles,z,Y.platform,Y.encodeFileName),Q=0;try{$.forEach(function(J,I){Q++;var K=rr0(I.options.compression,Y.compression),G=I.options.compressionOptions||Y.compressionOptions||{},H=I.dir,W=I.date;I._compressWorker(K,G).withStreamInfo("file",{name:J,dir:H,date:W,comment:I.comment||"",unixPermissions:I.unixPermissions,dosPermissions:I.dosPermissions}).pipe(U)}),U.entriesCount=Q}catch(J){U.error(J)}return U}});var Q90=E((Um1,U90)=>{var tr0=c4(),CM=K$();function wW($,Y){CM.call(this,"Nodejs stream input adapter for "+$),this._upstreamEnded=!1,this._bindStream(Y)}tr0.inherits(wW,CM);wW.prototype._bindStream=function($){var Y=this;this._stream=$,$.pause(),$.on("data",function(z){Y.push({data:z,meta:{percent:0}})}).on("error",function(z){if(Y.isPaused)this.generatedError=z;else Y.error(z)}).on("end",function(){if(Y.isPaused)Y._upstreamEnded=!0;else Y.end()})};wW.prototype.pause=function(){if(!CM.prototype.pause.call(this))return!1;return this._stream.pause(),!0};wW.prototype.resume=function(){if(!CM.prototype.resume.call(this))return!1;if(this._upstreamEnded)this.end();else this._stream.resume();return!0};U90.exports=wW});var V90=E((Qm1,q90)=>{var er0=WJ(),MW=c4(),G90=K$(),$s0=Uy(),H90=Qy(),J90=HM(),Ys0=I$0(),zs0=z90(),I90=aH(),Us0=Q90(),W90=function($,Y,z){var U=MW.getTypeOf(Y),Q,J=MW.extend(z||{},H90);if(J.date=J.date||new Date,J.compression!==null)J.compression=J.compression.toUpperCase();if(typeof J.unixPermissions==="string")J.unixPermissions=parseInt(J.unixPermissions,8);if(J.unixPermissions&&J.unixPermissions&16384)J.dir=!0;if(J.dosPermissions&&J.dosPermission Line truncated
`)}openNode($,Y){let z=this.tos,U=this._xml;if(z&&this.open)U.push(">");this._stack.push($),U.push("<"),U.push($),gk(U,Y),this.leaf=!0,this.open=!0}addAttribute($,Y){if(!this.open)throw Error("Cannot write attributes to node if it is not open");if(Y!==void 0)Q70(this._xml,$,Y)}addAttributes($){if(!this.open)throw Error("Cannot write attributes to node if it is not open");gk(this._xml,$)}writeText($){let Y=this._xml;if(this.open)Y.push(">"),this.open=!1;this.leaf=!1,Y.push(U70.xmlEncode($.toString()))}writeXml($){if(this.open)this._xml.push(">"),this.open=!1;this.leaf=!1,this._xml.push($)}closeNode(){let $=this._stack.pop(),Y=this._xml;if(this.leaf)Y.push("/>");else Y.push("</"),Y.push($),Y.push(">");this.open=!1,this.leaf=!1}leafNode($,Y,z){if(this.openNode($,Y),z!==void 0)this.writeText(z);this.closeNode()}closeAll(){while(this._stack.length)this.closeNode()}addRollback(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf,open:this.open}),this.cursor}commit(){this._rollbacks.pop()}rollback(){let $=this._rollbacks.pop();if(this._xml.length>$.xml)this._xml.splice($.xml,this._xml.length-$.xml);if(this._stack.length>$.stack)this._stack.splice($.stack,this._stack.length-$.stack);this.leaf=$.leaf,this.open=$.open}get xml(){return this.closeAll(),this._xml.join("")}}yk.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"};J70.exports=yk});var kk=E((ot0)=>{var I70=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function lt0($){if(typeof $==="string")return $;if(I70)return I70.decode($);return $.toString()}ot0.bufferToString=lt0});var X70=E((G70)=>{Object.defineProperty(G70,"__esModule",{value:!0});G70.CHAR=`
\r -퟿-�\uD800\uDC00-\uDBFF\uDFFF`;G70.S=` \r
`;G70.NAME_START_CHAR=":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�\uD800\uDC00-\uDB7F\uDFFF";G70.NAME_CHAR="-"+G70.NAME_START_CHAR+".0-9·̀-ͯ‿-⁀";G70.CHAR_RE=new RegExp("^["+G70.CHAR+"]$","u");G70.S_RE=new RegExp("^["+G70.S+"]+$","u");G70.NAME_START_CHAR_RE=new RegExp("^["+G70.NAME_START_CHAR+"]$","u");G70.NAME_CHAR_RE=new RegExp("^["+G70.NAME_CHAR+"]$","u");G70.NAME_RE=new RegExp("^["+G70.NAME_START_CHAR+"]["+G70.NAME_CHAR+"]*$","u");G70.NMTOKEN_RE=new RegExp("^["+G70.NAME_CHAR+"]+$","u");var xk=9,fk=10,uk=13,bk=32;G70.S_LIST=[bk,fk,uk,xk];function st0($){return $>=bk&&$<=55295||$===fk||$===uk||$===xk||$>=57344&&$<=65533||$>=65536&&$<=1114111}G70.isChar=st0;function at0($){return $===bk||$===fk||$===uk||$===xk}G70.isS=at0;function K70($){return $>=65&&$<=90||$>=97&&$<=122||$===58||$===95||$===8204||$===8205||$>=192&&$<=214||$>=216&&$<=246||$>=248&&$<=767||$>=880&&$<=893||$>=895&&$<=8191||$>=8304&&$<=8591||$>=11264&&$<=12271||$>=12289&&$<=55295||$>=63744&&$<=64975||$>=65008&&$<=65533||$>=65536&&$<=983039}G70.isNameStartChar=K70;function tt0($){return K70($)||$>=48&&$<=57||$===45||$===46||$===183||$>=768&&$<=879||$>=8255&&$<=8256}G70.isNameChar=tt0});var D70=E((O70)=>{Object.defineProperty(O70,"__esModule",{value:!0});O70.CHAR="\x01-퟿-�\uD800\uDC00-\uDBFF\uDFFF";O70.RESTRICTED_CHAR="\x01-\b\v\f\x0E-\x1F-„†-Ÿ";O70.S=` \r
`;O70.NAME_START_CHAR=":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�\uD800\uDC00-\uDB7F\uDFFF";O70.NAME_CHAR="-"+O70.NAME_START_CHAR+".0-9·̀-ͯ‿-⁀";O70.CHAR_RE=new RegExp("^["+O70.CHAR+"]$","u");O70.RESTRICTED_CHAR_RE=new RegExp("^["+O70.RESTRICTED_CHAR+"]$","u");O70.S_RE=new RegExp("^["+O70.S+"]+$","u");O70.NAME_START_CHAR_RE=new RegExp("^["+O70.NAME_START_CHAR+"]$","u");O70.NAME_CHAR_RE=new RegExp("^["+O70.NAME_CHAR+"]$","u");O70.NAME_RE=new RegExp("^["+O70.NAME_START_CHAR+"]["+O70.NAME_CHAR+"]*$","u");O70.NMTOKEN_RE=new RegExp("^["+O70.NAME_CHAR+"]+$","u");var Z70=9,q70=10,V70=13,L70=32;O70.S_LIST=[L70,q70,V70,Z70];function We0($){return $>=1&&$<=55295||$>=57344&&$<=65533||$>=65536&&$<=1114111}O70.isChar=We0;function Xe0($){return $>=1&&$<=8||$===11||$===12||$>=14&&$<=31||$>=127&&$<=132||$>=134&&$<=159}O70.isRestrictedChar=Xe0;function Ze0($){return $===9||$===10||$===13||$>31&&$<127||$===133||$>159&&$<=55295||$>=57344&&$<=65533||$>=65536&&$<=1114111}O70.isCharAndNotRestricted=Ze0;function qe0($){return $===L70||$===q70||$===V70||$===Z70}O70.isS=qe0;function F70($){return $>=65&&$<=90||$>=97&&$<=122||$===58||$===95||$===8204||$===8205||$>=192&&$<=214||$>=216&&$<=246||$>=248&&$<=767||$>=880&&$<=893||$>=895&&$<=8191||$>=8304&&$<=8591||$>=11264&&$<=12271||$>=12289&&$<=55295||$>=63744&&$<=64975||$>=65008&&$<=65533||$>=65536&&$<=983039}O70.isNameStartChar=F70;function Ve0($){return F70($)||$>=48&&$<=57||$===45||$===46||$===183||$>=768&&$<=879||$>=8255&&$<=8256}O70.isNameChar=Ve0});var P70=E((B70)=>{Object.defineProperty(B70,"__esModule",{value:!0});B70.NC_NAME_START_CHAR="A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�\uD800\uDC00-\uDB7F\uDFFF";B70.NC_NAME_CHAR="-"+B70.NC_NAME_START_CHAR+".0-9·̀-ͯ‿-⁀";B70.NC_NAME_START_CHAR_RE=new RegExp("^["+B70.NC_NAME_START_CHAR+"]$","u");B70.NC_NAME_CHAR_RE=new RegExp("^["+B70.NC_NAME_CHAR+"]$","u");B70.NC_NAME_RE=new RegExp("^["+B70.NC_NAME_START_CHAR+"]["+B70.NC_NAME_CHAR+"]*$","u");function A70($){return $>=65&&$<=90||$===95||$>=97&&$<=122||$>=192&&$<=214||$>=216&&$<=246||$>=248&&$<=767||$>=880&&$<=893||$>=895&&$<=8191||$>=8204&&$<=8205||$>=8304&&$<=8591||$>=11264&&$<=12271||$>=12289&&$<=55295||$>=63744&&$<=64975||$>=65008&&$<=65533||$>=65536&&$<=983039}B70.isNCNameStartChar=A70;function Re0($){return A70($)||($===45||$===46||$>=48&&$<=57||$===183||$>=768&&$<=879||$>=8255&&$<=8256)}B70.isNCNameChar=Re0});var m70=E((d70)=>{Object.defineProperty(d70,"__esModule",{value:!0});var SJ=X70(),ye0=D70(),$x=P70(),d8=SJ.isS,ke0=SJ.isChar,hW=SJ.isNameStartChar,j70=SJ.isNameChar,u70=SJ.S_LIST,xe0=SJ.NAME_RE,fe0=ye0.isChar,ue0=$x.isNCNameStartChar,be0=$x.isNCNameChar,ie0=$x.NC_NAME_RE,UN="http://www.w3.org/XML/1998/namespace",hJ="http://www.w3.org/2000/xmlns/",ne0={__proto__:null,xml:UN,xmlns:hJ},ce0={__proto__:null,amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},k4=-1,H9=-2,T70=0,pe0=1,nk=2,de0=3,RJ=4,me0=5,le0=6,oe0=7,ck=8,re0=9,se0=10,ae0=11,te0=12,R8=13,tM=14,pk=15,ee0=16,dk=17,$01=18,Y01=19,mk=20,z01=21,U01=22,Q01=23,E70=24,lk=25,eM=26,C70=27,J01=28,I01=29,R70=30,K01=31,G01=32,qz=33,H01=34,ok=35,SW=36,rk=37,W01=38,_70=39,v70=40,X01=41,h70=42,Z01=43,q01=44,sk=9,V5=10,ak=13,S70=32,g70=33,b70=34,gW=38,i70=39,$N=45,YN=47,V01=59,$2=60,_J=61,j6=62,r6=63,n70=91,vJ=93,y70=133,k70=8232,zN=($)=>$===b70||$===i70,c70=[b70,i70],L01=[...c70,n70,j6],F01=[...c70,$2,vJ],O01=[_J,r6,...u70],w01=[...u70,j6,gW,$2];function ek($,Y,z){switch(Y){case"xml":if(z!==UN)$.fail(`xml prefix must be bound to ${UN}.`);break;case"xmlns":if(z!==hJ)$.fail(`xmlns prefix must be bound to ${hJ}.`);break;default:}switch(z){case hJ:$.fail(Y===""?`the default namespace may not be set to ${z}.`:`may not assign a prefix (even "xmlns") to the URI ${hJ}.`);break;case UN:switch(Y){case"xml":break;case"":$.fail(`the default namespace may not be set to ${z}.`);break;default:$.fail("may not assign the xml namespace to another prefix.")}break;default:}}function M01($,Y){for(let z of Object.keys(Y))ek($,z,Y[z])}var N01=($)=>ie0.test($),D01=($)=>xe0.test($),Vz=0,x70=1,tk=2;d70.EVENTS=["xmldecl","text","processinginstruction","doctype","comment","opentagstart","attribute","opentag","closetag","cdata","error","end","ready"];var f70={xmldecl:"xmldeclHandler",text:"textHandler",processinginstruction:"piHandler",doctype:"doctypeHandler",comment:"commentHandler",opentagstart:"openTagStartHandler",attribute:"attributeHandler",opentag:"openTagHandler",closetag:"closeTagHandler",cdata:"cdataHandler",error:"errorHandler",end:"endHandler",ready:"readyHandler"};class p70{constructor($){this.opt=$!==null&&$!==void 0?$:{},this.fragmentOpt=!!this.opt.fragment;let Y=this.xmlnsOpt=!!this.opt.xmlns;if(this.trackPosition=this.opt.position!==!1,this.fileName=this.opt.fileName,Y){this.nameStartCheck=ue0,this.nameCheck=be0,this.isName=N01,this.processAttribs=this.processAttribsNS,this.pushAttrib=this.pushAttribNS,this.ns=Object.assign({__proto__:null},ne0);let z=this.opt.additionalNamesp Line truncated
`,Y=this.i}}captureToChar($){let{i:Y}=this,{chunk:z}=this;while(!0){let U=this.getCode();switch(U){case H9:this.text+=`${z.slice(Y,this.prevI)}
`,Y=this.i,U=V5;break;case k4:return this.text+=z.slice(Y),!1;default:}if(U===$)return this.text+=z.slice(Y,this.prevI),!0}}captureNameChars(){let{chunk:$,i:Y}=this;while(!0){let z=this.getCode();if(z===k4)return this.name+=$.slice(Y),k4;if(!j70(z))return this.name+=$.slice(Y,this.prevI),z===H9?V5:z}}skipSpaces(){while(!0){let $=this.getCodeNorm();if($===k4||!d8($))return $}}setXMLVersion($){if(this.currentXMLVersion=$,$==="1.0")this.isChar=ke0,this.getCode=this.getCode10;else this.isChar=fe0,this.getCode=this.getCode11}sBegin(){if(this.chunk.charCodeAt(0)===65279)this.i++,this.column++;this.state=pe0}sBeginWhitespace(){let $=this.i,Y=this.skipSpaces();if(this.prevI!==$)this.xmlDeclPossible=!1;switch(Y){case $2:if(this.state=pk,this.text.length!==0)throw Error("no-empty text at start");break;case k4:break;default:this.unget(),this.state=R8,this.xmlDeclPossible=!1}}sDoctype(){var $;let Y=this.captureTo(L01);switch(Y){case j6:{($=this.doctypeHandler)===null||$===void 0||$.call(this,this.text),this.text="",this.state=R8,this.doctype=!0;break}case k4:break;default:if(this.text+=String.fromCodePoint(Y),Y===n70)this.state=RJ;else if(zN(Y))this.state=de0,this.q=Y}}sDoctypeQuote(){let $=this.q;if(this.captureToChar($))this.text+=String.fromCodePoint($),this.q=null,this.state=nk}sDTD(){let $=this.captureTo(F01);if($===k4)return;if(this.text+=String.fromCodePoint($),$===vJ)this.state=nk;else if($===$2)this.state=le0;else if(zN($))this.state=me0,this.q=$}sDTDQuoted(){let $=this.q;if(this.captureToChar($))this.text+=String.fromCodePoint($),this.state=RJ,this.q=null}sDTDOpenWaka(){let $=this.getCodeNorm();switch(this.text+=String.fromCodePoint($),$){case g70:this.state=oe0,this.openWakaBang="";break;case r6:this.state=ae0;break;default:this.state=RJ}}sDTDOpenWakaBang(){let $=String.fromCodePoint(this.getCodeNorm()),Y=this.openWakaBang+=$;if(this.text+=$,Y!=="-")this.state=Y==="--"?ck:RJ,this.openWakaBang=""}sDTDComment(){if(this.captureToChar($N))this.text+="-",this.state=re0}sDTDCommentEnding(){let $=this.getCodeNorm();this.text+=String.fromCodePoint($),this.state=$===$N?se0:ck}sDTDCommentEnded(){let $=this.getCodeNorm();if(this.text+=String.fromCodePoint($),$===j6)this.state=RJ;else this.fail("malformed comment."),this.state=ck}sDTDPI(){if(this.captureToChar(r6))this.text+="?",this.state=te0}sDTDPIEnding(){let $=this.getCodeNorm();if(this.text+=String.fromCodePoint($),$===j6)this.state=RJ}sText(){if(this.tags.length!==0)this.handleTextInRoot();else this.handleTextOutsideRoot()}sEntity(){let{i:$}=this,{chunk:Y}=this;$:while(!0)switch(this.getCode()){case H9:this.entity+=`${Y.slice($,this.prevI)}
`,$=this.i;break;case V01:{let{entityReturnState:z}=this,U=this.entity+Y.slice($,this.prevI);this.state=z;let Q;if(U==="")this.fail("empty entity name."),Q="&;";else Q=this.parseEntity(U),this.entity="";if(z!==R8||this.textHandler!==void 0)this.text+=Q;break $}case k4:this.entity+=Y.slice($);break $;default:}}sOpenWaka(){let $=this.getCode();if(hW($))this.state=H01,this.unget(),this.xmlDeclPossible=!1;else switch($){case YN:this.state=Z01,this.xmlDeclPossible=!1;break;case g70:this.state=ee0,this.openWakaBang="",this.xmlDeclPossible=!1;break;case r6:this.state=Q01;break;default:this.fail("disallowed character in tag name"),this.state=R8,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case"[CDATA[":if(!this.sawRoot&&!this.reportedTextBeforeRoot)this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0;if(this.closedRoot&&!this.reportedTextAfterRoot)this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0;this.state=mk,this.openWakaBang="";break;case"--":this.state=dk,this.openWakaBang="";break;case"DOCTYPE":if(this.state=nk,this.doctype||this.sawRoot)this.fail("inappropriately located doctype declaration.");this.openWakaBang="";break;default:if(this.openWakaBang.length>=7)this.fail("incorrect syntax.")}}sComment(){if(this.captureToChar($N))this.state=$01}sCommentEnding(){var $;let Y=this.getCodeNorm();if(Y===$N)this.state=Y01,($=this.commentHandler)===null||$===void 0||$.call(this,this.text),this.text="";else this.text+=`-${String.fromCodePoint(Y)}`,this.state=dk}sCommentEnded(){let $=this.getCodeNorm();if($!==j6)this.fail("malformed comment."),this.text+=`--${String.fromCodePoint($)}`,this.state=dk;else this.state=R8}sCData(){if(this.captureToChar(vJ))this.state=z01}sCDataEnding(){let $=this.getCodeNorm();if($===vJ)this.state=U01;else this.text+=`]${String.fromCodePoint($)}`,this.state=mk}sCDataEnding2(){var $;let Y=this.getCodeNorm();switch(Y){case j6:{($=this.cdataHandler)===null||$===void 0||$.call(this,this.text),this.text="",this.state=R8;break}case vJ:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(Y)}`,this.state=mk}}sPIFirstChar(){let $=this.getCodeNorm();if(this.nameStartCheck($))this.piTarget+=String.fromCodePoint($),this.state=E70;else if($===r6||d8($))this.fail("processing instruction without a target."),this.state=$===r6?eM:lk;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint($),this.state=E70}sPIRest(){let{chunk:$,i:Y}=this;while(!0){let z=this.getCodeNorm();if(z===k4){this.piTarget+=$.slice(Y);return}if(!this.nameCheck(z)){this.piTarget+=$.slice(Y,this.prevI);let U=z===r6;if(U||d8(z))if(this.piTarget==="xml"){if(!this.xmlDeclPossible)this.fail("an XML declaration must be at the start of the document.");this.state=U?qz:C70}else this.state=U?eM:lk;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(z);break}}}sPIBody(){if(this.text.length===0){let $=this.getCodeNorm();if($===r6)this.state=eM;else if(!d8($))this.text=String.fromCodePoint($)}else if(this.captureToChar(r6))this.state=eM}sPIEnding(){var $;let Y=this.getCodeNorm();if(Y===j6){let{piTarget:z}=this;if(z.toLowerCase()==="xml")this.fail("the XML declaration must appear at the start of the document.");($=this.piHandler)===null||$===void 0||$.call(this,{target:z,body:this.text}),this.piTarget=this.text="",this.state=R8}else if(Y===r6)this.text+="?";else this.text+=`?${String.fromCodePoint(Y)}`,this.state=lk;this.xmlDeclPossible=!1}sXMLDeclNameStart(){let $=this.skipSpaces();if($===r6){this.state=qz;return}if($!==k4)this.state=J01,this.name=String.fromCodePoint($)}sXMLDeclName(){let $=this.captureTo(O01);if($===r6){this.state=qz,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(!(d8($)||$===_J))return;if(this.name+=this.text,this.text="",!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail("did not expect any more name/value pairs.");break;case 1:this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`)}this.state=$===_J?R70:I01}sXMLDeclEq(){let $=this.getCodeNorm();if($===r6){this.state=qz,this.fail("XML declaration is incomplete.");return}if(d8($))return;if($!==_J)this.fail("value required.");this.state=R70}sXMLDeclValueStart(){let $=this.getCodeNorm();if($===r6){this.state=qz,this.fail("XML declaration is incomplete.");return}if(d8($))return;if(!zN($))this.fail("value must be quoted."),this.q=S70;else this.q=$;this.state=K01}sXMLDeclValue(){let $=this.captureTo([this.q,r6]);if($===r6){this.state=qz,this.text="",this.fail("XML declaration is incomplete.");return}if($===k4)return;let Y=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let z=Y;if(this.xmlDecl.version=z,!/^1\.[0-9]+$/.test(z))this.fail("ver Line truncated
`;$=this.i,Y=Vz;break;case k4:if(U!==void 0)this.text+=z.slice($);break $;default:Y=Vz}this.forbiddenState=Y}handleTextOutsideRoot(){let{i:$}=this,{chunk:Y,textHandler:z}=this,U=!1;$:while(!0){let Q=this.getCode();switch(Q){case $2:{if(this.state=pk,z!==void 0){let{text:J}=this,I=Y.slice($,this.prevI);if(J.length!==0)z(J+I),this.text="";else if(I.length!==0)z(I)}break $}case gW:if(this.state=tM,this.entityReturnState=R8,z!==void 0)this.text+=Y.slice($,this.prevI);U=!0;break $;case H9:if(z!==void 0)this.text+=`${Y.slice($,this.prevI)}
`;$=this.i;break;case k4:if(z!==void 0)this.text+=Y.slice($);break $;default:if(!d8(Q))U=!0}}if(!U)return;if(!this.sawRoot&&!this.reportedTextBeforeRoot)this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0;if(this.closedRoot&&!this.reportedTextAfterRoot)this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0}pushAttribNS($,Y){var z;let{prefix:U,local:Q}=this.qname($),J={name:$,prefix:U,local:Q,value:Y};if(this.attribList.push(J),(z=this.attributeHandler)===null||z===void 0||z.call(this,J),U==="xmlns"){let I=Y.trim();if(this.currentXMLVersion==="1.0"&&I==="")this.fail("invalid attempt to undefine prefix in XML 1.0");this.topNS[Q]=I,ek(this,Q,I)}else if($==="xmlns"){let I=Y.trim();this.topNS[""]=I,ek(this,"",I)}}pushAttribPlain($,Y){var z;let U={name:$,value:Y};this.attribList.push(U),(z=this.attributeHandler)===null||z===void 0||z.call(this,U)}end(){var $,Y;if(!this.sawRoot)this.fail("document must contain a root element.");let{tags:z}=this;while(z.length>0){let Q=z.pop();this.fail(`unclosed tag: ${Q.name}`)}if(this.state!==T70&&this.state!==R8)this.fail("unexpected end.");let{text:U}=this;if(U.length!==0)($=this.textHandler)===null||$===void 0||$.call(this,U),this.text="";return this._closed=!0,(Y=this.endHandler)===null||Y===void 0||Y.call(this),this._init(),this}resolve($){var Y,z;let U=this.topNS[$];if(U!==void 0)return U;let{tags:Q}=this;for(let J=Q.length-1;J>=0;J--)if(U=Q[J].ns[$],U!==void 0)return U;if(U=this.ns[$],U!==void 0)return U;return(z=(Y=this.opt).resolvePrefix)===null||z===void 0?void 0:z.call(Y,$)}qname($){let Y=$.indexOf(":");if(Y===-1)return{prefix:"",local:$};let z=$.slice(Y+1),U=$.slice(0,Y);if(U===""||z===""||z.includes(":"))this.fail(`malformed name: ${$}.`);return{prefix:U,local:z}}processAttribsNS(){var $;let{attribList:Y}=this,z=this.tag;{let{prefix:J,local:I}=this.qname(z.name);z.prefix=J,z.local=I;let K=z.uri=($=this.resolve(J))!==null&&$!==void 0?$:"";if(J!==""){if(J==="xmlns")this.fail('tags may not have "xmlns" as prefix.');if(K==="")this.fail(`unbound namespace prefix: ${JSON.stringify(J)}.`),z.uri=J}}if(Y.length===0)return;let{attributes:U}=z,Q=new Set;for(let J of Y){let{name:I,prefix:K,local:G}=J,H,W;if(K==="")H=I==="xmlns"?hJ:"",W=I;else{if(H=this.resolve(K),H===void 0)this.fail(`unbound namespace prefix: ${JSON.stringify(K)}.`),H=K;W=`{${H}}${G}`}if(Q.has(W))this.fail(`duplicate attribute: ${W}.`);Q.add(W),J.uri=H,U[I]=J}this.attribList=[]}processAttribsPlain(){let{attribList:$}=this,Y=this.tag.attributes;for(let{name:z,value:U}of $){if(Y[z]!==void 0)this.fail(`duplicate attribute: ${z}.`);Y[z]=U}this.attribList=[]}openTag(){var $;this.processAttribs();let{tags:Y}=this,z=this.tag;z.isSelfClosing=!1,($=this.openTagHandler)===null||$===void 0||$.call(this,z),Y.push(z),this.state=R8,this.name=""}openSelfClosingTag(){var $,Y,z;this.processAttribs();let{tags:U}=this,Q=this.tag;if(Q.isSelfClosing=!0,($=this.openTagHandler)===null||$===void 0||$.call(this,Q),(Y=this.closeTagHandler)===null||Y===void 0||Y.call(this,Q),(this.tag=(z=U[U.length-1])!==null&&z!==void 0?z:null)===null)this.closedRoot=!0;this.state=R8,this.name=""}closeTag(){let{tags:$,name:Y}=this;if(this.state=R8,this.name="",Y===""){this.fail("weird empty close tag."),this.text+="</>";return}let z=this.closeTagHandler,U=$.length;while(U-- >0){let Q=this.tag=$.pop();if(this.topNS=Q.ns,z===null||z===void 0||z(Q),Q.name===Y)break;this.fail("unexpected close tag.")}if(U===0)this.closedRoot=!0;else if(U<0)this.fail(`unmatched closing tag: ${Y}.`),this.text+=`</${Y}>`}parseEntity($){if($[0]!=="#"){let z=this.ENTITIES[$];if(z!==void 0)return z;return this.fail(this.isName($)?"undefined entity.":"disallowed character in entity name."),`&${$};`}let Y=NaN;if($[1]==="x"&&/^#x[0-9a-f]+$/i.test($))Y=parseInt($.slice(2),16);else if(/^#[0-9]+$/.test($))Y=parseInt($.slice(1),10);if(!this.isChar(Y))return this.fail("malformed character entity."),`&${$};`;return String.fromCodePoint(Y)}}d70.SaxesParser=p70});var yW=E((im1,l70)=>{var{SaxesParser:P01}=m70(),{PassThrough:j01}=C8(),{bufferToString:T01}=kk();l70.exports=async function*($){if($.pipe&&!$[Symbol.asyncIterator])$=$.pipe(new j01);let Y=new P01,z;Y.on("error",(Q)=>{z=Q});let U=[];Y.on("opentag",(Q)=>U.push({eventType:"opentag",value:Q})),Y.on("text",(Q)=>U.push({eventType:"text",value:Q})),Y.on("closetag",(Q)=>U.push({eventType:"closetag",value:Q}));for await(let Q of $){if(Y.write(T01(Q)),z)throw z;yield U,U=[]}}});var g0=E((nm1,o70)=>{var E01=yW(),C01=o6();class gJ{prepare(){}render(){}parseOpen($){}parseText($){}parseClose($){}reconcile($,Y){}reset(){if(this.model=null,this.map)Object.values(this.map).forEach(($)=>{if($ instanceof gJ)$.reset();else if($.xform)$.xform.reset()})}mergeModel($){this.model=Object.assign(this.model||{},$)}async parse($){for await(let Y of $)for(let{eventType:z,value:U}of Y)if(z==="opentag")this.parseOpen(U);else if(z==="text")this.parseText(U);else if(z==="closetag"){if(!this.parseClose(U.name))return thLine truncated
<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"> <a:themeElements> <a:clrScheme name="Office"> <a:dk1> <a:sysClr val="windowText" lastClr="000000"/> </a:dk1> <a:lt1> <a:sysClr val="window" lastClr="FFFFFF"/> </a:lt1> <a:dk2> <a:srgbClr val="1F497D"/> </a:dk2> <a:lt2> <a:srgbClr val="EEECE1"/> </a:lt2> <a:accent1> <a:srgbClr val="4F81BD"/> </a:accent1> <a:accent2> <a:srgbClr val="C0504D"/> </a:accent2> <a:accent3> <a:srgbClr val="9BBB59"/> </a:accent3> <a:accent4> <a:srgbClr val="8064A2"/> </a:accent4> <a:accent5> <a:srgbClr val="4BACC6"/> </a:accent5> <a:accent6> <a:srgbClr val="F79646"/> </a:accent6> <a:hlink> <a:srgbClr val="0000FF"/> </a:hlink> <a:folHlink> <a:srgbClr val="800080"/> </a:folHlink> </a:clrScheme> <a:fontScheme name="Office"> <a:majorFont> <a:latin typeface="Cambria"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Times New Roman"/> <a:font script="Hebr" typeface="Times New Roman"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="MoolBoran"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Times New Roman"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:majorFont> <a:minorFont> <a:latin typeface="Calibri"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Arial"/> <a:font script="Hebr" typeface="Arial"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="DaunPenh"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Arial"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:minorFont> </a:fontScheme> <a:fmtScheme name="Office"> <a:fillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="35000"> <a:schemeClr val="phClr"> <a:tint val="37000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="15000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="1"/> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="100000"/> <a:shade val="100000"/> <a:satMod val="130000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:shade val="100000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="0"/> </a:gradFill> </a:fillStyleLst> <a:lnStyleLst> <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"> <a:shade val="95000"/> <a:satMod val="105000"/> </a:schemeClr> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:Line truncated
`,this.quote='"',this.escape=this.quote,this.quoteColumns=!1,this.quoteHeaders=this.quoteColumns,this.headers=null,this.includeEndRowDelimiter=!1,this.writeBOM=!1,this.BOM="\uFEFF",this.alwaysWriteHeaders=!1,Object.assign(this,$||{}),typeof($===null||$===void 0?void 0:$.quoteHeaders)>"u")this.quoteHeaders=this.quoteColumns;if(($===null||$===void 0?void 0:$.quote)===!0)this.quote='"';else if(($===null||$===void 0?void 0:$.quote)===!1)this.quote="";if(typeof($===null||$===void 0?void 0:$.escape)!=="string")this.escape=this.quote;this.shouldWriteHeaders=!!this.headers&&((Y=$.writeHeaders)!==null&&Y!==void 0?Y:!0),this.headers=Array.isArray(this.headers)?this.headers:null,this.escapedQuote=`${this.escape}${this.quote}`}}PI0.FormatterOptions=BI0});var kN=E((qr1,RI0)=>{var f51="[object AsyncFunction]",u51="[object Function]",b51="[object GeneratorFunction]",i51="[object Null]",n51="[object Proxy]",c51="[object Undefined]",p51=typeof global=="object"&&global&&global.Object===Object&&global,d51=typeof self=="object"&&self&&self.Object===Object&&self,m51=p51||d51||Function("return this")(),EI0=Object.prototype,l51=EI0.hasOwnProperty,CI0=EI0.toString,TI0=m51.Symbol,Dz=TI0?TI0.toStringTag:void 0;function o51($){if($==null)return $===void 0?c51:i51;return Dz&&Dz in Object($)?r51($):s51($)}function r51($){var Y=l51.call($,Dz),z=$[Dz];try{$[Dz]=void 0;var U=!0}catch(J){}var Q=CI0.call($);if(U)if(Y)$[Dz]=z;else delete $[Dz];return Q}function s51($){return CI0.call($)}function a51($){if(!t51($))return!1;var Y=o51($);return Y==u51||Y==b51||Y==f51||Y==n51}function t51($){var Y=typeof $;return $!=null&&(Y=="object"||Y=="function")}RI0.exports=a51});var WK0=E((xN,pJ)=>{var e51=200,Bf="__lodash_hash_undefined__",dN=1,iI0=2,nI0=9007199254740991,fN="[object Arguments]",Ff="[object Array]",$91="[object AsyncFunction]",cI0="[object Boolean]",pI0="[object Date]",dI0="[object Error]",mI0="[object Function]",Y91="[object GeneratorFunction]",uN="[object Map]",lI0="[object Number]",z91="[object Null]",cJ="[object Object]",_I0="[object Promise]",U91="[object Proxy]",oI0="[object RegExp]",bN="[object Set]",rI0="[object String]",Q91="[object Symbol]",J91="[object Undefined]",Of="[object WeakMap]",sI0="[object ArrayBuffer]",iN="[object DataView]",I91="[object Float32Array]",K91="[object Float64Array]",G91="[object Int8Array]",H91="[object Int16Array]",W91="[object Int32Array]",X91="[object Uint8Array]",Z91="[object Uint8ClampedArray]",q91="[object Uint16Array]",V91="[object Uint32Array]",L91=/[\\^$.*+?()[\]{}|]/g,F91=/^\[object .+?Constructor\]$/,O91=/^(?:0|[1-9]\d*)$/,j4={};j4[I91]=j4[K91]=j4[G91]=j4[H91]=j4[W91]=j4[X91]=j4[Z91]=j4[q91]=j4[V91]=!0;j4[fN]=j4[Ff]=j4[sI0]=j4[cI0]=j4[iN]=j4[pI0]=j4[dI0]=j4[mI0]=j4[uN]=j4[lI0]=j4[cJ]=j4[oI0]=j4[bN]=j4[rI0]=j4[Of]=!1;var aI0=typeof global=="object"&&global&&global.Object===Object&&global,w91=typeof self=="object"&&self&&self.Object===Object&&self,V3=aI0||w91||Function("return this")(),tI0=typeof xN=="object"&&xN&&!xN.nodeType&&xN,vI0=tI0&&typeof pJ=="object"&&pJ&&!pJ.nodeType&&pJ,eI0=vI0&&vI0.exports===tI0,qf=eI0&&aI0.process,hI0=function(){try{return qf&&qf.binding&&qf.binding("util")}catch($){}}(),SI0=hI0&&hI0.isTypedArray;function M91($,Y){var z=-1,U=$==null?0:$.length,Q=0,J=[];while(++z<U){var I=$[z];if(Y(I,z,$))J[Q++]=I}return J}function N91($,Y){var z=-1,U=Y.length,Q=$.length;while(++z<U)$[Q+z]=Y[z];return $}function D91($,Y){var z=-1,U=$==null?0:$.length;while(++z<U)if(Y($[z],z,$))return!0;return!1}function A91($,Y){var z=-1,U=Array($);while(++z<$)U[z]=Y(z);return U}function B91($){return function(Y){return $(Y)}}function P91($,Y){return $.has(Y)}function j91($,Y){return $==null?void 0:$[Y]}function T91($){var Y=-1,z=Array($.size);return $.forEach(function(U,Q){z[++Y]=[Q,U]}),z}function E91($,Y){return function(z){return $(Y(z))}}function C91($){var Y=-1,z=Array($.size);return $.forEach(function(U){z[++Y]=U}),z}var R91=Array.prototype,_91=Function.prototype,mN=Object.prototype,Vf=V3["__core-js_shared__"],$K0=_91.toString,X9=mN.hasOwnProperty,gI0=function(){var $=/[^.]+$/.exec(Vf&&Vf.keys&&Vf.keys.IE_PROTO||"");return $?"Symbol(src)_1."+$:""}(),YK0=mN.toString,v91=RegExp("^"+$K0.call(X9).replace(L91,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),yI0=eI0?V3.Buffer:void 0,nN=V3.Symbol,kI0=V3.Uint8Array,zK0=mN.propertyIsEnumerable,h91=R91.splice,Az=nN?nN.toStringTag:void 0,xI0=Object.getOwnPropertySymbols,S91=yI0?yI0.isBuffer:void 0,g91=E91(Object.keys,Object),wf=dJ(V3,"DataView"),nW=dJ(V3,"Map"),Mf=dJ(V3,"Promise"),Nf=dJ(V3,"Set"),Df=dJ(V3,"WeakMap"),cW=dJ(Object,"create"),y91=jz(wf),k91=jz(nW),x91=jz(Mf),f91=jz(Nf),u91=jz(Df),fI0=nN?nN.prototype:void 0,Lf=fI0?fI0.valueOf:void 0;function Bz($){var Y=-1,z=$==null?0:$.length;this.clear();while(++Y<z){var U=$[Y];this.set(U[0],U[1])}}function b91(){this.__data__=cW?cW(null):{},this.size=0}function i91($){var Y=this.has($)&&delete this.__data__[$];return this.size-=Y?1:0,Y}function n91($){var Y=this.__data Line truncated
]`;this.ESCAPE_REGEXP=new RegExp(Y)}set headers($){this._headers=$}shouldQuote($,Y){let z=Y?this.formatterOptions.quoteHeaders:this.formatterOptions.quoteColumns;if(o31.default(z))return z;if(Array.isArray(z))return z[$];if(this._headers!==null)return z[this._headers[$]];return!1}format($,Y,z){let U=`${r31.default($)?"":$}`.replace(/\0/g,""),{formatterOptions:Q}=this;if(Q.quote!==""){if(U.indexOf(Q.quote)!==-1)return this.quoteField(U.replace(this.REPLACE_REGEXP,Q.escapedQuote))}if(U.search(this.ESCAPE_REGEXP)!==-1||this.shouldQuote(Y,z))return this.quoteField(U);return U}quoteField($){let{quote:Y}=this.formatterOptions;return`${Y}${$}${Y}`}}mJ.FieldFormatter=MK0});var Cf=E((NK0)=>{Object.defineProperty(NK0,"__esModule",{value:!0});NK0.isSyncTransform=void 0;NK0.isSyncTransform=($)=>$.length===1});var BK0=E((lJ)=>{var AK0=lJ&&lJ.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(lJ,"__esModule",{value:!0});lJ.RowFormatter=void 0;var a31=AK0(kN()),t31=AK0(WK0()),e31=Ef(),$71=Cf();class Tz{constructor($){if(this.rowCount=0,this.formatterOptions=$,this.fieldFormatter=new e31.FieldFormatter($),this.headers=$.headers,this.shouldWriteHeaders=$.shouldWriteHeaders,this.hasWrittenHeaders=!1,this.headers!==null)this.fieldFormatter.headers=this.headers;if($.transform)this.rowTransform=$.transform}static isRowHashArray($){if(Array.isArray($))return Array.isArray($[0])&&$[0].length===2;return!1}static isRowArray($){return Array.isArray($)&&!this.isRowHashArray($)}static gatherHeaders($){if(Tz.isRowHashArray($))return $.map((Y)=>Y[0]);if(Array.isArray($))return $;return Object.keys($)}static createTransform($){if($71.isSyncTransform($))return(Y,z)=>{let U=null;try{U=$(Y)}catch(Q){return z(Q)}return z(null,U)};return(Y,z)=>{$(Y,z)}}set rowTransform($){if(!a31.default($))throw TypeError("The transform should be a function");this._rowTransform=Tz.createTransform($)}format($,Y){this.callTransformer($,(z,U)=>{if(z)return Y(z);if(!$)return Y(null);let Q=[];if(U){let{shouldFormatColumns:J,headers:I}=this.checkHeaders(U);if(this.shouldWriteHeaders&&I&&!this.hasWrittenHeaders)Q.push(this.formatColumns(I,!0)),this.hasWrittenHeaders=!0;if(J){let K=this.gatherColumns(U);Q.push(this.formatColumns(K,!1))}}return Y(null,Q)})}finish($){let Y=[];if(this.formatterOptions.alwaysWriteHeaders&&this.rowCount===0){if(!this.headers)return $(Error("`alwaysWriteHeaders` option is set to true but `headers` option not provided."));Y.push(this.formatColumns(this.headers,!0))}if(this.formatterOptions.includeEndRowDelimiter)Y.push(this.formatterOptions.rowDelimiter);return $(null,Y)}checkHeaders($){if(this.headers)return{shouldFormatColumns:!0,headers:this.headers};let Y=Tz.gatherHeaders($);if(this.headers=Y,this.fieldFormatter.headers=Y,!this.shouldWriteHeaders)return{shouldFormatColumns:!0,headers:null};return{shouldFormatColumns:!t31.default(Y,$),headers:Y}}gatherColumns($){if(this.headers===null)throw Error("Headers is currently null");if(!Array.isArray($))return this.headers.map((Y)=>$[Y]);if(Tz.isRowHashArray($))return this.headers.map((Y,z)=>{let U=$[z];if(U)return U[1];return""});if(Tz.isRowArray($)&&!this.shouldWriteHeaders)return $;return this.headers.map((Y,z)=>$[z])}callTransformer($,Y){if(!this._rowTransform)return Y(null,$);return this._rowTransform($,Y)}formatColumns($,Y){let z=$.map((Q,J)=>this.fieldFormatter.format(Q,J,Y)).join(this.formatterOptions.delimiter),{rowCount:U}=this;if(this.rowCount+=1,U)return[this.formatterOptions.rowDelimiter,z].join("");return z}}lJ.RowFormatter=Tz});var PK0=E((rN)=>{Object.defineProperty(rN,"__esModule",{value:!0});rN.FieldFormatter=rN.RowFormatter=void 0;var Y71=BK0();Object.defineProperty(rN,"RowFormatter",{enumerable:!0,get:function(){return Y71.RowFormatter}});var z71=Ef();Object.defineProperty(rN,"FieldFormatter",{enumerable:!0,get:function(){return z71.FieldFormatter}})});var Rf=E((TK0)=>{Object.defineProperty(TK0,"__esModule",{value:!0});TK0.CsvFormatterStream=void 0;var Q71=I0("stream"),J71=PK0();class jK0 extends Q71.Transform{constructor($){super({writableObjectMode:$.objectMode});this.hasWrittenBOM=!1,this.formatterOptions=$,this.rowFormatter=new J71.RowFormatter($),this.hasWrittenBOM=!$.writeBOM}transform($){return this.rowFormatter.rowTransform=$,this}_transform($,Y,z){let U=!1;try{if(!this.hasWrittenBOM)this.push(this.formatterOptions.BOM),this.hasWrittenBOM=!0;this.rowFormatter.format($,(Q,J)=>{if(Q)return U=!0,z(Q);if(J)J.forEach((I)=>{this.push(Buffer.from(I,"utf8"))});return U=!0,z()})}catch(Q){if(U)throw Q;z(Q)}}_flush($){this.rowFormatter.finish((Y,z)=>{if(Y)return $(Y);if(z)z.forEach((U)=>{this.push(Buffer.from(U,"utf8"))});return $()})}}TK0.CsvFormatterStream=jK0});var RK0=E((s1)=>{var CK0=s1&&s1.__createBinding||(Object.create?function($,Y,z,U){if(U===void 0)U=z;Object.defineProperty($,U,{enumerable:!0,get:function(){return Y[z]}})}:function($,Y,z,U){if(U===void 0)U=z;$[U]=Y[z]}),I71=s1&&s1.__setModuleDefault||(Object.create?function($,Y){O Line truncated
`||Y===`\r
`}static isTokenCarriageReturn($,Y){return $.token===Y.carriageReturn}static isTokenComment($,Y){return Y.supportsComments&&!!$&&$.token===Y.comment}static isTokenEscapeCharacter($,Y){return $.token===Y.escapeChar}static isTokenQuote($,Y){return $.token===Y.quote}static isTokenDelimiter($,Y){return $.token===Y.delimiter}}_G0.Token=RG0});var $u=E((gG0)=>{Object.defineProperty(gG0,"__esModule",{value:!0});gG0.Scanner=void 0;var hG0=X2(),Vz1=/((?:\r\n)|\n|\r)/;class SG0{constructor($){this.cursor=0,this.line=$.line,this.lineLength=this.line.length,this.parserOptions=$.parserOptions,this.hasMoreData=$.hasMoreData,this.cursor=$.cursor||0}get hasMoreCharacters(){return this.lineLength>this.cursor}get nextNonSpaceToken(){let{lineFromCursor:$}=this,Y=this.parserOptions.NEXT_TOKEN_REGEXP;if($.search(Y)===-1)return null;let z=Y.exec($);if(z==null)return null;let U=z[1],Q=this.cursor+(z.index||0);return new hG0.Token({token:U,startCursor:Q,endCursor:Q+U.length-1})}get nextCharacterToken(){let{cursor:$,lineLength:Y}=this;if(Y<=$)return null;return new hG0.Token({token:this.line[$],startCursor:$,endCursor:$})}get lineFromCursor(){return this.line.substr(this.cursor)}advancePastLine(){let $=Vz1.exec(this.lineFromCursor);if(!$){if(this.hasMoreData)return null;return this.cursor=this.lineLength,this}return this.cursor+=($.index||0)+$[0].length,this}advanceTo($){return this.cursor=$,this}advanceToToken($){return this.cursor=$.startCursor,this}advancePastToken($){return this.cursor=$.endCursor+1,this}truncateToCursor(){return this.line=this.lineFromCursor,this.lineLength=this.line.length,this.cursor=0,this}}gG0.Scanner=SG0});var wD=E((xG0)=>{Object.defineProperty(xG0,"__esModule",{value:!0});xG0.ColumnFormatter=void 0;class kG0{constructor($){if($.trim)this.format=(Y)=>Y.trim();else if($.ltrim)this.format=(Y)=>Y.trimLeft();else if($.rtrim)this.format=(Y)=>Y.trimRight();else this.format=(Y)=>Y}}xG0.ColumnFormatter=kG0});var Yu=E((iG0)=>{Object.defineProperty(iG0,"__esModule",{value:!0});iG0.NonQuotedColumnParser=void 0;var Lz1=wD(),uG0=X2();class bG0{constructor($){this.parserOptions=$,this.columnFormatter=new Lz1.ColumnFormatter($)}parse($){if(!$.hasMoreCharacters)return null;let{parserOptions:Y}=this,z=[],U=$.nextCharacterToken;for(;U;U=$.nextCharacterToken){if(uG0.Token.isTokenDelimiter(U,Y)||uG0.Token.isTokenRowDelimiter(U))break;z.push(U.token),$.advancePastToken(U)}return this.columnFormatter.format(z.join(""))}}iG0.NonQuotedColumnParser=bG0});var zu=E((pG0)=>{Object.defineProperty(pG0,"__esModule",{value:!0});pG0.QuotedColumnParser=void 0;var Fz1=wD(),QI=X2();class cG0{constructor($){this.parserOptions=$,this.columnFormatter=new Fz1.ColumnFormatter($)}parse($){if(!$.hasMoreCharacters)return null;let Y=$.cursor,{foundClosingQuote:z,col:U}=this.gatherDataBetweenQuotes($);if(!z){if($.advanceTo(Y),!$.hasMoreData)throw Error(`Parse Error: missing closing: '${this.parserOptions.quote||""}' in line: at '${$.lineFromCursor.replace(/[\r\n]/g,"\\n'")}'`);return null}return this.checkForMalformedColumn($),U}gatherDataBetweenQuotes($){let{parserOptions:Y}=this,z=!1,U=!1,Q=[],J=$.nextCharacterToken;for(;!U&&J!==null;J=$.nextCharacterToken){let I=QI.Token.isTokenQuote(J,Y);if(!z&&I)z=!0;else if(z)if(QI.Token.isTokenEscapeCharacter(J,Y)){$.advancePastToken(J);let K=$.nextCharacterToken;if(K!==null&&(QI.Token.isTokenQuote(K,Y)||QI.Token.isTokenEscapeCharacter(K,Y)))Q.push(K.token),J=K;else if(I)U=!0;else Q.push(J.token)}else if(I)U=!0;else Q.push(J.token);$.advancePastToken(J)}return{col:this.columnFormatter.format(Q.join("")),foundClosingQuote:U}}checkForMalformedColumn($){let{parserOptions:Y}=this,{nextNonSpaceToken:z}=$;if(z){let U=QI.Token.isTokenDelimiter(z,Y),Q=QI.Token.isTokenRowDelimiter(z);if(!(U||Q)){let J=$.lineFromCursor.substr(0,10).replace(/[\r\n]/g,"\\n'");throw Error(`Parse Error: expected: '${Y.escapedDelimiter}' OR new line got: '${z.token}'. at '${J}`)}$.advanceToToken(z)}else if(!$.hasMoreData)$.advancePastLine()}}pG0.QuotedColumnParser=cG0});var rG0=E((lG0)=>{Object.defineProperty(lG0,"__esModule",{value:!0});lG0.ColumnParser=void 0;var Oz1=Yu(),wz1=zu(),Mz1=X2();class mG0{constructor($){this.parserOptions=$,this.quotedColumnParser=new wz1.QuotedColumnParser($),this.nonQuotedColumnParser=new Oz1.NonQuotedColumnParser($)}parse($){let{nextNonSpaceToken:Y}=$;if(Y!==null&&Mz1.Token.isTokenQuote(Y,this.parserOptions))return $.advanceToToken(Y),this.quotedColumnParser.parse($);return this.nonQuotedColumnParser.parse($)}}lG0.ColumnParser=mG0});var Uu=E((JI)=>{Object.defineProperty(JI,"__esModule",{value:!0});JI.ColumnFormatter=JI.QuotedColumnParser=JI.NonQuotedColumnParser=JI.ColumnParser=void 0;var Nz1=rG0();Object.defineProperty(JI,"ColumnParser",{enumerable:!0,get:function(){return Nz1.ColumnParser}});var Dz1=Yu();Object.defineProperty(JI,"NonQuotedColumnParser",{enumerable:!0,get:function(){return Dz1.NonQuotedColumnParser}});var Az1=zu();Object.defineProperty(JI,"QuotedColumnParser",{enumerable:!0,get:function(){re Line truncated
%s`,j,j,q,U);let A=q.type==="*"?wu:q.type==="?"?Du:"\\"+q.type;Q=!0,U=U.slice(0,q.reStart)+A+"\\("+j}if(M(),J)U+="\\\\";let D=qU1[U.charAt(0)];for(let j=K.length-1;j>-1;j--){let A=K[j],T=U.slice(0,A.reStart),C=U.slice(A.reStart,A.reEnd-8),b=U.slice(A.reEnd),k=U.slice(A.reEnd-8,A.reEnd)+b,S=T.split(")").length,i=T.split("(").length-S,n=b;for(let x=0;x<i;x++)n=n.replace(/\)[+*?]?/,"");b=n;let U0=b===""&&Y!==Mu?"(?:$|\\/)":"";U=T+C+b+U0+k}if(U!==""&&Q)U="(?=.)"+U;if(D)U=O()+U;if(Y===Mu)return[U,Q];if(z.nocase&&!Q)Q=$.toUpperCase()!==$.toLowerCase();if(!Q)return LU1($);let P=z.nocase?"i":"";try{return Object.assign(new RegExp("^"+U+"$",P),{_glob:$,_src:U})}catch(j){return new RegExp("$.")}}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let $=this.set;if(!$.length)return this.regexp=!1,this.regexp;let Y=this.options,z=Y.noglobstar?wu:Y.dot?XU1:ZU1,U=Y.nocase?"i":"",Q=$.map((J)=>{return J=J.map((I)=>typeof I==="string"?OU1(I):I===_8?_8:I._src).reduce((I,K)=>{if(!(I[I.length-1]===_8&&K===_8))I.push(K);return I},[]),J.forEach((I,K)=>{if(I!==_8||J[K-1]===_8)return;if(K===0)if(J.length>1)J[K+1]="(?:\\/|"+z+"\\/)?"+J[K+1];else J[K]=z;else if(K===J.length-1)J[K-1]+="(?:\\/|"+z+")?";else J[K-1]+="(?:\\/|\\/"+z+"\\/)"+J[K+1],J[K+1]=_8}),J.filter((I)=>I!==_8).join("/")}).join("|");if(Q="^(?:"+Q+")$",this.negate)Q="^(?!"+Q+").*$";try{this.regexp=new RegExp(Q,U)}catch(J){this.regexp=!1}return this.regexp}match($,Y=this.partial){if(this.debug("match",$,this.pattern),this.comment)return!1;if(this.empty)return $==="";if($==="/"&&Y)return!0;let z=this.options;if(Nu.sep!=="/")$=$.split(Nu.sep).join("/");$=$.split(nH0),this.debug(this.pattern,"split",$);let U=this.set;this.debug(this.pattern,"set",U);let Q;for(let J=$.length-1;J>=0;J--)if(Q=$[J],Q)break;for(let J=0;J<U.length;J++){let I=U[J],K=$;if(z.matchBase&&I.length===1)K=[Q];if(this.matchOne(K,I,Y)){if(z.flipNegate)return!0;return!this.negate}}if(z.flipNegate)return!1;return this.negate}static defaults($){return W$.defaults($).Minimatch}}W$.Minimatch=aW});var sH0=E((As1,rH0)=>{rH0.exports=oH0;var Pu=I0("fs"),{EventEmitter:MU1}=I0("events"),{Minimatch:Bu}=dH0(),{resolve:NU1}=I0("path");function DU1($,Y){return new Promise((z,U)=>{Pu.readdir($,{withFileTypes:!0},(Q,J)=>{if(Q)switch(Q.code){case"ENOTDIR":if(Y)U(Q);else z([]);break;case"ENOTSUP":case"ENOENT":case"ENAMETOOLONG":case"UNKNOWN":z([]);break;case"ELOOP":default:U(Q);break}else z(J)})})}function mH0($,Y){return new Promise((z,U)=>{(Y?Pu.stat:Pu.lstat)($,(J,I)=>{if(J)switch(J.code){case"ENOENT":if(Y)z(mH0($,!1));else z(null);break;default:z(null);break}else z(I)})})}async function*lH0($,Y,z,U,Q,J){let I=await DU1(Y+$,J);for(let K of I){let G=K.name;if(G===void 0)G=K,U=!0;let H=$+"/"+G,W=H.slice(1),X=Y+"/"+W,Z=null;if(U||z)Z=await mH0(X,z);if(!Z&&K.name!==void 0)Z=K;if(Z===null)Z={isDirectory:()=>!1};if(Z.isDirectory()){if(!Q(W))yield{relative:W,absolute:X,stats:Z},yield*lH0(H,Y,z,U,Q,!1)}else yield{relative:W,absolute:X,stats:Z}}}async function*AU1($,Y,z,U){yield*lH0("",$,Y,z,U,!0)}function BU1($){return{pattern:$.pattern,dot:!!$.dot,noglobstar:!!$.noglobstar,matchBase:!!$.matchBase,nocase:!!$.nocase,ignore:$.ignore,skip:$.skip,follow:!!$.follow,stat:!!$.stat,nodir:!!$.nodir,mark:!!$.mark,silent:!!$.silent,absolute:!!$.absolute}}class ju extends MU1{constructor($,Y,z){super();if(typeof Y==="function")z=Y,Y=null;if(this.options=BU1(Y||{}),this.matchers=[],this.options.pattern){let U=Array.isArray(this.options.pattern)?this.options.pattern:[this.options.pattern];this.matchers=U.map((Q)=>new Bu(Q,{dot:this.options.dot,noglobstar:this.options.noglobstar,matchBase:this.options.matchBase,nocase:this.options.nocase}))}if(this.ignoreMatchers=[],this.options.ignore){let U=Array.isArray(this.options.ignore)?this.options.ignore:[this.options.ignore];this.ignoreMatchers=U.map((Q)=>new Bu(Q,{dot:!0}))}if(this.skipMatchers=[],this.options.skip){let U=Array.isArray(this.options.skip)?this.options.skip:[this.options.skip];this.skipMatchers=U.map((Q)=>new Bu(Q,{dot:!0}))}if(this.iterator=AU1(NU1($||"."),this.options.follow,this.options.stat,this._shouldSkipDirectory.bind(this)),this.paused=!1,this.inactive=!1,this.aborted=!1,z)this._matches=[],this.on("match",(U)=>this._matches.push(this.options.absolute?U.absolute:U.relative)),this.on("error",(U)=>z(U)),this.on("end",()=>z(null,this._matches));setTimeout(()=>this._next(),0)}_shouldSkipDirectory($){return this.skipMatchers.some((Y)=>Y.match($))}_fileMatches($,Y){let z=$+(Y?"/":"");return(this.matchers.length===0||this.matchers.some((U)=>U.match(z)))&&!this.ignoreMatchers.some((U)=>U.match(z))&&(!this.options.nodir||!Y)}_next(){if(!this.paused&&!this.aborted)this.iterator.next().then(($)=>{if(!$.done){let Y=$.value.stats.isDirectory();if(this._fileMatches($.value.relative,Y)){let z=$.value.relative,U=$.value.absolute;if(this.options.mark&&Y)z+="/",U+="/";if(this.options.stat)this.emit("match",{relative:z,absolute:U,stat:$.value.stats});else this.emit("match",{relative:z Line truncated
`,o);o=O0===-1?f.length:O0}else if(K0!==-1&&f[o]==="/"&&f[o+1]==="*"){let O0=f.indexOf("*/",o);if(O0!==-1)o=O0+2,K0=f.indexOf("*/",o);else c+=f[o],o++}else c+=f[o],o++;return c}function n0(f){let c=i0(f.toString()),o=c.match(s);if(!o)o=c.match(H0);if(!o)throw Error(`could not parse args in autoInject
deps: ${W}}`};let I={keyword:"dependencies",type:"object",schemaType:"object",error:$.error,code(G){let[H,W]=Q(G);J(G,H),K(G,W)}};function Q({schema:G}){let H={},W={};for(let X in G){if(X==="__proto__")continue;let Z=Array.isArray(G[X])?H:W;Z[X]=G[X]}return[H,W]}function J(G,H=G.schema){let{gen:W,data:X,it:Z}=G;if(Object.keys(H).length===0)return;let q=W.let("missing");for(let V in H){let F=H[V];if(F.length===0)continue;let M=(0,z.propertyInData)(W,X,V,Z.opts.ownProperties);if(G.setParams({property:V,depsCount:F.length,deps:F.join(", ")}),Z.allErrors)W.if(M,()=>{for(let w of F)(0,z.checkReportMissingProp)(G,w)});else W.if(U._`${M} && (${(0,z.checkMissingProp)(G,F,q)})`),(0,z.reportMissingProp)(G,q),W.else()}}$.validatePropertyDeps=J;function K(G,H=G.schema){let{gen:W,data:X,keyword:Z,it:q}=G,V=W.name("valid");for(let F in H){if((0,Y.alwaysValidSchema)(q,H[F]))continue;W.if((0,z.propertyInData)(W,X,F,q.opts.ownProperties),()=>{let M=G.subschema({keyword:Z,schemaProp:F},V);G.mergeValidEvaluated(M,V)},()=>W.var(V,!0)),G.ok(V)}}$.validateSchemaDeps=K,$.default=I}),Li0=E0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let U=w1(),Y=v1(),z={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:I})=>U._`{propertyName: ${I.propertyName}}`},code(I){let{gen:Q,schema:J,data:K,it:G}=I;if((0,Y.alwaysValidSchema)(G,J))return;let H=Q.name("valid");Q.forIn("key",K,(W)=>{I.setParams({propertyName:W}),I.subschema({keyword:"propertyNames",data:W,dataTypes:["string"],propertyName:W,compositeRule:!0},H),Q.if((0,U.not)(H),()=>{if(I.error(!0),!G.allErrors)Q.break()})}),I.ok(H)}};$.default=z}),Se=E0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let U=G5(),Y=w1(),z=K5(),I=v1(),Q={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:J})=>Y._`{additionalProperty: ${J.additionalProperty}}`},code(J){let{gen:K,schema:G,parentSchema:H,data:W,errsCount:X,it:Z}=J;if(!X)throw Error("ajv implementation error");let{allErrors:q,opts:V}=Z;if(Z.props=!0,V.removeAdditional!=="all"&&(0,I.alwaysValidSchema)(Z,G))return;let F=(0,U.allSchemaProperties)(H.properties),M=(0,U.allSchemaProperties)(H.patternProperties);w(),J.ok(Y._`${X} === ${z.default.errors}`);function w(){K.forIn("key",W,(T)=>{if(!F.length&&!M.length)D(T);else K.if(N(T),()=>D(T))})}function N(T){let A;if(F.length>8){let j=(0,I.schemaRefOrVal)(Z,H.properties,"properties");A=(0,U.isOwnProperty)(K,j,T)}else if(F.length)A=(0,Y.or)(...F.map((j)=>Y._`${T} === ${j}`));else A=Y.nil;if(M.length)A=(0,Y.or)(A,...M.map((j)=>Y._`${(0,U.usePattern)(J,j)}.test(${T})`));return(0,Y.not)(A)}function O(T){K.code(Y._`delete ${W}[${T}]`)}function D(T){if(V.removeAdditional==="all"||V.removeAdditional&&G===!1){O(T);return}if(G===!1){if(J.setParams({additionalProperty:T}),J.error(),!q)K.break();return}if(typeof G=="object"&&!(0,I.alwaysValidSchema)(Z,G)){let A=K.name("valid");if(V.removeAdditional==="failing")P(T,A,!1),K.if((0,Y.not)(A),()=>{J.reset(),O(T)});else if(P(T,A),!q)K.if((0,Y.not)(A),()=>K.break())}}function P(T,A,j){let C={keyword:"additionalProperties",dataProp:T,dataPropType:I.Type.Str};if(j===!1)Object.assign(C,{compositeRule:!0,createErrors:!1,allErrors:!1});J.subschema(C,A)}}};$.default=Q}),wi0=E0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let U=bI(),Y=G5(),z=v1(),I=Se(),Q={keyword:"properties",type:"object",schemaType:"object",code(J){let{gen:K,schema:G,parentSchema:H,data:W,it:X}=J;if(X.opts.removeAdditional==="all"&&H.additionalProperties===void 0)I.default.code(new U.KeywordCxt(X,I.default,"additionalProperties"));let Z=(0,Y.allSchemaProperties)(G);for(let w of Z)X.definedProperties.add(w);if(X.opts.unevaluated&&Z.length&&X.props!==!0)X.props=z.mergeEvaluated.props(K,(0,z.toHash)(Z),X.props);let q=Z.filter((w)=>!(0,z.alwaysValidSchema)(X,G[w]));if(q.length===0)return;let V=K.name("valid");for(let w of q){if(F(w))M(w);else{if(K.if((0,Y.propertyInData)(K,W,w,X.opts.ownProperties)),M(w),!X.allErrors)K.else().var(V,!0);K.endIf()}J.it.definedProperties.add(w),J.ok(V)}function F(w){return X.opts.useDefaults&&!X.compositeRule&&G[w].default!==void 0}function M(w){J.subschema({keyword:"properties",schemaProp:w,dataProp:w},V)}}};$.default=Q}),Fi0=E0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let U=G5(),Y=w1(),z=v1(),I=v1(),Q={keyword:"patternProperties",type:"object",schemaType:"object",code(J){let{gen:K,schema:G,data:H,parentSchema:W,it:X}=J,{opts:Z}=X,q=(0,U.allSchemaProperties)(G),V=q.filter((P)=>(0,z.alwaysValidSchema)(X,G[P]));if(q.length===0||V.length===q.length&&(!X.opts.unevaluated||X.props===!0))return;let F=Z.strictSchema&&!Z.allowMatchingProperties&&W.properties,M=K.name("valid");if(X.props!==!0&&!(X.props instanceof Y.Name))X.props=(0,I.evaluatedPropsToName)(K,X.props);let{props:w}=X;N();function N(){for(let P of q){if(F)O(P);if(X.allErrors) Line truncated
\x00`,x+=D4(j,2),x+=K.magic,x+=D4(M,2),x+=D4(w,2),x+=D4(A.crc32,4),x+=D4(A.compressedSize,4),x+=D4(A.uncompressedSize,4),x+=D4(H.length,2),x+=D4(N.length,2);var g=SO.LOCAL_FILE_HEADER+x+H+N,i=SO.CENTRAL_FILE_HEADER+D4(b,2)+x+D4(Z.length,2)+"\x00\x00\x00\x00"+D4(C,4)+D4(z,4)+H+N+Z;return{fileRecord:g,dirRecord:i}},Os0=function($,U,Y,z,I){var Q="",J=DQ.transformTo("string",I(z));return Q=SO.CENTRAL_DIRECTORY_END+"\x00\x00\x00\x00"+D4($,2)+D4($,2)+D4(U,4)+D4(Y,4)+D4(J.length,2)+J,Q},Ns0=function($){var U="";return U=SO.DATA_DESCRIPTOR+D4($.crc32,4)+D4($.compressedSize,4)+D4($.uncompressedSize,4),U};function L5($,U,Y,z){AQ.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=U,this.zipPlatform=Y,this.encodeFileName=z,this.streamFiles=$,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}DQ.inherits(L5,AQ);L5.prototype.push=function($){var U=$.meta.percent||0,Y=this.entriesCount,z=this._sources.length;if(this.accumulate)this.contentBuffer.push($);else this.bytesWritten+=$.data.length,AQ.prototype.push.call(this,{data:$.data,meta:{currentFile:this.currentFile,percent:Y?(U+100*(Y-z-1))/Y:100}})};L5.prototype.openedSource=function($){this.currentSourceOffset=this.bytesWritten,this.currentFile=$.file.name;var U=this.streamFiles&&!$.file.dir;if(U){var Y=W90($,U,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:Y.fileRecord,meta:{percent:0}})}else this.accumulate=!0};L5.prototype.closedSource=function($){this.accumulate=!1;var U=this.streamFiles&&!$.file.dir,Y=W90($,U,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(Y.dirRecord),U)this.push({data:Ns0($),meta:{percent:100}});else{this.push({data:Y.fileRecord,meta:{percent:0}});while(this.contentBuffer.length)this.push(this.contentBuffer.shift())}this.currentFile=null};L5.prototype.flush=function(){var $=this.bytesWritten;for(var U=0;U<this.dirRecords.length;U++)this.push({data:this.dirRecords[U],meta:{percent:100}});var Y=this.bytesWritten-$,z=Os0(this.dirRecords.length,Y,$,this.zipComment,this.encodeFileName);this.push({data:z,meta:{percent:100}})};L5.prototype.prepareNextSource=function(){if(this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused)this.previous.pause();else this.previous.resume()};L5.prototype.registerPrevious=function($){this._sources.push($);var U=this;return $.on("data",function(Y){U.processChunk(Y)}),$.on("end",function(){if(U.closedSource(U.previous.streamInfo),U._sources.length)U.prepareNextSource();else U.end()}),$.on("error",function(Y){U.error(Y)}),this};L5.prototype.resume=function(){if(!AQ.prototype.resume.call(this))return!1;if(!this.previous&&this._sources.length)return this.prepareNextSource(),!0;if(!this.previous&&!this._sources.length&&!this.generatedError)return this.end(),!0};L5.prototype.error=function($){var U=this._sources;if(!AQ.prototype.error.call(this,$))return!1;for(var Y=0;Y<U.length;Y++)try{U[Y].error($)}catch(z){}return!0};L5.prototype.lock=function(){AQ.prototype.lock.call(this);var $=this._sources;for(var U=0;U<$.length;U++)$[U].lock()};X90.exports=L5});var q90=E((Ps0)=>{var Ds0=Xk(),As0=Z90(),Bs0=function($,U){var Y=$||U,z=Ds0[Y];if(!z)throw Error(Y+" is not a valid compression method !");return z};Ps0.generateWorker=function($,U,Y){var z=new As0(U.streamFiles,Y,U.platform,U.encodeFileName),I=0;try{$.forEach(function(Q,J){I++;var K=Bs0(J.options.compression,U.compression),G=J.options.compressionOptions||U.compressionOptions||{},H=J.dir,W=J.date;J._compressWorker(K,G).withStreamInfo("file",{name:Q,dir:H,date:W,comment:J.comment||"",unixPermissions:J.unixPermissions,dosPermissions:J.dosPermissions}).pipe(z)}),z.entriesCount=I}catch(Q){z.error(Q)}return z}});var L90=E((ym1,V90)=>{var js0=c4(),gO=G$();function NW($,U){gO.call(this,"Nodejs stream input adapter for "+$),this._upstreamEnded=!1,this._bindStream(U)}js0.inherits(NW,gO);NW.prototype._bindStream=function($){var U=this;this._stream=$,$.pause(),$.on("data",function(Y){U.push({data:Y,meta:{percent:0}})}).on("error",function(Y){if(U.isPaused)this.generatedError=Y;else U.error(Y)}).on("end",function(){if(U.isPaused)U._upstreamEnded=!0;else U.end()})};NW.prototype.pause=function(){if(!gO.prototype.pause.call(this))return!1;return this._stream.pause(),!0};NW.prototype.resume=function(){if(!gO.prototype.resume.call(this))return!1;if(this._upstreamEnded)this.end();else this._stream.resume();return!0};V90.exports=NW});var T90=E((km1,P90)=>{var Es0=XQ(),DW=c4(),O90=G$(),Cs0=Fy(),N90=My(),w90=LO(),Rs0=F$0(),_s0=q90(),F90=eH(),vs0=L90(),D90=function($,U,Y){var z=DW.getTypeOf(U),I,Q=DW.extend(Y||{},N90);if(Q.date=Q.date||new Date,Q.compression!==null)Q.compression=Q.compression.toUpperCase();if(typeof Q.unixPermissions==="string")Q.unixPermissions=parseInt(Q.unixPermissions,8);if(Q.unixPermissions&&Q.unixPermissions&16384)Q.dir=!0;if(Q.dosPermissions&&Q.dosPermission Line truncated
`)}openNode($,U){let Y=this.tos,z=this._xml;if(Y&&this.open)z.push(">");this._stack.push($),z.push("<"),z.push($),ok(z,U),this.leaf=!0,this.open=!0}addAttribute($,U){if(!this.open)throw Error("Cannot write attributes to node if it is not open");if(U!==void 0)L70(this._xml,$,U)}addAttributes($){if(!this.open)throw Error("Cannot write attributes to node if it is not open");ok(this._xml,$)}writeText($){let U=this._xml;if(this.open)U.push(">"),this.open=!1;this.leaf=!1,U.push(V70.xmlEncode($.toString()))}writeXml($){if(this.open)this._xml.push(">"),this.open=!1;this.leaf=!1,this._xml.push($)}closeNode(){let $=this._stack.pop(),U=this._xml;if(this.leaf)U.push("/>");else U.push("</"),U.push($),U.push(">");this.open=!1,this.leaf=!1}leafNode($,U,Y){if(this.openNode($,U),Y!==void 0)this.writeText(Y);this.closeNode()}closeAll(){while(this._stack.length)this.closeNode()}addRollback(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf,open:this.open}),this.cursor}commit(){this._rollbacks.pop()}rollback(){let $=this._rollbacks.pop();if(this._xml.length>$.xml)this._xml.splice($.xml,this._xml.length-$.xml);if(this._stack.length>$.stack)this._stack.splice($.stack,this._stack.length-$.stack);this.leaf=$.leaf,this.open=$.open}get xml(){return this.closeAll(),this._xml.join("")}}rk.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"};w70.exports=rk});var sk=E((Ae0)=>{var F70=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function De0($){if(typeof $==="string")return $;if(F70)return F70.decode($);return $.toString()}Ae0.bufferToString=De0});var A70=E((O70)=>{Object.defineProperty(O70,"__esModule",{value:!0});O70.CHAR=`
\r -퟿-�\uD800\uDC00-\uDBFF\uDFFF`;O70.S=` \r
`;O70.NAME_START_CHAR=":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�\uD800\uDC00-\uDB7F\uDFFF";O70.NAME_CHAR="-"+O70.NAME_START_CHAR+".0-9·̀-ͯ‿-⁀";O70.CHAR_RE=new RegExp("^["+O70.CHAR+"]$","u");O70.S_RE=new RegExp("^["+O70.S+"]+$","u");O70.NAME_START_CHAR_RE=new RegExp("^["+O70.NAME_START_CHAR+"]$","u");O70.NAME_CHAR_RE=new RegExp("^["+O70.NAME_CHAR+"]$","u");O70.NAME_RE=new RegExp("^["+O70.NAME_START_CHAR+"]["+O70.NAME_CHAR+"]*$","u");O70.NMTOKEN_RE=new RegExp("^["+O70.NAME_CHAR+"]+$","u");var ak=9,tk=10,ek=13,$x=32;O70.S_LIST=[$x,tk,ek,ak];function Pe0($){return $>=$x&&$<=55295||$===tk||$===ek||$===ak||$>=57344&&$<=65533||$>=65536&&$<=1114111}O70.isChar=Pe0;function Te0($){return $===$x||$===tk||$===ek||$===ak}O70.isS=Te0;function M70($){return $>=65&&$<=90||$>=97&&$<=122||$===58||$===95||$===8204||$===8205||$>=192&&$<=214||$>=216&&$<=246||$>=248&&$<=767||$>=880&&$<=893||$>=895&&$<=8191||$>=8304&&$<=8591||$>=11264&&$<=12271||$>=12289&&$<=55295||$>=63744&&$<=64975||$>=65008&&$<=65533||$>=65536&&$<=983039}O70.isNameStartChar=M70;function je0($){return M70($)||$>=48&&$<=57||$===45||$===46||$===183||$>=768&&$<=879||$>=8255&&$<=8256}O70.isNameChar=je0});var h70=E((C70)=>{Object.defineProperty(C70,"__esModule",{value:!0});C70.CHAR="\x01-퟿-�\uD800\uDC00-\uDBFF\uDFFF";C70.RESTRICTED_CHAR="\x01-\b\v\f\x0E-\x1F-„†-Ÿ";C70.S=` \r
`;C70.NAME_START_CHAR=":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�\uD800\uDC00-\uDB7F\uDFFF";C70.NAME_CHAR="-"+C70.NAME_START_CHAR+".0-9·̀-ͯ‿-⁀";C70.CHAR_RE=new RegExp("^["+C70.CHAR+"]$","u");C70.RESTRICTED_CHAR_RE=new RegExp("^["+C70.RESTRICTED_CHAR+"]$","u");C70.S_RE=new RegExp("^["+C70.S+"]+$","u");C70.NAME_START_CHAR_RE=new RegExp("^["+C70.NAME_START_CHAR+"]$","u");C70.NAME_CHAR_RE=new RegExp("^["+C70.NAME_CHAR+"]$","u");C70.NAME_RE=new RegExp("^["+C70.NAME_START_CHAR+"]["+C70.NAME_CHAR+"]*$","u");C70.NMTOKEN_RE=new RegExp("^["+C70.NAME_CHAR+"]+$","u");var B70=9,P70=10,T70=13,j70=32;C70.S_LIST=[j70,P70,T70,B70];function fe0($){return $>=1&&$<=55295||$>=57344&&$<=65533||$>=65536&&$<=1114111}C70.isChar=fe0;function ue0($){return $>=1&&$<=8||$===11||$===12||$>=14&&$<=31||$>=127&&$<=132||$>=134&&$<=159}C70.isRestrictedChar=ue0;function be0($){return $===9||$===10||$===13||$>31&&$<127||$===133||$>159&&$<=55295||$>=57344&&$<=65533||$>=65536&&$<=1114111}C70.isCharAndNotRestricted=be0;function ie0($){return $===j70||$===P70||$===T70||$===B70}C70.isS=ie0;function E70($){return $>=65&&$<=90||$>=97&&$<=122||$===58||$===95||$===8204||$===8205||$>=192&&$<=214||$>=216&&$<=246||$>=248&&$<=767||$>=880&&$<=893||$>=895&&$<=8191||$>=8304&&$<=8591||$>=11264&&$<=12271||$>=12289&&$<=55295||$>=63744&&$<=64975||$>=65008&&$<=65533||$>=65536&&$<=983039}C70.isNameStartChar=E70;function ne0($){return E70($)||$>=48&&$<=57||$===45||$===46||$===183||$>=768&&$<=879||$>=8255&&$<=8256}C70.isNameChar=ne0});var y70=E((g70)=>{Object.defineProperty(g70,"__esModule",{value:!0});g70.NC_NAME_START_CHAR="A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�\uD800\uDC00-\uDB7F\uDFFF";g70.NC_NAME_CHAR="-"+g70.NC_NAME_START_CHAR+".0-9·̀-ͯ‿-⁀";g70.NC_NAME_START_CHAR_RE=new RegExp("^["+g70.NC_NAME_START_CHAR+"]$","u");g70.NC_NAME_CHAR_RE=new RegExp("^["+g70.NC_NAME_CHAR+"]$","u");g70.NC_NAME_RE=new RegExp("^["+g70.NC_NAME_START_CHAR+"]["+g70.NC_NAME_CHAR+"]*$","u");function S70($){return $>=65&&$<=90||$===95||$>=97&&$<=122||$>=192&&$<=214||$>=216&&$<=246||$>=248&&$<=767||$>=880&&$<=893||$>=895&&$<=8191||$>=8204&&$<=8205||$>=8304&&$<=8591||$>=11264&&$<=12271||$>=12289&&$<=55295||$>=63744&&$<=64975||$>=65008&&$<=65533||$>=65536&&$<=983039}g70.isNCNameStartChar=S70;function z01($){return S70($)||($===45||$===46||$>=48&&$<=57||$===183||$>=768&&$<=879||$>=8255&&$<=8256)}g70.isNCNameChar=z01});var z20=E((Y20)=>{Object.defineProperty(Y20,"__esModule",{value:!0});var gQ=A70(),H01=h70(),Vx=y70(),m8=gQ.isS,W01=gQ.isChar,gW=gQ.isNameStartChar,k70=gQ.isNameChar,s70=gQ.S_LIST,X01=gQ.NAME_RE,Z01=H01.isChar,q01=Vx.isNCNameStartChar,V01=Vx.isNCNameChar,L01=Vx.NC_NAME_RE,HN="http://www.w3.org/XML/1998/namespace",SQ="http://www.w3.org/2000/xmlns/",w01={__proto__:null,xml:HN,xmlns:SQ},F01={__proto__:null,amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},x4=-1,X9=-2,x70=0,M01=1,Yx=2,O01=3,_Q=4,N01=5,D01=6,A01=7,zx=8,B01=9,P01=10,T01=11,j01=12,h8=13,IN=14,Ix=15,E01=16,Qx=17,C01=18,R01=19,Jx=20,_01=21,v01=22,h01=23,f70=24,Kx=25,QN=26,u70=27,S01=28,g01=29,b70=30,y01=31,k01=32,qY=33,x01=34,Gx=35,yW=36,Hx=37,f01=38,i70=39,n70=40,u01=41,c70=42,b01=43,i01=44,Wx=9,F5=10,Xx=13,d70=32,p70=33,a70=34,kW=38,t70=39,JN=45,KN=47,n01=59,U2=60,vQ=61,T6=62,s6=63,e70=91,hQ=93,m70=133,l70=8232,GN=($)=>$===a70||$===t70,$20=[a70,t70],c01=[...$20,e70,T6],d01=[...$20,U2,hQ],p01=[vQ,s6,...s70],m01=[...s70,T6,kW,U2];function qx($,U,Y){switch(U){case"xml":if(Y!==HN)$.fail(`xml prefix must be bound to ${HN}.`);break;case"xmlns":if(Y!==SQ)$.fail(`xmlns prefix must be bound to ${SQ}.`);break;default:}switch(Y){case SQ:$.fail(U===""?`the default namespace may not be set to ${Y}.`:`may not assign a prefix (even "xmlns") to the URI ${SQ}.`);break;case HN:switch(U){case"xml":break;case"":$.fail(`the default namespace may not be set to ${Y}.`);break;default:$.fail("may not assign the xml namespace to another prefix.")}break;default:}}function l01($,U){for(let Y of Object.keys(U))qx($,Y,U[Y])}var o01=($)=>L01.test($),r01=($)=>X01.test($),VY=0,o70=1,Zx=2;Y20.EVENTS=["xmldecl","text","processinginstruction","doctype","comment","opentagstart","attribute","opentag","closetag","cdata","error","end","ready"];var r70={xmldecl:"xmldeclHandler",text:"textHandler",processinginstruction:"piHandler",doctype:"doctypeHandler",comment:"commentHandler",opentagstart:"openTagStartHandler",attribute:"attributeHandler",opentag:"openTagHandler",closetag:"closeTagHandler",cdata:"cdataHandler",error:"errorHandler",end:"endHandler",ready:"readyHandler"};class U20{constructor($){this.opt=$!==null&&$!==void 0?$:{},this.fragmentOpt=!!this.opt.fragment;let U=this.xmlnsOpt=!!this.opt.xmlns;if(this.trackPosition=this.opt.position!==!1,this.fileName=this.opt.fileName,U){this.nameStartCheck=q01,this.nameCheck=V01,this.isName=o01,this.processAttribs=this.processAttribsNS,this.pushAttrib=this.pushAttribNS,this.ns=Object.assign({__proto__:null},w01);let Y=this.opt.additionalNamesp Line truncated
`,U=this.i}}captureToChar($){let{i:U}=this,{chunk:Y}=this;while(!0){let z=this.getCode();switch(z){case X9:this.text+=`${Y.slice(U,this.prevI)}
`,U=this.i,z=F5;break;case x4:return this.text+=Y.slice(U),!1;default:}if(z===$)return this.text+=Y.slice(U,this.prevI),!0}}captureNameChars(){let{chunk:$,i:U}=this;while(!0){let Y=this.getCode();if(Y===x4)return this.name+=$.slice(U),x4;if(!k70(Y))return this.name+=$.slice(U,this.prevI),Y===X9?F5:Y}}skipSpaces(){while(!0){let $=this.getCodeNorm();if($===x4||!m8($))return $}}setXMLVersion($){if(this.currentXMLVersion=$,$==="1.0")this.isChar=W01,this.getCode=this.getCode10;else this.isChar=Z01,this.getCode=this.getCode11}sBegin(){if(this.chunk.charCodeAt(0)===65279)this.i++,this.column++;this.state=M01}sBeginWhitespace(){let $=this.i,U=this.skipSpaces();if(this.prevI!==$)this.xmlDeclPossible=!1;switch(U){case U2:if(this.state=Ix,this.text.length!==0)throw Error("no-empty text at start");break;case x4:break;default:this.unget(),this.state=h8,this.xmlDeclPossible=!1}}sDoctype(){var $;let U=this.captureTo(c01);switch(U){case T6:{($=this.doctypeHandler)===null||$===void 0||$.call(this,this.text),this.text="",this.state=h8,this.doctype=!0;break}case x4:break;default:if(this.text+=String.fromCodePoint(U),U===e70)this.state=_Q;else if(GN(U))this.state=O01,this.q=U}}sDoctypeQuote(){let $=this.q;if(this.captureToChar($))this.text+=String.fromCodePoint($),this.q=null,this.state=Yx}sDTD(){let $=this.captureTo(d01);if($===x4)return;if(this.text+=String.fromCodePoint($),$===hQ)this.state=Yx;else if($===U2)this.state=D01;else if(GN($))this.state=N01,this.q=$}sDTDQuoted(){let $=this.q;if(this.captureToChar($))this.text+=String.fromCodePoint($),this.state=_Q,this.q=null}sDTDOpenWaka(){let $=this.getCodeNorm();switch(this.text+=String.fromCodePoint($),$){case p70:this.state=A01,this.openWakaBang="";break;case s6:this.state=T01;break;default:this.state=_Q}}sDTDOpenWakaBang(){let $=String.fromCodePoint(this.getCodeNorm()),U=this.openWakaBang+=$;if(this.text+=$,U!=="-")this.state=U==="--"?zx:_Q,this.openWakaBang=""}sDTDComment(){if(this.captureToChar(JN))this.text+="-",this.state=B01}sDTDCommentEnding(){let $=this.getCodeNorm();this.text+=String.fromCodePoint($),this.state=$===JN?P01:zx}sDTDCommentEnded(){let $=this.getCodeNorm();if(this.text+=String.fromCodePoint($),$===T6)this.state=_Q;else this.fail("malformed comment."),this.state=zx}sDTDPI(){if(this.captureToChar(s6))this.text+="?",this.state=j01}sDTDPIEnding(){let $=this.getCodeNorm();if(this.text+=String.fromCodePoint($),$===T6)this.state=_Q}sText(){if(this.tags.length!==0)this.handleTextInRoot();else this.handleTextOutsideRoot()}sEntity(){let{i:$}=this,{chunk:U}=this;$:while(!0)switch(this.getCode()){case X9:this.entity+=`${U.slice($,this.prevI)}
`,$=this.i;break;case n01:{let{entityReturnState:Y}=this,z=this.entity+U.slice($,this.prevI);this.state=Y;let I;if(z==="")this.fail("empty entity name."),I="&;";else I=this.parseEntity(z),this.entity="";if(Y!==h8||this.textHandler!==void 0)this.text+=I;break $}case x4:this.entity+=U.slice($);break $;default:}}sOpenWaka(){let $=this.getCode();if(gW($))this.state=x01,this.unget(),this.xmlDeclPossible=!1;else switch($){case KN:this.state=b01,this.xmlDeclPossible=!1;break;case p70:this.state=E01,this.openWakaBang="",this.xmlDeclPossible=!1;break;case s6:this.state=h01;break;default:this.fail("disallowed character in tag name"),this.state=h8,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case"[CDATA[":if(!this.sawRoot&&!this.reportedTextBeforeRoot)this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0;if(this.closedRoot&&!this.reportedTextAfterRoot)this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0;this.state=Jx,this.openWakaBang="";break;case"--":this.state=Qx,this.openWakaBang="";break;case"DOCTYPE":if(this.state=Yx,this.doctype||this.sawRoot)this.fail("inappropriately located doctype declaration.");this.openWakaBang="";break;default:if(this.openWakaBang.length>=7)this.fail("incorrect syntax.")}}sComment(){if(this.captureToChar(JN))this.state=C01}sCommentEnding(){var $;let U=this.getCodeNorm();if(U===JN)this.state=R01,($=this.commentHandler)===null||$===void 0||$.call(this,this.text),this.text="";else this.text+=`-${String.fromCodePoint(U)}`,this.state=Qx}sCommentEnded(){let $=this.getCodeNorm();if($!==T6)this.fail("malformed comment."),this.text+=`--${String.fromCodePoint($)}`,this.state=Qx;else this.state=h8}sCData(){if(this.captureToChar(hQ))this.state=_01}sCDataEnding(){let $=this.getCodeNorm();if($===hQ)this.state=v01;else this.text+=`]${String.fromCodePoint($)}`,this.state=Jx}sCDataEnding2(){var $;let U=this.getCodeNorm();switch(U){case T6:{($=this.cdataHandler)===null||$===void 0||$.call(this,this.text),this.text="",this.state=h8;break}case hQ:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(U)}`,this.state=Jx}}sPIFirstChar(){let $=this.getCodeNorm();if(this.nameStartCheck($))this.piTarget+=String.fromCodePoint($),this.state=f70;else if($===s6||m8($))this.fail("processing instruction without a target."),this.state=$===s6?QN:Kx;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint($),this.state=f70}sPIRest(){let{chunk:$,i:U}=this;while(!0){let Y=this.getCodeNorm();if(Y===x4){this.piTarget+=$.slice(U);return}if(!this.nameCheck(Y)){this.piTarget+=$.slice(U,this.prevI);let z=Y===s6;if(z||m8(Y))if(this.piTarget==="xml"){if(!this.xmlDeclPossible)this.fail("an XML declaration must be at the start of the document.");this.state=z?qY:u70}else this.state=z?QN:Kx;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(Y);break}}}sPIBody(){if(this.text.length===0){let $=this.getCodeNorm();if($===s6)this.state=QN;else if(!m8($))this.text=String.fromCodePoint($)}else if(this.captureToChar(s6))this.state=QN}sPIEnding(){var $;let U=this.getCodeNorm();if(U===T6){let{piTarget:Y}=this;if(Y.toLowerCase()==="xml")this.fail("the XML declaration must appear at the start of the document.");($=this.piHandler)===null||$===void 0||$.call(this,{target:Y,body:this.text}),this.piTarget=this.text="",this.state=h8}else if(U===s6)this.text+="?";else this.text+=`?${String.fromCodePoint(U)}`,this.state=Kx;this.xmlDeclPossible=!1}sXMLDeclNameStart(){let $=this.skipSpaces();if($===s6){this.state=qY;return}if($!==x4)this.state=S01,this.name=String.fromCodePoint($)}sXMLDeclName(){let $=this.captureTo(p01);if($===s6){this.state=qY,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(!(m8($)||$===vQ))return;if(this.name+=this.text,this.text="",!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail("did not expect any more name/value pairs.");break;case 1:this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`)}this.state=$===vQ?b70:g01}sXMLDeclEq(){let $=this.getCodeNorm();if($===s6){this.state=qY,this.fail("XML declaration is incomplete.");return}if(m8($))return;if($!==vQ)this.fail("value required.");this.state=b70}sXMLDeclValueStart(){let $=this.getCodeNorm();if($===s6){this.state=qY,this.fail("XML declaration is incomplete.");return}if(m8($))return;if(!GN($))this.fail("value must be quoted."),this.q=d70;else this.q=$;this.state=y01}sXMLDeclValue(){let $=this.captureTo([this.q,s6]);if($===s6){this.state=qY,this.text="",this.fail("XML declaration is incomplete.");return}if($===x4)return;let U=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let Y=U;if(this.xmlDecl.version=Y,!/^1\.[0-9]+$/.test(Y))this.fail("ver Line truncated
`;$=this.i,U=VY;break;case x4:if(z!==void 0)this.text+=Y.slice($);break $;default:U=VY}this.forbiddenState=U}handleTextOutsideRoot(){let{i:$}=this,{chunk:U,textHandler:Y}=this,z=!1;$:while(!0){let I=this.getCode();switch(I){case U2:{if(this.state=Ix,Y!==void 0){let{text:Q}=this,J=U.slice($,this.prevI);if(Q.length!==0)Y(Q+J),this.text="";else if(J.length!==0)Y(J)}break $}case kW:if(this.state=IN,this.entityReturnState=h8,Y!==void 0)this.text+=U.slice($,this.prevI);z=!0;break $;case X9:if(Y!==void 0)this.text+=`${U.slice($,this.prevI)}
`;$=this.i;break;case x4:if(Y!==void 0)this.text+=U.slice($);break $;default:if(!m8(I))z=!0}}if(!z)return;if(!this.sawRoot&&!this.reportedTextBeforeRoot)this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0;if(this.closedRoot&&!this.reportedTextAfterRoot)this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0}pushAttribNS($,U){var Y;let{prefix:z,local:I}=this.qname($),Q={name:$,prefix:z,local:I,value:U};if(this.attribList.push(Q),(Y=this.attributeHandler)===null||Y===void 0||Y.call(this,Q),z==="xmlns"){let J=U.trim();if(this.currentXMLVersion==="1.0"&&J==="")this.fail("invalid attempt to undefine prefix in XML 1.0");this.topNS[I]=J,qx(this,I,J)}else if($==="xmlns"){let J=U.trim();this.topNS[""]=J,qx(this,"",J)}}pushAttribPlain($,U){var Y;let z={name:$,value:U};this.attribList.push(z),(Y=this.attributeHandler)===null||Y===void 0||Y.call(this,z)}end(){var $,U;if(!this.sawRoot)this.fail("document must contain a root element.");let{tags:Y}=this;while(Y.length>0){let I=Y.pop();this.fail(`unclosed tag: ${I.name}`)}if(this.state!==x70&&this.state!==h8)this.fail("unexpected end.");let{text:z}=this;if(z.length!==0)($=this.textHandler)===null||$===void 0||$.call(this,z),this.text="";return this._closed=!0,(U=this.endHandler)===null||U===void 0||U.call(this),this._init(),this}resolve($){var U,Y;let z=this.topNS[$];if(z!==void 0)return z;let{tags:I}=this;for(let Q=I.length-1;Q>=0;Q--)if(z=I[Q].ns[$],z!==void 0)return z;if(z=this.ns[$],z!==void 0)return z;return(Y=(U=this.opt).resolvePrefix)===null||Y===void 0?void 0:Y.call(U,$)}qname($){let U=$.indexOf(":");if(U===-1)return{prefix:"",local:$};let Y=$.slice(U+1),z=$.slice(0,U);if(z===""||Y===""||Y.includes(":"))this.fail(`malformed name: ${$}.`);return{prefix:z,local:Y}}processAttribsNS(){var $;let{attribList:U}=this,Y=this.tag;{let{prefix:Q,local:J}=this.qname(Y.name);Y.prefix=Q,Y.local=J;let K=Y.uri=($=this.resolve(Q))!==null&&$!==void 0?$:"";if(Q!==""){if(Q==="xmlns")this.fail('tags may not have "xmlns" as prefix.');if(K==="")this.fail(`unbound namespace prefix: ${JSON.stringify(Q)}.`),Y.uri=Q}}if(U.length===0)return;let{attributes:z}=Y,I=new Set;for(let Q of U){let{name:J,prefix:K,local:G}=Q,H,W;if(K==="")H=J==="xmlns"?SQ:"",W=J;else{if(H=this.resolve(K),H===void 0)this.fail(`unbound namespace prefix: ${JSON.stringify(K)}.`),H=K;W=`{${H}}${G}`}if(I.has(W))this.fail(`duplicate attribute: ${W}.`);I.add(W),Q.uri=H,z[J]=Q}this.attribList=[]}processAttribsPlain(){let{attribList:$}=this,U=this.tag.attributes;for(let{name:Y,value:z}of $){if(U[Y]!==void 0)this.fail(`duplicate attribute: ${Y}.`);U[Y]=z}this.attribList=[]}openTag(){var $;this.processAttribs();let{tags:U}=this,Y=this.tag;Y.isSelfClosing=!1,($=this.openTagHandler)===null||$===void 0||$.call(this,Y),U.push(Y),this.state=h8,this.name=""}openSelfClosingTag(){var $,U,Y;this.processAttribs();let{tags:z}=this,I=this.tag;if(I.isSelfClosing=!0,($=this.openTagHandler)===null||$===void 0||$.call(this,I),(U=this.closeTagHandler)===null||U===void 0||U.call(this,I),(this.tag=(Y=z[z.length-1])!==null&&Y!==void 0?Y:null)===null)this.closedRoot=!0;this.state=h8,this.name=""}closeTag(){let{tags:$,name:U}=this;if(this.state=h8,this.name="",U===""){this.fail("weird empty close tag."),this.text+="</>";return}let Y=this.closeTagHandler,z=$.length;while(z-- >0){let I=this.tag=$.pop();if(this.topNS=I.ns,Y===null||Y===void 0||Y(I),I.name===U)break;this.fail("unexpected close tag.")}if(z===0)this.closedRoot=!0;else if(z<0)this.fail(`unmatched closing tag: ${U}.`),this.text+=`</${U}>`}parseEntity($){if($[0]!=="#"){let Y=this.ENTITIES[$];if(Y!==void 0)return Y;return this.fail(this.isName($)?"undefined entity.":"disallowed character in entity name."),`&${$};`}let U=NaN;if($[1]==="x"&&/^#x[0-9a-f]+$/i.test($))U=parseInt($.slice(2),16);else if(/^#[0-9]+$/.test($))U=parseInt($.slice(1),10);if(!this.isChar(U))return this.fail("malformed character entity."),`&${$};`;return String.fromCodePoint(U)}}Y20.SaxesParser=U20});var xW=E((Ol1,I20)=>{var{SaxesParser:t01}=z20(),{PassThrough:e01}=v8(),{bufferToString:$11}=sk();I20.exports=async function*($){if($.pipe&&!$[Symbol.asyncIterator])$=$.pipe(new e01);let U=new t01,Y;U.on("error",(I)=>{Y=I});let z=[];U.on("opentag",(I)=>z.push({eventType:"opentag",value:I})),U.on("text",(I)=>z.push({eventType:"text",value:I})),U.on("closetag",(I)=>z.push({eventType:"closetag",value:I}));for await(let I of $){if(U.write($11(I)),Y)throw Y;yield z,z=[]}}});var g0=E((Nl1,Q20)=>{var U11=xW(),Y11=r6();class yQ{prepare(){}render(){}parseOpen($){}parseText($){}parseClose($){}reconcile($,U){}reset(){if(this.model=null,this.map)Object.values(this.map).forEach(($)=>{if($ instanceof yQ)$.reset();else if($.xform)$.xform.reset()})}mergeModel($){this.model=Object.assign(this.model||{},$)}async parse($){for await(let U of $)for(let{eventType:Y,value:z}of U)if(Y==="opentag")this.parseOpen(z);else if(Y==="text")this.parseText(z);else if(Y==="closetag"){if(!this.parseClose(z.name))return thLine truncated
<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"> <a:themeElements> <a:clrScheme name="Office"> <a:dk1> <a:sysClr val="windowText" lastClr="000000"/> </a:dk1> <a:lt1> <a:sysClr val="window" lastClr="FFFFFF"/> </a:lt1> <a:dk2> <a:srgbClr val="1F497D"/> </a:dk2> <a:lt2> <a:srgbClr val="EEECE1"/> </a:lt2> <a:accent1> <a:srgbClr val="4F81BD"/> </a:accent1> <a:accent2> <a:srgbClr val="C0504D"/> </a:accent2> <a:accent3> <a:srgbClr val="9BBB59"/> </a:accent3> <a:accent4> <a:srgbClr val="8064A2"/> </a:accent4> <a:accent5> <a:srgbClr val="4BACC6"/> </a:accent5> <a:accent6> <a:srgbClr val="F79646"/> </a:accent6> <a:hlink> <a:srgbClr val="0000FF"/> </a:hlink> <a:folHlink> <a:srgbClr val="800080"/> </a:folHlink> </a:clrScheme> <a:fontScheme name="Office"> <a:majorFont> <a:latin typeface="Cambria"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Times New Roman"/> <a:font script="Hebr" typeface="Times New Roman"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="MoolBoran"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Times New Roman"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:majorFont> <a:minorFont> <a:latin typeface="Calibri"/> <a:ea typeface=""/> <a:cs typeface=""/> <a:font script="Jpan" typeface="MS Pゴシック"/> <a:font script="Hang" typeface="맑은 고딕"/> <a:font script="Hans" typeface="宋体"/> <a:font script="Hant" typeface="新細明體"/> <a:font script="Arab" typeface="Arial"/> <a:font script="Hebr" typeface="Arial"/> <a:font script="Thai" typeface="Tahoma"/> <a:font script="Ethi" typeface="Nyala"/> <a:font script="Beng" typeface="Vrinda"/> <a:font script="Gujr" typeface="Shruti"/> <a:font script="Khmr" typeface="DaunPenh"/> <a:font script="Knda" typeface="Tunga"/> <a:font script="Guru" typeface="Raavi"/> <a:font script="Cans" typeface="Euphemia"/> <a:font script="Cher" typeface="Plantagenet Cherokee"/> <a:font script="Yiii" typeface="Microsoft Yi Baiti"/> <a:font script="Tibt" typeface="Microsoft Himalaya"/> <a:font script="Thaa" typeface="MV Boli"/> <a:font script="Deva" typeface="Mangal"/> <a:font script="Telu" typeface="Gautami"/> <a:font script="Taml" typeface="Latha"/> <a:font script="Syrc" typeface="Estrangelo Edessa"/> <a:font script="Orya" typeface="Kalinga"/> <a:font script="Mlym" typeface="Kartika"/> <a:font script="Laoo" typeface="DokChampa"/> <a:font script="Sinh" typeface="Iskoola Pota"/> <a:font script="Mong" typeface="Mongolian Baiti"/> <a:font script="Viet" typeface="Arial"/> <a:font script="Uigh" typeface="Microsoft Uighur"/> <a:font script="Geor" typeface="Sylfaen"/> </a:minorFont> </a:fontScheme> <a:fmtScheme name="Office"> <a:fillStyleLst> <a:solidFill> <a:schemeClr val="phClr"/> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="35000"> <a:schemeClr val="phClr"> <a:tint val="37000"/> <a:satMod val="300000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="15000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="1"/> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="100000"/> <a:shade val="100000"/> <a:satMod val="130000"/> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:tint val="50000"/> <a:shade val="100000"/> <a:satMod val="350000"/> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="16200000" scaled="0"/> </a:gradFill> </a:fillStyleLst> <a:lnStyleLst> <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr"> <a:shade val="95000"/> <a:satMod val="105000"/> </a:schemeClr> </a:solidFill> <a:prstDash val="solid"/> </a:ln> <a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:Line truncated
`,this.quote='"',this.escape=this.quote,this.quoteColumns=!1,this.quoteHeaders=this.quoteColumns,this.headers=null,this.includeEndRowDelimiter=!1,this.writeBOM=!1,this.BOM="\uFEFF",this.alwaysWriteHeaders=!1,Object.assign(this,$||{}),typeof($===null||$===void 0?void 0:$.quoteHeaders)>"u")this.quoteHeaders=this.quoteColumns;if(($===null||$===void 0?void 0:$.quote)===!0)this.quote='"';else if(($===null||$===void 0?void 0:$.quote)===!1)this.quote="";if(typeof($===null||$===void 0?void 0:$.escape)!=="string")this.escape=this.quote;this.shouldWriteHeaders=!!this.headers&&((U=$.writeHeaders)!==null&&U!==void 0?U:!0),this.headers=Array.isArray(this.headers)?this.headers:null,this.escapedQuote=`${this.escape}${this.quote}`}}yJ0.FormatterOptions=gJ0});var nN=E((pr1,bJ0)=>{var Z91="[object AsyncFunction]",q91="[object Function]",V91="[object GeneratorFunction]",L91="[object Null]",w91="[object Proxy]",F91="[object Undefined]",M91=typeof global=="object"&&global&&global.Object===Object&&global,O91=typeof self=="object"&&self&&self.Object===Object&&self,N91=M91||O91||Function("return this")(),fJ0=Object.prototype,D91=fJ0.hasOwnProperty,uJ0=fJ0.toString,xJ0=N91.Symbol,DY=xJ0?xJ0.toStringTag:void 0;function A91($){if($==null)return $===void 0?F91:L91;return DY&&DY in Object($)?B91($):P91($)}function B91($){var U=D91.call($,DY),Y=$[DY];try{$[DY]=void 0;var z=!0}catch(Q){}var I=uJ0.call($);if(z)if(U)$[DY]=Y;else delete $[DY];return I}function P91($){return uJ0.call($)}function T91($){if(!j91($))return!1;var U=A91($);return U==q91||U==V91||U==Z91||U==w91}function j91($){var U=typeof $;return $!=null&&(U=="object"||U=="function")}bJ0.exports=T91});var DK0=E((cN,pQ)=>{var E91=200,xf="__lodash_hash_undefined__",aN=1,tJ0=2,eJ0=9007199254740991,dN="[object Arguments]",_f="[object Array]",C91="[object AsyncFunction]",$K0="[object Boolean]",UK0="[object Date]",YK0="[object Error]",zK0="[object Function]",R91="[object GeneratorFunction]",pN="[object Map]",IK0="[object Number]",_91="[object Null]",dQ="[object Object]",iJ0="[object Promise]",v91="[object Proxy]",QK0="[object RegExp]",mN="[object Set]",JK0="[object String]",h91="[object Symbol]",S91="[object Undefined]",vf="[object WeakMap]",KK0="[object ArrayBuffer]",lN="[object DataView]",g91="[object Float32Array]",y91="[object Float64Array]",k91="[object Int8Array]",x91="[object Int16Array]",f91="[object Int32Array]",u91="[object Uint8Array]",b91="[object Uint8ClampedArray]",i91="[object Uint16Array]",n91="[object Uint32Array]",c91=/[\\^$.*+?()[\]{}|]/g,d91=/^\[object .+?Constructor\]$/,p91=/^(?:0|[1-9]\d*)$/,T4={};T4[g91]=T4[y91]=T4[k91]=T4[x91]=T4[f91]=T4[u91]=T4[b91]=T4[i91]=T4[n91]=!0;T4[dN]=T4[_f]=T4[KK0]=T4[$K0]=T4[lN]=T4[UK0]=T4[YK0]=T4[zK0]=T4[pN]=T4[IK0]=T4[dQ]=T4[QK0]=T4[mN]=T4[JK0]=T4[vf]=!1;var GK0=typeof global=="object"&&global&&global.Object===Object&&global,m91=typeof self=="object"&&self&&self.Object===Object&&self,F3=GK0||m91||Function("return this")(),HK0=typeof cN=="object"&&cN&&!cN.nodeType&&cN,nJ0=HK0&&typeof pQ=="object"&&pQ&&!pQ.nodeType&&pQ,WK0=nJ0&&nJ0.exports===HK0,Ef=WK0&&GK0.process,cJ0=function(){try{return Ef&&Ef.binding&&Ef.binding("util")}catch($){}}(),dJ0=cJ0&&cJ0.isTypedArray;function l91($,U){var Y=-1,z=$==null?0:$.length,I=0,Q=[];while(++Y<z){var J=$[Y];if(U(J,Y,$))Q[I++]=J}return Q}function o91($,U){var Y=-1,z=U.length,I=$.length;while(++Y<z)$[I+Y]=U[Y];return $}function r91($,U){var Y=-1,z=$==null?0:$.length;while(++Y<z)if(U($[Y],Y,$))return!0;return!1}function s91($,U){var Y=-1,z=Array($);while(++Y<$)z[Y]=U(Y);return z}function a91($){return function(U){return $(U)}}function t91($,U){return $.has(U)}function e91($,U){return $==null?void 0:$[U]}function $31($){var U=-1,Y=Array($.size);return $.forEach(function(z,I){Y[++U]=[I,z]}),Y}function U31($,U){return function(Y){return $(U(Y))}}function Y31($){var U=-1,Y=Array($.size);return $.forEach(function(z){Y[++U]=z}),Y}var z31=Array.prototype,I31=Function.prototype,tN=Object.prototype,Cf=F3["__core-js_shared__"],XK0=I31.toString,q9=tN.hasOwnProperty,pJ0=function(){var $=/[^.]+$/.exec(Cf&&Cf.keys&&Cf.keys.IE_PROTO||"");return $?"Symbol(src)_1."+$:""}(),ZK0=tN.toString,Q31=RegExp("^"+XK0.call(q9).replace(c91,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),mJ0=WK0?F3.Buffer:void 0,oN=F3.Symbol,lJ0=F3.Uint8Array,qK0=tN.propertyIsEnumerable,J31=z31.splice,AY=oN?oN.toStringTag:void 0,oJ0=Object.getOwnPropertySymbols,K31=mJ0?mJ0.isBuffer:void 0,G31=U31(Object.keys,Object),hf=mQ(F3,"DataView"),dW=mQ(F3,"Map"),Sf=mQ(F3,"Promise"),gf=mQ(F3,"Set"),yf=mQ(F3,"WeakMap"),pW=mQ(Object,"create"),H31=TY(hf),W31=TY(dW),X31=TY(Sf),Z31=TY(gf),q31=TY(yf),rJ0=oN?oN.prototype:void 0,Rf=rJ0?rJ0.valueOf:void 0;function BY($){var U=-1,Y=$==null?0:$.length;this.clear();while(++U<Y){var z=$[U];this.set(z[0],z[1])}}function V31(){this.__data__=pW?pW(null):{},this.size=0}function L31($){var U=this.has($)&&delete this.__data__[$];return this.size-=U?1:0,U}function w31($){var U=this.__data Line truncated
]`;this.ESCAPE_REGEXP=new RegExp(U)}set headers($){this._headers=$}shouldQuote($,U){let Y=U?this.formatterOptions.quoteHeaders:this.formatterOptions.quoteColumns;if(A71.default(Y))return Y;if(Array.isArray(Y))return Y[$];if(this._headers!==null)return Y[this._headers[$]];return!1}format($,U,Y){let z=`${B71.default($)?"":$}`.replace(/\0/g,""),{formatterOptions:I}=this;if(I.quote!==""){if(z.indexOf(I.quote)!==-1)return this.quoteField(z.replace(this.REPLACE_REGEXP,I.escapedQuote))}if(z.search(this.ESCAPE_REGEXP)!==-1||this.shouldQuote(U,Y))return this.quoteField(z);return z}quoteField($){let{quote:U}=this.formatterOptions;return`${U}${$}${U}`}}lQ.FieldFormatter=_K0});var cf=E((vK0)=>{Object.defineProperty(vK0,"__esModule",{value:!0});vK0.isSyncTransform=void 0;vK0.isSyncTransform=($)=>$.length===1});var gK0=E((oQ)=>{var SK0=oQ&&oQ.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(oQ,"__esModule",{value:!0});oQ.RowFormatter=void 0;var T71=SK0(nN()),j71=SK0(DK0()),E71=nf(),C71=cf();class jY{constructor($){if(this.rowCount=0,this.formatterOptions=$,this.fieldFormatter=new E71.FieldFormatter($),this.headers=$.headers,this.shouldWriteHeaders=$.shouldWriteHeaders,this.hasWrittenHeaders=!1,this.headers!==null)this.fieldFormatter.headers=this.headers;if($.transform)this.rowTransform=$.transform}static isRowHashArray($){if(Array.isArray($))return Array.isArray($[0])&&$[0].length===2;return!1}static isRowArray($){return Array.isArray($)&&!this.isRowHashArray($)}static gatherHeaders($){if(jY.isRowHashArray($))return $.map((U)=>U[0]);if(Array.isArray($))return $;return Object.keys($)}static createTransform($){if(C71.isSyncTransform($))return(U,Y)=>{let z=null;try{z=$(U)}catch(I){return Y(I)}return Y(null,z)};return(U,Y)=>{$(U,Y)}}set rowTransform($){if(!T71.default($))throw TypeError("The transform should be a function");this._rowTransform=jY.createTransform($)}format($,U){this.callTransformer($,(Y,z)=>{if(Y)return U(Y);if(!$)return U(null);let I=[];if(z){let{shouldFormatColumns:Q,headers:J}=this.checkHeaders(z);if(this.shouldWriteHeaders&&J&&!this.hasWrittenHeaders)I.push(this.formatColumns(J,!0)),this.hasWrittenHeaders=!0;if(Q){let K=this.gatherColumns(z);I.push(this.formatColumns(K,!1))}}return U(null,I)})}finish($){let U=[];if(this.formatterOptions.alwaysWriteHeaders&&this.rowCount===0){if(!this.headers)return $(Error("`alwaysWriteHeaders` option is set to true but `headers` option not provided."));U.push(this.formatColumns(this.headers,!0))}if(this.formatterOptions.includeEndRowDelimiter)U.push(this.formatterOptions.rowDelimiter);return $(null,U)}checkHeaders($){if(this.headers)return{shouldFormatColumns:!0,headers:this.headers};let U=jY.gatherHeaders($);if(this.headers=U,this.fieldFormatter.headers=U,!this.shouldWriteHeaders)return{shouldFormatColumns:!0,headers:null};return{shouldFormatColumns:!j71.default(U,$),headers:U}}gatherColumns($){if(this.headers===null)throw Error("Headers is currently null");if(!Array.isArray($))return this.headers.map((U)=>$[U]);if(jY.isRowHashArray($))return this.headers.map((U,Y)=>{let z=$[Y];if(z)return z[1];return""});if(jY.isRowArray($)&&!this.shouldWriteHeaders)return $;return this.headers.map((U,Y)=>$[Y])}callTransformer($,U){if(!this._rowTransform)return U(null,$);return this._rowTransform($,U)}formatColumns($,U){let Y=$.map((I,Q)=>this.fieldFormatter.format(I,Q,U)).join(this.formatterOptions.delimiter),{rowCount:z}=this;if(this.rowCount+=1,z)return[this.formatterOptions.rowDelimiter,Y].join("");return Y}}oQ.RowFormatter=jY});var yK0=E((UD)=>{Object.defineProperty(UD,"__esModule",{value:!0});UD.FieldFormatter=UD.RowFormatter=void 0;var R71=gK0();Object.defineProperty(UD,"RowFormatter",{enumerable:!0,get:function(){return R71.RowFormatter}});var _71=nf();Object.defineProperty(UD,"FieldFormatter",{enumerable:!0,get:function(){return _71.FieldFormatter}})});var df=E((xK0)=>{Object.defineProperty(xK0,"__esModule",{value:!0});xK0.CsvFormatterStream=void 0;var h71=J0("stream"),S71=yK0();class kK0 extends h71.Transform{constructor($){super({writableObjectMode:$.objectMode});this.hasWrittenBOM=!1,this.formatterOptions=$,this.rowFormatter=new S71.RowFormatter($),this.hasWrittenBOM=!$.writeBOM}transform($){return this.rowFormatter.rowTransform=$,this}_transform($,U,Y){let z=!1;try{if(!this.hasWrittenBOM)this.push(this.formatterOptions.BOM),this.hasWrittenBOM=!0;this.rowFormatter.format($,(I,Q)=>{if(I)return z=!0,Y(I);if(Q)Q.forEach((J)=>{this.push(Buffer.from(J,"utf8"))});return z=!0,Y()})}catch(I){if(z)throw I;Y(I)}}_flush($){this.rowFormatter.finish((U,Y)=>{if(U)return $(U);if(Y)Y.forEach((z)=>{this.push(Buffer.from(z,"utf8"))});return $()})}}xK0.CsvFormatterStream=kK0});var bK0=E((a1)=>{var uK0=a1&&a1.__createBinding||(Object.create?function($,U,Y,z){if(z===void 0)z=Y;Object.defineProperty($,z,{enumerable:!0,get:function(){return U[Y]}})}:function($,U,Y,z){if(z===void 0)z=Y;$[z]=U[Y]}),g71=a1&&a1.__setModuleDefault||(Object.create?function($,U){O Line truncated
`||U===`\r
`}static isTokenCarriageReturn($,U){return $.token===U.carriageReturn}static isTokenComment($,U){return U.supportsComments&&!!$&&$.token===U.comment}static isTokenEscapeCharacter($,U){return $.token===U.escapeChar}static isTokenQuote($,U){return $.token===U.quote}static isTokenDelimiter($,U){return $.token===U.delimiter}}iG0.Token=bG0});var Vu=E((pG0)=>{Object.defineProperty(pG0,"__esModule",{value:!0});pG0.Scanner=void 0;var cG0=Z2(),nY1=/((?:\r\n)|\n|\r)/;class dG0{constructor($){this.cursor=0,this.line=$.line,this.lineLength=this.line.length,this.parserOptions=$.parserOptions,this.hasMoreData=$.hasMoreData,this.cursor=$.cursor||0}get hasMoreCharacters(){return this.lineLength>this.cursor}get nextNonSpaceToken(){let{lineFromCursor:$}=this,U=this.parserOptions.NEXT_TOKEN_REGEXP;if($.search(U)===-1)return null;let Y=U.exec($);if(Y==null)return null;let z=Y[1],I=this.cursor+(Y.index||0);return new cG0.Token({token:z,startCursor:I,endCursor:I+z.length-1})}get nextCharacterToken(){let{cursor:$,lineLength:U}=this;if(U<=$)return null;return new cG0.Token({token:this.line[$],startCursor:$,endCursor:$})}get lineFromCursor(){return this.line.substr(this.cursor)}advancePastLine(){let $=nY1.exec(this.lineFromCursor);if(!$){if(this.hasMoreData)return null;return this.cursor=this.lineLength,this}return this.cursor+=($.index||0)+$[0].length,this}advanceTo($){return this.cursor=$,this}advanceToToken($){return this.cursor=$.startCursor,this}advancePastToken($){return this.cursor=$.endCursor+1,this}truncateToCursor(){return this.line=this.lineFromCursor,this.lineLength=this.line.length,this.cursor=0,this}}pG0.Scanner=dG0});var PD=E((oG0)=>{Object.defineProperty(oG0,"__esModule",{value:!0});oG0.ColumnFormatter=void 0;class lG0{constructor($){if($.trim)this.format=(U)=>U.trim();else if($.ltrim)this.format=(U)=>U.trimLeft();else if($.rtrim)this.format=(U)=>U.trimRight();else this.format=(U)=>U}}oG0.ColumnFormatter=lG0});var Lu=E((tG0)=>{Object.defineProperty(tG0,"__esModule",{value:!0});tG0.NonQuotedColumnParser=void 0;var cY1=PD(),sG0=Z2();class aG0{constructor($){this.parserOptions=$,this.columnFormatter=new cY1.ColumnFormatter($)}parse($){if(!$.hasMoreCharacters)return null;let{parserOptions:U}=this,Y=[],z=$.nextCharacterToken;for(;z;z=$.nextCharacterToken){if(sG0.Token.isTokenDelimiter(z,U)||sG0.Token.isTokenRowDelimiter(z))break;Y.push(z.token),$.advancePastToken(z)}return this.columnFormatter.format(Y.join(""))}}tG0.NonQuotedColumnParser=aG0});var wu=E((UH0)=>{Object.defineProperty(UH0,"__esModule",{value:!0});UH0.QuotedColumnParser=void 0;var dY1=PD(),QJ=Z2();class $H0{constructor($){this.parserOptions=$,this.columnFormatter=new dY1.ColumnFormatter($)}parse($){if(!$.hasMoreCharacters)return null;let U=$.cursor,{foundClosingQuote:Y,col:z}=this.gatherDataBetweenQuotes($);if(!Y){if($.advanceTo(U),!$.hasMoreData)throw Error(`Parse Error: missing closing: '${this.parserOptions.quote||""}' in line: at '${$.lineFromCursor.replace(/[\r\n]/g,"\\n'")}'`);return null}return this.checkForMalformedColumn($),z}gatherDataBetweenQuotes($){let{parserOptions:U}=this,Y=!1,z=!1,I=[],Q=$.nextCharacterToken;for(;!z&&Q!==null;Q=$.nextCharacterToken){let J=QJ.Token.isTokenQuote(Q,U);if(!Y&&J)Y=!0;else if(Y)if(QJ.Token.isTokenEscapeCharacter(Q,U)){$.advancePastToken(Q);let K=$.nextCharacterToken;if(K!==null&&(QJ.Token.isTokenQuote(K,U)||QJ.Token.isTokenEscapeCharacter(K,U)))I.push(K.token),Q=K;else if(J)z=!0;else I.push(Q.token)}else if(J)z=!0;else I.push(Q.token);$.advancePastToken(Q)}return{col:this.columnFormatter.format(I.join("")),foundClosingQuote:z}}checkForMalformedColumn($){let{parserOptions:U}=this,{nextNonSpaceToken:Y}=$;if(Y){let z=QJ.Token.isTokenDelimiter(Y,U),I=QJ.Token.isTokenRowDelimiter(Y);if(!(z||I)){let Q=$.lineFromCursor.substr(0,10).replace(/[\r\n]/g,"\\n'");throw Error(`Parse Error: expected: '${U.escapedDelimiter}' OR new line got: '${Y.token}'. at '${Q}`)}$.advanceToToken(Y)}else if(!$.hasMoreData)$.advancePastLine()}}UH0.QuotedColumnParser=$H0});var JH0=E((IH0)=>{Object.defineProperty(IH0,"__esModule",{value:!0});IH0.ColumnParser=void 0;var pY1=Lu(),mY1=wu(),lY1=Z2();class zH0{constructor($){this.parserOptions=$,this.quotedColumnParser=new mY1.QuotedColumnParser($),this.nonQuotedColumnParser=new pY1.NonQuotedColumnParser($)}parse($){let{nextNonSpaceToken:U}=$;if(U!==null&&lY1.Token.isTokenQuote(U,this.parserOptions))return $.advanceToToken(U),this.quotedColumnParser.parse($);return this.nonQuotedColumnParser.parse($)}}IH0.ColumnParser=zH0});var Fu=E((JJ)=>{Object.defineProperty(JJ,"__esModule",{value:!0});JJ.ColumnFormatter=JJ.QuotedColumnParser=JJ.NonQuotedColumnParser=JJ.ColumnParser=void 0;var oY1=JH0();Object.defineProperty(JJ,"ColumnParser",{enumerable:!0,get:function(){return oY1.ColumnParser}});var rY1=Lu();Object.defineProperty(JJ,"NonQuotedColumnParser",{enumerable:!0,get:function(){return rY1.NonQuotedColumnParser}});var sY1=wu();Object.defineProperty(JJ,"QuotedColumnParser",{enumerable:!0,get:function(){re Line truncated
%s`,T,T,q,z);let A=q.type==="*"?hu:q.type==="?"?yu:"\\"+q.type;I=!0,z=z.slice(0,q.reStart)+A+"\\("+T}if(O(),Q)z+="\\\\";let D=iz1[z.charAt(0)];for(let T=K.length-1;T>-1;T--){let A=K[T],j=z.slice(0,A.reStart),C=z.slice(A.reStart,A.reEnd-8),b=z.slice(A.reEnd),x=z.slice(A.reEnd-8,A.reEnd)+b,g=j.split(")").length,i=j.split("(").length-g,n=b;for(let k=0;k<i;k++)n=n.replace(/\)[+*?]?/,"");b=n;let z0=b===""&&U!==Su?"(?:$|\\/)":"";z=j+C+b+z0+x}if(z!==""&&I)z="(?=.)"+z;if(D)z=w()+z;if(U===Su)return[z,I];if(Y.nocase&&!I)I=$.toUpperCase()!==$.toLowerCase();if(!I)return cz1($);let P=Y.nocase?"i":"";try{return Object.assign(new RegExp("^"+z+"$",P),{_glob:$,_src:z})}catch(T){return new RegExp("$.")}}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let $=this.set;if(!$.length)return this.regexp=!1,this.regexp;let U=this.options,Y=U.noglobstar?hu:U.dot?uz1:bz1,z=U.nocase?"i":"",I=$.map((Q)=>{return Q=Q.map((J)=>typeof J==="string"?pz1(J):J===S8?S8:J._src).reduce((J,K)=>{if(!(J[J.length-1]===S8&&K===S8))J.push(K);return J},[]),Q.forEach((J,K)=>{if(J!==S8||Q[K-1]===S8)return;if(K===0)if(Q.length>1)Q[K+1]="(?:\\/|"+Y+"\\/)?"+Q[K+1];else Q[K]=Y;else if(K===Q.length-1)Q[K-1]+="(?:\\/|"+Y+")?";else Q[K-1]+="(?:\\/|\\/"+Y+"\\/)"+Q[K+1],Q[K+1]=S8}),Q.filter((J)=>J!==S8).join("/")}).join("|");if(I="^(?:"+I+")$",this.negate)I="^(?!"+I+").*$";try{this.regexp=new RegExp(I,z)}catch(Q){this.regexp=!1}return this.regexp}match($,U=this.partial){if(this.debug("match",$,this.pattern),this.comment)return!1;if(this.empty)return $==="";if($==="/"&&U)return!0;let Y=this.options;if(gu.sep!=="/")$=$.split(gu.sep).join("/");$=$.split(eH0),this.debug(this.pattern,"split",$);let z=this.set;this.debug(this.pattern,"set",z);let I;for(let Q=$.length-1;Q>=0;Q--)if(I=$[Q],I)break;for(let Q=0;Q<z.length;Q++){let J=z[Q],K=$;if(Y.matchBase&&J.length===1)K=[I];if(this.matchOne(K,J,U)){if(Y.flipNegate)return!0;return!this.negate}}if(Y.flipNegate)return!1;return this.negate}static defaults($){return X$.defaults($).Minimatch}}X$.Minimatch=eW});var KW0=E(($a1,JW0)=>{JW0.exports=QW0;var fu=J0("fs"),{EventEmitter:lz1}=J0("events"),{Minimatch:xu}=YW0(),{resolve:oz1}=J0("path");function rz1($,U){return new Promise((Y,z)=>{fu.readdir($,{withFileTypes:!0},(I,Q)=>{if(I)switch(I.code){case"ENOTDIR":if(U)z(I);else Y([]);break;case"ENOTSUP":case"ENOENT":case"ENAMETOOLONG":case"UNKNOWN":Y([]);break;case"ELOOP":default:z(I);break}else Y(Q)})})}function zW0($,U){return new Promise((Y,z)=>{(U?fu.stat:fu.lstat)($,(Q,J)=>{if(Q)switch(Q.code){case"ENOENT":if(U)Y(zW0($,!1));else Y(null);break;default:Y(null);break}else Y(J)})})}async function*IW0($,U,Y,z,I,Q){let J=await rz1(U+$,Q);for(let K of J){let G=K.name;if(G===void 0)G=K,z=!0;let H=$+"/"+G,W=H.slice(1),X=U+"/"+W,Z=null;if(z||Y)Z=await zW0(X,Y);if(!Z&&K.name!==void 0)Z=K;if(Z===null)Z={isDirectory:()=>!1};if(Z.isDirectory()){if(!I(W))yield{relative:W,absolute:X,stats:Z},yield*IW0(H,U,Y,z,I,!1)}else yield{relative:W,absolute:X,stats:Z}}}async function*sz1($,U,Y,z){yield*IW0("",$,U,Y,z,!0)}function az1($){return{pattern:$.pattern,dot:!!$.dot,noglobstar:!!$.noglobstar,matchBase:!!$.matchBase,nocase:!!$.nocase,ignore:$.ignore,skip:$.skip,follow:!!$.follow,stat:!!$.stat,nodir:!!$.nodir,mark:!!$.mark,silent:!!$.silent,absolute:!!$.absolute}}class uu extends lz1{constructor($,U,Y){super();if(typeof U==="function")Y=U,U=null;if(this.options=az1(U||{}),this.matchers=[],this.options.pattern){let z=Array.isArray(this.options.pattern)?this.options.pattern:[this.options.pattern];this.matchers=z.map((I)=>new xu(I,{dot:this.options.dot,noglobstar:this.options.noglobstar,matchBase:this.options.matchBase,nocase:this.options.nocase}))}if(this.ignoreMatchers=[],this.options.ignore){let z=Array.isArray(this.options.ignore)?this.options.ignore:[this.options.ignore];this.ignoreMatchers=z.map((I)=>new xu(I,{dot:!0}))}if(this.skipMatchers=[],this.options.skip){let z=Array.isArray(this.options.skip)?this.options.skip:[this.options.skip];this.skipMatchers=z.map((I)=>new xu(I,{dot:!0}))}if(this.iterator=sz1(oz1($||"."),this.options.follow,this.options.stat,this._shouldSkipDirectory.bind(this)),this.paused=!1,this.inactive=!1,this.aborted=!1,Y)this._matches=[],this.on("match",(z)=>this._matches.push(this.options.absolute?z.absolute:z.relative)),this.on("error",(z)=>Y(z)),this.on("end",()=>Y(null,this._matches));setTimeout(()=>this._next(),0)}_shouldSkipDirectory($){return this.skipMatchers.some((U)=>U.match($))}_fileMatches($,U){let Y=$+(U?"/":"");return(this.matchers.length===0||this.matchers.some((z)=>z.match(Y)))&&!this.ignoreMatchers.some((z)=>z.match(Y))&&(!this.options.nodir||!U)}_next(){if(!this.paused&&!this.aborted)this.iterator.next().then(($)=>{if(!$.done){let U=$.value.stats.isDirectory();if(this._fileMatches($.value.relative,U)){let Y=$.value.relative,z=$.value.absolute;if(this.options.mark&&U)Y+="/",z+="/";if(this.options.stat)this.emit("match",{relative:Y,absolute:z,stat:$.value.stats});else this.emit("match",{relative:Y Line truncated
`,r);r=L0===-1?f.length:L0}else if(K0!==-1&&f[r]==="/"&&f[r+1]==="*"){let L0=f.indexOf("*/",r);if(L0!==-1)r=L0+2,K0=f.indexOf("*/",r);else c+=f[r],r++}else c+=f[r],r++;return c}function n0(f){let c=b0(f.toString()),r=c.match(t);if(!r)r=c.match(X0);if(!r)throw Error(`could not parse args in autoInject
Source:
`+c);let[,K0]=o;return K0.replace(/\s/g,"").split(F0).map((O0)=>O0.replace(b0,"").trim())}function w1(f,c){var o={};return Object.keys(f).forEach((K0)=>{var O0=f[K0],D0,P0=q(O0),j0=!P0&&O0.length===1||P0&&O0.length===0;if(Array.isArray(O0))D0=[...O0],O0=D0.pop(),o[K0]=D0.concat(D0.length>0?h0:O0);else if(j0)o[K0]=O0;else{if(D0=n0(O0),O0.length===0&&!P0&&D0.length===0)throw Error("autoInject task functions require explicit parameters.");if(!P0)D0.pop();o[K0]=D0.concat(h0)}function h0(z1,x1){var m1=D0.map((i1)=>z1[i1]);m1.push(x1),w(O0)(...m1)}}),e0(o,c)}class k1{constructor(){this.head=this.tail=null,this.length=0}removeLink(f){if(f.prev)f.prev.next=f.next;else this.head=f.next;if(f.next)f.next.prev=f.prev;else this.tail=f.prev;return f.prev=f.next=null,this.length-=1,f}empty(){while(this.head)this.shift();return this}insertAfter(f,c){if(c.prev=f,c.next=f.next,f.next)f.next.prev=c;else this.tail=c;f.next=c,this.length+=1}insertBefore(f,c){if(c.prev=f.prev,c.next=f,f.prev)f.prev.next=c;else this.head=c;f.prev=c,this.length+=1}unshift(f){if(this.head)this.insertBefore(this.head,f);else u1(this,f)}push(f){if(this.tail)this.insertAfter(this.tail,f);else u1(this,f)}shift(){return this.head&&this.removeLink(this.head)}pop(){return this.tail&&this.removeLink(this.tail)}toArray(){return[...this]}*[Symbol.iterator](){var f=this.head;while(f)yield f.data,f=f.next}remove(f){var c=this.head;while(c){var{next:o}=c;if(f(c))this.removeLink(c);c=o}return this}}function u1(f,c){f.length=1,f.head=f.tail=c}function b1(f,c,o){if(c==null)c=1;else if(c===0)throw RangeError("Concurrency must not be zero");var K0=w(f),O0=0,D0=[];let P0={error:[],drain:[],saturated:[],unsaturated:[],empty:[]};function j0(G1,$1){P0[G1].push($1)}function h0(G1,$1){let H1=(...n1)=>{z1(G1,H1),$1(...n1)};P0[G1].push(H1)}function z1(G1,$1){if(!G1)return Object.keys(P0).forEach((H1)=>P0[H1]=[]);if(!$1)return P0[G1]=[];P0[G1]=P0[G1].filter((H1)=>H1!==$1)}function x1(G1,...$1){P0[G1].forEach((H1)=>H1(...$1))}var m1=!1;function i1(G1,$1,H1,n1){if(n1!=null&&typeof n1!=="function")throw Error("task callback must be a function");l1.started=!0;var g4,h6;function D$(PY,...rK){if(PY)return H1?h6(PY):g4();if(rK.length<=1)return g4(rK[0]);g4(rK)}var pU=l1._createTaskItem(G1,H1?D$:n1||D$);if($1)l1._tasks.unshift(pU);else l1._tasks.push(pU);if(!m1)m1=!0,H(()=>{m1=!1,l1.process()});if(H1||!n1)return new Promise((PY,rK)=>{g4=PY,h6=rK})}function N$(G1){return function($1,...H1){O0-=1;for(var n1=0,g4=G1.length;n1<g4;n1++){var h6=G1[n1],D$=D0.indexOf(h6);if(D$===0)D0.shift();else if(D$>0)D0.splice(D$,1);if(h6.callback($1,...H1),$1!=null)x1("error",$1,h6.data)}if(O0<=l1.concurrency-l1.buffer)x1("unsaturated");if(l1.idle())x1("drain");l1.process()}}function cU(G1){if(G1.length===0&&l1.idle())return H(()=>x1("drain")),!0;return!1}let BY=(G1)=>($1)=>{if(!$1)return new Promise((H1,n1)=>{h0(G1,(g4,h6)=>{if(g4)return n1(g4);H1(h6)})});z1(G1),j0(G1,$1)};var oK=!1,l1={_tasks:new k1,_createTaskItem(G1,$1){return{data:G1,callback:$1}},*[Symbol.iterator](){yield*l1._tasks[Symbol.iterator]()},concurrency:c,payload:o,buffer:c/4,started:!1,paused:!1,push(G1,$1){if(Array.isArray(G1)){if(cU(G1))return;return G1.map((H1)=>i1(H1,!1,!1,$1))}return i1(G1,!1,!1,$1)},pushAsync(G1,$1){if(Array.isArray(G1)){if(cU(G1))return;return G1.map((H1)=>i1(H1,!1,!0,$1))}return i1(G1,!1,!0,$1)},kill(){z1(),l1._tasks.empty()},unshift(G1,$1){if(Array.isArray(G1)){if(cU(G1))return;return G1.map((H1)=>i1(H1,!0,!1,$1))}return i1(G1,!0,!1,$1)},unshiftAsync(G1,$1){if(Array.isArray(G1)){if(cU(G1))return;return G1.map((H1)=>i1(H1,!0,!0,$1))}return i1(G1,!0,!0,$1)},remove(G1){l1._tasks.remove(G1)},process(){if(oK)return;oK=!0;while(!l1.paused&&O0<l1.concurrency&&l1._tasks.length){var G1=[],$1=[],H1=l1._tasks.length;if(l1.payload)H1=Math.min(H1,l1.payload);for(var n1=0;n1<H1;n1++){var g4=l1._tasks.shift();G1.push(g4),D0.push(g4),$1.push(g4.data)}if(O0+=1,l1._tasks.length===0)x1("empty");if(O0===l1.concurrency)x1("saturated");var h6=S(N$(G1));K0($1,h6)}oK=!1},length(){return l1._tasks.length},running(){return O0},workersList(){return D0},idle(){return l1._tasks.length+O0===0},pause(){l1.paused=!0},resume(){if(l1.paused===!1)return;l1.paused=!1,H(l1.process)}};return Object.defineProperties(l1,{saturated:{writable:!1,value:BY("saturated")},unsaturated:{writable:!1,value:BY("unsaturated")},empty:{writable:!1,value:BY("empty")},drain:{writable:!1,value:BY("drain")},error:{writable:!1,value:BY("error")}}),l1}function A0(f,c){return b1(f,1,c)}function Q0(f,c,o){return b1(f,c,o)}function B(f,c,o,K0){K0=j(K0);var O0=w(o);return $0(f,(D0,P0,j0)=>{O0(c,D0,(h0,z1)=>{c=z1,j0(h0)})},(D0)=>K0(D0,c))}var v=O(B,4);function u(...f){var c=f.map(w);return function(...o){var K0=this,O0=o[o.length-1];if(typeof O0=="function")o.pop();else O0=f0();return v(c,o,(D0,P0,j0)=>{P0.apply(K0,D0.concat((h0,...z1)=>{j0(h0,z1)}))},(D0,P0)=>O0(D0,...P0)),O0[G0]}}function a(...f){return u(...f.reverse())}function X0(f,c,o,K0){return M(n(c),f,o,K0)}var J Line truncated
GFS4: `),console.error($)};if(!d4[a6]){if(Eu=global[a6]||[],IW0(d4,Eu),d4.close=function($){function Y(z,U){return $.call(d4,z,function(Q){if(!Q)JW0();if(typeof U==="function")U.apply(this,arguments)})}return Object.defineProperty(Y,CD,{value:$}),Y}(d4.close),d4.closeSync=function($){function Y(z){$.apply(d4,arguments),JW0()}return Object.defineProperty(Y,CD,{value:$}),Y}(d4.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))process.on("exit",function(){_z(d4[a6]),I0("assert").equal(d4[a6].length,0)})}var Eu;if(!global[a6])IW0(global,d4[a6]);_u.exports=Cu(hU1(d4));if(process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!d4.__patched)_u.exports=Cu(d4),d4.__patched=!0;function Cu($){_U1($),$.gracefulify=Cu,$.createReadStream=P,$.createWriteStream=j;var Y=$.readFile;$.readFile=z;function z(C,b,k){if(typeof b==="function")k=b,b=null;return S(C,b,k);function S(i,n,U0,x){return Y(i,n,function(d){if(d&&(d.code==="EMFILE"||d.code==="ENFILE"))GI([S,[i,n,U0],d,x||Date.now(),Date.now()]);else if(typeof U0==="function")U0.apply(this,arguments)})}}var U=$.writeFile;$.writeFile=Q;function Q(C,b,k,S){if(typeof k==="function")S=k,k=null;return i(C,b,k,S);function i(n,U0,x,d,t){return U(n,U0,x,function(e){if(e&&(e.code==="EMFILE"||e.code==="ENFILE"))GI([i,[n,U0,x,d],e,t||Date.now(),Date.now()]);else if(typeof d==="function")d.apply(this,arguments)})}}var J=$.appendFile;if(J)$.appendFile=I;function I(C,b,k,S){if(typeof k==="function")S=k,k=null;return i(C,b,k,S);function i(n,U0,x,d,t){return J(n,U0,x,function(e){if(e&&(e.code==="EMFILE"||e.code==="ENFILE"))GI([i,[n,U0,x,d],e,t||Date.now(),Date.now()]);else if(typeof d==="function")d.apply(this,arguments)})}}var K=$.copyFile;if(K)$.copyFile=G;function G(C,b,k,S){if(typeof k==="function")S=k,k=0;return i(C,b,k,S);function i(n,U0,x,d,t){return K(n,U0,x,function(e){if(e&&(e.code==="EMFILE"||e.code==="ENFILE"))GI([i,[n,U0,x,d],e,t||Date.now(),Date.now()]);else if(typeof d==="function")d.apply(this,arguments)})}}var H=$.readdir;$.readdir=X;var W=/^v[0-5]\./;function X(C,b,k){if(typeof b==="function")k=b,b=null;var S=W.test(process.version)?function(U0,x,d,t){return H(U0,i(U0,x,d,t))}:function(U0,x,d,t){return H(U0,x,i(U0,x,d,t))};return S(C,b,k);function i(n,U0,x,d){return function(t,e){if(t&&(t.code==="EMFILE"||t.code==="ENFILE"))GI([S,[n,U0,x],t,d||Date.now(),Date.now()]);else{if(e&&e.sort)e.sort();if(typeof x==="function")x.call(this,t,e)}}}}if(process.version.substr(0,4)==="v0.8"){var Z=vU1($);O=Z.ReadStream,M=Z.WriteStream}var q=$.ReadStream;if(q)O.prototype=Object.create(q.prototype),O.prototype.open=N;var V=$.WriteStream;if(V)M.prototype=Object.create(V.prototype),M.prototype.open=D;Object.defineProperty($,"ReadStream",{get:function(){return O},set:function(C){O=C},enumerable:!0,configurable:!0}),Object.defineProperty($,"WriteStream",{get:function(){return M},set:function(C){M=C},enumerable:!0,configurable:!0});var F=O;Object.defineProperty($,"FileReadStream",{get:function(){return F},set:function(C){F=C},enumerable:!0,configurable:!0});var w=M;Object.defineProperty($,"FileWriteStream",{get:function(){return w},set:function(C){w=C},enumerable:!0,configurable:!0});function O(C,b){if(this instanceof O)return q.apply(this,arguments),this;else return O.apply(Object.create(O.prototype),arguments)}function N(){var C=this;T(C.path,C.flags,C.mode,function(b,k){if(b){if(C.autoClose)C.destroy();C.emit("error",b)}else C.fd=k,C.emit("open",k),C.read()})}function M(C,b){if(this instanceof M)return V.apply(this,arguments),this;else return M.apply(Object.create(M.prototype),arguments)}function D(){var C=this;T(C.path,C.flags,C.mode,function(b,k){if(b)C.destroy(),C.emit("error",b);else C.fd=k,C.emit("open",k)})}function P(C,b){return new $.ReadStream(C,b)}function j(C,b){return new $.WriteStream(C,b)}var A=$.open;$.open=T;function T(C,b,k,S){if(typeof k==="function")S=k,k=null;return i(C,b,k,S);function i(n,U0,x,d,t){return A(n,U0,x,function(e,g){if(e&&(e.code==="EMFILE"||e.code==="ENFILE"))GI([i,[n,U0,x,d],e,t||Date.now(),Date.now()]);else if(typeof d==="function")d.apply(this,arguments)})}}return $}function GI($){_z("ENQUEUE",$[0].name,$[1]),d4[a6].push($),Ru()}var ED;function JW0(){var $=Date.now();for(var Y=0;Y<d4[a6].length;++Y)if(d4[a6][Y].length>2)d4[a6][Y][3]=$,d4[a6][Y][4]=$;Ru()}function Ru(){if(clearTimeout(ED),ED=void 0,d4[a6].length===0)return;var $=d4[a6].shift(),Y=$[0],z=$[1],U=$[2],Q=$[3],J=$[4];if(Q===void 0)_z("RETRY",Y.name,z),Y.apply(null,z);else if(Date.now()-Q>=60000){_z("TIMEOUT",Y.name,z);var I=z.pop();if(typeof I==="function")I.call(null,U)}else{var K=Date.now()-J,G=Math.max(J-Q,1),H=Math.min(G*1.2,100);if(K>=H)_z("RETRY",Y.name,z),Y.apply(null,z.concat([Q]));else d4[a6].push($)}if(ED===void 0)ED=setTimeout(Ru,0)}});var GW0=E((Es1,vu)=>{function gU1($,Y){if(!($ instanceof Y))throw TypeError("Cannot call a class as a function")}var KW0=K6().Buffer,tW=I0("util");function yU1($,Y,z){$.copy(Y,z)}vu.exports=function(){function $(){gU1(this,$),this.head=null,this.tail=null,t Line truncated
`+c);let[,K0]=r;return K0.replace(/\s/g,"").split(w0).map((L0)=>L0.replace(u0,"").trim())}function P1(f,c){var r={};return Object.keys(f).forEach((K0)=>{var L0=f[K0],N0,B0=q(L0),P0=!B0&&L0.length===1||B0&&L0.length===0;if(Array.isArray(L0))N0=[...L0],L0=N0.pop(),r[K0]=N0.concat(N0.length>0?h0:L0);else if(P0)r[K0]=L0;else{if(N0=n0(L0),L0.length===0&&!B0&&N0.length===0)throw Error("autoInject task functions require explicit parameters.");if(!B0)N0.pop();r[K0]=N0.concat(h0)}function h0(U1,x1){var l1=N0.map((i1)=>U1[i1]);l1.push(x1),M(L0)(...l1)}}),q1(r,c)}class k1{constructor(){this.head=this.tail=null,this.length=0}removeLink(f){if(f.prev)f.prev.next=f.next;else this.head=f.next;if(f.next)f.next.prev=f.prev;else this.tail=f.prev;return f.prev=f.next=null,this.length-=1,f}empty(){while(this.head)this.shift();return this}insertAfter(f,c){if(c.prev=f,c.next=f.next,f.next)f.next.prev=c;else this.tail=c;f.next=c,this.length+=1}insertBefore(f,c){if(c.prev=f.prev,c.next=f,f.prev)f.prev.next=c;else this.head=c;f.prev=c,this.length+=1}unshift(f){if(this.head)this.insertBefore(this.head,f);else u1(this,f)}push(f){if(this.tail)this.insertAfter(this.tail,f);else u1(this,f)}shift(){return this.head&&this.removeLink(this.head)}pop(){return this.tail&&this.removeLink(this.tail)}toArray(){return[...this]}*[Symbol.iterator](){var f=this.head;while(f)yield f.data,f=f.next}remove(f){var c=this.head;while(c){var{next:r}=c;if(f(c))this.removeLink(c);c=r}return this}}function u1(f,c){f.length=1,f.head=f.tail=c}function b1(f,c,r){if(c==null)c=1;else if(c===0)throw RangeError("Concurrency must not be zero");var K0=M(f),L0=0,N0=[];let B0={error:[],drain:[],saturated:[],unsaturated:[],empty:[]};function P0(K1,e0){B0[K1].push(e0)}function h0(K1,e0){let G1=(...n1)=>{U1(K1,G1),e0(...n1)};B0[K1].push(G1)}function U1(K1,e0){if(!K1)return Object.keys(B0).forEach((G1)=>B0[G1]=[]);if(!e0)return B0[K1]=[];B0[K1]=B0[K1].filter((G1)=>G1!==e0)}function x1(K1,...e0){B0[K1].forEach((G1)=>G1(...e0))}var l1=!1;function i1(K1,e0,G1,n1){if(n1!=null&&typeof n1!=="function")throw Error("task callback must be a function");o1.started=!0;var y4,S6;function A$(PU,...sK){if(PU)return G1?S6(PU):y4();if(sK.length<=1)return y4(sK[0]);y4(sK)}var pz=o1._createTaskItem(K1,G1?A$:n1||A$);if(e0)o1._tasks.unshift(pz);else o1._tasks.push(pz);if(!l1)l1=!0,H(()=>{l1=!1,o1.process()});if(G1||!n1)return new Promise((PU,sK)=>{y4=PU,S6=sK})}function D$(K1){return function(e0,...G1){L0-=1;for(var n1=0,y4=K1.length;n1<y4;n1++){var S6=K1[n1],A$=N0.indexOf(S6);if(A$===0)N0.shift();else if(A$>0)N0.splice(A$,1);if(S6.callback(e0,...G1),e0!=null)x1("error",e0,S6.data)}if(L0<=o1.concurrency-o1.buffer)x1("unsaturated");if(o1.idle())x1("drain");o1.process()}}function dz(K1){if(K1.length===0&&o1.idle())return H(()=>x1("drain")),!0;return!1}let BU=(K1)=>(e0)=>{if(!e0)return new Promise((G1,n1)=>{h0(K1,(y4,S6)=>{if(y4)return n1(y4);G1(S6)})});U1(K1),P0(K1,e0)};var rK=!1,o1={_tasks:new k1,_createTaskItem(K1,e0){return{data:K1,callback:e0}},*[Symbol.iterator](){yield*o1._tasks[Symbol.iterator]()},concurrency:c,payload:r,buffer:c/4,started:!1,paused:!1,push(K1,e0){if(Array.isArray(K1)){if(dz(K1))return;return K1.map((G1)=>i1(G1,!1,!1,e0))}return i1(K1,!1,!1,e0)},pushAsync(K1,e0){if(Array.isArray(K1)){if(dz(K1))return;return K1.map((G1)=>i1(G1,!1,!0,e0))}return i1(K1,!1,!0,e0)},kill(){U1(),o1._tasks.empty()},unshift(K1,e0){if(Array.isArray(K1)){if(dz(K1))return;return K1.map((G1)=>i1(G1,!0,!1,e0))}return i1(K1,!0,!1,e0)},unshiftAsync(K1,e0){if(Array.isArray(K1)){if(dz(K1))return;return K1.map((G1)=>i1(G1,!0,!0,e0))}return i1(K1,!0,!0,e0)},remove(K1){o1._tasks.remove(K1)},process(){if(rK)return;rK=!0;while(!o1.paused&&L0<o1.concurrency&&o1._tasks.length){var K1=[],e0=[],G1=o1._tasks.length;if(o1.payload)G1=Math.min(G1,o1.payload);for(var n1=0;n1<G1;n1++){var y4=o1._tasks.shift();K1.push(y4),N0.push(y4),e0.push(y4.data)}if(L0+=1,o1._tasks.length===0)x1("empty");if(L0===o1.concurrency)x1("saturated");var S6=g(D$(K1));K0(e0,S6)}rK=!1},length(){return o1._tasks.length},running(){return L0},workersList(){return N0},idle(){return o1._tasks.length+L0===0},pause(){o1.paused=!0},resume(){if(o1.paused===!1)return;o1.paused=!1,H(o1.process)}};return Object.defineProperties(o1,{saturated:{writable:!1,value:BU("saturated")},unsaturated:{writable:!1,value:BU("unsaturated")},empty:{writable:!1,value:BU("empty")},drain:{writable:!1,value:BU("drain")},error:{writable:!1,value:BU("error")}}),o1}function D0(f,c){return b1(f,1,c)}function I0(f,c,r){return b1(f,c,r)}function B(f,c,r,K0){K0=T(K0);var L0=M(r);return e(f,(N0,B0,P0)=>{L0(c,N0,(h0,U1)=>{c=U1,P0(h0)})},(N0)=>K0(N0,c))}var h=w(B,4);function u(...f){var c=f.map(M);return function(...r){var K0=this,L0=r[r.length-1];if(typeof L0=="function")r.pop();else L0=o0();return h(c,r,(N0,B0,P0)=>{B0.apply(K0,N0.concat((h0,...U1)=>{P0(h0,U1)}))},(N0,B0)=>L0(N0,...B0)),L0[v0]}}function s(...f){return u(...f.reverse())}function W0(f,c,r,K0){return O(n(c),f,r,K0)}var Q0 Line truncated
GFS4: `),console.error($)};if(!p4[t6]){if(iu=global[t6]||[],FW0(p4,iu),p4.close=function($){function U(Y,z){return $.call(p4,Y,function(I){if(!I)wW0();if(typeof z==="function")z.apply(this,arguments)})}return Object.defineProperty(U,gD,{value:$}),U}(p4.close),p4.closeSync=function($){function U(Y){$.apply(p4,arguments),wW0()}return Object.defineProperty(U,gD,{value:$}),U}(p4.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))process.on("exit",function(){_Y(p4[t6]),J0("assert").equal(p4[t6].length,0)})}var iu;if(!global[t6])FW0(global,p4[t6]);du.exports=nu(JI1(p4));if(process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!p4.__patched)du.exports=nu(p4),p4.__patched=!0;function nu($){II1($),$.gracefulify=nu,$.createReadStream=P,$.createWriteStream=T;var U=$.readFile;$.readFile=Y;function Y(C,b,x){if(typeof b==="function")x=b,b=null;return g(C,b,x);function g(i,n,z0,k){return U(i,n,function(p){if(p&&(p.code==="EMFILE"||p.code==="ENFILE"))HJ([g,[i,n,z0],p,k||Date.now(),Date.now()]);else if(typeof z0==="function")z0.apply(this,arguments)})}}var z=$.writeFile;$.writeFile=I;function I(C,b,x,g){if(typeof x==="function")g=x,x=null;return i(C,b,x,g);function i(n,z0,k,p,a){return z(n,z0,k,function($0){if($0&&($0.code==="EMFILE"||$0.code==="ENFILE"))HJ([i,[n,z0,k,p],$0,a||Date.now(),Date.now()]);else if(typeof p==="function")p.apply(this,arguments)})}}var Q=$.appendFile;if(Q)$.appendFile=J;function J(C,b,x,g){if(typeof x==="function")g=x,x=null;return i(C,b,x,g);function i(n,z0,k,p,a){return Q(n,z0,k,function($0){if($0&&($0.code==="EMFILE"||$0.code==="ENFILE"))HJ([i,[n,z0,k,p],$0,a||Date.now(),Date.now()]);else if(typeof p==="function")p.apply(this,arguments)})}}var K=$.copyFile;if(K)$.copyFile=G;function G(C,b,x,g){if(typeof x==="function")g=x,x=0;return i(C,b,x,g);function i(n,z0,k,p,a){return K(n,z0,k,function($0){if($0&&($0.code==="EMFILE"||$0.code==="ENFILE"))HJ([i,[n,z0,k,p],$0,a||Date.now(),Date.now()]);else if(typeof p==="function")p.apply(this,arguments)})}}var H=$.readdir;$.readdir=X;var W=/^v[0-5]\./;function X(C,b,x){if(typeof b==="function")x=b,b=null;var g=W.test(process.version)?function(z0,k,p,a){return H(z0,i(z0,k,p,a))}:function(z0,k,p,a){return H(z0,k,i(z0,k,p,a))};return g(C,b,x);function i(n,z0,k,p){return function(a,$0){if(a&&(a.code==="EMFILE"||a.code==="ENFILE"))HJ([g,[n,z0,k],a,p||Date.now(),Date.now()]);else{if($0&&$0.sort)$0.sort();if(typeof k==="function")k.call(this,a,$0)}}}}if(process.version.substr(0,4)==="v0.8"){var Z=QI1($);w=Z.ReadStream,O=Z.WriteStream}var q=$.ReadStream;if(q)w.prototype=Object.create(q.prototype),w.prototype.open=N;var V=$.WriteStream;if(V)O.prototype=Object.create(V.prototype),O.prototype.open=D;Object.defineProperty($,"ReadStream",{get:function(){return w},set:function(C){w=C},enumerable:!0,configurable:!0}),Object.defineProperty($,"WriteStream",{get:function(){return O},set:function(C){O=C},enumerable:!0,configurable:!0});var F=w;Object.defineProperty($,"FileReadStream",{get:function(){return F},set:function(C){F=C},enumerable:!0,configurable:!0});var M=O;Object.defineProperty($,"FileWriteStream",{get:function(){return M},set:function(C){M=C},enumerable:!0,configurable:!0});function w(C,b){if(this instanceof w)return q.apply(this,arguments),this;else return w.apply(Object.create(w.prototype),arguments)}function N(){var C=this;j(C.path,C.flags,C.mode,function(b,x){if(b){if(C.autoClose)C.destroy();C.emit("error",b)}else C.fd=x,C.emit("open",x),C.read()})}function O(C,b){if(this instanceof O)return V.apply(this,arguments),this;else return O.apply(Object.create(O.prototype),arguments)}function D(){var C=this;j(C.path,C.flags,C.mode,function(b,x){if(b)C.destroy(),C.emit("error",b);else C.fd=x,C.emit("open",x)})}function P(C,b){return new $.ReadStream(C,b)}function T(C,b){return new $.WriteStream(C,b)}var A=$.open;$.open=j;function j(C,b,x,g){if(typeof x==="function")g=x,x=null;return i(C,b,x,g);function i(n,z0,k,p,a){return A(n,z0,k,function($0,y){if($0&&($0.code==="EMFILE"||$0.code==="ENFILE"))HJ([i,[n,z0,k,p],$0,a||Date.now(),Date.now()]);else if(typeof p==="function")p.apply(this,arguments)})}}return $}function HJ($){_Y("ENQUEUE",$[0].name,$[1]),p4[t6].push($),cu()}var SD;function wW0(){var $=Date.now();for(var U=0;U<p4[t6].length;++U)if(p4[t6][U].length>2)p4[t6][U][3]=$,p4[t6][U][4]=$;cu()}function cu(){if(clearTimeout(SD),SD=void 0,p4[t6].length===0)return;var $=p4[t6].shift(),U=$[0],Y=$[1],z=$[2],I=$[3],Q=$[4];if(I===void 0)_Y("RETRY",U.name,Y),U.apply(null,Y);else if(Date.now()-I>=60000){_Y("TIMEOUT",U.name,Y);var J=Y.pop();if(typeof J==="function")J.call(null,z)}else{var K=Date.now()-Q,G=Math.max(Q-I,1),H=Math.min(G*1.2,100);if(K>=H)_Y("RETRY",U.name,Y),U.apply(null,Y.concat([I]));else p4[t6].push($)}if(SD===void 0)SD=setTimeout(cu,0)}});var OW0=E((Qa1,pu)=>{function GI1($,U){if(!($ instanceof U))throw TypeError("Cannot call a class as a function")}var MW0=J6().Buffer,$X=J0("util");function HI1($,U,Y){$.copy(U,Y)}pu.exports=function(){function $(){GI1(this,$),this.h Line truncated
* normalize-path <https://github.com/jonschlinkert/normalize-path>
*
* Copyright (c) 2014-2018, Jon Schlinkert.
* Released under the MIT License.
*/oW0.exports=function($,Y){if(typeof $!=="string")throw TypeError("expected path to be a string");if($==="\\"||$==="/")return"/";var z=$.length;if(z<=1)return $;var U="";if(z>4&&$[3]==="\\"){var Q=$[2];if((Q==="?"||Q===".")&&$.slice(0,2)==="\\\\")$=$.slice(2),U="//"}var J=$.split(/[/\\]+/);if(Y!==!1&&J[J.length-1]==="")J.pop();return U+J.join("/")}});var su=E((us1,YX0)=>{var sW0=9007199254740991,iQ1="[object Arguments]",nQ1="[object Function]",cQ1="[object GeneratorFunction]",pQ1=/^(?:0|[1-9]\d*)$/;function aW0($,Y,z){switch(z.length){case 0:return $.call(Y);case 1:return $.call(Y,z[0]);case 2:return $.call(Y,z[0],z[1]);case 3:return $.call(Y,z[0],z[1],z[2])}return $.apply(Y,z)}function dQ1($,Y){var z=-1,U=Array($);while(++z<$)U[z]=Y(z);return U}var KX=Object.prototype,GX=KX.hasOwnProperty,tW0=KX.toString,mQ1=KX.propertyIsEnumerable,rW0=Math.max;function lQ1($,Y){var z=UJ1($)||zJ1($)?dQ1($.length,String):[],U=z.length,Q=!!U;for(var J in $)if((Y||GX.call($,J))&&!(Q&&(J=="length"||$X0(J,U))))z.push(J);return z}function oQ1($,Y,z,U){if($===void 0||lu($,KX[z])&&!GX.call(U,z))return Y;return $}function rQ1($,Y,z){var U=$[Y];if(!(GX.call($,Y)&&lu(U,z))||z===void 0&&!(Y in $))$[Y]=z}function sQ1($){if(!ru($))return YJ1($);var Y=$J1($),z=[];for(var U in $)if(!(U=="constructor"&&(Y||!GX.call($,U))))z.push(U);return z}function eW0($,Y){return Y=rW0(Y===void 0?$.length-1:Y,0),function(){var z=arguments,U=-1,Q=rW0(z.length-Y,0),J=Array(Q);while(++U<Q)J[U]=z[Y+U];U=-1;var I=Array(Y+1);while(++U<Y)I[U]=z[U];return I[Y]=J,aW0($,this,I)}}function aQ1($,Y,z,U){z||(z={});var Q=-1,J=Y.length;while(++Q<J){var I=Y[Q],K=U?U(z[I],$[I],I,z,$):void 0;rQ1(z,I,K===void 0?$[I]:K)}return z}function tQ1($){return eW0(function(Y,z){var U=-1,Q=z.length,J=Q>1?z[Q-1]:void 0,I=Q>2?z[2]:void 0;if(J=$.length>3&&typeof J=="function"?(Q--,J):void 0,I&&eQ1(z[0],z[1],I))J=Q<3?void 0:J,Q=1;Y=Object(Y);while(++U<Q){var K=z[U];if(K)$(Y,K,U,J)}return Y})}function $X0($,Y){return Y=Y==null?sW0:Y,!!Y&&(typeof $=="number"||pQ1.test($))&&($>-1&&$%1==0&&$<Y)}function eQ1($,Y,z){if(!ru(z))return!1;var U=typeof Y;if(U=="number"?ou(z)&&$X0(Y,z.length):U=="string"&&(Y in z))return lu(z[Y],$);return!1}function $J1($){var Y=$&&$.constructor,z=typeof Y=="function"&&Y.prototype||KX;return $===z}function YJ1($){var Y=[];if($!=null)for(var z in Object($))Y.push(z);return Y}function lu($,Y){return $===Y||$!==$&&Y!==Y}function zJ1($){return QJ1($)&&GX.call($,"callee")&&(!mQ1.call($,"callee")||tW0.call($)==iQ1)}var UJ1=Array.isArray;function ou($){return $!=null&&IJ1($.length)&&!JJ1($)}function QJ1($){return KJ1($)&&ou($)}function JJ1($){var Y=ru($)?tW0.call($):"";return Y==nQ1||Y==cQ1}function IJ1($){return typeof $=="number"&&$>-1&&$%1==0&&$<=sW0}function ru($){var Y=typeof $;return!!$&&(Y=="object"||Y=="function")}function KJ1($){return!!$&&typeof $=="object"}var GJ1=tQ1(function($,Y,z,U){aQ1(Y,WJ1(Y),$,U)}),HJ1=eW0(function($){return $.push(void 0,oQ1),aW0(GJ1,void 0,$)});function WJ1($){return ou($)?lQ1($,!0):sQ1($)}YX0.exports=HJ1});var UX0=E((bs1,au)=>{function XJ1($,Y){if(!($ instanceof Y))throw TypeError("Cannot call a class as a function")}var zX0=K6().Buffer,HX=I0("util");function ZJ1($,Y,z){$.copy(Y,z)}au.exports=function(){function $(){XJ1(this,$),this.head=null,this.tail=null,this.length=0}return $.prototype.push=function(z){var U={data:z,next:null};if(this.length>0)this.tail.next=U;else this.head=U;this.tail=U,++this.length},$.prototype.unshift=function(z){var U={data:z,next:this.head};if(this.length===0)this.tail=U;this.head=U,++this.length},$.prototype.shift=function(){if(this.length===0)return;var z=this.head.data;if(this.length===1)this.head=this.tail=null;else this.head=this.head.next;return--this.length,z},$.prototype.clear=function(){this.head=this.tail=null,this.length=0},$.prototype.join=function(z){if(this.length===0)return"";var U=this.head,Q=""+U.data;while(U=U.next)Q+=z+U.data;return Q},$.prototype.concat=function(z){if(this.length===0)return zX0.alloc(0);var U=zX0.allocUnsafe(z>>>0),Q=this.head,J=0;while(Q)ZJ1(Q.data,U,J),J+=Q.data.length,Q=Q.next;return U},$}();if(HX&&HX.inspect&&HX.inspect.custom)au.exports.prototype[HX.inspect.custom]=function(){var $=HX.inspect({length:this.length});return this.constructor.name+" "+$}});var tu=E((is1,QX0)=>{var iD=I6();function qJ1($,Y){var z=this,U=this._readableState&&this._readableState.destroyed,Q=this._writableState&&this._writableState.destroyed;if(U||Q){if(Y)Y($);else if($){if(!this._writableState)iD.nextTick(nD,this,$);else if(!this._writableState.errorEmitted)this._writableState.errorEmitted=!0,iD.nextTick(nD,this,$)}return this}if(this._readableState)this._readableState.destroyed=!0;if(this._writableState)this._writableState.destroyed=!0;return this._destroy($||null,function(J){if(!Y&&J){if(!z._writableState)iD.nextTick(nD,z,J);else if(!z._writableState.errorEmitted)z._writableState.errorEmitted=!0,iD.nextTick(nD,z,J)}else if(Y)Y(J)}),this}function VJ1(){if(this._readableState)this._readabl Line truncated
%s`,P,P,N,U);var j=N.type==="*"?kb:N.type==="?"?yb:"\\"+N.type;Q=!0,U=U.slice(0,N.reStart)+j+"\\("+P}if(V(),J)U+="\\\\";var A=!1;switch(U.charAt(0)){case"[":case".":case"(":A=!0}for(var T=K.length-1;T>-1;T--){var C=K[T],b=U.slice(0,C.reStart),k=U.slice(C.reStart,C.reEnd-8),S=U.slice(C.reEnd-8,C.reEnd),i=U.slice(C.reEnd);S+=i;var n=b.split("(").length-1,U0=i;for(F=0;F<n;F++)U0=U0.replace(/\)[+*?]?/,"");i=U0;var x="";if(i===""&&Y!==QA)x="$";var d=b+k+i+x+S;U=d}if(U!==""&&Q)U="(?=.)"+U;if(A)U=Z+U;if(Y===QA)return[U,Q];if(!Q)return SH1($);var t=z.nocase?"i":"";try{var e=new RegExp("^"+U+"$",t)}catch(g){return new RegExp("$.")}return e._glob=$,e._src=U,e}X$.makeRe=function($,Y){return new L6($,Y||{}).makeRe()};L6.prototype.makeRe=hH1;function hH1(){if(this.regexp||this.regexp===!1)return this.regexp;var $=this.set;if(!$.length)return this.regexp=!1,this.regexp;var Y=this.options,z=Y.noglobstar?kb:Y.dot?PH1:jH1,U=Y.nocase?"i":"",Q=$.map(function(J){return J.map(function(I){return I===uz?z:typeof I==="string"?gH1(I):I._src}).join("\\/")}).join("|");if(Q="^(?:"+Q+")$",this.negate)Q="^(?!"+Q+").*$";try{this.regexp=new RegExp(Q,U)}catch(J){this.regexp=!1}return this.regexp}X$.match=function($,Y,z){z=z||{};var U=new L6(Y,z);if($=$.filter(function(Q){return U.match(Q)}),U.options.nonull&&!$.length)$.push(Y);return $};L6.prototype.match=function(Y,z){if(typeof z>"u")z=this.partial;if(this.debug("match",Y,this.pattern),this.comment)return!1;if(this.empty)return Y==="";if(Y==="/"&&z)return!0;var U=this.options;if(DX.sep!=="/")Y=Y.split(DX.sep).join("/");Y=Y.split(xZ0),this.debug(this.pattern,"split",Y);var Q=this.set;this.debug(this.pattern,"set",Q);var J,I;for(I=Y.length-1;I>=0;I--)if(J=Y[I],J)break;for(I=0;I<Q.length;I++){var K=Q[I],G=Y;if(U.matchBase&&K.length===1)G=[J];var H=this.matchOne(G,K,z);if(H){if(U.flipNegate)return!0;return!this.negate}}if(U.flipNegate)return!1;return this.negate};L6.prototype.matchOne=function($,Y,z){if(Y.indexOf(uz)!==-1)return this._matchGlobstar($,Y,z,0,0);return this._matchOne($,Y,z,0,0)};L6.prototype._matchGlobstar=function($,Y,z,U,Q){var J,I=-1;for(J=Q;J<Y.length;J++)if(Y[J]===uz){I=J;break}var K=-1;for(J=Y.length-1;J>=0;J--)if(Y[J]===uz){K=J;break}var G=Y.slice(Q,I),H=z?Y.slice(I+1):Y.slice(I+1,K),W=z?[]:Y.slice(K+1);if(G.length){var X=$.slice(U,U+G.length);if(!this._matchOne(X,G,z,0,0))return!1;U+=G.length}var Z=0;if(W.length){if(W.length+U>$.length)return!1;var q=$.length-W.length;if(this._matchOne($,W,z,q,0))Z=W.length;else{if($[$.length-1]!==""||U+W.length===$.length)return!1;if(q--,!this._matchOne($,W,z,q,0))return!1;Z=W.length+1}}if(!H.length){var V=!!Z;for(J=U;J<$.length-Z;J++){var F=String($[J]);if(V=!0,F==="."||F===".."||!this.options.dot&&F.charAt(0)===".")return!1}return z||V}var w=[[[],0]],O=w[0],N=0,M=[0];for(var D=0;D<H.length;D++){var P=H[D];if(P===uz)M.push(N),O=[[],0],w.push(O);else O[0].push(P),N++}var j=w.length-1,A=$.length-Z;for(var T=0;T<w.length;T++)w[T][1]=A-(M[j--]+w[T][0].length);return!!this._matchGlobStarBodySections($,w,U,0,z,0,!!Z)};L6.prototype._matchGlobStarBodySections=function($,Y,z,U,Q,J,I){var K=Y[U];if(!K){for(var G=z;G<$.length;G++){I=!0;var H=$[G];if(H==="."||H===".."||!this.options.dot&&H.charAt(0)===".")return!1}return I}var W=K[0],X=K[1];while(z<=X){var Z=this._matchOne($.slice(0,z+W.length),W,Q,z,0);if(Z&&J<this.maxGlobstarRecursion){var q=this._matchGlobStarBodySections($,Y,z+W.length,U+1,Q,J+1,I);if(q!==!1)return q}var H=$[z];if(H==="."||H===".."||!this.options.dot&&H.charAt(0)===".")return!1;z++}return Q||null};L6.prototype._matchOne=function($,Y,z,U,Q){var J,I,K,G;for(J=U,I=Q,K=$.length,G=Y.length;J<K&&I<G;J++,I++){this.debug("matchOne loop");var H=Y[I],W=$[J];if(this.debug(Y,H,W),H===!1||H===uz)return!1;var X;if(typeof H==="string")X=W===H,this.debug("string match",H,W,X);else X=W.match(H),this.debug("pattern match",H,W,X);if(!X)return!1}if(J===K&&I===G)return!0;else if(J===K)return z;else if(I===G)return J===K-1&&$[J]==="";throw Error("wtf?")};function SH1($){return $.replace(/\\(.)/g,"$1")}function gH1($){return $.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}});var GA=E((Ka1,KA)=>{function bZ0($){return $.charAt(0)==="/"}function iZ0($){var Y=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/,z=Y.exec($),U=z[1]||"",Q=Boolean(U&&U.charAt(1)!==":");return Boolean(z[2]||Q)}KA.exports=process.platform==="win32"?iZ0:bZ0;KA.exports.posix=bZ0;KA.exports.win32=iZ0});var fb=E((pH1)=>{pH1.setopts=bH1;pH1.ownProp=nZ0;pH1.makeAbs=AX;pH1.finish=iH1;pH1.mark=nH1;pH1.isIgnored=pZ0;pH1.childrenIgnored=cH1;function nZ0($,Y){return Object.prototype.hasOwnProperty.call($,Y)}var yH1=I0("fs"),DI=I0("path"),kH1=IA(),cZ0=GA(),xb=kH1.Minimatch;function xH1($,Y){return $.localeCompare(Y,"en")}function fH1($,Y){if($.ignore=Y.ignore||[],!Array.isArray($.ignore))$.ignore=[$.ignore];if($.ignore.length)$.ignore=$.ignore.map(uH1)}function uH1($){var Y=null;if($.slice(-3)==="/**"){var z=$.replace(/(\/\*\*)+$/,"");Y=new xb(z,{dot:!0})}return{matche Line truncated
See: https://github.com/isaacs/node-glob/issues/167`);return new T6($,Y).found}function T6($,Y){if(!$)throw Error("must provide pattern");if(typeof Y==="function"||arguments.length===3)throw TypeError(`callback provided to sync glob
See: https://github.com/isaacs/node-glob/issues/167`);if(!(this instanceof T6))return new T6($,Y);if(eH1(this,$,Y),this.noprocess)return this;var z=this.minimatch.set.length;this.matches=Array(z);for(var U=0;U<z;U++)this._process(this.minimatch.set[U],U,!1);this._finish()}T6.prototype._finish=function(){if(mZ0.ok(this instanceof T6),this.realpath){var $=this;this.matches.forEach(function(Y,z){var U=$.matches[z]=Object.create(null);for(var Q in Y)try{Q=$._makeAbs(Q);var J=tH1.realpathSync(Q,$.realpathCache);U[J]=!0}catch(I){if(I.syscall==="stat")U[$._makeAbs(Q)]=!0;else throw I}})}bz.finish(this)};T6.prototype._process=function($,Y,z){mZ0.ok(this instanceof T6);var U=0;while(typeof $[U]==="string")U++;var Q;switch(U){case $.length:this._processSimple($.join("/"),Y);return;case 0:Q=null;break;default:Q=$.slice(0,U).join("/");break}var J=$.slice(U),I;if(Q===null)I=".";else if(HA(Q)||HA($.map(function(H){return typeof H==="string"?H:"[*]"}).join("/"))){if(!Q||!HA(Q))Q="/"+Q;I=Q}else I=Q;var K=this._makeAbs(I);if($W1(this,I))return;var G=J[0]===dZ0.GLOBSTAR;if(G)this._processGlobStar(Q,I,K,J,Y,z);else this._processReaddir(Q,I,K,J,Y,z)};T6.prototype._processReaddir=function($,Y,z,U,Q,J){var I=this._readdir(z,J);if(!I)return;var K=U[0],G=!!this.minimatch.negate,H=K._glob,W=this.dot||H.charAt(0)===".",X=[];for(var Z=0;Z<I.length;Z++){var q=I[Z];if(q.charAt(0)!=="."||W){var V;if(G&&!$)V=!q.match(K);else V=q.match(K);if(V)X.push(q)}}var F=X.length;if(F===0)return;if(U.length===1&&!this.mark&&!this.stat){if(!this.matches[Q])this.matches[Q]=Object.create(null);for(var Z=0;Z<F;Z++){var q=X[Z];if($)if($.slice(-1)!=="/")q=$+"/"+q;else q=$+q;if(q.charAt(0)==="/"&&!this.nomount)q=ub.join(this.root,q);this._emitMatch(Q,q)}return}U.shift();for(var Z=0;Z<F;Z++){var q=X[Z],w;if($)w=[$,q];else w=[q];this._process(w.concat(U),Q,J)}};T6.prototype._emitMatch=function($,Y){if(YW1(this,Y))return;var z=this._makeAbs(Y);if(this.mark)Y=this._mark(Y);if(this.absolute)Y=z;if(this.matches[$][Y])return;if(this.nodir){var U=this.cache[z];if(U==="DIR"||Array.isArray(U))return}if(this.matches[$][Y]=!0,this.stat)this._stat(Y)};T6.prototype._readdirInGlobStar=function($){if(this.follow)return this._readdir($,!1);var Y,z,U;try{z=this.fs.lstatSync($)}catch(J){if(J.code==="ENOENT")return null}var Q=z&&z.isSymbolicLink();if(this.symlinks[$]=Q,!Q&&z&&!z.isDirectory())this.cache[$]="FILE";else Y=this._readdir($,!1);return Y};T6.prototype._readdir=function($,Y){var z;if(Y&&!bb(this.symlinks,$))return this._readdirInGlobStar($);if(bb(this.cache,$)){var U=this.cache[$];if(!U||U==="FILE")return null;if(Array.isArray(U))return U}try{return this._readdirEntries($,this.fs.readdirSync($))}catch(Q){return this._readdirError($,Q),null}};T6.prototype._readdirEntries=function($,Y){if(!this.mark&&!this.stat)for(var z=0;z<Y.length;z++){var U=Y[z];if($==="/")U=$+U;else U=$+"/"+U;this.cache[U]=!0}return this.cache[$]=Y,Y};T6.prototype._readdirError=function($,Y){switch(Y.code){case"ENOTSUP":case"ENOTDIR":var z=this._makeAbs($);if(this.cache[z]="FILE",z===this.cwdAbs){var U=Error(Y.code+" invalid cwd "+this.cwd);throw U.path=this.cwd,U.code=Y.code,U}break;case"ENOENT":case"ELOOP":case"ENAMETOOLONG":case"UNKNOWN":this.cache[this._makeAbs($)]=!1;break;default:if(this.cache[this._makeAbs($)]=!1,this.strict)throw Y;if(!this.silent)console.error("glob error",Y);break}};T6.prototype._processGlobStar=function($,Y,z,U,Q,J){var I=this._readdir(z,J);if(!I)return;var K=U.slice(1),G=$?[$]:[],H=G.concat(K);this._process(H,Q,!1);var W=I.length,X=this.symlinks[z];if(X&&J)return;for(var Z=0;Z<W;Z++){var q=I[Z];if(q.charAt(0)==="."&&!this.dot)continue;var V=G.concat(I[Z],K);this._process(V,Q,!0);var F=G.concat(I[Z],U);this._process(F,Q,!0)}};T6.prototype._processSimple=function($,Y){var z=this._stat($);if(!this.matches[Y])this.matches[Y]=Object.create(null);if(!z)return;if($&&HA($)&&!this.nomount){var U=/[\/\\]$/.test($);if($.charAt(0)==="/")$=ub.join(this.root,$);else if($=ub.resolve(this.root,$),U)$+="/"}if(process.platform==="win32")$=$.replace(/\\/g,"/");this._emitMatch(Y,$)};T6.prototype._stat=function($){var Y=this._makeAbs($),z=$.slice(-1)==="/";if($.length>this.maxLength)return!1;if(!this.stat&&bb(this.cache,Y)){var I=this.cache[Y];if(Array.isArray(I))I="DIR";if(!z||I==="DIR")return I;if(z&&I==="FILE")return!1}var U,Q=this.statCache[Y];if(!Q){var J;try{J=this.fs.lstatSync(Y)}catch(K){if(K&&(K.code==="ENOENT"||K.code==="ENOTDIR"))return this.statCache[Y]=!1,!1}if(J&&J.isSymbolicLink())try{Q=this.fs.statSync(Y)}catch(K){Q=J}else Q=J}this.statCache[Y]=Q;var I=!0;if(Q)I=Q.isDirectory()?"DIR":"FILE";if(this.cache[Y]=this.cache[Y]||I,z&&I==="FILE")return!1;return I};T6.prototype._mark=function($){return bz.mark(this,$)};T6.prototype._makeAbs=function($){return bz.makeAbs(this,$)}});var ib=E((qa1,aZ0)=>{aZ0.exports=sZ0;function sZ0($,Y){if($&&Y)return sZ0($)(Y);if(typeof $!=="function")throw TypeError("need wrapper function");return Object.keys($).forEach(function(U){z[U]=$[U]}),z;f Line truncated
`);if($.linkname)Y+=ui(" linkpath="+$.linkname+`
`);var z=$.pax;if(z)for(var U in z)Y+=ui(" "+U+"="+z[U]+`
`);return Buffer.from(Y)};Xq1.decodePax=function($){var Y={};while($.length){var z=0;while(z<$.length&&$[z]!==32)z++;var U=parseInt($.slice(0,z).toString(),10);if(!U)return Y;var Q=$.slice(z+1,U-1).toString(),J=Q.indexOf("=");if(J===-1)return Y;Y[Q.slice(0,J)]=Q.slice(J+1),$=$.slice(U)}return Y};Xq1.encode=function($){var Y=$q1(512),z=$.name,U="";if($.typeflag===5&&z[z.length-1]!=="/")z+="/";if(Buffer.byteLength(z)!==z.length)return null;while(Buffer.byteLength(z)>100){var Q=z.indexOf("/");if(Q===-1)return null;U+=U?"/"+z.slice(0,Q):z.slice(0,Q),z=z.slice(Q+1)}if(Buffer.byteLength(z)>100||Buffer.byteLength(U)>155)return null;if($.linkname&&Buffer.byteLength($.linkname)>100)return null;if(Y.write(z),Y.write(T2($.mode&Iq1,6),100),Y.write(T2($.uid,6),108),Y.write(T2($.gid,6),116),Y.write(T2($.size,11),124),Y.write(T2($.mtime.getTime()/1000|0,11),136),Y[156]=XL0+Hq1($.type),$.linkname)Y.write($.linkname,157);if(ZL0.copy(Y,fX),Uq1.copy(Y,bi),$.uname)Y.write($.uname,265);if($.gname)Y.write($.gname,297);if(Y.write(T2($.devmajor||0,6),329),Y.write(T2($.devminor||0,6),337),U)Y.write(U,345);return Y.write(T2(VL0(Y),6),148),Y};Xq1.decode=function($,Y,z){var U=$[156]===0?0:$[156]-XL0,Q=_I($,0,100,Y),J=E2($,100,8),I=E2($,108,8),K=E2($,116,8),G=E2($,124,12),H=E2($,136,12),W=Gq1(U),X=$[157]===0?null:_I($,157,100,Y),Z=_I($,265,32),q=_I($,297,32),V=E2($,329,8),F=E2($,337,8),w=VL0($);if(w===256)return null;if(w!==E2($,148,8))throw Error("Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?");if(ZL0.compare($,fX,fX+6)===0){if($[345])Q=_I($,345,155,Y)+"/"+Q}else if(Qq1.compare($,fX,fX+6)===0&&Jq1.compare($,bi,bi+2)===0);else if(!z)throw Error("Invalid tar header: unknown format.");if(U===0&&Q&&Q[Q.length-1]==="/")U=5;return{name:Q,mode:J,uid:I,gid:K,size:G,mtime:new Date(1000*H),type:W,linkname:X,uname:Z,gname:q,devmajor:V,devminor:F}}});var DL0=E((Kt1,NL0)=>{var FL0=I0("util"),Oq1=WL0(),uX=ii(),OL0=C8().Writable,wL0=C8().PassThrough,ML0=function(){},LL0=function($){return $&=511,$&&512-$},wq1=function($,Y){var z=new RA($,Y);return z.end(),z},Mq1=function($,Y){if(Y.path)$.name=Y.path;if(Y.linkpath)$.linkname=Y.linkpath;if(Y.size)$.size=parseInt(Y.size,10);return $.pax=Y,$},RA=function($,Y){this._parent=$,this.offset=Y,wL0.call(this,{autoDestroy:!1})};FL0.inherits(RA,wL0);RA.prototype.destroy=function($){this._parent.destroy($)};var j3=function($){if(!(this instanceof j3))return new j3($);OL0.call(this,$),$=$||{},this._offset=0,this._buffer=Oq1(),this._missing=0,this._partial=!1,this._onparse=ML0,this._header=null,this._stream=null,this._overflow=null,this._cb=null,this._locked=!1,this._destroyed=!1,this._pax=null,this._paxGlobal=null,this._gnuLongPath=null,this._gnuLongLinkPath=null;var Y=this,z=Y._buffer,U=function(){Y._continue()},Q=function(Z){if(Y._locked=!1,Z)return Y.destroy(Z);if(!Y._stream)U()},J=function(){Y._stream=null;var Z=LL0(Y._header.size);if(Z)Y._parse(Z,I);else Y._parse(512,X);if(!Y._locked)U()},I=function(){Y._buffer.consume(LL0(Y._header.size)),Y._parse(512,X),U()},K=function(){var Z=Y._header.size;Y._paxGlobal=uX.decodePax(z.slice(0,Z)),z.consume(Z),J()},G=function(){var Z=Y._header.size;if(Y._pax=uX.decodePax(z.slice(0,Z)),Y._paxGlobal)Y._pax=Object.assign({},Y._paxGlobal,Y._pax);z.consume(Z),J()},H=function(){var Z=Y._header.size;this._gnuLongPath=uX.decodeLongPath(z.slice(0,Z),$.filenameEncoding),z.consume(Z),J()},W=function(){var Z=Y._header.size;this._gnuLongLinkPath=uX.decodeLongPath(z.slice(0,Z),$.filenameEncoding),z.consume(Z),J()},X=function(){var Z=Y._offset,q;try{q=Y._header=uX.decode(z.slice(0,512),$.filenameEncoding,$.allowUnknownFormat)}catch(V){Y.emit("error",V)}if(z.consume(512),!q){Y._parse(512,X),U();return}if(q.type==="gnu-long-path"){Y._parse(q.size,H),U();return}if(q.type==="gnu-long-link-path"){Y._parse(q.size,W),U();return}if(q.type==="pax-global-header"){Y._parse(q.size,K),U();return}if(q.type==="pax-header"){Y._parse(q.size,G),U();return}if(Y._gnuLongPath)q.name=Y._gnuLongPath,Y._gnuLongPath=null;if(Y._gnuLongLinkPath)q.linkname=Y._gnuLongLinkPath,Y._gnuLongLinkPath=null;if(Y._pax)Y._header=q=Mq1(q,Y._pax),Y._pax=null;if(Y._locked=!0,!q.size||q.type==="directory"){Y._parse(512,X),Y.emit("entry",q,wq1(Y,Z),Q);return}Y._stream=new RA(Y,Z),Y.emit("entry",q,Y._stream,Q),Y._parse(q.size,J),U()};this._onheader=X,this._parse(512,X)};FL0.inherits(j3,OL0);j3.prototype.destroy=function($){if(this._destroyed)return;if(this._destroyed=!0,$)this.emit("error",$);if(this.emit("close"),this._stream)this._stream.emit("close")};j3.prototype._parse=function($,Y){if(this._destroyed)return;if(this._offset+=$,this._missing=$,Y===this._onheader)this._partial=!1;this._onparse=Y};j3.prototype._continue=function(){if(this._destroyed)return;var $=this._cb;if(this._cb=ML0,this._overflow)this._write(this._overflow,void 0,$);else $()};j3.prototype._write=function($,Y,z){if(this._destroyed)return;var U=this._stream,Q=this._buffer,J=this._missing;if($.length)this._partial=!0;if($.length<J) Line truncated
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">`)}_writeRelationship($){if(!this.count)this._writeOpen();let Y=`rId${++this.count}`;if($.TargetMode)this.stream.write(`<Relationship Id="${Y}" Type="${$.Type}" Target="${fq1.xmlEncode($.Target)}" TargetMode="${$.TargetMode}"/>`);else this.stream.write(`<Relationship Id="${Y}" Type="${$.Type}" Target="${$.Target}"/>`);return Y}_writeClose(){this.stream.write("</Relationships>")}}lL0.exports=mL0});var eL0=E((Ot1,tL0)=>{var rL0=o6(),sL0=Q2(),bq1=n4(),iq1=$f(),nq1=zf();class aL0{constructor($,Y,z){this.id=z.id,this.count=0,this._worksheet=$,this._workbook=z.workbook,this._sheetRelsWriter=Y}get commentsStream(){if(!this._commentsStream)this._commentsStream=this._workbook._openStream(`/xl/comments${this.id}.xml`);return this._commentsStream}get vmlStream(){if(!this._vmlStream)this._vmlStream=this._workbook._openStream(`xl/drawings/vmlDrawing${this.id}.vml`);return this._vmlStream}_addRelationships(){let $={Type:sL0.Comments,Target:`../comments${this.id}.xml`};this._sheetRelsWriter.addRelationship($);let Y={Type:sL0.VmlDrawing,Target:`../drawings/vmlDrawing${this.id}.vml`};this.vmlRelId=this._sheetRelsWriter.addRelationship(Y)}_addCommentRefs(){this._workbook.commentRefs.push({commentName:`comments${this.id}`,vmlDrawing:`vmlDrawing${this.id}`})}_writeOpen(){this.commentsStream.write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><comments xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><authors><author>Author</author></authors><commentList>'),this.vmlStream.write('<?xml version="1.0" encoding="UTF-8"?><xml xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:x="urn:schemas-microsoft-com:office:excel"><o:shapelayout v:ext="edit"><o:idmap v:ext="edit" data="1" /></o:shapelayout><v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe"><v:stroke joinstyle="miter" /><v:path gradientshapeok="t" o:connecttype="rect" /></v:shapetype>')}_writeComment($,Y){let z=new iq1,U=new rL0;z.render(U,$),this.commentsStream.write(U.xml);let Q=new nq1,J=new rL0;Q.render(J,$,Y),this.vmlStream.write(J.xml)}_writeClose(){this.commentsStream.write("</commentList></comments>"),this.vmlStream.write("</xml>")}addComments($){if($&&$.length){if(!this.startedData)this._worksheet.comments=[],this._writeOpen(),this._addRelationships(),this._addCommentRefs(),this.startedData=!0;$.forEach((Y)=>{Y.refAddress=bq1.decodeAddress(Y.ref)}),$.forEach((Y)=>{this._writeComment(Y,this.count),this.count+=1})}}commit(){if(this.count)this._writeClose(),this.commentsStream.end(),this.vmlStream.end()}}tL0.exports=aL0});var JF0=E((wt1,QF0)=>{var cq1=Y6(),pq1=Q2(),pi=n4(),$F0=Mg(),YF0=z3(),dq1=Sk(),zF0=gw(),di=kw(),mq1=oL0(),lq1=eL0(),oq1=Og(),x6=new dq1,mi=Y2(),rq1=Cx(),sq1=Rx(),aq1=_x(),tq1=Px(),eq1=Ax(),$V1=jx(),YV1=vx(),zV1=hx(),UV1=Sx(),QV1=gx(),JV1=yx(),IV1=kx(),KV1=ix(),GV1=fx(),HV1=xx(),f6={dataValidations:new rq1,sheetProperties:new sq1,sheetFormatProperties:new aq1,columns:new mi({tag:"cols",length:!1,childXform:new tq1}),row:new eq1,hyperlinks:new mi({tag:"hyperlinks",length:!1,childXform:new $V1}),sheetViews:new mi({tag:"sheetViews",length:!1,childXform:new YV1}),sheetProtection:new zV1,pageMargins:new UV1,pageSeteup:new QV1,autoFilter:new JV1,picture:new IV1,conditionalFormattings:new KV1,headerFooter:new GV1,rowBreaks:new HV1};class UF0{constructor($){this.id=$.id,this.name=$.name||`Sheet${this.id}`,this.state=$.state||"visible",this._rows=[],this._columns=null,this._keys={},this._merges=[],this._merges.add=function(){},this._sheetRelsWriter=new mq1($),this._sheetCommentsWriter=new lq1(this,this._sheetRelsWriter,$),this._dimensions=new YF0,this._rowZero=1,this.committed=!1,this.dataValidations=new oq1,this._formulae={},this._siFormulae=0,this.conditionalFormatting=[],this.rowBreaks=[],this.properties=Object.assign({},{defaultRowHeight:15,dyDescent:55,outlineLevelCol:0,outlineLevelRow:0},$.properties),this.headerFooter=Object.assign({},{differentFirst:!1,differentOddEven:!1,oddHeader:null,oddFooter:null,evenHeader:null,evenFooter:null,firstHeader:null,firstFooter:null},$.headerFooter),this.pageSetup=Object.assign({},{margins:{left:0.7,right:0.7,top:0.75,bottom:0.75,header:0.3,footer:0.3},orientation:"portrait",horizontalDpi:4294967295,verticalDpi:4294967295,fitToPage:!!($.pageSetup&&($.pageSetup.fitToWidth||$.pageSetup.fitToHeight)&&!$.pageSetup.scale),pageOrder:"downThenOver",blackAndWhite:!1,draft:!1,cellComments:"None",errors:"displayed",scale:100,fitToWidth:1,fitToHeight:1,paperSize:void 0,showRowColHeaders:!1,showGridLines:!1,horizontalCentered:!1,verticalCentered:!1,rowBreaks:null,colBreaks:null},$.pageSetup),this.useSharedStrings=$.useSharedStrings||!1,this._workbook=$.workbook,this.hasComments=!1,this._views=$.views||[],this.autoFilter=$.autoFilter||null,this._media=[],this.sheetProtection=null,this._writeOpenWorksheet(),this.startedData=!1}get Line truncated
*/QX0.exports=function($,U){if(typeof $!=="string")throw TypeError("expected path to be a string");if($==="\\"||$==="/")return"/";var Y=$.length;if(Y<=1)return $;var z="";if(Y>4&&$[3]==="\\"){var I=$[2];if((I==="?"||I===".")&&$.slice(0,2)==="\\\\")$=$.slice(2),z="//"}var Q=$.split(/[/\\]+/);if(U!==!1&&Q[Q.length-1]==="")Q.pop();return z+Q.join("/")}});var Wb=E((Fa1,ZX0)=>{var KX0=9007199254740991,LQ1="[object Arguments]",wQ1="[object Function]",FQ1="[object GeneratorFunction]",MQ1=/^(?:0|[1-9]\d*)$/;function GX0($,U,Y){switch(Y.length){case 0:return $.call(U);case 1:return $.call(U,Y[0]);case 2:return $.call(U,Y[0],Y[1]);case 3:return $.call(U,Y[0],Y[1],Y[2])}return $.apply(U,Y)}function OQ1($,U){var Y=-1,z=Array($);while(++Y<$)z[Y]=U(Y);return z}var HX=Object.prototype,WX=HX.hasOwnProperty,HX0=HX.toString,NQ1=HX.propertyIsEnumerable,JX0=Math.max;function DQ1($,U){var Y=vQ1($)||_Q1($)?OQ1($.length,String):[],z=Y.length,I=!!z;for(var Q in $)if((U||WX.call($,Q))&&!(I&&(Q=="length"||XX0(Q,z))))Y.push(Q);return Y}function AQ1($,U,Y,z){if($===void 0||Kb($,HX[Y])&&!WX.call(z,Y))return U;return $}function BQ1($,U,Y){var z=$[U];if(!(WX.call($,U)&&Kb(z,Y))||Y===void 0&&!(U in $))$[U]=Y}function PQ1($){if(!Hb($))return RQ1($);var U=CQ1($),Y=[];for(var z in $)if(!(z=="constructor"&&(U||!WX.call($,z))))Y.push(z);return Y}function WX0($,U){return U=JX0(U===void 0?$.length-1:U,0),function(){var Y=arguments,z=-1,I=JX0(Y.length-U,0),Q=Array(I);while(++z<I)Q[z]=Y[U+z];z=-1;var J=Array(U+1);while(++z<U)J[z]=Y[z];return J[U]=Q,GX0($,this,J)}}function TQ1($,U,Y,z){Y||(Y={});var I=-1,Q=U.length;while(++I<Q){var J=U[I],K=z?z(Y[J],$[J],J,Y,$):void 0;BQ1(Y,J,K===void 0?$[J]:K)}return Y}function jQ1($){return WX0(function(U,Y){var z=-1,I=Y.length,Q=I>1?Y[I-1]:void 0,J=I>2?Y[2]:void 0;if(Q=$.length>3&&typeof Q=="function"?(I--,Q):void 0,J&&EQ1(Y[0],Y[1],J))Q=I<3?void 0:Q,I=1;U=Object(U);while(++z<I){var K=Y[z];if(K)$(U,K,z,Q)}return U})}function XX0($,U){return U=U==null?KX0:U,!!U&&(typeof $=="number"||MQ1.test($))&&($>-1&&$%1==0&&$<U)}function EQ1($,U,Y){if(!Hb(Y))return!1;var z=typeof U;if(z=="number"?Gb(Y)&&XX0(U,Y.length):z=="string"&&(U in Y))return Kb(Y[U],$);return!1}function CQ1($){var U=$&&$.constructor,Y=typeof U=="function"&&U.prototype||HX;return $===Y}function RQ1($){var U=[];if($!=null)for(var Y in Object($))U.push(Y);return U}function Kb($,U){return $===U||$!==$&&U!==U}function _Q1($){return hQ1($)&&WX.call($,"callee")&&(!NQ1.call($,"callee")||HX0.call($)==LQ1)}var vQ1=Array.isArray;function Gb($){return $!=null&&gQ1($.length)&&!SQ1($)}function hQ1($){return yQ1($)&&Gb($)}function SQ1($){var U=Hb($)?HX0.call($):"";return U==wQ1||U==FQ1}function gQ1($){return typeof $=="number"&&$>-1&&$%1==0&&$<=KX0}function Hb($){var U=typeof $;return!!$&&(U=="object"||U=="function")}function yQ1($){return!!$&&typeof $=="object"}var kQ1=jQ1(function($,U,Y,z){TQ1(U,fQ1(U),$,z)}),xQ1=WX0(function($){return $.push(void 0,AQ1),GX0(kQ1,void 0,$)});function fQ1($){return Gb($)?DQ1($,!0):PQ1($)}ZX0.exports=xQ1});var VX0=E((Ma1,Xb)=>{function uQ1($,U){if(!($ instanceof U))throw TypeError("Cannot call a class as a function")}var qX0=J6().Buffer,XX=J0("util");function bQ1($,U,Y){$.copy(U,Y)}Xb.exports=function(){function $(){uQ1(this,$),this.head=null,this.tail=null,this.length=0}return $.prototype.push=function(Y){var z={data:Y,next:null};if(this.length>0)this.tail.next=z;else this.head=z;this.tail=z,++this.length},$.prototype.unshift=function(Y){var z={data:Y,next:this.head};if(this.length===0)this.tail=z;this.head=z,++this.length},$.prototype.shift=function(){if(this.length===0)return;var Y=this.head.data;if(this.length===1)this.head=this.tail=null;else this.head=this.head.next;return--this.length,Y},$.prototype.clear=function(){this.head=this.tail=null,this.length=0},$.prototype.join=function(Y){if(this.length===0)return"";var z=this.head,I=""+z.data;while(z=z.next)I+=Y+z.data;return I},$.prototype.concat=function(Y){if(this.length===0)return qX0.alloc(0);var z=qX0.allocUnsafe(Y>>>0),I=this.head,Q=0;while(I)bQ1(I.data,z,Q),Q+=I.data.length,I=I.next;return z},$}();if(XX&&XX.inspect&&XX.inspect.custom)Xb.exports.prototype[XX.inspect.custom]=function(){var $=XX.inspect({length:this.length});return this.constructor.name+" "+$}});var Zb=E((Oa1,LX0)=>{var lD=Q6();function iQ1($,U){var Y=this,z=this._readableState&&this._readableState.destroyed,I=this._writableState&&this._writableState.destroyed;if(z||I){if(U)U($);else if($){if(!this._writableState)lD.nextTick(oD,this,$);else if(!this._writableState.errorEmitted)this._writableState.errorEmitted=!0,lD.nextTick(oD,this,$)}return this}if(this._readableState)this._readableState.destroyed=!0;if(this._writableState)this._writableState.destroyed=!0;return this._destroy($||null,function(Q){if(!U&&Q){if(!Y._writableState)lD.nextTick(oD,Y,Q);else if(!Y._writableState.errorEmitted)Y._writableState.errorEmitted=!0,lD.nextTick(oD,Y,Q)}else if(U)U(Q)}),this}function nQ1(){if(this._readableState)this._readabl Line truncated
%s`,P,P,N,z);var T=N.type==="*"?sb:N.type==="?"?rb:"\\"+N.type;I=!0,z=z.slice(0,N.reStart)+T+"\\("+P}if(V(),Q)z+="\\\\";var A=!1;switch(z.charAt(0)){case"[":case".":case"(":A=!0}for(var j=K.length-1;j>-1;j--){var C=K[j],b=z.slice(0,C.reStart),x=z.slice(C.reStart,C.reEnd-8),g=z.slice(C.reEnd-8,C.reEnd),i=z.slice(C.reEnd);g+=i;var n=b.split("(").length-1,z0=i;for(F=0;F<n;F++)z0=z0.replace(/\)[+*?]?/,"");i=z0;var k="";if(i===""&&U!==WA)k="$";var p=b+x+i+k+g;z=p}if(z!==""&&I)z="(?=.)"+z;if(A)z=Z+z;if(U===WA)return[z,I];if(!I)return KW1($);var a=Y.nocase?"i":"";try{var $0=new RegExp("^"+z+"$",a)}catch(y){return new RegExp("$.")}return $0._glob=$,$0._src=z,$0}Z$.makeRe=function($,U){return new L6($,U||{}).makeRe()};L6.prototype.makeRe=JW1;function JW1(){if(this.regexp||this.regexp===!1)return this.regexp;var $=this.set;if(!$.length)return this.regexp=!1,this.regexp;var U=this.options,Y=U.noglobstar?sb:U.dot?tH1:eH1,z=U.nocase?"i":"",I=$.map(function(Q){return Q.map(function(J){return J===uY?Y:typeof J==="string"?GW1(J):J._src}).join("\\/")}).join("|");if(I="^(?:"+I+")$",this.negate)I="^(?!"+I+").*$";try{this.regexp=new RegExp(I,z)}catch(Q){this.regexp=!1}return this.regexp}Z$.match=function($,U,Y){Y=Y||{};var z=new L6(U,Y);if($=$.filter(function(I){return z.match(I)}),z.options.nonull&&!$.length)$.push(U);return $};L6.prototype.match=function(U,Y){if(typeof Y>"u")Y=this.partial;if(this.debug("match",U,this.pattern),this.comment)return!1;if(this.empty)return U==="";if(U==="/"&&Y)return!0;var z=this.options;if(BX.sep!=="/")U=U.split(BX.sep).join("/");U=U.split(oZ0),this.debug(this.pattern,"split",U);var I=this.set;this.debug(this.pattern,"set",I);var Q,J;for(J=U.length-1;J>=0;J--)if(Q=U[J],Q)break;for(J=0;J<I.length;J++){var K=I[J],G=U;if(z.matchBase&&K.length===1)G=[Q];var H=this.matchOne(G,K,Y);if(H){if(z.flipNegate)return!0;return!this.negate}}if(z.flipNegate)return!1;return this.negate};L6.prototype.matchOne=function($,U,Y){if(U.indexOf(uY)!==-1)return this._matchGlobstar($,U,Y,0,0);return this._matchOne($,U,Y,0,0)};L6.prototype._matchGlobstar=function($,U,Y,z,I){var Q,J=-1;for(Q=I;Q<U.length;Q++)if(U[Q]===uY){J=Q;break}var K=-1;for(Q=U.length-1;Q>=0;Q--)if(U[Q]===uY){K=Q;break}var G=U.slice(I,J),H=Y?U.slice(J+1):U.slice(J+1,K),W=Y?[]:U.slice(K+1);if(G.length){var X=$.slice(z,z+G.length);if(!this._matchOne(X,G,Y,0,0))return!1;z+=G.length}var Z=0;if(W.length){if(W.length+z>$.length)return!1;var q=$.length-W.length;if(this._matchOne($,W,Y,q,0))Z=W.length;else{if($[$.length-1]!==""||z+W.length===$.length)return!1;if(q--,!this._matchOne($,W,Y,q,0))return!1;Z=W.length+1}}if(!H.length){var V=!!Z;for(Q=z;Q<$.length-Z;Q++){var F=String($[Q]);if(V=!0,F==="."||F===".."||!this.options.dot&&F.charAt(0)===".")return!1}return Y||V}var M=[[[],0]],w=M[0],N=0,O=[0];for(var D=0;D<H.length;D++){var P=H[D];if(P===uY)O.push(N),w=[[],0],M.push(w);else w[0].push(P),N++}var T=M.length-1,A=$.length-Z;for(var j=0;j<M.length;j++)M[j][1]=A-(O[T--]+M[j][0].length);return!!this._matchGlobStarBodySections($,M,z,0,Y,0,!!Z)};L6.prototype._matchGlobStarBodySections=function($,U,Y,z,I,Q,J){var K=U[z];if(!K){for(var G=Y;G<$.length;G++){J=!0;var H=$[G];if(H==="."||H===".."||!this.options.dot&&H.charAt(0)===".")return!1}return J}var W=K[0],X=K[1];while(Y<=X){var Z=this._matchOne($.slice(0,Y+W.length),W,I,Y,0);if(Z&&Q<this.maxGlobstarRecursion){var q=this._matchGlobStarBodySections($,U,Y+W.length,z+1,I,Q+1,J);if(q!==!1)return q}var H=$[Y];if(H==="."||H===".."||!this.options.dot&&H.charAt(0)===".")return!1;Y++}return I||null};L6.prototype._matchOne=function($,U,Y,z,I){var Q,J,K,G;for(Q=z,J=I,K=$.length,G=U.length;Q<K&&J<G;Q++,J++){this.debug("matchOne loop");var H=U[J],W=$[Q];if(this.debug(U,H,W),H===!1||H===uY)return!1;var X;if(typeof H==="string")X=W===H,this.debug("string match",H,W,X);else X=W.match(H),this.debug("pattern match",H,W,X);if(!X)return!1}if(Q===K&&J===G)return!0;else if(Q===K)return Y;else if(J===G)return Q===K-1&&$[Q]==="";throw Error("wtf?")};function KW1($){return $.replace(/\\(.)/g,"$1")}function GW1($){return $.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}});var VA=E((ua1,qA)=>{function aZ0($){return $.charAt(0)==="/"}function tZ0($){var U=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/,Y=U.exec($),z=Y[1]||"",I=Boolean(z&&z.charAt(1)!==":");return Boolean(Y[2]||I)}qA.exports=process.platform==="win32"?tZ0:aZ0;qA.exports.posix=aZ0;qA.exports.win32=tZ0});var tb=E((MW1)=>{MW1.setopts=VW1;MW1.ownProp=eZ0;MW1.makeAbs=PX;MW1.finish=LW1;MW1.mark=wW1;MW1.isIgnored=Uq0;MW1.childrenIgnored=FW1;function eZ0($,U){return Object.prototype.hasOwnProperty.call($,U)}var HW1=J0("fs"),AJ=J0("path"),WW1=ZA(),$q0=VA(),ab=WW1.Minimatch;function XW1($,U){return $.localeCompare(U,"en")}function ZW1($,U){if($.ignore=U.ignore||[],!Array.isArray($.ignore))$.ignore=[$.ignore];if($.ignore.length)$.ignore=$.ignore.map(qW1)}function qW1($){var U=null;if($.slice(-3)==="/**"){var Y=$.replace(/(\/\*\*)+$/,"");U=new ab(Y,{dot:!0})}return{ma Line truncated
See: https://github.com/isaacs/node-glob/issues/167`);return new j6($,U).found}function j6($,U){if(!$)throw Error("must provide pattern");if(typeof U==="function"||arguments.length===3)throw TypeError(`callback provided to sync glob
See: https://github.com/isaacs/node-glob/issues/167`);if(!(this instanceof j6))return new j6($,U);if(EW1(this,$,U),this.noprocess)return this;var Y=this.minimatch.set.length;this.matches=Array(Y);for(var z=0;z<Y;z++)this._process(this.minimatch.set[z],z,!1);this._finish()}j6.prototype._finish=function(){if(zq0.ok(this instanceof j6),this.realpath){var $=this;this.matches.forEach(function(U,Y){var z=$.matches[Y]=Object.create(null);for(var I in U)try{I=$._makeAbs(I);var Q=jW1.realpathSync(I,$.realpathCache);z[Q]=!0}catch(J){if(J.syscall==="stat")z[$._makeAbs(I)]=!0;else throw J}})}bY.finish(this)};j6.prototype._process=function($,U,Y){zq0.ok(this instanceof j6);var z=0;while(typeof $[z]==="string")z++;var I;switch(z){case $.length:this._processSimple($.join("/"),U);return;case 0:I=null;break;default:I=$.slice(0,z).join("/");break}var Q=$.slice(z),J;if(I===null)J=".";else if(LA(I)||LA($.map(function(H){return typeof H==="string"?H:"[*]"}).join("/"))){if(!I||!LA(I))I="/"+I;J=I}else J=I;var K=this._makeAbs(J);if(CW1(this,J))return;var G=Q[0]===Yq0.GLOBSTAR;if(G)this._processGlobStar(I,J,K,Q,U,Y);else this._processReaddir(I,J,K,Q,U,Y)};j6.prototype._processReaddir=function($,U,Y,z,I,Q){var J=this._readdir(Y,Q);if(!J)return;var K=z[0],G=!!this.minimatch.negate,H=K._glob,W=this.dot||H.charAt(0)===".",X=[];for(var Z=0;Z<J.length;Z++){var q=J[Z];if(q.charAt(0)!=="."||W){var V;if(G&&!$)V=!q.match(K);else V=q.match(K);if(V)X.push(q)}}var F=X.length;if(F===0)return;if(z.length===1&&!this.mark&&!this.stat){if(!this.matches[I])this.matches[I]=Object.create(null);for(var Z=0;Z<F;Z++){var q=X[Z];if($)if($.slice(-1)!=="/")q=$+"/"+q;else q=$+q;if(q.charAt(0)==="/"&&!this.nomount)q=eb.join(this.root,q);this._emitMatch(I,q)}return}z.shift();for(var Z=0;Z<F;Z++){var q=X[Z],M;if($)M=[$,q];else M=[q];this._process(M.concat(z),I,Q)}};j6.prototype._emitMatch=function($,U){if(RW1(this,U))return;var Y=this._makeAbs(U);if(this.mark)U=this._mark(U);if(this.absolute)U=Y;if(this.matches[$][U])return;if(this.nodir){var z=this.cache[Y];if(z==="DIR"||Array.isArray(z))return}if(this.matches[$][U]=!0,this.stat)this._stat(U)};j6.prototype._readdirInGlobStar=function($){if(this.follow)return this._readdir($,!1);var U,Y,z;try{Y=this.fs.lstatSync($)}catch(Q){if(Q.code==="ENOENT")return null}var I=Y&&Y.isSymbolicLink();if(this.symlinks[$]=I,!I&&Y&&!Y.isDirectory())this.cache[$]="FILE";else U=this._readdir($,!1);return U};j6.prototype._readdir=function($,U){var Y;if(U&&!$i(this.symlinks,$))return this._readdirInGlobStar($);if($i(this.cache,$)){var z=this.cache[$];if(!z||z==="FILE")return null;if(Array.isArray(z))return z}try{return this._readdirEntries($,this.fs.readdirSync($))}catch(I){return this._readdirError($,I),null}};j6.prototype._readdirEntries=function($,U){if(!this.mark&&!this.stat)for(var Y=0;Y<U.length;Y++){var z=U[Y];if($==="/")z=$+z;else z=$+"/"+z;this.cache[z]=!0}return this.cache[$]=U,U};j6.prototype._readdirError=function($,U){switch(U.code){case"ENOTSUP":case"ENOTDIR":var Y=this._makeAbs($);if(this.cache[Y]="FILE",Y===this.cwdAbs){var z=Error(U.code+" invalid cwd "+this.cwd);throw z.path=this.cwd,z.code=U.code,z}break;case"ENOENT":case"ELOOP":case"ENAMETOOLONG":case"UNKNOWN":this.cache[this._makeAbs($)]=!1;break;default:if(this.cache[this._makeAbs($)]=!1,this.strict)throw U;if(!this.silent)console.error("glob error",U);break}};j6.prototype._processGlobStar=function($,U,Y,z,I,Q){var J=this._readdir(Y,Q);if(!J)return;var K=z.slice(1),G=$?[$]:[],H=G.concat(K);this._process(H,I,!1);var W=J.length,X=this.symlinks[Y];if(X&&Q)return;for(var Z=0;Z<W;Z++){var q=J[Z];if(q.charAt(0)==="."&&!this.dot)continue;var V=G.concat(J[Z],K);this._process(V,I,!0);var F=G.concat(J[Z],z);this._process(F,I,!0)}};j6.prototype._processSimple=function($,U){var Y=this._stat($);if(!this.matches[U])this.matches[U]=Object.create(null);if(!Y)return;if($&&LA($)&&!this.nomount){var z=/[\/\\]$/.test($);if($.charAt(0)==="/")$=eb.join(this.root,$);else if($=eb.resolve(this.root,$),z)$+="/"}if(process.platform==="win32")$=$.replace(/\\/g,"/");this._emitMatch(U,$)};j6.prototype._stat=function($){var U=this._makeAbs($),Y=$.slice(-1)==="/";if($.length>this.maxLength)return!1;if(!this.stat&&$i(this.cache,U)){var J=this.cache[U];if(Array.isArray(J))J="DIR";if(!Y||J==="DIR")return J;if(Y&&J==="FILE")return!1}var z,I=this.statCache[U];if(!I){var Q;try{Q=this.fs.lstatSync(U)}catch(K){if(K&&(K.code==="ENOENT"||K.code==="ENOTDIR"))return this.statCache[U]=!1,!1}if(Q&&Q.isSymbolicLink())try{I=this.fs.statSync(U)}catch(K){I=Q}else I=Q}this.statCache[U]=I;var J=!0;if(I)J=I.isDirectory()?"DIR":"FILE";if(this.cache[U]=this.cache[U]||J,Y&&J==="FILE")return!1;return J};j6.prototype._mark=function($){return bY.mark(this,$)};j6.prototype._makeAbs=function($){return bY.makeAbs(this,$)}});var Ui=E((pa1,Gq0)=>{Gq0.exports=Kq0;function Kq0($,U){if($&&U)return Kq0($)(U);if(typeof $!=="function")throw TypeError("need wrapper function");return Object.keys($).forEach(function(z){Y[z]=$[z]}),Y;f Line truncated
`);if($.linkname)U+=ei(" linkpath="+$.linkname+`
`);var Y=$.pax;if(Y)for(var z in Y)U+=ei(" "+z+"="+Y[z]+`
`);return Buffer.from(U)};uq1.decodePax=function($){var U={};while($.length){var Y=0;while(Y<$.length&&$[Y]!==32)Y++;var z=parseInt($.slice(0,Y).toString(),10);if(!z)return U;var I=$.slice(Y+1,z-1).toString(),Q=I.indexOf("=");if(Q===-1)return U;U[I.slice(0,Q)]=I.slice(Q+1),$=$.slice(z)}return U};uq1.encode=function($){var U=Cq1(512),Y=$.name,z="";if($.typeflag===5&&Y[Y.length-1]!=="/")Y+="/";if(Buffer.byteLength(Y)!==Y.length)return null;while(Buffer.byteLength(Y)>100){var I=Y.indexOf("/");if(I===-1)return null;z+=z?"/"+Y.slice(0,I):Y.slice(0,I),Y=Y.slice(I+1)}if(Buffer.byteLength(Y)>100||Buffer.byteLength(z)>155)return null;if($.linkname&&Buffer.byteLength($.linkname)>100)return null;if(U.write(Y),U.write(E2($.mode&gq1,6),100),U.write(E2($.uid,6),108),U.write(E2($.gid,6),116),U.write(E2($.size,11),124),U.write(E2($.mtime.getTime()/1000|0,11),136),U[156]=AL0+xq1($.type),$.linkname)U.write($.linkname,157);if(BL0.copy(U,bX),vq1.copy(U,$n),$.uname)U.write($.uname,265);if($.gname)U.write($.gname,297);if(U.write(E2($.devmajor||0,6),329),U.write(E2($.devminor||0,6),337),z)U.write(z,345);return U.write(E2(TL0(U),6),148),U};uq1.decode=function($,U,Y){var z=$[156]===0?0:$[156]-AL0,I=vJ($,0,100,U),Q=C2($,100,8),J=C2($,108,8),K=C2($,116,8),G=C2($,124,12),H=C2($,136,12),W=kq1(z),X=$[157]===0?null:vJ($,157,100,U),Z=vJ($,265,32),q=vJ($,297,32),V=C2($,329,8),F=C2($,337,8),M=TL0($);if(M===256)return null;if(M!==C2($,148,8))throw Error("Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?");if(BL0.compare($,bX,bX+6)===0){if($[345])I=vJ($,345,155,U)+"/"+I}else if(hq1.compare($,bX,bX+6)===0&&Sq1.compare($,$n,$n+2)===0);else if(!Y)throw Error("Invalid tar header: unknown format.");if(z===0&&I&&I[I.length-1]==="/")z=5;return{name:I,mode:Q,uid:J,gid:K,size:G,mtime:new Date(1000*H),type:W,linkname:X,uname:Z,gname:q,devmajor:V,devminor:F}}});var hL0=E((ut1,vL0)=>{var EL0=J0("util"),pq1=DL0(),iX=Un(),CL0=v8().Writable,RL0=v8().PassThrough,_L0=function(){},jL0=function($){return $&=511,$&&512-$},mq1=function($,U){var Y=new yA($,U);return Y.end(),Y},lq1=function($,U){if(U.path)$.name=U.path;if(U.linkpath)$.linkname=U.linkpath;if(U.size)$.size=parseInt(U.size,10);return $.pax=U,$},yA=function($,U){this._parent=$,this.offset=U,RL0.call(this,{autoDestroy:!1})};EL0.inherits(yA,RL0);yA.prototype.destroy=function($){this._parent.destroy($)};var C3=function($){if(!(this instanceof C3))return new C3($);CL0.call(this,$),$=$||{},this._offset=0,this._buffer=pq1(),this._missing=0,this._partial=!1,this._onparse=_L0,this._header=null,this._stream=null,this._overflow=null,this._cb=null,this._locked=!1,this._destroyed=!1,this._pax=null,this._paxGlobal=null,this._gnuLongPath=null,this._gnuLongLinkPath=null;var U=this,Y=U._buffer,z=function(){U._continue()},I=function(Z){if(U._locked=!1,Z)return U.destroy(Z);if(!U._stream)z()},Q=function(){U._stream=null;var Z=jL0(U._header.size);if(Z)U._parse(Z,J);else U._parse(512,X);if(!U._locked)z()},J=function(){U._buffer.consume(jL0(U._header.size)),U._parse(512,X),z()},K=function(){var Z=U._header.size;U._paxGlobal=iX.decodePax(Y.slice(0,Z)),Y.consume(Z),Q()},G=function(){var Z=U._header.size;if(U._pax=iX.decodePax(Y.slice(0,Z)),U._paxGlobal)U._pax=Object.assign({},U._paxGlobal,U._pax);Y.consume(Z),Q()},H=function(){var Z=U._header.size;this._gnuLongPath=iX.decodeLongPath(Y.slice(0,Z),$.filenameEncoding),Y.consume(Z),Q()},W=function(){var Z=U._header.size;this._gnuLongLinkPath=iX.decodeLongPath(Y.slice(0,Z),$.filenameEncoding),Y.consume(Z),Q()},X=function(){var Z=U._offset,q;try{q=U._header=iX.decode(Y.slice(0,512),$.filenameEncoding,$.allowUnknownFormat)}catch(V){U.emit("error",V)}if(Y.consume(512),!q){U._parse(512,X),z();return}if(q.type==="gnu-long-path"){U._parse(q.size,H),z();return}if(q.type==="gnu-long-link-path"){U._parse(q.size,W),z();return}if(q.type==="pax-global-header"){U._parse(q.size,K),z();return}if(q.type==="pax-header"){U._parse(q.size,G),z();return}if(U._gnuLongPath)q.name=U._gnuLongPath,U._gnuLongPath=null;if(U._gnuLongLinkPath)q.linkname=U._gnuLongLinkPath,U._gnuLongLinkPath=null;if(U._pax)U._header=q=lq1(q,U._pax),U._pax=null;if(U._locked=!0,!q.size||q.type==="directory"){U._parse(512,X),U.emit("entry",q,mq1(U,Z),I);return}U._stream=new yA(U,Z),U.emit("entry",q,U._stream,I),U._parse(q.size,Q),z()};this._onheader=X,this._parse(512,X)};EL0.inherits(C3,CL0);C3.prototype.destroy=function($){if(this._destroyed)return;if(this._destroyed=!0,$)this.emit("error",$);if(this.emit("close"),this._stream)this._stream.emit("close")};C3.prototype._parse=function($,U){if(this._destroyed)return;if(this._offset+=$,this._missing=$,U===this._onheader)this._partial=!1;this._onparse=U};C3.prototype._continue=function(){if(this._destroyed)return;var $=this._cb;if(this._cb=_L0,this._overflow)this._write(this._overflow,void 0,$);else $()};C3.prototype._write=function($,U,Y){if(this._destroyed)return;var z=this._stream,I=this._buffer,Q=this._missing;if($.length)this._partial=!0;if($.length<Q) Line truncated
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">`)}_writeRelationship($){if(!this.count)this._writeOpen();let U=`rId${++this.count}`;if($.TargetMode)this.stream.write(`<Relationship Id="${U}" Type="${$.Type}" Target="${ZV1.xmlEncode($.Target)}" TargetMode="${$.TargetMode}"/>`);else this.stream.write(`<Relationship Id="${U}" Type="${$.Type}" Target="${$.Target}"/>`);return U}_writeClose(){this.stream.write("</Relationships>")}}Iw0.exports=zw0});var Ww0=E((rt1,Hw0)=>{var Jw0=r6(),Kw0=Q2(),VV1=n4(),LV1=Vf(),wV1=wf();class Gw0{constructor($,U,Y){this.id=Y.id,this.count=0,this._worksheet=$,this._workbook=Y.workbook,this._sheetRelsWriter=U}get commentsStream(){if(!this._commentsStream)this._commentsStream=this._workbook._openStream(`/xl/comments${this.id}.xml`);return this._commentsStream}get vmlStream(){if(!this._vmlStream)this._vmlStream=this._workbook._openStream(`xl/drawings/vmlDrawing${this.id}.vml`);return this._vmlStream}_addRelationships(){let $={Type:Kw0.Comments,Target:`../comments${this.id}.xml`};this._sheetRelsWriter.addRelationship($);let U={Type:Kw0.VmlDrawing,Target:`../drawings/vmlDrawing${this.id}.vml`};this.vmlRelId=this._sheetRelsWriter.addRelationship(U)}_addCommentRefs(){this._workbook.commentRefs.push({commentName:`comments${this.id}`,vmlDrawing:`vmlDrawing${this.id}`})}_writeOpen(){this.commentsStream.write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><comments xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><authors><author>Author</author></authors><commentList>'),this.vmlStream.write('<?xml version="1.0" encoding="UTF-8"?><xml xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:x="urn:schemas-microsoft-com:office:excel"><o:shapelayout v:ext="edit"><o:idmap v:ext="edit" data="1" /></o:shapelayout><v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe"><v:stroke joinstyle="miter" /><v:path gradientshapeok="t" o:connecttype="rect" /></v:shapetype>')}_writeComment($,U){let Y=new LV1,z=new Jw0;Y.render(z,$),this.commentsStream.write(z.xml);let I=new wV1,Q=new Jw0;I.render(Q,$,U),this.vmlStream.write(Q.xml)}_writeClose(){this.commentsStream.write("</commentList></comments>"),this.vmlStream.write("</xml>")}addComments($){if($&&$.length){if(!this.startedData)this._worksheet.comments=[],this._writeOpen(),this._addRelationships(),this._addCommentRefs(),this.startedData=!0;$.forEach((U)=>{U.refAddress=VV1.decodeAddress(U.ref)}),$.forEach((U)=>{this._writeComment(U,this.count),this.count+=1})}}commit(){if(this.count)this._writeClose(),this.commentsStream.end(),this.vmlStream.end()}}Hw0.exports=Gw0});var ww0=E((st1,Lw0)=>{var FV1=$6(),MV1=Q2(),In=n4(),Xw0=Sg(),Zw0=Q3(),OV1=lk(),qw0=bM(),Qn=nM(),NV1=Qw0(),DV1=Ww0(),AV1=vg(),x6=new OV1,Jn=Y2(),BV1=nx(),PV1=cx(),TV1=dx(),jV1=fx(),EV1=kx(),CV1=ux(),RV1=px(),_V1=mx(),vV1=lx(),hV1=ox(),SV1=rx(),gV1=sx(),yV1=Uf(),kV1=tx(),xV1=ax(),f6={dataValidations:new BV1,sheetProperties:new PV1,sheetFormatProperties:new TV1,columns:new Jn({tag:"cols",length:!1,childXform:new jV1}),row:new EV1,hyperlinks:new Jn({tag:"hyperlinks",length:!1,childXform:new CV1}),sheetViews:new Jn({tag:"sheetViews",length:!1,childXform:new RV1}),sheetProtection:new _V1,pageMargins:new vV1,pageSeteup:new hV1,autoFilter:new SV1,picture:new gV1,conditionalFormattings:new yV1,headerFooter:new kV1,rowBreaks:new xV1};class Vw0{constructor($){this.id=$.id,this.name=$.name||`Sheet${this.id}`,this.state=$.state||"visible",this._rows=[],this._columns=null,this._keys={},this._merges=[],this._merges.add=function(){},this._sheetRelsWriter=new NV1($),this._sheetCommentsWriter=new DV1(this,this._sheetRelsWriter,$),this._dimensions=new Zw0,this._rowZero=1,this.committed=!1,this.dataValidations=new AV1,this._formulae={},this._siFormulae=0,this.conditionalFormatting=[],this.rowBreaks=[],this.properties=Object.assign({},{defaultRowHeight:15,dyDescent:55,outlineLevelCol:0,outlineLevelRow:0},$.properties),this.headerFooter=Object.assign({},{differentFirst:!1,differentOddEven:!1,oddHeader:null,oddFooter:null,evenHeader:null,evenFooter:null,firstHeader:null,firstFooter:null},$.headerFooter),this.pageSetup=Object.assign({},{margins:{left:0.7,right:0.7,top:0.75,bottom:0.75,header:0.3,footer:0.3},orientation:"portrait",horizontalDpi:4294967295,verticalDpi:4294967295,fitToPage:!!($.pageSetup&&($.pageSetup.fitToWidth||$.pageSetup.fitToHeight)&&!$.pageSetup.scale),pageOrder:"downThenOver",blackAndWhite:!1,draft:!1,cellComments:"None",errors:"displayed",scale:100,fitToWidth:1,fitToHeight:1,paperSize:void 0,showRowColHeaders:!1,showGridLines:!1,horizontalCentered:!1,verticalCentered:!1,rowBreaks:null,colBreaks:null},$.pageSetup),this.useSharedStrings=$.useSharedStrings||!1,this._workbook=$.workbook,this.hasComments=!1,this._views=$.views||[],this.autoFilter=$.autoFilter||null,this._media=[],this.sheetProtection=null,this._writeOpenWorksheet(),this.startedData=!1}get Line truncated
See http://goo.gl/MqrFmX
`)},Wn=Xn.getNativePromise();if(Xn.isNode&&typeof MutationObserver>"u")Zn=global.setImmediate,qn=process.nextTick,tz=Xn.isRecentNode?function($){Zn.call(global,$)}:function($){qn.call(process,$)};else if(typeof Wn==="function"&&typeof Wn.resolve==="function")Vn=Wn.resolve(),tz=function($){Vn.then($)};else if(typeof MutationObserver<"u"&&!(typeof window<"u"&&window.navigator&&(window.navigator.standalone||window.cordova)))tz=function(){var $=document.createElement("div"),Y={attributes:!0},z=!1,U=document.createElement("div"),Q=new MutationObserver(function(){$.classList.toggle("foo"),z=!1});Q.observe(U,Y);var J=function(){if(z)return;z=!0,U.classList.toggle("foo")};return function(K){var G=new MutationObserver(function(){G.disconnect(),K()});G.observe($,Y),J()}}();else if(typeof setImmediate<"u")tz=function($){setImmediate($)};else if(typeof setTimeout<"u")tz=function($){setTimeout($,0)};else tz=$L1;var Zn,qn,Vn;fF0.exports=tz});var iF0=E((_t1,bF0)=>{function YL1($,Y,z,U,Q){for(var J=0;J<Q;++J)z[J+U]=$[J+Y],$[J+Y]=void 0}function _2($){this._capacity=$,this._length=0,this._front=0}_2.prototype._willBeOverCapacity=function($){return this._capacity<$};_2.prototype._pushOne=function($){var Y=this.length();this._checkCapacity(Y+1);var z=this._front+Y&this._capacity-1;this[z]=$,this._length=Y+1};_2.prototype.push=function($,Y,z){var U=this.length()+3;if(this._willBeOverCapacity(U)){this._pushOne($),this._pushOne(Y),this._pushOne(z);return}var Q=this._front+U-3;this._checkCapacity(U);var J=this._capacity-1;this[Q+0&J]=$,this[Q+1&J]=Y,this[Q+2&J]=z,this._length=U};_2.prototype.shift=function(){var $=this._front,Y=this[$];return this[$]=void 0,this._front=$+1&this._capacity-1,this._length--,Y};_2.prototype.length=function(){return this._length};_2.prototype._checkCapacity=function($){if(this._capacity<$)this._resizeTo(this._capacity<<1)};_2.prototype._resizeTo=function($){var Y=this._capacity;this._capacity=$;var z=this._front,U=this._length,Q=z+U&Y-1;YL1(this,0,this,Y,Q)};bF0.exports=_2});var oF0=E((vt1,Ln)=>{var mF0;try{throw Error()}catch($){mF0=$}var zL1=uF0(),nF0=iF0(),lF0=O4();function u6(){this._customScheduler=!1,this._isTickUsed=!1,this._lateQueue=new nF0(16),this._normalQueue=new nF0(16),this._haveDrainedQueues=!1,this._trampolineEnabled=!0;var $=this;this.drainQueues=function(){$._drainQueues()},this._schedule=zL1}u6.prototype.setScheduler=function($){var Y=this._schedule;return this._schedule=$,this._customScheduler=!0,Y};u6.prototype.hasCustomScheduler=function(){return this._customScheduler};u6.prototype.enableTrampoline=function(){this._trampolineEnabled=!0};u6.prototype.disableTrampolineIfNecessary=function(){if(lF0.hasDevTools)this._trampolineEnabled=!1};u6.prototype.haveItemsQueued=function(){return this._isTickUsed||this._haveDrainedQueues};u6.prototype.fatalError=function($,Y){if(Y)process.stderr.write("Fatal "+($ instanceof Error?$.stack:$)+`
`),process.exit(2);else this.throwLater($)};u6.prototype.throwLater=function($,Y){if(arguments.length===1)Y=$,$=function(){throw Y};if(typeof setTimeout<"u")setTimeout(function(){$(Y)},0);else try{this._schedule(function(){$(Y)})}catch(z){throw Error(`No async scheduler available
`)},Pn=Tn.getNativePromise();if(Tn.isNode&&typeof MutationObserver>"u")jn=global.setImmediate,En=process.nextTick,tY=Tn.isRecentNode?function($){jn.call(global,$)}:function($){En.call(process,$)};else if(typeof Pn==="function"&&typeof Pn.resolve==="function")Cn=Pn.resolve(),tY=function($){Cn.then($)};else if(typeof MutationObserver<"u"&&!(typeof window<"u"&&window.navigator&&(window.navigator.standalone||window.cordova)))tY=function(){var $=document.createElement("div"),U={attributes:!0},Y=!1,z=document.createElement("div"),I=new MutationObserver(function(){$.classList.toggle("foo"),Y=!1});I.observe(z,U);var Q=function(){if(Y)return;Y=!0,z.classList.toggle("foo")};return function(K){var G=new MutationObserver(function(){G.disconnect(),K()});G.observe($,U),Q()}}();else if(typeof setImmediate<"u")tY=function($){setImmediate($)};else if(typeof setTimeout<"u")tY=function($){setTimeout($,0)};else tY=CL1;var jn,En,Cn;rw0.exports=tY});var tw0=E((Ge1,aw0)=>{function RL1($,U,Y,z,I){for(var Q=0;Q<I;++Q)Y[Q+z]=$[Q+U],$[Q+U]=void 0}function v2($){this._capacity=$,this._length=0,this._front=0}v2.prototype._willBeOverCapacity=function($){return this._capacity<$};v2.prototype._pushOne=function($){var U=this.length();this._checkCapacity(U+1);var Y=this._front+U&this._capacity-1;this[Y]=$,this._length=U+1};v2.prototype.push=function($,U,Y){var z=this.length()+3;if(this._willBeOverCapacity(z)){this._pushOne($),this._pushOne(U),this._pushOne(Y);return}var I=this._front+z-3;this._checkCapacity(z);var Q=this._capacity-1;this[I+0&Q]=$,this[I+1&Q]=U,this[I+2&Q]=Y,this._length=z};v2.prototype.shift=function(){var $=this._front,U=this[$];return this[$]=void 0,this._front=$+1&this._capacity-1,this._length--,U};v2.prototype.length=function(){return this._length};v2.prototype._checkCapacity=function($){if(this._capacity<$)this._resizeTo(this._capacity<<1)};v2.prototype._resizeTo=function($){var U=this._capacity;this._capacity=$;var Y=this._front,z=this._length,I=Y+z&U-1;RL1(this,0,this,U,I)};aw0.exports=v2});var QF0=E((He1,Rn)=>{var zF0;try{throw Error()}catch($){zF0=$}var _L1=sw0(),ew0=tw0(),IF0=F4();function u6(){this._customScheduler=!1,this._isTickUsed=!1,this._lateQueue=new ew0(16),this._normalQueue=new ew0(16),this._haveDrainedQueues=!1,this._trampolineEnabled=!0;var $=this;this.drainQueues=function(){$._drainQueues()},this._schedule=_L1}u6.prototype.setScheduler=function($){var U=this._schedule;return this._schedule=$,this._customScheduler=!0,U};u6.prototype.hasCustomScheduler=function(){return this._customScheduler};u6.prototype.enableTrampoline=function(){this._trampolineEnabled=!0};u6.prototype.disableTrampolineIfNecessary=function(){if(IF0.hasDevTools)this._trampolineEnabled=!1};u6.prototype.haveItemsQueued=function(){return this._isTickUsed||this._haveDrainedQueues};u6.prototype.fatalError=function($,U){if(U)process.stderr.write("Fatal "+($ instanceof Error?$.stack:$)+`
`),process.exit(2);else this.throwLater($)};u6.prototype.throwLater=function($,U){if(arguments.length===1)U=$,$=function(){throw U};if(typeof setTimeout<"u")setTimeout(function(){$(U)},0);else try{this._schedule(function(){$(U)})}catch(Y){throw Error(`No async scheduler available
See http://goo.gl/MqrFmX
`)}};function cF0($,Y,z){this._lateQueue.push($,Y,z),this._queueTick()}function pF0($,Y,z){this._normalQueue.push($,Y,z),this._queueTick()}function dF0($){this._normalQueue._pushOne($),this._queueTick()}if(!lF0.hasDevTools)u6.prototype.invokeLater=cF0,u6.prototype.invoke=pF0,u6.prototype.settlePromises=dF0;else u6.prototype.invokeLater=function($,Y,z){if(this._trampolineEnabled)cF0.call(this,$,Y,z);else this._schedule(function(){setTimeout(function(){$.call(Y,z)},100)})},u6.prototype.invoke=function($,Y,z){if(this._trampolineEnabled)pF0.call(this,$,Y,z);else this._schedule(function(){$.call(Y,z)})},u6.prototype.settlePromises=function($){if(this._trampolineEnabled)dF0.call(this,$);else this._schedule(function(){$._settlePromises()})};u6.prototype._drainQueue=function($){while($.length()>0){var Y=$.shift();if(typeof Y!=="function"){Y._settlePromises();continue}var z=$.shift(),U=$.shift();Y.call(z,U)}};u6.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,this._drainQueue(this._lateQueue)};u6.prototype._queueTick=function(){if(!this._isTickUsed)this._isTickUsed=!0,this._schedule(this.drainQueues)};u6.prototype._reset=function(){this._isTickUsed=!1};Ln.exports=u6;Ln.exports.firstLineError=mF0});var E3=E((ht1,aF0)=>{var wn=az(),UL1=wn.freeze,rF0=O4(),sF0=rF0.inherits,yI=rF0.notEnumerableProp;function kI($,Y){function z(U){if(!(this instanceof z))return new z(U);if(yI(this,"message",typeof U==="string"?U:Y),yI(this,"name",$),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);else Error.call(this)}return sF0(z,Error),z}var Fn,On,QL1=kI("Warning","warning"),JL1=kI("CancellationError","cancellation error"),IL1=kI("TimeoutError","timeout error"),dX=kI("AggregateError","aggregate error");try{Fn=TypeError,On=RangeError}catch($){Fn=kI("TypeError","type error"),On=kI("RangeError","range error")}var fA="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" ");for(ez=0;ez<fA.length;++ez)if(typeof Array.prototype[fA[ez]]==="function")dX.prototype[fA[ez]]=Array.prototype[fA[ez]];var ez;wn.defineProperty(dX.prototype,"length",{value:0,configurable:!1,writable:!0,enumerable:!0});dX.prototype.isOperational=!0;var uA=0;dX.prototype.toString=function(){var $=Array(uA*4+1).join(" "),Y=`
`)}};function $F0($,U,Y){this._lateQueue.push($,U,Y),this._queueTick()}function UF0($,U,Y){this._normalQueue.push($,U,Y),this._queueTick()}function YF0($){this._normalQueue._pushOne($),this._queueTick()}if(!IF0.hasDevTools)u6.prototype.invokeLater=$F0,u6.prototype.invoke=UF0,u6.prototype.settlePromises=YF0;else u6.prototype.invokeLater=function($,U,Y){if(this._trampolineEnabled)$F0.call(this,$,U,Y);else this._schedule(function(){setTimeout(function(){$.call(U,Y)},100)})},u6.prototype.invoke=function($,U,Y){if(this._trampolineEnabled)UF0.call(this,$,U,Y);else this._schedule(function(){$.call(U,Y)})},u6.prototype.settlePromises=function($){if(this._trampolineEnabled)YF0.call(this,$);else this._schedule(function(){$._settlePromises()})};u6.prototype._drainQueue=function($){while($.length()>0){var U=$.shift();if(typeof U!=="function"){U._settlePromises();continue}var Y=$.shift(),z=$.shift();U.call(Y,z)}};u6.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,this._drainQueue(this._lateQueue)};u6.prototype._queueTick=function(){if(!this._isTickUsed)this._isTickUsed=!0,this._schedule(this.drainQueues)};u6.prototype._reset=function(){this._isTickUsed=!1};Rn.exports=u6;Rn.exports.firstLineError=zF0});var _3=E((We1,GF0)=>{var hn=aY(),vL1=hn.freeze,JF0=F4(),KF0=JF0.inherits,kJ=JF0.notEnumerableProp;function xJ($,U){function Y(z){if(!(this instanceof Y))return new Y(z);if(kJ(this,"message",typeof z==="string"?z:U),kJ(this,"name",$),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);else Error.call(this)}return KF0(Y,Error),Y}var _n,vn,hL1=xJ("Warning","warning"),SL1=xJ("CancellationError","cancellation error"),gL1=xJ("TimeoutError","timeout error"),lX=xJ("AggregateError","aggregate error");try{_n=TypeError,vn=RangeError}catch($){_n=xJ("TypeError","type error"),vn=xJ("RangeError","range error")}var dA="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" ");for(eY=0;eY<dA.length;++eY)if(typeof Array.prototype[dA[eY]]==="function")lX.prototype[dA[eY]]=Array.prototype[dA[eY]];var eY;hn.defineProperty(lX.prototype,"length",{value:0,configurable:!1,writable:!0,enumerable:!0});lX.prototype.isOperational=!0;var pA=0;lX.prototype.toString=function(){var $=Array(pA*4+1).join(" "),U=`
`+$+`AggregateError of:
`;uA++,$=Array(uA*4+1).join(" ");for(var z=0;z<this.length;++z){var U=this[z]===this?"[Circular AggregateError]":this[z]+"",Q=U.split(`
`);for(var J=0;J<Q.length;++J)Q[J]=$+Q[J];U=Q.join(`
`),Y+=U+`
`}return uA--,Y};function pX($){if(!(this instanceof pX))return new pX($);if(yI(this,"name","OperationalError"),yI(this,"message",$),this.cause=$,this.isOperational=!0,$ instanceof Error)yI(this,"message",$.message),yI(this,"stack",$.stack);else if(Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}sF0(pX,Error);var $U=Error.__BluebirdErrorTypes__;if(!$U)$U=UL1({CancellationError:JL1,TimeoutError:IL1,OperationalError:pX,RejectionError:pX,AggregateError:dX}),wn.defineProperty(Error,"__BluebirdErrorTypes__",{value:$U,writable:!1,enumerable:!1,configurable:!1});aF0.exports={Error,TypeError:Fn,RangeError:On,CancellationError:$U.CancellationError,OperationalError:$U.OperationalError,TimeoutError:$U.TimeoutError,AggregateError:$U.AggregateError,Warning:QL1}});var eF0=E((St1,tF0)=>{tF0.exports=function($,Y){var z=O4(),U=z.errorObj,Q=z.isObject;function J(X,Z){if(Q(X)){if(X instanceof $)return X;var q=K(X);if(q===U){if(Z)Z._pushContext();var V=$.reject(q.e);if(Z)Z._popContext();return V}else if(typeof q==="function"){if(H(X)){var V=new $(Y);return X._then(V._fulfill,V._reject,void 0,V,null),V}return W(X,q,Z)}}return X}function I(X){return X.then}function K(X){try{return I(X)}catch(Z){return U.e=Z,U}}var G={}.hasOwnProperty;function H(X){try{return G.call(X,"_promise0")}catch(Z){return!1}}function W(X,Z,q){var V=new $(Y),F=V;if(q)q._pushContext();if(V._captureStackTrace(),q)q._popContext();var w=!0,O=z.tryCatch(Z).call(X,N,M);if(w=!1,V&&O===U)V._rejectCallback(O.e,!0,!0),V=null;function N(D){if(!V)return;V._resolveCallback(D),V=null}function M(D){if(!V)return;V._rejectCallback(D,w,!0),V=null}return F}return J}});var YO0=E((gt1,$O0)=>{$O0.exports=function($,Y,z,U,Q){var J=O4(),I=J.isArray;function K(H){switch(H){case-2:return[];case-3:return{}}}function G(H){var W=this._promise=new $(Y);if(H instanceof $)W._propagateFrom(H,3);W._setOnCancel(this),this._values=H,this._length=0,this._totalResolved=0,this._init(void 0,-2)}return J.inherits(G,Q),G.prototype.length=function(){return this._length},G.prototype.promise=function(){return this._promise},G.prototype._init=function H(W,X){var Z=z(this._values,this._promise);if(Z instanceof $){Z=Z._target();var q=Z._bitField;if(this._values=Z,(q&50397184)===0)return this._promise._setAsyncGuaranteed(),Z._then(H,this._reject,void 0,this,X);else if((q&33554432)!==0)Z=Z._value();else if((q&16777216)!==0)return this._reject(Z._reason());else return this._cancel()}if(Z=J.asArray(Z),Z===null){var V=U("expecting an array or an iterable object but got "+J.classString(Z)).reason();this._promise._rejectCallback(V,!1);return}if(Z.length===0){if(X===-5)this._resolveEmptyArray();else this._resolve(K(X));return}this._iterate(Z)},G.prototype._iterate=function(H){var W=this.getActualLength(H.length);this._length=W,this._values=this.shouldCopyValues()?Array(W):this._values;var X=this._promise,Z=!1,q=null;for(var V=0;V<W;++V){var F=z(H[V],X);if(F instanceof $)F=F._target(),q=F._bitField;else q=null;if(Z){if(q!==null)F.suppressUnhandledRejections()}else if(q!==null)if((q&50397184)===0)F._proxy(this,V),this._values[V]=F;else if((q&33554432)!==0)Z=this._promiseFulfilled(F._value(),V);else if((q&16777216)!==0)Z=this._promiseRejected(F._reason(),V);else Z=this._promiseCancelled(V);else Z=this._promiseFulfilled(F,V)}if(!Z)X._setAsyncGuaranteed()},G.prototype._isResolved=function(){return this._values===null},G.prototype._resolve=function(H){this._values=null,this._promise._fulfill(H)},G.prototype._cancel=function(){if(this._isResolved()||!this._promise._isCancellable())return;this._values=null,this._promise._cancel()},G.prototype._reject=function(H){this._values=null,this._promise._rejectCallback(H,!1)},G.prototype._promiseFulfilled=function(H,W){this._values[W]=H;var X=++this._totalResolved;if(X>=this._length)return this._resolve(this._values),!0;return!1},G.prototype._promiseCancelled=function(){return this._cancel(),!0},G.prototype._promiseRejected=function(H){return this._totalResolved++,this._reject(H),!0},G.prototype._resultCancelled=function(){if(this._isResolved())return;var H=this._values;if(this._cancel(),H instanceof $)H.cancel();else for(var W=0;W<H.length;++W)if(H[W]instanceof $)H[W].cancel()},G.prototype.shouldCopyValues=function(){return!0},G.prototype.getActualLength=function(H){return H},G}});var UO0=E((yt1,zO0)=>{zO0.exports=function($){var Y=!1,z=[];$.prototype._promiseCreated=function(){},$.prototype._pushContext=function(){},$.prototype._popContext=function(){return null},$._peekContext=$.prototype._peekContext=function(){};function U(){this._trace=new U.CapturedTrace(J())}U.prototype._pushContext=function(){if(this._trace!==void 0)this._trace._promiseCreated=null,z.push(this._trace)},U.prototype._popContext=function(){if(this._trace!==void 0){var I=z.pop(),K=I._promiseCreated;return I._promiseCreated=null,K}return null};function Q(){if(Y)return new U}function J(){var I=z.length-1;if(I>=0)return z[I];return}return U.CapturedTrace=null,U.create=Q,U.deactivateLong Line truncated
`;pA++,$=Array(pA*4+1).join(" ");for(var Y=0;Y<this.length;++Y){var z=this[Y]===this?"[Circular AggregateError]":this[Y]+"",I=z.split(`
`);for(var Q=0;Q<I.length;++Q)I[Q]=$+I[Q];z=I.join(`
`),U+=z+`
`}return pA--,U};function mX($){if(!(this instanceof mX))return new mX($);if(kJ(this,"name","OperationalError"),kJ(this,"message",$),this.cause=$,this.isOperational=!0,$ instanceof Error)kJ(this,"message",$.message),kJ(this,"stack",$.stack);else if(Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}KF0(mX,Error);var $z=Error.__BluebirdErrorTypes__;if(!$z)$z=vL1({CancellationError:SL1,TimeoutError:gL1,OperationalError:mX,RejectionError:mX,AggregateError:lX}),hn.defineProperty(Error,"__BluebirdErrorTypes__",{value:$z,writable:!1,enumerable:!1,configurable:!1});GF0.exports={Error,TypeError:_n,RangeError:vn,CancellationError:$z.CancellationError,OperationalError:$z.OperationalError,TimeoutError:$z.TimeoutError,AggregateError:$z.AggregateError,Warning:hL1}});var WF0=E((Xe1,HF0)=>{HF0.exports=function($,U){var Y=F4(),z=Y.errorObj,I=Y.isObject;function Q(X,Z){if(I(X)){if(X instanceof $)return X;var q=K(X);if(q===z){if(Z)Z._pushContext();var V=$.reject(q.e);if(Z)Z._popContext();return V}else if(typeof q==="function"){if(H(X)){var V=new $(U);return X._then(V._fulfill,V._reject,void 0,V,null),V}return W(X,q,Z)}}return X}function J(X){return X.then}function K(X){try{return J(X)}catch(Z){return z.e=Z,z}}var G={}.hasOwnProperty;function H(X){try{return G.call(X,"_promise0")}catch(Z){return!1}}function W(X,Z,q){var V=new $(U),F=V;if(q)q._pushContext();if(V._captureStackTrace(),q)q._popContext();var M=!0,w=Y.tryCatch(Z).call(X,N,O);if(M=!1,V&&w===z)V._rejectCallback(w.e,!0,!0),V=null;function N(D){if(!V)return;V._resolveCallback(D),V=null}function O(D){if(!V)return;V._rejectCallback(D,M,!0),V=null}return F}return Q}});var ZF0=E((Ze1,XF0)=>{XF0.exports=function($,U,Y,z,I){var Q=F4(),J=Q.isArray;function K(H){switch(H){case-2:return[];case-3:return{}}}function G(H){var W=this._promise=new $(U);if(H instanceof $)W._propagateFrom(H,3);W._setOnCancel(this),this._values=H,this._length=0,this._totalResolved=0,this._init(void 0,-2)}return Q.inherits(G,I),G.prototype.length=function(){return this._length},G.prototype.promise=function(){return this._promise},G.prototype._init=function H(W,X){var Z=Y(this._values,this._promise);if(Z instanceof $){Z=Z._target();var q=Z._bitField;if(this._values=Z,(q&50397184)===0)return this._promise._setAsyncGuaranteed(),Z._then(H,this._reject,void 0,this,X);else if((q&33554432)!==0)Z=Z._value();else if((q&16777216)!==0)return this._reject(Z._reason());else return this._cancel()}if(Z=Q.asArray(Z),Z===null){var V=z("expecting an array or an iterable object but got "+Q.classString(Z)).reason();this._promise._rejectCallback(V,!1);return}if(Z.length===0){if(X===-5)this._resolveEmptyArray();else this._resolve(K(X));return}this._iterate(Z)},G.prototype._iterate=function(H){var W=this.getActualLength(H.length);this._length=W,this._values=this.shouldCopyValues()?Array(W):this._values;var X=this._promise,Z=!1,q=null;for(var V=0;V<W;++V){var F=Y(H[V],X);if(F instanceof $)F=F._target(),q=F._bitField;else q=null;if(Z){if(q!==null)F.suppressUnhandledRejections()}else if(q!==null)if((q&50397184)===0)F._proxy(this,V),this._values[V]=F;else if((q&33554432)!==0)Z=this._promiseFulfilled(F._value(),V);else if((q&16777216)!==0)Z=this._promiseRejected(F._reason(),V);else Z=this._promiseCancelled(V);else Z=this._promiseFulfilled(F,V)}if(!Z)X._setAsyncGuaranteed()},G.prototype._isResolved=function(){return this._values===null},G.prototype._resolve=function(H){this._values=null,this._promise._fulfill(H)},G.prototype._cancel=function(){if(this._isResolved()||!this._promise._isCancellable())return;this._values=null,this._promise._cancel()},G.prototype._reject=function(H){this._values=null,this._promise._rejectCallback(H,!1)},G.prototype._promiseFulfilled=function(H,W){this._values[W]=H;var X=++this._totalResolved;if(X>=this._length)return this._resolve(this._values),!0;return!1},G.prototype._promiseCancelled=function(){return this._cancel(),!0},G.prototype._promiseRejected=function(H){return this._totalResolved++,this._reject(H),!0},G.prototype._resultCancelled=function(){if(this._isResolved())return;var H=this._values;if(this._cancel(),H instanceof $)H.cancel();else for(var W=0;W<H.length;++W)if(H[W]instanceof $)H[W].cancel()},G.prototype.shouldCopyValues=function(){return!0},G.prototype.getActualLength=function(H){return H},G}});var VF0=E((qe1,qF0)=>{qF0.exports=function($){var U=!1,Y=[];$.prototype._promiseCreated=function(){},$.prototype._pushContext=function(){},$.prototype._popContext=function(){return null},$._peekContext=$.prototype._peekContext=function(){};function z(){this._trace=new z.CapturedTrace(Q())}z.prototype._pushContext=function(){if(this._trace!==void 0)this._trace._promiseCreated=null,Y.push(this._trace)},z.prototype._popContext=function(){if(this._trace!==void 0){var J=Y.pop(),K=J._promiseCreated;return J._promiseCreated=null,K}return null};function I(){if(U)return new z}function Q(){var J=Y.length-1;if(J>=0)return Y[J];return}return z.CapturedTrace=null,z.create=I,z.deactivateLong Line truncated
See http://goo.gl/MqrFmX
`);if(!A0.longStackTraces&&b0()){var Q0=$.prototype._captureStackTrace,B=$.prototype._attachExtraTrace;A0.longStackTraces=!0,D=function(){if(U.haveItemsQueued()&&!A0.longStackTraces)throw Error(`cannot enable long stack traces after promises have been created
`);if(!D0.longStackTraces&&u0()){var I0=$.prototype._captureStackTrace,B=$.prototype._attachExtraTrace;D0.longStackTraces=!0,D=function(){if(z.haveItemsQueued()&&!D0.longStackTraces)throw Error(`cannot enable long stack traces after promises have been created
See http://goo.gl/MqrFmX
`);$.prototype._captureStackTrace=Q0,$.prototype._attachExtraTrace=B,Y.deactivateLongStackTraces(),U.enableTrampoline(),A0.longStackTraces=!1},$.prototype._captureStackTrace=g,$.prototype._attachExtraTrace=p,Y.activateLongStackTraces(),U.disableTrampolineIfNecessary()}},$.hasLongStackTraces=function(){return A0.longStackTraces&&b0()};var P=function(){try{if(typeof CustomEvent==="function"){var Q0=new CustomEvent("CustomEvent");return J.global.dispatchEvent(Q0),function(B,v){var u=new CustomEvent(B.toLowerCase(),{detail:v,cancelable:!0});return!J.global.dispatchEvent(u)}}else if(typeof Event==="function"){var Q0=new Event("CustomEvent");return J.global.dispatchEvent(Q0),function(v,u){var a=new Event(v.toLowerCase(),{cancelable:!0});return a.detail=u,!J.global.dispatchEvent(a)}}else{var Q0=document.createEvent("CustomEvent");return Q0.initCustomEvent("testingtheevent",!1,!0,{}),J.global.dispatchEvent(Q0),function(v,u){var a=document.createEvent("CustomEvent");return a.initCustomEvent(v.toLowerCase(),!1,!0,u),!J.global.dispatchEvent(a)}}}catch(B){}return function(){return!1}}(),j=function(){if(J.isNode)return function(){return process.emit.apply(process,arguments)};else{if(!J.global)return function(){return!1};return function(Q0){var B="on"+Q0.toLowerCase(),v=J.global[B];if(!v)return!1;return v.apply(J.global,[].slice.call(arguments,1)),!0}}}();function A(Q0,B){return{promise:B}}var T={promiseCreated:A,promiseFulfilled:A,promiseRejected:A,promiseResolved:A,promiseCancelled:A,promiseChained:function(Q0,B,v){return{promise:B,child:v}},warning:function(Q0,B){return{warning:B}},unhandledRejection:function(Q0,B,v){return{reason:B,promise:v}},rejectionHandled:A},C=function(Q0){var B=!1;try{B=j.apply(null,arguments)}catch(u){U.throwLater(u),B=!0}var v=!1;try{v=P(Q0,T[Q0].apply(null,arguments))}catch(u){U.throwLater(u),v=!0}return v||B};$.config=function(Q0){if(Q0=Object(Q0),"longStackTraces"in Q0){if(Q0.longStackTraces)$.longStackTraces();else if(!Q0.longStackTraces&&$.hasLongStackTraces())D()}if("warnings"in Q0){var B=Q0.warnings;if(A0.warnings=!!B,M=A0.warnings,J.isObject(B)){if("wForgottenReturn"in B)M=!!B.wForgottenReturn}}if("cancellation"in Q0&&Q0.cancellation&&!A0.cancellation){if(U.haveItemsQueued())throw Error("cannot enable cancellation after promises are in use");$.prototype._clearCancellationData=U0,$.prototype._propagateFrom=x,$.prototype._onCancel=i,$.prototype._setOnCancel=n,$.prototype._attachCancellationCallback=S,$.prototype._execute=k,t=x,A0.cancellation=!0}if("monitoring"in Q0){if(Q0.monitoring&&!A0.monitoring)A0.monitoring=!0,$.prototype._fireEvent=C;else if(!Q0.monitoring&&A0.monitoring)A0.monitoring=!1,$.prototype._fireEvent=b}return $};function b(){return!1}$.prototype._fireEvent=b,$.prototype._execute=function(Q0,B,v){try{Q0(B,v)}catch(u){return u}},$.prototype._onCancel=function(){},$.prototype._setOnCancel=function(Q0){},$.prototype._attachCancellationCallback=function(Q0){},$.prototype._captureStackTrace=function(){},$.prototype._attachExtraTrace=function(){},$.prototype._clearCancellationData=function(){},$.prototype._propagateFrom=function(Q0,B){};function k(Q0,B,v){var u=this;try{Q0(B,v,function(a){if(typeof a!=="function")throw TypeError("onCancel must be a function, got: "+J.toString(a));u._attachCancellationCallback(a)})}catch(a){return a}}function S(Q0){if(!this._isCancellable())return this;var B=this._onCancel();if(B!==void 0)if(J.isArray(B))B.push(Q0);else this._setOnCancel([B,Q0]);else this._setOnCancel(Q0)}function i(){return this._onCancelField}function n(Q0){this._onCancelField=Q0}function U0(){this._cancellationParent=void 0,this._onCancelField=void 0}function x(Q0,B){if((B&1)!==0){this._cancellationParent=Q0;var v=Q0._branchesRemainingToCancel;if(v===void 0)v=0;Q0._branchesRemainingToCancel=v+1}if((B&2)!==0&&Q0._isBound())this._setBoundTo(Q0._boundTo)}function d(Q0,B){if((B&2)!==0&&Q0._isBound())this._setBoundTo(Q0._boundTo)}var t=d;function e(){var Q0=this._boundTo;if(Q0!==void 0){if(Q0 instanceof $)if(Q0.isFulfilled())return Q0.value();else return}return Q0}function g(){this._trace=new u1(this._peekContext())}function p(Q0,B){if(I(Q0)){var v=this._trace;if(v!==void 0){if(B)v=v._parent}if(v!==void 0)v.attachExtraTrace(Q0);else if(!Q0.__stackCleaned__){var u=f0(Q0);J.notEnumerableProp(Q0,"stack",u.message+`
`);$.prototype._captureStackTrace=I0,$.prototype._attachExtraTrace=B,U.deactivateLongStackTraces(),z.enableTrampoline(),D0.longStackTraces=!1},$.prototype._captureStackTrace=y,$.prototype._attachExtraTrace=d,U.activateLongStackTraces(),z.disableTrampolineIfNecessary()}},$.hasLongStackTraces=function(){return D0.longStackTraces&&u0()};var P=function(){try{if(typeof CustomEvent==="function"){var I0=new CustomEvent("CustomEvent");return Q.global.dispatchEvent(I0),function(B,h){var u=new CustomEvent(B.toLowerCase(),{detail:h,cancelable:!0});return!Q.global.dispatchEvent(u)}}else if(typeof Event==="function"){var I0=new Event("CustomEvent");return Q.global.dispatchEvent(I0),function(h,u){var s=new Event(h.toLowerCase(),{cancelable:!0});return s.detail=u,!Q.global.dispatchEvent(s)}}else{var I0=document.createEvent("CustomEvent");return I0.initCustomEvent("testingtheevent",!1,!0,{}),Q.global.dispatchEvent(I0),function(h,u){var s=document.createEvent("CustomEvent");return s.initCustomEvent(h.toLowerCase(),!1,!0,u),!Q.global.dispatchEvent(s)}}}catch(B){}return function(){return!1}}(),T=function(){if(Q.isNode)return function(){return process.emit.apply(process,arguments)};else{if(!Q.global)return function(){return!1};return function(I0){var B="on"+I0.toLowerCase(),h=Q.global[B];if(!h)return!1;return h.apply(Q.global,[].slice.call(arguments,1)),!0}}}();function A(I0,B){return{promise:B}}var j={promiseCreated:A,promiseFulfilled:A,promiseRejected:A,promiseResolved:A,promiseCancelled:A,promiseChained:function(I0,B,h){return{promise:B,child:h}},warning:function(I0,B){return{warning:B}},unhandledRejection:function(I0,B,h){return{reason:B,promise:h}},rejectionHandled:A},C=function(I0){var B=!1;try{B=T.apply(null,arguments)}catch(u){z.throwLater(u),B=!0}var h=!1;try{h=P(I0,j[I0].apply(null,arguments))}catch(u){z.throwLater(u),h=!0}return h||B};$.config=function(I0){if(I0=Object(I0),"longStackTraces"in I0){if(I0.longStackTraces)$.longStackTraces();else if(!I0.longStackTraces&&$.hasLongStackTraces())D()}if("warnings"in I0){var B=I0.warnings;if(D0.warnings=!!B,O=D0.warnings,Q.isObject(B)){if("wForgottenReturn"in B)O=!!B.wForgottenReturn}}if("cancellation"in I0&&I0.cancellation&&!D0.cancellation){if(z.haveItemsQueued())throw Error("cannot enable cancellation after promises are in use");$.prototype._clearCancellationData=z0,$.prototype._propagateFrom=k,$.prototype._onCancel=i,$.prototype._setOnCancel=n,$.prototype._attachCancellationCallback=g,$.prototype._execute=x,a=k,D0.cancellation=!0}if("monitoring"in I0){if(I0.monitoring&&!D0.monitoring)D0.monitoring=!0,$.prototype._fireEvent=C;else if(!I0.monitoring&&D0.monitoring)D0.monitoring=!1,$.prototype._fireEvent=b}return $};function b(){return!1}$.prototype._fireEvent=b,$.prototype._execute=function(I0,B,h){try{I0(B,h)}catch(u){return u}},$.prototype._onCancel=function(){},$.prototype._setOnCancel=function(I0){},$.prototype._attachCancellationCallback=function(I0){},$.prototype._captureStackTrace=function(){},$.prototype._attachExtraTrace=function(){},$.prototype._clearCancellationData=function(){},$.prototype._propagateFrom=function(I0,B){};function x(I0,B,h){var u=this;try{I0(B,h,function(s){if(typeof s!=="function")throw TypeError("onCancel must be a function, got: "+Q.toString(s));u._attachCancellationCallback(s)})}catch(s){return s}}function g(I0){if(!this._isCancellable())return this;var B=this._onCancel();if(B!==void 0)if(Q.isArray(B))B.push(I0);else this._setOnCancel([B,I0]);else this._setOnCancel(I0)}function i(){return this._onCancelField}function n(I0){this._onCancelField=I0}function z0(){this._cancellationParent=void 0,this._onCancelField=void 0}function k(I0,B){if((B&1)!==0){this._cancellationParent=I0;var h=I0._branchesRemainingToCancel;if(h===void 0)h=0;I0._branchesRemainingToCancel=h+1}if((B&2)!==0&&I0._isBound())this._setBoundTo(I0._boundTo)}function p(I0,B){if((B&2)!==0&&I0._isBound())this._setBoundTo(I0._boundTo)}var a=p;function $0(){var I0=this._boundTo;if(I0!==void 0){if(I0 instanceof $)if(I0.isFulfilled())return I0.value();else return}return I0}function y(){this._trace=new u1(this._peekContext())}function d(I0,B){if(J(I0)){var h=this._trace;if(h!==void 0){if(B)h=h._parent}if(h!==void 0)h.attachExtraTrace(I0);else if(!I0.__stackCleaned__){var u=o0(I0);Q.notEnumerableProp(I0,"stack",u.message+`
`+u.stack.join(`
`)),J.notEnumerableProp(Q0,"__stackCleaned__",!0)}}}function Y0(Q0,B,v,u,a){if(Q0===void 0&&B!==null&&M){if(a!==void 0&&a._returnedNonUndefined())return;if((u._bitField&65535)===0)return;if(v)v=v+" ";var X0="",J0="";if(B._trace){var q0=B._trace.stack.split(`
`),w0=_0(q0);for(var B0=w0.length-1;B0>=0;--B0){var r0=w0[B0];if(!W.test(r0)){var I1=r0.match(X);if(I1)X0="at "+I1[1]+":"+I1[2]+":"+I1[3]+" ";break}}if(w0.length>0){var U1=w0[0];for(var B0=0;B0<q0.length;++B0)if(q0[B0]===U1){if(B0>0)J0=`
`+q0[B0-1];break}}}var A1="a promise was created in a "+v+"handler "+X0+"but was not returned from it, see http://goo.gl/rRqMUw"+J0;u._warn(A1,!0,B)}}function y(Q0,B){var v=Q0+" is deprecated and will be removed in a future version.";if(B)v+=" Use "+B+" instead.";return r(v)}function r(Q0,B,v){if(!A0.warnings)return;var u=new Q(Q0),a;if(B)v._attachExtraTrace(u);else if(A0.longStackTraces&&(a=$._peekContext()))a.attachExtraTrace(u);else{var X0=f0(u);u.stack=X0.message+`
`+X0.stack.join(`
`)}if(!C("warning",u))e0(u,"",!0)}function $0(Q0,B){for(var v=0;v<B.length-1;++v)B[v].push("From previous event:"),B[v]=B[v].join(`
`);if(v<B.length)B[v]=B[v].join(`
`);return Q0+`
`)),Q.notEnumerableProp(I0,"__stackCleaned__",!0)}}}function U0(I0,B,h,u,s){if(I0===void 0&&B!==null&&O){if(s!==void 0&&s._returnedNonUndefined())return;if((u._bitField&65535)===0)return;if(h)h=h+" ";var W0="",Q0="";if(B._trace){var Z0=B._trace.stack.split(`
`),F0=y0(Z0);for(var A0=F0.length-1;A0>=0;--A0){var r0=F0[A0];if(!W.test(r0)){var Q1=r0.match(X);if(Q1)W0="at "+Q1[1]+":"+Q1[2]+":"+Q1[3]+" ";break}}if(F0.length>0){var Y1=F0[0];for(var A0=0;A0<Z0.length;++A0)if(Z0[A0]===Y1){if(A0>0)Q0=`
`+Z0[A0-1];break}}}var A1="a promise was created in a "+h+"handler "+W0+"but was not returned from it, see http://goo.gl/rRqMUw"+Q0;u._warn(A1,!0,B)}}function R(I0,B){var h=I0+" is deprecated and will be removed in a future version.";if(B)h+=" Use "+B+" instead.";return o(h)}function o(I0,B,h){if(!D0.warnings)return;var u=new I(I0),s;if(B)h._attachExtraTrace(u);else if(D0.longStackTraces&&(s=$._peekContext()))s.attachExtraTrace(u);else{var W0=o0(u);u.stack=W0.message+`
`+W0.stack.join(`
`)}if(!C("warning",u))q1(u,"",!0)}function e(I0,B){for(var h=0;h<B.length-1;++h)B[h].push("From previous event:"),B[h]=B[h].join(`
`);if(h<B.length)B[h]=B[h].join(`
`);return I0+`
`+B.join(`
`)}function N0(Q0){for(var B=0;B<Q0.length;++B)if(Q0[B].length===0||B+1<Q0.length&&Q0[B][0]===Q0[B+1][0])Q0.splice(B,1),B--}function T0(Q0){var B=Q0[0];for(var v=1;v<Q0.length;++v){var u=Q0[v],a=B.length-1,X0=B[a],J0=-1;for(var q0=u.length-1;q0>=0;--q0)if(u[q0]===X0){J0=q0;break}for(var q0=J0;q0>=0;--q0){var w0=u[q0];if(B[a]===w0)B.pop(),a--;else break}B=u}}function _0(Q0){var B=[];for(var v=0;v<Q0.length;++v){var u=Q0[v],a=u===" (No stack trace)"||Z.test(u),X0=a&&i0(u);if(a&&!X0){if(V&&u.charAt(0)!==" ")u=" "+u;B.push(u)}}return B}function G0(Q0){var B=Q0.stack.replace(/\s+$/g,"").split(`
`);for(var v=0;v<B.length;++v){var u=B[v];if(u===" (No stack trace)"||Z.test(u))break}if(v>0&&Q0.name!="SyntaxError")B=B.slice(v);return B}function f0(Q0){var B=Q0.stack,v=Q0.toString();return B=typeof B==="string"&&B.length>0?G0(Q0):[" (No stack trace)"],{message:v,stack:Q0.name=="SyntaxError"?B:_0(B)}}function e0(Q0,B,v){if(typeof console<"u"){var u;if(J.isObject(Q0)){var a=Q0.stack;u=B+q(a,Q0)}else u=B+String(Q0);if(typeof F==="function")F(u,v);else if(typeof console.log==="function"||typeof console.log==="object")console.log(u)}}function s(Q0,B,v,u){var a=!1;try{if(typeof B==="function")if(a=!0,Q0==="rejectionHandled")B(u);else B(v,u)}catch(X0){U.throwLater(X0)}if(Q0==="unhandledRejection"){if(!C(Q0,v,u)&&!a)e0(v,"Unhandled rejection ")}else C(Q0,u)}function H0(Q0){var B;if(typeof Q0==="function")B="[function "+(Q0.name||"anonymous")+"]";else{B=Q0&&typeof Q0.toString==="function"?Q0.toString():J.toString(Q0);var v=/\[object [a-zA-Z0-9$_]+\]/;if(v.test(B))try{var u=JSON.stringify(Q0);B=u}catch(a){}if(B.length===0)B="(empty array)"}return"(<"+F0(B)+">, no stack trace)"}function F0(Q0){var B=41;if(Q0.length<B)return Q0;return Q0.substr(0,B-3)+"..."}function b0(){return typeof b1==="function"}var i0=function(){return!1},n0=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;function w1(Q0){var B=Q0.match(n0);if(B)return{fileName:B[1],line:parseInt(B[2],10)}}function k1(Q0,B){if(!b0())return;var v=Q0.stack.split(`
`)}function O0(I0){for(var B=0;B<I0.length;++B)if(I0[B].length===0||B+1<I0.length&&I0[B][0]===I0[B+1][0])I0.splice(B,1),B--}function T0(I0){var B=I0[0];for(var h=1;h<I0.length;++h){var u=I0[h],s=B.length-1,W0=B[s],Q0=-1;for(var Z0=u.length-1;Z0>=0;--Z0)if(u[Z0]===W0){Q0=Z0;break}for(var Z0=Q0;Z0>=0;--Z0){var F0=u[Z0];if(B[s]===F0)B.pop(),s--;else break}B=u}}function y0(I0){var B=[];for(var h=0;h<I0.length;++h){var u=I0[h],s=u===" (No stack trace)"||Z.test(u),W0=s&&b0(u);if(s&&!W0){if(V&&u.charAt(0)!==" ")u=" "+u;B.push(u)}}return B}function v0(I0){var B=I0.stack.replace(/\s+$/g,"").split(`
`);for(var h=0;h<B.length;++h){var u=B[h];if(u===" (No stack trace)"||Z.test(u))break}if(h>0&&I0.name!="SyntaxError")B=B.slice(h);return B}function o0(I0){var B=I0.stack,h=I0.toString();return B=typeof B==="string"&&B.length>0?v0(I0):[" (No stack trace)"],{message:h,stack:I0.name=="SyntaxError"?B:y0(B)}}function q1(I0,B,h){if(typeof console<"u"){var u;if(Q.isObject(I0)){var s=I0.stack;u=B+q(s,I0)}else u=B+String(I0);if(typeof F==="function")F(u,h);else if(typeof console.log==="function"||typeof console.log==="object")console.log(u)}}function t(I0,B,h,u){var s=!1;try{if(typeof B==="function")if(s=!0,I0==="rejectionHandled")B(u);else B(h,u)}catch(W0){z.throwLater(W0)}if(I0==="unhandledRejection"){if(!C(I0,h,u)&&!s)q1(h,"Unhandled rejection ")}else C(I0,u)}function X0(I0){var B;if(typeof I0==="function")B="[function "+(I0.name||"anonymous")+"]";else{B=I0&&typeof I0.toString==="function"?I0.toString():Q.toString(I0);var h=/\[object [a-zA-Z0-9$_]+\]/;if(h.test(B))try{var u=JSON.stringify(I0);B=u}catch(s){}if(B.length===0)B="(empty array)"}return"(<"+w0(B)+">, no stack trace)"}function w0(I0){var B=41;if(I0.length<B)return I0;return I0.substr(0,B-3)+"..."}function u0(){return typeof b1==="function"}var b0=function(){return!1},n0=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;function P1(I0){var B=I0.match(n0);if(B)return{fileName:B[1],line:parseInt(B[2],10)}}function k1(I0,B){if(!u0())return;var h=I0.stack.split(`
`),u=B.stack.split(`
`),a=-1,X0=-1,J0,q0;for(var w0=0;w0<v.length;++w0){var B0=w1(v[w0]);if(B0){J0=B0.fileName,a=B0.line;break}}for(var w0=0;w0<u.length;++w0){var B0=w1(u[w0]);if(B0){q0=B0.fileName,X0=B0.line;break}}if(a<0||X0<0||!J0||!q0||J0!==q0||a>=X0)return;i0=function(r0){if(H.test(r0))return!0;var I1=w1(r0);if(I1){if(I1.fileName===J0&&(a<=I1.line&&I1.line<=X0))return!0}return!1}}function u1(Q0){this._parent=Q0,this._promisesCreated=0;var B=this._length=1+(Q0===void 0?0:Q0._length);if(b1(this,u1),B>32)this.uncycle()}J.inherits(u1,Error),Y.CapturedTrace=u1,u1.prototype.uncycle=function(){var Q0=this._length;if(Q0<2)return;var B=[],v={};for(var u=0,a=this;a!==void 0;++u)B.push(a),a=a._parent;Q0=this._length=u;for(var u=Q0-1;u>=0;--u){var X0=B[u].stack;if(v[X0]===void 0)v[X0]=u}for(var u=0;u<Q0;++u){var J0=B[u].stack,q0=v[J0];if(q0!==void 0&&q0!==u){if(q0>0)B[q0-1]._parent=void 0,B[q0-1]._length=1;B[u]._parent=void 0,B[u]._length=1;var w0=u>0?B[u-1]:this;if(q0<Q0-1)w0._parent=B[q0+1],w0._parent.uncycle(),w0._length=w0._parent._length+1;else w0._parent=void 0,w0._length=1;var B0=w0._length+1;for(var r0=u-2;r0>=0;--r0)B[r0]._length=B0,B0++;return}}},u1.prototype.attachExtraTrace=function(Q0){if(Q0.__stackCleaned__)return;this.uncycle();var B=f0(Q0),v=B.message,u=[B.stack],a=this;while(a!==void 0)u.push(_0(a.stack.split(`
`))),a=a._parent;T0(u),N0(u),J.notEnumerableProp(Q0,"stack",$0(v,u)),J.notEnumerableProp(Q0,"__stackCleaned__",!0)};var b1=function(){var B=/^\s*at\s*/,v=function(J0,q0){if(typeof J0==="string")return J0;if(q0.name!==void 0&&q0.message!==void 0)return q0.toString();return H0(q0)};if(typeof Error.stackTraceLimit==="number"&&typeof Error.captureStackTrace==="function"){Error.stackTraceLimit+=6,Z=B,q=v;var u=Error.captureStackTrace;return i0=function(J0){return H.test(J0)},function(J0,q0){Error.stackTraceLimit+=6,u(J0,q0),Error.stackTraceLimit-=6}}var a=Error();if(typeof a.stack==="string"&&a.stack.split(`
`)[0].indexOf("stackDetection@")>=0)return Z=/@/,q=v,V=!0,function(q0){q0.stack=Error().stack};var X0;try{throw Error()}catch(J0){X0="stack"in J0}if(!("stack"in a)&&X0&&typeof Error.stackTraceLimit==="number")return Z=B,q=v,function(q0){Error.stackTraceLimit+=6;try{throw Error()}catch(w0){q0.stack=w0.stack}Error.stackTraceLimit-=6};return q=function(J0,q0){if(typeof J0==="string")return J0;if((typeof q0==="object"||typeof q0==="function")&&q0.name!==void 0&&q0.message!==void 0)return q0.toString();return H0(q0)},null}([]);if(typeof console<"u"&&typeof console.warn<"u"){if(F=function(Q0){console.warn(Q0)},J.isNode&&process.stderr.isTTY)F=function(Q0,B){var v=B?"\x1B[33m":"\x1B[31m";console.warn(v+Q0+`\x1B[0m
`)};else if(!J.isNode&&typeof Error().stack==="string")F=function(Q0,B){console.warn("%c"+Q0,B?"color: darkorange":"color: red")}}var A0={warnings:O,longStackTraces:!1,cancellation:!1,monitoring:!1};if(N)$.longStackTraces();return{longStackTraces:function(){return A0.longStackTraces},warnings:function(){return A0.warnings},cancellation:function(){return A0.cancellation},monitoring:function(){return A0.monitoring},propagateFromFunction:function(){return t},boundValueFunction:function(){return e},checkForgottenReturns:Y0,setBounds:k1,warn:r,deprecated:y,CapturedTrace:u1,fireDomEvent:P,fireGlobalEvent:j}}});var KO0=E((xt1,IO0)=>{IO0.exports=function($,Y){var z=O4(),U=$.CancellationError,Q=z.errorObj;function J(X,Z,q){this.promise=X,this.type=Z,this.handler=q,this.called=!1,this.cancelPromise=null}J.prototype.isFinallyHandler=function(){return this.type===0};function I(X){this.finallyHandler=X}I.prototype._resultCancelled=function(){K(this.finallyHandler)};function K(X,Z){if(X.cancelPromise!=null){if(arguments.length>1)X.cancelPromise._reject(Z);else X.cancelPromise._cancel();return X.cancelPromise=null,!0}return!1}function G(){return W.call(this,this.promise._target()._settledValue())}function H(X){if(K(this,X))return;return Q.e=X,Q}function W(X){var Z=this.promise,q=this.handler;if(!this.called){this.called=!0;var V=this.isFinallyHandler()?q.call(Z._boundValue()):q.call(Z._boundValue(),X);if(V!==void 0){Z._setReturnedNonUndefined();var F=Y(V,Z);if(F instanceof $){if(this.cancelPromise!=null){if(F._isCancelled()){var w=new U("late cancellation observer");return Z._attachExtraTrace(w),Q.e=w,Q}else if(F.isPending())F._attachCancellationCallback(new I(this))}return F._then(G,H,void 0,this,void 0)}}}if(Z.isRejected())return K(this),Q.e=X,Q;else return K(this),X}return $.prototype._passThrough=function(X,Z,q,V){if(typeof X!=="function")return this.then();return this._then(q,V,void 0,new J(this,Z,X),void 0)},$.prototype.lastly=$.prototype.finally=function(X){return this._passThrough(X,0,W,W)},$.prototype.tap=function(X){return this._passThrough(X,1,W)},J}});var HO0=E((ft1,GO0)=>{GO0.exports=function($){var Y=O4(),z=az().keys,U=Y.tryCatch,Q=Y.errorObj;function J(I,K,G){return function(H){var W=G._boundValue();$:for(var X=0;X<I.length;++X){var Z=I[X];if(Z===Error||Z!=null&&Z.prototype instanceof Error){if(H instanceof Z)return U(K).call(W,H)}else if(typeof Z==="function"){var q=U(Z).call(W,H);if(q===Q)return q;else if(q)return U(K).call(W,H)}else if(Y.isObject(H)){var V=z(Z);for(var F=0;F<V.length;++F){var w=V[F];if(Z[w]!=H[w])continue $}return U(K).call(W,H)}}return $}}return J}});var Mn=E((ut1,ZO0)=>{var WO0=O4(),KL1=WO0.maybeWrapAsError,GL1=E3(),HL1=GL1.OperationalError,XO0=az();function WL1($){return $ instanceof Error&&XO0.getPrototypeOf($)===Error.prototype}var XL1=/^(?:name|message|stack|cause)$/;function ZL1($){var Y;if(WL1($)){Y=new HL1($),Y.name=$.name,Y.message=$.message,Y.stack=$.stack;var z=XO0.keys($);for(var U=0;U<z.length;++U){var Q=z[U];if(!XL1.test(Q))Y[Q]=$[Q]}return Y}return WO0.markAsOriginatingFromRejection($),$}function qL1($,Y){return function(z,U){if($===null)return;if(z){var Q=ZL1(KL1(z));$._attachExtraTrace(Q),$._reject(Q)}else if(!Y)$._fulfill(U);else{var J=arguments.length,I=Array(Math.max(J-1,0));for(var K=1;K<J;++K)I[K-1]=arguments[K];$._fulfill(I)}$=null}}ZO0.exports=qL1});var VO0=E((bt1,qO0)=>{qO0.exports=function($,Y,z,U,Q){var J=O4(),I=J.tryCatch;$.method=function(K){if(typeof K!=="function")throw new $.TypeError("expecting a function but got "+J.classString(K));return function(){var G=new $(Y);G._captureStackTrace(),G._pushContext();var H=I(K).apply(this,arguments),W=G._popContext();return Q.checkForgottenReturns(H,W,"Promise.method",G),G._resolveFromSyncValue(H),G}},$.attempt=$.try=function(K){if(typeof K!=="function")return U("expecting a function but got "+J.classString(K));var G=new $(Y);G._captureStackTrace(),G._pushContext();var H;if(arguments.length>1){Q.deprecated("calling Promise.try with more than 1 argument");var W=arguments[1],X=arguments[2];H=J.isArray(W)?I(K).apply(X,W):I(K).call(X,W)}else H=I(K)();var Z=G._popContext();return Q.checkForgottenReturns(H,Z,"Promise.try",G),G._resolveFromSyncValue(H),G},$.prototype._resolveFromSyncValue=function(K){if(K===J.errorObj)this._rejectCallback(K.e,!1);else this._resolveCallback(K,!0)}}});var FO0=E((it1,LO0)=>{LO0.exports=function($,Y,z,U){var Q=!1,J=function(H,W){this._reject(W)},I=function(H,W){W.promiseRejectionQueued=!0,W.bindingPromise._then(J,J,null,this,H)},K=function(H,W){if((this._bitField&50397184)===0)this._resolveCallback(W.target)},G=function(H,W){if(!W.promiseRejectionQueued)this._reject(H)};$.prototype.bind=function(H){if(!Q)Q=!0,$.prototype._propagateFrom=U.propagateFromFunction(),$.prototype._boundValue=U.boundValueFunction();var W=z(H),X=new $(Y);X._propagateFrom(this,1);var Z=this._target();if(X._setBoundTo(W),W instanceof $){var q={promiseRejectionQueued:!1,promise:X,target:Z,bindingPromise:W};Z._then(Y,I,voi Line truncated
`),s=-1,W0=-1,Q0,Z0;for(var F0=0;F0<h.length;++F0){var A0=P1(h[F0]);if(A0){Q0=A0.fileName,s=A0.line;break}}for(var F0=0;F0<u.length;++F0){var A0=P1(u[F0]);if(A0){Z0=A0.fileName,W0=A0.line;break}}if(s<0||W0<0||!Q0||!Z0||Q0!==Z0||s>=W0)return;b0=function(r0){if(H.test(r0))return!0;var Q1=P1(r0);if(Q1){if(Q1.fileName===Q0&&(s<=Q1.line&&Q1.line<=W0))return!0}return!1}}function u1(I0){this._parent=I0,this._promisesCreated=0;var B=this._length=1+(I0===void 0?0:I0._length);if(b1(this,u1),B>32)this.uncycle()}Q.inherits(u1,Error),U.CapturedTrace=u1,u1.prototype.uncycle=function(){var I0=this._length;if(I0<2)return;var B=[],h={};for(var u=0,s=this;s!==void 0;++u)B.push(s),s=s._parent;I0=this._length=u;for(var u=I0-1;u>=0;--u){var W0=B[u].stack;if(h[W0]===void 0)h[W0]=u}for(var u=0;u<I0;++u){var Q0=B[u].stack,Z0=h[Q0];if(Z0!==void 0&&Z0!==u){if(Z0>0)B[Z0-1]._parent=void 0,B[Z0-1]._length=1;B[u]._parent=void 0,B[u]._length=1;var F0=u>0?B[u-1]:this;if(Z0<I0-1)F0._parent=B[Z0+1],F0._parent.uncycle(),F0._length=F0._parent._length+1;else F0._parent=void 0,F0._length=1;var A0=F0._length+1;for(var r0=u-2;r0>=0;--r0)B[r0]._length=A0,A0++;return}}},u1.prototype.attachExtraTrace=function(I0){if(I0.__stackCleaned__)return;this.uncycle();var B=o0(I0),h=B.message,u=[B.stack],s=this;while(s!==void 0)u.push(y0(s.stack.split(`
`))),s=s._parent;T0(u),O0(u),Q.notEnumerableProp(I0,"stack",e(h,u)),Q.notEnumerableProp(I0,"__stackCleaned__",!0)};var b1=function(){var B=/^\s*at\s*/,h=function(Q0,Z0){if(typeof Q0==="string")return Q0;if(Z0.name!==void 0&&Z0.message!==void 0)return Z0.toString();return X0(Z0)};if(typeof Error.stackTraceLimit==="number"&&typeof Error.captureStackTrace==="function"){Error.stackTraceLimit+=6,Z=B,q=h;var u=Error.captureStackTrace;return b0=function(Q0){return H.test(Q0)},function(Q0,Z0){Error.stackTraceLimit+=6,u(Q0,Z0),Error.stackTraceLimit-=6}}var s=Error();if(typeof s.stack==="string"&&s.stack.split(`
`)[0].indexOf("stackDetection@")>=0)return Z=/@/,q=h,V=!0,function(Z0){Z0.stack=Error().stack};var W0;try{throw Error()}catch(Q0){W0="stack"in Q0}if(!("stack"in s)&&W0&&typeof Error.stackTraceLimit==="number")return Z=B,q=h,function(Z0){Error.stackTraceLimit+=6;try{throw Error()}catch(F0){Z0.stack=F0.stack}Error.stackTraceLimit-=6};return q=function(Q0,Z0){if(typeof Q0==="string")return Q0;if((typeof Z0==="object"||typeof Z0==="function")&&Z0.name!==void 0&&Z0.message!==void 0)return Z0.toString();return X0(Z0)},null}([]);if(typeof console<"u"&&typeof console.warn<"u"){if(F=function(I0){console.warn(I0)},Q.isNode&&process.stderr.isTTY)F=function(I0,B){var h=B?"\x1B[33m":"\x1B[31m";console.warn(h+I0+`\x1B[0m
`)};else if(!Q.isNode&&typeof Error().stack==="string")F=function(I0,B){console.warn("%c"+I0,B?"color: darkorange":"color: red")}}var D0={warnings:w,longStackTraces:!1,cancellation:!1,monitoring:!1};if(N)$.longStackTraces();return{longStackTraces:function(){return D0.longStackTraces},warnings:function(){return D0.warnings},cancellation:function(){return D0.cancellation},monitoring:function(){return D0.monitoring},propagateFromFunction:function(){return a},boundValueFunction:function(){return $0},checkForgottenReturns:U0,setBounds:k1,warn:o,deprecated:R,CapturedTrace:u1,fireDomEvent:P,fireGlobalEvent:T}}});var MF0=E((Le1,FF0)=>{FF0.exports=function($,U){var Y=F4(),z=$.CancellationError,I=Y.errorObj;function Q(X,Z,q){this.promise=X,this.type=Z,this.handler=q,this.called=!1,this.cancelPromise=null}Q.prototype.isFinallyHandler=function(){return this.type===0};function J(X){this.finallyHandler=X}J.prototype._resultCancelled=function(){K(this.finallyHandler)};function K(X,Z){if(X.cancelPromise!=null){if(arguments.length>1)X.cancelPromise._reject(Z);else X.cancelPromise._cancel();return X.cancelPromise=null,!0}return!1}function G(){return W.call(this,this.promise._target()._settledValue())}function H(X){if(K(this,X))return;return I.e=X,I}function W(X){var Z=this.promise,q=this.handler;if(!this.called){this.called=!0;var V=this.isFinallyHandler()?q.call(Z._boundValue()):q.call(Z._boundValue(),X);if(V!==void 0){Z._setReturnedNonUndefined();var F=U(V,Z);if(F instanceof $){if(this.cancelPromise!=null){if(F._isCancelled()){var M=new z("late cancellation observer");return Z._attachExtraTrace(M),I.e=M,I}else if(F.isPending())F._attachCancellationCallback(new J(this))}return F._then(G,H,void 0,this,void 0)}}}if(Z.isRejected())return K(this),I.e=X,I;else return K(this),X}return $.prototype._passThrough=function(X,Z,q,V){if(typeof X!=="function")return this.then();return this._then(q,V,void 0,new Q(this,Z,X),void 0)},$.prototype.lastly=$.prototype.finally=function(X){return this._passThrough(X,0,W,W)},$.prototype.tap=function(X){return this._passThrough(X,1,W)},Q}});var NF0=E((we1,OF0)=>{OF0.exports=function($){var U=F4(),Y=aY().keys,z=U.tryCatch,I=U.errorObj;function Q(J,K,G){return function(H){var W=G._boundValue();$:for(var X=0;X<J.length;++X){var Z=J[X];if(Z===Error||Z!=null&&Z.prototype instanceof Error){if(H instanceof Z)return z(K).call(W,H)}else if(typeof Z==="function"){var q=z(Z).call(W,H);if(q===I)return q;else if(q)return z(K).call(W,H)}else if(U.isObject(H)){var V=Y(Z);for(var F=0;F<V.length;++F){var M=V[F];if(Z[M]!=H[M])continue $}return z(K).call(W,H)}}return $}}return Q}});var Sn=E((Fe1,BF0)=>{var DF0=F4(),yL1=DF0.maybeWrapAsError,kL1=_3(),xL1=kL1.OperationalError,AF0=aY();function fL1($){return $ instanceof Error&&AF0.getPrototypeOf($)===Error.prototype}var uL1=/^(?:name|message|stack|cause)$/;function bL1($){var U;if(fL1($)){U=new xL1($),U.name=$.name,U.message=$.message,U.stack=$.stack;var Y=AF0.keys($);for(var z=0;z<Y.length;++z){var I=Y[z];if(!uL1.test(I))U[I]=$[I]}return U}return DF0.markAsOriginatingFromRejection($),$}function iL1($,U){return function(Y,z){if($===null)return;if(Y){var I=bL1(yL1(Y));$._attachExtraTrace(I),$._reject(I)}else if(!U)$._fulfill(z);else{var Q=arguments.length,J=Array(Math.max(Q-1,0));for(var K=1;K<Q;++K)J[K-1]=arguments[K];$._fulfill(J)}$=null}}BF0.exports=iL1});var TF0=E((Me1,PF0)=>{PF0.exports=function($,U,Y,z,I){var Q=F4(),J=Q.tryCatch;$.method=function(K){if(typeof K!=="function")throw new $.TypeError("expecting a function but got "+Q.classString(K));return function(){var G=new $(U);G._captureStackTrace(),G._pushContext();var H=J(K).apply(this,arguments),W=G._popContext();return I.checkForgottenReturns(H,W,"Promise.method",G),G._resolveFromSyncValue(H),G}},$.attempt=$.try=function(K){if(typeof K!=="function")return z("expecting a function but got "+Q.classString(K));var G=new $(U);G._captureStackTrace(),G._pushContext();var H;if(arguments.length>1){I.deprecated("calling Promise.try with more than 1 argument");var W=arguments[1],X=arguments[2];H=Q.isArray(W)?J(K).apply(X,W):J(K).call(X,W)}else H=J(K)();var Z=G._popContext();return I.checkForgottenReturns(H,Z,"Promise.try",G),G._resolveFromSyncValue(H),G},$.prototype._resolveFromSyncValue=function(K){if(K===Q.errorObj)this._rejectCallback(K.e,!1);else this._resolveCallback(K,!0)}}});var EF0=E((Oe1,jF0)=>{jF0.exports=function($,U,Y,z){var I=!1,Q=function(H,W){this._reject(W)},J=function(H,W){W.promiseRejectionQueued=!0,W.bindingPromise._then(Q,Q,null,this,H)},K=function(H,W){if((this._bitField&50397184)===0)this._resolveCallback(W.target)},G=function(H,W){if(!W.promiseRejectionQueued)this._reject(H)};$.prototype.bind=function(H){if(!I)I=!0,$.prototype._propagateFrom=z.propagateFromFunction(),$.prototype._boundValue=z.boundValueFunction();var W=Y(H),X=new $(U);X._propagateFrom(this,1);var Z=this._target();if(X._setBoundTo(W),W instanceof $){var q={promiseRejectionQueued:!1,promise:X,target:Z,bindingPromise:W};Z._then(U,J,vo Line truncated
See http://goo.gl/MqrFmX
`);return this._settledValue()},U=Y.prototype.error=Y.prototype.reason=function(){if(!this.isRejected())throw TypeError(`cannot get rejection reason of a non-rejected promise
`);return this._settledValue()},z=U.prototype.error=U.prototype.reason=function(){if(!this.isRejected())throw TypeError(`cannot get rejection reason of a non-rejected promise
See http://goo.gl/MqrFmX
`);return this._settledValue()},Q=Y.prototype.isFulfilled=function(){return(this._bitField&33554432)!==0},J=Y.prototype.isRejected=function(){return(this._bitField&16777216)!==0},I=Y.prototype.isPending=function(){return(this._bitField&50397184)===0},K=Y.prototype.isResolved=function(){return(this._bitField&50331648)!==0};Y.prototype.isCancelled=function(){return(this._bitField&8454144)!==0},$.prototype.__isCancelled=function(){return(this._bitField&65536)===65536},$.prototype._isCancelled=function(){return this._target().__isCancelled()},$.prototype.isCancelled=function(){return(this._target()._bitField&8454144)!==0},$.prototype.isPending=function(){return I.call(this._target())},$.prototype.isRejected=function(){return J.call(this._target())},$.prototype.isFulfilled=function(){return Q.call(this._target())},$.prototype.isResolved=function(){return K.call(this._target())},$.prototype.value=function(){return z.call(this._target())},$.prototype.reason=function(){var G=this._target();return G._unsetRejectionIsUnhandled(),U.call(G)},$.prototype._value=function(){return this._settledValue()},$.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue()},$.PromiseInspection=Y}});var PO0=E((dt1,BO0)=>{BO0.exports=function($,Y,z,U,Q,J){var I=O4(),K=I.canEvaluate,G=I.tryCatch,H=I.errorObj,W;if(K){var X=function(N){return Function("value","holder",`
`);return this._settledValue()},I=U.prototype.isFulfilled=function(){return(this._bitField&33554432)!==0},Q=U.prototype.isRejected=function(){return(this._bitField&16777216)!==0},J=U.prototype.isPending=function(){return(this._bitField&50397184)===0},K=U.prototype.isResolved=function(){return(this._bitField&50331648)!==0};U.prototype.isCancelled=function(){return(this._bitField&8454144)!==0},$.prototype.__isCancelled=function(){return(this._bitField&65536)===65536},$.prototype._isCancelled=function(){return this._target().__isCancelled()},$.prototype.isCancelled=function(){return(this._target()._bitField&8454144)!==0},$.prototype.isPending=function(){return J.call(this._target())},$.prototype.isRejected=function(){return Q.call(this._target())},$.prototype.isFulfilled=function(){return I.call(this._target())},$.prototype.isResolved=function(){return K.call(this._target())},$.prototype.value=function(){return Y.call(this._target())},$.prototype.reason=function(){var G=this._target();return G._unsetRejectionIsUnhandled(),z.call(G)},$.prototype._value=function(){return this._settledValue()},$.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue()},$.PromiseInspection=U}});var yF0=E((Be1,gF0)=>{gF0.exports=function($,U,Y,z,I,Q){var J=F4(),K=J.canEvaluate,G=J.tryCatch,H=J.errorObj,W;if(K){var X=function(N){return Function("value","holder",`
'use strict';
holder.pIndex = value;
holder.checkFulfillment(this);
`.replace(/Index/g,N))},Z=function(N){return Function("promise","holder",`
'use strict';
holder.pIndex = promise;
`.replace(/Index/g,N))},q=function(N){var M=Array(N);for(var D=0;D<M.length;++D)M[D]="this.p"+(D+1);var P=M.join(" = ")+" = null;",j=`var promise;
`+M.map(function(b){return`
`.replace(/Index/g,N))},q=function(N){var O=Array(N);for(var D=0;D<O.length;++D)O[D]="this.p"+(D+1);var P=O.join(" = ")+" = null;",T=`var promise;
`+O.map(function(b){return`
promise = `+b+`;
if (promise instanceof Promise) {
promise.cancel();
}
`}).join(`
`),A=M.join(", "),T="Holder$"+N,C=`return function(tryCatch, errorObj, Promise, async) {
`),A=O.join(", "),j="Holder$"+N,C=`return function(tryCatch, errorObj, Promise, async) {
'use strict';
function [TheName](fn) {
[TheProperties]
@@ -199,7 +199,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);if(!(this instanceof T6))r
return [TheName];
}(tryCatch, errorObj, Promise, async);
`;return C=C.replace(/\[TheName\]/g,T).replace(/\[TheTotal\]/g,N).replace(/\[ThePassedArguments\]/g,A).replace(/\[TheProperties\]/g,P).replace(/\[CancellationCode\]/g,j),Function("tryCatch","errorObj","Promise","async",C)(G,H,$,Q)},V=[],F=[],w=[];for(var O=0;O<8;++O)V.push(q(O+1)),F.push(X(O+1)),w.push(Z(O+1));W=function(N){this._reject(N)}}$.join=function(){var N=arguments.length-1,M;if(N>0&&typeof arguments[N]==="function"){if(M=arguments[N],N<=8&&K){var n=new $(U);n._captureStackTrace();var D=V[N-1],P=new D(M),j=F;for(var A=0;A<N;++A){var T=z(arguments[A],n);if(T instanceof $){T=T._target();var C=T._bitField;if((C&50397184)===0)T._then(j[A],W,void 0,n,P),w[A](T,P),P.asyncNeeded=!1;else if((C&33554432)!==0)j[A].call(n,T._value(),P);else if((C&16777216)!==0)n._reject(T._reason());else n._cancel()}else j[A].call(n,T,P)}if(!n._isFateSealed()){if(P.asyncNeeded){var b=J();if(b!==null)P.fn=I.domainBind(b,P.fn)}n._setAsyncGuaranteed(),n._setOnCancel(P)}return n}}var k=arguments.length,S=Array(k);for(var i=0;i<k;++i)S[i]=arguments[i];if(M)S.pop();var n=new Y(S).promise();return M!==void 0?n.spread(M):n}}});var TO0=E((mt1,jO0)=>{jO0.exports=function($,Y,z,U,Q,J){var I=$._getDomain,K=O4(),G=K.tryCatch,H=K.errorObj,W=$._async;function X(q,V,F,w){this.constructor$(q),this._promise._captureStackTrace();var O=I();this._callback=O===null?V:K.domainBind(O,V),this._preservedValues=w===Q?Array(this.length()):null,this._limit=F,this._inFlight=0,this._queue=[],W.invoke(this._asyncInit,this,void 0)}K.inherits(X,Y),X.prototype._asyncInit=function(){this._init$(void 0,-2)},X.prototype._init=function(){},X.prototype._promiseFulfilled=function(q,V){var F=this._values,w=this.length(),O=this._preservedValues,N=this._limit;if(V<0){if(V=V*-1-1,F[V]=q,N>=1){if(this._inFlight--,this._drainQueue(),this._isResolved())return!0}}else{if(N>=1&&this._inFlight>=N)return F[V]=q,this._queue.push(V),!1;if(O!==null)O[V]=q;var M=this._promise,D=this._callback,P=M._boundValue();M._pushContext();var j=G(D).call(P,q,V,w),A=M._popContext();if(J.checkForgottenReturns(j,A,O!==null?"Promise.filter":"Promise.map",M),j===H)return this._reject(j.e),!0;var T=U(j,this._promise);if(T instanceof $){T=T._target();var C=T._bitField;if((C&50397184)===0){if(N>=1)this._inFlight++;return F[V]=T,T._proxy(this,(V+1)*-1),!1}else if((C&33554432)!==0)j=T._value();else if((C&16777216)!==0)return this._reject(T._reason()),!0;else return this._cancel(),!0}F[V]=j}var b=++this._totalResolved;if(b>=w){if(O!==null)this._filter(F,O);else this._resolve(F);return!0}return!1},X.prototype._drainQueue=function(){var q=this._queue,V=this._limit,F=this._values;while(q.length>0&&this._inFlight<V){if(this._isResolved())return;var w=q.pop();this._promiseFulfilled(F[w],w)}},X.prototype._filter=function(q,V){var F=V.length,w=Array(F),O=0;for(var N=0;N<F;++N)if(q[N])w[O++]=V[N];w.length=O,this._resolve(w)},X.prototype.preservedValues=function(){return this._preservedValues};function Z(q,V,F,w){if(typeof V!=="function")return z("expecting a function but got "+K.classString(V));var O=0;if(F!==void 0)if(typeof F==="object"&&F!==null){if(typeof F.concurrency!=="number")return $.reject(TypeError("'concurrency' must be a number but it is "+K.classString(F.concurrency)));O=F.concurrency}else return $.reject(TypeError("options argument must be an object but it is "+K.classString(F)));return O=typeof O==="number"&&isFinite(O)&&O>=1?O:0,new X(q,V,O,w).promise()}$.prototype.map=function(q,V){return Z(this,q,V,null)},$.map=function(q,V,F,w){return Z(q,V,F,w)}}});var CO0=E((lt1,EO0)=>{var Nn=Object.create;if(Nn)bA=Nn(null),iA=Nn(null),bA[" size"]=iA[" size"]=0;var bA,iA;EO0.exports=function($){var Y=O4(),z=Y.canEvaluate,U=Y.isIdentifier,Q,J,I=function(q){return Function("ensureMethod",`
`;return C=C.replace(/\[TheName\]/g,j).replace(/\[TheTotal\]/g,N).replace(/\[ThePassedArguments\]/g,A).replace(/\[TheProperties\]/g,P).replace(/\[CancellationCode\]/g,T),Function("tryCatch","errorObj","Promise","async",C)(G,H,$,I)},V=[],F=[],M=[];for(var w=0;w<8;++w)V.push(q(w+1)),F.push(X(w+1)),M.push(Z(w+1));W=function(N){this._reject(N)}}$.join=function(){var N=arguments.length-1,O;if(N>0&&typeof arguments[N]==="function"){if(O=arguments[N],N<=8&&K){var n=new $(z);n._captureStackTrace();var D=V[N-1],P=new D(O),T=F;for(var A=0;A<N;++A){var j=Y(arguments[A],n);if(j instanceof $){j=j._target();var C=j._bitField;if((C&50397184)===0)j._then(T[A],W,void 0,n,P),M[A](j,P),P.asyncNeeded=!1;else if((C&33554432)!==0)T[A].call(n,j._value(),P);else if((C&16777216)!==0)n._reject(j._reason());else n._cancel()}else T[A].call(n,j,P)}if(!n._isFateSealed()){if(P.asyncNeeded){var b=Q();if(b!==null)P.fn=J.domainBind(b,P.fn)}n._setAsyncGuaranteed(),n._setOnCancel(P)}return n}}var x=arguments.length,g=Array(x);for(var i=0;i<x;++i)g[i]=arguments[i];if(O)g.pop();var n=new U(g).promise();return O!==void 0?n.spread(O):n}}});var xF0=E((Pe1,kF0)=>{kF0.exports=function($,U,Y,z,I,Q){var J=$._getDomain,K=F4(),G=K.tryCatch,H=K.errorObj,W=$._async;function X(q,V,F,M){this.constructor$(q),this._promise._captureStackTrace();var w=J();this._callback=w===null?V:K.domainBind(w,V),this._preservedValues=M===I?Array(this.length()):null,this._limit=F,this._inFlight=0,this._queue=[],W.invoke(this._asyncInit,this,void 0)}K.inherits(X,U),X.prototype._asyncInit=function(){this._init$(void 0,-2)},X.prototype._init=function(){},X.prototype._promiseFulfilled=function(q,V){var F=this._values,M=this.length(),w=this._preservedValues,N=this._limit;if(V<0){if(V=V*-1-1,F[V]=q,N>=1){if(this._inFlight--,this._drainQueue(),this._isResolved())return!0}}else{if(N>=1&&this._inFlight>=N)return F[V]=q,this._queue.push(V),!1;if(w!==null)w[V]=q;var O=this._promise,D=this._callback,P=O._boundValue();O._pushContext();var T=G(D).call(P,q,V,M),A=O._popContext();if(Q.checkForgottenReturns(T,A,w!==null?"Promise.filter":"Promise.map",O),T===H)return this._reject(T.e),!0;var j=z(T,this._promise);if(j instanceof $){j=j._target();var C=j._bitField;if((C&50397184)===0){if(N>=1)this._inFlight++;return F[V]=j,j._proxy(this,(V+1)*-1),!1}else if((C&33554432)!==0)T=j._value();else if((C&16777216)!==0)return this._reject(j._reason()),!0;else return this._cancel(),!0}F[V]=T}var b=++this._totalResolved;if(b>=M){if(w!==null)this._filter(F,w);else this._resolve(F);return!0}return!1},X.prototype._drainQueue=function(){var q=this._queue,V=this._limit,F=this._values;while(q.length>0&&this._inFlight<V){if(this._isResolved())return;var M=q.pop();this._promiseFulfilled(F[M],M)}},X.prototype._filter=function(q,V){var F=V.length,M=Array(F),w=0;for(var N=0;N<F;++N)if(q[N])M[w++]=V[N];M.length=w,this._resolve(M)},X.prototype.preservedValues=function(){return this._preservedValues};function Z(q,V,F,M){if(typeof V!=="function")return Y("expecting a function but got "+K.classString(V));var w=0;if(F!==void 0)if(typeof F==="object"&&F!==null){if(typeof F.concurrency!=="number")return $.reject(TypeError("'concurrency' must be a number but it is "+K.classString(F.concurrency)));w=F.concurrency}else return $.reject(TypeError("options argument must be an object but it is "+K.classString(F)));return w=typeof w==="number"&&isFinite(w)&&w>=1?w:0,new X(q,V,w,M).promise()}$.prototype.map=function(q,V){return Z(this,q,V,null)},$.map=function(q,V,F,M){return Z(q,V,F,M)}}});var uF0=E((Te1,fF0)=>{var gn=Object.create;if(gn)mA=gn(null),lA=gn(null),mA[" size"]=lA[" size"]=0;var mA,lA;fF0.exports=function($){var U=F4(),Y=U.canEvaluate,z=U.isIdentifier,I,Q,J=function(q){return Function("ensureMethod",`
return function(obj) {
'use strict'
var len = this.length;
@@ -216,26 +216,26 @@ See: https://github.com/isaacs/node-glob/issues/167`);if(!(this instanceof T6))r
`.replace(/methodName/g,q))(H)},K=function(q){return Function("obj",`
'use strict';
return obj.propertyName;
`.replace("propertyName",q))},G=function(q,V,F){var w=F[q];if(typeof w!=="function"){if(!U(q))return null;if(w=V(q),F[q]=w,F[" size"]++,F[" size"]>512){var O=Object.keys(F);for(var N=0;N<256;++N)delete F[O[N]];F[" size"]=O.length-256}}return w};Q=function(q){return G(q,I,bA)},J=function(q){return G(q,K,iA)};function H(q,V){var F;if(q!=null)F=q[V];if(typeof F!=="function"){var w="Object "+Y.classString(q)+" has no method '"+Y.toString(V)+"'";throw new $.TypeError(w)}return F}function W(q){var V=this.pop(),F=H(q,V);return F.apply(q,this)}$.prototype.call=function(q){var V=arguments.length,F=Array(Math.max(V-1,0));for(var w=1;w<V;++w)F[w-1]=arguments[w];if(z){var O=Q(q);if(O!==null)return this._then(O,void 0,void 0,F,void 0)}return F.push(q),this._then(W,void 0,void 0,F,void 0)};function X(q){return q[this]}function Z(q){var V=+this;if(V<0)V=Math.max(0,V+q.length);return q[V]}$.prototype.get=function(q){var V=typeof q==="number",F;if(!V)if(z){var w=J(q);F=w!==null?w:X}else F=X;else F=Z;return this._then(F,void 0,void 0,q,void 0)}}});var _O0=E((ot1,RO0)=>{RO0.exports=function($,Y,z,U,Q,J){var I=O4(),K=E3().TypeError,G=O4().inherits,H=I.errorObj,W=I.tryCatch,X={};function Z(M){setTimeout(function(){throw M},0)}function q(M){var D=z(M);if(D!==M&&typeof M._isDisposable==="function"&&typeof M._getDisposer==="function"&&M._isDisposable())D._setDisposable(M._getDisposer());return D}function V(M,D){var P=0,j=M.length,A=new $(Q);function T(){if(P>=j)return A._fulfill();var C=q(M[P++]);if(C instanceof $&&C._isDisposable()){try{C=z(C._getDisposer().tryDispose(D),M.promise)}catch(b){return Z(b)}if(C instanceof $)return C._then(T,Z,null,null,null)}T()}return T(),A}function F(M,D,P){this._data=M,this._promise=D,this._context=P}F.prototype.data=function(){return this._data},F.prototype.promise=function(){return this._promise},F.prototype.resource=function(){if(this.promise().isFulfilled())return this.promise().value();return X},F.prototype.tryDispose=function(M){var D=this.resource(),P=this._context;if(P!==void 0)P._pushContext();var j=D!==X?this.doDispose(D,M):null;if(P!==void 0)P._popContext();return this._promise._unsetDisposable(),this._data=null,j},F.isDisposer=function(M){return M!=null&&typeof M.resource==="function"&&typeof M.tryDispose==="function"};function w(M,D,P){this.constructor$(M,D,P)}G(w,F),w.prototype.doDispose=function(M,D){var P=this.data();return P.call(M,M,D)};function O(M){if(F.isDisposer(M))return this.resources[this.index]._setDisposable(M),M.promise();return M}function N(M){this.length=M,this.promise=null,this[M-1]=null}N.prototype._resultCancelled=function(){var M=this.length;for(var D=0;D<M;++D){var P=this[D];if(P instanceof $)P.cancel()}},$.using=function(){var M=arguments.length;if(M<2)return Y("you must pass at least 2 arguments to Promise.using");var D=arguments[M-1];if(typeof D!=="function")return Y("expecting a function but got "+I.classString(D));var P,j=!0;if(M===2&&Array.isArray(arguments[0]))P=arguments[0],M=P.length,j=!1;else P=arguments,M--;var A=new N(M);for(var T=0;T<M;++T){var C=P[T];if(F.isDisposer(C)){var b=C;C=C.promise(),C._setDisposable(b)}else{var k=z(C);if(k instanceof $)C=k._then(O,null,null,{resources:A,index:T},void 0)}A[T]=C}var S=Array(A.length);for(var T=0;T<S.length;++T)S[T]=$.resolve(A[T]).reflect();var i=$.all(S).then(function(U0){for(var x=0;x<U0.length;++x){var d=U0[x];if(d.isRejected())return H.e=d.error(),H;else if(!d.isFulfilled()){i.cancel();return}U0[x]=d.value()}n._pushContext(),D=W(D);var t=j?D.apply(void 0,U0):D(U0),e=n._popContext();return J.checkForgottenReturns(t,e,"Promise.using",n),t}),n=i.lastly(function(){var U0=new $.PromiseInspection(i);return V(A,U0)});return A.promise=n,n._setOnCancel(A),n},$.prototype._setDisposable=function(M){this._bitField=this._bitField|131072,this._disposer=M},$.prototype._isDisposable=function(){return(this._bitField&131072)>0},$.prototype._getDisposer=function(){return this._disposer},$.prototype._unsetDisposable=function(){this._bitField=this._bitField&-131073,this._disposer=void 0},$.prototype.disposer=function(M){if(typeof M==="function")return new w(M,this,U());throw new K}}});var hO0=E((rt1,vO0)=>{vO0.exports=function($,Y,z){var U=O4(),Q=$.TimeoutError;function J(X){this.handle=X}J.prototype._resultCancelled=function(){clearTimeout(this.handle)};var I=function(X){return K(+this).thenReturn(X)},K=$.delay=function(X,Z){var q,V;if(Z!==void 0){if(q=$.resolve(Z)._then(I,null,null,X,void 0),z.cancellation()&&Z instanceof $)q._setOnCancel(Z)}else{if(q=new $(Y),V=setTimeout(function(){q._fulfill()},+X),z.cancellation())q._setOnCancel(new J(V));q._captureStackTrace()}return q._setAsyncGuaranteed(),q};$.prototype.delay=function(X){return K(X,this)};var G=function(X,Z,q){var V;if(typeof Z!=="string")if(Z instanceof Error)V=Z;else V=new Q("operation timed out");else V=new Q(Z);if(U.markAsOriginatingFromRejection(V),X._attachExtraTrace(V),X._reject(V),q!=null)q.cancel()};function H(X){return clearTimeout(this.handle),X}f Line truncated
`.replace("propertyName",q))},G=function(q,V,F){var M=F[q];if(typeof M!=="function"){if(!z(q))return null;if(M=V(q),F[q]=M,F[" size"]++,F[" size"]>512){var w=Object.keys(F);for(var N=0;N<256;++N)delete F[w[N]];F[" size"]=w.length-256}}return M};I=function(q){return G(q,J,mA)},Q=function(q){return G(q,K,lA)};function H(q,V){var F;if(q!=null)F=q[V];if(typeof F!=="function"){var M="Object "+U.classString(q)+" has no method '"+U.toString(V)+"'";throw new $.TypeError(M)}return F}function W(q){var V=this.pop(),F=H(q,V);return F.apply(q,this)}$.prototype.call=function(q){var V=arguments.length,F=Array(Math.max(V-1,0));for(var M=1;M<V;++M)F[M-1]=arguments[M];if(Y){var w=I(q);if(w!==null)return this._then(w,void 0,void 0,F,void 0)}return F.push(q),this._then(W,void 0,void 0,F,void 0)};function X(q){return q[this]}function Z(q){var V=+this;if(V<0)V=Math.max(0,V+q.length);return q[V]}$.prototype.get=function(q){var V=typeof q==="number",F;if(!V)if(Y){var M=Q(q);F=M!==null?M:X}else F=X;else F=Z;return this._then(F,void 0,void 0,q,void 0)}}});var iF0=E((je1,bF0)=>{bF0.exports=function($,U,Y,z,I,Q){var J=F4(),K=_3().TypeError,G=F4().inherits,H=J.errorObj,W=J.tryCatch,X={};function Z(O){setTimeout(function(){throw O},0)}function q(O){var D=Y(O);if(D!==O&&typeof O._isDisposable==="function"&&typeof O._getDisposer==="function"&&O._isDisposable())D._setDisposable(O._getDisposer());return D}function V(O,D){var P=0,T=O.length,A=new $(I);function j(){if(P>=T)return A._fulfill();var C=q(O[P++]);if(C instanceof $&&C._isDisposable()){try{C=Y(C._getDisposer().tryDispose(D),O.promise)}catch(b){return Z(b)}if(C instanceof $)return C._then(j,Z,null,null,null)}j()}return j(),A}function F(O,D,P){this._data=O,this._promise=D,this._context=P}F.prototype.data=function(){return this._data},F.prototype.promise=function(){return this._promise},F.prototype.resource=function(){if(this.promise().isFulfilled())return this.promise().value();return X},F.prototype.tryDispose=function(O){var D=this.resource(),P=this._context;if(P!==void 0)P._pushContext();var T=D!==X?this.doDispose(D,O):null;if(P!==void 0)P._popContext();return this._promise._unsetDisposable(),this._data=null,T},F.isDisposer=function(O){return O!=null&&typeof O.resource==="function"&&typeof O.tryDispose==="function"};function M(O,D,P){this.constructor$(O,D,P)}G(M,F),M.prototype.doDispose=function(O,D){var P=this.data();return P.call(O,O,D)};function w(O){if(F.isDisposer(O))return this.resources[this.index]._setDisposable(O),O.promise();return O}function N(O){this.length=O,this.promise=null,this[O-1]=null}N.prototype._resultCancelled=function(){var O=this.length;for(var D=0;D<O;++D){var P=this[D];if(P instanceof $)P.cancel()}},$.using=function(){var O=arguments.length;if(O<2)return U("you must pass at least 2 arguments to Promise.using");var D=arguments[O-1];if(typeof D!=="function")return U("expecting a function but got "+J.classString(D));var P,T=!0;if(O===2&&Array.isArray(arguments[0]))P=arguments[0],O=P.length,T=!1;else P=arguments,O--;var A=new N(O);for(var j=0;j<O;++j){var C=P[j];if(F.isDisposer(C)){var b=C;C=C.promise(),C._setDisposable(b)}else{var x=Y(C);if(x instanceof $)C=x._then(w,null,null,{resources:A,index:j},void 0)}A[j]=C}var g=Array(A.length);for(var j=0;j<g.length;++j)g[j]=$.resolve(A[j]).reflect();var i=$.all(g).then(function(z0){for(var k=0;k<z0.length;++k){var p=z0[k];if(p.isRejected())return H.e=p.error(),H;else if(!p.isFulfilled()){i.cancel();return}z0[k]=p.value()}n._pushContext(),D=W(D);var a=T?D.apply(void 0,z0):D(z0),$0=n._popContext();return Q.checkForgottenReturns(a,$0,"Promise.using",n),a}),n=i.lastly(function(){var z0=new $.PromiseInspection(i);return V(A,z0)});return A.promise=n,n._setOnCancel(A),n},$.prototype._setDisposable=function(O){this._bitField=this._bitField|131072,this._disposer=O},$.prototype._isDisposable=function(){return(this._bitField&131072)>0},$.prototype._getDisposer=function(){return this._disposer},$.prototype._unsetDisposable=function(){this._bitField=this._bitField&-131073,this._disposer=void 0},$.prototype.disposer=function(O){if(typeof O==="function")return new M(O,this,z());throw new K}}});var cF0=E((Ee1,nF0)=>{nF0.exports=function($,U,Y){var z=F4(),I=$.TimeoutError;function Q(X){this.handle=X}Q.prototype._resultCancelled=function(){clearTimeout(this.handle)};var J=function(X){return K(+this).thenReturn(X)},K=$.delay=function(X,Z){var q,V;if(Z!==void 0){if(q=$.resolve(Z)._then(J,null,null,X,void 0),Y.cancellation()&&Z instanceof $)q._setOnCancel(Z)}else{if(q=new $(U),V=setTimeout(function(){q._fulfill()},+X),Y.cancellation())q._setOnCancel(new Q(V));q._captureStackTrace()}return q._setAsyncGuaranteed(),q};$.prototype.delay=function(X){return K(X,this)};var G=function(X,Z,q){var V;if(typeof Z!=="string")if(Z instanceof Error)V=Z;else V=new I("operation timed out");else V=new I(Z);if(z.markAsOriginatingFromRejection(V),X._attachExtraTrace(V),X._reject(V),q!=null)q.cancel()};function H(X){return clearTimeout(this.handle),X Line truncated
See http://goo.gl/MqrFmX
`.replace("%s",w)+`From coroutine:
`.replace("%s",M)+`From coroutine:
`+this._stack.split(`
`).slice(1,-7).join(`
`)));return}}O=O._target();var N=O._bitField;if((N&50397184)===0)this._yieldedPromise=O,O._proxy(this,null);else if((N&33554432)!==0)$._async.invoke(this._promiseFulfilled,this,O._value());else if((N&16777216)!==0)$._async.invoke(this._promiseRejected,this,O._reason());else this._promiseCancelled()}},$.coroutine=function(V,F){if(typeof V!=="function")throw new K(`generatorFunction must be a function
`)));return}}w=w._target();var N=w._bitField;if((N&50397184)===0)this._yieldedPromise=w,w._proxy(this,null);else if((N&33554432)!==0)$._async.invoke(this._promiseFulfilled,this,w._value());else if((N&16777216)!==0)$._async.invoke(this._promiseRejected,this,w._reason());else this._promiseCancelled()}},$.coroutine=function(V,F){if(typeof V!=="function")throw new K(`generatorFunction must be a function
See http://goo.gl/MqrFmX
`);var w=Object(F).yieldHandler,O=q,N=Error().stack;return function(){var M=V.apply(this,arguments),D=new O(void 0,void 0,w,N),P=D.promise();return D._generator=M,D._promiseFulfilled(void 0),P}},$.coroutine.addYieldHandler=function(V){if(typeof V!=="function")throw new K("expecting a function but got "+G.classString(V));X.push(V)},$.spawn=function(V){if(J.deprecated("Promise.spawn()","Promise.coroutine()"),typeof V!=="function")return Y(`generatorFunction must be a function
`);var M=Object(F).yieldHandler,w=q,N=Error().stack;return function(){var O=V.apply(this,arguments),D=new w(void 0,void 0,M,N),P=D.promise();return D._generator=O,D._promiseFulfilled(void 0),P}},$.coroutine.addYieldHandler=function(V){if(typeof V!=="function")throw new K("expecting a function but got "+G.classString(V));X.push(V)},$.spawn=function(V){if(Q.deprecated("Promise.spawn()","Promise.coroutine()"),typeof V!=="function")return U(`generatorFunction must be a function
See http://goo.gl/MqrFmX
`);var F=new q(V,this),w=F.promise();return F._run($.spawn),w}}});var kO0=E((at1,yO0)=>{yO0.exports=function($){var Y=O4(),z=$._async,U=Y.tryCatch,Q=Y.errorObj;function J(G,H){var W=this;if(!Y.isArray(G))return I.call(W,G,H);var X=U(H).apply(W._boundValue(),[null].concat(G));if(X===Q)z.throwLater(X.e)}function I(G,H){var W=this,X=W._boundValue(),Z=G===void 0?U(H).call(X,null):U(H).call(X,null,G);if(Z===Q)z.throwLater(Z.e)}function K(G,H){var W=this;if(!G){var X=Error(G+"");X.cause=G,G=X}var Z=U(H).call(W._boundValue(),G);if(Z===Q)z.throwLater(Z.e)}$.prototype.asCallback=$.prototype.nodeify=function(G,H){if(typeof G=="function"){var W=I;if(H!==void 0&&Object(H).spread)W=J;this._then(W,K,void 0,this,G)}return this}}});var fO0=E((tt1,xO0)=>{xO0.exports=function($,Y){var z={},U=O4(),Q=Mn(),J=U.withAppended,I=U.maybeWrapAsError,K=U.canEvaluate,G=E3().TypeError,H="Async",W={__isPromisified__:!0},X=["arity","length","name","arguments","caller","callee","prototype","__isPromisified__"],Z=new RegExp("^(?:"+X.join("|")+")$"),q=function(i){return U.isIdentifier(i)&&i.charAt(0)!=="_"&&i!=="constructor"};function V(i){return!Z.test(i)}function F(i){try{return i.__isPromisified__===!0}catch(n){return!1}}function w(i,n,U0){var x=U.getDataPropertyOrDefault(i,n+U0,W);return x?F(x):!1}function O(i,n,U0){for(var x=0;x<i.length;x+=2){var d=i[x];if(U0.test(d)){var t=d.replace(U0,"");for(var e=0;e<i.length;e+=2)if(i[e]===t)throw new G(`Cannot promisify an API that has normal methods with '%s'-suffix
`);var F=new q(V,this),M=F.promise();return F._run($.spawn),M}}});var lF0=E((Re1,mF0)=>{mF0.exports=function($){var U=F4(),Y=$._async,z=U.tryCatch,I=U.errorObj;function Q(G,H){var W=this;if(!U.isArray(G))return J.call(W,G,H);var X=z(H).apply(W._boundValue(),[null].concat(G));if(X===I)Y.throwLater(X.e)}function J(G,H){var W=this,X=W._boundValue(),Z=G===void 0?z(H).call(X,null):z(H).call(X,null,G);if(Z===I)Y.throwLater(Z.e)}function K(G,H){var W=this;if(!G){var X=Error(G+"");X.cause=G,G=X}var Z=z(H).call(W._boundValue(),G);if(Z===I)Y.throwLater(Z.e)}$.prototype.asCallback=$.prototype.nodeify=function(G,H){if(typeof G=="function"){var W=J;if(H!==void 0&&Object(H).spread)W=Q;this._then(W,K,void 0,this,G)}return this}}});var rF0=E((_e1,oF0)=>{oF0.exports=function($,U){var Y={},z=F4(),I=Sn(),Q=z.withAppended,J=z.maybeWrapAsError,K=z.canEvaluate,G=_3().TypeError,H="Async",W={__isPromisified__:!0},X=["arity","length","name","arguments","caller","callee","prototype","__isPromisified__"],Z=new RegExp("^(?:"+X.join("|")+")$"),q=function(i){return z.isIdentifier(i)&&i.charAt(0)!=="_"&&i!=="constructor"};function V(i){return!Z.test(i)}function F(i){try{return i.__isPromisified__===!0}catch(n){return!1}}function M(i,n,z0){var k=z.getDataPropertyOrDefault(i,n+z0,W);return k?F(k):!1}function w(i,n,z0){for(var k=0;k<i.length;k+=2){var p=i[k];if(z0.test(p)){var a=p.replace(z0,"");for(var $0=0;$0<i.length;$0+=2)if(i[$0]===a)throw new G(`Cannot promisify an API that has normal methods with '%s'-suffix
See http://goo.gl/MqrFmX
`.replace("%s",n))}}}function N(i,n,U0,x){var d=U.inheritedDataKeys(i),t=[];for(var e=0;e<d.length;++e){var g=d[e],p=i[g],Y0=x===q?!0:q(g,p,i);if(typeof p==="function"&&!F(p)&&!w(i,g,n)&&x(g,p,i,Y0))t.push(g,p)}return O(t,n,U0),t}var M=function(i){return i.replace(/([$])/,"\\$")},D,P=function(i){var n=[i],U0=Math.max(0,i-1-3);for(var x=i-1;x>=U0;--x)n.push(x);for(var x=i+1;x<=3;++x)n.push(x);return n},j=function(i){return U.filledRange(i,"_arg","")},A=function(i){return U.filledRange(Math.max(i,3),"_arg","")},T=function(i){if(typeof i.length==="number")return Math.max(Math.min(i.length,1024),0);return 0};D=function(i,n,U0,x,d,t){var e=Math.max(0,T(x)-1),g=P(e),p=typeof i==="string"||n===z;function Y0(N0){var T0=j(N0).join(", "),_0=N0>0?", ":"",G0;if(p)G0=`ret = callback.call(this, {{args}}, nodeback); break;
`;else G0=n===void 0?`ret = callback({{args}}, nodeback); break;
`.replace("%s",n))}}}function N(i,n,z0,k){var p=z.inheritedDataKeys(i),a=[];for(var $0=0;$0<p.length;++$0){var y=p[$0],d=i[y],U0=k===q?!0:q(y,d,i);if(typeof d==="function"&&!F(d)&&!M(i,y,n)&&k(y,d,i,U0))a.push(y,d)}return w(a,n,z0),a}var O=function(i){return i.replace(/([$])/,"\\$")},D,P=function(i){var n=[i],z0=Math.max(0,i-1-3);for(var k=i-1;k>=z0;--k)n.push(k);for(var k=i+1;k<=3;++k)n.push(k);return n},T=function(i){return z.filledRange(i,"_arg","")},A=function(i){return z.filledRange(Math.max(i,3),"_arg","")},j=function(i){if(typeof i.length==="number")return Math.max(Math.min(i.length,1024),0);return 0};D=function(i,n,z0,k,p,a){var $0=Math.max(0,j(k)-1),y=P($0),d=typeof i==="string"||n===Y;function U0(O0){var T0=T(O0).join(", "),y0=O0>0?", ":"",v0;if(d)v0=`ret = callback.call(this, {{args}}, nodeback); break;
`;else v0=n===void 0?`ret = callback({{args}}, nodeback); break;
`:`ret = callback.call(receiver, {{args}}, nodeback); break;
`;return G0.replace("{{args}}",T0).replace(", ",_0)}function y(){var N0="";for(var T0=0;T0<g.length;++T0)N0+="case "+g[T0]+":"+Y0(g[T0]);return N0+=`
`;return v0.replace("{{args}}",T0).replace(", ",y0)}function R(){var O0="";for(var T0=0;T0<y.length;++T0)O0+="case "+y[T0]+":"+U0(y[T0]);return O0+=`
default:
var args = new Array(len + 1);
var i = 0;
@@ -245,15 +245,15 @@ See: https://github.com/isaacs/node-glob/issues/167`);if(!(this instanceof T6))r
args[i] = nodeback;
[CodeForCall]
break;
`.replace("[CodeForCall]",p?`ret = callback.apply(this, args);
`.replace("[CodeForCall]",d?`ret = callback.apply(this, args);
`:`ret = callback.apply(receiver, args);
`),N0}var r=typeof i==="string"?"this != null ? this['"+i+"'] : fn":"fn",$0=`'use strict';
`),O0}var o=typeof i==="string"?"this != null ? this['"+i+"'] : fn":"fn",e=`'use strict';
var ret = function (Parameters) {
'use strict';
var len = arguments.length;
var promise = new Promise(INTERNAL);
promise._captureStackTrace();
var nodeback = nodebackForPromise(promise, `+t+`);
var nodeback = nodebackForPromise(promise, `+a+`);
var ret;
var callback = tryCatch([GetFunctionCode]);
switch(len) {
@@ -267,25 +267,25 @@ See: https://github.com/isaacs/node-glob/issues/167`);if(!(this instanceof T6))r
};
notEnumerableProp(ret, '__isPromisified__', true);
return ret;
`.replace("[CodeForSwitchCase]",y()).replace("[GetFunctionCode]",r);return $0=$0.replace("Parameters",A(e)),Function("Promise","fn","receiver","withAppended","maybeWrapAsError","nodebackForPromise","tryCatch","errorObj","notEnumerableProp","INTERNAL",$0)($,x,n,J,I,Q,U.tryCatch,U.errorObj,U.notEnumerableProp,Y)};function C(i,n,U0,x,d,t){var e=function(){return this}(),g=i;if(typeof g==="string")i=x;function p(){var Y0=n;if(n===z)Y0=this;var y=new $(Y);y._captureStackTrace();var r=typeof g==="string"&&this!==e?this[g]:i,$0=Q(y,t);try{r.apply(Y0,J(arguments,$0))}catch(N0){y._rejectCallback(I(N0),!0,!0)}if(!y._isFateSealed())y._setAsyncGuaranteed();return y}return U.notEnumerableProp(p,"__isPromisified__",!0),p}var b=K?D:C;function k(i,n,U0,x,d){var t=new RegExp(M(n)+"$"),e=N(i,n,t,U0);for(var g=0,p=e.length;g<p;g+=2){var Y0=e[g],y=e[g+1],r=Y0+n;if(x===b)i[r]=b(Y0,z,Y0,y,n,d);else{var $0=x(y,function(){return b(Y0,z,Y0,y,n,d)});U.notEnumerableProp($0,"__isPromisified__",!0),i[r]=$0}}return U.toFastProperties(i),i}function S(i,n,U0){return b(i,n,void 0,i,null,U0)}$.promisify=function(i,n){if(typeof i!=="function")throw new G("expecting a function but got "+U.classString(i));if(F(i))return i;n=Object(n);var U0=n.context===void 0?z:n.context,x=!!n.multiArgs,d=S(i,U0,x);return U.copyDescriptors(i,d,V),d},$.promisifyAll=function(i,n){if(typeof i!=="function"&&typeof i!=="object")throw new G(`the target of promisifyAll must be an object or a function
`.replace("[CodeForSwitchCase]",R()).replace("[GetFunctionCode]",o);return e=e.replace("Parameters",A($0)),Function("Promise","fn","receiver","withAppended","maybeWrapAsError","nodebackForPromise","tryCatch","errorObj","notEnumerableProp","INTERNAL",e)($,k,n,Q,J,I,z.tryCatch,z.errorObj,z.notEnumerableProp,U)};function C(i,n,z0,k,p,a){var $0=function(){return this}(),y=i;if(typeof y==="string")i=k;function d(){var U0=n;if(n===Y)U0=this;var R=new $(U);R._captureStackTrace();var o=typeof y==="string"&&this!==$0?this[y]:i,e=I(R,a);try{o.apply(U0,Q(arguments,e))}catch(O0){R._rejectCallback(J(O0),!0,!0)}if(!R._isFateSealed())R._setAsyncGuaranteed();return R}return z.notEnumerableProp(d,"__isPromisified__",!0),d}var b=K?D:C;function x(i,n,z0,k,p){var a=new RegExp(O(n)+"$"),$0=N(i,n,a,z0);for(var y=0,d=$0.length;y<d;y+=2){var U0=$0[y],R=$0[y+1],o=U0+n;if(k===b)i[o]=b(U0,Y,U0,R,n,p);else{var e=k(R,function(){return b(U0,Y,U0,R,n,p)});z.notEnumerableProp(e,"__isPromisified__",!0),i[o]=e}}return z.toFastProperties(i),i}function g(i,n,z0){return b(i,n,void 0,i,null,z0)}$.promisify=function(i,n){if(typeof i!=="function")throw new G("expecting a function but got "+z.classString(i));if(F(i))return i;n=Object(n);var z0=n.context===void 0?Y:n.context,k=!!n.multiArgs,p=g(i,z0,k);return z.copyDescriptors(i,p,V),p},$.promisifyAll=function(i,n){if(typeof i!=="function"&&typeof i!=="object")throw new G(`the target of promisifyAll must be an object or a function
See http://goo.gl/MqrFmX
`);n=Object(n);var U0=!!n.multiArgs,x=n.suffix;if(typeof x!=="string")x=H;var d=n.filter;if(typeof d!=="function")d=q;var t=n.promisifier;if(typeof t!=="function")t=b;if(!U.isIdentifier(x))throw RangeError(`suffix must be a valid identifier
`);n=Object(n);var z0=!!n.multiArgs,k=n.suffix;if(typeof k!=="string")k=H;var p=n.filter;if(typeof p!=="function")p=q;var a=n.promisifier;if(typeof a!=="function")a=b;if(!z.isIdentifier(k))throw RangeError(`suffix must be a valid identifier
See http://goo.gl/MqrFmX
`);var e=U.inheritedDataKeys(i);for(var g=0;g<e.length;++g){var p=i[e[g]];if(e[g]!=="constructor"&&U.isClass(p))k(p.prototype,x,d,t,U0),k(p,x,d,t,U0)}return k(i,x,d,t,U0)}}});var bO0=E((et1,uO0)=>{uO0.exports=function($,Y,z,U){var Q=O4(),J=Q.isObject,I=az(),K;if(typeof Map==="function")K=Map;var G=function(){var Z=0,q=0;function V(F,w){this[Z]=F,this[Z+q]=w,Z++}return function(w){q=w.size,Z=0;var O=Array(w.size*2);return w.forEach(V,O),O}}(),H=function(Z){var q=new K,V=Z.length/2|0;for(var F=0;F<V;++F){var w=Z[V+F],O=Z[F];q.set(w,O)}return q};function W(Z){var q=!1,V;if(K!==void 0&&Z instanceof K)V=G(Z),q=!0;else{var F=I.keys(Z),w=F.length;V=Array(w*2);for(var O=0;O<w;++O){var N=F[O];V[O]=Z[N],V[O+w]=N}}this.constructor$(V),this._isMap=q,this._init$(void 0,-3)}Q.inherits(W,Y),W.prototype._init=function(){},W.prototype._promiseFulfilled=function(Z,q){this._values[q]=Z;var V=++this._totalResolved;if(V>=this._length){var F;if(this._isMap)F=H(this._values);else{F={};var w=this.length();for(var O=0,N=this.length();O<N;++O)F[this._values[O+w]]=this._values[O]}return this._resolve(F),!0}return!1},W.prototype.shouldCopyValues=function(){return!1},W.prototype.getActualLength=function(Z){return Z>>1};function X(Z){var q,V=z(Z);if(!J(V))return U(`cannot await properties of a non-object
`);var $0=z.inheritedDataKeys(i);for(var y=0;y<$0.length;++y){var d=i[$0[y]];if($0[y]!=="constructor"&&z.isClass(d))x(d.prototype,k,p,a,z0),x(d,k,p,a,z0)}return x(i,k,p,a,z0)}}});var aF0=E((ve1,sF0)=>{sF0.exports=function($,U,Y,z){var I=F4(),Q=I.isObject,J=aY(),K;if(typeof Map==="function")K=Map;var G=function(){var Z=0,q=0;function V(F,M){this[Z]=F,this[Z+q]=M,Z++}return function(M){q=M.size,Z=0;var w=Array(M.size*2);return M.forEach(V,w),w}}(),H=function(Z){var q=new K,V=Z.length/2|0;for(var F=0;F<V;++F){var M=Z[V+F],w=Z[F];q.set(M,w)}return q};function W(Z){var q=!1,V;if(K!==void 0&&Z instanceof K)V=G(Z),q=!0;else{var F=J.keys(Z),M=F.length;V=Array(M*2);for(var w=0;w<M;++w){var N=F[w];V[w]=Z[N],V[w+M]=N}}this.constructor$(V),this._isMap=q,this._init$(void 0,-3)}I.inherits(W,U),W.prototype._init=function(){},W.prototype._promiseFulfilled=function(Z,q){this._values[q]=Z;var V=++this._totalResolved;if(V>=this._length){var F;if(this._isMap)F=H(this._values);else{F={};var M=this.length();for(var w=0,N=this.length();w<N;++w)F[this._values[w+M]]=this._values[w]}return this._resolve(F),!0}return!1},W.prototype.shouldCopyValues=function(){return!1},W.prototype.getActualLength=function(Z){return Z>>1};function X(Z){var q,V=Y(Z);if(!Q(V))return z(`cannot await properties of a non-object
See http://goo.gl/MqrFmX
`);else if(V instanceof $)q=V._then($.props,void 0,void 0,void 0,void 0);else q=new W(V).promise();if(V instanceof $)q._propagateFrom(V,2);return q}$.prototype.props=function(){return X(this)},$.props=function(Z){return X(Z)}}});var nO0=E(($e1,iO0)=>{iO0.exports=function($,Y,z,U){var Q=O4(),J=function(K){return K.then(function(G){return I(G,K)})};function I(K,G){var H=z(K);if(H instanceof $)return J(H);else if(K=Q.asArray(K),K===null)return U("expecting an array or an iterable object but got "+Q.classString(K));var W=new $(Y);if(G!==void 0)W._propagateFrom(G,3);var{_fulfill:X,_reject:Z}=W;for(var q=0,V=K.length;q<V;++q){var F=K[q];if(F===void 0&&!(q in K))continue;$.cast(F)._then(X,Z,void 0,W,null)}return W}$.race=function(K){return I(K,void 0)},$.prototype.race=function(){return I(this,void 0)}}});var pO0=E((Ye1,cO0)=>{cO0.exports=function($,Y,z,U,Q,J){var I=$._getDomain,K=O4(),G=K.tryCatch;function H(V,F,w,O){this.constructor$(V);var N=I();if(this._fn=N===null?F:K.domainBind(N,F),w!==void 0)w=$.resolve(w),w._attachCancellationCallback(this);if(this._initialValue=w,this._currentCancellable=null,O===Q)this._eachValues=Array(this._length);else if(O===0)this._eachValues=null;else this._eachValues=void 0;this._promise._captureStackTrace(),this._init$(void 0,-5)}K.inherits(H,Y),H.prototype._gotAccum=function(V){if(this._eachValues!==void 0&&this._eachValues!==null&&V!==Q)this._eachValues.push(V)},H.prototype._eachComplete=function(V){if(this._eachValues!==null)this._eachValues.push(V);return this._eachValues},H.prototype._init=function(){},H.prototype._resolveEmptyArray=function(){this._resolve(this._eachValues!==void 0?this._eachValues:this._initialValue)},H.prototype.shouldCopyValues=function(){return!1},H.prototype._resolve=function(V){this._promise._resolveCallback(V),this._values=null},H.prototype._resultCancelled=function(V){if(V===this._initialValue)return this._cancel();if(this._isResolved())return;if(this._resultCancelled$(),this._currentCancellable instanceof $)this._currentCancellable.cancel();if(this._initialValue instanceof $)this._initialValue.cancel()},H.prototype._iterate=function(V){this._values=V;var F,w,O=V.length;if(this._initialValue!==void 0)F=this._initialValue,w=0;else F=$.resolve(V[0]),w=1;if(this._currentCancellable=F,!F.isRejected())for(;w<O;++w){var N={accum:null,value:V[w],index:w,length:O,array:this};F=F._then(Z,void 0,void 0,N,void 0)}if(this._eachValues!==void 0)F=F._then(this._eachComplete,void 0,void 0,this,void 0);F._then(W,W,void 0,F,this)},$.prototype.reduce=function(V,F){return X(this,V,F,null)},$.reduce=function(V,F,w,O){return X(V,F,w,O)};function W(V,F){if(this.isFulfilled())F._resolve(V);else F._reject(V)}function X(V,F,w,O){if(typeof F!=="function")return z("expecting a function but got "+K.classString(F));var N=new H(V,F,w,O);return N.promise()}function Z(V){this.accum=V,this.array._gotAccum(V);var F=U(this.value,this.array._promise);if(F instanceof $)return this.array._currentCancellable=F,F._then(q,void 0,void 0,this,void 0);else return q.call(this,F)}function q(V){var F=this.array,w=F._promise,O=G(F._fn);w._pushContext();var N;if(F._eachValues!==void 0)N=O.call(w._boundValue(),V,this.index,this.length);else N=O.call(w._boundValue(),this.accum,V,this.index,this.length);if(N instanceof $)F._currentCancellable=N;var M=w._popContext();return J.checkForgottenReturns(N,M,F._eachValues!==void 0?"Promise.each":"Promise.reduce",w),N}}});var mO0=E((ze1,dO0)=>{dO0.exports=function($,Y,z){var U=$.PromiseInspection,Q=O4();function J(I){this.constructor$(I)}Q.inherits(J,Y),J.prototype._promiseResolved=function(I,K){this._values[I]=K;var G=++this._totalResolved;if(G>=this._length)return this._resolve(this._values),!0;return!1},J.prototype._promiseFulfilled=function(I,K){var G=new U;return G._bitField=33554432,G._settledValueField=I,this._promiseResolved(K,G)},J.prototype._promiseRejected=function(I,K){var G=new U;return G._bitField=16777216,G._settledValueField=I,this._promiseResolved(K,G)},$.settle=function(I){return z.deprecated(".settle()",".reflect()"),new J(I).promise()},$.prototype.settle=function(){return $.settle(this)}}});var oO0=E((Ue1,lO0)=>{lO0.exports=function($,Y,z){var U=O4(),Q=E3().RangeError,J=E3().AggregateError,I=U.isArray,K={};function G(W){this.constructor$(W),this._howMany=0,this._unwrap=!1,this._initialized=!1}U.inherits(G,Y),G.prototype._init=function(){if(!this._initialized)return;if(this._howMany===0){this._resolve([]);return}this._init$(void 0,-5);var W=I(this._values);if(!this._isResolved()&&W&&this._howMany>this._canPossiblyFulfill())this._reject(this._getRangeError(this.length()))},G.prototype.init=function(){this._initialized=!0,this._init()},G.prototype.setUnwrap=function(){this._unwrap=!0},G.prototype.howMany=function(){return this._howMany},G.prototype.setHowMany=function(W){this._howMany=W},G.prototype._promiseFulfilled=function(W){if(this._addFulfilled(W),this._fulfilled()===this.howMany()){if(this._values.length=this.howMany(),this.howMany()= Line truncated
`);else if(V instanceof $)q=V._then($.props,void 0,void 0,void 0,void 0);else q=new W(V).promise();if(V instanceof $)q._propagateFrom(V,2);return q}$.prototype.props=function(){return X(this)},$.props=function(Z){return X(Z)}}});var eF0=E((he1,tF0)=>{tF0.exports=function($,U,Y,z){var I=F4(),Q=function(K){return K.then(function(G){return J(G,K)})};function J(K,G){var H=Y(K);if(H instanceof $)return Q(H);else if(K=I.asArray(K),K===null)return z("expecting an array or an iterable object but got "+I.classString(K));var W=new $(U);if(G!==void 0)W._propagateFrom(G,3);var{_fulfill:X,_reject:Z}=W;for(var q=0,V=K.length;q<V;++q){var F=K[q];if(F===void 0&&!(q in K))continue;$.cast(F)._then(X,Z,void 0,W,null)}return W}$.race=function(K){return J(K,void 0)},$.prototype.race=function(){return J(this,void 0)}}});var UM0=E((Se1,$M0)=>{$M0.exports=function($,U,Y,z,I,Q){var J=$._getDomain,K=F4(),G=K.tryCatch;function H(V,F,M,w){this.constructor$(V);var N=J();if(this._fn=N===null?F:K.domainBind(N,F),M!==void 0)M=$.resolve(M),M._attachCancellationCallback(this);if(this._initialValue=M,this._currentCancellable=null,w===I)this._eachValues=Array(this._length);else if(w===0)this._eachValues=null;else this._eachValues=void 0;this._promise._captureStackTrace(),this._init$(void 0,-5)}K.inherits(H,U),H.prototype._gotAccum=function(V){if(this._eachValues!==void 0&&this._eachValues!==null&&V!==I)this._eachValues.push(V)},H.prototype._eachComplete=function(V){if(this._eachValues!==null)this._eachValues.push(V);return this._eachValues},H.prototype._init=function(){},H.prototype._resolveEmptyArray=function(){this._resolve(this._eachValues!==void 0?this._eachValues:this._initialValue)},H.prototype.shouldCopyValues=function(){return!1},H.prototype._resolve=function(V){this._promise._resolveCallback(V),this._values=null},H.prototype._resultCancelled=function(V){if(V===this._initialValue)return this._cancel();if(this._isResolved())return;if(this._resultCancelled$(),this._currentCancellable instanceof $)this._currentCancellable.cancel();if(this._initialValue instanceof $)this._initialValue.cancel()},H.prototype._iterate=function(V){this._values=V;var F,M,w=V.length;if(this._initialValue!==void 0)F=this._initialValue,M=0;else F=$.resolve(V[0]),M=1;if(this._currentCancellable=F,!F.isRejected())for(;M<w;++M){var N={accum:null,value:V[M],index:M,length:w,array:this};F=F._then(Z,void 0,void 0,N,void 0)}if(this._eachValues!==void 0)F=F._then(this._eachComplete,void 0,void 0,this,void 0);F._then(W,W,void 0,F,this)},$.prototype.reduce=function(V,F){return X(this,V,F,null)},$.reduce=function(V,F,M,w){return X(V,F,M,w)};function W(V,F){if(this.isFulfilled())F._resolve(V);else F._reject(V)}function X(V,F,M,w){if(typeof F!=="function")return Y("expecting a function but got "+K.classString(F));var N=new H(V,F,M,w);return N.promise()}function Z(V){this.accum=V,this.array._gotAccum(V);var F=z(this.value,this.array._promise);if(F instanceof $)return this.array._currentCancellable=F,F._then(q,void 0,void 0,this,void 0);else return q.call(this,F)}function q(V){var F=this.array,M=F._promise,w=G(F._fn);M._pushContext();var N;if(F._eachValues!==void 0)N=w.call(M._boundValue(),V,this.index,this.length);else N=w.call(M._boundValue(),this.accum,V,this.index,this.length);if(N instanceof $)F._currentCancellable=N;var O=M._popContext();return Q.checkForgottenReturns(N,O,F._eachValues!==void 0?"Promise.each":"Promise.reduce",M),N}}});var zM0=E((ge1,YM0)=>{YM0.exports=function($,U,Y){var z=$.PromiseInspection,I=F4();function Q(J){this.constructor$(J)}I.inherits(Q,U),Q.prototype._promiseResolved=function(J,K){this._values[J]=K;var G=++this._totalResolved;if(G>=this._length)return this._resolve(this._values),!0;return!1},Q.prototype._promiseFulfilled=function(J,K){var G=new z;return G._bitField=33554432,G._settledValueField=J,this._promiseResolved(K,G)},Q.prototype._promiseRejected=function(J,K){var G=new z;return G._bitField=16777216,G._settledValueField=J,this._promiseResolved(K,G)},$.settle=function(J){return Y.deprecated(".settle()",".reflect()"),new Q(J).promise()},$.prototype.settle=function(){return $.settle(this)}}});var QM0=E((ye1,IM0)=>{IM0.exports=function($,U,Y){var z=F4(),I=_3().RangeError,Q=_3().AggregateError,J=z.isArray,K={};function G(W){this.constructor$(W),this._howMany=0,this._unwrap=!1,this._initialized=!1}z.inherits(G,U),G.prototype._init=function(){if(!this._initialized)return;if(this._howMany===0){this._resolve([]);return}this._init$(void 0,-5);var W=J(this._values);if(!this._isResolved()&&W&&this._howMany>this._canPossiblyFulfill())this._reject(this._getRangeError(this.length()))},G.prototype.init=function(){this._initialized=!0,this._init()},G.prototype.setUnwrap=function(){this._unwrap=!0},G.prototype.howMany=function(){return this._howMany},G.prototype.setHowMany=function(W){this._howMany=W},G.prototype._promiseFulfilled=function(W){if(this._addFulfilled(W),this._fulfilled()===this.howMany()){if(this._values.length=this.howMany(),this.howMany()= Line truncated
See http://goo.gl/MqrFmX
`);var Z=new G(W),q=Z.promise();return Z.setHowMany(X),Z.init(),q}$.some=function(W,X){return H(W,X)},$.prototype.some=function(W){return H(this,W)},$._SomePromiseArray=G}});var sO0=E((Qe1,rO0)=>{rO0.exports=function($,Y){var z=$.map;$.prototype.filter=function(U,Q){return z(this,U,Q,Y)},$.filter=function(U,Q,J){return z(U,Q,J,Y)}}});var tO0=E((Je1,aO0)=>{aO0.exports=function($,Y){var{reduce:z,all:U}=$;function Q(){return U(this)}function J(I,K){return z(I,K,Y,Y)}$.prototype.each=function(I){return z(this,I,Y,0)._then(Q,void 0,void 0,this,void 0)},$.prototype.mapSeries=function(I){return z(this,I,Y,Y)},$.each=function(I,K){return z(I,K,Y,0)._then(Q,void 0,void 0,I,void 0)},$.mapSeries=J}});var $w0=E((Ie1,eO0)=>{eO0.exports=function($){var Y=$._SomePromiseArray;function z(U){var Q=new Y(U),J=Q.promise();return Q.setHowMany(1),Q.setUnwrap(),Q.init(),J}$.any=function(U){return z(U)},$.prototype.any=function(){return z(this)}}});var Yw0=E((Ke1,Dn)=>{Dn.exports=function(){var $=function(){return new X(`circular promise resolution chain
`);var Z=new G(W),q=Z.promise();return Z.setHowMany(X),Z.init(),q}$.some=function(W,X){return H(W,X)},$.prototype.some=function(W){return H(this,W)},$._SomePromiseArray=G}});var KM0=E((ke1,JM0)=>{JM0.exports=function($,U){var Y=$.map;$.prototype.filter=function(z,I){return Y(this,z,I,U)},$.filter=function(z,I,Q){return Y(z,I,Q,U)}}});var HM0=E((xe1,GM0)=>{GM0.exports=function($,U){var{reduce:Y,all:z}=$;function I(){return z(this)}function Q(J,K){return Y(J,K,U,U)}$.prototype.each=function(J){return Y(this,J,U,0)._then(I,void 0,void 0,this,void 0)},$.prototype.mapSeries=function(J){return Y(this,J,U,U)},$.each=function(J,K){return Y(J,K,U,0)._then(I,void 0,void 0,J,void 0)},$.mapSeries=Q}});var XM0=E((fe1,WM0)=>{WM0.exports=function($){var U=$._SomePromiseArray;function Y(z){var I=new U(z),Q=I.promise();return I.setHowMany(1),I.setUnwrap(),I.init(),Q}$.any=function(z){return Y(z)},$.prototype.any=function(){return Y(this)}}});var ZM0=E((ue1,yn)=>{yn.exports=function(){var $=function(){return new X(`circular promise resolution chain
See http://goo.gl/MqrFmX
`)},Y=function(){return new S.PromiseInspection(this._target())},z=function(x){return S.reject(new X(x))};function U(){}var Q={},J=O4(),I;if(J.isNode)I=function(){var x=process.domain;if(x===void 0)x=null;return x};else I=function(){return null};J.notEnumerableProp(S,"_getDomain",I);var K=az(),G=oF0(),H=new G;K.defineProperty(S,"_async",{value:H});var W=E3(),X=S.TypeError=W.TypeError;S.RangeError=W.RangeError;var Z=S.CancellationError=W.CancellationError;S.TimeoutError=W.TimeoutError,S.OperationalError=W.OperationalError,S.RejectionError=W.OperationalError,S.AggregateError=W.AggregateError;var q=function(){},V={},F={},w=eF0()(S,q),O=YO0()(S,q,w,z,U),N=UO0()(S),M=N.create,D=JO0()(S,N),P=D.CapturedTrace,j=KO0()(S,w),A=HO0()(F),T=Mn(),C=J.errorObj,b=J.tryCatch;function k(x,d){if(typeof d!=="function")throw new X("expecting a function but got "+J.classString(d));if(x.constructor!==S)throw new X(`the promise constructor cannot be invoked directly
`)},U=function(){return new g.PromiseInspection(this._target())},Y=function(k){return g.reject(new X(k))};function z(){}var I={},Q=F4(),J;if(Q.isNode)J=function(){var k=process.domain;if(k===void 0)k=null;return k};else J=function(){return null};Q.notEnumerableProp(g,"_getDomain",J);var K=aY(),G=QF0(),H=new G;K.defineProperty(g,"_async",{value:H});var W=_3(),X=g.TypeError=W.TypeError;g.RangeError=W.RangeError;var Z=g.CancellationError=W.CancellationError;g.TimeoutError=W.TimeoutError,g.OperationalError=W.OperationalError,g.RejectionError=W.OperationalError,g.AggregateError=W.AggregateError;var q=function(){},V={},F={},M=WF0()(g,q),w=ZF0()(g,q,M,Y,z),N=VF0()(g),O=N.create,D=wF0()(g,N),P=D.CapturedTrace,T=MF0()(g,M),A=NF0()(F),j=Sn(),C=Q.errorObj,b=Q.tryCatch;function x(k,p){if(typeof p!=="function")throw new X("expecting a function but got "+Q.classString(p));if(k.constructor!==g)throw new X(`the promise constructor cannot be invoked directly
See http://goo.gl/MqrFmX
`)}function S(x){if(this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,x!==q)k(this,x),this._resolveFromExecutor(x);this._promiseCreated(),this._fireEvent("promiseCreated",this)}S.prototype.toString=function(){return"[object Promise]"},S.prototype.caught=S.prototype.catch=function(x){var d=arguments.length;if(d>1){var t=Array(d-1),e=0,g;for(g=0;g<d-1;++g){var p=arguments[g];if(J.isObject(p))t[e++]=p;else return z("expecting an object but got A catch statement predicate "+J.classString(p))}return t.length=e,x=arguments[g],this.then(void 0,A(t,x,this))}return this.then(void 0,x)},S.prototype.reflect=function(){return this._then(Y,Y,void 0,this,void 0)},S.prototype.then=function(x,d){if(D.warnings()&&arguments.length>0&&typeof x!=="function"&&typeof d!=="function"){var t=".then() only accepts functions but was passed: "+J.classString(x);if(arguments.length>1)t+=", "+J.classString(d);this._warn(t)}return this._then(x,d,void 0,void 0,void 0)},S.prototype.done=function(x,d){var t=this._then(x,d,void 0,void 0,void 0);t._setIsFinal()},S.prototype.spread=function(x){if(typeof x!=="function")return z("expecting a function but got "+J.classString(x));return this.all()._then(x,void 0,void 0,V,void 0)},S.prototype.toJSON=function(){var x={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};if(this.isFulfilled())x.fulfillmentValue=this.value(),x.isFulfilled=!0;else if(this.isRejected())x.rejectionReason=this.reason(),x.isRejected=!0;return x},S.prototype.all=function(){if(arguments.length>0)this._warn(".all() was passed arguments but it does not take any");return new O(this).promise()},S.prototype.error=function(x){return this.caught(J.originatesFromRejection,x)},S.getNewLibraryCopy=Dn.exports,S.is=function(x){return x instanceof S},S.fromNode=S.fromCallback=function(x){var d=new S(q);d._captureStackTrace();var t=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,e=b(x)(T(d,t));if(e===C)d._rejectCallback(e.e,!0);if(!d._isFateSealed())d._setAsyncGuaranteed();return d},S.all=function(x){return new O(x).promise()},S.cast=function(x){var d=w(x);if(!(d instanceof S))d=new S(q),d._captureStackTrace(),d._setFulfilled(),d._rejectionHandler0=x;return d},S.resolve=S.fulfilled=S.cast,S.reject=S.rejected=function(x){var d=new S(q);return d._captureStackTrace(),d._rejectCallback(x,!0),d},S.setScheduler=function(x){if(typeof x!=="function")throw new X("expecting a function but got "+J.classString(x));return H.setScheduler(x)},S.prototype._then=function(x,d,t,e,g){var p=g!==void 0,Y0=p?g:new S(q),y=this._target(),r=y._bitField;if(!p){if(Y0._propagateFrom(this,3),Y0._captureStackTrace(),e===void 0&&(this._bitField&2097152)!==0)if((r&50397184)!==0)e=this._boundValue();else e=y===this?void 0:this._boundTo;this._fireEvent("promiseChained",this,Y0)}var $0=I();if((r&50397184)!==0){var N0,T0,_0=y._settlePromiseCtx;if((r&33554432)!==0)T0=y._rejectionHandler0,N0=x;else if((r&16777216)!==0)T0=y._fulfillmentHandler0,N0=d,y._unsetRejectionIsUnhandled();else _0=y._settlePromiseLateCancellationObserver,T0=new Z("late cancellation observer"),y._attachExtraTrace(T0),N0=d;H.invoke(_0,y,{handler:$0===null?N0:typeof N0==="function"&&J.domainBind($0,N0),promise:Y0,receiver:e,value:T0})}else y._addCallbacks(x,d,Y0,e,$0);return Y0},S.prototype._length=function(){return this._bitField&65535},S.prototype._isFateSealed=function(){return(this._bitField&117506048)!==0},S.prototype._isFollowing=function(){return(this._bitField&67108864)===67108864},S.prototype._setLength=function(x){this._bitField=this._bitField&-65536|x&65535},S.prototype._setFulfilled=function(){this._bitField=this._bitField|33554432,this._fireEvent("promiseFulfilled",this)},S.prototype._setRejected=function(){this._bitField=this._bitField|16777216,this._fireEvent("promiseRejected",this)},S.prototype._setFollowing=function(){this._bitField=this._bitField|67108864,this._fireEvent("promiseResolved",this)},S.prototype._setIsFinal=function(){this._bitField=this._bitField|4194304},S.prototype._isFinal=function(){return(this._bitField&4194304)>0},S.prototype._unsetCancelled=function(){this._bitField=this._bitField&-65537},S.prototype._setCancelled=function(){this._bitField=this._bitField|65536,this._fireEvent("promiseCancelled",this)},S.prototype._setWillBeCancelled=function(){this._bitField=this._bitField|8388608},S.prototype._setAsyncGuaranteed=function(){if(H.hasCustomScheduler())return;this._bitField=this._bitField|134217728},S.prototype._receiverAt=function(x){var d=x===0?this._receiver0:this[x*4-4+3];if(d===Q)return;else if(d===void 0&&this._isBound())return this._boundValue();return d},S.prototype._promiseAt=function(x){return this[x*4-4+2]},S.prototype._fulfillmentHandlerAt=function(x){return this[x*4-4+0]},S.prototype._rejectionHandlerAt=function(x){return this[x*4-4+1]},S.prototype._boundValue=function(){},S.prototype._migrateCallback0=function(x){var{_bitField:d,_fulfillmentHandler0:t,_ Line truncated
`)}function g(k){if(this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,k!==q)x(this,k),this._resolveFromExecutor(k);this._promiseCreated(),this._fireEvent("promiseCreated",this)}g.prototype.toString=function(){return"[object Promise]"},g.prototype.caught=g.prototype.catch=function(k){var p=arguments.length;if(p>1){var a=Array(p-1),$0=0,y;for(y=0;y<p-1;++y){var d=arguments[y];if(Q.isObject(d))a[$0++]=d;else return Y("expecting an object but got A catch statement predicate "+Q.classString(d))}return a.length=$0,k=arguments[y],this.then(void 0,A(a,k,this))}return this.then(void 0,k)},g.prototype.reflect=function(){return this._then(U,U,void 0,this,void 0)},g.prototype.then=function(k,p){if(D.warnings()&&arguments.length>0&&typeof k!=="function"&&typeof p!=="function"){var a=".then() only accepts functions but was passed: "+Q.classString(k);if(arguments.length>1)a+=", "+Q.classString(p);this._warn(a)}return this._then(k,p,void 0,void 0,void 0)},g.prototype.done=function(k,p){var a=this._then(k,p,void 0,void 0,void 0);a._setIsFinal()},g.prototype.spread=function(k){if(typeof k!=="function")return Y("expecting a function but got "+Q.classString(k));return this.all()._then(k,void 0,void 0,V,void 0)},g.prototype.toJSON=function(){var k={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};if(this.isFulfilled())k.fulfillmentValue=this.value(),k.isFulfilled=!0;else if(this.isRejected())k.rejectionReason=this.reason(),k.isRejected=!0;return k},g.prototype.all=function(){if(arguments.length>0)this._warn(".all() was passed arguments but it does not take any");return new w(this).promise()},g.prototype.error=function(k){return this.caught(Q.originatesFromRejection,k)},g.getNewLibraryCopy=yn.exports,g.is=function(k){return k instanceof g},g.fromNode=g.fromCallback=function(k){var p=new g(q);p._captureStackTrace();var a=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,$0=b(k)(j(p,a));if($0===C)p._rejectCallback($0.e,!0);if(!p._isFateSealed())p._setAsyncGuaranteed();return p},g.all=function(k){return new w(k).promise()},g.cast=function(k){var p=M(k);if(!(p instanceof g))p=new g(q),p._captureStackTrace(),p._setFulfilled(),p._rejectionHandler0=k;return p},g.resolve=g.fulfilled=g.cast,g.reject=g.rejected=function(k){var p=new g(q);return p._captureStackTrace(),p._rejectCallback(k,!0),p},g.setScheduler=function(k){if(typeof k!=="function")throw new X("expecting a function but got "+Q.classString(k));return H.setScheduler(k)},g.prototype._then=function(k,p,a,$0,y){var d=y!==void 0,U0=d?y:new g(q),R=this._target(),o=R._bitField;if(!d){if(U0._propagateFrom(this,3),U0._captureStackTrace(),$0===void 0&&(this._bitField&2097152)!==0)if((o&50397184)!==0)$0=this._boundValue();else $0=R===this?void 0:this._boundTo;this._fireEvent("promiseChained",this,U0)}var e=J();if((o&50397184)!==0){var O0,T0,y0=R._settlePromiseCtx;if((o&33554432)!==0)T0=R._rejectionHandler0,O0=k;else if((o&16777216)!==0)T0=R._fulfillmentHandler0,O0=p,R._unsetRejectionIsUnhandled();else y0=R._settlePromiseLateCancellationObserver,T0=new Z("late cancellation observer"),R._attachExtraTrace(T0),O0=p;H.invoke(y0,R,{handler:e===null?O0:typeof O0==="function"&&Q.domainBind(e,O0),promise:U0,receiver:$0,value:T0})}else R._addCallbacks(k,p,U0,$0,e);return U0},g.prototype._length=function(){return this._bitField&65535},g.prototype._isFateSealed=function(){return(this._bitField&117506048)!==0},g.prototype._isFollowing=function(){return(this._bitField&67108864)===67108864},g.prototype._setLength=function(k){this._bitField=this._bitField&-65536|k&65535},g.prototype._setFulfilled=function(){this._bitField=this._bitField|33554432,this._fireEvent("promiseFulfilled",this)},g.prototype._setRejected=function(){this._bitField=this._bitField|16777216,this._fireEvent("promiseRejected",this)},g.prototype._setFollowing=function(){this._bitField=this._bitField|67108864,this._fireEvent("promiseResolved",this)},g.prototype._setIsFinal=function(){this._bitField=this._bitField|4194304},g.prototype._isFinal=function(){return(this._bitField&4194304)>0},g.prototype._unsetCancelled=function(){this._bitField=this._bitField&-65537},g.prototype._setCancelled=function(){this._bitField=this._bitField|65536,this._fireEvent("promiseCancelled",this)},g.prototype._setWillBeCancelled=function(){this._bitField=this._bitField|8388608},g.prototype._setAsyncGuaranteed=function(){if(H.hasCustomScheduler())return;this._bitField=this._bitField|134217728},g.prototype._receiverAt=function(k){var p=k===0?this._receiver0:this[k*4-4+3];if(p===I)return;else if(p===void 0&&this._isBound())return this._boundValue();return p},g.prototype._promiseAt=function(k){return this[k*4-4+2]},g.prototype._fulfillmentHandlerAt=function(k){return this[k*4-4+0]},g.prototype._rejectionHandlerAt=function(k){return this[k*4-4+1]},g.prototype._boundValue=function(){},g.prototype._migrateCallback0=function(k){var{_bitField:p,_fulfillmentHand Line truncated
path = %s
syscall = %s
fstream_type = %s
@@ -294,31 +294,31 @@ fstream_unc_path = %s
fstream_class = %s
fstream_stack =
%s
`,Y||"UNKNOWN",U.stack,U.path,U.syscall,U.fstream_type,U.fstream_path,U.fstream_unc_path,U.fstream_class,U.fstream_stack.join(`
`));else z.emit("warn",U)};S2.prototype.info=function($,Y){this.emit("info",$,Y)};S2.prototype.error=function($,Y,z){var U=gM0($,Y,this);if(z)throw U;else this.emit("error",U)};function gM0($,Y,z){if(!($ instanceof Error))$=Error($);if($.code=$.code||Y,$.path=$.path||z.path,$.fstream_type=$.fstream_type||z.type,$.fstream_path=$.fstream_path||z.path,z._path!==z.path)$.fstream_unc_path=$.fstream_unc_path||z._path;if(z.linkpath)$.fstream_linkpath=$.fstream_linkpath||z.linkpath;return $.fstream_class=$.fstream_class||z.constructor.name,$.fstream_stack=$.fstream_stack||Error().stack.split(/\n/).slice(3).map(function(U){return U.replace(/^ {4}at /,"")}),$}});var VZ=E((xe1,kM0)=>{kM0.exports=mO1;function mO1($){var Y=["Directory","File","SymbolicLink","Link","BlockDevice","CharacterDevice","FIFO","Socket"],z;if($.type&&Y.indexOf($.type)!==-1)return $[$.type]=!0,$.type;for(var U=0,Q=Y.length;U<Q;U++){z=Y[U];var J=$[z]||$["is"+z];if(typeof J==="function")J=J.call($);if(J)return $[z]=!0,$.type=z,z}return null}});var Gc=E((fe1,xM0)=>{xM0.exports=LZ;var lO1=o8(),oO1=X1(),Kc=IU();oO1(LZ,Kc);function LZ($){var Y=this;if(!(Y instanceof LZ))throw Error("LinkReader must be called as constructor.");if(!($.type==="Link"&&$.Link||$.type==="SymbolicLink"&&$.SymbolicLink))throw Error("Non-link type "+$.type);Kc.call(Y,$)}LZ.prototype._stat=function($){var Y=this;lO1.readlink(Y._path,function(z,U){if(z)return Y.error(z);Y.linkpath=Y.props.linkpath=U,Y.emit("linkpath",U),Kc.prototype._stat.call(Y,$)})};LZ.prototype._read=function(){var $=this;if($._paused)return;if(!$._ended)$.emit("end"),$.emit("close"),$._ended=!0}});var Wc=E((ue1,bM0)=>{bM0.exports=D9;var uM0=o8(),rO1=X1(),FZ=I0("path"),Hc=IU(),fM0=I0("assert").ok;rO1(D9,Hc);function D9($){var Y=this;if(!(Y instanceof D9))throw Error("DirReader must be called as constructor.");if($.type!=="Directory"||!$.Directory)throw Error("Non-directory type "+$.type);if(Y.entries=null,Y._index=-1,Y._paused=!1,Y._length=-1,$.sort)this.sort=$.sort;Hc.call(this,$)}D9.prototype._getEntries=function(){var $=this;if($._gotEntries)return;$._gotEntries=!0,uM0.readdir($._path,function(Y,z){if(Y)return $.error(Y);if($.entries=z,$.emit("entries",z),$._paused)$.once("resume",U);else U();function U(){if($._length=$.entries.length,typeof $.sort==="function")$.entries=$.entries.sort($.sort.bind($));$._read()}})};D9.prototype._read=function(){var $=this;if(!$.entries)return $._getEntries();if($._paused||$._currentEntry||$._aborted)return;if($._index++,$._index>=$.entries.length){if(!$._ended)$._ended=!0,$.emit("end"),$.emit("close");return}var Y=FZ.resolve($._path,$.entries[$._index]);fM0(Y!==$._path),fM0($.entries[$._index]),$._currentEntry=Y,uM0[$.props.follow?"stat":"lstat"](Y,function(z,U){if(z)return $.error(z);var Q=$._proxy||$;U.path=Y,U.basename=FZ.basename(Y),U.dirname=FZ.dirname(Y);var J=$.getChildProps.call(Q,U);J.path=Y,J.basename=FZ.basename(Y),J.dirname=FZ.dirname(Y);var I=Hc(J,U);$._currentEntry=I,I.on("pause",function(H){if(!$._paused&&!I._disowned)$.pause(H)}),I.on("resume",function(H){if($._paused&&!I._disowned)$.resume(H)}),I.on("stat",function(H){if($.emit("_entryStat",I,H),I._aborted)return;if(I._paused)I.once("resume",function(){$.emit("entryStat",I,H)});else $.emit("entryStat",I,H)}),I.on("ready",function H(){if($._paused)return I.pause($),$.once("resume",H);if(I.type==="Socket")$.emit("socket",I);else $.emitEntry(I)});var K=!1;I.on("close",G),I.on("disown",G);function G(){if(K)return;if(K=!0,$.emit("childEnd",I),$.emit("entryEnd",I),$._currentEntry=null,!$._paused)$._read()}I.on("error",function(H){if(I._swallowErrors)$.warn(H),I.emit("end"),I.emit("close");else $.emit("error",H)}),["child","childEnd","warn"].forEach(function(H){I.on(H,$.emit.bind($,H))})})};D9.prototype.disown=function($){if($.emit("beforeDisown"),$._disowned=!0,$.parent=$.root=null,$===this._currentEntry)this._currentEntry=null;$.emit("disown")};D9.prototype.getChildProps=function(){return{depth:this.depth+1,root:this.root||this,parent:this,follow:this.follow,filter:this.filter,sort:this.props.sort,hardlinks:this.props.hardlinks}};D9.prototype.pause=function($){var Y=this;if(Y._paused)return;if($=$||Y,Y._paused=!0,Y._currentEntry&&Y._currentEntry.pause)Y._currentEntry.pause($);Y.emit("pause",$)};D9.prototype.resume=function($){var Y=this;if(!Y._paused)return;if($=$||Y,Y._paused=!1,Y.emit("resume",$),Y._paused)return;if(Y._currentEntry){if(Y._currentEntry.resume)Y._currentEntry.resume($)}else Y._read()};D9.prototype.emitEntry=function($){this.emit("entry",$),this.emit("child",$)}});var Xc=E((be1,pM0)=>{pM0.exports=KU;var sO1=o8(),aO1=X1(),iM0=IU(),nM0={EOF:!0},cM0={CLOSE:!0};aO1(KU,iM0);function KU($){var Y=this;if(!(Y instanceof KU))throw Error("FileReader must be called as constructor.");if(!($.type==="Link"&&$.Link||$.type==="File"&&$.File))throw Error("Non-file type "+$.type);Y._buffer=[],Y._bytesEmitted=0,iM0.call(Y,$)}KU.prototype._getStream=function(){var $=this,Y=$._stream=sO1.createReadStream($._path,$.p Line truncated
`,U||"UNKNOWN",z.stack,z.path,z.syscall,z.fstream_type,z.fstream_path,z.fstream_unc_path,z.fstream_class,z.fstream_stack.join(`
`));else Y.emit("warn",z)};g2.prototype.info=function($,U){this.emit("info",$,U)};g2.prototype.error=function($,U,Y){var z=pO0($,U,this);if(Y)throw z;else this.emit("error",z)};function pO0($,U,Y){if(!($ instanceof Error))$=Error($);if($.code=$.code||U,$.path=$.path||Y.path,$.fstream_type=$.fstream_type||Y.type,$.fstream_path=$.fstream_path||Y.path,Y._path!==Y.path)$.fstream_unc_path=$.fstream_unc_path||Y._path;if(Y.linkpath)$.fstream_linkpath=$.fstream_linkpath||Y.linkpath;return $.fstream_class=$.fstream_class||Y.constructor.name,$.fstream_stack=$.fstream_stack||Error().stack.split(/\n/).slice(3).map(function(z){return z.replace(/^ {4}at /,"")}),$}});var wZ=E((L04,lO0)=>{lO0.exports=NM1;function NM1($){var U=["Directory","File","SymbolicLink","Link","BlockDevice","CharacterDevice","FIFO","Socket"],Y;if($.type&&U.indexOf($.type)!==-1)return $[$.type]=!0,$.type;for(var z=0,I=U.length;z<I;z++){Y=U[z];var Q=$[Y]||$["is"+Y];if(typeof Q==="function")Q=Q.call($);if(Q)return $[Y]=!0,$.type=Y,Y}return null}});var Ac=E((w04,oO0)=>{oO0.exports=FZ;var DM1=r8(),AM1=W1(),Dc=Jz();AM1(FZ,Dc);function FZ($){var U=this;if(!(U instanceof FZ))throw Error("LinkReader must be called as constructor.");if(!($.type==="Link"&&$.Link||$.type==="SymbolicLink"&&$.SymbolicLink))throw Error("Non-link type "+$.type);Dc.call(U,$)}FZ.prototype._stat=function($){var U=this;DM1.readlink(U._path,function(Y,z){if(Y)return U.error(Y);U.linkpath=U.props.linkpath=z,U.emit("linkpath",z),Dc.prototype._stat.call(U,$)})};FZ.prototype._read=function(){var $=this;if($._paused)return;if(!$._ended)$.emit("end"),$.emit("close"),$._ended=!0}});var Pc=E((F04,aO0)=>{aO0.exports=B9;var sO0=r8(),BM1=W1(),MZ=J0("path"),Bc=Jz(),rO0=J0("assert").ok;BM1(B9,Bc);function B9($){var U=this;if(!(U instanceof B9))throw Error("DirReader must be called as constructor.");if($.type!=="Directory"||!$.Directory)throw Error("Non-directory type "+$.type);if(U.entries=null,U._index=-1,U._paused=!1,U._length=-1,$.sort)this.sort=$.sort;Bc.call(this,$)}B9.prototype._getEntries=function(){var $=this;if($._gotEntries)return;$._gotEntries=!0,sO0.readdir($._path,function(U,Y){if(U)return $.error(U);if($.entries=Y,$.emit("entries",Y),$._paused)$.once("resume",z);else z();function z(){if($._length=$.entries.length,typeof $.sort==="function")$.entries=$.entries.sort($.sort.bind($));$._read()}})};B9.prototype._read=function(){var $=this;if(!$.entries)return $._getEntries();if($._paused||$._currentEntry||$._aborted)return;if($._index++,$._index>=$.entries.length){if(!$._ended)$._ended=!0,$.emit("end"),$.emit("close");return}var U=MZ.resolve($._path,$.entries[$._index]);rO0(U!==$._path),rO0($.entries[$._index]),$._currentEntry=U,sO0[$.props.follow?"stat":"lstat"](U,function(Y,z){if(Y)return $.error(Y);var I=$._proxy||$;z.path=U,z.basename=MZ.basename(U),z.dirname=MZ.dirname(U);var Q=$.getChildProps.call(I,z);Q.path=U,Q.basename=MZ.basename(U),Q.dirname=MZ.dirname(U);var J=Bc(Q,z);$._currentEntry=J,J.on("pause",function(H){if(!$._paused&&!J._disowned)$.pause(H)}),J.on("resume",function(H){if($._paused&&!J._disowned)$.resume(H)}),J.on("stat",function(H){if($.emit("_entryStat",J,H),J._aborted)return;if(J._paused)J.once("resume",function(){$.emit("entryStat",J,H)});else $.emit("entryStat",J,H)}),J.on("ready",function H(){if($._paused)return J.pause($),$.once("resume",H);if(J.type==="Socket")$.emit("socket",J);else $.emitEntry(J)});var K=!1;J.on("close",G),J.on("disown",G);function G(){if(K)return;if(K=!0,$.emit("childEnd",J),$.emit("entryEnd",J),$._currentEntry=null,!$._paused)$._read()}J.on("error",function(H){if(J._swallowErrors)$.warn(H),J.emit("end"),J.emit("close");else $.emit("error",H)}),["child","childEnd","warn"].forEach(function(H){J.on(H,$.emit.bind($,H))})})};B9.prototype.disown=function($){if($.emit("beforeDisown"),$._disowned=!0,$.parent=$.root=null,$===this._currentEntry)this._currentEntry=null;$.emit("disown")};B9.prototype.getChildProps=function(){return{depth:this.depth+1,root:this.root||this,parent:this,follow:this.follow,filter:this.filter,sort:this.props.sort,hardlinks:this.props.hardlinks}};B9.prototype.pause=function($){var U=this;if(U._paused)return;if($=$||U,U._paused=!0,U._currentEntry&&U._currentEntry.pause)U._currentEntry.pause($);U.emit("pause",$)};B9.prototype.resume=function($){var U=this;if(!U._paused)return;if($=$||U,U._paused=!1,U.emit("resume",$),U._paused)return;if(U._currentEntry){if(U._currentEntry.resume)U._currentEntry.resume($)}else U._read()};B9.prototype.emitEntry=function($){this.emit("entry",$),this.emit("child",$)}});var Tc=E((M04,UN0)=>{UN0.exports=Kz;var PM1=r8(),TM1=W1(),tO0=Jz(),eO0={EOF:!0},$N0={CLOSE:!0};TM1(Kz,tO0);function Kz($){var U=this;if(!(U instanceof Kz))throw Error("FileReader must be called as constructor.");if(!($.type==="Link"&&$.Link||$.type==="File"&&$.File))throw Error("Non-file type "+$.type);U._buffer=[],U._bytesEmitted=0,tO0.call(U,$)}Kz.prototype._getStream=function(){var $=this,U=$._stream=PM1.createReadStream($._path,$.p Line truncated
expect: `+$.props.size+`
actual: `+$._bytesEmitted)}),Y.on("close",function(){if($._paused||$._buffer.length)$._buffer.push(cM0),$._read();else $.emit("close")}),Y.on("error",function(z){$.emit("error",z)}),$._read()};KU.prototype._read=function(){var $=this;if($._paused)return;if(!$._stream)return $._getStream();if($._buffer.length){var Y=$._buffer;for(var z=0,U=Y.length;z<U;z++){var Q=Y[z];if(Q===nM0)$.emit("end");else if(Q===cM0)$.emit("close");else $.emit("data",Q);if($._paused){$._buffer=Y.slice(z);return}}$._buffer.length=0}};KU.prototype.pause=function($){var Y=this;if(Y._paused)return;if($=$||Y,Y._paused=!0,Y._stream)Y._stream.pause();Y.emit("pause",$)};KU.prototype.resume=function($){var Y=this;if(!Y._paused)return;if($=$||Y,Y.emit("resume",$),Y._paused=!1,Y._stream)Y._stream.resume();Y._read()}});var lM0=E((ie1,mM0)=>{mM0.exports=qB;var tO1=X1(),dM0=IU();tO1(qB,dM0);function qB($){var Y=this;if(!(Y instanceof qB))throw Error("SocketReader must be called as constructor.");if(!($.type==="Socket"&&$.Socket))throw Error("Non-socket type "+$.type);dM0.call(Y,$)}qB.prototype._read=function(){var $=this;if($._paused)return;if(!$._ended)$.emit("end"),$.emit("close"),$._ended=!0}});var qc=E((ne1,oM0)=>{oM0.exports=GU;var Zc=IU(),eO1=VZ(),$w1=X1(),Yw1=o8();$w1(GU,Zc);function GU($){var Y=this;if(!(Y instanceof GU))throw Error("ProxyReader must be called as constructor.");Y.props=$,Y._buffer=[],Y.ready=!1,Zc.call(Y,$)}GU.prototype._stat=function(){var $=this,Y=$.props,z=Y.follow?"stat":"lstat";Yw1[z](Y.path,function(U,Q){var J;if(U||!Q)J="File";else J=eO1(Q);Y[J]=!0,Y.type=$.type=J,$._old=Q,$._addProxy(Zc(Y,Q))})};GU.prototype._addProxy=function($){var Y=this;if(Y._proxyTarget)return Y.error("proxy already set");Y._proxyTarget=$,$._proxy=Y,["error","data","end","close","linkpath","entry","entryEnd","child","childEnd","warn","stat"].forEach(function(U){$.on(U,Y.emit.bind(Y,U))}),Y.emit("proxy",$),$.on("ready",function(){Y.ready=!0,Y.emit("ready")});var z=Y._buffer;Y._buffer.length=0,z.forEach(function(U){$[U[0]].apply($,U[1])})};GU.prototype.pause=function(){return this._proxyTarget?this._proxyTarget.pause():!1};GU.prototype.resume=function(){return this._proxyTarget?this._proxyTarget.resume():!1}});var IU=E((ce1,aM0)=>{aM0.exports=N5;var zw1=o8(),Uw1=I0("stream").Stream,Qw1=X1(),Vc=I0("path"),Lc=VZ(),VB=N5.hardLinks={},rM0=ZB();Qw1(N5,rM0);var sM0=Gc();function N5($,Y){var z=this;if(!(z instanceof N5))return new N5($,Y);if(typeof $==="string")$={path:$};var U,Q;if($.type&&typeof $.type==="function")U=$.type,Q=U;else U=Lc($),Q=N5;if(Y&&!U)U=Lc(Y),$[U]=!0,$.type=U;switch(U){case"Directory":Q=Wc();break;case"Link":case"File":Q=Xc();break;case"SymbolicLink":Q=sM0;break;case"Socket":Q=lM0();break;case null:Q=qc();break}if(!(z instanceof Q))return new Q($);if(rM0.call(z),!$.path)z.error("Must provide a path",null,!0);if(z.readable=!0,z.writable=!1,z.type=U,z.props=$,z.depth=$.depth=$.depth||0,z.parent=$.parent||null,z.root=$.root||$.parent&&$.parent.root||z,z._path=z.path=Vc.resolve($.path),process.platform==="win32"){if(z.path=z._path=z.path.replace(/\?/g,"_"),z._path.length>=260)z._swallowErrors=!0,z._path="\\\\?\\"+z.path.replace(/\//g,"\\")}if(z.basename=$.basename=Vc.basename(z.path),z.dirname=$.dirname=Vc.dirname(z.path),$.parent=$.root=null,z.size=$.size,z.filter=typeof $.filter==="function"?$.filter:null,$.sort==="alpha")$.sort=Jw1;z._stat(Y)}function Jw1($,Y){return $===Y?0:$.toLowerCase()>Y.toLowerCase()?1:$.toLowerCase()<Y.toLowerCase()?-1:$>Y?1:-1}N5.prototype._stat=function($){var Y=this,z=Y.props,U=z.follow?"stat":"lstat";if($)process.nextTick(Q.bind(null,null,$));else zw1[U](Y._path,Q);function Q(J,I){if(J)return Y.error(J);if(Object.keys(I).forEach(function(q){z[q]=I[q]}),Y.size!==void 0&&z.size!==Y.size)return Y.error("incorrect size");Y.size=z.size;var K=Lc(z),G=z.hardlinks!==!1;if(G&&K!=="Directory"&&z.nlink&&z.nlink>1){var H=z.dev+":"+z.ino;if(VB[H]===Y._path||!VB[H])VB[H]=Y._path;else K=Y.type=Y.props.type="Link",Y.Link=Y.props.Link=!0,Y.linkpath=Y.props.linkpath=VB[H],Y._stat=Y._read=sM0.prototype._read}if(Y.type&&Y.type!==K)Y.error("Unexpected type: "+K);if(Y.filter){var W=Y._proxy||Y;if(!Y.filter.call(W,W,z)){if(!Y._disowned)Y.abort(),Y.emit("end"),Y.emit("close");return}}var X=["_stat","stat","ready"],Z=0;(function q(){if(Y._aborted){Y.emit("end"),Y.emit("close");return}if(Y._paused&&Y.type!=="Directory"){Y.once("resume",q);return}var V=X[Z++];if(!V)return Y._read();Y.emit(V,z),q()})()}};N5.prototype.pipe=function($){var Y=this;if(typeof $.add==="function")Y.on("entry",function(z){var U=$.add(z);if(U===!1)Y.pause()});return Uw1.prototype.pipe.apply(this,arguments)};N5.prototype.pause=function($){if(this._paused=!0,$=$||this,this.emit("pause",$),this._stream)this._stream.pause($)};N5.prototype.resume=function($){if(this._paused=!1,$=$||this,this.emit("resume",$),this._stream)this._stream.resume($);this._read()};N5.prototype._read=function(){this.error("Cannot read unknown type: "+this.type)}});var Mc=E((pe1,JN0)=> Line truncated
actual: `+$._bytesEmitted)}),U.on("close",function(){if($._paused||$._buffer.length)$._buffer.push($N0),$._read();else $.emit("close")}),U.on("error",function(Y){$.emit("error",Y)}),$._read()};Kz.prototype._read=function(){var $=this;if($._paused)return;if(!$._stream)return $._getStream();if($._buffer.length){var U=$._buffer;for(var Y=0,z=U.length;Y<z;Y++){var I=U[Y];if(I===eO0)$.emit("end");else if(I===$N0)$.emit("close");else $.emit("data",I);if($._paused){$._buffer=U.slice(Y);return}}$._buffer.length=0}};Kz.prototype.pause=function($){var U=this;if(U._paused)return;if($=$||U,U._paused=!0,U._stream)U._stream.pause();U.emit("pause",$)};Kz.prototype.resume=function($){var U=this;if(!U._paused)return;if($=$||U,U.emit("resume",$),U._paused=!1,U._stream)U._stream.resume();U._read()}});var IN0=E((O04,zN0)=>{zN0.exports=OB;var jM1=W1(),YN0=Jz();jM1(OB,YN0);function OB($){var U=this;if(!(U instanceof OB))throw Error("SocketReader must be called as constructor.");if(!($.type==="Socket"&&$.Socket))throw Error("Non-socket type "+$.type);YN0.call(U,$)}OB.prototype._read=function(){var $=this;if($._paused)return;if(!$._ended)$.emit("end"),$.emit("close"),$._ended=!0}});var Ec=E((N04,QN0)=>{QN0.exports=Gz;var jc=Jz(),EM1=wZ(),CM1=W1(),RM1=r8();CM1(Gz,jc);function Gz($){var U=this;if(!(U instanceof Gz))throw Error("ProxyReader must be called as constructor.");U.props=$,U._buffer=[],U.ready=!1,jc.call(U,$)}Gz.prototype._stat=function(){var $=this,U=$.props,Y=U.follow?"stat":"lstat";RM1[Y](U.path,function(z,I){var Q;if(z||!I)Q="File";else Q=EM1(I);U[Q]=!0,U.type=$.type=Q,$._old=I,$._addProxy(jc(U,I))})};Gz.prototype._addProxy=function($){var U=this;if(U._proxyTarget)return U.error("proxy already set");U._proxyTarget=$,$._proxy=U,["error","data","end","close","linkpath","entry","entryEnd","child","childEnd","warn","stat"].forEach(function(z){$.on(z,U.emit.bind(U,z))}),U.emit("proxy",$),$.on("ready",function(){U.ready=!0,U.emit("ready")});var Y=U._buffer;U._buffer.length=0,Y.forEach(function(z){$[z[0]].apply($,z[1])})};Gz.prototype.pause=function(){return this._proxyTarget?this._proxyTarget.pause():!1};Gz.prototype.resume=function(){return this._proxyTarget?this._proxyTarget.resume():!1}});var Jz=E((D04,GN0)=>{GN0.exports=B5;var _M1=r8(),vM1=J0("stream").Stream,hM1=W1(),Cc=J0("path"),Rc=wZ(),NB=B5.hardLinks={},JN0=MB();hM1(B5,JN0);var KN0=Ac();function B5($,U){var Y=this;if(!(Y instanceof B5))return new B5($,U);if(typeof $==="string")$={path:$};var z,I;if($.type&&typeof $.type==="function")z=$.type,I=z;else z=Rc($),I=B5;if(U&&!z)z=Rc(U),$[z]=!0,$.type=z;switch(z){case"Directory":I=Pc();break;case"Link":case"File":I=Tc();break;case"SymbolicLink":I=KN0;break;case"Socket":I=IN0();break;case null:I=Ec();break}if(!(Y instanceof I))return new I($);if(JN0.call(Y),!$.path)Y.error("Must provide a path",null,!0);if(Y.readable=!0,Y.writable=!1,Y.type=z,Y.props=$,Y.depth=$.depth=$.depth||0,Y.parent=$.parent||null,Y.root=$.root||$.parent&&$.parent.root||Y,Y._path=Y.path=Cc.resolve($.path),process.platform==="win32"){if(Y.path=Y._path=Y.path.replace(/\?/g,"_"),Y._path.length>=260)Y._swallowErrors=!0,Y._path="\\\\?\\"+Y.path.replace(/\//g,"\\")}if(Y.basename=$.basename=Cc.basename(Y.path),Y.dirname=$.dirname=Cc.dirname(Y.path),$.parent=$.root=null,Y.size=$.size,Y.filter=typeof $.filter==="function"?$.filter:null,$.sort==="alpha")$.sort=SM1;Y._stat(U)}function SM1($,U){return $===U?0:$.toLowerCase()>U.toLowerCase()?1:$.toLowerCase()<U.toLowerCase()?-1:$>U?1:-1}B5.prototype._stat=function($){var U=this,Y=U.props,z=Y.follow?"stat":"lstat";if($)process.nextTick(I.bind(null,null,$));else _M1[z](U._path,I);function I(Q,J){if(Q)return U.error(Q);if(Object.keys(J).forEach(function(q){Y[q]=J[q]}),U.size!==void 0&&Y.size!==U.size)return U.error("incorrect size");U.size=Y.size;var K=Rc(Y),G=Y.hardlinks!==!1;if(G&&K!=="Directory"&&Y.nlink&&Y.nlink>1){var H=Y.dev+":"+Y.ino;if(NB[H]===U._path||!NB[H])NB[H]=U._path;else K=U.type=U.props.type="Link",U.Link=U.props.Link=!0,U.linkpath=U.props.linkpath=NB[H],U._stat=U._read=KN0.prototype._read}if(U.type&&U.type!==K)U.error("Unexpected type: "+K);if(U.filter){var W=U._proxy||U;if(!U.filter.call(W,W,Y)){if(!U._disowned)U.abort(),U.emit("end"),U.emit("close");return}}var X=["_stat","stat","ready"],Z=0;(function q(){if(U._aborted){U.emit("end"),U.emit("close");return}if(U._paused&&U.type!=="Directory"){U.once("resume",q);return}var V=X[Z++];if(!V)return U._read();U.emit(V,Y),q()})()}};B5.prototype.pipe=function($){var U=this;if(typeof $.add==="function")U.on("entry",function(Y){var z=$.add(Y);if(z===!1)U.pause()});return vM1.prototype.pipe.apply(this,arguments)};B5.prototype.pause=function($){if(this._paused=!0,$=$||this,this.emit("pause",$),this._stream)this._stream.pause($)};B5.prototype.resume=function($){if(this._paused=!1,$=$||this,this.emit("resume",$),this._stream)this._stream.resume($);this._read()};B5.prototype._read=function(){this.error("Cannot read unknown type: "+this.type)}});var Sc=E((A04,wN0)=> Line truncated
expect: `+$.size+`
actual: `+$._bytesWritten);jB.prototype._finish.call($)}});var _c=E((G04,oN0)=>{oN0.exports=f2;var Rc=oI(),hw1=VZ(),Sw1=X1(),gw1=BB(),yw1=I0("fs");Sw1(f2,Rc);function f2($){var Y=this;if(!(Y instanceof f2))throw Error("ProxyWriter must be called as constructor.");Y.props=$,Y._needDrain=!1,Rc.call(Y,$)}f2.prototype._stat=function(){var $=this,Y=$.props,z=Y.follow?"stat":"lstat";yw1[z](Y.path,function(U,Q){var J;if(U||!Q)J="File";else J=hw1(Q);Y[J]=!0,Y.type=$.type=J,$._old=Q,$._addProxy(Rc(Y,Q))})};f2.prototype._addProxy=function($){var Y=this;if(Y._proxy)return Y.error("proxy already set");Y._proxy=$,["ready","error","close","pipe","drain","warn"].forEach(function(U){$.on(U,Y.emit.bind(Y,U))}),Y.emit("proxy",$);var z=Y._buffer;if(z.forEach(function(U){$[U[0]].apply($,U[1])}),Y._buffer.length=0,Y._needsDrain)Y.emit("drain")};f2.prototype.add=function($){if(gw1($),!this._proxy)return this._buffer.push(["add",[$]]),this._needDrain=!0,!1;return this._proxy.add($)};f2.prototype.write=function($){if(!this._proxy)return this._buffer.push(["write",[$]]),this._needDrain=!0,!1;return this._proxy.write($)};f2.prototype.end=function($){if(!this._proxy)return this._buffer.push(["end",[$]]),!1;return this._proxy.end($)}});var oI=E((H04,UD0)=>{UD0.exports=u$;var f$=o8(),kw1=X1(),xw1=Mc(),fw1=Pc(),NZ=I0("path"),sN0=process.platform==="win32"?0:process.umask(),aN0=VZ(),tN0=ZB();kw1(u$,tN0);u$.dirmode=parseInt("0777",8)&~sN0;u$.filemode=parseInt("0666",8)&~sN0;var uw1=Tc(),bw1=Ec(),iw1=Cc(),nw1=_c();function u$($,Y){var z=this;if(typeof $==="string")$={path:$};var U=aN0($),Q=u$;switch(U){case"Directory":Q=uw1;break;case"File":Q=iw1;break;case"Link":case"SymbolicLink":Q=bw1;break;case null:default:Q=nw1;break}if(!(z instanceof Q))return new Q($);if(tN0.call(z),!$.path)z.error("Must provide a path",null,!0);if(z.type=$.type,z.props=$,z.depth=$.depth||0,z.clobber=$.clobber===!1?$.clobber:!0,z.parent=$.parent||null,z.root=$.root||$.parent&&$.parent.root||z,z._path=z.path=NZ.resolve($.path),process.platform==="win32"){if(z.path=z._path=z.path.replace(/\?/g,"_"),z._path.length>=260)z._swallowErrors=!0,z._path="\\\\?\\"+z.path.replace(/\//g,"\\")}if(z.basename=NZ.basename($.path),z.dirname=NZ.dirname($.path),z.linkpath=$.linkpath||null,$.parent=$.root=null,z.size=$.size,typeof $.mode==="string")$.mode=parseInt($.mode,8);z.readable=!1,z.writable=!0,z._buffer=[],z.ready=!1,z.filter=typeof $.filter==="function"?$.filter:null,z._stat(Y)}u$.prototype._create=function(){var $=this;f$[$.props.follow?"stat":"lstat"]($._path,function(Y){if(Y)return $.warn("Cannot create "+$._path+`
Unsupported type: `+$.type,"ENOTSUP");$._finish()})};u$.prototype._stat=function($){var Y=this,z=Y.props,U=z.follow?"stat":"lstat",Q=Y._proxy||Y;if($)J(null,$);else f$[U](Y._path,J);function J(I,K){if(Y.filter&&!Y.filter.call(Q,Q,K)){Y._aborted=!0,Y.emit("end"),Y.emit("close");return}if(I||!K)return vc(Y);Y._old=K;var G=aN0(K);if(G!==Y.type||Y.type==="File"&&K.nlink>1)return xw1(Y._path,function(H){if(H)return Y.error(H);Y._old=null,vc(Y)});vc(Y)}};function vc($){fw1(NZ.dirname($._path),u$.dirmode,function(Y,z){if(Y)return $.error(Y);return $._madeDir=z,$._create()})}function eN0($,Y,z,U,Q){var J=Y.mode,I=Y.follow||$.type!=="SymbolicLink"?"chmod":"lchmod";if(!f$[I])return Q();if(typeof J!=="number")return Q();var K=z.mode&parseInt("0777",8);if(J=J&parseInt("0777",8),J===K)return Q();f$[I](U,J,Q)}function $D0($,Y,z,U,Q){if(process.platform==="win32")return Q();if(!process.getuid||process.getuid()!==0)return Q();if(typeof Y.uid!=="number"&&typeof Y.gid!=="number")return Q();if(z.uid===Y.uid&&z.gid===Y.gid)return Q();var J=$.props.follow||$.type!=="SymbolicLink"?"chown":"lchown";if(!f$[J])return Q();if(typeof Y.uid!=="number")Y.uid=z.uid;if(typeof Y.gid!=="number")Y.gid=z.gid;f$[J](U,Y.uid,Y.gid,Q)}function YD0($,Y,z,U,Q){if(!f$.utimes||process.platform==="win32")return Q();var J=Y.follow||$.type!=="SymbolicLink"?"utimes":"lutimes";if(J==="lutimes"&&!f$[J])J="utimes";if(!f$[J])return Q();var{atime:I,mtime:K}=z,G=Y.atime,H=Y.mtime;if(G===void 0)G=I;if(H===void 0)H=K;if(!rN0(G))G=new Date(G);if(!rN0(H))G=new Date(H);if(G.getTime()===I.getTime()&&H.getTime()===K.getTime())return Q();f$[J](U,G,H,Q)}u$.prototype._finish=function(){var $=this;if($._finishing)return;$._finishing=!0;var Y=0,z=null,U=!1;if($._old)$._old.atime=new Date(0),$._old.mtime=new Date(0),J($._old);else{var Q=$.props.follow?"stat":"lstat";f$[Q]($._path,function(K,G){if(K)if(K.code==="ENOENT"&&($.type==="Link"||$.type==="SymbolicLink")&&process.platform==="win32"){$.ready=!0,$.emit("ready"),$.emit("end"),$.emit("close"),$.end=$._finish=function(){};return}else return $.error(K);J($._old=G)})}return;function J(K){Y+=3,eN0($,$.props,K,$._path,I("chmod")),$D0($,$.props,K,$._path,I("chown")),YD0($,$.props,K,$._path,I("utimes"))}function I(K){return function(G){if(z)return;if(G)return G.fstream_finish_call=K,$.error(z=G);if(--Y>0)return;if(U)return;if(U=!0,!$._madeDir)return H();else zD0($,$._path,H);function H(W){if(W)return W.fstream_finish_call="setupMadeDir",$.error(W);$.emit("end"),$.emit("close")}}}};function zD0($,Y,z){var U=$._madeDir,Q=NZ.dirname(Y);cw1($,Q,function(J){if(J)return z(J);if(Q===U)return z();zD0($,Q,z)})}function cw1($,Y,z){var U={};Object.keys($.props).forEach(function(K){if(U[K]=$.props[K],K==="mode"&&$.type!=="Directory")U[K]=U[K]|parseInt("0111",8)});var Q=3,J=null;f$.stat(Y,function(K,G){if(K)return z(J=K);eN0($,U,G,Y,I),$D0($,U,G,Y,I),YD0($,U,G,Y,I)});function I(K){if(J)return;if(K)return z(J=K);if(--Q===0)return z()}}u$.prototype.pipe=function(){this.error("Can't pipe from writable stream")};u$.prototype.add=function(){this.error("Can't add to non-Directory type")};u$.prototype.write=function(){return!0};function pw1($){return Object.prototype.toString.call($)}function rN0($){return typeof $==="object"&&pw1($)==="[object Date]"}});var kc=E((dw1)=>{dw1.Abstract=ZB();dw1.Reader=IU();dw1.Writer=oI();dw1.File={Reader:Xc(),Writer:Cc()};dw1.Dir={Reader:Wc(),Writer:Tc()};dw1.Link={Reader:Gc(),Writer:Ec()};dw1.Proxy={Reader:qc(),Writer:_c()};dw1.Reader.Dir=dw1.DirReader=dw1.Dir.Reader;dw1.Reader.File=dw1.FileReader=dw1.File.Reader;dw1.Reader.Link=dw1.LinkReader=dw1.Link.Reader;dw1.Reader.Proxy=dw1.ProxyReader=dw1.Proxy.Reader;dw1.Writer.Dir=dw1.DirWriter=dw1.Dir.Writer;dw1.Writer.File=dw1.FileWriter=dw1.File.Writer;dw1.Writer.Link=dw1.LinkWriter=dw1.Link.Writer;dw1.Writer.Proxy=dw1.ProxyWriter=dw1.Proxy.Writer;dw1.collect=BB()});var JD0=E((M04,QD0)=>{QD0.exports=ew1;var ow1=UB(),rw1=kc().Writer,xc=I0("path"),sw1=I0("stream"),aw1=Jc(),tw1=v2();function ew1($){$.path=xc.resolve(xc.normalize($.path));var Y=new ow1($),z=new sw1.Writable({objectMode:!0});z._write=function(Q,J,I){if(Q.type=="Directory")return I();var K=xc.join($.path,Q.path);if(K.indexOf($.path)!=0)return I();let G=$.getWriter?$.getWriter({path:K}):rw1({path:K});Q.pipe(G).on("error",I).on("close",I)};var U=aw1(Y,z);return Y.once("crx-header",function(Q){U.crxHeader=Q}),Y.pipe(z).on("finish",function(){U.emit("close")}),U.promise=function(){return new tw1(function(Q,J){U.on("close",Q),U.on("error",J)})},U}});var ID0=E((N04,TB)=>{var E6=function($){var Y=1e7,z=7,U=9007199254740992,Q=Z(U),J="0123456789abcdefghijklmnopqrstuvwxyz",I=typeof BigInt==="function";function K(B,v,u,a){if(typeof B>"u")return K[0];if(typeof v<"u")return+v===10&&!u?A0(B):b0(B,v,u,a);return A0(B)}function G(B,v){this.value=B,this.sign=v,this.isSmall=!1}G.prototype=Object.create(K.prototype);function H(B){this.value=B,this.sign=B<0,this.isSmall=!0}H.prototype=Object.create(K.prototype);function W(B){ Line truncated
actual: `+$._bytesWritten);vB.prototype._finish.call($)}});var dc=E((b04,QD0)=>{QD0.exports=u2;var cc=rJ(),JO1=wZ(),KO1=W1(),GO1=RB(),HO1=J0("fs");KO1(u2,cc);function u2($){var U=this;if(!(U instanceof u2))throw Error("ProxyWriter must be called as constructor.");U.props=$,U._needDrain=!1,cc.call(U,$)}u2.prototype._stat=function(){var $=this,U=$.props,Y=U.follow?"stat":"lstat";HO1[Y](U.path,function(z,I){var Q;if(z||!I)Q="File";else Q=JO1(I);U[Q]=!0,U.type=$.type=Q,$._old=I,$._addProxy(cc(U,I))})};u2.prototype._addProxy=function($){var U=this;if(U._proxy)return U.error("proxy already set");U._proxy=$,["ready","error","close","pipe","drain","warn"].forEach(function(z){$.on(z,U.emit.bind(U,z))}),U.emit("proxy",$);var Y=U._buffer;if(Y.forEach(function(z){$[z[0]].apply($,z[1])}),U._buffer.length=0,U._needsDrain)U.emit("drain")};u2.prototype.add=function($){if(GO1($),!this._proxy)return this._buffer.push(["add",[$]]),this._needDrain=!0,!1;return this._proxy.add($)};u2.prototype.write=function($){if(!this._proxy)return this._buffer.push(["write",[$]]),this._needDrain=!0,!1;return this._proxy.write($)};u2.prototype.end=function($){if(!this._proxy)return this._buffer.push(["end",[$]]),!1;return this._proxy.end($)}});var rJ=E((i04,VD0)=>{VD0.exports=i$;var b$=r8(),WO1=W1(),XO1=Sc(),ZO1=fc(),AZ=J0("path"),KD0=process.platform==="win32"?0:process.umask(),GD0=wZ(),HD0=MB();WO1(i$,HD0);i$.dirmode=parseInt("0777",8)&~KD0;i$.filemode=parseInt("0666",8)&~KD0;var qO1=bc(),VO1=ic(),LO1=nc(),wO1=dc();function i$($,U){var Y=this;if(typeof $==="string")$={path:$};var z=GD0($),I=i$;switch(z){case"Directory":I=qO1;break;case"File":I=LO1;break;case"Link":case"SymbolicLink":I=VO1;break;case null:default:I=wO1;break}if(!(Y instanceof I))return new I($);if(HD0.call(Y),!$.path)Y.error("Must provide a path",null,!0);if(Y.type=$.type,Y.props=$,Y.depth=$.depth||0,Y.clobber=$.clobber===!1?$.clobber:!0,Y.parent=$.parent||null,Y.root=$.root||$.parent&&$.parent.root||Y,Y._path=Y.path=AZ.resolve($.path),process.platform==="win32"){if(Y.path=Y._path=Y.path.replace(/\?/g,"_"),Y._path.length>=260)Y._swallowErrors=!0,Y._path="\\\\?\\"+Y.path.replace(/\//g,"\\")}if(Y.basename=AZ.basename($.path),Y.dirname=AZ.dirname($.path),Y.linkpath=$.linkpath||null,$.parent=$.root=null,Y.size=$.size,typeof $.mode==="string")$.mode=parseInt($.mode,8);Y.readable=!1,Y.writable=!0,Y._buffer=[],Y.ready=!1,Y.filter=typeof $.filter==="function"?$.filter:null,Y._stat(U)}i$.prototype._create=function(){var $=this;b$[$.props.follow?"stat":"lstat"]($._path,function(U){if(U)return $.warn("Cannot create "+$._path+`
Unsupported type: `+$.type,"ENOTSUP");$._finish()})};i$.prototype._stat=function($){var U=this,Y=U.props,z=Y.follow?"stat":"lstat",I=U._proxy||U;if($)Q(null,$);else b$[z](U._path,Q);function Q(J,K){if(U.filter&&!U.filter.call(I,I,K)){U._aborted=!0,U.emit("end"),U.emit("close");return}if(J||!K)return pc(U);U._old=K;var G=GD0(K);if(G!==U.type||U.type==="File"&&K.nlink>1)return XO1(U._path,function(H){if(H)return U.error(H);U._old=null,pc(U)});pc(U)}};function pc($){ZO1(AZ.dirname($._path),i$.dirmode,function(U,Y){if(U)return $.error(U);return $._madeDir=Y,$._create()})}function WD0($,U,Y,z,I){var Q=U.mode,J=U.follow||$.type!=="SymbolicLink"?"chmod":"lchmod";if(!b$[J])return I();if(typeof Q!=="number")return I();var K=Y.mode&parseInt("0777",8);if(Q=Q&parseInt("0777",8),Q===K)return I();b$[J](z,Q,I)}function XD0($,U,Y,z,I){if(process.platform==="win32")return I();if(!process.getuid||process.getuid()!==0)return I();if(typeof U.uid!=="number"&&typeof U.gid!=="number")return I();if(Y.uid===U.uid&&Y.gid===U.gid)return I();var Q=$.props.follow||$.type!=="SymbolicLink"?"chown":"lchown";if(!b$[Q])return I();if(typeof U.uid!=="number")U.uid=Y.uid;if(typeof U.gid!=="number")U.gid=Y.gid;b$[Q](z,U.uid,U.gid,I)}function ZD0($,U,Y,z,I){if(!b$.utimes||process.platform==="win32")return I();var Q=U.follow||$.type!=="SymbolicLink"?"utimes":"lutimes";if(Q==="lutimes"&&!b$[Q])Q="utimes";if(!b$[Q])return I();var{atime:J,mtime:K}=Y,G=U.atime,H=U.mtime;if(G===void 0)G=J;if(H===void 0)H=K;if(!JD0(G))G=new Date(G);if(!JD0(H))G=new Date(H);if(G.getTime()===J.getTime()&&H.getTime()===K.getTime())return I();b$[Q](z,G,H,I)}i$.prototype._finish=function(){var $=this;if($._finishing)return;$._finishing=!0;var U=0,Y=null,z=!1;if($._old)$._old.atime=new Date(0),$._old.mtime=new Date(0),Q($._old);else{var I=$.props.follow?"stat":"lstat";b$[I]($._path,function(K,G){if(K)if(K.code==="ENOENT"&&($.type==="Link"||$.type==="SymbolicLink")&&process.platform==="win32"){$.ready=!0,$.emit("ready"),$.emit("end"),$.emit("close"),$.end=$._finish=function(){};return}else return $.error(K);Q($._old=G)})}return;function Q(K){U+=3,WD0($,$.props,K,$._path,J("chmod")),XD0($,$.props,K,$._path,J("chown")),ZD0($,$.props,K,$._path,J("utimes"))}function J(K){return function(G){if(Y)return;if(G)return G.fstream_finish_call=K,$.error(Y=G);if(--U>0)return;if(z)return;if(z=!0,!$._madeDir)return H();else qD0($,$._path,H);function H(W){if(W)return W.fstream_finish_call="setupMadeDir",$.error(W);$.emit("end"),$.emit("close")}}}};function qD0($,U,Y){var z=$._madeDir,I=AZ.dirname(U);FO1($,I,function(Q){if(Q)return Y(Q);if(I===z)return Y();qD0($,I,Y)})}function FO1($,U,Y){var z={};Object.keys($.props).forEach(function(K){if(z[K]=$.props[K],K==="mode"&&$.type!=="Directory")z[K]=z[K]|parseInt("0111",8)});var I=3,Q=null;b$.stat(U,function(K,G){if(K)return Y(Q=K);WD0($,z,G,U,J),XD0($,z,G,U,J),ZD0($,z,G,U,J)});function J(K){if(Q)return;if(K)return Y(Q=K);if(--I===0)return Y()}}i$.prototype.pipe=function(){this.error("Can't pipe from writable stream")};i$.prototype.add=function(){this.error("Can't add to non-Directory type")};i$.prototype.write=function(){return!0};function MO1($){return Object.prototype.toString.call($)}function JD0($){return typeof $==="object"&&MO1($)==="[object Date]"}});var sc=E((OO1)=>{OO1.Abstract=MB();OO1.Reader=Jz();OO1.Writer=rJ();OO1.File={Reader:Tc(),Writer:nc()};OO1.Dir={Reader:Pc(),Writer:bc()};OO1.Link={Reader:Ac(),Writer:ic()};OO1.Proxy={Reader:Ec(),Writer:dc()};OO1.Reader.Dir=OO1.DirReader=OO1.Dir.Reader;OO1.Reader.File=OO1.FileReader=OO1.File.Reader;OO1.Reader.Link=OO1.LinkReader=OO1.Link.Reader;OO1.Reader.Proxy=OO1.ProxyReader=OO1.Proxy.Reader;OO1.Writer.Dir=OO1.DirWriter=OO1.Dir.Writer;OO1.Writer.File=OO1.FileWriter=OO1.File.Writer;OO1.Writer.Link=OO1.LinkWriter=OO1.Link.Writer;OO1.Writer.Proxy=OO1.ProxyWriter=OO1.Proxy.Writer;OO1.collect=RB()});var wD0=E((a04,LD0)=>{LD0.exports=EO1;var AO1=HB(),BO1=sc().Writer,ac=J0("path"),PO1=J0("stream"),TO1=Oc(),jO1=h2();function EO1($){$.path=ac.resolve(ac.normalize($.path));var U=new AO1($),Y=new PO1.Writable({objectMode:!0});Y._write=function(I,Q,J){if(I.type=="Directory")return J();var K=ac.join($.path,I.path);if(K.indexOf($.path)!=0)return J();let G=$.getWriter?$.getWriter({path:K}):BO1({path:K});I.pipe(G).on("error",J).on("close",J)};var z=TO1(U,Y);return U.once("crx-header",function(I){z.crxHeader=I}),U.pipe(Y).on("finish",function(){z.emit("close")}),z.promise=function(){return new jO1(function(I,Q){z.on("close",I),z.on("error",Q)})},z}});var FD0=E((t04,hB)=>{var E6=function($){var U=1e7,Y=7,z=9007199254740992,I=Z(z),Q="0123456789abcdefghijklmnopqrstuvwxyz",J=typeof BigInt==="function";function K(B,h,u,s){if(typeof B>"u")return K[0];if(typeof h<"u")return+h===10&&!u?D0(B):u0(B,h,u,s);return D0(B)}function G(B,h){this.value=B,this.sign=h,this.isSmall=!1}G.prototype=Object.create(K.prototype);function H(B){this.value=B,this.sign=B<0,this.isSmall=!0}H.prototype=Object.create(K.prototype);function W(B){ Line truncated
* Tmp
*
* Copyright (c) 2011-2017 KARASZI Istvan <github@spam.raszi.hu>
*
* MIT Licensed
*/var V4=I0("fs"),hB=I0("os"),C6=I0("path"),MD0=I0("crypto"),A9={fs:V4.constants,os:hB.constants},BD0=/XXXXXX/,PD0=(A9.O_CREAT||A9.fs.O_CREAT)|(A9.O_EXCL||A9.fs.O_EXCL)|(A9.O_RDWR||A9.fs.O_RDWR),BM1=hB.platform()==="win32",PM1=A9.EBADF||A9.os.errno.EBADF,jM1=A9.ENOENT||A9.os.errno.ENOENT,sI=[],jD0=V4.rmdirSync.bind(V4),TD0=!1;function TM1($,Y){return V4.rm($,{recursive:!0},Y)}function ED0($){return V4.rmSync($,{recursive:!0})}function nc($,Y){let z=aI($,Y),U=z[0],Q=z[1];kM1(U,function(J,I){if(J)return Q(J);let K=I.tries;(function G(){try{let H=RD0(I);V4.stat(H,function(W){if(!W){if(K-- >0)return G();return Q(Error("Could not get a unique tmp filename, max tries reached "+H))}Q(null,H)})}catch(H){Q(H)}})()})}function cc($){let Y=aI($),z=Y[0],U=xM1(z),Q=U.tries;do{let J=RD0(U);try{V4.statSync(J)}catch(I){return J}}while(Q-- >0);throw Error("Could not get a unique tmp filename, max tries reached")}function EM1($,Y){let z=aI($,Y),U=z[0],Q=z[1];nc(U,function(I,K){if(I)return Q(I);V4.open(K,PD0,U.mode||384,function(H,W){if(H)return Q(H);if(U.discardDescriptor)return V4.close(W,function(Z){return Q(Z,K,void 0,bc(K,-1,U,!1))});else{let X=U.discardDescriptor||U.detachDescriptor;Q(null,K,W,bc(K,X?-1:W,U,!1))}})})}function CM1($){let Y=aI($),z=Y[0],U=z.discardDescriptor||z.detachDescriptor,Q=cc(z),J=V4.openSync(Q,PD0,z.mode||384);if(z.discardDescriptor)V4.closeSync(J),J=void 0;return{name:Q,fd:J,removeCallback:bc(Q,U?-1:J,z,!0)}}function RM1($,Y){let z=aI($,Y),U=z[0],Q=z[1];nc(U,function(I,K){if(I)return Q(I);V4.mkdir(K,U.mode||448,function(H){if(H)return Q(H);Q(null,K,CD0(K,U,!1))})})}function _M1($){let Y=aI($),z=Y[0],U=cc(z);return V4.mkdirSync(U,z.mode||448),{name:U,removeCallback:CD0(U,z,!0)}}function vM1($,Y){let z=function(U){if(U&&!ic(U))return Y(U);Y()};if(0<=$[0])V4.close($[0],function(){V4.unlink($[1],z)});else V4.unlink($[1],z)}function hM1($){let Y=null;try{if(0<=$[0])V4.closeSync($[0])}catch(z){if(!fM1(z)&&!ic(z))throw z}finally{try{V4.unlinkSync($[1])}catch(z){if(!ic(z))Y=z}}if(Y!==null)throw Y}function bc($,Y,z,U){let Q=vB(hM1,[Y,$],U),J=vB(vM1,[Y,$],U,Q);if(!z.keep)sI.unshift(Q);return U?Q:J}function CD0($,Y,z){let U=Y.unsafeCleanup?TM1:V4.rmdir.bind(V4),Q=Y.unsafeCleanup?ED0:jD0,J=vB(Q,$,z),I=vB(U,$,z,J);if(!Y.keep)sI.unshift(J);return z?J:I}function vB($,Y,z,U){let Q=!1;return function J(I){if(!Q){let K=U||J,G=sI.indexOf(K);if(G>=0)sI.splice(G,1);if(Q=!0,z||$===jD0||$===ED0)return $(Y);else return $(Y,I||function(){})}}}function SM1(){if(!TD0)return;while(sI.length)try{sI[0]()}catch($){}}function ND0($){let Y=[],z=null;try{z=MD0.randomBytes($)}catch(U){z=MD0.pseudoRandomBytes($)}for(let U=0;U<$;U++)Y.push("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"[z[U]%62]);return Y.join("")}function s8($){return typeof $>"u"}function aI($,Y){if(typeof $==="function")return[{},$];if(s8($))return[{},Y];let z={};for(let U of Object.getOwnPropertyNames($))z[U]=$[U];return[z,Y]}function gM1($,Y,z){let U=C6.isAbsolute($)?$:C6.join(Y,$);V4.stat(U,function(Q){if(Q)V4.realpath(C6.dirname(U),function(J,I){if(J)return z(J);z(null,C6.join(I,C6.basename(U)))});else V4.realpath(U,z)})}function yM1($,Y){let z=C6.isAbsolute($)?$:C6.join(Y,$);try{return V4.statSync(z),V4.realpathSync(z)}catch(U){let Q=V4.realpathSync(C6.dirname(z));return C6.join(Q,C6.basename(z))}}function RD0($){let Y=$.tmpdir;if(!s8($.name))return C6.join(Y,$.dir,$.name);if(!s8($.template))return C6.join(Y,$.dir,$.template).replace(BD0,ND0(6));let z=[$.prefix?$.prefix:"tmp","-",process.pid,"-",ND0(12),$.postfix?"-"+$.postfix:""].join("");return C6.join(Y,$.dir,z)}function uc($,Y){if(typeof Y!=="string")throw Error(`${$} option must be a string, got "${typeof Y}".`);if(Y.includes(".."))throw Error("Relative value not allowed");return Y}function _D0($){if(!s8($.name)){let Y=$.name;if(C6.isAbsolute(Y))throw Error(`name option must not contain an absolute path, found "${Y}".`);let z=C6.basename(Y);if(z===".."||z==="."||z!==Y)throw Error(`name option must not contain a path, found "${Y}".`)}if(!s8($.template)){if(typeof $.template!=="string")throw Error(`template option must be a string, got "${typeof $.template}".`);if(!$.template.match(BD0))throw Error(`Invalid template, found "${$.template}".`)}if(!s8($.tries)&&isNaN($.tries)||$.tries<0)throw Error(`Invalid tries, found "${$.tries}".`);$.tries=s8($.name)?$.tries||3:1,$.keep=!!$.keep,$.detachDescriptor=!!$.detachDescriptor,$.discardDescriptor=!!$.discardDescriptor,$.unsafeCleanup=!!$.unsafeCleanup,$.prefix=s8($.prefix)?"":uc("prefix",$.prefix),$.postfix=s8($.postfix)?"":uc("postfix",$.postfix),$.template=s8($.template)?void 0:uc("template",$.template)}function DD0($,Y,z,U){if(s8(Y))return U(null);gM1(Y,z,function(Q,J){if(Q)return U(Q);let I=C6.relative(z,J);if(I.startsWith("..")||C6.isAbsolute(I))return U(Error(`${$} option must be relative to "${z}", found "${I}".`));U(null,I)})}function AD0($,Y,z){if(s8(Y))return;let U=yM1(Y,z),Q=C6.relative(z,U);if(Q.startsWith("..")||C6.isAbsolute(Q))thrLine truncated
`)}let U=[];Y.forEach((Q,J)=>{let I=$.length+J+1,K=J===0?"⏳ ":"";U.push(`${K}${I}. ${Q}`)});for(let Q=$.length-1;Q>=0;Q--){let J=Q+1;U.push(`${J}. ${$[Q]}`)}return U.join(`
`)}function $p($,Y,z,U,Q){let J=$?.operator||Y?.operator||z?.operator,I=J?.name||J?.id||z?.operatorName||"",K=($?.nodeName||Y?.fromNodeName||Y?.nodeName||z?.nodeName||"").trim();if(K==="合思审批节点"||K==="外部审批节点"||K.includes("合思审批")||K.includes("外部审批"))K="";if((!K||K==="提交人"||K==="审批节点")&&I&&U){let w=U.find((O)=>O.operator?.name===I&&O.nodeName&&O.nodeName.trim()!=="提交人"&&!O.isEbot&&O.rawAction!=="freeflow.reject");if(w?.nodeName)K=w.nodeName.trim()}let H=$?.comment||Y?.reason||z?.rejectComment||"修改";if(H.includes(":")){let w=H.split(":");if(w.length>1)H=w.slice(1).join(":").trim()}let W=H;if(K&&I)W=`${K}(${I}) ❌: ${H}`;else if(I)W=`${I} ❌: ${H}`;else if(K)W=`${K} ❌: ${H}`;else W=H;let X=$?.rejectTargetNodeName||Y?.targetNodeName||"提交人",Z=$?.rejectTargetOperator?.name||Y?.targetOperator?.name||Q?.submitter?.name,q=Z?`${X}(${Z})`:X,V=$?.resubmitRuleText||Y?.resubmitRuleText||(I?`重新提交后由${I}继续审批`:"重新提交后继续审批");return{comment:`${W}
*/var L4=J0("fs"),fB=J0("os"),C6=J0("path"),_D0=J0("crypto"),P9={fs:L4.constants,os:fB.constants},gD0=/XXXXXX/,yD0=(P9.O_CREAT||P9.fs.O_CREAT)|(P9.O_EXCL||P9.fs.O_EXCL)|(P9.O_RDWR||P9.fs.O_RDWR),aO1=fB.platform()==="win32",tO1=P9.EBADF||P9.os.errno.EBADF,eO1=P9.ENOENT||P9.os.errno.ENOENT,aJ=[],kD0=L4.rmdirSync.bind(L4),xD0=!1;function $N1($,U){return L4.rm($,{recursive:!0},U)}function fD0($){return L4.rmSync($,{recursive:!0})}function Yd($,U){let Y=tJ($,U),z=Y[0],I=Y[1];WN1(z,function(Q,J){if(Q)return I(Q);let K=J.tries;(function G(){try{let H=bD0(J);L4.stat(H,function(W){if(!W){if(K-- >0)return G();return I(Error("Could not get a unique tmp filename, max tries reached "+H))}I(null,H)})}catch(H){I(H)}})()})}function zd($){let U=tJ($),Y=U[0],z=XN1(Y),I=z.tries;do{let Q=bD0(z);try{L4.statSync(Q)}catch(J){return Q}}while(I-- >0);throw Error("Could not get a unique tmp filename, max tries reached")}function UN1($,U){let Y=tJ($,U),z=Y[0],I=Y[1];Yd(z,function(J,K){if(J)return I(J);L4.open(K,yD0,z.mode||384,function(H,W){if(H)return I(H);if(z.discardDescriptor)return L4.close(W,function(Z){return I(Z,K,void 0,$d(K,-1,z,!1))});else{let X=z.discardDescriptor||z.detachDescriptor;I(null,K,W,$d(K,X?-1:W,z,!1))}})})}function YN1($){let U=tJ($),Y=U[0],z=Y.discardDescriptor||Y.detachDescriptor,I=zd(Y),Q=L4.openSync(I,yD0,Y.mode||384);if(Y.discardDescriptor)L4.closeSync(Q),Q=void 0;return{name:I,fd:Q,removeCallback:$d(I,z?-1:Q,Y,!0)}}function zN1($,U){let Y=tJ($,U),z=Y[0],I=Y[1];Yd(z,function(J,K){if(J)return I(J);L4.mkdir(K,z.mode||448,function(H){if(H)return I(H);I(null,K,uD0(K,z,!1))})})}function IN1($){let U=tJ($),Y=U[0],z=zd(Y);return L4.mkdirSync(z,Y.mode||448),{name:z,removeCallback:uD0(z,Y,!0)}}function QN1($,U){let Y=function(z){if(z&&!Ud(z))return U(z);U()};if(0<=$[0])L4.close($[0],function(){L4.unlink($[1],Y)});else L4.unlink($[1],Y)}function JN1($){let U=null;try{if(0<=$[0])L4.closeSync($[0])}catch(Y){if(!ZN1(Y)&&!Ud(Y))throw Y}finally{try{L4.unlinkSync($[1])}catch(Y){if(!Ud(Y))U=Y}}if(U!==null)throw U}function $d($,U,Y,z){let I=xB(JN1,[U,$],z),Q=xB(QN1,[U,$],z,I);if(!Y.keep)aJ.unshift(I);return z?I:Q}function uD0($,U,Y){let z=U.unsafeCleanup?$N1:L4.rmdir.bind(L4),I=U.unsafeCleanup?fD0:kD0,Q=xB(I,$,Y),J=xB(z,$,Y,Q);if(!U.keep)aJ.unshift(Q);return Y?Q:J}function xB($,U,Y,z){let I=!1;return function Q(J){if(!I){let K=z||Q,G=aJ.indexOf(K);if(G>=0)aJ.splice(G,1);if(I=!0,Y||$===kD0||$===fD0)return $(U);else return $(U,J||function(){})}}}function KN1(){if(!xD0)return;while(aJ.length)try{aJ[0]()}catch($){}}function vD0($){let U=[],Y=null;try{Y=_D0.randomBytes($)}catch(z){Y=_D0.pseudoRandomBytes($)}for(let z=0;z<$;z++)U.push("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"[Y[z]%62]);return U.join("")}function a8($){return typeof $>"u"}function tJ($,U){if(typeof $==="function")return[{},$];if(a8($))return[{},U];let Y={};for(let z of Object.getOwnPropertyNames($))Y[z]=$[z];return[Y,U]}function GN1($,U,Y){let z=C6.isAbsolute($)?$:C6.join(U,$);L4.stat(z,function(I){if(I)L4.realpath(C6.dirname(z),function(Q,J){if(Q)return Y(Q);Y(null,C6.join(J,C6.basename(z)))});else L4.realpath(z,Y)})}function HN1($,U){let Y=C6.isAbsolute($)?$:C6.join(U,$);try{return L4.statSync(Y),L4.realpathSync(Y)}catch(z){let I=L4.realpathSync(C6.dirname(Y));return C6.join(I,C6.basename(Y))}}function bD0($){let U=$.tmpdir;if(!a8($.name))return C6.join(U,$.dir,$.name);if(!a8($.template))return C6.join(U,$.dir,$.template).replace(gD0,vD0(6));let Y=[$.prefix?$.prefix:"tmp","-",process.pid,"-",vD0(12),$.postfix?"-"+$.postfix:""].join("");return C6.join(U,$.dir,Y)}function ec($,U){if(typeof U!=="string")throw Error(`${$} option must be a string, got "${typeof U}".`);if(U.includes(".."))throw Error("Relative value not allowed");return U}function iD0($){if(!a8($.name)){let U=$.name;if(C6.isAbsolute(U))throw Error(`name option must not contain an absolute path, found "${U}".`);let Y=C6.basename(U);if(Y===".."||Y==="."||Y!==U)throw Error(`name option must not contain a path, found "${U}".`)}if(!a8($.template)){if(typeof $.template!=="string")throw Error(`template option must be a string, got "${typeof $.template}".`);if(!$.template.match(gD0))throw Error(`Invalid template, found "${$.template}".`)}if(!a8($.tries)&&isNaN($.tries)||$.tries<0)throw Error(`Invalid tries, found "${$.tries}".`);$.tries=a8($.name)?$.tries||3:1,$.keep=!!$.keep,$.detachDescriptor=!!$.detachDescriptor,$.discardDescriptor=!!$.discardDescriptor,$.unsafeCleanup=!!$.unsafeCleanup,$.prefix=a8($.prefix)?"":ec("prefix",$.prefix),$.postfix=a8($.postfix)?"":ec("postfix",$.postfix),$.template=a8($.template)?void 0:ec("template",$.template)}function hD0($,U,Y,z){if(a8(U))return z(null);GN1(U,Y,function(I,Q){if(I)return z(I);let J=C6.relative(Y,Q);if(J.startsWith("..")||C6.isAbsolute(J))return z(Error(`${$} option must be relative to "${Y}", found "${J}".`));z(null,J)})}function SD0($,U,Y){if(a8(U))return;let z=HN1(U,Y),I=C6.relative(Y,z);if(I.startsWith("..")||C6.isAbsolute(I))thrLine truncated
`)}let z=[];U.forEach((I,Q)=>{let J=$.length+Q+1,K=Q===0?"⏳ ":"";z.push(`${K}${J}. ${I}`)});for(let I=$.length-1;I>=0;I--){let Q=I+1;z.push(`${Q}. ${$[I]}`)}return z.join(`
`)}function Vd($,U,Y,z,I){let Q=$?.operator||U?.operator||Y?.operator,J=Q?.name||Q?.id||Y?.operatorName||"",K=($?.nodeName||U?.fromNodeName||U?.nodeName||Y?.nodeName||"").trim();if(K==="合思审批节点"||K==="外部审批节点"||K.includes("合思审批")||K.includes("外部审批"))K="";if((!K||K==="提交人"||K==="审批节点")&&J&&z){let M=z.find((w)=>w.operator?.name===J&&w.nodeName&&w.nodeName.trim()!=="提交人"&&!w.isEbot&&w.rawAction!=="freeflow.reject");if(M?.nodeName)K=M.nodeName.trim()}let H=$?.comment||U?.reason||Y?.rejectComment||"修改";if(H.includes(":")){let M=H.split(":");if(M.length>1)H=M.slice(1).join(":").trim()}let W=H;if(K&&J)W=`${K}(${J}) ❌: ${H}`;else if(J)W=`${J} ❌: ${H}`;else if(K)W=`${K} ❌: ${H}`;else W=H;let X=$?.rejectTargetNodeName||U?.targetNodeName||"提交人",Z=$?.rejectTargetOperator?.name||U?.targetOperator?.name||I?.submitter?.name,q=Z?`${X}(${Z})`:X,V=$?.resubmitRuleText||U?.resubmitRuleText||(J?`重新提交后由${J}继续审批`:"重新提交后继续审批");return{comment:`${W}
↳ 驳回至: ${q}
↳ ${V}`,operator:J}}function qA0($){if(!$)return[];let Y=$.pending||[],z=String($.rawState||"").toUpperCase(),U=String($.state||"").toUpperCase(),Q=[];if(Y.length>0)for(let J of Y){let I=J.approver?.name||J.approver?.id||"待定",K=(J.name||$.currentNode||"").trim(),G=K?`${K}(${I})`:I,W=J.type?.toUpperCase()==="PAYING"||K.includes("支付")||z==="PAYING"||U==="支付中"?"待支付":"待审批";Q.push(`${G}: ${W}`)}else if($.currentNode?.trim()){let I=$.currentNode.includes("支付")||z==="PAYING"||U==="支付中"?"待支付":"待审批";Q.push(`${$.currentNode.trim()}: ${I}`)}return Q}function XU($,Y){let z=new Map;if(!$||$.length===0)return z;if(!Y){for(let q of $){let F=(q.result||{}).decision||q.aiDecision||"-";z.set(q.id,{recordId:q.id,sourceDocumentSN:q.sourceDocumentSN,taskMode:q.taskMode,aiDecision:ZA0(typeof F==="string"?F:"-"),aiAction:"-",eHumanAction:"-",eHumanComment:"-",auditDrift:!1})}return z}let U=[...$].sort((q,V)=>(Number(q.createdAt)||0)-(Number(V.createdAt)||0)),Q=Y.history||[],J=String(Y.rawState||"").toUpperCase(),I=String(Y.state||"").toUpperCase(),K=J==="DRAFT"||J==="REVOKED"||J==="CANCELED"||J==="CANCELLED"||I==="草稿"||I==="已撤回"||I==="已取消",G=J==="REJECTED"||J==="TERMINATED"||I==="审批驳回"||I==="已驳回",H=!K&&!G&&(J==="PAID"||I==="已支付"||Q.some((q)=>!q.isEbot&&(q.rawAction==="freeflow.pay"||q.action==="支付成功"||q.action==="支付完成"))),W=!K&&!G&&!H&&(J==="PAYING"||I==="支付中"||(Y.pending||[]).some((q)=>q.isCurrent&&(q.type?.toUpperCase()==="PAYING"||q.name?.includes("支付")))||Y.currentNode?.includes("支付")===!0),Z=H||!K&&!G&&!W&&(J==="COMPLETED"||J==="APPROVED"||I==="已完成"||I==="审批通过");for(let q=0;q<U.length;q++){let V=U[q];if(!V)continue;let F=Number(V.createdAt)||0,w=V.document||{},O=V.manualApprovalRecord||V.result?.manualApprovalRecord||w.manualApprovalRecord||{},N=typeof V.sourceExtendData?.nodeId==="string"?String(V.sourceExtendData.nodeId):void 0,M=typeof O.nodeId==="string"?String(O.nodeId):void 0,D=M?decodeURIComponent(M).replace(/^hcnode_/,"").replace(/_r\d+$/,""):void 0,P=N||D,j=P?Q.find((A0)=>A0.nodeId&&(A0.nodeId===P||P.includes(A0.nodeId))):void 0,A=j?.time??F,T=U[q+1],C=T?Number(T.createdAt)||1/0:1/0,b=q===U.length-1,k=Q.find((A0)=>(A0.time??0)>A+5000&&A0.isEbot&&(A0.nodeName?.includes("智能")||A0.nodeName?.includes("AI")||A0.action?.includes("智能")||A0.comment?.includes("AI")||A0.comment?.includes("approval-result"))&&!A0.nodeName?.includes("费用标准检查")&&!A0.nodeName?.includes("标准检查")&&!A0.nodeName?.includes("预算"));if(k){if(b=!1,(k.time??1/0)<C)C=k.time}let S=V.result||{},i=S.decision||V.aiDecision||"-",n=typeof i==="string"?i:"-",U0=n.toUpperCase(),x=U0==="REJECT"||U0==="驳回",d=U0==="APPROVE"||U0==="通过",t=U0==="EXEMPT_APPROVE"||U0==="免审通过"||U0==="备注通过",e=V.taskMode||V.finalExecutionMode||"",p=String(e).toLowerCase().includes("auto")||V.finalExecutionMode==="automatic"||e==="automatic"||e==="fully_automatic",Y0="-";if(d||t)Y0="添加评论";else if(x)Y0=p?"驳回":"添加评论";else if(U0==="REVIEW"||U0==="转交复核")Y0="转交复核";let y=typeof O.status==="object"&&O.status!==null?String(O.status.type||O.status.label||"").toUpperCase():"",r=typeof O.status==="object"&&O.status!==null?String(O.status.sourceStatus||""):"",$0=w.manualApprovalStatus||S.manualApprovalStatus||V.manualApprovalStatus,N0=typeof $0==="string"?$0.toUpperCase():"",T0=N0==="CANCELLED"||N0==="CANCELED"||N0==="已取消"||N0==="已撤回"||N0==="REVOKED"||y==="CANCELLED"||y==="CANCELED"||r.includes("撤回")||r.includes("取消"),_0=N0==="APPROVED"||N0==="已支付/审批完成"||N0==="已通过"||N0==="已完成"||N0==="已支付"||y==="APPROVED",f0=!(r.includes("补偿")||r.includes("已支付"))&&(N0==="TERMINATED"||N0==="REJECTED"||N0==="REJECT"||N0==="已驳回"||N0==="被驳回"||y==="TERMINATED"||y==="REJECTED"||y==="已驳回"||y==="被驳回"),e0=j?1000:60000,s=Q.filter((A0)=>{let Q0=A0.time??0;return Q0>=A-e0&&Q0<C}),H0="-",F0="-",b0=!1,i0,n0,w1=d||t,k1=Q.filter((A0)=>(A0.time??0)>A+5000),u1=k1.some((A0)=>A0.rawAction==="freeflow.retract"||A0.action==="单据撤回"),b1=k1.some((A0)=>A0.rawAction==="freeflow.submit"||A0.action==="提交送审");if(w1&&b&&(u1||b1))b0=!0,i0="AI通过后单据发生撤回/修改重提,后续未经AI复审";if(p&&x)H0="无操作",F0="-";else{let A0=s.filter((v)=>(v.time??0)>=A-1000&&!v.isEbot&&v.rawAction!=="freeflow.submit"&&v.action!=="提交送审"&&!((v.rawAction==="freeflow.comment"||v.action==="发表评论")&&!v.comment)&&!((v.rawAction==="freeflow.print"||v.action==="打印提醒")&&!v.comment)&&!(v.rawAction==="freeflow.carbonCopy"||v.rawAction==="freeflow.cc"||v.action==="抄送通知")),Q0=A0.find((v)=>v.rawAction==="freeflow.retract"||v.action==="单据撤回"),B=A0.find((v)=>v.rawAction==="freeflow.reject"||v.action==="审批驳回");if(!b)if(B||!Y&&f0){H0="审批驳回",b0=!1,i0=void 0;let v=$p(B,void 0,O,Q,Y);F0=v.commen Line truncated
`,{mode:384}),Y}function Vp($){let Y=hA0();for(let z of Y){if(!L$(z))continue;for(let U of dB(z).filter((Q)=>Q.endsWith(".json")).filter((Q)=>!Q.startsWith("example."))){let Q=P9(z,U);try{let J=lB(Q,"utf-8"),I=JSON.parse(J);if(I&&typeof I==="object"&&I.id===$)return Q}catch{}}}return}function y3($,Y){let z=Vp($);if(!z)throw Error(`Enterprise config not found: ${$}`);let Q={...JSON.parse(lB(z,"utf-8")),...Y};for(let I of Object.keys(Y))if(Y[I]===void 0)delete Q[I];let J=Wp.parse(Q);return TA0(z,`${JSON.stringify(J,null,2)}
`,"utf-8"),J}var Zp="SEAL_USE_ENTERPRISES_DIR",EA0="SEAL_HOME_ENTERPRISES_DIR",CA0="SEAL_USE_USER_ENTERPRISES_DIR",RA0="SEAL_HOME_USER_ENTERPRISES_DIR",_A0="SEAL_USE_CONFIG_FILE",vA0="SEAL_HOME_CONFIG_FILE",YK,mB,pB,PA0;var k3=m(()=>{Xp();YK=P9(oB(),".config","seal-use","enterprises"),mB=P9(oB(),".config","seal-home","enterprises"),pB=P9(oB(),".config","seal-use","config.json"),PA0=P9(oB(),".config","seal-home","config.json")});function n2($,Y,z=[]){let U=Y.corpId?.trim()||void 0,Q=Y.stateful?Y.defaultCorpId?.trim()||void 0:void 0,J=U??Q;if(J){let K=$.find((W)=>W.id===J);if(K)return K;let G=$.find((W)=>W.id.toLowerCase()===J.toLowerCase());if(G)return G;let H=$.find((W)=>W.name.toLowerCase()===J.toLowerCase());if(H)return H;throw Error(`No enterprise config found for ${J}`)}if(!Y.stateful)throw Error("Stateless mode is enabled. Every enterprise command requires --corp <corpId>. Use `seal-use config mode stateful` to enable a default enterprise.");let I=$[0];if(I)return I;throw Error("No enterprise config found. Add a non-example JSON file under one of: "+(z.length?z.join(", "):"the configured enterprise directories"))}import{existsSync as Lp,mkdirSync as wD1,readFileSync as MD1,renameSync as ND1,unlinkSync as DD1,writeFileSync as AD1}from"node:fs";import{homedir as BD1}from"node:os";import{dirname as PD1,join as jD1}from"node:path";function vZ(){let $=process.env[TD1]?.trim();if($)return $;return ED1}function SA0($=new Date){return $.toISOString().slice(0,10)}function gA0($=Fp,Y=new Date){let z=Y.getTime()-Math.max(0,$-1)*86400000;return new Date(z).toISOString().slice(0,10)}function yA0($=vZ()){if(!Lp($))return{};try{let Y=MD1($,"utf-8"),z=JSON.parse(Y);if(z&&typeof z==="object"&&!Array.isArray(z))return z;return{}}catch{return{}}}function CD1($,Y){let z={};for(let[U,Q]of Object.entries($)){if(!Q||typeof Q!=="object")continue;let J={},I=!1;for(let[K,G]of Object.entries(Q))if(typeof G==="number"&&G>0&&K>=Y)J[K]=G,I=!0;if(I)z[U]=J}return z}function RD1($,Y=vZ()){let z=PD1(Y);if(!Lp(z))wD1(z,{recursive:!0,mode:448});let U=`${Y}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2,8)}.tmp`;try{AD1(U,JSON.stringify($,null,2),{encoding:"utf-8",mode:384}),ND1(U,Y)}catch(Q){try{if(Lp(U))DD1(U)}catch{}throw Q}}function kA0($,Y=new Date){if(!$||typeof $!=="string")return;try{let z=vZ(),U=yA0(z),Q=SA0(Y),J=gA0(Fp,Y),I=CD1(U,J);I[$]=I[$]||{},I[$][Q]=(I[$][Q]??0)+1,RD1(I,z)}catch{}}function _D1($,Y=Fp,z=new Date){let U=new Map;try{let Q=yA0(),J=gA0(Y,z),I=SA0(z),K=$??Object.keys(Q);for(let G of K){let H=Q[G];if(!H){U.set(G,0);continue}let W=0;for(let[X,Z]of Object.entries(H))if(X>=J&&X<=I&&typeof Z==="number")W+=Z;U.set(G,W)}}catch{if($)for(let Q of $)U.set(Q,0)}return U}function xA0($,Y,z){let U=z??_D1($.map((Q)=>Q.id));return[...$].sort((Q,J)=>{if(Y){if(Q.id===Y&&J.id!==Y)return-1;if(J.id===Y&&Q.id!==Y)return 1}let I=U.get(Q.id)??0,K=U.get(J.id)??0;if(I!==K)return K-I;let G=Q.name??Q.id,H=J.name??J.id,W=G.localeCompare(H,"zh-CN");if(W!==0)return W;return Q.id.localeCompare(J.id)})}var TD1="SEAL_USE_USAGE_FILE",ED1,Fp=7;var rB=m(()=>{ED1=jD1(BD1(),".config","seal-use","usage.json")});function vD1($,Y){return $.map((z)=>z.trim()).filter(Boolean).map((z)=>Y?z:z.toLowerCase())}function hD1($,Y){return Y?$:$.toLowerCase()}function SD1($,Y,z,U){let Q=hD1($,U),J=Y.filter((I)=>Q.includes(I));if(z==="all"&&J.length!==Y.length)return[];return J}function gD1($){if(typeof $==="string")return $.split(/\r?\n/);return JSON.stringify($,null,2).split(/\r?\n/)}function yD1($,Y){if(Y.fields&&!Y.fields.has($.field))return[];let z=gD1($.value),U=[];return z.forEach((Q,J)=>{let I=SD1(Q,Y.keywords,Y.matchMode,Y.caseSensitive);if(I.length===0)return;let K=Math.max(0,J-Y.contextLines),G=Math.min(z.length,J+Y.contextLines+1),H={area:$.area,entityType:$.entityType,entityId:$.entityId,title:$.title,field:$.field,lineNumber:J+1,matchedKeywords:I,matchedText:sB(Q,Y.maxChars),context:{before:Y.snippetOnly?[]:z.slice(K,J).map((W)=>sB(W,Y.maxChars)),line:sB(Q,Y.maxChars),after:Y.snippetOnly?[]:z.slice(J+1,G).map((W)=>sB(W,Y.maxChars))},metadata:$.metadata};if(Y.snippetOnly)H.context={before:[],line:H.context.line,after:[]};U.push(H)}),U}function sB($,Y){if(!Y||$.length<=Y)return $;return`${$.slice(0,Math.max(0,Y))}...`}function kD1($){return[{area:"rules",entityType:"rule",entityId:$.id,title:$.scope,field:"description",value:$.description,metadata:{scope:$.scope,strictness:$.strictness,status:$.status}},{area:"rules",entityType:"rule",entityId:$.id,title:$.scope,field:"scope",value:$.scope,metadata:{strictness:$.strictness,status:$.status}}]}function uA0($){return $.rules.flatMap((Y,z)=>{let U=`${$.id}:${Y.description.slice(0,32)}`,Q={versionId:$.id,versionNumber:$.versionNumber,versionName:$.versionName,publishedByName:$.publishedByName,publishedAt:$.publishedAt,scope:Y.scope,strictness:Y.strictness,code:"code"in Y?Y.code:void 0,index:z};return[{area:"rules",entityType:"rule",entityId:U,title:`${$.versionName} / ${Y.scope}`,field:"hi Line truncated
`):[]}function cD1($,Y){let z=Array.from({length:$.length+1},()=>Array(Y.length+1).fill(0));for(let I=$.length-1;I>=0;I-=1)for(let K=Y.length-1;K>=0;K-=1)z[I][K]=$[I]===Y[K]?z[I+1][K+1]+1:Math.max(z[I+1][K],z[I][K+1]);let U=[],Q=0,J=0;while(Q<$.length&&J<Y.length)if($[Q]===Y[J])U.push(` ${$[Q]}`),Q+=1,J+=1;else if(z[Q+1][J]>=z[Q][J+1])U.push(`-${$[Q++]}`);else U.push(`+${Y[J++]}`);while(Q<$.length)U.push(`-${$[Q++]}`);while(J<Y.length)U.push(`+${Y[J++]}`);return U}function pD1($,Y,z,U,Q,J){let I=cA0(U,J),K=cA0(Q,J),G=U?`a/rules/${$}`:"/dev/null",H=Q?`b/rules/${$}`:"/dev/null";return[`diff --git a/rules/${$} b/rules/${$}`,`--- ${G} v${Y.versionNumber}`,`+++ ${H} v${z.versionNumber}`,`@@ -${I.length?1:0},${I.length} +${K.length?1:0},${K.length} @@`,...cD1(I,K)].join(`
`)}function pA0($){return{id:$.id,versionNumber:$.versionNumber,versionName:$.versionName,publishedAt:$.publishedAt}}function dA0($,Y){let z=new Map;for(let U of $.rules){let Q=hZ(U),J=Y==="stable-id"?lA0(Q):SZ(Q.code??Q.ruleCode);if(!J)throw Error(`Rule version ${$.versionNumber} contains a rule without a ${Y==="stable-id"?"stable rule ID":"code"}.`);if(z.has(J))throw Error(`Rule version ${$.versionNumber} contains duplicate ${Y==="stable-id"?"stable rule ID":"code"}: ${J}`);z.set(J,Q)}return z}function dD1($,Y,z){if(z!=="auto")return z;if([...$.rules,...Y.rules].every((J)=>Boolean(lA0(J))))return"stable-id";if([...$.rules,...Y.rules].every((J)=>Boolean(SZ(hZ(J).code??hZ(J).ruleCode))))return"code";throw Error("Rule snapshots have neither a complete stable-ID mapping nor a complete code mapping.")}function oA0($,Y,z={}){let U=dD1($,Y,z.identityMode??"auto"),Q=dA0($,U),J=dA0(Y,U),I=[...new Set([...Q.keys(),...J.keys()])],K=[],G={added:0,removed:0,modified:0,unchanged:0},H=pA0($),W=pA0(Y);for(let Z of I){let q=Q.get(Z),V=J.get(Z),F=q?VU(q,U):void 0,w=V?VU(V,U):void 0,O=!q?"added":!V?"removed":JSON.stringify(F)!==JSON.stringify(w)?"modified":"unchanged";if(G[O]+=1,O==="unchanged"&&!z.includeUnchanged)continue;let N=O==="modified"?[...new Set([...Object.keys(F??{}),...Object.keys(w??{})])].filter((M)=>JSON.stringify(F?.[M])!==JSON.stringify(w?.[M])):void 0;K.push({status:O,ruleId:Z,identityMode:U,...q?{before:q}:{},...V?{after:V}:{},...N?.length?{changedFields:N}:{},...O!=="unchanged"?{diff:pD1(Z,H,W,q,V,U)}:{}})}let X={from:H,to:W,identityMode:U,counts:G,changes:K,unifiedDiff:K.filter((Z)=>Z.diff).map((Z)=>Z.diff).join(`
`)};if(U==="code"){let Z=I.filter((P)=>Q.has(P)&&J.has(P)).length,q=I.filter((P)=>Q.has(P)&&J.has(P)&&JSON.stringify(VU(Q.get(P),"code"))===JSON.stringify(VU(J.get(P),"code"))).length,V=Q.size,F=J.size,w=Math.min(V,F)?Z/Math.min(V,F):1,O=new Map;for(let[P,j]of Q)O.set(JSON.stringify(VU(j,"code")),P);let N=0;for(let[P,j]of J){let A=O.get(JSON.stringify(VU(j,"code")));if(A&&A!==P)N+=1}let D=(Math.min(V,F)?q/Math.min(V,F):1)>=0.5?"high":q>0||N>0?"ambiguous":"low";X.codeStats={oldCount:V,newCount:F,sameCodeCount:Z,sameCodeUnchanged:q,sameBodyDifferentCode:N,overlapRatio:w,confidence:D,warning:"Published snapshots do not carry stable IDs; code matching can report reorderings as remove/add or modified rules."}}return X}function wp($,Y=20000,z=!1){if(z||$.unifiedDiff.length<=Y)return{...$,truncation:{truncated:!1,maxChars:Y,omittedChars:0,hint:"Use --full only when the complete diff is required."}};let U=$.unifiedDiff.length-Y,Q=`
... [diff truncated: ${U} characters omitted; rerun with --full for the complete diff]`,J=$.changes.map(({before:I,after:K,diff:G,...H})=>({...H,...G?{diff:G.length>Y?`${G.slice(0,Y)}${Q}`:G}:{}}));return{...$,changes:J,unifiedDiff:`${$.unifiedDiff.slice(0,Y)}${Q}`,truncation:{truncated:!0,maxChars:Y,omittedChars:U,hint:"Use --full for the complete diff."}}}var mA0,nD1;var rA0=m(()=>{mA0=["id","ruleId","stableId"],nD1=new Set([...mA0,"runtimeRuleId","runtimeId","tenantId","createdAt","updatedAt","versionId","versionNumber"])});import{existsSync as mD1,mkdirSync as lD1,readFileSync as oD1,renameSync as rD1,writeFileSync as sD1}from"node:fs";import{homedir as aD1}from"node:os";import{join as sA0}from"node:path";function gZ($){if($===void 0||$===null)return;let Y=String($).trim().toLowerCase().replace(/^rule[-_:]?/,"").replace(/^#/,"");if(!Y)return;return/^\d+$/.test(Y)?String(Number(Y)):Y}function aB($){return JSON.stringify([$.description??"",$.scope??"",$.strictness??""])}function aA0(){return process.env.SEAL_USE_RULE_VERSION_SNAPSHOTS_DIR?.trim()||sA0(aD1(),".config","seal-use","rule-version-snapshots")}function tD1($){return $.replace(/[^a-zA-Z0-9._-]/g,"_")}function tA0($,Y){return sA0(aA0(),`${tD1($)}-v${Y}.json`)}function yZ($,Y,z){let U=new Map,Q=new Map;for(let W of z){let X=gZ(W.code);if(X)U.set(X,[...U.get(X)??[],W]);let Z=aB(W);Q.set(Z,[...Q.get(Z)??[],W])}let J=[];for(let W of Y.rules??[]){let X=gZ(W.code),Z=X?U.get(X)??[]:[],q=Q.get(aB(W))??[],V=Z.length===1?Z[0]:q.length===1?q[0]:void 0;if(!V)continue;J.push({stableId:V.id,...W.code!==void 0?{code:W.code}:{},description:W.description,scope:W.scope,strictness:W.strictness})}let I={corpId:$,versionId:Y.id,versionNumber:Y.versionNumber,capturedAt:new Date().toISOString(),rules:J},K=aA0();lD1(K,{recursive:!0,mode:448});let G=tA0($,Y.versionNumber),H=`${G}.${process.pid}.tmp`;return sD1(H,`${JSON.stringify(I,null,2)}
`,{encoding:"utf8",mode:384}),rD1(H,G),G}function eD1($,Y){let z=tA0($,Y.versionNumber);if(!mD1(z))return null;try{return JSON.parse(oD1(z,"utf8"))}catch{return null}}function Mp($,Y){let z=eD1($,Y);if(!z?.rules.length)return Y;let U=new Map(z.rules.flatMap((J)=>{let I=gZ(J.code);return I?[[I,J]]:[]})),Q=new Map(z.rules.map((J)=>[aB(J),J]));return{...Y,rules:Y.rules.map((J)=>{if(J.id!==void 0||J.ruleId!==void 0||J.stableId!==void 0)return J;let I=(gZ(J.code)?U.get(gZ(J.code)):void 0)??Q.get(aB(J));return I?{...J,stableId:I.stableId}:J})}}var Np=()=>{};import{createHmac as $A1,randomBytes as YA1}from"node:crypto";function zA1($,Y,z,U){return $A1("sha256",U).update(`${$}.${Y}.${JSON.stringify(z)}`).digest("hex")}function kZ($,Y){let z=Math.floor(Date.now()/1000),U=YA1(16).toString("hex");return{Authorization:`Bearer ${Y}`,"x-webhook-signature":zA1(z,U,$,Y),"x-webhook-timestamp":String(z),"x-webhook-nonce":U}}var tB=()=>{};function m4($,Y){return new L4($,2,Y)}function A5($,Y){return new L4($,10,Y)}function xZ($){if($ instanceof L4)return{exitCode:$.exitCode,nextAction:$.nextAction};let Y=$ instanceof Error?$.message:String($),z=UA1($);if(z===401||z===403||/(?:^|\s)(?:token|bearer|session) (?:expired|missing|invalid)/i.test(Y))return{exitCode:11};if(/^(?:Usage:|Unknown (?:[a-z0-9_-]+ )?command|Invalid (?:number|boolean|command)|--json must|Missing required JSON field)/i.test(Y))return{exitCode:2};if(/^Refusing to (?:clear|delete)|without --yes|without confirm=true/i.test(Y))return{exitCode:10};return{exitCode:1}}function UA1($){if(!$||typeof $!=="object")return;let Y=$.response;if(!Y||typeof Y!=="object")return;let z=Y.status;return typeof z==="number"?z:void 0}var L4,eB;var F$=m(()=>{L4=class L4 extends Error{exitCode;nextAction;constructor($,Y,z){super($);this.name="CliError",this.exitCode=Y,this.nextAction=z}};eB=class eB extends L4{constructor($,Y){super($,12,Y);this.name="PayloadTooLargeError"}}});function eA0($,Y){let z=$&&typeof $==="object"?$:{},U=typeof z.type==="string"?z.type.toUpperCase().trim():"",Q=typeof z.key==="string"&&z.key.trim()?z.key.trim():typeof z.label==="string"&&z.label.trim()?z.label.trim():`field_${Y}`,J=typeof z.label==="string"&&z.label.trim()?z.label.trim():Q,I=z.value!==void 0?z.value:null;if(U==="LIST"&&Array.isArray(I))I=I.map((G)=>{if(Array.isArray(G))return G.map((H,W)=>eA0(H,W));return G});let K=U;if(!QA1.has(K))if(Array.isArray(I))K="LIST";else if(I&&typeof I==="object")K="OBJECT";else if(typeof I==="number")K="NUMBER";else K="TEXT";return{key:Q,label:J,type:K,value:I}}function Dp($,Y={}){let z=$.document,U=$.sourceDocumentSN??(typeof z?.sn==="string"?z.sn:void 0)??(typeof z?.sourceDocumentSN==="string"?z.sourceDocumentSN:void 0)??$.id,Q=$.sourceDocumentId??(typeof z?.id==="string"?z.id:void 0)??(typeof z?.sourceDocumentId==="string"?z.sourceDocumentId:void 0)??$.documentId??$.id,J=Y.snPrefix??"",I=Y.snSuffix??"",K=Y.docIdPrefix??J,G=Y.docIdSuffix??I,H=`${J}${U}${I}`,W=`${K}${Q}${G}`,X=typeof z?.sourceStartTime==="number"?z.sourceStartTime:typeof $.createdAt==="number"?Math.floor($.createdAt/1000):null,q=(Array.isArray(z?.fields)?z.fields:[]).map((V,F)=>eA0(V,F));return{type:"document",documentId:W,documentSN:H,startTime:X,fields:q}}function JA1($){let Y=new URL($),z=Y.pathname.match(/\/webhook\/([^/]+)/);if(!z)throw Error(`Webhook URL 必须包含 /webhook/{webhookId}/document,收到: ${$}`);let U=z[1],Q=`${Y.protocol}//${Y.host}`,J=`${Q}/api/v1/integrations/webhook/${encodeURIComponent(U)}/document`;return{baseUrl:Q,webhookId:U,documentEndpoint:J}}async function Ap($,Y,z,U=fetch,Q={}){let{webhookId:J,documentEndpoint:I}=JA1($),K={...Q,"Content-Type":"application/json",...kZ({webhookId:J,...z},Y)},G=await U(I,{method:"POST",headers:K,body:JSON.stringify(z)});if(!G.ok){let H=await G.text();throw Error(`Webhook 单据推送失败 (${G.status}): ${H}`)}return G.json()}function $B0($,Y,z){if(Y){let U=Y.trim().toLowerCase(),Q=$.find((J)=>J.id.toLowerCase()===U||J.name.toLowerCase()===U||J.incomingDocumentWebhook.id.toLowerCase()===U);if(!Q){let J=$.map((I)=>`"${I.name}" (${I.id})`).join(", ");throw Error(`未找到匹配 "${Y}" 的 Webhook 集成通道。可用通道: [${J}]`)}return Q}if($.length===1)return $[0];if($.length>1){let U=$.find((J)=>J.name.includes("回放")||J.name.toLowerCase().includes("replay"));if(U)return U;let Q=$.map((J)=>`"${J.name}" (${J.id})`).join(", ");throw Error(`当前租户存在多个 Webhook 通道 [${Q}],请通过 --webhook <idOrName> 指定目标通道。`)}throw new L4("当前租户未配置任何 Webhook 集成通道。",1,`seal-use webhook add --name <name> --result-url <url>${z?` --corp ${z}`:""}`)}function $P($,Y){let z,U,{sourceCorpId:Q,targetCorpId:J,activeCorp:I,force:K}=$;if(Q&&J)z=Y(Q),U=Y(J);else if(Q&&!J)if(z=Y(Q),z.testCorpId)U=Y(z.testCorpId);else if(I.id!==z.id&&I.environment==="test")U=I;else U=I;else if(!Q&&J)if(U=Y(J),U.prodCorpId)z=Y(U.prodCorpId);else if(I.id!==U.id)z=I;else z=I;else if(I.environment==="test")if(U=I,I Line truncated
`+"为防止测试单据污染生产审批流,禁止向生产环境重放单据。请指定测试企业 (--target-corp <testCorpId>),或在确有需要时添加 --force。",1,`seal-use webhook replay --target-corp <testCorpId>${z.id!==U.id?` --source-corp ${z.id}`:""}`);return{sourceCorp:z,targetCorp:U}}async function Bp($,Y,z){let U=Y.seal?.endpoints?.approvalStylePreferences??"api/v1/agent/ai-approval/config",Q=await I$($,U);if(z||Q.length>0)return $B0(Q,z,Y.id);if(Y.environment==="test"||Y.id.toLowerCase().includes("test")){console.error(`[webhook-replay] 测试企业「${Y.name}」未配置 Webhook 通道,正在自动创建「(Seal测-回放通道)」...`);let J=(Y.seal.url??Y.source?.sealUrl??`https://${Y.id.toLowerCase()}.sealai.cc`).replace(/\/+$/,"");return await Pw($,J,{name:"(Seal测-回放通道)",mode:"assisted",outgoingResultWebhook:`${J}/api/v1/integrations/webhook/replay-mock-callback`},Y.seal.endpoints.approvalStylePreferences)}throw new L4(`当前租户「${Y.name}」未配置任何 Webhook 集成通道。`,1,`seal-use webhook add --name <name> --result-url <url> --corp ${Y.id}`)}async function zK($){let{query:Y,sourceClient:z,targetClient:U,sourceCorp:Q,targetCorp:J,webhookSelector:I,snPrefix:K,snSuffix:G,docIdPrefix:H,docIdSuffix:W,dryRun:X,fetchFn:Z=fetch}=$,q=[];if(Y.recordId){let P=await H4(z,Y.recordId);q.push(P)}else if(Y.recordIds&&Y.recordIds.length>0)for(let P of Y.recordIds)q.push(await H4(z,P));else if(Y.sn){let j=(await i4(z,{search:Y.sn,sourceDocumentSN:Y.sn,limit:20})).records.find((A)=>A.sourceDocumentSN===Y.sn||A.sourceDocumentId===Y.sn||A.document?.sourceDocumentSN===Y.sn||A.document?.sn===Y.sn);if(!j)throw Error(`在企业「${Q.name}」中未找到单据编号为「${Y.sn}」的审批记录。`);q.push(j)}else if(Y.sns&&Y.sns.length>0)for(let P of Y.sns){let A=(await i4(z,{search:P,sourceDocumentSN:P,limit:20})).records.find((T)=>T.sourceDocumentSN===P||T.sourceDocumentId===P||T.document?.sourceDocumentSN===P||T.document?.sn===P);if(!A)throw Error(`在企业「${Q.name}」中未找到单据编号为「${P}」的审批记录。`);q.push(A)}else if(Y.limit!==void 0){let P=await i4(z,{limit:Y.limit,status:Y.status,startDate:Y.startDate,endDate:Y.endDate});if(!P.records.length)throw Error(`在企业「${Q.name}」中未检索到符合条件的审批记录。`);q=P.records}else throw Error("Usage: seal-use webhook replay <recordId> [--sn <documentSN>] [--limit <n>] [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>] [--dry-run]");let V=q.map((P)=>({run:P,doc:Dp(P,{snPrefix:K,snSuffix:G,docIdPrefix:H,docIdSuffix:W})}));if(X){let P={id:"preview-webhook",name:I??"预览目标通道",mode:"assisted",incomingDocumentWebhookUrl:`${J.seal.url}/api/v1/integrations/webhook/preview`};try{let T=await I$(U,J.seal.endpoints.approvalStylePreferences);if(T.length>0){let C=$B0(T,I,J.id);P={id:C.id,name:C.name,mode:C.mode,incomingDocumentWebhookUrl:C.incomingDocumentWebhook.url}}}catch{}let j=V.map(({run:T,doc:C})=>({originalRecord:{id:T.id,sourceSystem:T.sourceSystem,sourceDocumentSN:T.sourceDocumentSN,sourceDocumentId:T.sourceDocumentId},document:C,success:!0})),A=j.length===1;return{dryRun:!0,success:!0,sourceCorp:{id:Q.id,name:Q.name,environment:Q.environment},targetCorp:{id:J.id,name:J.name,environment:J.environment},targetWebhook:P,totalCount:j.length,successCount:j.length,failureCount:0,originalRecord:A?j[0].originalRecord:void 0,document:A?j[0].document:void 0,records:j}}let F=await Bp(U,J,I),w={id:F.id,name:F.name,mode:F.mode,incomingDocumentWebhookUrl:F.incomingDocumentWebhook.url},O=[],N=0,M=0;for(let{run:P,doc:j}of V){console.error(`[webhook-replay] 正在向 Webhook 通道「${F.name}」推送单据: ${j.documentSN}...`);try{let A=await Ap(F.incomingDocumentWebhook.url,F.secret,j,Z,A6(J.seal));O.push({originalRecord:{id:P.id,sourceSystem:P.sourceSystem,sourceDocumentSN:P.sourceDocumentSN,sourceDocumentId:P.sourceDocumentId},replayedDocument:{documentSN:j.documentSN,documentId:j.documentId,fieldCount:j.fields.length},pushResult:A,success:!0}),N+=1}catch(A){let T=A instanceof Error?A.message:String(A);O.push({originalRecord:{id:P.id,sourceSystem:P.sourceSystem,sourceDocumentSN:P.sourceDocumentSN,sourceDocumentId:P.sourceDocumentId},replayedDocument:{documentSN:j.documentSN,documentId:j.documentId,fieldCount:j.fields.length},error:T,success:!1}),M+=1}}let D=O.length===1;return{success:M===0,dryRun:!1,sourceCorp:{id:Q.id,name:Q.name,environment:Q.environment},targetCorp:{id:J.id,name:J.name,environment:J.environment},targetWebhook:w,totalCount:O.length,successCount:N,failureCount:M,originalRecord:D?O[0].originalRecord:void 0,replayedDocument:D?O[0].replayedDocument:void 0,pushResult:D?O[0].pushResult:void 0,records:O}}var QA1;var fZ=m(()=>{tB();F$();B6();QA1=new Set(["TEXT","NUMBER","DATE","AMOUNT","PERSON","ATTACHMENT","DATE_RANGE","DEPARTMENT","LIST","CITY","OBJECT"])});var YB0,Z44,IA1,q44;var zB0=m(()=>{P$();YB0=L.object({level:L.enum(["error","warning" Line truncated
↳ ${V}`,operator:Q}}function PA0($){if(!$)return[];let U=$.pending||[],Y=String($.rawState||"").toUpperCase(),z=String($.state||"").toUpperCase(),I=[];if(U.length>0)for(let Q of U){let J=Q.approver?.name||Q.approver?.id||"待定",K=(Q.name||$.currentNode||"").trim(),G=K?`${K}(${J})`:J,W=Q.type?.toUpperCase()==="PAYING"||K.includes("支付")||Y==="PAYING"||z==="支付中"?"待支付":"待审批";I.push(`${G}: ${W}`)}else if($.currentNode?.trim()){let J=$.currentNode.includes("支付")||Y==="PAYING"||z==="支付中"?"待支付":"待审批";I.push(`${$.currentNode.trim()}: ${J}`)}return I}function Xz($,U){let Y=new Map;if(!$||$.length===0)return Y;if(!U){for(let q of $){let F=(q.result||{}).decision||q.aiDecision||"-";Y.set(q.id,{recordId:q.id,sourceDocumentSN:q.sourceDocumentSN,taskMode:q.taskMode,aiDecision:BA0(typeof F==="string"?F:"-"),aiAction:"-",eHumanAction:"-",eHumanComment:"-",auditDrift:!1})}return Y}let z=[...$].sort((q,V)=>(Number(q.createdAt)||0)-(Number(V.createdAt)||0)),I=U.history||[],Q=String(U.rawState||"").toUpperCase(),J=String(U.state||"").toUpperCase(),K=Q==="DRAFT"||Q==="REVOKED"||Q==="CANCELED"||Q==="CANCELLED"||J==="草稿"||J==="已撤回"||J==="已取消",G=Q==="REJECTED"||Q==="TERMINATED"||J==="审批驳回"||J==="已驳回",H=!K&&!G&&(Q==="PAID"||J==="已支付"||I.some((q)=>!q.isEbot&&(q.rawAction==="freeflow.pay"||q.action==="支付成功"||q.action==="支付完成"))),W=!K&&!G&&!H&&(Q==="PAYING"||J==="支付中"||(U.pending||[]).some((q)=>q.isCurrent&&(q.type?.toUpperCase()==="PAYING"||q.name?.includes("支付")))||U.currentNode?.includes("支付")===!0),Z=H||!K&&!G&&!W&&(Q==="COMPLETED"||Q==="APPROVED"||J==="已完成"||J==="审批通过");for(let q=0;q<z.length;q++){let V=z[q];if(!V)continue;let F=Number(V.createdAt)||0,M=V.document||{},w=V.manualApprovalRecord||V.result?.manualApprovalRecord||M.manualApprovalRecord||{},N=typeof V.sourceExtendData?.nodeId==="string"?String(V.sourceExtendData.nodeId):void 0,O=typeof w.nodeId==="string"?String(w.nodeId):void 0,D=O?decodeURIComponent(O).replace(/^hcnode_/,"").replace(/_r\d+$/,""):void 0,P=N||D,T=P?I.find((D0)=>D0.nodeId&&(D0.nodeId===P||P.includes(D0.nodeId))):void 0,A=T?.time??F,j=z[q+1],C=j?Number(j.createdAt)||1/0:1/0,b=q===z.length-1,x=I.find((D0)=>(D0.time??0)>A+5000&&D0.isEbot&&(D0.nodeName?.includes("智能")||D0.nodeName?.includes("AI")||D0.action?.includes("智能")||D0.comment?.includes("AI")||D0.comment?.includes("approval-result"))&&!D0.nodeName?.includes("费用标准检查")&&!D0.nodeName?.includes("标准检查")&&!D0.nodeName?.includes("预算"));if(x){if(b=!1,(x.time??1/0)<C)C=x.time}let g=V.result||{},i=g.decision||V.aiDecision||"-",n=typeof i==="string"?i:"-",z0=n.toUpperCase(),k=z0==="REJECT"||z0==="驳回",p=z0==="APPROVE"||z0==="通过",a=z0==="EXEMPT_APPROVE"||z0==="免审通过"||z0==="备注通过",$0=V.taskMode||V.finalExecutionMode||"",d=String($0).toLowerCase().includes("auto")||V.finalExecutionMode==="automatic"||$0==="automatic"||$0==="fully_automatic",U0="-";if(p||a)U0="添加评论";else if(k)U0=d?"驳回":"添加评论";else if(z0==="REVIEW"||z0==="转交复核")U0="转交复核";let R=typeof w.status==="object"&&w.status!==null?String(w.status.type||w.status.label||"").toUpperCase():"",o=typeof w.status==="object"&&w.status!==null?String(w.status.sourceStatus||""):"",e=M.manualApprovalStatus||g.manualApprovalStatus||V.manualApprovalStatus,O0=typeof e==="string"?e.toUpperCase():"",T0=O0==="CANCELLED"||O0==="CANCELED"||O0==="已取消"||O0==="已撤回"||O0==="REVOKED"||R==="CANCELLED"||R==="CANCELED"||o.includes("撤回")||o.includes("取消"),y0=O0==="APPROVED"||O0==="已支付/审批完成"||O0==="已通过"||O0==="已完成"||O0==="已支付"||R==="APPROVED",o0=!(o.includes("补偿")||o.includes("已支付"))&&(O0==="TERMINATED"||O0==="REJECTED"||O0==="REJECT"||O0==="已驳回"||O0==="被驳回"||R==="TERMINATED"||R==="REJECTED"||R==="已驳回"||R==="被驳回"),q1=T?1000:60000,t=I.filter((D0)=>{let I0=D0.time??0;return I0>=A-q1&&I0<C}),X0="-",w0="-",u0=!1,b0,n0,P1=p||a,k1=I.filter((D0)=>(D0.time??0)>A+5000),u1=k1.some((D0)=>D0.rawAction==="freeflow.retract"||D0.action==="单据撤回"),b1=k1.some((D0)=>D0.rawAction==="freeflow.submit"||D0.action==="提交送审");if(P1&&b&&(u1||b1))u0=!0,b0="AI通过后单据发生撤回/修改重提,后续未经AI复审";if(d&&k)X0="无操作",w0="-";else{let D0=t.filter((h)=>(h.time??0)>=A-1000&&!h.isEbot&&h.rawAction!=="freeflow.submit"&&h.action!=="提交送审"&&!((h.rawAction==="freeflow.comment"||h.action==="发表评论")&&!h.comment)&&!((h.rawAction==="freeflow.print"||h.action==="打印提醒")&&!h.comment)&&!(h.rawAction==="freeflow.carbonCopy"||h.rawAction==="freeflow.cc"||h.action==="抄送通知")),I0=D0.find((h)=>h.rawAction==="freeflow.retract"||h.action==="单据撤回"),B=D0.find((h)=>h.rawAction==="freeflow.reject"||h.action==="审批驳回");if(!b)if(B||!U&&o0){X0="审批驳回",u0=!1,b0=void 0;let h=Vd(B,void 0,w,I,U);w0=h.comme Line truncated
`,{mode:384}),U}function Td($){let U=dA0();for(let Y of U){if(!w$(Y))continue;for(let z of tB(Y).filter((I)=>I.endsWith(".json")).filter((I)=>!I.startsWith("example."))){let I=j9(Y,z);try{let Q=$P(I,"utf-8"),J=JSON.parse(Q);if(J&&typeof J==="object"&&J.id===$)return I}catch{}}}return}function E9($,U){let Y=Td($);if(!Y)throw Error(`Enterprise config not found: ${$}`);let I={...JSON.parse($P(Y,"utf-8")),...U};for(let J of Object.keys(U))if(U[J]===void 0)delete I[J];let Q=hZ.parse(I);return fA0(Y,`${JSON.stringify(Q,null,2)}
`,"utf-8"),Q}var Pd="SEAL_USE_ENTERPRISES_DIR",uA0="SEAL_HOME_ENTERPRISES_DIR",bA0="SEAL_USE_USER_ENTERPRISES_DIR",iA0="SEAL_HOME_USER_ENTERPRISES_DIR",nA0="SEAL_USE_CONFIG_FILE",cA0="SEAL_HOME_CONFIG_FILE",YK,eB,aB,kA0;var T5=m(()=>{sB();YK=j9(UP(),".config","seal-use","enterprises"),eB=j9(UP(),".config","seal-home","enterprises"),aB=j9(UP(),".config","seal-use","config.json"),kA0=j9(UP(),".config","seal-home","config.json")});function c2($,U,Y=[]){let z=U.corpId?.trim()||void 0,I=U.stateful?U.defaultCorpId?.trim()||void 0:void 0,Q=z??I;if(Q){let K=$.find((W)=>W.id===Q);if(K)return K;let G=$.find((W)=>W.id.toLowerCase()===Q.toLowerCase());if(G)return G;let H=$.find((W)=>W.name.toLowerCase()===Q.toLowerCase());if(H)return H;throw Error(`No enterprise config found for ${Q}`)}if(!U.stateful)throw Error("Stateless mode is enabled. Every enterprise command requires --corp <corpId>. Use `seal-use config mode stateful` to enable a default enterprise.");let J=$[0];if(J)return J;throw Error("No enterprise config found. Add a non-example JSON file under one of: "+(Y.length?Y.join(", "):"the configured enterprise directories"))}import{existsSync as jd,mkdirSync as pD1,readFileSync as mD1,renameSync as lD1,unlinkSync as oD1,writeFileSync as rD1}from"node:fs";import{homedir as sD1}from"node:os";import{dirname as aD1,join as tD1}from"node:path";function gZ(){let $=process.env[eD1]?.trim();if($)return $;return $A1}function mA0($=new Date){return $.toISOString().slice(0,10)}function lA0($=Ed,U=new Date){let Y=U.getTime()-Math.max(0,$-1)*86400000;return new Date(Y).toISOString().slice(0,10)}function oA0($=gZ()){if(!jd($))return{};try{let U=mD1($,"utf-8"),Y=JSON.parse(U);if(Y&&typeof Y==="object"&&!Array.isArray(Y))return Y;return{}}catch{return{}}}function UA1($,U){let Y={};for(let[z,I]of Object.entries($)){if(!I||typeof I!=="object")continue;let Q={},J=!1;for(let[K,G]of Object.entries(I))if(typeof G==="number"&&G>0&&K>=U)Q[K]=G,J=!0;if(J)Y[z]=Q}return Y}function YA1($,U=gZ()){let Y=aD1(U);if(!jd(Y))pD1(Y,{recursive:!0,mode:448});let z=`${U}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2,8)}.tmp`;try{rD1(z,JSON.stringify($,null,2),{encoding:"utf-8",mode:384}),lD1(z,U)}catch(I){try{if(jd(z))oD1(z)}catch{}throw I}}function rA0($,U=new Date){if(!$||typeof $!=="string")return;try{let Y=gZ(),z=oA0(Y),I=mA0(U),Q=lA0(Ed,U),J=UA1(z,Q);J[$]=J[$]||{},J[$][I]=(J[$][I]??0)+1,YA1(J,Y)}catch{}}function zA1($,U=Ed,Y=new Date){let z=new Map;try{let I=oA0(),Q=lA0(U,Y),J=mA0(Y),K=$??Object.keys(I);for(let G of K){let H=I[G];if(!H){z.set(G,0);continue}let W=0;for(let[X,Z]of Object.entries(H))if(X>=Q&&X<=J&&typeof Z==="number")W+=Z;z.set(G,W)}}catch{if($)for(let I of $)z.set(I,0)}return z}function sA0($,U,Y){let z=Y??zA1($.map((I)=>I.id));return[...$].sort((I,Q)=>{if(U){if(I.id===U&&Q.id!==U)return-1;if(Q.id===U&&I.id!==U)return 1}let J=z.get(I.id)??0,K=z.get(Q.id)??0;if(J!==K)return K-J;let G=I.name??I.id,H=Q.name??Q.id,W=G.localeCompare(H,"zh-CN");if(W!==0)return W;return I.id.localeCompare(Q.id)})}var eD1="SEAL_USE_USAGE_FILE",$A1,Ed=7;var YP=m(()=>{$A1=tD1(sD1(),".config","seal-use","usage.json")});function IA1($,U){return $.map((Y)=>Y.trim()).filter(Boolean).map((Y)=>U?Y:Y.toLowerCase())}function QA1($,U){return U?$:$.toLowerCase()}function JA1($,U,Y,z){let I=QA1($,z),Q=U.filter((J)=>I.includes(J));if(Y==="all"&&Q.length!==U.length)return[];return Q}function KA1($){if(typeof $==="string")return $.split(/\r?\n/);return JSON.stringify($,null,2).split(/\r?\n/)}function GA1($,U){if(U.fields&&!U.fields.has($.field))return[];let Y=KA1($.value),z=[];return Y.forEach((I,Q)=>{let J=JA1(I,U.keywords,U.matchMode,U.caseSensitive);if(J.length===0)return;let K=Math.max(0,Q-U.contextLines),G=Math.min(Y.length,Q+U.contextLines+1),H={area:$.area,entityType:$.entityType,entityId:$.entityId,title:$.title,field:$.field,lineNumber:Q+1,matchedKeywords:J,matchedText:zP(I,U.maxChars),context:{before:U.snippetOnly?[]:Y.slice(K,Q).map((W)=>zP(W,U.maxChars)),line:zP(I,U.maxChars),after:U.snippetOnly?[]:Y.slice(Q+1,G).map((W)=>zP(W,U.maxChars))},metadata:$.metadata};if(U.snippetOnly)H.context={before:[],line:H.context.line,after:[]};z.push(H)}),z}function zP($,U){if(!U||$.length<=U)return $;return`${$.slice(0,Math.max(0,U))}...`}function HA1($){return[{area:"rules",entityType:"rule",entityId:$.id,title:$.scope,field:"description",value:$.description,metadata:{scope:$.scope,strictness:$.strictness,status:$.status}},{area:"rules",entityType:"rule",entityId:$.id,title:$.scope,field:"scope",value:$.scope,metadata:{strictness:$.strictness,status:$.status}}]}function tA0($){return $.rules.flatMap((U,Y)=>{let z=`${$.id}:${U.description.slice(0,32)}`,I={versionId:$.id,versionNumber:$.versionNumber,versionName:$.versionName,publishedByName:$.publishedByName,publishedAt:$.publishedAt,scope:U.scope,strictness:U.strictness,code:"code"in U?U.code:void 0,index:Y};return[{area:"rules",entityType:"rule",entityId:z,title:`${$.versionName} / ${U.scope}`,field:"hi Line truncated
`):[]}function wA1($,U){let Y=Array.from({length:$.length+1},()=>Array(U.length+1).fill(0));for(let J=$.length-1;J>=0;J-=1)for(let K=U.length-1;K>=0;K-=1)Y[J][K]=$[J]===U[K]?Y[J+1][K+1]+1:Math.max(Y[J+1][K],Y[J][K+1]);let z=[],I=0,Q=0;while(I<$.length&&Q<U.length)if($[I]===U[Q])z.push(` ${$[I]}`),I+=1,Q+=1;else if(Y[I+1][Q]>=Y[I][Q+1])z.push(`-${$[I++]}`);else z.push(`+${U[Q++]}`);while(I<$.length)z.push(`-${$[I++]}`);while(Q<U.length)z.push(`+${U[Q++]}`);return z}function FA1($,U,Y,z,I,Q){let J=YB0(z,Q),K=YB0(I,Q),G=z?`a/rules/${$}`:"/dev/null",H=I?`b/rules/${$}`:"/dev/null";return[`diff --git a/rules/${$} b/rules/${$}`,`--- ${G} v${U.versionNumber}`,`+++ ${H} v${Y.versionNumber}`,`@@ -${J.length?1:0},${J.length} +${K.length?1:0},${K.length} @@`,...wA1(J,K)].join(`
`)}function zB0($){return{id:$.id,versionNumber:$.versionNumber,versionName:$.versionName,publishedAt:$.publishedAt}}function IB0($,U){let Y=new Map;for(let z of $.rules){let I=yZ(z),Q=U==="stable-id"?JB0(I):kZ(I.code??I.ruleCode);if(!Q)throw Error(`Rule version ${$.versionNumber} contains a rule without a ${U==="stable-id"?"stable rule ID":"code"}.`);if(Y.has(Q))throw Error(`Rule version ${$.versionNumber} contains duplicate ${U==="stable-id"?"stable rule ID":"code"}: ${Q}`);Y.set(Q,I)}return Y}function MA1($,U,Y){if(Y!=="auto")return Y;if([...$.rules,...U.rules].every((Q)=>Boolean(JB0(Q))))return"stable-id";if([...$.rules,...U.rules].every((Q)=>Boolean(kZ(yZ(Q).code??yZ(Q).ruleCode))))return"code";throw Error("Rule snapshots have neither a complete stable-ID mapping nor a complete code mapping.")}function KB0($,U,Y={}){let z=MA1($,U,Y.identityMode??"auto"),I=IB0($,z),Q=IB0(U,z),J=[...new Set([...I.keys(),...Q.keys()])],K=[],G={added:0,removed:0,modified:0,unchanged:0},H=zB0($),W=zB0(U);for(let Z of J){let q=I.get(Z),V=Q.get(Z),F=q?Vz(q,z):void 0,M=V?Vz(V,z):void 0,w=!q?"added":!V?"removed":JSON.stringify(F)!==JSON.stringify(M)?"modified":"unchanged";if(G[w]+=1,w==="unchanged"&&!Y.includeUnchanged)continue;let N=w==="modified"?[...new Set([...Object.keys(F??{}),...Object.keys(M??{})])].filter((O)=>JSON.stringify(F?.[O])!==JSON.stringify(M?.[O])):void 0;K.push({status:w,ruleId:Z,identityMode:z,...q?{before:q}:{},...V?{after:V}:{},...N?.length?{changedFields:N}:{},...w!=="unchanged"?{diff:FA1(Z,H,W,q,V,z)}:{}})}let X={from:H,to:W,identityMode:z,counts:G,changes:K,unifiedDiff:K.filter((Z)=>Z.diff).map((Z)=>Z.diff).join(`
`)};if(z==="code"){let Z=J.filter((P)=>I.has(P)&&Q.has(P)).length,q=J.filter((P)=>I.has(P)&&Q.has(P)&&JSON.stringify(Vz(I.get(P),"code"))===JSON.stringify(Vz(Q.get(P),"code"))).length,V=I.size,F=Q.size,M=Math.min(V,F)?Z/Math.min(V,F):1,w=new Map;for(let[P,T]of I)w.set(JSON.stringify(Vz(T,"code")),P);let N=0;for(let[P,T]of Q){let A=w.get(JSON.stringify(Vz(T,"code")));if(A&&A!==P)N+=1}let D=(Math.min(V,F)?q/Math.min(V,F):1)>=0.5?"high":q>0||N>0?"ambiguous":"low";X.codeStats={oldCount:V,newCount:F,sameCodeCount:Z,sameCodeUnchanged:q,sameBodyDifferentCode:N,overlapRatio:M,confidence:D,warning:"Published snapshots do not carry stable IDs; code matching can report reorderings as remove/add or modified rules."}}return X}function Rd($,U=20000,Y=!1){if(Y||$.unifiedDiff.length<=U)return{...$,truncation:{truncated:!1,maxChars:U,omittedChars:0,hint:"Use --full only when the complete diff is required."}};let z=$.unifiedDiff.length-U,I=`
... [diff truncated: ${z} characters omitted; rerun with --full for the complete diff]`,Q=$.changes.map(({before:J,after:K,diff:G,...H})=>({...H,...G?{diff:G.length>U?`${G.slice(0,U)}${I}`:G}:{}}));return{...$,changes:Q,unifiedDiff:`${$.unifiedDiff.slice(0,U)}${I}`,truncation:{truncated:!0,maxChars:U,omittedChars:z,hint:"Use --full for the complete diff."}}}var QB0,LA1;var GB0=m(()=>{QB0=["id","ruleId","stableId"],LA1=new Set([...QB0,"runtimeRuleId","runtimeId","tenantId","createdAt","updatedAt","versionId","versionNumber"])});import{existsSync as OA1,mkdirSync as NA1,readFileSync as DA1,renameSync as AA1,writeFileSync as BA1}from"node:fs";import{homedir as PA1}from"node:os";import{join as HB0}from"node:path";function xZ($){if($===void 0||$===null)return;let U=String($).trim().toLowerCase().replace(/^rule[-_:]?/,"").replace(/^#/,"");if(!U)return;return/^\d+$/.test(U)?String(Number(U)):U}function IP($){return JSON.stringify([$.description??"",$.scope??"",$.strictness??""])}function WB0(){return process.env.SEAL_USE_RULE_VERSION_SNAPSHOTS_DIR?.trim()||HB0(PA1(),".config","seal-use","rule-version-snapshots")}function TA1($){return $.replace(/[^a-zA-Z0-9._-]/g,"_")}function XB0($,U){return HB0(WB0(),`${TA1($)}-v${U}.json`)}function fZ($,U,Y){let z=new Map,I=new Map;for(let W of Y){let X=xZ(W.code);if(X)z.set(X,[...z.get(X)??[],W]);let Z=IP(W);I.set(Z,[...I.get(Z)??[],W])}let Q=[];for(let W of U.rules??[]){let X=xZ(W.code),Z=X?z.get(X)??[]:[],q=I.get(IP(W))??[],V=Z.length===1?Z[0]:q.length===1?q[0]:void 0;if(!V)continue;Q.push({stableId:V.id,...W.code!==void 0?{code:W.code}:{},description:W.description,scope:W.scope,strictness:W.strictness})}let J={corpId:$,versionId:U.id,versionNumber:U.versionNumber,capturedAt:new Date().toISOString(),rules:Q},K=WB0();NA1(K,{recursive:!0,mode:448});let G=XB0($,U.versionNumber),H=`${G}.${process.pid}.tmp`;return BA1(H,`${JSON.stringify(J,null,2)}
`,{encoding:"utf8",mode:384}),AA1(H,G),G}function jA1($,U){let Y=XB0($,U.versionNumber);if(!OA1(Y))return null;try{return JSON.parse(DA1(Y,"utf8"))}catch{return null}}function _d($,U){let Y=jA1($,U);if(!Y?.rules.length)return U;let z=new Map(Y.rules.flatMap((Q)=>{let J=xZ(Q.code);return J?[[J,Q]]:[]})),I=new Map(Y.rules.map((Q)=>[IP(Q),Q]));return{...U,rules:U.rules.map((Q)=>{if(Q.id!==void 0||Q.ruleId!==void 0||Q.stableId!==void 0)return Q;let J=(xZ(Q.code)?z.get(xZ(Q.code)):void 0)??I.get(IP(Q));return J?{...Q,stableId:J.stableId}:Q})}}var vd=()=>{};import{createHmac as EA1,randomBytes as CA1}from"node:crypto";function RA1($,U,Y,z){return EA1("sha256",z).update(`${$}.${U}.${JSON.stringify(Y)}`).digest("hex")}function uZ($,U){let Y=Math.floor(Date.now()/1000),z=CA1(16).toString("hex");return{Authorization:`Bearer ${U}`,"x-webhook-signature":RA1(Y,z,$,U),"x-webhook-timestamp":String(Y),"x-webhook-nonce":z}}var QP=()=>{};function h4($,U){return new W4($,2,U)}function F$($,U){return new W4($,10,U)}function bZ($){if($ instanceof W4)return{exitCode:$.exitCode,nextAction:$.nextAction};let U=$ instanceof Error?$.message:String($),Y=_A1($);if(Y===401||Y===403||/(?:^|\s)(?:token|bearer|session) (?:expired|missing|invalid)/i.test(U))return{exitCode:11};if(/^(?:Usage:|Unknown (?:[a-z0-9_-]+ )?command|Invalid (?:number|boolean|command)|--json must|Missing required JSON field)/i.test(U))return{exitCode:2};if(/^Refusing to (?:clear|delete)|without --yes|without confirm=true/i.test(U))return{exitCode:10};return{exitCode:1}}function _A1($){if(!$||typeof $!=="object")return;let U=$.response;if(!U||typeof U!=="object")return;let Y=U.status;return typeof Y==="number"?Y:void 0}var W4,JP;var O8=m(()=>{W4=class W4 extends Error{exitCode;nextAction;constructor($,U,Y){super($);this.name="CliError",this.exitCode=U,this.nextAction=Y}};JP=class JP extends W4{constructor($,U){super($,12,U);this.name="PayloadTooLargeError"}}});function ZB0($,U){let Y=$&&typeof $==="object"?$:{},z=typeof Y.type==="string"?Y.type.toUpperCase().trim():"",I=typeof Y.key==="string"&&Y.key.trim()?Y.key.trim():typeof Y.label==="string"&&Y.label.trim()?Y.label.trim():`field_${U}`,Q=typeof Y.label==="string"&&Y.label.trim()?Y.label.trim():I,J=Y.value!==void 0?Y.value:null;if(z==="LIST"&&Array.isArray(J))J=J.map((G)=>{if(Array.isArray(G))return G.map((H,W)=>ZB0(H,W));return G});let K=z;if(!vA1.has(K))if(Array.isArray(J))K="LIST";else if(J&&typeof J==="object")K="OBJECT";else if(typeof J==="number")K="NUMBER";else K="TEXT";return{key:I,label:Q,type:K,value:J}}function hd($,U={}){let Y=$.document,z=$.sourceDocumentSN??(typeof Y?.sn==="string"?Y.sn:void 0)??(typeof Y?.sourceDocumentSN==="string"?Y.sourceDocumentSN:void 0)??$.id,I=$.sourceDocumentId??(typeof Y?.id==="string"?Y.id:void 0)??(typeof Y?.sourceDocumentId==="string"?Y.sourceDocumentId:void 0)??$.documentId??$.id,Q=U.snPrefix??"",J=U.snSuffix??"",K=U.docIdPrefix??Q,G=U.docIdSuffix??J,H=`${Q}${z}${J}`,W=`${K}${I}${G}`,X=typeof Y?.sourceStartTime==="number"?Y.sourceStartTime:typeof $.createdAt==="number"?Math.floor($.createdAt/1000):null,q=(Array.isArray(Y?.fields)?Y.fields:[]).map((V,F)=>ZB0(V,F));return{type:"document",documentId:W,documentSN:H,startTime:X,fields:q}}function hA1($){let U=new URL($),Y=U.pathname.match(/\/webhook\/([^/]+)/);if(!Y)throw Error(`Webhook URL 必须包含 /webhook/{webhookId}/document,收到: ${$}`);let z=Y[1],I=`${U.protocol}//${U.host}`,Q=`${I}/api/v1/integrations/webhook/${encodeURIComponent(z)}/document`;return{baseUrl:I,webhookId:z,documentEndpoint:Q}}async function Sd($,U,Y,z=fetch,I={}){let{webhookId:Q,documentEndpoint:J}=hA1($),K={...I,"Content-Type":"application/json",...uZ({webhookId:Q,...Y},U)},G=await z(J,{method:"POST",headers:K,body:JSON.stringify(Y)});if(!G.ok){let H=await G.text();throw Error(`Webhook 单据推送失败 (${G.status}): ${H}`)}return G.json()}function qB0($,U,Y){if(U){let z=U.trim().toLowerCase(),I=$.find((Q)=>Q.id.toLowerCase()===z||Q.name.toLowerCase()===z||Q.incomingDocumentWebhook.id.toLowerCase()===z);if(!I){let Q=$.map((J)=>`"${J.name}" (${J.id})`).join(", ");throw Error(`未找到匹配 "${U}" 的 Webhook 集成通道。可用通道: [${Q}]`)}return I}if($.length===1)return $[0];if($.length>1){let z=$.find((Q)=>Q.name.includes("回放")||Q.name.toLowerCase().includes("replay"));if(z)return z;let I=$.map((Q)=>`"${Q.name}" (${Q.id})`).join(", ");throw Error(`当前租户存在多个 Webhook 通道 [${I}],请通过 --webhook <idOrName> 指定目标通道。`)}throw new W4("当前租户未配置任何 Webhook 集成通道。",1,`seal-use webhook add --name <name> --result-url <url>${Y?` --corp ${Y}`:""}`)}function KP($,U){let Y,z,{sourceCorpId:I,targetCorpId:Q,activeCorp:J,force:K}=$;if(I&&Q)Y=U(I),z=U(Q);else if(I&&!Q)if(Y=U(I),Y.testCorpId)z=U(Y.testCorpId);else if(J.id!==Y.id&&J.environment==="test")z=J;else z=J;else if(!I&&Q)if(z=U(Q),z.prodCorpId)Y=U(z.prodCorpId);else if(J.id!==z.id)Y=J;else Y=J;else if(J.environment==="test")if(z=J,J Line truncated
`+"为防止测试单据污染生产审批流,禁止向生产环境重放单据。请指定测试企业 (--target-corp <testCorpId>),或在确有需要时添加 --force。",1,`seal-use webhook replay --target-corp <testCorpId>${Y.id!==z.id?` --source-corp ${Y.id}`:""}`);return{sourceCorp:Y,targetCorp:z}}async function gd($,U,Y){let z=U.seal?.endpoints?.approvalStylePreferences??"api/v1/agent/ai-approval/config",I=await K$($,z);if(Y||I.length>0)return qB0(I,Y,U.id);if(U.environment==="test"||U.id.toLowerCase().includes("test")){console.error(`[webhook-replay] 测试企业「${U.name}」未配置 Webhook 通道,正在自动创建「(Seal测-回放通道)」...`);let Q=(U.seal.url??U.source?.sealUrl??`https://${U.id.toLowerCase()}.sealai.cc`).replace(/\/+$/,"");return await _M($,Q,{name:"(Seal测-回放通道)",mode:"assisted",outgoingResultWebhook:`${Q}/api/v1/integrations/webhook/replay-mock-callback`},U.seal.endpoints.approvalStylePreferences)}throw new W4(`当前租户「${U.name}」未配置任何 Webhook 集成通道。`,1,`seal-use webhook add --name <name> --result-url <url> --corp ${U.id}`)}async function zK($){let{query:U,sourceClient:Y,targetClient:z,sourceCorp:I,targetCorp:Q,webhookSelector:J,snPrefix:K,snSuffix:G,docIdPrefix:H,docIdSuffix:W,dryRun:X,fetchFn:Z=fetch}=$,q=[];if(U.recordId){let P=await H4(Y,U.recordId);q.push(P)}else if(U.recordIds&&U.recordIds.length>0)for(let P of U.recordIds)q.push(await H4(Y,P));else if(U.sn){let T=(await i4(Y,{search:U.sn,sourceDocumentSN:U.sn,limit:20})).records.find((A)=>A.sourceDocumentSN===U.sn||A.sourceDocumentId===U.sn||A.document?.sourceDocumentSN===U.sn||A.document?.sn===U.sn);if(!T)throw Error(`在企业「${I.name}」中未找到单据编号为「${U.sn}」的审批记录。`);q.push(T)}else if(U.sns&&U.sns.length>0)for(let P of U.sns){let A=(await i4(Y,{search:P,sourceDocumentSN:P,limit:20})).records.find((j)=>j.sourceDocumentSN===P||j.sourceDocumentId===P||j.document?.sourceDocumentSN===P||j.document?.sn===P);if(!A)throw Error(`在企业「${I.name}」中未找到单据编号为「${P}」的审批记录。`);q.push(A)}else if(U.limit!==void 0){let P=await i4(Y,{limit:U.limit,status:U.status,startDate:U.startDate,endDate:U.endDate});if(!P.records.length)throw Error(`在企业「${I.name}」中未检索到符合条件的审批记录。`);q=P.records}else throw Error("Usage: seal-use webhook replay <recordId> [--sn <documentSN>] [--limit <n>] [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>] [--dry-run]");let V=q.map((P)=>({run:P,doc:hd(P,{snPrefix:K,snSuffix:G,docIdPrefix:H,docIdSuffix:W})}));if(X){let P={id:"preview-webhook",name:J??"预览目标通道",mode:"assisted",incomingDocumentWebhookUrl:`${Q.seal.url}/api/v1/integrations/webhook/preview`};try{let j=await K$(z,Q.seal.endpoints.approvalStylePreferences);if(j.length>0){let C=qB0(j,J,Q.id);P={id:C.id,name:C.name,mode:C.mode,incomingDocumentWebhookUrl:C.incomingDocumentWebhook.url}}}catch{}let T=V.map(({run:j,doc:C})=>({originalRecord:{id:j.id,sourceSystem:j.sourceSystem,sourceDocumentSN:j.sourceDocumentSN,sourceDocumentId:j.sourceDocumentId},document:C,success:!0})),A=T.length===1;return{dryRun:!0,success:!0,sourceCorp:{id:I.id,name:I.name,environment:I.environment},targetCorp:{id:Q.id,name:Q.name,environment:Q.environment},targetWebhook:P,totalCount:T.length,successCount:T.length,failureCount:0,originalRecord:A?T[0].originalRecord:void 0,document:A?T[0].document:void 0,records:T}}let F=await gd(z,Q,J),M={id:F.id,name:F.name,mode:F.mode,incomingDocumentWebhookUrl:F.incomingDocumentWebhook.url},w=[],N=0,O=0;for(let{run:P,doc:T}of V){console.error(`[webhook-replay] 正在向 Webhook 通道「${F.name}」推送单据: ${T.documentSN}...`);try{let A=await Sd(F.incomingDocumentWebhook.url,F.secret,T,Z,A6(Q.seal));w.push({originalRecord:{id:P.id,sourceSystem:P.sourceSystem,sourceDocumentSN:P.sourceDocumentSN,sourceDocumentId:P.sourceDocumentId},replayedDocument:{documentSN:T.documentSN,documentId:T.documentId,fieldCount:T.fields.length},pushResult:A,success:!0}),N+=1}catch(A){let j=A instanceof Error?A.message:String(A);w.push({originalRecord:{id:P.id,sourceSystem:P.sourceSystem,sourceDocumentSN:P.sourceDocumentSN,sourceDocumentId:P.sourceDocumentId},replayedDocument:{documentSN:T.documentSN,documentId:T.documentId,fieldCount:T.fields.length},error:j,success:!1}),O+=1}}let D=w.length===1;return{success:O===0,dryRun:!1,sourceCorp:{id:I.id,name:I.name,environment:I.environment},targetCorp:{id:Q.id,name:Q.name,environment:Q.environment},targetWebhook:M,totalCount:w.length,successCount:N,failureCount:O,originalRecord:D?w[0].originalRecord:void 0,replayedDocument:D?w[0].replayedDocument:void 0,pushResult:D?w[0].pushResult:void 0,records:w}}var vA1;var iZ=m(()=>{QP();O8();X6();vA1=new Set(["TEXT","NUMBER","DATE","AMOUNT","PERSON","ATTACHMENT","DATE_RANGE","DEPARTMENT","LIST","CITY","OBJECT"])});var VB0,d44,SA1,p44;var LB0=m(()=>{T$();VB0=L.object({level:L.enum(["error","warning" Line truncated
* ==============================================================================
* Seal 官方标准规则校验器 (Official Standard Rule Linter)
* ==============================================================================
@@ -881,68 +881,65 @@ export function lintRule(rule: RuleLintTarget): RuleLintResult {
}
export default lintRule;
`}});import{existsSync as LU,mkdirSync as NA1,readFileSync as DA1,readdirSync as KB0,rmSync as AA1,unlinkSync as BA1,writeFileSync as PA1}from"node:fs";import{homedir as jA1}from"node:os";import{isAbsolute as TA1,join as b6,resolve as EA1}from"node:path";import{pathToFileURL as JB0}from"node:url";function GB0($=n$){let Y=[],z=[];try{if(!LU($))NA1($,{recursive:!0});let U=Object.keys(Ep);for(let[J,I]of Object.entries(Ep)){let K=b6($,J),G=!0;if(LU(K))try{if(DA1(K,"utf8")===I)G=!1}catch{G=!0}if(G)PA1(K,I,"utf8");Y.push(J)}let Q=KB0($,{withFileTypes:!0});for(let J of Q)if(!U.includes(J.name)){let I=b6($,J.name);try{if(J.isDirectory())AA1(I,{recursive:!0,force:!0});else BA1(I);z.push(J.name)}catch{}}}catch{}return{synced:Y,pruned:z}}function HB0($={syncOfficial:!0}){if($.syncOfficial!==!1)GB0();let Y=[{name:"builtin",type:"builtin",path:b6(n$,"builtin.ts"),description:"Seal 官方标准校验器 (拦截过短描述、主观模糊词与悬空例外条款)"},{name:"strict",type:"official",path:b6(n$,"strict.ts"),description:"Seal 官方严格风控校验器 (强校验字数、刚性定量约束、凭证依据与具体审批人角色)"},{name:"hlab",type:"official",path:b6(n$,"hlab.ts"),description:"合思实验室 (HLab) 结构化规则校验器 (SOP 四段论结构、三元闭环判定、剥离处置动作与防漏判)"}],z=[i$,YP];for(let U of z)if(LU(U))try{let Q=KB0(U,{withFileTypes:!0});for(let J of Q){if(J.isDirectory())continue;let I=J.name;if(I.endsWith(".ts")||I.endsWith(".js")||I.endsWith(".mjs")){let K=I.replace(/\.(ts|js|mjs)$/,"");if(!Y.some((G)=>G.name===K))Y.push({name:K,type:"custom",path:b6(U,I),description:`用户自定义规则校验器 (${I})`})}}}catch{}return Y}function RA1($){let Y=($||"").trim();if(!Y||Y==="builtin"||Y==="default"||Y==="official/builtin"||Y==="official/builtin.ts")return{path:b6(n$,"builtin.ts"),isOfficial:!0,officialKind:"builtin"};if(Y==="strict"||Y==="official/strict"||Y==="official/strict.ts")return{path:b6(n$,"strict.ts"),isOfficial:!0,officialKind:"strict"};if(Y==="hlab"||Y==="hlab-sop"||Y==="hlab-rules"||Y==="hlab-standard"||Y==="official/hlab"||Y==="official/hlab.ts")return{path:b6(n$,"hlab.ts"),isOfficial:!0,officialKind:"hlab"};if(TA1(Y)||Y.startsWith("./")||Y.startsWith("../")){let U=EA1(Y);if(LU(U))return{path:U};for(let Q of[".ts",".js",".mjs"])if(LU(`${U}${Q}`))return{path:`${U}${Q}`}}let z=[b6(i$,`${Y}.ts`),b6(i$,`${Y}.js`),b6(i$,`${Y}.mjs`),b6(YP,`${Y}.ts`),b6(YP,`${Y}.js`),b6(YP,`${Y}.mjs`)];for(let U of z)if(LU(U))return{path:U};return{}}async function Rp($){GB0();let Y=RA1($??"builtin");if(Y.isOfficial){let U=Y.officialKind==="strict"?UB0:Y.officialKind==="hlab"?QB0:UK,Q=Y.officialKind==="builtin"?"builtin":"official",J=Y.path;if(J&&LU(J))try{let K=await import(JB0(J).href),G=K.default??K.lintRule??K.linter??K.lint;if(typeof G==="function")return{name:Y.officialKind??"builtin",type:Q,filePath:J,linter:IB0(G,U)}}catch{}return{name:Y.officialKind??"builtin",type:Q,filePath:J,linter:U}}let z=Y.path;if(!z)return console.error(`⚠️ [linter] 未找到自定义校验器 "${$}",已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:UK};try{let Q=await import(JB0(z).href),J=Q.default??Q.lintRule??Q.linter??Q.lint;if(typeof J!=="function")return console.error(`⚠️ [linter] 自定义校验器 "${z}" 未导出标准函数 (default / lintRule),已安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:UK};return{name:$??"custom",type:"custom",filePath:z,linter:IB0(J,UK)}}catch(U){return console.error(`⚠️ [linter] 加载自定义校验器脚本 "${z}" 失败(语法错误或依赖缺失: ${U?.message??U}),已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:UK}}}function IB0($,Y){return async(z,U)=>{try{let Q=await $(z,U);if(Q&&typeof Q==="object"&&typeof Q.score==="number"&&Array.isArray(Q.issues))return Q;return console.error("⚠️ [linter] 自定义校验器返回值格式不符合 RuleLintResult 契约,已回退至内置结果。"),Y(z,U)}catch(Q){return console.error("⚠️ [linter] 自定义校验器执行异常:",Q),Y(z,U)}}}var i$,CA1="official",n$,YP;var _p=m(()=>{Pp();Tp();Cp();jp();i$=b6(jA1(),".config","seal-use","linters"),n$=b6(i$,CA1),YP=b6(process.cwd(),"linters")});async function vp($,Y,z){let U=await Y.linter($,z);return{ruleId:$.id,ruleCode:$.code,ruleName:$.name,score:U.score,passed:U.passed,issues:U.issues,description:$.description}}async function WB0($,Y,z,U){let Q=U?.minScore??0,J=U?.level??"all",I=[],K=0;for(let q of $){let V=await vp(q,Y,z);K+=V.score;let F=V.issues;if(J==="error")F=V.issues.filter((O)=>O.level==="error");else if(J==="warning")F=V.issues.filter((O)=>O.level==="warning"||O.level==="error");let w=F.every((O)=>O.level!=="error");if(U?.summary){if(F.length>0)I.push({...V,passed:w,issues:F})}else I.push({...V,passed:w,issues:F})}let G=$.length,H=G===0?100:Math.round(K/G),W=I.filter((q)=>q.issues.length>0).length,X=G-Line truncated
`,"utf8"),z}function VB0($){return $.map((Y,z)=>{let U;if(typeof Y.code==="number")U=`#${String(Y.code).padStart(4,"0")}`;else if(typeof Y.code==="string")U=Y.code.startsWith("#")?Y.code:`#${Y.code}`;else U=`#${String(z+1).padStart(4,"0")}`;return{id:Y.id,code:U,name:Y.name,description:Y.description,scope:Y.scope,strictness:Y.strictness}})}var LB0=()=>{};var FB0,B5;var QK=m(()=>{FB0=class FB0 extends Error{errors;warnings;constructor($,Y=[]){super([`webhook 资源包校验失败:${$.length} 个错误`,...$.map((z)=>`- ${z}`)].join(`
`));this.errors=$;this.warnings=Y;this.name="ResourcePackValidationError"}};B5=FB0});var NB0=E((i44,MB0)=>{MB0.exports=zP;function zP(){this.pending=0,this.max=1/0,this.listeners=[],this.waiting=[],this.error=null}zP.prototype.go=function($){if(this.pending<this.max)wB0(this,$);else this.waiting.push($)};zP.prototype.wait=function($){if(this.pending===0)$(this.error);else this.listeners.push($)};zP.prototype.hold=function(){return OB0(this)};function OB0($){$.pending+=1;var Y=!1;return z;function z(Q){if(Y)throw Error("callback called twice");if(Y=!0,$.error=$.error||Q,$.pending-=1,$.waiting.length>0&&$.pending<$.max)wB0($,$.waiting.shift());else if($.pending===0){var J=$.listeners;$.listeners=[],J.forEach(U)}}function U(Q){Q($.error)}}function wB0($,Y){Y(OB0($))}});var BB0=E((fA1)=>{var gp=I0("fs"),yp=I0("util"),DB0=I0("stream"),AB0=DB0.Readable,kA1=DB0.PassThrough,xA1=NB0(),UP=I0("events").EventEmitter;fA1.BufferSlicer=IK;fA1.FdSlicer=JK;yp.inherits(JK,UP);function JK($){UP.call(this),this.fd=$,this.pend=new xA1,this.pend.max=1,this.refCount=0}JK.prototype.read=function($,Y,z,U,Q){var J=this;J.pend.go(function(I){gp.read(J.fd,$,Y,z,U,function(K,G,H){I(),Q(K,G,H)})})};JK.prototype.createReadStream=function($){return new uZ(this,$)};JK.prototype.ref=function(){this.refCount+=1};JK.prototype.unref=function(){var $=this;if($.refCount-=1,$.refCount<0)throw Error("invalid unref");if($.refCount>0)return;gp.close($.fd,Y);function Y(z){if(z)$.emit("error",z);else $.emit("close")}};yp.inherits(uZ,AB0);function uZ($,Y){Y=Y||{},AB0.call(this,Y),this.context=$,this.context.ref(),this.start=Y.start||0,this.endOffset=Y.end,this.pos=this.start}uZ.prototype._read=function($){var Y=this,z=Math.min(Y._readableState.highWaterMark,$);if(Y.endOffset!=null)z=Math.min(z,Y.endOffset-Y.pos);if(z<=0){Y.push(null),this._cleanup();return}Y.context.pend.go(function(U){var Q=Buffer.allocUnsafe(z);gp.read(Y.context.fd,Q,0,z,Y.pos,function(J,I){if(J)Y.destroy(J);else if(I===0)Y.push(null),Y._cleanup();else Y.pos+=I,Y.push(Q.slice(0,I));U()})})};uZ.prototype._destroy=function($,Y){this._cleanup(),Y($)};uZ.prototype._cleanup=function(){if(this.context!=null)this.context.unref(),this.context=null};yp.inherits(IK,UP);function IK($){UP.call(this),this.refCount=0,this.buffer=$}IK.prototype.read=function($,Y,z,U,Q){if(!(0<=Y&&Y<=$.length))throw RangeError("offset outside buffer: 0 <= "+Y+" <= "+$.length);if(U<0)throw RangeError("position is negative: "+U);if(Y+z>$.length)z=$.length-Y;if(U+z>this.buffer.length)z=this.buffer.length-U;if(z<=0){setImmediate(function(){Q(null,0)});return}this.buffer.copy($,Y,U,U+z),setImmediate(function(){Q(null,z)})};IK.prototype.createReadStream=function($){$=$||{};var Y=new kA1($);Y.start=$.start||0,Y.endOffset=$.end,Y.pos=Y.endOffset||this.buffer.length;var z=this.buffer.slice(Y.start,Y.pos),U=65536,Q=0;while(!0){var J=Q+U;if(J>=z.length){if(Q<z.length)Y.write(z.slice(Q,z.length));break}Y.write(z.slice(Q,J)),Q=J}return Y.end(),Y};IK.prototype.ref=function(){this.refCount+=1};IK.prototype.unref=function(){if(this.refCount-=1,this.refCount<0)throw Error("invalid unref")}});var jB0=E((c44,PB0)=>{var iA1=new Int32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462, Line truncated
`}});import{existsSync as Lz,mkdirSync as lA1,readFileSync as oA1,readdirSync as NB0,rmSync as rA1,unlinkSync as sA1,writeFileSync as aA1}from"node:fs";import{homedir as tA1}from"node:os";import{isAbsolute as eA1,join as b6,resolve as $B1}from"node:path";import{pathToFileURL as MB0}from"node:url";function DB0($=d$){let U=[],Y=[];try{if(!Lz($))lA1($,{recursive:!0});let z=Object.keys(fd);for(let[Q,J]of Object.entries(fd)){let K=b6($,Q),G=!0;if(Lz(K))try{if(oA1(K,"utf8")===J)G=!1}catch{G=!0}if(G)aA1(K,J,"utf8");U.push(Q)}let I=NB0($,{withFileTypes:!0});for(let Q of I)if(!z.includes(Q.name)){let J=b6($,Q.name);try{if(Q.isDirectory())rA1(J,{recursive:!0,force:!0});else sA1(J);Y.push(Q.name)}catch{}}}catch{}return{synced:U,pruned:Y}}function AB0($={syncOfficial:!0}){if($.syncOfficial!==!1)DB0();let U=[{name:"builtin",type:"builtin",path:b6(d$,"builtin.ts"),description:"Seal 官方标准校验器 (拦截过短描述、主观模糊词与悬空例外条款)"},{name:"strict",type:"official",path:b6(d$,"strict.ts"),description:"Seal 官方严格风控校验器 (强校验字数、刚性定量约束、凭证依据与具体审批人角色)"},{name:"hlab",type:"official",path:b6(d$,"hlab.ts"),description:"合思实验室 (HLab) 结构化规则校验器 (SOP 四段论结构、三元闭环判定、剥离处置动作与防漏判)"}],Y=[c$,GP];for(let z of Y)if(Lz(z))try{let I=NB0(z,{withFileTypes:!0});for(let Q of I){if(Q.isDirectory())continue;let J=Q.name;if(J.endsWith(".ts")||J.endsWith(".js")||J.endsWith(".mjs")){let K=J.replace(/\.(ts|js|mjs)$/,"");if(!U.some((G)=>G.name===K))U.push({name:K,type:"custom",path:b6(z,J),description:`用户自定义规则校验器 (${J})`})}}}catch{}return U}function YB1($){let U=($||"").trim();if(!U||U==="builtin"||U==="default"||U==="official/builtin"||U==="official/builtin.ts")return{path:b6(d$,"builtin.ts"),isOfficial:!0,officialKind:"builtin"};if(U==="strict"||U==="official/strict"||U==="official/strict.ts")return{path:b6(d$,"strict.ts"),isOfficial:!0,officialKind:"strict"};if(U==="hlab"||U==="hlab-sop"||U==="hlab-rules"||U==="hlab-standard"||U==="official/hlab"||U==="official/hlab.ts")return{path:b6(d$,"hlab.ts"),isOfficial:!0,officialKind:"hlab"};if(eA1(U)||U.startsWith("./")||U.startsWith("../")){let z=$B1(U);if(Lz(z))return{path:z};for(let I of[".ts",".js",".mjs"])if(Lz(`${z}${I}`))return{path:`${z}${I}`}}let Y=[b6(c$,`${U}.ts`),b6(c$,`${U}.js`),b6(c$,`${U}.mjs`),b6(GP,`${U}.ts`),b6(GP,`${U}.js`),b6(GP,`${U}.mjs`)];for(let z of Y)if(Lz(z))return{path:z};return{}}async function bd($){DB0();let U=YB1($??"builtin");if(U.isOfficial){let z=U.officialKind==="strict"?wB0:U.officialKind==="hlab"?FB0:IK,I=U.officialKind==="builtin"?"builtin":"official",Q=U.path;if(Q&&Lz(Q))try{let K=await import(MB0(Q).href),G=K.default??K.lintRule??K.linter??K.lint;if(typeof G==="function")return{name:U.officialKind??"builtin",type:I,filePath:Q,linter:OB0(G,z)}}catch{}return{name:U.officialKind??"builtin",type:I,filePath:Q,linter:z}}let Y=U.path;if(!Y)return console.error(`⚠️ [linter] 未找到自定义校验器 "${$}",已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:IK};try{let I=await import(MB0(Y).href),Q=I.default??I.lintRule??I.linter??I.lint;if(typeof Q!=="function")return console.error(`⚠️ [linter] 自定义校验器 "${Y}" 未导出标准函数 (default / lintRule),已安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:IK};return{name:$??"custom",type:"custom",filePath:Y,linter:OB0(Q,IK)}}catch(z){return console.error(`⚠️ [linter] 加载自定义校验器脚本 "${Y}" 失败(语法错误或依赖缺失: ${z?.message??z}),已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:IK}}}function OB0($,U){return async(Y,z)=>{try{let I=await $(Y,z);if(I&&typeof I==="object"&&typeof I.score==="number"&&Array.isArray(I.issues))return I;return console.error("⚠️ [linter] 自定义校验器返回值格式不符合 RuleLintResult 契约,已回退至内置结果。"),U(Y,z)}catch(I){return console.error("⚠️ [linter] 自定义校验器执行异常:",I),U(Y,z)}}}var c$,UB1="official",d$,GP;var id=m(()=>{yd();xd();ud();kd();c$=b6(tA1(),".config","seal-use","linters"),d$=b6(c$,UB1),GP=b6(process.cwd(),"linters")});async function nd($,U,Y){let z=await U.linter($,Y);return{ruleId:$.id,ruleCode:$.code,ruleName:$.name,score:z.score,passed:z.passed,issues:z.issues,description:$.description}}async function BB0($,U,Y,z){let I=z?.minScore??0,Q=z?.level??"all",J=[],K=0;for(let q of $){let V=await nd(q,U,Y);K+=V.score;let F=V.issues;if(Q==="error")F=V.issues.filter((w)=>w.level==="error");else if(Q==="warning")F=V.issues.filter((w)=>w.level==="warning"||w.level==="error");let M=F.every((w)=>w.level!=="error");if(z?.summary){if(F.length>0)J.push({...V,passed:M,issues:F})}else J.push({...V,passed:M,issues:F})}let G=$.length,H=G===0?100:Math.round(K/G),W=J.filter((q)=>q.issues.length>0).length,X=G-Line truncated
`,"utf8"),Y}function EB0($){return $.map((U,Y)=>{let z;if(typeof U.code==="number")z=`#${String(U.code).padStart(4,"0")}`;else if(typeof U.code==="string")z=U.code.startsWith("#")?U.code:`#${U.code}`;else z=`#${String(Y+1).padStart(4,"0")}`;return{id:U.id,code:z,name:U.name,description:U.description,scope:U.scope,strictness:U.strictness}})}var CB0=()=>{};var RB0,j5;var QK=m(()=>{RB0=class RB0 extends Error{errors;warnings;constructor($,U=[]){super([`webhook 资源包校验失败:${$.length} 个错误`,...$.map((Y)=>`- ${Y}`)].join(`
`));this.errors=$;this.warnings=U;this.name="ResourcePackValidationError"}};j5=RB0});var SB0=E((O64,hB0)=>{hB0.exports=HP;function HP(){this.pending=0,this.max=1/0,this.listeners=[],this.waiting=[],this.error=null}HP.prototype.go=function($){if(this.pending<this.max)vB0(this,$);else this.waiting.push($)};HP.prototype.wait=function($){if(this.pending===0)$(this.error);else this.listeners.push($)};HP.prototype.hold=function(){return _B0(this)};function _B0($){$.pending+=1;var U=!1;return Y;function Y(I){if(U)throw Error("callback called twice");if(U=!0,$.error=$.error||I,$.pending-=1,$.waiting.length>0&&$.pending<$.max)vB0($,$.waiting.shift());else if($.pending===0){var Q=$.listeners;$.listeners=[],Q.forEach(z)}}function z(I){I($.error)}}function vB0($,U){U(_B0($))}});var kB0=E((XB1)=>{var pd=J0("fs"),md=J0("util"),gB0=J0("stream"),yB0=gB0.Readable,HB1=gB0.PassThrough,WB1=SB0(),WP=J0("events").EventEmitter;XB1.BufferSlicer=KK;XB1.FdSlicer=JK;md.inherits(JK,WP);function JK($){WP.call(this),this.fd=$,this.pend=new WB1,this.pend.max=1,this.refCount=0}JK.prototype.read=function($,U,Y,z,I){var Q=this;Q.pend.go(function(J){pd.read(Q.fd,$,U,Y,z,function(K,G,H){J(),I(K,G,H)})})};JK.prototype.createReadStream=function($){return new nZ(this,$)};JK.prototype.ref=function(){this.refCount+=1};JK.prototype.unref=function(){var $=this;if($.refCount-=1,$.refCount<0)throw Error("invalid unref");if($.refCount>0)return;pd.close($.fd,U);function U(Y){if(Y)$.emit("error",Y);else $.emit("close")}};md.inherits(nZ,yB0);function nZ($,U){U=U||{},yB0.call(this,U),this.context=$,this.context.ref(),this.start=U.start||0,this.endOffset=U.end,this.pos=this.start}nZ.prototype._read=function($){var U=this,Y=Math.min(U._readableState.highWaterMark,$);if(U.endOffset!=null)Y=Math.min(Y,U.endOffset-U.pos);if(Y<=0){U.push(null),this._cleanup();return}U.context.pend.go(function(z){var I=Buffer.allocUnsafe(Y);pd.read(U.context.fd,I,0,Y,U.pos,function(Q,J){if(Q)U.destroy(Q);else if(J===0)U.push(null),U._cleanup();else U.pos+=J,U.push(I.slice(0,J));z()})})};nZ.prototype._destroy=function($,U){this._cleanup(),U($)};nZ.prototype._cleanup=function(){if(this.context!=null)this.context.unref(),this.context=null};md.inherits(KK,WP);function KK($){WP.call(this),this.refCount=0,this.buffer=$}KK.prototype.read=function($,U,Y,z,I){if(!(0<=U&&U<=$.length))throw RangeError("offset outside buffer: 0 <= "+U+" <= "+$.length);if(z<0)throw RangeError("position is negative: "+z);if(U+Y>$.length)Y=$.length-U;if(z+Y>this.buffer.length)Y=this.buffer.length-z;if(Y<=0){setImmediate(function(){I(null,0)});return}this.buffer.copy($,U,z,z+Y),setImmediate(function(){I(null,Y)})};KK.prototype.createReadStream=function($){$=$||{};var U=new HB1($);U.start=$.start||0,U.endOffset=$.end,U.pos=U.endOffset||this.buffer.length;var Y=this.buffer.slice(U.start,U.pos),z=65536,I=0;while(!0){var Q=I+z;if(Q>=Y.length){if(I<Y.length)U.write(Y.slice(I,Y.length));break}U.write(Y.slice(I,Q)),I=Q}return U.end(),U};KK.prototype.ref=function(){this.refCount+=1};KK.prototype.unref=function(){if(this.refCount-=1,this.refCount<0)throw Error("invalid unref")}});var fB0=E((D64,xB0)=>{var VB1=new Int32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462, Line truncated
\v\f\r\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F !"#$٪&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~°·∙√▒─│┼┤┬├┴┐┌└┘β∞φ±½¼≈«»ﻷﻸ��ﻻﻼ� ­ﺂ£¤ﺄ��ﺎﺏﺕﺙ،ﺝﺡﺥ٠١٢٣٤٥٦٧٨٩ﻑ؛ﺱﺵﺹ؟¢ﺀﺁﺃﺅﻊﺋﺍﺑﺓﺗﺛﺟﺣﺧﺩﺫﺭﺯﺳﺷﺻﺿﻁﻅﻋﻏ¦¬÷×ﻉـﻓﻗﻛﻟﻣﻧﻫﻭﻯﻳﺽﻌﻎﻍﻡﹽّﻥﻩﻬﻰﻲﻐﻕﻵﻶﻝﻙﻱ■�`},ibm864:"cp864",csibm864:"cp864",cp865:{type:"_sbcs",chars:"ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø₧ƒáíóúñѪº¿⌐¬½¼¡«¤░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ "},ibm865:"cp865",csibm865:"cp865",cp866:{type:"_sbcs",chars:"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмноп░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀рстуфхцчшщъыьэюяЁёЄєЇїЎў°∙·√№¤■ "},ibm866:"cp866",csibm866:"cp866",cp869:{type:"_sbcs",chars:"������Ά�·¬¦‘’Έ―ΉΊΪΌ��ΎΫ©Ώ²³ά£έήίϊΐόύΑΒΓΔΕΖΗ½ΘΙ«»░▒▓│┤ΚΛΜΝ╣║╗╝ΞΟ┐└┴┬├─┼ΠΡ╚╔╩╦╠═╬ΣΤΥΦΧΨΩαβγ┘┌█▄δε▀ζηθικλμνξοπρσςτ΄­±υφχ§ψ΅°¨ωϋΰώ■ "},ibm869:"cp869",csibm869:"cp869",cp922:{type:"_sbcs",chars:"€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®‾°±²³´µ·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏŠÑÒÓÔÕÖרÙÚÛÜÝŽßàáâãäåæçèéêëìíîïšñòóôõö÷øùúûüýžÿ"},ibm922:"cp922",csibm922:"cp922",cp1046:{type:"_sbcs",chars:"ﺈ×÷ﹱˆ■│─┐┌└┘ﹹﹻﹽﹿﹷﺊﻰﻳﻲﻎﻏﻐﻶﻸﻺﻼ ¤ﺋﺑﺗﺛﺟﺣ،­ﺧﺳ٠١٢٣٤٥٦٧٨٩ﺷ؛ﺻﺿﻊ؟ﻋءآأؤإئابةتثجحخدذرزسشصضطﻇعغﻌﺂﺄﺎﻓـفقكلمنهوىيًٌٍَُِّْﻗﻛﻟﻵﻷﻹﻻﻣﻧﻬﻩ�"},ibm1046:"cp1046",csibm1046:"cp1046",cp1124:{type:"_sbcs",chars:"€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ЁЂҐЄЅІЇЈЉЊЋЌ­ЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя№ёђґєѕіїјљњћќ§ўџ"},ibm1124:"cp1124",csibm1124:"cp1124",cp1125:{type:"_sbcs",chars:"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмноп░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀рстуфхцчшщъыьэюяЁёҐґЄєІіЇї·√№¤■ "},ibm1125:"cp1125",csibm1125:"cp1125",cp1129:{type:"_sbcs",chars:"€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§œ©ª«¬­®¯°±²³Ÿµ·Œ¹º»¼½¾¿ÀÁÂĂÄÅÆÇÈÉÊË̀ÍÎÏĐÑ̉ÓÔƠÖרÙÚÛÜỮßàáâăäåæçèéêë́íîïđṇ̃óôơö÷øùúûüư₫ÿ"},ibm1129:"cp1129",csibm1129:"cp1129",cp1133:{type:"_sbcs",chars:"€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ກຂຄງຈສຊຍດຕຖທນບປຜຝພຟມຢຣລວຫອຮ���ຯະາຳິີຶືຸູຼັົຽ���ເແໂໃໄ່້໊໋໌ໍໆ�ໜໝ₭����������������໐໑໒໓໔໕໖໗໘໙��¢¬¦�"},ibm1133:"cp1133",csibm1133:"cp1133",cp1161:{type:"_sbcs",chars:"��������������������������������่กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู้๊๋€฿เแโใไๅๆ็่้๊๋์ํ๎๏๐๑๒๓๔๕๖๗๘๙๚๛¢¬¦ "},ibm1161:"cp1161",csibm1161:"cp1161",cp1162:{type:"_sbcs",chars:"€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู����฿เแโใไๅๆ็่้๊๋์ํ๎๏๐๑๒๓๔๕๖๗๘๙๚๛����"},ibm1162:"cp1162",csibm1162:"cp1162",cp1163:{type:"_sbcs",chars:"€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£€¥¦§œ©ª«¬­®¯°±²³Ÿµ·Œ¹º»¼½¾¿ÀÁÂĂÄÅÆÇÈÉÊË̀ÍÎÏĐÑ̉ÓÔƠÖרÙÚÛÜỮßàáâăäåæçèéêë́íîïđṇ̃óôơö÷øùúûüư₫ÿ"},ibm1163:"cp1163",csiLine truncated
\v\f\r\x0E\x0F\x10ỨỰỲỶỸÝỴ\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~ÀẢÃÁẠẶẬÈẺẼÉẸỆÌỈĨÍỊÒỎÕÓỌỘỜỞỠỚỢÙỦŨ ĂÂÊÔƠƯĐăâêôơưđẶ̀̀̉̃́àảãáạẲằẳẵắẴẮẦẨẪẤỀặầẩẫấậèỂẻẽéẹềểễếệìỉỄẾỒĩíịòỔỏõóọồổỗốộờởỡớợùỖủũúụừửữứựỳỷỹýỵỐ`},georgianacademy:{type:"_sbcs",chars:"€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ·¸¹º»¼½¾¿აბგდევზთიკლმნოპჟრსტუფქღყშჩცძწჭხჯჰჱჲჳჴჵჶçèéêëìíîïðñòóôõö÷øùúûüýþÿ"},georgianps:{type:"_sbcs",chars:"€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ·¸¹º»¼½¾¿აბგდევზჱთიკლმნჲოპჟრსტჳუფქღყშჩცძწჭხჴჯჰჵæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"},pt154:{type:"_sbcs",chars:"ҖҒӮғ„…ҶҮҲүҠӢҢҚҺҸҗ‘’“”•–—ҳҷҡӣңқһҹ ЎўЈӨҘҰ§Ё©Ә«¬ӯ®Ҝ°ұІіҙө·ё№ә»јҪҫҝАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя"},viscii:{type:"_sbcs",chars:`\x00\x01Ẳ\x03\x04ẴẪ\x07\b
\v\f\r\x0E\x0F\x10\x11\x12\x13Ỷ\x15\x16\x17\x18Ỹ\x1A\x1B\x1C\x1DỴ\x1F !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~ẠẮẰẶẤẦẨẬẼẸẾỀỂỄỆỐỒỔỖỘỢỚỜỞỊỎỌỈỦŨỤỲÕắằặấầẩậẽẹếềểễệốồổỗỠƠộờởịỰỨỪỬơớƯÀÁÂÃẢĂẳẵÈÉÊẺÌÍĨỳĐứÒÓÔạỷừửÙÚỹỵÝỡưàáâãảăữẫèéêẻìíĩỉđựòóôõỏọụùúũủýợỮ`},iso646cn:{type:"_sbcs",chars:`\x00\x01\x02\x03\x04\x05\x06\x07\b
\v\f\r\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F !"#¥%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}‾��������������������������������������������������������������������������������������������������������������������������������`},iso646jp:{type:"_sbcs",chars:`\x00\x01\x02\x03\x04\x05\x06\x07\b
\v\f\r\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[¥]^_\`abcdefghijklmnopqrstuvwxyz{|}‾��������������������������������������������������������������������������������������������������������������������������������`},hproman8:{type:"_sbcs",chars:"€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ÀÂÈÊËÎÏ´ˋˆ¨˜ÙÛ₤¯Ýý°ÇçÑñ¡¿¤£¥§ƒ¢âêôûáéóúàèòùäëöüÅîØÆåíøæÄìÖÜÉïßÔÁÃãÐðÍÌÓÒÕõŠšÚŸÿÞþ·µ¾—¼½ªº«■»±�"},macintosh:{type:"_sbcs",chars:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄¤‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ�ÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ"},ascii:{type:"_sbcs",chars:"��������������������������������������������������������������������������������������������������������������������������������"},tis620:{type:"_sbcs",chars:"���������������������������������กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู����฿เแโใไๅๆ็่้๊๋์ํ๎๏๐๑๒๓๔๕๖๗๘๙๚๛����"}}});var UP0=E((uB1)=>{var Od=f3().Buffer;uB1._dbcs=b3;var U8=-1,zP0=-2,d$=-10,S8=-1000,qK=Array(256),nZ=-1;for(iZ=0;iZ<256;iZ++)qK[iZ]=U8;var iZ;function b3($,Y){if(this.encodingName=$.encodingName,!$)throw Error("DBCS codec is called without the data.");if(!$.table)throw Error("Encoding '"+this.encodingName+"' has no data.");var z=$.table();this.decodeTables=[],this.decodeTables[0]=qK.slice(0),this.decodeTableSeq=[];for(var U=0;U<z.length;U++)this._addDecodeChunk(z[U]);if(typeof $.gb18030==="function"){this.gb18030=$.gb18030();var Q=this.decodeTables.length;this.decodeTables.push(qK.slice(0));var J=this.decodeTables.length;this.decodeTables.push(qK.slice(0));var I=this.decodeTables[0];for(var U=129;U<=254;U++){var K=this.decodeTables[S8-I[U]];for(var G=48;G<=57;G++){if(K[G]===U8)K[G]=S8-Q;else if(K[G]>S8)throw Error("gb18030 decode tables conflict at byte 2");var H=this.decodeTables[S8-K[G]];for(var W=129;W<=254;W++){if(H[W]===U8)H[W]=S8-J;else if(H[W]===S8-J)continue;else if(H[W]>S8)throw Error("gb18030 decode tables conflict at byte 3");var X=this.decodeTables[S8-H[W]];for(var Z=48;Z<=57;Z++)if(X[Z]===U8)X[Z]=zP0}}}}this.defaultCharUnicode=Y.defaultCharUnicode,this.encodeTable=[],this.encodeTableSeq=[];var q={};if($.encodeSkipVals)for(var U=0;U<$.encodeSkipVals.length;U++){var V=$.encodeSkipVals[U];if(typeof V==="number")q[V]=!0;else for(var G=V.from;G<=V.to;G++)q[G]=!0}if(this._fillEncodeTable(0,0,q),$.encodeAdd){for(var F in $.encodeAdd)if(Object.prototype.hasOwnProperty.call($.encodeAdd,F))this._setEncodeChar(F.charCodeAt(0),$.encodeAdd[F])}if(this.defCharSB=this.encodeTable[0][Y.defaultCharSingleByte.charCodeAt(0)],this.defCharSB===U8)this.defCharSB=this.encodeTable[0]["?"];if(this.defCharSB===U8)this.defCharSB=63}b3.prototype.encoder=FP;b3.prototype.decoder=wd;b3.prototype._getDecodeTrieNode=function($){var Y=[];for(;$>0;$>>>=8)Y.push($&255);if(Y.length==0)Y.push(0);var z=this.decodeTables[0];for(var U=Y.length-1;U>0;U--){var Q=z[Y[U]];if(Q==U8)z[Y[U]]=S8-this.decodeTables.length,this.decodeTables.push(z=qK.slice(0));else if(Q<=S8)z=this.decodeTables[S8-Q];else throw Error("Overwrite byte in "+this.encodingName+", addr: "+$.toString(16))}return z};b3.prototype._addDecodeChunk=function($){var Y=parseInt($[0],16),z=this._getDecodeTrieNode(Y);Y=Y&255;for(var U=1;U<$.length;U++){var Q=$[U];if(typeof Q==="string")for(var J=0;J<Q.length;){var I=Q.charCodeAt(J++);if(I>=55296&&I<56320){var K=Q.charCodeAt(J++);if(K>=56320&&K<57344)z[Y++]=65536+(I-55296)*1024+(K-56320);else throw Error("Incorrect surrogate pair in "+this.encodingName+" at chunk "+$[0])}else if(I>4080&&I<=4095){var G=4095-I+2,H=[];for(var W=0;W<G;W++)H.push(Q.charCodeAt(J++));z[Y++]=d$-this.decodeTableSeq.length,this.decodeTableSeq.push(H)}else z[Y++]=I}else if(typeof Q==="number"){var X=z[Y-1]+1;for(var J=0;J<Q;J++)z[Y++]=X++}else throw Error("Incorrect type '"+typeof Q+"' given in "+this.encodingName+" at chunk "+$[0])}if(Y>255)throw Error("Incorrect chunk in "+this.encoLine truncated
`;super(Y);this.name="AggregateError",this.errors=$}}Zj0.exports={AggregateError:Xj0,ArrayIsArray($){return Array.isArray($)},ArrayPrototypeIncludes($,Y){return $.includes(Y)},ArrayPrototypeIndexOf($,Y){return $.indexOf(Y)},ArrayPrototypeJoin($,Y){return $.join(Y)},ArrayPrototypeMap($,Y){return $.map(Y)},ArrayPrototypePop($,Y){return $.pop(Y)},ArrayPrototypePush($,Y){return $.push(Y)},ArrayPrototypeSlice($,Y,z){return $.slice(Y,z)},Error,FunctionPrototypeCall($,Y,...z){return $.call(Y,...z)},FunctionPrototypeSymbolHasInstance($,Y){return Function.prototype[Symbol.hasInstance].call($,Y)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties($,Y){return Object.defineProperties($,Y)},ObjectDefineProperty($,Y,z){return Object.defineProperty($,Y,z)},ObjectGetOwnPropertyDescriptor($,Y){return Object.getOwnPropertyDescriptor($,Y)},ObjectKeys($){return Object.keys($)},ObjectSetPrototypeOf($,Y){return Object.setPrototypeOf($,Y)},Promise,PromisePrototypeCatch($,Y){return $.catch(Y)},PromisePrototypeThen($,Y,z){return $.then(Y,z)},PromiseReject($){return Promise.reject($)},PromiseResolve($){return Promise.resolve($)},ReflectApply:Reflect.apply,RegExpPrototypeTest($,Y){return $.test(Y)},SafeSet:Set,String,StringPrototypeSlice($,Y,z){return $.slice(Y,z)},StringPrototypeToLowerCase($){return $.toLowerCase()},StringPrototypeToUpperCase($){return $.toUpperCase()},StringPrototypeTrim($){return $.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet($,Y,z){return $.set(Y,z)},Boolean,Uint8Array}});var id=E((l64,qj0)=>{qj0.exports={format($,...Y){return $.replace(/%([sdifj])/g,function(...[z,U]){let Q=Y.shift();if(U==="f")return Q.toFixed(6);else if(U==="j")return JSON.stringify(Q);else if(U==="s"&&typeof Q==="object")return`${Q.constructor!==Object?Q.constructor.name:""} {}`.trim();else return Q.toString()})},inspect($){switch(typeof $){case"string":if($.includes("'")){if(!$.includes('"'))return`"${$}"`;else if(!$.includes("`")&&!$.includes("${"))return`\`${$}\``}return`'${$}'`;case"number":if(isNaN($))return"NaN";else if(Object.is($,-0))return String($);return $;case"bigint":return`${String($)}n`;case"boolean":case"undefined":return String($);case"object":return"{}"}}}});var w8=E((o64,Oj0)=>{var{format:hj1,inspect:AP}=id(),{AggregateError:Sj1}=x4(),gj1=globalThis.AggregateError||Sj1,yj1=Symbol("kIsNodeError"),kj1=["string","function","number","object","Function","Object","boolean","bigint","symbol"],xj1=/^([A-Z][a-z0-9]*)+$/,BP={};function wU($,Y){if(!$)throw new BP.ERR_INTERNAL_ASSERTION(Y)}function Vj0($){let Y="",z=$.length,U=$[0]==="-"?1:0;for(;z>=U+4;z-=3)Y=`_${$.slice(z-3,z)}${Y}`;return`${$.slice(0,z)}${Y}`}function fj1($,Y,z){if(typeof Y==="function")return wU(Y.length<=z.length,`Code: ${$}; The provided arguments length (${z.length}) does not match the required ones (${Y.length}).`),Y(...z);let U=(Y.match(/%[dfijoOs]/g)||[]).length;if(wU(U===z.length,`Code: ${$}; The provided arguments length (${z.length}) does not match the required ones (${U}).`),z.length===0)return Y;return hj1(Y,...z)}function Q8($,Y,z){if(!z)z=Error;class U extends z{constructor(...Q){super(fj1($,Y,Q))}toString(){return`${this.name} [${$}]: ${this.message}`}}Object.defineProperties(U.prototype,{name:{value:z.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${$}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),U.prototype.code=$,U.prototype[yj1]=!0,BP[$]=U}function Lj0($){let Y="__node_internal_"+$.name;return Object.defineProperty($,"name",{value:Y}),$}function uj1($,Y){if($&&Y&&$!==Y){if(Array.isArray(Y.errors))return Y.errors.push($),Y;let z=new gj1([Y,$],Y.message);return z.code=Y.code,z}return $||Y}class Fj0 extends Error{constructor($="The operation was aborted",Y=void 0){if(Y!==void 0&&typeof Y!=="object")throw new BP.ERR_INVALID_ARG_TYPE("options","Object",Y);super($,Y);this.code="ABORT_ERR",this.name="AbortError"}}Q8("ERR_ASSERTION","%s",Error);Q8("ERR_INVALID_ARG_TYPE",($,Y,z)=>{if(wU(typeof $==="string","'name' must be a string"),!Array.isArray(Y))Y=[Y];let U="The ";if($.endsWith(" argument"))U+=`${$} `;else U+=`"${$}" ${$.includes(".")?"property":"argument"} `;U+="must be ";let Q=[],J=[],I=[];for(let G of Y)if(wU(typeof G==="string","All expected entries have to be of type string"),kj1.includes(G))Q.push(G.toLowerCase());else if(xj1.test(G))J.push(G);else wU(G!=="object",'The value "object" should be written as "Object"'),I.push(G);if(J.length>0){let G=Q.indexOf("object");if(G!==-1)Q.splice(Q,G,1),J.push("Object")}if(Q.length>0){switch(Q.length){case 1:U+=`of type ${Q[Line truncated
`);if(Y.linkname)z+=Ol(" linkpath="+Y.linkname+`
`);let U=Y.pax;if(U)for(let Q in U)z+=Ol(" "+Q+"="+U[Q]+`
`);return c1.from(z)};kh1.decodePax=function(Y){let z={};while(Y.length){let U=0;while(U<Y.length&&Y[U]!==32)U++;let Q=parseInt(c1.toString(Y.subarray(0,U)),10);if(!Q)return z;let J=c1.toString(Y.subarray(U+1,Q-1)),I=J.indexOf("=");if(I===-1)return z;z[J.slice(0,I)]=J.slice(I+1),Y=Y.subarray(Q)}return z};kh1.encode=function(Y){let z=c1.alloc(512),U=Y.name,Q="";if(Y.typeflag===5&&U[U.length-1]!=="/")U+="/";if(c1.byteLength(U)!==U.length)return null;while(c1.byteLength(U)>100){let J=U.indexOf("/");if(J===-1)return null;Q+=Q?"/"+U.slice(0,J):U.slice(0,J),U=U.slice(J+1)}if(c1.byteLength(U)>100||c1.byteLength(Q)>155)return null;if(Y.linkname&&c1.byteLength(Y.linkname)>100)return null;if(c1.write(z,U),c1.write(z,s2(Y.mode&4095,6),100),c1.write(z,s2(Y.uid,6),108),c1.write(z,s2(Y.gid,6),116),gh1(Y.size,z,124),c1.write(z,s2(Y.mtime.getTime()/1000|0,11),136),z[156]=48+hh1(Y.type),Y.linkname)c1.write(z,Y.linkname,157);if(c1.copy(iR0,z,257),c1.copy(jh1,z,263),Y.uname)c1.write(z,Y.uname,265);if(Y.gname)c1.write(z,Y.gname,297);if(c1.write(z,s2(Y.devmajor||0,6),329),c1.write(z,s2(Y.devminor||0,6),337),Q)c1.write(z,Q,345);return c1.write(z,s2(cR0(z),6),148),z};kh1.decode=function(Y,z,U){let Q=Y[156]===0?0:Y[156]-48,J=SK(Y,0,100,z),I=r2(Y,100,8),K=r2(Y,108,8),G=r2(Y,116,8),H=r2(Y,124,12),W=r2(Y,136,12),X=vh1(Q),Z=Y[157]===0?null:SK(Y,157,100,z),q=SK(Y,265,32),V=SK(Y,297,32),F=r2(Y,329,8),w=r2(Y,337,8),O=cR0(Y);if(O===256)return null;if(O!==r2(Y,148,8))throw Error("Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?");if(Ch1(Y)){if(Y[345])J=SK(Y,345,155,z)+"/"+J}else if(Rh1(Y));else if(!U)throw Error("Invalid tar header: unknown format.");if(Q===0&&J&&J[J.length-1]==="/")Q=5;return{name:J,mode:I,uid:K,gid:G,size:H,byteOffset:0,mtime:new Date(1000*W),type:X,linkname:Z,uname:q,gname:V,devmajor:F,devminor:w,pax:null}};function Ch1($){return c1.equals(iR0,$.subarray(257,263))}function Rh1($){return c1.equals(Th1,$.subarray(257,263))&&c1.equals(Eh1,$.subarray(263,265))}function _h1($,Y,z){if(typeof $!=="number")return z;if($=~~$,$>=Y)return Y;if($>=0)return $;if($+=Y,$>=0)return $;return 0}function vh1($){switch($){case 0:return"file";case 1:return"link";case 2:return"symlink";case 3:return"character-device";case 4:return"block-device";case 5:return"directory";case 6:return"fifo";case 7:return"contiguous-file";case 72:return"pax-header";case 55:return"pax-global-header";case 27:return"gnu-long-link-path";case 28:case 30:return"gnu-long-path"}return null}function hh1($){switch($){case"file":return 0;case"link":return 1;case"symlink":return 2;case"character-device":return 3;case"block-device":return 4;case"directory":return 5;case"fifo":return 6;case"contiguous-file":return 7;case"pax-header":return 72}return 0}function nR0($,Y,z,U){for(;z<U;z++)if($[z]===Y)return z;return U}function cR0($){let Y=256;for(let z=0;z<148;z++)Y+=$[z];for(let z=156;z<512;z++)Y+=$[z];return Y}function s2($,Y){if($=$.toString(8),$.length>Y)return"7777777777777777777".slice(0,Y)+" ";return"0000000000000000000".slice(0,Y-$.length)+$+" "}function Sh1($,Y,z){Y[z]=128;for(let U=11;U>0;U--)Y[z+U]=$&255,$=Math.floor($/256)}function gh1($,Y,z){if($.toString(8).length>11)Sh1($,Y,z);else c1.write(Y,s2($,11),z)}function yh1($){let Y;if($[0]===128)Y=!0;else if($[0]===255)Y=!1;else return null;let z=[],U;for(U=$.length-1;U>0;U--){let I=$[U];if(Y)z.push(I);else z.push(255-I)}let Q=0,J=z.length;for(U=0;U<J;U++)Q+=z[U]*Math.pow(256,U);return Y?Q:-1*Q}function r2($,Y,z){if($=$.subarray(Y,Y+z),Y=0,$[Y]&128)return yh1($);else{while(Y<$.length&&$[Y]===32)Y++;let U=_h1(nR0($,32,Y,$.length),$.length,$.length);while(Y<U&&$[Y]===0)Y++;if(U===Y)return 0;return parseInt(c1.toString($.subarray(Y,U)),8)}}function SK($,Y,z,U){return c1.toString($.subarray(Y,nR0($,0,Y,Y+z)),U)}function Ol($){let Y=c1.byteLength($),z=Math.floor(Math.log(Y)/Math.log(10))+1;if(Y+z>=Math.pow(10,z))z++;return Y+z+$}});var aR0=E((f$4,sR0)=>{var{Writable:nh1,Readable:ch1,getStreamError:pR0}=Fl(),ph1=Gl(),dR0=hK(),gK=wl(),dh1=dR0.alloc(0);class mR0{constructor(){this.buffered=0,this.shifted=0,this.queue=new ph1,this._offset=0}push($){this.buffered+=$.byteLength,this.queue.push($)}shiftFirst($){return this.buffered===0?null:this._next($)}shift($){if($>this.buffered)return null;if($===0)return dh1;let Y=this._next($);if($===Y.byteLength)return Y;let z=[Y];while(($-=Y.byteLength)>0)Y=this._next($),z.push(Y);return dR0.concat(z)}_next($){let Y=this.queue.peek(),z=Y.byteLength-this._offset;if($>=z){let U=this._offset?Y.subarray(this._offset,Y.byteLength):Y;return this.queue.shift(),this._offset=0,this.buffered-=z,this.shifted+=z,U}return this.buffered-=$,this.shifted+=$,Y.subarray(this._offset,this._offset+=$)}}class lR0 extends ch1{constructor($,Y,z){super();this.header=Y,this.offset=z,this._parent=$}_read($){if(this.header.size===0)this.push(null);if(this._parent._stream===this)this._parent._update();$(null)}_predestroy(){this._parent.destroy(pR0(this))}_detach(){if(this._parent._stream= Line truncated
`),U=[await H4($,z.recordId)];else if(z.recordIds&&z.recordIds.length>0)process.stderr.write(`\uD83D\uDD0D 批量查询 ${z.recordIds.length} 条单据记录...
`),U=await Promise.all(z.recordIds.map((O)=>H4($,O)));else{let O=z.limit??10;process.stderr.write(`\uD83D\uDD0D 检索企业「${Y.name}」(${Y.id}) 的线上审核记录 (限制 ${O} 条)...
`);let M=(await i4($,{limit:O,status:z.status,startDate:z.startDate!==void 0?String(z.startDate):void 0,endDate:z.endDate!==void 0?String(z.endDate):void 0})).records??[];if(M.length===0)throw Error("未检索到符合条件的线上审核记录,无法导出 webhook 资源包。");process.stderr.write(`\uD83D\uDCE5 正在拉取 ${M.length} 条审核记录完整详情...
`),U=await Promise.all(M.map((D)=>H4($,D.id)))}let Q=new Map,J=0;for(let O of U){let N=O.document,M=O.sourceDocumentId??(typeof N?.id==="string"?N.id:void 0)??(typeof N?.sourceDocumentId==="string"?N.sourceDocumentId:void 0)??O.documentId??O.id,D=`${z.docIdPrefix??""}${M}${z.docIdSuffix??""}`,P=[];if(z.includeAttachments!==!1){let A=i2(O,{summary:!1}).attachments,T=new Set;for(let C of A){let b=C.ossSignedUrl??C.url;if(!b)continue;let k=C.fileName??C.fileId??"attachment",S=Kp(k),i=S,n=S.lastIndexOf("."),U0=n>0?S.slice(0,n):S,x=n>0?S.slice(n):"",d=1;while(T.has(i.toLowerCase()))i=`${U0}_${d}${x}`,d++;T.add(i.toLowerCase());try{process.stderr.write(`⬇ 下载单据「${D}」附件: ${k}...
`);let t=await fetch(b);if(t.ok){let e=await t.arrayBuffer(),g=Buffer.from(e);P.push({fileName:i,zipPath:`${D}/${i}`,buffer:g,sourceField:C.sourceField??"附件"}),J++}}catch(t){process.stderr.write(`⚠️ [跳过附件] 下载失败 ${k}: ${t}
`)}}}Q.set(D,P)}let I=new L_0.default.Workbook;I.creator="seal-use",I.created=new Date;let K=new Set;for(let O of Q.values())for(let N of O)K.add(N.sourceField);if(K.size===0)K.add("附件");let G=new Set;for(let O of U){let N=O.document,M=Array.isArray(N?.fields)?N.fields:[];for(let D of M)if(D&&typeof D==="object"){let P=D,j=typeof P.label==="string"?P.label.trim():typeof P.key==="string"?P.key.trim():"",A=typeof P.type==="string"?P.type.toUpperCase():"";if(j&&A!=="ATTACHMENT"&&A!=="LIST")G.add(j)}}let H=["会议编号","会议名称","状态","总金额","报销事由","申请日期"],W=Array.from(G).filter((O)=>!H.includes(O)&&O!=="单据编号"&&O!=="单号"),X=Array.from(K).map((O)=>`[附件]${O}`),Z=[...H,...W,...X],q=I.addWorksheet("主表");q.addRow(Z),q.getRow(1).font={bold:!0};for(let O of U){let N=O.document,M=O.sourceDocumentSN??(typeof N?.sn==="string"?N.sn:void 0)??(typeof N?.sourceDocumentSN==="string"?N.sourceDocumentSN:void 0)??O.id,D=O.sourceDocumentId??(typeof N?.id==="string"?N.id:void 0)??(typeof N?.sourceDocumentId==="string"?N.sourceDocumentId:void 0)??O.documentId??O.id,P=`${z.docIdPrefix??""}${D}${z.docIdSuffix??""}`,j=`${z.docIdPrefix??""}${M}${z.docIdSuffix??""}`,A=(typeof N?.title==="string"?N.title:void 0)??(typeof N?.name==="string"?N.name:void 0)??j,T="";if(typeof N?.sourceStartTime==="number")T=new Date(N.sourceStartTime*1000).toLocaleDateString("en-CA",{timeZone:"Asia/Shanghai"});else if(typeof O.createdAt==="number")T=new Date(O.createdAt).toLocaleDateString("en-CA",{timeZone:"Asia/Shanghai"});else if(typeof O.createdAt==="string")T=O.createdAt.slice(0,10);let C=new Map,b=Array.isArray(N?.fields)?N.fields:[];for(let U0 of b)if(U0&&typeof U0==="object"){let x=U0,d=typeof x.label==="string"?x.label.trim():typeof x.key==="string"?x.key.trim():"";if(d)C.set(d,x.value)}let k,S=C.get("总金额")??C.get("报销金额")??C.get("total_amount");if(typeof S==="number")k=S;else if(S&&typeof S==="object"&&"amount"in S&&typeof S.amount==="number")k=S.amount;let i=[];i.push(P),i.push(A),i.push(O.status??"已审批"),i.push(k??""),i.push(C.get("报销事由")??C.get("事由")??A),i.push(T);for(let U0 of W){let x=C.get(U0);if(x===void 0||x===null)i.push("");else if(typeof x==="object")if("amount"in x)i.push(x.amount);else i.push(JSON.stringify(x));else i.push(x)}let n=Q.get(P)??[];for(let U0 of K){let x=n.filter((d)=>d.sourceField===U0||K.size===1);if(x.length>0)i.push(x.map((d)=>d.zipPath).join(`
`));else i.push("")}q.addRow(i)}let V=WS1(z,Y);JS1(GS1(V),{recursive:!0});let F=await I.xlsx.writeBuffer();process.stderr.write(`\uD83D\uDCE6 正在压缩生成 Webhook 资源包: ${V}...
`),await new Promise((O,N)=>{let M=QS1(V),D=new Bl({zlib:{level:9}});M.on("close",()=>O()),D.on("error",(P)=>N(P)),D.pipe(M),D.append(Buffer.from(F),{name:"信息表.xlsx"});for(let P of Q.values())for(let j of P)D.append(j.buffer,{name:j.zipPath});D.finalize()});let w=IS1(V);return{filePath:V,corpId:Y.id,corpName:Y.name,recordCount:U.length,attachmentCount:J,fileSizeBytes:w.size,exportedAt:new Date().toISOString(),nextAction:`seal-use webhook resource-pack push ${V} --corp <targetCorpId>`}}var L_0;var Pl=m(()=>{q_0();B6();nB();L_0=J6(CZ(),1)});import{readFileSync as XS1}from"node:fs";function ZS1($){let Y=new URL($),z=Y.pathname.match(/\/webhook\/([^/]+)/);if(!z)throw Error("Webhook URL 必须包含 /webhook/{webhookId}/document");return{baseUrl:`${Y.protocol}//${Y.host}`,webhookId:z[1]}}function qS1($,Y){return Y.toLowerCase().endsWith(".zip")||$[0]===80&&$[1]===75&&!Y.toLowerCase().endsWith(".xlsx")}function VS1($,Y){if(!$.length)return;let z=new Set($.map((J)=>{let I=J.fileName.split("/")[0],K=I.indexOf("@");return K>=0?I.slice(0,K):I}).filter((J)=>J!=="信息表.xlsx")),U=[];for(let J of Y){let I=J.document.documentId;if((J.documentAttachments.length>0||Object.values(J.expenseAttachments).some((G)=>G.length>0)||Object.values(J.personAttachments).some((G)=>G.length>0))&&!z.has(I))U.push(`Excel 会议编号「${I}」声明了附件,但在 ZIP 中找不到对应的根目录「${I}/」或「${I}@.../」。`)}let Q=new Set(Y.map((J)=>J.document.documentId));for(let J of z)if(!Q.has(J))U.push(`ZIP 根目录对应的编号「${J}」在信息表中找不到对应的会议编号。`);if(U.length)throw new B5(U)}async function F_0($,Y,z){let U=[],Q=$;if(qS1($,Y)){U=await TP0($),CP0(U,z);let G=U.find((H)=>H.fileName==="信息表.xlsx");if(!G)throw Error("ZIP 根目录缺少信息表.xlsx");Q=await Pd($,G)}let J=await yP0(Q);VS1(U,J);let I=kP0(U,J),K=J.map((G)=>G.document);return{entries:U,parsed:J,plans:I,documents:K,fileBuffer:$}}async function kU($,Y,z){let U=await F_0($,Y,z),Q=U.parsed.map((J,I)=>_d(J.document,U.plans[I],new Map));return{warnings:[],documents:Q,attachmentPlan:U.plans}}async function Zj($,Y,z){let U=await F_0($,Y,z.materialPackFilePolicy),{baseUrl:Q,webhookId:J}=ZS1(z.webhookUrl),I=[];for(let K=0;K<U.parsed.length;K+=1){let G=U.parsed[K],H=U.plans[K],W=new Map,X=[...H.categoryFields,...Object.values(H.personAttachments).flat(),...Object.values(H.expenseAttachments).flat()];for(let V of X)for(let F of V.paths){if(W.has(F))continue;let w=U.entries.find((j)=>j.fileName===F);if(!w)continue;process.stderr.write(`⬆ 上传附件: ${F}
`);let O=new FormData,N=await Pd(U.fileBuffer,w),M=F.split("/").pop()??F;O.append("files",new File([new Uint8Array(N)],M));let D=await fetch(`${Q}/api/v1/integrations/webhook/${encodeURIComponent(J)}/attachments`,{method:"POST",headers:{...z.customHeaders??{},...kZ({},z.secret)},body:O});if(!D.ok)throw Error(`附件上传失败 ${D.status}: ${await D.text()}`);let P=await D.json();W.set(F,P.attachments?.map((j)=>j.data)??(P.data===void 0?[]:[P.data])),process.stderr.write(`✓ 附件上传成功: ${F}
\v\f\r\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[¥]^_\`abcdefghijklmnopqrstuvwxyz{|}‾��������������������������������������������������������������������������������������������������������������������������������`},hproman8:{type:"_sbcs",chars:"€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ÀÂÈÊËÎÏ´ˋˆ¨˜ÙÛ₤¯Ýý°ÇçÑñ¡¿¤£¥§ƒ¢âêôûáéóúàèòùäëöüÅîØÆåíøæÄìÖÜÉïßÔÁÃãÐðÍÌÓÒÕõŠšÚŸÿÞþ·µ¾—¼½ªº«■»±�"},macintosh:{type:"_sbcs",chars:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄¤‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ�ÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ"},ascii:{type:"_sbcs",chars:"��������������������������������������������������������������������������������������������������������������������������������"},tis620:{type:"_sbcs",chars:"���������������������������������กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู����฿เแโใไๅๆ็่้๊๋์ํ๎๏๐๑๒๓๔๕๖๗๘๙๚๛����"}}});var wP0=E((ZP1)=>{var Cp=u3().Buffer;ZP1._dbcs=i3;var I8=-1,LP0=-2,l$=-10,k8=-1000,VK=Array(256),pZ=-1;for(dZ=0;dZ<256;dZ++)VK[dZ]=I8;var dZ;function i3($,U){if(this.encodingName=$.encodingName,!$)throw Error("DBCS codec is called without the data.");if(!$.table)throw Error("Encoding '"+this.encodingName+"' has no data.");var Y=$.table();this.decodeTables=[],this.decodeTables[0]=VK.slice(0),this.decodeTableSeq=[];for(var z=0;z<Y.length;z++)this._addDecodeChunk(Y[z]);if(typeof $.gb18030==="function"){this.gb18030=$.gb18030();var I=this.decodeTables.length;this.decodeTables.push(VK.slice(0));var Q=this.decodeTables.length;this.decodeTables.push(VK.slice(0));var J=this.decodeTables[0];for(var z=129;z<=254;z++){var K=this.decodeTables[k8-J[z]];for(var G=48;G<=57;G++){if(K[G]===I8)K[G]=k8-I;else if(K[G]>k8)throw Error("gb18030 decode tables conflict at byte 2");var H=this.decodeTables[k8-K[G]];for(var W=129;W<=254;W++){if(H[W]===I8)H[W]=k8-Q;else if(H[W]===k8-Q)continue;else if(H[W]>k8)throw Error("gb18030 decode tables conflict at byte 3");var X=this.decodeTables[k8-H[W]];for(var Z=48;Z<=57;Z++)if(X[Z]===I8)X[Z]=LP0}}}}this.defaultCharUnicode=U.defaultCharUnicode,this.encodeTable=[],this.encodeTableSeq=[];var q={};if($.encodeSkipVals)for(var z=0;z<$.encodeSkipVals.length;z++){var V=$.encodeSkipVals[z];if(typeof V==="number")q[V]=!0;else for(var G=V.from;G<=V.to;G++)q[G]=!0}if(this._fillEncodeTable(0,0,q),$.encodeAdd){for(var F in $.encodeAdd)if(Object.prototype.hasOwnProperty.call($.encodeAdd,F))this._setEncodeChar(F.charCodeAt(0),$.encodeAdd[F])}if(this.defCharSB=this.encodeTable[0][U.defaultCharSingleByte.charCodeAt(0)],this.defCharSB===I8)this.defCharSB=this.encodeTable[0]["?"];if(this.defCharSB===I8)this.defCharSB=63}i3.prototype.encoder=BP;i3.prototype.decoder=Rp;i3.prototype._getDecodeTrieNode=function($){var U=[];for(;$>0;$>>>=8)U.push($&255);if(U.length==0)U.push(0);var Y=this.decodeTables[0];for(var z=U.length-1;z>0;z--){var I=Y[U[z]];if(I==I8)Y[U[z]]=k8-this.decodeTables.length,this.decodeTables.push(Y=VK.slice(0));else if(I<=k8)Y=this.decodeTables[k8-I];else throw Error("Overwrite byte in "+this.encodingName+", addr: "+$.toString(16))}return Y};i3.prototype._addDecodeChunk=function($){var U=parseInt($[0],16),Y=this._getDecodeTrieNode(U);U=U&255;for(var z=1;z<$.length;z++){var I=$[z];if(typeof I==="string")for(var Q=0;Q<I.length;){var J=I.charCodeAt(Q++);if(J>=55296&&J<56320){var K=I.charCodeAt(Q++);if(K>=56320&&K<57344)Y[U++]=65536+(J-55296)*1024+(K-56320);else throw Error("Incorrect surrogate pair in "+this.encodingName+" at chunk "+$[0])}else if(J>4080&&J<=4095){var G=4095-J+2,H=[];for(var W=0;W<G;W++)H.push(I.charCodeAt(Q++));Y[U++]=l$-this.decodeTableSeq.length,this.decodeTableSeq.push(H)}else Y[U++]=J}else if(typeof I==="number"){var X=Y[U-1]+1;for(var Q=0;Q<I;Q++)Y[U++]=X++}else throw Error("Incorrect type '"+typeof I+"' given in "+this.encodingName+" at chunk "+$[0])}if(U>255)throw Error("Incorrect chunk in "+this.encoLine truncated
`;super(U);this.name="AggregateError",this.errors=$}}TT0.exports={AggregateError:PT0,ArrayIsArray($){return Array.isArray($)},ArrayPrototypeIncludes($,U){return $.includes(U)},ArrayPrototypeIndexOf($,U){return $.indexOf(U)},ArrayPrototypeJoin($,U){return $.join(U)},ArrayPrototypeMap($,U){return $.map(U)},ArrayPrototypePop($,U){return $.pop(U)},ArrayPrototypePush($,U){return $.push(U)},ArrayPrototypeSlice($,U,Y){return $.slice(U,Y)},Error,FunctionPrototypeCall($,U,...Y){return $.call(U,...Y)},FunctionPrototypeSymbolHasInstance($,U){return Function.prototype[Symbol.hasInstance].call($,U)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties($,U){return Object.defineProperties($,U)},ObjectDefineProperty($,U,Y){return Object.defineProperty($,U,Y)},ObjectGetOwnPropertyDescriptor($,U){return Object.getOwnPropertyDescriptor($,U)},ObjectKeys($){return Object.keys($)},ObjectSetPrototypeOf($,U){return Object.setPrototypeOf($,U)},Promise,PromisePrototypeCatch($,U){return $.catch(U)},PromisePrototypeThen($,U,Y){return $.then(U,Y)},PromiseReject($){return Promise.reject($)},PromiseResolve($){return Promise.resolve($)},ReflectApply:Reflect.apply,RegExpPrototypeTest($,U){return $.test(U)},SafeSet:Set,String,StringPrototypeSlice($,U,Y){return $.slice(U,Y)},StringPrototypeToLowerCase($){return $.toLowerCase()},StringPrototypeToUpperCase($){return $.toUpperCase()},StringPrototypeTrim($){return $.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet($,U,Y){return $.set(U,Y)},Boolean,Uint8Array}});var tp=E((T84,jT0)=>{jT0.exports={format($,...U){return $.replace(/%([sdifj])/g,function(...[Y,z]){let I=U.shift();if(z==="f")return I.toFixed(6);else if(z==="j")return JSON.stringify(I);else if(z==="s"&&typeof I==="object")return`${I.constructor!==Object?I.constructor.name:""} {}`.trim();else return I.toString()})},inspect($){switch(typeof $){case"string":if($.includes("'")){if(!$.includes('"'))return`"${$}"`;else if(!$.includes("`")&&!$.includes("${"))return`\`${$}\``}return`'${$}'`;case"number":if(isNaN($))return"NaN";else if(Object.is($,-0))return String($);return $;case"bigint":return`${String($)}n`;case"boolean":case"undefined":return String($);case"object":return"{}"}}}});var D8=E((j84,_T0)=>{var{format:Qj1,inspect:RP}=tp(),{AggregateError:Jj1}=f4(),Kj1=globalThis.AggregateError||Jj1,Gj1=Symbol("kIsNodeError"),Hj1=["string","function","number","object","Function","Object","boolean","bigint","symbol"],Wj1=/^([A-Z][a-z0-9]*)+$/,_P={};function Mz($,U){if(!$)throw new _P.ERR_INTERNAL_ASSERTION(U)}function ET0($){let U="",Y=$.length,z=$[0]==="-"?1:0;for(;Y>=z+4;Y-=3)U=`_${$.slice(Y-3,Y)}${U}`;return`${$.slice(0,Y)}${U}`}function Xj1($,U,Y){if(typeof U==="function")return Mz(U.length<=Y.length,`Code: ${$}; The provided arguments length (${Y.length}) does not match the required ones (${U.length}).`),U(...Y);let z=(U.match(/%[dfijoOs]/g)||[]).length;if(Mz(z===Y.length,`Code: ${$}; The provided arguments length (${Y.length}) does not match the required ones (${z}).`),Y.length===0)return U;return Qj1(U,...Y)}function Q8($,U,Y){if(!Y)Y=Error;class z extends Y{constructor(...I){super(Xj1($,U,I))}toString(){return`${this.name} [${$}]: ${this.message}`}}Object.defineProperties(z.prototype,{name:{value:Y.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${$}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),z.prototype.code=$,z.prototype[Gj1]=!0,_P[$]=z}function CT0($){let U="__node_internal_"+$.name;return Object.defineProperty($,"name",{value:U}),$}function Zj1($,U){if($&&U&&$!==U){if(Array.isArray(U.errors))return U.errors.push($),U;let Y=new Kj1([U,$],U.message);return Y.code=U.code,Y}return $||U}class RT0 extends Error{constructor($="The operation was aborted",U=void 0){if(U!==void 0&&typeof U!=="object")throw new _P.ERR_INVALID_ARG_TYPE("options","Object",U);super($,U);this.code="ABORT_ERR",this.name="AbortError"}}Q8("ERR_ASSERTION","%s",Error);Q8("ERR_INVALID_ARG_TYPE",($,U,Y)=>{if(Mz(typeof $==="string","'name' must be a string"),!Array.isArray(U))U=[U];let z="The ";if($.endsWith(" argument"))z+=`${$} `;else z+=`"${$}" ${$.includes(".")?"property":"argument"} `;z+="must be ";let I=[],Q=[],J=[];for(let G of U)if(Mz(typeof G==="string","All expected entries have to be of type string"),Hj1.includes(G))I.push(G.toLowerCase());else if(Wj1.test(G))Q.push(G);else Mz(G!=="object",'The value "object" should be written as "Object"'),J.push(G);if(Q.length>0){let G=I.indexOf("object");if(G!==-1)I.splice(I,G,1),Q.push("Object")}if(I.length>0){switch(I.length){case 1:z+=`of type ${I[Line truncated
`);if(U.linkname)Y+=Cl(" linkpath="+U.linkname+`
`);let z=U.pax;if(z)for(let I in z)Y+=Cl(" "+I+"="+z[I]+`
`);return c1.from(Y)};HS1.decodePax=function(U){let Y={};while(U.length){let z=0;while(z<U.length&&U[z]!==32)z++;let I=parseInt(c1.toString(U.subarray(0,z)),10);if(!I)return Y;let Q=c1.toString(U.subarray(z+1,I-1)),J=Q.indexOf("=");if(J===-1)return Y;Y[Q.slice(0,J)]=Q.slice(J+1),U=U.subarray(I)}return Y};HS1.encode=function(U){let Y=c1.alloc(512),z=U.name,I="";if(U.typeflag===5&&z[z.length-1]!=="/")z+="/";if(c1.byteLength(z)!==z.length)return null;while(c1.byteLength(z)>100){let Q=z.indexOf("/");if(Q===-1)return null;I+=I?"/"+z.slice(0,Q):z.slice(0,Q),z=z.slice(Q+1)}if(c1.byteLength(z)>100||c1.byteLength(I)>155)return null;if(U.linkname&&c1.byteLength(U.linkname)>100)return null;if(c1.write(Y,z),c1.write(Y,a2(U.mode&4095,6),100),c1.write(Y,a2(U.uid,6),108),c1.write(Y,a2(U.gid,6),116),KS1(U.size,Y,124),c1.write(Y,a2(U.mtime.getTime()/1000|0,11),136),Y[156]=48+QS1(U.type),U.linkname)c1.write(Y,U.linkname,157);if(c1.copy($_0,Y,257),c1.copy(th1,Y,263),U.uname)c1.write(Y,U.uname,265);if(U.gname)c1.write(Y,U.gname,297);if(c1.write(Y,a2(U.devmajor||0,6),329),c1.write(Y,a2(U.devminor||0,6),337),I)c1.write(Y,I,345);return c1.write(Y,a2(Y_0(Y),6),148),Y};HS1.decode=function(U,Y,z){let I=U[156]===0?0:U[156]-48,Q=gK(U,0,100,Y),J=s2(U,100,8),K=s2(U,108,8),G=s2(U,116,8),H=s2(U,124,12),W=s2(U,136,12),X=IS1(I),Z=U[157]===0?null:gK(U,157,100,Y),q=gK(U,265,32),V=gK(U,297,32),F=s2(U,329,8),M=s2(U,337,8),w=Y_0(U);if(w===256)return null;if(w!==s2(U,148,8))throw Error("Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?");if(US1(U)){if(U[345])Q=gK(U,345,155,Y)+"/"+Q}else if(YS1(U));else if(!z)throw Error("Invalid tar header: unknown format.");if(I===0&&Q&&Q[Q.length-1]==="/")I=5;return{name:Q,mode:J,uid:K,gid:G,size:H,byteOffset:0,mtime:new Date(1000*W),type:X,linkname:Z,uname:q,gname:V,devmajor:F,devminor:M,pax:null}};function US1($){return c1.equals($_0,$.subarray(257,263))}function YS1($){return c1.equals(eh1,$.subarray(257,263))&&c1.equals($S1,$.subarray(263,265))}function zS1($,U,Y){if(typeof $!=="number")return Y;if($=~~$,$>=U)return U;if($>=0)return $;if($+=U,$>=0)return $;return 0}function IS1($){switch($){case 0:return"file";case 1:return"link";case 2:return"symlink";case 3:return"character-device";case 4:return"block-device";case 5:return"directory";case 6:return"fifo";case 7:return"contiguous-file";case 72:return"pax-header";case 55:return"pax-global-header";case 27:return"gnu-long-link-path";case 28:case 30:return"gnu-long-path"}return null}function QS1($){switch($){case"file":return 0;case"link":return 1;case"symlink":return 2;case"character-device":return 3;case"block-device":return 4;case"directory":return 5;case"fifo":return 6;case"contiguous-file":return 7;case"pax-header":return 72}return 0}function U_0($,U,Y,z){for(;Y<z;Y++)if($[Y]===U)return Y;return z}function Y_0($){let U=256;for(let Y=0;Y<148;Y++)U+=$[Y];for(let Y=156;Y<512;Y++)U+=$[Y];return U}function a2($,U){if($=$.toString(8),$.length>U)return"7777777777777777777".slice(0,U)+" ";return"0000000000000000000".slice(0,U-$.length)+$+" "}function JS1($,U,Y){U[Y]=128;for(let z=11;z>0;z--)U[Y+z]=$&255,$=Math.floor($/256)}function KS1($,U,Y){if($.toString(8).length>11)JS1($,U,Y);else c1.write(U,a2($,11),Y)}function GS1($){let U;if($[0]===128)U=!0;else if($[0]===255)U=!1;else return null;let Y=[],z;for(z=$.length-1;z>0;z--){let J=$[z];if(U)Y.push(J);else Y.push(255-J)}let I=0,Q=Y.length;for(z=0;z<Q;z++)I+=Y[z]*Math.pow(256,z);return U?I:-1*I}function s2($,U,Y){if($=$.subarray(U,U+Y),U=0,$[U]&128)return GS1($);else{while(U<$.length&&$[U]===32)U++;let z=zS1(U_0($,32,U,$.length),$.length,$.length);while(U<z&&$[U]===0)U++;if(z===U)return 0;return parseInt(c1.toString($.subarray(U,z)),8)}}function gK($,U,Y,z){return c1.toString($.subarray(U,U_0($,0,U,U+Y)),z)}function Cl($){let U=c1.byteLength($),Y=Math.floor(Math.log(U)/Math.log(10))+1;if(U+Y>=Math.pow(10,Y))Y++;return U+Y+$}});var W_0=E((w54,H_0)=>{var{Writable:LS1,Readable:wS1,getStreamError:z_0}=El(),FS1=Ol(),I_0=SK(),yK=Rl(),MS1=I_0.alloc(0);class Q_0{constructor(){this.buffered=0,this.shifted=0,this.queue=new FS1,this._offset=0}push($){this.buffered+=$.byteLength,this.queue.push($)}shiftFirst($){return this.buffered===0?null:this._next($)}shift($){if($>this.buffered)return null;if($===0)return MS1;let U=this._next($);if($===U.byteLength)return U;let Y=[U];while(($-=U.byteLength)>0)U=this._next($),Y.push(U);return I_0.concat(Y)}_next($){let U=this.queue.peek(),Y=U.byteLength-this._offset;if($>=Y){let z=this._offset?U.subarray(this._offset,U.byteLength):U;return this.queue.shift(),this._offset=0,this.buffered-=Y,this.shifted+=Y,z}return this.buffered-=$,this.shifted+=$,U.subarray(this._offset,this._offset+=$)}}class J_0 extends wS1{constructor($,U,Y){super();this.header=U,this.offset=Y,this._parent=$}_read($){if(this.header.size===0)this.push(null);if(this._parent._stream===this)this._parent._update();$(null)}_predestroy(){this._parent.destroy(z_0(this))}_detach(){if(this._parent._stream= Line truncated
`),z=[await H4($,Y.recordId)];else if(Y.recordIds&&Y.recordIds.length>0)process.stderr.write(`\uD83D\uDD0D 批量查询 ${Y.recordIds.length} 条单据记录...
`),z=await Promise.all(Y.recordIds.map((w)=>H4($,w)));else{let w=Y.limit??10;process.stderr.write(`\uD83D\uDD0D 检索企业「${U.name}」(${U.id}) 的线上审核记录 (限制 ${w} 条)...
`);let O=(await i4($,{limit:w,status:Y.status,startDate:Y.startDate!==void 0?String(Y.startDate):void 0,endDate:Y.endDate!==void 0?String(Y.endDate):void 0})).records??[];if(O.length===0)throw Error("未检索到符合条件的线上审核记录,无法导出 webhook 资源包。");process.stderr.write(`\uD83D\uDCE5 正在拉取 ${O.length} 条审核记录完整详情...
`),z=await Promise.all(O.map((D)=>H4($,D.id)))}let I=new Map,Q=0;for(let w of z){let N=w.document,O=w.sourceDocumentId??(typeof N?.id==="string"?N.id:void 0)??(typeof N?.sourceDocumentId==="string"?N.sourceDocumentId:void 0)??w.documentId??w.id,D=`${Y.docIdPrefix??""}${O}${Y.docIdSuffix??""}`,P=[];if(Y.includeAttachments!==!1){let A=n2(w,{summary:!1}).attachments,j=new Set;for(let C of A){let b=C.ossSignedUrl??C.url;if(!b)continue;let x=C.fileName??C.fileId??"attachment",g=Dd(x),i=g,n=g.lastIndexOf("."),z0=n>0?g.slice(0,n):g,k=n>0?g.slice(n):"",p=1;while(j.has(i.toLowerCase()))i=`${z0}_${p}${k}`,p++;j.add(i.toLowerCase());try{process.stderr.write(`⬇ 下载单据「${D}」附件: ${x}...
`);let a=await fetch(b);if(a.ok){let $0=await a.arrayBuffer(),y=Buffer.from($0);P.push({fileName:i,zipPath:`${D}/${i}`,buffer:y,sourceField:C.sourceField??"附件"}),Q++}}catch(a){process.stderr.write(`⚠️ [跳过附件] 下载失败 ${x}: ${a}
`)}}}I.set(D,P)}let J=new C_0.default.Workbook;J.creator="seal-use",J.created=new Date;let K=new Set;for(let w of I.values())for(let N of w)K.add(N.sourceField);if(K.size===0)K.add("附件");let G=new Set;for(let w of z){let N=w.document,O=Array.isArray(N?.fields)?N.fields:[];for(let D of O)if(D&&typeof D==="object"){let P=D,T=typeof P.label==="string"?P.label.trim():typeof P.key==="string"?P.key.trim():"",A=typeof P.type==="string"?P.type.toUpperCase():"";if(T&&A!=="ATTACHMENT"&&A!=="LIST")G.add(T)}}let H=["会议编号","会议名称","状态","总金额","报销事由","申请日期"],W=Array.from(G).filter((w)=>!H.includes(w)&&w!=="单据编号"&&w!=="单号"),X=Array.from(K).map((w)=>`[附件]${w}`),Z=[...H,...W,...X],q=J.addWorksheet("主表");q.addRow(Z),q.getRow(1).font={bold:!0};for(let w of z){let N=w.document,O=w.sourceDocumentSN??(typeof N?.sn==="string"?N.sn:void 0)??(typeof N?.sourceDocumentSN==="string"?N.sourceDocumentSN:void 0)??w.id,D=w.sourceDocumentId??(typeof N?.id==="string"?N.id:void 0)??(typeof N?.sourceDocumentId==="string"?N.sourceDocumentId:void 0)??w.documentId??w.id,P=`${Y.docIdPrefix??""}${D}${Y.docIdSuffix??""}`,T=`${Y.docIdPrefix??""}${O}${Y.docIdSuffix??""}`,A=(typeof N?.title==="string"?N.title:void 0)??(typeof N?.name==="string"?N.name:void 0)??T,j="";if(typeof N?.sourceStartTime==="number")j=new Date(N.sourceStartTime*1000).toLocaleDateString("en-CA",{timeZone:"Asia/Shanghai"});else if(typeof w.createdAt==="number")j=new Date(w.createdAt).toLocaleDateString("en-CA",{timeZone:"Asia/Shanghai"});else if(typeof w.createdAt==="string")j=w.createdAt.slice(0,10);let C=new Map,b=Array.isArray(N?.fields)?N.fields:[];for(let z0 of b)if(z0&&typeof z0==="object"){let k=z0,p=typeof k.label==="string"?k.label.trim():typeof k.key==="string"?k.key.trim():"";if(p)C.set(p,k.value)}let x,g=C.get("总金额")??C.get("报销金额")??C.get("total_amount");if(typeof g==="number")x=g;else if(g&&typeof g==="object"&&"amount"in g&&typeof g.amount==="number")x=g.amount;let i=[];i.push(P),i.push(A),i.push(w.status??"已审批"),i.push(x??""),i.push(C.get("报销事由")??C.get("事由")??A),i.push(j);for(let z0 of W){let k=C.get(z0);if(k===void 0||k===null)i.push("");else if(typeof k==="object")if("amount"in k)i.push(k.amount);else i.push(JSON.stringify(k));else i.push(k)}let n=I.get(P)??[];for(let z0 of K){let k=n.filter((p)=>p.sourceField===z0||K.size===1);if(k.length>0)i.push(k.map((p)=>p.zipPath).join(`
`));else i.push("")}q.addRow(i)}let V=xS1(Y,U);hS1(yS1(V),{recursive:!0});let F=await J.xlsx.writeBuffer();process.stderr.write(`\uD83D\uDCE6 正在压缩生成 Webhook 资源包: ${V}...
`),await new Promise((w,N)=>{let O=vS1(V),D=new gl({zlib:{level:9}});O.on("close",()=>w()),D.on("error",(P)=>N(P)),D.pipe(O),D.append(Buffer.from(F),{name:"信息表.xlsx"});for(let P of I.values())for(let T of P)D.append(T.buffer,{name:T.zipPath});D.finalize()});let M=SS1(V);return{filePath:V,corpId:U.id,corpName:U.name,recordCount:z.length,attachmentCount:Q,fileSizeBytes:M.size,exportedAt:new Date().toISOString(),nextAction:`seal-use webhook resource-pack push ${V} --corp <targetCorpId>`}}var C_0;var yl=m(()=>{j_0();X6();oB();C_0=I6(_Z(),1)});import{readFileSync as fS1}from"node:fs";function uS1($){let U=new URL($),Y=U.pathname.match(/\/webhook\/([^/]+)/);if(!Y)throw Error("Webhook URL 必须包含 /webhook/{webhookId}/document");return{baseUrl:`${U.protocol}//${U.host}`,webhookId:Y[1]}}function bS1($,U){return U.toLowerCase().endsWith(".zip")||$[0]===80&&$[1]===75&&!U.toLowerCase().endsWith(".xlsx")}function iS1($,U){if(!$.length)return;let Y=new Set($.map((Q)=>{let J=Q.fileName.split("/")[0],K=J.indexOf("@");return K>=0?J.slice(0,K):J}).filter((Q)=>Q!=="信息表.xlsx")),z=[];for(let Q of U){let J=Q.document.documentId;if((Q.documentAttachments.length>0||Object.values(Q.expenseAttachments).some((G)=>G.length>0)||Object.values(Q.personAttachments).some((G)=>G.length>0))&&!Y.has(J))z.push(`Excel 会议编号「${J}」声明了附件,但在 ZIP 中找不到对应的根目录「${J}/」或「${J}@.../」。`)}let I=new Set(U.map((Q)=>Q.document.documentId));for(let Q of Y)if(!I.has(Q))z.push(`ZIP 根目录对应的编号「${Q}」在信息表中找不到对应的会议编号。`);if(z.length)throw new j5(z)}async function R_0($,U,Y){let z=[],I=$;if(bS1($,U)){z=await uP0($),iP0(z,Y);let G=z.find((H)=>H.fileName==="信息表.xlsx");if(!G)throw Error("ZIP 根目录缺少信息表.xlsx");I=await yp($,G)}let Q=await oP0(I);iS1(z,Q);let J=rP0(z,Q),K=Q.map((G)=>G.document);return{entries:z,parsed:Q,plans:J,documents:K,fileBuffer:$}}async function kz($,U,Y){let z=await R_0($,U,Y),I=z.parsed.map((Q,J)=>ip(Q.document,z.plans[J],new Map));return{warnings:[],documents:I,attachmentPlan:z.plans}}async function OT($,U,Y){let z=await R_0($,U,Y.materialPackFilePolicy),{baseUrl:I,webhookId:Q}=uS1(Y.webhookUrl),J=[];for(let K=0;K<z.parsed.length;K+=1){let G=z.parsed[K],H=z.plans[K],W=new Map,X=[...H.categoryFields,...Object.values(H.personAttachments).flat(),...Object.values(H.expenseAttachments).flat()];for(let V of X)for(let F of V.paths){if(W.has(F))continue;let M=z.entries.find((T)=>T.fileName===F);if(!M)continue;process.stderr.write(`⬆ 上传附件: ${F}
`);let w=new FormData,N=await yp(z.fileBuffer,M),O=F.split("/").pop()??F;w.append("files",new File([new Uint8Array(N)],O));let D=await fetch(`${I}/api/v1/integrations/webhook/${encodeURIComponent(Q)}/attachments`,{method:"POST",headers:{...Y.customHeaders??{},...uZ({},Y.secret)},body:w});if(!D.ok)throw Error(`附件上传失败 ${D.status}: ${await D.text()}`);let P=await D.json();W.set(F,P.attachments?.map((T)=>T.data)??(P.data===void 0?[]:[P.data])),process.stderr.write(`✓ 附件上传成功: ${F}
`)}process.stderr.write(`\uD83D\uDCE4 推送单据: ${G.document.documentId}
`);let Z=_d(G.document,H,W),q=await fetch(`${Q}/api/v1/integrations/webhook/${encodeURIComponent(J)}/document`,{method:"POST",headers:{...z.customHeaders??{},"Content-Type":"application/json",...kZ({webhookId:J,...Z},z.secret)},body:JSON.stringify(Z)});if(!q.ok)throw Error(`Webhook 单据推送失败 ${q.status}: ${await q.text()}`);I.push({documentId:Z.documentId,document:Z,pushResult:await q.json()}),process.stderr.write(`✓ 单据推送成功: ${Z.documentId}
`)}return{warnings:[],results:I}}function xU($){return{fileBuffer:XS1($),fileName:$.split(/[\\\/]/).pop()??"material-pack.zip"}}var jl=m(()=>{tB();vd();Rd();jd();QK();Pl()});import{existsSync as LS1}from"node:fs";async function qj($,Y,z={}){let Q=v4().stateful?"stateful":"stateless",J="ok",I,K,G;try{let D=await T8($);G={id:D.user.id,name:D.user.name,isAdmin:D.user.isAdmin},K={id:D.tenant.id,name:D.tenant.name,tenantSlug:D.tenant.tenantSlug,corporationName:D.tenant.hoseCorpConfig?.corporationName}}catch(D){J="error",I=D instanceof Error?D.message:String(D)}let H=[];if(J==="ok")try{H=await I$($,Y.seal.endpoints.approvalStylePreferences)}catch(D){J="error",I=`读取 Webhook 配置失败: ${D instanceof Error?D.message:String(D)}`}let W=H.length===1,X=H.map((D)=>({id:D.id,name:D.name,mode:D.mode,incomingDocumentWebhookUrl:D.incomingDocumentWebhook.url,outgoingResultWebhookUrl:D.outgoingResultWebhook,autoApprovalRate:D.autoApprovalRate,...W?{isDefault:!0}:{}})),Z=W?{id:H[0].id,name:H[0].name,mode:H[0].mode}:null,q=z.webhook?k7(H,z.webhook):W?H[0]:void 0,V;if(z.filePath)if(!LS1(z.filePath))V={valid:!1,filePath:z.filePath,fileName:z.filePath.split(/[\\/]/).pop()??z.filePath,documentCount:0,errors:[`文件不存在: ${z.filePath}`]};else try{let D=xU(z.filePath),P=await kU(D.fileBuffer,D.fileName,q?.materialPackFilePolicy);V={valid:!0,filePath:z.filePath,fileName:D.fileName,documentCount:P.documents.length,warnings:P.warnings}}catch(D){V={valid:!1,filePath:z.filePath,fileName:z.filePath.split(/[\\/]/).pop()??z.filePath,documentCount:0,errors:[D instanceof Error?D.message:String(D)]}}let F=V?V.valid:!0,w=J==="ok"&&X.length>0&&F,O=Q==="stateful"?"":` --corp ${Y.id}`,N="",M="";if(J!=="ok")M=`凭证鉴权异常: ${I}`,N=`seal-use auth diagnose${O}`;else if(X.length===0)M="当前企业尚未配置任何 Webhook 集成通道",N=`seal-use webhook add --name "默认入站通道" --result-url "https://your-domain.com/callback"${O}`;else if(V&&!V.valid)M=`资源包预检失败: ${V.errors?.join("; ")}`,N=`seal-use webhook resource-pack preview ${V.filePath}${O}`;else{M=W?"所有通道正常,已自动锁定唯一 Webhook 通道,等待载入":`所有通道正常,检测到 ${X.length} 个 Webhook 通道,等待载入`;let D=V?.filePath??"<资源包.zip>",P=W?"":` --webhook ${Z?Z.id:"<webhookIdOrName>"}`;N=`seal-use webhook resource-pack push ${D}${P}${O}`}return{ready:w,corp:{id:Y.id,name:Y.name,sourceType:Y.source.type,tenant:K,user:G},stateMode:Q,authStatus:J,authError:I,activeWebhooks:X,defaultWebhook:Z,resourcePack:V,materialPack:V,statusMessage:M,nextAction:N}}var O_0=m(()=>{k3();B6();jl()});var Tl=m(()=>{QK();sQ();tB();jd();Rd();vd();jl();O_0();Pl()});import{existsSync as w_0,mkdirSync as M_0,statSync as FS1}from"node:fs";import{homedir as OS1}from"node:os";import{dirname as wS1,resolve as Vj}from"node:path";function MS1($){if($.outputFile){let I=Vj($.outputFile),K=wS1(I);if(!w_0(K))M_0(K,{recursive:!0});return I}let z=($.corpName||$.corpId||"企业").replace(/[/\\?%*:|"<>]/g,"_").trim()||"企业",U=$.dateTag||new Date().toISOString().slice(0,10),Q=`${z}_智能洞察报告_${U}.xlsx`,J;if($.toDownloads)J=Vj(OS1(),"Downloads");else J=Vj(process.cwd(),"exports");if(!w_0(J))M_0(J,{recursive:!0});return Vj(J,Q)}async function Lj($,Y,z={}){let U=Y.name||Y.id,Q=Qp({startDate:z.startDate,endDate:z.endDate,force:z.force}),J=new Date().toISOString(),[I,K]=await Promise.all([Rw($,{startDate:Q.startDateStr,endDate:Q.endDateStr,limit:z.limit??100}),vw($,{startDate:Q.startDateStr,endDate:Q.endDateStr}).catch(()=>({metrics:{},sankeyData:{nodes:[],links:[]}}))]),G=I.tagStats||[],H=[],W=Math.min(G.length,z.limit??50);for(let C=0;C<W;C++){let b=G[C];if(!b?.tagId)continue;try{let k=await _w($,{tagId:b.tagId,startDate:Q.startDateStr,endDate:Q.endDateStr});for(let S of k.risks||[])H.push({tagId:b.tagId,tagName:b.tagName||b.tagId,documentSN:S.documentSN||"-",documentType:S.documentType||"-",riskLevel:S.riskLevel||"warning",confidence:S.confidence??0,riskDetails:S.riskDetails||"-",reasoning:S.reasoning||"-",sourceDocumentURL:S.sourceDocumentURL,createdAt:S.createdAt})}catch{}}let X=new N_0.default.Workbook;X.creator="seal-use",X.lastModifiedBy="seal-use",X.created=new Date,X.modified=new Date;let Z={type:"pattern",pattern:"solid",fgColor:{argb:"FF1E293B"}},q={name:"Microsoft YaHei",size:11,bold:!0,color:{argb:"FFFFFFFF"}},V={top:{style:"thin",color:{argb:"FFE2E8F0"}},bottom:{style:"thin",color:{argb:"FFE2E8F0"}},left:{style:"thin",color:{argb:"FFE2E8F0"}},right:{style:"thin",color:{argb:"FFE2E8F0"}}},F=X.addWorksheet("审核效能与决策流向",{views:[{showGridLines:!0}]});F.columns=[{header:"分类",key:"category",width:20},{header:"指标名称",key:"name",width:28},{header:"数值",key:"val",width:22},{header:"环比/趋势",key:"trend",width:18},{header:"说明",key:"desc",width:36}],F.getRow(1).height=28,F.getRow(1).font=q,F.getRow(1).fill=Z,F.getRow(1).alignment={vertical:"middle",horizontal:"center"};let w=K.metrics||{},O=[{c Line truncated
`);return{recordId:$.id,sourceDocumentSN:$.sourceDocumentSN,sourceDocumentId:$.sourceDocumentId,document:kK({id:Y?.id,sn:Y?.sn??Y?.sourceDocumentSN??$.sourceDocumentSN,title:Y?.title??Y?.name,template:Dj(Y,["template.name","templateName","form.name","formName","formTitle"]),amount:Oj(z,["金额","报销金额","付款金额","合计","价税合计"])??Dj(Y,["amount","totalAmount","expenseAmount"]),expenseType:Oj(z,["费用类型","费用类别","报销类型"]),costCompany:Oj(z,["费用承担公司","承担公司","成本中心","费用归属"]),payee:Oj(z,["收款方","收款账户","收款信息","开户名","银行账号"]),keyFields:z.slice(0,30)}),invoices:xS1($),attachments:i2($,{summary:!0}).attachments,aiResult:Bj($),manualResult:uU($)?.value,hints:kK({amountMentions:P_0(U,["金额","合计","税率"],8),partyMentions:P_0(U,["买方","卖方","甲方","乙方","收款"],8)})}}function SS1($){let Y=[["result.citedRules",m3($,"result.citedRules")],["result.matchedRules",m3($,"result.matchedRules")],["result.ruleResults",m3($,"result.ruleResults")],["result.rules",m3($,"result.rules")],["pipelineData.citedRules",m3($,"pipelineData.citedRules")],["pipelineData.matchedRules",m3($,"pipelineData.matchedRules")]],z=[],U=new Set;for(let[Q,J]of Y)(Array.isArray(J)?J:J&&typeof J==="object"?Object.values(J):[]).forEach((K,G)=>{let H=Aq(K);if(!H)return;let W=w4(H.runtimeRuleId)??w4(H.runtimeId)??w4(H.id)??w4(H.ruleId),X=w4(H.ruleCode)??w4(H.code)??(W?bS1(W):void 0),Z=kK({runtimeRuleId:W,ruleCode:X,versionNumber:yS1(H.versionNumber)??$.ruleSetVersionNumber,scope:w4(H.scope),strictness:w4(H.strictness),appliedAnalysis:H.appliedAnalysis??H.analysis??H.reasoning,checkResult:H.checkResult??H.result??H.decision,findings:H.findings??H.riskPoints??H.evidence,sourcePath:`${Q}.${G}`}),q=JSON.stringify(Z);if(!U.has(q))U.add(q),z.push(Z)});return{recordId:$.id,sourceDocumentSN:$.sourceDocumentSN,sourceDocumentId:$.sourceDocumentId,ruleSetVersionNumber:$.ruleSetVersionNumber,count:z.length,rules:z}}function Dj($,Y){if(!$)return;for(let z of Y){let U=m3($,z);if(U!==void 0)return U}return}function B_0($,Y){if(!$)return 0;for(let z of Y){let U=m3($,z);if(Array.isArray(U))return U.length;if(U&&typeof U==="object")return Object.keys(U).length;if(typeof U==="number")return U}return 0}function m3($,Y){return Y.split(".").reduce((z,U)=>{if(z===void 0||z===null)return;if(Array.isArray(z)){let Q=Number(U);return Number.isInteger(Q)?z[Q]:void 0}if(typeof z==="object")return z[U];return},$)}function gS1($,Y,z){let U=Y.split("."),Q=$;for(let J of U.slice(0,-1)){let I=Q[J];if(!I||typeof I!=="object"||Array.isArray(I))Q[J]={};Q=Q[J]}Q[U[U.length-1]??Y]=z}function kK($){return Object.fromEntries(Object.entries($).filter(([,Y])=>Y!==void 0))}function Aq($){return $&&typeof $==="object"&&!Array.isArray($)?$:void 0}function yS1($){return typeof $==="number"&&Number.isFinite($)?$:void 0}function kS1($){let Y=[];return Rl($,"document",Y),Y}function Rl($,Y,z){if(Array.isArray($)){$.forEach((I,K)=>Rl(I,`${Y}.${K}`,z));return}let U=Aq($);if(!U)return;let Q=w4(U.label)??w4(U.name)??w4(U.title)??w4(U.fieldName),J=U.value??U.displayValue??U.text??U.content;if(Q&&J!==void 0&&typeof J!=="object")z.push(kK({path:Y,label:Q,value:J,type:w4(U.type)??w4(U.fieldType)}));for(let[I,K]of Object.entries(U)){if(I==="attachments")continue;Rl(K,`${Y}.${I}`,z)}}function Oj($,Y){return $.find((U)=>{let Q=w4(U.label)??"";return Y.some((J)=>Q.includes(J))})?.value}function xS1($){let Y=[];return Aj($.result,"result",Y),Aj($.document,"document",Y),Y.slice(0,20)}function Aj($,Y,z){if(Array.isArray($)){$.forEach((Q,J)=>Aj(Q,`${Y}.${J}`,z));return}let U=Aq($);if(!U)return;if(/invoice|发票/i.test(Y))z.push(kK({path:Y,fileName:w4(U.fileName)??w4(U.filename)??w4(U.name),buyer:U.buyer??U.buyerName??U.purchaserName,seller:U.seller??U.sellerName,amount:U.amount??U.totalAmount??U.total,taxRate:U.taxRate,category:U.category??U.type}));for(let[Q,J]of Object.entries(U))Aj(J,`${Y}.${Q}`,z)}function P_0($,Y,z){return $.split(/\r?\n/).filter((U)=>Y.some((Q)=>U.includes(Q))).slice(0,z)}function wj($){return $.map((Y)=>{let z=fU(Y);return{recordId:z.id,tenantId:z.tenantId,agentId:z.agentId,sourceDocumentSN:z.sourceDocumentSN,sourceDocumentId:z.sourceDocumentId,simulationBatchId:z.simulationBatchId,langfuseTraceId:z.langfuseTraceId,langfuseSessionFallback:z.langfuseSessionFallback,ruleSetVersionNumber:z.ruleSetVersionNumber,ruleSetPublishedAt:z.ruleSetPublishedAt,ruleSetPublishedByName:z.ruleSetPublishedByName,resolution:z.langfuseTraceId?"trace":z.langfuseSessionFallback?"session-fallback":"unresolved"}})}function Cl($){return{id:$.id,tenantId:$.tenantId,versionNumber:$.versionNumber,versionName:$.versionName,publishedBy:$.publishedBy,publishedByName:$.publishedByName,rulesCount:$.rules.length,publishedAt:$.publishedAt,createdAt:$.createdAt}}async function fS1($,Y){if(Y.recordId&&!Y.versionId&&!Y.versionNumber&&!Y.latest){let z=await H4($,Y.recordId);if(!z.ruleSetVersionNumber)throw Er Line truncated
`)},{...wp(J,20000,Y.full===!0),format:Y.format??"unified"}}},{name:"seal_approval_rule_version_publish",description:"发布 Seal 草稿审批规则为新版本",parameters:L.object({versionName:L.string().describe("版本名称")}),handler:async($,Y,z)=>{let U=await X6($).catch(()=>{return}),Q=await yH($,Y.versionName);if(U)try{yZ(z.corp.id,Q.version,U.rules)}catch{}return Q}},{name:"seal_approval_rule_get",description:"按版本号/code/runtime-id/record-id 定位单条规则;code 只在选定的版本编号体系内有效,避免拉取整版规则快照",parameters:L.object({versionId:L.string().optional().describe("规则版本 ID"),versionNumber:L.number().int().positive().optional().describe("规则版本号"),latest:L.boolean().optional().describe("为 true 时取最新版本"),code:L.string().optional().describe("规则展示编号,如 #0038;没有后端 code 时按版本内序号匹配"),runtimeId:L.string().optional().describe("运行时规则 ID,如 rule-205;按版本内序号匹配"),recordId:L.string().optional().describe("从运行记录推断 ruleSetVersionNumber")}),handler:async($,Y)=>{let z=await fS1($,Y),U=uS1(z,{code:Y.code,runtimeId:Y.runtimeId});if(!U)throw Error(`Rule not found in version ${z.versionNumber}`);return U}},{name:"seal_approval_rules_lint",description:"对 Seal 本地规则文件、草稿审批规则或指定发布版本规则进行质量与可执行性检查(模糊词、悬空例外检测)",parameters:L.object({file:L.string().optional().describe("指定本地规则文件路径进行离线质检(支持 .json),0网络请求、不污染远端草稿"),linter:L.string().optional().describe("指定使用的校验器名称或脚本路径(如 builtin、strict、./my-linter.ts)"),version:L.string().optional().describe("指定要质检的历史发布版本号或 ID(如 16 或 latest),不传默认质检当前草稿"),code:L.string().optional().describe("按规则展示编号过滤(如 #0038)"),ruleId:L.string().optional().describe("按规则 ID 过滤"),minScore:L.number().optional().describe("最低合格质量分阈值(0~100),低于该分值抛出错误以返回非零退出码"),level:L.enum(["all","error","warning"]).default("all").describe("问题报告等级过滤"),summary:L.boolean().optional().describe("为 true 时仅返回存在瑕疵/扣分的规则")}),handler:async($,Y,z)=>{let U=[],Q;if(Y.file){let H=Sp(Y.file);U=VB0(H.rules),Q=H.meta.versionNumber}else if(Y.version){let H=await c8($),W=Number(Y.version),X=isNaN(W)?Y.version==="latest"?H[0]:H.find((Z)=>Z.id===Y.version):H.find((Z)=>Z.versionNumber===W);if(!X)throw Error(`未找到指定的规则版本: ${Y.version}`);Q=X.versionNumber,U=(X.rules??[]).map((Z,q)=>({id:Z.id??Z.runtimeId,code:Z.code??`#${String(q+1).padStart(4,"0")}`,name:Z.name??Z.title,description:Z.description??"",scope:Z.scope,strictness:Z.strictness}))}else U=((await X6($)).rules??[]).map((W,X)=>({id:W.id,code:W.code??`#${String(X+1).padStart(4,"0")}`,name:W.name??W.title,description:W.description??"",scope:W.scope,strictness:W.strictness}));if(Y.code)U=U.filter((H)=>H.code===Y.code||H.code?.replace(/[#\s]/g,"")===Y.code?.replace(/[#\s]/g,""));if(Y.ruleId)U=U.filter((H)=>H.id===Y.ruleId||H.code===Y.ruleId);let J=v4(),I=Y.linter??J.lint?.activeLinter??"builtin",K=await Rp(I),G=await WB0(U,K,{corpId:z?.corp?.id,versionNumber:Q,allRules:U},{minScore:Y.minScore,level:Y.level,summary:Y.summary});if(Y.minScore&&G.overallScore<Y.minScore)throw Error(`[Linter 质量门禁未通过] 综合评分 ${G.overallScore} 低于要求的最低分 ${Y.minScore} 分 (共发现 ${G.issueCount} 条问题规则)。`);return G}},{name:"seal_approval_rules_pull",description:"从 Seal 远端拉取草稿或指定版本规则,保存至本地规则文件(支持离线编辑与本地 Lint,绝不污染远端草稿)",parameters:L.object({version:L.string().optional().describe("指定拉取的历史发布版本号或 ID(如 16 或 latest),不传默认拉取当前草稿规则"),out:L.string().optional().describe("保存的目标本地文件路径,默认为 ./rules.local.json")}),handler:async($,Y,z)=>{let U=Y.out??"./rules.local.json",Q=[],J="draft",I;if(Y.version){let G=await c8($),H=Number(Y.version),W=isNaN(H)?Y.version==="latest"?G[0]:G.find((X)=>X.id===Y.version):G.find((X)=>X.versionNumber===H);if(!W)throw Error(`未找到指定的规则版本: ${Y.version}`);I=W.versionNumber,J=`version:${I}`,Q=(W.rules??[]).map((X,Z)=>({code:X.code?Number(String(X.code).replace(/^#/,""))||Z+1:Z+1,name:X.name??X.title,description:X.description??"",scope:X.scope??"ALL",strictness:X.strictness??"MUST_FOLLOW"}))}else Q=((await X6($)).rules??[]).map((H,W)=>({id:H.id,code:H.code??W+1,name:H.name??H.title,description:H.description??"",scope:H.scope??"ALL",strictness:H.strictness??"MUST_FOLLOW",status:H.status}));return{saved:!0,path:qB0(U,{corpId:z.corp.id,source:J,versionNumber:I,exportedAt:new Date().toISOString(),rulesCount:Q.length,rules: Line truncated
`+`• 身份主体:${j}${A}
`);let Z=ip(G.document,H,W),q=await fetch(`${I}/api/v1/integrations/webhook/${encodeURIComponent(Q)}/document`,{method:"POST",headers:{...Y.customHeaders??{},"Content-Type":"application/json",...uZ({webhookId:Q,...Z},Y.secret)},body:JSON.stringify(Z)});if(!q.ok)throw Error(`Webhook 单据推送失败 ${q.status}: ${await q.text()}`);J.push({documentId:Z.documentId,document:Z,pushResult:await q.json()}),process.stderr.write(`✓ 单据推送成功: ${Z.documentId}
`)}return{warnings:[],results:J}}function xz($){return{fileBuffer:fS1($),fileName:$.split(/[\\\/]/).pop()??"material-pack.zip"}}var kl=m(()=>{QP();np();bp();kp();QK();yl()});import{existsSync as nS1}from"node:fs";async function NT($,U,Y={}){let I=v4().stateful?"stateful":"stateless",Q="ok",J,K,G;try{let D=await Z8($);G={id:D.user.id,name:D.user.name,isAdmin:D.user.isAdmin},K={id:D.tenant.id,name:D.tenant.name,tenantSlug:D.tenant.tenantSlug,corporationName:D.tenant.hoseCorpConfig?.corporationName}}catch(D){Q="error",J=D instanceof Error?D.message:String(D)}let H=[];if(Q==="ok")try{H=await K$($,U.seal.endpoints.approvalStylePreferences)}catch(D){Q="error",J=`读取 Webhook 配置失败: ${D instanceof Error?D.message:String(D)}`}let W=H.length===1,X=H.map((D)=>({id:D.id,name:D.name,mode:D.mode,incomingDocumentWebhookUrl:D.incomingDocumentWebhook.url,outgoingResultWebhookUrl:D.outgoingResultWebhook,autoApprovalRate:D.autoApprovalRate,...W?{isDefault:!0}:{}})),Z=W?{id:H[0].id,name:H[0].name,mode:H[0].mode}:null,q=Y.webhook?x7(H,Y.webhook):W?H[0]:void 0,V;if(Y.filePath)if(!nS1(Y.filePath))V={valid:!1,filePath:Y.filePath,fileName:Y.filePath.split(/[\\/]/).pop()??Y.filePath,documentCount:0,errors:[`文件不存在: ${Y.filePath}`]};else try{let D=xz(Y.filePath),P=await kz(D.fileBuffer,D.fileName,q?.materialPackFilePolicy);V={valid:!0,filePath:Y.filePath,fileName:D.fileName,documentCount:P.documents.length,warnings:P.warnings}}catch(D){V={valid:!1,filePath:Y.filePath,fileName:Y.filePath.split(/[\\/]/).pop()??Y.filePath,documentCount:0,errors:[D instanceof Error?D.message:String(D)]}}let F=V?V.valid:!0,M=Q==="ok"&&X.length>0&&F,w=I==="stateful"?"":` --corp ${U.id}`,N="",O="";if(Q!=="ok")O=`凭证鉴权异常: ${J}`,N=`seal-use auth diagnose${w}`;else if(X.length===0)O="当前企业尚未配置任何 Webhook 集成通道",N=`seal-use webhook add --name "默认入站通道" --result-url "https://your-domain.com/callback"${w}`;else if(V&&!V.valid)O=`资源包预检失败: ${V.errors?.join("; ")}`,N=`seal-use webhook resource-pack preview ${V.filePath}${w}`;else{O=W?"所有通道正常,已自动锁定唯一 Webhook 通道,等待载入":`所有通道正常,检测到 ${X.length} 个 Webhook 通道,等待载入`;let D=V?.filePath??"<资源包.zip>",P=W?"":` --webhook ${Z?Z.id:"<webhookIdOrName>"}`;N=`seal-use webhook resource-pack push ${D}${P}${w}`}return{ready:M,corp:{id:U.id,name:U.name,sourceType:U.source.type,tenant:K,user:G},stateMode:I,authStatus:Q,authError:J,activeWebhooks:X,defaultWebhook:Z,resourcePack:V,materialPack:V,statusMessage:O,nextAction:N}}var __0=m(()=>{T5();X6();kl()});var xl=m(()=>{QK();aI();QP();kp();bp();np();kl();__0();yl()});import{existsSync as v_0,mkdirSync as h_0,statSync as cS1}from"node:fs";import{homedir as dS1}from"node:os";import{dirname as pS1,resolve as DT}from"node:path";function mS1($){if($.outputFile){let J=DT($.outputFile),K=pS1(J);if(!v_0(K))h_0(K,{recursive:!0});return J}let Y=($.corpName||$.corpId||"企业").replace(/[/\\?%*:|"<>]/g,"_").trim()||"企业",z=$.dateTag||new Date().toISOString().slice(0,10),I=`${Y}_智能洞察报告_${z}.xlsx`,Q;if($.toDownloads)Q=DT(dS1(),"Downloads");else Q=DT(process.cwd(),"exports");if(!v_0(Q))h_0(Q,{recursive:!0});return DT(Q,I)}async function AT($,U,Y={}){let z=U.name||U.id,I=Md({startDate:Y.startDate,endDate:Y.endDate,force:Y.force}),Q=new Date().toISOString(),[J,K]=await Promise.all([yM($,{startDate:I.startDateStr,endDate:I.endDateStr,limit:Y.limit??100}),xM($,{startDate:I.startDateStr,endDate:I.endDateStr}).catch(()=>({metrics:{},sankeyData:{nodes:[],links:[]}}))]),G=J.tagStats||[],H=[],W=Math.min(G.length,Y.limit??50);for(let C=0;C<W;C++){let b=G[C];if(!b?.tagId)continue;try{let x=await kM($,{tagId:b.tagId,startDate:I.startDateStr,endDate:I.endDateStr});for(let g of x.risks||[])H.push({tagId:b.tagId,tagName:b.tagName||b.tagId,documentSN:g.documentSN||"-",documentType:g.documentType||"-",riskLevel:g.riskLevel||"warning",confidence:g.confidence??0,riskDetails:g.riskDetails||"-",reasoning:g.reasoning||"-",sourceDocumentURL:g.sourceDocumentURL,createdAt:g.createdAt})}catch{}}let X=new S_0.default.Workbook;X.creator="seal-use",X.lastModifiedBy="seal-use",X.created=new Date,X.modified=new Date;let Z={type:"pattern",pattern:"solid",fgColor:{argb:"FF1E293B"}},q={name:"Microsoft YaHei",size:11,bold:!0,color:{argb:"FFFFFFFF"}},V={top:{style:"thin",color:{argb:"FFE2E8F0"}},bottom:{style:"thin",color:{argb:"FFE2E8F0"}},left:{style:"thin",color:{argb:"FFE2E8F0"}},right:{style:"thin",color:{argb:"FFE2E8F0"}}},F=X.addWorksheet("审核效能与决策流向",{views:[{showGridLines:!0}]});F.columns=[{header:"分类",key:"category",width:20},{header:"指标名称",key:"name",width:28},{header:"数值",key:"val",width:22},{header:"环比/趋势",key:"trend",width:18},{header:"说明",key:"desc",width:36}],F.getRow(1).height=28,F.getRow(1).font=q,F.getRow(1).fill=Z,F.getRow(1).alignment={vertical:"middle",horizontal:"center"};let M=K.metrics||{},w=[{c Line truncated
`);return{recordId:$.id,sourceDocumentSN:$.sourceDocumentSN,sourceDocumentId:$.sourceDocumentId,document:xK({id:U?.id,sn:U?.sn??U?.sourceDocumentSN??$.sourceDocumentSN,title:U?.title??U?.name,template:CT(U,["template.name","templateName","form.name","formName","formTitle"]),amount:PT(Y,["金额","报销金额","付款金额","合计","价税合计"])??CT(U,["amount","totalAmount","expenseAmount"]),expenseType:PT(Y,["费用类型","费用类别","报销类型"]),costCompany:PT(Y,["费用承担公司","承担公司","成本中心","费用归属"]),payee:PT(Y,["收款方","收款账户","收款信息","开户名","银行账号"]),keyFields:Y.slice(0,30)}),invoices:Wg1($),attachments:n2($,{summary:!0}).attachments,aiResult:_T($),manualResult:uz($)?.value,hints:xK({amountMentions:x_0(z,["金额","合计","税率"],8),partyMentions:x_0(z,["买方","卖方","甲方","乙方","收款"],8)})}}function Jg1($){let U=[["result.citedRules",l3($,"result.citedRules")],["result.matchedRules",l3($,"result.matchedRules")],["result.ruleResults",l3($,"result.ruleResults")],["result.rules",l3($,"result.rules")],["pipelineData.citedRules",l3($,"pipelineData.citedRules")],["pipelineData.matchedRules",l3($,"pipelineData.matchedRules")]],Y=[],z=new Set;for(let[I,Q]of U)(Array.isArray(Q)?Q:Q&&typeof Q==="object"?Object.values(Q):[]).forEach((K,G)=>{let H=Tq(K);if(!H)return;let W=M4(H.runtimeRuleId)??M4(H.runtimeId)??M4(H.id)??M4(H.ruleId),X=M4(H.ruleCode)??M4(H.code)??(W?qg1(W):void 0),Z=xK({runtimeRuleId:W,ruleCode:X,versionNumber:Gg1(H.versionNumber)??$.ruleSetVersionNumber,scope:M4(H.scope),strictness:M4(H.strictness),appliedAnalysis:H.appliedAnalysis??H.analysis??H.reasoning,checkResult:H.checkResult??H.result??H.decision,findings:H.findings??H.riskPoints??H.evidence,sourcePath:`${I}.${G}`}),q=JSON.stringify(Z);if(!z.has(q))z.add(q),Y.push(Z)});return{recordId:$.id,sourceDocumentSN:$.sourceDocumentSN,sourceDocumentId:$.sourceDocumentId,ruleSetVersionNumber:$.ruleSetVersionNumber,count:Y.length,rules:Y}}function CT($,U){if(!$)return;for(let Y of U){let z=l3($,Y);if(z!==void 0)return z}return}function k_0($,U){if(!$)return 0;for(let Y of U){let z=l3($,Y);if(Array.isArray(z))return z.length;if(z&&typeof z==="object")return Object.keys(z).length;if(typeof z==="number")return z}return 0}function l3($,U){return U.split(".").reduce((Y,z)=>{if(Y===void 0||Y===null)return;if(Array.isArray(Y)){let I=Number(z);return Number.isInteger(I)?Y[I]:void 0}if(typeof Y==="object")return Y[z];return},$)}function Kg1($,U,Y){let z=U.split("."),I=$;for(let Q of z.slice(0,-1)){let J=I[Q];if(!J||typeof J!=="object"||Array.isArray(J))I[Q]={};I=I[Q]}I[z[z.length-1]??U]=Y}function xK($){return Object.fromEntries(Object.entries($).filter(([,U])=>U!==void 0))}function Tq($){return $&&typeof $==="object"&&!Array.isArray($)?$:void 0}function Gg1($){return typeof $==="number"&&Number.isFinite($)?$:void 0}function Hg1($){let U=[];return bl($,"document",U),U}function bl($,U,Y){if(Array.isArray($)){$.forEach((J,K)=>bl(J,`${U}.${K}`,Y));return}let z=Tq($);if(!z)return;let I=M4(z.label)??M4(z.name)??M4(z.title)??M4(z.fieldName),Q=z.value??z.displayValue??z.text??z.content;if(I&&Q!==void 0&&typeof Q!=="object")Y.push(xK({path:U,label:I,value:Q,type:M4(z.type)??M4(z.fieldType)}));for(let[J,K]of Object.entries(z)){if(J==="attachments")continue;bl(K,`${U}.${J}`,Y)}}function PT($,U){return $.find((z)=>{let I=M4(z.label)??"";return U.some((Q)=>I.includes(Q))})?.value}function Wg1($){let U=[];return RT($.result,"result",U),RT($.document,"document",U),U.slice(0,20)}function RT($,U,Y){if(Array.isArray($)){$.forEach((I,Q)=>RT(I,`${U}.${Q}`,Y));return}let z=Tq($);if(!z)return;if(/invoice|发票/i.test(U))Y.push(xK({path:U,fileName:M4(z.fileName)??M4(z.filename)??M4(z.name),buyer:z.buyer??z.buyerName??z.purchaserName,seller:z.seller??z.sellerName,amount:z.amount??z.totalAmount??z.total,taxRate:z.taxRate,category:z.category??z.type}));for(let[I,Q]of Object.entries(z))RT(Q,`${U}.${I}`,Y)}function x_0($,U,Y){return $.split(/\r?\n/).filter((z)=>U.some((I)=>z.includes(I))).slice(0,Y)}function TT($){return $.map((U)=>{let Y=fz(U);return{recordId:Y.id,tenantId:Y.tenantId,agentId:Y.agentId,sourceDocumentSN:Y.sourceDocumentSN,sourceDocumentId:Y.sourceDocumentId,simulationBatchId:Y.simulationBatchId,langfuseTraceId:Y.langfuseTraceId,langfuseSessionFallback:Y.langfuseSessionFallback,ruleSetVersionNumber:Y.ruleSetVersionNumber,ruleSetPublishedAt:Y.ruleSetPublishedAt,ruleSetPublishedByName:Y.ruleSetPublishedByName,resolution:Y.langfuseTraceId?"trace":Y.langfuseSessionFallback?"session-fallback":"unresolved"}})}function ul($){return{id:$.id,tenantId:$.tenantId,versionNumber:$.versionNumber,versionName:$.versionName,publishedBy:$.publishedBy,publishedByName:$.publishedByName,rulesCount:$.rules.length,publishedAt:$.publishedAt,createdAt:$.createdAt}}async function Xg1($,U){if(U.recordId&&!U.versionId&&!U.versionNumber&&!U.latest){let Y=await H4($,U.recordId);if(!Y.ruleSetVersionNumber)throw Er Line truncated
`)},{...Rd(Q,20000,U.full===!0),format:U.format??"unified"}}},{name:"seal_approval_rule_version_publish",description:"发布 Seal 草稿审批规则为新版本",parameters:L.object({versionName:L.string().describe("版本名称")}),handler:async($,U,Y)=>{let z=await W6($).catch(()=>{return}),I=await xH($,U.versionName);if(z)try{fZ(Y.corp.id,I.version,z.rules)}catch{}return I}},{name:"seal_approval_rule_get",description:"按版本号/code/runtime-id/record-id 定位单条规则;code 只在选定的版本编号体系内有效,避免拉取整版规则快照",parameters:L.object({versionId:L.string().optional().describe("规则版本 ID"),versionNumber:L.number().int().positive().optional().describe("规则版本号"),latest:L.boolean().optional().describe("为 true 时取最新版本"),code:L.string().optional().describe("规则展示编号,如 #0038;没有后端 code 时按版本内序号匹配"),runtimeId:L.string().optional().describe("运行时规则 ID,如 rule-205;按版本内序号匹配"),recordId:L.string().optional().describe("从运行记录推断 ruleSetVersionNumber")}),handler:async($,U)=>{let Y=await Xg1($,U),z=Zg1(Y,{code:U.code,runtimeId:U.runtimeId});if(!z)throw Error(`Rule not found in version ${Y.versionNumber}`);return z}},{name:"seal_approval_rules_lint",description:"对 Seal 本地规则文件、草稿审批规则或指定发布版本规则进行质量与可执行性检查(模糊词、悬空例外检测)",parameters:L.object({file:L.string().optional().describe("指定本地规则文件路径进行离线质检(支持 .json),0网络请求、不污染远端草稿"),linter:L.string().optional().describe("指定使用的校验器名称或脚本路径(如 builtin、strict、./my-linter.ts)"),version:L.string().optional().describe("指定要质检的历史发布版本号或 ID(如 16 或 latest),不传默认质检当前草稿"),code:L.string().optional().describe("按规则展示编号过滤(如 #0038)"),ruleId:L.string().optional().describe("按规则 ID 过滤"),minScore:L.number().optional().describe("最低合格质量分阈值(0~100),低于该分值抛出错误以返回非零退出码"),level:L.enum(["all","error","warning"]).default("all").describe("问题报告等级过滤"),summary:L.boolean().optional().describe("为 true 时仅返回存在瑕疵/扣分的规则")}),handler:async($,U,Y)=>{let z=[],I;if(U.file){let H=dd(U.file);z=EB0(H.rules),I=H.meta.versionNumber}else if(U.version){let H=await d8($),W=Number(U.version),X=isNaN(W)?U.version==="latest"?H[0]:H.find((Z)=>Z.id===U.version):H.find((Z)=>Z.versionNumber===W);if(!X)throw Error(`未找到指定的规则版本: ${U.version}`);I=X.versionNumber,z=(X.rules??[]).map((Z,q)=>({id:Z.id??Z.runtimeId,code:Z.code??`#${String(q+1).padStart(4,"0")}`,name:Z.name??Z.title,description:Z.description??"",scope:Z.scope,strictness:Z.strictness}))}else z=((await W6($)).rules??[]).map((W,X)=>({id:W.id,code:W.code??`#${String(X+1).padStart(4,"0")}`,name:W.name??W.title,description:W.description??"",scope:W.scope,strictness:W.strictness}));if(U.code)z=z.filter((H)=>H.code===U.code||H.code?.replace(/[#\s]/g,"")===U.code?.replace(/[#\s]/g,""));if(U.ruleId)z=z.filter((H)=>H.id===U.ruleId||H.code===U.ruleId);let Q=v4(),J=U.linter??Q.lint?.activeLinter??"builtin",K=await bd(J),G=await BB0(z,K,{corpId:Y?.corp?.id,versionNumber:I,allRules:z},{minScore:U.minScore,level:U.level,summary:U.summary});if(U.minScore&&G.overallScore<U.minScore)throw Error(`[Linter 质量门禁未通过] 综合评分 ${G.overallScore} 低于要求的最低分 ${U.minScore} 分 (共发现 ${G.issueCount} 条问题规则)。`);return G}},{name:"seal_approval_rules_pull",description:"从 Seal 远端拉取草稿或指定版本规则,保存至本地规则文件(支持离线编辑与本地 Lint,绝不污染远端草稿)",parameters:L.object({version:L.string().optional().describe("指定拉取的历史发布版本号或 ID(如 16 或 latest),不传默认拉取当前草稿规则"),out:L.string().optional().describe("保存的目标本地文件路径,默认为 ./rules.local.json")}),handler:async($,U,Y)=>{let z=U.out??"./rules.local.json",I=[],Q="draft",J;if(U.version){let G=await d8($),H=Number(U.version),W=isNaN(H)?U.version==="latest"?G[0]:G.find((X)=>X.id===U.version):G.find((X)=>X.versionNumber===H);if(!W)throw Error(`未找到指定的规则版本: ${U.version}`);J=W.versionNumber,Q=`version:${J}`,I=(W.rules??[]).map((X,Z)=>({code:X.code?Number(String(X.code).replace(/^#/,""))||Z+1:Z+1,name:X.name??X.title,description:X.description??"",scope:X.scope??"ALL",strictness:X.strictness??"MUST_FOLLOW"}))}else I=((await W6($)).rules??[]).map((H,W)=>({id:H.id,code:H.code??W+1,name:H.name??H.title,description:H.description??"",scope:H.scope??"ALL",strictness:H.strictness??"MUST_FOLLOW",status:H.status}));return{saved:!0,path:jB0(z,{corpId:Y.corp.id,source:Q,versionNumber:J,exportedAt:new Date().toISOString(),rulesCount:I.length,rules: Line truncated
`+`• 身份主体:${T}${A}
`+`• 权限范围:持有该链接者在 Seal AI 中拥有该用户的完整操作权限(含系统设置与规则编辑)
`+`• 时效性:换票凭证有效时间 ${q} 秒(${Math.round(q/60)} 分钟),在浏览器打开后将保留 30 天会话
`+"• 安全边界:该凭证绝不包含且无法访问合思 (Hose) 主系统;仅限内部排查,严禁在外部公开分享!")}return{url:W?I:Z?V:G,type:X,mode:Z?"auto_login":"direct",sealResultUrl:G,hoseDocumentUrl:I,documentUrl:I,ssoUrl:V,expiresIn:Z?q:void 0,identity:F,warning:w,hoseDomain:J.type==="hose"?pS1(J.domain):void 0,recordId:Q.id,sourceDocumentSN:Q.sourceDocumentSN,sourceDocumentId:Q.sourceDocumentId,sourceSystem:Q.sourceSystem,missing:{hoseDocumentUrl:!I?"sourceExtendData.hosecloudViewUrl is absent from the approval run detail.":void 0}}}},{name:"seal_approval_run_pick",description:"按合思单号或关键字查询运行记录,返回候选记录及其当时使用的规则版本,便于再取详情或查版本规则",parameters:L.object({query:L.string().optional().describe("合思单号、源单据 ID、运行记录 ID 或 trace 关键字"),sn:L.string().optional().describe("合思/易快报单号;优先作为精确 sourceDocumentSN 查询"),batchId:L.string().optional().describe("模拟批次 ID"),latest:L.boolean().optional().describe("只返回最新一条匹配记录"),fields:L.union([L.string(),L.array(L.string())]).optional().describe("限制返回字段"),limit:L.number().int().positive().max(100).optional(),maxScan:L.number().int().positive().max(5000).optional().describe("最多扫描多少条运行记录用于本地匹配,默认 1000"),includeBridge:L.boolean().optional()}),handler:async($,Y,z)=>{let U=Y.sn??Y.query;if(!U)throw Error("query or sn is required");let Q=await dS1($,{query:U,sn:Y.sn,batchId:Y.batchId,latest:Y.latest,limit:Y.latest?1:Y.limit??20,maxScan:Y.maxScan??1000}),J=await Promise.all(Q.records.map((X)=>H4($,X.id))),I=A_0(Y.fields),K=J.map((X)=>iS1(X,I)),G=J.find((X)=>X.ruleSetVersionNumber!==void 0)?.ruleSetVersionNumber,H=G===void 0?"latest":String(G),W=G===void 0?'"latestRuleVersion":true':`"ruleVersionNumber":${G}`;return{query:U,sourceDocumentSN:Y.sn,simulationBatchId:Y.batchId,latest:Y.latest??!1,total:Q.total,scanned:Q.scanned,matched:K.length,records:K,next:{getSummary:`seal-use approval-runs get <recordId> --summary --corp ${z.corp.id}`,getRuleVersion:`seal-use rules version ${H} --corp ${z.corp.id}`,searchRuleVersion:`seal-use tool seal_approval_search --corp ${z.corp.id} --json '{"keywords":["关键词"],"areas":["rules"],"ruleVersionScope":"version",${W}}'`,getVersionContext:`seal-use tool seal_approval_context_get --corp ${z.corp.id} --json '{${W}}'`},...Y.includeBridge?{bridge:wj(J)}:{}}}},{name:"seal_simulation_batch_records_get",description:"获取某一次 Seal 模拟批次的运行记录,并整理对应 Langfuse trace/session 桥接字段",parameters:L.object({batchId:L.string().describe("simulation batch ID"),query:L.string().optional().describe("在 id、sourceDocumentSN、sourceDocumentId、documentId、Langfuse traceId 中做本地包含匹配")}),handler:async($,Y)=>{let z=yl(await Wg($,Y.batchId),Y.query);return{batchId:Y.batchId,count:z.length,records:z.map(fU),bridge:wj(z)}}},{name:"seal_simulation_batch_create",description:"创建 Seal 模拟测试批次。支持合思指定单号(hosecloud)与材料包导入(material_pack)两种模式;其他取数模式通过 rawParams 预留透传。",parameters:L.object({mode:L.enum(["hosecloud","material_pack"]).default("hosecloud").describe("来源模式: hosecloud=合思指定单号; material_pack=材料包导入"),flowIds:L.array(L.string()).max(100).optional().describe("合思模式: 单据流水号列表"),rejectNodeName:L.string().nullable().optional().describe("仅关注特定节点: 节点名称, 不设为 null 表示不限制"),thinkingDepthOverride:L.enum(["default","medium","high"]).optional().describe("思考深度: default=按偏好设置, medium=标准, high=深度推理"),skipInvoiceGeneration:L.boolean().optional().describe("跳过发票生成, 默认 true"),skipExpenseExtraction:L.boolean().optional().describe("跳过费用提取, 默认 true"),disableAttachmentCache:L.boolean().optional().describe("不使用附件缓存, 默认 false"),signKey:L.string().optional().describe("合思集成标识; 缺省时自动取第一个合思集成"),packageIds:L.array(L.string()).optional().describe("材料包模式: 材料包 id 列表(来自 material-packages upload 响应)"),templateId:L.string().optional().describe("材料包模板 id, 例如 conference_reimbursement_v1; 缺省取 schemaConfig.id"),schemaConfig:L.record(L.string(),L.unknown()).optional().describe("材料包字段映射(确认参数), 建议使用 material-packages upload 返回的 schemaConfig"),noWait:L.boolean().optional().describe("创建后立即返回异步票据,不等待批次完成"),rawParams:L.record(L.string(),L.unknown()).optional().describe("预留: 其他取数模式(如时间范围 startTime/endTime)透传参数, 覆盖上述构建结果")}),handler:async($,Y)=>{let z=Y.mode??"hosecloud",U=Y.signKey;if(z==="hosecloud"&&!U){if(U=(await Zg($)).find((K)=>K.signKey)?.signKey,!U)throw Error(" Line truncated
`)}function Yg1($){let Y=[];if(Y.push(`seal-use ${$.area} - ${$.title}`),$.description)Y.push($.description);Y.push(""),Y.push("Usage:");let z=new Map;for(let Q of $.commands){let J=Q.group??"",I=z.get(J)??[];I.push(Q),z.set(J,I)}let U=[...$.groupOrder??[],...[...z.keys()].filter((Q)=>!$.groupOrder?.includes(Q))];for(let Q of U){let J=z.get(Q);if(!J)continue;if(Q)Y.push(""),Y.push(`${Q}:`);for(let I of J)for(let K of I.usage)Y.push(` ${K}`)}if($.commands.some((Q)=>Q.name))Y.push(""),Y.push(`Run 'seal-use ${$.area} <command> --help' for details on a specific command.`);return Y.join(`
`)}function i_0(){let $=[];$.push("seal-use CLI"),$.push(""),$.push("Usage:"),$.push(" seal-use version");for(let Y of n_0)for(let z of Y.commands)for(let U of z.usage)$.push(` ${U}`);return $.push(""),$.push("Run 'seal-use <command> --help' for details on a specific command."),$.join(`
`)}var n_0;var nl=m(()=>{F$();n_0=[{area:"corps",title:"Enterprise and tenant management",description:"Manage enterprise configurations, environment modes, test bindings, and syncing.",groupOrder:["企业接入","发现与选择","企业配置","测试配对与验证","Hose 专属能力"],commands:[{name:"list",group:"发现与选择",summary:"List configured enterprises sorted by 7-day usage frequency",usage:["seal-use corps list [query] [--all] [--limit <n>] [--env <production|test>] [--strict] [--corp <corpId>]"],options:[{flag:"--all",description:"Display all configured enterprises without the default 10-item limit"},{flag:"--limit <n>",description:"Maximum number of enterprises to display (defaults to 10)"},{flag:"--env <production|test>",description:"Filter enterprises by environment ('production' or 'test')"},{flag:"--strict",description:"Use strict exact substring matching instead of default soft fuzzy search"}]},{name:"search",aliases:["find"],group:"发现与选择",summary:"Search configured enterprises with intelligent soft fuzzy matching",usage:["seal-use corps search <query> [--env <production|test>] [--strict]"],options:[{flag:"--env <production|test>",description:"Filter enterprises by environment ('production' or 'test')"},{flag:"--strict",description:"Use strict exact substring matching instead of default soft fuzzy search"}],description:"Searches enterprise ID, name, staff ID, domain, tenant slug, environment, or bindings. Uses soft search by default (case-insensitive, Chinese homophones, front/back nasal vowels, initials, typo/missing letter tolerance)."},{name:"get",aliases:["show"],group:"发现与选择",summary:"Get rich details and configuration of an enterprise",usage:["seal-use corps get <corpId>"],description:"Retrieves complete enterprise details (URLs, tenant slugs, custom headers/cookies, staff IDs, relations, config file path) with sensitive secrets safely redacted."},{name:"current",group:"发现与选择",summary:"Show active enterprise in stateful mode",usage:["seal-use corps current [--corp <corpId>]"]},{name:"switch",group:"发现与选择",summary:"Switch default active enterprise",usage:["seal-use corps switch <corpId>"]},{name:"mark",group:"企业配置",summary:"Mark enterprise environment as production or test",usage:["seal-use corps mark <corpId> --env <production|test> [--confirm]"],options:[{flag:"--env <production|test>",description:"Target environment: 'production' or 'test' (required)"},{flag:"--confirm",description:"Confirm the environment update (required)"}],description:"Explicitly updates an enterprise's environment tag. Requires --confirm to prevent accidental changes."},{name:"rename",group:"企业配置",summary:"Rename an enterprise display name",usage:["seal-use corps rename <corpId> --name <newName>"],options:[{flag:"--name <newName>",description:"New human-readable enterprise name (required)"}],description:"Safely updates the display name of a configured enterprise without modifying underlying files manually."},{name:"bind-test",group:"测试配对与验证",summary:"Bind a production enterprise to a test enterprise (1-to-1 association)",usage:["seal-use corps bind-test <prodCorpId> <testCorpId> [--confirm] [--force]","seal-use corps bind-test <testCorpId> --corp <prodCorpId> [--confirm] [--force]"],options:[{flag:"--confirm",description:"Explicitly confirm binding and tag test environment (required)"},{flag:"--force",description:"Force re-binding if the production enterprise is already bound"},{flag:"--corp <corpId>",description:"Specify production enterprise ID or name"}],description:"Establishes a strict 1-to-1 association between a production enterprise and a test enterprise. Automatically marks the test enterprise with environment 'test'."},{name:"unbind-test",group:"测试配对与验证",summary:"Unbind a production and test enterprise association",usage:["seal-use corps unbind-test [<corpId>] [--confirm]"],options:[{flag:"--confirm",description:"Explicitly confirm unbinding both sides (required)"},{flag:"--corp <corpId>",description:"Specify enterprise ID or name"}],description:"Removes the 1-to-1 test association from both the production enterprise and the test enterprise."},{name:"sync-test",group:"测试配对与验证",summary:"Synchronize rules and preferences from production to test enterprise",usage:["seal-use corps sync-test [<prodCorpId>] [--dry-run] [--yes] [--version-name <name>]"],options:[{flag:"--dry-run",description:"Preview sync diff without making network mutations (default)"},{flag:"--yes",description:"Execute synchronization and publish new rule version on test enterprise"},{flag:"--version-name <name>",description:"Custom version name for published test rule version"},{flag:"--corp <corpId>",description:"Specify production enterprise ID or name"}],description:"Overwrites test enterprise decision preferences with production preferences, syncs production draft rules to test enterprise, and immediately publishes a new versi Line truncated
`+"• 安全边界:该凭证绝不包含且无法访问合思 (Hose) 主系统;仅限内部排查,严禁在外部公开分享!")}return{url:W?J:Z?V:G,type:X,mode:Z?"auto_login":"direct",sealResultUrl:G,hoseDocumentUrl:J,documentUrl:J,ssoUrl:V,expiresIn:Z?q:void 0,identity:F,warning:M,hoseDomain:Q.type==="hose"?Fg1(Q.domain):void 0,recordId:I.id,sourceDocumentSN:I.sourceDocumentSN,sourceDocumentId:I.sourceDocumentId,sourceSystem:I.sourceSystem,missing:{hoseDocumentUrl:!J?"sourceExtendData.hosecloudViewUrl is absent from the approval run detail.":void 0}}}},{name:"seal_approval_run_pick",description:"按合思单号或关键字查询运行记录,返回候选记录及其当时使用的规则版本,便于再取详情或查版本规则",parameters:L.object({query:L.string().optional().describe("合思单号、源单据 ID、运行记录 ID 或 trace 关键字"),sn:L.string().optional().describe("合思/易快报单号;优先作为精确 sourceDocumentSN 查询"),batchId:L.string().optional().describe("模拟批次 ID"),latest:L.boolean().optional().describe("只返回最新一条匹配记录"),fields:L.union([L.string(),L.array(L.string())]).optional().describe("限制返回字段"),limit:L.number().int().positive().max(100).optional(),maxScan:L.number().int().positive().max(5000).optional().describe("最多扫描多少条运行记录用于本地匹配,默认 1000"),includeBridge:L.boolean().optional()}),handler:async($,U,Y)=>{let z=U.sn??U.query;if(!z)throw Error("query or sn is required");let I=await Mg1($,{query:z,sn:U.sn,batchId:U.batchId,latest:U.latest,limit:U.latest?1:U.limit??20,maxScan:U.maxScan??1000}),Q=await Promise.all(I.records.map((X)=>H4($,X.id))),J=y_0(U.fields),K=Q.map((X)=>Vg1(X,J)),G=Q.find((X)=>X.ruleSetVersionNumber!==void 0)?.ruleSetVersionNumber,H=G===void 0?"latest":String(G),W=G===void 0?'"latestRuleVersion":true':`"ruleVersionNumber":${G}`;return{query:z,sourceDocumentSN:U.sn,simulationBatchId:U.batchId,latest:U.latest??!1,total:I.total,scanned:I.scanned,matched:K.length,records:K,next:{getSummary:`seal-use approval-runs get <recordId> --summary --corp ${Y.corp.id}`,getRuleVersion:`seal-use rules version ${H} --corp ${Y.corp.id}`,searchRuleVersion:`seal-use tool seal_approval_search --corp ${Y.corp.id} --json '{"keywords":["关键词"],"areas":["rules"],"ruleVersionScope":"version",${W}}'`,getVersionContext:`seal-use tool seal_approval_context_get --corp ${Y.corp.id} --json '{${W}}'`},...U.includeBridge?{bridge:TT(Q)}:{}}}},{name:"seal_simulation_batch_records_get",description:"获取某一次 Seal 模拟批次的运行记录,并整理对应 Langfuse trace/session 桥接字段",parameters:L.object({batchId:L.string().describe("simulation batch ID"),query:L.string().optional().describe("在 id、sourceDocumentSN、sourceDocumentId、documentId、Langfuse traceId 中做本地包含匹配")}),handler:async($,U)=>{let Y=ml(await Pg($,U.batchId),U.query);return{batchId:U.batchId,count:Y.length,records:Y.map(fz),bridge:TT(Y)}}},{name:"seal_simulation_batch_create",description:"创建 Seal 模拟测试批次。支持合思指定单号(hosecloud)与材料包导入(material_pack)两种模式;其他取数模式通过 rawParams 预留透传。",parameters:L.object({mode:L.enum(["hosecloud","material_pack"]).default("hosecloud").describe("来源模式: hosecloud=合思指定单号; material_pack=材料包导入"),flowIds:L.array(L.string()).max(100).optional().describe("合思模式: 单据流水号列表"),rejectNodeName:L.string().nullable().optional().describe("仅关注特定节点: 节点名称, 不设为 null 表示不限制"),thinkingDepthOverride:L.enum(["default","medium","high"]).optional().describe("思考深度: default=按偏好设置, medium=标准, high=深度推理"),skipInvoiceGeneration:L.boolean().optional().describe("跳过发票生成, 默认 true"),skipExpenseExtraction:L.boolean().optional().describe("跳过费用提取, 默认 true"),disableAttachmentCache:L.boolean().optional().describe("不使用附件缓存, 默认 false"),signKey:L.string().optional().describe("合思集成标识; 缺省时自动取第一个合思集成"),packageIds:L.array(L.string()).optional().describe("材料包模式: 材料包 id 列表(来自 material-packages upload 响应)"),templateId:L.string().optional().describe("材料包模板 id, 例如 conference_reimbursement_v1; 缺省取 schemaConfig.id"),schemaConfig:L.record(L.string(),L.unknown()).optional().describe("材料包字段映射(确认参数), 建议使用 material-packages upload 返回的 schemaConfig"),noWait:L.boolean().optional().describe("创建后立即返回异步票据,不等待批次完成"),rawParams:L.record(L.string(),L.unknown()).optional().describe("预留: 其他取数模式(如时间范围 startTime/endTime)透传参数, 覆盖上述构建结果")}),handler:async($,U)=>{let Y=U.mode??"hosecloud",z=U.signKey;if(Y==="hosecloud"&&!z){if(z=(await jg($)).find((K)=>K.signKey)?.signKey,!z)throw Error(" Line truncated
`)}function Rg1($){let U=[];if(U.push(`seal-use ${$.area} - ${$.title}`),$.description)U.push($.description);U.push(""),U.push("Usage:");let Y=new Map;for(let I of $.commands){let Q=I.group??"",J=Y.get(Q)??[];J.push(I),Y.set(Q,J)}let z=[...$.groupOrder??[],...[...Y.keys()].filter((I)=>!$.groupOrder?.includes(I))];for(let I of z){let Q=Y.get(I);if(!Q)continue;if(I)U.push(""),U.push(`${I}:`);for(let J of Q)for(let K of J.usage)U.push(` ${K}`)}if($.commands.some((I)=>I.name))U.push(""),U.push(`Run 'seal-use ${$.area} <command> --help' for details on a specific command.`);return U.join(`
`)}function $v0(){let $=[];$.push("seal-use CLI"),$.push(""),$.push("Usage:"),$.push(" seal-use version");for(let U of Uv0)for(let Y of U.commands)for(let z of Y.usage)$.push(` ${z}`);return $.push(""),$.push("Run 'seal-use <command> --help' for details on a specific command."),$.join(`
`)}var Uv0;var el=m(()=>{O8();Uv0=[{area:"corps",title:"Enterprise and tenant management",description:"Manage enterprise configurations, environment modes, test bindings, and syncing.",groupOrder:["企业接入","发现与选择","企业配置","测试配对与验证","Hose 专属能力"],commands:[{name:"list",group:"发现与选择",summary:"List configured enterprises sorted by 7-day usage frequency",usage:["seal-use corps list [query] [--all] [--limit <n>] [--env <production|test>] [--strict] [--corp <corpId>]"],options:[{flag:"--all",description:"Display all configured enterprises without the default 10-item limit"},{flag:"--limit <n>",description:"Maximum number of enterprises to display (defaults to 10)"},{flag:"--env <production|test>",description:"Filter enterprises by environment ('production' or 'test')"},{flag:"--strict",description:"Use strict exact substring matching instead of default soft fuzzy search"}]},{name:"search",aliases:["find"],group:"发现与选择",summary:"Search configured enterprises with intelligent soft fuzzy matching",usage:["seal-use corps search <query> [--env <production|test>] [--strict]"],options:[{flag:"--env <production|test>",description:"Filter enterprises by environment ('production' or 'test')"},{flag:"--strict",description:"Use strict exact substring matching instead of default soft fuzzy search"}],description:"Searches enterprise ID, name, staff ID, domain, tenant slug, environment, or bindings. Uses soft search by default (case-insensitive, Chinese homophones, front/back nasal vowels, initials, typo/missing letter tolerance)."},{name:"get",aliases:["show"],group:"发现与选择",summary:"Get rich details and configuration of an enterprise",usage:["seal-use corps get <corpId>"],description:"Retrieves complete enterprise details (URLs, tenant slugs, custom headers/cookies, staff IDs, relations, config file path) with sensitive secrets safely redacted."},{name:"current",group:"发现与选择",summary:"Show active enterprise in stateful mode",usage:["seal-use corps current [--corp <corpId>]"]},{name:"switch",group:"发现与选择",summary:"Switch default active enterprise",usage:["seal-use corps switch <corpId>"]},{name:"mark",group:"企业配置",summary:"Mark enterprise environment as production or test",usage:["seal-use corps mark <corpId> --env <production|test> [--confirm]"],options:[{flag:"--env <production|test>",description:"Target environment: 'production' or 'test' (required)"},{flag:"--confirm",description:"Confirm the environment update (required)"}],description:"Explicitly updates an enterprise's environment tag. Requires --confirm to prevent accidental changes."},{name:"rename",group:"企业配置",summary:"Rename an enterprise display name",usage:["seal-use corps rename <corpId> --name <newName>"],options:[{flag:"--name <newName>",description:"New human-readable enterprise name (required)"}],description:"Safely updates the display name of a configured enterprise without modifying underlying files manually."},{name:"bind-test",group:"测试配对与验证",summary:"Bind a production enterprise to a test enterprise (1-to-1 association)",usage:["seal-use corps bind-test <prodCorpId> <testCorpId> [--confirm] [--force]","seal-use corps bind-test <testCorpId> --corp <prodCorpId> [--confirm] [--force]"],options:[{flag:"--confirm",description:"Explicitly confirm binding and tag test environment (required)"},{flag:"--force",description:"Force re-binding if the production enterprise is already bound"},{flag:"--corp <corpId>",description:"Specify production enterprise ID or name"}],description:"Establishes a strict 1-to-1 association between a production enterprise and a test enterprise. Automatically marks the test enterprise with environment 'test'."},{name:"unbind-test",group:"测试配对与验证",summary:"Unbind a production and test enterprise association",usage:["seal-use corps unbind-test [<corpId>] [--confirm]"],options:[{flag:"--confirm",description:"Explicitly confirm unbinding both sides (required)"},{flag:"--corp <corpId>",description:"Specify enterprise ID or name"}],description:"Removes the 1-to-1 test association from both the production enterprise and the test enterprise."},{name:"sync-test",group:"测试配对与验证",summary:"Synchronize rules and preferences from production to test enterprise",usage:["seal-use corps sync-test [<prodCorpId>] [--dry-run] [--yes] [--version-name <name>]"],options:[{flag:"--dry-run",description:"Preview sync diff without making network mutations (default)"},{flag:"--yes",description:"Execute synchronization and publish new rule version on test enterprise"},{flag:"--version-name <name>",description:"Custom version name for published test rule version"},{flag:"--corp <corpId>",description:"Specify production enterprise ID or name"}],description:"Overwrites test enterprise decision preferences with production preferences, syncs production draft rules to test enterprise, and immediately publishes a new versi Line truncated
`)}
`}function Rq($){return $.replace(/([?&](?:accessToken|token|returnToken)=)[^&\s]+/gi,"$1<redacted>").replace(/(Bearer\s+)[A-Za-z0-9._~+/=-]+/gi,"$1<redacted>")}function R0($,U={}){gg1($,U);let Y=`${JSON.stringify($,null,2)}
`;if(U.outputFile){_g1(U.outputFile,Y),console.log(JSON.stringify({outputFile:U.outputFile,bytes:Buffer.byteLength(Y,"utf-8")},null,2));return}console.log(Y.trimEnd())}function gg1($,U={}){if(U.allowFull||U.outputFile)return;let Y=Buffer.byteLength(JSON.stringify($),"utf-8");if(Y>Sg1)throw new JP(`Output is large (${Y} bytes). Use --summary, --fields, --count, or --output-file; pass --full only when you really need the full response.`)}function Qv0($,U){if(U)return;let Y=$&&typeof $==="object"?$:{},z=typeof Y.count==="number"?Y.count:void 0,I=Array.isArray(Y.rules)?Y.rules.length:void 0,Q=Buffer.byteLength(JSON.stringify($),"utf-8"),J=z??I??0;if(J>vg1||Q>hg1)throw new JP(`Rule list is large (${J} rules, ${Q} bytes). Use "seal-use rules list --summary", "seal-use rules count", or --output-file; pass --full only when you really need full descriptions.`,"seal-use rules list --summary")}function j0($){return{allowFull:G0($.full)===!0,outputFile:S($.outputFile)??S($["output-file"])}}function Jv0($=[]){console.log(zv0($))}var vg1=100,hg1=120000,Iv0,Sg1=200000;var m1=m(()=>{Z4();O8();el();Iv0=["code","status","strictness","scope","updatedAt"]});var Uo={};T8(Uo,{selectCorp:()=>M1,runToolResult:()=>M$,runTool:()=>x0,globalConfigSummary:()=>t2});function M1($){let U=t8(),Y=v4(),z=c2(U,{stateful:Y.stateful,defaultCorpId:Y.defaultCorpId,corpId:$},x3());return rA0(z.id),z}function t2($=v4()){return{mode:$.stateful?"stateful":"stateless",stateful:$.stateful,...$.stateful&&$.defaultCorpId?{defaultCorpId:$.defaultCorpId}:{},...$.testEnterprisesDir?{testEnterprisesDir:$.testEnterprisesDir}:{},lint:$.lint,configFile:Zz()}}async function x0($,U,Y,z,I={}){R0(await M$($,U,Y,z),I)}async function M$($,U,Y,z){let I=Pq.find((K)=>K.name===$);if(!I)throw Error(`Unknown Seal tool: ${$}`);let Q=Object.fromEntries(Object.entries(z).filter(([,K])=>K!==void 0)),J=I.handler;return J(U,Q,{corp:Y})}var O4=m(()=>{T5();YP();jq();m1()});import{existsSync as Kv0}from"node:fs";async function Gv0($,U){if(!Kv0($))throw Error(`File not found: ${$}`);let Y=xz($);console.log(JSON.stringify(await kz(Y.fileBuffer,Y.fileName,U),null,2))}async function gT($,U,Y,z,I){if($==="ready"||$==="status"){let Q=U??S(I.options.file)??S(I.options.input),J=await NT(Y,z,{filePath:Q,webhook:S(I.options.webhook)??S(I.options.selector)});if(console.error(`[webhook-ready] 企业环境: ${J.corp.name} (${J.corp.id}) [${J.stateMode}]`),J.corp.tenant?.name)console.error(`[webhook-ready] 租户信息: ${J.corp.tenant.name} (${J.corp.tenant.id})`);console.error(`[webhook-ready] 凭证状态: ${J.authStatus==="ok"?"OK":`异常 (${J.authError})`}`),console.error(`[webhook-ready] Webhook 通道: ${J.activeWebhooks.length} 个可用`);for(let K of J.activeWebhooks){let G=K.isDefault?" [默认通道]":"";console.error(` - ${K.name} (${K.id}) mode=${K.mode}${G}`)}if(J.materialPack)console.error(`[webhook-ready] 材料包预检: ${J.materialPack.valid?`通过 (${J.materialPack.documentCount} 单)`:`失败 (${J.materialPack.errors?.join("; ")})`}`);if(J.ready)console.error(`\uD83D\uDFE2 ${J.statusMessage}`),console.error(`\uD83D\uDC49 Next action: ${J.nextAction}`);else console.error(`\uD83D\uDD34 准备阶段未通过: ${J.statusMessage}`),console.error(`\uD83D\uDC49 Next action: ${J.nextAction}`);console.log(JSON.stringify(J,null,2));return}if($==="replay"){let Q=U??S(I.options.recordId)??S(I.options["record-id"])??S(I.options.id),J=S(I.options.recordIds)??S(I.options["record-ids"]),K=J?J.split(",").map((n)=>n.trim()).filter(Boolean):void 0,G=S(I.options.sn)??S(I.options.documentSn)??S(I.options["document-sn"]),H=S(I.options.sns)??S(I.options["document-sns"]),W=H?H.split(",").map((n)=>n.trim()).filter(Boolean):void 0,X=s0(I.options.limit),Z=S(I.options.status),q=S(I.options.startDate)??S(I.options["start-date"]),V=S(I.options.endDate)??S(I.options["end-date"]);if(!Q&&!K&&!G&&!W&&X===void 0)throw Error("Usage: seal-use webhook replay <recordId> [--sn <documentSN>] [--limit <n>] [--status <status>] [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>] [--dry-run]");let F=S(I.options.sourceCorp)??S(I.options["source-corp"])??S(I.options.prodCorp)??S(I.options["prod-corp"]),M=S(I.options.targetCorp)??S(I.options["target-corp"])??S(I.options.testCorp)??S(I.options["test-corp"]),w=G0(I.options.force)===!0,{sourceCorp:N,targetCorp:O}=KP({sourceCorpId:F,targetCorpId:M,activeCorp:z,force:w},M1),D=N.id===z.id?Y:await B1(N),P=O.id===z.id?Y:await B1(O),T=S(I.options.webhook)??S(I.options.selector),A=S(I.options.snSuffix)??S(I.options["sn-suffix"]),j=S(I.options.snPrefix)??S(I.options["sn-prefix"]),C=S(I.options.docIdSuffix)??S(I.options["doc-id-suffix"]),b=S(I.options.docIdPrefix)??S(I.options["doc-id-prefix"]),x=G0(I.options.dryRun)??G0(I.options["dry-run"]),i=await zK({query:{recordId:Q,recordIds:K,sn:G,sns:W,limit:X,status:Z,startDate:q,endDate:V},sourceClient:D,targetClient:P,sourceCorp:N,targetCorp:O,webhookSelector:T,snPrefix:j,snSuffix:A,docIdPrefix:b,docIdSuffix:C,dr Line truncated
or: seal-use corps bind-test <testCorpId> --corp <prodCorpId> [--confirm] [--force]`);let Q=M1(z),J=M1(I);if(Q.id===J.id)throw h4(`Cannot bind enterprise '${Q.id}' to itself.`);if(Q.prodCorpId&&Q.prodCorpId!==J.id)throw h4(`Cannot use '${Q.id}' as a production enterprise because it is already registered as a test enterprise for '${Q.prodCorpId}'. Multi-tier chaining is not permitted.`);if(J.testCorpId&&J.testCorpId!==Q.id)throw h4(`Cannot bind '${J.id}' as a test enterprise because it already has a bound test enterprise '${J.testCorpId}'. Multi-tier chaining is not permitted.`);let K=G0(Y.options.force)===!0;if(Q.testCorpId&&Q.testCorpId!==J.id||J.prodCorpId&&J.prodCorpId!==Q.id){if(!K)throw F$(`Enterprise binding conflict: production enterprise '${Q.id}' is bound to '${Q.testCorpId??"none"}', and test enterprise '${J.id}' is bound to '${J.prodCorpId??"none"}'. Overwriting an existing binding requires --force and --confirm.`,`seal-use corps bind-test ${Q.id} ${J.id} --confirm --force`)}if(!(G0(Y.options.confirm)===!0||G0(Y.options.yes)===!0)){let X=K?" --force":"";throw F$(`Refusing to bind test enterprise '${J.name}' (${J.id}) to production enterprise '${Q.name}' (${Q.id}) without --confirm. Enterprise binding establishes 1-to-1 sync pairing and marks '${J.id}' as a test environment.`,`seal-use corps bind-test ${Q.id} ${J.id} --confirm${X}`)}if(Q.testCorpId&&Q.testCorpId!==J.id)try{E9(Q.testCorpId,{prodCorpId:void 0})}catch{}if(J.prodCorpId&&J.prodCorpId!==Q.id)try{E9(J.prodCorpId,{testCorpId:void 0})}catch{}let H=E9(Q.id,{environment:"production",testCorpId:J.id}),W=E9(J.id,{environment:"test",prodCorpId:Q.id});return R0({success:!0,productionEnterprise:{id:H.id,name:H.name,environment:H.environment,testCorpId:H.testCorpId},testEnterprise:{id:W.id,name:W.name,environment:W.environment,prodCorpId:W.prodCorpId}}),!0}if($==="unbind-test"){let z=U??S(Y.options.corp),I=M1(z);if(!I.testCorpId&&!I.prodCorpId)return R0({unbound:!1,message:`Enterprise '${I.name}' (${I.id}) does not have an active test enterprise binding.`}),!0;let Q=I.testCorpId?I.id:I.prodCorpId,J=I.testCorpId?I.testCorpId:I.id;if(!(G0(Y.options.confirm)===!0||G0(Y.options.yes)===!0))throw F$(`Refusing to unbind production enterprise '${Q}' and test enterprise '${J}' without --confirm.`,`seal-use corps unbind-test ${I.id} --confirm`);E9(Q,{testCorpId:void 0});try{E9(J,{prodCorpId:void 0})}catch{}return R0({success:!0,unboundProduction:Q,unboundTest:J}),!0}return!1}var Vv0=m(()=>{T5();O4();O8();Z4();m1()});function yT($){let U;try{U=new URL($.trim())}catch{throw Error("Invalid Seal delegate link: expected a valid HTTPS URL")}if(U.protocol!=="https:")throw Error("Invalid Seal delegate link: expected HTTPS");let Y=U.hostname.toLowerCase();if(!Y.endsWith(Lv0))throw Error(`Invalid Seal delegate link: expected host ending in ${Lv0}, got ${Y}`);let z=U.pathname.replace(/\/+$/,"");if(z!==wv0)throw Error(`Invalid Seal delegate link: expected path ${wv0}, got ${z}`);let I=U.searchParams.get("token");if(!I)throw Error("Invalid Seal delegate link: token query parameter is required");return{sealUrl:U.origin,delegateToken:I}}async function Fv0($){let U=typeof $==="string"?yT($):$;return(await B6(U.sealUrl,void 0).post("api/v1/delegation/preview",{json:{token:U.delegateToken}}).json()).data}async function Mv0($){let U=typeof $==="string"?yT($):$,Y=U.sealUrl,z=B6(Y,void 0),I=await z.post("api/v1/delegation/consume",{json:{token:U.delegateToken}}),Q=I.headers.get("set-cookie")??"",J=typeof I.headers.getSetCookie==="function"?I.headers.getSetCookie():[Q],K="";for(let M of J)if(M&&M.includes("session_token=")){K=(M.split(";")[0]??"").trim();break}let G;try{G=await z.get("api/auth/get-session",{headers:K?{cookie:K}:{}}).json()}catch{}let H=G?.session?.token;if(!H&&K){let M=K.match(/session_token=([^.;]+)/);if(M?.[1])H=decodeURIComponent(M[1])}if(!H)throw Error("Seal delegate exchange did not return a session token");let W=86400;if(G?.session?.expiresAt){let M=new Date(G.session.expiresAt).getTime();if(Number.isFinite(M)){let w=Math.floor((M-Date.now())/1000);if(w>0)W=w}}let Z=await B6(Y,H).get("api/v1/auth/me").json(),q=Z.data&&typeof Z.data==="object"?Z.data:Z,V=q.user??G?.user??{},F=q.tenant??{};return{sealUrl:Y,token:H,expiresIn:W,user:V,tenant:F}}function kT($){let U=[],Y=0,z="";try{let J=new URL($.trim()),K=J.hostname.toLowerCase(),G=J.pathname.replace(/\/+$/,"");if(K.endsWith(".ekuaibao.com")||K.endsWith(".hosecloud.com")||K==="ekuaibao.com"||K==="hosecloud.com")Y+=40,z="host is Hose domain";if(G==="/web/thirdparty.html")Y+=40,z+="; path is /web/thirdparty.html";if(J.searchParams.has("accessToken"))Y+=10,z+="; has accessToken";if(J.searchParams.has("ekbCorpId"))Y+=10,z+="; has ekbCorpId"}catch{Y=0}if(Y>0)U.push({kind:"hose",score:Y,reason:z});let I=0,Q="";try{let J=new URL($.trim()),K=J.hostname.toLowerCase(),G=J.pathname.replace(/\/+$/,"");if(K.endsWith(".sealai.cc"))I+=40,Q="host ends with .sealai.cc";if(G==="/delegate")I+=40,Q+="; path is /delegate";if( Line truncated
`,{mode:384}),{config:Y,path:I}}var Io=m(()=>{T5();sB()});function Qo($){return new Date($).toISOString().replace(/\.\d{3}Z$/,"Z")}function xT($){let U=new Date($);if(Number.isNaN(U.getTime()))return $;return Qo(U.getTime())}function $5($){return typeof $==="string"&&$?$:void 0}function bg1($){return{headers:Ad.parse($.headers),cookies:Bd.parse($.cookies)}}async function ig1($,U,Y={}){let z=await Z8(B6($,U,Y));return{user:z.user??{},tenant:z.tenant??{}}}async function Ov0($){let U=$.sealUrl.replace(/\/+$/,""),Y=$.expiresIn??2592000,z=$.force===!0||$.verify===!1?!1:!0,I=bg1($),Q=z?await ig1(U,$.token,A6(I)):void 0,J=Dv0($,{token:$.token,sealUrl:U,expiresIn:Y,expiresAt:$.expiresAt,verify:z,remote:Q,custom:I}),K=$.tenantId??$5(Q?.tenant.id),G=$.tenantSlug??$5(Q?.tenant.tenantSlug);return{...J,verified:z,tenantId:K,tenantSlug:G}}function Nv0($){let U=$5($.session.tenant.tenantSlug),Y=$5($.session.tenant.id),z=U??Y??"seal-delegate";return{...Dv0({id:z,corpId:z,name:$.name,provider:"seal",overwrite:$.overwrite},{token:$.session.token,sealUrl:$.session.sealUrl,expiresIn:$.session.expiresIn,verify:!0,remote:{user:$.session.user,tenant:$.session.tenant}}),tenantId:Y,tenantSlug:U}}function Dv0($,U){let Y=U.remote?.user,z=U.remote?.tenant,I=$.tenantSlug??$5(z?.tenantSlug),Q=$.tenantId??$5(z?.id),J=$.tenantName??$5(z?.name),K=$.id??I??Q;if(!K)throw Error("Missing required JSON field: id. Seal whoami did not return tenantSlug or tenantId.");let G=U.expiresAt?xT(U.expiresAt):Qo(Date.now()+U.expiresIn*1000),H=$.staffId??$5(Y?.providerUserId)??$5(Y?.id)??"seal",W=$.provider??$5(Y?.provider)??$5(z?.providerConfig?.provider),X=$.corpId??I??Q??K,Z={id:K,name:$.name??J??K,environment:"production",seal:{url:U.sealUrl,tenantSlug:I,headers:U.custom?.headers,cookies:U.custom?.cookies,endpoints:{approvalStylePreferences:"api/v1/agent/ai-approval/config"}},source:{type:"seal",token:U.token,sealUrl:U.sealUrl,expiresIn:U.expiresIn,expiresAt:G,staffId:H,corpId:X,tenantId:Q,tenantSlug:I,tenantName:J,providerUserId:$5(Y?.providerUserId),provider:W},auth:{refreshTtl:300}};return _q(Z,{overwrite:$.overwrite===!0})}var Jo=m(()=>{Io();sB();m6();X6()});async function bK($){let[U,Y]=await Promise.all([J10($),B1($)]),z=await Z8(Y);return{...U,tenantId:z.tenant.id,tenantSlug:z.tenant.tenantSlug??U.tenantSlug,tenantName:z.tenant.name,raw:{...typeof U.raw==="object"&&U.raw!==null?U.raw:{},user:{id:z.user.id,name:z.user.name,isAdmin:z.user.isAdmin,providerUserId:z.user.providerUserId,hosecloudStaff:z.user.hosecloudStaff},tenant:z.tenant}}}var fT=m(()=>{m6();Gg();X6()});async function Av0($){let U=await rI($.appKey,$.appSecurity,$.domain),Y=await wM(U.domain,U.openapiToken).catch(()=>[]);return{...U,roleCount:Y.reduce((z,I)=>z+I.roleDefs.length,0),roleGroups:Y.map((z)=>({id:z.id,name:z.name,roleDefs:z.roleDefs.map((I)=>({id:I.id,name:I.name,sourceType:I.sourceType}))}))}}async function Bv0($){let U=await rI($.appKey,$.appSecurity,$.domain),Y=$.role??$.roleDefId??"admin",z=await wM(U.domain,U.openapiToken),I,Q;for(let G of z){for(let H of G.roleDefs)if(H.id===Y||H.id===`${U.corpId}:${Y}`){I=H.id,Q=H.name;break}if(I)break}if(!I&&(Y==="admin"||Y==="主管理员"))for(let G of z){for(let H of G.roleDefs)if(H.id.endsWith(":admin")||H.name==="主管理员"){I=H.id,Q=H.name;break}if(I)break}if(!I)for(let G of z){for(let H of G.roleDefs)if(H.name.toLowerCase().includes(Y.toLowerCase())){I=H.id,Q=H.name;break}if(I)break}if(!I)throw Error(`Role not found matching query: '${Y}'. Run 'seal-use corps probe-hose' to view all available roles.`);let J=await Ig(U.domain,U.openapiToken,I),K=await Qg(U.domain,U.openapiToken,J.staffs);return{domain:U.domain,corpId:U.corpId,corpName:U.corpName??U.corpId,roleId:I,roleName:Q,staffs:K}}async function vq($){let U=$.domain,Y=$.staffId??$.proxyStaffBizId,z=$.force===!0,I=z||$.verify===!1?!1:!0,Q=U,J=$.corpId??$.corporationId,K=$.name,G;if(!Q||!J||!Y){let V=await rI($.appKey,$.appSecurity,U);Q=V.domain,J=J??V.corpId,K=K??V.corpName,G=V.openapiToken}let H=Y;if(!H&&G&&Q){let V=$.role??"admin",F=await wM(Q,G).catch(()=>[]),M;for(let w of F){for(let N of w.roleDefs)if(N.id.endsWith(`:${V}`)||N.name===V||N.id===V){M=N.id;break}if(M)break}if(!M)M=F.find((w)=>w.roleDefs.some((N)=>N.id.endsWith(":admin")))?.roleDefs.find((w)=>w.id.endsWith(":admin"))?.id;if(M){let w=await Ig(Q,G,M).catch(()=>({staffs:[]})),N=await Qg(Q,G,w.staffs).catch(()=>[]);if($.staffName||$.staffPhone){let O=N.filter((D)=>{if($.staffName&&D.name!==$.staffName&&!D.name.includes($.staffName))return!1;if($.staffPhone&&(!D.cellphone||!D.cellphone.includes($.staffPhone)))return!1;return!0});if(O.length===1&&O[0])H=O[0].id;else if(O.length>1)throw Error(`Multiple staff members matched '${$.staffName??$.staffPhone}': ${O.map((D)=>`${D.name}(${D.id})`).join(", ")}. Please specify exact staffId.`);else throw Error(`No staff member found matching '${$.staffName??$.staffPhone}' under role ${M}. Run 'seal-use corps hose-staffs' to view candidates.`)}else if(!z){let O=N.map( Line truncated
`+"\uD83D\uDCA1 说明:此能力专属于合思 (Hose) 子域,用于将临时会话提权为标准 OpenAPI 开发者接入。需要企业管理员已在合思开放平台创建应用并生成 appKey/appSecurity。",z);if(Y.keyId||Y.appKey){let I=$.find((Q)=>Y.keyId&&Q.id===Y.keyId||Y.appKey&&Q.appKey===Y.appKey);if(!I)throw new bz(`指定的合思密钥不存在,请从上述候选列表中选择正确的 appKey 或 keyId。
`+`当前企业存在以下 ${$.length} 套候选密钥:
`+$.map((Q)=>` • "${Q.name||"未命名应用"}" (appKey: ${Q.appKey}, keyId: ${Q.id}, 状态: ${Q.active?"\uD83D\uDFE2 启用":"⚪ 停用"})`).join(`
`),`${z} --app-key ${$[0].appKey}`);return I}if($.length===1)return $[0];throw new bz(`
ℹ️ [合思子域提权] 合思企业 [${U}] 存在多套 (${$.length} 套) OpenAPI 应用密钥凭据:
${$.map((I,Q)=>` [${Q+1}] "${I.name||"未命名应用"}" (appKey: ${I.appKey}, keyId: ${I.id}, 状态: ${I.active?"\uD83D\uDFE2 启用":"⚪ 停用"})`).join(`
`)}
`}function Tq($){return $.replace(/([?&](?:accessToken|token|returnToken)=)[^&\s]+/gi,"$1<redacted>").replace(/(Bearer\s+)[A-Za-z0-9._~+/=-]+/gi,"$1<redacted>")}function x0($,Y={}){Ig1($,Y);let z=`${JSON.stringify($,null,2)}
`;if(Y.outputFile){zg1(Y.outputFile,z),console.log(JSON.stringify({outputFile:Y.outputFile,bytes:Buffer.byteLength(z,"utf-8")},null,2));return}console.log(z.trimEnd())}function Ig1($,Y={}){if(Y.allowFull||Y.outputFile)return;let z=Buffer.byteLength(JSON.stringify($),"utf-8");if(z>Jg1)throw new eB(`Output is large (${z} bytes). Use --summary, --fields, --count, or --output-file; pass --full only when you really need the full response.`)}function m_0($,Y){if(Y)return;let z=$&&typeof $==="object"?$:{},U=typeof z.count==="number"?z.count:void 0,Q=Array.isArray(z.rules)?z.rules.length:void 0,J=Buffer.byteLength(JSON.stringify($),"utf-8"),I=U??Q??0;if(I>Ug1||J>Qg1)throw new eB(`Rule list is large (${I} rules, ${J} bytes). Use "seal-use rules list --summary", "seal-use rules count", or --output-file; pass --full only when you really need full descriptions.`,"seal-use rules list --summary")}function E0($){return{allowFull:Z0($.full)===!0,outputFile:h($.outputFile)??h($["output-file"])}}function l_0($=[]){console.log(p_0($))}var Ug1=100,Qg1=120000,d_0,Jg1=200000;var K4=m(()=>{A4();F$();nl();d_0=["code","status","strictness","scope","updatedAt"]});var pl={};D8(pl,{selectCorp:()=>T1,runToolResult:()=>O$,runTool:()=>k0,globalConfigSummary:()=>a2});function T1($){let Y=a8(),z=v4(),U=n2(Y,{stateful:z.stateful,defaultCorpId:z.defaultCorpId,corpId:$},g3());return kA0(U.id),U}function a2($=v4()){return{mode:$.stateful?"stateful":"stateless",stateful:$.stateful,...$.stateful&&$.defaultCorpId?{defaultCorpId:$.defaultCorpId}:{},...$.testEnterprisesDir?{testEnterprisesDir:$.testEnterprisesDir}:{},lint:$.lint,configFile:ZU()}}async function k0($,Y,z,U,Q={}){x0(await O$($,Y,z,U),Q)}async function O$($,Y,z,U){let Q=Dq.find((K)=>K.name===$);if(!Q)throw Error(`Unknown Seal tool: ${$}`);let J=Object.fromEntries(Object.entries(U).filter(([,K])=>K!==void 0)),I=Q.handler;return I(Y,J,{corp:z})}var f4=m(()=>{k3();rB();Bq();K4()});import{existsSync as o_0}from"node:fs";async function r_0($,Y){if(!o_0($))throw Error(`File not found: ${$}`);let z=xU($);console.log(JSON.stringify(await kU(z.fileBuffer,z.fileName,Y),null,2))}async function Cj($,Y,z,U,Q){if($==="ready"||$==="status"){let J=Y??h(Q.options.file)??h(Q.options.input),I=await qj(z,U,{filePath:J,webhook:h(Q.options.webhook)??h(Q.options.selector)});if(console.error(`[webhook-ready] 企业环境: ${I.corp.name} (${I.corp.id}) [${I.stateMode}]`),I.corp.tenant?.name)console.error(`[webhook-ready] 租户信息: ${I.corp.tenant.name} (${I.corp.tenant.id})`);console.error(`[webhook-ready] 凭证状态: ${I.authStatus==="ok"?"OK":`异常 (${I.authError})`}`),console.error(`[webhook-ready] Webhook 通道: ${I.activeWebhooks.length} 个可用`);for(let K of I.activeWebhooks){let G=K.isDefault?" [默认通道]":"";console.error(` - ${K.name} (${K.id}) mode=${K.mode}${G}`)}if(I.materialPack)console.error(`[webhook-ready] 材料包预检: ${I.materialPack.valid?`通过 (${I.materialPack.documentCount} 单)`:`失败 (${I.materialPack.errors?.join("; ")})`}`);if(I.ready)console.error(`\uD83D\uDFE2 ${I.statusMessage}`),console.error(`\uD83D\uDC49 Next action: ${I.nextAction}`);else console.error(`\uD83D\uDD34 准备阶段未通过: ${I.statusMessage}`),console.error(`\uD83D\uDC49 Next action: ${I.nextAction}`);console.log(JSON.stringify(I,null,2));return}if($==="replay"){let J=Y??h(Q.options.recordId)??h(Q.options["record-id"])??h(Q.options.id),I=h(Q.options.recordIds)??h(Q.options["record-ids"]),K=I?I.split(",").map((n)=>n.trim()).filter(Boolean):void 0,G=h(Q.options.sn)??h(Q.options.documentSn)??h(Q.options["document-sn"]),H=h(Q.options.sns)??h(Q.options["document-sns"]),W=H?H.split(",").map((n)=>n.trim()).filter(Boolean):void 0,X=s0(Q.options.limit),Z=h(Q.options.status),q=h(Q.options.startDate)??h(Q.options["start-date"]),V=h(Q.options.endDate)??h(Q.options["end-date"]);if(!J&&!K&&!G&&!W&&X===void 0)throw Error("Usage: seal-use webhook replay <recordId> [--sn <documentSN>] [--limit <n>] [--status <status>] [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>] [--dry-run]");let F=h(Q.options.sourceCorp)??h(Q.options["source-corp"])??h(Q.options.prodCorp)??h(Q.options["prod-corp"]),w=h(Q.options.targetCorp)??h(Q.options["target-corp"])??h(Q.options.testCorp)??h(Q.options["test-corp"]),O=Z0(Q.options.force)===!0,{sourceCorp:N,targetCorp:M}=$P({sourceCorpId:F,targetCorpId:w,activeCorp:U,force:O},T1),D=N.id===U.id?z:await P1(N),P=M.id===U.id?z:await P1(M),j=h(Q.options.webhook)??h(Q.options.selector),A=h(Q.options.snSuffix)??h(Q.options["sn-suffix"]),T=h(Q.options.snPrefix)??h(Q.options["sn-prefix"]),C=h(Q.options.docIdSuffix)??h(Q.options["doc-id-suffix"]),b=h(Q.options.docIdPrefix)??h(Q.options["doc-id-prefix"]),k=Z0(Q.options.dryRun)??Z0(Q.options["dry-run"]),i=await zK({query:{recordId:J,recordIds:K,sn:G,sns:W,limit:X,status:Z,startDate:q,endDate:V},sourceClient:D,targetClient:P,sourceCorp:N,targetCorp:M,webhookSelector:j,snPrefix:T,snSuffix:A,docIdPrefix:b,docIdSuffix:C,dr Line truncated
`+`\uD83D\uDC49 查看全部请添加: seal-use corps list --all
`+"\uD83D\uDC49 检索指定企业请使用: seal-use corps search <keyword>")}x0(O.map((N)=>({id:N.id,name:N.name,environment:N.environment??"production",sourceType:N.source.type,provider:N.source.provider??N.source.type,staffId:N.source.staffId,testCorpId:N.testCorpId,prodCorpId:N.prodCorpId,current:N.id===H})));return}if($==="get"||$==="show"){let U=Y??h(z.options.corp);if(!U)throw m4("Usage: seal-use corps get <corpId>");let Q=T1(U),J=Vp(Q.id),I=yg1(Q);x0({id:Q.id,name:Q.name,environment:Q.environment??"production",configFile:J,seal:{url:I,tenantSlug:Q.seal.tenantSlug??Q.source.tenantSlug,customHeaderNames:Q.seal.headers?Object.keys(Q.seal.headers):[],customCookieNames:Q.seal.cookies?Object.keys(Q.seal.cookies):[],endpoints:Q.seal.endpoints},source:kg1(Q.source),relations:{testCorpId:Q.testCorpId,prodCorpId:Q.prodCorpId},auth:{refreshTtl:Q.auth.refreshTtl}});return}if($==="current"){let U=T1(h(z.options.corp));x0({id:U.id,name:U.name,environment:U.environment??"production",sourceType:U.source.type,provider:U.source.provider??U.source.type,staffId:U.source.staffId,testCorpId:U.testCorpId,prodCorpId:U.prodCorpId});return}if($==="mark"||$==="mark-test"||$==="mark-prod"){let U=Y??h(z.options.corp);if(!U)throw m4("Usage: seal-use corps mark <corpId> --env <production|test> [--confirm]");let Q=T1(U),J=$==="mark-test"?"test":$==="mark-prod"?"production":h(z.options.env)??h(z.options.environment);if(J!=="production"&&J!=="test")throw m4("Usage: seal-use corps mark <corpId> --env <production|test> [--confirm]");if(!(Z0(z.options.confirm)===!0||Z0(z.options.yes)===!0))throw A5(`Refusing to change environment tag of enterprise '${Q.name}' (${Q.id}) to '${J}' without --confirm. Marking alters synchronization safety guards.`,`seal-use corps mark ${Q.id} --env ${J} --confirm`);let K=y3(Q.id,{environment:J});x0({id:K.id,name:K.name,environment:K.environment,testCorpId:K.testCorpId,prodCorpId:K.prodCorpId});return}if($==="rename"){let U=Y??h(z.options.corp)??h(z.options.id),Q=h(z.options.name)??h(z.options.to)??(z.command[3]&&!z.command[3].startsWith("-")?z.command[3]:void 0);if(!U||!Q)throw Error("Usage: seal-use corps rename <corpId> --name <newName>");let J=T1(U),I=y3(J.id,{name:Q});x0({success:!0,id:I.id,name:I.name,previousName:J.name});return}if($==="bind-test"){let U,Q;if(Y&&z.command[3])U=Y,Q=z.command[3];else if(Y){let X=h(z.options.corp),Z=h(z.options["test-corp"])??h(z.options.testCorp);if(X)U=X,Q=Y;else if(Z)U=Y,Q=Z}if(!U||!Q)throw m4(`Usage: seal-use corps bind-test <prodCorpId> <testCorpId> [--confirm] [--force]
or: seal-use corps bind-test <testCorpId> --corp <prodCorpId> [--confirm] [--force]`);let J=T1(U),I=T1(Q);if(J.id===I.id)throw m4(`Cannot bind enterprise '${J.id}' to itself.`);if(J.prodCorpId&&J.prodCorpId!==I.id)throw m4(`Cannot use '${J.id}' as a production enterprise because it is already registered as a test enterprise for '${J.prodCorpId}'. Multi-tier chaining is not permitted.`);if(I.testCorpId&&I.testCorpId!==J.id)throw m4(`Cannot bind '${I.id}' as a test enterprise because it already has a bound test enterprise '${I.testCorpId}'. Multi-tier chaining is not permitted.`);let K=Z0(z.options.force)===!0;if(J.testCorpId&&J.testCorpId!==I.id||I.prodCorpId&&I.prodCorpId!==J.id){if(!K)throw A5(`Enterprise binding conflict: production enterprise '${J.id}' is bound to '${J.testCorpId??"none"}', and test enterprise '${I.id}' is bound to '${I.prodCorpId??"none"}'. Overwriting an existing binding requires --force and --confirm.`,`seal-use corps bind-test ${J.id} ${I.id} --confirm --force`)}if(!(Z0(z.options.confirm)===!0||Z0(z.options.yes)===!0)){let X=K?" --force":"";throw A5(`Refusing to bind test enterprise '${I.name}' (${I.id}) to production enterprise '${J.name}' (${J.id}) without --confirm. Enterprise binding establishes 1-to-1 sync pairing and marks '${I.id}' as a test environment.`,`seal-use corps bind-test ${J.id} ${I.id} --confirm${X}`)}if(J.testCorpId&&J.testCorpId!==I.id)try{y3(J.testCorpId,{prodCorpId:void 0})}catch{}if(I.prodCorpId&&I.prodCorpId!==J.id)try{y3(I.prodCorpId,{testCorpId:void 0})}catch{}let H=y3(J.id,{environment:"production",testCorpId:I.id}),W=y3(I.id,{environment:"test",prodCorpId:J.id});x0({success:!0,productionEnterprise:{id:H.id,name:H.name,environment:H.environment,testCorpId:H.testCorpId},testEnterprise:{id:W.id,name:W.name,environment:W.environment,prodCorpId:W.prodCorpId}});return}if($==="unbind-test"){let U=Y??h(z.options.corp),Q=T1(U);if(!Q.testCorpId&&!Q.prodCorpId){x0({unbound:!1,message:`Enterprise '${Q.name}' (${Q.id}) does not have an active test enterprise binding.`});return}let J=Q.testCorpId?Q.id:Q.prodCorpId,I=Q.testCorpId?Q.testCorpId:Q.id;if(!(Z0(z.options.confirm)===!0||Z0(z.options.yes)===!0))throw A5(`Refusing to unbind production enterprise '${J}' and test enterprise '${I}' without --confirm.`,`seal-use corps unbind-test ${Q.id} --confirm`);y3(J,{testCorpId:void 0});try{y3(I,{prodCorpId:void 0})}catch{}x0({success:!0,unboundProduction:J,unboundTest:I});return}if($==="sync-test"){let U=Y??h(z.options.corp),Q=T1(U);if(!Q.testCorpId)throw m4(`Production enterprise '${Q.name}' (${Q.id}) has no bound test enterprise.
Run 'seal-use corps bind-test ${Q.id} <testCorpId> --confirm' first to establish a verified 1-to-1 association.`);let J=T1(Q.testCorpId);if(J.environment!=="test")throw Error(`Target enterprise '${J.name}' (${J.id}) is marked as '${J.environment}', NOT 'test'. Aborting sync to protect non-test environments.`);let I=await P1(Q),K=await P1(J),[G,H,W,X,Z,q,V,F]=await Promise.all([o1(I,Q.seal.endpoints.approvalStylePreferences),o1(K,J.seal.endpoints.approvalStylePreferences),X6(I),X6(K),c8(I),c8(K),Ch0(I),Ch0(K)]),w=(V.articles||[]).filter((G0)=>!G0.isDeleted),O=(F.articles||[]).filter((G0)=>!G0.isDeleted),N=new Map(O.map((G0)=>[G0.title.trim(),G0])),M=[],D=[],P=new Set(w.map((G0)=>G0.title.trim()));for(let G0 of w){let f0=G0.title.trim(),e0=N.get(f0);if(!e0)M.push(G0);else{let s=e0.content!==G0.content,H0=(e0.purpose??"")!==(G0.purpose??""),F0=e0.enabled!==G0.enabled,b0=e0.contentType!==G0.contentType,i0=(e0.status??"")!==(G0.status??""),n0=JSON.stringify([...e0.scenarios??[]].sort())!==JSON.stringify([...G0.scenarios??[]].sort()),w1=JSON.stringify([...e0.tags??[]].sort())!==JSON.stringify([...G0.tags??[]].sort());if(s||H0||F0||b0||i0||n0||w1)D.push({testId:e0.id,prodDoc:G0,reasons:[...s?["content"]:[],...H0?["purpose"]:[],...F0?["enabled"]:[],...b0?["contentType"]:[],...i0?["status"]:[],...n0?["scenarios"]:[],...w1?["tags"]:[]]})}}let j=O.filter((G0)=>!P.has(G0.title.trim())),T=[...Z].sort((G0,f0)=>f0.versionNumber-G0.versionNumber)[0],C=T?.versionNumber,k=([...q].sort((G0,f0)=>f0.versionNumber-G0.versionNumber)[0]?.versionNumber??0)+1,S=Th0(Q.name,C,q),n=h(z.options["version-name"])??h(z.options.versionName)??Eh0(Q.name,C,S,k),U0={...H,tone:G.tone,language:G.language,detailLevel:G.detailLevel,outputFormat:G.outputFormat,examples:G.examples??[],prohibitedPhrases:G.prohibitedPhrases??[],customInstructions:G.customInstructions,decisionPreferences:G.decisionPreferences,thinkingDepthPreference:G.thinkingDepthPreference};if(Z0(z.options["dry-run"])===!0||Z0(z.options.dryRun)===!0){x0({dryRun:!0,source:{id:Q.id,name:Q.name,environment:Q.environment,latestPublishedVersion:T?{versionNumber:T.versionNumber,versionName:T.versionName}:null,documentsCount:w.length},target:{id:J.id,name:J.name,environment:J.environment},versionMappingPlan:{sourceProdVersionNumber:C??null,sourceProdVersionName:T?.versionName??null,targetTestExpectedVersionNumber:k,targetTestPublishVersionName:n,iteration:S},preferencesDiff:{decisionPreferences:{before:H.decisionPreferences,after:G.decisionPreferences},thinkingDepthPreference:{before:H.thinkingDepthPreference,after:G.thinkingDepthPreference}},rulesPlan:{sourceDraftRuleCount:W.rules.length,targetExistingDraftRuleCount:X.rules.length,toDeleteCount:X.rules.length,toCreateCount:W.rules.length,rulesToSync:W.rules.map((G0,f0)=>({index:f0+1,sourceRuleId:G0.id,sourceRuleCode:G0.code??f0+1,expectedTargetCode:`rule-${f0+1}`,description:G0.description,scope:G0.scope,strictness:G0.strictness}))},documentsPlan:{sourceDocumentCount:w.length,targetExistingDocumentCount:O.length,toCreateCount:M.length,toCreate:M.map((G0)=>({title:G0.title,purpose:G0.purpose,contentType:G0.contentType,scenarios:G0.scenarios})),toUpdateCount:D.length,toUpdate:D.map((G0)=>({targetDocumentId:G0.testId,title:G0.prodDoc.title,reasons:G0.reasons})),toDeleteCount:j.length,toDelete:j.map((G0)=>({targetDocumentId:G0.id,title:G0.title}))},publishingPlan:{targetCorpId:J.id,publishVersionName:n,publishTarget:"test"},hosecloudSyncPlan:(()=>{if(Q.source.type!=="hose")return{sourceType:Q.source.type,skipped:!0,reason:"prod source is not hose; no hosecloud credentials available"};let G0=(G.integrations??[]).filter((s)=>s.type==="hosecloud"),f0=new Set,e0=G0.filter((s)=>{let H0=s.corporationId??Q.id;if(f0.has(H0))return!1;return f0.add(H0),!0});return{sourceType:"hose",outboundName:yh0(Q.name),targetMode:"assisted",integrationsCount:e0.length,integrations:e0.map((s)=>({corporationId:s.corporationId,apiOrigin:s.apiOrigin,customApiUrl:s.customApiUrl}))}})(),productionGuarantees:{prodRulesStayDraft:!0,prodVersionPublished:!1}});return}if(!(Z0(z.options.yes)===!0||Z0(z.options.confirm)===!0))throw A5(`Refusing to overwrite test enterprise '${J.name}' (${J.id}) with preferences, ${W.rules.length} draft rules, and ${w.length} knowledge documents from production enterprise '${Q.name}' (${Q.id}) without --yes. This will replace test draft rules, synchronize knowledge documents, and publish a new version on the test enterprise.`,`seal-use corps sync-test ${Q.id} --yes`);await s5(K,U0,J.seal.endpoints.approvalStylePreferences);let t=[];for(let G0 of j)await Bw(K,G0.id),t.push({id:G0.id,title:G0.title});let e=[];for(let G0 of D)await Aw(K,G0.testId,{title:G0.prodDoc.title,purpose:G0.prodDoc.purpose,content:G0.prodDoc.content,contentType:G0.prodDoc.contentType,status:G0.prodDoc.status,enabled:G0.prodDoc.enabled,scenarios:G0.prodDoc.scenarios&&G0.prodDoc.scenarios.length>0?G0.prodDoc.scenarios:["audit"],tags:G0.prodDoc.tags}),e.push({id:G0.testId,title Line truncated
Run 'seal-use corps bind-test ${Q.id} <testCorpId> --confirm' first to establish a verified 1-to-1 association,
or add '--force' (or use 'seal-use webhook replay <recordId> --force') if you explicitly intend to replay directly within production.`);G=Q}else if(G=T1(Q.testCorpId),G.environment!=="test"&&!J)throw Error(`Target enterprise '${G.name}' (${G.id}) is marked as '${G.environment}', NOT 'test'. Aborting replay to protect non-test environments (use --force to override).`);if(!I&&!K)throw A5("Refusing to replay approval records without --confirm. Use --dry-run to preview the payload without sending it.",`seal-use corps replay-test ${U??"<prodCorpId>"} --confirm`);let H=h(z.options.recordId)??h(z.options["record-id"])??h(z.options.id),W=h(z.options.recordIds)??h(z.options["record-ids"]),X=W?W.split(",").map((S)=>S.trim()).filter(Boolean):void 0,Z=h(z.options.sn)??h(z.options.documentSn)??h(z.options["document-sn"]),q=h(z.options.sns)??h(z.options["document-sns"]),V=q?q.split(",").map((S)=>S.trim()).filter(Boolean):void 0,F=s0(z.options.limit)??(!H&&!X&&!Z&&!V?1:void 0),w=h(z.options.status),O=h(z.options.startDate)??h(z.options["start-date"]),N=h(z.options.endDate)??h(z.options["end-date"]),M=await P1(Q),D=Q.id===G.id?M:await P1(G),P=h(z.options.webhook)??h(z.options.selector),j=h(z.options.snSuffix)??h(z.options["sn-suffix"]),A=h(z.options.snPrefix)??h(z.options["sn-prefix"]),T=h(z.options.docIdSuffix)??h(z.options["doc-id-suffix"]),C=h(z.options.docIdPrefix)??h(z.options["doc-id-prefix"]),b={recordId:H,recordIds:X,sn:Z,sns:V,limit:F,status:w,startDate:O,endDate:N};console.error(`[corps-replay-test] 正式企业「${Q.name}」(${Q.id}) -> 测试企业「${G.name}」(${G.id})`);let k=await zK({query:b,sourceClient:M,targetClient:D,sourceCorp:Q,targetCorp:G,webhookSelector:P,snPrefix:A,snSuffix:j,docIdPrefix:C,docIdSuffix:T,dryRun:I});if(I){console.error(`[corps-replay-test] 预览模式:已成功从 ${Q.name} 提取单据并转换为 Webhook Payload(未实际推送)。`),console.log(JSON.stringify(k,null,2));return}if(k.success)if(k.totalCount===1&&k.replayedDocument)console.error(`\uD83D\uDFE2 成功重放单据「${k.replayedDocument.documentSN}」至 ${G.name} (${k.targetWebhook?.name??"Webhook 通道"})`);else console.error(`\uD83D\uDFE2 成功重放 ${k.successCount} 条单据(来自「${Q.name}」)至「${G.name}」(${k.targetWebhook?.name??"Webhook 通道"})`);else console.error(`\uD83D\uDD34 单据重放部分或全部失败(成功 ${k.successCount} 条,失败 ${k.failureCount} 条)至「${G.name}」`);if(console.error(`\uD83D\uDC49 Next action: seal-use approval-runs list --corp ${G.id} --limit ${k.totalCount}`),console.log(JSON.stringify(k,null,2)),!k.success)throw new L4(`Approval record replay failed: ${k.failureCount} record(s) failed.`,1);return}if($==="switch"){let U=Y;if(!U)throw Error("Usage: seal-use corps switch <corpId>");let Q=v4();if(!Q.stateful)throw Error("Cannot switch the default enterprise while stateless mode is enabled. Use `seal-use config mode stateful` first.");let J=T1(U);qU({...Q,stateful:!0,defaultCorpId:J.id}),x0({current:!0,id:J.id,name:J.name});return}if($==="probe-hose"){await fg1(k8(z.json));return}if($==="hose-staffs"){await ug1(k8(z.json));return}if($==="add-hose"){let Q={...k8(z.json),...z.options.staffName?{staffName:h(z.options.staffName)}:{},...z.options["staff-name"]?{staffName:h(z.options["staff-name"])}:{},...z.options.staffPhone?{staffPhone:h(z.options.staffPhone)}:{},...z.options["staff-phone"]?{staffPhone:h(z.options["staff-phone"])}:{},...z.options.name?{name:h(z.options.name)}:{},...z.options.domain?{domain:h(z.options.domain)}:{},...z.options.corpId?{corpId:h(z.options.corpId)}:{},...z.options["corp-id"]?{corpId:h(z.options["corp-id"])}:{},...z.options.appKey?{appKey:h(z.options.appKey)}:{},...z.options["app-key"]?{appKey:h(z.options["app-key"])}:{},...z.options.appSecurity?{appSecurity:h(z.options.appSecurity)}:{},...z.options["app-security"]?{appSecurity:h(z.options["app-security"])}:{},...z.options.force!==void 0?{force:Z0(z.options.force)}:{},...z.options.overwrite!==void 0?{overwrite:Z0(z.options.overwrite)}:{}};await Go(Q);return}if($==="add-seal"){let Q={...k8(z.json),...z.options.name?{name:h(z.options.name)}:{},...z.options.token?{token:h(z.options.token)}:{},...z.options.sealUrl?{sealUrl:h(z.options.sealUrl)}:{},...z.options.url?{sealUrl:h(z.options.url)}:{},...z.options.force!==void 0?{force:Z0(z.options.force)}:{},...z.options.overwrite!==void 0?{overwrite:Z0(z.options.overwrite)}:{}};await bg1(Q);return}if($==="add-link"){let U=Y??h(z.options.link)??h(z.options.url);if(!U)throw Error("Usage: seal-use corps add-link <url> [--name <customName>] [--as-hose] [--overwrite]");let Q=Z0(z.options["dry-run"])===!0||Z0(z.options.dryRun)===!0;if(Z0(z.options["as-hose"])===!0||Z0(z.options.hose)===!0){if(ml(U)[0]?.kind==="seal-delegate")throw Error("Option --as-hose cannot be used with a Seal native delegate link. Seal delegate links directly authenticate to Seal.");await ng1(U,h(z.options.name),Z0(z.options.overwrite)===!0,Z0(z.options.force Line truncated
`);throw Error(`Missing required parameter: staffId. 当前企业共配置了 ${C.length} 位管理员账号(手机号已脱敏):
`+`${b}
`+`\uD83D\uDC49 请指定要作为审计身份绑定的管理员:
`+` • 按姓名选择:追加 --staffName <姓名>(支持关键字,如: --staffName 谢子豪)
`+` • 按手机选择:追加 --staffPhone <手机号>(支持手机后4位,如: --staffPhone 5678)
`+" • 或传 force:true / --force 自动使用默认首位管理员。")}else F=C.find((b)=>b.active)?.id??C[0]?.id}}if(!F)if(!W&&J)F=J;else throw Error("Missing required parameter: staffId (or proxyStaffBizId). Run 'seal-use corps hose-staffs' to discover available administrators.");let w=X4($,"id")??Z,O=Y??q??Z,N=X4($,"sealUrl")??`https://${Z.toLowerCase()}.sealai.cc`,M={id:w,name:O,environment:"production",seal:{url:N,endpoints:{approvalStylePreferences:"api/v1/agent/ai-approval/config"}},source:{type:"hose",domain:X,appKey:z,appSecurity:U,corpId:Z,staffId:F},auth:{refreshTtl:300}};if(W){Qw(w);let j=await iK(M);if((!Y||Y===Z)&&j.tenantName&&j.tenantName!==Z)O=j.tenantName,M.name=j.tenantName}let D=qp();_h0(D,{recursive:!0,mode:448});let P=hh0(D,`${Pj(w)}.json`);if(Rh0(P)&&$.overwrite!==!0)throw Error(`Enterprise config already exists: ${P}。如需覆盖已有配置,请在命令行追加 --overwrite 或在 JSON 参数中添加 "overwrite": true。`);vh0(P,`${JSON.stringify(M,null,2)}
`,{mode:384}),x0({id:w,name:O,corpId:Z,domain:X,staffId:F,verified:W,path:P})}async function bg1($){let Y=l3($,"token"),z=(X4($,"sealUrl")??X4($,"url")??"").replace(/\/+$/,"");if(!z)throw Error("Missing required JSON field: sealUrl");let U=kl($,"expiresIn")??2592000,Q=$.force===!0||$.verify===!1?!1:!0,J=kh0($),I=Q?await cg1(z,Y,A6(J)):void 0;Ko($,{token:Y,sealUrl:z,expiresIn:U,verify:Q,remote:I,custom:J})}function kh0($){return{headers:Gp.parse($.headers),cookies:Hp.parse($.cookies)}}async function ig1($,Y,z,U=!1){let J=ml($)[0];if(!J||J.score<50)throw Error(`Unrecognized assistance/delegate link. Expected either a Seal native delegate link (https://<tenant>.sealai.cc/delegate?token=...) or a Hose assistance link (https://<corp>.ekuaibao.com/web/thirdparty.html?accessToken=...&ekbCorpId=...). Top score: ${J?J.kind+"="+J.score:"none"}.`);if(J.kind==="seal-delegate"){if(U){let F=await zv0($),w=Rj($);x0({dryRun:!0,kind:"seal-delegate",sealUrl:w.sealUrl,tenant:{id:F.tenantId,name:F.tenantName},user:{id:F.userId,name:F.userName},delegationId:F.delegationId});return}console.error(`ℹ️ [Seal 委托链接] 识别为 Seal 原生委托链接 (${J.reason}),正在交换临时会话...`);let W=await Uv0($),X={user:W.user,tenant:W.tenant},Z=typeof W.tenant.tenantSlug==="string"&&W.tenant.tenantSlug||void 0,q=typeof W.tenant.id==="string"&&W.tenant.id||void 0,V=Z??q??"seal-delegate";Ko({id:V,corpId:V,name:Y,provider:"seal",overwrite:z},{token:W.token,sealUrl:W.sealUrl,expiresIn:W.expiresIn,verify:!0,remote:X});return}let I=await Jw($),K=y6(I.sealUrl,I.token),G=await T8(K),H={user:G.user,tenant:G.tenant};if(Iw(I.corpId,H.tenant),U){x0({dryRun:!0,kind:"hose",corpId:I.corpId,sealUrl:I.sealUrl,tenant:H.tenant,user:H.user});return}Ko({id:I.corpId,corpId:I.corpId,name:Y,provider:"hosecloud",overwrite:z},{token:I.token,sealUrl:I.sealUrl,expiresIn:I.expiresIn,verify:!0,remote:H})}function xh0($,Y,z,U){if($.length===0)throw Error(`[合思子域提权] 未能从协助链接中提取到合思企业 [${Y}] 的 OpenAPI 密钥凭据。
`+"\uD83D\uDCA1 说明:此能力专属于合思 (Hose) 子域,用于将临时会话提权为标准 OpenAPI 开发者接入。需要企业管理员已在合思开放平台创建应用并生成 appKey/appSecurity。");if(z.keyId||z.appKey){let Q=$.find((J)=>z.keyId&&J.id===z.keyId||z.appKey&&J.appKey===z.appKey);if(!Q){console.error(`
❌ 未找到指定的合思 OpenAPI 密钥 (${z.appKey??z.keyId})。`),console.error(`ℹ️ 该合思企业当前存在以下 ${$.length} 套候选密钥:`);for(let J of $){let I=J.active?"\uD83D\uDFE2 启用":"⚪ 停用";console.error(` • "${J.name||"未命名应用"}" (appKey: ${J.appKey}, keyId: ${J.id}, 状态: ${I})`)}throw new L4("指定的合思密钥不存在,请从上述候选列表中选择正确的 appKey 或 keyId。",2,`${U} --app-key ${$[0].appKey}`)}return Q}if($.length===1)return $[0];console.error(`
ℹ️ [合思子域提权] 合思企业 [${Y}] 存在多套 (${$.length} 套) OpenAPI 应用密钥凭据:`);for(let Q=0;Q<$.length;Q++){let J=$[Q],I=J.active?"\uD83D\uDFE2 启用":"⚪ 停用",K=J.name||"未命名应用";console.error(` [${Q+1}] "${K}" (appKey: ${J.appKey}, keyId: ${J.id}, 状态: ${I})`)}throw console.error(`
\uD83D\uDC49 为确保权限提权绑定正确的业务应用,请显式指定要使用的密钥套件:`),console.error(` 在命令后追加 --app-key <key> 或 --key-id <id> 参数。
`),new L4(`合思企业 [${Y}] 存在多套 OpenAPI 密钥,必须指定 --app-key 或 --key-id 明确选择要绑定的密钥。`,2,`${U} --app-key ${$[0].appKey}`)}async function ng1($,Y,z,U=!1,Q=!1,J){console.error("ℹ️ [合思子域提权] 正在通过合思协助链接提取 OpenAPI 开发者密钥并提升企业权限等级...");let I=await lS($),K=xh0(I.keys,I.corpId,J??{},'seal-use corps add-link "<url>" --as-hose');if(console.error(Q?`ℹ️ [合思子域提权] 已选定合思 OpenAPI 凭据 (appKey: ${K.appKey}, 应用: "${K.name||"未命名应用"}"),正在生成预览...`:`ℹ️ [合思子域提权] 已选定合思 OpenAPI 凭据 (appKey: ${K.appKey}, 应用: "${K.name||"未命名应用"}"),正在初始化为长期合思标准配置...`),Q){x0({dryRun:!0,kind:"hose",provider:"hose",corpId:I.corpId,corpName:I.corpName,baseUrl:I.baseUrl,staffId:I.staffId,selectedKey:{id:K.id,name:K.name||"-",appKey:K.appKey,appSecurity:Ww(K.appSecurity),active:K.active}});return}await Go({domain:I.baseUrl,appKey:K.appKey,appSecurity:K.appSecurity,corpId:I.corpId,name:Y??I.corpName,staffId:I.staffId,overwrite:z,force:U})}async function uj($,Y){let z=await lS($),U=Y.reveal===!0;if(Y.save){let Q=xh0(z.keys,z.corpId,{appKey:Y.appKey,keyId:Y.keyId},'seal-use corps hose-extract-keys "<url>" --save');console.error(`ℹ️ [合思子域提权] 正在将选定的合思 OpenAPI 密钥 (appKey: ${Q.appKey}, 应用: "${Q.name||"未命名应用"}") 保存为标准合思企业配置...`),await Go({domain:z.baseUrl,appKey:Q.appKey,appSecurity:Q.appSecurity,corpId:z.corpId,name:Y.name??z.corpName,staffId:z.staffId,overwrite:Y.overwrite,force:Y.force});return}if(!U)console.error(`ℹ️ [合思子域提权] 成功提取合思 (Hose) OpenAPI 密钥。接入密码默认脱敏,附加 --reveal (或 -r) 可查看完整 appSecurity 明文;附加 --save 可将临时会话提权并持久化为标准合思企业。
\uD83D\uDC49 为确保权限提权绑定正确的业务应用,请显式指定要使用的密钥套件:
在命令后追加 --app-key <key> 或 --key-id <id> 参数。
`,`${z} --app-key ${$[0].appKey}`)}async function Ev0($){let U=await Kg($.link),Y=jv0(U.keys,U.corpId,$,'seal-use corps add-link "<url>" --elevate-hose');if($.dryRun)return{result:U,selectedKey:Y,dryRun:!0};let z=await vq({domain:U.baseUrl,appKey:Y.appKey,appSecurity:Y.appSecurity,corpId:U.corpId,name:$.name??U.corpName,staffId:U.staffId,overwrite:$.overwrite,force:$.force});return{result:U,selectedKey:Y,saved:z,dryRun:!1}}async function Cv0($){let U=await Kg($.link);if(!$.save)return{result:U,reveal:$.reveal===!0};let Y=jv0(U.keys,U.corpId,$,'seal-use corps hose-extract-keys "<url>" --save'),z=await vq({domain:U.baseUrl,appKey:Y.appKey,appSecurity:Y.appSecurity,corpId:U.corpId,name:$.name??U.corpName,staffId:U.staffId,overwrite:$.overwrite,force:$.force});return{result:U,selectedKey:Y,saved:z,reveal:$.reveal===!0}}function Rv0($,U){return{id:$.id,name:$.name||"-",appKey:$.appKey,appSecurity:U?$.appSecurity:_H($.appSecurity),active:$.active,createTime:$.createTime,updateTime:$.updateTime}}var bz;var _v0=m(()=>{E$();bT();bz=class bz extends Error{nextAction;constructor($,U){super($);this.name="HoseKeySelectionError",this.nextAction=U}}});function vv0($){if(!$)return;if($.length<=8)return"****";return`${$.slice(0,4)}...${$.slice(-4)}`}function hv0($){if($.source.type==="hose")return y7($,$.source);return $.seal.url??$.source.sealUrl}function Sv0($){if($.type==="hose"){let U=$.appKey??$.key;return{type:"hose",provider:$.provider??"hosecloud",domain:$.domain,corpId:$.corpId,staffId:$.staffId,appKey:vv0(U),hasAppSecurity:Boolean($.appSecurity??$.password),hasCloseToken:Boolean($.closeToken),closeTokenExpiresIn:$.closeToken?$.expiresIn:void 0,closeTokenExpiresAt:$.closeToken?$.expiresAt:void 0,credentialMode:$.closeToken?"web-session":"persistent",sealUrl:$.sealUrl}}if($.type==="seal")return{type:"seal",provider:$.provider??"seal",tenantId:$.tenantId,tenantSlug:$.tenantSlug,tenantName:$.tenantName,providerUserId:$.providerUserId,staffId:$.staffId,corpId:$.corpId,sealUrl:$.sealUrl,hasToken:Boolean($.token),tokenMasked:vv0($.token),expiresIn:$.expiresIn,expiresAt:$.expiresAt};throw Error(`Unsupported enterprise source type: ${$.type}`)}function Ko($){if(!$)return"未绑定手机";let U=$.trim();if(U.length===11)return`${U.slice(0,3)}****${U.slice(7)}`;if(U.length>=7)return`${U.slice(0,3)}****${U.slice(-4)}`;if(U.length>4)return`${U.slice(0,2)}****${U.slice(-2)}`;return U}var iT=m(()=>{E$()});async function gv0($,U,Y){if($==="probe-hose"){let z=B8(Y.json),I=await Av0({appKey:o3(z,"appKey"),appSecurity:o3(z,"appSecurity"),domain:v6(z,"domain")});return R0({domain:I.domain,corpId:I.corpId,name:I.corpName??I.corpId,roleCount:I.roleCount,roleGroups:I.roleGroups}),!0}if($==="hose-staffs"){let z=B8(Y.json),I=await Bv0({appKey:o3(z,"appKey"),appSecurity:o3(z,"appSecurity"),domain:v6(z,"domain"),role:v6(z,"role"),roleDefId:v6(z,"roleDefId")});return R0({domain:I.domain,corpId:I.corpId,corpName:I.corpName,roleId:I.roleId,roleName:I.roleName,count:I.staffs.length,staffs:I.staffs.map((Q)=>({id:Q.id,name:Q.name,cellphone:Ko(Q.cellphone),active:Q.active,authState:Q.authState,userId:Q.userId,email:Q.email}))}),!0}if($==="add-hose-persistent"||$==="add-hose"){if($==="add-hose")console.error("⚠️ Notice: 'add-hose' is a compatibility alias; use 'add-hose-persistent' for durable Hose credentials.");let I={...B8(Y.json),...Y.options.staffName?{staffName:S(Y.options.staffName)}:{},...Y.options["staff-name"]?{staffName:S(Y.options["staff-name"])}:{},...Y.options.staffPhone?{staffPhone:S(Y.options.staffPhone)}:{},...Y.options["staff-phone"]?{staffPhone:S(Y.options["staff-phone"])}:{},...Y.options.name?{name:S(Y.options.name)}:{},...Y.options.domain?{domain:S(Y.options.domain)}:{},...Y.options.corpId?{corpId:S(Y.options.corpId)}:{},...Y.options["corp-id"]?{corpId:S(Y.options["corp-id"])}:{},...Y.options.appKey?{appKey:S(Y.options.appKey)}:{},...Y.options["app-key"]?{appKey:S(Y.options["app-key"])}:{},...Y.options.appSecurity?{appSecurity:S(Y.options.appSecurity)}:{},...Y.options["app-security"]?{appSecurity:S(Y.options["app-security"])}:{},...Y.options.force!==void 0?{force:G0(Y.options.force)}:{},...Y.options.overwrite!==void 0?{overwrite:G0(Y.options.overwrite)}:{}},Q=await vq({...I,appKey:o3(I,"appKey"),appSecurity:o3(I,"appSecurity")});return R0({id:Q.config.id,name:Q.config.name,corpId:Q.config.source.type==="hose"?Q.config.source.corpId:void 0,domain:Q.domain,staffId:Q.staffId,verified:Q.verified,path:Q.path}),!0}if($==="add-hose-web-session"){let I={...B8(Y.json),...Y.options.name?{name:S(Y.options.name)}:{},...Y.options.domain?{baseUrl:S(Y.options.domain)}:{},...Y.options["base-url"]?{baseUrl:S(Y.options["base-url"])}:{},...Y.options.corpId?{corpId:S(Y.options.corpId)}:{},...Y.options["corp-id"]?{corpId:S(Y.options["corp-id"])}:{},...Y.options.staffId?{staffId:S(Y.options.staffId)}:{},...Y.options["staff-id"]?{staffId:S(Y.options["staff-id"])}:{},...Y.options.accessToken?{accessToken:S(Y.options.accessToken)}:{},...Y.options[ Line truncated
`);else console.error(`⚠️ [合思子域提权] 正在以明文展示合思 (Hose) appSecurity 接入密码,请妥善保管敏感凭据。
`);x0({provider:"hose",capability:"privilege-elevation",corpId:z.corpId,corpName:z.corpName??z.corpId,baseUrl:z.baseUrl,staffId:z.staffId,keyCount:z.keys.length,keys:z.keys.map((Q)=>({id:Q.id,name:Q.name||"-",appKey:Q.appKey,appSecurity:U?Q.appSecurity:Ww(Q.appSecurity),active:Q.active,createTime:Q.createTime,updateTime:Q.updateTime}))})}async function Ho($,Y){let z=T1($),U=Y.reveal===!0;if(z.source.type!=="hose")throw new L4(`【合思子域专享能力】当前企业「${z.name}」(id: ${z.id}) 为原生 Seal (${z.source.type}) 租户,非合思 (Hose/合思云/易快报) 渠道企业。
`+"OpenAPI 密钥查询与提权能力专属于合思生态租户(用于从合思协助链接或合思凭据中提取开发者密钥提升权限等级),非合思渠道企业不支持此能力。",2);let Q=z.source.appKey??z.source.key,J=z.source.appSecurity??z.source.password;if(!U)console.error(`\uD83D\uDCA1 [合思子域] 接入密码默认脱敏,附加 --reveal (或 -r) 可查看完整 appSecurity 明文。
`);R0({provider:"hose",capability:"privilege-elevation",corpId:z.corpId,corpName:z.corpName??z.corpId,baseUrl:z.baseUrl,staffId:z.staffId,keyCount:z.keys.length,keys:z.keys.map((Q)=>Rv0(Q,I))})}async function nT($,U){let Y=M1($),z=U.reveal===!0;if(Y.source.type!=="hose")throw new W4(`【合思子域专享能力】当前企业「${Y.name}」(id: ${Y.id}) 为原生 Seal (${Y.source.type}) 租户,非合思 (Hose/合思云/易快报) 渠道企业。
`+"OpenAPI 密钥查询与提权能力专属于合思生态租户(用于从合思协助链接或合思凭据中提取开发者密钥提升权限等级),非合思渠道企业不支持此能力。",2);let I=Y.source.appKey??Y.source.key,Q=Y.source.appSecurity??Y.source.password;if(!z)console.error(`\uD83D\uDCA1 [合思子域] 接入密码默认脱敏,附加 --reveal (或 -r) 可查看完整 appSecurity 明文。
`);else console.error(`⚠️ [合思子域] 正在以明文展示合思 appSecurity 接入密码,请妥善保管敏感凭据。
`);x0({provider:"hose",capability:"privilege-elevation",corpId:z.id,corpName:z.name,domain:z.source.domain,staffId:z.source.staffId,appKey:Q??"-",appSecurity:J?U?J:Ww(J):"-",active:!0})}function Ko($,Y){let{token:z,sealUrl:U,expiresIn:Q,verify:J,remote:I}=Y,K=Y.custom??kh0($),G=I?.user,H=I?.tenant,W=X4($,"tenantSlug")??e2(H?.tenantSlug),X=X4($,"tenantId")??e2(H?.id),Z=X4($,"tenantName")??e2(H?.name),q=X4($,"id")??W??X;if(!q)throw Error("Missing required JSON field: id. Seal whoami did not return tenantSlug or tenantId.");let V=X4($,"staffId")??e2(G?.providerUserId)??e2(G?.id)??"seal",F=X4($,"provider")??e2(G?.provider)??e2(H?.providerConfig?.provider),w=X4($,"corpId")??W??X??q,O={id:q,name:X4($,"name")??Z??q,environment:"production",seal:{url:U,tenantSlug:W,headers:K.headers,cookies:K.cookies,endpoints:{approvalStylePreferences:"api/v1/agent/ai-approval/config"}},source:{type:"seal",token:z,sealUrl:U,expiresIn:Q,staffId:V,corpId:w,tenantId:X,tenantSlug:W,tenantName:Z,providerUserId:e2(G?.providerUserId),provider:F},auth:{refreshTtl:300}},N=qp();_h0(N,{recursive:!0,mode:448});let M=hh0(N,`${Pj(q)}.json`);if(Rh0(M)&&$.overwrite!==!0)throw Error(`Enterprise config already exists: ${M}. Pass "overwrite": true to replace it.`);vh0(M,`${JSON.stringify(O,null,2)}
`,{mode:384}),x0({id:q,name:O.name,tenantId:X,tenantSlug:W,verified:J,path:M})}async function cg1($,Y,z={}){let U=y6($,Y,z),Q=await T8(U);return{user:Q.user??{},tenant:Q.tenant??{}}}function e2($){return typeof $==="string"&&$?$:void 0}var Wo=m(()=>{g7();Qv0();CH();i8();k3();Nh0();rB();Xp();B6();B6();Jo();Np();fZ();fj();f4();F$();A4();K4()});var bh0={};D8(bh0,{handleAuthExtractKeysCommand:()=>qo,handleAuthCommand:()=>ij,formatBeijingIso:()=>Zo});async function qo($,Y){let z=$??h(Y.options.link)??h(Y.options.url);if(!z)throw Error("Usage: seal-use auth hose-extract-keys <https://.../web/thirdparty.html?...> [--reveal] [--save] [--name <customName>] [--overwrite]");let U=Z0(Y.options.reveal)===!0||Z0(Y.options.r)===!0||Z0(Y.options.plain)===!0,Q=Z0(Y.options.save)===!0||Z0(Y.options.add)===!0;await uj(z,{reveal:U,save:Q,name:h(Y.options.name),overwrite:Z0(Y.options.overwrite)===!0,force:Z0(Y.options.force)===!0,appKey:h(Y.options["app-key"])??h(Y.options.appKey),keyId:h(Y.options["key-id"])??h(Y.options.keyId)})}async function ij($,Y,z){if($==="check"||$==="diagnose"||$==="status"||$==="test"||$==="doctor"){x0(await pg1(Y));return}if($==="seal-link"||$==="link"||$==="hose-link"&&Y?.source?.type==="seal"){let U=z.command[2]?.toLowerCase(),Q=h(z.options["from-link"])??(U==="from-link"?z.command[3]:void 0);if(Q){let X=h(z.options.note),Z=await Jw(Q),q=y6(Z.sealUrl,Z.token),V=await T8(q);Iw(Z.corpId,V.tenant);let F=await aQ(q,{note:X});x0({tenant:{id:V.tenant.id,name:V.tenant.name,tenantSlug:V.tenant.tenantSlug,corpId:Z.corpId},user:{id:V.user.id,name:V.user.name,providerUserId:V.user.providerUserId,isAdmin:V.user.isAdmin},delegation:F,expiresIn:Z.expiresIn});return}let J=await P1(Y);if(U==="list"){await k0("seal_delegation_list",J,Y,{},E0(z.options));return}if(U==="revoke"){let X=z.command[3]??h(z.options.tokenId)??h(z.options.id);if(!X)throw Error("Usage: seal-use auth link revoke <tokenId>");await k0("seal_delegation_revoke",J,Y,{tokenId:X},E0(z.options));return}let I=h(z.options.note)??"CLI generated provisional access link",K=await O$("seal_delegation_create",J,Y,{note:I});if($==="hose-link")console.error(`\uD83D\uDC49 提示: 企业「${Y.name}」源类型为 Seal 原生测试环境,已自动为您生成委托免登直达链接。`);let G=K,H="staffName"in Y.source&&typeof Y.source.staffName==="string"?Y.source.staffName:void 0,W=Zo(Date.now()+86400000);x0({id:G.id,corpId:Y.source.corpId??Y.id,corpName:Y.name,staffId:Y.source.staffId,...H?{staffName:H}:{},link:G.link,expiresAt:W,token:G.token});return}if($==="hose-link"){let U=z.options.expire,Q=U!==void 0?s0(U):7200;if(Q===void 0||Q<=0)throw Error(`Invalid --expire: ${String(U)}. Must be a positive number of seconds (e.g. --expire 7200 or --expire 86400).`);let J=Z0(z.options.force)===!0||Z0(z.options.refresh)===!0||Z0(z.options.f)===!0,I=await m00(Y,Q,{force:J}),K="staffName"in Y.source&&typeof Y.source.staffName==="string"?Y.source.staffName:void 0,G=Zo(Date.now()+Q*1000);x0({corpId:Y.source.corpId??Y.id,corpName:Y.name,staffId:Y.source.staffId,...K?{staffName:K}:{},link:I.url,expiresAt:G,token:I.token});return}if($==="keys"||$==="hose-keys"){let U=Z0(z.options.reveal)===!0||Z0(z.options.r)===!0||Z0(z.options.plain)===!0;await Ho(Y.id,{reveal:U});return}throw Error(`Unknown auth command: ${$??""}. Run 'seal-use help' for available commands.`)}async function pg1($){if($.source.type!=="hose"){let F=await P1($),w=await T8(F);return{corp:{id:$.id,name:$.name,sourceType:$.source.type},ok:!0,stages:[{name:"seal.whoami",ok:!0,user:w.user,tenant:w.tenant}]}}Qw($.id);let Y=$.source,z=Y.appKey??Y.key,U=Y.appSecurity??Y.password,Q=($.seal.url??Y.sealUrl??`https://${Y.corpId.toLowerCase()}.sealai.cc`).replace(/\/+$/,""),J=Y.staffId.includes(":")?Y.staffId:`${Y.corpId}:${Y.staffId}`,I=[];if(!z||!U)return{corp:{id:$.id,name:$.name,sourceType:$.source.type},ok:!1,stages:[{name:"hose.openapi",ok:!1,error:"Hose source requires appKey/key and appSecurity/password"}]};let K=await bj("hose.openapi",async()=>{let F=await fh0(`${Y.domain.replace(/\/+$/,"")}/api/openapi/v1/auth/getAccessToken`,{appKey:z,appSecurity:U}),w=o3(F.value),O=n6(w.accessToken)??n6(F.accessToken)??n6(F.token);if(!O)throw Error("Hose login did not return an access token");return{token:O,public:{corporationId:n6(w.corporationId)??n6(o3(w.corporation).id),expireTime:vq(w.expireTime)}}});I.push(K.public);let G=K.private?.token,H=G?await bj("hose.provisional",async()=>{let F=await fh0(`${Y.domain.replace(/\/+$/,"")}/api/openapi/v1.1/provisional/getProvisionalAuth?accessToken=${encodeURIComponent(G)}`,{uid:J,pageType:"home",expireDate:7200}),w=n6(o3(F.value).message);if(!w)throw Error("Hose CloseAPI did not return a provisional auth URL");let O=new URL(w).searchParams.get("accessToken");if(!O)throw Error("Hose provisional auth URL did not include accessToken");return{token:O,public:{uid:J,enterpriseUrl:Tq(w)}}}):Xo("hose.provisional");I.push(H.public);let W=A6($.seal),X=H.private?.token,Z=X?await bj("seal Line truncated
`);R0({provider:"hose",capability:"privilege-elevation",corpId:Y.id,corpName:Y.name,domain:Y.source.domain,staffId:Y.source.staffId,appKey:I??"-",appSecurity:Q?z?Q:_H(Q):"-",active:!0})}var yv0=m(()=>{E$();zo();Jo();Tv0();bT();_v0();O8();O4();Z4();m1();iT()});var xv0,fv0,cT,kv0,o4;var U5=m(()=>{xv0=/^[\uD800-\uDBFF]$/,fv0=/^[\uDC00-\uDFFF]$/,cT=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;(function($){$[$.Unknown=0.0000000000001]="Unknown",$[$.Rule=0.000000000001]="Rule",$[$.DICT=0.00000002]="DICT",$[$.Surname=1]="Surname",$[$.Custom=1]="Custom"})(kv0||(kv0={}));o4={Normal:1,Surname:10,Custom:100}});function e2($){var U;return $.length-(((U=$.match(cT))===null||U===void 0?void 0:U.length)||0)}function O$($){if(cT.lastIndex=0,!cT.test($))return $.split("");let U=[],Y=0;while(Y<$.length){let z=$[Y];if(xv0.test(z)&&fv0.test($[Y+1]))U.push($.substring(Y,Y+2)),Y+=2;else U.push(z),Y+=1}return U}class iK{constructor(){this.NumberDICT=[],this.StringDICT=new Map}get($){if($.length>1)return this.StringDICT.get($);else{let U=$.charCodeAt(0);return this.NumberDICT[U]}}set($,U){if($.length>1)this.StringDICT.set($,U);else{let Y=$.charCodeAt(0);this.NumberDICT[Y]=U}}clear(){this.NumberDICT=[],this.StringDICT.clear()}}var k9=m(()=>{U5()});function pg1(){let $={零一:"líng yī",〇一:"líng yī",十一:"shí yī",一十:"yī shí",第一:"dì yī",一十一:"yī shí yī"};for(let U in uv0)for(let Y in bv0){let z=`${U}${Y}`,I=`${uv0[U]} ${bv0[Y]}`;$[z]=I}return $}var nv0,cv0,dv0,pv0,mv0,uv0,bv0,iv0,lv0,Go,ov0,rv0;var Ho=m(()=>{U5();k9();nv0=["zh","ch","sh","z","c","s","b","p","m","f","d","t","n","l","g","k","h","j","q","x","r","y","w",""],cv0=["j","q","x"],dv0=["uān","uán","uǎn","uàn","uan","uē","ué","uě","uè","ue","ūn","ún","ǔn","ùn","un","ū","ú","ǔ","ù","u"],pv0={uān:"üān",uán:"üán",uǎn:"üǎn",uàn:"üàn",uan:"üan",uē:"üē",ué:"üé",uě:"üě",uè:"üè",ue:"üe",ūn:"ǖn",ún:"ǘn",ǔn:"ǚn",ùn:"ǜn",un:"ün",ū:"ǖ",ú:"ǘ",ǔ:"ǚ",ù:"ǜ",u:"ü"},mv0=["ia","ian","iang","iao","ie","iu","iong","ua","uai","uan","uang","ue","ui","uo","üan","üe","van","ve"],uv0={一:"yì",二:"èr",三:"sān",四:"sì",五:"wǔ",六:"liù",七:"qī",八:"bā",九:"jiǔ",十:"shí",百:"bǎi",千:"qiān",万:"wàn",亿:"yì",单:"dān",两:"liǎng",双:"shuāng",多:"duō",几:"jǐ",十一:"shí yī",零一:"líng yī",第一:"dì yī",一十:"yī shí",一十一:"yī shí yī"},bv0={重:"chóng",行:"háng",斗:"dǒu",更:"gēng"};iv0=pg1(),lv0=Object.keys(iv0).map(($)=>({zh:$,pinyin:iv0[$],probability:0.000000000001,length:e2($),priority:o4.Normal,dict:Symbol("rule")})),Go={不:{bú:[4]},一:{yí:[4],yì:[1,2,3]}},ov0={不:["的","而","之","后","也","还","地"],一:["的","而","之","后","也","还","是"]},rv0=Object.keys(Go)});var sv0,_5;var dT=m(()=>{k9();sv0={"bǎng páng pāng":["膀"],líng:["〇","伶","凌","刢","囹","坽","夌","姈","婈","孁","岺","彾","掕","昤","朎","柃","棂","櫺","欞","泠","淩","澪","灵","燯","爧","狑","玲","琌","瓴","皊","砱","祾","秢","竛","笭","紷","綾","绫","羐","羚","翎","聆","舲","苓","菱","蓤","蔆","蕶","蛉","衑","裬","詅","跉","軨","輘","酃","醽","鈴","錂","铃","閝","陵","零","霊","霗","霛","霝","靈","駖","魿","鯪","鲮","鴒","鸰","鹷","麢","齡","齢","龄","龗","㥄"],yī:["一","乊","伊","依","医","吚","咿","噫","壱","壹","夁","嫛","嬄","弌","揖","撎","檹","毉","洢","渏","漪","瑿","畩","祎","禕","稦","繄","蛜","衤","譩","辷","郼","醫","銥","铱","鷖","鹥","黟","黳"],"dīng zhēng":["丁"],"kǎo qiǎo yú":["丂"],qī:["七","倛","僛","凄","嘁","墄","娸","悽","慼","慽","戚","捿","柒","桤","桼","棲","榿","欺","沏","淒","漆","紪","緀","萋","褄","諆","迉","郪","鏚","霋","魌","鶈"],shàng:["丄","尙","尚","恦","緔","绱"],xià:["丅","下","乤","圷","夏","夓","懗","梺","疜","睱","罅","鎼","鏬"],hǎn:["丆","喊","浫","罕","豃","㘎"],"wàn mò":["万"],zhàng:["丈","仗","墇","嶂","帐","帳","幛","扙","杖","涱","痮","瘬","瘴","瞕","粀","胀","脹","賬","账","障"],sān:["三","厁","叁","弎","毵","毶","毿","犙","鬖"],"shàng shǎng shang":["上"],"qí jī":["丌","其","奇"],"bù fǒu":["不"],"yǔ yù yú":["与"],miǎn:["丏","偭","免","冕","勉","勔","喕","娩","愐","汅","沔","湎","睌","緬","缅","腼","葂","靦","鮸","\uD867\uDF83"],gài:["丐","乢","匃","匄","戤","概","槩","槪","溉","漑","瓂","葢","鈣","钙","\uD872\uDFBF"],chǒu:["丑","丒","侴","吜","杽","瞅","矁","醜","魗"],zhuān:["专","叀","嫥","専","專","瑼","甎","砖","磗","磚","蟤","諯","鄟","顓","颛","鱄","䏝"],"qiě jū":["且"],pī:["丕","伓","伾","噼","坯","岯","憵","批","披","炋","狉","狓","砒","磇","礔","礕","秛","秠","耚","豾","邳","鈚","鉟","銔","錃","錍","霹","駓","髬","魾","\uD873\uDCF5"],shì:["世","丗","亊","事","仕","侍","冟","势","勢" Line truncated
`+`\uD83D\uDC49 查看全部请添加: seal-use corps list --all
`+"\uD83D\uDC49 检索指定企业请使用: seal-use corps search <keyword>")}return R0(w.map((N)=>({id:N.id,name:N.name,environment:N.environment??"production",sourceType:N.source.type,provider:N.source.provider??N.source.type,staffId:N.source.staffId,testCorpId:N.testCorpId,prodCorpId:N.prodCorpId,current:N.id===H}))),!0}if($==="get"||$==="show"){let z=U??S(Y.options.corp);if(!z)throw h4("Usage: seal-use corps get <corpId>");let I=M1(z),Q=Td(I.id),J=hv0(I);return R0({id:I.id,name:I.name,environment:I.environment??"production",configFile:Q,seal:{url:J,tenantSlug:I.seal.tenantSlug??I.source.tenantSlug,customHeaderNames:I.seal.headers?Object.keys(I.seal.headers):[],customCookieNames:I.seal.cookies?Object.keys(I.seal.cookies):[],endpoints:I.seal.endpoints},source:Sv0(I.source),relations:{testCorpId:I.testCorpId,prodCorpId:I.prodCorpId},auth:{refreshTtl:I.auth.refreshTtl}}),!0}if($==="current"){let z=M1(S(Y.options.corp));return R0({id:z.id,name:z.name,environment:z.environment??"production",sourceType:z.source.type,provider:z.source.provider??z.source.type,staffId:z.source.staffId,testCorpId:z.testCorpId,prodCorpId:z.prodCorpId}),!0}if($==="mark"||$==="mark-test"||$==="mark-prod"){let z=U??S(Y.options.corp);if(!z)throw h4("Usage: seal-use corps mark <corpId> --env <production|test> [--confirm]");let I=M1(z),Q=$==="mark-test"?"test":$==="mark-prod"?"production":S(Y.options.env)??S(Y.options.environment);if(Q!=="production"&&Q!=="test")throw h4("Usage: seal-use corps mark <corpId> --env <production|test> [--confirm]");if(!(G0(Y.options.confirm)===!0||G0(Y.options.yes)===!0))throw F$(`Refusing to change environment tag of enterprise '${I.name}' (${I.id}) to '${Q}' without --confirm. Marking alters synchronization safety guards.`,`seal-use corps mark ${I.id} --env ${Q} --confirm`);let K=E9(I.id,{environment:Q});return R0({id:K.id,name:K.name,environment:K.environment,testCorpId:K.testCorpId,prodCorpId:K.prodCorpId}),!0}if($==="rename"){let z=U??S(Y.options.corp)??S(Y.options.id),I=S(Y.options.name)??S(Y.options.to)??(Y.command[3]&&!Y.command[3].startsWith("-")?Y.command[3]:void 0);if(!z||!I)throw Error("Usage: seal-use corps rename <corpId> --name <newName>");let Q=M1(z),J=E9(Q.id,{name:I});return R0({success:!0,id:J.id,name:J.name,previousName:Q.name}),!0}if($==="switch"){let z=U;if(!z)throw Error("Usage: seal-use corps switch <corpId>");let I=v4();if(!I.stateful)throw Error("Cannot switch the default enterprise while stateless mode is enabled. Use `seal-use config mode stateful` first.");let Q=M1(z);return qz({...I,stateful:!0,defaultCorpId:Q.id}),R0({current:!0,id:Q.id,name:Q.name}),!0}return!1}var eh0=m(()=>{T5();ah0();YP();O4();O8();Z4();m1();iT()});import{existsSync as Vy1,mkdirSync as Ly1,readFileSync as wy1,writeFileSync as $S0}from"node:fs";import{homedir as Fy1}from"node:os";import{join as sT}from"node:path";function US0(){let $=process.env.SEAL_USE_MAPPINGS_DIR?.trim();if($)return $;return sT(Fy1(),".config","seal-use","mappings")}function YS0($){let U=US0();Ly1(U,{recursive:!0,mode:448});let Y=sT(U,`${$.target.id}-v${$.target.publishedVersionNumber}.json`),z=sT(U,`${$.target.id}-latest.json`),I=JSON.stringify($,null,2);return $S0(Y,I,{encoding:"utf-8",mode:384}),$S0(z,I,{encoding:"utf-8",mode:384}),Y}function zS0($,U){let Y=US0(),z;if(!U||U==="latest")z=`${$}-latest.json`;else{let Q=String(U).replace(/^v/i,"");z=`${$}-v${Q}.json`}let I=sT(Y,z);if(!Vy1(I))return null;try{let Q=wy1(I,"utf-8");return JSON.parse(Q)}catch{return null}}function IS0($,U){if(!U)return $;let Y=U.trim().toLowerCase();return $.filter((z)=>{return String(z.sourceRuleCode).toLowerCase()===Y||String(z.targetRuleCode).toLowerCase()===Y||z.sourceRuleId.toLowerCase()===Y||z.targetRuleId.toLowerCase()===Y||`#${z.sourceRuleCode}`.toLowerCase()===Y||`#${z.targetRuleCode}`.toLowerCase()===Y})}function QS0($,U,Y){let z=0,I=U!==void 0?new RegExp(`\\[Prod v${U}\\s*·\\s*#(\\d+)(?:[^\\]]*)\\]`):/\[Prod draft\s*·\s*#(\d+)(?:[^\]]*)\]/;for(let J of Y){if(!J.versionName)continue;let K=J.versionName.match(I);if(K&&K[1]){let G=parseInt(K[1],10);if(!isNaN(G)&&G>z)z=G}}if(z>0)return z+1;if(!Y.some((J)=>J.versionName&&/\[Prod v\d+/.test(J.versionName))){let J=Y.filter((K)=>K.versionName&&K.versionName.includes(`Sync from ${$}`)).length;if(J>0)return J+1}return 1}function JS0($,U,Y,z){let I=U!==void 0?`Prod v${U}`:"Prod draft",Q=z!==void 0?` -> Test v${z}`:"";return`Sync from ${$} [${I} · #${Y}${Q}]`}var No=()=>{};import{randomBytes as My1}from"node:crypto";async function aT($,U,Y={}){let z=await B1($),I=await B1(U),[Q,J,K,G,H,W,X,Z]=await Promise.all([r1(z,$.seal.endpoints.approvalStylePreferences),r1(I,U.seal.endpoints.approvalStylePreferences),W6(z),W6(I),d8(z),d8(I),KS0(z),KS0(I)]),q=(X.articles||[]).filter((R)=>!R.isDeleted),V=(Z.articles||[]).filter((R)=>!R.isDeleted),F=new Map(V.map((R)=>[R.title.trim(),R])),M=[],w=[],N=new Set(q.map((R)=>R.title.trim()));for(let R of q){let o=R.title.trim(),e=F.get(o);if(!e){M.push(R);continue}let O0=[["co Line truncated
Run 'seal-use corps bind-test ${I.id} <testCorpId> --confirm' first to establish a verified 1-to-1 association.`);let Q=M1(I.testCorpId);if(Q.environment!=="test")throw Error(`Target enterprise '${Q.name}' (${Q.id}) is marked as '${Q.environment}', NOT 'test'. Aborting sync to protect non-test environments.`);let J=S(Y.options["version-name"])??S(Y.options.versionName),K=G0(Y.options["dry-run"])===!0||G0(Y.options.dryRun)===!0,G=G0(Y.options.yes)===!0||G0(Y.options.confirm)===!0;if(K)return R0(await aT(I,Q,{versionName:J,dryRun:!0})),!0;if(!G){let H=await aT(I,Q,{versionName:J,execute:!1});throw F$(`Refusing to overwrite test enterprise '${Q.name}' (${Q.id}) with preferences, ${H.rulesPlan.sourceDraftRuleCount} draft rules, and ${H.documentsPlan.sourceDocumentCount} knowledge documents from production enterprise '${I.name}' (${I.id}) without --yes. This will replace test draft rules, synchronize knowledge documents, and publish a new version on the test enterprise.`,`seal-use corps sync-test ${I.id} --yes`)}return R0(await aT(I,Q,{versionName:J,execute:!0})),!0}if($==="replay-test"){let z=U??S(Y.options.corp)??S(Y.options.prodCorp)??S(Y.options["prod-corp"]),I=M1(z),Q=G0(Y.options.force)===!0,J=G0(Y.options.dryRun)??G0(Y.options["dry-run"]),K=G0(Y.options.yes)===!0||G0(Y.options.confirm)===!0,G;if(!I.testCorpId){if(!Q)throw h4(`Production enterprise '${I.name}' (${I.id}) has no bound test enterprise.
Run 'seal-use corps bind-test ${I.id} <testCorpId> --confirm' first to establish a verified 1-to-1 association,
or add '--force' (or use 'seal-use webhook replay <recordId> --force') if you explicitly intend to replay directly within production.`);G=I}else if(G=M1(I.testCorpId),G.environment!=="test"&&!Q)throw Error(`Target enterprise '${G.name}' (${G.id}) is marked as '${G.environment}', NOT 'test'. Aborting replay to protect non-test environments (use --force to override).`);if(!J&&!K)throw F$("Refusing to replay approval records without --confirm. Use --dry-run to preview the payload without sending it.",`seal-use corps replay-test ${z??"<prodCorpId>"} --confirm`);let H=S(Y.options.recordId)??S(Y.options["record-id"])??S(Y.options.id),W=S(Y.options.recordIds)??S(Y.options["record-ids"]),X=W?W.split(",").map((D)=>D.trim()).filter(Boolean):void 0,Z=S(Y.options.sn)??S(Y.options.documentSn)??S(Y.options["document-sn"]),q=S(Y.options.sns)??S(Y.options["document-sns"]),V=q?q.split(",").map((D)=>D.trim()).filter(Boolean):void 0,F=s0(Y.options.limit)??(!H&&!X&&!Z&&!V?1:void 0),M={recordId:H,recordIds:X,sn:Z,sns:V,limit:F,status:S(Y.options.status),startDate:S(Y.options.startDate)??S(Y.options["start-date"]),endDate:S(Y.options.endDate)??S(Y.options["end-date"])},w=await B1(I),N=I.id===G.id?w:await B1(G);console.error(`[corps-replay-test] 正式企业「${I.name}」(${I.id}) -> 测试企业「${G.name}」(${G.id})`);let O=await zK({query:M,sourceClient:w,targetClient:N,sourceCorp:I,targetCorp:G,webhookSelector:S(Y.options.webhook)??S(Y.options.selector),snPrefix:S(Y.options.snPrefix)??S(Y.options["sn-prefix"]),snSuffix:S(Y.options.snSuffix)??S(Y.options["sn-suffix"]),docIdPrefix:S(Y.options.docIdPrefix)??S(Y.options["doc-id-prefix"]),docIdSuffix:S(Y.options.docIdSuffix)??S(Y.options["doc-id-suffix"]),dryRun:J});if(J)return console.error(`[corps-replay-test] 预览模式:已成功从 ${I.name} 提取单据并转换为 Webhook Payload(未实际推送)。`),R0(O),!0;if(O.success)console.error(`\uD83D\uDFE2 成功重放 ${O.successCount} 条单据(来自「${I.name}」)至「${G.name}」(${O.targetWebhook?.name??"Webhook 通道"})`);else console.error(`\uD83D\uDD34 单据重放部分或全部失败(成功 ${O.successCount} 条,失败 ${O.failureCount} 条)至「${G.name}」`);if(console.error(`\uD83D\uDC49 Next action: seal-use approval-runs list --corp ${G.id} --limit ${O.totalCount}`),R0(O),!O.success)throw new W4(`Approval record replay failed: ${O.failureCount} record(s) failed.`,1);return!0}return!1}var HS0=m(()=>{m6();Do();iZ();O4();O8();Z4();m1();Do()});async function WS0($,U,Y){if(await th0($,U,Y))return;if(await qv0($,U,Y))return;if(await GS0($,U,Y))return;if(await gv0($,U,Y))return;throw Error(`Unknown corps command: ${$??""}. Run 'seal-use help' for available commands.`)}var Ao=m(()=>{Vv0();yv0();eh0();HS0();iT()});var qS0={};T8(qS0,{handleAuthExtractKeysCommand:()=>To,handleAuthCommand:()=>$j,formatBeijingIso:()=>Po});async function To($,U){let Y=$??S(U.options.link)??S(U.options.url);if(!Y)throw Error("Usage: seal-use auth hose-extract-keys <https://.../web/thirdparty.html?...> [--reveal] [--save] [--name <customName>] [--overwrite]");let z=G0(U.options.reveal)===!0||G0(U.options.r)===!0||G0(U.options.plain)===!0,I=G0(U.options.save)===!0||G0(U.options.add)===!0;await hq(Y,{reveal:z,save:I,name:S(U.options.name),overwrite:G0(U.options.overwrite)===!0,force:G0(U.options.force)===!0,appKey:S(U.options["app-key"])??S(U.options.appKey),keyId:S(U.options["key-id"])??S(U.options.keyId)})}async function $j($,U,Y){if($==="check"||$==="diagnose"||$==="status"||$==="test"||$==="doctor"){R0(await Dy1(U));return}if($==="seal-link"||$==="link"||$==="hose-link"&&U?.source?.type==="seal"){let z=Y.command[2]?.toLowerCase(),I=S(Y.options["from-link"])??(z==="from-link"?Y.command[3]:void 0);if(I){let X=S(Y.options.note),Z=await ZM(I),q=B6(Z.sealUrl,Z.token),V=await Z8(q);qM(Z.corpId,V.tenant);let F=await tI(q,{note:X});R0({tenant:{id:V.tenant.id,name:V.tenant.name,tenantSlug:V.tenant.tenantSlug,corpId:Z.corpId},user:{id:V.user.id,name:V.user.name,providerUserId:V.user.providerUserId,isAdmin:V.user.isAdmin},delegation:F,expiresIn:Z.expiresIn});return}let Q=await B1(U);if(z==="list"){await x0("seal_delegation_list",Q,U,{},j0(Y.options));return}if(z==="revoke"){let X=Y.command[3]??S(Y.options.tokenId)??S(Y.options.id);if(!X)throw Error("Usage: seal-use auth link revoke <tokenId>");await x0("seal_delegation_revoke",Q,U,{tokenId:X},j0(Y.options));return}let J=S(Y.options.note)??"CLI generated provisional access link",K=await M$("seal_delegation_create",Q,U,{note:J});if($==="hose-link")console.error(`\uD83D\uDC49 提示: 企业「${U.name}」源类型为 Seal 原生测试环境,已自动为您生成委托免登直达链接。`);let G=K,H="staffName"in U.source&&typeof U.source.staffName==="string"?U.source.staffName:void 0,W=Po(Date.now()+86400000);R0({id:G.id,corpId:U.source.corpId??U.id,corpName:U.name,staffId:U.source.staffId,...H?{staffName:H}:{},link:G.link,expiresAt:W,token:G.token});return}if($==="hose-link"){le Line truncated
`+`支持的审批系统与发布目标:
`+` • hosecloud (合思费控): seal-use deploy hosecloud <requirements|list|get|status|configure|sync> --corp <corpId>
@@ -950,14 +947,14 @@ or add '--force' (or use 'seal-use webhook replay <recordId> --force') if you ex
`+` • feishu (飞书审批): 建议使用 Webhook 模式对接
`+` • weaver (泛微 OA): 建议使用 Webhook 模式对接
`+` • helios (汇联易): 建议使用 Webhook 模式对接
`+" • maycur (每刻报销): 建议使用 Webhook 模式对接");if($==="webhook"||$==="webhooks")throw Error("Webhook 审批流发布请直接使用专有命令:seal-use webhook <list|get|add|update|delete> --corp <corpId>");if($==="feishu"||$==="lark")throw Error("飞书审批发布:建议使用 Webhook 通用发布模式对接。命令:seal-use webhook add --name '飞书审批' --result-url <url> --corp <corpId>");if($==="weaver")throw Error("泛微 OA 发布:建议使用 Webhook 通用发布模式对接。命令:seal-use webhook add --name '泛微OA' --result-url <url> --corp <corpId>");if($==="maycur"||$==="helios"){let H=$==="maycur"?"每刻报销":"汇联易";throw Error(`${H}发布:目前可通过 Webhook 模式接入。命令:seal-use webhook add --name '${H}' --result-url <url> --corp <corpId>`)}let I=$==="hosecloud",K=$==="hosecloud"?Y:$,G=$==="hosecloud"?z:Y;if(!I)throw Error(`未知的发布目标系统: ${$}。当前支持: hosecloud (合思费控) 与 webhook (通用回调)。`);if(K==="requirements"){await k0("seal_deploy_hosecloud_requirements",U,Q,{},E0(J.options));return}if(K==="list"){await k0("seal_deploy_hosecloud_list",U,Q,{},E0(J.options));return}if(K==="get"){let H=G??h(J.options.signKey)??h(J.options["sign-key"]);if(!H){let X=((await o1(U)).integrations??[]).filter((Z)=>Z.type==="hosecloud");if(X.length===0)throw Error(`当前企业 (${Q.name}) 尚未添加合思发布配置。
`+`\uD83D\uDC49 请先运行配置命令:seal-use deploy hosecloud configure --json '{...}' --corp ${Q.id}`);console.error(`Usage: seal-use deploy hosecloud get <sign-key> [--corp ${Q.id}]
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let Z of X){let q=Z.outboundName??"SealAI 审批",V=Z.signKey,F=Z.apiOrigin??"production";console.error(` • "${q}" (signKey: ${V}, 环境: ${F})`),console.error(` \uD83D\uDC49 查看命令: seal-use deploy hosecloud get ${V} --corp ${Q.id}
`)}throw new L4("缺少必需参数 <sign-key>。请从上述候选列表中选择并指定 signKey。",2,X.length===1?`seal-use deploy hosecloud get ${X[0].signKey} --corp ${Q.id}`:void 0)}await k0("seal_deploy_hosecloud_get",U,Q,{signKey:H},E0(J.options));return}if(K==="status"){await k0("seal_deploy_hosecloud_status",U,Q,{},E0(J.options));return}if(K==="configure"){let H=h(J.options.input),W=H?JSON.parse(og1(H,"utf8")):k8(J.json);if(!W||Object.keys(W).length===0)throw Error("Usage: seal-use deploy hosecloud configure --json '{...}' or --input <file>");await k0("seal_deploy_hosecloud_configure",U,Q,{...W,dryRun:Z0(J.options.dryRun)??Z0(J.options["dry-run"])},E0(J.options));return}if(K==="sync"){let H=G??h(J.options.signKey)??h(J.options["sign-key"]),W=Z0(J.options.auto)??Z0(J.options.yes);if(!H){let Z=((await o1(U)).integrations??[]).filter((V)=>V.type==="hosecloud");if(Z.length===0)throw Error(`当前企业 (${Q.name}) 尚未添加合思发布配置。
`+`\uD83D\uDC49 请先运行配置命令:seal-use deploy hosecloud configure --json '{...}' --corp ${Q.id}`);let q=Z[0];if(q&&Z.length===1&&W){let V=q.signKey;console.error(`ℹ️ [auto] 检测到企业仅有 1 个合思配置,已自动选择 (signKey: ${V})`),await k0("seal_deploy_hosecloud_sync",U,Q,{signKey:V},E0(J.options));return}console.error(`Usage: seal-use deploy hosecloud sync <sign-key> [--corp ${Q.id}]
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let V of Z){let F=V.outboundName??"SealAI 审批",w=V.signKey,O=V.apiOrigin??"production";console.error(` • "${F}" (signKey: ${w}, 环境: ${O})`),console.error(` \uD83D\uDC49 同步命令: seal-use deploy hosecloud sync ${w} --corp ${Q.id}
`)}if(Z.length===1)console.error(`\uD83D\uDCA1 提示:若希望单配置自动同步,可附加 --auto 参数:seal-use deploy hosecloud sync --auto --corp ${Q.id}
`);throw new L4("缺少必需参数 <sign-key>。请从上述候选列表中选择并指定 signKey 执行同步。",2,Z.length===1?`seal-use deploy hosecloud sync ${Z[0].signKey} --corp ${Q.id}`:void 0)}await k0("seal_deploy_hosecloud_sync",U,Q,{signKey:H},E0(J.options));return}throw Error(`Unknown deploy hosecloud action: ${K??""}. Available: requirements, list, get, status, configure, sync.`)}var th0=m(()=>{f4();A4();K4();B6();F$()});var $S0=`---
`+" • maycur (每刻报销): 建议使用 Webhook 模式对接");if($==="webhook"||$==="webhooks")throw Error("Webhook 审批流发布请直接使用专有命令:seal-use webhook <list|get|add|update|delete> --corp <corpId>");if($==="feishu"||$==="lark")throw Error("飞书审批发布:建议使用 Webhook 通用发布模式对接。命令:seal-use webhook add --name '飞书审批' --result-url <url> --corp <corpId>");if($==="weaver")throw Error("泛微 OA 发布:建议使用 Webhook 通用发布模式对接。命令:seal-use webhook add --name '泛微OA' --result-url <url> --corp <corpId>");if($==="maycur"||$==="helios"){let H=$==="maycur"?"每刻报销":"汇联易";throw Error(`${H}发布:目前可通过 Webhook 模式接入。命令:seal-use webhook add --name '${H}' --result-url <url> --corp <corpId>`)}let J=$==="hosecloud",K=$==="hosecloud"?U:$,G=$==="hosecloud"?Y:U;if(!J)throw Error(`未知的发布目标系统: ${$}。当前支持: hosecloud (合思费控) 与 webhook (通用回调)。`);if(K==="requirements"){await x0("seal_deploy_hosecloud_requirements",z,I,{},j0(Q.options));return}if(K==="list"){await x0("seal_deploy_hosecloud_list",z,I,{},j0(Q.options));return}if(K==="get"){let H=G??S(Q.options.signKey)??S(Q.options["sign-key"]);if(!H){let X=((await r1(z)).integrations??[]).filter((Z)=>Z.type==="hosecloud");if(X.length===0)throw Error(`当前企业 (${I.name}) 尚未添加合思发布配置。
`+`\uD83D\uDC49 请先运行配置命令:seal-use deploy hosecloud configure --json '{...}' --corp ${I.id}`);console.error(`Usage: seal-use deploy hosecloud get <sign-key> [--corp ${I.id}]
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let Z of X){let q=Z.outboundName??"SealAI 审批",V=Z.signKey,F=Z.apiOrigin??"production";console.error(` • "${q}" (signKey: ${V}, 环境: ${F})`),console.error(` \uD83D\uDC49 查看命令: seal-use deploy hosecloud get ${V} --corp ${I.id}
`)}throw new W4("缺少必需参数 <sign-key>。请从上述候选列表中选择并指定 signKey。",2,X.length===1?`seal-use deploy hosecloud get ${X[0].signKey} --corp ${I.id}`:void 0)}await x0("seal_deploy_hosecloud_get",z,I,{signKey:H},j0(Q.options));return}if(K==="status"){await x0("seal_deploy_hosecloud_status",z,I,{},j0(Q.options));return}if(K==="configure"){let H=S(Q.options.input),W=H?JSON.parse(Ty1(H,"utf8")):B8(Q.json);if(!W||Object.keys(W).length===0)throw Error("Usage: seal-use deploy hosecloud configure --json '{...}' or --input <file>");await x0("seal_deploy_hosecloud_configure",z,I,{...W,dryRun:G0(Q.options.dryRun)??G0(Q.options["dry-run"])},j0(Q.options));return}if(K==="sync"){let H=G??S(Q.options.signKey)??S(Q.options["sign-key"]),W=G0(Q.options.auto)??G0(Q.options.yes);if(!H){let Z=((await r1(z)).integrations??[]).filter((V)=>V.type==="hosecloud");if(Z.length===0)throw Error(`当前企业 (${I.name}) 尚未添加合思发布配置。
`+`\uD83D\uDC49 请先运行配置命令:seal-use deploy hosecloud configure --json '{...}' --corp ${I.id}`);let q=Z[0];if(q&&Z.length===1&&W){let V=q.signKey;console.error(`ℹ️ [auto] 检测到企业仅有 1 个合思配置,已自动选择 (signKey: ${V})`),await x0("seal_deploy_hosecloud_sync",z,I,{signKey:V},j0(Q.options));return}console.error(`Usage: seal-use deploy hosecloud sync <sign-key> [--corp ${I.id}]
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let V of Z){let F=V.outboundName??"SealAI 审批",M=V.signKey,w=V.apiOrigin??"production";console.error(` • "${F}" (signKey: ${M}, 环境: ${w})`),console.error(` \uD83D\uDC49 同步命令: seal-use deploy hosecloud sync ${M} --corp ${I.id}
`)}if(Z.length===1)console.error(`\uD83D\uDCA1 提示:若希望单配置自动同步,可附加 --auto 参数:seal-use deploy hosecloud sync --auto --corp ${I.id}
`);throw new W4("缺少必需参数 <sign-key>。请从上述候选列表中选择并指定 signKey 执行同步。",2,Z.length===1?`seal-use deploy hosecloud sync ${Z[0].signKey} --corp ${I.id}`:void 0)}await x0("seal_deploy_hosecloud_sync",z,I,{signKey:H},j0(Q.options));return}throw Error(`Unknown deploy hosecloud action: ${K??""}. Available: requirements, list, get, status, configure, sync.`)}var TS0=m(()=>{O4();Z4();m1();X6();O8()});var ES0=`---
name: seal-use
description: "v0.10.37: Use for Seal Use first-time enterprise onboarding, Hose/合思 or Seal-native authentication, assistance links and browser cURL intake, plus tenant approval operations, diagnosis, simulation, rules, users, configuration, and search."
metadata:
@@ -969,6 +966,28 @@ metadata:
> CLI 是主执行通道,MCP 默认关闭(插件配置可选开启)。机器通道 (\`stdout\`) 必须输出纯净 JSON,诊断日志与下一步建议统一输出在 \`stderr\`。
### 时间显示约定
- 机器字段(如 \`checkedAt\`、\`lastCheckedAt\`)保留 ISO 8601 UTC 格式,精确到秒,例如 \`2026-09-22T04:56:06Z\`;不要改成本地时间或添加毫秒。
- Agent 面向用户解释时间时,必须将 UTC 换算为北京时间(\`Asia/Shanghai\`,\`UTC+8\`),明确标注“北京时间”;需要审计或消歧时同时附上原始 UTC 时间。
### 企业接入路由约定
必须区分“用户提供的材料”“最终企业来源”和“标准化 CLI 入口”三个概念:
| 用户材料 | Agent 预处理后的标准入口 | 说明 |
|---|---|---|
| 合思开放平台 \`appKey + appSecurity\` | \`corps add-hose-persistent\` | 纯 Hose 长期凭据入口;自动探测域名、企业和管理员。 |
| Seal URL + Bearer Token,或从 Seal 后台复制的 cURL | \`corps add-seal-bearer\` | 两者是同一类 Seal 会话凭据;cURL 只需提取必要字段后再调用 \`add-seal-bearer\`。 |
| Seal 原生委托链接,或合思协助链接 | \`corps add-link\` | \`add-link\` 是 URL 混合入口,自动识别 Seal 与 Hose 链接;它不直接接收 cURL。 |
| 从已登录合思管理员页面复制的 cURL | 优先提取密钥后调用 \`corps add-hose-persistent\`;失败时调用 \`corps add-hose-web-session\` | Hose \`accesstoken\` 与 Seal Bearer 不是同一种 token;不能直接混用。 |
**Token 类型不得混用**:\`add-seal-bearer\` 只接受 Seal Bearer Token;合思网页 cURL 中的 \`accesstoken\` 只能用于 Hose API 和密钥提取,提取失败后由 \`add-hose-web-session\` 经 SSO 换成 Seal Bearer,不能直接作为 \`add-seal-bearer\` 的 \`token\`。
**配置类型判断**:\`source.type: "hose"\` 且存在 \`appKey/appSecurity\` 表示 Hose 持久化凭据;\`source.type: "hose"\` 且存在 \`closeToken + staffId\` 表示 Hose Web Session。Web Session 调用 Seal 能力时才通过 SSO 换取运行时 Seal Bearer;不要把 Hose 的 \`accessToken/closeToken\` 当作 Seal Bearer Token。若会话材料提供了有效期,Hose source 同样记录 \`expiresIn\` 和 \`expiresAt\`(UTC 秒精度,如 \`2026-09-22T05:30:00Z\`)。
\`add-link\` 的默认行为是导入临时会话。只有明确使用 \`--elevate-hose\` 时,才执行合思提权并提取长期 OpenAPI 凭据;\`--as-hose\` 仅作为兼容旧参数,不作为 Agent 的默认表达。
---
## 0. 全局业务术语与对外输出契约(Mandatory Vocabulary Contract)⚠️ 核心红线
@@ -1017,7 +1036,7 @@ metadata:
![网络Fetch/XHR](assets/hose-curl-network-fetch-xhr.png)
3. 找到任一正常业务请求,右键「复制」-「以 cURL 格式复制」:
![以cURL格式复制](assets/hose-curl-copy-as-curl.png)
3. **无感接入**:Agent 接收材料后自动执行 \`corps add-hose\`、\`corps add-link\` 或 \`corps hose-extract-keys --save\`,系统自动反查拉取真实企业中文名,自动绑定管理员,完成接入。无需用户手动查找 \`corpId\` 或 \`staffId\`。详阅 \`references/first-time-user.md\` 与 \`references/enterprise-onboarding.md\`。
3. **无感接入**:Agent 接收材料后自动执行 \`corps add-hose-persistent\`、\`corps add-hose-web-session\`、\`corps add-seal-bearer\`、\`corps add-link\` 或 \`corps hose-extract-keys --save\`,系统自动反查拉取真实企业中文名,自动绑定管理员,完成接入。无需用户手动查找 \`corpId\` 或 \`staffId\`。详阅 \`references/first-time-user.md\` 与 \`references/enterprise-onboarding.md\`。
---
@@ -1029,7 +1048,7 @@ metadata:
\`corps\` 是企业上下文的总入口,推荐按“接入 → 发现与选择 → 环境配对 → 测试验证”的主线使用;Hose 能力是针对合思来源企业的专属子域,不应覆盖原生 Seal 主流程。
- **企业接入(主入口)**:\`add-link\`(自动识别 Seal 原生委托链接或 Hose 协助链接,原生 Seal 优先)、\`add-seal\`、\`add-hose\`。
- **企业接入(主入口)**:\`add-link\`(自动识别 Seal 原生委托链接或 Hose 协助链接,原生 Seal 优先)、\`add-seal-bearer\`、\`add-hose-persistent\`、\`add-hose-web-session\`。
- **发现与选择(高频管理)**:\`list\`、\`search\`/\`find\`、\`get\`/\`show\`、\`current\`、\`switch\`。
- **企业配置(低频维护)**:\`mark\`、\`rename\`。
- **测试配对与验证(生产变更闭环)**:\`bind-test\`、\`unbind-test\`、\`sync-test\`、\`replay-test\`;回归测试统一使用 \`seal-use test regression\`。
@@ -1037,7 +1056,7 @@ metadata:
命令保持扁平兼容以避免破坏现有脚本;\`seal-use corps --help\` 会按上述业务组展示,不代表这些命令属于同一风险等级。涉及本地配置或测试数据写入的操作仍须遵守确认与预览规则。
Hose 专属命令必须从命令名上显式可见:认证入口使用 \`auth hose-*\`,合思原生审批流使用 \`approval-runs hose-flow\`,部署入口使用 \`deploy hosecloud ...\`,模拟入口使用 \`simulation --mode hosecloud\`。跨 Seal/Hose 的混合命令保留通用名称,但必须通过 \`--as-hose\`、\`--with-flow\` 或 \`--type hose-document\` 明确选择 Hose 能力。
Hose 专属命令必须从命令名上显式可见:认证入口使用 \`auth hose-*\`,合思原生审批流使用 \`approval-runs hose-flow\`,部署入口使用 \`deploy hosecloud ...\`,模拟入口使用 \`simulation --mode hosecloud\`。跨 Seal/Hose 的混合命令保留通用名称,但必须通过 \`--elevate-hose\`、\`--with-flow\` 或 \`--type hose-document\` 明确选择 Hose 能力。
### 2.1 企业定位与直达访问
- 关键字智能搜索(支持同音字/拼音/简拼/容错):\`seal-use corps search <keyword>\`
@@ -1100,11 +1119,11 @@ Hose 专属命令必须从命令名上显式可见:认证入口使用 \`auth h
- 返回授权、协助或委托链接时,必须同时提供代码块(便于复制)与可点击链接;
- 审批单链接默认提供只读 Deep Link(\`type: 'deep_link'\`);仅在用户明确需要免密时才使用 \`--sso\` 并声明四项安全告知。
- **高危写操作防线**:规则推送或发布(\`rules push --publish\`)、清空(\`rules clear\`)、测试同步(\`corps sync-test\`)与单据重放(\`corps replay-test\`)优先使用 \`--dry-run\` 预览;正式执行必须按命令要求显式带 \`--yes\` 或 \`--confirm\`。\`replay-test --force\` 仅放宽目标环境/绑定检查,不会跳过确认。
`;var eh0=()=>{};var zS0=`interface:
`;var jS0=()=>{};var RS0=`interface:
display_name: "Seal Use"
short_description: "Diagnose approval feedback and publish minimal rule fixes"
default_prompt: "Use $seal-use to resolve a customer feedback package to the correct tenant, diagnose the approval run, propose a minimal rule diff, and publish only after explicit confirmation."
`;var YS0=()=>{};var QS0=`# Approval Attachment Trace Investigation
`;var CS0=()=>{};var vS0=`# Approval Attachment Trace Investigation
Use this workflow when a customer disputes an AI approval finding about an attachment, invoice, receipt, OCR result, or a UI-highlighted audit result.
@@ -1325,7 +1344,7 @@ Manual image check:
- The customer's objection that they were receipts rather than invoices was reasonable.
However, the final rejection also had an independent rule-37 reason: payment screenshots totaled 699.48 while reimbursement was 700.00.
`;var US0=()=>{};var IS0=`# Approval Bad Case Catalog
`;var _S0=()=>{};var SS0=`# Approval Bad Case Catalog
Use this file only as a comparison catalog after inspecting the current trace. Do not treat any case below as a default diagnosis.
@@ -1375,7 +1394,7 @@ Important nuance:
- This is a bad-case pattern, not a general rule that every amount-total dispute is caused by \`pre_analysis\`.
- Use it when the current trace shows recognized amounts being excluded downstream or duplicate attachments producing inconsistent conclusions.
`;var JS0=()=>{};var GS0="# Approval Run Lightweight Queries\n\nUse this reference when the user gives a 合思/易快报单号, source document SN, record ID, simulation batch ID, or asks for an approval decision without needing the full raw run payload.\n\n## Locate A Run By Document Number\n\nPrefer `pick` before broad search + bridge + get.\n\n```bash\nseal-use approval-runs pick --corp <corpId> --sn <sourceDocumentSN> --latest\nseal-use approval-runs pick --corp <corpId> --sn <sourceDocumentSN> --batch <batchId> --latest\nseal-use approval-runs pick --corp <corpId> --sn <sourceDocumentSN> --latest --fields recordId,sourceDocumentSN,status,aiDecision,aiSummary\n```\n\nDefault output is intentionally small: `recordId`, `sourceDocumentSN`, `sourceDocumentId`, `simulationBatchId`, `status`, `taskMode`, `ruleSetVersionNumber`, `langfuseTraceId`, `manualResult`, `aiDecision`, and `aiSummary`.\n\nIf there are multiple candidates and `--latest` was not used, report the candidates and ask which one to inspect.\n\n## Read Compact Run Detail\n\nUse `--summary` for most diagnosis and support questions.\n\n```bash\nseal-use approval-runs get <recordId> --corp <corpId> --summary\n```\n\nUse `--fields` when the user needs a particular slice.\n\n```bash\nseal-use approval-runs get <recordId> --corp <corpId> --fields metadata\nseal-use approval-runs get <recordId> --corp <corpId> --fields document.fields,result.summary\nseal-use approval-runs get <recordId> --corp <corpId> --fields result.summary,result.decision,result.riskPoints\nseal-use approval-runs get <recordId> --corp <corpId> --fields document.keyFields,result,manualApprovalRecord,ruleSetVersionNumber\n```\n\nAvoid full `approval-runs get <recordId>` unless the user specifically needs raw document fields, pipeline logs, invoice rawData, or signed URLs. Prefer `--output-file` for full payloads.\n\n## Understand The Case First\n\nBefore pulling the full document, use:\n\n```bash\nseal-use approval-runs document-summary <recordId> --corp <corpId>\n```\n\nThis is for quick case reading: template/title, key fields, amount, expense type, cost company, payee, invoice summary, attachment names, AI result, and manual result.\n\n## Extract AI-Cited Rules\n\nUse this when the user asks \"AI 用了哪条规则\", \"为什么命中这条\", or needs the rule evidence for a specific run.\n\n```bash\nseal-use approval-runs cited-rules <recordId> --corp <corpId>\n```\n\nReturn and discuss `runtimeRuleId`, `ruleCode`, `versionNumber`, `scope`, `strictness`, `appliedAnalysis`, `checkResult`, and `findings` when present.\n\nIf the user then wants the full text of one cited rule, use `rules get --record-id <recordId> --runtime-id rule-205` from `rule-lightweight.md`.\n\n## Attachments Without Raw Payloads\n\nUse:\n\n```bash\n# 查看附件列表摘要(包含文件名、类型、大小及直链可用性)\nseal-use approval-runs attachments <recordId> --corp <corpId> --summary\n\n# 下载全部附件到本地目录(优先使用 ossSignedUrl 签名直链)\nseal-use approval-runs attachments download <recordId> --all --out-dir ./downloads --corp <corpId>\n\n# 按名称或 fileId 过滤下载单个附件\nseal-use approval-runs attachments download <recordId> --name 发票 --corp <corpId>\n```\n\nThis should be enough for file names, file IDs, mime types, positions, invoice/attachment grouping, and links when available. For customer disputes about OCR, receipt/invoice classification, or image content, switch to `approval-attachment-trace.md`.\n\n## Result Summary\n\nUse:\n\n```bash\nseal-use approval-runs result <recordId> --corp <corpId> --summary\n```\n\nThis is for decision, summary, risk point count, matched rule count, trace ID, and record ID.\n\n## Approval Run Web Links & Auto-Login Links\n\nUse this when the user asks for a link to an approval run or wants to open the run directly in their browser:\n\n```bash\n# 默认推荐:生成 Seal AI 审核详情直达链接(无凭证、无越权风险,用户在已有登录状态的浏览器中直接打开)\nseal-use approval-runs link <recordId> --corp <corpId>\nseal-use approval-runs link --sn <sourceDocumentSN> --corp <corpId>\n\n# 生成合思主系统原始单据页面链接\nseal-use approval-runs link <recordId> --type hose-document --corp <corpId>\n\n# 仅当用户明确要求免密/跨浏览器/无登录直达且确认知晓安全风险时:生成携带合思单次临时票据的免登直达链接\nseal-use approval-runs link <recordId> --auto-login [--expire 7200] --corp <corpId>\n```\n\n### 返回字段说明与语义规范\n- `sealResultUrl`: Seal AI 单据智能审核结果页\n- `hoseDocumentUrl`: 合思费控主系统原始报销/借款单详情页\n- `type`: 链接类型,默认为 `seal_result`,指定时可为 `hose_document`\n- `mode`: 鉴权模式,`direct`(原生直接打开)或 `auto_login`(免密换票)\n\n### 免登链接安全与声明规范\n当向用户返回 `--auto-login` 链接时 Line truncated
`;var hS0=()=>{};var yS0="# Approval Run Lightweight Queries\n\nUse this reference when the user gives a 合思/易快报单号, source document SN, record ID, simulation batch ID, or asks for an approval decision without needing the full raw run payload.\n\n## Locate A Run By Document Number\n\nPrefer `pick` before broad search + bridge + get.\n\n```bash\nseal-use approval-runs pick --corp <corpId> --sn <sourceDocumentSN> --latest\nseal-use approval-runs pick --corp <corpId> --sn <sourceDocumentSN> --batch <batchId> --latest\nseal-use approval-runs pick --corp <corpId> --sn <sourceDocumentSN> --latest --fields recordId,sourceDocumentSN,status,aiDecision,aiSummary\n```\n\nDefault output is intentionally small: `recordId`, `sourceDocumentSN`, `sourceDocumentId`, `simulationBatchId`, `status`, `taskMode`, `ruleSetVersionNumber`, `langfuseTraceId`, `manualResult`, `aiDecision`, and `aiSummary`.\n\nIf there are multiple candidates and `--latest` was not used, report the candidates and ask which one to inspect.\n\n## Read Compact Run Detail\n\nUse `--summary` for most diagnosis and support questions.\n\n```bash\nseal-use approval-runs get <recordId> --corp <corpId> --summary\n```\n\nUse `--fields` when the user needs a particular slice.\n\n```bash\nseal-use approval-runs get <recordId> --corp <corpId> --fields metadata\nseal-use approval-runs get <recordId> --corp <corpId> --fields document.fields,result.summary\nseal-use approval-runs get <recordId> --corp <corpId> --fields result.summary,result.decision,result.riskPoints\nseal-use approval-runs get <recordId> --corp <corpId> --fields document.keyFields,result,manualApprovalRecord,ruleSetVersionNumber\n```\n\nAvoid full `approval-runs get <recordId>` unless the user specifically needs raw document fields, pipeline logs, invoice rawData, or signed URLs. Prefer `--output-file` for full payloads.\n\n## Understand The Case First\n\nBefore pulling the full document, use:\n\n```bash\nseal-use approval-runs document-summary <recordId> --corp <corpId>\n```\n\nThis is for quick case reading: template/title, key fields, amount, expense type, cost company, payee, invoice summary, attachment names, AI result, and manual result.\n\n## Extract AI-Cited Rules\n\nUse this when the user asks \"AI 用了哪条规则\", \"为什么命中这条\", or needs the rule evidence for a specific run.\n\n```bash\nseal-use approval-runs cited-rules <recordId> --corp <corpId>\n```\n\nReturn and discuss `runtimeRuleId`, `ruleCode`, `versionNumber`, `scope`, `strictness`, `appliedAnalysis`, `checkResult`, and `findings` when present.\n\nIf the user then wants the full text of one cited rule, use `rules get --record-id <recordId> --runtime-id rule-205` from `rule-lightweight.md`.\n\n## Attachments Without Raw Payloads\n\nUse:\n\n```bash\n# 查看附件列表摘要(包含文件名、类型、大小及直链可用性)\nseal-use approval-runs attachments <recordId> --corp <corpId> --summary\n\n# 下载全部附件到本地目录(优先使用 ossSignedUrl 签名直链)\nseal-use approval-runs attachments download <recordId> --all --out-dir ./downloads --corp <corpId>\n\n# 按名称或 fileId 过滤下载单个附件\nseal-use approval-runs attachments download <recordId> --name 发票 --corp <corpId>\n```\n\nThis should be enough for file names, file IDs, mime types, positions, invoice/attachment grouping, and links when available. For customer disputes about OCR, receipt/invoice classification, or image content, switch to `approval-attachment-trace.md`.\n\n## Result Summary\n\nUse:\n\n```bash\nseal-use approval-runs result <recordId> --corp <corpId> --summary\n```\n\nThis is for decision, summary, risk point count, matched rule count, trace ID, and record ID.\n\n## Approval Run Web Links & Auto-Login Links\n\nUse this when the user asks for a link to an approval run or wants to open the run directly in their browser:\n\n```bash\n# 默认推荐:生成 Seal AI 审核详情直达链接(无凭证、无越权风险,用户在已有登录状态的浏览器中直接打开)\nseal-use approval-runs link <recordId> --corp <corpId>\nseal-use approval-runs link --sn <sourceDocumentSN> --corp <corpId>\n\n# 生成合思主系统原始单据页面链接\nseal-use approval-runs link <recordId> --type hose-document --corp <corpId>\n\n# 仅当用户明确要求免密/跨浏览器/无登录直达且确认知晓安全风险时:生成携带合思单次临时票据的免登直达链接\nseal-use approval-runs link <recordId> --auto-login [--expire 7200] --corp <corpId>\n```\n\n### 返回字段说明与语义规范\n- `sealResultUrl`: Seal AI 单据智能审核结果页\n- `hoseDocumentUrl`: 合思费控主系统原始报销/借款单详情页\n- `type`: 链接类型,默认为 `seal_result`,指定时可为 `hose_document`\n- `mode`: 鉴权模式,`direct`(原生直接打开)或 `auto_login`(免密换票)\n\n### 免登链接安全与声明规范\n当向用户返回 `--auto-login` 链接时 Line truncated
Use this low-freedom workflow when the user provides packaged customer feedback from WeChat, screenshots, rejection notifications, a document number, or expected business behavior and wants diagnosis or an approval-rule change.
@@ -1643,7 +1662,7 @@ Do not automatically rerun or resubmit the customer's production document. Run a
- **系统调用凭证账号**:显式说明“周晚容(系统调用凭证账号,由智能助手代执行)”
- **全量规则总数**:核对总数是否变化
- **规则一致性校验**:确认目标规则文本与确认内容 100% 逐字吻合
`;var XS0=()=>{};var VS0=`# Enterprise Onboarding
`;var fS0=()=>{};var iS0=`# Enterprise Onboarding
> 💡 **新手接入指引分工**:
> - 若是引导无技术背景的用户找凭证材料、找按钮,**必须直接使用 \`references/first-time-user.md\` 并渲染其中的指引截图**;
@@ -1684,16 +1703,25 @@ Classify both the enterprise identity origin and how the current credential was
| Enterprise identity origin | Credential material the user may have | 权限等级与时效 | Meaning |
| --- | --- | --- | --- |
| Hose/合思-sourced Seal tenant | Hose \`appKey\` + \`appSecurity\` | 【最高·永久】自动签名/续期 | Stable, refreshable standard integration; unlocks full OpenAPI and \`deploy hosecloud sync\`. |
| Hose/合思-sourced Seal tenant | Hose authorization/assistance link (\`thirdparty.html\`) | 【两极分化】普通导入→短效;提权→永久 | Temporary session that can be **elevated** to permanent \`appKey\`/\`appSecurity\` with \`extract-keys --save\` or \`add-link --as-hose\`. |
| Hose/合思-sourced Seal tenant | Hose authorization/assistance link (\`thirdparty.html\`) | 【两极分化】普通导入→短效;提权→永久 | Temporary session that can be **elevated** to permanent \`appKey\`/\`appSecurity\` with \`extract-keys --save\` or \`add-link --elevate-hose\`. |
| Hose/合思-sourced Seal tenant | cURL copied from an authenticated **Hose admin** page | 【两极分化】普通导入→短效;提权→永久 | **Same session scope as an assistance link.** If the user is a Hose administrator, this carries the same web session credentials (\`accesstoken\`, \`corpid\`, cookies) and can equally invoke \`/api/innerapi/v1/key\` to extract permanent \`appKey\`/\`appSecurity\`. |
| Hose/合思-sourced Seal tenant | cURL copied from an authenticated Seal page | 【短效会话快照】 | Snapshot with Seal Bearer token; can set up temporary Seal session access. |
| Seal-native tenant | Seal assistance/delegation link | 【临时·可撤销】 | Temporary delegated access to a Seal tenant. |
| Seal-native tenant | cURL copied from an authenticated Seal page | 【短效会话快照】 | Snapshot containing the Seal host and session authentication. |
| Seal-native tenant | Seal URL + Bearer Token, or cURL copied from an authenticated Seal page | 【短效会话快照】 | Both normalize to \`add-seal-bearer\`; the cURL is only a transport format for the same Seal Bearer credential. |
**同等凭据原则(Equal Credential Scope Principle)**: A Hose assistance link and a browser cURL from an authenticated Hose admin session are both Hose web frontend sessions — they carry the same underlying \`accessToken\`/\`accesstoken\` and \`corpid\`. The **only** structural difference is delivery format. When a Hose administrator sends you a cURL, treat it with the same privilege elevation potential as an assistance link. Do not downgrade it to a plain Seal session import without first attempting key extraction.
Credential shape alone does not define identity origin. In particular, a Hose-sourced user eventually receives a Seal Bearer session after SSO. When \`whoami\` returns provider metadata, preserve it and use it to describe the tenant accurately.
### Token boundary
The Hose web-session \`accesstoken\` and the Seal Bearer Token are different credentials and are not interchangeable:
- \`corps add-seal-bearer\` accepts the Seal Bearer Token together with \`sealUrl\`.
- A Hose cURL's \`accesstoken\` is used first for Hose key extraction. If no permanent OpenAPI key can be extracted, call \`add-hose-web-session\`; it stores the Hose \`closeToken\` and \`staffId\`, then exchanges the Hose session through Seal SSO only when a Seal session is needed.
- Never pass a Hose \`accesstoken\` directly as the \`token\` field of \`add-seal-bearer\`.
The saved config makes the lifecycle visible: durable Hose credentials use \`source.type: "hose"\` with \`appKey/appSecurity\`; Hose Web Session credentials also use \`source.type: "hose"\`, but carry \`closeToken\` and \`staffId\` instead. If the Hose session material provides an expiry, it is stored as \`expiresIn\` (seconds) and \`expiresAt\` in UTC second precision, such as \`2026-09-22T05:30:00Z\`. The Seal Bearer obtained through SSO is a runtime cache, not the enterprise source type.
## Parameter Ownership
Ask the user only for information that cannot be discovered safely:
@@ -1712,7 +1740,7 @@ Ask the user only for information that cannot be discovered safely:
This is the preferred durable route for a Hose-sourced tenant. Read \`hose-enterprise-init.md\`, then use:
\`\`\`bash
seal-use corps add-hose --json '{"appKey":"...","appSecurity":"..."}'
seal-use corps add-hose-persistent --json '{"appKey":"...","appSecurity":"..."}'
\`\`\`
The CLI probes the standard domains, discovers the corporation, and discovers administrator candidates. If it returns multiple candidates, show only useful identifying information and ask which person should be used; retry with \`staffName\`, \`staffPhone\`, or the selected \`staffId\` internally. After creation, run:
@@ -1728,8 +1756,8 @@ Do not ask for \`domain\`, \`corpId\`, or \`proxyStaffBizId\` up front. For a de
First distinguish the link by its host, purpose, and identity origin:
- **Seal-Native Delegation Link (默认第一公民)**: \`https://<tenant>.sealai.cc/delegate?token=...\` grants delegated access directly on a Seal tenant. Running \`seal-use corps add-link <url>\` automatically exchanges the delegation token via \`/api/v1/delegation/consume\`, receives the session, retrieves tenant and user info via \`/api/v1/auth/me\`, and registers a native Seal enterprise (\`provider: "seal"\`). Supports \`--dry-run\` to preview metadata without mutating local config.
- **Hose/合思 Assistance Link**: \`https://<domain>/web/thirdparty.html?...\` opens an upstream Hose session and continues through Seal SSO. Running standard \`seal-use corps add-link <url>\` exchanges that temporary token for a short-lived Seal Bearer token.
- **Hose Subdomain Boundary (合思子域专属提权)**: \`seal-use\` primarily manages Seal tenants. Tenants sourced from the Hose ecosystem have an upstream Hose enterprise backing them. A received Hose assistance link contains only a temporary session \`accessToken\`. To elevate to permanent Hose OpenAPI developer credentials, use \`corps hose-extract-keys <url> --save\` or \`corps add-link <url> --as-hose\`. (Note: \`--as-hose\` cannot be used on Seal-native delegation links).
- **Hose/合思 Assistance Link**: \`https://<domain>/web/thirdparty.html?...\` opens an upstream Hose session and continues through Seal SSO. Running standard \`seal-use corps add-link <url>\` verifies the tenant and stores the Hose \`closeToken\` plus \`staffId\`; the Seal Bearer is runtime-only.
- **Hose Subdomain Boundary (合思子域专属提权)**: \`seal-use\` primarily manages Seal tenants. Tenants sourced from the Hose ecosystem have an upstream Hose enterprise backing them. A received Hose assistance link contains only a temporary session \`accessToken\`. To elevate to permanent Hose OpenAPI developer credentials, use \`corps hose-extract-keys <url> --save\` or \`corps add-link <url> --elevate-hose\`. (Note: \`--elevate-hose\` cannot be used on Seal-native delegation links; \`--as-hose\` remains a deprecated compatibility alias).
- **Multi-Key Disambiguation (多套密钥明确抉择)**: If the Hose enterprise owns multiple application keys, the CLI will not guess or silently pick the first key. Instead, it terminates with an informative candidate list and requires the user to specify \`--app-key <key>\` or \`--key-id <id>\`. If only one key exists, it is selected automatically.
- **Non-Hose Tenants Blocked**: Calling \`keys\` on native Seal enterprises (\`corp.source.type !== "hose"\`) is strictly rejected with exit code 2, explaining that this capability belongs exclusively to the Hose ecosystem.
@@ -1740,7 +1768,7 @@ First distinguish the link by its host, purpose, and identity origin:
seal-use corps add-link "https://<tenant>.sealai.cc/delegate?token=..." [--name "企业名称"] [--dry-run]
# 2. 接入合思协助链接并提权为标准持久化合思企业配置:
seal-use corps add-link "<url>" --as-hose [--name "企业名称"]
seal-use corps add-link "<url>" --elevate-hose [--name "企业名称"]
# 或通过 extract-keys 提取保存:
seal-use corps hose-extract-keys "<url>" --save [--name "企业名称"]
@@ -1758,7 +1786,7 @@ seal-use corps hose-keys <corpId> [--reveal]
seal-use auth hose-keys --corp <corpId> [--reveal]
\`\`\`
When using standard \`add-link\` with a Seal delegate link, it consumes the token directly against the Seal tenant and persists the verified Seal session. When using standard \`add-link\` with a Hose link (without \`--as-hose\`), it exchanges the temporary Hose token at the target Seal tenant and stores the short-lived Seal session. When \`--as-hose\` is used on a Hose link, the CLI executes Hose subdomain privilege elevation to register a durable standard Hose configuration.
When using standard \`add-link\` with a Seal delegate link, it consumes the token directly against the Seal tenant and persists the verified Seal session. When using standard \`add-link\` with a Hose link (without \`--elevate-hose\`), it stores the Hose web-session source (\`closeToken\` plus \`staffId\`) and uses the temporary Seal Bearer only at runtime. When \`--elevate-hose\` is used on a Hose link, the CLI executes Hose subdomain privilege elevation to register a durable standard Hose configuration. The legacy \`--as-hose\` alias remains accepted for compatibility.
Assistance links are credentials. Do not follow a link merely to inspect it when the user's request was only explanatory, and never publish, log, or commit it.
@@ -1785,7 +1813,7 @@ This is functionally equivalent to a Hose assistance link. Both carry the same u
1. Treat the entire cURL as a secret. Do not echo it, execute it blindly, paste it into another service, or store it in repository files.
2. Extract: the request hostname (determines \`baseUrl\`), \`accesstoken\` header (session token), \`corpid\` header or cookie, and any other Hose session headers.
3. **Privilege elevation path (preferred)**: Use extracted \`accesstoken\`, \`corpid\`, and \`baseUrl\` to call \`/api/innerapi/v1/key\`, exactly as \`corps hose-extract-keys\` does for assistance links. This retrieves permanent \`appKey\`/\`appSecurity\` to register a durable Hose enterprise configuration — do not skip this step just because the input is a cURL instead of a URL.
4. **Fallback short-term path**: If the session user is not an administrator and the key interface returns no keys, fall back to the Seal SSO bridge to register a temporary Seal session.
4. **Fallback short-term path**: If the session user is not an administrator and the key interface returns no keys, pass the normalized Hose session to \`corps add-hose-web-session\`; it saves the Hose \`closeToken\` and \`staffId\`, then uses the Seal SSO bridge only when a Seal session is needed.
5. If key extraction succeeds, inform the user that credentials have been permanently elevated; if it fails, explain the limitation and suggest the administrator copy a dedicated cURL or provide an assistance link or \`appKey\`/\`appSecurity\`.
\`\`\`
@@ -1800,11 +1828,11 @@ This is functionally equivalent to a Hose assistance link. Both carry the same u
1. Treat the entire cURL as a secret.
2. Parse it as data. Extract the request host, path, \`Authorization: Bearer ...\` header, and provider/tenant hints.
3. Verify with \`/api/v1/auth/me\` through \`seal-use corps add-seal\`; use returned provider metadata to retain the actual origin.
3. Verify with \`/api/v1/auth/me\` through \`seal-use corps add-seal-bearer\`; use returned provider metadata to retain the actual origin.
4. Persist only the normalized minimum configuration needed by seal-use.
\`\`\`bash
seal-use corps add-seal --json '{"sealUrl":"https://target-tenant.example","token":"<bearer>"}'
seal-use corps add-seal-bearer --json '{"sealUrl":"https://target-tenant.example","token":"<bearer>"}'
\`\`\`
If the captured request contains only cookies or an authentication shape the CLI cannot verify, do not improvise a token. Ask the user to copy another successful Seal Fetch/XHR request that contains the Bearer header, or explain the current limitation.
@@ -1833,7 +1861,7 @@ seal-use auth check --corp <discovered-id> # Hose source
Report the human enterprise name, identity provider, credential method, and whether verification succeeded. Do not expose internal IDs unless they help with troubleshooting. Do not perform approval, rule, document, simulation, publishing, or other business mutations just because onboarding succeeded; continue only with the user's requested task and its normal confirmation rules.
If a temporary assistance-link or browser session expires, explain that it must be renewed or recaptured. Recommend standard Hose app credentials when the user needs durable unattended access.
`;var qS0=()=>{};var FS0=`# 第一次接入:看图找到材料
`;var bS0=()=>{};var cS0=`# 第一次接入:看图找到材料
> **【Agent 呈现铁律(Mandatory Image Rule)】**:
> 当向用户提供接入指引或引导用户获取材料时,**Agent 必须将本文档中对应的截图主动按顺序渲染到 Markdown 对话中**(使用图片语法 \`![说明](路径)\`),**绝不允许只讲纯文字步骤!** 真实业务用户必须对照图片界面才能准确找到按钮。
@@ -1906,8 +1934,10 @@ macOS 也可以使用 \`Option + Command + I\`;Windows 常见快捷键是 \`F1
助手会先判断这条请求来自合思网页还是 Seal 网页:
- **合思网页**:读取请求主机、会话令牌和企业标识。若当前登录人具备管理员权限,优先尝试把短期网页会话提升为长期 OpenAPI 凭据;否则导入为临时会话。
- **Seal 网页**:读取 Seal 主机和 Bearer 会话,验证当前租户和用户身份。
- **合思网页**:读取请求主机、Hose \`accesstoken\` 和企业标识。若当前登录人具备管理员权限,优先提取长期 OpenAPI 凭据并调用 \`add-hose-persistent\`;否则调用 \`add-hose-web-session\`,保存 Hose \`closeToken\` 与 \`staffId\`,仅在需要 Seal 能力时经 Hose→Seal SSO 换取运行时 Seal Bearer。
- **Seal 网页**:读取 Seal 主机和 Bearer 会话,整理为 \`sealUrl + token\` 后调用 \`add-seal-bearer\`。
注意:cURL 是 Agent 的输入材料,不是 \`add-link\` 的参数。\`add-link\` 只接收 Seal 委托链接或合思协助链接,并负责自动识别这两类 URL。
这些步骤由助手完成,用户不需要从 cURL 中手动寻找 token、企业 ID 或员工 ID。
@@ -1918,7 +1948,7 @@ macOS 也可以使用 \`Option + Command + I\`;Windows 常见快捷键是 \`F1
## 安全提醒
协助平台、网页登录、SSO 和浏览器 cURL 都可能携带当前用户的访问权限。只把材料交给正在处理本机接入的可信助手,并在接入完成后关闭或刷新该网页会话。不要把原始 cURL、接入密码或完整截图发送到外部渠道。
`;var LS0=()=>{};var wS0=`# Hose Enterprise Auth
`;var nS0=()=>{};var pS0=`# Hose Enterprise Auth
Use this reference for Hose/合思 enterprise configuration and user-facing Hose authorization links.
@@ -1926,16 +1956,16 @@ Use this reference for Hose/合思 enterprise configuration and user-facing Hose
Use the CLI for normal enterprise setup. Do not inspect source code or hand-edit \`~/.config/seal-use/enterprises/*.json\` unless the CLI fails or the user explicitly asks for low-level config debugging.
For first-time setup or when the user has an assistance link or browser cURL instead of standard application credentials, read \`enterprise-onboarding.md\` first. This reference's \`add-hose\` route is specifically for durable Hose OpenAPI credentials.
For first-time setup or when the user has an assistance link or browser cURL instead of standard application credentials, read \`enterprise-onboarding.md\` first. This reference's \`add-hose-persistent\` route is specifically for durable Hose OpenAPI credentials.
\`\`\`bash
seal-use corps add-hose --json '{"appKey":"...","appSecurity":"..."}'
seal-use corps add-hose-persistent --json '{"appKey":"...","appSecurity":"..."}'
seal-use corps list
seal-use corps current --corp <corpId>
seal-use corps switch <corpId>
\`\`\`
\`corps add-hose\` probes standard domains and discovers the enterprise automatically. If it returns multiple administrator candidates, present their names and masked phones for the user to choose, then retry with \`staffName\`, \`staffPhone\`, or the selected \`staffId\`. Do not ask for \`domain\`, \`corpId\`, \`staffId\`, or \`proxyStaffBizId\` before discovery. Ask for a dedicated/private-cloud \`domain\` only after standard probing fails.
\`corps add-hose-persistent\` probes standard domains and discovers the enterprise automatically. If it returns multiple administrator candidates, present their names and masked phones for the user to choose, then retry with \`staffName\`, \`staffPhone\`, or the selected \`staffId\`. Do not ask for \`domain\`, \`corpId\`, \`staffId\`, or \`proxyStaffBizId\` before discovery. Ask for a dedicated/private-cloud \`domain\` only after standard probing fails. The old \`add-hose\` spelling remains a compatibility alias.
The command verifies by default and writes the enterprise config. If the user says not to operate business logic, stop at \`corps\` and auth/config commands; do not run approval, rule, document, simulation, or approval-run commands.
@@ -1987,7 +2017,7 @@ Important:
3. BOTH a code block (\` \`\`\`text ... \`\`\` \`) for easy copying without accidental default browser redirection, AND a clickable hyperlink.
- **Dedicated CLI Command**: Use \`seal-use auth hose-link --corp <corpId> [--expire <seconds>] [--force]\`. This command directly generates an independent provisional auth link without reading or mutating internal CLI session cache. It supports \`--expire\` (default 7200, e.g. 86400 for 1 day).
- **Seal AI Platform Direct Link**: Use \`seal-use auth link --corp <corpId> [--note <note>]\`. This generates a 24-hour provisional delegation link for the Seal AI audit platform (\`https://*.sealai.cc\`).
`;var OS0=()=>{};var NS0=`# Seal AI 智能审核发布到合思费控 (HoseCloud Deployment)
`;var dS0=()=>{};var lS0=`# Seal AI 智能审核发布到合思费控 (HoseCloud Deployment)
Use this reference when configuring, deploying, or troubleshooting Seal AI smart approval integrations with Hose/合思费控 (界面路径:【智能审核】 $\\to$ 【发布】 $\\to$ 【合思费控】).
@@ -2085,7 +2115,7 @@ seal-use deploy hosecloud status --corp <corpId>
| \`signKey\` | string | 否 | 随机生成 | 集成配置卡片唯一标识,编辑时传入以更新对应配置 |
| \`apiOrigin\` | string | 否 | 自动探测 | \`production\` / \`custom\` |
| \`customApiUrl\` | string | 否 | - | 专属私有云 API 地址(当 \`apiOrigin=custom\` 时必填) |
`;var MS0=()=>{};var AS0=`# Hose Enterprise Initialization & Automated Discovery
`;var mS0=()=>{};var rS0=`# Hose Enterprise Initialization & Automated Discovery
Use this reference for automated Hose/合思 enterprise onboarding, multi-domain probing (including dedicated private cloud domains like 美年大健康), OpenAPI role and staff discovery, and non-TUI safe administrator selection.
@@ -2165,7 +2195,7 @@ seal-use corps hose-staffs --json '{
1. **若用户在初始指令中已指名(姓名或手机号)**:
\`\`\`bash
seal-use corps add-hose --json '{
seal-use corps add-hose-persistent --json '{
"appKey": "...",
"appSecurity": "...",
"staffName": "于光泽"
@@ -2174,7 +2204,7 @@ seal-use corps hose-staffs --json '{
* 系统通过角色人员列表匹配:若**唯一匹配且 \`active == true\`**,直接绑定该 \`staffId\` 完成接入。
2. **若用户未指定管理员**:
\`\`\`bash
seal-use corps add-hose --json '{
seal-use corps add-hose-persistent --json '{
"appKey": "...",
"appSecurity": "..."
}'
@@ -2184,14 +2214,14 @@ seal-use corps hose-staffs --json '{
* 只有用户明确允许自动选择时才传 \`--force\`,此时按“首位启用管理员,若无则首位候选”确定审计身份,并在结果中保留该选择。
3. **若已知目标人员 ID**:
\`\`\`bash
seal-use corps add-hose --json '{
seal-use corps add-hose-persistent --json '{
"appKey": "...",
"appSecurity": "...",
"staffId": "ID01OZVhtzekb5:ID01K9vHULqNj1"
}'
\`\`\`
* 直接使用指定 ID 完成接入并进行连通性验证。
`;var DS0=()=>{};var PS0=`# Rule Lightweight Queries
`;var oS0=()=>{};var aS0=`# Rule Lightweight Queries
Use this reference when the user wants rule counts, compact rule lists, one rule from a historical version, or approval knowledge search without dumping hundreds of rule descriptions.
@@ -2302,7 +2332,7 @@ Use current search only when the question is about current draft/current knowled
## Output Discipline
If a rule command would return many descriptions or more than about 20 rules, use \`rules count\`, \`rules list --summary\`, \`fields\`, \`snippetOnly\`, or \`--output-file\`. Use \`--full\` only for deliberate exports.
`;var BS0=()=>{};var TS0="# Seal Approval Rule Linter & Quality Validation\n\nUse this reference when analyzing, validating, or linting Seal AI approval rules to detect vague phrasing, missing exception evidence, or formatting defects before publishing.\n\n## Key Principles\n\n- **Default State**: Linter is **disabled by default** in global configuration (`lint.enabled: false`) to avoid unsolicited noise during standard operations.\n- **Doctor Visibility**: `seal-use doctor` audits the rule linter configuration state and active linter name in its health checks, and surfaces a one-click hint (`seal-use config lint enable`) when disabled.\n- **Explicit Triggering**: `seal-use rules lint` always runs regardless of global configuration.\n- **Draft Hook**: When `seal-use config lint enable` is set, `seal_approval_rule_update` outputs real-time diagnostic warnings to `stderr` without mutating `stdout` payloads.\n- **Fault-Tolerant Fallback**: If a custom `.ts` linter file has syntax errors, runtime exceptions, or is missing, the engine logs a warning to `stderr` and **silently falls back to the built-in heuristic linter without failing**.\n\n## CLI Commands\n\n### 1. Lint Current Draft Rules (Whole-RuleSet Scan)\n\n```bash\nseal-use rules lint --corp <corpId>\n```\n\n### 2. Lint Specific Historical Version or Single Rule\n\n```bash\n# Lint rules in published version 16\nseal-use rules lint --version 16 --corp <corpId>\n\n# Lint a specific rule by code (#0038)\nseal-use rules lint --code '#0038' --corp <corpId>\n\n# Summary mode (only show rules with issues)\nseal-use rules lint --summary --corp <corpId>\n```\n\n### 3. Quality Gate for CI / Release\n\n```bash\n# If overall score is below 85, terminates with exit code 1\nseal-use rules lint --min-score 85 --level error --corp <corpId>\n```\n\n### 4. Configure Global Linter Settings\n\n```bash\n# Check status\nseal-use config lint status\n\n# Enable auto lint on rule updates\nseal-use config lint enable --linter builtin --min-score 80\n\n# Disable auto lint\nseal-use config lint disable\n```\n\n## Official Linters\n\n| Linter Name | Scope & Purpose | Aliases |\n| :--- | :--- | :--- |\n| `builtin` | Seal 官方标准校验器:拦截过短描述、主观模糊词与悬空例外条款。 | `default`, `official/builtin` |\n| `strict` | Seal 官方严格风控校验器:强校验字数、刚性定量约束、凭证依据与具体审批人角色。 | `official/strict` |\n| `hlab` | 合思实验室 (HLab) 结构化规则校验器:SOP 四段论结构、三元闭环判定、剥离处置动作与防漏判。 | `hlab-sop`, `hlab-rules`, `hlab-standard`, `official/hlab` |\n\n```bash\n# Inspect available linters\nseal-use rules linters\n\n# Lint rules using HLab SOP standard\nseal-use rules lint --linter hlab --corp <corpId>\n\n# Lint local rule workspace offline with HLab standard\nseal-use rules lint --linter hlab --file ./rules.local.json\n```\n\n## Built-In Detection Rules (`builtin`)\n\n| Code | Level | Description | Recommendation |\n| :--- | :---: | :--- | :--- |\n| `TOO_SHORT` | `error` | Rule description is under 5 characters. | Add concrete conditions and criteria. |\n| `VAGUE_WORD` | `error` | Contains subjective/fuzziness words (`原则上`, `尽量`, `适当`, `酌情`, `一般情况下`, `合理控制`). | Replace with rigid thresholds, enums, or criteria. |\n| `HANGING_EXCEPTION` | `warning` | Exception trigger found (`除非`, `特殊情况`, `经批准`) without verifiable evidence keyword (`备注`, `附件`, `证明`, `邮件`, `截图`). | Specify exact evidence source in invoice/document. |\n\n## HLab SOP Detection Rules (`hlab`)\n\n| Code | Level | Description | Recommendation |\n| :--- | :---: | :--- | :--- |\n| `MISSING_CHECK_METHOD` | `error` | Missing `**检查方法**` section in rule description. | Add `**检查方法**:` specifying fields, vouchers, and normalization logic. |\n| `MISSING_EVAL_STANDARD` | `error` | Missing `**判定标准**` section in rule description. | Add `**判定标准**:` with standard branches. |\n| `INCOMPLETE_TERNARY_BRANCH` | `error` | Incomplete ternary branch under evaluation criteria (missing `PASS`, `FAIL`, or `证据不足`). | Provide complete ternary closure: `- PASS:`, `- FAIL:`, `- 证据不足:`. |\n| `INSUFFICIENT_WITHOUT_MANUAL_REVIEW` | `warning` | `证据不足` branch does not specify escalating to `人工复核`. | Add `转人工复核` at the end of `证据不足` branch. |\n| `DISPOSAL_ACTION_LEAK` | `warning` | Contains whole-bill workflow disposal actions (`驳回单据`, `直接驳回`, `进行提醒`, `退回单据`). | Decouple disposal actions from rule text; rely on rule strictness or platform workflow. |\n| `SCOPE_FALSE_SKIP_PRONE` | `warning` | Scope contains material upload conditions (`若上传了`, `若提供了`, `附件需上传`). | Keep scope pure to business triggers; handle missing materials explicitly in FAIL branch to prevent silent SKIP. |\n| `RISK_SUPPRESSION` | `erroLine truncated
`;var sS0=()=>{};var eS0="# Seal Approval Rule Linter & Quality Validation\n\nUse this reference when analyzing, validating, or linting Seal AI approval rules to detect vague phrasing, missing exception evidence, or formatting defects before publishing.\n\n## Key Principles\n\n- **Default State**: Linter is **disabled by default** in global configuration (`lint.enabled: false`) to avoid unsolicited noise during standard operations.\n- **Doctor Visibility**: `seal-use doctor` audits the rule linter configuration state and active linter name in its health checks, and surfaces a one-click hint (`seal-use config lint enable`) when disabled.\n- **Explicit Triggering**: `seal-use rules lint` always runs regardless of global configuration.\n- **Draft Hook**: When `seal-use config lint enable` is set, `seal_approval_rule_update` outputs real-time diagnostic warnings to `stderr` without mutating `stdout` payloads.\n- **Fault-Tolerant Fallback**: If a custom `.ts` linter file has syntax errors, runtime exceptions, or is missing, the engine logs a warning to `stderr` and **silently falls back to the built-in heuristic linter without failing**.\n\n## CLI Commands\n\n### 1. Lint Current Draft Rules (Whole-RuleSet Scan)\n\n```bash\nseal-use rules lint --corp <corpId>\n```\n\n### 2. Lint Specific Historical Version or Single Rule\n\n```bash\n# Lint rules in published version 16\nseal-use rules lint --version 16 --corp <corpId>\n\n# Lint a specific rule by code (#0038)\nseal-use rules lint --code '#0038' --corp <corpId>\n\n# Summary mode (only show rules with issues)\nseal-use rules lint --summary --corp <corpId>\n```\n\n### 3. Quality Gate for CI / Release\n\n```bash\n# If overall score is below 85, terminates with exit code 1\nseal-use rules lint --min-score 85 --level error --corp <corpId>\n```\n\n### 4. Configure Global Linter Settings\n\n```bash\n# Check status\nseal-use config lint status\n\n# Enable auto lint on rule updates\nseal-use config lint enable --linter builtin --min-score 80\n\n# Disable auto lint\nseal-use config lint disable\n```\n\n## Official Linters\n\n| Linter Name | Scope & Purpose | Aliases |\n| :--- | :--- | :--- |\n| `builtin` | Seal 官方标准校验器:拦截过短描述、主观模糊词与悬空例外条款。 | `default`, `official/builtin` |\n| `strict` | Seal 官方严格风控校验器:强校验字数、刚性定量约束、凭证依据与具体审批人角色。 | `official/strict` |\n| `hlab` | 合思实验室 (HLab) 结构化规则校验器:SOP 四段论结构、三元闭环判定、剥离处置动作与防漏判。 | `hlab-sop`, `hlab-rules`, `hlab-standard`, `official/hlab` |\n\n```bash\n# Inspect available linters\nseal-use rules linters\n\n# Lint rules using HLab SOP standard\nseal-use rules lint --linter hlab --corp <corpId>\n\n# Lint local rule workspace offline with HLab standard\nseal-use rules lint --linter hlab --file ./rules.local.json\n```\n\n## Built-In Detection Rules (`builtin`)\n\n| Code | Level | Description | Recommendation |\n| :--- | :---: | :--- | :--- |\n| `TOO_SHORT` | `error` | Rule description is under 5 characters. | Add concrete conditions and criteria. |\n| `VAGUE_WORD` | `error` | Contains subjective/fuzziness words (`原则上`, `尽量`, `适当`, `酌情`, `一般情况下`, `合理控制`). | Replace with rigid thresholds, enums, or criteria. |\n| `HANGING_EXCEPTION` | `warning` | Exception trigger found (`除非`, `特殊情况`, `经批准`) without verifiable evidence keyword (`备注`, `附件`, `证明`, `邮件`, `截图`). | Specify exact evidence source in invoice/document. |\n\n## HLab SOP Detection Rules (`hlab`)\n\n| Code | Level | Description | Recommendation |\n| :--- | :---: | :--- | :--- |\n| `MISSING_CHECK_METHOD` | `error` | Missing `**检查方法**` section in rule description. | Add `**检查方法**:` specifying fields, vouchers, and normalization logic. |\n| `MISSING_EVAL_STANDARD` | `error` | Missing `**判定标准**` section in rule description. | Add `**判定标准**:` with standard branches. |\n| `INCOMPLETE_TERNARY_BRANCH` | `error` | Incomplete ternary branch under evaluation criteria (missing `PASS`, `FAIL`, or `证据不足`). | Provide complete ternary closure: `- PASS:`, `- FAIL:`, `- 证据不足:`. |\n| `INSUFFICIENT_WITHOUT_MANUAL_REVIEW` | `warning` | `证据不足` branch does not specify escalating to `人工复核`. | Add `转人工复核` at the end of `证据不足` branch. |\n| `DISPOSAL_ACTION_LEAK` | `warning` | Contains whole-bill workflow disposal actions (`驳回单据`, `直接驳回`, `进行提醒`, `退回单据`). | Decouple disposal actions from rule text; rely on rule strictness or platform workflow. |\n| `SCOPE_FALSE_SKIP_PRONE` | `warning` | Scope contains material upload conditions (`若上传了`, `若提供了`, `附件需上传`). | Keep scope pure to business triggers; handle missing materials explicitly in FAIL branch to prevent silent SKIP. |\n| `RISK_SUPPRESSION` | `erroLine truncated
本文档面向 AI Agent 与运维人员,规范从**生产/测试环境搭配接入**、**配置与合思集成自动同步**、**测试环境单据模拟验证**,到**生产规则安全投产**的端到端标准工作流。
@@ -2365,7 +2395,7 @@ flowchart TD
识别生产企业(\`sourceType: "hose"\` 或 \`"seal"\`)与测试企业(如专用的测试环境)。
3. **如果尚未接入企业**:
- 合思标准凭证接入生产企业:\`seal-use corps add-hose --json '{"appKey":"...","appSecurity":"...","domain":"..."}'\`
- 合思标准凭证接入生产企业:\`seal-use corps add-hose-persistent --json '{"appKey":"...","appSecurity":"...","domain":"..."}'\`
- 或通过协助链接接入:\`seal-use corps add-link <url>\`
4. **环境严格标记与 1 对 1 绑定**:
@@ -2517,10 +2547,10 @@ flowchart TD
seal-use tool seal_approval_rules_publish --corp <prodCorpId> --json '{"versionName":"审核规则 版本N"}'
\`\`\`
发布后核实版本状态,完成业务安全闭环。
`;var ES0=()=>{};var Wy1="iVBORw0KGgoAAAANSUhEUgAADVgAAAdwCAYAAACUWcTmAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAANWKADAAQAAAABAAAHcAAAAAD4n9OGAABAAElEQVR4AeydB4AdVfX/z246pNAD0hK6dOki0rsU+dMJJVIFRYoUFUFAQUCqgHSkxx8gTRCpFkB6CU06SQi9BEhC+u7/fu7b83J3dt7bt33f5nuStzNz5947M583c+fOvPO9p6Y+mMlEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREYA4kUDsHHrMOWQREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAQigd7jxo8TChEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYIwkogtUc+bXroEVABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABCBQUx9MKERABERABERABERABERABERABERABERABERABERABERABERABESgqwiMHz/eBgwY0FWb13ZFQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQATmcAKKYDWHnwA6fBEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYkwlIYDUnf/s6dhEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYwwlIYDWHnwA6fBEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYkwlIYDUnf/s6dhEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYwwlIYDWHnwA6fBEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYkwn0npMPXscuAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAj2RwP8+n26vfjbd3vpyho2fPN0+mjLTJs+qs/qaOhvYp8YWGtDLFh/U25YZ3NdWnr+/rTDvgJ6IQcckAhURqKkPVlFOZRIBERABERABERABERABERABERABERABERABERABERABERABERCBDiAwfvx4GzBAP9p2AFpVKQIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiMIcR+GhSnT347lT713tT7eOpM4OYqj5+LEzNEFdZ+MyKU5Zr4jLp9fat/r1ss28NtM0WG2KLzN1nDiOnw53TCUhgNaefATp+ERABERABERABERABERABERABERABERABERABERABERABEehiAhJYdfEXoM2LgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAhUPYFJ08z+7+Updsc7U8OxFARURKqyIKAqCKnqbVYQUdU2CK7iOiuIr4oirLBcgxArfHZZcrDttcwCNnefXlXPRgcgApUQkMCqEkrKIwIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIi0GEEJLDqMLSqWAREQAREQAREQAREQAREQAREQAREQAREQAREQAREYA4g8MR7M+2Cp6fY5JmFSFQhRlUQStUVBVUsF0VUCKiSSFZEsKqLkawa5yH/oN5mP195qK0/dPAcQFGHOKcTkMBqTj8DdPwiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIi0MUEJLDq4i+gCzY/ZcqUuNUBAwZ0wda1SREQAREQAREQAREQAREQAREQAREQAREQAREQARHoHAKd8S501AszbNT/psXIUwWhVDi2IK6qj5GriGRVEE4RlSoVWlUayYry+w2fx0Yst1DnQNNWRKCLCAQ9oUwEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAERKCaCFz035n20JgZ1stqQowqs9qaWmJVBR1VbRBZkdLLakN0qiCzCtMGgVXMURfW1YQsTHsFEdasMC0UCSWjOIvcbte++6V9MX2mHb7ytzypS6e/+93v7H//+1/uPuy888727W9/O35yMyhRBEoQ4NyXiYAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiECPIXDbbbfZiBEjGh0PP7aSxif90dXzks68G3k8P2VTYznNm67TvAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAh0BoGLHp1lD74zM6qh6kK4qprwqW+YMl9TR1pYHcRWtUFHhZaqLi6TFsJbhflCOYRVtbG818H6+KGOhnr+9v4ku/DlDzrj0Mpug/fz6Xv+bOa//vWvxkcmAi0loAhWLSWm/CIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAt2WAD+sdvQPp/xwy0cjYHbb00A7JgIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAI9msCo5+rt4XdDVKoaIlfVxChVHHCMPtXoyIO4KuSoy0ayqifOFeWJUxVqSCJZfW/hwfbox1/FuqiKHF4zIqt5+39qey+zYEztij/pbwC8p0/NhVc+TddpXgSaIyCBVXOEtF4EREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAERKBqCLz66qudtq/8iPvrX/+607aX3VBniMluvPHG7Ga1LAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiUIJAzT+vi2vqN9m3RA4li0DbCTw5xuyWl+qMIFQWIk8Rpqo+Cq1YDlKokL7m4v2D7IrFOgurwvqwoiaEsIpyKebNHv9wki+FdERaSKlq7fytlrEj73vLHvvoq7gNUkM4q1BPKBTque7tCbbUoH62/tDBrOkyQ1yVfUf/u9/9rmx0qy7b2VZu2H8H4FhXXHFF+3//7/+1siYVq4RATX2wSjIqjwiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAh0BIHx48fbgAEDOqLqHlun/6ja0QfYUQKrKVOmxF3X997R36DqFwEREAEREAEREAEREAEREAEREAEREAER6EwCs074btxcr9Me78zNalvdmEB7vwudNM3ssFvNJs2oi0KqWUE0FQVUUUiF6KreLtx5QVtt0X5lqYz+cIodevfYkKcg1KpHfBXKHvadobbvdxay0R9NsgPveyOsD3KTWiQniLjCNHyYDgqhfq7bcCmbu0+vsttpy0rEUlgqLErfje+8885NBEepwMrXE83Ko16ldbVl3zqjbHqsvj0EZdmoXb5O07YTUASrtjNUDSIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiLQqQQ6M1JXpx5YD96Yj3sZR3ntwcdZyaHNmDHDPv74Y1t00UULo95WUqiL8syaNct69eo4J5EuOqwu3Szff58+fZrsg66RJkiU0MkEGJ4YhzSZCHQmAdpEjHtNbW0Ydb4djHvX9OnTNYBBA0ucWfv169dufNvhK+oxVUydOtXq6upsrrnm6jHHpAMRAREQAREQgbYS8OhV1FN/1VFWc8B5ba2yWJ6+45gxY+ytt96y/v3729JLL22LLbZYbj+H9y4u6ilWUGJm7rnntgUXXDCu/frrr+2LL74okbNxMv3XJZZYonFia5fGjLaad0e3tnSx3JwSNezmZ2ts8vQQTSr8C9KoOA2Sp8ChJvyttQPXG9SsuMqh1VEslIviqTBdf5G5o7iK1NUWHmg/XW1Ru/iF960+aK8QVbE1j2SFwOumtz6zg749lOztbqlQygVSCIuYL2cIqDwPoirepfsy5ZgnLRv5qlydXbUu73cAjqka9h1mCMSw1kbdamv5uPEW/pHAqoXAlF0EREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEuppA+oNwR0WZ6upj7Enbf+ONN+yUU06Jh3Tsscfa6quv3pMOLx7Lhx9+aMcff3yc33vvvW3LLbfMPcZbbrnF7rjjjrjuF7/4ha2yyiq5+dLEyZMn24QJE2zhhRe23r1720svvWTnn39+zPLLX/7SlllmmTR77jyORb/61a/iuv3339++973v5eZLE99++2076aSTbNlll7UtttiiojJp+WqZHz16dBQ84XziNnPmTPv00099sUVTHLMGDx6cW2bcuHHRAWSzzTazHXfc0eaZZ56Y7/HHH7eLLroozh933HG21FJL2Zlnnmm77LJLm6+Xb775xr766qvc/ckmzjvvvNFJLZveluWzzz7b3nrzTVty2DDjfG2JTZs2ze677z7bZpttGonSvvzyy4od5bLb4zqqJqHnxxNmWcHZK3skLV/u16fG5huUL2B5cPRUO Line truncated
`,"utf8"),{detected:U,configured:!0,configPath:z,targetDir:Y,action:"created"};let Q={};try{Q=JSON.parse(vS0(z,"utf8"))}catch{Q={entries:[]}}if(!Array.isArray(Q.entries))Q.entries=[];if(Q.entries.findIndex((K)=>K&&typeof K.path==="string"&&K.path===Y)!==-1)return{detected:U,configured:!0,configPath:z,targetDir:Y,action:"already_present"};let I=Q.entries.findIndex((K)=>K&&typeof K.path==="string"&&(K.path==="~/.agents/skills"||K.path==="~/.agents/skills/"));if(I!==-1)return Q.entries[I]={...Q.entries[I],path:Y},Fo(z,JSON.stringify(Q,null,2)+`
`,"utf8"),{detected:U,configured:!0,configPath:z,targetDir:Y,action:"updated_tilde"};return Q.entries.unshift({path:Y}),Fo(z,JSON.stringify(Q,null,2)+`
`,"utf8"),{detected:U,configured:!0,configPath:z,targetDir:Y,action:"prepended"}}function Mo($){let Y=$?.targetSkillsDir??hS0(),z=$?.configFile??SS0(),U=gS0(),Q=!1;if(hq(z))try{let J=JSON.parse(vS0(z,"utf8"));if(Array.isArray(J?.entries))Q=J.entries.some((I)=>I?.path===Y)}catch{}return{detected:U,configured:Q,configPath:z,targetDir:Y}}var No=()=>{};import{cpSync as wy1,existsSync as nK,lstatSync as kS0,mkdirSync as My1,realpathSync as $Y,rmSync as Ny1,symlinkSync as Dy1,unlinkSync as yS0}from"node:fs";import{homedir as xS0}from"node:os";import{dirname as fS0,join as YY}from"node:path";function Ay1($,Y){let z=Y?.baseHomeDir??xS0(),U=YY(z,$.rootDirName),Q=Y?.sourceSkillDir??YY(z,".agents","skills","seal-use"),J=fS0(Q),I=YY(U,"skills"),K=YY(I,"seal-use");if(!nK(U))return{id:$.id,name:$.name,detected:!1,configured:!1,mode:"skipped_not_detected"};if(nK(I)&&nK(J))try{if($Y(I)===$Y(J))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"parent_symlinked",targetPath:I}}catch{}My1(I,{recursive:!0});let G;try{G=kS0(K)}catch{G=void 0}let H=!1;if(G)if(G.isSymbolicLink()){try{if($Y(K)===$Y(Q))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"already_linked",targetPath:K}}catch{}try{yS0(K)}catch{}}else if(G.isDirectory())Ny1(K,{recursive:!0,force:!0}),H=!0;else yS0(K);let W=process.platform==="win32"?"junction":"dir";try{return Dy1(Q,K,W),{id:$.id,name:$.name,detected:!0,configured:!0,mode:H?"replaced_real_dir":"linked",targetPath:K}}catch{try{return wy1(Q,K,{recursive:!0}),{id:$.id,name:$.name,detected:!0,configured:!0,mode:"fallback_copied",targetPath:K}}catch(X){return{id:$.id,name:$.name,detected:!0,configured:!1,mode:"error",targetPath:K,error:X?.message||String(X)}}}}function By1($,Y){let z=Y?.baseHomeDir??xS0(),U=YY(z,$.rootDirName),Q=Y?.sourceSkillDir??YY(z,".agents","skills","seal-use"),J=fS0(Q),I=YY(U,"skills"),K=YY(I,"seal-use");if(!nK(U))return{id:$.id,name:$.name,detected:!1,configured:!1,mode:"not_detected"};if(nK(I)&&nK(J))try{if($Y(I)===$Y(J))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"parent_symlinked",targetPath:I}}catch{}let G;try{G=kS0(K)}catch{G=void 0}if(G){if(G.isSymbolicLink())try{if($Y(K)===$Y(Q))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"single_symlinked",targetPath:K}}catch{}else if(G.isDirectory())return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"real_directory",targetPath:K}}return{id:$.id,name:$.name,detected:!0,configured:!1,mode:"not_configured",targetPath:K}}function Do($){return uS0.map((Y)=>Ay1(Y,$))}function Ao($){return uS0.map((Y)=>By1(Y,$))}var uS0;var Bo=m(()=>{uS0=[{id:"workbuddy",name:"WorkBuddy",rootDirName:".workbuddy"},{id:"claude",name:"Claude",rootDirName:".claude"},{id:"qoder",name:"Qoder",rootDirName:".qoder"}]});var Po=m(()=>{No();Bo();No();Bo()});import{existsSync as Py1,mkdirSync as jo,readFileSync as jy1,rmSync as Ty1,writeFileSync as bS0}from"node:fs";import{homedir as nS0}from"node:os";import{dirname as iS0,join as gq}from"node:path";function To(){return cS0["SKILL.md"]||""}function pS0($){return $.match(/^\s*version:\s*(\S+)\s*$/m)?.[1]}function dS0($=gq(bU(),"SKILL.md")){try{return pS0(jy1($,"utf8"))}catch{return}}function bU(){return gq(nS0(),".agents","skills","seal-use")}function Cy1(){return gq(nS0(),".agents","skills","seal-home")}function Ry1(){let $=Cy1();if(Py1($))try{return Ty1($,{recursive:!0,force:!0}),!0}catch{return!1}return!1}function mS0($=bU()){Ry1(),jo($,{recursive:!0});let Y=[];for(let[z,U]of Object.entries(cS0)){let Q=gq($,z);jo(iS0(Q),{recursive:!0}),bS0(Q,U,"utf8"),Y.push(z)}for(let[z,U]of Object.entries(Ey1)){let Q=gq($,z);jo(iS0(Q),{recursive:!0}),bS0(Q,U),Y.push(z)}return{targetDir:$,files:Y}}var cS0,Ey1,xY4;var yq=m(()=>{Lo();Lo();Po();cS0=RS0,Ey1=Object.fromEntries(Object.entries(_S0).map(([$,Y])=>[$,Buffer.from(Y,"base64")]));xY4=pS0(To())});function lS0(){return`# Seal Use 系统架构与运行规范白皮书
`;var $g0=()=>{};var iy1="iVBORw0KGgoAAAANSUhEUgAADVgAAAdwCAYAAACUWcTmAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAANWKADAAQAAAABAAAHcAAAAAD4n9OGAABAAElEQVR4AeydB4AdVfX/z246pNAD0hK6dOki0rsU+dMJJVIFRYoUFUFAQUCqgHSkxx8gTRCpFkB6CU06SQi9BEhC+u7/fu7b83J3dt7bt33f5nuStzNz5947M583c+fOvPO9p6Y+mMlEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREYA4kUDsHHrMOWQREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAQigd7jxo8TChEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYIwkogtUc+bXroEVABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABCBQUx9MKERABERABERABERABERABERABERABERABERABERABERABERABESgqwiMHz/eBgwY0FWb13ZFQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQATmcAKKYDWHnwA6fBEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYkwlIYDUnf/s6dhEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYwwlIYDWHnwA6fBEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYkwlIYDUnf/s6dhEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYwwlIYDWHnwA6fBEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYkwn0npMPXscuAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAj2RwP8+n26vfjbd3vpyho2fPN0+mjLTJs+qs/qaOhvYp8YWGtDLFh/U25YZ3NdWnr+/rTDvgJ6IQcckAhURqKkPVlFOZRIBERABERABERABERABERABERABERABERABERABERABERABERCBDiAwfvx4GzBAP9p2AFpVKQIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiMIcR+GhSnT347lT713tT7eOpM4OYqj5+LEzNEFdZ+MyKU5Zr4jLp9fat/r1ss28NtM0WG2KLzN1nDiOnw53TCUhgNaefATp+ERABERABERABERABERABERABERABERABERABERABERABEehiAhJYdfEXoM2LgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAhUPYFJ08z+7+Updsc7U8OxFARURKqyIKAqCKnqbVYQUdU2CK7iOiuIr4oirLBcgxArfHZZcrDttcwCNnefXlXPRgcgApUQkMCqEkrKIwIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIi0GEEJLDqMLSqWAREQAREQAREQAREQAREQAREQAREQAREQAREQAREYA4g8MR7M+2Cp6fY5JmFSFQhRlUQStUVBVUsF0VUCKiSSFZEsKqLkawa5yH/oN5mP195qK0/dPAcQFGHOKcTkMBqTj8DdPwiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIi0MUEJLDq4i+gCzY/ZcqUuNUBAwZ0wda1SREQAREQAREQAREQAREQAREQAREQAREQAREQARHoHAKd8S501AszbNT/psXIUwWhVDi2IK6qj5GriGRVEE4RlSoVWlUayYry+w2fx0Yst1DnQNNWRKCLCAQ9oUwEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAERKCaCFz035n20JgZ1stqQowqs9qaWmJVBR1VbRBZkdLLakN0qiCzCtMGgVXMURfW1YQsTHsFEdasMC0UCSWjOIvcbte++6V9MX2mHb7ytzypS6e/+93v7H//+1/uPuy888727W9/O35yMyhRBEoQ4NyXiYAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiECPIXDbbbfZiBEjGh0PP7aSxif90dXzks68G3k8P2VTYznNm67TvAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAh0BoGLHp1lD74zM6qh6kK4qprwqW+YMl9TR1pYHcRWtUFHhZaqLi6TFsJbhflCOYRVtbG818H6+KGOhnr+9v4ku/DlDzrj0Mpug/fz6Xv+bOa//vWvxkcmAi0loAhWLSWm/CIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAt2WAD+sdvQPp/xwy0cjYHbb00A7JgIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAI9msCo5+rt4XdDVKoaIlfVxChVHHCMPtXoyIO4KuSoy0ayqifOFeWJUxVqSCJZfW/hwfbox1/FuqiKHF4zIqt5+39qey+zYEztij/pbwC8p0/NhVc+TddpXgSaIyCBVXOEtF4EREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAERKBqCLz66qudtq/8iPvrX/+607aX3VBniMluvPHG7Ga1LAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiUIJAzT+vi2vqN9m3RA4li0DbCTw5xuyWl+qMIFQWIk8Rpqo+Cq1YDlKokL7m4v2D7IrFOgurwvqwoiaEsIpyKebNHv9wki+FdERaSKlq7fytlrEj73vLHvvoq7gNUkM4q1BPKBTque7tCbbUoH62/tDBrOkyQ1yVfUf/u9/9rmx0qy7b2VZu2H8H4FhXXHFF+3//7/+1siYVq4RATX2wSjIqjwiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAh0BIHx48fbgAEDOqLqHlun/6ja0QfYUQKrKVOmxF3X997R36DqFwEREAEREAEREAEREAEREAEREAEREAER6EwCs074btxcr9Me78zNalvdmEB7vwudNM3ssFvNJs2oi0KqWUE0FQVUUUiF6KreLtx5QVtt0X5lqYz+cIodevfYkKcg1KpHfBXKHvadobbvdxay0R9NsgPveyOsD3KTWiQniLjCNHyYDgqhfq7bcCmbu0+vsttpy0rEUlgqLErfje+8885NBEepwMrXE83Ko16ldbVl3zqjbHqsvj0EZdmoXb5O07YTUASrtjNUDSIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiLQqQQ6M1JXpx5YD96Yj3sZR3ntwcdZyaHNmDHDPv74Y1t00UULo95WUqiL8syaNct69eo4J5EuOqwu3Szff58+fZrsg66RJkiU0MkEGJ4YhzSZCHQmAdpEjHtNbW0Ydb4djHvX9OnTNYBBA0ucWfv169dufNvhK+oxVUydOtXq6upsrrnm6jHHpAMRAREQAREQgbYS8OhV1FN/1VFWc8B5ba2yWJ6+45gxY+ytt96y/v3729JLL22LLbZYbj+H9y4u6ilWUGJm7rnntgUXXDCu/frrr+2LL74okbNxMv3XJZZYonFia5fGjLaad0e3tnSx3JwSNezmZ2ts8vQQTSr8C9KoOA2Sp8ChJvyttQPXG9SsuMqh1VEslIviqTBdf5G5o7iK1NUWHmg/XW1Ru/iF960+aK8QVbE1j2SFwOumtz6zg749lOztbqlQygVSCIuYL2cIqDwPoirepfsy5ZgnLRv5qlydXbUu73cAjqka9h1mCMSw1kbdamv5uPEW/pHAqoXAlF0EREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEuppA+oNwR0WZ6upj7Enbf+ONN+yUU06Jh3Tsscfa6quv3pMOLx7Lhx9+aMcff3yc33vvvW3LLbfMPcZbbrnF7rjjjrjuF7/4ha2yyiq5+dLEyZMn24QJE2zhhRe23r1720svvWTnn39+zPLLX/7SlllmmTR77jyORb/61a/iuv3339++973v5eZLE99++2076aSTbNlll7UtttiiojJp+WqZHz16dBQ84XziNnPmTPv00099sUVTHLMGDx6cW2bcuHHRAWSzzTazHXfc0eaZZ56Y7/HHH7eLLroozh933HG21FJL2Zlnnmm77LJLm6+Xb775xr766qvc/ckmzjvvvNFJLZveluWzzz7b3nrzTVty2DDjfG2JTZs2ze677z7bZpttGonSvvzyy4od5bLb4zqqJqHnxxNmWcHZK3skLV/u16fG5huUL2B5cPRUO Line truncated
`,"utf8"),{detected:z,configured:!0,configPath:Y,targetDir:U,action:"created"};let I={};try{I=JSON.parse(Ig0(Y,"utf8"))}catch{I={entries:[]}}if(!Array.isArray(I.entries))I.entries=[];if(I.entries.findIndex((K)=>K&&typeof K.path==="string"&&K.path===U)!==-1)return{detected:z,configured:!0,configPath:Y,targetDir:U,action:"already_present"};let J=I.entries.findIndex((K)=>K&&typeof K.path==="string"&&(K.path==="~/.agents/skills"||K.path==="~/.agents/skills/"));if(J!==-1)return I.entries[J]={...I.entries[J],path:U},Co(Y,JSON.stringify(I,null,2)+`
`,"utf8"),{detected:z,configured:!0,configPath:Y,targetDir:U,action:"updated_tilde"};return I.entries.unshift({path:U}),Co(Y,JSON.stringify(I,null,2)+`
`,"utf8"),{detected:z,configured:!0,configPath:Y,targetDir:U,action:"prepended"}}function vo($){let U=$?.targetSkillsDir??Qg0(),Y=$?.configFile??Jg0(),z=Kg0(),I=!1;if(fq(Y))try{let Q=JSON.parse(Ig0(Y,"utf8"));if(Array.isArray(Q?.entries))I=Q.entries.some((J)=>J?.path===U)}catch{}return{detected:z,configured:I,configPath:Y,targetDir:U}}var ho=()=>{};import{cpSync as ry1,existsSync as cK,lstatSync as Hg0,mkdirSync as sy1,realpathSync as $U,rmSync as ay1,symlinkSync as ty1,unlinkSync as Gg0}from"node:fs";import{homedir as Wg0}from"node:os";import{dirname as Xg0,join as UU}from"node:path";function ey1($,U){let Y=U?.baseHomeDir??Wg0(),z=UU(Y,$.rootDirName),I=U?.sourceSkillDir??UU(Y,".agents","skills","seal-use"),Q=Xg0(I),J=UU(z,"skills"),K=UU(J,"seal-use");if(!cK(z))return{id:$.id,name:$.name,detected:!1,configured:!1,mode:"skipped_not_detected"};if(cK(J)&&cK(Q))try{if($U(J)===$U(Q))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"parent_symlinked",targetPath:J}}catch{}sy1(J,{recursive:!0});let G;try{G=Hg0(K)}catch{G=void 0}let H=!1;if(G)if(G.isSymbolicLink()){try{if($U(K)===$U(I))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"already_linked",targetPath:K}}catch{}try{Gg0(K)}catch{}}else if(G.isDirectory())ay1(K,{recursive:!0,force:!0}),H=!0;else Gg0(K);let W=process.platform==="win32"?"junction":"dir";try{return ty1(I,K,W),{id:$.id,name:$.name,detected:!0,configured:!0,mode:H?"replaced_real_dir":"linked",targetPath:K}}catch{try{return ry1(I,K,{recursive:!0}),{id:$.id,name:$.name,detected:!0,configured:!0,mode:"fallback_copied",targetPath:K}}catch(X){return{id:$.id,name:$.name,detected:!0,configured:!1,mode:"error",targetPath:K,error:X?.message||String(X)}}}}function $k1($,U){let Y=U?.baseHomeDir??Wg0(),z=UU(Y,$.rootDirName),I=U?.sourceSkillDir??UU(Y,".agents","skills","seal-use"),Q=Xg0(I),J=UU(z,"skills"),K=UU(J,"seal-use");if(!cK(z))return{id:$.id,name:$.name,detected:!1,configured:!1,mode:"not_detected"};if(cK(J)&&cK(Q))try{if($U(J)===$U(Q))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"parent_symlinked",targetPath:J}}catch{}let G;try{G=Hg0(K)}catch{G=void 0}if(G){if(G.isSymbolicLink())try{if($U(K)===$U(I))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"single_symlinked",targetPath:K}}catch{}else if(G.isDirectory())return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"real_directory",targetPath:K}}return{id:$.id,name:$.name,detected:!0,configured:!1,mode:"not_configured",targetPath:K}}function So($){return Zg0.map((U)=>ey1(U,$))}function go($){return Zg0.map((U)=>$k1(U,$))}var Zg0;var yo=m(()=>{Zg0=[{id:"workbuddy",name:"WorkBuddy",rootDirName:".workbuddy"},{id:"claude",name:"Claude",rootDirName:".claude"},{id:"qoder",name:"Qoder",rootDirName:".qoder"}]});var ko=m(()=>{ho();yo();ho();yo()});import{existsSync as Uk1,mkdirSync as xo,readFileSync as Yk1,rmSync as zk1,writeFileSync as qg0}from"node:fs";import{homedir as Lg0}from"node:os";import{dirname as Vg0,join as bq}from"node:path";function fo(){return wg0["SKILL.md"]||""}function Fg0($){return $.match(/^\s*version:\s*(\S+)\s*$/m)?.[1]}function Mg0($=bq(iz(),"SKILL.md")){try{return Fg0(Yk1($,"utf8"))}catch{return}}function iz(){return bq(Lg0(),".agents","skills","seal-use")}function Qk1(){return bq(Lg0(),".agents","skills","seal-home")}function Jk1(){let $=Qk1();if(Uk1($))try{return zk1($,{recursive:!0,force:!0}),!0}catch{return!1}return!1}function Og0($=iz()){Jk1(),xo($,{recursive:!0});let U=[];for(let[Y,z]of Object.entries(wg0)){let I=bq($,Y);xo(Vg0(I),{recursive:!0}),qg0(I,z,"utf8"),U.push(Y)}for(let[Y,z]of Object.entries(Ik1)){let I=bq($,Y);xo(Vg0(I),{recursive:!0}),qg0(I,z),U.push(Y)}return{targetDir:$,files:U}}var wg0,Ik1,Oz4;var iq=m(()=>{Eo();Eo();ko();wg0=Yg0,Ik1=Object.fromEntries(Object.entries(zg0).map(([$,U])=>[$,Buffer.from(U,"base64")]));Oz4=Fg0(fo())});function Ng0(){return`# Seal Use 系统架构与运行规范白皮书
> 本文档由 \`seal-use\` 单文件二进制程序内嵌提供,纯内存只读,未向用户电脑写入任何临时文件。
@@ -2543,14 +2573,14 @@ flowchart TD
| 目录名称 | 类别 | 规范路径 | 作用与生命周期 |
| :--- | :--- | :--- | :--- |
${Eo.map(($)=>`| **${$.name}** | \`${$.category}\` | \`${$.standardPath}\` | ${$.purpose} (${$.retention}) |`).join(`
${uo.map(($)=>`| **${$.name}** | \`${$.category}\` | \`${$.standardPath}\` | ${$.purpose} (${$.retention}) |`).join(`
`)}
---
## 3. 安全与数据隐私保证
${Co.map(($,Y)=>`### 3.${Y+1} ${$.topic}
${bo.map(($,U)=>`### 3.${U+1} ${$.topic}
- **安全承诺**:${$.guarantee}
- **实现约束**:${$.enforcement}
`).join(`
@@ -2560,9 +2590,9 @@ ${Co.map(($,Y)=>`### 3.${Y+1} ${$.topic}
## 4. 业务域能力图谱
${Ro.map(($)=>`### \`seal-use ${$.domain}\`
${io.map(($)=>`### \`seal-use ${$.domain}\`
* **能力定位**:${$.summary}
* **核心命令**:${$.primaryCommands.map((Y)=>`\`seal-use ${Y}\``).join("、")}
* **核心命令**:${$.primaryCommands.map((U)=>`\`seal-use ${U}\``).join("、")}
`).join(`
`)}
@@ -2573,19 +2603,19 @@ ${Ro.map(($)=>`### \`seal-use ${$.domain}\`
- **环境自检**:运行 \`seal-use doctor\`,一键检查当前运行时版本、本地目录健康度、企业资产接入数量以及守护服务状态。
- **查看企业配置源文件**:运行 \`seal-use corps get <corpId>\`,可直接查看指定企业的本地 JSON 存储绝对路径。
- **查阅完整操作手册**:运行 \`seal-use doctor guide\` 随时在离线状态下查看本文档。
`}var Eo,Co,Ro;var _o=m(()=>{Eo=[{name:"配置与状态根目录",category:"config",standardPath:"~/.config/seal-use",purpose:"用户本地持久化配置根目录,存放企业连接元数据、会话缓存与全局状态。",accessMode:"read-write",retention:"persistent"},{name:"企业配置文件目录",category:"config",standardPath:"~/.config/seal-use/enterprises",purpose:"存放各已添加企业的配置 JSON 文件(如 xiezihao.json),存储企业域名、脱敏 Token、员工绑定关系等。",accessMode:"read-write",retention:"persistent"},{name:"全局配置文件",category:"config",standardPath:"~/.config/seal-use/config.json",purpose:"维护全局工作模式(stateful/stateless)、默认激活企业 defaultCorpId 以及 Lint 偏好。",accessMode:"read-write",retention:"persistent"},{name:"会话凭据安全缓存",category:"config",standardPath:"~/.config/seal-use/seal_tokens.json",purpose:"缓存已认证租户的 Bearer Token 与过期时间戳,避免高频调用上游 OAuth 换票接口。",accessMode:"read-write",retention:"cache"},{name:"规则版本映射快照",category:"config",standardPath:"~/.config/seal-use/mappings",purpose:"存储 corps sync-test 生成的生产与测试规则版本/编号对照映射快照,供 rules map 离线毫秒级速查。",accessMode:"read-write",retention:"persistent"},{name:"后台守护服务日志",category:"config",standardPath:"~/.config/seal-use/service.log",purpose:"常驻后台 HTTP 服务守护进程运行输出日志。",accessMode:"read-write",retention:"persistent"},{name:"全局命令行程序",category:"binary",standardPath:"/opt/homebrew/bin/seal-use",purpose:"macOS / Linux 全局独立单文件二进制程序;旧版 seal-home 命令仅保留解析兼容,不再新建全局别名。",accessMode:"executable",retention:"persistent"},{name:"AI Agent 技能主目录",category:"skill",standardPath:"~/.agents/skills/seal-use",purpose:"面向 Antigravity、Codex 等 AI 智能体的标准技能目录,包含 SKILL.md、参考文档与操作规程。",accessMode:"read-write",retention:"persistent"},{name:"报表默认导出目录",category:"export",standardPath:"~/Downloads",purpose:"执行 approval-runs export 等大盘报表命令且未指定 --out 时,默认写入的 Excel 文件路径。",accessMode:"read-write",retention:"persistent"},{name:"系统隔离临时目录",category:"temp",standardPath:"/tmp 或 /var/folders/.../T",purpose:"自动化测试(bun test)生成的隔离工作副本,执行完毕后通过 afterEach 钩子彻底删除,零残留。",accessMode:"transient",retention:"ephemeral"}],Co=[{topic:"敏感凭据脱敏保护",guarantee:"appSecurity、password 等高危密钥永不回显在 stdout,Session Token 采用掩码处理(如 5oUL...Y%3D)。",enforcement:"CLI 所有展示接口(corps get、corps list、probe 等)均经 formatSafeSourceDetail 脱敏过滤。"},{topic:"正式环境与测试环境严格隔离",guarantee:"正式企业与测试企业必须严格 1 对 1 下挂,禁止多层级级联绑定;环境标记需显式 --confirm 确认。",enforcement:"corps bind-test 与 mark 强制要求 --confirm,缺少时阻断并返回退出码 10(confirmationRequired)。"},{topic:"跨环境规则同步安全基线",guarantee:"corps sync-test 仅将正式企业偏好与规则覆盖同步至测试企业并自动发布,正式企业规则严格维持草稿态永不发布。",enforcement:"规则同步流水线由 sync-test 独占受控,正式环境端仅执行拉取草稿读取操作,零发版变更。"},{topic:"只读诊断无副作用原则",guarantee:"doctor、search、get、list、context、probe 等命令为严格只读操作,不修改用户本地文件系统,零写入污染。",enforcement:"核心领域函数严格分离 Mutation 操作与 Query 操作,Query 路径杜绝写文件与环境篡改。"}],Ro=[{domain:"corps (企业管理)",summary:"多租户接入、智能软搜索、富属性查看、环境标记、测试绑定与配置规则同步",primaryCommands:["corps list","corps search <query>","corps get <corpId>","corps mark","corps bind-test","corps sync-test"]},{domain:"approval-runs (审核大盘)",summary:"AI 审核单据检索、统计分析、引证规则查看、附件全链路追踪、Excel 报表导出、单据直达链接与免登",primaryCommands:["approval-runs list","approval-runs stats","approval-runs get","approval-runs export","approval-runs link"]},{domain:"rules (规则治理)",summary:"审核规则拉取、本地 Lint 质量检查、增量差量推送、离线版本与编号对照映射速查",primaryCommands:["rules pull","rules lint","rules push","rules map","rules count"]},{domain:"preference (决策偏好)",summary:"AI 审核偏好读取与更新、全局与分品类思考深度策略(medium/high)配置",primaryCommands:["preference get","preference decision update","preference thinking-depth set"]},{domain:"simulation (模拟演练)",summary:"合 Line truncated
`)}var tS0=m(()=>{_p();$3();k3();yq();rB();_o()});var eS0={};D8(eS0,{formatTenantDoctorDashboard:()=>ky1,diagnoseTenantContract:()=>yy1});async function yy1($,Y){let z=[],U=Y.environment==="test"?"test":"production",Q=U==="test"?Y.prodCorpId:Y.testCorpId,J=U==="test"?"prodParent":"testTarget",I=Q?U==="test"?"已绑定生产母企业 (上游配置与样本源)":"已绑定测试靶场 (下游隔离演练环境)":void 0,K=null,G=null;try{let O=await T8($);if(K=O.user,G=O.tenant,Boolean(K?.isAdmin||K?.permissions?.includes("*")))z.push({id:"auth_identity",name:"身份与权限契约",status:"pass",summary:`已认证为管理员「${K.name??"未知"}」(${K.id??""}),具备完整操作权限`,details:{userId:K.id,userName:K.name,isAdmin:!0,permissionLevel:"超级管理员(具备完整操作权限)",tenantName:G?.name,tenantSlug:G?.tenantSlug,permissions:K.permissions}});else z.push({id:"auth_identity",name:"身份与权限契约",status:"warn",summary:`已认证为普通用户「${K.name??"未知"}」,非超级管理员,部分配置操作可能受限`,details:{userId:K.id,userName:K.name,isAdmin:!1,permissionLevel:"普通用户(部分管理配置受限)",tenantName:G?.name,permissions:K.permissions},recommendation:"建议使用具有管理权限的企业主账号执行规则修改与集成发布"})}catch(O){z.push({id:"auth_identity",name:"身份与权限契约",status:"fail",summary:`鉴权握手失败:${O instanceof Error?O.message:String(O)}`,details:{error:String(O)},recommendation:`请执行 seal-use auth login --corp ${Y.id} 重新登录或更新 Token`})}let H={featureCode:"ai-approval",balance:0,deductionAmount:120,estimatedRuns:0,status:"exhausted"},W={used:0,remaining:0};try{let O=await lY($),N=Array.isArray(O.features)?O.features:[],M=N.find((P)=>P?.code==="ai-approval");if(M){let P=typeof M.balance==="number"?M.balance:0,j=typeof M.deductionAmount==="number"&&M.deductionAmount>0?M.deductionAmount:120,A=Math.floor(P/j);if(H.balance=P,H.deductionAmount=j,H.estimatedRuns=A,P<=0)H.status="exhausted",z.push({id:"billing_quota",name:"AI 审批额度余量",status:"fail",summary:"当前额度已耗尽 (余量 0 点),无法执行审批模拟或回归测试",details:{balance:P,deductionAmount:j,estimatedRuns:A},recommendation:`请前往后台充值补充额度 (可通过 seal-use auth link --corp ${Y.id} 免密直达)`});else if(A<10)H.status="low",z.push({id:"billing_quota",name:"AI 审批额度余量",status:"warn",summary:`额度偏低:剩余 ${P} 点 (单笔扣除 ${j} 点),仅可支持约 ${A} 笔审核`,details:{balance:P,deductionAmount:j,estimatedRuns:A},recommendation:`建议补充额度 (可通过 seal-use auth link --corp ${Y.id} 免密直达)`});else H.status="sufficient",z.push({id:"billing_quota",name:"AI 审批额度余量",status:"pass",summary:`额度充裕:剩余 ${P} 点,预估可支持 ${A} 笔审核单据`,details:{balance:P,deductionAmount:j,estimatedRuns:A}})}else z.push({id:"billing_quota",name:"AI 审批额度余量",status:"warn",summary:"未检索到「ai-approval」功能包额度明细,按默认通道运行",details:{features:N.map((P)=>P?.code)}});let D=N.find((P)=>P?.code==="approval-rules");if(D)W.used=typeof D.used==="number"?D.used:0,W.remaining=typeof D.remaining==="number"?D.remaining:0}catch(O){z.push({id:"billing_quota",name:"AI 审批额度余量",status:"warn",summary:`读取计费状态失败:${O instanceof Error?O.message:String(O)}`,details:{error:String(O)}})}let X={totalCount:0,activeCount:0,quotaUsed:W.used,quotaRemaining:W.remaining};try{let O=await X6($),N=Array.isArray(O.rules)?O.rules:[];if(X.totalCount=N.length,X.activeCount=N.filter((M)=>M.status==="ACTIVE").length,N.length===0)z.push({id:"rules_status",name:"审核规则状态",status:"warn",summary:"当前租户未配置任何审核规则 (规则数为 0)",details:{totalCount:0,activeCount:0},recommendation:U==="test"&&Q?`可运行 seal-use corps sync-test --corp ${Q} 从生产企业同步规则`:"可运行 seal-use rules add 创建基础规则"});else z.push({id:"rules_status",name:"审核规则状态",status:"pass",summary:`审核规则健康:共 ${X.totalCount} 条规则,其中生效活跃 ${X.activeCount} 条`,details:{totalCount:X.totalCount,activeCount:X.activeCount,quotaUsed:W.used,quotaRemaining:W.remaining}})}catch(O){z.push({id:"rules_status",name:"审核规则状态",status:"fail",summary:`拉取规则列表失败:${O instanceof Error?O.message:String(O)}`,details:{error:String(O)}})}let Z={integrationCount:0,hasReplayChannel:!1,activeWebhookId:void 0};try{let O=await I$($);Z.integrationCount=O.length;let N=O.find((M)=>M.name.includes("回放")||M.name.toLowerCase().includes("replay"));if(Z.hasReplayChannel=Boolean(N),Z.activeWebhookId=N?.id??O[0]?.id,O.length===0)z.push({id:"webhook_integrations",name:"单据推送 Webhook 通道",status:"pass",summary:"未配置任何 Webhook 集成通道 (日常审批无影响;若需自动化系统推流或单据重放将 Line truncated
`)}var $g0=m(()=>{B6()});async function Yg0($,Y,z){let U=($??Y??"").toLowerCase();if(U==="guide"||U==="doc"||U==="knowledge"||U==="book"){console.error(`\uD83D\uDCD6 [Seal Use Doctor] 正在读取内嵌系统规范白皮书(纯内存只读)...
`),console.log(lS0());return}if(U==="paths"||U==="dirs"||U==="directories"){let I=vo();x0(I.directories);return}if(U==="auth"){let{selectCorp:I}=await Promise.resolve().then(() => (f4(),pl)),{stringOption:K}=await Promise.resolve().then(() => (A4(),il)),{handleAuthCommand:G}=await Promise.resolve().then(() => (Vo(),bh0)),H=K(z.options.corp)??(Y&&Y!==U?Y:void 0)??(z.command[2]&&z.command[2]!==U?z.command[2]:void 0),W=I(H);await G("check",W,z);return}if(U==="tenant"||U==="corp"||U==="enterprise"){let{selectCorp:I}=await Promise.resolve().then(() => (f4(),pl)),{createSealClient:K}=await Promise.resolve().then(() => (i8(),t00)),{stringOption:G}=await Promise.resolve().then(() => (A4(),il)),{diagnoseTenantContract:H,formatTenantDoctorDashboard:W}=await Promise.resolve().then(() => ($g0(),eS0)),X=G(z.options.corp)??(Y&&Y!==U?Y:void 0)??(z.command[2]&&z.command[2]!==U?z.command[2]:void 0),Z=I(X),q=await K(Z),V=await H(q,Z);if(!(Z0(z.options.quiet)||Z0(z.options.silent)))console.error(W(V));x0(V);return}let Q=vo();if(!(Z0(z.options.quiet)||Z0(z.options.silent)))console.error(aS0(Q));x0(Q)}var zg0=m(()=>{tS0();_o();A4();K4()});var Qg0;var Ug0=m(()=>{Qg0={openapi:"3.1.0",info:{title:"seal-use Wrapped API",version:"0.10.37",description:"HTTP contract for the seal-use wrapped backend API, served by the local HTTP adapter\n(`seal-use http`, or the `seal-use service start` daemon; default http://127.0.0.1:8787).\n\nThese endpoints describe the stable wrapped API for frontend developers and agents. They are\nnot the raw downstream Seal endpoints: seal-use is responsible for enterprise selection,\nsource authentication, response compaction, and diagnostics-friendly fields.\n\nEvery operation declares `x-implementation-status`, so a caller can tell what the running\nadapter actually serves:\n\n- `implemented` — routed by `src/http/routes.ts` today. `src/http/openapi-implementation.test.ts`\n fails when an `implemented` operation has no matching route.\n- `planned` — contract-only, designed but not routed yet. Calling it returns 404.\n\nThe same capabilities are reachable through the CLI, and through the optional MCP server when\nit is enabled.\n"},servers:[{url:"http://localhost:8787",description:"Local HTTP adapter (`seal-use http`, or the `seal-use service start` daemon). Loopback-only by default."}],security:[{localSession:[]}],tags:[{name:"Corps",description:"Local enterprise configuration selection."},{name:"Source",description:"Source-derived Seal enterprise configuration."},{name:"Auth",description:"Wrapped authentication diagnostics and current identity."},{name:"Approval Runs",description:"Wrapped approval run history, summaries, document URLs, and trace bridge helpers."},{name:"Approval Knowledge",description:"Wrapped approval rules, documents, preferences, and search."},{name:"Simulation",description:"Wrapped simulation batch record access."}],paths:{"/v1/corps":{get:{tags:["Corps"],operationId:"listCorps","x-implementation-status":"implemented",summary:"List configured enterprises",responses:{"200":{description:"Configured enterprises.",content:{"application/json":{schema:{type:"array",items:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","direct","seal"]},current:{type:"boolean"}}}}}}}}}},"/v1/corps/current":{get:{tags:["Corps"],operationId:"getCurrentCorp","x-implementation-status":"planned",summary:"Get current enterprise",description:"Returns the configured default enterprise in stateful mode. Stateless mode has no current enterprise and requires an explicit corpId for enterprise operations.",responses:{"200":{description:"Current enterprise.",content:{"application/json":{schema:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","direct","seal"]},current:{type:"boolean"}}}}}}}}},"/v1/corps/current/switch":{post:{tags:["Corps"],operationId:"switchCurrentCorp","x-implementation-status":"planned",summary:"Switch current enterprise",requestBody:{required:!0,content:{"application/json":{schema:{type:"object",required:["corpId"],properties:{corpId:{type:"string"}}}}}},responses:{"200":{description:"Switched enterprise.",content:{"application/json":{schema:{type:"object",required:["current","id","name"],properties:{current:{type:"boolean"},id:{type:"string"},name:{type:"string"}}}}}},"404":{description:"Requested resource was not found.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}}}},"/v1/source/config":{get:{tags:["Source"],operationId:"getSourceConfig","x-implementation-status":"planned",summary:"Resolve source-derived Seal enterprise config",parameters:[{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is sta Line truncated
`}var uo,bo,io;var no=m(()=>{uo=[{name:"配置与状态根目录",category:"config",standardPath:"~/.config/seal-use",purpose:"用户本地持久化配置根目录,存放企业连接元数据、会话缓存与全局状态。",accessMode:"read-write",retention:"persistent"},{name:"企业配置文件目录",category:"config",standardPath:"~/.config/seal-use/enterprises",purpose:"存放各已添加企业的配置 JSON 文件(如 xiezihao.json),存储企业域名、脱敏 Token、员工绑定关系等。",accessMode:"read-write",retention:"persistent"},{name:"全局配置文件",category:"config",standardPath:"~/.config/seal-use/config.json",purpose:"维护全局工作模式(stateful/stateless)、默认激活企业 defaultCorpId 以及 Lint 偏好。",accessMode:"read-write",retention:"persistent"},{name:"会话凭据安全缓存",category:"config",standardPath:"~/.config/seal-use/seal_tokens.json",purpose:"缓存已认证租户的 Bearer Token 与过期时间戳,避免高频调用上游 OAuth 换票接口。",accessMode:"read-write",retention:"cache"},{name:"规则版本映射快照",category:"config",standardPath:"~/.config/seal-use/mappings",purpose:"存储 corps sync-test 生成的生产与测试规则版本/编号对照映射快照,供 rules map 离线毫秒级速查。",accessMode:"read-write",retention:"persistent"},{name:"后台守护服务日志",category:"config",standardPath:"~/.config/seal-use/service.log",purpose:"常驻后台 HTTP 服务守护进程运行输出日志。",accessMode:"read-write",retention:"persistent"},{name:"全局命令行程序",category:"binary",standardPath:"/opt/homebrew/bin/seal-use",purpose:"macOS / Linux 全局独立单文件二进制程序;旧版 seal-home 命令仅保留解析兼容,不再新建全局别名。",accessMode:"executable",retention:"persistent"},{name:"AI Agent 技能主目录",category:"skill",standardPath:"~/.agents/skills/seal-use",purpose:"面向 Antigravity、Codex 等 AI 智能体的标准技能目录,包含 SKILL.md、参考文档与操作规程。",accessMode:"read-write",retention:"persistent"},{name:"报表默认导出目录",category:"export",standardPath:"~/Downloads",purpose:"执行 approval-runs export 等大盘报表命令且未指定 --out 时,默认写入的 Excel 文件路径。",accessMode:"read-write",retention:"persistent"},{name:"系统隔离临时目录",category:"temp",standardPath:"/tmp 或 /var/folders/.../T",purpose:"自动化测试(bun test)生成的隔离工作副本,执行完毕后通过 afterEach 钩子彻底删除,零残留。",accessMode:"transient",retention:"ephemeral"}],bo=[{topic:"敏感凭据脱敏保护",guarantee:"appSecurity、password 等高危密钥永不回显在 stdout,Session Token 采用掩码处理(如 5oUL...Y%3D)。",enforcement:"CLI 所有展示接口(corps get、corps list、probe 等)均经 formatSafeSourceDetail 脱敏过滤。"},{topic:"正式环境与测试环境严格隔离",guarantee:"正式企业与测试企业必须严格 1 对 1 下挂,禁止多层级级联绑定;环境标记需显式 --confirm 确认。",enforcement:"corps bind-test 与 mark 强制要求 --confirm,缺少时阻断并返回退出码 10(confirmationRequired)。"},{topic:"跨环境规则同步安全基线",guarantee:"corps sync-test 仅将正式企业偏好与规则覆盖同步至测试企业并自动发布,正式企业规则严格维持草稿态永不发布。",enforcement:"规则同步流水线由 sync-test 独占受控,正式环境端仅执行拉取草稿读取操作,零发版变更。"},{topic:"只读诊断无副作用原则",guarantee:"doctor、search、get、list、context、probe 等命令为严格只读操作,不修改用户本地文件系统,零写入污染。",enforcement:"核心领域函数严格分离 Mutation 操作与 Query 操作,Query 路径杜绝写文件与环境篡改。"}],io=[{domain:"corps (企业管理)",summary:"多租户接入、智能软搜索、富属性查看、环境标记、测试绑定与配置规则同步",primaryCommands:["corps list","corps search <query>","corps get <corpId>","corps mark","corps bind-test","corps sync-test"]},{domain:"approval-runs (审核大盘)",summary:"AI 审核单据检索、统计分析、引证规则查看、附件全链路追踪、Excel 报表导出、单据直达链接与免登",primaryCommands:["approval-runs list","approval-runs stats","approval-runs get","approval-runs export","approval-runs link"]},{domain:"rules (规则治理)",summary:"审核规则拉取、本地 Lint 质量检查、增量差量推送、离线版本与编号对照映射速查",primaryCommands:["rules pull","rules lint","rules push","rules map","rules count"]},{domain:"preference (决策偏好)",summary:"AI 审核偏好读取与更新、全局与分品类思考深度策略(medium/high)配置",primaryCommands:["preference get","preference decision update","preference thinking-depth set"]},{domain:"simulation (模拟演练)",summary:"合 Line truncated
`)}var Tg0=m(()=>{id();z3();T5();iq();YP();no()});var jg0={};T8(jg0,{formatTenantDoctorDashboard:()=>qk1,diagnoseTenantContract:()=>Zk1});async function Zk1($,U){let Y=[],z=U.environment==="test"?"test":"production",I=z==="test"?U.prodCorpId:U.testCorpId,Q=z==="test"?"prodParent":"testTarget",J=I?z==="test"?"已绑定生产母企业 (上游配置与样本源)":"已绑定测试靶场 (下游隔离演练环境)":void 0,K=null,G=null;try{let w=await Z8($);if(K=w.user,G=w.tenant,Boolean(K?.isAdmin||K?.permissions?.includes("*")))Y.push({id:"auth_identity",name:"身份与权限契约",status:"pass",summary:`已认证为管理员「${K.name??"未知"}」(${K.id??""}),具备完整操作权限`,details:{userId:K.id,userName:K.name,isAdmin:!0,permissionLevel:"超级管理员(具备完整操作权限)",tenantName:G?.name,tenantSlug:G?.tenantSlug,permissions:K.permissions}});else Y.push({id:"auth_identity",name:"身份与权限契约",status:"warn",summary:`已认证为普通用户「${K.name??"未知"}」,非超级管理员,部分配置操作可能受限`,details:{userId:K.id,userName:K.name,isAdmin:!1,permissionLevel:"普通用户(部分管理配置受限)",tenantName:G?.name,permissions:K.permissions},recommendation:"建议使用具有管理权限的企业主账号执行规则修改与集成发布"})}catch(w){Y.push({id:"auth_identity",name:"身份与权限契约",status:"fail",summary:`鉴权握手失败:${w instanceof Error?w.message:String(w)}`,details:{error:String(w)},recommendation:`请执行 seal-use auth login --corp ${U.id} 重新登录或更新 Token`})}let H={featureCode:"ai-approval",balance:0,deductionAmount:120,estimatedRuns:0,status:"exhausted"},W={used:0,remaining:0};try{let w=await lU($),N=Array.isArray(w.features)?w.features:[],O=N.find((P)=>P?.code==="ai-approval");if(O){let P=typeof O.balance==="number"?O.balance:0,T=typeof O.deductionAmount==="number"&&O.deductionAmount>0?O.deductionAmount:120,A=Math.floor(P/T);if(H.balance=P,H.deductionAmount=T,H.estimatedRuns=A,P<=0)H.status="exhausted",Y.push({id:"billing_quota",name:"AI 审批额度余量",status:"fail",summary:"当前额度已耗尽 (余量 0 点),无法执行审批模拟或回归测试",details:{balance:P,deductionAmount:T,estimatedRuns:A},recommendation:`请前往后台充值补充额度 (可通过 seal-use auth link --corp ${U.id} 免密直达)`});else if(A<10)H.status="low",Y.push({id:"billing_quota",name:"AI 审批额度余量",status:"warn",summary:`额度偏低:剩余 ${P} 点 (单笔扣除 ${T} 点),仅可支持约 ${A} 笔审核`,details:{balance:P,deductionAmount:T,estimatedRuns:A},recommendation:`建议补充额度 (可通过 seal-use auth link --corp ${U.id} 免密直达)`});else H.status="sufficient",Y.push({id:"billing_quota",name:"AI 审批额度余量",status:"pass",summary:`额度充裕:剩余 ${P} 点,预估可支持 ${A} 笔审核单据`,details:{balance:P,deductionAmount:T,estimatedRuns:A}})}else Y.push({id:"billing_quota",name:"AI 审批额度余量",status:"warn",summary:"未检索到「ai-approval」功能包额度明细,按默认通道运行",details:{features:N.map((P)=>P?.code)}});let D=N.find((P)=>P?.code==="approval-rules");if(D)W.used=typeof D.used==="number"?D.used:0,W.remaining=typeof D.remaining==="number"?D.remaining:0}catch(w){Y.push({id:"billing_quota",name:"AI 审批额度余量",status:"warn",summary:`读取计费状态失败:${w instanceof Error?w.message:String(w)}`,details:{error:String(w)}})}let X={totalCount:0,activeCount:0,quotaUsed:W.used,quotaRemaining:W.remaining};try{let w=await W6($),N=Array.isArray(w.rules)?w.rules:[];if(X.totalCount=N.length,X.activeCount=N.filter((O)=>O.status==="ACTIVE").length,N.length===0)Y.push({id:"rules_status",name:"审核规则状态",status:"warn",summary:"当前租户未配置任何审核规则 (规则数为 0)",details:{totalCount:0,activeCount:0},recommendation:z==="test"&&I?`可运行 seal-use corps sync-test --corp ${I} 从生产企业同步规则`:"可运行 seal-use rules add 创建基础规则"});else Y.push({id:"rules_status",name:"审核规则状态",status:"pass",summary:`审核规则健康:共 ${X.totalCount} 条规则,其中生效活跃 ${X.activeCount} 条`,details:{totalCount:X.totalCount,activeCount:X.activeCount,quotaUsed:W.used,quotaRemaining:W.remaining}})}catch(w){Y.push({id:"rules_status",name:"审核规则状态",status:"fail",summary:`拉取规则列表失败:${w instanceof Error?w.message:String(w)}`,details:{error:String(w)}})}let Z={integrationCount:0,hasReplayChannel:!1,activeWebhookId:void 0};try{let w=await K$($);Z.integrationCount=w.length;let N=w.find((O)=>O.name.includes("回放")||O.name.toLowerCase().includes("replay"));if(Z.hasReplayChannel=Boolean(N),Z.activeWebhookId=N?.id??w[0]?.id,w.length===0)Y.push({id:"webhook_integrations",name:"单据推送 Webhook 通道",status:"pass",summary:"未配置任何 Webhook 集成通道 (日常审批无影响;若需自动化系统推流或单据重放将 Line truncated
`)}var Eg0=m(()=>{X6()});async function Cg0($,U,Y){let z=($??U??"").toLowerCase();if(z==="guide"||z==="doc"||z==="knowledge"||z==="book"){console.error(`\uD83D\uDCD6 [Seal Use Doctor] 正在读取内嵌系统规范白皮书(纯内存只读)...
`),console.log(Ng0());return}if(z==="paths"||z==="dirs"||z==="directories"){let J=co();R0(J.directories);return}if(z==="auth"){let{selectCorp:J}=await Promise.resolve().then(() => (O4(),Uo)),{stringOption:K}=await Promise.resolve().then(() => (Z4(),tl)),{handleAuthCommand:G}=await Promise.resolve().then(() => (jo(),qS0)),H=K(Y.options.corp)??(U&&U!==z?U:void 0)??(Y.command[2]&&Y.command[2]!==z?Y.command[2]:void 0),W=J(H);await G("check",W,Y);return}if(z==="tenant"||z==="corp"||z==="enterprise"){let{selectCorp:J}=await Promise.resolve().then(() => (O4(),Uo)),{createSealClient:K}=await Promise.resolve().then(() => (m6(),H10)),{stringOption:G}=await Promise.resolve().then(() => (Z4(),tl)),{diagnoseTenantContract:H,formatTenantDoctorDashboard:W}=await Promise.resolve().then(() => (Eg0(),jg0)),X=G(Y.options.corp)??(U&&U!==z?U:void 0)??(Y.command[2]&&Y.command[2]!==z?Y.command[2]:void 0),Z=J(X),q=await K(Z),V=await H(q,Z);if(!(G0(Y.options.quiet)||G0(Y.options.silent)))console.error(W(V));R0(V);return}let I=co();if(!(G0(Y.options.quiet)||G0(Y.options.silent)))console.error(Pg0(I));R0(I)}var Rg0=m(()=>{Tg0();no();Z4();m1()});var vg0;var _g0=m(()=>{vg0={openapi:"3.1.0",info:{title:"seal-use Wrapped API",version:"0.10.37",description:"HTTP contract for the seal-use wrapped backend API, served by the local HTTP adapter\n(`seal-use http`, or the `seal-use service start` daemon; default http://127.0.0.1:8787).\n\nThese endpoints describe the stable wrapped API for frontend developers and agents. They are\nnot the raw downstream Seal endpoints: seal-use is responsible for enterprise selection,\nsource authentication, response compaction, and diagnostics-friendly fields.\n\nEvery operation declares `x-implementation-status`, so a caller can tell what the running\nadapter actually serves:\n\n- `implemented` — routed by `src/http/routes.ts` today. `src/http/openapi-implementation.test.ts`\n fails when an `implemented` operation has no matching route.\n- `planned` — contract-only, designed but not routed yet. Calling it returns 404.\n\nThe same capabilities are reachable through the CLI, and through the optional MCP server when\nit is enabled.\n"},servers:[{url:"http://localhost:8787",description:"Local HTTP adapter (`seal-use http`, or the `seal-use service start` daemon). Loopback-only by default."}],security:[{localSession:[]}],tags:[{name:"Corps",description:"Local enterprise configuration selection."},{name:"Source",description:"Source-derived Seal enterprise configuration."},{name:"Auth",description:"Wrapped authentication diagnostics and current identity."},{name:"Approval Runs",description:"Wrapped approval run history, summaries, document URLs, and trace bridge helpers."},{name:"Approval Knowledge",description:"Wrapped approval rules, documents, preferences, and search."},{name:"Simulation",description:"Wrapped simulation batch record access."}],paths:{"/v1/corps":{get:{tags:["Corps"],operationId:"listCorps","x-implementation-status":"implemented",summary:"List configured enterprises",responses:{"200":{description:"Configured enterprises.",content:{"application/json":{schema:{type:"array",items:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","seal"]},current:{type:"boolean"}}}}}}}}}},"/v1/corps/current":{get:{tags:["Corps"],operationId:"getCurrentCorp","x-implementation-status":"planned",summary:"Get current enterprise",description:"Returns the configured default enterprise in stateful mode. Stateless mode has no current enterprise and requires an explicit corpId for enterprise operations.",responses:{"200":{description:"Current enterprise.",content:{"application/json":{schema:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","seal"]},current:{type:"boolean"}}}}}}}}},"/v1/corps/current/switch":{post:{tags:["Corps"],operationId:"switchCurrentCorp","x-implementation-status":"planned",summary:"Switch current enterprise",requestBody:{required:!0,content:{"application/json":{schema:{type:"object",required:["corpId"],properties:{corpId:{type:"string"}}}}}},responses:{"200":{description:"Switched enterprise.",content:{"application/json":{schema:{type:"object",required:["current","id","name"],properties:{current:{type:"boolean"},id:{type:"string"},name:{type:"string"}}}}}},"404":{description:"Requested resource was not found.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}}}},"/v1/source/config":{get:{tags:["Source"],operationId:"getSourceConfig","x-implementation-status":"planned",summary:"Resolve source-derived Seal enterprise config",parameters:[{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional i Line truncated
the credentials already stored on this machine for the selected enterprise. Keep it bound
to loopback (\`--host 127.0.0.1\`) and do not expose the port to a network or an origin you
do not control.
`}},parameters:{CorpId:{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."},Offset:{name:"offset",in:"query",schema:{type:"integer",minimum:0,default:0},description:"Zero-based pagination offset."},Limit:{name:"limit",in:"query",schema:{type:"integer",minimum:1,maximum:100,default:50},description:"Maximum number of records to return."},RuleId:{name:"ruleId",in:"path",required:!0,schema:{type:"string"},description:"Approval rule ID."},VersionId:{name:"versionId",in:"path",required:!0,schema:{type:"string"},description:"Published rule version ID."},DocumentId:{name:"documentId",in:"path",required:!0,schema:{type:"string"},description:"Approval knowledge document ID."},RecordId:{name:"recordId",in:"path",required:!0,schema:{type:"string"},description:"seal-use approval run record ID."},BatchId:{name:"batchId",in:"path",required:!0,schema:{type:"string"},description:"Simulation batch ID."}},responses:{BadRequest:{description:"Invalid request.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}},Unauthorized:{description:"Local service authentication failed or downstream Seal auth failed.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}},NotFound:{description:"Requested resource was not found.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}},schemas:{ErrorResponse:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}},CorpSummary:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","direct","seal"]},current:{type:"boolean"}}},SwitchCorpRequest:{type:"object",required:["corpId"],properties:{corpId:{type:"string"}}},SwitchCorpResponse:{type:"object",required:["current","id","name"],properties:{current:{type:"boolean"},id:{type:"string"},name:{type:"string"}}},SourceConfig:{type:"object",additionalProperties:!0,description:"Redacted Seal enterprise config resolved from the configured source."},AuthStage:{type:"object",additionalProperties:!0,required:["name","ok"],properties:{name:{type:"string",examples:["hose.openapi","hose.provisional","seal.sso","seal.whoami"]},ok:{type:"boolean"},error:{type:"string"}}},AuthDiagnosis:{type:"object",required:["stages"],properties:{stages:{type:"array",items:{$ref:"#/components/schemas/AuthStage"}}}},SealUser:{type:"object",additionalProperties:!0,required:["id","name"],properties:{id:{type:"string"},tenantId:{type:"string"},name:{type:"string"},isAdmin:{type:"boolean"},permissions:{type:"array",items:{type:"string"}}}},SealTenant:{type:"object",additionalProperties:!0,required:["id","name"],properties:{id:{type:"string"},name:{type:"string"},tenantSlug:{type:"string"}}},WhoamiResponse:{type:"object",required:["user","tenant"],properties:{user:{$ref:"#/components/schemas/SealUser"},tenant:{$ref:"#/components/schemas/SealTenant"}}},SessionResponse:{type:"object",additionalProperties:!0,required:["user","session"],properties:{user:{$ref:"#/components/schemas/SealUser"},session:{type:"object",additionalProperties:!0}}},ApprovalRule:{type:"object",additionalProperties:!0,required:["id","description","scope","strictness"],properties:{id:{type:"string"},description:{type:"string"},scope:{type:"string"},strictness:{type:"string",enum:["MUST_FOLLOW","SHOULD_FOLLOW","SUGGESTION"]},status:{type:"string"}}},ApprovalRuleInput:{type:"object",required:["description","scope","strictness"],properties:{description:{type:"string"},scope:{type:"string"},strictness:{type:"string",enum:["MUST_FOLLOW","SHOULD_FOLLOW","SUGGESTION"]}}},ApprovalRulePatch:{type:"object",additionalProperties:!1,properties:{description:{type:"string"},scope:{type:"string"},strictness:{type:"string",enum:["MUST_FOLLOW","SHOULD_FOLLOW","SUGGESTION"]}}},ApprovalRulesResponse:{type:"object",required:["rules"],properties:{rules:{type:"array",items:{$ref:"#/components/schemas/ApprovalRule"}},hasPendingDeletes:{type:"boolean"}}},RuleSetVersion:{type:"object",additionalProperties:!0,required:["id","versionNumber","versionName","rules"],properties:{id:{type:"string"},versionNumber:{type:"integer"},versionName:{type:"string"},publishedByName:{type:"string"},rules:{type:"array",items:{type:"object",additionalProperties:!0}}}},PublishRuleVersionRequest:{type:"object",required:["versionName"],properties:{versionName:{type:"string"}}},ApprovalDocument:{type:"object",additionalProperties:!0,required:["id","title","content"],properties:{id:{type:"string"},t Line truncated
`}},parameters:{CorpId:{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."},Offset:{name:"offset",in:"query",schema:{type:"integer",minimum:0,default:0},description:"Zero-based pagination offset."},Limit:{name:"limit",in:"query",schema:{type:"integer",minimum:1,maximum:100,default:50},description:"Maximum number of records to return."},RuleId:{name:"ruleId",in:"path",required:!0,schema:{type:"string"},description:"Approval rule ID."},VersionId:{name:"versionId",in:"path",required:!0,schema:{type:"string"},description:"Published rule version ID."},DocumentId:{name:"documentId",in:"path",required:!0,schema:{type:"string"},description:"Approval knowledge document ID."},RecordId:{name:"recordId",in:"path",required:!0,schema:{type:"string"},description:"seal-use approval run record ID."},BatchId:{name:"batchId",in:"path",required:!0,schema:{type:"string"},description:"Simulation batch ID."}},responses:{BadRequest:{description:"Invalid request.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}},Unauthorized:{description:"Local service authentication failed or downstream Seal auth failed.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}},NotFound:{description:"Requested resource was not found.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}},schemas:{ErrorResponse:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}},CorpSummary:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","seal"]},current:{type:"boolean"}}},SwitchCorpRequest:{type:"object",required:["corpId"],properties:{corpId:{type:"string"}}},SwitchCorpResponse:{type:"object",required:["current","id","name"],properties:{current:{type:"boolean"},id:{type:"string"},name:{type:"string"}}},SourceConfig:{type:"object",additionalProperties:!0,description:"Redacted Seal enterprise config resolved from the configured source."},AuthStage:{type:"object",additionalProperties:!0,required:["name","ok"],properties:{name:{type:"string",examples:["hose.openapi","hose.provisional","seal.sso","seal.whoami"]},ok:{type:"boolean"},error:{type:"string"}}},AuthDiagnosis:{type:"object",required:["stages"],properties:{stages:{type:"array",items:{$ref:"#/components/schemas/AuthStage"}}}},SealUser:{type:"object",additionalProperties:!0,required:["id","name"],properties:{id:{type:"string"},tenantId:{type:"string"},name:{type:"string"},isAdmin:{type:"boolean"},permissions:{type:"array",items:{type:"string"}}}},SealTenant:{type:"object",additionalProperties:!0,required:["id","name"],properties:{id:{type:"string"},name:{type:"string"},tenantSlug:{type:"string"}}},WhoamiResponse:{type:"object",required:["user","tenant"],properties:{user:{$ref:"#/components/schemas/SealUser"},tenant:{$ref:"#/components/schemas/SealTenant"}}},SessionResponse:{type:"object",additionalProperties:!0,required:["user","session"],properties:{user:{$ref:"#/components/schemas/SealUser"},session:{type:"object",additionalProperties:!0}}},ApprovalRule:{type:"object",additionalProperties:!0,required:["id","description","scope","strictness"],properties:{id:{type:"string"},description:{type:"string"},scope:{type:"string"},strictness:{type:"string",enum:["MUST_FOLLOW","SHOULD_FOLLOW","SUGGESTION"]},status:{type:"string"}}},ApprovalRuleInput:{type:"object",required:["description","scope","strictness"],properties:{description:{type:"string"},scope:{type:"string"},strictness:{type:"string",enum:["MUST_FOLLOW","SHOULD_FOLLOW","SUGGESTION"]}}},ApprovalRulePatch:{type:"object",additionalProperties:!1,properties:{description:{type:"string"},scope:{type:"string"},strictness:{type:"string",enum:["MUST_FOLLOW","SHOULD_FOLLOW","SUGGESTION"]}}},ApprovalRulesResponse:{type:"object",required:["rules"],properties:{rules:{type:"array",items:{$ref:"#/components/schemas/ApprovalRule"}},hasPendingDeletes:{type:"boolean"}}},RuleSetVersion:{type:"object",additionalProperties:!0,required:["id","versionNumber","versionName","rules"],properties:{id:{type:"string"},versionNumber:{type:"integer"},versionName:{type:"string"},publishedByName:{type:"string"},rules:{type:"array",items:{type:"object",additionalProperties:!0}}}},PublishRuleVersionRequest:{type:"object",required:["versionName"],properties:{versionName:{type:"string"}}},ApprovalDocument:{type:"object",additionalProperties:!0,required:["id","title","content"],properties:{id:{type:"string"},title:{typ Line truncated
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Seal Home API Docs (v${Z1})</title>
<title>Seal Home API Docs (v${X1})</title>
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>\uD83E\uDDAD</text></svg>" />
<style>
body {
@@ -2604,23 +2634,23 @@ do not control.
src="https://cdn.jsdelivr.net/npm/@scalar/api-reference@1.25.101/dist/browser/standalone.js"
></script>
</body>
</html>`}var Kg0=m(()=>{$3()});import{URL as fy1}from"node:url";async function v6($,Y,z,U){let Q=$.handler;return Q(Y,z,{corp:U})}async function Gg0($,Y){if(Y.setHeader("Access-Control-Allow-Origin","*"),Y.setHeader("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS, PATCH"),Y.setHeader("Access-Control-Allow-Headers","Content-Type, Authorization, X-Seal-Corp, X-Seal-Home-Session"),$.method==="OPTIONS"){Y.writeHead(204),Y.end();return}let z=$.headers.host||"localhost",U=$.headers["x-forwarded-proto"]||"http",Q=new fy1($.url||"/",`${U}://${z}`),J=Q.pathname.replace(/\/+$/,"")||"/",I=($.method||"GET").toUpperCase();try{if(I==="GET"&&J==="/"){B4(Y,200,{name:"seal-use",version:Z1,description:"Seal tenant operations and approval automation HTTP API",docs:"/docs",openapi:"/openapi.json",health:"/health",endpoints:{cli:"POST /api/cli",tools:"GET /api/tools",toolInvoke:"POST /api/tool/:name",restV1:"GET/POST /v1/*"}});return}if(I==="GET"&&J==="/docs"){by1(Y,200,Ig0());return}if(I==="GET"&&J==="/openapi.json"){B4(Y,200,cj());return}if(I==="GET"&&J==="/health"){B4(Y,200,{status:"ok",version:Z1,name:"seal-use",timestamp:new Date().toISOString()});return}if(I==="POST"&&(J==="/shutdown"||J==="/api/shutdown")){B4(Y,200,{success:!0,message:"Shutting down seal-use background daemon",pid:process.pid}),setTimeout(()=>{process.kill(process.pid,"SIGTERM")},50);return}if(I==="POST"&&J==="/api/cli"){let K=await dj($),G=(typeof K?.command==="string"?K.command:"").trim();if(!G){pj(Y,400,"Missing 'command' property in request body");return}let H=kq(G),W=H[0]==="seal-use"||H[0]==="seal-home"||H[0]?.endsWith("/seal-use")||H[0]?.endsWith("/seal-home")?H.slice(1):H,X=await xq(W),Z=void 0;try{if(X.stdout.trim().startsWith("{")||X.stdout.trim().startsWith("["))Z=JSON.parse(X.stdout)}catch{}B4(Y,X.isError?400:200,{success:!X.isError,stdout:X.stdout,stderr:X.stderr,exitCode:X.exitCode,data:Z});return}if(I==="POST"&&J.startsWith("/api/tool/")){let K=J.slice(10).trim(),G=w6(K);if(!G){pj(Y,404,`Tool not found: '${K}'`);return}let H=await dj($)||{},W=x8($,Q,H),X=T1(W),Z=await P1(X),q={...H};delete q.corp;let V=await v6(G,Z,q,X);B4(Y,200,V);return}if(J.startsWith("/v1/")){if(await uy1($,Y,I,J,Q))return}pj(Y,404,`Cannot ${I} ${J}. Visit /docs for available endpoints.`)}catch(K){let G=K instanceof Error?K.message:String(K);pj(Y,500,G)}}async function uy1($,Y,z,U,Q){let J=Object.fromEntries(Q.searchParams.entries());if(z==="GET"&&U==="/v1/corps"){let I=a8(),K=v4();return B4(Y,200,{count:I.length,mode:K.stateful?"stateful":"stateless",defaultCorpId:K.defaultCorpId,corps:I.map((G)=>({id:G.id,name:G.name,sourceType:G.source.type,sealUrl:G.seal?.url}))}),!0}if(z==="GET"&&U==="/v1/whoami"){let I=x8($,Q,J),K=T1(I),G=await P1(K),H=w6("seal_whoami"),W=await v6(H,G,{},K);return B4(Y,200,W),!0}if(z==="GET"&&U==="/v1/session"){let I=x8($,Q,J),K=T1(I),G=await P1(K),H=w6("seal_session_get"),W=await v6(H,G,{},K);return B4(Y,200,W),!0}if(z==="GET"&&U==="/v1/approval-runs/summary"){let I=x8($,Q,J),K=T1(I),G=await P1(K),H=w6("seal_approval_runs_summary"),W=await v6(H,G,J,K);return B4(Y,200,W),!0}if(z==="GET"&&U==="/v1/approval-runs/stats"){let I=x8($,Q,J),K=T1(I),G=await P1(K),H=w6("seal_approval_runs_stats"),W=await v6(H,G,J,K);return B4(Y,200,W),!0}if(z==="GET"&&U==="/v1/approval-runs/pick"){let I=x8($,Q,J),K=T1(I),G=await P1(K),H=w6("seal_approval_run_pick"),W=await v6(H,G,J,K);return B4(Y,200,W),!0}if(z==="GET"&&U==="/v1/approval-runs/url"){let I=x8($,Q,J),K=T1(I),G=await P1(K),H=w6("seal_approval_run_url_get"),W=await v6(H,G,J,K);return B4(Y,200,W),!0}if(U.startsWith("/v1/approval-runs/")){let I=U.slice(18).split("/"),K=I[0],G=I[1];if(K&&!["summary","pick","stats","url","bridge"].includes(K)){let H=x8($,Q,J),W=T1(H),X=await P1(W);if(!G){let Z=w6("seal_approval_run_get"),q=await v6(Z,X,{recordId:K,...J},W);return B4(Y,200,q),!0}if(G==="attachments"){let Z=w6("seal_approval_run_attachments_get"),q=await v6(Z,X,{recordId:K,...J},W);return B4(Y,200,q),!0}if(G==="cited-rules"){let Z=w6("seal_approval_run_cited_rules_get"),q=await v6(Z,X,{recordId:K,...J},W);return B4(Y,200,q),!0}if(G==="document-summary"){let Z=w6("seal_approval_run_document_summary_get"),q=await v6(Z,X,{recordId:K,...J},W);return B4(Y,200,q),!0}if(G==="result"){let Z=w6("seal_approval_run_result_get"),q=await v6(Z,X,{recordId:K,...J},W);return B4(Y,200,q),!0}}}if(z==="GET"&&U==="/v1/approval-runs"){let I=x8($,Q,J),K=T1(I),G=await P1(K),H=w6("seal_approval_runs_search"),W=await v6(H,G,{...J,limit:J.limit?Number(J.limit):void 0,offset:J.offset?Number(J.offset):void 0,includeBridge:J.includeBridge==="true"},K);return B4(Y,200,W),!0}if(z==="GET"&&U==="/v1/approval/rules"){let I=x8($,Q,J),K=T1(I),G=await P1(K),H=w6("seal_approval_rules_list"),W=await v6(H,G,J,K);return B4(Y,200,W),!0}if(z==="GET"&&U==="/v1/simulation/batches"){let I=x8($,Q,J),K=T1(I),G=await P1(K),H=w6("seal_simulation_batches_list"),W=await v6(H,G,J,K);return B4(Y,200,W),!0}if(z==="POST"&&U==="/v1/simulation/create-batchLine truncated
\uD83D\uDE80 seal-use HTTP Server (v${Z1}) started`),console.error(` URL: http://${z}:${Y}`),console.error(` Docs: http://${z}:${Y}/docs`),console.error(` OpenAPI: http://${z}:${Y}/openapi.json`),console.error(` CLI Exec: POST http://${z}:${Y}/api/cli`),console.error(` REST API: http://${z}:${Y}/v1/...
`);Q(U)})})}var mj=8787,lj="127.0.0.1";var go=m(()=>{Hg0();$3()});async function Wg0($){let Y=s0($.options.port)??s0($.options.p),z=h($.options.host)??h($.options.h),U=await oj({port:Y,host:z}),Q=()=>{U.close(()=>{process.exit(0)})};process.on("SIGINT",Q),process.on("SIGTERM",Q),await new Promise(()=>{})}var Xg0=m(()=>{A4();go()});async function Zg0($,Y,z,U){if($==="config"||$==="get"){await k0("seal_llm_config_get",Y,z,{},E0(U.options));return}if($==="providers"||$==="list"){await k0("seal_llm_providers_list",Y,z,{},E0(U.options));return}throw Error(`Unknown llm command: ${$??""}. Run 'seal-use help' for available commands.`)}var qg0=m(()=>{f4();K4()});async function Vg0($,Y){if($==="config"||$==="json"){yo();return}let{startServer:z}=await Og0().then(() => Fg0);z()}function yo(){x0({mcpServers:{"seal-use":{type:"stdio",command:"seal-use",args:["mcp"],env:{SEAL_USE_MCP_ENABLED:"true"}}}})}var Lg0=m(()=>{K4()});function wg0($){let Y=cj();x0(Y,{...E0($.options),allowFull:!0})}var Mg0=m(()=>{ho();K4()});async function Ng0($,Y,z,U){if($==="available"){await k0("seal_permissions_available_list",Y,z,{},E0(U.options));return}if($==="configs"||$==="list"){await k0("seal_permissions_configs_list",Y,z,{},E0(U.options));return}throw Error(`Unknown permissions command: ${$??""}. Run 'seal-use help' for available commands.`)}var Dg0=m(()=>{f4();K4()});import{readFileSync as Ag0}from"node:fs";async function Bg0($,Y,z,U,Q,J,I){if(!$||$==="get"){await k0("seal_preference_get",Q,J,{},E0(I.options));return}if($==="decision"){if(Y==="update"||!Y){let K=h(I.options.input),G=K?JSON.parse(Ag0(K,"utf8")):k8(I.json);if(!G||Object.keys(G).length===0)throw Error(`Usage: seal-use preference decision update --json '{"explicitApprove":"..."}'`);await k0("seal_preference_decision_update",Q,J,{...G,dryRun:Z0(I.options.dryRun)??Z0(I.options["dry-run"])},E0(I.options));return}}if($==="thinking-depth"||$==="thinkingDepth"){if(Y==="set"){let K=h(I.options.default)??h(I.options.level)??U;if(K!=="medium"&&K!=="high")throw Error("Usage: seal-use preference thinking-depth set --default <medium|high>");await k0("seal_preference_thinking_depth_set",Q,J,{defaultLevel:K,dryRun:Z0(I.options.dryRun)??Z0(I.options["dry-run"])},E0(I.options));return}if(Y==="policies"){if(z==="list"||!z){await k0("seal_preference_thinking_depth_policies_list",Q,J,{},E0(I.options));return}if(z==="upsert"){let K=h(I.options.input),G=K?JSON.parse(Ag0(K,"utf8")):k8(I.json);if(!G||!G.id||!G.name)throw Error(`Usage: seal-use preference thinking-depth policies upsert --json '{"id":"...","name":"...","level":"high"}'`);await k0("seal_preference_thinking_depth_policies_upsert",Q,J,{...G,dryRun:Z0(I.options.dryRun)??Z0(I.options["dry-run"])},E0(I.options));return}if(z==="remove"||z==="delete"){let K=U??h(I.options.id)??h(I.options.policyId);if(!K)throw Error("Usage: seal-use preference thinking-depth policies remove <policyId>");await k0("seal_preference_thinking_depth_policies_remove",Q,J,{policyId:K,dryRun:Z0(I.options.dryRun)??Z0(I.options["dry-run"])},E0(I.options));return}}}throw Error(`Unknown preference action: ${$??""}. Available: get, decision update, thinking-depth set, thinking-depth policies list/upsert/remove.`)}var Pg0=m(()=>{f4();A4();K4()});async function jg0($={}){let Y=a8(),z=v4(),U=n2(Y,{stateful:z.stateful,defaultCorpId:z.defaultCorpId,corpId:$.corpId},g3());console.log(`[probe] corp=${U.id} source=${U.source.type}`);let Q=await iK(U);console.log("[probe] seal enterprise"),console.log(JSON.stringify(Q,null,2));let J=await P1(U),I=await Ew(J,{documentLimit:20,stylePreferencesEndpoint:U.seal.endpoints.approvalStylePreferences});console.log("[probe] approval context summary"),console.log(JSON.stringify({rules:I.rules.rules.length,hasPendingRuleDeletes:I.rules.hasPendingDeletes,documents:I.documents.articles.length,documentsTotal:I.documents.total,stylePreferences:I.stylePreferences.ok?"ok":`error: ${I.stylePreferences.error}`},null,2))}var Tg0=m(()=>{k3();i8();fj();B6()});async function Eg0($,Y,z){let U=Y??h(z.options.corp)??($&&$!=="--corp"?$:void 0);await jg0({corpId:U})}var Cg0=m(()=>{Tg0();A4()});async function ko($,Y,z,U,Q){if($==="count"){await k0("seal_approval_rules_list",z,U,{countOnly:!0},E0(Q.options));return}if($==="list"){if(Z0(Q.options.count)){await k0("seal_approval_rules_list",z,U,{countOnly:!0},E0(Q.options));return}let J=s0(Q.options.limit),I=s0(Q.options.offset);if(Z0(Q.options.summary)){await k0("seal_approval_rules_list",z,U,{fields:d_0,limit:J,offset:I},E0(Q.options));return}let K=await O$("seal_approval_rules_list",z,U,{limit:J,offset:I}),G=E0(Q.options);m_0(K,G.allowFull===!0||Boolean(G.outputFile)),x0(K,G);return}if($==="clear"){let J=Z0(Q.options.yes)===!0,I=Z0(Q.options.dryRun)??Z0(Q.options["dry-run"])??!J;if(!J&&!I)throw A5("Refusing to clear rules without --yes. Use --dry-run to preview.",`seal-use rules clear --corp ${U.id} --dry-run`);let K=await O$("seal_approval_rules_clear",z,U,{dryRun:I,recode:Z0(Q.options.recode)});if(!J&&I& Line truncated
`).filter(Boolean),J=Q.slice(-Y);return{logFile:z,lines:J,totalLines:Q.length}}async function my1($){let Y=tj($),z=uo($),U=fq($);Sg0($.stateDir);let Q=$.port??(process.env.PORT?Number.parseInt(process.env.PORT,10):mj),J=$.host??(process.env.HOST?process.env.HOST:lj);sj(Y,`${process.pid}
`,{mode:384}),sj(z,JSON.stringify({pid:process.pid,port:Q,host:J,version:$.version,startedAt:new Date().toISOString()},null,2),{mode:384}),cK(U,`service starting on http://${J}:${Q} pid=${process.pid}`);let I=null;try{I=await oj({port:Q,host:J,silent:!0}),cK(U,`service listening pid=${process.pid}`)}catch(G){if(cK(U,`service failed to bind port ${Q}: ${G instanceof Error?G.message:String(G)}`),aj(Y)===process.pid)g9(Y,{force:!0}),g9(z,{force:!0});throw G}let K=()=>{if(I)I.close(),I=null;if(aj(Y)===process.pid)g9(Y,{force:!0}),g9(z,{force:!0});cK(U,`stopped pid=${process.pid}`)};await new Promise((G)=>{let H=!1,W=()=>{if(H)return;H=!0,K(),process.off("SIGTERM",W),process.off("SIGINT",W),G()};process.once("SIGTERM",W),process.once("SIGINT",W)})}function _g0($){Sg0($.stateDir);let Y=iU($);if(Y.running)return Y;let z=$.launcher??{command:process.execPath,args:[$.entryFile]},U=[...z.args??[],"service","run"];if($.port)U.push("--port",String($.port));if($.host)U.push("--host",String($.host));let Q=ny1(z.command,U,{cwd:$.appRoot,detached:!0,stdio:["ignore","ignore","ignore"],env:process.env});Q.unref();let J=tj($);return sj(J,`${Q.pid}
`,{mode:384}),cK(fq($),`started pid=${Q.pid}`),{started:!0,...iU($)}}function vg0($,Y={}){let z=tj($),U=uo($),Q=aj(z);if(!Q||!hg0(Q,$.appRoot))return g9(z,{force:!0}),g9(U,{force:!0}),Y.quiet?void 0:{stopped:!1,reason:"not running"};return process.kill(Q,"SIGTERM"),g9(z,{force:!0}),g9(U,{force:!0}),cK(fq($),`stop requested pid=${Q}`),Y.quiet?void 0:{stopped:!0,pid:Q}}function hg0($,Y){if(!ly1($))return!1;try{let z=cy1("ps",["-p",String($),"-o","command="],{encoding:"utf8"}),U=z.trim().split(/\s+/).filter(Boolean),Q=U.indexOf("service"),J=Q!==-1&&U[Q+1]==="run",I=z.includes(Y)||U.some((K)=>/(^|[\\/])(seal-use|seal-home)(\.exe)?$/.test(K));return J&&I}catch{return!1}}function ly1($){try{return process.kill($,0),!0}catch{return!1}}function tj($){return fo($.stateDir,"service.pid")}function uo($){return fo($.stateDir,"service.json")}function fq($){return fo($.stateDir,"service.log")}function aj($){if(!rj($))return;let Y=Number(xo($,"utf8").trim());return Number.isInteger(Y)&&Y>0?Y:void 0}function Sg0($){py1($,{recursive:!0,mode:448})}function cK($,Y){sj($,`${new Date().toISOString()} ${Y}
`,{flag:"a",mode:384})}var bo=m(()=>{go()});import{homedir as oy1}from"node:os";import{join as ry1}from"node:path";async function no($,Y,z){let U=z?s0(z.options.port)??s0(z.options.p):void 0,Q=z?h(z.options.host)??h(z.options.h):void 0,J=z?s0(z.options.lines)??s0(z.options.n):void 0,I=await r3($,{appRoot:Y.appRoot,entryFile:Y.entryFile,stateDir:io,version:Z1,launcher:Y.launcher,port:U,host:Q},{maxLines:J});if(I!==void 0)x0(I)}var io;var co=m(()=>{$3();bo();K4();A4();io=ry1(oy1(),".config","seal-use")});import{existsSync as sy1,readFileSync as gg0}from"node:fs";async function yg0($,Y,z,U,Q){if($==="batch-records"||$==="records"){let J=Y??h(Q.options.batchId)??h(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation batch-records <batchId>");await k0("seal_simulation_batch_records_get",z,U,{batchId:J,query:h(Q.options.query)},E0(Q.options));return}if($==="create"||$==="run"){let J=h(Q.options.mode)??h(Q.options.sourceSystem)??h(Q.options["source-system"])??"hosecloud",I=J==="material-pack"?"material_pack":J,K=h(Q.options.schemaConfig)??h(Q.options["schema-config"]),G=K?JSON.parse(gg0(K,"utf8")):void 0,H=h(Q.options.input),W=H?JSON.parse(gg0(H,"utf8")):k8(Q.json),X=h(Q.options.packageId)??h(Q.options["package-id"]),Z=i6(Q.options.packageIds)??i6(Q.options["package-ids"])??(X?[X]:void 0),q=i6(Q.options.flowIds)??i6(Q.options["flow-ids"])??i6(Q.options.documentSn)??i6(Q.options["document-sn"]),V=h(Q.options.signKey)??h(Q.options["sign-key"])??h(Q.options.integration),F=Z0(Q.options.wait)===!0,w=Z0(Q.options.noWait)??Z0(Q.options["no-wait"])??(F?!1:!0),O=await O$("seal_simulation_batch_create",z,U,{mode:I,sourceSystem:I,flowIds:q,documentSn:q,rejectNodeName:h(Q.options.rejectNode)??h(Q.options["reject-node"])??null,thinkingDepthOverride:h(Q.options.thinkingDepth)??h(Q.options["thinking-depth"]),skipInvoiceGeneration:Z0(Q.options.skipInvoiceGeneration)??Z0(Q.options["skip-invoice-generation"]),skipExpenseExtraction:Z0(Q.options.skipExpenseExtraction)??Z0(Q.options["skip-expense-extraction"]),disableAttachmentCache:Z0(Q.options.disableAttachmentCache)??Z0(Q.options["disable-attachment-cache"]),signKey:V,packageIds:Z,packageId:X,templateId:h(Q.options.templateId)??h(Q.options["template-id"]),schemaConfig:G,requestIds:i6(Q.options.requestIds)??i6(Q.options["request-ids"]),workflowTypeId:h(Q.options.workflowTypeId)??h(Q.options["workflow-type-id"]),flowStatusList:i6(Q.options.flowStatusList)?.map(Number)??i6(Q.options["flow-status-list"])?.map(Number),businessCodes:i6(Q.options.businessCodes)??i6(Q.options["business-codes"]),documentType:h(Q.options.documentType)??h(Q.options["document-type"]),startTime:s0(Q.options.startTime)??s0(Q.options["start-time"]),endTime:s0(Q.options.endTime)??s0(Q.options["end-time"]),status:i6(Q.options.status),limit:s0(Q.options.limit),noWait:w,rawParams:W});if(F&&O&&typeof O==="object"&&"batchId"in O&&typeof O.batchId==="string"){await k0("seal_simulation_batch_wait",z,U,{batchId:O.batchId,timeout:h(Q.options.timeout),pollInterval:h(Q.options.pollInterval)??h(Q.options["poll-interval"])},E0(Q.options));return}x0(O,E0(Q.options));return}if($==="wait"){let J=Y??h(Q.options.batchId)??h(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s]");await k0("seal_simulation_batch_wait",z,U,{batchId:J,timeout:h(Q.options.timeout),pollInterval:h(Q.options.pollInterval)??h(Q.options["poll-interval"])},E0(Q.options));return}if($==="status"){let J=Y??h(Q.options.batchId)??h(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation status <batchId>");await k0("seal_simulation_batch_status",z,U,{batchId:J},E0(Q.options));return}if($==="clean"||$==="delete"){let J=Y??h(Q.options.batchId)??h(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation clean <batchId>");await k0("seal_simulation_batch_clean",z,U,{batchId:J},E0(Q.options));return}if($==="specifications"){let J=Y??h(Q.options.integration)??h(Q.options.signKey)??h(Q.options["sign-key"]);await k0("seal_simulation_specifications_list",z,U,{signKey:J},E0(Q.options));return}if($==="approval-definitions"||$==="definitions"){await k0("seal_simulation_feishu_approval_definitions_list",z,U,{},E0(Q.options));return}if($==="list"){await k0("seal_simulation_batches_list",z,U,{limit:s0(Q.options.limit)},E0(Q.options));return}if($==="get"){let J=Y??h(Q.options.batchId)??h(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation get <batchId>");await k0("seal_simulation_batch_get",z,U,{batchId:J},E0(Q.options));return}if($==="templates"){await k0("seal_simulation_templates_get",z,U,{},E0(Q.options));return}if($==="integrations"){await k0("seal_simulation_integrations_get",z,U,{},E0(Q.options));return}if($==="package-upload"){let J=Y??h(Q.options.file);if(!J)throw Error("Usage: seal-use simulation package-upload <材料包.zip>");if(!sy1(J))throw Error(`File not found: ${J}`);await k0("seal_simulation_material_package_upload",z,U,{filePath:J},E0(Q.o Line truncated
`);return}if($==="install"||$==="init"||$==="sync"){let U=Z0(z.options.local)||Z0(z.options.workspace),Q=h(z.options.dir)??h(z.options.target)??Y,J=Q?Q:U?ej(process.cwd(),".agents","skills","seal-use"):bU(),I=mS0(J),K=!U&&!Q,G=K?wo():void 0,H=K?Do():void 0;x0({installed:!0,targetDir:I.targetDir,fileCount:I.files.length,files:I.files,...G?{antigravity:G}:{},...H?{hosts:H}:{}});return}if($==="status"||$==="get"||!$){let U=bU(),Q=ej(process.cwd(),".agents","skills","seal-use"),J=Mo(),I=Ao();x0({global:{dir:U,installed:xg0(ej(U,"SKILL.md"))},local:{dir:Q,installed:xg0(ej(Q,"SKILL.md"))},antigravity:J,hosts:I});return}throw Error(`Unknown skill command: ${$}. Run 'seal-use help' for available commands.`)}var ug0=m(()=>{Po();yq();A4();K4()});async function bg0($,Y){if($==="config"){x0(await iK(Y));return}throw Error(`Unknown source command: ${$??""}. Run 'seal-use help' for available commands.`)}var ig0=m(()=>{fj();K4()});function po($){if(typeof $!=="string"||!$.trim())return"UNKNOWN";let Y=$.toUpperCase().trim();if(Y==="APPROVE"||Y==="PASS")return"APPROVE";if(Y==="REJECT"||Y==="DENIED")return"REJECT";if(Y==="MANUAL"||Y==="ASSISTED")return"MANUAL";if(Y==="ERROR"||Y==="FAILED")return"ERROR";return Y}async function ng0($){let{sourceCorp:Y,targetCorp:z,sourceClient:U,targetClient:Q,samples:J=10,dryRun:I=!1,pollIntervalMs:K=2000,timeoutMs:G=45000,snPrefix:H="REG_",fetchFn:W=fetch}=$;if(z.environment!=="test")throw new L4(`重放目标企业「${z.name}」(${z.id}) 的环境为「${z.environment}」,非测试环境!
`+"硬性安全规定:自动化回归测试矩阵严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-use corps bind-test ${Y.id} <testCorpId>`);let X=await lY(Q),q=(Array.isArray(X.features)?X.features:[]).find((d)=>d?.code==="ai-approval"),V=typeof q?.balance==="number"?q.balance:0,F=typeof q?.deductionAmount==="number"&&q.deductionAmount>0?q.deductionAmount:120,w=J*F;if(V<w)throw new L4(`测试企业「${z.name}」AI 审批额度不足:当前剩余 ${V} 点,本次回归抽样 ${J} 笔需要约 ${w} 点。
`+"为防止测试环境额度耗尽中断业务,已硬性拦截并拒绝发起测试单据注入。",2,`请为测试企业「${z.id}」充值 AI 审批额度,或降低抽样笔数 (--samples ${Math.max(1,Math.floor(V/F))})`);let O=await i4(U,{limit:J,status:"completed"}),N=Array.isArray(O.records)?O.records:[];if(N.length===0){let d=await i4(U,{limit:J});N=Array.isArray(d.records)?d.records:[]}if(N.length===0)throw new L4(`在母企业「${Y.name}」(${Y.id}) 中未检索到任何历史审批单据,无法抽取回归样本。`,2);if(N=N.slice(0,J),I){let d=N.map((t)=>{let e=t.sourceDocumentSN??t.id,g=t?.result?.decision??t.aiDecision??t?.decision,p=po(g),Y0=t?.result?.summary??t.aiSummary;return{sn:e,sourceRecordId:t.id,prodDecision:p,prodSummary:Y0,status:"DRY_RUN"}});return{ok:!0,verdict:"DRY_RUN",safeToPublish:!0,timestamp:new Date().toISOString(),sourceCorp:{id:Y.id,name:Y.name,environment:Y.environment??"production"},targetCorp:{id:z.id,name:z.name,environment:z.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:V,deductionAmount:F,estimatedRequired:w},metrics:{sampleCount:d.length,successCount:d.length,failureCount:0,matchCount:d.length,flipCount:0,concordanceRate:1},flips:[],records:d}}let M=await Bp(Q,z,$.webhookSelector),D=[];for(let d of N){let t=Date.now(),e=d.sourceDocumentSN??d.id,g=po(d?.result?.decision??d.aiDecision??d?.decision),p=d?.result?.summary??d.aiSummary;try{let Y0=await H4(U,d.id),y=`${H}${e}`,r=Dp(Y0,{snPrefix:H,docIdPrefix:H});await Ap(M.incomingDocumentWebhook.url,M.secret,r,W,A6(z.seal));let $0=null,N0=Date.now();while(Date.now()-N0<G){await new Promise((H0)=>setTimeout(H0,K));let s=await i4(Q,{sourceDocumentSN:y,limit:1});if(s.records&&s.records.length>0){let H0=s.records[0];if(H0.status==="completed"||H0.status==="failed"){$0=H0;break}}}if(!$0){D.push({sn:e,sourceRecordId:d.id,prodDecision:g,prodSummary:p,status:"FAILED",error:`测试租户单据审核超时 (${Math.round(G/1000)}s 未完成)`,durationMs:Date.now()-t});continue}let T0=po($0?.result?.decision??$0.aiDecision??$0?.decision??($0.status==="completed"?"APPROVE":"ERROR")),_0=$0?.result?.summary??$0.aiSummary,G0=g===T0,f0=G0?"MATCHED":"FLIPPED",e0={sn:e,sourceRecordId:d.id,prodDecision:g,prodSummary:p,testRecordId:$0.id,testDecision:T0,testSummary:_0,status:f0,durationMs:Date.now()-t};if(!G0)e0.diff={from:g,to:T0,reasonDiff:_0&&p&&_0!==p?`生产: ${p.slice(0,60)}... -> 测试: ${_0.slice(0,60)}...`:void 0};D.push(e0)}catch(Y0){D.push({sn:e,sourceRecordId:d.id,prodDecision:g,prodSummary:p,status:"FAILED",error:Y0 instanceof Error?Y0.message:String(Y0),durationMs:Date.now()-t})}}let P=D.filter((d)=>d.status==="MATCHED"||d.status==="FLIPPED"),j=D.filter((d)=>d.status==="MATCHED"),A=D.filter((d)=>d.status==="FLIPPED"),T=D.filter((d)=>d.status==="FAILED").length,C=j.length,b=A.length,k=C+b,S=k>0?C/k:0,i=b>0,n=i?"REGRESSIONS_DETECTED":"CLEAN",U0=!i&&T===0,x;try{let d=await lY(Q),e=(Array.isArray(d.features)?d.features:[]).find((g)=>g?.code==="ai-approval");if(typeof e?.balance==="number")x=e.balance}catch{}return{ok:!i&&T===0,verdict:n,safeToPublish:U0,timestamp:new Date().toISOString(),sourceCorp:{id:Y.id,name:Y.name,environment:Y.environment??"production"},targetCorp:{id:z.id,name:z.name,environment:z.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:V,deductionAmount:F,estimatedRequired:w,balanceAfter:x},metrics:{sampleCount:D.length,successCount:P.length,failureCount:T,matchCount:C,flipCount:b,concordanceRate:Number(S.toFixed(4))},flips:A,records:D}}function cg0($){let{sourceCorp:Y,targetCorp:z,verdict:U,safeToPublish:Q,metrics:J,quota:I,flips:K,records:G}=$,H=U==="CLEAN"?"\uD83D\uDFE2 决策完全一致 (CLEAN - 无回归)":U==="DRY_RUN"?"⚪ 预演模式 (DRY-RUN)":"\uD83D\uDD34 发现决策翻转 (REGRESSIONS_DETECTED)",W=["",`\uD83E\uDDEA [Seal Use Test] 规则回归测试矩阵: 生产「${Y.name}」-> 测试靶场「${z.name}」`,` 判定: ${H} · 准许发布: ${Q?"YES (可安全上线)":"NO (存在行为偏离/待复核)"}`," "+"─".repeat(65),` 样本总数: ${J.sampleCount} | 一致通过: ${J.matchCount} | 决策翻转: ${J.flipCount} | 异常失败: ${J.failureCount}`,` 一致率: ${(J.concordanceRate*100).toFixed(1)}% | 消耗预估: ${I.estimatedRequired} 点 (余量: ${I.balanceBefore}${I.balanceAfter!==void 0?` -> ${I.balanceAfter}`:""})`," "+"─".repeat(65)];if(K.length>0){W.push(` ⚠️ 决策翻转清单 (${K.length} 笔单据在新规则下结果改变):`);for(let X of K)if(W.push(` • 单据 [${X.sn}]: 原生产判定「${X.prodDecision}」 ➔ 测试新判定「${X.testDecision}」`),X.diff?.reasonDiff)W.push(` 理由差异: ${X.diff.reasonDiff}`);W.push(" "+"─".repeat(65)),W.push(" \uD83D\uDC49 建议: 请检查上述翻转单据是否符合预期修正。若为意外误杀,请调整测试环境规则后再次回归。")}else if(U==="CLEAN")W.push(" ✓ 全部样本在新规则下的审核决策与生产历史 100% Line truncated
`)}var pg0=m(()=>{F$();B6();fZ()});async function mo($,Y,z){let U=($??Y??"regression").toLowerCase();if(U==="regression"||U==="regress"||U==="matrix"){let Q=h(z.options.corp)??(Y&&Y!==U?Y:void 0),J=T1(Q),I=J,K=J;if(J.environment==="test"){K=J;let M=h(z.options["prod-corp"])??h(z.options.prod)??J.prodCorpId;if(!M)throw new L4(`测试企业「${J.name}」(${J.id}) 未绑定生产母企业,无法拉取历史样本。
`+"请建立绑定或通过 --prod-corp 参数指定生产企业来源。",2,`seal-use corps bind-test <prodCorpId> ${J.id}`);I=T1(M)}else{I=J;let M=h(z.options["test-corp"])??h(z.options.test)??J.testCorpId;if(!M)throw new L4(`生产企业「${J.name}」(${J.id}) 未绑定测试靶场企业。
`+"硬性规定:回归测试严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-use corps bind-test ${J.id} <testCorpId>`);K=T1(M)}let G=await P1(I),H=await P1(K),W=s0(z.options.samples)??s0(z.options.limit)??s0(z.options.n)??10,X=Z0(z.options["dry-run"]),Z=Z0(z.options["fail-on-flips"]),q=s0(z.options["poll-interval"])??2000,V=s0(z.options.timeout)??45000,F=h(z.options["sn-prefix"])??"REG_",w=h(z.options.webhook)??h(z.options.selector),O=await ng0({sourceCorp:I,targetCorp:K,sourceClient:G,targetClient:H,samples:W,dryRun:X,pollIntervalMs:q,timeoutMs:V,snPrefix:F,failOnFlips:Z,webhookSelector:w});if(!(Z0(z.options.quiet)||Z0(z.options.silent)))console.error(cg0(O));if(x0(O),Z&&!O.ok)throw new L4(`回归测试发现 ${O.metrics.flipCount} 笔单据决策翻转,已按 --fail-on-flips 策略非零终止。`,1);return}throw new L4(`未知的 test 子命令: "${U}"。
可用子命令: seal-use test regression [--corp <id>] [--samples <N>] [--dry-run]`,2,"seal-use test regression --help")}var dg0=m(()=>{F$();f4();A4();K4();i8();pg0()});async function mg0($,Y,z,U){if(!$)throw Error("Usage: seal-use tool <toolName> [--json '{...}']");await k0($,Y,z,k8(U.json),E0(U.options))}var lg0=m(()=>{f4();A4();K4()});function og0(){x0(Dq.map(($)=>({name:$.name,description:$.description})))}var rg0=m(()=>{Bq();K4()});function $T($=process.execPath,Y=import.meta.url){if(Y.includes("/$bunfs/")||Y.includes("\\$bunfs\\"))return!0;let z=$.toLowerCase().replace(/\\/g,"/");return!z.endsWith("/bun")&&!z.endsWith("/bun.exe")&&!z.endsWith("/node")&&!z.endsWith("/node.exe")}var sg0=m(()=>{yq()});import{existsSync as ay1,mkdirSync as ty1,readFileSync as ey1,renameSync as $k1,writeFileSync as Yk1}from"node:fs";import{homedir as zk1}from"node:os";import{dirname as Uk1,join as Qk1}from"node:path";import{spawn as Jk1}from"node:child_process";function ag0(){let $=process.env[Ik1]?.trim();if($)return $;return Gk1}function tg0($=ag0()){if(!ay1($))return null;try{let Y=ey1($,"utf-8"),z=JSON.parse(Y);if(z&&typeof z==="object"&&typeof z.latestVersion==="string"&&typeof z.checkedAt==="string")return z;return null}catch{return null}}function uq($,Y=ag0()){try{let z=Uk1(Y);ty1(z,{recursive:!0,mode:448});let U={checkedAt:$.checkedAt??new Date().toISOString(),latestVersion:$.latestVersion,publishedAt:$.publishedAt,releaseUrl:$.releaseUrl},Q=`${Y}.tmp.${Date.now()}.${Math.random().toString(36).slice(2,8)}`;Yk1(Q,JSON.stringify(U,null,2),{mode:384}),$k1(Q,Y)}catch{}}function eg0($,Y=Kk1){if(!$||!$.checkedAt)return!0;let z=new Date($.checkedAt).getTime();if(Number.isNaN(z))return!0;return Date.now()-z>Y}function $y0($){if(process.env.SEAL_DISABLE_BG_UPDATE==="1"||!1||process.env.CI)return!1;if(!$||!$.command)return!1;try{let Y=$.command,z=[...$.args??[],"update","check","--bg-save"];return Jk1(Y,z,{detached:!0,stdio:"ignore",env:{...process.env,SEAL_DISABLE_BG_UPDATE:"1"}}).unref(),!0}catch{return!1}}var Ik1="SEAL_USE_UPDATE_CACHE_FILE",Kk1=86400000,Gk1;var lo=m(()=>{Gk1=Qk1(zk1(),".config","seal-use","update-cache.json")});import{chmodSync as Hk1,mkdirSync as Wk1,readdirSync as Xk1,realpathSync as Yy0,renameSync as oo,rmSync as Zk1,unlinkSync as Jy0,writeFileSync as zy0}from"node:fs";import{basename as qk1,dirname as Vk1,isAbsolute as Lk1,join as UT,relative as Fk1}from"node:path";import{spawnSync as _5}from"node:child_process";async function Ky0($,Y={}){let z={appRoot:$.appRoot,entryFile:$.entryFile,stateDir:io,version:Z1,launcher:$.launcher},U=Y.repo||process.env[Ok1]?.trim()||process.env[wk1]?.trim()||Iy0,Q=Y.targetVersion?.trim(),J=Q&&Q.toLowerCase()!=="latest"?Q:void 0;if(J){let D=J.replace(/^v/,""),P=Xy0(D,Z1);if(P<0)if(!sS&&Y.force);else{x0({updated:!1,currentVersion:Z1,targetVersion:D,mode:$T()?"binary":"source",message:!sS?`Cannot downgrade seal-use from dev build v${Z1} to release v${D}. Use --force to overwrite.`:`Cannot downgrade seal-use from v${Z1} to older version v${D}. Updates must be forward-only.`});return}if(P===0&&!Y.force){x0({updated:!1,currentVersion:Z1,targetVersion:D,mode:$T()?"binary":"source",message:`seal-use is already at version v${Z1}. Use --force to reinstall.`});return}}if(Y.changelogOnly){let D=await zT(U,Y.limit??10);x0({currentVersion:Z1,totalQueried:D.length,releases:D.map((P)=>({version:P.version,tagName:P.tagName,publishedAt:P.publishedAt,author:P.author,releaseNotes:P.notes,releaseUrl:P.htmlUrl,isCurrent:P.version===Z1,isNewer:R5(P.version,Z1)}))});return}if(!$T()){if(Y.checkOnly){let P=await zT(U,30),j=P[0],A=j?.version??Z1,T=P.find((k)=>k.version===Z1),C=R5(A,Z1),b=P.filter((k)=>R5(k.version,Z1));if(j?.version)uq({latestVersion:j.version,publishedAt:j.publishedAt,releaseUrl:j.htmlUrl});if(Y.bgSave)return;x0({updated:!1,updateAvailable:C,currentVersion:Z1,currentVersionPublishedAt:T?.publishedAt,latestVersion:A,latestVersionPublishedAt:j?.publishedAt,behindCount:b.length,pendingReleases:b.map((k)=>({version:k.version,tagName:k.tagName,publishedAt:k.publishedAt,author:k.author,releaseNotes:k.notes,releaseUrl:k.htmlUrl})),releaseNotes:j?.notes??"",releaseUrl:j?.htmlUrl??"",mode:"source",message:"当前运行的是开发版。正式用户请安装正式版后使用 seal-use update。"});return}let D=iU(z).running;if(D)await r3("stop",z);try{Qy0("git",["-C",$.appRoot,"pull","--ff-only"])}catch(P){console.error(`⚠️ 开发版更新同步失败,继续刷新本地依赖: ${P instanceof Error?P.message:String(P)}`)}if(Qy0("bun",["install"],{cwd:$.appRoot}),D)await r3("start",z);x0({updated:!0,serviceRestarted:D,version:Z1,mode:"source"});return}if(Bk1())try{await Pk1($,Y,z,U,J);return}catch(D){console.error(`⚠️ Homebrew 自动更新失败,回退至原生二进制更新: ${D instanceof Error?D.message:String(D)}`)}let I=Nk1(),K=Dk1(),G=await zT(U,30),H=J?G.find((D)=>D.version===J||D.tagName===J||D.tagName===`v${J}`)??await QT(U,J):G[0]??await QT(U);if(!H){x0({updated:!1, Line truncated
`)}catch{}}async function Ek1($,Y,z,U){let Q=ro(),J=[],I=z?z.startsWith("v")?z:`v${z}`:void 0,K=U||$.split("/").pop()||"";if(Q!=="github"){if(I&&K)J.push(`https://git.ying-qing.cn/gitea/seal-use/releases/download/${I}/${K}`,`https://git.ying-qing.cn/gitea/seal-home/releases/download/${I}/${K}`);if($.startsWith("https://git.ying-qing.cn"))J.push($)}if(Q!=="gitea")if(I&&K){let F=`https://github.com/${Iy0}/releases/download/${I}/${K}`;if(!process.env.CI)J.push(`https://ghfast.top/${F}`,`https://gh.ddlc.top/${F}`);J.push(F)}else if($.includes("github.com")){if(!process.env.CI)J.push(`https://ghfast.top/${$}`,`https://gh.ddlc.top/${$}`);J.push($)}else J.push($);let G=Array.from(new Set(J)),H,W=6000,X=6000,Z=307200,q=1e4,V=180000;for(let F=0;F<G.length;F++){let w=G[F],O=new AbortController,N="",M=(A)=>{N=A;try{O.abort()}catch{}},D=setTimeout(()=>{M("Connection timed out (no response headers within 6s)")},W),P,j;try{YT(`==> [${F+1}/${G.length}] Downloading via: ${w}`);let A=await fetch(w,{signal:O.signal});if(D)clearTimeout(D),D=void 0;if(!A.ok)throw Error(`HTTP ${A.status} ${A.statusText}`);P=setTimeout(()=>{M("Overall download time exceeded 3 minutes")},V);let T=Number(A.headers.get("content-length"))||0,C=A.body?.getReader();if(!C){let n=Buffer.from(await A.arrayBuffer());if(n.length<1000)throw Error(`Downloaded content is suspiciously small (${n.length} bytes)`);zy0(Y,n),YT(`✓ Download succeeded (${(n.length/1024/1024).toFixed(1)} MB)`);return}let b=[],k=0,S=0;j=setTimeout(()=>{if(k<Z){let n=(k/1024).toFixed(1);M(`Initial transfer too slow (${n} KB < 300 KB in 6s), switching mirror...`)}},X);while(!0){let n=C.read(),U0,x=new Promise((g,p)=>{U0=setTimeout(()=>{p(Error("Data transfer stalled (no chunk received for 10s)"))},q)}),d;try{d=await Promise.race([n,x])}finally{if(U0)clearTimeout(U0)}let{done:t,value:e}=d;if(t)break;if(e){if(b.push(e),k+=e.length,j&&k>=Z)clearTimeout(j),j=void 0;let g=Date.now();if(g-S>200){S=g;let p=T?Math.round(k/T*100):0,Y0=(k/1048576).toFixed(1),y=T?(T/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${p}% (${Y0} / ${y} MB)...`)}catch{}}}}try{process.stderr.write(`
`)}catch{}let i=Buffer.concat(b);if(i.length<1000)throw Error(`Downloaded content is suspiciously small (${i.length} bytes)`);zy0(Y,i),YT(`✓ Download completed successfully (${(i.length/1024/1024).toFixed(1)} MB)`);return}catch(A){if(D)clearTimeout(D);if(j)clearTimeout(j);if(P)clearTimeout(P);let T=N||(A instanceof Error?A.message:String(A));H=Error(T),YT(`
↳ Mirror failed: ${H.message}`)}finally{if(D)clearTimeout(D);if(j)clearTimeout(j);if(P)clearTimeout(P)}}throw Error(`Failed to download asset from all mirrors: ${H?.message}`)}function Hy0($){let Y;try{Y=Xk1($,{withFileTypes:!0})}catch{return[]}let z=[];for(let U of Y){let Q=UT($,U.name);if(U.isDirectory())z.push(...Hy0(Q));else if(U.isFile())z.push(Q)}return z}function Wy0($,Y,z){let U=Y==="windows"?"seal-use.exe":"seal-use",Q=Hy0($);return Q.find((J)=>qk1(J)===U)??Q[0]??z}function Ck1($,Y,z){let U=_5("tar",["-xzf",$,"-C",Y],{stdio:"pipe"});if(U.status!==0)throw Error(`Failed to extract tar archive: ${U.stderr.toString()}`);return Jy0($),Wy0(Y,z,$)}function Rk1($,Y,z){let U=_5("unzip",["-q","-o",$,"-d",Y],{stdio:"pipe"});if(U.status!==0)throw Error(`Failed to extract zip archive: ${U.stderr.toString()}`);return Jy0($),Wy0(Y,z,$)}function Xy0($,Y){let z=$.replace(/^v/,"").split(".").map((Q)=>Number.parseInt(Q,10)||0),U=Y.replace(/^v/,"").split(".").map((Q)=>Number.parseInt(Q,10)||0);for(let Q=0;Q<Math.max(z.length,U.length);Q++){let J=z[Q]??0,I=U[Q]??0;if(J>I)return 1;if(J<I)return-1}return 0}function R5($,Y){return Xy0($,Y)>0}function Qy0($,Y,z={}){let U=_5($,Y,{cwd:z.cwd,encoding:"utf8",stdio:["ignore","pipe","pipe"]});if(U.stdout)console.error(U.stdout.trimEnd());if(U.stderr)console.error(U.stderr.trimEnd());if(U.status!==0)throw Error(`${$} ${Y.join(" ")} failed with status ${U.status}`)}var Iy0="yunyingk/seal-use",bq="yunyingk/seal-home",Ok1="SEAL_USE_GITHUB_REPO",wk1="SEAL_HOME_GITHUB_REPO";var Zy0=m(()=>{sg0();yq();lo();$3();bo();K4();co()});async function qy0($,Y,z,U,Q){if($==="create"){let J=h(Q.options.name)??Y,I=h(Q.options.phone);if(!J||!I)throw Error("Usage: seal-use users create --name <name> --phone <phone> [--dept <deptId>]");let K=h(Q.options.dept)??h(Q.options.departmentId);await k0("seal_user_create",z,U,{name:J,phone:I,departmentIds:K?[K]:void 0},E0(Q.options));return}if($==="reset-password"){let J=Y??h(Q.options.userId);if(!J)throw Error("Usage: seal-use users reset-password <userId>");await k0("seal_user_reset_password",z,U,{userId:J},E0(Q.options));return}if($==="search"||$==="list"){let J=Y??h(Q.options.keyword)??h(Q.options.query)??"";await k0("seal_user_search",z,U,{keyword:J},E0(Q.options));return}if($==="get"){let J=Y??h(Q.options.userId);if(!J)throw Error("Usage: seal-use users get <userId>");await k0("seal_user_get",z,U,{userId:J},E0(Q.options));return}if($==="delete"){let J=Y??h(Q.options.userId);if(!J)throw Error("Usage: seal-use users delete <userId>");await k0("seal_user_delete",z,U,{userId:J},E0(Q.options));return}if($==="activate"){let J=Y??h(Q.options.userId);if(!J)throw Error("Usage: seal-use users activate <userId>");await k0("seal_user_activate",z,U,{userId:J},E0(Q.options));return}if($==="delegation"||$==="impersonate"){let J=Y??h(Q.options.userId)??h(Q.options.phone);if(!J)throw Error("Usage: seal-use users delegation <userIdOrPhone> [--note <note>]");let I=h(Q.options.note);await k0("seal_user_delegation_create",z,U,{userIdOrPhone:J,note:I},E0(Q.options));return}throw Error(`Unknown users command: ${$??""}. Run 'seal-use help' for available commands.`)}var Vy0=m(()=>{f4();A4();K4()});import{dirname as so,join as _k1}from"node:path";import{fileURLToPath as vk1}from"node:url";function yk1($){if(!$.length)return!1;let Y=$[0]?.toLowerCase(),z=$[1]?.toLowerCase();if(Y&&gk1.has(Y))return!0;if((Y==="service"||Y==="daemon")&&z==="run")return!0;return!1}function xq($,Y={}){if(yk1($))return Oy0($,Y);let z=Fy0.then(()=>Oy0($,Y));return Fy0=z.then(()=>{return},()=>{return}),z}async function Oy0($,Y){let z=[],U=[],Q=console.log,J=console.error,I={appRoot:Y.appRoot??Ly0,entryFile:Y.entryFile??_k1(Y.appRoot??Ly0,"src","cli.ts"),launcher:Y.launcher};console.log=(...K)=>{z.push(cl(K))},console.error=(...K)=>{U.push(cl(K))};try{return await kk1($,I),{stdout:jq(z),stderr:jq(U),isError:!1,exitCode:0}}catch(K){let G=Tq(K instanceof Error?K.message:String(K)),H=xZ(K);if(U.push(G),H.nextAction&&!G.includes("Next action:"))U.push(`\uD83D\uDC49 Next action: ${H.nextAction}`);return{stdout:jq(z),stderr:jq(U),isError:!0,exitCode:H.exitCode}}finally{console.log=Q,console.error=J}}async function kk1($,Y){let z=Pq($),[U,Q,J]=z.command,I=U?.toLowerCase(),K=I?hk1.has(I):!1,G=K?"update":I;if(G==="version"||G==="v"||Boolean(z.options.version)||Boolean(z.options.v)||Boolean(z.options.V)){let Z=tg0(),q=Z?.latestVersion?R5(Z.latestVersion,dY.version):!1,V={...dY,...Z?.latestVersion?{latestVersion:Z.latestVersion,updateAvailable:q,lastCheckedAt:Z.checkedAt}:{}};if(q&&Z?.latestVersion)console.error(`\uD83D\uDCA1 发现新版本可用: v${dY.version} -> v${Z.latestVersion}`),console.error(`\uD83D\uDC49 Next action: seal-use update
`);if(x0(V),eg0(Z))$y0(Y.launcher);return}let H=c_0(z);if(H.isHelp){l_0(H.target);return}if(!G||!Sk1.has(G))throw Error(`Unknown command: ${z.command.join(" ")}. Run 'seal-use help' for available commands.`);if(G==="webhook"&&(Q==="resource-pack"||Q==="pack"||Q==="material-pack")&&J==="preview"){let Z=z.command[3]??h(z.options.file)??h(z.options.input);if(!Z)throw Error("Usage: seal-use webhook resource-pack preview <资源包.zip>");await r_0(Z,fK(z.options));return}if(G==="openapi"){wg0(z);return}if(G==="mcp-config"){yo();return}if(G==="skill"){fg0(Q,J,z);return}if(G==="mcp"||G==="server"){await Vg0(Q,z);return}if(G==="probe"){await Eg0(Q,J,z);return}if(G==="doctor"){await Yg0(Q,J,z);return}if(G==="test"){await mo(Q,J,z);return}if(G==="config"){ch0(Q,J,z);return}if(G==="service"){await no(Q,Y,z);return}if(G==="stop"){await no("stop",Y,z);return}if(G==="http"||G==="serve"){await Wg0(z);return}if(K||G==="changelog"){if(K&&U!=="update")console.error(`⚠️ Notice: '${U}' is an alias for 'seal-use update'. Please use 'seal-use update' instead.`);let Z=Q?.toLowerCase(),q=G==="changelog"||Z==="changelog"||Z==="log"||Z==="history"||Z0(z.options.changelog)===!0,V=Z==="check"||Z0(z.options.check)===!0||Z0(z.options["check-only"])===!0,F=Z0(z.options["bg-save"])===!0||Z0(z.options["silent-save"])===!0,w=h(z.options.version)??h(z.options.tag)??(!q&&!V&&!F&&Q&&!Q.startsWith("-")?Q:void 0);await Ky0(Y,{checkOnly:V||F,changelogOnly:q,limit:s0(z.options.limit),force:Z0(z.options.force),targetVersion:w,repo:h(z.options.repo),bgSave:F});return}if(G==="tools"&&Q==="list"){og0();return}if(G==="corps"||G==="corp"){if(Q==="regression"||Q==="test-regression"){await mo("regression",J,z);return}await Sh0(Q,J,z);return}if(G==="rules"&&Q==="lint"&&(("file"in z.options)||("f"in z.options))){let Z;try{Z=T1(h(z.options.corp))}catch{Z={id:"local",name:"Local Workspace",source:{type:"native"}}}await ko(Q,J,null,Z,z);return}if(G==="auth"&&(Q==="extract-keys"||Q==="extract-key"||Q==="extract-hose-keys"||Q==="hose-extract-keys")){await qo(J,z);return}if(G==="auth"&&(Q==="link"||Q==="seal-link")&&(("from-link"in z.options)||J==="from-link")){await ij(Q,null,z);return}let W=T1(h(z.options.corp));if(G==="source"){await bg0(Q,W);return}if(G==="auth"){await ij(Q,W,z);return}let X=await P1(W);if(G==="users"){await qy0(Q,J,X,W,z);return}if(G==="contacts"){await dh0(Q,J,X,W,z);return}if(G==="data"){await lh0(Q,X,W,z);return}if(G==="llm"){await Zg0(Q,X,W,z);return}if(G==="permissions"){await Ng0(Q,X,W,z);return}if(G==="billing"){await ih0(Q,X,W,z);return}if(G==="webhook"||G==="webhooks"){await Cj(Q,J,X,W,z);return}if(G==="context"){await rh0(X,W,z);return}if(G==="rules"){await ko(Q,J,X,W,z);return}if(G==="approval-runs"){await s_0(Q,J,X,W,z);return}if(G==="analytics"){await t_0(Q,J,X,W,z);return}if(G==="simulation"){await yg0(Q,J,X,W,z);return}if(G==="deploy"){await ah0(Q,J,z.command[3],X,W,z);return}if(G==="preference"||G==="preferences"){await Bg0(Q,J,z.command[3],z.command[4],X,W,z);return}if(G==="tool"){await mg0(Q,X,W,z);return}throw Error(`Unknown command: ${z.command.join(" ")}. Run 'seal-use help' for available commands.`)}var Ly0,hk1,Sk1,gk1,Fy0;var So=m(()=>{i8();$3();a_0();e_0();Vo();nh0();ph0();mh0();oh0();sh0();Wo();th0();zg0();Xg0();qg0();Lg0();Mg0();Dg0();Pg0();Cg0();Rg0();co();kg0();ug0();ig0();dg0();lg0();rg0();Zy0();lo();Vy0();dl();F$();f4();A4();nl();K4();Ly0=so(so(so(vk1(import.meta.url)))),hk1=new Set(["update","upgrade","up","self-update","selfupdate"]),Sk1=new Set(["config","service","stop","http","serve","update","tools","corps","corp","tool","source","auth","users","contacts","data","llm","permissions","billing","webhook","webhooks","context","rules","approval-runs","analytics","simulation","deploy","preference","preferences","mcp","server","mcp-config","skill","openapi","probe","doctor","changelog","test"]),gk1=new Set(["http","server","web","mcp"]);Fy0=Promise.resolve()});function bk1($){let{command:Y}=Pq($),z=(Y[0]??"").toLowerCase();return{area:xk1[z]??z,actionTokens:Y.slice(1).map((U)=>U.toLowerCase())}}function wy0($){let Y,z;try{({area:Y,actionTokens:z}=bk1($))}catch{return!1}if(z.length===0&&uk1.has(Y))return!0;if(Y==="tool"){let Q=z[0];return Q!==void 0&&h_0(Q)}let U=fk1[Y];if(!U)return!1;return U.some((Q)=>{let J=Q.split(" ").filter(Boolean);if(J.length===0)return z.length===0;if(J.length>z.length)return!1;return J.every((I,K)=>I===z[K])})}var xk1,fk1,uk1;var My0=m(()=>{Bq();A4();xk1={corp:"corps",webhooks:"webhook",preferences:"preference"},fk1={corps:["list","search","get","current"],rules:["count","list","versions","version","diff","diff-one","get","search","lint","linters","pull","map"],webhook:["ready","status","list","get","resource-pack export","resource-pack preview"],"approval-runs":["summary","stats","count","export","flow","list","search","pick","bridge","get","cited-rules","document-summary","attachments","result","link","url"],simulation:["batch-records","status","wait","specifications","approval-d Line truncated
</html>`}var gg0=m(()=>{z3()});import{URL as Lk1}from"node:url";async function h6($,U,Y,z){let I=$.handler;return I(U,Y,{corp:z})}async function yg0($,U){if(U.setHeader("Access-Control-Allow-Origin","*"),U.setHeader("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS, PATCH"),U.setHeader("Access-Control-Allow-Headers","Content-Type, Authorization, X-Seal-Corp, X-Seal-Home-Session"),$.method==="OPTIONS"){U.writeHead(204),U.end();return}let Y=$.headers.host||"localhost",z=$.headers["x-forwarded-proto"]||"http",I=new Lk1($.url||"/",`${z}://${Y}`),Q=I.pathname.replace(/\/+$/,"")||"/",J=($.method||"GET").toUpperCase();try{if(J==="GET"&&Q==="/"){B4(U,200,{name:"seal-use",version:X1,description:"Seal tenant operations and approval automation HTTP API",docs:"/docs",openapi:"/openapi.json",health:"/health",endpoints:{cli:"POST /api/cli",tools:"GET /api/tools",toolInvoke:"POST /api/tool/:name",restV1:"GET/POST /v1/*"}});return}if(J==="GET"&&Q==="/docs"){Fk1(U,200,Sg0());return}if(J==="GET"&&Q==="/openapi.json"){B4(U,200,Yj());return}if(J==="GET"&&Q==="/health"){B4(U,200,{status:"ok",version:X1,name:"seal-use",timestamp:new Date().toISOString()});return}if(J==="POST"&&(Q==="/shutdown"||Q==="/api/shutdown")){B4(U,200,{success:!0,message:"Shutting down seal-use background daemon",pid:process.pid}),setTimeout(()=>{process.kill(process.pid,"SIGTERM")},50);return}if(J==="POST"&&Q==="/api/cli"){let K=await Ij($),G=(typeof K?.command==="string"?K.command:"").trim();if(!G){zj(U,400,"Missing 'command' property in request body");return}let H=nq(G),W=H[0]==="seal-use"||H[0]==="seal-home"||H[0]?.endsWith("/seal-use")||H[0]?.endsWith("/seal-home")?H.slice(1):H,X=await cq(W),Z=void 0;try{if(X.stdout.trim().startsWith("{")||X.stdout.trim().startsWith("["))Z=JSON.parse(X.stdout)}catch{}B4(U,X.isError?400:200,{success:!X.isError,stdout:X.stdout,stderr:X.stderr,exitCode:X.exitCode,data:Z});return}if(J==="POST"&&Q.startsWith("/api/tool/")){let K=Q.slice(10).trim(),G=M6(K);if(!G){zj(U,404,`Tool not found: '${K}'`);return}let H=await Ij($)||{},W=u8($,I,H),X=M1(W),Z=await B1(X),q={...H};delete q.corp;let V=await h6(G,Z,q,X);B4(U,200,V);return}if(Q.startsWith("/v1/")){if(await wk1($,U,J,Q,I))return}zj(U,404,`Cannot ${J} ${Q}. Visit /docs for available endpoints.`)}catch(K){let G=K instanceof Error?K.message:String(K);zj(U,500,G)}}async function wk1($,U,Y,z,I){let Q=Object.fromEntries(I.searchParams.entries());if(Y==="GET"&&z==="/v1/corps"){let J=t8(),K=v4();return B4(U,200,{count:J.length,mode:K.stateful?"stateful":"stateless",defaultCorpId:K.defaultCorpId,corps:J.map((G)=>({id:G.id,name:G.name,sourceType:G.source.type,sealUrl:G.seal?.url}))}),!0}if(Y==="GET"&&z==="/v1/whoami"){let J=u8($,I,Q),K=M1(J),G=await B1(K),H=M6("seal_whoami"),W=await h6(H,G,{},K);return B4(U,200,W),!0}if(Y==="GET"&&z==="/v1/session"){let J=u8($,I,Q),K=M1(J),G=await B1(K),H=M6("seal_session_get"),W=await h6(H,G,{},K);return B4(U,200,W),!0}if(Y==="GET"&&z==="/v1/approval-runs/summary"){let J=u8($,I,Q),K=M1(J),G=await B1(K),H=M6("seal_approval_runs_summary"),W=await h6(H,G,Q,K);return B4(U,200,W),!0}if(Y==="GET"&&z==="/v1/approval-runs/stats"){let J=u8($,I,Q),K=M1(J),G=await B1(K),H=M6("seal_approval_runs_stats"),W=await h6(H,G,Q,K);return B4(U,200,W),!0}if(Y==="GET"&&z==="/v1/approval-runs/pick"){let J=u8($,I,Q),K=M1(J),G=await B1(K),H=M6("seal_approval_run_pick"),W=await h6(H,G,Q,K);return B4(U,200,W),!0}if(Y==="GET"&&z==="/v1/approval-runs/url"){let J=u8($,I,Q),K=M1(J),G=await B1(K),H=M6("seal_approval_run_url_get"),W=await h6(H,G,Q,K);return B4(U,200,W),!0}if(z.startsWith("/v1/approval-runs/")){let J=z.slice(18).split("/"),K=J[0],G=J[1];if(K&&!["summary","pick","stats","url","bridge"].includes(K)){let H=u8($,I,Q),W=M1(H),X=await B1(W);if(!G){let Z=M6("seal_approval_run_get"),q=await h6(Z,X,{recordId:K,...Q},W);return B4(U,200,q),!0}if(G==="attachments"){let Z=M6("seal_approval_run_attachments_get"),q=await h6(Z,X,{recordId:K,...Q},W);return B4(U,200,q),!0}if(G==="cited-rules"){let Z=M6("seal_approval_run_cited_rules_get"),q=await h6(Z,X,{recordId:K,...Q},W);return B4(U,200,q),!0}if(G==="document-summary"){let Z=M6("seal_approval_run_document_summary_get"),q=await h6(Z,X,{recordId:K,...Q},W);return B4(U,200,q),!0}if(G==="result"){let Z=M6("seal_approval_run_result_get"),q=await h6(Z,X,{recordId:K,...Q},W);return B4(U,200,q),!0}}}if(Y==="GET"&&z==="/v1/approval-runs"){let J=u8($,I,Q),K=M1(J),G=await B1(K),H=M6("seal_approval_runs_search"),W=await h6(H,G,{...Q,limit:Q.limit?Number(Q.limit):void 0,offset:Q.offset?Number(Q.offset):void 0,includeBridge:Q.includeBridge==="true"},K);return B4(U,200,W),!0}if(Y==="GET"&&z==="/v1/approval/rules"){let J=u8($,I,Q),K=M1(J),G=await B1(K),H=M6("seal_approval_rules_list"),W=await h6(H,G,Q,K);return B4(U,200,W),!0}if(Y==="GET"&&z==="/v1/simulation/batches"){let J=u8($,I,Q),K=M1(J),G=await B1(K),H=M6("seal_simulation_batches_list"),W=await h6(H,G,Q,K);return B4(U,200,W),!0}if(Y==="POST"&&z==="/v1/simulation/create-batchLine truncated
\uD83D\uDE80 seal-use HTTP Server (v${X1}) started`),console.error(` URL: http://${Y}:${U}`),console.error(` Docs: http://${Y}:${U}/docs`),console.error(` OpenAPI: http://${Y}:${U}/openapi.json`),console.error(` CLI Exec: POST http://${Y}:${U}/api/cli`),console.error(` REST API: http://${Y}:${U}/v1/...
`);I(z)})})}var Qj=8787,Jj="127.0.0.1";var lo=m(()=>{kg0();z3()});async function xg0($){let U=s0($.options.port)??s0($.options.p),Y=S($.options.host)??S($.options.h),z=await Kj({port:U,host:Y}),I=()=>{z.close(()=>{process.exit(0)})};process.on("SIGINT",I),process.on("SIGTERM",I),await new Promise(()=>{})}var fg0=m(()=>{Z4();lo()});async function ug0($,U,Y,z){if($==="config"||$==="get"){await x0("seal_llm_config_get",U,Y,{},j0(z.options));return}if($==="providers"||$==="list"){await x0("seal_llm_providers_list",U,Y,{},j0(z.options));return}throw Error(`Unknown llm command: ${$??""}. Run 'seal-use help' for available commands.`)}var bg0=m(()=>{O4();m1()});async function ig0($,U){if($==="config"||$==="json"){oo();return}let{startServer:Y}=await dg0().then(() => cg0);Y()}function oo(){R0({mcpServers:{"seal-use":{type:"stdio",command:"seal-use",args:["mcp"],env:{SEAL_USE_MCP_ENABLED:"true"}}}})}var ng0=m(()=>{m1()});function pg0($){let U=Yj();R0(U,{...j0($.options),allowFull:!0})}var mg0=m(()=>{po();m1()});async function lg0($,U,Y,z){if($==="available"){await x0("seal_permissions_available_list",U,Y,{},j0(z.options));return}if($==="configs"||$==="list"){await x0("seal_permissions_configs_list",U,Y,{},j0(z.options));return}throw Error(`Unknown permissions command: ${$??""}. Run 'seal-use help' for available commands.`)}var og0=m(()=>{O4();m1()});import{readFileSync as rg0}from"node:fs";async function sg0($,U,Y,z,I,Q,J){if(!$||$==="get"){await x0("seal_preference_get",I,Q,{},j0(J.options));return}if($==="decision"){if(U==="update"||!U){let K=S(J.options.input),G=K?JSON.parse(rg0(K,"utf8")):B8(J.json);if(!G||Object.keys(G).length===0)throw Error(`Usage: seal-use preference decision update --json '{"explicitApprove":"..."}'`);await x0("seal_preference_decision_update",I,Q,{...G,dryRun:G0(J.options.dryRun)??G0(J.options["dry-run"])},j0(J.options));return}}if($==="thinking-depth"||$==="thinkingDepth"){if(U==="set"){let K=S(J.options.default)??S(J.options.level)??z;if(K!=="medium"&&K!=="high")throw Error("Usage: seal-use preference thinking-depth set --default <medium|high>");await x0("seal_preference_thinking_depth_set",I,Q,{defaultLevel:K,dryRun:G0(J.options.dryRun)??G0(J.options["dry-run"])},j0(J.options));return}if(U==="policies"){if(Y==="list"||!Y){await x0("seal_preference_thinking_depth_policies_list",I,Q,{},j0(J.options));return}if(Y==="upsert"){let K=S(J.options.input),G=K?JSON.parse(rg0(K,"utf8")):B8(J.json);if(!G||!G.id||!G.name)throw Error(`Usage: seal-use preference thinking-depth policies upsert --json '{"id":"...","name":"...","level":"high"}'`);await x0("seal_preference_thinking_depth_policies_upsert",I,Q,{...G,dryRun:G0(J.options.dryRun)??G0(J.options["dry-run"])},j0(J.options));return}if(Y==="remove"||Y==="delete"){let K=z??S(J.options.id)??S(J.options.policyId);if(!K)throw Error("Usage: seal-use preference thinking-depth policies remove <policyId>");await x0("seal_preference_thinking_depth_policies_remove",I,Q,{policyId:K,dryRun:G0(J.options.dryRun)??G0(J.options["dry-run"])},j0(J.options));return}}}throw Error(`Unknown preference action: ${$??""}. Available: get, decision update, thinking-depth set, thinking-depth policies list/upsert/remove.`)}var ag0=m(()=>{O4();Z4();m1()});async function tg0($={}){let U=t8(),Y=v4(),z=c2(U,{stateful:Y.stateful,defaultCorpId:Y.defaultCorpId,corpId:$.corpId},x3());console.log(`[probe] corp=${z.id} source=${z.source.type}`);let I=await bK(z);console.log("[probe] seal enterprise"),console.log(JSON.stringify(I,null,2));let Q=await B1(z),J=await SM(Q,{documentLimit:20,stylePreferencesEndpoint:z.seal.endpoints.approvalStylePreferences});console.log("[probe] approval context summary"),console.log(JSON.stringify({rules:J.rules.rules.length,hasPendingRuleDeletes:J.rules.hasPendingDeletes,documents:J.documents.articles.length,documentsTotal:J.documents.total,stylePreferences:J.stylePreferences.ok?"ok":`error: ${J.stylePreferences.error}`},null,2))}var eg0=m(()=>{T5();m6();fT();X6()});async function $y0($,U,Y){let z=U??S(Y.options.corp)??($&&$!=="--corp"?$:void 0);await tg0({corpId:z})}var Uy0=m(()=>{eg0();Z4()});async function ro($,U,Y,z,I){if($==="count"){await x0("seal_approval_rules_list",Y,z,{countOnly:!0},j0(I.options));return}if($==="list"){if(G0(I.options.count)){await x0("seal_approval_rules_list",Y,z,{countOnly:!0},j0(I.options));return}let Q=s0(I.options.limit),J=s0(I.options.offset);if(G0(I.options.summary)){await x0("seal_approval_rules_list",Y,z,{fields:Iv0,limit:Q,offset:J},j0(I.options));return}let K=await M$("seal_approval_rules_list",Y,z,{limit:Q,offset:J}),G=j0(I.options);Qv0(K,G.allowFull===!0||Boolean(G.outputFile)),R0(K,G);return}if($==="clear"){let Q=G0(I.options.yes)===!0,J=G0(I.options.dryRun)??G0(I.options["dry-run"])??!Q;if(!Q&&!J)throw F$("Refusing to clear rules without --yes. Use --dry-run to preview.",`seal-use rules clear --corp ${z.id} --dry-run`);let K=await M$("seal_approval_rules_clear",Y,z,{dryRun:J,recode:G0(I.options.recode)});if(!Q&&J& Line truncated
`).filter(Boolean),Q=I.slice(-U);return{logFile:Y,lines:Q,totalLines:I.length}}async function Bk1($){let U=Xj($),Y=to($),z=dq($);Jy0($.stateDir);let I=$.port??(process.env.PORT?Number.parseInt(process.env.PORT,10):Qj),Q=$.host??(process.env.HOST?process.env.HOST:Jj);Hj(U,`${process.pid}
`,{mode:384}),Hj(Y,JSON.stringify({pid:process.pid,port:I,host:Q,version:$.version,startedAt:new Date().toISOString()},null,2),{mode:384}),dK(z,`service starting on http://${Q}:${I} pid=${process.pid}`);let J=null;try{J=await Kj({port:I,host:Q,silent:!0}),dK(z,`service listening pid=${process.pid}`)}catch(G){if(dK(z,`service failed to bind port ${I}: ${G instanceof Error?G.message:String(G)}`),Wj(U)===process.pid)x9(U,{force:!0}),x9(Y,{force:!0});throw G}let K=()=>{if(J)J.close(),J=null;if(Wj(U)===process.pid)x9(U,{force:!0}),x9(Y,{force:!0});dK(z,`stopped pid=${process.pid}`)};await new Promise((G)=>{let H=!1,W=()=>{if(H)return;H=!0,K(),process.off("SIGTERM",W),process.off("SIGINT",W),G()};process.once("SIGTERM",W),process.once("SIGINT",W)})}function zy0($){Jy0($.stateDir);let U=nz($);if(U.running)return U;let Y=$.launcher??{command:process.execPath,args:[$.entryFile]},z=[...Y.args??[],"service","run"];if($.port)z.push("--port",String($.port));if($.host)z.push("--host",String($.host));let I=Ok1(Y.command,z,{cwd:$.appRoot,detached:!0,stdio:["ignore","ignore","ignore"],env:process.env});I.unref();let Q=Xj($);return Hj(Q,`${I.pid}
`,{mode:384}),dK(dq($),`started pid=${I.pid}`),{started:!0,...nz($)}}function Iy0($,U={}){let Y=Xj($),z=to($),I=Wj(Y);if(!I||!Qy0(I,$.appRoot))return x9(Y,{force:!0}),x9(z,{force:!0}),U.quiet?void 0:{stopped:!1,reason:"not running"};return process.kill(I,"SIGTERM"),x9(Y,{force:!0}),x9(z,{force:!0}),dK(dq($),`stop requested pid=${I}`),U.quiet?void 0:{stopped:!0,pid:I}}function Qy0($,U){if(!Pk1($))return!1;try{let Y=Nk1("ps",["-p",String($),"-o","command="],{encoding:"utf8"}),z=Y.trim().split(/\s+/).filter(Boolean),I=z.indexOf("service"),Q=I!==-1&&z[I+1]==="run",J=Y.includes(U)||z.some((K)=>/(^|[\\/])(seal-use|seal-home)(\.exe)?$/.test(K));return Q&&J}catch{return!1}}function Pk1($){try{return process.kill($,0),!0}catch{return!1}}function Xj($){return ao($.stateDir,"service.pid")}function to($){return ao($.stateDir,"service.json")}function dq($){return ao($.stateDir,"service.log")}function Wj($){if(!Gj($))return;let U=Number(so($,"utf8").trim());return Number.isInteger(U)&&U>0?U:void 0}function Jy0($){Dk1($,{recursive:!0,mode:448})}function dK($,U){Hj($,`${new Date().toISOString()} ${U}
`,{flag:"a",mode:384})}var eo=m(()=>{lo()});import{homedir as Tk1}from"node:os";import{join as jk1}from"node:path";async function Ur($,U,Y){let z=Y?s0(Y.options.port)??s0(Y.options.p):void 0,I=Y?S(Y.options.host)??S(Y.options.h):void 0,Q=Y?s0(Y.options.lines)??s0(Y.options.n):void 0,J=await s3($,{appRoot:U.appRoot,entryFile:U.entryFile,stateDir:$r,version:X1,launcher:U.launcher,port:z,host:I},{maxLines:Q});if(J!==void 0)R0(J)}var $r;var Yr=m(()=>{z3();eo();m1();Z4();$r=jk1(Tk1(),".config","seal-use")});import{existsSync as Ek1,readFileSync as Ky0}from"node:fs";async function Gy0($,U,Y,z,I){if($==="batch-records"||$==="records"){let Q=U??S(I.options.batchId)??S(I.options["batch-id"]);if(!Q)throw Error("Usage: seal-use simulation batch-records <batchId>");await x0("seal_simulation_batch_records_get",Y,z,{batchId:Q,query:S(I.options.query)},j0(I.options));return}if($==="create"||$==="run"){let Q=S(I.options.mode)??S(I.options.sourceSystem)??S(I.options["source-system"])??"hosecloud",J=Q==="material-pack"?"material_pack":Q,K=S(I.options.schemaConfig)??S(I.options["schema-config"]),G=K?JSON.parse(Ky0(K,"utf8")):void 0,H=S(I.options.input),W=H?JSON.parse(Ky0(H,"utf8")):B8(I.json),X=S(I.options.packageId)??S(I.options["package-id"]),Z=i6(I.options.packageIds)??i6(I.options["package-ids"])??(X?[X]:void 0),q=i6(I.options.flowIds)??i6(I.options["flow-ids"])??i6(I.options.documentSn)??i6(I.options["document-sn"]),V=S(I.options.signKey)??S(I.options["sign-key"])??S(I.options.integration),F=G0(I.options.wait)===!0,M=G0(I.options.noWait)??G0(I.options["no-wait"])??(F?!1:!0),w=await M$("seal_simulation_batch_create",Y,z,{mode:J,sourceSystem:J,flowIds:q,documentSn:q,rejectNodeName:S(I.options.rejectNode)??S(I.options["reject-node"])??null,thinkingDepthOverride:S(I.options.thinkingDepth)??S(I.options["thinking-depth"]),skipInvoiceGeneration:G0(I.options.skipInvoiceGeneration)??G0(I.options["skip-invoice-generation"]),skipExpenseExtraction:G0(I.options.skipExpenseExtraction)??G0(I.options["skip-expense-extraction"]),disableAttachmentCache:G0(I.options.disableAttachmentCache)??G0(I.options["disable-attachment-cache"]),signKey:V,packageIds:Z,packageId:X,templateId:S(I.options.templateId)??S(I.options["template-id"]),schemaConfig:G,requestIds:i6(I.options.requestIds)??i6(I.options["request-ids"]),workflowTypeId:S(I.options.workflowTypeId)??S(I.options["workflow-type-id"]),flowStatusList:i6(I.options.flowStatusList)?.map(Number)??i6(I.options["flow-status-list"])?.map(Number),businessCodes:i6(I.options.businessCodes)??i6(I.options["business-codes"]),documentType:S(I.options.documentType)??S(I.options["document-type"]),startTime:s0(I.options.startTime)??s0(I.options["start-time"]),endTime:s0(I.options.endTime)??s0(I.options["end-time"]),status:i6(I.options.status),limit:s0(I.options.limit),noWait:M,rawParams:W});if(F&&w&&typeof w==="object"&&"batchId"in w&&typeof w.batchId==="string"){await x0("seal_simulation_batch_wait",Y,z,{batchId:w.batchId,timeout:S(I.options.timeout),pollInterval:S(I.options.pollInterval)??S(I.options["poll-interval"])},j0(I.options));return}R0(w,j0(I.options));return}if($==="wait"){let Q=U??S(I.options.batchId)??S(I.options["batch-id"]);if(!Q)throw Error("Usage: seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s]");await x0("seal_simulation_batch_wait",Y,z,{batchId:Q,timeout:S(I.options.timeout),pollInterval:S(I.options.pollInterval)??S(I.options["poll-interval"])},j0(I.options));return}if($==="status"){let Q=U??S(I.options.batchId)??S(I.options["batch-id"]);if(!Q)throw Error("Usage: seal-use simulation status <batchId>");await x0("seal_simulation_batch_status",Y,z,{batchId:Q},j0(I.options));return}if($==="clean"||$==="delete"){let Q=U??S(I.options.batchId)??S(I.options["batch-id"]);if(!Q)throw Error("Usage: seal-use simulation clean <batchId>");await x0("seal_simulation_batch_clean",Y,z,{batchId:Q},j0(I.options));return}if($==="specifications"){let Q=U??S(I.options.integration)??S(I.options.signKey)??S(I.options["sign-key"]);await x0("seal_simulation_specifications_list",Y,z,{signKey:Q},j0(I.options));return}if($==="approval-definitions"||$==="definitions"){await x0("seal_simulation_feishu_approval_definitions_list",Y,z,{},j0(I.options));return}if($==="list"){await x0("seal_simulation_batches_list",Y,z,{limit:s0(I.options.limit)},j0(I.options));return}if($==="get"){let Q=U??S(I.options.batchId)??S(I.options["batch-id"]);if(!Q)throw Error("Usage: seal-use simulation get <batchId>");await x0("seal_simulation_batch_get",Y,z,{batchId:Q},j0(I.options));return}if($==="templates"){await x0("seal_simulation_templates_get",Y,z,{},j0(I.options));return}if($==="integrations"){await x0("seal_simulation_integrations_get",Y,z,{},j0(I.options));return}if($==="package-upload"){let Q=U??S(I.options.file);if(!Q)throw Error("Usage: seal-use simulation package-upload <材料包.zip>");if(!Ek1(Q))throw Error(`File not found: ${Q}`);await x0("seal_simulation_material_package_upload",Y,z,{filePath:Q},j0(I.o Line truncated
`);return}if($==="install"||$==="init"||$==="sync"){let z=G0(Y.options.local)||G0(Y.options.workspace),I=S(Y.options.dir)??S(Y.options.target)??U,Q=I?I:z?Zj(process.cwd(),".agents","skills","seal-use"):iz(),J=Og0(Q),K=!z&&!I,G=K?_o():void 0,H=K?So():void 0;R0({installed:!0,targetDir:J.targetDir,fileCount:J.files.length,files:J.files,...G?{antigravity:G}:{},...H?{hosts:H}:{}});return}if($==="status"||$==="get"||!$){let z=iz(),I=Zj(process.cwd(),".agents","skills","seal-use"),Q=vo(),J=go();R0({global:{dir:z,installed:Wy0(Zj(z,"SKILL.md"))},local:{dir:I,installed:Wy0(Zj(I,"SKILL.md"))},antigravity:Q,hosts:J});return}throw Error(`Unknown skill command: ${$}. Run 'seal-use help' for available commands.`)}var Zy0=m(()=>{ko();iq();Z4();m1()});async function qy0($,U){if($==="config"){R0(await bK(U));return}throw Error(`Unknown source command: ${$??""}. Run 'seal-use help' for available commands.`)}var Vy0=m(()=>{fT();m1()});function zr($){if(typeof $!=="string"||!$.trim())return"UNKNOWN";let U=$.toUpperCase().trim();if(U==="APPROVE"||U==="PASS")return"APPROVE";if(U==="REJECT"||U==="DENIED")return"REJECT";if(U==="MANUAL"||U==="ASSISTED")return"MANUAL";if(U==="ERROR"||U==="FAILED")return"ERROR";return U}async function Ly0($){let{sourceCorp:U,targetCorp:Y,sourceClient:z,targetClient:I,samples:Q=10,dryRun:J=!1,pollIntervalMs:K=2000,timeoutMs:G=45000,snPrefix:H="REG_",fetchFn:W=fetch}=$;if(Y.environment!=="test")throw new W4(`重放目标企业「${Y.name}」(${Y.id}) 的环境为「${Y.environment}」,非测试环境!
`+"硬性安全规定:自动化回归测试矩阵严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-use corps bind-test ${U.id} <testCorpId>`);let X=await lU(I),q=(Array.isArray(X.features)?X.features:[]).find((p)=>p?.code==="ai-approval"),V=typeof q?.balance==="number"?q.balance:0,F=typeof q?.deductionAmount==="number"&&q.deductionAmount>0?q.deductionAmount:120,M=Q*F;if(V<M)throw new W4(`测试企业「${Y.name}」AI 审批额度不足:当前剩余 ${V} 点,本次回归抽样 ${Q} 笔需要约 ${M} 点。
`+"为防止测试环境额度耗尽中断业务,已硬性拦截并拒绝发起测试单据注入。",2,`请为测试企业「${Y.id}」充值 AI 审批额度,或降低抽样笔数 (--samples ${Math.max(1,Math.floor(V/F))})`);let w=await i4(z,{limit:Q,status:"completed"}),N=Array.isArray(w.records)?w.records:[];if(N.length===0){let p=await i4(z,{limit:Q});N=Array.isArray(p.records)?p.records:[]}if(N.length===0)throw new W4(`在母企业「${U.name}」(${U.id}) 中未检索到任何历史审批单据,无法抽取回归样本。`,2);if(N=N.slice(0,Q),J){let p=N.map((a)=>{let $0=a.sourceDocumentSN??a.id,y=a?.result?.decision??a.aiDecision??a?.decision,d=zr(y),U0=a?.result?.summary??a.aiSummary;return{sn:$0,sourceRecordId:a.id,prodDecision:d,prodSummary:U0,status:"DRY_RUN"}});return{ok:!0,verdict:"DRY_RUN",safeToPublish:!0,timestamp:new Date().toISOString(),sourceCorp:{id:U.id,name:U.name,environment:U.environment??"production"},targetCorp:{id:Y.id,name:Y.name,environment:Y.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:V,deductionAmount:F,estimatedRequired:M},metrics:{sampleCount:p.length,successCount:p.length,failureCount:0,matchCount:p.length,flipCount:0,concordanceRate:1},flips:[],records:p}}let O=await gd(I,Y,$.webhookSelector),D=[];for(let p of N){let a=Date.now(),$0=p.sourceDocumentSN??p.id,y=zr(p?.result?.decision??p.aiDecision??p?.decision),d=p?.result?.summary??p.aiSummary;try{let U0=await H4(z,p.id),R=`${H}${$0}`,o=hd(U0,{snPrefix:H,docIdPrefix:H});await Sd(O.incomingDocumentWebhook.url,O.secret,o,W,A6(Y.seal));let e=null,O0=Date.now();while(Date.now()-O0<G){await new Promise((X0)=>setTimeout(X0,K));let t=await i4(I,{sourceDocumentSN:R,limit:1});if(t.records&&t.records.length>0){let X0=t.records[0];if(X0.status==="completed"||X0.status==="failed"){e=X0;break}}}if(!e){D.push({sn:$0,sourceRecordId:p.id,prodDecision:y,prodSummary:d,status:"FAILED",error:`测试租户单据审核超时 (${Math.round(G/1000)}s 未完成)`,durationMs:Date.now()-a});continue}let T0=zr(e?.result?.decision??e.aiDecision??e?.decision??(e.status==="completed"?"APPROVE":"ERROR")),y0=e?.result?.summary??e.aiSummary,v0=y===T0,o0=v0?"MATCHED":"FLIPPED",q1={sn:$0,sourceRecordId:p.id,prodDecision:y,prodSummary:d,testRecordId:e.id,testDecision:T0,testSummary:y0,status:o0,durationMs:Date.now()-a};if(!v0)q1.diff={from:y,to:T0,reasonDiff:y0&&d&&y0!==d?`生产: ${d.slice(0,60)}... -> 测试: ${y0.slice(0,60)}...`:void 0};D.push(q1)}catch(U0){D.push({sn:$0,sourceRecordId:p.id,prodDecision:y,prodSummary:d,status:"FAILED",error:U0 instanceof Error?U0.message:String(U0),durationMs:Date.now()-a})}}let P=D.filter((p)=>p.status==="MATCHED"||p.status==="FLIPPED"),T=D.filter((p)=>p.status==="MATCHED"),A=D.filter((p)=>p.status==="FLIPPED"),j=D.filter((p)=>p.status==="FAILED").length,C=T.length,b=A.length,x=C+b,g=x>0?C/x:0,i=b>0,n=i?"REGRESSIONS_DETECTED":"CLEAN",z0=!i&&j===0,k;try{let p=await lU(I),$0=(Array.isArray(p.features)?p.features:[]).find((y)=>y?.code==="ai-approval");if(typeof $0?.balance==="number")k=$0.balance}catch{}return{ok:!i&&j===0,verdict:n,safeToPublish:z0,timestamp:new Date().toISOString(),sourceCorp:{id:U.id,name:U.name,environment:U.environment??"production"},targetCorp:{id:Y.id,name:Y.name,environment:Y.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:V,deductionAmount:F,estimatedRequired:M,balanceAfter:k},metrics:{sampleCount:D.length,successCount:P.length,failureCount:j,matchCount:C,flipCount:b,concordanceRate:Number(g.toFixed(4))},flips:A,records:D}}function wy0($){let{sourceCorp:U,targetCorp:Y,verdict:z,safeToPublish:I,metrics:Q,quota:J,flips:K,records:G}=$,H=z==="CLEAN"?"\uD83D\uDFE2 决策完全一致 (CLEAN - 无回归)":z==="DRY_RUN"?"⚪ 预演模式 (DRY-RUN)":"\uD83D\uDD34 发现决策翻转 (REGRESSIONS_DETECTED)",W=["",`\uD83E\uDDEA [Seal Use Test] 规则回归测试矩阵: 生产「${U.name}」-> 测试靶场「${Y.name}」`,` 判定: ${H} · 准许发布: ${I?"YES (可安全上线)":"NO (存在行为偏离/待复核)"}`," "+"─".repeat(65),` 样本总数: ${Q.sampleCount} | 一致通过: ${Q.matchCount} | 决策翻转: ${Q.flipCount} | 异常失败: ${Q.failureCount}`,` 一致率: ${(Q.concordanceRate*100).toFixed(1)}% | 消耗预估: ${J.estimatedRequired} 点 (余量: ${J.balanceBefore}${J.balanceAfter!==void 0?` -> ${J.balanceAfter}`:""})`," "+"─".repeat(65)];if(K.length>0){W.push(` ⚠️ 决策翻转清单 (${K.length} 笔单据在新规则下结果改变):`);for(let X of K)if(W.push(` • 单据 [${X.sn}]: 原生产判定「${X.prodDecision}」 ➔ 测试新判定「${X.testDecision}」`),X.diff?.reasonDiff)W.push(` 理由差异: ${X.diff.reasonDiff}`);W.push(" "+"─".repeat(65)),W.push(" \uD83D\uDC49 建议: 请检查上述翻转单据是否符合预期修正。若为意外误杀,请调整测试环境规则后再次回归。")}else if(z==="CLEAN")W.push(" ✓ 全部样本在新规则下的审核决策与生产历史 100% Line truncated
`)}var Fy0=m(()=>{O8();X6();iZ()});async function Ir($,U,Y){let z=($??U??"regression").toLowerCase();if(z==="regression"||z==="regress"||z==="matrix"){let I=S(Y.options.corp)??(U&&U!==z?U:void 0),Q=M1(I),J=Q,K=Q;if(Q.environment==="test"){K=Q;let O=S(Y.options["prod-corp"])??S(Y.options.prod)??Q.prodCorpId;if(!O)throw new W4(`测试企业「${Q.name}」(${Q.id}) 未绑定生产母企业,无法拉取历史样本。
`+"请建立绑定或通过 --prod-corp 参数指定生产企业来源。",2,`seal-use corps bind-test <prodCorpId> ${Q.id}`);J=M1(O)}else{J=Q;let O=S(Y.options["test-corp"])??S(Y.options.test)??Q.testCorpId;if(!O)throw new W4(`生产企业「${Q.name}」(${Q.id}) 未绑定测试靶场企业。
`+"硬性规定:回归测试严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-use corps bind-test ${Q.id} <testCorpId>`);K=M1(O)}let G=await B1(J),H=await B1(K),W=s0(Y.options.samples)??s0(Y.options.limit)??s0(Y.options.n)??10,X=G0(Y.options["dry-run"]),Z=G0(Y.options["fail-on-flips"]),q=s0(Y.options["poll-interval"])??2000,V=s0(Y.options.timeout)??45000,F=S(Y.options["sn-prefix"])??"REG_",M=S(Y.options.webhook)??S(Y.options.selector),w=await Ly0({sourceCorp:J,targetCorp:K,sourceClient:G,targetClient:H,samples:W,dryRun:X,pollIntervalMs:q,timeoutMs:V,snPrefix:F,failOnFlips:Z,webhookSelector:M});if(!(G0(Y.options.quiet)||G0(Y.options.silent)))console.error(wy0(w));if(R0(w),Z&&!w.ok)throw new W4(`回归测试发现 ${w.metrics.flipCount} 笔单据决策翻转,已按 --fail-on-flips 策略非零终止。`,1);return}throw new W4(`未知的 test 子命令: "${z}"。
可用子命令: seal-use test regression [--corp <id>] [--samples <N>] [--dry-run]`,2,"seal-use test regression --help")}var My0=m(()=>{O8();O4();Z4();m1();m6();Fy0()});async function Oy0($,U,Y,z){if(!$)throw Error("Usage: seal-use tool <toolName> [--json '{...}']");await x0($,U,Y,B8(z.json),j0(z.options))}var Ny0=m(()=>{O4();Z4();m1()});function Dy0(){R0(Pq.map(($)=>({name:$.name,description:$.description})))}var Ay0=m(()=>{jq();m1()});function qj($=process.execPath,U=import.meta.url){if(U.includes("/$bunfs/")||U.includes("\\$bunfs\\"))return!0;let Y=$.toLowerCase().replace(/\\/g,"/");return!Y.endsWith("/bun")&&!Y.endsWith("/bun.exe")&&!Y.endsWith("/node")&&!Y.endsWith("/node.exe")}var By0=m(()=>{iq()});import{existsSync as Ck1,mkdirSync as Rk1,readFileSync as _k1,renameSync as vk1,writeFileSync as hk1}from"node:fs";import{homedir as Sk1}from"node:os";import{dirname as gk1,join as yk1}from"node:path";import{spawn as kk1}from"node:child_process";function Py0($){return $.replace(/\.\d+Z$/,"Z")}function Ty0(){let $=process.env[xk1]?.trim();if($)return $;return uk1}function jy0($=Ty0()){if(!Ck1($))return null;try{let U=_k1($,"utf-8"),Y=JSON.parse(U);if(Y&&typeof Y==="object"&&typeof Y.latestVersion==="string"&&typeof Y.checkedAt==="string")return{...Y,checkedAt:Py0(Y.checkedAt)};return null}catch{return null}}function pq($,U=Ty0()){try{let Y=gk1(U);Rk1(Y,{recursive:!0,mode:448});let z={checkedAt:Py0($.checkedAt??new Date().toISOString()),latestVersion:$.latestVersion,publishedAt:$.publishedAt,releaseUrl:$.releaseUrl},I=`${U}.tmp.${Date.now()}.${Math.random().toString(36).slice(2,8)}`;hk1(I,JSON.stringify(z,null,2),{mode:384}),vk1(I,U)}catch{}}function Ey0($,U=fk1){if(!$||!$.checkedAt)return!0;let Y=new Date($.checkedAt).getTime();if(Number.isNaN(Y))return!0;return Date.now()-Y>U}function Cy0($){if(process.env.SEAL_DISABLE_BG_UPDATE==="1"||!1||process.env.CI)return!1;if(!$||!$.command)return!1;try{let U=$.command,Y=[...$.args??[],"update","check","--bg-save"];return kk1(U,Y,{detached:!0,stdio:"ignore",env:{...process.env,SEAL_DISABLE_BG_UPDATE:"1"}}).unref(),!0}catch{return!1}}var xk1="SEAL_USE_UPDATE_CACHE_FILE",fk1=86400000,uk1;var Qr=m(()=>{uk1=yk1(Sk1(),".config","seal-use","update-cache.json")});import{chmodSync as bk1,mkdirSync as ik1,readdirSync as nk1,realpathSync as Ry0,renameSync as Jr,rmSync as ck1,unlinkSync as gy0,writeFileSync as _y0}from"node:fs";import{basename as dk1,dirname as pk1,isAbsolute as mk1,join as wj,relative as lk1}from"node:path";import{spawn as ok1,spawnSync as a3}from"node:child_process";async function ky0($,U={}){let Y={appRoot:$.appRoot,entryFile:$.entryFile,stateDir:$r,version:X1,launcher:$.launcher},z=U.repo||process.env[rk1]?.trim()||process.env[sk1]?.trim()||yy0,I=U.targetVersion?.trim(),Q=I&&I.toLowerCase()!=="latest"?I:void 0;if(Q){let D=Q.replace(/^v/,""),P=by0(D,X1);if(P<0)if(!Wg&&U.force);else{R0({updated:!1,currentVersion:X1,targetVersion:D,mode:qj()?"binary":"source",message:!Wg?`Cannot downgrade seal-use from dev build v${X1} to release v${D}. Use --force to overwrite.`:`Cannot downgrade seal-use from v${X1} to older version v${D}. Updates must be forward-only.`});return}if(P===0&&!U.force){R0({updated:!1,currentVersion:X1,targetVersion:D,mode:qj()?"binary":"source",message:`seal-use is already at version v${X1}. Use --force to reinstall.`});return}}if(U.changelogOnly){let D=await Lj(z,U.limit??10);R0({currentVersion:X1,totalQueried:D.length,releases:D.map((P)=>({version:P.version,tagName:P.tagName,publishedAt:P.publishedAt,author:P.author,releaseNotes:P.notes,releaseUrl:P.htmlUrl,isCurrent:P.version===X1,isNewer:h5(P.version,X1)}))});return}if(!qj()){if(U.checkOnly){let P=await Lj(z,30),T=P[0],A=T?.version??X1,j=P.find((x)=>x.version===X1),C=h5(A,X1),b=P.filter((x)=>h5(x.version,X1));if(T?.version)pq({latestVersion:T.version,publishedAt:T.publishedAt,releaseUrl:T.htmlUrl});if(U.bgSave)return;R0({updated:!1,updateAvailable:C,currentVersion:X1,currentVersionPublishedAt:j?.publishedAt,latestVersion:A,latestVersionPublishedAt:T?.publishedAt,behindCount:b.length,pendingReleases:b.map((x)=>({version:x.version,tagName:x.tagName,publishedAt:x.publishedAt,author:x.author,releaseNotes:x.notes,releaseUrl:x.htmlUrl})),releaseNotes:T?.notes??"",releaseUrl:T?.htmlUrl??"",mode:"source",message:"当前运行的是开发版。正式用户请安装正式版后使用 seal-use update。"});return}let D=nz(Y).running;if(D)await s3("stop",Y);try{Sy0("git",["-C",$.appRoot,"pull","--ff-only"])}catch(P){console.error(`⚠️ 开发版更新同步失败,继续刷新本地依赖: ${P instanceof Error?P.message:String(P)}`)}if(Sy0("bun",["install"],{cwd:$.appRoot}),D)await s3("start",Y);R0({updated:!0,serviceRestarted:D,version:X1,mode:"source"});return}if(Ux1())try{await Yx1($,U,Y,z,Q);return}catch(D){console.error(`⚠️ Homebrew 自动更新失败,回退至原生二进制更新: ${D instanceof Error?D.message:String(D)}`)}let J=tk1(),K=ek1(),G=await Lj(z,30),H=Q?G.find((D)=>D.version Line truncated
`)}catch{}}async function Qx1($,U,Y,z){let I=Kr(),Q=[],J=Y?Y.startsWith("v")?Y:`v${Y}`:void 0,K=z||$.split("/").pop()||"";if(I!=="github"){if(J&&K)Q.push(`https://git.ying-qing.cn/gitea/seal-use/releases/download/${J}/${K}`,`https://git.ying-qing.cn/gitea/seal-home/releases/download/${J}/${K}`);if($.startsWith("https://git.ying-qing.cn"))Q.push($)}if(I!=="gitea")if(J&&K){let F=`https://github.com/${yy0}/releases/download/${J}/${K}`;if(!process.env.CI)Q.push(`https://ghfast.top/${F}`,`https://gh.ddlc.top/${F}`);Q.push(F)}else if($.includes("github.com")){if(!process.env.CI)Q.push(`https://ghfast.top/${$}`,`https://gh.ddlc.top/${$}`);Q.push($)}else Q.push($);let G=Array.from(new Set(Q)),H,W=6000,X=6000,Z=307200,q=1e4,V=180000;for(let F=0;F<G.length;F++){let M=G[F],w=new AbortController,N="",O=(A)=>{N=A;try{w.abort()}catch{}},D=setTimeout(()=>{O("Connection timed out (no response headers within 6s)")},W),P,T;try{Vj(`==> [${F+1}/${G.length}] Downloading via: ${M}`);let A=await fetch(M,{signal:w.signal});if(D)clearTimeout(D),D=void 0;if(!A.ok)throw Error(`HTTP ${A.status} ${A.statusText}`);P=setTimeout(()=>{O("Overall download time exceeded 3 minutes")},V);let j=Number(A.headers.get("content-length"))||0,C=A.body?.getReader();if(!C){let n=Buffer.from(await A.arrayBuffer());if(n.length<1000)throw Error(`Downloaded content is suspiciously small (${n.length} bytes)`);_y0(U,n),Vj(`✓ Download succeeded (${(n.length/1024/1024).toFixed(1)} MB)`);return}let b=[],x=0,g=0;T=setTimeout(()=>{if(x<Z){let n=(x/1024).toFixed(1);O(`Initial transfer too slow (${n} KB < 300 KB in 6s), switching mirror...`)}},X);while(!0){let n=C.read(),z0,k=new Promise((y,d)=>{z0=setTimeout(()=>{d(Error("Data transfer stalled (no chunk received for 10s)"))},q)}),p;try{p=await Promise.race([n,k])}finally{if(z0)clearTimeout(z0)}let{done:a,value:$0}=p;if(a)break;if($0){if(b.push($0),x+=$0.length,T&&x>=Z)clearTimeout(T),T=void 0;let y=Date.now();if(y-g>200){g=y;let d=j?Math.round(x/j*100):0,U0=(x/1048576).toFixed(1),R=j?(j/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${d}% (${U0} / ${R} MB)...`)}catch{}}}}try{process.stderr.write(`
`)}catch{}let i=Buffer.concat(b);if(i.length<1000)throw Error(`Downloaded content is suspiciously small (${i.length} bytes)`);_y0(U,i),Vj(`✓ Download completed successfully (${(i.length/1024/1024).toFixed(1)} MB)`);return}catch(A){if(D)clearTimeout(D);if(T)clearTimeout(T);if(P)clearTimeout(P);let j=N||(A instanceof Error?A.message:String(A));H=Error(j),Vj(`
↳ Mirror failed: ${H.message}`)}finally{if(D)clearTimeout(D);if(T)clearTimeout(T);if(P)clearTimeout(P)}}throw Error(`Failed to download asset from all mirrors: ${H?.message}`)}function fy0($){let U;try{U=nk1($,{withFileTypes:!0})}catch{return[]}let Y=[];for(let z of U){let I=wj($,z.name);if(z.isDirectory())Y.push(...fy0(I));else if(z.isFile())Y.push(I)}return Y}function uy0($,U,Y){let z=U==="windows"?"seal-use.exe":"seal-use",I=fy0($);return I.find((Q)=>dk1(Q)===z)??I[0]??Y}function Jx1($,U,Y){let z=a3("tar",["-xzf",$,"-C",U],{stdio:"pipe"});if(z.status!==0)throw Error(`Failed to extract tar archive: ${z.stderr.toString()}`);return gy0($),uy0(U,Y,$)}function Kx1($,U,Y){let z=a3("unzip",["-q","-o",$,"-d",U],{stdio:"pipe"});if(z.status!==0)throw Error(`Failed to extract zip archive: ${z.stderr.toString()}`);return gy0($),uy0(U,Y,$)}function by0($,U){let Y=$.replace(/^v/,"").split(".").map((I)=>Number.parseInt(I,10)||0),z=U.replace(/^v/,"").split(".").map((I)=>Number.parseInt(I,10)||0);for(let I=0;I<Math.max(Y.length,z.length);I++){let Q=Y[I]??0,J=z[I]??0;if(Q>J)return 1;if(Q<J)return-1}return 0}function h5($,U){return by0($,U)>0}function Sy0($,U,Y={}){let z=a3($,U,{cwd:Y.cwd,encoding:"utf8",stdio:["ignore","pipe","pipe"]});if(z.stdout)console.error(z.stdout.trimEnd());if(z.stderr)console.error(z.stderr.trimEnd());if(z.status!==0)throw Error(`${$} ${U.join(" ")} failed with status ${z.status}`)}var yy0="yunyingk/seal-use",mq="yunyingk/seal-home",rk1="SEAL_USE_GITHUB_REPO",sk1="SEAL_HOME_GITHUB_REPO";var iy0=m(()=>{By0();iq();Qr();z3();eo();m1();Yr()});async function ny0($,U,Y,z,I){if($==="create"){let Q=S(I.options.name)??U,J=S(I.options.phone);if(!Q||!J)throw Error("Usage: seal-use users create --name <name> --phone <phone> [--dept <deptId>]");let K=S(I.options.dept)??S(I.options.departmentId);await x0("seal_user_create",Y,z,{name:Q,phone:J,departmentIds:K?[K]:void 0},j0(I.options));return}if($==="reset-password"){let Q=U??S(I.options.userId);if(!Q)throw Error("Usage: seal-use users reset-password <userId>");await x0("seal_user_reset_password",Y,z,{userId:Q},j0(I.options));return}if($==="search"||$==="list"){let Q=U??S(I.options.keyword)??S(I.options.query)??"";await x0("seal_user_search",Y,z,{keyword:Q},j0(I.options));return}if($==="get"){let Q=U??S(I.options.userId);if(!Q)throw Error("Usage: seal-use users get <userId>");await x0("seal_user_get",Y,z,{userId:Q},j0(I.options));return}if($==="delete"){let Q=U??S(I.options.userId);if(!Q)throw Error("Usage: seal-use users delete <userId>");await x0("seal_user_delete",Y,z,{userId:Q},j0(I.options));return}if($==="activate"){let Q=U??S(I.options.userId);if(!Q)throw Error("Usage: seal-use users activate <userId>");await x0("seal_user_activate",Y,z,{userId:Q},j0(I.options));return}if($==="delegation"||$==="impersonate"){let Q=U??S(I.options.userId)??S(I.options.phone);if(!Q)throw Error("Usage: seal-use users delegation <userIdOrPhone> [--note <note>]");let J=S(I.options.note);await x0("seal_user_delegation_create",Y,z,{userIdOrPhone:Q,note:J},j0(I.options));return}throw Error(`Unknown users command: ${$??""}. Run 'seal-use help' for available commands.`)}var cy0=m(()=>{O4();Z4();m1()});import{dirname as Gr,join as Gx1}from"node:path";import{fileURLToPath as Hx1}from"node:url";function qx1($){if(!$.length)return!1;let U=$[0]?.toLowerCase(),Y=$[1]?.toLowerCase();if(U&&Zx1.has(U))return!0;if((U==="service"||U==="daemon")&&Y==="run")return!0;return!1}function cq($,U={}){if(qx1($))return my0($,U);let Y=py0.then(()=>my0($,U));return py0=Y.then(()=>{return},()=>{return}),Y}async function my0($,U){let Y=[],z=[],I=console.log,Q=console.error,J={appRoot:U.appRoot??dy0,entryFile:U.entryFile??Gx1(U.appRoot??dy0,"src","cli.ts"),launcher:U.launcher};console.log=(...K)=>{Y.push($o(K))},console.error=(...K)=>{z.push($o(K))};try{return await Vx1($,J),{stdout:Cq(Y),stderr:Cq(z),isError:!1,exitCode:0}}catch(K){let G=Rq(K instanceof Error?K.message:String(K)),H=bZ(K);if(z.push(G),H.nextAction&&!G.includes("Next action:"))z.push(`\uD83D\uDC49 Next action: ${H.nextAction}`);return{stdout:Cq(Y),stderr:Cq(z),isError:!0,exitCode:H.exitCode}}finally{console.log=I,console.error=Q}}async function Vx1($,U){let Y=Eq($),[z,I,Q]=Y.command,J=z?.toLowerCase(),K=J?Wx1.has(J):!1,G=K?"update":J;if(G==="version"||G==="v"||Boolean(Y.options.version)||Boolean(Y.options.v)||Boolean(Y.options.V)){let Z=jy0(),q=Z?.latestVersion?h5(Z.latestVersion,pU.version):!1,V={...pU,...Z?.latestVersion?{latestVersion:Z.latestVersion,updateAvailable:q,lastCheckedAt:Z.checkedAt}:{}};if(q&&Z?.latestVersion)console.error(`\uD83D\uDCA1 发现新版本可用: v${pU.version} -> v${Z.latestVersion}`),console.error(`\uD83D\uDC49 Next action: seal-use update
`);if(R0(V),Ey0(Z))Cy0(U.launcher);return}let H=Yv0(Y);if(H.isHelp){Jv0(H.target);return}if(!G||!Xx1.has(G))throw Error(`Unknown command: ${Y.command.join(" ")}. Run 'seal-use help' for available commands.`);if(G==="webhook"&&(I==="resource-pack"||I==="pack"||I==="material-pack")&&Q==="preview"){let Z=Y.command[3]??S(Y.options.file)??S(Y.options.input);if(!Z)throw Error("Usage: seal-use webhook resource-pack preview <资源包.zip>");await Gv0(Z,uK(Y.options));return}if(G==="openapi"){pg0(Y);return}if(G==="mcp-config"){oo();return}if(G==="skill"){Xy0(I,Q,Y);return}if(G==="mcp"||G==="server"){await ig0(I,Y);return}if(G==="probe"){await $y0(I,Q,Y);return}if(G==="doctor"){await Cg0(I,Q,Y);return}if(G==="test"){await Ir(I,Q,Y);return}if(G==="config"){wS0(I,Q,Y);return}if(G==="service"){await Ur(I,U,Y);return}if(G==="stop"){await Ur("stop",U,Y);return}if(G==="http"||G==="serve"){await xg0(Y);return}if(K||G==="changelog"){if(K&&z!=="update")console.error(`⚠️ Notice: '${z}' is an alias for 'seal-use update'. Please use 'seal-use update' instead.`);let Z=I?.toLowerCase(),q=G==="changelog"||Z==="changelog"||Z==="log"||Z==="history"||G0(Y.options.changelog)===!0,V=Z==="check"||G0(Y.options.check)===!0||G0(Y.options["check-only"])===!0,F=G0(Y.options["bg-save"])===!0||G0(Y.options["silent-save"])===!0,M=S(Y.options.version)??S(Y.options.tag)??(!q&&!V&&!F&&I&&!I.startsWith("-")?I:void 0);await ky0(U,{checkOnly:V||F,changelogOnly:q,limit:s0(Y.options.limit),force:G0(Y.options.force),targetVersion:M,repo:S(Y.options.repo),bgSave:F});return}if(G==="tools"&&I==="list"){Dy0();return}if(G==="corps"||G==="corp"){if(I==="regression"||I==="test-regression"){await Ir("regression",Q,Y);return}await WS0(I,Q,Y);return}if(G==="rules"&&I==="lint"&&(("file"in Y.options)||("f"in Y.options))){let Z;try{Z=M1(S(Y.options.corp))}catch{Z={id:"local",name:"Local Workspace",source:{type:"native"}}}await ro(I,Q,null,Z,Y);return}if(G==="auth"&&(I==="extract-keys"||I==="extract-key"||I==="extract-hose-keys"||I==="hose-extract-keys")){await To(Q,Y);return}if(G==="auth"&&(I==="link"||I==="seal-link")&&(("from-link"in Y.options)||Q==="from-link")){await $j(I,null,Y);return}let W=M1(S(Y.options.corp));if(G==="source"){await qy0(I,W);return}if(G==="auth"){await $j(I,W,Y);return}let X=await B1(W);if(G==="users"){await ny0(I,Q,X,W,Y);return}if(G==="contacts"){await MS0(I,Q,X,W,Y);return}if(G==="data"){await NS0(I,X,W,Y);return}if(G==="llm"){await ug0(I,X,W,Y);return}if(G==="permissions"){await lg0(I,X,W,Y);return}if(G==="billing"){await VS0(I,X,W,Y);return}if(G==="webhook"||G==="webhooks"){await gT(I,Q,X,W,Y);return}if(G==="context"){await AS0(X,W,Y);return}if(G==="rules"){await ro(I,Q,X,W,Y);return}if(G==="approval-runs"){await Hv0(I,Q,X,W,Y);return}if(G==="analytics"){await Xv0(I,Q,X,W,Y);return}if(G==="simulation"){await Gy0(I,Q,X,W,Y);return}if(G==="deploy"){await PS0(I,Q,Y.command[3],X,W,Y);return}if(G==="preference"||G==="preferences"){await sg0(I,Q,Y.command[3],Y.command[4],X,W,Y);return}if(G==="tool"){await Oy0(I,X,W,Y);return}throw Error(`Unknown command: ${Y.command.join(" ")}. Run 'seal-use help' for available commands.`)}var dy0,Wx1,Xx1,Zx1,py0;var mo=m(()=>{m6();z3();Wv0();Zv0();jo();LS0();FS0();OS0();DS0();BS0();Ao();TS0();Rg0();fg0();bg0();ng0();mg0();og0();ag0();Uy0();Yy0();Yr();Hy0();Zy0();Vy0();My0();Ny0();Ay0();iy0();Qr();cy0();Yo();O8();O4();Z4();el();m1();dy0=Gr(Gr(Gr(Hx1(import.meta.url)))),Wx1=new Set(["update","upgrade","up","self-update","selfupdate"]),Xx1=new Set(["config","service","stop","http","serve","update","tools","corps","corp","tool","source","auth","users","contacts","data","llm","permissions","billing","webhook","webhooks","context","rules","approval-runs","analytics","simulation","deploy","preference","preferences","mcp","server","mcp-config","skill","openapi","probe","doctor","changelog","test"]),Zx1=new Set(["http","server","web","mcp"]);py0=Promise.resolve()});function Mx1($){let{command:U}=Eq($),Y=(U[0]??"").toLowerCase();return{area:Lx1[Y]??Y,actionTokens:U.slice(1).map((z)=>z.toLowerCase())}}function ly0($){let U,Y;try{({area:U,actionTokens:Y}=Mx1($))}catch{return!1}if(Y.length===0&&Fx1.has(U))return!0;if(U==="tool"){let I=Y[0];return I!==void 0&&p_0(I)}let z=wx1[U];if(!z)return!1;return z.some((I)=>{let Q=I.split(" ").filter(Boolean);if(Q.length===0)return Y.length===0;if(Q.length>Y.length)return!1;return Q.every((J,K)=>J===Y[K])})}var Lx1,wx1,Fx1;var oy0=m(()=>{jq();Z4();Lx1={corp:"corps",webhooks:"webhook",preferences:"preference"},wx1={corps:["list","search","get","current"],rules:["count","list","versions","version","diff","diff-one","get","search","lint","linters","pull","map"],webhook:["ready","status","list","get","resource-pack export","resource-pack preview"],"approval-runs":["summary","stats","count","export","flow","list","search","pick","bridge","get","cited-rules","document-summary","attachments","result","link","url"],simulation:["batch-records","status","wait","specifications","approval-d Line truncated
`)?"":`
`}`);process.exitCode=$.exitCode}var s3,Ay0,JT="seal_cli",cq="seal_cli_write",By0="SEAL_USE_MCP_ENABLED",Py0="SEAL_HOME_MCP_ENABLED",ck1;var Og0=m(async()=>{oe();ae();P$();So();My0();F$();$3();s3=ik1(import.meta.url),Ay0=s3.includes("/dist/mcp/")||s3.includes("\\dist\\mcp\\")?iq(iq(iq(s3))):iq(iq(s3));ck1=Boolean(I0.main==I0.module||!import.meta.url.includes("$bunfs")&&process.argv[1]&&Ny0(process.argv[1])===Ny0(s3));if(ck1)if(process.argv[2]==="--seal-use-cli")await nk1();else try{Ey0()}catch($){console.error($),process.exitCode=1}});await Og0();export{kq as tokenizeCommand,Ey0 as startServer,jy0 as resolveMcpEnabled,Ty0 as createServer,By0 as SEAL_MCP_ENABLED_ENV,cq as SEAL_CLI_WRITE_TOOL_NAME,JT as SEAL_CLI_TOOL_NAME,Py0 as LEGACY_SEAL_MCP_ENABLED_ENV};
`}`);process.exitCode=$.exitCode}var t3,ay0,Mj="seal_cli",rq="seal_cli_write",ty0="SEAL_USE_MCP_ENABLED",ey0="SEAL_HOME_MCP_ENABLED",Dx1;var dg0=m(async()=>{J00();H00();T$();mo();oy0();O8();z3();t3=Ox1(import.meta.url),ay0=t3.includes("/dist/mcp/")||t3.includes("\\dist\\mcp\\")?lq(lq(lq(t3))):lq(lq(t3));Dx1=Boolean(J0.main==J0.module||!import.meta.url.includes("$bunfs")&&process.argv[1]&&ry0(process.argv[1])===ry0(t3));if(Dx1)if(process.argv[2]==="--seal-use-cli")await Nx1();else try{Yk0()}catch($){console.error($),process.exitCode=1}});await dg0();export{nq as tokenizeCommand,Yk0 as startServer,$k0 as resolveMcpEnabled,Uk0 as createServer,ty0 as SEAL_MCP_ENABLED_ENV,rq as SEAL_CLI_WRITE_TOOL_NAME,Mj as SEAL_CLI_TOOL_NAME,ey0 as LEGACY_SEAL_MCP_ENABLED_ENV};
-3
View File
@@ -77,7 +77,6 @@
"type": "string",
"enum": [
"hose",
"direct",
"seal"
]
},
@@ -126,7 +125,6 @@
"type": "string",
"enum": [
"hose",
"direct",
"seal"
]
},
@@ -2970,7 +2968,6 @@
"type": "string",
"enum": [
"hose",
"direct",
"seal"
]
},
-21
View File
@@ -1,21 +0,0 @@
{
"id": "direct-corp",
"name": "Direct Seal 企业",
"seal": {
"url": "https://corp-id.sealai.cc",
"endpoints": {
"approvalStylePreferences": "api/v1/agent/ai-approval/config"
}
},
"source": {
"type": "direct",
"token": "seal-bearer-token",
"sealUrl": "https://corp-id.sealai.cc",
"expiresIn": 3600,
"corpId": "corp-id",
"staffId": "staff-id"
},
"auth": {
"refreshTtl": 300
}
}
+1
View File
@@ -13,6 +13,7 @@
"token": "seal-bearer-token",
"sealUrl": "https://tenant.sealai.cc",
"expiresIn": 2592000,
"expiresAt": "2026-10-22T00:00:00Z",
"staffId": "seal-user-id",
"corpId": "tenant-slug",
"tenantId": "seal-tenant-id",
+1 -1
View File
@@ -18,7 +18,7 @@ CorpSummary:
type: string
sourceType:
type: string
enum: [hose, direct, seal]
enum: [hose, seal]
current:
type: boolean
SwitchCorpRequest:
+1 -1
View File
@@ -273,7 +273,7 @@ echo "✨ seal-use successfully installed to ${TARGET_PATH}!"
"$TARGET_PATH" version
echo ""
echo "Quick start:"
echo " 1. Add enterprise: seal-use corps add-hose --json '{...}'"
echo " 1. Add enterprise: seal-use corps add-hose-persistent --json '{...}'"
echo " 2. View MCP config: seal-use mcp-config"
echo " 3. Self-update: seal-use update"
echo ""
+25 -3
View File
@@ -10,6 +10,28 @@ metadata:
> CLI 是主执行通道,MCP 默认关闭(插件配置可选开启)。机器通道 (`stdout`) 必须输出纯净 JSON,诊断日志与下一步建议统一输出在 `stderr`。
### 时间显示约定
- 机器字段(如 `checkedAt`、`lastCheckedAt`)保留 ISO 8601 UTC 格式,精确到秒,例如 `2026-09-22T04:56:06Z`;不要改成本地时间或添加毫秒。
- Agent 面向用户解释时间时,必须将 UTC 换算为北京时间(`Asia/Shanghai`,`UTC+8`),明确标注“北京时间”;需要审计或消歧时同时附上原始 UTC 时间。
### 企业接入路由约定
必须区分“用户提供的材料”“最终企业来源”和“标准化 CLI 入口”三个概念:
| 用户材料 | Agent 预处理后的标准入口 | 说明 |
|---|---|---|
| 合思开放平台 `appKey + appSecurity` | `corps add-hose-persistent` | 纯 Hose 长期凭据入口;自动探测域名、企业和管理员。 |
| Seal URL + Bearer Token,或从 Seal 后台复制的 cURL | `corps add-seal-bearer` | 两者是同一类 Seal 会话凭据;cURL 只需提取必要字段后再调用 `add-seal-bearer`。 |
| Seal 原生委托链接,或合思协助链接 | `corps add-link` | `add-link` 是 URL 混合入口,自动识别 Seal 与 Hose 链接;它不直接接收 cURL。 |
| 从已登录合思管理员页面复制的 cURL | 优先提取密钥后调用 `corps add-hose-persistent`;失败时调用 `corps add-hose-web-session` | Hose `accesstoken` 与 Seal Bearer 不是同一种 token;不能直接混用。 |
**Token 类型不得混用**:`add-seal-bearer` 只接受 Seal Bearer Token;合思网页 cURL 中的 `accesstoken` 只能用于 Hose API 和密钥提取,提取失败后由 `add-hose-web-session` 经 SSO 换成 Seal Bearer,不能直接作为 `add-seal-bearer` 的 `token`。
**配置类型判断**:`source.type: "hose"` 且存在 `appKey/appSecurity` 表示 Hose 持久化凭据;`source.type: "hose"` 且存在 `closeToken + staffId` 表示 Hose Web Session。Web Session 调用 Seal 能力时才通过 SSO 换取运行时 Seal Bearer;不要把 Hose 的 `accessToken/closeToken` 当作 Seal Bearer Token。若会话材料提供了有效期,Hose source 同样记录 `expiresIn` 和 `expiresAt`(UTC 秒精度,如 `2026-09-22T05:30:00Z`)。
`add-link` 的默认行为是导入临时会话。只有明确使用 `--elevate-hose` 时,才执行合思提权并提取长期 OpenAPI 凭据;`--as-hose` 仅作为兼容旧参数,不作为 Agent 的默认表达。
---
## 0. 全局业务术语与对外输出契约(Mandatory Vocabulary Contract)⚠️ 核心红线
@@ -58,7 +80,7 @@ metadata:
![网络Fetch/XHR](assets/hose-curl-network-fetch-xhr.png)
3. 找到任一正常业务请求,右键「复制」-「以 cURL 格式复制」:
![以cURL格式复制](assets/hose-curl-copy-as-curl.png)
3. **无感接入**:Agent 接收材料后自动执行 `corps add-hose`、`corps add-link` 或 `corps hose-extract-keys --save`,系统自动反查拉取真实企业中文名,自动绑定管理员,完成接入。无需用户手动查找 `corpId` 或 `staffId`。详阅 `references/first-time-user.md` 与 `references/enterprise-onboarding.md`。
3. **无感接入**:Agent 接收材料后自动执行 `corps add-hose-persistent`、`corps add-hose-web-session`、`corps add-seal-bearer`、`corps add-link` 或 `corps hose-extract-keys --save`,系统自动反查拉取真实企业中文名,自动绑定管理员,完成接入。无需用户手动查找 `corpId` 或 `staffId`。详阅 `references/first-time-user.md` 与 `references/enterprise-onboarding.md`。
---
@@ -70,7 +92,7 @@ metadata:
`corps` 是企业上下文的总入口,推荐按“接入 → 发现与选择 → 环境配对 → 测试验证”的主线使用;Hose 能力是针对合思来源企业的专属子域,不应覆盖原生 Seal 主流程。
- **企业接入(主入口)**:`add-link`(自动识别 Seal 原生委托链接或 Hose 协助链接,原生 Seal 优先)、`add-seal`、`add-hose`。
- **企业接入(主入口)**:`add-link`(自动识别 Seal 原生委托链接或 Hose 协助链接,原生 Seal 优先)、`add-seal-bearer`、`add-hose-persistent`、`add-hose-web-session`。
- **发现与选择(高频管理)**:`list`、`search`/`find`、`get`/`show`、`current`、`switch`。
- **企业配置(低频维护)**:`mark`、`rename`。
- **测试配对与验证(生产变更闭环)**:`bind-test`、`unbind-test`、`sync-test`、`replay-test`;回归测试统一使用 `seal-use test regression`。
@@ -78,7 +100,7 @@ metadata:
命令保持扁平兼容以避免破坏现有脚本;`seal-use corps --help` 会按上述业务组展示,不代表这些命令属于同一风险等级。涉及本地配置或测试数据写入的操作仍须遵守确认与预览规则。
Hose 专属命令必须从命令名上显式可见:认证入口使用 `auth hose-*`,合思原生审批流使用 `approval-runs hose-flow`,部署入口使用 `deploy hosecloud ...`,模拟入口使用 `simulation --mode hosecloud`。跨 Seal/Hose 的混合命令保留通用名称,但必须通过 `--as-hose`、`--with-flow` 或 `--type hose-document` 明确选择 Hose 能力。
Hose 专属命令必须从命令名上显式可见:认证入口使用 `auth hose-*`,合思原生审批流使用 `approval-runs hose-flow`,部署入口使用 `deploy hosecloud ...`,模拟入口使用 `simulation --mode hosecloud`。跨 Seal/Hose 的混合命令保留通用名称,但必须通过 `--elevate-hose`、`--with-flow` 或 `--type hose-document` 明确选择 Hose 能力。
### 2.1 企业定位与直达访问
- 关键字智能搜索(支持同音字/拼音/简拼/容错):`seal-use corps search <keyword>`
+11 -8
View File
@@ -87,9 +87,9 @@ seal-use corps bind-test <prodCorpId> <testCorpId> [--confirm] [--force]
seal-use corps unbind-test [<corpId>] [--confirm]
seal-use corps sync-test [<prodCorpId>] [--dry-run] [--yes] [--version-name <name>]
seal-use corps replay-test [<prodCorpId>] [--record-id <id>] [--sn <sn>] [--limit <n>] [--status <status>] [--webhook <idOrName>] [--sn-suffix <str>] [--dry-run] [--confirm|--yes] [--force]
seal-use corps add-hose --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}'
seal-use corps add-seal --json '{"sealUrl":"https://tenant.sealai.cc","token":"seal-bearer-token"}'
seal-use corps add-link <url> [--name <customName>] [--as-hose] [--app-key <key>] [--key-id <id>] [--overwrite] [--dry-run]
seal-use corps add-hose-persistent --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}'
seal-use corps add-seal-bearer --json '{"sealUrl":"https://tenant.sealai.cc","token":"seal-bearer-token"}'
seal-use corps add-link <url> [--name <customName>] [--elevate-hose] [--app-key <key>] [--key-id <id>] [--overwrite] [--dry-run]
seal-use corps probe-hose --json '{"appKey":"...","appSecurity":"...","domain":"https://..."}'
seal-use corps hose-staffs --json '{"appKey":"...","appSecurity":"...","role":"admin"}'
seal-use corps hose-extract-keys <https://.../web/thirdparty.html?...> [--reveal] [--save] [--name <customName>] [--app-key <key>] [--key-id <id>] [--overwrite]
@@ -212,9 +212,12 @@ Enterprise and tenant management (`corps` is the enterprise-context entry point)
Use the command groups in this order for normal work: **enterprise onboarding** → **discovery and selection** → **environment configuration** → **test pairing and verification**. Hose probing, staff discovery, key extraction, and key inspection are secondary capabilities for Hose-sourced enterprises.
- `seal-use corps add-link <url> [--name <name>] [--as-hose] [--app-key <key>] [--key-id <id>] [--overwrite] [--dry-run]` is the preferred onboarding entry point: it auto-detects a Seal native delegate link or a Hose assistance link. Native Seal links are registered as native Seal enterprises; Hose links can remain short-lived or use `--as-hose` for durable Hose credentials. `--dry-run` never writes local config.
- `seal-use corps add-seal --json '{"sealUrl":"https://tenant.sealai.cc","token":"..."}'` registers a native Seal enterprise directly.
- `seal-use corps add-hose --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"..."}'` registers a Hose enterprise from durable OpenAPI credentials.
- `seal-use corps add-link <url> [--name <name>] [--elevate-hose] [--app-key <key>] [--key-id <id>] [--overwrite] [--dry-run]` is the preferred onboarding entry point: it auto-detects a Seal native delegate link or a Hose assistance link. Native Seal links are registered as native Seal enterprises; Hose links can remain short-lived or use `--elevate-hose` for durable Hose credentials. The legacy `--as-hose` alias remains accepted for compatibility. `--dry-run` never writes local config.
- `seal-use corps add-seal-bearer --json '{"sealUrl":"https://tenant.sealai.cc","token":"..."}'` registers a native Seal enterprise directly from a Seal Bearer Token. The old `add-seal` spelling remains a compatibility alias.
- `seal-use corps add-hose-web-session --json '{"baseUrl":"https://wx2.ekuaibao.com","corpId":"...","staffId":"...","accessToken":"..."}'` imports a normalized Hose web session (for example, parsed from a Hose admin cURL), saving the Hose `closeToken` and personnel ID. Seal Bearer is exchanged only at runtime; this command does not create or save OpenAPI `appKey/appSecurity` credentials.
- `seal-use corps add-hose-persistent --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"..."}'` registers and persists a Hose enterprise from durable OpenAPI credentials. The old `add-hose` spelling remains a compatibility alias.
Durable Hose configs are identified by `source.type: "hose"` plus `appKey/appSecurity`; Hose Web Session configs use the same source type with `closeToken + staffId`. When the session material includes an expiry, it is recorded as `expiresIn` (TTL seconds) and `expiresAt` (UTC without milliseconds, for example `2026-09-22T05:30:00Z`).
- `seal-use corps list [query] [--env <production|test>] [--limit <n>] [--all] [--strict] [--corp <corpId>]` (defaults to displaying the top 10 most frequently used enterprises in the last 7 days; sorting is automatic and query results keep relevance order)
- `seal-use corps search <query> [--env <production|test>] [--strict]` (intelligent soft search by default: case-insensitive, Chinese homophones, front/back nasal vowels, flat/retroflex consonants, initials, typo/missing letter tolerance; pass `--strict` for exact substring match)
- `seal-use corps get <corpId>` (rich enterprise attributes with sensitive secrets safely redacted)
@@ -350,14 +353,14 @@ Approval runs, simulations, and Langfuse bridge:
Add and verify a Hose enterprise:
```bash
seal-use corps add-hose --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}'
seal-use corps add-hose-persistent --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}'
seal-use auth check --corp <corpId>
```
Force-write a Hose config without verification:
```bash
seal-use corps add-hose --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId","force":true}'
seal-use corps add-hose-persistent --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId","force":true}'
```
Check auth failures:
@@ -39,16 +39,25 @@ Classify both the enterprise identity origin and how the current credential was
| Enterprise identity origin | Credential material the user may have | 权限等级与时效 | Meaning |
| --- | --- | --- | --- |
| Hose/合思-sourced Seal tenant | Hose `appKey` + `appSecurity` | 【最高·永久】自动签名/续期 | Stable, refreshable standard integration; unlocks full OpenAPI and `deploy hosecloud sync`. |
| Hose/合思-sourced Seal tenant | Hose authorization/assistance link (`thirdparty.html`) | 【两极分化】普通导入→短效;提权→永久 | Temporary session that can be **elevated** to permanent `appKey`/`appSecurity` with `extract-keys --save` or `add-link --as-hose`. |
| Hose/合思-sourced Seal tenant | Hose authorization/assistance link (`thirdparty.html`) | 【两极分化】普通导入→短效;提权→永久 | Temporary session that can be **elevated** to permanent `appKey`/`appSecurity` with `extract-keys --save` or `add-link --elevate-hose`. |
| Hose/合思-sourced Seal tenant | cURL copied from an authenticated **Hose admin** page | 【两极分化】普通导入→短效;提权→永久 | **Same session scope as an assistance link.** If the user is a Hose administrator, this carries the same web session credentials (`accesstoken`, `corpid`, cookies) and can equally invoke `/api/innerapi/v1/key` to extract permanent `appKey`/`appSecurity`. |
| Hose/合思-sourced Seal tenant | cURL copied from an authenticated Seal page | 【短效会话快照】 | Snapshot with Seal Bearer token; can set up temporary Seal session access. |
| Seal-native tenant | Seal assistance/delegation link | 【临时·可撤销】 | Temporary delegated access to a Seal tenant. |
| Seal-native tenant | cURL copied from an authenticated Seal page | 【短效会话快照】 | Snapshot containing the Seal host and session authentication. |
| Seal-native tenant | Seal URL + Bearer Token, or cURL copied from an authenticated Seal page | 【短效会话快照】 | Both normalize to `add-seal-bearer`; the cURL is only a transport format for the same Seal Bearer credential. |
**同等凭据原则(Equal Credential Scope Principle)**: A Hose assistance link and a browser cURL from an authenticated Hose admin session are both Hose web frontend sessions — they carry the same underlying `accessToken`/`accesstoken` and `corpid`. The **only** structural difference is delivery format. When a Hose administrator sends you a cURL, treat it with the same privilege elevation potential as an assistance link. Do not downgrade it to a plain Seal session import without first attempting key extraction.
Credential shape alone does not define identity origin. In particular, a Hose-sourced user eventually receives a Seal Bearer session after SSO. When `whoami` returns provider metadata, preserve it and use it to describe the tenant accurately.
### Token boundary
The Hose web-session `accesstoken` and the Seal Bearer Token are different credentials and are not interchangeable:
- `corps add-seal-bearer` accepts the Seal Bearer Token together with `sealUrl`.
- A Hose cURL's `accesstoken` is used first for Hose key extraction. If no permanent OpenAPI key can be extracted, call `add-hose-web-session`; it stores the Hose `closeToken` and `staffId`, then exchanges the Hose session through Seal SSO only when a Seal session is needed.
- Never pass a Hose `accesstoken` directly as the `token` field of `add-seal-bearer`.
The saved config makes the lifecycle visible: durable Hose credentials use `source.type: "hose"` with `appKey/appSecurity`; Hose Web Session credentials also use `source.type: "hose"`, but carry `closeToken` and `staffId` instead. If the Hose session material provides an expiry, it is stored as `expiresIn` (seconds) and `expiresAt` in UTC second precision, such as `2026-09-22T05:30:00Z`. The Seal Bearer obtained through SSO is a runtime cache, not the enterprise source type.
## Parameter Ownership
Ask the user only for information that cannot be discovered safely:
@@ -67,7 +76,7 @@ Ask the user only for information that cannot be discovered safely:
This is the preferred durable route for a Hose-sourced tenant. Read `hose-enterprise-init.md`, then use:
```bash
seal-use corps add-hose --json '{"appKey":"...","appSecurity":"..."}'
seal-use corps add-hose-persistent --json '{"appKey":"...","appSecurity":"..."}'
```
The CLI probes the standard domains, discovers the corporation, and discovers administrator candidates. If it returns multiple candidates, show only useful identifying information and ask which person should be used; retry with `staffName`, `staffPhone`, or the selected `staffId` internally. After creation, run:
@@ -83,8 +92,8 @@ Do not ask for `domain`, `corpId`, or `proxyStaffBizId` up front. For a dedicate
First distinguish the link by its host, purpose, and identity origin:
- **Seal-Native Delegation Link (默认第一公民)**: `https://<tenant>.sealai.cc/delegate?token=...` grants delegated access directly on a Seal tenant. Running `seal-use corps add-link <url>` automatically exchanges the delegation token via `/api/v1/delegation/consume`, receives the session, retrieves tenant and user info via `/api/v1/auth/me`, and registers a native Seal enterprise (`provider: "seal"`). Supports `--dry-run` to preview metadata without mutating local config.
- **Hose/合思 Assistance Link**: `https://<domain>/web/thirdparty.html?...` opens an upstream Hose session and continues through Seal SSO. Running standard `seal-use corps add-link <url>` exchanges that temporary token for a short-lived Seal Bearer token.
- **Hose Subdomain Boundary (合思子域专属提权)**: `seal-use` primarily manages Seal tenants. Tenants sourced from the Hose ecosystem have an upstream Hose enterprise backing them. A received Hose assistance link contains only a temporary session `accessToken`. To elevate to permanent Hose OpenAPI developer credentials, use `corps hose-extract-keys <url> --save` or `corps add-link <url> --as-hose`. (Note: `--as-hose` cannot be used on Seal-native delegation links).
- **Hose/合思 Assistance Link**: `https://<domain>/web/thirdparty.html?...` opens an upstream Hose session and continues through Seal SSO. Running standard `seal-use corps add-link <url>` verifies the tenant and stores the Hose `closeToken` plus `staffId`; the Seal Bearer is runtime-only.
- **Hose Subdomain Boundary (合思子域专属提权)**: `seal-use` primarily manages Seal tenants. Tenants sourced from the Hose ecosystem have an upstream Hose enterprise backing them. A received Hose assistance link contains only a temporary session `accessToken`. To elevate to permanent Hose OpenAPI developer credentials, use `corps hose-extract-keys <url> --save` or `corps add-link <url> --elevate-hose`. (Note: `--elevate-hose` cannot be used on Seal-native delegation links; `--as-hose` remains a deprecated compatibility alias).
- **Multi-Key Disambiguation (多套密钥明确抉择)**: If the Hose enterprise owns multiple application keys, the CLI will not guess or silently pick the first key. Instead, it terminates with an informative candidate list and requires the user to specify `--app-key <key>` or `--key-id <id>`. If only one key exists, it is selected automatically.
- **Non-Hose Tenants Blocked**: Calling `keys` on native Seal enterprises (`corp.source.type !== "hose"`) is strictly rejected with exit code 2, explaining that this capability belongs exclusively to the Hose ecosystem.
@@ -95,7 +104,7 @@ First distinguish the link by its host, purpose, and identity origin:
seal-use corps add-link "https://<tenant>.sealai.cc/delegate?token=..." [--name "企业名称"] [--dry-run]
# 2. 接入合思协助链接并提权为标准持久化合思企业配置:
seal-use corps add-link "<url>" --as-hose [--name "企业名称"]
seal-use corps add-link "<url>" --elevate-hose [--name "企业名称"]
# 或通过 extract-keys 提取保存:
seal-use corps hose-extract-keys "<url>" --save [--name "企业名称"]
@@ -113,7 +122,7 @@ seal-use corps hose-keys <corpId> [--reveal]
seal-use auth hose-keys --corp <corpId> [--reveal]
```
When using standard `add-link` with a Seal delegate link, it consumes the token directly against the Seal tenant and persists the verified Seal session. When using standard `add-link` with a Hose link (without `--as-hose`), it exchanges the temporary Hose token at the target Seal tenant and stores the short-lived Seal session. When `--as-hose` is used on a Hose link, the CLI executes Hose subdomain privilege elevation to register a durable standard Hose configuration.
When using standard `add-link` with a Seal delegate link, it consumes the token directly against the Seal tenant and persists the verified Seal session. When using standard `add-link` with a Hose link (without `--elevate-hose`), it stores the Hose web-session source (`closeToken` plus `staffId`) and uses the temporary Seal Bearer only at runtime. When `--elevate-hose` is used on a Hose link, the CLI executes Hose subdomain privilege elevation to register a durable standard Hose configuration. The legacy `--as-hose` alias remains accepted for compatibility.
Assistance links are credentials. Do not follow a link merely to inspect it when the user's request was only explanatory, and never publish, log, or commit it.
@@ -140,7 +149,7 @@ This is functionally equivalent to a Hose assistance link. Both carry the same u
1. Treat the entire cURL as a secret. Do not echo it, execute it blindly, paste it into another service, or store it in repository files.
2. Extract: the request hostname (determines `baseUrl`), `accesstoken` header (session token), `corpid` header or cookie, and any other Hose session headers.
3. **Privilege elevation path (preferred)**: Use extracted `accesstoken`, `corpid`, and `baseUrl` to call `/api/innerapi/v1/key`, exactly as `corps hose-extract-keys` does for assistance links. This retrieves permanent `appKey`/`appSecurity` to register a durable Hose enterprise configuration — do not skip this step just because the input is a cURL instead of a URL.
4. **Fallback short-term path**: If the session user is not an administrator and the key interface returns no keys, fall back to the Seal SSO bridge to register a temporary Seal session.
4. **Fallback short-term path**: If the session user is not an administrator and the key interface returns no keys, pass the normalized Hose session to `corps add-hose-web-session`; it saves the Hose `closeToken` and `staffId`, then uses the Seal SSO bridge only when a Seal session is needed.
5. If key extraction succeeds, inform the user that credentials have been permanently elevated; if it fails, explain the limitation and suggest the administrator copy a dedicated cURL or provide an assistance link or `appKey`/`appSecurity`.
```
@@ -155,11 +164,11 @@ This is functionally equivalent to a Hose assistance link. Both carry the same u
1. Treat the entire cURL as a secret.
2. Parse it as data. Extract the request host, path, `Authorization: Bearer ...` header, and provider/tenant hints.
3. Verify with `/api/v1/auth/me` through `seal-use corps add-seal`; use returned provider metadata to retain the actual origin.
3. Verify with `/api/v1/auth/me` through `seal-use corps add-seal-bearer`; use returned provider metadata to retain the actual origin.
4. Persist only the normalized minimum configuration needed by seal-use.
```bash
seal-use corps add-seal --json '{"sealUrl":"https://target-tenant.example","token":"<bearer>"}'
seal-use corps add-seal-bearer --json '{"sealUrl":"https://target-tenant.example","token":"<bearer>"}'
```
If the captured request contains only cookies or an authentication shape the CLI cannot verify, do not improvise a token. Ask the user to copy another successful Seal Fetch/XHR request that contains the Bearer header, or explain the current limitation.
@@ -71,8 +71,10 @@ macOS 也可以使用 `Option + Command + I`;Windows 常见快捷键是 `F12`
助手会先判断这条请求来自合思网页还是 Seal 网页:
- **合思网页**:读取请求主机、会话令牌和企业标识。若当前登录人具备管理员权限,优先尝试把短期网页会话提升为长期 OpenAPI 凭据;否则导入为临时会话。
- **Seal 网页**:读取 Seal 主机和 Bearer 会话,验证当前租户和用户身份。
- **合思网页**:读取请求主机、Hose `accesstoken` 和企业标识。若当前登录人具备管理员权限,优先提取长期 OpenAPI 凭据并调用 `add-hose-persistent`;否则调用 `add-hose-web-session`,保存 Hose `closeToken` 与 `staffId`,仅在需要 Seal 能力时经 Hose→Seal SSO 换取运行时 Seal Bearer。
- **Seal 网页**:读取 Seal 主机和 Bearer 会话,整理为 `sealUrl + token` 后调用 `add-seal-bearer`。
注意:cURL 是 Agent 的输入材料,不是 `add-link` 的参数。`add-link` 只接收 Seal 委托链接或合思协助链接,并负责自动识别这两类 URL。
这些步骤由助手完成,用户不需要从 cURL 中手动寻找 token、企业 ID 或员工 ID。
@@ -6,16 +6,16 @@ Use this reference for Hose/合思 enterprise configuration and user-facing Hose
Use the CLI for normal enterprise setup. Do not inspect source code or hand-edit `~/.config/seal-use/enterprises/*.json` unless the CLI fails or the user explicitly asks for low-level config debugging.
For first-time setup or when the user has an assistance link or browser cURL instead of standard application credentials, read `enterprise-onboarding.md` first. This reference's `add-hose` route is specifically for durable Hose OpenAPI credentials.
For first-time setup or when the user has an assistance link or browser cURL instead of standard application credentials, read `enterprise-onboarding.md` first. This reference's `add-hose-persistent` route is specifically for durable Hose OpenAPI credentials.
```bash
seal-use corps add-hose --json '{"appKey":"...","appSecurity":"..."}'
seal-use corps add-hose-persistent --json '{"appKey":"...","appSecurity":"..."}'
seal-use corps list
seal-use corps current --corp <corpId>
seal-use corps switch <corpId>
```
`corps add-hose` probes standard domains and discovers the enterprise automatically. If it returns multiple administrator candidates, present their names and masked phones for the user to choose, then retry with `staffName`, `staffPhone`, or the selected `staffId`. Do not ask for `domain`, `corpId`, `staffId`, or `proxyStaffBizId` before discovery. Ask for a dedicated/private-cloud `domain` only after standard probing fails.
`corps add-hose-persistent` probes standard domains and discovers the enterprise automatically. If it returns multiple administrator candidates, present their names and masked phones for the user to choose, then retry with `staffName`, `staffPhone`, or the selected `staffId`. Do not ask for `domain`, `corpId`, `staffId`, or `proxyStaffBizId` before discovery. Ask for a dedicated/private-cloud `domain` only after standard probing fails. The old `add-hose` spelling remains a compatibility alias.
The command verifies by default and writes the enterprise config. If the user says not to operate business logic, stop at `corps` and auth/config commands; do not run approval, rule, document, simulation, or approval-run commands.
@@ -78,7 +78,7 @@ seal-use corps hose-staffs --json '{
1. **若用户在初始指令中已指名(姓名或手机号)**:
```bash
seal-use corps add-hose --json '{
seal-use corps add-hose-persistent --json '{
"appKey": "...",
"appSecurity": "...",
"staffName": "于光泽"
@@ -87,7 +87,7 @@ seal-use corps hose-staffs --json '{
* 系统通过角色人员列表匹配:若**唯一匹配且 `active == true`**,直接绑定该 `staffId` 完成接入。
2. **若用户未指定管理员**:
```bash
seal-use corps add-hose --json '{
seal-use corps add-hose-persistent --json '{
"appKey": "...",
"appSecurity": "..."
}'
@@ -97,7 +97,7 @@ seal-use corps hose-staffs --json '{
* 只有用户明确允许自动选择时才传 `--force`,此时按“首位启用管理员,若无则首位候选”确定审计身份,并在结果中保留该选择。
3. **若已知目标人员 ID**:
```bash
seal-use corps add-hose --json '{
seal-use corps add-hose-persistent --json '{
"appKey": "...",
"appSecurity": "...",
"staffId": "ID01OZVhtzekb5:ID01K9vHULqNj1"
@@ -61,7 +61,7 @@ flowchart TD
识别生产企业(`sourceType: "hose"` 或 `"seal"`)与测试企业(如专用的测试环境)。
3. **如果尚未接入企业**:
- 合思标准凭证接入生产企业:`seal-use corps add-hose --json '{"appKey":"...","appSecurity":"...","domain":"..."}'`
- 合思标准凭证接入生产企业:`seal-use corps add-hose-persistent --json '{"appKey":"...","appSecurity":"...","domain":"..."}'`
- 或通过协助链接接入:`seal-use corps add-link <url>`
4. **环境严格标记与 1 对 1 绑定**:
+1 -1
View File
@@ -235,7 +235,7 @@ function makeConfigEnv(): Record<string, string> {
id: "corp-a",
name: "Corp A",
source: {
type: "direct",
type: "seal",
token: "seal-token",
sealUrl: "https://corp-a.seal.test"
}
+34 -20
View File
@@ -177,7 +177,7 @@ async function diagnoseAuth(corp: CorpConfig) {
const uid = source.staffId.includes(":") ? source.staffId : `${source.corpId}:${source.staffId}`;
const stages: Array<Record<string, unknown>> = [];
if (!appKey || !appSecurity) {
if ((!appKey || !appSecurity) && !source.closeToken) {
return {
corp: {
id: corp.id,
@@ -195,26 +195,40 @@ async function diagnoseAuth(corp: CorpConfig) {
};
}
const openapi = await runDiagnoseStage("hose.openapi", async () => {
const json = await postJson(`${source.domain.replace(/\/+$/, "")}/api/openapi/v1/auth/getAccessToken`, {
appKey,
appSecurity
});
const value = objectValue(json.value);
const token = stringValue(value.accessToken) ?? stringValue(json.accessToken) ?? stringValue(json.token);
if (!token) throw new Error("Hose login did not return an access token");
return {
token,
public: {
corporationId: stringValue(value.corporationId) ?? stringValue(objectValue(value.corporation).id),
expireTime: numberValue(value.expireTime)
}
};
});
stages.push(openapi.public);
const openapi = appKey && appSecurity
? await runDiagnoseStage("hose.openapi", async () => {
const json = await postJson(`${source.domain.replace(/\/+$/, "")}/api/openapi/v1/auth/getAccessToken`, {
appKey,
appSecurity
});
const value = objectValue(json.value);
const token = stringValue(value.accessToken) ?? stringValue(json.accessToken) ?? stringValue(json.token);
if (!token) throw new Error("Hose login did not return an access token");
return {
token,
public: {
corporationId: stringValue(value.corporationId) ?? stringValue(objectValue(value.corporation).id),
expireTime: numberValue(value.expireTime)
}
};
})
: undefined;
if (openapi) stages.push(openapi.public);
const openapiToken = openapi.private?.token;
const provisional = openapiToken
const openapiToken = openapi?.private?.token;
const provisional = source.closeToken
? {
public: {
name: "hose.closeapi",
ok: true,
corpId: source.corpId,
staffId: source.staffId,
configured: true,
expiresAt: source.expiresAt
},
private: { token: source.closeToken }
}
: openapiToken
? await runDiagnoseStage("hose.provisional", async () => {
const json = await postJson(
`${source.domain.replace(/\/+$/, "")}/api/openapi/v1.1/provisional/getProvisionalAuth?accessToken=${encodeURIComponent(openapiToken)}`,
+68 -13
View File
@@ -26,7 +26,7 @@ afterEach(() => {
});
describe("corps link onboarding", () => {
test("imports a Hose assistance link and writes a verified Seal config", async () => {
test("imports a Hose assistance link and writes a verified Hose web-session config", async () => {
const enterprises = setupConfigEnv();
mockSealLinkRequests();
@@ -43,8 +43,8 @@ describe("corps link onboarding", () => {
seal: { url?: string; tenantSlug?: string };
source: {
type: string;
token: string;
expiresIn: number;
closeToken: string;
staffId: string;
provider?: string;
corpId?: string;
};
@@ -57,9 +57,9 @@ describe("corps link onboarding", () => {
tenantSlug: "acme-01"
},
source: {
type: "seal",
token: "seal-bearer-token",
expiresIn: 1800,
type: "hose",
closeToken: "hose-token",
staffId: "acme-01:admin",
provider: "hosecloud",
corpId: "acme-01"
}
@@ -171,14 +171,39 @@ describe("corps link onboarding", () => {
expect(readDirectory(enterprises)).toEqual([]);
});
test("rejects --as-hose when passed with a Seal native delegate link", async () => {
test("imports a normalized Hose web session and stores the Hose source", async () => {
const enterprises = setupConfigEnv();
mockSealLinkRequests();
const result = await runCli([
"corps",
"add-hose-web-session",
"--json",
JSON.stringify({
baseUrl: "https://wx2.ekuaibao.com",
corpId: "Acme-01",
accessToken: "hose-token",
staffId: "staff-1"
})
]);
expect(result.isError).toBe(false);
expect(result.exitCode).toBe(0);
const config = JSON.parse(readFileSync(join(enterprises, "acme-01.json"), "utf-8"));
expect(config.source.type).toBe("hose");
expect(config.source.provider).toBe("hosecloud");
expect(config.source.closeToken).toBe("hose-token");
expect(config.source.staffId).toBe("staff-1");
});
test("rejects --elevate-hose when passed with a Seal native delegate link", async () => {
mockSealLinkRequests();
const link = "https://acme-01.sealai.cc/delegate?token=del-tok";
const result = await runCli(["corps", "add-link", link, "--as-hose"]);
const result = await runCli(["corps", "add-link", link, "--elevate-hose"]);
expect(result.isError).toBe(true);
expect(result.stderr).toContain("Option --as-hose cannot be used with a Seal native delegate link");
expect(result.stderr).toContain("Option --elevate-hose cannot be used with a Seal native delegate link");
});
test("rejects a link when Seal identity does not match ekbCorpId", async () => {
@@ -195,6 +220,24 @@ describe("corps link onboarding", () => {
});
describe("corp compatibility alias", () => {
test("exposes add-hose-persistent as the canonical Hose onboarding command", async () => {
setupConfigEnv();
const result = await runCli(["corps", "add-hose-persistent", "--json", "{}"]);
expect(result.isError).toBe(true);
expect(result.stderr).toContain("Missing required JSON field: appKey");
expect(result.stderr).not.toContain("Unknown corps action");
});
test("exposes add-seal-bearer as the canonical Seal onboarding command", async () => {
setupConfigEnv();
const result = await runCli(["corps", "add-seal-bearer", "--json", "{}"]);
expect(result.isError).toBe(true);
expect(result.stderr).toContain("Missing required JSON field: token");
expect(result.stderr).not.toContain("Unknown corps action");
});
test("seal-use corp list executes and resolves cleanly like seal-use corps", async () => {
setupConfigEnv();
const result = await runCli(["corp", "list"]);
@@ -744,12 +787,12 @@ describe("Hose OpenAPI key extraction from assistance link", () => {
expect(config.source.staffId).toBe("acme-01:admin01");
});
test("corps add-link --as-hose automatically registers as Hose OpenAPI configuration", async () => {
test("corps add-link --elevate-hose automatically registers as Hose OpenAPI configuration", async () => {
const enterprises = setupConfigEnv();
mockHoseKeysRequests();
const link = hoseLink();
const result = await runCli(["corps", "add-link", link, "--as-hose", "--name", "Acme Auto Hose", "--force"]);
const result = await runCli(["corps", "add-link", link, "--elevate-hose", "--name", "Acme Auto Hose", "--force"]);
expect(result.isError).toBe(false);
expect(result.exitCode).toBe(0);
@@ -763,11 +806,11 @@ describe("Hose OpenAPI key extraction from assistance link", () => {
expect(config.source.appSecurity).toBe("sec_secret_password_456789");
});
test("corps add-link --as-hose --dry-run does not save a Hose configuration", async () => {
test("corps add-link --elevate-hose --dry-run does not save a Hose configuration", async () => {
const enterprises = setupConfigEnv();
mockHoseKeysRequests();
const result = await runCli(["corps", "add-link", hoseLink(), "--as-hose", "--dry-run"]);
const result = await runCli(["corps", "add-link", hoseLink(), "--elevate-hose", "--dry-run"]);
expect(result.isError).toBe(false);
const parsed = JSON.parse(result.stdout);
@@ -783,6 +826,18 @@ describe("Hose OpenAPI key extraction from assistance link", () => {
expect(readDirectory(enterprises)).toEqual([]);
});
test("corps add-link keeps --as-hose as a deprecated compatibility alias", async () => {
const enterprises = setupConfigEnv();
mockHoseKeysRequests();
const result = await runCli(["corps", "add-link", hoseLink(), "--as-hose", "--force"]);
expect(result.isError).toBe(false);
expect(result.exitCode).toBe(0);
expect(result.stderr).toContain("'--as-hose' is deprecated");
expect(existsSync(join(enterprises, "acme-01.json"))).toBe(true);
});
test("auth extract-keys alias works before any enterprise is configured", async () => {
setupConfigEnv();
mockHoseKeysRequests();
+16 -2005
View File
File diff suppressed because it is too large. Load diff
+155
View File
@@ -0,0 +1,155 @@
import { updateCorpConfig } from "../../../core/config/loader.js";
import { selectCorp } from "../../helpers.js";
import { confirmationRequired, usageError } from "../../errors.js";
import { booleanOption, stringOption } from "../../parser.js";
import { printJson } from "../../printer.js";
import type { ParsedArgs } from "../../types.js";
export async function handleCorpBindings(
action: string | undefined,
maybeName: string | undefined,
args: ParsedArgs
): Promise<boolean> {
if (action === "bind-test") {
let prodId: string | undefined;
let testId: string | undefined;
if (maybeName && args.command[3]) {
prodId = maybeName;
testId = args.command[3];
} else if (maybeName) {
const corpOption = stringOption(args.options.corp);
const testCorpOption = stringOption(args.options["test-corp"]) ?? stringOption(args.options.testCorp);
if (corpOption) {
prodId = corpOption;
testId = maybeName;
} else if (testCorpOption) {
prodId = maybeName;
testId = testCorpOption;
}
}
if (!prodId || !testId) {
throw usageError(
"Usage: seal-use corps bind-test <prodCorpId> <testCorpId> [--confirm] [--force]\n" +
" or: seal-use corps bind-test <testCorpId> --corp <prodCorpId> [--confirm] [--force]"
);
}
const prodCorp = selectCorp(prodId);
const testCorp = selectCorp(testId);
if (prodCorp.id === testCorp.id) {
throw usageError(`Cannot bind enterprise '${prodCorp.id}' to itself.`);
}
if (prodCorp.prodCorpId && prodCorp.prodCorpId !== testCorp.id) {
throw usageError(
`Cannot use '${prodCorp.id}' as a production enterprise because it is already registered as a test enterprise for '${prodCorp.prodCorpId}'. Multi-tier chaining is not permitted.`
);
}
if (testCorp.testCorpId && testCorp.testCorpId !== prodCorp.id) {
throw usageError(
`Cannot bind '${testCorp.id}' as a test enterprise because it already has a bound test enterprise '${testCorp.testCorpId}'. Multi-tier chaining is not permitted.`
);
}
const force = booleanOption(args.options.force) === true;
if (
(prodCorp.testCorpId && prodCorp.testCorpId !== testCorp.id) ||
(testCorp.prodCorpId && testCorp.prodCorpId !== prodCorp.id)
) {
if (!force) {
throw confirmationRequired(
`Enterprise binding conflict: production enterprise '${prodCorp.id}' is bound to '${prodCorp.testCorpId ?? "none"}', and test enterprise '${testCorp.id}' is bound to '${testCorp.prodCorpId ?? "none"}'. Overwriting an existing binding requires --force and --confirm.`,
`seal-use corps bind-test ${prodCorp.id} ${testCorp.id} --confirm --force`
);
}
}
const confirmed = booleanOption(args.options.confirm) === true || booleanOption(args.options.yes) === true;
if (!confirmed) {
const forceFlag = force ? " --force" : "";
throw confirmationRequired(
`Refusing to bind test enterprise '${testCorp.name}' (${testCorp.id}) to production enterprise '${prodCorp.name}' (${prodCorp.id}) without --confirm. Enterprise binding establishes 1-to-1 sync pairing and marks '${testCorp.id}' as a test environment.`,
`seal-use corps bind-test ${prodCorp.id} ${testCorp.id} --confirm${forceFlag}`
);
}
if (prodCorp.testCorpId && prodCorp.testCorpId !== testCorp.id) {
try {
updateCorpConfig(prodCorp.testCorpId, { prodCorpId: undefined });
} catch {}
}
if (testCorp.prodCorpId && testCorp.prodCorpId !== prodCorp.id) {
try {
updateCorpConfig(testCorp.prodCorpId, { testCorpId: undefined });
} catch {}
}
const updatedProd = updateCorpConfig(prodCorp.id, {
environment: "production",
testCorpId: testCorp.id
});
const updatedTest = updateCorpConfig(testCorp.id, {
environment: "test",
prodCorpId: prodCorp.id
});
printJson({
success: true,
productionEnterprise: {
id: updatedProd.id,
name: updatedProd.name,
environment: updatedProd.environment,
testCorpId: updatedProd.testCorpId
},
testEnterprise: {
id: updatedTest.id,
name: updatedTest.name,
environment: updatedTest.environment,
prodCorpId: updatedTest.prodCorpId
}
});
return true;
}
if (action === "unbind-test") {
const targetId = maybeName ?? stringOption(args.options.corp);
const corp = selectCorp(targetId);
if (!corp.testCorpId && !corp.prodCorpId) {
printJson({
unbound: false,
message: `Enterprise '${corp.name}' (${corp.id}) does not have an active test enterprise binding.`
});
return true;
}
const prodId = corp.testCorpId ? corp.id : corp.prodCorpId!;
const testId = corp.testCorpId ? corp.testCorpId : corp.id;
const confirmed = booleanOption(args.options.confirm) === true || booleanOption(args.options.yes) === true;
if (!confirmed) {
throw confirmationRequired(
`Refusing to unbind production enterprise '${prodId}' and test enterprise '${testId}' without --confirm.`,
`seal-use corps unbind-test ${corp.id} --confirm`
);
}
updateCorpConfig(prodId, { testCorpId: undefined });
try {
updateCorpConfig(testId, { prodCorpId: undefined });
} catch {}
printJson({
success: true,
unboundProduction: prodId,
unboundTest: testId
});
return true;
}
return false;
}
+439
View File
@@ -0,0 +1,439 @@
import { maskHoseSecurity } from "../../../core/auth/hose.js";
import { scoreAssistLink } from "../../../core/auth/delegate.js";
import { onboardSealBearer } from "../../../domains/seal/onboarding.js";
import { onboardAssistanceLink } from "../../../domains/enterprise/onboarding.js";
import {
listHoseStaffs,
onboardHosePersistent,
onboardHoseWebSession,
probeHoseEnterprise
} from "../../../domains/hose/onboarding.js";
import {
elevateHoseLink,
extractHoseKeysFromLink,
formatHoseKeyForOutput,
HoseKeySelectionError
} from "../../../domains/hose/keys.js";
import { CliError } from "../../errors.js";
import { selectCorp } from "../../helpers.js";
import {
booleanOption,
jsonObject,
optionalNumber,
optionalString,
requiredString,
stringOption
} from "../../parser.js";
import { printJson } from "../../printer.js";
import type { ParsedArgs } from "../../types.js";
import { maskCellphone } from "./shared.js";
export async function handleCorpOnboarding(
action: string | undefined,
maybeName: string | undefined,
args: ParsedArgs
): Promise<boolean> {
if (action === "probe-hose") {
const input = jsonObject(args.json);
const result = await probeHoseEnterprise({
appKey: requiredString(input, "appKey"),
appSecurity: requiredString(input, "appSecurity"),
domain: optionalString(input, "domain")
});
printJson({
domain: result.domain,
corpId: result.corpId,
name: result.corpName ?? result.corpId,
roleCount: result.roleCount,
roleGroups: result.roleGroups
});
return true;
}
if (action === "hose-staffs") {
const input = jsonObject(args.json);
const result = await listHoseStaffs({
appKey: requiredString(input, "appKey"),
appSecurity: requiredString(input, "appSecurity"),
domain: optionalString(input, "domain"),
role: optionalString(input, "role"),
roleDefId: optionalString(input, "roleDefId")
});
printJson({
domain: result.domain,
corpId: result.corpId,
corpName: result.corpName,
roleId: result.roleId,
roleName: result.roleName,
count: result.staffs.length,
staffs: result.staffs.map((staff) => ({
id: staff.id,
name: staff.name,
cellphone: maskCellphone(staff.cellphone),
active: staff.active,
authState: staff.authState,
userId: staff.userId,
email: staff.email
}))
});
return true;
}
if (action === "add-hose-persistent" || action === "add-hose") {
if (action === "add-hose") {
console.error("⚠️ Notice: 'add-hose' is a compatibility alias; use 'add-hose-persistent' for durable Hose credentials.");
}
const jsonPayload = jsonObject(args.json);
const merged = {
...jsonPayload,
...(args.options.staffName ? { staffName: stringOption(args.options.staffName) } : {}),
...(args.options["staff-name"] ? { staffName: stringOption(args.options["staff-name"]) } : {}),
...(args.options.staffPhone ? { staffPhone: stringOption(args.options.staffPhone) } : {}),
...(args.options["staff-phone"] ? { staffPhone: stringOption(args.options["staff-phone"]) } : {}),
...(args.options.name ? { name: stringOption(args.options.name) } : {}),
...(args.options.domain ? { domain: stringOption(args.options.domain) } : {}),
...(args.options.corpId ? { corpId: stringOption(args.options.corpId) } : {}),
...(args.options["corp-id"] ? { corpId: stringOption(args.options["corp-id"]) } : {}),
...(args.options.appKey ? { appKey: stringOption(args.options.appKey) } : {}),
...(args.options["app-key"] ? { appKey: stringOption(args.options["app-key"]) } : {}),
...(args.options.appSecurity ? { appSecurity: stringOption(args.options.appSecurity) } : {}),
...(args.options["app-security"] ? { appSecurity: stringOption(args.options["app-security"]) } : {}),
...(args.options.force !== undefined ? { force: booleanOption(args.options.force) } : {}),
...(args.options.overwrite !== undefined ? { overwrite: booleanOption(args.options.overwrite) } : {})
};
const result = await onboardHosePersistent({
...merged,
appKey: requiredString(merged, "appKey"),
appSecurity: requiredString(merged, "appSecurity")
});
printJson({
id: result.config.id,
name: result.config.name,
corpId: result.config.source.type === "hose" ? result.config.source.corpId : undefined,
domain: result.domain,
staffId: result.staffId,
verified: result.verified,
path: result.path
});
return true;
}
if (action === "add-hose-web-session") {
const jsonPayload = jsonObject(args.json);
const merged = {
...jsonPayload,
...(args.options.name ? { name: stringOption(args.options.name) } : {}),
...(args.options.domain ? { baseUrl: stringOption(args.options.domain) } : {}),
...(args.options["base-url"] ? { baseUrl: stringOption(args.options["base-url"]) } : {}),
...(args.options.corpId ? { corpId: stringOption(args.options.corpId) } : {}),
...(args.options["corp-id"] ? { corpId: stringOption(args.options["corp-id"]) } : {}),
...(args.options.staffId ? { staffId: stringOption(args.options.staffId) } : {}),
...(args.options["staff-id"] ? { staffId: stringOption(args.options["staff-id"]) } : {}),
...(args.options.accessToken ? { accessToken: stringOption(args.options.accessToken) } : {}),
...(args.options["access-token"] ? { accessToken: stringOption(args.options["access-token"]) } : {}),
...(args.options.overwrite !== undefined ? { overwrite: booleanOption(args.options.overwrite) } : {}),
...(args.options["dry-run"] !== undefined ? { dryRun: booleanOption(args.options["dry-run"]) } : {})
};
const dryRun = merged.dryRun === true;
const input = merged as Parameters<typeof onboardHoseWebSession>[0] & { dryRun?: boolean };
const result = await onboardHoseWebSession({
...input,
persist: !dryRun
});
if (dryRun) {
printJson({
dryRun: true,
kind: "hose-web-session",
corpId: result.session.corpId,
sealUrl: result.session.sealUrl,
tenant: result.identity.tenant,
user: result.identity.user,
staffId: result.staffId,
expiresIn: result.session.expiresIn
});
} else {
printJson({
id: result.config.id,
name: result.config.name,
tenantId: result.identity.tenant.id,
tenantSlug: result.config.seal.tenantSlug,
sourceType: "hose",
credentialMode: "web-session",
verified: true,
path: result.path
});
}
return true;
}
if (action === "add-seal-bearer" || action === "add-seal") {
if (action === "add-seal") {
console.error("⚠️ Notice: 'add-seal' is a compatibility alias; use 'add-seal-bearer' for Seal Bearer credentials.");
}
const jsonPayload = jsonObject(args.json);
const merged = {
...jsonPayload,
...(args.options.name ? { name: stringOption(args.options.name) } : {}),
...(args.options.token ? { token: stringOption(args.options.token) } : {}),
...(args.options.sealUrl ? { sealUrl: stringOption(args.options.sealUrl) } : {}),
...(args.options.url ? { sealUrl: stringOption(args.options.url) } : {}),
...(args.options.force !== undefined ? { force: booleanOption(args.options.force) } : {}),
...(args.options.overwrite !== undefined ? { overwrite: booleanOption(args.options.overwrite) } : {})
};
await addSealCorp(merged);
return true;
}
if (action === "add-link") {
const link = maybeName ?? stringOption(args.options.link) ?? stringOption(args.options.url);
if (!link) {
throw new Error("Usage: seal-use corps add-link <url> [--name <customName>] [--elevate-hose] [--overwrite]");
}
const dryRun = booleanOption(args.options["dry-run"]) === true || booleanOption(args.options.dryRun) === true;
const legacyAsHose = booleanOption(args.options["as-hose"]) === true || booleanOption(args.options.hose) === true;
const elevateHose = booleanOption(args.options["elevate-hose"]) === true || legacyAsHose;
if (legacyAsHose && !booleanOption(args.options["elevate-hose"])) {
console.error("⚠️ Notice: '--as-hose' is deprecated; use '--elevate-hose' to request Hose credential elevation.");
}
if (elevateHose) {
const winner = scoreAssistLink(link)[0];
if (winner?.kind === "seal-delegate") {
throw new Error("Option --elevate-hose cannot be used with a Seal native delegate link. Seal delegate links directly authenticate to Seal.");
}
await addLinkAsHoseCorp(
link,
stringOption(args.options.name),
booleanOption(args.options.overwrite) === true,
booleanOption(args.options.force) === true,
dryRun,
{
appKey: stringOption(args.options["app-key"]) ?? stringOption(args.options.appKey),
keyId: stringOption(args.options["key-id"]) ?? stringOption(args.options.keyId)
}
);
return true;
}
await addLinkCorp(link, stringOption(args.options.name), booleanOption(args.options.overwrite) === true, dryRun);
return true;
}
if (action === "extract-keys" || action === "extract-key" || action === "extract-hose-keys" || action === "hose-extract-keys") {
const link = maybeName ?? stringOption(args.options.link) ?? stringOption(args.options.url);
if (!link) {
throw new Error("Usage: seal-use corps hose-extract-keys <url> [--reveal] [--save] [--app-key <key>] [--key-id <id>] [--name <customName>] [--overwrite]");
}
await extractKeysFromLinkAction(link, {
reveal: booleanOption(args.options.reveal) === true || booleanOption(args.options.r) === true || booleanOption(args.options.plain) === true,
save: booleanOption(args.options.save) === true || booleanOption(args.options.add) === true,
name: stringOption(args.options.name),
overwrite: booleanOption(args.options.overwrite) === true,
force: booleanOption(args.options.force) === true,
appKey: stringOption(args.options["app-key"]) ?? stringOption(args.options.appKey),
keyId: stringOption(args.options["key-id"]) ?? stringOption(args.options.keyId)
});
return true;
}
if (action === "keys" || action === "hose-keys") {
const target = maybeName ?? stringOption(args.options.link) ?? stringOption(args.options.url) ?? stringOption(args.options.corp);
const reveal = booleanOption(args.options.reveal) === true || booleanOption(args.options.r) === true || booleanOption(args.options.plain) === true;
if (target && (target.startsWith("http://") || target.startsWith("https://"))) {
await extractKeysFromLinkAction(target, {
reveal,
save: booleanOption(args.options.save) === true || booleanOption(args.options.add) === true,
name: stringOption(args.options.name),
overwrite: booleanOption(args.options.overwrite) === true,
force: booleanOption(args.options.force) === true,
appKey: stringOption(args.options["app-key"]) ?? stringOption(args.options.appKey),
keyId: stringOption(args.options["key-id"]) ?? stringOption(args.options.keyId)
});
return true;
}
await showCorpKeysAction(target, { reveal });
return true;
}
return false;
}
async function addSealCorp(input: Record<string, unknown>) {
const token = requiredString(input, "token");
const sealUrl = (optionalString(input, "sealUrl") ?? optionalString(input, "url") ?? "").replace(/\/+$/, "");
if (!sealUrl) throw new Error("Missing required JSON field: sealUrl");
const result = await onboardSealBearer({
...input,
token,
sealUrl,
expiresIn: optionalNumber(input, "expiresIn"),
expiresAt: optionalString(input, "expiresAt"),
id: optionalString(input, "id"),
name: optionalString(input, "name"),
tenantSlug: optionalString(input, "tenantSlug"),
tenantId: optionalString(input, "tenantId"),
tenantName: optionalString(input, "tenantName"),
corpId: optionalString(input, "corpId"),
staffId: optionalString(input, "staffId"),
provider: optionalString(input, "provider"),
force: input.force === true,
verify: input.verify === false,
overwrite: input.overwrite === true,
headers: input.headers,
cookies: input.cookies
});
printJson({
id: result.config.id,
name: result.config.name,
tenantId: result.tenantId,
tenantSlug: result.tenantSlug,
verified: result.verified,
path: result.path
});
}
async function addLinkCorp(link: string, name: string | undefined, overwrite: boolean, dryRun = false) {
const result = await onboardAssistanceLink(link, { name, overwrite, dryRun });
if (result.kind === "seal-delegate") {
if (result.dryRun) {
printJson(result);
return;
}
printJson({
id: result.saved.config.id,
name: result.saved.config.name,
tenantId: result.saved.tenantId,
tenantSlug: result.saved.tenantSlug,
verified: true,
path: result.saved.path
});
return;
}
if (result.dryRun) {
printJson({
dryRun: true,
kind: "hose",
corpId: result.result.session.corpId,
sealUrl: result.result.session.sealUrl,
tenant: result.result.identity.tenant,
user: result.result.identity.user,
staffId: result.result.staffId
});
return;
}
printJson({
id: result.result.config.id,
name: result.result.config.name,
tenantId: result.result.identity.tenant.id,
tenantSlug: result.result.config.seal.tenantSlug,
sourceType: "hose",
credentialMode: "web-session",
verified: true,
path: result.result.path
});
}
async function addLinkAsHoseCorp(link: string, name: string | undefined, overwrite: boolean, force = false, dryRun = false, selection?: { appKey?: string; keyId?: string }) {
console.error("ℹ️ [合思子域提权] 正在通过合思协助链接提取 OpenAPI 开发者密钥并提升企业权限等级...");
let elevated;
try {
elevated = await elevateHoseLink({ link, name, overwrite, force, dryRun, ...(selection ?? {}) });
} catch (error) {
if (error instanceof HoseKeySelectionError) throw new CliError(error.message, 2, error.nextAction);
throw error;
}
const { result, selectedKey } = elevated;
console.error(dryRun
? `ℹ️ [合思子域提权] 已选定合思 OpenAPI 凭据 (appKey: ${selectedKey.appKey}, 应用: "${selectedKey.name || "未命名应用"}"),正在生成预览...`
: `ℹ️ [合思子域提权] 已选定合思 OpenAPI 凭据 (appKey: ${selectedKey.appKey}, 应用: "${selectedKey.name || "未命名应用"}"),正在初始化为长期合思标准配置...`);
if (dryRun) {
printJson({
dryRun: true,
kind: "hose",
provider: "hose",
corpId: result.corpId,
corpName: result.corpName,
baseUrl: result.baseUrl,
staffId: result.staffId,
selectedKey: {
id: selectedKey.id,
name: selectedKey.name || "-",
appKey: selectedKey.appKey,
appSecurity: maskHoseSecurity(selectedKey.appSecurity),
active: selectedKey.active
}
});
return;
}
const saved = elevated.saved;
if (!saved) throw new Error("Hose elevation completed without a saved enterprise configuration");
printJson({
id: saved.config.id,
name: saved.config.name,
corpId: result.corpId,
domain: saved.domain,
staffId: saved.staffId,
verified: saved.verified,
path: saved.path
});
}
export async function extractKeysFromLinkAction(link: string, options: { reveal?: boolean; save?: boolean; name?: string; overwrite?: boolean; force?: boolean; appKey?: string; keyId?: string }) {
let extracted;
try {
extracted = await extractHoseKeysFromLink({ link, ...options });
} catch (error) {
if (error instanceof HoseKeySelectionError) throw new CliError(error.message, 2, error.nextAction);
throw error;
}
const { result } = extracted;
const reveal = extracted.reveal;
if (options.save) {
const selectedKey = extracted.selectedKey!;
console.error(`ℹ️ [合思子域提权] 正在将选定的合思 OpenAPI 密钥 (appKey: ${selectedKey.appKey}, 应用: "${selectedKey.name || "未命名应用"}") 保存为标准合思企业配置...`);
printJson({
id: extracted.saved!.config.id,
name: extracted.saved!.config.name,
corpId: result.corpId,
domain: extracted.saved!.domain,
staffId: extracted.saved!.staffId,
verified: extracted.saved!.verified,
path: extracted.saved!.path
});
return;
}
if (!reveal) console.error("ℹ️ [合思子域提权] 成功提取合思 (Hose) OpenAPI 密钥。接入密码默认脱敏,附加 --reveal (或 -r) 可查看完整 appSecurity 明文;附加 --save 可将临时会话提权并持久化为标准合思企业。\n");
else console.error("⚠️ [合思子域提权] 正在以明文展示合思 (Hose) appSecurity 接入密码,请妥善保管敏感凭据。\n");
printJson({
provider: "hose",
capability: "privilege-elevation",
corpId: result.corpId,
corpName: result.corpName ?? result.corpId,
baseUrl: result.baseUrl,
staffId: result.staffId,
keyCount: result.keys.length,
keys: result.keys.map((key) => formatHoseKeyForOutput(key, reveal))
});
}
export async function showCorpKeysAction(targetCorpId: string | undefined, options: { reveal?: boolean }) {
const corp = selectCorp(targetCorpId);
const reveal = options.reveal === true;
if (corp.source.type !== "hose") {
throw new CliError(`【合思子域专享能力】当前企业「${corp.name}」(id: ${corp.id}) 为原生 Seal (${corp.source.type}) 租户,非合思 (Hose/合思云/易快报) 渠道企业。\n` +
"OpenAPI 密钥查询与提权能力专属于合思生态租户(用于从合思协助链接或合思凭据中提取开发者密钥提升权限等级),非合思渠道企业不支持此能力。", 2);
}
const appKey = corp.source.appKey ?? corp.source.key;
const appSecurity = corp.source.appSecurity ?? corp.source.password;
if (!reveal) console.error("💡 [合思子域] 接入密码默认脱敏,附加 --reveal (或 -r) 可查看完整 appSecurity 明文。\n");
else console.error("⚠️ [合思子域] 正在以明文展示合思 appSecurity 接入密码,请妥善保管敏感凭据。\n");
printJson({
provider: "hose",
capability: "privilege-elevation",
corpId: corp.id,
corpName: corp.name,
domain: corp.source.domain,
staffId: corp.source.staffId,
appKey: appKey ?? "-",
appSecurity: appSecurity ? (reveal ? appSecurity : maskHoseSecurity(appSecurity)) : "-",
active: true
});
}
+224
View File
@@ -0,0 +1,224 @@
import {
findCorpConfigFile,
loadCorpConfigs,
loadGlobalConfig,
saveGlobalConfig,
updateCorpConfig
} from "../../../core/config/loader.js";
import { filterCorpsFuzzy } from "../../../core/search/fuzzy.js";
import { sortCorpsByUsageAndRecency } from "../../../core/stats/usage-tracker.js";
import type { CorpEnvironment } from "../../../core/config/types.js";
import { selectCorp } from "../../helpers.js";
import { confirmationRequired, usageError } from "../../errors.js";
import { booleanOption, numberOption, optionalString, stringOption } from "../../parser.js";
import { printJson } from "../../printer.js";
import type { ParsedArgs } from "../../types.js";
import { formatSafeSourceDetail, resolveCorpSealUrl } from "./shared.js";
export async function handleCorpOverview(
action: string | undefined,
maybeName: string | undefined,
args: ParsedArgs
): Promise<boolean> {
if (!action || action === "list" || action === "search" || action === "find") {
const rawQuery = (
maybeName ?? stringOption(args.options.query) ?? stringOption(args.options.q)
)?.trim();
const isStrict = booleanOption(args.options.strict) === true;
const envFilter = (
stringOption(args.options.env) ?? stringOption(args.options.environment)
)?.trim().toLowerCase();
if ((action === "search" || action === "find") && !rawQuery && !envFilter) {
throw usageError("Usage: seal-use corps search <query> [--env <production|test>] [--strict]");
}
const corpId = stringOption(args.options.corp);
const allCorps = loadCorpConfigs();
const globalConfig = loadGlobalConfig();
const currentCorpId = corpId ?? (
globalConfig.stateful
? globalConfig.defaultCorpId ?? allCorps[0]?.id
: undefined
);
let filtered = allCorps;
if (envFilter) {
filtered = filtered.filter((item) => (item.environment ?? "production").toLowerCase() === envFilter);
}
if (rawQuery) {
filtered = filterCorpsFuzzy(filtered, rawQuery, { strict: isStrict });
}
if (allCorps.length === 0) {
console.error("提示:当前未检测到企业配置。你可以使用 seal-use corps add-hose-persistent、add-hose-web-session 或 add-seal-bearer 添加企业,或运行 seal-use help 查看说明。");
} else if (isStrict && filtered.length === 0 && (action === "search" || action === "find") && rawQuery) {
console.error(`提示:未在严格模式下匹配到企业 "${rawQuery}"。可以尝试省略 --strict 进行智能软搜索。`);
}
// Search results are already ranked by match confidence. Usage sorting is
// useful for an unfiltered list, but would otherwise discard relevance
// ordering for a query.
const sorted = rawQuery ? filtered : sortCorpsByUsageAndRecency(filtered, currentCorpId);
const isList = !action || action === "list";
const isAll = booleanOption(args.options.all) === true;
const limitOpt = numberOption(args.options.limit);
const defaultLimit = 10;
const effectiveLimit = limitOpt !== undefined
? Math.max(1, limitOpt)
: (isList && !isAll ? defaultLimit : undefined);
let displayList = sorted;
if (effectiveLimit !== undefined && sorted.length > effectiveLimit) {
displayList = sorted.slice(0, effectiveLimit);
if (isList && !isAll && limitOpt === undefined) {
console.error(
`ℹ️ 当前共有 ${sorted.length} 家企业,已按最近 7 天使用频次展示前 ${effectiveLimit} 家。\n` +
`👉 查看全部请添加: seal-use corps list --all\n` +
`👉 检索指定企业请使用: seal-use corps search <keyword>`
);
}
}
printJson(displayList.map((item) => ({
id: item.id,
name: item.name,
environment: item.environment ?? "production",
sourceType: item.source.type,
provider: (item.source as any).provider ?? item.source.type,
staffId: item.source.staffId,
testCorpId: item.testCorpId,
prodCorpId: item.prodCorpId,
current: item.id === currentCorpId
})));
return true;
}
if (action === "get" || action === "show") {
const targetCorpId = maybeName ?? stringOption(args.options.corp);
if (!targetCorpId) {
throw usageError("Usage: seal-use corps get <corpId>");
}
const corp = selectCorp(targetCorpId);
const configFile = findCorpConfigFile(corp.id);
const sealUrl = resolveCorpSealUrl(corp);
printJson({
id: corp.id,
name: corp.name,
environment: corp.environment ?? "production",
configFile,
seal: {
url: sealUrl,
tenantSlug: corp.seal.tenantSlug ?? (corp.source as any).tenantSlug,
customHeaderNames: corp.seal.headers ? Object.keys(corp.seal.headers) : [],
customCookieNames: corp.seal.cookies ? Object.keys(corp.seal.cookies) : [],
endpoints: corp.seal.endpoints
},
source: formatSafeSourceDetail(corp.source),
relations: {
testCorpId: corp.testCorpId,
prodCorpId: corp.prodCorpId
},
auth: {
refreshTtl: corp.auth.refreshTtl
}
});
return true;
}
if (action === "current") {
const corp = selectCorp(stringOption(args.options.corp));
printJson({
id: corp.id,
name: corp.name,
environment: corp.environment ?? "production",
sourceType: corp.source.type,
provider: (corp.source as any).provider ?? corp.source.type,
staffId: corp.source.staffId,
testCorpId: corp.testCorpId,
prodCorpId: corp.prodCorpId
});
return true;
}
if (action === "mark" || action === "mark-test" || action === "mark-prod") {
const corpId = maybeName ?? stringOption(args.options.corp);
if (!corpId) {
throw usageError("Usage: seal-use corps mark <corpId> --env <production|test> [--confirm]");
}
const corp = selectCorp(corpId);
const targetEnv = (
action === "mark-test"
? "test"
: action === "mark-prod"
? "production"
: (stringOption(args.options.env) ?? stringOption(args.options.environment))
) as CorpEnvironment | undefined;
if (targetEnv !== "production" && targetEnv !== "test") {
throw usageError("Usage: seal-use corps mark <corpId> --env <production|test> [--confirm]");
}
const confirmed = booleanOption(args.options.confirm) === true || booleanOption(args.options.yes) === true;
if (!confirmed) {
throw confirmationRequired(
`Refusing to change environment tag of enterprise '${corp.name}' (${corp.id}) to '${targetEnv}' without --confirm. Marking alters synchronization safety guards.`,
`seal-use corps mark ${corp.id} --env ${targetEnv} --confirm`
);
}
const updated = updateCorpConfig(corp.id, { environment: targetEnv });
printJson({
id: updated.id,
name: updated.name,
environment: updated.environment,
testCorpId: updated.testCorpId,
prodCorpId: updated.prodCorpId
});
return true;
}
if (action === "rename") {
const targetCorpId = maybeName ?? stringOption(args.options.corp) ?? stringOption(args.options.id);
const newName = stringOption(args.options.name) ?? stringOption(args.options.to) ??
(args.command[3] && !args.command[3].startsWith("-") ? args.command[3] : undefined);
if (!targetCorpId || !newName) {
throw new Error("Usage: seal-use corps rename <corpId> --name <newName>");
}
const corp = selectCorp(targetCorpId);
const updated = updateCorpConfig(corp.id, { name: newName });
printJson({
success: true,
id: updated.id,
name: updated.name,
previousName: corp.name
});
return true;
}
if (action === "switch") {
const corpId = maybeName;
if (!corpId) throw new Error("Usage: seal-use corps switch <corpId>");
const globalConfig = loadGlobalConfig();
if (!globalConfig.stateful) {
throw new Error(
"Cannot switch the default enterprise while stateless mode is enabled. " +
"Use `seal-use config mode stateful` first."
);
}
const corp = selectCorp(corpId);
saveGlobalConfig({ ...globalConfig, stateful: true, defaultCorpId: corp.id });
printJson({
current: true,
id: corp.id,
name: corp.name
});
return true;
}
return false;
}
+82
View File
@@ -0,0 +1,82 @@
import { defaultSealUrl } from "../../../core/auth/hose.js";
import type { CorpConfig, SealSource } from "../../../core/config/types.js";
// ---------------------------------------------------------------------------
// Helpers & Sanitizers
// ---------------------------------------------------------------------------
export function maskSecret(value: string | undefined): string | undefined {
if (!value) return undefined;
if (value.length <= 8) return "****";
return `${value.slice(0, 4)}...${value.slice(-4)}`;
}
export function resolveCorpSealUrl(corp: CorpConfig): string | undefined {
if (corp.source.type === "hose") {
return defaultSealUrl(corp, corp.source);
}
return corp.seal.url ?? corp.source.sealUrl;
}
export function formatSafeSourceDetail(source: SealSource) {
if (source.type === "hose") {
const key = source.appKey ?? source.key;
return {
type: "hose",
provider: source.provider ?? "hosecloud",
domain: source.domain,
corpId: source.corpId,
staffId: source.staffId,
appKey: maskSecret(key),
hasAppSecurity: Boolean(source.appSecurity ?? source.password),
hasCloseToken: Boolean(source.closeToken),
closeTokenExpiresIn: source.closeToken ? source.expiresIn : undefined,
closeTokenExpiresAt: source.closeToken ? source.expiresAt : undefined,
credentialMode: source.closeToken ? "web-session" : "persistent",
sealUrl: source.sealUrl
};
}
if (source.type === "seal") {
return {
type: "seal",
provider: source.provider ?? "seal",
tenantId: source.tenantId,
tenantSlug: source.tenantSlug,
tenantName: source.tenantName,
providerUserId: source.providerUserId,
staffId: source.staffId,
corpId: source.corpId,
sealUrl: source.sealUrl,
hasToken: Boolean(source.token),
tokenMasked: maskSecret(source.token),
expiresIn: source.expiresIn,
expiresAt: source.expiresAt
};
}
throw new Error(`Unsupported enterprise source type: ${(source as { type: string }).type}`);
}
export function maskCellphone(phone: string | undefined | null): string {
if (!phone) return "未绑定手机";
const cleaned = phone.trim();
if (cleaned.length === 11) {
return `${cleaned.slice(0, 3)}****${cleaned.slice(7)}`;
}
if (cleaned.length >= 7) {
return `${cleaned.slice(0, 3)}****${cleaned.slice(-4)}`;
}
if (cleaned.length > 4) {
return `${cleaned.slice(0, 2)}****${cleaned.slice(-2)}`;
}
return cleaned;
}
export function formatUtcTimestampSeconds(timestampMs: number): string {
return new Date(timestampMs).toISOString().replace(/\.\d{3}Z$/, "Z");
}
export function stringValue(value: unknown): string | undefined {
return typeof value === "string" && value ? value : undefined;
}
+135
View File
@@ -0,0 +1,135 @@
import { createSealClient } from "../../../core/http/factory.js";
import type { CorpConfig } from "../../../core/config/types.js";
import { syncTestEnterprise, buildTestHosecloudOutboundName } from "../../../domains/seal/test-sync.js";
import { executeApprovalRunsReplay, type ReplayRecordsQuery } from "../../../domains/seal/webhook-replay.js";
import { selectCorp } from "../../helpers.js";
import { CliError, confirmationRequired, usageError } from "../../errors.js";
import { booleanOption, numberOption, stringOption } from "../../parser.js";
import { printJson } from "../../printer.js";
import type { ParsedArgs } from "../../types.js";
export { buildTestHosecloudOutboundName } from "../../../domains/seal/test-sync.js";
export async function handleCorpSync(
action: string | undefined,
maybeName: string | undefined,
args: ParsedArgs
): Promise<boolean> {
if (action === "sync-test") {
const targetCorpId = maybeName ?? stringOption(args.options.corp);
const prodCorp = selectCorp(targetCorpId);
if (!prodCorp.testCorpId) {
throw usageError(
`Production enterprise '${prodCorp.name}' (${prodCorp.id}) has no bound test enterprise.\n` +
`Run 'seal-use corps bind-test ${prodCorp.id} <testCorpId> --confirm' first to establish a verified 1-to-1 association.`
);
}
const testCorp = selectCorp(prodCorp.testCorpId);
if (testCorp.environment !== "test") {
throw new Error(
`Target enterprise '${testCorp.name}' (${testCorp.id}) is marked as '${testCorp.environment}', NOT 'test'. Aborting sync to protect non-test environments.`
);
}
const versionName = stringOption(args.options["version-name"]) ?? stringOption(args.options.versionName);
const dryRun = booleanOption(args.options["dry-run"]) === true || booleanOption(args.options.dryRun) === true;
const confirmed = booleanOption(args.options.yes) === true || booleanOption(args.options.confirm) === true;
if (dryRun) {
printJson(await syncTestEnterprise(prodCorp, testCorp, { versionName, dryRun: true }));
return true;
}
if (!confirmed) {
const preview = await syncTestEnterprise(prodCorp, testCorp, { versionName, execute: false }) as {
rulesPlan: { sourceDraftRuleCount: number };
documentsPlan: { sourceDocumentCount: number };
};
throw confirmationRequired(
`Refusing to overwrite test enterprise '${testCorp.name}' (${testCorp.id}) with preferences, ${preview.rulesPlan.sourceDraftRuleCount} draft rules, and ${preview.documentsPlan.sourceDocumentCount} knowledge documents from production enterprise '${prodCorp.name}' (${prodCorp.id}) without --yes. This will replace test draft rules, synchronize knowledge documents, and publish a new version on the test enterprise.`,
`seal-use corps sync-test ${prodCorp.id} --yes`
);
}
printJson(await syncTestEnterprise(prodCorp, testCorp, { versionName, execute: true }));
return true;
}
if (action === "replay-test") {
const targetCorpId = maybeName ?? stringOption(args.options.corp) ?? stringOption(args.options.prodCorp) ?? stringOption(args.options["prod-corp"]);
const prodCorp = selectCorp(targetCorpId);
const force = booleanOption(args.options.force) === true;
const dryRun = booleanOption(args.options.dryRun) ?? booleanOption(args.options["dry-run"]);
const confirmed = booleanOption(args.options.yes) === true || booleanOption(args.options.confirm) === true;
let testCorp: CorpConfig;
if (!prodCorp.testCorpId) {
if (!force) {
throw usageError(
`Production enterprise '${prodCorp.name}' (${prodCorp.id}) has no bound test enterprise.\n` +
`Run 'seal-use corps bind-test ${prodCorp.id} <testCorpId> --confirm' first to establish a verified 1-to-1 association,\n` +
`or add '--force' (or use 'seal-use webhook replay <recordId> --force') if you explicitly intend to replay directly within production.`
);
}
testCorp = prodCorp;
} else {
testCorp = selectCorp(prodCorp.testCorpId);
if (testCorp.environment !== "test" && !force) {
throw new Error(
`Target enterprise '${testCorp.name}' (${testCorp.id}) is marked as '${testCorp.environment}', NOT 'test'. Aborting replay to protect non-test environments (use --force to override).`
);
}
}
if (!dryRun && !confirmed) {
throw confirmationRequired(
"Refusing to replay approval records without --confirm. Use --dry-run to preview the payload without sending it.",
`seal-use corps replay-test ${targetCorpId ?? "<prodCorpId>"} --confirm`
);
}
const recordId = stringOption(args.options.recordId) ?? stringOption(args.options["record-id"]) ?? stringOption(args.options.id);
const recordIdsRaw = stringOption(args.options.recordIds) ?? stringOption(args.options["record-ids"]);
const recordIds = recordIdsRaw ? recordIdsRaw.split(",").map((value) => value.trim()).filter(Boolean) : undefined;
const sn = stringOption(args.options.sn) ?? stringOption(args.options.documentSn) ?? stringOption(args.options["document-sn"]);
const snsRaw = stringOption(args.options.sns) ?? stringOption(args.options["document-sns"]);
const sns = snsRaw ? snsRaw.split(",").map((value) => value.trim()).filter(Boolean) : undefined;
const limit = numberOption(args.options.limit) ?? (!recordId && !recordIds && !sn && !sns ? 1 : undefined);
const query: ReplayRecordsQuery = {
recordId,
recordIds,
sn,
sns,
limit,
status: stringOption(args.options.status),
startDate: stringOption(args.options.startDate) ?? stringOption(args.options["start-date"]),
endDate: stringOption(args.options.endDate) ?? stringOption(args.options["end-date"])
};
const prodClient = await createSealClient(prodCorp);
const testClient = prodCorp.id === testCorp.id ? prodClient : await createSealClient(testCorp);
console.error(`[corps-replay-test] 正式企业「${prodCorp.name}」(${prodCorp.id}) -> 测试企业「${testCorp.name}」(${testCorp.id})`);
const result = await executeApprovalRunsReplay({
query,
sourceClient: prodClient,
targetClient: testClient,
sourceCorp: prodCorp,
targetCorp: testCorp,
webhookSelector: stringOption(args.options.webhook) ?? stringOption(args.options.selector),
snPrefix: stringOption(args.options.snPrefix) ?? stringOption(args.options["sn-prefix"]),
snSuffix: stringOption(args.options.snSuffix) ?? stringOption(args.options["sn-suffix"]),
docIdPrefix: stringOption(args.options.docIdPrefix) ?? stringOption(args.options["doc-id-prefix"]),
docIdSuffix: stringOption(args.options.docIdSuffix) ?? stringOption(args.options["doc-id-suffix"]),
dryRun
});
if (dryRun) {
console.error(`[corps-replay-test] 预览模式:已成功从 ${prodCorp.name} 提取单据并转换为 Webhook Payload(未实际推送)。`);
printJson(result);
return true;
}
if (result.success) {
console.error(`🟢 成功重放 ${result.successCount} 条单据(来自「${prodCorp.name}」)至「${testCorp.name}」(${result.targetWebhook?.name ?? "Webhook 通道"})`);
} else {
console.error(`🔴 单据重放部分或全部失败(成功 ${result.successCount} 条,失败 ${result.failureCount} 条)至「${testCorp.name}」`);
}
console.error(`👉 Next action: seal-use approval-runs list --corp ${testCorp.id} --limit ${result.totalCount}`);
printJson(result);
if (!result.success) throw new CliError(`Approval record replay failed: ${result.failureCount} record(s) failed.`, 1);
return true;
}
return false;
}
+79 -12
View File
@@ -1,6 +1,6 @@
import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
import { basename, dirname, isAbsolute, join, relative } from "node:path";
import { spawnSync } from "node:child_process";
import { spawn, spawnSync } from "node:child_process";
import { isCompiledBinary } from "../../core/runtime.js";
import { readInstalledSkillVersion } from "../../core/embedded-skill.js";
import { saveUpdateCache } from "../../core/update-cache.js";
@@ -529,11 +529,10 @@ async function handleHomebrewUpdate(
// `brew update` refreshes all configured taps. Passing a tap name here is
// parsed as a formula upgrade by newer Homebrew versions (and fails with
// "No available formula ... tap").
const tapUpdate = spawnSync("brew", ["update"], {
stdio: ["ignore", "pipe", "pipe"],
encoding: "utf-8",
env: { ...process.env, NONINTERACTIVE: "1" }
});
const tapUpdate = await runHomebrewCommand(
["update"],
"🔄 [1/2] 正在刷新 Homebrew 软件源(可能需要几分钟)..."
);
if (tapUpdate.status !== 0) {
const msg = tapUpdate.stderr?.trim() || tapUpdate.stdout?.trim();
@@ -541,11 +540,10 @@ async function handleHomebrewUpdate(
}
// 2. Upgrade the formula
const upgradeRes = spawnSync("brew", ["upgrade", "seal-use"], {
stdio: ["ignore", "pipe", "pipe"],
encoding: "utf-8",
env: { ...process.env, NONINTERACTIVE: "1" }
});
const upgradeRes = await runHomebrewCommand(
["upgrade", "seal-use"],
"⬆️ [2/2] 正在升级 seal-use..."
);
const outCombined = `${upgradeRes.stdout || ""} ${upgradeRes.stderr || ""}`;
const brewReportsAlreadyLatest =
@@ -553,7 +551,7 @@ async function handleHomebrewUpdate(
if (upgradeRes.status !== 0 && !brewReportsAlreadyLatest) {
throw new Error(
`brew upgrade seal-use failed (exit ${upgradeRes.status}): ${upgradeRes.stderr?.trim() || upgradeRes.stdout?.trim()}`
`brew upgrade seal-use failed (exit ${upgradeRes.status}): ${upgradeRes.stderr.trim() || upgradeRes.stdout.trim()}`
);
}
@@ -607,6 +605,75 @@ async function handleHomebrewUpdate(
});
}
type HomebrewCommandResult = {
status: number | null;
signal: NodeJS.Signals | null;
stdout: string;
stderr: string;
};
/**
* Runs Homebrew without buffering its output until completion. Homebrew can spend several minutes
* refreshing taps or downloading a formula, so its output belongs on stderr as live diagnostics;
* stdout must remain reserved for the command's final machine-readable JSON payload.
*/
function runHomebrewCommand(args: string[], startMessage: string): Promise<HomebrewCommandResult> {
console.error(startMessage);
return new Promise((resolve, reject) => {
let child;
try {
child = spawn("brew", args, {
stdio: ["ignore", "pipe", "pipe"],
env: { ...process.env, NONINTERACTIVE: "1" }
});
} catch (error) {
reject(error);
return;
}
let stdout = "";
let stderr = "";
let lastOutputAt = Date.now();
let settled = false;
const forward = (chunk: Buffer, stream: "stdout" | "stderr") => {
const text = chunk.toString();
if (stream === "stdout") stdout += text;
else stderr += text;
lastOutputAt = Date.now();
try {
process.stderr.write(text);
} catch {
// Ignore a closed diagnostic stream; the child process still needs to complete normally.
}
};
child.stdout?.on("data", (chunk: Buffer) => forward(chunk, "stdout"));
child.stderr?.on("data", (chunk: Buffer) => forward(chunk, "stderr"));
const heartbeat = setInterval(() => {
if (Date.now() - lastOutputAt >= 15000) {
console.error("⏳ Homebrew 仍在运行,当前没有新的输出,请稍候...");
lastOutputAt = Date.now();
}
}, 15000);
heartbeat.unref?.();
const finish = (callback: () => void) => {
if (settled) return;
settled = true;
clearInterval(heartbeat);
callback();
};
child.once("error", (error) => finish(() => reject(error)));
child.once("close", (status, signal) =>
finish(() => resolve({ status, signal, stdout, stderr }))
);
});
}
type GitHubAsset = {
name: string;
downloadUrl: string;
@@ -49,7 +49,7 @@ function setupMockEnv() {
name: "测试资源包企业",
environment: "test",
source: {
type: "direct",
type: "seal",
token: "mock-valid-token",
sealUrl: "https://test-pack.sealai.cc"
},
@@ -115,7 +115,7 @@ describe("Webhook Resource Pack CLI Commands", () => {
id: "test-corp-pack",
name: "测试企业",
source: {
type: "direct",
type: "seal",
token: "mock-valid-token",
sealUrl: "https://test-pack.sealai.cc",
expiresIn: 3600,
+15
View File
@@ -75,6 +75,9 @@ describe("renderHelp", () => {
expect(help).toContain("seal-use corps sync-test");
expect(help).toContain("发现与选择:");
expect(help).toContain("企业接入:");
expect(help).toContain("seal-use corps add-hose-persistent");
expect(help).toContain("seal-use corps add-seal-bearer");
expect(help).toContain("seal-use corps add-hose-web-session");
expect(help).toContain("Hose 专属能力:");
expect(help).toContain("seal-use corps probe-hose");
expect(help).toContain("seal-use corps hose-staffs");
@@ -103,6 +106,18 @@ describe("renderHelp", () => {
expect(help).not.toContain("seal-use webhook");
});
test("documents the add-hose compatibility alias", () => {
const help = renderHelp(["corps", "add-hose-persistent"]);
expect(help).toContain("seal-use corps add-hose-persistent");
expect(help).toContain("旧命令 add-hose 仍可用");
});
test("documents the add-seal compatibility alias", () => {
const help = renderHelp(["corps", "add-seal-bearer"]);
expect(help).toContain("seal-use corps add-seal-bearer");
expect(help).toContain("旧命令 add-seal 仍可用");
});
test("throws usage error for unknown area or subcommand", () => {
expect(() => renderHelp(["nonexistent-domain"])).toThrow(/Unknown command/);
expect(() => renderHelp(["corps", "nonexistent-cmd"])).toThrow(/Unknown corps command/);
+29 -9
View File
@@ -157,28 +157,48 @@ export const HELP_REGISTRY: AreaHelp[] = [
description: "Pulls production approval records from the production enterprise and replays them into the bound test enterprise's Webhook channel for rule verification."
},
{
name: "add-hose",
name: "add-hose-persistent",
aliases: ["add-hose"],
group: "企业接入",
summary: "Add a Hose/Ekuaibao enterprise configuration",
usage: ["seal-use corps add-hose --json '{\"name\":\"企业名称\",\"domain\":\"https://app.ekuaibao.com\",\"appKey\":\"...\",\"appSecurity\":\"...\",\"proxyStaffBizId\":\"corpId:staffId\"}'"]
summary: "Add a durable Hose/Ekuaibao enterprise configuration",
usage: ["seal-use corps add-hose-persistent --json '{\"name\":\"企业名称\",\"domain\":\"https://app.ekuaibao.com\",\"appKey\":\"...\",\"appSecurity\":\"...\",\"proxyStaffBizId\":\"corpId:staffId\"}'"],
description: "使用长期 Hose OpenAPI 凭据接入企业并持久化配置;旧命令 add-hose 仍可用,但仅作为兼容别名。"
},
{
name: "add-seal",
name: "add-seal-bearer",
aliases: ["add-seal"],
group: "企业接入",
summary: "Add a native Seal enterprise configuration",
usage: ["seal-use corps add-seal --json '{\"sealUrl\":\"https://tenant.sealai.cc\",\"token\":\"seal-bearer-token\"}'"]
summary: "Add a native Seal enterprise from a Bearer session",
usage: ["seal-use corps add-seal-bearer --json '{\"sealUrl\":\"https://tenant.sealai.cc\",\"token\":\"seal-bearer-token\"}'"],
description: "使用 Seal Bearer Token 接入原生 Seal 企业;旧命令 add-seal 仍可用,但仅作为兼容别名。"
},
{
name: "add-hose-web-session",
group: "企业接入",
summary: "Import a temporary Hose web session and exchange it for a Seal session",
usage: ["seal-use corps add-hose-web-session --json '{\"baseUrl\":\"https://wx2.ekuaibao.com\",\"corpId\":\"...\",\"staffId\":\"...\",\"accessToken\":\"...\"}'"],
options: [
{ flag: "--name <name>", description: "Optional custom name for the enterprise" },
{ flag: "--domain <url>", description: "Hose web-session base URL (alias: --base-url)" },
{ flag: "--corp-id <id>", description: "Hose corporation ID" },
{ flag: "--staff-id <id>", description: "Hose web-session staff ID (normally discovered automatically)" },
{ flag: "--access-token <token>", description: "Hose web-session accesstoken" },
{ flag: "--overwrite", description: "Overwrite existing enterprise config" },
{ flag: "--dry-run", description: "Exchange and verify the session without saving local config" }
],
description: "将 Agent 从合思后台 cURL 提取出的 accesstoken 保存为 Hose closeToken,并绑定 corpId/staffId;调用 Seal 能力时再经 Hose→Seal SSO 换取短期 Seal Bearer。不提取或持久化 OpenAPI appKey/appSecurity。"
},
{
name: "add-link",
group: "企业接入",
summary: "Import enterprise configuration from a Seal delegation link or Hose assistance link",
usage: [
"seal-use corps add-link <url> [--name <customName>] [--as-hose] [--app-key <key>] [--key-id <id>] [--overwrite] [--dry-run]"
"seal-use corps add-link <url> [--name <customName>] [--elevate-hose] [--app-key <key>] [--key-id <id>] [--overwrite] [--dry-run]"
],
options: [
{ flag: "--name <name>", description: "Optional custom name for the enterprise" },
{ flag: "--dry-run", description: "Preview link resolution and tenant metadata without saving" },
{ flag: "--as-hose", description: "【合思子域提权】从协助链接提取 OpenAPI 密钥并将临时会话升级为长期合思标准配置" },
{ flag: "--elevate-hose", description: "【明确提权】从合思协助链接提取 OpenAPI 密钥并将临时会话升级为长期标准配置(旧别名:--as-hose)" },
{ flag: "--app-key <key>", description: "企业存在多套密钥时,指定使用的 appKey" },
{ flag: "--key-id <id>", description: "企业存在多套密钥时,指定使用的 keyId" },
{ flag: "--overwrite", description: "Overwrite existing enterprise config" }
@@ -196,7 +216,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
group: "Hose 专属能力",
summary: "Discover Hose staff candidates by role",
usage: ["seal-use corps hose-staffs --json '{\"appKey\":\"...\",\"appSecurity\":\"...\",\"role\":\"admin\"}'"],
description: "按合思角色查询员工候选;手机号默认脱敏,供 add-hose 选择管理员。"
description: "按合思角色查询员工候选;手机号默认脱敏,供 add-hose-persistent 选择管理员。"
},
{
name: "hose-extract-keys",
-28
View File
@@ -1,28 +0,0 @@
import { CorpConfig } from "../config/types.js";
import { SealSession } from "./types.js";
export async function getDirectSealSession(corp: CorpConfig): Promise<SealSession> {
if (corp.source.type !== "direct" && corp.source.type !== "seal") {
throw new Error(`Unsupported Seal source: ${corp.source.type}`);
}
const sealUrl = corp.seal.url ?? corp.source.sealUrl;
const nativeSource = corp.source.type === "seal" ? corp.source : undefined;
return {
token: corp.source.token,
expiresAt: Date.now() + corp.source.expiresIn * 1000,
enterprise: {
provider: nativeSource ? "seal" : "direct",
corpId: corp.source.corpId ?? corp.id,
staffId: corp.source.staffId,
sealUrl,
tenantId: nativeSource?.tenantId,
tenantSlug: corp.seal.tenantSlug ?? nativeSource?.tenantSlug,
tenantName: nativeSource?.tenantName,
raw: {
sourceType: corp.source.type
}
}
};
}
+39
View File
@@ -12,6 +12,7 @@ import {
fetchHoseStaffDetails,
getHoseEnterpriseUrl,
getHoseProvisionalAuthLink,
getHoseSealSession,
normalizeBaseUrl,
parseHoseAssistLink
} from "./hose.js";
@@ -113,6 +114,44 @@ describe("hose auth helpers", () => {
expect(url).toBe("https://app.ekuaibao.com/web/home.html?accessToken=close-token");
});
test("uses a configured Hose closeToken without OpenAPI credentials", async () => {
let requestedToken = "";
globalThis.fetch = (async (input: RequestInfo | URL) => {
const requestUrl = typeof input === "string"
? input
: input instanceof URL
? input.toString()
: input.url;
const url = new URL(requestUrl);
requestedToken = url.searchParams.get("token") ?? "";
return new Response(JSON.stringify({ accessToken: "seal-runtime-token", expiresIn: 1800 }), {
status: 200,
headers: { "content-type": "application/json" }
});
}) as typeof fetch;
const corp: CorpConfig = {
id: "corp-web",
name: "Corp Web",
environment: "production",
seal: { endpoints: { approvalStylePreferences: "" } },
source: {
type: "hose",
provider: "hosecloud",
domain: "https://wx2.ekuaibao.com",
closeToken: "hose-close-token",
staffId: "corp-web:staff-1",
corpId: "corp-web"
},
auth: { refreshTtl: 300 }
};
const session = await getHoseSealSession(corp);
expect(requestedToken).toBe("hose-close-token");
expect(session.token).toBe("seal-runtime-token");
expect(session.enterprise.provider).toBe("hose");
});
test("HOSE_STANDARD_DOMAINS contains 6 expected public platform domains", () => {
expect(HOSE_STANDARD_DOMAINS.length).toBe(6);
expect(HOSE_STANDARD_DOMAINS).toContain("https://app.ekuaibao.com");
+12 -1
View File
@@ -275,7 +275,7 @@ async function fetchHoseOpenapiToken(source: HoseSealSource): Promise<TokenEntry
const appSecurity = source.appSecurity ?? source.password;
if (!appKey || !appSecurity) {
throw new Error("Hose source requires appKey/key and appSecurity/password");
throw new Error("Hose source has no OpenAPI credentials; the configured closeToken is only valid for Hose web-session APIs");
}
const response = await client
@@ -367,6 +367,17 @@ export async function ensureHoseCloseApiToken(corp: CorpConfig): Promise<TokenEn
}
const source = corp.source;
if (source.closeToken) {
const expiresAt = source.expiresAt ? Date.parse(source.expiresAt) : Number.MAX_SAFE_INTEGER;
if (expiresAt !== Number.MAX_SAFE_INTEGER && Date.now() >= expiresAt) {
throw new Error("Configured Hose closeToken has expired; import a fresh Hose web session");
}
return {
token: source.closeToken,
expiresAt
};
}
const cache = getHoseAuthCache(corp.id);
if (isFresh(cache.closeapi) && cache.closeapi.url) {
return cache.closeapi;
@@ -1,45 +1,45 @@
import { describe, expect, test } from "bun:test";
import { CorpConfig } from "../config/types.js";
import { getDirectSealSession } from "./direct.js";
import { getNativeSealSession } from "./native.js";
describe("getDirectSealSession", () => {
test("resolves direct source session correctly", async () => {
describe("getNativeSealSession", () => {
test("resolves native Seal source session correctly", async () => {
const corp: CorpConfig = {
id: "corp-direct-1",
name: "Direct Corp",
id: "corp-native-1",
name: "Native Seal Corp",
environment: "production",
seal: {
url: "https://seal.example.com",
tenantSlug: "direct-slug",
tenantSlug: "native-slug",
endpoints: {
approvalStylePreferences: "api/v1/agent/ai-approval/config"
}
},
source: {
type: "direct",
token: "bearer-token-direct",
type: "seal",
token: "bearer-token-native",
sealUrl: "https://seal.example.com",
expiresIn: 3600,
staffId: "staff-123",
corpId: "corp-direct-1"
corpId: "corp-native-1"
},
auth: {
refreshTtl: 300
}
};
const session = await getDirectSealSession(corp);
expect(session.token).toBe("bearer-token-direct");
const session = await getNativeSealSession(corp);
expect(session.token).toBe("bearer-token-native");
expect(session.enterprise).toEqual({
provider: "direct",
corpId: "corp-direct-1",
provider: "seal",
corpId: "corp-native-1",
staffId: "staff-123",
sealUrl: "https://seal.example.com",
tenantId: undefined,
tenantSlug: "direct-slug",
tenantSlug: "native-slug",
tenantName: undefined,
raw: {
sourceType: "direct"
sourceType: "seal"
}
});
expect(session.expiresAt).toBeGreaterThan(Date.now());
@@ -62,6 +62,7 @@ describe("getDirectSealSession", () => {
token: "bearer-token-native",
sealUrl: "https://tenant.sealai.cc",
expiresIn: 7200,
expiresAt: "2026-09-22T05:30:00Z",
staffId: "seal-admin",
tenantId: "tenant-100",
tenantSlug: "tenant-slug",
@@ -72,11 +73,12 @@ describe("getDirectSealSession", () => {
}
};
const session = await getDirectSealSession(corp);
const session = await getNativeSealSession(corp);
expect(session.token).toBe("bearer-token-native");
expect(session.enterprise.provider).toBe("seal");
expect(session.enterprise.tenantId).toBe("tenant-100");
expect(session.enterprise.tenantName).toBe("Tenant 100 Name");
expect(session.expiresAt).toBe(new Date("2026-09-22T05:30:00Z").getTime());
});
test("throws error for unsupported source type", async () => {
@@ -88,6 +90,6 @@ describe("getDirectSealSession", () => {
auth: { refreshTtl: 300 }
} as unknown as CorpConfig;
expect(getDirectSealSession(invalidCorp)).rejects.toThrow("Unsupported Seal source");
expect(getNativeSealSession(invalidCorp)).rejects.toThrow("Unsupported Seal source");
});
});
+30
View File
@@ -0,0 +1,30 @@
import { CorpConfig } from "../config/types.js";
import { SealSession } from "./types.js";
export async function getNativeSealSession(corp: CorpConfig): Promise<SealSession> {
if (corp.source.type !== "seal") {
throw new Error(`Unsupported Seal source: ${corp.source.type}`);
}
const sealUrl = corp.seal.url ?? corp.source.sealUrl;
const expiresAt = corp.source.expiresAt
? new Date(corp.source.expiresAt).getTime()
: Date.now() + corp.source.expiresIn * 1000;
return {
token: corp.source.token,
expiresAt,
enterprise: {
provider: corp.source.provider ?? "seal",
corpId: corp.source.corpId ?? corp.id,
staffId: corp.source.staffId,
sealUrl,
tenantId: corp.source.tenantId,
tenantSlug: corp.seal.tenantSlug ?? corp.source.tenantSlug,
tenantName: corp.source.tenantName,
raw: {
sourceType: corp.source.type
}
}
};
}
+2 -3
View File
@@ -1,5 +1,5 @@
import { CorpConfig } from "../config/types.js";
import { getDirectSealSession } from "./direct.js";
import { getNativeSealSession } from "./native.js";
import { getHoseSealSession } from "./hose.js";
import { clearSealSession, getSealSession, setSealSession } from "./token-store.js";
import { SealEnterpriseConfig, SealSession } from "./types.js";
@@ -14,9 +14,8 @@ async function refreshSealSession(corp: CorpConfig): Promise<SealSession> {
switch (corp.source.type) {
case "hose":
return getHoseSealSession(corp);
case "direct":
case "seal":
return getDirectSealSession(corp);
return getNativeSealSession(corp);
}
}
+2 -2
View File
@@ -66,7 +66,7 @@ describe("token-store", () => {
token: "test-token-123",
expiresAt: Date.now() + 3600_000,
enterprise: {
provider: "direct",
provider: "seal",
corpId: "corp-1",
staffId: "staff-1",
sealUrl: "https://seal.example.com"
@@ -108,7 +108,7 @@ describe("token-store", () => {
token: "legacy-token-456",
expiresAt: Date.now() + 3600_000,
enterprise: {
provider: "direct",
provider: "seal",
corpId: "corp-legacy",
staffId: "staff-legacy",
sealUrl: "https://seal.example.com"
+3 -3
View File
@@ -55,7 +55,7 @@ describe("loadCorpConfigs", () => {
id: "direct",
name: "Direct",
source: {
type: "direct",
type: "seal",
token: "seal-token",
sealUrl: "https://direct.sealai.cc"
}
@@ -70,7 +70,7 @@ describe("loadCorpConfigs", () => {
id: "direct-use",
name: "Direct Use",
source: {
type: "direct",
type: "seal",
token: "seal-token",
sealUrl: "https://direct.sealai.cc"
}
@@ -233,7 +233,7 @@ function writeCorpConfig(path: string, id: string, name: string) {
id,
name,
source: {
type: "direct",
type: "seal",
token: "seal-token",
sealUrl: `https://${id}.sealai.cc`
}
+1 -1
View File
@@ -13,7 +13,7 @@ function corp(id: string, name = id): CorpConfig {
}
},
source: {
type: "direct",
type: "seal",
token: `${id}-token`,
sealUrl: `https://${id}.seal.test`,
expiresIn: 3600,
+32
View File
@@ -0,0 +1,32 @@
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { resolveWritableEnterprisesDir } from "./loader.js";
import { CorpConfigSchema, type CorpConfig } from "./types.js";
export type SavedCorpConfig = {
config: CorpConfig;
path: string;
};
function safeCorpFileName(value: string): string {
const normalized = value.trim().replace(/[^a-zA-Z0-9._-]+/g, "-");
return normalized.replace(/^-+|-+$/g, "") || "enterprise";
}
/** Persist one validated enterprise config without coupling callers to CLI code. */
export function saveCorpConfig(
input: CorpConfig,
options: { overwrite?: boolean } = {}
): SavedCorpConfig {
const config = CorpConfigSchema.parse(input);
const enterprisesDir = resolveWritableEnterprisesDir();
mkdirSync(enterprisesDir, { recursive: true, mode: 0o700 });
const path = join(enterprisesDir, `${safeCorpFileName(config.id)}.json`);
if (existsSync(path) && options.overwrite !== true) {
throw new Error(`Enterprise config already exists: ${path}. Pass "overwrite": true to replace it.`);
}
writeFileSync(path, `${JSON.stringify(config, null, 2)}\n`, { mode: 0o600 });
return { config, path };
}
+11
View File
@@ -0,0 +1,11 @@
/** Render an ISO timestamp at UTC-second precision for persisted config. */
export function formatUtcTimestampSeconds(timestampMs: number): string {
return new Date(timestampMs).toISOString().replace(/\.\d{3}Z$/, "Z");
}
/** Normalize caller-provided ISO timestamps while retaining UTC semantics. */
export function normalizeUtcTimestampSeconds(value: string): string {
const parsed = new Date(value);
if (Number.isNaN(parsed.getTime())) return value;
return formatUtcTimestampSeconds(parsed.getTime());
}
+45 -18
View File
@@ -45,22 +45,49 @@ describe("CorpConfigSchema", () => {
expect(result.success).toBe(false);
});
test("accepts direct Seal bearer source", () => {
test("accepts a Hose web session with closeToken and staffId", () => {
const config = CorpConfigSchema.parse({
id: "direct",
name: "Direct",
id: "hose-web",
name: "Hose Web Session",
source: {
type: "direct",
token: "seal-token",
sealUrl: "https://direct.sealai.cc"
type: "hose",
provider: "hosecloud",
domain: "https://wx2.ekuaibao.com",
closeToken: "hose-close-token",
expiresIn: 1800,
expiresAt: "2026-09-22T05:30:00Z",
corpId: "corp-1",
staffId: "corp-1:staff-1"
}
});
expect(config.source.type).toBe("direct");
if (config.source.type !== "direct") {
throw new Error("expected direct source");
expect(config.source.type).toBe("hose");
if (config.source.type !== "hose") {
throw new Error("expected hose source");
}
expect(config.source.closeToken).toBe("hose-close-token");
expect(config.source.staffId).toBe("corp-1:staff-1");
expect(config.source.expiresAt).toBe("2026-09-22T05:30:00Z");
});
test("accepts Seal Bearer source with expiry metadata", () => {
const config = CorpConfigSchema.parse({
id: "seal",
name: "Seal",
source: {
type: "seal",
token: "seal-token",
sealUrl: "https://seal.sealai.cc",
expiresAt: "2026-09-22T05:30:00Z"
}
});
expect(config.source.type).toBe("seal");
if (config.source.type !== "seal") {
throw new Error("expected seal source");
}
expect(config.source.expiresIn).toBe(3600);
expect(config.source.expiresAt).toBe("2026-09-22T05:30:00Z");
});
test("accepts native Seal bearer source", () => {
@@ -86,12 +113,12 @@ describe("CorpConfigSchema", () => {
test("leaves custom headers and cookies absent by default", () => {
const config = CorpConfigSchema.parse({
id: "direct",
name: "Direct",
id: "seal",
name: "Seal",
source: {
type: "direct",
type: "seal",
token: "seal-token",
sealUrl: "https://direct.sealai.cc"
sealUrl: "https://seal.sealai.cc"
}
});
@@ -109,9 +136,9 @@ describe("CorpConfigSchema", () => {
environment: "production",
testCorpId: "test-corp",
source: {
type: "direct",
type: "seal",
token: "seal-token",
sealUrl: "https://direct.sealai.cc"
sealUrl: "https://seal.sealai.cc"
}
});
expect(prodConfig.environment).toBe("production");
@@ -123,9 +150,9 @@ describe("CorpConfigSchema", () => {
environment: "test",
prodCorpId: "prod-corp",
source: {
type: "direct",
type: "seal",
token: "seal-token",
sealUrl: "https://direct.sealai.cc"
sealUrl: "https://seal.sealai.cc"
}
});
expect(testConfig.environment).toBe("test");
@@ -142,7 +169,7 @@ describe("CorpConfigSchema", () => {
cookies: { sdp_app_session_20142: "abc" }
},
source: {
type: "direct",
type: "seal",
token: "seal-token",
sealUrl: "https://gated.sealai.cc"
}
+14 -15
View File
@@ -1,47 +1,48 @@
import { z } from "zod";
const UtcSecondTimestampSchema = z.string().regex(
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/,
"Timestamp must be an ISO 8601 UTC timestamp without milliseconds"
);
export const HoseSealSourceSchema = z.object({
type: z.literal("hose"),
provider: z.string().optional(),
domain: z.string().url().default("https://app.ekuaibao.com"),
appKey: z.string().optional(),
appSecurity: z.string().optional(),
key: z.string().optional(),
password: z.string().optional(),
closeToken: z.string().optional(),
expiresIn: z.number().int().positive().optional(),
expiresAt: UtcSecondTimestampSchema.optional(),
staffId: z.string(),
corpId: z.string(),
sealUrl: z.string().url().optional()
}).superRefine((source, ctx) => {
if (!source.appKey && !source.key) {
if (!source.closeToken && !source.appKey && !source.key) {
ctx.addIssue({
code: "custom",
path: ["appKey"],
message: "Hose source requires appKey or key"
message: "Hose source requires appKey/key or closeToken"
});
}
if (!source.appSecurity && !source.password) {
if (!source.closeToken && !source.appSecurity && !source.password) {
ctx.addIssue({
code: "custom",
path: ["appSecurity"],
message: "Hose source requires appSecurity or password"
message: "Hose source requires appSecurity/password or closeToken"
});
}
});
export const DirectSealSourceSchema = z.object({
type: z.literal("direct"),
token: z.string(),
sealUrl: z.string().url(),
expiresIn: z.number().int().positive().default(3600),
staffId: z.string().default("direct"),
corpId: z.string().optional()
});
export const NativeSealSourceSchema = z.object({
type: z.literal("seal"),
token: z.string(),
sealUrl: z.string().url(),
expiresIn: z.number().int().positive().default(3600),
expiresAt: UtcSecondTimestampSchema.optional(),
staffId: z.string().default("seal"),
corpId: z.string().optional(),
tenantId: z.string().optional(),
@@ -54,7 +55,6 @@ export const NativeSealSourceSchema = z.object({
export const SealSourceSchema = z.discriminatedUnion("type", [
HoseSealSourceSchema,
DirectSealSourceSchema,
NativeSealSourceSchema
]);
@@ -137,7 +137,6 @@ export const GlobalConfigSchema = z.object({
export type CorpEnvironment = z.infer<typeof CorpEnvironmentSchema>;
export type HoseSealSource = z.infer<typeof HoseSealSourceSchema>;
export type DirectSealSource = z.infer<typeof DirectSealSourceSchema>;
export type NativeSealSource = z.infer<typeof NativeSealSourceSchema>;
export type SealSource = z.infer<typeof SealSourceSchema>;
export type CorpAuthConfig = z.infer<typeof CorpAuthConfigSchema>;
+1 -1
View File
@@ -258,7 +258,7 @@ export function diagnoseSystem(): DoctorDiagnosis {
id: "enterprises",
title: "企业接入状态",
status: "warn",
message: "当前未检测到企业配置,请使用 seal-use corps add-hose 或 add-seal 接入企业"
message: "当前未检测到企业配置,请使用 seal-use corps add-hose-persistent、add-hose-web-session 或 add-seal-bearer 接入企业"
});
}
+1 -1
View File
@@ -21,7 +21,7 @@ function makeCorp(id: string, name: string, overrides: Partial<CorpConfig> = {})
}
},
source: {
type: "direct",
type: "seal",
token: `${id}-token`,
sealUrl: `https://${id}.seal.test`,
expiresIn: 3600,
+18
View File
@@ -90,6 +90,24 @@ describe("update-cache", () => {
expect(typeof loaded?.checkedAt).toBe("string");
});
test("normalizes checkedAt to UTC seconds and removes legacy milliseconds", () => {
saveUpdateCache(
{
checkedAt: "2026-09-22T04:56:06.777Z",
latestVersion: "0.10.37"
},
testCacheFile
);
expect(loadUpdateCache(testCacheFile)?.checkedAt).toBe("2026-09-22T04:56:06Z");
writeFileSync(
testCacheFile,
JSON.stringify({ checkedAt: "2026-09-22T04:56:06.123Z", latestVersion: "0.10.37" })
);
expect(loadUpdateCache(testCacheFile)?.checkedAt).toBe("2026-09-22T04:56:06Z");
});
test("isUpdateCacheExpired detects null, missing checkedAt, and expired timestamps", () => {
expect(isUpdateCacheExpired(null)).toBe(true);
expect(isUpdateCacheExpired({ latestVersion: "1.0.0", checkedAt: "invalid" })).toBe(true);
+9 -2
View File
@@ -9,6 +9,10 @@ export const DEFAULT_UPDATE_CACHE_TTL_MS = 24 * 60 * 60 * 1000; // 24 hours
const DEFAULT_UPDATE_CACHE_FILE = join(homedir(), ".config", "seal-use", "update-cache.json");
function normalizeTimestampToSeconds(timestamp: string): string {
return timestamp.replace(/\.\d+Z$/, "Z");
}
export interface UpdateCacheData {
checkedAt: string;
latestVersion: string;
@@ -35,7 +39,10 @@ export function loadUpdateCache(filePath = resolveUpdateCacheFilePath()): Update
typeof parsed.latestVersion === "string" &&
typeof parsed.checkedAt === "string"
) {
return parsed as UpdateCacheData;
return {
...parsed,
checkedAt: normalizeTimestampToSeconds(parsed.checkedAt)
} as UpdateCacheData;
}
return null;
} catch {
@@ -52,7 +59,7 @@ export function saveUpdateCache(
mkdirSync(dir, { recursive: true, mode: 0o700 });
const payload: UpdateCacheData = {
checkedAt: data.checkedAt ?? new Date().toISOString(),
checkedAt: normalizeTimestampToSeconds(data.checkedAt ?? new Date().toISOString()),
latestVersion: data.latestVersion,
publishedAt: data.publishedAt,
releaseUrl: data.releaseUrl
+67
View File
@@ -0,0 +1,67 @@
import {
exchangeSealDelegateLink,
parseSealDelegateLink,
previewSealDelegateLink,
scoreAssistLink
} from "../../core/auth/delegate.js";
import { parseHoseAssistLink } from "../../core/auth/hose.js";
import { onboardHoseWebSession } from "../hose/onboarding.js";
import { persistSealDelegateSession } from "../seal/onboarding.js";
export type AssistanceLinkOnboardingInput = {
name?: string;
overwrite?: boolean;
dryRun?: boolean;
};
export async function onboardAssistanceLink(link: string, input: AssistanceLinkOnboardingInput = {}) {
const winner = scoreAssistLink(link)[0];
if (!winner || winner.score < 50) {
throw new Error(
"Unrecognized assistance/delegate link. Expected either a Seal native delegate link " +
"(https://<tenant>.sealai.cc/delegate?token=...) or a Hose assistance link " +
"(https://<corp>.ekuaibao.com/web/thirdparty.html?accessToken=...&ekbCorpId=...). " +
`Top score: ${winner ? `${winner.kind}=${winner.score}` : "none"}.`
);
}
if (winner.kind === "seal-delegate") {
if (input.dryRun) {
const preview = await previewSealDelegateLink(link);
const parsed = parseSealDelegateLink(link);
return {
kind: "seal-delegate" as const,
dryRun: true as const,
sealUrl: parsed.sealUrl,
tenant: { id: preview.tenantId, name: preview.tenantName },
user: { id: preview.userId, name: preview.userName },
delegationId: preview.delegationId
};
}
const session = await exchangeSealDelegateLink(link);
const saved = persistSealDelegateSession({
name: input.name,
overwrite: input.overwrite,
session: {
token: session.token,
sealUrl: session.sealUrl,
expiresIn: session.expiresIn,
user: session.user,
tenant: session.tenant
}
});
return { kind: "seal-delegate" as const, dryRun: false as const, saved };
}
const hoseLink = parseHoseAssistLink(link);
const result = await onboardHoseWebSession({
corpId: hoseLink.corpId,
accessToken: hoseLink.accessToken,
baseUrl: hoseLink.baseUrl,
name: input.name,
overwrite: input.overwrite,
persist: !input.dryRun
});
return { kind: "hose" as const, dryRun: input.dryRun === true, result };
}
+1 -1
View File
@@ -467,7 +467,7 @@ describe("Hose Flow Domain", () => {
name: "Direct Corp",
environment: "production",
source: {
type: "direct",
type: "seal",
token: "tok",
sealUrl: "https://test.sealai.cc",
expiresIn: 3600,
+110
View File
@@ -0,0 +1,110 @@
import {
fetchHoseOpenApiKeysFromLink,
maskHoseSecurity,
type HoseOpenApiKey
} from "../../core/auth/hose.js";
import { onboardHosePersistent } from "./onboarding.js";
export class HoseKeySelectionError extends Error {
readonly nextAction: string;
constructor(message: string, nextAction: string) {
super(message);
this.name = "HoseKeySelectionError";
this.nextAction = nextAction;
}
}
export function selectHoseOpenApiKey(
keys: HoseOpenApiKey[],
corpId: string,
selection: { appKey?: string; keyId?: string },
contextCmd: string
): HoseOpenApiKey {
if (keys.length === 0) {
throw new HoseKeySelectionError(
`[合思子域提权] 未能从协助链接中提取到合思企业 [${corpId}] 的 OpenAPI 密钥凭据。\n` +
"💡 说明:此能力专属于合思 (Hose) 子域,用于将临时会话提权为标准 OpenAPI 开发者接入。需要企业管理员已在合思开放平台创建应用并生成 appKey/appSecurity。",
contextCmd
);
}
if (selection.keyId || selection.appKey) {
const matched = keys.find((key) => (selection.keyId && key.id === selection.keyId) || (selection.appKey && key.appKey === selection.appKey));
if (!matched) {
throw new HoseKeySelectionError(
`指定的合思密钥不存在,请从上述候选列表中选择正确的 appKey 或 keyId。\n` +
`当前企业存在以下 ${keys.length} 套候选密钥:\n` +
keys.map((key) => ` • "${key.name || "未命名应用"}" (appKey: ${key.appKey}, keyId: ${key.id}, 状态: ${key.active ? "🟢 启用" : "⚪ 停用"})`).join("\n"),
`${contextCmd} --app-key ${keys[0]!.appKey}`
);
}
return matched;
}
if (keys.length === 1) return keys[0]!;
throw new HoseKeySelectionError(
`
ℹ️ [合思子域提权] 合思企业 [${corpId}] 存在多套 (${keys.length} 套) OpenAPI 应用密钥凭据:
${keys.map((key, index) => ` [${index + 1}] "${key.name || "未命名应用"}" (appKey: ${key.appKey}, keyId: ${key.id}, 状态: ${key.active ? "🟢 启用" : "⚪ 停用"})`).join("\n")}
👉 为确保权限提权绑定正确的业务应用,请显式指定要使用的密钥套件:
在命令后追加 --app-key <key> 或 --key-id <id> 参数。
`,
`${contextCmd} --app-key ${keys[0]!.appKey}`
);
}
export type HoseKeyLinkOptions = {
link: string;
appKey?: string;
keyId?: string;
name?: string;
overwrite?: boolean;
force?: boolean;
dryRun?: boolean;
};
export async function elevateHoseLink(options: HoseKeyLinkOptions) {
const result = await fetchHoseOpenApiKeysFromLink(options.link);
const selectedKey = selectHoseOpenApiKey(result.keys, result.corpId, options, `seal-use corps add-link "<url>" --elevate-hose`);
if (options.dryRun) return { result, selectedKey, dryRun: true as const };
const saved = await onboardHosePersistent({
domain: result.baseUrl,
appKey: selectedKey.appKey,
appSecurity: selectedKey.appSecurity,
corpId: result.corpId,
name: options.name ?? result.corpName,
staffId: result.staffId,
overwrite: options.overwrite,
force: options.force
});
return { result, selectedKey, saved, dryRun: false as const };
}
export async function extractHoseKeysFromLink(options: HoseKeyLinkOptions & { save?: boolean; reveal?: boolean }) {
const result = await fetchHoseOpenApiKeysFromLink(options.link);
if (!options.save) return { result, reveal: options.reveal === true };
const selectedKey = selectHoseOpenApiKey(result.keys, result.corpId, options, `seal-use corps hose-extract-keys "<url>" --save`);
const saved = await onboardHosePersistent({
domain: result.baseUrl,
appKey: selectedKey.appKey,
appSecurity: selectedKey.appSecurity,
corpId: result.corpId,
name: options.name ?? result.corpName,
staffId: result.staffId,
overwrite: options.overwrite,
force: options.force
});
return { result, selectedKey, saved, reveal: options.reveal === true };
}
export function formatHoseKeyForOutput(key: HoseOpenApiKey, reveal: boolean) {
return {
id: key.id,
name: key.name || "-",
appKey: key.appKey,
appSecurity: reveal ? key.appSecurity : maskHoseSecurity(key.appSecurity),
active: key.active,
createTime: key.createTime,
updateTime: key.updateTime
};
}
+291
View File
@@ -0,0 +1,291 @@
import { clearCorpTokenCache } from "../../core/auth/token-store.js";
import {
assertHoseAssistTenantMatches,
exchangeHoseAssistLink,
fetchHoseRoleDefGroups,
fetchHoseRoleStaffs,
fetchHoseStaffDetails,
probeHoseDomain,
resolveHoseAssistLinkDetails
} from "../../core/auth/hose.js";
import { createSealClientForUrl } from "../../core/http/factory.js";
import { saveCorpConfig, type SavedCorpConfig } from "../../core/config/repository.js";
import { normalizeUtcTimestampSeconds } from "../../core/config/timestamps.js";
import type { CorpConfig } from "../../core/config/types.js";
import { getMe } from "../seal/api.js";
import { resolveLiveSealEnterpriseConfig } from "../seal/source.js";
export type HosePersistentInput = {
id?: string;
name?: string;
appKey: string;
appSecurity: string;
domain?: string;
corpId?: string;
corporationId?: string;
staffId?: string;
proxyStaffBizId?: string;
staffName?: string;
staffPhone?: string;
role?: string;
force?: boolean;
verify?: boolean;
sealUrl?: string;
overwrite?: boolean;
};
export type HoseWebSessionInput = {
name?: string;
baseUrl?: string;
domain?: string;
corpId: string;
accessToken: string;
staffId?: string;
expiresIn?: number;
expiresAt?: string;
overwrite?: boolean;
persist?: boolean;
};
export type HoseProbeResult = Awaited<ReturnType<typeof probeHoseDomain>> & {
roleCount: number;
roleGroups: Array<{
id: string;
name: string;
roleDefs: Array<{ id: string; name: string; sourceType?: string }>;
}>;
};
export async function probeHoseEnterprise(input: {
appKey: string;
appSecurity: string;
domain?: string;
}): Promise<HoseProbeResult> {
const probe = await probeHoseDomain(input.appKey, input.appSecurity, input.domain);
const roleGroups = await fetchHoseRoleDefGroups(probe.domain, probe.openapiToken).catch(() => []);
return {
...probe,
roleCount: roleGroups.reduce((total, group) => total + group.roleDefs.length, 0),
roleGroups: roleGroups.map((group) => ({
id: group.id,
name: group.name,
roleDefs: group.roleDefs.map((role) => ({
id: role.id,
name: role.name,
sourceType: role.sourceType
}))
}))
};
}
export async function listHoseStaffs(input: {
appKey: string;
appSecurity: string;
domain?: string;
role?: string;
roleDefId?: string;
}) {
const probe = await probeHoseDomain(input.appKey, input.appSecurity, input.domain);
const roleQuery = input.role ?? input.roleDefId ?? "admin";
const roleGroups = await fetchHoseRoleDefGroups(probe.domain, probe.openapiToken);
let targetRoleDefId: string | undefined;
let targetRoleName: string | undefined;
for (const group of roleGroups) {
for (const role of group.roleDefs) {
if (role.id === roleQuery || role.id === `${probe.corpId}:${roleQuery}`) {
targetRoleDefId = role.id;
targetRoleName = role.name;
break;
}
}
if (targetRoleDefId) break;
}
if (!targetRoleDefId && (roleQuery === "admin" || roleQuery === "主管理员")) {
for (const group of roleGroups) {
for (const role of group.roleDefs) {
if (role.id.endsWith(":admin") || role.name === "主管理员") {
targetRoleDefId = role.id;
targetRoleName = role.name;
break;
}
}
if (targetRoleDefId) break;
}
}
if (!targetRoleDefId) {
for (const group of roleGroups) {
for (const role of group.roleDefs) {
if (role.name.toLowerCase().includes(roleQuery.toLowerCase())) {
targetRoleDefId = role.id;
targetRoleName = role.name;
break;
}
}
if (targetRoleDefId) break;
}
}
if (!targetRoleDefId) {
throw new Error(`Role not found matching query: '${roleQuery}'. Run 'seal-use corps probe-hose' to view all available roles.`);
}
const roleStaffs = await fetchHoseRoleStaffs(probe.domain, probe.openapiToken, targetRoleDefId);
const staffs = await fetchHoseStaffDetails(probe.domain, probe.openapiToken, roleStaffs.staffs);
return {
domain: probe.domain,
corpId: probe.corpId,
corpName: probe.corpName ?? probe.corpId,
roleId: targetRoleDefId,
roleName: targetRoleName,
staffs
};
}
export async function onboardHosePersistent(input: HosePersistentInput): Promise<SavedCorpConfig & { verified: boolean; domain: string; staffId: string }> {
const explicitDomain = input.domain;
const explicitStaffId = input.staffId ?? input.proxyStaffBizId;
const force = input.force === true;
const verify = force || input.verify === false ? false : true;
let domain = explicitDomain;
let corpId = input.corpId ?? input.corporationId;
let corpName = input.name;
let openapiToken: string | undefined;
if (!domain || !corpId || !explicitStaffId) {
const probe = await probeHoseDomain(input.appKey, input.appSecurity, explicitDomain);
domain = probe.domain;
corpId = corpId ?? probe.corpId;
corpName = corpName ?? probe.corpName;
openapiToken = probe.openapiToken;
}
let finalStaffId = explicitStaffId;
if (!finalStaffId && openapiToken && domain) {
const roleQuery = input.role ?? "admin";
const roleGroups = await fetchHoseRoleDefGroups(domain, openapiToken).catch(() => []);
let targetRoleId: string | undefined;
for (const group of roleGroups) {
for (const role of group.roleDefs) {
if (role.id.endsWith(`:${roleQuery}`) || role.name === roleQuery || role.id === roleQuery) {
targetRoleId = role.id;
break;
}
}
if (targetRoleId) break;
}
if (!targetRoleId) {
targetRoleId = roleGroups.find((group) => group.roleDefs.some((role) => role.id.endsWith(":admin")))
?.roleDefs.find((role) => role.id.endsWith(":admin"))?.id;
}
if (targetRoleId) {
const roleStaffs = await fetchHoseRoleStaffs(domain, openapiToken, targetRoleId).catch(() => ({ staffs: [] }));
const staffDetails = await fetchHoseStaffDetails(domain, openapiToken, roleStaffs.staffs).catch(() => []);
if (input.staffName || input.staffPhone) {
const matches = staffDetails.filter((staff) => {
if (input.staffName && staff.name !== input.staffName && !staff.name.includes(input.staffName)) return false;
if (input.staffPhone && (!staff.cellphone || !staff.cellphone.includes(input.staffPhone))) return false;
return true;
});
if (matches.length === 1 && matches[0]) finalStaffId = matches[0].id;
else if (matches.length > 1) {
throw new Error(`Multiple staff members matched '${input.staffName ?? input.staffPhone}': ${matches.map((staff) => `${staff.name}(${staff.id})`).join(", ")}. Please specify exact staffId.`);
} else {
throw new Error(`No staff member found matching '${input.staffName ?? input.staffPhone}' under role ${targetRoleId}. Run 'seal-use corps hose-staffs' to view candidates.`);
}
} else if (!force) {
const candidates = staffDetails.map((staff) => ({ id: staff.id, name: staff.name, cellphone: staff.cellphone, active: staff.active }));
throw new Error(`Missing required parameter: staffId. Candidates: ${JSON.stringify(candidates)}`);
} else {
finalStaffId = staffDetails.find((staff) => staff.active)?.id ?? staffDetails[0]?.id;
}
}
}
if (!finalStaffId) {
if (!verify && explicitStaffId) finalStaffId = explicitStaffId;
else throw new Error("Missing required parameter: staffId (or proxyStaffBizId). Run 'seal-use corps hose-staffs' to discover available administrators.");
}
if (!corpId || !domain) throw new Error("Unable to resolve Hose corporation or domain");
const id = input.id ?? corpId;
const config: CorpConfig = {
id,
name: input.name ?? corpName ?? corpId,
environment: "production",
seal: {
url: input.sealUrl ?? `https://${corpId.toLowerCase()}.sealai.cc`,
endpoints: { approvalStylePreferences: "api/v1/agent/ai-approval/config" }
},
source: {
type: "hose",
domain,
appKey: input.appKey,
appSecurity: input.appSecurity,
corpId,
staffId: finalStaffId
},
auth: { refreshTtl: 300 }
};
let finalConfig = config;
if (verify) {
clearCorpTokenCache(id);
const live = await resolveLiveSealEnterpriseConfig(config);
if ((!input.name || input.name === corpId) && live.tenantName && live.tenantName !== corpId) {
finalConfig = { ...config, name: live.tenantName };
}
}
const saved = saveCorpConfig(finalConfig, { overwrite: input.overwrite });
return { ...saved, verified: verify, domain, staffId: finalStaffId };
}
export async function onboardHoseWebSession(input: HoseWebSessionInput) {
const baseUrl = input.baseUrl ?? input.domain;
const details = await resolveHoseAssistLinkDetails({
corpId: input.corpId,
accessToken: input.accessToken,
baseUrl
});
const session = await exchangeHoseAssistLink({
corpId: input.corpId,
accessToken: input.accessToken,
baseUrl
});
const me = await getMe(createSealClientForUrl(session.sealUrl, session.token));
const identity = {
user: me.user as unknown as Record<string, unknown>,
tenant: me.tenant as unknown as Record<string, unknown>
};
assertHoseAssistTenantMatches(session.corpId, identity.tenant);
const staffId = input.staffId ?? details.staffId;
const tenantSlug = typeof identity.tenant.tenantSlug === "string" ? identity.tenant.tenantSlug : input.corpId;
const config: CorpConfig = {
id: session.corpId,
name: input.name ?? details.corpName ?? session.corpId,
environment: "production",
seal: {
url: session.sealUrl,
tenantSlug,
endpoints: { approvalStylePreferences: "api/v1/agent/ai-approval/config" }
},
source: {
type: "hose",
provider: "hosecloud",
domain: details.baseUrl,
closeToken: input.accessToken,
...(input.expiresIn !== undefined ? { expiresIn: input.expiresIn } : {}),
...(input.expiresAt ? { expiresAt: normalizeUtcTimestampSeconds(input.expiresAt) } : {}),
staffId,
corpId: session.corpId,
sealUrl: session.sealUrl
},
auth: { refreshTtl: 300 }
};
const saved = input.persist === false ? undefined : saveCorpConfig(config, { overwrite: input.overwrite });
return { config, ...(saved ?? {}), session, identity, staffId };
}
@@ -199,7 +199,7 @@ describe("exportApprovalRunsToExcel integration", () => {
}
},
source: {
type: "direct",
type: "seal",
token: "test-token",
sealUrl: "https://mock.sealai.cc",
expiresIn: 3600,
+3 -3
View File
@@ -110,7 +110,7 @@ describe("insight-export domain", () => {
tenantSlug: "test"
},
source: {
type: "direct",
type: "seal",
token: "fake-token",
sealUrl: "https://seal.example.com"
}
@@ -170,7 +170,7 @@ describe("insight-export domain", () => {
}
},
source: {
type: "direct",
type: "seal",
token: "mock-token",
sealUrl: "https://mock.sealai.cc",
expiresIn: 3600,
@@ -199,7 +199,7 @@ describe("insight-export domain", () => {
}
},
source: {
type: "direct",
type: "seal",
token: "mock-token",
sealUrl: "https://mock.sealai.cc",
expiresIn: 3600,
@@ -16,7 +16,7 @@ const mockCorp: CorpConfig = {
name: "测试研发企业",
environment: "test",
source: {
type: "direct",
type: "seal",
token: "mock-token",
sealUrl: "https://seal.example.com",
expiresIn: 3600,
+159
View File
@@ -0,0 +1,159 @@
import { saveCorpConfig, type SavedCorpConfig } from "../../core/config/repository.js";
import { formatUtcTimestampSeconds, normalizeUtcTimestampSeconds } from "../../core/config/timestamps.js";
import {
SealCookieMapSchema,
SealHeaderMapSchema,
type CorpConfig
} from "../../core/config/types.js";
import { createSealClientForUrl } from "../../core/http/factory.js";
import { resolveSealCustomHeaders } from "../../core/http/request-headers.js";
import { getMe } from "./api.js";
export type RemoteSealIdentity = {
user: Record<string, unknown>;
tenant: Record<string, unknown>;
};
export type SealBearerInput = {
id?: string;
name?: string;
token: string;
sealUrl: string;
expiresIn?: number;
expiresAt?: string;
tenantSlug?: string;
tenantId?: string;
tenantName?: string;
corpId?: string;
staffId?: string;
provider?: string;
headers?: unknown;
cookies?: unknown;
force?: boolean;
verify?: boolean;
overwrite?: boolean;
};
export type SealDelegateSession = {
token: string;
sealUrl: string;
expiresIn: number;
user: Record<string, unknown>;
tenant: Record<string, unknown>;
};
function stringValue(value: unknown): string | undefined {
return typeof value === "string" && value ? value : undefined;
}
function resolveCustomHeaders(input: SealBearerInput) {
return {
headers: SealHeaderMapSchema.parse(input.headers),
cookies: SealCookieMapSchema.parse(input.cookies)
};
}
async function resolveSealIdentity(sealUrl: string, token: string, headers: Record<string, string> = {}) {
const me = await getMe(createSealClientForUrl(sealUrl, token, headers));
return {
user: (me.user ?? {}) as Record<string, unknown>,
tenant: (me.tenant ?? {}) as Record<string, unknown>
};
}
export async function onboardSealBearer(input: SealBearerInput): Promise<SavedCorpConfig & { verified: boolean; tenantId?: string; tenantSlug?: string }> {
const sealUrl = input.sealUrl.replace(/\/+$/, "");
const expiresIn = input.expiresIn ?? 30 * 24 * 60 * 60;
const verify = input.force === true || input.verify === false ? false : true;
const custom = resolveCustomHeaders(input);
const remote = verify ? await resolveSealIdentity(sealUrl, input.token, resolveSealCustomHeaders(custom)) : undefined;
const saved = saveSealConfig(input, {
token: input.token,
sealUrl,
expiresIn,
expiresAt: input.expiresAt,
verify,
remote,
custom
});
const tenantId = input.tenantId ?? stringValue(remote?.tenant.id);
const tenantSlug = input.tenantSlug ?? stringValue(remote?.tenant.tenantSlug);
return { ...saved, verified: verify, tenantId, tenantSlug };
}
export function persistSealDelegateSession(input: {
name?: string;
overwrite?: boolean;
session: SealDelegateSession;
}): SavedCorpConfig & { tenantId?: string; tenantSlug?: string } {
const tenantSlug = stringValue(input.session.tenant.tenantSlug);
const tenantId = stringValue(input.session.tenant.id);
const corpId = tenantSlug ?? tenantId ?? "seal-delegate";
const saved = saveSealConfig(
{ id: corpId, corpId, name: input.name, provider: "seal", overwrite: input.overwrite },
{
token: input.session.token,
sealUrl: input.session.sealUrl,
expiresIn: input.session.expiresIn,
verify: true,
remote: { user: input.session.user, tenant: input.session.tenant }
}
);
return { ...saved, tenantId, tenantSlug };
}
function saveSealConfig(
input: Partial<SealBearerInput> & Record<string, unknown>,
auth: {
token: string;
sealUrl: string;
expiresIn: number;
expiresAt?: string;
verify: boolean;
remote?: RemoteSealIdentity;
custom?: { headers?: Record<string, string>; cookies?: Record<string, string> };
}
): SavedCorpConfig {
const remoteUser = auth.remote?.user;
const remoteTenant = auth.remote?.tenant;
const tenantSlug = input.tenantSlug ?? stringValue(remoteTenant?.tenantSlug);
const tenantId = input.tenantId ?? stringValue(remoteTenant?.id);
const tenantName = input.tenantName ?? stringValue(remoteTenant?.name);
const id = input.id ?? tenantSlug ?? tenantId;
if (!id) throw new Error("Missing required JSON field: id. Seal whoami did not return tenantSlug or tenantId.");
const expiresAt = auth.expiresAt
? normalizeUtcTimestampSeconds(auth.expiresAt)
: formatUtcTimestampSeconds(Date.now() + auth.expiresIn * 1000);
const staffId = input.staffId ?? stringValue(remoteUser?.providerUserId) ?? stringValue(remoteUser?.id) ?? "seal";
const provider = input.provider ?? stringValue(remoteUser?.provider) ?? stringValue((remoteTenant as { providerConfig?: { provider?: unknown } } | undefined)?.providerConfig?.provider);
const corpId = input.corpId ?? tenantSlug ?? tenantId ?? id;
const config: CorpConfig = {
id,
name: input.name ?? tenantName ?? id,
environment: "production",
seal: {
url: auth.sealUrl,
tenantSlug,
headers: auth.custom?.headers,
cookies: auth.custom?.cookies,
endpoints: { approvalStylePreferences: "api/v1/agent/ai-approval/config" }
},
source: {
type: "seal",
token: auth.token,
sealUrl: auth.sealUrl,
expiresIn: auth.expiresIn,
expiresAt,
staffId,
corpId,
tenantId,
tenantSlug,
tenantName,
providerUserId: stringValue(remoteUser?.providerUserId),
provider
},
auth: { refreshTtl: 300 }
};
const saved = saveCorpConfig(config, { overwrite: input.overwrite === true });
return saved;
}
+1 -1
View File
@@ -84,7 +84,7 @@ function fakeCorp(): CorpConfig {
}
},
source: {
type: "direct",
type: "seal",
token: "tok",
sealUrl: "https://seal.test",
expiresIn: 3600,
+334
View File
@@ -0,0 +1,334 @@
import { randomBytes } from "node:crypto";
import type { KyInstance } from "ky";
import { createSealClient } from "../../core/http/factory.js";
import type { CorpConfig } from "../../core/config/types.js";
import * as api from "./api.js";
import { computeNextSyncIteration, formatSyncVersionName, saveRuleMappingSnapshot } from "./rule-mapping.js";
import { savePublishedRuleVersionSnapshot } from "./rule-version-snapshot.js";
export type TestSyncOptions = {
versionName?: string;
dryRun?: boolean;
execute?: boolean;
};
export async function syncTestEnterprise(
prodCorp: CorpConfig,
testCorp: CorpConfig,
options: TestSyncOptions = {}
) {
const prodClient = await createSealClient(prodCorp);
const testClient = await createSealClient(testCorp);
const [
prodPref,
testPref,
prodRules,
testRules,
prodVersions,
testVersions,
prodDocsRes,
testDocsRes
] = await Promise.all([
api.getApprovalStylePreferences(prodClient, prodCorp.seal.endpoints.approvalStylePreferences),
api.getApprovalStylePreferences(testClient, testCorp.seal.endpoints.approvalStylePreferences),
api.listApprovalRules(prodClient),
api.listApprovalRules(testClient),
api.listApprovalRuleVersions(prodClient),
api.listApprovalRuleVersions(testClient),
listAllApprovalDocuments(prodClient),
listAllApprovalDocuments(testClient)
]);
const prodDocs = (prodDocsRes.articles || []).filter((doc) => !doc.isDeleted);
const testDocs = (testDocsRes.articles || []).filter((doc) => !doc.isDeleted);
const testDocsByTitle = new Map(testDocs.map((doc) => [doc.title.trim(), doc]));
const docsToCreate: any[] = [];
const docsToUpdate: any[] = [];
const prodTitles = new Set(prodDocs.map((doc) => doc.title.trim()));
for (const prodDoc of prodDocs) {
const title = prodDoc.title.trim();
const existing = testDocsByTitle.get(title);
if (!existing) {
docsToCreate.push(prodDoc);
continue;
}
const reasons = [
["content", existing.content !== prodDoc.content],
["purpose", (existing.purpose ?? "") !== (prodDoc.purpose ?? "")],
["enabled", existing.enabled !== prodDoc.enabled],
["contentType", existing.contentType !== prodDoc.contentType],
["status", (existing.status ?? "") !== (prodDoc.status ?? "")],
["scenarios", JSON.stringify([...(existing.scenarios ?? [])].sort()) !== JSON.stringify([...(prodDoc.scenarios ?? [])].sort())],
["tags", JSON.stringify([...(existing.tags ?? [])].sort()) !== JSON.stringify([...(prodDoc.tags ?? [])].sort())]
].filter(([, changed]) => changed).map(([reason]) => reason as string);
if (reasons.length > 0) docsToUpdate.push({ testId: existing.id, prodDoc, reasons });
}
const docsToDelete = testDocs.filter((doc) => !prodTitles.has(doc.title.trim()));
const sortedProdVersions = [...prodVersions].sort((a, b) => b.versionNumber - a.versionNumber);
const latestProd = sortedProdVersions[0];
const prodVersionNumber = latestProd?.versionNumber;
const sortedTestVersions = [...testVersions].sort((a, b) => b.versionNumber - a.versionNumber);
const targetTestExpectedVersionNumber = (sortedTestVersions[0]?.versionNumber ?? 0) + 1;
const nextIteration = computeNextSyncIteration(prodCorp.name, prodVersionNumber, testVersions);
const versionName = options.versionName ?? formatSyncVersionName(
prodCorp.name,
prodVersionNumber,
nextIteration,
targetTestExpectedVersionNumber
);
const updatedTestPref = {
...testPref,
tone: prodPref.tone,
language: prodPref.language,
detailLevel: prodPref.detailLevel,
outputFormat: prodPref.outputFormat,
examples: prodPref.examples ?? [],
prohibitedPhrases: prodPref.prohibitedPhrases ?? [],
customInstructions: prodPref.customInstructions,
decisionPreferences: prodPref.decisionPreferences,
thinkingDepthPreference: prodPref.thinkingDepthPreference
};
if (options.dryRun || options.execute === false) {
return {
dryRun: true as const,
source: {
id: prodCorp.id,
name: prodCorp.name,
environment: prodCorp.environment,
latestPublishedVersion: latestProd ? { versionNumber: latestProd.versionNumber, versionName: latestProd.versionName } : null,
documentsCount: prodDocs.length
},
target: { id: testCorp.id, name: testCorp.name, environment: testCorp.environment },
versionMappingPlan: {
sourceProdVersionNumber: prodVersionNumber ?? null,
sourceProdVersionName: latestProd?.versionName ?? null,
targetTestExpectedVersionNumber,
targetTestPublishVersionName: versionName,
iteration: nextIteration
},
preferencesDiff: {
decisionPreferences: { before: testPref.decisionPreferences, after: prodPref.decisionPreferences },
thinkingDepthPreference: { before: testPref.thinkingDepthPreference, after: prodPref.thinkingDepthPreference }
},
rulesPlan: {
sourceDraftRuleCount: prodRules.rules.length,
targetExistingDraftRuleCount: testRules.rules.length,
toDeleteCount: testRules.rules.length,
toCreateCount: prodRules.rules.length,
rulesToSync: prodRules.rules.map((rule, index) => ({
index: index + 1,
sourceRuleId: rule.id,
sourceRuleCode: rule.code ?? index + 1,
expectedTargetCode: `rule-${index + 1}`,
description: rule.description,
scope: rule.scope,
strictness: rule.strictness
}))
},
documentsPlan: {
sourceDocumentCount: prodDocs.length,
targetExistingDocumentCount: testDocs.length,
toCreateCount: docsToCreate.length,
toCreate: docsToCreate.map((doc) => ({ title: doc.title, purpose: doc.purpose, contentType: doc.contentType, scenarios: doc.scenarios })),
toUpdateCount: docsToUpdate.length,
toUpdate: docsToUpdate.map((item) => ({ targetDocumentId: item.testId, title: item.prodDoc.title, reasons: item.reasons })),
toDeleteCount: docsToDelete.length,
toDelete: docsToDelete.map((doc) => ({ targetDocumentId: doc.id, title: doc.title }))
},
publishingPlan: { targetCorpId: testCorp.id, publishVersionName: versionName, publishTarget: "test" },
hosecloudSyncPlan: buildHosecloudSyncPlan(prodCorp, prodPref),
productionGuarantees: { prodRulesStayDraft: true, prodVersionPublished: false }
};
}
await api.updateApprovalStylePreferences(testClient, updatedTestPref, testCorp.seal.endpoints.approvalStylePreferences);
const deletedDocs: Array<{ id: string; title: string }> = [];
for (const doc of docsToDelete) {
await api.deleteApprovalDocument(testClient, doc.id);
deletedDocs.push({ id: doc.id, title: doc.title });
}
const updatedDocs: Array<{ id: string; title: string; reasons: string[] }> = [];
for (const item of docsToUpdate) {
await api.updateApprovalDocument(testClient, item.testId, {
title: item.prodDoc.title,
purpose: item.prodDoc.purpose,
content: item.prodDoc.content,
contentType: item.prodDoc.contentType,
status: item.prodDoc.status,
enabled: item.prodDoc.enabled,
scenarios: item.prodDoc.scenarios && item.prodDoc.scenarios.length > 0 ? item.prodDoc.scenarios : ["audit"],
tags: item.prodDoc.tags
});
updatedDocs.push({ id: item.testId, title: item.prodDoc.title, reasons: item.reasons });
}
const createdDocs: Array<{ id: string; title: string }> = [];
for (const doc of docsToCreate) {
const created = await api.createApprovalDocument(testClient, {
title: doc.title,
purpose: doc.purpose,
content: doc.content,
contentType: doc.contentType,
status: doc.status,
enabled: doc.enabled,
scenarios: doc.scenarios && doc.scenarios.length > 0 ? doc.scenarios : ["audit"],
tags: doc.tags
});
createdDocs.push({ id: created.id, title: created.title });
}
for (const rule of testRules.rules) await api.deleteApprovalRule(testClient, rule.id);
const createdRules: any[] = [];
for (const rule of prodRules.rules) {
createdRules.push(await api.createApprovalRule(testClient, {
description: rule.description,
scope: rule.scope,
strictness: rule.strictness
}));
}
const recodeResult = await api.recodeApprovalRules(testClient) as { ok: boolean; status: number };
if (!recodeResult.ok) throw new Error(`Failed to recode test approval rules: HTTP ${recodeResult.status}`);
const hosecloudSync = await syncHosecloudIntegrationsToTest(prodCorp, testCorp, prodClient, testClient);
const published = await api.publishApprovalRuleVersion(testClient, versionName);
try { savePublishedRuleVersionSnapshot(testCorp.id, published.version, createdRules); } catch {}
const publishedRules = published.version.rules ?? [];
const ruleMapping = prodRules.rules.map((prodRule, index) => ({
index: index + 1,
sourceRuleId: prodRule.id,
sourceRuleCode: prodRule.code ?? index + 1,
targetRuleId: createdRules[index]?.id ?? "",
targetRuleCode: publishedRules[index]?.code ?? `rule-${index + 1}`,
description: prodRule.description,
scope: prodRule.scope,
strictness: prodRule.strictness
}));
const versionMapping = {
sourceProdVersionNumber: prodVersionNumber ?? null,
sourceProdVersionName: latestProd?.versionName ?? null,
targetTestVersionNumber: published.version.versionNumber,
targetTestVersionName: published.version.versionName ?? null
};
let mappingSavedTo: string | undefined;
try {
mappingSavedTo = saveRuleMappingSnapshot({
syncedAt: new Date().toISOString(),
source: { id: prodCorp.id, name: prodCorp.name, latestPublishedVersionNumber: prodVersionNumber ?? null, latestPublishedVersionName: latestProd?.versionName ?? null },
target: { id: testCorp.id, name: testCorp.name, publishedVersionNumber: published.version.versionNumber, publishedVersionName: published.version.versionName, rulesCount: published.rulesCount },
versionMapping,
ruleMapping
});
} catch {}
return {
success: true as const,
syncedAt: new Date().toISOString(),
source: {
id: prodCorp.id,
name: prodCorp.name,
environment: prodCorp.environment,
latestPublishedVersion: latestProd ? { versionNumber: latestProd.versionNumber, versionName: latestProd.versionName } : null,
draftRulesCount: prodRules.rules.length,
documentsCount: prodDocs.length
},
target: {
id: testCorp.id,
name: testCorp.name,
environment: testCorp.environment,
deletedDraftRulesCount: testRules.rules.length,
createdDraftRulesCount: createdRules.length,
publishedVersion: { id: published.version.id, versionNumber: published.version.versionNumber, versionName: published.version.versionName, rulesCount: published.rulesCount }
},
documents: { sourceCount: prodDocs.length, targetExistingCount: testDocs.length, createdCount: createdDocs.length, created: createdDocs, updatedCount: updatedDocs.length, updated: updatedDocs, deletedCount: deletedDocs.length, deleted: deletedDocs },
versionMapping,
ruleMapping,
...(mappingSavedTo ? { mappingSavedTo } : {}),
hosecloudSync,
productionGuarantees: { prodRulesStayDraft: true, prodVersionPublished: false }
};
}
async function listAllApprovalDocuments(client: KyInstance) {
const pageSize = 100;
const documents: Awaited<ReturnType<typeof api.listApprovalDocuments>>["articles"] = [];
let offset = 0;
while (true) {
const page = await api.listApprovalDocuments(client, { offset, limit: pageSize });
documents.push(...page.articles);
offset += page.articles.length;
if (page.articles.length === 0 || page.articles.length < pageSize) break;
if (page.total !== undefined && offset >= page.total) break;
}
return { articles: documents, total: documents.length };
}
export function buildTestHosecloudOutboundName(corpName: string): string {
const suffix = "(Seal测)";
return [...corpName].slice(0, 13 - suffix.length).join("") + suffix;
}
function buildHosecloudSyncPlan(prodCorp: CorpConfig, prodPref: any) {
if (prodCorp.source.type !== "hose") return { sourceType: prodCorp.source.type, skipped: true, reason: "prod source is not hose; no hosecloud credentials available" };
const seen = new Set<string>();
const integrations = (prodPref.integrations ?? []).filter((item: any) => item.type === "hosecloud").filter((item: any) => {
const corpId = item.corporationId ?? prodCorp.id;
if (seen.has(corpId)) return false;
seen.add(corpId);
return true;
});
return {
sourceType: "hose",
outboundName: buildTestHosecloudOutboundName(prodCorp.name),
targetMode: "assisted",
integrationsCount: integrations.length,
integrations: integrations.map((item: any) => ({ corporationId: item.corporationId, apiOrigin: item.apiOrigin, customApiUrl: item.customApiUrl }))
};
}
interface HosecloudSyncResult {
skipped: boolean;
reason?: string;
synced?: Array<{ signKey: string; outboundName: string; corporationId: string; action: "created" | "updated" }>;
}
async function syncHosecloudIntegrationsToTest(prodCorp: CorpConfig, testCorp: CorpConfig, prodClient: KyInstance, testClient: KyInstance): Promise<HosecloudSyncResult> {
if (prodCorp.source.type !== "hose") return { skipped: true, reason: "prod source is not hose; no hosecloud credentials available" };
const appKey = (prodCorp.source.appKey ?? prodCorp.source.key)?.trim();
const appSecurity = (prodCorp.source.appSecurity ?? prodCorp.source.password)?.trim();
if (!appKey || !appSecurity) return { skipped: true, reason: "prod hose source missing appKey/appSecurity (or key/password)" };
const [prodPref, testPref] = await Promise.all([
api.getApprovalStylePreferences(prodClient, prodCorp.seal.endpoints.approvalStylePreferences),
api.getApprovalStylePreferences(testClient, testCorp.seal.endpoints.approvalStylePreferences)
]);
const prodIntegrations: any[] = (prodPref.integrations ?? []).filter((item: any) => item.type === "hosecloud");
if (prodIntegrations.length === 0) return { skipped: true, reason: "prod Seal enterprise has no hosecloud integrations configured" };
const seenCorpIds = new Set<string>();
const distinct = prodIntegrations.filter((item) => {
const corpId = item.corporationId ?? prodCorp.id;
if (seenCorpIds.has(corpId)) return false;
seenCorpIds.add(corpId);
return true;
}).map((item) => ({ ...item, corporationId: item.corporationId ?? prodCorp.id }));
const testIntegrations: any[] = testPref.integrations ?? [];
const testByCorpId = new Map<string, any>(testIntegrations.filter((item) => item.type === "hosecloud").map((item) => [item.corporationId, item]));
const outboundName = buildTestHosecloudOutboundName(prodCorp.name);
const synced: HosecloudSyncResult["synced"] = [];
const nextIntegrations = distinct.map((prodInt) => {
const existing = testByCorpId.get(prodInt.corporationId);
const signKey = existing?.signKey ?? randomBytes(6).toString("hex");
synced!.push({ signKey, outboundName, corporationId: prodInt.corporationId, action: existing ? "updated" : "created" });
return {
type: "hosecloud",
signKey,
outboundName,
mode: "assisted",
apiKey: appKey,
apiSecret: appSecurity,
apiOrigin: prodInt.apiOrigin,
...(prodInt.customApiUrl ? { customApiUrl: prodInt.customApiUrl } : {}),
corporationId: prodInt.corporationId
};
});
const otherIntegrations = testIntegrations.filter((item) => item.type !== "hosecloud");
await api.updateApprovalStylePreferences(testClient, { ...testPref, integrations: [...otherIntegrations, ...nextIntegrations] }, testCorp.seal.endpoints.approvalStylePreferences);
return { skipped: false, synced };
}
+1 -1
View File
@@ -1173,7 +1173,7 @@ function fakeContext(): { corp: CorpConfig } {
}
},
source: {
type: "direct",
type: "seal",
token: "token",
sealUrl: "https://seal.test",
expiresIn: 3600,