1.**Token Economy**: If set to `trigger: "always_on"`, every turn of the conversation unconditionally injects all rules into the system prompt (`<user_rules>`), consuming ~800 tokens on every request regardless of task relevance.
1.**Token Economy**: If set to `trigger: "always_on"`, every turn of the conversation unconditionally injects all rules into the system prompt (`<user_rules>`), consuming substantial tokens on every request regardless of task relevance.
2.**On-Demand Activation**: Setting `trigger: "manual"` prevents automatic background injection into the prompt budget. The rules remain available on-demand when explicitly referenced or requested.
3.**Cross-Agent Neutrality**: Non-agy agents (e.g. OpenAI Codex, Claude Code, Cursor, generic LLMs) do not recognize `agy`'s private frontmatter triggers. Storing modular guidelines as plain Markdown with a manual trigger ensures they function as clean, standalone reference docs that any agent can read on demand via standard file reading tools without unexpected prompt pollution.
- **CLI Development**: When adding or refactoring CLI commands under `src/cli/`, read [`rules/cli-protocol.md`](./rules/cli-protocol.md) before writing output streams.
- **Writing Tests**: When creating or modifying tests, read [`rules/testing.md`](./rules/testing.md).
- **TypeScript & Modules**: When adding new TypeScript files or resolving local imports, refer to [`rules/typescript-style.md`](./rules/typescript-style.md).
- **Rule Remediation & Staging**: When modifying approval rules or syncing between production and test enterprises, refer to [`rules/staging-simulation.md`](./rules/staging-simulation.md).
- **Webhook Material Packs**: When exporting, previewing, or validating Webhook attachment bundles, refer to [`rules/material-pack-policy.md`](./rules/material-pack-policy.md).
-**NEVER** output human text, logs, spinners, progress banners, or update notices to `stdout`. The Agent Harness parses `stdout` directly into typed payloads.
- **Documented exceptions**: `seal-use --help` / `seal-use help <area>` (`src/cli/printer.ts`) and `seal-use doctor guide` (`src/cli/commands/doctor.ts`) intentionally output Markdown documents on `stdout` because their output *is* the requested document payload. Never add new stdout-prose commands outside this list.
- **Diagnostics & Guidance Channel (`stderr`)**:
- Use `stderr` for runtime logs, network probing status, self-healing notifications, and human tips.
- Explicit **Next-Step Command Suggestions** MUST follow the format:
```text
👉 Next action: seal-use <command>
```
3.**Exit Code Contract**:
- Successful operations MUST exit with `0`.
- Any validation error, upstream API failure, or block MUST result in non-zero exit code (e.g. `1`).
- DO NOT call `process.exit()` deep in domain functions; throw structured errors and let `src/cli/runner.ts` handle stream routing and exit code assignment.
---
## 2. Performance Contract & SWR Architecture
- **Sub-10ms Local Execution**:
- Read-only discovery commands (e.g. `seal-use version`, `seal-use doctor paths`, `seal-use corps list`) MUST return instantaneously (<10ms).
- Never trigger synchronous external HTTP requests during routine discovery or inspection invocations.
- **Stale-While-Revalidate (SWR) Pattern**:
1. Synchronously read local cache from `~/.config/seal-use/*.json` (<0.2ms).
2. Return the local cached state immediately on `stdout`.
3. If cache is missing or older than TTL (e.g. 24 hours), trigger a background refresh:
| `10` | **Confirmation Required** | Mutating command invoked without `--confirm` or `--yes` |
**Rule**: Never call `process.exit()` deep in domain functions. Throw structured errors and let `src/cli/runner.ts` handle error classification, stream routing, and exit code assignment.
---
## 5. Argument Parsing Conventions
- Use helpers from `src/cli/parser.ts`:
- `booleanOption(args.options.flag)`
- `stringOption(args.options.param)`
- `numberOption(args.options.limit)`
- Support kebab-case and camelCase options gracefully.
- Positional arguments should fall back to option flags when natural (e.g. `corps get <corpId>` and `corps get --corp <corpId>`).
@@ -19,10 +19,11 @@ Tests are colocated as `*.test.ts` files in `src/`. OpenAPI source YAML lives in
-`bun test`: run all colocated Bun tests.
-`bun run bump <version | patch | minor>`: bump version across all manifest/skill/openapi files and bundle.
-`bun run openapi:bundle`: rebuild `dist/openapi.json`.
-`bun run build:binary`: compile the standalone `seal-use` binary to `dist/bin/seal-use` (gitignored).
-`bun run build:plugin`: bundle the MCP server to `dist/mcp/server.js` (tracked, used by `.mcp.json`).
-`bun run dev:override`: compile the host binary with Git dev version metadata, macOS sign, atomically override the Mac global command (`/opt/homebrew/bin/seal-use`), and sync the local Agent Skill.
> **Pre-Push Bundle Gates**: Modifying `src/` files imported by the MCP server requires running `bun run build:plugin` to keep `dist/mcp/server.js` in sync; modifying `openapi/` requires `bun run openapi:bundle` to keep `dist/openapi.json` in sync. CI strictly checks for zero diff on both tracked bundles.
## Coding Style & Naming Conventions
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`.
@@ -34,18 +35,28 @@ Prefer small domain functions over broad utility modules.
- **Machine Channel (`stdout`)**: Data 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.
- **Documented exception — document-output commands**: `seal-use --help` / `seal-use help <area>` (`src/cli/printer.ts`) and `seal-use doctor guide` (`src/cli/commands/doctor.ts`) intentionally write Markdown to `stdout`, because their output *is* the payload the caller redirects or reads (e.g. `seal-use doctor guide > guide.md`). Never add a new prose-on-stdout command outside this list: return structured JSON and put the readable rendering on `stderr` instead. `src/probe.ts` is a local developer probe script rather than a `bin` entry point, so its `[probe] …` lines are outside this contract.
- **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>`).
- **Performance Contract & SWR Architecture**: Read-only discovery and version commands (`seal-use version`, `seal-use doctor`, `seal-use corps list`) MUST execute instantaneously (<10ms). Never block on external network I/O during routine invocations. Use the Stale-While-Revalidate (SWR) pattern: read local cache from `~/.config/seal-use/*.json` synchronously (<0.2ms), and refresh stale/missing data via detached, unref'd child processes (`triggerBackgroundUpdateCheck`, `unref()`).
- **Safety Guardrail & Mutation Preview (`--dry-run`)**: All potentially destructive or state-mutating commands (e.g. `rules push/clear`, `corps sync-test`, `preference update`, `webhook add/update`) MUST support `--dry-run` returning structured JSON previews with `preview: true` and a clean diff, without executing mutations. Live execution requires explicit `--yes` or `--confirm`.
- **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.
-`0`: Successful execution.
-`1`: Upstream API failure or domain business block.
-`2`: Parameter validation failure, unknown subcommand, or invalid JSON.
-`10`: Safety gate block requiring user confirmation (`--confirm` / `--yes`).
- 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
Use `bun:test` with `describe`, `test`, and `expect`. Place tests next to covered code using `name.test.ts`, for example `src/core/config/loader.test.ts`. Tests that change environment variables or working directories must restore them in `afterEach`.
Use `bun:test` with `describe`, `test`, and `expect`. Place tests next to covered code using `name.test.ts`, for example `src/core/config/loader.test.ts`. Tests that change environment variables or working directories must restore them in `afterEach`. Ensure background tasks are guarded with `SEAL_DISABLE_BG_UPDATE=1` or `NODE_ENV=test` during tests. Detailed test hygiene guidelines are in `.agents/rules/testing.md`.
## Commit & Pull Request Guidelines
Recent commits use concise imperative subjects, often `Add ...` or `Refine ...`, such as `Add compact approval rule listing`. Keep subjects under roughly 72 characters. Specific workflows and domain guidelines are maintained in `.agents/rules/`.
Recent commits use concise imperative subjects, often `Add ...` or `Refine ...`, such as `Add compact approval rule listing`. Keep subjects under roughly 72 characters. Specific workflows and domain guidelines are maintained in `.agents/rules/`:
- Issue triage & PR workflow (No premature release): `.agents/rules/issue-pr-workflow.md`
@@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.10.33] - 2026-09-20
### Added
- **Instantaneous Version Discovery via SWR Update Cache**:
- Implemented zero-network Stale-While-Revalidate caching for `seal-use version` backed by `~/.config/seal-use/update-cache.json`, keeping invocations strictly sub-10ms.
- Automatically dispatches an unref'd, detached background check when cache is older than 24 hours without blocking exit.
- Returns structured `latestVersion`, `updateAvailable: true`, and `lastCheckedAt` in stdout JSON when an upgrade is available, paired with non-blocking guidance on stderr.
- **Actionable Quota Guidance & Webhook Status Clarification in Tenant Health Check**:
- Added direct console recharge auto-login guidance (`seal-use auth link --corp <corpId>`) in `seal-use doctor tenant` when tenant quota is low or exhausted.
- Refined webhook integration audit in `doctor tenant` to return `pass` with clarifying notes when no webhook integrations exist, avoiding alarmism for clients who only use direct form approvals.
- **Transparent Approval Run De-duplication**:
- Added `duplicateRuns` and `dedupeNote` to `seal-use approval-runs stats` to explicitly account for and explain the discrepancy between total runs and unique document runs (e.g. retries and push events).
- Emits an objective diagnostic note on stderr when duplicates are present, while keeping the command strictly non-intrusive.
- Reorganized `.agents/rules/` covering CLI protocol standards, test hygiene, staging simulation red lines, and webhook material pack policies.
### Added
- **Semantic Approval Run Web Links (`approval-runs link`)**:
- Replaced un-semantic `approval-runs url` command with standard `approval-runs link` (preserving `url` as backwards-compatible alias).
- Added `--type <seal-result|hose-document>` parameter (defaulting to `seal-result`) to cleanly distinguish between the Seal AI audit page and the Hose/source original form.
- Standardized `--auto-login` (with aliases `--sso` and `--hose-sso`) for generating temporary auto-login OAuth delegation links with safety warnings.
- Structured return payload into Form 1: `{ url, type, mode, sealResultUrl, hoseDocumentUrl, recordId, sourceDocumentSN, ... }`.
- Added `seal-use auth link` (alias `seal-link`) for Seal AI console auto-login delegation links, clearly decoupled from `auth hose-link` for external Hose workbenches.
- Hardened `approval-runs export` against extension confusion: rejects non-`.xlsx` extensions (such as `.csv`) with explicit error guidance.
- Completely purged vague `ssoUrl` and `documentUrl` fields from skill documentation, CLI `--help`, and OpenAPI schemas in favor of `sealResultUrl` and `hoseDocumentUrl`.
import{createRequireasWy0}from"node:module";varUy0=Object.create;var{getPrototypeOf:Yy0,defineProperty:mT,getOwnPropertyNames:zy0}=Object;varQy0=Object.prototype.hasOwnProperty;functionJy0($){returnthis[$]}varIy0,Ky0,J6=($,U,Y)=>{varz=$!=null&&typeof$==="object";if(z){varQ=U?Iy0??=newWeakMap:Ky0??=newWeakMap,J=Q.get($);if(J)returnJ}Y=$!=null?Uy0(Yy0($)):{};letI=U||!$||!$.__esModule?mT(Y,"default",{value:$,enumerable:!0}):Y;for(letKofzy0($))if(!Qy0.call(I,K))mT(I,K,{get:Jy0.bind($,K),enumerable:!0});if(z)Q.set($,I);returnI};varE=($,U)=>()=>(U||$((U={exports:{}}).exports,U),U.exports);varGy0=($)=>$;functionHy0($,U){this[$]=Gy0.bind(null,U)}varx8=($,U)=>{for(varYinU)mT($,Y,{get:U[Y],enumerable:!0,configurable:!0,set:Hy0.bind(U,Y)})};varo=($,U)=>()=>($&&(U=$($=0)),U);varI0=Wy0(import.meta.url);varXy0,cq,Zy0,qy0,Vy0,Ly0,R0=($,U)=>()=>(U||$((U={exports:{}}).exports,U),U.exports),xo=($,U)=>{letY={};for(varzin$)cq(Y,z,{get:$[z],enumerable:!0});if(U)cq(Y,Symbol.toStringTag,{value:"Module"});returnY},Fy0=($,U,Y,z)=>{if(U&&typeofU==="object"||typeofU==="function"){for(varQ=qy0(U),J=0,I=Q.length,K;J<I;J++)if(K=Q[J],!Ly0.call($,K)&&K!==Y)cq($,K,{get:((G)=>U[G]).bind(null,K),enumerable:!(z=Zy0(U,K))||z.enumerable})}return$},nq=($,U,Y)=>(Y=$!=null?Xy0(Vy0($)):{},Fy0(U||!$||!$.__esModule?cq(Y,"default",{value:$,enumerable:!0}):Y,$));varlT=o(()=>{Xy0=Object.create,cq=Object.defineProperty,Zy0=Object.getOwnPropertyDescriptor,qy0=Object.getOwnPropertyNames,Vy0=Object.getPrototypeOf,Ly0=Object.prototype.hasOwnProperty});functionuo($){returntypeof$==="string"&&fo.has($.replace(/#$/,""))}functionbo($,U){if(!("$schema"in$)||typeof$.$schema!=="string")return"2020-12";letY=$.$schema.replace(/#$/,"");if(wy0.has(Y))return"2020-12";if(fo.has(Y))return"2019-09";if(Oy0.has(Y)||My0.has(Y))return"draft-7";throwError(`JSON Schema declares an unsupported dialect ("$schema": "${$.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${U}`)}varwy0,fo,Oy0,My0;varoT=o(()=>{wy0=newSet(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),fo=newSet(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),Oy0=newSet(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),My0=newSet(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"])});functionH0($,U,Y){functionz(K,G){if(!K._zod)Object.defineProperty(K,"_zod",{value:{def:G,constr:I,traits:newSet},enumerable:!1});if(K._zod.traits.has($))return;K._zod.traits.add($),U(K,G);letH=I.prototype,W=Object.keys(H);for(letX=0;X<W.length;X++){letZ=W[X];if(!(ZinK))K[Z]=H[Z].bind(K)}}letQ=Y?.Parent??Object;classJextendsQ{}Object.defineProperty(J,"name",{value:$});functionI(K){varG;letH=Y?.Parent?newJ:this;z(H,K),(G=H._zod).deferred??(G.deferred=[]);for(letWofH._zod.deferred)W();returnH}returnObject.defineProperty(I,"init",{value:z}),Object.defineProperty(I,Symbol.hasInstance,{value:(K)=>{if(Y?.Parent&&KinstanceofY.Parent)return!0;returnK?._zod?.traits?.has($)}}),Object.defineProperty(I,"name",{value:$}),I}functiona4($){if($)Object.assign(AU,$);returnAU}vario,mK,rT,f5,PU,AU;varBU=o(()=>{mK=Object.freeze({status:"aborted"});rT=Symbol("zod_brand");f5=classf5extendsError{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};PU=classPUextendsError{constructor($){super(`Encountered unidirectional transform during encode: ${$}`);this.name="ZodEncodeError"}};(io=globalThis).__zod_globalConfig??(io.__zod_globalConfig={});AU=globalThis.__zod_globalConfig});vary0={};x8(y0,{unwrapMessage:()=>lK,uint8ArrayToHex:()=>py0,uint8ArrayToBase64url:()=>cy0,uint8ArrayToBase64:()=>po,stringifyPrimitive:()=>v0,slugify:()=>tT,shallowClone:()=>$j,safeExtend:()=>ky0,required:()=>uy0,randomString:()=>Ry0,propertyKeyTypes:()=>sK,promiseAllObject:()=>Cy0,primitiveTypes:()=>Uj,prefixIssues:()=>f8,pick:()=>Sy0,partial:()=>fy0,parsedType:()=>S0,optionalKeys:()=>Yj,omit:()=>gy0,objectClone:()=>Ty0,numKeys:()=>_y0,nullish:()=>Q7,normalizeParams:()=>x0,mergeDefs:()=>i9,merge:()=>xy0,jsonStringifyReplacer:()=>uz,joinValues:()=>N0,issue:()=>iz,isPlainObject:()=>I7,isObject:()=>TU,hexToUint8Array:()=>ny0,getSizableOrigin:()=>aK,getParsedType:()=>vy0,getLengthableOrigin:()=>tK,getEnumValues:()=>oK,getElementAtPath:()=>Ey0,floatSafeRemainder:()=>aT,finalizeIssue:()=>A8,extend:()=>yy0,explicitlyAborted:()=>Jj,escapeRegex:()=>N$,esc:()=>pq,defineLazy:()=>T1,createTransparentProxy:()=>hy0,cloneDef:()=>jy0,clone:()=>D8,cleanRegex:()=>rK,cleanEnum:()=>by0,captureStackTrace:()=>dq,cached:()=>bz,base64urlToUint8Array:()=>iy0,base64ToUint8Array:()=>no,assignProp:()=>J7,assertNotEqual:()=>Dy0,assertNever:()=>Py0,assertIs:()=>Ay0,assertEqual:()=>Ny0,assert:()=>By0,allowsEval:()=>eT,aborted:()=>K7,NUMBER_FORMAT_RANGES:()=>zj,Class:()=>moLine truncated
`)}var lo=($,U)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:U,enumerable:!1}),$.message=JSON.stringify(U,uz,2),Object.defineProperty($,"toString",{value:()=>$.message,enumerable:!1})},eK,u8;var Gj=o(()=>{BU();$1();eK=H0("$ZodError",lo),u8=H0("$ZodError",lo,{Parent:Error})});var cz=($)=>(U,Y,z,Q)=>{let J=z?{...z,async:!1}:{async:!1},I=U._zod.run({value:Y,issues:[]},J);if(I instanceof Promise)throw new f5;if(I.issues.length){let K=new(Q?.Err??$)(I.issues.map((G)=>A8(G,J,a4())));throw dq(K,Q?.callee),K}return I.value},mq,nz=($)=>async(U,Y,z,Q)=>{let J=z?{...z,async:!0}:{async:!0},I=U._zod.run({value:Y,issues:[]},J);if(I instanceof Promise)I=await I;if(I.issues.length){let K=new(Q?.Err??$)(I.issues.map((G)=>A8(G,J,a4())));throw dq(K,Q?.callee),K}return I.value},lq,pz=($)=>(U,Y,z)=>{let Q=z?{...z,async:!1}:{async:!1},J=U._zod.run({value:Y,issues:[]},Q);if(J instanceof Promise)throw new f5;return J.issues.length?{success:!1,error:new($??eK)(J.issues.map((I)=>A8(I,Q,a4())))}:{success:!0,data:J.value}},Hj,dz=($)=>async(U,Y,z)=>{let Q=z?{...z,async:!0}:{async:!0},J=U._zod.run({value:Y,issues:[]},Q);if(J instanceof Promise)J=await J;return J.issues.length?{success:!1,error:new $(J.issues.map((I)=>A8(I,Q,a4())))}:{success:!0,data:J.value}},Wj,oq=($)=>(U,Y,z)=>{let Q=z?{...z,direction:"backward"}:{direction:"backward"};return cz($)(U,Y,Q)},my0,rq=($)=>(U,Y,z)=>{return cz($)(U,Y,z)},ly0,sq=($)=>async(U,Y,z)=>{let Q=z?{...z,direction:"backward"}:{direction:"backward"};return nz($)(U,Y,Q)},oy0,aq=($)=>async(U,Y,z)=>{return nz($)(U,Y,z)},ry0,tq=($)=>(U,Y,z)=>{let Q=z?{...z,direction:"backward"}:{direction:"backward"};return pz($)(U,Y,Q)},sy0,eq=($)=>(U,Y,z)=>{return pz($)(U,Y,z)},ay0,$V=($)=>async(U,Y,z)=>{let Q=z?{...z,direction:"backward"}:{direction:"backward"};return dz($)(U,Y,Q)},ty0,UV=($)=>async(U,Y,z)=>{return dz($)(U,Y,z)},ey0;var Xj=o(()=>{BU();Gj();$1();mq=cz(u8),lq=nz(u8),Hj=pz(u8),Wj=dz(u8),my0=oq(u8),ly0=rq(u8),oy0=sq(u8),ry0=aq(u8),sy0=tq(u8),ay0=eq(u8),ty0=$V(u8),ey0=UV(u8)});var U$={};x8(U$,{xid:()=>Lj,uuid7:()=>zk0,uuid6:()=>Yk0,uuid4:()=>Uk0,uuid:()=>jU,uppercase:()=>bj,unicodeEmail:()=>ro,undefined:()=>fj,ulid:()=>Vj,time:()=>vj,string:()=>Sj,sha512_hex:()=>Bk0,sha512_base64url:()=>jk0,sha512_base64:()=>Tk0,sha384_hex:()=>Dk0,sha384_base64url:()=>Pk0,sha384_base64:()=>Ak0,sha256_hex:()=>Ok0,sha256_base64url:()=>Nk0,sha256_base64:()=>Mk0,sha1_hex:()=>Lk0,sha1_base64url:()=>wk0,sha1_base64:()=>Fk0,rfc5322Email:()=>Jk0,number:()=>YG,null:()=>xj,nanoid:()=>wj,md5_hex:()=>Zk0,md5_base64url:()=>Vk0,md5_base64:()=>qk0,mac:()=>Bj,lowercase:()=>uj,ksuid:()=>Fj,ipv6:()=>Pj,ipv4:()=>Aj,integer:()=>yj,idnEmail:()=>Ik0,httpProtocol:()=>Cj,html5Email:()=>Qk0,hostname:()=>Hk0,hex:()=>Xk0,guid:()=>Mj,extendedDuration:()=>$k0,emoji:()=>Dj,email:()=>Nj,e164:()=>Rj,duration:()=>Oj,domain:()=>Wk0,datetime:()=>hj,date:()=>_j,cuid2:()=>qj,cuid:()=>Zj,cidrv6:()=>jj,cidrv4:()=>Tj,browserEmail:()=>Kk0,boolean:()=>kj,bigint:()=>gj,base64url:()=>YV,base64:()=>Ej});function Dj(){return new RegExp(Gk0,"u")}function ao($){return typeof $.precision==="number"?$.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":$.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${$.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function vj($){return new RegExp(`^${ao($)}$`)}function hj($){let U=ao({precision:$.precision}),Y=["Z"];if($.local)Y.push("");if($.offset)Y.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let z=`${U}(?:${Y.join("|")})`;return new RegExp(`^${so}T(?:${z})$`)}function zG($,U){return new RegExp(`^[A-Za-z0-9+/]{${$}}${U}$`)}function QG($){return new RegExp(`^[A-Za-z0-9_-]{${$}}$`)}var Zj,qj,Vj,Lj,Fj,wj,Oj,$k0,Mj,jU=($)=>{if(!$)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;returnnewRegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${$}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},Uk0,Yk0,zk0,Nj,Qk0,Jk0,ro,Ik0,Kk0,Gk0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Aj,Pj,Bj=($)=>{letU=N$($??":");returnnewRegExp(`^(?:[0-9A-F]{2}${U}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${U}){5}[0-9a-f]{2}$`)},Tj,jj,Ej,YV,Hk0,Wk0,Cj,Rj,so="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",_j,Sj=($)=>{letU=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";returnnewRegExp(`^${U}$`)},gj,yj,YG,kj,xj,fj,uj,bj,Xk0,Zk0,qk0,Vk0,Lk0,Fk0,wk0,Ok0,Mk0,Nk0,Dk0,Ak0,Pk0,Bk0,Tk0,jk0;varzV=o(()=>{$1();Zj=/^[cC][0-9a-z]{6,}$/,qj=/^[0-9a-z]+$/,Vj=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Lj=/^[0-9a-vA-V]{20}$/,Fj=/^[A-Za-z0-9]{27}$/,wj=/^[a-zA-Z0-9_-]{21}$/,Oj=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\dLine truncated
`).filter((J)=>J),z=Math.min(...Y.map((J)=>J.length-J.trimStart().length)),Q=Y.map((J)=>J.slice(z)).map((J)=>" ".repeat(this.indent*2)+J);for(let J of Q)this.content.push(J)}compile(){let $=Function,U=this?.args,z=[...(this?.content??[""]).map((Q)=>`${Q}`)];return new $(...U,z.join(`
`))}}var JE;var IE=o(()=>{JE={major:4,minor:4,patch:3}});function CE($){if($==="")return!0;if(/\s/.test($))return!1;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}function Lr($){if(!YV.test($))return!1;let U=$.replace(/[-_]/g,(z)=>z==="-"?"+":"/"),Y=U.padEnd(Math.ceil(U.length/4)*4,"=");return CE(Y)}function Fr($,U=null){try{let Y=$.split(".");if(Y.length!==3)return!1;let[z]=Y;if(!z)return!1;let Q=JSON.parse(atob(z));if("typ"in Q&&Q?.typ!=="JWT")return!1;if(!Q.alg)return!1;if(U&&(!("alg"in Q)||Q.alg!==U))return!1;return!0}catch{return!1}}function Ur($,U,Y){if($.issues.length)U.issues.push(...f8(Y,$.issues));U.value[Y]=$.value}function XV($,U,Y,z,Q,J){let I=Y in z;if($.issues.length){if(Q&&J&&!I)return;U.issues.push(...f8(Y,$.issues))}if(!I&&!Q){if(!$.issues.length)U.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[Y]});return}if($.value===void 0){if(I)U.value[Y]=void 0}else U.value[Y]=$.value}function wr($){let U=Object.keys($.shape);for(let z of U)if(!$.shape?.[z]?._zod?.traits?.has("$ZodType"))throw Error(`Invalidelementatkey"${z}":expectedaZodschema`);let Y=Yj($.shape);return{...$,keys:U,keySet:new Set(U),numKeys:U.length,optionalKeys:new Set(Y)}}function Or($,U,Y,z,Q,J){let I=[],K=Q.keySet,G=Q.catchall._zod,H=G.def.type,W=G.optin==="optional",X=G.optout==="optional";for(let Z in U){if(Z==="__proto__")continue;if(K.has(Z))continue;if(H==="never"){I.push(Z);continue}let q=G.run({value:U[Z],issues:[]},z);if(q instanceof Promise)$.push(q.then((V)=>XV(V,Y,Z,U,W,X)));else XV(q,Y,Z,U,W,X)}if(I.length)Y.issues.push({code:"unrecognized_keys",keys:I,input:U,inst:J});if(!$.length)return Y;return Promise.all($).then(()=>{return Y})}function Yr($,U,Y,z){for(let J of $)if(J.issues.length===0)return U.value=J.value,U;let Q=$.filter((J)=>!K7(J));if(Q.length===1)return U.value=Q[0].value,Q[0];return U.issues.push({code:"invalid_union",input:U.value,inst:Y,errors:$.map((J)=>J.issues.map((I)=>A8(I,z,a4())))}),U}function zr($,U,Y,z){let Q=$.filter((J)=>J.issues.length===0);if(Q.length===1)return U.value=Q[0].value,U;if(Q.length===0)U.issues.push({code:"invalid_union",input:U.value,inst:Y,errors:$.map((J)=>J.issues.map((I)=>A8(I,z,a4())))});else U.issues.push({code:"invalid_union",input:U.value,inst:Y,errors:[],inclusive:!1});return U}function KE($,U){if($===U)return{valid:!0,data:$};if($ instanceof Date&&U instanceof Date&&+$===+U)return{valid:!0,data:$};if(I7($)&&I7(U)){let Y=Object.keys(U),z=Object.keys($).filter((J)=>Y.indexOf(J)!==-1),Q={...$,...U};for(let J of z){let I=KE($[J],U[J]);if(!I.valid)return{valid:!1,mergeErrorPath:[J,...I.mergeErrorPath]};Q[J]=I.data}return{valid:!0,data:Q}}if(Array.isArray($)&&Array.isArray(U)){if($.length!==U.length)return{valid:!1,mergeErrorPath:[]};let Y=[];for(let z=0;z<$.length;z++){let Q=$[z],J=U[z],I=KE(Q,J);if(!I.valid)return{valid:!1,mergeErrorPath:[z,...I.mergeErrorPath]};Y.push(I.data)}return{valid:!0,data:Y}}return{valid:!1,mergeErrorPath:[]}}function Qr($,U,Y){let z=new Map,Q;for(let K of U.issues)if(K.code==="unrecognized_keys"){Q??(Q=K);for(let G of K.keys){if(!z.has(G))z.set(G,{});z.get(G).l=!0}}else $.issues.push(K);for(let K of Y.issues)if(K.code==="unrecognized_keys")for(let G of K.keys){if(!z.has(G))z.set(G,{});z.get(G).r=!0}else $.issues.push(K);let J=[...z].filter(([,K])=>K.l&&K.r).map(([K])=>K);if(J.length&&Q)$.issues.push({...Q,keys:J});if(K7($))return $;let I=KE(U.value,Y.value);if(!I.valid)throw Error(`Unmergableintersection.Errorpath:${JSON.stringify(I.mergeErrorPath)}`);return $.value=I.data,$}function Jr($,U){for(let Y=$.length-1;Y>=0;Y--)if($[Y]._zod[U]!=="optional")return Y+1;return 0}function Ir($,U,Y){if($.issues.length)U.issues.push(...f8(Y,$.issues));U.value[Y]=$.value}function Kr($,U,Y,z,Q){for(let J=0;J<Y.length;J++){let I=$[J],K=J<z.length;if(I.issues.length){if(!K&&J>=Q){U.value.length=J;break}U.issues.push(...f8(J,I.issues))}U.value[J]=I.value}for(let J=U.value.length-1;J>=z.length;J--)if(Y[J]._zod.optout==="optional"&&U.value[J]===void 0)U.value.length=J;else break;return U}function Gr($,U,Y,z,Q,J,I){if($.issues.length)if(sK.has(typeof z))Y.issues.push(...f8(z,$.issues));else Y.issues.push({code:"invalid_key",origin:"map",input:Q,inst:J,issues:$.issues.map((K)=>A8(K,I,a4()))});if(U.issues.length)if(sK.has(typeof z))Y.issues.push(...f8(z,U.issues));else Y.issues.push({origin:"map",code:"invalid_element",input:Q,inst:J,key:z,issues:U.issues.map((K)=>A8(K,I,a4()))});Y.value.set($.value,U.value)}function Hr($,U){if($.issues.length)U.issues.push(...$.issues);U.value.add($.value)}function Wr($,U){if(U===void 0&&($.issues.length||$.fallback))return{issues:[],value:void 0};return $}function Xr($,U){if($.value===void 0)$.value=U.defaultValue;return $}function Zr($,U){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:U});return $}function GV($,U,Y){if($.issues.length)return $.aborted=!0,$;return U._zod.run({value:$.value,issues:$.issues,fa
Line truncated
import{createRequireasLy0}from"node:module";varIy0=Object.create;var{getPrototypeOf:Ky0,defineProperty:oT,getOwnPropertyNames:Gy0}=Object;varHy0=Object.prototype.hasOwnProperty;functionWy0($){returnthis[$]}varXy0,Zy0,J6=($,Y,U)=>{varz=$!=null&&typeof$==="object";if(z){varQ=Y?Xy0??=newWeakMap:Zy0??=newWeakMap,J=Q.get($);if(J)returnJ}U=$!=null?Iy0(Ky0($)):{};letI=Y||!$||!$.__esModule?oT(U,"default",{value:$,enumerable:!0}):U;for(letKofGy0($))if(!Hy0.call(I,K))oT(I,K,{get:Wy0.bind($,K),enumerable:!0});if(z)Q.set($,I);returnI};varE=($,Y)=>()=>(Y||$((Y={exports:{}}).exports,Y),Y.exports);varqy0=($)=>$;functionVy0($,Y){this[$]=qy0.bind(null,Y)}varx8=($,Y)=>{for(varUinY)oT($,U,{get:Y[U],enumerable:!0,configurable:!0,set:Vy0.bind(Y,U)})};varm=($,Y)=>()=>($&&(Y=$($=0)),Y);varI0=Ly0(import.meta.url);varFy0,cq,wy0,My0,Oy0,Ny0,R0=($,Y)=>()=>(Y||$((Y={exports:{}}).exports,Y),Y.exports),uo=($,Y)=>{letU={};for(varzin$)cq(U,z,{get:$[z],enumerable:!0});if(Y)cq(U,Symbol.toStringTag,{value:"Module"});returnU},Dy0=($,Y,U,z)=>{if(Y&&typeofY==="object"||typeofY==="function"){for(varQ=My0(Y),J=0,I=Q.length,K;J<I;J++)if(K=Q[J],!Ny0.call($,K)&&K!==U)cq($,K,{get:((G)=>Y[G]).bind(null,K),enumerable:!(z=wy0(Y,K))||z.enumerable})}return$},nq=($,Y,U)=>(U=$!=null?Fy0(Oy0($)):{},Dy0(Y||!$||!$.__esModule?cq(U,"default",{value:$,enumerable:!0}):U,$));varrT=m(()=>{Fy0=Object.create,cq=Object.defineProperty,wy0=Object.getOwnPropertyDescriptor,My0=Object.getOwnPropertyNames,Oy0=Object.getPrototypeOf,Ny0=Object.prototype.hasOwnProperty});functionio($){returntypeof$==="string"&&bo.has($.replace(/#$/,""))}functionco($,Y){if(!("$schema"in$)||typeof$.$schema!=="string")return"2020-12";letU=$.$schema.replace(/#$/,"");if(Ay0.has(U))return"2020-12";if(bo.has(U))return"2019-09";if(By0.has(U)||Py0.has(U))return"draft-7";throwError(`JSON Schema declares an unsupported dialect ("$schema": "${$.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${Y}`)}varAy0,bo,By0,Py0;varsT=m(()=>{Ay0=newSet(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),bo=newSet(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),By0=newSet(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Py0=newSet(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"])});functionH0($,Y,U){functionz(K,G){if(!K._zod)Object.defineProperty(K,"_zod",{value:{def:G,constr:I,traits:newSet},enumerable:!1});if(K._zod.traits.has($))return;K._zod.traits.add($),Y(K,G);letH=I.prototype,W=Object.keys(H);for(letX=0;X<W.length;X++){letZ=W[X];if(!(ZinK))K[Z]=H[Z].bind(K)}}letQ=U?.Parent??Object;classJextendsQ{}Object.defineProperty(J,"name",{value:$});functionI(K){varG;letH=U?.Parent?newJ:this;z(H,K),(G=H._zod).deferred??(G.deferred=[]);for(letWofH._zod.deferred)W();returnH}returnObject.defineProperty(I,"init",{value:z}),Object.defineProperty(I,Symbol.hasInstance,{value:(K)=>{if(U?.Parent&&KinstanceofU.Parent)return!0;returnK?._zod?.traits?.has($)}}),Object.defineProperty(I,"name",{value:$}),I}functiona4($){if($)Object.assign(AY,$);returnAY}varno,oK,aT,u5,BY,AY;varPY=m(()=>{oK=Object.freeze({status:"aborted"});aT=Symbol("zod_brand");u5=classu5extendsError{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};BY=classBYextendsError{constructor($){super(`Encountered unidirectional transform during encode: ${$}`);this.name="ZodEncodeError"}};(no=globalThis).__zod_globalConfig??(no.__zod_globalConfig={});AY=globalThis.__zod_globalConfig});vary0={};x8(y0,{unwrapMessage:()=>rK,uint8ArrayToHex:()=>ry0,uint8ArrayToBase64url:()=>ly0,uint8ArrayToBase64:()=>lo,stringifyPrimitive:()=>v0,slugify:()=>$j,shallowClone:()=>Uj,safeExtend:()=>iy0,required:()=>py0,randomString:()=>gy0,propertyKeyTypes:()=>tK,promiseAllObject:()=>Sy0,primitiveTypes:()=>zj,prefixIssues:()=>f8,pick:()=>fy0,partial:()=>ny0,parsedType:()=>S0,optionalKeys:()=>Qj,omit:()=>uy0,objectClone:()=>_y0,numKeys:()=>yy0,nullish:()=>I7,normalizeParams:()=>x0,mergeDefs:()=>c9,merge:()=>cy0,jsonStringifyReplacer:()=>iz,joinValues:()=>O0,issue:()=>nz,isPlainObject:()=>G7,isObject:()=>TY,hexToUint8Array:()=>oy0,getSizableOrigin:()=>eK,getParsedType:()=>ky0,getLengthableOrigin:()=>$G,getEnumValues:()=>sK,getElementAtPath:()=>hy0,floatSafeRemainder:()=>eT,finalizeIssue:()=>A8,extend:()=>by0,explicitlyAborted:()=>Kj,escapeRegex:()=>N$,esc:()=>pq,defineLazy:()=>E1,createTransparentProxy:()=>xy0,cloneDef:()=>vy0,clone:()=>D8,cleanRegex:()=>aK,cleanEnum:()=>dy0,captureStackTrace:()=>dq,cached:()=>cz,base64urlToUint8Array:()=>my0,base64ToUint8Array:()=>mo,assignProp:()=>K7,assertNotEqual:()=>jy0,assertNever:()=>Cy0,assertIs:()=>Ey0,assertEqual:()=>Ty0,assert:()=>Ry0,allowsEval:()=>Yj,aborted:()=>H7,NUMBER_FORMAT_RANGES:()=>Jj,Class:()=>ooLine truncated
`)}var ro=($,Y)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:Y,enumerable:!1}),$.message=JSON.stringify(Y,iz,2),Object.defineProperty($,"toString",{value:()=>$.message,enumerable:!1})},YG,u8;var Wj=m(()=>{PY();$1();YG=H0("$ZodError",ro),u8=H0("$ZodError",ro,{Parent:Error})});var pz=($)=>(Y,U,z,Q)=>{let J=z?{...z,async:!1}:{async:!1},I=Y._zod.run({value:U,issues:[]},J);if(I instanceof Promise)throw new u5;if(I.issues.length){let K=new(Q?.Err??$)(I.issues.map((G)=>A8(G,J,a4())));throw dq(K,Q?.callee),K}return I.value},mq,dz=($)=>async(Y,U,z,Q)=>{let J=z?{...z,async:!0}:{async:!0},I=Y._zod.run({value:U,issues:[]},J);if(I instanceof Promise)I=await I;if(I.issues.length){let K=new(Q?.Err??$)(I.issues.map((G)=>A8(G,J,a4())));throw dq(K,Q?.callee),K}return I.value},lq,mz=($)=>(Y,U,z)=>{let Q=z?{...z,async:!1}:{async:!1},J=Y._zod.run({value:U,issues:[]},Q);if(J instanceof Promise)throw new u5;return J.issues.length?{success:!1,error:new($??YG)(J.issues.map((I)=>A8(I,Q,a4())))}:{success:!0,data:J.value}},Xj,lz=($)=>async(Y,U,z)=>{let Q=z?{...z,async:!0}:{async:!0},J=Y._zod.run({value:U,issues:[]},Q);if(J instanceof Promise)J=await J;return J.issues.length?{success:!1,error:new $(J.issues.map((I)=>A8(I,Q,a4())))}:{success:!0,data:J.value}},Zj,oq=($)=>(Y,U,z)=>{let Q=z?{...z,direction:"backward"}:{direction:"backward"};return pz($)(Y,U,Q)},ay0,rq=($)=>(Y,U,z)=>{return pz($)(Y,U,z)},ty0,sq=($)=>async(Y,U,z)=>{let Q=z?{...z,direction:"backward"}:{direction:"backward"};return dz($)(Y,U,Q)},ey0,aq=($)=>async(Y,U,z)=>{return dz($)(Y,U,z)},$k0,tq=($)=>(Y,U,z)=>{let Q=z?{...z,direction:"backward"}:{direction:"backward"};return mz($)(Y,U,Q)},Yk0,eq=($)=>(Y,U,z)=>{return mz($)(Y,U,z)},Uk0,$V=($)=>async(Y,U,z)=>{let Q=z?{...z,direction:"backward"}:{direction:"backward"};return lz($)(Y,U,Q)},zk0,YV=($)=>async(Y,U,z)=>{return lz($)(Y,U,z)},Qk0;var qj=m(()=>{PY();Wj();$1();mq=pz(u8),lq=dz(u8),Xj=mz(u8),Zj=lz(u8),ay0=oq(u8),ty0=rq(u8),ey0=sq(u8),$k0=aq(u8),Yk0=tq(u8),Uk0=eq(u8),zk0=$V(u8),Qk0=YV(u8)});var Y$={};x8(Y$,{xid:()=>wj,uuid7:()=>Gk0,uuid6:()=>Kk0,uuid4:()=>Ik0,uuid:()=>jY,uppercase:()=>cj,unicodeEmail:()=>ao,undefined:()=>bj,ulid:()=>Fj,time:()=>Sj,string:()=>yj,sha512_hex:()=>Rk0,sha512_base64url:()=>vk0,sha512_base64:()=>_k0,sha384_hex:()=>jk0,sha384_base64url:()=>Ck0,sha384_base64:()=>Ek0,sha256_hex:()=>Bk0,sha256_base64url:()=>Tk0,sha256_base64:()=>Pk0,sha1_hex:()=>Nk0,sha1_base64url:()=>Ak0,sha1_base64:()=>Dk0,rfc5322Email:()=>Wk0,number:()=>QG,null:()=>uj,nanoid:()=>Oj,md5_hex:()=>wk0,md5_base64url:()=>Ok0,md5_base64:()=>Mk0,mac:()=>jj,lowercase:()=>ij,ksuid:()=>Mj,ipv6:()=>Tj,ipv4:()=>Pj,integer:()=>xj,idnEmail:()=>Xk0,httpProtocol:()=>_j,html5Email:()=>Hk0,hostname:()=>Vk0,hex:()=>Fk0,guid:()=>Dj,extendedDuration:()=>Jk0,emoji:()=>Bj,email:()=>Aj,e164:()=>vj,duration:()=>Nj,domain:()=>Lk0,datetime:()=>gj,date:()=>hj,cuid2:()=>Lj,cuid:()=>Vj,cidrv6:()=>Cj,cidrv4:()=>Ej,browserEmail:()=>Zk0,boolean:()=>fj,bigint:()=>kj,base64url:()=>UV,base64:()=>Rj});function Bj(){return new RegExp(qk0,"u")}function eo($){return typeof $.precision==="number"?$.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":$.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${$.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Sj($){return new RegExp(`^${eo($)}$`)}function gj($){let Y=eo({precision:$.precision}),U=["Z"];if($.local)U.push("");if($.offset)U.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let z=`${Y}(?:${U.join("|")})`;return new RegExp(`^${to}T(?:${z})$`)}function JG($,Y){return new RegExp(`^[A-Za-z0-9+/]{${$}}${Y}$`)}function IG($){return new RegExp(`^[A-Za-z0-9_-]{${$}}$`)}var Vj,Lj,Fj,wj,Mj,Oj,Nj,Jk0,Dj,jY=($)=>{if(!$)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;returnnewRegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${$}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},Ik0,Kk0,Gk0,Aj,Hk0,Wk0,ao,Xk0,Zk0,qk0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Pj,Tj,jj=($)=>{letY=N$($??":");returnnewRegExp(`^(?:[0-9A-F]{2}${Y}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${Y}){5}[0-9a-f]{2}$`)},Ej,Cj,Rj,UV,Vk0,Lk0,_j,vj,to="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",hj,yj=($)=>{letY=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";returnnewRegExp(`^${Y}$`)},kj,xj,QG,fj,uj,bj,ij,cj,Fk0,wk0,Mk0,Ok0,Nk0,Dk0,Ak0,Bk0,Pk0,Tk0,jk0,Ek0,Ck0,Rk0,_k0,vk0;varzV=m(()=>{$1();Vj=/^[cC][0-9a-z]{6,}$/,Lj=/^[0-9a-z]+$/,Fj=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,wj=/^[0-9a-vA-V]{20}$/,Mj=/^[A-Za-z0-9]{27}$/,Oj=/^[a-zA-Z0-9_-]{21}$/,Nj=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\dLine truncated
`).filter((J)=>J),z=Math.min(...U.map((J)=>J.length-J.trimStart().length)),Q=U.map((J)=>J.slice(z)).map((J)=>" ".repeat(this.indent*2)+J);for(let J of Q)this.content.push(J)}compile(){let $=Function,Y=this?.args,z=[...(this?.content??[""]).map((Q)=>`${Q}`)];return new $(...Y,z.join(`
`))}}var KE;var GE=m(()=>{KE={major:4,minor:4,patch:3}});function _E($){if($==="")return!0;if(/\s/.test($))return!1;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}function wr($){if(!UV.test($))return!1;let Y=$.replace(/[-_]/g,(z)=>z==="-"?"+":"/"),U=Y.padEnd(Math.ceil(Y.length/4)*4,"=");return _E(U)}function Mr($,Y=null){try{let U=$.split(".");if(U.length!==3)return!1;let[z]=U;if(!z)return!1;let Q=JSON.parse(atob(z));if("typ"in Q&&Q?.typ!=="JWT")return!1;if(!Q.alg)return!1;if(Y&&(!("alg"in Q)||Q.alg!==Y))return!1;return!0}catch{return!1}}function zr($,Y,U){if($.issues.length)Y.issues.push(...f8(U,$.issues));Y.value[U]=$.value}function XV($,Y,U,z,Q,J){let I=U in z;if($.issues.length){if(Q&&J&&!I)return;Y.issues.push(...f8(U,$.issues))}if(!I&&!Q){if(!$.issues.length)Y.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[U]});return}if($.value===void 0){if(I)Y.value[U]=void 0}else Y.value[U]=$.value}function Or($){let Y=Object.keys($.shape);for(let z of Y)if(!$.shape?.[z]?._zod?.traits?.has("$ZodType"))throw Error(`Invalidelementatkey"${z}":expectedaZodschema`);let U=Qj($.shape);return{...$,keys:Y,keySet:new Set(Y),numKeys:Y.length,optionalKeys:new Set(U)}}function Nr($,Y,U,z,Q,J){let I=[],K=Q.keySet,G=Q.catchall._zod,H=G.def.type,W=G.optin==="optional",X=G.optout==="optional";for(let Z in Y){if(Z==="__proto__")continue;if(K.has(Z))continue;if(H==="never"){I.push(Z);continue}let q=G.run({value:Y[Z],issues:[]},z);if(q instanceof Promise)$.push(q.then((V)=>XV(V,U,Z,Y,W,X)));else XV(q,U,Z,Y,W,X)}if(I.length)U.issues.push({code:"unrecognized_keys",keys:I,input:Y,inst:J});if(!$.length)return U;return Promise.all($).then(()=>{return U})}function Qr($,Y,U,z){for(let J of $)if(J.issues.length===0)return Y.value=J.value,Y;let Q=$.filter((J)=>!H7(J));if(Q.length===1)return Y.value=Q[0].value,Q[0];return Y.issues.push({code:"invalid_union",input:Y.value,inst:U,errors:$.map((J)=>J.issues.map((I)=>A8(I,z,a4())))}),Y}function Jr($,Y,U,z){let Q=$.filter((J)=>J.issues.length===0);if(Q.length===1)return Y.value=Q[0].value,Y;if(Q.length===0)Y.issues.push({code:"invalid_union",input:Y.value,inst:U,errors:$.map((J)=>J.issues.map((I)=>A8(I,z,a4())))});else Y.issues.push({code:"invalid_union",input:Y.value,inst:U,errors:[],inclusive:!1});return Y}function HE($,Y){if($===Y)return{valid:!0,data:$};if($ instanceof Date&&Y instanceof Date&&+$===+Y)return{valid:!0,data:$};if(G7($)&&G7(Y)){let U=Object.keys(Y),z=Object.keys($).filter((J)=>U.indexOf(J)!==-1),Q={...$,...Y};for(let J of z){let I=HE($[J],Y[J]);if(!I.valid)return{valid:!1,mergeErrorPath:[J,...I.mergeErrorPath]};Q[J]=I.data}return{valid:!0,data:Q}}if(Array.isArray($)&&Array.isArray(Y)){if($.length!==Y.length)return{valid:!1,mergeErrorPath:[]};let U=[];for(let z=0;z<$.length;z++){let Q=$[z],J=Y[z],I=HE(Q,J);if(!I.valid)return{valid:!1,mergeErrorPath:[z,...I.mergeErrorPath]};U.push(I.data)}return{valid:!0,data:U}}return{valid:!1,mergeErrorPath:[]}}function Ir($,Y,U){let z=new Map,Q;for(let K of Y.issues)if(K.code==="unrecognized_keys"){Q??(Q=K);for(let G of K.keys){if(!z.has(G))z.set(G,{});z.get(G).l=!0}}else $.issues.push(K);for(let K of U.issues)if(K.code==="unrecognized_keys")for(let G of K.keys){if(!z.has(G))z.set(G,{});z.get(G).r=!0}else $.issues.push(K);let J=[...z].filter(([,K])=>K.l&&K.r).map(([K])=>K);if(J.length&&Q)$.issues.push({...Q,keys:J});if(H7($))return $;let I=HE(Y.value,U.value);if(!I.valid)throw Error(`Unmergableintersection.Errorpath:${JSON.stringify(I.mergeErrorPath)}`);return $.value=I.data,$}function Kr($,Y){for(let U=$.length-1;U>=0;U--)if($[U]._zod[Y]!=="optional")return U+1;return 0}function Gr($,Y,U){if($.issues.length)Y.issues.push(...f8(U,$.issues));Y.value[U]=$.value}function Hr($,Y,U,z,Q){for(let J=0;J<U.length;J++){let I=$[J],K=J<z.length;if(I.issues.length){if(!K&&J>=Q){Y.value.length=J;break}Y.issues.push(...f8(J,I.issues))}Y.value[J]=I.value}for(let J=Y.value.length-1;J>=z.length;J--)if(U[J]._zod.optout==="optional"&&Y.value[J]===void 0)Y.value.length=J;else break;return Y}function Wr($,Y,U,z,Q,J,I){if($.issues.length)if(tK.has(typeof z))U.issues.push(...f8(z,$.issues));else U.issues.push({code:"invalid_key",origin:"map",input:Q,inst:J,issues:$.issues.map((K)=>A8(K,I,a4()))});if(Y.issues.length)if(tK.has(typeof z))U.issues.push(...f8(z,Y.issues));else U.issues.push({origin:"map",code:"invalid_element",input:Q,inst:J,key:z,issues:Y.issues.map((K)=>A8(K,I,a4()))});U.value.set($.value,Y.value)}function Xr($,Y){if($.issues.length)Y.issues.push(...$.issues);Y.value.add($.value)}function Zr($,Y){if(Y===void 0&&($.issues.length||$.fallback))return{issues:[],value:void 0};return $}function qr($,Y){if($.value===void 0)$.value=Y.defaultValue;return $}function Vr($,Y){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:Y});return $}function GV($,Y,U){if($.issues.length)return $.aborted=!0,$;return Y._zod.run({value:$.value,issues:$.issues,fa
Line truncated
`)}q.write("payload.value = newResult;"),q.write("return payload;");let M=q.compile();return(N,D)=>M(Z,N,D)},J,I=TU,K=!AU.jitless,H=K&&eT.value,W=U.catchall,X;$._zod.parse=(Z,q)=>{X??(X=z.value);let V=Z.value;if(!I(V))return Z.issues.push({expected:"object",code:"invalid_type",input:V,inst:$}),Z;if(K&&H&&q?.async===!1&&q.jitless!==!0){if(!J)J=Q(U.shape);if(Z=J(Z,q),!W)return Z;return Or([],V,Z,q,X,$)}return Y(Z,q)}});IG=H0("$ZodUnion",($,U)=>{q1.init($,U),T1($._zod,"optin",()=>U.options.some((z)=>z._zod.optin==="optional")?"optional":void 0),T1($._zod,"optout",()=>U.options.some((z)=>z._zod.optout==="optional")?"optional":void 0),T1($._zod,"values",()=>{if(U.options.every((z)=>z._zod.values))return new Set(U.options.flatMap((z)=>Array.from(z._zod.values)));return}),T1($._zod,"pattern",()=>{if(U.options.every((z)=>z._zod.pattern)){let z=U.options.map((Q)=>Q._zod.pattern);return new RegExp(`^(${z.map((Q)=>rK(Q.source)).join("|")})$`)}return});let Y=U.options.length===1?U.options[0]._zod.run:null;$._zod.parse=(z,Q)=>{if(Y)return Y(z,Q);let J=!1,I=[];for(let K of U.options){let G=K._zod.run({value:z.value,issues:[]},Q);if(G instanceof Promise)I.push(G),J=!0;else{if(G.issues.length===0)return G;I.push(G)}}if(!J)return Yr(I,z,$,Q);return Promise.all(I).then((K)=>{return Yr(K,z,$,Q)})}});mE=H0("$ZodXor",($,U)=>{IG.init($,U),U.inclusive=!1;let Y=U.options.length===1?U.options[0]._zod.run:null;$._zod.parse=(z,Q)=>{if(Y)return Y(z,Q);let J=!1,I=[];for(let K of U.options){let G=K._zod.run({value:z.value,issues:[]},Q);if(G instanceof Promise)I.push(G),J=!0;else I.push(G)}if(!J)return zr(I,z,$,Q);return Promise.all(I).then((K)=>{return zr(K,z,$,Q)})}}),lE=H0("$ZodDiscriminatedUnion",($,U)=>{U.inclusive=!1,IG.init($,U);let Y=$._zod.parse;T1($._zod,"propValues",()=>{let Q={};for(let J of U.options){let I=J._zod.propValues;if(!I||Object.keys(I).length===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${U.options.indexOf(J)}"`);for(let[K,G]of Object.entries(I)){if(!Q[K])Q[K]=new Set;for(let H of G)Q[K].add(H)}}return Q});let z=bz(()=>{let Q=U.options,J=new Map;for(let I of Q){let K=I._zod.propValues?.[U.discriminator];if(!K||K.size===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${U.options.indexOf(I)}"`);for(let G of K){if(J.has(G))throw Error(`Duplicatediscriminatorvalue"${String(G)}"`);J.set(G,I)}}return J});$._zod.parse=(Q,J)=>{let I=Q.value;if(!TU(I))return Q.issues.push({code:"invalid_type",expected:"object",input:I,inst:$}),Q;let K=z.value.get(I?.[U.discriminator]);if(K)return K._zod.run(Q,J);if(U.unionFallback||J.direction==="backward")return Y(Q,J);return Q.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:U.discriminator,options:Array.from(z.value.keys()),input:I,path:[U.discriminator],inst:$}),Q}}),oE=H0("$ZodIntersection",($,U)=>{q1.init($,U),$._zod.parse=(Y,z)=>{let Q=Y.value,J=U.left._zod.run({value:Q,issues:[]},z),I=U.right._zod.run({value:Q,issues:[]},z);if(J instanceof Promise||I instanceof Promise)return Promise.all([J,I]).then(([G,H])=>{return Qr(Y,G,H)});return Qr(Y,J,I)}});VV=H0("$ZodTuple",($,U)=>{q1.init($,U);let Y=U.items;$._zod.parse=(z,Q)=>{let J=z.value;if(!Array.isArray(J))return z.issues.push({input:J,inst:$,expected:"tuple",code:"invalid_type"}),z;z.value=[];let I=[],K=Jr(Y,"optin"),G=Jr(Y,"optout");if(!U.rest){if(J.length<K)return z.issues.push({code:"too_small",minimum:K,inclusive:!0,input:J,inst:$,origin:"array"}),z;if(J.length>Y.length)z.issues.push({code:"too_big",maximum:Y.length,inclusive:!0,input:J,inst:$,origin:"array"})}let H=Array(Y.length);for(let W=0;W<Y.length;W++){let X=Y[W]._zod.run({value:J[W],issues:[]},Q);if(X instanceof Promise)I.push(X.then((Z)=>{H[W]=Z}));else H[W]=X}if(U.rest){let W=Y.length-1,X=J.slice(Y.length);for(let Z of X){W++;let q=U.rest._zod.run({value:Z,issues:[]},Q);if(q instanceof Promise)I.push(q.then((V)=>Ir(V,z,W)));else Ir(q,z,W)}}if(I.length)return Promise.all(I).then(()=>Kr(H,z,Y,J,G));return Kr(H,z,Y,J,G)}});rE=H0("$ZodRecord",($,U)=>{q1.init($,U),$._zod.parse=(Y,z)=>{let Q=Y.value;if(!I7(Q))return Y.issues.push({expected:"record",code:"invalid_type",input:Q,inst:$}),Y;let J=[],I=U.keyType._zod.values;if(I){Y.value={};let K=new Set;for(let H of I)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){K.add(typeof H==="number"?H.toString():H);let W=U.keyType._zod.run({value:H,issues:[]},z);if(W instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(W.issues.length){Y.issues.push({code:"invalid_key",origin:"record",issues:W.issues.map((q)=>A8(q,z,a4())),input:H,path:[H],inst:$});continue}let X=W.value,Z=U.valueType._zod.run({value:Q[H],issues:[]},z);if(Z instanceof Promise)J.push(Z.then((q)=>{if(q.issues.length)Y.issues.push(...f8(H,q.issues));Y.value[X]=q.value}));else{if(Z.issues.length)Y.issues.push(...f8(H,Z.issues));Y.value[X]=Z.value}}let G;for(let H in Q)if(!K.has(H))G=G??[],G.push(H);if(G&&G.length>0)Y.issues.push({code:"unrec
Line truncated
`)}q.write("payload.value = newResult;"),q.write("return payload;");let N=q.compile();return(O,D)=>N(Z,O,D)},J,I=TY,K=!AY.jitless,H=K&&Yj.value,W=Y.catchall,X;$._zod.parse=(Z,q)=>{X??(X=z.value);let V=Z.value;if(!I(V))return Z.issues.push({expected:"object",code:"invalid_type",input:V,inst:$}),Z;if(K&&H&&q?.async===!1&&q.jitless!==!0){if(!J)J=Q(Y.shape);if(Z=J(Z,q),!W)return Z;return Nr([],V,Z,q,X,$)}return U(Z,q)}});GG=H0("$ZodUnion",($,Y)=>{q1.init($,Y),E1($._zod,"optin",()=>Y.options.some((z)=>z._zod.optin==="optional")?"optional":void 0),E1($._zod,"optout",()=>Y.options.some((z)=>z._zod.optout==="optional")?"optional":void 0),E1($._zod,"values",()=>{if(Y.options.every((z)=>z._zod.values))return new Set(Y.options.flatMap((z)=>Array.from(z._zod.values)));return}),E1($._zod,"pattern",()=>{if(Y.options.every((z)=>z._zod.pattern)){let z=Y.options.map((Q)=>Q._zod.pattern);return new RegExp(`^(${z.map((Q)=>aK(Q.source)).join("|")})$`)}return});let U=Y.options.length===1?Y.options[0]._zod.run:null;$._zod.parse=(z,Q)=>{if(U)return U(z,Q);let J=!1,I=[];for(let K of Y.options){let G=K._zod.run({value:z.value,issues:[]},Q);if(G instanceof Promise)I.push(G),J=!0;else{if(G.issues.length===0)return G;I.push(G)}}if(!J)return Qr(I,z,$,Q);return Promise.all(I).then((K)=>{return Qr(K,z,$,Q)})}});oE=H0("$ZodXor",($,Y)=>{GG.init($,Y),Y.inclusive=!1;let U=Y.options.length===1?Y.options[0]._zod.run:null;$._zod.parse=(z,Q)=>{if(U)return U(z,Q);let J=!1,I=[];for(let K of Y.options){let G=K._zod.run({value:z.value,issues:[]},Q);if(G instanceof Promise)I.push(G),J=!0;else I.push(G)}if(!J)return Jr(I,z,$,Q);return Promise.all(I).then((K)=>{return Jr(K,z,$,Q)})}}),rE=H0("$ZodDiscriminatedUnion",($,Y)=>{Y.inclusive=!1,GG.init($,Y);let U=$._zod.parse;E1($._zod,"propValues",()=>{let Q={};for(let J of Y.options){let I=J._zod.propValues;if(!I||Object.keys(I).length===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${Y.options.indexOf(J)}"`);for(let[K,G]of Object.entries(I)){if(!Q[K])Q[K]=new Set;for(let H of G)Q[K].add(H)}}return Q});let z=cz(()=>{let Q=Y.options,J=new Map;for(let I of Q){let K=I._zod.propValues?.[Y.discriminator];if(!K||K.size===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${Y.options.indexOf(I)}"`);for(let G of K){if(J.has(G))throw Error(`Duplicatediscriminatorvalue"${String(G)}"`);J.set(G,I)}}return J});$._zod.parse=(Q,J)=>{let I=Q.value;if(!TY(I))return Q.issues.push({code:"invalid_type",expected:"object",input:I,inst:$}),Q;let K=z.value.get(I?.[Y.discriminator]);if(K)return K._zod.run(Q,J);if(Y.unionFallback||J.direction==="backward")return U(Q,J);return Q.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:Y.discriminator,options:Array.from(z.value.keys()),input:I,path:[Y.discriminator],inst:$}),Q}}),sE=H0("$ZodIntersection",($,Y)=>{q1.init($,Y),$._zod.parse=(U,z)=>{let Q=U.value,J=Y.left._zod.run({value:Q,issues:[]},z),I=Y.right._zod.run({value:Q,issues:[]},z);if(J instanceof Promise||I instanceof Promise)return Promise.all([J,I]).then(([G,H])=>{return Ir(U,G,H)});return Ir(U,J,I)}});VV=H0("$ZodTuple",($,Y)=>{q1.init($,Y);let U=Y.items;$._zod.parse=(z,Q)=>{let J=z.value;if(!Array.isArray(J))return z.issues.push({input:J,inst:$,expected:"tuple",code:"invalid_type"}),z;z.value=[];let I=[],K=Kr(U,"optin"),G=Kr(U,"optout");if(!Y.rest){if(J.length<K)return z.issues.push({code:"too_small",minimum:K,inclusive:!0,input:J,inst:$,origin:"array"}),z;if(J.length>U.length)z.issues.push({code:"too_big",maximum:U.length,inclusive:!0,input:J,inst:$,origin:"array"})}let H=Array(U.length);for(let W=0;W<U.length;W++){let X=U[W]._zod.run({value:J[W],issues:[]},Q);if(X instanceof Promise)I.push(X.then((Z)=>{H[W]=Z}));else H[W]=X}if(Y.rest){let W=U.length-1,X=J.slice(U.length);for(let Z of X){W++;let q=Y.rest._zod.run({value:Z,issues:[]},Q);if(q instanceof Promise)I.push(q.then((V)=>Gr(V,z,W)));else Gr(q,z,W)}}if(I.length)return Promise.all(I).then(()=>Hr(H,z,U,J,G));return Hr(H,z,U,J,G)}});aE=H0("$ZodRecord",($,Y)=>{q1.init($,Y),$._zod.parse=(U,z)=>{let Q=U.value;if(!G7(Q))return U.issues.push({expected:"record",code:"invalid_type",input:Q,inst:$}),U;let J=[],I=Y.keyType._zod.values;if(I){U.value={};let K=new Set;for(let H of I)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){K.add(typeof H==="number"?H.toString():H);let W=Y.keyType._zod.run({value:H,issues:[]},z);if(W instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(W.issues.length){U.issues.push({code:"invalid_key",origin:"record",issues:W.issues.map((q)=>A8(q,z,a4())),input:H,path:[H],inst:$});continue}let X=W.value,Z=Y.valueType._zod.run({value:Q[H],issues:[]},z);if(Z instanceof Promise)J.push(Z.then((q)=>{if(q.issues.length)U.issues.push(...f8(H,q.issues));U.value[X]=q.value}));else{if(Z.issues.length)U.issues.push(...f8(H,Z.issues));U.value[X]=Z.value}}let G;for(let H in Q)if(!K.has(H))G=G??[],G.push(H);if(G&&G.length>0)U.issues.push({code:"unrec
Line truncated
Setthe\`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(letIof$.seen.entries()){letK=I[1];if(U===I[0]){J(I);continue}if($.external){letH=$.external.registry.get(I[0])?.id;if(U!==I[0]&&H){J(I);continue}}if($.metadataRegistry.get(I[0])?.id){J(I);continue}if(K.cycle){J(I);continue}if(K.count>1){if($.reused==="ref"){J(I);continue}}}}functionZ7($,U){letY=$.seen.get(U);if(!Y)throwError("Unprocessed schema. This is a bug in Zod.");letz=(K)=>{letG=$.seen.get(K);if(G.ref===null)return;letH=G.def??G.schema,W={...H},X=G.ref;if(G.ref=null,X){z(X);letq=$.seen.get(X),V=q.schema;if(V.$ref&&($.target==="draft-07"||$.target==="draft-04"||$.target==="openapi-3.0"))H.allOf=H.allOf??[],H.allOf.push(V);elseObject.assign(H,V);if(Object.assign(H,W),K._zod.parent===X)for(letOinH){if(O==="$ref"||O==="allOf")continue;if(!(OinW))deleteH[O]}if(V.$ref&&q.def)for(letOinH){if(O==="$ref"||O==="allOf")continue;if(Oinq.def&&JSON.stringify(H[O])===JSON.stringify(q.def[O]))deleteH[O]}}letZ=K._zod.parent;if(Z&&Z!==X){z(Z);letq=$.seen.get(Z);if(q?.schema.$ref){if(H.$ref=q.schema.$ref,q.def)for(letVinH){if(V==="$ref"||V==="allOf")continue;if(Vinq.def&&JSON.stringify(H[V])===JSON.stringify(q.def[V]))deleteH[V]}}}$.override({zodSchema:K,jsonSchema:H,path:G.path??[]})};for(letKof[...$.seen.entries()].reverse())z(K[0]);letQ={};if($.target==="draft-2020-12")Q.$schema="https://json-schema.org/draft/2020-12/schema";elseif($.target==="draft-07")Q.$schema="http://json-schema.org/draft-07/schema#";elseif($.target==="draft-04")Q.$schema="http://json-schema.org/draft-04/schema#";elseif($.target==="openapi-3.0");if($.external?.uri){letK=$.external.registry.get(U)?.id;if(!K)throwError("Schema is missing an `id` property");Q.$id=$.external.uri(K)}Object.assign(Q,Y.def??Y.schema);letJ=$.metadataRegistry.get(U)?.id;if(J!==void0&&Q.id===J)deleteQ.id;letI=$.external?.defs??{};for(letKof$.seen.entries()){letG=K[1];if(G.def&&G.defId){if(G.def.id===G.defId)deleteG.def.id;I[G.defId]=G.def}}if($.external);elseif(Object.keys(I).length>0)if($.target==="draft-2020-12")Q.$defs=I;elseQ.definitions=I;try{letK=JSON.parse(JSON.stringify(Q));returnObject.defineProperty(K,"~standard",{value:{...U["~standard"],jsonSchema:{input:KQ(U,"input",$.processors),output:KQ(U,"output",$.processors)}},enumerable:!1,writable:!1}),K}catch(K){throwError("Error converting schema to JSON.")}}functionB8($,U){letY=U??{seen:newSet};if(Y.seen.has($))return!1;Y.seen.add($);letz=$._zod.def;if(z.type==="transform")return!0;if(z.type==="array")returnB8(z.element,Y);if(z.type==="set")returnB8(z.valueType,Y);if(z.type==="lazy")returnB8(z.getter(),Y);if(z.type==="promise"||z.type==="optional"||z.type==="nonoptional"||z.type==="nullable"||z.type==="readonly"||z.type==="default"||z.type==="prefault")returnB8(z.innerType,Y);if(z.type==="intersection")returnB8(z.left,Y)||B8(z.right,Y);if(z.type==="record"||z.type==="map")returnB8(z.keyType,Y)||B8(z.valueType,Y);if(z.type==="pipe"){if($._zod.traits.has("$ZodCodec"))return!0;returnB8(z.in,Y)||B8(z.out,Y)}if(z.type==="object"){for(letQinz.shape)if(B8(z.shape[Q],Y))return!0;return!1}if(z.type==="union"){for(letQofz.options)if(B8(Q,Y))return!0;return!1}if(z.type==="tuple"){for(letQofz.items)if(B8(Q,Y))return!0;if(z.rest&&B8(z.rest,Y))return!0;return!1}return!1}varJ_=($,U={})=>(Y)=>{letz=W7({...Y,processors:U});returnI4($,z),X7(z,$),Z7(z,$)},KQ=($,U,Y={})=>(z)=>{let{libraryOptions:Q,target:J}=z??{},I=W7({...Q??{},target:J,io:U,processors:Y});returnI4($,I),X7(I,$),Z7(I,$)};varFG=o(()=>{qG()});functionvU($,U){if("_idmap"in$){letz=$,Q=W7({...U,processors:nV}),J={};for(letGofz._idmap.entries()){let[H,W]=G;I4(W,Q)}letI={},K={registry:z,uri:U?.uri,defs:J};Q.external=K;for(letGofz._idmap.entries()){let[H,W]=G;X7(Q,W),I[H]=Z7(Q,W)}if(Object.keys(J).length>0){letG=Q.target==="draft-2020-12"?"$defs":"definitions";I.__shared={[G]:J}}return{schemas:I}}letY=W7({...U,processors:nV});returnI4($,Y),X7(Y,$),Z7(Y,$)}varox0,I_=($,U,Y,z)=>{letQ=Y;Q.type="string";let{minimum:J,maximum:I,format:K,patterns:G,contentEncoding:H}=$._zod.bag;if(typeofJ==="number")Q.minLength=J;if(typeofI==="number")Q.maxLength=I;if(K){if(Q.format=ox0[K]??K,Q.format==="")deleteQ.format;if(K==="time")deleteQ.format}if(H)Q.contentEncoding=H;if(G&&G.size>0){letW=[...G];if(W.length===1)Q.pattern=W[0].source;elseif(W.length>1)Q.allOf=[...W.map((X)=>({...U.target==="draft-07"||U.target==="draft-04"||U.target==="openapi-3.0"?{type:"string"}:{},pattern:X.source}))]}},K_=($,U,Y,z)=>{letQ=Y,{minimum:J,maximum:I,format:K,multipleOf:G,exclusiveMaximum:H,exclusiveMinimum:W}=$._zod.bag;if(typeofK==="string"&&K.includes("int"))Q.type="integer";elseQ.type="number";letX=typeofW==="number"&&W>=(J??Number.NEGATIVE_INFINITY),Z=typeofH==="number"&&H<=(I??Number.POSITIVE_INFINITY),q=U.target==="draft-04"||U.target==="openapi-3.0";if(X)if(q)Q.minimum=W,Q.exclusiveMinimum=!0;elseQ.exclusiveMinimuLine truncated
`}function Cu0($){let U=[];if($.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if($.length>128)return{isValid:!1,warnings:[`Toolnameexceedsmaximumlengthof128characters(current:${$.length})`]};if($.includes(" "))U.push("Tool name contains spaces, which may cause parsing issues");if($.includes(","))U.push("Tool name contains commas, which may cause parsing issues");if($.startsWith("-")||$.endsWith("-"))U.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts");if($.startsWith(".")||$.endsWith("."))U.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts");if(!Eu0.test($)){let Y=[...$].filter((z)=>!/[A-Za-z0-9._-]/.test(z)).filter((z,Q,J)=>J.indexOf(z)===Q);return U.push(`Toolnamecontainsinvalidcharacters:${Y.map((z)=>`"${z}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:U}}return{isValid:!0,warnings:U}}function Ru0($,U){if(U.length>0){console.warn(`Toolnamevalidationwarningfor"${$}":`);for(let Y of U)console.warn(`-${Y}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function YS($){let U=Cu0($);return Ru0($,U.warnings),U.isValid}function _u0($){return typeof $==="object"&&$!==null&&"_zod"in $}function vu0($){return typeof $==="object"&&$!==null&&!("_zod"in $)&&"_def"in $&&typeof $._def?.typeName==="string"}function hu0($){if(typeof $!=="object"||$===null)return!1;if(_Q($))return!1;let U=Object.getPrototypeOf($);if(U!==Object.prototype&&U!==null)return!1;return Object.values($).every((Y)=>_u0(Y))}function Rw($){if($===void 0)return;if(hu0($))return Y0($);if(typeof $==="object"&&$!==null&&!_Q($)&&Object.values($).some((U)=>vu0(U)))throw TypeError("Raw-shape inputSchema/outputSchema/argsSchema fields must be Zod v4 schemas. Got a Zod v3 field schema. Import from `zod/v4` (or upgrade your zod import), or wrap with `z.object({...})` yourself.");if(!_Q($))throw TypeError("inputSchema/outputSchema/argsSchema must be a Standard Schema (e.g. z.object({...})) or a raw Zod shape ({ field: z.string() }).");return $}var _h,Wf0,A1,V1,Xf0,Zt="2026-07-28",T7,Lt,Vf0,Lf0,Ff0,Ot,Mt,Of0,qw,xf1,ff1,$t,fh,Bf0,Tf0,CQ,n0,J1,Aw,At,hQ,Pw,Cf0=0,Rf0="private",_f0,ff0,Lw,ch,Tt,uf1,bf1,pf0,df0,nh,Fw,XH="2026-07-28",Ct,of0,D$=($)=>xG.safeParse($).success,j7=($)=>fG.safeParse($).success,HH=($)=>wQ.safeParse($).success,Ew=($)=>OQ.safeParse($).success,r9=($)=>typeof $==="object"&&$!==null&&!Array.isArray($)&&$.resultType==="input_required",Jt="x-mcp-header",rf0,sf0,af0,tf0,Mw=-32020,if1,ef0,It=!1,hh="draft-2020-12",Yu0,Ku0,Gu0,Kt,Hu0,Lu0,vt=250,Fu0,wu0,yt,kt,Ou0,Mu0,ft=60000,Du0,Au0,Pu0,ut,th,ju0,cf1,bt=10485760,$S=class{_buffer;_maxBufferSize;constructor($){this._maxBufferSize=$?.maxBufferSize??bt}append($){if((this._buffer?.length??0)+$.length>this._maxBufferSize)throw this.clear(),Error(`ReadBufferexceededmaximumsizeof${this._maxBufferSize}bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,$]):$}readMessage(){while(this._buffer){let $=this._buffer.indexOf(`
`);if($===-1)return null;let U=this._buffer.toString("utf8",0,$).replace(/\r$/,"");this._buffer=this._buffer.subarray($+1);try{return it(U)}catch(Y){if(Y instanceof SyntaxError)continue;throw Y}}return null}clear(){this._buffer=void 0}},Eu0;var _w=o(()=>{lT();oT();aa();rv();_h=Symbol.for("mcp.sdk.errorBrands");Wf0=class $ extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](U){return RQ(this,U)}static isInstance(U){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v=>SdkError.isInstance(v)`");return RQ(this,U)}constructor(U,Y,z){super(Y);this.code=U,this.errorUri=z,this.name="OAuthError",gh(this,new.target)}toResponseObject(){let U={error:this.code,error_description:this.message};if(this.errorUri)U.error_uri=this.errorUri;return U}static fromResponse(U){return new $(U.error,U.error_description??U.error,U.error_uri)}},A1=function($){return $.NotConnected="NOT_CONNECTED",$.AlreadyConnected="ALREADY_CONNECTED",$.NotInitialized="NOT_INITIALIZED",$.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",$.RequestTimeout="REQUEST_TIMEOUT",$.ConnectionClosed="CONNECTION_CLOSED",$.SendFailed="SEND_FAILED",$.InvalidResult="INVALID_RESULT",$.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",$.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",$.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",$.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",$.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",$.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",$.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",$.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",$.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",$.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",$.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",$}({}),V1=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance]($){return RQ(this,$)}static isInstance($){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v=>SdkError.isInstance(v)`");return RQ(this,$)}constructor($,U,Y){super(U);this.code=$,this.data=Y,this.name="SdkError",gh(this,new.target)}},Xf0=class extends V1{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor($,U,Y){super($,U,Y);this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};T7=[Zt];Lt=["task","inputRequests","requestState"];Lf0=new Set(["const","enum","default","examples"]),Ff0=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);Ot={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Mt={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},Of0={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null};xf1=Object.keys(Ot),ff1=Object.keys(Mt);$t={ok:!1,reason:"not-in-era"};fh={era:"2025-11-25",hasRequestMethod:Nt,hasNotificationMethod:Dt,validateRequest:($,U)=>Vw(Df0($),U),validateResult:($,U)=>Vw(Nf0($),U),validateNotification:($,U)=>Vw(Af0($),U),hasInputRequestMethod:()=>!1,validateInputRequest:()=>$t,validateInputResponse:()=>$t,samplingResultVariant:($,U)=>{let Y=Ft();return Vw($?Y.CreateMessageResultWithToolsSchema:Y.CreateMessageResultSchema,U)},outboundEnvelope:($)=>{return},validateEnvelopeMeta:($)=>[],projectCallToolResult($,U){let Y=Vt($),z=Y.structuredContent;if(z===void 0)return Y;let Q=typeof z!=="object"||z===null||Array.isArray(z),J=U!==void 0&&wt(U);if(!Q&&!J)return Y;return{...Y,structuredContent:{result:z}}},decodeResult($,U){if(vh(U)&&"resultType"in U){let Y={...U};return delete Y.resultType,{kind:"complete",result:Yt(Y)}}return{kind:"complete",result:Yt(U)}},encodeResult($,U){if($!=="tools/list")return U;l
Line truncated
Setthe\`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(letIof$.seen.entries()){letK=I[1];if(Y===I[0]){J(I);continue}if($.external){letH=$.external.registry.get(I[0])?.id;if(Y!==I[0]&&H){J(I);continue}}if($.metadataRegistry.get(I[0])?.id){J(I);continue}if(K.cycle){J(I);continue}if(K.count>1){if($.reused==="ref"){J(I);continue}}}}functionV7($,Y){letU=$.seen.get(Y);if(!U)throwError("Unprocessed schema. This is a bug in Zod.");letz=(K)=>{letG=$.seen.get(K);if(G.ref===null)return;letH=G.def??G.schema,W={...H},X=G.ref;if(G.ref=null,X){z(X);letq=$.seen.get(X),V=q.schema;if(V.$ref&&($.target==="draft-07"||$.target==="draft-04"||$.target==="openapi-3.0"))H.allOf=H.allOf??[],H.allOf.push(V);elseObject.assign(H,V);if(Object.assign(H,W),K._zod.parent===X)for(letMinH){if(M==="$ref"||M==="allOf")continue;if(!(MinW))deleteH[M]}if(V.$ref&&q.def)for(letMinH){if(M==="$ref"||M==="allOf")continue;if(Minq.def&&JSON.stringify(H[M])===JSON.stringify(q.def[M]))deleteH[M]}}letZ=K._zod.parent;if(Z&&Z!==X){z(Z);letq=$.seen.get(Z);if(q?.schema.$ref){if(H.$ref=q.schema.$ref,q.def)for(letVinH){if(V==="$ref"||V==="allOf")continue;if(Vinq.def&&JSON.stringify(H[V])===JSON.stringify(q.def[V]))deleteH[V]}}}$.override({zodSchema:K,jsonSchema:H,path:G.path??[]})};for(letKof[...$.seen.entries()].reverse())z(K[0]);letQ={};if($.target==="draft-2020-12")Q.$schema="https://json-schema.org/draft/2020-12/schema";elseif($.target==="draft-07")Q.$schema="http://json-schema.org/draft-07/schema#";elseif($.target==="draft-04")Q.$schema="http://json-schema.org/draft-04/schema#";elseif($.target==="openapi-3.0");if($.external?.uri){letK=$.external.registry.get(Y)?.id;if(!K)throwError("Schema is missing an `id` property");Q.$id=$.external.uri(K)}Object.assign(Q,U.def??U.schema);letJ=$.metadataRegistry.get(Y)?.id;if(J!==void0&&Q.id===J)deleteQ.id;letI=$.external?.defs??{};for(letKof$.seen.entries()){letG=K[1];if(G.def&&G.defId){if(G.def.id===G.defId)deleteG.def.id;I[G.defId]=G.def}}if($.external);elseif(Object.keys(I).length>0)if($.target==="draft-2020-12")Q.$defs=I;elseQ.definitions=I;try{letK=JSON.parse(JSON.stringify(Q));returnObject.defineProperty(K,"~standard",{value:{...Y["~standard"],jsonSchema:{input:HQ(Y,"input",$.processors),output:HQ(Y,"output",$.processors)}},enumerable:!1,writable:!1}),K}catch(K){throwError("Error converting schema to JSON.")}}functionP8($,Y){letU=Y??{seen:newSet};if(U.seen.has($))return!1;U.seen.add($);letz=$._zod.def;if(z.type==="transform")return!0;if(z.type==="array")returnP8(z.element,U);if(z.type==="set")returnP8(z.valueType,U);if(z.type==="lazy")returnP8(z.getter(),U);if(z.type==="promise"||z.type==="optional"||z.type==="nonoptional"||z.type==="nullable"||z.type==="readonly"||z.type==="default"||z.type==="prefault")returnP8(z.innerType,U);if(z.type==="intersection")returnP8(z.left,U)||P8(z.right,U);if(z.type==="record"||z.type==="map")returnP8(z.keyType,U)||P8(z.valueType,U);if(z.type==="pipe"){if($._zod.traits.has("$ZodCodec"))return!0;returnP8(z.in,U)||P8(z.out,U)}if(z.type==="object"){for(letQinz.shape)if(P8(z.shape[Q],U))return!0;return!1}if(z.type==="union"){for(letQofz.options)if(P8(Q,U))return!0;return!1}if(z.type==="tuple"){for(letQofz.items)if(P8(Q,U))return!0;if(z.rest&&P8(z.rest,U))return!0;return!1}return!1}varK_=($,Y={})=>(U)=>{letz=Z7({...U,processors:Y});returnI4($,z),q7(z,$),V7(z,$)},HQ=($,Y,U={})=>(z)=>{let{libraryOptions:Q,target:J}=z??{},I=Z7({...Q??{},target:J,io:Y,processors:U});returnI4($,I),q7(I,$),V7(I,$)};varMG=m(()=>{LG()});functionvY($,Y){if("_idmap"in$){letz=$,Q=Z7({...Y,processors:nV}),J={};for(letGofz._idmap.entries()){let[H,W]=G;I4(W,Q)}letI={},K={registry:z,uri:Y?.uri,defs:J};Q.external=K;for(letGofz._idmap.entries()){let[H,W]=G;q7(Q,W),I[H]=V7(Q,W)}if(Object.keys(J).length>0){letG=Q.target==="draft-2020-12"?"$defs":"definitions";I.__shared={[G]:J}}return{schemas:I}}letU=Z7({...Y,processors:nV});returnI4($,U),q7(U,$),V7(U,$)}varex0,G_=($,Y,U,z)=>{letQ=U;Q.type="string";let{minimum:J,maximum:I,format:K,patterns:G,contentEncoding:H}=$._zod.bag;if(typeofJ==="number")Q.minLength=J;if(typeofI==="number")Q.maxLength=I;if(K){if(Q.format=ex0[K]??K,Q.format==="")deleteQ.format;if(K==="time")deleteQ.format}if(H)Q.contentEncoding=H;if(G&&G.size>0){letW=[...G];if(W.length===1)Q.pattern=W[0].source;elseif(W.length>1)Q.allOf=[...W.map((X)=>({...Y.target==="draft-07"||Y.target==="draft-04"||Y.target==="openapi-3.0"?{type:"string"}:{},pattern:X.source}))]}},H_=($,Y,U,z)=>{letQ=U,{minimum:J,maximum:I,format:K,multipleOf:G,exclusiveMaximum:H,exclusiveMinimum:W}=$._zod.bag;if(typeofK==="string"&&K.includes("int"))Q.type="integer";elseQ.type="number";letX=typeofW==="number"&&W>=(J??Number.NEGATIVE_INFINITY),Z=typeofH==="number"&&H<=(I??Number.POSITIVE_INFINITY),q=Y.target==="draft-04"||Y.target==="openapi-3.0";if(X)if(q)Q.minimum=W,Q.exclusiveMinimum=!0;elseQ.exclusiveMinimuLine truncated
`}function Su0($){let Y=[];if($.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if($.length>128)return{isValid:!1,warnings:[`Toolnameexceedsmaximumlengthof128characters(current:${$.length})`]};if($.includes(" "))Y.push("Tool name contains spaces, which may cause parsing issues");if($.includes(","))Y.push("Tool name contains commas, which may cause parsing issues");if($.startsWith("-")||$.endsWith("-"))Y.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts");if($.startsWith(".")||$.endsWith("."))Y.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts");if(!hu0.test($)){let U=[...$].filter((z)=>!/[A-Za-z0-9._-]/.test(z)).filter((z,Q,J)=>J.indexOf(z)===Q);return Y.push(`Toolnamecontainsinvalidcharacters:${U.map((z)=>`"${z}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:Y}}return{isValid:!0,warnings:Y}}function gu0($,Y){if(Y.length>0){console.warn(`Toolnamevalidationwarningfor"${$}":`);for(let U of Y)console.warn(`-${U}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function QS($){let Y=Su0($);return gu0($,Y.warnings),Y.isValid}function yu0($){return typeof $==="object"&&$!==null&&"_zod"in $}function ku0($){return typeof $==="object"&&$!==null&&!("_zod"in $)&&"_def"in $&&typeof $._def?.typeName==="string"}function xu0($){if(typeof $!=="object"||$===null)return!1;if(hQ($))return!1;let Y=Object.getPrototypeOf($);if(Y!==Object.prototype&&Y!==null)return!1;return Object.values($).every((U)=>yu0(U))}function Rw($){if($===void 0)return;if(xu0($))return U0($);if(typeof $==="object"&&$!==null&&!hQ($)&&Object.values($).some((Y)=>ku0(Y)))throw TypeError("Raw-shape inputSchema/outputSchema/argsSchema fields must be Zod v4 schemas. Got a Zod v3 field schema. Import from `zod/v4` (or upgrade your zod import), or wrap with `z.object({...})` yourself.");if(!hQ($))throw TypeError("inputSchema/outputSchema/argsSchema must be a Standard Schema (e.g. z.object({...})) or a raw Zod shape ({ field: z.string() }).");return $}var hh,Lf0,A1,V1,Ff0,Vt="2026-07-28",E7,wt,Of0,Nf0,Df0,Nt,Dt,Bf0,qw,Yu1,Uu1,Ut,bh,Rf0,_f0,_Q,n0,J1,Aw,Pt,gQ,Bw,Sf0=0,gf0="private",yf0,nf0,Lw,ph,Et,zu1,Qu1,rf0,sf0,dh,Fw,qH="2026-07-28",_t,ef0,D$=($)=>uG.safeParse($).success,C7=($)=>bG.safeParse($).success,XH=($)=>OQ.safeParse($).success,Ew=($)=>NQ.safeParse($).success,s9=($)=>typeof $==="object"&&$!==null&&!Array.isArray($)&&$.resultType==="input_required",Kt="x-mcp-header",$u0,Yu0,Uu0,zu0,Ow=-32020,Ju1,Qu0,Gt=!1,gh="draft-2020-12",Ku0,Zu0,qu0,Ht,Vu0,Nu0,St=250,Du0,Au0,xt,ft,Bu0,Pu0,bt=60000,ju0,Eu0,Cu0,it,$S,vu0,Iu1,ct=10485760,US=class{_buffer;_maxBufferSize;constructor($){this._maxBufferSize=$?.maxBufferSize??ct}append($){if((this._buffer?.length??0)+$.length>this._maxBufferSize)throw this.clear(),Error(`ReadBufferexceededmaximumsizeof${this._maxBufferSize}bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,$]):$}readMessage(){while(this._buffer){let $=this._buffer.indexOf(`
`);if($===-1)return null;let Y=this._buffer.toString("utf8",0,$).replace(/\r$/,"");this._buffer=this._buffer.subarray($+1);try{return nt(Y)}catch(U){if(U instanceof SyntaxError)continue;throw U}}return null}clear(){this._buffer=void 0}},hu0;var _w=m(()=>{rT();sT();ea();av();hh=Symbol.for("mcp.sdk.errorBrands");Lf0=class $ extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](Y){return vQ(this,Y)}static isInstance(Y){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v=>SdkError.isInstance(v)`");return vQ(this,Y)}constructor(Y,U,z){super(U);this.code=Y,this.errorUri=z,this.name="OAuthError",kh(this,new.target)}toResponseObject(){let Y={error:this.code,error_description:this.message};if(this.errorUri)Y.error_uri=this.errorUri;return Y}static fromResponse(Y){return new $(Y.error,Y.error_description??Y.error,Y.error_uri)}},A1=function($){return $.NotConnected="NOT_CONNECTED",$.AlreadyConnected="ALREADY_CONNECTED",$.NotInitialized="NOT_INITIALIZED",$.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",$.RequestTimeout="REQUEST_TIMEOUT",$.ConnectionClosed="CONNECTION_CLOSED",$.SendFailed="SEND_FAILED",$.InvalidResult="INVALID_RESULT",$.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",$.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",$.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",$.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",$.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",$.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",$.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",$.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",$.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",$.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",$.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",$}({}),V1=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance]($){return vQ(this,$)}static isInstance($){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v=>SdkError.isInstance(v)`");return vQ(this,$)}constructor($,Y,U){super(Y);this.code=$,this.data=U,this.name="SdkError",kh(this,new.target)}},Ff0=class extends V1{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor($,Y,U){super($,Y,U);this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};E7=[Vt];wt=["task","inputRequests","requestState"];Nf0=new Set(["const","enum","default","examples"]),Df0=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);Nt={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Dt={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},Bf0={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null};Yu1=Object.keys(Nt),Uu1=Object.keys(Dt);Ut={ok:!1,reason:"not-in-era"};bh={era:"2025-11-25",hasRequestMethod:At,hasNotificationMethod:Bt,validateRequest:($,Y)=>Vw(jf0($),Y),validateResult:($,Y)=>Vw(Tf0($),Y),validateNotification:($,Y)=>Vw(Ef0($),Y),hasInputRequestMethod:()=>!1,validateInputRequest:()=>Ut,validateInputResponse:()=>Ut,samplingResultVariant:($,Y)=>{let U=Mt();return Vw($?U.CreateMessageResultWithToolsSchema:U.CreateMessageResultSchema,Y)},outboundEnvelope:($)=>{return},validateEnvelopeMeta:($)=>[],projectCallToolResult($,Y){let U=Ft($),z=U.structuredContent;if(z===void 0)return U;let Q=typeof z!=="object"||z===null||Array.isArray(z),J=Y!==void 0&&Ot(Y);if(!Q&&!J)return U;return{...U,structuredContent:{result:z}}},decodeResult($,Y){if(Sh(Y)&&"resultType"in Y){let U={...Y};return delete U.resultType,{kind:"complete",result:Qt(U)}}return{kind:"complete",result:Qt(Y)}},encodeResult($,Y){if($!=="tools/list")return Y;l
Line truncated
*content-type
*Copyright(c)2015DouglasChristopherWilson
*MITLicensed
*/ju0=R0(($)=>{var U=/;*([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,Y=/\\([\u000b\u0020-\u00ff])/g,z=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;$.parse=Q;function Q(K){if(!K)throw TypeError("argument string is required");var G=typeof K==="object"?J(K):K;if(typeof G!=="string")throw TypeError("argument string is required to be a string");var H=G.indexOf(";"),W=H!==-1?G.slice(0,H).trim():G.trim();if(!z.test(W))throw TypeError("invalid media type");var X=new I(W.toLowerCase());if(H!==-1){var Z,q,V;U.lastIndex=H;while(q=U.exec(G)){if(q.index!==H)throw TypeError("invalid parameter format");if(H+=q[0].length,Z=q[1].toLowerCase(),V=q[2],V.charCodeAt(0)===34){if(V=V.slice(1,-1),V.indexOf("\\")!==-1)V=V.replace(Y,"$1")}X.parameters[Z]=V}if(H!==G.length)throw TypeError("invalid parameter format")}return X}function J(K){var G;if(typeof K.getHeader==="function")G=K.getHeader("content-type");else if(typeof K.headers==="object")G=K.headers&&K.headers["content-type"];if(typeof G!=="string")throw TypeError("content-type header is missing from object");return G}function I(K){this.parameters=Object.create(null),this.type=K}}),cf1=nq(ju0(),1);Eu0=/^[A-Za-z0-9._-]{1,128}$/});function zS($){let U=new $({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return ob0(U),U}var vw,ct,L1,v1,z5,Sw,Su0,nt,pt,hw,gu0,Q5,yu0,ku0,dt,xu0,gw,SQ,qH,gQ,yw,fu0,mt,uu0,bu0,iu0,QS,cu0,JS,lt,nu0,pu0,du0,mu0,lu0,ou0,ru0,su0,IS,au0,tu0,eu0,ot,rt,st,$b0,Ub0,Yb0,KS,zb0,at,Qb0,Jb0,Ib0,Kb0,Gb0,Hb0,Wb0,Xb0,tt,Zb0,et,$e,Ue,qb0,GS,Vb0,Ye,ze,Qe,Lb0,Fb0,Je,wb0,Ob0,Mb0,Ie,Nb0,Db0,Ke,Ab0,Pb0,Bb0,Tb0,jb0,Eb0,Cb0,Rb0,_b0,vb0,hb0,Sb0,gb0,yb0,kb0,xb0,fb0,ub0,bb0,ib0,cb0,nb0,pb0,Ge,db0,mb0,lb0,ob0,kw=class{_ajv;_ajvDraft7;_ajv2019;_userAjv;constructor($){this._userAjv=$!==void 0,this._ajv=$}get ajv(){return this._ajv??=zS(mb0.Ajv2020)}_engineFor($){if(this._userAjv)return this.ajv;let U=bo($,"pass a pre-configured Ajv instance to AjvJsonSchemaValidator(ajv) to validate other dialects.");if(U==="2020-12")return this.ajv;if(U==="2019-09")return this._ajv2019??=zS(db0.Ajv2019);return this._ajvDraft7??=zS(Ge.Ajv)}getValidator($){let U=this._engineFor($),Y="$id"in $&&typeof $.$id==="string"?U.getSchema($.$id)??U.compile($):U.compile($);return(z)=>{return Y(z)?{valid:!0,data:z,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:U.errorsText(Y.errors)}}}},$u1;var He=o(()=>{lT();oT();vw=R0(($)=>{Object.defineProperty($,"__esModule",{value:!0}),$.regexpCode=$.getEsmExportName=$.getProperty=$.safeStringify=$.stringify=$.strConcat=$.addCodeArg=$.str=$._=$.nil=$._Code=$.Name=$.IDENTIFIER=$._CodeOrName=void 0;var U=class{};$._CodeOrName=U,$.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Y=class extends U{constructor(w){super();if(!$.IDENTIFIER.test(w))throw Error("CodeGen: name must be a valid identifier");this.str=w}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};$.Name=Y;var z=class extends U{constructor(w){super();this._items=typeof w==="string"?[w]:w}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let w=this._items[0];return w===""||w==='""'}get str(){var w;return(w=this._str)!==null&&w!==void 0?w:this._str=this._items.reduce((M,N)=>`${M}${N}`,"")}get names(){var w;return(w=this._names)!==null&&w!==void 0?w:this._names=this._items.reduce((M,N)=>{if(N instanceof Y)M[N.str]=(M[N.str]||0)+1;return M},{})}};$._Code=z,$.nil=new z("");function Q(w,...M){let N=[w[0]],D=0;while(D<M.length)K(N,M[D]),N.push(w[++D]);return new z(N)}$._=Q;let J=new z("+");function I(w,...M){let N=[q(w[0])],D=0;while(D<M.length)N.push(J),K(N,M[D]),N.push(J,q(w[++D]));return G(N),new z(N)}$.str=I;function K(w,M){if(M instanceof z)w.push(...M._items);else if(M instanceof Y)w.push(M);else w.push(X(M))}$.addCodeArg=K;function G(w){let M=1;while(M<w.length-1){if(w[M]===J){let N=H(w[M-1],w[M+1]);if(N!==void 0){w.splice(M-1,3,N);continue}w[M++]="+"}M++}}function H(w,M){if(M==='""')return w;if(w==='""')return M;if(typeof w=="string"){if(M instanceof Y||w[w.length-1]!=='"')return;if(typeof M!="string")return`${w.slice(0,-1)}${M}"`;if(M[0]==='"')return w.slice(0,-1)+M.slice(1);return}if(typeof M=="string"&&M[0]==='"'&&!(w instanceof Y))return`"${w}${M.slice(1)}`}function W(w,M){return M.emptyStr()?w:w.emptyStr()?M:I`${w}${M}`}$.strConcat=W;function X(w){return typeof w=="number"||typeof w=="boolean"||w===null?w:q(Array.isArray(w)?w.join(","):w)}function Z(w){return new z(q(w))}$.stringify=Z;function q(w){return JSON.stringify(w).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}$.safeStringify=q;function V(w){return typeof w=="string"&&$.IDENTIFIER.test(w)?new z(`.${w}`):Q`[${w}]`}$.getProperty=V;function F(w){if(typeof w=="string"&&$.IDENTIFIER.test(w))returnnewz(`${w}`);throwError(`CodeGen: invalid export name: ${w}, use explicit $id name mapping`)}$.getEsmExportName=F;functionO(w){returnnewz(w.toStringLine truncated
deps:${W}}`};let Q={keyword:"dependencies",type:"object",schemaType:"object",error:$.error,code(G){let[H,W]=J(G);I(G,H),K(G,W)}};function J({schema:G}){let H={},W={};for(let X in G){if(X==="__proto__")continue;let Z=Array.isArray(G[X])?H:W;Z[X]=G[X]}return[H,W]}function I(G,H=G.schema){let{gen:W,data:X,it:Z}=G;if(Object.keys(H).length===0)return;let q=W.let("missing");for(let V in H){let F=H[V];if(F.length===0)continue;let O=(0,z.propertyInData)(W,X,V,Z.opts.ownProperties);if(G.setParams({property:V,depsCount:F.length,deps:F.join(", ")}),Z.allErrors)W.if(O,()=>{for(let w of F)(0,z.checkReportMissingProp)(G,w)});else W.if(U._`${O}&&(${(0,z.checkMissingProp)(G,F,q)})`),(0,z.reportMissingProp)(G,q),W.else()}}$.validatePropertyDeps=I;function K(G,H=G.schema){let{gen:W,data:X,keyword:Z,it:q}=G,V=W.name("valid");for(let F in H){if((0,Y.alwaysValidSchema)(q,H[F]))continue;W.if((0,z.propertyInData)(W,X,F,q.opts.ownProperties),()=>{let O=G.subschema({keyword:Z,schemaProp:F},V);G.mergeValidEvaluated(O,V)},()=>W.var(V,!0)),G.ok(V)}}$.validateSchemaDeps=K,$.default=Q}),zb0=R0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let U=L1(),Y=v1(),z={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:Q})=>U._`{propertyName:${Q.propertyName}}`},code(Q){let{gen:J,schema:I,data:K,it:G}=Q;if((0,Y.alwaysValidSchema)(G,I))return;let H=J.name("valid");J.forIn("key",K,(W)=>{Q.setParams({propertyName:W}),Q.subschema({keyword:"propertyNames",data:W,dataTypes:["string"],propertyName:W,compositeRule:!0},H),J.if((0,U.not)(H),()=>{if(Q.error(!0),!G.allErrors)J.break()})}),Q.ok(H)}};$.default=z}),at=R0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let U=Q5(),Y=L1(),z=z5(),Q=v1(),J={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:I})=>Y._`{additionalProperty:${I.additionalProperty}}`},code(I){let{gen:K,schema:G,parentSchema:H,data:W,errsCount:X,it:Z}=I;if(!X)throw Error("ajv implementation error");let{allErrors:q,opts:V}=Z;if(Z.props=!0,V.removeAdditional!=="all"&&(0,Q.alwaysValidSchema)(Z,G))return;let F=(0,U.allSchemaProperties)(H.properties),O=(0,U.allSchemaProperties)(H.patternProperties);w(),I.ok(Y._`${X}===${z.default.errors}`);function w(){K.forIn("key",W,(T)=>{if(!F.length&&!O.length)D(T);else K.if(M(T),()=>D(T))})}function M(T){let A;if(F.length>8){let j=(0,Q.schemaRefOrVal)(Z,H.properties,"properties");A=(0,U.isOwnProperty)(K,j,T)}else if(F.length)A=(0,Y.or)(...F.map((j)=>Y._`${T}===${j}`));else A=Y.nil;if(O.length)A=(0,Y.or)(A,...O.map((j)=>Y._`${(0,U.usePattern)(I,j)}.test(${T})`));return(0,Y.not)(A)}function N(T){K.code(Y._`delete${W}[${T}]`)}function D(T){if(V.removeAdditional==="all"||V.removeAdditional&&G===!1){N(T);return}if(G===!1){if(I.setParams({additionalProperty:T}),I.error(),!q)K.break();return}if(typeof G=="object"&&!(0,Q.alwaysValidSchema)(Z,G)){let A=K.name("valid");if(V.removeAdditional==="failing")B(T,A,!1),K.if((0,Y.not)(A),()=>{I.reset(),N(T)});else if(B(T,A),!q)K.if((0,Y.not)(A),()=>K.break())}}function B(T,A,j){let C={keyword:"additionalProperties",dataProp:T,dataPropType:Q.Type.Str};if(j===!1)Object.assign(C,{compositeRule:!0,createErrors:!1,allErrors:!1});I.subschema(C,A)}}};$.default=J}),Qb0=R0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let U=SQ(),Y=Q5(),z=v1(),Q=at(),J={keyword:"properties",type:"object",schemaType:"object",code(I){let{gen:K,schema:G,parentSchema:H,data:W,it:X}=I;if(X.opts.removeAdditional==="all"&&H.additionalProperties===void 0)Q.default.code(new U.KeywordCxt(X,Q.default,"additionalProperties"));let Z=(0,Y.allSchemaProperties)(G);for(let w of Z)X.definedProperties.add(w);if(X.opts.unevaluated&&Z.length&&X.props!==!0)X.props=z.mergeEvaluated.props(K,(0,z.toHash)(Z),X.props);let q=Z.filter((w)=>!(0,z.alwaysValidSchema)(X,G[w]));if(q.length===0)return;let V=K.name("valid");for(let w of q){if(F(w))O(w);else{if(K.if((0,Y.propertyInData)(K,W,w,X.opts.ownProperties)),O(w),!X.allErrors)K.else().var(V,!0);K.endIf()}I.it.definedProperties.add(w),I.ok(V)}function F(w){return X.opts.useDefaults&&!X.compositeRule&&G[w].default!==void 0}function O(w){I.subschema({keyword:"properties",schemaProp:w,dataProp:w},V)}}};$.default=J}),Jb0=R0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let U=Q5(),Y=L1(),z=v1(),Q=v1(),J={keyword:"patternProperties",type:"object",schemaType:"object",code(I){let{gen:K,schema:G,data:H,parentSchema:W,it:X}=I,{opts:Z}=X,q=(0,U.allSchemaProperties)(G),V=q.filter((B)=>(0,z.alwaysValidSchema)(X,G[B]));if(q.length===0||V.length===q.length&&(!X.opts.unevaluated||X.props===!0))return;let F=Z.strictSchema&&!Z.allowMatchingProperties&&W.properties,O=K.name("valid");if(X.props!==!0&&!(X.props instanceof Y.Name))X.props=(0,Q.evaluatedPropsToName)(K,X.props);let{props:w}=X;M();function M(){for(let B of q){if(F)N(B);if(X.allErrors)
Line truncated
`)}openNode($,U){let Y=this.tos,z=this._xml;if(Y&&this.open)z.push(">");this._stack.push($),z.push("<"),z.push($),Dk(z,U),this.leaf=!0,this.open=!0}addAttribute($,U){if(!this.open)throw Error("Cannot write attributes to node if it is not open");if(U!==void 0)y30(this._xml,$,U)}addAttributes($){if(!this.open)throw Error("Cannot write attributes to node if it is not open");Dk(this._xml,$)}writeText($){let U=this._xml;if(this.open)U.push(">"),this.open=!1;this.leaf=!1,U.push(g30.xmlEncode($.toString()))}writeXml($){if(this.open)this._xml.push(">"),this.open=!1;this.leaf=!1,this._xml.push($)}closeNode(){let $=this._stack.pop(),U=this._xml;if(this.leaf)U.push("/>");else U.push("</"),U.push($),U.push(">");this.open=!1,this.leaf=!1}leafNode($,U,Y){if(this.openNode($,U),Y!==void 0)this.writeText(Y);this.closeNode()}closeAll(){while(this._stack.length)this.closeNode()}addRollback(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf,open:this.open}),this.cursor}commit(){this._rollbacks.pop()}rollback(){let $=this._rollbacks.pop();if(this._xml.length>$.xml)this._xml.splice($.xml,this._xml.length-$.xml);if(this._stack.length>$.stack)this._stack.splice($.stack,this._stack.length-$.stack);this.leaf=$.leaf,this.open=$.open}get xml(){return this.closeAll(),this._xml.join("")}}Ak.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"};k30.exports=Ak});var Pk=E((Xt0)=>{var x30=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function Wt0($){if(typeof $==="string")return $;if(x30)return x30.decode($);return $.toString()}Xt0.bufferToString=Wt0});var c30=E((u30)=>{Object.defineProperty(u30,"__esModule",{value:!0});u30.CHAR=`
`,$=this.i;break;case ve0:{let{entityReturnState:Y}=this,z=this.entity+U.slice($,this.prevI);this.state=Y;let Q;if(z==="")this.fail("empty entity name."),Q="&;";else Q=this.parseEntity(z),this.entity="";if(Y!==C8||this.textHandler!==void 0)this.text+=Q;break $}case k4:this.entity+=U.slice($);break $;default:}}sOpenWaka(){let $=this.getCode();if(vW($))this.state=je0,this.unget(),this.xmlDeclPossible=!1;else switch($){case mM:this.state=Re0,this.xmlDeclPossible=!1;break;case X70:this.state=Fe0,this.openWakaBang="",this.xmlDeclPossible=!1;break;case o6:this.state=De0;break;default:this.fail("disallowed character in tag name"),this.state=C8,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case"[CDATA[":if(!this.sawRoot&&!this.reportedTextBeforeRoot)this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0;if(this.closedRoot&&!this.reportedTextAfterRoot)this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0;this.state=Sk,this.openWakaBang="";break;case"--":this.state=hk,this.openWakaBang="";break;case"DOCTYPE":if(this.state=Rk,this.doctype||this.sawRoot)this.fail("inappropriately located doctype declaration.");this.openWakaBang="";break;default:if(this.openWakaBang.length>=7)this.fail("incorrect syntax.")}}sComment(){if(this.captureToChar(dM))this.state=we0}sCommentEnding(){var $;let U=this.getCodeNorm();if(U===dM)this.state=Oe0,($=this.commentHandler)===null||$===void 0||$.call(this,this.text),this.text="";else this.text+=`-${String.fromCodePoint(U)}`,this.state=hk}sCommentEnded(){let $=this.getCodeNorm();if($!==B6)this.fail("malformed comment."),this.text+=`--${String.fromCodePoint($)}`,this.state=hk;else this.state=C8}sCData(){if(this.captureToChar(TJ))this.state=Me0}sCDataEnding(){let $=this.getCodeNorm();if($===TJ)this.state=Ne0;else this.text+=`]${String.fromCodePoint($)}`,this.state=Sk}sCDataEnding2(){var $;let U=this.getCodeNorm();switch(U){case B6:{($=this.cdataHandler)===null||$===void 0||$.call(this,this.text),this.text="",this.state=C8;break}case TJ:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(U)}`,this.state=Sk}}sPIFirstChar(){let $=this.getCodeNorm();if(this.nameStartCheck($))this.piTarget+=String.fromCodePoint($),this.state=Q70;else if($===o6||p8($))this.fail("processing instruction without a target."),this.state=$===o6?pM:gk;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint($),this.state=Q70}sPIRest(){let{chunk:$,i:U}=this;while(!0){let Y=this.getCodeNorm();if(Y===k4){this.piTarget+=$.slice(U);return}if(!this.nameCheck(Y)){this.piTarget+=$.slice(U,this.prevI);let z=Y===o6;if(z||p8(Y))if(this.piTarget==="xml"){if(!this.xmlDeclPossible)this.fail("an XML declaration must be at the start of the document.");this.state=z?GY:J70}else this.state=z?pM:gk;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(Y);break}}}sPIBody(){if(this.text.length===0){let $=this.getCodeNorm();if($===o6)this.state=pM;else if(!p8($))this.text=String.fromCodePoint($)}else if(this.captureToChar(o6))this.state=pM}sPIEnding(){var $;let U=this.getCodeNorm();if(U===B6){let{piTarget:Y}=this;if(Y.toLowerCase()==="xml")this.fail("the XML declaration must appear at the start of the document.");($=this.piHandler)===null||$===void 0||$.call(this,{target:Y,body:this.text}),this.piTarget=this.text="",this.state=C8}else if(U===o6)this.text+="?";else this.text+=`?${String.fromCodePoint(U)}`,this.state=gk;this.xmlDeclPossible=!1}sXMLDeclNameStart(){let $=this.skipSpaces();if($===o6){this.state=GY;return}if($!==k4)this.state=Ae0,this.name=String.fromCodePoint($)}sXMLDeclName(){let $=this.captureTo(ge0);if($===o6){this.state=GY,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(!(p8($)||$===BJ))return;if(this.name+=this.text,this.text="",!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail("did not expect any more name/value pairs.");break;case 1:this.fail(`expectedthename${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expectedoneof${this.xmlDeclExpects.join(", ")}`)}this.state=$===BJ?I70:Pe0}sXMLDeclEq(){let $=this.getCodeNorm();if($===o6){this.state=GY,this.fail("XML declaration is incomplete.");return}if(p8($))return;if($!==BJ)this.fail("value required.");this.state=I70}sXMLDeclValueStart(){let $=this.getCodeNorm();if($===o6){this.state=GY,this.fail("XML declaration is incomplete.");return}if(p8($))return;if(!lM($))this.fail("value must be quoted."),this.q=W70;else this.q=$;this.state=Be0}sXMLDeclValue(){let $=this.captureTo([this.q,o6]);if($===o6){this.state=GY,this.text="",this.fail("XML declaration is incomplete.");return}if($===k4)return;let U=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let Y=U;if(this.xmlDecl.version=Y,!/^1\.[0-9]+$/.test(Y))this.fail("ver
Line truncated
deps:${W}}`};let Q={keyword:"dependencies",type:"object",schemaType:"object",error:$.error,code(G){let[H,W]=J(G);I(G,H),K(G,W)}};function J({schema:G}){let H={},W={};for(let X in G){if(X==="__proto__")continue;let Z=Array.isArray(G[X])?H:W;Z[X]=G[X]}return[H,W]}function I(G,H=G.schema){let{gen:W,data:X,it:Z}=G;if(Object.keys(H).length===0)return;let q=W.let("missing");for(let V in H){let F=H[V];if(F.length===0)continue;let M=(0,z.propertyInData)(W,X,V,Z.opts.ownProperties);if(G.setParams({property:V,depsCount:F.length,deps:F.join(", ")}),Z.allErrors)W.if(M,()=>{for(let w of F)(0,z.checkReportMissingProp)(G,w)});else W.if(Y._`${M}&&(${(0,z.checkMissingProp)(G,F,q)})`),(0,z.reportMissingProp)(G,q),W.else()}}$.validatePropertyDeps=I;function K(G,H=G.schema){let{gen:W,data:X,keyword:Z,it:q}=G,V=W.name("valid");for(let F in H){if((0,U.alwaysValidSchema)(q,H[F]))continue;W.if((0,z.propertyInData)(W,X,F,q.opts.ownProperties),()=>{let M=G.subschema({keyword:Z,schemaProp:F},V);G.mergeValidEvaluated(M,V)},()=>W.var(V,!0)),G.ok(V)}}$.validateSchemaDeps=K,$.default=Q}),Gb0=R0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let Y=L1(),U=v1(),z={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:Q})=>Y._`{propertyName:${Q.propertyName}}`},code(Q){let{gen:J,schema:I,data:K,it:G}=Q;if((0,U.alwaysValidSchema)(G,I))return;let H=J.name("valid");J.forIn("key",K,(W)=>{Q.setParams({propertyName:W}),Q.subschema({keyword:"propertyNames",data:W,dataTypes:["string"],propertyName:W,compositeRule:!0},H),J.if((0,Y.not)(H),()=>{if(Q.error(!0),!G.allErrors)J.break()})}),Q.ok(H)}};$.default=z}),et=R0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let Y=Q5(),U=L1(),z=z5(),Q=v1(),J={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:I})=>U._`{additionalProperty:${I.additionalProperty}}`},code(I){let{gen:K,schema:G,parentSchema:H,data:W,errsCount:X,it:Z}=I;if(!X)throw Error("ajv implementation error");let{allErrors:q,opts:V}=Z;if(Z.props=!0,V.removeAdditional!=="all"&&(0,Q.alwaysValidSchema)(Z,G))return;let F=(0,Y.allSchemaProperties)(H.properties),M=(0,Y.allSchemaProperties)(H.patternProperties);w(),I.ok(U._`${X}===${z.default.errors}`);function w(){K.forIn("key",W,(T)=>{if(!F.length&&!M.length)D(T);else K.if(N(T),()=>D(T))})}function N(T){let A;if(F.length>8){let j=(0,Q.schemaRefOrVal)(Z,H.properties,"properties");A=(0,Y.isOwnProperty)(K,j,T)}else if(F.length)A=(0,U.or)(...F.map((j)=>U._`${T}===${j}`));else A=U.nil;if(M.length)A=(0,U.or)(A,...M.map((j)=>U._`${(0,Y.usePattern)(I,j)}.test(${T})`));return(0,U.not)(A)}function O(T){K.code(U._`delete${W}[${T}]`)}function D(T){if(V.removeAdditional==="all"||V.removeAdditional&&G===!1){O(T);return}if(G===!1){if(I.setParams({additionalProperty:T}),I.error(),!q)K.break();return}if(typeof G=="object"&&!(0,Q.alwaysValidSchema)(Z,G)){let A=K.name("valid");if(V.removeAdditional==="failing")P(T,A,!1),K.if((0,U.not)(A),()=>{I.reset(),O(T)});else if(P(T,A),!q)K.if((0,U.not)(A),()=>K.break())}}function P(T,A,j){let C={keyword:"additionalProperties",dataProp:T,dataPropType:Q.Type.Str};if(j===!1)Object.assign(C,{compositeRule:!0,createErrors:!1,allErrors:!1});I.subschema(C,A)}}};$.default=J}),Hb0=R0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let Y=yQ(),U=Q5(),z=v1(),Q=et(),J={keyword:"properties",type:"object",schemaType:"object",code(I){let{gen:K,schema:G,parentSchema:H,data:W,it:X}=I;if(X.opts.removeAdditional==="all"&&H.additionalProperties===void 0)Q.default.code(new Y.KeywordCxt(X,Q.default,"additionalProperties"));let Z=(0,U.allSchemaProperties)(G);for(let w of Z)X.definedProperties.add(w);if(X.opts.unevaluated&&Z.length&&X.props!==!0)X.props=z.mergeEvaluated.props(K,(0,z.toHash)(Z),X.props);let q=Z.filter((w)=>!(0,z.alwaysValidSchema)(X,G[w]));if(q.length===0)return;let V=K.name("valid");for(let w of q){if(F(w))M(w);else{if(K.if((0,U.propertyInData)(K,W,w,X.opts.ownProperties)),M(w),!X.allErrors)K.else().var(V,!0);K.endIf()}I.it.definedProperties.add(w),I.ok(V)}function F(w){return X.opts.useDefaults&&!X.compositeRule&&G[w].default!==void 0}function M(w){I.subschema({keyword:"properties",schemaProp:w,dataProp:w},V)}}};$.default=J}),Wb0=R0(($)=>{Object.defineProperty($,"__esModule",{value:!0});let Y=Q5(),U=L1(),z=v1(),Q=v1(),J={keyword:"patternProperties",type:"object",schemaType:"object",code(I){let{gen:K,schema:G,data:H,parentSchema:W,it:X}=I,{opts:Z}=X,q=(0,Y.allSchemaProperties)(G),V=q.filter((P)=>(0,z.alwaysValidSchema)(X,G[P]));if(q.length===0||V.length===q.length&&(!X.opts.unevaluated||X.props===!0))return;let F=Z.strictSchema&&!Z.allowMatchingProperties&&W.properties,M=K.name("valid");if(X.props!==!0&&!(X.props instanceof U.Name))X.props=(0,Q.evaluatedPropsToName)(K,X.props);let{props:w}=X;N();function N(){for(let P of q){if(F)O(P);if(X.allErrors)
Line truncated
`)}openNode($,Y){let U=this.tos,z=this._xml;if(U&&this.open)z.push(">");this._stack.push($),z.push("<"),z.push($),Bk(z,Y),this.leaf=!0,this.open=!0}addAttribute($,Y){if(!this.open)throw Error("Cannot write attributes to node if it is not open");if(Y!==void 0)k30(this._xml,$,Y)}addAttributes($){if(!this.open)throw Error("Cannot write attributes to node if it is not open");Bk(this._xml,$)}writeText($){let Y=this._xml;if(this.open)Y.push(">"),this.open=!1;this.leaf=!1,Y.push(y30.xmlEncode($.toString()))}writeXml($){if(this.open)this._xml.push(">"),this.open=!1;this.leaf=!1,this._xml.push($)}closeNode(){let $=this._stack.pop(),Y=this._xml;if(this.leaf)Y.push("/>");else Y.push("</"),Y.push($),Y.push(">");this.open=!1,this.leaf=!1}leafNode($,Y,U){if(this.openNode($,Y),U!==void 0)this.writeText(U);this.closeNode()}closeAll(){while(this._stack.length)this.closeNode()}addRollback(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf,open:this.open}),this.cursor}commit(){this._rollbacks.pop()}rollback(){let $=this._rollbacks.pop();if(this._xml.length>$.xml)this._xml.splice($.xml,this._xml.length-$.xml);if(this._stack.length>$.stack)this._stack.splice($.stack,this._stack.length-$.stack);this.leaf=$.leaf,this.open=$.open}get xml(){return this.closeAll(),this._xml.join("")}}Pk.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"};x30.exports=Pk});var Tk=E((Ft0)=>{var f30=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function Lt0($){if(typeof $==="string")return $;if(f30)return f30.decode($);return $.toString()}Ft0.bufferToString=Lt0});var n30=E((b30)=>{Object.defineProperty(b30,"__esModule",{value:!0});b30.CHAR=`
`,$=this.i;break;case ke0:{let{entityReturnState:U}=this,z=this.entity+Y.slice($,this.prevI);this.state=U;let Q;if(z==="")this.fail("empty entity name."),Q="&;";else Q=this.parseEntity(z),this.entity="";if(U!==C8||this.textHandler!==void 0)this.text+=Q;break $}case k4:this.entity+=Y.slice($);break $;default:}}sOpenWaka(){let $=this.getCode();if(vW($))this.state=ve0,this.unget(),this.xmlDeclPossible=!1;else switch($){case lO:this.state=ge0,this.xmlDeclPossible=!1;break;case Z70:this.state=De0,this.openWakaBang="",this.xmlDeclPossible=!1;break;case o6:this.state=je0;break;default:this.fail("disallowed character in tag name"),this.state=C8,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case"[CDATA[":if(!this.sawRoot&&!this.reportedTextBeforeRoot)this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0;if(this.closedRoot&&!this.reportedTextAfterRoot)this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0;this.state=yk,this.openWakaBang="";break;case"--":this.state=gk,this.openWakaBang="";break;case"DOCTYPE":if(this.state=vk,this.doctype||this.sawRoot)this.fail("inappropriately located doctype declaration.");this.openWakaBang="";break;default:if(this.openWakaBang.length>=7)this.fail("incorrect syntax.")}}sComment(){if(this.captureToChar(mO))this.state=Ae0}sCommentEnding(){var $;let Y=this.getCodeNorm();if(Y===mO)this.state=Be0,($=this.commentHandler)===null||$===void 0||$.call(this,this.text),this.text="";else this.text+=`-${String.fromCodePoint(Y)}`,this.state=gk}sCommentEnded(){let $=this.getCodeNorm();if($!==P6)this.fail("malformed comment."),this.text+=`--${String.fromCodePoint($)}`,this.state=gk;else this.state=C8}sCData(){if(this.captureToChar(EJ))this.state=Pe0}sCDataEnding(){let $=this.getCodeNorm();if($===EJ)this.state=Te0;else this.text+=`]${String.fromCodePoint($)}`,this.state=yk}sCDataEnding2(){var $;let Y=this.getCodeNorm();switch(Y){case P6:{($=this.cdataHandler)===null||$===void 0||$.call(this,this.text),this.text="",this.state=C8;break}case EJ:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(Y)}`,this.state=yk}}sPIFirstChar(){let $=this.getCodeNorm();if(this.nameStartCheck($))this.piTarget+=String.fromCodePoint($),this.state=J70;else if($===o6||p8($))this.fail("processing instruction without a target."),this.state=$===o6?dO:kk;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint($),this.state=J70}sPIRest(){let{chunk:$,i:Y}=this;while(!0){let U=this.getCodeNorm();if(U===k4){this.piTarget+=$.slice(Y);return}if(!this.nameCheck(U)){this.piTarget+=$.slice(Y,this.prevI);let z=U===o6;if(z||p8(U))if(this.piTarget==="xml"){if(!this.xmlDeclPossible)this.fail("an XML declaration must be at the start of the document.");this.state=z?HU:I70}else this.state=z?dO:kk;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(U);break}}}sPIBody(){if(this.text.length===0){let $=this.getCodeNorm();if($===o6)this.state=dO;else if(!p8($))this.text=String.fromCodePoint($)}else if(this.captureToChar(o6))this.state=dO}sPIEnding(){var $;let Y=this.getCodeNorm();if(Y===P6){let{piTarget:U}=this;if(U.toLowerCase()==="xml")this.fail("the XML declaration must appear at the start of the document.");($=this.piHandler)===null||$===void 0||$.call(this,{target:U,body:this.text}),this.piTarget=this.text="",this.state=C8}else if(Y===o6)this.text+="?";else this.text+=`?${String.fromCodePoint(Y)}`,this.state=kk;this.xmlDeclPossible=!1}sXMLDeclNameStart(){let $=this.skipSpaces();if($===o6){this.state=HU;return}if($!==k4)this.state=Ee0,this.name=String.fromCodePoint($)}sXMLDeclName(){let $=this.captureTo(ue0);if($===o6){this.state=HU,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(!(p8($)||$===jJ))return;if(this.name+=this.text,this.text="",!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail("did not expect any more name/value pairs.");break;case 1:this.fail(`expectedthename${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expectedoneof${this.xmlDeclExpects.join(", ")}`)}this.state=$===jJ?K70:Ce0}sXMLDeclEq(){let $=this.getCodeNorm();if($===o6){this.state=HU,this.fail("XML declaration is incomplete.");return}if(p8($))return;if($!==jJ)this.fail("value required.");this.state=K70}sXMLDeclValueStart(){let $=this.getCodeNorm();if($===o6){this.state=HU,this.fail("XML declaration is incomplete.");return}if(p8($))return;if(!oO($))this.fail("value must be quoted."),this.q=X70;else this.q=$;this.state=Re0}sXMLDeclValue(){let $=this.captureTo([this.q,o6]);if($===o6){this.state=HU,this.text="",this.fail("XML declaration is incomplete.");return}if($===k4)return;let Y=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let U=Y;if(this.xmlDecl.version=U,!/^1\.[0-9]+$/.test(U))this.fail("ver
Line truncated
See:https://github.com/isaacs/node-glob/issues/167`);return new T6($,U).found}function T6($,U){if(!$)throw Error("must provide pattern");if(typeof U==="function"||arguments.length===3)throw TypeError(`callback provided to sync glob
See:https://github.com/isaacs/node-glob/issues/167`);return new T6($,Y).found}function T6($,Y){if(!$)throw Error("must provide pattern");if(typeof Y==="function"||arguments.length===3)throw TypeError(`callback provided to sync glob
`+Z0[P0-1];break}}}var N1="a promise was created in a "+v+"handler "+X0+"but was not returned from it, see http://goo.gl/rRqMUw"+J0;u._warn(N1,!0,P)}}function y(Q0,P){var v=Q0+" is deprecated and will be removed in a future version.";if(P)v+=" Use "+P+" instead.";return s(v)}function s(Q0,P,v){if(!A0.warnings)return;var u=new Q(Q0),r;if(P)v._attachExtraTrace(u);else if(A0.longStackTraces&&(r=$._peekContext()))r.attachExtraTrace(u);else{var X0=b0(u);u.stack=X0.message+`
`+q0[B0-1];break}}}var N1="a promise was created in a "+v+"handler "+X0+"but was not returned from it, see http://goo.gl/rRqMUw"+J0;u._warn(N1,!0,B)}}function y(Q0,B){var v=Q0+" is deprecated and will be removed in a future version.";if(B)v+=" Use "+B+" instead.";return s(v)}function s(Q0,B,v){if(!A0.warnings)return;var u=new Q(Q0),r;if(B)v._attachExtraTrace(u);else if(A0.longStackTraces&&(r=$._peekContext()))r.attachExtraTrace(u);else{var X0=i0(u);u.stack=X0.message+`
`)));return}}w=w._target();var M=w._bitField;if((M&50397184)===0)this._yieldedPromise=w,w._proxy(this,null);else if((M&33554432)!==0)$._async.invoke(this._promiseFulfilled,this,w._value());else if((M&16777216)!==0)$._async.invoke(this._promiseRejected,this,w._reason());else this._promiseCancelled()}},$.coroutine=function(V,F){if(typeof V!=="function")throw new K(`generatorFunctionmustbeafunction
`)));return}}w=w._target();var N=w._bitField;if((N&50397184)===0)this._yieldedPromise=w,w._proxy(this,null);else if((N&33554432)!==0)$._async.invoke(this._promiseFulfilled,this,w._value());else if((N&16777216)!==0)$._async.invoke(this._promiseRejected,this,w._reason());else this._promiseCancelled()}},$.coroutine=function(V,F){if(typeof V!=="function")throw new K(`generatorFunctionmustbeafunction
Seehttp://goo.gl/MqrFmX
`);var O=Object(F).yieldHandler,w=q,M=Error().stack;return function(){var N=V.apply(this,arguments),D=new w(void 0,void 0,O,M),B=D.promise();return D._generator=N,D._promiseFulfilled(void 0),B}},$.coroutine.addYieldHandler=function(V){if(typeof V!=="function")throw new K("expecting a function but got "+G.classString(V));X.push(V)},$.spawn=function(V){if(J.deprecated("Promise.spawn()","Promise.coroutine()"),typeof V!=="function")return U(`generatorFunctionmustbeafunction
`);var M=Object(F).yieldHandler,w=q,N=Error().stack;return function(){var O=V.apply(this,arguments),D=new w(void 0,void 0,M,N),P=D.promise();return D._generator=O,D._promiseFulfilled(void 0),P}},$.coroutine.addYieldHandler=function(V){if(typeof V!=="function")throw new K("expecting a function but got "+G.classString(V));X.push(V)},$.spawn=function(V){if(J.deprecated("Promise.spawn()","Promise.coroutine()"),typeof V!=="function")return Y(`generatorFunctionmustbeafunction
`)},U=function(){return new h.PromiseInspection(this._target())},Y=function(k){return h.reject(new X(k))};function z(){}var Q={},J=F4(),I;if(J.isNode)I=function(){var k=process.domain;if(k===void 0)k=null;return k};else I=function(){return null};J.notEnumerableProp(h,"_getDomain",I);var K=mY(),G=TF0(),H=new G;K.defineProperty(h,"_async",{value:H});var W=T3(),X=h.TypeError=W.TypeError;h.RangeError=W.RangeError;var Z=h.CancellationError=W.CancellationError;h.TimeoutError=W.TimeoutError,h.OperationalError=W.OperationalError,h.RejectionError=W.OperationalError,h.AggregateError=W.AggregateError;var q=function(){},V={},F={},O=_F0()(h,q),w=hF0()(h,q,O,Y,z),M=gF0()(h),N=M.create,D=kF0()(h,M),B=D.CapturedTrace,T=fF0()(h,O),A=bF0()(F),j=Ic(),C=J.errorObj,b=J.tryCatch;function x(k,d){if(typeof d!=="function")throw new X("expecting a function but got "+J.classString(d));if(k.constructor!==h)throw new X(`thepromiseconstructorcannotbeinvokeddirectly
`)},Y=function(){return new S.PromiseInspection(this._target())},U=function(k){return S.reject(new X(k))};function z(){}var Q={},J=F4(),I;if(J.isNode)I=function(){var k=process.domain;if(k===void 0)k=null;return k};else I=function(){return null};J.notEnumerableProp(S,"_getDomain",I);var K=lU(),G=jF0(),H=new G;K.defineProperty(S,"_async",{value:H});var W=j3(),X=S.TypeError=W.TypeError;S.RangeError=W.RangeError;var Z=S.CancellationError=W.CancellationError;S.TimeoutError=W.TimeoutError,S.OperationalError=W.OperationalError,S.RejectionError=W.OperationalError,S.AggregateError=W.AggregateError;var q=function(){},V={},F={},M=vF0()(S,q),w=SF0()(S,q,M,U,z),N=yF0()(S),O=N.create,D=xF0()(S,N),P=D.CapturedTrace,T=uF0()(S,M),A=iF0()(F),j=Gc(),C=J.errorObj,b=J.tryCatch;function x(k,d){if(typeof d!=="function")throw new X("expecting a function but got "+J.classString(d));if(k.constructor!==S)throw new X(`thepromiseconstructorcannotbeinvokeddirectly
Seehttp://goo.gl/MqrFmX
`)}function h(k){if(this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,k!==q)x(this,k),this._resolveFromExecutor(k);this._promiseCreated(),this._fireEvent("promiseCreated",this)}h.prototype.toString=function(){return"[object Promise]"},h.prototype.caught=h.prototype.catch=function(k){var d=arguments.length;if(d>1){var t=Array(d-1),$0=0,g;for(g=0;g<d-1;++g){var p=arguments[g];if(J.isObject(p))t[$0++]=p;else return Y("expecting an object but got A catch statement predicate "+J.classString(p))}return t.length=$0,k=arguments[g],this.then(void 0,A(t,k,this))}return this.then(void 0,k)},h.prototype.reflect=function(){return this._then(U,U,void 0,this,void 0)},h.prototype.then=function(k,d){if(D.warnings()&&arguments.length>0&&typeof k!=="function"&&typeof d!=="function"){var t=".then() only accepts functions but was passed: "+J.classString(k);if(arguments.length>1)t+=", "+J.classString(d);this._warn(t)}return this._then(k,d,void 0,void 0,void 0)},h.prototype.done=function(k,d){var t=this._then(k,d,void 0,void 0,void 0);t._setIsFinal()},h.prototype.spread=function(k){if(typeof k!=="function")return Y("expecting a function but got "+J.classString(k));return this.all()._then(k,void 0,void 0,V,void 0)},h.prototype.toJSON=function(){var k={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};if(this.isFulfilled())k.fulfillmentValue=this.value(),k.isFulfilled=!0;else if(this.isRejected())k.rejectionReason=this.reason(),k.isRejected=!0;return k},h.prototype.all=function(){if(arguments.length>0)this._warn(".all() was passed arguments but it does not take any");return new w(this).promise()},h.prototype.error=function(k){return this.caught(J.originatesFromRejection,k)},h.getNewLibraryCopy=Gc.exports,h.is=function(k){return k instanceof h},h.fromNode=h.fromCallback=function(k){var d=new h(q);d._captureStackTrace();var t=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,$0=b(k)(j(d,t));if($0===C)d._rejectCallback($0.e,!0);if(!d._isFateSealed())d._setAsyncGuaranteed();return d},h.all=function(k){return new w(k).promise()},h.cast=function(k){var d=O(k);if(!(d instanceof h))d=new h(q),d._captureStackTrace(),d._setFulfilled(),d._rejectionHandler0=k;return d},h.resolve=h.fulfilled=h.cast,h.reject=h.rejected=function(k){var d=new h(q);return d._captureStackTrace(),d._rejectCallback(k,!0),d},h.setScheduler=function(k){if(typeof k!=="function")throw new X("expecting a function but got "+J.classString(k));return H.setScheduler(k)},h.prototype._then=function(k,d,t,$0,g){var p=g!==void 0,e=p?g:new h(q),y=this._target(),s=y._bitField;if(!p){if(e._propagateFrom(this,3),e._captureStackTrace(),$0===void 0&&(this._bitField&2097152)!==0)if((s&50397184)!==0)$0=this._boundValue();else $0=y===this?void 0:this._boundTo;this._fireEvent("promiseChained",this,e)}var U0=I();if((s&50397184)!==0){var O0,E0,G0=y._settlePromiseCtx;if((s&33554432)!==0)E0=y._rejectionHandler0,O0=k;else if((s&16777216)!==0)E0=y._fulfillmentHandler0,O0=d,y._unsetRejectionIsUnhandled();else G0=y._settlePromiseLateCancellationObserver,E0=new Z("late cancellation observer"),y._attachExtraTrace(E0),O0=d;H.invoke(G0,y,{handler:U0===null?O0:typeof O0==="function"&&J.domainBind(U0,O0),promise:e,receiver:$0,value:E0})}else y._addCallbacks(k,d,e,$0,U0);return e},h.prototype._length=function(){return this._bitField&65535},h.prototype._isFateSealed=function(){return(this._bitField&117506048)!==0},h.prototype._isFollowing=function(){return(this._bitField&67108864)===67108864},h.prototype._setLength=function(k){this._bitField=this._bitField&-65536|k&65535},h.prototype._setFulfilled=function(){this._bitField=this._bitField|33554432,this._fireEvent("promiseFulfilled",this)},h.prototype._setRejected=function(){this._bitField=this._bitField|16777216,this._fireEvent("promiseRejected",this)},h.prototype._setFollowing=function(){this._bitField=this._bitField|67108864,this._fireEvent("promiseResolved",this)},h.prototype._setIsFinal=function(){this._bitField=this._bitField|4194304},h.prototype._isFinal=function(){return(this._bitField&4194304)>0},h.prototype._unsetCancelled=function(){this._bitField=this._bitField&-65537},h.prototype._setCancelled=function(){this._bitField=this._bitField|65536,this._fireEvent("promiseCancelled",this)},h.prototype._setWillBeCancelled=function(){this._bitField=this._bitField|8388608},h.prototype._setAsyncGuaranteed=function(){if(H.hasCustomScheduler())return;this._bitField=this._bitField|134217728},h.prototype._receiverAt=function(k){var d=k===0?this._receiver0:this[k*4-4+3];if(d===Q)return;else if(d===void 0&&this._isBound())return this._boundValue();return d},h.prototype._promiseAt=function(k){return this[k*4-4+2]},h.prototype._fulfillmentHandlerAt=function(k){return this[k*4-4+0]},h.prototype._rejectionHandlerAt=function(k){return this[k*4-4+1]},h.prototype._boundValue=function(){},h.prototype._migrateCallback0=function(k){var{_bitField:d,_fulfillmentHandler
Line truncated
`)}function S(k){if(this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,k!==q)x(this,k),this._resolveFromExecutor(k);this._promiseCreated(),this._fireEvent("promiseCreated",this)}S.prototype.toString=function(){return"[object Promise]"},S.prototype.caught=S.prototype.catch=function(k){var d=arguments.length;if(d>1){var t=Array(d-1),$0=0,g;for(g=0;g<d-1;++g){var p=arguments[g];if(J.isObject(p))t[$0++]=p;else return U("expecting an object but got A catch statement predicate "+J.classString(p))}return t.length=$0,k=arguments[g],this.then(void 0,A(t,k,this))}return this.then(void 0,k)},S.prototype.reflect=function(){return this._then(Y,Y,void 0,this,void 0)},S.prototype.then=function(k,d){if(D.warnings()&&arguments.length>0&&typeof k!=="function"&&typeof d!=="function"){var t=".then() only accepts functions but was passed: "+J.classString(k);if(arguments.length>1)t+=", "+J.classString(d);this._warn(t)}return this._then(k,d,void 0,void 0,void 0)},S.prototype.done=function(k,d){var t=this._then(k,d,void 0,void 0,void 0);t._setIsFinal()},S.prototype.spread=function(k){if(typeof k!=="function")return U("expecting a function but got "+J.classString(k));return this.all()._then(k,void 0,void 0,V,void 0)},S.prototype.toJSON=function(){var k={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};if(this.isFulfilled())k.fulfillmentValue=this.value(),k.isFulfilled=!0;else if(this.isRejected())k.rejectionReason=this.reason(),k.isRejected=!0;return k},S.prototype.all=function(){if(arguments.length>0)this._warn(".all() was passed arguments but it does not take any");return new w(this).promise()},S.prototype.error=function(k){return this.caught(J.originatesFromRejection,k)},S.getNewLibraryCopy=Wc.exports,S.is=function(k){return k instanceof S},S.fromNode=S.fromCallback=function(k){var d=new S(q);d._captureStackTrace();var t=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,$0=b(k)(j(d,t));if($0===C)d._rejectCallback($0.e,!0);if(!d._isFateSealed())d._setAsyncGuaranteed();return d},S.all=function(k){return new w(k).promise()},S.cast=function(k){var d=M(k);if(!(d instanceof S))d=new S(q),d._captureStackTrace(),d._setFulfilled(),d._rejectionHandler0=k;return d},S.resolve=S.fulfilled=S.cast,S.reject=S.rejected=function(k){var d=new S(q);return d._captureStackTrace(),d._rejectCallback(k,!0),d},S.setScheduler=function(k){if(typeof k!=="function")throw new X("expecting a function but got "+J.classString(k));return H.setScheduler(k)},S.prototype._then=function(k,d,t,$0,g){var p=g!==void 0,e=p?g:new S(q),y=this._target(),s=y._bitField;if(!p){if(e._propagateFrom(this,3),e._captureStackTrace(),$0===void 0&&(this._bitField&2097152)!==0)if((s&50397184)!==0)$0=this._boundValue();else $0=y===this?void 0:this._boundTo;this._fireEvent("promiseChained",this,e)}var Y0=I();if((s&50397184)!==0){var N0,E0,G0=y._settlePromiseCtx;if((s&33554432)!==0)E0=y._rejectionHandler0,N0=k;else if((s&16777216)!==0)E0=y._fulfillmentHandler0,N0=d,y._unsetRejectionIsUnhandled();else G0=y._settlePromiseLateCancellationObserver,E0=new Z("late cancellation observer"),y._attachExtraTrace(E0),N0=d;H.invoke(G0,y,{handler:Y0===null?N0:typeof N0==="function"&&J.domainBind(Y0,N0),promise:e,receiver:$0,value:E0})}else y._addCallbacks(k,d,e,$0,Y0);return e},S.prototype._length=function(){return this._bitField&65535},S.prototype._isFateSealed=function(){return(this._bitField&117506048)!==0},S.prototype._isFollowing=function(){return(this._bitField&67108864)===67108864},S.prototype._setLength=function(k){this._bitField=this._bitField&-65536|k&65535},S.prototype._setFulfilled=function(){this._bitField=this._bitField|33554432,this._fireEvent("promiseFulfilled",this)},S.prototype._setRejected=function(){this._bitField=this._bitField|16777216,this._fireEvent("promiseRejected",this)},S.prototype._setFollowing=function(){this._bitField=this._bitField|67108864,this._fireEvent("promiseResolved",this)},S.prototype._setIsFinal=function(){this._bitField=this._bitField|4194304},S.prototype._isFinal=function(){return(this._bitField&4194304)>0},S.prototype._unsetCancelled=function(){this._bitField=this._bitField&-65537},S.prototype._setCancelled=function(){this._bitField=this._bitField|65536,this._fireEvent("promiseCancelled",this)},S.prototype._setWillBeCancelled=function(){this._bitField=this._bitField|8388608},S.prototype._setAsyncGuaranteed=function(){if(H.hasCustomScheduler())return;this._bitField=this._bitField|134217728},S.prototype._receiverAt=function(k){var d=k===0?this._receiver0:this[k*4-4+3];if(d===Q)return;else if(d===void 0&&this._isBound())return this._boundValue();return d},S.prototype._promiseAt=function(k){return this[k*4-4+2]},S.prototype._fulfillmentHandlerAt=function(k){return this[k*4-4+0]},S.prototype._rejectionHandlerAt=function(k){return this[k*4-4+1]},S.prototype._boundValue=function(){},S.prototype._migrateCallback0=function(k){var{_bitField:d,_fulfillmentHandler
Line truncated
`,{mode:384}),U}function Up($){let U=HA0();for(let Y of U){if(!V$(Y))continue;for(let z of kP(Y).filter((Q)=>Q.endsWith(".json")).filter((Q)=>!Q.startsWith("example."))){let Q=N9(Y,z);try{let J=fP(Q,"utf-8"),I=JSON.parse(J);if(I&&typeof I==="object"&&I.id===$)return Q}catch{}}}return}function x2($,U){let Y=Up($);if(!Y)throw Error(`Enterpriseconfignotfound:${$}`);let Q={...JSON.parse(fP(Y,"utf-8")),...U};for(let I of Object.keys(U))if(U[I]===void 0)delete Q[I];let J=an.parse(Q);return zA0(Y,`${JSON.stringify(J,null,2)}
`,"utf-8"),J}var en="SEAL_USE_ENTERPRISES_DIR",QA0="SEAL_HOME_ENTERPRISES_DIR",JA0="SEAL_USE_USER_ENTERPRISES_DIR",IA0="SEAL_HOME_USER_ENTERPRISES_DIR",KA0="SEAL_USE_CONFIG_FILE",GA0="SEAL_HOME_CONFIG_FILE",rI,xP,yP,UA0;var S3=o(()=>{tn();rI=N9(uP(),".config","seal-use","enterprises"),xP=N9(uP(),".config","seal-home","enterprises"),yP=N9(uP(),".config","seal-use","config.json"),UA0=N9(uP(),".config","seal-home","config.json")});function f2($,U,Y=[]){let z=U.corpId?.trim()||void 0,Q=U.stateful?U.defaultCorpId?.trim()||void 0:void 0,J=z??Q;if(J){let K=$.find((W)=>W.id===J);if(K)return K;let G=$.find((W)=>W.id.toLowerCase()===J.toLowerCase());if(G)return G;let H=$.find((W)=>W.name.toLowerCase()===J.toLowerCase());if(H)return H;throw Error(`Noenterpriseconfigfoundfor${J}`)}if(!U.stateful)throw Error("Stateless mode is enabled. Every enterprise command requires --corp <corpId>. Use `seal-homeconfigmodestateful` to enable a default enterprise.");let I=$[0];if(I)return I;throw Error("No enterprise config found. Add a non-example JSON file under one of: "+(Y.length?Y.join(", "):"the configured enterprise directories"))}import{existsSync as Yp,mkdirSync as gN1,readFileSync as yN1,renameSync as kN1,unlinkSync as xN1,writeFileSync as fN1}from"node:fs";import{homedir as uN1}from"node:os";import{dirname as bN1,join as iN1}from"node:path";function _Z(){let $=process.env[cN1]?.trim();if($)return $;return nN1}function WA0($=new Date){return $.toISOString().slice(0,10)}function XA0($=zp,U=new Date){let Y=U.getTime()-Math.max(0,$-1)*86400000;return new Date(Y).toISOString().slice(0,10)}function ZA0($=_Z()){if(!Yp($))return{};try{let U=yN1($,"utf-8"),Y=JSON.parse(U);if(Y&&typeof Y==="object"&&!Array.isArray(Y))return Y;return{}}catch{return{}}}function pN1($,U){let Y={};for(let[z,Q]of Object.entries($)){if(!Q||typeof Q!=="object")continue;let J={},I=!1;for(let[K,G]of Object.entries(Q))if(typeof G==="number"&&G>0&&K>=U)J[K]=G,I=!0;if(I)Y[z]=J}return Y}function dN1($,U=_Z()){let Y=bN1(U);if(!Yp(Y))gN1(Y,{recursive:!0,mode:448});let z=`${U}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2,8)}.tmp`;try{fN1(z,JSON.stringify($,null,2),{encoding:"utf-8",mode:384}),kN1(z,U)}catch(Q){try{if(Yp(z))xN1(z)}catch{}throw Q}}function qA0($,U=new Date){if(!$||typeof $!=="string")return;try{let Y=_Z(),z=ZA0(Y),Q=WA0(U),J=XA0(zp,U),I=pN1(z,J);I[$]=I[$]||{},I[$][Q]=(I[$][Q]??0)+1,dN1(I,Y)}catch{}}function mN1($,U=zp,Y=new Date){let z=new Map;try{let Q=ZA0(),J=XA0(U,Y),I=WA0(Y),K=$??Object.keys(Q);for(let G of K){let H=Q[G];if(!H){z.set(G,0);continue}let W=0;for(let[X,Z]of Object.entries(H))if(X>=J&&X<=I&&typeof Z==="number")W+=Z;z.set(G,W)}}catch{if($)for(let Q of $)z.set(Q,0)}return z}function VA0($,U,Y){let z=Y??mN1($.map((Q)=>Q.id));return[...$].sort((Q,J)=>{if(U){if(Q.id===U&&J.id!==U)return-1;if(J.id===U&&Q.id!==U)return 1}let I=z.get(Q.id)??0,K=z.get(J.id)??0;if(I!==K)return K-I;let G=Q.name??Q.id,H=J.name??J.id,W=G.localeCompare(H,"zh-CN");if(W!==0)return W;return Q.id.localeCompare(J.id)})}var cN1="SEAL_USE_USAGE_FILE",nN1,zp=7;var bP=o(()=>{nN1=iN1(uN1(),".config","seal-use","usage.json")});function lN1($,U){return $.map((Y)=>Y.trim()).filter(Boolean).map((Y)=>U?Y:Y.toLowerCase())}function oN1($,U){return U?$:$.toLowerCase()}function rN1($,U,Y,z){let Q=oN1($,z),J=U.filter((I)=>Q.includes(I));if(Y==="all"&&J.length!==U.length)return[];return J}function sN1($){if(typeof $==="string")return $.split(/\r?\n/);return JSON.stringify($,null,2).split(/\r?\n/)}function aN1($,U){if(U.fields&&!U.fields.has($.field))return[];let Y=sN1($.value),z=[];return Y.forEach((Q,J)=>{let I=rN1(Q,U.keywords,U.matchMode,U.caseSensitive);if(I.length===0)return;let K=Math.max(0,J-U.contextLines),G=Math.min(Y.length,J+U.contextLines+1),H={area:$.area,entityType:$.entityType,entityId:$.entityId,title:$.title,field:$.field,lineNumber:J+1,matchedKeywords:I,matchedText:iP(Q,U.maxChars),context:{before:U.snippetOnly?[]:Y.slice(K,J).map((W)=>iP(W,U.maxChars)),line:iP(Q,U.maxChars),after:U.snippetOnly?[]:Y.slice(J+1,G).map((W)=>iP(W,U.maxChars))},metadata:$.metadata};if(U.snippetOnly)H.context={before:[],line:H.context.line,after:[]};z.push(H)}),z}function iP($,U){if(!U||$.length<=U)return $;return`${$.slice(0,Math.max(0,U))}...`}function tN1($){return[{area:"rules",entityType:"rule",entityId:$.id,title:$.scope,field:"description",value:$.description,metadata:{scope:$.scope,strictness:$.strictness,status:$.status}},{area:"rules",entityType:"rule",entityId:$.id,title:$.scope,field:"scope",value:$.scope,metadata:{strictness:$.strictness,status:$.status}}]}function FA0($){return $.rules.flatMap((U,Y)=>{let z=`${$.id}:${U.description.slice(0,32)}`,Q={versionId:$.id,versionNumber:$.versionNumber,versionName:$.versionName,publishedByName:$.publishedByName,publishedAt:$.publishedAt,scope:U.scope,strictness:U.strictness,code:"code"in U?U.code:void 0,index:Y};return[{area:"rules",entityType:"rule",entityId:z,title:`${$.versionName}/${U.scope}`,field:"h
Line truncated
`,{mode:384}),Y}function zp($){let Y=WA0();for(let U of Y){if(!V$(U))continue;for(let z of xB(U).filter((Q)=>Q.endsWith(".json")).filter((Q)=>!Q.startsWith("example."))){let Q=D9(U,z);try{let J=uB(Q,"utf-8"),I=JSON.parse(J);if(I&&typeof I==="object"&&I.id===$)return Q}catch{}}}return}function g3($,Y){let U=zp($);if(!U)throw Error(`Enterpriseconfignotfound:${$}`);let Q={...JSON.parse(uB(U,"utf-8")),...Y};for(let I of Object.keys(Y))if(Y[I]===void 0)delete Q[I];let J=en.parse(Q);return QA0(U,`${JSON.stringify(J,null,2)}
`,"utf-8"),J}var Yp="SEAL_USE_ENTERPRISES_DIR",JA0="SEAL_HOME_ENTERPRISES_DIR",IA0="SEAL_USE_USER_ENTERPRISES_DIR",KA0="SEAL_HOME_USER_ENTERPRISES_DIR",GA0="SEAL_USE_CONFIG_FILE",HA0="SEAL_HOME_CONFIG_FILE",aI,fB,kB,UA0;var y3=m(()=>{$p();aI=D9(bB(),".config","seal-use","enterprises"),fB=D9(bB(),".config","seal-home","enterprises"),kB=D9(bB(),".config","seal-use","config.json"),UA0=D9(bB(),".config","seal-home","config.json")});function u2($,Y,U=[]){let z=Y.corpId?.trim()||void 0,Q=Y.stateful?Y.defaultCorpId?.trim()||void 0:void 0,J=z??Q;if(J){let K=$.find((W)=>W.id===J);if(K)return K;let G=$.find((W)=>W.id.toLowerCase()===J.toLowerCase());if(G)return G;let H=$.find((W)=>W.name.toLowerCase()===J.toLowerCase());if(H)return H;throw Error(`Noenterpriseconfigfoundfor${J}`)}if(!Y.stateful)throw Error("Stateless mode is enabled. Every enterprise command requires --corp <corpId>. Use `seal-homeconfigmodestateful` to enable a default enterprise.");let I=$[0];if(I)return I;throw Error("No enterprise config found. Add a non-example JSON file under one of: "+(U.length?U.join(", "):"the configured enterprise directories"))}import{existsSync as Qp,mkdirSync as bN1,readFileSync as iN1,renameSync as cN1,unlinkSync as nN1,writeFileSync as pN1}from"node:fs";import{homedir as dN1}from"node:os";import{dirname as mN1,join as lN1}from"node:path";function _Z(){let $=process.env[oN1]?.trim();if($)return $;return rN1}function XA0($=new Date){return $.toISOString().slice(0,10)}function ZA0($=Jp,Y=new Date){let U=Y.getTime()-Math.max(0,$-1)*86400000;return new Date(U).toISOString().slice(0,10)}function qA0($=_Z()){if(!Qp($))return{};try{let Y=iN1($,"utf-8"),U=JSON.parse(Y);if(U&&typeof U==="object"&&!Array.isArray(U))return U;return{}}catch{return{}}}function sN1($,Y){let U={};for(let[z,Q]of Object.entries($)){if(!Q||typeof Q!=="object")continue;let J={},I=!1;for(let[K,G]of Object.entries(Q))if(typeof G==="number"&&G>0&&K>=Y)J[K]=G,I=!0;if(I)U[z]=J}return U}function aN1($,Y=_Z()){let U=mN1(Y);if(!Qp(U))bN1(U,{recursive:!0,mode:448});let z=`${Y}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2,8)}.tmp`;try{pN1(z,JSON.stringify($,null,2),{encoding:"utf-8",mode:384}),cN1(z,Y)}catch(Q){try{if(Qp(z))nN1(z)}catch{}throw Q}}function VA0($,Y=new Date){if(!$||typeof $!=="string")return;try{let U=_Z(),z=qA0(U),Q=XA0(Y),J=ZA0(Jp,Y),I=sN1(z,J);I[$]=I[$]||{},I[$][Q]=(I[$][Q]??0)+1,aN1(I,U)}catch{}}function tN1($,Y=Jp,U=new Date){let z=new Map;try{let Q=qA0(),J=ZA0(Y,U),I=XA0(U),K=$??Object.keys(Q);for(let G of K){let H=Q[G];if(!H){z.set(G,0);continue}let W=0;for(let[X,Z]of Object.entries(H))if(X>=J&&X<=I&&typeof Z==="number")W+=Z;z.set(G,W)}}catch{if($)for(let Q of $)z.set(Q,0)}return z}function LA0($,Y,U){let z=U??tN1($.map((Q)=>Q.id));return[...$].sort((Q,J)=>{if(Y){if(Q.id===Y&&J.id!==Y)return-1;if(J.id===Y&&Q.id!==Y)return 1}let I=z.get(Q.id)??0,K=z.get(J.id)??0;if(I!==K)return K-I;let G=Q.name??Q.id,H=J.name??J.id,W=G.localeCompare(H,"zh-CN");if(W!==0)return W;return Q.id.localeCompare(J.id)})}var oN1="SEAL_USE_USAGE_FILE",rN1,Jp=7;var iB=m(()=>{rN1=lN1(dN1(),".config","seal-use","usage.json")});function eN1($,Y){return $.map((U)=>U.trim()).filter(Boolean).map((U)=>Y?U:U.toLowerCase())}function $D1($,Y){return Y?$:$.toLowerCase()}function YD1($,Y,U,z){let Q=$D1($,z),J=Y.filter((I)=>Q.includes(I));if(U==="all"&&J.length!==Y.length)return[];return J}function UD1($){if(typeof $==="string")return $.split(/\r?\n/);return JSON.stringify($,null,2).split(/\r?\n/)}function zD1($,Y){if(Y.fields&&!Y.fields.has($.field))return[];let U=UD1($.value),z=[];return U.forEach((Q,J)=>{let I=YD1(Q,Y.keywords,Y.matchMode,Y.caseSensitive);if(I.length===0)return;let K=Math.max(0,J-Y.contextLines),G=Math.min(U.length,J+Y.contextLines+1),H={area:$.area,entityType:$.entityType,entityId:$.entityId,title:$.title,field:$.field,lineNumber:J+1,matchedKeywords:I,matchedText:cB(Q,Y.maxChars),context:{before:Y.snippetOnly?[]:U.slice(K,J).map((W)=>cB(W,Y.maxChars)),line:cB(Q,Y.maxChars),after:Y.snippetOnly?[]:U.slice(J+1,G).map((W)=>cB(W,Y.maxChars))},metadata:$.metadata};if(Y.snippetOnly)H.context={before:[],line:H.context.line,after:[]};z.push(H)}),z}function cB($,Y){if(!Y||$.length<=Y)return $;return`${$.slice(0,Math.max(0,Y))}...`}function QD1($){return[{area:"rules",entityType:"rule",entityId:$.id,title:$.scope,field:"description",value:$.description,metadata:{scope:$.scope,strictness:$.strictness,status:$.status}},{area:"rules",entityType:"rule",entityId:$.id,title:$.scope,field:"scope",value:$.scope,metadata:{strictness:$.strictness,status:$.status}}]}function wA0($){return $.rules.flatMap((Y,U)=>{let z=`${$.id}:${Y.description.slice(0,32)}`,Q={versionId:$.id,versionNumber:$.versionNumber,versionName:$.versionName,publishedByName:$.publishedByName,publishedAt:$.publishedAt,scope:Y.scope,strictness:Y.strictness,code:"code"in Y?Y.code:void 0,index:U};return[{area:"rules",entityType:"rule",entityId:z,title:`${$.versionName}/${Y.scope}`,field:"h
Line truncated
@@ -876,47 +876,47 @@ export function lintRule(rule: RuleLintTarget): RuleLintResult {
}
exportdefaultlintRule;
`}});import{existsSync as Hz,mkdirSync as BD1,readFileSync as TD1,readdirSync as CA0,rmSync as jD1,unlinkSync as ED1,writeFileSync as CD1}from"node:fs";import{homedir as RD1}from"node:os";import{isAbsolute as _D1,join as f6,resolve as vD1}from"node:path";import{pathToFileURL as jA0}from"node:url";function RA0($=i$){let U=[],Y=[];try{if(!Hz($))BD1($,{recursive:!0});let z=Object.keys(Wp);for(let[J,I]of Object.entries(Wp)){let K=f6($,J),G=!0;if(Hz(K))try{if(TD1(K,"utf8")===I)G=!1}catch{G=!0}if(G)CD1(K,I,"utf8");U.push(J)}let Q=CA0($,{withFileTypes:!0});for(let J of Q)if(!z.includes(J.name)){let I=f6($,J.name);try{if(J.isDirectory())jD1(I,{recursive:!0,force:!0});else ED1(I);Y.push(J.name)}catch{}}}catch{}return{synced:U,pruned:Y}}function _A0($={syncOfficial:!0}){if($.syncOfficial!==!1)RA0();let U=[{name:"builtin",type:"builtin",path:f6(i$,"builtin.ts"),description:"Seal 官方标准校验器 (拦截过短描述、主观模糊词与悬空例外条款)"},{name:"strict",type:"official",path:f6(i$,"strict.ts"),description:"Seal 官方严格风控校验器 (强校验字数、刚性定量约束、凭证依据与具体审批人角色)"},{name:"hlab",type:"official",path:f6(i$,"hlab.ts"),description:"合思实验室 (HLab) 结构化规则校验器 (SOP 四段论结构、三元闭环判定、剥离处置动作与防漏判)"}],Y=[b$,dP];for(let z of Y)if(Hz(z))try{let Q=CA0(z,{withFileTypes:!0});for(let J of Q){if(J.isDirectory())continue;let I=J.name;if(I.endsWith(".ts")||I.endsWith(".js")||I.endsWith(".mjs")){let K=I.replace(/\.(ts|js|mjs)$/,"");if(!U.some((G)=>G.name===K))U.push({name:K,type:"custom",path:f6(z,I),description:`用户自定义规则校验器(${I})`})}}}catch{}return U}function SD1($){let U=($||"").trim();if(!U||U==="builtin"||U==="default"||U==="official/builtin"||U==="official/builtin.ts")return{path:f6(i$,"builtin.ts"),isOfficial:!0,officialKind:"builtin"};if(U==="strict"||U==="official/strict"||U==="official/strict.ts")return{path:f6(i$,"strict.ts"),isOfficial:!0,officialKind:"strict"};if(U==="hlab"||U==="hlab-sop"||U==="hlab-rules"||U==="hlab-standard"||U==="official/hlab"||U==="official/hlab.ts")return{path:f6(i$,"hlab.ts"),isOfficial:!0,officialKind:"hlab"};if(_D1(U)||U.startsWith("./")||U.startsWith("../")){let z=vD1(U);if(Hz(z))return{path:z};for(let Q of[".ts",".js",".mjs"])if(Hz(`${z}${Q}`))return{path:`${z}${Q}`}}let Y=[f6(b$,`${U}.ts`),f6(b$,`${U}.js`),f6(b$,`${U}.mjs`),f6(dP,`${U}.ts`),f6(dP,`${U}.js`),f6(dP,`${U}.mjs`)];for(let z of Y)if(Hz(z))return{path:z};return{}}async function Zp($){RA0();let U=SD1($??"builtin");if(U.isOfficial){let z=U.officialKind==="strict"?BA0:U.officialKind==="hlab"?TA0:aI,Q=U.officialKind==="builtin"?"builtin":"official",J=U.path;if(J&&Hz(J))try{let K=await import(jA0(J).href),G=K.default??K.lintRule??K.linter??K.lint;if(typeof G==="function")return{name:U.officialKind??"builtin",type:Q,filePath:J,linter:EA0(G,z)}}catch{}return{name:U.officialKind??"builtin",type:Q,filePath:J,linter:z}}let Y=U.path;if(!Y)return console.error(`⚠️[linter]未找到自定义校验器"${$}",已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:aI};try{let Q=await import(jA0(Y).href),J=Q.default??Q.lintRule??Q.linter??Q.lint;if(typeof J!=="function")return console.error(`⚠️[linter]自定义校验器"${Y}"未导出标准函数(default/lintRule),已安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:aI};return{name:$??"custom",type:"custom",filePath:Y,linter:EA0(J,aI)}}catch(z){returnconsole.error(`⚠️[linter]加载自定义校验器脚本"${Y}"失败(语法错误或依赖缺失:${z?.message??z}),已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:aI}}}functionEA0($,U){returnasync(Y,z)=>{try{letQ=await$(Y,z);if(Q&&typeofQ==="object"&&typeofQ.score==="number"&&Array.isArray(Q.issues))returnQ;returnconsole.error("⚠️[linter]自定义校验器返回值格式不符合RuleLintResult契约,已回退至内置结果。"),U(Y,z)}catch(Q){returnconsole.error("⚠️[linter]自定义校验器执行异常:",Q),U(Y,z)}}}varb$,hD1="official",i$,dP;varqp=o(()=>{Kp();Hp();Xp();Gp();b$=f6(RD1(),".config","seal-use","linters"),i$=f6(b$,hD1),dP=f6(process.cwd(),"linters")});asyncfunctionVp($,U,Y){letz=awaitU.linter($,Y);return{ruleId:$.id,ruleCode:$.code,ruleName:$.name,score:z.score,passed:z.passed,issues:z.issues,description:$.description}}asyncfunctionvA0($,U,Y,z){letQ=z?.minScore??0,J=z?.level??"all",I=[],K=0;for(letqof$){letV=awaitVp(q,U,Y);K+=V.score;letF=V.issues;if(J==="error")F=V.issues.filter((w)=>w.level==="error");elseif(J==="warning")F=V.issues.filter((w)=>w.level==="warning"||w.level==="error");letO=F.every((w)=>w.level!=="error");if(z?.summary){if(F.length>0)I.push({...V,passed:O,issues:F})}elseI.push({...V,passed:O,issues:F})}letG=$.length,H=G===0?100:Math.round(K/G),W=I.filter((q)=>q.issues.length>0).length,X=G-Line truncated
`}});import{existsSync as Wz,mkdirSync as _D1,readFileSync as vD1,readdirSync as RA0,rmSync as hD1,unlinkSync as SD1,writeFileSync as gD1}from"node:fs";import{homedir as yD1}from"node:os";import{isAbsolute as kD1,join as f6,resolve as xD1}from"node:path";import{pathToFileURL as EA0}from"node:url";function _A0($=i$){let Y=[],U=[];try{if(!Wz($))_D1($,{recursive:!0});let z=Object.keys(Zp);for(let[J,I]of Object.entries(Zp)){let K=f6($,J),G=!0;if(Wz(K))try{if(vD1(K,"utf8")===I)G=!1}catch{G=!0}if(G)gD1(K,I,"utf8");Y.push(J)}let Q=RA0($,{withFileTypes:!0});for(let J of Q)if(!z.includes(J.name)){let I=f6($,J.name);try{if(J.isDirectory())hD1(I,{recursive:!0,force:!0});else SD1(I);U.push(J.name)}catch{}}}catch{}return{synced:Y,pruned:U}}function vA0($={syncOfficial:!0}){if($.syncOfficial!==!1)_A0();let Y=[{name:"builtin",type:"builtin",path:f6(i$,"builtin.ts"),description:"Seal 官方标准校验器 (拦截过短描述、主观模糊词与悬空例外条款)"},{name:"strict",type:"official",path:f6(i$,"strict.ts"),description:"Seal 官方严格风控校验器 (强校验字数、刚性定量约束、凭证依据与具体审批人角色)"},{name:"hlab",type:"official",path:f6(i$,"hlab.ts"),description:"合思实验室 (HLab) 结构化规则校验器 (SOP 四段论结构、三元闭环判定、剥离处置动作与防漏判)"}],U=[b$,mB];for(let z of U)if(Wz(z))try{let Q=RA0(z,{withFileTypes:!0});for(let J of Q){if(J.isDirectory())continue;let I=J.name;if(I.endsWith(".ts")||I.endsWith(".js")||I.endsWith(".mjs")){let K=I.replace(/\.(ts|js|mjs)$/,"");if(!Y.some((G)=>G.name===K))Y.push({name:K,type:"custom",path:f6(z,I),description:`用户自定义规则校验器(${I})`})}}}catch{}return Y}function uD1($){let Y=($||"").trim();if(!Y||Y==="builtin"||Y==="default"||Y==="official/builtin"||Y==="official/builtin.ts")return{path:f6(i$,"builtin.ts"),isOfficial:!0,officialKind:"builtin"};if(Y==="strict"||Y==="official/strict"||Y==="official/strict.ts")return{path:f6(i$,"strict.ts"),isOfficial:!0,officialKind:"strict"};if(Y==="hlab"||Y==="hlab-sop"||Y==="hlab-rules"||Y==="hlab-standard"||Y==="official/hlab"||Y==="official/hlab.ts")return{path:f6(i$,"hlab.ts"),isOfficial:!0,officialKind:"hlab"};if(kD1(Y)||Y.startsWith("./")||Y.startsWith("../")){let z=xD1(Y);if(Wz(z))return{path:z};for(let Q of[".ts",".js",".mjs"])if(Wz(`${z}${Q}`))return{path:`${z}${Q}`}}let U=[f6(b$,`${Y}.ts`),f6(b$,`${Y}.js`),f6(b$,`${Y}.mjs`),f6(mB,`${Y}.ts`),f6(mB,`${Y}.js`),f6(mB,`${Y}.mjs`)];for(let z of U)if(Wz(z))return{path:z};return{}}async function Vp($){_A0();let Y=uD1($??"builtin");if(Y.isOfficial){let z=Y.officialKind==="strict"?TA0:Y.officialKind==="hlab"?jA0:eI,Q=Y.officialKind==="builtin"?"builtin":"official",J=Y.path;if(J&&Wz(J))try{let K=await import(EA0(J).href),G=K.default??K.lintRule??K.linter??K.lint;if(typeof G==="function")return{name:Y.officialKind??"builtin",type:Q,filePath:J,linter:CA0(G,z)}}catch{}return{name:Y.officialKind??"builtin",type:Q,filePath:J,linter:z}}let U=Y.path;if(!U)return console.error(`⚠️[linter]未找到自定义校验器"${$}",已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:eI};try{let Q=await import(EA0(U).href),J=Q.default??Q.lintRule??Q.linter??Q.lint;if(typeof J!=="function")return console.error(`⚠️[linter]自定义校验器"${U}"未导出标准函数(default/lintRule),已安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:eI};return{name:$??"custom",type:"custom",filePath:U,linter:CA0(J,eI)}}catch(z){returnconsole.error(`⚠️[linter]加载自定义校验器脚本"${U}"失败(语法错误或依赖缺失:${z?.message??z}),已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:eI}}}functionCA0($,Y){returnasync(U,z)=>{try{letQ=await$(U,z);if(Q&&typeofQ==="object"&&typeofQ.score==="number"&&Array.isArray(Q.issues))returnQ;returnconsole.error("⚠️[linter]自定义校验器返回值格式不符合RuleLintResult契约,已回退至内置结果。"),Y(U,z)}catch(Q){returnconsole.error("⚠️[linter]自定义校验器执行异常:",Q),Y(U,z)}}}varb$,fD1="official",i$,mB;varLp=m(()=>{Hp();Xp();qp();Wp();b$=f6(yD1(),".config","seal-use","linters"),i$=f6(b$,fD1),mB=f6(process.cwd(),"linters")});asyncfunctionFp($,Y,U){letz=awaitY.linter($,U);return{ruleId:$.id,ruleCode:$.code,ruleName:$.name,score:z.score,passed:z.passed,issues:z.issues,description:$.description}}asyncfunctionhA0($,Y,U,z){letQ=z?.minScore??0,J=z?.level??"all",I=[],K=0;for(letqof$){letV=awaitFp(q,Y,U);K+=V.score;letF=V.issues;if(J==="error")F=V.issues.filter((w)=>w.level==="error");elseif(J==="warning")F=V.issues.filter((w)=>w.level==="warning"||w.level==="error");letM=F.every((w)=>w.level!=="error");if(z?.summary){if(F.length>0)I.push({...V,passed:M,issues:F})}elseI.push({...V,passed:M,issues:F})}letG=$.length,H=G===0?100:Math.round(K/G),W=I.filter((q)=>q.issues.length>0).length,X=G-Line truncated
`),z=await Promise.all(N.map((D)=>H4($,D.id)))}let Q=new Map,J=0;for(let w of z){let M=w.document,N=w.sourceDocumentId??(typeof M?.id==="string"?M.id:void 0)??(typeof M?.sourceDocumentId==="string"?M.sourceDocumentId:void 0)??w.documentId??w.id,D=`${Y.docIdPrefix??""}${N}${Y.docIdSuffix??""}`,B=[];if(Y.includeAttachments!==!1){let A=k2(w,{summary:!1}).attachments,j=new Set;for(let C of A){let b=C.ossSignedUrl??C.url;if(!b)continue;let x=C.fileName??C.fileId??"attachment",h=on(x),i=h,c=h.lastIndexOf("."),z0=c>0?h.slice(0,c):h,k=c>0?h.slice(c):"",d=1;while(j.has(i.toLowerCase()))i=`${z0}_${d}${k}`,d++;j.add(i.toLowerCase());try{process.stderr.write(`⬇下载单据「${D}」附件:${x}...
`),await new Promise((w,M)=>{let N=Gh1(V),D=new Il({zlib:{level:9}});N.on("close",()=>w()),D.on("error",(B)=>M(B)),D.pipe(N),D.append(Buffer.from(F),{name:"信息表.xlsx"});for(let B of Q.values())for(let T of B)D.append(T.buffer,{name:T.zipPath});D.finalize()});let O=Wh1(V);return{filePath:V,corpId:U.id,corpName:U.name,recordCount:z.length,attachmentCount:J,fileSizeBytes:O.size,exportedAt:new Date().toISOString(),nextAction:`seal-usewebhookresource-packpush${V}--corp<targetCorpId>`}}var kR0;var Kl=o(()=>{gR0();X6();SP();kR0=J6(EZ(),1)});import{readFileSync as Lh1}from"node:fs";function Fh1($){let U=new URL($),Y=U.pathname.match(/\/webhook\/([^/]+)/);if(!Y)throw Error("Webhook URL 必须包含 /webhook/{webhookId}/document");return{baseUrl:`${U.protocol}//${U.host}`,webhookId:Y[1]}}function wh1($,U){return U.toLowerCase().endsWith(".zip")||$[0]===80&&$[1]===75&&!U.toLowerCase().endsWith(".xlsx")}function Oh1($,U){if(!$.length)return;let Y=new Set($.map((J)=>{let I=J.fileName.split("/")[0],K=I.indexOf("@");return K>=0?I.slice(0,K):I}).filter((J)=>J!=="信息表.xlsx")),z=[];for(let J of U){let I=J.document.documentId;if((J.documentAttachments.length>0||Object.values(J.expenseAttachments).some((G)=>G.length>0)||Object.values(J.personAttachments).some((G)=>G.length>0))&&!Y.has(I))z.push(`Excel 会议编号「${I}」声明了附件,但在 ZIP 中找不到对应的根目录「${I}/」或「${I}@.../」。`)}let Q=new Set(U.map((J)=>J.document.documentId));for(let J of Y)if(!Q.has(J))z.push(`ZIP 根目录对应的编号「${J}」在信息表中找不到对应的会议编号。`);if(z.length)throw new D5(z)}async function xR0($,U,Y){let z=[],Q=$;if(wh1($,U)){z=await lP0($),rP0(z,Y);let G=z.find((H)=>H.fileName==="信息表.xlsx");if(!G)throw Error("ZIP 根目录缺少信息表.xlsx");Q=await Kd($,G)}let J=await YB0(Q);Oh1(z,J);let I=zB0(z,J),K=J.map((G)=>G.document);return{entries:z,parsed:J,plans:I,documents:K,fileBuffer:$}}async function _z($,U,Y){let z=await xR0($,U,Y),Q=z.parsed.map((J,I)=>qd(J.document,z.plans[I],new Map));return{warnings:[],documents:Q,attachmentPlan:z.plans}}async function YT($,U,Y){let z=await xR0($,U,Y.materialPackFilePolicy),{baseUrl:Q,webhookId:J}=Fh1(Y.webhookUrl),I=[];for(let K=0;K<z.parsed.length;K+=1){let G=z.parsed[K],H=z.plans[K],W=new Map,X=[...H.categoryFields,...Object.values(H.personAttachments).flat(),...Object.values(H.expenseAttachments).flat()];for(let V of X)for(let F of V.paths){if(W.has(F))continue;let O=z.entries.find((T)=>T.fileName===F);if(!O)continue;process.stderr.write(`⬆ 上传附件: ${F}
`),z=await Promise.all(O.map((D)=>H4($,D.id)))}let Q=new Map,J=0;for(let w of z){let N=w.document,O=w.sourceDocumentId??(typeof N?.id==="string"?N.id:void 0)??(typeof N?.sourceDocumentId==="string"?N.sourceDocumentId:void 0)??w.documentId??w.id,D=`${U.docIdPrefix??""}${O}${U.docIdSuffix??""}`,P=[];if(U.includeAttachments!==!1){let A=f2(w,{summary:!1}).attachments,j=new Set;for(let C of A){let b=C.ossSignedUrl??C.url;if(!b)continue;let x=C.fileName??C.fileId??"attachment",S=sn(x),i=S,c=S.lastIndexOf("."),z0=c>0?S.slice(0,c):S,k=c>0?S.slice(c):"",d=1;while(j.has(i.toLowerCase()))i=`${z0}_${d}${k}`,d++;j.add(i.toLowerCase());try{process.stderr.write(`⬇下载单据「${D}」附件:${x}...
`),await new Promise((w,N)=>{let O=Vh1(V),D=new Gl({zlib:{level:9}});O.on("close",()=>w()),D.on("error",(P)=>N(P)),D.pipe(O),D.append(Buffer.from(F),{name:"信息表.xlsx"});for(let P of Q.values())for(let T of P)D.append(T.buffer,{name:T.zipPath});D.finalize()});let M=Fh1(V);return{filePath:V,corpId:Y.id,corpName:Y.name,recordCount:z.length,attachmentCount:J,fileSizeBytes:M.size,exportedAt:new Date().toISOString(),nextAction:`seal-usewebhookresource-packpush${V}--corp<targetCorpId>`}}var xR0;var Hl=m(()=>{yR0();X6();gB();xR0=J6(EZ(),1)});import{readFileSync as Dh1}from"node:fs";function Ah1($){let Y=new URL($),U=Y.pathname.match(/\/webhook\/([^/]+)/);if(!U)throw Error("Webhook URL 必须包含 /webhook/{webhookId}/document");return{baseUrl:`${Y.protocol}//${Y.host}`,webhookId:U[1]}}function Bh1($,Y){return Y.toLowerCase().endsWith(".zip")||$[0]===80&&$[1]===75&&!Y.toLowerCase().endsWith(".xlsx")}function Ph1($,Y){if(!$.length)return;let U=new Set($.map((J)=>{let I=J.fileName.split("/")[0],K=I.indexOf("@");return K>=0?I.slice(0,K):I}).filter((J)=>J!=="信息表.xlsx")),z=[];for(let J of Y){let I=J.document.documentId;if((J.documentAttachments.length>0||Object.values(J.expenseAttachments).some((G)=>G.length>0)||Object.values(J.personAttachments).some((G)=>G.length>0))&&!U.has(I))z.push(`Excel 会议编号「${I}」声明了附件,但在 ZIP 中找不到对应的根目录「${I}/」或「${I}@.../」。`)}let Q=new Set(Y.map((J)=>J.document.documentId));for(let J of U)if(!Q.has(J))z.push(`ZIP 根目录对应的编号「${J}」在信息表中找不到对应的会议编号。`);if(z.length)throw new D5(z)}async function fR0($,Y,U){let z=[],Q=$;if(Bh1($,Y)){z=await oB0($),sB0(z,U);let G=z.find((H)=>H.fileName==="信息表.xlsx");if(!G)throw Error("ZIP 根目录缺少信息表.xlsx");Q=await Hd($,G)}let J=await zP0(Q);Ph1(z,J);let I=QP0(z,J),K=J.map((G)=>G.document);return{entries:z,parsed:J,plans:I,documents:K,fileBuffer:$}}async function vz($,Y,U){let z=await fR0($,Y,U),Q=z.parsed.map((J,I)=>Ld(J.document,z.plans[I],new Map));return{warnings:[],documents:Q,attachmentPlan:z.plans}}async function zT($,Y,U){let z=await fR0($,Y,U.materialPackFilePolicy),{baseUrl:Q,webhookId:J}=Ah1(U.webhookUrl),I=[];for(let K=0;K<z.parsed.length;K+=1){let G=z.parsed[K],H=z.plans[K],W=new Map,X=[...H.categoryFields,...Object.values(H.personAttachments).flat(),...Object.values(H.expenseAttachments).flat()];for(let V of X)for(let F of V.paths){if(W.has(F))continue;let M=z.entries.find((T)=>T.fileName===F);if(!M)continue;process.stderr.write(`⬆ 上传附件: ${F}
`+"• 安全边界:该凭证绝不包含且无法访问合思 (Hose) 主系统;仅限内部排查,严禁在外部公开分享!")}return{url:U.sso?W:H,sealResultUrl:H,ssoUrl:W,type:U.sso?"sso_link":"deep_link",expiresIn:U.sso?q:void 0,identity:X,warning:Z,enterpriseAssistUrl:I,enterpriseUrl:I,hoseDomain:J.type==="hose"?oh1(J.domain):void 0,documentUrl:K,recordId:Q?.id,sourceDocumentSN:Q?.sourceDocumentSN,sourceDocumentId:Q?.sourceDocumentId,sourceSystem:Q?.sourceSystem,missing:{enterpriseAssistUrl:I?void 0:"Current enterprise source is not Hose, so no Hose enterprise assist URL is configured.",documentUrl:z&&!K?"sourceExtendData.hosecloudViewUrl is absent from the approval run detail.":void 0}}}},{name:"seal_approval_run_pick",description:"按合思单号或关键字查询运行记录,返回候选记录及其当时使用的规则版本,便于再取详情或查版本规则",parameters:L.object({query:L.string().optional().describe("合思单号、源单据 ID、运行记录 ID 或 trace 关键字"),sn:L.string().optional().describe("合思/易快报单号;优先作为精确 sourceDocumentSN 查询"),batchId:L.string().optional().describe("模拟批次 ID"),latest:L.boolean().optional().describe("只返回最新一条匹配记录"),fields:L.union([L.string(),L.array(L.string())]).optional().describe("限制返回字段"),limit:L.number().int().positive().max(100).optional(),maxScan:L.number().int().positive().max(5000).optional().describe("最多扫描多少条运行记录用于本地匹配,默认 1000"),includeBridge:L.boolean().optional()}),handler:async($,U)=>{let Y=U.sn??U.query;if(!Y)throw Error("query or sn is required");let z=await rh1($,{query:Y,sn:U.sn,batchId:U.batchId,latest:U.latest,limit:U.latest?1:U.limit??20,maxScan:U.maxScan??1000}),Q=await Promise.all(z.records.map((K)=>H4($,K.id))),J=nR0(U.fields),I=Q.map((K)=>dh1(K,J));return{query:Y,sourceDocumentSN:U.sn,simulationBatchId:U.batchId,latest:U.latest??!1,total:z.total,scanned:z.scanned,matched:I.length,records:I,next:{getSummary:"seal-home approval-runs get <recordId> --summary",getRuleVersion:"seal-home rules version <ruleSetVersionNumber>",searchRuleVersion:`seal-hometoolseal_approval_search--json'{"keywords":["关键词"],"areas":["rules"],"ruleVersionScope":"version","ruleVersionNumber":14}'`,getVersionContext:`seal-hometoolseal_approval_context_get--json'{"ruleVersionNumber":14}'`},...U.includeBridge?{bridge:GT(Q)}:{}}}},{name:"seal_simulation_batch_records_get",description:"获取某一次 Seal 模拟批次的运行记录,并整理对应 Langfuse trace/session 桥接字段",parameters:L.object({batchId:L.string().describe("simulation batch ID"),query:L.string().optional().describe("在 id、sourceDocumentSN、sourceDocumentId、documentId、Langfuse traceId 中做本地包含匹配")}),handler:async($,U)=>{let Y=Ml(await aS($,U.batchId),U.query);return{batchId:U.batchId,count:Y.length,records:Y.map(hz),bridge:GT(Y)}}},{name:"seal_simulation_batch_create",description:"创建 Seal 模拟测试批次。支持合思指定单号(hosecloud)与材料包导入(material_pack)两种模式;其他取数模式通过 rawParams 预留透传。",parameters:L.object({mode:L.enum(["hosecloud","material_pack"]).default("hosecloud").describe("来源模式: hosecloud=合思指定单号; material_pack=材料包导入"),flowIds:L.array(L.string()).max(100).optional().describe("合思模式: 单据流水号列表"),rejectNodeName:L.string().nullable().optional().describe("仅关注特定节点: 节点名称, 不设为 null 表示不限制"),thinkingDepthOverride:L.enum(["default","medium","high"]).optional().describe("思考深度: default=按偏好设置, medium=标准, high=深度推理"),skipInvoiceGeneration:L.boolean().optional().describe("跳过发票生成, 默认 true"),skipExpenseExtraction:L.boolean().optional().describe("跳过费用提取, 默认 true"),disableAttachmentCache:L.boolean().optional().describe("不使用附件缓存, 默认 false"),signKey:L.string().optional().describe("合思集成标识; 缺省时自动取第一个合思集成"),packageIds:L.array(L.string()).optional().describe("材料包模式: 材料包 id 列表(来自 material-packages upload 响应)"),templateId:L.string().optional().describe("材料包模板 id, 例如 conference_reimbursement_v1; 缺省取 schemaConfig.id"),schemaConfig:L.record(L.string(),L.unknown()).optional().describe("材料包字段映射(确认参数), 建议使用 material-packages upload 返回的 schemaConfig"),noWait:L.boolean().optional().describe("创建后立即返回异步票据,不等待批次完成"),rawParams:L.record(L.string(),L.unknown()).optional().describe("预留: 其他取数模式(如时间范围 startTime/endTime)透传参数, 覆盖上述构建结果")}),handler:async($,U)=>{let Y=U.mode??"hosecloud",z=U.signKey;if(Y==="hosecloud"&&!z){if(z=(await eS($)).find((K)=>K.signKey)?.signKey,!z)throw Error("未找到合思集成 signKey, 请通过 signKey
Line truncated
`)}function JS1($){let U=[];if(U.push(`seal-use${$.area}-${$.title}`),$.description)U.push($.description);U.push(""),U.push("Usage:");for(let Y of $.commands)for(let z of Y.usage)U.push(`${z}`);if($.commands.some((Y)=>Y.name))U.push(""),U.push(`Run'seal-use ${$.area} <command> --help'fordetailsonaspecificcommand.`);return U.join(`
`)}function H_0(){let $=[];$.push("seal-use CLI"),$.push(""),$.push("Usage:"),$.push(" seal-use version");for(let U of W_0)for(let Y of U.commands)for(let z of Y.usage)$.push(`${z}`);return $.push(""),$.push("Run 'seal-use <command> --help' for details on a specific command."),$.join(`
`)}var W_0;var Tl=o(()=>{L$();W_0=[{area:"corps",title:"Enterprise and tenant management",description:"Manage enterprise configurations, environment modes, test bindings, and syncing.",commands:[{name:"list",summary:"List configured enterprises sorted by 7-day usage frequency",usage:["seal-use corps list [query] [--all] [--limit <n>] [--env <production|test>] [--strict] [--corp <corpId>]"],options:[{flag:"--all",description:"Display all configured enterprises without the default 10-item limit"},{flag:"--limit <n>",description:"Maximum number of enterprises to display (defaults to 10)"},{flag:"--env <production|test>",description:"Filter enterprises by environment ('production' or 'test')"},{flag:"--strict",description:"Use strict exact substring matching instead of default soft fuzzy search"}]},{name:"search",aliases:["find"],summary:"Search configured enterprises with intelligent soft fuzzy matching",usage:["seal-use corps search <query> [--env <production|test>] [--strict]"],options:[{flag:"--env <production|test>",description:"Filter enterprises by environment ('production' or 'test')"},{flag:"--strict",description:"Use strict exact substring matching instead of default soft fuzzy search"}],description:"Searches enterprise ID, name, staff ID, domain, tenant slug, environment, or bindings. Uses soft search by default (case-insensitive, Chinese homophones, front/back nasal vowels, initials, typo/missing letter tolerance)."},{name:"get",aliases:["show"],summary:"Get rich details and configuration of an enterprise",usage:["seal-use corps get <corpId>"],description:"Retrieves complete enterprise details (URLs, tenant slugs, custom headers/cookies, staff IDs, relations, config file path) with sensitive secrets safely redacted."},{name:"current",summary:"Show active enterprise in stateful mode",usage:["seal-use corps current [--corp <corpId>]"]},{name:"switch",summary:"Switch default active enterprise",usage:["seal-use corps switch <corpId>"]},{name:"mark",summary:"Mark enterprise environment as production or test",usage:["seal-use corps mark <corpId> --env <production|test> [--confirm]"],options:[{flag:"--env <production|test>",description:"Target environment: 'production' or 'test' (required)"},{flag:"--confirm",description:"Confirm the environment update (required)"}],description:"Explicitly updates an enterprise's environment tag. Requires --confirm to prevent accidental changes."},{name:"bind-test",summary:"Bind a production enterprise to a test enterprise (1-to-1 association)",usage:["seal-use corps bind-test <prodCorpId> <testCorpId> [--confirm] [--force]","seal-use corps bind-test <testCorpId> --corp <prodCorpId> [--confirm] [--force]"],options:[{flag:"--confirm",description:"Explicitly confirm binding and tag test environment (required)"},{flag:"--force",description:"Force re-binding if the production enterprise is already bound"},{flag:"--corp <corpId>",description:"Specify production enterprise ID or name"}],description:"Establishes a strict 1-to-1 association between a production enterprise and a test enterprise. Automatically marks the test enterprise with environment 'test'."},{name:"unbind-test",summary:"Unbind a production and test enterprise association",usage:["seal-use corps unbind-test [<corpId>] [--confirm]"],options:[{flag:"--confirm",description:"Explicitly confirm unbinding both sides (required)"},{flag:"--corp <corpId>",description:"Specify enterprise ID or name"}],description:"Removes the 1-to-1 test association from both the production enterprise and the test enterprise."},{name:"sync-test",summary:"Synchronize rules and preferences from production to test enterprise",usage:["seal-use corps sync-test [<prodCorpId>] [--dry-run] [--yes] [--version-name <name>]"],options:[{flag:"--dry-run",description:"Preview sync diff without making network mutations (default)"},{flag:"--yes",description:"Execute synchronization and publish new rule version on test enterprise"},{flag:"--version-name <name>",description:"Custom version name for published test rule version"},{flag:"--corp <corpId>",description:"Specify production enterprise ID or name"}],description:"Overwrites test enterprise decision preferences with production preferences, syncs production draft rules to test enterprise, and immediately publishes a new version on the test enterprise. Production rules remain safe in draft state."},{name:"replay-test",summary:"Replay approval records from production enterprise to bound test enterprise via Webhook",usage:["seal-use corps replay-test [<prodCorpId>] [--record-id <id>] [--sn <sn>] [--limit <n>] [--webhook <idOrName>] [--dry-run]"],options:[{flag:"<prodCorpId>",description:"Production enterprise ID (default: active enterprise)"},{flag:"--record-id <id>",description:"Replay a specific approval run ID"},{flag:"--sn <sn>",description:"Replay a specific document SN"},{flag:"--limit <n>",description:"Batch replay latest N records from production (default: 1)"},{flag:"--status <status>",descripti
Line truncated
`+"• 安全边界:该凭证绝不包含且无法访问合思 (Hose) 主系统;仅限内部排查,严禁在外部公开分享!")}return{url:W?I:Z?V:G,type:X,mode:Z?"auto_login":"direct",sealResultUrl:G,hoseDocumentUrl:I,documentUrl:I,ssoUrl:V,expiresIn:Z?q:void 0,identity:F,warning:M,hoseDomain:J.type==="hose"?$S1(J.domain):void 0,recordId:Q.id,sourceDocumentSN:Q.sourceDocumentSN,sourceDocumentId:Q.sourceDocumentId,sourceSystem:Q.sourceSystem,missing:{hoseDocumentUrl:!I?"sourceExtendData.hosecloudViewUrl is absent from the approval run detail.":void 0}}}},{name:"seal_approval_run_pick",description:"按合思单号或关键字查询运行记录,返回候选记录及其当时使用的规则版本,便于再取详情或查版本规则",parameters:L.object({query:L.string().optional().describe("合思单号、源单据 ID、运行记录 ID 或 trace 关键字"),sn:L.string().optional().describe("合思/易快报单号;优先作为精确 sourceDocumentSN 查询"),batchId:L.string().optional().describe("模拟批次 ID"),latest:L.boolean().optional().describe("只返回最新一条匹配记录"),fields:L.union([L.string(),L.array(L.string())]).optional().describe("限制返回字段"),limit:L.number().int().positive().max(100).optional(),maxScan:L.number().int().positive().max(5000).optional().describe("最多扫描多少条运行记录用于本地匹配,默认 1000"),includeBridge:L.boolean().optional()}),handler:async($,Y)=>{let U=Y.sn??Y.query;if(!U)throw Error("query or sn is required");let z=await YS1($,{query:U,sn:Y.sn,batchId:Y.batchId,latest:Y.latest,limit:Y.latest?1:Y.limit??20,maxScan:Y.maxScan??1000}),Q=await Promise.all(z.records.map((K)=>H4($,K.id))),J=pR0(Y.fields),I=Q.map((K)=>ah1(K,J));return{query:U,sourceDocumentSN:Y.sn,simulationBatchId:Y.batchId,latest:Y.latest??!1,total:z.total,scanned:z.scanned,matched:I.length,records:I,next:{getSummary:"seal-home approval-runs get <recordId> --summary",getRuleVersion:"seal-home rules version <ruleSetVersionNumber>",searchRuleVersion:`seal-hometoolseal_approval_search--json'{"keywords":["关键词"],"areas":["rules"],"ruleVersionScope":"version","ruleVersionNumber":14}'`,getVersionContext:`seal-hometoolseal_approval_context_get--json'{"ruleVersionNumber":14}'`},...Y.includeBridge?{bridge:HT(Q)}:{}}}},{name:"seal_simulation_batch_records_get",description:"获取某一次 Seal 模拟批次的运行记录,并整理对应 Langfuse trace/session 桥接字段",parameters:L.object({batchId:L.string().describe("simulation batch ID"),query:L.string().optional().describe("在 id、sourceDocumentSN、sourceDocumentId、documentId、Langfuse traceId 中做本地包含匹配")}),handler:async($,Y)=>{let U=Nl(await eS($,Y.batchId),Y.query);return{batchId:Y.batchId,count:U.length,records:U.map(Sz),bridge:HT(U)}}},{name:"seal_simulation_batch_create",description:"创建 Seal 模拟测试批次。支持合思指定单号(hosecloud)与材料包导入(material_pack)两种模式;其他取数模式通过 rawParams 预留透传。",parameters:L.object({mode:L.enum(["hosecloud","material_pack"]).default("hosecloud").describe("来源模式: hosecloud=合思指定单号; material_pack=材料包导入"),flowIds:L.array(L.string()).max(100).optional().describe("合思模式: 单据流水号列表"),rejectNodeName:L.string().nullable().optional().describe("仅关注特定节点: 节点名称, 不设为 null 表示不限制"),thinkingDepthOverride:L.enum(["default","medium","high"]).optional().describe("思考深度: default=按偏好设置, medium=标准, high=深度推理"),skipInvoiceGeneration:L.boolean().optional().describe("跳过发票生成, 默认 true"),skipExpenseExtraction:L.boolean().optional().describe("跳过费用提取, 默认 true"),disableAttachmentCache:L.boolean().optional().describe("不使用附件缓存, 默认 false"),signKey:L.string().optional().describe("合思集成标识; 缺省时自动取第一个合思集成"),packageIds:L.array(L.string()).optional().describe("材料包模式: 材料包 id 列表(来自 material-packages upload 响应)"),templateId:L.string().optional().describe("材料包模板 id, 例如 conference_reimbursement_v1; 缺省取 schemaConfig.id"),schemaConfig:L.record(L.string(),L.unknown()).optional().describe("材料包字段映射(确认参数), 建议使用 material-packages upload 返回的 schemaConfig"),noWait:L.boolean().optional().describe("创建后立即返回异步票据,不等待批次完成"),rawParams:L.record(L.string(),L.unknown()).optional().describe("预留: 其他取数模式(如时间范围 startTime/endTime)透传参数, 覆盖上述构建结果")}),handler:async($,Y)=>{let U=Y.mode??"hosecloud",z=Y.signKey;if(U==="hosecloud"&&!z){if(z=(await Yg($)).find((K)=>K.signKey)?.signKey,!z)throw Error("未找到合思集成 signKey, 请通过 signKey 参数提供")}let Q=uh1({mode:U,flowIds:Y.flowIds,rejectNodeName:Y.rejectNodeName,thinkingDepthOverride:Y.thinkingDepthOverride,skipInvoiceGene
Line truncated
`)}function XS1($){let Y=[];if(Y.push(`seal-use${$.area}-${$.title}`),$.description)Y.push($.description);Y.push(""),Y.push("Usage:");for(let U of $.commands)for(let z of U.usage)Y.push(`${z}`);if($.commands.some((U)=>U.name))Y.push(""),Y.push(`Run'seal-use ${$.area} <command> --help'fordetailsonaspecificcommand.`);return Y.join(`
`)}function W_0(){let $=[];$.push("seal-use CLI"),$.push(""),$.push("Usage:"),$.push(" seal-use version");for(let Y of X_0)for(let U of Y.commands)for(let z of U.usage)$.push(`${z}`);return $.push(""),$.push("Run 'seal-use <command> --help' for details on a specific command."),$.join(`
`)}var X_0;var jl=m(()=>{L$();X_0=[{area:"corps",title:"Enterprise and tenant management",description:"Manage enterprise configurations, environment modes, test bindings, and syncing.",commands:[{name:"list",summary:"List configured enterprises sorted by 7-day usage frequency",usage:["seal-use corps list [query] [--all] [--limit <n>] [--env <production|test>] [--strict] [--corp <corpId>]"],options:[{flag:"--all",description:"Display all configured enterprises without the default 10-item limit"},{flag:"--limit <n>",description:"Maximum number of enterprises to display (defaults to 10)"},{flag:"--env <production|test>",description:"Filter enterprises by environment ('production' or 'test')"},{flag:"--strict",description:"Use strict exact substring matching instead of default soft fuzzy search"}]},{name:"search",aliases:["find"],summary:"Search configured enterprises with intelligent soft fuzzy matching",usage:["seal-use corps search <query> [--env <production|test>] [--strict]"],options:[{flag:"--env <production|test>",description:"Filter enterprises by environment ('production' or 'test')"},{flag:"--strict",description:"Use strict exact substring matching instead of default soft fuzzy search"}],description:"Searches enterprise ID, name, staff ID, domain, tenant slug, environment, or bindings. Uses soft search by default (case-insensitive, Chinese homophones, front/back nasal vowels, initials, typo/missing letter tolerance)."},{name:"get",aliases:["show"],summary:"Get rich details and configuration of an enterprise",usage:["seal-use corps get <corpId>"],description:"Retrieves complete enterprise details (URLs, tenant slugs, custom headers/cookies, staff IDs, relations, config file path) with sensitive secrets safely redacted."},{name:"current",summary:"Show active enterprise in stateful mode",usage:["seal-use corps current [--corp <corpId>]"]},{name:"switch",summary:"Switch default active enterprise",usage:["seal-use corps switch <corpId>"]},{name:"mark",summary:"Mark enterprise environment as production or test",usage:["seal-use corps mark <corpId> --env <production|test> [--confirm]"],options:[{flag:"--env <production|test>",description:"Target environment: 'production' or 'test' (required)"},{flag:"--confirm",description:"Confirm the environment update (required)"}],description:"Explicitly updates an enterprise's environment tag. Requires --confirm to prevent accidental changes."},{name:"rename",summary:"Rename an enterprise display name",usage:["seal-use corps rename <corpId> --name <newName>"],options:[{flag:"--name <newName>",description:"New human-readable enterprise name (required)"}],description:"Safely updates the display name of a configured enterprise without modifying underlying files manually."},{name:"bind-test",summary:"Bind a production enterprise to a test enterprise (1-to-1 association)",usage:["seal-use corps bind-test <prodCorpId> <testCorpId> [--confirm] [--force]","seal-use corps bind-test <testCorpId> --corp <prodCorpId> [--confirm] [--force]"],options:[{flag:"--confirm",description:"Explicitly confirm binding and tag test environment (required)"},{flag:"--force",description:"Force re-binding if the production enterprise is already bound"},{flag:"--corp <corpId>",description:"Specify production enterprise ID or name"}],description:"Establishes a strict 1-to-1 association between a production enterprise and a test enterprise. Automatically marks the test enterprise with environment 'test'."},{name:"unbind-test",summary:"Unbind a production and test enterprise association",usage:["seal-use corps unbind-test [<corpId>] [--confirm]"],options:[{flag:"--confirm",description:"Explicitly confirm unbinding both sides (required)"},{flag:"--corp <corpId>",description:"Specify enterprise ID or name"}],description:"Removes the 1-to-1 test association from both the production enterprise and the test enterprise."},{name:"sync-test",summary:"Synchronize rules and preferences from production to test enterprise",usage:["seal-use corps sync-test [<prodCorpId>] [--dry-run] [--yes] [--version-name <name>]"],options:[{flag:"--dry-run",description:"Preview sync diff without making network mutations (default)"},{flag:"--yes",description:"Execute synchronization and publish new rule version on test enterprise"},{flag:"--version-name <name>",description:"Custom version name for published test rule version"},{flag:"--corp <corpId>",description:"Specify production enterprise ID or name"}],description:"Overwrites test enterprise decision preferences with production preferences, syncs production draft rules to test enterprise, and immediately publishes a new version on the test enterprise. Production rules remain safe in draft state."},{name:"replay-test",summary:"Replay approval records from production enterprise to bound test enterprise via Webhook",usage:["seal-use corps replay-test [<prodCorpId>] [--record-id <id>] [--sn <sn>] [--limit <n>] [--webhook <idOrName>] [--dry-run]"],options:[{flag:"<prodCorpId>",des
Line truncated
`);c0({provider:"hose",capability:"privilege-elevation",corpId:Y.corpId,corpName:Y.corpName??Y.corpId,baseUrl:Y.baseUrl,staffId:Y.staffId,keyCount:Y.keys.length,keys:Y.keys.map((Q)=>({id:Q.id,name:Q.name||"-",appKey:Q.appKey,appSecurity:z?Q.appSecurity:SS(Q.appSecurity),active:Q.active,createTime:Q.createTime,updateTime:Q.updateTime}))})}async function cl($,U){let Y=E1($),z=U.reveal===!0;if(Y.source.type!=="hose")throw new w4(`【合思子域专享能力】当前企业「${Y.name}」(id:${Y.id})为原生Seal(${Y.source.type})租户,非合思(Hose/合思云/易快报)渠道企业。
`);f0({provider:"hose",capability:"privilege-elevation",corpId:U.corpId,corpName:U.corpName??U.corpId,baseUrl:U.baseUrl,staffId:U.staffId,keyCount:U.keys.length,keys:U.keys.map((Q)=>({id:Q.id,name:Q.name||"-",appKey:Q.appKey,appSecurity:z?Q.appSecurity:yS(Q.appSecurity),active:Q.active,createTime:Q.createTime,updateTime:Q.updateTime}))})}async function nl($,Y){let U=j1($),z=Y.reveal===!0;if(U.source.type!=="hose")throw new w4(`【合思子域专享能力】当前企业「${U.name}」(id:${U.id})为原生Seal(${U.source.type})租户,非合思(Hose/合思云/易快报)渠道企业。
`);c0({provider:"hose",capability:"privilege-elevation",corpId:Y.id,corpName:Y.name,domain:Y.source.domain,staffId:Y.source.staffId,appKey:Q??"-",appSecurity:J?z?J:SS(J):"-",active:!0})}function $h0($,U){let{token:Y,sealUrl:z,expiresIn:Q,verify:J,remote:I}=U,K=U.custom??tv0($),G=I?.user,H=I?.tenant,W=X4($,"tenantSlug")??s2(H?.tenantSlug),X=X4($,"tenantId")??s2(H?.id),Z=X4($,"tenantName")??s2(H?.name),q=X4($,"id")??W??X;if(!q)throw Error("Missing required JSON field: id. Seal whoami did not return tenantSlug or tenantId.");let V=X4($,"staffId")??s2(G?.providerUserId)??s2(G?.id)??"seal",F=X4($,"provider")??s2(G?.provider)??s2(H?.providerConfig?.provider),O=X4($,"corpId")??W??X??q,w={id:q,name:X4($,"name")??Z??q,environment:"production",seal:{url:z,tenantSlug:W,headers:K.headers,cookies:K.cookies,endpoints:{approvalStylePreferences:"api/v1/agent/ai-approval/config"}},source:{type:"seal",token:Y,sealUrl:z,expiresIn:Q,staffId:V,corpId:O,tenantId:X,tenantSlug:W,tenantName:Z,providerUserId:s2(G?.providerUserId),provider:F},auth:{refreshTtl:300}},M=$p();lv0(M,{recursive:!0,mode:448});let N=rv0(M,`${VT(q)}.json`);if(mv0(N)&&$.overwrite!==!0)throw Error(`Enterpriseconfigalreadyexists:${N}.Pass"overwrite":truetoreplaceit.`);ov0(N,`${JSON.stringify(w,null,2)}
`,{mode:384}),c0({id:q,name:w.name,tenantId:X,tenantSlug:W,verified:J,path:N})}async function lS1($,U,Y={}){let z=T8($,U,Y),Q=await W8(z);return{user:Q.user??{},tenant:Q.tenant??{}}}function s2($){return typeof $==="string"&&$?$:void 0}var nl=o(()=>{a9();BH();i8();S3();fv0();bP();tn();X6();X6();ul();SZ();ET();o4();L$();D4();J4()});async function Yh0($,U){let Y=$??S(U.options.link)??S(U.options.url);if(!Y)throw Error("Usage: seal-use auth extract-keys <https://.../web/thirdparty.html?...> [--reveal] [--save] [--name <customName>] [--overwrite]");let z=V0(U.options.reveal)===!0||V0(U.options.r)===!0||V0(U.options.plain)===!0,Q=V0(U.options.save)===!0||V0(U.options.add)===!0;await CT(Y,{reveal:z,save:Q,name:S(U.options.name),overwrite:V0(U.options.overwrite)===!0,force:V0(U.options.force)===!0,appKey:S(U.options["app-key"])??S(U.options.appKey),keyId:S(U.options["key-id"])??S(U.options.keyId)})}async function zh0($,U,Y){if($==="diagnose"){c0(await oS1(U));return}if($==="hose-link"){let z=Y.options.expire,Q=z!==void 0?s0(z):7200;if(Q===void 0||Q<=0)throw Error(`Invalid--expire:${String(z)}.Mustbeapositivenumberofseconds(e.g.--expire7200or--expire86400).`);let J=V0(Y.options.force)===!0||V0(Y.options.refresh)===!0||V0(Y.options.f)===!0;c0(await P00(U,Q,{force:J}));return}if($==="keys"){let z=V0(Y.options.reveal)===!0||V0(Y.options.r)===!0||V0(Y.options.plain)===!0;await cl(U.id,{reveal:z});return}throw Error(`Unknownauthcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}async function oS1($){if($.source.type!=="hose"){let F=await j1($),O=await W8(F);return{corp:{id:$.id,name:$.name,sourceType:$.source.type},ok:!0,stages:[{name:"seal.whoami",ok:!0,user:O.user,tenant:O.tenant}]}}aw($.id);let U=$.source,Y=U.appKey??U.key,z=U.appSecurity??U.password,Q=($.seal.url??U.sealUrl??`https://${U.corpId.toLowerCase()}.sealai.cc`).replace(/\/+$/,""),J=U.staffId.includes(":")?U.staffId:`${U.corpId}:${U.staffId}`,I=[];if(!Y||!z)return{corp:{id:$.id,name:$.name,sourceType:$.source.type},ok:!1,stages:[{name:"hose.openapi",ok:!1,error:"Hose source requires appKey/key and appSecurity/password"}]};let K=await RT("hose.openapi",async()=>{let F=await Uh0(`${U.domain.replace(/\/+$/,"")}/api/openapi/v1/auth/getAccessToken`,{appKey:Y,appSecurity:z}),O=d3(F.value),w=b6(O.accessToken)??b6(F.accessToken)??b6(F.token);if(!w)throw Error("Hose login did not return an access token");return{token:w,public:{corporationId:b6(O.corporationId)??b6(d3(O.corporation).id),expireTime:Bq(O.expireTime)}}});I.push(K.public);let G=K.private?.token,H=G?await RT("hose.provisional",async()=>{let F=await Uh0(`${U.domain.replace(/\/+$/,"")}/api/openapi/v1.1/provisional/getProvisionalAuth?accessToken=${encodeURIComponent(G)}`,{uid:J,pageType:"home",expireDate:7200}),O=b6(d3(F.value).message);if(!O)throw Error("Hose CloseAPI did not return a provisional auth URL");let w=new URL(O).searchParams.get("accessToken");if(!w)throw Error("Hose provisional auth URL did not include accessToken");return{token:w,public:{uid:J,enterpriseUrl:Mq(O)}}}):pl("hose.provisional");I.push(H.public);let W=A6($.seal),X=H.private?.token,Z=X?await RT("seal.sso",async()=>{let O=await T8(Q,void 0,W).get(`api/auth/oauth2/session/oem-hosecloud?token=${encodeURIComponent(X)}&returnToken=1`).json(),w=d3(O.data),M=b6(O.token)??b6(O.accessToken)??b6(w.token)??b6(w.accessToken);if(!M)throw Error("Seal SSO did not return a bearer token");return{token:M,public:{sealUrl:Q,expiresIn:Bq(O.expiresIn)??Bq(O.expires_in)??Bq(w.expiresIn)??Bq(w.expires_in)}}}):pl("seal.sso");I.push(Z.public);let q=Z.private?.token,V=q?await RT("seal.whoami",async()=>{let O=await T8(Q,q,W).get("api/v1/auth/me").json(),w=d3(O.data),M=d3(w.user??O.user),N=d3(w.tenant??O.tenant);return{public:{user:{id:b6(M.id),name:b6(M.name),isAdmin:sS1(M.isAdmin),providerUserId:b6(M.providerUserId)},tenant:{id:b6(N.id),name:b6(N.name),tenantSlug:b6(N.tenantSlug),hoseCorpConfig:aS1(N.hoseCorpConfig)}}}}):pl("seal.whoami");return I.push(V.public),{corp:{id:$.id,name:$.name,sourceType:$.source.type},ok:I.every((F)=>F.ok===!0),stages:I}}async function RT($,U){try{let Y=await U();return{public:{name:$,ok:!0,...Qh0(Y.public)},private:Y.token?{token:Y.token}:void 0}}catch(Y){return{public:{name:$,ok:!1,error:Mq(Y instanceof Error?Y.message:String(Y))}}}}function pl($){return{public:{name:$,ok:!1,skipped:!0}}}async function Uh0($,U){let Y=await fetch($,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(U)});return rS1(Y)}async function rS1($){let U=await $.text();if(!$.ok)throw Error(`${$.status} ${U}`);let Y=JSON.parse(U);return d3(Y)}function d3($){return $&&typeof $==="object"&&!Array.isArray($)?$:{}}function b6($){return typeof $==="string"&&$?$:void 0}function Bq($){return typeof $==="number"&&Number.isFinite($)?$:void 0}function sS1($){return typeof $==="boolean"?$:void 0}function aS1($){let U=d3($);return Qh0({corporationId:b6(U.corporationId),corporationName:b6(U.corporationName)})}f
Line truncated
`);f0({provider:"hose",capability:"privilege-elevation",corpId:U.id,corpName:U.name,domain:U.source.domain,staffId:U.source.staffId,appKey:Q??"-",appSecurity:J?z?J:yS(J):"-",active:!0})}function Yh0($,Y){let{token:U,sealUrl:z,expiresIn:Q,verify:J,remote:I}=Y,K=Y.custom??ev0($),G=I?.user,H=I?.tenant,W=X4($,"tenantSlug")??s2(H?.tenantSlug),X=X4($,"tenantId")??s2(H?.id),Z=X4($,"tenantName")??s2(H?.name),q=X4($,"id")??W??X;if(!q)throw Error("Missing required JSON field: id. Seal whoami did not return tenantSlug or tenantId.");let V=X4($,"staffId")??s2(G?.providerUserId)??s2(G?.id)??"seal",F=X4($,"provider")??s2(G?.provider)??s2(H?.providerConfig?.provider),M=X4($,"corpId")??W??X??q,w={id:q,name:X4($,"name")??Z??q,environment:"production",seal:{url:z,tenantSlug:W,headers:K.headers,cookies:K.cookies,endpoints:{approvalStylePreferences:"api/v1/agent/ai-approval/config"}},source:{type:"seal",token:U,sealUrl:z,expiresIn:Q,staffId:V,corpId:M,tenantId:X,tenantSlug:W,tenantName:Z,providerUserId:s2(G?.providerUserId),provider:F},auth:{refreshTtl:300}},N=Up();ov0(N,{recursive:!0,mode:448});let O=sv0(N,`${LT(q)}.json`);if(lv0(O)&&$.overwrite!==!0)throw Error(`Enterpriseconfigalreadyexists:${O}.Pass"overwrite":truetoreplaceit.`);rv0(O,`${JSON.stringify(w,null,2)}
`,{mode:384}),f0({id:q,name:w.name,tenantId:X,tenantSlug:W,verified:J,path:O})}async function eS1($,Y,U={}){let z=T8($,Y,U),Q=await W8(z);return{user:Q.user??{},tenant:Q.tenant??{}}}function s2($){return typeof $==="string"&&$?$:void 0}var pl=m(()=>{t9();jH();i8();y3();uv0();iB();$p();X6();X6();bl();SZ();CT();f4();L$();D4();J4()});async function zh0($,Y){let U=$??h(Y.options.link)??h(Y.options.url);if(!U)throw Error("Usage: seal-use auth extract-keys <https://.../web/thirdparty.html?...> [--reveal] [--save] [--name <customName>] [--overwrite]");let z=Z0(Y.options.reveal)===!0||Z0(Y.options.r)===!0||Z0(Y.options.plain)===!0,Q=Z0(Y.options.save)===!0||Z0(Y.options.add)===!0;await RT(U,{reveal:z,save:Q,name:h(Y.options.name),overwrite:Z0(Y.options.overwrite)===!0,force:Z0(Y.options.force)===!0,appKey:h(Y.options["app-key"])??h(Y.options.appKey),keyId:h(Y.options["key-id"])??h(Y.options.keyId)})}async function Qh0($,Y,U){if($==="diagnose"){f0(await $g1(Y));return}if($==="seal-link"||$==="link"||$==="hose-link"&&Y.source.type==="seal"){let z=await B1(Y),Q=h(U.options.note)??"CLI generated provisional access link",J=await T5("seal_delegation_create",z,Y,{note:Q});if($==="hose-link")console.error(`\uD83D\uDC49提示:企业「${Y.name}」源类型为Seal原生测试环境,已自动为您生成委托免登直达链接。`);f0(J);return}if($==="hose-link"){let z=U.options.expire,Q=z!==void 0?s0(z):7200;if(Q===void 0||Q<=0)throw Error(`Invalid--expire:${String(z)}.Mustbeapositivenumberofseconds(e.g.--expire7200or--expire86400).`);let J=Z0(U.options.force)===!0||Z0(U.options.refresh)===!0||Z0(U.options.f)===!0;f0(await P00(Y,Q,{force:J}));return}if($==="keys"){let z=Z0(U.options.reveal)===!0||Z0(U.options.r)===!0||Z0(U.options.plain)===!0;await nl(Y.id,{reveal:z});return}throw Error(`Unknownauthcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}async function $g1($){if($.source.type!=="hose"){let F=await B1($),M=await W8(F);return{corp:{id:$.id,name:$.name,sourceType:$.source.type},ok:!0,stages:[{name:"seal.whoami",ok:!0,user:M.user,tenant:M.tenant}]}}aw($.id);let Y=$.source,U=Y.appKey??Y.key,z=Y.appSecurity??Y.password,Q=($.seal.url??Y.sealUrl??`https://${Y.corpId.toLowerCase()}.sealai.cc`).replace(/\/+$/,""),J=Y.staffId.includes(":")?Y.staffId:`${Y.corpId}:${Y.staffId}`,I=[];if(!U||!z)return{corp:{id:$.id,name:$.name,sourceType:$.source.type},ok:!1,stages:[{name:"hose.openapi",ok:!1,error:"Hose source requires appKey/key and appSecurity/password"}]};let K=await _T("hose.openapi",async()=>{let F=await Uh0(`${Y.domain.replace(/\/+$/,"")}/api/openapi/v1/auth/getAccessToken`,{appKey:U,appSecurity:z}),M=l3(F.value),w=b6(M.accessToken)??b6(F.accessToken)??b6(F.token);if(!w)throw Error("Hose login did not return an access token");return{token:w,public:{corporationId:b6(M.corporationId)??b6(l3(M.corporation).id),expireTime:Tq(M.expireTime)}}});I.push(K.public);let G=K.private?.token,H=G?await _T("hose.provisional",async()=>{let F=await Uh0(`${Y.domain.replace(/\/+$/,"")}/api/openapi/v1.1/provisional/getProvisionalAuth?accessToken=${encodeURIComponent(G)}`,{uid:J,pageType:"home",expireDate:7200}),M=b6(l3(F.value).message);if(!M)throw Error("Hose CloseAPI did not return a provisional auth URL");let w=new URL(M).searchParams.get("accessToken");if(!w)throw Error("Hose provisional auth URL did not include accessToken");return{token:w,public:{uid:J,enterpriseUrl:Nq(M)}}}):dl("hose.provisional");I.push(H.public);let W=A6($.seal),X=H.private?.token,Z=X?await _T("seal.sso",async()=>{let M=await T8(Q,void 0,W).get(`api/auth/oauth2/session/oem-hosecloud?token=${encodeURIComponent(X)}&returnToken=1`).json(),w=l3(M.data),N=b6(M.token)??b6(M.accessToken)??b6(w.token)??b6(w.accessToken);if(!N)throw Error("Seal SSO did not return a bearer token");return{token:N,public:{sealUrl:Q,expiresIn:Tq(M.expiresIn)??Tq(M.expires_in)??Tq(w.expiresIn)??Tq(w.expires_in)}}}):dl("seal.sso");I.push(Z.public);let q=Z.private?.token,V=q?await _T("seal.whoami",async()=>{let M=await T8(Q,q,W).get("api/v1/auth/me").json(),w=l3(M.data),N=l3(w.user??M.user),O=l3(w.tenant??M.tenant);return{public:{user:{id:b6(N.id),name:b6(N.name),isAdmin:Ug1(N.isAdmin),providerUserId:b6(N.providerUserId)},tenant:{id:b6(O.id),name:b6(O.name),tenantSlug:b6(O.tenantSlug),hoseCorpConfig:zg1(O.hoseCorpConfig)}}}}):dl("seal.whoami");return I.push(V.public),{corp:{id:$.id,name:$.name,sourceType:$.source.type},ok:I.every((F)=>F.ok===!0),stages:I}}async function _T($,Y){try{let U=await Y();return{public:{name:$,ok:!0,...Jh0(U.public)},private:U.token?{token:U.token}:void 0}}catch(U){return{public:{name:$,ok:!1,error:Nq(U instanceof Error?U.message:String(U))}}}}function dl($){return{public:{name:$,ok:!1,skipped:!0}}}async function Uh0($,Y){let U=await fetch($,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Y)});return Yg1(U)}async function Yg1($){let Y=await $.text();if(!$.ok)throw Error(`${$.status} ${Y}`);let U=JSON.par
Line truncated
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let Z of X){let q=Z.outboundName??"SealAI 审批",V=Z.signKey,F=Z.apiOrigin??"production";console.error(`•"${q}"(signKey:${V},环境:${F})`),console.error(`\uD83D\uDC49查看命令:seal-usedeployhosecloudget${V}--corp${Q.id}
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let V of Z){let F=V.outboundName??"SealAI 审批",O=V.signKey,w=V.apiOrigin??"production";console.error(`•"${F}"(signKey:${O},环境:${w})`),console.error(`\uD83D\uDC49同步命令:seal-usedeployhosecloudsync${O}--corp${Q.id}
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let V of Z){let F=V.outboundName??"SealAI 审批",M=V.signKey,w=V.apiOrigin??"production";console.error(`•"${F}"(signKey:${M},环境:${w})`),console.error(`\uD83D\uDC49同步命令:seal-usedeployhosecloudsync${M}--corp${Q.id}
short_description:"Diagnose approval feedback and publish minimal rule fixes"
default_prompt:"Use $seal-use to resolve a customer feedback package to the correct tenant, diagnose the approval run, propose a minimal rule diff, and publish only after explicit confirmation."
`;var Th0=()=>{};var Ch0="# 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\n#查看附件列表摘要(包含文件名、类型、大小及直链可用性)\nseal-useapproval-runsattachments<recordId>--corp<corpId>--summary\n\n#下载全部附件到本地目录(优先使用ossSignedUrl签名直链)\nseal-useapproval-runsattachmentsdownload<recordId>--all--out-dir./downloads--corp<corpId>\n\n#按名称或fileId过滤下载单个附件\nseal-useapproval-runsattachmentsdownload<recordId>--name发票--corp<corpId>\n```\n\nThis should be enough for file names, file IDs, mime types, positions, invoice/attachment grouping, and links when available. For customer disputes about OCR, receipt/invoice classification, or image content, switch to `approval-attachment-trace.md`.\n\n## Result Summary\n\nUse:\n\n```bash\nseal-useapproval-runsresult<recordId>--corp<corpId>--summary\n```\n\nThis is for decision, summary, risk point count, matched rule count, trace ID, and record ID.\n\n## Approval Run Web Links & SSO Links\n\nUse this when the user asks for a link to an approval run or wants to open the run directly in their browser:\n\n```bash\n#默认推荐:生成干净的深度链接(无凭证、无越权风险,用户在已有登录状态的浏览器中直接打开)\nseal-useapproval-runsurl<recordId>--corp<corpId>\nseal-useapproval-runsurl--sn<sourceDocumentSN>--corp<corpId>\n\n#仅当用户明确要求免密/跨浏览器/无登录直达且确认知晓安全风险时:生成携带单次临时票据的SSO直登链接\nseal-useapproval-runsurl<recordId>--sso[--expire7200]--corp<corpId>\n```\n\n### SSO 链接安全与声明规范\n当向用户返回 `--sso` 链接时,Agent **必须**在回答中明确说明以下 4 点:\n1. **身份主体**:该链接代表哪个具体员工身份(如管理员姓名)登录。\n2. **权限范围**:该身份在 Seal AI 平台的全部权限范围(如完全操作权限)。\n3. **时效性**:临时 Ticket 换票时效(默认 2 小时,换票登录后会话有效 30 天)。\n4. **安全与防扩散边界**:该链接仅在 Seal AI 租户内生效,不代表合思主系统权限;严禁在公开或外部群聊中传播。\n\n>
Line truncated
`;var jh0=()=>{};var Rh0="# 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\n#查看附件列表摘要(包含文件名、类型、大小及直链可用性)\nseal-useapproval-runsattachments<recordId>--corp<corpId>--summary\n\n#下载全部附件到本地目录(优先使用ossSignedUrl签名直链)\nseal-useapproval-runsattachmentsdownload<recordId>--all--out-dir./downloads--corp<corpId>\n\n#按名称或fileId过滤下载单个附件\nseal-useapproval-runsattachmentsdownload<recordId>--name发票--corp<corpId>\n```\n\nThis should be enough for file names, file IDs, mime types, positions, invoice/attachment grouping, and links when available. For customer disputes about OCR, receipt/invoice classification, or image content, switch to `approval-attachment-trace.md`.\n\n## Result Summary\n\nUse:\n\n```bash\nseal-useapproval-runsresult<recordId>--corp<corpId>--summary\n```\n\nThis is for decision, summary, risk point count, matched rule count, trace ID, and record ID.\n\n## Approval Run Web Links & Auto-Login Links\n\nUse this when the user asks for a link to an approval run or wants to open the run directly in their browser:\n\n```bash\n#默认推荐:生成SealAI审核详情直达链接(无凭证、无越权风险,用户在已有登录状态的浏览器中直接打开)\nseal-useapproval-runslink<recordId>--corp<corpId>\nseal-useapproval-runslink--sn<sourceDocumentSN>--corp<corpId>\n\n#生成合思主系统原始单据页面链接\nseal-useapproval-runslink<recordId>--typehose-document--corp<corpId>\n\n#仅当用户明确要求免密/跨浏览器/无登录直达且确认知晓安全风险时:生成携带合思单次临时票据的免登直达链接\nseal-useapproval-runslink<recordId>--auto-login[--expire7200]--corp<corpId>\n```\n\n### 返回字段说明与语义规范\n- `sealResultUrl`: Seal AI 单据智能审核结果页\n- `hoseDocumentUrl`: 合思费控主系统原始报销/借款单详情页\n- `type`: 链接类型,默认为 `seal_result`,指定时可为 `hose_document`\n- `mode`: 鉴权模式,`direct`(原生直接打开)或 `auto_login`(免密换票)\n\n### 免登链接安全与声明规范\n当向用户返回 `--auto-login` 链接时
Line truncated
-**FormattingRequirement**:WhenreturningaHoseauthorizationlinktotheuser,ALWAYSprovideBOTHacodeblock(\`\`\`\`text ... \`\`\`\`) for easy copying without accidental default browser redirection, AND a clickable hyperlink.
-**DedicatedCLICommand**:Use\`seal-use auth hose-link --corp <corpId> [--expire <seconds>] [--force]\`. This command directly generates an independent provisional auth link without reading or mutating internal CLI session cache. It supports \`--expire\` (default 7200, e.g. 86400 for 1 day). Note: this link cannot be listed via \`seal-use delegation list\` (the latter only tracks Seal audit platform delegations).
@@ -2153,7 +2153,7 @@ Use current search only when the question is about current draft/current knowled
##OutputDiscipline
Ifarulecommandwouldreturnmanydescriptionsormorethanabout20rules,use\`rules count\`, \`rules list --summary\`, \`fields\`, \`snippetOnly\`, or \`--output-file\`. Use \`--full\` only for deliberate exports.
`;var nh0=()=>{};var mh0="# Seal Approval Rule Linter & Quality Validation\n\nUse this reference when analyzing, validating, or linting Seal AI approval rules to detect vague phrasing, missing exception evidence, or formatting defects before publishing.\n\n## Key Principles\n\n- **Default State**: Linter is **disabled by default** in global configuration (`lint.enabled:false`) to avoid unsolicited noise during standard operations.\n- **Doctor Visibility**: `seal-usedoctor` audits the rule linter configuration state and active linter name in its health checks, and surfaces a one-click hint (`seal-useconfiglintenable`) when disabled.\n- **Explicit Triggering**: `seal-useruleslint` always runs regardless of global configuration.\n- **Draft Hook**: When `seal-useconfiglintenable` is set, `seal_approval_rule_update` outputs real-time diagnostic warnings to `stderr` without mutating `stdout` payloads.\n- **Fault-Tolerant Fallback**: If a custom `.ts` linter file has syntax errors, runtime exceptions, or is missing, the engine logs a warning to `stderr` and **silently falls back to the built-in heuristic linter without failing**.\n\n## CLI Commands\n\n### 1. Lint Current Draft Rules (Whole-RuleSet Scan)\n\n```bash\nseal-useruleslint--corp<corpId>\n```\n\n### 2. Lint Specific Historical Version or Single Rule\n\n```bash\n#Lintrulesinpublishedversion16\nseal-useruleslint--version16--corp<corpId>\n\n#Lintaspecificrulebycode(#0038)\nseal-useruleslint--code'#0038'--corp<corpId>\n\n#Summarymode(onlyshowruleswithissues)\nseal-useruleslint--summary--corp<corpId>\n```\n\n### 3. Quality Gate for CI / Release\n\n```bash\n#Ifoverallscoreisbelow85,terminateswithexitcode1\nseal-useruleslint--min-score85--levelerror--corp<corpId>\n```\n\n### 4. Configure Global Linter Settings\n\n```bash\n#Checkstatus\nseal-useconfiglintstatus\n\n#Enableautolintonruleupdates\nseal-useconfiglintenable--linterbuiltin--min-score80\n\n#Disableautolint\nseal-useconfiglintdisable\n```\n\n## Official Linters\n\n| Linter Name | Scope & Purpose | Aliases |\n| :--- | :--- | :--- |\n| `builtin` | Seal 官方标准校验器:拦截过短描述、主观模糊词与悬空例外条款。 | `default`, `official/builtin` |\n| `strict` | Seal 官方严格风控校验器:强校验字数、刚性定量约束、凭证依据与具体审批人角色。 | `official/strict` |\n| `hlab` | 合思实验室 (HLab) 结构化规则校验器:SOP 四段论结构、三元闭环判定、剥离处置动作与防漏判。 | `hlab-sop`, `hlab-rules`, `hlab-standard`, `official/hlab` |\n\n```bash\n#Inspectavailablelinters\nseal-useruleslinters\n\n#LintrulesusingHLabSOPstandard\nseal-useruleslint--linterhlab--corp<corpId>\n\n#LintlocalruleworkspaceofflinewithHLabstandard\nseal-useruleslint--linterhlab--file./rules.local.json\n```\n\n## Built-In Detection Rules (`builtin`)\n\n| Code | Level | Description | Recommendation |\n| :--- | :---: | :--- | :--- |\n| `TOO_SHORT` | `error` | Rule description is under 5 characters. | Add concrete conditions and criteria. |\n| `VAGUE_WORD` | `error` | Contains subjective/fuzziness words (`原则上`, `尽量`, `适当`, `酌情`, `一般情况下`, `合理控制`). | Replace with rigid thresholds, enums, or criteria. |\n| `HANGING_EXCEPTION` | `warning` | Exception trigger found (`除非`, `特殊情况`, `经批准`) without verifiable evidence keyword (`备注`, `附件`, `证明`, `邮件`, `截图`). | Specify exact evidence source in invoice/document. |\n\n## HLab SOP Detection Rules (`hlab`)\n\n| Code | Level | Description | Recommendation |\n| :--- | :---: | :--- | :--- |\n| `MISSING_CHECK_METHOD` | `error` | Missing `**检查方法**` section in rule description. | Add `**检查方法**:` specifying fields, vouchers, and normalization logic. |\n| `MISSING_EVAL_STANDARD` | `error` | Missing `**判定标准**` section in rule description. | Add `**判定标准**:` with standard branches. |\n| `INCOMPLETE_TERNARY_BRANCH` | `error` | Incomplete ternary branch under evaluation criteria (missing `PASS`, `FAIL`, or `证据不足`). | Provide complete ternary closure: `-PASS:`, `-FAIL:`, `-证据不足:`. |\n| `INSUFFICIENT_WITHOUT_MANUAL_REVIEW` | `warning` | `证据不足` branch does not specify escalating to `人工复核`. | Add `转人工复核` at the end of `证据不足` branch. |\n| `DISPOSAL_ACTION_LEAK` | `warning` | Contains whole-bill workflow disposal actions (`驳回单据`, `直接驳回`, `进行提醒`, `退回单据`). | Decouple disposal actions from rule text; rely on rule strictness or platform workflow. |\n| `SCOPE_FALSE_SKIP_PRONE` | `warning` | Scope contains material upload conditions (`若上传了`, `若提供了`, `附件需上传`). | Keep scope pure to business triggers; handle missing materials explicitly in FAIL branch to prevent silent SKIP. |\n| `RISK_SUPPRESSION` | `erroLine truncated
`;var ph0=()=>{};var lh0="# Seal Approval Rule Linter & Quality Validation\n\nUse this reference when analyzing, validating, or linting Seal AI approval rules to detect vague phrasing, missing exception evidence, or formatting defects before publishing.\n\n## Key Principles\n\n- **Default State**: Linter is **disabled by default** in global configuration (`lint.enabled:false`) to avoid unsolicited noise during standard operations.\n- **Doctor Visibility**: `seal-usedoctor` audits the rule linter configuration state and active linter name in its health checks, and surfaces a one-click hint (`seal-useconfiglintenable`) when disabled.\n- **Explicit Triggering**: `seal-useruleslint` always runs regardless of global configuration.\n- **Draft Hook**: When `seal-useconfiglintenable` is set, `seal_approval_rule_update` outputs real-time diagnostic warnings to `stderr` without mutating `stdout` payloads.\n- **Fault-Tolerant Fallback**: If a custom `.ts` linter file has syntax errors, runtime exceptions, or is missing, the engine logs a warning to `stderr` and **silently falls back to the built-in heuristic linter without failing**.\n\n## CLI Commands\n\n### 1. Lint Current Draft Rules (Whole-RuleSet Scan)\n\n```bash\nseal-useruleslint--corp<corpId>\n```\n\n### 2. Lint Specific Historical Version or Single Rule\n\n```bash\n#Lintrulesinpublishedversion16\nseal-useruleslint--version16--corp<corpId>\n\n#Lintaspecificrulebycode(#0038)\nseal-useruleslint--code'#0038'--corp<corpId>\n\n#Summarymode(onlyshowruleswithissues)\nseal-useruleslint--summary--corp<corpId>\n```\n\n### 3. Quality Gate for CI / Release\n\n```bash\n#Ifoverallscoreisbelow85,terminateswithexitcode1\nseal-useruleslint--min-score85--levelerror--corp<corpId>\n```\n\n### 4. Configure Global Linter Settings\n\n```bash\n#Checkstatus\nseal-useconfiglintstatus\n\n#Enableautolintonruleupdates\nseal-useconfiglintenable--linterbuiltin--min-score80\n\n#Disableautolint\nseal-useconfiglintdisable\n```\n\n## Official Linters\n\n| Linter Name | Scope & Purpose | Aliases |\n| :--- | :--- | :--- |\n| `builtin` | Seal 官方标准校验器:拦截过短描述、主观模糊词与悬空例外条款。 | `default`, `official/builtin` |\n| `strict` | Seal 官方严格风控校验器:强校验字数、刚性定量约束、凭证依据与具体审批人角色。 | `official/strict` |\n| `hlab` | 合思实验室 (HLab) 结构化规则校验器:SOP 四段论结构、三元闭环判定、剥离处置动作与防漏判。 | `hlab-sop`, `hlab-rules`, `hlab-standard`, `official/hlab` |\n\n```bash\n#Inspectavailablelinters\nseal-useruleslinters\n\n#LintrulesusingHLabSOPstandard\nseal-useruleslint--linterhlab--corp<corpId>\n\n#LintlocalruleworkspaceofflinewithHLabstandard\nseal-useruleslint--linterhlab--file./rules.local.json\n```\n\n## Built-In Detection Rules (`builtin`)\n\n| Code | Level | Description | Recommendation |\n| :--- | :---: | :--- | :--- |\n| `TOO_SHORT` | `error` | Rule description is under 5 characters. | Add concrete conditions and criteria. |\n| `VAGUE_WORD` | `error` | Contains subjective/fuzziness words (`原则上`, `尽量`, `适当`, `酌情`, `一般情况下`, `合理控制`). | Replace with rigid thresholds, enums, or criteria. |\n| `HANGING_EXCEPTION` | `warning` | Exception trigger found (`除非`, `特殊情况`, `经批准`) without verifiable evidence keyword (`备注`, `附件`, `证明`, `邮件`, `截图`). | Specify exact evidence source in invoice/document. |\n\n## HLab SOP Detection Rules (`hlab`)\n\n| Code | Level | Description | Recommendation |\n| :--- | :---: | :--- | :--- |\n| `MISSING_CHECK_METHOD` | `error` | Missing `**检查方法**` section in rule description. | Add `**检查方法**:` specifying fields, vouchers, and normalization logic. |\n| `MISSING_EVAL_STANDARD` | `error` | Missing `**判定标准**` section in rule description. | Add `**判定标准**:` with standard branches. |\n| `INCOMPLETE_TERNARY_BRANCH` | `error` | Incomplete ternary branch under evaluation criteria (missing `PASS`, `FAIL`, or `证据不足`). | Provide complete ternary closure: `-PASS:`, `-FAIL:`, `-证据不足:`. |\n| `INSUFFICIENT_WITHOUT_MANUAL_REVIEW` | `warning` | `证据不足` branch does not specify escalating to `人工复核`. | Add `转人工复核` at the end of `证据不足` branch. |\n| `DISPOSAL_ACTION_LEAK` | `warning` | Contains whole-bill workflow disposal actions (`驳回单据`, `直接驳回`, `进行提醒`, `退回单据`). | Decouple disposal actions from rule text; rely on rule strictness or platform workflow. |\n| `SCOPE_FALSE_SKIP_PRONE` | `warning` | Scope contains material upload conditions (`若上传了`, `若提供了`, `附件需上传`). | Keep scope pure to business triggers; handle missing materials explicitly in FAIL branch to prevent silent SKIP. |\n| `RISK_SUPPRESSION` | `erroLine truncated
description:"v0.10.31: 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.33: 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."
`;var rh0=()=>{};var Vg1="iVBORw0KGgoAAAANSUhEUgAADVgAAAdwCAYAAACUWcTmAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAANWKADAAQAAAABAAAHcAAAAAD4n9OGAABAAElEQVR4AeydB4AdVfX/z246pNAD0hK6dOki0rsU+dMJJVIFRYoUFUFAQUCqgHSkxx8gTRCpFkB6CU06SQi9BEhC+u7/fu7b83J3dt7bt33f5nuStzNz5947M583c+fOvPO9p6Y+mMlEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREYA4kUDsHHrMOWQREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAQigd7jxo8TChEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYIwkogtUc+bXroEVABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABCBQUx9MKERABERABERABERABERABERABERABERABERABERABERABERABESgqwiMHz/eBgwY0FWb13ZFQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQATmcAKKYDWHnwA6fBEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYkwlIYDUnf/s6dhEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYwwlIYDWHnwA6fBEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYkwlIYDUnf/s6dhEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYwwlIYDWHnwA6fBEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYkwn0npMPXscuAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAj2RwP8+n26vfjbd3vpyho2fPN0+mjLTJs+qs/qaOhvYp8YWGtDLFh/U25YZ3NdWnr+/rTDvgJ6IQcckAhURqKkPVlFOZRIBERABERABERABERABERABERABERABERABERABERABERABERCBDiAwfvx4GzBAP9p2AFpVKQIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiMIcR+GhSnT347lT713tT7eOpM4OYqj5+LEzNEFdZ+MyKU5Zr4jLp9fat/r1ss28NtM0WG2KLzN1nDiOnw53TCUhgNaefATp+ERABERABERABERABERABERABERABERABERABERABERABEehiAhJYdfEXoM2LgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAhUPYFJ08z+7+Updsc7U8OxFARURKqyIKAqCKnqbVYQUdU2CK7iOiuIr4oirLBcgxArfHZZcrDttcwCNnefXlXPRgcgApUQkMCqEkrKIwIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIi0GEEJLDqMLSqWAREQAREQAREQAREQAREQAREQAREQAREQAREQAREYA4g8MR7M+2Cp6fY5JmFSFQhRlUQStUVBVUsF0VUCKiSSFZEsKqLkawa5yH/oN5mP195qK0/dPAcQFGHOKcTkMBqTj8DdPwiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIi0MUEJLDq4i+gCzY/ZcqUuNUBAwZ0wda1SREQAREQAREQAREQAREQAREQAREQAREQAREQARHoHAKd8S501AszbNT/psXIUwWhVDi2IK6qj5GriGRVEE4RlSoVWlUayYry+w2fx0Yst1DnQNNWRKCLCAQ9oUwEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAERKCaCFz035n20JgZ1stqQowqs9qaWmJVBR1VbRBZkdLLakN0qiCzCtMGgVXMURfW1YQsTHsFEdasMC0UCSWjOIvcbte++6V9MX2mHb7ytzypS6e/+93v7H//+1/uPuy888727W9/O35yMyhRBEoQ4NyXiYAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiECPIXDbbbfZiBEjGh0PP7aSxif90dXzks68G3k8P2VTYznNm67TvAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAh0BoGLHp1lD74zM6qh6kK4qprwqW+YMl9TR1pYHcRWtUFHhZaqLi6TFsJbhflCOYRVtbG818H6+KGOhnr+9v4ku/DlDzrj0Mpug/fz6Xv+bOa//vWvxkcmAi0loAhWLSWm/CIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAt2WAD+sdvQPp/xwy0cjYHbb00A7JgIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAI9msCo5+rt4XdDVKoaIlfVxChVHHCMPtXoyIO4KuSoy0ayqifOFeWJUxVqSCJZfW/hwfbox1/FuqiKHF4zIqt5+39qey+zYEztij/pbwC8p0/NhVc+TddpXgSaIyCBVXOEtF4EREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAERKBqCLz66qudtq/8iPvrX/+607aX3VBniMluvPHG7Ga1LAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiUIJAzT+vi2vqN9m3RA4li0DbCTw5xuyWl+qMIFQWIk8Rpqo+Cq1YDlKokL7m4v2D7IrFOgurwvqwoiaEsIpyKebNHv9wki+FdERaSKlq7fytlrEj73vLHvvoq7gNUkM4q1BPKBTque7tCbbUoH62/tDBrOkyQ1yVfUf/u9/9rmx0qy7b2VZu2H8H4FhXXHFF+3//7/+1siYVq4RATX2wSjIqjwiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAh0BIHx48fbgAEDOqLqHlun/6ja0QfYUQKrKVOmxF3X997R36DqFwEREAEREAEREAEREAEREAEREAEREAER6EwCs074btxcr9Me78zNalvdmEB7vwudNM3ssFvNJs2oi0KqWUE0FQVUUUiF6KreLtx5QVtt0X5lqYz+cIodevfYkKcg1KpHfBXKHvadobbvdxay0R9NsgPveyOsD3KTWiQniLjCNHyYDgqhfq7bcCmbu0+vsttpy0rEUlgqLErfje+8885NBEepwMrXE83Ko16ldbVl3zqjbHqsvj0EZdmoXb5O07YTUASrtjNUDSIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiLQqQQ6M1JXpx5YD96Yj3sZR3ntwcdZyaHNmDHDPv74Y1t00UULo95WUqiL8syaNct69eo4J5EuOqwu3Szff58+fZrsg66RJkiU0MkEGJ4YhzSZCHQmAdpEjHtNbW0Ydb4djHvX9OnTNYBBA0ucWfv169dufNvhK+oxVUydOtXq6upsrrnm6jHHpAMRAREQAREQgbYS8OhV1FN/1VFWc8B5ba2yWJ6+45gxY+ytt96y/v3729JLL22LLbZYbj+H9y4u6ilWUGJm7rnntgUXXDCu/frrr+2LL74okbNxMv3XJZZYonFia5fGjLaad0e3tnSx3JwSNezmZ2ts8vQQTSr8C9KoOA2Sp8ChJvyttQPXG9SsuMqh1VEslIviqTBdf5G5o7iK1NUWHmg/XW1Ru/iF960+aK8QVbE1j2SFwOumtz6zg749lOztbqlQygVSCIuYL2cIqDwPoirepfsy5ZgnLRv5qlydXbUu73cAjqka9h1mCMSw1kbdamv5uPEW/pHAqoXAlF0EREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEuppA+oNwR0WZ6upj7Enbf+ONN+yUU06Jh3Tsscfa6quv3pMOLx7Lhx9+aMcff3yc33vvvW3LLbfMPcZbbrnF7rjjjrjuF7/4ha2yyiq5+dLEyZMn24QJE2zhhRe23r1720svvWTnn39+zPLLX/7SlllmmTR77jyORb/61a/iuv3339++973v5eZLE99++2076aSTbNlll7UtttiiojJp+WqZHz16dBQ84XziNnPmTPv00099sUVTHLMGDx6cW2bcuHHRAWSzzTazHXfc0eaZZ56Y7/HHH7eLLroozh933HG21FJL2Zlnnmm77LJLm6+Xb775xr766qvc/ckmzjvvvNFJLZveluWzzz7b3nrzTVty2DDjfG2JTZs2ze677z7bZpttGonSvvzyy4od5bLb4zqqJqHnxxNmWcHZK3skLV/u16fG5huUL2B5cPRUO
Line truncated
`,"utf8"),{detected:z,configured:!0,configPath:Y,targetDir:U,action:"prepended"}}function rl($){let U=$?.targetSkillsDir??$S0(),Y=$?.configFile??US0(),z=YS0(),Q=!1;if(Tq(Y))try{let J=JSON.parse(eh0(Y,"utf8"));if(Array.isArray(J?.entries))Q=J.entries.some((I)=>I?.path===U)}catch{}return{detected:z,configured:Q,configPath:Y,targetDir:U}}var sl=()=>{};import{cpSync as Ag1,existsSync as kK,lstatSync as QS0,mkdirSync as Pg1,realpathSync as a2,rmSync as Bg1,symlinkSync as Tg1,unlinkSync as zS0}from"node:fs";import{homedir as JS0}from"node:os";import{dirname as IS0,join as t2}from"node:path";function jg1($,U){let Y=U?.baseHomeDir??JS0(),z=t2(Y,$.rootDirName),Q=U?.sourceSkillDir??t2(Y,".agents","skills","seal-use"),J=IS0(Q),I=t2(z,"skills"),K=t2(I,"seal-use");if(!kK(z))return{id:$.id,name:$.name,detected:!1,configured:!1,mode:"skipped_not_detected"};if(kK(I)&&kK(J))try{if(a2(I)===a2(J))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"parent_symlinked",targetPath:I}}catch{}Pg1(I,{recursive:!0});let G;try{G=QS0(K)}catch{G=void 0}let H=!1;if(G)if(G.isSymbolicLink()){try{if(a2(K)===a2(Q))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"already_linked",targetPath:K}}catch{}try{zS0(K)}catch{}}else if(G.isDirectory())Bg1(K,{recursive:!0,force:!0}),H=!0;else zS0(K);let W=process.platform==="win32"?"junction":"dir";try{return Tg1(Q,K,W),{id:$.id,name:$.name,detected:!0,configured:!0,mode:H?"replaced_real_dir":"linked",targetPath:K}}catch{try{return Ag1(Q,K,{recursive:!0}),{id:$.id,name:$.name,detected:!0,configured:!0,mode:"fallback_copied",targetPath:K}}catch(X){return{id:$.id,name:$.name,detected:!0,configured:!1,mode:"error",targetPath:K,error:X?.message||String(X)}}}}function Eg1($,U){let Y=U?.baseHomeDir??JS0(),z=t2(Y,$.rootDirName),Q=U?.sourceSkillDir??t2(Y,".agents","skills","seal-use"),J=IS0(Q),I=t2(z,"skills"),K=t2(I,"seal-use");if(!kK(z))return{id:$.id,name:$.name,detected:!1,configured:!1,mode:"not_detected"};if(kK(I)&&kK(J))try{if(a2(I)===a2(J))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"parent_symlinked",targetPath:I}}catch{}let G;try{G=QS0(K)}catch{G=void 0}if(G){if(G.isSymbolicLink())try{if(a2(K)===a2(Q))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"single_symlinked",targetPath:K}}catch{}else if(G.isDirectory())return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"real_directory",targetPath:K}}return{id:$.id,name:$.name,detected:!0,configured:!1,mode:"not_configured",targetPath:K}}function al($){return KS0.map((U)=>jg1(U,$))}function tl($){return KS0.map((U)=>Eg1(U,$))}var KS0;var el=o(()=>{KS0=[{id:"workbuddy",name:"WorkBuddy",rootDirName:".workbuddy"},{id:"claude",name:"Claude",rootDirName:".claude"},{id:"qoder",name:"Qoder",rootDirName:".qoder"}]});var $o=o(()=>{sl();el();sl();el()});import{existsSync as Cg1,mkdirSync as Uo,readFileSync as Rg1,rmSync as _g1,writeFileSync as GS0}from"node:fs";import{homedir as WS0}from"node:os";import{dirname as HS0,join as Eq}from"node:path";function Yo(){return XS0["SKILL.md"]||""}function ZS0($){return $.match(/^\s*version:\s*(\S+)\s*$/m)?.[1]}function qS0($=Eq(gz(),"SKILL.md")){try{return ZS0(Rg1($,"utf8"))}catch{return}}function gz(){return Eq(WS0(),".agents","skills","seal-use")}function hg1(){return Eq(WS0(),".agents","skills","seal-home")}function Sg1(){let $=hg1();if(Cg1($))try{return _g1($,{recursive:!0,force:!0}),!0}catch{return!1}return!1}function VS0($=gz()){Sg1(),Uo($,{recursive:!0});let U=[];for(let[Y,z]of Object.entries(XS0)){let Q=Eq($,Y);Uo(HS0(Q),{recursive:!0}),GS0(Q,z,"utf8"),U.push(Y)}for(let[Y,z]of Object.entries(vg1)){let Q=Eq($,Y);Uo(HS0(Q),{recursive:!0}),GS0(Q,z),U.push(Y)}return{targetDir:$,files:U}}var XS0,vg1,A24;var Cq=o(()=>{dl();dl();$o();XS0=ah0,vg1=Object.fromEntries(Object.entries(th0).map(([$,U])=>[$,Buffer.from(U,"base64")]));A24=ZS0(Yo())});function LS0(){return`#SealUse系统架构与运行规范白皮书
`;var sh0=()=>{};var Ng1="iVBORw0KGgoAAAANSUhEUgAADVgAAAdwCAYAAACUWcTmAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAANWKADAAQAAAABAAAHcAAAAAD4n9OGAABAAElEQVR4AeydB4AdVfX/z246pNAD0hK6dOki0rsU+dMJJVIFRYoUFUFAQUCqgHSkxx8gTRCpFkB6CU06SQi9BEhC+u7/fu7b83J3dt7bt33f5nuStzNz5947M583c+fOvPO9p6Y+mMlEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREYA4kUDsHHrMOWQREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAQigd7jxo8TChEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYIwkogtUc+bXroEVABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABCBQUx9MKERABERABERABERABERABERABERABERABERABERABERABERABESgqwiMHz/eBgwY0FWb13ZFQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQATmcAKKYDWHnwA6fBEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYkwlIYDUnf/s6dhEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYwwlIYDWHnwA6fBEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYkwlIYDUnf/s6dhEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYwwlIYDWHnwA6fBEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYkwn0npMPXscuAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAj2RwP8+n26vfjbd3vpyho2fPN0+mjLTJs+qs/qaOhvYp8YWGtDLFh/U25YZ3NdWnr+/rTDvgJ6IQcckAhURqKkPVlFOZRIBERABERABERABERABERABERABERABERABERABERABERABERCBDiAwfvx4GzBAP9p2AFpVKQIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiMIcR+GhSnT347lT713tT7eOpM4OYqj5+LEzNEFdZ+MyKU5Zr4jLp9fat/r1ss28NtM0WG2KLzN1nDiOnw53TCUhgNaefATp+ERABERABERABERABERABERABERABERABERABERABERABEehiAhJYdfEXoM2LgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAhUPYFJ08z+7+Updsc7U8OxFARURKqyIKAqCKnqbVYQUdU2CK7iOiuIr4oirLBcgxArfHZZcrDttcwCNnefXlXPRgcgApUQkMCqEkrKIwIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIi0GEEJLDqMLSqWAREQAREQAREQAREQAREQAREQAREQAREQAREQAREYA4g8MR7M+2Cp6fY5JmFSFQhRlUQStUVBVUsF0VUCKiSSFZEsKqLkawa5yH/oN5mP195qK0/dPAcQFGHOKcTkMBqTj8DdPwiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIi0MUEJLDq4i+gCzY/ZcqUuNUBAwZ0wda1SREQAREQAREQAREQAREQAREQAREQAREQAREQARHoHAKd8S501AszbNT/psXIUwWhVDi2IK6qj5GriGRVEE4RlSoVWlUayYry+w2fx0Yst1DnQNNWRKCLCAQ9oUwEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAERKCaCFz035n20JgZ1stqQowqs9qaWmJVBR1VbRBZkdLLakN0qiCzCtMGgVXMURfW1YQsTHsFEdasMC0UCSWjOIvcbte++6V9MX2mHb7ytzypS6e/+93v7H//+1/uPuy888727W9/O35yMyhRBEoQ4NyXiYAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiECPIXDbbbfZiBEjGh0PP7aSxif90dXzks68G3k8P2VTYznNm67TvAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAh0BoGLHp1lD74zM6qh6kK4qprwqW+YMl9TR1pYHcRWtUFHhZaqLi6TFsJbhflCOYRVtbG818H6+KGOhnr+9v4ku/DlDzrj0Mpug/fz6Xv+bOa//vWvxkcmAi0loAhWLSWm/CIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAt2WAD+sdvQPp/xwy0cjYHbb00A7JgIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAI9msCo5+rt4XdDVKoaIlfVxChVHHCMPtXoyIO4KuSoy0ayqifOFeWJUxVqSCJZfW/hwfbox1/FuqiKHF4zIqt5+39qey+zYEztij/pbwC8p0/NhVc+TddpXgSaIyCBVXOEtF4EREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAERKBqCLz66qudtq/8iPvrX/+607aX3VBniMluvPHG7Ga1LAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiUIJAzT+vi2vqN9m3RA4li0DbCTw5xuyWl+qMIFQWIk8Rpqo+Cq1YDlKokL7m4v2D7IrFOgurwvqwoiaEsIpyKebNHv9wki+FdERaSKlq7fytlrEj73vLHvvoq7gNUkM4q1BPKBTque7tCbbUoH62/tDBrOkyQ1yVfUf/u9/9rmx0qy7b2VZu2H8H4FhXXHFF+3//7/+1siYVq4RATX2wSjIqjwiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAh0BIHx48fbgAEDOqLqHlun/6ja0QfYUQKrKVOmxF3X997R36DqFwEREAEREAEREAEREAEREAEREAEREAER6EwCs074btxcr9Me78zNalvdmEB7vwudNM3ssFvNJs2oi0KqWUE0FQVUUUiF6KreLtx5QVtt0X5lqYz+cIodevfYkKcg1KpHfBXKHvadobbvdxay0R9NsgPveyOsD3KTWiQniLjCNHyYDgqhfq7bcCmbu0+vsttpy0rEUlgqLErfje+8885NBEepwMrXE83Ko16ldbVl3zqjbHqsvj0EZdmoXb5O07YTUASrtjNUDSIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiLQqQQ6M1JXpx5YD96Yj3sZR3ntwcdZyaHNmDHDPv74Y1t00UULo95WUqiL8syaNct69eo4J5EuOqwu3Szff58+fZrsg66RJkiU0MkEGJ4YhzSZCHQmAdpEjHtNbW0Ydb4djHvX9OnTNYBBA0ucWfv169dufNvhK+oxVUydOtXq6upsrrnm6jHHpAMRAREQAREQgbYS8OhV1FN/1VFWc8B5ba2yWJ6+45gxY+ytt96y/v3729JLL22LLbZYbj+H9y4u6ilWUGJm7rnntgUXXDCu/frrr+2LL74okbNxMv3XJZZYonFia5fGjLaad0e3tnSx3JwSNezmZ2ts8vQQTSr8C9KoOA2Sp8ChJvyttQPXG9SsuMqh1VEslIviqTBdf5G5o7iK1NUWHmg/XW1Ru/iF960+aK8QVbE1j2SFwOumtz6zg749lOztbqlQygVSCIuYL2cIqDwPoirepfsy5ZgnLRv5qlydXbUu73cAjqka9h1mCMSw1kbdamv5uPEW/pHAqoXAlF0EREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEuppA+oNwR0WZ6upj7Enbf+ONN+yUU06Jh3Tsscfa6quv3pMOLx7Lhx9+aMcff3yc33vvvW3LLbfMPcZbbrnF7rjjjrjuF7/4ha2yyiq5+dLEyZMn24QJE2zhhRe23r1720svvWTnn39+zPLLX/7SlllmmTR77jyORb/61a/iuv3339++973v5eZLE99++2076aSTbNlll7UtttiiojJp+WqZHz16dBQ84XziNnPmTPv00099sUVTHLMGDx6cW2bcuHHRAWSzzTazHXfc0eaZZ56Y7/HHH7eLLroozh933HG21FJL2Zlnnmm77LJLm6+Xb775xr766qvc/ckmzjvvvNFJLZveluWzzz7b3nrzTVty2DDjfG2JTZs2ze677z7bZpttGonSvvzyy4od5bLb4zqqJqHnxxNmWcHZK3skLV/u16fG5huUL2B5cPRUO
Line truncated
`,"utf8"),{detected:z,configured:!0,configPath:U,targetDir:Y,action:"prepended"}}function sl($){let Y=$?.targetSkillsDir??YS0(),U=$?.configFile??US0(),z=zS0(),Q=!1;if(jq(U))try{let J=JSON.parse($S0(U,"utf8"));if(Array.isArray(J?.entries))Q=J.entries.some((I)=>I?.path===Y)}catch{}return{detected:z,configured:Q,configPath:U,targetDir:Y}}var al=()=>{};import{cpSync as Cg1,existsSync as fK,lstatSync as JS0,mkdirSync as Rg1,realpathSync as a2,rmSync as _g1,symlinkSync as vg1,unlinkSync as QS0}from"node:fs";import{homedir as IS0}from"node:os";import{dirname as KS0,join as t2}from"node:path";function hg1($,Y){let U=Y?.baseHomeDir??IS0(),z=t2(U,$.rootDirName),Q=Y?.sourceSkillDir??t2(U,".agents","skills","seal-use"),J=KS0(Q),I=t2(z,"skills"),K=t2(I,"seal-use");if(!fK(z))return{id:$.id,name:$.name,detected:!1,configured:!1,mode:"skipped_not_detected"};if(fK(I)&&fK(J))try{if(a2(I)===a2(J))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"parent_symlinked",targetPath:I}}catch{}Rg1(I,{recursive:!0});let G;try{G=JS0(K)}catch{G=void 0}let H=!1;if(G)if(G.isSymbolicLink()){try{if(a2(K)===a2(Q))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"already_linked",targetPath:K}}catch{}try{QS0(K)}catch{}}else if(G.isDirectory())_g1(K,{recursive:!0,force:!0}),H=!0;else QS0(K);let W=process.platform==="win32"?"junction":"dir";try{return vg1(Q,K,W),{id:$.id,name:$.name,detected:!0,configured:!0,mode:H?"replaced_real_dir":"linked",targetPath:K}}catch{try{return Cg1(Q,K,{recursive:!0}),{id:$.id,name:$.name,detected:!0,configured:!0,mode:"fallback_copied",targetPath:K}}catch(X){return{id:$.id,name:$.name,detected:!0,configured:!1,mode:"error",targetPath:K,error:X?.message||String(X)}}}}function Sg1($,Y){let U=Y?.baseHomeDir??IS0(),z=t2(U,$.rootDirName),Q=Y?.sourceSkillDir??t2(U,".agents","skills","seal-use"),J=KS0(Q),I=t2(z,"skills"),K=t2(I,"seal-use");if(!fK(z))return{id:$.id,name:$.name,detected:!1,configured:!1,mode:"not_detected"};if(fK(I)&&fK(J))try{if(a2(I)===a2(J))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"parent_symlinked",targetPath:I}}catch{}let G;try{G=JS0(K)}catch{G=void 0}if(G){if(G.isSymbolicLink())try{if(a2(K)===a2(Q))return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"single_symlinked",targetPath:K}}catch{}else if(G.isDirectory())return{id:$.id,name:$.name,detected:!0,configured:!0,mode:"real_directory",targetPath:K}}return{id:$.id,name:$.name,detected:!0,configured:!1,mode:"not_configured",targetPath:K}}function tl($){return GS0.map((Y)=>hg1(Y,$))}function el($){return GS0.map((Y)=>Sg1(Y,$))}var GS0;var $o=m(()=>{GS0=[{id:"workbuddy",name:"WorkBuddy",rootDirName:".workbuddy"},{id:"claude",name:"Claude",rootDirName:".claude"},{id:"qoder",name:"Qoder",rootDirName:".qoder"}]});var Yo=m(()=>{al();$o();al();$o()});import{existsSync as gg1,mkdirSync as Uo,readFileSync as yg1,rmSync as kg1,writeFileSync as HS0}from"node:fs";import{homedir as XS0}from"node:os";import{dirname as WS0,join as Cq}from"node:path";function zo(){return ZS0["SKILL.md"]||""}function qS0($){return $.match(/^\s*version:\s*(\S+)\s*$/m)?.[1]}function VS0($=Cq(yz(),"SKILL.md")){try{return qS0(yg1($,"utf8"))}catch{return}}function yz(){return Cq(XS0(),".agents","skills","seal-use")}function fg1(){return Cq(XS0(),".agents","skills","seal-home")}function ug1(){let $=fg1();if(gg1($))try{return kg1($,{recursive:!0,force:!0}),!0}catch{return!1}return!1}function LS0($=yz()){ug1(),Uo($,{recursive:!0});let Y=[];for(let[U,z]of Object.entries(ZS0)){let Q=Cq($,U);Uo(WS0(Q),{recursive:!0}),HS0(Q,z,"utf8"),Y.push(U)}for(let[U,z]of Object.entries(xg1)){let Q=Cq($,U);Uo(WS0(Q),{recursive:!0}),HS0(Q,z),Y.push(U)}return{targetDir:$,files:Y}}var ZS0,xg1,i24;var Rq=m(()=>{ml();ml();Yo();ZS0=th0,xg1=Object.fromEntries(Object.entries(eh0).map(([$,Y])=>[$,Buffer.from(Y,"base64")]));i24=qS0(zo())});function FS0(){return`#SealUse系统架构与运行规范白皮书
`)}var AS0=o(()=>{X6()});async function PS0($,U,Y){let z=($??U??"").toLowerCase();if(z==="guide"||z==="doc"||z==="knowledge"||z==="book"){console.error(`\uD83D\uDCD6[SealUseDoctor]正在读取内嵌系统规范白皮书(纯内存只读)...
`),console.log(LS0());return}if(z==="paths"||z==="dirs"||z==="directories"){let I=Ko();c0(I.directories);return}if(z==="tenant"||z==="corp"||z==="enterprise"){let{selectCorp:I}=await Promise.resolve().then(() => (o4(),F_0)),{createSealClient:K}=await Promise.resolve().then(() => (i8(),R00)),{stringOption:G}=await Promise.resolve().then(() => (D4(),G_0)),{diagnoseTenantContract:H,formatTenantDoctorDashboard:W}=await Promise.resolve().then(() => (AS0(),DS0)),X=G(Y.options.corp)??(U&&U!==z?U:void 0)??(Y.command[2]&&Y.command[2]!==z?Y.command[2]:void 0),Z=I(X),q=await K(Z),V=await H(q,Z);if(!(V0(Y.options.quiet)||V0(Y.options.silent)))console.error(W(V));c0(V);return}let Q=Ko();if(!(V0(Y.options.quiet)||V0(Y.options.silent)))console.error(MS0(Q));c0(Q)}var BS0=o(()=>{NS0();Io();D4();J4()});var jS0;var TS0=o(()=>{jS0={openapi:"3.1.0",info:{title:"seal-use Wrapped API",version:"0.10.31",description:"HTTP contract for the seal-use wrapped backend API, served by the local HTTP adapter\n(`seal-usehttp`, or the `seal-useservicestart` daemon; default http://127.0.0.1:8787).\n\nThese endpoints describe the stable wrapped API for frontend developers and agents. They are\nnot the raw downstream Seal endpoints: seal-use is responsible for enterprise selection,\nsource authentication, response compaction, and diagnostics-friendly fields.\n\nEvery operation declares `x-implementation-status`, so a caller can tell what the running\nadapter actually serves:\n\n- `implemented` — routed by `src/http/routes.ts` today. `src/http/openapi-implementation.test.ts`\n fails when an `implemented` operation has no matching route.\n- `planned` — contract-only, designed but not routed yet. Calling it returns 404.\n\nThe same capabilities are reachable through the CLI, and through the optional MCP server when\nit is enabled.\n"},servers:[{url:"http://localhost:8787",description:"Local HTTP adapter (`seal-usehttp`, or the `seal-useservicestart` daemon). Loopback-only by default."}],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","x-implementation-status":"implemented",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","x-implementation-status":"planned",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","x-implementation-status":"planned",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","x-implementation-status":"planned",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
Line truncated
`)}var BS0=m(()=>{X6()});async function PS0($,Y,U){let z=($??Y??"").toLowerCase();if(z==="guide"||z==="doc"||z==="knowledge"||z==="book"){console.error(`\uD83D\uDCD6[SealUseDoctor]正在读取内嵌系统规范白皮书(纯内存只读)...
`),console.log(FS0());return}if(z==="paths"||z==="dirs"||z==="directories"){let I=Go();f0(I.directories);return}if(z==="tenant"||z==="corp"||z==="enterprise"){let{selectCorp:I}=await Promise.resolve().then(() => (f4(),w_0)),{createSealClient:K}=await Promise.resolve().then(() => (i8(),_00)),{stringOption:G}=await Promise.resolve().then(() => (D4(),H_0)),{diagnoseTenantContract:H,formatTenantDoctorDashboard:W}=await Promise.resolve().then(() => (BS0(),AS0)),X=G(U.options.corp)??(Y&&Y!==z?Y:void 0)??(U.command[2]&&U.command[2]!==z?U.command[2]:void 0),Z=I(X),q=await K(Z),V=await H(q,Z);if(!(Z0(U.options.quiet)||Z0(U.options.silent)))console.error(W(V));f0(V);return}let Q=Go();if(!(Z0(U.options.quiet)||Z0(U.options.silent)))console.error(NS0(Q));f0(Q)}var TS0=m(()=>{DS0();Ko();D4();J4()});var ES0;var jS0=m(()=>{ES0={openapi:"3.1.0",info:{title:"seal-use Wrapped API",version:"0.10.33",description:"HTTP contract for the seal-use wrapped backend API, served by the local HTTP adapter\n(`seal-usehttp`, or the `seal-useservicestart` daemon; default http://127.0.0.1:8787).\n\nThese endpoints describe the stable wrapped API for frontend developers and agents. They are\nnot the raw downstream Seal endpoints: seal-use is responsible for enterprise selection,\nsource authentication, response compaction, and diagnostics-friendly fields.\n\nEvery operation declares `x-implementation-status`, so a caller can tell what the running\nadapter actually serves:\n\n- `implemented` — routed by `src/http/routes.ts` today. `src/http/openapi-implementation.test.ts`\n fails when an `implemented` operation has no matching route.\n- `planned` — contract-only, designed but not routed yet. Calling it returns 404.\n\nThe same capabilities are reachable through the CLI, and through the optional MCP server when\nit is enabled.\n"},servers:[{url:"http://localhost:8787",description:"Local HTTP adapter (`seal-usehttp`, or the `seal-useservicestart` daemon). Loopback-only by default."}],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","x-implementation-status":"implemented",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","x-implementation-status":"planned",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","x-implementation-status":"planned",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","x-implementation-status":"planned",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
Line truncated
toloopback(\`--host 127.0.0.1\`) and do not expose the port to a network or an origin you
donotcontrol.
`}},parameters:{CorpId:{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."},Offset:{name:"offset",in:"query",schema:{type:"integer",minimum:0,default:0},description:"Zero-based pagination offset."},Limit:{name:"limit",in:"query",schema:{type:"integer",minimum:1,maximum:100,default:50},description:"Maximum number of records to return."},RuleId:{name:"ruleId",in:"path",required:!0,schema:{type:"string"},description:"Approval rule ID."},VersionId:{name:"versionId",in:"path",required:!0,schema:{type:"string"},description:"Published rule version ID."},DocumentId:{name:"documentId",in:"path",required:!0,schema:{type:"string"},description:"Approval knowledge document ID."},RecordId:{name:"recordId",in:"path",required:!0,schema:{type:"string"},description:"seal-use approval run record ID."},BatchId:{name:"batchId",in:"path",required:!0,schema:{type:"string"},description:"Simulation batch ID."}},responses:{BadRequest:{description:"Invalid request.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}},Unauthorized:{description:"Local service authentication failed or downstream Seal auth failed.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}},NotFound:{description:"Requested resource was not found.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}},schemas:{ErrorResponse:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}},CorpSummary:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","direct","seal"]},current:{type:"boolean"}}},SwitchCorpRequest:{type:"object",required:["corpId"],properties:{corpId:{type:"string"}}},SwitchCorpResponse:{type:"object",required:["current","id","name"],properties:{current:{type:"boolean"},id:{type:"string"},name:{type:"string"}}},SourceConfig:{type:"object",additionalProperties:!0,description:"Redacted Seal enterprise config resolved from the configured source."},AuthStage:{type:"object",additionalProperties:!0,required:["name","ok"],properties:{name:{type:"string",examples:["hose.openapi","hose.provisional","seal.sso","seal.whoami"]},ok:{type:"boolean"},error:{type:"string"}}},AuthDiagnosis:{type:"object",required:["stages"],properties:{stages:{type:"array",items:{$ref:"#/components/schemas/AuthStage"}}}},SealUser:{type:"object",additionalProperties:!0,required:["id","name"],properties:{id:{type:"string"},tenantId:{type:"string"},name:{type:"string"},isAdmin:{type:"boolean"},permissions:{type:"array",items:{type:"string"}}}},SealTenant:{type:"object",additionalProperties:!0,required:["id","name"],properties:{id:{type:"string"},name:{type:"string"},tenantSlug:{type:"string"}}},WhoamiResponse:{type:"object",required:["user","tenant"],properties:{user:{$ref:"#/components/schemas/SealUser"},tenant:{$ref:"#/components/schemas/SealTenant"}}},SessionResponse:{type:"object",additionalProperties:!0,required:["user","session"],properties:{user:{$ref:"#/components/schemas/SealUser"},session:{type:"object",additionalProperties:!0}}},ApprovalRule:{type:"object",additionalProperties:!0,required:["id","description","scope","strictness"],properties:{id:{type:"string"},description:{type:"string"},scope:{type:"string"},strictness:{type:"string",enum:["MUST_FOLLOW","SHOULD_FOLLOW","SUGGESTION"]},status:{type:"string"}}},ApprovalRuleInput:{type:"object",required:["description","scope","strictness"],properties:{description:{type:"string"},scope:{type:"string"},strictness:{type:"string",enum:["MUST_FOLLOW","SHOULD_FOLLOW","SUGGESTION"]}}},ApprovalRulePatch:{type:"object",additionalProperties:!1,properties:{description:{type:"string"},scope:{type:"string"},strictness:{type:"string",enum:["MUST_FOLLOW","SHOULD_FOLLOW","SUGGESTION"]}}},ApprovalRulesResponse:{type:"object",required:["rules"],properties:{rules:{type:"array",items:{$ref:"#/components/schemas/ApprovalRule"}},hasPendingDeletes:{type:"boolean"}}},RuleSetVersion:{type:"object",additionalProperties:!0,required:["id","versionNumber","versionName","rules"],properties:{id:{type:"string"},versionNumber:{type:"integer"},versionName:{type:"string"},publishedByName:{type:"string"},rules:{type:"array",items:{type:"object",additionalProperties:!0}}}},PublishRuleVersionRequest:{type:"object",required:["versionName"],properties:{versionName:{type:"string"}}},ApprovalDocument:{type:"object",additionalProperties:!0,required:["id","title","content"],properties:{id:{type:"string"},t
Line truncated
`}},parameters:{CorpId:{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."},Offset:{name:"offset",in:"query",schema:{type:"integer",minimum:0,default:0},description:"Zero-based pagination offset."},Limit:{name:"limit",in:"query",schema:{type:"integer",minimum:1,maximum:100,default:50},description:"Maximum number of records to return."},RuleId:{name:"ruleId",in:"path",required:!0,schema:{type:"string"},description:"Approval rule ID."},VersionId:{name:"versionId",in:"path",required:!0,schema:{type:"string"},description:"Published rule version ID."},DocumentId:{name:"documentId",in:"path",required:!0,schema:{type:"string"},description:"Approval knowledge document ID."},RecordId:{name:"recordId",in:"path",required:!0,schema:{type:"string"},description:"seal-use approval run record ID."},BatchId:{name:"batchId",in:"path",required:!0,schema:{type:"string"},description:"Simulation batch ID."}},responses:{BadRequest:{description:"Invalid request.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}},Unauthorized:{description:"Local service authentication failed or downstream Seal auth failed.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}},NotFound:{description:"Requested resource was not found.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}},schemas:{ErrorResponse:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}},CorpSummary:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","direct","seal"]},current:{type:"boolean"}}},SwitchCorpRequest:{type:"object",required:["corpId"],properties:{corpId:{type:"string"}}},SwitchCorpResponse:{type:"object",required:["current","id","name"],properties:{current:{type:"boolean"},id:{type:"string"},name:{type:"string"}}},SourceConfig:{type:"object",additionalProperties:!0,description:"Redacted Seal enterprise config resolved from the configured source."},AuthStage:{type:"object",additionalProperties:!0,required:["name","ok"],properties:{name:{type:"string",examples:["hose.openapi","hose.provisional","seal.sso","seal.whoami"]},ok:{type:"boolean"},error:{type:"string"}}},AuthDiagnosis:{type:"object",required:["stages"],properties:{stages:{type:"array",items:{$ref:"#/components/schemas/AuthStage"}}}},SealUser:{type:"object",additionalProperties:!0,required:["id","name"],properties:{id:{type:"string"},tenantId:{type:"string"},name:{type:"string"},isAdmin:{type:"boolean"},permissions:{type:"array",items:{type:"string"}}}},SealTenant:{type:"object",additionalProperties:!0,required:["id","name"],properties:{id:{type:"string"},name:{type:"string"},tenantSlug:{type:"string"}}},WhoamiResponse:{type:"object",required:["user","tenant"],properties:{user:{$ref:"#/components/schemas/SealUser"},tenant:{$ref:"#/components/schemas/SealTenant"}}},SessionResponse:{type:"object",additionalProperties:!0,required:["user","session"],properties:{user:{$ref:"#/components/schemas/SealUser"},session:{type:"object",additionalProperties:!0}}},ApprovalRule:{type:"object",additionalProperties:!0,required:["id","description","scope","strictness"],properties:{id:{type:"string"},description:{type:"string"},scope:{type:"string"},strictness:{type:"string",enum:["MUST_FOLLOW","SHOULD_FOLLOW","SUGGESTION"]},status:{type:"string"}}},ApprovalRuleInput:{type:"object",required:["description","scope","strictness"],properties:{description:{type:"string"},scope:{type:"string"},strictness:{type:"string",enum:["MUST_FOLLOW","SHOULD_FOLLOW","SUGGESTION"]}}},ApprovalRulePatch:{type:"object",additionalProperties:!1,properties:{description:{type:"string"},scope:{type:"string"},strictness:{type:"string",enum:["MUST_FOLLOW","SHOULD_FOLLOW","SUGGESTION"]}}},ApprovalRulesResponse:{type:"object",required:["rules"],properties:{rules:{type:"array",items:{$ref:"#/components/schemas/ApprovalRule"}},hasPendingDeletes:{type:"boolean"}}},RuleSetVersion:{type:"object",additionalProperties:!0,required:["id","versionNumber","versionName","rules"],properties:{id:{type:"string"},versionNumber:{type:"integer"},versionName:{type:"string"},publishedByName:{type:"string"},rules:{type:"array",items:{type:"object",additionalProperties:!0}}}},PublishRuleVersionRequest:{type:"object",required:["versionName"],properties:{versionName:{type:"string"}}},ApprovalDocument:{type:"object",additionalProperties:!0,required:["id","title","content"],properties:{id:{type:"string"},t
Line truncated
`);Q(z)})})}var gT=8787,yT="127.0.0.1";var Wo=o(()=>{vS0();t9()});async function hS0($){let U=s0($.options.port)??s0($.options.p),Y=S($.options.host)??S($.options.h),z=await kT({port:U,host:Y}),Q=()=>{z.close(()=>{process.exit(0)})};process.on("SIGINT",Q),process.on("SIGTERM",Q),await new Promise(()=>{})}var SS0=o(()=>{D4();Wo()});async function gS0($,U,Y,z){if($==="config"||$==="get"){await k0("seal_llm_config_get",U,Y,{},C0(z.options));return}if($==="providers"||$==="list"){await k0("seal_llm_providers_list",U,Y,{},C0(z.options));return}throw Error(`Unknownllmcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}var yS0=o(()=>{o4();J4()});async function kS0($,U){if($==="config"||$==="json"){Xo();return}let{startServer:Y}=await uS0().then(() => fS0);Y()}function Xo(){c0({mcpServers:{"seal-use":{type:"stdio",command:"seal-use",args:["mcp"],env:{SEAL_USE_MCP_ENABLED:"true"}}}})}var xS0=o(()=>{J4()});function bS0($){let U=vT();c0(U,{...C0($.options),allowFull:!0})}var iS0=o(()=>{Go();J4()});async function cS0($,U,Y,z){if($==="available"){await k0("seal_permissions_available_list",U,Y,{},C0(z.options));return}if($==="configs"||$==="list"){await k0("seal_permissions_configs_list",U,Y,{},C0(z.options));return}throw Error(`Unknownpermissionscommand:${$??""}.Run'seal-use help'foravailablecommands.`)}var nS0=o(()=>{o4();J4()});import{readFileSync as pS0}from"node:fs";async function dS0($,U,Y,z,Q,J,I){if(!$||$==="get"){await k0("seal_preference_get",Q,J,{},C0(I.options));return}if($==="decision"){if(U==="update"||!U){let K=S(I.options.input),G=K?JSON.parse(pS0(K,"utf8")):y8(I.json);if(!G||Object.keys(G).length===0)throw Error(`Usage:seal-usepreferencedecisionupdate--json'{"explicitApprove":"..."}'`);await k0("seal_preference_decision_update",Q,J,{...G,dryRun:V0(I.options.dryRun)??V0(I.options["dry-run"])},C0(I.options));return}}if($==="thinking-depth"||$==="thinkingDepth"){if(U==="set"){let K=S(I.options.default)??S(I.options.level)??z;if(K!=="medium"&&K!=="high")throw Error("Usage: seal-use preference thinking-depth set --default <medium|high>");await k0("seal_preference_thinking_depth_set",Q,J,{defaultLevel:K,dryRun:V0(I.options.dryRun)??V0(I.options["dry-run"])},C0(I.options));return}if(U==="policies"){if(Y==="list"||!Y){await k0("seal_preference_thinking_depth_policies_list",Q,J,{},C0(I.options));return}if(Y==="upsert"){let K=S(I.options.input),G=K?JSON.parse(pS0(K,"utf8")):y8(I.json);if(!G||!G.id||!G.name)throw Error(`Usage:seal-usepreferencethinking-depthpoliciesupsert--json'{"id":"...","name":"...","level":"high"}'`);await k0("seal_preference_thinking_depth_policies_upsert",Q,J,{...G,dryRun:V0(I.options.dryRun)??V0(I.options["dry-run"])},C0(I.options));return}if(Y==="remove"||Y==="delete"){let K=z??S(I.options.id)??S(I.options.policyId);if(!K)throw Error("Usage: seal-use preference thinking-depth policies remove <policyId>");await k0("seal_preference_thinking_depth_policies_remove",Q,J,{policyId:K,dryRun:V0(I.options.dryRun)??V0(I.options["dry-run"])},C0(I.options));return}}}throw Error(`Unknownpreferenceaction:${$??""}.Available:get,decisionupdate,thinking-depthset,thinking-depthpolicieslist/upsert/remove.`)}var mS0=o(()=>{o4();D4();J4()});async function lS0($={}){let U=s8(),Y=_4(),z=f2(U,{stateful:Y.stateful,defaultCorpId:Y.defaultCorpId,corpId:$.corpId},h3());console.log(`[probe]corp=${z.id}source=${z.source.type}`);let Q=await yK(z);console.log("[probe] seal enterprise"),console.log(JSON.stringify(Q,null,2));let J=await j1(z),I=await OO(J,{documentLimit:20,stylePreferencesEndpoint:z.seal.endpoints.approvalStylePreferences});console.log("[probe] approval context summary"),console.log(JSON.stringify({rules:I.rules.rules.length,hasPendingRuleDeletes:I.rules.hasPendingDeletes,documents:I.documents.articles.length,documentsTotal:I.documents.total,stylePreferences:I.stylePreferences.ok?"ok":`error:${I.stylePreferences.error}`},null,2))}var oS0=o(()=>{S3();i8();ET();X6()});async function rS0($,U,Y){let z=U??S(Y.options.corp)??($&&$!=="--corp"?$:void 0);await lS0({corpId:z})}var sS0=o(()=>{oS0();D4()});async function Zo($,U,Y,z,Q){if($==="count"){await k0("seal_approval_rules_list",Y,z,{countOnly:!0},C0(Q.options));return}if($==="list"){if(V0(Q.options.count)){await k0("seal_approval_rules_list",Y,z,{countOnly:!0},C0(Q.options));return}let J=s0(Q.options.limit),I=s0(Q.options.offset);if(V0(Q.options.summary)){await k0("seal_approval_rules_list",Y,z,{fields:q_0,limit:J,offset:I},C0(Q.options));return}let K=await o2("seal_approval_rules_list",Y,z,{limit:J,offset:I});V_0(K,V0(Q.options.full)===!0),c0(K);return}if($==="clear"){let J=V0(Q.options.yes)===!0,I=V0(Q.options.dryRun)??V0(Q.options["dry-run"])??!J;if(!J&&!I)throw D9("Refusing to clear rules without --yes. Use --dry-run to preview.",`seal-userulesclear--corp${z.id}--dry-run`);let K=await o2("seal_approval_rules_clear",Y,z,{dryRun:I,recode:V0(Q.options.recode)});if(!J&&I&&K&&typeof K==="object"){c0({...K,
Line truncated
`).filter(Boolean),J=Q.slice(-U);return{logFile:Y,lines:J,totalLines:Q.length}}async function sg1($){let U=bT($),Y=Lo($),z=vq($);Ug0($.stateDir);let Q=$.port??(process.env.PORT?Number.parseInt(process.env.PORT,10):gT),J=$.host??(process.env.HOST?process.env.HOST:yT);fT(U,`${process.pid}
`,{mode:384}),fT(Y,JSON.stringify({pid:process.pid,port:Q,host:J,version:$.version,startedAt:new Date().toISOString()},null,2),{mode:384}),xK(z,`servicestartingonhttp://${J}:${Q} pid=${process.pid}`);let I=null;try{I=await kT({port:Q,host:J,silent:!0}),xK(z,`service listening pid=${process.pid}`)}catch(G){if(xK(z,`service failed to bind port ${Q}: ${G instanceof Error?G.message:String(G)}`),uT(U)===process.pid)v9(U,{force:!0}),v9(Y,{force:!0});throw G}let K=()=>{if(I)I.close(),I=null;if(uT(U)===process.pid)v9(U,{force:!0}),v9(Y,{force:!0});xK(z,`stopped pid=${process.pid}`)};await new Promise((G)=>{let H=!1,W=()=>{if(H)return;H=!0,K(),process.off("SIGTERM",W),process.off("SIGINT",W),G()};process.once("SIGTERM",W),process.once("SIGINT",W)})}function tS0($){Ug0($.stateDir);let U=fK($);if(U.running)return U;let Y=$.launcher??{command:process.execPath,args:[$.entryFile]},z=[...Y.args??[],"service","run"];if($.port)z.push("--port",String($.port));if($.host)z.push("--host",String($.host));let Q=mg1(Y.command,z,{cwd:$.appRoot,detached:!0,stdio:["ignore","ignore","ignore"],env:process.env});Q.unref();let J=bT($);return fT(J,`${Q.pid}
`,{flag:"a",mode:384})}var Fo=o(()=>{Wo()});import{homedir as tg1}from"node:os";import{join as eg1}from"node:path";async function Oo($,U,Y){let z=Y?s0(Y.options.port)??s0(Y.options.p):void 0,Q=Y?S(Y.options.host)??S(Y.options.h):void 0,J=Y?s0(Y.options.lines)??s0(Y.options.n):void 0,I=await yz($,{appRoot:U.appRoot,entryFile:U.entryFile,stateDir:wo,version:P1,launcher:U.launcher,port:z,host:Q},{maxLines:J});if(I!==void 0)c0(I)}var wo;var Mo=o(()=>{t9();Fo();J4();D4();wo=eg1(tg1(),".config","seal-use")});import{existsSync as $y1,readFileSync as Yg0}from"node:fs";async function zg0($,U,Y,z,Q){if($==="batch-records"||$==="records"){let J=U??S(Q.options.batchId)??S(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation batch-records <batchId>");await k0("seal_simulation_batch_records_get",Y,z,{batchId:J,query:S(Q.options.query)},C0(Q.options));return}if($==="create"||$==="run"){let J=S(Q.options.mode)??S(Q.options.sourceSystem)??S(Q.options["source-system"])??"hosecloud",I=J==="material-pack"?"material_pack":J,K=S(Q.options.schemaConfig)??S(Q.options["schema-config"]),G=K?JSON.parse(Yg0(K,"utf8")):void 0,H=S(Q.options.input),W=H?JSON.parse(Yg0(H,"utf8")):y8(Q.json),X=S(Q.options.packageId)??S(Q.options["package-id"]),Z=u6(Q.options.packageIds)??u6(Q.options["package-ids"])??(X?[X]:void 0),q=u6(Q.options.flowIds)??u6(Q.options["flow-ids"])??u6(Q.options.documentSn)??u6(Q.options["document-sn"]),V=S(Q.options.signKey)??S(Q.options["sign-key"])??S(Q.options.integration),F=V0(Q.options.noWait)??V0(Q.options["no-wait"]);await k0("seal_simulation_batch_create",Y,z,{mode:I,sourceSystem:I,flowIds:q,documentSn:q,rejectNodeName:S(Q.options.rejectNode)??S(Q.options["reject-node"])??null,thinkingDepthOverride:S(Q.options.thinkingDepth)??S(Q.options["thinking-depth"]),skipInvoiceGeneration:V0(Q.options.skipInvoiceGeneration)??V0(Q.options["skip-invoice-generation"]),skipExpenseExtraction:V0(Q.options.skipExpenseExtraction)??V0(Q.options["skip-expense-extraction"]),disableAttachmentCache:V0(Q.options.disableAttachmentCache)??V0(Q.options["disable-attachment-cache"]),signKey:V,packageIds:Z,packageId:X,templateId:S(Q.options.templateId)??S(Q.options["template-id"]),schemaConfig:G,requestIds:u6(Q.options.requestIds)??u6(Q.options["request-ids"]),workflowTypeId:S(Q.options.workflowTypeId)??S(Q.options["workflow-type-id"]),flowStatusList:u6(Q.options.flowStatusList)?.map(Number)??u6(Q.options["flow-status-list"])?.map(Number),businessCodes:u6(Q.options.businessCodes)??u6(Q.options["business-codes"]),documentType:S(Q.options.documentType)??S(Q.options["document-type"]),startTime:s0(Q.options.startTime)??s0(Q.options["start-time"]),endTime:s0(Q.options.endTime)??s0(Q.options["end-time"]),status:u6(Q.options.status),limit:s0(Q.options.limit),noWait:F,rawParams:W},C0(Q.options));return}if($==="wait"){let J=U??S(Q.options.batchId)??S(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s]");await k0("seal_simulation_batch_wait",Y,z,{batchId:J,timeout:S(Q.options.timeout),pollInterval:S(Q.options.pollInterval)??S(Q.options["poll-interval"])},C0(Q.options));return}if($==="status"){let J=U??S(Q.options.batchId)??S(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation status <batchId>");await k0("seal_simulation_batch_status",Y,z,{batchId:J},C0(Q.options));return}if($==="clean"||$==="delete"){let J=U??S(Q.options.batchId)??S(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation clean <batchId>");await k0("seal_simulation_batch_clean",Y,z,{batchId:J},C0(Q.options));return}if($==="specifications"){let J=U??S(Q.options.integration)??S(Q.options.signKey)??S(Q.options["sign-key"]);await k0("seal_simulation_specifications_list",Y,z,{signKey:J},C0(Q.options));return}if($==="approval-definitions"||$==="definitions"){await k0("seal_simulation_feishu_approval_definitions_list",Y,z,{},C0(Q.options));return}if($==="list"){await k0("seal_simulation_batches_list",Y,z,{limit:s0(Q.options.limit)},C0(Q.options));return}if($==="get"){let J=U??S(Q.options.batchId)??S(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation get <batchId>");await k0("seal_simulation_batch_get",Y,z,{batchId:J},C0(Q.options));return}if($==="templates"){await k0("seal_simulation_templates_get",Y,z,{},C0(Q.options));return}if($==="integrations"){await k0("seal_simulation_integrations_get",Y,z,{},C0(Q.options));return}if($==="package-upload"){let J=U??S(Q.options.file);if(!J)throw Error("Usage: seal-use simulation package-upload <材料包.zip>");if(!$y1(J))throw Error(`Filenotfound:${J}`);await k0("seal_simulation_material_package_upload",Y,z,{filePath:J},C0(Q.options));return}throw Error(`Unknownsimulationcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}var Qg0=o(()=>{o4();D4();J4()});import{existsSync as Jg0}from"node:fs";import{join as iT}from"node:path";function Ig0($,U,Y){if($==="dump"||$==="cat"||$==="show"){process.stdout.write(`${YoLine truncated
`);return}if($==="install"||$==="init"||$==="sync"){let z=V0(Y.options.local)||V0(Y.options.workspace),Q=S(Y.options.dir)??S(Y.options.target)??U,J=Q?Q:z?iT(process.cwd(),".agents","skills","seal-use"):gz(),I=VS0(J),K=!z&&!Q,G=K?ol():void 0,H=K?al():void 0;c0({installed:!0,targetDir:I.targetDir,fileCount:I.files.length,files:I.files,...G?{antigravity:G}:{},...H?{hosts:H}:{}});return}if($==="status"||$==="get"||!$){let z=gz(),Q=iT(process.cwd(),".agents","skills","seal-use"),J=rl(),I=tl();c0({global:{dir:z,installed:Jg0(iT(z,"SKILL.md"))},local:{dir:Q,installed:Jg0(iT(Q,"SKILL.md"))},antigravity:J,hosts:I});return}throw Error(`Unknownskillcommand:${$}.Run'seal-use help'foravailablecommands.`)}var Kg0=o(()=>{$o();Cq();D4();J4()});async function Gg0($,U){if($==="config"){c0(await yK(U));return}throw Error(`Unknownsourcecommand:${$??""}.Run'seal-use help'foravailablecommands.`)}var Hg0=o(()=>{ET();J4()});function No($){if(typeof $!=="string"||!$.trim())return"UNKNOWN";let U=$.toUpperCase().trim();if(U==="APPROVE"||U==="PASS")return"APPROVE";if(U==="REJECT"||U==="DENIED")return"REJECT";if(U==="MANUAL"||U==="ASSISTED")return"MANUAL";if(U==="ERROR"||U==="FAILED")return"ERROR";return U}async function Wg0($){let{sourceCorp:U,targetCorp:Y,sourceClient:z,targetClient:Q,samples:J=10,dryRun:I=!1,pollIntervalMs:K=2000,timeoutMs:G=45000,snPrefix:H="REG_",fetchFn:W=fetch}=$;if(Y.environment!=="test")throw new w4(`重放目标企业「${Y.name}」(${Y.id})的环境为「${Y.environment}」,非测试环境!
`+"硬性安全规定:自动化回归测试矩阵严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-usecorpsbind-test${U.id}<testCorpId>`);let X=await cU(Q),q=(Array.isArray(X.features)?X.features:[]).find((d)=>d?.code==="ai-approval"),V=typeof q?.balance==="number"?q.balance:0,F=typeof q?.deductionAmount==="number"&&q.deductionAmount>0?q.deductionAmount:120,O=J*F;if(V<O)throw new w4(`测试企业「${Y.name}」AI审批额度不足:当前剩余${V}点,本次回归抽样${J}笔需要约${O}点。
`+"为防止测试环境额度耗尽中断业务,已硬性拦截并拒绝发起测试单据注入。",2,`请为测试企业「${Y.id}」充值AI审批额度,或降低抽样笔数(--samples${Math.max(1,Math.floor(V/F))})`);let w=await b4(z,{limit:J,status:"completed"}),M=Array.isArray(w.records)?w.records:[];if(M.length===0){let d=await b4(z,{limit:J});M=Array.isArray(d.records)?d.records:[]}if(M.length===0)throw new w4(`在母企业「${U.name}」(${U.id})中未检索到任何历史审批单据,无法抽取回归样本。`,2);if(M=M.slice(0,J),I){let d=M.map((t)=>{let $0=t.sourceDocumentSN??t.id,g=t?.result?.decision??t.aiDecision??t?.decision,p=No(g),e=t?.result?.summary??t.aiSummary;return{sn:$0,sourceRecordId:t.id,prodDecision:p,prodSummary:e,status:"DRY_RUN"}});return{ok:!0,verdict:"DRY_RUN",safeToPublish:!0,timestamp:new Date().toISOString(),sourceCorp:{id:U.id,name:U.name,environment:U.environment??"production"},targetCorp:{id:Y.id,name:Y.name,environment:Y.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:V,deductionAmount:F,estimatedRequired:O},metrics:{sampleCount:d.length,successCount:d.length,failureCount:0,matchCount:d.length,flipCount:0,concordanceRate:1},flips:[],records:d}}let N=await Ip(Q,Y),D=[];for(let d of M){let t=Date.now(),$0=d.sourceDocumentSN??d.id,g=No(d?.result?.decision??d.aiDecision??d?.decision),p=d?.result?.summary??d.aiSummary;try{let e=await H4(z,d.id),y=`${H}${$0}`,s=Qp(e,{snPrefix:H,docIdPrefix:H});await Jp(N.incomingDocumentWebhook.url,N.secret,s,W,A6(Y.seal));let U0=null,O0=Date.now();while(Date.now()-O0<G){await new Promise((W0)=>setTimeout(W0,K));let a=await b4(Q,{sourceDocumentSN:y,limit:1});if(a.records&&a.records.length>0){let W0=a.records[0];if(W0.status==="completed"||W0.status==="failed"){U0=W0;break}}}if(!U0){D.push({sn:$0,sourceRecordId:d.id,prodDecision:g,prodSummary:p,status:"FAILED",error:`测试租户单据审核超时(${Math.round(G/1000)}s未完成)`,durationMs:Date.now()-t});continue}let E0=No(U0?.result?.decision??U0.aiDecision??U0?.decision??(U0.status==="completed"?"APPROVE":"ERROR")),G0=U0?.result?.summary??U0.aiSummary,T0=g===E0,b0=T0?"MATCHED":"FLIPPED",U1={sn:$0,sourceRecordId:d.id,prodDecision:g,prodSummary:p,testRecordId:U0.id,testDecision:E0,testSummary:G0,status:b0,durationMs:Date.now()-t};if(!T0)U1.diff={from:g,to:E0,reasonDiff:G0&&p&&G0!==p?`生产:${p.slice(0,60)}...->测试:${G0.slice(0,60)}...`:void 0};D.push(U1)}catch(e){D.push({sn:$0,sourceRecordId:d.id,prodDecision:g,prodSummary:p,status:"FAILED",error:e instanceof Error?e.message:String(e),durationMs:Date.now()-t})}}let B=D.filter((d)=>d.status==="MATCHED"||d.status==="FLIPPED"),T=D.filter((d)=>d.status==="MATCHED"),A=D.filter((d)=>d.status==="FLIPPED"),j=D.filter((d)=>d.status==="FAILED").length,C=T.length,b=A.length,x=C+b,h=x>0?C/x:0,i=b>0,c=i?"REGRESSIONS_DETECTED":"CLEAN",z0=!i&&j===0,k;try{let d=await cU(Q),$0=(Array.isArray(d.features)?d.features:[]).find((g)=>g?.code==="ai-approval");if(typeof $0?.balance==="number")k=$0.balance}catch{}return{ok:!i&&j===0,verdict:c,safeToPublish:z0,timestamp:new Date().toISOString(),sourceCorp:{id:U.id,name:U.name,environment:U.environment??"production"},targetCorp:{id:Y.id,name:Y.name,environment:Y.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:V,deductionAmount:F,estimatedRequired:O,balanceAfter:k},metrics:{sampleCount:D.length,successCount:B.length,failureCount:j,matchCount:C,flipCount:b,concordanceRate:Number(h.toFixed(4))},flips:A,records:D}}function Xg0($){let{sourceCorp:U,targetCorp:Y,verdict:z,safeToPublish:Q,metrics:J,quota:I,flips:K,records:G}=$,H=z==="CLEAN"?"\uD83D\uDFE2 决策完全一致 (CLEAN - 无回归)":z==="DRY_RUN"?"⚪ 预演模式 (DRY-RUN)":"\uD83D\uDD34 发现决策翻转 (REGRESSIONS_DETECTED)",W=["",`\uD83E\uDDEA[SealUseTest]规则回归测试矩阵:生产「${U.name}」->测试靶场「${Y.name}」`,`判定:${H}·准许发布:${Q?"YES (可安全上线)":"NO (存在行为偏离/待复核)"}`," "+"─".repeat(65),`样本总数:${J.sampleCount}|一致通过:${J.matchCount}|决策翻转:${J.flipCount}|异常失败:${J.failureCount}`,`一致率:${(J.concordanceRate*100).toFixed(1)}%|消耗预估:${I.estimatedRequired}点(余量:${I.balanceBefore}${I.balanceAfter!==void0?` -> ${I.balanceAfter}`:""})`," "+"─".repeat(65)];if(K.length>0){W.push(`⚠️决策翻转清单(${K.length}笔单据在新规则下结果改变):`);for(let X of K)if(W.push(`•单据[${X.sn}]:原生产判定「${X.prodDecision}」➔测试新判定「${X.testDecision}」`),X.diff?.reasonDiff)W.push(`理由差异:${X.diff.reasonDiff}`);W.push(" "+"─".repeat(65)),W.push(" \uD83D\uDC49 建议: 请检查上述翻转单据是否符合预期修正。若为意外误杀,请调整测试环境规则后再次回归。")}else if(z==="CLEAN")W.push(" ✓ 全部样本在新规则下的审核决策与生产历史 100% 吻合,无任
Line truncated
`)}var Zg0=o(()=>{L$();X6();SZ()});async function Do($,U,Y){let z=($??U??"regression").toLowerCase();if(z==="regression"||z==="regress"||z==="matrix"){let Q=S(Y.options.corp)??(U&&U!==z?U:void 0),J=E1(Q),I=J,K=J;if(J.environment==="test"){K=J;let M=S(Y.options["prod-corp"])??S(Y.options.prod)??J.prodCorpId;if(!M)throw new w4(`测试企业「${J.name}」(${J.id})未绑定生产母企业,无法拉取历史样本。
`+"请建立绑定或通过 --prod-corp 参数指定生产企业来源。",2,`seal-usecorpsbind-test<prodCorpId>${J.id}`);I=E1(M)}else{I=J;let M=S(Y.options["test-corp"])??S(Y.options.test)??J.testCorpId;if(!M)throw new w4(`生产企业「${J.name}」(${J.id})未绑定测试靶场企业。
`+"硬性规定:回归测试严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-usecorpsbind-test${J.id}<testCorpId>`);K=E1(M)}let G=await j1(I),H=await j1(K),W=s0(Y.options.samples)??s0(Y.options.limit)??s0(Y.options.n)??10,X=V0(Y.options["dry-run"]),Z=V0(Y.options["fail-on-flips"]),q=s0(Y.options["poll-interval"])??2000,V=s0(Y.options.timeout)??45000,F=S(Y.options["sn-prefix"])??"REG_",O=await Wg0({sourceCorp:I,targetCorp:K,sourceClient:G,targetClient:H,samples:W,dryRun:X,pollIntervalMs:q,timeoutMs:V,snPrefix:F,failOnFlips:Z});if(!(V0(Y.options.quiet)||V0(Y.options.silent)))console.error(Xg0(O));if(c0(O),Z&&!O.ok)throw new w4(`回归测试发现${O.metrics.flipCount}笔单据决策翻转,已按--fail-on-flips策略非零终止。`,1);return}throw new w4(`未知的test子命令:"${z}"。
可用子命令:seal-usetestregression[--corp<id>][--samples<N>][--dry-run]`,2,"seal-use test regression --help")}var qg0=o(()=>{L$();o4();D4();J4();i8();Zg0()});async function Vg0($,U,Y,z){if(!$)throw Error("Usage: seal-use tool <toolName> [--json '{...}']");await k0($,U,Y,y8(z.json),C0(z.options))}var Lg0=o(()=>{o4();D4();J4()});function Fg0(){c0(Vq.map(($)=>({name:$.name,description:$.description})))}var wg0=o(()=>{Fq();J4()});function cT($=process.execPath,U=import.meta.url){if(U.includes("/$bunfs/")||U.includes("\\$bunfs\\"))return!0;let Y=$.toLowerCase().replace(/\\/g,"/");return!Y.endsWith("/bun")&&!Y.endsWith("/bun.exe")&&!Y.endsWith("/node")&&!Y.endsWith("/node.exe")}var Og0=o(()=>{Cq()});import{chmodSync as Uy1,mkdirSync as Yy1,readdirSync as zy1,renameSync as Ao,rmSync as Qy1,unlinkSync as Ag0,writeFileSync as Mg0}from"node:fs";import{basename as Jy1,dirname as Iy1,join as pT}from"node:path";import{spawnSync as uK}from"node:child_process";async function Bg0($,U={}){let Y={appRoot:$.appRoot,entryFile:$.entryFile,stateDir:wo,version:P1,launcher:$.launcher},z=U.repo||process.env[Ky1]?.trim()||process.env[Gy1]?.trim()||Pg0,Q=U.targetVersion?.trim(),J=Q&&Q.toLowerCase()!=="latest"?Q:void 0;if(J){let D=J.replace(/^v/,""),B=Cg0(D,P1);if(B<0)if(!xS&&U.force);else{c0({updated:!1,currentVersion:P1,targetVersion:D,mode:cT()?"binary":"source",message:!xS?`Cannotdowngradeseal-usefromdevbuildv${P1}toreleasev${D}.Use--forcetooverwrite.`:`Cannotdowngradeseal-usefromv${P1}toolderversionv${D}.Updatesmustbeforward-only.`});return}if(B===0&&!U.force){c0({updated:!1,currentVersion:P1,targetVersion:D,mode:cT()?"binary":"source",message:`seal-useisalreadyatversionv${P1}.Use--forcetoreinstall.`});return}}if(U.changelogOnly){let D=await Po(z,U.limit??10);c0({currentVersion:P1,totalQueried:D.length,releases:D.map((B)=>({version:B.version,tagName:B.tagName,publishedAt:B.publishedAt,author:B.author,releaseNotes:B.notes,releaseUrl:B.htmlUrl,isCurrent:B.version===P1,isNewer:hq(B.version,P1)}))});return}if(!cT()){if(U.checkOnly){let B=await Po(z,30),T=B[0],A=T?.version??P1,j=B.find((x)=>x.version===P1),C=hq(A,P1),b=B.filter((x)=>hq(x.version,P1));c0({updated:!1,updateAvailable:C,currentVersion:P1,currentVersionPublishedAt:j?.publishedAt,latestVersion:A,latestVersionPublishedAt:T?.publishedAt,behindCount:b.length,pendingReleases:b.map((x)=>({version:x.version,tagName:x.tagName,publishedAt:x.publishedAt,author:x.author,releaseNotes:x.notes,releaseUrl:x.htmlUrl})),releaseNotes:T?.notes??"",releaseUrl:T?.htmlUrl??"",mode:"source",message:"Running in source development mode. Run 'seal-use update' to git pull & bun install."});return}let D=fK(Y).running;if(D)await yz("stop",Y);try{Dg0("git",["-C",$.appRoot,"pull","--ff-only"])}catch(B){console.error(`gitpullskipped:${BinstanceofError?B.message:String(B)}`)}if(Dg0("bun",["install"],{cwd:$.appRoot}),D)await yz("start",Y);c0({updated:!0,serviceRestarted:D,version:P1,mode:"source"});return}let I=Wy1(),K=Xy1(),G=await Po(z,30),H=J?G.find((D)=>D.version===J||D.tagName===J||D.tagName===`v${J}`)??await Ng0(z,J):G[0]??await Ng0(z);if(!H){c0({updated:!1,currentVersion:P1,mode:"binary",message:`Failedtoqueryreleasesfromrepository'${z}'`});return}let W=H.version,X=G.find((D)=>D.version===P1),Z=hq(W,P1),q=Z||Boolean(U.force),V=G.filter((D)=>hq(D.version,P1));if(U.checkOnly){c0({updated:!1,updateAvailable:Z,currentVersion:P1,currentVersionPublishedAt:X?.publishedAt,latestVersion:W,latestVersionPublishedAt:H.publishedAt,behindCount:V.length,pendingReleases:V.map((D)=>({version:D.version,tagName:D.tagName,publishedAt:D.publishedAt,author:D.author,releaseNotes:D.notes,releaseUrl:D.htmlUrl})),releaseNotes:H.notes,releaseUrl:H.htmlUrl,mode:"binary"});return}if(!q){c0({updated:!1,currentVersion:P1,currentVersionPublishedAt:X?.publishedAt,latestVersion:W,latestVersionPublishedAt:H.publishedAt,mode:"binary",message:`seal-useisalreadyuptodate(v${P1})`});return}let F=qy1(H.assets,I,K);if(!F)throw Error(`Nocompatiblebinaryfoundfor${I}-${K}inreleasev${W}.Availableassets:${H.assets.map((D)=>D.name).join(", ")}`);let O=fK(Y).running;if(O)await yz("stop",Y);let w=process.execPath,M=Iy1(w),N=pT(M,`.tmp-update-${Date.now()}`);Yy1(N,{recursive:!0});try{let D=pT(N,F.name);await Vy1(F.downloadUrl,D,H.tagName,F.name);let B=D;if(F.name.endsWith(".tar.gz")||F.name.endsWith(".tgz"))B=Ly1(D,N,I);else if(F.name.endsWith(".zip"))B=Fy1(D,N,I);if(Uy1(B,493),process.platform==="darwin")try{uK("/usr/bin/codesign",["--remove-signature",B],{stdio:"ignore"}),uK("/usr/bin/codesign",["--force","--sign","-",B],{stdio:"ignore"})}catch{}if(process.platform==="win32"){let A=`${w}.old.${Date.now()}`;try{Ao(w,A)}catch{}Ao(B,w)}else Ao(B,w);if(O)await yz("start",Y);let T=Hy1(w,W);c0({updated:!0,fromVersion:P1,toVersion:W,serviceRestarted:O,skillSynced:T.targetDir??!1,skillVersion:T.version??!1,mode:"binary"})}finally{try{Qy1(N,{recursive:!0,force:!0})}catch{}}}function
Line truncated
`)}catch{}}async function Vy1($,U,Y,z){let Q=Bo(),J=[],I=Y?Y.startsWith("v")?Y:`v${Y}`:void 0,K=z||$.split("/").pop()||"";if(Q!=="github"){if(I&&K)J.push(`https://git.ying-qing.cn/gitea/seal-use/releases/download/${I}/${K}`,`https://git.ying-qing.cn/gitea/seal-home/releases/download/${I}/${K}`);if($.startsWith("https://git.ying-qing.cn"))J.push($)}if(Q!=="gitea")if(I&&K){let F=`https://github.com/${Pg0}/releases/download/${I}/${K}`;if(!process.env.CI)J.push(`https://ghfast.top/${F}`,`https://gh.ddlc.top/${F}`);J.push(F)}else if($.includes("github.com")){if(!process.env.CI)J.push(`https://ghfast.top/${$}`,`https://gh.ddlc.top/${$}`);J.push($)}else J.push($);let G=Array.from(new Set(J)),H,W=6000,X=6000,Z=307200,q=1e4,V=180000;for(let F=0;F<G.length;F++){let O=G[F],w=new AbortController,M="",N=(A)=>{M=A;try{w.abort()}catch{}},D=setTimeout(()=>{N("Connection timed out (no response headers within 6s)")},W),B,T;try{nT(`==> [${F+1}/${G.length}] Downloading via: ${O}`);let A=await fetch(O,{signal:w.signal});if(D)clearTimeout(D),D=void 0;if(!A.ok)throw Error(`HTTP ${A.status} ${A.statusText}`);B=setTimeout(()=>{N("Overall download time exceeded 3 minutes")},V);let j=Number(A.headers.get("content-length"))||0,C=A.body?.getReader();if(!C){let c=Buffer.from(await A.arrayBuffer());if(c.length<1000)throw Error(`Downloaded content is suspiciously small (${c.length} bytes)`);Mg0(U,c),nT(`✓ Download succeeded (${(c.length/1024/1024).toFixed(1)} MB)`);return}let b=[],x=0,h=0;T=setTimeout(()=>{if(x<Z){let c=(x/1024).toFixed(1);N(`Initial transfer too slow (${c} KB < 300 KB in 6s), switching mirror...`)}},X);while(!0){let c=C.read(),z0,k=new Promise((g,p)=>{z0=setTimeout(()=>{p(Error("Data transfer stalled (no chunk received for 10s)"))},q)}),d;try{d=await Promise.race([c,k])}finally{if(z0)clearTimeout(z0)}let{done:t,value:$0}=d;if(t)break;if($0){if(b.push($0),x+=$0.length,T&&x>=Z)clearTimeout(T),T=void 0;let g=Date.now();if(g-h>200){h=g;let p=j?Math.round(x/j*100):0,e=(x/1048576).toFixed(1),y=j?(j/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${p}% (${e} / ${y} MB)...`)}catch{}}}}try{process.stderr.write(`
`);Q(z)})})}var yT=8787,kT="127.0.0.1";var Xo=m(()=>{hS0();e9()});async function SS0($){let Y=s0($.options.port)??s0($.options.p),U=h($.options.host)??h($.options.h),z=await xT({port:Y,host:U}),Q=()=>{z.close(()=>{process.exit(0)})};process.on("SIGINT",Q),process.on("SIGTERM",Q),await new Promise(()=>{})}var gS0=m(()=>{D4();Xo()});async function yS0($,Y,U,z){if($==="config"||$==="get"){await k0("seal_llm_config_get",Y,U,{},C0(z.options));return}if($==="providers"||$==="list"){await k0("seal_llm_providers_list",Y,U,{},C0(z.options));return}throw Error(`Unknownllmcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}var kS0=m(()=>{f4();J4()});async function xS0($,Y){if($==="config"||$==="json"){Zo();return}let{startServer:U}=await bS0().then(() => uS0);U()}function Zo(){f0({mcpServers:{"seal-use":{type:"stdio",command:"seal-use",args:["mcp"],env:{SEAL_USE_MCP_ENABLED:"true"}}}})}var fS0=m(()=>{J4()});function iS0($){let Y=hT();f0(Y,{...C0($.options),allowFull:!0})}var cS0=m(()=>{Ho();J4()});async function nS0($,Y,U,z){if($==="available"){await k0("seal_permissions_available_list",Y,U,{},C0(z.options));return}if($==="configs"||$==="list"){await k0("seal_permissions_configs_list",Y,U,{},C0(z.options));return}throw Error(`Unknownpermissionscommand:${$??""}.Run'seal-use help'foravailablecommands.`)}var pS0=m(()=>{f4();J4()});import{readFileSync as dS0}from"node:fs";async function mS0($,Y,U,z,Q,J,I){if(!$||$==="get"){await k0("seal_preference_get",Q,J,{},C0(I.options));return}if($==="decision"){if(Y==="update"||!Y){let K=h(I.options.input),G=K?JSON.parse(dS0(K,"utf8")):y8(I.json);if(!G||Object.keys(G).length===0)throw Error(`Usage:seal-usepreferencedecisionupdate--json'{"explicitApprove":"..."}'`);await k0("seal_preference_decision_update",Q,J,{...G,dryRun:Z0(I.options.dryRun)??Z0(I.options["dry-run"])},C0(I.options));return}}if($==="thinking-depth"||$==="thinkingDepth"){if(Y==="set"){let K=h(I.options.default)??h(I.options.level)??z;if(K!=="medium"&&K!=="high")throw Error("Usage: seal-use preference thinking-depth set --default <medium|high>");await k0("seal_preference_thinking_depth_set",Q,J,{defaultLevel:K,dryRun:Z0(I.options.dryRun)??Z0(I.options["dry-run"])},C0(I.options));return}if(Y==="policies"){if(U==="list"||!U){await k0("seal_preference_thinking_depth_policies_list",Q,J,{},C0(I.options));return}if(U==="upsert"){let K=h(I.options.input),G=K?JSON.parse(dS0(K,"utf8")):y8(I.json);if(!G||!G.id||!G.name)throw Error(`Usage:seal-usepreferencethinking-depthpoliciesupsert--json'{"id":"...","name":"...","level":"high"}'`);await k0("seal_preference_thinking_depth_policies_upsert",Q,J,{...G,dryRun:Z0(I.options.dryRun)??Z0(I.options["dry-run"])},C0(I.options));return}if(U==="remove"||U==="delete"){let K=z??h(I.options.id)??h(I.options.policyId);if(!K)throw Error("Usage: seal-use preference thinking-depth policies remove <policyId>");await k0("seal_preference_thinking_depth_policies_remove",Q,J,{policyId:K,dryRun:Z0(I.options.dryRun)??Z0(I.options["dry-run"])},C0(I.options));return}}}throw Error(`Unknownpreferenceaction:${$??""}.Available:get,decisionupdate,thinking-depthset,thinking-depthpolicieslist/upsert/remove.`)}var lS0=m(()=>{f4();D4();J4()});async function oS0($={}){let Y=s8(),U=_4(),z=u2(Y,{stateful:U.stateful,defaultCorpId:U.defaultCorpId,corpId:$.corpId},S3());console.log(`[probe]corp=${z.id}source=${z.source.type}`);let Q=await xK(z);console.log("[probe] seal enterprise"),console.log(JSON.stringify(Q,null,2));let J=await B1(z),I=await OM(J,{documentLimit:20,stylePreferencesEndpoint:z.seal.endpoints.approvalStylePreferences});console.log("[probe] approval context summary"),console.log(JSON.stringify({rules:I.rules.rules.length,hasPendingRuleDeletes:I.rules.hasPendingDeletes,documents:I.documents.articles.length,documentsTotal:I.documents.total,stylePreferences:I.stylePreferences.ok?"ok":`error:${I.stylePreferences.error}`},null,2))}var rS0=m(()=>{y3();i8();CT();X6()});async function sS0($,Y,U){let z=Y??h(U.options.corp)??($&&$!=="--corp"?$:void 0);await oS0({corpId:z})}var aS0=m(()=>{rS0();D4()});async function qo($,Y,U,z,Q){if($==="count"){await k0("seal_approval_rules_list",U,z,{countOnly:!0},C0(Q.options));return}if($==="list"){if(Z0(Q.options.count)){await k0("seal_approval_rules_list",U,z,{countOnly:!0},C0(Q.options));return}let J=s0(Q.options.limit),I=s0(Q.options.offset);if(Z0(Q.options.summary)){await k0("seal_approval_rules_list",U,z,{fields:V_0,limit:J,offset:I},C0(Q.options));return}let K=await T5("seal_approval_rules_list",U,z,{limit:J,offset:I});L_0(K,Z0(Q.options.full)===!0),f0(K);return}if($==="clear"){let J=Z0(Q.options.yes)===!0,I=Z0(Q.options.dryRun)??Z0(Q.options["dry-run"])??!J;if(!J&&!I)throw A9("Refusing to clear rules without --yes. Use --dry-run to preview.",`seal-userulesclear--corp${z.id}--dry-run`);let K=await T5("seal_approval_rules_clear",U,z,{dryRun:I,recode:Z0(Q.options.recode)});if(!J&&I&&K&&typeof K==="object"){f0({...K,
Line truncated
`).filter(Boolean),J=Q.slice(-Y);return{logFile:U,lines:J,totalLines:Q.length}}async function Uy1($){let Y=iT($),U=Fo($),z=hq($);Ug0($.stateDir);let Q=$.port??(process.env.PORT?Number.parseInt(process.env.PORT,10):yT),J=$.host??(process.env.HOST?process.env.HOST:kT);uT(Y,`${process.pid}
`,{mode:384}),uT(U,JSON.stringify({pid:process.pid,port:Q,host:J,version:$.version,startedAt:new Date().toISOString()},null,2),{mode:384}),uK(z,`servicestartingonhttp://${J}:${Q} pid=${process.pid}`);let I=null;try{I=await xT({port:Q,host:J,silent:!0}),uK(z,`service listening pid=${process.pid}`)}catch(G){if(uK(z,`service failed to bind port ${Q}: ${G instanceof Error?G.message:String(G)}`),bT(Y)===process.pid)h9(Y,{force:!0}),h9(U,{force:!0});throw G}let K=()=>{if(I)I.close(),I=null;if(bT(Y)===process.pid)h9(Y,{force:!0}),h9(U,{force:!0});uK(z,`stopped pid=${process.pid}`)};await new Promise((G)=>{let H=!1,W=()=>{if(H)return;H=!0,K(),process.off("SIGTERM",W),process.off("SIGINT",W),G()};process.once("SIGTERM",W),process.once("SIGINT",W)})}function eS0($){Ug0($.stateDir);let Y=bK($);if(Y.running)return Y;let U=$.launcher??{command:process.execPath,args:[$.entryFile]},z=[...U.args??[],"service","run"];if($.port)z.push("--port",String($.port));if($.host)z.push("--host",String($.host));let Q=tg1(U.command,z,{cwd:$.appRoot,detached:!0,stdio:["ignore","ignore","ignore"],env:process.env});Q.unref();let J=iT($);return uT(J,`${Q.pid}
`,{flag:"a",mode:384})}var wo=m(()=>{Xo()});import{homedir as Qy1}from"node:os";import{join as Jy1}from"node:path";async function Oo($,Y,U){let z=U?s0(U.options.port)??s0(U.options.p):void 0,Q=U?h(U.options.host)??h(U.options.h):void 0,J=U?s0(U.options.lines)??s0(U.options.n):void 0,I=await kz($,{appRoot:Y.appRoot,entryFile:Y.entryFile,stateDir:Mo,version:P1,launcher:Y.launcher,port:z,host:Q},{maxLines:J});if(I!==void 0)f0(I)}var Mo;var No=m(()=>{e9();wo();J4();D4();Mo=Jy1(Qy1(),".config","seal-use")});import{existsSync as Iy1,readFileSync as zg0}from"node:fs";async function Qg0($,Y,U,z,Q){if($==="batch-records"||$==="records"){let J=Y??h(Q.options.batchId)??h(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation batch-records <batchId>");await k0("seal_simulation_batch_records_get",U,z,{batchId:J,query:h(Q.options.query)},C0(Q.options));return}if($==="create"||$==="run"){let J=h(Q.options.mode)??h(Q.options.sourceSystem)??h(Q.options["source-system"])??"hosecloud",I=J==="material-pack"?"material_pack":J,K=h(Q.options.schemaConfig)??h(Q.options["schema-config"]),G=K?JSON.parse(zg0(K,"utf8")):void 0,H=h(Q.options.input),W=H?JSON.parse(zg0(H,"utf8")):y8(Q.json),X=h(Q.options.packageId)??h(Q.options["package-id"]),Z=u6(Q.options.packageIds)??u6(Q.options["package-ids"])??(X?[X]:void 0),q=u6(Q.options.flowIds)??u6(Q.options["flow-ids"])??u6(Q.options.documentSn)??u6(Q.options["document-sn"]),V=h(Q.options.signKey)??h(Q.options["sign-key"])??h(Q.options.integration),F=Z0(Q.options.noWait)??Z0(Q.options["no-wait"]);await k0("seal_simulation_batch_create",U,z,{mode:I,sourceSystem:I,flowIds:q,documentSn:q,rejectNodeName:h(Q.options.rejectNode)??h(Q.options["reject-node"])??null,thinkingDepthOverride:h(Q.options.thinkingDepth)??h(Q.options["thinking-depth"]),skipInvoiceGeneration:Z0(Q.options.skipInvoiceGeneration)??Z0(Q.options["skip-invoice-generation"]),skipExpenseExtraction:Z0(Q.options.skipExpenseExtraction)??Z0(Q.options["skip-expense-extraction"]),disableAttachmentCache:Z0(Q.options.disableAttachmentCache)??Z0(Q.options["disable-attachment-cache"]),signKey:V,packageIds:Z,packageId:X,templateId:h(Q.options.templateId)??h(Q.options["template-id"]),schemaConfig:G,requestIds:u6(Q.options.requestIds)??u6(Q.options["request-ids"]),workflowTypeId:h(Q.options.workflowTypeId)??h(Q.options["workflow-type-id"]),flowStatusList:u6(Q.options.flowStatusList)?.map(Number)??u6(Q.options["flow-status-list"])?.map(Number),businessCodes:u6(Q.options.businessCodes)??u6(Q.options["business-codes"]),documentType:h(Q.options.documentType)??h(Q.options["document-type"]),startTime:s0(Q.options.startTime)??s0(Q.options["start-time"]),endTime:s0(Q.options.endTime)??s0(Q.options["end-time"]),status:u6(Q.options.status),limit:s0(Q.options.limit),noWait:F,rawParams:W},C0(Q.options));return}if($==="wait"){let J=Y??h(Q.options.batchId)??h(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s]");await k0("seal_simulation_batch_wait",U,z,{batchId:J,timeout:h(Q.options.timeout),pollInterval:h(Q.options.pollInterval)??h(Q.options["poll-interval"])},C0(Q.options));return}if($==="status"){let J=Y??h(Q.options.batchId)??h(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation status <batchId>");await k0("seal_simulation_batch_status",U,z,{batchId:J},C0(Q.options));return}if($==="clean"||$==="delete"){let J=Y??h(Q.options.batchId)??h(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation clean <batchId>");await k0("seal_simulation_batch_clean",U,z,{batchId:J},C0(Q.options));return}if($==="specifications"){let J=Y??h(Q.options.integration)??h(Q.options.signKey)??h(Q.options["sign-key"]);await k0("seal_simulation_specifications_list",U,z,{signKey:J},C0(Q.options));return}if($==="approval-definitions"||$==="definitions"){await k0("seal_simulation_feishu_approval_definitions_list",U,z,{},C0(Q.options));return}if($==="list"){await k0("seal_simulation_batches_list",U,z,{limit:s0(Q.options.limit)},C0(Q.options));return}if($==="get"){let J=Y??h(Q.options.batchId)??h(Q.options["batch-id"]);if(!J)throw Error("Usage: seal-use simulation get <batchId>");await k0("seal_simulation_batch_get",U,z,{batchId:J},C0(Q.options));return}if($==="templates"){await k0("seal_simulation_templates_get",U,z,{},C0(Q.options));return}if($==="integrations"){await k0("seal_simulation_integrations_get",U,z,{},C0(Q.options));return}if($==="package-upload"){let J=Y??h(Q.options.file);if(!J)throw Error("Usage: seal-use simulation package-upload <材料包.zip>");if(!Iy1(J))throw Error(`Filenotfound:${J}`);await k0("seal_simulation_material_package_upload",U,z,{filePath:J},C0(Q.options));return}throw Error(`Unknownsimulationcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}var Jg0=m(()=>{f4();D4();J4()});import{existsSync as Ig0}from"node:fs";import{join as cT}from"node:path";function Kg0($,Y,U){if($==="dump"||$==="cat"||$==="show"){process.stdout.write(`${zoLine truncated
`);return}if($==="install"||$==="init"||$==="sync"){let z=Z0(U.options.local)||Z0(U.options.workspace),Q=h(U.options.dir)??h(U.options.target)??Y,J=Q?Q:z?cT(process.cwd(),".agents","skills","seal-use"):yz(),I=LS0(J),K=!z&&!Q,G=K?rl():void 0,H=K?tl():void 0;f0({installed:!0,targetDir:I.targetDir,fileCount:I.files.length,files:I.files,...G?{antigravity:G}:{},...H?{hosts:H}:{}});return}if($==="status"||$==="get"||!$){let z=yz(),Q=cT(process.cwd(),".agents","skills","seal-use"),J=sl(),I=el();f0({global:{dir:z,installed:Ig0(cT(z,"SKILL.md"))},local:{dir:Q,installed:Ig0(cT(Q,"SKILL.md"))},antigravity:J,hosts:I});return}throw Error(`Unknownskillcommand:${$}.Run'seal-use help'foravailablecommands.`)}var Gg0=m(()=>{Yo();Rq();D4();J4()});async function Hg0($,Y){if($==="config"){f0(await xK(Y));return}throw Error(`Unknownsourcecommand:${$??""}.Run'seal-use help'foravailablecommands.`)}var Wg0=m(()=>{CT();J4()});function Do($){if(typeof $!=="string"||!$.trim())return"UNKNOWN";let Y=$.toUpperCase().trim();if(Y==="APPROVE"||Y==="PASS")return"APPROVE";if(Y==="REJECT"||Y==="DENIED")return"REJECT";if(Y==="MANUAL"||Y==="ASSISTED")return"MANUAL";if(Y==="ERROR"||Y==="FAILED")return"ERROR";return Y}async function Xg0($){let{sourceCorp:Y,targetCorp:U,sourceClient:z,targetClient:Q,samples:J=10,dryRun:I=!1,pollIntervalMs:K=2000,timeoutMs:G=45000,snPrefix:H="REG_",fetchFn:W=fetch}=$;if(U.environment!=="test")throw new w4(`重放目标企业「${U.name}」(${U.id})的环境为「${U.environment}」,非测试环境!
`+"硬性安全规定:自动化回归测试矩阵严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-usecorpsbind-test${Y.id}<testCorpId>`);let X=await nY(Q),q=(Array.isArray(X.features)?X.features:[]).find((d)=>d?.code==="ai-approval"),V=typeof q?.balance==="number"?q.balance:0,F=typeof q?.deductionAmount==="number"&&q.deductionAmount>0?q.deductionAmount:120,M=J*F;if(V<M)throw new w4(`测试企业「${U.name}」AI审批额度不足:当前剩余${V}点,本次回归抽样${J}笔需要约${M}点。
`+"为防止测试环境额度耗尽中断业务,已硬性拦截并拒绝发起测试单据注入。",2,`请为测试企业「${U.id}」充值AI审批额度,或降低抽样笔数(--samples${Math.max(1,Math.floor(V/F))})`);let w=await i4(z,{limit:J,status:"completed"}),N=Array.isArray(w.records)?w.records:[];if(N.length===0){let d=await i4(z,{limit:J});N=Array.isArray(d.records)?d.records:[]}if(N.length===0)throw new w4(`在母企业「${Y.name}」(${Y.id})中未检索到任何历史审批单据,无法抽取回归样本。`,2);if(N=N.slice(0,J),I){let d=N.map((t)=>{let $0=t.sourceDocumentSN??t.id,g=t?.result?.decision??t.aiDecision??t?.decision,p=Do(g),e=t?.result?.summary??t.aiSummary;return{sn:$0,sourceRecordId:t.id,prodDecision:p,prodSummary:e,status:"DRY_RUN"}});return{ok:!0,verdict:"DRY_RUN",safeToPublish:!0,timestamp:new Date().toISOString(),sourceCorp:{id:Y.id,name:Y.name,environment:Y.environment??"production"},targetCorp:{id:U.id,name:U.name,environment:U.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:V,deductionAmount:F,estimatedRequired:M},metrics:{sampleCount:d.length,successCount:d.length,failureCount:0,matchCount:d.length,flipCount:0,concordanceRate:1},flips:[],records:d}}let O=await Gp(Q,U,$.webhookSelector),D=[];for(let d of N){let t=Date.now(),$0=d.sourceDocumentSN??d.id,g=Do(d?.result?.decision??d.aiDecision??d?.decision),p=d?.result?.summary??d.aiSummary;try{let e=await H4(z,d.id),y=`${H}${$0}`,s=Ip(e,{snPrefix:H,docIdPrefix:H});await Kp(O.incomingDocumentWebhook.url,O.secret,s,W,A6(U.seal));let Y0=null,N0=Date.now();while(Date.now()-N0<G){await new Promise((W0)=>setTimeout(W0,K));let a=await i4(Q,{sourceDocumentSN:y,limit:1});if(a.records&&a.records.length>0){let W0=a.records[0];if(W0.status==="completed"||W0.status==="failed"){Y0=W0;break}}}if(!Y0){D.push({sn:$0,sourceRecordId:d.id,prodDecision:g,prodSummary:p,status:"FAILED",error:`测试租户单据审核超时(${Math.round(G/1000)}s未完成)`,durationMs:Date.now()-t});continue}let E0=Do(Y0?.result?.decision??Y0.aiDecision??Y0?.decision??(Y0.status==="completed"?"APPROVE":"ERROR")),G0=Y0?.result?.summary??Y0.aiSummary,T0=g===E0,i0=T0?"MATCHED":"FLIPPED",Y1={sn:$0,sourceRecordId:d.id,prodDecision:g,prodSummary:p,testRecordId:Y0.id,testDecision:E0,testSummary:G0,status:i0,durationMs:Date.now()-t};if(!T0)Y1.diff={from:g,to:E0,reasonDiff:G0&&p&&G0!==p?`生产:${p.slice(0,60)}...->测试:${G0.slice(0,60)}...`:void 0};D.push(Y1)}catch(e){D.push({sn:$0,sourceRecordId:d.id,prodDecision:g,prodSummary:p,status:"FAILED",error:e instanceof Error?e.message:String(e),durationMs:Date.now()-t})}}let P=D.filter((d)=>d.status==="MATCHED"||d.status==="FLIPPED"),T=D.filter((d)=>d.status==="MATCHED"),A=D.filter((d)=>d.status==="FLIPPED"),j=D.filter((d)=>d.status==="FAILED").length,C=T.length,b=A.length,x=C+b,S=x>0?C/x:0,i=b>0,c=i?"REGRESSIONS_DETECTED":"CLEAN",z0=!i&&j===0,k;try{let d=await nY(Q),$0=(Array.isArray(d.features)?d.features:[]).find((g)=>g?.code==="ai-approval");if(typeof $0?.balance==="number")k=$0.balance}catch{}return{ok:!i&&j===0,verdict:c,safeToPublish:z0,timestamp:new Date().toISOString(),sourceCorp:{id:Y.id,name:Y.name,environment:Y.environment??"production"},targetCorp:{id:U.id,name:U.name,environment:U.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:V,deductionAmount:F,estimatedRequired:M,balanceAfter:k},metrics:{sampleCount:D.length,successCount:P.length,failureCount:j,matchCount:C,flipCount:b,concordanceRate:Number(S.toFixed(4))},flips:A,records:D}}function Zg0($){let{sourceCorp:Y,targetCorp:U,verdict:z,safeToPublish:Q,metrics:J,quota:I,flips:K,records:G}=$,H=z==="CLEAN"?"\uD83D\uDFE2 决策完全一致 (CLEAN - 无回归)":z==="DRY_RUN"?"⚪ 预演模式 (DRY-RUN)":"\uD83D\uDD34 发现决策翻转 (REGRESSIONS_DETECTED)",W=["",`\uD83E\uDDEA[SealUseTest]规则回归测试矩阵:生产「${Y.name}」->测试靶场「${U.name}」`,`判定:${H}·准许发布:${Q?"YES (可安全上线)":"NO (存在行为偏离/待复核)"}`," "+"─".repeat(65),`样本总数:${J.sampleCount}|一致通过:${J.matchCount}|决策翻转:${J.flipCount}|异常失败:${J.failureCount}`,`一致率:${(J.concordanceRate*100).toFixed(1)}%|消耗预估:${I.estimatedRequired}点(余量:${I.balanceBefore}${I.balanceAfter!==void0?` -> ${I.balanceAfter}`:""})`," "+"─".repeat(65)];if(K.length>0){W.push(`⚠️决策翻转清单(${K.length}笔单据在新规则下结果改变):`);for(let X of K)if(W.push(`•单据[${X.sn}]:原生产判定「${X.prodDecision}」➔测试新判定「${X.testDecision}」`),X.diff?.reasonDiff)W.push(`理由差异:${X.diff.reasonDiff}`);W.push(" "+"─".repeat(65)),W.push(" \uD83D\uDC49 建议: 请检查上述翻转单据是否符合预期修正。若为意外误杀,请调整测试环境规则后再次回归。")}else if(z==="CLEAN")W.push(" ✓ 全部样本在新规则下的审核决策与生产历史 100
Line truncated
`)}var qg0=m(()=>{L$();X6();SZ()});async function Ao($,Y,U){let z=($??Y??"regression").toLowerCase();if(z==="regression"||z==="regress"||z==="matrix"){let Q=h(U.options.corp)??(Y&&Y!==z?Y:void 0),J=j1(Q),I=J,K=J;if(J.environment==="test"){K=J;let O=h(U.options["prod-corp"])??h(U.options.prod)??J.prodCorpId;if(!O)throw new w4(`测试企业「${J.name}」(${J.id})未绑定生产母企业,无法拉取历史样本。
`+"请建立绑定或通过 --prod-corp 参数指定生产企业来源。",2,`seal-usecorpsbind-test<prodCorpId>${J.id}`);I=j1(O)}else{I=J;let O=h(U.options["test-corp"])??h(U.options.test)??J.testCorpId;if(!O)throw new w4(`生产企业「${J.name}」(${J.id})未绑定测试靶场企业。
`+"硬性规定:回归测试严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-usecorpsbind-test${J.id}<testCorpId>`);K=j1(O)}let G=await B1(I),H=await B1(K),W=s0(U.options.samples)??s0(U.options.limit)??s0(U.options.n)??10,X=Z0(U.options["dry-run"]),Z=Z0(U.options["fail-on-flips"]),q=s0(U.options["poll-interval"])??2000,V=s0(U.options.timeout)??45000,F=h(U.options["sn-prefix"])??"REG_",M=h(U.options.webhook)??h(U.options.selector),w=await Xg0({sourceCorp:I,targetCorp:K,sourceClient:G,targetClient:H,samples:W,dryRun:X,pollIntervalMs:q,timeoutMs:V,snPrefix:F,failOnFlips:Z,webhookSelector:M});if(!(Z0(U.options.quiet)||Z0(U.options.silent)))console.error(Zg0(w));if(f0(w),Z&&!w.ok)throw new w4(`回归测试发现${w.metrics.flipCount}笔单据决策翻转,已按--fail-on-flips策略非零终止。`,1);return}throw new w4(`未知的test子命令:"${z}"。
可用子命令:seal-usetestregression[--corp<id>][--samples<N>][--dry-run]`,2,"seal-use test regression --help")}var Vg0=m(()=>{L$();f4();D4();J4();i8();qg0()});async function Lg0($,Y,U,z){if(!$)throw Error("Usage: seal-use tool <toolName> [--json '{...}']");await k0($,Y,U,y8(z.json),C0(z.options))}var Fg0=m(()=>{f4();D4();J4()});function wg0(){f0(Lq.map(($)=>({name:$.name,description:$.description})))}var Mg0=m(()=>{wq();J4()});function nT($=process.execPath,Y=import.meta.url){if(Y.includes("/$bunfs/")||Y.includes("\\$bunfs\\"))return!0;let U=$.toLowerCase().replace(/\\/g,"/");return!U.endsWith("/bun")&&!U.endsWith("/bun.exe")&&!U.endsWith("/node")&&!U.endsWith("/node.exe")}var Og0=m(()=>{Rq()});import{existsSync as Ky1,mkdirSync as Gy1,readFileSync as Hy1,renameSync as Wy1,writeFileSync as Xy1}from"node:fs";import{homedir as Zy1}from"node:os";import{dirname as qy1,join as Vy1}from"node:path";import{spawn as Ly1}from"node:child_process";function Ng0(){let $=process.env[Fy1]?.trim();if($)return $;return My1}function Dg0($=Ng0()){if(!Ky1($))return null;try{let Y=Hy1($,"utf-8"),U=JSON.parse(Y);if(U&&typeof U==="object"&&typeof U.latestVersion==="string"&&typeof U.checkedAt==="string")return U;return null}catch{return null}}function pT($,Y=Ng0()){try{let U=qy1(Y);Gy1(U,{recursive:!0,mode:448});let z={checkedAt:$.checkedAt??new Date().toISOString(),latestVersion:$.latestVersion,publishedAt:$.publishedAt,releaseUrl:$.releaseUrl},Q=`${Y}.tmp.${Date.now()}.${Math.random().toString(36).slice(2,8)}`;Xy1(Q,JSON.stringify(z,null,2),{mode:384}),Wy1(Q,Y)}catch{}}function Ag0($,Y=wy1){if(!$||!$.checkedAt)return!0;let U=new Date($.checkedAt).getTime();if(Number.isNaN(U))return!0;return Date.now()-U>Y}function Bg0($){if(process.env.SEAL_DISABLE_BG_UPDATE==="1"||!1||process.env.CI)return!1;if(!$||!$.command)return!1;try{let Y=$.command,U=[...$.args??[],"update","check","--bg-save"];return Ly1(Y,U,{detached:!0,stdio:"ignore",env:{...process.env,SEAL_DISABLE_BG_UPDATE:"1"}}).unref(),!0}catch{return!1}}var Fy1="SEAL_USE_UPDATE_CACHE_FILE",wy1=86400000,My1;var Bo=m(()=>{My1=Vy1(Zy1(),".config","seal-use","update-cache.json")});import{chmodSync as Oy1,mkdirSync as Ny1,readdirSync as Dy1,renameSync as Po,rmSync as Ay1,unlinkSync as Eg0,writeFileSync as Pg0}from"node:fs";import{basename as By1,dirname as Py1,join as mT}from"node:path";import{spawnSync as iK}from"node:child_process";async function Rg0($,Y={}){let U={appRoot:$.appRoot,entryFile:$.entryFile,stateDir:Mo,version:P1,launcher:$.launcher},z=Y.repo||process.env[Ty1]?.trim()||process.env[jy1]?.trim()||Cg0,Q=Y.targetVersion?.trim(),J=Q&&Q.toLowerCase()!=="latest"?Q:void 0;if(J){let D=J.replace(/^v/,""),P=Sg0(D,P1);if(P<0)if(!uS&&Y.force);else{f0({updated:!1,currentVersion:P1,targetVersion:D,mode:nT()?"binary":"source",message:!uS?`Cannotdowngradeseal-usefromdevbuildv${P1}toreleasev${D}.Use--forcetooverwrite.`:`Cannotdowngradeseal-usefromv${P1}toolderversionv${D}.Updatesmustbeforward-only.`});return}if(P===0&&!Y.force){f0({updated:!1,currentVersion:P1,targetVersion:D,mode:nT()?"binary":"source",message:`seal-useisalreadyatversionv${P1}.Use--forcetoreinstall.`});return}}if(Y.changelogOnly){let D=await To(z,Y.limit??10);f0({currentVersion:P1,totalQueried:D.length,releases:D.map((P)=>({version:P.version,tagName:P.tagName,publishedAt:P.publishedAt,author:P.author,releaseNotes:P.notes,releaseUrl:P.htmlUrl,isCurrent:P.version===P1,isNewer:xz(P.version,P1)}))});return}if(!nT()){if(Y.checkOnly){let P=await To(z,30),T=P[0],A=T?.version??P1,j=P.find((x)=>x.version===P1),C=xz(A,P1),b=P.filter((x)=>xz(x.version,P1));if(T?.version)pT({latestVersion:T.version,publishedAt:T.publishedAt,releaseUrl:T.htmlUrl});if(Y.bgSave)return;f0({updated:!1,updateAvailable:C,currentVersion:P1,currentVersionPublishedAt:j?.publishedAt,latestVersion:A,latestVersionPublishedAt:T?.publishedAt,behindCount:b.length,pendingReleases:b.map((x)=>({version:x.version,tagName:x.tagName,publishedAt:x.publishedAt,author:x.author,releaseNotes:x.notes,releaseUrl:x.htmlUrl})),releaseNotes:T?.notes??"",releaseUrl:T?.htmlUrl??"",mode:"source",message:"Running in source development mode. Run 'seal-use update' to git pull & bun install."});return}let D=bK(U).running;if(D)await kz("stop",U);try{jg0("git",["-C",$.appRoot,"pull","--ff-only"])}catch(P){console.error(`gitpullskipped:${PinstanceofError?P.message:String(P)}`)}if(jg0("bun",["install"],{cwd:$.appRoot}),D)await kz("start",U);f0({updated:!0,serviceRestarted:D,version:P1,mode:"source"});return}let I=Cy1(),K=Ry1(),G=await To(z,30),H=J?G.find((D)=>D.version===J||D.tagName===J||D.tagName===`v${J}`)??await Tg0(z,J):G[0]??await Tg0(z);if(!H){f0({updated:!1,currentVersion:P1,mode:"binary",message:`Failedtoqueryreleasesfromrepository'${z}'`});return}let W=H.version,X=G.find((D)=>D.version===P1),Z=xz(W,P1),q=Z||Boolean(Y.force),V=G.filter((D)=>xz(D.version,P1));if(H?.version)pT({latestVersion:H.version,publishedAt:H.publishedAt
Line truncated
`)}catch{}}async function hy1($,Y,U,z){let Q=jo(),J=[],I=U?U.startsWith("v")?U:`v${U}`:void 0,K=z||$.split("/").pop()||"";if(Q!=="github"){if(I&&K)J.push(`https://git.ying-qing.cn/gitea/seal-use/releases/download/${I}/${K}`,`https://git.ying-qing.cn/gitea/seal-home/releases/download/${I}/${K}`);if($.startsWith("https://git.ying-qing.cn"))J.push($)}if(Q!=="gitea")if(I&&K){let F=`https://github.com/${Cg0}/releases/download/${I}/${K}`;if(!process.env.CI)J.push(`https://ghfast.top/${F}`,`https://gh.ddlc.top/${F}`);J.push(F)}else if($.includes("github.com")){if(!process.env.CI)J.push(`https://ghfast.top/${$}`,`https://gh.ddlc.top/${$}`);J.push($)}else J.push($);let G=Array.from(new Set(J)),H,W=6000,X=6000,Z=307200,q=1e4,V=180000;for(let F=0;F<G.length;F++){let M=G[F],w=new AbortController,N="",O=(A)=>{N=A;try{w.abort()}catch{}},D=setTimeout(()=>{O("Connection timed out (no response headers within 6s)")},W),P,T;try{dT(`==> [${F+1}/${G.length}] Downloading via: ${M}`);let A=await fetch(M,{signal:w.signal});if(D)clearTimeout(D),D=void 0;if(!A.ok)throw Error(`HTTP ${A.status} ${A.statusText}`);P=setTimeout(()=>{O("Overall download time exceeded 3 minutes")},V);let j=Number(A.headers.get("content-length"))||0,C=A.body?.getReader();if(!C){let c=Buffer.from(await A.arrayBuffer());if(c.length<1000)throw Error(`Downloaded content is suspiciously small (${c.length} bytes)`);Pg0(Y,c),dT(`✓ Download succeeded (${(c.length/1024/1024).toFixed(1)} MB)`);return}let b=[],x=0,S=0;T=setTimeout(()=>{if(x<Z){let c=(x/1024).toFixed(1);O(`Initial transfer too slow (${c} KB < 300 KB in 6s), switching mirror...`)}},X);while(!0){let c=C.read(),z0,k=new Promise((g,p)=>{z0=setTimeout(()=>{p(Error("Data transfer stalled (no chunk received for 10s)"))},q)}),d;try{d=await Promise.race([c,k])}finally{if(z0)clearTimeout(z0)}let{done:t,value:$0}=d;if(t)break;if($0){if(b.push($0),x+=$0.length,T&&x>=Z)clearTimeout(T),T=void 0;let g=Date.now();if(g-S>200){S=g;let p=j?Math.round(x/j*100):0,e=(x/1048576).toFixed(1),y=j?(j/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${p}% (${e} / ${y} MB)...`)}catch{}}}}try{process.stderr.write(`
"description":"HTTP contract for the seal-use wrapped backend API, served by the local HTTP adapter\n(`seal-use http`, or the `seal-use service start` daemon; default http://127.0.0.1:8787).\n\nThese endpoints describe the stable wrapped API for frontend developers and agents. They are\nnot the raw downstream Seal endpoints: seal-use is responsible for enterprise selection,\nsource authentication, response compaction, and diagnostics-friendly fields.\n\nEvery operation declares `x-implementation-status`, so a caller can tell what the running\nadapter actually serves:\n\n- `implemented` — routed by `src/http/routes.ts` today. `src/http/openapi-implementation.test.ts`\n fails when an `implemented` operation has no matching route.\n- `planned` — contract-only, designed but not routed yet. Calling it returns 404.\n\nThe same capabilities are reachable through the CLI, and through the optional MCP server when\nit is enabled.\n"
},
"servers":[
@@ -2206,7 +2206,7 @@
],
"operationId":"getApprovalRunUrl",
"x-implementation-status":"implemented",
"summary":"Get enterprise assist URL and optional source document URL",
"summary":"Get Seal AI result URL and optional source document URL",
"parameters":[
{
"name":"corpId",
@@ -2240,22 +2240,28 @@
],
"responses":{
"200":{
"description":"Enterprise and document URLs.",
"description":"Seal AI result URL and source document URL.",
description:"v0.10.31: 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.33: 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.31
short-description:Seal tenant and Hose approval automation (v0.10.31)
version:0.10.33
short-description:Seal tenant and Hose approval automation (v0.10.33)
thrownewError("recordId or sourceDocumentSN is required to generate an SSO approvalresult URL");
if(useAutoLogin){
if(isHoseDoc){
thrownewError("Auto-login (--auto-login) is only supported for Seal AI audit link (type: seal-result)");
}
if(source.type!=="hose"){
thrownewError(
`SSO direct links currently support Hose-integrated enterprises (corp '${context.corp.id}' uses '${source.type}'). For Seal-native enterprises, use 'seal-use delegation create' for authorized access.`
`Auto-login direct links currently support Hose-integrated enterprises (corp '${context.corp.id}' uses '${source.type}'). For Seal-native enterprises, use 'seal-use auth link' for authorized access.`
);
}
@@ -1810,7 +1824,7 @@ export const sealTools = [
warning=`⚠️ 安全警示:该链接使用 [${userName}${roleLabel}] 身份签发,在 Seal AI 拥有全站操作权限。链接具备 ${Math.round(expiresIn/3600*10)/10} 小时时效,仅供受信任人员排查使用,请勿在外部公开分享。`;
console.error(
`⚠️ 安全警示 (SSO 强化免密链接):\n`+
`⚠️ 安全警示 (免密直达链接):\n`+
`• 身份主体:${userName}${roleLabel}\n`+
`• 权限范围:持有该链接者在 Seal AI 中拥有该用户的完整操作权限(含系统设置与规则编辑)\n`+
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.