git diff --exit-code dist/openapi.json || (echo "::error::dist/openapi.json is out of sync with openapi/openapi.yaml. Run 'bun run openapi:bundle' and commit changes." && exit 1)
- name:Build MCP Plugin & Validate Sync
- name:Build MCP Plugin & Verify
run:|
bun run build:plugin
git diff --exit-code dist/mcp/server.js || (echo "::error::dist/mcp/server.js is out of sync. Run 'bun run build:plugin' and commit changes." && exit 1)
@@ -5,6 +5,25 @@ All notable changes to `seal-home` will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.9.7] - 2026-09-01
### Enhanced
- **Agent-first Enterprise Onboarding**: Added a dedicated first-run workflow that makes Agents discover configured enterprises before asking users for parameters, resolves human enterprise names to internal IDs, and avoids asking users for discoverable `corpId`, `staffId`, or tenant identifiers.
- **Identity and Credential Classification**: Clearly separated Hose/合思-sourced versus Seal-native tenant identity from the way access was obtained: standard Hose app credentials, incoming assistance links, or browser-copied cURL sessions.
- **Browser cURL Guidance and Secret Handling**: Added concrete F12/Network/Fetch-XHR capture instructions, read-only verification guidance, credential redaction rules, and explicit boundaries for raw cURL and assistance-link capabilities not yet supported by the CLI.
- **Simplified Hose Setup Routing**: Updated the standard Hose path to request only `appKey` and `appSecurity` initially, while automatically discovering the domain, enterprise, and administrator candidates.
---
## [0.9.6] - 2026-08-27
### Fixed & Enhanced
- **Smart Download Speed & Stall Monitor**: Added dynamic transfer speed monitoring with a 50 KB/s low-speed threshold and 5s stall detection in `seal-home update`, allowing fast downloads to complete without artificial timeouts while proactively abandoning crawling mirrors.
import{createRequireas$j}from"node:module";varij=Object.create;var{getPrototypeOf:nj,defineProperty:o$,getOwnPropertyNames:rj}=Object;vartj=Object.prototype.hasOwnProperty;functionoj(i){returnthis[i]}varuj,lj,V0=(i,n,t)=>{varo=i!=null&&typeofi==="object";if(o){varr=n?uj??=newWeakMap:lj??=newWeakMap,u=r.get(i);if(u)returnu}t=i!=null?ij(nj(i)):{};letl=n||!i||!i.__esModule?o$(t,"default",{value:i,enumerable:!0}):t;for(leteofrj(i))if(!tj.call(l,e))o$(l,e,{get:oj.bind(i,e),enumerable:!0});if(o)r.set(i,l);returnl};varQ=(i,n)=>()=>(n||i((n={exports:{}}).exports,n),n.exports);varej=(i)=>i;functionvj(i,n){this[i]=ej.bind(null,n)}varHn=(i,n)=>{for(vartinn)o$(i,t,{get:n[t],enumerable:!0,configurable:!0,set:vj.bind(n,t)})};varT0=$j(import.meta.url);varRo=Q((w1)=>{Object.defineProperty(w1,"__esModule",{value:!0});w1.regexpCode=w1.getEsmExportName=w1.getProperty=w1.safeStringify=w1.stringify=w1.strConcat=w1.addCodeArg=w1.str=w1._=w1.nil=w1._Code=w1.Name=w1.IDENTIFIER=w1._CodeOrName=void0;classPe{}w1._CodeOrName=Pe;w1.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;classWtextendsPe{constructor(i){super();if(!w1.IDENTIFIER.test(i))throwError("CodeGen: name must be a valid identifier");this.str=i}toString(){returnthis.str}emptyStr(){return!1}getnames(){return{[this.str]:1}}}w1.Name=Wt;classfnextendsPe{constructor(i){super();this._items=typeofi==="string"?[i]:i}toString(){returnthis.str}emptyStr(){if(this._items.length>1)return!1;leti=this._items[0];returni===""||i==='""'}getstr(){vari;return(i=this._str)!==null&&i!==void0?i:this._str=this._items.reduce((n,t)=>`${n}${t}`,"")}getnames(){vari;return(i=this._names)!==null&&i!==void0?i:this._names=this._items.reduce((n,t)=>{if(tinstanceofWt)n[t.str]=(n[t.str]||0)+1;returnn},{})}}w1._Code=fn;w1.nil=newfn("");functiong1(i,...n){lett=[i[0]],o=0;while(o<n.length)S6(t,n[o]),t.push(i[++o]);returnnewfn(t)}w1._=g1;varc6=newfn("+");functionb1(i,...n){lett=[mo(i[0])],o=0;while(o<n.length)t.push(c6),S6(t,n[o]),t.push(c6,mo(i[++o]));returnY8(t),newfn(t)}w1.str=b1;functionS6(i,n){if(ninstanceoffn)i.push(...n._items);elseif(ninstanceofWt)i.push(n);elsei.push(H8(n))}w1.addCodeArg=S6;functionY8(i){letn=1;while(n<i.length-1){if(i[n]===c6){lett=P8(i[n-1],i[n+1]);if(t!==void0){i.splice(n-1,3,t);continue}i[n++]="+"}n++}}functionP8(i,n){if(n==='""')returni;if(i==='""')returnn;if(typeofi=="string"){if(ninstanceofWt||i[i.length-1]!=='"')return;if(typeofn!="string")return`${i.slice(0,-1)}${n}"`;if(n[0]==='"')returni.slice(0,-1)+n.slice(1);return}if(typeofn=="string"&&n[0]==='"'&&!(iinstanceofWt))return`"${i}${n.slice(1)}`;return}functionQ8(i,n){returnn.emptyStr()?i:i.emptyStr()?n:b1`${i}${n}`}w1.strConcat=Q8;functionH8(i){returntypeofi=="number"||typeofi=="boolean"||i===null?i:mo(Array.isArray(i)?i.join(","):i)}functionF8(i){returnnewfn(mo(i))}w1.stringify=F8;functionmo(i){returnJSON.stringify(i).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}w1.safeStringify=mo;functionK8(i){returntypeofi=="string"&&w1.IDENTIFIER.test(i)?newfn(`.${i}`):g1`[${i}]`}w1.getProperty=K8;functionB8(i){if(typeofi=="string"&&w1.IDENTIFIER.test(i))returnnewfn(`${i}`);throwError(`CodeGen: invalid export name: ${i}, use explicit $id name mapping`)}w1.getEsmExportName=B8;functionV8(i){returnnewfn(i.toString())}w1.regexpCode=V8});varL6=Q((c1)=>{Object.defineProperty(c1,"__esModule",{value:!0});c1.ValueScope=c1.ValueScopeName=c1.Scope=c1.varKinds=c1.UsedValueState=void0;varxi=Ro();classD1extendsError{constructor(i){super(`CodeGen: "code" for ${i} not defined`);this.value=i.value}}varHe;(function(i){i[i.Started=0]="Started",i[i.Completed=1]="Completed"})(He||(c1.UsedValueState=He={}));c1.varKinds={const:newxi.Name("const"),let:newxi.Name("let"),var:newxi.Name("var")};classA6{constructor({prefixes:i,parent:n}={}){this._names={},this._prefixes=i,this._parent=n}toName(i){returniinstanceofxi.Name?i:this.name(i)}name(i){returnnewxi.Name(this._newName(i))}_newName(i){letn=this._names[i]||this._nameGroup(i);return`${i}${n.index++}`}_nameGroup(i){varn,t;if(((t=(n=this._parent)===null||n===void0?void0:n._prefixes)===null||t===void0?void0:t.has(i))||this._prefixes&&!this._prefixes.has(i))throwError(`CodeGen: prefix "${i}" is not allowed in this scope`);returnthis._names[i]={prefix:i,index:0}}}c1.Scope=A6;classN6extendsxi.Name{constructor(i,n){super(n);this.prefix=i}setValue(i,{property:n,itemIndex:t}){this.value=i,this.scopePath=xi._`.${newxi.Name(n)}[${t}]`}}c1.ValueScopeName=N6;varR8=xi._`\n`;classU1extendsA6{constructor(i){super(i);this._values={},this._scope=i.scope,this.opts={...i,_n:i.lines?R8:xi.nil}}get(){returnthis._scope}name(i){returnnewN6(i,this._newName(i))}value(i,n){vart;if(n.ref===void0)throwError("CodeGen: ref must be passed in value");leto=this.toName(i),{prefix:r}=o,u=(t=n.key)!==null&&t!==void0?t:n.ref,l=this._values[r];if(l){letI=l.get(u);if(I)returnI}elsel=this._values[r]=newLine truncated
`:""},this._extScope=i,this._scope=new Dn.Scope({parent:i}),this._nodes=[new j1]}toString(){return this._root.render(this.opts)}name(i){return this._scope.name(i)}scopeName(i){return this._extScope.name(i)}scopeValue(i,n){let t=this._extScope.value(i,n);return(this._values[t.prefix]||(this._values[t.prefix]=new Set)).add(t),t}getScopeValue(i,n){return this._extScope.getValue(i,n)}scopeRefs(i){return this._extScope.scopeRefs(i,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(i,n,t,o){let r=this._scope.toName(n);if(t!==void 0&&o)this._constants[r.str]=t;return this._leafNode(new O1(i,r,t)),r}const(i,n,t){return this._def(Dn.varKinds.const,i,n,t)}let(i,n,t){return this._def(Dn.varKinds.let,i,n,t)}var(i,n,t){return this._def(Dn.varKinds.var,i,n,t)}assign(i,n,t){return this._leafNode(new j6(i,n,t))}add(i,n){return this._leafNode(new A1(i,ai.operators.ADD,n))}code(i){if(typeof i=="function")i();else if(i!==x.nil)this._leafNode(new G1(i));return this}object(...i){let n=["{"];for(let[t,o]of i){if(n.length>1)n.push(",");if(n.push(t),t!==o||this.opts.es5)n.push(":"),(0,x.addCodeArg)(n,o)}return n.push("}"),new x._Code(n)}if(i,n,t){if(this._blockNode(new Tn(i)),n&&t)this.code(n).else().code(t).endIf();else if(n)this.code(n).endIf();else if(t)throw Error('CodeGen: "else" body without "then" body');return this}elseIf(i){return this._elseNode(new Tn(i))}else(){return this._elseNode(new xo)}endIf(){return this._endBlockNode(Tn,xo)}_for(i,n){if(this._blockNode(i),n)this.code(n).endFor();return this}for(i,n){return this._for(new W1(i),n)}forRange(i,n,t,o,r=this.opts.es5?Dn.varKinds.var:Dn.varKinds.let){let u=this._scope.toName(i);return this._for(new y1(r,u,n,t),()=>o(u))}forOf(i,n,t,o=Dn.varKinds.const){let r=this._scope.toName(i);if(this.opts.es5){let u=n instanceof x.Name?n:this.var("_arr",n);return this.forRange("_i",0,x._`${u}.length`,(l)=>{this.var(r,x._`${u}[${l}]`),t(r)})}return this._for(new k6("of",o,r,n),()=>t(r))}forIn(i,n,t,o=this.opts.es5?Dn.varKinds.var:Dn.varKinds.const){if(this.opts.ownProperties)return this.forOf(i,x._`Object.keys(${n})`,t);let r=this._scope.toName(i);return this._for(new k6("in",o,r,n),()=>t(r))}endFor(){return this._endBlockNode(yt)}label(i){return this._leafNode(new N1(i))}break(i){return this._leafNode(new L1(i))}return(i){let n=new Ke;if(this._blockNode(n),this.code(i),n.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(Ke)}try(i,n,t){if(!n&&!t)throw Error('CodeGen: "try" without "catch" and "finally"');let o=new J1;if(this._blockNode(o),this.code(i),n){let r=this.name("e");this._currNode=o.catch=new Be(r),n(r)}if(t)this._currNode=o.finally=new Ve,this.code(t);return this._endBlockNode(Be,Ve)}throw(i){return this._leafNode(new k1(i))}block(i,n){if(this._blockStarts.push(this._nodes.length),i)this.code(i).endBlock(n);return this}endBlock(i){let n=this._blockStarts.pop();if(n===void 0)throw Error("CodeGen: not in self-balancing block");let t=this._nodes.length-n;if(t<0||i!==void 0&&t!==i)throw Error(`CodeGen:wrongnumberofnodes:${t}vs${i}expected`);return this._nodes.length=n,this}func(i,n=x.nil,t,o){if(this._blockNode(new Fe(i,n,t)),o)this.code(o).endFunc();return this}endFunc(){return this._endBlockNode(Fe)}optimize(i=1){while(i-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(i){return this._currNode.nodes.push(i),this}_blockNode(i){this._currNode.nodes.push(i),this._nodes.push(i)}_endBlockNode(i,n){let t=this._currNode;if(t instanceof i||n&&t instanceof n)return this._nodes.pop(),this;throw Error(`CodeGen:notinblock"${n?`${i.kind}/${n.kind}`:i.kind}"`)}_elseNode(i){let n=this._currNode;if(!(n instanceof Tn))throw Error('CodeGen: "else" without "if"');return this._currNode=n.else=i,this}get _root(){return this._nodes[0]}get _currNode(){let i=this._nodes;return i[i.length-1]}set _currNode(i){let n=this._nodes;n[n.length-1]=i}}ai.CodeGen=X1;function Jr(i,n){for(let t in n)i[t]=(i[t]||0)+(n[t]||0);return i}function Te(i,n){return n instanceof x._CodeOrName?Jr(i,n.names):i}function Jt(i,n,t){if(i instanceof x.Name)return o(i);if(!r(i))return i;return new x._Code(i._items.reduce((u,l)=>{if(l instanceof x.Name)l=o(l);if(l instanceof x._Code)u.push(...l._items);else u.push(l);return u},[]));function o(u){let l=t[u.str];if(l===void 0||n[u.str]!==1)return u;return delete n[u.str],l}function r(u){return u instanceof x._Code&&u._items.some((l)=>l instanceof x.Name&&n[l.str]===1&&t[l.str]!==void 0)}}function i9(i,n){for(let t in n)i[t]=(i[t]||0)-(n[t]||0)}function Y1(i){return typeof i=="boolean"||typeof i=="number"||i===null?!i:x._`!${G6(i)}`}ai.not=Y1;var n9=P1(ai.operators.AND);function r9(...i){return i.reduce(n9)}ai.and=r9;var t9=P1(ai.operators.OR);function o9(...i){return i.reduce(t9)}ai.or=o9;function P1(i){return(n,t)=>n===x.nil?t:t===x.nil?n:x._`${G6(n)}${i}${G6(t)}`}function G6(i){return i instanceof x.Name?i:x._`(${i})`}});var s=Q((q1)=>{Object.
Line truncated
import{createRequireasSd}from"node:module";var$d=Object.create;var{getPrototypeOf:Id,defineProperty:I$,getOwnPropertyNames:gd}=Object;varbd=Object.prototype.hasOwnProperty;functionwd(n){returnthis[n]}varfd,cd,T4=(n,i,r)=>{varo=n!=null&&typeofn==="object";if(o){vart=i?fd??=newWeakMap:cd??=newWeakMap,u=t.get(n);if(u)returnu}r=n!=null?$d(Id(n)):{};lete=i||!n||!n.__esModule?I$(r,"default",{value:n,enumerable:!0}):r;for(letlofgd(n))if(!bd.call(e,l))I$(e,l,{get:wd.bind(n,l),enumerable:!0});if(o)t.set(n,e);returne};varP=(n,i)=>()=>(i||n((i={exports:{}}).exports,i),i.exports);varDd=(n)=>n;functionUd(n,i){this[n]=Dd.bind(null,i)}varQi=(n,i)=>{for(varrini)I$(n,r,{get:i[r],enumerable:!0,configurable:!0,set:Ud.bind(i,r)})};var_4=Sd(import.meta.url);varso=P((SU)=>{Object.defineProperty(SU,"__esModule",{value:!0});SU.regexpCode=SU.getEsmExportName=SU.getProperty=SU.safeStringify=SU.stringify=SU.strConcat=SU.addCodeArg=SU.str=SU._=SU.nil=SU._Code=SU.Name=SU.IDENTIFIER=SU._CodeOrName=void0;classQl{}SU._CodeOrName=Ql;SU.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;classWrextendsQl{constructor(n){super();if(!SU.IDENTIFIER.test(n))throwError("CodeGen: name must be a valid identifier");this.str=n}toString(){returnthis.str}emptyStr(){return!1}getnames(){return{[this.str]:1}}}SU.Name=Wr;classciextendsQl{constructor(n){super();this._items=typeofn==="string"?[n]:n}toString(){returnthis.str}emptyStr(){if(this._items.length>1)return!1;letn=this._items[0];returnn===""||n==='""'}getstr(){varn;return(n=this._str)!==null&&n!==void0?n:this._str=this._items.reduce((i,r)=>`${i}${r}`,"")}getnames(){varn;return(n=this._names)!==null&&n!==void0?n:this._names=this._items.reduce((i,r)=>{if(rinstanceofWr)i[r.str]=(i[r.str]||0)+1;returni},{})}}SU._Code=ci;SU.nil=newci("");functionDU(n,...i){letr=[n[0]],o=0;while(o<i.length)k6(r,i[o]),r.push(n[++o]);returnnewci(r)}SU._=DU;vary6=newci("+");functionUU(n,...i){letr=[ao(n[0])],o=0;while(o<i.length)r.push(y6),k6(r,i[o]),r.push(y6,ao(n[++o]));returnpJ(r),newci(r)}SU.str=UU;functionk6(n,i){if(iinstanceofci)n.push(...i._items);elseif(iinstanceofWr)n.push(i);elsen.push(TJ(i))}SU.addCodeArg=k6;functionpJ(n){leti=1;while(i<n.length-1){if(n[i]===y6){letr=VJ(n[i-1],n[i+1]);if(r!==void0){n.splice(i-1,3,r);continue}n[i++]="+"}i++}}functionVJ(n,i){if(i==='""')returnn;if(n==='""')returni;if(typeofn=="string"){if(iinstanceofWr||n[n.length-1]!=='"')return;if(typeofi!="string")return`${n.slice(0,-1)}${i}"`;if(i[0]==='"')returnn.slice(0,-1)+i.slice(1);return}if(typeofi=="string"&&i[0]==='"'&&!(ninstanceofWr))return`"${n}${i.slice(1)}`;return}functionqJ(n,i){returni.emptyStr()?n:n.emptyStr()?i:UU`${n}${i}`}SU.strConcat=qJ;functionTJ(n){returntypeofn=="number"||typeofn=="boolean"||n===null?n:ao(Array.isArray(n)?n.join(","):n)}function_J(n){returnnewci(ao(n))}SU.stringify=_J;functionao(n){returnJSON.stringify(n).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}SU.safeStringify=ao;functionEJ(n){returntypeofn=="string"&&SU.IDENTIFIER.test(n)?newci(`.${n}`):DU`[${n}]`}SU.getProperty=EJ;functionZJ(n){if(typeofn=="string"&&SU.IDENTIFIER.test(n))returnnewci(`${n}`);throwError(`CodeGen: invalid export name: ${n}, use explicit $id name mapping`)}SU.getEsmExportName=ZJ;functionMJ(n){returnnewci(n.toString())}SU.regexpCode=MJ});varW6=P((LU)=>{Object.defineProperty(LU,"__esModule",{value:!0});LU.ValueScope=LU.ValueScopeName=LU.Scope=LU.varKinds=LU.UsedValueState=void0;varan=so();classAUextendsError{constructor(n){super(`CodeGen: "code" for ${n} not defined`);this.value=n.value}}varhl;(function(n){n[n.Started=0]="Started",n[n.Completed=1]="Completed"})(hl||(LU.UsedValueState=hl={}));LU.varKinds={const:newan.Name("const"),let:newan.Name("let"),var:newan.Name("var")};classG6{constructor({prefixes:n,parent:i}={}){this._names={},this._prefixes=n,this._parent=i}toName(n){returnninstanceofan.Name?n:this.name(n)}name(n){returnnewan.Name(this._newName(n))}_newName(n){leti=this._names[n]||this._nameGroup(n);return`${n}${i.index++}`}_nameGroup(n){vari,r;if(((r=(i=this._parent)===null||i===void0?void0:i._prefixes)===null||r===void0?void0:r.has(n))||this._prefixes&&!this._prefixes.has(n))throwError(`CodeGen: prefix "${n}" is not allowed in this scope`);returnthis._names[n]={prefix:n,index:0}}}LU.Scope=G6;classj6extendsan.Name{constructor(n,i){super(i);this.prefix=n}setValue(n,{property:i,itemIndex:r}){this.value=n,this.scopePath=an._`.${newan.Name(i)}[${r}]`}}LU.ValueScopeName=j6;varu8=an._`\n`;classNUextendsG6{constructor(n){super(n);this._values={},this._scope=n.scope,this.opts={...n,_n:n.lines?u8:an.nil}}get(){returnthis._scope}name(n){returnnewj6(n,this._newName(n))}value(n,i){varr;if(i.ref===void0)throwError("CodeGen: ref must be passed in value");leto=this.toName(n),{prefix:t}=o,u=(r=i.key)!==null&&r!==void0?r:i.ref,e=this._values[t];if(e){letI=e.get(u);if(I)returnI}elsee=this._values[t]=newLine truncated
`:""},this._extScope=n,this._scope=new Di.Scope({parent:n}),this._nodes=[new XU]}toString(){return this._root.render(this.opts)}name(n){return this._scope.name(n)}scopeName(n){return this._extScope.name(n)}scopeValue(n,i){let r=this._extScope.value(n,i);return(this._values[r.prefix]||(this._values[r.prefix]=new Set)).add(r),r}getScopeValue(n,i){return this._extScope.getValue(n,i)}scopeRefs(n){return this._extScope.scopeRefs(n,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(n,i,r,o){let t=this._scope.toName(i);if(r!==void 0&&o)this._constants[t.str]=r;return this._leafNode(new kU(n,t,r)),t}const(n,i,r){return this._def(Di.varKinds.const,n,i,r)}let(n,i,r){return this._def(Di.varKinds.let,n,i,r)}var(n,i,r){return this._def(Di.varKinds.var,n,i,r)}assign(n,i,r){return this._leafNode(new Y6(n,i,r))}add(n,i){return this._leafNode(new dU(n,sn.operators.ADD,i))}code(n){if(typeof n=="function")n();else if(n!==s.nil)this._leafNode(new JU(n));return this}object(...n){let i=["{"];for(let[r,o]of n){if(i.length>1)i.push(",");if(i.push(r),r!==o||this.opts.es5)i.push(":"),(0,s.addCodeArg)(i,o)}return i.push("}"),new s._Code(i)}if(n,i,r){if(this._blockNode(new pi(n)),i&&r)this.code(i).else().code(r).endIf();else if(i)this.code(i).endIf();else if(r)throw Error('CodeGen: "else" body without "then" body');return this}elseIf(n){return this._elseNode(new pi(n))}else(){return this._elseNode(new nu)}endIf(){return this._endBlockNode(pi,nu)}_for(n,i){if(this._blockNode(n),i)this.code(i).endFor();return this}for(n,i){return this._for(new YU(n),i)}forRange(n,i,r,o,t=this.opts.es5?Di.varKinds.var:Di.varKinds.let){let u=this._scope.toName(n);return this._for(new HU(t,u,i,r),()=>o(u))}forOf(n,i,r,o=Di.varKinds.const){let t=this._scope.toName(n);if(this.opts.es5){let u=i instanceof s.Name?i:this.var("_arr",i);return this.forRange("_i",0,s._`${u}.length`,(e)=>{this.var(t,s._`${u}[${e}]`),r(t)})}return this._for(new J6("of",o,t,i),()=>r(t))}forIn(n,i,r,o=this.opts.es5?Di.varKinds.var:Di.varKinds.const){if(this.opts.ownProperties)return this.forOf(n,s._`Object.keys(${i})`,r);let t=this._scope.toName(n);return this._for(new J6("in",o,t,i),()=>r(t))}endFor(){return this._endBlockNode(Jr)}label(n){return this._leafNode(new GU(n))}break(n){return this._leafNode(new jU(n))}return(n){let i=new Bl;if(this._blockNode(i),this.code(n),i.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(Bl)}try(n,i,r){if(!i&&!r)throw Error('CodeGen: "try" without "catch" and "finally"');let o=new PU;if(this._blockNode(o),this.code(n),i){let t=this.name("e");this._currNode=o.catch=new pl(t),i(t)}if(r)this._currNode=o.finally=new Vl,this.code(r);return this._endBlockNode(pl,Vl)}throw(n){return this._leafNode(new WU(n))}block(n,i){if(this._blockStarts.push(this._nodes.length),n)this.code(n).endBlock(i);return this}endBlock(n){let i=this._blockStarts.pop();if(i===void 0)throw Error("CodeGen: not in self-balancing block");let r=this._nodes.length-i;if(r<0||n!==void 0&&r!==n)throw Error(`CodeGen:wrongnumberofnodes:${r}vs${n}expected`);return this._nodes.length=i,this}func(n,i=s.nil,r,o){if(this._blockNode(new Kl(n,i,r)),o)this.code(o).endFunc();return this}endFunc(){return this._endBlockNode(Kl)}optimize(n=1){while(n-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(n){return this._currNode.nodes.push(n),this}_blockNode(n){this._currNode.nodes.push(n),this._nodes.push(n)}_endBlockNode(n,i){let r=this._currNode;if(r instanceof n||i&&r instanceof i)return this._nodes.pop(),this;throw Error(`CodeGen:notinblock"${i?`${n.kind}/${i.kind}`:n.kind}"`)}_elseNode(n){let i=this._currNode;if(!(i instanceof pi))throw Error('CodeGen: "else" without "if"');return this._currNode=i.else=n,this}get _root(){return this._nodes[0]}get _currNode(){let n=this._nodes;return n[n.length-1]}set _currNode(n){let i=this._nodes;i[i.length-1]=n}}sn.CodeGen=QU;function Xt(n,i){for(let r in i)n[r]=(n[r]||0)+(i[r]||0);return n}function ql(n,i){return i instanceof s._CodeOrName?Xt(n,i.names):n}function Xr(n,i,r){if(n instanceof s.Name)return o(n);if(!t(n))return n;return new s._Code(n._items.reduce((u,e)=>{if(e instanceof s.Name)e=o(e);if(e instanceof s._Code)u.push(...e._items);else u.push(e);return u},[]));function o(u){let e=r[u.str];if(e===void 0||i[u.str]!==1)return u;return delete i[u.str],e}function t(u){return u instanceof s._Code&&u._items.some((e)=>e instanceof s.Name&&i[e.str]===1&&r[e.str]!==void 0)}}function $8(n,i){for(let r in i)n[r]=(n[r]||0)-(i[r]||0)}function FU(n){return typeof n=="boolean"||typeof n=="number"||n===null?!n:s._`!${X6(n)}`}sn.not=FU;var I8=hU(sn.operators.AND);function g8(...n){return n.reduce(I8)}sn.and=g8;var b8=hU(sn.operators.OR);function w8(...n){return n.reduce(b8)}sn.or=w8;function hU(n){return(i,r)=>i===s.nil?r:r===s.nil?i:s._`${X6(i)}${n}${X6(r)}`}function X6(n){return n instanceof s.Name?n:s._`(${n})`}});var nn=P((ZU)=>{Object
Line truncated
deps:${t}}`};var tQ={keyword:"dependencies",type:"object",schemaType:"object",error:QO.error,code(i){let[n,t]=oQ(i);YO(i,n),PO(i,t)}};function oQ({schema:i}){let n={},t={};for(let o in i){if(o==="__proto__")continue;let r=Array.isArray(i[o])?n:t;r[o]=i[o]}return[n,t]}function YO(i,n=i.schema){let{gen:t,data:o,it:r}=i;if(Object.keys(n).length===0)return;let u=t.let("missing");for(let l in n){let e=n[l];if(e.length===0)continue;let $=(0,Du.propertyInData)(t,o,l,r.opts.ownProperties);if(i.setParams({property:l,depsCount:e.length,deps:e.join(", ")}),r.allErrors)t.if($,()=>{for(let I of e)(0,Du.checkReportMissingProp)(i,I)});else t.if(l4._`${$}&&(${(0,Du.checkMissingProp)(i,e,u)})`),(0,Du.reportMissingProp)(i,u),t.else()}}QO.validatePropertyDeps=YO;function PO(i,n=i.schema){let{gen:t,data:o,keyword:r,it:u}=i,l=t.name("valid");for(let e in n){if((0,rQ.alwaysValidSchema)(u,n[e]))continue;t.if((0,Du.propertyInData)(t,o,e,u.opts.ownProperties),()=>{let $=i.subschema({keyword:r,schemaProp:e},l);i.mergeValidEvaluated($,l)},()=>t.var(l,!0)),i.ok(l)}}QO.validateSchemaDeps=PO;QO.default=tQ});var TO=Q((VO)=>{Object.defineProperty(VO,"__esModule",{value:!0});var BO=p(),eQ=s(),vQ={message:"property name must be valid",params:({params:i})=>BO._`{propertyName:${i.propertyName}}`},$Q={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:vQ,code(i){let{gen:n,schema:t,data:o,it:r}=i;if((0,eQ.alwaysValidSchema)(r,t))return;let u=n.name("valid");n.forIn("key",o,(l)=>{i.setParams({propertyName:l}),i.subschema({keyword:"propertyNames",data:l,dataTypes:["string"],propertyName:l,compositeRule:!0},u),n.if((0,BO.not)(u),()=>{if(i.error(!0),!r.allErrors)n.break()})}),i.ok(u)}};VO.default=$Q});var e4=Q((_O)=>{Object.defineProperty(_O,"__esModule",{value:!0});var lv=In(),Sn=p(),gQ=_n(),ev=s(),bQ={message:"must NOT have additional properties",params:({params:i})=>Sn._`{additionalProperty:${i.additionalProperty}}`},wQ={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:bQ,code(i){let{gen:n,schema:t,parentSchema:o,data:r,errsCount:u,it:l}=i;if(!u)throw Error("ajv implementation error");let{allErrors:e,opts:$}=l;if(l.props=!0,$.removeAdditional!=="all"&&(0,ev.alwaysValidSchema)(l,t))return;let I=(0,lv.allSchemaProperties)(o.properties),g=(0,lv.allSchemaProperties)(o.patternProperties);b(),i.ok(Sn._`${u}===${gQ.default.errors}`);function b(){n.forIn("key",r,(N)=>{if(!I.length&&!g.length)D(N);else n.if(w(N),()=>D(N))})}function w(N){let L;if(I.length>8){let K=(0,ev.schemaRefOrVal)(l,o.properties,"properties");L=(0,lv.isOwnProperty)(n,K,N)}else if(I.length)L=(0,Sn.or)(...I.map((K)=>Sn._`${N}===${K}`));else L=Sn.nil;if(g.length)L=(0,Sn.or)(L,...g.map((K)=>Sn._`${(0,lv.usePattern)(i,K)}.test(${N})`));return(0,Sn.not)(L)}function f(N){n.code(Sn._`delete${r}[${N}]`)}function D(N){if($.removeAdditional==="all"||$.removeAdditional&&t===!1){f(N);return}if(t===!1){if(i.setParams({additionalProperty:N}),i.error(),!e)n.break();return}if(typeof t=="object"&&!(0,ev.alwaysValidSchema)(l,t)){let L=n.name("valid");if($.removeAdditional==="failing")S(N,L,!1),n.if((0,Sn.not)(L),()=>{i.reset(),f(N)});else if(S(N,L),!e)n.if((0,Sn.not)(L),()=>n.break())}}function S(N,L,K){let F={keyword:"additionalProperties",dataProp:N,dataPropType:ev.Type.Str};if(K===!1)Object.assign(F,{compositeRule:!0,createErrors:!1,allErrors:!1});i.subschema(F,L)}}};_O.default=wQ});var MO=Q((ZO)=>{Object.defineProperty(ZO,"__esModule",{value:!0});var DQ=tu(),qO=In(),v4=s(),EO=e4(),UQ={keyword:"properties",type:"object",schemaType:"object",code(i){let{gen:n,schema:t,parentSchema:o,data:r,it:u}=i;if(u.opts.removeAdditional==="all"&&o.additionalProperties===void 0)EO.default.code(new DQ.KeywordCxt(u,EO.default,"additionalProperties"));let l=(0,qO.allSchemaProperties)(t);for(let b of l)u.definedProperties.add(b);if(u.opts.unevaluated&&l.length&&u.props!==!0)u.props=v4.mergeEvaluated.props(n,(0,v4.toHash)(l),u.props);let e=l.filter((b)=>!(0,v4.alwaysValidSchema)(u,t[b]));if(e.length===0)return;let $=n.name("valid");for(let b of e){if(I(b))g(b);else{if(n.if((0,qO.propertyInData)(n,r,b,u.opts.ownProperties)),g(b),!u.allErrors)n.else().var($,!0);n.endIf()}i.it.definedProperties.add(b),i.ok($)}function I(b){return u.opts.useDefaults&&!u.compositeRule&&t[b].default!==void 0}function g(b){i.subschema({keyword:"properties",schemaProp:b,dataProp:b},$)}}};ZO.default=UQ});var CO=Q((hO)=>{Object.defineProperty(hO,"__esModule",{value:!0});var dO=In(),vv=p(),zO=s(),pO=s(),SQ={keyword:"patternProperties",type:"object",schemaType:"object",code(i){let{gen:n,schema:t,data:o,parentSchema:r,it:u}=i,{opts:l}=u,e=(0,dO.allSchemaProperties)(t),$=e.filter((S)=>(0,zO.alwaysValidSchema)(u,t[S]));if(e.length===0||$.length===e.length&&(!u.opts.unevaluated||u.props===!0))return;let I=l.strictSchema&&!l.allowMatchingProperties&&r.properties,g=n.name("valid");if(u.props!==!0&&!(u.props instanceof vv.Name))u.props=(0,pO.evalu
Line truncated
`).filter((u)=>u),o=Math.min(...t.map((u)=>u.length-u.trimStart().length)),r=t.map((u)=>u.slice(o)).map((u)=>" ".repeat(this.indent*2)+u);for(let u of r)this.content.push(u)}compile(){let i=Function,n=this?.args,o=[...(this?.content??[""]).map((r)=>`${r}`)];return new i(...n,o.join(`
`))}}var bI={major:4,minor:4,patch:3};var _=U("$ZodType",(i,n)=>{var t;i??(i={}),i._zod.def=n,i._zod.bag=i._zod.bag||{},i._zod.version=bI;let o=[...i._zod.def.checks??[]];if(i._zod.traits.has("$ZodCheck"))o.unshift(i);for(let r of o)for(let u of r._zod.onattach)u(i);if(o.length===0)(t=i._zod).deferred??(t.deferred=[]),i._zod.deferred?.push(()=>{i._zod.run=i._zod.parse});else{let r=(l,e,$)=>{let I=mn(l),g;for(let b of e){if(b._zod.def.when){if(U$(l))continue;if(!b._zod.def.when(l))continue}else if(I)continue;let w=l.issues.length,f=b._zod.check(l);if(f instanceof Promise&&$?.async===!1)throw new kn;if(g||f instanceof Promise)g=(g??Promise.resolve()).then(async()=>{if(await f,l.issues.length===w)return;if(!I)I=mn(l,w)});else{if(l.issues.length===w)continue;if(!I)I=mn(l,w)}}if(g)return g.then(()=>{return l});return l},u=(l,e,$)=>{if(mn(l))return l.aborted=!0,l;let I=r(e,o,$);if(I instanceof Promise){if($.async===!1)throw new kn;return I.then((g)=>i._zod.parse(g,$))}return i._zod.parse(I,$)};i._zod.run=(l,e)=>{if(e.skipChecks)return i._zod.parse(l,e);if(e.direction==="backward"){let I=i._zod.parse({value:l.value,issues:[]},{...e,skipChecks:!0});if(I instanceof Promise)return I.then((g)=>{return u(g,l,e)});return u(I,l,e)}let $=i._zod.parse(l,e);if($ instanceof Promise){if(e.async===!1)throw new kn;return $.then((I)=>r(I,o,e))}return r($,o,e)}}h(i,"~standard",()=>({validate:(r)=>{try{let u=mr(i,r);return u.success?{value:u.data}:{issues:u.error?.issues}}catch(u){return vo(i,r).then((l)=>l.success?{value:l.data}:{issues:l.error?.issues})}},vendor:"zod",version:1}))}),kr=U("$ZodString",(i,n)=>{_.init(i,n),i._zod.pattern=[...i?._zod.bag?.patterns??[]].pop()??q$(i._zod.bag),i._zod.parse=(t,o)=>{if(n.coerce)try{t.value=String(t.value)}catch(r){}if(typeof t.value==="string")return t;return t.issues.push({expected:"string",code:"invalid_type",input:t.value,inst:i}),t}}),ei=U("$ZodStringFormat",(i,n)=>{xr.init(i,n),kr.init(i,n)}),fI=U("$ZodGUID",(i,n)=>{n.pattern??(n.pattern=W$),ei.init(i,n)}),DI=U("$ZodUUID",(i,n)=>{if(n.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[n.version];if(o===void 0)throw Error(`InvalidUUIDversion:"${n.version}"`);n.pattern??(n.pattern=Lr(o))}else n.pattern??(n.pattern=Lr());ei.init(i,n)}),UI=U("$ZodEmail",(i,n)=>{n.pattern??(n.pattern=y$),ei.init(i,n)}),cI=U("$ZodURL",(i,n)=>{ei.init(i,n),i._zod.check=(t)=>{try{let o=t.value.trim();if(!n.normalize&&n.protocol?.source===K$.source){if(!/^https?:\/\//i.test(o)){t.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:t.value,inst:i,continue:!n.abort});return}}let r=new URL(o);if(n.hostname){if(n.hostname.lastIndex=0,!n.hostname.test(r.hostname))t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:n.hostname.source,input:t.value,inst:i,continue:!n.abort})}if(n.protocol){if(n.protocol.lastIndex=0,!n.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol))t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:n.protocol.source,input:t.value,inst:i,continue:!n.abort})}if(n.normalize)t.value=r.href;else t.value=o;return}catch(o){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:i,continue:!n.abort})}}}),SI=U("$ZodEmoji",(i,n)=>{n.pattern??(n.pattern=J$()),ei.init(i,n)}),OI=U("$ZodNanoID",(i,n)=>{n.pattern??(n.pattern=G$),ei.init(i,n)}),AI=U("$ZodCUID",(i,n)=>{n.pattern??(n.pattern=O$),ei.init(i,n)}),NI=U("$ZodCUID2",(i,n)=>{n.pattern??(n.pattern=A$),ei.init(i,n)}),LI=U("$ZodULID",(i,n)=>{n.pattern??(n.pattern=N$),ei.init(i,n)}),kI=U("$ZodXID",(i,n)=>{n.pattern??(n.pattern=L$),ei.init(i,n)}),GI=U("$ZodKSUID",(i,n)=>{n.pattern??(n.pattern=k$),ei.init(i,n)}),jI=U("$ZodISODateTime",(i,n)=>{n.pattern??(n.pattern=_$(n)),ei.init(i,n)}),WI=U("$ZodISODate",(i,n)=>{n.pattern??(n.pattern=V$),ei.init(i,n)}),yI=U("$ZodISOTime",(i,n)=>{n.pattern??(n.pattern=T$(n)),ei.init(i,n)}),JI=U("$ZodISODuration",(i,n)=>{n.pattern??(n.pattern=j$),ei.init(i,n)}),XI=U("$ZodIPv4",(i,n)=>{n.pattern??(n.pattern=X$),ei.init(i,n),i._zod.bag.format="ipv4"}),YI=U("$ZodIPv6",(i,n)=>{n.pattern??(n.pattern=Y$),ei.init(i,n),i._zod.bag.format="ipv6",i._zod.check=(t)=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:i,continue:!n.abort})}}}),PI=U("$ZodMAC",(i,n)=>{n.pattern??(n.pattern=P$(n.delimiter)),ei.init(i,n),i._zod.bag.format="mac"}),QI=U("$ZodCIDRv4",(i,n)=>{n.pattern??(n.pattern=Q$),ei.init(i,n)}),HI=U("$ZodCIDRv6",(i,n)=>{n.pattern??(n.pattern=H$),ei.init(i,n),i._zod.check=(t)=>{let o=t.value.split("/");try{if(o.length!==2)throw Error();let[r,u]=o;if(!u)throw Error();let l=Number(u);if(`${l}`!==u)throw Error();if(l<0||l>128)throw Error();new URL(`http://[${r}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:i,continue:!n.abort})}}});function FI(i){if(i==="")return!0;if(/\s/.test(i))return!1;if(i.length%4!==0)return!1;try{return atob(i),!0}catch{return!1}}var
Line truncated
deps:${r}}`};var bP={keyword:"dependencies",type:"object",schemaType:"object",error:KO.error,code(n){let[i,r]=wP(n);FO(n,i),hO(n,r)}};function wP({schema:n}){let i={},r={};for(let o in n){if(o==="__proto__")continue;let t=Array.isArray(n[o])?i:r;t[o]=n[o]}return[i,r]}function FO(n,i=n.schema){let{gen:r,data:o,it:t}=n;if(Object.keys(i).length===0)return;let u=r.let("missing");for(let e in i){let l=i[e];if(l.length===0)continue;let $=(0,Su.propertyInData)(r,o,e,t.opts.ownProperties);if(n.setParams({property:e,depsCount:l.length,deps:l.join(", ")}),t.allErrors)r.if($,()=>{for(let I of l)(0,Su.checkReportMissingProp)(n,I)});else r.if(bc._`${$}&&(${(0,Su.checkMissingProp)(n,l,u)})`),(0,Su.reportMissingProp)(n,u),r.else()}}KO.validatePropertyDeps=FO;function hO(n,i=n.schema){let{gen:r,data:o,keyword:t,it:u}=n,e=r.name("valid");for(let l in i){if((0,gP.alwaysValidSchema)(u,i[l]))continue;r.if((0,Su.propertyInData)(r,o,l,u.opts.ownProperties),()=>{let $=n.subschema({keyword:t,schemaProp:l},e);n.mergeValidEvaluated($,e)},()=>r.var(e,!0)),n.ok(e)}}KO.validateSchemaDeps=hO;KO.default=bP});var _O=P((TO)=>{Object.defineProperty(TO,"__esModule",{value:!0});var qO=z(),DP=nn(),UP={message:"property name must be valid",params:({params:n})=>qO._`{propertyName:${n.propertyName}}`},SP={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:UP,code(n){let{gen:i,schema:r,data:o,it:t}=n;if((0,DP.alwaysValidSchema)(t,r))return;let u=i.name("valid");i.forIn("key",o,(e)=>{n.setParams({propertyName:e}),n.subschema({keyword:"propertyNames",data:e,dataTypes:["string"],propertyName:e,compositeRule:!0},u),i.if((0,qO.not)(u),()=>{if(n.error(!0),!t.allErrors)i.break()})}),n.ok(u)}};TO.default=SP});var wc=P((EO)=>{Object.defineProperty(EO,"__esModule",{value:!0});var $v=Ii(),Oi=z(),AP=Vi(),Iv=nn(),NP={message:"must NOT have additional properties",params:({params:n})=>Oi._`{additionalProperty:${n.additionalProperty}}`},LP={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:NP,code(n){let{gen:i,schema:r,parentSchema:o,data:t,errsCount:u,it:e}=n;if(!u)throw Error("ajv implementation error");let{allErrors:l,opts:$}=e;if(e.props=!0,$.removeAdditional!=="all"&&(0,Iv.alwaysValidSchema)(e,r))return;let I=(0,$v.allSchemaProperties)(o.properties),g=(0,$v.allSchemaProperties)(o.patternProperties);b(),n.ok(Oi._`${u}===${AP.default.errors}`);function b(){i.forIn("key",t,(N)=>{if(!I.length&&!g.length)c(N);else i.if(w(N),()=>c(N))})}function w(N){let L;if(I.length>8){let K=(0,Iv.schemaRefOrVal)(e,o.properties,"properties");L=(0,$v.isOwnProperty)(i,K,N)}else if(I.length)L=(0,Oi.or)(...I.map((K)=>Oi._`${N}===${K}`));else L=Oi.nil;if(g.length)L=(0,Oi.or)(L,...g.map((K)=>Oi._`${(0,$v.usePattern)(n,K)}.test(${N})`));return(0,Oi.not)(L)}function f(N){i.code(Oi._`delete${t}[${N}]`)}function c(N){if($.removeAdditional==="all"||$.removeAdditional&&r===!1){f(N);return}if(r===!1){if(n.setParams({additionalProperty:N}),n.error(),!l)i.break();return}if(typeof r=="object"&&!(0,Iv.alwaysValidSchema)(e,r)){let L=i.name("valid");if($.removeAdditional==="failing")S(N,L,!1),i.if((0,Oi.not)(L),()=>{n.reset(),f(N)});else if(S(N,L),!l)i.if((0,Oi.not)(L),()=>i.break())}}function S(N,L,K){let H={keyword:"additionalProperties",dataProp:N,dataPropType:Iv.Type.Str};if(K===!1)Object.assign(H,{compositeRule:!0,createErrors:!1,allErrors:!1});n.subschema(H,L)}}};EO.default=LP});var mO=P((zO)=>{Object.defineProperty(zO,"__esModule",{value:!0});var kP=eu(),ZO=Ii(),fc=nn(),MO=wc(),dP={keyword:"properties",type:"object",schemaType:"object",code(n){let{gen:i,schema:r,parentSchema:o,data:t,it:u}=n;if(u.opts.removeAdditional==="all"&&o.additionalProperties===void 0)MO.default.code(new kP.KeywordCxt(u,MO.default,"additionalProperties"));let e=(0,ZO.allSchemaProperties)(r);for(let b of e)u.definedProperties.add(b);if(u.opts.unevaluated&&e.length&&u.props!==!0)u.props=fc.mergeEvaluated.props(i,(0,fc.toHash)(e),u.props);let l=e.filter((b)=>!(0,fc.alwaysValidSchema)(u,r[b]));if(l.length===0)return;let $=i.name("valid");for(let b of l){if(I(b))g(b);else{if(i.if((0,ZO.propertyInData)(i,t,b,u.opts.ownProperties)),g(b),!u.allErrors)i.else().var($,!0);i.endIf()}n.it.definedProperties.add(b),n.ok($)}function I(b){return u.opts.useDefaults&&!u.compositeRule&&r[b].default!==void 0}function g(b){n.subschema({keyword:"properties",schemaProp:b,dataProp:b},$)}}};zO.default=dP});var sO=P((aO)=>{Object.defineProperty(aO,"__esModule",{value:!0});var CO=Ii(),gv=z(),RO=nn(),xO=nn(),jP={keyword:"patternProperties",type:"object",schemaType:"object",code(n){let{gen:i,schema:r,data:o,parentSchema:t,it:u}=n,{opts:e}=u,l=(0,CO.allSchemaProperties)(r),$=l.filter((S)=>(0,RO.alwaysValidSchema)(u,r[S]));if(l.length===0||$.length===l.length&&(!u.opts.unevaluated||u.props===!0))return;let I=e.strictSchema&&!e.allowMatchingProperties&&t.properties,g=i.name("valid");if(u.props!==!0&&!(u.props instanceof gv.Name))u.props=(0,xO.
Line truncated
`).filter((u)=>u),o=Math.min(...r.map((u)=>u.length-u.trimStart().length)),t=r.map((u)=>u.slice(o)).map((u)=>" ".repeat(this.indent*2)+u);for(let u of t)this.content.push(u)}compile(){let n=Function,i=this?.args,o=[...(this?.content??[""]).map((t)=>`${t}`)];return new n(...i,o.join(`
`))}}var SI={major:4,minor:4,patch:3};var p=D("$ZodType",(n,i)=>{var r;n??(n={}),n._zod.def=i,n._zod.bag=n._zod.bag||{},n._zod.version=SI;let o=[...n._zod.def.checks??[]];if(n._zod.traits.has("$ZodCheck"))o.unshift(n);for(let t of o)for(let u of t._zod.onattach)u(n);if(o.length===0)(r=n._zod).deferred??(r.deferred=[]),n._zod.deferred?.push(()=>{n._zod.run=n._zod.parse});else{let t=(e,l,$)=>{let I=Ri(e),g;for(let b of l){if(b._zod.def.when){if(L$(e))continue;if(!b._zod.def.when(e))continue}else if(I)continue;let w=e.issues.length,f=b._zod.check(e);if(f instanceof Promise&&$?.async===!1)throw new ki;if(g||f instanceof Promise)g=(g??Promise.resolve()).then(async()=>{if(await f,e.issues.length===w)return;if(!I)I=Ri(e,w)});else{if(e.issues.length===w)continue;if(!I)I=Ri(e,w)}}if(g)return g.then(()=>{return e});return e},u=(e,l,$)=>{if(Ri(e))return e.aborted=!0,e;let I=t(l,o,$);if(I instanceof Promise){if($.async===!1)throw new ki;return I.then((g)=>n._zod.parse(g,$))}return n._zod.parse(I,$)};n._zod.run=(e,l)=>{if(l.skipChecks)return n._zod.parse(e,l);if(l.direction==="backward"){let I=n._zod.parse({value:e.value,issues:[]},{...l,skipChecks:!0});if(I instanceof Promise)return I.then((g)=>{return u(g,e,l)});return u(I,e,l)}let $=n._zod.parse(e,l);if($ instanceof Promise){if(l.async===!1)throw new ki;return $.then((I)=>t(I,o,l))}return t($,o,l)}}m(n,"~standard",()=>({validate:(t)=>{try{let u=xt(n,t);return u.success?{value:u.data}:{issues:u.error?.issues}}catch(u){return go(n,t).then((e)=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),dt=D("$ZodString",(n,i)=>{p.init(n,i),n._zod.pattern=[...n?._zod.bag?.patterns??[]].pop()??M$(n._zod.bag),n._zod.parse=(r,o)=>{if(i.coerce)try{r.value=String(r.value)}catch(t){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:n}),r}}),$n=D("$ZodStringFormat",(n,i)=>{st.init(n,i),dt.init(n,i)}),AI=D("$ZodGUID",(n,i)=>{i.pattern??(i.pattern=H$),$n.init(n,i)}),NI=D("$ZodUUID",(n,i)=>{if(i.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[i.version];if(o===void 0)throw Error(`InvalidUUIDversion:"${i.version}"`);i.pattern??(i.pattern=kt(o))}else i.pattern??(i.pattern=kt());$n.init(n,i)}),LI=D("$ZodEmail",(n,i)=>{i.pattern??(i.pattern=P$),$n.init(n,i)}),yI=D("$ZodURL",(n,i)=>{$n.init(n,i),n._zod.check=(r)=>{try{let o=r.value.trim();if(!i.normalize&&i.protocol?.source===q$.source){if(!/^https?:\/\//i.test(o)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:n,continue:!i.abort});return}}let t=new URL(o);if(i.hostname){if(i.hostname.lastIndex=0,!i.hostname.test(t.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:i.hostname.source,input:r.value,inst:n,continue:!i.abort})}if(i.protocol){if(i.protocol.lastIndex=0,!i.protocol.test(t.protocol.endsWith(":")?t.protocol.slice(0,-1):t.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:i.protocol.source,input:r.value,inst:n,continue:!i.abort})}if(i.normalize)r.value=t.href;else r.value=o;return}catch(o){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:n,continue:!i.abort})}}}),kI=D("$ZodEmoji",(n,i)=>{i.pattern??(i.pattern=Q$()),$n.init(n,i)}),dI=D("$ZodNanoID",(n,i)=>{i.pattern??(i.pattern=X$),$n.init(n,i)}),GI=D("$ZodCUID",(n,i)=>{i.pattern??(i.pattern=d$),$n.init(n,i)}),jI=D("$ZodCUID2",(n,i)=>{i.pattern??(i.pattern=G$),$n.init(n,i)}),WI=D("$ZodULID",(n,i)=>{i.pattern??(i.pattern=j$),$n.init(n,i)}),JI=D("$ZodXID",(n,i)=>{i.pattern??(i.pattern=W$),$n.init(n,i)}),XI=D("$ZodKSUID",(n,i)=>{i.pattern??(i.pattern=J$),$n.init(n,i)}),YI=D("$ZodISODateTime",(n,i)=>{i.pattern??(i.pattern=Z$(i)),$n.init(n,i)}),HI=D("$ZodISODate",(n,i)=>{i.pattern??(i.pattern=_$),$n.init(n,i)}),PI=D("$ZodISOTime",(n,i)=>{i.pattern??(i.pattern=E$(i)),$n.init(n,i)}),QI=D("$ZodISODuration",(n,i)=>{i.pattern??(i.pattern=Y$),$n.init(n,i)}),FI=D("$ZodIPv4",(n,i)=>{i.pattern??(i.pattern=F$),$n.init(n,i),n._zod.bag.format="ipv4"}),hI=D("$ZodIPv6",(n,i)=>{i.pattern??(i.pattern=h$),$n.init(n,i),n._zod.bag.format="ipv6",n._zod.check=(r)=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:n,continue:!i.abort})}}}),KI=D("$ZodMAC",(n,i)=>{i.pattern??(i.pattern=K$(i.delimiter)),$n.init(n,i),n._zod.bag.format="mac"}),BI=D("$ZodCIDRv4",(n,i)=>{i.pattern??(i.pattern=B$),$n.init(n,i)}),pI=D("$ZodCIDRv6",(n,i)=>{i.pattern??(i.pattern=p$),$n.init(n,i),n._zod.check=(r)=>{let o=r.value.split("/");try{if(o.length!==2)throw Error();let[t,u]=o;if(!u)throw Error();let e=Number(u);if(`${e}`!==u)throw Error();if(e<0||e>128)throw Error();new URL(`http://[${t}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:n,continue:!i.abort})}}});function VI(n){if(n==="")return!0;if(/\s/.test(n))return!1;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}var
Line truncated
`)}f.write("payload.value = newResult;"),f.write("return payload;");let K=f.compile();return(F,y)=>K(w,F,y)},u,l=Nr,e=!Or.jitless,I=e&&I$.value,g=n.catchall,b;i._zod.parse=(w,f)=>{b??(b=o.value);let D=w.value;if(!l(D))return w.issues.push({expected:"object",code:"invalid_type",input:D,inst:i}),w;if(e&&I&&f?.async===!1&&f.jitless!==!0){if(!u)u=r(n.shape);if(w=u(w,f),!g)return w;return kD([],D,w,f,b,i)}return t(w,f)}});function eD(i,n,t,o){for(let u of i)if(u.issues.length===0)return n.value=u.value,n;let r=i.filter((u)=>!mn(u));if(r.length===1)return n.value=r[0].value,r[0];return n.issues.push({code:"invalid_union",input:n.value,inst:t,errors:i.map((u)=>u.issues.map((l)=>Zi(l,o,Oi())))}),n}var wo=U("$ZodUnion",(i,n)=>{_.init(i,n),h(i._zod,"optin",()=>n.options.some((o)=>o._zod.optin==="optional")?"optional":void 0),h(i._zod,"optout",()=>n.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),h(i._zod,"values",()=>{if(n.options.every((o)=>o._zod.values))return new Set(n.options.flatMap((o)=>Array.from(o._zod.values)));return}),h(i._zod,"pattern",()=>{if(n.options.every((o)=>o._zod.pattern)){let o=n.options.map((r)=>r._zod.pattern);return new RegExp(`^(${o.map((r)=>st(r.source)).join("|")})$`)}return});let t=n.options.length===1?n.options[0]._zod.run:null;i._zod.parse=(o,r)=>{if(t)return t(o,r);let u=!1,l=[];for(let e of n.options){let $=e._zod.run({value:o.value,issues:[]},r);if($ instanceof Promise)l.push($),u=!0;else{if($.issues.length===0)return $;l.push($)}}if(!u)return eD(l,o,i,r);return Promise.all(l).then((e)=>{return eD(e,o,i,r)})}});function vD(i,n,t,o){let r=i.filter((u)=>u.issues.length===0);if(r.length===1)return n.value=r[0].value,n;if(r.length===0)n.issues.push({code:"invalid_union",input:n.value,inst:t,errors:i.map((u)=>u.issues.map((l)=>Zi(l,o,Oi())))});else n.issues.push({code:"invalid_union",input:n.value,inst:t,errors:[],inclusive:!1});return n}var aI=U("$ZodXor",(i,n)=>{wo.init(i,n),n.inclusive=!1;let t=n.options.length===1?n.options[0]._zod.run:null;i._zod.parse=(o,r)=>{if(t)return t(o,r);let u=!1,l=[];for(let e of n.options){let $=e._zod.run({value:o.value,issues:[]},r);if($ instanceof Promise)l.push($),u=!0;else l.push($)}if(!u)return vD(l,o,i,r);return Promise.all(l).then((e)=>{return vD(e,o,i,r)})}}),sI=U("$ZodDiscriminatedUnion",(i,n)=>{n.inclusive=!1,wo.init(i,n);let t=i._zod.parse;h(i._zod,"propValues",()=>{let r={};for(let u of n.options){let l=u._zod.propValues;if(!l||Object.keys(l).length===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${n.options.indexOf(u)}"`);for(let[e,$]of Object.entries(l)){if(!r[e])r[e]=new Set;for(let I of $)r[e].add(I)}}return r});let o=dr(()=>{let r=n.options,u=new Map;for(let l of r){let e=l._zod.propValues?.[n.discriminator];if(!e||e.size===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${n.options.indexOf(l)}"`);for(let $ of e){if(u.has($))throw Error(`Duplicatediscriminatorvalue"${String($)}"`);u.set($,l)}}return u});i._zod.parse=(r,u)=>{let l=r.value;if(!Nr(l))return r.issues.push({code:"invalid_type",expected:"object",input:l,inst:i}),r;let e=o.value.get(l?.[n.discriminator]);if(e)return e._zod.run(r,u);if(n.unionFallback||u.direction==="backward")return t(r,u);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:n.discriminator,options:Array.from(o.value.keys()),input:l,path:[n.discriminator],inst:i}),r}}),ig=U("$ZodIntersection",(i,n)=>{_.init(i,n),i._zod.parse=(t,o)=>{let r=t.value,u=n.left._zod.run({value:r,issues:[]},o),l=n.right._zod.run({value:r,issues:[]},o);if(u instanceof Promise||l instanceof Promise)return Promise.all([u,l]).then(([$,I])=>{return $D(t,$,I)});return $D(t,u,l)}});function wI(i,n){if(i===n)return{valid:!0,data:i};if(i instanceof Date&&n instanceof Date&&+i===+n)return{valid:!0,data:i};if(Cn(i)&&Cn(n)){let t=Object.keys(n),o=Object.keys(i).filter((u)=>t.indexOf(u)!==-1),r={...i,...n};for(let u of o){let l=wI(i[u],n[u]);if(!l.valid)return{valid:!1,mergeErrorPath:[u,...l.mergeErrorPath]};r[u]=l.data}return{valid:!0,data:r}}if(Array.isArray(i)&&Array.isArray(n)){if(i.length!==n.length)return{valid:!1,mergeErrorPath:[]};let t=[];for(let o=0;o<i.length;o++){let r=i[o],u=n[o],l=wI(r,u);if(!l.valid)return{valid:!1,mergeErrorPath:[o,...l.mergeErrorPath]};t.push(l.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function $D(i,n,t){let o=new Map,r;for(let e of n.issues)if(e.code==="unrecognized_keys"){r??(r=e);for(let $ of e.keys){if(!o.has($))o.set($,{});o.get($).l=!0}}else i.issues.push(e);for(let e of t.issues)if(e.code==="unrecognized_keys")for(let $ of e.keys){if(!o.has($))o.set($,{});o.get($).r=!0}else i.issues.push(e);let u=[...o].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(u.length&&r)i.issues.push({...r,keys:u});if(mn(i))return i;let l=wI(n.value,t.value);if(!l.valid)throw Error(`Unmergableintersection.Errorpath:${JSON.stringify(l.mergeErrorPath)}`);return i.value=l.data,i}var el=U("$ZodTuple",(i,n)=>{_.init(i,n
Line truncated
`)}f.write("payload.value = newResult;"),f.write("return payload;");let K=f.compile();return(H,j)=>K(w,H,j)},u,e=yt,l=!Nt.jitless,I=l&&D$.value,g=i.catchall,b;n._zod.parse=(w,f)=>{b??(b=o.value);let c=w.value;if(!e(c))return w.issues.push({expected:"object",code:"invalid_type",input:c,inst:n}),w;if(l&&I&&f?.async===!1&&f.jitless!==!0){if(!u)u=t(i.shape);if(w=u(w,f),!g)return w;return W0([],c,w,f,b,n)}return r(w,f)}});function b0(n,i,r,o){for(let u of n)if(u.issues.length===0)return i.value=u.value,i;let t=n.filter((u)=>!Ri(u));if(t.length===1)return i.value=t[0].value,t[0];return i.issues.push({code:"invalid_union",input:i.value,inst:r,errors:n.map((u)=>u.issues.map((e)=>_n(e,o,Nn())))}),i}var Do=D("$ZodUnion",(n,i)=>{p.init(n,i),m(n._zod,"optin",()=>i.options.some((o)=>o._zod.optin==="optional")?"optional":void 0),m(n._zod,"optout",()=>i.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),m(n._zod,"values",()=>{if(i.options.every((o)=>o._zod.values))return new Set(i.options.flatMap((o)=>Array.from(o._zod.values)));return}),m(n._zod,"pattern",()=>{if(i.options.every((o)=>o._zod.pattern)){let o=i.options.map((t)=>t._zod.pattern);return new RegExp(`^(${o.map((t)=>to(t.source)).join("|")})$`)}return});let r=i.options.length===1?i.options[0]._zod.run:null;n._zod.parse=(o,t)=>{if(r)return r(o,t);let u=!1,e=[];for(let l of i.options){let $=l._zod.run({value:o.value,issues:[]},t);if($ instanceof Promise)e.push($),u=!0;else{if($.issues.length===0)return $;e.push($)}}if(!u)return b0(e,o,n,t);return Promise.all(e).then((l)=>{return b0(l,o,n,t)})}});function w0(n,i,r,o){let t=n.filter((u)=>u.issues.length===0);if(t.length===1)return i.value=t[0].value,i;if(t.length===0)i.issues.push({code:"invalid_union",input:i.value,inst:r,errors:n.map((u)=>u.issues.map((e)=>_n(e,o,Nn())))});else i.issues.push({code:"invalid_union",input:i.value,inst:r,errors:[],inclusive:!1});return i}var og=D("$ZodXor",(n,i)=>{Do.init(n,i),i.inclusive=!1;let r=i.options.length===1?i.options[0]._zod.run:null;n._zod.parse=(o,t)=>{if(r)return r(o,t);let u=!1,e=[];for(let l of i.options){let $=l._zod.run({value:o.value,issues:[]},t);if($ instanceof Promise)e.push($),u=!0;else e.push($)}if(!u)return w0(e,o,n,t);return Promise.all(e).then((l)=>{return w0(l,o,n,t)})}}),ug=D("$ZodDiscriminatedUnion",(n,i)=>{i.inclusive=!1,Do.init(n,i);let r=n._zod.parse;m(n._zod,"propValues",()=>{let t={};for(let u of i.options){let e=u._zod.propValues;if(!e||Object.keys(e).length===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${i.options.indexOf(u)}"`);for(let[l,$]of Object.entries(e)){if(!t[l])t[l]=new Set;for(let I of $)t[l].add(I)}}return t});let o=Mt(()=>{let t=i.options,u=new Map;for(let e of t){let l=e._zod.propValues?.[i.discriminator];if(!l||l.size===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${i.options.indexOf(e)}"`);for(let $ of l){if(u.has($))throw Error(`Duplicatediscriminatorvalue"${String($)}"`);u.set($,e)}}return u});n._zod.parse=(t,u)=>{let e=t.value;if(!yt(e))return t.issues.push({code:"invalid_type",expected:"object",input:e,inst:n}),t;let l=o.value.get(e?.[i.discriminator]);if(l)return l._zod.run(t,u);if(i.unionFallback||u.direction==="backward")return r(t,u);return t.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:i.discriminator,options:Array.from(o.value.keys()),input:e,path:[i.discriminator],inst:n}),t}}),eg=D("$ZodIntersection",(n,i)=>{p.init(n,i),n._zod.parse=(r,o)=>{let t=r.value,u=i.left._zod.run({value:t,issues:[]},o),e=i.right._zod.run({value:t,issues:[]},o);if(u instanceof Promise||e instanceof Promise)return Promise.all([u,e]).then(([$,I])=>{return f0(r,$,I)});return f0(r,u,e)}});function OI(n,i){if(n===i)return{valid:!0,data:n};if(n instanceof Date&&i instanceof Date&&+n===+i)return{valid:!0,data:n};if(Ci(n)&&Ci(i)){let r=Object.keys(i),o=Object.keys(n).filter((u)=>r.indexOf(u)!==-1),t={...n,...i};for(let u of o){let e=OI(n[u],i[u]);if(!e.valid)return{valid:!1,mergeErrorPath:[u,...e.mergeErrorPath]};t[u]=e.data}return{valid:!0,data:t}}if(Array.isArray(n)&&Array.isArray(i)){if(n.length!==i.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let o=0;o<n.length;o++){let t=n[o],u=i[o],e=OI(t,u);if(!e.valid)return{valid:!1,mergeErrorPath:[o,...e.mergeErrorPath]};r.push(e.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function f0(n,i,r){let o=new Map,t;for(let l of i.issues)if(l.code==="unrecognized_keys"){t??(t=l);for(let $ of l.keys){if(!o.has($))o.set($,{});o.get($).l=!0}}else n.issues.push(l);for(let l of r.issues)if(l.code==="unrecognized_keys")for(let $ of l.keys){if(!o.has($))o.set($,{});o.get($).r=!0}else n.issues.push(l);let u=[...o].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(u.length&&t)n.issues.push({...t,keys:u});if(Ri(n))return n;let e=OI(i.value,r.value);if(!e.valid)throw Error(`Unmergableintersection.Errorpath:${JSON.stringify(e.mergeErrorPath)}`);return n.value=e.data,n}var Ie=D("$ZodTuple",(n,i)=>{p.init(n,i
Line truncated
Setthe\`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(letlofi.seen.entries()){lete=l[1];if(n===l[0]){u(l);continue}if(i.external){letI=i.external.registry.get(l[0])?.id;if(n!==l[0]&&I){u(l);continue}}if(i.metadataRegistry.get(l[0])?.id){u(l);continue}if(e.cycle){u(l);continue}if(e.count>1){if(i.reused==="ref"){u(l);continue}}}}functionir(i,n){lett=i.seen.get(n);if(!t)throwError("Unprocessed schema. This is a bug in Zod.");leto=(e)=>{let$=i.seen.get(e);if($.ref===null)return;letI=$.def??$.schema,g={...I},b=$.ref;if($.ref=null,b){o(b);letf=i.seen.get(b),D=f.schema;if(D.$ref&&(i.target==="draft-07"||i.target==="draft-04"||i.target==="openapi-3.0"))I.allOf=I.allOf??[],I.allOf.push(D);elseObject.assign(I,D);if(Object.assign(I,g),e._zod.parent===b)for(letNinI){if(N==="$ref"||N==="allOf")continue;if(!(Ning))deleteI[N]}if(D.$ref&&f.def)for(letNinI){if(N==="$ref"||N==="allOf")continue;if(Ninf.def&&JSON.stringify(I[N])===JSON.stringify(f.def[N]))deleteI[N]}}letw=e._zod.parent;if(w&&w!==b){o(w);letf=i.seen.get(w);if(f?.schema.$ref){if(I.$ref=f.schema.$ref,f.def)for(letDinI){if(D==="$ref"||D==="allOf")continue;if(Dinf.def&&JSON.stringify(I[D])===JSON.stringify(f.def[D]))deleteI[D]}}}i.override({zodSchema:e,jsonSchema:I,path:$.path??[]})};for(leteof[...i.seen.entries()].reverse())o(e[0]);letr={};if(i.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";elseif(i.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";elseif(i.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";elseif(i.target==="openapi-3.0");if(i.external?.uri){lete=i.external.registry.get(n)?.id;if(!e)throwError("Schema is missing an `id` property");r.$id=i.external.uri(e)}Object.assign(r,t.def??t.schema);letu=i.metadataRegistry.get(n)?.id;if(u!==void0&&r.id===u)deleter.id;letl=i.external?.defs??{};for(leteofi.seen.entries()){let$=e[1];if($.def&&$.defId){if($.def.id===$.defId)delete$.def.id;l[$.defId]=$.def}}if(i.external);elseif(Object.keys(l).length>0)if(i.target==="draft-2020-12")r.$defs=l;elser.definitions=l;try{lete=JSON.parse(JSON.stringify(r));returnObject.defineProperty(e,"~standard",{value:{...n["~standard"],jsonSchema:{input:bt(n,"input",i.processors),output:bt(n,"output",i.processors)}},enumerable:!1,writable:!1}),e}catch(e){throwError("Error converting schema to JSON.")}}functiondi(i,n){lett=n??{seen:newSet};if(t.seen.has(i))return!1;t.seen.add(i);leto=i._zod.def;if(o.type==="transform")return!0;if(o.type==="array")returndi(o.element,t);if(o.type==="set")returndi(o.valueType,t);if(o.type==="lazy")returndi(o.getter(),t);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")returndi(o.innerType,t);if(o.type==="intersection")returndi(o.left,t)||di(o.right,t);if(o.type==="record"||o.type==="map")returndi(o.keyType,t)||di(o.valueType,t);if(o.type==="pipe"){if(i._zod.traits.has("$ZodCodec"))return!0;returndi(o.in,t)||di(o.out,t)}if(o.type==="object"){for(letrino.shape)if(di(o.shape[r],t))return!0;return!1}if(o.type==="union"){for(letrofo.options)if(di(r,t))return!0;return!1}if(o.type==="tuple"){for(letrofo.items)if(di(r,t))return!0;if(o.rest&&di(o.rest,t))return!0;return!1}return!1}varlw=(i,n={})=>(t)=>{leto=an({...t,processors:n});returnoi(i,o),sn(o,i),ir(o,i)},bt=(i,n,t={})=>(o)=>{let{libraryOptions:r,target:u}=o??{},l=an({...r??{},target:u,io:n,processors:t});returnoi(i,l),sn(l,i),ir(l,i)};varYy={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ew=(i,n,t,o)=>{letr=t;r.type="string";let{minimum:u,maximum:l,format:e,patterns:$,contentEncoding:I}=i._zod.bag;if(typeofu==="number")r.minLength=u;if(typeofl==="number")r.maxLength=l;if(e){if(r.format=Yy[e]??e,r.format==="")deleter.format;if(e==="time")deleter.format}if(I)r.contentEncoding=I;if($&&$.size>0){letg=[...$];if(g.length===1)r.pattern=g[0].source;elseif(g.length>1)r.allOf=[...g.map((b)=>({...n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0"?{type:"string"}:{},pattern:b.source}))]}},vw=(i,n,t,o)=>{letr=t,{minimum:u,maximum:l,format:e,multipleOf:$,exclusiveMaximum:I,exclusiveMinimum:g}=i._zod.bag;if(typeofe==="string"&&e.includes("int"))r.type="integer";elser.type="number";letb=typeofg==="number"&&g>=(u??Number.NEGATIVE_INFINITY),w=typeofI==="number"&&I<=(l??Number.POSITIVE_INFINITY),f=n.target==="draft-04"||n.target==="openapi-3.0";if(b)if(f)r.minimum=g,r.exclusiveMinimum=!0;elser.exclusiveMinimum=g;elseif(typeofu==="number")r.minimum=u;if(w)if(f)r.maximum=I,r.exclusiveMaximum=!0;elser.exclusiveMaximum=I;elseif(typeofl==="number")r.maximum=l;if(typeof$==="number")r.multipleOf=$},$w=(i,n,t,o)=>{t.type="boolean"},Iw=(i,n,t,o)=>{if(n.unrepresentable==="throw")throwError("BigInt cannot be represented in JSON Schema")},gw=(i,n,t,o)=>{if(n.unrepresentable==="Line truncated
`}class j4{constructor(i=xA.stdin,n=xA.stdout){this._stdin=i,this._stdout=n,this._readBuffer=new G4,this._started=!1,this._ondata=(t)=>{this._readBuffer.append(t),this.processReadBuffer()},this._onerror=(t)=>{this.onerror?.(t)}}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 i=this._readBuffer.readMessage();if(i===null)break;this.onmessage?.(i)}catch(i){this.onerror?.(i)}}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(i){return new Promise((n)=>{let t=RA(i);if(this._stdout.write(t))n();else this._stdout.once("drain",n)})}}import{dirname as H0,join as e3}from"node:path";import{fileURLToPath as v3}from"node:url";class Zn extends Error{name="KyError";get isKyError(){return!0}}class rn extends Zn{name="HTTPError";response;request;options;data;constructor(i,n,t){let o=i.status||i.status===0?i.status:"",r=i.statusText??"",u=`${o}${r}`.trim(),l=u?`statuscode${u}`:"an unknown error";super(`Requestfailedwith${l}:${n.method}${n.url}`);this.response=i,this.request=n,this.options=t}}class Su extends Zn{name="NetworkError";request;constructor(i,n){super(`Requestfailedduetoanetworkerror:${i.method}${i.url}`,n);this.request=i}}class Ou extends Error{name="NonError";value;constructor(i){let n="Non-error value was thrown";try{if(typeof i==="string")n=i;else if(i&&typeof i==="object"&&"message"in i&&typeof i.message==="string")n=i.message}catch{}super(n);this.value=i}}class _t extends Zn{name="ForceRetryError";customDelay;code;customRequest;constructor(i){let n=i?.cause?i.cause instanceof Error?i.cause:new Ou(i.cause):void 0;super(i?.code?`Forcedretry:${i.code}`:"Forced retry",n?{cause:n}:void 0);this.customDelay=i?.delay,this.code=i?.code,this.customRequest=i?.request}}class W4 extends Error{name="SchemaValidationError";issues;constructor(i){super("Response schema validation failed");this.issues=i}}class An extends Zn{name="TimeoutError";request;constructor(i){super(`Requesttimedout:${i.method}${i.url}`);this.request=i}}var y4=(()=>{let i=!1,n=!1,t=typeof globalThis.ReadableStream==="function",o=typeof globalThis.Request==="function";if(t&&o)try{n=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return i=!0,"half"}}).headers.has("Content-Type")}catch(r){if(r instanceof Error&&r.message==="unsupported BodyInit type")return!1;throw r}return i&&!n})(),aA=typeof globalThis.AbortController==="function",wv=typeof globalThis.AbortSignal==="function"&&typeof globalThis.AbortSignal.any==="function",sA=typeof globalThis.ReadableStream==="function",iN=typeof globalThis.FormData==="function",fv=["get","post","put","patch","head","delete"],sH=()=>{return};sH();var nN={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},qt=2147483647,rN=40,Dv=Symbol("stop");class Uv{options;constructor(i){this.options=i}}var tN=(i)=>new Uv(i),oN={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},uN={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 cv=new TextEncoder,iF=(i)=>{if(!i)return 0;if(i instanceof FormData){let n=0;for(let[t,o]of i)n+=rN,n+=cv.encode(`Content-Disposition:form-data;name="${t}"`).byteLength,n+=typeof o==="string"?cv.encode(o).byteLength:o.size;return n}if(i instanceof Blob)return i.size;if(i instanceof ArrayBuffer||ArrayBuffer.isView(i))return i.byteLength;if(typeof i==="string")return cv.encode(i).byteLength;if(i instanceof URLSearchParams)return cv.encode(i.toString()).byteLength;return 0},lN=(i,n,t)=>{let o,r=0;return i.pipeThrough(new TransformStream({transform(u,l){if(l.enqueue(u),o){r+=o.byteLength;let e=n===0?0:r/n;if(e>=1)e=1-Number.EPSILON;t?.({percent:e,totalBytes:Math.max(n,r),transferredBytes:r},o)}o=u},flush(){if(o)r+=o.byteLength,t?.({percent:1,totalBytes:Math.max(n,r),transferredBytes:r},o)}}))},eN=(i,n)=>{if(!i.body)return i;let t={status:i.status,statusText:i.statusText,headers:i.headers};if(i.status===204)return new Response(null,t);let o=Math.max(0,Number(i.headers.get("content-length"))||0);return new Response(lN(i.body,o,n),t)},vN=(i,n,t)=>{if(!i.body)return i;let o=iF(t??i.body);return new Request(i,{duplex:"half",body:lN(i.body,o,n)})};var Yn=(i)=>i!==null&&typeof i==="object";var nF=Symbol("replaceOption"),J4=(i)=>Yn(i)&&i[nF]===!0?{isReplace:!0,value:i.value}:{isReplace:!1,value:i};var Nu=(...i)=>{for(let n of i)if((!Yn(n)|
Line truncated
`,{mode:384}),n}function zt(i,n,t=[]){let o=n.corpId?.trim()||void 0,r=n.stateful?n.defaultCorpId?.trim()||void 0:void 0,u=o??r;if(u){let e=i.find(($)=>$.id===u);if(e)return e;throw Error(`Noenterpriseconfigfoundfor${u}`)}if(!n.stateful)throw Error("Stateless mode is enabled. Every enterprise command requires --corp <corpId>. Use `seal-homeconfigmodestateful` to enable a default enterprise.");let l=i[0];if(l)return l;throw Error("No enterprise config found. Add a non-example JSON file under one of: "+(t.length?t.join(", "):"the configured enterprise directories"))}import{readFileSync as YK}from"node:fs";import{randomBytes as PK}from"node:crypto";import{randomBytes as wL}from"node:crypto";var CF=v.object({staffId:v.string(),name:v.string().optional(),code:v.string().default(""),bindTime:v.number().optional()}),mF=v.object({id:v.string(),tenantId:v.string(),name:v.string(),isAdmin:v.boolean().default(!1),permissions:v.array(v.string()).default([]),providerUserId:v.string().optional(),hosecloudStaff:CF.optional()}),RF=v.object({apiKey:v.string().optional(),corporationId:v.string().optional(),corporationName:v.string().optional()}),xF=v.object({id:v.string(),name:v.string(),tenantSlug:v.string().optional(),isDemo:v.boolean().default(!1),logoUrl:v.string().nullable().optional(),hoseCorpConfig:RF.optional()}),zN=v.object({user:mF,tenant:xF}),aF=v.object({id:v.string(),name:v.string(),email:v.string().nullable().optional(),emailVerified:v.boolean().optional(),image:v.string().nullable().optional(),tenantId:v.string().optional(),provider:v.string().optional(),providerUserId:v.string().optional(),mobile:v.string().nullable().optional(),status:v.string().optional(),permissions:v.array(v.string()).default([]),isAdmin:v.boolean().default(!1),hosecloudStaff:v.unknown().optional()}).passthrough(),sF=v.object({id:v.string(),token:v.string().optional(),expiresAt:v.string(),createdAt:v.string().optional(),updatedAt:v.string().optional(),ipAddress:v.string().optional(),userAgent:v.string().optional(),userId:v.string(),delegationId:v.string().nullable().optional()}).passthrough(),pN=v.object({user:aF,session:sF}),Yv=v.object({id:v.string(),tenantId:v.string().optional(),code:v.number().optional(),description:v.string(),scope:v.string(),strictness:v.string(),status:v.string().optional(),createdAt:v.number().optional(),updatedAt:v.number().optional()}),hN=v.object({rules:v.array(Yv),hasPendingDeletes:v.boolean().default(!1)}),iK=v.object({code:v.string().optional(),description:v.string(),scope:v.string(),strictness:v.string()}),Pv=v.object({id:v.string(),tenantId:v.string().optional(),versionNumber:v.number(),versionName:v.string().nullable().optional(),publishedBy:v.string().nullable().optional(),publishedByName:v.string().nullable().optional(),rules:v.array(iK).default([]),publishedAt:v.number().optional(),createdAt:v.number().optional()}),CN=v.object({version:Pv,rulesCount:v.number()}),Wu=v.object({id:v.string(),tenantId:v.string().optional(),title:v.string(),purpose:v.string().default(""),contentType:v.string().default("policy"),content:v.string(),status:v.string().default("published"),enabled:v.boolean().default(!0),scenarios:v.array(v.string()).default([]),tags:v.array(v.string()).default([]),category:v.string().nullable().optional(),categoryTags:v.array(v.string()).default([]),createdBy:v.string().nullable().optional(),createdByName:v.string().nullable().optional(),createdAt:v.number().optional(),updatedAt:v.number().optional(),updatedBy:v.string().nullable().optional(),updatedByName:v.string().nullable().optional(),isDeleted:v.boolean().default(!1)}),mN=v.object({articles:v.array(Wu),total:v.number().optional()}),nK=v.object({explicitApprove:v.string().default(""),explicitReject:v.string().default(""),exemptApprove:v.string().default(""),review:v.string().default("")}).passthrough(),rK=v.object({type:v.string(),signKey:v.string().optional(),outboundName:v.string().optional(),mode:v.string().optional(),autoApprovalRate:v.number().optional(),apiKey:v.string().optional(),apiSecret:v.string().optional(),apiOrigin:v.string().optional(),corporationId:v.string().optional(),ebotSignKey:v.string().optional(),completionSignKey:v.string().optional(),outboundMessageId:v.string().optional(),completionMessageId:v.string().optional()}).passthrough(),tK=v.enum(["assisted","semi_automatic","fully_automatic"]),dN=v.object({id:v.string(),url:v.string().url()}).passthrough(),yu=v.object({type:v.literal("webhook"),id:v.string(),name:v.string(),mode:tK,incomingDocumentWebhook:dN,outgoingResultWebhook:v.string().url(),incomingManualResultWebhook:dN,secret:v.string().min(1),autoApprovalRate:v.number().int().min(0).max(100).optional()}).passthrough(),p4=v.object({id:v.string().optional(),tenantId:v.string().optional(),tone:v.string().optional(),language:v.string().optional(),detailLevel:v.string().optional(),outputFormat:v.string().optional(),examples:v.array(v.string()).default([]),prohibitedPhrases:v.array(v.string()).default([]),cus
Line truncated
Setthe\`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(leteofn.seen.entries()){letl=e[1];if(i===e[0]){u(e);continue}if(n.external){letI=n.external.registry.get(e[0])?.id;if(i!==e[0]&&I){u(e);continue}}if(n.metadataRegistry.get(e[0])?.id){u(e);continue}if(l.cycle){u(e);continue}if(l.count>1){if(n.reused==="ref"){u(e);continue}}}}functionit(n,i){letr=n.seen.get(i);if(!r)throwError("Unprocessed schema. This is a bug in Zod.");leto=(l)=>{let$=n.seen.get(l);if($.ref===null)return;letI=$.def??$.schema,g={...I},b=$.ref;if($.ref=null,b){o(b);letf=n.seen.get(b),c=f.schema;if(c.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0"))I.allOf=I.allOf??[],I.allOf.push(c);elseObject.assign(I,c);if(Object.assign(I,g),l._zod.parent===b)for(letNinI){if(N==="$ref"||N==="allOf")continue;if(!(Ning))deleteI[N]}if(c.$ref&&f.def)for(letNinI){if(N==="$ref"||N==="allOf")continue;if(Ninf.def&&JSON.stringify(I[N])===JSON.stringify(f.def[N]))deleteI[N]}}letw=l._zod.parent;if(w&&w!==b){o(w);letf=n.seen.get(w);if(f?.schema.$ref){if(I.$ref=f.schema.$ref,f.def)for(letcinI){if(c==="$ref"||c==="allOf")continue;if(cinf.def&&JSON.stringify(I[c])===JSON.stringify(f.def[c]))deleteI[c]}}}n.override({zodSchema:l,jsonSchema:I,path:$.path??[]})};for(letlof[...n.seen.entries()].reverse())o(l[0]);lett={};if(n.target==="draft-2020-12")t.$schema="https://json-schema.org/draft/2020-12/schema";elseif(n.target==="draft-07")t.$schema="http://json-schema.org/draft-07/schema#";elseif(n.target==="draft-04")t.$schema="http://json-schema.org/draft-04/schema#";elseif(n.target==="openapi-3.0");if(n.external?.uri){letl=n.external.registry.get(i)?.id;if(!l)throwError("Schema is missing an `id` property");t.$id=n.external.uri(l)}Object.assign(t,r.def??r.schema);letu=n.metadataRegistry.get(i)?.id;if(u!==void0&&t.id===u)deletet.id;lete=n.external?.defs??{};for(letlofn.seen.entries()){let$=l[1];if($.def&&$.defId){if($.def.id===$.defId)delete$.def.id;e[$.defId]=$.def}}if(n.external);elseif(Object.keys(e).length>0)if(n.target==="draft-2020-12")t.$defs=e;elset.definitions=e;try{letl=JSON.parse(JSON.stringify(t));returnObject.defineProperty(l,"~standard",{value:{...i["~standard"],jsonSchema:{input:fr(i,"input",n.processors),output:fr(i,"output",n.processors)}},enumerable:!1,writable:!1}),l}catch(l){throwError("Error converting schema to JSON.")}}functionZn(n,i){letr=i??{seen:newSet};if(r.seen.has(n))return!1;r.seen.add(n);leto=n._zod.def;if(o.type==="transform")return!0;if(o.type==="array")returnZn(o.element,r);if(o.type==="set")returnZn(o.valueType,r);if(o.type==="lazy")returnZn(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")returnZn(o.innerType,r);if(o.type==="intersection")returnZn(o.left,r)||Zn(o.right,r);if(o.type==="record"||o.type==="map")returnZn(o.keyType,r)||Zn(o.valueType,r);if(o.type==="pipe"){if(n._zod.traits.has("$ZodCodec"))return!0;returnZn(o.in,r)||Zn(o.out,r)}if(o.type==="object"){for(lettino.shape)if(Zn(o.shape[t],r))return!0;return!1}if(o.type==="union"){for(lettofo.options)if(Zn(t,r))return!0;return!1}if(o.type==="tuple"){for(lettofo.items)if(Zn(t,r))return!0;if(o.rest&&Zn(o.rest,r))return!0;return!1}return!1}varbw=(n,i={})=>(r)=>{leto=si({...r,processors:i});returnen(n,o),nt(o,n),it(o,n)},fr=(n,i,r={})=>(o)=>{let{libraryOptions:t,target:u}=o??{},e=si({...t??{},target:u,io:i,processors:r});returnen(n,e),nt(e,n),it(e,n)};varpj={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ww=(n,i,r,o)=>{lett=r;t.type="string";let{minimum:u,maximum:e,format:l,patterns:$,contentEncoding:I}=n._zod.bag;if(typeofu==="number")t.minLength=u;if(typeofe==="number")t.maxLength=e;if(l){if(t.format=pj[l]??l,t.format==="")deletet.format;if(l==="time")deletet.format}if(I)t.contentEncoding=I;if($&&$.size>0){letg=[...$];if(g.length===1)t.pattern=g[0].source;elseif(g.length>1)t.allOf=[...g.map((b)=>({...i.target==="draft-07"||i.target==="draft-04"||i.target==="openapi-3.0"?{type:"string"}:{},pattern:b.source}))]}},fw=(n,i,r,o)=>{lett=r,{minimum:u,maximum:e,format:l,multipleOf:$,exclusiveMaximum:I,exclusiveMinimum:g}=n._zod.bag;if(typeofl==="string"&&l.includes("int"))t.type="integer";elset.type="number";letb=typeofg==="number"&&g>=(u??Number.NEGATIVE_INFINITY),w=typeofI==="number"&&I<=(e??Number.POSITIVE_INFINITY),f=i.target==="draft-04"||i.target==="openapi-3.0";if(b)if(f)t.minimum=g,t.exclusiveMinimum=!0;elset.exclusiveMinimum=g;elseif(typeofu==="number")t.minimum=u;if(w)if(f)t.maximum=I,t.exclusiveMaximum=!0;elset.exclusiveMaximum=I;elseif(typeofe==="number")t.maximum=e;if(typeof$==="number")t.multipleOf=$},cw=(n,i,r,o)=>{r.type="boolean"},Dw=(n,i,r,o)=>{if(i.unrepresentable==="throw")throwError("BigInt cannot be represented in JSON Schema")},Uw=(n,i,r,o)=>{if(i.unrepresentable==="Line truncated
`}class Yc{constructor(n=tN.stdin,i=tN.stdout){this._stdin=n,this._stdout=i,this._readBuffer=new Xc,this._started=!1,this._ondata=(r)=>{this._readBuffer.append(r),this.processReadBuffer()},this._onerror=(r)=>{this.onerror?.(r)}}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 n=this._readBuffer.readMessage();if(n===null)break;this.onmessage?.(n)}catch(n){this.onerror?.(n)}}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(n){return new Promise((i)=>{let r=iN(n);if(this._stdout.write(r))i();else this._stdout.once("drain",i)})}}import{dirname as p4,join as UK}from"node:path";import{fileURLToPath as SK}from"node:url";class _i extends Error{name="KyError";get isKyError(){return!0}}class ti extends _i{name="HTTPError";response;request;options;data;constructor(n,i,r){let o=n.status||n.status===0?n.status:"",t=n.statusText??"",u=`${o}${t}`.trim(),e=u?`statuscode${u}`:"an unknown error";super(`Requestfailedwith${e}:${i.method}${i.url}`);this.response=n,this.request=i,this.options=r}}class Nu extends _i{name="NetworkError";request;constructor(n,i){super(`Requestfailedduetoanetworkerror:${n.method}${n.url}`,i);this.request=n}}class Lu extends Error{name="NonError";value;constructor(n){let i="Non-error value was thrown";try{if(typeof n==="string")i=n;else if(n&&typeof n==="object"&&"message"in n&&typeof n.message==="string")i=n.message}catch{}super(i);this.value=n}}class qr extends _i{name="ForceRetryError";customDelay;code;customRequest;constructor(n){let i=n?.cause?n.cause instanceof Error?n.cause:new Lu(n.cause):void 0;super(n?.code?`Forcedretry:${n.code}`:"Forced retry",i?{cause:i}:void 0);this.customDelay=n?.delay,this.code=n?.code,this.customRequest=n?.request}}class Hc extends Error{name="SchemaValidationError";issues;constructor(n){super("Response schema validation failed");this.issues=n}}class Ni extends _i{name="TimeoutError";request;constructor(n){super(`Requesttimedout:${n.method}${n.url}`);this.request=n}}var Pc=(()=>{let n=!1,i=!1,r=typeof globalThis.ReadableStream==="function",o=typeof globalThis.Request==="function";if(r&&o)try{i=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type")}catch(t){if(t instanceof Error&&t.message==="unsupported BodyInit type")return!1;throw t}return n&&!i})(),rN=typeof globalThis.AbortController==="function",Dv=typeof globalThis.AbortSignal==="function"&&typeof globalThis.AbortSignal.any==="function",oN=typeof globalThis.ReadableStream==="function",uN=typeof globalThis.FormData==="function",Uv=["get","post","put","patch","head","delete"],vQ=()=>{return};vQ();var eN={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Tr=2147483647,lN=40,Sv=Symbol("stop");class Ov{options;constructor(n){this.options=n}}var vN=(n)=>new Ov(n),$N={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},IN={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 Av=new TextEncoder,$Q=(n)=>{if(!n)return 0;if(n instanceof FormData){let i=0;for(let[r,o]of n)i+=lN,i+=Av.encode(`Content-Disposition:form-data;name="${r}"`).byteLength,i+=typeof o==="string"?Av.encode(o).byteLength:o.size;return i}if(n instanceof Blob)return n.size;if(n instanceof ArrayBuffer||ArrayBuffer.isView(n))return n.byteLength;if(typeof n==="string")return Av.encode(n).byteLength;if(n instanceof URLSearchParams)return Av.encode(n.toString()).byteLength;return 0},gN=(n,i,r)=>{let o,t=0;return n.pipeThrough(new TransformStream({transform(u,e){if(e.enqueue(u),o){t+=o.byteLength;let l=i===0?0:t/i;if(l>=1)l=1-Number.EPSILON;r?.({percent:l,totalBytes:Math.max(i,t),transferredBytes:t},o)}o=u},flush(){if(o)t+=o.byteLength,r?.({percent:1,totalBytes:Math.max(i,t),transferredBytes:t},o)}}))},bN=(n,i)=>{if(!n.body)return n;let r={status:n.status,statusText:n.statusText,headers:n.headers};if(n.status===204)return new Response(null,r);let o=Math.max(0,Number(n.headers.get("content-length"))||0);return new Response(gN(n.body,o,i),r)},wN=(n,i,r)=>{if(!n.body)return n;let o=$Q(r??n.body);return new Request(n,{duplex:"half",body:gN(n.body,o,i)})};var Yi=(n)=>n!==null&&typeof n==="object";var IQ=Symbol("replaceOption"),Qc=(n)=>Yi(n)&&n[IQ]===!0?{isReplace:!0,value:n.value}:{isReplace:!1,value:n};var ku=(...n)=>{for(let i of n)if((!Yi(i)|
Line truncated
`,{mode:384}),i}function zr(n,i,r=[]){let o=i.corpId?.trim()||void 0,t=i.stateful?i.defaultCorpId?.trim()||void 0:void 0,u=o??t;if(u){let l=n.find(($)=>$.id===u);if(l)return l;throw Error(`Noenterpriseconfigfoundfor${u}`)}if(!i.stateful)throw Error("Stateless mode is enabled. Every enterprise command requires --corp <corpId>. Use `seal-homeconfigmodestateful` to enable a default enterprise.");let e=n[0];if(e)return e;throw Error("No enterprise config found. Add a non-example JSON file under one of: "+(r.length?r.join(", "):"the configured enterprise directories"))}import{readFileSync as pF}from"node:fs";import{randomBytes as VF}from"node:crypto";import{randomBytes as SL}from"node:crypto";var rF=v.object({staffId:v.string(),name:v.string().optional(),code:v.string().default(""),bindTime:v.number().optional()}),oF=v.object({id:v.string(),tenantId:v.string(),name:v.string(),isAdmin:v.boolean().default(!1),permissions:v.array(v.string()).default([]),providerUserId:v.string().optional(),hosecloudStaff:rF.optional()}),uF=v.object({apiKey:v.string().optional(),corporationId:v.string().optional(),corporationName:v.string().optional()}),eF=v.object({id:v.string(),name:v.string(),tenantSlug:v.string().optional(),isDemo:v.boolean().default(!1),logoUrl:v.string().nullable().optional(),hoseCorpConfig:uF.optional()}),RN=v.object({user:oF,tenant:eF}),lF=v.object({id:v.string(),name:v.string(),email:v.string().nullable().optional(),emailVerified:v.boolean().optional(),image:v.string().nullable().optional(),tenantId:v.string().optional(),provider:v.string().optional(),providerUserId:v.string().optional(),mobile:v.string().nullable().optional(),status:v.string().optional(),permissions:v.array(v.string()).default([]),isAdmin:v.boolean().default(!1),hosecloudStaff:v.unknown().optional()}).passthrough(),vF=v.object({id:v.string(),token:v.string().optional(),expiresAt:v.string(),createdAt:v.string().optional(),updatedAt:v.string().optional(),ipAddress:v.string().optional(),userAgent:v.string().optional(),userId:v.string(),delegationId:v.string().nullable().optional()}).passthrough(),xN=v.object({user:lF,session:vF}),Pv=v.object({id:v.string(),tenantId:v.string().optional(),code:v.number().optional(),description:v.string(),scope:v.string(),strictness:v.string(),status:v.string().optional(),createdAt:v.number().optional(),updatedAt:v.number().optional()}),aN=v.object({rules:v.array(Pv),hasPendingDeletes:v.boolean().default(!1)}),$F=v.object({code:v.string().optional(),description:v.string(),scope:v.string(),strictness:v.string()}),Qv=v.object({id:v.string(),tenantId:v.string().optional(),versionNumber:v.number(),versionName:v.string().nullable().optional(),publishedBy:v.string().nullable().optional(),publishedByName:v.string().nullable().optional(),rules:v.array($F).default([]),publishedAt:v.number().optional(),createdAt:v.number().optional()}),sN=v.object({version:Qv,rulesCount:v.number()}),Ju=v.object({id:v.string(),tenantId:v.string().optional(),title:v.string(),purpose:v.string().default(""),contentType:v.string().default("policy"),content:v.string(),status:v.string().default("published"),enabled:v.boolean().default(!0),scenarios:v.array(v.string()).default([]),tags:v.array(v.string()).default([]),category:v.string().nullable().optional(),categoryTags:v.array(v.string()).default([]),createdBy:v.string().nullable().optional(),createdByName:v.string().nullable().optional(),createdAt:v.number().optional(),updatedAt:v.number().optional(),updatedBy:v.string().nullable().optional(),updatedByName:v.string().nullable().optional(),isDeleted:v.boolean().default(!1)}),nL=v.object({articles:v.array(Ju),total:v.number().optional()}),IF=v.object({explicitApprove:v.string().default(""),explicitReject:v.string().default(""),exemptApprove:v.string().default(""),review:v.string().default("")}).passthrough(),gF=v.object({type:v.string(),signKey:v.string().optional(),outboundName:v.string().optional(),mode:v.string().optional(),autoApprovalRate:v.number().optional(),apiKey:v.string().optional(),apiSecret:v.string().optional(),apiOrigin:v.string().optional(),corporationId:v.string().optional(),ebotSignKey:v.string().optional(),completionSignKey:v.string().optional(),outboundMessageId:v.string().optional(),completionMessageId:v.string().optional()}).passthrough(),bF=v.enum(["assisted","semi_automatic","fully_automatic"]),CN=v.object({id:v.string(),url:v.string().url()}).passthrough(),Xu=v.object({type:v.literal("webhook"),id:v.string(),name:v.string(),mode:bF,incomingDocumentWebhook:CN,outgoingResultWebhook:v.string().url(),incomingManualResultWebhook:CN,secret:v.string().min(1),autoApprovalRate:v.number().int().min(0).max(100).optional()}).passthrough(),ac=v.object({id:v.string().optional(),tenantId:v.string().optional(),tone:v.string().optional(),language:v.string().optional(),detailLevel:v.string().optional(),outputFormat:v.string().optional(),examples:v.array(v.string()).default([]),prohibitedPhrases:v.array(v.string()).default([]),cus
Line truncated
`},servers:[{url:"http://localhost:8787",description:"Reserved for a future local HTTP adapter; the current service uses MCP stdio."}],security:[{localSession:[]}],tags:[{name:"Corps",description:"Local enterprise configuration selection."},{name:"Source",description:"Source-derived Seal enterprise configuration."},{name:"Auth",description:"Wrapped authentication diagnostics and current identity."},{name:"Approval Runs",description:"Wrapped approval run history, summaries, document URLs, and trace bridge helpers."},{name:"Approval Knowledge",description:"Wrapped approval rules, documents, preferences, and search."},{name:"Simulation",description:"Wrapped simulation batch record access."}],paths:{"/v1/corps":{get:{tags:["Corps"],operationId:"listCorps",summary:"List configured enterprises",responses:{"200":{description:"Configured enterprises.",content:{"application/json":{schema:{type:"array",items:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","direct","seal"]},current:{type:"boolean"}}}}}}}}}},"/v1/corps/current":{get:{tags:["Corps"],operationId:"getCurrentCorp",summary:"Get current enterprise",description:"Returns the configured default enterprise in stateful mode. Stateless mode has no current enterprise and requires an explicit corpId for enterprise operations.",responses:{"200":{description:"Current enterprise.",content:{"application/json":{schema:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","direct","seal"]},current:{type:"boolean"}}}}}}}}},"/v1/corps/current/switch":{post:{tags:["Corps"],operationId:"switchCurrentCorp",summary:"Switch current enterprise",requestBody:{required:!0,content:{"application/json":{schema:{type:"object",required:["corpId"],properties:{corpId:{type:"string"}}}}}},responses:{"200":{description:"Switched enterprise.",content:{"application/json":{schema:{type:"object",required:["current","id","name"],properties:{current:{type:"boolean"},id:{type:"string"},name:{type:"string"}}}}}},"404":{description:"Requested resource was not found.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}}}},"/v1/source/config":{get:{tags:["Source"],operationId:"getSourceConfig",summary:"Resolve source-derived Seal enterprise config",parameters:[{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."}],responses:{"200":{description:"Redacted Seal enterprise config.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,description:"Redacted Seal enterprise config resolved from the configured source."}}}},"401":{description:"Local service authentication failed or downstream Seal auth failed.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}}}},"/v1/auth/diagnose":{get:{tags:["Auth"],operationId:"diagnoseAuth",summary:"Diagnose wrapped source-to-Seal authentication",parameters:[{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."}],responses:{"200":{description:"Authentication stage diagnosis.",content:{"application/json":{schema:{type:"object",required:["stages"],properties:{stages:{type:"array",items:{$ref:"#/components/schemas/AuthStage"}}}}}}}}}},"/v1/whoami":{get:{tags:["Auth"],operationId:"whoami",summary:"Get current wrapped Seal identity",parameters:[{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."}],responses:{"200":{description:"Current Seal user and tenant.",content:{"application/json":{schema:{type:"object",required:["user","tenant"],properties:{user:{$ref:"#/components/schemas/SealUser"},tenant:{$ref:"#/components/schemas/SealTenant"}}}}}},"401":{description:"Local service authentication failed or downstream Seal auth failed.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}}}},"/v1/session":{get:{tags:["Auth"],operationId:"getSession",summary:"Get current wrapped Seal session metadata",parameters:[{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."}],responses:{"2
Line truncated
`},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
`,{flag:"a",mode:384})}var F4=Eh(_h(),".config","seal-home");async function Nk(n,i){let r=await _t(n,{appRoot:i.appRoot,entryFile:i.entryFile,stateDir:F4,version:R,launcher:i.launcher});if(r!==void 0)B(r)}import{existsSync as Zh,readFileSync as Lk}from"node:fs";async function yk(n,i,r,o,t){if(n==="batch-records"||n==="records"){let u=i??U(t.options.batchId)??U(t.options["batch-id"]);if(!u)throw Error("Usage: seal-home simulation batch-records <batchId>");await X("seal_simulation_batch_records_get",r,o,{batchId:u,query:U(t.options.query)},J(t.options));return}if(n==="create"||n==="run"){let u=U(t.options.mode)??U(t.options.sourceSystem)??U(t.options["source-system"])??"hosecloud",e=u==="material-pack"?"material_pack":u,l=U(t.options.schemaConfig)??U(t.options["schema-config"]),$=l?JSON.parse(Lk(l,"utf8")):void 0,I=U(t.options.input),g=I?JSON.parse(Lk(I,"utf8")):ri(t.json),b=U(t.options.packageId)??U(t.options["package-id"]),w=qn(t.options.packageIds)??qn(t.options["package-ids"])??(b?[b]:void 0),f=qn(t.options.flowIds)??qn(t.options["flow-ids"])??qn(t.options.documentSn)??qn(t.options["document-sn"]),c=U(t.options.signKey)??U(t.options["sign-key"])??U(t.options.integration);await X("seal_simulation_batch_create",r,o,{mode:e,sourceSystem:e,flowIds:f,documentSn:f,rejectNodeName:U(t.options.rejectNode)??U(t.options["reject-node"])??null,thinkingDepthOverride:U(t.options.thinkingDepth)??U(t.options["thinking-depth"]),skipInvoiceGeneration:M(t.options.skipInvoiceGeneration)??M(t.options["skip-invoice-generation"]),skipExpenseExtraction:M(t.options.skipExpenseExtraction)??M(t.options["skip-expense-extraction"]),disableAttachmentCache:M(t.options.disableAttachmentCache)??M(t.options["disable-attachment-cache"]),signKey:c,packageIds:w,packageId:b,templateId:U(t.options.templateId)??U(t.options["template-id"]),schemaConfig:$,requestIds:qn(t.options.requestIds)??qn(t.options["request-ids"]),workflowTypeId:U(t.options.workflowTypeId)??U(t.options["workflow-type-id"]),flowStatusList:qn(t.options.flowStatusList)?.map(Number)??qn(t.options["flow-status-list"])?.map(Number),businessCodes:qn(t.options.businessCodes)??qn(t.options["business-codes"]),documentType:U(t.options.documentType)??U(t.options["document-type"]),startTime:ln(t.options.startTime)??ln(t.options["start-time"]),endTime:ln(t.options.endTime)??ln(t.options["end-time"]),status:qn(t.options.status),limit:ln(t.options.limit),rawParams:g},J(t.options));return}if(n==="wait"){let u=i??U(t.options.batchId)??U(t.options["batch-id"]);if(!u)throw Error("Usage: seal-home simulation wait <batchId> [--timeout 10m] [--poll-interval 2s]");await X("seal_simulation_batch_wait",r,o,{batchId:u,timeout:U(t.options.timeout),pollInterval:U(t.options.pollInterval)??U(t.options["poll-interval"])},J(t.options));return}if(n==="clean"||n==="delete"){let u=i??U(t.options.batchId)??U(t.options["batch-id"]);if(!u)throw Error("Usage: seal-home simulation clean <batchId>");await X("seal_simulation_batch_clean",r,o,{batchId:u},J(t.options));return}if(n==="specifications"){let u=i??U(t.options.integration)??U(t.options.signKey)??U(t.options["sign-key"]);await X("seal_simulation_specifications_list",r,o,{signKey:u},J(t.options));return}if(n==="list"){await X("seal_simulation_batches_list",r,o,{limit:ln(t.options.limit)},J(t.options));return}if(n==="get"){let u=i??U(t.options.batchId)??U(t.options["batch-id"]);if(!u)throw Error("Usage: seal-home simulation get <batchId>");await X("seal_simulation_batch_get",r,o,{batchId:u},J(t.options));return}if(n==="templates"){await X("seal_simulation_templates_get",r,o,{},J(t.options));return}if(n==="integrations"){await X("seal_simulation_integrations_get",r,o,{},J(t.options));return}if(n==="package-upload"){let u=i??U(t.options.file);if(!u)throw Error("Usage: seal-home simulation package-upload <材料包.zip>");if(!Zh(u))throw Error(`Filenotfound:${u}`);await X("seal_simulation_material_package_upload",r,o,{filePath:u},J(t.options));return}throw Error(`Unknownsimulationcommand:${n??""}.Run'seal-home help'foravailablecommands.`)}import{existsSync as Vk}from"node:fs";import{join as o$}from"node:path";import{mkdirSync as Fk,writeFileSync as rK}from"node:fs";import{homedir as oK}from"node:os";import{dirname as uK,join as hk}from"node:path";var kk=`---
name:seal-home
description:"v0.9.5: Use when working with Seal Home tenant operations: packaged customer feedback from WeChat or screenshots, target-enterprise discovery, approval-run and Langfuse diagnosis, simulation test batch creation and publishing, minimal approval-rule remediation and publishing, delegation links, Hose/合思 authorization, LLM config, permissions, billing, users, rules, documents, and search."
description:"v0.9.7: Use for Seal Home 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-home\` 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.
@@ -235,6 +235,11 @@ seal-home tools list
##FirstRules
-TreatCLI/MCPastheAgent's execution channel, not the user'sinterface.Translatenatural-languageintentintocommandsyourself;neverasktheusertocomposeCLIsyntax,JSONpayloads,placeholdervalues,orinternalIDs.
-Beforeaskingforenterpriseparameters,run\`seal-home 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\`.
-Ifnoenterpriseisconfigured,theuserisinstallingforthefirsttime,ortheuserprovidescredentials,anassistancelink,orabrowser-copiedcURL,read\`references/enterprise-onboarding.md\` before asking questions or running setup commands.
-Neveraskanormaluserfor\`corpId\`, \`staffId\`, \`proxyStaffBizId\`, \`tenantId\`, or another discoverable internal ID. Discover it first. If discovery fails, explain what the field means, why it could not be discovered, and exactly where the user can find it.
-Prefercompactcommandsfirst:\`pick\`, \`--summary\`, \`--fields\`, \`attachments --summary\`, \`rules count\`, and \`rules list --summary\`.
-ParseJSONstdout.Donotscrapehumantext.
-Donothand-editenterpriseconfigsfornormalsetup.Use\`seal-home corps ...\`.
@@ -251,6 +256,7 @@ seal-home tools list
##RouteByIntent
-Firstinstall/zeroconfiguration/“howdoIconnectmyenterprise?”/usersuppliesappcredentials,anassistancelink,orF12/NetworkcURL:read\`references/enterprise-onboarding.md\`. Ask what material the user already has in plain language, then discover all remaining identifiers automatically.
-User-facingSealtenantassistancelink(Seal协助/Seal授权/委托):resolvethenamedenterprisefirst,thenrun\`seal-home 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 AG=`interface:
`;var dk=`interface:
display_name:"Seal Home"
short_description:"Diagnose approval feedback and publish minimal rule fixes"
default_prompt:"Use $seal-home 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."
@@ -426,7 +434,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 GG="# Approval Run Lightweight Queries\n\nUse this reference when the user gives a 合思/易快报单号, source document SN, record ID, simulation batch ID, or asks for an approval decision without needing the full raw run payload.\n\n## Locate A Run By Document Number\n\nPrefer `pick` before broad search + bridge + get.\n\n```bash\nseal-homeapproval-runspick--corp<corpId>--sn<sourceDocumentSN>--latest\nseal-homeapproval-runspick--corp<corpId>--sn<sourceDocumentSN>--batch<batchId>--latest\nseal-homeapproval-runspick--corp<corpId>--sn<sourceDocumentSN>--latest--fieldsrecordId,sourceDocumentSN,status,aiDecision,aiSummary\n```\n\nDefault output is intentionally small: `recordId`, `sourceDocumentSN`, `sourceDocumentId`, `simulationBatchId`, `status`, `taskMode`, `ruleSetVersionNumber`, `langfuseTraceId`, `manualResult`, `aiDecision`, and `aiSummary`.\n\nIf there are multiple candidates and `--latest` was not used, report the candidates and ask which one to inspect.\n\n## Read Compact Run Detail\n\nUse `--summary` for most diagnosis and support questions.\n\n```bash\nseal-homeapproval-runsget<recordId>--corp<corpId>--summary\n```\n\nUse `--fields` when the user needs a particular slice.\n\n```bash\nseal-homeapproval-runsget<recordId>--corp<corpId>--fieldsmetadata\nseal-homeapproval-runsget<recordId>--corp<corpId>--fieldsdocument.fields,result.summary\nseal-homeapproval-runsget<recordId>--corp<corpId>--fieldsresult.summary,result.decision,result.riskPoints\nseal-homeapproval-runsget<recordId>--corp<corpId>--fieldsdocument.keyFields,result,manualApprovalRecord,ruleSetVersionNumber\n```\n\nAvoid full `approval-runsget<recordId>` unless the user specifically needs raw document fields, pipeline logs, invoice rawData, or signed URLs. Prefer `--output-file` for full payloads.\n\n## Understand The Case First\n\nBefore pulling the full document, use:\n\n```bash\nseal-homeapproval-runsdocument-summary<recordId>--corp<corpId>\n```\n\nThis is for quick case reading: template/title, key fields, amount, expense type, cost company, payee, invoice summary, attachment names, AI result, and manual result.\n\n## Extract AI-Cited Rules\n\nUse this when the user asks \"AI 用了哪条规则\", \"为什么命中这条\", or needs the rule evidence for a specific run.\n\n```bash\nseal-homeapproval-runscited-rules<recordId>--corp<corpId>\n```\n\nReturn and discuss `runtimeRuleId`, `ruleCode`, `versionNumber`, `scope`, `strictness`, `appliedAnalysis`, `checkResult`, and `findings` when present.\n\nIf the user then wants the full text of one cited rule, use `rulesget--record-id<recordId>--runtime-idrule-205` from `rule-lightweight.md`.\n\n## Attachments Without Raw Payloads\n\nUse:\n\n```bash\nseal-homeapproval-runsattachments<recordId>--corp<corpId>--summary\n```\n\nThis should be enough for file names, file IDs, mime types, positions, invoice/attachment grouping, and links when available. For customer disputes about OCR, receipt/invoice classification, or image content, switch to `approval-attachment-trace.md`.\n\n## Result Summary\n\nUse:\n\n```bash\nseal-homeapproval-runsresult<recordId>--corp<corpId>--summary\n```\n\nThis is for decision, summary, risk point count, matched rule count, trace ID, and record ID.\n\n## Output Discipline\n\nIf a command warns that output is large, do not retry with `--full` reflexively. Narrow with `--summary`, `--fields`, or `--output-file` first.\n";var jG=`#ApprovalAttachmentTraceInvestigation
`;var Jk="# Approval Run Lightweight Queries\n\nUse this reference when the user gives a 合思/易快报单号, source document SN, record ID, simulation batch ID, or asks for an approval decision without needing the full raw run payload.\n\n## Locate A Run By Document Number\n\nPrefer `pick` before broad search + bridge + get.\n\n```bash\nseal-homeapproval-runspick--corp<corpId>--sn<sourceDocumentSN>--latest\nseal-homeapproval-runspick--corp<corpId>--sn<sourceDocumentSN>--batch<batchId>--latest\nseal-homeapproval-runspick--corp<corpId>--sn<sourceDocumentSN>--latest--fieldsrecordId,sourceDocumentSN,status,aiDecision,aiSummary\n```\n\nDefault output is intentionally small: `recordId`, `sourceDocumentSN`, `sourceDocumentId`, `simulationBatchId`, `status`, `taskMode`, `ruleSetVersionNumber`, `langfuseTraceId`, `manualResult`, `aiDecision`, and `aiSummary`.\n\nIf there are multiple candidates and `--latest` was not used, report the candidates and ask which one to inspect.\n\n## Read Compact Run Detail\n\nUse `--summary` for most diagnosis and support questions.\n\n```bash\nseal-homeapproval-runsget<recordId>--corp<corpId>--summary\n```\n\nUse `--fields` when the user needs a particular slice.\n\n```bash\nseal-homeapproval-runsget<recordId>--corp<corpId>--fieldsmetadata\nseal-homeapproval-runsget<recordId>--corp<corpId>--fieldsdocument.fields,result.summary\nseal-homeapproval-runsget<recordId>--corp<corpId>--fieldsresult.summary,result.decision,result.riskPoints\nseal-homeapproval-runsget<recordId>--corp<corpId>--fieldsdocument.keyFields,result,manualApprovalRecord,ruleSetVersionNumber\n```\n\nAvoid full `approval-runsget<recordId>` unless the user specifically needs raw document fields, pipeline logs, invoice rawData, or signed URLs. Prefer `--output-file` for full payloads.\n\n## Understand The Case First\n\nBefore pulling the full document, use:\n\n```bash\nseal-homeapproval-runsdocument-summary<recordId>--corp<corpId>\n```\n\nThis is for quick case reading: template/title, key fields, amount, expense type, cost company, payee, invoice summary, attachment names, AI result, and manual result.\n\n## Extract AI-Cited Rules\n\nUse this when the user asks \"AI 用了哪条规则\", \"为什么命中这条\", or needs the rule evidence for a specific run.\n\n```bash\nseal-homeapproval-runscited-rules<recordId>--corp<corpId>\n```\n\nReturn and discuss `runtimeRuleId`, `ruleCode`, `versionNumber`, `scope`, `strictness`, `appliedAnalysis`, `checkResult`, and `findings` when present.\n\nIf the user then wants the full text of one cited rule, use `rulesget--record-id<recordId>--runtime-idrule-205` from `rule-lightweight.md`.\n\n## Attachments Without Raw Payloads\n\nUse:\n\n```bash\nseal-homeapproval-runsattachments<recordId>--corp<corpId>--summary\n```\n\nThis should be enough for file names, file IDs, mime types, positions, invoice/attachment grouping, and links when available. For customer disputes about OCR, receipt/invoice classification, or image content, switch to `approval-attachment-trace.md`.\n\n## Result Summary\n\nUse:\n\n```bash\nseal-homeapproval-runsresult<recordId>--corp<corpId>--summary\n```\n\nThis is for decision, summary, risk point count, matched rule count, trace ID, and record ID.\n\n## Output Discipline\n\nIf a command warns that output is large, do not retry with `--full` reflexively. Narrow with `--summary`, `--fields`, or `--output-file` first.\n";var Xk=`#ApprovalAttachmentTraceInvestigation
-Ifthetargetenterpriseislisted,matchtheuser'shumanenterprisenametoitsreturned\`id\` and use that value as \`--corp\` on every command. Do not ask the user for \`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-homeauthdiagnose--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-home auth hose-link\` and \`seal-home delegation create\` generate links for an enterprise that is already configured; they do not import a new enterprise from a received link.
ThecurrentCLIdoesnotdirectlyimportanincomingassistancelink.Donotpretendthat\`corps add-hose\` or \`corps add-seal\` accepts the raw URL. If a browser tool is available and the user authorized opening the link, open it, confirm the final tenant host, and obtain an authenticated Seal business request. Otherwise explain that the link must be opened in the user's browser, then continue with the browser cURL route below.
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-home 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.
@@ -1232,14 +1357,18 @@ Use this reference for Hose/合思 enterprise configuration and user-facing Hose
UsetheCLIfornormalenterprisesetup.Donotinspectsourcecodeorhand-edit\`~/.config/seal-home/enterprises/*.json\` unless the CLI fails or the user explicitly asks for low-level config debugging.
Forfirst-timesetuporwhentheuserhasanassistancelinkorbrowsercURLinsteadofstandardapplicationcredentials,read\`enterprise-onboarding.md\` first. This reference's \`add-hose\` route is specifically for durable Hose OpenAPI credentials.
\`corps add-hose\`verifies by default and writes the enterprise config. If the user says not to operate business logic, stop at\`corps\` and auth/config commands; do not run approval, rule, document, simulation, or approval-run commands.
\`corps add-hose\`probes standard domains and discovers the enterprise automatically. If it returns multiple administrator candidates, present their names and masked phones for the user to choose, then retry with\`staffName\`, \`staffPhone\`, or the selected \`staffId\`. Do not ask for \`domain\`, \`corpId\`, \`staffId\`, or \`proxyStaffBizId\` before discovery. Ask for a dedicated/private-cloud \`domain\` only after standard probing fails.
Thecommandverifiesbydefaultandwritestheenterpriseconfig.Iftheusersaysnottooperatebusinesslogic,stopat\`corps\` and auth/config commands; do not run approval, rule, document, simulation, or approval-run commands.
##Diagnoseauthentication
@@ -1285,7 +1414,7 @@ Important:
-\`seal-home 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(i==="install"||i==="init"||i==="sync"){let o=z(t.options.local)||z(t.options.workspace),r=c(t.options.dir)??c(t.options.target)??n,u=r?r:o?n$(process.cwd(),".agents","skills","seal-home"):Tu(),l=Y0(u);T({installed:!0,targetDir:l.targetDir,fileCount:l.files.length,files:l.files});return}if(i==="status"||i==="get"||!i){let o=Tu(),r=n$(process.cwd(),".agents","skills","seal-home");T({global:{dir:o,installed:FG(n$(o,"SKILL.md"))},local:{dir:r,installed:FG(n$(r,"SKILL.md"))}});return}throw Error(`Unknownskillcommand:${i}.Run'seal-home help'foravailablecommands.`)}async function BG(i,n){if(i==="config"){T(await mt(n));return}throw Error(`Unknownsourcecommand:${i??""}.Run'seal-home help'foravailablecommands.`)}async function VG(i,n,t,o){if(!i)throw Error("Usage: seal-home tool <toolName> [--json '{...}']");await Y(i,n,t,tn(o.json),X(o.options))}function TG(){T(Ur.map((i)=>({name:i.name,description:i.description})))}import{chmodSync as RB,mkdirSync as xB,renameSync as P0,rmSync as aB,unlinkSync as MG,writeFileSync as _G}from"node:fs";import{dirname as sB,join as qG}from"node:path";import{spawnSync as Zr}from"node:child_process";function r$(i=process.execPath,n=import.meta.url){if(n.includes("/$bunfs/")||n.includes("\\$bunfs\\"))return!0;let t=i.toLowerCase().replace(/\\/g,"/");return!t.endsWith("/bun")&&!t.endsWith("/bun.exe")}var dG="yunyingk/seal-home";var i3="SEAL_HOME_GITHUB_REPO";async function zG(i,n={}){let t={appRoot:i.appRoot,entryFile:i.entryFile,stateDir:X0,version:m,launcher:i.launcher},o=n.repo||process.env[i3]?.trim()||dG,r=n.targetVersion?.trim(),u=r&&r.toLowerCase()!=="latest"?r:void 0;if(u){let y=u.replace(/^v/,""),G=pG(y,m);if(G<0){T({updated:!1,currentVersion:m,targetVersion:y,mode:r$()?"binary":"source",message:`Cannotdowngradeseal-homefromv${m}toolderversionv${y}.Updatesmustbeforward-only.`});return}if(G===0&&!n.force){T({updated:!1,currentVersion:m,targetVersion:y,mode:r$()?"binary":"source",message:`seal-homeisalreadyatversionv${m}.Use--forcetoreinstall.`});return}}if(n.changelogOnly){let y=await Q0(o,n.limit??10);T({currentVersion:m,totalQueried:y.length,releases:y.map((G)=>({version:G.version,tagName:G.tagName,publishedAt:G.publishedAt,author:G.author,releaseNotes:G.notes,releaseUrl:G.htmlUrl,isCurrent:G.version===m,isNewer:_u(G.version,m)}))});return}if(!r$()){if(n.checkOnly){let G=await Q0(o,30),a=G[0],ni=a?.version??m,Ji=G.find((gi)=>gi.version===m),Bi=_u(ni,m),Vi=G.filter((gi)=>_u(gi.version,m));T({updated:!1,updateAvailable:Bi,currentVersion:m,currentVersionPublishedAt:Ji?.publishedAt,latestVersion:ni,latestVersionPublishedAt:a?.publishedAt,behindCount:Vi.length,pendingReleases:Vi.map((gi)=>({version:gi.version,tagName:gi.tagName,publishedAt:gi.publishedAt,author:gi.author,releaseNotes:gi.notes,releaseUrl:gi.htmlUrl})),releaseNotes:a?.notes??"",releaseUrl:a?.htmlUrl??"",mode:"source",message:"Running in source development mode. Run 'seal-home update' to git pull & bun install."});return}let y=Rt(t).running;if(y)await Er("stop",t);try{ZG("git",["-C",i.appRoot,"pull","--ff-only"])}catch(G){console.error(`gitpullskipped:${GinstanceofError?G.message:String(G)}`)}if(ZG("bun",["install"],{cwd:i.appRoot}),y)await Er("start",t);T({updated:!0,serviceRestarted:y,version:m,mode:"source"});return}let l=n3(),e=r3(),$=await Q0(o,30),I=u?$.find((y)=>y.version===u||y.tagName===u||y.tagName===`v${u}`)??await EG(o,u):$[0]??await EG(o);if(!I){T({updated:!1,currentVersion:m,mode:"binary",message:`FailedtoqueryreleasesfromGitHubrepository'${o}'`});return}let g=I.version,b=$.find((y)=>y.version===m),w=_u(g,m),f=w||Boolean(n.force),D=$.filter((y)=>_u(y.version,m));if(n.checkOnly){T({updated:!1,updateAvailable:w,currentVersion:m,currentVersionPublishedAt:b?.publishedAt,latestVersion:g,latestVersionPublishedAt:I.publishedAt,behindCount:D.length,pendingReleases:D.map((y)=>({version:y.version,tagName:y.tagName,publishedAt:y.publishedAt,author:y.author,releaseNotes:y.notes,releaseUrl:y.htmlUrl})),releaseNotes:I.notes,releaseUrl:I.htmlUrl,mode:"binary"});return}if(!f){T({updated:!1,currentVersion:m,currentVersionPublishedAt:b?.publishedAt,latestVersion:g,latestVersionPublishedAt:I.publishedAt,mode:"binary",message:`seal-homeisalreadyuptodate(v${m})`});return}let S=t3(I.assets,l,e);if(!S)throw Error(`Nocompatiblebinaryfoundfor${l}-${e}inreleasev${g}.Availableassets:${I.assets.map((y)=>y.name).join(", ")}`);let N=Rt(t).running;if(N)await Er("stop",t);let L=process.execPath,K=sB(L),F=qG(K,`.tmp-update-${Date.now()}`);xB(F,{recursive:!0});try{let y=qG(F,S.name);await o3(S.downloadUrl,y,I.tagName,S.name);let G=y;if(S.name.endsWith(".tar.gz")||S.name.endsWith(".tgz"))G=u3(y,F,l);else if(S.name.endsWith(".zip"))G=l3(y,F,l);if(RB(G,493),process.platform==="darwin")try{Zr("/usr/bin/codesign",["--remove-signature",G],{stdio:"ignore"}),Zr("/usr/bin/codesign",["--force","--sign","-",G],{stdio:"ignore"})}catch{}if(process.platform==="win32"){let ni
Line truncated
`);return}if(n==="install"||n==="init"||n==="sync"){let o=M(r.options.local)||M(r.options.workspace),t=U(r.options.dir)??U(r.options.target)??i,u=t?t:o?o$(process.cwd(),".agents","skills","seal-home"):qu(),e=h4(u);B({installed:!0,targetDir:e.targetDir,fileCount:e.files.length,files:e.files});return}if(n==="status"||n==="get"||!n){let o=qu(),t=o$(process.cwd(),".agents","skills","seal-home");B({global:{dir:o,installed:Vk(o$(o,"SKILL.md"))},local:{dir:t,installed:Vk(o$(t,"SKILL.md"))}});return}throw Error(`Unknownskillcommand:${n}.Run'seal-home help'foravailablecommands.`)}async function Tk(n,i){if(n==="config"){B(await xr(i));return}throw Error(`Unknownsourcecommand:${n??""}.Run'seal-home help'foravailablecommands.`)}async function _k(n,i,r,o){if(!n)throw Error("Usage: seal-home tool <toolName> [--json '{...}']");await X(n,i,r,ri(o.json),J(o.options))}function Ek(){B(Ut.map((n)=>({name:n.name,description:n.description})))}import{chmodSync as eK,mkdirSync as lK,renameSync as K4,rmSync as vK,unlinkSync as Ck,writeFileSync as Zk}from"node:fs";import{dirname as $K,join as Mk}from"node:path";import{spawnSync as Et}from"node:child_process";function u$(n=process.execPath,i=import.meta.url){if(i.includes("/$bunfs/")||i.includes("\\$bunfs\\"))return!0;let r=n.toLowerCase().replace(/\\/g,"/");return!r.endsWith("/bun")&&!r.endsWith("/bun.exe")}var Rk="yunyingk/seal-home";var IK="SEAL_HOME_GITHUB_REPO";async function xk(n,i={}){let r={appRoot:n.appRoot,entryFile:n.entryFile,stateDir:F4,version:R,launcher:n.launcher},o=i.repo||process.env[IK]?.trim()||Rk,t=i.targetVersion?.trim(),u=t&&t.toLowerCase()!=="latest"?t:void 0;if(u){let j=u.replace(/^v/,""),y=ak(j,R);if(y<0){B({updated:!1,currentVersion:R,targetVersion:j,mode:u$()?"binary":"source",message:`Cannotdowngradeseal-homefromv${R}toolderversionv${j}.Updatesmustbeforward-only.`});return}if(y===0&&!i.force){B({updated:!1,currentVersion:R,targetVersion:j,mode:u$()?"binary":"source",message:`seal-homeisalreadyatversionv${R}.Use--forcetoreinstall.`});return}}if(i.changelogOnly){let j=await B4(o,i.limit??10);B({currentVersion:R,totalQueried:j.length,releases:j.map((y)=>({version:y.version,tagName:y.tagName,publishedAt:y.publishedAt,author:y.author,releaseNotes:y.notes,releaseUrl:y.htmlUrl,isCurrent:y.version===R,isNewer:Tu(y.version,R)}))});return}if(!u$()){if(i.checkOnly){let y=await B4(o,30),T=y[0],x=T?.version??R,dn=y.find((un)=>un.version===R),Wn=Tu(x,R),An=y.filter((un)=>Tu(un.version,R));B({updated:!1,updateAvailable:Wn,currentVersion:R,currentVersionPublishedAt:dn?.publishedAt,latestVersion:x,latestVersionPublishedAt:T?.publishedAt,behindCount:An.length,pendingReleases:An.map((un)=>({version:un.version,tagName:un.tagName,publishedAt:un.publishedAt,author:un.author,releaseNotes:un.notes,releaseUrl:un.htmlUrl})),releaseNotes:T?.notes??"",releaseUrl:T?.htmlUrl??"",mode:"source",message:"Running in source development mode. Run 'seal-home update' to git pull & bun install."});return}let j=ar(r).running;if(j)await _t("stop",r);try{mk("git",["-C",n.appRoot,"pull","--ff-only"])}catch(y){console.error(`gitpullskipped:${yinstanceofError?y.message:String(y)}`)}if(mk("bun",["install"],{cwd:n.appRoot}),j)await _t("start",r);B({updated:!0,serviceRestarted:j,version:R,mode:"source"});return}let e=gK(),l=bK(),$=await B4(o,30),I=u?$.find((j)=>j.version===u||j.tagName===u||j.tagName===`v${u}`)??await zk(o,u):$[0]??await zk(o);if(!I){B({updated:!1,currentVersion:R,mode:"binary",message:`FailedtoqueryreleasesfromGitHubrepository'${o}'`});return}let g=I.version,b=$.find((j)=>j.version===R),w=Tu(g,R),f=w||Boolean(i.force),c=$.filter((j)=>Tu(j.version,R));if(i.checkOnly){B({updated:!1,updateAvailable:w,currentVersion:R,currentVersionPublishedAt:b?.publishedAt,latestVersion:g,latestVersionPublishedAt:I.publishedAt,behindCount:c.length,pendingReleases:c.map((j)=>({version:j.version,tagName:j.tagName,publishedAt:j.publishedAt,author:j.author,releaseNotes:j.notes,releaseUrl:j.htmlUrl})),releaseNotes:I.notes,releaseUrl:I.htmlUrl,mode:"binary"});return}if(!f){B({updated:!1,currentVersion:R,currentVersionPublishedAt:b?.publishedAt,latestVersion:g,latestVersionPublishedAt:I.publishedAt,mode:"binary",message:`seal-homeisalreadyuptodate(v${R})`});return}let S=wK(I.assets,e,l);if(!S)throw Error(`Nocompatiblebinaryfoundfor${e}-${l}inreleasev${g}.Availableassets:${I.assets.map((j)=>j.name).join(", ")}`);let N=ar(r).running;if(N)await _t("stop",r);let L=process.execPath,K=$K(L),H=Mk(K,`.tmp-update-${Date.now()}`);lK(H,{recursive:!0});try{let j=Mk(H,S.name);await fK(S.downloadUrl,j,I.tagName,S.name);let y=j;if(S.name.endsWith(".tar.gz")||S.name.endsWith(".tgz"))y=cK(j,H,e);else if(S.name.endsWith(".zip"))y=DK(j,H,e);if(eK(y,493),process.platform==="darwin")try{Et("/usr/bin/codesign",["--remove-signature",y],{stdio:"ignore"}),Et("/usr/bin/codesign",["--force","--sign","-",y],{stdio:"ignore"})}catch{}if(process.platform==="win32"){let x=`${Line truncated
`)}catch{}}async function fK(n,i,r,o){let t=[],u=r?r.startsWith("v")?r:`v${r}`:void 0,e=o||n.split("/").pop()||"";if(u&&e)t.push(`https://git.ying-qing.cn/gitea/seal-home/releases/download/${u}/${e}`);if(n.startsWith("https://git.ying-qing.cn"))t.push(n);if(u&&e){let c=`https://github.com/${Rk}/releases/download/${u}/${e}`;t.push(`https://ghfast.top/${c}`),t.push(`https://gh.ddlc.top/${c}`),t.push(c)}else if(n.includes("github.com"))t.push(`https://ghfast.top/${n}`),t.push(`https://gh.ddlc.top/${n}`),t.push(n);else t.push(n);let l=Array.from(new Set(t)),$,I=6000,g=6000,b=307200,w=1e4,f=180000;for(let c=0;c<l.length;c++){let S=l[c],N=new AbortController,L="",K=(T)=>{L=T;try{N.abort()}catch{}},H=setTimeout(()=>{K("Connection timed out (no response headers within 6s)")},I),j,y;try{e$(`==> [${c+1}/${l.length}] Downloading via: ${S}`);let T=await fetch(S,{signal:N.signal});if(H)clearTimeout(H),H=void 0;if(!T.ok)throw Error(`HTTP ${T.status} ${T.statusText}`);j=setTimeout(()=>{K("Overall download time exceeded 3 minutes")},f);let x=Number(T.headers.get("content-length"))||0,dn=T.body?.getReader();if(!dn){let wi=Buffer.from(await T.arrayBuffer());if(wi.length<1000)throw Error(`Downloaded content is suspiciously small (${wi.length} bytes)`);Zk(i,wi),e$(`✓ Download succeeded (${(wi.length/1024/1024).toFixed(1)} MB)`);return}let Wn=[],An=0,un=0;y=setTimeout(()=>{if(An<b){let wi=(An/1024).toFixed(1);K(`Initial transfer too slow (${wi} KB < 300 KB in 6s), switching mirror...`)}},g);while(!0){let wi=dn.read(),sr,ud=new Promise((v$,$$)=>{sr=setTimeout(()=>{$$(Error("Data transfer stalled (no chunk received for 10s)"))},w)}),q4;try{q4=await Promise.race([wi,ud])}finally{if(sr)clearTimeout(sr)}let{done:ed,value:l$}=q4;if(ed)break;if(l$){if(Wn.push(l$),An+=l$.length,y&&An>=b)clearTimeout(y),y=void 0;let v$=Date.now();if(v$-un>200){un=v$;let $$=x?Math.round(An/x*100):0,ld=(An/1048576).toFixed(1),vd=x?(x/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${$$}% (${ld} / ${vd} MB)...`)}catch{}}}}try{process.stderr.write(`
"description":"Planned HTTP contract for the seal-home 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-home is responsible for enterprise\nselection, source authentication, response compaction, and diagnostics-friendly fields.\n"
description:"v0.9.5: Use when working with Seal Home tenant operations: packaged customer feedback from WeChat or screenshots, target-enterprise discovery, approval-run and Langfuse diagnosis, simulation test batch creation and publishing, minimal approval-rule remediation and publishing, delegation links, Hose/合思 authorization, LLM config, permissions, billing, users, rules, documents, and search."
description:"v0.9.7: Use for Seal Home 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.9.5
short-description:Seal tenant and Hose approval automation (v0.9.5)
version:0.9.7
short-description:Seal tenant and Hose approval automation (v0.9.7)
---
# Seal Home (v0.9.5)
# Seal Home (v0.9.7)
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-home` 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.
@@ -18,6 +18,11 @@ seal-home tools 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-home 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`.
- 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.
- 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.
- Never ask a normal user for `corpId`, `staffId`, `proxyStaffBizId`, `tenantId`, or another discoverable internal ID. Discover it first. If discovery fails, explain what the field means, why it could not be discovered, and exactly where the user can find it.
- 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-home corps ...`.
@@ -34,6 +39,7 @@ seal-home tools list
## Route By Intent
- First install / zero configuration / “how do I connect my enterprise?” / user supplies app credentials, an assistance link, or F12/Network cURL: read `references/enterprise-onboarding.md`. Ask what material the user already has in plain language, then discover all remaining identifiers automatically.
- User-facing Seal tenant assistance link (Seal 协助/Seal 授权/委托): resolve the named enterprise first, then run `seal-home 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.
Read 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.
## Start With Discovery
Run this before asking for setup parameters:
```bash
seal-home version
seal-home corps list
```
- 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 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?”
Do not open with a JSON template or a list of internal fields.
All 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.
## Keep Two Concepts Separate
Classify both the enterprise identity origin and how the current credential was acquired:
| Enterprise identity origin | Credential material the user may have | Meaning |
| --- | --- | --- |
| Hose/合思-sourced Seal tenant | Hose `appKey` + `appSecurity` | Stable, refreshable standard integration |
| Hose/合思-sourced Seal tenant | Hose authorization/assistance link | Temporary Hose authorization that can lead into the Seal SSO session |
| Hose/合思-sourced Seal tenant | cURL copied from an authenticated Hose or Seal page | Snapshot of a signed-in browser session; it may expire |
| Seal-native tenant | Seal assistance/delegation link | Temporary delegated access to a Seal tenant |
| Seal-native tenant | cURL copied from an authenticated Seal page | Snapshot containing the Seal host and session authentication |
Credential shape alone does not define identity origin. In particular, a Hose-sourced user eventually receives a Seal Bearer session after SSO. When `whoami` returns provider metadata, preserve it and use it to describe the tenant accurately.
## Parameter Ownership
Ask the user only for information that cannot be discovered safely:
| Field | Owner and behavior |
| --- | --- |
| `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. |
| Enterprise name and `corpId` | Discover from the credential response or Seal `whoami`. Do not ask the user to invent or locate them first. |
| 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. |
| Seal URL, tenant ID, tenant slug | Discover from the assistance link, cURL host, and Seal `whoami`. |
| Bearer token, cookies, signed query tokens | Extract only from user-supplied authentication material. Never print them back or include them in summaries. |
## Route 1: Standard Hose Credentials
This is the preferred durable route for a Hose-sourced tenant. Read `hose-enterprise-init.md`, then use:
```bash
seal-home corps add-hose --json '{"appKey":"...","appSecurity":"..."}'
```
The CLI probes the standard domains, discovers the corporation, and discovers administrator candidates. If it returns multiple candidates, show only useful identifying information and ask which person should be used; retry with `staffName`, `staffPhone`, or the selected `staffId` internally. After creation, run:
```bash
seal-home auth diagnose --corp <discovered-id>
```
Do 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.
## Route 2: Incoming Assistance Link
First distinguish the link by its host and purpose:
- A Hose authorization/provisional link opens a Hose session and may continue through Seal SSO. It is not a Seal delegation link.
- A Seal assistance/delegation link grants temporary delegated access on a Seal tenant. It is not a Hose OpenAPI credential.
-`seal-home auth hose-link` and `seal-home delegation create` generate links for an enterprise that is already configured; they do not import a new enterprise from a received link.
The current CLI does not directly import an incoming assistance link. Do not pretend that `corps add-hose` or `corps add-seal` accepts the raw URL. If a browser tool is available and the user authorized opening the link, open it, confirm the final tenant host, and obtain an authenticated Seal business request. Otherwise explain that the link must be opened in the user's browser, then continue with the browser cURL route below.
Assistance links are credentials. Do not follow a link merely to inspect it when the user's request was only explanatory, and never publish, log, or commit it.
## Route 3: Browser F12 cURL
When the user needs capture instructions, give these concrete steps:
1. Open the already signed-in Hose or Seal page.
2. Open browser developer tools: `F12` on many keyboards, or `Option+Command+I` on macOS.
3. Open **Network**, then select **Fetch/XHR**.
4. Refresh the page or perform one ordinary read-only business action.
5. Choose a successful business API request from the relevant tenant, not analytics, static assets, upload, delete, publish, or logout requests.
6. Right-click it and choose **Copy → Copy as cURL**.
7. Send that complete cURL only to the local trusted Agent handling setup.
When receiving cURL:
1. Treat the entire cURL as a secret. Do not echo it, execute it blindly, paste it into another service, or store it in repository files.
2. Parse it as data. Extract the request host, path, `Authorization` header, cookies, and provider/tenant hints. Ignore the request body unless it is required to identify the tenant.
3. Classify whether the captured request is to Hose or Seal. A Seal request with `Authorization: Bearer ...` can supply `sealUrl` and a session token even when the user's identity origin is Hose.
4. Verify with the narrowest read-only identity endpoint available. For a Seal Bearer session, verify `/api/v1/auth/me` through `seal-home corps add-seal`; use returned provider metadata to retain the actual origin.
5. Persist only the normalized minimum configuration needed by seal-home. Do not preserve the raw cURL, unrelated headers, request body, cookies, or signed URL.
For a verified Seal Bearer captured from cURL, the existing CLI route is:
```bash
seal-home corps add-seal --json '{"sealUrl":"https://target-tenant.example","token":"<bearer>"}'
```
The current CLI has no raw-cURL import command and `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.
Report the human enterprise name, identity provider, credential method, and whether verification succeeded. Do not expose internal IDs unless they help with troubleshooting. Do not perform approval, rule, document, simulation, publishing, or other business mutations just because onboarding succeeded; continue only with the user's requested task and its normal confirmation rules.
If a temporary assistance-link or browser session expires, explain that it must be renewed or recaptured. Recommend standard Hose app credentials when the user needs durable unattended access.
@@ -6,14 +6,18 @@ Use this reference for Hose/合思 enterprise configuration and user-facing Hose
Use the CLI for normal enterprise setup. Do not inspect source code or hand-edit `~/.config/seal-home/enterprises/*.json` unless the CLI fails or the user explicitly asks for low-level config debugging.
For first-time setup or when the user has an assistance link or browser cURL instead of standard application credentials, read `enterprise-onboarding.md` first. This reference's `add-hose` route is specifically for durable Hose OpenAPI credentials.
```bash
seal-home corps add-hose --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}'
seal-home corps add-hose --json '{"appKey":"...","appSecurity":"..."}'
seal-home corps list
seal-home corps current --corp <corpId>
seal-home corps switch <corpId>
```
`corps add-hose`verifies by default and writes the enterprise config. If the user says not to operate business logic, stop at `corps` and auth/config commands; do not run approval, rule, document, simulation, or approval-run commands.
`corps add-hose`probes standard domains and discovers the enterprise automatically. If it returns multiple administrator candidates, present their names and masked phones for the user to choose, then retry with `staffName`, `staffPhone`, or the selected `staffId`. Do not ask for `domain`, `corpId`, `staffId`, or `proxyStaffBizId` before discovery. Ask for a dedicated/private-cloud `domain` only after standard probing fails.
The command verifies by default and writes the enterprise config. If the user says not to operate business logic, stop at `corps` and auth/config commands; do not run approval, rule, document, simulation, or approval-run commands.
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.