- Added opt-in `--with-flow` flag to `seal-use approval-runs export` to enrich reports with **E人工行为** and **E人工意见** columns from native Hose/Ekuaibao approval timelines.
- **Rejection Formatting (样式 2-B 三行展开式)**: Cleanly structures rejections with explicit reject target nodes, staff names with roles, and resubmission routing (`↳ 驳回至: ...` / `↳ 重新提交后由...继续审批`).
- **Mid-Flow Modification Detection**: Identifies mid-flow edits (`已支付 (中途修改)` / `审批通过 (中途修改)`), hoists modification events to top (`✏️: 修改了单据`) for instant fact visibility while strictly preserving genuine approval-flow chronological sequence numbers.
- **Action Emojis**: Visual distinction across approval actions (`✏️` 修改、`🤖` 自动同意、`❌` 驳回、`💰` 支付、`💬` 附言、`↩️` 撤回、`🔀` 转审),while normal approvals maintain a clean text format (`: 同意`).
- **Targeted Document SN Export Filter (`--sn` / `--sns`)**:
- Supported `--sn <SN1,SN2>` or `--sns` option for `seal-use approval-runs export` to filter specific documents by single or comma-separated document SNs.
- Direct indexed lookup via Seal backend `search: sn`, bypassing full pagination scans and reducing export runtimes from 30+ seconds to ~1.5 seconds.
- Smart time windowing: searches across full history without artificial 1-day truncation when start/end dates are omitted, and dynamically computes filename date interval from retrieved records.
- **Strict Clean Export Filenames with Forced Minute Timestamp**:
- Enforced a standard format `${safeCorpName}_审核记录_${dateTag}_${countTag}_${YYYYMMDD_HHmm}.xlsx`.
- Filename timestamp suffix accurate to the minute prevents accidental overwrites and ambiguity.
- Eradicated document SN numbers from the output filename to maintain a concise, standard pattern regardless of export batch size.
- **CLI Help, Guidance & Diagnostics Channel**:
- Enhanced `seal-use approval-runs export --help` with complete option table.
- Added next-step command suggestions (`👉 查看导出文件: open "..."`) and flow enrichment hints to `stderr`.
- Synchronized `skills/seal-use/SKILL.md` and CLI documentation references.
import{createRequireasHS0}from"node:module";var$S0=Object.create;var{getPrototypeOf:IS0,defineProperty:QP,getOwnPropertyNames:zS0}=Object;varqS0=Object.prototype.hasOwnProperty;functionUS0($){returnthis[$]}varYS0,JS0,j4=($,I,z)=>{varq=$!=null&&typeof$==="object";if(q){varU=I?YS0??=newWeakMap:JS0??=newWeakMap,Y=U.get($);if(Y)returnY}z=$!=null?$S0(IS0($)):{};letJ=I||!$||!$.__esModule?QP(z,"default",{value:$,enumerable:!0}):z;for(letQofzS0($))if(!qS0.call(J,Q))QP(J,Q,{get:US0.bind($,Q),enumerable:!0});if(q)U.set($,J);returnJ};varM=($,I)=>()=>(I||$((I={exports:{}}).exports,I),I.exports);varQS0=($)=>$;functionKS0($,I){this[$]=QS0.bind(null,I)}varo8=($,I)=>{for(varzinI)QP($,z,{get:I[z],enumerable:!0,configurable:!0,set:KS0.bind(I,z)})};vare=($,I)=>()=>($&&(I=$($=0)),I);vard=HS0(import.meta.url);functiont($,I,z){functionq(Q,K){if(!Q._zod)Object.defineProperty(Q,"_zod",{value:{def:K,constr:J,traits:newSet},enumerable:!1});if(Q._zod.traits.has($))return;Q._zod.traits.add($),I(Q,K);letH=J.prototype,G=Object.keys(H);for(letZ=0;Z<G.length;Z++){letW=G[Z];if(!(WinQ))Q[W]=H[W].bind(Q)}}letU=z?.Parent??Object;classYextendsU{}Object.defineProperty(Y,"name",{value:$});functionJ(Q){varK;letH=z?.Parent?newY:this;q(H,Q),(K=H._zod).deferred??(K.deferred=[]);for(letGofH._zod.deferred)G();returnH}returnObject.defineProperty(J,"init",{value:q}),Object.defineProperty(J,Symbol.hasInstance,{value:(Q)=>{if(z?.Parent&&Qinstanceofz.Parent)return!0;returnQ?._zod?.traits?.has($)}}),Object.defineProperty(J,"name",{value:$}),J}functionf4($){if($)Object.assign(H2,$);returnH2}varqm,KP,HP,O5,G2,H2;varZ2=e(()=>{KP=Object.freeze({status:"aborted"});HP=Symbol("zod_brand");O5=classO5extendsError{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};G2=classG2extendsError{constructor($){super(`Encountered unidirectional transform during encode: ${$}`);this.name="ZodEncodeError"}};(qm=globalThis).__zod_globalConfig??(qm.__zod_globalConfig={});H2=globalThis.__zod_globalConfig});varM0={};o8(M0,{unwrapMessage:()=>EJ,uint8ArrayToHex:()=>SS0,uint8ArrayToBase64url:()=>hS0,uint8ArrayToBase64:()=>Jm,stringifyPrimitive:()=>w0,slugify:()=>WP,shallowClone:()=>VP,safeExtend:()=>ES0,required:()=>_S0,randomString:()=>MS0,propertyKeyTypes:()=>_J,promiseAllObject:()=>FS0,primitiveTypes:()=>wP,prefixIssues:()=>E8,pick:()=>PS0,partial:()=>CS0,parsedType:()=>O0,optionalKeys:()=>LP,omit:()=>BS0,objectClone:()=>wS0,numKeys:()=>NS0,nullish:()=>L3,normalizeParams:()=>A0,mergeDefs:()=>H9,merge:()=>jS0,jsonStringifyReplacer:()=>Bz,joinValues:()=>Y0,issue:()=>Ez,isPlainObject:()=>F3,isObject:()=>W2,hexToUint8Array:()=>gS0,getSizableOrigin:()=>RJ,getParsedType:()=>DS0,getLengthableOrigin:()=>vJ,getEnumValues:()=>jJ,getElementAtPath:()=>OS0,floatSafeRemainder:()=>ZP,finalizeIssue:()=>K8,extend:()=>TS0,explicitlyAborted:()=>MP,escapeRegex:()=>w$,esc:()=>TW,defineLazy:()=>J1,createTransparentProxy:()=>AS0,cloneDef:()=>LS0,clone:()=>Q8,cleanRegex:()=>CJ,cleanEnum:()=>RS0,captureStackTrace:()=>EW,cached:()=>Tz,base64urlToUint8Array:()=>vS0,base64ToUint8Array:()=>Ym,assignProp:()=>O3,assertNotEqual:()=>ZS0,assertNever:()=>XS0,assertIs:()=>WS0,assertEqual:()=>GS0,assert:()=>VS0,allowsEval:()=>XP,aborted:()=>M3,NUMBER_FORMAT_RANGES:()=>OP,Class:()=>Qm,BIGINT_FORMAT_RANGES:()=>FP});functionGS0($){return$}functionZS0($){return$}functionWS0($){}functionXS0($){throwError("Unexpected value in exhaustive check")}functionVS0($){}functionjJ($){letI=Object.values($).filter((q)=>typeofq==="number");returnObject.entries($).filter(([q,U])=>I.indexOf(+q)===-1).map(([q,U])=>U)}functionY0($,I="|"){return$.map((z)=>w0(z)).join(I)}functionBz($,I){if(typeofI==="bigint")returnI.toString();returnI}functionTz($){return{getvalue(){{letz=$();returnObject.defineProperty(this,"value",{value:z}),z}throwError("cached value already set")}}}functionL3($){return$===null||$===void0}functionCJ($){letI=$.startsWith("^")?1:0,z=$.endsWith("$")?$.length-1:$.length;return$.slice(I,z)}functionZP($,I){letz=$/I,q=Math.round(z),U=Number.EPSILON*Math.max(Math.abs(z),1);if(Math.abs(z-q)<U)return0;returnz-q}functionJ1($,I,z){letq=void0;Object.defineProperty($,I,{get(){if(q===Um)return;if(q===void0)q=Um,q=z();returnq},set(U){Object.defineProperty($,I,{value:U})},configurable:!0})}functionwS0($){returnObject.create(Object.getPrototypeOf($),Object.getOwnPropertyDescriptors($))}functionO3($,I,z){Object.defineProperty($,I,{value:z,writable:!0,enumerable:!0,configurable:!0})}functionH9(...$){letI={};for(letzof$){letq=Object.getOwnPropertyDescriptors(z);Object.assign(I,q)}returnObject.defineProperties({},I)}functionLS0($){returnH9($._zod.def)}functionOS0($,I){if(!I)return$;returnI.reduce((z,q)=>z?.[q],$)}functionFS0($){letI=Object.keys($),z=I.map((q)=>$[q]);returnPromise.all(z).then((q)=>{letU={};for(letY=0;Y<I.length;Y++)U[I[Y]]=q[Y];returnU})}functionMS0($=10){letz=""Line truncated
`)}var Km=($,I)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:I,enumerable:!1}),$.message=JSON.stringify(I,Bz,2),Object.defineProperty($,"toString",{value:()=>$.message,enumerable:!1})},hJ,j8;var AP=e(()=>{Z2();h0();hJ=t("$ZodError",Km),j8=t("$ZodError",Km,{Parent:Error})});var jz=($)=>(I,z,q,U)=>{let Y=q?{...q,async:!1}:{async:!1},J=I._zod.run({value:z,issues:[]},Y);if(J instanceof Promise)throw new O5;if(J.issues.length){let Q=new(U?.Err??$)(J.issues.map((K)=>K8(K,Y,f4())));throw EW(Q,U?.callee),Q}return J.value},yJ,Cz=($)=>async(I,z,q,U)=>{let Y=q?{...q,async:!0}:{async:!0},J=I._zod.run({value:z,issues:[]},Y);if(J instanceof Promise)J=await J;if(J.issues.length){let Q=new(U?.Err??$)(J.issues.map((K)=>K8(K,Y,f4())));throw EW(Q,U?.callee),Q}return J.value},xJ,_z=($)=>(I,z,q)=>{let U=q?{...q,async:!1}:{async:!1},Y=I._zod.run({value:z,issues:[]},U);if(Y instanceof Promise)throw new O5;return Y.issues.length?{success:!1,error:new($??hJ)(Y.issues.map((J)=>K8(J,U,f4())))}:{success:!0,data:Y.value}},Rz,vz=($)=>async(I,z,q)=>{let U=q?{...q,async:!0}:{async:!0},Y=I._zod.run({value:z,issues:[]},U);if(Y instanceof Promise)Y=await Y;return Y.issues.length?{success:!1,error:new $(Y.issues.map((J)=>K8(J,U,f4())))}:{success:!0,data:Y.value}},uJ,jW=($)=>(I,z,q)=>{let U=q?{...q,direction:"backward"}:{direction:"backward"};return jz($)(I,z,U)},Gm,CW=($)=>(I,z,q)=>{return jz($)(I,z,q)},Zm,_W=($)=>async(I,z,q)=>{let U=q?{...q,direction:"backward"}:{direction:"backward"};return Cz($)(I,z,U)},Wm,RW=($)=>async(I,z,q)=>{return Cz($)(I,z,q)},Xm,vW=($)=>(I,z,q)=>{let U=q?{...q,direction:"backward"}:{direction:"backward"};return _z($)(I,z,U)},Vm,hW=($)=>(I,z,q)=>{return _z($)(I,z,q)},wm,gW=($)=>async(I,z,q)=>{let U=q?{...q,direction:"backward"}:{direction:"backward"};return vz($)(I,z,U)},Lm,SW=($)=>async(I,z,q)=>{return vz($)(I,z,q)},Om;var PP=e(()=>{Z2();AP();h0();yJ=jz(j8),xJ=Cz(j8),Rz=_z(j8),uJ=vz(j8),Gm=jW(j8),Zm=CW(j8),Wm=_W(j8),Xm=RW(j8),Vm=vW(j8),wm=hW(j8),Lm=gW(j8),Om=SW(j8)});var r8={};o8(r8,{xid:()=>jP,uuid7:()=>fS0,uuid6:()=>kS0,uuid4:()=>uS0,uuid:()=>X2,uppercase:()=>aP,unicodeEmail:()=>Fm,undefined:()=>sP,ulid:()=>EP,time:()=>cP,string:()=>dP,sha512_hex:()=>Jy0,sha512_base64url:()=>Ky0,sha512_base64:()=>Qy0,sha384_hex:()=>qy0,sha384_base64url:()=>Yy0,sha384_base64:()=>Uy0,sha256_hex:()=>$y0,sha256_base64url:()=>zy0,sha256_base64:()=>Iy0,sha1_hex:()=>tS0,sha1_base64url:()=>eS0,sha1_base64:()=>aS0,rfc5322Email:()=>iS0,number:()=>kJ,null:()=>rP,nanoid:()=>_P,md5_hex:()=>oS0,md5_base64url:()=>sS0,md5_base64:()=>rS0,mac:()=>xP,lowercase:()=>tP,ksuid:()=>CP,ipv6:()=>yP,ipv4:()=>SP,integer:()=>lP,idnEmail:()=>nS0,httpProtocol:()=>bP,html5Email:()=>bS0,hostname:()=>dS0,hex:()=>lS0,guid:()=>vP,extendedDuration:()=>xS0,emoji:()=>gP,email:()=>hP,e164:()=>iP,duration:()=>RP,domain:()=>mS0,datetime:()=>pP,date:()=>nP,cuid2:()=>TP,cuid:()=>BP,cidrv6:()=>kP,cidrv4:()=>uP,browserEmail:()=>cS0,boolean:()=>oP,bigint:()=>mP,base64url:()=>yW,base64:()=>fP});function gP(){return new RegExp(pS0,"u")}function Nm($){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 cP($){return new RegExp(`^${Nm($)}$`)}function pP($){let I=Nm({precision:$.precision}),z=["Z"];if($.local)z.push("");if($.offset)z.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let q=`${I}(?:${z.join("|")})`;return new RegExp(`^${Mm}T(?:${q})$`)}function fJ($,I){return new RegExp(`^[A-Za-z0-9+/]{${$}}${I}$`)}function bJ($){return new RegExp(`^[A-Za-z0-9_-]{${$}}$`)}var BP,TP,EP,jP,CP,_P,RP,xS0,vP,X2=($)=>{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})$`)},uS0,kS0,fS0,hP,bS0,iS0,Fm,nS0,cS0,pS0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",SP,yP,xP=($)=>{letI=w$($??":");returnnewRegExp(`^(?:[0-9A-F]{2}${I}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${I}){5}[0-9a-f]{2}$`)},uP,kP,fP,yW,dS0,mS0,bP,iP,Mm="(?:(?:\\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])))",nP,dP=($)=>{letI=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";returnnewRegExp(`^${I}$`)},mP,lP,kJ,oP,rP,sP,tP,aP,lS0,oS0,rS0,sS0,tS0,aS0,eS0,$y0,Iy0,zy0,qy0,Uy0,Yy0,Jy0,Qy0,Ky0;varxW=e(()=>{h0();BP=/^[cC][0-9a-z]{6,}$/,TP=/^[0-9a-z]+$/,EP=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,jP=/^[0-9a-vA-V]{20}$/,CP=/^[A-Za-z0-9]{27}$/,_P=/^[a-zA-Z0-9_-]{21}$/,RP=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?Line truncated
`).filter((Y)=>Y),q=Math.min(...z.map((Y)=>Y.length-Y.trimStart().length)),U=z.map((Y)=>Y.slice(q)).map((Y)=>" ".repeat(this.indent*2)+Y);for(let Y of U)this.content.push(Y)}compile(){let $=Function,I=this?.args,q=[...(this?.content??[""]).map((U)=>`${U}`)];return new $(...I,q.join(`
`))}}var OB;var FB=e(()=>{OB={major:4,minor:4,patch:3}});function bB($){if($==="")return!0;if(/\s/.test($))return!1;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}function km($){if(!yW.test($))return!1;let I=$.replace(/[-_]/g,(q)=>q==="-"?"+":"/"),z=I.padEnd(Math.ceil(I.length/4)*4,"=");return bB(z)}function fm($,I=null){try{let z=$.split(".");if(z.length!==3)return!1;let[q]=z;if(!q)return!1;let U=JSON.parse(atob(q));if("typ"in U&&U?.typ!=="JWT")return!1;if(!U.alg)return!1;if(I&&(!("alg"in U)||U.alg!==I))return!1;return!0}catch{return!1}}function Bm($,I,z){if($.issues.length)I.issues.push(...E8(z,$.issues));I.value[z]=$.value}function pW($,I,z,q,U,Y){let J=z in q;if($.issues.length){if(U&&Y&&!J)return;I.issues.push(...E8(z,$.issues))}if(!J&&!U){if(!$.issues.length)I.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[z]});return}if($.value===void 0){if(J)I.value[z]=void 0}else I.value[z]=$.value}function bm($){let I=Object.keys($.shape);for(let q of I)if(!$.shape?.[q]?._zod?.traits?.has("$ZodType"))throw Error(`Invalidelementatkey"${q}":expectedaZodschema`);let z=LP($.shape);return{...$,keys:I,keySet:new Set(I),numKeys:I.length,optionalKeys:new Set(z)}}function im($,I,z,q,U,Y){let J=[],Q=U.keySet,K=U.catchall._zod,H=K.def.type,G=K.optin==="optional",Z=K.optout==="optional";for(let W in I){if(W==="__proto__")continue;if(Q.has(W))continue;if(H==="never"){J.push(W);continue}let X=K.run({value:I[W],issues:[]},q);if(X instanceof Promise)$.push(X.then((w)=>pW(w,z,W,I,G,Z)));else pW(X,z,W,I,G,Z)}if(J.length)z.issues.push({code:"unrecognized_keys",keys:J,input:I,inst:Y});if(!$.length)return z;return Promise.all($).then(()=>{return z})}function Tm($,I,z,q){for(let Y of $)if(Y.issues.length===0)return I.value=Y.value,I;let U=$.filter((Y)=>!M3(Y));if(U.length===1)return I.value=U[0].value,U[0];return I.issues.push({code:"invalid_union",input:I.value,inst:z,errors:$.map((Y)=>Y.issues.map((J)=>K8(J,q,f4())))}),I}function Em($,I,z,q){let U=$.filter((Y)=>Y.issues.length===0);if(U.length===1)return I.value=U[0].value,I;if(U.length===0)I.issues.push({code:"invalid_union",input:I.value,inst:z,errors:$.map((Y)=>Y.issues.map((J)=>K8(J,q,f4())))});else I.issues.push({code:"invalid_union",input:I.value,inst:z,errors:[],inclusive:!1});return I}function MB($,I){if($===I)return{valid:!0,data:$};if($ instanceof Date&&I instanceof Date&&+$===+I)return{valid:!0,data:$};if(F3($)&&F3(I)){let z=Object.keys(I),q=Object.keys($).filter((Y)=>z.indexOf(Y)!==-1),U={...$,...I};for(let Y of q){let J=MB($[Y],I[Y]);if(!J.valid)return{valid:!1,mergeErrorPath:[Y,...J.mergeErrorPath]};U[Y]=J.data}return{valid:!0,data:U}}if(Array.isArray($)&&Array.isArray(I)){if($.length!==I.length)return{valid:!1,mergeErrorPath:[]};let z=[];for(let q=0;q<$.length;q++){let U=$[q],Y=I[q],J=MB(U,Y);if(!J.valid)return{valid:!1,mergeErrorPath:[q,...J.mergeErrorPath]};z.push(J.data)}return{valid:!0,data:z}}return{valid:!1,mergeErrorPath:[]}}function jm($,I,z){let q=new Map,U;for(let Q of I.issues)if(Q.code==="unrecognized_keys"){U??(U=Q);for(let K of Q.keys){if(!q.has(K))q.set(K,{});q.get(K).l=!0}}else $.issues.push(Q);for(let Q of z.issues)if(Q.code==="unrecognized_keys")for(let K of Q.keys){if(!q.has(K))q.set(K,{});q.get(K).r=!0}else $.issues.push(Q);let Y=[...q].filter(([,Q])=>Q.l&&Q.r).map(([Q])=>Q);if(Y.length&&U)$.issues.push({...U,keys:Y});if(M3($))return $;let J=MB(I.value,z.value);if(!J.valid)throw Error(`Unmergableintersection.Errorpath:${JSON.stringify(J.mergeErrorPath)}`);return $.value=J.data,$}function Cm($,I){for(let z=$.length-1;z>=0;z--)if($[z]._zod[I]!=="optional")return z+1;return 0}function _m($,I,z){if($.issues.length)I.issues.push(...E8(z,$.issues));I.value[z]=$.value}function Rm($,I,z,q,U){for(let Y=0;Y<z.length;Y++){let J=$[Y],Q=Y<q.length;if(J.issues.length){if(!Q&&Y>=U){I.value.length=Y;break}I.issues.push(...E8(Y,J.issues))}I.value[Y]=J.value}for(let Y=I.value.length-1;Y>=q.length;Y--)if(z[Y]._zod.optout==="optional"&&I.value[Y]===void 0)I.value.length=Y;else break;return I}function vm($,I,z,q,U,Y,J){if($.issues.length)if(_J.has(typeof q))z.issues.push(...E8(q,$.issues));else z.issues.push({code:"invalid_key",origin:"map",input:U,inst:Y,issues:$.issues.map((Q)=>K8(Q,J,f4()))});if(I.issues.length)if(_J.has(typeof q))z.issues.push(...E8(q,I.issues));else z.issues.push({origin:"map",code:"invalid_element",input:U,inst:Y,key:q,issues:I.issues.map((Q)=>K8(Q,J,f4()))});z.value.set($.value,I.value)}function hm($,I){if($.issues.length)I.issues.push(...$.issues);I.value.add($.value)}function gm($,I){if(I===void 0&&($.issues.length||$.fallback))return{issues:[],value:void 0};return $}function Sm($,I){if($.value===void 0)$.value=I.defaultValue;return $}function ym($,I){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:I});return $}function iW($,I,z){if($.issues.length)return $.aborted=!0,$;return I._zod.run({value:$.value,issues:$.issues,fa
Line truncated
if(${A}.issues.length){
import{createRequireassS0}from"node:module";variS0=Object.create;var{getPrototypeOf:nS0,defineProperty:NP,getOwnPropertyNames:cS0}=Object;varpS0=Object.prototype.hasOwnProperty;functiondS0($){returnthis[$]}varmS0,lS0,S4=($,q,Y)=>{varz=$!=null&&typeof$==="object";if(z){varU=q?mS0??=newWeakMap:lS0??=newWeakMap,I=U.get($);if(I)returnI}Y=$!=null?iS0(nS0($)):{};letJ=q||!$||!$.__esModule?NP(Y,"default",{value:$,enumerable:!0}):Y;for(letQofcS0($))if(!pS0.call(J,Q))NP(J,Q,{get:dS0.bind($,Q),enumerable:!0});if(z)U.set($,J);returnJ};varM=($,q)=>()=>(q||$((q={exports:{}}).exports,q),q.exports);varoS0=($)=>$;functionrS0($,q){this[$]=oS0.bind(null,q)}var$$=($,q)=>{for(varYinq)NP($,Y,{get:q[Y],enumerable:!0,configurable:!0,set:rS0.bind(q,Y)})};vare=($,q)=>()=>($&&(q=$($=0)),q);varm=sS0(import.meta.url);functiona($,q,Y){functionz(Q,K){if(!Q._zod)Object.defineProperty(Q,"_zod",{value:{def:K,constr:J,traits:newSet},enumerable:!1});if(Q._zod.traits.has($))return;Q._zod.traits.add($),q(Q,K);letH=J.prototype,G=Object.keys(H);for(letZ=0;Z<G.length;Z++){letV=G[Z];if(!(VinQ))Q[V]=H[V].bind(Q)}}letU=Y?.Parent??Object;classIextendsU{}Object.defineProperty(I,"name",{value:$});functionJ(Q){varK;letH=Y?.Parent?newI:this;z(H,Q),(K=H._zod).deferred??(K.deferred=[]);for(letGofH._zod.deferred)G();returnH}returnObject.defineProperty(J,"init",{value:z}),Object.defineProperty(J,Symbol.hasInstance,{value:(Q)=>{if(Y?.Parent&&QinstanceofY.Parent)return!0;returnQ?._zod?.traits?.has($)}}),Object.defineProperty(J,"name",{value:$}),J}functionm4($){if($)Object.assign(V2,$);returnV2}var_m,DP,AP,B5,w2,V2;varL2=e(()=>{DP=Object.freeze({status:"aborted"});AP=Symbol("zod_brand");B5=classB5extendsError{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};w2=classw2extendsError{constructor($){super(`Encountered unidirectional transform during encode: ${$}`);this.name="ZodEncodeError"}};(_m=globalThis).__zod_globalConfig??(_m.__zod_globalConfig={});V2=globalThis.__zod_globalConfig});varA0={};$$(A0,{unwrapMessage:()=>kJ,uint8ArrayToHex:()=>Dy0,uint8ArrayToBase64url:()=>My0,uint8ArrayToBase64:()=>vm,stringifyPrimitive:()=>O0,slugify:()=>TP,shallowClone:()=>jP,safeExtend:()=>Xy0,required:()=>Ly0,randomString:()=>Jy0,propertyKeyTypes:()=>bJ,promiseAllObject:()=>Iy0,primitiveTypes:()=>_P,prefixIssues:()=>h8,pick:()=>Gy0,partial:()=>wy0,parsedType:()=>N0,optionalKeys:()=>CP,omit:()=>Zy0,objectClone:()=>Yy0,numKeys:()=>Qy0,nullish:()=>P3,normalizeParams:()=>B0,mergeDefs:()=>F9,merge:()=>Vy0,jsonStringifyReplacer:()=>RY,joinValues:()=>I0,issue:()=>hY,isPlainObject:()=>T3,isObject:()=>F2,hexToUint8Array:()=>Ny0,getSizableOrigin:()=>iJ,getParsedType:()=>Ky0,getLengthableOrigin:()=>nJ,getEnumValues:()=>uJ,getElementAtPath:()=>Uy0,floatSafeRemainder:()=>BP,finalizeIssue:()=>w8,extend:()=>Wy0,explicitlyAborted:()=>hP,escapeRegex:()=>O$,esc:()=>xW,defineLazy:()=>H1,createTransparentProxy:()=>Hy0,cloneDef:()=>zy0,clone:()=>V8,cleanRegex:()=>fJ,cleanEnum:()=>Fy0,captureStackTrace:()=>kW,cached:()=>vY,base64urlToUint8Array:()=>Oy0,base64ToUint8Array:()=>Rm,assignProp:()=>B3,assertNotEqual:()=>aS0,assertNever:()=>$y0,assertIs:()=>eS0,assertEqual:()=>tS0,assert:()=>qy0,allowsEval:()=>EP,aborted:()=>E3,NUMBER_FORMAT_RANGES:()=>RP,Class:()=>hm,BIGINT_FORMAT_RANGES:()=>vP});functiontS0($){return$}functionaS0($){return$}functioneS0($){}function$y0($){throwError("Unexpected value in exhaustive check")}functionqy0($){}functionuJ($){letq=Object.values($).filter((z)=>typeofz==="number");returnObject.entries($).filter(([z,U])=>q.indexOf(+z)===-1).map(([z,U])=>U)}functionI0($,q="|"){return$.map((Y)=>O0(Y)).join(q)}functionRY($,q){if(typeofq==="bigint")returnq.toString();returnq}functionvY($){return{getvalue(){{letY=$();returnObject.defineProperty(this,"value",{value:Y}),Y}throwError("cached value already set")}}}functionP3($){return$===null||$===void0}functionfJ($){letq=$.startsWith("^")?1:0,Y=$.endsWith("$")?$.length-1:$.length;return$.slice(q,Y)}functionBP($,q){letY=$/q,z=Math.round(Y),U=Number.EPSILON*Math.max(Math.abs(Y),1);if(Math.abs(Y-z)<U)return0;returnY-z}functionH1($,q,Y){letz=void0;Object.defineProperty($,q,{get(){if(z===Cm)return;if(z===void0)z=Cm,z=Y();returnz},set(U){Object.defineProperty($,q,{value:U})},configurable:!0})}functionYy0($){returnObject.create(Object.getPrototypeOf($),Object.getOwnPropertyDescriptors($))}functionB3($,q,Y){Object.defineProperty($,q,{value:Y,writable:!0,enumerable:!0,configurable:!0})}functionF9(...$){letq={};for(letYof$){letz=Object.getOwnPropertyDescriptors(Y);Object.assign(q,z)}returnObject.defineProperties({},q)}functionzy0($){returnF9($._zod.def)}functionUy0($,q){if(!q)return$;returnq.reduce((Y,z)=>Y?.[z],$)}functionIy0($){letq=Object.keys($),Y=q.map((z)=>$[z]);returnPromise.all(Y).then((z)=>{letU={};for(letI=0;I<q.length;I++)U[q[I]]=z[I];returnU})}functionJy0($=10){letY=""Line truncated
`)}var gm=($,q)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:q,enumerable:!1}),$.message=JSON.stringify(q,RY,2),Object.defineProperty($,"toString",{value:()=>$.message,enumerable:!1})},cJ,g8;var yP=e(()=>{L2();y0();cJ=a("$ZodError",gm),g8=a("$ZodError",gm,{Parent:Error})});var gY=($)=>(q,Y,z,U)=>{let I=z?{...z,async:!1}:{async:!1},J=q._zod.run({value:Y,issues:[]},I);if(J instanceof Promise)throw new B5;if(J.issues.length){let Q=new(U?.Err??$)(J.issues.map((K)=>w8(K,I,m4())));throw kW(Q,U?.callee),Q}return J.value},mJ,SY=($)=>async(q,Y,z,U)=>{let I=z?{...z,async:!0}:{async:!0},J=q._zod.run({value:Y,issues:[]},I);if(J instanceof Promise)J=await J;if(J.issues.length){let Q=new(U?.Err??$)(J.issues.map((K)=>w8(K,I,m4())));throw kW(Q,U?.callee),Q}return J.value},lJ,yY=($)=>(q,Y,z)=>{let U=z?{...z,async:!1}:{async:!1},I=q._zod.run({value:Y,issues:[]},U);if(I instanceof Promise)throw new B5;return I.issues.length?{success:!1,error:new($??cJ)(I.issues.map((J)=>w8(J,U,m4())))}:{success:!0,data:I.value}},xY,kY=($)=>async(q,Y,z)=>{let U=z?{...z,async:!0}:{async:!0},I=q._zod.run({value:Y,issues:[]},U);if(I instanceof Promise)I=await I;return I.issues.length?{success:!1,error:new $(I.issues.map((J)=>w8(J,U,m4())))}:{success:!0,data:I.value}},oJ,uW=($)=>(q,Y,z)=>{let U=z?{...z,direction:"backward"}:{direction:"backward"};return gY($)(q,Y,U)},ym,fW=($)=>(q,Y,z)=>{return gY($)(q,Y,z)},xm,bW=($)=>async(q,Y,z)=>{let U=z?{...z,direction:"backward"}:{direction:"backward"};return SY($)(q,Y,U)},km,iW=($)=>async(q,Y,z)=>{return SY($)(q,Y,z)},um,nW=($)=>(q,Y,z)=>{let U=z?{...z,direction:"backward"}:{direction:"backward"};return yY($)(q,Y,U)},fm,cW=($)=>(q,Y,z)=>{return yY($)(q,Y,z)},bm,pW=($)=>async(q,Y,z)=>{let U=z?{...z,direction:"backward"}:{direction:"backward"};return kY($)(q,Y,U)},im,dW=($)=>async(q,Y,z)=>{return kY($)(q,Y,z)},nm;var xP=e(()=>{L2();yP();y0();mJ=gY(g8),lJ=SY(g8),xY=yY(g8),oJ=kY(g8),ym=uW(g8),xm=fW(g8),km=bW(g8),um=iW(g8),fm=nW(g8),bm=cW(g8),im=pW(g8),nm=dW(g8)});var q$={};$$(q$,{xid:()=>bP,uuid7:()=>Ey0,uuid6:()=>Ty0,uuid4:()=>By0,uuid:()=>O2,uppercase:()=>ZB,unicodeEmail:()=>cm,undefined:()=>HB,ulid:()=>fP,time:()=>YB,string:()=>UB,sha512_hex:()=>ly0,sha512_base64url:()=>ry0,sha512_base64:()=>oy0,sha384_hex:()=>py0,sha384_base64url:()=>my0,sha384_base64:()=>dy0,sha256_hex:()=>iy0,sha256_base64url:()=>cy0,sha256_base64:()=>ny0,sha1_hex:()=>uy0,sha1_base64url:()=>by0,sha1_base64:()=>fy0,rfc5322Email:()=>_y0,number:()=>rJ,null:()=>KB,nanoid:()=>nP,md5_hex:()=>yy0,md5_base64url:()=>ky0,md5_base64:()=>xy0,mac:()=>rP,lowercase:()=>GB,ksuid:()=>iP,ipv6:()=>oP,ipv4:()=>lP,integer:()=>JB,idnEmail:()=>Cy0,httpProtocol:()=>eP,html5Email:()=>jy0,hostname:()=>hy0,hex:()=>Sy0,guid:()=>pP,extendedDuration:()=>Py0,emoji:()=>mP,email:()=>dP,e164:()=>$B,duration:()=>cP,domain:()=>gy0,datetime:()=>zB,date:()=>qB,cuid2:()=>uP,cuid:()=>kP,cidrv6:()=>tP,cidrv4:()=>sP,browserEmail:()=>Ry0,boolean:()=>QB,bigint:()=>IB,base64url:()=>mW,base64:()=>aP});function mP(){return new RegExp(vy0,"u")}function dm($){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 YB($){return new RegExp(`^${dm($)}$`)}function zB($){let q=dm({precision:$.precision}),Y=["Z"];if($.local)Y.push("");if($.offset)Y.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let z=`${q}(?:${Y.join("|")})`;return new RegExp(`^${pm}T(?:${z})$`)}function sJ($,q){return new RegExp(`^[A-Za-z0-9+/]{${$}}${q}$`)}function tJ($){return new RegExp(`^[A-Za-z0-9_-]{${$}}$`)}var kP,uP,fP,bP,iP,nP,cP,Py0,pP,O2=($)=>{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})$`)},By0,Ty0,Ey0,dP,jy0,_y0,cm,Cy0,Ry0,vy0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",lP,oP,rP=($)=>{letq=O$($??":");returnnewRegExp(`^(?:[0-9A-F]{2}${q}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${q}){5}[0-9a-f]{2}$`)},sP,tP,aP,mW,hy0,gy0,eP,$B,pm="(?:(?:\\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])))",qB,UB=($)=>{letq=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";returnnewRegExp(`^${q}$`)},IB,JB,rJ,QB,KB,HB,GB,ZB,Sy0,yy0,xy0,ky0,uy0,fy0,by0,iy0,ny0,cy0,py0,dy0,my0,ly0,oy0,ry0;varlW=e(()=>{y0();kP=/^[cC][0-9a-z]{6,}$/,uP=/^[0-9a-z]+$/,fP=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,bP=/^[0-9a-vA-V]{20}$/,iP=/^[A-Za-z0-9]{27}$/,nP=/^[a-zA-Z0-9_-]{21}$/,cP=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?Line truncated
`).filter((I)=>I),z=Math.min(...Y.map((I)=>I.length-I.trimStart().length)),U=Y.map((I)=>I.slice(z)).map((I)=>" ".repeat(this.indent*2)+I);for(let I of U)this.content.push(I)}compile(){let $=Function,q=this?.args,z=[...(this?.content??[""]).map((U)=>`${U}`)];return new $(...q,z.join(`
`))}}var RB;var vB=e(()=>{RB={major:4,minor:4,patch:3}});function eB($){if($==="")return!0;if(/\s/.test($))return!1;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}function Hl($){if(!mW.test($))return!1;let q=$.replace(/[-_]/g,(z)=>z==="-"?"+":"/"),Y=q.padEnd(Math.ceil(q.length/4)*4,"=");return eB(Y)}function Gl($,q=null){try{let Y=$.split(".");if(Y.length!==3)return!1;let[z]=Y;if(!z)return!1;let U=JSON.parse(atob(z));if("typ"in U&&U?.typ!=="JWT")return!1;if(!U.alg)return!1;if(q&&(!("alg"in U)||U.alg!==q))return!1;return!0}catch{return!1}}function rm($,q,Y){if($.issues.length)q.issues.push(...h8(Y,$.issues));q.value[Y]=$.value}function qX($,q,Y,z,U,I){let J=Y in z;if($.issues.length){if(U&&I&&!J)return;q.issues.push(...h8(Y,$.issues))}if(!J&&!U){if(!$.issues.length)q.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[Y]});return}if($.value===void 0){if(J)q.value[Y]=void 0}else q.value[Y]=$.value}function Zl($){let q=Object.keys($.shape);for(let z of q)if(!$.shape?.[z]?._zod?.traits?.has("$ZodType"))throw Error(`Invalidelementatkey"${z}":expectedaZodschema`);let Y=CP($.shape);return{...$,keys:q,keySet:new Set(q),numKeys:q.length,optionalKeys:new Set(Y)}}function Wl($,q,Y,z,U,I){let J=[],Q=U.keySet,K=U.catchall._zod,H=K.def.type,G=K.optin==="optional",Z=K.optout==="optional";for(let V in q){if(V==="__proto__")continue;if(Q.has(V))continue;if(H==="never"){J.push(V);continue}let X=K.run({value:q[V],issues:[]},z);if(X instanceof Promise)$.push(X.then((w)=>qX(w,Y,V,q,G,Z)));else qX(X,Y,V,q,G,Z)}if(J.length)Y.issues.push({code:"unrecognized_keys",keys:J,input:q,inst:I});if(!$.length)return Y;return Promise.all($).then(()=>{return Y})}function sm($,q,Y,z){for(let I of $)if(I.issues.length===0)return q.value=I.value,q;let U=$.filter((I)=>!E3(I));if(U.length===1)return q.value=U[0].value,U[0];return q.issues.push({code:"invalid_union",input:q.value,inst:Y,errors:$.map((I)=>I.issues.map((J)=>w8(J,z,m4())))}),q}function tm($,q,Y,z){let U=$.filter((I)=>I.issues.length===0);if(U.length===1)return q.value=U[0].value,q;if(U.length===0)q.issues.push({code:"invalid_union",input:q.value,inst:Y,errors:$.map((I)=>I.issues.map((J)=>w8(J,z,m4())))});else q.issues.push({code:"invalid_union",input:q.value,inst:Y,errors:[],inclusive:!1});return q}function hB($,q){if($===q)return{valid:!0,data:$};if($ instanceof Date&&q instanceof Date&&+$===+q)return{valid:!0,data:$};if(T3($)&&T3(q)){let Y=Object.keys(q),z=Object.keys($).filter((I)=>Y.indexOf(I)!==-1),U={...$,...q};for(let I of z){let J=hB($[I],q[I]);if(!J.valid)return{valid:!1,mergeErrorPath:[I,...J.mergeErrorPath]};U[I]=J.data}return{valid:!0,data:U}}if(Array.isArray($)&&Array.isArray(q)){if($.length!==q.length)return{valid:!1,mergeErrorPath:[]};let Y=[];for(let z=0;z<$.length;z++){let U=$[z],I=q[z],J=hB(U,I);if(!J.valid)return{valid:!1,mergeErrorPath:[z,...J.mergeErrorPath]};Y.push(J.data)}return{valid:!0,data:Y}}return{valid:!1,mergeErrorPath:[]}}function am($,q,Y){let z=new Map,U;for(let Q of q.issues)if(Q.code==="unrecognized_keys"){U??(U=Q);for(let K of Q.keys){if(!z.has(K))z.set(K,{});z.get(K).l=!0}}else $.issues.push(Q);for(let Q of Y.issues)if(Q.code==="unrecognized_keys")for(let K of Q.keys){if(!z.has(K))z.set(K,{});z.get(K).r=!0}else $.issues.push(Q);let I=[...z].filter(([,Q])=>Q.l&&Q.r).map(([Q])=>Q);if(I.length&&U)$.issues.push({...U,keys:I});if(E3($))return $;let J=hB(q.value,Y.value);if(!J.valid)throw Error(`Unmergableintersection.Errorpath:${JSON.stringify(J.mergeErrorPath)}`);return $.value=J.data,$}function em($,q){for(let Y=$.length-1;Y>=0;Y--)if($[Y]._zod[q]!=="optional")return Y+1;return 0}function $l($,q,Y){if($.issues.length)q.issues.push(...h8(Y,$.issues));q.value[Y]=$.value}function ql($,q,Y,z,U){for(let I=0;I<Y.length;I++){let J=$[I],Q=I<z.length;if(J.issues.length){if(!Q&&I>=U){q.value.length=I;break}q.issues.push(...h8(I,J.issues))}q.value[I]=J.value}for(let I=q.value.length-1;I>=z.length;I--)if(Y[I]._zod.optout==="optional"&&q.value[I]===void 0)q.value.length=I;else break;return q}function Yl($,q,Y,z,U,I,J){if($.issues.length)if(bJ.has(typeof z))Y.issues.push(...h8(z,$.issues));else Y.issues.push({code:"invalid_key",origin:"map",input:U,inst:I,issues:$.issues.map((Q)=>w8(Q,J,m4()))});if(q.issues.length)if(bJ.has(typeof z))Y.issues.push(...h8(z,q.issues));else Y.issues.push({origin:"map",code:"invalid_element",input:U,inst:I,key:z,issues:q.issues.map((Q)=>w8(Q,J,m4()))});Y.value.set($.value,q.value)}function zl($,q){if($.issues.length)q.issues.push(...$.issues);q.value.add($.value)}function Ul($,q){if(q===void 0&&($.issues.length||$.fallback))return{issues:[],value:void 0};return $}function Il($,q){if($.value===void 0)$.value=q.defaultValue;return $}function Jl($,q){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:q});return $}function aW($,q,Y){if($.issues.length)return $.aborted=!0,$;return q._zod.run({value:$.value,issues:$.issues,fa
Line truncated
`)}X.write("payload.value = newResult;"),X.write("return payload;");let D=X.compile();return(P,A)=>D(W,P,A)},Y,J=W2,Q=!H2.jitless,H=Q&&XP.value,G=I.catchall,Z;$._zod.parse=(W,X)=>{Z??(Z=q.value);let w=W.value;if(!J(w))return W.issues.push({expected:"object",code:"invalid_type",input:w,inst:$}),W;if(Q&&H&&X?.async===!1&&X.jitless!==!0){if(!Y)Y=U(I.shape);if(W=Y(W,X),!G)return W;return im([],w,W,X,Z,$)}return z(W,X)}});nJ=t("$ZodUnion",($,I)=>{m0.init($,I),J1($._zod,"optin",()=>I.options.some((q)=>q._zod.optin==="optional")?"optional":void 0),J1($._zod,"optout",()=>I.options.some((q)=>q._zod.optout==="optional")?"optional":void 0),J1($._zod,"values",()=>{if(I.options.every((q)=>q._zod.values))return new Set(I.options.flatMap((q)=>Array.from(q._zod.values)));return}),J1($._zod,"pattern",()=>{if(I.options.every((q)=>q._zod.pattern)){let q=I.options.map((U)=>U._zod.pattern);return new RegExp(`^(${q.map((U)=>CJ(U.source)).join("|")})$`)}return});let z=I.options.length===1?I.options[0]._zod.run:null;$._zod.parse=(q,U)=>{if(z)return z(q,U);let Y=!1,J=[];for(let Q of I.options){let K=Q._zod.run({value:q.value,issues:[]},U);if(K instanceof Promise)J.push(K),Y=!0;else{if(K.issues.length===0)return K;J.push(K)}}if(!Y)return Tm(J,q,$,U);return Promise.all(J).then((Q)=>{return Tm(Q,q,$,U)})}});UT=t("$ZodXor",($,I)=>{nJ.init($,I),I.inclusive=!1;let z=I.options.length===1?I.options[0]._zod.run:null;$._zod.parse=(q,U)=>{if(z)return z(q,U);let Y=!1,J=[];for(let Q of I.options){let K=Q._zod.run({value:q.value,issues:[]},U);if(K instanceof Promise)J.push(K),Y=!0;else J.push(K)}if(!Y)return Em(J,q,$,U);return Promise.all(J).then((Q)=>{return Em(Q,q,$,U)})}}),YT=t("$ZodDiscriminatedUnion",($,I)=>{I.inclusive=!1,nJ.init($,I);let z=$._zod.parse;J1($._zod,"propValues",()=>{let U={};for(let Y of I.options){let J=Y._zod.propValues;if(!J||Object.keys(J).length===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${I.options.indexOf(Y)}"`);for(let[Q,K]of Object.entries(J)){if(!U[Q])U[Q]=new Set;for(let H of K)U[Q].add(H)}}return U});let q=Tz(()=>{let U=I.options,Y=new Map;for(let J of U){let Q=J._zod.propValues?.[I.discriminator];if(!Q||Q.size===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${I.options.indexOf(J)}"`);for(let K of Q){if(Y.has(K))throw Error(`Duplicatediscriminatorvalue"${String(K)}"`);Y.set(K,J)}}return Y});$._zod.parse=(U,Y)=>{let J=U.value;if(!W2(J))return U.issues.push({code:"invalid_type",expected:"object",input:J,inst:$}),U;let Q=q.value.get(J?.[I.discriminator]);if(Q)return Q._zod.run(U,Y);if(I.unionFallback||Y.direction==="backward")return z(U,Y);return U.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:I.discriminator,options:Array.from(q.value.keys()),input:J,path:[I.discriminator],inst:$}),U}}),JT=t("$ZodIntersection",($,I)=>{m0.init($,I),$._zod.parse=(z,q)=>{let U=z.value,Y=I.left._zod.run({value:U,issues:[]},q),J=I.right._zod.run({value:U,issues:[]},q);if(Y instanceof Promise||J instanceof Promise)return Promise.all([Y,J]).then(([K,H])=>{return jm(z,K,H)});return jm(z,Y,J)}});lW=t("$ZodTuple",($,I)=>{m0.init($,I);let z=I.items;$._zod.parse=(q,U)=>{let Y=q.value;if(!Array.isArray(Y))return q.issues.push({input:Y,inst:$,expected:"tuple",code:"invalid_type"}),q;q.value=[];let J=[],Q=Cm(z,"optin"),K=Cm(z,"optout");if(!I.rest){if(Y.length<Q)return q.issues.push({code:"too_small",minimum:Q,inclusive:!0,input:Y,inst:$,origin:"array"}),q;if(Y.length>z.length)q.issues.push({code:"too_big",maximum:z.length,inclusive:!0,input:Y,inst:$,origin:"array"})}let H=Array(z.length);for(let G=0;G<z.length;G++){let Z=z[G]._zod.run({value:Y[G],issues:[]},U);if(Z instanceof Promise)J.push(Z.then((W)=>{H[G]=W}));else H[G]=Z}if(I.rest){let G=z.length-1,Z=Y.slice(z.length);for(let W of Z){G++;let X=I.rest._zod.run({value:W,issues:[]},U);if(X instanceof Promise)J.push(X.then((w)=>_m(w,q,G)));else _m(X,q,G)}}if(J.length)return Promise.all(J).then(()=>Rm(H,q,z,Y,K));return Rm(H,q,z,Y,K)}});QT=t("$ZodRecord",($,I)=>{m0.init($,I),$._zod.parse=(z,q)=>{let U=z.value;if(!F3(U))return z.issues.push({expected:"record",code:"invalid_type",input:U,inst:$}),z;let Y=[],J=I.keyType._zod.values;if(J){z.value={};let Q=new Set;for(let H of J)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){Q.add(typeof H==="number"?H.toString():H);let G=I.keyType._zod.run({value:H,issues:[]},q);if(G instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(G.issues.length){z.issues.push({code:"invalid_key",origin:"record",issues:G.issues.map((X)=>K8(X,q,f4())),input:H,path:[H],inst:$});continue}let Z=G.value,W=I.valueType._zod.run({value:U[H],issues:[]},q);if(W instanceof Promise)Y.push(W.then((X)=>{if(X.issues.length)z.issues.push(...E8(H,X.issues));z.value[Z]=X.value}));else{if(W.issues.length)z.issues.push(...E8(H,W.issues));z.value[Z]=W.value}}let K;for(let H in U)if(!Q.has(H))K=K??[],K.push(H);if(K&&K.length>0)z.issues.push({code:"unrecognize
Line truncated
`)}X.write("payload.value = newResult;"),X.write("return payload;");let A=X.compile();return(B,P)=>A(V,B,P)},I,J=F2,Q=!V2.jitless,H=Q&&EP.value,G=q.catchall,Z;$._zod.parse=(V,X)=>{Z??(Z=z.value);let w=V.value;if(!J(w))return V.issues.push({expected:"object",code:"invalid_type",input:w,inst:$}),V;if(Q&&H&&X?.async===!1&&X.jitless!==!0){if(!I)I=U(q.shape);if(V=I(V,X),!G)return V;return Wl([],w,V,X,Z,$)}return Y(V,X)}});eJ=a("$ZodUnion",($,q)=>{s0.init($,q),H1($._zod,"optin",()=>q.options.some((z)=>z._zod.optin==="optional")?"optional":void 0),H1($._zod,"optout",()=>q.options.some((z)=>z._zod.optout==="optional")?"optional":void 0),H1($._zod,"values",()=>{if(q.options.every((z)=>z._zod.values))return new Set(q.options.flatMap((z)=>Array.from(z._zod.values)));return}),H1($._zod,"pattern",()=>{if(q.options.every((z)=>z._zod.pattern)){let z=q.options.map((U)=>U._zod.pattern);return new RegExp(`^(${z.map((U)=>fJ(U.source)).join("|")})$`)}return});let Y=q.options.length===1?q.options[0]._zod.run:null;$._zod.parse=(z,U)=>{if(Y)return Y(z,U);let I=!1,J=[];for(let Q of q.options){let K=Q._zod.run({value:z.value,issues:[]},U);if(K instanceof Promise)J.push(K),I=!0;else{if(K.issues.length===0)return K;J.push(K)}}if(!I)return sm(J,z,$,U);return Promise.all(J).then((Q)=>{return sm(Q,z,$,U)})}});FT=a("$ZodXor",($,q)=>{eJ.init($,q),q.inclusive=!1;let Y=q.options.length===1?q.options[0]._zod.run:null;$._zod.parse=(z,U)=>{if(Y)return Y(z,U);let I=!1,J=[];for(let Q of q.options){let K=Q._zod.run({value:z.value,issues:[]},U);if(K instanceof Promise)J.push(K),I=!0;else J.push(K)}if(!I)return tm(J,z,$,U);return Promise.all(J).then((Q)=>{return tm(Q,z,$,U)})}}),OT=a("$ZodDiscriminatedUnion",($,q)=>{q.inclusive=!1,eJ.init($,q);let Y=$._zod.parse;H1($._zod,"propValues",()=>{let U={};for(let I of q.options){let J=I._zod.propValues;if(!J||Object.keys(J).length===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${q.options.indexOf(I)}"`);for(let[Q,K]of Object.entries(J)){if(!U[Q])U[Q]=new Set;for(let H of K)U[Q].add(H)}}return U});let z=vY(()=>{let U=q.options,I=new Map;for(let J of U){let Q=J._zod.propValues?.[q.discriminator];if(!Q||Q.size===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${q.options.indexOf(J)}"`);for(let K of Q){if(I.has(K))throw Error(`Duplicatediscriminatorvalue"${String(K)}"`);I.set(K,J)}}return I});$._zod.parse=(U,I)=>{let J=U.value;if(!F2(J))return U.issues.push({code:"invalid_type",expected:"object",input:J,inst:$}),U;let Q=z.value.get(J?.[q.discriminator]);if(Q)return Q._zod.run(U,I);if(q.unionFallback||I.direction==="backward")return Y(U,I);return U.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:q.discriminator,options:Array.from(z.value.keys()),input:J,path:[q.discriminator],inst:$}),U}}),MT=a("$ZodIntersection",($,q)=>{s0.init($,q),$._zod.parse=(Y,z)=>{let U=Y.value,I=q.left._zod.run({value:U,issues:[]},z),J=q.right._zod.run({value:U,issues:[]},z);if(I instanceof Promise||J instanceof Promise)return Promise.all([I,J]).then(([K,H])=>{return am(Y,K,H)});return am(Y,I,J)}});UX=a("$ZodTuple",($,q)=>{s0.init($,q);let Y=q.items;$._zod.parse=(z,U)=>{let I=z.value;if(!Array.isArray(I))return z.issues.push({input:I,inst:$,expected:"tuple",code:"invalid_type"}),z;z.value=[];let J=[],Q=em(Y,"optin"),K=em(Y,"optout");if(!q.rest){if(I.length<Q)return z.issues.push({code:"too_small",minimum:Q,inclusive:!0,input:I,inst:$,origin:"array"}),z;if(I.length>Y.length)z.issues.push({code:"too_big",maximum:Y.length,inclusive:!0,input:I,inst:$,origin:"array"})}let H=Array(Y.length);for(let G=0;G<Y.length;G++){let Z=Y[G]._zod.run({value:I[G],issues:[]},U);if(Z instanceof Promise)J.push(Z.then((V)=>{H[G]=V}));else H[G]=Z}if(q.rest){let G=Y.length-1,Z=I.slice(Y.length);for(let V of Z){G++;let X=q.rest._zod.run({value:V,issues:[]},U);if(X instanceof Promise)J.push(X.then((w)=>$l(w,z,G)));else $l(X,z,G)}}if(J.length)return Promise.all(J).then(()=>ql(H,z,Y,I,K));return ql(H,z,Y,I,K)}});NT=a("$ZodRecord",($,q)=>{s0.init($,q),$._zod.parse=(Y,z)=>{let U=Y.value;if(!T3(U))return Y.issues.push({expected:"record",code:"invalid_type",input:U,inst:$}),Y;let I=[],J=q.keyType._zod.values;if(J){Y.value={};let Q=new Set;for(let H of J)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){Q.add(typeof H==="number"?H.toString():H);let G=q.keyType._zod.run({value:H,issues:[]},z);if(G instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(G.issues.length){Y.issues.push({code:"invalid_key",origin:"record",issues:G.issues.map((X)=>w8(X,z,m4())),input:H,path:[H],inst:$});continue}let Z=G.value,V=q.valueType._zod.run({value:U[H],issues:[]},z);if(V instanceof Promise)I.push(V.then((X)=>{if(X.issues.length)Y.issues.push(...h8(H,X.issues));Y.value[Z]=X.value}));else{if(V.issues.length)Y.issues.push(...h8(H,V.issues));Y.value[Z]=V.value}}let K;for(let H in U)if(!Q.has(H))K=K??[],K.push(H);if(K&&K.length>0)Y.issues.push({code:"unrecognize
Line truncated
Setthe\`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(letJof$.seen.entries()){letQ=J[1];if(I===J[0]){Y(J);continue}if($.external){letH=$.external.registry.get(J[0])?.id;if(I!==J[0]&&H){Y(J);continue}}if($.metadataRegistry.get(J[0])?.id){Y(J);continue}if(Q.cycle){Y(J);continue}if(Q.count>1){if($.reused==="ref"){Y(J);continue}}}}functionB3($,I){letz=$.seen.get(I);if(!z)throwError("Unprocessed schema. This is a bug in Zod.");letq=(Q)=>{letK=$.seen.get(Q);if(K.ref===null)return;letH=K.def??K.schema,G={...H},Z=K.ref;if(K.ref=null,Z){q(Z);letX=$.seen.get(Z),w=X.schema;if(w.$ref&&($.target==="draft-07"||$.target==="draft-04"||$.target==="openapi-3.0"))H.allOf=H.allOf??[],H.allOf.push(w);elseObject.assign(H,w);if(Object.assign(H,G),Q._zod.parent===Z)for(letOinH){if(O==="$ref"||O==="allOf")continue;if(!(OinG))deleteH[O]}if(w.$ref&&X.def)for(letOinH){if(O==="$ref"||O==="allOf")continue;if(OinX.def&&JSON.stringify(H[O])===JSON.stringify(X.def[O]))deleteH[O]}}letW=Q._zod.parent;if(W&&W!==Z){q(W);letX=$.seen.get(W);if(X?.schema.$ref){if(H.$ref=X.schema.$ref,X.def)for(letwinH){if(w==="$ref"||w==="allOf")continue;if(winX.def&&JSON.stringify(H[w])===JSON.stringify(X.def[w]))deleteH[w]}}}$.override({zodSchema:Q,jsonSchema:H,path:K.path??[]})};for(letQof[...$.seen.entries()].reverse())q(Q[0]);letU={};if($.target==="draft-2020-12")U.$schema="https://json-schema.org/draft/2020-12/schema";elseif($.target==="draft-07")U.$schema="http://json-schema.org/draft-07/schema#";elseif($.target==="draft-04")U.$schema="http://json-schema.org/draft-04/schema#";elseif($.target==="openapi-3.0");if($.external?.uri){letQ=$.external.registry.get(I)?.id;if(!Q)throwError("Schema is missing an `id` property");U.$id=$.external.uri(Q)}Object.assign(U,z.def??z.schema);letY=$.metadataRegistry.get(I)?.id;if(Y!==void0&&U.id===Y)deleteU.id;letJ=$.external?.defs??{};for(letQof$.seen.entries()){letK=Q[1];if(K.def&&K.defId){if(K.def.id===K.defId)deleteK.def.id;J[K.defId]=K.def}}if($.external);elseif(Object.keys(J).length>0)if($.target==="draft-2020-12")U.$defs=J;elseU.definitions=J;try{letQ=JSON.parse(JSON.stringify(U));returnObject.defineProperty(Q,"~standard",{value:{...I["~standard"],jsonSchema:{input:lz(I,"input",$.processors),output:lz(I,"output",$.processors)}},enumerable:!1,writable:!1}),Q}catch(Q){throwError("Error converting schema to JSON.")}}functionG8($,I){letz=I??{seen:newSet};if(z.seen.has($))return!1;z.seen.add($);letq=$._zod.def;if(q.type==="transform")return!0;if(q.type==="array")returnG8(q.element,z);if(q.type==="set")returnG8(q.valueType,z);if(q.type==="lazy")returnG8(q.getter(),z);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,z);if(q.type==="intersection")returnG8(q.left,z)||G8(q.right,z);if(q.type==="record"||q.type==="map")returnG8(q.keyType,z)||G8(q.valueType,z);if(q.type==="pipe"){if($._zod.traits.has("$ZodCodec"))return!0;returnG8(q.in,z)||G8(q.out,z)}if(q.type==="object"){for(letUinq.shape)if(G8(q.shape[U],z))return!0;return!1}if(q.type==="union"){for(letUofq.options)if(G8(U,z))return!0;return!1}if(q.type==="tuple"){for(letUofq.items)if(G8(U,z))return!0;if(q.rest&&G8(q.rest,z))return!0;return!1}return!1}varOj=($,I={})=>(z)=>{letq=A3({...z,processors:I});returnc1($,q),P3(q,$),B3(q,$)},lz=($,I,z={})=>(q)=>{let{libraryOptions:U,target:Y}=q??{},J=A3({...U??{},target:Y,io:I,processors:z});returnc1($,J),P3(J,$),B3(J,$)};varaJ=e(()=>{rJ()});functionTX($,I){if("_idmap"in$){letq=$,U=A3({...I,processors:AX}),Y={};for(letKofq._idmap.entries()){let[H,G]=K;c1(G,U)}letJ={},Q={registry:q,uri:I?.uri,defs:Y};U.external=Q;for(letKofq._idmap.entries()){let[H,G]=K;P3(U,G),J[H]=B3(U,G)}if(Object.keys(Y).length>0){letK=U.target==="draft-2020-12"?"$defs":"definitions";J.__shared={[K]:Y}}return{schemas:J}}letz=A3({...I,processors:AX});returnc1($,z),P3(z,$),B3(z,$)}varRx0,Fj=($,I,z,q)=>{letU=z;U.type="string";let{minimum:Y,maximum:J,format:Q,patterns:K,contentEncoding:H}=$._zod.bag;if(typeofY==="number")U.minLength=Y;if(typeofJ==="number")U.maxLength=J;if(Q){if(U.format=Rx0[Q]??Q,U.format==="")deleteU.format;if(Q==="time")deleteU.format}if(H)U.contentEncoding=H;if(K&&K.size>0){letG=[...K];if(G.length===1)U.pattern=G[0].source;elseif(G.length>1)U.allOf=[...G.map((Z)=>({...I.target==="draft-07"||I.target==="draft-04"||I.target==="openapi-3.0"?{type:"string"}:{},pattern:Z.source}))]}},Mj=($,I,z,q)=>{letU=z,{minimum:Y,maximum:J,format:Q,multipleOf:K,exclusiveMaximum:H,exclusiveMinimum:G}=$._zod.bag;if(typeofQ==="string"&&Q.includes("int"))U.type="integer";elseU.type="number";letZ=typeofG==="number"&&G>=(Y??Number.NEGATIVE_INFINITY),W=typeofH==="number"&&H<=(J??Number.POSITIVE_INFINITY),X=I.target==="draft-04"||I.target==="openapi-3.0";if(Z)if(X)U.minimum=G,U.exclusiveMinimum=!0;elseU.exclusiveMinimuLine truncated
`)}openNode($,I){let z=this.tos,q=this._xml;if(z&&this.open)q.push(">");this._stack.push($),q.push("<"),q.push($),pg(q,I),this.leaf=!0,this.open=!0}addAttribute($,I){if(!this.open)throw Error("Cannot write attributes to node if it is not open");if(I!==void 0)D70(this._xml,$,I)}addAttributes($){if(!this.open)throw Error("Cannot write attributes to node if it is not open");pg(this._xml,$)}writeText($){let I=this._xml;if(this.open)I.push(">"),this.open=!1;this.leaf=!1,I.push(N70.xmlEncode($.toString()))}writeXml($){if(this.open)this._xml.push(">"),this.open=!1;this.leaf=!1,this._xml.push($)}closeNode(){let $=this._stack.pop(),I=this._xml;if(this.leaf)I.push("/>");else I.push("</"),I.push($),I.push(">");this.open=!1,this.leaf=!1}leafNode($,I,z){if(this.openNode($,I),z!==void 0)this.writeText(z);this.closeNode()}closeAll(){while(this._stack.length)this.closeNode()}addRollback(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf,open:this.open}),this.cursor}commit(){this._rollbacks.pop()}rollback(){let $=this._rollbacks.pop();if(this._xml.length>$.xml)this._xml.splice($.xml,this._xml.length-$.xml);if(this._stack.length>$.stack)this._stack.splice($.stack,this._stack.length-$.stack);this.leaf=$.leaf,this.open=$.open}get xml(){return this.closeAll(),this._xml.join("")}}dg.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"};A70.exports=dg});var mg=M((t61)=>{var P70=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function s61($){if(typeof $==="string")return $;if(P70)return P70.decode($);return $.toString()}t61.bufferToString=s61});var C70=M((T70)=>{Object.defineProperty(T70,"__esModule",{value:!0});T70.CHAR=`
`,$=this.i;break;case O$1:{let{entityReturnState:z}=this,q=this.entity+I.slice($,this.prevI);this.state=z;let U;if(q==="")this.fail("empty entity name."),U="&;";else U=this.parseEntity(q),this.entity="";if(z!==L8||this.textHandler!==void 0)this.text+=U;break $}case B4:this.entity+=I.slice($);break $;default:}}sOpenWaka(){let $=this.getCode();if(ZH($))this.state=W$1,this.unget(),this.xmlDeclPossible=!1;else switch($){case GO:this.state=w$1,this.xmlDeclPossible=!1;break;case t70:this.state=z$1,this.openWakaBang="",this.xmlDeclPossible=!1;break;case x6:this.state=Q$1;break;default:this.fail("disallowed character in tag name"),this.state=L8,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=zS,this.openWakaBang="";break;case"--":this.state=IS,this.openWakaBang="";break;case"DOCTYPE":if(this.state=ag,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(HO))this.state=q$1}sCommentEnding(){var $;let I=this.getCodeNorm();if(I===HO)this.state=U$1,($=this.commentHandler)===null||$===void 0||$.call(this,this.text),this.text="";else this.text+=`-${String.fromCodePoint(I)}`,this.state=IS}sCommentEnded(){let $=this.getCodeNorm();if($!==G6)this.fail("malformed comment."),this.text+=`--${String.fromCodePoint($)}`,this.state=IS;else this.state=L8}sCData(){if(this.captureToChar(HU))this.state=Y$1}sCDataEnding(){let $=this.getCodeNorm();if($===HU)this.state=J$1;else this.text+=`]${String.fromCodePoint($)}`,this.state=zS}sCDataEnding2(){var $;let I=this.getCodeNorm();switch(I){case G6:{($=this.cdataHandler)===null||$===void 0||$.call(this,this.text),this.text="",this.state=L8;break}case HU:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(I)}`,this.state=zS}}sPIFirstChar(){let $=this.getCodeNorm();if(this.nameStartCheck($))this.piTarget+=String.fromCodePoint($),this.state=p70;else if($===x6||u8($))this.fail("processing instruction without a target."),this.state=$===x6?KO:qS;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint($),this.state=p70}sPIRest(){let{chunk:$,i:I}=this;while(!0){let z=this.getCodeNorm();if(z===B4){this.piTarget+=$.slice(I);return}if(!this.nameCheck(z)){this.piTarget+=$.slice(I,this.prevI);let q=z===x6;if(q||u8(z))if(this.piTarget==="xml"){if(!this.xmlDeclPossible)this.fail("an XML declaration must be at the start of the document.");this.state=q?o2:d70}else this.state=q?KO:qS;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(z);break}}}sPIBody(){if(this.text.length===0){let $=this.getCodeNorm();if($===x6)this.state=KO;else if(!u8($))this.text=String.fromCodePoint($)}else if(this.captureToChar(x6))this.state=KO}sPIEnding(){var $;let I=this.getCodeNorm();if(I===G6){let{piTarget:z}=this;if(z.toLowerCase()==="xml")this.fail("the XML declaration must appear at the start of the document.");($=this.piHandler)===null||$===void 0||$.call(this,{target:z,body:this.text}),this.piTarget=this.text="",this.state=L8}else if(I===x6)this.text+="?";else this.text+=`?${String.fromCodePoint(I)}`,this.state=qS;this.xmlDeclPossible=!1}sXMLDeclNameStart(){let $=this.skipSpaces();if($===x6){this.state=o2;return}if($!==B4)this.state=K$1,this.name=String.fromCodePoint($)}sXMLDeclName(){let $=this.captureTo(N$1);if($===x6){this.state=o2,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(!(u8($)||$===KU))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=$===KU?m70:H$1}sXMLDeclEq(){let $=this.getCodeNorm();if($===x6){this.state=o2,this.fail("XML declaration is incomplete.");return}if(u8($))return;if($!==KU)this.fail("value required.");this.state=m70}sXMLDeclValueStart(){let $=this.getCodeNorm();if($===x6){this.state=o2,this.fail("XML declaration is incomplete.");return}if(u8($))return;if(!ZO($))this.fail("value must be quoted."),this.q=s70;else this.q=$;this.state=G$1}sXMLDeclValue(){let $=this.captureTo([this.q,x6]);if($===x6){this.state=o2,this.text="",this.fail("XML declaration is incomplete.");return}if($===B4)return;let I=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let z=I;if(this.xmlDecl.version=z,!/^1\.[0-9]+$/.test(z))this.fail("ver
Line truncated
`;$=this.i;break;case B4:if(z!==void 0)this.text+=I.slice($);break $;default:if(!u8(U))q=!0}}if(!q)return;if(!this.sawRoot&&!this.reportedTextBeforeRoot)this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0;if(this.closedRoot&&!this.reportedTextAfterRoot)this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0}pushAttribNS($,I){var z;let{prefix:q,local:U}=this.qname($),Y={name:$,prefix:q,local:U,value:I};if(this.attribList.push(Y),(z=this.attributeHandler)===null||z===void 0||z.call(this,Y),q==="xmlns"){let J=I.trim();if(this.currentXMLVersion==="1.0"&&J==="")this.fail("invalid attempt to undefine prefix in XML 1.0");this.topNS[U]=J,HS(this,U,J)}else if($==="xmlns"){let J=I.trim();this.topNS[""]=J,HS(this,"",J)}}pushAttribPlain($,I){var z;let q={name:$,value:I};this.attribList.push(q),(z=this.attributeHandler)===null||z===void 0||z.call(this,q)}end(){var $,I;if(!this.sawRoot)this.fail("document must contain a root element.");let{tags:z}=this;while(z.length>0){let U=z.pop();this.fail(`unclosedtag:${U.name}`)}if(this.state!==c70&&this.state!==L8)this.fail("unexpected end.");let{text:q}=this;if(q.length!==0)($=this.textHandler)===null||$===void 0||$.call(this,q),this.text="";return this._closed=!0,(I=this.endHandler)===null||I===void 0||I.call(this),this._init(),this}resolve($){var I,z;let q=this.topNS[$];if(q!==void 0)return q;let{tags:U}=this;for(let Y=U.length-1;Y>=0;Y--)if(q=U[Y].ns[$],q!==void 0)return q;if(q=this.ns[$],q!==void 0)return q;return(z=(I=this.opt).resolvePrefix)===null||z===void 0?void 0:z.call(I,$)}qname($){let I=$.indexOf(":");if(I===-1)return{prefix:"",local:$};let z=$.slice(I+1),q=$.slice(0,I);if(q===""||z===""||z.includes(":"))this.fail(`malformedname:${$}.`);return{prefix:q,local:z}}processAttribsNS(){var $;let{attribList:I}=this,z=this.tag;{let{prefix:Y,local:J}=this.qname(z.name);z.prefix=Y,z.local=J;let Q=z.uri=($=this.resolve(Y))!==null&&$!==void 0?$:"";if(Y!==""){if(Y==="xmlns")this.fail('tags may not have "xmlns" as prefix.');if(Q==="")this.fail(`unboundnamespaceprefix:${JSON.stringify(Y)}.`),z.uri=Y}}if(I.length===0)return;let{attributes:q}=z,U=new Set;for(let Y of I){let{name:J,prefix:Q,local:K}=Y,H,G;if(Q==="")H=J==="xmlns"?GU:"",G=J;else{if(H=this.resolve(Q),H===void 0)this.fail(`unboundnamespaceprefix:${JSON.stringify(Q)}.`),H=Q;G=`{${H}}${K}`}if(U.has(G))this.fail(`duplicateattribute:${G}.`);U.add(G),Y.uri=H,q[J]=Y}this.attribList=[]}processAttribsPlain(){let{attribList:$}=this,I=this.tag.attributes;for(let{name:z,value:q}of $){if(I[z]!==void 0)this.fail(`duplicateattribute:${z}.`);I[z]=q}this.attribList=[]}openTag(){var $;this.processAttribs();let{tags:I}=this,z=this.tag;z.isSelfClosing=!1,($=this.openTagHandler)===null||$===void 0||$.call(this,z),I.push(z),this.state=L8,this.name=""}openSelfClosingTag(){var $,I,z;this.processAttribs();let{tags:q}=this,U=this.tag;if(U.isSelfClosing=!0,($=this.openTagHandler)===null||$===void 0||$.call(this,U),(I=this.closeTagHandler)===null||I===void 0||I.call(this,U),(this.tag=(z=q[q.length-1])!==null&&z!==void 0?z:null)===null)this.closedRoot=!0;this.state=L8,this.name=""}closeTag(){let{tags:$,name:I}=this;if(this.state=L8,this.name="",I===""){this.fail("weird empty close tag."),this.text+="</>";return}let z=this.closeTagHandler,q=$.length;while(q-- >0){let U=this.tag=$.pop();if(this.topNS=U.ns,z===null||z===void 0||z(U),U.name===I)break;this.fail("unexpected close tag.")}if(q===0)this.closedRoot=!0;else if(q<0)this.fail(`unmatchedclosingtag:${I}.`),this.text+=`</${I}>`}parseEntity($){if($[0]!=="#"){let z=this.ENTITIES[$];if(z!==void 0)return z;return this.fail(this.isName($)?"undefined entity.":"disallowed character in entity name."),`&${$};`}let I=NaN;if($[1]==="x"&&/^#x[0-9a-f]+$/i.test($))I=parseInt($.slice(2),16);elseif(/^#[0-9]+$/.test($))I=parseInt($.slice(1),10);if(!this.isChar(I))returnthis.fail("malformed character entity."),`&${$};`;returnString.fromCodePoint(I)}}K20.SaxesParser=Q20});varVH=M((le1,G20)=>{var{SaxesParser:j$1}=H20(),{PassThrough:C$1}=w8(),{bufferToString:_$1}=mg();G20.exports=asyncfunction*($){if($.pipe&&!$[Symbol.asyncIterator])$=$.pipe(newC$1);letI=newj$1,z;I.on("error",(U)=>{z=U});letq=[];I.on("opentag",(U)=>q.push({eventType:"opentag",value:U})),I.on("text",(U)=>q.push({eventType:"text",value:U})),I.on("closetag",(U)=>q.push({eventType:"closetag",value:U}));forawait(letUof$){if(I.write(_$1(U)),z)throwz;yieldq,q=[]}}});varF0=M((oe1,Z20)=>{varR$1=VH(),v$1=y6();classWU{prepare(){}render(){}parseOpen($){}parseText($){}parseClose($){}reconcile($,I){}reset(){if(this.model=null,this.map)Object.values(this.map).forEach(($)=>{if($instanceofWU)$.reset();elseif($.xform)$.xform.reset()})}mergeModel($){this.model=Object.assign(this.model||{},$)}asyncparse($){forawait(letIof$)for(let{eventType:z,value:q}ofI)if(z==="opentag")this.parseOpen(q);elseif(z==="text")this.parseText(q);elseif(z==="closetag"){if(!this.parseClose(q.name))returnthLine truncated
Setthe\`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(letJof$.seen.entries()){letQ=J[1];if(q===J[0]){I(J);continue}if($.external){letH=$.external.registry.get(J[0])?.id;if(q!==J[0]&&H){I(J);continue}}if($.metadataRegistry.get(J[0])?.id){I(J);continue}if(Q.cycle){I(J);continue}if(Q.count>1){if($.reused==="ref"){I(J);continue}}}}functionv3($,q){letY=$.seen.get(q);if(!Y)throwError("Unprocessed schema. This is a bug in Zod.");letz=(Q)=>{letK=$.seen.get(Q);if(K.ref===null)return;letH=K.def??K.schema,G={...H},Z=K.ref;if(K.ref=null,Z){z(Z);letX=$.seen.get(Z),w=X.schema;if(w.$ref&&($.target==="draft-07"||$.target==="draft-04"||$.target==="openapi-3.0"))H.allOf=H.allOf??[],H.allOf.push(w);elseObject.assign(H,w);if(Object.assign(H,G),Q._zod.parent===Z)for(letFinH){if(F==="$ref"||F==="allOf")continue;if(!(FinG))deleteH[F]}if(w.$ref&&X.def)for(letFinH){if(F==="$ref"||F==="allOf")continue;if(FinX.def&&JSON.stringify(H[F])===JSON.stringify(X.def[F]))deleteH[F]}}letV=Q._zod.parent;if(V&&V!==Z){z(V);letX=$.seen.get(V);if(X?.schema.$ref){if(H.$ref=X.schema.$ref,X.def)for(letwinH){if(w==="$ref"||w==="allOf")continue;if(winX.def&&JSON.stringify(H[w])===JSON.stringify(X.def[w]))deleteH[w]}}}$.override({zodSchema:Q,jsonSchema:H,path:K.path??[]})};for(letQof[...$.seen.entries()].reverse())z(Q[0]);letU={};if($.target==="draft-2020-12")U.$schema="https://json-schema.org/draft/2020-12/schema";elseif($.target==="draft-07")U.$schema="http://json-schema.org/draft-07/schema#";elseif($.target==="draft-04")U.$schema="http://json-schema.org/draft-04/schema#";elseif($.target==="openapi-3.0");if($.external?.uri){letQ=$.external.registry.get(q)?.id;if(!Q)throwError("Schema is missing an `id` property");U.$id=$.external.uri(Q)}Object.assign(U,Y.def??Y.schema);letI=$.metadataRegistry.get(q)?.id;if(I!==void0&&U.id===I)deleteU.id;letJ=$.external?.defs??{};for(letQof$.seen.entries()){letK=Q[1];if(K.def&&K.defId){if(K.def.id===K.defId)deleteK.def.id;J[K.defId]=K.def}}if($.external);elseif(Object.keys(J).length>0)if($.target==="draft-2020-12")U.$defs=J;elseU.definitions=J;try{letQ=JSON.parse(JSON.stringify(U));returnObject.defineProperty(Q,"~standard",{value:{...q["~standard"],jsonSchema:{input:eY(q,"input",$.processors),output:eY(q,"output",$.processors)}},enumerable:!1,writable:!1}),Q}catch(Q){throwError("Error converting schema to JSON.")}}functionF8($,q){letY=q??{seen:newSet};if(Y.seen.has($))return!1;Y.seen.add($);letz=$._zod.def;if(z.type==="transform")return!0;if(z.type==="array")returnF8(z.element,Y);if(z.type==="set")returnF8(z.valueType,Y);if(z.type==="lazy")returnF8(z.getter(),Y);if(z.type==="promise"||z.type==="optional"||z.type==="nonoptional"||z.type==="nullable"||z.type==="readonly"||z.type==="default"||z.type==="prefault")returnF8(z.innerType,Y);if(z.type==="intersection")returnF8(z.left,Y)||F8(z.right,Y);if(z.type==="record"||z.type==="map")returnF8(z.keyType,Y)||F8(z.valueType,Y);if(z.type==="pipe"){if($._zod.traits.has("$ZodCodec"))return!0;returnF8(z.in,Y)||F8(z.out,Y)}if(z.type==="object"){for(letUinz.shape)if(F8(z.shape[U],Y))return!0;return!1}if(z.type==="union"){for(letUofz.options)if(F8(U,Y))return!0;return!1}if(z.type==="tuple"){for(letUofz.items)if(F8(U,Y))return!0;if(z.rest&&F8(z.rest,Y))return!0;return!1}return!1}varRj=($,q={})=>(Y)=>{letz=C3({...Y,processors:q});returns1($,z),R3(z,$),v3(z,$)},eY=($,q,Y={})=>(z)=>{let{libraryOptions:U,target:I}=z??{},J=C3({...U??{},target:I,io:q,processors:Y});returns1($,J),R3(J,$),v3(J,$)};varHQ=e(()=>{JQ()});functionxX($,q){if("_idmap"in$){letz=$,U=C3({...q,processors:gX}),I={};for(letKofz._idmap.entries()){let[H,G]=K;s1(G,U)}letJ={},Q={registry:z,uri:q?.uri,defs:I};U.external=Q;for(letKofz._idmap.entries()){let[H,G]=K;R3(U,G),J[H]=v3(U,G)}if(Object.keys(I).length>0){letK=U.target==="draft-2020-12"?"$defs":"definitions";J.__shared={[K]:I}}return{schemas:J}}letY=C3({...q,processors:gX});returns1($,Y),R3(Y,$),v3(Y,$)}varFk0,vj=($,q,Y,z)=>{letU=Y;U.type="string";let{minimum:I,maximum:J,format:Q,patterns:K,contentEncoding:H}=$._zod.bag;if(typeofI==="number")U.minLength=I;if(typeofJ==="number")U.maxLength=J;if(Q){if(U.format=Fk0[Q]??Q,U.format==="")deleteU.format;if(Q==="time")deleteU.format}if(H)U.contentEncoding=H;if(K&&K.size>0){letG=[...K];if(G.length===1)U.pattern=G[0].source;elseif(G.length>1)U.allOf=[...G.map((Z)=>({...q.target==="draft-07"||q.target==="draft-04"||q.target==="openapi-3.0"?{type:"string"}:{},pattern:Z.source}))]}},hj=($,q,Y,z)=>{letU=Y,{minimum:I,maximum:J,format:Q,multipleOf:K,exclusiveMaximum:H,exclusiveMinimum:G}=$._zod.bag;if(typeofQ==="string"&&Q.includes("int"))U.type="integer";elseU.type="number";letZ=typeofG==="number"&&G>=(I??Number.NEGATIVE_INFINITY),V=typeofH==="number"&&H<=(J??Number.POSITIVE_INFINITY),X=q.target==="draft-04"||q.target==="openapi-3.0";if(Z)if(X)U.minimum=G,U.exclusiveMinimum=!0;elseU.exclusiveMinimuLine truncated
deps:${Y}}`};var pd0={keyword:"dependencies",type:"object",schemaType:"object",error:Pe.error,code($){let[q,Y]=dd0($);De($,q),Ae($,Y)}};function dd0({schema:$}){let q={},Y={};for(let z in $){if(z==="__proto__")continue;let U=Array.isArray($[z])?q:Y;U[z]=$[z]}return[q,Y]}function De($,q=$.schema){let{gen:Y,data:z,it:U}=$;if(Object.keys(q).length===0)return;let I=Y.let("missing");for(let J in q){let Q=q[J];if(Q.length===0)continue;let K=(0,IK.propertyInData)(Y,z,J,U.opts.ownProperties);if($.setParams({property:J,depsCount:Q.length,deps:Q.join(", ")}),U.allErrors)Y.if(K,()=>{for(let H of Q)(0,IK.checkReportMissingProp)($,H)});else Y.if(hR._`${K}&&(${(0,IK.checkMissingProp)($,Q,I)})`),(0,IK.reportMissingProp)($,I),Y.else()}}Pe.validatePropertyDeps=De;function Ae($,q=$.schema){let{gen:Y,data:z,keyword:U,it:I}=$,J=Y.name("valid");for(let Q in q){if((0,cd0.alwaysValidSchema)(I,q[Q]))continue;Y.if((0,IK.propertyInData)(Y,z,Q,I.opts.ownProperties),()=>{let K=$.subschema({keyword:U,schemaProp:Q},J);$.mergeValidEvaluated(K,J)},()=>Y.var(J,!0)),$.ok(J)}}Pe.validateSchemaDeps=Ae;Pe.default=pd0});var Ce=M((_e)=>{Object.defineProperty(_e,"__esModule",{value:!0});var je=J1(),od0=j1(),rd0={message:"property name must be valid",params:({params:$})=>je._`{propertyName:${$.propertyName}}`},sd0={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:rd0,code($){let{gen:q,schema:Y,data:z,it:U}=$;if((0,od0.alwaysValidSchema)(U,Y))return;let I=q.name("valid");q.forIn("key",z,(J)=>{$.setParams({propertyName:J}),$.subschema({keyword:"propertyNames",data:J,dataTypes:["string"],propertyName:J,compositeRule:!0},I),q.if((0,je.not)(I),()=>{if($.error(!0),!U.allErrors)q.break()})}),$.ok(I)}};_e.default=sd0});var gR=M((Re)=>{Object.defineProperty(Re,"__esModule",{value:!0});var Uw=D$(),Y5=J1(),ad0=A9(),Iw=j1(),ed0={message:"must NOT have additional properties",params:({params:$})=>Y5._`{additionalProperty:${$.additionalProperty}}`},$m0={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:ed0,code($){let{gen:q,schema:Y,parentSchema:z,data:U,errsCount:I,it:J}=$;if(!I)throw Error("ajv implementation error");let{allErrors:Q,opts:K}=J;if(J.props=!0,K.removeAdditional!=="all"&&(0,Iw.alwaysValidSchema)(J,Y))return;let H=(0,Uw.allSchemaProperties)(z.properties),G=(0,Uw.allSchemaProperties)(z.patternProperties);Z(),$.ok(Y5._`${I}===${ad0.default.errors}`);function Z(){q.forIn("key",U,(F)=>{if(!H.length&&!G.length)w(F);else q.if(V(F),()=>w(F))})}function V(F){let O;if(H.length>8){let A=(0,Iw.schemaRefOrVal)(J,z.properties,"properties");O=(0,Uw.isOwnProperty)(q,A,F)}else if(H.length)O=(0,Y5.or)(...H.map((A)=>Y5._`${F}===${A}`));else O=Y5.nil;if(G.length)O=(0,Y5.or)(O,...G.map((A)=>Y5._`${(0,Uw.usePattern)($,A)}.test(${F})`));return(0,Y5.not)(O)}function X(F){q.code(Y5._`delete${U}[${F}]`)}function w(F){if(K.removeAdditional==="all"||K.removeAdditional&&Y===!1){X(F);return}if(Y===!1){if($.setParams({additionalProperty:F}),$.error(),!Q)q.break();return}if(typeof Y=="object"&&!(0,Iw.alwaysValidSchema)(J,Y)){let O=q.name("valid");if(K.removeAdditional==="failing")L(F,O,!1),q.if((0,Y5.not)(O),()=>{$.reset(),X(F)});else if(L(F,O),!Q)q.if((0,Y5.not)(O),()=>q.break())}}function L(F,O,A){let B={keyword:"additionalProperties",dataProp:F,dataPropType:Iw.Type.Str};if(A===!1)Object.assign(B,{compositeRule:!0,createErrors:!1,allErrors:!1});$.subschema(B,O)}}};Re.default=$m0});var Se=M((ge)=>{Object.defineProperty(ge,"__esModule",{value:!0});var Ym0=lQ(),ve=D$(),SR=j1(),he=gR(),zm0={keyword:"properties",type:"object",schemaType:"object",code($){let{gen:q,schema:Y,parentSchema:z,data:U,it:I}=$;if(I.opts.removeAdditional==="all"&&z.additionalProperties===void 0)he.default.code(new Ym0.KeywordCxt(I,he.default,"additionalProperties"));let J=(0,ve.allSchemaProperties)(Y);for(let Z of J)I.definedProperties.add(Z);if(I.opts.unevaluated&&J.length&&I.props!==!0)I.props=SR.mergeEvaluated.props(q,(0,SR.toHash)(J),I.props);let Q=J.filter((Z)=>!(0,SR.alwaysValidSchema)(I,Y[Z]));if(Q.length===0)return;let K=q.name("valid");for(let Z of Q){if(H(Z))G(Z);else{if(q.if((0,ve.propertyInData)(q,U,Z,I.opts.ownProperties)),G(Z),!I.allErrors)q.else().var(K,!0);q.endIf()}$.it.definedProperties.add(Z),$.ok(K)}function H(Z){return I.opts.useDefaults&&!I.compositeRule&&Y[Z].default!==void 0}function G(Z){$.subschema({keyword:"properties",schemaProp:Z,dataProp:Z},K)}}};ge.default=zm0});var fe=M((ue)=>{Object.defineProperty(ue,"__esModule",{value:!0});var ye=D$(),Jw=J1(),xe=j1(),ke=j1(),Im0={keyword:"patternProperties",type:"object",schemaType:"object",code($){let{gen:q,schema:Y,data:z,parentSchema:U,it:I}=$,{opts:J}=I,Q=(0,ye.allSchemaProperties)(Y),K=Q.filter((L)=>(0,xe.alwaysValidSchema)(I,Y[L]));if(Q.length===0||K.length===Q.length&&(!I.opts.unevaluated||I.props===!0))return;let H=J.strictSchema&&!J.allowMatchingProperties&&U.properties,G=q.name("valid");if(I.props!==!0&&!(I.props instanceo
Line truncated
`)}openNode($,q){let Y=this.tos,z=this._xml;if(Y&&this.open)z.push(">");this._stack.push($),z.push("<"),z.push($),US(z,q),this.leaf=!0,this.open=!0}addAttribute($,q){if(!this.open)throw Error("Cannot write attributes to node if it is not open");if(q!==void 0)d70(this._xml,$,q)}addAttributes($){if(!this.open)throw Error("Cannot write attributes to node if it is not open");US(this._xml,$)}writeText($){let q=this._xml;if(this.open)q.push(">"),this.open=!1;this.leaf=!1,q.push(p70.xmlEncode($.toString()))}writeXml($){if(this.open)this._xml.push(">"),this.open=!1;this.leaf=!1,this._xml.push($)}closeNode(){let $=this._stack.pop(),q=this._xml;if(this.leaf)q.push("/>");else q.push("</"),q.push($),q.push(">");this.open=!1,this.leaf=!1}leafNode($,q,Y){if(this.openNode($,q),Y!==void 0)this.writeText(Y);this.closeNode()}closeAll(){while(this._stack.length)this.closeNode()}addRollback(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf,open:this.open}),this.cursor}commit(){this._rollbacks.pop()}rollback(){let $=this._rollbacks.pop();if(this._xml.length>$.xml)this._xml.splice($.xml,this._xml.length-$.xml);if(this._stack.length>$.stack)this._stack.splice($.stack,this._stack.length-$.stack);this.leaf=$.leaf,this.open=$.open}get xml(){return this.closeAll(),this._xml.join("")}}IS.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"};m70.exports=IS});var JS=M((u81)=>{var l70=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function k81($){if(typeof $==="string")return $;if(l70)return l70.decode($);return $.toString()}u81.bufferToString=k81});var a70=M((r70)=>{Object.defineProperty(r70,"__esModule",{value:!0});r70.CHAR=`
`,$=this.i;break;case U51:{let{entityReturnState:Y}=this,z=this.entity+q.slice($,this.prevI);this.state=Y;let U;if(z==="")this.fail("empty entity name."),U="&;";else U=this.parseEntity(z),this.entity="";if(Y!==P8||this.textHandler!==void 0)this.text+=U;break $}case v4:this.entity+=q.slice($);break $;default:}}sOpenWaka(){let $=this.getCode();if(DH($))this.state=e$1,this.unget(),this.xmlDeclPossible=!1;else switch($){case MF:this.state=Y51,this.xmlDeclPossible=!1;break;case D20:this.state=c$1,this.openWakaBang="",this.xmlDeclPossible=!1;break;case p6:this.state=o$1;break;default:this.fail("disallowed character in tag name"),this.state=P8,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=LS,this.openWakaBang="";break;case"--":this.state=wS,this.openWakaBang="";break;case"DOCTYPE":if(this.state=WS,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(OF))this.state=p$1}sCommentEnding(){var $;let q=this.getCodeNorm();if(q===OF)this.state=d$1,($=this.commentHandler)===null||$===void 0||$.call(this,this.text),this.text="";else this.text+=`-${String.fromCodePoint(q)}`,this.state=wS}sCommentEnded(){let $=this.getCodeNorm();if($!==O6)this.fail("malformed comment."),this.text+=`--${String.fromCodePoint($)}`,this.state=wS;else this.state=P8}sCData(){if(this.captureToChar(FU))this.state=m$1}sCDataEnding(){let $=this.getCodeNorm();if($===FU)this.state=l$1;else this.text+=`]${String.fromCodePoint($)}`,this.state=LS}sCDataEnding2(){var $;let q=this.getCodeNorm();switch(q){case O6:{($=this.cdataHandler)===null||$===void 0||$.call(this,this.text),this.text="",this.state=P8;break}case FU:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(q)}`,this.state=LS}}sPIFirstChar(){let $=this.getCodeNorm();if(this.nameStartCheck($))this.piTarget+=String.fromCodePoint($),this.state=V20;else if($===p6||c8($))this.fail("processing instruction without a target."),this.state=$===p6?FF:FS;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint($),this.state=V20}sPIRest(){let{chunk:$,i:q}=this;while(!0){let Y=this.getCodeNorm();if(Y===v4){this.piTarget+=$.slice(q);return}if(!this.nameCheck(Y)){this.piTarget+=$.slice(q,this.prevI);let z=Y===p6;if(z||c8(Y))if(this.piTarget==="xml"){if(!this.xmlDeclPossible)this.fail("an XML declaration must be at the start of the document.");this.state=z?e2:w20}else this.state=z?FF:FS;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(Y);break}}}sPIBody(){if(this.text.length===0){let $=this.getCodeNorm();if($===p6)this.state=FF;else if(!c8($))this.text=String.fromCodePoint($)}else if(this.captureToChar(p6))this.state=FF}sPIEnding(){var $;let q=this.getCodeNorm();if(q===O6){let{piTarget:Y}=this;if(Y.toLowerCase()==="xml")this.fail("the XML declaration must appear at the start of the document.");($=this.piHandler)===null||$===void 0||$.call(this,{target:Y,body:this.text}),this.piTarget=this.text="",this.state=P8}else if(q===p6)this.text+="?";else this.text+=`?${String.fromCodePoint(q)}`,this.state=FS;this.xmlDeclPossible=!1}sXMLDeclNameStart(){let $=this.skipSpaces();if($===p6){this.state=e2;return}if($!==v4)this.state=r$1,this.name=String.fromCodePoint($)}sXMLDeclName(){let $=this.captureTo(Q51);if($===p6){this.state=e2,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(!(c8($)||$===LU))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=$===LU?L20:s$1}sXMLDeclEq(){let $=this.getCodeNorm();if($===p6){this.state=e2,this.fail("XML declaration is incomplete.");return}if(c8($))return;if($!==LU)this.fail("value required.");this.state=L20}sXMLDeclValueStart(){let $=this.getCodeNorm();if($===p6){this.state=e2,this.fail("XML declaration is incomplete.");return}if(c8($))return;if(!NF($))this.fail("value must be quoted."),this.q=N20;else this.q=$;this.state=t$1}sXMLDeclValue(){let $=this.captureTo([this.q,p6]);if($===p6){this.state=e2,this.text="",this.fail("XML declaration is incomplete.");return}if($===v4)return;let q=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let Y=q;if(this.xmlDecl.version=Y,!/^1\.[0-9]+$/.test(Y))this.fail("ver
Line truncated
`;$=this.i;break;case v4:if(Y!==void 0)this.text+=q.slice($);break $;default:if(!c8(U))z=!0}}if(!z)return;if(!this.sawRoot&&!this.reportedTextBeforeRoot)this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0;if(this.closedRoot&&!this.reportedTextAfterRoot)this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0}pushAttribNS($,q){var Y;let{prefix:z,local:U}=this.qname($),I={name:$,prefix:z,local:U,value:q};if(this.attribList.push(I),(Y=this.attributeHandler)===null||Y===void 0||Y.call(this,I),z==="xmlns"){let J=q.trim();if(this.currentXMLVersion==="1.0"&&J==="")this.fail("invalid attempt to undefine prefix in XML 1.0");this.topNS[U]=J,PS(this,U,J)}else if($==="xmlns"){let J=q.trim();this.topNS[""]=J,PS(this,"",J)}}pushAttribPlain($,q){var Y;let z={name:$,value:q};this.attribList.push(z),(Y=this.attributeHandler)===null||Y===void 0||Y.call(this,z)}end(){var $,q;if(!this.sawRoot)this.fail("document must contain a root element.");let{tags:Y}=this;while(Y.length>0){let U=Y.pop();this.fail(`unclosedtag:${U.name}`)}if(this.state!==X20&&this.state!==P8)this.fail("unexpected end.");let{text:z}=this;if(z.length!==0)($=this.textHandler)===null||$===void 0||$.call(this,z),this.text="";return this._closed=!0,(q=this.endHandler)===null||q===void 0||q.call(this),this._init(),this}resolve($){var q,Y;let z=this.topNS[$];if(z!==void 0)return z;let{tags:U}=this;for(let I=U.length-1;I>=0;I--)if(z=U[I].ns[$],z!==void 0)return z;if(z=this.ns[$],z!==void 0)return z;return(Y=(q=this.opt).resolvePrefix)===null||Y===void 0?void 0:Y.call(q,$)}qname($){let q=$.indexOf(":");if(q===-1)return{prefix:"",local:$};let Y=$.slice(q+1),z=$.slice(0,q);if(z===""||Y===""||Y.includes(":"))this.fail(`malformedname:${$}.`);return{prefix:z,local:Y}}processAttribsNS(){var $;let{attribList:q}=this,Y=this.tag;{let{prefix:I,local:J}=this.qname(Y.name);Y.prefix=I,Y.local=J;let Q=Y.uri=($=this.resolve(I))!==null&&$!==void 0?$:"";if(I!==""){if(I==="xmlns")this.fail('tags may not have "xmlns" as prefix.');if(Q==="")this.fail(`unboundnamespaceprefix:${JSON.stringify(I)}.`),Y.uri=I}}if(q.length===0)return;let{attributes:z}=Y,U=new Set;for(let I of q){let{name:J,prefix:Q,local:K}=I,H,G;if(Q==="")H=J==="xmlns"?OU:"",G=J;else{if(H=this.resolve(Q),H===void 0)this.fail(`unboundnamespaceprefix:${JSON.stringify(Q)}.`),H=Q;G=`{${H}}${K}`}if(U.has(G))this.fail(`duplicateattribute:${G}.`);U.add(G),I.uri=H,z[J]=I}this.attribList=[]}processAttribsPlain(){let{attribList:$}=this,q=this.tag.attributes;for(let{name:Y,value:z}of $){if(q[Y]!==void 0)this.fail(`duplicateattribute:${Y}.`);q[Y]=z}this.attribList=[]}openTag(){var $;this.processAttribs();let{tags:q}=this,Y=this.tag;Y.isSelfClosing=!1,($=this.openTagHandler)===null||$===void 0||$.call(this,Y),q.push(Y),this.state=P8,this.name=""}openSelfClosingTag(){var $,q,Y;this.processAttribs();let{tags:z}=this,U=this.tag;if(U.isSelfClosing=!0,($=this.openTagHandler)===null||$===void 0||$.call(this,U),(q=this.closeTagHandler)===null||q===void 0||q.call(this,U),(this.tag=(Y=z[z.length-1])!==null&&Y!==void 0?Y:null)===null)this.closedRoot=!0;this.state=P8,this.name=""}closeTag(){let{tags:$,name:q}=this;if(this.state=P8,this.name="",q===""){this.fail("weird empty close tag."),this.text+="</>";return}let Y=this.closeTagHandler,z=$.length;while(z-- >0){let U=this.tag=$.pop();if(this.topNS=U.ns,Y===null||Y===void 0||Y(U),U.name===q)break;this.fail("unexpected close tag.")}if(z===0)this.closedRoot=!0;else if(z<0)this.fail(`unmatchedclosingtag:${q}.`),this.text+=`</${q}>`}parseEntity($){if($[0]!=="#"){let Y=this.ENTITIES[$];if(Y!==void 0)return Y;return this.fail(this.isName($)?"undefined entity.":"disallowed character in entity name."),`&${$};`}let q=NaN;if($[1]==="x"&&/^#x[0-9a-f]+$/i.test($))q=parseInt($.slice(2),16);elseif(/^#[0-9]+$/.test($))q=parseInt($.slice(1),10);if(!this.isChar(q))returnthis.fail("malformed character entity."),`&${$};`;returnString.fromCodePoint(q)}}h20.SaxesParser=v20});varBH=M((X14,S20)=>{var{SaxesParser:V51}=g20(),{PassThrough:w51}=A8(),{bufferToString:L51}=JS();S20.exports=asyncfunction*($){if($.pipe&&!$[Symbol.asyncIterator])$=$.pipe(neww51);letq=newV51,Y;q.on("error",(U)=>{Y=U});letz=[];q.on("opentag",(U)=>z.push({eventType:"opentag",value:U})),q.on("text",(U)=>z.push({eventType:"text",value:U})),q.on("closetag",(U)=>z.push({eventType:"closetag",value:U}));forawait(letUof$){if(q.write(L51(U)),Y)throwY;yieldz,z=[]}}});varD0=M((V14,y20)=>{varF51=BH(),O51=c6();classNU{prepare(){}render(){}parseOpen($){}parseText($){}parseClose($){}reconcile($,q){}reset(){if(this.model=null,this.map)Object.values(this.map).forEach(($)=>{if($instanceofNU)$.reset();elseif($.xform)$.xform.reset()})}mergeModel($){this.model=Object.assign(this.model||{},$)}asyncparse($){forawait(letqof$)for(let{eventType:Y,value:z}ofq)if(Y==="opentag")this.parseOpen(z);elseif(Y==="text")this.parseText(z);elseif(Y==="closetag"){if(!this.parseClose(z.name))returnthLine truncated
See:https://github.com/isaacs/node-glob/issues/167`);return new Z6($,I).found}function Z6($,I){if(!$)throw Error("must provide pattern");if(typeof I==="function"||arguments.length===3)throw TypeError(`callback provided to sync glob
See:https://github.com/isaacs/node-glob/issues/167`);return new M6($,q).found}function M6($,q){if(!$)throw Error("must provide pattern");if(typeof q==="function"||arguments.length===3)throw TypeError(`callback provided to sync glob
`+z0[W0-1];break}}}var O1="a promise was created in a "+B+"handler "+I0+"but was not returned from it, see http://goo.gl/rRqMUw"+r;S._warn(O1,!0,N)}}function _0(a,N){var B=a+" is deprecated and will be removed in a future version.";if(N)B+=" Use "+N+" instead.";return Y1(B)}function Y1(a,N,B){if(!C0.warnings)return;var S=new U(a),n;if(N)B._attachExtraTrace(S);else if(C0.longStackTraces&&(n=$._peekContext()))n.attachExtraTrace(S);else{var I0=k0(S);S.stack=I0.message+`
`+z0[V0-1];break}}}var D1="a promise was created in a "+D+"handler "+q0+"but was not returned from it, see http://goo.gl/rRqMUw"+r;h._warn(D1,!0,N)}}function w0(o,N){var D=o+" is deprecated and will be removed in a future version.";if(N)D+=" Use "+N+" instead.";return T0(D)}function T0(o,N,D){if(!L0.warnings)return;var h=new U(o),x;if(N)D._attachExtraTrace(h);else if(L0.longStackTraces&&(x=$._peekContext()))x.attachExtraTrace(h);else{var q0=f0(h);h.stack=q0.message+`
`)));return}}F=F._target();var D=F._bitField;if((D&50397184)===0)this._yieldedPromise=F,F._proxy(this,null);else if((D&33554432)!==0)$._async.invoke(this._promiseFulfilled,this,F._value());else if((D&16777216)!==0)$._async.invoke(this._promiseRejected,this,F._reason());else this._promiseCancelled()}},$.coroutine=function(w,L){if(typeof w!=="function")throw new Q(`generatorFunctionmustbeafunction
`)));return}}O=O._target();var A=O._bitField;if((A&50397184)===0)this._yieldedPromise=O,O._proxy(this,null);else if((A&33554432)!==0)$._async.invoke(this._promiseFulfilled,this,O._value());else if((A&16777216)!==0)$._async.invoke(this._promiseRejected,this,O._reason());else this._promiseCancelled()}},$.coroutine=function(w,L){if(typeof w!=="function")throw new Q(`generatorFunctionmustbeafunction
Seehttp://goo.gl/MqrFmX
`);var O=Object(L).yieldHandler,F=X,D=Error().stack;return function(){var P=w.apply(this,arguments),A=new F(void 0,void 0,O,D),T=A.promise();return A._generator=P,A._promiseFulfilled(void 0),T}},$.coroutine.addYieldHandler=function(w){if(typeof w!=="function")throw new Q("expecting a function but got "+K.classString(w));Z.push(w)},$.spawn=function(w){if(Y.deprecated("Promise.spawn()","Promise.coroutine()"),typeof w!=="function")return I(`generatorFunctionmustbeafunction
`);var F=Object(L).yieldHandler,O=X,A=Error().stack;return function(){var B=w.apply(this,arguments),P=new O(void 0,void 0,F,A),T=P.promise();return P._generator=B,P._promiseFulfilled(void 0),T}},$.coroutine.addYieldHandler=function(w){if(typeof w!=="function")throw new Q("expecting a function but got "+K.classString(w));Z.push(w)},$.spawn=function(w){if(I.deprecated("Promise.spawn()","Promise.coroutine()"),typeof w!=="function")return q(`generatorFunctionmustbeafunction
`)},I=function(){return new v.PromiseInspection(this._target())},z=function(R){return v.reject(new Z(R))};function q(){}var U={},Y=q4(),J;if(Y.isNode)J=function(){var R=process.domain;if(R===void 0)R=null;return R};else J=function(){return null};Y.notEnumerableProp(v,"_getDomain",J);var Q=hI(),K=ZO0(),H=new K;Q.defineProperty(v,"_async",{value:H});var G=d9(),Z=v.TypeError=G.TypeError;v.RangeError=G.RangeError;var W=v.CancellationError=G.CancellationError;v.TimeoutError=G.TimeoutError,v.OperationalError=G.OperationalError,v.RejectionError=G.OperationalError,v.AggregateError=G.AggregateError;var X=function(){},w={},L={},O=LO0()(v,X),F=FO0()(v,X,O,z,q),D=NO0()(v),P=D.create,A=AO0()(v,D),T=A.CapturedTrace,k=BO0()(v,O),h=EO0()(L),f=Cf(),C=Y.errorObj,b=Y.tryCatch;function i(R,u){if(typeof u!=="function")throw new Z("expecting a function but got "+Y.classString(u));if(R.constructor!==v)throw new Z(`thepromiseconstructorcannotbeinvokeddirectly
`)},q=function(){return new g.PromiseInspection(this._target())},Y=function(j){return g.reject(new Z(j))};function z(){}var U={},I=G4(),J;if(I.isNode)J=function(){var j=process.domain;if(j===void 0)j=null;return j};else J=function(){return null};I.notEnumerableProp(g,"_getDomain",J);var Q=kq(),K=yF0(),H=new K;Q.defineProperty(g,"_async",{value:H});var G=e9(),Z=g.TypeError=G.TypeError;g.RangeError=G.RangeError;var V=g.CancellationError=G.CancellationError;g.TimeoutError=G.TimeoutError,g.OperationalError=G.OperationalError,g.RejectionError=G.OperationalError,g.AggregateError=G.AggregateError;var X=function(){},w={},L={},F=bF0()(g,X),O=nF0()(g,X,F,Y,z),A=pF0()(g),B=A.create,P=mF0()(g,A),T=P.CapturedTrace,y=oF0()(g,F),v=sF0()(L),k=cf(),R=I.errorObj,c=I.tryCatch;function n(j,u){if(typeof u!=="function")throw new Z("expecting a function but got "+I.classString(u));if(j.constructor!==g)throw new Z(`thepromiseconstructorcannotbeinvokeddirectly
Seehttp://goo.gl/MqrFmX
`)}function v(R){if(this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,R!==X)i(this,R),this._resolveFromExecutor(R);this._promiseCreated(),this._fireEvent("promiseCreated",this)}v.prototype.toString=function(){return"[object Promise]"},v.prototype.caught=v.prototype.catch=function(R){var u=arguments.length;if(u>1){var p=Array(u-1),s=0,U0;for(U0=0;U0<u-1;++U0){var H0=arguments[U0];if(Y.isObject(H0))p[s++]=H0;else return z("expecting an object but got A catch statement predicate "+Y.classString(H0))}return p.length=s,R=arguments[U0],this.then(void 0,h(p,R,this))}return this.then(void 0,R)},v.prototype.reflect=function(){return this._then(I,I,void 0,this,void 0)},v.prototype.then=function(R,u){if(A.warnings()&&arguments.length>0&&typeof R!=="function"&&typeof u!=="function"){var p=".then() only accepts functions but was passed: "+Y.classString(R);if(arguments.length>1)p+=", "+Y.classString(u);this._warn(p)}return this._then(R,u,void 0,void 0,void 0)},v.prototype.done=function(R,u){var p=this._then(R,u,void 0,void 0,void 0);p._setIsFinal()},v.prototype.spread=function(R){if(typeof R!=="function")return z("expecting a function but got "+Y.classString(R));return this.all()._then(R,void 0,void 0,w,void 0)},v.prototype.toJSON=function(){var R={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};if(this.isFulfilled())R.fulfillmentValue=this.value(),R.isFulfilled=!0;else if(this.isRejected())R.rejectionReason=this.reason(),R.isRejected=!0;return R},v.prototype.all=function(){if(arguments.length>0)this._warn(".all() was passed arguments but it does not take any");return new F(this).promise()},v.prototype.error=function(R){return this.caught(Y.originatesFromRejection,R)},v.getNewLibraryCopy=Rf.exports,v.is=function(R){return R instanceof v},v.fromNode=v.fromCallback=function(R){var u=new v(X);u._captureStackTrace();var p=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,s=b(R)(f(u,p));if(s===C)u._rejectCallback(s.e,!0);if(!u._isFateSealed())u._setAsyncGuaranteed();return u},v.all=function(R){return new F(R).promise()},v.cast=function(R){var u=O(R);if(!(u instanceof v))u=new v(X),u._captureStackTrace(),u._setFulfilled(),u._rejectionHandler0=R;return u},v.resolve=v.fulfilled=v.cast,v.reject=v.rejected=function(R){var u=new v(X);return u._captureStackTrace(),u._rejectCallback(R,!0),u},v.setScheduler=function(R){if(typeof R!=="function")throw new Z("expecting a function but got "+Y.classString(R));return H.setScheduler(R)},v.prototype._then=function(R,u,p,s,U0){var H0=U0!==void 0,D0=H0?U0:new v(X),_0=this._target(),Y1=_0._bitField;if(!H0){if(D0._propagateFrom(this,3),D0._captureStackTrace(),s===void 0&&(this._bitField&2097152)!==0)if((Y1&50397184)!==0)s=this._boundValue();else s=_0===this?void 0:this._boundTo;this._fireEvent("promiseChained",this,D0)}var u0=J();if((Y1&50397184)!==0){var r0,I1,o=_0._settlePromiseCtx;if((Y1&33554432)!==0)I1=_0._rejectionHandler0,r0=R;else if((Y1&16777216)!==0)I1=_0._fulfillmentHandler0,r0=u,_0._unsetRejectionIsUnhandled();else o=_0._settlePromiseLateCancellationObserver,I1=new W("late cancellation observer"),_0._attachExtraTrace(I1),r0=u;H.invoke(o,_0,{handler:u0===null?r0:typeof r0==="function"&&Y.domainBind(u0,r0),promise:D0,receiver:s,value:I1})}else _0._addCallbacks(R,u,D0,s,u0);return D0},v.prototype._length=function(){return this._bitField&65535},v.prototype._isFateSealed=function(){return(this._bitField&117506048)!==0},v.prototype._isFollowing=function(){return(this._bitField&67108864)===67108864},v.prototype._setLength=function(R){this._bitField=this._bitField&-65536|R&65535},v.prototype._setFulfilled=function(){this._bitField=this._bitField|33554432,this._fireEvent("promiseFulfilled",this)},v.prototype._setRejected=function(){this._bitField=this._bitField|16777216,this._fireEvent("promiseRejected",this)},v.prototype._setFollowing=function(){this._bitField=this._bitField|67108864,this._fireEvent("promiseResolved",this)},v.prototype._setIsFinal=function(){this._bitField=this._bitField|4194304},v.prototype._isFinal=function(){return(this._bitField&4194304)>0},v.prototype._unsetCancelled=function(){this._bitField=this._bitField&-65537},v.prototype._setCancelled=function(){this._bitField=this._bitField|65536,this._fireEvent("promiseCancelled",this)},v.prototype._setWillBeCancelled=function(){this._bitField=this._bitField|8388608},v.prototype._setAsyncGuaranteed=function(){if(H.hasCustomScheduler())return;this._bitField=this._bitField|134217728},v.prototype._receiverAt=function(R){var u=R===0?this._receiver0:this[R*4-4+3];if(u===U)return;else if(u===void 0&&this._isBound())return this._boundValue();return u},v.prototype._promiseAt=function(R){return this[R*4-4+2]},v.prototype._fulfillmentHandlerAt=function(R){return this[R*4-4+0]},v.prototype._rejectionHandlerAt=function(R){return this[R*4-4+1]},v.prototype._boundValue=function(){},v.prototype._migrateCallback0=function(R){var{_bitFie
Line truncated
`)}function g(j){if(this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,j!==X)n(this,j),this._resolveFromExecutor(j);this._promiseCreated(),this._fireEvent("promiseCreated",this)}g.prototype.toString=function(){return"[object Promise]"},g.prototype.caught=g.prototype.catch=function(j){var u=arguments.length;if(u>1){var p=Array(u-1),d=0,Y0;for(Y0=0;Y0<u-1;++Y0){var t=arguments[Y0];if(I.isObject(t))p[d++]=t;else return Y("expecting an object but got A catch statement predicate "+I.classString(t))}return p.length=d,j=arguments[Y0],this.then(void 0,v(p,j,this))}return this.then(void 0,j)},g.prototype.reflect=function(){return this._then(q,q,void 0,this,void 0)},g.prototype.then=function(j,u){if(P.warnings()&&arguments.length>0&&typeof j!=="function"&&typeof u!=="function"){var p=".then() only accepts functions but was passed: "+I.classString(j);if(arguments.length>1)p+=", "+I.classString(u);this._warn(p)}return this._then(j,u,void 0,void 0,void 0)},g.prototype.done=function(j,u){var p=this._then(j,u,void 0,void 0,void 0);p._setIsFinal()},g.prototype.spread=function(j){if(typeof j!=="function")return Y("expecting a function but got "+I.classString(j));return this.all()._then(j,void 0,void 0,w,void 0)},g.prototype.toJSON=function(){var j={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};if(this.isFulfilled())j.fulfillmentValue=this.value(),j.isFulfilled=!0;else if(this.isRejected())j.rejectionReason=this.reason(),j.isRejected=!0;return j},g.prototype.all=function(){if(arguments.length>0)this._warn(".all() was passed arguments but it does not take any");return new O(this).promise()},g.prototype.error=function(j){return this.caught(I.originatesFromRejection,j)},g.getNewLibraryCopy=df.exports,g.is=function(j){return j instanceof g},g.fromNode=g.fromCallback=function(j){var u=new g(X);u._captureStackTrace();var p=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,d=c(j)(k(u,p));if(d===R)u._rejectCallback(d.e,!0);if(!u._isFateSealed())u._setAsyncGuaranteed();return u},g.all=function(j){return new O(j).promise()},g.cast=function(j){var u=F(j);if(!(u instanceof g))u=new g(X),u._captureStackTrace(),u._setFulfilled(),u._rejectionHandler0=j;return u},g.resolve=g.fulfilled=g.cast,g.reject=g.rejected=function(j){var u=new g(X);return u._captureStackTrace(),u._rejectCallback(j,!0),u},g.setScheduler=function(j){if(typeof j!=="function")throw new Z("expecting a function but got "+I.classString(j));return H.setScheduler(j)},g.prototype._then=function(j,u,p,d,Y0){var t=Y0!==void 0,H0=t?Y0:new g(X),w0=this._target(),T0=w0._bitField;if(!t){if(H0._propagateFrom(this,3),H0._captureStackTrace(),d===void 0&&(this._bitField&2097152)!==0)if((T0&50397184)!==0)d=this._boundValue();else d=w0===this?void 0:this._boundTo;this._fireEvent("promiseChained",this,H0)}var R0=J();if((T0&50397184)!==0){var E0,i0,Q0=w0._settlePromiseCtx;if((T0&33554432)!==0)i0=w0._rejectionHandler0,E0=j;else if((T0&16777216)!==0)i0=w0._fulfillmentHandler0,E0=u,w0._unsetRejectionIsUnhandled();else Q0=w0._settlePromiseLateCancellationObserver,i0=new V("late cancellation observer"),w0._attachExtraTrace(i0),E0=u;H.invoke(Q0,w0,{handler:R0===null?E0:typeof E0==="function"&&I.domainBind(R0,E0),promise:H0,receiver:d,value:i0})}else w0._addCallbacks(j,u,H0,d,R0);return H0},g.prototype._length=function(){return this._bitField&65535},g.prototype._isFateSealed=function(){return(this._bitField&117506048)!==0},g.prototype._isFollowing=function(){return(this._bitField&67108864)===67108864},g.prototype._setLength=function(j){this._bitField=this._bitField&-65536|j&65535},g.prototype._setFulfilled=function(){this._bitField=this._bitField|33554432,this._fireEvent("promiseFulfilled",this)},g.prototype._setRejected=function(){this._bitField=this._bitField|16777216,this._fireEvent("promiseRejected",this)},g.prototype._setFollowing=function(){this._bitField=this._bitField|67108864,this._fireEvent("promiseResolved",this)},g.prototype._setIsFinal=function(){this._bitField=this._bitField|4194304},g.prototype._isFinal=function(){return(this._bitField&4194304)>0},g.prototype._unsetCancelled=function(){this._bitField=this._bitField&-65537},g.prototype._setCancelled=function(){this._bitField=this._bitField|65536,this._fireEvent("promiseCancelled",this)},g.prototype._setWillBeCancelled=function(){this._bitField=this._bitField|8388608},g.prototype._setAsyncGuaranteed=function(){if(H.hasCustomScheduler())return;this._bitField=this._bitField|134217728},g.prototype._receiverAt=function(j){var u=j===0?this._receiver0:this[j*4-4+3];if(u===U)return;else if(u===void 0&&this._isBound())return this._boundValue();return u},g.prototype._promiseAt=function(j){return this[j*4-4+2]},g.prototype._fulfillmentHandlerAt=function(j){return this[j*4-4+0]},g.prototype._rejectionHandlerAt=function(j){return this[j*4-4+1]},g.prototype._boundValue=function(){},g.prototype._migrateCallback0=function(j){var{_bitField:u
Line truncated
↳${w}`,operator:I}}function $P0($){if(!$)return[];let q=$.pending||[],Y=String($.rawState||"").toUpperCase(),z=String($.state||"").toUpperCase(),U=[];if(q.length>0)for(let I of q){let J=I.approver?.name||I.approver?.id||"待定",Q=(I.name||$.currentNode||"").trim(),K=Q?`${Q}(${J})`:J,G=I.type?.toUpperCase()==="PAYING"||Q.includes("支付")||Y==="PAYING"||z==="支付中"?"待支付":"待审批";U.push(`${K}:${G}`)}else if($.currentNode?.trim()){let J=$.currentNode.includes("支付")||Y==="PAYING"||z==="支付中"?"待支付":"待审批";U.push(`${$.currentNode.trim()}:${J}`)}return U}function tq($,q){let Y=new Map;if(!$||$.length===0)return Y;if(!q){for(let X of $){let L=(X.result||{}).decision||X.aiDecision||"-";Y.set(X.id,{recordId:X.id,sourceDocumentSN:X.sourceDocumentSN,taskMode:X.taskMode,aiDecision:eA0(typeof L==="string"?L:"-"),aiAction:"-",eHumanAction:"-",eHumanComment:"-",auditDrift:!1})}return Y}let z=[...$].sort((X,w)=>(Number(X.createdAt)||0)-(Number(w.createdAt)||0)),U=q.history||[],I=String(q.rawState||"").toUpperCase(),J=String(q.state||"").toUpperCase(),Q=I==="DRAFT"||I==="REVOKED"||I==="CANCELED"||I==="CANCELLED"||J==="草稿"||J==="已撤回"||J==="已取消",K=I==="REJECTED"||I==="TERMINATED"||J==="审批驳回"||J==="已驳回",H=!Q&&!K&&(I==="PAID"||J==="已支付"||U.some((X)=>!X.isEbot&&(X.rawAction==="freeflow.pay"||X.action==="支付成功"||X.action==="支付完成"))),G=!Q&&!K&&!H&&(I==="PAYING"||J==="支付中"||(q.pending||[]).some((X)=>X.isCurrent&&(X.type?.toUpperCase()==="PAYING"||X.name?.includes("支付")))||q.currentNode?.includes("支付")===!0),V=H||!Q&&!K&&!G&&(I==="COMPLETED"||I==="APPROVED"||J==="已完成"||J==="审批通过");for(let X=0;X<z.length;X++){let w=z[X];if(!w)continue;let L=Number(w.createdAt)||0,F=w.document||{},O=w.manualApprovalRecord||w.result?.manualApprovalRecord||F.manualApprovalRecord||{},A=typeof w.sourceExtendData?.nodeId==="string"?String(w.sourceExtendData.nodeId):void 0,B=typeof O.nodeId==="string"?String(O.nodeId):void 0,P=B?decodeURIComponent(B).replace(/^hcnode_/,"").replace(/_r\d+$/,""):void 0,T=A||P,y=T?U.find((L0)=>L0.nodeId&&(L0.nodeId===T||T.includes(L0.nodeId))):void 0,v=y?.time??L,k=z[X+1],R=k?Number(k.createdAt)||1/0:1/0,c=X===z.length-1,n=U.find((L0)=>(L0.time??0)>v+5000&&L0.isEbot&&(L0.nodeName?.includes("智能")||L0.nodeName?.includes("AI")||L0.action?.includes("智能")||L0.comment?.includes("AI")||L0.comment?.includes("approval-result"))&&!L0.nodeName?.includes("费用标准检查")&&!L0.nodeName?.includes("标准检查")&&!L0.nodeName?.includes("预算"));if(n){if(c=!1,(n.time??1/0)<R)R=n.time}let g=w.result||{},b=g.decision||w.aiDecision||"-",i=typeof b==="string"?b:"-",$0=i.toUpperCase(),j=$0==="REJECT"||$0==="驳回",u=$0==="APPROVE"||$0==="通过",p=$0==="EXEMPT_APPROVE"||$0==="免审通过"||$0==="备注通过",d=w.taskMode||w.finalExecutionMode||"",t=String(d).toLowerCase().includes("auto")||w.finalExecutionMode==="automatic"||d==="automatic"||d==="fully_automatic",H0="-";if(u||p)H0="添加评论";else if(j)H0=t?"驳回":"添加评论";else if($0==="REVIEW"||$0==="转交复核")H0="转交复核";let w0=typeof O.status==="object"&&O.status!==null?String(O.status.type||O.status.label||"").toUpperCase():"",T0=typeof O.status==="object"&&O.status!==null?String(O.status.sourceStatus||""):"",R0=F.manualApprovalStatus||g.manualApprovalStatus||w.manualApprovalStatus,E0=typeof R0==="string"?R0.toUpperCase():"",i0=E0==="CANCELLED"||E0==="CANCELED"||E0==="已取消"||E0==="已撤回"||E0==="REVOKED"||w0==="CANCELLED"||w0==="CANCELED"||T0.includes("撤回")||T0.includes("取消"),Q0=E0==="APPROVED"||E0==="已支付/审批完成"||E0==="已通过"||E0==="已完成"||E0==="已支付"||w0==="APPROVED",f0=!(T0.includes("补偿")||T0.includes("已支付"))&&(E0==="TERMINATED"||E0==="REJECTED"||E0==="REJECT"||E0==="已驳回"||E0==="被驳回"||w0==="TERMINATED"||w0==="REJECTED"||w0==="已驳回"||w0==="被驳回"),c0=y?1000:60000,R1=U.filter((L0)=>{let o=L0.time??0;return o>=v-c0&&o<R}),a0="-",r1="-",F1=!1,b1,$1,U6=u||p,a8=U.filter((L0)=>(L0.time??0)>v+5000),I6=a8.some((L0)=>L0.rawAction==="freeflow.retract"||L0.action==="单据撤回"),e8=a8.some((L0)=>L0.rawAction==="freeflow.submit"||L0.action==="提交送审");if(U6&&c&&(I6||e8))F1=!0,b1="AI通过后单据发生撤回/修改重提,后续未经AI复审";if(t&&j)a0="无操作",r1="-";else{let L0=R1.filter((D)=>(D.time??0)>=v-1000&&!D.isEbot&&D.rawAction!=="freeflow.submit"&&D.action!=="提交送审"&&!((D.rawAction==="freeflow.comment"||D.action==="发表评论")&&!D.comment)&&!((D.rawAction==="freeflow.print"||D.action==="打印提醒")&&!D.comment)&&!(D.rawAction==="freeflow.carbonCopy"||D.rawAction==="freeflow.cc"||D.action==="抄送通知")),o=L0.find((D)=>D.rawAction==="freeflow.retract"||D.action==="单据撤回"),N=L0.find((D)=>D.rawAction==="freeflow.reject"||D.action==="审批驳回");if(!c)if(N||!q&&f0){a0="审批驳回",F1=!1,b1=void 0;let D=Pi(N,void 0,O,U,q);
Line truncated
`,{mode:384}),q}function ki($){let q=MP0();for(let Y of q){if(!X$(Y))continue;for(let z of HD(Y).filter((U)=>U.endsWith(".json")).filter((U)=>!U.startsWith("example."))){let U=J9(Y,z);try{let I=ZD(U,"utf-8"),J=JSON.parse(I);if(J&&typeof J==="object"&&J.id===$)return U}catch{}}}return}function a7($,q){let Y=ki($);if(!Y)throw Error(`Enterpriseconfignotfound:${$}`);let U={...JSON.parse(ZD(Y,"utf-8")),...q};for(let J of Object.keys(q))if(q[J]===void 0)delete U[J];let I=gi.parse(U);return XP0(Y,`${JSON.stringify(I,null,2)}
`,"utf-8"),I}var yi="SEAL_USE_ENTERPRISES_DIR",VP0="SEAL_HOME_ENTERPRISES_DIR",wP0="SEAL_USE_USER_ENTERPRISES_DIR",LP0="SEAL_HOME_USER_ENTERPRISES_DIR",FP0="SEAL_USE_CONFIG_FILE",OP0="SEAL_HOME_CONFIG_FILE",iI,GD,KD,ZP0;var Q3=e(()=>{Si();iI=J9(WD(),".config","seal-use","enterprises"),GD=J9(WD(),".config","seal-home","enterprises"),KD=J9(WD(),".config","seal-use","config.json"),ZP0=J9(WD(),".config","seal-home","config.json")});function e7($,q,Y=[]){let z=q.corpId?.trim()||void 0,U=q.stateful?q.defaultCorpId?.trim()||void 0:void 0,I=z??U;if(I){let Q=$.find((G)=>G.id===I);if(Q)return Q;let K=$.find((G)=>G.id.toLowerCase()===I.toLowerCase());if(K)return K;let H=$.find((G)=>G.name.toLowerCase()===I.toLowerCase());if(H)return H;throw Error(`Noenterpriseconfigfoundfor${I}`)}if(!q.stateful)throw Error("Stateless mode is enabled. Every enterprise command requires --corp <corpId>. Use `seal-homeconfigmodestateful` to enable a default enterprise.");let J=$[0];if(J)return J;throw Error("No enterprise config found. Add a non-example JSON file under one of: "+(Y.length?Y.join(", "):"the configured enterprise directories"))}import{existsSync as ui,mkdirSync as Qj1,readFileSync as Kj1,renameSync as Hj1,unlinkSync as Gj1,writeFileSync as Zj1}from"node:fs";import{homedir as Wj1}from"node:os";import{dirname as Xj1,join as Vj1}from"node:path";function bi(){let $=process.env[wj1]?.trim();if($)return $;return Lj1}function NP0($=new Date){return $.toISOString().slice(0,10)}function DP0($=fi,q=new Date){let Y=q.getTime()-Math.max(0,$-1)*86400000;return new Date(Y).toISOString().slice(0,10)}function AP0($=bi()){if(!ui($))return{};try{let q=Kj1($,"utf-8"),Y=JSON.parse(q);if(Y&&typeof Y==="object"&&!Array.isArray(Y))return Y;return{}}catch{return{}}}function Fj1($,q){let Y={};for(let[z,U]of Object.entries($)){if(!U||typeof U!=="object")continue;let I={},J=!1;for(let[Q,K]of Object.entries(U))if(typeof K==="number"&&K>0&&Q>=q)I[Q]=K,J=!0;if(J)Y[z]=I}return Y}function Oj1($,q=bi()){let Y=Xj1(q);if(!ui(Y))Qj1(Y,{recursive:!0,mode:448});let z=`${q}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2,8)}.tmp`;try{Zj1(z,JSON.stringify($,null,2),"utf-8"),Hj1(z,q)}catch(U){try{if(ui(z))Gj1(z)}catch{}throw U}}function PP0($,q=new Date){if(!$||typeof $!=="string")return;try{let Y=bi(),z=AP0(Y),U=NP0(q),I=DP0(fi,q),J=Fj1(z,I);J[$]=J[$]||{},J[$][U]=(J[$][U]??0)+1,Oj1(J,Y)}catch{}}function Mj1($,q=fi,Y=new Date){let z=new Map;try{let U=AP0(),I=DP0(q,Y),J=NP0(Y),Q=$??Object.keys(U);for(let K of Q){let H=U[K];if(!H){z.set(K,0);continue}let G=0;for(let[Z,V]of Object.entries(H))if(Z>=I&&Z<=J&&typeof V==="number")G+=V;z.set(K,G)}}catch{if($)for(let U of $)z.set(U,0)}return z}function BP0($,q,Y){let z=Y??Mj1($.map((U)=>U.id));return[...$].sort((U,I)=>{if(q){if(U.id===q&&I.id!==q)return-1;if(I.id===q&&U.id!==q)return 1}let J=z.get(U.id)??0,Q=z.get(I.id)??0;if(J!==Q)return Q-J;let K=U.name??U.id,H=I.name??I.id,G=K.localeCompare(H,"zh-CN");if(G!==0)return G;return U.id.localeCompare(I.id)})}var wj1="SEAL_USE_USAGE_FILE",Lj1,fi=7;var ii=e(()=>{Lj1=Vj1(Wj1(),".config","seal-use","usage.json")});function Nj1($,q){return $.map((Y)=>Y.trim()).filter(Boolean).map((Y)=>q?Y:Y.toLowerCase())}function Dj1($,q){return q?$:$.toLowerCase()}function Aj1($,q,Y,z){let U=Dj1($,z),I=q.filter((J)=>U.includes(J));if(Y==="all"&&I.length!==q.length)return[];return I}function Pj1($){if(typeof $==="string")return $.split(/\r?\n/);return JSON.stringify($,null,2).split(/\r?\n/)}function Bj1($,q){if(q.fields&&!q.fields.has($.field))return[];let Y=Pj1($.value),z=[];return Y.forEach((U,I)=>{let J=Aj1(U,q.keywords,q.matchMode,q.caseSensitive);if(J.length===0)return;let Q=Math.max(0,I-q.contextLines),K=Math.min(Y.length,I+q.contextLines+1),H={area:$.area,entityType:$.entityType,entityId:$.entityId,title:$.title,field:$.field,lineNumber:I+1,matchedKeywords:J,matchedText:XD(U,q.maxChars),context:{before:q.snippetOnly?[]:Y.slice(Q,I).map((G)=>XD(G,q.maxChars)),line:XD(U,q.maxChars),after:q.snippetOnly?[]:Y.slice(I+1,K).map((G)=>XD(G,q.maxChars))},metadata:$.metadata};if(q.snippetOnly)H.context={before:[],line:H.context.line,after:[]};z.push(H)}),z}function XD($,q){if(!q||$.length<=q)return $;return`${$.slice(0,Math.max(0,q))}...`}function Tj1($){return[{area:"rules",entityType:"rule",entityId:$.id,title:$.scope,field:"description",value:$.description,metadata:{scope:$.scope,strictness:$.strictness,status:$.status}},{area:"rules",entityType:"rule",entityId:$.id,title:$.scope,field:"scope",value:$.scope,metadata:{strictness:$.strictness,status:$.status}}]}function EP0($){return $.rules.flatMap((q,Y)=>{let z=`${$.id}:${q.description.slice(0,32)}`,U={versionId:$.id,versionNumber:$.versionNumber,versionName:$.versionName,publishedByName:$.publishedByName,publishedAt:$.publishedAt,scope:q.scope,strictness:q.strictness,code:"code"in q?q.code:void 0,index:Y};return[{area:"rules",entityType:"rule",entityId:z,title:`${$.versionName}/${q.scope}`,field:"history.description",
Line truncated
@@ -866,55 +870,55 @@ export function lintRule(rule: RuleLintTarget): RuleLintResult {
}
exportdefaultlintRule;
`}});import{existsSync as oI,mkdirSync as vE1,readFileSync as hE1,readdirSync as tA0,rmSync as gE1,unlinkSync as SE1,writeFileSync as yE1}from"node:fs";import{homedir as xE1}from"node:os";import{isAbsolute as uE1,join as A6,resolve as kE1}from"node:path";import{pathToFileURL as rA0}from"node:url";function aA0($=x$){let I=[],z=[];try{if(!oI($))vE1($,{recursive:!0});let q=Object.keys(Pi);for(let[Y,J]of Object.entries(Pi)){let Q=A6($,Y),K=!0;if(oI(Q))try{if(hE1(Q,"utf8")===J)K=!1}catch{K=!0}if(K)yE1(Q,J,"utf8");I.push(Y)}let U=tA0($,{withFileTypes:!0});for(let Y of U)if(!q.includes(Y.name)){let J=A6($,Y.name);try{if(Y.isDirectory())gE1(J,{recursive:!0,force:!0});else SE1(J);z.push(Y.name)}catch{}}}catch{}return{synced:I,pruned:z}}function eA0($={syncOfficial:!0}){if($.syncOfficial!==!1)aA0();let I=[{name:"builtin",type:"builtin",path:A6(x$,"builtin.ts"),description:"Seal 官方标准校验器 (拦截过短描述、主观模糊词与悬空例外条款)"},{name:"strict",type:"official",path:A6(x$,"strict.ts"),description:"Seal 官方严格风控校验器 (强校验字数、刚性定量约束、凭证依据与具体审批人角色)"},{name:"hlab",type:"official",path:A6(x$,"hlab.ts"),description:"合思实验室 (HLab) 结构化规则校验器 (SOP 四段论结构、三元闭环判定、剥离处置动作与防漏判)"}],z=[y$,YD];for(let q of z)if(oI(q))try{let U=tA0(q,{withFileTypes:!0});for(let Y of U){if(Y.isDirectory())continue;let J=Y.name;if(J.endsWith(".ts")||J.endsWith(".js")||J.endsWith(".mjs")){let Q=J.replace(/\.(ts|js|mjs)$/,"");if(!I.some((K)=>K.name===Q))I.push({name:Q,type:"custom",path:A6(q,J),description:`用户自定义规则校验器(${J})`})}}}catch{}return I}function bE1($){let I=($||"").trim();if(!I||I==="builtin"||I==="default"||I==="official/builtin"||I==="official/builtin.ts")return{path:A6(x$,"builtin.ts"),isOfficial:!0,officialKind:"builtin"};if(I==="strict"||I==="official/strict"||I==="official/strict.ts")return{path:A6(x$,"strict.ts"),isOfficial:!0,officialKind:"strict"};if(I==="hlab"||I==="hlab-sop"||I==="hlab-rules"||I==="hlab-standard"||I==="official/hlab"||I==="official/hlab.ts")return{path:A6(x$,"hlab.ts"),isOfficial:!0,officialKind:"hlab"};if(uE1(I)||I.startsWith("./")||I.startsWith("../")){let q=kE1(I);if(oI(q))return{path:q};for(let U of[".ts",".js",".mjs"])if(oI(`${q}${U}`))return{path:`${q}${U}`}}let z=[A6(y$,`${I}.ts`),A6(y$,`${I}.js`),A6(y$,`${I}.mjs`),A6(YD,`${I}.ts`),A6(YD,`${I}.js`),A6(YD,`${I}.mjs`)];for(let q of z)if(oI(q))return{path:q};return{}}async function Ti($){aA0();let I=bE1($??"builtin");if(I.isOfficial){let q=I.officialKind==="strict"?lA0:I.officialKind==="hlab"?oA0:hY,U=I.officialKind==="builtin"?"builtin":"official",Y=I.path;if(Y&&oI(Y))try{let Q=await import(rA0(Y).href),K=Q.default??Q.lintRule??Q.linter??Q.lint;if(typeof K==="function")return{name:I.officialKind??"builtin",type:U,filePath:Y,linter:sA0(K,q)}}catch{}return{name:I.officialKind??"builtin",type:U,filePath:Y,linter:q}}let z=I.path;if(!z)return console.error(`⚠️[linter]未找到自定义校验器"${$}",已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:hY};try{let U=await import(rA0(z).href),Y=U.default??U.lintRule??U.linter??U.lint;if(typeof Y!=="function")return console.error(`⚠️[linter]自定义校验器"${z}"未导出标准函数(default/lintRule),已安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:hY};return{name:$??"custom",type:"custom",filePath:z,linter:sA0(Y,hY)}}catch(q){returnconsole.error(`⚠️[linter]加载自定义校验器脚本"${z}"失败(语法错误或依赖缺失:${q?.message??q}),已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:hY}}}functionsA0($,I){returnasync(z,q)=>{try{letU=await$(z,q);if(U&&typeofU==="object"&&typeofU.score==="number"&&Array.isArray(U.issues))returnU;returnconsole.error("⚠️[linter]自定义校验器返回值格式不符合RuleLintResult契约,已回退至内置结果。"),I(z,q)}catch(U){returnconsole.error("⚠️[linter]自定义校验器执行异常:",U),I(z,q)}}}vary$,fE1="official",x$,YD;varEi=e(()=>{Ni();Ai();Bi();Di();y$=A6(xE1(),".config","seal-use","linters"),x$=A6(y$,fE1),YD=A6(process.cwd(),"linters")});asyncfunctionji($,I,z){letq=awaitI.linter($,z);return{ruleId:$.id,ruleCode:$.code,ruleName:$.name,score:q.score,passed:q.passed,issues:q.issues,description:$.description}}asyncfunction$P0($,I,z,q){letU=q?.minScore??0,Y=q?.level??"all",J=[],Q=0;for(letXof$){letw=awaitji(X,I,z);Q+=w.score;letL=w.issues;if(Y==="error")L=w.issues.filter((F)=>F.level==="error");elseif(Y==="warning")L=w.issues.filter((F)=>F.level==="warning"||F.level==="error");letO=L.every((F)=>F.level!=="error");if(q?.summary){if(L.length>0)J.push({...w,passed:O,issues:L})}elseJ.push({...w,passed:O,issues:L})}letK=$.length,H=K===0?100:Math.round(Q/K),G=J.filter((X)=>X.issues.length>0).length,Z=K-Line truncated
`}});import{existsSync as $Y,mkdirSync as tj1,readFileSync as aj1,readdirSync as uP0,rmSync as ej1,unlinkSync as $_1,writeFileSync as q_1}from"node:fs";import{homedir as Y_1}from"node:os";import{isAbsolute as z_1,join as R6,resolve as U_1}from"node:path";import{pathToFileURL as xP0}from"node:url";function fP0($=i$){let q=[],Y=[];try{if(!$Y($))tj1($,{recursive:!0});let z=Object.keys(oi);for(let[I,J]of Object.entries(oi)){let Q=R6($,I),K=!0;if($Y(Q))try{if(aj1(Q,"utf8")===J)K=!1}catch{K=!0}if(K)q_1(Q,J,"utf8");q.push(I)}let U=uP0($,{withFileTypes:!0});for(let I of U)if(!z.includes(I.name)){let J=R6($,I.name);try{if(I.isDirectory())ej1(J,{recursive:!0,force:!0});else $_1(J);Y.push(I.name)}catch{}}}catch{}return{synced:q,pruned:Y}}function bP0($={syncOfficial:!0}){if($.syncOfficial!==!1)fP0();let q=[{name:"builtin",type:"builtin",path:R6(i$,"builtin.ts"),description:"Seal 官方标准校验器 (拦截过短描述、主观模糊词与悬空例外条款)"},{name:"strict",type:"official",path:R6(i$,"strict.ts"),description:"Seal 官方严格风控校验器 (强校验字数、刚性定量约束、凭证依据与具体审批人角色)"},{name:"hlab",type:"official",path:R6(i$,"hlab.ts"),description:"合思实验室 (HLab) 结构化规则校验器 (SOP 四段论结构、三元闭环判定、剥离处置动作与防漏判)"}],Y=[b$,OD];for(let z of Y)if($Y(z))try{let U=uP0(z,{withFileTypes:!0});for(let I of U){if(I.isDirectory())continue;let J=I.name;if(J.endsWith(".ts")||J.endsWith(".js")||J.endsWith(".mjs")){let Q=J.replace(/\.(ts|js|mjs)$/,"");if(!q.some((K)=>K.name===Q))q.push({name:Q,type:"custom",path:R6(z,J),description:`用户自定义规则校验器(${J})`})}}}catch{}return q}function J_1($){let q=($||"").trim();if(!q||q==="builtin"||q==="default"||q==="official/builtin"||q==="official/builtin.ts")return{path:R6(i$,"builtin.ts"),isOfficial:!0,officialKind:"builtin"};if(q==="strict"||q==="official/strict"||q==="official/strict.ts")return{path:R6(i$,"strict.ts"),isOfficial:!0,officialKind:"strict"};if(q==="hlab"||q==="hlab-sop"||q==="hlab-rules"||q==="hlab-standard"||q==="official/hlab"||q==="official/hlab.ts")return{path:R6(i$,"hlab.ts"),isOfficial:!0,officialKind:"hlab"};if(z_1(q)||q.startsWith("./")||q.startsWith("../")){let z=U_1(q);if($Y(z))return{path:z};for(let U of[".ts",".js",".mjs"])if($Y(`${z}${U}`))return{path:`${z}${U}`}}let Y=[R6(b$,`${q}.ts`),R6(b$,`${q}.js`),R6(b$,`${q}.mjs`),R6(OD,`${q}.ts`),R6(OD,`${q}.js`),R6(OD,`${q}.mjs`)];for(let z of Y)if($Y(z))return{path:z};return{}}async function si($){fP0();let q=J_1($??"builtin");if(q.isOfficial){let z=q.officialKind==="strict"?SP0:q.officialKind==="hlab"?yP0:cI,U=q.officialKind==="builtin"?"builtin":"official",I=q.path;if(I&&$Y(I))try{let Q=await import(xP0(I).href),K=Q.default??Q.lintRule??Q.linter??Q.lint;if(typeof K==="function")return{name:q.officialKind??"builtin",type:U,filePath:I,linter:kP0(K,z)}}catch{}return{name:q.officialKind??"builtin",type:U,filePath:I,linter:z}}let Y=q.path;if(!Y)return console.error(`⚠️[linter]未找到自定义校验器"${$}",已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:cI};try{let U=await import(xP0(Y).href),I=U.default??U.lintRule??U.linter??U.lint;if(typeof I!=="function")return console.error(`⚠️[linter]自定义校验器"${Y}"未导出标准函数(default/lintRule),已安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:cI};return{name:$??"custom",type:"custom",filePath:Y,linter:kP0(I,cI)}}catch(z){returnconsole.error(`⚠️[linter]加载自定义校验器脚本"${Y}"失败(语法错误或依赖缺失:${z?.message??z}),已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:cI}}}functionkP0($,q){returnasync(Y,z)=>{try{letU=await$(Y,z);if(U&&typeofU==="object"&&typeofU.score==="number"&&Array.isArray(U.issues))returnU;returnconsole.error("⚠️[linter]自定义校验器返回值格式不符合RuleLintResult契约,已回退至内置结果。"),q(Y,z)}catch(U){returnconsole.error("⚠️[linter]自定义校验器执行异常:",U),q(Y,z)}}}varb$,I_1="official",i$,OD;varti=e(()=>{di();li();ri();mi();b$=R6(Y_1(),".config","seal-use","linters"),i$=R6(b$,I_1),OD=R6(process.cwd(),"linters")});asyncfunctionai($,q,Y){letz=awaitq.linter($,Y);return{ruleId:$.id,ruleCode:$.code,ruleName:$.name,score:z.score,passed:z.passed,issues:z.issues,description:$.description}}asyncfunctioniP0($,q,Y,z){letU=z?.minScore??0,I=z?.level??"all",J=[],Q=0;for(letXof$){letw=awaitai(X,q,Y);Q+=w.score;letL=w.issues;if(I==="error")L=w.issues.filter((O)=>O.level==="error");elseif(I==="warning")L=w.issues.filter((O)=>O.level==="warning"||O.level==="error");letF=L.every((O)=>O.level!=="error");if(z?.summary){if(L.length>0)J.push({...w,passed:F,issues:L})}elseJ.push({...w,passed:F,issues:L})}letK=$.length,H=K===0?100:Math.round(Q/K),G=J.filter((X)=>X.issues.length>0).length,Z=K-Line truncated
`),q=await Promise.all(P.map((A)=>z4($,A.id)))}let U=new Map,Y=0;for(let F of q){let D=F.document,P=F.sourceDocumentId??(typeof D?.id==="string"?D.id:void 0)??(typeof D?.sourceDocumentId==="string"?D.sourceDocumentId:void 0)??F.documentId??F.id,A=`${z.docIdPrefix??""}${P}${z.docIdSuffix??""}`,T=[];if(z.includeAttachments!==!1){let h=d7(F,{summary:!1}).attachments,f=new Set;for(let C of h){let b=C.ossSignedUrl??C.url;if(!b)continue;let i=C.fileName??C.fileId??"attachment",v=Yi(i),y=v,c=v.lastIndexOf("."),$0=c>0?v.slice(0,c):v,R=c>0?v.slice(c):"",u=1;while(f.has(y.toLowerCase()))y=`${$0}_${u}${R}`,u++;f.add(y.toLowerCase());try{process.stderr.write(`⬇下载单据「${A}」附件:${i}...
`),await new Promise((F,D)=>{let P=wu1(w),A=new Np({zlib:{level:9}});P.on("close",()=>F()),A.on("error",(T)=>D(T)),A.pipe(P),A.append(Buffer.from(L),{name:"信息表.xlsx"});for(let T of U.values())for(let k of T)A.append(k.buffer,{name:k.zipPath});A.finalize()});let O=Ou1(w);return{filePath:w,corpId:I.id,corpName:I.name,recordCount:q.length,attachmentCount:Y,fileSizeBytes:O.size,exportedAt:new Date().toISOString(),nextAction:`seal-usewebhookresource-packpush${w}--corp<targetCorpId>`}}var YR0;var Dp=e(()=>{qR0();e4();lN();YR0=j4(QZ(),1)});import{readFileSync as Au1}from"node:fs";function Pu1($){let I=new URL($),z=I.pathname.match(/\/webhook\/([^/]+)/);if(!z)throw Error("Webhook URL 必须包含 /webhook/{webhookId}/document");return{baseUrl:`${I.protocol}//${I.host}`,webhookId:z[1]}}function Bu1($,I){return I.toLowerCase().endsWith(".zip")||$[0]===80&&$[1]===75&&!I.toLowerCase().endsWith(".xlsx")}function Tu1($,I){if(!$.length)return;let z=new Set($.map((Y)=>{let J=Y.fileName.split("/")[0],Q=J.indexOf("@");return Q>=0?J.slice(0,Q):J}).filter((Y)=>Y!=="信息表.xlsx")),q=[];for(let Y of I){let J=Y.document.documentId;if((Y.documentAttachments.length>0||Object.values(Y.expenseAttachments).some((K)=>K.length>0)||Object.values(Y.personAttachments).some((K)=>K.length>0))&&!z.has(J))q.push(`Excel 会议编号「${J}」声明了附件,但在 ZIP 中找不到对应的根目录「${J}/」或「${J}@.../」。`)}let U=new Set(I.map((Y)=>Y.document.documentId));for(let Y of z)if(!U.has(Y))q.push(`ZIP 根目录对应的编号「${Y}」在信息表中找不到对应的会议编号。`);if(q.length)throw new W5(q)}async function JR0($,I,z){let q=[],U=$;if(Bu1($,I)){q=await LB0($),FB0(q,z);let K=q.find((H)=>H.fileName==="信息表.xlsx");if(!K)throw Error("ZIP 根目录缺少信息表.xlsx");U=await Nn($,K)}let Y=await TB0(U);Tu1(q,Y);let J=EB0(q,Y),Q=Y.map((K)=>K.document);return{entries:q,parsed:Y,plans:J,documents:Q,fileBuffer:$}}async function wz($,I,z){let q=await JR0($,I,z),U=q.parsed.map((Y,J)=>En(Y.document,q.plans[J],new Map));return{warnings:[],documents:U,attachmentPlan:q.plans}}async function LA($,I,z){let q=await JR0($,I,z.materialPackFilePolicy),{baseUrl:U,webhookId:Y}=Pu1(z.webhookUrl),J=[];for(let Q=0;Q<q.parsed.length;Q+=1){let K=q.parsed[Q],H=q.plans[Q],G=new Map,Z=[...H.categoryFields,...Object.values(H.personAttachments).flat(),...Object.values(H.expenseAttachments).flat()];for(let w of Z)for(let L of w.paths){if(G.has(L))continue;let O=q.entries.find((k)=>k.fileName===L);if(!O)continue;process.stderr.write(`⬆ 上传附件: ${L}
`),z=await Promise.all(B.map((P)=>e1($,P.id)))}let U=new Map,I=0;for(let O of z){let A=O.document,B=O.sourceDocumentId??(typeof A?.id==="string"?A.id:void 0)??(typeof A?.sourceDocumentId==="string"?A.sourceDocumentId:void 0)??O.documentId??O.id,P=`${Y.docIdPrefix??""}${B}${Y.docIdSuffix??""}`,T=[];if(Y.includeAttachments!==!1){let v=t7(O,{summary:!1}).attachments,k=new Set;for(let R of v){let c=R.ossSignedUrl??R.url;if(!c)continue;let n=R.fileName??R.fileId??"attachment",g=Ri(n),b=g,i=g.lastIndexOf("."),$0=i>0?g.slice(0,i):g,j=i>0?g.slice(i):"",u=1;while(k.has(b.toLowerCase()))b=`${$0}_${u}${j}`,u++;k.add(b.toLowerCase());try{process.stderr.write(`⬇下载单据「${P}」附件:${n}...
`),await new Promise((O,A)=>{let B=yu1(w),P=new dp({zlib:{level:9}});B.on("close",()=>O()),P.on("error",(T)=>A(T)),P.pipe(B),P.append(Buffer.from(L),{name:"信息表.xlsx"});for(let T of U.values())for(let y of T)P.append(y.buffer,{name:y.zipPath});P.finalize()});let F=ku1(w);return{filePath:w,corpId:q.id,corpName:q.name,recordCount:z.length,attachmentCount:I,fileSizeBytes:F.size,exportedAt:new Date().toISOString(),nextAction:`seal-usewebhookresource-packpush${w}--corp<targetCorpId>`}}var mR0;var mp=e(()=>{pR0();J6();JD();mR0=S4(FZ(),1)});import{readFileSync as nu1}from"node:fs";function cu1($){let q=new URL($),Y=q.pathname.match(/\/webhook\/([^/]+)/);if(!Y)throw Error("Webhook URL 必须包含 /webhook/{webhookId}/document");return{baseUrl:`${q.protocol}//${q.host}`,webhookId:Y[1]}}function pu1($,q){return q.toLowerCase().endsWith(".zip")||$[0]===80&&$[1]===75&&!q.toLowerCase().endsWith(".xlsx")}function du1($,q){if(!$.length)return;let Y=new Set($.map((I)=>{let J=I.fileName.split("/")[0],Q=J.indexOf("@");return Q>=0?J.slice(0,Q):J}).filter((I)=>I!=="信息表.xlsx")),z=[];for(let I of q){let J=I.document.documentId;if((I.documentAttachments.length>0||Object.values(I.expenseAttachments).some((K)=>K.length>0)||Object.values(I.personAttachments).some((K)=>K.length>0))&&!Y.has(J))z.push(`Excel 会议编号「${J}」声明了附件,但在 ZIP 中找不到对应的根目录「${J}/」或「${J}@.../」。`)}let U=new Set(q.map((I)=>I.document.documentId));for(let I of Y)if(!U.has(I))z.push(`ZIP 根目录对应的编号「${I}」在信息表中找不到对应的会议编号。`);if(z.length)throw new M5(z)}async function lR0($,q,Y){let z=[],U=$;if(pu1($,q)){z=await zT0($),IT0(z,Y);let K=z.find((H)=>H.fileName==="信息表.xlsx");if(!K)throw Error("ZIP 根目录缺少信息表.xlsx");U=await mn($,K)}let I=await WT0(U);du1(z,I);let J=XT0(z,I),Q=I.map((K)=>K.document);return{entries:z,parsed:I,plans:J,documents:Q,fileBuffer:$}}async function DY($,q,Y){let z=await lR0($,q,Y),U=z.parsed.map((I,J)=>an(I.document,z.plans[J],new Map));return{warnings:[],documents:U,attachmentPlan:z.plans}}async function CA($,q,Y){let z=await lR0($,q,Y.materialPackFilePolicy),{baseUrl:U,webhookId:I}=cu1(Y.webhookUrl),J=[];for(let Q=0;Q<z.parsed.length;Q+=1){let K=z.parsed[Q],H=z.plans[Q],G=new Map,Z=[...H.categoryFields,...Object.values(H.personAttachments).flat(),...Object.values(H.expenseAttachments).flat()];for(let w of Z)for(let L of w.paths){if(G.has(L))continue;let F=z.entries.find((y)=>y.fileName===L);if(!F)continue;process.stderr.write(`⬆ 上传附件: ${L}
`+"• 安全边界:该凭证绝不包含且无法访问合思 (Hose) 主系统;仅限内部排查,严禁在外部公开分享!")}return{url:I.sso?G:H,sealResultUrl:H,ssoUrl:G,type:I.sso?"sso_link":"deep_link",expiresIn:I.sso?X:void 0,identity:Z,warning:W,enterpriseAssistUrl:J,enterpriseUrl:J,hoseDomain:Y.type==="hose"?$k1(Y.domain):void 0,documentUrl:Q,recordId:U?.id,sourceDocumentSN:U?.sourceDocumentSN,sourceDocumentId:U?.sourceDocumentId,sourceSystem:U?.sourceSystem,missing:{enterpriseAssistUrl:J?void 0:"Current enterprise source is not Hose, so no Hose enterprise assist URL is configured.",documentUrl:q&&!Q?"sourceExtendData.hosecloudViewUrl is absent from the approval run detail.":void 0}}}},{name:"seal_approval_run_pick",description:"按合思单号或关键字查询运行记录,返回候选记录及其当时使用的规则版本,便于再取详情或查版本规则",parameters:V.object({query:V.string().optional().describe("合思单号、源单据 ID、运行记录 ID 或 trace 关键字"),sn:V.string().optional().describe("合思/易快报单号;优先作为精确 sourceDocumentSN 查询"),batchId:V.string().optional().describe("模拟批次 ID"),latest:V.boolean().optional().describe("只返回最新一条匹配记录"),fields:V.union([V.string(),V.array(V.string())]).optional().describe("限制返回字段"),limit:V.number().int().positive().max(100).optional(),maxScan:V.number().int().positive().max(5000).optional().describe("最多扫描多少条运行记录用于本地匹配,默认 1000"),includeBridge:V.boolean().optional()}),handler:async($,I)=>{let z=I.sn??I.query;if(!z)throw Error("query or sn is required");let q=await Ik1($,{query:z,sn:I.sn,batchId:I.batchId,latest:I.latest,limit:I.latest?1:I.limit??20,maxScan:I.maxScan??1000}),U=await Promise.all(q.records.map((Q)=>z4($,Q.id))),Y=WR0(I.fields),J=U.map((Q)=>tu1(Q,Y));return{query:z,sourceDocumentSN:I.sn,simulationBatchId:I.batchId,latest:I.latest??!1,total:q.total,scanned:q.scanned,matched:J.length,records:J,next:{getSummary:"seal-home approval-runs get <recordId> --summary",getRuleVersion:"seal-home rules version <ruleSetVersionNumber>",searchRuleVersion:`seal-hometoolseal_approval_search--json'{"keywords":["关键词"],"areas":["rules"],"ruleVersionScope":"version","ruleVersionNumber":14}'`,getVersionContext:`seal-hometoolseal_approval_context_get--json'{"ruleVersionNumber":14}'`},...I.includeBridge?{bridge:AA(U)}:{}}}},{name:"seal_simulation_batch_records_get",description:"获取某一次 Seal 模拟批次的运行记录,并整理对应 Langfuse trace/session 桥接字段",parameters:V.object({batchId:V.string().describe("simulation batch ID"),query:V.string().optional().describe("在 id、sourceDocumentSN、sourceDocumentId、documentId、Langfuse traceId 中做本地包含匹配")}),handler:async($,I)=>{let z=gp(await Nv($,I.batchId),I.query);return{batchId:I.batchId,count:z.length,records:z.map(Oz),bridge:AA(z)}}},{name:"seal_simulation_batch_create",description:"创建 Seal 模拟测试批次。支持合思指定单号(hosecloud)与材料包导入(material_pack)两种模式;其他取数模式通过 rawParams 预留透传。",parameters:V.object({mode:V.enum(["hosecloud","material_pack"]).default("hosecloud").describe("来源模式: hosecloud=合思指定单号; material_pack=材料包导入"),flowIds:V.array(V.string()).max(100).optional().describe("合思模式: 单据流水号列表"),rejectNodeName:V.string().nullable().optional().describe("仅关注特定节点: 节点名称, 不设为 null 表示不限制"),thinkingDepthOverride:V.enum(["default","medium","high"]).optional().describe("思考深度: default=按偏好设置, medium=标准, high=深度推理"),skipInvoiceGeneration:V.boolean().optional().describe("跳过发票生成, 默认 true"),skipExpenseExtraction:V.boolean().optional().describe("跳过费用提取, 默认 true"),disableAttachmentCache:V.boolean().optional().describe("不使用附件缓存, 默认 false"),signKey:V.string().optional().describe("合思集成标识; 缺省时自动取第一个合思集成"),packageIds:V.array(V.string()).optional().describe("材料包模式: 材料包 id 列表(来自 material-packages upload 响应)"),templateId:V.string().optional().describe("材料包模板 id, 例如 conference_reimbursement_v1; 缺省取 schemaConfig.id"),schemaConfig:V.record(V.string(),V.unknown()).optional().describe("材料包字段映射(确认参数), 建议使用 material-packages upload 返回的 schemaConfig"),noWait:V.boolean().optional().describe("创建后立即返回异步票据,不等待批次完成"),rawParams:V.record(V.string(),V.unknown()).optional().describe("预留: 其他取数模式(如时间范围 startTime/endTime)透传参数, 覆盖上述构建结果")}),handler:async($,I)=>{let z=I.mode??"hosecloud",q=I.signKey;if(z==="hosecloud"&&!q){if(q=(await Av($)).find((Q)=>Q.signKey)?.signKey,!q)throw Error("未找到合思集成 signKey, 请通过 signKey
Line truncated
`)}function Zk1($){let I=[];if(I.push(`seal-use${$.area}-${$.title}`),$.description)I.push($.description);I.push(""),I.push("Usage:");for(let z of $.commands)for(let q of z.usage)I.push(`${q}`);if($.commands.some((z)=>z.name))I.push(""),I.push(`Run'seal-use ${$.area} <command> --help'fordetailsonaspecificcommand.`);return I.join(`
`)}function vR0(){let $=[];$.push("seal-use CLI"),$.push(""),$.push("Usage:"),$.push(" seal-use version");for(let I of hR0)for(let z of I.commands)for(let q of z.usage)$.push(`${q}`);return $.push(""),$.push("Run 'seal-use <command> --help' for details on a specific command."),$.join(`
`)}var hR0;var bp=e(()=>{H$();hR0=[{area:"corps",title:"Enterprise and tenant management",description:"Manage enterprise configurations, environment modes, test bindings, and syncing.",commands:[{name:"list",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"],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"],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",summary:"Show active enterprise in stateful mode",usage:["seal-use corps current [--corp <corpId>]"]},{name:"switch",summary:"Switch default active enterprise",usage:["seal-use corps switch <corpId>"]},{name:"mark",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:"bind-test",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",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",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 version on the test enterprise. Production rules remain safe in draft state."},{name:"replay-test",summary:"Replay approval records from production enterprise to bound test enterprise via Webhook",usage:["seal-use corps replay-test [<prodCorpId>] [--record-id <id>] [--sn <sn>] [--limit <n>] [--webhook <idOrName>] [--dry-run]"],options:[{flag:"<prodCorpId>",description:"Production enterprise ID (default: active enterprise)"},{flag:"--record-id <id>",description:"Replay a specific approval run ID"},{flag:"--sn <sn>",description:"Replay a specific document SN"},{flag:"--limit <n>",description:"Batch replay latest N records from production (default: 1)"},{flag:"--status <status>",descripti
Line truncated
`+"• 安全边界:该凭证绝不包含且无法访问合思 (Hose) 主系统;仅限内部排查,严禁在外部公开分享!")}return{url:q.sso?G:H,sealResultUrl:H,ssoUrl:G,type:q.sso?"sso_link":"deep_link",expiresIn:q.sso?X:void 0,identity:Z,warning:V,enterpriseAssistUrl:J,enterpriseUrl:J,hoseDomain:I.type==="hose"?Nf1(I.domain):void 0,documentUrl:Q,recordId:U?.id,sourceDocumentSN:U?.sourceDocumentSN,sourceDocumentId:U?.sourceDocumentId,sourceSystem:U?.sourceSystem,missing:{enterpriseAssistUrl:J?void 0:"Current enterprise source is not Hose, so no Hose enterprise assist URL is configured.",documentUrl:z&&!Q?"sourceExtendData.hosecloudViewUrl is absent from the approval run detail.":void 0}}}},{name:"seal_approval_run_pick",description:"按合思单号或关键字查询运行记录,返回候选记录及其当时使用的规则版本,便于再取详情或查版本规则",parameters:W.object({query:W.string().optional().describe("合思单号、源单据 ID、运行记录 ID 或 trace 关键字"),sn:W.string().optional().describe("合思/易快报单号;优先作为精确 sourceDocumentSN 查询"),batchId:W.string().optional().describe("模拟批次 ID"),latest:W.boolean().optional().describe("只返回最新一条匹配记录"),fields:W.union([W.string(),W.array(W.string())]).optional().describe("限制返回字段"),limit:W.number().int().positive().max(100).optional(),maxScan:W.number().int().positive().max(5000).optional().describe("最多扫描多少条运行记录用于本地匹配,默认 1000"),includeBridge:W.boolean().optional()}),handler:async($,q)=>{let Y=q.sn??q.query;if(!Y)throw Error("query or sn is required");let z=await Df1($,{query:Y,sn:q.sn,batchId:q.batchId,latest:q.latest,limit:q.latest?1:q.limit??20,maxScan:q.maxScan??1000}),U=await Promise.all(z.records.map((Q)=>e1($,Q.id))),I=eR0(q.fields),J=U.map((Q)=>Ff1(Q,I));return{query:Y,sourceDocumentSN:q.sn,simulationBatchId:q.batchId,latest:q.latest??!1,total:z.total,scanned:z.scanned,matched:J.length,records:J,next:{getSummary:"seal-home approval-runs get <recordId> --summary",getRuleVersion:"seal-home rules version <ruleSetVersionNumber>",searchRuleVersion:`seal-hometoolseal_approval_search--json'{"keywords":["关键词"],"areas":["rules"],"ruleVersionScope":"version","ruleVersionNumber":14}'`,getVersionContext:`seal-hometoolseal_approval_context_get--json'{"ruleVersionNumber":14}'`},...q.includeBridge?{bridge:yA(U)}:{}}}},{name:"seal_simulation_batch_records_get",description:"获取某一次 Seal 模拟批次的运行记录,并整理对应 Langfuse trace/session 桥接字段",parameters:W.object({batchId:W.string().describe("simulation batch ID"),query:W.string().optional().describe("在 id、sourceDocumentSN、sourceDocumentId、documentId、Langfuse traceId 中做本地包含匹配")}),handler:async($,q)=>{let Y=Ud(await Sv($,q.batchId),q.query);return{batchId:q.batchId,count:Y.length,records:Y.map(PY),bridge:yA(Y)}}},{name:"seal_simulation_batch_create",description:"创建 Seal 模拟测试批次。支持合思指定单号(hosecloud)与材料包导入(material_pack)两种模式;其他取数模式通过 rawParams 预留透传。",parameters:W.object({mode:W.enum(["hosecloud","material_pack"]).default("hosecloud").describe("来源模式: hosecloud=合思指定单号; material_pack=材料包导入"),flowIds:W.array(W.string()).max(100).optional().describe("合思模式: 单据流水号列表"),rejectNodeName:W.string().nullable().optional().describe("仅关注特定节点: 节点名称, 不设为 null 表示不限制"),thinkingDepthOverride:W.enum(["default","medium","high"]).optional().describe("思考深度: default=按偏好设置, medium=标准, high=深度推理"),skipInvoiceGeneration:W.boolean().optional().describe("跳过发票生成, 默认 true"),skipExpenseExtraction:W.boolean().optional().describe("跳过费用提取, 默认 true"),disableAttachmentCache:W.boolean().optional().describe("不使用附件缓存, 默认 false"),signKey:W.string().optional().describe("合思集成标识; 缺省时自动取第一个合思集成"),packageIds:W.array(W.string()).optional().describe("材料包模式: 材料包 id 列表(来自 material-packages upload 响应)"),templateId:W.string().optional().describe("材料包模板 id, 例如 conference_reimbursement_v1; 缺省取 schemaConfig.id"),schemaConfig:W.record(W.string(),W.unknown()).optional().describe("材料包字段映射(确认参数), 建议使用 material-packages upload 返回的 schemaConfig"),noWait:W.boolean().optional().describe("创建后立即返回异步票据,不等待批次完成"),rawParams:W.record(W.string(),W.unknown()).optional().describe("预留: 其他取数模式(如时间范围 startTime/endTime)透传参数, 覆盖上述构建结果")}),handler:async($,q)=>{let Y=q.mode??"hosecloud",z=q.signKey;if(Y==="hosecloud"&&!z){if(z=(await xv($)).find((Q)=>Q.signKey)?.signKey,!z)throw Error("未找到合思集成 signKey, 请通过 signKey
Line truncated
`)}function vf1($){let q=[];if(q.push(`seal-use${$.area}-${$.title}`),$.description)q.push($.description);q.push(""),q.push("Usage:");for(let Y of $.commands)for(let z of Y.usage)q.push(`${z}`);if($.commands.some((Y)=>Y.name))q.push(""),q.push(`Run'seal-use ${$.area} <command> --help'fordetailsonaspecificcommand.`);return q.join(`
`)}function Ov0(){let $=[];$.push("seal-use CLI"),$.push(""),$.push("Usage:"),$.push(" seal-use version");for(let q of Mv0)for(let Y of q.commands)for(let z of Y.usage)$.push(`${z}`);return $.push(""),$.push("Run 'seal-use <command> --help' for details on a specific command."),$.join(`
`)}var Mv0;var Zd=e(()=>{V$();Mv0=[{area:"corps",title:"Enterprise and tenant management",description:"Manage enterprise configurations, environment modes, test bindings, and syncing.",commands:[{name:"list",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"],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"],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",summary:"Show active enterprise in stateful mode",usage:["seal-use corps current [--corp <corpId>]"]},{name:"switch",summary:"Switch default active enterprise",usage:["seal-use corps switch <corpId>"]},{name:"mark",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:"bind-test",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",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",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 version on the test enterprise. Production rules remain safe in draft state."},{name:"replay-test",summary:"Replay approval records from production enterprise to bound test enterprise via Webhook",usage:["seal-use corps replay-test [<prodCorpId>] [--record-id <id>] [--sn <sn>] [--limit <n>] [--webhook <idOrName>] [--dry-run]"],options:[{flag:"<prodCorpId>",description:"Production enterprise ID (default: active enterprise)"},{flag:"--record-id <id>",description:"Replay a specific approval run ID"},{flag:"--sn <sn>",description:"Replay a specific document SN"},{flag:"--limit <n>",description:"Batch replay latest N records from production (default: 1)"},{flag:"--status <status>",descripti
Line truncated
`}class kR{constructor($=O00.stdin,I=O00.stdout){this._stdin=$,this._stdout=I,this._readBuffer=new uR,this._started=!1,this._ondata=(z)=>{this._readBuffer.append(z),this.processReadBuffer()},this._onerror=(z)=>{this.onerror?.(z)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let $=this._readBuffer.readMessage();if($===null)break;this.onmessage?.($)}catch($){this.onerror?.($)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send($){return new Promise((I)=>{let z=L00($);if(this._stdout.write(z))I();else this._stdout.once("drain",I)})}}S8();import{dirname as Nd,join as sf1}from"node:path";import{fileURLToPath as tf1}from"node:url";import{spawnSync as O10}from"node:child_process";var JK={name:"seal-use",version:"0.10.22",type:"module",module:"src/server.ts",bin:{"seal-use":"src/cli.ts","seal-home":"src/cli.ts"},scripts:{dev:"bun run --watch src/server.ts",start:"bun run src/server.ts",probe:"bun run src/probe.ts",cli:"bun run src/cli.ts",check:"tsc --noEmit","build:binary":"node scripts/build-binary.mjs","build:plugin":"node scripts/build-plugin.mjs",bump:"bun run scripts/bump-version.ts","dev:override":"bun run scripts/dev-override.ts","dev:link":"bun run scripts/dev-override.ts","openapi:bundle":"bun run scripts/bundle-openapi.ts","openapi:raw":"bun run scripts/generate-raw-openapi.ts",test:"bun test"},dependencies:{"@modelcontextprotocol/sdk":"^1.29.0",archiver:"^8.0.0",exceljs:"^4.4.0","iconv-lite":"^0.7.3",ky:"^2.0.2","pinyin-pro":"^3.29.3",yauzl:"^3.4.0",zod:"^4.4.3"},devDependencies:{"@types/archiver":"^8.0.0","@types/bun":"^1.3.14","@types/yauzl":"^3.4.0","bun-types":"^1.3.14",typescript:"^5.9.3",yaml:"^2.9.0"}};function il0($,I=JK.version){let z=$.trim();if(!z)return null;let q=z.endsWith("-dirty"),U=q?z.slice(0,-6):z,Y=U.match(/^v?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?)-(\d+)-g([0-9a-f]+)$/);if(Y&&Y[1]&&Y[2]&&Y[3])return{baseVersion:Y[1],commitsAhead:Number.parseInt(Y[2],10),commit:Y[3],dirty:q,describe:z};let J=U.match(/^v?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?)$/);if(J&&J[1])return{baseVersion:J[1],commitsAhead:0,commit:"",dirty:q,describe:z};let Q=U.match(/^([0-9a-f]{7,40})$/);if(Q&&Q[1])return{baseVersion:I,commitsAhead:0,commit:Q[1],dirty:q,describe:z};return null}function nl0($,I,z,q){let Y=z?`+g${z}${q?".dirty":""}`:q?"+dirty":"";return`${$}-dev.${I}${Y}`}function cl0($){let I=$?.env,z=I?.SEAL_BUILD_VERSION??process.env.SEAL_BUILD_VERSION,q=I?.SEAL_BUILD_IS_RELEASE??process.env.SEAL_BUILD_IS_RELEASE,U=I?.SEAL_BUILD_CHANNEL??process.env.SEAL_BUILD_CHANNEL,Y=I?.SEAL_BUILD_GIT_BASE??process.env.SEAL_BUILD_GIT_BASE,J=I?.SEAL_BUILD_GIT_COMMITS_AHEAD??process.env.SEAL_BUILD_GIT_COMMITS_AHEAD,Q=I?.SEAL_BUILD_GIT_COMMIT??process.env.SEAL_BUILD_GIT_COMMIT,K=I?.SEAL_BUILD_GIT_DIRTY??process.env.SEAL_BUILD_GIT_DIRTY,H=I?.SEAL_BUILD_GIT_DESCRIBE??process.env.SEAL_BUILD_GIT_DESCRIBE,G=I?.SEAL_FORCE_RELEASE??process.env.SEAL_FORCE_RELEASE,Z=$?.cwd;if(z){let W=q==="true",w={name:"seal-use",version:z,channel:U||(W?"release":"dev"),isRelease:W};if(Y)w.git={baseVersion:Y,commitsAhead:Number.parseInt(J||"0",10),commit:Q||"",dirty:K==="true",describe:H||z};return w}if(q==="true"||G==="1")return{name:"seal-use",version:JK.version,channel:"release",isRelease:!0};try{let W=O10("git",["describe","--tags","--long","--dirty","--always"],{cwd:Z,encoding:"utf8",stdio:["ignore","pipe","ignore"]});if(W.status===0&&W.stdout){let X=il0(W.stdout.trim(),JK.version);if(X){if(!X.commit){let L=O10("git",["rev-parse","--short","HEAD"],{cwd:Z,encoding:"utf8",stdio:["ignore","pipe","ignore"]});if(L.status===0&&L.stdout)X.commit=L.stdout.trim()}return{name:"seal-use",version:nl0(X.baseVersion,X.commitsAhead,X.commit,X.dirty),channel:"dev",isRelease:!1,git:X}}}}catch{}return{name:"seal-use",version:`${JK.version}-dev.0+local`,channel:"dev",isRelease:!1}}var QK=cl0(),q1=QK.version,Jv=QK.isRelease,gs1=QK.channel;e4();dN();lN();x4();D4();n1();S8();x4();e4();e4();GZ();Pp();D4();n1();H$();import{existsSync as fR0}from"node:fs";async function bR0($,I){if(!fR0($))throw Error(`Filenotfound:${$}`);let z=Lz($);console.log(JSON.stringify(await wz(z.fileBuffer,z.fileName,I),null,2))}async function gA($,I,z,q,U){if($==="ready"||$==="status"){let Y=I??E(U.options.file)??E(U.options.input),J=await OA(z,q,{filePath:Y,webhook:E(U.options.webhook)??E(U.options.selector)});if(console.error(`[webhook-ready]企业环境:${J.corp.name}(${J.corp.id})[${J.stateMode}]`),J.corp.tenant?.name)console.error(`[webhook-ready]租户信息:${J.corp.tenant.name}(${J.corp.tenant.id})`);console.error(`[webhook-ready]凭证状态:${J.authStatus==="ok"?"OK":`异常 (${J.authError})`}`),console.erro
Line truncated
`}class tR{constructor($=n00.stdin,q=n00.stdout){this._stdin=$,this._stdout=q,this._readBuffer=new sR,this._started=!1,this._ondata=(Y)=>{this._readBuffer.append(Y),this.processReadBuffer()},this._onerror=(Y)=>{this.onerror?.(Y)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let $=this._readBuffer.readMessage();if($===null)break;this.onmessage?.($)}catch($){this.onerror?.($)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send($){return new Promise((q)=>{let Y=i00($);if(this._stdout.write(Y))q();else this._stdout.once("drain",q)})}}b8();import{dirname as dd,join as Li1}from"node:path";import{fileURLToPath as Fi1}from"node:url";import{spawnSync as i10}from"node:child_process";var LK={name:"seal-use",version:"0.10.23",type:"module",module:"src/server.ts",bin:{"seal-use":"src/cli.ts","seal-home":"src/cli.ts"},scripts:{dev:"bun run --watch src/server.ts",start:"bun run src/server.ts",probe:"bun run src/probe.ts",cli:"bun run src/cli.ts",check:"tsc --noEmit","build:binary":"node scripts/build-binary.mjs","build:plugin":"node scripts/build-plugin.mjs",bump:"bun run scripts/bump-version.ts","dev:override":"bun run scripts/dev-override.ts","dev:link":"bun run scripts/dev-override.ts","openapi:bundle":"bun run scripts/bundle-openapi.ts","openapi:raw":"bun run scripts/generate-raw-openapi.ts",test:"bun test"},dependencies:{"@modelcontextprotocol/sdk":"^1.29.0",archiver:"^8.0.0",exceljs:"^4.4.0","iconv-lite":"^0.7.3",ky:"^2.0.2","pinyin-pro":"^3.29.3",yauzl:"^3.4.0",zod:"^4.4.3"},devDependencies:{"@types/archiver":"^8.0.0","@types/bun":"^1.3.14","@types/yauzl":"^3.4.0","bun-types":"^1.3.14",typescript:"^5.9.3",yaml:"^2.9.0"}};function _o0($,q=LK.version){let Y=$.trim();if(!Y)return null;let z=Y.endsWith("-dirty"),U=z?Y.slice(0,-6):Y,I=U.match(/^v?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?)-(\d+)-g([0-9a-f]+)$/);if(I&&I[1]&&I[2]&&I[3])return{baseVersion:I[1],commitsAhead:Number.parseInt(I[2],10),commit:I[3],dirty:z,describe:Y};let J=U.match(/^v?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?)$/);if(J&&J[1])return{baseVersion:J[1],commitsAhead:0,commit:"",dirty:z,describe:Y};let Q=U.match(/^([0-9a-f]{7,40})$/);if(Q&&Q[1])return{baseVersion:q,commitsAhead:0,commit:Q[1],dirty:z,describe:Y};return null}function Co0($,q,Y,z){let I=Y?`+g${Y}${z?".dirty":""}`:z?"+dirty":"";return`${$}-dev.${q}${I}`}function Ro0($){let q=$?.env,Y=q?.SEAL_BUILD_VERSION??process.env.SEAL_BUILD_VERSION,z=q?.SEAL_BUILD_IS_RELEASE??process.env.SEAL_BUILD_IS_RELEASE,U=q?.SEAL_BUILD_CHANNEL??process.env.SEAL_BUILD_CHANNEL,I=q?.SEAL_BUILD_GIT_BASE??process.env.SEAL_BUILD_GIT_BASE,J=q?.SEAL_BUILD_GIT_COMMITS_AHEAD??process.env.SEAL_BUILD_GIT_COMMITS_AHEAD,Q=q?.SEAL_BUILD_GIT_COMMIT??process.env.SEAL_BUILD_GIT_COMMIT,K=q?.SEAL_BUILD_GIT_DIRTY??process.env.SEAL_BUILD_GIT_DIRTY,H=q?.SEAL_BUILD_GIT_DESCRIBE??process.env.SEAL_BUILD_GIT_DESCRIBE,G=q?.SEAL_FORCE_RELEASE??process.env.SEAL_FORCE_RELEASE,Z=$?.cwd;if(Y){let V=z==="true",w={name:"seal-use",version:Y,channel:U||(V?"release":"dev"),isRelease:V};if(I)w.git={baseVersion:I,commitsAhead:Number.parseInt(J||"0",10),commit:Q||"",dirty:K==="true",describe:H||Y};return w}if(z==="true"||G==="1")return{name:"seal-use",version:LK.version,channel:"release",isRelease:!0};try{let V=i10("git",["describe","--tags","--long","--dirty","--always"],{cwd:Z,encoding:"utf8",stdio:["ignore","pipe","ignore"]});if(V.status===0&&V.stdout){let X=_o0(V.stdout.trim(),LK.version);if(X){if(!X.commit){let L=i10("git",["rev-parse","--short","HEAD"],{cwd:Z,encoding:"utf8",stdio:["ignore","pipe","ignore"]});if(L.status===0&&L.stdout)X.commit=L.stdout.trim()}return{name:"seal-use",version:Co0(X.baseVersion,X.commitsAhead,X.commit,X.dirty),channel:"dev",isRelease:!1,git:X}}}}catch{}return{name:"seal-use",version:`${LK.version}-dev.0+local`,channel:"dev",isRelease:!1}}var FK=Ro0(),Q1=FK.version,Nv=FK.isRelease,et1=FK.channel;J6();UD();JD();p4();_4();o1();b8();p4();J6();J6();DZ();op();_4();o1();V$();import{existsSync as Ev0}from"node:fs";async function jv0($,q){if(!Ev0($))throw Error(`Filenotfound:${$}`);let Y=AY($);console.log(JSON.stringify(await DY(Y.fileBuffer,Y.fileName,q),null,2))}async function mA($,q,Y,z,U){if($==="ready"||$==="status"){let I=q??E(U.options.file)??E(U.options.input),J=await RA(Y,z,{filePath:I,webhook:E(U.options.webhook)??E(U.options.selector)});if(console.error(`[webhook-ready]企业环境:${J.corp.name}(${J.corp.id})[${J.stateMode}]`),J.corp.tenant?.name)console.error(`[webhook-ready]租户信息:${J.corp.tenant.name}(${J.corp.tenant.id})`);console.error(`[webhook-ready]凭证状态:${J.authStatus==="ok"?"OK":`异常 (${J.authError})`}`),console.erro
Line truncated
`+`\uD83D\uDC49查看全部请添加:seal-usecorpslist--all
`+"\uD83D\uDC49 检索指定企业请使用: seal-use corps search <keyword>")}P0(F.map((D)=>({id:D.id,name:D.name,environment:D.environment??"production",sourceType:D.source.type,provider:D.source.provider??D.source.type,staffId:D.source.staffId,testCorpId:D.testCorpId,prodCorpId:D.prodCorpId,current:D.id===H})));return}if($==="get"||$==="show"){let q=I??E(z.options.corp);if(!q)throw g4("Usage: seal-use corps get <corpId>");let U=W1(q),Y=Wi(U.id),J=ok1(U);P0({id:U.id,name:U.name,environment:U.environment??"production",configFile:Y,seal:{url:J,tenantSlug:U.seal.tenantSlug??U.source.tenantSlug,customHeaderNames:U.seal.headers?Object.keys(U.seal.headers):[],customCookieNames:U.seal.cookies?Object.keys(U.seal.cookies):[],endpoints:U.seal.endpoints},source:rk1(U.source),relations:{testCorpId:U.testCorpId,prodCorpId:U.prodCorpId},auth:{refreshTtl:U.auth.refreshTtl}});return}if($==="current"){let q=W1(E(z.options.corp));P0({id:q.id,name:q.name,environment:q.environment??"production",sourceType:q.source.type,provider:q.source.provider??q.source.type,staffId:q.source.staffId,testCorpId:q.testCorpId,prodCorpId:q.prodCorpId});return}if($==="mark"||$==="mark-test"||$==="mark-prod"){let q=I??E(z.options.corp);if(!q)throw g4("Usage: seal-use corps mark <corpId> --env <production|test> [--confirm]");let U=W1(q),Y=$==="mark-test"?"test":$==="mark-prod"?"production":E(z.options.env)??E(z.options.environment);if(Y!=="production"&&Y!=="test")throw g4("Usage: seal-use corps mark <corpId> --env <production|test> [--confirm]");if(!(X0(z.options.confirm)===!0||X0(z.options.yes)===!0))throw e5(`Refusingtochangeenvironmenttagofenterprise'${U.name}'(${U.id})to'${Y}'without--confirm.Markingalterssynchronizationsafetyguards.`,`seal-usecorpsmark${U.id}--env${Y}--confirm`);let Q=m7(U.id,{environment:Y});P0({id:Q.id,name:Q.name,environment:Q.environment,testCorpId:Q.testCorpId,prodCorpId:Q.prodCorpId});return}if($==="bind-test"){let q,U;if(I&&z.command[3])q=I,U=z.command[3];else if(I){let Z=E(z.options.corp),W=E(z.options["test-corp"])??E(z.options.testCorp);if(Z)q=Z,U=I;else if(W)q=I,U=W}if(!q||!U)throw g4(`Usage:seal-usecorpsbind-test<prodCorpId><testCorpId>[--confirm][--force]
Run'seal-use corps bind-test ${U.id} <testCorpId> --confirm'firsttoestablishaverified1-to-1association.`);let Y=W1(U.testCorpId);if(Y.environment!=="test")throw Error(`Targetenterprise'${Y.name}'(${Y.id})ismarkedas'${Y.environment}',NOT'test'.Abortingsynctoprotectnon-testenvironments.`);let J=await K1(U),Q=await K1(Y),[K,H,G,Z,W,X,w,L]=await Promise.all([v1(J,U.seal.endpoints.approvalStylePreferences).catch(()=>({})),v1(Q,Y.seal.endpoints.approvalStylePreferences).catch(()=>({})),h6(J),h6(Q),N$(J).catch(()=>[]),N$(Q).catch(()=>[]),f3(J,{limit:100}).catch(()=>({articles:[]})),f3(Q,{limit:100}).catch(()=>({articles:[]}))]),O=(w.articles||[]).filter((o)=>!o.isDeleted),F=(L.articles||[]).filter((o)=>!o.isDeleted),D=new Map(F.map((o)=>[o.title.trim(),o])),P=[],A=[],T=new Set(O.map((o)=>o.title.trim()));for(let o of O){let E0=o.title.trim(),k0=D.get(E0);if(!k0)P.push(o);else{let L1=k0.content!==o.content,k4=(k0.purpose??"")!==(o.purpose??""),t4=k0.enabled!==o.enabled,Z$=k0.contentType!==o.contentType,T8=(k0.status??"")!==(o.status??""),J8=JSON.stringify([...k0.scenarios??[]].sort())!==JSON.stringify([...o.scenarios??[]].sort()),W$=JSON.stringify([...k0.tags??[]].sort())!==JSON.stringify([...o.tags??[]].sort());if(L1||k4||t4||Z$||T8||J8||W$)A.push({testId:k0.id,prodDoc:o,reasons:[...L1?["content"]:[],...k4?["purpose"]:[],...t4?["enabled"]:[],...Z$?["contentType"]:[],...T8?["status"]:[],...J8?["scenarios"]:[],...W$?["tags"]:[]]})}}let k=F.filter((o)=>!T.has(o.title.trim())),f=[...W].sort((o,E0)=>E0.versionNumber-o.versionNumber)[0],C=f?.versionNumber,i=([...X].sort((o,E0)=>E0.versionNumber-o.versionNumber)[0]?.versionNumber??0)+1,v=zh0(U.name,C,X),c=E(z.options["version-name"])??E(z.options.versionName)??qh0(U.name,C,v,i),$0={...H,tone:K.tone,language:K.language,detailLevel:K.detailLevel,outputFormat:K.outputFormat,examples:K.examples??[],prohibitedPhrases:K.prohibitedPhrases??[],customInstructions:K.customInstructions,decisionPreferences:K.decisionPreferences,thinkingDepthPreference:K.thinkingDepthPreference};if(X0(z.options["dry-run"])===!0||X0(z.options.dryRun)===!0){P0({dryRun:!0,source:{id:U.id,name:U.name,environment:U.environment,latestPublishedVersion:f?{versionNumber:f.versionNumber,versionName:f.versionName}:null,documentsCount:O.length},target:{id:Y.id,name:Y.name,environment:Y.environment},versionMappingPlan:{sourceProdVersionNumber:C??null,sourceProdVersionName:f?.versionName??null,targetTestExpectedVersionNumber:i,targetTestPublishVersionName:c,iteration:v},preferencesDiff:{decisionPreferences:{before:H.decisionPreferences,after:K.decisionPreferences},thinkingDepthPreference:{before:H.thinkingDepthPreference,after:K.thinkingDepthPreference}},rulesPlan:{sourceDraftRuleCount:G.rules.length,targetExistingDraftRuleCount:Z.rules.length,toDeleteCount:Z.rules.length,toCreateCount:G.rules.length,rulesToSync:G.rules.map((o,E0)=>({index:E0+1,sourceRuleId:o.id,sourceRuleCode:o.code??E0+1,expectedTargetCode:`rule-${E0+1}`,description:o.description,scope:o.scope,strictness:o.strictness}))},documentsPlan:{sourceDocumentCount:O.length,targetExistingDocumentCount:F.length,toCreateCount:P.length,toCreate:P.map((o)=>({title:o.title,purpose:o.purpose,contentType:o.contentType,scenarios:o.scenarios})),toUpdateCount:A.length,toUpdate:A.map((o)=>({targetDocumentId:o.testId,title:o.prodDoc.title,reasons:o.reasons})),toDeleteCount:k.length,toDelete:k.map((o)=>({targetDocumentId:o.id,title:o.title}))},publishingPlan:{targetCorpId:Y.id,publishVersionName:c,publishTarget:"test"},hosecloudSyncPlan:(()=>{if(U.source.type!=="hose")return{sourceType:U.source.type,skipped:!0,reason:"prod source is not hose; no hosecloud credentials available"};let o=(K.integrations??[]).filter((L1)=>L1.type==="hosecloud"),E0=new Set,k0=o.filter((L1)=>{let k4=L1.corporationId??U.id;if(E0.has(k4))return!1;return E0.add(k4),!0});return{sourceType:"hose",outboundName:Hh0(U.name),targetMode:"assisted",integrationsCount:k0.length,integrations:k0.map((L1)=>({corporationId:L1.corporationId,apiOrigin:L1.apiOrigin,customApiUrl:L1.customApiUrl}))}})(),productionGuarantees:{prodRulesStayDraft:!0,prodVersionPublished:!1}});return}if(!(X0(z.options.yes)===!0||X0(z.options.confirm)===!0))throw e5(`Refusingtooverwritetestenterprise'${Y.name}'(${Y.id})withpreferences,${G.rules.length}draftrules,and${O.length}knowledgedocumentsfromproductionenterprise'${U.name}'(${U.id})without--yes.Thiswillreplacetestdraftrules,synchronizeknowledgedocuments,andpublishanewversiononthetestenterprise.`,`seal-usecorpssync-test${U.id}--yes`);await T5(Q,$0,Y.seal.endpoints.approvalStylePreferences);let p=[];for(let o of k)await hw(Q,o.id),p.push({id:o.id,title:o.title});let s=[];for(let o of A)await vw(Q,o.testId,{title:o.prodDoc.title,purpose:o.prodDoc.purpose,content:o.prodDoc.content,contentType:o.prodDoc.contentType,status:o.prodDoc.status,enabled:o.prodDoc.enabled,scenarios:o.prodDoc.scenarios&&o.prodDoc.scenarios.le
Line truncated
`+"\uD83D\uDC49 检索指定企业请使用: seal-use corps search <keyword>")}j0(O.map((A)=>({id:A.id,name:A.name,environment:A.environment??"production",sourceType:A.source.type,provider:A.source.provider??A.source.type,staffId:A.source.staffId,testCorpId:A.testCorpId,prodCorpId:A.prodCorpId,current:A.id===H})));return}if($==="get"||$==="show"){let z=q??E(Y.options.corp);if(!z)throw i4("Usage: seal-use corps get <corpId>");let U=w1(z),I=ki(U.id),J=Vb1(U);j0({id:U.id,name:U.name,environment:U.environment??"production",configFile:I,seal:{url:J,tenantSlug:U.seal.tenantSlug??U.source.tenantSlug,customHeaderNames:U.seal.headers?Object.keys(U.seal.headers):[],customCookieNames:U.seal.cookies?Object.keys(U.seal.cookies):[],endpoints:U.seal.endpoints},source:wb1(U.source),relations:{testCorpId:U.testCorpId,prodCorpId:U.prodCorpId},auth:{refreshTtl:U.auth.refreshTtl}});return}if($==="current"){let z=w1(E(Y.options.corp));j0({id:z.id,name:z.name,environment:z.environment??"production",sourceType:z.source.type,provider:z.source.provider??z.source.type,staffId:z.source.staffId,testCorpId:z.testCorpId,prodCorpId:z.prodCorpId});return}if($==="mark"||$==="mark-test"||$==="mark-prod"){let z=q??E(Y.options.corp);if(!z)throw i4("Usage: seal-use corps mark <corpId> --env <production|test> [--confirm]");let U=w1(z),I=$==="mark-test"?"test":$==="mark-prod"?"production":E(Y.options.env)??E(Y.options.environment);if(I!=="production"&&I!=="test")throw i4("Usage: seal-use corps mark <corpId> --env <production|test> [--confirm]");if(!(W0(Y.options.confirm)===!0||W0(Y.options.yes)===!0))throw Q9(`Refusingtochangeenvironmenttagofenterprise'${U.name}'(${U.id})to'${I}'without--confirm.Markingalterssynchronizationsafetyguards.`,`seal-usecorpsmark${U.id}--env${I}--confirm`);let Q=a7(U.id,{environment:I});j0({id:Q.id,name:Q.name,environment:Q.environment,testCorpId:Q.testCorpId,prodCorpId:Q.prodCorpId});return}if($==="bind-test"){let z,U;if(q&&Y.command[3])z=q,U=Y.command[3];else if(q){let Z=E(Y.options.corp),V=E(Y.options["test-corp"])??E(Y.options.testCorp);if(Z)z=Z,U=q;else if(V)z=q,U=V}if(!z||!U)throw i4(`Usage:seal-usecorpsbind-test<prodCorpId><testCorpId>[--confirm][--force]
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let W of Z){let X=W.outboundName??"SealAI 审批",w=W.signKey,L=W.apiOrigin??"production";console.error(`•"${X}"(signKey:${w},环境:${L})`),console.error(`\uD83D\uDC49查看命令:seal-usedeployhosecloudget${w}--corp${U.id}
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let w of W){let L=w.outboundName??"SealAI 审批",O=w.signKey,F=w.apiOrigin??"production";console.error(`•"${L}"(signKey:${O},环境:${F})`),console.error(`\uD83D\uDC49同步命令:seal-usedeployhosecloudsync${O}--corp${U.id}
`);throw new h4("缺少必需参数 <sign-key>。请从上述候选列表中选择并指定 signKey 执行同步。",2,W.length===1?`seal-usedeployhosecloudsync${W[0].signKey}--corp${U.id}`:void 0)}await N0("seal_deploy_hosecloud_sync",q,U,{signKey:H},V0(Y.options));return}throw Error(`Unknowndeployhosecloudaction:${Q??""}.Available:requirements,list,get,status,configure,sync.`)}Ei();import{accessSync as Ff1,constants as Mf1,existsSync as Y8,readdirSync as Nf1}from"node:fs";import{homedir as Df1}from"node:os";import{join as W3}from"node:path";e9();import{existsSync as ap,mkdirSync as Eh0,rmSync as wf1,writeFileSync as Lf1}from"node:fs";import{homedir as jh0}from"node:os";import{dirname as Of1,join as ep}from"node:path";var wh0=`---
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let V of Z){let X=V.outboundName??"SealAI 审批",w=V.signKey,L=V.apiOrigin??"production";console.error(`•"${X}"(signKey:${w},环境:${L})`),console.error(`\uD83D\uDC49查看命令:seal-usedeployhosecloudget${w}--corp${U.id}
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let w of V){let L=w.outboundName??"SealAI 审批",F=w.signKey,O=w.apiOrigin??"production";console.error(`•"${L}"(signKey:${F},环境:${O})`),console.error(`\uD83D\uDC49同步命令:seal-usedeployhosecloudsync${F}--corp${U.id}
`);throw new b4("缺少必需参数 <sign-key>。请从上述候选列表中选择并指定 signKey 执行同步。",2,V.length===1?`seal-usedeployhosecloudsync${V[0].signKey}--corp${U.id}`:void 0)}await P0("seal_deploy_hosecloud_sync",z,U,{signKey:H},F0(I.options));return}throw Error(`Unknowndeployhosecloudaction:${Q??""}.Available:requirements,list,get,status,configure,sync.`)}ti();import{accessSync as ub1,constants as fb1,existsSync as X8,readdirSync as bb1}from"node:fs";import{homedir as ib1}from"node:os";import{join as N3}from"node:path";Q3();import{existsSync as Pd,mkdirSync as Xg0,rmSync as yb1,writeFileSync as xb1}from"node:fs";import{homedir as Vg0}from"node:os";import{dirname as kb1,join as Bd}from"node:path";var Yg0=`---
name:seal-use
description:"v0.10.22: Use for Seal Use first-time enterprise onboarding, Hose/合思 or Seal-native authentication, assistance links and browser cURL intake, plus tenant approval operations, diagnosis, simulation, rules, users, configuration, and search."
description:"v0.10.23: Use for Seal Use first-time enterprise onboarding, Hose/合思 or Seal-native authentication, assistance links and browser cURL intake, plus tenant approval operations, diagnosis, simulation, rules, users, configuration, and search."
Usethe\`seal_cli\` MCP tool when it is available; pass the command string as its \`command\` argument. If MCP is unavailable, fall back to the global \`seal-use\` CLI. This skill is a routing layer for agents: keep this file short, choose the right command, and read a focused reference only when the task needs detail.
-User-facing合思authorizationlink(合思/易快报授权):\`seal-use auth hose-link --corp <corpId> --expire 7200\`; read \`references/hose-enterprise-auth.md\`. Never use this route when the user says Seal 协助. Always provide BOTH a code block (\`\`\`\`text ... \`\`\`\`) AND a hyperlink.
Rule,document,stylepreference,andpublishactionsmutateSealconfiguration.Makethetargetenterpriseexplicit,showtheintendedpayload,andverifyafterthewrite.Neversendreal\`enterprises/*.json\` files, tokens, signed URLs, or full raw documents to GitHub, tickets, logs, or chat unless the user explicitly requests a safe export.
`;var Lh0=`interface:
`;var zg0=`interface:
display_name:"Seal Use"
short_description:"Diagnose approval feedback and publish minimal rule fixes"
default_prompt:"Use $seal-use to resolve a customer feedback package to the correct tenant, diagnose the approval run, propose a minimal rule diff, and publish only after explicit confirmation."
@@ -1240,7 +1248,7 @@ Use current search only when the question is about current draft/current knowled
##OutputDiscipline
Ifarulecommandwouldreturnmanydescriptionsormorethanabout20rules,use\`rules count\`, \`rules list --summary\`, \`fields\`, \`snippetOnly\`, or \`--output-file\`. Use \`--full\` only for deliberate exports.
`;var Mh0="# Seal Use CLI Reference\n\nRun from any directory after installing the global CLI:\n\n```bash\nseal-use<command>\n```\n\nEnterprise config lookup:\n\n- If `SEAL_USE_ENTERPRISES_DIR` is set, only that directory is loaded.\n- Otherwise the user-level `~/.config/seal-use/enterprises`directoryisloaded.Aconfigured\n`testEnterprisesDir`isloadedfirstfortest-tenantworkflows.Thecurrentworkingdirectory's\n`./enterprises`directoryisnotloadedimplicitly.\n-Set`SEAL_USE_ENTERPRISES_DIR`touseoneexplicitdirectoryinstead.Legacy\n`~/.config/seal-home/enterprises`filesaremigratedtotheprimarydirectorywhenpossible.\n\nEnterpriseselectionisstatelessbydefault.Commandsthataccessanenterpriserequire\n`--corp<corpId>`unlessstatefulmodeisexplicitlyenabled:\n\n```bash\nseal-useconfigmodestateful--corp<corpId>\nseal-usecorpsswitch<corpId>\nseal-useconfigmodestateless\n```\n\nTheglobalmodeisstoredin`~/.config/seal-use/config.json`;set`SEAL_USE_CONFIG_FILE`to\noverridethatpath.Thelegacy`current-corp`fileisnotread.\n\n##Stream&ExitCodeContract\n\n-**`stdout`**:Pure,deterministicJSONformachine/Agentparsing.\n-**`stderr`**:Diagnostics,probinglogs,and**Next-StepCommandSuggestions**withthestableprefix`👉Nextaction:seal-use...`.\n-**`ExitCode`**:`0`onsuccess;`1`runtime/upstreamfailure,`2`usage/argumenterror,`10`explicitdestructive-operationconfirmationrequired,`11`missing/invalidauthentication,and`12`outputprotectionrequiringacompact/file/queryalternative.\n\n##Top-LevelCommands\n\n```bash\nseal-useversion\nseal-useconfigpaths\nseal-useconfigget\nseal-useconfigmode<stateful|stateless>[--corp<corpId>]\nseal-useconfigtest-dir[<path>|--clear]\nseal-useconfiglint<enable|disable|status>[--linter<name>][--min-score<score>]\nseal-userulescount[--corp<corpId>]\nseal-useruleslist[--summary][--count][--limit20][--offset0][--corp<corpId>]\nseal-userulesclear[--corp<corpId>][--dry-run|--yes]\nseal-userulesversions[--corp<corpId>]\nseal-userulesversion<versionId|versionNumber|latest>[--corp<corpId>]\nseal-userulesget--corp<corpId>--version<number|latest>--code'#0038'\nseal-userulesget--corp<corpId>--record-id<recordId>--runtime-idrule-205\nseal-userulessearch<keyword>[--version<versionId|versionNumber|latest>][--maxResults20][--corp<corpId>]\nseal-userulespull[--corp<corpId>][--version<id|num|latest>][--out<file>]\nseal-useruleslint[--file<path>][--corp<corpId>][--linter<name|path>][--version<num>][--code<code>][--min-score<score>][--summary]\nseal-useruleslinters[--corp<corpId>]\nseal-userulespush[--file<path>][--corp<corpId>][--publish][--version-name<name>][--dry-run|--yes]\nseal-userulesmap[--corp<corpId>][--version<id|num|latest>][--code<code>]\nseal-useservice<start|stop|restart|status|logs>[--port8787][--host127.0.0.1][--lines50]\nseal-usehttp[--port8787][--host127.0.0.1]\nseal-useserve[--port8787]\nseal-useupdate[--check][--force][--version<v>]\nseal-useupdatecheck\nseal-useupdatechangelog[--limit<n>]\nseal-usechangelog[--limit<n>]\nseal-usemcp\nseal-usemcpconfig\nseal-usemcp-config\nseal-useskilldump\nseal-useskillinstall[--dir<path>|--local]\nseal-useskillstatus\nseal-usedoctor[--quiet]\nseal-usedoctortenant[--corp<corpId>][--quiet]\nseal-usedoctorguide\nseal-usedoctorpaths\nseal-usetestregression[--corp<corpId>][--samples<N>][--dry-run][--fail-on-flips]\nseal-useprobe[<corpId>]\nseal-usetoolslist\nseal-usecorpslist[query][--env<production|test>][--limit<n>][--all][--sort<usage|name|id>][--strict][--corp<corpId>]\nseal-usecorpssearch<query>[--env<production|test>][--strict]\nseal-usecorpsget<corpId>\nseal-usecorpscurrent[--corp<corpId>]\nseal-usecorpsswitch<corpId>\nseal-usecorpsmark<corpId>--env<production|test>[--confirm]\nseal-usecorpsbind-test<prodCorpId><testCorpId>[--confirm][--force]\nseal-usecorpsunbind-test[<corpId>][--confirm]\nseal-usecorpssync-test[<prodCorpId>][--dry-run][--yes][--version-name<name>]\nseal-usecorpsreplay-test[<prodCorpId>][--record-id<id>][--sn<sn>][--limit<n>][--status<status>][--webhook<idOrName>][--sn-suffix<str>][--dry-run][--force]\nseal-usecorpsregression[--corp<corpId>][--samples<N>][--dry-run][--fail-on-flips]\nseal-usecorpsadd-hose--json'{\"name\":\"企业名称\",\"domain\":\"https://app.ekuaibao.com\",\"appKey\":\"...\",\"appSecurity\":\"...\",\"proxyStaffBizId\":\"corpId:staffId\"}'\nseal-usecorpsadd-seal--json'{\"sealUrl\":\"https://tenant.sealai.cc\",\"token\":\"seal-bearer-token\"}'\nseal-usecorpsadd-link<https://.../web/thirdparty.html?...>[--name<customName>][--overwrite]\nseal-useauthdiagnose[--corp<corpId>]\nseal-useauthhose-link[--corp<corpId>][--expire7200]Line truncated
`;var Jg0="# Seal Use CLI Reference\n\nRun from any directory after installing the global CLI:\n\n```bash\nseal-use<command>\n```\n\nEnterprise config lookup:\n\n- If `SEAL_USE_ENTERPRISES_DIR` is set, only that directory is loaded.\n- Otherwise the user-level `~/.config/seal-use/enterprises`directoryisloaded.Aconfigured\n`testEnterprisesDir`isloadedfirstfortest-tenantworkflows.Thecurrentworkingdirectory's\n`./enterprises`directoryisnotloadedimplicitly.\n-Set`SEAL_USE_ENTERPRISES_DIR`touseoneexplicitdirectoryinstead.Legacy\n`~/.config/seal-home/enterprises`filesaremigratedtotheprimarydirectorywhenpossible.\n\nEnterpriseselectionisstatelessbydefault.Commandsthataccessanenterpriserequire\n`--corp<corpId>`unlessstatefulmodeisexplicitlyenabled:\n\n```bash\nseal-useconfigmodestateful--corp<corpId>\nseal-usecorpsswitch<corpId>\nseal-useconfigmodestateless\n```\n\nTheglobalmodeisstoredin`~/.config/seal-use/config.json`;set`SEAL_USE_CONFIG_FILE`to\noverridethatpath.Thelegacy`current-corp`fileisnotread.\n\n##Stream&ExitCodeContract\n\n-**`stdout`**:Pure,deterministicJSONformachine/Agentparsing.\n-**`stderr`**:Diagnostics,probinglogs,and**Next-StepCommandSuggestions**withthestableprefix`👉Nextaction:seal-use...`.\n-**`ExitCode`**:`0`onsuccess;`1`runtime/upstreamfailure,`2`usage/argumenterror,`10`explicitdestructive-operationconfirmationrequired,`11`missing/invalidauthentication,and`12`outputprotectionrequiringacompact/file/queryalternative.\n\n##Top-LevelCommands\n\n```bash\nseal-useversion\nseal-useconfigpaths\nseal-useconfigget\nseal-useconfigmode<stateful|stateless>[--corp<corpId>]\nseal-useconfigtest-dir[<path>|--clear]\nseal-useconfiglint<enable|disable|status>[--linter<name>][--min-score<score>]\nseal-userulescount[--corp<corpId>]\nseal-useruleslist[--summary][--count][--limit20][--offset0][--corp<corpId>]\nseal-userulesclear[--corp<corpId>][--dry-run|--yes]\nseal-userulesversions[--corp<corpId>]\nseal-userulesversion<versionId|versionNumber|latest>[--corp<corpId>]\nseal-userulesget--corp<corpId>--version<number|latest>--code'#0038'\nseal-userulesget--corp<corpId>--record-id<recordId>--runtime-idrule-205\nseal-userulessearch<keyword>[--version<versionId|versionNumber|latest>][--maxResults20][--corp<corpId>]\nseal-userulespull[--corp<corpId>][--version<id|num|latest>][--out<file>]\nseal-useruleslint[--file<path>][--corp<corpId>][--linter<name|path>][--version<num>][--code<code>][--min-score<score>][--summary]\nseal-useruleslinters[--corp<corpId>]\nseal-userulespush[--file<path>][--corp<corpId>][--publish][--version-name<name>][--dry-run|--yes]\nseal-userulesmap[--corp<corpId>][--version<id|num|latest>][--code<code>]\nseal-useservice<start|stop|restart|status|logs>[--port8787][--host127.0.0.1][--lines50]\nseal-usehttp[--port8787][--host127.0.0.1]\nseal-useserve[--port8787]\nseal-useupdate[--check][--force][--version<v>]\nseal-useupdatecheck\nseal-useupdatechangelog[--limit<n>]\nseal-usechangelog[--limit<n>]\nseal-usemcp\nseal-usemcpconfig\nseal-usemcp-config\nseal-useskilldump\nseal-useskillinstall[--dir<path>|--local]\nseal-useskillstatus\nseal-usedoctor[--quiet]\nseal-usedoctortenant[--corp<corpId>][--quiet]\nseal-usedoctorguide\nseal-usedoctorpaths\nseal-usetestregression[--corp<corpId>][--samples<N>][--dry-run][--fail-on-flips]\nseal-useprobe[<corpId>]\nseal-usetoolslist\nseal-usecorpslist[query][--env<production|test>][--limit<n>][--all][--sort<usage|name|id>][--strict][--corp<corpId>]\nseal-usecorpssearch<query>[--env<production|test>][--strict]\nseal-usecorpsget<corpId>\nseal-usecorpscurrent[--corp<corpId>]\nseal-usecorpsswitch<corpId>\nseal-usecorpsmark<corpId>--env<production|test>[--confirm]\nseal-usecorpsbind-test<prodCorpId><testCorpId>[--confirm][--force]\nseal-usecorpsunbind-test[<corpId>][--confirm]\nseal-usecorpssync-test[<prodCorpId>][--dry-run][--yes][--version-name<name>]\nseal-usecorpsreplay-test[<prodCorpId>][--record-id<id>][--sn<sn>][--limit<n>][--status<status>][--webhook<idOrName>][--sn-suffix<str>][--dry-run][--force]\nseal-usecorpsregression[--corp<corpId>][--samples<N>][--dry-run][--fail-on-flips]\nseal-usecorpsadd-hose--json'{\"name\":\"企业名称\",\"domain\":\"https://app.ekuaibao.com\",\"appKey\":\"...\",\"appSecurity\":\"...\",\"proxyStaffBizId\":\"corpId:staffId\"}'\nseal-usecorpsadd-seal--json'{\"sealUrl\":\"https://tenant.sealai.cc\",\"token\":\"seal-bearer-token\"}'\nseal-usecorpsadd-link<https://.../web/thirdparty.html?...>[--name<customName>][--overwrite]\nseal-useauthdiagnose[--corp<corpId>]\nseal-useauthhose-link[--corp<corpId>][--expire7200]Line truncated
-\`seal-use auth diagnose\` proves this stage works but redacts the token, so it is not enough when the user needs the actual clickable Hose link.
-**FormattingRequirement**:WhenreturningaHoseauthorizationlinktotheuser,ALWAYSprovideBOTHacodeblock(\`\`\`\`text ... \`\`\`\`) for easy copying without accidental default browser redirection, AND a clickable hyperlink.
`)}D4();n1();async function uh0($,I,z){let q=($??I??"").toLowerCase();if(q==="guide"||q==="doc"||q==="knowledge"||q==="book"){console.error(`\uD83D\uDCD6[SealUseDoctor]正在读取内嵌系统规范白皮书(纯内存只读)...
`)}_4();o1();async function Bg0($,q,Y){let z=($??q??"").toLowerCase();if(z==="guide"||z==="doc"||z==="knowledge"||z==="book"){console.error(`\uD83D\uDCD6[SealUseDoctor]正在读取内嵌系统规范白皮书(纯内存只读)...
`},servers:[{url:"http://localhost:8787",description:"Reserved for a future local HTTP adapter; the current service uses MCP stdio."}],security:[{localSession:[]}],tags:[{name:"Corps",description:"Local enterprise configuration selection."},{name:"Source",description:"Source-derived Seal enterprise configuration."},{name:"Auth",description:"Wrapped authentication diagnostics and current identity."},{name:"Approval Runs",description:"Wrapped approval run history, summaries, document URLs, and trace bridge helpers."},{name:"Approval Knowledge",description:"Wrapped approval rules, documents, preferences, and search."},{name:"Simulation",description:"Wrapped simulation batch record access."}],paths:{"/v1/corps":{get:{tags:["Corps"],operationId:"listCorps",summary:"List configured enterprises",responses:{"200":{description:"Configured enterprises.",content:{"application/json":{schema:{type:"array",items:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","direct","seal"]},current:{type:"boolean"}}}}}}}}}},"/v1/corps/current":{get:{tags:["Corps"],operationId:"getCurrentCorp",summary:"Get current enterprise",description:"Returns the configured default enterprise in stateful mode. Stateless mode has no current enterprise and requires an explicit corpId for enterprise operations.",responses:{"200":{description:"Current enterprise.",content:{"application/json":{schema:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","direct","seal"]},current:{type:"boolean"}}}}}}}}},"/v1/corps/current/switch":{post:{tags:["Corps"],operationId:"switchCurrentCorp",summary:"Switch current enterprise",requestBody:{required:!0,content:{"application/json":{schema:{type:"object",required:["corpId"],properties:{corpId:{type:"string"}}}}}},responses:{"200":{description:"Switched enterprise.",content:{"application/json":{schema:{type:"object",required:["current","id","name"],properties:{current:{type:"boolean"},id:{type:"string"},name:{type:"string"}}}}}},"404":{description:"Requested resource was not found.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}}}},"/v1/source/config":{get:{tags:["Source"],operationId:"getSourceConfig",summary:"Resolve source-derived Seal enterprise config",parameters:[{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."}],responses:{"200":{description:"Redacted Seal enterprise config.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,description:"Redacted Seal enterprise config resolved from the configured source."}}}},"401":{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:{}}}}}}}}},"/v1/auth/diagnose":{get:{tags:["Auth"],operationId:"diagnoseAuth",summary:"Diagnose wrapped source-to-Seal authentication",parameters:[{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."}],responses:{"200":{description:"Authentication stage diagnosis.",content:{"application/json":{schema:{type:"object",required:["stages"],properties:{stages:{type:"array",items:{$ref:"#/components/schemas/AuthStage"}}}}}}}}}},"/v1/whoami":{get:{tags:["Auth"],operationId:"whoami",summary:"Get current wrapped Seal identity",parameters:[{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."}],responses:{"200":{description:"Current Seal user and tenant.",content:{"application/json":{schema:{type:"object",required:["user","tenant"],properties:{user:{$ref:"#/components/schemas/SealUser"},tenant:{$ref:"#/components/schemas/SealTenant"}}}}}},"401":{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:{}}}}}}}}},"/v1/session":{get:{tags:["Auth"],operationId:"getSession",summary:"Get current wrapped Seal session metadata",parameters:[{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."}],responses:{"2
Line truncated
`},servers:[{url:"http://localhost:8787",description:"Reserved for a future local HTTP adapter; the current service uses MCP stdio."}],security:[{localSession:[]}],tags:[{name:"Corps",description:"Local enterprise configuration selection."},{name:"Source",description:"Source-derived Seal enterprise configuration."},{name:"Auth",description:"Wrapped authentication diagnostics and current identity."},{name:"Approval Runs",description:"Wrapped approval run history, summaries, document URLs, and trace bridge helpers."},{name:"Approval Knowledge",description:"Wrapped approval rules, documents, preferences, and search."},{name:"Simulation",description:"Wrapped simulation batch record access."}],paths:{"/v1/corps":{get:{tags:["Corps"],operationId:"listCorps",summary:"List configured enterprises",responses:{"200":{description:"Configured enterprises.",content:{"application/json":{schema:{type:"array",items:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","direct","seal"]},current:{type:"boolean"}}}}}}}}}},"/v1/corps/current":{get:{tags:["Corps"],operationId:"getCurrentCorp",summary:"Get current enterprise",description:"Returns the configured default enterprise in stateful mode. Stateless mode has no current enterprise and requires an explicit corpId for enterprise operations.",responses:{"200":{description:"Current enterprise.",content:{"application/json":{schema:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","direct","seal"]},current:{type:"boolean"}}}}}}}}},"/v1/corps/current/switch":{post:{tags:["Corps"],operationId:"switchCurrentCorp",summary:"Switch current enterprise",requestBody:{required:!0,content:{"application/json":{schema:{type:"object",required:["corpId"],properties:{corpId:{type:"string"}}}}}},responses:{"200":{description:"Switched enterprise.",content:{"application/json":{schema:{type:"object",required:["current","id","name"],properties:{current:{type:"boolean"},id:{type:"string"},name:{type:"string"}}}}}},"404":{description:"Requested resource was not found.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}}}},"/v1/source/config":{get:{tags:["Source"],operationId:"getSourceConfig",summary:"Resolve source-derived Seal enterprise config",parameters:[{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."}],responses:{"200":{description:"Redacted Seal enterprise config.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,description:"Redacted Seal enterprise config resolved from the configured source."}}}},"401":{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:{}}}}}}}}},"/v1/auth/diagnose":{get:{tags:["Auth"],operationId:"diagnoseAuth",summary:"Diagnose wrapped source-to-Seal authentication",parameters:[{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."}],responses:{"200":{description:"Authentication stage diagnosis.",content:{"application/json":{schema:{type:"object",required:["stages"],properties:{stages:{type:"array",items:{$ref:"#/components/schemas/AuthStage"}}}}}}}}}},"/v1/whoami":{get:{tags:["Auth"],operationId:"whoami",summary:"Get current wrapped Seal identity",parameters:[{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."}],responses:{"200":{description:"Current Seal user and tenant.",content:{"application/json":{schema:{type:"object",required:["user","tenant"],properties:{user:{$ref:"#/components/schemas/SealUser"},tenant:{$ref:"#/components/schemas/SealTenant"}}}}}},"401":{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:{}}}}}}}}},"/v1/session":{get:{tags:["Auth"],operationId:"getSession",summary:"Get current wrapped Seal session metadata",parameters:[{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."}],responses:{"2
Line truncated
`);U(q)})})}async function ih0($){let I=R0($.options.port)??R0($.options.p),z=E($.options.host)??E($.options.h),q=await lA({port:I,host:z}),U=()=>{q.close(()=>{process.exit(0)})};process.on("SIGINT",U),process.on("SIGTERM",U),await new Promise(()=>{})}x4();n1();async function nh0($,I,z,q){if($==="config"||$==="get"){await N0("seal_llm_config_get",I,z,{},V0(q.options));return}if($==="providers"||$==="list"){await N0("seal_llm_providers_list",I,z,{},V0(q.options));return}throw Error(`Unknownllmcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}n1();async function ch0($,I){if($==="config"||$==="json"){Qd();return}await Kd()}function Qd(){P0({mcpServers:{"seal-use":{type:"stdio",command:"seal-use",args:["mcp"],env:{SEAL_USE_MCP_ENABLED:"true"}}}})}n1();function ph0($){let I=nA();P0(I,{...V0($.options),allowFull:!0})}x4();n1();async function dh0($,I,z,q){if($==="available"){await N0("seal_permissions_available_list",I,z,{},V0(q.options));return}if($==="configs"||$==="list"){await N0("seal_permissions_configs_list",I,z,{},V0(q.options));return}throw Error(`Unknownpermissionscommand:${$??""}.Run'seal-use help'foravailablecommands.`)}x4();D4();n1();import{readFileSync as mh0}from"node:fs";async function lh0($,I,z,q,U,Y,J){if(!$||$==="get"){await N0("seal_preference_get",U,Y,{},V0(J.options));return}if($==="decision"){if(I==="update"||!I){let Q=E(J.options.input),K=Q?JSON.parse(mh0(Q,"utf8")):P8(J.json);if(!K||Object.keys(K).length===0)throw Error(`Usage:seal-usepreferencedecisionupdate--json'{"explicitApprove":"..."}'`);await N0("seal_preference_decision_update",U,Y,{...K,dryRun:X0(J.options.dryRun)??X0(J.options["dry-run"])},V0(J.options));return}}if($==="thinking-depth"||$==="thinkingDepth"){if(I==="set"){let Q=E(J.options.default)??E(J.options.level)??q;if(Q!=="medium"&&Q!=="high")throw Error("Usage: seal-use preference thinking-depth set --default <medium|high>");await N0("seal_preference_thinking_depth_set",U,Y,{defaultLevel:Q,dryRun:X0(J.options.dryRun)??X0(J.options["dry-run"])},V0(J.options));return}if(I==="policies"){if(z==="list"||!z){await N0("seal_preference_thinking_depth_policies_list",U,Y,{},V0(J.options));return}if(z==="upsert"){let Q=E(J.options.input),K=Q?JSON.parse(mh0(Q,"utf8")):P8(J.json);if(!K||!K.id||!K.name)throw Error(`Usage:seal-usepreferencethinking-depthpoliciesupsert--json'{"id":"...","name":"...","level":"high"}'`);await N0("seal_preference_thinking_depth_policies_upsert",U,Y,{...K,dryRun:X0(J.options.dryRun)??X0(J.options["dry-run"])},V0(J.options));return}if(z==="remove"||z==="delete"){let Q=q??E(J.options.id)??E(J.options.policyId);if(!Q)throw Error("Usage: seal-use preference thinking-depth policies remove <policyId>");await N0("seal_preference_thinking_depth_policies_remove",U,Y,{policyId:Q,dryRun:X0(J.options.dryRun)??X0(J.options["dry-run"])},V0(J.options));return}}}throw Error(`Unknownpreferenceaction:${$??""}.Available:get,decisionupdate,thinking-depthset,thinking-depthpolicieslist/upsert/remove.`)}e9();S8();e4();async function oh0($={}){let I=c8(),z=O4(),q=l7(I,{stateful:z.stateful,defaultCorpId:z.defaultCorpId,corpId:$.corpId},a9());console.log(`[probe]corp=${q.id}source=${q.source.type}`);let U=await LJ(q);console.log("[probe] seal enterprise"),console.log(JSON.stringify(U,null,2));let Y=await K1(q),J=await xw(Y,{documentLimit:20,stylePreferencesEndpoint:q.seal.endpoints.approvalStylePreferences});console.log("[probe] approval context summary"),console.log(JSON.stringify({rules:J.rules.rules.length,hasPendingRuleDeletes:J.rules.hasPendingDeletes,documents:J.documents.articles.length,documentsTotal:J.documents.total,stylePreferences:J.stylePreferences.ok?"ok":`error:${J.stylePreferences.error}`},null,2))}D4();async function rh0($,I,z){let q=I??E(z.options.corp)??($&&$!=="--corp"?$:void 0);await oh0({corpId:q})}Ci();x4();H$();D4();n1();async function Hd($,I,z,q,U){if($==="count"){await N0("seal_approval_rules_list",z,q,{countOnly:!0},V0(U.options));return}if($==="list"){if(X0(U.options.count)){await N0("seal_approval_rules_list",z,q,{countOnly:!0},V0(U.options));return}let Y=R0(U.options.limit),J=R0(U.options.offset);if(X0(U.options.summary)){await N0("seal_approval_rules_list",z,q,{fields:yR0,limit:Y,offset:J},V0(U.options));return}let Q=await q2("seal_approval_rules_list",z,q,{limit:Y,offset:J});xR0(Q,X0(U.options.full)===!0),P0(Q);return}if($==="clear"){let Y=X0(U.options.yes)===!0,J=X0(U.options.dryRun)??X0(U.options["dry-run"])??!Y;if(!Y&&!J)throw e5("Refusing to clear rules without --yes. Use --dry-run to preview.",`seal-userulesclear--corp${q.id}--dry-run`);let Q=await q2("seal_approval_rules_clear",z,q,{dryRun:J,recode:X0(U.options.recode)});if(!Y&&J&&Q&&typeof Q==="object"){P0({...Q,nextCommand:`seal-userulesclear--corp${q.id}--yes`},V0(U.options));return}P0(Q,V0(U.options));return}if($==="versions"){await N0("seal_approval_rule_versions_list",z,q,{},V0(U.options));return}if($==="version"){let Y=I??E(U.op
Line truncated
`).filter(Boolean),Y=U.slice(-I);return{logFile:z,lines:Y,totalLines:U.length}}async function gf1($){let I=tA($),z=Wd($),q=IW($);eh0($.stateDir);let U=$.port??(process.env.PORT?Number.parseInt(process.env.PORT,10):dA),Y=$.host??(process.env.HOST?process.env.HOST:mA);rA(I,`${process.pid}
`,{mode:384}),rA(z,JSON.stringify({pid:process.pid,port:U,host:Y,version:$.version,startedAt:new Date().toISOString()},null,2),{mode:384}),OJ(q,`servicestartingonhttp://${Y}:${U} pid=${process.pid}`);let J=null;try{J=await lA({port:U,host:Y,silent:!0}),OJ(q,`service listening pid=${process.pid}`)}catch(K){if(OJ(q,`service failed to bind port ${U}: ${K instanceof Error?K.message:String(K)}`),sA(I)===process.pid)K9(I,{force:!0}),K9(z,{force:!0});throw K}let Q=()=>{if(J)J.close(),J=null;if(sA(I)===process.pid)K9(I,{force:!0}),K9(z,{force:!0});OJ(q,`stopped pid=${process.pid}`)};await new Promise((K)=>{let H=!1,G=()=>{if(H)return;H=!0,Q(),process.off("SIGTERM",G),process.off("SIGINT",G),K()};process.once("SIGTERM",G),process.once("SIGINT",G)})}function sh0($){eh0($.stateDir);let I=FJ($);if(I.running)return I;let z=$.launcher??{command:process.execPath,args:[$.entryFile]},q=[...z.args??[],"service","run"];if($.port)q.push("--port",String($.port));if($.host)q.push("--host",String($.host));let U=_f1(z.command,q,{cwd:$.appRoot,detached:!0,stdio:["ignore","ignore","ignore"],env:process.env});U.unref();let Y=tA($);return rA(Y,`${U.pid}
`,{flag:"a",mode:384})}n1();D4();var Xd=xf1(yf1(),".config","seal-use");async function Vd($,I,z){let q=z?R0(z.options.port)??R0(z.options.p):void 0,U=z?E(z.options.host)??E(z.options.h):void 0,Y=z?R0(z.options.lines)??R0(z.options.n):void 0,J=await Nz($,{appRoot:I.appRoot,entryFile:I.entryFile,stateDir:Xd,version:q1,launcher:I.launcher,port:q,host:U},{maxLines:Y});if(J!==void 0)P0(J)}x4();D4();n1();import{existsSync as uf1,readFileSync as $g0}from"node:fs";async function Ig0($,I,z,q,U){if($==="batch-records"||$==="records"){let Y=I??E(U.options.batchId)??E(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation batch-records <batchId>");await N0("seal_simulation_batch_records_get",z,q,{batchId:Y,query:E(U.options.query)},V0(U.options));return}if($==="create"||$==="run"){let Y=E(U.options.mode)??E(U.options.sourceSystem)??E(U.options["source-system"])??"hosecloud",J=Y==="material-pack"?"material_pack":Y,Q=E(U.options.schemaConfig)??E(U.options["schema-config"]),K=Q?JSON.parse($g0(Q,"utf8")):void 0,H=E(U.options.input),G=H?JSON.parse($g0(H,"utf8")):P8(U.json),Z=E(U.options.packageId)??E(U.options["package-id"]),W=P6(U.options.packageIds)??P6(U.options["package-ids"])??(Z?[Z]:void 0),X=P6(U.options.flowIds)??P6(U.options["flow-ids"])??P6(U.options.documentSn)??P6(U.options["document-sn"]),w=E(U.options.signKey)??E(U.options["sign-key"])??E(U.options.integration),L=X0(U.options.noWait)??X0(U.options["no-wait"]);await N0("seal_simulation_batch_create",z,q,{mode:J,sourceSystem:J,flowIds:X,documentSn:X,rejectNodeName:E(U.options.rejectNode)??E(U.options["reject-node"])??null,thinkingDepthOverride:E(U.options.thinkingDepth)??E(U.options["thinking-depth"]),skipInvoiceGeneration:X0(U.options.skipInvoiceGeneration)??X0(U.options["skip-invoice-generation"]),skipExpenseExtraction:X0(U.options.skipExpenseExtraction)??X0(U.options["skip-expense-extraction"]),disableAttachmentCache:X0(U.options.disableAttachmentCache)??X0(U.options["disable-attachment-cache"]),signKey:w,packageIds:W,packageId:Z,templateId:E(U.options.templateId)??E(U.options["template-id"]),schemaConfig:K,requestIds:P6(U.options.requestIds)??P6(U.options["request-ids"]),workflowTypeId:E(U.options.workflowTypeId)??E(U.options["workflow-type-id"]),flowStatusList:P6(U.options.flowStatusList)?.map(Number)??P6(U.options["flow-status-list"])?.map(Number),businessCodes:P6(U.options.businessCodes)??P6(U.options["business-codes"]),documentType:E(U.options.documentType)??E(U.options["document-type"]),startTime:R0(U.options.startTime)??R0(U.options["start-time"]),endTime:R0(U.options.endTime)??R0(U.options["end-time"]),status:P6(U.options.status),limit:R0(U.options.limit),noWait:L,rawParams:G},V0(U.options));return}if($==="wait"){let Y=I??E(U.options.batchId)??E(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s]");await N0("seal_simulation_batch_wait",z,q,{batchId:Y,timeout:E(U.options.timeout),pollInterval:E(U.options.pollInterval)??E(U.options["poll-interval"])},V0(U.options));return}if($==="status"){let Y=I??E(U.options.batchId)??E(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation status <batchId>");await N0("seal_simulation_batch_status",z,q,{batchId:Y},V0(U.options));return}if($==="clean"||$==="delete"){let Y=I??E(U.options.batchId)??E(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation clean <batchId>");await N0("seal_simulation_batch_clean",z,q,{batchId:Y},V0(U.options));return}if($==="specifications"){let Y=I??E(U.options.integration)??E(U.options.signKey)??E(U.options["sign-key"]);await N0("seal_simulation_specifications_list",z,q,{signKey:Y},V0(U.options));return}if($==="approval-definitions"||$==="definitions"){await N0("seal_simulation_feishu_approval_definitions_list",z,q,{},V0(U.options));return}if($==="list"){await N0("seal_simulation_batches_list",z,q,{limit:R0(U.options.limit)},V0(U.options));return}if($==="get"){let Y=I??E(U.options.batchId)??E(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation get <batchId>");await N0("seal_simulation_batch_get",z,q,{batchId:Y},V0(U.options));return}if($==="templates"){await N0("seal_simulation_templates_get",z,q,{},V0(U.options));return}if($==="integrations"){await N0("seal_simulation_integrations_get",z,q,{},V0(U.options));return}if($==="package-upload"){let Y=I??E(U.options.file);if(!Y)throw Error("Usage: seal-use simulation package-upload <材料包.zip>");if(!uf1(Y))throw Error(`Filenotfound:${Y}`);await N0("seal_simulation_material_package_upload",z,q,{filePath:Y},V0(U.options));return}throw Error(`Unknownsimulationcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}import{existsSync as zg0}from"node:fs";import{join as aA}from"node:path";D4();n1();function qg0($,I,z){if($==="dump"||$==="cat"||$==="show"){process.stdout.write(`${_h0()}
`);return}if($==="install"||$==="init"||$==="sync"){let q=X0(z.options.local)||X0(z.options.workspace),U=E(z.options.dir)??E(z.options.target)??I,Y=U?U:q?aA(process.cwd(),".agents","skills","seal-use"):Mz(),J=$d(Y);P0({installed:!0,targetDir:J.targetDir,fileCount:J.files.length,files:J.files});return}if($==="status"||$==="get"||!$){let q=Mz(),U=aA(process.cwd(),".agents","skills","seal-use");P0({global:{dir:q,installed:zg0(aA(q,"SKILL.md"))},local:{dir:U,installed:zg0(aA(U,"SKILL.md"))}});return}throw Error(`Unknownskillcommand:${$}.Run'seal-use help'foravailablecommands.`)}n1();async function Ug0($,I){if($==="config"){P0(await LJ(I));return}throw Error(`Unknownsourcecommand:${$??""}.Run'seal-use help'foravailablecommands.`)}H$();x4();D4();n1();S8();H$();e4();GZ();function wd($){if(typeof $!=="string"||!$.trim())return"UNKNOWN";let I=$.toUpperCase().trim();if(I==="APPROVE"||I==="PASS")return"APPROVE";if(I==="REJECT"||I==="DENIED")return"REJECT";if(I==="MANUAL"||I==="ASSISTED")return"MANUAL";if(I==="ERROR"||I==="FAILED")return"ERROR";return I}async function Yg0($){let{sourceCorp:I,targetCorp:z,sourceClient:q,targetClient:U,samples:Y=10,dryRun:J=!1,pollIntervalMs:Q=2000,timeoutMs:K=45000,snPrefix:H="REG_",fetchFn:G=fetch}=$;if(z.environment!=="test")throw new h4(`重放目标企业「${z.name}」(${z.id})的环境为「${z.environment}」,非测试环境!
`+"硬性安全规定:自动化回归测试矩阵严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-usecorpsbind-test${I.id}<testCorpId>`);let Z=await C2(U),X=(Array.isArray(Z.features)?Z.features:[]).find((u)=>u?.code==="ai-approval"),w=typeof X?.balance==="number"?X.balance:0,L=typeof X?.deductionAmount==="number"&&X.deductionAmount>0?X.deductionAmount:120,O=Y*L;if(w<O)throw new h4(`测试企业「${z.name}」AI审批额度不足:当前剩余${w}点,本次回归抽样${Y}笔需要约${O}点。
`+"为防止测试环境额度耗尽中断业务,已硬性拦截并拒绝发起测试单据注入。",2,`请为测试企业「${z.id}」充值AI审批额度,或降低抽样笔数(--samples${Math.max(1,Math.floor(w/L))})`);let F=await a4(q,{limit:Y,status:"completed"}),D=Array.isArray(F.records)?F.records:[];if(D.length===0){let u=await a4(q,{limit:Y});D=Array.isArray(u.records)?u.records:[]}if(D.length===0)throw new h4(`在母企业「${I.name}」(${I.id})中未检索到任何历史审批单据,无法抽取回归样本。`,2);if(D=D.slice(0,Y),J){let u=D.map((p)=>{let s=p.sourceDocumentSN??p.id,U0=p?.result?.decision??p.aiDecision??p?.decision,H0=wd(U0),D0=p?.result?.summary??p.aiSummary;return{sn:s,sourceRecordId:p.id,prodDecision:H0,prodSummary:D0,status:"DRY_RUN"}});return{ok:!0,verdict:"DRY_RUN",safeToPublish:!0,timestamp:new Date().toISOString(),sourceCorp:{id:I.id,name:I.name,environment:I.environment??"production"},targetCorp:{id:z.id,name:z.name,environment:z.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:w,deductionAmount:L,estimatedRequired:O},metrics:{sampleCount:u.length,successCount:u.length,failureCount:0,matchCount:u.length,flipCount:0,concordanceRate:1},flips:[],records:u}}let P=await Mi(U,z),A=[];for(let u of D){let p=Date.now(),s=u.sourceDocumentSN??u.id,U0=wd(u?.result?.decision??u.aiDecision??u?.decision),H0=u?.result?.summary??u.aiSummary;try{let D0=await z4(q,u.id),_0=`${H}${s}`,Y1=Oi(D0,{snPrefix:H,docIdPrefix:H});await Fi(P.incomingDocumentWebhook.url,P.secret,Y1,G,K6(z.seal));let u0=null,r0=Date.now();while(Date.now()-r0<K){await new Promise((t4)=>setTimeout(t4,Q));let k4=await a4(U,{sourceDocumentSN:_0,limit:1});if(k4.records&&k4.records.length>0){let t4=k4.records[0];if(t4.status==="completed"||t4.status==="failed"){u0=t4;break}}}if(!u0){A.push({sn:s,sourceRecordId:u.id,prodDecision:U0,prodSummary:H0,status:"FAILED",error:`测试租户单据审核超时(${Math.round(K/1000)}s未完成)`,durationMs:Date.now()-p});continue}let I1=wd(u0?.result?.decision??u0.aiDecision??u0?.decision??(u0.status==="completed"?"APPROVE":"ERROR")),o=u0?.result?.summary??u0.aiSummary,E0=U0===I1,k0=E0?"MATCHED":"FLIPPED",L1={sn:s,sourceRecordId:u.id,prodDecision:U0,prodSummary:H0,testRecordId:u0.id,testDecision:I1,testSummary:o,status:k0,durationMs:Date.now()-p};if(!E0)L1.diff={from:U0,to:I1,reasonDiff:o&&H0&&o!==H0?`生产:${H0.slice(0,60)}...->测试:${o.slice(0,60)}...`:void 0};A.push(L1)}catch(D0){A.push({sn:s,sourceRecordId:u.id,prodDecision:U0,prodSummary:H0,status:"FAILED",error:D0 instanceof Error?D0.message:String(D0),durationMs:Date.now()-p})}}let T=A.filter((u)=>u.status==="MATCHED"||u.status==="FLIPPED"),k=A.filter((u)=>u.status==="MATCHED"),h=A.filter((u)=>u.status==="FLIPPED"),f=A.filter((u)=>u.status==="FAILED").length,C=k.length,b=h.length,i=C+b,v=i>0?C/i:0,y=b>0,c=y?"REGRESSIONS_DETECTED":"CLEAN",$0=!y&&f===0,R;try{let u=await C2(U),s=(Array.isArray(u.features)?u.features:[]).find((U0)=>U0?.code==="ai-approval");if(typeof s?.balance==="number")R=s.balance}catch{}return{ok:!y&&f===0,verdict:c,safeToPublish:$0,timestamp:new Date().toISOString(),sourceCorp:{id:I.id,name:I.name,environment:I.environment??"production"},targetCorp:{id:z.id,name:z.name,environment:z.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:w,deductionAmount:L,estimatedRequired:O,balanceAfter:R},metrics:{sampleCount:A.length,successCount:T.length,failureCount:f,matchCount:C,flipCount:b,concordanceRate:Number(v.toFixed(4))},flips:h,records:A}}function Jg0($){let{sourceCorp:I,targetCorp:z,verdict:q,safeToPublish:U,metrics:Y,quota:J,flips:Q,records:K}=$,H=q==="CLEAN"?"\uD83D\uDFE2 决策完全一致 (CLEAN - 无回归)":q==="DRY_RUN"?"⚪ 预演模式 (DRY-RUN)":"\uD83D\uDD34 发现决策翻转 (REGRESSIONS_DETECTED)",G=["",`\uD83E\uDDEA[SealUseTest]规则回归测试矩阵:生产「${I.name}」->测试靶场「${z.name}」`,`判定:${H}·准许发布:${U?"YES (可安全上线)":"NO (存在行为偏离/待复核)"}`," "+"─".repeat(65),`样本总数:${Y.sampleCount}|一致通过:${Y.matchCount}|决策翻转:${Y.flipCount}|异常失败:${Y.failureCount}`,`一致率:${(Y.concordanceRate*100).toFixed(1)}%|消耗预估:${J.estimatedRequired}点(余量:${J.balanceBefore}${J.balanceAfter!==void0?` -> ${J.balanceAfter}`:""})`," "+"─".repeat(65)];if(Q.length>0){G.push(`⚠️决策翻转清单(${Q.length}笔单据在新规则下结果改变):`);for(let Z of Q)if(G.push(`•单据[${Z.sn}]:原生产判定「${Z.prodDecision}」➔测试新判定「${Z.testDecision}」`),Z.diff?.reasonDiff)G.push(`理由差异:${Z.diff.reasonDiff}`);G.push(" "+"─".repeat(65)),G.push(" \uD83D\uDC49 建议: 请检查上述翻转单据是否符合预期修正。若为意外误杀,请调整测试环境规则后再次回归。")}else if(q==="CLEAN")G.push(" ✓ 全部样本在新规则下的审核决策与生产历史 1
Line truncated
`)}async function Ld($,I,z){let q=($??I??"regression").toLowerCase();if(q==="regression"||q==="regress"||q==="matrix"){let U=E(z.options.corp)??(I&&I!==q?I:void 0),Y=W1(U),J=Y,Q=Y;if(Y.environment==="test"){Q=Y;let D=E(z.options["prod-corp"])??E(z.options.prod)??Y.prodCorpId;if(!D)throw new h4(`测试企业「${Y.name}」(${Y.id})未绑定生产母企业,无法拉取历史样本。
`+"请建立绑定或通过 --prod-corp 参数指定生产企业来源。",2,`seal-usecorpsbind-test<prodCorpId>${Y.id}`);J=W1(D)}else{J=Y;let D=E(z.options["test-corp"])??E(z.options.test)??Y.testCorpId;if(!D)throw new h4(`生产企业「${Y.name}」(${Y.id})未绑定测试靶场企业。
`+"硬性规定:回归测试严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-usecorpsbind-test${Y.id}<testCorpId>`);Q=W1(D)}let K=await K1(J),H=await K1(Q),G=R0(z.options.samples)??R0(z.options.limit)??R0(z.options.n)??10,Z=X0(z.options["dry-run"]),W=X0(z.options["fail-on-flips"]),X=R0(z.options["poll-interval"])??2000,w=R0(z.options.timeout)??45000,L=E(z.options["sn-prefix"])??"REG_",O=await Yg0({sourceCorp:J,targetCorp:Q,sourceClient:K,targetClient:H,samples:G,dryRun:Z,pollIntervalMs:X,timeoutMs:w,snPrefix:L,failOnFlips:W});if(!(X0(z.options.quiet)||X0(z.options.silent)))console.error(Jg0(O));if(P0(O),W&&!O.ok)throw new h4(`回归测试发现${O.metrics.flipCount}笔单据决策翻转,已按--fail-on-flips策略非零终止。`,1);return}throw new h4(`未知的test子命令:"${q}"。
可用子命令:seal-usetestregression[--corp<id>][--samples<N>][--dry-run]`,2,"seal-use test regression --help")}x4();D4();n1();async function Qg0($,I,z,q){if(!$)throw Error("Usage: seal-use tool <toolName> [--json '{...}']");await N0($,I,z,P8(q.json),V0(q.options))}CA();n1();function Kg0(){P0(dZ.map(($)=>({name:$.name,description:$.description})))}import{chmodSync as kf1,mkdirSync as ff1,renameSync as Od,rmSync as bf1,unlinkSync as Xg0,writeFileSync as Hg0}from"node:fs";import{dirname as if1,join as Gg0}from"node:path";import{spawnSync as Dz}from"node:child_process";function eA($=process.execPath,I=import.meta.url){if(I.includes("/$bunfs/")||I.includes("\\$bunfs\\"))return!0;let z=$.toLowerCase().replace(/\\/g,"/");return!z.endsWith("/bun")&&!z.endsWith("/bun.exe")&&!z.endsWith("/node")&&!z.endsWith("/node.exe")}n1();var Vg0="yunyingk/seal-use",qW="yunyingk/seal-home";var nf1="SEAL_USE_GITHUB_REPO",cf1="SEAL_HOME_GITHUB_REPO";async function wg0($,I={}){let z={appRoot:$.appRoot,entryFile:$.entryFile,stateDir:Xd,version:q1,launcher:$.launcher},q=I.repo||process.env[nf1]?.trim()||process.env[cf1]?.trim()||Vg0,U=I.targetVersion?.trim(),Y=U&&U.toLowerCase()!=="latest"?U:void 0;if(Y){let A=Y.replace(/^v/,""),T=Lg0(A,q1);if(T<0)if(!Jv&&I.force);else{P0({updated:!1,currentVersion:q1,targetVersion:A,mode:eA()?"binary":"source",message:!Jv?`Cannotdowngradeseal-usefromdevbuildv${q1}toreleasev${A}.Use--forcetooverwrite.`:`Cannotdowngradeseal-usefromv${q1}toolderversionv${A}.Updatesmustbeforward-only.`});return}if(T===0&&!I.force){P0({updated:!1,currentVersion:q1,targetVersion:A,mode:eA()?"binary":"source",message:`seal-useisalreadyatversionv${q1}.Use--forcetoreinstall.`});return}}if(I.changelogOnly){let A=await Fd(q,I.limit??10);P0({currentVersion:q1,totalQueried:A.length,releases:A.map((T)=>({version:T.version,tagName:T.tagName,publishedAt:T.publishedAt,author:T.author,releaseNotes:T.notes,releaseUrl:T.htmlUrl,isCurrent:T.version===q1,isNewer:zW(T.version,q1)}))});return}if(!eA()){if(I.checkOnly){let T=await Fd(q,30),k=T[0],h=k?.version??q1,f=T.find((i)=>i.version===q1),C=zW(h,q1),b=T.filter((i)=>zW(i.version,q1));P0({updated:!1,updateAvailable:C,currentVersion:q1,currentVersionPublishedAt:f?.publishedAt,latestVersion:h,latestVersionPublishedAt:k?.publishedAt,behindCount:b.length,pendingReleases:b.map((i)=>({version:i.version,tagName:i.tagName,publishedAt:i.publishedAt,author:i.author,releaseNotes:i.notes,releaseUrl:i.htmlUrl})),releaseNotes:k?.notes??"",releaseUrl:k?.htmlUrl??"",mode:"source",message:"Running in source development mode. Run 'seal-use update' to git pull & bun install."});return}let A=FJ(z).running;if(A)await Nz("stop",z);try{Wg0("git",["-C",$.appRoot,"pull","--ff-only"])}catch(T){console.error(`gitpullskipped:${TinstanceofError?T.message:String(T)}`)}if(Wg0("bun",["install"],{cwd:$.appRoot}),A)await Nz("start",z);P0({updated:!0,serviceRestarted:A,version:q1,mode:"source"});return}let J=pf1(),Q=df1(),K=await Fd(q,30),H=Y?K.find((A)=>A.version===Y||A.tagName===Y||A.tagName===`v${Y}`)??await Zg0(q,Y):K[0]??await Zg0(q);if(!H){P0({updated:!1,currentVersion:q1,mode:"binary",message:`Failedtoqueryreleasesfromrepository'${q}'`});return}let G=H.version,Z=K.find((A)=>A.version===q1),W=zW(G,q1),X=W||Boolean(I.force),w=K.filter((A)=>zW(A.version,q1));if(I.checkOnly){P0({updated:!1,updateAvailable:W,currentVersion:q1,currentVersionPublishedAt:Z?.publishedAt,latestVersion:G,latestVersionPublishedAt:H.publishedAt,behindCount:w.length,pendingReleases:w.map((A)=>({version:A.version,tagName:A.tagName,publishedAt:A.publishedAt,author:A.author,releaseNotes:A.notes,releaseUrl:A.htmlUrl})),releaseNotes:H.notes,releaseUrl:H.htmlUrl,mode:"binary"});return}if(!X){P0({updated:!1,currentVersion:q1,currentVersionPublishedAt:Z?.publishedAt,latestVersion:G,latestVersionPublishedAt:H.publishedAt,mode:"binary",message:`seal-useisalreadyuptodate(v${q1})`});return}let L=mf1(H.assets,J,Q);if(!L)throw Error(`Nocompatiblebinaryfoundfor${J}-${Q}inreleasev${G}.Availableassets:${H.assets.map((A)=>A.name).join(", ")}`);let O=FJ(z).running;if(O)await Nz("stop",z);let F=process.execPath,D=if1(F),P=Gg0(D,`.tmp-update-${Date.now()}`);ff1(P,{recursive:!0});try{let A=Gg0(P,L.name);await lf1(L.downloadUrl,A,H.tagName,L.name);let T=A;if(L.name.endsWith(".tar.gz")||L.name.endsWith(".tgz"))T=of1(A,P,J);else if(L.name.endsWith(".zip"))T=rf1(A,P,J);if(kf1(T,493),process.platform==="darwin")try{Dz("/usr/bin/codesign",["--remove-signature",T],{stdio:"ignore"}),Dz("/usr/bin/codesign",["--force","--sign","-",T],{stdio:"ignore"})}catch{}if(process.platform==="win32"){let h=`${F}.old.${Date.now()}`;try{Od(F,h)}catch{}Od(T,F)}else Od(T,F);if(O)await Nz("start",z);let k=Id();P0({updated:!0,fromVersion:q1,toVersion:G,serviceRestarted:O,skillSynced:k.synced?k.targetDir:!1,mode:"binary"})}finally{try{bf1(P,{recursive:!0,force:!0})}catch{}}}function pf1(){if(process.platform==="darwin")retur
Line truncated
`)}catch{}}async function lf1($,I,z,q){let U=Md(),Y=[],J=z?z.startsWith("v")?z:`v${z}`:void 0,Q=q||$.split("/").pop()||"";if(U!=="github"){if(J&&Q)Y.push(`https://git.ying-qing.cn/gitea/seal-use/releases/download/${J}/${Q}`,`https://git.ying-qing.cn/gitea/seal-home/releases/download/${J}/${Q}`);if($.startsWith("https://git.ying-qing.cn"))Y.push($)}if(U!=="gitea")if(J&&Q){let L=`https://github.com/${Vg0}/releases/download/${J}/${Q}`;if(!process.env.CI)Y.push(`https://ghfast.top/${L}`,`https://gh.ddlc.top/${L}`);Y.push(L)}else if($.includes("github.com")){if(!process.env.CI)Y.push(`https://ghfast.top/${$}`,`https://gh.ddlc.top/${$}`);Y.push($)}else Y.push($);let K=Array.from(new Set(Y)),H,G=6000,Z=6000,W=307200,X=1e4,w=180000;for(let L=0;L<K.length;L++){let O=K[L],F=new AbortController,D="",P=(h)=>{D=h;try{F.abort()}catch{}},A=setTimeout(()=>{P("Connection timed out (no response headers within 6s)")},G),T,k;try{$P(`==> [${L+1}/${K.length}] Downloading via: ${O}`);let h=await fetch(O,{signal:F.signal});if(A)clearTimeout(A),A=void 0;if(!h.ok)throw Error(`HTTP ${h.status} ${h.statusText}`);T=setTimeout(()=>{P("Overall download time exceeded 3 minutes")},w);let f=Number(h.headers.get("content-length"))||0,C=h.body?.getReader();if(!C){let c=Buffer.from(await h.arrayBuffer());if(c.length<1000)throw Error(`Downloaded content is suspiciously small (${c.length} bytes)`);Hg0(I,c),$P(`✓ Download succeeded (${(c.length/1024/1024).toFixed(1)} MB)`);return}let b=[],i=0,v=0;k=setTimeout(()=>{if(i<W){let c=(i/1024).toFixed(1);P(`Initial transfer too slow (${c} KB < 300 KB in 6s), switching mirror...`)}},Z);while(!0){let c=C.read(),$0,R=new Promise((U0,H0)=>{$0=setTimeout(()=>{H0(Error("Data transfer stalled (no chunk received for 10s)"))},X)}),u;try{u=await Promise.race([c,R])}finally{if($0)clearTimeout($0)}let{done:p,value:s}=u;if(p)break;if(s){if(b.push(s),i+=s.length,k&&i>=W)clearTimeout(k),k=void 0;let U0=Date.now();if(U0-v>200){v=U0;let H0=f?Math.round(i/f*100):0,D0=(i/1048576).toFixed(1),_0=f?(f/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${H0}% (${D0} / ${_0} MB)...`)}catch{}}}}try{process.stderr.write(`
`);U(z)})})}async function _g0($){let q=g0($.options.port)??g0($.options.p),Y=E($.options.host)??E($.options.h),z=await JP({port:q,host:Y}),U=()=>{z.close(()=>{process.exit(0)})};process.on("SIGINT",U),process.on("SIGTERM",U),await new Promise(()=>{})}p4();o1();async function Cg0($,q,Y,z){if($==="config"||$==="get"){await P0("seal_llm_config_get",q,Y,{},F0(z.options));return}if($==="providers"||$==="list"){await P0("seal_llm_providers_list",q,Y,{},F0(z.options));return}throw Error(`Unknownllmcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}o1();async function Rg0($,q){if($==="config"||$==="json"){hd();return}await gd()}function hd(){j0({mcpServers:{"seal-use":{type:"stdio",command:"seal-use",args:["mcp"],env:{SEAL_USE_MCP_ENABLED:"true"}}}})}o1();function vg0($){let q=qP();j0(q,{...F0($.options),allowFull:!0})}p4();o1();async function hg0($,q,Y,z){if($==="available"){await P0("seal_permissions_available_list",q,Y,{},F0(z.options));return}if($==="configs"||$==="list"){await P0("seal_permissions_configs_list",q,Y,{},F0(z.options));return}throw Error(`Unknownpermissionscommand:${$??""}.Run'seal-use help'foravailablecommands.`)}p4();_4();o1();import{readFileSync as gg0}from"node:fs";async function Sg0($,q,Y,z,U,I,J){if(!$||$==="get"){await P0("seal_preference_get",U,I,{},F0(J.options));return}if($==="decision"){if(q==="update"||!q){let Q=E(J.options.input),K=Q?JSON.parse(gg0(Q,"utf8")):R8(J.json);if(!K||Object.keys(K).length===0)throw Error(`Usage:seal-usepreferencedecisionupdate--json'{"explicitApprove":"..."}'`);await P0("seal_preference_decision_update",U,I,{...K,dryRun:W0(J.options.dryRun)??W0(J.options["dry-run"])},F0(J.options));return}}if($==="thinking-depth"||$==="thinkingDepth"){if(q==="set"){let Q=E(J.options.default)??E(J.options.level)??z;if(Q!=="medium"&&Q!=="high")throw Error("Usage: seal-use preference thinking-depth set --default <medium|high>");await P0("seal_preference_thinking_depth_set",U,I,{defaultLevel:Q,dryRun:W0(J.options.dryRun)??W0(J.options["dry-run"])},F0(J.options));return}if(q==="policies"){if(Y==="list"||!Y){await P0("seal_preference_thinking_depth_policies_list",U,I,{},F0(J.options));return}if(Y==="upsert"){let Q=E(J.options.input),K=Q?JSON.parse(gg0(Q,"utf8")):R8(J.json);if(!K||!K.id||!K.name)throw Error(`Usage:seal-usepreferencethinking-depthpoliciesupsert--json'{"id":"...","name":"...","level":"high"}'`);await P0("seal_preference_thinking_depth_policies_upsert",U,I,{...K,dryRun:W0(J.options.dryRun)??W0(J.options["dry-run"])},F0(J.options));return}if(Y==="remove"||Y==="delete"){let Q=z??E(J.options.id)??E(J.options.policyId);if(!Q)throw Error("Usage: seal-use preference thinking-depth policies remove <policyId>");await P0("seal_preference_thinking_depth_policies_remove",U,I,{policyId:Q,dryRun:W0(J.options.dryRun)??W0(J.options["dry-run"])},F0(J.options));return}}}throw Error(`Unknownpreferenceaction:${$??""}.Available:get,decisionupdate,thinking-depthset,thinking-depthpolicieslist/upsert/remove.`)}Q3();b8();J6();async function yg0($={}){let q=r8(),Y=B4(),z=e7(q,{stateful:Y.stateful,defaultCorpId:Y.defaultCorpId,corpId:$.corpId},J3());console.log(`[probe]corp=${z.id}source=${z.source.type}`);let U=await jJ(z);console.log("[probe] seal enterprise"),console.log(JSON.stringify(U,null,2));let I=await Z1(z),J=await dw(I,{documentLimit:20,stylePreferencesEndpoint:z.seal.endpoints.approvalStylePreferences});console.log("[probe] approval context summary"),console.log(JSON.stringify({rules:J.rules.rules.length,hasPendingRuleDeletes:J.rules.hasPendingDeletes,documents:J.documents.articles.length,documentsTotal:J.documents.total,stylePreferences:J.stylePreferences.ok?"ok":`error:${J.stylePreferences.error}`},null,2))}_4();async function xg0($,q,Y){let z=q??E(Y.options.corp)??($&&$!=="--corp"?$:void 0);await yg0({corpId:z})}ei();p4();V$();_4();o1();async function Sd($,q,Y,z,U){if($==="count"){await P0("seal_approval_rules_list",Y,z,{countOnly:!0},F0(U.options));return}if($==="list"){if(W0(U.options.count)){await P0("seal_approval_rules_list",Y,z,{countOnly:!0},F0(U.options));return}let I=g0(U.options.limit),J=g0(U.options.offset);if(W0(U.options.summary)){await P0("seal_approval_rules_list",Y,z,{fields:Av0,limit:I,offset:J},F0(U.options));return}let Q=await H2("seal_approval_rules_list",Y,z,{limit:I,offset:J});Pv0(Q,W0(U.options.full)===!0),j0(Q);return}if($==="clear"){let I=W0(U.options.yes)===!0,J=W0(U.options.dryRun)??W0(U.options["dry-run"])??!I;if(!I&&!J)throw Q9("Refusing to clear rules without --yes. Use --dry-run to preview.",`seal-userulesclear--corp${z.id}--dry-run`);let Q=await H2("seal_approval_rules_clear",Y,z,{dryRun:J,recode:W0(U.options.recode)});if(!I&&J&&Q&&typeof Q==="object"){j0({...Q,nextCommand:`seal-userulesclear--corp${z.id}--yes`},F0(U.options));return}j0(Q,F0(U.options));return}if($==="versions"){await P0("seal_approval_rule_versions_list",Y,z,{},F0(U.options));return}if($==="version"){let I=q??E(U.op
Line truncated
`).filter(Boolean),I=U.slice(-q);return{logFile:Y,lines:I,totalLines:U.length}}async function eb1($){let q=GP($),Y=kd($),z=WW($);bg0($.stateDir);let U=$.port??(process.env.PORT?Number.parseInt(process.env.PORT,10):UP),I=$.host??(process.env.HOST?process.env.HOST:IP);KP(q,`${process.pid}
`,{mode:384}),KP(Y,JSON.stringify({pid:process.pid,port:U,host:I,version:$.version,startedAt:new Date().toISOString()},null,2),{mode:384}),_J(z,`servicestartingonhttp://${I}:${U} pid=${process.pid}`);let J=null;try{J=await JP({port:U,host:I,silent:!0}),_J(z,`service listening pid=${process.pid}`)}catch(K){if(_J(z,`service failed to bind port ${U}: ${K instanceof Error?K.message:String(K)}`),HP(q)===process.pid)L9(q,{force:!0}),L9(Y,{force:!0});throw K}let Q=()=>{if(J)J.close(),J=null;if(HP(q)===process.pid)L9(q,{force:!0}),L9(Y,{force:!0});_J(z,`stopped pid=${process.pid}`)};await new Promise((K)=>{let H=!1,G=()=>{if(H)return;H=!0,Q(),process.off("SIGTERM",G),process.off("SIGINT",G),K()};process.once("SIGTERM",G),process.once("SIGINT",G)})}function kg0($){bg0($.stateDir);let q=CJ($);if(q.running)return q;let Y=$.launcher??{command:process.execPath,args:[$.entryFile]},z=[...Y.args??[],"service","run"];if($.port)z.push("--port",String($.port));if($.host)z.push("--host",String($.host));let U=rb1(Y.command,z,{cwd:$.appRoot,detached:!0,stdio:["ignore","ignore","ignore"],env:process.env});U.unref();let I=GP($);return KP(I,`${U.pid}
`,{flag:"a",mode:384})}o1();_4();var ud=Yi1(qi1(),".config","seal-use");async function fd($,q,Y){let z=Y?g0(Y.options.port)??g0(Y.options.p):void 0,U=Y?E(Y.options.host)??E(Y.options.h):void 0,I=Y?g0(Y.options.lines)??g0(Y.options.n):void 0,J=await EY($,{appRoot:q.appRoot,entryFile:q.entryFile,stateDir:ud,version:Q1,launcher:q.launcher,port:z,host:U},{maxLines:I});if(J!==void 0)j0(J)}p4();_4();o1();import{existsSync as zi1,readFileSync as ig0}from"node:fs";async function ng0($,q,Y,z,U){if($==="batch-records"||$==="records"){let I=q??E(U.options.batchId)??E(U.options["batch-id"]);if(!I)throw Error("Usage: seal-use simulation batch-records <batchId>");await P0("seal_simulation_batch_records_get",Y,z,{batchId:I,query:E(U.options.query)},F0(U.options));return}if($==="create"||$==="run"){let I=E(U.options.mode)??E(U.options.sourceSystem)??E(U.options["source-system"])??"hosecloud",J=I==="material-pack"?"material_pack":I,Q=E(U.options.schemaConfig)??E(U.options["schema-config"]),K=Q?JSON.parse(ig0(Q,"utf8")):void 0,H=E(U.options.input),G=H?JSON.parse(ig0(H,"utf8")):R8(U.json),Z=E(U.options.packageId)??E(U.options["package-id"]),V=v6(U.options.packageIds)??v6(U.options["package-ids"])??(Z?[Z]:void 0),X=v6(U.options.flowIds)??v6(U.options["flow-ids"])??v6(U.options.documentSn)??v6(U.options["document-sn"]),w=E(U.options.signKey)??E(U.options["sign-key"])??E(U.options.integration),L=W0(U.options.noWait)??W0(U.options["no-wait"]);await P0("seal_simulation_batch_create",Y,z,{mode:J,sourceSystem:J,flowIds:X,documentSn:X,rejectNodeName:E(U.options.rejectNode)??E(U.options["reject-node"])??null,thinkingDepthOverride:E(U.options.thinkingDepth)??E(U.options["thinking-depth"]),skipInvoiceGeneration:W0(U.options.skipInvoiceGeneration)??W0(U.options["skip-invoice-generation"]),skipExpenseExtraction:W0(U.options.skipExpenseExtraction)??W0(U.options["skip-expense-extraction"]),disableAttachmentCache:W0(U.options.disableAttachmentCache)??W0(U.options["disable-attachment-cache"]),signKey:w,packageIds:V,packageId:Z,templateId:E(U.options.templateId)??E(U.options["template-id"]),schemaConfig:K,requestIds:v6(U.options.requestIds)??v6(U.options["request-ids"]),workflowTypeId:E(U.options.workflowTypeId)??E(U.options["workflow-type-id"]),flowStatusList:v6(U.options.flowStatusList)?.map(Number)??v6(U.options["flow-status-list"])?.map(Number),businessCodes:v6(U.options.businessCodes)??v6(U.options["business-codes"]),documentType:E(U.options.documentType)??E(U.options["document-type"]),startTime:g0(U.options.startTime)??g0(U.options["start-time"]),endTime:g0(U.options.endTime)??g0(U.options["end-time"]),status:v6(U.options.status),limit:g0(U.options.limit),noWait:L,rawParams:G},F0(U.options));return}if($==="wait"){let I=q??E(U.options.batchId)??E(U.options["batch-id"]);if(!I)throw Error("Usage: seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s]");await P0("seal_simulation_batch_wait",Y,z,{batchId:I,timeout:E(U.options.timeout),pollInterval:E(U.options.pollInterval)??E(U.options["poll-interval"])},F0(U.options));return}if($==="status"){let I=q??E(U.options.batchId)??E(U.options["batch-id"]);if(!I)throw Error("Usage: seal-use simulation status <batchId>");await P0("seal_simulation_batch_status",Y,z,{batchId:I},F0(U.options));return}if($==="clean"||$==="delete"){let I=q??E(U.options.batchId)??E(U.options["batch-id"]);if(!I)throw Error("Usage: seal-use simulation clean <batchId>");await P0("seal_simulation_batch_clean",Y,z,{batchId:I},F0(U.options));return}if($==="specifications"){let I=q??E(U.options.integration)??E(U.options.signKey)??E(U.options["sign-key"]);await P0("seal_simulation_specifications_list",Y,z,{signKey:I},F0(U.options));return}if($==="approval-definitions"||$==="definitions"){await P0("seal_simulation_feishu_approval_definitions_list",Y,z,{},F0(U.options));return}if($==="list"){await P0("seal_simulation_batches_list",Y,z,{limit:g0(U.options.limit)},F0(U.options));return}if($==="get"){let I=q??E(U.options.batchId)??E(U.options["batch-id"]);if(!I)throw Error("Usage: seal-use simulation get <batchId>");await P0("seal_simulation_batch_get",Y,z,{batchId:I},F0(U.options));return}if($==="templates"){await P0("seal_simulation_templates_get",Y,z,{},F0(U.options));return}if($==="integrations"){await P0("seal_simulation_integrations_get",Y,z,{},F0(U.options));return}if($==="package-upload"){let I=q??E(U.options.file);if(!I)throw Error("Usage: seal-use simulation package-upload <材料包.zip>");if(!zi1(I))throw Error(`Filenotfound:${I}`);await P0("seal_simulation_material_package_upload",Y,z,{filePath:I},F0(U.options));return}throw Error(`Unknownsimulationcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}import{existsSync as cg0}from"node:fs";import{join as ZP}from"node:path";_4();o1();function pg0($,q,Y){if($==="dump"||$==="cat"||$==="show"){process.stdout.write(`${Lg0()}
`);return}if($==="install"||$==="init"||$==="sync"){let z=W0(Y.options.local)||W0(Y.options.workspace),U=E(Y.options.dir)??E(Y.options.target)??q,I=U?U:z?ZP(process.cwd(),".agents","skills","seal-use"):TY(),J=Td(I);j0({installed:!0,targetDir:J.targetDir,fileCount:J.files.length,files:J.files});return}if($==="status"||$==="get"||!$){let z=TY(),U=ZP(process.cwd(),".agents","skills","seal-use");j0({global:{dir:z,installed:cg0(ZP(z,"SKILL.md"))},local:{dir:U,installed:cg0(ZP(U,"SKILL.md"))}});return}throw Error(`Unknownskillcommand:${$}.Run'seal-use help'foravailablecommands.`)}o1();async function dg0($,q){if($==="config"){j0(await jJ(q));return}throw Error(`Unknownsourcecommand:${$??""}.Run'seal-use help'foravailablecommands.`)}V$();p4();_4();o1();b8();V$();J6();DZ();function bd($){if(typeof $!=="string"||!$.trim())return"UNKNOWN";let q=$.toUpperCase().trim();if(q==="APPROVE"||q==="PASS")return"APPROVE";if(q==="REJECT"||q==="DENIED")return"REJECT";if(q==="MANUAL"||q==="ASSISTED")return"MANUAL";if(q==="ERROR"||q==="FAILED")return"ERROR";return q}async function mg0($){let{sourceCorp:q,targetCorp:Y,sourceClient:z,targetClient:U,samples:I=10,dryRun:J=!1,pollIntervalMs:Q=2000,timeoutMs:K=45000,snPrefix:H="REG_",fetchFn:G=fetch}=$;if(Y.environment!=="test")throw new b4(`重放目标企业「${Y.name}」(${Y.id})的环境为「${Y.environment}」,非测试环境!
`+"硬性安全规定:自动化回归测试矩阵严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-usecorpsbind-test${q.id}<testCorpId>`);let Z=await g2(U),X=(Array.isArray(Z.features)?Z.features:[]).find((u)=>u?.code==="ai-approval"),w=typeof X?.balance==="number"?X.balance:0,L=typeof X?.deductionAmount==="number"&&X.deductionAmount>0?X.deductionAmount:120,F=I*L;if(w<F)throw new b4(`测试企业「${Y.name}」AI审批额度不足:当前剩余${w}点,本次回归抽样${I}笔需要约${F}点。
`+"为防止测试环境额度耗尽中断业务,已硬性拦截并拒绝发起测试单据注入。",2,`请为测试企业「${Y.id}」充值AI审批额度,或降低抽样笔数(--samples${Math.max(1,Math.floor(w/L))})`);let O=await y4(z,{limit:I,status:"completed"}),A=Array.isArray(O.records)?O.records:[];if(A.length===0){let u=await y4(z,{limit:I});A=Array.isArray(u.records)?u.records:[]}if(A.length===0)throw new b4(`在母企业「${q.name}」(${q.id})中未检索到任何历史审批单据,无法抽取回归样本。`,2);if(A=A.slice(0,I),J){let u=A.map((p)=>{let d=p.sourceDocumentSN??p.id,Y0=p?.result?.decision??p.aiDecision??p?.decision,t=bd(Y0),H0=p?.result?.summary??p.aiSummary;return{sn:d,sourceRecordId:p.id,prodDecision:t,prodSummary:H0,status:"DRY_RUN"}});return{ok:!0,verdict:"DRY_RUN",safeToPublish:!0,timestamp:new Date().toISOString(),sourceCorp:{id:q.id,name:q.name,environment:q.environment??"production"},targetCorp:{id:Y.id,name:Y.name,environment:Y.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:w,deductionAmount:L,estimatedRequired:F},metrics:{sampleCount:u.length,successCount:u.length,failureCount:0,matchCount:u.length,flipCount:0,concordanceRate:1},flips:[],records:u}}let B=await pi(U,Y),P=[];for(let u of A){let p=Date.now(),d=u.sourceDocumentSN??u.id,Y0=bd(u?.result?.decision??u.aiDecision??u?.decision),t=u?.result?.summary??u.aiSummary;try{let H0=await e1(z,u.id),w0=`${H}${d}`,T0=ni(H0,{snPrefix:H,docIdPrefix:H});await ci(B.incomingDocumentWebhook.url,B.secret,T0,G,L6(Y.seal));let R0=null,E0=Date.now();while(Date.now()-E0<K){await new Promise((a0)=>setTimeout(a0,Q));let R1=await y4(U,{sourceDocumentSN:w0,limit:1});if(R1.records&&R1.records.length>0){let a0=R1.records[0];if(a0.status==="completed"||a0.status==="failed"){R0=a0;break}}}if(!R0){P.push({sn:d,sourceRecordId:u.id,prodDecision:Y0,prodSummary:t,status:"FAILED",error:`测试租户单据审核超时(${Math.round(K/1000)}s未完成)`,durationMs:Date.now()-p});continue}let i0=bd(R0?.result?.decision??R0.aiDecision??R0?.decision??(R0.status==="completed"?"APPROVE":"ERROR")),Q0=R0?.result?.summary??R0.aiSummary,v0=Y0===i0,f0=v0?"MATCHED":"FLIPPED",c0={sn:d,sourceRecordId:u.id,prodDecision:Y0,prodSummary:t,testRecordId:R0.id,testDecision:i0,testSummary:Q0,status:f0,durationMs:Date.now()-p};if(!v0)c0.diff={from:Y0,to:i0,reasonDiff:Q0&&t&&Q0!==t?`生产:${t.slice(0,60)}...->测试:${Q0.slice(0,60)}...`:void 0};P.push(c0)}catch(H0){P.push({sn:d,sourceRecordId:u.id,prodDecision:Y0,prodSummary:t,status:"FAILED",error:H0 instanceof Error?H0.message:String(H0),durationMs:Date.now()-p})}}let T=P.filter((u)=>u.status==="MATCHED"||u.status==="FLIPPED"),y=P.filter((u)=>u.status==="MATCHED"),v=P.filter((u)=>u.status==="FLIPPED"),k=P.filter((u)=>u.status==="FAILED").length,R=y.length,c=v.length,n=R+c,g=n>0?R/n:0,b=c>0,i=b?"REGRESSIONS_DETECTED":"CLEAN",$0=!b&&k===0,j;try{let u=await g2(U),d=(Array.isArray(u.features)?u.features:[]).find((Y0)=>Y0?.code==="ai-approval");if(typeof d?.balance==="number")j=d.balance}catch{}return{ok:!b&&k===0,verdict:i,safeToPublish:$0,timestamp:new Date().toISOString(),sourceCorp:{id:q.id,name:q.name,environment:q.environment??"production"},targetCorp:{id:Y.id,name:Y.name,environment:Y.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:w,deductionAmount:L,estimatedRequired:F,balanceAfter:j},metrics:{sampleCount:P.length,successCount:T.length,failureCount:k,matchCount:R,flipCount:c,concordanceRate:Number(g.toFixed(4))},flips:v,records:P}}function lg0($){let{sourceCorp:q,targetCorp:Y,verdict:z,safeToPublish:U,metrics:I,quota:J,flips:Q,records:K}=$,H=z==="CLEAN"?"\uD83D\uDFE2 决策完全一致 (CLEAN - 无回归)":z==="DRY_RUN"?"⚪ 预演模式 (DRY-RUN)":"\uD83D\uDD34 发现决策翻转 (REGRESSIONS_DETECTED)",G=["",`\uD83E\uDDEA[SealUseTest]规则回归测试矩阵:生产「${q.name}」->测试靶场「${Y.name}」`,`判定:${H}·准许发布:${U?"YES (可安全上线)":"NO (存在行为偏离/待复核)"}`," "+"─".repeat(65),`样本总数:${I.sampleCount}|一致通过:${I.matchCount}|决策翻转:${I.flipCount}|异常失败:${I.failureCount}`,`一致率:${(I.concordanceRate*100).toFixed(1)}%|消耗预估:${J.estimatedRequired}点(余量:${J.balanceBefore}${J.balanceAfter!==void0?` -> ${J.balanceAfter}`:""})`," "+"─".repeat(65)];if(Q.length>0){G.push(`⚠️决策翻转清单(${Q.length}笔单据在新规则下结果改变):`);for(let Z of Q)if(G.push(`•单据[${Z.sn}]:原生产判定「${Z.prodDecision}」➔测试新判定「${Z.testDecision}」`),Z.diff?.reasonDiff)G.push(`理由差异:${Z.diff.reasonDiff}`);G.push(" "+"─".repeat(65)),G.push(" \uD83D\uDC49 建议: 请检查上述翻转单据是否符合预期修正。若为意外误杀,请调整测试环境规则后再次回归。")}else if(z==="CLEAN")G.push(" ✓ 全部样本在新规则下的审核决策与生产历史 100%
Line truncated
`)}async function id($,q,Y){let z=($??q??"regression").toLowerCase();if(z==="regression"||z==="regress"||z==="matrix"){let U=E(Y.options.corp)??(q&&q!==z?q:void 0),I=w1(U),J=I,Q=I;if(I.environment==="test"){Q=I;let A=E(Y.options["prod-corp"])??E(Y.options.prod)??I.prodCorpId;if(!A)throw new b4(`测试企业「${I.name}」(${I.id})未绑定生产母企业,无法拉取历史样本。
`+"请建立绑定或通过 --prod-corp 参数指定生产企业来源。",2,`seal-usecorpsbind-test<prodCorpId>${I.id}`);J=w1(A)}else{J=I;let A=E(Y.options["test-corp"])??E(Y.options.test)??I.testCorpId;if(!A)throw new b4(`生产企业「${I.name}」(${I.id})未绑定测试靶场企业。
`+"硬性规定:回归测试严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-usecorpsbind-test${I.id}<testCorpId>`);Q=w1(A)}let K=await Z1(J),H=await Z1(Q),G=g0(Y.options.samples)??g0(Y.options.limit)??g0(Y.options.n)??10,Z=W0(Y.options["dry-run"]),V=W0(Y.options["fail-on-flips"]),X=g0(Y.options["poll-interval"])??2000,w=g0(Y.options.timeout)??45000,L=E(Y.options["sn-prefix"])??"REG_",F=await mg0({sourceCorp:J,targetCorp:Q,sourceClient:K,targetClient:H,samples:G,dryRun:Z,pollIntervalMs:X,timeoutMs:w,snPrefix:L,failOnFlips:V});if(!(W0(Y.options.quiet)||W0(Y.options.silent)))console.error(lg0(F));if(j0(F),V&&!F.ok)throw new b4(`回归测试发现${F.metrics.flipCount}笔单据决策翻转,已按--fail-on-flips策略非零终止。`,1);return}throw new b4(`未知的test子命令:"${z}"。
可用子命令:seal-usetestregression[--corp<id>][--samples<N>][--dry-run]`,2,"seal-use test regression --help")}p4();_4();o1();async function og0($,q,Y,z){if(!$)throw Error("Usage: seal-use tool <toolName> [--json '{...}']");await P0($,q,Y,R8(z.json),F0(z.options))}iA();o1();function rg0(){j0(YW.map(($)=>({name:$.name,description:$.description})))}import{chmodSync as Ui1,mkdirSync as Ii1,renameSync as nd,rmSync as Ji1,unlinkSync as $S0,writeFileSync as sg0}from"node:fs";import{dirname as Qi1,join as tg0}from"node:path";import{spawnSync as jY}from"node:child_process";function WP($=process.execPath,q=import.meta.url){if(q.includes("/$bunfs/")||q.includes("\\$bunfs\\"))return!0;let Y=$.toLowerCase().replace(/\\/g,"/");return!Y.endsWith("/bun")&&!Y.endsWith("/bun.exe")&&!Y.endsWith("/node")&&!Y.endsWith("/node.exe")}o1();var qS0="yunyingk/seal-use",VW="yunyingk/seal-home";var Ki1="SEAL_USE_GITHUB_REPO",Hi1="SEAL_HOME_GITHUB_REPO";async function YS0($,q={}){let Y={appRoot:$.appRoot,entryFile:$.entryFile,stateDir:ud,version:Q1,launcher:$.launcher},z=q.repo||process.env[Ki1]?.trim()||process.env[Hi1]?.trim()||qS0,U=q.targetVersion?.trim(),I=U&&U.toLowerCase()!=="latest"?U:void 0;if(I){let P=I.replace(/^v/,""),T=zS0(P,Q1);if(T<0)if(!Nv&&q.force);else{j0({updated:!1,currentVersion:Q1,targetVersion:P,mode:WP()?"binary":"source",message:!Nv?`Cannotdowngradeseal-usefromdevbuildv${Q1}toreleasev${P}.Use--forcetooverwrite.`:`Cannotdowngradeseal-usefromv${Q1}toolderversionv${P}.Updatesmustbeforward-only.`});return}if(T===0&&!q.force){j0({updated:!1,currentVersion:Q1,targetVersion:P,mode:WP()?"binary":"source",message:`seal-useisalreadyatversionv${Q1}.Use--forcetoreinstall.`});return}}if(q.changelogOnly){let P=await cd(z,q.limit??10);j0({currentVersion:Q1,totalQueried:P.length,releases:P.map((T)=>({version:T.version,tagName:T.tagName,publishedAt:T.publishedAt,author:T.author,releaseNotes:T.notes,releaseUrl:T.htmlUrl,isCurrent:T.version===Q1,isNewer:XW(T.version,Q1)}))});return}if(!WP()){if(q.checkOnly){let T=await cd(z,30),y=T[0],v=y?.version??Q1,k=T.find((n)=>n.version===Q1),R=XW(v,Q1),c=T.filter((n)=>XW(n.version,Q1));j0({updated:!1,updateAvailable:R,currentVersion:Q1,currentVersionPublishedAt:k?.publishedAt,latestVersion:v,latestVersionPublishedAt:y?.publishedAt,behindCount:c.length,pendingReleases:c.map((n)=>({version:n.version,tagName:n.tagName,publishedAt:n.publishedAt,author:n.author,releaseNotes:n.notes,releaseUrl:n.htmlUrl})),releaseNotes:y?.notes??"",releaseUrl:y?.htmlUrl??"",mode:"source",message:"Running in source development mode. Run 'seal-use update' to git pull & bun install."});return}let P=CJ(Y).running;if(P)await EY("stop",Y);try{eg0("git",["-C",$.appRoot,"pull","--ff-only"])}catch(T){console.error(`gitpullskipped:${TinstanceofError?T.message:String(T)}`)}if(eg0("bun",["install"],{cwd:$.appRoot}),P)await EY("start",Y);j0({updated:!0,serviceRestarted:P,version:Q1,mode:"source"});return}let J=Gi1(),Q=Zi1(),K=await cd(z,30),H=I?K.find((P)=>P.version===I||P.tagName===I||P.tagName===`v${I}`)??await ag0(z,I):K[0]??await ag0(z);if(!H){j0({updated:!1,currentVersion:Q1,mode:"binary",message:`Failedtoqueryreleasesfromrepository'${z}'`});return}let G=H.version,Z=K.find((P)=>P.version===Q1),V=XW(G,Q1),X=V||Boolean(q.force),w=K.filter((P)=>XW(P.version,Q1));if(q.checkOnly){j0({updated:!1,updateAvailable:V,currentVersion:Q1,currentVersionPublishedAt:Z?.publishedAt,latestVersion:G,latestVersionPublishedAt:H.publishedAt,behindCount:w.length,pendingReleases:w.map((P)=>({version:P.version,tagName:P.tagName,publishedAt:P.publishedAt,author:P.author,releaseNotes:P.notes,releaseUrl:P.htmlUrl})),releaseNotes:H.notes,releaseUrl:H.htmlUrl,mode:"binary"});return}if(!X){j0({updated:!1,currentVersion:Q1,currentVersionPublishedAt:Z?.publishedAt,latestVersion:G,latestVersionPublishedAt:H.publishedAt,mode:"binary",message:`seal-useisalreadyuptodate(v${Q1})`});return}let L=Wi1(H.assets,J,Q);if(!L)throw Error(`Nocompatiblebinaryfoundfor${J}-${Q}inreleasev${G}.Availableassets:${H.assets.map((P)=>P.name).join(", ")}`);let F=CJ(Y).running;if(F)await EY("stop",Y);let O=process.execPath,A=Qi1(O),B=tg0(A,`.tmp-update-${Date.now()}`);Ii1(B,{recursive:!0});try{let P=tg0(B,L.name);await Xi1(L.downloadUrl,P,H.tagName,L.name);let T=P;if(L.name.endsWith(".tar.gz")||L.name.endsWith(".tgz"))T=Vi1(P,B,J);else if(L.name.endsWith(".zip"))T=wi1(P,B,J);if(Ui1(T,493),process.platform==="darwin")try{jY("/usr/bin/codesign",["--remove-signature",T],{stdio:"ignore"}),jY("/usr/bin/codesign",["--force","--sign","-",T],{stdio:"ignore"})}catch{}if(process.platform==="win32"){let v=`${O}.old.${Date.now()}`;try{nd(O,v)}catch{}nd(T,O)}else nd(T,O);if(F)await EY("start",Y);let y=Ed();j0({updated:!0,fromVersion:Q1,toVersion:G,serviceRestarted:F,skillSynced:y.synced?y.targetDir:!1,mode:"binary"})}finally{try{Ji1(B,{recursive:!0,force:!0})}catch{}}}function Gi1(){if(process.platform==="darwin")retur
Line truncated
`)}catch{}}async function Xi1($,q,Y,z){let U=pd(),I=[],J=Y?Y.startsWith("v")?Y:`v${Y}`:void 0,Q=z||$.split("/").pop()||"";if(U!=="github"){if(J&&Q)I.push(`https://git.ying-qing.cn/gitea/seal-use/releases/download/${J}/${Q}`,`https://git.ying-qing.cn/gitea/seal-home/releases/download/${J}/${Q}`);if($.startsWith("https://git.ying-qing.cn"))I.push($)}if(U!=="gitea")if(J&&Q){let L=`https://github.com/${qS0}/releases/download/${J}/${Q}`;if(!process.env.CI)I.push(`https://ghfast.top/${L}`,`https://gh.ddlc.top/${L}`);I.push(L)}else if($.includes("github.com")){if(!process.env.CI)I.push(`https://ghfast.top/${$}`,`https://gh.ddlc.top/${$}`);I.push($)}else I.push($);let K=Array.from(new Set(I)),H,G=6000,Z=6000,V=307200,X=1e4,w=180000;for(let L=0;L<K.length;L++){let F=K[L],O=new AbortController,A="",B=(v)=>{A=v;try{O.abort()}catch{}},P=setTimeout(()=>{B("Connection timed out (no response headers within 6s)")},G),T,y;try{XP(`==> [${L+1}/${K.length}] Downloading via: ${F}`);let v=await fetch(F,{signal:O.signal});if(P)clearTimeout(P),P=void 0;if(!v.ok)throw Error(`HTTP ${v.status} ${v.statusText}`);T=setTimeout(()=>{B("Overall download time exceeded 3 minutes")},w);let k=Number(v.headers.get("content-length"))||0,R=v.body?.getReader();if(!R){let i=Buffer.from(await v.arrayBuffer());if(i.length<1000)throw Error(`Downloaded content is suspiciously small (${i.length} bytes)`);sg0(q,i),XP(`✓ Download succeeded (${(i.length/1024/1024).toFixed(1)} MB)`);return}let c=[],n=0,g=0;y=setTimeout(()=>{if(n<V){let i=(n/1024).toFixed(1);B(`Initial transfer too slow (${i} KB < 300 KB in 6s), switching mirror...`)}},Z);while(!0){let i=R.read(),$0,j=new Promise((Y0,t)=>{$0=setTimeout(()=>{t(Error("Data transfer stalled (no chunk received for 10s)"))},X)}),u;try{u=await Promise.race([i,j])}finally{if($0)clearTimeout($0)}let{done:p,value:d}=u;if(p)break;if(d){if(c.push(d),n+=d.length,y&&n>=V)clearTimeout(y),y=void 0;let Y0=Date.now();if(Y0-g>200){g=Y0;let t=k?Math.round(n/k*100):0,H0=(n/1048576).toFixed(1),w0=k?(k/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${t}% (${H0} / ${w0} MB)...`)}catch{}}}}try{process.stderr.write(`
"description":"Planned HTTP contract for the seal-use wrapped backend API.\n\nThese endpoints describe the intended stable API for frontend developers and agents once\nthe HTTP adapter is implemented.\nThey are not the raw downstream Seal endpoints. seal-use is responsible for enterprise\nselection, source authentication, response compaction, and diagnostics-friendly fields.\n"
description:"v0.10.22: Use for Seal Use first-time enterprise onboarding, Hose/合思 or Seal-native authentication, assistance links and browser cURL intake, plus tenant approval operations, diagnosis, simulation, rules, users, configuration, and search."
description:"v0.10.23: Use for Seal Use first-time enterprise onboarding, Hose/合思 or Seal-native authentication, assistance links and browser cURL intake, plus tenant approval operations, diagnosis, simulation, rules, users, configuration, and search."
metadata:
version:0.10.22
short-description:Seal tenant and Hose approval automation (v0.10.22)
version:0.10.23
short-description:Seal tenant and Hose approval automation (v0.10.23)
---
# Seal Use (v0.10.22)
# Seal Use (v0.10.23)
Use the `seal_cli` MCP tool when it is available; pass the command string as its `command` argument. If MCP is unavailable, fall back to the global `seal-use` CLI. This skill is a routing layer for agents: keep this file short, choose the right command, and read a focused reference only when the task needs detail.
- User-facing 合思 authorization link (合思/易快报授权): `seal-use auth hose-link --corp <corpId> --expire 7200`; read `references/hose-enterprise-auth.md`. Never use this route when the user says Seal 协助. Always provide BOTH a code block (` ```text ... ``` `) AND a hyperlink.
summary:"Export approval run audit records to Excel workbook. Add --with-flow to include E人工行为 / E人工意见 columns (requires Hose Open API; adds ~30s for large batches).",
{flag:"--sn, --sns <SNs>",description:"Target specific document SNs (comma-separated, e.g. B26002307,B26002144); fast indexed search bypassing full pagination"},
{flag:"--with-flow",description:"Enrich export with Hose human actions and opinions in E人工行为 / E人工意见 columns (rejection 2-B, mid-flow modifications, action emojis)"},
{flag:"--start <date>",description:"Filter records by start date (YYYY-MM-DD or ms timestamp)"},
{flag:"--end <date>",description:"Filter records by end date (YYYY-MM-DD or ms timestamp)"},
{flag:"--force",description:"Force export when time range exceeds 180 days"},
{flag:"--status <status>",description:"Filter by system status (e.g. completed, processing)"},
{flag:"--manual-status <status>",description:"Filter by manual approval status (e.g. APPROVED, TERMINATED)"},
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.