@@ -26,7 +26,16 @@ Tests are colocated as `*.test.ts` files in `src/`. OpenAPI source YAML lives in
Use TypeScript ES modules with explicit `.js` import extensions for local files. Validate external data with Zod or narrow types before use. Follow existing style: two-space indentation, double quotes, omitted trailing semicolons, `camelCase` variables/functions, `PascalCase` classes/types, and lowercase hyphenated filenames such as `token-store.ts`.
Prefer small domain functions over broad utility modules. Keep CLI output JSON on stdout and diagnostics/errors on stderr.
Prefer small domain functions over broad utility modules.
## CLI & Agent Harness Protocol Guidelines
- **Machine Channel (`stdout`)**: CLI commands MUST output clean, parseable JSON on `stdout`. Never dump human prose, raw logs, or progress banners into `stdout`. The Agent Harness parses `stdout` directly into typed payloads.
- **Guidance & Diagnostic Channel (`stderr`)**: Use `stderr` for runtime logs, network probing status, self-healing notifications, and explicit **Next-Step Command Suggestions** (e.g. `👉 Next action: seal-use deploy hosecloud sync <signKey>`).
- **Exit Code Contract**:
- Successful executions MUST terminate with exit code `0`.
- Any parameter validation failure, upstream API error, or business block MUST result in a non-zero exit code (e.g. `1`), allowing the Agent Harness to reliably detect failures and trigger automated error remediation.
- Never call `process.exit()` deep in domain functions; throw structured errors and let `src/cli/runner.ts` handle stream routing and exit code assignment.
## Testing Guidelines
@@ -43,21 +52,21 @@ Recent commits use concise imperative subjects, often `Add ...` or `Refine ...`,
- Update `CHANGELOG.md` with new features and fixes.
- Run `bun test && bun run check`.
2.**Protected-Branch Release**:
- Do not tag or push `master` directly. Create a release branch, commit the version bump, push it, open a PR to `master`, wait for the required CI check, and merge the PR first.
- After the PR is merged, fast-forward the local `master`, then synchronize `home/master` before creating the tag:
- Do not tag or push `main` directly. Create a release branch, commit the version bump, push it, open a PR to `main`, wait for the required CI check, and merge the PR first.
- After the PR is merged, fast-forward the local `main`, then synchronize `home/main` before creating the tag:
- Only after both `origin/master` and `home/master` contain the merged release should you create the annotated tag. Push the tag to `home` first, then to `origin`; pushing the GitHub tag last triggers the Release workflow after the Gitea tag and branch are ready:
- Only after both `origin/main` and `home/main` contain the merged release should you create the annotated tag. Push the tag to `home` first, then to `origin`; pushing the GitHub tag last triggers the Release workflow after the Gitea tag and branch are ready:
```bash
git tag -a vX.Y.Z -m "🚀 Release summary text describing key changes"
@@ -5,6 +5,27 @@ All notable changes to `seal-use` 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.10.3] - 2026-09-02
### Added & Enhanced
- **Auto Platform Probing for HoseCloud Deployment**: In `deploy hosecloud configure` (`seal_deploy_hosecloud_configure`), automatically probes 6 standard Hose SaaS platform domains (Standard, DingTalk, WeChat Work, Feishu, CloudHub, DingTalk Enterprise) using `probeHoseDomain` when `customApiUrl` is omitted. Eliminates manual platform guessing and prevents authentication failures (`请检查 API 平台和凭证配置是否正确`).
- **Standardized Business Terminology**: Aligned all CLI and tool descriptions with Seal AI product semantics: `Seal AI 智能审核发布到合思费控` (replacing raw backend jargon like "合思出站消息").
- **Dedicated Reference Documentation**: Added `skills/seal-use/references/hose-enterprise-deploy.md` covering end-to-end deployment, auto platform detection, 3-step publishing, and EBot node integration.
## [0.10.2] - 2026-09-02
### Added & Enhanced
- **Agent Skill Self-Bootstrap & Auto-Installation**: Embedded direct 1-line installation scripts into `skills/seal-use/SKILL.md` and onboarding references. Third-party AI Agents can now automatically self-install and bootstrap `seal-use` when missing without human intervention.
- **CI / Mirror Routing Isolation**: Added intelligent mirror mode resolver (`SEAL_USE_MIRROR=github|gitea|auto`). Automatically bypasses Gitea in CI environments to ensure 100% offline, deterministic, and fast (<20s) test execution.
## [0.10.1] - 2026-09-02
### Changed & Infrastructure
- **Default Branch Modernization (`master` $\rightarrow$ `main`)**: Standardized default branch to `main` across GitHub and Gitea with dual-branch transition compatibility for legacy script URLs.
- **Repository Rename (`seal-home` $\rightarrow$ `seal-use`)**: Updated primary repository references to `yunyingk/seal-use` and `gitea/seal-use` with multi-source fallback and GitHub 301/302 redirect support.
- **Two-Job Decoupled Release Architecture**: Split CI/CD release workflow into independent GitHub Release job (~40s fast path) and asynchronous Gitea mirror sync job.
- **Tiered Gitea Sync with Supreme Priority**: Prioritized `seal-use-darwin-arm64.tar.gz` and `checksums.txt` (Tier 1, ~26MB) for 10-second sync completion on macOS Apple Silicon.
Or download the native binary directly from [GitHub Releases](https://github.com/yunyingk/seal-home/releases/latest) or [Gitea Releases](https://git.ying-qing.cn/gitea/seal-home/releases):
Or download the native binary directly from [GitHub Releases](https://github.com/yunyingk/seal-use/releases/latest) or [Gitea Releases](https://git.ying-qing.cn/gitea/seal-use/releases):
git push origin main --tags && git push home main --tags
```
**CI Automation Pipeline:**
- GitHub Actions triggers automatically upon pushing a `v*` tag;
- Cross-compiles standalone binaries for 5 target platforms (macOS Apple Silicon/Intel, Linux x86_64/ARM64, Windows x64) in under 60 seconds;
- Automatically extracts your Git tag annotation message and appends commit changelogs (`--generate-notes`);
- Simultaneously publishes release packages to **[GitHub Releases](https://github.com/yunyingk/seal-home/releases)** and **[Gitea Releases](https://git.ying-qing.cn/gitea/seal-home/releases)** for global and mainland China high-speed downloads.
- Simultaneously publishes release packages to **[GitHub Releases](https://github.com/yunyingk/seal-use/releases)** and **[Gitea Releases](https://git.ying-qing.cn/gitea/seal-use/releases)** for global and mainland China high-speed downloads.
import{createRequireasqy}from"node:module";varYy=Object.create;var{getPrototypeOf:Py,defineProperty:A$,getOwnPropertyNames:py}=Object;varQy=Object.prototype.hasOwnProperty;functionFy(n){returnthis[n]}varKy,By,n0=(n,i,r)=>{varo=n!=null&&typeofn==="object";if(o){vart=i?Ky??=newWeakMap:By??=newWeakMap,u=t.get(n);if(u)returnu}r=n!=null?Yy(Py(n)):{};lete=i||!n||!n.__esModule?A$(r,"default",{value:n,enumerable:!0}):r;for(letlofpy(n))if(!Qy.call(e,l))A$(e,l,{get:Fy.bind(n,l),enumerable:!0});if(o)t.set(n,e);returne};varP=(n,i)=>()=>(i||n((i={exports:{}}).exports,i),i.exports);varTy=(n)=>n;functionVy(n,i){this[n]=Ty.bind(null,i)}varQi=(n,i)=>{for(varrini)A$(n,r,{get:i[r],enumerable:!0,configurable:!0,set:Vy.bind(i,r)})};vari0=qy(import.meta.url);varnu=P((XD)=>{Object.defineProperty(XD,"__esModule",{value:!0});XD.regexpCode=XD.getEsmExportName=XD.getProperty=XD.safeStringify=XD.stringify=XD.strConcat=XD.addCodeArg=XD.str=XD._=XD.nil=XD._Code=XD.Name=XD.IDENTIFIER=XD._CodeOrName=void0;classTl{}XD._CodeOrName=Tl;XD.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;classWrextendsTl{constructor(n){super();if(!XD.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}}}XD.Name=Wr;classciextendsTl{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},{})}}XD._Code=ci;XD.nil=newci("");functionWD(n,...i){letr=[n[0]],o=0;while(o<i.length)Pc(r,i[o]),r.push(n[++o]);returnnewci(r)}XD._=WD;varYc=newci("+");functionJD(n,...i){letr=[so(n[0])],o=0;while(o<i.length)r.push(Yc),Pc(r,i[o]),r.push(Yc,so(n[++o]));returnvX(r),newci(r)}XD.str=JD;functionPc(n,i){if(iinstanceofci)n.push(...i._items);elseif(iinstanceofWr)n.push(i);elsen.push(gX(i))}XD.addCodeArg=Pc;functionvX(n){leti=1;while(i<n.length-1){if(n[i]===Yc){letr=$X(n[i-1],n[i+1]);if(r!==void0){n.splice(i-1,3,r);continue}n[i++]="+"}i++}}function$X(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}functionIX(n,i){returni.emptyStr()?n:n.emptyStr()?i:JD`${n}${i}`}XD.strConcat=IX;functiongX(n){returntypeofn=="number"||typeofn=="boolean"||n===null?n:so(Array.isArray(n)?n.join(","):n)}functionbX(n){returnnewci(so(n))}XD.stringify=bX;functionso(n){returnJSON.stringify(n).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}XD.safeStringify=so;functionwX(n){returntypeofn=="string"&&XD.IDENTIFIER.test(n)?newci(`.${n}`):WD`[${n}]`}XD.getProperty=wX;functionfX(n){if(typeofn=="string"&&XD.IDENTIFIER.test(n))returnnewci(`${n}`);throwError(`CodeGen: invalid export name: ${n}, use explicit $id name mapping`)}XD.getEsmExportName=fX;functioncX(n){returnnewci(n.toString())}XD.regexpCode=cX});varKc=P((pD)=>{Object.defineProperty(pD,"__esModule",{value:!0});pD.ValueScope=pD.ValueScopeName=pD.Scope=pD.varKinds=pD.UsedValueState=void0;varan=nu();classYDextendsError{constructor(n){super(`CodeGen: "code" for ${n} not defined`);this.value=n.value}}varql;(function(n){n[n.Started=0]="Started",n[n.Completed=1]="Completed"})(ql||(pD.UsedValueState=ql={}));pD.varKinds={const:newan.Name("const"),let:newan.Name("let"),var:newan.Name("var")};classQc{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}}}pD.Scope=Qc;classFcextendsan.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}]`}}pD.ValueScopeName=Fc;varWX=an._`\n`;classPDextendsQc{constructor(n){super(n);this._values={},this._scope=n.scope,this.opts={...n,_n:n.lines?WX:an.nil}}get(){returnthis._scope}name(n){returnnewFc(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 Ui.Scope({parent:n}),this._nodes=[new ED]}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 FD(n,t,r)),t}const(n,i,r){return this._def(Ui.varKinds.const,n,i,r)}let(n,i,r){return this._def(Ui.varKinds.let,n,i,r)}var(n,i,r){return this._def(Ui.varKinds.var,n,i,r)}assign(n,i,r){return this._leafNode(new Vc(n,i,r))}add(n,i){return this._leafNode(new KD(n,sn.operators.ADD,i))}code(n){if(typeof n=="function")n();else if(n!==s.nil)this._leafNode(new qD(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 Vi(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 Vi(n))}else(){return this._elseNode(new iu)}endIf(){return this._endBlockNode(Vi,iu)}_for(n,i){if(this._blockNode(n),i)this.code(i).endFor();return this}for(n,i){return this._for(new _D(n),i)}forRange(n,i,r,o,t=this.opts.es5?Ui.varKinds.var:Ui.varKinds.let){let u=this._scope.toName(n);return this._for(new ZD(t,u,i,r),()=>o(u))}forOf(n,i,r,o=Ui.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 Bc("of",o,t,i),()=>r(t))}forIn(n,i,r,o=this.opts.es5?Ui.varKinds.var:Ui.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 Bc("in",o,t,i),()=>r(t))}endFor(){return this._endBlockNode(Jr)}label(n){return this._leafNode(new BD(n))}break(n){return this._leafNode(new TD(n))}return(n){let i=new _l;if(this._blockNode(i),this.code(n),i.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(_l)}try(n,i,r){if(!i&&!r)throw Error('CodeGen: "try" without "catch" and "finally"');let o=new MD;if(this._blockNode(o),this.code(n),i){let t=this.name("e");this._currNode=o.catch=new Zl(t),i(t)}if(r)this._currNode=o.finally=new Ml,this.code(r);return this._endBlockNode(Zl,Ml)}throw(n){return this._leafNode(new VD(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 El(n,i,r)),o)this.code(o).endFunc();return this}endFunc(){return this._endBlockNode(El)}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 Vi))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=zD;function Xt(n,i){for(let r in i)n[r]=(n[r]||0)+(i[r]||0);return n}function zl(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 YX(n,i){for(let r in i)n[r]=(n[r]||0)-(i[r]||0)}function CD(n){return typeof n=="boolean"||typeof n=="number"||n===null?!n:s._`!${Tc(n)}`}sn.not=CD;var PX=RD(sn.operators.AND);function pX(...n){return n.reduce(PX)}sn.and=pX;var QX=RD(sn.operators.OR);function FX(...n){return n.reduce(QX)}sn.or=FX;function RD(n){return(i,r)=>i===s.nil?r:r===s.nil?i:s._`${Tc(i)}${n}${Tc(r)}`}function Tc(n){return n instanceof s.Name?n:s._`(${n})`}});var nn=P((r1)=>{Object
Line truncated
import{createRequireas_y}from"node:module";varQy=Object.create;var{getPrototypeOf:Py,defineProperty:O$,getOwnPropertyNames:Fy}=Object;varKy=Object.prototype.hasOwnProperty;functionBy(n){returnthis[n]}varEy,Ty,t0=(n,i,r)=>{varo=n!=null&&typeofn==="object";if(o){vart=i?Ey??=newWeakMap:Ty??=newWeakMap,u=t.get(n);if(u)returnu}r=n!=null?Qy(Py(n)):{};lete=i||!n||!n.__esModule?O$(r,"default",{value:n,enumerable:!0}):r;for(letlofFy(n))if(!Ky.call(e,l))O$(e,l,{get:By.bind(n,l),enumerable:!0});if(o)t.set(n,e);returne};varY=(n,i)=>()=>(i||n((i={exports:{}}).exports,i),i.exports);varVy=(n)=>n;functionqy(n,i){this[n]=Vy.bind(null,i)}varPi=(n,i)=>{for(varrini)O$(n,r,{get:i[r],enumerable:!0,configurable:!0,set:qy.bind(i,r)})};varr0=_y(import.meta.url);varnu=Y((YD)=>{Object.defineProperty(YD,"__esModule",{value:!0});YD.regexpCode=YD.getEsmExportName=YD.getProperty=YD.safeStringify=YD.stringify=YD.strConcat=YD.addCodeArg=YD.str=YD._=YD.nil=YD._Code=YD.Name=YD.IDENTIFIER=YD._CodeOrName=void0;classTl{}YD._CodeOrName=Tl;YD.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;classjrextendsTl{constructor(n){super();if(!YD.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}}}YD.Name=jr;classfiextendsTl{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(rinstanceofjr)i[r.str]=(i[r.str]||0)+1;returni},{})}}YD._Code=fi;YD.nil=newfi("");functionXD(n,...i){letr=[n[0]],o=0;while(o<i.length)Qc(r,i[o]),r.push(n[++o]);returnnewfi(r)}YD._=XD;varpc=newfi("+");functionHD(n,...i){letr=[so(n[0])],o=0;while(o<i.length)r.push(pc),Qc(r,i[o]),r.push(pc,so(n[++o]));returnIX(r),newfi(r)}YD.str=HD;functionQc(n,i){if(iinstanceoffi)n.push(...i._items);elseif(iinstanceofjr)n.push(i);elsen.push(wX(i))}YD.addCodeArg=Qc;functionIX(n){leti=1;while(i<n.length-1){if(n[i]===pc){letr=gX(n[i-1],n[i+1]);if(r!==void0){n.splice(i-1,3,r);continue}n[i++]="+"}i++}}functiongX(n,i){if(i==='""')returnn;if(n==='""')returni;if(typeofn=="string"){if(iinstanceofjr||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]==='"'&&!(ninstanceofjr))return`"${n}${i.slice(1)}`;return}functionbX(n,i){returni.emptyStr()?n:n.emptyStr()?i:HD`${n}${i}`}YD.strConcat=bX;functionwX(n){returntypeofn=="number"||typeofn=="boolean"||n===null?n:so(Array.isArray(n)?n.join(","):n)}functionfX(n){returnnewfi(so(n))}YD.stringify=fX;functionso(n){returnJSON.stringify(n).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}YD.safeStringify=so;functioncX(n){returntypeofn=="string"&&YD.IDENTIFIER.test(n)?newfi(`.${n}`):XD`[${n}]`}YD.getProperty=cX;functionUX(n){if(typeofn=="string"&&YD.IDENTIFIER.test(n))returnnewfi(`${n}`);throwError(`CodeGen: invalid export name: ${n}, use explicit $id name mapping`)}YD.getEsmExportName=UX;functionDX(n){returnnewfi(n.toString())}YD.regexpCode=DX});varBc=Y((FD)=>{Object.defineProperty(FD,"__esModule",{value:!0});FD.ValueScope=FD.ValueScopeName=FD.Scope=FD.varKinds=FD.UsedValueState=void0;varan=nu();classQDextendsError{constructor(n){super(`CodeGen: "code" for ${n} not defined`);this.value=n.value}}varql;(function(n){n[n.Started=0]="Started",n[n.Completed=1]="Completed"})(ql||(FD.UsedValueState=ql={}));FD.varKinds={const:newan.Name("const"),let:newan.Name("let"),var:newan.Name("var")};classFc{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}}}FD.Scope=Fc;classKcextendsan.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}]`}}FD.ValueScopeName=Kc;varXX=an._`\n`;classPDextendsFc{constructor(n){super(n);this._values={},this._scope=n.scope,this.opts={...n,_n:n.lines?XX:an.nil}}get(){returnthis._scope}name(n){returnnewKc(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 ci.Scope({parent:n}),this._nodes=[new ZD]}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 BD(n,t,r)),t}const(n,i,r){return this._def(ci.varKinds.const,n,i,r)}let(n,i,r){return this._def(ci.varKinds.let,n,i,r)}var(n,i,r){return this._def(ci.varKinds.var,n,i,r)}assign(n,i,r){return this._leafNode(new Vc(n,i,r))}add(n,i){return this._leafNode(new ED(n,sn.operators.ADD,i))}code(n){if(typeof n=="function")n();else if(n!==s.nil)this._leafNode(new _D(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 Ti(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 Ti(n))}else(){return this._elseNode(new iu)}endIf(){return this._endBlockNode(Ti,iu)}_for(n,i){if(this._blockNode(n),i)this.code(i).endFor();return this}for(n,i){return this._for(new MD(n),i)}forRange(n,i,r,o,t=this.opts.es5?ci.varKinds.var:ci.varKinds.let){let u=this._scope.toName(n);return this._for(new zD(t,u,i,r),()=>o(u))}forOf(n,i,r,o=ci.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 Ec("of",o,t,i),()=>r(t))}forIn(n,i,r,o=this.opts.es5?ci.varKinds.var:ci.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 Ec("in",o,t,i),()=>r(t))}endFor(){return this._endBlockNode(Jr)}label(n){return this._leafNode(new TD(n))}break(n){return this._leafNode(new VD(n))}return(n){let i=new Zl;if(this._blockNode(i),this.code(n),i.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(Zl)}try(n,i,r){if(!i&&!r)throw Error('CodeGen: "try" without "catch" and "finally"');let o=new CD;if(this._blockNode(o),this.code(n),i){let t=this.name("e");this._currNode=o.catch=new Ml(t),i(t)}if(r)this._currNode=o.finally=new zl,this.code(r);return this._endBlockNode(Ml,zl)}throw(n){return this._leafNode(new qD(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 _l(n,i,r)),o)this.code(o).endFunc();return this}endFunc(){return this._endBlockNode(_l)}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 Ti))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=RD;function Xt(n,i){for(let r in i)n[r]=(n[r]||0)+(i[r]||0);return n}function Cl(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 QX(n,i){for(let r in i)n[r]=(n[r]||0)-(i[r]||0)}function hD(n){return typeof n=="boolean"||typeof n=="number"||n===null?!n:s._`!${Tc(n)}`}sn.not=hD;var PX=mD(sn.operators.AND);function FX(...n){return n.reduce(PX)}sn.and=FX;var KX=mD(sn.operators.OR);function BX(...n){return n.reduce(KX)}sn.or=BX;function mD(n){return(i,r)=>i===s.nil?r:r===s.nil?i:s._`${Tc(i)}${n}${Tc(r)}`}function Tc(n){return n instanceof s.Name?n:s._`(${n})`}});var tn=Y((u1)=>{Object
Line truncated
deps:${r}}`};var QP={keyword:"dependencies",type:"object",schemaType:"object",error:hA.error,code(n){let[i,r]=FP(n);CA(n,i),RA(n,r)}};function FP({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 CA(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,Au.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,Au.checkReportMissingProp)(n,I)});else r.if(k6._`${$}&&(${(0,Au.checkMissingProp)(n,l,u)})`),(0,Au.reportMissingProp)(n,u),r.else()}}hA.validatePropertyDeps=CA;function RA(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,pP.alwaysValidSchema)(u,i[l]))continue;r.if((0,Au.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)}}hA.validateSchemaDeps=RA;hA.default=QP});var iO=P((nO)=>{Object.defineProperty(nO,"__esModule",{value:!0});var sA=C(),TP=nn(),VP={message:"property name must be valid",params:({params:n})=>sA._`{propertyName:${n.propertyName}}`},qP={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:VP,code(n){let{gen:i,schema:r,data:o,it:t}=n;if((0,TP.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,sA.not)(u),()=>{if(n.error(!0),!t.allErrors)i.break()})}),n.ok(u)}};nO.default=qP});var d6=P((tO)=>{Object.defineProperty(tO,"__esModule",{value:!0});var fv=Ii(),Ai=C(),_P=qi(),cv=nn(),ZP={message:"must NOT have additional properties",params:({params:n})=>Ai._`{additionalProperty:${n.additionalProperty}}`},MP={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:ZP,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,cv.alwaysValidSchema)(e,r))return;let I=(0,fv.allSchemaProperties)(o.properties),g=(0,fv.allSchemaProperties)(o.patternProperties);b(),n.ok(Ai._`${u}===${_P.default.errors}`);function b(){i.forIn("key",t,(k)=>{if(!I.length&&!g.length)c(k);else i.if(w(k),()=>c(k))})}function w(k){let d;if(I.length>8){let Q=(0,cv.schemaRefOrVal)(e,o.properties,"properties");d=(0,fv.isOwnProperty)(i,Q,k)}else if(I.length)d=(0,Ai.or)(...I.map((Q)=>Ai._`${k}===${Q}`));else d=Ai.nil;if(g.length)d=(0,Ai.or)(d,...g.map((Q)=>Ai._`${(0,fv.usePattern)(n,Q)}.test(${k})`));return(0,Ai.not)(d)}function f(k){i.code(Ai._`delete${t}[${k}]`)}function c(k){if($.removeAdditional==="all"||$.removeAdditional&&r===!1){f(k);return}if(r===!1){if(n.setParams({additionalProperty:k}),n.error(),!l)i.break();return}if(typeof r=="object"&&!(0,cv.alwaysValidSchema)(e,r)){let d=i.name("valid");if($.removeAdditional==="failing")S(k,d,!1),i.if((0,Ai.not)(d),()=>{n.reset(),f(k)});else if(S(k,d),!l)i.if((0,Ai.not)(d),()=>i.break())}}function S(k,d,Q){let Y={keyword:"additionalProperties",dataProp:k,dataPropType:cv.Type.Str};if(Q===!1)Object.assign(Y,{compositeRule:!0,createErrors:!1,allErrors:!1});n.subschema(Y,d)}}};tO.default=MP});var eO=P((uO)=>{Object.defineProperty(uO,"__esModule",{value:!0});var CP=lu(),rO=Ii(),N6=nn(),oO=d6(),RP={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)oO.default.code(new CP.KeywordCxt(u,oO.default,"additionalProperties"));let e=(0,rO.allSchemaProperties)(r);for(let b of e)u.definedProperties.add(b);if(u.opts.unevaluated&&e.length&&u.props!==!0)u.props=N6.mergeEvaluated.props(i,(0,N6.toHash)(e),u.props);let l=e.filter((b)=>!(0,N6.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,rO.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},$)}}};uO.default=RP});var gO=P((IO)=>{Object.defineProperty(IO,"__esModule",{value:!0});var lO=Ii(),Uv=C(),vO=nn(),$O=nn(),mP={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,lO.allSchemaProperties)(r),$=l.filter((S)=>(0,vO.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 Uv.Name))u.props=(0,$O.
Line truncated
deps:${r}}`};var K7={keyword:"dependencies",type:"object",schemaType:"object",error:xA.error,code(n){let[i,r]=B7(n);hA(n,i),mA(n,r)}};function B7({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 hA(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,Au.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,Au.checkReportMissingProp)(n,I)});else r.if(k6._`${$}&&(${(0,Au.checkMissingProp)(n,l,u)})`),(0,Au.reportMissingProp)(n,u),r.else()}}xA.validatePropertyDeps=hA;function mA(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,F7.alwaysValidSchema)(u,i[l]))continue;r.if((0,Au.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)}}xA.validateSchemaDeps=mA;xA.default=K7});var rO=Y((tO)=>{Object.defineProperty(tO,"__esModule",{value:!0});var iO=R(),V7=tn(),q7={message:"property name must be valid",params:({params:n})=>iO._`{propertyName:${n.propertyName}}`},_7={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:q7,code(n){let{gen:i,schema:r,data:o,it:t}=n;if((0,V7.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,iO.not)(u),()=>{if(n.error(!0),!t.allErrors)i.break()})}),n.ok(u)}};tO.default=_7});var N6=Y((oO)=>{Object.defineProperty(oO,"__esModule",{value:!0});var cv=Ii(),Si=R(),M7=Vi(),Uv=tn(),z7={message:"must NOT have additional properties",params:({params:n})=>Si._`{additionalProperty:${n.additionalProperty}}`},C7={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:z7,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,Uv.alwaysValidSchema)(e,r))return;let I=(0,cv.allSchemaProperties)(o.properties),g=(0,cv.allSchemaProperties)(o.patternProperties);b(),n.ok(Si._`${u}===${M7.default.errors}`);function b(){i.forIn("key",t,(d)=>{if(!I.length&&!g.length)c(d);else i.if(w(d),()=>c(d))})}function w(d){let k;if(I.length>8){let P=(0,Uv.schemaRefOrVal)(e,o.properties,"properties");k=(0,cv.isOwnProperty)(i,P,d)}else if(I.length)k=(0,Si.or)(...I.map((P)=>Si._`${d}===${P}`));else k=Si.nil;if(g.length)k=(0,Si.or)(k,...g.map((P)=>Si._`${(0,cv.usePattern)(n,P)}.test(${d})`));return(0,Si.not)(k)}function f(d){i.code(Si._`delete${t}[${d}]`)}function c(d){if($.removeAdditional==="all"||$.removeAdditional&&r===!1){f(d);return}if(r===!1){if(n.setParams({additionalProperty:d}),n.error(),!l)i.break();return}if(typeof r=="object"&&!(0,Uv.alwaysValidSchema)(e,r)){let k=i.name("valid");if($.removeAdditional==="failing")S(d,k,!1),i.if((0,Si.not)(k),()=>{n.reset(),f(d)});else if(S(d,k),!l)i.if((0,Si.not)(k),()=>i.break())}}function S(d,k,P){let Q={keyword:"additionalProperties",dataProp:d,dataPropType:Uv.Type.Str};if(P===!1)Object.assign(Q,{compositeRule:!0,createErrors:!1,allErrors:!1});n.subschema(Q,k)}}};oO.default=C7});var vO=Y((lO)=>{Object.defineProperty(lO,"__esModule",{value:!0});var h7=lu(),uO=Ii(),L6=tn(),eO=N6(),m7={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)eO.default.code(new h7.KeywordCxt(u,eO.default,"additionalProperties"));let e=(0,uO.allSchemaProperties)(r);for(let b of e)u.definedProperties.add(b);if(u.opts.unevaluated&&e.length&&u.props!==!0)u.props=L6.mergeEvaluated.props(i,(0,L6.toHash)(e),u.props);let l=e.filter((b)=>!(0,L6.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,uO.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},$)}}};lO.default=m7});var wO=Y((bO)=>{Object.defineProperty(bO,"__esModule",{value:!0});var $O=Ii(),Dv=R(),IO=tn(),gO=tn(),a7={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,$O.allSchemaProperties)(r),$=l.filter((S)=>(0,IO.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 Dv.Name))u.props=(0,gO.
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 GI={major:4,minor:4,patch:3};var T=U("$ZodType",(n,i)=>{var r;n??(n={}),n._zod.def=i,n._zod.bag=n._zod.bag||{},n._zod.version=GI;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=ai(e),g;for(let b of l){if(b._zod.def.when){if(H$(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 Li;if(g||f instanceof Promise)g=(g??Promise.resolve()).then(async()=>{if(await f,e.issues.length===w)return;if(!I)I=ai(e,w)});else{if(e.issues.length===w)continue;if(!I)I=ai(e,w)}}if(g)return g.then(()=>{return e});return e},u=(e,l,$)=>{if(ai(e))return e.aborted=!0,e;let I=t(l,o,$);if(I instanceof Promise){if($.async===!1)throw new Li;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 Li;return $.then((I)=>t(I,o,l))}return t($,o,l)}}R(n,"~standard",()=>({validate:(t)=>{try{let u=xt(n,t);return u.success?{value:u.data}:{issues:u.error?.issues}}catch(u){return bo(n,t).then((e)=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),yt=U("$ZodString",(n,i)=>{T.init(n,i),n._zod.pattern=[...n?._zod.bag?.patterns??[]].pop()??iI(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=U("$ZodStringFormat",(n,i)=>{st.init(n,i),yt.init(n,i)}),JI=U("$ZodGUID",(n,i)=>{i.pattern??(i.pattern=q$),$n.init(n,i)}),XI=U("$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=Lt(o))}else i.pattern??(i.pattern=Lt());$n.init(n,i)}),HI=U("$ZodEmail",(n,i)=>{i.pattern??(i.pattern=E$),$n.init(n,i)}),YI=U("$ZodURL",(n,i)=>{$n.init(n,i),n._zod.check=(r)=>{try{let o=r.value.trim();if(!i.normalize&&i.protocol?.source===m$.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})}}}),PI=U("$ZodEmoji",(n,i)=>{i.pattern??(i.pattern=_$()),$n.init(n,i)}),pI=U("$ZodNanoID",(n,i)=>{i.pattern??(i.pattern=T$),$n.init(n,i)}),QI=U("$ZodCUID",(n,i)=>{i.pattern??(i.pattern=p$),$n.init(n,i)}),FI=U("$ZodCUID2",(n,i)=>{i.pattern??(i.pattern=Q$),$n.init(n,i)}),KI=U("$ZodULID",(n,i)=>{i.pattern??(i.pattern=F$),$n.init(n,i)}),BI=U("$ZodXID",(n,i)=>{i.pattern??(i.pattern=K$),$n.init(n,i)}),TI=U("$ZodKSUID",(n,i)=>{i.pattern??(i.pattern=B$),$n.init(n,i)}),VI=U("$ZodISODateTime",(n,i)=>{i.pattern??(i.pattern=nI(i)),$n.init(n,i)}),qI=U("$ZodISODate",(n,i)=>{i.pattern??(i.pattern=a$),$n.init(n,i)}),EI=U("$ZodISOTime",(n,i)=>{i.pattern??(i.pattern=s$(i)),$n.init(n,i)}),_I=U("$ZodISODuration",(n,i)=>{i.pattern??(i.pattern=V$),$n.init(n,i)}),ZI=U("$ZodIPv4",(n,i)=>{i.pattern??(i.pattern=Z$),$n.init(n,i),n._zod.bag.format="ipv4"}),MI=U("$ZodIPv6",(n,i)=>{i.pattern??(i.pattern=M$),$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})}}}),zI=U("$ZodMAC",(n,i)=>{i.pattern??(i.pattern=z$(i.delimiter)),$n.init(n,i),n._zod.bag.format="mac"}),CI=U("$ZodCIDRv4",(n,i)=>{i.pattern??(i.pattern=C$),$n.init(n,i)}),RI=U("$ZodCIDRv6",(n,i)=>{i.pattern??(i.pattern=R$),$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 hI(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
if(${G}.issues.length){
`))}}var jI={major:4,minor:4,patch:3};var E=U("$ZodType",(n,i)=>{var r;n??(n={}),n._zod.def=i,n._zod.bag=n._zod.bag||{},n._zod.version=jI;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=ai(e),g;for(let b of l){if(b._zod.def.when){if(Y$(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 Li;if(g||f instanceof Promise)g=(g??Promise.resolve()).then(async()=>{if(await f,e.issues.length===w)return;if(!I)I=ai(e,w)});else{if(e.issues.length===w)continue;if(!I)I=ai(e,w)}}if(g)return g.then(()=>{return e});return e},u=(e,l,$)=>{if(ai(e))return e.aborted=!0,e;let I=t(l,o,$);if(I instanceof Promise){if($.async===!1)throw new Li;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 Li;return $.then((I)=>t(I,o,l))}return t($,o,l)}}h(n,"~standard",()=>({validate:(t)=>{try{let u=xt(n,t);return u.success?{value:u.data}:{issues:u.error?.issues}}catch(u){return bo(n,t).then((e)=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),yt=U("$ZodString",(n,i)=>{E.init(n,i),n._zod.pattern=[...n?._zod.bag?.patterns??[]].pop()??tI(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=U("$ZodStringFormat",(n,i)=>{st.init(n,i),yt.init(n,i)}),XI=U("$ZodGUID",(n,i)=>{i.pattern??(i.pattern=q$),$n.init(n,i)}),HI=U("$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=Lt(o))}else i.pattern??(i.pattern=Lt());$n.init(n,i)}),YI=U("$ZodEmail",(n,i)=>{i.pattern??(i.pattern=_$),$n.init(n,i)}),pI=U("$ZodURL",(n,i)=>{$n.init(n,i),n._zod.check=(r)=>{try{let o=r.value.trim();if(!i.normalize&&i.protocol?.source===x$.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})}}}),QI=U("$ZodEmoji",(n,i)=>{i.pattern??(i.pattern=Z$()),$n.init(n,i)}),PI=U("$ZodNanoID",(n,i)=>{i.pattern??(i.pattern=T$),$n.init(n,i)}),FI=U("$ZodCUID",(n,i)=>{i.pattern??(i.pattern=P$),$n.init(n,i)}),KI=U("$ZodCUID2",(n,i)=>{i.pattern??(i.pattern=F$),$n.init(n,i)}),BI=U("$ZodULID",(n,i)=>{i.pattern??(i.pattern=K$),$n.init(n,i)}),EI=U("$ZodXID",(n,i)=>{i.pattern??(i.pattern=B$),$n.init(n,i)}),TI=U("$ZodKSUID",(n,i)=>{i.pattern??(i.pattern=E$),$n.init(n,i)}),VI=U("$ZodISODateTime",(n,i)=>{i.pattern??(i.pattern=iI(i)),$n.init(n,i)}),qI=U("$ZodISODate",(n,i)=>{i.pattern??(i.pattern=s$),$n.init(n,i)}),_I=U("$ZodISOTime",(n,i)=>{i.pattern??(i.pattern=nI(i)),$n.init(n,i)}),ZI=U("$ZodISODuration",(n,i)=>{i.pattern??(i.pattern=V$),$n.init(n,i)}),MI=U("$ZodIPv4",(n,i)=>{i.pattern??(i.pattern=M$),$n.init(n,i),n._zod.bag.format="ipv4"}),zI=U("$ZodIPv6",(n,i)=>{i.pattern??(i.pattern=z$),$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})}}}),CI=U("$ZodMAC",(n,i)=>{i.pattern??(i.pattern=C$(i.delimiter)),$n.init(n,i),n._zod.bag.format="mac"}),RI=U("$ZodCIDRv4",(n,i)=>{i.pattern??(i.pattern=R$),$n.init(n,i)}),hI=U("$ZodCIDRv6",(n,i)=>{i.pattern??(i.pattern=h$),$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 mI(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 Q=f.compile();return(Y,G)=>Q(w,Y,G)},u,e=Nt,l=!kt.jitless,I=l&&y$.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 V0([],c,w,f,b,n)}return r(w,f)}});function L0(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)=>!ai(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,kn())))}),i}var Do=U("$ZodUnion",(n,i)=>{T.init(n,i),R(n._zod,"optin",()=>i.options.some((o)=>o._zod.optin==="optional")?"optional":void 0),R(n._zod,"optout",()=>i.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),R(n._zod,"values",()=>{if(i.options.every((o)=>o._zod.values))return new Set(i.options.flatMap((o)=>Array.from(o._zod.values)));return}),R(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)=>ro(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 L0(e,o,n,t);return Promise.all(e).then((l)=>{return L0(l,o,n,t)})}});function y0(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,kn())))});else i.issues.push({code:"invalid_union",input:i.value,inst:r,errors:[],inclusive:!1});return i}var wg=U("$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 y0(e,o,n,t);return Promise.all(e).then((l)=>{return y0(l,o,n,t)})}}),fg=U("$ZodDiscriminatedUnion",(n,i)=>{i.inclusive=!1,Do.init(n,i);let r=n._zod.parse;R(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=zt(()=>{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(!Nt(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}}),cg=U("$ZodIntersection",(n,i)=>{T.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 j0(r,$,I)});return j0(r,u,e)}});function WI(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(xi(n)&&xi(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=WI(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=WI(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 j0(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(ai(n))return n;let e=WI(i.value,r.value);if(!e.valid)throw Error(`Unmergableintersection.Errorpath:${JSON.stringify(e.mergeErrorPath)}`);return n.value=e.data,n}var ce=U("$ZodTuple",(n,i)=>{T.init(n,i
Line truncated
`)}f.write("payload.value = newResult;"),f.write("return payload;");let P=f.compile();return(Q,W)=>P(w,Q,W)},u,e=Nt,l=!dt.jitless,I=l&&G$.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 q0([],c,w,f,b,n)}return r(w,f)}});function G0(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)=>!ai(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,dn())))}),i}var Do=U("$ZodUnion",(n,i)=>{E.init(n,i),h(n._zod,"optin",()=>i.options.some((o)=>o._zod.optin==="optional")?"optional":void 0),h(n._zod,"optout",()=>i.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),h(n._zod,"values",()=>{if(i.options.every((o)=>o._zod.values))return new Set(i.options.flatMap((o)=>Array.from(o._zod.values)));return}),h(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)=>ro(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 G0(e,o,n,t);return Promise.all(e).then((l)=>{return G0(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,dn())))});else i.issues.push({code:"invalid_union",input:i.value,inst:r,errors:[],inclusive:!1});return i}var fg=U("$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)})}}),cg=U("$ZodDiscriminatedUnion",(n,i)=>{i.inclusive=!1,Do.init(n,i);let r=n._zod.parse;h(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=zt(()=>{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(!Nt(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}}),Ug=U("$ZodIntersection",(n,i)=>{E.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 j0(r,$,I)});return j0(r,u,e)}});function JI(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(xi(n)&&xi(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=JI(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=JI(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 j0(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(ai(n))return n;let e=JI(i.value,r.value);if(!e.valid)throw Error(`Unmergableintersection.Errorpath:${JSON.stringify(e.mergeErrorPath)}`);return n.value=e.data,n}var Ue=U("$ZodTuple",(n,i)=>{E.init(n,i
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}}}}functionrt(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(letkinI){if(k==="$ref"||k==="allOf")continue;if(!(king))deleteI[k]}if(c.$ref&&f.def)for(letkinI){if(k==="$ref"||k==="allOf")continue;if(kinf.def&&JSON.stringify(I[k])===JSON.stringify(f.def[k]))deleteI[k]}}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.")}}functionMn(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")returnMn(o.element,r);if(o.type==="set")returnMn(o.valueType,r);if(o.type==="lazy")returnMn(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")returnMn(o.innerType,r);if(o.type==="intersection")returnMn(o.left,r)||Mn(o.right,r);if(o.type==="record"||o.type==="map")returnMn(o.keyType,r)||Mn(o.valueType,r);if(o.type==="pipe"){if(n._zod.traits.has("$ZodCodec"))return!0;returnMn(o.in,r)||Mn(o.out,r)}if(o.type==="object"){for(lettino.shape)if(Mn(o.shape[t],r))return!0;return!1}if(o.type==="union"){for(lettofo.options)if(Mn(t,r))return!0;return!1}if(o.type==="tuple"){for(lettofo.items)if(Mn(t,r))return!0;if(o.rest&&Mn(o.rest,r))return!0;return!1}return!1}varkw=(n,i={})=>(r)=>{leto=it({...r,processors:i});returnen(n,o),tt(o,n),rt(o,n)},fr=(n,i,r={})=>(o)=>{let{libraryOptions:t,target:u}=o??{},e=it({...t??{},target:u,io:i,processors:r});returnen(n,e),tt(e,n),rt(e,n)};varvW={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},dw=(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=vW[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}))]}},Nw=(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=$},Lw=(n,i,r,o)=>{r.type="boolean"},yw=(n,i,r,o)=>{if(i.unrepresentable==="throw")throwError("BigInt cannot be represented in JSON Schema")},jw=(n,i,r,o)=>{if(i.unrepresentable==="Line truncated
`}class V6{constructor(n=fk.stdin,i=fk.stdout){this._stdin=n,this._stdout=i,this._readBuffer=new T6,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=wk(n);if(this._stdout.write(r))i();else this._stdout.once("drain",i)})}}import{dirname as x4,join as _K}from"node:path";import{fileURLToPath as ZK}from"node:url";class Zi extends Error{name="KyError";get isKyError(){return!0}}class ti extends Zi{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 du extends Zi{name="NetworkError";request;constructor(n,i){super(`Requestfailedduetoanetworkerror:${n.method}${n.url}`,i);this.request=n}}class Nu 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 Zi{name="ForceRetryError";customDelay;code;customRequest;constructor(n){let i=n?.cause?n.cause instanceof Error?n.cause:new Nu(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 q6 extends Error{name="SchemaValidationError";issues;constructor(n){super("Response schema validation failed");this.issues=n}}class ki extends Zi{name="TimeoutError";request;constructor(n){super(`Requesttimedout:${n.method}${n.url}`);this.request=n}}var E6=(()=>{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})(),ck=typeof globalThis.AbortController==="function",kv=typeof globalThis.AbortSignal==="function"&&typeof globalThis.AbortSignal.any==="function",Uk=typeof globalThis.ReadableStream==="function",Dk=typeof globalThis.FormData==="function",dv=["get","post","put","patch","head","delete"],Hp=()=>{return};Hp();var Sk={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Er=2147483647,Ak=40,Nv=Symbol("stop");class Lv{options;constructor(n){this.options=n}}var Ok=(n)=>new Lv(n),kk={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},dk={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 yv=new TextEncoder,Yp=(n)=>{if(!n)return 0;if(n instanceof FormData){let i=0;for(let[r,o]of n)i+=Ak,i+=yv.encode(`Content-Disposition:form-data;name="${r}"`).byteLength,i+=typeof o==="string"?yv.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 yv.encode(n).byteLength;if(n instanceof URLSearchParams)return yv.encode(n.toString()).byteLength;return 0},Nk=(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)}}))},Lk=(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(Nk(n.body,o,i),r)},yk=(n,i,r)=>{if(!n.body)return n;let o=Yp(r??n.body);return new Request(n,{duplex:"half",body:Nk(n.body,o,i)})};var Hi=(n)=>n!==null&&typeof n==="object";var Pp=Symbol("replaceOption"),_6=(n)=>Hi(n)&&n[Pp]===!0?{isReplace:!0,value:n.value}:{isReplace:!1,value:n};var yu=(...n)=>{for(let i of n)if((!Hi(i)|
Line truncated
`,{mode:384}),i}function Cr(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 $F}from"node:fs";import{randomBytes as IF}from"node:crypto";import{randomBytes as Bd}from"node:crypto";var GQ=v.object({staffId:v.string(),name:v.string().optional(),code:v.string().default(""),bindTime:v.number().optional()}),WQ=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:GQ.optional()}),JQ=v.object({apiKey:v.string().optional(),corporationId:v.string().optional(),corporationName:v.string().optional()}),XQ=v.object({id:v.string(),name:v.string(),tenantSlug:v.string().optional(),isDemo:v.boolean().default(!1),logoUrl:v.string().nullable().optional(),hoseCorpConfig:JQ.optional()}),Ud=v.object({user:WQ,tenant:XQ}),HQ=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(),YQ=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(),Dd=v.object({user:HQ,session:YQ}),_v=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()}),Sd=v.object({rules:v.array(_v),hasPendingDeletes:v.boolean().default(!1)}),PQ=v.object({code:v.string().optional(),description:v.string(),scope:v.string(),strictness:v.string()}),Zv=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(PQ).default([]),publishedAt:v.number().optional(),createdAt:v.number().optional()}),Ad=v.object({version:Zv,rulesCount:v.number()}),Pu=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)}),Od=v.object({articles:v.array(Pu),total:v.number().optional()}),pQ=v.object({explicitApprove:v.string().default(""),explicitReject:v.string().default(""),exemptApprove:v.string().default(""),review:v.string().default("")}).passthrough(),QQ=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(),FQ=v.enum(["assisted","semi_automatic","fully_automatic"]),cd=v.object({id:v.string(),url:v.string().url()}).passthrough(),pu=v.object({type:v.literal("webhook"),id:v.string(),name:v.string(),mode:FQ,incomingDocumentWebhook:cd,outgoingResultWebhook:v.string().url(),incomingManualResultWebhook:cd,secret:v.string().min(1),autoApprovalRate:v.number().int().min(0).max(100).optional()}).passthrough(),l4=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}}}}functionrt(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(letdinI){if(d==="$ref"||d==="allOf")continue;if(!(ding))deleteI[d]}if(c.$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]}}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.")}}functionMn(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")returnMn(o.element,r);if(o.type==="set")returnMn(o.valueType,r);if(o.type==="lazy")returnMn(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")returnMn(o.innerType,r);if(o.type==="intersection")returnMn(o.left,r)||Mn(o.right,r);if(o.type==="record"||o.type==="map")returnMn(o.keyType,r)||Mn(o.valueType,r);if(o.type==="pipe"){if(n._zod.traits.has("$ZodCodec"))return!0;returnMn(o.in,r)||Mn(o.out,r)}if(o.type==="object"){for(lettino.shape)if(Mn(o.shape[t],r))return!0;return!1}if(o.type==="union"){for(lettofo.options)if(Mn(t,r))return!0;return!1}if(o.type==="tuple"){for(lettofo.items)if(Mn(t,r))return!0;if(o.rest&&Mn(o.rest,r))return!0;return!1}return!1}varkw=(n,i={})=>(r)=>{leto=it({...r,processors:i});returnen(n,o),tt(o,n),rt(o,n)},fr=(n,i,r={})=>(o)=>{let{libraryOptions:t,target:u}=o??{},e=it({...t??{},target:u,io:i,processors:r});returnen(n,e),tt(e,n),rt(e,n)};varIj={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Nw=(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=Ij[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}))]}},Lw=(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=$},yw=(n,i,r,o)=>{r.type="boolean"},Gw=(n,i,r,o)=>{if(i.unrepresentable==="throw")throwError("BigInt cannot be represented in JSON Schema")},Ww=(n,i,r,o)=>{if(i.unrepresentable==="Line truncated
`}class V6{constructor(n=Ud.stdin,i=Ud.stdout){this._stdin=n,this._stdout=i,this._readBuffer=new T6,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=cd(n);if(this._stdout.write(r))i();else this._stdout.once("drain",i)})}}import{dirname as s4,join as MK}from"node:path";import{fileURLToPath as zK}from"node:url";class Zi extends Error{name="KyError";get isKyError(){return!0}}class ti extends Zi{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 ku extends Zi{name="NetworkError";request;constructor(n,i){super(`Requestfailedduetoanetworkerror:${n.method}${n.url}`,i);this.request=n}}class Nu 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 Vr extends Zi{name="ForceRetryError";customDelay;code;customRequest;constructor(n){let i=n?.cause?n.cause instanceof Error?n.cause:new Nu(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 q6 extends Error{name="SchemaValidationError";issues;constructor(n){super("Response schema validation failed");this.issues=n}}class Oi extends Zi{name="TimeoutError";request;constructor(n){super(`Requesttimedout:${n.method}${n.url}`);this.request=n}}var _6=(()=>{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})(),Dd=typeof globalThis.AbortController==="function",kv=typeof globalThis.AbortSignal==="function"&&typeof globalThis.AbortSignal.any==="function",Sd=typeof globalThis.ReadableStream==="function",Ad=typeof globalThis.FormData==="function",Nv=["get","post","put","patch","head","delete"],pQ=()=>{return};pQ();var Od={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},qr=2147483647,dd=40,Lv=Symbol("stop");class yv{options;constructor(n){this.options=n}}var kd=(n)=>new yv(n),Nd={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},Ld={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 Gv=new TextEncoder,QQ=(n)=>{if(!n)return 0;if(n instanceof FormData){let i=0;for(let[r,o]of n)i+=dd,i+=Gv.encode(`Content-Disposition:form-data;name="${r}"`).byteLength,i+=typeof o==="string"?Gv.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 Gv.encode(n).byteLength;if(n instanceof URLSearchParams)return Gv.encode(n.toString()).byteLength;return 0},yd=(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)}}))},Gd=(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(yd(n.body,o,i),r)},Wd=(n,i,r)=>{if(!n.body)return n;let o=QQ(r??n.body);return new Request(n,{duplex:"half",body:yd(n.body,o,i)})};var Hi=(n)=>n!==null&&typeof n==="object";var PQ=Symbol("replaceOption"),Z6=(n)=>Hi(n)&&n[PQ]===!0?{isReplace:!0,value:n.value}:{isReplace:!1,value:n};var yu=(...n)=>{for(let i of n)if((!Hi(i)|
Line truncated
`,{mode:384}),i}function Rr(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 gF}from"node:fs";import{randomBytes as bF}from"node:crypto";import{randomBytes as Tk}from"node:crypto";var JP=v.object({staffId:v.string(),name:v.string().optional(),code:v.string().default(""),bindTime:v.number().optional()}),XP=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:JP.optional()}),HP=v.object({apiKey:v.string().optional(),corporationId:v.string().optional(),corporationName:v.string().optional()}),YP=v.object({id:v.string(),name:v.string(),tenantSlug:v.string().optional(),isDemo:v.boolean().default(!1),logoUrl:v.string().nullable().optional(),hoseCorpConfig:HP.optional()}),Sk=v.object({user:XP,tenant:YP}),pP=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(),QP=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(),Ak=v.object({user:pP,session:QP}),_v=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()}),Ok=v.object({rules:v.array(_v),hasPendingDeletes:v.boolean().default(!1)}),PP=v.object({code:v.string().optional(),description:v.string(),scope:v.string(),strictness:v.string()}),Zv=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(PP).default([]),publishedAt:v.number().optional(),createdAt:v.number().optional()}),dk=v.object({version:Zv,rulesCount:v.number()}),pu=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)}),kk=v.object({articles:v.array(pu),total:v.number().optional()}),FP=v.object({explicitApprove:v.string().default(""),explicitReject:v.string().default(""),exemptApprove:v.string().default(""),review:v.string().default("")}).passthrough(),KP=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(),BP=v.enum(["assisted","semi_automatic","fully_automatic"]),Dk=v.object({id:v.string(),url:v.string().url()}).passthrough(),Qu=v.object({type:v.literal("webhook"),id:v.string(),name:v.string(),mode:BP,incomingDocumentWebhook:Dk,outgoingResultWebhook:v.string().url(),incomingManualResultWebhook:Dk,secret:v.string().min(1),autoApprovalRate:v.number().int().min(0).max(100).optional()}).passthrough(),v4=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 M4=DK(UK(),".config","seal-use");async function ML(n,i){let r=await _t(n,{appRoot:i.appRoot,entryFile:i.entryFile,stateDir:M4,version:x,launcher:i.launcher});if(r!==void 0)B(r)}import{existsSync as SK,readFileSync as zL}from"node:fs";async function CL(n,i,r,o,t){if(n==="batch-records"||n==="records"){let u=i??D(t.options.batchId)??D(t.options["batch-id"]);if(!u)throw Error("Usage: seal-use simulation batch-records <batchId>");await X("seal_simulation_batch_records_get",r,o,{batchId:u,query:D(t.options.query)},J(t.options));return}if(n==="create"||n==="run"){let u=D(t.options.mode)??D(t.options.sourceSystem)??D(t.options["source-system"])??"hosecloud",e=u==="material-pack"?"material_pack":u,l=D(t.options.schemaConfig)??D(t.options["schema-config"]),$=l?JSON.parse(zL(l,"utf8")):void 0,I=D(t.options.input),g=I?JSON.parse(zL(I,"utf8")):ri(t.json),b=D(t.options.packageId)??D(t.options["package-id"]),w=Vn(t.options.packageIds)??Vn(t.options["package-ids"])??(b?[b]:void 0),f=Vn(t.options.flowIds)??Vn(t.options["flow-ids"])??Vn(t.options.documentSn)??Vn(t.options["document-sn"]),c=D(t.options.signKey)??D(t.options["sign-key"])??D(t.options.integration);await X("seal_simulation_batch_create",r,o,{mode:e,sourceSystem:e,flowIds:f,documentSn:f,rejectNodeName:D(t.options.rejectNode)??D(t.options["reject-node"])??null,thinkingDepthOverride:D(t.options.thinkingDepth)??D(t.options["thinking-depth"]),skipInvoiceGeneration:_(t.options.skipInvoiceGeneration)??_(t.options["skip-invoice-generation"]),skipExpenseExtraction:_(t.options.skipExpenseExtraction)??_(t.options["skip-expense-extraction"]),disableAttachmentCache:_(t.options.disableAttachmentCache)??_(t.options["disable-attachment-cache"]),signKey:c,packageIds:w,packageId:b,templateId:D(t.options.templateId)??D(t.options["template-id"]),schemaConfig:$,requestIds:Vn(t.options.requestIds)??Vn(t.options["request-ids"]),workflowTypeId:D(t.options.workflowTypeId)??D(t.options["workflow-type-id"]),flowStatusList:Vn(t.options.flowStatusList)?.map(Number)??Vn(t.options["flow-status-list"])?.map(Number),businessCodes:Vn(t.options.businessCodes)??Vn(t.options["business-codes"]),documentType:D(t.options.documentType)??D(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:Vn(t.options.status),limit:ln(t.options.limit),rawParams:g},J(t.options));return}if(n==="wait"){let u=i??D(t.options.batchId)??D(t.options["batch-id"]);if(!u)throw Error("Usage: seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s]");await X("seal_simulation_batch_wait",r,o,{batchId:u,timeout:D(t.options.timeout),pollInterval:D(t.options.pollInterval)??D(t.options["poll-interval"])},J(t.options));return}if(n==="clean"||n==="delete"){let u=i??D(t.options.batchId)??D(t.options["batch-id"]);if(!u)throw Error("Usage: seal-use simulation clean <batchId>");await X("seal_simulation_batch_clean",r,o,{batchId:u},J(t.options));return}if(n==="specifications"){let u=i??D(t.options.integration)??D(t.options.signKey)??D(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??D(t.options.batchId)??D(t.options["batch-id"]);if(!u)throw Error("Usage: seal-use 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??D(t.options.file);if(!u)throw Error("Usage: seal-use simulation package-upload <材料包.zip>");if(!SK(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-use help'foravailablecommands.`)}import{existsSync as gy}from"node:fs";import{join as w$}from"node:path";import{existsSync as z4,mkdirSync as uy,rmSync as XK,writeFileSync as HK}from"node:fs";import{homedir as ey}from"node:os";import{dirname as YK,join as C4}from"node:path";var RL=`---
name:seal-use
description:"v0.10.0: Use for Seal Use first-time enterprise onboarding, Hose/合思 or Seal-native authentication, assistance links and browser cURL intake, plus tenant approval operations, diagnosis, simulation, rules, users, configuration, and search."
description:"v0.10.3: Use for Seal Use first-time enterprise onboarding, Hose/合思 or Seal-native authentication, assistance links and browser cURL intake, plus tenant approval operations, diagnosis, simulation, rules, users, configuration, and search."
Usethe\`seal_cli\` MCP tool when it is available; pass the command string as its \`command\` argument. If MCP is unavailable, fall back to the global \`seal-use\` CLI. This skill is a routing layer for agents: keep this file short, choose the right command, and read a focused reference only when the task needs detail.
##Bootstrap&Installation(环境安装与自愈)
If\`seal-use\` or \`seal_cli\` is not installed on the system, the Agent should automatically install it via:
-User-facingSealtenantassistancelink(Seal协助/Seal授权/委托):resolvethenamedenterprisefirst,thenrun\`seal-use delegation create --corp <corpId> --note '<enterprise>'\`; verify the returned hostname is that tenant's Seal hostname. Always provide BOTH a code block (\`\`\`\`text ... \`\`\`\`) AND a hyperlink.
-Packagedcustomerfeedback→approval-ruleremediation:read\`references/customer-feedback-rule-remediation.md\`. Use this route for WeChat messages, screenshots, rejection notifications, document numbers, customer complaints, expected approval behavior, rule-only mitigation, exact diffs, or requests to update and publish a rule version.
-User-facing合思authorizationlink(合思/易快报授权):\`seal-use auth hose-link --corp <corpId> --expire 7200\`; read \`references/hose-enterprise-auth.md\`. Never use this route when the user says Seal 协助. Always provide BOTH a code block (\`\`\`\`text ... \`\`\`\`) AND a hyperlink.
Rule,document,stylepreference,andpublishactionsmutateSealconfiguration.Makethetargetenterpriseexplicit,showtheintendedpayload,andverifyafterthewrite.Neversendreal\`enterprises/*.json\` files, tokens, signed URLs, or full raw documents to GitHub, tickets, logs, or chat unless the user explicitly requests a safe export.
`;var CL=`interface:
`;var hL=`interface:
display_name:"Seal Use"
short_description:"Diagnose approval feedback and publish minimal rule fixes"
default_prompt:"Use $seal-use to resolve a customer feedback package to the correct tenant, diagnose the approval run, propose a minimal rule diff, and publish only after explicit confirmation."
@@ -436,7 +457,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.
-CLIcommandsareshort-livedprocesses.In-memoryauth/searchcachesonlyliveforthatsingleprocess.Use\`seal-use service restart\` after updates so the optional local service picks up new code.
-Ifnorunisfoundby\`sourceDocumentSN\`, retry with \`sourceDocumentId\` or a broader \`query\`.
-Ifdate-basedsummarieslookwrong,pass\`--timezone Asia/Shanghai\` and an explicit \`--date\`.
-If\`langfuseTraceId\` is missing, use \`langfuseSessionFallback\`.
`;var xL="# Approval Run Lightweight Queries\n\nUse this reference when the user gives a 合思/易快报单号, source document SN, record ID, simulation batch ID, or asks for an approval decision without needing the full raw run payload.\n\n## Locate A Run By Document Number\n\nPrefer `pick` before broad search + bridge + get.\n\n```bash\nseal-useapproval-runspick--corp<corpId>--sn<sourceDocumentSN>--latest\nseal-useapproval-runspick--corp<corpId>--sn<sourceDocumentSN>--batch<batchId>--latest\nseal-useapproval-runspick--corp<corpId>--sn<sourceDocumentSN>--latest--fieldsrecordId,sourceDocumentSN,status,aiDecision,aiSummary\n```\n\nDefault output is intentionally small: `recordId`, `sourceDocumentSN`, `sourceDocumentId`, `simulationBatchId`, `status`, `taskMode`, `ruleSetVersionNumber`, `langfuseTraceId`, `manualResult`, `aiDecision`, and `aiSummary`.\n\nIf there are multiple candidates and `--latest` was not used, report the candidates and ask which one to inspect.\n\n## Read Compact Run Detail\n\nUse `--summary` for most diagnosis and support questions.\n\n```bash\nseal-useapproval-runsget<recordId>--corp<corpId>--summary\n```\n\nUse `--fields` when the user needs a particular slice.\n\n```bash\nseal-useapproval-runsget<recordId>--corp<corpId>--fieldsmetadata\nseal-useapproval-runsget<recordId>--corp<corpId>--fieldsdocument.fields,result.summary\nseal-useapproval-runsget<recordId>--corp<corpId>--fieldsresult.summary,result.decision,result.riskPoints\nseal-useapproval-runsget<recordId>--corp<corpId>--fieldsdocument.keyFields,result,manualApprovalRecord,ruleSetVersionNumber\n```\n\nAvoid full `approval-runsget<recordId>` unless the user specifically needs raw document fields, pipeline logs, invoice rawData, or signed URLs. Prefer `--output-file` for full payloads.\n\n## Understand The Case First\n\nBefore pulling the full document, use:\n\n```bash\nseal-useapproval-runsdocument-summary<recordId>--corp<corpId>\n```\n\nThis is for quick case reading: template/title, key fields, amount, expense type, cost company, payee, invoice summary, attachment names, AI result, and manual result.\n\n## Extract AI-Cited Rules\n\nUse this when the user asks \"AI 用了哪条规则\", \"为什么命中这条\", or needs the rule evidence for a specific run.\n\n```bash\nseal-useapproval-runscited-rules<recordId>--corp<corpId>\n```\n\nReturn and discuss `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-useapproval-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-useapproval-runsresult<recordId>--corp<corpId>--summary\n```\n\nThis is for decision, summary, risk point count, matched rule count, trace ID, and record ID.\n\n## 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 aL=`#ApprovalAttachmentTraceInvestigation
`;var aL="# Seal Use CLI Reference\n\nRun from any directory after installing the global CLI:\n\n```bash\nseal-use<command>\n```\n\nEnterprise config lookup:\n\n- If `SEAL_USE_ENTERPRISES_DIR` is set, only that directory is loaded.\n- Otherwise `./enterprises` and `~/.config/seal-use/enterprises`aremerged.\n-User-levelconfigsoverridesame-IDlocalconfigs.\n\nEnterpriseselectionisstatelessbydefault.Commandsthataccessanenterpriserequire\n`--corp<corpId>`unlessstatefulmodeisexplicitlyenabled:\n\n```bash\nseal-useconfigmodestateful--corp<corpId>\nseal-usecorpsswitch<corpId>\nseal-useconfigmodestateless\n```\n\nTheglobalmodeisstoredin`~/.config/seal-use/config.json`;set`SEAL_USE_CONFIG_FILE`to\noverridethatpath.Thelegacy`current-corp`fileisnotread.\n\n##Stream&ExitCodeContract\n\n-**`stdout`**:Pure,deterministicJSONformachine/Agentparsing.\n-**`stderr`**:Diagnostics,probinglogs,and**Next-StepCommandSuggestions**(e.g.`👉Nextaction:...`).\n-**`ExitCode`**:`0`onsuccess,non-zero(e.g.`1`)onfailuretotriggerAgenterrorself-remediation.\n\n##Top-LevelCommands\n\n```bash\nseal-useversion\nseal-useconfigpaths\nseal-useconfigget\nseal-useconfigmode<stateful|stateless>[--corp<corpId>]\nseal-useservice<start|stop|restart|status>\nseal-usehttp[--port8787][--host127.0.0.1]\nseal-useserve[--port8787]\nseal-useupdate\nseal-usetoolslist\nseal-usecorpslist[--corp<corpId>]\nseal-usecorpscurrent[--corp<corpId>]\nseal-usecorpsswitch<corpId>\nseal-usecorpsadd-hose--json'{\"name\":\"企业名称\",\"domain\":\"https://app.ekuaibao.com\",\"appKey\":\"...\",\"appSecurity\":\"...\",\"proxyStaffBizId\":\"corpId:staffId\"}'\nseal-usecorpsadd-seal--json'{\"sealUrl\":\"https://tenant.sealai.cc\",\"token\":\"seal-bearer-token\"}'\nseal-usecorpsadd-link<https://.../web/thirdparty.html?...>[--name<customName>][--overwrite]\nseal-useauthdiagnose[--corp<corpId>]\nseal-useauthhose-link[--corp<corpId>][--expire7200]\nseal-usedelegationlist[--corp<corpId>]\nseal-usedelegationcreate[--note<note>][--from-link<url>][--corp<corpId>]\nseal-usedelegationrevoke<tokenId>[--corp<corpId>]\nseal-useuserscreate--name<name>--phone<phone>[--dept<deptId>][--corp<corpId>]\nseal-useusersreset-password<userId>[--corp<corpId>]\nseal-useusersget<userId>[--corp<corpId>]\nseal-useusersdelete<userId>[--corp<corpId>]\nseal-usellmconfig[--corp<corpId>]\nseal-usellmproviders[--corp<corpId>]\nseal-usepermissionsavailable[--corp<corpId>]\nseal-usepermissionsconfigs[--corp<corpId>]\nseal-usebillingstatus[--corp<corpId>]\nseal-usebillingplans[--corp<corpId>]\nseal-usebillingfeatures[--corp<corpId>]\nseal-usewebhooklist[--query<text>][--show-secret][--corp<corpId>]\nseal-usewebhookget|find<idOrName>[--show-secret][--corp<corpId>]\nseal-usewebhookadd--name<name>--result-url<url>[--modeassisted|semi_automatic|fully_automatic][--auto-approval-rate60][--secret<secret>][--corp<corpId>]\nseal-usewebhookupdate<idOrName>[--name<name>][--result-url<url>][--modeassisted|semi_automatic|fully_automatic][--auto-approval-rate60][--secret<secret>|--rotate-secret][--corp<corpId>]\nseal-usewebhookdelete<idOrName>--yes[--corp<corpId>]\nseal-usedeployhosecloudrequirements[--corp<corpId>]\nseal-usedeployhosecloudlist[--corp<corpId>]\nseal-usedeployhosecloudget<sign-key>[--corp<corpId>]\nseal-usedeployhosecloudstatus[--corp<corpId>]\nseal-usedeployhosecloudconfigure--json'{...}'[--corp<corpId>]\nseal-usedeployhosecloudsync<sign-key>[--corp<corpId>]\nseal-usepreferenceget[--corp<corpId>]\nseal-usepreferencedecisionupdate--json'{\"explicitApprove\":\"...\"}'[--corp<corpId>]\nseal-usepreferencethinking-depthset--default<medium|high>[--corp<corpId>]\nseal-usepreferencethinking-depthpolicieslist[--corp<corpId>]\nseal-usepreferencethinking-depthpoliciesupsert--json'{...}'[--corp<corpId>]\nseal-usepreferencethinking-depthpoliciesremove<policyId>[--corp<corpId>]\nseal-usesourceconfig[--corp<corpId>]\nseal-usetool<toolName>[--corp<corpId>][--json'{\"key\":\"value\"}']\nseal-useapproval-runssummary--corp<corpId>[--dateYYYY-MM-DD][--timezoneAsia/Shanghai]\nseal-useapproval-runsstats--corp<corpId>[--since3months][--dedupe-bysourceDocumentSN|sourceDocumentId|id]\nseal-useapproval-runscount--corp<corpId>[--statusAPPROVED]\nseal-useapproval-runssearch--corp<corpId>[--querytext][--limit20][--includeBridgetrue]\nseal-useapproval-runsget<recordId>--corp<corpId>[--fieldsmetadata|document.fields,result.summary][--output-filefile.json]\nseal-useapproval-runsattachments<recordId>--corp<corpId>\nseal-useapproval-runsresult<recordId>--corp<corpId>[--summary]\nseal-useapproval-runsurl--corp<corpId>\nseal-useapproval-runLine truncated
-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-useauthdiagnose--corp<discovered-id>
\`\`\`
Donotaskfor\`domain\`, \`corpId\`, or \`proxyStaffBizId\` up front. For a dedicated/private Hose deployment, add \`domain\` only after standard probing reports that it cannot find the enterprise.
-\`seal-use auth hose-link\` and \`seal-use delegation create\` generate links for an enterprise that is already configured. \`seal-use corps add-link <url>\` imports a received Hose/合思 \`thirdparty.html\` assistance link and verifies the resulting Seal tenant.
UsethedirectimportroutewhentheincominglinkisanHTTPS\`thirdparty.html\` URL from a supported \`ekuaibao.com\` or \`hosecloud.com\` domain:
Thecommandparses\`accessToken\` and \`ekbCorpId\`, exchanges the temporary Hose token at the target Seal tenant, verifies \`/api/v1/auth/me\`, and stores only the normalized short-lived Seal session. It never prints or persists the original URL. Use \`--overwrite\` only when intentionally replacing an existing enterprise config. To create a Seal delegation link without persisting the session, use \`seal-use delegation create --from-link <url> [--note ...]\`.
2.Parseitasdata.Extracttherequesthost,path,\`Authorization\` header, cookies, and provider/tenant hints. Ignore the request body unless it is required to identify the tenant.
3.ClassifywhetherthecapturedrequestistoHoseorSeal.ASealrequestwith\`Authorization: Bearer ...\` can supply \`sealUrl\` and a session token even when the user's identity origin is Hose.
4.Verifywiththenarrowestread-onlyidentityendpointavailable.ForaSealBearersession,verify\`/api/v1/auth/me\` through \`seal-use corps add-seal\`; use returned provider metadata to retain the actual origin.
ThecurrentCLIhasnoraw-cURLimportcommandand\`add-seal\` requires a Bearer token. If the captured request contains only cookies or an authentication shape the CLI cannot verify, do not improvise a token. Ask the user to copy another successful Seal Fetch/XHR request that contains the Bearer header, or explain the current limitation.
`;var ty="# Enterprise Onboarding\n\nRead this reference for first installation, zero configured enterprises, incoming credentials or assistance links, and browser-copied cURL. The goal is to identify the enterprise with the least user effort while keeping authentication material confidential.\n\n## Start With Discovery\n\nRun this before asking for setup parameters (if `seal-use` is not installed, first run `curl-fsSLhttps://git.ying-qing.cn/gitea/seal-use/raw/branch/main/scripts/install.sh | bash`):\n\n```bash\nseal-use version\nseal-use corps list\n```\n\n- If `seal-use` is not installed on the system, run the curl install script above to install it.\n- If the target enterprise is listed, match the user's human enterprise name to its returned `id` and use that value as `--corp` on every command. Do not ask the user for `corpId`.\n- If multiple configured enterprises plausibly match, show their human names and let the user choose. Keep their IDs as implementation details.\n- If none are configured, ask one plain-language question: “你现在手上有哪一种接入材料:合思开放平台 appKey/appSecurity、合思授权/协助链接、Seal 协助链接,还是从已登录的合思或 Seal 网页复制的 cURL?”\n\nDo not open with a JSON template or a list of internal fields.\n\nAll command examples in this reference are for the Agent to run. Do not hand them to the user as setup instructions. Communicate with the user in natural language and translate their answer into CLI/MCP parameters yourself.\n\n## Keep Two Concepts Separate\n\nClassify both the enterprise identity origin and how the current credential was acquired:\n\n| Enterprise identity origin | Credential material the user may have | Meaning |\n| --- | --- | --- |\n| Hose/合思-sourced Seal tenant | Hose `appKey` + `appSecurity` | Stable, refreshable standard integration |\n| Hose/合思-sourced Seal tenant | Hose authorization/assistance link | Temporary Hose authorization that can lead into the Seal SSO session |\n| Hose/合思-sourced Seal tenant | cURL copied from an authenticated Hose or Seal page | Snapshot of a signed-in browser session; it may expire |\n| Seal-native tenant | Seal assistance/delegation link | Temporary delegated access to a Seal tenant |\n| Seal-native tenant | cURL copied from an authenticated Seal page | Snapshot containing the Seal host and session authentication |\n\nCredential shape alone does not define identity origin. In particular, a Hose-sourced user eventually receives a Seal Bearer session after SSO. When `whoami` returns provider metadata, preserve it and use it to describe the tenant accurately.\n\n## Parameter Ownership\n\nAsk the user only for information that cannot be discovered safely:\n\n| Field | Owner and behavior |\n| --- | --- |\n| `appKey`, `appSecurity` | User supplies these for standard Hose OpenAPI onboarding. Explain that they come from the enterprise's 合思开放平台 application credentials. Treat both as secrets. |\n| `domain` | Probe the standard Hose SaaS domains automatically. Ask only when probing fails and the enterprise uses a private or dedicated deployment. |\n| Enterprise name and `corpId` | Discover from the credential response or Seal `whoami`. Do not ask the user to invent or locate them first. |\n| Administrator and `staffId` | Discover administrator candidates. If more than one is eligible, present name and masked phone for the user to choose; pass the selected ID internally. |\n| Seal URL, tenant ID, tenant slug | Discover from the assistance link, cURL host, and Seal `whoami`. |\n| Bearer token, cookies, signed query tokens | Extract only from user-supplied authentication material. Never print them back or include them in summaries. |\n\n## Route 1: Standard Hose Credentials\n\nThis is the preferred durable route for a Hose-sourced tenant. Read `hose-enterprise-init.md`, then use:\n\n```bash\nseal-use corps add-hose --json '{\"appKey\":\"...\",\"appSecurity\":\"...\"}'\n```\n\nThe CLI probes the standard domains, discovers the corporation, and discovers administrator candidates. If it returns multiple candidates, show only useful identifying information and ask which person should be used; retry with `staffName`, `staffPhone`, or the selected `staffId` internally. After creation, run:\n\n```bash\nseal-use auth diagnose --corp <discovered-id>\n```\n\nDo not ask for `domain`, `corpId`, or `proxyStaffBizId` up front. For a dedicated/private Hose deployment, add `domain` only after standard probing reports that it cannot find the enterprise.\n\n## Route 2: Incoming Assistance Link\n\nFirst distinguish the link by its host and purpose:\n\n- A Hose authorization/provisional link opens a Hose session and may continue through Seal SSO. It is not a Seal delegation link.\n- A Seal assistance/delegation link grants temporary delegated access on a Seal tenant. It is not a Hose OpenAPI credential.\n- `seal-use auth hose-link` and `seal-use delegation create` generate
Line truncated
-\`seal-use auth diagnose\` proves this stage works but redacts the token, so it is not enough when the user needs the actual clickable Hose link.
-**FormattingRequirement**:WhenreturningaHoseauthorizationlinktotheuser,ALWAYSprovideBOTHacodeblock(\`\`\`\`text ... \`\`\`\`) for easy copying without accidental default browser redirection, AND a clickable hyperlink.
`);return}if(n==="install"||n==="init"||n==="sync"){let o=_(r.options.local)||_(r.options.workspace),t=D(r.options.dir)??D(r.options.target)??i,u=t?t:o?w$(process.cwd(),".agents","skills","seal-use"):zu(),e=C4(u);B({installed:!0,targetDir:e.targetDir,fileCount:e.files.length,files:e.files});return}if(n==="status"||n==="get"||!n){let o=zu(),t=w$(process.cwd(),".agents","skills","seal-use");B({global:{dir:o,installed:$y(w$(o,"SKILL.md"))},local:{dir:t,installed:$y(w$(t,"SKILL.md"))}});return}throw Error(`Unknownskillcommand:${n}.Run'seal-use help'foravailablecommands.`)}async function gy(n,i){if(n==="config"){B(await xr(i));return}throw Error(`Unknownsourcecommand:${n??""}.Run'seal-use help'foravailablecommands.`)}async function by(n,i,r,o){if(!n)throw Error("Usage: seal-use tool <toolName> [--json '{...}']");await X(n,i,r,ri(o.json),J(o.options))}function wy(){B(Vu.map((n)=>({name:n.name,description:n.description})))}import{chmodSync as HK,mkdirSync as YK,renameSync as h4,rmSync as PK,unlinkSync as Sy,writeFileSync as fy}from"node:fs";import{dirname as pK,join as cy}from"node:path";import{spawnSync as Zt}from"node:child_process";function f$(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")&&!r.endsWith("/node")&&!r.endsWith("/node.exe")}var Ay="yunyingk/seal-home",sr="yunyingk/seal-home";var QK="SEAL_USE_GITHUB_REPO",FK="SEAL_HOME_GITHUB_REPO";async function Oy(n,i={}){let r={appRoot:n.appRoot,entryFile:n.entryFile,stateDir:Z4,version:m,launcher:n.launcher},o=i.repo||process.env[QK]?.trim()||process.env[FK]?.trim()||Ay,t=i.targetVersion?.trim(),u=t&&t.toLowerCase()!=="latest"?t:void 0;if(u){let G=u.replace(/^v/,""),N=ky(G,m);if(N<0){B({updated:!1,currentVersion:m,targetVersion:G,mode:f$()?"binary":"source",message:`Cannotdowngradeseal-usefromv${m}toolderversionv${G}.Updatesmustbeforward-only.`});return}if(N===0&&!i.force){B({updated:!1,currentVersion:m,targetVersion:G,mode:f$()?"binary":"source",message:`seal-useisalreadyatversionv${m}.Use--forcetoreinstall.`});return}}if(i.changelogOnly){let G=await m4(o,i.limit??10);B({currentVersion:m,totalQueried:G.length,releases:G.map((N)=>({version:N.version,tagName:N.tagName,publishedAt:N.publishedAt,author:N.author,releaseNotes:N.notes,releaseUrl:N.htmlUrl,isCurrent:N.version===m,isNewer:Cu(N.version,m)}))});return}if(!f$()){if(i.checkOnly){let N=await m4(o,30),E=N[0],x=E?.version??m,yn=N.find((un)=>un.version===m),Wn=Cu(x,m),On=N.filter((un)=>Cu(un.version,m));B({updated:!1,updateAvailable:Wn,currentVersion:m,currentVersionPublishedAt:yn?.publishedAt,latestVersion:x,latestVersionPublishedAt:E?.publishedAt,behindCount:On.length,pendingReleases:On.map((un)=>({version:un.version,tagName:un.tagName,publishedAt:un.publishedAt,author:un.author,releaseNotes:un.notes,releaseUrl:un.htmlUrl})),releaseNotes:E?.notes??"",releaseUrl:E?.htmlUrl??"",mode:"source",message:"Running in source development mode. Run 'seal-use update' to git pull & bun install."});return}let G=ar(r).running;if(G)await _t("stop",r);try{Dy("git",["-C",n.appRoot,"pull","--ff-only"])}catch(N){console.error(`gitpullskipped:${NinstanceofError?N.message:String(N)}`)}if(Dy("bun",["install"],{cwd:n.appRoot}),G)await _t("start",r);B({updated:!0,serviceRestarted:G,version:m,mode:"source"});return}let e=KK(),l=BK(),$=await m4(o,30),I=u?$.find((G)=>G.version===u||G.tagName===u||G.tagName===`v${u}`)??await Uy(o,u):$[0]??await Uy(o);if(!I){B({updated:!1,currentVersion:m,mode:"binary",message:`Failedtoqueryreleasesfromrepository'${o}'`});return}let g=I.version,b=$.find((G)=>G.version===m),w=Cu(g,m),f=w||Boolean(i.force),c=$.filter((G)=>Cu(G.version,m));if(i.checkOnly){B({updated:!1,updateAvailable:w,currentVersion:m,currentVersionPublishedAt:b?.publishedAt,latestVersion:g,latestVersionPublishedAt:I.publishedAt,behindCount:c.length,pendingReleases:c.map((G)=>({version:G.version,tagName:G.tagName,publishedAt:G.publishedAt,author:G.author,releaseNotes:G.notes,releaseUrl:G.htmlUrl})),releaseNotes:I.notes,releaseUrl:I.htmlUrl,mode:"binary"});return}if(!f){B({updated:!1,currentVersion:m,currentVersionPublishedAt:b?.publishedAt,latestVersion:g,latestVersionPublishedAt:I.publishedAt,mode:"binary",message:`seal-useisalreadyuptodate(v${m})`});return}let S=TK(I.assets,e,l);if(!S)throw Error(`Nocompatiblebinaryfoundfor${e}-${l}inreleasev${g}.Availableassets:${I.assets.map((G)=>G.name).join(", ")}`);let k=ar(r).running;if(k)await _t("stop",r);let d=process.execPath,Q=pK(d),Y=cy(Q,`.tmp-update-${Date.now()}`);YK(Y,{recursive:!0});try{let G=cy(Y,S.name);await VK(S.downloadUrl,G,I.tagName,S.name);let N=G;if(S.name.endsWith(".tar.gz")||S.name.endsWith(".tgz"))N=qK(G,Y,e);else if(S.name.endsWith(".zip"))N=EK(G,Y,e);if(HK(N,493),process.platform==="darwin")try{Zt("/usr/bin/codesign",["--remove-signature",N],{stdio:"ignore"}),Zt("/usr
Line truncated
`)}catch{}}async function VK(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/${Ay}/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],k=new AbortController,d="",Q=(E)=>{d=E;try{k.abort()}catch{}},Y=setTimeout(()=>{Q("Connection timed out (no response headers within 6s)")},I),G,N;try{c$(`==> [${c+1}/${l.length}] Downloading via: ${S}`);let E=await fetch(S,{signal:k.signal});if(Y)clearTimeout(Y),Y=void 0;if(!E.ok)throw Error(`HTTP ${E.status} ${E.statusText}`);G=setTimeout(()=>{Q("Overall download time exceeded 3 minutes")},f);let x=Number(E.headers.get("content-length"))||0,yn=E.body?.getReader();if(!yn){let wi=Buffer.from(await E.arrayBuffer());if(wi.length<1000)throw Error(`Downloaded content is suspiciously small (${wi.length} bytes)`);fy(i,wi),c$(`✓ Download succeeded (${(wi.length/1024/1024).toFixed(1)} MB)`);return}let Wn=[],On=0,un=0;N=setTimeout(()=>{if(On<b){let wi=(On/1024).toFixed(1);Q(`Initial transfer too slow (${wi} KB < 300 KB in 6s), switching mirror...`)}},g);while(!0){let wi=yn.read(),no,Wy=new Promise((D$,S$)=>{no=setTimeout(()=>{S$(Error("Data transfer stalled (no chunk received for 10s)"))},w)}),s4;try{s4=await Promise.race([wi,Wy])}finally{if(no)clearTimeout(no)}let{done:Jy,value:U$}=s4;if(Jy)break;if(U$){if(Wn.push(U$),On+=U$.length,N&&On>=b)clearTimeout(N),N=void 0;let D$=Date.now();if(D$-un>200){un=D$;let S$=x?Math.round(On/x*100):0,Xy=(On/1048576).toFixed(1),Hy=x?(x/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${S$}% (${Xy} / ${Hy} MB)...`)}catch{}}}}try{process.stderr.write(`
`);return}if(n==="install"||n==="init"||n==="sync"){let o=_(r.options.local)||_(r.options.workspace),t=D(r.options.dir)??D(r.options.target)??i,u=t?t:o?w$(process.cwd(),".agents","skills","seal-use"):zu(),e=R4(u);B({installed:!0,targetDir:e.targetDir,fileCount:e.files.length,files:e.files});return}if(n==="status"||n==="get"||!n){let o=zu(),t=w$(process.cwd(),".agents","skills","seal-use");B({global:{dir:o,installed:gy(w$(o,"SKILL.md"))},local:{dir:t,installed:gy(w$(t,"SKILL.md"))}});return}throw Error(`Unknownskillcommand:${n}.Run'seal-use help'foravailablecommands.`)}async function wy(n,i){if(n==="config"){B(await ar(i));return}throw Error(`Unknownsourcecommand:${n??""}.Run'seal-use help'foravailablecommands.`)}async function fy(n,i,r,o){if(!n)throw Error("Usage: seal-use tool <toolName> [--json '{...}']");await X(n,i,r,ri(o.json),J(o.options))}function cy(){B(Tu.map((n)=>({name:n.name,description:n.description})))}import{chmodSync as pK,mkdirSync as QK,renameSync as m4,rmSync as PK,unlinkSync as Oy,writeFileSync as Uy}from"node:fs";import{dirname as FK,join as Dy}from"node:path";import{spawnSync as Zt}from"node:child_process";function f$(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")&&!r.endsWith("/node")&&!r.endsWith("/node.exe")}var dy="yunyingk/seal-use",Ru="yunyingk/seal-home";var KK="SEAL_USE_GITHUB_REPO",BK="SEAL_HOME_GITHUB_REPO";async function ky(n,i={}){let r={appRoot:n.appRoot,entryFile:n.entryFile,stateDir:M4,version:x,launcher:n.launcher},o=i.repo||process.env[KK]?.trim()||process.env[BK]?.trim()||dy,t=i.targetVersion?.trim(),u=t&&t.toLowerCase()!=="latest"?t:void 0;if(u){let W=u.replace(/^v/,""),N=Ny(W,x);if(N<0){B({updated:!1,currentVersion:x,targetVersion:W,mode:f$()?"binary":"source",message:`Cannotdowngradeseal-usefromv${x}toolderversionv${W}.Updatesmustbeforward-only.`});return}if(N===0&&!i.force){B({updated:!1,currentVersion:x,targetVersion:W,mode:f$()?"binary":"source",message:`seal-useisalreadyatversionv${x}.Use--forcetoreinstall.`});return}}if(i.changelogOnly){let W=await x4(o,i.limit??10);B({currentVersion:x,totalQueried:W.length,releases:W.map((N)=>({version:N.version,tagName:N.tagName,publishedAt:N.publishedAt,author:N.author,releaseNotes:N.notes,releaseUrl:N.htmlUrl,isCurrent:N.version===x,isNewer:Cu(N.version,x)}))});return}if(!f$()){if(i.checkOnly){let N=await x4(o,30),M=N[0],q=M?.version??x,An=N.find((nn)=>nn.version===x),Wn=Cu(q,x),jn=N.filter((nn)=>Cu(nn.version,x));B({updated:!1,updateAvailable:Wn,currentVersion:x,currentVersionPublishedAt:An?.publishedAt,latestVersion:q,latestVersionPublishedAt:M?.publishedAt,behindCount:jn.length,pendingReleases:jn.map((nn)=>({version:nn.version,tagName:nn.tagName,publishedAt:nn.publishedAt,author:nn.author,releaseNotes:nn.notes,releaseUrl:nn.htmlUrl})),releaseNotes:M?.notes??"",releaseUrl:M?.htmlUrl??"",mode:"source",message:"Running in source development mode. Run 'seal-use update' to git pull & bun install."});return}let W=sr(r).running;if(W)await _t("stop",r);try{Ay("git",["-C",n.appRoot,"pull","--ff-only"])}catch(N){console.error(`gitpullskipped:${NinstanceofError?N.message:String(N)}`)}if(Ay("bun",["install"],{cwd:n.appRoot}),W)await _t("start",r);B({updated:!0,serviceRestarted:W,version:x,mode:"source"});return}let e=EK(),l=TK(),$=await x4(o,30),I=u?$.find((W)=>W.version===u||W.tagName===u||W.tagName===`v${u}`)??await Sy(o,u):$[0]??await Sy(o);if(!I){B({updated:!1,currentVersion:x,mode:"binary",message:`Failedtoqueryreleasesfromrepository'${o}'`});return}let g=I.version,b=$.find((W)=>W.version===x),w=Cu(g,x),f=w||Boolean(i.force),c=$.filter((W)=>Cu(W.version,x));if(i.checkOnly){B({updated:!1,updateAvailable:w,currentVersion:x,currentVersionPublishedAt:b?.publishedAt,latestVersion:g,latestVersionPublishedAt:I.publishedAt,behindCount:c.length,pendingReleases:c.map((W)=>({version:W.version,tagName:W.tagName,publishedAt:W.publishedAt,author:W.author,releaseNotes:W.notes,releaseUrl:W.htmlUrl})),releaseNotes:I.notes,releaseUrl:I.htmlUrl,mode:"binary"});return}if(!f){B({updated:!1,currentVersion:x,currentVersionPublishedAt:b?.publishedAt,latestVersion:g,latestVersionPublishedAt:I.publishedAt,mode:"binary",message:`seal-useisalreadyuptodate(v${x})`});return}let S=VK(I.assets,e,l);if(!S)throw Error(`Nocompatiblebinaryfoundfor${e}-${l}inreleasev${g}.Availableassets:${I.assets.map((W)=>W.name).join(", ")}`);let d=sr(r).running;if(d)await _t("stop",r);let k=process.execPath,P=FK(k),Q=Dy(P,`.tmp-update-${Date.now()}`);QK(Q,{recursive:!0});try{let W=Dy(Q,S.name);await qK(S.downloadUrl,W,I.tagName,S.name);let N=W;if(S.name.endsWith(".tar.gz")||S.name.endsWith(".tgz"))N=_K(W,Q,e);else if(S.name.endsWith(".zip"))N=ZK(W,Q,e);if(pK(N,493),process.platform==="darwin")try{Zt("/usr/bin/codesign",["--remove-signature",N],{stdio:"ignore"}),Zt("/usr/
Line truncated
`)}catch{}}async function qK(n,i,r,o){let t=a4(),u=[],e=r?r.startsWith("v")?r:`v${r}`:void 0,l=o||n.split("/").pop()||"";if(t!=="github"){if(e&&l)u.push(`https://git.ying-qing.cn/gitea/seal-use/releases/download/${e}/${l}`,`https://git.ying-qing.cn/gitea/seal-home/releases/download/${e}/${l}`);if(n.startsWith("https://git.ying-qing.cn"))u.push(n)}if(t!=="gitea")if(e&&l){let S=`https://github.com/${dy}/releases/download/${e}/${l}`;if(!process.env.CI)u.push(`https://ghfast.top/${S}`,`https://gh.ddlc.top/${S}`);u.push(S)}else if(n.includes("github.com")){if(!process.env.CI)u.push(`https://ghfast.top/${n}`,`https://gh.ddlc.top/${n}`);u.push(n)}else u.push(n);let $=Array.from(new Set(u)),I,g=6000,b=6000,w=307200,f=1e4,c=180000;for(let S=0;S<$.length;S++){let d=$[S],k=new AbortController,P="",Q=(q)=>{P=q;try{k.abort()}catch{}},W=setTimeout(()=>{Q("Connection timed out (no response headers within 6s)")},g),N,M;try{c$(`==> [${S+1}/${$.length}] Downloading via: ${d}`);let q=await fetch(d,{signal:k.signal});if(W)clearTimeout(W),W=void 0;if(!q.ok)throw Error(`HTTP ${q.status} ${q.statusText}`);N=setTimeout(()=>{Q("Overall download time exceeded 3 minutes")},c);let An=Number(q.headers.get("content-length"))||0,Wn=q.body?.getReader();if(!Wn){let Ni=Buffer.from(await q.arrayBuffer());if(Ni.length<1000)throw Error(`Downloaded content is suspiciously small (${Ni.length} bytes)`);Uy(i,Ni),c$(`✓ Download succeeded (${(Ni.length/1024/1024).toFixed(1)} MB)`);return}let jn=[],nn=0,no=0;M=setTimeout(()=>{if(nn<w){let Ni=(nn/1024).toFixed(1);Q(`Initial transfer too slow (${Ni} KB < 300 KB in 6s), switching mirror...`)}},b);while(!0){let Ni=Wn.read(),U$,Xy=new Promise((S$,A$)=>{U$=setTimeout(()=>{A$(Error("Data transfer stalled (no chunk received for 10s)"))},f)}),i0;try{i0=await Promise.race([Ni,Xy])}finally{if(U$)clearTimeout(U$)}let{done:Hy,value:D$}=i0;if(Hy)break;if(D$){if(jn.push(D$),nn+=D$.length,M&&nn>=w)clearTimeout(M),M=void 0;let S$=Date.now();if(S$-no>200){no=S$;let A$=An?Math.round(nn/An*100):0,Yy=(nn/1048576).toFixed(1),py=An?(An/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${A$}% (${Yy} / ${py} MB)...`)}catch{}}}}try{process.stderr.write(`
"description":"Planned HTTP contract for the seal-use wrapped backend API.\n\nThese endpoints describe the intended stable API for frontend developers and agents once\nthe HTTP adapter is implemented.\nThey are not the raw downstream Seal endpoints. seal-use is responsible for enterprise\nselection, source authentication, response compaction, and diagnostics-friendly fields.\n"
description:"v0.10.0: Use for Seal Use first-time enterprise onboarding, Hose/合思 or Seal-native authentication, assistance links and browser cURL intake, plus tenant approval operations, diagnosis, simulation, rules, users, configuration, and search."
description:"v0.10.3: Use for Seal Use first-time enterprise onboarding, Hose/合思 or Seal-native authentication, assistance links and browser cURL intake, plus tenant approval operations, diagnosis, simulation, rules, users, configuration, and search."
metadata:
version:0.10.0
short-description:Seal tenant and Hose approval automation (v0.10.0)
version:0.10.3
short-description:Seal tenant and Hose approval automation (v0.10.3)
---
# Seal Use (v0.10.0)
# Seal Use (v0.10.3)
Use the `seal_cli` MCP tool when it is available; pass the command string as its `command` argument. If MCP is unavailable, fall back to the global `seal-use` CLI. This skill is a routing layer for agents: keep this file short, choose the right command, and read a focused reference only when the task needs detail.
## Bootstrap & Installation (环境安装与自愈)
If `seal-use` or `seal_cli` is not installed on the system, the Agent should automatically install it via:
- User-facing Seal tenant assistance link (Seal 协助/Seal 授权/委托): resolve the named enterprise first, then run `seal-use delegation create --corp <corpId> --note '<enterprise>'`; verify the returned hostname is that tenant's Seal hostname. Always provide BOTH a code block (` ```text ... ``` `) AND a hyperlink.
- Packaged customer feedback → approval-rule remediation: read `references/customer-feedback-rule-remediation.md`. Use this route for WeChat messages, screenshots, rejection notifications, document numbers, customer complaints, expected approval behavior, rule-only mitigation, exact diffs, or requests to update and publish a rule version.
- User-facing 合思 authorization link (合思/易快报授权): `seal-use auth hose-link --corp <corpId> --expire 7200`; read `references/hose-enterprise-auth.md`. Never use this route when the user says Seal 协助. Always provide BOTH a code block (` ```text ... ``` `) AND a hyperlink.
@@ -4,13 +4,14 @@ Read this reference for first installation, zero configured enterprises, incomin
## Start With Discovery
Run this before asking for setup parameters:
Run this before asking for setup parameters (if `seal-use` is not installed, first run `curl -fsSL https://git.ying-qing.cn/gitea/seal-use/raw/branch/main/scripts/install.sh | bash`):
```bash
seal-use version
seal-use corps list
```
- If `seal-use` is not installed on the system, run the curl install script above to install it.
- If the target enterprise is listed, match the user's human enterprise name to its returned `id` and use that value as `--corp` on every command. Do not ask the user for `corpId`.
- If 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?”
Use this reference when configuring, deploying, or troubleshooting Seal AI smart approval integrations with Hose/合思费控 (界面路径:【智能审核】 $\to$ 【发布】 $\to$ 【合思费控】).
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.