import{createRequireasFx0}from"node:module";varzx0=Object.create;var{getPrototypeOf:Gx0,defineProperty:SE,getOwnPropertyNames:Hx0}=Object;varWx0=Object.prototype.hasOwnProperty;functionXx0($){returnthis[$]}varZx0,qx0,H6=($,Y,U)=>{varI=$!=null&&typeof$==="object";if(I){varQ=Y?Zx0??=newWeakMap:qx0??=newWeakMap,J=Q.get($);if(J)returnJ}U=$!=null?zx0(Gx0($)):{};letK=Y||!$||!$.__esModule?SE(U,"default",{value:$,enumerable:!0}):U;for(letzofHx0($))if(!Wx0.call(K,z))SE(K,z,{get:Xx0.bind($,z),enumerable:!0});if(I)Q.set($,K);returnK};varj=($,Y)=>()=>(Y||$((Y={exports:{}}).exports,Y),Y.exports);varVx0=($)=>$;functionLx0($,Y){this[$]=Vx0.bind(null,Y)}varL8=($,Y)=>{for(varUinY)SE($,U,{get:Y[U],enumerable:!0,configurable:!0,set:Lx0.bind(Y,U)})};varo=($,Y)=>()=>($&&(Y=$($=0)),Y);varK0=Fx0(import.meta.url);varwx0,qV,Mx0,Ox0,Nx0,Dx0,_0=($,Y)=>()=>(Y||$((Y={exports:{}}).exports,Y),Y.exports),br=($,Y)=>{letU={};for(varIin$)qV(U,I,{get:$[I],enumerable:!0});if(Y)qV(U,Symbol.toStringTag,{value:"Module"});returnU},Ax0=($,Y,U,I)=>{if(Y&&typeofY==="object"||typeofY==="function"){for(varQ=Ox0(Y),J=0,K=Q.length,z;J<K;J++)if(z=Q[J],!Dx0.call($,z)&&z!==U)qV($,z,{get:((G)=>Y[G]).bind(null,z),enumerable:!(I=Mx0(Y,z))||I.enumerable})}return$},VV=($,Y,U)=>(U=$!=null?wx0(Nx0($)):{},Ax0(Y||!$||!$.__esModule?qV(U,"default",{value:$,enumerable:!0}):U,$));varhE=o(()=>{wx0=Object.create,qV=Object.defineProperty,Mx0=Object.getOwnPropertyDescriptor,Ox0=Object.getOwnPropertyNames,Nx0=Object.getPrototypeOf,Dx0=Object.prototype.hasOwnProperty});functioncr($){returntypeof$==="string"&&ir.has($.replace(/#$/,""))}functionnr($,Y){if(!("$schema"in$)||typeof$.$schema!=="string")return"2020-12";letU=$.$schema.replace(/#$/,"");if(Bx0.has(U))return"2020-12";if(ir.has(U))return"2019-09";if(Px0.has(U)||Tx0.has(U))return"draft-7";throwError(`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}`)}varBx0,ir,Px0,Tx0;varyE=o(()=>{Bx0=newSet(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),ir=newSet(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),Px0=newSet(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Tx0=newSet(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"])});functionH0($,Y,U){functionI(z,G){if(!z._zod)Object.defineProperty(z,"_zod",{value:{def:G,constr:K,traits:newSet},enumerable:!1});if(z._zod.traits.has($))return;z._zod.traits.add($),Y(z,G);letH=K.prototype,W=Object.keys(H);for(letX=0;X<W.length;X++){letZ=W[X];if(!(Zinz))z[Z]=H[Z].bind(z)}}letQ=U?.Parent??Object;classJextendsQ{}Object.defineProperty(J,"name",{value:$});functionK(z){varG;letH=U?.Parent?newJ:this;I(H,z),(G=H._zod).deferred??(G.deferred=[]);for(letWofH._zod.deferred)W();returnH}returnObject.defineProperty(K,"init",{value:I}),Object.defineProperty(K,Symbol.hasInstance,{value:(z)=>{if(U?.Parent&&zinstanceofU.Parent)return!0;returnz?._zod?.traits?.has($)}}),Object.defineProperty(K,"name",{value:$}),K}functione4($){if($)Object.assign(yY,$);returnyY}vardr,GG,gE,e5,gY,yY;varkY=o(()=>{GG=Object.freeze({status:"aborted"});gE=Symbol("zod_brand");e5=classe5extendsError{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};gY=classgYextendsError{constructor($){super(`Encountered unidirectional transform during encode: ${$}`);this.name="ZodEncodeError"}};(dr=globalThis).__zod_globalConfig??(dr.__zod_globalConfig={});yY=globalThis.__zod_globalConfig});varx0={};L8(x0,{unwrapMessage:()=>HG,uint8ArrayToHex:()=>sx0,uint8ArrayToBase64url:()=>ox0,uint8ArrayToBase64:()=>lr,stringifyPrimitive:()=>h0,slugify:()=>fE,shallowClone:()=>bE,safeExtend:()=>cx0,required:()=>px0,randomString:()=>gx0,propertyKeyTypes:()=>ZG,promiseAllObject:()=>yx0,primitiveTypes:()=>iE,prefixIssues:()=>l8,pick:()=>ux0,partial:()=>dx0,parsedType:()=>g0,optionalKeys:()=>cE,omit:()=>bx0,objectClone:()=>vx0,numKeys:()=>kx0,nullish:()=>O7,normalizeParams:()=>f0,mergeDefs:()=>$3,merge:()=>nx0,jsonStringifyReplacer:()=>$Q,joinValues:()=>O0,issue:()=>UQ,isPlainObject:()=>D7,isObject:()=>xY,hexToUint8Array:()=>rx0,getSizableOrigin:()=>qG,getParsedType:()=>xx0,getLengthableOrigin:()=>VG,getEnumValues:()=>WG,getElementAtPath:()=>hx0,floatSafeRemainder:()=>xE,finalizeIssue:()=>S8,extend:()=>ix0,explicitlyAborted:()=>pE,escapeRegex:()=>h$,esc:()=>LV,defineLazy:()=>C1,createTransparentProxy:()=>fx0,cloneDef:()=>Sx0,clone:()=>v8,cleanRegex:()=>XG,cleanEnum:()=>mx0,captureStackTrace:()=>FV,cached:()=>YQ,base64urlToUint8Array:()=>lx0,base64ToUint8Array:()=>mr,assignProp:()=>N7,assertNotEqual:()=>jx0,assertNever:()=>Rx0,assertIs:()=>Cx0,assertEqual:()=>Ex0,assert:()=>_x0,allowsEval:()=>uE,aborted:()=>A7,NUMBER_FORMAT_RANGES:()=>nE,Class:()=>orLine truncated
`)}var rr=($,Y)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:Y,enumerable:!1}),$.message=JSON.stringify(Y,$Q,2),Object.defineProperty($,"toString",{value:()=>$.message,enumerable:!1})},LG,o8;var oE=o(()=>{kY();$1();LG=H0("$ZodError",rr),o8=H0("$ZodError",rr,{Parent:Error})});var IQ=($)=>(Y,U,I,Q)=>{let J=I?{...I,async:!1}:{async:!1},K=Y._zod.run({value:U,issues:[]},J);if(K instanceof Promise)throw new e5;if(K.issues.length){let z=new(Q?.Err??$)(K.issues.map((G)=>S8(G,J,e4())));throw FV(z,Q?.callee),z}return K.value},wV,QQ=($)=>async(Y,U,I,Q)=>{let J=I?{...I,async:!0}:{async:!0},K=Y._zod.run({value:U,issues:[]},J);if(K instanceof Promise)K=await K;if(K.issues.length){let z=new(Q?.Err??$)(K.issues.map((G)=>S8(G,J,e4())));throw FV(z,Q?.callee),z}return K.value},MV,JQ=($)=>(Y,U,I)=>{let Q=I?{...I,async:!1}:{async:!1},J=Y._zod.run({value:U,issues:[]},Q);if(J instanceof Promise)throw new e5;return J.issues.length?{success:!1,error:new($??LG)(J.issues.map((K)=>S8(K,Q,e4())))}:{success:!0,data:J.value}},rE,KQ=($)=>async(Y,U,I)=>{let Q=I?{...I,async:!0}:{async:!0},J=Y._zod.run({value:U,issues:[]},Q);if(J instanceof Promise)J=await J;return J.issues.length?{success:!1,error:new $(J.issues.map((K)=>S8(K,Q,e4())))}:{success:!0,data:J.value}},sE,OV=($)=>(Y,U,I)=>{let Q=I?{...I,direction:"backward"}:{direction:"backward"};return IQ($)(Y,U,Q)},tx0,NV=($)=>(Y,U,I)=>{return IQ($)(Y,U,I)},ex0,DV=($)=>async(Y,U,I)=>{let Q=I?{...I,direction:"backward"}:{direction:"backward"};return QQ($)(Y,U,Q)},$f0,AV=($)=>async(Y,U,I)=>{return QQ($)(Y,U,I)},Yf0,BV=($)=>(Y,U,I)=>{let Q=I?{...I,direction:"backward"}:{direction:"backward"};return JQ($)(Y,U,Q)},Uf0,PV=($)=>(Y,U,I)=>{return JQ($)(Y,U,I)},If0,TV=($)=>async(Y,U,I)=>{let Q=I?{...I,direction:"backward"}:{direction:"backward"};return KQ($)(Y,U,Q)},Qf0,EV=($)=>async(Y,U,I)=>{return KQ($)(Y,U,I)},Jf0;var aE=o(()=>{kY();oE();$1();wV=IQ(o8),MV=QQ(o8),rE=JQ(o8),sE=KQ(o8),tx0=OV(o8),ex0=NV(o8),$f0=DV(o8),Yf0=AV(o8),Uf0=BV(o8),If0=PV(o8),Qf0=TV(o8),Jf0=EV(o8)});var Z$={};L8(Z$,{xid:()=>Yj,uuid7:()=>Hf0,uuid6:()=>Gf0,uuid4:()=>zf0,uuid:()=>fY,uppercase:()=>Ej,unicodeEmail:()=>ar,undefined:()=>Pj,ulid:()=>$j,time:()=>wj,string:()=>Oj,sha512_hex:()=>_f0,sha512_base64url:()=>Sf0,sha512_base64:()=>vf0,sha384_hex:()=>jf0,sha384_base64url:()=>Rf0,sha384_base64:()=>Cf0,sha256_hex:()=>Pf0,sha256_base64url:()=>Ef0,sha256_base64:()=>Tf0,sha1_hex:()=>Df0,sha1_base64url:()=>Bf0,sha1_base64:()=>Af0,rfc5322Email:()=>Xf0,number:()=>MG,null:()=>Bj,nanoid:()=>Ij,md5_hex:()=>Mf0,md5_base64url:()=>Nf0,md5_base64:()=>Of0,mac:()=>Wj,lowercase:()=>Tj,ksuid:()=>Uj,ipv6:()=>Hj,ipv4:()=>Gj,integer:()=>Dj,idnEmail:()=>Zf0,httpProtocol:()=>Vj,html5Email:()=>Wf0,hostname:()=>Lf0,hex:()=>wf0,guid:()=>Jj,extendedDuration:()=>Kf0,emoji:()=>zj,email:()=>Kj,e164:()=>Lj,duration:()=>Qj,domain:()=>Ff0,datetime:()=>Mj,date:()=>Fj,cuid2:()=>eE,cuid:()=>tE,cidrv6:()=>Zj,cidrv4:()=>Xj,browserEmail:()=>qf0,boolean:()=>Aj,bigint:()=>Nj,base64url:()=>jV,base64:()=>qj});function zj(){return new RegExp(Vf0,"u")}function er($){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 wj($){return new RegExp(`^${er($)}$`)}function Mj($){let Y=er({precision:$.precision}),U=["Z"];if($.local)U.push("");if($.offset)U.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let I=`${Y}(?:${U.join("|")})`;return new RegExp(`^${tr}T(?:${I})$`)}function OG($,Y){return new RegExp(`^[A-Za-z0-9+/]{${$}}${Y}$`)}function NG($){return new RegExp(`^[A-Za-z0-9_-]{${$}}$`)}var tE,eE,$j,Yj,Uj,Ij,Qj,Kf0,Jj,fY=($)=>{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)$/;returnnewRegExp(`^([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})$`)},zf0,Gf0,Hf0,Kj,Wf0,Xf0,ar,Zf0,qf0,Vf0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Gj,Hj,Wj=($)=>{letY=h$($??":");returnnewRegExp(`^(?:[0-9A-F]{2}${Y}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${Y}){5}[0-9a-f]{2}$`)},Xj,Zj,qj,jV,Lf0,Ff0,Vj,Lj,tr="(?:(?:\\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])))",Fj,Oj=($)=>{letY=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";returnnewRegExp(`^${Y}$`)},Nj,Dj,MG,Aj,Bj,Pj,Tj,Ej,wf0,Mf0,Of0,Nf0,Df0,Af0,Bf0,Pf0,Tf0,Ef0,jf0,Cf0,Rf0,_f0,vf0,Sf0;varCV=o(()=>{$1();tE=/^[cC][0-9a-z]{6,}$/,eE=/^[0-9a-z]+$/,$j=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Yj=/^[0-9a-vA-V]{20}$/,Uj=/^[A-Za-z0-9]{27}$/,Ij=/^[a-zA-Z0-9_-]{21}$/,Qj=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\dLine truncated
`).filter((J)=>J),I=Math.min(...U.map((J)=>J.length-J.trimStart().length)),Q=U.map((J)=>J.slice(I)).map((J)=>" ".repeat(this.indent*2)+J);for(let J of Q)this.content.push(J)}compile(){let $=Function,Y=this?.args,I=[...(this?.content??[""]).map((Q)=>`${Q}`)];return new $(...Y,I.join(`
`))}}var pj;var mj=o(()=>{pj={major:4,minor:4,patch:3}});function VC($){if($==="")return!0;if(/\s/.test($))return!1;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}function ws($){if(!jV.test($))return!1;let Y=$.replace(/[-_]/g,(I)=>I==="-"?"+":"/"),U=Y.padEnd(Math.ceil(Y.length/4)*4,"=");return VC(U)}function Ms($,Y=null){try{let U=$.split(".");if(U.length!==3)return!1;let[I]=U;if(!I)return!1;let Q=JSON.parse(atob(I));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 Is($,Y,U){if($.issues.length)Y.issues.push(...l8(U,$.issues));Y.value[U]=$.value}function kV($,Y,U,I,Q,J){let K=U in I;if($.issues.length){if(Q&&J&&!K)return;Y.issues.push(...l8(U,$.issues))}if(!K&&!Q){if(!$.issues.length)Y.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[U]});return}if($.value===void 0){if(K)Y.value[U]=void 0}else Y.value[U]=$.value}function Os($){let Y=Object.keys($.shape);for(let I of Y)if(!$.shape?.[I]?._zod?.traits?.has("$ZodType"))throw Error(`Invalidelementatkey"${I}":expectedaZodschema`);let U=cE($.shape);return{...$,keys:Y,keySet:new Set(Y),numKeys:Y.length,optionalKeys:new Set(U)}}function Ns($,Y,U,I,Q,J){let K=[],z=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(z.has(Z))continue;if(H==="never"){K.push(Z);continue}let q=G.run({value:Y[Z],issues:[]},I);if(q instanceof Promise)$.push(q.then((V)=>kV(V,U,Z,Y,W,X)));else kV(q,U,Z,Y,W,X)}if(K.length)U.issues.push({code:"unrecognized_keys",keys:K,input:Y,inst:J});if(!$.length)return U;return Promise.all($).then(()=>{return U})}function Qs($,Y,U,I){for(let J of $)if(J.issues.length===0)return Y.value=J.value,Y;let Q=$.filter((J)=>!A7(J));if(Q.length===1)return Y.value=Q[0].value,Q[0];return Y.issues.push({code:"invalid_union",input:Y.value,inst:U,errors:$.map((J)=>J.issues.map((K)=>S8(K,I,e4())))}),Y}function Js($,Y,U,I){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:U,errors:$.map((J)=>J.issues.map((K)=>S8(K,I,e4())))});else Y.issues.push({code:"invalid_union",input:Y.value,inst:U,errors:[],inclusive:!1});return Y}function lj($,Y){if($===Y)return{valid:!0,data:$};if($ instanceof Date&&Y instanceof Date&&+$===+Y)return{valid:!0,data:$};if(D7($)&&D7(Y)){let U=Object.keys(Y),I=Object.keys($).filter((J)=>U.indexOf(J)!==-1),Q={...$,...Y};for(let J of I){let K=lj($[J],Y[J]);if(!K.valid)return{valid:!1,mergeErrorPath:[J,...K.mergeErrorPath]};Q[J]=K.data}return{valid:!0,data:Q}}if(Array.isArray($)&&Array.isArray(Y)){if($.length!==Y.length)return{valid:!1,mergeErrorPath:[]};let U=[];for(let I=0;I<$.length;I++){let Q=$[I],J=Y[I],K=lj(Q,J);if(!K.valid)return{valid:!1,mergeErrorPath:[I,...K.mergeErrorPath]};U.push(K.data)}return{valid:!0,data:U}}return{valid:!1,mergeErrorPath:[]}}function Ks($,Y,U){let I=new Map,Q;for(let z of Y.issues)if(z.code==="unrecognized_keys"){Q??(Q=z);for(let G of z.keys){if(!I.has(G))I.set(G,{});I.get(G).l=!0}}else $.issues.push(z);for(let z of U.issues)if(z.code==="unrecognized_keys")for(let G of z.keys){if(!I.has(G))I.set(G,{});I.get(G).r=!0}else $.issues.push(z);let J=[...I].filter(([,z])=>z.l&&z.r).map(([z])=>z);if(J.length&&Q)$.issues.push({...Q,keys:J});if(A7($))return $;let K=lj(Y.value,U.value);if(!K.valid)throw Error(`Unmergableintersection.Errorpath:${JSON.stringify(K.mergeErrorPath)}`);return $.value=K.data,$}function zs($,Y){for(let U=$.length-1;U>=0;U--)if($[U]._zod[Y]!=="optional")return U+1;return 0}function Gs($,Y,U){if($.issues.length)Y.issues.push(...l8(U,$.issues));Y.value[U]=$.value}function Hs($,Y,U,I,Q){for(let J=0;J<U.length;J++){let K=$[J],z=J<I.length;if(K.issues.length){if(!z&&J>=Q){Y.value.length=J;break}Y.issues.push(...l8(J,K.issues))}Y.value[J]=K.value}for(let J=Y.value.length-1;J>=I.length;J--)if(U[J]._zod.optout==="optional"&&Y.value[J]===void 0)Y.value.length=J;else break;return Y}function Ws($,Y,U,I,Q,J,K){if($.issues.length)if(ZG.has(typeof I))U.issues.push(...l8(I,$.issues));else U.issues.push({code:"invalid_key",origin:"map",input:Q,inst:J,issues:$.issues.map((z)=>S8(z,K,e4()))});if(Y.issues.length)if(ZG.has(typeof I))U.issues.push(...l8(I,Y.issues));else U.issues.push({origin:"map",code:"invalid_element",input:Q,inst:J,key:I,issues:Y.issues.map((z)=>S8(z,K,e4()))});U.value.set($.value,Y.value)}function Xs($,Y){if($.issues.length)Y.issues.push(...$.issues);Y.value.add($.value)}function Zs($,Y){if(Y===void 0&&($.issues.length||$.fallback))return{issues:[],value:void 0};return $}function qs($,Y){if($.value===void 0)$.value=Y.defaultValue;return $}function Vs($,Y){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:Y});return $}function hV($,Y,U){if($.issues.length)return $.aborted=!0,$;return Y._zod.run({value:$.value,issues:$.issues,fa
Line truncated
import{createRequireasOx0}from"node:module";varWx0=Object.create;var{getPrototypeOf:Xx0,defineProperty:hE,getOwnPropertyNames:Zx0}=Object;varqx0=Object.prototype.hasOwnProperty;functionVx0($){returnthis[$]}varLx0,Fx0,H6=($,Y,U)=>{varQ=$!=null&&typeof$==="object";if(Q){varI=Y?Lx0??=newWeakMap:Fx0??=newWeakMap,J=I.get($);if(J)returnJ}U=$!=null?Wx0(Xx0($)):{};letK=Y||!$||!$.__esModule?hE(U,"default",{value:$,enumerable:!0}):U;for(letzofZx0($))if(!qx0.call(K,z))hE(K,z,{get:Vx0.bind($,z),enumerable:!0});if(Q)I.set($,K);returnK};varj=($,Y)=>()=>(Y||$((Y={exports:{}}).exports,Y),Y.exports);varwx0=($)=>$;functionMx0($,Y){this[$]=wx0.bind(null,Y)}varL8=($,Y)=>{for(varUinY)hE($,U,{get:Y[U],enumerable:!0,configurable:!0,set:Mx0.bind(Y,U)})};varo=($,Y)=>()=>($&&(Y=$($=0)),Y);varK0=Ox0(import.meta.url);varNx0,qV,Dx0,Ax0,Bx0,Px0,_0=($,Y)=>()=>(Y||$((Y={exports:{}}).exports,Y),Y.exports),nr=($,Y)=>{letU={};for(varQin$)qV(U,Q,{get:$[Q],enumerable:!0});if(Y)qV(U,Symbol.toStringTag,{value:"Module"});returnU},Tx0=($,Y,U,Q)=>{if(Y&&typeofY==="object"||typeofY==="function"){for(varI=Ax0(Y),J=0,K=I.length,z;J<K;J++)if(z=I[J],!Px0.call($,z)&&z!==U)qV($,z,{get:((G)=>Y[G]).bind(null,z),enumerable:!(Q=Dx0(Y,z))||Q.enumerable})}return$},VV=($,Y,U)=>(U=$!=null?Nx0(Bx0($)):{},Tx0(Y||!$||!$.__esModule?qV(U,"default",{value:$,enumerable:!0}):U,$));vargE=o(()=>{Nx0=Object.create,qV=Object.defineProperty,Dx0=Object.getOwnPropertyDescriptor,Ax0=Object.getOwnPropertyNames,Bx0=Object.getPrototypeOf,Px0=Object.prototype.hasOwnProperty});functionpr($){returntypeof$==="string"&&dr.has($.replace(/#$/,""))}functionmr($,Y){if(!("$schema"in$)||typeof$.$schema!=="string")return"2020-12";letU=$.$schema.replace(/#$/,"");if(Ex0.has(U))return"2020-12";if(dr.has(U))return"2019-09";if(jx0.has(U)||Cx0.has(U))return"draft-7";throwError(`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}`)}varEx0,dr,jx0,Cx0;varyE=o(()=>{Ex0=newSet(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),dr=newSet(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),jx0=newSet(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Cx0=newSet(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"])});functionH0($,Y,U){functionQ(z,G){if(!z._zod)Object.defineProperty(z,"_zod",{value:{def:G,constr:K,traits:newSet},enumerable:!1});if(z._zod.traits.has($))return;z._zod.traits.add($),Y(z,G);letH=K.prototype,W=Object.keys(H);for(letX=0;X<W.length;X++){letZ=W[X];if(!(Zinz))z[Z]=H[Z].bind(z)}}letI=U?.Parent??Object;classJextendsI{}Object.defineProperty(J,"name",{value:$});functionK(z){varG;letH=U?.Parent?newJ:this;Q(H,z),(G=H._zod).deferred??(G.deferred=[]);for(letWofH._zod.deferred)W();returnH}returnObject.defineProperty(K,"init",{value:Q}),Object.defineProperty(K,Symbol.hasInstance,{value:(z)=>{if(U?.Parent&&zinstanceofU.Parent)return!0;returnz?._zod?.traits?.has($)}}),Object.defineProperty(K,"name",{value:$}),K}functione4($){if($)Object.assign(gY,$);returngY}varlr,GG,kE,e5,yY,gY;varkY=o(()=>{GG=Object.freeze({status:"aborted"});kE=Symbol("zod_brand");e5=classe5extendsError{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};yY=classyYextendsError{constructor($){super(`Encountered unidirectional transform during encode: ${$}`);this.name="ZodEncodeError"}};(lr=globalThis).__zod_globalConfig??(lr.__zod_globalConfig={});gY=globalThis.__zod_globalConfig});varx0={};L8(x0,{unwrapMessage:()=>HG,uint8ArrayToHex:()=>ex0,uint8ArrayToBase64url:()=>tx0,uint8ArrayToBase64:()=>sr,stringifyPrimitive:()=>h0,slugify:()=>uE,shallowClone:()=>iE,safeExtend:()=>px0,required:()=>ox0,randomString:()=>fx0,propertyKeyTypes:()=>ZG,promiseAllObject:()=>xx0,primitiveTypes:()=>cE,prefixIssues:()=>l8,pick:()=>cx0,partial:()=>lx0,parsedType:()=>y0,optionalKeys:()=>nE,omit:()=>nx0,objectClone:()=>gx0,numKeys:()=>ux0,nullish:()=>O7,normalizeParams:()=>f0,mergeDefs:()=>$3,merge:()=>mx0,jsonStringifyReplacer:()=>$I,joinValues:()=>O0,issue:()=>UI,isPlainObject:()=>D7,isObject:()=>xY,hexToUint8Array:()=>ax0,getSizableOrigin:()=>qG,getParsedType:()=>bx0,getLengthableOrigin:()=>VG,getEnumValues:()=>WG,getElementAtPath:()=>kx0,floatSafeRemainder:()=>fE,finalizeIssue:()=>S8,extend:()=>dx0,explicitlyAborted:()=>mE,escapeRegex:()=>h$,esc:()=>LV,defineLazy:()=>C1,createTransparentProxy:()=>ix0,cloneDef:()=>yx0,clone:()=>v8,cleanRegex:()=>XG,cleanEnum:()=>rx0,captureStackTrace:()=>FV,cached:()=>YI,base64urlToUint8Array:()=>sx0,base64ToUint8Array:()=>rr,assignProp:()=>N7,assertNotEqual:()=>_x0,assertNever:()=>Sx0,assertIs:()=>vx0,assertEqual:()=>Rx0,assert:()=>hx0,allowsEval:()=>bE,aborted:()=>A7,NUMBER_FORMAT_RANGES:()=>dE,Class:()=>trLine truncated
`)}var ar=($,Y)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:Y,enumerable:!1}),$.message=JSON.stringify(Y,$I,2),Object.defineProperty($,"toString",{value:()=>$.message,enumerable:!1})},LG,o8;var rE=o(()=>{kY();$1();LG=H0("$ZodError",ar),o8=H0("$ZodError",ar,{Parent:Error})});var QI=($)=>(Y,U,Q,I)=>{let J=Q?{...Q,async:!1}:{async:!1},K=Y._zod.run({value:U,issues:[]},J);if(K instanceof Promise)throw new e5;if(K.issues.length){let z=new(I?.Err??$)(K.issues.map((G)=>S8(G,J,e4())));throw FV(z,I?.callee),z}return K.value},wV,II=($)=>async(Y,U,Q,I)=>{let J=Q?{...Q,async:!0}:{async:!0},K=Y._zod.run({value:U,issues:[]},J);if(K instanceof Promise)K=await K;if(K.issues.length){let z=new(I?.Err??$)(K.issues.map((G)=>S8(G,J,e4())));throw FV(z,I?.callee),z}return K.value},MV,JI=($)=>(Y,U,Q)=>{let I=Q?{...Q,async:!1}:{async:!1},J=Y._zod.run({value:U,issues:[]},I);if(J instanceof Promise)throw new e5;return J.issues.length?{success:!1,error:new($??LG)(J.issues.map((K)=>S8(K,I,e4())))}:{success:!0,data:J.value}},sE,KI=($)=>async(Y,U,Q)=>{let I=Q?{...Q,async:!0}:{async:!0},J=Y._zod.run({value:U,issues:[]},I);if(J instanceof Promise)J=await J;return J.issues.length?{success:!1,error:new $(J.issues.map((K)=>S8(K,I,e4())))}:{success:!0,data:J.value}},tE,OV=($)=>(Y,U,Q)=>{let I=Q?{...Q,direction:"backward"}:{direction:"backward"};return QI($)(Y,U,I)},Yf0,NV=($)=>(Y,U,Q)=>{return QI($)(Y,U,Q)},Uf0,DV=($)=>async(Y,U,Q)=>{let I=Q?{...Q,direction:"backward"}:{direction:"backward"};return II($)(Y,U,I)},Qf0,AV=($)=>async(Y,U,Q)=>{return II($)(Y,U,Q)},If0,BV=($)=>(Y,U,Q)=>{let I=Q?{...Q,direction:"backward"}:{direction:"backward"};return JI($)(Y,U,I)},Jf0,PV=($)=>(Y,U,Q)=>{return JI($)(Y,U,Q)},Kf0,TV=($)=>async(Y,U,Q)=>{let I=Q?{...Q,direction:"backward"}:{direction:"backward"};return KI($)(Y,U,I)},zf0,EV=($)=>async(Y,U,Q)=>{return KI($)(Y,U,Q)},Gf0;var aE=o(()=>{kY();rE();$1();wV=QI(o8),MV=II(o8),sE=JI(o8),tE=KI(o8),Yf0=OV(o8),Uf0=NV(o8),Qf0=DV(o8),If0=AV(o8),Jf0=BV(o8),Kf0=PV(o8),zf0=TV(o8),Gf0=EV(o8)});var Z$={};L8(Z$,{xid:()=>Uj,uuid7:()=>Zf0,uuid6:()=>Xf0,uuid4:()=>Wf0,uuid:()=>fY,uppercase:()=>jj,unicodeEmail:()=>$s,undefined:()=>Tj,ulid:()=>Yj,time:()=>Mj,string:()=>Nj,sha512_hex:()=>hf0,sha512_base64url:()=>yf0,sha512_base64:()=>gf0,sha384_hex:()=>_f0,sha384_base64url:()=>Sf0,sha384_base64:()=>vf0,sha256_hex:()=>jf0,sha256_base64url:()=>Rf0,sha256_base64:()=>Cf0,sha1_hex:()=>Pf0,sha1_base64url:()=>Ef0,sha1_base64:()=>Tf0,rfc5322Email:()=>Vf0,number:()=>MG,null:()=>Pj,nanoid:()=>Ij,md5_hex:()=>Df0,md5_base64url:()=>Bf0,md5_base64:()=>Af0,mac:()=>Xj,lowercase:()=>Ej,ksuid:()=>Qj,ipv6:()=>Wj,ipv4:()=>Hj,integer:()=>Aj,idnEmail:()=>Lf0,httpProtocol:()=>Lj,html5Email:()=>qf0,hostname:()=>Mf0,hex:()=>Nf0,guid:()=>Kj,extendedDuration:()=>Hf0,emoji:()=>Gj,email:()=>zj,e164:()=>Fj,duration:()=>Jj,domain:()=>Of0,datetime:()=>Oj,date:()=>wj,cuid2:()=>$j,cuid:()=>eE,cidrv6:()=>qj,cidrv4:()=>Zj,browserEmail:()=>Ff0,boolean:()=>Bj,bigint:()=>Dj,base64url:()=>jV,base64:()=>Vj});function Gj(){return new RegExp(wf0,"u")}function Us($){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 Mj($){return new RegExp(`^${Us($)}$`)}function Oj($){let Y=Us({precision:$.precision}),U=["Z"];if($.local)U.push("");if($.offset)U.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let Q=`${Y}(?:${U.join("|")})`;return new RegExp(`^${Ys}T(?:${Q})$`)}function OG($,Y){return new RegExp(`^[A-Za-z0-9+/]{${$}}${Y}$`)}function NG($){return new RegExp(`^[A-Za-z0-9_-]{${$}}$`)}var eE,$j,Yj,Uj,Qj,Ij,Jj,Hf0,Kj,fY=($)=>{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)$/;returnnewRegExp(`^([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})$`)},Wf0,Xf0,Zf0,zj,qf0,Vf0,$s,Lf0,Ff0,wf0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Hj,Wj,Xj=($)=>{letY=h$($??":");returnnewRegExp(`^(?:[0-9A-F]{2}${Y}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${Y}){5}[0-9a-f]{2}$`)},Zj,qj,Vj,jV,Mf0,Of0,Lj,Fj,Ys="(?:(?:\\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])))",wj,Nj=($)=>{letY=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";returnnewRegExp(`^${Y}$`)},Dj,Aj,MG,Bj,Pj,Tj,Ej,jj,Nf0,Df0,Af0,Bf0,Pf0,Tf0,Ef0,jf0,Cf0,Rf0,_f0,vf0,Sf0,hf0,gf0,yf0;varCV=o(()=>{$1();eE=/^[cC][0-9a-z]{6,}$/,$j=/^[0-9a-z]+$/,Yj=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Uj=/^[0-9a-vA-V]{20}$/,Qj=/^[A-Za-z0-9]{27}$/,Ij=/^[a-zA-Z0-9_-]{21}$/,Jj=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\dLine truncated
`).filter((J)=>J),Q=Math.min(...U.map((J)=>J.length-J.trimStart().length)),I=U.map((J)=>J.slice(Q)).map((J)=>" ".repeat(this.indent*2)+J);for(let J of I)this.content.push(J)}compile(){let $=Function,Y=this?.args,Q=[...(this?.content??[""]).map((I)=>`${I}`)];return new $(...Y,Q.join(`
`))}}var mj;var lj=o(()=>{mj={major:4,minor:4,patch:3}});function LC($){if($==="")return!0;if(/\s/.test($))return!1;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}function Ns($){if(!jV.test($))return!1;let Y=$.replace(/[-_]/g,(Q)=>Q==="-"?"+":"/"),U=Y.padEnd(Math.ceil(Y.length/4)*4,"=");return LC(U)}function Ds($,Y=null){try{let U=$.split(".");if(U.length!==3)return!1;let[Q]=U;if(!Q)return!1;let I=JSON.parse(atob(Q));if("typ"in I&&I?.typ!=="JWT")return!1;if(!I.alg)return!1;if(Y&&(!("alg"in I)||I.alg!==Y))return!1;return!0}catch{return!1}}function Ks($,Y,U){if($.issues.length)Y.issues.push(...l8(U,$.issues));Y.value[U]=$.value}function kV($,Y,U,Q,I,J){let K=U in Q;if($.issues.length){if(I&&J&&!K)return;Y.issues.push(...l8(U,$.issues))}if(!K&&!I){if(!$.issues.length)Y.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[U]});return}if($.value===void 0){if(K)Y.value[U]=void 0}else Y.value[U]=$.value}function As($){let Y=Object.keys($.shape);for(let Q of Y)if(!$.shape?.[Q]?._zod?.traits?.has("$ZodType"))throw Error(`Invalidelementatkey"${Q}":expectedaZodschema`);let U=nE($.shape);return{...$,keys:Y,keySet:new Set(Y),numKeys:Y.length,optionalKeys:new Set(U)}}function Bs($,Y,U,Q,I,J){let K=[],z=I.keySet,G=I.catchall._zod,H=G.def.type,W=G.optin==="optional",X=G.optout==="optional";for(let Z in Y){if(Z==="__proto__")continue;if(z.has(Z))continue;if(H==="never"){K.push(Z);continue}let q=G.run({value:Y[Z],issues:[]},Q);if(q instanceof Promise)$.push(q.then((V)=>kV(V,U,Z,Y,W,X)));else kV(q,U,Z,Y,W,X)}if(K.length)U.issues.push({code:"unrecognized_keys",keys:K,input:Y,inst:J});if(!$.length)return U;return Promise.all($).then(()=>{return U})}function zs($,Y,U,Q){for(let J of $)if(J.issues.length===0)return Y.value=J.value,Y;let I=$.filter((J)=>!A7(J));if(I.length===1)return Y.value=I[0].value,I[0];return Y.issues.push({code:"invalid_union",input:Y.value,inst:U,errors:$.map((J)=>J.issues.map((K)=>S8(K,Q,e4())))}),Y}function Gs($,Y,U,Q){let I=$.filter((J)=>J.issues.length===0);if(I.length===1)return Y.value=I[0].value,Y;if(I.length===0)Y.issues.push({code:"invalid_union",input:Y.value,inst:U,errors:$.map((J)=>J.issues.map((K)=>S8(K,Q,e4())))});else Y.issues.push({code:"invalid_union",input:Y.value,inst:U,errors:[],inclusive:!1});return Y}function oj($,Y){if($===Y)return{valid:!0,data:$};if($ instanceof Date&&Y instanceof Date&&+$===+Y)return{valid:!0,data:$};if(D7($)&&D7(Y)){let U=Object.keys(Y),Q=Object.keys($).filter((J)=>U.indexOf(J)!==-1),I={...$,...Y};for(let J of Q){let K=oj($[J],Y[J]);if(!K.valid)return{valid:!1,mergeErrorPath:[J,...K.mergeErrorPath]};I[J]=K.data}return{valid:!0,data:I}}if(Array.isArray($)&&Array.isArray(Y)){if($.length!==Y.length)return{valid:!1,mergeErrorPath:[]};let U=[];for(let Q=0;Q<$.length;Q++){let I=$[Q],J=Y[Q],K=oj(I,J);if(!K.valid)return{valid:!1,mergeErrorPath:[Q,...K.mergeErrorPath]};U.push(K.data)}return{valid:!0,data:U}}return{valid:!1,mergeErrorPath:[]}}function Hs($,Y,U){let Q=new Map,I;for(let z of Y.issues)if(z.code==="unrecognized_keys"){I??(I=z);for(let G of z.keys){if(!Q.has(G))Q.set(G,{});Q.get(G).l=!0}}else $.issues.push(z);for(let z of U.issues)if(z.code==="unrecognized_keys")for(let G of z.keys){if(!Q.has(G))Q.set(G,{});Q.get(G).r=!0}else $.issues.push(z);let J=[...Q].filter(([,z])=>z.l&&z.r).map(([z])=>z);if(J.length&&I)$.issues.push({...I,keys:J});if(A7($))return $;let K=oj(Y.value,U.value);if(!K.valid)throw Error(`Unmergableintersection.Errorpath:${JSON.stringify(K.mergeErrorPath)}`);return $.value=K.data,$}function Ws($,Y){for(let U=$.length-1;U>=0;U--)if($[U]._zod[Y]!=="optional")return U+1;return 0}function Xs($,Y,U){if($.issues.length)Y.issues.push(...l8(U,$.issues));Y.value[U]=$.value}function Zs($,Y,U,Q,I){for(let J=0;J<U.length;J++){let K=$[J],z=J<Q.length;if(K.issues.length){if(!z&&J>=I){Y.value.length=J;break}Y.issues.push(...l8(J,K.issues))}Y.value[J]=K.value}for(let J=Y.value.length-1;J>=Q.length;J--)if(U[J]._zod.optout==="optional"&&Y.value[J]===void 0)Y.value.length=J;else break;return Y}function qs($,Y,U,Q,I,J,K){if($.issues.length)if(ZG.has(typeof Q))U.issues.push(...l8(Q,$.issues));else U.issues.push({code:"invalid_key",origin:"map",input:I,inst:J,issues:$.issues.map((z)=>S8(z,K,e4()))});if(Y.issues.length)if(ZG.has(typeof Q))U.issues.push(...l8(Q,Y.issues));else U.issues.push({origin:"map",code:"invalid_element",input:I,inst:J,key:Q,issues:Y.issues.map((z)=>S8(z,K,e4()))});U.value.set($.value,Y.value)}function Vs($,Y){if($.issues.length)Y.issues.push(...$.issues);Y.value.add($.value)}function Ls($,Y){if(Y===void 0&&($.issues.length||$.fallback))return{issues:[],value:void 0};return $}function Fs($,Y){if($.value===void 0)$.value=Y.defaultValue;return $}function ws($,Y){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:Y});return $}function hV($,Y,U){if($.issues.length)return $.aborted=!0,$;return Y._zod.run({value:$.value,issues:$.issues,fa
Line truncated
@@ -60,94 +60,94 @@ import{createRequire as Fx0}from"node:module";var zx0=Object.create;var{getProto
newResult[${P}]=${D}.value;
}
`)}q.write("payload.value = newResult;"),q.write("return payload;");let N=q.compile();return(O,D)=>N(Z,O,D)},J,K=xY,z=!yY.jitless,H=z&&uE.value,W=Y.catchall,X;$._zod.parse=(Z,q)=>{X??(X=I.value);let V=Z.value;if(!K(V))return Z.issues.push({expected:"object",code:"invalid_type",input:V,inst:$}),Z;if(z&&H&&q?.async===!1&&q.jitless!==!0){if(!J)J=Q(Y.shape);if(Z=J(Z,q),!W)return Z;return Ns([],V,Z,q,X,$)}return U(Z,q)}});AG=H0("$ZodUnion",($,Y)=>{V1.init($,Y),C1($._zod,"optin",()=>Y.options.some((I)=>I._zod.optin==="optional")?"optional":void 0),C1($._zod,"optout",()=>Y.options.some((I)=>I._zod.optout==="optional")?"optional":void 0),C1($._zod,"values",()=>{if(Y.options.every((I)=>I._zod.values))return new Set(Y.options.flatMap((I)=>Array.from(I._zod.values)));return}),C1($._zod,"pattern",()=>{if(Y.options.every((I)=>I._zod.pattern)){let I=Y.options.map((Q)=>Q._zod.pattern);return new RegExp(`^(${I.map((Q)=>XG(Q.source)).join("|")})$`)}return});let U=Y.options.length===1?Y.options[0]._zod.run:null;$._zod.parse=(I,Q)=>{if(U)return U(I,Q);let J=!1,K=[];for(let z of Y.options){let G=z._zod.run({value:I.value,issues:[]},Q);if(G instanceof Promise)K.push(G),J=!0;else{if(G.issues.length===0)return G;K.push(G)}}if(!J)return Qs(K,I,$,Q);return Promise.all(K).then((z)=>{return Qs(z,I,$,Q)})}});SC=H0("$ZodXor",($,Y)=>{AG.init($,Y),Y.inclusive=!1;let U=Y.options.length===1?Y.options[0]._zod.run:null;$._zod.parse=(I,Q)=>{if(U)return U(I,Q);let J=!1,K=[];for(let z of Y.options){let G=z._zod.run({value:I.value,issues:[]},Q);if(G instanceof Promise)K.push(G),J=!0;else K.push(G)}if(!J)return Js(K,I,$,Q);return Promise.all(K).then((z)=>{return Js(z,I,$,Q)})}}),hC=H0("$ZodDiscriminatedUnion",($,Y)=>{Y.inclusive=!1,AG.init($,Y);let U=$._zod.parse;C1($._zod,"propValues",()=>{let Q={};for(let J of Y.options){let K=J._zod.propValues;if(!K||Object.keys(K).length===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${Y.options.indexOf(J)}"`);for(let[z,G]of Object.entries(K)){if(!Q[z])Q[z]=new Set;for(let H of G)Q[z].add(H)}}return Q});let I=YQ(()=>{let Q=Y.options,J=new Map;for(let K of Q){let z=K._zod.propValues?.[Y.discriminator];if(!z||z.size===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${Y.options.indexOf(K)}"`);for(let G of z){if(J.has(G))throw Error(`Duplicatediscriminatorvalue"${String(G)}"`);J.set(G,K)}}return J});$._zod.parse=(Q,J)=>{let K=Q.value;if(!xY(K))return Q.issues.push({code:"invalid_type",expected:"object",input:K,inst:$}),Q;let z=I.value.get(K?.[Y.discriminator]);if(z)return z._zod.run(Q,J);if(Y.unionFallback||J.direction==="backward")return U(Q,J);return Q.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:Y.discriminator,options:Array.from(I.value.keys()),input:K,path:[Y.discriminator],inst:$}),Q}}),yC=H0("$ZodIntersection",($,Y)=>{V1.init($,Y),$._zod.parse=(U,I)=>{let Q=U.value,J=Y.left._zod.run({value:Q,issues:[]},I),K=Y.right._zod.run({value:Q,issues:[]},I);if(J instanceof Promise||K instanceof Promise)return Promise.all([J,K]).then(([G,H])=>{return Ks(U,G,H)});return Ks(U,J,K)}});uV=H0("$ZodTuple",($,Y)=>{V1.init($,Y);let U=Y.items;$._zod.parse=(I,Q)=>{let J=I.value;if(!Array.isArray(J))return I.issues.push({input:J,inst:$,expected:"tuple",code:"invalid_type"}),I;I.value=[];let K=[],z=zs(U,"optin"),G=zs(U,"optout");if(!Y.rest){if(J.length<z)return I.issues.push({code:"too_small",minimum:z,inclusive:!0,input:J,inst:$,origin:"array"}),I;if(J.length>U.length)I.issues.push({code:"too_big",maximum:U.length,inclusive:!0,input:J,inst:$,origin:"array"})}let H=Array(U.length);for(let W=0;W<U.length;W++){let X=U[W]._zod.run({value:J[W],issues:[]},Q);if(X instanceof Promise)K.push(X.then((Z)=>{H[W]=Z}));else H[W]=X}if(Y.rest){let W=U.length-1,X=J.slice(U.length);for(let Z of X){W++;let q=Y.rest._zod.run({value:Z,issues:[]},Q);if(q instanceof Promise)K.push(q.then((V)=>Gs(V,I,W)));else Gs(q,I,W)}}if(K.length)return Promise.all(K).then(()=>Hs(H,I,U,J,G));return Hs(H,I,U,J,G)}});gC=H0("$ZodRecord",($,Y)=>{V1.init($,Y),$._zod.parse=(U,I)=>{let Q=U.value;if(!D7(Q))return U.issues.push({expected:"record",code:"invalid_type",input:Q,inst:$}),U;let J=[],K=Y.keyType._zod.values;if(K){U.value={};let z=new Set;for(let H of K)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){z.add(typeof H==="number"?H.toString():H);let W=Y.keyType._zod.run({value:H,issues:[]},I);if(W instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(W.issues.length){U.issues.push({code:"invalid_key",origin:"record",issues:W.issues.map((q)=>S8(q,I,e4())),input:H,path:[H],inst:$});continue}let X=W.value,Z=Y.valueType._zod.run({value:Q[H],issues:[]},I);if(Z instanceof Promise)J.push(Z.then((q)=>{if(q.issues.length)U.issues.push(...l8(H,q.issues));U.value[X]=q.value}));else{if(Z.issues.length)U.issues.push(...l8(H,Z.issues));U.value[X]=Z.value}}let G;for(let H in Q)if(!z.has(H))G=G??[],G.push(H);if(G&&G.length>0)U.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)},J,K=xY,z=!gY.jitless,H=z&&bE.value,W=Y.catchall,X;$._zod.parse=(Z,q)=>{X??(X=Q.value);let V=Z.value;if(!K(V))return Z.issues.push({expected:"object",code:"invalid_type",input:V,inst:$}),Z;if(z&&H&&q?.async===!1&&q.jitless!==!0){if(!J)J=I(Y.shape);if(Z=J(Z,q),!W)return Z;return Bs([],V,Z,q,X,$)}return U(Z,q)}});AG=H0("$ZodUnion",($,Y)=>{V1.init($,Y),C1($._zod,"optin",()=>Y.options.some((Q)=>Q._zod.optin==="optional")?"optional":void 0),C1($._zod,"optout",()=>Y.options.some((Q)=>Q._zod.optout==="optional")?"optional":void 0),C1($._zod,"values",()=>{if(Y.options.every((Q)=>Q._zod.values))return new Set(Y.options.flatMap((Q)=>Array.from(Q._zod.values)));return}),C1($._zod,"pattern",()=>{if(Y.options.every((Q)=>Q._zod.pattern)){let Q=Y.options.map((I)=>I._zod.pattern);return new RegExp(`^(${Q.map((I)=>XG(I.source)).join("|")})$`)}return});let U=Y.options.length===1?Y.options[0]._zod.run:null;$._zod.parse=(Q,I)=>{if(U)return U(Q,I);let J=!1,K=[];for(let z of Y.options){let G=z._zod.run({value:Q.value,issues:[]},I);if(G instanceof Promise)K.push(G),J=!0;else{if(G.issues.length===0)return G;K.push(G)}}if(!J)return zs(K,Q,$,I);return Promise.all(K).then((z)=>{return zs(z,Q,$,I)})}});hC=H0("$ZodXor",($,Y)=>{AG.init($,Y),Y.inclusive=!1;let U=Y.options.length===1?Y.options[0]._zod.run:null;$._zod.parse=(Q,I)=>{if(U)return U(Q,I);let J=!1,K=[];for(let z of Y.options){let G=z._zod.run({value:Q.value,issues:[]},I);if(G instanceof Promise)K.push(G),J=!0;else K.push(G)}if(!J)return Gs(K,Q,$,I);return Promise.all(K).then((z)=>{return Gs(z,Q,$,I)})}}),gC=H0("$ZodDiscriminatedUnion",($,Y)=>{Y.inclusive=!1,AG.init($,Y);let U=$._zod.parse;C1($._zod,"propValues",()=>{let I={};for(let J of Y.options){let K=J._zod.propValues;if(!K||Object.keys(K).length===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${Y.options.indexOf(J)}"`);for(let[z,G]of Object.entries(K)){if(!I[z])I[z]=new Set;for(let H of G)I[z].add(H)}}return I});let Q=YI(()=>{let I=Y.options,J=new Map;for(let K of I){let z=K._zod.propValues?.[Y.discriminator];if(!z||z.size===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${Y.options.indexOf(K)}"`);for(let G of z){if(J.has(G))throw Error(`Duplicatediscriminatorvalue"${String(G)}"`);J.set(G,K)}}return J});$._zod.parse=(I,J)=>{let K=I.value;if(!xY(K))return I.issues.push({code:"invalid_type",expected:"object",input:K,inst:$}),I;let z=Q.value.get(K?.[Y.discriminator]);if(z)return z._zod.run(I,J);if(Y.unionFallback||J.direction==="backward")return U(I,J);return I.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:Y.discriminator,options:Array.from(Q.value.keys()),input:K,path:[Y.discriminator],inst:$}),I}}),yC=H0("$ZodIntersection",($,Y)=>{V1.init($,Y),$._zod.parse=(U,Q)=>{let I=U.value,J=Y.left._zod.run({value:I,issues:[]},Q),K=Y.right._zod.run({value:I,issues:[]},Q);if(J instanceof Promise||K instanceof Promise)return Promise.all([J,K]).then(([G,H])=>{return Hs(U,G,H)});return Hs(U,J,K)}});uV=H0("$ZodTuple",($,Y)=>{V1.init($,Y);let U=Y.items;$._zod.parse=(Q,I)=>{let J=Q.value;if(!Array.isArray(J))return Q.issues.push({input:J,inst:$,expected:"tuple",code:"invalid_type"}),Q;Q.value=[];let K=[],z=Ws(U,"optin"),G=Ws(U,"optout");if(!Y.rest){if(J.length<z)return Q.issues.push({code:"too_small",minimum:z,inclusive:!0,input:J,inst:$,origin:"array"}),Q;if(J.length>U.length)Q.issues.push({code:"too_big",maximum:U.length,inclusive:!0,input:J,inst:$,origin:"array"})}let H=Array(U.length);for(let W=0;W<U.length;W++){let X=U[W]._zod.run({value:J[W],issues:[]},I);if(X instanceof Promise)K.push(X.then((Z)=>{H[W]=Z}));else H[W]=X}if(Y.rest){let W=U.length-1,X=J.slice(U.length);for(let Z of X){W++;let q=Y.rest._zod.run({value:Z,issues:[]},I);if(q instanceof Promise)K.push(q.then((V)=>Xs(V,Q,W)));else Xs(q,Q,W)}}if(K.length)return Promise.all(K).then(()=>Zs(H,Q,U,J,G));return Zs(H,Q,U,J,G)}});kC=H0("$ZodRecord",($,Y)=>{V1.init($,Y),$._zod.parse=(U,Q)=>{let I=U.value;if(!D7(I))return U.issues.push({expected:"record",code:"invalid_type",input:I,inst:$}),U;let J=[],K=Y.keyType._zod.values;if(K){U.value={};let z=new Set;for(let H of K)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){z.add(typeof H==="number"?H.toString():H);let W=Y.keyType._zod.run({value:H,issues:[]},Q);if(W instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(W.issues.length){U.issues.push({code:"invalid_key",origin:"record",issues:W.issues.map((q)=>S8(q,Q,e4())),input:H,path:[H],inst:$});continue}let X=W.value,Z=Y.valueType._zod.run({value:I[H],issues:[]},Q);if(Z instanceof Promise)J.push(Z.then((q)=>{if(q.issues.length)U.issues.push(...l8(H,q.issues));U.value[X]=q.value}));else{if(Z.issues.length)U.issues.push(...l8(H,Z.issues));U.value[X]=Z.value}}let G;for(let H in I)if(!z.has(H))G=G??[],G.push(H);if(G&&G.length>0)U.issues.push({code:"unrec
Line truncated
Setthe\`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(letKof$.seen.entries()){letz=K[1];if(Y===K[0]){J(K);continue}if($.external){letH=$.external.registry.get(K[0])?.id;if(Y!==K[0]&&H){J(K);continue}}if($.metadataRegistry.get(K[0])?.id){J(K);continue}if(z.cycle){J(K);continue}if(z.count>1){if($.reused==="ref"){J(K);continue}}}}functionj7($,Y){letU=$.seen.get(Y);if(!U)throwError("Unprocessed schema. This is a bug in Zod.");letI=(z)=>{letG=$.seen.get(z);if(G.ref===null)return;letH=G.def??G.schema,W={...H},X=G.ref;if(G.ref=null,X){I(X);letq=$.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);elseObject.assign(H,V);if(Object.assign(H,W),z._zod.parent===X)for(letMinH){if(M==="$ref"||M==="allOf")continue;if(!(MinW))deleteH[M]}if(V.$ref&&q.def)for(letMinH){if(M==="$ref"||M==="allOf")continue;if(Minq.def&&JSON.stringify(H[M])===JSON.stringify(q.def[M]))deleteH[M]}}letZ=z._zod.parent;if(Z&&Z!==X){I(Z);letq=$.seen.get(Z);if(q?.schema.$ref){if(H.$ref=q.schema.$ref,q.def)for(letVinH){if(V==="$ref"||V==="allOf")continue;if(Vinq.def&&JSON.stringify(H[V])===JSON.stringify(q.def[V]))deleteH[V]}}}$.override({zodSchema:z,jsonSchema:H,path:G.path??[]})};for(letzof[...$.seen.entries()].reverse())I(z[0]);letQ={};if($.target==="draft-2020-12")Q.$schema="https://json-schema.org/draft/2020-12/schema";elseif($.target==="draft-07")Q.$schema="http://json-schema.org/draft-07/schema#";elseif($.target==="draft-04")Q.$schema="http://json-schema.org/draft-04/schema#";elseif($.target==="openapi-3.0");if($.external?.uri){letz=$.external.registry.get(Y)?.id;if(!z)throwError("Schema is missing an `id` property");Q.$id=$.external.uri(z)}Object.assign(Q,U.def??U.schema);letJ=$.metadataRegistry.get(Y)?.id;if(J!==void0&&Q.id===J)deleteQ.id;letK=$.external?.defs??{};for(letzof$.seen.entries()){letG=z[1];if(G.def&&G.defId){if(G.def.id===G.defId)deleteG.def.id;K[G.defId]=G.def}}if($.external);elseif(Object.keys(K).length>0)if($.target==="draft-2020-12")Q.$defs=K;elseQ.definitions=K;try{letz=JSON.parse(JSON.stringify(Q));returnObject.defineProperty(z,"~standard",{value:{...Y["~standard"],jsonSchema:{input:AQ(Y,"input",$.processors),output:AQ(Y,"output",$.processors)}},enumerable:!1,writable:!1}),z}catch(z){throwError("Error converting schema to JSON.")}}functiony8($,Y){letU=Y??{seen:newSet};if(U.seen.has($))return!1;U.seen.add($);letI=$._zod.def;if(I.type==="transform")return!0;if(I.type==="array")returny8(I.element,U);if(I.type==="set")returny8(I.valueType,U);if(I.type==="lazy")returny8(I.getter(),U);if(I.type==="promise"||I.type==="optional"||I.type==="nonoptional"||I.type==="nullable"||I.type==="readonly"||I.type==="default"||I.type==="prefault")returny8(I.innerType,U);if(I.type==="intersection")returny8(I.left,U)||y8(I.right,U);if(I.type==="record"||I.type==="map")returny8(I.keyType,U)||y8(I.valueType,U);if(I.type==="pipe"){if($._zod.traits.has("$ZodCodec"))return!0;returny8(I.in,U)||y8(I.out,U)}if(I.type==="object"){for(letQinI.shape)if(y8(I.shape[Q],U))return!0;return!1}if(I.type==="union"){for(letQofI.options)if(y8(Q,U))return!0;return!1}if(I.type==="tuple"){for(letQofI.items)if(y8(Q,U))return!0;if(I.rest&&y8(I.rest,U))return!0;return!1}return!1}varp_=($,Y={})=>(U)=>{letI=T7({...U,processors:Y});returnH4($,I),E7(I,$),j7(I,$)},AQ=($,Y,U={})=>(I)=>{let{libraryOptions:Q,target:J}=I??{},K=T7({...Q??{},target:J,io:Y,processors:U});returnH4($,K),E7(K,$),j7(K,$)};varSG=o(()=>{RG()});functionnY($,Y){if("_idmap"in$){letI=$,Q=T7({...Y,processors:VL}),J={};for(letGofI._idmap.entries()){let[H,W]=G;H4(W,Q)}letK={},z={registry:I,uri:Y?.uri,defs:J};Q.external=z;for(letGofI._idmap.entries()){let[H,W]=G;E7(Q,W),K[H]=j7(Q,W)}if(Object.keys(J).length>0){letG=Q.target==="draft-2020-12"?"$defs":"definitions";K.__shared={[G]:J}}return{schemas:K}}letU=T7({...Y,processors:VL});returnH4($,U),E7(U,$),j7(U,$)}var$b0,m_=($,Y,U,I)=>{letQ=U;Q.type="string";let{minimum:J,maximum:K,format:z,patterns:G,contentEncoding:H}=$._zod.bag;if(typeofJ==="number")Q.minLength=J;if(typeofK==="number")Q.maxLength=K;if(z){if(Q.format=$b0[z]??z,Q.format==="")deleteQ.format;if(z==="time")deleteQ.format}if(H)Q.contentEncoding=H;if(G&&G.size>0){letW=[...G];if(W.length===1)Q.pattern=W[0].source;elseif(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}))]}},l_=($,Y,U,I)=>{letQ=U,{minimum:J,maximum:K,format:z,multipleOf:G,exclusiveMaximum:H,exclusiveMinimum:W}=$._zod.bag;if(typeofz==="string"&&z.includes("int"))Q.type="integer";elseQ.type="number";letX=typeofW==="number"&&W>=(J??Number.NEGATIVE_INFINITY),Z=typeofH==="number"&&H<=(K??Number.POSITIVE_INFINITY),q=Y.target==="draft-04"||Y.target==="openapi-3.0";if(X)if(q)Q.minimum=W,Q.exclusiveMinimum=!0;elseQ.exclusiveMinimuLine truncated
`}function yi0($){let Y=[];if($.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if($.length>128)return{isValid:!1,warnings:[`Toolnameexceedsmaximumlengthof128characters(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(!hi0.test($)){let U=[...$].filter((I)=>!/[A-Za-z0-9._-]/.test(I)).filter((I,Q,J)=>J.indexOf(I)===Q);return Y.push(`Toolnamecontainsinvalidcharacters:${U.map((I)=>`"${I}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:Y}}return{isValid:!0,warnings:Y}}function gi0($,Y){if(Y.length>0){console.warn(`Toolnamevalidationwarningfor"${$}":`);for(let U of Y)console.warn(`-${U}`);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 ch($){let Y=yi0($);return gi0($,Y.warnings),Y.isValid}function ki0($){return typeof $==="object"&&$!==null&&"_zod"in $}function xi0($){return typeof $==="object"&&$!==null&&!("_zod"in $)&&"_def"in $&&typeof $._def?.typeName==="string"}function fi0($){if(typeof $!=="object"||$===null)return!1;if(pQ($))return!1;let Y=Object.getPrototypeOf($);if(Y!==Object.prototype&&Y!==null)return!1;return Object.values($).every((U)=>ki0(U))}function $M($){if($===void 0)return;if(fi0($))return U0($);if(typeof $==="object"&&$!==null&&!pQ($)&&Object.values($).some((Y)=>xi0(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(!pQ($))throw TypeError("inputSchema/outputSchema/argsSchema must be a Standard Schema (e.g. z.object({...})) or a raw Zod shape ({ field: z.string() }).");return $}var Fh,Fb0,E1,L1,wb0,Ve="2026-07-28",b7,we,Nb0,Db0,Ab0,Ne,De,Pb0,fw,Yc1,Uc1,Ue,Ph,_b0,vb0,nQ,i0,Q1,lw,Pe,lQ,ow,yb0=0,gb0="private",kb0,db0,bw,Ch,je,Ic1,Qc1,sb0,ab0,Rh,iw,jH="2026-07-28",_e,$i0,y$=($)=>eG.safeParse($).success,i7=($)=>$H.safeParse($).success,TH=($)=>SQ.safeParse($).success,tw=($)=>hQ.safeParse($).success,G3=($)=>typeof $==="object"&&$!==null&&!Array.isArray($)&&$.resultType==="input_required",ze="x-mcp-header",Yi0,Ui0,Ii0,Qi0,dw=-32020,Jc1,Ji0,Ge=!1,Mh="draft-2020-12",Gi0,qi0,Vi0,He,Li0,Di0,he=250,Ai0,Bi0,xe,fe,Pi0,Ti0,be=60000,ji0,Ci0,Ri0,ie,fh,Si0,Kc1,ce=10485760,bh=class{_buffer;_maxBufferSize;constructor($){this._maxBufferSize=$?.maxBufferSize??ce}append($){if((this._buffer?.length??0)+$.length>this._maxBufferSize)throw this.clear(),Error(`ReadBufferexceededmaximumsizeof${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 ne(Y)}catch(U){if(U instanceof SyntaxError)continue;throw U}}return null}clear(){this._buffer=void 0}},hi0;var YM=o(()=>{hE();yE();et();gS();Fh=Symbol.for("mcp.sdk.errorBrands");Fb0=class $ extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](Y){return dQ(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 dQ(this,Y)}constructor(Y,U,I){super(U);this.code=Y,this.errorUri=I,this.name="OAuthError",Nh(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)}},E1=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 dQ(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 dQ(this,$)}constructor($,Y,U){super(Y);this.code=$,this.data=U,this.name="SdkError",Nh(this,new.target)}},wb0=class extends L1{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor($,Y,U){super($,Y,U);this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};b7=[Ve];we=["task","inputRequests","requestState"];Db0=new Set(["const","enum","default","examples"]),Ab0=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);Ne={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},De={"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},Pb0={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};Yc1=Object.keys(Ne),Uc1=Object.keys(De);Ue={ok:!1,reason:"not-in-era"};Ph={era:"2025-11-25",hasRequestMethod:Ae,hasNotificationMethod:Be,validateRequest:($,Y)=>uw(jb0($),Y),validateResult:($,Y)=>uw(Eb0($),Y),validateNotification:($,Y)=>uw(Cb0($),Y),hasInputRequestMethod:()=>!1,validateInputRequest:()=>Ue,validateInputResponse:()=>Ue,samplingResultVariant:($,Y)=>{let U=Me();return uw($?U.CreateMessageResultWithToolsSchema:U.CreateMessageResultSchema,Y)},outboundEnvelope:($)=>{return},validateEnvelopeMeta:($)=>[],projectCallToolResult($,Y){let U=Fe($),I=U.structuredContent;if(I===void 0)return U;let Q=typeof I!=="object"||I===null||Array.isArray(I),J=Y!==void 0&&Oe(Y);if(!Q&&!J)return U;return{...U,structuredContent:{result:I}}},decodeResult($,Y){if(wh(Y)&&"resultType"in Y){let U={...Y};return delete U.resultType,{kind:"complete",result:Qe(U)}}return{kind:"complete",result:Qe(Y)}},encodeResult($,Y){if($!=="tools/list")return Y;l
Line truncated
Setthe\`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(letKof$.seen.entries()){letz=K[1];if(Y===K[0]){J(K);continue}if($.external){letH=$.external.registry.get(K[0])?.id;if(Y!==K[0]&&H){J(K);continue}}if($.metadataRegistry.get(K[0])?.id){J(K);continue}if(z.cycle){J(K);continue}if(z.count>1){if($.reused==="ref"){J(K);continue}}}}functionj7($,Y){letU=$.seen.get(Y);if(!U)throwError("Unprocessed schema. This is a bug in Zod.");letQ=(z)=>{letG=$.seen.get(z);if(G.ref===null)return;letH=G.def??G.schema,W={...H},X=G.ref;if(G.ref=null,X){Q(X);letq=$.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);elseObject.assign(H,V);if(Object.assign(H,W),z._zod.parent===X)for(letMinH){if(M==="$ref"||M==="allOf")continue;if(!(MinW))deleteH[M]}if(V.$ref&&q.def)for(letMinH){if(M==="$ref"||M==="allOf")continue;if(Minq.def&&JSON.stringify(H[M])===JSON.stringify(q.def[M]))deleteH[M]}}letZ=z._zod.parent;if(Z&&Z!==X){Q(Z);letq=$.seen.get(Z);if(q?.schema.$ref){if(H.$ref=q.schema.$ref,q.def)for(letVinH){if(V==="$ref"||V==="allOf")continue;if(Vinq.def&&JSON.stringify(H[V])===JSON.stringify(q.def[V]))deleteH[V]}}}$.override({zodSchema:z,jsonSchema:H,path:G.path??[]})};for(letzof[...$.seen.entries()].reverse())Q(z[0]);letI={};if($.target==="draft-2020-12")I.$schema="https://json-schema.org/draft/2020-12/schema";elseif($.target==="draft-07")I.$schema="http://json-schema.org/draft-07/schema#";elseif($.target==="draft-04")I.$schema="http://json-schema.org/draft-04/schema#";elseif($.target==="openapi-3.0");if($.external?.uri){letz=$.external.registry.get(Y)?.id;if(!z)throwError("Schema is missing an `id` property");I.$id=$.external.uri(z)}Object.assign(I,U.def??U.schema);letJ=$.metadataRegistry.get(Y)?.id;if(J!==void0&&I.id===J)deleteI.id;letK=$.external?.defs??{};for(letzof$.seen.entries()){letG=z[1];if(G.def&&G.defId){if(G.def.id===G.defId)deleteG.def.id;K[G.defId]=G.def}}if($.external);elseif(Object.keys(K).length>0)if($.target==="draft-2020-12")I.$defs=K;elseI.definitions=K;try{letz=JSON.parse(JSON.stringify(I));returnObject.defineProperty(z,"~standard",{value:{...Y["~standard"],jsonSchema:{input:AI(Y,"input",$.processors),output:AI(Y,"output",$.processors)}},enumerable:!1,writable:!1}),z}catch(z){throwError("Error converting schema to JSON.")}}functiong8($,Y){letU=Y??{seen:newSet};if(U.seen.has($))return!1;U.seen.add($);letQ=$._zod.def;if(Q.type==="transform")return!0;if(Q.type==="array")returng8(Q.element,U);if(Q.type==="set")returng8(Q.valueType,U);if(Q.type==="lazy")returng8(Q.getter(),U);if(Q.type==="promise"||Q.type==="optional"||Q.type==="nonoptional"||Q.type==="nullable"||Q.type==="readonly"||Q.type==="default"||Q.type==="prefault")returng8(Q.innerType,U);if(Q.type==="intersection")returng8(Q.left,U)||g8(Q.right,U);if(Q.type==="record"||Q.type==="map")returng8(Q.keyType,U)||g8(Q.valueType,U);if(Q.type==="pipe"){if($._zod.traits.has("$ZodCodec"))return!0;returng8(Q.in,U)||g8(Q.out,U)}if(Q.type==="object"){for(letIinQ.shape)if(g8(Q.shape[I],U))return!0;return!1}if(Q.type==="union"){for(letIofQ.options)if(g8(I,U))return!0;return!1}if(Q.type==="tuple"){for(letIofQ.items)if(g8(I,U))return!0;if(Q.rest&&g8(Q.rest,U))return!0;return!1}return!1}varm_=($,Y={})=>(U)=>{letQ=T7({...U,processors:Y});returnH4($,Q),E7(Q,$),j7(Q,$)},AI=($,Y,U={})=>(Q)=>{let{libraryOptions:I,target:J}=Q??{},K=T7({...I??{},target:J,io:Y,processors:U});returnH4($,K),E7(K,$),j7(K,$)};varSG=o(()=>{RG()});functionnY($,Y){if("_idmap"in$){letQ=$,I=T7({...Y,processors:VL}),J={};for(letGofQ._idmap.entries()){let[H,W]=G;H4(W,I)}letK={},z={registry:Q,uri:Y?.uri,defs:J};I.external=z;for(letGofQ._idmap.entries()){let[H,W]=G;E7(I,W),K[H]=j7(I,W)}if(Object.keys(J).length>0){letG=I.target==="draft-2020-12"?"$defs":"definitions";K.__shared={[G]:J}}return{schemas:K}}letU=T7({...Y,processors:VL});returnH4($,U),E7(U,$),j7(U,$)}varQb0,l_=($,Y,U,Q)=>{letI=U;I.type="string";let{minimum:J,maximum:K,format:z,patterns:G,contentEncoding:H}=$._zod.bag;if(typeofJ==="number")I.minLength=J;if(typeofK==="number")I.maxLength=K;if(z){if(I.format=Qb0[z]??z,I.format==="")deleteI.format;if(z==="time")deleteI.format}if(H)I.contentEncoding=H;if(G&&G.size>0){letW=[...G];if(W.length===1)I.pattern=W[0].source;elseif(W.length>1)I.allOf=[...W.map((X)=>({...Y.target==="draft-07"||Y.target==="draft-04"||Y.target==="openapi-3.0"?{type:"string"}:{},pattern:X.source}))]}},o_=($,Y,U,Q)=>{letI=U,{minimum:J,maximum:K,format:z,multipleOf:G,exclusiveMaximum:H,exclusiveMinimum:W}=$._zod.bag;if(typeofz==="string"&&z.includes("int"))I.type="integer";elseI.type="number";letX=typeofW==="number"&&W>=(J??Number.NEGATIVE_INFINITY),Z=typeofH==="number"&&H<=(K??Number.POSITIVE_INFINITY),q=Y.target==="draft-04"||Y.target==="openapi-3.0";if(X)if(q)I.minimum=W,I.exclusiveMinimum=!0;elseI.exclusiveMinimuLine truncated
`}function xi0($){let Y=[];if($.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if($.length>128)return{isValid:!1,warnings:[`Toolnameexceedsmaximumlengthof128characters(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(!ki0.test($)){let U=[...$].filter((Q)=>!/[A-Za-z0-9._-]/.test(Q)).filter((Q,I,J)=>J.indexOf(Q)===I);return Y.push(`Toolnamecontainsinvalidcharacters:${U.map((Q)=>`"${Q}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:Y}}return{isValid:!0,warnings:Y}}function fi0($,Y){if(Y.length>0){console.warn(`Toolnamevalidationwarningfor"${$}":`);for(let U of Y)console.warn(`-${U}`);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 nh($){let Y=xi0($);return fi0($,Y.warnings),Y.isValid}function ui0($){return typeof $==="object"&&$!==null&&"_zod"in $}function bi0($){return typeof $==="object"&&$!==null&&!("_zod"in $)&&"_def"in $&&typeof $._def?.typeName==="string"}function ii0($){if(typeof $!=="object"||$===null)return!1;if(pI($))return!1;let Y=Object.getPrototypeOf($);if(Y!==Object.prototype&&Y!==null)return!1;return Object.values($).every((U)=>ui0(U))}function $M($){if($===void 0)return;if(ii0($))return U0($);if(typeof $==="object"&&$!==null&&!pI($)&&Object.values($).some((Y)=>bi0(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(!pI($))throw TypeError("inputSchema/outputSchema/argsSchema must be a Standard Schema (e.g. z.object({...})) or a raw Zod shape ({ field: z.string() }).");return $}var wh,Ob0,E1,L1,Nb0,we="2026-07-28",b7,Ne,Bb0,Pb0,Tb0,Be,Pe,jb0,fw,Gc1,Hc1,Je,Th,hb0,gb0,nI,i0,I1,lw,je,lI,ow,xb0=0,fb0="private",ub0,lb0,bw,Rh,_e,Wc1,Xc1,eb0,$i0,_h,iw,jH="2026-07-28",he,Qi0,g$=($)=>eG.safeParse($).success,i7=($)=>$H.safeParse($).success,TH=($)=>SI.safeParse($).success,aw=($)=>hI.safeParse($).success,G3=($)=>typeof $==="object"&&$!==null&&!Array.isArray($)&&$.resultType==="input_required",We="x-mcp-header",Ii0,Ji0,Ki0,zi0,dw=-32020,Zc1,Gi0,Xe=!1,Oh="draft-2020-12",Xi0,Fi0,wi0,Ze,Mi0,Pi0,ke=250,Ti0,Ei0,be,ie,ji0,Ci0,ne=60000,_i0,vi0,Si0,de,uh,yi0,qc1,pe=10485760,ih=class{_buffer;_maxBufferSize;constructor($){this._maxBufferSize=$?.maxBufferSize??pe}append($){if((this._buffer?.length??0)+$.length>this._maxBufferSize)throw this.clear(),Error(`ReadBufferexceededmaximumsizeof${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 me(Y)}catch(U){if(U instanceof SyntaxError)continue;throw U}}return null}clear(){this._buffer=void 0}},ki0;var YM=o(()=>{gE();yE();Ue();kS();wh=Symbol.for("mcp.sdk.errorBrands");Ob0=class $ extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](Y){return dI(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 dI(this,Y)}constructor(Y,U,Q){super(U);this.code=Y,this.errorUri=Q,this.name="OAuthError",Dh(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)}},E1=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 dI(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 dI(this,$)}constructor($,Y,U){super(Y);this.code=$,this.data=U,this.name="SdkError",Dh(this,new.target)}},Nb0=class extends L1{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor($,Y,U){super($,Y,U);this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};b7=[we];Ne=["task","inputRequests","requestState"];Pb0=new Set(["const","enum","default","examples"]),Tb0=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);Be={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},Pe={"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},jb0={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};Gc1=Object.keys(Be),Hc1=Object.keys(Pe);Je={ok:!1,reason:"not-in-era"};Th={era:"2025-11-25",hasRequestMethod:Te,hasNotificationMethod:Ee,validateRequest:($,Y)=>uw(_b0($),Y),validateResult:($,Y)=>uw(Rb0($),Y),validateNotification:($,Y)=>uw(vb0($),Y),hasInputRequestMethod:()=>!1,validateInputRequest:()=>Je,validateInputResponse:()=>Je,samplingResultVariant:($,Y)=>{let U=De();return uw($?U.CreateMessageResultWithToolsSchema:U.CreateMessageResultSchema,Y)},outboundEnvelope:($)=>{return},validateEnvelopeMeta:($)=>[],projectCallToolResult($,Y){let U=Oe($),Q=U.structuredContent;if(Q===void 0)return U;let I=typeof Q!=="object"||Q===null||Array.isArray(Q),J=Y!==void 0&&Ae(Y);if(!I&&!J)return U;return{...U,structuredContent:{result:Q}}},decodeResult($,Y){if(Mh(Y)&&"resultType"in Y){let U={...Y};return delete U.resultType,{kind:"complete",result:ze(U)}}return{kind:"complete",result:ze(Y)}},encodeResult($,Y){if($!=="tools/list")return Y;l
Line truncated
*content-type
*Copyright(c)2015DouglasChristopherWilson
*MITLicensed
*/Si0=_0(($)=>{var Y=/;*([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,U=/\\([\u000b\u0020-\u00ff])/g,I=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;$.parse=Q;function Q(z){if(!z)throw TypeError("argument string is required");var G=typeof z==="object"?J(z):z;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(!I.test(W))throw TypeError("invalid media type");var X=new K(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(U,"$1")}X.parameters[Z]=V}if(H!==G.length)throw TypeError("invalid parameter format")}return X}function J(z){var G;if(typeof z.getHeader==="function")G=z.getHeader("content-type");else if(typeof z.headers==="object")G=z.headers&&z.headers["content-type"];if(typeof G!=="string")throw TypeError("content-type header is missing from object");return G}function K(z){this.parameters=Object.create(null),this.type=z}}),Kc1=VV(Si0(),1);hi0=/^[A-Za-z0-9._-]{1,128}$/});function nh($){let Y=new $({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return $n0(Y),Y}var UM,de,F1,S1,w5,QM,ui0,pe,me,IM,bi0,M5,ii0,ci0,le,ni0,JM,oQ,RH,rQ,KM,di0,oe,pi0,mi0,li0,dh,oi0,ph,re,ri0,si0,ai0,ti0,ei0,$c0,Yc0,Uc0,mh,Ic0,Qc0,Jc0,se,ae,te,Kc0,zc0,Gc0,lh,Hc0,ee,Wc0,Xc0,Zc0,qc0,Vc0,Lc0,Fc0,wc0,$00,Mc0,Y00,U00,I00,Oc0,oh,Nc0,Q00,J00,K00,Dc0,Ac0,z00,Bc0,Pc0,Tc0,G00,Ec0,jc0,H00,Cc0,Rc0,_c0,vc0,Sc0,hc0,yc0,gc0,kc0,xc0,fc0,uc0,bc0,ic0,cc0,nc0,dc0,pc0,mc0,lc0,oc0,rc0,sc0,W00,ac0,tc0,ec0,$n0,zM=class{_ajv;_ajvDraft7;_ajv2019;_userAjv;constructor($){this._userAjv=$!==void 0,this._ajv=$}get ajv(){return this._ajv??=nh(tc0.Ajv2020)}_engineFor($){if(this._userAjv)return this.ajv;let Y=nr($,"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??=nh(ac0.Ajv2019);return this._ajvDraft7??=nh(W00.Ajv)}getValidator($){let Y=this._engineFor($),U="$id"in $&&typeof $.$id==="string"?Y.getSchema($.$id)??Y.compile($):Y.compile($);return(I)=>{return U(I)?{valid:!0,data:I,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:Y.errorsText(U.errors)}}}},Mc1;var X00=o(()=>{hE();yE();UM=_0(($)=>{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 U=class extends Y{constructor(F){super();if(!$.IDENTIFIER.test(F))throw Error("CodeGen: name must be a valid identifier");this.str=F}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};$.Name=U;var I=class extends Y{constructor(F){super();this._items=typeof F==="string"?[F]:F}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let F=this._items[0];return F===""||F==='""'}get str(){var F;return(F=this._str)!==null&&F!==void 0?F:this._str=this._items.reduce((N,O)=>`${N}${O}`,"")}get names(){var F;return(F=this._names)!==null&&F!==void 0?F:this._names=this._items.reduce((N,O)=>{if(O instanceof U)N[O.str]=(N[O.str]||0)+1;return N},{})}};$._Code=I,$.nil=new I("");function Q(F,...N){let O=[F[0]],D=0;while(D<N.length)z(O,N[D]),O.push(F[++D]);return new I(O)}$._=Q;let J=new I("+");function K(F,...N){let O=[q(F[0])],D=0;while(D<N.length)O.push(J),z(O,N[D]),O.push(J,q(F[++D]));return G(O),new I(O)}$.str=K;function z(F,N){if(N instanceof I)F.push(...N._items);else if(N instanceof U)F.push(N);else F.push(X(N))}$.addCodeArg=z;function G(F){let N=1;while(N<F.length-1){if(F[N]===J){let O=H(F[N-1],F[N+1]);if(O!==void 0){F.splice(N-1,3,O);continue}F[N++]="+"}N++}}function H(F,N){if(N==='""')return F;if(F==='""')return N;if(typeof F=="string"){if(N instanceof U||F[F.length-1]!=='"')return;if(typeof N!="string")return`${F.slice(0,-1)}${N}"`;if(N[0]==='"')return F.slice(0,-1)+N.slice(1);return}if(typeof N=="string"&&N[0]==='"'&&!(F instanceof U))return`"${F}${N.slice(1)}`}function W(F,N){return N.emptyStr()?F:F.emptyStr()?N:K`${F}${N}`}$.strConcat=W;function X(F){return typeof F=="number"||typeof F=="boolean"||F===null?F:q(Array.isArray(F)?F.join(","):F)}function Z(F){return new I(q(F))}$.stringify=Z;function q(F){return JSON.stringify(F).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}$.safeStringify=q;function V(F){return typeof F=="string"&&$.IDENTIFIER.test(F)?new I(`.${F}`):Q`[${F}]`}$.getProperty=V;function w(F){if(typeof F=="string"&&$.IDENTIFIER.test(F))returnnewI(`${F}`);throwError(`CodeGen: invalid export name: ${F}, use explicit $id name mapping`)}$.getEsmExportName=w;functionM(F){returnnewLine truncated
deps:${W}}`};let Q={keyword:"dependencies",type:"object",schemaType:"object",error:$.error,code(G){let[H,W]=J(G);K(G,H),z(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 K(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 w=H[V];if(w.length===0)continue;let M=(0,I.propertyInData)(W,X,V,Z.opts.ownProperties);if(G.setParams({property:V,depsCount:w.length,deps:w.join(", ")}),Z.allErrors)W.if(M,()=>{for(let F of w)(0,I.checkReportMissingProp)(G,F)});else W.if(Y._`${M}&&(${(0,I.checkMissingProp)(G,w,q)})`),(0,I.reportMissingProp)(G,q),W.else()}}$.validatePropertyDeps=K;function z(G,H=G.schema){let{gen:W,data:X,keyword:Z,it:q}=G,V=W.name("valid");for(let w in H){if((0,U.alwaysValidSchema)(q,H[w]))continue;W.if((0,I.propertyInData)(W,X,w,q.opts.ownProperties),()=>{let M=G.subschema({keyword:Z,schemaProp:w},V);G.mergeValidEvaluated(M,V)},()=>W.var(V,!0)),G.ok(V)}}$.validateSchemaDeps=z,$.default=Q}),Hc0=_0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let Y=F1(),U=S1(),I={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:K,data:z,it:G}=Q;if((0,U.alwaysValidSchema)(G,K))return;let H=J.name("valid");J.forIn("key",z,(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=I}),ee=_0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let Y=M5(),U=F1(),I=w5(),Q=S1(),J={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:K})=>U._`{additionalProperty:${K.additionalProperty}}`},code(K){let{gen:z,schema:G,parentSchema:H,data:W,errsCount:X,it:Z}=K;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 w=(0,Y.allSchemaProperties)(H.properties),M=(0,Y.allSchemaProperties)(H.patternProperties);F(),K.ok(U._`${X}===${I.default.errors}`);function F(){z.forIn("key",W,(T)=>{if(!w.length&&!M.length)D(T);else z.if(N(T),()=>D(T))})}function N(T){let A;if(w.length>8){let E=(0,Q.schemaRefOrVal)(Z,H.properties,"properties");A=(0,Y.isOwnProperty)(z,E,T)}else if(w.length)A=(0,U.or)(...w.map((E)=>U._`${T}===${E}`));else A=U.nil;if(M.length)A=(0,U.or)(A,...M.map((E)=>U._`${(0,Y.usePattern)(K,E)}.test(${T})`));return(0,U.not)(A)}function O(T){z.code(U._`delete${W}[${T}]`)}function D(T){if(V.removeAdditional==="all"||V.removeAdditional&&G===!1){O(T);return}if(G===!1){if(K.setParams({additionalProperty:T}),K.error(),!q)z.break();return}if(typeof G=="object"&&!(0,Q.alwaysValidSchema)(Z,G)){let A=z.name("valid");if(V.removeAdditional==="failing")P(T,A,!1),z.if((0,U.not)(A),()=>{K.reset(),O(T)});else if(P(T,A),!q)z.if((0,U.not)(A),()=>z.break())}}function P(T,A,E){let C={keyword:"additionalProperties",dataProp:T,dataPropType:Q.Type.Str};if(E===!1)Object.assign(C,{compositeRule:!0,createErrors:!1,allErrors:!1});K.subschema(C,A)}}};$.default=J}),Wc0=_0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let Y=oQ(),U=M5(),I=S1(),Q=ee(),J={keyword:"properties",type:"object",schemaType:"object",code(K){let{gen:z,schema:G,parentSchema:H,data:W,it:X}=K;if(X.opts.removeAdditional==="all"&&H.additionalProperties===void 0)Q.default.code(new Y.KeywordCxt(X,Q.default,"additionalProperties"));let Z=(0,U.allSchemaProperties)(G);for(let F of Z)X.definedProperties.add(F);if(X.opts.unevaluated&&Z.length&&X.props!==!0)X.props=I.mergeEvaluated.props(z,(0,I.toHash)(Z),X.props);let q=Z.filter((F)=>!(0,I.alwaysValidSchema)(X,G[F]));if(q.length===0)return;let V=z.name("valid");for(let F of q){if(w(F))M(F);else{if(z.if((0,U.propertyInData)(z,W,F,X.opts.ownProperties)),M(F),!X.allErrors)z.else().var(V,!0);z.endIf()}K.it.definedProperties.add(F),K.ok(V)}function w(F){return X.opts.useDefaults&&!X.compositeRule&&G[F].default!==void 0}function M(F){K.subschema({keyword:"properties",schemaProp:F,dataProp:F},V)}}};$.default=J}),Xc0=_0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let Y=M5(),U=F1(),I=S1(),Q=S1(),J={keyword:"patternProperties",type:"object",schemaType:"object",code(K){let{gen:z,schema:G,data:H,parentSchema:W,it:X}=K,{opts:Z}=X,q=(0,Y.allSchemaProperties)(G),V=q.filter((P)=>(0,I.alwaysValidSchema)(X,G[P]));if(q.length===0||V.length===q.length&&(!X.opts.unevaluated||X.props===!0))return;let w=Z.strictSchema&&!Z.allowMatchingProperties&&W.properties,M=z.name("valid");if(X.props!==!0&&!(X.props instanceof U.Name))X.props=(0,Q.evaluatedPropsToName)(z,X.props);let{props:F}=X;N();function N(){for(let P of q){if(w)O(P);if(X.allErrors)
Line truncated
`)}openNode($,Y){let U=this.tos,I=this._xml;if(U&&this.open)I.push(">");this._stack.push($),I.push("<"),I.push($),Jx(I,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)g70(this._xml,$,Y)}addAttributes($){if(!this.open)throw Error("Cannot write attributes to node if it is not open");Jx(this._xml,$)}writeText($){let Y=this._xml;if(this.open)Y.push(">"),this.open=!1;this.leaf=!1,Y.push(y70.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,U){if(this.openNode($,Y),U!==void 0)this.writeText(U);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("")}}Kx.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"};k70.exports=Kx});var zx=j((F01)=>{var x70=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function L01($){if(typeof $==="string")return $;if(x70)return x70.decode($);return $.toString()}F01.bufferToString=L01});var c70=j((u70)=>{Object.defineProperty(u70,"__esModule",{value:!0});u70.CHAR=`
`,$=this.i;break;case k11:{let{entityReturnState:U}=this,I=this.entity+Y.slice($,this.prevI);this.state=U;let Q;if(I==="")this.fail("empty entity name."),Q="&;";else Q=this.parseEntity(I),this.entity="";if(U!==f8||this.textHandler!==void 0)this.text+=Q;break $}case i4:this.entity+=Y.slice($);break $;default:}}sOpenWaka(){let $=this.getCode();if(pW($))this.state=v11,this.unget(),this.xmlDeclPossible=!1;else switch($){case DN:this.state=y11,this.xmlDeclPossible=!1;break;case X20:this.state=D11,this.openWakaBang="",this.xmlDeclPossible=!1;break;case Y8:this.state=E11;break;default:this.fail("disallowed character in tag name"),this.state=f8,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=wx,this.openWakaBang="";break;case"--":this.state=Fx,this.openWakaBang="";break;case"DOCTYPE":if(this.state=qx,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(NN))this.state=A11}sCommentEnding(){var $;let Y=this.getCodeNorm();if(Y===NN)this.state=B11,($=this.commentHandler)===null||$===void 0||$.call(this,this.text),this.text="";else this.text+=`-${String.fromCodePoint(Y)}`,this.state=Fx}sCommentEnded(){let $=this.getCodeNorm();if($!==_6)this.fail("malformed comment."),this.text+=`--${String.fromCodePoint($)}`,this.state=Fx;else this.state=f8}sCData(){if(this.captureToChar(bJ))this.state=P11}sCDataEnding(){let $=this.getCodeNorm();if($===bJ)this.state=T11;else this.text+=`]${String.fromCodePoint($)}`,this.state=wx}sCDataEnding2(){var $;let Y=this.getCodeNorm();switch(Y){case _6:{($=this.cdataHandler)===null||$===void 0||$.call(this,this.text),this.text="",this.state=f8;break}case bJ:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(Y)}`,this.state=wx}}sPIFirstChar(){let $=this.getCodeNorm();if(this.nameStartCheck($))this.piTarget+=String.fromCodePoint($),this.state=Q20;else if($===Y8||$$($))this.fail("processing instruction without a target."),this.state=$===Y8?ON:Mx;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint($),this.state=Q20}sPIRest(){let{chunk:$,i:Y}=this;while(!0){let U=this.getCodeNorm();if(U===i4){this.piTarget+=$.slice(Y);return}if(!this.nameCheck(U)){this.piTarget+=$.slice(Y,this.prevI);let I=U===Y8;if(I||$$(U))if(this.piTarget==="xml"){if(!this.xmlDeclPossible)this.fail("an XML declaration must be at the start of the document.");this.state=I?AU:J20}else this.state=I?ON:Mx;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(U);break}}}sPIBody(){if(this.text.length===0){let $=this.getCodeNorm();if($===Y8)this.state=ON;else if(!$$($))this.text=String.fromCodePoint($)}else if(this.captureToChar(Y8))this.state=ON}sPIEnding(){var $;let Y=this.getCodeNorm();if(Y===_6){let{piTarget:U}=this;if(U.toLowerCase()==="xml")this.fail("the XML declaration must appear at the start of the document.");($=this.piHandler)===null||$===void 0||$.call(this,{target:U,body:this.text}),this.piTarget=this.text="",this.state=f8}else if(Y===Y8)this.text+="?";else this.text+=`?${String.fromCodePoint(Y)}`,this.state=Mx;this.xmlDeclPossible=!1}sXMLDeclNameStart(){let $=this.skipSpaces();if($===Y8){this.state=AU;return}if($!==i4)this.state=j11,this.name=String.fromCodePoint($)}sXMLDeclName(){let $=this.captureTo(u11);if($===Y8){this.state=AU,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(!($$($)||$===uJ))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(`expectedthename${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expectedoneof${this.xmlDeclExpects.join(", ")}`)}this.state=$===uJ?K20:C11}sXMLDeclEq(){let $=this.getCodeNorm();if($===Y8){this.state=AU,this.fail("XML declaration is incomplete.");return}if($$($))return;if($!==uJ)this.fail("value required.");this.state=K20}sXMLDeclValueStart(){let $=this.getCodeNorm();if($===Y8){this.state=AU,this.fail("XML declaration is incomplete.");return}if($$($))return;if(!AN($))this.fail("value must be quoted."),this.q=W20;else this.q=$;this.state=R11}sXMLDeclValue(){let $=this.captureTo([this.q,Y8]);if($===Y8){this.state=AU,this.text="",this.fail("XML declaration is incomplete.");return}if($===i4)return;let Y=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let U=Y;if(this.xmlDecl.version=U,!/^1\.[0-9]+$/.test(U))this.fail("ver
Line truncated
]`;this.ESCAPE_REGEXP=new RegExp(Y)}set headers($){this._headers=$}shouldQuote($,Y){let U=Y?this.formatterOptions.quoteHeaders:this.formatterOptions.quoteColumns;if(F21.default(U))return U;if(Array.isArray(U))return U[$];if(this._headers!==null)return U[this._headers[$]];return!1}format($,Y,U){let I=`${w21.default($)?"":$}`.replace(/\0/g,""),{formatterOptions:Q}=this;if(Q.quote!==""){if(I.indexOf(Q.quote)!==-1)return this.quoteField(I.replace(this.REPLACE_REGEXP,Q.escapedQuote))}if(I.search(this.ESCAPE_REGEXP)!==-1||this.shouldQuote(Y,U))return this.quoteField(I);return I}quoteField($){let{quote:Y}=this.formatterOptions;return`${Y}${$}${Y}`}}YK.FieldFormatter=sz0});var $u=j((az0)=>{Object.defineProperty(az0,"__esModule",{value:!0});az0.isSyncTransform=void 0;az0.isSyncTransform=($)=>$.length===1});var $G0=j((UK)=>{var ez0=UK&&UK.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(UK,"__esModule",{value:!0});UK.RowFormatter=void 0;var O21=ez0(UD()),N21=ez0(iz0()),D21=ef(),A21=$u();class gU{constructor($){if(this.rowCount=0,this.formatterOptions=$,this.fieldFormatter=new D21.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(gU.isRowHashArray($))return $.map((Y)=>Y[0]);if(Array.isArray($))return $;return Object.keys($)}static createTransform($){if(A21.isSyncTransform($))return(Y,U)=>{let I=null;try{I=$(Y)}catch(Q){return U(Q)}return U(null,I)};return(Y,U)=>{$(Y,U)}}set rowTransform($){if(!O21.default($))throw TypeError("The transform should be a function");this._rowTransform=gU.createTransform($)}format($,Y){this.callTransformer($,(U,I)=>{if(U)return Y(U);if(!$)return Y(null);let Q=[];if(I){let{shouldFormatColumns:J,headers:K}=this.checkHeaders(I);if(this.shouldWriteHeaders&&K&&!this.hasWrittenHeaders)Q.push(this.formatColumns(K,!0)),this.hasWrittenHeaders=!0;if(J){let z=this.gatherColumns(I);Q.push(this.formatColumns(z,!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=gU.gatherHeaders($);if(this.headers=Y,this.fieldFormatter.headers=Y,!this.shouldWriteHeaders)return{shouldFormatColumns:!0,headers:null};return{shouldFormatColumns:!N21.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(gU.isRowHashArray($))return this.headers.map((Y,U)=>{let I=$[U];if(I)return I[1];return""});if(gU.isRowArray($)&&!this.shouldWriteHeaders)return $;return this.headers.map((Y,U)=>$[U])}callTransformer($,Y){if(!this._rowTransform)return Y(null,$);return this._rowTransform($,Y)}formatColumns($,Y){let U=$.map((Q,J)=>this.fieldFormatter.format(Q,J,Y)).join(this.formatterOptions.delimiter),{rowCount:I}=this;if(this.rowCount+=1,I)return[this.formatterOptions.rowDelimiter,U].join("");return U}}UK.RowFormatter=gU});var YG0=j((LD)=>{Object.defineProperty(LD,"__esModule",{value:!0});LD.FieldFormatter=LD.RowFormatter=void 0;var B21=$G0();Object.defineProperty(LD,"RowFormatter",{enumerable:!0,get:function(){return B21.RowFormatter}});var P21=ef();Object.defineProperty(LD,"FieldFormatter",{enumerable:!0,get:function(){return P21.FieldFormatter}})});var Yu=j((IG0)=>{Object.defineProperty(IG0,"__esModule",{value:!0});IG0.CsvFormatterStream=void 0;var E21=K0("stream"),j21=YG0();class UG0 extends E21.Transform{constructor($){super({writableObjectMode:$.objectMode});this.hasWrittenBOM=!1,this.formatterOptions=$,this.rowFormatter=new j21.RowFormatter($),this.hasWrittenBOM=!$.writeBOM}transform($){return this.rowFormatter.rowTransform=$,this}_transform($,Y,U){let I=!1;try{if(!this.hasWrittenBOM)this.push(this.formatterOptions.BOM),this.hasWrittenBOM=!0;this.rowFormatter.format($,(Q,J)=>{if(Q)return I=!0,U(Q);if(J)J.forEach((K)=>{this.push(Buffer.from(K,"utf8"))});return I=!0,U()})}catch(Q){if(I)throw Q;U(Q)}}_flush($){this.rowFormatter.finish((Y,U)=>{if(Y)return $(Y);if(U)U.forEach((I)=>{this.push(Buffer.from(I,"utf8"))});return $()})}}IG0.CsvFormatterStream=UG0});var KG0=j((t1)=>{var JG0=t1&&t1.__createBinding||(Object.create?function($,Y,U,I){if(I===void 0)I=U;Object.defineProperty($,I,{enumerable:!0,get:function(){return Y[U]}})}:function($,Y,U,I){if(I===void 0)I=U;$[I]=Y[U]}),C21=t1&&t1.__setModuleDefault||(Object.create?function($,Y){O
Line truncated
deps:${W}}`};let I={keyword:"dependencies",type:"object",schemaType:"object",error:$.error,code(G){let[H,W]=J(G);K(G,H),z(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 K(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 w=H[V];if(w.length===0)continue;let M=(0,Q.propertyInData)(W,X,V,Z.opts.ownProperties);if(G.setParams({property:V,depsCount:w.length,deps:w.join(", ")}),Z.allErrors)W.if(M,()=>{for(let F of w)(0,Q.checkReportMissingProp)(G,F)});else W.if(Y._`${M}&&(${(0,Q.checkMissingProp)(G,w,q)})`),(0,Q.reportMissingProp)(G,q),W.else()}}$.validatePropertyDeps=K;function z(G,H=G.schema){let{gen:W,data:X,keyword:Z,it:q}=G,V=W.name("valid");for(let w in H){if((0,U.alwaysValidSchema)(q,H[w]))continue;W.if((0,Q.propertyInData)(W,X,w,q.opts.ownProperties),()=>{let M=G.subschema({keyword:Z,schemaProp:w},V);G.mergeValidEvaluated(M,V)},()=>W.var(V,!0)),G.ok(V)}}$.validateSchemaDeps=z,$.default=I}),Zc0=_0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let Y=F1(),U=S1(),Q={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:I})=>Y._`{propertyName:${I.propertyName}}`},code(I){let{gen:J,schema:K,data:z,it:G}=I;if((0,U.alwaysValidSchema)(G,K))return;let H=J.name("valid");J.forIn("key",z,(W)=>{I.setParams({propertyName:W}),I.subschema({keyword:"propertyNames",data:W,dataTypes:["string"],propertyName:W,compositeRule:!0},H),J.if((0,Y.not)(H),()=>{if(I.error(!0),!G.allErrors)J.break()})}),I.ok(H)}};$.default=Q}),U00=_0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let Y=M5(),U=F1(),Q=w5(),I=S1(),J={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:K})=>U._`{additionalProperty:${K.additionalProperty}}`},code(K){let{gen:z,schema:G,parentSchema:H,data:W,errsCount:X,it:Z}=K;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 w=(0,Y.allSchemaProperties)(H.properties),M=(0,Y.allSchemaProperties)(H.patternProperties);F(),K.ok(U._`${X}===${Q.default.errors}`);function F(){z.forIn("key",W,(T)=>{if(!w.length&&!M.length)D(T);else z.if(N(T),()=>D(T))})}function N(T){let A;if(w.length>8){let E=(0,I.schemaRefOrVal)(Z,H.properties,"properties");A=(0,Y.isOwnProperty)(z,E,T)}else if(w.length)A=(0,U.or)(...w.map((E)=>U._`${T}===${E}`));else A=U.nil;if(M.length)A=(0,U.or)(A,...M.map((E)=>U._`${(0,Y.usePattern)(K,E)}.test(${T})`));return(0,U.not)(A)}function O(T){z.code(U._`delete${W}[${T}]`)}function D(T){if(V.removeAdditional==="all"||V.removeAdditional&&G===!1){O(T);return}if(G===!1){if(K.setParams({additionalProperty:T}),K.error(),!q)z.break();return}if(typeof G=="object"&&!(0,I.alwaysValidSchema)(Z,G)){let A=z.name("valid");if(V.removeAdditional==="failing")P(T,A,!1),z.if((0,U.not)(A),()=>{K.reset(),O(T)});else if(P(T,A),!q)z.if((0,U.not)(A),()=>z.break())}}function P(T,A,E){let C={keyword:"additionalProperties",dataProp:T,dataPropType:I.Type.Str};if(E===!1)Object.assign(C,{compositeRule:!0,createErrors:!1,allErrors:!1});K.subschema(C,A)}}};$.default=J}),qc0=_0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let Y=oI(),U=M5(),Q=S1(),I=U00(),J={keyword:"properties",type:"object",schemaType:"object",code(K){let{gen:z,schema:G,parentSchema:H,data:W,it:X}=K;if(X.opts.removeAdditional==="all"&&H.additionalProperties===void 0)I.default.code(new Y.KeywordCxt(X,I.default,"additionalProperties"));let Z=(0,U.allSchemaProperties)(G);for(let F of Z)X.definedProperties.add(F);if(X.opts.unevaluated&&Z.length&&X.props!==!0)X.props=Q.mergeEvaluated.props(z,(0,Q.toHash)(Z),X.props);let q=Z.filter((F)=>!(0,Q.alwaysValidSchema)(X,G[F]));if(q.length===0)return;let V=z.name("valid");for(let F of q){if(w(F))M(F);else{if(z.if((0,U.propertyInData)(z,W,F,X.opts.ownProperties)),M(F),!X.allErrors)z.else().var(V,!0);z.endIf()}K.it.definedProperties.add(F),K.ok(V)}function w(F){return X.opts.useDefaults&&!X.compositeRule&&G[F].default!==void 0}function M(F){K.subschema({keyword:"properties",schemaProp:F,dataProp:F},V)}}};$.default=J}),Vc0=_0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let Y=M5(),U=F1(),Q=S1(),I=S1(),J={keyword:"patternProperties",type:"object",schemaType:"object",code(K){let{gen:z,schema:G,data:H,parentSchema:W,it:X}=K,{opts:Z}=X,q=(0,Y.allSchemaProperties)(G),V=q.filter((P)=>(0,Q.alwaysValidSchema)(X,G[P]));if(q.length===0||V.length===q.length&&(!X.opts.unevaluated||X.props===!0))return;let w=Z.strictSchema&&!Z.allowMatchingProperties&&W.properties,M=z.name("valid");if(X.props!==!0&&!(X.props instanceof U.Name))X.props=(0,I.evaluatedPropsToName)(z,X.props);let{props:F}=X;N();function N(){for(let P of q){if(w)O(P);if(X.allError
Line truncated
`)}openNode($,Y){let U=this.tos,Q=this._xml;if(U&&this.open)Q.push(">");this._stack.push($),Q.push("<"),Q.push($),zx(Q,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)x70(this._xml,$,Y)}addAttributes($){if(!this.open)throw Error("Cannot write attributes to node if it is not open");zx(this._xml,$)}writeText($){let Y=this._xml;if(this.open)Y.push(">"),this.open=!1;this.leaf=!1,Y.push(k70.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,U){if(this.openNode($,Y),U!==void 0)this.writeText(U);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("")}}Gx.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"};f70.exports=Gx});var Hx=j((O01)=>{var u70=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function M01($){if(typeof $==="string")return $;if(u70)return u70.decode($);return $.toString()}O01.bufferToString=M01});var d70=j((i70)=>{Object.defineProperty(i70,"__esModule",{value:!0});i70.CHAR=`
`,$=this.i;break;case u11:{let{entityReturnState:U}=this,Q=this.entity+Y.slice($,this.prevI);this.state=U;let I;if(Q==="")this.fail("empty entity name."),I="&;";else I=this.parseEntity(Q),this.entity="";if(U!==f8||this.textHandler!==void 0)this.text+=I;break $}case i4:this.entity+=Y.slice($);break $;default:}}sOpenWaka(){let $=this.getCode();if(pW($))this.state=g11,this.unget(),this.xmlDeclPossible=!1;else switch($){case DN:this.state=x11,this.xmlDeclPossible=!1;break;case q20:this.state=P11,this.openWakaBang="",this.xmlDeclPossible=!1;break;case Y8:this.state=R11;break;default:this.fail("disallowed character in tag name"),this.state=f8,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=Ox,this.openWakaBang="";break;case"--":this.state=Mx,this.openWakaBang="";break;case"DOCTYPE":if(this.state=Lx,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(NN))this.state=T11}sCommentEnding(){var $;let Y=this.getCodeNorm();if(Y===NN)this.state=E11,($=this.commentHandler)===null||$===void 0||$.call(this,this.text),this.text="";else this.text+=`-${String.fromCodePoint(Y)}`,this.state=Mx}sCommentEnded(){let $=this.getCodeNorm();if($!==_6)this.fail("malformed comment."),this.text+=`--${String.fromCodePoint($)}`,this.state=Mx;else this.state=f8}sCData(){if(this.captureToChar(bJ))this.state=j11}sCDataEnding(){let $=this.getCodeNorm();if($===bJ)this.state=C11;else this.text+=`]${String.fromCodePoint($)}`,this.state=Ox}sCDataEnding2(){var $;let Y=this.getCodeNorm();switch(Y){case _6:{($=this.cdataHandler)===null||$===void 0||$.call(this,this.text),this.text="",this.state=f8;break}case bJ:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(Y)}`,this.state=Ox}}sPIFirstChar(){let $=this.getCodeNorm();if(this.nameStartCheck($))this.piTarget+=String.fromCodePoint($),this.state=K20;else if($===Y8||$$($))this.fail("processing instruction without a target."),this.state=$===Y8?ON:Nx;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint($),this.state=K20}sPIRest(){let{chunk:$,i:Y}=this;while(!0){let U=this.getCodeNorm();if(U===i4){this.piTarget+=$.slice(Y);return}if(!this.nameCheck(U)){this.piTarget+=$.slice(Y,this.prevI);let Q=U===Y8;if(Q||$$(U))if(this.piTarget==="xml"){if(!this.xmlDeclPossible)this.fail("an XML declaration must be at the start of the document.");this.state=Q?AU:z20}else this.state=Q?ON:Nx;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(U);break}}}sPIBody(){if(this.text.length===0){let $=this.getCodeNorm();if($===Y8)this.state=ON;else if(!$$($))this.text=String.fromCodePoint($)}else if(this.captureToChar(Y8))this.state=ON}sPIEnding(){var $;let Y=this.getCodeNorm();if(Y===_6){let{piTarget:U}=this;if(U.toLowerCase()==="xml")this.fail("the XML declaration must appear at the start of the document.");($=this.piHandler)===null||$===void 0||$.call(this,{target:U,body:this.text}),this.piTarget=this.text="",this.state=f8}else if(Y===Y8)this.text+="?";else this.text+=`?${String.fromCodePoint(Y)}`,this.state=Nx;this.xmlDeclPossible=!1}sXMLDeclNameStart(){let $=this.skipSpaces();if($===Y8){this.state=AU;return}if($!==i4)this.state=_11,this.name=String.fromCodePoint($)}sXMLDeclName(){let $=this.captureTo(c11);if($===Y8){this.state=AU,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(!($$($)||$===uJ))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(`expectedthename${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expectedoneof${this.xmlDeclExpects.join(", ")}`)}this.state=$===uJ?G20:v11}sXMLDeclEq(){let $=this.getCodeNorm();if($===Y8){this.state=AU,this.fail("XML declaration is incomplete.");return}if($$($))return;if($!==uJ)this.fail("value required.");this.state=G20}sXMLDeclValueStart(){let $=this.getCodeNorm();if($===Y8){this.state=AU,this.fail("XML declaration is incomplete.");return}if($$($))return;if(!AN($))this.fail("value must be quoted."),this.q=Z20;else this.q=$;this.state=S11}sXMLDeclValue(){let $=this.captureTo([this.q,Y8]);if($===Y8){this.state=AU,this.text="",this.fail("XML declaration is incomplete.");return}if($===i4)return;let Y=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let U=Y;if(this.xmlDecl.version=U,!/^1\.[0-9]+$/.test(U))this.fail("ver
Line truncated
See:https://github.com/isaacs/node-glob/issues/167`);return new v6($,Y).found}function v6($,Y){if(!$)throw Error("must provide pattern");if(typeof Y==="function"||arguments.length===3)throw TypeError(`callback provided to sync glob
`+Z0[B0-1];break}}}var B1="a promise was created in a "+S+"handler "+W0+"but was not returned from it, see http://goo.gl/rRqMUw"+J0;u._warn(B1,!0,B)}}function g(Q0,B){var S=Q0+" is deprecated and will be removed in a future version.";if(B)S+=" Use "+B+" instead.";return c(S)}function c(Q0,B,S){if(!D0.warnings)return;var u=new Q(Q0),s;if(B)S._attachExtraTrace(u);else if(D0.longStackTraces&&(s=$._peekContext()))s.attachExtraTrace(u);else{var W0=r0(u);u.stack=W0.message+`
`+Z0[B0-1];break}}}var B1="a promise was created in a "+S+"handler "+W0+"but was not returned from it, see http://goo.gl/rRqMUw"+J0;u._warn(B1,!0,B)}}function y(I0,B){var S=I0+" is deprecated and will be removed in a future version.";if(B)S+=" Use "+B+" instead.";return c(S)}function c(I0,B,S){if(!D0.warnings)return;var u=new I(I0),s;if(B)S._attachExtraTrace(u);else if(D0.longStackTraces&&(s=$._peekContext()))s.attachExtraTrace(u);else{var W0=r0(u);u.stack=W0.message+`
`);var M=Object(w).yieldHandler,F=q,N=Error().stack;return function(){var O=V.apply(this,arguments),D=new F(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 z("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(`generatorFunctionmustbeafunction
`)},Y=function(){return new h.PromiseInspection(this._target())},U=function(k){return h.reject(new X(k))};function I(){}var Q={},J=N4(),K;if(J.isNode)K=function(){var k=process.domain;if(k===void 0)k=null;return k};else K=function(){return null};J.notEnumerableProp(h,"_getDomain",K);var z=KI(),G=Tw0(),H=new G;z.defineProperty(h,"_async",{value:H});var W=f3(),X=h.TypeError=W.TypeError;h.RangeError=W.RangeError;var Z=h.CancellationError=W.CancellationError;h.TimeoutError=W.TimeoutError,h.OperationalError=W.OperationalError,h.RejectionError=W.OperationalError,h.AggregateError=W.AggregateError;var q=function(){},V={},w={},M=_w0()(h,q),F=Sw0()(h,q,M,U,I),N=yw0()(h),O=N.create,D=kw0()(h,N),P=D.CapturedTrace,T=fw0()(h,M),A=bw0()(w),E=dc(),C=J.errorObj,i=J.tryCatch;function x(k,m){if(typeof m!=="function")throw new X("expecting a function but got "+J.classString(m));if(k.constructor!==h)throw new X(`thepromiseconstructorcannotbeinvokeddirectly
`)},Y=function(){return new h.PromiseInspection(this._target())},U=function(k){return h.reject(new X(k))};function Q(){}var I={},J=N4(),K;if(J.isNode)K=function(){var k=process.domain;if(k===void 0)k=null;return k};else K=function(){return null};J.notEnumerableProp(h,"_getDomain",K);var z=KQ(),G=jw0(),H=new G;z.defineProperty(h,"_async",{value:H});var W=f3(),X=h.TypeError=W.TypeError;h.RangeError=W.RangeError;var Z=h.CancellationError=W.CancellationError;h.TimeoutError=W.TimeoutError,h.OperationalError=W.OperationalError,h.RejectionError=W.OperationalError,h.AggregateError=W.AggregateError;var q=function(){},V={},w={},M=Sw0()(h,q),F=gw0()(h,q,M,U,Q),N=kw0()(h),O=N.create,D=fw0()(h,N),P=D.CapturedTrace,T=bw0()(h,M),A=cw0()(w),E=mc(),C=J.errorObj,i=J.tryCatch;function x(k,m){if(typeof m!=="function")throw new X("expecting a function but got "+J.classString(m));if(k.constructor!==h)throw new X(`thepromiseconstructorcannotbeinvokeddirectly
Seehttp://goo.gl/MqrFmX
`)}function h(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)}h.prototype.toString=function(){return"[object Promise]"},h.prototype.caught=h.prototype.catch=function(k){var m=arguments.length;if(m>1){var t=Array(m-1),$0=0,y;for(y=0;y<m-1;++y){var p=arguments[y];if(J.isObject(p))t[$0++]=p;else return U("expecting an object but got A catch statement predicate "+J.classString(p))}return t.length=$0,k=arguments[y],this.then(void 0,A(t,k,this))}return this.then(void 0,k)},h.prototype.reflect=function(){return this._then(Y,Y,void 0,this,void 0)},h.prototype.then=function(k,m){if(D.warnings()&&arguments.length>0&&typeof k!=="function"&&typeof m!=="function"){var t=".then() only accepts functions but was passed: "+J.classString(k);if(arguments.length>1)t+=", "+J.classString(m);this._warn(t)}return this._then(k,m,void 0,void 0,void 0)},h.prototype.done=function(k,m){var t=this._then(k,m,void 0,void 0,void 0);t._setIsFinal()},h.prototype.spread=function(k){if(typeof k!=="function")return U("expecting a function but got "+J.classString(k));return this.all()._then(k,void 0,void 0,V,void 0)},h.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},h.prototype.all=function(){if(arguments.length>0)this._warn(".all() was passed arguments but it does not take any");return new F(this).promise()},h.prototype.error=function(k){return this.caught(J.originatesFromRejection,k)},h.getNewLibraryCopy=mc.exports,h.is=function(k){return k instanceof h},h.fromNode=h.fromCallback=function(k){var m=new h(q);m._captureStackTrace();var t=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,$0=i(k)(E(m,t));if($0===C)m._rejectCallback($0.e,!0);if(!m._isFateSealed())m._setAsyncGuaranteed();return m},h.all=function(k){return new F(k).promise()},h.cast=function(k){var m=M(k);if(!(m instanceof h))m=new h(q),m._captureStackTrace(),m._setFulfilled(),m._rejectionHandler0=k;return m},h.resolve=h.fulfilled=h.cast,h.reject=h.rejected=function(k){var m=new h(q);return m._captureStackTrace(),m._rejectCallback(k,!0),m},h.setScheduler=function(k){if(typeof k!=="function")throw new X("expecting a function but got "+J.classString(k));return H.setScheduler(k)},h.prototype._then=function(k,m,t,$0,y){var p=y!==void 0,Y0=p?y:new h(q),g=this._target(),c=g._bitField;if(!p){if(Y0._propagateFrom(this,3),Y0._captureStackTrace(),$0===void 0&&(this._bitField&2097152)!==0)if((c&50397184)!==0)$0=this._boundValue();else $0=g===this?void 0:this._boundTo;this._fireEvent("promiseChained",this,Y0)}var e=K();if((c&50397184)!==0){var V0,j0,A0=g._settlePromiseCtx;if((c&33554432)!==0)j0=g._rejectionHandler0,V0=k;else if((c&16777216)!==0)j0=g._fulfillmentHandler0,V0=m,g._unsetRejectionIsUnhandled();else A0=g._settlePromiseLateCancellationObserver,j0=new Z("late cancellation observer"),g._attachExtraTrace(j0),V0=m;H.invoke(A0,g,{handler:e===null?V0:typeof V0==="function"&&J.domainBind(e,V0),promise:Y0,receiver:$0,value:j0})}else g._addCallbacks(k,m,Y0,$0,e);return Y0},h.prototype._length=function(){return this._bitField&65535},h.prototype._isFateSealed=function(){return(this._bitField&117506048)!==0},h.prototype._isFollowing=function(){return(this._bitField&67108864)===67108864},h.prototype._setLength=function(k){this._bitField=this._bitField&-65536|k&65535},h.prototype._setFulfilled=function(){this._bitField=this._bitField|33554432,this._fireEvent("promiseFulfilled",this)},h.prototype._setRejected=function(){this._bitField=this._bitField|16777216,this._fireEvent("promiseRejected",this)},h.prototype._setFollowing=function(){this._bitField=this._bitField|67108864,this._fireEvent("promiseResolved",this)},h.prototype._setIsFinal=function(){this._bitField=this._bitField|4194304},h.prototype._isFinal=function(){return(this._bitField&4194304)>0},h.prototype._unsetCancelled=function(){this._bitField=this._bitField&-65537},h.prototype._setCancelled=function(){this._bitField=this._bitField|65536,this._fireEvent("promiseCancelled",this)},h.prototype._setWillBeCancelled=function(){this._bitField=this._bitField|8388608},h.prototype._setAsyncGuaranteed=function(){if(H.hasCustomScheduler())return;this._bitField=this._bitField|134217728},h.prototype._receiverAt=function(k){var m=k===0?this._receiver0:this[k*4-4+3];if(m===Q)return;else if(m===void 0&&this._isBound())return this._boundValue();return m},h.prototype._promiseAt=function(k){return this[k*4-4+2]},h.prototype._fulfillmentHandlerAt=function(k){return this[k*4-4+0]},h.prototype._rejectionHandlerAt=function(k){return this[k*4-4+1]},h.prototype._boundValue=function(){},h.prototype._migrateCallback0=function(k){var{_bitField:m,_fulfillmentHand
Line truncated
`)}function h(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)}h.prototype.toString=function(){return"[object Promise]"},h.prototype.caught=h.prototype.catch=function(k){var m=arguments.length;if(m>1){var a=Array(m-1),$0=0,g;for(g=0;g<m-1;++g){var p=arguments[g];if(J.isObject(p))a[$0++]=p;else return U("expecting an object but got A catch statement predicate "+J.classString(p))}return a.length=$0,k=arguments[g],this.then(void 0,A(a,k,this))}return this.then(void 0,k)},h.prototype.reflect=function(){return this._then(Y,Y,void 0,this,void 0)},h.prototype.then=function(k,m){if(D.warnings()&&arguments.length>0&&typeof k!=="function"&&typeof m!=="function"){var a=".then() only accepts functions but was passed: "+J.classString(k);if(arguments.length>1)a+=", "+J.classString(m);this._warn(a)}return this._then(k,m,void 0,void 0,void 0)},h.prototype.done=function(k,m){var a=this._then(k,m,void 0,void 0,void 0);a._setIsFinal()},h.prototype.spread=function(k){if(typeof k!=="function")return U("expecting a function but got "+J.classString(k));return this.all()._then(k,void 0,void 0,V,void 0)},h.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},h.prototype.all=function(){if(arguments.length>0)this._warn(".all() was passed arguments but it does not take any");return new F(this).promise()},h.prototype.error=function(k){return this.caught(J.originatesFromRejection,k)},h.getNewLibraryCopy=oc.exports,h.is=function(k){return k instanceof h},h.fromNode=h.fromCallback=function(k){var m=new h(q);m._captureStackTrace();var a=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,$0=i(k)(E(m,a));if($0===C)m._rejectCallback($0.e,!0);if(!m._isFateSealed())m._setAsyncGuaranteed();return m},h.all=function(k){return new F(k).promise()},h.cast=function(k){var m=M(k);if(!(m instanceof h))m=new h(q),m._captureStackTrace(),m._setFulfilled(),m._rejectionHandler0=k;return m},h.resolve=h.fulfilled=h.cast,h.reject=h.rejected=function(k){var m=new h(q);return m._captureStackTrace(),m._rejectCallback(k,!0),m},h.setScheduler=function(k){if(typeof k!=="function")throw new X("expecting a function but got "+J.classString(k));return H.setScheduler(k)},h.prototype._then=function(k,m,a,$0,g){var p=g!==void 0,Y0=p?g:new h(q),y=this._target(),c=y._bitField;if(!p){if(Y0._propagateFrom(this,3),Y0._captureStackTrace(),$0===void 0&&(this._bitField&2097152)!==0)if((c&50397184)!==0)$0=this._boundValue();else $0=y===this?void 0:this._boundTo;this._fireEvent("promiseChained",this,Y0)}var e=K();if((c&50397184)!==0){var V0,j0,A0=y._settlePromiseCtx;if((c&33554432)!==0)j0=y._rejectionHandler0,V0=k;else if((c&16777216)!==0)j0=y._fulfillmentHandler0,V0=m,y._unsetRejectionIsUnhandled();else A0=y._settlePromiseLateCancellationObserver,j0=new Z("late cancellation observer"),y._attachExtraTrace(j0),V0=m;H.invoke(A0,y,{handler:e===null?V0:typeof V0==="function"&&J.domainBind(e,V0),promise:Y0,receiver:$0,value:j0})}else y._addCallbacks(k,m,Y0,$0,e);return Y0},h.prototype._length=function(){return this._bitField&65535},h.prototype._isFateSealed=function(){return(this._bitField&117506048)!==0},h.prototype._isFollowing=function(){return(this._bitField&67108864)===67108864},h.prototype._setLength=function(k){this._bitField=this._bitField&-65536|k&65535},h.prototype._setFulfilled=function(){this._bitField=this._bitField|33554432,this._fireEvent("promiseFulfilled",this)},h.prototype._setRejected=function(){this._bitField=this._bitField|16777216,this._fireEvent("promiseRejected",this)},h.prototype._setFollowing=function(){this._bitField=this._bitField|67108864,this._fireEvent("promiseResolved",this)},h.prototype._setIsFinal=function(){this._bitField=this._bitField|4194304},h.prototype._isFinal=function(){return(this._bitField&4194304)>0},h.prototype._unsetCancelled=function(){this._bitField=this._bitField&-65537},h.prototype._setCancelled=function(){this._bitField=this._bitField|65536,this._fireEvent("promiseCancelled",this)},h.prototype._setWillBeCancelled=function(){this._bitField=this._bitField|8388608},h.prototype._setAsyncGuaranteed=function(){if(H.hasCustomScheduler())return;this._bitField=this._bitField|134217728},h.prototype._receiverAt=function(k){var m=k===0?this._receiver0:this[k*4-4+3];if(m===I)return;else if(m===void 0&&this._isBound())return this._boundValue();return m},h.prototype._promiseAt=function(k){return this[k*4-4+2]},h.prototype._fulfillmentHandlerAt=function(k){return this[k*4-4+0]},h.prototype._rejectionHandlerAt=function(k){return this[k*4-4+1]},h.prototype._boundValue=function(){},h.prototype._migrateCallback0=function(k){var{_bitField:m,_fulfillmentHand
Line truncated
`,{mode:384}),Y}function gd($){let Y=WB0();for(let U of Y){if(!T$(U))continue;for(let I of XP(U).filter((Q)=>Q.endsWith(".json")).filter((Q)=>!Q.startsWith("example."))){let Q=y9(U,I);try{let J=qP(Q,"utf-8"),K=JSON.parse(J);if(K&&typeof K==="object"&&K.id===$)return Q}catch{}}}return}function g9($,Y){let U=gd($);if(!U)throw Error(`Enterpriseconfignotfound:${$}`);let Q={...JSON.parse(qP(U,"utf-8")),...Y};for(let K of Object.keys(Y))if(Y[K]===void 0)delete Q[K];let J=dZ.parse(Q);return QB0(U,`${JSON.stringify(J,null,2)}
`,"utf-8"),J}var yd="SEAL_USE_ENTERPRISES_DIR",JB0="SEAL_HOME_ENTERPRISES_DIR",KB0="SEAL_USE_USER_ENTERPRISES_DIR",zB0="SEAL_HOME_USER_ENTERPRISES_DIR",GB0="SEAL_USE_CONFIG_FILE",HB0="SEAL_HOME_CONFIG_FILE",Xz,ZP,WP,UB0;var t$=o(()=>{HP();Xz=y9(VP(),".config","seal-use","enterprises"),ZP=y9(VP(),".config","seal-home","enterprises"),WP=y9(VP(),".config","seal-use","config.json"),UB0=y9(VP(),".config","seal-home","config.json")});function r2($,Y,U=[]){let I=Y.corpId?.trim()||void 0,Q=Y.stateful?Y.defaultCorpId?.trim()||void 0:void 0,J=I??Q;if(J){let z=$.find((W)=>W.id===J);if(z)return z;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(`Noenterpriseconfigfoundfor${J}`)}if(!Y.stateful)throw Error("Stateless mode is enabled. Every enterprise command requires --corp <corpId>. Use `seal-useconfigmodestateful` to enable a default enterprise.");let K=$[0];if(K)return K;throw Error("No enterprise config found. Add a non-example JSON file under one of: "+(U.length?U.join(", "):"the configured enterprise directories"))}import{existsSync as kd,mkdirSync as uA1,readFileSync as bA1,renameSync as iA1,unlinkSync as cA1,writeFileSync as nA1}from"node:fs";import{homedir as dA1}from"node:os";import{dirname as pA1,join as mA1}from"node:path";function mZ(){let $=process.env[lA1]?.trim();if($)return $;return oA1}function ZB0($=new Date){return $.toISOString().slice(0,10)}function qB0($=xd,Y=new Date){let U=Y.getTime()-Math.max(0,$-1)*86400000;return new Date(U).toISOString().slice(0,10)}function VB0($=mZ()){if(!kd($))return{};try{let Y=bA1($,"utf-8"),U=JSON.parse(Y);if(U&&typeof U==="object"&&!Array.isArray(U))return U;return{}}catch{return{}}}function rA1($,Y){let U={};for(let[I,Q]of Object.entries($)){if(!Q||typeof Q!=="object")continue;let J={},K=!1;for(let[z,G]of Object.entries(Q))if(typeof G==="number"&&G>0&&z>=Y)J[z]=G,K=!0;if(K)U[I]=J}return U}function sA1($,Y=mZ()){let U=pA1(Y);if(!kd(U))uA1(U,{recursive:!0,mode:448});let I=`${Y}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2,8)}.tmp`;try{nA1(I,JSON.stringify($,null,2),{encoding:"utf-8",mode:384}),iA1(I,Y)}catch(Q){try{if(kd(I))cA1(I)}catch{}throw Q}}function LB0($,Y=new Date){if(!$||typeof $!=="string")return;try{let U=mZ(),I=VB0(U),Q=ZB0(Y),J=qB0(xd,Y),K=rA1(I,J);K[$]=K[$]||{},K[$][Q]=(K[$][Q]??0)+1,sA1(K,U)}catch{}}function aA1($,Y=xd,U=new Date){let I=new Map;try{let Q=VB0(),J=qB0(Y,U),K=ZB0(U),z=$??Object.keys(Q);for(let G of z){let H=Q[G];if(!H){I.set(G,0);continue}let W=0;for(let[X,Z]of Object.entries(H))if(X>=J&&X<=K&&typeof Z==="number")W+=Z;I.set(G,W)}}catch{if($)for(let Q of $)I.set(Q,0)}return I}function FB0($,Y,U){let I=U??aA1($.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 K=I.get(Q.id)??0,z=I.get(J.id)??0;if(K!==z)return z-K;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 lA1="SEAL_USE_USAGE_FILE",oA1,xd=7;var LP=o(()=>{oA1=mA1(dA1(),".config","seal-use","usage.json")});var H8={};L8(H8,{withApprovalRunFilters:()=>AB1,toDate:()=>rd,timestampOf:()=>bd,summarizeSimulationBatch:()=>JB1,summarizeRunBridge:()=>WB1,summarizeRuleVersion:()=>XB1,summarizeApprovalRuns:()=>KB1,summarizeApprovalRunResult:()=>NP,summarizeApprovalRunDocument:()=>AB0,summarizeApprovalRunDetail:()=>GB1,summarizeApprovalRun:()=>tZ,stringifyHumanResultValue:()=>od,stringFromUnknown:()=>q4,setPath:()=>BB0,scalarIncludes:()=>wP,runtimeRuleIndex:()=>LB1,runtimeRuleIdToCode:()=>jB0,rulesHaveSameContent:()=>OB0,ruleChangedFields:()=>NB0,resolveSealBaseUrl:()=>MB1,resolveRuleVersionSelector:()=>DB1,resolveRuleVersionForLookup:()=>ZB1,resolveRuleVersion:()=>id,resolveManualApprovalStatus:()=>RB0,resolveApprovalRunForUrl:()=>wB1,redactPreviewValue:()=>rZ,redactIntegrationSecrets:()=>UB1,projectApprovalRules:()=>eA1,presentWebhookIntegration:()=>tA1,prepareApprovalRuns:()=>BB1,pickRunFields:()=>DB0,pickRuleFields:()=>MB0,pickApprovalRuns:()=>NB1,pickApprovalRunCandidate:()=>FB1,parseRuleCodeNumber:()=>z$,parseFieldPaths:()=>zB1,parseDurationMs:()=>YB1,objectContainsScalar:()=>MP,numberFromUnknown:()=>PB0,normalizeUrl:()=>OB1,normalizeRuleStrictness:()=>pd,normalizeRuleCode:()=>oZ,mutationPreview:()=>IB1,matchesRunLookup:()=>TB1,localParts:()=>sd,localDateKey:()=>EB1,isHumanResultKey:()=>cd,getPath:()=>e$,getConfiguredSealBaseUrl:()=>wB0,formatRuleCode:()=>a2,formatLocalDateTime:()=>dd,flattenDocumentFields:()=>TB0,firstPath:()=>sZ,firstByLabel:()=>lZ,findRuleInVersion:()=>VB1,findRuleInDraft:()=>qB1,findKeywordLines:()=>ud,findHumanResultValue:()=>OP,filterRunsByHumanResult:()=>CB0,filterRuns:()=>ld,extractHumanResult:()=>BI,extractCitedRules:()=>HB1,countPathCandidates:()=>fd,countBy:()=>nd,compactObject:()=>s2,collectInvoiceSummary:()=>EB0,collectInvoiceObjects:()=>aZ,collectDocumentFields:()=>FP,buildSimulationBatchParams:()=>QB1,
Line truncated
`)}function lB0($){return{id:$.id,versionNumber:$.versionNumber,versionName:$.versionName,publishedAt:$.publishedAt}}function oB0($,Y){let U=new Map;for(let I of $.rules){let Q=eZ(I),J=Y==="stable-id"?sB0(Q):$q(Q.code??Q.ruleCode);if(!J)throw Error(`Ruleversion${$.versionNumber}containsarulewithouta${Y==="stable-id"?"stable rule ID":"code"}.`);if(U.has(J))throw Error(`Ruleversion${$.versionNumber}containsduplicate${Y==="stable-id"?"stable rule ID":"code"}:${J}`);U.set(J,Q)}return U}function mB1($,Y,U){if(U!=="auto")return U;if([...$.rules,...Y.rules].every((J)=>Boolean(sB0(J))))return"stable-id";if([...$.rules,...Y.rules].every((J)=>Boolean($q(eZ(J).code??eZ(J).ruleCode))))return"code";throw Error("Rule snapshots have neither a complete stable-ID mapping nor a complete code mapping.")}function aB0($,Y,U={}){let I=mB1($,Y,U.identityMode??"auto"),Q=oB0($,I),J=oB0(Y,I),K=[...new Set([...Q.keys(),...J.keys()])],z=[],G={added:0,removed:0,modified:0,unchanged:0},H=lB0($),W=lB0(Y);for(let Z of K){let q=Q.get(Z),V=J.get(Z),w=q?PI(q,I):void 0,M=V?PI(V,I):void 0,F=!q?"added":!V?"removed":JSON.stringify(w)!==JSON.stringify(M)?"modified":"unchanged";if(G[F]+=1,F==="unchanged"&&!U.includeUnchanged)continue;let N=F==="modified"?[...new Set([...Object.keys(w??{}),...Object.keys(M??{})])].filter((O)=>JSON.stringify(w?.[O])!==JSON.stringify(M?.[O])):void 0;z.push({status:F,ruleId:Z,identityMode:I,...q?{before:q}:{},...V?{after:V}:{},...N?.length?{changedFields:N}:{},...F!=="unchanged"?{diff:pB1(Z,H,W,q,V,I)}:{}})}let X={from:H,to:W,identityMode:I,counts:G,changes:z,unifiedDiff:z.filter((Z)=>Z.diff).map((Z)=>Z.diff).join(`
`)};if(I==="code"){let Z=K.filter((P)=>Q.has(P)&&J.has(P)).length,q=K.filter((P)=>Q.has(P)&&J.has(P)&&JSON.stringify(PI(Q.get(P),"code"))===JSON.stringify(PI(J.get(P),"code"))).length,V=Q.size,w=J.size,M=Math.min(V,w)?Z/Math.min(V,w):1,F=new Map;for(let[P,T]of Q)F.set(JSON.stringify(PI(T,"code")),P);let N=0;for(let[P,T]of J){let A=F.get(JSON.stringify(PI(T,"code")));if(A&&A!==P)N+=1}let D=(Math.min(V,w)?q/Math.min(V,w):1)>=0.5?"high":q>0||N>0?"ambiguous":"low";X.codeStats={oldCount:V,newCount:w,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 ed($,Y=20000,U=!1){if(U||$.unifiedDiff.length<=Y)return{...$,truncation:{truncated:!1,maxChars:Y,omittedChars:0,hint:"Use --full only when the complete diff is required."}};let I=$.unifiedDiff.length-Y,Q=`
...[difftruncated:${I}charactersomitted;rerunwith--fullforthecompletediff]`,J=$.changes.map(({before:K,after:z,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:I,hint:"Use --full for the complete diff."}}}var rB0,nB1;var tB0=o(()=>{rB0=["id","ruleId","stableId"],nB1=new Set([...rB0,"runtimeRuleId","runtimeId","tenantId","createdAt","updatedAt","versionId","versionNumber"])});import{existsSync as lB1,mkdirSync as oB1,readFileSync as rB1,renameSync as sB1,writeFileSync as aB1}from"node:fs";import{homedir as tB1}from"node:os";import{join as eB0}from"node:path";function Yq($){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 PP($){return JSON.stringify([$.description??"",$.scope??"",$.strictness??""])}function $P0(){return process.env.SEAL_USE_RULE_VERSION_SNAPSHOTS_DIR?.trim()||eB0(tB1(),".config","seal-use","rule-version-snapshots")}function eB1($){return $.replace(/[^a-zA-Z0-9._-]/g,"_")}function YP0($,Y){return eB0($P0(),`${eB1($)}-v${Y}.json`)}function Uq($,Y,U){let I=new Map,Q=new Map;for(let W of U){let X=Yq(W.code);if(X)I.set(X,[...I.get(X)??[],W]);let Z=PP(W);Q.set(Z,[...Q.get(Z)??[],W])}let J=[];for(let W of Y.rules??[]){let X=Yq(W.code),Z=X?I.get(X)??[]:[],q=Q.get(PP(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 K={corpId:$,versionId:Y.id,versionNumber:Y.versionNumber,capturedAt:A1(),rules:J},z=$P0();oB1(z,{recursive:!0,mode:448});let G=YP0($,Y.versionNumber),H=`${G}.${process.pid}.tmp`;return aB1(H,`${JSON.stringify(K,null,2)}
`,{mode:384}),Y}function xd($){let Y=ZB0();for(let U of Y){if(!T$(U))continue;for(let Q of XP(U).filter((I)=>I.endsWith(".json")).filter((I)=>!I.startsWith("example."))){let I=g9(U,Q);try{let J=qP(I,"utf-8"),K=JSON.parse(J);if(K&&typeof K==="object"&&K.id===$)return I}catch{}}}return}function y9($,Y){let U=xd($);if(!U)throw Error(`Enterpriseconfignotfound:${$}`);let I={...JSON.parse(qP(U,"utf-8")),...Y};for(let K of Object.keys(Y))if(Y[K]===void 0)delete I[K];let J=dZ.parse(I);return KB0(U,`${JSON.stringify(J,null,2)}
`,"utf-8"),J}var kd="SEAL_USE_ENTERPRISES_DIR",zB0="SEAL_HOME_ENTERPRISES_DIR",GB0="SEAL_USE_USER_ENTERPRISES_DIR",HB0="SEAL_HOME_USER_ENTERPRISES_DIR",WB0="SEAL_USE_CONFIG_FILE",XB0="SEAL_HOME_CONFIG_FILE",Xz,ZP,WP,IB0;var a$=o(()=>{HP();Xz=g9(VP(),".config","seal-use","enterprises"),ZP=g9(VP(),".config","seal-home","enterprises"),WP=g9(VP(),".config","seal-use","config.json"),IB0=g9(VP(),".config","seal-home","config.json")});function r2($,Y,U=[]){let Q=Y.corpId?.trim()||void 0,I=Y.stateful?Y.defaultCorpId?.trim()||void 0:void 0,J=Q??I;if(J){let z=$.find((W)=>W.id===J);if(z)return z;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(`Noenterpriseconfigfoundfor${J}`)}if(!Y.stateful)throw Error("Stateless mode is enabled. Every enterprise command requires --corp <corpId>. Use `seal-useconfigmodestateful` to enable a default enterprise.");let K=$[0];if(K)return K;throw Error("No enterprise config found. Add a non-example JSON file under one of: "+(U.length?U.join(", "):"the configured enterprise directories"))}import{existsSync as fd,mkdirSync as cA1,readFileSync as nA1,renameSync as dA1,unlinkSync as pA1,writeFileSync as mA1}from"node:fs";import{homedir as lA1}from"node:os";import{dirname as oA1,join as rA1}from"node:path";function mZ(){let $=process.env[sA1]?.trim();if($)return $;return tA1}function VB0($=new Date){return $.toISOString().slice(0,10)}function LB0($=ud,Y=new Date){let U=Y.getTime()-Math.max(0,$-1)*86400000;return new Date(U).toISOString().slice(0,10)}function FB0($=mZ()){if(!fd($))return{};try{let Y=nA1($,"utf-8"),U=JSON.parse(Y);if(U&&typeof U==="object"&&!Array.isArray(U))return U;return{}}catch{return{}}}function aA1($,Y){let U={};for(let[Q,I]of Object.entries($)){if(!I||typeof I!=="object")continue;let J={},K=!1;for(let[z,G]of Object.entries(I))if(typeof G==="number"&&G>0&&z>=Y)J[z]=G,K=!0;if(K)U[Q]=J}return U}function eA1($,Y=mZ()){let U=oA1(Y);if(!fd(U))cA1(U,{recursive:!0,mode:448});let Q=`${Y}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2,8)}.tmp`;try{mA1(Q,JSON.stringify($,null,2),{encoding:"utf-8",mode:384}),dA1(Q,Y)}catch(I){try{if(fd(Q))pA1(Q)}catch{}throw I}}function wB0($,Y=new Date){if(!$||typeof $!=="string")return;try{let U=mZ(),Q=FB0(U),I=VB0(Y),J=LB0(ud,Y),K=aA1(Q,J);K[$]=K[$]||{},K[$][I]=(K[$][I]??0)+1,eA1(K,U)}catch{}}function $B1($,Y=ud,U=new Date){let Q=new Map;try{let I=FB0(),J=LB0(Y,U),K=VB0(U),z=$??Object.keys(I);for(let G of z){let H=I[G];if(!H){Q.set(G,0);continue}let W=0;for(let[X,Z]of Object.entries(H))if(X>=J&&X<=K&&typeof Z==="number")W+=Z;Q.set(G,W)}}catch{if($)for(let I of $)Q.set(I,0)}return Q}function MB0($,Y,U){let Q=U??$B1($.map((I)=>I.id));return[...$].sort((I,J)=>{if(Y){if(I.id===Y&&J.id!==Y)return-1;if(J.id===Y&&I.id!==Y)return 1}let K=Q.get(I.id)??0,z=Q.get(J.id)??0;if(K!==z)return z-K;let G=I.name??I.id,H=J.name??J.id,W=G.localeCompare(H,"zh-CN");if(W!==0)return W;return I.id.localeCompare(J.id)})}var sA1="SEAL_USE_USAGE_FILE",tA1,ud=7;var LP=o(()=>{tA1=rA1(lA1(),".config","seal-use","usage.json")});var H8={};L8(H8,{withApprovalRunFilters:()=>jB1,toDate:()=>td,timestampOf:()=>cd,summarizeSimulationBatch:()=>GB1,summarizeRunBridge:()=>LB1,summarizeRuleVersion:()=>FB1,summarizeApprovalRuns:()=>XB1,summarizeApprovalRunResult:()=>DP,summarizeApprovalRunDocument:()=>EB0,summarizeApprovalRunDetail:()=>qB1,summarizeApprovalRun:()=>aZ,stringifyHumanResultValue:()=>sd,stringFromUnknown:()=>q4,simulationBatchCreatedAtMs:()=>PB0,setPath:()=>jB0,scalarIncludes:()=>MP,runtimeRuleIndex:()=>NB1,runtimeRuleIdToCode:()=>vB0,rulesHaveSameContent:()=>AB0,ruleChangedFields:()=>BB0,resolveSealBaseUrl:()=>BB1,resolveRuleVersionSelector:()=>EB1,resolveRuleVersionForLookup:()=>wB1,resolveRuleVersion:()=>nd,resolveManualApprovalStatus:()=>hB0,resolveApprovalRunForUrl:()=>AB1,redactPreviewValue:()=>rZ,redactIntegrationSecrets:()=>JB1,projectApprovalRules:()=>UB1,presentWebhookIntegration:()=>YB1,prepareApprovalRuns:()=>CB1,pickRunFields:()=>TB0,pickRuleFields:()=>DB0,pickApprovalRuns:()=>TB1,pickApprovalRunCandidate:()=>DB1,parseRuleCodeNumber:()=>z$,parseFieldPaths:()=>ZB1,parseDurationMs:()=>IB1,objectContainsScalar:()=>OP,numberFromUnknown:()=>CB0,normalizeUrl:()=>PB1,normalizeRuleStrictness:()=>ld,normalizeRuleCode:()=>oZ,mutationPreview:()=>KB1,matchesRunLookup:()=>_B1,localParts:()=>ad,localDateKey:()=>vB1,isHumanResultKey:()=>dd,getPath:()=>e$,getConfiguredSealBaseUrl:()=>NB0,formatRuleCode:()=>t2,formatLocalDateTime:()=>md,flattenDocumentFields:()=>RB0,firstPath:()=>sZ,firstByLabel:()=>lZ,findRuleInVersion:()=>OB1,findRuleInDraft:()=>MB1,findReusableSimulationBatch:()=>WB1,findKeywordLines:()=>id,findHumanResultValue:()=>NP,filterRunsByHumanResult:()=>SB0,filterRuns:()=>rd,extractHumanResult:()=>BQ,extractCitedRules:()=>VB1,countPathCandidates:()=>bd,countBy:()=>pd,compactObject:()=>s2,collectInvoiceSummary:()=>_B0,collectInvoiceObjects:
Line truncated
`)}function tB0($){return{id:$.id,versionNumber:$.versionNumber,versionName:$.versionName,publishedAt:$.publishedAt}}function aB0($,Y){let U=new Map;for(let Q of $.rules){let I=eZ(Q),J=Y==="stable-id"?$P0(I):$q(I.code??I.ruleCode);if(!J)throw Error(`Ruleversion${$.versionNumber}containsarulewithouta${Y==="stable-id"?"stable rule ID":"code"}.`);if(U.has(J))throw Error(`Ruleversion${$.versionNumber}containsduplicate${Y==="stable-id"?"stable rule ID":"code"}:${J}`);U.set(J,I)}return U}function tB1($,Y,U){if(U!=="auto")return U;if([...$.rules,...Y.rules].every((J)=>Boolean($P0(J))))return"stable-id";if([...$.rules,...Y.rules].every((J)=>Boolean($q(eZ(J).code??eZ(J).ruleCode))))return"code";throw Error("Rule snapshots have neither a complete stable-ID mapping nor a complete code mapping.")}function YP0($,Y,U={}){let Q=tB1($,Y,U.identityMode??"auto"),I=aB0($,Q),J=aB0(Y,Q),K=[...new Set([...I.keys(),...J.keys()])],z=[],G={added:0,removed:0,modified:0,unchanged:0},H=tB0($),W=tB0(Y);for(let Z of K){let q=I.get(Z),V=J.get(Z),w=q?PQ(q,Q):void 0,M=V?PQ(V,Q):void 0,F=!q?"added":!V?"removed":JSON.stringify(w)!==JSON.stringify(M)?"modified":"unchanged";if(G[F]+=1,F==="unchanged"&&!U.includeUnchanged)continue;let N=F==="modified"?[...new Set([...Object.keys(w??{}),...Object.keys(M??{})])].filter((O)=>JSON.stringify(w?.[O])!==JSON.stringify(M?.[O])):void 0;z.push({status:F,ruleId:Z,identityMode:Q,...q?{before:q}:{},...V?{after:V}:{},...N?.length?{changedFields:N}:{},...F!=="unchanged"?{diff:sB1(Z,H,W,q,V,Q)}:{}})}let X={from:H,to:W,identityMode:Q,counts:G,changes:z,unifiedDiff:z.filter((Z)=>Z.diff).map((Z)=>Z.diff).join(`
`)};if(Q==="code"){let Z=K.filter((P)=>I.has(P)&&J.has(P)).length,q=K.filter((P)=>I.has(P)&&J.has(P)&&JSON.stringify(PQ(I.get(P),"code"))===JSON.stringify(PQ(J.get(P),"code"))).length,V=I.size,w=J.size,M=Math.min(V,w)?Z/Math.min(V,w):1,F=new Map;for(let[P,T]of I)F.set(JSON.stringify(PQ(T,"code")),P);let N=0;for(let[P,T]of J){let A=F.get(JSON.stringify(PQ(T,"code")));if(A&&A!==P)N+=1}let D=(Math.min(V,w)?q/Math.min(V,w):1)>=0.5?"high":q>0||N>0?"ambiguous":"low";X.codeStats={oldCount:V,newCount:w,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 Yp($,Y=20000,U=!1){if(U||$.unifiedDiff.length<=Y)return{...$,truncation:{truncated:!1,maxChars:Y,omittedChars:0,hint:"Use --full only when the complete diff is required."}};let Q=$.unifiedDiff.length-Y,I=`
...[difftruncated:${Q}charactersomitted;rerunwith--fullforthecompletediff]`,J=$.changes.map(({before:K,after:z,diff:G,...H})=>({...H,...G?{diff:G.length>Y?`${G.slice(0,Y)}${I}`:G}:{}}));return{...$,changes:J,unifiedDiff:`${$.unifiedDiff.slice(0,Y)}${I}`,truncation:{truncated:!0,maxChars:Y,omittedChars:Q,hint:"Use --full for the complete diff."}}}var eB0,oB1;var UP0=o(()=>{eB0=["id","ruleId","stableId"],oB1=new Set([...eB0,"runtimeRuleId","runtimeId","tenantId","createdAt","updatedAt","versionId","versionNumber"])});import{existsSync as aB1,mkdirSync as eB1,readFileSync as $P1,renameSync as YP1,writeFileSync as UP1}from"node:fs";import{homedir as QP1}from"node:os";import{join as QP0}from"node:path";function Yq($){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 TP($){return JSON.stringify([$.description??"",$.scope??"",$.strictness??""])}function IP0(){return process.env.SEAL_USE_RULE_VERSION_SNAPSHOTS_DIR?.trim()||QP0(QP1(),".config","seal-use","rule-version-snapshots")}function IP1($){return $.replace(/[^a-zA-Z0-9._-]/g,"_")}function JP0($,Y){return QP0(IP0(),`${IP1($)}-v${Y}.json`)}function Uq($,Y,U){let Q=new Map,I=new Map;for(let W of U){let X=Yq(W.code);if(X)Q.set(X,[...Q.get(X)??[],W]);let Z=TP(W);I.set(Z,[...I.get(Z)??[],W])}let J=[];for(let W of Y.rules??[]){let X=Yq(W.code),Z=X?Q.get(X)??[]:[],q=I.get(TP(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 K={corpId:$,versionId:Y.id,versionNumber:Y.versionNumber,capturedAt:A1(),rules:J},z=IP0();eB1(z,{recursive:!0,mode:448});let G=JP0($,Y.versionNumber),H=`${G}.${process.pid}.tmp`;return UP1(H,`${JSON.stringify(K,null,2)}
@@ -881,66 +881,66 @@ export function lintRule(rule: RuleLintTarget): RuleLintResult {
}
exportdefaultlintRule;
`}});import{homedir as LP1}from"node:os";import{join as Kp}from"node:path";var FP1,E$,j$;var zp=o(()=>{FP1=Kp(LP1(),".config","seal-use"),E$=Kp(FP1,"linters"),j$=Kp(E$,"official")});import{existsSync as TI,mkdirSync as wP1,readFileSync as MP1,readdirSync as GP0,rmSync as OP1,unlinkSync as NP1,writeFileSync as DP1}from"node:fs";import{isAbsolute as AP1,join as E8,resolve as BP1}from"node:path";import{pathToFileURL as KP0}from"node:url";function HP0($=j$){let Y=[],U=[];try{if(!TI($))wP1($,{recursive:!0});let I=Object.keys(Qp);for(let[J,K]of Object.entries(Qp)){let z=E8($,J),G=!0;if(TI(z))try{if(MP1(z,"utf8")===K)G=!1}catch{G=!0}if(G)DP1(z,K,"utf8");Y.push(J)}let Q=GP0($,{withFileTypes:!0});for(let J of Q)if(!I.includes(J.name)){let K=E8($,J.name);try{if(J.isDirectory())OP1(K,{recursive:!0,force:!0});else NP1(K);U.push(J.name)}catch{}}}catch{}return{synced:Y,pruned:U}}function WP0($={syncOfficial:!0}){if($.syncOfficial!==!1)HP0();let Y=[{name:"builtin",type:"builtin",path:E8(j$,"builtin.ts"),description:"Seal 官方标准校验器 (拦截过短描述、主观模糊词与悬空例外条款)"},{name:"strict",type:"official",path:E8(j$,"strict.ts"),description:"Seal 官方严格风控校验器 (强校验字数、刚性定量约束、凭证依据与具体审批人角色)"},{name:"hlab",type:"official",path:E8(j$,"hlab.ts"),description:"合思实验室 (HLab) 结构化规则校验器 (SOP 四段论结构、三元闭环判定、剥离处置动作与防漏判)"}],U=[E$,EP];for(let I of U)if(TI(I))try{let Q=GP0(I,{withFileTypes:!0});for(let J of Q){if(J.isDirectory())continue;let K=J.name;if(K.endsWith(".ts")||K.endsWith(".js")||K.endsWith(".mjs")){let z=K.replace(/\.(ts|js|mjs)$/,"");if(!Y.some((G)=>G.name===z))Y.push({name:z,type:"custom",path:E8(I,K),description:`用户自定义规则校验器(${K})`})}}}catch{}return Y}function PP1($){let Y=($||"").trim();if(!Y||Y==="builtin"||Y==="default"||Y==="official/builtin"||Y==="official/builtin.ts")return{path:E8(j$,"builtin.ts"),isOfficial:!0,officialKind:"builtin"};if(Y==="strict"||Y==="official/strict"||Y==="official/strict.ts")return{path:E8(j$,"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:E8(j$,"hlab.ts"),isOfficial:!0,officialKind:"hlab"};if(AP1(Y)||Y.startsWith("./")||Y.startsWith("../")){let I=BP1(Y);if(TI(I))return{path:I};for(let Q of[".ts",".js",".mjs"])if(TI(`${I}${Q}`))return{path:`${I}${Q}`}}let U=[E8(E$,`${Y}.ts`),E8(E$,`${Y}.js`),E8(E$,`${Y}.mjs`),E8(EP,`${Y}.ts`),E8(EP,`${Y}.js`),E8(EP,`${Y}.mjs`)];for(let I of U)if(TI(I))return{path:I};return{}}async function Gp($){HP0();let Y=PP1($??"builtin");if(Y.isOfficial){let I=Y.officialKind==="strict"?QP0:Y.officialKind==="hlab"?JP0:qz,Q=Y.officialKind==="builtin"?"builtin":"official",J=Y.path;if(J&&TI(J))try{let z=await import(KP0(J).href),G=z.default??z.lintRule??z.linter??z.lint;if(typeof G==="function")return{name:Y.officialKind??"builtin",type:Q,filePath:J,linter:zP0(G,I)}}catch{}return{name:Y.officialKind??"builtin",type:Q,filePath:J,linter:I}}let U=Y.path;if(!U)return console.error(`⚠️[linter]未找到自定义校验器"${$}",已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:qz};try{let Q=await import(KP0(U).href),J=Q.default??Q.lintRule??Q.linter??Q.lint;if(typeof J!=="function")return console.error(`⚠️[linter]自定义校验器"${U}"未导出标准函数(default/lintRule),已安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:qz};return{name:$??"custom",type:"custom",filePath:U,linter:zP0(J,qz)}}catch(I){returnconsole.error(`⚠️[linter]加载自定义校验器脚本"${U}"失败(语法错误或依赖缺失:${I?.message??I}),已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:qz}}}functionzP0($,Y){returnasync(U,I)=>{try{letQ=await$(U,I);if(Q&&typeofQ==="object"&&typeofQ.score==="number"&&Array.isArray(Q.issues))returnQ;returnconsole.error("⚠️[linter]自定义校验器返回值格式不符合RuleLintResult契约,已回退至内置结果。"),Y(U,I)}catch(Q){returnconsole.error("⚠️[linter]自定义校验器执行异常:",Q),Y(U,I)}}}varEP;varXP0=o(()=>{zp();Yp();Ip();Jp();Up();EP=E8(process.cwd(),"linters")});asyncfunctionHp($,Y,U){letI=awaitY.linter($,U);return{ruleId:$.id,ruleCode:$.code,ruleName:$.name,score:I.score,passed:I.passed,issues:I.issues,description:$.description}}asyncfunctionZP0($,Y,U,I){letQ=I?.minScore??0,J=I?.level??"all",K=[],z=0;for(letqof$){letV=awaitHp(q,Y,U);z+=V.score;letw=V.issues;if(J==="error")w=V.issues.filter((F)=>F.level==="error");elseif(J==="warning")w=V.issues.filter((F)=>F.level==="warning"||F.level==="error");letM=w.every((F)=>F.level!=="error");if(I?.summary){if(w.length>0)K.push({...V,passed:M,issues:w})}elseK.push({...V,passed:M,issues:w})}letG=$.length,H=G===Line truncated
`,"utf8"),U}function wP0($){return $.map((Y,U)=>{let I=LP0(Y.code),Q;if(I!==void 0)Q=String(I).padStart(4,"0");else if(typeof Y.code==="string"&&Y.code.trim())Q=Y.code.trim().replace(/^#/,"");else Q=String(U).padStart(4,"0");return{id:Y.id,code:Q,name:Y.name,description:Y.description,scope:Y.scope,strictness:Y.strictness}})}var MP0=()=>{};var T$4,E$4,OP0,j$4,vP1,C$4,R$4,NP0,_$4,v$4,DP0,S$4,h$4,y$4,g$4,k$4,x$4,f$4,u$4,b$4,i$4,c$4,n$4,d$4,p$4,m$4,l$4,o$4,r$4,s$4,a$4,t$4,e$4,$54,Y54,U54,I54,Zp,SP1,hP1,yP1,l3,Vz,Q54,J54,jP,K54,z54,G54,H54,W54,X54,Z54,gP1,qp,q54,V54,L54,F54,w54,M54,O54,N54,D54,A54,B54,P54,T54,E54,j54,C54,R54,_54,AP0;var BP0=o(()=>{W6();X4();t$();pB0();tB0();$p();Wp();MP0();$5();({presentWebhookIntegration:T$4,getConfiguredSealBaseUrl:E$4,projectApprovalRules:OP0,pickRuleFields:j$4,buildRulePushPlan:vP1,rulesHaveSameContent:C$4,ruleChangedFields:R$4,normalizeRuleStrictness:NP0,parseDurationMs:_$4,redactIntegrationSecrets:v$4,mutationPreview:DP0,redactPreviewValue:S$4,buildSimulationBatchParams:h$4,summarizeSimulationBatch:y$4,summarizeApprovalRun:g$4,summarizeApprovalRuns:k$4,parseFieldPaths:x$4,pickRunFields:f$4,approvalRunMetadata:u$4,summarizeApprovalRunDetail:b$4,summarizeApprovalRunResult:i$4,summarizeApprovalRunDocument:c$4,extractCitedRules:n$4,firstPath:d$4,countPathCandidates:p$4,getPath:m$4,setPath:l$4,compactObject:o$4,asRecord:r$4,numberFromUnknown:s$4,flattenDocumentFields:a$4,collectDocumentFields:t$4,firstByLabel:e$4,collectInvoiceSummary:$54,collectInvoiceObjects:Y54,findKeywordLines:U54,summarizeRunBridge:I54,summarizeRuleVersion:Zp,resolveRuleVersionForLookup:SP1,findRuleInDraft:hP1,findRuleInVersion:yP1,parseRuleCodeNumber:l3,normalizeRuleCode:Vz,runtimeRuleIndex:Q54,runtimeRuleIdToCode:J54,formatRuleCode:jP,pickApprovalRunCandidate:K54,resolveApprovalRunForUrl:z54,resolveSealBaseUrl:G54,normalizeUrl:H54,stringFromUnknown:W54,pickApprovalRuns:X54,timestampOf:Z54,resolveRuleVersion:gP1,resolveRuleVersionSelector:qp,filterRuns:q54,scalarIncludes:V54,objectContainsScalar:L54,filterRunsByHumanResult:F54,withApprovalRunFilters:w54,resolveManualApprovalStatus:M54,prepareApprovalRuns:O54,approvalRunAliases:N54,extractHumanResult:D54,findHumanResultValue:A54,isHumanResultKey:B54,stringifyHumanResultValue:P54,matchesRunLookup:T54,countBy:E54,localDateKey:j54,formatLocalDateTime:C54,toDate:R54,localParts:_54}=H8),AP0=[{name:"seal_approval_rules_list",description:"列出 Seal 审批规则(默认当前草稿,传 version='latest' 或版本号则列出对应已发布版本);支持 countOnly、fields、limit",parameters:L.object({version:L.string().optional().describe("可选发布版本号或 'latest';不传则读取当前草稿"),countOnly:L.boolean().optional().describe("只返回规则数量,不返回规则列表"),fields:L.array(L.enum(["id","code","tenantId","status","strictness","scope","createdAt","updatedAt","description"])).optional().describe("只返回指定字段;不传则返回完整规则"),limit:L.number().int().nonnegative().optional().describe("最多返回多少条规则;0 可配合 fields 或 countOnly 只取数量"),offset:L.number().int().nonnegative().optional().describe("跳过前多少条规则")}),handler:async($,Y)=>{if(Y.version){let I=await qp($,Y.version),Q=(I.rules??[]).map((K)=>({id:K.id??String(K.code),tenantId:K.tenantId??"",code:l3(K.code)??K.code,description:K.description,scope:K.scope,strictness:K.strictness,status:typeof K.status==="string"?K.status:"published",createdAt:K.createdAt??I.publishedAt??I.createdAt??0,updatedAt:K.updatedAt??I.publishedAt??I.createdAt??0}));return{...OP0({rules:Q,hasPendingDeletes:!1},Y),versionNumber:I.versionNumber,versionName:I.versionName??null}}let U=await I6($);return OP0(U,Y)}},{name:"seal_approval_rules_clear",description:"清空 Seal 当前草稿审批规则;用于测试环境导入规则前重置草稿规则集",parameters:L.object({dryRun:L.boolean().optional().describe("只预览将删除的规则数量,不执行删除"),recode:L.boolean().optional().describe("删除后尝试重新编排规则编号;失败会作为 warning 返回")}),handler:async($,Y,U)=>{let I=await I6($);if(Y.dryRun)return{...DP0(U,"api/v1/rules",I.rules,[],I.rules.length),corpId:U.corp.id,corpName:U.corp.name,dryRun:!0,beforeCount:I.rules.length,deleted:0,afterCount:I.rules.length,hasPendingDeletes:I.hasPendingDeletes};let Q=[],J=0;for(let H of I.rules)try{await zJ($,H.id),J+=1}catch(W){Q.push({ruleId:H.id,error:a8(W instanceof Error?W.message:String(W))})}let K=[],z;if(J>0&&Y.recode!==!1){if(z=await fM($),z&&typeof z==="object"&&"ok"in z&&z.ok!==!0)K.push("batch-recode did not complete; current rules were still deleted")}let G=await I6($);return{corpId:U.corp.id,corpName:U.corp.name,dryRun:!1,beforeCount:I.rules.length,deleted:J,failed:Q,afterCount:G.rules.length,hasPendingDeletes:G.hasPendingDeletes,warnings:K,recode:z}}},{name:"seal_approval_rule_create",description:"新建 Seal 草稿审批规则",parameters:L.object({
Line truncated
\uD83D\uDC49Nextaction:若您已直接修改远端草稿、仅需发布正式版本,请执行seal-userulespublish"${q}"--corp${U.corp.id}`)}throw Z}let K=Y.confirm!==!0||Y.dryRun===!0,z=await I6($),G=vP1(z.rules,Q.rules);if(K)return{...DP0(U,"api/v1/rules",z.rules,Q.rules.map((Z)=>({description:Z.description,scope:Z.scope??"ALL",strictness:Z.strictness??"MUST_FOLLOW"})),z.rules.length+Q.rules.length),corpId:U.corp.id,dryRun:!0,localFile:Q.resolvedPath,localRulesCount:Q.rules.length,remoteDraftCount:z.rules.length,changes:G,impactCount:G.created.length+G.updated.length+G.deleted.length,preservedRuleIds:[...G.updated.map((Z)=>Z.id),...G.unchanged.map((Z)=>Z.id)],warning:"Incremental mode preserves matched rule IDs and does not recode the draft rule set.",willPublish:Boolean(Y.publish),message:"Preview mode. Use --yes or confirm=true to apply the listed incremental changes to the remote draft."};for(let Z of G.deleted)await zJ($,Z.id);let H=[];for(let Z of G.created){let q=await lH($,{description:Z.description,scope:Z.scope??"ALL",strictness:NP0(Z.strictness)});H.push({id:q.id,description:q.description,code:q.code})}let W=[];for(let Z of G.updated)await yy($,Z.id,{description:Z.rule.description,scope:Z.rule.scope??"ALL",strictness:NP0(Z.rule.strictness)}),W.push(Z.id);let X=void 0;if(Y.publish){let Z=A1().slice(0,10).replace(/-/g,""),q=Y.versionName||`v-local-${Z}-${Date.now().toString().slice(-4)}`;X=await oH($,q);try{let V=await I6($);Uq(U.corp.id,X.version,V.rules)}catch{}}return{corpId:U.corp.id,dryRun:!1,localFile:Q.resolvedPath,deletedRules:G.deleted.length,createdRules:H.length,updatedRules:W.length,unchangedRules:G.unchanged.length,preservedRuleIds:[...W,...G.unchanged.map((Z)=>Z.id)],recoded:!1,published:X??!1}}},{name:"seal_approval_documents_list",description:"列出 Seal 审批知识文档",parameters:L.object({scenarios:L.array(L.string()).optional().describe("场景过滤"),offset:L.number().int().nonnegative().optional(),limit:L.number().int().positive().optional()}),handler:async($,Y)=>YU($,Y)},{name:"seal_approval_document_get",description:"获取 Seal 审批知识文档详情",parameters:L.object({documentId:L.string().describe("文档 ID")}),handler:async($,Y)=>O40($,Y.documentId)},{name:"seal_approval_document_create",description:"新建 Seal 审批知识文档",parameters:L.object({title:L.string(),purpose:L.string(),content:L.string().describe("正文,通常为 Markdown"),contentType:L.string().optional(),status:L.string().optional(),enabled:L.boolean().optional(),scenarios:L.array(L.string()).optional(),tags:L.array(L.string()).optional()}),handler:async($,Y)=>uM($,Y)},{name:"seal_approval_document_update",description:"更新 Seal 审批知识文档",parameters:L.object({documentId:L.string(),title:L.string().optional(),purpose:L.string().optional(),content:L.string().optional(),contentType:L.string().optional(),status:L.string().optional(),enabled:L.boolean().optional(),scenarios:L.array(L.string()).optional(),tags:L.array(L.string()).optional()}),handler:async($,Y)=>{let{documentId:U,...I}=Y;return bM($,U,I)}},{name:"seal_approval_delete_document",description:"删除 Seal 审批知识文档",parameters:L.object({documentId:L.string().describe("知识文档 ID")}),handler:($,Y)=>iM($,Y.documentId)},{name:"seal_approval_search",description:"按关键词组检索 Seal 审批规则、审批文档和审批偏好配置,返回命中位置、字段、行号和前后三行上下文",parameters:L.object({keywords:L.array(L.string()).min(1).describe("关键词组"),matchMode:L.enum(["any","all"]).optional().describe("any 命中任一关键词,all 要求同一行命中全部关键词"),areas:L.array(L.enum(["rules","documents","preferences"])).optional().describe("检索范围"),caseSensitive:L.boolean().optional().describe("是否大小写敏感"),contextLines:L.number().int().nonnegative().optional().describe("返回命中行前后几行,默认 3"),documentLimit:L.number().int().positive().optional().describe("缓存刷新时最多拉取文档数,默认 100"),maxResults:L.number().int().positive().optional().describe("最多返回命中数,默认 50"),refresh:L.boolean().optional().describe("是否跳过 5 分钟内存缓存并强制刷新"),ruleVersionScope:L.enum(["current","all","version"]).optional().describe("规则检索范围,默认 current;all 会检索所有已发布历史版本"),ruleVersionId:L.string().optional().describe("ruleVersionScope=version 时指定版本 ID"),ruleVersionNumber:L.number().int().positive().optional().describe("ruleVersionScope=version 时指定版本号"),latestRuleVersion:L.boolean().optional().describe("ruleVersionScope=version 时取最新已发布版本"),snippetOnly:L.boolean().optional().describe("只返回命中行,不返回前后文"),maxChars:L.number().int().positive().optional().describe("每个文本片段最多返回字符数"),fields:L.array(L.string()).optional().describe("只搜索指定字段,如 history.descrip
Line truncated
`}});import{homedir as NP1}from"node:os";import{join as Gp}from"node:path";var DP1,E$,j$;var Hp=o(()=>{DP1=Gp(NP1(),".config","seal-use"),E$=Gp(DP1,"linters"),j$=Gp(E$,"official")});import{existsSync as TQ,mkdirSync as AP1,readFileSync as BP1,readdirSync as ZP0,rmSync as PP1,unlinkSync as TP1,writeFileSync as EP1}from"node:fs";import{isAbsolute as jP1,join as E8,resolve as CP1}from"node:path";import{pathToFileURL as WP0}from"node:url";function qP0($=j$){let Y=[],U=[];try{if(!TQ($))AP1($,{recursive:!0});let Q=Object.keys(Kp);for(let[J,K]of Object.entries(Kp)){let z=E8($,J),G=!0;if(TQ(z))try{if(BP1(z,"utf8")===K)G=!1}catch{G=!0}if(G)EP1(z,K,"utf8");Y.push(J)}let I=ZP0($,{withFileTypes:!0});for(let J of I)if(!Q.includes(J.name)){let K=E8($,J.name);try{if(J.isDirectory())PP1(K,{recursive:!0,force:!0});else TP1(K);U.push(J.name)}catch{}}}catch{}return{synced:Y,pruned:U}}function VP0($={syncOfficial:!0}){if($.syncOfficial!==!1)qP0();let Y=[{name:"builtin",type:"builtin",path:E8(j$,"builtin.ts"),description:"Seal 官方标准校验器 (拦截过短描述、主观模糊词与悬空例外条款)"},{name:"strict",type:"official",path:E8(j$,"strict.ts"),description:"Seal 官方严格风控校验器 (强校验字数、刚性定量约束、凭证依据与具体审批人角色)"},{name:"hlab",type:"official",path:E8(j$,"hlab.ts"),description:"合思实验室 (HLab) 结构化规则校验器 (SOP 四段论结构、三元闭环判定、剥离处置动作与防漏判)"}],U=[E$,jP];for(let Q of U)if(TQ(Q))try{let I=ZP0(Q,{withFileTypes:!0});for(let J of I){if(J.isDirectory())continue;let K=J.name;if(K.endsWith(".ts")||K.endsWith(".js")||K.endsWith(".mjs")){let z=K.replace(/\.(ts|js|mjs)$/,"");if(!Y.some((G)=>G.name===z))Y.push({name:z,type:"custom",path:E8(Q,K),description:`用户自定义规则校验器(${K})`})}}}catch{}return Y}function RP1($){let Y=($||"").trim();if(!Y||Y==="builtin"||Y==="default"||Y==="official/builtin"||Y==="official/builtin.ts")return{path:E8(j$,"builtin.ts"),isOfficial:!0,officialKind:"builtin"};if(Y==="strict"||Y==="official/strict"||Y==="official/strict.ts")return{path:E8(j$,"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:E8(j$,"hlab.ts"),isOfficial:!0,officialKind:"hlab"};if(jP1(Y)||Y.startsWith("./")||Y.startsWith("../")){let Q=CP1(Y);if(TQ(Q))return{path:Q};for(let I of[".ts",".js",".mjs"])if(TQ(`${Q}${I}`))return{path:`${Q}${I}`}}let U=[E8(E$,`${Y}.ts`),E8(E$,`${Y}.js`),E8(E$,`${Y}.mjs`),E8(jP,`${Y}.ts`),E8(jP,`${Y}.js`),E8(jP,`${Y}.mjs`)];for(let Q of U)if(TQ(Q))return{path:Q};return{}}async function Wp($){qP0();let Y=RP1($??"builtin");if(Y.isOfficial){let Q=Y.officialKind==="strict"?GP0:Y.officialKind==="hlab"?HP0:qz,I=Y.officialKind==="builtin"?"builtin":"official",J=Y.path;if(J&&TQ(J))try{let z=await import(WP0(J).href),G=z.default??z.lintRule??z.linter??z.lint;if(typeof G==="function")return{name:Y.officialKind??"builtin",type:I,filePath:J,linter:XP0(G,Q)}}catch{}return{name:Y.officialKind??"builtin",type:I,filePath:J,linter:Q}}let U=Y.path;if(!U)return console.error(`⚠️[linter]未找到自定义校验器"${$}",已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:qz};try{let I=await import(WP0(U).href),J=I.default??I.lintRule??I.linter??I.lint;if(typeof J!=="function")return console.error(`⚠️[linter]自定义校验器"${U}"未导出标准函数(default/lintRule),已安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:qz};return{name:$??"custom",type:"custom",filePath:U,linter:XP0(J,qz)}}catch(Q){returnconsole.error(`⚠️[linter]加载自定义校验器脚本"${U}"失败(语法错误或依赖缺失:${Q?.message??Q}),已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:qz}}}functionXP0($,Y){returnasync(U,Q)=>{try{letI=await$(U,Q);if(I&&typeofI==="object"&&typeofI.score==="number"&&Array.isArray(I.issues))returnI;returnconsole.error("⚠️[linter]自定义校验器返回值格式不符合RuleLintResult契约,已回退至内置结果。"),Y(U,Q)}catch(I){returnconsole.error("⚠️[linter]自定义校验器执行异常:",I),Y(U,Q)}}}varjP;varLP0=o(()=>{Hp();Qp();Jp();zp();Ip();jP=E8(process.cwd(),"linters")});asyncfunctionXp($,Y,U){letQ=awaitY.linter($,U);return{ruleId:$.id,ruleCode:$.code,ruleName:$.name,score:Q.score,passed:Q.passed,issues:Q.issues,description:$.description}}asyncfunctionFP0($,Y,U,Q){letI=Q?.minScore??0,J=Q?.level??"all",K=[],z=0;for(letqof$){letV=awaitXp(q,Y,U);z+=V.score;letw=V.issues;if(J==="error")w=V.issues.filter((F)=>F.level==="error");elseif(J==="warning")w=V.issues.filter((F)=>F.level==="warning"||F.level==="error");letM=w.every((F)=>F.level!=="error");if(Q?.summary){if(w.length>0)K.push({...V,passed:M,issues:w})}elseK.push({...V,passed:M,issues:w})}letG=$.length,H=G===Line truncated
`,"utf8"),U}function DP0($){return $.map((Y,U)=>{let Q=OP0(Y.code),I;if(Q!==void 0)I=String(Q).padStart(4,"0");else if(typeof Y.code==="string"&&Y.code.trim())I=Y.code.trim().replace(/^#/,"");else I=String(U).padStart(4,"0");return{id:Y.id,code:I,name:Y.name,description:Y.description,scope:Y.scope,strictness:Y.strictness}})}var AP0=()=>{};var S$4,h$4,BP0,g$4,kP1,y$4,k$4,PP0,x$4,f$4,TP0,u$4,b$4,i$4,c$4,n$4,d$4,p$4,m$4,l$4,o$4,r$4,s$4,t$4,a$4,e$4,$54,Y54,U54,Q54,I54,J54,K54,z54,G54,H54,W54,Vp,xP1,fP1,uP1,l3,Vz,X54,Z54,CP,q54,V54,L54,F54,w54,M54,O54,bP1,Lp,N54,D54,A54,B54,P54,T54,E54,j54,C54,R54,_54,v54,S54,h54,g54,y54,k54,x54,EP0;var jP0=o(()=>{W6();X4();a$();rB0();UP0();Up();Zp();AP0();$5();({presentWebhookIntegration:S$4,getConfiguredSealBaseUrl:h$4,projectApprovalRules:BP0,pickRuleFields:g$4,buildRulePushPlan:kP1,rulesHaveSameContent:y$4,ruleChangedFields:k$4,normalizeRuleStrictness:PP0,parseDurationMs:x$4,redactIntegrationSecrets:f$4,mutationPreview:TP0,redactPreviewValue:u$4,buildSimulationBatchParams:b$4,summarizeSimulationBatch:i$4,summarizeApprovalRun:c$4,summarizeApprovalRuns:n$4,parseFieldPaths:d$4,pickRunFields:p$4,approvalRunMetadata:m$4,summarizeApprovalRunDetail:l$4,summarizeApprovalRunResult:o$4,summarizeApprovalRunDocument:r$4,extractCitedRules:s$4,firstPath:t$4,countPathCandidates:a$4,getPath:e$4,setPath:$54,compactObject:Y54,asRecord:U54,numberFromUnknown:Q54,flattenDocumentFields:I54,collectDocumentFields:J54,firstByLabel:K54,collectInvoiceSummary:z54,collectInvoiceObjects:G54,findKeywordLines:H54,summarizeRunBridge:W54,summarizeRuleVersion:Vp,resolveRuleVersionForLookup:xP1,findRuleInDraft:fP1,findRuleInVersion:uP1,parseRuleCodeNumber:l3,normalizeRuleCode:Vz,runtimeRuleIndex:X54,runtimeRuleIdToCode:Z54,formatRuleCode:CP,pickApprovalRunCandidate:q54,resolveApprovalRunForUrl:V54,resolveSealBaseUrl:L54,normalizeUrl:F54,stringFromUnknown:w54,pickApprovalRuns:M54,timestampOf:O54,resolveRuleVersion:bP1,resolveRuleVersionSelector:Lp,filterRuns:N54,scalarIncludes:D54,objectContainsScalar:A54,filterRunsByHumanResult:B54,withApprovalRunFilters:P54,resolveManualApprovalStatus:T54,prepareApprovalRuns:E54,approvalRunAliases:j54,extractHumanResult:C54,findHumanResultValue:R54,isHumanResultKey:_54,stringifyHumanResultValue:v54,matchesRunLookup:S54,countBy:h54,localDateKey:g54,formatLocalDateTime:y54,toDate:k54,localParts:x54}=H8),EP0=[{name:"seal_approval_rules_list",description:"列出 Seal 审批规则(默认当前草稿,传 version='latest' 或版本号则列出对应已发布版本);支持 countOnly、fields、limit",parameters:L.object({version:L.string().optional().describe("可选发布版本号或 'latest';不传则读取当前草稿"),countOnly:L.boolean().optional().describe("只返回规则数量,不返回规则列表"),fields:L.array(L.enum(["id","code","tenantId","status","strictness","scope","createdAt","updatedAt","description"])).optional().describe("只返回指定字段;不传则返回完整规则"),limit:L.number().int().nonnegative().optional().describe("最多返回多少条规则;0 可配合 fields 或 countOnly 只取数量"),offset:L.number().int().nonnegative().optional().describe("跳过前多少条规则")}),handler:async($,Y)=>{if(Y.version){let Q=await Lp($,Y.version),I=(Q.rules??[]).map((K)=>({id:K.id??String(K.code),tenantId:K.tenantId??"",code:l3(K.code)??K.code,description:K.description,scope:K.scope,strictness:K.strictness,status:typeof K.status==="string"?K.status:"published",createdAt:K.createdAt??Q.publishedAt??Q.createdAt??0,updatedAt:K.updatedAt??Q.publishedAt??Q.createdAt??0}));return{...BP0({rules:I,hasPendingDeletes:!1},Y),versionNumber:Q.versionNumber,versionName:Q.versionName??null}}let U=await Q6($);return BP0(U,Y)}},{name:"seal_approval_rules_clear",description:"清空 Seal 当前草稿审批规则;用于测试环境导入规则前重置草稿规则集",parameters:L.object({dryRun:L.boolean().optional().describe("只预览将删除的规则数量,不执行删除"),recode:L.boolean().optional().describe("删除后尝试重新编排规则编号;失败会作为 warning 返回")}),handler:async($,Y,U)=>{let Q=await Q6($);if(Y.dryRun)return{...TP0(U,"api/v1/rules",Q.rules,[],Q.rules.length),corpId:U.corp.id,corpName:U.corp.name,dryRun:!0,beforeCount:Q.rules.length,deleted:0,afterCount:Q.rules.length,hasPendingDeletes:Q.hasPendingDeletes};let I=[],J=0;for(let H of Q.rules)try{await zJ($,H.id),J+=1}catch(W){I.push({ruleId:H.id,error:t8(W instanceof Error?W.message:String(W))})}let K=[],z;if(J>0&&Y.recode!==!1){if(z=await fM($),z&&typeof z==="object"&&"ok"in z&&z.ok!==!0)K.push("batch-recode did not complete; current rules were still deleted")}let G=await Q6($);return{corpId:U.corp.id,corpName:U.corp.name,dryRun:!1,beforeCount:Q.rules.length,deleted:J,failed:I,afterCount:G.rules.length,hasPendingDeletes:G.hasPendingDeletes,warnings:K,recode:z}}},{name:"seal_approval_rule_create",description:"新建 Seal 草稿审批规则",parameters:L.object({
Line truncated
\uD83D\uDC49Nextaction:若您已直接修改远端草稿、仅需发布正式版本,请执行seal-userulespublish"${q}"--corp${U.corp.id}`)}throw Z}let K=Y.confirm!==!0||Y.dryRun===!0,z=await Q6($),G=kP1(z.rules,I.rules);if(K)return{...TP0(U,"api/v1/rules",z.rules,I.rules.map((Z)=>({description:Z.description,scope:Z.scope??"ALL",strictness:Z.strictness??"MUST_FOLLOW"})),z.rules.length+I.rules.length),corpId:U.corp.id,dryRun:!0,localFile:I.resolvedPath,localRulesCount:I.rules.length,remoteDraftCount:z.rules.length,changes:G,impactCount:G.created.length+G.updated.length+G.deleted.length,preservedRuleIds:[...G.updated.map((Z)=>Z.id),...G.unchanged.map((Z)=>Z.id)],warning:"Incremental mode preserves matched rule IDs and does not recode the draft rule set.",willPublish:Boolean(Y.publish),message:"Preview mode. Use --yes or confirm=true to apply the listed incremental changes to the remote draft."};for(let Z of G.deleted)await zJ($,Z.id);let H=[];for(let Z of G.created){let q=await lH($,{description:Z.description,scope:Z.scope??"ALL",strictness:PP0(Z.strictness)});H.push({id:q.id,description:q.description,code:q.code})}let W=[];for(let Z of G.updated)await yg($,Z.id,{description:Z.rule.description,scope:Z.rule.scope??"ALL",strictness:PP0(Z.rule.strictness)}),W.push(Z.id);let X=void 0;if(Y.publish){let Z=A1().slice(0,10).replace(/-/g,""),q=Y.versionName||`v-local-${Z}-${Date.now().toString().slice(-4)}`;X=await oH($,q);try{let V=await Q6($);Uq(U.corp.id,X.version,V.rules)}catch{}}return{corpId:U.corp.id,dryRun:!1,localFile:I.resolvedPath,deletedRules:G.deleted.length,createdRules:H.length,updatedRules:W.length,unchangedRules:G.unchanged.length,preservedRuleIds:[...W,...G.unchanged.map((Z)=>Z.id)],recoded:!1,published:X??!1}}},{name:"seal_approval_documents_list",description:"列出 Seal 审批知识文档",parameters:L.object({scenarios:L.array(L.string()).optional().describe("场景过滤"),offset:L.number().int().nonnegative().optional(),limit:L.number().int().positive().optional()}),handler:async($,Y)=>YU($,Y)},{name:"seal_approval_document_get",description:"获取 Seal 审批知识文档详情",parameters:L.object({documentId:L.string().describe("文档 ID")}),handler:async($,Y)=>A40($,Y.documentId)},{name:"seal_approval_document_create",description:"新建 Seal 审批知识文档",parameters:L.object({title:L.string(),purpose:L.string(),content:L.string().describe("正文,通常为 Markdown"),contentType:L.string().optional(),status:L.string().optional(),enabled:L.boolean().optional(),scenarios:L.array(L.string()).optional(),tags:L.array(L.string()).optional()}),handler:async($,Y)=>uM($,Y)},{name:"seal_approval_document_update",description:"更新 Seal 审批知识文档",parameters:L.object({documentId:L.string(),title:L.string().optional(),purpose:L.string().optional(),content:L.string().optional(),contentType:L.string().optional(),status:L.string().optional(),enabled:L.boolean().optional(),scenarios:L.array(L.string()).optional(),tags:L.array(L.string()).optional()}),handler:async($,Y)=>{let{documentId:U,...Q}=Y;return bM($,U,Q)}},{name:"seal_approval_delete_document",description:"删除 Seal 审批知识文档",parameters:L.object({documentId:L.string().describe("知识文档 ID")}),handler:($,Y)=>iM($,Y.documentId)},{name:"seal_approval_search",description:"按关键词组检索 Seal 审批规则、审批文档和审批偏好配置,返回命中位置、字段、行号和前后三行上下文",parameters:L.object({keywords:L.array(L.string()).min(1).describe("关键词组"),matchMode:L.enum(["any","all"]).optional().describe("any 命中任一关键词,all 要求同一行命中全部关键词"),areas:L.array(L.enum(["rules","documents","preferences"])).optional().describe("检索范围"),caseSensitive:L.boolean().optional().describe("是否大小写敏感"),contextLines:L.number().int().nonnegative().optional().describe("返回命中行前后几行,默认 3"),documentLimit:L.number().int().positive().optional().describe("缓存刷新时最多拉取文档数,默认 100"),maxResults:L.number().int().positive().optional().describe("最多返回命中数,默认 50"),refresh:L.boolean().optional().describe("是否跳过 5 分钟内存缓存并强制刷新"),ruleVersionScope:L.enum(["current","all","version"]).optional().describe("规则检索范围,默认 current;all 会检索所有已发布历史版本"),ruleVersionId:L.string().optional().describe("ruleVersionScope=version 时指定版本 ID"),ruleVersionNumber:L.number().int().positive().optional().describe("ruleVersionScope=version 时指定版本号"),latestRuleVersion:L.boolean().optional().describe("ruleVersionScope=version 时取最新已发布版本"),snippetOnly:L.boolean().optional().describe("只返回命中行,不返回前后文"),maxChars:L.number().int().positive().optional().describe("每个文本片段最多返回字符数"),fields:L.array(L.string()).optional().describe("只搜索指定字段,如 history.descrip
Line truncated
`),I=await Promise.all(O.map((D)=>W4($,D.id)))}let Q=new Map,J=0;for(let F of I){let N=F.document,O=F.sourceDocumentId??(typeof N?.id==="string"?N.id:void 0)??(typeof N?.sourceDocumentId==="string"?N.sourceDocumentId:void 0)??F.documentId??F.id,D=`${U.docIdPrefix??""}${O}${U.docIdSuffix??""}`,P=[];if(U.includeAttachments!==!1){let A=p3(F,{summary:!1}).attachments,E=new Set;for(let C of A){let i=C.ossSignedUrl??C.url;if(!i)continue;let x=C.fileName??C.fileId??"attachment",h=vd(x),b=h,n=h.lastIndexOf("."),I0=n>0?h.slice(0,n):h,k=n>0?h.slice(n):"",m=1;while(E.has(b.toLowerCase()))b=`${I0}_${m}${k}`,m++;E.add(b.toLowerCase());try{process.stderr.write(`⬇下载单据「${D}」附件:${x}...
`),await new Promise((F,N)=>{let O=Wg1(V),D=new Ko({zlib:{level:9}});O.on("close",()=>F()),D.on("error",(P)=>N(P)),D.pipe(O),D.append(Buffer.from(w),{name:"信息表.xlsx"});for(let P of Q.values())for(let T of P)D.append(T.buffer,{name:T.zipPath});D.finalize()});let M=Zg1(V);return{filePath:V,corpId:Y.id,corpName:Y.name,recordCount:I.length,attachmentCount:J,fileSizeBytes:M.size,exportedAt:A1(),nextAction:`seal-usewebhookresource-packpush${V}--corp<targetCorpId>`}}var Tv0;var zo=o(()=>{Bv0();X4();nZ();Tv0=H6(iZ(),1)});import{readFileSync as wg1}from"node:fs";function Mg1($){let Y=new URL($),U=Y.pathname.match(/\/webhook\/([^/]+)/);if(!U)throw Error("Webhook URL 必须包含 /webhook/{webhookId}/document");return{baseUrl:`${Y.protocol}//${Y.host}`,webhookId:U[1]}}function Og1($,Y){return Y.toLowerCase().endsWith(".zip")||$[0]===80&&$[1]===75&&!Y.toLowerCase().endsWith(".xlsx")}function Ng1($,Y){if(!$.length)return;let U=new Set($.map((J)=>{let K=J.fileName.split("/")[0],z=K.indexOf("@");return z>=0?K.slice(0,z):K}).filter((J)=>J!=="信息表.xlsx")),I=[];for(let J of Y){let K=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))&&!U.has(K))I.push(`Excel 会议编号「${K}」声明了附件,但在 ZIP 中找不到对应的根目录「${K}/」或「${K}@.../」。`)}let Q=new Set(Y.map((J)=>J.document.documentId));for(let J of U)if(!Q.has(J))I.push(`ZIP 根目录对应的编号「${J}」在信息表中找不到对应的会议编号。`);if(I.length)throw new g5(I)}async function Ev0($,Y,U){let I=[],Q=$;if(Og1($,Y)){I=await kT0($),fT0(I,U);let G=I.find((H)=>H.fileName==="信息表.xlsx");if(!G)throw Error("ZIP 根目录缺少信息表.xlsx");Q=await zm($,G)}let J=await pT0(Q);Ng1(I,J);let K=mT0(I,J),z=J.map((G)=>G.document);return{entries:I,parsed:J,plans:K,documents:z,fileBuffer:$}}async function mI($,Y,U){let I=await Ev0($,Y,U),Q=I.parsed.map((J,K)=>qm(J.document,I.plans[K],new Map));return{warnings:[],documents:Q,attachmentPlan:I.plans}}async function iT($,Y,U){let I=await Ev0($,Y,U.materialPackFilePolicy),{baseUrl:Q,webhookId:J}=Mg1(U.webhookUrl),K=[];for(let z=0;z<I.parsed.length;z+=1){let G=I.parsed[z],H=I.plans[z],W=new Map,X=[...H.categoryFields,...Object.values(H.personAttachments).flat(),...Object.values(H.expenseAttachments).flat()];for(let V of X)for(let w of V.paths){if(W.has(w))continue;let M=I.entries.find((T)=>T.fileName===w);if(!M)continue;process.stderr.write(`⬆ 上传附件: ${w}
`),Q=await Promise.all(O.map((D)=>W4($,D.id)))}let I=new Map,J=0;for(let F of Q){let N=F.document,O=F.sourceDocumentId??(typeof N?.id==="string"?N.id:void 0)??(typeof N?.sourceDocumentId==="string"?N.sourceDocumentId:void 0)??F.documentId??F.id,D=`${U.docIdPrefix??""}${O}${U.docIdSuffix??""}`,P=[];if(U.includeAttachments!==!1){let A=p3(F,{summary:!1}).attachments,E=new Set;for(let C of A){let i=C.ossSignedUrl??C.url;if(!i)continue;let x=C.fileName??C.fileId??"attachment",h=hd(x),b=h,n=h.lastIndexOf("."),Q0=n>0?h.slice(0,n):h,k=n>0?h.slice(n):"",m=1;while(E.has(b.toLowerCase()))b=`${Q0}_${m}${k}`,m++;E.add(b.toLowerCase());try{process.stderr.write(`⬇下载单据「${D}」附件:${x}...
`),await new Promise((F,N)=>{let O=Ly1(V),D=new Go({zlib:{level:9}});O.on("close",()=>F()),D.on("error",(P)=>N(P)),D.pipe(O),D.append(Buffer.from(w),{name:"信息表.xlsx"});for(let P of I.values())for(let T of P)D.append(T.buffer,{name:T.zipPath});D.finalize()});let M=wy1(V);return{filePath:V,corpId:Y.id,corpName:Y.name,recordCount:Q.length,attachmentCount:J,fileSizeBytes:M.size,exportedAt:A1(),nextAction:`seal-usewebhookresource-packpush${V}--corp<targetCorpId>`}}var Rv0;var Ho=o(()=>{jv0();X4();nZ();Rv0=H6(iZ(),1)});import{readFileSync as Ay1}from"node:fs";function By1($){let Y=new URL($),U=Y.pathname.match(/\/webhook\/([^/]+)/);if(!U)throw Error("Webhook URL 必须包含 /webhook/{webhookId}/document");return{baseUrl:`${Y.protocol}//${Y.host}`,webhookId:U[1]}}function Py1($,Y){return Y.toLowerCase().endsWith(".zip")||$[0]===80&&$[1]===75&&!Y.toLowerCase().endsWith(".xlsx")}function Ty1($,Y){if(!$.length)return;let U=new Set($.map((J)=>{let K=J.fileName.split("/")[0],z=K.indexOf("@");return z>=0?K.slice(0,z):K}).filter((J)=>J!=="信息表.xlsx")),Q=[];for(let J of Y){let K=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))&&!U.has(K))Q.push(`Excel 会议编号「${K}」声明了附件,但在 ZIP 中找不到对应的根目录「${K}/」或「${K}@.../」。`)}let I=new Set(Y.map((J)=>J.document.documentId));for(let J of U)if(!I.has(J))Q.push(`ZIP 根目录对应的编号「${J}」在信息表中找不到对应的会议编号。`);if(Q.length)throw new y5(Q)}async function _v0($,Y,U){let Q=[],I=$;if(Py1($,Y)){Q=await bT0($),cT0(Q,U);let G=Q.find((H)=>H.fileName==="信息表.xlsx");if(!G)throw Error("ZIP 根目录缺少信息表.xlsx");I=await Hm($,G)}let J=await rT0(I);Ty1(Q,J);let K=sT0(Q,J),z=J.map((G)=>G.document);return{entries:Q,parsed:J,plans:K,documents:z,fileBuffer:$}}async function mQ($,Y,U){let Q=await _v0($,Y,U),I=Q.parsed.map((J,K)=>Lm(J.document,Q.plans[K],new Map));return{warnings:[],documents:I,attachmentPlan:Q.plans}}async function cT($,Y,U){let Q=await _v0($,Y,U.materialPackFilePolicy),{baseUrl:I,webhookId:J}=By1(U.webhookUrl),K=[];for(let z=0;z<Q.parsed.length;z+=1){let G=Q.parsed[z],H=Q.plans[z],W=new Map,X=[...H.categoryFields,...Object.values(H.personAttachments).flat(),...Object.values(H.expenseAttachments).flat()];for(let V of X)for(let w of V.paths){if(W.has(w))continue;let M=Q.entries.find((T)=>T.fileName===w);if(!M)continue;process.stderr.write(`⬆ 上传附件: ${w}
`+"• 安全边界:该凭证绝不包含且无法访问合思 (Hose) 主系统;仅限内部排查,严禁在外部公开分享!")}return{url:W?K:Z?V:G,type:X,mode:Z?"auto_login":"direct",sealResultUrl:G,hoseDocumentUrl:K,documentUrl:K,ssoUrl:V,expiresIn:Z?q:void 0,identity:w,warning:M,hoseDomain:J.type==="hose"?Sg1(J.domain):void 0,recordId:Q.id,sourceDocumentSN:Q.sourceDocumentSN,sourceDocumentId:Q.sourceDocumentId,sourceSystem:Q.sourceSystem,missing:{hoseDocumentUrl:!K?"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,U)=>{let I=Y.sn??Y.query;if(!I)throw Error("query or sn is required");let Q=await yg1($,{query:I,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((W)=>W4($,W.id))),K=vv0(Y.fields),z=J.map((W)=>Rg1(W,K)),G=J.find((W)=>W.ruleSetVersionNumber!==void 0)?.ruleSetVersionNumber,H=G===void 0?"latest":String(G);return{query:I,sourceDocumentSN:Y.sn,simulationBatchId:Y.batchId,latest:Y.latest??!1,total:Q.total,scanned:Q.scanned,matched:z.length,records:z,next:{getSummary:`seal-useapproval-runsget<recordId>--summary--corp${U.corp.id}`,getRuleVersion:`seal-userulesversion${H}--corp${U.corp.id}`,searchRuleVersion:`seal-userulessearch<keyword>--version${H}--corp${U.corp.id}`,getVersionContext:`seal-usecontext--ruleVersion${H}--corp${U.corp.id}`},...Y.includeBridge?{bridge:Xo(J)}:{}}}},{name:"seal_approval_run_langfuse_bridge_get",description:"从 Seal approval run 中抽取 Langfuse 定位信息;优先返回 _langfuseTraceId,没有时给出 hosecloud-{sourceDocumentSN} session 回退",parameters:L.object({recordId:L.string().optional(),sourceDocumentSN:L.string().optional(),sourceDocumentId:L.string().optional(),simulationBatchId:L.string().optional(),limit:L.number().int().positive().max(100).optional()}),handler:async($,Y)=>{let I=(Y.simulationBatchId?await mM($,Y.simulationBatchId):(await u4($,{limit:Y.limit??50,search:Y.sourceDocumentSN??Y.sourceDocumentId,sourceDocumentSN:Y.sourceDocumentSN,sourceDocumentId:Y.sourceDocumentId})).records).filter((Q)=>ug1(Q,{recordId:Y.recordId,sourceDocumentSN:Y.sourceDocumentSN,sourceDocumentId:Y.sourceDocumentId}));return{count:I.length,records:I.map(_v0),bridge:Xo(I)}}},{name:"seal_approval_runs_stats",description:"统计审核记录状态分布、来源系统分布及按单号/ID去重统计",parameters:L.object({since:L.string().optional().describe("时间范围,如 3months, 7days, 24hours"),dedupeBy:L.enum(["sourceDocumentSN","sourceDocumentId","id"]).default("sourceDocumentSN").describe("去重字段"),status:L.string().optional(),sourceSystem:L.string().optional(),taskMode:L.string().optional()}),handler:async($,Y)=>{let U=await u4($,{limit:1000,status:Y.status,sourceSystem:Y.sourceSystem,taskMode:Y.taskMode}),I=Y.dedupeBy??"sourceDocumentSN",Q=U.records,J={},K={},z=new Set;for(let H of Q){let W=H.status??"unknown";J[W]=(J[W]??0)+1;let X=H.sourceSystem??"unknown";K[X]=(K[X]??0)+1;let Z=H[I];if(Z)z.add(String(Z))}let G=Math.max(0,Q.length-z.size);return{total:Q.length,dedupeBy:I,unique:z.size,duplicateRuns:G,dedupeNote:G>0?`存在${G}笔重复运行记录(同一单据重跑或修改重推)`:"全部单据唯一,无重复记录",byStatus:J,bySourceSystem:K}}},{name:"seal_approval_runs_count",description:"统计符合条件的审核记录总数",parameters:L.object({status:L.string().optional(),sourceSystem:L.string().optional(),taskMode:L.string().optional(),search:L.string().optional(),startDate:L.string().optional().describe("起始时间戳(毫秒)或日期字符串"),endDate:L.string().optional().describe("结束时间戳(毫秒)或日期字符串")}),handler:async($,Y)=>{let U=await u4($,{limit:1,status:Y.status,sourceSystem:Y.sourceSystem,taskMode:Y.taskMode,search:Y.search,startDate:a$(Y.startDate,!1),endDate:a$(Y.endDate,!0)});return{total:U.total??U.records.length}}}]});import{readFileSync as bg1}from"node:fs";var GI4,HI4,WI4,XI4,ZI4,qI4,VI4,LI4,kv0,FI4,wI4,MI4,ig1,cg1,ng1,OI4,NI4,DI4,AI4,BI4,PI4,TI4,EI4,jI4,CI4,RI4,_I
Line truncated
`)}function Yk1($){let Y=[];if(Y.push(`seal-use${$.area}-${$.title}`),$.description)Y.push($.description);Y.push(""),Y.push("Usage:");let U=new Map;for(let Q of $.commands){let J=Q.group??"",K=U.get(J)??[];K.push(Q),U.set(J,K)}let I=[...$.groupOrder??[],...[...U.keys()].filter((Q)=>!$.groupOrder?.includes(Q))];for(let Q of I){let J=U.get(Q);if(!J)continue;if(Q)Y.push(""),Y.push(`${Q}:`);for(let K of J)for(let z of K.usage)Y.push(`${z}`)}if($.commands.some((Q)=>Q.name))Y.push(""),Y.push(`Run'seal-use ${$.area} <command> --help'fordetailsonaspecificcommand.`);return Y.join(`
`)}function dv0(){let $=[];$.push("seal-use CLI"),$.push(""),$.push("Usage:"),$.push(" seal-use version");for(let Y of pv0)for(let U of Y.commands)for(let I of U.usage)$.push(`${I}`);return $.push(""),$.push("Run 'seal-use <command> --help' for details on a specific command."),$.join(`
`)}var pv0;var No=o(()=>{p8();pv0=[{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?K:Z?V:G,type:X,mode:Z?"auto_login":"direct",sealResultUrl:G,hoseDocumentUrl:K,documentUrl:K,ssoUrl:V,expiresIn:Z?q:void 0,identity:w,warning:M,hoseDomain:J.type==="hose"?xy1(J.domain):void 0,recordId:I.id,sourceDocumentSN:I.sourceDocumentSN,sourceDocumentId:I.sourceDocumentId,sourceSystem:I.sourceSystem,missing:{hoseDocumentUrl:!K?"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,U)=>{let Q=Y.sn??Y.query;if(!Q)throw Error("query or sn is required");let I=await uy1($,{query:Q,sn:Y.sn,batchId:Y.batchId,latest:Y.latest,limit:Y.latest?1:Y.limit??20,maxScan:Y.maxScan??1000}),J=await Promise.all(I.records.map((W)=>W4($,W.id))),K=yv0(Y.fields),z=J.map((W)=>gy1(W,K)),G=J.find((W)=>W.ruleSetVersionNumber!==void 0)?.ruleSetVersionNumber,H=G===void 0?"latest":String(G);return{query:Q,sourceDocumentSN:Y.sn,simulationBatchId:Y.batchId,latest:Y.latest??!1,total:I.total,scanned:I.scanned,matched:z.length,records:z,next:{getSummary:`seal-useapproval-runsget<recordId>--summary--corp${U.corp.id}`,getRuleVersion:`seal-userulesversion${H}--corp${U.corp.id}`,searchRuleVersion:`seal-userulessearch<keyword>--version${H}--corp${U.corp.id}`,getVersionContext:`seal-usecontext--ruleVersion${H}--corp${U.corp.id}`},...Y.includeBridge?{bridge:qo(J)}:{}}}},{name:"seal_approval_run_langfuse_bridge_get",description:"从 Seal approval run 中抽取 Langfuse 定位信息;优先返回 _langfuseTraceId,没有时给出 hosecloud-{sourceDocumentSN} session 回退",parameters:L.object({recordId:L.string().optional(),sourceDocumentSN:L.string().optional(),sourceDocumentId:L.string().optional(),simulationBatchId:L.string().optional(),limit:L.number().int().positive().max(100).optional()}),handler:async($,Y)=>{let Q=(Y.simulationBatchId?await mM($,Y.simulationBatchId):(await u4($,{limit:Y.limit??50,search:Y.sourceDocumentSN??Y.sourceDocumentId,sourceDocumentSN:Y.sourceDocumentSN,sourceDocumentId:Y.sourceDocumentId})).records).filter((I)=>dy1(I,{recordId:Y.recordId,sourceDocumentSN:Y.sourceDocumentSN,sourceDocumentId:Y.sourceDocumentId}));return{count:Q.length,records:Q.map(gv0),bridge:qo(Q)}}},{name:"seal_approval_runs_stats",description:"统计审核记录状态分布、来源系统分布及按单号/ID去重统计",parameters:L.object({since:L.string().optional().describe("时间范围,如 3months, 7days, 24hours"),dedupeBy:L.enum(["sourceDocumentSN","sourceDocumentId","id"]).default("sourceDocumentSN").describe("去重字段"),status:L.string().optional(),sourceSystem:L.string().optional(),taskMode:L.string().optional()}),handler:async($,Y)=>{let U=await u4($,{limit:1000,status:Y.status,sourceSystem:Y.sourceSystem,taskMode:Y.taskMode}),Q=Y.dedupeBy??"sourceDocumentSN",I=U.records,J={},K={},z=new Set;for(let H of I){let W=H.status??"unknown";J[W]=(J[W]??0)+1;let X=H.sourceSystem??"unknown";K[X]=(K[X]??0)+1;let Z=H[Q];if(Z)z.add(String(Z))}let G=Math.max(0,I.length-z.size);return{total:I.length,dedupeBy:Q,unique:z.size,duplicateRuns:G,dedupeNote:G>0?`存在${G}笔重复运行记录(同一单据重跑或修改重推)`:"全部单据唯一,无重复记录",byStatus:J,bySourceSystem:K}}},{name:"seal_approval_runs_count",description:"统计符合条件的审核记录总数",parameters:L.object({status:L.string().optional(),sourceSystem:L.string().optional(),taskMode:L.string().optional(),search:L.string().optional(),startDate:L.string().optional().describe("起始时间戳(毫秒)或日期字符串"),endDate:L.string().optional().describe("结束时间戳(毫秒)或日期字符串")}),handler:async($,Y)=>{let U=await u4($,{limit:1,status:Y.status,sourceSystem:Y.sourceSystem,taskMode:Y.taskMode,search:Y.search,startDate:t$(Y.startDate,!1),endDate:t$(Y.endDate,!0)});return{total:U.total??U.records.length}}}]});import{readFileSync as py1}from"node:fs";var LQ4,FQ4,wQ4,MQ4,OQ4,NQ4,DQ4,AQ4,Vo,BQ4,PQ4,TQ4,my1,ly1,oy1,EQ4,jQ4,CQ4,RQ4,_Q4,vQ4,SQ4,hQ4,ry1,gQ4,yQ4,kQ4
Line truncated
`)}function Gk1($){let Y=[];if(Y.push(`seal-use${$.area}-${$.title}`),$.description)Y.push($.description);Y.push(""),Y.push("Usage:");let U=new Map;for(let I of $.commands){let J=I.group??"",K=U.get(J)??[];K.push(I),U.set(J,K)}let Q=[...$.groupOrder??[],...[...U.keys()].filter((I)=>!$.groupOrder?.includes(I))];for(let I of Q){let J=U.get(I);if(!J)continue;if(I)Y.push(""),Y.push(`${I}:`);for(let K of J)for(let z of K.usage)Y.push(`${z}`)}if($.commands.some((I)=>I.name))Y.push(""),Y.push(`Run'seal-use ${$.area} <command> --help'fordetailsonaspecificcommand.`);return Y.join(`
`)}function lv0(){let $=[];$.push("seal-use CLI"),$.push(""),$.push("Usage:"),$.push(" seal-use version");for(let Y of ov0)for(let U of Y.commands)for(let Q of U.usage)$.push(`${Q}`);return $.push(""),$.push("Run 'seal-use <command> --help' for details on a specific command."),$.join(`
`)}var ov0;var Bo=o(()=>{p8();ov0=[{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
`;if(Y.outputFile){Uk1(Y.outputFile,U),console.log(JSON.stringify({outputFile:Y.outputFile,bytes:Buffer.byteLength(U,"utf-8")},null,2));return}console.log(U.trimEnd())}function Kk1($,Y={}){if(Y.allowFull||Y.outputFile)return;let U=Buffer.byteLength(JSON.stringify($),"utf-8");if(U>Jk1)throw new Qq(`Outputislarge(${U}bytes).Use--summary,--fields,--count,or--output-file;pass--fullonlywhenyoureallyneedthefullresponse.`)}function rv0($,Y){if(Y)return;let U=$&&typeof $==="object"?$:{},I=typeof U.count==="number"?U.count:void 0,Q=Array.isArray(U.rules)?U.rules.length:void 0,J=Buffer.byteLength(JSON.stringify($),"utf-8"),K=I??Q??0;if(K>Ik1||J>Qk1)throw new Qq(`Rulelistislarge(${K}rules,${J}bytes).Use"seal-use rules list --summary","seal-use rules count",or--output-file;pass--fullonlywhenyoureallyneedfulldescriptions.`,"seal-use rules list --summary")}function T0($){return{allowFull:z0($.full)===!0,outputFile:R($.outputFile)??R($["output-file"])}}function sv0($=[]){console.log(lv0($))}var Ik1=100,Qk1=120000,ov0,Jk1=200000;var $4=o(()=>{L4();p8();No();ov0=["code","status","strictness","scope","updatedAt"]});var Ao={};L8(Ao,{selectCorp:()=>M1,runToolResult:()=>C$,runTool:()=>v0,globalConfigSummary:()=>KY});function M1($){let Y=K$(),U=T4(),I=r2(Y,{stateful:U.stateful,defaultCorpId:U.defaultCorpId,corpId:$},m3());return LB0(I.id),I}function KY($=T4()){return{mode:$.stateful?"stateful":"stateless",stateful:$.stateful,...$.stateful&&$.defaultCorpId?{defaultCorpId:$.defaultCorpId}:{},...$.testEnterprisesDir?{testEnterprisesDir:$.testEnterprisesDir}:{},lint:$.lint,configFile:DI()}}async function v0($,Y,U,I,Q={}){C0(await C$($,Y,U,I),Q)}async function C$($,Y,U,I){let Q=Zo.find((z)=>z.name===$);if(!Q)throw Error(`UnknownSealtool:${$}`);let J=Object.fromEntries(Object.entries(I).filter(([,z])=>z!==void 0)),K=Q.handler;return K(Y,J,{corp:U})}var D4=o(()=>{t$();LP();qo();$4()});import{existsSync as av0}from"node:fs";async function tv0($,Y){if(!av0($))throw Error(`Filenotfound:${$}`);let U=lI($);C0(await mI(U.fileBuffer,U.fileName,Y))}async function oT($,Y,U,I,Q){if($==="ready"||$==="status"){let J=Y??R(Q.options.file)??R(Q.options.input),K=await cT(U,I,{filePath:J,webhook:R(Q.options.webhook)??R(Q.options.selector)});if(console.error(`[webhook-ready]企业环境:${K.corp.name}(${K.corp.id})[${K.stateMode}]`),K.corp.tenant?.name)console.error(`[webhook-ready]租户信息:${K.corp.tenant.name}(${K.corp.tenant.id})`);console.error(`[webhook-ready]凭证状态:${K.authStatus==="ok"?"OK":`异常 (${K.authError})`}`),console.error(`[webhook-ready]Webhook通道:${K.activeWebhooks.length}个可用`);for(let z of K.activeWebhooks){let G=z.isDefault?" [默认通道]":"";console.error(`-${z.name}(${z.id})mode=${z.mode}${G}`)}if(K.materialPack)console.error(`[webhook-ready]材料包预检:${K.materialPack.valid?`通过 (${K.materialPack.documentCount} 单)`:`失败 (${K.materialPack.errors?.join("; ")})`}`);if(K.ready)console.error(`\uD83D\uDFE2${K.statusMessage}`),console.error(`\uD83D\uDC49Nextaction:${K.nextAction}`);else console.error(`\uD83D\uDD34准备阶段未通过:${K.statusMessage}`),console.error(`\uD83D\uDC49Nextaction:${K.nextAction}`);C0(K,T0(Q.options));return}if($==="replay"){let J=Y??R(Q.options.recordId)??R(Q.options["record-id"])??R(Q.options.id),K=R(Q.options.recordIds)??R(Q.options["record-ids"]),z=K?K.split(",").map((n)=>n.trim()).filter(Boolean):void 0,G=R(Q.options.sn)??R(Q.options.documentSn)??R(Q.options["document-sn"]),H=R(Q.options.sns)??R(Q.options["document-sns"]),W=H?H.split(",").map((n)=>n.trim()).filter(Boolean):void 0,X=l0(Q.options.limit),Z=R(Q.options.status),q=R(Q.options.startDate)??R(Q.options["start-date"]),V=R(Q.options.endDate)??R(Q.options["end-date"]);if(!J&&!z&&!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 w=R(Q.options.sourceCorp)??R(Q.options["source-corp"])??R(Q.options.prodCorp)??R(Q.options["prod-corp"]),M=R(Q.options.targetCorp)??R(Q.options["target-corp"])??R(Q.options.testCorp)??R(Q.options["test-corp"]),F=z0(Q.options.force)===!0,{sourceCorp:N,targetCorp:O}=_P({sourceCorpId:w,targetCorpId:M,activeCorp:I,force:F},M1),D=N.id===I.id?U:await P1(N),P=O.id===I.id?U:await P1(O),T=R(Q.options.webhook)??R(Q.options.selector),A=R(Q.options.snSuffix)??R(Q.options["sn-suffix"]),E=R(Q.options.snPrefix)??R(Q.options["sn-prefix"]),C=R(Q.options.docIdSuffix)??R(Q.options["doc-id-suffix"]),i=R(Q.options.docIdPrefix)??R(Q.options["doc-id-prefix"]),x=z0(Q.options.dryRun)??z0(Q.options["dry-run"]),b=await Fz({query:{recordId:J,recordIds:z,sn:G,sns:W,limit:X,status:Z,startDate:q,endDate:V},sourceClient:D,targetClient:P,sourceCorp:N,targetCorp:O,webhookSelector:T,snPrefix:E,snSuffix:A,docIdPrefix:i,docIdSuffix:C,dryRun:x});if(x){console.error(`[webhook-replay]预Line truncated
or:seal-usecorpsbind-test<testCorpId>--corp<prodCorpId>[--confirm][--force]`);let J=M1(I),K=M1(Q);if(J.id===K.id)throw E4(`Cannotbindenterprise'${J.id}'toitself.`);if(J.prodCorpId&&J.prodCorpId!==K.id)throw E4(`Cannotuse'${J.id}'asaproductionenterprisebecauseitisalreadyregisteredasatestenterprisefor'${J.prodCorpId}'.Multi-tierchainingisnotpermitted.`);if(K.testCorpId&&K.testCorpId!==J.id)throw E4(`Cannotbind'${K.id}'asatestenterprisebecauseitalreadyhasaboundtestenterprise'${K.testCorpId}'.Multi-tierchainingisnotpermitted.`);let z=z0(U.options.force)===!0;if(J.testCorpId&&J.testCorpId!==K.id||K.prodCorpId&&K.prodCorpId!==J.id){if(!z)throw m6(`Enterprisebindingconflict:productionenterprise'${J.id}'isboundto'${J.testCorpId??"none"}',andtestenterprise'${K.id}'isboundto'${K.prodCorpId??"none"}'.Overwritinganexistingbindingrequires--forceand--confirm.`,`seal-usecorpsbind-test${J.id}${K.id}--confirm--force`)}if(!(z0(U.options.confirm)===!0||z0(U.options.yes)===!0)){let X=z?" --force":"";throw m6(`Refusingtobindtestenterprise'${K.name}'(${K.id})toproductionenterprise'${J.name}'(${J.id})without--confirm.Enterprisebindingestablishes1-to-1syncpairingandmarks'${K.id}'asatestenvironment.`,`seal-usecorpsbind-test${J.id}${K.id}--confirm${X}`)}if(J.testCorpId&&J.testCorpId!==K.id)try{g9(J.testCorpId,{prodCorpId:void 0})}catch{}if(K.prodCorpId&&K.prodCorpId!==J.id)try{g9(K.prodCorpId,{testCorpId:void 0})}catch{}let H=g9(J.id,{environment:"production",testCorpId:K.id}),W=g9(K.id,{environment:"test",prodCorpId:J.id});return C0({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 I=Y??R(U.options.corp),Q=M1(I);if(!Q.testCorpId&&!Q.prodCorpId)return C0({unbound:!1,message:`Enterprise'${Q.name}'(${Q.id})doesnothaveanactivetestenterprisebinding.`}),!0;let J=Q.testCorpId?Q.id:Q.prodCorpId,K=Q.testCorpId?Q.testCorpId:Q.id;if(!(z0(U.options.confirm)===!0||z0(U.options.yes)===!0))throw m6(`Refusingtounbindproductionenterprise'${J}'andtestenterprise'${K}'without--confirm.`,`seal-usecorpsunbind-test${Q.id}--confirm`);g9(J,{testCorpId:void 0});try{g9(K,{prodCorpId:void 0})}catch{}return C0({success:!0,unboundProduction:J,unboundTest:K}),!0}return!1}var QS0=o(()=>{t$();D4();p8();L4();$4()});function rT($){let Y;try{Y=new URL($.trim())}catch{throw Error("Invalid Seal delegate link: expected a valid HTTPS URL")}if(Y.protocol!=="https:")throw Error("Invalid Seal delegate link: expected HTTPS");let U=Y.hostname.toLowerCase();if(!U.endsWith(JS0))throw Error(`InvalidSealdelegatelink:expectedhostendingin${JS0},got${U}`);let I=Y.pathname.replace(/\/+$/,"");if(I!==KS0)throw Error(`InvalidSealdelegatelink:expectedpath${KS0},got${I}`);let Q=Y.searchParams.get("token");if(!Q)throw Error("Invalid Seal delegate link: token query parameter is required");return{sealUrl:Y.origin,delegateToken:Q}}async function zS0($){let Y=typeof $==="string"?rT($):$;return(await C6(Y.sealUrl,void 0).post("api/v1/delegation/preview",{json:{token:Y.delegateToken}}).json()).data}async function GS0($){let Y=typeof $==="string"?rT($):$,U=Y.sealUrl,I=C6(U,void 0),Q=await I.post("api/v1/delegation/consume",{json:{token:Y.delegateToken}}),J=Q.headers.get("set-cookie")??"",K=typeof Q.headers.getSetCookie==="function"?Q.headers.getSetCookie():[J],z="";for(let M of K)if(M&&M.includes("session_token=")){z=(M.split(";")[0]??"").trim();break}let G;try{G=await I.get("api/auth/get-session",{headers:z?{cookie:z}:{}}).json()}catch{}let H=G?.session?.token;if(!H&&z){let M=z.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 F=Math.floor((M-Date.now())/1000);if(F>0)W=F}}let Z=await C6(U,H).get("api/v1/auth/me").json(),q=Z.data&&typeof Z.data==="object"?Z.data:Z,V=q.user??G?.user??{},w=q.tenant??{};return{sealUrl:U,token:H,expiresIn:W,user:V,tenant:w}}function sT($){let Y=[],U=0,I="";try{let K=new URL($.trim()),z=K.hostname.toLowerCase(),G=K.pathname.replace(/\/+$/,"");if(z.endsWith(".ekuaibao.com")||z.endsWith(".hosecloud.com")||z==="ekuaibao.com"||z==="hosecloud.com")U+=40,I="host is Hose domain";if(G==="/web/thirdparty.html")U+=40,I+="; path is /web/thirdparty.html";if(K.searchParams.has("accessToken"))U+=10,I+="; has accessToken";if(K.searchParams.has("ekbCorpId"))U+=10,I+="; has ekbCorpId"}catch{U=0}if(U>0)Y.push({kind:"hose",score:U,reason:I});let Q=0,J="";try{let K=new URL($.trim()),z=K.hostname.toLowerCase(),G=K.pathname.replace(/\/+$/,"");if(z.endsWith(".sealai.cc"))Q+=40,J="host ends with .sealai.cc";if(G==="/delegate")Q+=40,J+="; path is /delegate";if(
Line truncated
`,{mode:384}),{config:U,path:Q}}var To=o(()=>{t$();HP()});function W5($){return typeof $==="string"&&$?$:void 0}function Zk1($){return{headers:Sd.parse($.headers),cookies:hd.parse($.cookies)}}async function qk1($,Y,U={}){let I=await a6(C6($,Y,U));return{user:I.user??{},tenant:I.tenant??{}}}async function HS0($){let Y=$.sealUrl.replace(/\/+$/,""),U=$.expiresIn??2592000,I=$.force===!0||$.verify===!1?!1:!0,Q=Zk1($),J=I?await qk1(Y,$.token,j6(Q)):void 0,K=XS0($,{token:$.token,sealUrl:Y,expiresIn:U,expiresAt:$.expiresAt,verify:I,remote:J,custom:Q}),z=$.tenantId??W5(J?.tenant.id),G=$.tenantSlug??W5(J?.tenant.tenantSlug);return{...K,verified:I,tenantId:z,tenantSlug:G}}function WS0($){let Y=W5($.session.tenant.tenantSlug),U=W5($.session.tenant.id),I=Y??U??"seal-delegate";return{...XS0({id:I,corpId:I,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:U,tenantSlug:Y}}function XS0($,Y){let U=Y.remote?.user,I=Y.remote?.tenant,Q=$.tenantSlug??W5(I?.tenantSlug),J=$.tenantId??W5(I?.id),K=$.tenantName??W5(I?.name),z=$.id??Q??J;if(!z)throw Error("Missing required JSON field: id. Seal whoami did not return tenantSlug or tenantId.");let G=Y.expiresAt?T8(Y.expiresAt):A1(Date.now()+Y.expiresIn*1000),H=$.staffId??W5(U?.providerUserId)??W5(U?.id)??"seal",W=$.provider??W5(U?.provider)??W5(I?.providerConfig?.provider),X=$.corpId??Q??J??z,Z={id:z,name:$.name??K??z,environment:"production",seal:{url:Y.sealUrl,tenantSlug:Q,headers:Y.custom?.headers,cookies:Y.custom?.cookies,endpoints:{approvalStylePreferences:"api/v1/agent/ai-approval/config"}},source:{type:"seal",token:Y.token,sealUrl:Y.sealUrl,expiresIn:Y.expiresIn,expiresAt:G,staffId:H,corpId:X,tenantId:J,tenantSlug:Q,tenantName:K,providerUserId:W5(U?.providerUserId),provider:W},auth:{refreshTtl:300}};return cq(Z,{overwrite:$.overwrite===!0})}var Eo=o(()=>{To();HP();i6();X4()});async function az($){let[Y,U]=await Promise.all([E10($),P1($)]),I=await a6(U);return{...Y,tenantId:I.tenant.id,tenantSlug:I.tenant.tenantSlug??Y.tenantSlug,tenantName:I.tenant.name,raw:{...typeof Y.raw==="object"&&Y.raw!==null?Y.raw:{},user:{id:I.user.id,name:I.user.name,isAdmin:I.user.isAdmin,providerUserId:I.user.providerUserId,hosecloudStaff:I.user.hosecloudStaff},tenant:I.tenant}}}var aT=o(()=>{i6();Dy();X4()});async function ZS0($){let Y=await IJ($.appKey,$.appSecurity,$.domain),U=await CM(Y.domain,Y.openapiToken).catch(()=>[]);return{...Y,roleCount:U.reduce((I,Q)=>I+Q.roleDefs.length,0),roleGroups:U.map((I)=>({id:I.id,name:I.name,roleDefs:I.roleDefs.map((Q)=>({id:Q.id,name:Q.name,sourceType:Q.sourceType}))}))}}async function qS0($){let Y=await IJ($.appKey,$.appSecurity,$.domain),U=$.role??$.roleDefId??"admin",I=await CM(Y.domain,Y.openapiToken),Q,J;for(let G of I){for(let H of G.roleDefs)if(H.id===U||H.id===`${Y.corpId}:${U}`){Q=H.id,J=H.name;break}if(Q)break}if(!Q&&(U==="admin"||U==="主管理员"))for(let G of I){for(let H of G.roleDefs)if(H.id.endsWith(":admin")||H.name==="主管理员"){Q=H.id,J=H.name;break}if(Q)break}if(!Q)for(let G of I){for(let H of G.roleDefs)if(H.name.toLowerCase().includes(U.toLowerCase())){Q=H.id,J=H.name;break}if(Q)break}if(!Q)throw Error(`Rolenotfoundmatchingquery:'${U}'.Run'seal-use corps probe-hose'toviewallavailableroles.`);let K=await wy(Y.domain,Y.openapiToken,Q),z=await My(Y.domain,Y.openapiToken,K.staffs);return{domain:Y.domain,corpId:Y.corpId,corpName:Y.corpName??Y.corpId,roleId:Q,roleName:J,staffs:z}}async function nq($){let Y=$.domain,U=$.staffId??$.proxyStaffBizId,I=$.force===!0,Q=I||$.verify===!1?!1:!0,J=Y,K=$.corpId??$.corporationId,z=$.name,G;if(!J||!K||!U){let V=await IJ($.appKey,$.appSecurity,Y);J=V.domain,K=K??V.corpId,z=z??V.corpName,G=V.openapiToken}let H=U;if(!H&&G&&J){let V=$.role??"admin",w=await CM(J,G).catch(()=>[]),M;for(let F of w){for(let N of F.roleDefs)if(N.id.endsWith(`:${V}`)||N.name===V||N.id===V){M=N.id;break}if(M)break}if(!M)M=w.find((F)=>F.roleDefs.some((N)=>N.id.endsWith(":admin")))?.roleDefs.find((F)=>F.id.endsWith(":admin"))?.id;if(M){let F=await wy(J,G,M).catch(()=>({staffs:[]})),N=await My(J,G,F.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(`Multiplestaffmembersmatched'${$.staffName??$.staffPhone}':${O.map((D)=>`${D.name}(${D.id})`).join(", ")}.PleasespecifyexactstaffId.`);else throw Error(`Nostaffmemberfoundmatching'${$.staffName??$.staffPhone}'underrole${M}.Run'seal-use corps hose-staffs'toviewcandidates.`)}else if(!I){let O=N.map((D)=>({id:D.id,name:D.name,cellphone:D.cellphone,active:D.active}));throw Error(`Missingrequiredparameter:staffId.Candidates:${JSON.stringify(O)}`)}else H=N.find(
Line truncated
`+"\uD83D\uDCA1 说明:此能力专属于合思 (Hose) 子域,用于将临时会话提权为标准 OpenAPI 开发者接入。需要企业管理员已在合思开放平台创建应用并生成 appKey/appSecurity。",I);if(U.keyId||U.appKey){let Q=$.find((J)=>U.keyId&&J.id===U.keyId||U.appKey&&J.appKey===U.appKey);if(!Q)throw new oI(`指定的合思密钥不存在,请从上述候选列表中选择正确的appKey或keyId。
`;if(Y.outputFile){Hk1(Y.outputFile,U),console.log(JSON.stringify({outputFile:Y.outputFile,bytes:Buffer.byteLength(U,"utf-8")},null,2));return}console.log(U.trimEnd())}function qk1($,Y={}){if(Y.allowFull||Y.outputFile)return;let U=Buffer.byteLength(JSON.stringify($),"utf-8");if(U>Zk1)throw new Iq(`Outputislarge(${U}bytes).Use--summary,--fields,--count,or--output-file;pass--fullonlywhenyoureallyneedthefullresponse.`)}function av0($,Y){if(Y)return;let U=$&&typeof $==="object"?$:{},Q=typeof U.count==="number"?U.count:void 0,I=Array.isArray(U.rules)?U.rules.length:void 0,J=Buffer.byteLength(JSON.stringify($),"utf-8"),K=Q??I??0;if(K>Wk1||J>Xk1)throw new Iq(`Rulelistislarge(${K}rules,${J}bytes).Use"seal-use rules list --summary","seal-use rules count",or--output-file;pass--fullonlywhenyoureallyneedfulldescriptions.`,"seal-use rules list --summary")}function T0($){return{allowFull:z0($.full)===!0,outputFile:R($.outputFile)??R($["output-file"])}}function ev0($=[]){console.log(sv0($))}var Wk1=100,Xk1=120000,tv0,Zk1=200000;var $4=o(()=>{L4();p8();Bo();tv0=["code","status","strictness","scope","updatedAt"]});var To={};L8(To,{selectCorp:()=>M1,runToolResult:()=>C$,runTool:()=>v0,globalConfigSummary:()=>KY});function M1($){let Y=K$(),U=T4(),Q=r2(Y,{stateful:U.stateful,defaultCorpId:U.defaultCorpId,corpId:$},m3());return wB0(Q.id),Q}function KY($=T4()){return{mode:$.stateful?"stateful":"stateless",stateful:$.stateful,...$.stateful&&$.defaultCorpId?{defaultCorpId:$.defaultCorpId}:{},...$.testEnterprisesDir?{testEnterprisesDir:$.testEnterprisesDir}:{},lint:$.lint,configFile:DQ()}}async function v0($,Y,U,Q,I={}){C0(await C$($,Y,U,Q),I)}async function C$($,Y,U,Q){let I=Lo.find((z)=>z.name===$);if(!I)throw Error(`UnknownSealtool:${$}`);let J=Object.fromEntries(Object.entries(Q).filter(([,z])=>z!==void 0)),K=I.handler;return K(Y,J,{corp:U})}var D4=o(()=>{a$();LP();Fo();$4()});import{existsSync as $S0}from"node:fs";async function YS0($,Y){if(!$S0($))throw Error(`Filenotfound:${$}`);let U=lQ($);C0(await mQ(U.fileBuffer,U.fileName,Y))}async function rT($,Y,U,Q,I){if($==="ready"||$==="status"){let J=Y??R(I.options.file)??R(I.options.input),K=await nT(U,Q,{filePath:J,webhook:R(I.options.webhook)??R(I.options.selector)});if(console.error(`[webhook-ready]企业环境:${K.corp.name}(${K.corp.id})[${K.stateMode}]`),K.corp.tenant?.name)console.error(`[webhook-ready]租户信息:${K.corp.tenant.name}(${K.corp.tenant.id})`);console.error(`[webhook-ready]凭证状态:${K.authStatus==="ok"?"OK":`异常 (${K.authError})`}`),console.error(`[webhook-ready]Webhook通道:${K.activeWebhooks.length}个可用`);for(let z of K.activeWebhooks){let G=z.isDefault?" [默认通道]":"";console.error(`-${z.name}(${z.id})mode=${z.mode}${G}`)}if(K.materialPack)console.error(`[webhook-ready]材料包预检:${K.materialPack.valid?`通过 (${K.materialPack.documentCount} 单)`:`失败 (${K.materialPack.errors?.join("; ")})`}`);if(K.ready)console.error(`\uD83D\uDFE2${K.statusMessage}`),console.error(`\uD83D\uDC49Nextaction:${K.nextAction}`);else console.error(`\uD83D\uDD34准备阶段未通过:${K.statusMessage}`),console.error(`\uD83D\uDC49Nextaction:${K.nextAction}`);C0(K,T0(I.options));return}if($==="replay"){let J=Y??R(I.options.recordId)??R(I.options["record-id"])??R(I.options.id),K=R(I.options.recordIds)??R(I.options["record-ids"]),z=K?K.split(",").map((n)=>n.trim()).filter(Boolean):void 0,G=R(I.options.sn)??R(I.options.documentSn)??R(I.options["document-sn"]),H=R(I.options.sns)??R(I.options["document-sns"]),W=H?H.split(",").map((n)=>n.trim()).filter(Boolean):void 0,X=l0(I.options.limit),Z=R(I.options.status),q=R(I.options.startDate)??R(I.options["start-date"]),V=R(I.options.endDate)??R(I.options["end-date"]);if(!J&&!z&&!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 w=R(I.options.sourceCorp)??R(I.options["source-corp"])??R(I.options.prodCorp)??R(I.options["prod-corp"]),M=R(I.options.targetCorp)??R(I.options["target-corp"])??R(I.options.testCorp)??R(I.options["test-corp"]),F=z0(I.options.force)===!0,{sourceCorp:N,targetCorp:O}=vP({sourceCorpId:w,targetCorpId:M,activeCorp:Q,force:F},M1),D=N.id===Q.id?U:await P1(N),P=O.id===Q.id?U:await P1(O),T=R(I.options.webhook)??R(I.options.selector),A=R(I.options.snSuffix)??R(I.options["sn-suffix"]),E=R(I.options.snPrefix)??R(I.options["sn-prefix"]),C=R(I.options.docIdSuffix)??R(I.options["doc-id-suffix"]),i=R(I.options.docIdPrefix)??R(I.options["doc-id-prefix"]),x=z0(I.options.dryRun)??z0(I.options["dry-run"]),b=await Fz({query:{recordId:J,recordIds:z,sn:G,sns:W,limit:X,status:Z,startDate:q,endDate:V},sourceClient:D,targetClient:P,sourceCorp:N,targetCorp:O,webhookSelector:T,snPrefix:E,snSuffix:A,docIdPrefix:i,docIdSuffix:C,dryRun:x});if(x){console.error(`[webhook-replay]预Line truncated
or:seal-usecorpsbind-test<testCorpId>--corp<prodCorpId>[--confirm][--force]`);let J=M1(Q),K=M1(I);if(J.id===K.id)throw E4(`Cannotbindenterprise'${J.id}'toitself.`);if(J.prodCorpId&&J.prodCorpId!==K.id)throw E4(`Cannotuse'${J.id}'asaproductionenterprisebecauseitisalreadyregisteredasatestenterprisefor'${J.prodCorpId}'.Multi-tierchainingisnotpermitted.`);if(K.testCorpId&&K.testCorpId!==J.id)throw E4(`Cannotbind'${K.id}'asatestenterprisebecauseitalreadyhasaboundtestenterprise'${K.testCorpId}'.Multi-tierchainingisnotpermitted.`);let z=z0(U.options.force)===!0;if(J.testCorpId&&J.testCorpId!==K.id||K.prodCorpId&&K.prodCorpId!==J.id){if(!z)throw m6(`Enterprisebindingconflict:productionenterprise'${J.id}'isboundto'${J.testCorpId??"none"}',andtestenterprise'${K.id}'isboundto'${K.prodCorpId??"none"}'.Overwritinganexistingbindingrequires--forceand--confirm.`,`seal-usecorpsbind-test${J.id}${K.id}--confirm--force`)}if(!(z0(U.options.confirm)===!0||z0(U.options.yes)===!0)){let X=z?" --force":"";throw m6(`Refusingtobindtestenterprise'${K.name}'(${K.id})toproductionenterprise'${J.name}'(${J.id})without--confirm.Enterprisebindingestablishes1-to-1syncpairingandmarks'${K.id}'asatestenvironment.`,`seal-usecorpsbind-test${J.id}${K.id}--confirm${X}`)}if(J.testCorpId&&J.testCorpId!==K.id)try{y9(J.testCorpId,{prodCorpId:void 0})}catch{}if(K.prodCorpId&&K.prodCorpId!==J.id)try{y9(K.prodCorpId,{testCorpId:void 0})}catch{}let H=y9(J.id,{environment:"production",testCorpId:K.id}),W=y9(K.id,{environment:"test",prodCorpId:J.id});return C0({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 Q=Y??R(U.options.corp),I=M1(Q);if(!I.testCorpId&&!I.prodCorpId)return C0({unbound:!1,message:`Enterprise'${I.name}'(${I.id})doesnothaveanactivetestenterprisebinding.`}),!0;let J=I.testCorpId?I.id:I.prodCorpId,K=I.testCorpId?I.testCorpId:I.id;if(!(z0(U.options.confirm)===!0||z0(U.options.yes)===!0))throw m6(`Refusingtounbindproductionenterprise'${J}'andtestenterprise'${K}'without--confirm.`,`seal-usecorpsunbind-test${I.id}--confirm`);y9(J,{testCorpId:void 0});try{y9(K,{prodCorpId:void 0})}catch{}return C0({success:!0,unboundProduction:J,unboundTest:K}),!0}return!1}var zS0=o(()=>{a$();D4();p8();L4();$4()});function sT($){let Y;try{Y=new URL($.trim())}catch{throw Error("Invalid Seal delegate link: expected a valid HTTPS URL")}if(Y.protocol!=="https:")throw Error("Invalid Seal delegate link: expected HTTPS");let U=Y.hostname.toLowerCase();if(!U.endsWith(GS0))throw Error(`InvalidSealdelegatelink:expectedhostendingin${GS0},got${U}`);let Q=Y.pathname.replace(/\/+$/,"");if(Q!==HS0)throw Error(`InvalidSealdelegatelink:expectedpath${HS0},got${Q}`);let I=Y.searchParams.get("token");if(!I)throw Error("Invalid Seal delegate link: token query parameter is required");return{sealUrl:Y.origin,delegateToken:I}}async function WS0($){let Y=typeof $==="string"?sT($):$;return(await C6(Y.sealUrl,void 0).post("api/v1/delegation/preview",{json:{token:Y.delegateToken}}).json()).data}async function XS0($){let Y=typeof $==="string"?sT($):$,U=Y.sealUrl,Q=C6(U,void 0),I=await Q.post("api/v1/delegation/consume",{json:{token:Y.delegateToken}}),J=I.headers.get("set-cookie")??"",K=typeof I.headers.getSetCookie==="function"?I.headers.getSetCookie():[J],z="";for(let M of K)if(M&&M.includes("session_token=")){z=(M.split(";")[0]??"").trim();break}let G;try{G=await Q.get("api/auth/get-session",{headers:z?{cookie:z}:{}}).json()}catch{}let H=G?.session?.token;if(!H&&z){let M=z.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 F=Math.floor((M-Date.now())/1000);if(F>0)W=F}}let Z=await C6(U,H).get("api/v1/auth/me").json(),q=Z.data&&typeof Z.data==="object"?Z.data:Z,V=q.user??G?.user??{},w=q.tenant??{};return{sealUrl:U,token:H,expiresIn:W,user:V,tenant:w}}function tT($){let Y=[],U=0,Q="";try{let K=new URL($.trim()),z=K.hostname.toLowerCase(),G=K.pathname.replace(/\/+$/,"");if(z.endsWith(".ekuaibao.com")||z.endsWith(".hosecloud.com")||z==="ekuaibao.com"||z==="hosecloud.com")U+=40,Q="host is Hose domain";if(G==="/web/thirdparty.html")U+=40,Q+="; path is /web/thirdparty.html";if(K.searchParams.has("accessToken"))U+=10,Q+="; has accessToken";if(K.searchParams.has("ekbCorpId"))U+=10,Q+="; has ekbCorpId"}catch{U=0}if(U>0)Y.push({kind:"hose",score:U,reason:Q});let I=0,J="";try{let K=new URL($.trim()),z=K.hostname.toLowerCase(),G=K.pathname.replace(/\/+$/,"");if(z.endsWith(".sealai.cc"))I+=40,J="host ends with .sealai.cc";if(G==="/delegate")I+=40,J+="; path is /delegate";if(
Line truncated
`,{mode:384}),{config:U,path:I}}var Co=o(()=>{a$();HP()});function W5($){return typeof $==="string"&&$?$:void 0}function Ok1($){return{headers:gd.parse($.headers),cookies:yd.parse($.cookies)}}async function Nk1($,Y,U={}){let Q=await t6(C6($,Y,U));return{user:Q.user??{},tenant:Q.tenant??{}}}async function ZS0($){let Y=$.sealUrl.replace(/\/+$/,""),U=$.expiresIn??2592000,Q=$.force===!0||$.verify===!1?!1:!0,I=Ok1($),J=Q?await Nk1(Y,$.token,j6(I)):void 0,K=VS0($,{token:$.token,sealUrl:Y,expiresIn:U,expiresAt:$.expiresAt,verify:Q,remote:J,custom:I}),z=$.tenantId??W5(J?.tenant.id),G=$.tenantSlug??W5(J?.tenant.tenantSlug);return{...K,verified:Q,tenantId:z,tenantSlug:G}}function qS0($){let Y=W5($.session.tenant.tenantSlug),U=W5($.session.tenant.id),Q=Y??U??"seal-delegate";return{...VS0({id:Q,corpId:Q,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:U,tenantSlug:Y}}function VS0($,Y){let U=Y.remote?.user,Q=Y.remote?.tenant,I=$.tenantSlug??W5(Q?.tenantSlug),J=$.tenantId??W5(Q?.id),K=$.tenantName??W5(Q?.name),z=$.id??I??J;if(!z)throw Error("Missing required JSON field: id. Seal whoami did not return tenantSlug or tenantId.");let G=Y.expiresAt?T8(Y.expiresAt):A1(Date.now()+Y.expiresIn*1000),H=$.staffId??W5(U?.providerUserId)??W5(U?.id)??"seal",W=$.provider??W5(U?.provider)??W5(Q?.providerConfig?.provider),X=$.corpId??I??J??z,Z={id:z,name:$.name??K??z,environment:"production",seal:{url:Y.sealUrl,tenantSlug:I,headers:Y.custom?.headers,cookies:Y.custom?.cookies,endpoints:{approvalStylePreferences:"api/v1/agent/ai-approval/config"}},source:{type:"seal",token:Y.token,sealUrl:Y.sealUrl,expiresIn:Y.expiresIn,expiresAt:G,staffId:H,corpId:X,tenantId:J,tenantSlug:I,tenantName:K,providerUserId:W5(U?.providerUserId),provider:W},auth:{refreshTtl:300}};return cq(Z,{overwrite:$.overwrite===!0})}var Ro=o(()=>{Co();HP();i6();X4()});async function tz($){let[Y,U]=await Promise.all([R10($),P1($)]),Q=await t6(U);return{...Y,tenantId:Q.tenant.id,tenantSlug:Q.tenant.tenantSlug??Y.tenantSlug,tenantName:Q.tenant.name,raw:{...typeof Y.raw==="object"&&Y.raw!==null?Y.raw:{},user:{id:Q.user.id,name:Q.user.name,isAdmin:Q.user.isAdmin,providerUserId:Q.user.providerUserId,hosecloudStaff:Q.user.hosecloudStaff},tenant:Q.tenant}}}var aT=o(()=>{i6();Ag();X4()});async function LS0($){let Y=await QJ($.appKey,$.appSecurity,$.domain),U=await CM(Y.domain,Y.openapiToken).catch(()=>[]);return{...Y,roleCount:U.reduce((Q,I)=>Q+I.roleDefs.length,0),roleGroups:U.map((Q)=>({id:Q.id,name:Q.name,roleDefs:Q.roleDefs.map((I)=>({id:I.id,name:I.name,sourceType:I.sourceType}))}))}}async function FS0($){let Y=await QJ($.appKey,$.appSecurity,$.domain),U=$.role??$.roleDefId??"admin",Q=await CM(Y.domain,Y.openapiToken),I,J;for(let G of Q){for(let H of G.roleDefs)if(H.id===U||H.id===`${Y.corpId}:${U}`){I=H.id,J=H.name;break}if(I)break}if(!I&&(U==="admin"||U==="主管理员"))for(let G of Q){for(let H of G.roleDefs)if(H.id.endsWith(":admin")||H.name==="主管理员"){I=H.id,J=H.name;break}if(I)break}if(!I)for(let G of Q){for(let H of G.roleDefs)if(H.name.toLowerCase().includes(U.toLowerCase())){I=H.id,J=H.name;break}if(I)break}if(!I)throw Error(`Rolenotfoundmatchingquery:'${U}'.Run'seal-use corps probe-hose'toviewallavailableroles.`);let K=await Mg(Y.domain,Y.openapiToken,I),z=await Og(Y.domain,Y.openapiToken,K.staffs);return{domain:Y.domain,corpId:Y.corpId,corpName:Y.corpName??Y.corpId,roleId:I,roleName:J,staffs:z}}async function nq($){let Y=$.domain,U=$.staffId??$.proxyStaffBizId,Q=$.force===!0,I=Q||$.verify===!1?!1:!0,J=Y,K=$.corpId??$.corporationId,z=$.name,G;if(!J||!K||!U){let V=await QJ($.appKey,$.appSecurity,Y);J=V.domain,K=K??V.corpId,z=z??V.corpName,G=V.openapiToken}let H=U;if(!H&&G&&J){let V=$.role??"admin",w=await CM(J,G).catch(()=>[]),M;for(let F of w){for(let N of F.roleDefs)if(N.id.endsWith(`:${V}`)||N.name===V||N.id===V){M=N.id;break}if(M)break}if(!M)M=w.find((F)=>F.roleDefs.some((N)=>N.id.endsWith(":admin")))?.roleDefs.find((F)=>F.id.endsWith(":admin"))?.id;if(M){let F=await Mg(J,G,M).catch(()=>({staffs:[]})),N=await Og(J,G,F.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(`Multiplestaffmembersmatched'${$.staffName??$.staffPhone}':${O.map((D)=>`${D.name}(${D.id})`).join(", ")}.PleasespecifyexactstaffId.`);else throw Error(`Nostaffmemberfoundmatching'${$.staffName??$.staffPhone}'underrole${M}.Run'seal-use corps hose-staffs'toviewcandidates.`)}else if(!Q){let O=N.map((D)=>({id:D.id,name:D.name,cellphone:D.cellphone,active:D.active}));throw Error(`Missingrequiredparameter:staffId.Candidates:${JSON.stringify(O)}`)}else H=N.find(
Line truncated
`+"\uD83D\uDCA1 说明:此能力专属于合思 (Hose) 子域,用于将临时会话提权为标准 OpenAPI 开发者接入。需要企业管理员已在合思开放平台创建应用并生成 appKey/appSecurity。",Q);if(U.keyId||U.appKey){let I=$.find((J)=>U.keyId&&J.id===U.keyId||U.appKey&&J.appKey===U.appKey);if(!I)throw new oQ(`指定的合思密钥不存在,请从上述候选列表中选择正确的appKey或keyId。
`);C0({provider:"hose",capability:"privilege-elevation",corpId:I.corpId,corpName:I.corpName??I.corpId,baseUrl:I.baseUrl,staffId:I.staffId,keyCount:I.keys.length,keys:I.keys.map((J)=>OS0(J,Q))})}async function YE($,Y){let U=M1($),I=Y.reveal===!0;if(U.source.type!=="hose")throw new G4(`【合思子域专享能力】当前企业「${U.name}」(id:${U.id})为原生Seal(${U.source.type})租户,非合思(Hose/合思云/易快报)渠道企业。
`);C0({provider:"hose",capability:"privilege-elevation",corpId:Q.corpId,corpName:Q.corpName??Q.corpId,baseUrl:Q.baseUrl,staffId:Q.staffId,keyCount:Q.keys.length,keys:Q.keys.map((J)=>AS0(J,I))})}async function UE($,Y){let U=M1($),Q=Y.reveal===!0;if(U.source.type!=="hose")throw new G4(`【合思子域专享能力】当前企业「${U.name}」(id:${U.id})为原生Seal(${U.source.type})租户,非合思(Hose/合思云/易快报)渠道企业。
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let Z of X){let q=Z.outboundName??"SealAI 审批",V=Z.signKey,w=Z.apiOrigin??"production";console.error(`•"${q}"(signKey:${V},环境:${w})`),console.error(`\uD83D\uDC49查看命令:seal-usedeployhosecloudget${V}--corp${Q.id}
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let V of Z){let w=V.outboundName??"SealAI 审批",M=V.signKey,F=V.apiOrigin??"production";console.error(`•"${w}"(signKey:${M},环境:${F})`),console.error(`\uD83D\uDC49同步命令:seal-usedeployhosecloudsync${M}--corp${Q.id}
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let Z of X){let q=Z.outboundName??"SealAI 审批",V=Z.signKey,w=Z.apiOrigin??"production";console.error(`•"${q}"(signKey:${V},环境:${w})`),console.error(`\uD83D\uDC49查看命令:seal-usedeployhosecloudget${V}--corp${I.id}
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let V of Z){let w=V.outboundName??"SealAI 审批",M=V.signKey,F=V.apiOrigin??"production";console.error(`•"${w}"(signKey:${M},环境:${F})`),console.error(`\uD83D\uDC49同步命令:seal-usedeployhosecloudsync${M}--corp${I.id}
`);throw new G4("缺少必需参数 <sign-key>。请从上述候选列表中选择并指定 signKey 执行同步。",2,Z.length===1?`seal-usedeployhosecloudsync${Z[0].signKey}--corp${I.id}`:void 0)}await v0("seal_deploy_hosecloud_sync",Q,I,{signKey:H},T0(J.options));return}throw Error(`Unknowndeployhosecloudaction:${z??""}.Available:requirements,list,get,status,configure,sync.`)}var Mg0=o(()=>{D4();L4();$4();X4();p8()});var Ng0='---\nname: seal-use\ndescription: "v0.10.40: Use for Seal Use enterprise onboarding, Hose/合思 or Seal-native authentication, approval operations, diagnosis, simulation, rules, users, configuration, and search."\nmetadata:\n version: 0.10.40\n short-description: Seal tenant and Hose approval automation (v0.10.40)\n---\n\n# Seal Use\n\nCLI 是主执行通道。机器通道 `stdout` 必须是纯 JSON;诊断日志、进度和下一步建议写入 `stderr`。MCP 默认关闭。\n\n## 时间与输出\n\n- 机器字段统一使用带 `+08:00` 北京时间偏移的 ISO 8601 秒级格式,不带毫秒,例如 `2026-09-28T11:51:09+08:00`。\n- 面向用户解释时间时,直接基于 `Asia/Shanghai`(北京时间)表述,无需再做 `+8` 小时换算。\n- 不向用户暴露 Bearer、`accessToken`、`closeToken`、`appSecurity`、原始 cURL 或未脱敏手机号。\n- 不向用户直接暴露底层 UUID、`tenantSlug`、`boundCorpRole` 等内部字段;优先使用企业名称、规则编号(例如 `0038`)和脱敏后的业务信息。\n\n## 企业接入:先识别材料,再选择入口\n\n最终企业来源只有两种:`source.type:"seal"` 和 `source.type:"hose"`。不要把材料格式、认证凭据和最终来源混为一谈。\n\n| 用户材料 | 标准入口 | 最终配置形态 |\n| --- | --- | --- |\n| Hose 开放平台 `appKey+appSecurity` | `corpsadd-hose-persistent` | Hose 持久化凭据 |\n| Seal URL + Bearer,或 Seal 页面 cURL | `corpsadd-seal-bearer` | Seal Bearer 会话 |\n| Seal 原生委托链接 | `corpsadd-link<url>` | Seal 委托会话 |\n| Hose 协助链接 | `corpsadd-link<url>` | Hose Web Session;加 `--elevate-hose` 才提取长期密钥 |\n| Hose 页面 cURL | 先提取密钥;失败时 `corpsadd-hose-web-session` | Hose 持久化或 Hose Web Session |\n| 已规范化的 Hose `corpId+accessToken+baseUrl` | `corpsadd-hose-web-session` | Hose Web Session |\n\n### 凭据边界\n\n- Seal Bearer 只能给 `add-seal-bearer`;Hose `accessToken/accesstoken/closeToken` 不能直接当作 Seal Bearer。\n- Hose Web Session 保存 `closeToken+staffId`,需要调用 Seal 时才通过 SSO 换取运行时 Seal Bearer。\n- Hose 持久化配置保存 `appKey+appSecurity`,适合无人值守、部署和长期同步。\n- 会话有有效期时,Hose source 保存 `expiresIn` 和北京时间 ISO 秒级 `expiresAt`(`+08:00`)。\n- `add-link` 是 URL 混合入口,不接收 cURL:自动识别 Seal 委托链接和 Hose 协助链接。\n- `--elevate-hose` 是唯一明确的 Hose 提权动作。\n\n收到 Hose 管理员 cURL 时,按 Hose 协助链接处理:解析主机、`accesstoken`、企业标识和必要会话信息,优先调用密钥提取路径;无法提取长期密钥时才保存 Web Session。收到 Seal cURL 时,提取 Seal 主机和 `Authorization:Bearer`,走 `add-seal-bearer`。不要盲目执行 cURL,也不要把原文写入文件或日志。\n\n详细来源决策、提权边界和 cURL 处理见 `references/enterprise-onboarding.md`;首次找材料时必须使用 `references/first-time-user.md`。\n\n## 首次接入图文规则\n\n当用户首次接入、询问如何取得材料,或需要用户打开后台找凭据时:\n\n1. 先确认用户手上是 Hose 开放平台凭据、协助链接、Seal 委托链接,还是已登录网页 cURL。\n2. 读取 `references/first-time-user.md`,只渲染与当前路径对应的截图;不能只给纯文字步骤。\n3. 接收材料后由 Agent 自动发现企业、域名和管理员。除非自动发现失败,不要要求用户先填写 `corpId`、`staffId` 或域名。\n\n## `corps` 主线\n\n- 接入:`add-link`、`add-seal-bearer`、`add-hose-persistent`、`add-hose-web-session`\n- 发现:`list`、`search`/`find`、`get`/`show`、`current`、`switch`\n- 维护:`mark`、`rename`\n- 测试闭环:`bind-test`、`unbind-test`、`sync-test`、`replay-test`\n- Hose 专属:`probe-hose`、`hose-staffs`、`hose-extract-keys`、`hose-keys`\n\nHose 专属命令应从命令名或选项中明确可见:`authhose-*`、`approval-runshose-flow`、`deployhosecloud`、`simulation--modehosecloud`。跨来源入口只有在明确使用 `--elevate-hose`、`--with-flow` 或 `--typehose-document` 时才启用对应 Hose 能力。\n\n生产规则变更遵循:生产改草稿 → 同步测试 → 模拟/回归验证 → 用户确认 → 生产发布。`sync-test`、`replay-test`、规则发布和清空等高风险操作优先 `--dry-run`Line truncated
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 Ay0=()=>{};var Ty0="# 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-useapproval-runspick--corp<corpId>--sn<sourceDocumentSN>--latest\nseal-useapproval-runspick--corp<corpId>--sn<sourceDocumentSN>--batch<batchId>--latest\nseal-useapproval-runspick--corp<corpId>--sn<sourceDocumentSN>--latest--fieldsrecordId,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-useapproval-runsget<recordId>--corp<corpId>--summary\n```\n\nUse `--fields` when the user needs a particular slice.\n\n```bash\nseal-useapproval-runsget<recordId>--corp<corpId>--fieldsmetadata\nseal-useapproval-runsget<recordId>--corp<corpId>--fieldsdocument.fields,result.summary\nseal-useapproval-runsget<recordId>--corp<corpId>--fieldsresult.summary,result.decision,result.riskPoints\nseal-useapproval-runsget<recordId>--corp<corpId>--fieldsdocument.keyFields,result,manualApprovalRecord,ruleSetVersionNumber\n```\n\nAvoid full `approval-runsget<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-useapproval-runsdocument-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-useapproval-runscited-rules<recordId>--corp<corpId>\n```\n\nReturn and discuss `code`, `runtimeRuleId`, `ruleCode`, `versionNumber`, `scope`, `strictness`, `appliedAnalysis`, `checkResult`, and `findings` when present.\n\nIf the user then wants the full text of one cited rule from that run's snapshot, use `seal-userulesget<code>--record-id<recordId>--corp<corpId>` from `rule-lightweight.md`.\n\n## Attachments Without Raw Payloads\n\nUse:\n\n```bash\n#查看附件列表摘要(包含文件名、类型、大小及直链可用性)\nseal-useapproval-runsattachments<recordId>--corp<corpId>--summary\n\n#下载全部附件到本地目录(优先使用ossSignedUrl签名直链)\nseal-useapproval-runsattachmentsdownload<recordId>--all--out-dir./downloads--corp<corpId>\n\n#按名称或fileId过滤下载单个附件\nseal-useapproval-runsattachmentsdownload<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-useapproval-runsresult<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#默认推荐:生成SealAI审核详情直达链接(无凭证、无越权风险,用户在已有登录状态的浏览器中直接打开)\nseal-useapproval-runslink<recordId>--corp<corpId>\nseal-useapproval-runslink--sn<sourceDocumentSN>--corp<corpId>\n\n#生成合思主系统原始单据页面链接\nseal-useapproval-runslink<recordId>--typehose-document--corp<corpId>\n\n#仅当用户明确要求免密/跨浏览器/无登录直达且确认知晓安全风险时:生成携带合思单次临时票据的免登直达链接\nseal-useapproval-runslink<recordId>--auto-login[--expire7200]--corp<corpId>\n```\n\n### 返回字段说明与语义规范\n- `sealResultUrl`: Seal AI 单据智能审核结果页\n- `hoseDocumentUrl`: 合思费控主系统原始报销/借款单详情页\n- `type`: 链接类型,默认为 `seal_result`,指定时可为 `hose_document`\n- `mode`: 鉴权模式,`direct`(原生直接打开)或 `auto_login`(免密换票)\n\n### 免登链接安全与声明规范\nLine truncated
`;var Tg0=()=>{};var Cg0="# 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-useapproval-runspick--corp<corpId>--sn<sourceDocumentSN>--latest\nseal-useapproval-runspick--corp<corpId>--sn<sourceDocumentSN>--batch<batchId>--latest\nseal-useapproval-runspick--corp<corpId>--sn<sourceDocumentSN>--latest--fieldsrecordId,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-useapproval-runsget<recordId>--corp<corpId>--summary\n```\n\nUse `--fields` when the user needs a particular slice.\n\n```bash\nseal-useapproval-runsget<recordId>--corp<corpId>--fieldsmetadata\nseal-useapproval-runsget<recordId>--corp<corpId>--fieldsdocument.fields,result.summary\nseal-useapproval-runsget<recordId>--corp<corpId>--fieldsresult.summary,result.decision,result.riskPoints\nseal-useapproval-runsget<recordId>--corp<corpId>--fieldsdocument.keyFields,result,manualApprovalRecord,ruleSetVersionNumber\n```\n\nAvoid full `approval-runsget<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-useapproval-runsdocument-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-useapproval-runscited-rules<recordId>--corp<corpId>\n```\n\nReturn and discuss `code`, `runtimeRuleId`, `ruleCode`, `versionNumber`, `scope`, `strictness`, `appliedAnalysis`, `checkResult`, and `findings` when present.\n\nIf the user then wants the full text of one cited rule from that run's snapshot, use `seal-userulesget<code>--record-id<recordId>--corp<corpId>` from `rule-lightweight.md`.\n\n## Attachments Without Raw Payloads\n\nUse:\n\n```bash\n#查看附件列表摘要(包含文件名、类型、大小及直链可用性)\nseal-useapproval-runsattachments<recordId>--corp<corpId>--summary\n\n#下载全部附件到本地目录(优先使用ossSignedUrl签名直链)\nseal-useapproval-runsattachmentsdownload<recordId>--all--out-dir./downloads--corp<corpId>\n\n#按名称或fileId过滤下载单个附件\nseal-useapproval-runsattachmentsdownload<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-useapproval-runsresult<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#默认推荐:生成SealAI审核详情直达链接(无凭证、无越权风险,用户在已有登录状态的浏览器中直接打开)\nseal-useapproval-runslink<recordId>--corp<corpId>\nseal-useapproval-runslink--sn<sourceDocumentSN>--corp<corpId>\n\n#生成合思主系统原始单据页面链接\nseal-useapproval-runslink<recordId>--typehose-document--corp<corpId>\n\n#仅当用户明确要求免密/跨浏览器/无登录直达且确认知晓安全风险时:生成携带合思单次临时票据的免登直达链接\nseal-useapproval-runslink<recordId>--auto-login[--expire7200]--corp<corpId>\n```\n\n### 返回字段说明与语义规范\n- `sealResultUrl`: Seal AI 单据智能审核结果页\n- `hoseDocumentUrl`: 合思费控主系统原始报销/借款单详情页\n- `type`: 链接类型,默认为 `seal_result`,指定时可为 `hose_document`\n- `mode`: 鉴权模式,`direct`(原生直接打开)或 `auto_login`(免密换票)\n\n### 免登链接安全与声明规范\nLine truncated
3.BOTHacodeblock(\`\`\`\`text ... \`\`\`\`) for easy copying without accidental default browser redirection, AND a clickable hyperlink.
-**DedicatedCLICommand**: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).
-**SealAIPlatformDirectLink**: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\`).
@@ -2015,7 +2015,7 @@ seal-use corps hose-staffs --json '{
}'
\`\`\`
*直接使用指定ID完成接入并进行连通性验证。
`;var fy0=()=>{};var iy0="# Rule Lightweight Queries\n\nUse this reference when the user wants rule counts, compact rule lists, one rule from draft or a historical version, or approval rule search without dumping hundreds of rule descriptions.\n\n## Draft Default vs. Published Version (`--versionlatest`)\n\nEvery rule has a 4-digit zero-padded `code` (`0000,0001,0025,0038,...`).\n\n- **Default = Current Draft (`草稿`)**: When `--version` is omitted, `rulescount`, `ruleslist`, `rulesget<code>`, `rulessearch`, `ruleslint`, and `rulespull` **all read the current draft**.\n- **Latest Published Version = `--versionlatest` (`最新发布`)**: To inspect the latest published version, **always pass `--versionlatest`** (or `--version<number>` for a specific historical version).\n- Publishing or deleting rules can shift `code` numbers across versions, so a `code` in a historical run must be resolved together with `--version<number>` or `--record-id<recordId>`.\n\n## Count Rules\n\nUse count when only scale or existence matters.\n\n```bash\n#Countcurrentdraftrules(default)\nseal-userulescount--corp<corpId>\n\n#Countrulesinlatestpublishedversion\nseal-userulescount--versionlatest--corp<corpId>\n```\n\nExpected shape:\n\n```json\n{\"count\": 191 }\n```\n\n## List Rule Summaries\n\nUse summaries for navigation and selection.\n\n```bash\n# List current draft rule summaries (default)\nseal-use rules list --summary --corp <corpId>\n\n# List latest published version rule summaries\nseal-use rules list --version latest --summary --corp <corpId>\n```\n\nDefault summary includes `code`, `status`, `strictness`, `scope`, and `updatedAt`. Do not pull full `description` fields across all rules unless the user needs rule text.\n\n## Get One Rule (Draft or Published Version)\n\nRead a single rule from the current draft (default):\n\n```bash\nseal-use rules get 0038 --corp <corpId>\n```\n\nRead a single rule from the latest published version, a specific published version, or the version used by an approval run:\n\n```bash\nseal-use rules get 0038 --version latest --corp <corpId>\nseal-use rules get 0038 --version 16 --corp <corpId>\nseal-use rules get 0205 --record-id <recordId> --corp <corpId>\n```\n\nReturns `id`, `code`, `ruleCode`, `runtimeRuleId`, `description`, `scope`, `strictness`, `status`, and version metadata when reading from a published version.\n\n## Search Rules Compactly\n\n```bash\n# Search current draft rules (default)\nseal-use rules search <keyword> --maxResults 20 --corp <corpId>\n\n# Search latest published version or a specific historical version\nseal-use rules search <keyword> --version latest --maxResults 20 --corp <corpId>\nseal-use rules search <keyword> --version 16 --maxResults 20 --corp <corpId>\n```\n\n## Clear Draft Rules Before Import\n\nUse this for test tenants when the next step is importing another tenant's rule set. Always preview first unless the user has already confirmed the exact tenant.\n\n```bash\nseal-use rules clear --dry-run --corp <corpId>\nseal-use rules clear --yes --corp <corpId>\n```\n\nExpected shape:\n\n```json\n{\n \"corpId\": \"xiezihao\",\n \"dryRun\": false,\n \"beforeCount\": 49,\n \"deleted\": 49,\n \"afterCount\": 0\n}\n```\n\n## Output Discipline\n\nIf a rule command would return many descriptions or more than about 20 rules, use `rules count`, `rules list --summary`, `rules search`, or `--output-file`. Use `--full` only for deliberate exports.\n";varby0=()=>{};varny0="#SealApprovalRuleLinter&QualityValidation\n\nUsethisreferencewhenanalyzing,validating,orlintingSealAIapprovalrulestodetectvaguephrasing,missingexceptionevidence,orformattingdefectsbeforepublishing.\n\n##KeyPrinciples\n\n-**DefaultState**:Linteris**disabledbydefault**inglobalconfiguration(`lint.enabled: false`)toavoidunsolicitednoiseduringstandardoperations.\n-**DoctorVisibility**:`seal-use doctor`auditstherulelinterconfigurationstateandactivelinternameinitshealthchecks,andsurfacesaone-clickhint(`seal-use config lint enable`)whendisabled.\n-**ExplicitTriggering**:`seal-use rules lint`alwaysrunsregardlessofglobalconfiguration.\n-**DraftHook**:When`seal-use config lint enable`isset,`seal-use rules update`outputsreal-timediagnosticwarningsto`stderr`withoutmutating`stdout`payloads.\n-**Fault-TolerantFallback**:Ifacustom`.ts`linterfilehassyntaxerrors,runtimeexceptions,orismissing,theenginelogsawarningto`stderr`and**silentlyfallsbacktothebuilt-inheuristiclinterwithoutfailing**.\n\n##CLICommands\n\n###1.LintCurrentDraftRules(Whole-RuleSetScan)\n\n```bash\nseal-use rules lint --corp <corpId>\n```\n\n###2.LintSpecificHistoricalVersionorSingleRule\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\nseal-use rules lint --code 0038 --corp <cor
Line truncated
`;var ig0=()=>{};var dg0="# Rule Lightweight Queries\n\nUse this reference when the user wants rule counts, compact rule lists, one rule from draft or a historical version, or approval rule search without dumping hundreds of rule descriptions.\n\n## Draft Default vs. Published Version (`--versionlatest`)\n\nEvery rule has a 4-digit zero-padded `code` (`0000,0001,0025,0038,...`).\n\n- **Default = Current Draft (`草稿`)**: When `--version` is omitted, `rulescount`, `ruleslist`, `rulesget<code>`, `rulessearch`, `ruleslint`, and `rulespull` **all read the current draft**.\n- **Latest Published Version = `--versionlatest` (`最新发布`)**: To inspect the latest published version, **always pass `--versionlatest`** (or `--version<number>` for a specific historical version).\n- Publishing or deleting rules can shift `code` numbers across versions, so a `code` in a historical run must be resolved together with `--version<number>` or `--record-id<recordId>`.\n\n## Count Rules\n\nUse count when only scale or existence matters.\n\n```bash\n#Countcurrentdraftrules(default)\nseal-userulescount--corp<corpId>\n\n#Countrulesinlatestpublishedversion\nseal-userulescount--versionlatest--corp<corpId>\n```\n\nExpected shape:\n\n```json\n{\"count\": 191 }\n```\n\n## List Rule Summaries\n\nUse summaries for navigation and selection.\n\n```bash\n# List current draft rule summaries (default)\nseal-use rules list --summary --corp <corpId>\n\n# List latest published version rule summaries\nseal-use rules list --version latest --summary --corp <corpId>\n```\n\nDefault summary includes `code`, `status`, `strictness`, `scope`, and `updatedAt`. Do not pull full `description` fields across all rules unless the user needs rule text.\n\n## Get One Rule (Draft or Published Version)\n\nRead a single rule from the current draft (default):\n\n```bash\nseal-use rules get 0038 --corp <corpId>\n```\n\nRead a single rule from the latest published version, a specific published version, or the version used by an approval run:\n\n```bash\nseal-use rules get 0038 --version latest --corp <corpId>\nseal-use rules get 0038 --version 16 --corp <corpId>\nseal-use rules get 0205 --record-id <recordId> --corp <corpId>\n```\n\nReturns `id`, `code`, `ruleCode`, `runtimeRuleId`, `description`, `scope`, `strictness`, `status`, and version metadata when reading from a published version.\n\n## Search Rules Compactly\n\n```bash\n# Search current draft rules (default)\nseal-use rules search <keyword> --maxResults 20 --corp <corpId>\n\n# Search latest published version or a specific historical version\nseal-use rules search <keyword> --version latest --maxResults 20 --corp <corpId>\nseal-use rules search <keyword> --version 16 --maxResults 20 --corp <corpId>\n```\n\n## Clear Draft Rules Before Import\n\nUse this for test tenants when the next step is importing another tenant's rule set. Always preview first unless the user has already confirmed the exact tenant.\n\n```bash\nseal-use rules clear --dry-run --corp <corpId>\nseal-use rules clear --yes --corp <corpId>\n```\n\nExpected shape:\n\n```json\n{\n \"corpId\": \"xiezihao\",\n \"dryRun\": false,\n \"beforeCount\": 49,\n \"deleted\": 49,\n \"afterCount\": 0\n}\n```\n\n## Output Discipline\n\nIf a rule command would return many descriptions or more than about 20 rules, use `rules count`, `rules list --summary`, `rules search`, or `--output-file`. Use `--full` only for deliberate exports.\n";varng0=()=>{};varmg0="#SealApprovalRuleLinter&QualityValidation\n\nUsethisreferencewhenanalyzing,validating,orlintingSealAIapprovalrulestodetectvaguephrasing,missingexceptionevidence,orformattingdefectsbeforepublishing.\n\n##KeyPrinciples\n\n-**DefaultState**:Linteris**disabledbydefault**inglobalconfiguration(`lint.enabled: false`)toavoidunsolicitednoiseduringstandardoperations.\n-**DoctorVisibility**:`seal-use doctor`auditstherulelinterconfigurationstateandactivelinternameinitshealthchecks,andsurfacesaone-clickhint(`seal-use config lint enable`)whendisabled.\n-**ExplicitTriggering**:`seal-use rules lint`alwaysrunsregardlessofglobalconfiguration.\n-**DraftHook**:When`seal-use config lint enable`isset,`seal-use rules update`outputsreal-timediagnosticwarningsto`stderr`withoutmutating`stdout`payloads.\n-**Fault-TolerantFallback**:Ifacustom`.ts`linterfilehassyntaxerrors,runtimeexceptions,orismissing,theenginelogsawarningto`stderr`and**silentlyfallsbacktothebuilt-inheuristiclinterwithoutfailing**.\n\n##CLICommands\n\n###1.LintCurrentDraftRules(Whole-RuleSetScan)\n\n```bash\nseal-use rules lint --corp <corpId>\n```\n\n###2.LintSpecificHistoricalVersionorSingleRule\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\nseal-use rules lint --code 0038 --corp <cor
Line truncated
A**Webhookresourcepack**(webhook资源包/资源包,CLI:\`resource-pack\`, alias: \`pack\`, legacy alias: \`material-pack\`) is a ZIP file that bundles an Excel information sheet (\`信息表.xlsx\`) with attachments organised by document ID. It is designed for exporting online approval runs and transferring them offline across environments or teams to be replayed via inbound Webhooks.
@@ -2381,10 +2382,10 @@ The direct local \`resource-pack preview\` command uses the default or temporary
|\`附件后缀不在白名单中\` | Attachment extension is not allowed by the Webhook policy | Add the extension with \`--allowed-extensions\` or convert the file |
|\`附件上传失败 <status>\` | Network/server error during file upload | Check webhook URL, secret, and server availability |
`;var my0=()=>{};var Vx1="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:I,configured:!0,configPath:U,targetDir:Y,action:"prepended"}}function to($){let Y=$?.targetSkillsDir??ay0(),U=$?.configFile??ty0(),I=ey0(),Q=!1;if(sq(U))try{let J=JSON.parse(sy0(U,"utf8"));if(Array.isArray(J?.entries))Q=J.entries.some((K)=>K?.path===Y)}catch{}return{detected:I,configured:Q,configPath:U,targetDir:Y}}var eo=()=>{};import{cpSync as Ax1,existsSync as $G,lstatSync as Yg0,mkdirSync as Bx1,realpathSync as GY,rmSync as Px1,symlinkSync as Tx1,unlinkSync as $g0}from"node:fs";import{homedir as Ug0}from"node:os";import{dirname as Ig0,join as HY}from"node:path";function Ex1($,Y){let U=Y?.baseHomeDir??Ug0(),I=HY(U,$.rootDirName),Q=Y?.sourceSkillDir??HY(U,".agents","skills","seal-use"),J=Ig0(Q),K=HY(I,"skills"),z=HY(K,"seal-use");if(!$G(I))return{id:$.id,name:$.name,detected:!1,configured:!1,mode:"skipped_not_detected"};if($G(K)&&$G(J))try{if(GY(K)===GY(J))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"parent_symlinked",targetPath:K}}catch{}Bx1(K,{recursive:!0});let G;try{G=Yg0(z)}catch{G=void 0}let H=!1;if(G)if(G.isSymbolicLink()){try{if(GY(z)===GY(Q))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"already_linked",targetPath:z}}catch{}try{$g0(z)}catch{}}else if(G.isDirectory())Px1(z,{recursive:!0,force:!0}),H=!0;else $g0(z);let W=process.platform==="win32"?"junction":"dir";try{return Tx1(Q,z,W),{id:$.id,name:$.name,detected:!0,configured:!0,mode:H?"replaced_real_dir":"linked",targetPath:z}}catch{try{return Ax1(Q,z,{recursive:!0}),{id:$.id,name:$.name,detected:!0,configured:!0,mode:"fallback_copied",targetPath:z}}catch(X){return{id:$.id,name:$.name,detected:!0,configured:!1,mode:"error",targetPath:z,error:X?.message||String(X)}}}}function jx1($,Y){let U=Y?.baseHomeDir??Ug0(),I=HY(U,$.rootDirName),Q=Y?.sourceSkillDir??HY(U,".agents","skills","seal-use"),J=Ig0(Q),K=HY(I,"skills"),z=HY(K,"seal-use");if(!$G(I))return{id:$.id,name:$.name,detected:!1,configured:!1,mode:"not_detected"};if($G(K)&&$G(J))try{if(GY(K)===GY(J))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"parent_symlinked",targetPath:K}}catch{}let G;try{G=Yg0(z)}catch{G=void 0}if(G){if(G.isSymbolicLink())try{if(GY(z)===GY(Q))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"single_symlinked",targetPath:z}}catch{}else if(G.isDirectory())return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"real_directory",targetPath:z}}return{id:$.id,name:$.name,detected:!0,configured:!1,mode:"not_configured",targetPath:z}}function $r($){return Qg0.map((Y)=>Ex1(Y,$))}function Yr($){return Qg0.map((Y)=>jx1(Y,$))}var Qg0;var Ur=o(()=>{Qg0=[{id:"workbuddy",name:"WorkBuddy",rootDirName:".workbuddy"},{id:"claude",name:"Claude",rootDirName:".claude"},{id:"qoder",name:"Qoder",rootDirName:".qoder"}]});var Ir=o(()=>{eo();Ur();eo();Ur()});import{existsSync as Cx1,mkdirSync as Qr,readFileSync as Rx1,rmSync as _x1,writeFileSync as Jg0}from"node:fs";import{homedir as zg0}from"node:os";import{dirname as Kg0,join as tq}from"node:path";function Jr(){return Gg0["SKILL.md"]||""}function Hg0($){return $.match(/^\s*version:\s*(\S+)\s*$/m)?.[1]}function Wg0($=tq(rI(),"SKILL.md")){try{return Hg0(Rx1($,"utf8"))}catch{return}}function rI(){return tq(zg0(),".agents","skills","seal-use")}function Sx1(){return tq(zg0(),".agents","skills","seal-home")}function hx1(){let $=Sx1();if(Cx1($))try{return _x1($,{recursive:!0,force:!0}),!0}catch{return!1}return!1}function Xg0($=rI()){hx1(),Qr($,{recursive:!0});let Y=[];for(let[U,I]of Object.entries(Gg0)){let Q=tq($,U);Qr(Kg0(Q),{recursive:!0}),Jg0(Q,I,"utf8"),Y.push(U)}for(let[U,I]of Object.entries(vx1)){let Q=tq($,U);Qr(Kg0(Q),{recursive:!0}),Jg0(Q,I),Y.push(U)}return{targetDir:$,files:Y}}var Gg0,vx1,Xq4;var eq=o(()=>{oo();oo();Ir();Gg0=oy0,vx1=Object.fromEntries(Object.entries(ry0).map(([$,Y])=>[$,Buffer.from(Y,"base64")]));Xq4=Hg0(Jr())});function Zg0(){return`#SealUse系统架构与运行规范白皮书
`;var rg0=()=>{};var Dx1="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:Q,configured:!0,configPath:U,targetDir:Y,action:"prepended"}}function Yr($){let Y=$?.targetSkillsDir??$y0(),U=$?.configFile??Yy0(),Q=Uy0(),I=!1;if(sq(U))try{let J=JSON.parse(eg0(U,"utf8"));if(Array.isArray(J?.entries))I=J.entries.some((K)=>K?.path===Y)}catch{}return{detected:Q,configured:I,configPath:U,targetDir:Y}}var Ur=()=>{};import{cpSync as Rx1,existsSync as $G,lstatSync as Iy0,mkdirSync as _x1,realpathSync as GY,rmSync as vx1,symlinkSync as Sx1,unlinkSync as Qy0}from"node:fs";import{homedir as Jy0}from"node:os";import{dirname as Ky0,join as HY}from"node:path";function hx1($,Y){let U=Y?.baseHomeDir??Jy0(),Q=HY(U,$.rootDirName),I=Y?.sourceSkillDir??HY(U,".agents","skills","seal-use"),J=Ky0(I),K=HY(Q,"skills"),z=HY(K,"seal-use");if(!$G(Q))return{id:$.id,name:$.name,detected:!1,configured:!1,mode:"skipped_not_detected"};if($G(K)&&$G(J))try{if(GY(K)===GY(J))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"parent_symlinked",targetPath:K}}catch{}_x1(K,{recursive:!0});let G;try{G=Iy0(z)}catch{G=void 0}let H=!1;if(G)if(G.isSymbolicLink()){try{if(GY(z)===GY(I))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"already_linked",targetPath:z}}catch{}try{Qy0(z)}catch{}}else if(G.isDirectory())vx1(z,{recursive:!0,force:!0}),H=!0;else Qy0(z);let W=process.platform==="win32"?"junction":"dir";try{return Sx1(I,z,W),{id:$.id,name:$.name,detected:!0,configured:!0,mode:H?"replaced_real_dir":"linked",targetPath:z}}catch{try{return Rx1(I,z,{recursive:!0}),{id:$.id,name:$.name,detected:!0,configured:!0,mode:"fallback_copied",targetPath:z}}catch(X){return{id:$.id,name:$.name,detected:!0,configured:!1,mode:"error",targetPath:z,error:X?.message||String(X)}}}}function gx1($,Y){let U=Y?.baseHomeDir??Jy0(),Q=HY(U,$.rootDirName),I=Y?.sourceSkillDir??HY(U,".agents","skills","seal-use"),J=Ky0(I),K=HY(Q,"skills"),z=HY(K,"seal-use");if(!$G(Q))return{id:$.id,name:$.name,detected:!1,configured:!1,mode:"not_detected"};if($G(K)&&$G(J))try{if(GY(K)===GY(J))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"parent_symlinked",targetPath:K}}catch{}let G;try{G=Iy0(z)}catch{G=void 0}if(G){if(G.isSymbolicLink())try{if(GY(z)===GY(I))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"single_symlinked",targetPath:z}}catch{}else if(G.isDirectory())return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"real_directory",targetPath:z}}return{id:$.id,name:$.name,detected:!0,configured:!1,mode:"not_configured",targetPath:z}}function Qr($){return zy0.map((Y)=>hx1(Y,$))}function Ir($){return zy0.map((Y)=>gx1(Y,$))}var zy0;var Jr=o(()=>{zy0=[{id:"workbuddy",name:"WorkBuddy",rootDirName:".workbuddy"},{id:"claude",name:"Claude",rootDirName:".claude"},{id:"qoder",name:"Qoder",rootDirName:".qoder"}]});var Kr=o(()=>{Ur();Jr();Ur();Jr()});import{existsSync as yx1,mkdirSync as zr,readFileSync as kx1,rmSync as xx1,writeFileSync as Gy0}from"node:fs";import{homedir as Wy0}from"node:os";import{dirname as Hy0,join as aq}from"node:path";function Gr(){return Xy0["SKILL.md"]||""}function Zy0($){return $.match(/^\s*version:\s*(\S+)\s*$/m)?.[1]}function qy0($=aq(rQ(),"SKILL.md")){try{return Zy0(kx1($,"utf8"))}catch{return}}function rQ(){return aq(Wy0(),".agents","skills","seal-use")}function ux1(){return aq(Wy0(),".agents","skills","seal-home")}function bx1(){let $=ux1();if(yx1($))try{return xx1($,{recursive:!0,force:!0}),!0}catch{return!1}return!1}function Vy0($=rQ()){bx1(),zr($,{recursive:!0});let Y=[];for(let[U,Q]of Object.entries(Xy0)){let I=aq($,U);zr(Hy0(I),{recursive:!0}),Gy0(I,Q,"utf8"),Y.push(U)}for(let[U,Q]of Object.entries(fx1)){let I=aq($,U);zr(Hy0(I),{recursive:!0}),Gy0(I,Q),Y.push(U)}return{targetDir:$,files:Y}}var Xy0,fx1,Mq4;var eq=o(()=>{to();to();Kr();Xy0=tg0,fx1=Object.fromEntries(Object.entries(ag0).map(([$,Y])=>[$,Buffer.from(Y,"base64")]));Mq4=Zy0(Gr())});function Ly0(){return`#SealUse系统架构与运行规范白皮书
toloopback(\`--host 127.0.0.1\`) and do not expose the port to a network or an origin you
donotcontrol.
`}},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
`}},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
`);Q(I)})})}var ME=8787,OE="127.0.0.1";var qr=o(()=>{yg0();W3()});async function gg0($){let Y=l0($.options.port)??l0($.options.p),U=R($.options.host)??R($.options.h),I=await NE({port:Y,host:U}),Q=()=>{I.close(()=>{process.exit(0)})};process.on("SIGINT",Q),process.on("SIGTERM",Q),await new Promise(()=>{})}var kg0=o(()=>{L4();qr()});async function xg0($,Y,U,I){if($==="config"||$==="get"){await v0("seal_llm_config_get",Y,U,{},T0(I.options));return}if($==="providers"||$==="list"){await v0("seal_llm_providers_list",Y,U,{},T0(I.options));return}throw Error(`Unknownllmcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}var fg0=o(()=>{D4();$4()});async function ug0($,Y){if($==="config"||$==="json"){Vr();return}let{startServer:U}=await cg0().then(() => ig0);U()}function Vr(){C0({mcpServers:{"seal-use":{type:"stdio",command:"seal-use",args:["mcp"],env:{SEAL_USE_MCP_ENABLED:"true"}}}})}var bg0=o(()=>{$4()});function ng0($){let Y=LE();C0(Y,{...T0($.options),allowFull:!0})}var dg0=o(()=>{Xr();$4()});async function pg0($,Y,U,I){if($==="available"){await v0("seal_permissions_available_list",Y,U,{},T0(I.options));return}if($==="configs"||$==="list"){await v0("seal_permissions_configs_list",Y,U,{},T0(I.options));return}throw Error(`Unknownpermissionscommand:${$??""}.Run'seal-use help'foravailablecommands.`)}var mg0=o(()=>{D4();$4()});import{readFileSync as lg0}from"node:fs";async function og0($,Y,U,I,Q,J,K){if(!$||$==="get"){await v0("seal_preference_get",Q,J,{},T0(K.options));return}if($==="decision"){if(Y==="update"||!Y){let z=R(K.options.input),G=z?JSON.parse(lg0(z,"utf8")):F6(K.json);if(!G||Object.keys(G).length===0)throw Error(`Usage:seal-usepreferencedecisionupdate--json'{"explicitApprove":"..."}'`);await v0("seal_preference_decision_update",Q,J,{...G,dryRun:z0(K.options.dryRun)??z0(K.options["dry-run"])},T0(K.options));return}}if($==="thinking-depth"||$==="thinkingDepth"){if(Y==="set"){let z=R(K.options.default)??R(K.options.level)??I;if(z!=="medium"&&z!=="high")throw Error("Usage: seal-use preference thinking-depth set --default <medium|high>");await v0("seal_preference_thinking_depth_set",Q,J,{defaultLevel:z,dryRun:z0(K.options.dryRun)??z0(K.options["dry-run"])},T0(K.options));return}if(Y==="policies"){if(U==="list"||!U){await v0("seal_preference_thinking_depth_policies_list",Q,J,{},T0(K.options));return}if(U==="upsert"){let z=R(K.options.input),G=z?JSON.parse(lg0(z,"utf8")):F6(K.json);if(!G||!G.id||!G.name)throw Error(`Usage:seal-usepreferencethinking-depthpoliciesupsert--json'{"id":"...","name":"...","level":"high"}'`);await v0("seal_preference_thinking_depth_policies_upsert",Q,J,{...G,dryRun:z0(K.options.dryRun)??z0(K.options["dry-run"])},T0(K.options));return}if(U==="remove"||U==="delete"){let z=I??R(K.options.id)??R(K.options.policyId);if(!z)throw Error("Usage: seal-use preference thinking-depth policies remove <policyId>");await v0("seal_preference_thinking_depth_policies_remove",Q,J,{policyId:z,dryRun:z0(K.options.dryRun)??z0(K.options["dry-run"])},T0(K.options));return}}}throw Error(`Unknownpreferenceaction:${$??""}.Available:get,decisionupdate,thinking-depthset,thinking-depthpolicieslist/upsert/remove.`)}var rg0=o(()=>{D4();L4();$4()});async function sg0($={}){let Y=K$(),U=T4(),I=r2(Y,{stateful:U.stateful,defaultCorpId:U.defaultCorpId,corpId:$.corpId},m3());console.log(`[probe]corp=${I.id}source=${I.source.type}`);let Q=await az(I);console.log("[probe] seal enterprise"),console.log(JSON.stringify(Q,null,2));let J=await P1(I),K=await pM(J,{documentLimit:20,stylePreferencesEndpoint:I.seal.endpoints.approvalStylePreferences});console.log("[probe] approval context summary"),console.log(JSON.stringify({rules:K.rules.rules.length,hasPendingRuleDeletes:K.rules.hasPendingDeletes,documents:K.documents.articles.length,documentsTotal:K.documents.total,stylePreferences:K.stylePreferences.ok?"ok":`error:${K.stylePreferences.error}`},null,2))}var ag0=o(()=>{t$();i6();aT();X4()});async function tg0($,Y,U){let I=Y??R(U.options.corp)??($&&$!=="--corp"?$:void 0);await sg0({corpId:I})}var eg0=o(()=>{ag0();L4()});import{readFileSync as px1}from"node:fs";function $k0($,Y){let U=R($.options.descriptionFile)??R($.options["description-file"]);if(U)return px1(U,"utf8").trim();let I=R($.options.description)??R($.options.desc);if(I!==void 0)return I;return typeof Y.description==="string"?Y.description:void 0}function WY($,Y){let U=R($.options.version);if(U!==void 0)return U;if(z0($.options.latest))return"latest";if(Y!==void 0&&!Y.startsWith("-"))return Y;return}async function Lr($,Y,U,I,Q){if(!U&&!($==="lint"||$==="linters"||$==="linter-list"||$==="map"))throw Error(`rules${$??""}requiresanauthenticatedenterprise.Run'seal-use corps list'toselectone.`);if($==="count"){let K=WY(Q);await v0("seal_approval_rules_list",U,I,{version:K,countOnly:!0},T0(Q.options));return}if($==="list"){let K=WY(Q);if(z0(Q.options.count)){await v0("seal_approval_rules_list",U,I,{version:K,countOn
Line truncated
`).filter(Boolean),J=Q.slice(-Y);return{logFile:U,lines:J,totalLines:Q.length}}async function sx1($){let Y=PE($),U=Mr($),I=UV($);Jk0($.stateDir);let Q=$.port??(process.env.PORT?Number.parseInt(process.env.PORT,10):ME),J=$.host??(process.env.HOST?process.env.HOST:OE);AE(Y,`${process.pid}
`,{mode:384}),AE(U,JSON.stringify({pid:process.pid,port:Q,host:J,version:$.version,startedAt:A1()},null,2),{mode:384}),YG(I,`servicestartingonhttp://${J}:${Q} pid=${process.pid}`);let K=null;try{K=await NE({port:Q,host:J,silent:!0}),YG(I,`service listening pid=${process.pid}`)}catch(G){if(YG(I,`service failed to bind port ${Q}: ${G instanceof Error?G.message:String(G)}`),BE(Y)===process.pid)d9(Y,{force:!0}),d9(U,{force:!0});throw G}let z=()=>{if(K)K.close(),K=null;if(BE(Y)===process.pid)d9(Y,{force:!0}),d9(U,{force:!0});YG(I,`stopped pid=${process.pid}`)};await new Promise((G)=>{let H=!1,W=()=>{if(H)return;H=!0,z(),process.off("SIGTERM",W),process.off("SIGINT",W),G()};process.once("SIGTERM",W),process.once("SIGINT",W)})}function Uk0($){Jk0($.stateDir);let Y=sI($);if(Y.running)return Y;let U=$.launcher??{command:process.execPath,args:[$.entryFile]},I=[...U.args??[],"service","run"];if($.port)I.push("--port",String($.port));if($.host)I.push("--host",String($.host));let Q=mx1(U.command,I,{cwd:$.appRoot,detached:!0,stdio:["ignore","ignore","ignore"],env:process.env});Q.unref();let J=PE($);return AE(J,`${Q.pid}
`,{flag:"a",mode:384})}var Or=o(()=>{qr()});import{homedir as tx1}from"node:os";import{join as ex1}from"node:path";async function Dr($,Y,U){let I=U?l0(U.options.port)??l0(U.options.p):void 0,Q=U?R(U.options.host)??R(U.options.h):void 0,J=U?l0(U.options.lines)??l0(U.options.n):void 0,K=await J7($,{appRoot:Y.appRoot,entryFile:Y.entryFile,stateDir:Nr,version:Z1,launcher:Y.launcher,port:I,host:Q},{maxLines:J});if(K!==void 0)C0(K)}var Nr;var Ar=o(()=>{W3();Or();$4();L4();Nr=ex1(tx1(),".config","seal-use")});import{existsSync as $f1,readFileSync as Kk0}from"node:fs";async function zk0($,Y,U,I,Q){if($==="batch-records"||$==="records"){let J=Y??R(Q.options.batchId)??R(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation batch-records <batchId>");await v0("seal_simulation_batch_records_get",U,I,{batchId:J,query:R(Q.options.query)},T0(Q.options));return}if($==="create"||$==="run"){let J=R(Q.options.mode)??R(Q.options.sourceSystem)??R(Q.options["source-system"])??"hosecloud",K=J==="material-pack"?"material_pack":J,z=R(Q.options.schemaConfig)??R(Q.options["schema-config"]),G=z?JSON.parse(Kk0(z,"utf8")):void 0,H=R(Q.options.input),W=H?JSON.parse(Kk0(H,"utf8")):F6(Q.json),X=R(Q.options.packageId)??R(Q.options["package-id"]),Z=x4(Q.options.packageIds)??x4(Q.options["package-ids"])??(X?[X]:void 0),q=x4(Q.options.flowIds)??x4(Q.options["flow-ids"])??x4(Q.options.documentSn)??x4(Q.options["document-sn"]),V=R(Q.options.signKey)??R(Q.options["sign-key"])??R(Q.options.integration),w=z0(Q.options.wait)===!0,M=z0(Q.options.noWait)??z0(Q.options["no-wait"])??(w?!1:!0),F=await C$("seal_simulation_batch_create",U,I,{mode:K,sourceSystem:K,flowIds:q,documentSn:q,rejectNodeName:R(Q.options.rejectNode)??R(Q.options["reject-node"])??null,thinkingDepthOverride:R(Q.options.thinkingDepth)??R(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:R(Q.options.templateId)??R(Q.options["template-id"]),schemaConfig:G,requestIds:x4(Q.options.requestIds)??x4(Q.options["request-ids"]),workflowTypeId:R(Q.options.workflowTypeId)??R(Q.options["workflow-type-id"]),flowStatusList:x4(Q.options.flowStatusList)?.map(Number)??x4(Q.options["flow-status-list"])?.map(Number),businessCodes:x4(Q.options.businessCodes)??x4(Q.options["business-codes"]),documentType:R(Q.options.documentType)??R(Q.options["document-type"]),startTime:l0(Q.options.startTime)??l0(Q.options["start-time"]),endTime:l0(Q.options.endTime)??l0(Q.options["end-time"]),status:x4(Q.options.status),limit:l0(Q.options.limit),noWait:M,rawParams:W});if(w&&F&&typeof F==="object"&&"batchId"in F&&typeof F.batchId==="string"){await v0("seal_simulation_batch_wait",U,I,{batchId:F.batchId,timeout:R(Q.options.timeout),pollInterval:R(Q.options.pollInterval)??R(Q.options["poll-interval"])},T0(Q.options));return}C0(F,T0(Q.options));return}if($==="wait"){let J=Y??R(Q.options.batchId)??R(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s]");await v0("seal_simulation_batch_wait",U,I,{batchId:J,timeout:R(Q.options.timeout),pollInterval:R(Q.options.pollInterval)??R(Q.options["poll-interval"])},T0(Q.options));return}if($==="status"){let J=Y??R(Q.options.batchId)??R(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation status <batchId>");await v0("seal_simulation_batch_status",U,I,{batchId:J},T0(Q.options));return}if($==="clean"||$==="delete"){let J=Y??R(Q.options.batchId)??R(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation clean <batchId>");await v0("seal_simulation_batch_clean",U,I,{batchId:J},T0(Q.options));return}if($==="specifications"){let J=Y??R(Q.options.integration)??R(Q.options.signKey)??R(Q.options["sign-key"]);await v0("seal_simulation_specifications_list",U,I,{signKey:J},T0(Q.options));return}if($==="approval-definitions"||$==="definitions"){await v0("seal_simulation_feishu_approval_definitions_list",U,I,{},T0(Q.options));return}if($==="list"){await v0("seal_simulation_batches_list",U,I,{limit:l0(Q.options.limit)},T0(Q.options));return}if($==="get"){let J=Y??R(Q.options.batchId)??R(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation get <batchId>");await v0("seal_simulation_batch_get",U,I,{batchId:J},T0(Q.options));return}if($==="templates"){await v0("seal_simulation_templates_get",U,I,{},T0(Q.options));return}if($==="integrations"){await v0("seal_simulation_integrations_get",U,I,{},T0(Q.options));return}if($==="package-upload"){let J=Y??R(Q.options.file);if(!J)throw Error("Usage: seal-use simulation package-upload <材料包.zip>");if(!$f1(J))throw Error(`Filenotfound:${J}`);await v0("seal_simulation_material_package_upload",U,I,{filePath:J},T0(Q.o
Line truncated
`);return}if($==="install"||$==="init"||$==="sync"){let I=z0(U.options.local)||z0(U.options.workspace),Q=R(U.options.dir)??R(U.options.target)??Y,J=Q?Q:I?TE(process.cwd(),".agents","skills","seal-use"):rI(),K=Xg0(J),z=!I&&!Q,G=z?ao():void 0,H=z?$r():void 0;C0({installed:!0,targetDir:K.targetDir,fileCount:K.files.length,files:K.files,...G?{antigravity:G}:{},...H?{hosts:H}:{}});return}if($==="status"||$==="get"||!$){let I=rI(),Q=TE(process.cwd(),".agents","skills","seal-use"),J=to(),K=Yr();C0({global:{dir:I,installed:Hk0(TE(I,"SKILL.md"))},local:{dir:Q,installed:Hk0(TE(Q,"SKILL.md"))},antigravity:J,hosts:K});return}throw Error(`Unknownskillcommand:${$}.Run'seal-use help'foravailablecommands.`)}var Xk0=o(()=>{Ir();eq();L4();$4()});async function Zk0($,Y){if($==="config"){C0(await az(Y));return}throw Error(`Unknownsourcecommand:${$??""}.Run'seal-use help'foravailablecommands.`)}var qk0=o(()=>{aT();$4()});function Br($){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 Vk0($){let{sourceCorp:Y,targetCorp:U,sourceClient:I,targetClient:Q,samples:J=10,dryRun:K=!1,pollIntervalMs:z=2000,timeoutMs:G=45000,snPrefix:H="REG_",fetchFn:W=fetch}=$;if(U.environment!=="test")throw new G4(`重放目标企业「${U.name}」(${U.id})的环境为「${U.environment}」,非测试环境!
`+"硬性安全规定:自动化回归测试矩阵严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-usecorpsbind-test${Y.id}<testCorpId>`);let X=await UU(Q),q=(Array.isArray(X.features)?X.features:[]).find((m)=>m?.code==="ai-approval"),V=typeof q?.balance==="number"?q.balance:0,w=typeof q?.deductionAmount==="number"&&q.deductionAmount>0?q.deductionAmount:120,M=J*w;if(V<M)throw new G4(`测试企业「${U.name}」AI审批额度不足:当前剩余${V}点,本次回归抽样${J}笔需要约${M}点。
`+"为防止测试环境额度耗尽中断业务,已硬性拦截并拒绝发起测试单据注入。",2,`请为测试企业「${U.id}」充值AI审批额度,或降低抽样笔数(--samples${Math.max(1,Math.floor(V/w))})`);let F=await u4(I,{limit:J,status:"completed"}),N=Array.isArray(F.records)?F.records:[];if(N.length===0){let m=await u4(I,{limit:J});N=Array.isArray(m.records)?m.records:[]}if(N.length===0)throw new G4(`在母企业「${Y.name}」(${Y.id})中未检索到任何历史审批单据,无法抽取回归样本。`,2);if(N=N.slice(0,J),K){let m=N.map((t)=>{let $0=t.sourceDocumentSN??t.id,y=t?.result?.decision??t.aiDecision??t?.decision,p=Br(y),Y0=t?.result?.summary??t.aiSummary;return{sn:$0,sourceRecordId:t.id,prodDecision:p,prodSummary:Y0,status:"DRY_RUN"}});return{ok:!0,verdict:"DRY_RUN",safeToPublish:!0,timestamp:A1(),sourceCorp:{id:Y.id,name:Y.name,environment:Y.environment??"production"},targetCorp:{id:U.id,name:U.name,environment:U.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:V,deductionAmount:w,estimatedRequired:M},metrics:{sampleCount:m.length,successCount:m.length,failureCount:0,matchCount:m.length,flipCount:0,concordanceRate:1},flips:[],records:m}}let O=await Fp(Q,U,$.webhookSelector),D=[];for(let m of N){let t=Date.now(),$0=m.sourceDocumentSN??m.id,y=Br(m?.result?.decision??m.aiDecision??m?.decision),p=m?.result?.summary??m.aiSummary;try{let Y0=await W4(I,m.id),g=`${H}${$0}`,c=Vp(Y0,{snPrefix:H,docIdPrefix:H});await Lp(O.incomingDocumentWebhook.url,O.secret,c,W,j6(U.seal));let e=null,V0=Date.now();while(Date.now()-V0<G){await new Promise((X0)=>setTimeout(X0,z));let a=await u4(Q,{sourceDocumentSN:g,limit:1});if(a.records&&a.records.length>0){let X0=a.records[0];if(X0.status==="completed"||X0.status==="failed"){e=X0;break}}}if(!e){D.push({sn:$0,sourceRecordId:m.id,prodDecision:y,prodSummary:p,status:"FAILED",error:`测试租户单据审核超时(${Math.round(G/1000)}s未完成)`,durationMs:Date.now()-t});continue}let j0=Br(e?.result?.decision??e.aiDecision??e?.decision??(e.status==="completed"?"APPROVE":"ERROR")),A0=e?.result?.summary??e.aiSummary,R0=y===j0,r0=R0?"MATCHED":"FLIPPED",X1={sn:$0,sourceRecordId:m.id,prodDecision:y,prodSummary:p,testRecordId:e.id,testDecision:j0,testSummary:A0,status:r0,durationMs:Date.now()-t};if(!R0)X1.diff={from:y,to:j0,reasonDiff:A0&&p&&A0!==p?`生产:${p.slice(0,60)}...->测试:${A0.slice(0,60)}...`:void 0};D.push(X1)}catch(Y0){D.push({sn:$0,sourceRecordId:m.id,prodDecision:y,prodSummary:p,status:"FAILED",error:Y0 instanceof Error?Y0.message:String(Y0),durationMs:Date.now()-t})}}let P=D.filter((m)=>m.status==="MATCHED"||m.status==="FLIPPED"),T=D.filter((m)=>m.status==="MATCHED"),A=D.filter((m)=>m.status==="FLIPPED"),E=D.filter((m)=>m.status==="FAILED").length,C=T.length,i=A.length,x=C+i,h=x>0?C/x:0,b=i>0,n=b?"REGRESSIONS_DETECTED":"CLEAN",I0=!b&&E===0,k;try{let m=await UU(Q),$0=(Array.isArray(m.features)?m.features:[]).find((y)=>y?.code==="ai-approval");if(typeof $0?.balance==="number")k=$0.balance}catch{}return{ok:!b&&E===0,verdict:n,safeToPublish:I0,timestamp:A1(),sourceCorp:{id:Y.id,name:Y.name,environment:Y.environment??"production"},targetCorp:{id:U.id,name:U.name,environment:U.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:V,deductionAmount:w,estimatedRequired:M,balanceAfter:k},metrics:{sampleCount:D.length,successCount:P.length,failureCount:E,matchCount:C,flipCount:i,concordanceRate:Number(h.toFixed(4))},flips:A,records:D}}function Lk0($){let{sourceCorp:Y,targetCorp:U,verdict:I,safeToPublish:Q,metrics:J,quota:K,flips:z,records:G}=$,H=I==="CLEAN"?"\uD83D\uDFE2 决策完全一致 (CLEAN - 无回归)":I==="DRY_RUN"?"⚪ 预演模式 (DRY-RUN)":"\uD83D\uDD34 发现决策翻转 (REGRESSIONS_DETECTED)",W=["",`\uD83E\uDDEA[SealUseTest]规则回归测试矩阵:生产「${Y.name}」->测试靶场「${U.name}」`,`判定:${H}·准许发布:${Q?"YES (可安全上线)":"NO (存在行为偏离/待复核)"}`," "+"─".repeat(65),`样本总数:${J.sampleCount}|一致通过:${J.matchCount}|决策翻转:${J.flipCount}|异常失败:${J.failureCount}`,`一致率:${(J.concordanceRate*100).toFixed(1)}%|消耗预估:${K.estimatedRequired}点(余量:${K.balanceBefore}${K.balanceAfter!==void0?` -> ${K.balanceAfter}`:""})`," "+"─".repeat(65)];if(z.length>0){W.push(`⚠️决策翻转清单(${z.length}笔单据在新规则下结果改变):`);for(let X of z)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(I==="CLEAN")W.push(" ✓ 全部样本在新规则下的审核决策与生产历史 100% 吻合,无任何意外误杀或漏判
Line truncated
`)}var Fk0=o(()=>{RP();X4();Jq()});async function Pr($,Y,U){let I=($??Y??"regression").toLowerCase();if(I==="regression"||I==="regress"||I==="matrix"){let Q=R(U.options.corp)??(Y&&Y!==I?Y:void 0),J=M1(Q),K=J,z=J;if(J.environment==="test"){z=J;let O=R(U.options["prod-corp"])??R(U.options.prod)??J.prodCorpId;if(!O)throw new G4(`测试企业「${J.name}」(${J.id})未绑定生产母企业,无法拉取历史样本。
`);I(Q)})})}var OE=8787,NE="127.0.0.1";var Fr=o(()=>{xy0();W3()});async function fy0($){let Y=l0($.options.port)??l0($.options.p),U=R($.options.host)??R($.options.h),Q=await DE({port:Y,host:U}),I=()=>{Q.close(()=>{process.exit(0)})};process.on("SIGINT",I),process.on("SIGTERM",I),await new Promise(()=>{})}var uy0=o(()=>{L4();Fr()});async function by0($,Y,U,Q){if($==="config"||$==="get"){await v0("seal_llm_config_get",Y,U,{},T0(Q.options));return}if($==="providers"||$==="list"){await v0("seal_llm_providers_list",Y,U,{},T0(Q.options));return}throw Error(`Unknownllmcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}var iy0=o(()=>{D4();$4()});async function cy0($,Y){if($==="config"||$==="json"){wr();return}let{startServer:U}=await py0().then(() => dy0);U()}function wr(){C0({mcpServers:{"seal-use":{type:"stdio",command:"seal-use",args:["mcp"],env:{SEAL_USE_MCP_ENABLED:"true"}}}})}var ny0=o(()=>{$4()});function my0($){let Y=FE();C0(Y,{...T0($.options),allowFull:!0})}var ly0=o(()=>{Vr();$4()});async function oy0($,Y,U,Q){if($==="available"){await v0("seal_permissions_available_list",Y,U,{},T0(Q.options));return}if($==="configs"||$==="list"){await v0("seal_permissions_configs_list",Y,U,{},T0(Q.options));return}throw Error(`Unknownpermissionscommand:${$??""}.Run'seal-use help'foravailablecommands.`)}var ry0=o(()=>{D4();$4()});import{readFileSync as sy0}from"node:fs";async function ty0($,Y,U,Q,I,J,K){if(!$||$==="get"){await v0("seal_preference_get",I,J,{},T0(K.options));return}if($==="decision"){if(Y==="update"||!Y){let z=R(K.options.input),G=z?JSON.parse(sy0(z,"utf8")):F6(K.json);if(!G||Object.keys(G).length===0)throw Error(`Usage:seal-usepreferencedecisionupdate--json'{"explicitApprove":"..."}'`);await v0("seal_preference_decision_update",I,J,{...G,dryRun:z0(K.options.dryRun)??z0(K.options["dry-run"])},T0(K.options));return}}if($==="thinking-depth"||$==="thinkingDepth"){if(Y==="set"){let z=R(K.options.default)??R(K.options.level)??Q;if(z!=="medium"&&z!=="high")throw Error("Usage: seal-use preference thinking-depth set --default <medium|high>");await v0("seal_preference_thinking_depth_set",I,J,{defaultLevel:z,dryRun:z0(K.options.dryRun)??z0(K.options["dry-run"])},T0(K.options));return}if(Y==="policies"){if(U==="list"||!U){await v0("seal_preference_thinking_depth_policies_list",I,J,{},T0(K.options));return}if(U==="upsert"){let z=R(K.options.input),G=z?JSON.parse(sy0(z,"utf8")):F6(K.json);if(!G||!G.id||!G.name)throw Error(`Usage:seal-usepreferencethinking-depthpoliciesupsert--json'{"id":"...","name":"...","level":"high"}'`);await v0("seal_preference_thinking_depth_policies_upsert",I,J,{...G,dryRun:z0(K.options.dryRun)??z0(K.options["dry-run"])},T0(K.options));return}if(U==="remove"||U==="delete"){let z=Q??R(K.options.id)??R(K.options.policyId);if(!z)throw Error("Usage: seal-use preference thinking-depth policies remove <policyId>");await v0("seal_preference_thinking_depth_policies_remove",I,J,{policyId:z,dryRun:z0(K.options.dryRun)??z0(K.options["dry-run"])},T0(K.options));return}}}throw Error(`Unknownpreferenceaction:${$??""}.Available:get,decisionupdate,thinking-depthset,thinking-depthpolicieslist/upsert/remove.`)}var ay0=o(()=>{D4();L4();$4()});async function ey0($={}){let Y=K$(),U=T4(),Q=r2(Y,{stateful:U.stateful,defaultCorpId:U.defaultCorpId,corpId:$.corpId},m3());console.log(`[probe]corp=${Q.id}source=${Q.source.type}`);let I=await tz(Q);console.log("[probe] seal enterprise"),console.log(JSON.stringify(I,null,2));let J=await P1(Q),K=await pM(J,{documentLimit:20,stylePreferencesEndpoint:Q.seal.endpoints.approvalStylePreferences});console.log("[probe] approval context summary"),console.log(JSON.stringify({rules:K.rules.rules.length,hasPendingRuleDeletes:K.rules.hasPendingDeletes,documents:K.documents.articles.length,documentsTotal:K.documents.total,stylePreferences:K.stylePreferences.ok?"ok":`error:${K.stylePreferences.error}`},null,2))}var $k0=o(()=>{a$();i6();aT();X4()});async function Yk0($,Y,U){let Q=Y??R(U.options.corp)??($&&$!=="--corp"?$:void 0);await ey0({corpId:Q})}var Uk0=o(()=>{$k0();L4()});import{readFileSync as ax1}from"node:fs";function Qk0($,Y){let U=R($.options.descriptionFile)??R($.options["description-file"]);if(U)return ax1(U,"utf8").trim();let Q=R($.options.description)??R($.options.desc);if(Q!==void 0)return Q;return typeof Y.description==="string"?Y.description:void 0}function WY($,Y){let U=R($.options.version);if(U!==void 0)return U;if(z0($.options.latest))return"latest";if(Y!==void 0&&!Y.startsWith("-"))return Y;return}async function Mr($,Y,U,Q,I){if(!U&&!($==="lint"||$==="linters"||$==="linter-list"||$==="map"))throw Error(`rules${$??""}requiresanauthenticatedenterprise.Run'seal-use corps list'toselectone.`);if($==="count"){let K=WY(I);await v0("seal_approval_rules_list",U,Q,{version:K,countOnly:!0},T0(I.options));return}if($==="list"){let K=WY(I);if(z0(I.options.count)){await v0("seal_approval_rules_list",U,Q,{version:K,countOn
Line truncated
`).filter(Boolean),J=I.slice(-Y);return{logFile:U,lines:J,totalLines:I.length}}async function Qf1($){let Y=TE($),U=Dr($),Q=UV($);Gk0($.stateDir);let I=$.port??(process.env.PORT?Number.parseInt(process.env.PORT,10):OE),J=$.host??(process.env.HOST?process.env.HOST:NE);BE(Y,`${process.pid}
`,{mode:384}),BE(U,JSON.stringify({pid:process.pid,port:I,host:J,version:$.version,startedAt:A1()},null,2),{mode:384}),YG(Q,`servicestartingonhttp://${J}:${I} pid=${process.pid}`);let K=null;try{K=await DE({port:I,host:J,silent:!0}),YG(Q,`service listening pid=${process.pid}`)}catch(G){if(YG(Q,`service failed to bind port ${I}: ${G instanceof Error?G.message:String(G)}`),PE(Y)===process.pid)d9(Y,{force:!0}),d9(U,{force:!0});throw G}let z=()=>{if(K)K.close(),K=null;if(PE(Y)===process.pid)d9(Y,{force:!0}),d9(U,{force:!0});YG(Q,`stopped pid=${process.pid}`)};await new Promise((G)=>{let H=!1,W=()=>{if(H)return;H=!0,z(),process.off("SIGTERM",W),process.off("SIGINT",W),G()};process.once("SIGTERM",W),process.once("SIGINT",W)})}function Jk0($){Gk0($.stateDir);let Y=sQ($);if(Y.running)return Y;let U=$.launcher??{command:process.execPath,args:[$.entryFile]},Q=[...U.args??[],"service","run"];if($.port)Q.push("--port",String($.port));if($.host)Q.push("--host",String($.host));let I=ex1(U.command,Q,{cwd:$.appRoot,detached:!0,stdio:["ignore","ignore","ignore"],env:process.env});I.unref();let J=TE($);return BE(J,`${I.pid}
`);return}if($==="install"||$==="init"||$==="sync"){let Q=z0(U.options.local)||z0(U.options.workspace),I=R(U.options.dir)??R(U.options.target)??Y,J=I?I:Q?EE(process.cwd(),".agents","skills","seal-use"):rQ(),K=Vy0(J),z=!Q&&!I,G=z?$r():void 0,H=z?Qr():void 0;C0({installed:!0,targetDir:K.targetDir,fileCount:K.files.length,files:K.files,...G?{antigravity:G}:{},...H?{hosts:H}:{}});return}if($==="status"||$==="get"||!$){let Q=rQ(),I=EE(process.cwd(),".agents","skills","seal-use"),J=Yr(),K=Ir();C0({global:{dir:Q,installed:Zk0(EE(Q,"SKILL.md"))},local:{dir:I,installed:Zk0(EE(I,"SKILL.md"))},antigravity:J,hosts:K});return}throw Error(`Unknownskillcommand:${$}.Run'seal-use help'foravailablecommands.`)}var Vk0=o(()=>{Kr();eq();L4();$4()});async function Lk0($,Y){if($==="config"){C0(await tz(Y));return}throw Error(`Unknownsourcecommand:${$??""}.Run'seal-use help'foravailablecommands.`)}var Fk0=o(()=>{aT();$4()});function Er($){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 wk0($){let{sourceCorp:Y,targetCorp:U,sourceClient:Q,targetClient:I,samples:J=10,dryRun:K=!1,pollIntervalMs:z=2000,timeoutMs:G=45000,snPrefix:H="REG_",fetchFn:W=fetch}=$;if(U.environment!=="test")throw new G4(`重放目标企业「${U.name}」(${U.id})的环境为「${U.environment}」,非测试环境!
`+"硬性安全规定:自动化回归测试矩阵严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-usecorpsbind-test${Y.id}<testCorpId>`);let X=await UU(I),q=(Array.isArray(X.features)?X.features:[]).find((m)=>m?.code==="ai-approval"),V=typeof q?.balance==="number"?q.balance:0,w=typeof q?.deductionAmount==="number"&&q.deductionAmount>0?q.deductionAmount:120,M=J*w;if(V<M)throw new G4(`测试企业「${U.name}」AI审批额度不足:当前剩余${V}点,本次回归抽样${J}笔需要约${M}点。
`+"为防止测试环境额度耗尽中断业务,已硬性拦截并拒绝发起测试单据注入。",2,`请为测试企业「${U.id}」充值AI审批额度,或降低抽样笔数(--samples${Math.max(1,Math.floor(V/w))})`);let F=await u4(Q,{limit:J,status:"completed"}),N=Array.isArray(F.records)?F.records:[];if(N.length===0){let m=await u4(Q,{limit:J});N=Array.isArray(m.records)?m.records:[]}if(N.length===0)throw new G4(`在母企业「${Y.name}」(${Y.id})中未检索到任何历史审批单据,无法抽取回归样本。`,2);if(N=N.slice(0,J),K){let m=N.map((a)=>{let $0=a.sourceDocumentSN??a.id,g=a?.result?.decision??a.aiDecision??a?.decision,p=Er(g),Y0=a?.result?.summary??a.aiSummary;return{sn:$0,sourceRecordId:a.id,prodDecision:p,prodSummary:Y0,status:"DRY_RUN"}});return{ok:!0,verdict:"DRY_RUN",safeToPublish:!0,timestamp:A1(),sourceCorp:{id:Y.id,name:Y.name,environment:Y.environment??"production"},targetCorp:{id:U.id,name:U.name,environment:U.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:V,deductionAmount:w,estimatedRequired:M},metrics:{sampleCount:m.length,successCount:m.length,failureCount:0,matchCount:m.length,flipCount:0,concordanceRate:1},flips:[],records:m}}let O=await Mp(I,U,$.webhookSelector),D=[];for(let m of N){let a=Date.now(),$0=m.sourceDocumentSN??m.id,g=Er(m?.result?.decision??m.aiDecision??m?.decision),p=m?.result?.summary??m.aiSummary;try{let Y0=await W4(Q,m.id),y=`${H}${$0}`,c=Fp(Y0,{snPrefix:H,docIdPrefix:H});await wp(O.incomingDocumentWebhook.url,O.secret,c,W,j6(U.seal));let e=null,V0=Date.now();while(Date.now()-V0<G){await new Promise((X0)=>setTimeout(X0,z));let t=await u4(I,{sourceDocumentSN:y,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:m.id,prodDecision:g,prodSummary:p,status:"FAILED",error:`测试租户单据审核超时(${Math.round(G/1000)}s未完成)`,durationMs:Date.now()-a});continue}let j0=Er(e?.result?.decision??e.aiDecision??e?.decision??(e.status==="completed"?"APPROVE":"ERROR")),A0=e?.result?.summary??e.aiSummary,R0=g===j0,r0=R0?"MATCHED":"FLIPPED",X1={sn:$0,sourceRecordId:m.id,prodDecision:g,prodSummary:p,testRecordId:e.id,testDecision:j0,testSummary:A0,status:r0,durationMs:Date.now()-a};if(!R0)X1.diff={from:g,to:j0,reasonDiff:A0&&p&&A0!==p?`生产:${p.slice(0,60)}...->测试:${A0.slice(0,60)}...`:void 0};D.push(X1)}catch(Y0){D.push({sn:$0,sourceRecordId:m.id,prodDecision:g,prodSummary:p,status:"FAILED",error:Y0 instanceof Error?Y0.message:String(Y0),durationMs:Date.now()-a})}}let P=D.filter((m)=>m.status==="MATCHED"||m.status==="FLIPPED"),T=D.filter((m)=>m.status==="MATCHED"),A=D.filter((m)=>m.status==="FLIPPED"),E=D.filter((m)=>m.status==="FAILED").length,C=T.length,i=A.length,x=C+i,h=x>0?C/x:0,b=i>0,n=b?"REGRESSIONS_DETECTED":"CLEAN",Q0=!b&&E===0,k;try{let m=await UU(I),$0=(Array.isArray(m.features)?m.features:[]).find((g)=>g?.code==="ai-approval");if(typeof $0?.balance==="number")k=$0.balance}catch{}return{ok:!b&&E===0,verdict:n,safeToPublish:Q0,timestamp:A1(),sourceCorp:{id:Y.id,name:Y.name,environment:Y.environment??"production"},targetCorp:{id:U.id,name:U.name,environment:U.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:V,deductionAmount:w,estimatedRequired:M,balanceAfter:k},metrics:{sampleCount:D.length,successCount:P.length,failureCount:E,matchCount:C,flipCount:i,concordanceRate:Number(h.toFixed(4))},flips:A,records:D}}function Mk0($){let{sourceCorp:Y,targetCorp:U,verdict:Q,safeToPublish:I,metrics:J,quota:K,flips:z,records:G}=$,H=Q==="CLEAN"?"\uD83D\uDFE2 决策完全一致 (CLEAN - 无回归)":Q==="DRY_RUN"?"⚪ 预演模式 (DRY-RUN)":"\uD83D\uDD34 发现决策翻转 (REGRESSIONS_DETECTED)",W=["",`\uD83E\uDDEA[SealUseTest]规则回归测试矩阵:生产「${Y.name}」->测试靶场「${U.name}」`,`判定:${H}·准许发布:${I?"YES (可安全上线)":"NO (存在行为偏离/待复核)"}`," "+"─".repeat(65),`样本总数:${J.sampleCount}|一致通过:${J.matchCount}|决策翻转:${J.flipCount}|异常失败:${J.failureCount}`,`一致率:${(J.concordanceRate*100).toFixed(1)}%|消耗预估:${K.estimatedRequired}点(余量:${K.balanceBefore}${K.balanceAfter!==void0?` -> ${K.balanceAfter}`:""})`," "+"─".repeat(65)];if(z.length>0){W.push(`⚠️决策翻转清单(${z.length}笔单据在新规则下结果改变):`);for(let X of z)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(Q==="CLEAN")W.push(" ✓ 全部样本在新规则下的审核决策与生产历史 100% 吻合,无任何意外误杀或漏判
Line truncated
`)}var Ok0=o(()=>{_P();X4();Jq()});async function jr($,Y,U){let Q=($??Y??"regression").toLowerCase();if(Q==="regression"||Q==="regress"||Q==="matrix"){let I=R(U.options.corp)??(Y&&Y!==Q?Y:void 0),J=M1(I),K=J,z=J;if(J.environment==="test"){z=J;let O=R(U.options["prod-corp"])??R(U.options.prod)??J.prodCorpId;if(!O)throw new G4(`测试企业「${J.name}」(${J.id})未绑定生产母企业,无法拉取历史样本。
`+"请建立绑定或通过 --prod-corp 参数指定生产企业来源。",2,`seal-usecorpsbind-test<prodCorpId>${J.id}`);K=M1(O)}else{K=J;let O=R(U.options["test-corp"])??R(U.options.test)??J.testCorpId;if(!O)throw new G4(`生产企业「${J.name}」(${J.id})未绑定测试靶场企业。
`+"硬性规定:回归测试严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-usecorpsbind-test${J.id}<testCorpId>`);z=M1(O)}let G=await P1(K),H=await P1(z),W=l0(U.options.samples)??l0(U.options.limit)??l0(U.options.n)??10,X=z0(U.options["dry-run"]),Z=z0(U.options["fail-on-flips"]),q=l0(U.options["poll-interval"])??2000,V=l0(U.options.timeout)??45000,w=R(U.options["sn-prefix"])??"REG_",M=R(U.options.webhook)??R(U.options.selector),F=await Vk0({sourceCorp:K,targetCorp:z,sourceClient:G,targetClient:H,samples:W,dryRun:X,pollIntervalMs:q,timeoutMs:V,snPrefix:w,failOnFlips:Z,webhookSelector:M});if(!(z0(U.options.quiet)||z0(U.options.silent)))console.error(Lk0(F));if(C0(F),Z&&!F.ok)throw new G4(`回归测试发现${F.metrics.flipCount}笔单据决策翻转,已按--fail-on-flips策略非零终止。`,1);return}throw new G4(`未知的test子命令:"${I}"。
可用子命令:seal-usetestregression[--corp<id>][--samples<N>][--dry-run]`,2,"seal-use test regression --help")}var wk0=o(()=>{p8();D4();L4();$4();i6();Fk0()});function EE($=process.execPath,Y=import.meta.url){if(Y.includes("/$bunfs/")||Y.includes("\\$bunfs\\"))return!0;let U=$.toLowerCase().replace(/\\/g,"/");return!U.endsWith("/bun")&&!U.endsWith("/bun.exe")&&!U.endsWith("/node")&&!U.endsWith("/node.exe")}var Mk0=o(()=>{eq()});import{existsSync as Yf1,mkdirSync as Uf1,readFileSync as If1,renameSync as Qf1,writeFileSync as Jf1}from"node:fs";import{homedir as Kf1}from"node:os";import{dirname as zf1,join as Gf1}from"node:path";import{spawn as Hf1}from"node:child_process";function Ok0(){let $=process.env[Wf1]?.trim();if($)return $;return Zf1}function Nk0($=Ok0()){if(!Yf1($))return null;try{let Y=If1($,"utf-8"),U=JSON.parse(Y);if(U&&typeof U==="object"&&typeof U.latestVersion==="string"&&typeof U.checkedAt==="string")return{...U,checkedAt:T8(U.checkedAt),...typeof U.publishedAt==="string"?{publishedAt:T8(U.publishedAt)}:{}};return null}catch{return null}}function IV($,Y=Ok0()){try{let U=zf1(Y);Uf1(U,{recursive:!0,mode:448});let I={checkedAt:$.checkedAt?T8($.checkedAt):A1(),latestVersion:$.latestVersion,publishedAt:$.publishedAt?T8($.publishedAt):void 0,releaseUrl:$.releaseUrl},Q=`${Y}.tmp.${Date.now()}.${Math.random().toString(36).slice(2,8)}`;Jf1(Q,JSON.stringify(I,null,2),{mode:384}),Qf1(Q,Y)}catch{}}function Dk0($,Y=Xf1){if(!$||!$.checkedAt)return!0;let U=new Date($.checkedAt).getTime();if(Number.isNaN(U))return!0;return Date.now()-U>Y}function Ak0($){if(process.env.SEAL_DISABLE_BG_UPDATE==="1"||!1||process.env.CI)return!1;if(!$||!$.command)return!1;try{let Y=$.command,U=[...$.args??[],"update","check","--bg-save"];return Hf1(Y,U,{detached:!0,stdio:"ignore",env:{...process.env,SEAL_DISABLE_BG_UPDATE:"1"}}).unref(),!0}catch{return!1}}var Wf1="SEAL_USE_UPDATE_CACHE_FILE",Xf1=86400000,Zf1;var Tr=o(()=>{Zf1=Gf1(Kf1(),".config","seal-use","update-cache.json")});import{chmodSync as qf1,mkdirSync as Vf1,readdirSync as Lf1,realpathSync as Bk0,renameSync as Er,rmSync as Ff1,unlinkSync as Ck0,writeFileSync as Pk0}from"node:fs";import{basename as wf1,dirname as Mf1,isAbsolute as Of1,join as RE,relative as Nf1}from"node:path";import{spawn as Df1,spawnSync as K7}from"node:child_process";async function _k0($,Y={}){let U={appRoot:$.appRoot,entryFile:$.entryFile,stateDir:Nr,version:Z1,launcher:$.launcher},I=Y.repo||process.env[Af1]?.trim()||process.env[Bf1]?.trim()||Rk0,Q=Y.targetVersion?.trim(),J=Q&&Q.toLowerCase()!=="latest"?Q:void 0;if(J){let D=J.replace(/^v/,""),P=yk0(D,Z1);if(P<0)if(!By&&Y.force);else{C0({updated:!1,currentVersion:Z1,targetVersion:D,mode:EE()?"binary":"source",message:!By?`Cannotdowngradeseal-usefromdevbuildv${Z1}toreleasev${D}.Use--forcetooverwrite.`:`Cannotdowngradeseal-usefromv${Z1}toolderversionv${D}.Updatesmustbeforward-only.`});return}if(P===0&&!Y.force){C0({updated:!1,currentVersion:Z1,targetVersion:D,mode:EE()?"binary":"source",message:`seal-useisalreadyatversionv${Z1}.Use--forcetoreinstall.`});return}}if(Y.changelogOnly){let D=await CE(I,Y.limit??10);C0({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:i5(P.version,Z1)}))});return}if(!EE()){if(Y.checkOnly){let P=await CE(I,30),T=P[0],A=T?.version??Z1,E=P.find((x)=>x.version===Z1),C=i5(A,Z1),i=P.filter((x)=>i5(x.version,Z1));if(T?.version)IV({latestVersion:T.version,publishedAt:T.publishedAt,releaseUrl:T.htmlUrl});if(Y.bgSave)return;C0({updated:!1,updateAvailable:C,currentVersion:Z1,currentVersionPublishedAt:E?.publishedAt,latestVersion:A,latestVersionPublishedAt:T?.publishedAt,behindCount:i.length,pendingReleases:i.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=sI(U).running;if(D)await J7("stop",U);try{jk0("git",["-C",$.appRoot,"pull","--ff-only"])}catch(P){console.error(`⚠️开发版更新同步失败,继续刷新本地依赖:${PinstanceofError?P.message:String(P)}`)}if(jk0("bun",["install"],{cwd:$.appRoot}),D)await J7("start",U);C0({updated:!0,serviceRestarted:D,version:Z1,mode:"source"});return}if(Cf1())try{await Rf1($,Y,U,I,J);return}catch(D){console.error(`⚠️Homebrew自动更新失败,回退至原生二进制更新:${DinstanceofError?D.message:String(D)}`)}let K=Tf1(),z=Ef1(),G=await CE(I,30),H=J?G.find((D)=>D.version===J||D.tagName===J||D.tagName===`v${J}`)??await _E(I,J):G[0]??await _E(I);if(!H){C0({updated:!1,currentVersion:Z1,mode:"binary",message:`Failedtoqueryreleasesfromrepository'${I}'`});return}let W=H.version,X=G.find((D)=>D.version=
Line truncated
`)}catch{}}async function Sf1($,Y,U,I){let Q=jr(),J=[],K=U?U.startsWith("v")?U:`v${U}`:void 0,z=I||$.split("/").pop()||"";if(Q!=="github"){if(K&&z)J.push(`https://git.ying-qing.cn/gitea/seal-use/releases/download/${K}/${z}`,`https://git.ying-qing.cn/gitea/seal-home/releases/download/${K}/${z}`);if($.startsWith("https://git.ying-qing.cn"))J.push($)}if(Q!=="gitea")if(K&&z){let w=`https://github.com/${Rk0}/releases/download/${K}/${z}`;if(!process.env.CI)J.push(`https://ghfast.top/${w}`,`https://gh.ddlc.top/${w}`);J.push(w)}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 w=0;w<G.length;w++){let M=G[w],F=new AbortController,N="",O=(A)=>{N=A;try{F.abort()}catch{}},D=setTimeout(()=>{O("Connection timed out (no response headers within 6s)")},W),P,T;try{jE(`==> [${w+1}/${G.length}] Downloading via: ${M}`);let A=await fetch(M,{signal:F.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 E=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)`);Pk0(Y,n),jE(`✓ Download succeeded (${(n.length/1024/1024).toFixed(1)} MB)`);return}let i=[],x=0,h=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(),I0,k=new Promise((y,p)=>{I0=setTimeout(()=>{p(Error("Data transfer stalled (no chunk received for 10s)"))},q)}),m;try{m=await Promise.race([n,k])}finally{if(I0)clearTimeout(I0)}let{done:t,value:$0}=m;if(t)break;if($0){if(i.push($0),x+=$0.length,T&&x>=Z)clearTimeout(T),T=void 0;let y=Date.now();if(y-h>200){h=y;let p=E?Math.round(x/E*100):0,Y0=(x/1048576).toFixed(1),g=E?(E/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${p}% (${Y0} / ${g} MB)...`)}catch{}}}}try{process.stderr.write(`
`+"硬性规定:回归测试严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-usecorpsbind-test${J.id}<testCorpId>`);z=M1(O)}let G=await P1(K),H=await P1(z),W=l0(U.options.samples)??l0(U.options.limit)??l0(U.options.n)??10,X=z0(U.options["dry-run"]),Z=z0(U.options["fail-on-flips"]),q=l0(U.options["poll-interval"])??2000,V=l0(U.options.timeout)??45000,w=R(U.options["sn-prefix"])??"REG_",M=R(U.options.webhook)??R(U.options.selector),F=await wk0({sourceCorp:K,targetCorp:z,sourceClient:G,targetClient:H,samples:W,dryRun:X,pollIntervalMs:q,timeoutMs:V,snPrefix:w,failOnFlips:Z,webhookSelector:M});if(!(z0(U.options.quiet)||z0(U.options.silent)))console.error(Mk0(F));if(C0(F),Z&&!F.ok)throw new G4(`回归测试发现${F.metrics.flipCount}笔单据决策翻转,已按--fail-on-flips策略非零终止。`,1);return}throw new G4(`未知的test子命令:"${Q}"。
可用子命令:seal-usetestregression[--corp<id>][--samples<N>][--dry-run]`,2,"seal-use test regression --help")}var Nk0=o(()=>{p8();D4();L4();$4();i6();Ok0()});function jE($=process.execPath,Y=import.meta.url){if(Y.includes("/$bunfs/")||Y.includes("\\$bunfs\\"))return!0;let U=$.toLowerCase().replace(/\\/g,"/");return!U.endsWith("/bun")&&!U.endsWith("/bun.exe")&&!U.endsWith("/node")&&!U.endsWith("/node.exe")}var Dk0=o(()=>{eq()});import{existsSync as Gf1,mkdirSync as Hf1,readFileSync as Wf1,renameSync as Xf1,writeFileSync as Zf1}from"node:fs";import{homedir as qf1}from"node:os";import{dirname as Vf1,join as Lf1}from"node:path";import{spawn as Ff1}from"node:child_process";function Ak0(){let $=process.env[wf1]?.trim();if($)return $;return Of1}function Bk0($=Ak0()){if(!Gf1($))return null;try{let Y=Wf1($,"utf-8"),U=JSON.parse(Y);if(U&&typeof U==="object"&&typeof U.latestVersion==="string"&&typeof U.checkedAt==="string")return{...U,checkedAt:T8(U.checkedAt),...typeof U.publishedAt==="string"?{publishedAt:T8(U.publishedAt)}:{}};return null}catch{return null}}function QV($,Y=Ak0()){try{let U=Vf1(Y);Hf1(U,{recursive:!0,mode:448});let Q={checkedAt:$.checkedAt?T8($.checkedAt):A1(),latestVersion:$.latestVersion,publishedAt:$.publishedAt?T8($.publishedAt):void 0,releaseUrl:$.releaseUrl},I=`${Y}.tmp.${Date.now()}.${Math.random().toString(36).slice(2,8)}`;Zf1(I,JSON.stringify(Q,null,2),{mode:384}),Xf1(I,Y)}catch{}}function Pk0($,Y=Mf1){if(!$||!$.checkedAt)return!0;let U=new Date($.checkedAt).getTime();if(Number.isNaN(U))return!0;return Date.now()-U>Y}function Tk0($){if(process.env.SEAL_DISABLE_BG_UPDATE==="1"||!1||process.env.CI)return!1;if(!$||!$.command)return!1;try{let Y=$.command,U=[...$.args??[],"update","check","--bg-save"];return Ff1(Y,U,{detached:!0,stdio:"ignore",env:{...process.env,SEAL_DISABLE_BG_UPDATE:"1"}}).unref(),!0}catch{return!1}}var wf1="SEAL_USE_UPDATE_CACHE_FILE",Mf1=86400000,Of1;var Cr=o(()=>{Of1=Lf1(qf1(),".config","seal-use","update-cache.json")});import{chmodSync as Nf1,mkdirSync as Df1,readdirSync as Af1,realpathSync as Ek0,renameSync as Rr,rmSync as Bf1,unlinkSync as vk0,writeFileSync as jk0}from"node:fs";import{basename as Pf1,dirname as Tf1,isAbsolute as Ef1,join as _E,relative as jf1}from"node:path";import{spawn as Cf1,spawnSync as K7}from"node:child_process";async function hk0($,Y={}){let U={appRoot:$.appRoot,entryFile:$.entryFile,stateDir:Br,version:Z1,launcher:$.launcher},Q=Y.repo||process.env[Rf1]?.trim()||process.env[_f1]?.trim()||Sk0,I=Y.targetVersion?.trim(),J=I&&I.toLowerCase()!=="latest"?I:void 0;if(J){let D=J.replace(/^v/,""),P=xk0(D,Z1);if(P<0)if(!Pg&&Y.force);else{C0({updated:!1,currentVersion:Z1,targetVersion:D,mode:jE()?"binary":"source",message:!Pg?`Cannotdowngradeseal-usefromdevbuildv${Z1}toreleasev${D}.Use--forcetooverwrite.`:`Cannotdowngradeseal-usefromv${Z1}toolderversionv${D}.Updatesmustbeforward-only.`});return}if(P===0&&!Y.force){C0({updated:!1,currentVersion:Z1,targetVersion:D,mode:jE()?"binary":"source",message:`seal-useisalreadyatversionv${Z1}.Use--forcetoreinstall.`});return}}if(Y.changelogOnly){let D=await RE(Q,Y.limit??10);C0({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:i5(P.version,Z1)}))});return}if(!jE()){if(Y.checkOnly){let P=await RE(Q,30),T=P[0],A=T?.version??Z1,E=P.find((x)=>x.version===Z1),C=i5(A,Z1),i=P.filter((x)=>i5(x.version,Z1));if(T?.version)QV({latestVersion:T.version,publishedAt:T.publishedAt,releaseUrl:T.htmlUrl});if(Y.bgSave)return;C0({updated:!1,updateAvailable:C,currentVersion:Z1,currentVersionPublishedAt:E?.publishedAt,latestVersion:A,latestVersionPublishedAt:T?.publishedAt,behindCount:i.length,pendingReleases:i.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=sQ(U).running;if(D)await J7("stop",U);try{_k0("git",["-C",$.appRoot,"pull","--ff-only"])}catch(P){console.error(`⚠️开发版更新同步失败,继续刷新本地依赖:${PinstanceofError?P.message:String(P)}`)}if(_k0("bun",["install"],{cwd:$.appRoot}),D)await J7("start",U);C0({updated:!0,serviceRestarted:D,version:Z1,mode:"source"});return}if(yf1())try{await kf1($,Y,U,Q,J);return}catch(D){console.error(`⚠️Homebrew自动更新失败,回退至原生二进制更新:${DinstanceofError?D.message:String(D)}`)}let K=Sf1(),z=hf1(),G=await RE(Q,30),H=J?G.find((D)=>D.version===J||D.tagName===J||D.tagName===`v${J}`)??await vE(Q,J):G[0]??await vE(Q);if(!H){C0({updated:!1,currentVersion:Z1,mode:"binary",message:`Failedtoqueryreleasesfromrepository'${Q}'`});return}let W=H.version,X=G.find((D)=>D.version=
Line truncated
`)}catch{}}async function uf1($,Y,U,Q){let I=_r(),J=[],K=U?U.startsWith("v")?U:`v${U}`:void 0,z=Q||$.split("/").pop()||"";if(I!=="github"){if(K&&z)J.push(`https://git.ying-qing.cn/gitea/seal-use/releases/download/${K}/${z}`,`https://git.ying-qing.cn/gitea/seal-home/releases/download/${K}/${z}`);if($.startsWith("https://git.ying-qing.cn"))J.push($)}if(I!=="gitea")if(K&&z){let w=`https://github.com/${Sk0}/releases/download/${K}/${z}`;if(!process.env.CI)J.push(`https://ghfast.top/${w}`,`https://gh.ddlc.top/${w}`);J.push(w)}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 w=0;w<G.length;w++){let M=G[w],F=new AbortController,N="",O=(A)=>{N=A;try{F.abort()}catch{}},D=setTimeout(()=>{O("Connection timed out (no response headers within 6s)")},W),P,T;try{CE(`==> [${w+1}/${G.length}] Downloading via: ${M}`);let A=await fetch(M,{signal:F.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 E=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)`);jk0(Y,n),CE(`✓ Download succeeded (${(n.length/1024/1024).toFixed(1)} MB)`);return}let i=[],x=0,h=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(),Q0,k=new Promise((g,p)=>{Q0=setTimeout(()=>{p(Error("Data transfer stalled (no chunk received for 10s)"))},q)}),m;try{m=await Promise.race([n,k])}finally{if(Q0)clearTimeout(Q0)}let{done:a,value:$0}=m;if(a)break;if($0){if(i.push($0),x+=$0.length,T&&x>=Z)clearTimeout(T),T=void 0;let g=Date.now();if(g-h>200){h=g;let p=E?Math.round(x/E*100):0,Y0=(x/1048576).toFixed(1),y=E?(E/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${p}% (${Y0} / ${y} MB)...`)}catch{}}}}try{process.stderr.write(`
-`seal-use simulation create --mode hosecloud --flow-ids ... --no-wait --corp <corpId>` returns immediately with an `asyncTicket` (creation is non-blocking by default for compatibility).
-`seal-use simulation create --mode hosecloud --flow-ids ... --no-wait --corp <corpId>` returns immediately with an `asyncTicket` (creation is non-blocking by default; `--wait` hangs and polls until the batch finishes).
- Create is idempotent per document set: before POSTing, the CLI checks recent batches and, if an identical `--flow-ids`/`--package-ids` batch (not failed/cancelled) was created within `--reuse-window` (default `5m`), it returns the existing batch with `reused: true` and does not create a new one — protecting against double billing when a `--wait` invocation is interrupted and re-issued. Pass `--force` (or `--reuse-window 0`) to skip the check and create a fresh batch.
-`seal-use simulation status <batchId> --corp <corpId>` performs one non-blocking status check and returns `QUEUED`/`RUNNING`/`COMPLETED`/`FAILED`-style state plus counters.
-`seal-use simulation approval-definitions --corp <corpId>` lists available Feishu approval definitions so an `approvalCode` can be selected before creating a batch.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.