@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.10.18] - 2026-09-11
### Added & Enhanced
- **System Diagnostic Doctor & Embedded Specification Whitepaper**:
- Added `seal-use doctor` for unified system health diagnostics, inspecting executable runtime, 8 core filesystem paths, enterprise assets, and health checks.
- Implemented `seal-use doctor guide` to output the full system architecture, 10-tier directory specifications, security guarantees, and capability matrix directly from binary memory with zero additional disk writes.
- Added `seal-use doctor paths` for compact JSON inspection of core directory status and descriptions.
- Adheres strictly to dual-channel protocol: typed JSON on `stdout` and terminal diagnostic dashboard on `stderr`.
- **Intelligent Soft Fuzzy Search for Enterprise Discovery**:
- Introduced dedicated fuzzy engine (`src/core/search/fuzzy.ts`) supporting case-insensitivity, Chinese homophones/allophones, pinyin initials (简拼), full pinyin, nasal/retroflex normalization, and Levenshtein typo tolerance.
- Enabled soft fuzzy search by default on `seal-use corps search <keyword>` and `seal-use corps list`, with `--strict` option for exact substring matching.
- Enforced `corps search` in Agent Skill guidelines over dumping entire enterprise lists when names or hints are known.
import{createRequireasvL0}from"node:module";varFL0=Object.create;var{getPrototypeOf:OL0,defineProperty:eD,getOwnPropertyNames:NL0}=Object;varML0=Object.prototype.hasOwnProperty;functionAL0($){returnthis[$]}varPL0,TL0,OI=($,I,U)=>{varY=$!=null&&typeof$==="object";if(Y){varJ=I?PL0??=newWeakMap:TL0??=newWeakMap,Q=J.get($);if(Q)returnQ}U=$!=null?FL0(OL0($)):{};letK=I||!$||!$.__esModule?eD(U,"default",{value:$,enumerable:!0}):U;for(letqofNL0($))if(!ML0.call(K,q))eD(K,q,{get:AL0.bind($,q),enumerable:!0});if(Y)J.set($,K);returnK};varF=($,I)=>()=>(I||$((I={exports:{}}).exports,I),I.exports);varEL0=($)=>$;functionBL0($,I){this[$]=EL0.bind(null,I)}var$5=($,I)=>{for(varUinI)eD($,U,{get:I[U],enumerable:!0,configurable:!0,set:BL0.bind(I,U)})};vart=vL0(import.meta.url);varfQ=F((Hb)=>{Object.defineProperty(Hb,"__esModule",{value:!0});Hb.regexpCode=Hb.getEsmExportName=Hb.getProperty=Hb.safeStringify=Hb.stringify=Hb.strConcat=Hb.addCodeArg=Hb.str=Hb._=Hb.nil=Hb._Code=Hb.Name=Hb.IDENTIFIER=Hb._CodeOrName=void0;classbW{}Hb._CodeOrName=bW;Hb.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;classYUextendsbW{constructor($){super();if(!Hb.IDENTIFIER.test($))throwError("CodeGen: name must be a valid identifier");this.str=$}toString(){returnthis.str}emptyStr(){return!1}getnames(){return{[this.str]:1}}}Hb.Name=YU;classd$extendsbW{constructor($){super();this._items=typeof$==="string"?[$]:$}toString(){returnthis.str}emptyStr(){if(this._items.length>1)return!1;let$=this._items[0];return$===""||$==='""'}getstr(){var$;return($=this._str)!==null&&$!==void0?$:this._str=this._items.reduce((I,U)=>`${I}${U}`,"")}getnames(){var$;return($=this._names)!==null&&$!==void0?$:this._names=this._items.reduce((I,U)=>{if(UinstanceofYU)I[U.str]=(I[U.str]||0)+1;returnI},{})}}Hb._Code=d$;Hb.nil=newd$("");functionKb($,...I){letU=[$[0]],Y=0;while(Y<I.length)VT(U,I[Y]),U.push($[++Y]);returnnewd$(U)}Hb._=Kb;varwT=newd$("+");functionqb($,...I){letU=[kQ($[0])],Y=0;while(Y<I.length)U.push(wT),VT(U,I[Y]),U.push(wT,kQ($[++Y]));returnoN0(U),newd$(U)}Hb.str=qb;functionVT($,I){if(Iinstanceofd$)$.push(...I._items);elseif(IinstanceofYU)$.push(I);else$.push(aN0(I))}Hb.addCodeArg=VT;functionoN0($){letI=1;while(I<$.length-1){if($[I]===wT){letU=rN0($[I-1],$[I+1]);if(U!==void0){$.splice(I-1,3,U);continue}$[I++]="+"}I++}}functionrN0($,I){if(I==='""')return$;if($==='""')returnI;if(typeof$=="string"){if(IinstanceofYU||$[$.length-1]!=='"')return;if(typeofI!="string")return`${$.slice(0,-1)}${I}"`;if(I[0]==='"')return$.slice(0,-1)+I.slice(1);return}if(typeofI=="string"&&I[0]==='"'&&!($instanceofYU))return`"${$}${I.slice(1)}`;return}functiontN0($,I){returnI.emptyStr()?$:$.emptyStr()?I:qb`${$}${I}`}Hb.strConcat=tN0;functionaN0($){returntypeof$=="number"||typeof$=="boolean"||$===null?$:kQ(Array.isArray($)?$.join(","):$)}functionsN0($){returnnewd$(kQ($))}Hb.stringify=sN0;functionkQ($){returnJSON.stringify($).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Hb.safeStringify=kQ;functioneN0($){returntypeof$=="string"&&Hb.IDENTIFIER.test($)?newd$(`.${$}`):Kb`[${$}]`}Hb.getProperty=eN0;function$M0($){if(typeof$=="string"&&Hb.IDENTIFIER.test($))returnnewd$(`${$}`);throwError(`CodeGen: invalid export name: ${$}, use explicit $id name mapping`)}Hb.getEsmExportName=$M0;functionIM0($){returnnewd$($.toString())}Hb.regexpCode=IM0});varLT=F((Vb)=>{Object.defineProperty(Vb,"__esModule",{value:!0});Vb.ValueScope=Vb.ValueScopeName=Vb.Scope=Vb.varKinds=Vb.UsedValueState=void0;varc6=fQ();classWbextendsError{constructor($){super(`CodeGen: "code" for ${$} not defined`);this.value=$.value}}varnW;(function($){$[$.Started=0]="Started",$[$.Completed=1]="Completed"})(nW||(Vb.UsedValueState=nW={}));Vb.varKinds={const:newc6.Name("const"),let:newc6.Name("let"),var:newc6.Name("var")};classzT{constructor({prefixes:$,parent:I}={}){this._names={},this._prefixes=$,this._parent=I}toName($){return$instanceofc6.Name?$:this.name($)}name($){returnnewc6.Name(this._newName($))}_newName($){letI=this._names[$]||this._nameGroup($);return`${$}${I.index++}`}_nameGroup($){varI,U;if(((U=(I=this._parent)===null||I===void0?void0:I._prefixes)===null||U===void0?void0:U.has($))||this._prefixes&&!this._prefixes.has($))throwError(`CodeGen: prefix "${$}" is not allowed in this scope`);returnthis._names[$]={prefix:$,index:0}}}Vb.Scope=zT;classXTextendsc6.Name{constructor($,I){super(I);this.prefix=$}setValue($,{property:I,itemIndex:U}){this.value=$,this.scopePath=c6._`.${newc6.Name(I)}[${U}]`}}Vb.ValueScopeName=XT;varzM0=c6._`\n`;classwbextendszT{constructor($){super($);this._values={},this._scope=$.scope,this.opts={...$,_n:$.lines?zM0:c6.nil}}get(){returnthis._scope}name($){returnnewXT($,this._newName($))}value($,I){varU;if(I.ref===void0)throwError("CodeGen: ref must be passed in value");letY=this.toName($),{prefix:J}=Y,Q=(U=I.key)!==null&&U!==void0?U:I.ref,K=this._values[J];if(K){letG=K.get(Q);if(Line truncated
import{createRequireasVO0}from"node:module";varUO0=Object.create;var{getPrototypeOf:YO0,defineProperty:FO,getOwnPropertyNames:JO0}=Object;varQO0=Object.prototype.hasOwnProperty;functionwO0($){returnthis[$]}varKO0,HO0,jI=($,I,q)=>{varz=$!=null&&typeof$==="object";if(z){varU=I?KO0??=newWeakMap:HO0??=newWeakMap,Y=U.get($);if(Y)returnY}q=$!=null?UO0(YO0($)):{};letJ=I||!$||!$.__esModule?FO(q,"default",{value:$,enumerable:!0}):q;for(letQofJO0($))if(!QO0.call(J,Q))FO(J,Q,{get:wO0.bind($,Q),enumerable:!0});if(z)U.set($,J);returnJ};varF=($,I)=>()=>(I||$((I={exports:{}}).exports,I),I.exports);varGO0=($)=>$;functionWO0($,I){this[$]=GO0.bind(null,I)}varU5=($,I)=>{for(varqinI)FO($,q,{get:I[q],enumerable:!0,configurable:!0,set:WO0.bind(I,q)})};vart=VO0(import.meta.url);vartY=F((cn)=>{Object.defineProperty(cn,"__esModule",{value:!0});cn.regexpCode=cn.getEsmExportName=cn.getProperty=cn.safeStringify=cn.stringify=cn.strConcat=cn.addCodeArg=cn.str=cn._=cn.nil=cn._Code=cn.Name=cn.IDENTIFIER=cn._CodeOrName=void0;classeH{}cn._CodeOrName=eH;cn.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;classGqextendseH{constructor($){super();if(!cn.IDENTIFIER.test($))throwError("CodeGen: name must be a valid identifier");this.str=$}toString(){returnthis.str}emptyStr(){return!1}getnames(){return{[this.str]:1}}}cn.Name=Gq;classa$extendseH{constructor($){super();this._items=typeof$==="string"?[$]:$}toString(){returnthis.str}emptyStr(){if(this._items.length>1)return!1;let$=this._items[0];return$===""||$==='""'}getstr(){var$;return($=this._str)!==null&&$!==void0?$:this._str=this._items.reduce((I,q)=>`${I}${q}`,"")}getnames(){var$;return($=this._names)!==null&&$!==void0?$:this._names=this._items.reduce((I,q)=>{if(qinstanceofGq)I[q.str]=(I[q.str]||0)+1;returnI},{})}}cn._Code=a$;cn.nil=newa$("");functionbn($,...I){letq=[$[0]],z=0;while(z<I.length)_T(q,I[z]),q.push($[++z]);returnnewa$(q)}cn._=bn;varCT=newa$("+");functionpn($,...I){letq=[rY($[0])],z=0;while(z<I.length)q.push(CT),_T(q,I[z]),q.push(CT,rY($[++z]));returnSA0(q),newa$(q)}cn.str=pn;function_T($,I){if(Iinstanceofa$)$.push(...I._items);elseif(IinstanceofGq)$.push(I);else$.push(xA0(I))}cn.addCodeArg=_T;functionSA0($){letI=1;while(I<$.length-1){if($[I]===CT){letq=uA0($[I-1],$[I+1]);if(q!==void0){$.splice(I-1,3,q);continue}$[I++]="+"}I++}}functionuA0($,I){if(I==='""')return$;if($==='""')returnI;if(typeof$=="string"){if(IinstanceofGq||$[$.length-1]!=='"')return;if(typeofI!="string")return`${$.slice(0,-1)}${I}"`;if(I[0]==='"')return$.slice(0,-1)+I.slice(1);return}if(typeofI=="string"&&I[0]==='"'&&!($instanceofGq))return`"${$}${I.slice(1)}`;return}functionyA0($,I){returnI.emptyStr()?$:$.emptyStr()?I:pn`${$}${I}`}cn.strConcat=yA0;functionxA0($){returntypeof$=="number"||typeof$=="boolean"||$===null?$:rY(Array.isArray($)?$.join(","):$)}functionkA0($){returnnewa$(rY($))}cn.stringify=kA0;functionrY($){returnJSON.stringify($).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}cn.safeStringify=rY;functionfA0($){returntypeof$=="string"&&cn.IDENTIFIER.test($)?newa$(`.${$}`):bn`[${$}]`}cn.getProperty=fA0;functionnA0($){if(typeof$=="string"&&cn.IDENTIFIER.test($))returnnewa$(`${$}`);throwError(`CodeGen: invalid export name: ${$}, use explicit $id name mapping`)}cn.getEsmExportName=nA0;functionbA0($){returnnewa$($.toString())}cn.regexpCode=bA0});varyT=F((on)=>{Object.defineProperty(on,"__esModule",{value:!0});on.ValueScope=on.ValueScopeName=on.Scope=on.varKinds=on.UsedValueState=void0;vard6=tY();classmnextendsError{constructor($){super(`CodeGen: "code" for ${$} not defined`);this.value=$.value}}varIG;(function($){$[$.Started=0]="Started",$[$.Completed=1]="Completed"})(IG||(on.UsedValueState=IG={}));on.varKinds={const:newd6.Name("const"),let:newd6.Name("let"),var:newd6.Name("var")};classST{constructor({prefixes:$,parent:I}={}){this._names={},this._prefixes=$,this._parent=I}toName($){return$instanceofd6.Name?$:this.name($)}name($){returnnewd6.Name(this._newName($))}_newName($){letI=this._names[$]||this._nameGroup($);return`${$}${I.index++}`}_nameGroup($){varI,q;if(((q=(I=this._parent)===null||I===void0?void0:I._prefixes)===null||q===void0?void0:q.has($))||this._prefixes&&!this._prefixes.has($))throwError(`CodeGen: prefix "${$}" is not allowed in this scope`);returnthis._names[$]={prefix:$,index:0}}}on.Scope=ST;classuTextendsd6.Name{constructor($,I){super(I);this.prefix=$}setValue($,{property:I,itemIndex:q}){this.value=$,this.scopePath=d6._`.${newd6.Name(I)}[${q}]`}}on.ValueScopeName=uT;var$P0=d6._`\n`;classlnextendsST{constructor($){super($);this._values={},this._scope=$.scope,this.opts={...$,_n:$.lines?$P0:d6.nil}}get(){returnthis._scope}name($){returnnewuT($,this._newName($))}value($,I){varq;if(I.ref===void0)throwError("CodeGen: ref must be passed in value");letz=this.toName($),{prefix:U}=z,Y=(q=I.key)!==null&&q!==void0?q:I.ref,J=this._values[U];if(J){letK=J.get(Y);if(Line truncated
deps:${U}}`};var Mv0={keyword:"dependencies",type:"object",schemaType:"object",error:Rp.error,code($){let[I,U]=Av0($);Bp($,I),vp($,U)}};function Av0({schema:$}){let I={},U={};for(let Y in $){if(Y==="__proto__")continue;let J=Array.isArray($[Y])?I:U;J[Y]=$[Y]}return[I,U]}function Bp($,I=$.schema){let{gen:U,data:Y,it:J}=$;if(Object.keys(I).length===0)return;let Q=U.let("missing");for(let K in I){let q=I[K];if(q.length===0)continue;let H=(0,J2.propertyInData)(U,Y,K,J.opts.ownProperties);if($.setParams({property:K,depsCount:q.length,deps:q.join(", ")}),J.allErrors)U.if(H,()=>{for(let G of q)(0,J2.checkReportMissingProp)($,G)});else U.if($E._`${H}&&(${(0,J2.checkMissingProp)($,q,Q)})`),(0,J2.reportMissingProp)($,Q),U.else()}}Rp.validatePropertyDeps=Bp;function vp($,I=$.schema){let{gen:U,data:Y,keyword:J,it:Q}=$,K=U.name("valid");for(let q in I){if((0,Nv0.alwaysValidSchema)(Q,I[q]))continue;U.if((0,J2.propertyInData)(U,Y,q,Q.opts.ownProperties),()=>{let H=$.subschema({keyword:J,schemaProp:q},K);$.mergeValidEvaluated(H,K)},()=>U.var(K,!0)),$.ok(K)}}Rp.validateSchemaDeps=vp;Rp.default=Mv0});var yp=F((gp)=>{Object.defineProperty(gp,"__esModule",{value:!0});var Sp=a0(),Ev0=z1(),Bv0={message:"property name must be valid",params:({params:$})=>Sp._`{propertyName:${$.propertyName}}`},vv0={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Bv0,code($){let{gen:I,schema:U,data:Y,it:J}=$;if((0,Ev0.alwaysValidSchema)(J,U))return;let Q=I.name("valid");I.forIn("key",Y,(K)=>{$.setParams({propertyName:K}),$.subschema({keyword:"propertyNames",data:K,dataTypes:["string"],propertyName:K,compositeRule:!0},Q),I.if((0,Sp.not)(Q),()=>{if($.error(!0),!J.allErrors)I.break()})}),$.ok(Q)}};gp.default=vv0});var IE=F((hp)=>{Object.defineProperty(hp,"__esModule",{value:!0});var Xw=E$(),r$=a0(),jv0=K5(),Lw=z1(),Cv0={message:"must NOT have additional properties",params:({params:$})=>r$._`{additionalProperty:${$.additionalProperty}}`},_v0={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:Cv0,code($){let{gen:I,schema:U,parentSchema:Y,data:J,errsCount:Q,it:K}=$;if(!Q)throw Error("ajv implementation error");let{allErrors:q,opts:H}=K;if(K.props=!0,H.removeAdditional!=="all"&&(0,Lw.alwaysValidSchema)(K,U))return;let G=(0,Xw.allSchemaProperties)(Y.properties),W=(0,Xw.allSchemaProperties)(Y.patternProperties);w(),$.ok(r$._`${Q}===${jv0.default.errors}`);function w(){I.forIn("key",J,(D)=>{if(!G.length&&!W.length)X(D);else I.if(V(D),()=>X(D))})}function V(D){let O;if(G.length>8){let E=(0,Lw.schemaRefOrVal)(K,Y.properties,"properties");O=(0,Xw.isOwnProperty)(I,E,D)}else if(G.length)O=(0,r$.or)(...G.map((E)=>r$._`${D}===${E}`));else O=r$.nil;if(W.length)O=(0,r$.or)(O,...W.map((E)=>r$._`${(0,Xw.usePattern)($,E)}.test(${D})`));return(0,r$.not)(O)}function Z(D){I.code(r$._`delete${J}[${D}]`)}function X(D){if(H.removeAdditional==="all"||H.removeAdditional&&U===!1){Z(D);return}if(U===!1){if($.setParams({additionalProperty:D}),$.error(),!q)I.break();return}if(typeof U=="object"&&!(0,Lw.alwaysValidSchema)(K,U)){let O=I.name("valid");if(H.removeAdditional==="failing")L(D,O,!1),I.if((0,r$.not)(O),()=>{$.reset(),Z(D)});else if(L(D,O),!q)I.if((0,r$.not)(O),()=>I.break())}}function L(D,O,E){let T={keyword:"additionalProperties",dataProp:D,dataPropType:Lw.Type.Str};if(E===!1)Object.assign(T,{compositeRule:!0,createErrors:!1,allErrors:!1});$.subschema(T,O)}}};hp.default=_v0});var fp=F((kp)=>{Object.defineProperty(kp,"__esModule",{value:!0});var gv0=mQ(),up=E$(),UE=z1(),xp=IE(),yv0={keyword:"properties",type:"object",schemaType:"object",code($){let{gen:I,schema:U,parentSchema:Y,data:J,it:Q}=$;if(Q.opts.removeAdditional==="all"&&Y.additionalProperties===void 0)xp.default.code(new gv0.KeywordCxt(Q,xp.default,"additionalProperties"));let K=(0,up.allSchemaProperties)(U);for(let w of K)Q.definedProperties.add(w);if(Q.opts.unevaluated&&K.length&&Q.props!==!0)Q.props=UE.mergeEvaluated.props(I,(0,UE.toHash)(K),Q.props);let q=K.filter((w)=>!(0,UE.alwaysValidSchema)(Q,U[w]));if(q.length===0)return;let H=I.name("valid");for(let w of q){if(G(w))W(w);else{if(I.if((0,up.propertyInData)(I,J,w,Q.opts.ownProperties)),W(w),!Q.allErrors)I.else().var(H,!0);I.endIf()}$.it.definedProperties.add(w),$.ok(H)}function G(w){return Q.opts.useDefaults&&!Q.compositeRule&&U[w].default!==void 0}function W(w){$.subschema({keyword:"properties",schemaProp:w,dataProp:w},H)}}};kp.default=yv0});var cp=F((pp)=>{Object.defineProperty(pp,"__esModule",{value:!0});var bp=E$(),Dw=a0(),ip=z1(),np=z1(),uv0={keyword:"patternProperties",type:"object",schemaType:"object",code($){let{gen:I,schema:U,data:Y,parentSchema:J,it:Q}=$,{opts:K}=Q,q=(0,bp.allSchemaProperties)(U),H=q.filter((L)=>(0,ip.alwaysValidSchema)(Q,U[L]));if(q.length===0||H.length===q.length&&(!Q.opts.unevaluated||Q.props===!0))return;let G=K.strictSchema&&!K.allowMatchingProperties&&J.properties,W=I.name("valid");if(Q.props!==!0&&!(Q.props instanceo
Line truncated
`)}openNode($,I){let U=this.tos,Y=this._xml;if(U&&this.open)Y.push(">");this._stack.push($),Y.push("<"),Y.push($),OR(Y,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)ne(this._xml,$,I)}addAttributes($){if(!this.open)throw Error("Cannot write attributes to node if it is not open");OR(this._xml,$)}writeText($){let I=this._xml;if(this.open)I.push(">"),this.open=!1;this.leaf=!1,I.push(ie.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,U){if(this.openNode($,I),U!==void 0)this.writeText(U);this.closeNode()}closeAll(){while(this._stack.length)this.closeNode()}addRollback(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf,open:this.open}),this.cursor}commit(){this._rollbacks.pop()}rollback(){let $=this._rollbacks.pop();if(this._xml.length>$.xml)this._xml.splice($.xml,this._xml.length-$.xml);if(this._stack.length>$.stack)this._stack.splice($.stack,this._stack.length-$.stack);this.leaf=$.leaf,this.open=$.open}get xml(){return this.closeAll(),this._xml.join("")}}NR.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"};pe.exports=NR});var MR=F((Lb0)=>{var ce=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function Xb0($){if(typeof $==="string")return $;if(ce)return ce.decode($);return $.toString()}Lb0.bufferToString=Xb0});var re=F((me)=>{Object.defineProperty(me,"__esModule",{value:!0});me.CHAR=`
`,$=this.i;break;case ui0:{let{entityReturnState:U}=this,Y=this.entity+I.slice($,this.prevI);this.state=U;let J;if(Y==="")this.fail("empty entity name."),J="&;";else J=this.parseEntity(Y),this.entity="";if(U!==g6||this.textHandler!==void 0)this.text+=J;break $}case H4:this.entity+=I.slice($);break $;default:}}sOpenWaka(){let $=this.getCode();if(MK($))this.state=_i0,this.unget(),this.xmlDeclPossible=!1;else switch($){case PZ:this.state=yi0,this.xmlDeclPossible=!1;break;case F00:this.state=Mi0,this.openWakaBang="",this.xmlDeclPossible=!1;break;case Y6:this.state=Bi0;break;default:this.fail("disallowed character in tag name"),this.state=g6,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=_R,this.openWakaBang="";break;case"--":this.state=CR,this.openWakaBang="";break;case"DOCTYPE":if(this.state=vR,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(AZ))this.state=Ai0}sCommentEnding(){var $;let I=this.getCodeNorm();if(I===AZ)this.state=Pi0,($=this.commentHandler)===null||$===void 0||$.call(this,this.text),this.text="";else this.text+=`-${String.fromCodePoint(I)}`,this.state=CR}sCommentEnded(){let $=this.getCodeNorm();if($!==y4)this.fail("malformed comment."),this.text+=`--${String.fromCodePoint($)}`,this.state=CR;else this.state=g6}sCData(){if(this.captureToChar(UY))this.state=Ti0}sCDataEnding(){let $=this.getCodeNorm();if($===UY)this.state=Ei0;else this.text+=`]${String.fromCodePoint($)}`,this.state=_R}sCDataEnding2(){var $;let I=this.getCodeNorm();switch(I){case y4:{($=this.cdataHandler)===null||$===void 0||$.call(this,this.text),this.text="",this.state=g6;break}case UY:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(I)}`,this.state=_R}}sPIFirstChar(){let $=this.getCodeNorm();if(this.nameStartCheck($))this.piTarget+=String.fromCodePoint($),this.state=w00;else if($===Y6||r6($))this.fail("processing instruction without a target."),this.state=$===Y6?MZ:SR;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint($),this.state=w00}sPIRest(){let{chunk:$,i:I}=this;while(!0){let U=this.getCodeNorm();if(U===H4){this.piTarget+=$.slice(I);return}if(!this.nameCheck(U)){this.piTarget+=$.slice(I,this.prevI);let Y=U===Y6;if(Y||r6(U))if(this.piTarget==="xml"){if(!this.xmlDeclPossible)this.fail("an XML declaration must be at the start of the document.");this.state=Y?W3:V00}else this.state=Y?MZ:SR;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(U);break}}}sPIBody(){if(this.text.length===0){let $=this.getCodeNorm();if($===Y6)this.state=MZ;else if(!r6($))this.text=String.fromCodePoint($)}else if(this.captureToChar(Y6))this.state=MZ}sPIEnding(){var $;let I=this.getCodeNorm();if(I===y4){let{piTarget:U}=this;if(U.toLowerCase()==="xml")this.fail("the XML declaration must appear at the start of the document.");($=this.piHandler)===null||$===void 0||$.call(this,{target:U,body:this.text}),this.piTarget=this.text="",this.state=g6}else if(I===Y6)this.text+="?";else this.text+=`?${String.fromCodePoint(I)}`,this.state=SR;this.xmlDeclPossible=!1}sXMLDeclNameStart(){let $=this.skipSpaces();if($===Y6){this.state=W3;return}if($!==H4)this.state=vi0,this.name=String.fromCodePoint($)}sXMLDeclName(){let $=this.captureTo(fi0);if($===Y6){this.state=W3,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(!(r6($)||$===IY))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=$===IY?Z00:Ri0}sXMLDeclEq(){let $=this.getCodeNorm();if($===Y6){this.state=W3,this.fail("XML declaration is incomplete.");return}if(r6($))return;if($!==IY)this.fail("value required.");this.state=Z00}sXMLDeclValueStart(){let $=this.getCodeNorm();if($===Y6){this.state=W3,this.fail("XML declaration is incomplete.");return}if(r6($))return;if(!TZ($))this.fail("value must be quoted."),this.q=D00;else this.q=$;this.state=ji0}sXMLDeclValue(){let $=this.captureTo([this.q,Y6]);if($===Y6){this.state=W3,this.text="",this.fail("XML declaration is incomplete.");return}if($===H4)return;let I=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let U=I;if(this.xmlDecl.version=U,!/^1\.[0-9]+$/.test(U))this.fail("ver
Line truncated
]`;this.ESCAPE_REGEXP=new RegExp(I)}set headers($){this._headers=$}shouldQuote($,I){let U=I?this.formatterOptions.quoteHeaders:this.formatterOptions.quoteColumns;if(Lt0.default(U))return U;if(Array.isArray(U))return U[$];if(this._headers!==null)return U[this._headers[$]];return!1}format($,I,U){let Y=`${Dt0.default($)?"":$}`.replace(/\0/g,""),{formatterOptions:J}=this;if(J.quote!==""){if(Y.indexOf(J.quote)!==-1)return this.quoteField(Y.replace(this.REPLACE_REGEXP,J.escapedQuote))}if(Y.search(this.ESCAPE_REGEXP)!==-1||this.shouldQuote(I,U))return this.quoteField(Y);return Y}quoteField($){let{quote:I}=this.formatterOptions;return`${I}${$}${I}`}}DY.FieldFormatter=Y70});var ZC=F((J70)=>{Object.defineProperty(J70,"__esModule",{value:!0});J70.isSyncTransform=void 0;J70.isSyncTransform=($)=>$.length===1});var q70=F((FY)=>{var K70=FY&&FY.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(FY,"__esModule",{value:!0});FY.RowFormatter=void 0;var Ot0=K70(Jz()),Nt0=K70(o90()),Mt0=VC(),At0=ZC();class P3{constructor($){if(this.rowCount=0,this.formatterOptions=$,this.fieldFormatter=new Mt0.FieldFormatter($),this.headers=$.headers,this.shouldWriteHeaders=$.shouldWriteHeaders,this.hasWrittenHeaders=!1,this.headers!==null)this.fieldFormatter.headers=this.headers;if($.transform)this.rowTransform=$.transform}static isRowHashArray($){if(Array.isArray($))return Array.isArray($[0])&&$[0].length===2;return!1}static isRowArray($){return Array.isArray($)&&!this.isRowHashArray($)}static gatherHeaders($){if(P3.isRowHashArray($))return $.map((I)=>I[0]);if(Array.isArray($))return $;return Object.keys($)}static createTransform($){if(At0.isSyncTransform($))return(I,U)=>{let Y=null;try{Y=$(I)}catch(J){return U(J)}return U(null,Y)};return(I,U)=>{$(I,U)}}set rowTransform($){if(!Ot0.default($))throw TypeError("The transform should be a function");this._rowTransform=P3.createTransform($)}format($,I){this.callTransformer($,(U,Y)=>{if(U)return I(U);if(!$)return I(null);let J=[];if(Y){let{shouldFormatColumns:Q,headers:K}=this.checkHeaders(Y);if(this.shouldWriteHeaders&&K&&!this.hasWrittenHeaders)J.push(this.formatColumns(K,!0)),this.hasWrittenHeaders=!0;if(Q){let q=this.gatherColumns(Y);J.push(this.formatColumns(q,!1))}}return I(null,J)})}finish($){let I=[];if(this.formatterOptions.alwaysWriteHeaders&&this.rowCount===0){if(!this.headers)return $(Error("`alwaysWriteHeaders` option is set to true but `headers` option not provided."));I.push(this.formatColumns(this.headers,!0))}if(this.formatterOptions.includeEndRowDelimiter)I.push(this.formatterOptions.rowDelimiter);return $(null,I)}checkHeaders($){if(this.headers)return{shouldFormatColumns:!0,headers:this.headers};let I=P3.gatherHeaders($);if(this.headers=I,this.fieldFormatter.headers=I,!this.shouldWriteHeaders)return{shouldFormatColumns:!0,headers:null};return{shouldFormatColumns:!Nt0.default(I,$),headers:I}}gatherColumns($){if(this.headers===null)throw Error("Headers is currently null");if(!Array.isArray($))return this.headers.map((I)=>$[I]);if(P3.isRowHashArray($))return this.headers.map((I,U)=>{let Y=$[U];if(Y)return Y[1];return""});if(P3.isRowArray($)&&!this.shouldWriteHeaders)return $;return this.headers.map((I,U)=>$[U])}callTransformer($,I){if(!this._rowTransform)return I(null,$);return this._rowTransform($,I)}formatColumns($,I){let U=$.map((J,Q)=>this.fieldFormatter.format(J,Q,I)).join(this.formatterOptions.delimiter),{rowCount:Y}=this;if(this.rowCount+=1,Y)return[this.formatterOptions.rowDelimiter,U].join("");return U}}FY.RowFormatter=P3});var H70=F((Dz)=>{Object.defineProperty(Dz,"__esModule",{value:!0});Dz.FieldFormatter=Dz.RowFormatter=void 0;var Pt0=q70();Object.defineProperty(Dz,"RowFormatter",{enumerable:!0,get:function(){return Pt0.RowFormatter}});var Tt0=VC();Object.defineProperty(Dz,"FieldFormatter",{enumerable:!0,get:function(){return Tt0.FieldFormatter}})});var zC=F((W70)=>{Object.defineProperty(W70,"__esModule",{value:!0});W70.CsvFormatterStream=void 0;var Bt0=t("stream"),vt0=H70();class G70 extends Bt0.Transform{constructor($){super({writableObjectMode:$.objectMode});this.hasWrittenBOM=!1,this.formatterOptions=$,this.rowFormatter=new vt0.RowFormatter($),this.hasWrittenBOM=!$.writeBOM}transform($){return this.rowFormatter.rowTransform=$,this}_transform($,I,U){let Y=!1;try{if(!this.hasWrittenBOM)this.push(this.formatterOptions.BOM),this.hasWrittenBOM=!0;this.rowFormatter.format($,(J,Q)=>{if(J)return Y=!0,U(J);if(Q)Q.forEach((K)=>{this.push(Buffer.from(K,"utf8"))});return Y=!0,U()})}catch(J){if(Y)throw J;U(J)}}_flush($){this.rowFormatter.finish((I,U)=>{if(I)return $(I);if(U)U.forEach((Y)=>{this.push(Buffer.from(Y,"utf8"))});return $()})}}W70.CsvFormatterStream=G70});var Z70=F((P1)=>{var V70=P1&&P1.__createBinding||(Object.create?function($,I,U,Y){if(Y===void 0)Y=U;Object.defineProperty($,Y,{enumerable:!0,get:function(){return I[U]}})}:function($,I,U,Y){if(Y===void 0)Y=U;$[Y]=I[U]}),Rt0=P1&&P1.__setModuleDefault||(Object.create?function($,I){Ob
Line truncated
deps:${q}}`};var Qv0={keyword:"dependencies",type:"object",schemaType:"object",error:Kc.error,code($){let[I,q]=wv0($);Qc($,I),wc($,q)}};function wv0({schema:$}){let I={},q={};for(let z in $){if(z==="__proto__")continue;let U=Array.isArray($[z])?I:q;U[z]=$[z]}return[I,q]}function Qc($,I=$.schema){let{gen:q,data:z,it:U}=$;if(Object.keys(I).length===0)return;let Y=q.let("missing");for(let J in I){let Q=I[J];if(Q.length===0)continue;let w=(0,XJ.propertyInData)(q,z,J,U.opts.ownProperties);if($.setParams({property:J,depsCount:Q.length,deps:Q.join(", ")}),U.allErrors)q.if(w,()=>{for(let K of Q)(0,XJ.checkReportMissingProp)($,K)});else q.if(NE._`${w}&&(${(0,XJ.checkMissingProp)($,Q,Y)})`),(0,XJ.reportMissingProp)($,Y),q.else()}}Kc.validatePropertyDeps=Qc;function wc($,I=$.schema){let{gen:q,data:z,keyword:U,it:Y}=$,J=q.name("valid");for(let Q in I){if((0,Jv0.alwaysValidSchema)(Y,I[Q]))continue;q.if((0,XJ.propertyInData)(q,z,Q,Y.opts.ownProperties),()=>{let w=$.subschema({keyword:U,schemaProp:Q},J);$.mergeValidEvaluated(w,J)},()=>q.var(J,!0)),$.ok(J)}}Kc.validateSchemaDeps=wc;Kc.default=Qv0});var Xc=F((Zc)=>{Object.defineProperty(Zc,"__esModule",{value:!0});var Vc=a0(),Gv0=Z1(),Wv0={message:"property name must be valid",params:({params:$})=>Vc._`{propertyName:${$.propertyName}}`},Vv0={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Wv0,code($){let{gen:I,schema:q,data:z,it:U}=$;if((0,Gv0.alwaysValidSchema)(U,q))return;let Y=I.name("valid");I.forIn("key",z,(J)=>{$.setParams({propertyName:J}),$.subschema({keyword:"propertyNames",data:J,dataTypes:["string"],propertyName:J,compositeRule:!0},Y),I.if((0,Vc.not)(Y),()=>{if($.error(!0),!U.allErrors)I.break()})}),$.ok(Y)}};Zc.default=Vv0});var ME=F((Lc)=>{Object.defineProperty(Lc,"__esModule",{value:!0});var gG=v$(),I8=a0(),Xv0=H5(),vG=Z1(),Lv0={message:"must NOT have additional properties",params:({params:$})=>I8._`{additionalProperty:${$.additionalProperty}}`},Dv0={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:Lv0,code($){let{gen:I,schema:q,parentSchema:z,data:U,errsCount:Y,it:J}=$;if(!Y)throw Error("ajv implementation error");let{allErrors:Q,opts:w}=J;if(J.props=!0,w.removeAdditional!=="all"&&(0,vG.alwaysValidSchema)(J,q))return;let K=(0,gG.allSchemaProperties)(z.properties),H=(0,gG.allSchemaProperties)(z.patternProperties);G(),$.ok(I8._`${Y}===${Xv0.default.errors}`);function G(){I.forIn("key",U,(D)=>{if(!K.length&&!H.length)X(D);else I.if(W(D),()=>X(D))})}function W(D){let O;if(K.length>8){let P=(0,vG.schemaRefOrVal)(J,z.properties,"properties");O=(0,gG.isOwnProperty)(I,P,D)}else if(K.length)O=(0,I8.or)(...K.map((P)=>I8._`${D}===${P}`));else O=I8.nil;if(H.length)O=(0,I8.or)(O,...H.map((P)=>I8._`${(0,gG.usePattern)($,P)}.test(${D})`));return(0,I8.not)(O)}function V(D){I.code(I8._`delete${U}[${D}]`)}function X(D){if(w.removeAdditional==="all"||w.removeAdditional&&q===!1){V(D);return}if(q===!1){if($.setParams({additionalProperty:D}),$.error(),!Q)I.break();return}if(typeof q=="object"&&!(0,vG.alwaysValidSchema)(J,q)){let O=I.name("valid");if(w.removeAdditional==="failing")L(D,O,!1),I.if((0,I8.not)(O),()=>{$.reset(),V(D)});else if(L(D,O),!Q)I.if((0,I8.not)(O),()=>I.break())}}function L(D,O,P){let T={keyword:"additionalProperties",dataProp:D,dataPropType:vG.Type.Str};if(P===!1)Object.assign(T,{compositeRule:!0,createErrors:!1,allErrors:!1});$.subschema(T,O)}}};Lc.default=Dv0});var Nc=F((Fc)=>{Object.defineProperty(Fc,"__esModule",{value:!0});var Fv0=zJ(),Dc=v$(),AE=Z1(),Oc=ME(),Nv0={keyword:"properties",type:"object",schemaType:"object",code($){let{gen:I,schema:q,parentSchema:z,data:U,it:Y}=$;if(Y.opts.removeAdditional==="all"&&z.additionalProperties===void 0)Oc.default.code(new Fv0.KeywordCxt(Y,Oc.default,"additionalProperties"));let J=(0,Dc.allSchemaProperties)(q);for(let G of J)Y.definedProperties.add(G);if(Y.opts.unevaluated&&J.length&&Y.props!==!0)Y.props=AE.mergeEvaluated.props(I,(0,AE.toHash)(J),Y.props);let Q=J.filter((G)=>!(0,AE.alwaysValidSchema)(Y,q[G]));if(Q.length===0)return;let w=I.name("valid");for(let G of Q){if(K(G))H(G);else{if(I.if((0,Dc.propertyInData)(I,U,G,Y.opts.ownProperties)),H(G),!Y.allErrors)I.else().var(w,!0);I.endIf()}$.it.definedProperties.add(G),$.ok(w)}function K(G){return Y.opts.useDefaults&&!Y.compositeRule&&q[G].default!==void 0}function H(G){$.subschema({keyword:"properties",schemaProp:G,dataProp:G},w)}}};Fc.default=Nv0});var Ec=F((Tc)=>{Object.defineProperty(Tc,"__esModule",{value:!0});var Mc=v$(),RG=a0(),Ac=Z1(),Pc=Z1(),Av0={keyword:"patternProperties",type:"object",schemaType:"object",code($){let{gen:I,schema:q,data:z,parentSchema:U,it:Y}=$,{opts:J}=Y,Q=(0,Mc.allSchemaProperties)(q),w=Q.filter((L)=>(0,Ac.alwaysValidSchema)(Y,q[L]));if(Q.length===0||w.length===Q.length&&(!Y.opts.unevaluated||Y.props===!0))return;let K=J.strictSchema&&!J.allowMatchingProperties&&U.properties,H=I.name("valid");if(Y.props!==!0&&!(Y.props instanceo
Line truncated
`)}openNode($,I){let q=this.tos,z=this._xml;if(q&&this.open)z.push(">");this._stack.push($),z.push("<"),z.push($),ng(z,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)M00(this._xml,$,I)}addAttributes($){if(!this.open)throw Error("Cannot write attributes to node if it is not open");ng(this._xml,$)}writeText($){let I=this._xml;if(this.open)I.push(">"),this.open=!1;this.leaf=!1,I.push(N00.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,q){if(this.openNode($,I),q!==void 0)this.writeText(q);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("")}}bg.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"};A00.exports=bg});var ig=F((qi0)=>{var P00=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function Ii0($){if(typeof $==="string")return $;if(P00)return P00.decode($);return $.toString()}qi0.bufferToString=Ii0});var g00=F((E00)=>{Object.defineProperty(E00,"__esModule",{value:!0});E00.CHAR=`
`,$=this.i;break;case Ap0:{let{entityReturnState:q}=this,z=this.entity+I.slice($,this.prevI);this.state=q;let U;if(z==="")this.fail("empty entity name."),U="&;";else U=this.parseEntity(z),this.entity="";if(q!==S6||this.textHandler!==void 0)this.text+=U;break $}case w4:this.entity+=I.slice($);break $;default:}}sOpenWaka(){let $=this.getCode();if(RQ($))this.state=Dp0,this.unget(),this.xmlDeclPossible=!1;else switch($){case xV:this.state=Np0,this.xmlDeclPossible=!1;break;case a00:this.state=Qp0,this.openWakaBang="",this.xmlDeclPossible=!1;break;case U6:this.state=Wp0;break;default:this.fail("disallowed character in tag name"),this.state=S6,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=sg,this.openWakaBang="";break;case"--":this.state=ag,this.openWakaBang="";break;case"DOCTYPE":if(this.state=og,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(yV))this.state=wp0}sCommentEnding(){var $;let I=this.getCodeNorm();if(I===yV)this.state=Kp0,($=this.commentHandler)===null||$===void 0||$.call(this,this.text),this.text="";else this.text+=`-${String.fromCodePoint(I)}`,this.state=ag}sCommentEnded(){let $=this.getCodeNorm();if($!==y4)this.fail("malformed comment."),this.text+=`--${String.fromCodePoint($)}`,this.state=ag;else this.state=S6}sCData(){if(this.captureToChar(Gz))this.state=Hp0}sCDataEnding(){let $=this.getCodeNorm();if($===Gz)this.state=Gp0;else this.text+=`]${String.fromCodePoint($)}`,this.state=sg}sCDataEnding2(){var $;let I=this.getCodeNorm();switch(I){case y4:{($=this.cdataHandler)===null||$===void 0||$.call(this,this.text),this.text="",this.state=S6;break}case Gz:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(I)}`,this.state=sg}}sPIFirstChar(){let $=this.getCodeNorm();if(this.nameStartCheck($))this.piTarget+=String.fromCodePoint($),this.state=c00;else if($===U6||t6($))this.fail("processing instruction without a target."),this.state=$===U6?uV:eg;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint($),this.state=c00}sPIRest(){let{chunk:$,i:I}=this;while(!0){let q=this.getCodeNorm();if(q===w4){this.piTarget+=$.slice(I);return}if(!this.nameCheck(q)){this.piTarget+=$.slice(I,this.prevI);let z=q===U6;if(z||t6(q))if(this.piTarget==="xml"){if(!this.xmlDeclPossible)this.fail("an XML declaration must be at the start of the document.");this.state=z?D3:d00}else this.state=z?uV:eg;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(q);break}}}sPIBody(){if(this.text.length===0){let $=this.getCodeNorm();if($===U6)this.state=uV;else if(!t6($))this.text=String.fromCodePoint($)}else if(this.captureToChar(U6))this.state=uV}sPIEnding(){var $;let I=this.getCodeNorm();if(I===y4){let{piTarget:q}=this;if(q.toLowerCase()==="xml")this.fail("the XML declaration must appear at the start of the document.");($=this.piHandler)===null||$===void 0||$.call(this,{target:q,body:this.text}),this.piTarget=this.text="",this.state=S6}else if(I===U6)this.text+="?";else this.text+=`?${String.fromCodePoint(I)}`,this.state=eg;this.xmlDeclPossible=!1}sXMLDeclNameStart(){let $=this.skipSpaces();if($===U6){this.state=D3;return}if($!==w4)this.state=Vp0,this.name=String.fromCodePoint($)}sXMLDeclName(){let $=this.captureTo(Ep0);if($===U6){this.state=D3,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(!(t6($)||$===Hz))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=$===Hz?m00:Zp0}sXMLDeclEq(){let $=this.getCodeNorm();if($===U6){this.state=D3,this.fail("XML declaration is incomplete.");return}if(t6($))return;if($!==Hz)this.fail("value required.");this.state=m00}sXMLDeclValueStart(){let $=this.getCodeNorm();if($===U6){this.state=D3,this.fail("XML declaration is incomplete.");return}if(t6($))return;if(!kV($))this.fail("value must be quoted."),this.q=t00;else this.q=$;this.state=Xp0}sXMLDeclValue(){let $=this.captureTo([this.q,U6]);if($===U6){this.state=D3,this.text="",this.fail("XML declaration is incomplete.");return}if($===w4)return;let I=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let q=I;if(this.xmlDecl.version=q,!/^1\.[0-9]+$/.test(q))this.fail("ver
Line truncated
`;$=this.i;break;case w4:if(q!==void 0)this.text+=I.slice($);break $;default:if(!t6(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($,I){var q;let{prefix:z,local:U}=this.qname($),Y={name:$,prefix:z,local:U,value:I};if(this.attribList.push(Y),(q=this.attributeHandler)===null||q===void 0||q.call(this,Y),z==="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,Yv(this,U,J)}else if($==="xmlns"){let J=I.trim();this.topNS[""]=J,Yv(this,"",J)}}pushAttribPlain($,I){var q;let z={name:$,value:I};this.attribList.push(z),(q=this.attributeHandler)===null||q===void 0||q.call(this,z)}end(){var $,I;if(!this.sawRoot)this.fail("document must contain a root element.");let{tags:q}=this;while(q.length>0){let U=q.pop();this.fail(`unclosedtag:${U.name}`)}if(this.state!==p00&&this.state!==S6)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,(I=this.endHandler)===null||I===void 0||I.call(this),this._init(),this}resolve($){var I,q;let z=this.topNS[$];if(z!==void 0)return z;let{tags:U}=this;for(let Y=U.length-1;Y>=0;Y--)if(z=U[Y].ns[$],z!==void 0)return z;if(z=this.ns[$],z!==void 0)return z;return(q=(I=this.opt).resolvePrefix)===null||q===void 0?void 0:q.call(I,$)}qname($){let I=$.indexOf(":");if(I===-1)return{prefix:"",local:$};let q=$.slice(I+1),z=$.slice(0,I);if(z===""||q===""||q.includes(":"))this.fail(`malformedname:${$}.`);return{prefix:z,local:q}}processAttribsNS(){var $;let{attribList:I}=this,q=this.tag;{let{prefix:Y,local:J}=this.qname(q.name);q.prefix=Y,q.local=J;let Q=q.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)}.`),q.uri=Y}}if(I.length===0)return;let{attributes:z}=q,U=new Set;for(let Y of I){let{name:J,prefix:Q,local:w}=Y,K,H;if(Q==="")K=J==="xmlns"?Wz:"",H=J;else{if(K=this.resolve(Q),K===void 0)this.fail(`unboundnamespaceprefix:${JSON.stringify(Q)}.`),K=Q;H=`{${K}}${w}`}if(U.has(H))this.fail(`duplicateattribute:${H}.`);U.add(H),Y.uri=K,z[J]=Y}this.attribList=[]}processAttribsPlain(){let{attribList:$}=this,I=this.tag.attributes;for(let{name:q,value:z}of $){if(I[q]!==void 0)this.fail(`duplicateattribute:${q}.`);I[q]=z}this.attribList=[]}openTag(){var $;this.processAttribs();let{tags:I}=this,q=this.tag;q.isSelfClosing=!1,($=this.openTagHandler)===null||$===void 0||$.call(this,q),I.push(q),this.state=S6,this.name=""}openSelfClosingTag(){var $,I,q;this.processAttribs();let{tags:z}=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=(q=z[z.length-1])!==null&&q!==void 0?q:null)===null)this.closedRoot=!0;this.state=S6,this.name=""}closeTag(){let{tags:$,name:I}=this;if(this.state=S6,this.name="",I===""){this.fail("weird empty close tag."),this.text+="</>";return}let q=this.closeTagHandler,z=$.length;while(z-- >0){let U=this.tag=$.pop();if(this.topNS=U.ns,q===null||q===void 0||q(U),U.name===I)break;this.fail("unexpected close tag.")}if(z===0)this.closedRoot=!0;else if(z<0)this.fail(`unmatchedclosingtag:${I}.`),this.text+=`</${I}>`}parseEntity($){if($[0]!=="#"){let q=this.ENTITIES[$];if(q!==void 0)return q;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)}}w10.SaxesParser=Q10});varhQ=F((EB1,H10)=>{var{SaxesParser:_p0}=K10(),{PassThrough:hp0}=O6(),{bufferToString:Sp0}=ig();H10.exports=asyncfunction*($){if($.pipe&&!$[Symbol.asyncIterator])$=$.pipe(newhp0);letI=new_p0,q;I.on("error",(U)=>{q=U});letz=[];I.on("opentag",(U)=>z.push({eventType:"opentag",value:U})),I.on("text",(U)=>z.push({eventType:"text",value:U})),I.on("closetag",(U)=>z.push({eventType:"closetag",value:U}));forawait(letUof$){if(I.write(Sp0(U)),q)throwq;yieldz,z=[]}}});varL0=F((BB1,G10)=>{varup0=hQ(),yp0=z6();classZz{prepare(){}render(){}parseOpen($){}parseText($){}parseClose($){}reconcile($,I){}reset(){if(this.model=null,this.map)Object.values(this.map).forEach(($)=>{if($instanceofZz)$.reset();elseif($.xform)$.xform.reset()})}mergeModel($){this.model=Object.assign(this.model||{},$)}asyncparse($){forawait(letIof$)for(let{eventType:q,value:z}ofI)if(q==="opentag")this.parseOpen(z);elseif(q==="text")this.parseText(z);elseif(q==="closetag"){if(!this.parseClose(z.name))returnthLine truncated
See:https://github.com/isaacs/node-glob/issues/167`);return new h4($,I).found}function h4($,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 x4($,I).found}function x4($,I){if(!$)throw Error("must provide pattern");if(typeof I==="function"||arguments.length===3)throw TypeError(`callback provided to sync glob
`+e[W0-1];break}}}var H1="a promise was created in a "+M+"handler "+s+"but was not returned from it, see http://goo.gl/rRqMUw"+m;C._warn(H1,!0,N)}}function j0(a,N){var M=a+" is deprecated and will be removed in a future version.";if(N)M+=" Use "+N+" instead.";return q1(M)}function q1(a,N,M){if(!v0.warnings)return;var C=new J(a),u;if(N)M._attachExtraTrace(C);else if(v0.longStackTraces&&(u=$._peekContext()))u.attachExtraTrace(C);else{var s=U1(C);C.stack=s.message+`
`+e[H0-1];break}}}var w1="a promise was created in a "+M+"handler "+s+"but was not returned from it, see http://goo.gl/rRqMUw"+m;R._warn(w1,!0,N)}}function v0(a,N){var M=a+" is deprecated and will be removed in a future version.";if(N)M+=" Use "+N+" instead.";return Q1(M)}function Q1(a,N,M){if(!j0.warnings)return;var R=new U(a),y;if(N)M._attachExtraTrace(R);else if(j0.longStackTraces&&(y=$._peekContext()))y.attachExtraTrace(R);else{var s=z1(R);R.stack=s.message+`
`)));return}}O=O._target();var E=O._bitField;if((E&50397184)===0)this._yieldedPromise=O,O._proxy(this,null);else if((E&33554432)!==0)$._async.invoke(this._promiseFulfilled,this,O._value());else if((E&16777216)!==0)$._async.invoke(this._promiseRejected,this,O._reason());else this._promiseCancelled()}},$.coroutine=function(X,L){if(typeof X!=="function")throw new q(`generatorFunctionmustbeafunction
`)));return}}O=O._target();var P=O._bitField;if((P&50397184)===0)this._yieldedPromise=O,O._proxy(this,null);else if((P&33554432)!==0)$._async.invoke(this._promiseFulfilled,this,O._value());else if((P&16777216)!==0)$._async.invoke(this._promiseRejected,this,O._reason());else this._promiseCancelled()}},$.coroutine=function(X,L){if(typeof X!=="function")throw new Q(`generatorFunctionmustbeafunction
Seehttp://goo.gl/MqrFmX
`);var D=Object(L).yieldHandler,O=Z,E=Error().stack;return function(){var T=X.apply(this,arguments),A=new O(void 0,void 0,D,E),R=A.promise();return A._generator=T,A._promiseFulfilled(void 0),R}},$.coroutine.addYieldHandler=function(X){if(typeof X!=="function")throw new q("expecting a function but got "+H.classString(X));w.push(X)},$.spawn=function(X){if(Q.deprecated("Promise.spawn()","Promise.coroutine()"),typeof X!=="function")return I(`generatorFunctionmustbeafunction
`);var D=Object(L).yieldHandler,O=V,P=Error().stack;return function(){var T=X.apply(this,arguments),A=new O(void 0,void 0,D,P),g=A.promise();return A._generator=T,A._promiseFulfilled(void 0),g}},$.coroutine.addYieldHandler=function(X){if(typeof X!=="function")throw new Q("expecting a function but got "+w.classString(X));G.push(X)},$.spawn=function(X){if(Y.deprecated("Promise.spawn()","Promise.coroutine()"),typeof X!=="function")return I(`generatorFunctionmustbeafunction
`)},I=function(){return new S.PromiseInspection(this._target())},U=function(B){return S.reject(new w(B))};function Y(){}var J={},Q=d1(),K;if(Q.isNode)K=function(){var B=process.domain;if(B===void 0)B=null;return B};else K=function(){return null};Q.notEnumerableProp(S,"_getDomain",K);var q=p3(),H=_K0(),G=new H;q.defineProperty(S,"_async",{value:G});var W=u5(),w=S.TypeError=W.TypeError;S.RangeError=W.RangeError;var V=S.CancellationError=W.CancellationError;S.TimeoutError=W.TimeoutError,S.OperationalError=W.OperationalError,S.RejectionError=W.OperationalError,S.AggregateError=W.AggregateError;var Z=function(){},X={},L={},D=uK0()(S,Z),O=kK0()(S,Z,D,U,Y),E=bK0()(S),T=E.create,A=nK0()(S,E),R=A.CapturedTrace,k=cK0()(S,D),g=mK0()(L),f=kg(),j=Q.errorObj,p=Q.tryCatch;function n(B,x){if(typeof x!=="function")throw new w("expecting a function but got "+Q.classString(x));if(B.constructor!==S)throw new w(`thepromiseconstructorcannotbeinvokeddirectly
`)},I=function(){return new h.PromiseInspection(this._target())},q=function(B){return h.reject(new G(B))};function z(){}var U={},Y=d1(),J;if(Y.isNode)J=function(){var B=process.domain;if(B===void 0)B=null;return B};else J=function(){return null};Y.notEnumerableProp(h,"_getDomain",J);var Q=t3(),w=H20(),K=new w;Q.defineProperty(h,"_async",{value:K});var H=b5(),G=h.TypeError=H.TypeError;h.RangeError=H.RangeError;var W=h.CancellationError=H.CancellationError;h.TimeoutError=H.TimeoutError,h.OperationalError=H.OperationalError,h.RejectionError=H.OperationalError,h.AggregateError=H.AggregateError;var V=function(){},X={},L={},D=X20()(h,V),O=D20()(h,V,D,q,z),P=F20()(h),T=P.create,A=M20()(h,P),g=A.CapturedTrace,k=P20()(h,D),S=E20()(L),f=YS(),v=Y.errorObj,p=Y.tryCatch;function i(B,x){if(typeof x!=="function")throw new G("expecting a function but got "+Y.classString(x));if(B.constructor!==h)throw new G(`thepromiseconstructorcannotbeinvokeddirectly
Seehttp://goo.gl/MqrFmX
`)}function S(B){if(this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,B!==Z)n(this,B),this._resolveFromExecutor(B);this._promiseCreated(),this._fireEvent("promiseCreated",this)}S.prototype.toString=function(){return"[object Promise]"},S.prototype.caught=S.prototype.catch=function(B){var x=arguments.length;if(x>1){var c=Array(x-1),r=0,J0;for(J0=0;J0<x-1;++J0){var w0=arguments[J0];if(Q.isObject(w0))c[r++]=w0;else return U("expecting an object but got A catch statement predicate "+Q.classString(w0))}return c.length=r,B=arguments[J0],this.then(void 0,g(c,B,this))}return this.then(void 0,B)},S.prototype.reflect=function(){return this._then(I,I,void 0,this,void 0)},S.prototype.then=function(B,x){if(A.warnings()&&arguments.length>0&&typeof B!=="function"&&typeof x!=="function"){var c=".then() only accepts functions but was passed: "+Q.classString(B);if(arguments.length>1)c+=", "+Q.classString(x);this._warn(c)}return this._then(B,x,void 0,void 0,void 0)},S.prototype.done=function(B,x){var c=this._then(B,x,void 0,void 0,void 0);c._setIsFinal()},S.prototype.spread=function(B){if(typeof B!=="function")return U("expecting a function but got "+Q.classString(B));return this.all()._then(B,void 0,void 0,X,void 0)},S.prototype.toJSON=function(){var B={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};if(this.isFulfilled())B.fulfillmentValue=this.value(),B.isFulfilled=!0;else if(this.isRejected())B.rejectionReason=this.reason(),B.isRejected=!0;return B},S.prototype.all=function(){if(arguments.length>0)this._warn(".all() was passed arguments but it does not take any");return new O(this).promise()},S.prototype.error=function(B){return this.caught(Q.originatesFromRejection,B)},S.getNewLibraryCopy=bg.exports,S.is=function(B){return B instanceof S},S.fromNode=S.fromCallback=function(B){var x=new S(Z);x._captureStackTrace();var c=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,r=p(B)(f(x,c));if(r===j)x._rejectCallback(r.e,!0);if(!x._isFateSealed())x._setAsyncGuaranteed();return x},S.all=function(B){return new O(B).promise()},S.cast=function(B){var x=D(B);if(!(x instanceof S))x=new S(Z),x._captureStackTrace(),x._setFulfilled(),x._rejectionHandler0=B;return x},S.resolve=S.fulfilled=S.cast,S.reject=S.rejected=function(B){var x=new S(Z);return x._captureStackTrace(),x._rejectCallback(B,!0),x},S.setScheduler=function(B){if(typeof B!=="function")throw new w("expecting a function but got "+Q.classString(B));return G.setScheduler(B)},S.prototype._then=function(B,x,c,r,J0){var w0=J0!==void 0,A0=w0?J0:new S(Z),j0=this._target(),q1=j0._bitField;if(!w0){if(A0._propagateFrom(this,3),A0._captureStackTrace(),r===void 0&&(this._bitField&2097152)!==0)if((q1&50397184)!==0)r=this._boundValue();else r=j0===this?void 0:this._boundTo;this._fireEvent("promiseChained",this,A0)}var k0=K();if((q1&50397184)!==0){var I1,M0,Q0=j0._settlePromiseCtx;if((q1&33554432)!==0)M0=j0._rejectionHandler0,I1=B;else if((q1&16777216)!==0)M0=j0._fulfillmentHandler0,I1=x,j0._unsetRejectionIsUnhandled();else Q0=j0._settlePromiseLateCancellationObserver,M0=new V("late cancellation observer"),j0._attachExtraTrace(M0),I1=x;G.invoke(Q0,j0,{handler:k0===null?I1:typeof I1==="function"&&Q.domainBind(k0,I1),promise:A0,receiver:r,value:M0})}else j0._addCallbacks(B,x,A0,r,k0);return A0},S.prototype._length=function(){return this._bitField&65535},S.prototype._isFateSealed=function(){return(this._bitField&117506048)!==0},S.prototype._isFollowing=function(){return(this._bitField&67108864)===67108864},S.prototype._setLength=function(B){this._bitField=this._bitField&-65536|B&65535},S.prototype._setFulfilled=function(){this._bitField=this._bitField|33554432,this._fireEvent("promiseFulfilled",this)},S.prototype._setRejected=function(){this._bitField=this._bitField|16777216,this._fireEvent("promiseRejected",this)},S.prototype._setFollowing=function(){this._bitField=this._bitField|67108864,this._fireEvent("promiseResolved",this)},S.prototype._setIsFinal=function(){this._bitField=this._bitField|4194304},S.prototype._isFinal=function(){return(this._bitField&4194304)>0},S.prototype._unsetCancelled=function(){this._bitField=this._bitField&-65537},S.prototype._setCancelled=function(){this._bitField=this._bitField|65536,this._fireEvent("promiseCancelled",this)},S.prototype._setWillBeCancelled=function(){this._bitField=this._bitField|8388608},S.prototype._setAsyncGuaranteed=function(){if(G.hasCustomScheduler())return;this._bitField=this._bitField|134217728},S.prototype._receiverAt=function(B){var x=B===0?this._receiver0:this[B*4-4+3];if(x===J)return;else if(x===void 0&&this._isBound())return this._boundValue();return x},S.prototype._promiseAt=function(B){return this[B*4-4+2]},S.prototype._fulfillmentHandlerAt=function(B){return this[B*4-4+0]},S.prototype._rejectionHandlerAt=function(B){return this[B*4-4+1]},S.prototype._boundValue=function(){},S.prototype._migrateCallback0=function(B){var{_bit
Line truncated
`)}function h(B){if(this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,B!==V)i(this,B),this._resolveFromExecutor(B);this._promiseCreated(),this._fireEvent("promiseCreated",this)}h.prototype.toString=function(){return"[object Promise]"},h.prototype.caught=h.prototype.catch=function(B){var x=arguments.length;if(x>1){var c=Array(x-1),r=0,U0;for(U0=0;U0<x-1;++U0){var G0=arguments[U0];if(Y.isObject(G0))c[r++]=G0;else return q("expecting an object but got A catch statement predicate "+Y.classString(G0))}return c.length=r,B=arguments[U0],this.then(void 0,S(c,B,this))}return this.then(void 0,B)},h.prototype.reflect=function(){return this._then(I,I,void 0,this,void 0)},h.prototype.then=function(B,x){if(A.warnings()&&arguments.length>0&&typeof B!=="function"&&typeof x!=="function"){var c=".then() only accepts functions but was passed: "+Y.classString(B);if(arguments.length>1)c+=", "+Y.classString(x);this._warn(c)}return this._then(B,x,void 0,void 0,void 0)},h.prototype.done=function(B,x){var c=this._then(B,x,void 0,void 0,void 0);c._setIsFinal()},h.prototype.spread=function(B){if(typeof B!=="function")return q("expecting a function but got "+Y.classString(B));return this.all()._then(B,void 0,void 0,X,void 0)},h.prototype.toJSON=function(){var B={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};if(this.isFulfilled())B.fulfillmentValue=this.value(),B.isFulfilled=!0;else if(this.isRejected())B.rejectionReason=this.reason(),B.isRejected=!0;return B},h.prototype.all=function(){if(arguments.length>0)this._warn(".all() was passed arguments but it does not take any");return new O(this).promise()},h.prototype.error=function(B){return this.caught(Y.originatesFromRejection,B)},h.getNewLibraryCopy=QS.exports,h.is=function(B){return B instanceof h},h.fromNode=h.fromCallback=function(B){var x=new h(V);x._captureStackTrace();var c=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,r=p(B)(f(x,c));if(r===v)x._rejectCallback(r.e,!0);if(!x._isFateSealed())x._setAsyncGuaranteed();return x},h.all=function(B){return new O(B).promise()},h.cast=function(B){var x=D(B);if(!(x instanceof h))x=new h(V),x._captureStackTrace(),x._setFulfilled(),x._rejectionHandler0=B;return x},h.resolve=h.fulfilled=h.cast,h.reject=h.rejected=function(B){var x=new h(V);return x._captureStackTrace(),x._rejectCallback(B,!0),x},h.setScheduler=function(B){if(typeof B!=="function")throw new G("expecting a function but got "+Y.classString(B));return K.setScheduler(B)},h.prototype._then=function(B,x,c,r,U0){var G0=U0!==void 0,A0=G0?U0:new h(V),v0=this._target(),Q1=v0._bitField;if(!G0){if(A0._propagateFrom(this,3),A0._captureStackTrace(),r===void 0&&(this._bitField&2097152)!==0)if((Q1&50397184)!==0)r=this._boundValue();else r=v0===this?void 0:this._boundTo;this._fireEvent("promiseChained",this,A0)}var k0=J();if((Q1&50397184)!==0){var q1,M0,Y0=v0._settlePromiseCtx;if((Q1&33554432)!==0)M0=v0._rejectionHandler0,q1=B;else if((Q1&16777216)!==0)M0=v0._fulfillmentHandler0,q1=x,v0._unsetRejectionIsUnhandled();else Y0=v0._settlePromiseLateCancellationObserver,M0=new W("late cancellation observer"),v0._attachExtraTrace(M0),q1=x;K.invoke(Y0,v0,{handler:k0===null?q1:typeof q1==="function"&&Y.domainBind(k0,q1),promise:A0,receiver:r,value:M0})}else v0._addCallbacks(B,x,A0,r,k0);return A0},h.prototype._length=function(){return this._bitField&65535},h.prototype._isFateSealed=function(){return(this._bitField&117506048)!==0},h.prototype._isFollowing=function(){return(this._bitField&67108864)===67108864},h.prototype._setLength=function(B){this._bitField=this._bitField&-65536|B&65535},h.prototype._setFulfilled=function(){this._bitField=this._bitField|33554432,this._fireEvent("promiseFulfilled",this)},h.prototype._setRejected=function(){this._bitField=this._bitField|16777216,this._fireEvent("promiseRejected",this)},h.prototype._setFollowing=function(){this._bitField=this._bitField|67108864,this._fireEvent("promiseResolved",this)},h.prototype._setIsFinal=function(){this._bitField=this._bitField|4194304},h.prototype._isFinal=function(){return(this._bitField&4194304)>0},h.prototype._unsetCancelled=function(){this._bitField=this._bitField&-65537},h.prototype._setCancelled=function(){this._bitField=this._bitField|65536,this._fireEvent("promiseCancelled",this)},h.prototype._setWillBeCancelled=function(){this._bitField=this._bitField|8388608},h.prototype._setAsyncGuaranteed=function(){if(K.hasCustomScheduler())return;this._bitField=this._bitField|134217728},h.prototype._receiverAt=function(B){var x=B===0?this._receiver0:this[B*4-4+3];if(x===U)return;else if(x===void 0&&this._isBound())return this._boundValue();return x},h.prototype._promiseAt=function(B){return this[B*4-4+2]},h.prototype._fulfillmentHandlerAt=function(B){return this[B*4-4+0]},h.prototype._rejectionHandlerAt=function(B){return this[B*4-4+1]},h.prototype._boundValue=function(){},h.prototype._migrateCallback0=function(B){var{_bit
Line truncated
`).filter((Q)=>Q),Y=Math.min(...U.map((Q)=>Q.length-Q.trimStart().length)),J=U.map((Q)=>Q.slice(Y)).map((Q)=>" ".repeat(this.indent*2)+Q);for(let Q of J)this.content.push(Q)}compile(){let $=Function,I=this?.args,Y=[...(this?.content??[""]).map((J)=>`${J}`)];return new $(...I,Y.join(`
`))}}var qO={major:4,minor:4,patch:3};var n0=o("$ZodType",($,I)=>{var U;$??($={}),$._zod.def=I,$._zod.bag=$._zod.bag||{},$._zod.version=qO;let Y=[...$._zod.def.checks??[]];if($._zod.traits.has("$ZodCheck"))Y.unshift($);for(let J of Y)for(let Q of J._zod.onattach)Q($);if(Y.length===0)(U=$._zod).deferred??(U.deferred=[]),$._zod.deferred?.push(()=>{$._zod.run=$._zod.parse});else{let J=(K,q,H)=>{let G=I9(K),W;for(let w of q){if(w._zod.def.when){if(wF(K))continue;if(!w._zod.def.when(K))continue}else if(G)continue;let V=K.issues.length,Z=w._zod.check(K);if(Z instanceof Promise&&H?.async===!1)throw new w8;if(W||Z instanceof Promise)W=(W??Promise.resolve()).then(async()=>{if(await Z,K.issues.length===V)return;if(!G)G=I9(K,V)});else{if(K.issues.length===V)continue;if(!G)G=I9(K,V)}}if(W)return W.then(()=>{return K});return K},Q=(K,q,H)=>{if(I9(K))return K.aborted=!0,K;let G=J(q,Y,H);if(G instanceof Promise){if(H.async===!1)throw new w8;return G.then((W)=>$._zod.parse(W,H))}return $._zod.parse(G,H)};$._zod.run=(K,q)=>{if(q.skipChecks)return $._zod.parse(K,q);if(q.direction==="backward"){let G=$._zod.parse({value:K.value,issues:[]},{...q,skipChecks:!0});if(G instanceof Promise)return G.then((W)=>{return Q(W,K,q)});return Q(G,K,q)}let H=$._zod.parse(K,q);if(H instanceof Promise){if(q.async===!1)throw new w8;return H.then((G)=>J(G,Y,q))}return J(H,Y,q)}}e0($,"~standard",()=>({validate:(J)=>{try{let Q=BI($,J);return Q.success?{value:Q.data}:{issues:Q.error?.issues}}catch(Q){return sJ($,J).then((K)=>K.success?{value:K.data}:{issues:K.error?.issues})}},vendor:"zod",version:1}))}),_7=o("$ZodString",($,I)=>{n0.init($,I),$._zod.pattern=[...$?._zod.bag?.patterns??[]].pop()??hF($._zod.bag),$._zod.parse=(U,Y)=>{if(I.coerce)try{U.value=String(U.value)}catch(J){}if(typeof U.value==="string")return U;return U.issues.push({expected:"string",code:"invalid_type",input:U.value,inst:$}),U}}),h1=o("$ZodStringFormat",($,I)=>{RI.init($,I),_7.init($,I)}),GO=o("$ZodGUID",($,I)=>{I.pattern??(I.pattern=MF),h1.init($,I)}),WO=o("$ZodUUID",($,I)=>{if(I.version){let Y={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[I.version];if(Y===void 0)throw Error(`InvalidUUIDversion:"${I.version}"`);I.pattern??(I.pattern=C7(Y))}else I.pattern??(I.pattern=C7());h1.init($,I)}),wO=o("$ZodEmail",($,I)=>{I.pattern??(I.pattern=AF),h1.init($,I)}),VO=o("$ZodURL",($,I)=>{h1.init($,I),$._zod.check=(U)=>{try{let Y=U.value.trim();if(!I.normalize&&I.protocol?.source===CF.source){if(!/^https?:\/\//i.test(Y)){U.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:U.value,inst:$,continue:!I.abort});return}}let J=new URL(Y);if(I.hostname){if(I.hostname.lastIndex=0,!I.hostname.test(J.hostname))U.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:I.hostname.source,input:U.value,inst:$,continue:!I.abort})}if(I.protocol){if(I.protocol.lastIndex=0,!I.protocol.test(J.protocol.endsWith(":")?J.protocol.slice(0,-1):J.protocol))U.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:I.protocol.source,input:U.value,inst:$,continue:!I.abort})}if(I.normalize)U.value=J.href;else U.value=Y;return}catch(Y){U.issues.push({code:"invalid_format",format:"url",input:U.value,inst:$,continue:!I.abort})}}}),ZO=o("$ZodEmoji",($,I)=>{I.pattern??(I.pattern=PF()),h1.init($,I)}),zO=o("$ZodNanoID",($,I)=>{I.pattern??(I.pattern=OF),h1.init($,I)}),XO=o("$ZodCUID",($,I)=>{I.pattern??(I.pattern=zF),h1.init($,I)}),LO=o("$ZodCUID2",($,I)=>{I.pattern??(I.pattern=XF),h1.init($,I)}),DO=o("$ZodULID",($,I)=>{I.pattern??(I.pattern=LF),h1.init($,I)}),FO=o("$ZodXID",($,I)=>{I.pattern??(I.pattern=DF),h1.init($,I)}),OO=o("$ZodKSUID",($,I)=>{I.pattern??(I.pattern=FF),h1.init($,I)}),NO=o("$ZodISODateTime",($,I)=>{I.pattern??(I.pattern=yF(I)),h1.init($,I)}),MO=o("$ZodISODate",($,I)=>{I.pattern??(I.pattern=SF),h1.init($,I)}),AO=o("$ZodISOTime",($,I)=>{I.pattern??(I.pattern=gF(I)),h1.init($,I)}),PO=o("$ZodISODuration",($,I)=>{I.pattern??(I.pattern=NF),h1.init($,I)}),TO=o("$ZodIPv4",($,I)=>{I.pattern??(I.pattern=TF),h1.init($,I),$._zod.bag.format="ipv4"}),EO=o("$ZodIPv6",($,I)=>{I.pattern??(I.pattern=EF),h1.init($,I),$._zod.bag.format="ipv6",$._zod.check=(U)=>{try{new URL(`http://[${U.value}]`)}catch{U.issues.push({code:"invalid_format",format:"ipv6",input:U.value,inst:$,continue:!I.abort})}}}),BO=o("$ZodMAC",($,I)=>{I.pattern??(I.pattern=BF(I.delimiter)),h1.init($,I),$._zod.bag.format="mac"}),vO=o("$ZodCIDRv4",($,I)=>{I.pattern??(I.pattern=vF),h1.init($,I)}),RO=o("$ZodCIDRv6",($,I)=>{I.pattern??(I.pattern=RF),h1.init($,I),$._zod.check=(U)=>{let Y=U.value.split("/");try{if(Y.length!==2)throw Error();let[J,Q]=Y;if(!Q)throw Error();let K=Number(Q);if(`${K}`!==Q)throw Error();if(K<0||K>128)throw Error();new URL(`http://[${J}]`)}catch{U.issues.push({code:"invalid_format",format:"cidrv6",input:U.value,inst:$,continue:!I.abort})}}});function jO($){if($==="")return!0;if(/\s/.test($))return!1;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}
Line truncated
`).filter((Y)=>Y),z=Math.min(...q.map((Y)=>Y.length-Y.trimStart().length)),U=q.map((Y)=>Y.slice(z)).map((Y)=>" ".repeat(this.indent*2)+Y);for(let Y of U)this.content.push(Y)}compile(){let $=Function,I=this?.args,z=[...(this?.content??[""]).map((U)=>`${U}`)];return new $(...I,z.join(`
`))}}var jF={major:4,minor:4,patch:3};var p0=o("$ZodType",($,I)=>{var q;$??($={}),$._zod.def=I,$._zod.bag=$._zod.bag||{},$._zod.version=jF;let z=[...$._zod.def.checks??[]];if($._zod.traits.has("$ZodCheck"))z.unshift($);for(let U of z)for(let Y of U._zod.onattach)Y($);if(z.length===0)(q=$._zod).deferred??(q.deferred=[]),$._zod.deferred?.push(()=>{$._zod.run=$._zod.parse});else{let U=(J,Q,w)=>{let K=Q9(J),H;for(let G of Q){if(G._zod.def.when){if(CO(J))continue;if(!G._zod.def.when(J))continue}else if(K)continue;let W=J.issues.length,V=G._zod.check(J);if(V instanceof Promise&&w?.async===!1)throw new O8;if(H||V instanceof Promise)H=(H??Promise.resolve()).then(async()=>{if(await V,J.issues.length===W)return;if(!K)K=Q9(J,W)});else{if(J.issues.length===W)continue;if(!K)K=Q9(J,W)}}if(H)return H.then(()=>{return J});return J},Y=(J,Q,w)=>{if(Q9(J))return J.aborted=!0,J;let K=U(Q,z,w);if(K instanceof Promise){if(w.async===!1)throw new O8;return K.then((H)=>$._zod.parse(H,w))}return $._zod.parse(K,w)};$._zod.run=(J,Q)=>{if(Q.skipChecks)return $._zod.parse(J,Q);if(Q.direction==="backward"){let K=$._zod.parse({value:J.value,issues:[]},{...Q,skipChecks:!0});if(K instanceof Promise)return K.then((H)=>{return Y(H,J,Q)});return Y(K,J,Q)}let w=$._zod.parse(J,Q);if(w instanceof Promise){if(Q.async===!1)throw new O8;return w.then((K)=>U(K,z,Q))}return U(w,z,Q)}}$1($,"~standard",()=>({validate:(U)=>{try{let Y=SI($,U);return Y.success?{value:Y.data}:{issues:Y.error?.issues}}catch(Y){return KY($,U).then((J)=>J.success?{value:J.data}:{issues:J.error?.issues})}},vendor:"zod",version:1}))}),k7=o("$ZodString",($,I)=>{p0.init($,I),$._zod.pattern=[...$?._zod.bag?.patterns??[]].pop()??IF($._zod.bag),$._zod.parse=(q,z)=>{if(I.coerce)try{q.value=String(q.value)}catch(U){}if(typeof q.value==="string")return q;return q.issues.push({expected:"string",code:"invalid_type",input:q.value,inst:$}),q}}),x1=o("$ZodStringFormat",($,I)=>{yI.init($,I),k7.init($,I)}),vF=o("$ZodGUID",($,I)=>{I.pattern??(I.pattern=bO),x1.init($,I)}),RF=o("$ZodUUID",($,I)=>{if(I.version){let z={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[I.version];if(z===void 0)throw Error(`InvalidUUIDversion:"${I.version}"`);I.pattern??(I.pattern=x7(z))}else I.pattern??(I.pattern=x7());x1.init($,I)}),CF=o("$ZodEmail",($,I)=>{I.pattern??(I.pattern=iO),x1.init($,I)}),_F=o("$ZodURL",($,I)=>{x1.init($,I),$._zod.check=(q)=>{try{let z=q.value.trim();if(!I.normalize&&I.protocol?.source===tO.source){if(!/^https?:\/\//i.test(z)){q.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:q.value,inst:$,continue:!I.abort});return}}let U=new URL(z);if(I.hostname){if(I.hostname.lastIndex=0,!I.hostname.test(U.hostname))q.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:I.hostname.source,input:q.value,inst:$,continue:!I.abort})}if(I.protocol){if(I.protocol.lastIndex=0,!I.protocol.test(U.protocol.endsWith(":")?U.protocol.slice(0,-1):U.protocol))q.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:I.protocol.source,input:q.value,inst:$,continue:!I.abort})}if(I.normalize)q.value=U.href;else q.value=z;return}catch(z){q.issues.push({code:"invalid_format",format:"url",input:q.value,inst:$,continue:!I.abort})}}}),hF=o("$ZodEmoji",($,I)=>{I.pattern??(I.pattern=pO()),x1.init($,I)}),SF=o("$ZodNanoID",($,I)=>{I.pattern??(I.pattern=fO),x1.init($,I)}),uF=o("$ZodCUID",($,I)=>{I.pattern??(I.pattern=SO),x1.init($,I)}),yF=o("$ZodCUID2",($,I)=>{I.pattern??(I.pattern=uO),x1.init($,I)}),xF=o("$ZodULID",($,I)=>{I.pattern??(I.pattern=yO),x1.init($,I)}),kF=o("$ZodXID",($,I)=>{I.pattern??(I.pattern=xO),x1.init($,I)}),fF=o("$ZodKSUID",($,I)=>{I.pattern??(I.pattern=kO),x1.init($,I)}),nF=o("$ZodISODateTime",($,I)=>{I.pattern??(I.pattern=$F(I)),x1.init($,I)}),bF=o("$ZodISODate",($,I)=>{I.pattern??(I.pattern=sO),x1.init($,I)}),iF=o("$ZodISOTime",($,I)=>{I.pattern??(I.pattern=eO(I)),x1.init($,I)}),pF=o("$ZodISODuration",($,I)=>{I.pattern??(I.pattern=nO),x1.init($,I)}),cF=o("$ZodIPv4",($,I)=>{I.pattern??(I.pattern=cO),x1.init($,I),$._zod.bag.format="ipv4"}),dF=o("$ZodIPv6",($,I)=>{I.pattern??(I.pattern=dO),x1.init($,I),$._zod.bag.format="ipv6",$._zod.check=(q)=>{try{new URL(`http://[${q.value}]`)}catch{q.issues.push({code:"invalid_format",format:"ipv6",input:q.value,inst:$,continue:!I.abort})}}}),mF=o("$ZodMAC",($,I)=>{I.pattern??(I.pattern=mO(I.delimiter)),x1.init($,I),$._zod.bag.format="mac"}),lF=o("$ZodCIDRv4",($,I)=>{I.pattern??(I.pattern=lO),x1.init($,I)}),oF=o("$ZodCIDRv6",($,I)=>{I.pattern??(I.pattern=oO),x1.init($,I),$._zod.check=(q)=>{let z=q.value.split("/");try{if(z.length!==2)throw Error();let[U,Y]=z;if(!Y)throw Error();let J=Number(Y);if(`${J}`!==Y)throw Error();if(J<0||J>128)throw Error();new URL(`http://[${U}]`)}catch{q.issues.push({code:"invalid_format",format:"cidrv6",input:q.value,inst:$,continue:!I.abort})}}});function rF($){if($==="")return!0;if(/\s/.test($))return!1;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}
Line truncated
`)}Z.write("payload.value = newResult;"),Z.write("return payload;");let E=Z.compile();return(T,A)=>E(V,T,A)},Q,K=j7,q=!v7.jitless,G=q&&QF.value,W=I.catchall,w;$._zod.parse=(V,Z)=>{w??(w=Y.value);let X=V.value;if(!K(X))return V.issues.push({expected:"object",code:"invalid_type",input:X,inst:$}),V;if(q&&G&&Z?.async===!1&&Z.jitless!==!0){if(!Q)Q=J(I.shape);if(V=Q(V,Z),!W)return V;return Dk([],X,V,Z,w,$)}return U(V,Z)}});function Ik($,I,U,Y){for(let Q of $)if(Q.issues.length===0)return I.value=Q.value,I;let J=$.filter((Q)=>!I9(Q));if(J.length===1)return I.value=J[0].value,J[0];return I.issues.push({code:"invalid_union",input:I.value,inst:U,errors:$.map((Q)=>Q.issues.map((K)=>E6(K,Y,z4())))}),I}var YQ=o("$ZodUnion",($,I)=>{n0.init($,I),e0($._zod,"optin",()=>I.options.some((Y)=>Y._zod.optin==="optional")?"optional":void 0),e0($._zod,"optout",()=>I.options.some((Y)=>Y._zod.optout==="optional")?"optional":void 0),e0($._zod,"values",()=>{if(I.options.every((Y)=>Y._zod.values))return new Set(I.options.flatMap((Y)=>Array.from(Y._zod.values)));return}),e0($._zod,"pattern",()=>{if(I.options.every((Y)=>Y._zod.pattern)){let Y=I.options.map((J)=>J._zod.pattern);return new RegExp(`^(${Y.map((J)=>pJ(J.source)).join("|")})$`)}return});let U=I.options.length===1?I.options[0]._zod.run:null;$._zod.parse=(Y,J)=>{if(U)return U(Y,J);let Q=!1,K=[];for(let q of I.options){let H=q._zod.run({value:Y.value,issues:[]},J);if(H instanceof Promise)K.push(H),Q=!0;else{if(H.issues.length===0)return H;K.push(H)}}if(!Q)return Ik(K,Y,$,J);return Promise.all(K).then((q)=>{return Ik(q,Y,$,J)})}});function Uk($,I,U,Y){let J=$.filter((Q)=>Q.issues.length===0);if(J.length===1)return I.value=J[0].value,I;if(J.length===0)I.issues.push({code:"invalid_union",input:I.value,inst:U,errors:$.map((Q)=>Q.issues.map((K)=>E6(K,Y,z4())))});else I.issues.push({code:"invalid_union",input:I.value,inst:U,errors:[],inclusive:!1});return I}var lO=o("$ZodXor",($,I)=>{YQ.init($,I),I.inclusive=!1;let U=I.options.length===1?I.options[0]._zod.run:null;$._zod.parse=(Y,J)=>{if(U)return U(Y,J);let Q=!1,K=[];for(let q of I.options){let H=q._zod.run({value:Y.value,issues:[]},J);if(H instanceof Promise)K.push(H),Q=!0;else K.push(H)}if(!Q)return Uk(K,Y,$,J);return Promise.all(K).then((q)=>{return Uk(q,Y,$,J)})}}),oO=o("$ZodDiscriminatedUnion",($,I)=>{I.inclusive=!1,YQ.init($,I);let U=$._zod.parse;e0($._zod,"propValues",()=>{let J={};for(let Q of I.options){let K=Q._zod.propValues;if(!K||Object.keys(K).length===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${I.options.indexOf(Q)}"`);for(let[q,H]of Object.entries(K)){if(!J[q])J[q]=new Set;for(let G of H)J[q].add(G)}}return J});let Y=MI(()=>{let J=I.options,Q=new Map;for(let K of J){let q=K._zod.propValues?.[I.discriminator];if(!q||q.size===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${I.options.indexOf(K)}"`);for(let H of q){if(Q.has(H))throw Error(`Duplicatediscriminatorvalue"${String(H)}"`);Q.set(H,K)}}return Q});$._zod.parse=(J,Q)=>{let K=J.value;if(!j7(K))return J.issues.push({code:"invalid_type",expected:"object",input:K,inst:$}),J;let q=Y.value.get(K?.[I.discriminator]);if(q)return q._zod.run(J,Q);if(I.unionFallback||Q.direction==="backward")return U(J,Q);return J.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:I.discriminator,options:Array.from(Y.value.keys()),input:K,path:[I.discriminator],inst:$}),J}}),rO=o("$ZodIntersection",($,I)=>{n0.init($,I),$._zod.parse=(U,Y)=>{let J=U.value,Q=I.left._zod.run({value:J,issues:[]},Y),K=I.right._zod.run({value:J,issues:[]},Y);if(Q instanceof Promise||K instanceof Promise)return Promise.all([Q,K]).then(([H,G])=>{return Yk(U,H,G)});return Yk(U,Q,K)}});function HO($,I){if($===I)return{valid:!0,data:$};if($ instanceof Date&&I instanceof Date&&+$===+I)return{valid:!0,data:$};if($9($)&&$9(I)){let U=Object.keys(I),Y=Object.keys($).filter((Q)=>U.indexOf(Q)!==-1),J={...$,...I};for(let Q of Y){let K=HO($[Q],I[Q]);if(!K.valid)return{valid:!1,mergeErrorPath:[Q,...K.mergeErrorPath]};J[Q]=K.data}return{valid:!0,data:J}}if(Array.isArray($)&&Array.isArray(I)){if($.length!==I.length)return{valid:!1,mergeErrorPath:[]};let U=[];for(let Y=0;Y<$.length;Y++){let J=$[Y],Q=I[Y],K=HO(J,Q);if(!K.valid)return{valid:!1,mergeErrorPath:[Y,...K.mergeErrorPath]};U.push(K.data)}return{valid:!0,data:U}}return{valid:!1,mergeErrorPath:[]}}function Yk($,I,U){let Y=new Map,J;for(let q of I.issues)if(q.code==="unrecognized_keys"){J??(J=q);for(let H of q.keys){if(!Y.has(H))Y.set(H,{});Y.get(H).l=!0}}else $.issues.push(q);for(let q of U.issues)if(q.code==="unrecognized_keys")for(let H of q.keys){if(!Y.has(H))Y.set(H,{});Y.get(H).r=!0}else $.issues.push(q);let Q=[...Y].filter(([,q])=>q.l&&q.r).map(([q])=>q);if(Q.length&&J)$.issues.push({...J,keys:Q});if(I9($))return $;let K=HO(I.value,U.value);if(!K.valid)throw Error(`Unmergableintersection.Errorpath:${JSON.stringify(K.mergeErrorPath)}`);return $.value=K.data,$}var LG=o("$ZodTuple",($,I)=>{n0.
Line truncated
`)}V.write("payload.value = newResult;"),V.write("return payload;");let P=V.compile();return(T,A)=>P(W,T,A)},Y,J=y7,Q=!S7.jitless,K=Q&&EO.value,H=I.catchall,G;$._zod.parse=(W,V)=>{G??(G=z.value);let X=W.value;if(!J(X))return W.issues.push({expected:"object",code:"invalid_type",input:X,inst:$}),W;if(Q&&K&&V?.async===!1&&V.jitless!==!0){if(!Y)Y=U(I.shape);if(W=Y(W,V),!H)return W;return sk([],X,W,V,G,$)}return q(W,V)}});function yk($,I,q,z){for(let Y of $)if(Y.issues.length===0)return I.value=Y.value,I;let U=$.filter((Y)=>!Q9(Y));if(U.length===1)return I.value=U[0].value,U[0];return I.issues.push({code:"invalid_union",input:I.value,inst:q,errors:$.map((Y)=>Y.issues.map((J)=>B6(J,z,L4())))}),I}var ZY=o("$ZodUnion",($,I)=>{p0.init($,I),$1($._zod,"optin",()=>I.options.some((z)=>z._zod.optin==="optional")?"optional":void 0),$1($._zod,"optout",()=>I.options.some((z)=>z._zod.optout==="optional")?"optional":void 0),$1($._zod,"values",()=>{if(I.options.every((z)=>z._zod.values))return new Set(I.options.flatMap((z)=>Array.from(z._zod.values)));return}),$1($._zod,"pattern",()=>{if(I.options.every((z)=>z._zod.pattern)){let z=I.options.map((U)=>U._zod.pattern);return new RegExp(`^(${z.map((U)=>$Y(U.source)).join("|")})$`)}return});let q=I.options.length===1?I.options[0]._zod.run:null;$._zod.parse=(z,U)=>{if(q)return q(z,U);let Y=!1,J=[];for(let Q of I.options){let w=Q._zod.run({value:z.value,issues:[]},U);if(w instanceof Promise)J.push(w),Y=!0;else{if(w.issues.length===0)return w;J.push(w)}}if(!Y)return yk(J,z,$,U);return Promise.all(J).then((Q)=>{return yk(Q,z,$,U)})}});function xk($,I,q,z){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:q,errors:$.map((Y)=>Y.issues.map((J)=>B6(J,z,L4())))});else I.issues.push({code:"invalid_union",input:I.value,inst:q,errors:[],inclusive:!1});return I}var VN=o("$ZodXor",($,I)=>{ZY.init($,I),I.inclusive=!1;let q=I.options.length===1?I.options[0]._zod.run:null;$._zod.parse=(z,U)=>{if(q)return q(z,U);let Y=!1,J=[];for(let Q of I.options){let w=Q._zod.run({value:z.value,issues:[]},U);if(w instanceof Promise)J.push(w),Y=!0;else J.push(w)}if(!Y)return xk(J,z,$,U);return Promise.all(J).then((Q)=>{return xk(Q,z,$,U)})}}),ZN=o("$ZodDiscriminatedUnion",($,I)=>{I.inclusive=!1,ZY.init($,I);let q=$._zod.parse;$1($._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,w]of Object.entries(J)){if(!U[Q])U[Q]=new Set;for(let K of w)U[Q].add(K)}}return U});let z=vI(()=>{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 w of Q){if(Y.has(w))throw Error(`Duplicatediscriminatorvalue"${String(w)}"`);Y.set(w,J)}}return Y});$._zod.parse=(U,Y)=>{let J=U.value;if(!y7(J))return U.issues.push({code:"invalid_type",expected:"object",input:J,inst:$}),U;let Q=z.value.get(J?.[I.discriminator]);if(Q)return Q._zod.run(U,Y);if(I.unionFallback||Y.direction==="backward")return q(U,Y);return U.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:I.discriminator,options:Array.from(z.value.keys()),input:J,path:[I.discriminator],inst:$}),U}}),XN=o("$ZodIntersection",($,I)=>{p0.init($,I),$._zod.parse=(q,z)=>{let U=q.value,Y=I.left._zod.run({value:U,issues:[]},z),J=I.right._zod.run({value:U,issues:[]},z);if(Y instanceof Promise||J instanceof Promise)return Promise.all([Y,J]).then(([w,K])=>{return kk(q,w,K)});return kk(q,Y,J)}});function gF($,I){if($===I)return{valid:!0,data:$};if($ instanceof Date&&I instanceof Date&&+$===+I)return{valid:!0,data:$};if(J9($)&&J9(I)){let q=Object.keys(I),z=Object.keys($).filter((Y)=>q.indexOf(Y)!==-1),U={...$,...I};for(let Y of z){let J=gF($[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 q=[];for(let z=0;z<$.length;z++){let U=$[z],Y=I[z],J=gF(U,Y);if(!J.valid)return{valid:!1,mergeErrorPath:[z,...J.mergeErrorPath]};q.push(J.data)}return{valid:!0,data:q}}return{valid:!1,mergeErrorPath:[]}}function kk($,I,q){let z=new Map,U;for(let Q of I.issues)if(Q.code==="unrecognized_keys"){U??(U=Q);for(let w of Q.keys){if(!z.has(w))z.set(w,{});z.get(w).l=!0}}else $.issues.push(Q);for(let Q of q.issues)if(Q.code==="unrecognized_keys")for(let w of Q.keys){if(!z.has(w))z.set(w,{});z.get(w).r=!0}else $.issues.push(Q);let Y=[...z].filter(([,Q])=>Q.l&&Q.r).map(([Q])=>Q);if(Y.length&&U)$.issues.push({...U,keys:Y});if(Q9($))return $;let J=gF(I.value,q.value);if(!J.valid)throw Error(`Unmergableintersection.Errorpath:${JSON.stringify(J.mergeErrorPath)}`);return $.value=J.data,$}var vK=o("$ZodTuple",($,I)=>{p0.
Line truncated
Setthe\`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(letKof$.seen.entries()){letq=K[1];if(I===K[0]){Q(K);continue}if($.external){letG=$.external.registry.get(K[0])?.id;if(I!==K[0]&&G){Q(K);continue}}if($.metadataRegistry.get(K[0])?.id){Q(K);continue}if(q.cycle){Q(K);continue}if(q.count>1){if($.reused==="ref"){Q(K);continue}}}}functionK9($,I){letU=$.seen.get(I);if(!U)throwError("Unprocessed schema. This is a bug in Zod.");letY=(q)=>{letH=$.seen.get(q);if(H.ref===null)return;letG=H.def??H.schema,W={...G},w=H.ref;if(H.ref=null,w){Y(w);letZ=$.seen.get(w),X=Z.schema;if(X.$ref&&($.target==="draft-07"||$.target==="draft-04"||$.target==="openapi-3.0"))G.allOf=G.allOf??[],G.allOf.push(X);elseObject.assign(G,X);if(Object.assign(G,W),q._zod.parent===w)for(letDinG){if(D==="$ref"||D==="allOf")continue;if(!(DinW))deleteG[D]}if(X.$ref&&Z.def)for(letDinG){if(D==="$ref"||D==="allOf")continue;if(DinZ.def&&JSON.stringify(G[D])===JSON.stringify(Z.def[D]))deleteG[D]}}letV=q._zod.parent;if(V&&V!==w){Y(V);letZ=$.seen.get(V);if(Z?.schema.$ref){if(G.$ref=Z.schema.$ref,Z.def)for(letXinG){if(X==="$ref"||X==="allOf")continue;if(XinZ.def&&JSON.stringify(G[X])===JSON.stringify(Z.def[X]))deleteG[X]}}}$.override({zodSchema:q,jsonSchema:G,path:H.path??[]})};for(letqof[...$.seen.entries()].reverse())Y(q[0]);letJ={};if($.target==="draft-2020-12")J.$schema="https://json-schema.org/draft/2020-12/schema";elseif($.target==="draft-07")J.$schema="http://json-schema.org/draft-07/schema#";elseif($.target==="draft-04")J.$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");J.$id=$.external.uri(q)}Object.assign(J,U.def??U.schema);letQ=$.metadataRegistry.get(I)?.id;if(Q!==void0&&J.id===Q)deleteJ.id;letK=$.external?.defs??{};for(letqof$.seen.entries()){letH=q[1];if(H.def&&H.defId){if(H.def.id===H.defId)deleteH.def.id;K[H.defId]=H.def}}if($.external);elseif(Object.keys(K).length>0)if($.target==="draft-2020-12")J.$defs=K;elseJ.definitions=K;try{letq=JSON.parse(JSON.stringify(J));returnObject.defineProperty(q,"~standard",{value:{...I["~standard"],jsonSchema:{input:pI(I,"input",$.processors),output:pI(I,"output",$.processors)}},enumerable:!1,writable:!1}),q}catch(q){throwError("Error converting schema to JSON.")}}functionv6($,I){letU=I??{seen:newSet};if(U.seen.has($))return!1;U.seen.add($);letY=$._zod.def;if(Y.type==="transform")return!0;if(Y.type==="array")returnv6(Y.element,U);if(Y.type==="set")returnv6(Y.valueType,U);if(Y.type==="lazy")returnv6(Y.getter(),U);if(Y.type==="promise"||Y.type==="optional"||Y.type==="nonoptional"||Y.type==="nullable"||Y.type==="readonly"||Y.type==="default"||Y.type==="prefault")returnv6(Y.innerType,U);if(Y.type==="intersection")returnv6(Y.left,U)||v6(Y.right,U);if(Y.type==="record"||Y.type==="map")returnv6(Y.keyType,U)||v6(Y.valueType,U);if(Y.type==="pipe"){if($._zod.traits.has("$ZodCodec"))return!0;returnv6(Y.in,U)||v6(Y.out,U)}if(Y.type==="object"){for(letJinY.shape)if(v6(Y.shape[J],U))return!0;return!1}if(Y.type==="union"){for(letJofY.options)if(v6(J,U))return!0;return!1}if(Y.type==="tuple"){for(letJofY.items)if(v6(J,U))return!0;if(Y.rest&&v6(Y.rest,U))return!0;return!1}return!1}varIA=($,I={})=>(U)=>{letY=J9({...U,processors:I});returnS1($,Y),Q9(Y,$),K9(Y,$)},pI=($,I,U={})=>(Y)=>{let{libraryOptions:J,target:Q}=Y??{},K=J9({...J??{},target:Q,io:I,processors:U});returnS1($,K),Q9(K,$),K9(K,$)};varoF0={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},UA=($,I,U,Y)=>{letJ=U;J.type="string";let{minimum:Q,maximum:K,format:q,patterns:H,contentEncoding:G}=$._zod.bag;if(typeofQ==="number")J.minLength=Q;if(typeofK==="number")J.maxLength=K;if(q){if(J.format=oF0[q]??q,J.format==="")deleteJ.format;if(q==="time")deleteJ.format}if(G)J.contentEncoding=G;if(H&&H.size>0){letW=[...H];if(W.length===1)J.pattern=W[0].source;elseif(W.length>1)J.allOf=[...W.map((w)=>({...I.target==="draft-07"||I.target==="draft-04"||I.target==="openapi-3.0"?{type:"string"}:{},pattern:w.source}))]}},YA=($,I,U,Y)=>{letJ=U,{minimum:Q,maximum:K,format:q,multipleOf:H,exclusiveMaximum:G,exclusiveMinimum:W}=$._zod.bag;if(typeofq==="string"&&q.includes("int"))J.type="integer";elseJ.type="number";letw=typeofW==="number"&&W>=(Q??Number.NEGATIVE_INFINITY),V=typeofG==="number"&&G<=(K??Number.POSITIVE_INFINITY),Z=I.target==="draft-04"||I.target==="openapi-3.0";if(w)if(Z)J.minimum=W,J.exclusiveMinimum=!0;elseJ.exclusiveMinimum=W;elseif(typeofQ==="number")J.minimum=Q;if(V)if(Z)J.maximum=G,J.exclusiveMaximum=!0;elseJ.exclusiveMaximum=G;elseif(typeofK==="number")J.maximum=K;if(typeofH==="number")J.multipleOf=H},JA=($,I,U,Y)=>{U.type="boolean"},QA=($,I,U,Y)=>{if(I.unrepresentable==="throw")throwError("BigInt cannot be represented in JSON Schema")},KA=($,I,U,Y)=>{if(I.unrepresentable==Line truncated
`}class OE{constructor($=lc.stdin,I=lc.stdout){this._stdin=$,this._stdout=I,this._readBuffer=new FE,this._started=!1,this._ondata=(U)=>{this._readBuffer.append(U),this.processReadBuffer()},this._onerror=(U)=>{this.onerror?.(U)}}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 U=mc($);if(this._stdout.write(U))I();else this._stdout.once("drain",I)})}}import{dirname as tu,join as FW1}from"node:path";import{fileURLToPath as OW1}from"node:url";class G5 extends Error{name="KyError";get isKyError(){return!0}}class H$ extends G5{name="HTTPError";response;request;options;data;constructor($,I,U){let Y=$.status||$.status===0?$.status:"",J=$.statusText??"",Q=`${Y}${J}`.trim(),K=Q?`statuscode${Q}`:"an unknown error";super(`Requestfailedwith${K}:${I.method}${I.url}`);this.response=$,this.request=I,this.options=U}}class q2 extends G5{name="NetworkError";request;constructor($,I){super(`Requestfailedduetoanetworkerror:${$.method}${$.url}`,I);this.request=$}}class H2 extends Error{name="NonError";value;constructor($){let I="Non-error value was thrown";try{if(typeof $==="string")I=$;else if($&&typeof $==="object"&&"message"in $&&typeof $.message==="string")I=$.message}catch{}super(I);this.value=$}}class LU extends G5{name="ForceRetryError";customDelay;code;customRequest;constructor($){let I=$?.cause?$.cause instanceof Error?$.cause:new H2($.cause):void 0;super($?.code?`Forcedretry:${$.code}`:"Forced retry",I?{cause:I}:void 0);this.customDelay=$?.delay,this.code=$?.code,this.customRequest=$?.request}}class NE extends Error{name="SchemaValidationError";issues;constructor($){super("Response schema validation failed");this.issues=$}}class a$ extends G5{name="TimeoutError";request;constructor($){super(`Requesttimedout:${$.method}${$.url}`);this.request=$}}var ME=(()=>{let $=!1,I=!1,U=typeof globalThis.ReadableStream==="function",Y=typeof globalThis.Request==="function";if(U&&Y)try{I=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return $=!0,"half"}}).headers.has("Content-Type")}catch(J){if(J instanceof Error&&J.message==="unsupported BodyInit type")return!1;throw J}return $&&!I})(),oc=typeof globalThis.AbortController==="function",Aw=typeof globalThis.AbortSignal==="function"&&typeof globalThis.AbortSignal.any==="function",rc=typeof globalThis.ReadableStream==="function",tc=typeof globalThis.FormData==="function",Pw=["get","post","put","patch","head","delete"],Dj0=()=>{return};Dj0();var ac={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},DU=2147483647,sc=40,Tw=Symbol("stop");class Ew{options;constructor($){this.options=$}}var ec=($)=>new Ew($),$d={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,baseUrl:!0,prefix:!0,retry:!0,timeout:!0,totalTimeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},Id={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0};var Bw=new TextEncoder,Fj0=($)=>{if(!$)return 0;if($ instanceof FormData){let I=0;for(let[U,Y]of $)I+=sc,I+=Bw.encode(`Content-Disposition:form-data;name="${U}"`).byteLength,I+=typeof Y==="string"?Bw.encode(Y).byteLength:Y.size;return I}if($ instanceof Blob)return $.size;if($ instanceof ArrayBuffer||ArrayBuffer.isView($))return $.byteLength;if(typeof $==="string")return Bw.encode($).byteLength;if($ instanceof URLSearchParams)return Bw.encode($.toString()).byteLength;return 0},Ud=($,I,U)=>{let Y,J=0;return $.pipeThrough(new TransformStream({transform(Q,K){if(K.enqueue(Q),Y){J+=Y.byteLength;let q=I===0?0:J/I;if(q>=1)q=1-Number.EPSILON;U?.({percent:q,totalBytes:Math.max(I,J),transferredBytes:J},Y)}Y=Q},flush(){if(Y)J+=Y.byteLength,U?.({percent:1,totalBytes:Math.max(I,J),transferredBytes:J},Y)}}))},Yd=($,I)=>{if(!$.body)return $;let U={status:$.status,statusText:$.statusText,headers:$.headers};if($.status===204)return new Response(null,U);let Y=Math.max(0,Number($.headers.get("content-length"))||0);return new Response(Ud($.body,Y,I),U)},Jd=($,I,U)=>{if(!$.body)return $;let Y=Fj0(U??$.body);return new Request($,{duplex:"half",body:Ud($.body,Y,I)})};var F8=($)=>$!==null&&typeof $==="object";var Oj0=Symbol("replaceOption"),AE=($)=>F8($)&&$[Oj0]===!0?{isReplace:!0,value:$.value}:{isReplace:!1,value:$};var W2=(...$)=>{for(let I of $)if(
Line truncated
`,{mode:384}),I}function VK1($){let I=sw0();for(let U of I){if(!D$(U))continue;for(let Y of oL(U).filter((J)=>J.endsWith(".json")).filter((J)=>!J.startsWith("example."))){let J=m8(U,Y);try{let Q=tL(J,"utf-8"),K=JSON.parse(Q);if(K&&typeof K==="object"&&K.id===$)return J}catch{}}}return}function O7($,I){let U=VK1($);if(!U)throw Error(`Enterpriseconfignotfound:${$}`);let J={...JSON.parse(tL(U,"utf-8")),...I};for(let K of Object.keys(I))if(I[K]===void 0)delete J[K];let Q=Xh.parse(J);return mw0(U,`${JSON.stringify(Q,null,2)}
`,"utf-8"),Q}function NJ($,I,U=[]){let Y=I.corpId?.trim()||void 0,J=I.stateful?I.defaultCorpId?.trim()||void 0:void 0,Q=Y??J;if(Q){let q=$.find((H)=>H.id===Q);if(q)return q;throw Error(`Noenterpriseconfigfoundfor${Q}`)}if(!I.stateful)throw Error("Stateless mode is enabled. Every enterprise command requires --corp <corpId>. Use `seal-homeconfigmodestateful` to enable a default enterprise.");let K=$[0];if(K)return K;throw Error("No enterprise config found. Add a non-example JSON file under one of: "+(U.length?U.join(", "):"the configured enterprise directories"))}import{readFileSync as _H1}from"node:fs";import{randomBytes as SH1}from"node:crypto";var IV0=300000,ew0=new Map;function ZK1($,I){return $.map((U)=>U.trim()).filter(Boolean).map((U)=>I?U:U.toLowerCase())}function zK1($,I){return I?$:$.toLowerCase()}function XK1($,I,U,Y){let J=zK1($,Y),Q=I.filter((K)=>J.includes(K));if(U==="all"&&Q.length!==I.length)return[];return Q}function LK1($){if(typeof $==="string")return $.split(/\r?\n/);return JSON.stringify($,null,2).split(/\r?\n/)}function DK1($,I){if(I.fields&&!I.fields.has($.field))return[];let U=LK1($.value),Y=[];return U.forEach((J,Q)=>{let K=XK1(J,I.keywords,I.matchMode,I.caseSensitive);if(K.length===0)return;let q=Math.max(0,Q-I.contextLines),H=Math.min(U.length,Q+I.contextLines+1),G={area:$.area,entityType:$.entityType,entityId:$.entityId,title:$.title,field:$.field,lineNumber:Q+1,matchedKeywords:K,matchedText:sL(J,I.maxChars),context:{before:I.snippetOnly?[]:U.slice(q,Q).map((W)=>sL(W,I.maxChars)),line:sL(J,I.maxChars),after:I.snippetOnly?[]:U.slice(Q+1,H).map((W)=>sL(W,I.maxChars))},metadata:$.metadata};if(I.snippetOnly)G.context={before:[],line:G.context.line,after:[]};Y.push(G)}),Y}function sL($,I){if(!I||$.length<=I)return $;return`${$.slice(0,Math.max(0,I))}...`}function FK1($){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 $V0($){return $.rules.flatMap((I,U)=>{let Y=`${$.id}:${I.description.slice(0,32)}`,J={versionId:$.id,versionNumber:$.versionNumber,versionName:$.versionName,publishedByName:$.publishedByName,publishedAt:$.publishedAt,scope:I.scope,strictness:I.strictness,code:"code"in I?I.code:void 0,index:U};return[{area:"rules",entityType:"rule",entityId:Y,title:`${$.versionName}/${I.scope}`,field:"history.description",value:I.description,metadata:J},{area:"rules",entityType:"rule",entityId:Y,title:`${$.versionName}/${I.scope}`,field:"history.scope",value:I.scope,metadata:J}]})}function OK1($){return[{area:"documents",entityType:"document",entityId:$.id,title:$.title,field:"title",value:$.title,metadata:{status:$.status,scenarios:$.scenarios,tags:$.tags}},{area:"documents",entityType:"document",entityId:$.id,title:$.title,field:"purpose",value:$.purpose,metadata:{status:$.status,scenarios:$.scenarios,tags:$.tags}},{area:"documents",entityType:"document",entityId:$.id,title:$.title,field:"content",value:$.content,metadata:{status:$.status,scenarios:$.scenarios,tags:$.tags}}]}function NK1($){let I=[];if($.decisionPreferences)for(let[U,Y]of Object.entries($.decisionPreferences))I.push({area:"preferences",entityType:"preference",field:`decisionPreferences.${U}`,value:Y,metadata:{integrationSystem:$.integrationSystem}});return $.integrations.forEach((U,Y)=>{I.push({area:"preferences",entityType:"integration",title:U.outboundName,field:`integrations[${Y}]`,value:U,metadata:{type:U.type,outboundName:U.outboundName,mode:U.mode,corporationId:U.corporationId}})}),I}async function MK1($,I,U){let Y=U.ruleVersionScope??"current",J=[I.id,`ruleVersionScope=${Y}`,`ruleVersionId=${U.ruleVersionId??""}`,`ruleVersionNumber=${U.ruleVersionNumber??""}`,`latestRuleVersion=${U.latestRuleVersion??!1}`,`documentLimit=${U.documentLimit??100}`].join("|"),Q=ew0.get(J);if(!U.refresh&&Q&&Date.now()<Q.expiresAt)return Q;let[K,q,H]=await Promise.all([AK1($,{scope:Y,versionId:U.ruleVersionId,versionNumber:U.ruleVersionNumber,latest:U.latestRuleVersion}),O9($,{limit:U.documentLimit??100}),M1($,I.seal.endpoints.approvalStylePreferences)]),G=Date.now(),W={entries:[...K,...q.articles.flatMap(OK1),...NK1(H)],fetchedAt:G,expiresAt:G+IV0};return ew0.set(J,W),W}async function AK1($,I){if(I.scope==="current")return(await _6($)).rules.flatMap(FK1);if(I.scope==="version"){let Y=await PK1($,I);return $V0(Y)}return(await R$($)).flatMap($V0)}async function PK1($,I){if(I.versionId)return P2($,I.versionId);let U=await R$($),Y=I.versionNumber?U.find((J)=>J.versionNumber===I.versionNumber):U[0];if(!Y)throw Error(I.versionNumber?`Ruleversionnotfound:${I.versionNumber}`:"No rule versions found");return Y}async function UV0($,I,U){let Y=U.matchMode??"any",J=U.caseSensitive??!1,Q=U.contextLines??3,K=new Set(U.areas??["rules","documents","preferences"]),q=U
Line truncated
`)}return{warnings:[],results:K}}function WI($){return{fileBuffer:BH1($),fileName:$.split(/[\\\/]/).pop()??"material-pack.zip"}}import{existsSync as CH1}from"node:fs";async function ND($,I,U={}){let J=F4().stateful?"stateful":"stateless",Q="ok",K,q,H;try{let A=await v$($);H={id:A.user.id,name:A.user.name,isAdmin:A.user.isAdmin},q={id:A.tenant.id,name:A.tenant.name,tenantSlug:A.tenant.tenantSlug,corporationName:A.tenant.hoseCorpConfig?.corporationName}}catch(A){Q="error",K=A instanceof Error?A.message:String(A)}let G=[];if(Q==="ok")try{G=await N9($,I.seal.endpoints.approvalStylePreferences)}catch(A){Q="error",K=`读取Webhook配置失败:${AinstanceofError?A.message:String(A)}`}let W=G.length===1,w=G.map((A)=>({id:A.id,name:A.name,mode:A.mode,incomingDocumentWebhookUrl:A.incomingDocumentWebhook.url,outgoingResultWebhookUrl:A.outgoingResultWebhook,autoApprovalRate:A.autoApprovalRate,...W?{isDefault:!0}:{}})),V=W?{id:G[0].id,name:G[0].name,mode:G[0].mode}:null,Z=U.webhook?M9(G,U.webhook):W?G[0]:void 0,X;if(U.filePath)if(!CH1(U.filePath))X={valid:!1,filePath:U.filePath,fileName:U.filePath.split(/[\\/]/).pop()??U.filePath,documentCount:0,errors:[`文件不存在:${U.filePath}`]};else try{let A=WI(U.filePath),R=await GI(A.fileBuffer,A.fileName,Z?.materialPackFilePolicy);X={valid:!0,filePath:U.filePath,fileName:A.fileName,documentCount:R.documents.length,warnings:R.warnings}}catch(A){X={valid:!1,filePath:U.filePath,fileName:U.filePath.split(/[\\/]/).pop()??U.filePath,documentCount:0,errors:[A instanceof Error?A.message:String(A)]}}let L=X?X.valid:!0,D=Q==="ok"&&w.length>0&&L,O=J==="stateful"?"":`--corp${I.id}`,E="",T="";if(Q!=="ok")T=`凭证鉴权异常:${K}`,E=`seal-useauthdiagnose${O}`;else if(w.length===0)T="当前企业尚未配置任何 Webhook 集成通道",E=`seal-usewebhookadd--name"默认入站通道"--result-url"https://your-domain.com/callback"${O}`;else if(X&&!X.valid)T=`材料包预检失败:${X.errors?.join("; ")}`,E=`seal-usewebhookmaterial-packpreview${X.filePath}${O}`;else{T=W?"所有通道正常,已自动锁定唯一 Webhook 通道,等待载入":`所有通道正常,检测到${w.length}个Webhook通道,等待载入`;let A=X?.filePath??"<材料包.zip>",R=W?"":`--webhook${V?V.id:"<webhookIdOrName>"}`;E=`seal-usewebhookmaterial-packpush${A}${R}${O}`}return{ready:D,corp:{id:I.id,name:I.name,sourceType:I.source.type,tenant:q,user:H},stateMode:J,authStatus:Q,authError:K,activeWebhooks:w,defaultWebhook:V,materialPack:X,statusMessage:T,nextAction:E}}var DH=[{name:"seal_whoami",description:"查询当前 Seal 用户身份及租户信息",parameters:z.object({}),handler:async($)=>v$($)},{name:"seal_session_get",description:"查询当前 Seal Bearer session、用户和过期时间",parameters:z.object({}),handler:async($)=>Am($)},{name:"seal_delegation_list",description:"查询当前 Seal 租户下的授权链接 (Delegation) 列表",parameters:z.object({}),handler:async($)=>dm($)},{name:"seal_delegation_create",description:"创建新的 Seal 授权链接 (Delegation)",parameters:z.object({note:z.string().optional().describe("授权链接的备注或说明信息")}),handler:async($,I)=>PU($,I)},{name:"seal_delegation_revoke",description:"撤销/废除指定的 Seal 授权链接 (Delegation)",parameters:z.object({tokenId:z.string().describe("授权链接 ID (delegation record ID)")}),handler:async($,I)=>mm($,I.tokenId)},{name:"seal_user_create",description:"创建本地 Seal 用户,生成并返回初始随机密码",parameters:z.object({name:z.string().describe("用户姓名"),phone:z.string().describe("手机号码 (例如 13300001111 或 +8613300001111)"),permissions:z.array(z.string()).optional().describe("权限列表,默认为 []"),departmentIds:z.array(z.string()).optional().describe("关联部门 ID 数组")}),handler:async($,I)=>lm($,I)},{name:"seal_user_reset_password",description:"重置指定 Seal 用户的默认/随机密码,并返回生成的新密码",parameters:z.object({userId:z.string().describe("用户 ID (_id)")}),handler:async($,I)=>sE($,I.userId)},{name:"seal_user_get",description:"获取指定 Seal 用户的详细信息",parameters:z.object({userId:z.string().describe("用户 ID (_id)")}),handler:async($,I)=>pw($,I.userId)},{name:"seal_user_search",description:"按姓名、手机号或邮箱搜索 Seal 成员用户列表",parameters:z.object({keyword:z.string().optional().describe("搜索关键词(姓名、手机号、邮箱等),不传或传空字符串可列出租户成员")}),handler:async($,I)=>cw($,I.keyword??"")},{name:"seal_user_delete",description:"删除指定 Seal 本地用户",parameters:z.object({userId:z.string().describe("用户 ID (_id)")}),handler:async($,I)=>Jl($,I.userId)},{name:"seal_user_activate",description:"启用/激活已离职的 Seal 用户账号",parameters:z.object({userId:z.string().describe("用户 ID (_id)")}),handler:async($,I)=>eE($,I.userId)},{name:"seal_user_delegation_create",description:"为指定 S
Line truncated
`)}function GG1($){let I=[];if(I.push(`seal-use${$.area}-${$.title}`),$.description)I.push($.description);I.push(""),I.push("Usage:");for(let U of $.commands)for(let Y of U.usage)I.push(`${Y}`);if($.commands.some((U)=>U.name))I.push(""),I.push(`Run'seal-use ${$.area} <command> --help'fordetailsonaspecificcommand.`);return I.join(`
`)}function Iz0(){let $=[];$.push("seal-use CLI"),$.push(""),$.push("Usage:"),$.push(" seal-use version");for(let I of Uz0)for(let U of I.commands)for(let Y of U.usage)$.push(`${Y}`);return $.push(""),$.push("Run 'seal-use <command> --help' for details on a specific command."),$.join(`
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){letK=$.external.registry.get(J[0])?.id;if(I!==J[0]&&K){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}}}}functionW9($,I){letq=$.seen.get(I);if(!q)throwError("Unprocessed schema. This is a bug in Zod.");letz=(Q)=>{letw=$.seen.get(Q);if(w.ref===null)return;letK=w.def??w.schema,H={...K},G=w.ref;if(w.ref=null,G){z(G);letV=$.seen.get(G),X=V.schema;if(X.$ref&&($.target==="draft-07"||$.target==="draft-04"||$.target==="openapi-3.0"))K.allOf=K.allOf??[],K.allOf.push(X);elseObject.assign(K,X);if(Object.assign(K,H),Q._zod.parent===G)for(letDinK){if(D==="$ref"||D==="allOf")continue;if(!(DinH))deleteK[D]}if(X.$ref&&V.def)for(letDinK){if(D==="$ref"||D==="allOf")continue;if(DinV.def&&JSON.stringify(K[D])===JSON.stringify(V.def[D]))deleteK[D]}}letW=Q._zod.parent;if(W&&W!==G){z(W);letV=$.seen.get(W);if(V?.schema.$ref){if(K.$ref=V.schema.$ref,V.def)for(letXinK){if(X==="$ref"||X==="allOf")continue;if(XinV.def&&JSON.stringify(K[X])===JSON.stringify(V.def[X]))deleteK[X]}}}$.override({zodSchema:Q,jsonSchema:K,path:w.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(I)?.id;if(!Q)throwError("Schema is missing an `id` property");U.$id=$.external.uri(Q)}Object.assign(U,q.def??q.schema);letY=$.metadataRegistry.get(I)?.id;if(Y!==void0&&U.id===Y)deleteU.id;letJ=$.external?.defs??{};for(letQof$.seen.entries()){letw=Q[1];if(w.def&&w.defId){if(w.def.id===w.defId)deletew.def.id;J[w.defId]=w.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:aI(I,"input",$.processors),output:aI(I,"output",$.processors)}},enumerable:!1,writable:!1}),Q}catch(Q){throwError("Error converting schema to JSON.")}}functiong6($,I){letq=I??{seen:newSet};if(q.seen.has($))return!1;q.seen.add($);letz=$._zod.def;if(z.type==="transform")return!0;if(z.type==="array")returng6(z.element,q);if(z.type==="set")returng6(z.valueType,q);if(z.type==="lazy")returng6(z.getter(),q);if(z.type==="promise"||z.type==="optional"||z.type==="nonoptional"||z.type==="nullable"||z.type==="readonly"||z.type==="default"||z.type==="prefault")returng6(z.innerType,q);if(z.type==="intersection")returng6(z.left,q)||g6(z.right,q);if(z.type==="record"||z.type==="map")returng6(z.keyType,q)||g6(z.valueType,q);if(z.type==="pipe"){if($._zod.traits.has("$ZodCodec"))return!0;returng6(z.in,q)||g6(z.out,q)}if(z.type==="object"){for(letUinz.shape)if(g6(z.shape[U],q))return!0;return!1}if(z.type==="union"){for(letUofz.options)if(g6(U,q))return!0;return!1}if(z.type==="tuple"){for(letUofz.items)if(g6(U,q))return!0;if(z.rest&&g6(z.rest,q))return!0;return!1}return!1}varMA=($,I={})=>(q)=>{letz=H9({...q,processors:I});returnh1($,z),G9(z,$),W9(z,$)},aI=($,I,q={})=>(z)=>{let{libraryOptions:U,target:Y}=z??{},J=H9({...U??{},target:Y,io:I,processors:q});returnh1($,J),G9(J,$),W9(J,$)};varSN0={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},AA=($,I,q,z)=>{letU=q;U.type="string";let{minimum:Y,maximum:J,format:Q,patterns:w,contentEncoding:K}=$._zod.bag;if(typeofY==="number")U.minLength=Y;if(typeofJ==="number")U.maxLength=J;if(Q){if(U.format=SN0[Q]??Q,U.format==="")deleteU.format;if(Q==="time")deleteU.format}if(K)U.contentEncoding=K;if(w&&w.size>0){letH=[...w];if(H.length===1)U.pattern=H[0].source;elseif(H.length>1)U.allOf=[...H.map((G)=>({...I.target==="draft-07"||I.target==="draft-04"||I.target==="openapi-3.0"?{type:"string"}:{},pattern:G.source}))]}},PA=($,I,q,z)=>{letU=q,{minimum:Y,maximum:J,format:Q,multipleOf:w,exclusiveMaximum:K,exclusiveMinimum:H}=$._zod.bag;if(typeofQ==="string"&&Q.includes("int"))U.type="integer";elseU.type="number";letG=typeofH==="number"&&H>=(Y??Number.NEGATIVE_INFINITY),W=typeofK==="number"&&K<=(J??Number.POSITIVE_INFINITY),V=I.target==="draft-04"||I.target==="openapi-3.0";if(G)if(V)U.minimum=H,U.exclusiveMinimum=!0;elseU.exclusiveMinimum=H;elseif(typeofY==="number")U.minimum=Y;if(W)if(V)U.maximum=K,U.exclusiveMaximum=!0;elseU.exclusiveMaximum=K;elseif(typeofJ==="number")U.maximum=J;if(typeofw==="number")U.multipleOf=w},TA=($,I,q,z)=>{q.type="boolean"},EA=($,I,q,z)=>{if(I.unrepresentable==="throw")throwError("BigInt cannot be represented in JSON Schema")},BA=($,I,q,z)=>{if(I.unrepresentable==Line truncated
`)}return{warnings:[],results:J}}function DI($){return{fileBuffer:GH1($),fileName:$.split(/[\\\/]/).pop()??"material-pack.zip"}}import{existsSync as XH1}from"node:fs";async function SD($,I,q={}){let U=K4().stateful?"stateful":"stateless",Y="ok",J,Q,w;try{let A=await H$($);w={id:A.user.id,name:A.user.name,isAdmin:A.user.isAdmin},Q={id:A.tenant.id,name:A.tenant.name,tenantSlug:A.tenant.tenantSlug,corporationName:A.tenant.hoseCorpConfig?.corporationName}}catch(A){Y="error",J=A instanceof Error?A.message:String(A)}let K=[];if(Y==="ok")try{K=await X5($,I.seal.endpoints.approvalStylePreferences)}catch(A){Y="error",J=`读取Webhook配置失败:${AinstanceofError?A.message:String(A)}`}let H=K.length===1,G=K.map((A)=>({id:A.id,name:A.name,mode:A.mode,incomingDocumentWebhookUrl:A.incomingDocumentWebhook.url,outgoingResultWebhookUrl:A.outgoingResultWebhook,autoApprovalRate:A.autoApprovalRate,...H?{isDefault:!0}:{}})),W=H?{id:K[0].id,name:K[0].name,mode:K[0].mode}:null,V=q.webhook?j9(K,q.webhook):H?K[0]:void 0,X;if(q.filePath)if(!XH1(q.filePath))X={valid:!1,filePath:q.filePath,fileName:q.filePath.split(/[\\/]/).pop()??q.filePath,documentCount:0,errors:[`文件不存在:${q.filePath}`]};else try{let A=DI(q.filePath),g=await LI(A.fileBuffer,A.fileName,V?.materialPackFilePolicy);X={valid:!0,filePath:q.filePath,fileName:A.fileName,documentCount:g.documents.length,warnings:g.warnings}}catch(A){X={valid:!1,filePath:q.filePath,fileName:q.filePath.split(/[\\/]/).pop()??q.filePath,documentCount:0,errors:[A instanceof Error?A.message:String(A)]}}let L=X?X.valid:!0,D=Y==="ok"&&G.length>0&&L,O=U==="stateful"?"":`--corp${I.id}`,P="",T="";if(Y!=="ok")T=`凭证鉴权异常:${J}`,P=`seal-useauthdiagnose${O}`;else if(G.length===0)T="当前企业尚未配置任何 Webhook 集成通道",P=`seal-usewebhookadd--name"默认入站通道"--result-url"https://your-domain.com/callback"${O}`;else if(X&&!X.valid)T=`材料包预检失败:${X.errors?.join("; ")}`,P=`seal-usewebhookmaterial-packpreview${X.filePath}${O}`;else{T=H?"所有通道正常,已自动锁定唯一 Webhook 通道,等待载入":`所有通道正常,检测到${G.length}个Webhook通道,等待载入`;let A=X?.filePath??"<材料包.zip>",g=H?"":`--webhook${W?W.id:"<webhookIdOrName>"}`;P=`seal-usewebhookmaterial-packpush${A}${g}${O}`}return{ready:D,corp:{id:I.id,name:I.name,sourceType:I.source.type,tenant:Q,user:w},stateMode:U,authStatus:Y,authError:J,activeWebhooks:G,defaultWebhook:W,materialPack:X,statusMessage:T,nextAction:P}}var jw=[{name:"seal_whoami",description:"查询当前 Seal 用户身份及租户信息",parameters:Z.object({}),handler:async($)=>H$($)},{name:"seal_session_get",description:"查询当前 Seal Bearer session、用户和过期时间",parameters:Z.object({}),handler:async($)=>Il($)},{name:"seal_delegation_list",description:"查询当前 Seal 租户下的授权链接 (Delegation) 列表",parameters:Z.object({}),handler:async($)=>Tl($)},{name:"seal_delegation_create",description:"创建新的 Seal 授权链接 (Delegation)",parameters:Z.object({note:Z.string().optional().describe("授权链接的备注或说明信息")}),handler:async($,I)=>_q($,I)},{name:"seal_delegation_revoke",description:"撤销/废除指定的 Seal 授权链接 (Delegation)",parameters:Z.object({tokenId:Z.string().describe("授权链接 ID (delegation record ID)")}),handler:async($,I)=>El($,I.tokenId)},{name:"seal_user_create",description:"创建本地 Seal 用户,生成并返回初始随机密码",parameters:Z.object({name:Z.string().describe("用户姓名"),phone:Z.string().describe("手机号码 (例如 13300001111 或 +8613300001111)"),permissions:Z.array(Z.string()).optional().describe("权限列表,默认为 []"),departmentIds:Z.array(Z.string()).optional().describe("关联部门 ID 数组")}),handler:async($,I)=>Bl($,I)},{name:"seal_user_reset_password",description:"重置指定 Seal 用户的默认/随机密码,并返回生成的新密码",parameters:Z.object({userId:Z.string().describe("用户 ID (_id)")}),handler:async($,I)=>FB($,I.userId)},{name:"seal_user_get",description:"获取指定 Seal 用户的详细信息",parameters:Z.object({userId:Z.string().describe("用户 ID (_id)")}),handler:async($,I)=>zW($,I.userId)},{name:"seal_user_search",description:"按姓名、手机号或邮箱搜索 Seal 成员用户列表",parameters:Z.object({keyword:Z.string().optional().describe("搜索关键词(姓名、手机号、邮箱等),不传或传空字符串可列出租户成员")}),handler:async($,I)=>UW($,I.keyword??"")},{name:"seal_user_delete",description:"删除指定 Seal 本地用户",parameters:Z.object({userId:Z.string().describe("用户 ID (_id)")}),handler:async($,I)=>xl($,I.userId)},{name:"seal_user_activate",description:"启用/激活已离职的 Seal 用户账号",parameters:Z.object({userId:Z.string().describe("用户 ID (_id)")}),handler:async($,I)=>NB($,I.userId)},{name:"seal_user_delegation_create",description:"为指定 S
Line truncated
`)}function rH1($){let I=[];if(I.push(`seal-use${$.area}-${$.title}`),$.description)I.push($.description);I.push(""),I.push("Usage:");for(let q of $.commands)for(let z of q.usage)I.push(`${z}`);if($.commands.some((q)=>q.name))I.push(""),I.push(`Run'seal-use ${$.area} <command> --help'fordetailsonaspecificcommand.`);return I.join(`
`)}function SZ0(){let $=[];$.push("seal-use CLI"),$.push(""),$.push("Usage:"),$.push(" seal-use version");for(let I of uZ0)for(let q of I.commands)for(let z of q.usage)$.push(`${z}`);return $.push(""),$.push("Run 'seal-use <command> --help' for details on a specific command."),$.join(`
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let V of w){let Z=V.outboundName??"SealAI 审批",X=V.signKey,L=V.apiOrigin??"production";console.error(`•"${Z}"(signKey:${X},环境:${L})`),console.error(`\uD83D\uDC49查看命令:seal-usedeployhosecloudget${X}--corp${J.id}
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let X of V){let L=X.outboundName??"SealAI 审批",D=X.signKey,O=X.apiOrigin??"production";console.error(`•"${L}"(signKey:${D},环境:${O})`),console.error(`\uD83D\uDC49同步命令:seal-usedeployhosecloudsync${D}--corp${J.id}
`},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
`);J(Y)})})}async function iz0($){let I=m0($.options.port)??m0($.options.p),U=h($.options.host)??h($.options.h),Y=await fD({port:I,host:U}),J=()=>{Y.close(()=>{process.exit(0)})};process.on("SIGINT",J),process.on("SIGTERM",J),await new Promise(()=>{})}async function nz0($,I,U,Y){if($==="config"||$==="get"){await F0("seal_llm_config_get",I,U,{},V0(Y.options));return}if($==="providers"||$==="list"){await F0("seal_llm_providers_list",I,U,{},V0(Y.options));return}throw Error(`Unknownllmcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}async function pz0($,I){if($==="config"||$==="json"){hu();return}await uu()}function hu(){B0({mcpServers:{"seal-use":{type:"stdio",command:"seal-use",args:["mcp"],env:{SEAL_USE_MCP_ENABLED:"true"}}}})}function cz0($){let I=yD();B0(I,{...V0($.options),allowFull:!0})}async function dz0($,I,U,Y){if($==="available"){await F0("seal_permissions_available_list",I,U,{},V0(Y.options));return}if($==="configs"||$==="list"){await F0("seal_permissions_configs_list",I,U,{},V0(Y.options));return}throw Error(`Unknownpermissionscommand:${$??""}.Run'seal-use help'foravailablecommands.`)}import{readFileSync as mz0}from"node:fs";async function lz0($,I,U,Y,J,Q,K){if(!$||$==="get"){await F0("seal_preference_get",J,Q,{},V0(K.options));return}if($==="decision"){if(I==="update"||!I){let q=h(K.options.input),H=q?JSON.parse(mz0(q,"utf8")):U$(K.json);if(!H||Object.keys(H).length===0)throw Error(`Usage:seal-usepreferencedecisionupdate--json'{"explicitApprove":"..."}'`);await F0("seal_preference_decision_update",J,Q,{...H,dryRun:N0(K.options.dryRun)??N0(K.options["dry-run"])},V0(K.options));return}}if($==="thinking-depth"||$==="thinkingDepth"){if(I==="set"){let q=h(K.options.default)??h(K.options.level)??Y;if(q!=="medium"&&q!=="high")throw Error("Usage: seal-use preference thinking-depth set --default <medium|high>");await F0("seal_preference_thinking_depth_set",J,Q,{defaultLevel:q,dryRun:N0(K.options.dryRun)??N0(K.options["dry-run"])},V0(K.options));return}if(I==="policies"){if(U==="list"||!U){await F0("seal_preference_thinking_depth_policies_list",J,Q,{},V0(K.options));return}if(U==="upsert"){let q=h(K.options.input),H=q?JSON.parse(mz0(q,"utf8")):U$(K.json);if(!H||!H.id||!H.name)throw Error(`Usage:seal-usepreferencethinking-depthpoliciesupsert--json'{"id":"...","name":"...","level":"high"}'`);await F0("seal_preference_thinking_depth_policies_upsert",J,Q,{...H,dryRun:N0(K.options.dryRun)??N0(K.options["dry-run"])},V0(K.options));return}if(U==="remove"||U==="delete"){let q=Y??h(K.options.id)??h(K.options.policyId);if(!q)throw Error("Usage: seal-use preference thinking-depth policies remove <policyId>");await F0("seal_preference_thinking_depth_policies_remove",J,Q,{policyId:q,dryRun:N0(K.options.dryRun)??N0(K.options["dry-run"])},V0(K.options));return}}}throw Error(`Unknownpreferenceaction:${$??""}.Available:get,decisionupdate,thinking-depthset,thinking-depthpolicieslist/upsert/remove.`)}async function oz0($={}){let I=l8(),U=F4(),Y=NJ(I,{stateful:U.stateful,defaultCorpId:U.defaultCorpId,corpId:$.corpId},YI());console.log(`[probe]corp=${Y.id}source=${Y.source.type}`);let J=await _J(Y);console.log("[probe] seal enterprise"),console.log(JSON.stringify(J,null,2));let Q=await c1(Y),K=await sw(Q,{documentLimit:20,stylePreferencesEndpoint:Y.seal.endpoints.approvalStylePreferences});console.log("[probe] approval context summary"),console.log(JSON.stringify({rules:K.rules.rules.length,hasPendingRuleDeletes:K.rules.hasPendingDeletes,documents:K.documents.articles.length,documentsTotal:K.documents.total,stylePreferences:K.stylePreferences.ok?"ok":`error:${K.stylePreferences.error}`},null,2))}async function rz0($,I,U){let Y=I??h(U.options.corp)??($&&$!=="--corp"?$:void 0);await oz0({corpId:Y})}async function xu($,I,U,Y,J){if($==="count"){await F0("seal_approval_rules_list",U,Y,{countOnly:!0},V0(J.options));return}if($==="list"){if(N0(J.options.count)){await F0("seal_approval_rules_list",U,Y,{countOnly:!0},V0(J.options));return}let Q=m0(J.options.limit),K=m0(J.options.offset);if(N0(J.options.summary)){await F0("seal_approval_rules_list",U,Y,{fields:Qz0,limit:Q,offset:K},V0(J.options));return}let q=await zI("seal_approval_rules_list",U,Y,{limit:Q,offset:K});Kz0(q,N0(J.options.full)===!0),B0(q);return}if($==="clear"){let Q=N0(J.options.yes)===!0,K=N0(J.options.dryRun)??N0(J.options["dry-run"])??!Q;if(!Q&&!K)throw s8("Refusing to clear rules without --yes. Use --dry-run to preview.",`seal-userulesclear--corp${Y.id}--dry-run`);let q=await zI("seal_approval_rules_clear",U,Y,{dryRun:K,recode:N0(J.options.recode)});if(!Q&&K&&q&&typeof q==="object"){B0({...q,nextCommand:`seal-userulesclear--corp${Y.id}--yes`},V0(J.options));return}B0(q,V0(J.options));return}if($==="versions"){await F0("seal_approval_rule_versions_list",U,Y,{},V0(J.options));return}if($==="version"){let Q=I??h(J.options.version);if(!Q)throw Error("Usage: seal-use rules version <versionId|versionNumber|l
Line truncated
`).filter(Boolean),Q=J.slice(-I);return{logFile:U,lines:Q,totalLines:J.length}}async function iG1($){let I=pD($),U=bu($),Y=EH($);ez0($.stateDir);let J=$.port??(process.env.PORT?Number.parseInt(process.env.PORT,10):xD),Q=$.host??(process.env.HOST?process.env.HOST:kD);iD(I,`${process.pid}
`,{mode:384}),iD(U,JSON.stringify({pid:process.pid,port:J,host:Q,version:$.version,startedAt:new Date().toISOString()},null,2),{mode:384}),SJ(Y,`servicestartingonhttp://${Q}:${J} pid=${process.pid}`);let K=null;try{K=await fD({port:J,host:Q,silent:!0}),SJ(Y,`service listening pid=${process.pid}`)}catch(H){if(SJ(Y,`service failed to bind port ${J}: ${H instanceof Error?H.message:String(H)}`),nD(I)===process.pid)e8(I,{force:!0}),e8(U,{force:!0});throw H}let q=()=>{if(K)K.close(),K=null;if(nD(I)===process.pid)e8(I,{force:!0}),e8(U,{force:!0});SJ(Y,`stopped pid=${process.pid}`)};await new Promise((H)=>{let G=!1,W=()=>{if(G)return;G=!0,q(),process.off("SIGTERM",W),process.off("SIGINT",W),H()};process.once("SIGTERM",W),process.once("SIGINT",W)})}function tz0($){ez0($.stateDir);let I=gJ($);if(I.running)return I;let U=$.launcher??{command:process.execPath,args:[$.entryFile]},Y=[...U.args??[],"service","run"];if($.port)Y.push("--port",String($.port));if($.host)Y.push("--host",String($.host));let J=xG1(U.command,Y,{cwd:$.appRoot,detached:!0,stdio:["ignore","ignore","ignore"],env:process.env});J.unref();let Q=pD($);return iD(Q,`${J.pid}
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let W of G){let V=W.outboundName??"SealAI 审批",X=W.signKey,L=W.apiOrigin??"production";console.error(`•"${V}"(signKey:${X},环境:${L})`),console.error(`\uD83D\uDC49查看命令:seal-usedeployhosecloudget${X}--corp${U.id}
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let X of W){let L=X.outboundName??"SealAI 审批",D=X.signKey,O=X.apiOrigin??"production";console.error(`•"${L}"(signKey:${D},环境:${O})`),console.error(`\uD83D\uDC49同步命令:seal-usedeployhosecloudsync${D}--corp${U.id}
`);throw new r$("缺少必需参数 <sign-key>。请从上述候选列表中选择并指定 signKey 执行同步。",2,W.length===1?`seal-usedeployhosecloudsync${W[0].signKey}--corp${U.id}`:void 0)}await F0("seal_deploy_hosecloud_sync",z,U,{signKey:K},W0(Y.options));return}throw Error(`Unknowndeployhosecloudaction:${Q??""}.Available:requirements,list,get,status,configure,sync.`)}import{accessSync as UW1,constants as YW1,existsSync as M$,readdirSync as JW1}from"node:fs";import{homedir as QW1}from"node:os";import{join as $9}from"node:path";import{existsSync as Hx,mkdirSync as SL0,rmSync as IW1,writeFileSync as qW1}from"node:fs";import{homedir as uL0}from"node:os";import{dirname as zW1,join as Gx}from"node:path";var PL0=`---
name:seal-use
description:"v0.10.17: 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.18: 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.
@@ -423,7 +392,7 @@ seal-use corps list
##FirstRules
-TreatCLI/MCPastheAgent's execution channel, not the user'sinterface.Translatenatural-languageintentintocommandsyourself;neverasktheusertocomposeCLIsyntax,JSONpayloads,placeholdervalues,orinternalIDs.
-Beforeaskingforenterpriseparameters,run\`seal-use corps list\`. If the target is already configured, resolve its human name to the returned \`id\` and pass that value as \`--corp\`; do not ask the user to know \`corpId\`.
-Beforeaskingforenterpriseparameters,resolvethetargetenterprise:whenanenterpriseisnamed,hinted,orkeyword-identifiable,ALWAYSrun\`seal-use corps search <keyword>\` (or \`seal-use corps get <corpId>\` if an exact ID is known) — DO NOT dump the entire enterprise catalog with \`seal-use corps list\` when the target is already known. Only run \`seal-use corps list\` (or \`corps list --env <test|production>\`) for initial discovery when zero enterprise context is known. Resolve its human name to the returned \`id\` and pass that value as \`--corp\`; do not ask the user to know \`corpId\`. Use \`seal-use corps get <corpId>\` to inspect rich enterprise attributes (URLs, tenant slugs, staff IDs, environment relations, and config file locations) with sensitive secrets safely redacted.
-Ifnoenterpriseisconfigured,theuserisinstallingforthefirsttime,ortheuserprovidescredentials,anassistancelink,orabrowser-copiedcURL,read\`references/enterprise-onboarding.md\` before asking questions or running setup commands.
-WhentheuserprovidesaHose/合思\`thirdparty.html\` assistance link, use \`seal-use corps add-link <url> [--name ...]\`; the command verifies the tenant and records the temporary Seal session without echoing the link token.
-Prefercompactcommandsfirst:\`pick\`, \`--summary\`, \`--fields\`, \`attachments --summary\`, \`rules count\`, and \`rules list --summary\`.
-ParseJSONstdout.Donotscrapehumantext.
-Donothand-editenterpriseconfigsfornormalsetup.Use\`seal-use corps ...\`.
-Beforewriteoperationsonrules,documents,stylepreferences,orpublishing,fetchcurrentstateandconfirmtheintendedmutationwiththeuser.Forsupportedconfigurationwrites,prefertheuniversal\`--dry-run\` preview first (rules clear/push, \`corps sync-test\`, preferences, thinking-depth policies, HoseCloud configure, and Webhook add/update/delete), then use \`--yes\` only after reviewing its redacted \`changesDiff\`.
-Beforewriteoperationsonrules,documents,stylepreferences,orpublishing,fetchcurrentstateandconfirmtheintendedmutationwiththeuser.Forsupportedconfigurationwrites,prefertheuniversal\`--dry-run\` preview first (rules clear/push, \`corps sync-test\`, preference updates, thinking-depth policies, HoseCloud configure, and Webhook add/update/delete), then use \`--yes\` only after reviewing its redacted \`changesDiff\`.
-Knowledgedocumentcreationanddeletionarenowsupported.Validate\`contentType\` and \`scenarios\` before creating; use \`enabled: false\` when the document should be withdrawn without deletion. For an explicit deletion, re-read the document and obtain confirmation before using the low-level \`seal_approval_delete_document\` tool.
-Forcustomer-feedbackruleremediation,showanexactfield-leveldiffandobtainexplicitapprovalbeforeupdating.Defaulttochangingonlythenarrowestnecessarypartof\`description\`; preserve \`scope\`, \`strictness\`, and unrelated clauses unless the user explicitly approves otherwise.
-Resolveandlockthetargetenterprise\`corpId\` before diagnosis or mutation. Never assume the current tenant is the customer tenant. Re-fetch the target rule immediately before updating, then verify the draft and newly published version after writing.
@@ -440,8 +409,18 @@ seal-use corps list
-WhenreturningANYauthorization,login,ordelegationlinks(e.g.合思授权链接,Seal授权链接/委托链接),ALWAYSprovideBOTHacodeblock(\`\`\`\`text ... \`\`\`\`) for easy copying without accidental default browser redirection, AND a clickable hyperlink.
-Fordelegationlinks,alwaysprefer\`seal-use delegation create\` over \`users delegation\` for link generation to ensure persistent token tracking.
-Alwaysdefaulttoreturningthecleandeeplink(\`type: 'deep_link'\`), which contains no credentials and requires no sensitive access. Users in their authorized browsers open it directly with zero token leakage risk.
-ONLYprovideanSSOlink(\`--sso\`) when the user explicitly requests an unauthenticated/cross-browser/no-login/免密 link and acknowledges risks.
2.ProvideBOTHacodeblock(\`\`\`\`text ... \`\`\`\`) and a clickable hyperlink.
-Inthedefaultstatelessmode,everyenterprisecommandrequires\`--corp <corpId>\`. In stateful mode, omitting \`--corp\` uses the configured default enterprise and is unsafe for an explicitly named enterprise.
-Foranexplicitlynamedenterprise,firstresolveitwith\`seal-use corps list\`, then pass its exact \`corpId\` to every command. After creation, verify the returned URL host matches that enterprise's Seal tenant; if the host is the current/default tenant or cannot be verified, do not present the link as the target enterprise's link.
-Foranexplicitlynamedenterprise,resolveitdirectlywith\`seal-use corps search <name>\` (or \`seal-use corps get <corpId>\` if given an exact ID) rather than dumping all enterprises with \`seal-use corps list\`. Then pass its exact \`corpId\` to every command. After creation, verify the returned URL host matches that enterprise's Seal tenant; if the host is the current/default tenant or cannot be verified, do not present the link as the target enterprise's link.
-User-facingSealtenantassistancelink(Seal协助/Seal授权/委托):resolvethenamedenterprisefirst,thenrun\`seal-use delegation create --corp <corpId> --note '<enterprise>'\`; verify the returned hostname is that tenant's Seal hostname. Always provide BOTH a code block (\`\`\`\`text ... \`\`\`\`) AND a hyperlink.
-Packagedcustomerfeedback→approval-ruleremediation:read\`references/customer-feedback-rule-remediation.md\`. Use this route for WeChat messages, screenshots, rejection notifications, document numbers, customer complaints, expected approval behavior, rule-only mitigation, exact diffs, or requests to update and publish a rule version.
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 YX0=`interface:
`;var TL0=`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."
@@ -666,7 +653,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 KX0="# 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-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-useopenapi\nseal-useprobe[<corpId>]\nseal-usetoolslist\nseal-usecorpslist[--corp<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-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]\nseal-usedelegationlist[--corp<corpId>]\nseal-usedelegationcreate[--note<note>][--from-link<url>][--corp<corpId>]\nseal-usedelegationrevoke<tokenId>[--corp<corpId>]\nseal-useuserscreate--name<name>--phone<phone>[--dept<deptId>][--corp<corpId>]\nseal-useuserssearch<keyword>[--corp<corpId>]\nseal-useusersdelegation<userIdOrPhone|name>[--note<note>][--corp<corpId>]\nseal-useusersactivate<userId>[--corp<corpId>]\nseal-useusersreset-password<userId>[--corp<corpId>]\nseal-useusersget<userId>[--corp<corpId>]\nseal-useusersdelete<userId>[--corp<corpId>]\nseal-usecontactsdepartments[<departmentId>][--corp<corpId>]\nseal-usecontLine truncated
`;var jL0="# 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-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-useopenapi\nseal-usedoctor[--quiet]\nseal-usedoctorguide\nseal-usedoctorpaths\nseal-useprobe[<corpId>]\nseal-usetoolslist\nseal-usecorpslist[query][--env<production|test>][--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-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]\nseal-usedelegationlist[--corp<corpId>]\nseal-usedelegationcreate[--note<note>][--from-link<url>][--corp<corpId>]\nseal-usedelegationrevoke<tokenId>[--corp<corpId>]\nseal-useuserscreate--name<name>--phone<phone>[--dept<deptId>][--corp<corpId>]\nseal-useuserssearch<keyword>[--corp<corpId>]\nseal-useusersdelegation<userIdOrPhone|name>[--note<note>][--corp<corpId>]\nseal-useusersactivate<userId>[--corp<corpId>]\nseal-useusersreseLine truncated
@@ -1103,7 +1094,141 @@ Return a compact report containing:
-Newversionnumberandversionname,ifpublished
-Verificationresult
-Whetheraregressionrerunwasperformed
`;var WX0="# Enterprise Onboarding\n\nRead this reference for first installation, zero configured enterprises, incoming credentials or assistance links, and browser-copied cURL. The goal is to identify the enterprise with the least user effort while keeping authentication material confidential.\n\n## Start With Discovery\n\nRun this before asking for setup parameters (if `seal-use` is not installed, first run `curl-fsSLhttps://git.ying-qing.cn/gitea/seal-use/raw/branch/main/scripts/install.sh | bash`):\n\n```bash\nseal-use version\nseal-use corps list\n```\n\n- If `seal-use` is not installed on the system, run the curl install script above to install it.\n- If the target enterprise is listed, match the user's human enterprise name to its returned `id` and use that value as `--corp` on every command. Do not ask the user for `corpId`.\n- If multiple configured enterprises plausibly match, show their human names and let the user choose. Keep their IDs as implementation details.\n- If none are configured, ask one plain-language question: “你现在手上有哪一种接入材料:合思开放平台 appKey/appSecurity、合思授权/协助链接、Seal 协助链接,还是从已登录的合思或 Seal 网页复制的 cURL?”\n\nDo not open with a JSON template or a list of internal fields.\n\nAll command examples in this reference are for the Agent to run. Do not hand them to the user as setup instructions. Communicate with the user in natural language and translate their answer into CLI/MCP parameters yourself.\n\n## Keep Two Concepts Separate\n\nClassify both the enterprise identity origin and how the current credential was acquired:\n\n| Enterprise identity origin | Credential material the user may have | Meaning |\n| --- | --- | --- |\n| Hose/合思-sourced Seal tenant | Hose `appKey` + `appSecurity` | Stable, refreshable standard integration |\n| Hose/合思-sourced Seal tenant | Hose authorization/assistance link | Temporary Hose authorization that can lead into the Seal SSO session |\n| Hose/合思-sourced Seal tenant | cURL copied from an authenticated Hose or Seal page | Snapshot of a signed-in browser session; it may expire |\n| Seal-native tenant | Seal assistance/delegation link | Temporary delegated access to a Seal tenant |\n| Seal-native tenant | cURL copied from an authenticated Seal page | Snapshot containing the Seal host and session authentication |\n\nCredential shape alone does not define identity origin. In particular, a Hose-sourced user eventually receives a Seal Bearer session after SSO. When `whoami` returns provider metadata, preserve it and use it to describe the tenant accurately.\n\n## Parameter Ownership\n\nAsk the user only for information that cannot be discovered safely:\n\n| Field | Owner and behavior |\n| --- | --- |\n| `appKey`, `appSecurity` | User supplies these for standard Hose OpenAPI onboarding. Explain that they come from the enterprise's 合思开放平台 application credentials. Treat both as secrets. |\n| `domain` | Probe the standard Hose SaaS domains automatically. Ask only when probing fails and the enterprise uses a private or dedicated deployment. |\n| Enterprise name and `corpId` | Discover from the credential response or Seal `whoami`. Do not ask the user to invent or locate them first. |\n| Administrator and `staffId` | Discover administrator candidates. If more than one is eligible, present name and masked phone for the user to choose; pass the selected ID internally. |\n| Seal URL, tenant ID, tenant slug | Discover from the assistance link, cURL host, and Seal `whoami`. |\n| Bearer token, cookies, signed query tokens | Extract only from user-supplied authentication material. Never print them back or include them in summaries. |\n\n## Route 1: Standard Hose Credentials\n\nThis is the preferred durable route for a Hose-sourced tenant. Read `hose-enterprise-init.md`, then use:\n\n```bash\nseal-use corps add-hose --json '{\"appKey\":\"...\",\"appSecurity\":\"...\"}'\n```\n\nThe CLI probes the standard domains, discovers the corporation, and discovers administrator candidates. If it returns multiple candidates, show only useful identifying information and ask which person should be used; retry with `staffName`, `staffPhone`, or the selected `staffId` internally. After creation, run:\n\n```bash\nseal-use auth diagnose --corp <discovered-id>\n```\n\nDo not ask for `domain`, `corpId`, or `proxyStaffBizId` up front. For a dedicated/private Hose deployment, add `domain` only after standard probing reports that it cannot find the enterprise.\n\n## Route 2: Incoming Assistance Link\n\nFirst distinguish the link by its host and purpose:\n\n- A Hose authorization/provisional link opens a Hose session and may continue through Seal SSO. It is not a Seal delegation link.\n- A Seal assistance/delegation link grants temporary delegated access on a Seal tenant. It is not a Hose OpenAPI credential.\n- `seal-use auth hose-link` and `seal-use delegation create` generat
Line truncated
Runthisbeforeaskingforsetupparameters(if\`seal-use\` is not installed, first run \`curl -fsSL https://git.ying-qing.cn/gitea/seal-use/raw/branch/main/scripts/install.sh | bash\`):
-If\`seal-use\` is not installed on the system, run the curl install script above to install it.
-Iftheuserprovidedanenterprisenameorkeyword,prioritize\`seal-use corps search <keyword>\` to locate it without dumping all enterprises. Match the user's human enterprise name to its returned \`id\` and use that value as \`--corp\` on every command. Do not ask the user for \`corpId\`.
-Ifzeroenterprisecontextisknown,run\`seal-use corps list\`.
-ToinspectfullendpointURLs,tenantslug,configfilelocation,andstaffbindingsofaconfiguredenterprise,run\`seal-use corps get <corpId>\`.
Credentialshapealonedoesnotdefineidentityorigin.Inparticular,aHose-sourcedusereventuallyreceivesaSealBearersessionafterSSO.When\`whoami\` returns provider metadata, preserve it and use it to describe the tenant accurately.
|\`appKey\`, \`appSecurity\` | User supplies these for standard Hose OpenAPI onboarding. Explain that they come from the enterprise's 合思开放平台 application credentials. Treat both as secrets. |
|\`domain\` | Probe the standard Hose SaaS domains automatically. Ask only when probing fails and the enterprise uses a private or dedicated deployment. |
|Enterprisenameand\`corpId\` | Discover from the credential response or Seal \`whoami\`. Do not ask the user to invent or locate them first. |
|Administratorand\`staffId\` | Discover administrator candidates. If more than one is eligible, present name and masked phone for the user to choose; pass the selected ID internally. |
TheCLIprobesthestandarddomains,discoversthecorporation,anddiscoversadministratorcandidates.Ifitreturnsmultiplecandidates,showonlyusefulidentifyinginformationandaskwhichpersonshouldbeused;retrywith\`staffName\`, \`staffPhone\`, or the selected \`staffId\` internally. After creation, run:
\`\`\`bash
seal-useauthdiagnose--corp<discovered-id>
\`\`\`
Donotaskfor\`domain\`, \`corpId\`, or \`proxyStaffBizId\` up front. For a dedicated/private Hose deployment, add \`domain\` only after standard probing reports that it cannot find the enterprise.
-\`seal-use auth hose-link\` and \`seal-use delegation create\` generate links for an enterprise that is already configured. \`seal-use corps add-link <url>\` imports a received Hose/合思 \`thirdparty.html\` assistance link and verifies the resulting Seal tenant.
UsethedirectimportroutewhentheincominglinkisanHTTPS\`thirdparty.html\` URL from a supported \`ekuaibao.com\` or \`hosecloud.com\` domain:
Thecommandparses\`accessToken\` and \`ekbCorpId\`, exchanges the temporary Hose token at the target Seal tenant, verifies \`/api/v1/auth/me\`, and stores only the normalized short-lived Seal session. It never prints or persists the original URL. Use \`--overwrite\` only when intentionally replacing an existing enterprise config. To create a Seal delegation link without persisting the session, use \`seal-use delegation create --from-link <url> [--note ...]\`.
2.Parseitasdata.Extracttherequesthost,path,\`Authorization\` header, cookies, and provider/tenant hints. Ignore the request body unless it is required to identify the tenant.
3.ClassifywhetherthecapturedrequestistoHoseorSeal.ASealrequestwith\`Authorization: Bearer ...\` can supply \`sealUrl\` and a session token even when the user's identity origin is Hose.
4.Verifywiththenarrowestread-onlyidentityendpointavailable.ForaSealBearersession,verify\`/api/v1/auth/me\` through \`seal-use corps add-seal\`; use returned provider metadata to retain the actual origin.
ThecurrentCLIhasnoraw-cURLimportcommandand\`add-seal\` requires a Bearer token. If the captured request contains only cookies or an authentication shape the CLI cannot verify, do not improvise a token. Ask the user to copy another successful Seal Fetch/XHR request that contains the Bearer header, or explain the current limitation.
-\`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.
`);return}if($==="install"||$==="init"||$==="sync"){let Y=N0(U.options.local)||N0(U.options.workspace),J=h(U.options.dir)??h(U.options.target)??I,Q=J?J:Y?cD(process.cwd(),".agents","skills","seal-use"):BH(),K=du(Q);B0({installed:!0,targetDir:K.targetDir,fileCount:K.files.length,files:K.files});return}if($==="status"||$==="get"||!$){let Y=BH(),J=cD(process.cwd(),".agents","skills","seal-use");B0({global:{dir:Y,installed:OX0(cD(Y,"SKILL.md"))},local:{dir:J,installed:OX0(cD(J,"SKILL.md"))}});return}throw Error(`Unknownskillcommand:${$}.Run'seal-use help'foravailablecommands.`)}async function MX0($,I){if($==="config"){B0(await _J(I));return}throw Error(`Unknownsourcecommand:${$??""}.Run'seal-use help'foravailablecommands.`)}async function AX0($,I,U,Y){if(!$)throw Error("Usage: seal-use tool <toolName> [--json '{...}']");await F0($,I,U,U$(Y.json),V0(Y.options))}function PX0(){B0(DH.map(($)=>({name:$.name,description:$.description})))}import{chmodSync as KW1,mkdirSync as qW1,renameSync as lu,rmSync as HW1,unlinkSync as RX0,writeFileSync as TX0}from"node:fs";import{dirname as GW1,join as EX0}from"node:path";import{spawnSync as LI}from"node:child_process";function dD($=process.execPath,I=import.meta.url){if(I.includes("/$bunfs/")||I.includes("\\$bunfs\\"))return!0;let U=$.toLowerCase().replace(/\\/g,"/");return!U.endsWith("/bun")&&!U.endsWith("/bun.exe")&&!U.endsWith("/node")&&!U.endsWith("/node.exe")}var jX0="yunyingk/seal-use",RH="yunyingk/seal-home";var WW1="SEAL_USE_GITHUB_REPO",wW1="SEAL_HOME_GITHUB_REPO";async function CX0($,I={}){let U={appRoot:$.appRoot,entryFile:$.entryFile,stateDir:iu,version:Y1,launcher:$.launcher},Y=I.repo||process.env[WW1]?.trim()||process.env[wW1]?.trim()||jX0,J=I.targetVersion?.trim(),Q=J&&J.toLowerCase()!=="latest"?J:void 0;if(Q){let A=Q.replace(/^v/,""),R=_X0(A,Y1);if(R<0)if(!uE&&I.force);else{B0({updated:!1,currentVersion:Y1,targetVersion:A,mode:dD()?"binary":"source",message:!uE?`Cannotdowngradeseal-usefromdevbuildv${Y1}toreleasev${A}.Use--forcetooverwrite.`:`Cannotdowngradeseal-usefromv${Y1}toolderversionv${A}.Updatesmustbeforward-only.`});return}if(R===0&&!I.force){B0({updated:!1,currentVersion:Y1,targetVersion:A,mode:dD()?"binary":"source",message:`seal-useisalreadyatversionv${Y1}.Use--forcetoreinstall.`});return}}if(I.changelogOnly){let A=await ou(Y,I.limit??10);B0({currentVersion:Y1,totalQueried:A.length,releases:A.map((R)=>({version:R.version,tagName:R.tagName,publishedAt:R.publishedAt,author:R.author,releaseNotes:R.notes,releaseUrl:R.htmlUrl,isCurrent:R.version===Y1,isNewer:vH(R.version,Y1)}))});return}if(!dD()){if(I.checkOnly){let R=await ou(Y,30),k=R[0],g=k?.version??Y1,f=R.find((n)=>n.version===Y1),j=vH(g,Y1),p=R.filter((n)=>vH(n.version,Y1));B0({updated:!1,updateAvailable:j,currentVersion:Y1,currentVersionPublishedAt:f?.publishedAt,latestVersion:g,latestVersionPublishedAt:k?.publishedAt,behindCount:p.length,pendingReleases:p.map((n)=>({version:n.version,tagName:n.tagName,publishedAt:n.publishedAt,author:n.author,releaseNotes:n.notes,releaseUrl:n.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=gJ(U).running;if(A)await XI("stop",U);try{vX0("git",["-C",$.appRoot,"pull","--ff-only"])}catch(R){console.error(`gitpullskipped:${RinstanceofError?R.message:String(R)}`)}if(vX0("bun",["install"],{cwd:$.appRoot}),A)await XI("start",U);B0({updated:!0,serviceRestarted:A,version:Y1,mode:"source"});return}let K=VW1(),q=ZW1(),H=await ou(Y,30),G=Q?H.find((A)=>A.version===Q||A.tagName===Q||A.tagName===`v${Q}`)??await BX0(Y,Q):H[0]??await BX0(Y);if(!G){B0({updated:!1,currentVersion:Y1,mode:"binary",message:`Failedtoqueryreleasesfromrepository'${Y}'`});return}let W=G.version,w=H.find((A)=>A.version===Y1),V=vH(W,Y1),Z=V||Boolean(I.force),X=H.filter((A)=>vH(A.version,Y1));if(I.checkOnly){B0({updated:!1,updateAvailable:V,currentVersion:Y1,currentVersionPublishedAt:w?.publishedAt,latestVersion:W,latestVersionPublishedAt:G.publishedAt,behindCount:X.length,pendingReleases:X.map((A)=>({version:A.version,tagName:A.tagName,publishedAt:A.publishedAt,author:A.author,releaseNotes:A.notes,releaseUrl:A.htmlUrl})),releaseNotes:G.notes,releaseUrl:G.htmlUrl,mode:"binary"});return}if(!Z){B0({updated:!1,currentVersion:Y1,currentVersionPublishedAt:w?.publishedAt,latestVersion:W,latestVersionPublishedAt:G.publishedAt,mode:"binary",message:`seal-useisalreadyuptodate(v${Y1})`});return}let L=zW1(G.assets,K,q);if(!L)throw Error(`Nocompatiblebinaryfoundfor${K}-${q}inreleasev${W}.Availableassets:${G.assets.map((A)=>A.name).join(", ")}`);let D=gJ(U).running;if(D)await XI("stop",U);let O=process.execPath,E=GW1(O),T=EX0(E,`.tmp-update-${Date.now()}`);qW1(T,{recursive:!0});try{let A=EX0(T,L.name);await XW1(L.downloadUrl,A,G.tagName,L.name);let R=A;if(L.name.endsWith(".tar.gz")||L.name.endsWith(".tgz"))R=LW1
Line truncated
`)}catch{}}async function XW1($,I,U,Y){let J=ru(),Q=[],K=U?U.startsWith("v")?U:`v${U}`:void 0,q=Y||$.split("/").pop()||"";if(J!=="github"){if(K&&q)Q.push(`https://git.ying-qing.cn/gitea/seal-use/releases/download/${K}/${q}`,`https://git.ying-qing.cn/gitea/seal-home/releases/download/${K}/${q}`);if($.startsWith("https://git.ying-qing.cn"))Q.push($)}if(J!=="gitea")if(K&&q){let L=`https://github.com/${jX0}/releases/download/${K}/${q}`;if(!process.env.CI)Q.push(`https://ghfast.top/${L}`,`https://gh.ddlc.top/${L}`);Q.push(L)}else if($.includes("github.com")){if(!process.env.CI)Q.push(`https://ghfast.top/${$}`,`https://gh.ddlc.top/${$}`);Q.push($)}else Q.push($);let H=Array.from(new Set(Q)),G,W=6000,w=6000,V=307200,Z=1e4,X=180000;for(let L=0;L<H.length;L++){let D=H[L],O=new AbortController,E="",T=(g)=>{E=g;try{O.abort()}catch{}},A=setTimeout(()=>{T("Connection timed out (no response headers within 6s)")},W),R,k;try{mD(`==> [${L+1}/${H.length}] Downloading via: ${D}`);let g=await fetch(D,{signal:O.signal});if(A)clearTimeout(A),A=void 0;if(!g.ok)throw Error(`HTTP ${g.status} ${g.statusText}`);R=setTimeout(()=>{T("Overall download time exceeded 3 minutes")},X);let f=Number(g.headers.get("content-length"))||0,j=g.body?.getReader();if(!j){let i=Buffer.from(await g.arrayBuffer());if(i.length<1000)throw Error(`Downloaded content is suspiciously small (${i.length} bytes)`);TX0(I,i),mD(`✓ Download succeeded (${(i.length/1024/1024).toFixed(1)} MB)`);return}let p=[],n=0,S=0;k=setTimeout(()=>{if(n<V){let i=(n/1024).toFixed(1);T(`Initial transfer too slow (${i} KB < 300 KB in 6s), switching mirror...`)}},w);while(!0){let i=j.read(),U0,B=new Promise((J0,w0)=>{U0=setTimeout(()=>{w0(Error("Data transfer stalled (no chunk received for 10s)"))},Z)}),x;try{x=await Promise.race([i,B])}finally{if(U0)clearTimeout(U0)}let{done:c,value:r}=x;if(c)break;if(r){if(p.push(r),n+=r.length,k&&n>=V)clearTimeout(k),k=void 0;let J0=Date.now();if(J0-S>200){S=J0;let w0=f?Math.round(n/f*100):0,A0=(n/1048576).toFixed(1),j0=f?(f/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${w0}% (${A0} / ${j0} MB)...`)}catch{}}}}try{process.stderr.write(`
`)}async function pL0($,I,q){let z=($??I??"").toLowerCase();if(z==="guide"||z==="doc"||z==="knowledge"||z==="book"){console.error(`\uD83D\uDCD6[SealUseDoctor]正在读取内嵌系统规范白皮书(纯内存只读)...
`),console.log(nL0());return}if(z==="paths"||z==="dirs"||z==="directories"){let J=Ox();E0(J.directories);return}let U=Ox();if(!(O0(q.options.quiet)||O0(q.options.silent)))console.error(iL0(U));E0(U)}import{createServer as WW1}from"node:http";import{URL as KW1}from"node:url";var cL0={openapi:"3.1.0",info:{title:"seal-use Wrapped API",version:"0.10.18",description:`PlannedHTTPcontractfortheseal-usewrappedbackendAPI.
`},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(z)})})}async function lL0($){let I=i0($.options.port)??i0($.options.p),q=C($.options.host)??C($.options.h),z=await YO({port:I,host:q}),U=()=>{z.close(()=>{process.exit(0)})};process.on("SIGINT",U),process.on("SIGTERM",U),await new Promise(()=>{})}async function oL0($,I,q,z){if($==="config"||$==="get"){await F0("seal_llm_config_get",I,q,{},W0(z.options));return}if($==="providers"||$==="list"){await F0("seal_llm_providers_list",I,q,{},W0(z.options));return}throw Error(`Unknownllmcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}async function rL0($,I){if($==="config"||$==="json"){Nx();return}await Mx()}function Nx(){E0({mcpServers:{"seal-use":{type:"stdio",command:"seal-use",args:["mcp"],env:{SEAL_USE_MCP_ENABLED:"true"}}}})}function tL0($){let I=$O();E0(I,{...W0($.options),allowFull:!0})}async function aL0($,I,q,z){if($==="available"){await F0("seal_permissions_available_list",I,q,{},W0(z.options));return}if($==="configs"||$==="list"){await F0("seal_permissions_configs_list",I,q,{},W0(z.options));return}throw Error(`Unknownpermissionscommand:${$??""}.Run'seal-use help'foravailablecommands.`)}import{readFileSync as sL0}from"node:fs";async function eL0($,I,q,z,U,Y,J){if(!$||$==="get"){await F0("seal_preference_get",U,Y,{},W0(J.options));return}if($==="decision"){if(I==="update"||!I){let Q=C(J.options.input),w=Q?JSON.parse(sL0(Q,"utf8")):z$(J.json);if(!w||Object.keys(w).length===0)throw Error(`Usage:seal-usepreferencedecisionupdate--json'{"explicitApprove":"..."}'`);await F0("seal_preference_decision_update",U,Y,{...w,dryRun:O0(J.options.dryRun)??O0(J.options["dry-run"])},W0(J.options));return}}if($==="thinking-depth"||$==="thinkingDepth"){if(I==="set"){let Q=C(J.options.default)??C(J.options.level)??z;if(Q!=="medium"&&Q!=="high")throw Error("Usage: seal-use preference thinking-depth set --default <medium|high>");await F0("seal_preference_thinking_depth_set",U,Y,{defaultLevel:Q,dryRun:O0(J.options.dryRun)??O0(J.options["dry-run"])},W0(J.options));return}if(I==="policies"){if(q==="list"||!q){await F0("seal_preference_thinking_depth_policies_list",U,Y,{},W0(J.options));return}if(q==="upsert"){let Q=C(J.options.input),w=Q?JSON.parse(sL0(Q,"utf8")):z$(J.json);if(!w||!w.id||!w.name)throw Error(`Usage:seal-usepreferencethinking-depthpoliciesupsert--json'{"id":"...","name":"...","level":"high"}'`);await F0("seal_preference_thinking_depth_policies_upsert",U,Y,{...w,dryRun:O0(J.options.dryRun)??O0(J.options["dry-run"])},W0(J.options));return}if(q==="remove"||q==="delete"){let Q=z??C(J.options.id)??C(J.options.policyId);if(!Q)throw Error("Usage: seal-use preference thinking-depth policies remove <policyId>");await F0("seal_preference_thinking_depth_policies_remove",U,Y,{policyId:Q,dryRun:O0(J.options.dryRun)??O0(J.options["dry-run"])},W0(J.options));return}}}throw Error(`Unknownpreferenceaction:${$??""}.Available:get,decisionupdate,thinking-depthset,thinking-depthpolicieslist/upsert/remove.`)}async function $D0($={}){let I=c$(),q=K4(),z=vU(I,{stateful:q.stateful,defaultCorpId:q.defaultCorpId,corpId:$.corpId},HI());console.log(`[probe]corp=${z.id}source=${z.source.type}`);let U=await iU(z);console.log("[probe] seal enterprise"),console.log(JSON.stringify(U,null,2));let Y=await y1(z),J=await WW(Y,{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))}async function ID0($,I,q){let z=I??C(q.options.corp)??($&&$!=="--corp"?$:void 0);await $D0({corpId:z})}async function Ax($,I,q,z,U){if($==="count"){await F0("seal_approval_rules_list",q,z,{countOnly:!0},W0(U.options));return}if($==="list"){if(O0(U.options.count)){await F0("seal_approval_rules_list",q,z,{countOnly:!0},W0(U.options));return}let Y=i0(U.options.limit),J=i0(U.options.offset);if(O0(U.options.summary)){await F0("seal_approval_rules_list",q,z,{fields:kZ0,limit:Y,offset:J},W0(U.options));return}let Q=await MI("seal_approval_rules_list",q,z,{limit:Y,offset:J});fZ0(Q,O0(U.options.full)===!0),E0(Q);return}if($==="clear"){let Y=O0(U.options.yes)===!0,J=O0(U.options.dryRun)??O0(U.options["dry-run"])??!Y;if(!Y&&!J)throw q5("Refusing to clear rules without --yes. Use --dry-run to preview.",`seal-userulesclear--corp${z.id}--dry-run`);let Q=await MI("seal_approval_rules_clear",q,z,{dryRun:J,recode:O0(U.options.recode)});if(!Y&&J&&Q&&typeof Q==="object"){E0({...Q,nextCommand:`seal-userulesclear--corp${z.id}--yes`},W0(U.options));return}E0(Q,W0(U.options));return}if($==="versions"){await F0("seal_approval_rule_versions_list",q,z,{},W0(U.options));return}if($==="version"){let Y=I??C(U.options.version);if(!Y)throw Error("Usage: seal-use rules version <versionId|versionNumber|l
Line truncated
`).filter(Boolean),Y=U.slice(-I);return{logFile:q,lines:Y,totalLines:U.length}}async function DW1($){let I=KO($),q=Ex($),z=fw($);YD0($.stateDir);let U=$.port??(process.env.PORT?Number.parseInt(process.env.PORT,10):zO),Y=$.host??(process.env.HOST?process.env.HOST:UO);QO(I,`${process.pid}
`,{mode:384}),QO(q,JSON.stringify({pid:process.pid,port:U,host:Y,version:$.version,startedAt:new Date().toISOString()},null,2),{mode:384}),pU(z,`servicestartingonhttp://${Y}:${U} pid=${process.pid}`);let J=null;try{J=await YO({port:U,host:Y,silent:!0}),pU(z,`service listening pid=${process.pid}`)}catch(w){if(pU(z,`service failed to bind port ${U}: ${w instanceof Error?w.message:String(w)}`),wO(I)===process.pid)z5(I,{force:!0}),z5(q,{force:!0});throw w}let Q=()=>{if(J)J.close(),J=null;if(wO(I)===process.pid)z5(I,{force:!0}),z5(q,{force:!0});pU(z,`stopped pid=${process.pid}`)};await new Promise((w)=>{let K=!1,H=()=>{if(K)return;K=!0,Q(),process.off("SIGTERM",H),process.off("SIGINT",H),w()};process.once("SIGTERM",H),process.once("SIGINT",H)})}function qD0($){YD0($.stateDir);let I=cU($);if(I.running)return I;let q=$.launcher??{command:process.execPath,args:[$.entryFile]},z=[...q.args??[],"service","run"];if($.port)z.push("--port",String($.port));if($.host)z.push("--host",String($.host));let U=VW1(q.command,z,{cwd:$.appRoot,detached:!0,stdio:["ignore","ignore","ignore"],env:process.env});U.unref();let Y=KO($);return QO(Y,`${U.pid}
`,{flag:"a",mode:384})}var Bx=NW1(FW1(),".config","seal-use");async function jx($,I,q){let z=q?i0(q.options.port)??i0(q.options.p):void 0,U=q?C(q.options.host)??C(q.options.h):void 0,Y=q?i0(q.options.lines)??i0(q.options.n):void 0,J=await PI($,{appRoot:I.appRoot,entryFile:I.entryFile,stateDir:Bx,version:s0,launcher:I.launcher,port:z,host:U},{maxLines:Y});if(J!==void 0)E0(J)}import{existsSync as MW1,readFileSync as JD0}from"node:fs";async function QD0($,I,q,z,U){if($==="batch-records"||$==="records"){let Y=I??C(U.options.batchId)??C(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation batch-records <batchId>");await F0("seal_simulation_batch_records_get",q,z,{batchId:Y,query:C(U.options.query)},W0(U.options));return}if($==="create"||$==="run"){let Y=C(U.options.mode)??C(U.options.sourceSystem)??C(U.options["source-system"])??"hosecloud",J=Y==="material-pack"?"material_pack":Y,Q=C(U.options.schemaConfig)??C(U.options["schema-config"]),w=Q?JSON.parse(JD0(Q,"utf8")):void 0,K=C(U.options.input),H=K?JSON.parse(JD0(K,"utf8")):z$(U.json),G=C(U.options.packageId)??C(U.options["package-id"]),W=V6(U.options.packageIds)??V6(U.options["package-ids"])??(G?[G]:void 0),V=V6(U.options.flowIds)??V6(U.options["flow-ids"])??V6(U.options.documentSn)??V6(U.options["document-sn"]),X=C(U.options.signKey)??C(U.options["sign-key"])??C(U.options.integration),L=O0(U.options.noWait)??O0(U.options["no-wait"]);await F0("seal_simulation_batch_create",q,z,{mode:J,sourceSystem:J,flowIds:V,documentSn:V,rejectNodeName:C(U.options.rejectNode)??C(U.options["reject-node"])??null,thinkingDepthOverride:C(U.options.thinkingDepth)??C(U.options["thinking-depth"]),skipInvoiceGeneration:O0(U.options.skipInvoiceGeneration)??O0(U.options["skip-invoice-generation"]),skipExpenseExtraction:O0(U.options.skipExpenseExtraction)??O0(U.options["skip-expense-extraction"]),disableAttachmentCache:O0(U.options.disableAttachmentCache)??O0(U.options["disable-attachment-cache"]),signKey:X,packageIds:W,packageId:G,templateId:C(U.options.templateId)??C(U.options["template-id"]),schemaConfig:w,requestIds:V6(U.options.requestIds)??V6(U.options["request-ids"]),workflowTypeId:C(U.options.workflowTypeId)??C(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:C(U.options.documentType)??C(U.options["document-type"]),startTime:i0(U.options.startTime)??i0(U.options["start-time"]),endTime:i0(U.options.endTime)??i0(U.options["end-time"]),status:V6(U.options.status),limit:i0(U.options.limit),noWait:L,rawParams:H},W0(U.options));return}if($==="wait"){let Y=I??C(U.options.batchId)??C(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s]");await F0("seal_simulation_batch_wait",q,z,{batchId:Y,timeout:C(U.options.timeout),pollInterval:C(U.options.pollInterval)??C(U.options["poll-interval"])},W0(U.options));return}if($==="status"){let Y=I??C(U.options.batchId)??C(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation status <batchId>");await F0("seal_simulation_batch_status",q,z,{batchId:Y},W0(U.options));return}if($==="clean"||$==="delete"){let Y=I??C(U.options.batchId)??C(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation clean <batchId>");await F0("seal_simulation_batch_clean",q,z,{batchId:Y},W0(U.options));return}if($==="specifications"){let Y=I??C(U.options.integration)??C(U.options.signKey)??C(U.options["sign-key"]);await F0("seal_simulation_specifications_list",q,z,{signKey:Y},W0(U.options));return}if($==="approval-definitions"||$==="definitions"){await F0("seal_simulation_feishu_approval_definitions_list",q,z,{},W0(U.options));return}if($==="list"){await F0("seal_simulation_batches_list",q,z,{limit:i0(U.options.limit)},W0(U.options));return}if($==="get"){let Y=I??C(U.options.batchId)??C(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation get <batchId>");await F0("seal_simulation_batch_get",q,z,{batchId:Y},W0(U.options));return}if($==="templates"){await F0("seal_simulation_templates_get",q,z,{},W0(U.options));return}if($==="integrations"){await F0("seal_simulation_integrations_get",q,z,{},W0(U.options));return}if($==="package-upload"){let Y=I??C(U.options.file);if(!Y)throw Error("Usage: seal-use simulation package-upload <材料包.zip>");if(!MW1(Y))throw Error(`Filenotfound:${Y}`);await F0("seal_simulation_material_package_upload",q,z,{filePath:Y},W0(U.options));return}throw Error(`Unknownsimulationcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}import{existsSync as wD0}from"node:fs";import{join as HO}from"node:path";function KD0($,I,q){if($==="dump"||$==="cat"||$==="show"){process.stdout.write(`${xL0()}
`);return}if($==="install"||$==="init"||$==="sync"){let z=O0(q.options.local)||O0(q.options.workspace),U=C(q.options.dir)??C(q.options.target)??I,Y=U?U:z?HO(process.cwd(),".agents","skills","seal-use"):AI(),J=Wx(Y);E0({installed:!0,targetDir:J.targetDir,fileCount:J.files.length,files:J.files});return}if($==="status"||$==="get"||!$){let z=AI(),U=HO(process.cwd(),".agents","skills","seal-use");E0({global:{dir:z,installed:wD0(HO(z,"SKILL.md"))},local:{dir:U,installed:wD0(HO(U,"SKILL.md"))}});return}throw Error(`Unknownskillcommand:${$}.Run'seal-use help'foravailablecommands.`)}async function HD0($,I){if($==="config"){E0(await iU(I));return}throw Error(`Unknownsourcecommand:${$??""}.Run'seal-use help'foravailablecommands.`)}async function GD0($,I,q,z){if(!$)throw Error("Usage: seal-use tool <toolName> [--json '{...}']");await F0($,I,q,z$(z.json),W0(z.options))}function WD0(){E0(jw.map(($)=>({name:$.name,description:$.description})))}import{chmodSync as AW1,mkdirSync as PW1,renameSync as gx,rmSync as TW1,unlinkSync as DD0,writeFileSync as VD0}from"node:fs";import{dirname as EW1,join as ZD0}from"node:path";import{spawnSync as TI}from"node:child_process";function GO($=process.execPath,I=import.meta.url){if(I.includes("/$bunfs/")||I.includes("\\$bunfs\\"))return!0;let q=$.toLowerCase().replace(/\\/g,"/");return!q.endsWith("/bun")&&!q.endsWith("/bun.exe")&&!q.endsWith("/node")&&!q.endsWith("/node.exe")}var OD0="yunyingk/seal-use",bw="yunyingk/seal-home";var BW1="SEAL_USE_GITHUB_REPO",jW1="SEAL_HOME_GITHUB_REPO";async function FD0($,I={}){let q={appRoot:$.appRoot,entryFile:$.entryFile,stateDir:Bx,version:s0,launcher:$.launcher},z=I.repo||process.env[BW1]?.trim()||process.env[jW1]?.trim()||OD0,U=I.targetVersion?.trim(),Y=U&&U.toLowerCase()!=="latest"?U:void 0;if(Y){let A=Y.replace(/^v/,""),g=ND0(A,s0);if(g<0)if(!zB&&I.force);else{E0({updated:!1,currentVersion:s0,targetVersion:A,mode:GO()?"binary":"source",message:!zB?`Cannotdowngradeseal-usefromdevbuildv${s0}toreleasev${A}.Use--forcetooverwrite.`:`Cannotdowngradeseal-usefromv${s0}toolderversionv${A}.Updatesmustbeforward-only.`});return}if(g===0&&!I.force){E0({updated:!1,currentVersion:s0,targetVersion:A,mode:GO()?"binary":"source",message:`seal-useisalreadyatversionv${s0}.Use--forcetoreinstall.`});return}}if(I.changelogOnly){let A=await vx(z,I.limit??10);E0({currentVersion:s0,totalQueried:A.length,releases:A.map((g)=>({version:g.version,tagName:g.tagName,publishedAt:g.publishedAt,author:g.author,releaseNotes:g.notes,releaseUrl:g.htmlUrl,isCurrent:g.version===s0,isNewer:nw(g.version,s0)}))});return}if(!GO()){if(I.checkOnly){let g=await vx(z,30),k=g[0],S=k?.version??s0,f=g.find((i)=>i.version===s0),v=nw(S,s0),p=g.filter((i)=>nw(i.version,s0));E0({updated:!1,updateAvailable:v,currentVersion:s0,currentVersionPublishedAt:f?.publishedAt,latestVersion:S,latestVersionPublishedAt:k?.publishedAt,behindCount:p.length,pendingReleases:p.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=cU(q).running;if(A)await PI("stop",q);try{LD0("git",["-C",$.appRoot,"pull","--ff-only"])}catch(g){console.error(`gitpullskipped:${ginstanceofError?g.message:String(g)}`)}if(LD0("bun",["install"],{cwd:$.appRoot}),A)await PI("start",q);E0({updated:!0,serviceRestarted:A,version:s0,mode:"source"});return}let J=gW1(),Q=vW1(),w=await vx(z,30),K=Y?w.find((A)=>A.version===Y||A.tagName===Y||A.tagName===`v${Y}`)??await XD0(z,Y):w[0]??await XD0(z);if(!K){E0({updated:!1,currentVersion:s0,mode:"binary",message:`Failedtoqueryreleasesfromrepository'${z}'`});return}let H=K.version,G=w.find((A)=>A.version===s0),W=nw(H,s0),V=W||Boolean(I.force),X=w.filter((A)=>nw(A.version,s0));if(I.checkOnly){E0({updated:!1,updateAvailable:W,currentVersion:s0,currentVersionPublishedAt:G?.publishedAt,latestVersion:H,latestVersionPublishedAt:K.publishedAt,behindCount:X.length,pendingReleases:X.map((A)=>({version:A.version,tagName:A.tagName,publishedAt:A.publishedAt,author:A.author,releaseNotes:A.notes,releaseUrl:A.htmlUrl})),releaseNotes:K.notes,releaseUrl:K.htmlUrl,mode:"binary"});return}if(!V){E0({updated:!1,currentVersion:s0,currentVersionPublishedAt:G?.publishedAt,latestVersion:H,latestVersionPublishedAt:K.publishedAt,mode:"binary",message:`seal-useisalreadyuptodate(v${s0})`});return}let L=RW1(K.assets,J,Q);if(!L)throw Error(`Nocompatiblebinaryfoundfor${J}-${Q}inreleasev${H}.Availableassets:${K.assets.map((A)=>A.name).join(", ")}`);let D=cU(q).running;if(D)await PI("stop",q);let O=process.execPath,P=EW1(O),T=ZD0(P,`.tmp-update-${Date.now()}`);PW1(T,{recursive:!0});try{let A=ZD0(T,L.name);await CW1(L.downloadUrl,A,K.tagName,L.name);let g=A;if(L.name.endsWith(".tar.gz")||L.name.endsWith(".tgz"))g=_W1
Line truncated
`)}catch{}}async function CW1($,I,q,z){let U=Rx(),Y=[],J=q?q.startsWith("v")?q:`v${q}`:void 0,Q=z||$.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/${OD0}/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 w=Array.from(new Set(Y)),K,H=6000,G=6000,W=307200,V=1e4,X=180000;for(let L=0;L<w.length;L++){let D=w[L],O=new AbortController,P="",T=(S)=>{P=S;try{O.abort()}catch{}},A=setTimeout(()=>{T("Connection timed out (no response headers within 6s)")},H),g,k;try{WO(`==> [${L+1}/${w.length}] Downloading via: ${D}`);let S=await fetch(D,{signal:O.signal});if(A)clearTimeout(A),A=void 0;if(!S.ok)throw Error(`HTTP ${S.status} ${S.statusText}`);g=setTimeout(()=>{T("Overall download time exceeded 3 minutes")},X);let f=Number(S.headers.get("content-length"))||0,v=S.body?.getReader();if(!v){let b=Buffer.from(await S.arrayBuffer());if(b.length<1000)throw Error(`Downloaded content is suspiciously small (${b.length} bytes)`);VD0(I,b),WO(`✓ Download succeeded (${(b.length/1024/1024).toFixed(1)} MB)`);return}let p=[],i=0,h=0;k=setTimeout(()=>{if(i<W){let b=(i/1024).toFixed(1);T(`Initial transfer too slow (${b} KB < 300 KB in 6s), switching mirror...`)}},G);while(!0){let b=v.read(),q0,B=new Promise((U0,G0)=>{q0=setTimeout(()=>{G0(Error("Data transfer stalled (no chunk received for 10s)"))},V)}),x;try{x=await Promise.race([b,B])}finally{if(q0)clearTimeout(q0)}let{done:c,value:r}=x;if(c)break;if(r){if(p.push(r),i+=r.length,k&&i>=W)clearTimeout(k),k=void 0;let U0=Date.now();if(U0-h>200){h=U0;let G0=f?Math.round(i/f*100):0,A0=(i/1048576).toFixed(1),v0=f?(f/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${G0}% (${A0} / ${v0} 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.17: 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.18: 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.17
short-description:Seal tenant and Hose approval automation (v0.10.17)
version:0.10.18
short-description:Seal tenant and Hose approval automation (v0.10.18)
---
# Seal Use (v0.10.17)
# Seal Use (v0.10.18)
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.
@@ -41,7 +41,7 @@ seal-use corps list
## First Rules
- Treat CLI/MCP as the Agent's execution channel, not the user's interface. Translate natural-language intent into commands yourself; never ask the user to compose CLI syntax, JSON payloads, placeholder values, or internal IDs.
- Before asking for enterprise parameters, run`seal-use corps list`. If the target is already configured, resolve its human name to the returned `id` and pass that value as `--corp`; do not ask the user to know `corpId`.
- Before asking for enterprise parameters, resolve the target enterprise: when an enterprise is named, hinted, or keyword-identifiable, ALWAYS run `seal-use corps search <keyword>` (or `seal-use corps get <corpId>` if an exact ID is known) — DO NOT dump the entire enterprise catalog with`seal-use corps list` when the target is already known. Only run `seal-use corps list` (or `corps list --env <test|production>`) for initial discovery when zero enterprise context is known. Resolve its human name to the returned `id` and pass that value as `--corp`; do not ask the user to know `corpId`. Use `seal-use corps get <corpId>` to inspect rich enterprise attributes (URLs, tenant slugs, staff IDs, environment relations, and config file locations) with sensitive secrets safely redacted.
- If no enterprise is configured, the user is installing for the first time, or the user provides credentials, an assistance link, or a browser-copied cURL, read `references/enterprise-onboarding.md` before asking questions or running setup commands.
- When the user provides a Hose/合思 `thirdparty.html` assistance link, use `seal-use corps add-link <url> [--name ...]`; the command verifies the tenant and records the temporary Seal session without echoing the link token.
- Keep enterprise identity origin separate from credential acquisition. A Hose/合思-sourced Seal tenant can be accessed with standard Hose app credentials, an assistance link, or a captured web session; receiving a Seal Bearer token does not by itself prove the tenant is Seal-native.
@@ -49,7 +49,7 @@ seal-use corps list
- Prefer compact commands first: `pick`, `--summary`, `--fields`, `attachments --summary`, `rules count`, and `rules list --summary`.
- Parse JSON stdout. Do not scrape human text.
- Do not hand-edit enterprise configs for normal setup. Use `seal-use corps ...`.
- Before write operations on rules, documents, style preferences, or publishing, fetch current state and confirm the intended mutation with the user. For supported configuration writes, prefer the universal `--dry-run` preview first (rules clear/push, `corps sync-test`, preferences, thinking-depth policies, HoseCloud configure, and Webhook add/update/delete), then use `--yes` only after reviewing its redacted `changesDiff`.
- Before write operations on rules, documents, style preferences, or publishing, fetch current state and confirm the intended mutation with the user. For supported configuration writes, prefer the universal `--dry-run` preview first (rules clear/push, `corps sync-test`, preference updates, thinking-depth policies, HoseCloud configure, and Webhook add/update/delete), then use `--yes` only after reviewing its redacted `changesDiff`.
- Knowledge document creation and deletion are now supported. Validate `contentType` and `scenarios` before creating; use `enabled: false` when the document should be withdrawn without deletion. For an explicit deletion, re-read the document and obtain confirmation before using the low-level `seal_approval_delete_document` tool.
- For customer-feedback rule remediation, show an exact field-level diff and obtain explicit approval before updating. Default to changing only the narrowest necessary part of `description`; preserve `scope`, `strictness`, and unrelated clauses unless the user explicitly approves otherwise.
- Resolve and lock the target enterprise `corpId` before diagnosis or mutation. Never assume the current tenant is the customer tenant. Re-fetch the target rule immediately before updating, then verify the draft and newly published version after writing.
@@ -58,8 +58,18 @@ seal-use corps list
- When returning ANY authorization, login, or delegation links (e.g. 合思授权链接, Seal授权链接/委托链接), ALWAYS provide BOTH a code block (` ```text ... ``` `) for easy copying without accidental default browser redirection, AND a clickable hyperlink.
- For delegation links, always prefer `seal-use delegation create` over `users delegation` for link generation to ensure persistent token tracking.
- Never treat “Seal 协助/Seal 授权/委托” as a 合思授权入口. They are different links and must use different commands.
- For approval run links (`seal-use approval-runs url <recordId> [--corp <corpId>]`):
- Always default to returning the clean deep link (`type: 'deep_link'`), which contains no credentials and requires no sensitive access. Users in their authorized browsers open it directly with zero token leakage risk.
- ONLY provide an SSO link (`--sso`) when the user explicitly requests an unauthenticated/cross-browser/no-login/免密 link and acknowledges risks.
- When returning an `--sso` link, the Agent MUST:
1. Declare the 4 mandatory security disclosures:
- 身份主体(Identity attribution: name and admin status)
- 权限范围(Full Seal AI operation permissions under this user)
- 时效性(2-hour provisional ticket TTL, 30-day session after opening)
- 安全与防扩散边界(No Hose main system access, strictly internal, never share to public/external groups)
2. Provide BOTH a code block (` ```text ... ``` `) and a clickable hyperlink.
- In the default stateless mode, every enterprise command requires `--corp <corpId>`. In stateful mode, omitting `--corp` uses the configured default enterprise and is unsafe for an explicitly named enterprise.
- For an explicitly named enterprise, first resolve it with `seal-use corps list`, then pass its exact `corpId` to every command. After creation, verify the returned URL host matches that enterprise's Seal tenant; if the host is the current/default tenant or cannot be verified, do not present the link as the target enterprise's link.
- For an explicitly named enterprise, resolve it directly with `seal-use corps search <name>` (or `seal-use corps get <corpId>` if given an exact ID) rather than dumping all enterprises with `seal-use corps list`. Then pass its exact `corpId` to every command. After creation, verify the returned URL host matches that enterprise's Seal tenant; if the host is the current/default tenant or cannot be verified, do not present the link as the target enterprise's link.
- User-facing Seal tenant assistance link (Seal 协助/Seal 授权/委托): resolve the named enterprise first, then run `seal-use delegation create --corp <corpId> --note '<enterprise>'`; verify the returned hostname is that tenant's Seal hostname. Always provide BOTH a code block (` ```text ... ``` `) AND a hyperlink.
- Packaged customer feedback → approval-rule remediation: read `references/customer-feedback-rule-remediation.md`. Use this route for WeChat messages, screenshots, rejection notifications, document numbers, customer complaints, expected approval behavior, rule-only mitigation, exact diffs, or requests to update and publish a rule version.
`seal-use update` updates the git checkout, runs `bun install`, and restarts the local service if it was running.
Identity and session:
System diagnostic & embedded architecture specifications:
-`seal-use doctor [--quiet]` executes a comprehensive read-only environment diagnostic health check (runtime executable, filesystem paths health, enterprise assets summary, daemon status) with zero disk footprint.
-`seal-use doctor guide` reads the complete embedded system architecture & directory specification whitepaper directly from binary memory without touching disk.
-`seal-use doctor paths` outputs compact JSON audit of all filesystem paths touched by the CLI.
Enterprise and tenant management:
-`seal-use corps list [query] [--env <production|test>] [--strict] [--corp <corpId>]`
-`seal-use corps search <query> [--env <production|test>] [--strict]` (intelligent soft search by default: case-insensitive, Chinese homophones, front/back nasal vowels, flat/retroflex consonants, initials, typo/missing letter tolerance; pass `--strict` for exact substring match)
-`seal-use corps get <corpId>` (rich enterprise attributes with sensitive secrets safely redacted)
Webhook writes read the current AI approval config and POST the merged full config back to `api/v1/agent/ai-approval/config`, preserving non-Webhook integrations. List/get mask `secret` by default; add returns the generated secret once. Each Webhook can also store a mutable `materialPackFilePolicy` with `minFileSizeBytes`, optional `maxFileSizeBytes`, and `allowedExtensions`. Update is a patch: omitted policy fields are retained; `allowedExtensions` replaces the complete list; `--clear-max-file-size` removes the upper bound.
@@ -34,9 +34,13 @@ Treat chat text as the customer's expected behavior, not proof of the current Se
## 2. Resolve and lock the enterprise
List configured enterprises first:
When the customer feedback mentions or hints at the enterprise name, resolve it directly with targeted search rather than dumping the full enterprise list:
@@ -8,11 +8,21 @@ Run this before asking for setup parameters (if `seal-use` is not installed, fir
```bash
seal-use version
# 当用户已提及企业名称或关键字时,优先运行精准搜索:
seal-use corps search <keyword> [--env production|test]
# 仅在完全没有企业线索或初次安装引导时运行全量列表:
seal-use corps list
# 查看目标企业完整富属性(含 Seal 域名、租户 Slug、合思域名、配置来源路径等,安全脱敏):
seal-use corps get <corpId>
```
- If `seal-use` is not installed on the system, run the curl install script above to install it.
- If the target enterprise is listed, match the user's human enterprise name to its returned `id` and use that value as `--corp` on every command. Do not ask the user for `corpId`.
- If the user provided an enterprise name or keyword, prioritize `seal-use corps search <keyword>` to locate it without dumping all enterprises. Match the user's human enterprise name to its returned `id` and use that value as `--corp` on every command. Do not ask the user for `corpId`.
- If zero enterprise context is known, run `seal-use corps list`.
- To inspect full endpoint URLs, tenant slug, config file location, and staff bindings of a configured enterprise, run `seal-use corps get <corpId>`.
- If multiple configured enterprises plausibly match, show their human names and let the user choose. Keep their IDs as implementation details.
- If none are configured, ask one plain-language question: “你现在手上有哪一种接入材料:合思开放平台 appKey/appSecurity、合思授权/协助链接、Seal 协助链接,还是从已登录的合思或 Seal 网页复制的 cURL?”
{flag:"<recordId>",description:"Approval run record ID to replay"},
{flag:"--sn <sn>",description:"Lookup approval record by source document SN if recordId not given"},
{flag:"--webhook <idOrName>",description:"Target Webhook integration (auto-locks if only one exists)"},
{flag:"--source-corp <corpId>",description:"Source enterprise where the approval record resides (default: active)"},
{flag:"--sn-suffix <str>",description:"Optional suffix appended to documentSN and documentId"},
{flag:"--sn-prefix <str>",description:"Optional prefix prepended to documentSN and documentId"},
{flag:"--dry-run",description:"Generate and output Webhook payload JSON without sending HTTP request"}
],
description:"Extracts structured form fields from any historical approval record (Webhook or Hose source), sanitizes field types, and pushes a new document to the target Webhook channel."
thrownewError("recordId or sourceDocumentSN is required to generate an SSO approval result URL");
}
if(source.type!=="hose"){
thrownewError(
`SSO direct links currently support Hose-integrated enterprises (corp '${context.corp.id}' uses '${source.type}'). For Seal-native enterprises, use 'seal-use delegation create' for authorized access.`
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.