Release v0.10.1: standardize main branch, rename repo to seal-use, and optimize release pipeline

This commit is contained in:
gitea committed 2026-09-02 16:18:54 +08:00
1 parent 756202bf20
commit 8e9141953d
14 files changed
+54 -40

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
blank_issues_enabled: false blank_issues_enabled: false
contact_links: contact_links:
- name: 📖 Documentation & Skill Guide - name: 📖 Documentation & Skill Guide
url: https://github.com/yunyingk/seal-use/blob/master/skills/seal-use/SKILL.md url: https://github.com/yunyingk/seal-use/blob/main/skills/seal-use/SKILL.md
about: Read the official documentation and agent skill manual for seal-use. about: Read the official documentation and agent skill manual for seal-use.
+2
View File
@@ -3,9 +3,11 @@ name: 🧪 CI
on: on:
push: push:
branches: branches:
- main
- master - master
pull_request: pull_request:
branches: branches:
- main
- master - master
workflow_dispatch: workflow_dispatch:
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "seal-use", "name": "seal-use",
"version": "0.10.0", "version": "0.10.1",
"description": "Seal Use tenant operations: approval-run diagnosis, minimal rule remediation, delegation links, Hose/合思 authorization, users, rules, billing, and search.", "description": "Seal Use tenant operations: approval-run diagnosis, minimal rule remediation, delegation links, Hose/合思 authorization, users, rules, billing, and search.",
"author": { "author": {
"name": "yingqing" "name": "yingqing"
+7 -7
View File
@@ -43,21 +43,21 @@ Recent commits use concise imperative subjects, often `Add ...` or `Refine ...`,
- Update `CHANGELOG.md` with new features and fixes. - Update `CHANGELOG.md` with new features and fixes.
- Run `bun test && bun run check`. - Run `bun test && bun run check`.
2. **Protected-Branch Release**: 2. **Protected-Branch Release**:
- Do not tag or push `master` directly. Create a release branch, commit the version bump, push it, open a PR to `master`, wait for the required CI check, and merge the PR first. - Do not tag or push `main` directly. Create a release branch, commit the version bump, push it, open a PR to `main`, wait for the required CI check, and merge the PR first.
- After the PR is merged, fast-forward the local `master`, then synchronize `home/master` before creating the tag: - After the PR is merged, fast-forward the local `main`, then synchronize `home/main` before creating the tag:
```bash ```bash
git switch -c codex/release-vX.Y.Z git switch -c codex/release-vX.Y.Z
git add <release-files> git add <release-files>
git commit -m "Release vX.Y.Z: ..." git commit -m "Release vX.Y.Z: ..."
git push origin HEAD:refs/heads/codex/release-vX.Y.Z git push origin HEAD:refs/heads/codex/release-vX.Y.Z
gh pr create --base master --head codex/release-vX.Y.Z --title "Release vX.Y.Z: ..." --body "..." gh pr create --base main --head codex/release-vX.Y.Z --title "Release vX.Y.Z: ..." --body "..."
gh pr checks <pr-number> --watch gh pr checks <pr-number> --watch
gh pr merge <pr-number> --merge gh pr merge <pr-number> --merge
git switch master git switch main
git pull --ff-only origin master git pull --ff-only origin main
git push home master git push home main
``` ```
- Only after both `origin/master` and `home/master` contain the merged release should you create the annotated tag. Push the tag to `home` first, then to `origin`; pushing the GitHub tag last triggers the Release workflow after the Gitea tag and branch are ready: - Only after both `origin/main` and `home/main` contain the merged release should you create the annotated tag. Push the tag to `home` first, then to `origin`; pushing the GitHub tag last triggers the Release workflow after the Gitea tag and branch are ready:
```bash ```bash
git tag -a vX.Y.Z -m "🚀 Release summary text describing key changes" git tag -a vX.Y.Z -m "🚀 Release summary text describing key changes"
git push home refs/tags/vX.Y.Z git push home refs/tags/vX.Y.Z
+8
View File
@@ -5,6 +5,14 @@ All notable changes to `seal-use` will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.10.1] - 2026-09-02
### Changed & Infrastructure
- **Default Branch Modernization (`master` $\rightarrow$ `main`)**: Standardized default branch to `main` across GitHub and Gitea with dual-branch transition compatibility for legacy script URLs.
- **Repository Rename (`seal-home` $\rightarrow$ `seal-use`)**: Updated primary repository references to `yunyingk/seal-use` and `gitea/seal-use` with multi-source fallback and GitHub 301/302 redirect support.
- **Two-Job Decoupled Release Architecture**: Split CI/CD release workflow into independent GitHub Release job (~40s fast path) and asynchronous Gitea mirror sync job.
- **Tiered Gitea Sync with Supreme Priority**: Prioritized `seal-use-darwin-arm64.tar.gz` and `checksums.txt` (Tier 1, ~26MB) for 10-second sync completion on macOS Apple Silicon.
## [0.10.0] - 2026-09-02 ## [0.10.0] - 2026-09-02
### Added & Changed ### Added & Changed
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2026 Yunying (<https://github.com/yunyingk/seal-home>) Copyright (c) 2026 Yunying (<https://github.com/yunyingk/seal-use>)
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
+9 -9
View File
@@ -19,18 +19,18 @@ No Node.js, Bun, or external runtime required. Run the one-line installer for ma
```bash ```bash
# 国内高速安装(Gitea 镜像源,免代理、秒级完成) # 国内高速安装(Gitea 镜像源,免代理、秒级完成)
curl -fsSL https://git.ying-qing.cn/gitea/seal-home/raw/branch/master/scripts/install.sh | bash curl -fsSL https://git.ying-qing.cn/gitea/seal-use/raw/branch/main/scripts/install.sh | bash
# Global / GitHub Direct # Global / GitHub Direct
curl -fsSL https://raw.githubusercontent.com/yunyingk/seal-home/master/scripts/install.sh | bash curl -fsSL https://raw.githubusercontent.com/yunyingk/seal-use/main/scripts/install.sh | bash
``` ```
Or download the native binary directly from [GitHub Releases](https://github.com/yunyingk/seal-home/releases/latest) or [Gitea Releases](https://git.ying-qing.cn/gitea/seal-home/releases): Or download the native binary directly from [GitHub Releases](https://github.com/yunyingk/seal-use/releases/latest) or [Gitea Releases](https://git.ying-qing.cn/gitea/seal-use/releases):
- **macOS (Apple Silicon)**: `curl -fsSL https://github.com/yunyingk/seal-home/releases/latest/download/seal-use-darwin-arm64 -o /usr/local/bin/seal-use && chmod +x /usr/local/bin/seal-use` - **macOS (Apple Silicon)**: `curl -fsSL https://github.com/yunyingk/seal-use/releases/latest/download/seal-use-darwin-arm64 -o /usr/local/bin/seal-use && chmod +x /usr/local/bin/seal-use`
- **macOS (Intel)**: `curl -fsSL https://github.com/yunyingk/seal-home/releases/latest/download/seal-use-darwin-x64 -o /usr/local/bin/seal-use && chmod +x /usr/local/bin/seal-use` - **macOS (Intel)**: `curl -fsSL https://github.com/yunyingk/seal-use/releases/latest/download/seal-use-darwin-x64 -o /usr/local/bin/seal-use && chmod +x /usr/local/bin/seal-use`
- **Linux (x86_64)**: `curl -fsSL https://github.com/yunyingk/seal-home/releases/latest/download/seal-use-linux-x64 -o /usr/local/bin/seal-use && chmod +x /usr/local/bin/seal-use` - **Linux (x86_64)**: `curl -fsSL https://github.com/yunyingk/seal-use/releases/latest/download/seal-use-linux-x64 -o /usr/local/bin/seal-use && chmod +x /usr/local/bin/seal-use`
- **Linux (ARM64)**: `curl -fsSL https://github.com/yunyingk/seal-home/releases/latest/download/seal-use-linux-arm64 -o /usr/local/bin/seal-use && chmod +x /usr/local/bin/seal-use` - **Linux (ARM64)**: `curl -fsSL https://github.com/yunyingk/seal-use/releases/latest/download/seal-use-linux-arm64 -o /usr/local/bin/seal-use && chmod +x /usr/local/bin/seal-use`
- **Windows (x64)**: Download `seal-use-windows-x64.zip` from Releases and extract `seal-use-windows-x64.exe`. - **Windows (x64)**: Download `seal-use-windows-x64.zip` from Releases and extract `seal-use-windows-x64.exe`.
After installation: After installation:
@@ -357,11 +357,11 @@ bun run bump 0.8.5
```bash ```bash
git commit -am "Release vX.Y.Z: ..." git commit -am "Release vX.Y.Z: ..."
git tag -a vX.Y.Z -m "🚀 版本更新文案与主要特性说明" git tag -a vX.Y.Z -m "🚀 版本更新文案与主要特性说明"
git push origin master --tags && git push home master --tags git push origin main --tags && git push home main --tags
``` ```
**CI Automation Pipeline:** **CI Automation Pipeline:**
- GitHub Actions triggers automatically upon pushing a `v*` tag; - GitHub Actions triggers automatically upon pushing a `v*` tag;
- Cross-compiles standalone binaries for 5 target platforms (macOS Apple Silicon/Intel, Linux x86_64/ARM64, Windows x64) in under 60 seconds; - Cross-compiles standalone binaries for 5 target platforms (macOS Apple Silicon/Intel, Linux x86_64/ARM64, Windows x64) in under 60 seconds;
- Automatically extracts your Git tag annotation message and appends commit changelogs (`--generate-notes`); - Automatically extracts your Git tag annotation message and appends commit changelogs (`--generate-notes`);
- Simultaneously publishes release packages to **[GitHub Releases](https://github.com/yunyingk/seal-home/releases)** and **[Gitea Releases](https://git.ying-qing.cn/gitea/seal-home/releases)** for global and mainland China high-speed downloads. - Simultaneously publishes release packages to **[GitHub Releases](https://github.com/yunyingk/seal-use/releases)** and **[Gitea Releases](https://git.ying-qing.cn/gitea/seal-use/releases)** for global and mainland China high-speed downloads.
+7 -7
View File
@@ -71,7 +71,7 @@ import{createRequire as qy}from"node:module";var Yy=Object.create;var{getPrototy
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let e of n.seen.entries()){let l=e[1];if(i===e[0]){u(e);continue}if(n.external){let I=n.external.registry.get(e[0])?.id;if(i!==e[0]&&I){u(e);continue}}if(n.metadataRegistry.get(e[0])?.id){u(e);continue}if(l.cycle){u(e);continue}if(l.count>1){if(n.reused==="ref"){u(e);continue}}}}function rt(n,i){let r=n.seen.get(i);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(l)=>{let $=n.seen.get(l);if($.ref===null)return;let I=$.def??$.schema,g={...I},b=$.ref;if($.ref=null,b){o(b);let f=n.seen.get(b),c=f.schema;if(c.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0"))I.allOf=I.allOf??[],I.allOf.push(c);else Object.assign(I,c);if(Object.assign(I,g),l._zod.parent===b)for(let k in I){if(k==="$ref"||k==="allOf")continue;if(!(k in g))delete I[k]}if(c.$ref&&f.def)for(let k in I){if(k==="$ref"||k==="allOf")continue;if(k in f.def&&JSON.stringify(I[k])===JSON.stringify(f.def[k]))delete I[k]}}let w=l._zod.parent;if(w&&w!==b){o(w);let f=n.seen.get(w);if(f?.schema.$ref){if(I.$ref=f.schema.$ref,f.def)for(let c in I){if(c==="$ref"||c==="allOf")continue;if(c in f.def&&JSON.stringify(I[c])===JSON.stringify(f.def[c]))delete I[c]}}}n.override({zodSchema:l,jsonSchema:I,path:$.path??[]})};for(let l of[...n.seen.entries()].reverse())o(l[0]);let t={};if(n.target==="draft-2020-12")t.$schema="https://json-schema.org/draft/2020-12/schema";else if(n.target==="draft-07")t.$schema="http://json-schema.org/draft-07/schema#";else if(n.target==="draft-04")t.$schema="http://json-schema.org/draft-04/schema#";else if(n.target==="openapi-3.0");if(n.external?.uri){let l=n.external.registry.get(i)?.id;if(!l)throw Error("Schema is missing an `id` property");t.$id=n.external.uri(l)}Object.assign(t,r.def??r.schema);let u=n.metadataRegistry.get(i)?.id;if(u!==void 0&&t.id===u)delete t.id;let e=n.external?.defs??{};for(let l of n.seen.entries()){let $=l[1];if($.def&&$.defId){if($.def.id===$.defId)delete $.def.id;e[$.defId]=$.def}}if(n.external);else if(Object.keys(e).length>0)if(n.target==="draft-2020-12")t.$defs=e;else t.definitions=e;try{let l=JSON.parse(JSON.stringify(t));return Object.defineProperty(l,"~standard",{value:{...i["~standard"],jsonSchema:{input:fr(i,"input",n.processors),output:fr(i,"output",n.processors)}},enumerable:!1,writable:!1}),l}catch(l){throw Error("Error converting schema to JSON.")}}function Mn(n,i){let r=i??{seen:new Set};if(r.seen.has(n))return!1;r.seen.add(n);let o=n._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return Mn(o.element,r);if(o.type==="set")return Mn(o.valueType,r);if(o.type==="lazy")return Mn(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return Mn(o.innerType,r);if(o.type==="intersection")return Mn(o.left,r)||Mn(o.right,r);if(o.type==="record"||o.type==="map")return Mn(o.keyType,r)||Mn(o.valueType,r);if(o.type==="pipe"){if(n._zod.traits.has("$ZodCodec"))return!0;return Mn(o.in,r)||Mn(o.out,r)}if(o.type==="object"){for(let t in o.shape)if(Mn(o.shape[t],r))return!0;return!1}if(o.type==="union"){for(let t of o.options)if(Mn(t,r))return!0;return!1}if(o.type==="tuple"){for(let t of o.items)if(Mn(t,r))return!0;if(o.rest&&Mn(o.rest,r))return!0;return!1}return!1}var kw=(n,i={})=>(r)=>{let o=it({...r,processors:i});return en(n,o),tt(o,n),rt(o,n)},fr=(n,i,r={})=>(o)=>{let{libraryOptions:t,target:u}=o??{},e=it({...t??{},target:u,io:i,processors:r});return en(n,e),tt(e,n),rt(e,n)};var vW={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},dw=(n,i,r,o)=>{let t=r;t.type="string";let{minimum:u,maximum:e,format:l,patterns:$,contentEncoding:I}=n._zod.bag;if(typeof u==="number")t.minLength=u;if(typeof e==="number")t.maxLength=e;if(l){if(t.format=vW[l]??l,t.format==="")delete t.format;if(l==="time")delete t.format}if(I)t.contentEncoding=I;if($&&$.size>0){let g=[...$];if(g.length===1)t.pattern=g[0].source;else if(g.length>1)t.allOf=[...g.map((b)=>({...i.target==="draft-07"||i.target==="draft-04"||i.target==="openapi-3.0"?{type:"string"}:{},pattern:b.source}))]}},Nw=(n,i,r,o)=>{let t=r,{minimum:u,maximum:e,format:l,multipleOf:$,exclusiveMaximum:I,exclusiveMinimum:g}=n._zod.bag;if(typeof l==="string"&&l.includes("int"))t.type="integer";else t.type="number";let b=typeof g==="number"&&g>=(u??Number.NEGATIVE_INFINITY),w=typeof I==="number"&&I<=(e??Number.POSITIVE_INFINITY),f=i.target==="draft-04"||i.target==="openapi-3.0";if(b)if(f)t.minimum=g,t.exclusiveMinimum=!0;else t.exclusiveMinimum=g;else if(typeof u==="number")t.minimum=u;if(w)if(f)t.maximum=I,t.exclusiveMaximum=!0;else t.exclusiveMaximum=I;else if(typeof e==="number")t.maximum=e;if(typeof $==="number")t.multipleOf=$},Lw=(n,i,r,o)=>{r.type="boolean"},yw=(n,i,r,o)=>{if(i.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},jw=(n,i,r,o)=>{if(i.unrepresentable==="Line truncated Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let e of n.seen.entries()){let l=e[1];if(i===e[0]){u(e);continue}if(n.external){let I=n.external.registry.get(e[0])?.id;if(i!==e[0]&&I){u(e);continue}}if(n.metadataRegistry.get(e[0])?.id){u(e);continue}if(l.cycle){u(e);continue}if(l.count>1){if(n.reused==="ref"){u(e);continue}}}}function rt(n,i){let r=n.seen.get(i);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(l)=>{let $=n.seen.get(l);if($.ref===null)return;let I=$.def??$.schema,g={...I},b=$.ref;if($.ref=null,b){o(b);let f=n.seen.get(b),c=f.schema;if(c.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0"))I.allOf=I.allOf??[],I.allOf.push(c);else Object.assign(I,c);if(Object.assign(I,g),l._zod.parent===b)for(let k in I){if(k==="$ref"||k==="allOf")continue;if(!(k in g))delete I[k]}if(c.$ref&&f.def)for(let k in I){if(k==="$ref"||k==="allOf")continue;if(k in f.def&&JSON.stringify(I[k])===JSON.stringify(f.def[k]))delete I[k]}}let w=l._zod.parent;if(w&&w!==b){o(w);let f=n.seen.get(w);if(f?.schema.$ref){if(I.$ref=f.schema.$ref,f.def)for(let c in I){if(c==="$ref"||c==="allOf")continue;if(c in f.def&&JSON.stringify(I[c])===JSON.stringify(f.def[c]))delete I[c]}}}n.override({zodSchema:l,jsonSchema:I,path:$.path??[]})};for(let l of[...n.seen.entries()].reverse())o(l[0]);let t={};if(n.target==="draft-2020-12")t.$schema="https://json-schema.org/draft/2020-12/schema";else if(n.target==="draft-07")t.$schema="http://json-schema.org/draft-07/schema#";else if(n.target==="draft-04")t.$schema="http://json-schema.org/draft-04/schema#";else if(n.target==="openapi-3.0");if(n.external?.uri){let l=n.external.registry.get(i)?.id;if(!l)throw Error("Schema is missing an `id` property");t.$id=n.external.uri(l)}Object.assign(t,r.def??r.schema);let u=n.metadataRegistry.get(i)?.id;if(u!==void 0&&t.id===u)delete t.id;let e=n.external?.defs??{};for(let l of n.seen.entries()){let $=l[1];if($.def&&$.defId){if($.def.id===$.defId)delete $.def.id;e[$.defId]=$.def}}if(n.external);else if(Object.keys(e).length>0)if(n.target==="draft-2020-12")t.$defs=e;else t.definitions=e;try{let l=JSON.parse(JSON.stringify(t));return Object.defineProperty(l,"~standard",{value:{...i["~standard"],jsonSchema:{input:fr(i,"input",n.processors),output:fr(i,"output",n.processors)}},enumerable:!1,writable:!1}),l}catch(l){throw Error("Error converting schema to JSON.")}}function Mn(n,i){let r=i??{seen:new Set};if(r.seen.has(n))return!1;r.seen.add(n);let o=n._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return Mn(o.element,r);if(o.type==="set")return Mn(o.valueType,r);if(o.type==="lazy")return Mn(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return Mn(o.innerType,r);if(o.type==="intersection")return Mn(o.left,r)||Mn(o.right,r);if(o.type==="record"||o.type==="map")return Mn(o.keyType,r)||Mn(o.valueType,r);if(o.type==="pipe"){if(n._zod.traits.has("$ZodCodec"))return!0;return Mn(o.in,r)||Mn(o.out,r)}if(o.type==="object"){for(let t in o.shape)if(Mn(o.shape[t],r))return!0;return!1}if(o.type==="union"){for(let t of o.options)if(Mn(t,r))return!0;return!1}if(o.type==="tuple"){for(let t of o.items)if(Mn(t,r))return!0;if(o.rest&&Mn(o.rest,r))return!0;return!1}return!1}var kw=(n,i={})=>(r)=>{let o=it({...r,processors:i});return en(n,o),tt(o,n),rt(o,n)},fr=(n,i,r={})=>(o)=>{let{libraryOptions:t,target:u}=o??{},e=it({...t??{},target:u,io:i,processors:r});return en(n,e),tt(e,n),rt(e,n)};var vW={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},dw=(n,i,r,o)=>{let t=r;t.type="string";let{minimum:u,maximum:e,format:l,patterns:$,contentEncoding:I}=n._zod.bag;if(typeof u==="number")t.minLength=u;if(typeof e==="number")t.maxLength=e;if(l){if(t.format=vW[l]??l,t.format==="")delete t.format;if(l==="time")delete t.format}if(I)t.contentEncoding=I;if($&&$.size>0){let g=[...$];if(g.length===1)t.pattern=g[0].source;else if(g.length>1)t.allOf=[...g.map((b)=>({...i.target==="draft-07"||i.target==="draft-04"||i.target==="openapi-3.0"?{type:"string"}:{},pattern:b.source}))]}},Nw=(n,i,r,o)=>{let t=r,{minimum:u,maximum:e,format:l,multipleOf:$,exclusiveMaximum:I,exclusiveMinimum:g}=n._zod.bag;if(typeof l==="string"&&l.includes("int"))t.type="integer";else t.type="number";let b=typeof g==="number"&&g>=(u??Number.NEGATIVE_INFINITY),w=typeof I==="number"&&I<=(e??Number.POSITIVE_INFINITY),f=i.target==="draft-04"||i.target==="openapi-3.0";if(b)if(f)t.minimum=g,t.exclusiveMinimum=!0;else t.exclusiveMinimum=g;else if(typeof u==="number")t.minimum=u;if(w)if(f)t.maximum=I,t.exclusiveMaximum=!0;else t.exclusiveMaximum=I;else if(typeof e==="number")t.maximum=e;if(typeof $==="number")t.multipleOf=$},Lw=(n,i,r,o)=>{r.type="boolean"},yw=(n,i,r,o)=>{if(i.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},jw=(n,i,r,o)=>{if(i.unrepresentable==="Line truncated
`);if(n===-1)return null;let i=this._buffer.toString("utf8",0,n).replace(/\r$/,"");return this._buffer=this._buffer.subarray(n+1),Xp(i)}clear(){this._buffer=void 0}}function Xp(n){return DD.parse(JSON.parse(n))}function wk(n){return JSON.stringify(n)+` `);if(n===-1)return null;let i=this._buffer.toString("utf8",0,n).replace(/\r$/,"");return this._buffer=this._buffer.subarray(n+1),Xp(i)}clear(){this._buffer=void 0}}function Xp(n){return DD.parse(JSON.parse(n))}function wk(n){return JSON.stringify(n)+`
`}class V6{constructor(n=fk.stdin,i=fk.stdout){this._stdin=n,this._stdout=i,this._readBuffer=new T6,this._started=!1,this._ondata=(r)=>{this._readBuffer.append(r),this.processReadBuffer()},this._onerror=(r)=>{this.onerror?.(r)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let n=this._readBuffer.readMessage();if(n===null)break;this.onmessage?.(n)}catch(n){this.onerror?.(n)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(n){return new Promise((i)=>{let r=wk(n);if(this._stdout.write(r))i();else this._stdout.once("drain",i)})}}import{dirname as x4,join as _K}from"node:path";import{fileURLToPath as ZK}from"node:url";class Zi extends Error{name="KyError";get isKyError(){return!0}}class ti extends Zi{name="HTTPError";response;request;options;data;constructor(n,i,r){let o=n.status||n.status===0?n.status:"",t=n.statusText??"",u=`${o} ${t}`.trim(),e=u?`status code ${u}`:"an unknown error";super(`Request failed with ${e}: ${i.method} ${i.url}`);this.response=n,this.request=i,this.options=r}}class du extends Zi{name="NetworkError";request;constructor(n,i){super(`Request failed due to a network error: ${n.method} ${n.url}`,i);this.request=n}}class Nu extends Error{name="NonError";value;constructor(n){let i="Non-error value was thrown";try{if(typeof n==="string")i=n;else if(n&&typeof n==="object"&&"message"in n&&typeof n.message==="string")i=n.message}catch{}super(i);this.value=n}}class qr extends Zi{name="ForceRetryError";customDelay;code;customRequest;constructor(n){let i=n?.cause?n.cause instanceof Error?n.cause:new Nu(n.cause):void 0;super(n?.code?`Forced retry: ${n.code}`:"Forced retry",i?{cause:i}:void 0);this.customDelay=n?.delay,this.code=n?.code,this.customRequest=n?.request}}class q6 extends Error{name="SchemaValidationError";issues;constructor(n){super("Response schema validation failed");this.issues=n}}class ki extends Zi{name="TimeoutError";request;constructor(n){super(`Request timed out: ${n.method} ${n.url}`);this.request=n}}var E6=(()=>{let n=!1,i=!1,r=typeof globalThis.ReadableStream==="function",o=typeof globalThis.Request==="function";if(r&&o)try{i=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type")}catch(t){if(t instanceof Error&&t.message==="unsupported BodyInit type")return!1;throw t}return n&&!i})(),ck=typeof globalThis.AbortController==="function",kv=typeof globalThis.AbortSignal==="function"&&typeof globalThis.AbortSignal.any==="function",Uk=typeof globalThis.ReadableStream==="function",Dk=typeof globalThis.FormData==="function",dv=["get","post","put","patch","head","delete"],Hp=()=>{return};Hp();var Sk={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Er=2147483647,Ak=40,Nv=Symbol("stop");class Lv{options;constructor(n){this.options=n}}var Ok=(n)=>new Lv(n),kk={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,baseUrl:!0,prefix:!0,retry:!0,timeout:!0,totalTimeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},dk={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0};var yv=new TextEncoder,Yp=(n)=>{if(!n)return 0;if(n instanceof FormData){let i=0;for(let[r,o]of n)i+=Ak,i+=yv.encode(`Content-Disposition: form-data; name="${r}"`).byteLength,i+=typeof o==="string"?yv.encode(o).byteLength:o.size;return i}if(n instanceof Blob)return n.size;if(n instanceof ArrayBuffer||ArrayBuffer.isView(n))return n.byteLength;if(typeof n==="string")return yv.encode(n).byteLength;if(n instanceof URLSearchParams)return yv.encode(n.toString()).byteLength;return 0},Nk=(n,i,r)=>{let o,t=0;return n.pipeThrough(new TransformStream({transform(u,e){if(e.enqueue(u),o){t+=o.byteLength;let l=i===0?0:t/i;if(l>=1)l=1-Number.EPSILON;r?.({percent:l,totalBytes:Math.max(i,t),transferredBytes:t},o)}o=u},flush(){if(o)t+=o.byteLength,r?.({percent:1,totalBytes:Math.max(i,t),transferredBytes:t},o)}}))},Lk=(n,i)=>{if(!n.body)return n;let r={status:n.status,statusText:n.statusText,headers:n.headers};if(n.status===204)return new Response(null,r);let o=Math.max(0,Number(n.headers.get("content-length"))||0);return new Response(Nk(n.body,o,i),r)},yk=(n,i,r)=>{if(!n.body)return n;let o=Yp(r??n.body);return new Request(n,{duplex:"half",body:Nk(n.body,o,i)})};var Hi=(n)=>n!==null&&typeof n==="object";var Pp=Symbol("replaceOption"),_6=(n)=>Hi(n)&&n[Pp]===!0?{isReplace:!0,value:n.value}:{isReplace:!1,value:n};var yu=(...n)=>{for(let i of n)if((!Hi(i)| Line truncated `}class V6{constructor(n=fk.stdin,i=fk.stdout){this._stdin=n,this._stdout=i,this._readBuffer=new T6,this._started=!1,this._ondata=(r)=>{this._readBuffer.append(r),this.processReadBuffer()},this._onerror=(r)=>{this.onerror?.(r)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let n=this._readBuffer.readMessage();if(n===null)break;this.onmessage?.(n)}catch(n){this.onerror?.(n)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(n){return new Promise((i)=>{let r=wk(n);if(this._stdout.write(r))i();else this._stdout.once("drain",i)})}}import{dirname as x4,join as _K}from"node:path";import{fileURLToPath as ZK}from"node:url";class Zi extends Error{name="KyError";get isKyError(){return!0}}class ti extends Zi{name="HTTPError";response;request;options;data;constructor(n,i,r){let o=n.status||n.status===0?n.status:"",t=n.statusText??"",u=`${o} ${t}`.trim(),e=u?`status code ${u}`:"an unknown error";super(`Request failed with ${e}: ${i.method} ${i.url}`);this.response=n,this.request=i,this.options=r}}class du extends Zi{name="NetworkError";request;constructor(n,i){super(`Request failed due to a network error: ${n.method} ${n.url}`,i);this.request=n}}class Nu extends Error{name="NonError";value;constructor(n){let i="Non-error value was thrown";try{if(typeof n==="string")i=n;else if(n&&typeof n==="object"&&"message"in n&&typeof n.message==="string")i=n.message}catch{}super(i);this.value=n}}class qr extends Zi{name="ForceRetryError";customDelay;code;customRequest;constructor(n){let i=n?.cause?n.cause instanceof Error?n.cause:new Nu(n.cause):void 0;super(n?.code?`Forced retry: ${n.code}`:"Forced retry",i?{cause:i}:void 0);this.customDelay=n?.delay,this.code=n?.code,this.customRequest=n?.request}}class q6 extends Error{name="SchemaValidationError";issues;constructor(n){super("Response schema validation failed");this.issues=n}}class ki extends Zi{name="TimeoutError";request;constructor(n){super(`Request timed out: ${n.method} ${n.url}`);this.request=n}}var E6=(()=>{let n=!1,i=!1,r=typeof globalThis.ReadableStream==="function",o=typeof globalThis.Request==="function";if(r&&o)try{i=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type")}catch(t){if(t instanceof Error&&t.message==="unsupported BodyInit type")return!1;throw t}return n&&!i})(),ck=typeof globalThis.AbortController==="function",kv=typeof globalThis.AbortSignal==="function"&&typeof globalThis.AbortSignal.any==="function",Uk=typeof globalThis.ReadableStream==="function",Dk=typeof globalThis.FormData==="function",dv=["get","post","put","patch","head","delete"],Hp=()=>{return};Hp();var Sk={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Er=2147483647,Ak=40,Nv=Symbol("stop");class Lv{options;constructor(n){this.options=n}}var Ok=(n)=>new Lv(n),kk={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,baseUrl:!0,prefix:!0,retry:!0,timeout:!0,totalTimeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},dk={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0};var yv=new TextEncoder,Yp=(n)=>{if(!n)return 0;if(n instanceof FormData){let i=0;for(let[r,o]of n)i+=Ak,i+=yv.encode(`Content-Disposition: form-data; name="${r}"`).byteLength,i+=typeof o==="string"?yv.encode(o).byteLength:o.size;return i}if(n instanceof Blob)return n.size;if(n instanceof ArrayBuffer||ArrayBuffer.isView(n))return n.byteLength;if(typeof n==="string")return yv.encode(n).byteLength;if(n instanceof URLSearchParams)return yv.encode(n.toString()).byteLength;return 0},Nk=(n,i,r)=>{let o,t=0;return n.pipeThrough(new TransformStream({transform(u,e){if(e.enqueue(u),o){t+=o.byteLength;let l=i===0?0:t/i;if(l>=1)l=1-Number.EPSILON;r?.({percent:l,totalBytes:Math.max(i,t),transferredBytes:t},o)}o=u},flush(){if(o)t+=o.byteLength,r?.({percent:1,totalBytes:Math.max(i,t),transferredBytes:t},o)}}))},Lk=(n,i)=>{if(!n.body)return n;let r={status:n.status,statusText:n.statusText,headers:n.headers};if(n.status===204)return new Response(null,r);let o=Math.max(0,Number(n.headers.get("content-length"))||0);return new Response(Nk(n.body,o,i),r)},yk=(n,i,r)=>{if(!n.body)return n;let o=Yp(r??n.body);return new Request(n,{duplex:"half",body:Nk(n.body,o,i)})};var Hi=(n)=>n!==null&&typeof n==="object";var Pp=Symbol("replaceOption"),_6=(n)=>Hi(n)&&n[Pp]===!0?{isReplace:!0,value:n.value}:{isReplace:!1,value:n};var yu=(...n)=>{for(let i of n)if((!Hi(i)| Line truncated
`,{mode:384}),i}function Cr(n,i,r=[]){let o=i.corpId?.trim()||void 0,t=i.stateful?i.defaultCorpId?.trim()||void 0:void 0,u=o??t;if(u){let l=n.find(($)=>$.id===u);if(l)return l;throw Error(`No enterprise config found for ${u}`)}if(!i.stateful)throw Error("Stateless mode is enabled. Every enterprise command requires --corp <corpId>. Use `seal-home config mode stateful` to enable a default enterprise.");let e=n[0];if(e)return e;throw Error("No enterprise config found. Add a non-example JSON file under one of: "+(r.length?r.join(", "):"the configured enterprise directories"))}import{readFileSync as $F}from"node:fs";import{randomBytes as IF}from"node:crypto";import{randomBytes as Bd}from"node:crypto";var GQ=v.object({staffId:v.string(),name:v.string().optional(),code:v.string().default(""),bindTime:v.number().optional()}),WQ=v.object({id:v.string(),tenantId:v.string(),name:v.string(),isAdmin:v.boolean().default(!1),permissions:v.array(v.string()).default([]),providerUserId:v.string().optional(),hosecloudStaff:GQ.optional()}),JQ=v.object({apiKey:v.string().optional(),corporationId:v.string().optional(),corporationName:v.string().optional()}),XQ=v.object({id:v.string(),name:v.string(),tenantSlug:v.string().optional(),isDemo:v.boolean().default(!1),logoUrl:v.string().nullable().optional(),hoseCorpConfig:JQ.optional()}),Ud=v.object({user:WQ,tenant:XQ}),HQ=v.object({id:v.string(),name:v.string(),email:v.string().nullable().optional(),emailVerified:v.boolean().optional(),image:v.string().nullable().optional(),tenantId:v.string().optional(),provider:v.string().optional(),providerUserId:v.string().optional(),mobile:v.string().nullable().optional(),status:v.string().optional(),permissions:v.array(v.string()).default([]),isAdmin:v.boolean().default(!1),hosecloudStaff:v.unknown().optional()}).passthrough(),YQ=v.object({id:v.string(),token:v.string().optional(),expiresAt:v.string(),createdAt:v.string().optional(),updatedAt:v.string().optional(),ipAddress:v.string().optional(),userAgent:v.string().optional(),userId:v.string(),delegationId:v.string().nullable().optional()}).passthrough(),Dd=v.object({user:HQ,session:YQ}),_v=v.object({id:v.string(),tenantId:v.string().optional(),code:v.number().optional(),description:v.string(),scope:v.string(),strictness:v.string(),status:v.string().optional(),createdAt:v.number().optional(),updatedAt:v.number().optional()}),Sd=v.object({rules:v.array(_v),hasPendingDeletes:v.boolean().default(!1)}),PQ=v.object({code:v.string().optional(),description:v.string(),scope:v.string(),strictness:v.string()}),Zv=v.object({id:v.string(),tenantId:v.string().optional(),versionNumber:v.number(),versionName:v.string().nullable().optional(),publishedBy:v.string().nullable().optional(),publishedByName:v.string().nullable().optional(),rules:v.array(PQ).default([]),publishedAt:v.number().optional(),createdAt:v.number().optional()}),Ad=v.object({version:Zv,rulesCount:v.number()}),Pu=v.object({id:v.string(),tenantId:v.string().optional(),title:v.string(),purpose:v.string().default(""),contentType:v.string().default("policy"),content:v.string(),status:v.string().default("published"),enabled:v.boolean().default(!0),scenarios:v.array(v.string()).default([]),tags:v.array(v.string()).default([]),category:v.string().nullable().optional(),categoryTags:v.array(v.string()).default([]),createdBy:v.string().nullable().optional(),createdByName:v.string().nullable().optional(),createdAt:v.number().optional(),updatedAt:v.number().optional(),updatedBy:v.string().nullable().optional(),updatedByName:v.string().nullable().optional(),isDeleted:v.boolean().default(!1)}),Od=v.object({articles:v.array(Pu),total:v.number().optional()}),pQ=v.object({explicitApprove:v.string().default(""),explicitReject:v.string().default(""),exemptApprove:v.string().default(""),review:v.string().default("")}).passthrough(),QQ=v.object({type:v.string(),signKey:v.string().optional(),outboundName:v.string().optional(),mode:v.string().optional(),autoApprovalRate:v.number().optional(),apiKey:v.string().optional(),apiSecret:v.string().optional(),apiOrigin:v.string().optional(),corporationId:v.string().optional(),ebotSignKey:v.string().optional(),completionSignKey:v.string().optional(),outboundMessageId:v.string().optional(),completionMessageId:v.string().optional()}).passthrough(),FQ=v.enum(["assisted","semi_automatic","fully_automatic"]),cd=v.object({id:v.string(),url:v.string().url()}).passthrough(),pu=v.object({type:v.literal("webhook"),id:v.string(),name:v.string(),mode:FQ,incomingDocumentWebhook:cd,outgoingResultWebhook:v.string().url(),incomingManualResultWebhook:cd,secret:v.string().min(1),autoApprovalRate:v.number().int().min(0).max(100).optional()}).passthrough(),l4=v.object({id:v.string().optional(),tenantId:v.string().optional(),tone:v.string().optional(),language:v.string().optional(),detailLevel:v.string().optional(),outputFormat:v.string().optional(),examples:v.array(v.string()).default([]),prohibitedPhrases:v.array(v.string()).default([]),cus Line truncated `,{mode:384}),i}function Cr(n,i,r=[]){let o=i.corpId?.trim()||void 0,t=i.stateful?i.defaultCorpId?.trim()||void 0:void 0,u=o??t;if(u){let l=n.find(($)=>$.id===u);if(l)return l;throw Error(`No enterprise config found for ${u}`)}if(!i.stateful)throw Error("Stateless mode is enabled. Every enterprise command requires --corp <corpId>. Use `seal-home config mode stateful` to enable a default enterprise.");let e=n[0];if(e)return e;throw Error("No enterprise config found. Add a non-example JSON file under one of: "+(r.length?r.join(", "):"the configured enterprise directories"))}import{readFileSync as $F}from"node:fs";import{randomBytes as IF}from"node:crypto";import{randomBytes as Bd}from"node:crypto";var GQ=v.object({staffId:v.string(),name:v.string().optional(),code:v.string().default(""),bindTime:v.number().optional()}),WQ=v.object({id:v.string(),tenantId:v.string(),name:v.string(),isAdmin:v.boolean().default(!1),permissions:v.array(v.string()).default([]),providerUserId:v.string().optional(),hosecloudStaff:GQ.optional()}),JQ=v.object({apiKey:v.string().optional(),corporationId:v.string().optional(),corporationName:v.string().optional()}),XQ=v.object({id:v.string(),name:v.string(),tenantSlug:v.string().optional(),isDemo:v.boolean().default(!1),logoUrl:v.string().nullable().optional(),hoseCorpConfig:JQ.optional()}),Ud=v.object({user:WQ,tenant:XQ}),HQ=v.object({id:v.string(),name:v.string(),email:v.string().nullable().optional(),emailVerified:v.boolean().optional(),image:v.string().nullable().optional(),tenantId:v.string().optional(),provider:v.string().optional(),providerUserId:v.string().optional(),mobile:v.string().nullable().optional(),status:v.string().optional(),permissions:v.array(v.string()).default([]),isAdmin:v.boolean().default(!1),hosecloudStaff:v.unknown().optional()}).passthrough(),YQ=v.object({id:v.string(),token:v.string().optional(),expiresAt:v.string(),createdAt:v.string().optional(),updatedAt:v.string().optional(),ipAddress:v.string().optional(),userAgent:v.string().optional(),userId:v.string(),delegationId:v.string().nullable().optional()}).passthrough(),Dd=v.object({user:HQ,session:YQ}),_v=v.object({id:v.string(),tenantId:v.string().optional(),code:v.number().optional(),description:v.string(),scope:v.string(),strictness:v.string(),status:v.string().optional(),createdAt:v.number().optional(),updatedAt:v.number().optional()}),Sd=v.object({rules:v.array(_v),hasPendingDeletes:v.boolean().default(!1)}),PQ=v.object({code:v.string().optional(),description:v.string(),scope:v.string(),strictness:v.string()}),Zv=v.object({id:v.string(),tenantId:v.string().optional(),versionNumber:v.number(),versionName:v.string().nullable().optional(),publishedBy:v.string().nullable().optional(),publishedByName:v.string().nullable().optional(),rules:v.array(PQ).default([]),publishedAt:v.number().optional(),createdAt:v.number().optional()}),Ad=v.object({version:Zv,rulesCount:v.number()}),Pu=v.object({id:v.string(),tenantId:v.string().optional(),title:v.string(),purpose:v.string().default(""),contentType:v.string().default("policy"),content:v.string(),status:v.string().default("published"),enabled:v.boolean().default(!0),scenarios:v.array(v.string()).default([]),tags:v.array(v.string()).default([]),category:v.string().nullable().optional(),categoryTags:v.array(v.string()).default([]),createdBy:v.string().nullable().optional(),createdByName:v.string().nullable().optional(),createdAt:v.number().optional(),updatedAt:v.number().optional(),updatedBy:v.string().nullable().optional(),updatedByName:v.string().nullable().optional(),isDeleted:v.boolean().default(!1)}),Od=v.object({articles:v.array(Pu),total:v.number().optional()}),pQ=v.object({explicitApprove:v.string().default(""),explicitReject:v.string().default(""),exemptApprove:v.string().default(""),review:v.string().default("")}).passthrough(),QQ=v.object({type:v.string(),signKey:v.string().optional(),outboundName:v.string().optional(),mode:v.string().optional(),autoApprovalRate:v.number().optional(),apiKey:v.string().optional(),apiSecret:v.string().optional(),apiOrigin:v.string().optional(),corporationId:v.string().optional(),ebotSignKey:v.string().optional(),completionSignKey:v.string().optional(),outboundMessageId:v.string().optional(),completionMessageId:v.string().optional()}).passthrough(),FQ=v.enum(["assisted","semi_automatic","fully_automatic"]),cd=v.object({id:v.string(),url:v.string().url()}).passthrough(),pu=v.object({type:v.literal("webhook"),id:v.string(),name:v.string(),mode:FQ,incomingDocumentWebhook:cd,outgoingResultWebhook:v.string().url(),incomingManualResultWebhook:cd,secret:v.string().min(1),autoApprovalRate:v.number().int().min(0).max(100).optional()}).passthrough(),l4=v.object({id:v.string().optional(),tenantId:v.string().optional(),tone:v.string().optional(),language:v.string().optional(),detailLevel:v.string().optional(),outputFormat:v.string().optional(),examples:v.array(v.string()).default([]),prohibitedPhrases:v.array(v.string()).default([]),cus Line truncated
`);return{recordId:n.id,sourceDocumentSN:n.sourceDocumentSN,sourceDocumentId:n.sourceDocumentId,document:Dt({id:i?.id,sn:i?.sn??i?.sourceDocumentSN??n.sourceDocumentSN,title:i?.title??i?.name,template:n$(i,["template.name","templateName","form.name","formName","formTitle"]),amount:av(r,["金额","报销金额","付款金额","合计","价税合计"])??n$(i,["amount","totalAmount","expenseAmount"]),expenseType:av(r,["费用类型","费用类别","报销类型"]),costCompany:av(r,["费用承担公司","承担公司","成本中心","费用归属"]),payee:av(r,["收款方","收款账户","收款信息","开户名","银行账号"]),keyFields:r.slice(0,30)}),invoices:WF(n),attachments:MN(n,{summary:!0}).attachments,aiResult:t$(n),manualResult:Et(n)?.value,hints:Dt({amountMentions:PN(o,["金额","合计","税率"],8),partyMentions:PN(o,["买方","卖方","甲方","乙方","收款"],8)})}}function MN(n,i={}){let r=[["document",n.document],["result",n.result],["pipelineData",n.pipelineData],["sourceExtendData",n.sourceExtendData]],o=[],t=new Set;for(let[u,e]of r)y4(e,u,o,t);return{recordId:n.id,sourceDocumentSN:n.sourceDocumentSN,sourceDocumentId:n.sourceDocumentId,count:o.length,attachments:i.summary?o.map((u)=>Dt({path:u.path,kind:u.kind,fileName:u.fileName,mimeType:u.mimeType,fileId:u.fileId,sourceField:u.sourceField})):o}}function dF(n){let i=[["result.citedRules",zi(n,"result.citedRules")],["result.matchedRules",zi(n,"result.matchedRules")],["result.ruleResults",zi(n,"result.ruleResults")],["result.rules",zi(n,"result.rules")],["pipelineData.citedRules",zi(n,"pipelineData.citedRules")],["pipelineData.matchedRules",zi(n,"pipelineData.matchedRules")]],r=[],o=new Set;for(let[t,u]of i)(Array.isArray(u)?u:u&&typeof u==="object"?Object.values(u):[]).forEach((l,$)=>{let I=hr(l);if(!I)return;let g=q(I.runtimeRuleId)??q(I.runtimeId)??q(I.id)??q(I.ruleId),b=q(I.ruleCode)??q(I.code)??(g?HF(g):void 0),w=Dt({runtimeRuleId:g,ruleCode:b,versionNumber:jF(I.versionNumber)??n.ruleSetVersionNumber,scope:q(I.scope),strictness:q(I.strictness),appliedAnalysis:I.appliedAnalysis??I.analysis??I.reasoning,checkResult:I.checkResult??I.result??I.decision,findings:I.findings??I.riskPoints??I.evidence,sourcePath:`${t}.${$}`}),f=JSON.stringify(w);if(!o.has(f))o.add(f),r.push(w)});return{recordId:n.id,sourceDocumentSN:n.sourceDocumentSN,sourceDocumentId:n.sourceDocumentId,ruleSetVersionNumber:n.ruleSetVersionNumber,count:r.length,rules:r}}function y4(n,i,r,o){if(Array.isArray(n)){n.forEach((u,e)=>y4(u,`${i}.${e}`,r,o));return}let t=hr(n);if(!t)return;if(NF(t,i)){let u=Dt({path:i,fieldPath:i,kind:LF(i,t),fileName:q(t.fileName)??q(t.filename)??q(t.name)??q(t.originalName),mimeType:q(t.mimeType)??q(t.mimetype)??q(t.contentType),fileId:q(t.fileId)??q(t.id)??q(t.attachmentId),ossPath:q(t.ossPath)??q(t.ossKey)??q(t.key),url:q(t.url)??q(t.signedUrl)??q(t.downloadUrl)??q(t.previewUrl),invoiceId:q(t.invoiceId),sourceField:q(t.fieldName)??q(t.label)}),e=JSON.stringify(u);if(!o.has(e))o.add(e),r.push(u)}for(let[u,e]of Object.entries(t))y4(e,`${i}.${u}`,r,o)}function NF(n,i){let r=Object.keys(n).map((u)=>u.toLowerCase());return/(attachment|attachments|invoice|receipt|file|files|附件|发票)/i.test(i)&&["filename","fileName","mimeType","mimetype","contentType","fileId","ossPath","signedUrl","downloadUrl","previewUrl","attachmentId"].some((u)=>r.includes(u.toLowerCase()))}function LF(n,i){let r=`${n} ${q(i.type)??""}`.toLowerCase();if(r.includes("invoice")||r.includes("发票"))return"invoice";if(r.includes("receipt"))return"receipt";return"attachment"}function n$(n,i){if(!n)return;for(let r of i){let o=zi(n,r);if(o!==void 0)return o}return}function YN(n,i){if(!n)return 0;for(let r of i){let o=zi(n,r);if(Array.isArray(o))return o.length;if(o&&typeof o==="object")return Object.keys(o).length;if(typeof o==="number")return o}return 0}function zi(n,i){return i.split(".").reduce((r,o)=>{if(r===void 0||r===null)return;if(Array.isArray(r)){let t=Number(o);return Number.isInteger(t)?r[t]:void 0}if(typeof r==="object")return r[o];return},n)}function yF(n,i,r){let o=i.split("."),t=n;for(let u of o.slice(0,-1)){let e=t[u];if(!e||typeof e!=="object"||Array.isArray(e))t[u]={};t=t[u]}t[o[o.length-1]??i]=r}function Dt(n){return Object.fromEntries(Object.entries(n).filter(([,i])=>i!==void 0))}function hr(n){return n&&typeof n==="object"&&!Array.isArray(n)?n:void 0}function jF(n){return typeof n==="number"&&Number.isFinite(n)?n:void 0}function GF(n){let i=[];return j4(n,"document",i),i}function j4(n,i,r){if(Array.isArray(n)){n.forEach((e,l)=>j4(e,`${i}.${l}`,r));return}let o=hr(n);if(!o)return;let t=q(o.label)??q(o.name)??q(o.title)??q(o.fieldName),u=o.value??o.displayValue??o.text??o.content;if(t&&u!==void 0&&typeof u!=="object")r.push(Dt({path:i,label:t,value:u,type:q(o.type)??q(o.fieldType)}));for(let[e,l]of Object.entries(o)){if(e==="attachments")continue;j4(l,`${i}.${e}`,r)}}function av(n,i){return n.find((o)=>{let t=q(o.label)??"";return i.some((u)=>t.includes(u)) Line truncated `);return{recordId:n.id,sourceDocumentSN:n.sourceDocumentSN,sourceDocumentId:n.sourceDocumentId,document:Dt({id:i?.id,sn:i?.sn??i?.sourceDocumentSN??n.sourceDocumentSN,title:i?.title??i?.name,template:n$(i,["template.name","templateName","form.name","formName","formTitle"]),amount:av(r,["金额","报销金额","付款金额","合计","价税合计"])??n$(i,["amount","totalAmount","expenseAmount"]),expenseType:av(r,["费用类型","费用类别","报销类型"]),costCompany:av(r,["费用承担公司","承担公司","成本中心","费用归属"]),payee:av(r,["收款方","收款账户","收款信息","开户名","银行账号"]),keyFields:r.slice(0,30)}),invoices:WF(n),attachments:MN(n,{summary:!0}).attachments,aiResult:t$(n),manualResult:Et(n)?.value,hints:Dt({amountMentions:PN(o,["金额","合计","税率"],8),partyMentions:PN(o,["买方","卖方","甲方","乙方","收款"],8)})}}function MN(n,i={}){let r=[["document",n.document],["result",n.result],["pipelineData",n.pipelineData],["sourceExtendData",n.sourceExtendData]],o=[],t=new Set;for(let[u,e]of r)y4(e,u,o,t);return{recordId:n.id,sourceDocumentSN:n.sourceDocumentSN,sourceDocumentId:n.sourceDocumentId,count:o.length,attachments:i.summary?o.map((u)=>Dt({path:u.path,kind:u.kind,fileName:u.fileName,mimeType:u.mimeType,fileId:u.fileId,sourceField:u.sourceField})):o}}function dF(n){let i=[["result.citedRules",zi(n,"result.citedRules")],["result.matchedRules",zi(n,"result.matchedRules")],["result.ruleResults",zi(n,"result.ruleResults")],["result.rules",zi(n,"result.rules")],["pipelineData.citedRules",zi(n,"pipelineData.citedRules")],["pipelineData.matchedRules",zi(n,"pipelineData.matchedRules")]],r=[],o=new Set;for(let[t,u]of i)(Array.isArray(u)?u:u&&typeof u==="object"?Object.values(u):[]).forEach((l,$)=>{let I=hr(l);if(!I)return;let g=q(I.runtimeRuleId)??q(I.runtimeId)??q(I.id)??q(I.ruleId),b=q(I.ruleCode)??q(I.code)??(g?HF(g):void 0),w=Dt({runtimeRuleId:g,ruleCode:b,versionNumber:jF(I.versionNumber)??n.ruleSetVersionNumber,scope:q(I.scope),strictness:q(I.strictness),appliedAnalysis:I.appliedAnalysis??I.analysis??I.reasoning,checkResult:I.checkResult??I.result??I.decision,findings:I.findings??I.riskPoints??I.evidence,sourcePath:`${t}.${$}`}),f=JSON.stringify(w);if(!o.has(f))o.add(f),r.push(w)});return{recordId:n.id,sourceDocumentSN:n.sourceDocumentSN,sourceDocumentId:n.sourceDocumentId,ruleSetVersionNumber:n.ruleSetVersionNumber,count:r.length,rules:r}}function y4(n,i,r,o){if(Array.isArray(n)){n.forEach((u,e)=>y4(u,`${i}.${e}`,r,o));return}let t=hr(n);if(!t)return;if(NF(t,i)){let u=Dt({path:i,fieldPath:i,kind:LF(i,t),fileName:q(t.fileName)??q(t.filename)??q(t.name)??q(t.originalName),mimeType:q(t.mimeType)??q(t.mimetype)??q(t.contentType),fileId:q(t.fileId)??q(t.id)??q(t.attachmentId),ossPath:q(t.ossPath)??q(t.ossKey)??q(t.key),url:q(t.url)??q(t.signedUrl)??q(t.downloadUrl)??q(t.previewUrl),invoiceId:q(t.invoiceId),sourceField:q(t.fieldName)??q(t.label)}),e=JSON.stringify(u);if(!o.has(e))o.add(e),r.push(u)}for(let[u,e]of Object.entries(t))y4(e,`${i}.${u}`,r,o)}function NF(n,i){let r=Object.keys(n).map((u)=>u.toLowerCase());return/(attachment|attachments|invoice|receipt|file|files|附件|发票)/i.test(i)&&["filename","fileName","mimeType","mimetype","contentType","fileId","ossPath","signedUrl","downloadUrl","previewUrl","attachmentId"].some((u)=>r.includes(u.toLowerCase()))}function LF(n,i){let r=`${n} ${q(i.type)??""}`.toLowerCase();if(r.includes("invoice")||r.includes("发票"))return"invoice";if(r.includes("receipt"))return"receipt";return"attachment"}function n$(n,i){if(!n)return;for(let r of i){let o=zi(n,r);if(o!==void 0)return o}return}function YN(n,i){if(!n)return 0;for(let r of i){let o=zi(n,r);if(Array.isArray(o))return o.length;if(o&&typeof o==="object")return Object.keys(o).length;if(typeof o==="number")return o}return 0}function zi(n,i){return i.split(".").reduce((r,o)=>{if(r===void 0||r===null)return;if(Array.isArray(r)){let t=Number(o);return Number.isInteger(t)?r[t]:void 0}if(typeof r==="object")return r[o];return},n)}function yF(n,i,r){let o=i.split("."),t=n;for(let u of o.slice(0,-1)){let e=t[u];if(!e||typeof e!=="object"||Array.isArray(e))t[u]={};t=t[u]}t[o[o.length-1]??i]=r}function Dt(n){return Object.fromEntries(Object.entries(n).filter(([,i])=>i!==void 0))}function hr(n){return n&&typeof n==="object"&&!Array.isArray(n)?n:void 0}function jF(n){return typeof n==="number"&&Number.isFinite(n)?n:void 0}function GF(n){let i=[];return j4(n,"document",i),i}function j4(n,i,r){if(Array.isArray(n)){n.forEach((e,l)=>j4(e,`${i}.${l}`,r));return}let o=hr(n);if(!o)return;let t=q(o.label)??q(o.name)??q(o.title)??q(o.fieldName),u=o.value??o.displayValue??o.text??o.content;if(t&&u!==void 0&&typeof u!=="object")r.push(Dt({path:i,label:t,value:u,type:q(o.type)??q(o.fieldType)}));for(let[e,l]of Object.entries(o)){if(e==="attachments")continue;j4(l,`${i}.${e}`,r)}}function av(n,i){return n.find((o)=>{let t=q(o.label)??"";return i.some((u)=>t.includes(u)) Line truncated
`)} `)}
@@ -181,7 +181,7 @@ Usage:
- ${On} - ${On}
Please specify 'staffId', 'staffName', or 'staffPhone' to explicitly select an account (or pass force:true to bypass).`)}}}if(!S)if(!g&&u)S=u;else throw Error("Missing required parameter: staffId (or proxyStaffBizId). Run 'seal-use corps hose-staffs' to discover available administrators.");let k=Un(n,"id")??w,d=f??w,Q=Un(n,"sealUrl")??`https://${w.toLowerCase()}.sealai.cc`,Y={id:k,name:d,seal:{url:Q,endpoints:{approvalStylePreferences:"api/v1/agent/ai-approval/config"}},source:{type:"hose",domain:b,appKey:r,appSecurity:o,corpId:w,staffId:S},auth:{refreshTtl:300}};if(g)Xv(k),await xr(Y);let G=e4();UL(G,{recursive:!0,mode:448});let N=SL(G,`${P4(k)}.json`);if(cL(N)&&n.overwrite!==!0)throw Error(`Enterprise config already exists: ${N}. Pass "overwrite": true to replace it.`);DL(N,`${JSON.stringify(Y,null,2)} Please specify 'staffId', 'staffName', or 'staffPhone' to explicitly select an account (or pass force:true to bypass).`)}}}if(!S)if(!g&&u)S=u;else throw Error("Missing required parameter: staffId (or proxyStaffBizId). Run 'seal-use corps hose-staffs' to discover available administrators.");let k=Un(n,"id")??w,d=f??w,Q=Un(n,"sealUrl")??`https://${w.toLowerCase()}.sealai.cc`,Y={id:k,name:d,seal:{url:Q,endpoints:{approvalStylePreferences:"api/v1/agent/ai-approval/config"}},source:{type:"hose",domain:b,appKey:r,appSecurity:o,corpId:w,staffId:S},auth:{refreshTtl:300}};if(g)Xv(k),await xr(Y);let G=e4();UL(G,{recursive:!0,mode:448});let N=SL(G,`${P4(k)}.json`);if(cL(N)&&n.overwrite!==!0)throw Error(`Enterprise config already exists: ${N}. Pass "overwrite": true to replace it.`);DL(N,`${JSON.stringify(Y,null,2)}
`,{mode:384}),B({id:k,name:d,corpId:w,domain:b,staffId:S,verified:g,path:N})}async function xF(n){let i=St(n,"token"),r=(Un(n,"sealUrl")??Un(n,"url")??"").replace(/\/+$/,"");if(!r)throw Error("Missing required JSON field: sealUrl");let o=aN(n,"expiresIn")??2592000,t=n.force===!0||n.verify===!1?!1:!0,u=t?await sF(r,i):void 0;OL(n,{token:i,sealUrl:r,expiresIn:o,verify:t,remote:u})}async function aF(n,i,r){let o=await Hv(n),t=Xu(o.sealUrl,o.token),u=await pi(t),e={user:u.user,tenant:u.tenant};Yv(o.corpId,e.tenant),OL({id:o.corpId,corpId:o.corpId,name:i,provider:"hosecloud",overwrite:r},{token:o.token,sealUrl:o.sealUrl,expiresIn:o.expiresIn,verify:!0,remote:e})}function OL(n,i){let{token:r,sealUrl:o,expiresIn:t,verify:u,remote:e}=i,l=e?.user,$=e?.tenant,I=Un(n,"tenantSlug")??At($?.tenantSlug),g=Un(n,"tenantId")??At($?.id),b=Un(n,"tenantName")??At($?.name),w=Un(n,"id")??I??g;if(!w)throw Error("Missing required JSON field: id. Seal whoami did not return tenantSlug or tenantId.");let f=Un(n,"staffId")??At(l?.providerUserId)??At(l?.id)??"seal",c=Un(n,"provider")??At(l?.provider)??At($?.providerConfig?.provider),S=Un(n,"corpId")??I??g??w,k={id:w,name:Un(n,"name")??b??w,seal:{url:o,tenantSlug:I,endpoints:{approvalStylePreferences:"api/v1/agent/ai-approval/config"}},source:{type:"seal",token:r,sealUrl:o,expiresIn:t,staffId:f,corpId:S,tenantId:g,tenantSlug:I,tenantName:b,providerUserId:At(l?.providerUserId),provider:c},auth:{refreshTtl:300}},d=e4();UL(d,{recursive:!0,mode:448});let Q=SL(d,`${P4(w)}.json`);if(cL(Q)&&n.overwrite!==!0)throw Error(`Enterprise config already exists: ${Q}. Pass "overwrite": true to replace it.`);DL(Q,`${JSON.stringify(k,null,2)} `,{mode:384}),B({id:k,name:d,corpId:w,domain:b,staffId:S,verified:g,path:N})}async function xF(n){let i=St(n,"token"),r=(Un(n,"sealUrl")??Un(n,"url")??"").replace(/\/+$/,"");if(!r)throw Error("Missing required JSON field: sealUrl");let o=aN(n,"expiresIn")??2592000,t=n.force===!0||n.verify===!1?!1:!0,u=t?await sF(r,i):void 0;OL(n,{token:i,sealUrl:r,expiresIn:o,verify:t,remote:u})}async function aF(n,i,r){let o=await Hv(n),t=Xu(o.sealUrl,o.token),u=await pi(t),e={user:u.user,tenant:u.tenant};Yv(o.corpId,e.tenant),OL({id:o.corpId,corpId:o.corpId,name:i,provider:"hosecloud",overwrite:r},{token:o.token,sealUrl:o.sealUrl,expiresIn:o.expiresIn,verify:!0,remote:e})}function OL(n,i){let{token:r,sealUrl:o,expiresIn:t,verify:u,remote:e}=i,l=e?.user,$=e?.tenant,I=Un(n,"tenantSlug")??At($?.tenantSlug),g=Un(n,"tenantId")??At($?.id),b=Un(n,"tenantName")??At($?.name),w=Un(n,"id")??I??g;if(!w)throw Error("Missing required JSON field: id. Seal whoami did not return tenantSlug or tenantId.");let f=Un(n,"staffId")??At(l?.providerUserId)??At(l?.id)??"seal",c=Un(n,"provider")??At(l?.provider)??At($?.providerConfig?.provider),S=Un(n,"corpId")??I??g??w,k={id:w,name:Un(n,"name")??b??w,seal:{url:o,tenantSlug:I,endpoints:{approvalStylePreferences:"api/v1/agent/ai-approval/config"}},source:{type:"seal",token:r,sealUrl:o,expiresIn:t,staffId:f,corpId:S,tenantId:g,tenantSlug:I,tenantName:b,providerUserId:At(l?.providerUserId),provider:c},auth:{refreshTtl:300}},d=e4();UL(d,{recursive:!0,mode:448});let Q=SL(d,`${P4(w)}.json`);if(cL(Q)&&n.overwrite!==!0)throw Error(`Enterprise config already exists: ${Q}. Pass "overwrite": true to replace it.`);DL(Q,`${JSON.stringify(k,null,2)}
`,{mode:384}),B({id:w,name:k.name,tenantId:g,tenantSlug:I,verified:u,path:Q})}async function sF(n,i){let r=await nK(`${n}/api/v1/auth/me`,{authorization:`Bearer ${i}`}),o=u$(r.data);return{user:u$(o.user??r.user),tenant:u$(o.tenant??r.tenant)}}async function nK(n,i={}){let r=await fetch(n,{headers:i}),o=await r.text();if(!r.ok)throw Error(`${r.status} ${o}`);let t=JSON.parse(o);return u$(t)}function u$(n){return n&&typeof n==="object"&&!Array.isArray(n)?n:{}}function At(n){return typeof n==="string"&&n?n:void 0}async function kL(n,i){let r=await Hv(n),o=Xu(r.sealUrl,r.token),t=await pi(o);Yv(r.corpId,t.tenant);let u=await Rr(o,{note:i});B({tenant:{id:t.tenant.id,name:t.tenant.name,tenantSlug:t.tenant.tenantSlug,corpId:r.corpId},user:{id:t.user.id,name:t.user.name,providerUserId:t.user.providerUserId,isAdmin:t.user.isAdmin},delegation:u,expiresIn:r.expiresIn})}async function dL(n,i,r,o,t){if(n==="list"){await X("seal_delegation_list",r,o,{},J(t.options));return}if(n==="create"){let u=D(t.options.note)??(i?[i,...t.command.slice(2)].join(" "):void 0);await X("seal_delegation_create",r,o,{note:u},J(t.options));return}if(n==="revoke"){let u=i??D(t.options.tokenId);if(!u)throw Error("Usage: seal-use delegation revoke <tokenId>");await X("seal_delegation_revoke",r,o,{tokenId:u},J(t.options));return}throw Error(`Unknown delegation command: ${n??""}. Run 'seal-use help' for available commands.`)}import{readFileSync as iK}from"node:fs";async function NL(n,i,r,o,t,u){let e=n==="hosecloud"||!n,l=n==="hosecloud"?i:n,$=n==="hosecloud"?r:i;if(!e&&n!=="hosecloud")throw Error(`Unknown deploy target: ${n??""}. Currently supported: hosecloud`);if(l==="requirements"){await X("seal_deploy_hosecloud_requirements",o,t,{},J(u.options));return}if(l==="list"){await X("seal_deploy_hosecloud_list",o,t,{},J(u.options));return}if(l==="get"){let I=$??D(u.options.signKey)??D(u.options["sign-key"]);if(!I)throw Error("Usage: seal-use deploy hosecloud get <sign-key>");await X("seal_deploy_hosecloud_get",o,t,{signKey:I},J(u.options));return}if(l==="status"){await X("seal_deploy_hosecloud_status",o,t,{},J(u.options));return}if(l==="configure"){let I=D(u.options.input),g=I?JSON.parse(iK(I,"utf8")):ri(u.json);if(!g||Object.keys(g).length===0)throw Error("Usage: seal-use deploy hosecloud configure --json '{...}' or --input <file>");await X("seal_deploy_hosecloud_configure",o,t,g,J(u.options));return}if(l==="sync"){let I=$??D(u.options.signKey)??D(u.options["sign-key"]);if(!I)throw Error("Usage: seal-use deploy hosecloud sync <sign-key>");await X("seal_deploy_hosecloud_sync",o,t,{signKey:I},J(u.options));return}throw Error(`Unknown deploy hosecloud action: ${l??""}. Available: requirements, list, get, status, configure, sync.`)}import{createServer as eK}from"node:http";import{URL as rK}from"node:url";var LL={openapi:"3.1.0",info:{title:"seal-use Wrapped API",version:"0.10.0",description:`Planned HTTP contract for the seal-use wrapped backend API. `,{mode:384}),B({id:w,name:k.name,tenantId:g,tenantSlug:I,verified:u,path:Q})}async function sF(n,i){let r=await nK(`${n}/api/v1/auth/me`,{authorization:`Bearer ${i}`}),o=u$(r.data);return{user:u$(o.user??r.user),tenant:u$(o.tenant??r.tenant)}}async function nK(n,i={}){let r=await fetch(n,{headers:i}),o=await r.text();if(!r.ok)throw Error(`${r.status} ${o}`);let t=JSON.parse(o);return u$(t)}function u$(n){return n&&typeof n==="object"&&!Array.isArray(n)?n:{}}function At(n){return typeof n==="string"&&n?n:void 0}async function kL(n,i){let r=await Hv(n),o=Xu(r.sealUrl,r.token),t=await pi(o);Yv(r.corpId,t.tenant);let u=await Rr(o,{note:i});B({tenant:{id:t.tenant.id,name:t.tenant.name,tenantSlug:t.tenant.tenantSlug,corpId:r.corpId},user:{id:t.user.id,name:t.user.name,providerUserId:t.user.providerUserId,isAdmin:t.user.isAdmin},delegation:u,expiresIn:r.expiresIn})}async function dL(n,i,r,o,t){if(n==="list"){await X("seal_delegation_list",r,o,{},J(t.options));return}if(n==="create"){let u=D(t.options.note)??(i?[i,...t.command.slice(2)].join(" "):void 0);await X("seal_delegation_create",r,o,{note:u},J(t.options));return}if(n==="revoke"){let u=i??D(t.options.tokenId);if(!u)throw Error("Usage: seal-use delegation revoke <tokenId>");await X("seal_delegation_revoke",r,o,{tokenId:u},J(t.options));return}throw Error(`Unknown delegation command: ${n??""}. Run 'seal-use help' for available commands.`)}import{readFileSync as iK}from"node:fs";async function NL(n,i,r,o,t,u){let e=n==="hosecloud"||!n,l=n==="hosecloud"?i:n,$=n==="hosecloud"?r:i;if(!e&&n!=="hosecloud")throw Error(`Unknown deploy target: ${n??""}. Currently supported: hosecloud`);if(l==="requirements"){await X("seal_deploy_hosecloud_requirements",o,t,{},J(u.options));return}if(l==="list"){await X("seal_deploy_hosecloud_list",o,t,{},J(u.options));return}if(l==="get"){let I=$??D(u.options.signKey)??D(u.options["sign-key"]);if(!I)throw Error("Usage: seal-use deploy hosecloud get <sign-key>");await X("seal_deploy_hosecloud_get",o,t,{signKey:I},J(u.options));return}if(l==="status"){await X("seal_deploy_hosecloud_status",o,t,{},J(u.options));return}if(l==="configure"){let I=D(u.options.input),g=I?JSON.parse(iK(I,"utf8")):ri(u.json);if(!g||Object.keys(g).length===0)throw Error("Usage: seal-use deploy hosecloud configure --json '{...}' or --input <file>");await X("seal_deploy_hosecloud_configure",o,t,g,J(u.options));return}if(l==="sync"){let I=$??D(u.options.signKey)??D(u.options["sign-key"]);if(!I)throw Error("Usage: seal-use deploy hosecloud sync <sign-key>");await X("seal_deploy_hosecloud_sync",o,t,{signKey:I},J(u.options));return}throw Error(`Unknown deploy hosecloud action: ${l??""}. Available: requirements, list, get, status, configure, sync.`)}import{createServer as eK}from"node:http";import{URL as rK}from"node:url";var LL={openapi:"3.1.0",info:{title:"seal-use Wrapped API",version:"0.10.1",description:`Planned HTTP contract for the seal-use wrapped backend API.
These endpoints describe the intended stable API for frontend developers and agents once These endpoints describe the intended stable API for frontend developers and agents once
the HTTP adapter is implemented. the HTTP adapter is implemented.
@@ -218,13 +218,13 @@ selection, source authentication, response compaction, and diagnostics-friendly
`,{mode:384}),I$(b$(n),`started pid=${o.pid}`),{started:!0,...ar(n)}}function TL(n,i={}){let r=g$(n),o=_4(r);if(!o||!qL(o,n.appRoot))return $$(r,{force:!0}),i.quiet?void 0:{stopped:!1,reason:"not running"};return process.kill(o,"SIGTERM"),$$(r,{force:!0}),I$(b$(n),`stop requested pid=${o}`),i.quiet?void 0:{stopped:!0,pid:o}}function qL(n,i){if(!wK(n))return!1;try{let r=vK("ps",["-p",String(n),"-o","command="],{encoding:"utf8"});return(r.includes(i)||r.includes("seal-use")||r.includes("src/cli.ts"))&&r.includes("service")&&r.includes("run")}catch{return!1}}function wK(n){try{return process.kill(n,0),!0}catch{return!1}}function g$(n){return VL(n.stateDir,"service.pid")}function b$(n){return VL(n.stateDir,"service.log")}function _4(n){if(!$K(n))return;let i=Number(gK(n,"utf8").trim());return Number.isInteger(i)&&i>0?i:void 0}function EL(n){IK(n,{recursive:!0,mode:448})}function I$(n,i){E4(n,`${new Date().toISOString()} ${i} `,{mode:384}),I$(b$(n),`started pid=${o.pid}`),{started:!0,...ar(n)}}function TL(n,i={}){let r=g$(n),o=_4(r);if(!o||!qL(o,n.appRoot))return $$(r,{force:!0}),i.quiet?void 0:{stopped:!1,reason:"not running"};return process.kill(o,"SIGTERM"),$$(r,{force:!0}),I$(b$(n),`stop requested pid=${o}`),i.quiet?void 0:{stopped:!0,pid:o}}function qL(n,i){if(!wK(n))return!1;try{let r=vK("ps",["-p",String(n),"-o","command="],{encoding:"utf8"});return(r.includes(i)||r.includes("seal-use")||r.includes("src/cli.ts"))&&r.includes("service")&&r.includes("run")}catch{return!1}}function wK(n){try{return process.kill(n,0),!0}catch{return!1}}function g$(n){return VL(n.stateDir,"service.pid")}function b$(n){return VL(n.stateDir,"service.log")}function _4(n){if(!$K(n))return;let i=Number(gK(n,"utf8").trim());return Number.isInteger(i)&&i>0?i:void 0}function EL(n){IK(n,{recursive:!0,mode:448})}function I$(n,i){E4(n,`${new Date().toISOString()} ${i}
`,{flag:"a",mode:384})}var Z4=cK(fK(),".config","seal-use");async function _L(n,i){let r=await _t(n,{appRoot:i.appRoot,entryFile:i.entryFile,stateDir:Z4,version:m,launcher:i.launcher});if(r!==void 0)B(r)}import{existsSync as UK,readFileSync as ZL}from"node:fs";async function ML(n,i,r,o,t){if(n==="batch-records"||n==="records"){let u=i??D(t.options.batchId)??D(t.options["batch-id"]);if(!u)throw Error("Usage: seal-use simulation batch-records <batchId>");await X("seal_simulation_batch_records_get",r,o,{batchId:u,query:D(t.options.query)},J(t.options));return}if(n==="create"||n==="run"){let u=D(t.options.mode)??D(t.options.sourceSystem)??D(t.options["source-system"])??"hosecloud",e=u==="material-pack"?"material_pack":u,l=D(t.options.schemaConfig)??D(t.options["schema-config"]),$=l?JSON.parse(ZL(l,"utf8")):void 0,I=D(t.options.input),g=I?JSON.parse(ZL(I,"utf8")):ri(t.json),b=D(t.options.packageId)??D(t.options["package-id"]),w=qn(t.options.packageIds)??qn(t.options["package-ids"])??(b?[b]:void 0),f=qn(t.options.flowIds)??qn(t.options["flow-ids"])??qn(t.options.documentSn)??qn(t.options["document-sn"]),c=D(t.options.signKey)??D(t.options["sign-key"])??D(t.options.integration);await X("seal_simulation_batch_create",r,o,{mode:e,sourceSystem:e,flowIds:f,documentSn:f,rejectNodeName:D(t.options.rejectNode)??D(t.options["reject-node"])??null,thinkingDepthOverride:D(t.options.thinkingDepth)??D(t.options["thinking-depth"]),skipInvoiceGeneration:_(t.options.skipInvoiceGeneration)??_(t.options["skip-invoice-generation"]),skipExpenseExtraction:_(t.options.skipExpenseExtraction)??_(t.options["skip-expense-extraction"]),disableAttachmentCache:_(t.options.disableAttachmentCache)??_(t.options["disable-attachment-cache"]),signKey:c,packageIds:w,packageId:b,templateId:D(t.options.templateId)??D(t.options["template-id"]),schemaConfig:$,requestIds:qn(t.options.requestIds)??qn(t.options["request-ids"]),workflowTypeId:D(t.options.workflowTypeId)??D(t.options["workflow-type-id"]),flowStatusList:qn(t.options.flowStatusList)?.map(Number)??qn(t.options["flow-status-list"])?.map(Number),businessCodes:qn(t.options.businessCodes)??qn(t.options["business-codes"]),documentType:D(t.options.documentType)??D(t.options["document-type"]),startTime:ln(t.options.startTime)??ln(t.options["start-time"]),endTime:ln(t.options.endTime)??ln(t.options["end-time"]),status:qn(t.options.status),limit:ln(t.options.limit),rawParams:g},J(t.options));return}if(n==="wait"){let u=i??D(t.options.batchId)??D(t.options["batch-id"]);if(!u)throw Error("Usage: seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s]");await X("seal_simulation_batch_wait",r,o,{batchId:u,timeout:D(t.options.timeout),pollInterval:D(t.options.pollInterval)??D(t.options["poll-interval"])},J(t.options));return}if(n==="clean"||n==="delete"){let u=i??D(t.options.batchId)??D(t.options["batch-id"]);if(!u)throw Error("Usage: seal-use simulation clean <batchId>");await X("seal_simulation_batch_clean",r,o,{batchId:u},J(t.options));return}if(n==="specifications"){let u=i??D(t.options.integration)??D(t.options.signKey)??D(t.options["sign-key"]);await X("seal_simulation_specifications_list",r,o,{signKey:u},J(t.options));return}if(n==="list"){await X("seal_simulation_batches_list",r,o,{limit:ln(t.options.limit)},J(t.options));return}if(n==="get"){let u=i??D(t.options.batchId)??D(t.options["batch-id"]);if(!u)throw Error("Usage: seal-use simulation get <batchId>");await X("seal_simulation_batch_get",r,o,{batchId:u},J(t.options));return}if(n==="templates"){await X("seal_simulation_templates_get",r,o,{},J(t.options));return}if(n==="integrations"){await X("seal_simulation_integrations_get",r,o,{},J(t.options));return}if(n==="package-upload"){let u=i??D(t.options.file);if(!u)throw Error("Usage: seal-use simulation package-upload <材料包.zip>");if(!UK(u))throw Error(`File not found: ${u}`);await X("seal_simulation_material_package_upload",r,o,{filePath:u},J(t.options));return}throw Error(`Unknown simulation command: ${n??""}. Run 'seal-use help' for available commands.`)}import{existsSync as $y}from"node:fs";import{join as w$}from"node:path";import{existsSync as M4,mkdirSync as ry,rmSync as WK,writeFileSync as JK}from"node:fs";import{homedir as oy}from"node:os";import{dirname as XK,join as z4}from"node:path";var zL=`--- `,{flag:"a",mode:384})}var Z4=cK(fK(),".config","seal-use");async function _L(n,i){let r=await _t(n,{appRoot:i.appRoot,entryFile:i.entryFile,stateDir:Z4,version:m,launcher:i.launcher});if(r!==void 0)B(r)}import{existsSync as UK,readFileSync as ZL}from"node:fs";async function ML(n,i,r,o,t){if(n==="batch-records"||n==="records"){let u=i??D(t.options.batchId)??D(t.options["batch-id"]);if(!u)throw Error("Usage: seal-use simulation batch-records <batchId>");await X("seal_simulation_batch_records_get",r,o,{batchId:u,query:D(t.options.query)},J(t.options));return}if(n==="create"||n==="run"){let u=D(t.options.mode)??D(t.options.sourceSystem)??D(t.options["source-system"])??"hosecloud",e=u==="material-pack"?"material_pack":u,l=D(t.options.schemaConfig)??D(t.options["schema-config"]),$=l?JSON.parse(ZL(l,"utf8")):void 0,I=D(t.options.input),g=I?JSON.parse(ZL(I,"utf8")):ri(t.json),b=D(t.options.packageId)??D(t.options["package-id"]),w=qn(t.options.packageIds)??qn(t.options["package-ids"])??(b?[b]:void 0),f=qn(t.options.flowIds)??qn(t.options["flow-ids"])??qn(t.options.documentSn)??qn(t.options["document-sn"]),c=D(t.options.signKey)??D(t.options["sign-key"])??D(t.options.integration);await X("seal_simulation_batch_create",r,o,{mode:e,sourceSystem:e,flowIds:f,documentSn:f,rejectNodeName:D(t.options.rejectNode)??D(t.options["reject-node"])??null,thinkingDepthOverride:D(t.options.thinkingDepth)??D(t.options["thinking-depth"]),skipInvoiceGeneration:_(t.options.skipInvoiceGeneration)??_(t.options["skip-invoice-generation"]),skipExpenseExtraction:_(t.options.skipExpenseExtraction)??_(t.options["skip-expense-extraction"]),disableAttachmentCache:_(t.options.disableAttachmentCache)??_(t.options["disable-attachment-cache"]),signKey:c,packageIds:w,packageId:b,templateId:D(t.options.templateId)??D(t.options["template-id"]),schemaConfig:$,requestIds:qn(t.options.requestIds)??qn(t.options["request-ids"]),workflowTypeId:D(t.options.workflowTypeId)??D(t.options["workflow-type-id"]),flowStatusList:qn(t.options.flowStatusList)?.map(Number)??qn(t.options["flow-status-list"])?.map(Number),businessCodes:qn(t.options.businessCodes)??qn(t.options["business-codes"]),documentType:D(t.options.documentType)??D(t.options["document-type"]),startTime:ln(t.options.startTime)??ln(t.options["start-time"]),endTime:ln(t.options.endTime)??ln(t.options["end-time"]),status:qn(t.options.status),limit:ln(t.options.limit),rawParams:g},J(t.options));return}if(n==="wait"){let u=i??D(t.options.batchId)??D(t.options["batch-id"]);if(!u)throw Error("Usage: seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s]");await X("seal_simulation_batch_wait",r,o,{batchId:u,timeout:D(t.options.timeout),pollInterval:D(t.options.pollInterval)??D(t.options["poll-interval"])},J(t.options));return}if(n==="clean"||n==="delete"){let u=i??D(t.options.batchId)??D(t.options["batch-id"]);if(!u)throw Error("Usage: seal-use simulation clean <batchId>");await X("seal_simulation_batch_clean",r,o,{batchId:u},J(t.options));return}if(n==="specifications"){let u=i??D(t.options.integration)??D(t.options.signKey)??D(t.options["sign-key"]);await X("seal_simulation_specifications_list",r,o,{signKey:u},J(t.options));return}if(n==="list"){await X("seal_simulation_batches_list",r,o,{limit:ln(t.options.limit)},J(t.options));return}if(n==="get"){let u=i??D(t.options.batchId)??D(t.options["batch-id"]);if(!u)throw Error("Usage: seal-use simulation get <batchId>");await X("seal_simulation_batch_get",r,o,{batchId:u},J(t.options));return}if(n==="templates"){await X("seal_simulation_templates_get",r,o,{},J(t.options));return}if(n==="integrations"){await X("seal_simulation_integrations_get",r,o,{},J(t.options));return}if(n==="package-upload"){let u=i??D(t.options.file);if(!u)throw Error("Usage: seal-use simulation package-upload <材料包.zip>");if(!UK(u))throw Error(`File not found: ${u}`);await X("seal_simulation_material_package_upload",r,o,{filePath:u},J(t.options));return}throw Error(`Unknown simulation command: ${n??""}. Run 'seal-use help' for available commands.`)}import{existsSync as $y}from"node:fs";import{join as w$}from"node:path";import{existsSync as M4,mkdirSync as ry,rmSync as WK,writeFileSync as JK}from"node:fs";import{homedir as oy}from"node:os";import{dirname as XK,join as z4}from"node:path";var zL=`---
name: seal-use name: seal-use
description: "v0.10.0: Use for Seal Use first-time enterprise onboarding, Hose/合思 or Seal-native authentication, assistance links and browser cURL intake, plus tenant approval operations, diagnosis, simulation, rules, users, configuration, and search." description: "v0.10.1: 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: metadata:
version: 0.10.0 version: 0.10.1
short-description: Seal tenant and Hose approval automation (v0.10.0) short-description: Seal tenant and Hose approval automation (v0.10.1)
--- ---
# Seal Use (v0.10.0) # Seal Use (v0.10.1)
Use the \`seal_cli\` MCP tool when it is available; pass the command string as its \`command\` argument. If MCP is unavailable, fall back to the global \`seal-use\` CLI. This skill is a routing layer for agents: keep this file short, choose the right command, and read a focused reference only when the task needs detail. Use the \`seal_cli\` MCP tool when it is available; pass the command string as its \`command\` argument. If MCP is unavailable, fall back to the global \`seal-use\` CLI. This skill is a routing layer for agents: keep this file short, choose the right command, and read a focused reference only when the task needs detail.
@@ -1530,7 +1530,7 @@ seal-use corps hose-staffs --json '{
\`\`\` \`\`\`
* 直接使用指定 ID 完成接入并进行连通性验证。 * 直接使用指定 ID 完成接入并进行连通性验证。
`;var uy={"SKILL.md":zL,"agents/openai.yaml":CL,"references/rule-lightweight.md":RL,"references/approval-bad-cases.md":hL,"references/cli.md":mL,"references/approval-run-lightweight.md":xL,"references/approval-attachment-trace.md":aL,"references/customer-feedback-rule-remediation.md":sL,"references/enterprise-onboarding.md":ny,"references/hose-enterprise-auth.md":iy,"references/hose-enterprise-init.md":ty};function ey(){return uy["SKILL.md"]||""}function zu(){return z4(oy(),".agents","skills","seal-use")}function ly(){return z4(oy(),".agents","skills","seal-home")}function vy(){let n=ly();if(M4(n))try{return WK(n,{recursive:!0,force:!0}),!0}catch{return!1}return!1}function C4(n=zu()){vy(),ry(n,{recursive:!0});let i=[];for(let[r,o]of Object.entries(uy)){let t=z4(n,r);ry(XK(t),{recursive:!0}),JK(t,o,"utf8"),i.push(r)}return{targetDir:n,files:i}}function R4(){let n=ly(),i=zu(),r=M4(n),o=M4(i);if(r||o)return vy(),C4(i),{synced:!0,targetDir:i};return{synced:!1}}function Iy(n,i,r){if(n==="dump"||n==="cat"||n==="show"){process.stdout.write(`${ey()} `;var uy={"SKILL.md":zL,"agents/openai.yaml":CL,"references/rule-lightweight.md":RL,"references/approval-bad-cases.md":hL,"references/cli.md":mL,"references/approval-run-lightweight.md":xL,"references/approval-attachment-trace.md":aL,"references/customer-feedback-rule-remediation.md":sL,"references/enterprise-onboarding.md":ny,"references/hose-enterprise-auth.md":iy,"references/hose-enterprise-init.md":ty};function ey(){return uy["SKILL.md"]||""}function zu(){return z4(oy(),".agents","skills","seal-use")}function ly(){return z4(oy(),".agents","skills","seal-home")}function vy(){let n=ly();if(M4(n))try{return WK(n,{recursive:!0,force:!0}),!0}catch{return!1}return!1}function C4(n=zu()){vy(),ry(n,{recursive:!0});let i=[];for(let[r,o]of Object.entries(uy)){let t=z4(n,r);ry(XK(t),{recursive:!0}),JK(t,o,"utf8"),i.push(r)}return{targetDir:n,files:i}}function R4(){let n=ly(),i=zu(),r=M4(n),o=M4(i);if(r||o)return vy(),C4(i),{synced:!0,targetDir:i};return{synced:!1}}function Iy(n,i,r){if(n==="dump"||n==="cat"||n==="show"){process.stdout.write(`${ey()}
`);return}if(n==="install"||n==="init"||n==="sync"){let o=_(r.options.local)||_(r.options.workspace),t=D(r.options.dir)??D(r.options.target)??i,u=t?t:o?w$(process.cwd(),".agents","skills","seal-use"):zu(),e=C4(u);B({installed:!0,targetDir:e.targetDir,fileCount:e.files.length,files:e.files});return}if(n==="status"||n==="get"||!n){let o=zu(),t=w$(process.cwd(),".agents","skills","seal-use");B({global:{dir:o,installed:$y(w$(o,"SKILL.md"))},local:{dir:t,installed:$y(w$(t,"SKILL.md"))}});return}throw Error(`Unknown skill command: ${n}. Run 'seal-use help' for available commands.`)}async function gy(n,i){if(n==="config"){B(await xr(i));return}throw Error(`Unknown source command: ${n??""}. Run 'seal-use help' for available commands.`)}async function by(n,i,r,o){if(!n)throw Error("Usage: seal-use tool <toolName> [--json '{...}']");await X(n,i,r,ri(o.json),J(o.options))}function wy(){B(Vu.map((n)=>({name:n.name,description:n.description})))}import{chmodSync as HK,mkdirSync as YK,renameSync as h4,rmSync as PK,unlinkSync as Sy,writeFileSync as fy}from"node:fs";import{dirname as pK,join as cy}from"node:path";import{spawnSync as Zt}from"node:child_process";function f$(n=process.execPath,i=import.meta.url){if(i.includes("/$bunfs/")||i.includes("\\$bunfs\\"))return!0;let r=n.toLowerCase().replace(/\\/g,"/");return!r.endsWith("/bun")&&!r.endsWith("/bun.exe")&&!r.endsWith("/node")&&!r.endsWith("/node.exe")}var Ay="yunyingk/seal-home",sr="yunyingk/seal-home";var QK="SEAL_USE_GITHUB_REPO",FK="SEAL_HOME_GITHUB_REPO";async function Oy(n,i={}){let r={appRoot:n.appRoot,entryFile:n.entryFile,stateDir:Z4,version:m,launcher:n.launcher},o=i.repo||process.env[QK]?.trim()||process.env[FK]?.trim()||Ay,t=i.targetVersion?.trim(),u=t&&t.toLowerCase()!=="latest"?t:void 0;if(u){let G=u.replace(/^v/,""),N=ky(G,m);if(N<0){B({updated:!1,currentVersion:m,targetVersion:G,mode:f$()?"binary":"source",message:`Cannot downgrade seal-use from v${m} to older version v${G}. Updates must be forward-only.`});return}if(N===0&&!i.force){B({updated:!1,currentVersion:m,targetVersion:G,mode:f$()?"binary":"source",message:`seal-use is already at version v${m}. Use --force to reinstall.`});return}}if(i.changelogOnly){let G=await m4(o,i.limit??10);B({currentVersion:m,totalQueried:G.length,releases:G.map((N)=>({version:N.version,tagName:N.tagName,publishedAt:N.publishedAt,author:N.author,releaseNotes:N.notes,releaseUrl:N.htmlUrl,isCurrent:N.version===m,isNewer:Cu(N.version,m)}))});return}if(!f$()){if(i.checkOnly){let N=await m4(o,30),E=N[0],x=E?.version??m,yn=N.find((un)=>un.version===m),Wn=Cu(x,m),On=N.filter((un)=>Cu(un.version,m));B({updated:!1,updateAvailable:Wn,currentVersion:m,currentVersionPublishedAt:yn?.publishedAt,latestVersion:x,latestVersionPublishedAt:E?.publishedAt,behindCount:On.length,pendingReleases:On.map((un)=>({version:un.version,tagName:un.tagName,publishedAt:un.publishedAt,author:un.author,releaseNotes:un.notes,releaseUrl:un.htmlUrl})),releaseNotes:E?.notes??"",releaseUrl:E?.htmlUrl??"",mode:"source",message:"Running in source development mode. Run 'seal-use update' to git pull & bun install."});return}let G=ar(r).running;if(G)await _t("stop",r);try{Dy("git",["-C",n.appRoot,"pull","--ff-only"])}catch(N){console.error(`git pull skipped: ${N instanceof Error?N.message:String(N)}`)}if(Dy("bun",["install"],{cwd:n.appRoot}),G)await _t("start",r);B({updated:!0,serviceRestarted:G,version:m,mode:"source"});return}let e=KK(),l=BK(),$=await m4(o,30),I=u?$.find((G)=>G.version===u||G.tagName===u||G.tagName===`v${u}`)??await Uy(o,u):$[0]??await Uy(o);if(!I){B({updated:!1,currentVersion:m,mode:"binary",message:`Failed to query releases from repository '${o}'`});return}let g=I.version,b=$.find((G)=>G.version===m),w=Cu(g,m),f=w||Boolean(i.force),c=$.filter((G)=>Cu(G.version,m));if(i.checkOnly){B({updated:!1,updateAvailable:w,currentVersion:m,currentVersionPublishedAt:b?.publishedAt,latestVersion:g,latestVersionPublishedAt:I.publishedAt,behindCount:c.length,pendingReleases:c.map((G)=>({version:G.version,tagName:G.tagName,publishedAt:G.publishedAt,author:G.author,releaseNotes:G.notes,releaseUrl:G.htmlUrl})),releaseNotes:I.notes,releaseUrl:I.htmlUrl,mode:"binary"});return}if(!f){B({updated:!1,currentVersion:m,currentVersionPublishedAt:b?.publishedAt,latestVersion:g,latestVersionPublishedAt:I.publishedAt,mode:"binary",message:`seal-use is already up to date (v${m})`});return}let S=TK(I.assets,e,l);if(!S)throw Error(`No compatible binary found for ${e}-${l} in release v${g}. Available assets: ${I.assets.map((G)=>G.name).join(", ")}`);let k=ar(r).running;if(k)await _t("stop",r);let d=process.execPath,Q=pK(d),Y=cy(Q,`.tmp-update-${Date.now()}`);YK(Y,{recursive:!0});try{let G=cy(Y,S.name);await VK(S.downloadUrl,G,I.tagName,S.name);let N=G;if(S.name.endsWith(".tar.gz")||S.name.endsWith(".tgz"))N=qK(G,Y,e);else if(S.name.endsWith(".zip"))N=EK(G,Y,e);if(HK(N,493),process.platform==="darwin")try{Zt("/usr/bin/codesign",["--remove-signature",N],{stdio:"ignore"}),Zt("/usr Line truncated `);return}if(n==="install"||n==="init"||n==="sync"){let o=_(r.options.local)||_(r.options.workspace),t=D(r.options.dir)??D(r.options.target)??i,u=t?t:o?w$(process.cwd(),".agents","skills","seal-use"):zu(),e=C4(u);B({installed:!0,targetDir:e.targetDir,fileCount:e.files.length,files:e.files});return}if(n==="status"||n==="get"||!n){let o=zu(),t=w$(process.cwd(),".agents","skills","seal-use");B({global:{dir:o,installed:$y(w$(o,"SKILL.md"))},local:{dir:t,installed:$y(w$(t,"SKILL.md"))}});return}throw Error(`Unknown skill command: ${n}. Run 'seal-use help' for available commands.`)}async function gy(n,i){if(n==="config"){B(await xr(i));return}throw Error(`Unknown source command: ${n??""}. Run 'seal-use help' for available commands.`)}async function by(n,i,r,o){if(!n)throw Error("Usage: seal-use tool <toolName> [--json '{...}']");await X(n,i,r,ri(o.json),J(o.options))}function wy(){B(Vu.map((n)=>({name:n.name,description:n.description})))}import{chmodSync as HK,mkdirSync as YK,renameSync as h4,rmSync as PK,unlinkSync as Sy,writeFileSync as fy}from"node:fs";import{dirname as pK,join as cy}from"node:path";import{spawnSync as Zt}from"node:child_process";function f$(n=process.execPath,i=import.meta.url){if(i.includes("/$bunfs/")||i.includes("\\$bunfs\\"))return!0;let r=n.toLowerCase().replace(/\\/g,"/");return!r.endsWith("/bun")&&!r.endsWith("/bun.exe")&&!r.endsWith("/node")&&!r.endsWith("/node.exe")}var Ay="yunyingk/seal-use",sr="yunyingk/seal-home";var QK="SEAL_USE_GITHUB_REPO",FK="SEAL_HOME_GITHUB_REPO";async function Oy(n,i={}){let r={appRoot:n.appRoot,entryFile:n.entryFile,stateDir:Z4,version:m,launcher:n.launcher},o=i.repo||process.env[QK]?.trim()||process.env[FK]?.trim()||Ay,t=i.targetVersion?.trim(),u=t&&t.toLowerCase()!=="latest"?t:void 0;if(u){let G=u.replace(/^v/,""),N=ky(G,m);if(N<0){B({updated:!1,currentVersion:m,targetVersion:G,mode:f$()?"binary":"source",message:`Cannot downgrade seal-use from v${m} to older version v${G}. Updates must be forward-only.`});return}if(N===0&&!i.force){B({updated:!1,currentVersion:m,targetVersion:G,mode:f$()?"binary":"source",message:`seal-use is already at version v${m}. Use --force to reinstall.`});return}}if(i.changelogOnly){let G=await m4(o,i.limit??10);B({currentVersion:m,totalQueried:G.length,releases:G.map((N)=>({version:N.version,tagName:N.tagName,publishedAt:N.publishedAt,author:N.author,releaseNotes:N.notes,releaseUrl:N.htmlUrl,isCurrent:N.version===m,isNewer:Cu(N.version,m)}))});return}if(!f$()){if(i.checkOnly){let N=await m4(o,30),E=N[0],x=E?.version??m,yn=N.find((un)=>un.version===m),Wn=Cu(x,m),On=N.filter((un)=>Cu(un.version,m));B({updated:!1,updateAvailable:Wn,currentVersion:m,currentVersionPublishedAt:yn?.publishedAt,latestVersion:x,latestVersionPublishedAt:E?.publishedAt,behindCount:On.length,pendingReleases:On.map((un)=>({version:un.version,tagName:un.tagName,publishedAt:un.publishedAt,author:un.author,releaseNotes:un.notes,releaseUrl:un.htmlUrl})),releaseNotes:E?.notes??"",releaseUrl:E?.htmlUrl??"",mode:"source",message:"Running in source development mode. Run 'seal-use update' to git pull & bun install."});return}let G=ar(r).running;if(G)await _t("stop",r);try{Dy("git",["-C",n.appRoot,"pull","--ff-only"])}catch(N){console.error(`git pull skipped: ${N instanceof Error?N.message:String(N)}`)}if(Dy("bun",["install"],{cwd:n.appRoot}),G)await _t("start",r);B({updated:!0,serviceRestarted:G,version:m,mode:"source"});return}let e=KK(),l=BK(),$=await m4(o,30),I=u?$.find((G)=>G.version===u||G.tagName===u||G.tagName===`v${u}`)??await Uy(o,u):$[0]??await Uy(o);if(!I){B({updated:!1,currentVersion:m,mode:"binary",message:`Failed to query releases from repository '${o}'`});return}let g=I.version,b=$.find((G)=>G.version===m),w=Cu(g,m),f=w||Boolean(i.force),c=$.filter((G)=>Cu(G.version,m));if(i.checkOnly){B({updated:!1,updateAvailable:w,currentVersion:m,currentVersionPublishedAt:b?.publishedAt,latestVersion:g,latestVersionPublishedAt:I.publishedAt,behindCount:c.length,pendingReleases:c.map((G)=>({version:G.version,tagName:G.tagName,publishedAt:G.publishedAt,author:G.author,releaseNotes:G.notes,releaseUrl:G.htmlUrl})),releaseNotes:I.notes,releaseUrl:I.htmlUrl,mode:"binary"});return}if(!f){B({updated:!1,currentVersion:m,currentVersionPublishedAt:b?.publishedAt,latestVersion:g,latestVersionPublishedAt:I.publishedAt,mode:"binary",message:`seal-use is already up to date (v${m})`});return}let S=TK(I.assets,e,l);if(!S)throw Error(`No compatible binary found for ${e}-${l} in release v${g}. Available assets: ${I.assets.map((G)=>G.name).join(", ")}`);let k=ar(r).running;if(k)await _t("stop",r);let d=process.execPath,Q=pK(d),Y=cy(Q,`.tmp-update-${Date.now()}`);YK(Y,{recursive:!0});try{let G=cy(Y,S.name);await VK(S.downloadUrl,G,I.tagName,S.name);let N=G;if(S.name.endsWith(".tar.gz")||S.name.endsWith(".tgz"))N=qK(G,Y,e);else if(S.name.endsWith(".zip"))N=EK(G,Y,e);if(HK(N,493),process.platform==="darwin")try{Zt("/usr/bin/codesign",["--remove-signature",N],{stdio:"ignore"}),Zt("/usr/ Line truncated
`)}catch{}}async function VK(n,i,r,o){let t=[],u=r?r.startsWith("v")?r:`v${r}`:void 0,e=o||n.split("/").pop()||"";if(u&&e)t.push(`https://git.ying-qing.cn/gitea/seal-home/releases/download/${u}/${e}`);if(n.startsWith("https://git.ying-qing.cn"))t.push(n);if(u&&e){let c=`https://github.com/${Ay}/releases/download/${u}/${e}`;t.push(`https://ghfast.top/${c}`),t.push(`https://gh.ddlc.top/${c}`),t.push(c)}else if(n.includes("github.com"))t.push(`https://ghfast.top/${n}`),t.push(`https://gh.ddlc.top/${n}`),t.push(n);else t.push(n);let l=Array.from(new Set(t)),$,I=6000,g=6000,b=307200,w=1e4,f=180000;for(let c=0;c<l.length;c++){let S=l[c],k=new AbortController,d="",Q=(E)=>{d=E;try{k.abort()}catch{}},Y=setTimeout(()=>{Q("Connection timed out (no response headers within 6s)")},I),G,N;try{c$(`==> [${c+1}/${l.length}] Downloading via: ${S}`);let E=await fetch(S,{signal:k.signal});if(Y)clearTimeout(Y),Y=void 0;if(!E.ok)throw Error(`HTTP ${E.status} ${E.statusText}`);G=setTimeout(()=>{Q("Overall download time exceeded 3 minutes")},f);let x=Number(E.headers.get("content-length"))||0,yn=E.body?.getReader();if(!yn){let wi=Buffer.from(await E.arrayBuffer());if(wi.length<1000)throw Error(`Downloaded content is suspiciously small (${wi.length} bytes)`);fy(i,wi),c$(`✓ Download succeeded (${(wi.length/1024/1024).toFixed(1)} MB)`);return}let Wn=[],On=0,un=0;N=setTimeout(()=>{if(On<b){let wi=(On/1024).toFixed(1);Q(`Initial transfer too slow (${wi} KB < 300 KB in 6s), switching mirror...`)}},g);while(!0){let wi=yn.read(),no,Wy=new Promise((D$,S$)=>{no=setTimeout(()=>{S$(Error("Data transfer stalled (no chunk received for 10s)"))},w)}),s4;try{s4=await Promise.race([wi,Wy])}finally{if(no)clearTimeout(no)}let{done:Jy,value:U$}=s4;if(Jy)break;if(U$){if(Wn.push(U$),On+=U$.length,N&&On>=b)clearTimeout(N),N=void 0;let D$=Date.now();if(D$-un>200){un=D$;let S$=x?Math.round(On/x*100):0,Xy=(On/1048576).toFixed(1),Hy=x?(x/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${S$}% (${Xy} / ${Hy} MB)...`)}catch{}}}}try{process.stderr.write(` `)}catch{}}async function VK(n,i,r,o){let t=[],u=r?r.startsWith("v")?r:`v${r}`:void 0,e=o||n.split("/").pop()||"";if(u&&e)t.push(`https://git.ying-qing.cn/gitea/seal-home/releases/download/${u}/${e}`);if(n.startsWith("https://git.ying-qing.cn"))t.push(n);if(u&&e){let c=`https://github.com/${Ay}/releases/download/${u}/${e}`;t.push(`https://ghfast.top/${c}`),t.push(`https://gh.ddlc.top/${c}`),t.push(c)}else if(n.includes("github.com"))t.push(`https://ghfast.top/${n}`),t.push(`https://gh.ddlc.top/${n}`),t.push(n);else t.push(n);let l=Array.from(new Set(t)),$,I=6000,g=6000,b=307200,w=1e4,f=180000;for(let c=0;c<l.length;c++){let S=l[c],k=new AbortController,d="",Q=(E)=>{d=E;try{k.abort()}catch{}},Y=setTimeout(()=>{Q("Connection timed out (no response headers within 6s)")},I),G,N;try{c$(`==> [${c+1}/${l.length}] Downloading via: ${S}`);let E=await fetch(S,{signal:k.signal});if(Y)clearTimeout(Y),Y=void 0;if(!E.ok)throw Error(`HTTP ${E.status} ${E.statusText}`);G=setTimeout(()=>{Q("Overall download time exceeded 3 minutes")},f);let x=Number(E.headers.get("content-length"))||0,yn=E.body?.getReader();if(!yn){let wi=Buffer.from(await E.arrayBuffer());if(wi.length<1000)throw Error(`Downloaded content is suspiciously small (${wi.length} bytes)`);fy(i,wi),c$(`✓ Download succeeded (${(wi.length/1024/1024).toFixed(1)} MB)`);return}let Wn=[],On=0,un=0;N=setTimeout(()=>{if(On<b){let wi=(On/1024).toFixed(1);Q(`Initial transfer too slow (${wi} KB < 300 KB in 6s), switching mirror...`)}},g);while(!0){let wi=yn.read(),no,Wy=new Promise((D$,S$)=>{no=setTimeout(()=>{S$(Error("Data transfer stalled (no chunk received for 10s)"))},w)}),s4;try{s4=await Promise.race([wi,Wy])}finally{if(no)clearTimeout(no)}let{done:Jy,value:U$}=s4;if(Jy)break;if(U$){if(Wn.push(U$),On+=U$.length,N&&On>=b)clearTimeout(N),N=void 0;let D$=Date.now();if(D$-un>200){un=D$;let S$=x?Math.round(On/x*100):0,Xy=(On/1048576).toFixed(1),Hy=x?(x/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${S$}% (${Xy} / ${Hy} MB)...`)}catch{}}}}try{process.stderr.write(`
`)}catch{}let Ot=Buffer.concat(Wn);if(Ot.length<1000)throw Error(`Downloaded content is suspiciously small (${Ot.length} bytes)`);fy(i,Ot),c$(`✓ Download completed successfully (${(Ot.length/1024/1024).toFixed(1)} MB)`);return}catch(E){if(Y)clearTimeout(Y);if(N)clearTimeout(N);if(G)clearTimeout(G);let x=d||(E instanceof Error?E.message:String(E));$=Error(x),c$(` `)}catch{}let Ot=Buffer.concat(Wn);if(Ot.length<1000)throw Error(`Downloaded content is suspiciously small (${Ot.length} bytes)`);fy(i,Ot),c$(`✓ Download completed successfully (${(Ot.length/1024/1024).toFixed(1)} MB)`);return}catch(E){if(Y)clearTimeout(Y);if(N)clearTimeout(N);if(G)clearTimeout(G);let x=d||(E instanceof Error?E.message:String(E));$=Error(x),c$(`
↳ Mirror failed: ${$.message}`)}finally{if(Y)clearTimeout(Y);if(N)clearTimeout(N);if(G)clearTimeout(G)}}throw Error(`Failed to download asset from all mirrors: ${$?.message}`)}function qK(n,i,r){let o=Zt("tar",["-xzf",n,"-C",i],{stdio:"pipe"});if(o.status!==0)throw Error(`Failed to extract tar archive: ${o.stderr.toString()}`);Sy(n);let t=r==="windows"?"seal-use.exe":"seal-use",u=Zt("find",[i,"-type","f"],{encoding:"utf8"}).stdout.trim().split(` ↳ Mirror failed: ${$.message}`)}finally{if(Y)clearTimeout(Y);if(N)clearTimeout(N);if(G)clearTimeout(G)}}throw Error(`Failed to download asset from all mirrors: ${$?.message}`)}function qK(n,i,r){let o=Zt("tar",["-xzf",n,"-C",i],{stdio:"pipe"});if(o.status!==0)throw Error(`Failed to extract tar archive: ${o.stderr.toString()}`);Sy(n);let t=r==="windows"?"seal-use.exe":"seal-use",u=Zt("find",[i,"-type","f"],{encoding:"utf8"}).stdout.trim().split(`
+1 -1
View File
@@ -2,7 +2,7 @@
"openapi": "3.1.0", "openapi": "3.1.0",
"info": { "info": {
"title": "seal-use Wrapped API", "title": "seal-use Wrapped API",
"version": "0.10.0", "version": "0.10.1",
"description": "Planned HTTP contract for the seal-use wrapped backend API.\n\nThese endpoints describe the intended stable API for frontend developers and agents once\nthe HTTP adapter is implemented.\nThey are not the raw downstream Seal endpoints. seal-use is responsible for enterprise\nselection, source authentication, response compaction, and diagnostics-friendly fields.\n" "description": "Planned HTTP contract for the seal-use wrapped backend API.\n\nThese endpoints describe the intended stable API for frontend developers and agents once\nthe HTTP adapter is implemented.\nThey are not the raw downstream Seal endpoints. seal-use is responsible for enterprise\nselection, source authentication, response compaction, and diagnostics-friendly fields.\n"
}, },
"servers": [ "servers": [
+1 -1
View File
@@ -1,7 +1,7 @@
openapi: 3.1.0 openapi: 3.1.0
info: info:
title: seal-use Wrapped API title: seal-use Wrapped API
version: 0.10.0 version: 0.10.1
description: | description: |
Planned HTTP contract for the seal-use wrapped backend API. Planned HTTP contract for the seal-use wrapped backend API.
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "seal-use", "name": "seal-use",
"version": "0.10.0", "version": "0.10.1",
"type": "module", "type": "module",
"module": "src/server.ts", "module": "src/server.ts",
"bin": { "bin": {
+7 -3
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
REPO="${SEAL_USE_GITHUB_REPO:-${SEAL_HOME_GITHUB_REPO:-yunyingk/seal-home}}" REPO="${SEAL_USE_GITHUB_REPO:-${SEAL_HOME_GITHUB_REPO:-yunyingk/seal-use}}"
REQ_VERSION="${SEAL_USE_VERSION:-${SEAL_HOME_VERSION:-latest}}" REQ_VERSION="${SEAL_USE_VERSION:-${SEAL_HOME_VERSION:-latest}}"
if [ "$REQ_VERSION" != "latest" ] && [[ "$REQ_VERSION" != v* ]]; then if [ "$REQ_VERSION" != "latest" ] && [[ "$REQ_VERSION" != v* ]]; then
REQ_VERSION="v${REQ_VERSION}" REQ_VERSION="v${REQ_VERSION}"
@@ -155,12 +155,14 @@ DOWNLOAD_SUCCESS=false
# Candidate mirrors # Candidate mirrors
if [ "$REQ_VERSION" = "latest" ]; then if [ "$REQ_VERSION" = "latest" ]; then
GITEA_URL="https://git.ying-qing.cn/gitea/seal-home/releases/download/latest/${ASSET_NAME}" GITEA_URL="https://git.ying-qing.cn/gitea/seal-use/releases/download/latest/${ASSET_NAME}"
GITEA_LEGACY_URL="https://git.ying-qing.cn/gitea/seal-home/releases/download/latest/${ASSET_NAME}"
GITHUB_URL="https://github.com/${REPO}/releases/latest/download/${ASSET_NAME}" GITHUB_URL="https://github.com/${REPO}/releases/latest/download/${ASSET_NAME}"
GHPROXY_URL="https://ghfast.top/https://github.com/${REPO}/releases/latest/download/${ASSET_NAME}" GHPROXY_URL="https://ghfast.top/https://github.com/${REPO}/releases/latest/download/${ASSET_NAME}"
CHECKSUM_URL="https://github.com/${REPO}/releases/latest/download/checksums.txt" CHECKSUM_URL="https://github.com/${REPO}/releases/latest/download/checksums.txt"
else else
GITEA_URL="https://git.ying-qing.cn/gitea/seal-home/releases/download/${REQ_VERSION}/${ASSET_NAME}" GITEA_URL="https://git.ying-qing.cn/gitea/seal-use/releases/download/${REQ_VERSION}/${ASSET_NAME}"
GITEA_LEGACY_URL="https://git.ying-qing.cn/gitea/seal-home/releases/download/${REQ_VERSION}/${ASSET_NAME}"
GITHUB_URL="https://github.com/${REPO}/releases/download/${REQ_VERSION}/${ASSET_NAME}" GITHUB_URL="https://github.com/${REPO}/releases/download/${REQ_VERSION}/${ASSET_NAME}"
GHPROXY_URL="https://ghfast.top/https://github.com/${REPO}/releases/download/${REQ_VERSION}/${ASSET_NAME}" GHPROXY_URL="https://ghfast.top/https://github.com/${REPO}/releases/download/${REQ_VERSION}/${ASSET_NAME}"
CHECKSUM_URL="https://github.com/${REPO}/releases/download/${REQ_VERSION}/checksums.txt" CHECKSUM_URL="https://github.com/${REPO}/releases/download/${REQ_VERSION}/checksums.txt"
@@ -172,6 +174,8 @@ MIRROR_MODE="${SEAL_USE_MIRROR:-${SEAL_HOME_MIRROR:-auto}}"
if [ "$MIRROR_MODE" = "gitea" ] || [ "$MIRROR_MODE" = "auto" ]; then if [ "$MIRROR_MODE" = "gitea" ] || [ "$MIRROR_MODE" = "auto" ]; then
if download_candidate "$GITEA_URL" "$TMP_FILE" "Gitea High-Speed Mirror"; then if download_candidate "$GITEA_URL" "$TMP_FILE" "Gitea High-Speed Mirror"; then
DOWNLOAD_SUCCESS=true DOWNLOAD_SUCCESS=true
elif download_candidate "$GITEA_LEGACY_URL" "$TMP_FILE" "Gitea High-Speed Mirror (Legacy Path)"; then
DOWNLOAD_SUCCESS=true
fi fi
fi fi
+4 -4
View File
@@ -1,12 +1,12 @@
--- ---
name: seal-use name: seal-use
description: "v0.10.0: Use for Seal Use first-time enterprise onboarding, Hose/合思 or Seal-native authentication, assistance links and browser cURL intake, plus tenant approval operations, diagnosis, simulation, rules, users, configuration, and search." description: "v0.10.1: 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: metadata:
version: 0.10.0 version: 0.10.1
short-description: Seal tenant and Hose approval automation (v0.10.0) short-description: Seal tenant and Hose approval automation (v0.10.1)
--- ---
# Seal Use (v0.10.0) # Seal Use (v0.10.1)
Use the `seal_cli` MCP tool when it is available; pass the command string as its `command` argument. If MCP is unavailable, fall back to the global `seal-use` CLI. This skill is a routing layer for agents: keep this file short, choose the right command, and read a focused reference only when the task needs detail. Use the `seal_cli` MCP tool when it is available; pass the command string as its `command` argument. If MCP is unavailable, fall back to the global `seal-use` CLI. This skill is a routing layer for agents: keep this file short, choose the right command, and read a focused reference only when the task needs detail.
+4 -4
View File
@@ -9,7 +9,7 @@ import { printJson } from "../printer.js";
import { STATE_DIR } from "./service.js"; import { STATE_DIR } from "./service.js";
import type { CliRuntime } from "../types.js"; import type { CliRuntime } from "../types.js";
const DEFAULT_GITHUB_REPO = "yunyingk/seal-home"; const DEFAULT_GITHUB_REPO = "yunyingk/seal-use";
const LEGACY_GITHUB_REPO = "yunyingk/seal-home"; const LEGACY_GITHUB_REPO = "yunyingk/seal-home";
const UPDATE_URL_ENV = "SEAL_USE_UPDATE_URL"; const UPDATE_URL_ENV = "SEAL_USE_UPDATE_URL";
const LEGACY_UPDATE_URL_ENV = "SEAL_HOME_UPDATE_URL"; const LEGACY_UPDATE_URL_ENV = "SEAL_HOME_UPDATE_URL";
@@ -316,7 +316,7 @@ async function fetchGitHubReleases(repo: string, limit = 20): Promise<GitHubRele
}; };
const urls = [ const urls = [
`https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases?per_page=${limit}`, `https://git.ying-qing.cn/api/v1/repos/gitea/seal-use/releases?per_page=${limit}`,
`https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases?per_page=${limit}`, `https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases?per_page=${limit}`,
`https://api.github.com/repos/${repo}/releases?per_page=${limit}` `https://api.github.com/repos/${repo}/releases?per_page=${limit}`
]; ];
@@ -381,13 +381,13 @@ async function fetchGitHubRelease(repo: string, targetVersion?: string): Promise
const urls = tag const urls = tag
? [ ? [
`https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases/tags/${tag}`, `https://git.ying-qing.cn/api/v1/repos/gitea/seal-use/releases/tags/${tag}`,
`https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases/tags/${tag}`, `https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases/tags/${tag}`,
`https://api.github.com/repos/${repo}/releases/tags/${tag}`, `https://api.github.com/repos/${repo}/releases/tags/${tag}`,
...(repo !== LEGACY_GITHUB_REPO ? [`https://api.github.com/repos/${LEGACY_GITHUB_REPO}/releases/tags/${tag}`] : []) ...(repo !== LEGACY_GITHUB_REPO ? [`https://api.github.com/repos/${LEGACY_GITHUB_REPO}/releases/tags/${tag}`] : [])
] ]
: [ : [
`https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases/latest`, `https://git.ying-qing.cn/api/v1/repos/gitea/seal-use/releases/latest`,
`https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases/latest`, `https://git.ying-qing.cn/api/v1/repos/gitea/seal-home/releases/latest`,
`https://api.github.com/repos/${repo}/releases/latest`, `https://api.github.com/repos/${repo}/releases/latest`,
...(repo !== LEGACY_GITHUB_REPO ? [`https://api.github.com/repos/${LEGACY_GITHUB_REPO}/releases/latest`] : []) ...(repo !== LEGACY_GITHUB_REPO ? [`https://api.github.com/repos/${LEGACY_GITHUB_REPO}/releases/latest`] : [])