Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97c59fae14 | ||
|
|
b44800c108 | ||
|
|
baa47753d3 | ||
|
|
50e4e492b4 | ||
|
|
780a4ba9c0 | ||
|
|
818f33a8e1 | ||
|
|
a760ea9572 | ||
|
|
69d5b4f130 |
No files matched your search
@@ -25,8 +25,8 @@ When developing or refactoring CLI commands under `src/cli/`:
|
||||
|
||||
## 2. Performance Contract & SWR Architecture
|
||||
|
||||
- **Sub-50ms Local Execution**:
|
||||
- Read-only discovery commands (e.g. `seal-use version`, `seal-use doctor paths`, `seal-use corps list`) MUST return in under 50ms wall clock (Bun interpreter startup is ~7ms on its own, so this leaves ~40ms for the module graph).
|
||||
- **Sub-70ms Local Execution**:
|
||||
- Read-only discovery commands (e.g. `seal-use version`, `seal-use doctor paths`, `seal-use corps list`) MUST return in under 70ms wall clock (Bun interpreter startup is ~7ms on its own, so this leaves ~60ms for the module graph).
|
||||
- Achieved by keeping `src/cli/runner.ts` free of static command-module imports: dispatch branches load their handler with `await import("./commands/<area>.js")` on demand, so `seal-use version` never loads the Excel/zip tool chain.
|
||||
- Never trigger synchronous external HTTP requests during routine discovery or inspection invocations. Measured on the maintainer's machine (2026-09): version 45ms, help 41ms, corps list 41ms, bare `bun -e` 7ms.
|
||||
- **Stale-While-Revalidate (SWR) Pattern**:
|
||||
|
||||
@@ -41,6 +41,12 @@ jobs:
|
||||
- name: Linter Plaintext Sync
|
||||
run: bun run verify:linter-plaintext
|
||||
|
||||
- name: CLI Documentation Sync
|
||||
run: bun run verify:cli-md
|
||||
|
||||
- name: Embedded Skill Sync
|
||||
run: bun run verify:embedded-skill
|
||||
|
||||
- name: Colocated Unit Tests
|
||||
run: bun test
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "seal-use",
|
||||
"version": "0.11.11",
|
||||
"version": "0.11.12",
|
||||
"description": "Seal Use tenant operations: approval-run diagnosis, minimal rule remediation, delegation links, Hose/合思 authorization, users, rules, billing, and search.",
|
||||
"author": {
|
||||
"name": "yingqing"
|
||||
|
||||
@@ -34,7 +34,7 @@ Prefer small domain functions over broad utility modules.
|
||||
- **Machine Channel (`stdout`)**: Data commands MUST output clean, parseable JSON on `stdout`. Never dump human prose, raw logs, or progress banners into `stdout`. The Agent Harness parses `stdout` directly into typed payloads.
|
||||
- **Documented exception — document-output commands**: `seal-use --help` / `seal-use help <area>` (`src/cli/printer.ts`), `seal-use doctor guide` (`src/cli/commands/doctor.ts`), and `seal-use skill dump` (`src/cli/commands/skill.ts`) intentionally write Markdown to `stdout`, because their output *is* the payload the caller redirects or reads (e.g. `seal-use doctor guide > guide.md`, `seal-use skill dump > SKILL.md`). Never add a new prose-on-stdout command outside this list: return structured JSON and put the readable rendering on `stderr` instead. `src/probe.ts` is a local developer probe script rather than a `bin` entry point, so its `[probe] …` lines are outside this contract.
|
||||
- **Guidance & Diagnostic Channel (`stderr`)**: Use `stderr` for runtime logs, network probing status, self-healing notifications, and explicit **Next-Step Command Suggestions** (e.g. `👉 Next action: seal-use deploy hosecloud sync <signKey>`).
|
||||
- **Performance Contract & SWR Architecture**: Read-only discovery and version commands (`seal-use version`, `seal-use doctor`, `seal-use corps list`) MUST execute in under 50ms wall clock (Bun startup alone is ~7ms; runner dispatch uses lazy `await import()` per command area, so the version path never loads the Excel/zip tool chain). Never block on external network I/O during routine invocations. Use the Stale-While-Revalidate (SWR) pattern: read local cache from `~/.config/seal-use/*.json` synchronously (<0.2ms), and refresh stale/missing data via detached, unref'd child processes (`triggerBackgroundUpdateCheck`, `unref()`).
|
||||
- **Performance Contract & SWR Architecture**: Read-only discovery and version commands (`seal-use version`, `seal-use doctor`, `seal-use corps list`) MUST execute in under 70ms wall clock (Bun startup alone is ~7ms; runner dispatch uses lazy `await import()` per command area, so the version path never loads the Excel/zip tool chain). Never block on external network I/O during routine invocations. Use the Stale-While-Revalidate (SWR) pattern: read local cache from `~/.config/seal-use/*.json` synchronously (<0.2ms), and refresh stale/missing data via detached, unref'd child processes (`triggerBackgroundUpdateCheck`, `unref()`).
|
||||
- **Safety Guardrail & Mutation Preview (`--dry-run`)**: All potentially destructive or state-mutating commands (e.g. `rules push/clear`, `corps sync-test`, `preference update`, `webhook add/update`) MUST support `--dry-run` returning structured JSON previews with `preview: true` and a clean diff, without executing mutations. Live execution requires explicit `--yes` or `--confirm`.
|
||||
- **Exit Code Contract**:
|
||||
- `0`: Successful execution.
|
||||
|
||||
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.11.12] - 2026-10-17
|
||||
|
||||
### Added
|
||||
- Merge pull request #251 from yunyingk/mac15/fix-architecture-review
|
||||
- Fix architecture review findings and align CLI metadata
|
||||
- Merge pull request #250 from yunyingk/mac15/refine-report-glossary-and-math-layout
|
||||
- Refine report glossary to plain business language and improve math layout
|
||||
- Merge pull request #249 from yunyingk/mac15/add-report-glossary-page
|
||||
- Add trailing terms definition appendix to report renderers
|
||||
|
||||
|
||||
## [0.11.11] - 2026-10-16
|
||||
|
||||
### Added
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ initial response within a few business days — this is a small project, not a s
|
||||
| `enterprises/*.json` (working tree) | Same, for enterprises added from a checkout | `0600` |
|
||||
| `~/.cache/seal-use/usage.json` | Per-enterprise command counts | `0600` |
|
||||
|
||||
The tool writes these `0600`; a config placed by hand can keep the `0o644` default, so
|
||||
Credential writes tighten existing files to `0600` before storing new content, including updates, overwrites, and legacy migration. A hand-placed file can retain `0o644` until the next write, so
|
||||
`seal-use doctor` reports any credential file whose mode is wider than `0600`. Real enterprise
|
||||
configs are gitignored — never commit them.
|
||||
|
||||
|
||||
+6
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "seal-use",
|
||||
"version": "0.11.11",
|
||||
"version": "0.11.12",
|
||||
"private": true,
|
||||
"description": "Seal tenant operations toolkit: approval-run diagnosis, rule remediation, Hose/合思 auth, plus a CLI and an optional MCP server.",
|
||||
"license": "MIT",
|
||||
@@ -35,7 +35,11 @@
|
||||
"generate:linter-plaintext": "bun run scripts/generate-linter-plaintext.mjs",
|
||||
"verify:linter-plaintext": "bun run scripts/check-linter-plaintext.mjs",
|
||||
"test": "bun test",
|
||||
"prepare": "git config core.hooksPath .githooks"
|
||||
"prepare": "git config core.hooksPath .githooks",
|
||||
"generate:embedded-skill": "bun run scripts/generate-embedded-skill.mjs",
|
||||
"verify:embedded-skill": "bun run scripts/check-embedded-skill.mjs",
|
||||
"generate:cli-md": "bun run scripts/generate-cli-md.mjs",
|
||||
"verify:cli-md": "bun run scripts/check-cli-md.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/server": "^2.0.0",
|
||||
|
||||
@@ -128,6 +128,11 @@ function getBuildInfo(releaseMode) {
|
||||
|
||||
async function main() {
|
||||
const startTime = Date.now();
|
||||
const generatedCliDoc = spawnSync(bun, [resolve(root, "scripts/generate-cli-md.mjs")], {
|
||||
cwd: root,
|
||||
stdio: "inherit"
|
||||
});
|
||||
if (generatedCliDoc.status !== 0) throw new Error("Failed to generate CLI documentation");
|
||||
const generatedSkill = spawnSync(bun, [resolve(root, "scripts/generate-embedded-skill.mjs")], {
|
||||
cwd: root,
|
||||
stdio: "inherit"
|
||||
|
||||
@@ -87,6 +87,10 @@ writeFileSync(skillPath, skillContent);
|
||||
console.log("✓ Updated skills/seal-use/SKILL.md");
|
||||
|
||||
|
||||
// Keep command documentation and the embedded file manifest synchronized before installation.
|
||||
execSync("bun run generate:cli-md", { cwd: ROOT, stdio: "inherit" });
|
||||
execSync("bun run generate:embedded-skill", { cwd: ROOT, stdio: "inherit" });
|
||||
|
||||
// 5. Sync to global ~/.agents/skills/seal-use/ if present
|
||||
const globalSkillDir = join(homedir(), ".agents", "skills", "seal-use");
|
||||
const legacyGlobalSkillDir = join(homedir(), ".agents", "skills", "seal-home");
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bun
|
||||
import { readFileSync } from "node:fs";
|
||||
import { cliDocPath, updateCliDoc } from "./generate-cli-md.mjs";
|
||||
|
||||
const content = readFileSync(cliDocPath, "utf8");
|
||||
if (content !== updateCliDoc(content)) {
|
||||
console.error("CLI command documentation is stale. Run bun run generate:cli-md and commit the result.");
|
||||
process.exitCode = 1;
|
||||
} else {
|
||||
console.log("CLI command documentation is synchronized.");
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bun
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { embeddedSkillOutput, renderEmbeddedSkill } from "./generate-embedded-skill.mjs";
|
||||
|
||||
if (!existsSync(embeddedSkillOutput) || readFileSync(embeddedSkillOutput, "utf8") !== renderEmbeddedSkill()) {
|
||||
console.error("Embedded Skill manifest is stale. Run bun run generate:embedded-skill and commit the result.");
|
||||
process.exitCode = 1;
|
||||
} else {
|
||||
console.log("Embedded Skill manifest is synchronized.");
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bun
|
||||
import { readFileSync, writeFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { HELP_REGISTRY } from "../src/cli/help.ts";
|
||||
|
||||
export const cliDocPath = resolve(import.meta.dirname, "../skills/seal-use/references/cli.md");
|
||||
const begin = "<!-- BEGIN GENERATED CLI COMMANDS -->";
|
||||
const end = "<!-- END GENERATED CLI COMMANDS -->";
|
||||
|
||||
export function renderCliCommandBlock() {
|
||||
const usages = ["seal-use version", ...HELP_REGISTRY.flatMap((area) => area.commands.flatMap((command) => command.usage))];
|
||||
return [begin, "", "```bash", ...usages, "```", "", end].join("\n");
|
||||
}
|
||||
|
||||
export function updateCliDoc(markdown) {
|
||||
if (markdown.split(begin).length !== 2 || markdown.split(end).length !== 2 || markdown.indexOf(end) < markdown.indexOf(begin)) {
|
||||
throw new Error("CLI documentation must contain exactly one ordered generated command block.");
|
||||
}
|
||||
const start = markdown.indexOf(begin);
|
||||
const finish = markdown.indexOf(end) + end.length;
|
||||
return markdown.slice(0, start) + renderCliCommandBlock() + markdown.slice(finish);
|
||||
}
|
||||
|
||||
if (import.meta.main) {
|
||||
const before = readFileSync(cliDocPath, "utf8");
|
||||
const after = updateCliDoc(before);
|
||||
if (before !== after) writeFileSync(cliDocPath, after, "utf8");
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
|
||||
|
||||
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const skillRoot = resolve(root, "skills", "seal-use");
|
||||
const output = resolve(root, "src", "core", "embedded-skill.generated.ts");
|
||||
export const embeddedSkillOutput = resolve(root, "src", "core", "embedded-skill.generated.ts");
|
||||
const textExtensions = new Set([".md", ".yaml", ".yml", ".json", ".txt"]);
|
||||
|
||||
function walk(dir) {
|
||||
@@ -20,40 +20,39 @@ function walk(dir) {
|
||||
return files;
|
||||
}
|
||||
|
||||
const files = walk(skillRoot).map((fullPath) => ({
|
||||
fullPath,
|
||||
relativePath: relative(skillRoot, fullPath).split("\\").join("/"),
|
||||
importPath: relative(resolve(root, "src", "core"), fullPath).split("\\").join("/"),
|
||||
kind: textExtensions.has(extname(fullPath).toLowerCase()) ? "text" : "asset"
|
||||
}));
|
||||
export function renderEmbeddedSkill(sourceDir = skillRoot, coreDir = resolve(root, "src", "core")) {
|
||||
const files = walk(sourceDir).map((fullPath) => ({
|
||||
relativePath: relative(sourceDir, fullPath).split("\\").join("/"),
|
||||
importPath: relative(coreDir, fullPath).split("\\").join("/"),
|
||||
kind: textExtensions.has(extname(fullPath).toLowerCase()) ? "text" : "asset"
|
||||
}));
|
||||
|
||||
const lines = [
|
||||
"// Generated by scripts/generate-embedded-skill.mjs. Do not edit manually.",
|
||||
""
|
||||
];
|
||||
|
||||
const lines = [
|
||||
"// Generated by scripts/generate-embedded-skill.mjs. Do not edit manually.",
|
||||
""
|
||||
];
|
||||
|
||||
for (const [index, file] of files.entries()) {
|
||||
if (file.kind === "text") {
|
||||
lines.push(`import file${index} from ${JSON.stringify(file.importPath)} with { type: "text" };`);
|
||||
} else {
|
||||
const base64 = readFileSync(file.fullPath).toString("base64");
|
||||
lines.push(`const file${index} = ${JSON.stringify(base64)};`);
|
||||
for (const [index, file] of files.entries()) {
|
||||
const loader = file.kind === "text" ? "text" : "file";
|
||||
lines.push(`import file${index} from ${JSON.stringify(file.importPath)} with { type: "${loader}" };`);
|
||||
}
|
||||
|
||||
lines.push("", "export const EMBEDDED_SKILL_TEXT_FILES: Record<string, string> = {");
|
||||
for (const [index, file] of files.entries()) {
|
||||
if (file.kind === "text") lines.push(` ${JSON.stringify(file.relativePath)}: file${index},`);
|
||||
}
|
||||
lines.push("};", "", "export const EMBEDDED_SKILL_ASSET_PATHS: Record<string, string> = {");
|
||||
for (const [index, file] of files.entries()) {
|
||||
if (file.kind === "asset") lines.push(` ${JSON.stringify(file.relativePath)}: file${index},`);
|
||||
}
|
||||
lines.push("};", "", "export const EMBEDDED_SKILL_ALL_PATHS = [");
|
||||
for (const file of files) lines.push(` ${JSON.stringify(file.relativePath)},`);
|
||||
lines.push("];", "");
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
lines.push("", "export const EMBEDDED_SKILL_TEXT_FILES: Record<string, string> = {");
|
||||
for (const [index, file] of files.entries()) {
|
||||
if (file.kind === "text") lines.push(` ${JSON.stringify(file.relativePath)}: file${index},`);
|
||||
if (import.meta.main) {
|
||||
const content = renderEmbeddedSkill();
|
||||
const previous = existsSync(embeddedSkillOutput) ? readFileSync(embeddedSkillOutput, "utf8") : "";
|
||||
if (previous !== content) writeFileSync(embeddedSkillOutput, content, "utf8");
|
||||
}
|
||||
lines.push("};", "", "export const EMBEDDED_SKILL_ASSET_DATA: Record<string, string> = {");
|
||||
for (const [index, file] of files.entries()) {
|
||||
if (file.kind === "asset") lines.push(` ${JSON.stringify(file.relativePath)}: file${index},`);
|
||||
}
|
||||
lines.push("};", "", "export const EMBEDDED_SKILL_ALL_PATHS = [");
|
||||
for (const file of files) lines.push(` ${JSON.stringify(file.relativePath)},`);
|
||||
lines.push("];", "");
|
||||
|
||||
const content = lines.join("\n");
|
||||
const previous = existsSync(output) ? readFileSync(output, "utf8").replace(/\r\n/g, "\n") : "";
|
||||
if (previous !== content) writeFileSync(output, content, "utf8");
|
||||
@@ -0,0 +1,77 @@
|
||||
import { afterEach, describe, expect, test } from "bun:test"
|
||||
import { copyFileSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
|
||||
import { tmpdir } from "node:os"
|
||||
import { join } from "node:path"
|
||||
import { embeddedSkillOutput, renderEmbeddedSkill } from "./generate-embedded-skill.mjs"
|
||||
import { cliDocPath, renderCliCommandBlock, updateCliDoc } from "./generate-cli-md.mjs"
|
||||
|
||||
const tempDirs: string[] = []
|
||||
afterEach(() => {
|
||||
for (const dir of tempDirs.splice(0)) rmSync(dir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
describe("generated documentation contracts", () => {
|
||||
test("both committed generated artifacts match their source", () => {
|
||||
const markdown = readFileSync(cliDocPath, "utf8")
|
||||
expect(updateCliDoc(markdown)).toBe(markdown)
|
||||
expect(readFileSync(embeddedSkillOutput, "utf8")).toBe(renderEmbeddedSkill())
|
||||
})
|
||||
|
||||
test("CLI regeneration repairs drift while preserving surrounding handwritten content", () => {
|
||||
const block = renderCliCommandBlock()
|
||||
const drifted = `before\n${block.replace("seal-use version", "seal-use stale-command")}\nafter`
|
||||
expect(updateCliDoc(drifted)).toBe(`before\n${block}\nafter`)
|
||||
expect(() => updateCliDoc("missing markers")).toThrow("exactly one ordered")
|
||||
expect(() => updateCliDoc(`${block}\n${block}`)).toThrow("exactly one ordered")
|
||||
})
|
||||
|
||||
test("embedded manifests follow added and removed paths without inlining asset bytes", () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), "seal-generator-"))
|
||||
tempDirs.push(dir)
|
||||
const skill = join(dir, "skill")
|
||||
mkdirSync(skill)
|
||||
writeFileSync(join(skill, "SKILL.md"), "first")
|
||||
const before = renderEmbeddedSkill(skill, dir)
|
||||
writeFileSync(join(skill, "SKILL.md"), "second")
|
||||
expect(renderEmbeddedSkill(skill, dir)).toBe(before)
|
||||
writeFileSync(join(skill, "fixture.png"), new Uint8Array([1, 2, 3]))
|
||||
const after = renderEmbeddedSkill(skill, dir)
|
||||
expect(after).not.toBe(before)
|
||||
expect(after).toContain('with { type: "file" }')
|
||||
expect(after).not.toContain("AQID")
|
||||
// Rendering and checking never write the generated output or alter sources.
|
||||
expect(readFileSync(join(skill, "SKILL.md"), "utf8")).toBe("second")
|
||||
rmSync(join(skill, "fixture.png"))
|
||||
expect(renderEmbeddedSkill(skill, dir)).toBe(before)
|
||||
})
|
||||
|
||||
test("check commands reject stale artifacts without rewriting them", () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), "seal-generator-check-"))
|
||||
tempDirs.push(dir)
|
||||
const scripts = join(dir, "scripts")
|
||||
const core = join(dir, "src/core")
|
||||
const cli = join(dir, "src/cli")
|
||||
const skill = join(dir, "skills/seal-use")
|
||||
for (const path of [scripts, core, cli, join(skill, "references")]) mkdirSync(path, { recursive: true })
|
||||
for (const name of ["generate-embedded-skill.mjs", "check-embedded-skill.mjs", "generate-cli-md.mjs", "check-cli-md.mjs"]) {
|
||||
copyFileSync(join(import.meta.dir, name), join(scripts, name))
|
||||
}
|
||||
writeFileSync(join(cli, "help.ts"), 'export const HELP_REGISTRY = [{ commands: [{ usage: ["seal-use fixture list"] }] }];')
|
||||
writeFileSync(join(skill, "SKILL.md"), "fixture skill")
|
||||
const embeddedPath = join(core, "embedded-skill.generated.ts")
|
||||
const markdownPath = join(skill, "references/cli.md")
|
||||
writeFileSync(embeddedPath, "stale embedded fixture")
|
||||
const markdown = renderCliCommandBlock().replace("seal-use version", "seal-use stale-command")
|
||||
writeFileSync(markdownPath, markdown)
|
||||
for (const script of ["check-embedded-skill.mjs", "check-cli-md.mjs"]) {
|
||||
const result = Bun.spawnSync([process.execPath, join(scripts, script)], { cwd: dir })
|
||||
expect(result.exitCode).toBe(1)
|
||||
}
|
||||
expect(readFileSync(embeddedPath, "utf8")).toBe("stale embedded fixture")
|
||||
expect(readFileSync(markdownPath, "utf8")).toBe(markdown)
|
||||
for (const script of ["generate-cli-md.mjs", "generate-embedded-skill.mjs", "check-embedded-skill.mjs", "check-cli-md.mjs"]) {
|
||||
const result = Bun.spawnSync([process.execPath, join(scripts, script)], { cwd: dir })
|
||||
expect(result.exitCode).toBe(0)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -1,14 +1,14 @@
|
||||
---
|
||||
name: seal-use
|
||||
description: "v0.11.11: Use for Seal Use enterprise onboarding, Hose/合思 or Seal-native authentication, approval operations, diagnosis, simulation, rules, users, configuration, and search."
|
||||
description: "v0.11.12: Use for Seal Use enterprise onboarding, Hose/合思 or Seal-native authentication, approval operations, diagnosis, simulation, rules, users, configuration, and search."
|
||||
metadata:
|
||||
version: 0.11.11
|
||||
short-description: Seal tenant and Hose approval automation (v0.11.11)
|
||||
version: 0.11.12
|
||||
short-description: Seal tenant and Hose approval automation (v0.11.12)
|
||||
---
|
||||
|
||||
# Seal Use
|
||||
|
||||
CLI 是主执行通道。机器通道 `stdout` 必须是纯 JSON;诊断日志、进度和下一步建议写入 `stderr`。插件不带 MCP;本地 MCP 需显式 `seal-use mcp` 启动。
|
||||
CLI 是主执行通道。运行 `seal-use help` 获取完整命令清单,使用 `seal-use help <area> [command]` 按需查询参数。机器通道 `stdout` 必须是纯 JSON;诊断日志、进度和下一步建议写入 `stderr`。插件不带 MCP;本地 MCP 需显式 `seal-use mcp` 启动。
|
||||
|
||||
## 工具就绪检测与安装 (Bootstrap & Installation)
|
||||
|
||||
@@ -86,11 +86,7 @@ bun run dev:override # 编译本机二进制、打版本号并原子覆盖
|
||||
|
||||
## `corps` 主线
|
||||
|
||||
- 接入:`add-link`、`add-seal-bearer`、`add-hose-persistent`、`add-hose-web-session`
|
||||
- 发现:`list`、`search`/`find`、`get`/`show`、`current`、`switch`
|
||||
- 维护:`mark`、`rename`
|
||||
- 测试闭环:`bind-test`、`unbind-test`、`sync-test`、`replay-test`
|
||||
- Hose 专属:`probe-hose`、`hose-staffs`、`hose-extract-keys`、`hose-keys`
|
||||
企业接入、发现、维护与测试配对的具体语法见 `seal-use help corps`;材料选择与操作流程按下方 reference 路由。
|
||||
|
||||
Hose 专属命令应从命令名或选项中明确可见:`auth hose-*`、`approval-runs hose-flow`、`deploy hosecloud`、`simulation --mode hosecloud`。跨来源入口只有在明确使用 `--elevate-hose`、`--with-flow` 或 `--type hose-document` 时才启用对应 Hose 能力。
|
||||
|
||||
|
||||
+158
-121
@@ -35,13 +35,30 @@ override that path. The legacy `current-corp` file is not read.
|
||||
|
||||
## Top-Level Commands
|
||||
|
||||
<!-- BEGIN GENERATED CLI COMMANDS -->
|
||||
|
||||
```bash
|
||||
seal-use version
|
||||
seal-use config paths
|
||||
seal-use config get
|
||||
seal-use config mode <stateful|stateless> [--corp <corpId>]
|
||||
seal-use config test-dir [<path>|--clear]
|
||||
seal-use config lint <enable|disable|status> [--linter <name>] [--min-score <score>]
|
||||
seal-use corps list [query] [--all] [--limit <n>] [--env <production|test>] [--strict] [--corp <corpId>]
|
||||
seal-use corps search <query> [--env <production|test>] [--strict]
|
||||
seal-use corps get <corpId>
|
||||
seal-use corps current [--corp <corpId>]
|
||||
seal-use corps switch <corpId>
|
||||
seal-use corps mark <corpId> --env <production|test> [--confirm]
|
||||
seal-use corps rename <corpId> --name <newName>
|
||||
seal-use corps bind-test <prodCorpId> <testCorpId> [--confirm] [--force]
|
||||
seal-use corps bind-test <testCorpId> --corp <prodCorpId> [--confirm] [--force]
|
||||
seal-use corps unbind-test [<corpId>] [--confirm]
|
||||
seal-use corps sync-test [<prodCorpId>] [--dry-run] [--yes] [--version-name <name>]
|
||||
seal-use corps replay-test [<prodCorpId>] [--record-id <id>] [--sn <sn>] [--limit <n>] [--status <status>] [--webhook <idOrName>] [--sn-suffix <str>] [--dry-run] [--confirm|--yes] [--force]
|
||||
seal-use corps add-hose-persistent --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}'
|
||||
seal-use corps add-seal-bearer --json '{"sealUrl":"https://tenant.sealai.cc","token":"seal-bearer-token"}'
|
||||
seal-use corps add-hose-web-session --json '{"baseUrl":"https://wx2.ekuaibao.com","corpId":"...","staffId":"...","accessToken":"..."}'
|
||||
seal-use corps add-link <url> [--name <customName>] [--elevate-hose] [--app-key <key>] [--key-id <id>] [--overwrite] [--dry-run]
|
||||
seal-use corps probe-hose --json '{"appKey":"...","appSecurity":"...","domain":"https://..."}'
|
||||
seal-use corps hose-staffs --json '{"appKey":"...","appSecurity":"...","role":"admin"}'
|
||||
seal-use corps hose-extract-keys <url> [--reveal] [--save] [--app-key <key>] [--key-id <id>] [--name <customName>] [--overwrite]
|
||||
seal-use corps hose-keys [<url> | <corpId>] [--reveal] [--save] [--app-key <key>]
|
||||
seal-use rules count [--version <number|latest>] [--corp <corpId>]
|
||||
seal-use rules list [--version <number|latest>] [--summary] [--limit 20] [--offset 0] [--output-file <path>] [--corp <corpId>]
|
||||
seal-use rules get <code> [--version <number|latest>] [--record-id <recordId>] [--corp <corpId>]
|
||||
@@ -61,102 +78,78 @@ seal-use rules push status [--file <path>] [--corp <corpId>]
|
||||
seal-use rules clear [--dry-run|--yes] [--corp <corpId>]
|
||||
seal-use rules recode [--dry-run] --corp <corpId>
|
||||
seal-use rules map [--version <number|latest>] [--code <code>] [--corp <corpId>]
|
||||
seal-use documents list [--scenarios <audit,fill>] [--limit 50] [--offset 0] [--corp <corpId>]
|
||||
seal-use documents get <documentId> [--corp <corpId>]
|
||||
seal-use documents search <keyword> [--maxResults 20] [--corp <corpId>]
|
||||
seal-use documents create --title <title> --purpose <purpose> [--content <text>|--content-file <path>] [--type <policy|document|video|pdf|feishu_doc>] [--scenarios <audit,fill>] [--tags <tag1,tag2>] [--status <published|draft>] [--corp <corpId>]
|
||||
seal-use documents update <documentId> [--title <title>] [--purpose <purpose>] [--content <text>|--content-file <path>] [--type <policy|document|video|pdf|feishu_doc>] [--enabled <true|false>] [--scenarios <audit,fill>] [--tags <tag1,tag2>] [--status <published|draft>] [--corp <corpId>]
|
||||
seal-use documents delete <documentId> --yes [--corp <corpId>]
|
||||
seal-use langfuse check
|
||||
seal-use langfuse cache-refresh <traceId>
|
||||
seal-use langfuse outline <traceId> [--include-io-preview] [--max-preview-chars <n>] [--full] [--refresh-if-missing]
|
||||
seal-use langfuse search <traceId> --query <term1,term2> [--fields <fields>] [--max-results <n>] [--context-chars <n>] [--observation-types <types>] [--metadata <json>] [--session-id <id>] [--refresh-if-missing]
|
||||
seal-use langfuse observation <traceId> <observationId> [--fields <fields>] [--max-chars <n>] [--json-path <path>] [--full] [--refresh-if-missing]
|
||||
seal-use langfuse session <sessionId> [--trace-limit <n>]
|
||||
seal-use langfuse observations <traceId> [--name-contains <text>] [--type <type>] [--metadata-key <key>] [--has-input] [--has-output] [--max-results <n>] [--refresh-if-missing]
|
||||
seal-use langfuse url <traceId>
|
||||
seal-use langfuse attachment-flow <traceId> [--file-id <id>] [--file-name <name>] [--content-hints <hints>] [--context-chars <n>] [--refresh-if-missing]
|
||||
seal-use langfuse rule-flow <traceId> --rule <text> [--rule-hints <hints>] [--context-chars <n>] [--refresh-if-missing]
|
||||
seal-use update [--check] [--force] [--version <v>]
|
||||
seal-use update check
|
||||
seal-use update changelog [--limit <n>]
|
||||
seal-use changelog [--limit <n>]
|
||||
seal-use mcp
|
||||
seal-use mcp config
|
||||
seal-use mcp-config
|
||||
seal-use skill dump
|
||||
seal-use skill install [--dir <path>|--local]
|
||||
seal-use skill status
|
||||
seal-use doctor [--quiet]
|
||||
seal-use doctor tenant [--corp <corpId>] [--quiet]
|
||||
seal-use doctor guide
|
||||
seal-use doctor paths
|
||||
seal-use test regression [--corp <corpId>] [--samples <N>] [--dry-run] [--fail-on-flips]
|
||||
seal-use probe [<corpId>]
|
||||
seal-use corps list [query] [--env <production|test>] [--limit <n>] [--all] [--strict] [--corp <corpId>]
|
||||
seal-use corps search <query> [--env <production|test>] [--strict]
|
||||
seal-use corps get <corpId>
|
||||
seal-use corps current [--corp <corpId>]
|
||||
seal-use corps switch <corpId>
|
||||
seal-use corps mark <corpId> --env <production|test> [--confirm]
|
||||
seal-use corps bind-test <prodCorpId> <testCorpId> [--confirm] [--force]
|
||||
seal-use corps unbind-test [<corpId>] [--confirm]
|
||||
seal-use corps sync-test [<prodCorpId>] [--dry-run] [--yes] [--version-name <name>]
|
||||
seal-use corps replay-test [<prodCorpId>] [--record-id <id>] [--sn <sn>] [--limit <n>] [--status <status>] [--webhook <idOrName>] [--sn-suffix <str>] [--dry-run] [--confirm|--yes] [--force]
|
||||
seal-use corps add-hose-persistent --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}'
|
||||
seal-use corps add-seal-bearer --json '{"sealUrl":"https://tenant.sealai.cc","token":"seal-bearer-token"}'
|
||||
seal-use corps add-link <url> [--name <customName>] [--elevate-hose] [--app-key <key>] [--key-id <id>] [--overwrite] [--dry-run]
|
||||
seal-use corps probe-hose --json '{"appKey":"...","appSecurity":"...","domain":"https://..."}'
|
||||
seal-use corps hose-staffs --json '{"appKey":"...","appSecurity":"...","role":"admin"}'
|
||||
seal-use corps hose-extract-keys <https://.../web/thirdparty.html?...> [--reveal] [--save] [--name <customName>] [--app-key <key>] [--key-id <id>] [--overwrite]
|
||||
seal-use corps hose-keys [<url> | <corpId>] [--reveal] [--save] [--app-key <key>] [--key-id <id>]
|
||||
seal-use auth hose-extract-keys <https://.../web/thirdparty.html?...> [--reveal] [--save] [--name <customName>] [--app-key <key>] [--key-id <id>] [--overwrite]
|
||||
seal-use auth hose-keys [--corp <corpId>] [--reveal]
|
||||
seal-use auth check [--corp <corpId>]
|
||||
seal-use auth link [--corp <corpId>] [--note <note>]
|
||||
seal-use auth link --from-link <url> [--note <note>]
|
||||
seal-use auth link list [--corp <corpId>]
|
||||
seal-use auth link revoke <tokenId> [--corp <corpId>]
|
||||
seal-use auth hose-link [--corp <corpId>] [--expire <seconds>] [--force]
|
||||
seal-use auth hose-openapi-token [--corp <corpId>] [--force]
|
||||
seal-use users create --name <name> --phone <phone> [--dept <deptId>] [--corp <corpId>]
|
||||
seal-use users search <keyword> [--corp <corpId>]
|
||||
seal-use users delegation <userIdOrPhone|name> [--note <note>] [--corp <corpId>]
|
||||
seal-use users activate <userId> [--corp <corpId>]
|
||||
seal-use users reset-password <userId> --yes [--corp <corpId>]
|
||||
seal-use users get <userId> [--corp <corpId>]
|
||||
seal-use users delete <userId> --yes [--corp <corpId>]
|
||||
seal-use contacts departments [<departmentId>] [--corp <corpId>]
|
||||
seal-use contacts children <departmentId> [--corp <corpId>]
|
||||
seal-use contacts users <departmentId> [--corp <corpId>]
|
||||
seal-use contacts sync-time [--corp <corpId>]
|
||||
seal-use data expenses --corp <corpId> [--search <text>] [--start-date <ISO|ms>] [--end-date <ISO|ms>] [--offset <n>] [--limit <n>]
|
||||
seal-use data invoices --corp <corpId> [--search <text>] [--start-date <ISO|ms>] [--end-date <ISO|ms>] [--offset <n>] [--limit <n>]
|
||||
seal-use llm config [--corp <corpId>]
|
||||
seal-use llm providers [--corp <corpId>]
|
||||
seal-use permissions available [--corp <corpId>]
|
||||
seal-use permissions configs [--corp <corpId>]
|
||||
seal-use billing status [--corp <corpId>]
|
||||
seal-use billing plans [--corp <corpId>]
|
||||
seal-use billing features [--corp <corpId>]
|
||||
seal-use webhook ready [<资源包.zip>] [--webhook <idOrName>] [--corp <corpId>]
|
||||
seal-use webhook ready [<材料包.zip>] [--webhook <idOrName>] [--corp <corpId>]
|
||||
seal-use webhook status [<材料包.zip>] [--corp <corpId>]
|
||||
seal-use webhook list [--query <text>] [--show-secret] [--corp <corpId>]
|
||||
seal-use webhook get|find <idOrName> [--show-secret] [--corp <corpId>]
|
||||
seal-use webhook add --name <name> --result-url <url> [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret <secret>] [--min-file-size <bytes>] [--max-file-size <bytes>] [--allowed-extensions <.pdf,.xlsx,...>] [--dry-run] [--corp <corpId>]
|
||||
seal-use webhook add --name <name> --result-url <url> [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret <secret>] [--min-file-size 500] [--max-file-size <bytes>] [--allowed-extensions <.pdf,.xlsx,...>] [--dry-run] [--corp <corpId>]
|
||||
seal-use webhook update <idOrName> [--name <name>] [--result-url <url>] [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret <secret>|--rotate-secret] [--min-file-size <bytes>] [--max-file-size <bytes>] [--allowed-extensions <.pdf,.xlsx,...>] [--clear-max-file-size] [--dry-run] [--corp <corpId>]
|
||||
seal-use webhook delete <idOrName> [--yes|--dry-run] [--corp <corpId>]
|
||||
seal-use webhook resource-pack export [--limit <n>] [--status <status>] [--output <file.zip>] [--to-downloads] [--corp <corpId>]
|
||||
seal-use webhook resource-pack export <recordId> [--output <file.zip>] [--corp <corpId>]
|
||||
seal-use webhook resource-pack export --record-ids <id1,id2> [--corp <corpId>]
|
||||
seal-use webhook resource-pack preview <资源包.zip|信息表.xlsx> [--min-file-size <bytes>] [--max-file-size <bytes>] [--allowed-extensions <.pdf,.xlsx,...>] [--corp <corpId>]
|
||||
seal-use webhook resource-pack push <资源包.zip|信息表.xlsx> [--webhook <idOrName>] [--corp <corpId>]
|
||||
seal-use webhook replay [<recordId>] [--sn <documentSN>] [--limit <n>] [--status <status>] [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>] [--sn-suffix <str>] [--channel webhook|hose-outbound] [--rejection-num <n>] [--message-id <msgId>] [--flow-id <flowId>] [--dry-run] [--yes|--confirm] [--force] [--corp <corpId>]
|
||||
seal-use approval-runs replay --sn <sn> [--channel hose-outbound] [--rejection-num <n>] [--message-id <msgId>] [--flow-id <flowId>] [--target-corp <corpId>] [--dry-run] [--yes|--confirm] [--corp <corpId>]
|
||||
seal-use webhook replay <recordId> [--webhook <idOrName>] [--sn-suffix <str>] [--dry-run] [--yes|--confirm] [--corp <corpId>]
|
||||
seal-use webhook replay --sn <documentSN> [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>] [--yes|--confirm]
|
||||
seal-use webhook replay --limit <n> [--status <status>] [--source-corp <corpId>] [--target-corp <corpId>] [--yes|--confirm]
|
||||
seal-use approval-runs summary [--date YYYY-MM-DD] [--timezone Asia/Shanghai] [--corp <corpId>]
|
||||
seal-use approval-runs stats [--since 3months] [--dedupe-by sourceDocumentSN|sourceDocumentId|id] [--corp <corpId>]
|
||||
seal-use approval-runs count [--status APPROVED] [--start <YYYY-MM-DD|ms>] [--end <YYYY-MM-DD|ms>] [--corp <corpId>]
|
||||
seal-use approval-runs export [--sn <SN1,SN2>] [--start <YYYY-MM-DD|ms>] [--end <YYYY-MM-DD|ms>] [--force] [--status <status>] [--manual-status <status>] [--completed-only] [--limit <n>] [--downloads|--to-downloads] [--with-flow] [--out <file>] [--corp <corpId>]
|
||||
seal-use approval-runs hose-flow <recordId|SN> [--corp <corpId>]
|
||||
seal-use approval-runs list|search [--query text] [--humanResult 驳回] [--manualApprovalStatus TERMINATED] [--startDate ms] [--endDate ms] [--limit 20] [--includeBridge true] [--corp <corpId>]
|
||||
seal-use approval-runs pick --sn <documentSN> [--batch <batchId>] [--latest] [--fields recordId,status,aiDecision] [--corp <corpId>]
|
||||
seal-use approval-runs get <recordId> [--summary] [--fields metadata|document.fields,result.summary] [--full] [--output-file file.json] [--corp <corpId>]
|
||||
seal-use approval-runs cited-rules <recordId> [--corp <corpId>]
|
||||
seal-use approval-runs diagnose <recordId>|--sn <documentSN> [--full] [--corp <corpId>]
|
||||
seal-use approval-runs document-summary <recordId> [--corp <corpId>]
|
||||
seal-use approval-runs attachments <recordId> [--summary] [--corp <corpId>]
|
||||
seal-use approval-runs attachments download <recordId> [--all] [--name <name>] [--out-dir <dir>] [--corp <corpId>]
|
||||
seal-use approval-runs result <recordId> [--summary] [--corp <corpId>]
|
||||
seal-use approval-runs link <recordId> [--corp <corpId>]
|
||||
seal-use approval-runs link <recordId> --auto-login [--expire 7200] [--corp <corpId>]
|
||||
seal-use approval-runs link <recordId> --type hose-document [--corp <corpId>]
|
||||
seal-use approval-runs link --sn <documentSN> [--auto-login] [--corp <corpId>]
|
||||
seal-use approval-runs bridge [--sourceDocumentSN B26001887] [--corp <corpId>]
|
||||
seal-use approval-runs replay <recordId> [--webhook <idOrName>] [--sn-suffix <str>] [--dry-run] [--yes|--confirm] [--corp <corpId>]
|
||||
seal-use approval-runs replay --sn <documentSN> [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>] [--yes|--confirm]
|
||||
seal-use approval-runs replay --sn <documentSN> --channel hose-outbound [--sign-key <key>] [--target-corp <corpId>] [--dry-run] [--yes|--confirm]
|
||||
seal-use approval-runs replay <recordId> --channel hose-outbound [--sign-key <key>] [--target-corp <corpId>] [--dry-run] [--yes|--confirm]
|
||||
seal-use approval-runs replay --limit <n> [--status <status>] [--source-corp <corpId>] [--target-corp <corpId>] [--yes|--confirm]
|
||||
seal-use report ledger --start-date <YYYY-MM-DD> --end-date <YYYY-MM-DD> [--templates <t1,t2...>] [--limit <n>] [--out <file.xlsx>] [--corp <corpId>]
|
||||
seal-use report data (--ledger <台账.xlsx> | --start-date <YYYY-MM-DD> --end-date <YYYY-MM-DD>) [--templates <t1,t2...>] [--limit <n>] [--corp <corpId>]
|
||||
seal-use report template [--out <file.md>]
|
||||
seal-use report chart venn --ai <acc> --human <acc> [--both <both>] [--out <file.svg>]
|
||||
seal-use report generate (--ledger <台账.xlsx> | --start-date <YYYY-MM-DD> --end-date <YYYY-MM-DD>) [--templates <t1,t2...>] [--out <报告.md>] [--template <file>] [--report-id <RPT-...>] [--limit <n>] [--allow-unreviewed] [--corp <corpId>]
|
||||
seal-use report validate <报告.md>
|
||||
seal-use report render <报告.md> --out <build/报告> [--format <all|html|png|pdf>]
|
||||
seal-use report export <报告.md> --out <输出目录> [--format <all|html|pdf>]
|
||||
seal-use report review set [--record-id <ID>] [--sn <SN>] --verdict <v> [--note <text>] [--reviewed-by <who>] [--corp <corpId>]
|
||||
seal-use report review list [--corp <corpId>]
|
||||
seal-use report review import <台账.xlsx|csv> --corp <corpId>
|
||||
seal-use simulation batch-records <batchId> [--corp <corpId>]
|
||||
seal-use simulation create --mode hosecloud --flow-ids "B26017701,B26022501" [--wait] [--timeout 10m] [--poll-interval 2s] [--reject-node 财务] [--thinking-depth default|medium|high] [--skip-extract|--extract] [--skip-invoice-generation] [--no-wait] [--force] [--reuse-window 5m] [--corp <corpId>]
|
||||
seal-use simulation create --mode material_pack --package-ids <materialPackageId> [--template-id conference_reimbursement_v1] [--schema-config file.json] [--corp <corpId>]
|
||||
seal-use simulation create --source-system weaver --request-ids "req-01,req-02" [--corp <corpId>]
|
||||
seal-use simulation status <batchId> [--corp <corpId>]
|
||||
seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s] [--corp <corpId>]
|
||||
seal-use simulation clean <batchId> --yes [--corp <corpId>]
|
||||
seal-use simulation specifications [--integration <sign-key>] [--corp <corpId>]
|
||||
seal-use simulation approval-definitions [--corp <corpId>]
|
||||
seal-use simulation list [--limit 50] [--corp <corpId>]
|
||||
seal-use simulation get <batchId> [--corp <corpId>]
|
||||
seal-use simulation templates [--corp <corpId>]
|
||||
seal-use simulation integrations [--corp <corpId>]
|
||||
seal-use simulation package-upload <材料包.zip> [--corp <corpId>]
|
||||
seal-use deploy hosecloud requirements [--corp <corpId>]
|
||||
seal-use deploy hosecloud list [--corp <corpId>]
|
||||
seal-use deploy hosecloud get <sign-key> [--corp <corpId>]
|
||||
seal-use deploy hosecloud status [--corp <corpId>]
|
||||
seal-use deploy hosecloud configure --json '{...}' [--dry-run] [--yes|--confirm] [--corp <corpId>]
|
||||
seal-use deploy hosecloud sync [<sign-key>] [--auto] [--dry-run] [--yes|--confirm] [--corp <corpId>]
|
||||
seal-use deploy hosecloud test-outbound [--sign-key <key>] --flow-id <flowId> --message-id <msgId> [--sn <sn>] [--rejection-num <n>] [--dry-run] [--yes|--confirm] [--corp <corpId>]
|
||||
seal-use deploy hosecloud test-outbound [--sign-key <key>] --flow-id <id> --message-id <msgId> [--dry-run] [--yes|--confirm] [--corp <corpId>]
|
||||
seal-use deploy hosecloud test-outbound [--sign-key <key>] --sn <SN> --message-id <msgId> [--dry-run] [--yes|--confirm] [--corp <corpId>]
|
||||
seal-use hose-ebot search <sn> [--type invoking|callback] [--limit <n>] [--reveal] [--corp <corpId>]
|
||||
seal-use hose-ebot messages [--type flow|message] [--reveal] [--corp <corpId>]
|
||||
seal-use hose-ebot callback --flow-id <flowId> --node-id <nodeId> --action <accept|refuse|preAdd|aftAdd> --comment <审批意见> [--sign-key <key>] [--policy <ALL|ANY>] [--add-approver-ids <id,id>] [--reject-to <nodeId>] [--resubmit-method <FROM_START|TO_REJECTOR>] [--dry-run] [--yes|--confirm] [--corp <corpId>]
|
||||
@@ -166,45 +159,89 @@ seal-use preference thinking-depth set --default <medium|high> [--dry-run] [--co
|
||||
seal-use preference thinking-depth policies list [--corp <corpId>]
|
||||
seal-use preference thinking-depth policies upsert --json '{...}' [--dry-run] [--corp <corpId>]
|
||||
seal-use preference thinking-depth policies remove <policyId> [--dry-run] [--corp <corpId>]
|
||||
seal-use config paths
|
||||
seal-use config get
|
||||
seal-use config mode <stateful|stateless> [--corp <corpId>]
|
||||
seal-use config test-dir [<path>|--clear]
|
||||
seal-use config lint [status|enable|disable] [--linter <name|path>] [--min-score <score>]
|
||||
seal-use auth check [--corp <corpId>]
|
||||
seal-use auth link [--note <note>] [--expire <duration>] [--corp <corpId>]
|
||||
seal-use auth link --from-link <url> [--note <note>] [--expire <duration>]
|
||||
seal-use auth link list [--corp <corpId>]
|
||||
seal-use auth link revoke <tokenId> [--corp <corpId>]
|
||||
seal-use auth hose-link [--corp <corpId>] [--expire <duration>] [--force]
|
||||
seal-use auth hose-openapi-token [--corp <corpId>] [--force]
|
||||
seal-use auth hose-extract-keys <url> [--reveal] [--save] [--app-key <key>] [--key-id <id>] [--name <customName>] [--overwrite]
|
||||
seal-use auth hose-keys [--corp <corpId>] [--reveal]
|
||||
seal-use users create --name <name> --phone <phone> [--dept <deptId>] [--corp <corpId>]
|
||||
seal-use users search <keyword> [--corp <corpId>]
|
||||
seal-use users delegation <userIdOrPhone|name> [--note <note>] [--expire <duration>] [--corp <corpId>]
|
||||
seal-use users reset-password <userId> --yes [--corp <corpId>]
|
||||
seal-use users get <userId> [--corp <corpId>]
|
||||
seal-use users delete <userId> --yes [--corp <corpId>]
|
||||
seal-use contacts departments [<departmentId>] [--corp <corpId>]
|
||||
seal-use contacts children <departmentId> [--corp <corpId>]
|
||||
seal-use contacts users <departmentId> [--corp <corpId>]
|
||||
seal-use contacts sync-time [--corp <corpId>]
|
||||
seal-use data expenses [--search <text>] [--start-date <ISO|ms>] [--end-date <ISO|ms>] [--offset <n>] [--limit <n>] [--corp <corpId>]
|
||||
seal-use data invoices [--search <text>] [--start-date <ISO|ms>] [--end-date <ISO|ms>] [--offset <n>] [--limit <n>] [--corp <corpId>]
|
||||
seal-use llm config [--corp <corpId>]
|
||||
seal-use llm providers [--corp <corpId>]
|
||||
seal-use permissions available [--corp <corpId>]
|
||||
seal-use permissions configs [--corp <corpId>]
|
||||
seal-use billing status [--corp <corpId>]
|
||||
seal-use billing plans [--corp <corpId>]
|
||||
seal-use billing features [--corp <corpId>]
|
||||
seal-use analytics insight [--start-date <ISO>] [--end-date <ISO>] [--limit <n>] [--corp <corpId>]
|
||||
seal-use analytics risks <tagId> [--start-date <ISO>] [--end-date <ISO>] [--corp <corpId>]
|
||||
seal-use analytics performance [--start-date <ISO|ms>] [--end-date <ISO|ms>] [--corp <corpId>]
|
||||
seal-use analytics analyze <recordId> [--corp <corpId>]
|
||||
seal-use analytics export [--downloads] [--out <file>] [--start-date <ISO>] [--end-date <ISO>] [--force] [--limit <n>] [--corp <corpId>]
|
||||
seal-use context [--ruleVersion <versionId|versionNumber|latest>] [--documentLimit 50] [--corp <corpId>]
|
||||
seal-use source config [--corp <corpId>]
|
||||
seal-use approval-runs summary --corp <corpId> [--date YYYY-MM-DD] [--timezone Asia/Shanghai]
|
||||
seal-use approval-runs stats --corp <corpId> [--since 3months] [--dedupe-by sourceDocumentSN|sourceDocumentId|id]
|
||||
seal-use analytics insight --corp <corpId> [--start-date <ISO>] [--end-date <ISO>] [--limit <n>]
|
||||
seal-use analytics risks <tagId> --corp <corpId> [--start-date <ISO>] [--end-date <ISO>]
|
||||
seal-use analytics performance --corp <corpId> [--start-date <ISO|ms>] [--end-date <ISO|ms>]
|
||||
seal-use analytics analyze <recordId> --corp <corpId>
|
||||
seal-use analytics export --corp <corpId> [--downloads] [--out <file>] [--start-date <ISO>] [--end-date <ISO>] [--force]
|
||||
seal-use approval-runs count --corp <corpId> [--status APPROVED] [--start <YYYY-MM-DD|ms>] [--end <YYYY-MM-DD|ms>]
|
||||
seal-use approval-runs export --corp <corpId> [--sn <SN1,SN2>] [--start <YYYY-MM-DD|ms>] [--end <YYYY-MM-DD|ms>] [--force] [--status <status>] [--manual-status <status>] [--completed-only] [--limit <n>] [--downloads] [--out <file>] [--with-flow]
|
||||
seal-use documents list [--scenarios <audit,fill>] [--limit 50] [--offset 0] [--corp <corpId>]
|
||||
seal-use documents get <documentId> [--corp <corpId>]
|
||||
seal-use documents search <keyword> [--maxResults 20] [--corp <corpId>]
|
||||
seal-use documents create --title <title> --purpose <purpose> [--content <text>|--content-file <path>] [--type <policy|document|video|pdf|feishu_doc>] [--scenarios <audit,fill>] [--tags <tag1,tag2>] [--status <published|draft>] [--corp <corpId>]
|
||||
seal-use documents update <documentId> [--title <title>] [--purpose <purpose>] [--content <text>|--content-file <path>] [--type <policy|document|video|pdf|feishu_doc>] [--enabled <true|false>] [--scenarios <audit,fill>] [--tags <tag1,tag2>] [--status <published|draft>] [--corp <corpId>]
|
||||
seal-use documents delete <documentId> --yes [--corp <corpId>]
|
||||
seal-use update [--check] [--force] [--version <v>]
|
||||
seal-use update check
|
||||
seal-use update changelog [--limit <n>]
|
||||
seal-use changelog [--limit <n>]
|
||||
seal-use probe [<corpId>]
|
||||
seal-use langfuse check
|
||||
seal-use langfuse cache-refresh <traceId> [--trace-id <traceId>]
|
||||
seal-use langfuse outline <traceId> [--include-io-preview] [--max-preview-chars <n>] [--full]
|
||||
seal-use langfuse search <traceId> --query <term1,term2> [--fields input,output] [--max-results <n>]
|
||||
seal-use langfuse observation <traceId> <observationId> [--fields input,output] [--max-chars <n>]
|
||||
seal-use langfuse session <sessionId> [--trace-limit <n>]
|
||||
seal-use langfuse observations <traceId> [--name-contains <text>] [--type <type>]
|
||||
seal-use langfuse url <traceId>
|
||||
seal-use langfuse attachment-flow <traceId> [--file-id <id>] [--file-name <name>]
|
||||
seal-use langfuse rule-flow <traceId> --rule <规则内容>
|
||||
seal-use mcp
|
||||
seal-use mcp config
|
||||
seal-use mcp-config
|
||||
seal-use skill dump
|
||||
seal-use skill install [--dir <path>|--local]
|
||||
seal-use skill status
|
||||
seal-use doctor [--quiet]
|
||||
seal-use doctor guide
|
||||
seal-use doctor paths
|
||||
seal-use doctor tenant [--corp <corpId>] [--quiet]
|
||||
seal-use test regression [--corp <corpId>] [--samples <N>] [--dry-run] [--fail-on-flips]
|
||||
```
|
||||
|
||||
<!-- END GENERATED CLI COMMANDS -->
|
||||
|
||||
以下补充说明独立维护:
|
||||
|
||||
```bash
|
||||
# --sn / --sns: 定向筛选单据编号(支持逗号/分号/空格分隔,跳过全量分页,秒级定向导出特定单据)
|
||||
# --with-flow: 启用合思原生审批流对齐,输出 E人工行为 / E人工意见 两列(含样式 2-B 三行展开式驳回目标与重审规则、中途修改置顶事实且保留时序、动作 Emoji,默认关闭以节省合思 API 调用)
|
||||
# 导出文件名自动追加精确到分钟的 _YYYYMMDD_HHmm 时间戳后缀防止文件覆盖,格式:${企业名称}_审核记录_${时间区间}_${条数}_${导出时间戳}.xlsx
|
||||
seal-use approval-runs search --corp <corpId> [--query text] [--limit 20] [--includeBridge true]
|
||||
seal-use approval-runs get <recordId> --corp <corpId> [--fields metadata|document.fields,result.summary] [--output-file file.json]
|
||||
seal-use approval-runs attachments <recordId> --corp <corpId>
|
||||
seal-use approval-runs attachments download <recordId> [--all] [--name <name>] [--out-dir <dir>] --corp <corpId>
|
||||
seal-use approval-runs result <recordId> --corp <corpId> [--summary]
|
||||
seal-use approval-runs link <recordId> --corp <corpId>
|
||||
seal-use approval-runs link <recordId> --auto-login [--expire 7200] --corp <corpId>
|
||||
seal-use approval-runs link <recordId> --type hose-document --corp <corpId>
|
||||
seal-use approval-runs link --sn <documentSN> [--auto-login] --corp <corpId>
|
||||
# 生成审批详情链接:seal-use approval-runs link <recordId>
|
||||
seal-use approval-runs bridge --corp <corpId> [--sourceDocumentSN <sourceDocumentSN>]
|
||||
seal-use simulation batch-records <batchId> --corp <corpId>
|
||||
seal-use simulation create --mode hosecloud --flow-ids "B26017701,B26022501" [--reject-node 财务] [--thinking-depth default|medium|high] [--skip-invoice-generation|--skip-invoice-generation false] [--no-wait] [--force] [--reuse-window 5m] --corp <corpId>
|
||||
seal-use simulation create --mode material_pack --package-ids <materialPackageId> [--template-id conference_reimbursement_v1] [--schema-config file.json] --corp <corpId>
|
||||
seal-use simulation create --source-system weaver --request-ids "req-01,req-02" --corp <corpId>
|
||||
seal-use simulation status <batchId> --corp <corpId>
|
||||
seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s] --corp <corpId>
|
||||
seal-use simulation clean <batchId> --yes --corp <corpId>
|
||||
seal-use simulation specifications [--integration <sign-key>] --corp <corpId>
|
||||
seal-use simulation approval-definitions --corp <corpId>
|
||||
seal-use simulation list [--limit 50] --corp <corpId>
|
||||
seal-use simulation get <batchId> --corp <corpId>
|
||||
seal-use simulation templates --corp <corpId>
|
||||
seal-use simulation integrations --corp <corpId>
|
||||
seal-use simulation package-upload <材料包.zip> --corp <corpId>
|
||||
```
|
||||
|
||||
## CLI Command Overview
|
||||
|
||||
@@ -34,6 +34,8 @@ Read the JSON `stages` in order:
|
||||
|
||||
Do not expect tokens in the output; the command intentionally redacts or omits them.
|
||||
|
||||
Seal requests made with a renewable Hose session recover from HTTP 401 once for GET/HEAD/OPTIONS: the CLI exchanges a fresh Seal session and retries that read. Concurrent reads share the refresh, and another 401 stops with exit 11. Fixed Seal Bearer credentials are not refreshed automatically. Mutation requests are never replayed by this recovery path; inspect their result before deciding whether to retry.
|
||||
|
||||
When the caller needs the actual OpenAPI `accessToken` itself (for example to call Hose OpenAPI from their own script), use `seal-use auth hose-openapi-token --corp <corpId> [--force]`. It prints the unredacted token as JSON together with `expiresAt` and `cached` (`cached: true` means a still-fresh local token was reused; pass `--force` to mint a new one). Non-Hose enterprises are rejected with exit 2, and a Hose enterprise without persisted `appKey/appSecurity` exits 13.
|
||||
|
||||
## Get a Hose authorization link
|
||||
|
||||
@@ -369,3 +369,7 @@ seal-use report export reports/审核报告.md --out build/交付整包/
|
||||
3. **超高清拼接长图 (`.png`)**:
|
||||
- 由原生无头浏览器以 4x 视口倍率切片截取,并通过高性能图形算法在内存中无损拼接;
|
||||
- 专为钉钉、微信、飞书等移动端 IM 聊天窗口设计,方便管理层在手机上顺滑滑动审阅。
|
||||
4. **末尾术语与指标定义规范附录页 (Glossary Page)**:
|
||||
- 渲染流水线在生成 HTML、PDF、PNG 产物时,自动在末尾追加独立术语解释与指标定义附录页(涵盖审批决策与五类裁决、人机一致性与极性、KaTeX 量化公式、`recordId` 与 `SN` 双主键规范);
|
||||
- 原始报告 Markdown 保持干净不被侵入修改;PDF 在打印时拥有独立的物理分页隔离(`page-break-before: always`);
|
||||
- 若特定简报场景不需要附录页,可在 `report render` 或 `report export` 中指定 `--no-glossary` 参数跳过追加。
|
||||
+1
-1
@@ -11,7 +11,7 @@ process.stderr.on("error", (err: any) => {
|
||||
if (err?.code === "EPIPE") process.exit(0);
|
||||
});
|
||||
|
||||
performRuntimeSelfHealing();
|
||||
await performRuntimeSelfHealing();
|
||||
|
||||
const entryFile = fileURLToPath(import.meta.url);
|
||||
const isCompiled = isCompiledBinary();
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/** Execution aliases shared by dispatch, help, and the read-only gateway. */
|
||||
export const AREA_ALIASES: Readonly<Record<string, string>> = {
|
||||
corp: "corps",
|
||||
webhooks: "webhook",
|
||||
preferences: "preference",
|
||||
server: "mcp"
|
||||
}
|
||||
|
||||
export const UPDATE_ALIASES = new Set([
|
||||
"update", "upgrade", "up", "self-update", "selfupdate"
|
||||
])
|
||||
|
||||
export function normalizeCliArea(area: string): string {
|
||||
const lower = area.toLowerCase()
|
||||
return UPDATE_ALIASES.has(lower) ? "update" : AREA_ALIASES[lower] ?? lower
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { usageError } from "../../core/errors.js";
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
import { exportInsightReportToExcel } from "../../domains/seal/insight/export.js";
|
||||
@@ -31,7 +32,7 @@ export async function handleAnalyticsCommand(
|
||||
if (action === "risks" || action === "risks-by-tag" || action === "tag-risks") {
|
||||
const tagId = maybeName ?? stringOption(args.options.tagId) ?? stringOption(args.options["tag-id"]);
|
||||
if (!tagId) {
|
||||
throw new Error("Usage: seal-use analytics risks <tagId> [--start-date <ISO>] [--end-date <ISO>] [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use analytics risks <tagId> [--start-date <ISO>] [--end-date <ISO>] [--corp <corpId>]");
|
||||
}
|
||||
await runCapability(
|
||||
"sealInsightRisksByTagGet",
|
||||
@@ -64,7 +65,7 @@ export async function handleAnalyticsCommand(
|
||||
if (action === "analyze" || action === "reanalyze") {
|
||||
const recordId = maybeName ?? stringOption(args.options.recordId) ?? stringOption(args.options["record-id"]);
|
||||
if (!recordId) {
|
||||
throw new Error("Usage: seal-use analytics analyze <recordId> [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use analytics analyze <recordId> [--corp <corpId>]");
|
||||
}
|
||||
await runCapability(
|
||||
"sealInsightRecordAnalyze",
|
||||
@@ -91,5 +92,5 @@ export async function handleAnalyticsCommand(
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown analytics command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown analytics command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { usageError } from "../../core/errors.js";
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
import * as api from "../../domains/seal/api.js";
|
||||
@@ -151,7 +152,7 @@ export async function handleApprovalRunsCommand(
|
||||
|
||||
if (action === "pick") {
|
||||
const query = maybeName ?? stringOption(args.options.query) ?? stringOption(args.options.sn);
|
||||
if (!query) throw new Error("Usage: seal-use approval-runs pick --sn <documentSN>");
|
||||
if (!query) throw usageError("Usage: seal-use approval-runs pick --sn <documentSN>");
|
||||
await runCapability(
|
||||
"sealApprovalRunPick",
|
||||
client,
|
||||
@@ -199,14 +200,14 @@ export async function handleApprovalRunsCommand(
|
||||
|
||||
if (action === "cited-rules") {
|
||||
const recordId = args.command[2];
|
||||
if (!recordId) throw new Error("Usage: seal-use approval-runs cited-rules <recordId>");
|
||||
if (!recordId) throw usageError("Usage: seal-use approval-runs cited-rules <recordId>");
|
||||
await runCapability("sealApprovalRunCitedRulesGet", client, corp, { recordId }, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === "document-summary") {
|
||||
const recordId = args.command[2];
|
||||
if (!recordId) throw new Error("Usage: seal-use approval-runs document-summary <recordId>");
|
||||
if (!recordId) throw usageError("Usage: seal-use approval-runs document-summary <recordId>");
|
||||
await runCapability("sealApprovalRunDocumentSummaryGet", client, corp, { recordId }, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
@@ -215,7 +216,7 @@ export async function handleApprovalRunsCommand(
|
||||
const recordId = args.command[2];
|
||||
const sn = stringOption(args.options.sn) ?? stringOption(args.options["document-sn"]);
|
||||
if (!recordId && !sn) {
|
||||
throw new Error("Usage: seal-use approval-runs diagnose <recordId>|--sn <documentSN> [--full] [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use approval-runs diagnose <recordId>|--sn <documentSN> [--full] [--corp <corpId>]");
|
||||
}
|
||||
await runCapability(
|
||||
"sealApprovalRunDiagnose",
|
||||
@@ -236,9 +237,7 @@ export async function handleApprovalRunsCommand(
|
||||
if (subAction === "download") {
|
||||
const recordId = args.command[3];
|
||||
if (!recordId) {
|
||||
throw new Error(
|
||||
"Usage: seal-use approval-runs attachments download <recordId> [--all] [--name <name>] [--out-dir <dir>]"
|
||||
);
|
||||
throw usageError("Usage: seal-use approval-runs attachments download <recordId> [--all] [--name <name>] [--out-dir <dir>]");
|
||||
}
|
||||
const record = await api.getApprovalRun(client, recordId);
|
||||
const downloadResult = await downloadApprovalRunAttachments({
|
||||
@@ -259,7 +258,7 @@ export async function handleApprovalRunsCommand(
|
||||
}
|
||||
|
||||
const recordId = args.command[2];
|
||||
if (!recordId) throw new Error("Usage: seal-use approval-runs attachments <recordId> | seal-use approval-runs attachments download <recordId>");
|
||||
if (!recordId) throw usageError("Usage: seal-use approval-runs attachments <recordId> | seal-use approval-runs attachments download <recordId>");
|
||||
|
||||
if (booleanOption(args.options.download)) {
|
||||
const record = await api.getApprovalRun(client, recordId);
|
||||
@@ -291,9 +290,7 @@ export async function handleApprovalRunsCommand(
|
||||
if (action === "download") {
|
||||
const recordId = args.command[2];
|
||||
if (!recordId) {
|
||||
throw new Error(
|
||||
"Usage: seal-use approval-runs download <recordId> [--all] [--name <name>] [--out-dir <dir>]"
|
||||
);
|
||||
throw usageError("Usage: seal-use approval-runs download <recordId> [--all] [--name <name>] [--out-dir <dir>]");
|
||||
}
|
||||
const record = await api.getApprovalRun(client, recordId);
|
||||
const downloadResult = await downloadApprovalRunAttachments({
|
||||
@@ -315,7 +312,7 @@ export async function handleApprovalRunsCommand(
|
||||
|
||||
if (action === "result") {
|
||||
const recordId = args.command[2];
|
||||
if (!recordId) throw new Error("Usage: seal-use approval-runs result <recordId> [--summary]");
|
||||
if (!recordId) throw usageError("Usage: seal-use approval-runs result <recordId> [--summary]");
|
||||
await runCapability(
|
||||
"sealApprovalRunResultGet",
|
||||
client,
|
||||
@@ -344,7 +341,7 @@ export async function handleApprovalRunsCommand(
|
||||
const sourceDocumentId = stringOption(args.options.sourceDocumentId);
|
||||
|
||||
if (!recordId && !sn && !sourceDocumentId) {
|
||||
throw new Error("Usage: seal-use approval-runs link <recordId> [--sn <sn>] [--type seal-result|hose-document] [--auto-login] [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use approval-runs link <recordId> [--sn <sn>] [--type seal-result|hose-document] [--auto-login] [--corp <corpId>]");
|
||||
}
|
||||
|
||||
await runCapability(
|
||||
@@ -373,7 +370,7 @@ export async function handleApprovalRunsCommand(
|
||||
stringOption(args.options.id) ??
|
||||
stringOption(args.options.recordId);
|
||||
if (!target) {
|
||||
throw new Error("Usage: seal-use approval-runs hose-flow <recordId|SN>");
|
||||
throw usageError("Usage: seal-use approval-runs hose-flow <recordId|SN>");
|
||||
}
|
||||
|
||||
await runCapability(
|
||||
@@ -451,5 +448,5 @@ export async function handleApprovalRunsCommand(
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown approval-runs command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown approval-runs command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
import { clearCorpTokenCache } from "../../core/auth/token-store.js";
|
||||
import { formatBeijingIso } from "../../core/config/timestamps.js";
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import { CliError, validationError } from "../../core/errors.js";
|
||||
import { CliError, validationError, usageError } from "../../core/errors.js";
|
||||
import { createSealClient, createSealClientForUrl } from "../../core/http/factory.js";
|
||||
import { resolveSealCustomHeaders } from "../../core/http/request-headers.js";
|
||||
import { createDelegation, getMe } from "../../domains/seal/api.js";
|
||||
@@ -26,9 +26,7 @@ import { extractKeysFromLinkAction, showCorpKeysAction } from "./corps.js";
|
||||
export async function handleAuthExtractKeysCommand(maybeName: string | undefined, args: ParsedArgs) {
|
||||
const link = maybeName ?? stringOption(args.options.link) ?? stringOption(args.options.url);
|
||||
if (!link) {
|
||||
throw new Error(
|
||||
"Usage: seal-use auth hose-extract-keys <https://.../web/thirdparty.html?...> [--reveal] [--save] [--name <customName>] [--overwrite]"
|
||||
);
|
||||
throw usageError("Usage: seal-use auth hose-extract-keys <https://.../web/thirdparty.html?...> [--reveal] [--save] [--name <customName>] [--overwrite]");
|
||||
}
|
||||
const reveal =
|
||||
booleanOption(args.options.reveal) === true ||
|
||||
@@ -81,7 +79,7 @@ export async function handleAuthCommand(action: string | undefined, corp: CorpCo
|
||||
}
|
||||
|
||||
if (!corp) {
|
||||
throw new Error(`auth ${action ?? ""} requires an enterprise. Provide --corp <id> or select one.`);
|
||||
throw validationError(`auth ${action ?? ""} requires an enterprise. Provide --corp <id> or select one.`);
|
||||
}
|
||||
|
||||
if (action === "check" || action === "diagnose" || action === "status" || action === "test" || action === "doctor") {
|
||||
@@ -99,7 +97,7 @@ export async function handleAuthCommand(action: string | undefined, corp: CorpCo
|
||||
|
||||
if (subAction === "revoke") {
|
||||
const tokenId = args.command[3] ?? stringOption(args.options.tokenId) ?? stringOption(args.options.id);
|
||||
if (!tokenId) throw new Error("Usage: seal-use auth link revoke <tokenId>");
|
||||
if (!tokenId) throw usageError("Usage: seal-use auth link revoke <tokenId>");
|
||||
await runCapability("sealDelegationRevoke", client, corp, { tokenId }, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
@@ -201,7 +199,7 @@ export async function handleAuthCommand(action: string | undefined, corp: CorpCo
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown auth command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown auth command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
|
||||
async function diagnoseAuth(corp: CorpConfig) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { usageError } from "../../core/errors.js";
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
import { runCapability } from "../helpers.js";
|
||||
@@ -25,5 +26,5 @@ export async function handleBillingCommand(
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown billing command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown billing command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { usageError } from "../../core/errors.js";
|
||||
import {
|
||||
getEnterprisesDirCandidates,
|
||||
loadCorpConfigs,
|
||||
@@ -123,5 +124,5 @@ export function handleConfigCommand(action: string | undefined, maybeName: strin
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown config command: ${action ?? ""}. Available: paths, get, status, mode, lint, test-dir. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown config command: ${action ?? ""}. Available: paths, get, status, mode, lint, test-dir. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { usageError } from "../../core/errors.js";
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
import { runCapability } from "../helpers.js";
|
||||
@@ -27,16 +28,16 @@ export async function handleContactsCommand(
|
||||
}
|
||||
|
||||
if (action === "children" || action === "department-children") {
|
||||
if (!maybeName) throw new Error("Usage: seal-use contacts children <departmentId>");
|
||||
if (!maybeName) throw usageError("Usage: seal-use contacts children <departmentId>");
|
||||
await runCapability("sealContactsDepartmentChildrenList", client, corp, { departmentId: maybeName }, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === "users" || action === "department-users") {
|
||||
if (!maybeName) throw new Error("Usage: seal-use contacts users <departmentId>");
|
||||
if (!maybeName) throw usageError("Usage: seal-use contacts users <departmentId>");
|
||||
await runCapability("sealContactsDepartmentUsersList", client, corp, { departmentId: maybeName }, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown contacts command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown contacts command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { usageError } from "../../core/errors.js";
|
||||
import { handleCorpBindings } from "./corps/bindings.js";
|
||||
import { handleCorpOnboarding, extractKeysFromLinkAction, showCorpKeysAction } from "./corps/onboarding.js";
|
||||
import { handleCorpOverview } from "./corps/overview.js";
|
||||
@@ -17,5 +18,5 @@ export async function handleCorpsCommand(
|
||||
if (await handleCorpSync(action, maybeName, args)) return;
|
||||
if (await handleCorpOnboarding(action, maybeName, args)) return;
|
||||
|
||||
throw new Error(`Unknown corps command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown corps command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { updateCorpConfig } from "../../../core/config/loader.js";
|
||||
import { selectCorp } from "../../helpers.js";
|
||||
import { confirmationRequired, usageError } from "../../errors.js";
|
||||
import { confirmationRequired, usageError } from "../../../core/errors.js";
|
||||
import { booleanOption, stringOption } from "../../parser.js";
|
||||
import { printJson } from "../../printer.js";
|
||||
import type { ParsedArgs } from "../../types.js";
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
formatHoseKeyForOutput,
|
||||
HoseKeySelectionError
|
||||
} from "../../../domains/hose/keys.js";
|
||||
import { CliError } from "../../errors.js";
|
||||
import { CliError, usageError } from "../../../core/errors.js";
|
||||
import { selectCorp } from "../../helpers.js";
|
||||
import {
|
||||
booleanOption,
|
||||
@@ -181,7 +181,7 @@ export async function handleCorpOnboarding(
|
||||
if (action === "add-link") {
|
||||
const link = maybeName ?? stringOption(args.options.link) ?? stringOption(args.options.url);
|
||||
if (!link) {
|
||||
throw new Error("Usage: seal-use corps add-link <url> [--name <customName>] [--elevate-hose] [--overwrite]");
|
||||
throw usageError("Usage: seal-use corps add-link <url> [--name <customName>] [--elevate-hose] [--overwrite]");
|
||||
}
|
||||
const dryRun = booleanOption(args.options["dry-run"]) === true || booleanOption(args.options.dryRun) === true;
|
||||
const legacyAsHose = booleanOption(args.options["as-hose"]) === true || booleanOption(args.options.hose) === true;
|
||||
@@ -211,7 +211,7 @@ export async function handleCorpOnboarding(
|
||||
if (action === "extract-keys" || action === "extract-key" || action === "extract-hose-keys" || action === "hose-extract-keys") {
|
||||
const link = maybeName ?? stringOption(args.options.link) ?? stringOption(args.options.url);
|
||||
if (!link) {
|
||||
throw new Error("Usage: seal-use corps hose-extract-keys <url> [--reveal] [--save] [--app-key <key>] [--key-id <id>] [--name <customName>] [--overwrite]");
|
||||
throw usageError("Usage: seal-use corps hose-extract-keys <url> [--reveal] [--save] [--app-key <key>] [--key-id <id>] [--name <customName>] [--overwrite]");
|
||||
}
|
||||
await extractKeysFromLinkAction(link, {
|
||||
reveal: booleanOption(args.options.reveal) === true || booleanOption(args.options.r) === true || booleanOption(args.options.plain) === true,
|
||||
@@ -250,7 +250,7 @@ export async function handleCorpOnboarding(
|
||||
async function addSealCorp(input: Record<string, unknown>) {
|
||||
const token = requiredString(input, "token");
|
||||
const sealUrl = (optionalString(input, "sealUrl") ?? optionalString(input, "url") ?? "").replace(/\/+$/, "");
|
||||
if (!sealUrl) throw new Error("Missing required JSON field: sealUrl");
|
||||
if (!sealUrl) throw usageError("Missing required JSON field: sealUrl");
|
||||
const result = await onboardSealBearer({
|
||||
...input,
|
||||
token,
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from "../../../core/stats/usage-tracker.js";
|
||||
import type { CorpEnvironment } from "../../../core/config/types.js";
|
||||
import { selectCorp } from "../../helpers.js";
|
||||
import { confirmationRequired, usageError } from "../../errors.js";
|
||||
import { confirmationRequired, usageError } from "../../../core/errors.js";
|
||||
import { booleanOption, numberOption, stringOption } from "../../parser.js";
|
||||
import { printJson } from "../../printer.js";
|
||||
import type { ParsedArgs } from "../../types.js";
|
||||
@@ -192,7 +192,7 @@ export async function handleCorpOverview(
|
||||
(args.command[3] && !args.command[3].startsWith("-") ? args.command[3] : undefined);
|
||||
|
||||
if (!targetCorpId || !newName) {
|
||||
throw new Error("Usage: seal-use corps rename <corpId> --name <newName>");
|
||||
throw usageError("Usage: seal-use corps rename <corpId> --name <newName>");
|
||||
}
|
||||
|
||||
const corp = selectCorp(targetCorpId);
|
||||
@@ -208,7 +208,7 @@ export async function handleCorpOverview(
|
||||
|
||||
if (action === "switch") {
|
||||
const corpId = maybeName;
|
||||
if (!corpId) throw new Error("Usage: seal-use corps switch <corpId>");
|
||||
if (!corpId) throw usageError("Usage: seal-use corps switch <corpId>");
|
||||
const globalConfig = loadGlobalConfig();
|
||||
if (!globalConfig.stateful) {
|
||||
throw new Error(
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { CorpConfig } from "../../../core/config/types.js";
|
||||
import { syncTestEnterprise } from "../../../domains/seal/testing/sync.js";
|
||||
import { executeApprovalRunsReplay, type ReplayRecordsQuery } from "../../../domains/seal/replay/webhook.js";
|
||||
import { selectCorp } from "../../helpers.js";
|
||||
import { CliError, confirmationRequired, usageError } from "../../errors.js";
|
||||
import { CliError, confirmationRequired, usageError } from "../../../core/errors.js";
|
||||
import { booleanOption, numberOption, stringOption } from "../../parser.js";
|
||||
import { outputOptions, printJson } from "../../printer.js";
|
||||
import type { ParsedArgs } from "../../types.js";
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { usageError } from "../../core/errors.js";
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
import { runCapability } from "../helpers.js";
|
||||
@@ -29,5 +30,5 @@ export async function handleDataCommand(
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown data command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown data command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import { outputOptions } from "../printer.js";
|
||||
import type { ParsedArgs } from "../types.js";
|
||||
import * as api from "../../domains/seal/api.js";
|
||||
import { listHoseIntegrations } from "../../domains/seal/outbound/push.js";
|
||||
import { CliError } from "../errors.js";
|
||||
import { CliError, usageError, validationError } from "../../core/errors.js";
|
||||
|
||||
export async function handleDeployCommand(
|
||||
systemOrAction: string | undefined,
|
||||
@@ -18,16 +18,14 @@ export async function handleDeployCommand(
|
||||
args: ParsedArgs
|
||||
) {
|
||||
if (!systemOrAction || systemOrAction === "help") {
|
||||
throw new Error(
|
||||
"Usage: seal-use deploy <system> <action> [options]\n\n" +
|
||||
throw usageError("Usage: seal-use deploy <system> <action> [options]\n\n" +
|
||||
"支持的审批系统与发布目标:\n" +
|
||||
" • hosecloud (合思费控): seal-use deploy hosecloud <requirements|list|get|status|configure|sync> --corp <corpId>\n" +
|
||||
" • webhook (通用审批流回调): seal-use webhook <list|get|add|update|delete> --corp <corpId>\n" +
|
||||
" • feishu (飞书审批): 建议使用 Webhook 模式对接\n" +
|
||||
" • weaver (泛微 OA): 建议使用 Webhook 模式对接\n" +
|
||||
" • helios (汇联易): 建议使用 Webhook 模式对接\n" +
|
||||
" • maycur (每刻报销): 建议使用 Webhook 模式对接"
|
||||
);
|
||||
" • maycur (每刻报销): 建议使用 Webhook 模式对接");
|
||||
}
|
||||
|
||||
if (systemOrAction === "webhook" || systemOrAction === "webhooks") {
|
||||
@@ -52,7 +50,7 @@ export async function handleDeployCommand(
|
||||
const target = systemOrAction === "hosecloud" ? maybeTarget : actionOrTarget;
|
||||
|
||||
if (!isHosecloud) {
|
||||
throw new Error(`未知的发布目标系统: ${systemOrAction}。当前支持: hosecloud (合思费控) 与 webhook (通用回调)。`);
|
||||
throw validationError(`未知的发布目标系统: ${systemOrAction}。当前支持: hosecloud (合思费控) 与 webhook (通用回调)。`);
|
||||
}
|
||||
|
||||
if (action === "requirements") {
|
||||
@@ -108,7 +106,7 @@ export async function handleDeployCommand(
|
||||
? JSON.parse(readFileSync(rawInput, "utf8"))
|
||||
: jsonObject(args.json);
|
||||
if (!payload || Object.keys(payload).length === 0) {
|
||||
throw new Error("Usage: seal-use deploy hosecloud configure --json '{...}' or --input <file>");
|
||||
throw usageError("Usage: seal-use deploy hosecloud configure --json '{...}' or --input <file>");
|
||||
}
|
||||
await runCapability("sealDeployHosecloudConfigure", client, corp, {
|
||||
...payload,
|
||||
@@ -200,6 +198,6 @@ export async function handleDeployCommand(
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown deploy hosecloud action: ${action ?? ""}. Available: requirements, list, get, status, configure, sync, test-outbound.`);
|
||||
throw usageError(`Unknown deploy hosecloud action: ${action ?? ""}. Available: requirements, list, get, status, configure, sync, test-outbound.`);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ export async function handleDoctorCommand(
|
||||
const { selectCorp } = await import("../helpers.js");
|
||||
const { createSealClient } = await import("../../core/http/factory.js");
|
||||
const { stringOption } = await import("../parser.js");
|
||||
const { diagnoseTenantContract, formatTenantDoctorDashboard } = await import("../../core/doctor/tenant-diagnose.js");
|
||||
const { diagnoseTenantContract, formatTenantDoctorDashboard } = await import("../../domains/seal/doctor/tenant-diagnose.js");
|
||||
|
||||
const corpSelector =
|
||||
stringOption(args.options.corp) ??
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
import { confirmationRequired } from "../errors.js";
|
||||
import { confirmationRequired, usageError } from "../../core/errors.js";
|
||||
import { runCapability } from "../helpers.js";
|
||||
import {
|
||||
booleanOption,
|
||||
@@ -55,7 +55,7 @@ export async function handleDocumentsCommand(
|
||||
stringOption(args.options["document-id"]) ??
|
||||
stringOption(args.options.id);
|
||||
if (!documentId) {
|
||||
throw new Error("Usage: seal-use documents get <documentId> [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use documents get <documentId> [--corp <corpId>]");
|
||||
}
|
||||
await runCapability(
|
||||
"sealApprovalDocumentGet",
|
||||
@@ -70,7 +70,7 @@ export async function handleDocumentsCommand(
|
||||
if (action === "search") {
|
||||
const keyword = maybeName ?? stringOption(args.options.query);
|
||||
if (!keyword) {
|
||||
throw new Error("Usage: seal-use documents search <keyword> [--maxResults 20] [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use documents search <keyword> [--maxResults 20] [--corp <corpId>]");
|
||||
}
|
||||
await runCapability(
|
||||
"sealApprovalSearch",
|
||||
@@ -115,9 +115,7 @@ export async function handleDocumentsCommand(
|
||||
(Array.isArray(payload.tags) ? (payload.tags as string[]) : undefined);
|
||||
|
||||
if (!title || !purpose || content === undefined) {
|
||||
throw new Error(
|
||||
"Usage: seal-use documents create --title <title> --purpose <purpose> [--content <text>|--content-file <path>] [--type <policy|document|video|pdf|feishu_doc>] [--scenarios <audit,fill>] [--tags <tag1,tag2>] [--status <published|draft>] [--corp <corpId>]"
|
||||
);
|
||||
throw usageError("Usage: seal-use documents create --title <title> --purpose <purpose> [--content <text>|--content-file <path>] [--type <policy|document|video|pdf|feishu_doc>] [--scenarios <audit,fill>] [--tags <tag1,tag2>] [--status <published|draft>] [--corp <corpId>]");
|
||||
}
|
||||
|
||||
await runCapability(
|
||||
@@ -179,9 +177,7 @@ export async function handleDocumentsCommand(
|
||||
tags !== undefined;
|
||||
|
||||
if (!documentId || !hasChanges) {
|
||||
throw new Error(
|
||||
"Usage: seal-use documents update <documentId> [--title <title>] [--purpose <purpose>] [--content <text>|--content-file <path>] [--type <policy|document|video|pdf|feishu_doc>] [--enabled <true|false>] [--scenarios <audit,fill>] [--tags <tag1,tag2>] [--status <published|draft>] [--corp <corpId>]"
|
||||
);
|
||||
throw usageError("Usage: seal-use documents update <documentId> [--title <title>] [--purpose <purpose>] [--content <text>|--content-file <path>] [--type <policy|document|video|pdf|feishu_doc>] [--enabled <true|false>] [--scenarios <audit,fill>] [--tags <tag1,tag2>] [--status <published|draft>] [--corp <corpId>]");
|
||||
}
|
||||
|
||||
await runCapability(
|
||||
@@ -211,7 +207,7 @@ export async function handleDocumentsCommand(
|
||||
stringOption(args.options["document-id"]) ??
|
||||
stringOption(args.options.id);
|
||||
if (!documentId) {
|
||||
throw new Error("Usage: seal-use documents delete <documentId> --yes [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use documents delete <documentId> --yes [--corp <corpId>]");
|
||||
}
|
||||
const confirmed = booleanOption(args.options.yes) === true || booleanOption(args.options.confirm) === true;
|
||||
if (!confirmed) {
|
||||
@@ -230,5 +226,5 @@ export async function handleDocumentsCommand(
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown documents command: ${action}. Available: list, get, search, create, update, delete.`);
|
||||
throw usageError(`Unknown documents command: ${action}. Available: list, get, search, create, update, delete.`);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
import { CliError } from "../errors.js";
|
||||
import { CliError } from "../../core/errors.js";
|
||||
import { runCapability } from "../helpers.js";
|
||||
import { booleanOption, numberOption, stringOption } from "../parser.js";
|
||||
import { outputOptions } from "../printer.js";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { validationError } from "../../core/errors.js";
|
||||
import { validationError, usageError } from "../../core/errors.js";
|
||||
import { booleanOption, numberOption, splitOption, stringOption } from "../parser.js";
|
||||
import { runLangfuseCapability } from "../helpers.js";
|
||||
import { outputOptions } from "../printer.js";
|
||||
@@ -151,9 +151,7 @@ export async function handleLangfuseCommand(
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`Unknown langfuse command: ${action ?? ""}. Run 'seal-use help' for available commands.`
|
||||
);
|
||||
throw usageError(`Unknown langfuse command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
|
||||
function parseMetadataOption(raw: string | undefined): Record<string, string | number | boolean> | undefined {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { usageError } from "../../core/errors.js";
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
import { runCapability } from "../helpers.js";
|
||||
@@ -20,5 +21,5 @@ export async function handleLlmCommand(
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown llm command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown llm command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { usageError } from "../../core/errors.js";
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
import { runCapability } from "../helpers.js";
|
||||
@@ -20,5 +21,5 @@ export async function handlePermissionsCommand(
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown permissions command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown permissions command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { usageError } from "../../core/errors.js";
|
||||
import { readFileSync } from "node:fs";
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
@@ -27,7 +28,7 @@ export async function handlePreferenceCommand(
|
||||
? JSON.parse(readFileSync(rawInput, "utf8"))
|
||||
: jsonObject(args.json);
|
||||
if (!payload || Object.keys(payload).length === 0) {
|
||||
throw new Error("Usage: seal-use preference decision update --json '{\"explicitApprove\":\"...\"}'");
|
||||
throw usageError("Usage: seal-use preference decision update --json '{\"explicitApprove\":\"...\"}'");
|
||||
}
|
||||
await runCapability("sealPreferenceDecisionUpdate", client, corp, {
|
||||
...payload,
|
||||
@@ -44,7 +45,7 @@ export async function handlePreferenceCommand(
|
||||
stringOption(args.options.level) ??
|
||||
maybeTarget;
|
||||
if (defaultLevel !== "medium" && defaultLevel !== "high") {
|
||||
throw new Error("Usage: seal-use preference thinking-depth set --default <medium|high>");
|
||||
throw usageError("Usage: seal-use preference thinking-depth set --default <medium|high>");
|
||||
}
|
||||
await runCapability("sealPreferenceThinkingDepthSet", client, corp, {
|
||||
defaultLevel,
|
||||
@@ -65,7 +66,7 @@ export async function handlePreferenceCommand(
|
||||
? JSON.parse(readFileSync(rawInput, "utf8"))
|
||||
: jsonObject(args.json);
|
||||
if (!payload || !payload.id || !payload.name) {
|
||||
throw new Error("Usage: seal-use preference thinking-depth policies upsert --json '{\"id\":\"...\",\"name\":\"...\",\"level\":\"high\"}'");
|
||||
throw usageError("Usage: seal-use preference thinking-depth policies upsert --json '{\"id\":\"...\",\"name\":\"...\",\"level\":\"high\"}'");
|
||||
}
|
||||
await runCapability("sealPreferenceThinkingDepthPoliciesUpsert", client, corp, {
|
||||
...payload,
|
||||
@@ -77,7 +78,7 @@ export async function handlePreferenceCommand(
|
||||
if (thirdAction === "remove" || thirdAction === "delete") {
|
||||
const policyId = maybeTarget ?? stringOption(args.options.id) ?? stringOption(args.options.policyId);
|
||||
if (!policyId) {
|
||||
throw new Error("Usage: seal-use preference thinking-depth policies remove <policyId>");
|
||||
throw usageError("Usage: seal-use preference thinking-depth policies remove <policyId>");
|
||||
}
|
||||
await runCapability("sealPreferenceThinkingDepthPoliciesRemove", client, corp, {
|
||||
policyId,
|
||||
@@ -88,5 +89,5 @@ export async function handlePreferenceCommand(
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`Unknown preference action: ${action ?? ""}. Available: get, decision update, thinking-depth set, thinking-depth policies list/upsert/remove.`);
|
||||
throw usageError(`Unknown preference action: ${action ?? ""}. Available: get, decision update, thinking-depth set, thinking-depth policies list/upsert/remove.`);
|
||||
}
|
||||
@@ -78,10 +78,12 @@ export async function handleLocalReportCommand(action: string | undefined, args:
|
||||
}
|
||||
const out = stringOption(args.options.out) ?? stringOption(args.options.o);
|
||||
if (!out) throw usageError(`Usage: seal-use report ${action} <报告文件.md> --out <${action === "export" ? "目标文件夹" : "产物路径词干"}>`);
|
||||
const glossary = args.options["no-glossary"] ? false : booleanOption(args.options.glossary) ?? true;
|
||||
if (action === "export") {
|
||||
const result = await exportReportPackage(file, {
|
||||
out, format: stringOption(args.options.format), width: numberOption(args.options.width),
|
||||
chrome: stringOption(args.options.chrome), overwrite: booleanOption(args.options.overwrite)
|
||||
chrome: stringOption(args.options.chrome), overwrite: booleanOption(args.options.overwrite),
|
||||
glossary
|
||||
});
|
||||
printJson(result, outputOptions(args.options));
|
||||
if (!result.validation.valid) throw new CliError("报告校验未通过,未生成完整导出包。请按 validation.issues 修正后重试。", 1);
|
||||
@@ -89,7 +91,8 @@ export async function handleLocalReportCommand(action: string | undefined, args:
|
||||
}
|
||||
const result = await renderReportFile(file, {
|
||||
out, format: stringOption(args.options.format), width: numberOption(args.options.width),
|
||||
chrome: stringOption(args.options.chrome), overwrite: booleanOption(args.options.overwrite)
|
||||
chrome: stringOption(args.options.chrome), overwrite: booleanOption(args.options.overwrite),
|
||||
glossary
|
||||
});
|
||||
printJson(result, outputOptions(args.options));
|
||||
if (!result.validation.valid) throw new CliError("报告校验未通过,未生成渲染产物。请按 validation.issues 修正后重试。", 1);
|
||||
|
||||
+11
-11
@@ -9,7 +9,7 @@ import {
|
||||
OFFICIAL_LINTERS_DIR
|
||||
} from "../../domains/seal/linter/index.js";
|
||||
import { runCapability, runCapabilityResult } from "../helpers.js";
|
||||
import { confirmationRequired } from "../errors.js";
|
||||
import { confirmationRequired, validationError, usageError } from "../../core/errors.js";
|
||||
import {
|
||||
booleanOption,
|
||||
jsonObject,
|
||||
@@ -58,7 +58,7 @@ export async function handleRulesCommand(
|
||||
// lint, linters, and map actions can run without a network client
|
||||
const clientless = action === "lint" || action === "linters" || action === "linter-list" || action === "map";
|
||||
if (!client && !clientless) {
|
||||
throw new Error(`rules ${action ?? ""} requires an authenticated enterprise. Run 'seal-use corps list' to select one.`);
|
||||
throw validationError(`rules ${action ?? ""} requires an authenticated enterprise. Run 'seal-use corps list' to select one.`);
|
||||
}
|
||||
|
||||
if (action === "count") {
|
||||
@@ -145,7 +145,7 @@ export async function handleRulesCommand(
|
||||
|
||||
if (action === "version") {
|
||||
const version = resolveVersionOption(args, maybeName);
|
||||
if (!version) throw new Error("Usage: seal-use rules version <versionNumber|latest>");
|
||||
if (!version) throw usageError("Usage: seal-use rules version <versionNumber|latest>");
|
||||
await runCapability(
|
||||
"sealApprovalRuleVersionGet",
|
||||
client!,
|
||||
@@ -160,7 +160,7 @@ export async function handleRulesCommand(
|
||||
const from = stringOption(args.options.from) ?? maybeName;
|
||||
const to = stringOption(args.options.to) ?? args.command[3];
|
||||
if (!from || !to) {
|
||||
throw new Error("Usage: seal-use rules diff <fromVersion> <toVersion> [--code <code>] [--full]");
|
||||
throw usageError("Usage: seal-use rules diff <fromVersion> <toVersion> [--code <code>] [--full]");
|
||||
}
|
||||
const singleSelector = args.command[4];
|
||||
await runCapability(
|
||||
@@ -190,7 +190,7 @@ export async function handleRulesCommand(
|
||||
stringOption(args.options.ruleId) ??
|
||||
stringOption(args.options["rule-id"]);
|
||||
if (!target) {
|
||||
throw new Error("Usage: seal-use rules get <code> [--version <number|latest>] [--record-id <recordId>] [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use rules get <code> [--version <number|latest>] [--record-id <recordId>] [--corp <corpId>]");
|
||||
}
|
||||
await runCapability(
|
||||
"sealApprovalRuleGet",
|
||||
@@ -214,7 +214,7 @@ export async function handleRulesCommand(
|
||||
stringOption(args.options.strictness) ??
|
||||
(typeof payload.strictness === "string" ? payload.strictness : "MUST_FOLLOW");
|
||||
if (!description || !scope) {
|
||||
throw new Error("Usage: seal-use rules create --description <text> --scope <scope> [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--description-file <path>] [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use rules create --description <text> --scope <scope> [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--description-file <path>] [--corp <corpId>]");
|
||||
}
|
||||
await runCapability(
|
||||
"sealApprovalRuleCreate",
|
||||
@@ -240,7 +240,7 @@ export async function handleRulesCommand(
|
||||
stringOption(args.options.strictness) ??
|
||||
(typeof payload.strictness === "string" ? payload.strictness : undefined);
|
||||
if (!ruleId || (description === undefined && scope === undefined && strictness === undefined)) {
|
||||
throw new Error("Usage: seal-use rules update <code> [--description <text>|--description-file <path>] [--scope <scope>] [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use rules update <code> [--description <text>|--description-file <path>] [--scope <scope>] [--strictness <MUST_FOLLOW|SHOULD_FOLLOW|SUGGESTION>] [--corp <corpId>]");
|
||||
}
|
||||
await runCapability(
|
||||
"sealApprovalRuleUpdate",
|
||||
@@ -259,7 +259,7 @@ export async function handleRulesCommand(
|
||||
stringOption(args.options["rule-id"]) ??
|
||||
stringOption(args.options.code);
|
||||
if (!ruleId) {
|
||||
throw new Error("Usage: seal-use rules delete <code> --yes [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use rules delete <code> --yes [--corp <corpId>]");
|
||||
}
|
||||
const confirmed = booleanOption(args.options.yes) === true || booleanOption(args.options.confirm) === true;
|
||||
if (!confirmed) {
|
||||
@@ -287,7 +287,7 @@ export async function handleRulesCommand(
|
||||
stringOption(args.options.name) ??
|
||||
(typeof payload.versionName === "string" ? payload.versionName : undefined);
|
||||
if (!versionName) {
|
||||
throw new Error("Usage: seal-use rules publish <versionName> [--corp <corpId>]");
|
||||
throw usageError("Usage: seal-use rules publish <versionName> [--corp <corpId>]");
|
||||
}
|
||||
await runCapability(
|
||||
"sealApprovalRuleVersionPublish",
|
||||
@@ -301,7 +301,7 @@ export async function handleRulesCommand(
|
||||
|
||||
if (action === "search") {
|
||||
const keyword = maybeName ?? stringOption(args.options.query);
|
||||
if (!keyword) throw new Error("Usage: seal-use rules search <keyword> [--version <number|latest>] [--maxResults 20] [--corp <corpId>]");
|
||||
if (!keyword) throw usageError("Usage: seal-use rules search <keyword> [--version <number|latest>] [--maxResults 20] [--corp <corpId>]");
|
||||
await runCapability(
|
||||
"sealApprovalSearch",
|
||||
client!,
|
||||
@@ -465,5 +465,5 @@ export async function handleRulesCommand(
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown rules command: ${action ?? ""}. Available: count, list, get, search, create, update, delete, publish, versions, version, diff, lint, linters, pull, push, clear, map. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown rules command: ${action ?? ""}. Available: count, list, get, search, create, update, delete, publish, versions, version, diff, lint, linters, pull, push, clear, map. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
import { confirmationRequired } from "../errors.js";
|
||||
import { confirmationRequired, usageError, validationError } from "../../core/errors.js";
|
||||
import { runCapability, runCapabilityResult } from "../helpers.js";
|
||||
import {
|
||||
booleanOption,
|
||||
@@ -22,7 +22,7 @@ export async function handleSimulationCommand(
|
||||
) {
|
||||
if (action === "batch-records" || action === "records") {
|
||||
const batchId = maybeName ?? stringOption(args.options.batchId) ?? stringOption(args.options["batch-id"]);
|
||||
if (!batchId) throw new Error("Usage: seal-use simulation batch-records <batchId>");
|
||||
if (!batchId) throw usageError("Usage: seal-use simulation batch-records <batchId>");
|
||||
await runCapability(
|
||||
"sealSimulationBatchRecordsGet",
|
||||
client,
|
||||
@@ -142,7 +142,7 @@ export async function handleSimulationCommand(
|
||||
|
||||
if (action === "wait") {
|
||||
const batchId = maybeName ?? stringOption(args.options.batchId) ?? stringOption(args.options["batch-id"]);
|
||||
if (!batchId) throw new Error("Usage: seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s]");
|
||||
if (!batchId) throw usageError("Usage: seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s]");
|
||||
await runCapability(
|
||||
"sealSimulationBatchWait",
|
||||
client,
|
||||
@@ -159,7 +159,7 @@ export async function handleSimulationCommand(
|
||||
|
||||
if (action === "status") {
|
||||
const batchId = maybeName ?? stringOption(args.options.batchId) ?? stringOption(args.options["batch-id"]);
|
||||
if (!batchId) throw new Error("Usage: seal-use simulation status <batchId>");
|
||||
if (!batchId) throw usageError("Usage: seal-use simulation status <batchId>");
|
||||
await runCapability(
|
||||
"sealSimulationBatchStatus",
|
||||
client,
|
||||
@@ -172,7 +172,7 @@ export async function handleSimulationCommand(
|
||||
|
||||
if (action === "clean" || action === "delete") {
|
||||
const batchId = maybeName ?? stringOption(args.options.batchId) ?? stringOption(args.options["batch-id"]);
|
||||
if (!batchId) throw new Error("Usage: seal-use simulation clean <batchId> --yes");
|
||||
if (!batchId) throw usageError("Usage: seal-use simulation clean <batchId> --yes");
|
||||
const confirmed = booleanOption(args.options.yes) === true || booleanOption(args.options.confirm) === true;
|
||||
if (!confirmed) {
|
||||
throw confirmationRequired(
|
||||
@@ -220,7 +220,7 @@ export async function handleSimulationCommand(
|
||||
|
||||
if (action === "get") {
|
||||
const batchId = maybeName ?? stringOption(args.options.batchId) ?? stringOption(args.options["batch-id"]);
|
||||
if (!batchId) throw new Error("Usage: seal-use simulation get <batchId>");
|
||||
if (!batchId) throw usageError("Usage: seal-use simulation get <batchId>");
|
||||
await runCapability("sealSimulationBatchGet", client, corp, { batchId }, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
@@ -237,11 +237,11 @@ export async function handleSimulationCommand(
|
||||
|
||||
if (action === "package-upload") {
|
||||
const filePath = maybeName ?? stringOption(args.options.file);
|
||||
if (!filePath) throw new Error("Usage: seal-use simulation package-upload <材料包.zip>");
|
||||
if (!existsSync(filePath)) throw new Error(`File not found: ${filePath}`);
|
||||
if (!filePath) throw usageError("Usage: seal-use simulation package-upload <材料包.zip>");
|
||||
if (!existsSync(filePath)) throw validationError(`File not found: ${filePath}`);
|
||||
await runCapability("sealSimulationMaterialPackageUpload", client, corp, { filePath }, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown simulation command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown simulation command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { usageError } from "../../core/errors.js";
|
||||
import { existsSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import {
|
||||
@@ -66,5 +67,5 @@ export function handleSkillCommand(action: string | undefined, maybeName: string
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown skill command: ${action}. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown skill command: ${action}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { usageError } from "../../core/errors.js";
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import { resolveLiveSealEnterpriseConfig } from "../../domains/seal/enterprise/source.js";
|
||||
import { printJson } from "../printer.js";
|
||||
@@ -8,5 +9,5 @@ export async function handleSourceCommand(action: string | undefined, corp: Corp
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown source command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown source command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CliError } from "../errors.js";
|
||||
import { CliError } from "../../core/errors.js";
|
||||
import { selectCorp } from "../helpers.js";
|
||||
import { booleanOption, numberOption, stringOption } from "../parser.js";
|
||||
import { printJson } from "../printer.js";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import type { createSealClient } from "../../core/http/factory.js";
|
||||
import { confirmationRequired } from "../errors.js";
|
||||
import { confirmationRequired, usageError } from "../../core/errors.js";
|
||||
import { runCapability } from "../helpers.js";
|
||||
import { booleanOption, parseDelegationExpireHours, stringOption } from "../parser.js";
|
||||
import { outputOptions } from "../printer.js";
|
||||
@@ -16,7 +16,7 @@ export async function handleUsersCommand(
|
||||
if (action === "create") {
|
||||
const name = stringOption(args.options.name) ?? maybeName;
|
||||
const phone = stringOption(args.options.phone);
|
||||
if (!name || !phone) throw new Error("Usage: seal-use users create --name <name> --phone <phone> [--dept <deptId>]");
|
||||
if (!name || !phone) throw usageError("Usage: seal-use users create --name <name> --phone <phone> [--dept <deptId>]");
|
||||
const deptId = stringOption(args.options.dept) ?? stringOption(args.options.departmentId);
|
||||
const departmentIds = deptId ? [deptId] : undefined;
|
||||
await runCapability("sealUserCreate", client, corp, { name, phone, departmentIds }, outputOptions(args.options));
|
||||
@@ -25,7 +25,7 @@ export async function handleUsersCommand(
|
||||
|
||||
if (action === "reset-password") {
|
||||
const userId = maybeName ?? stringOption(args.options.userId);
|
||||
if (!userId) throw new Error("Usage: seal-use users reset-password <userId> --yes");
|
||||
if (!userId) throw usageError("Usage: seal-use users reset-password <userId> --yes");
|
||||
const confirmed = booleanOption(args.options.yes) === true || booleanOption(args.options.confirm) === true;
|
||||
if (!confirmed) {
|
||||
throw confirmationRequired(
|
||||
@@ -45,14 +45,14 @@ export async function handleUsersCommand(
|
||||
|
||||
if (action === "get") {
|
||||
const userId = maybeName ?? stringOption(args.options.userId);
|
||||
if (!userId) throw new Error("Usage: seal-use users get <userId>");
|
||||
if (!userId) throw usageError("Usage: seal-use users get <userId>");
|
||||
await runCapability("sealUserGet", client, corp, { userId }, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === "delete") {
|
||||
const userId = maybeName ?? stringOption(args.options.userId);
|
||||
if (!userId) throw new Error("Usage: seal-use users delete <userId> --yes");
|
||||
if (!userId) throw usageError("Usage: seal-use users delete <userId> --yes");
|
||||
const confirmed = booleanOption(args.options.yes) === true || booleanOption(args.options.confirm) === true;
|
||||
if (!confirmed) {
|
||||
throw confirmationRequired(
|
||||
@@ -66,14 +66,14 @@ export async function handleUsersCommand(
|
||||
|
||||
if (action === "activate") {
|
||||
const userId = maybeName ?? stringOption(args.options.userId);
|
||||
if (!userId) throw new Error("Usage: seal-use users activate <userId>");
|
||||
if (!userId) throw usageError("Usage: seal-use users activate <userId>");
|
||||
await runCapability("sealUserActivate", client, corp, { userId }, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === "delegation" || action === "impersonate") {
|
||||
const userIdOrPhone = maybeName ?? stringOption(args.options.userId) ?? stringOption(args.options.phone);
|
||||
if (!userIdOrPhone) throw new Error("Usage: seal-use users delegation <userIdOrPhone> [--note <note>] [--expire <duration>]");
|
||||
if (!userIdOrPhone) throw usageError("Usage: seal-use users delegation <userIdOrPhone> [--note <note>] [--expire <duration>]");
|
||||
const note = stringOption(args.options.note);
|
||||
const expireOption = args.options.expire ?? args.options["expires-in"] ?? args.options.expiresIn;
|
||||
const expiresInHours = parseDelegationExpireHours(expireOption, 24);
|
||||
@@ -87,5 +87,5 @@ export async function handleUsersCommand(
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown users command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown users command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
+11
-13
@@ -32,13 +32,13 @@ import {
|
||||
import { outputOptions, printJson } from "../printer.js";
|
||||
import type { ParsedArgs } from "../types.js";
|
||||
import type { MaterialPackFilePolicyPatch } from "../../domains/seal/material-pack/policy.js";
|
||||
import { CliError, confirmationRequired, usageError, validationError } from "../errors.js";
|
||||
import { CliError, confirmationRequired, usageError, validationError } from "../../core/errors.js";
|
||||
|
||||
export async function handleWebhookResourcePackPreview(
|
||||
filePath: string,
|
||||
filePolicy?: MaterialPackFilePolicyPatch
|
||||
) {
|
||||
if (!existsSync(filePath)) throw new Error(`File not found: ${filePath}`);
|
||||
if (!existsSync(filePath)) throw validationError(`File not found: ${filePath}`);
|
||||
const input = readMaterialPackFile(filePath);
|
||||
printJson(await previewMaterialPack(input.fileBuffer, input.fileName, filePolicy));
|
||||
}
|
||||
@@ -110,9 +110,7 @@ export async function handleWebhookCommand(
|
||||
const endDate = stringOption(args.options.endDate) ?? stringOption(args.options["end-date"]);
|
||||
|
||||
if (!recordId && !recordIds && !sn && !sns && limit === undefined) {
|
||||
throw new Error(
|
||||
"Usage: seal-use webhook replay <recordId> [--sn <documentSN>] [--limit <n>] [--status <status>] [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>] [--dry-run]"
|
||||
);
|
||||
throw usageError("Usage: seal-use webhook replay <recordId> [--sn <documentSN>] [--limit <n>] [--status <status>] [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>] [--dry-run]");
|
||||
}
|
||||
|
||||
const sourceCorpId =
|
||||
@@ -317,14 +315,14 @@ export async function handleWebhookCommand(
|
||||
? stringOption(args.options.file) ?? stringOption(args.options.input)
|
||||
: args.command[3] ?? stringOption(args.options.file) ?? stringOption(args.options.input);
|
||||
|
||||
if (!filePath) throw new Error("Usage: seal-use webhook resource-pack <export|preview|push> [options]");
|
||||
if (!existsSync(filePath)) throw new Error(`File not found: ${filePath}`);
|
||||
if (!filePath) throw usageError("Usage: seal-use webhook resource-pack <export|preview|push> [options]");
|
||||
if (!existsSync(filePath)) throw validationError(`File not found: ${filePath}`);
|
||||
const input = readMaterialPackFile(filePath);
|
||||
if (operation === "preview") {
|
||||
printJson(await previewMaterialPack(input.fileBuffer, input.fileName), outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
if (operation !== "push") throw new Error("Usage: seal-use webhook resource-pack <export|preview|push> [options]");
|
||||
if (operation !== "push") throw usageError("Usage: seal-use webhook resource-pack <export|preview|push> [options]");
|
||||
const selector = stringOption(args.options.webhook) ?? stringOption(args.options.selector);
|
||||
const integrations = await api.listWebhookIntegrations(client, corp.seal.endpoints.approvalStylePreferences);
|
||||
let integration: WebhookIntegration;
|
||||
@@ -370,7 +368,7 @@ export async function handleWebhookCommand(
|
||||
|
||||
if (action === "get" || action === "find") {
|
||||
const selector = maybeName ?? stringOption(args.options.selector) ?? stringOption(args.options.id);
|
||||
if (!selector) throw new Error("Usage: seal-use webhook get <idOrName> [--show-secret]");
|
||||
if (!selector) throw usageError("Usage: seal-use webhook get <idOrName> [--show-secret]");
|
||||
await runCapability(
|
||||
"sealWebhookGet",
|
||||
client,
|
||||
@@ -392,7 +390,7 @@ export async function handleWebhookCommand(
|
||||
stringOption(args.options.outgoingResultWebhook) ??
|
||||
stringOption(args.options["outgoing-result-webhook"]);
|
||||
if (!name || !outgoingResultWebhook) {
|
||||
throw new Error("Usage: seal-use webhook add --name <name> --result-url <url> [--mode assisted|semi_automatic|fully_automatic]");
|
||||
throw usageError("Usage: seal-use webhook add --name <name> --result-url <url> [--mode assisted|semi_automatic|fully_automatic]");
|
||||
}
|
||||
const autoApprovalRate = webhookRateOption(args.options);
|
||||
const materialPackFilePolicy = materialPackFilePolicyOptions(args.options);
|
||||
@@ -417,7 +415,7 @@ export async function handleWebhookCommand(
|
||||
|
||||
if (action === "update") {
|
||||
const selector = maybeName ?? stringOption(args.options.selector) ?? stringOption(args.options.id);
|
||||
if (!selector) throw new Error("Usage: seal-use webhook update <idOrName> [options]");
|
||||
if (!selector) throw usageError("Usage: seal-use webhook update <idOrName> [options]");
|
||||
const secret = stringOption(args.options.secret);
|
||||
const rotateSecret = booleanOption(args.options.rotateSecret) ?? booleanOption(args.options["rotate-secret"]);
|
||||
if (secret !== undefined && rotateSecret) {
|
||||
@@ -468,7 +466,7 @@ export async function handleWebhookCommand(
|
||||
if (action === "delete") {
|
||||
const selector = maybeName ?? stringOption(args.options.selector) ?? stringOption(args.options.id);
|
||||
const dryRun = booleanOption(args.options.dryRun) ?? booleanOption(args.options["dry-run"]);
|
||||
if (!selector) throw new Error("Usage: seal-use webhook delete <idOrName> [--yes|--dry-run]");
|
||||
if (!selector) throw usageError("Usage: seal-use webhook delete <idOrName> [--yes|--dry-run]");
|
||||
if (booleanOption(args.options.yes) !== true && !dryRun) {
|
||||
throw confirmationRequired(
|
||||
"Refusing to delete Webhook integration without --yes",
|
||||
@@ -489,5 +487,5 @@ export async function handleWebhookCommand(
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown webhook command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown webhook command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
// Re-export from core — this file is the legacy entry point.
|
||||
// Domain-layer code should import from "../core/errors.js" directly.
|
||||
export {
|
||||
type CliExitCode,
|
||||
CliError,
|
||||
PayloadTooLargeError,
|
||||
usageError,
|
||||
validationError,
|
||||
safetyBlocked,
|
||||
confirmationRequired,
|
||||
classifyCliError
|
||||
} from "../core/errors.js";
|
||||
+5
-6
@@ -1,5 +1,6 @@
|
||||
import { normalizeCliArea } from "./area-aliases.js";
|
||||
import type { ParsedArgs } from "./types.js";
|
||||
import { usageError } from "./errors.js";
|
||||
import { usageError } from "../core/errors.js";
|
||||
|
||||
export interface CommandOptionHelp {
|
||||
flag: string;
|
||||
@@ -706,6 +707,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{ flag: "--format <format>", description: "all (default), html, png, or pdf; PNG/PDF also produce HTML" },
|
||||
{ flag: "--width <px>", description: "PNG viewport width, default 1200 (320–5000)" },
|
||||
{ flag: "--chrome <executable>", description: "Chrome/Chromium executable; otherwise auto-detected" },
|
||||
{ flag: "--no-glossary", description: "Omit the trailing terms definition and calculation standards appendix" },
|
||||
{ flag: "--overwrite", description: "Explicitly permit replacing existing output files after successful rendering" }
|
||||
],
|
||||
description: "No enterprise login. Validation failure produces JSON issues and no artifacts. Validation and HTML use the bundled runtime; PNG/PDF need Chrome/Chromium. No Python or Pillow required. First use of math fetches and caches KaTeX resources. Markdown parsing is bundled, with no runtime npm/npx dependency."
|
||||
@@ -719,6 +721,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
{ flag: "--format <format>", description: "all (default), html, or pdf" },
|
||||
{ flag: "--width <px>", description: "PNG viewport width, default 1200" },
|
||||
{ flag: "--chrome <executable>", description: "Chrome/Chromium executable; otherwise auto-detected" },
|
||||
{ flag: "--no-glossary", description: "Omit the trailing terms definition and calculation standards appendix" },
|
||||
{ flag: "--overwrite", description: "Explicitly permit replacing existing output files" }
|
||||
],
|
||||
description: "Bundles the report into a clean single directory: includes the Markdown with its .md.assets/ companion folder, plus self-contained HTML and print-ready PDF."
|
||||
@@ -1637,14 +1640,10 @@ export function renderHelp(target: string[] = []): string {
|
||||
}
|
||||
|
||||
function normalizeArea(area: string): string {
|
||||
const lower = area.toLowerCase();
|
||||
if (lower === "corp") return "corps";
|
||||
if (lower === "webhooks") return "webhook";
|
||||
if (lower === "preferences") return "preference";
|
||||
const lower = normalizeCliArea(area);
|
||||
if (lower === "changelog") return "update";
|
||||
if (lower === "serve") return "http";
|
||||
if (lower === "mcp-config") return "mcp";
|
||||
if (lower === "server") return "mcp";
|
||||
return lower;
|
||||
}
|
||||
|
||||
|
||||
+22
-16
@@ -1,6 +1,5 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { HELP_REGISTRY } from "./help.js";
|
||||
import {
|
||||
booleanOption,
|
||||
BOOLEAN_FLAGS,
|
||||
@@ -203,23 +202,30 @@ describe("option helpers", () => {
|
||||
|
||||
describe("flag registry cross-check", () => {
|
||||
test("every flag documented in help.ts is registered", () => {
|
||||
const help = readFileSync(join(import.meta.dirname, "help.ts"), "utf-8");
|
||||
const documented = new Set(
|
||||
[...help.matchAll(/flag: "--([a-z][a-z0-9-]*)"/g)].map((match) => match[1]!)
|
||||
);
|
||||
for (const flag of documented) {
|
||||
expect(KNOWN_FLAGS.has(flag)).toBe(true);
|
||||
}
|
||||
const documented = new Set(HELP_REGISTRY.flatMap((area) => area.commands.flatMap((command) =>
|
||||
(command.options ?? []).flatMap((option) => [...option.flag.matchAll(/--([a-zA-Z][a-zA-Z0-9-]*)/g)].map((match) => match[1]!))
|
||||
)));
|
||||
expect([...documented].filter((flag) => !KNOWN_FLAGS.has(flag))).toEqual([]);
|
||||
expect(documented.size).toBeGreaterThanOrEqual(20);
|
||||
});
|
||||
|
||||
test("every flag shown in a help usage line is registered", () => {
|
||||
const help = readFileSync(join(import.meta.dirname, "help.ts"), "utf-8");
|
||||
const usageFlags = new Set(
|
||||
[...help.matchAll(/ --([a-z][a-z0-9-]*)/g)].map((match) => match[1]!)
|
||||
);
|
||||
const missing = [...usageFlags].filter((flag) => !KNOWN_FLAGS.has(flag));
|
||||
expect(missing).toEqual([]);
|
||||
test("every flag shown in a help usage line is registered, including bracket and pipe forms", () => {
|
||||
const usageFlags = new Set(HELP_REGISTRY.flatMap((area) => area.commands.flatMap((command) =>
|
||||
command.usage.flatMap((usage) => [...usage.matchAll(/--([a-zA-Z][a-zA-Z0-9-]*)/g)].map((match) => match[1]!))
|
||||
)));
|
||||
expect([...usageFlags].filter((flag) => !KNOWN_FLAGS.has(flag))).toEqual([]);
|
||||
});
|
||||
|
||||
test("formerly rejected public flags retain their boolean and value arity", () => {
|
||||
const parsed = parseArgs(["report", "data", "--templates", "one,two", "--latest", "record"]);
|
||||
expect(parsed.options).toEqual({ templates: "one,two", latest: true });
|
||||
expect(parsed.command).toEqual(["report", "data", "record"]);
|
||||
expect(parseArgs(["config", "test-dir", "--clear"]).options.clear).toBe(true);
|
||||
expect(parseArgs(["webhook", "get", "id", "--show-secret"]).options["show-secret"]).toBe(true);
|
||||
expect(parseArgs(["webhook", "update", "id", "--min-file-size", "10", "--clear-max-file-size"]).options)
|
||||
.toEqual({ "min-file-size": "10", "clear-max-file-size": true });
|
||||
expect(() => parseArgs(["report", "data", "--templates"])).toThrow("requires a value");
|
||||
expect(() => parseArgs(["corps", "list", "--limitt=5"])).toThrow("Unknown option: --limitt");
|
||||
});
|
||||
|
||||
test("boolean and value sets partition the registry apart from the ambiguous three", () => {
|
||||
|
||||
+18
-62
@@ -2,7 +2,7 @@ import type { WebhookMode } from "../domains/seal/types.js";
|
||||
import type { MaterialPackFilePolicyPatch } from "../domains/seal/material-pack/policy.js";
|
||||
import type { ParsedArgs } from "./types.js";
|
||||
import { type DurationToken, EXPIRE_UNITS, expireSeconds, tokenizeDuration } from "../core/duration.js";
|
||||
import { usageError } from "./errors.js";
|
||||
import { usageError, validationError } from "../core/errors.js";
|
||||
|
||||
/**
|
||||
* Flag metadata for argv parsing, derived from how the code reads each flag:
|
||||
@@ -23,13 +23,14 @@ import { usageError } from "./errors.js";
|
||||
|
||||
// Read with booleanOption(...) / Boolean(...) / presence check.
|
||||
export const BOOLEAN_FLAGS = new Set([
|
||||
"clear", "clear-max-file-size", "clearMaxFileSize", "latest", "show-secret", "showSecret",
|
||||
"V", "add", "all", "allow-unreviewed", "allowUnreviewed", "as-hose", "attachments", "auto",
|
||||
"auto-login", "autoLogin", "bg-save", "changelog", "check", "check-only",
|
||||
"completed-only", "completedOnly", "confirm", "count", "disable-attachment-cache", "disableAttachmentCache",
|
||||
"download", "downloads", "dry-run", "dryRun", "elevate-hose", "enabled",
|
||||
"exclude-deleted", "extract", "extract-expenses", "extractExpenses", "fail-on-flips", "flow", "force", "full", "has-input", "has-output", "help",
|
||||
"exclude-deleted", "extract", "extract-expenses", "extractExpenses", "fail-on-flips", "flow", "force", "full", "glossary", "has-input", "has-output", "help",
|
||||
"hose", "hose-outbound", "hose-sso", "hoseOutbound", "hoseSso", "include-deleted", "include-io-preview", "include-simulation", "include-unchanged",
|
||||
"includeBridge", "includeSimulation", "includeUnchanged", "local", "no-attachments", "no-flow",
|
||||
"includeBridge", "includeSimulation", "includeUnchanged", "local", "no-attachments", "no-flow", "no-glossary",
|
||||
"no-wait", "noWait", "outbound", "overwrite", "plain", "publish", "quiet",
|
||||
"r", "recode", "refresh", "refresh-if-missing", "reveal", "rotate-secret", "rotateSecret",
|
||||
"save", "silent", "silent-save", "simulation", "skip-expense-extraction", "skip-extract", "skip-invoice-generation",
|
||||
@@ -40,6 +41,9 @@ export const BOOLEAN_FLAGS = new Set([
|
||||
|
||||
// Read with stringOption/numberOption/splitOption(...).
|
||||
export const VALUE_FLAGS = new Set([
|
||||
"allowed-extensions", "allowedExtensions", "extensions", "auto-approval-rate", "autoApprovalRate", "approval-rate",
|
||||
"min-file-size", "min-file-size-bytes", "minFileSize", "minFileSizeBytes",
|
||||
"max-file-size", "max-file-size-bytes", "maxFileSize", "maxFileSizeBytes", "templates",
|
||||
"access-token", "accessToken", "action", "add-approver-ids", "addApproverIds", "ai", "ai-accuracy", "aiAccuracy", "app-key", "app-security", "appKey", "appSecurity",
|
||||
"base-url", "batch", "batch-id", "batchId", "both", "both-accurate", "bothAccurate", "business-codes", "businessCodes",
|
||||
"channel", "chrome", "code", "comment", "concurrency", "confirm-code", "confirmCode", "content", "content-file", "content-hints", "content-type", "contentFile",
|
||||
@@ -86,60 +90,9 @@ export const VALUE_FLAGS = new Set([
|
||||
|
||||
// Registered flags. Unknown flags are rejected.
|
||||
export const KNOWN_FLAGS = new Set([
|
||||
"V", "access-token", "accessToken", "action", "add-approver-ids", "addApproverIds", "ai", "ai-accuracy", "aiAccuracy", "add", "all", "allow-unreviewed", "allowUnreviewed", "app-key",
|
||||
"app-security", "appKey", "appSecurity", "as-hose", "attachments", "auto",
|
||||
"auto-login", "autoLogin", "base-url", "batch", "batch-id", "batchId",
|
||||
"bg-save", "both", "both-accurate", "bothAccurate", "business-codes", "businessCodes", "channel", "changelog", "check", "check-only", "chrome",
|
||||
"code", "comment", "completed-only", "completedOnly", "concurrency", "confirm", "confirm-code", "confirmCode", "content",
|
||||
"content-file", "content-hints", "content-type", "contentFile", "contentType", "context-chars", "contextLines", "corp",
|
||||
"corp-id", "corpId", "corporation-id", "corporationId", "count", "date", "dedupe-by", "dedupeBy",
|
||||
"default", "departmentId", "dept", "desc", "description", "description-file",
|
||||
"descriptionFile", "dir", "disable-attachment-cache", "disableAttachmentCache", "doc-id-prefix", "doc-id-suffix",
|
||||
"docIdPrefix", "docIdSuffix", "document-id", "document-sn", "document-sns", "document-type",
|
||||
"documentId", "documentLimit", "documentSn", "documentType", "domain", "download",
|
||||
"downloads", "dry-run", "dryRun", "elevate-hose", "enable", "enabled",
|
||||
"end", "end-date", "end-time", "endDate", "endTime", "env",
|
||||
"environment", "exclude-deleted", "extract", "extract-expenses", "extractExpenses", "expire", "expires-in", "expiresIn", "f", "fail-on-flips",
|
||||
"fields", "file", "file-id", "file-name", "flow", "flow-concurrency", "flow-id", "flow-ids", "flow-status-list",
|
||||
"flowId", "flowIds", "flowStatusList", "force", "format", "from", "from-link",
|
||||
"full", "h", "has-input", "has-output", "help", "hose", "hose-outbound", "hose-sso", "hoseOutbound", "hoseSso",
|
||||
"host", "human", "human-accuracy", "humanAccuracy", "humanResult", "id", "include-deleted", "include-io-preview", "include-simulation", "include-unchanged",
|
||||
"includeBridge", "includeSimulation", "includeUnchanged", "input", "integration", "json",
|
||||
"json-path", "key-id", "keyId", "keyword", "ledger", "level", "limit", "lines",
|
||||
"link", "linter", "local", "manual-status", "manualApprovalStatus", "manualStatus",
|
||||
"max-chars", "max-preview-chars", "maxChars", "maxResults", "max-results", "message-id", "messageId", "metadata", "metadata-key", "min-score", "minScore", "mode",
|
||||
"max-runs",
|
||||
"month",
|
||||
"n", "name", "name-contains", "no-attachments", "no-flow", "no-wait", "noWait", "node-id", "nodeId",
|
||||
"note", "observation-id", "observation-types", "o", "offset", "out", "out-dir", "outDir", "outbound",
|
||||
"outgoing-result-webhook", "outgoingResultWebhook", "output", "output-file", "outputFile", "overwrite",
|
||||
"p", "package-id", "package-ids", "packageId", "packageIds", "path",
|
||||
"phone", "plain", "policy", "policyId", "poll-interval", "pollInterval", "port",
|
||||
"prod", "prod-corp", "prodCorp", "publish", "purpose", "q",
|
||||
"query", "quiet", "r", "recode", "record-id", "record-ids",
|
||||
"recordId", "recordIds", "refresh", "refresh-if-missing", "reject-node", "rejectNode", "reject-to", "rejectTo", "rejection-num", "rejectionNum", "repo",
|
||||
"report-id",
|
||||
"request-ids", "requestIds", "resubmit-method", "resubmitMethod", "result-url", "resultUrl", "reuse-window", "reuseWindow",
|
||||
"reviewed-by", "reviewedBy",
|
||||
"reveal", "rotate-secret", "rotateSecret", "rule", "rule-hints", "rule-id", "ruleId",
|
||||
"ruleVersion", "runtime-id", "runtimeId", "samples", "save", "scenarios",
|
||||
"schema-config", "schemaConfig", "scope", "sealUrl", "search", "secret",
|
||||
"selector", "session-id", "sign-key", "signKey", "silent", "silent-save", "simulation",
|
||||
"simulationBatchId", "since", "skip-expense-extraction", "skip-extract", "skip-invoice-generation", "skipExpenseExtraction", "skipExtract", "skipInvoiceGeneration",
|
||||
"sn", "sn-prefix", "sn-suffix", "snPrefix", "snSuffix", "snippet-only",
|
||||
"snippetOnly", "sns", "source-corp", "source-system", "sourceCorp", "sourceDocumentId",
|
||||
"sourceDocumentSN", "sourceSystem", "sso", "staff-id", "staff-name", "staff-phone",
|
||||
"staffId", "staffName", "staffPhone", "start", "start-date", "start-time",
|
||||
"startDate", "startTime", "state", "status", "strict", "strictness",
|
||||
"summary", "tag", "tag-id", "tagId", "tags", "target",
|
||||
"template",
|
||||
"target-corp", "targetCorp", "task-mode", "taskMode", "template-id", "templateId",
|
||||
"test-corp", "thinking-depth", "thinkingDepth", "timeout", "timezone", "title",
|
||||
"to", "to-downloads", "toDownloads", "token", "tokenId", "trace-id", "trace-limit", "type",
|
||||
"until", "url", "userId", "v", "version", "version-name",
|
||||
"verdict",
|
||||
"versionName", "wait", "webhook", "width", "with-expense-extraction", "withExpenseExtraction", "with-flow", "workflow-type-id", "workflowTypeId",
|
||||
"workspace", "yes"
|
||||
...BOOLEAN_FLAGS,
|
||||
...VALUE_FLAGS,
|
||||
"f", "h", "version"
|
||||
]);
|
||||
|
||||
export function parseArgs(argv: string[]): ParsedArgs {
|
||||
@@ -170,6 +123,9 @@ export function parseArgs(argv: string[]): ParsedArgs {
|
||||
const key = raw.slice(0, eqIdx);
|
||||
const val = raw.slice(eqIdx + 1);
|
||||
if (key === "python") throw usageError("--python 已移除:报告工具不再依赖 Python。");
|
||||
if (!KNOWN_FLAGS.has(key)) {
|
||||
throw usageError(`Unknown option: --${key}.${suggestFlag(key)}`);
|
||||
}
|
||||
options[key] = val;
|
||||
continue;
|
||||
}
|
||||
@@ -283,7 +239,7 @@ export function booleanOption(value: string | boolean | undefined): boolean | un
|
||||
|
||||
export function requiredString(input: Record<string, unknown>, key: string): string {
|
||||
const value = optionalString(input, key);
|
||||
if (!value) throw new Error(`Missing required JSON field: ${key}`);
|
||||
if (!value) throw usageError(`Missing required JSON field: ${key}`);
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -292,7 +248,7 @@ export function requiredStringAlias(input: Record<string, unknown>, keys: string
|
||||
const value = optionalString(input, key);
|
||||
if (value) return value;
|
||||
}
|
||||
throw new Error(`Missing required JSON field: ${keys.join(" or ")}`);
|
||||
throw usageError(`Missing required JSON field: ${keys.join(" or ")}`);
|
||||
}
|
||||
|
||||
export function optionalString(input: Record<string, unknown>, key: string): string | undefined {
|
||||
@@ -318,7 +274,7 @@ export function parseStateMode(value: string): boolean {
|
||||
const normalized = value.trim().toLowerCase();
|
||||
if (["stateful", "state", "有状态"].includes(normalized)) return true;
|
||||
if (["stateless", "无状态"].includes(normalized)) return false;
|
||||
throw new Error("Invalid config mode. Use stateful or stateless.");
|
||||
throw validationError("Invalid config mode. Use stateful or stateless.");
|
||||
}
|
||||
|
||||
export function parseRuleVersionSelector(value: string) {
|
||||
@@ -388,7 +344,7 @@ export function parseWebhookMode(value?: string): WebhookMode | undefined {
|
||||
};
|
||||
const mode = aliases[normalized];
|
||||
if (!mode) {
|
||||
throw new Error("Invalid Webhook mode. Use assisted, semi_automatic, or fully_automatic");
|
||||
throw validationError("Invalid Webhook mode. Use assisted, semi_automatic, or fully_automatic");
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
@@ -398,7 +354,7 @@ export function webhookRateOption(options: Record<string, string | boolean>): nu
|
||||
options.autoApprovalRate ?? options["auto-approval-rate"] ?? options["approval-rate"]
|
||||
);
|
||||
if (value !== undefined && (!Number.isInteger(value) || value < 0 || value > 100)) {
|
||||
throw new Error("Webhook auto approval rate must be an integer between 0 and 100");
|
||||
throw validationError("Webhook auto approval rate must be an integer between 0 and 100");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { writeFileSync } from "node:fs";
|
||||
import { booleanOption, stringOption } from "./parser.js";
|
||||
import { PayloadTooLargeError } from "./errors.js";
|
||||
import { PayloadTooLargeError } from "../core/errors.js";
|
||||
import { redactSensitiveText } from "../core/redact.js";
|
||||
import type { OutputOptions } from "./types.js";
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { normalizeCliArea } from "./area-aliases.js";
|
||||
import { parseArgs } from "./parser.js";
|
||||
|
||||
/**
|
||||
@@ -12,13 +13,6 @@ import { parseArgs } from "./parser.js";
|
||||
* Prefix matching is boundary-safe by construction: `list-evil` does not match `list`.
|
||||
*/
|
||||
|
||||
/** Area aliases the CLI dispatches under an alternative name; mirrors the pairs in runner.ts. */
|
||||
const AREA_ALIASES: Record<string, string> = {
|
||||
corp: "corps",
|
||||
webhooks: "webhook",
|
||||
preferences: "preference"
|
||||
};
|
||||
|
||||
/**
|
||||
* Commands that only read tenant state, produce a local file, or inspect local configuration.
|
||||
* Deliberately excluded even though they look harmless: anything that writes local config
|
||||
@@ -122,7 +116,7 @@ export function describeCliCommand(argv: string[]): { area: string; actionTokens
|
||||
const { command } = parseArgs(argv);
|
||||
const area = (command[0] ?? "").toLowerCase();
|
||||
return {
|
||||
area: AREA_ALIASES[area] ?? area,
|
||||
area: normalizeCliArea(area),
|
||||
actionTokens: command.slice(1).map((token) => token.toLowerCase())
|
||||
};
|
||||
}
|
||||
|
||||
+119
-227
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
|
||||
import type { CorpConfig } from "../core/config/types.js";
|
||||
import { VERSION_INFO } from "../version.js";
|
||||
import { isUpdateCacheExpired, loadUpdateCache, triggerBackgroundUpdateCheck } from "../core/update-cache.js";
|
||||
import { classifyCliError } from "./errors.js";
|
||||
import { classifyCliError, usageError } from "../core/errors.js";
|
||||
import {
|
||||
booleanOption,
|
||||
materialPackFilePolicyOptions,
|
||||
@@ -22,52 +22,70 @@ import {
|
||||
printJson,
|
||||
redactSensitiveText
|
||||
} from "./printer.js";
|
||||
import type { CliResult, CliRunOptions, CliRuntime } from "./types.js";
|
||||
import type { KyInstance } from "ky";
|
||||
import type { ParsedArgs, CliResult, CliRunOptions, CliRuntime } from "./types.js";
|
||||
|
||||
const DEFAULT_APP_ROOT = dirname(dirname(dirname(fileURLToPath(import.meta.url))));
|
||||
export const UPDATE_ALIASES = new Set([
|
||||
"update",
|
||||
"upgrade",
|
||||
"up",
|
||||
"self-update",
|
||||
"selfupdate"
|
||||
]);
|
||||
export { UPDATE_ALIASES } from "./area-aliases.js";
|
||||
import { AREA_ALIASES, normalizeCliArea, UPDATE_ALIASES } from "./area-aliases.js";
|
||||
|
||||
type LocalCommand = (args: ParsedArgs, runtime: CliRuntime) => Promise<void>;
|
||||
type CorpCommand = (args: ParsedArgs, corp: CorpConfig) => Promise<void>;
|
||||
type ClientCommand = (args: ParsedArgs, corp: CorpConfig, client: KyInstance) => Promise<void>;
|
||||
|
||||
// Handler tables also define the known command surface. Imports stay lazy so
|
||||
// local discovery never loads the tenant, Excel, or zip implementation graphs.
|
||||
const LOCAL_COMMANDS: Record<string, LocalCommand> = {
|
||||
"mcp-config": async () => (await import("./commands/mcp.js")).printMcpConfig(),
|
||||
skill: async (args) => (await import("./commands/skill.js")).handleSkillCommand(args.command[1], args.command[2], args),
|
||||
mcp: async (args) => (await import("./commands/mcp.js")).handleMcpCommand(args.command[1]),
|
||||
probe: async (args) => (await import("./commands/probe.js")).handleProbeCommand(args.command[1], args.command[2], args),
|
||||
doctor: async (args) => (await import("./commands/doctor.js")).handleDoctorCommand(args.command[1], args.command[2], args),
|
||||
langfuse: async (args) => (await import("./commands/langfuse.js")).handleLangfuseCommand(args.command[1], args.command[2], args),
|
||||
test: async (args) => (await import("./commands/test.js")).handleTestCommand(args.command[1], args.command[2], args),
|
||||
config: async (args) => (await import("./commands/config.js")).handleConfigCommand(args.command[1], args.command[2], args),
|
||||
update: dispatchUpdate,
|
||||
changelog: dispatchUpdate,
|
||||
corps: async (args) => {
|
||||
const action = args.command[1];
|
||||
if (action === "regression" || action === "test-regression") {
|
||||
await (await import("./commands/test.js")).handleTestCommand("regression", args.command[2], args);
|
||||
return;
|
||||
}
|
||||
await (await import("./commands/corps.js")).handleCorpsCommand(action, args.command[2], args);
|
||||
}
|
||||
};
|
||||
|
||||
const CORP_COMMANDS: Record<string, CorpCommand> = {
|
||||
source: async (args, corp) => (await import("./commands/source.js")).handleSourceCommand(args.command[1], corp),
|
||||
auth: async (args, corp) => (await import("./commands/auth.js")).handleAuthCommand(args.command[1], corp, args)
|
||||
};
|
||||
|
||||
const CLIENT_COMMANDS: Record<string, ClientCommand> = {
|
||||
"users": async (args, corp, client) => (await import("./commands/users.js")).handleUsersCommand(args.command[1], args.command[2], client, corp, args),
|
||||
"contacts": async (args, corp, client) => (await import("./commands/contacts.js")).handleContactsCommand(args.command[1], args.command[2], client, corp, args),
|
||||
"data": async (args, corp, client) => (await import("./commands/data.js")).handleDataCommand(args.command[1], client, corp, args),
|
||||
"llm": async (args, corp, client) => (await import("./commands/llm.js")).handleLlmCommand(args.command[1], client, corp, args),
|
||||
"permissions": async (args, corp, client) => (await import("./commands/permissions.js")).handlePermissionsCommand(args.command[1], client, corp, args),
|
||||
"billing": async (args, corp, client) => (await import("./commands/billing.js")).handleBillingCommand(args.command[1], client, corp, args),
|
||||
"webhook": async (args, corp, client) => (await import("./commands/webhook.js")).handleWebhookCommand(args.command[1], args.command[2], client, corp, args),
|
||||
"context": async (args, corp, client) => (await import("./commands/context.js")).handleContextCommand(client, corp, args),
|
||||
"documents": async (args, corp, client) => (await import("./commands/documents.js")).handleDocumentsCommand(args.command[1], args.command[2], client, corp, args),
|
||||
"rules": async (args, corp, client) => (await import("./commands/rules.js")).handleRulesCommand(args.command[1], args.command[2], client, corp, args),
|
||||
"approval-runs": async (args, corp, client) => (await import("./commands/approval-runs.js")).handleApprovalRunsCommand(args.command[1], args.command[2], client, corp, args),
|
||||
"analytics": async (args, corp, client) => (await import("./commands/analytics.js")).handleAnalyticsCommand(args.command[1], args.command[2], client, corp, args),
|
||||
"report": async (args, corp, client) => (await import("./commands/report.js")).handleReportCommand(args.command[1], client, corp, args),
|
||||
"simulation": async (args, corp, client) => (await import("./commands/simulation.js")).handleSimulationCommand(args.command[1], args.command[2], client, corp, args),
|
||||
"deploy": async (args, corp, client) => (await import("./commands/deploy.js")).handleDeployCommand(args.command[1], args.command[2], args.command[3], client, corp, args),
|
||||
"hose-ebot": async (args, corp, client) => (await import("./commands/hose-ebot.js")).handleHoseEbotCommand(args.command[1], args.command[2], client, corp, args),
|
||||
"preference": async (args, corp, client) => (await import("./commands/preference.js")).handlePreferenceCommand(args.command[1], args.command[2], args.command[3], args.command[4], client, corp, args),
|
||||
};
|
||||
|
||||
export const KNOWN_AREAS = new Set([
|
||||
"config",
|
||||
"update",
|
||||
"corps",
|
||||
"corp",
|
||||
"source",
|
||||
"hose-ebot",
|
||||
"auth",
|
||||
"users",
|
||||
"contacts",
|
||||
"data",
|
||||
"llm",
|
||||
"permissions",
|
||||
"billing",
|
||||
"webhook",
|
||||
"webhooks",
|
||||
"context",
|
||||
"documents",
|
||||
"rules",
|
||||
"approval-runs",
|
||||
"analytics",
|
||||
"report",
|
||||
"simulation",
|
||||
"deploy",
|
||||
"preference",
|
||||
"preferences",
|
||||
"mcp",
|
||||
"server",
|
||||
"mcp-config",
|
||||
"skill",
|
||||
"probe",
|
||||
"doctor",
|
||||
"langfuse",
|
||||
"changelog",
|
||||
"test"
|
||||
...Object.keys(LOCAL_COMMANDS),
|
||||
...Object.keys(CORP_COMMANDS),
|
||||
...Object.keys(CLIENT_COMMANDS),
|
||||
...Object.keys(AREA_ALIASES)
|
||||
]);
|
||||
|
||||
export type { CliResult, CliRunOptions } from "./types.js";
|
||||
@@ -140,12 +158,53 @@ async function runCliOnce(argv: string[], options: CliRunOptions): Promise<CliRe
|
||||
}
|
||||
}
|
||||
|
||||
async function dispatchUpdate(args: ParsedArgs, runtime: CliRuntime): Promise<void> {
|
||||
const [rawArea, action] = args.command;
|
||||
const isUpdate = rawArea ? UPDATE_ALIASES.has(rawArea.toLowerCase()) : false;
|
||||
const area = rawArea?.toLowerCase();
|
||||
if (isUpdate && rawArea !== "update") {
|
||||
console.error(`⚠️ Notice: '${rawArea}' is an alias for 'seal-use update'. Please use 'seal-use update' instead.`);
|
||||
}
|
||||
|
||||
const lowerAction = action?.toLowerCase();
|
||||
const isChangelog =
|
||||
area === "changelog" ||
|
||||
lowerAction === "changelog" ||
|
||||
lowerAction === "log" ||
|
||||
lowerAction === "history" ||
|
||||
booleanOption(args.options.changelog) === true;
|
||||
|
||||
const isCheck =
|
||||
lowerAction === "check" ||
|
||||
booleanOption(args.options.check) === true ||
|
||||
booleanOption(args.options["check-only"]) === true;
|
||||
|
||||
const isBgSave =
|
||||
booleanOption(args.options["bg-save"]) === true ||
|
||||
booleanOption(args.options["silent-save"]) === true;
|
||||
|
||||
const targetVersion =
|
||||
stringOption(args.options.version) ??
|
||||
stringOption(args.options.tag) ??
|
||||
(!isChangelog && !isCheck && !isBgSave && action && !action.startsWith("-") ? action : undefined);
|
||||
|
||||
await (await import("./commands/update.js")).handleUpdateCommand(runtime, {
|
||||
checkOnly: isCheck || isBgSave,
|
||||
changelogOnly: isChangelog,
|
||||
limit: numberOption(args.options.limit),
|
||||
force: booleanOption(args.options.force),
|
||||
targetVersion,
|
||||
repo: stringOption(args.options.repo),
|
||||
bgSave: isBgSave
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
async function dispatch(argv: string[], runtime: CliRuntime) {
|
||||
const args = parseArgs(argv);
|
||||
const [rawArea, action, maybeName] = args.command;
|
||||
const lowerArea = rawArea?.toLowerCase();
|
||||
const isUpdate = lowerArea ? UPDATE_ALIASES.has(lowerArea) : false;
|
||||
const area = isUpdate ? "update" : lowerArea;
|
||||
const area = lowerArea ? normalizeCliArea(lowerArea) : undefined;
|
||||
|
||||
if (
|
||||
area === "version" ||
|
||||
@@ -186,7 +245,7 @@ async function dispatch(argv: string[], runtime: CliRuntime) {
|
||||
}
|
||||
|
||||
if (!area || !KNOWN_AREAS.has(area)) {
|
||||
throw new Error(`Unknown command: ${args.command.join(" ")}. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown command: ${args.command.join(" ")}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -195,36 +254,11 @@ async function dispatch(argv: string[], runtime: CliRuntime) {
|
||||
maybeName === "preview"
|
||||
) {
|
||||
const filePath = args.command[3] ?? stringOption(args.options.file) ?? stringOption(args.options.input);
|
||||
if (!filePath) throw new Error("Usage: seal-use webhook resource-pack preview <资源包.zip>");
|
||||
if (!filePath) throw usageError("Usage: seal-use webhook resource-pack preview <资源包.zip>");
|
||||
await (await import("./commands/webhook.js")).handleWebhookResourcePackPreview(filePath, materialPackFilePolicyOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "mcp-config") {
|
||||
(await import("./commands/mcp.js")).printMcpConfig();
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "skill") {
|
||||
(await import("./commands/skill.js")).handleSkillCommand(action, maybeName, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "mcp" || area === "server") {
|
||||
await (await import("./commands/mcp.js")).handleMcpCommand(action);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "probe") {
|
||||
await (await import("./commands/probe.js")).handleProbeCommand(action, maybeName, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "doctor") {
|
||||
await (await import("./commands/doctor.js")).handleDoctorCommand(action, maybeName, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
area === "report" &&
|
||||
(action === "validate" ||
|
||||
@@ -239,69 +273,11 @@ async function dispatch(argv: string[], runtime: CliRuntime) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Langfuse trace inspection needs no tenant: it authenticates with the
|
||||
// compile-time injected read-only key pair, so it dispatches before corp
|
||||
// selection (like probe/doctor) and never touches a Seal client.
|
||||
if (area === "langfuse") {
|
||||
await (await import("./commands/langfuse.js")).handleLangfuseCommand(action, maybeName, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "test") {
|
||||
await (await import("./commands/test.js")).handleTestCommand(action, maybeName, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "config") {
|
||||
(await import("./commands/config.js")).handleConfigCommand(action, maybeName, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isUpdate || area === "changelog") {
|
||||
if (isUpdate && rawArea !== "update") {
|
||||
console.error(`⚠️ Notice: '${rawArea}' is an alias for 'seal-use update'. Please use 'seal-use update' instead.`);
|
||||
}
|
||||
|
||||
const lowerAction = action?.toLowerCase();
|
||||
const isChangelog =
|
||||
area === "changelog" ||
|
||||
lowerAction === "changelog" ||
|
||||
lowerAction === "log" ||
|
||||
lowerAction === "history" ||
|
||||
booleanOption(args.options.changelog) === true;
|
||||
|
||||
const isCheck =
|
||||
lowerAction === "check" ||
|
||||
booleanOption(args.options.check) === true ||
|
||||
booleanOption(args.options["check-only"]) === true;
|
||||
|
||||
const isBgSave =
|
||||
booleanOption(args.options["bg-save"]) === true ||
|
||||
booleanOption(args.options["silent-save"]) === true;
|
||||
|
||||
const targetVersion =
|
||||
stringOption(args.options.version) ??
|
||||
stringOption(args.options.tag) ??
|
||||
(!isChangelog && !isCheck && !isBgSave && action && !action.startsWith("-") ? action : undefined);
|
||||
|
||||
await (await import("./commands/update.js")).handleUpdateCommand(runtime, {
|
||||
checkOnly: isCheck || isBgSave,
|
||||
changelogOnly: isChangelog,
|
||||
limit: numberOption(args.options.limit),
|
||||
force: booleanOption(args.options.force),
|
||||
targetVersion,
|
||||
repo: stringOption(args.options.repo),
|
||||
bgSave: isBgSave
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "corps" || area === "corp") {
|
||||
if (action === "regression" || action === "test-regression") {
|
||||
await (await import("./commands/test.js")).handleTestCommand("regression", maybeName, args);
|
||||
return;
|
||||
}
|
||||
await (await import("./commands/corps.js")).handleCorpsCommand(action, maybeName, args);
|
||||
// These handlers intentionally run before enterprise selection, including
|
||||
// Langfuse's compile-time credentials and purely local discovery commands.
|
||||
const localCommand = LOCAL_COMMANDS[area];
|
||||
if (localCommand) {
|
||||
await localCommand(args, runtime);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -339,102 +315,18 @@ async function dispatch(argv: string[], runtime: CliRuntime) {
|
||||
|
||||
const corp = (await import("./helpers.js")).selectCorp(stringOption(args.options.corp));
|
||||
|
||||
if (area === "source") {
|
||||
await (await import("./commands/source.js")).handleSourceCommand(action, corp);
|
||||
const corpCommand = CORP_COMMANDS[area];
|
||||
if (corpCommand) {
|
||||
await corpCommand(args, corp);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "auth") {
|
||||
await (await import("./commands/auth.js")).handleAuthCommand(action, corp, args);
|
||||
const clientCommand = CLIENT_COMMANDS[area];
|
||||
if (clientCommand) {
|
||||
const client = await (await import("../core/http/factory.js")).createSealClient(corp);
|
||||
await clientCommand(args, corp, client);
|
||||
return;
|
||||
}
|
||||
|
||||
const client = await (await import("../core/http/factory.js")).createSealClient(corp);
|
||||
|
||||
if (area === "users") {
|
||||
await (await import("./commands/users.js")).handleUsersCommand(action, maybeName, client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "contacts") {
|
||||
await (await import("./commands/contacts.js")).handleContactsCommand(action, maybeName, client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "data") {
|
||||
await (await import("./commands/data.js")).handleDataCommand(action, client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "llm") {
|
||||
await (await import("./commands/llm.js")).handleLlmCommand(action, client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "permissions") {
|
||||
await (await import("./commands/permissions.js")).handlePermissionsCommand(action, client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "billing") {
|
||||
await (await import("./commands/billing.js")).handleBillingCommand(action, client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "webhook" || area === "webhooks") {
|
||||
await (await import("./commands/webhook.js")).handleWebhookCommand(action, maybeName, client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "context") {
|
||||
await (await import("./commands/context.js")).handleContextCommand(client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "documents") {
|
||||
await (await import("./commands/documents.js")).handleDocumentsCommand(action, maybeName, client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "rules") {
|
||||
await (await import("./commands/rules.js")).handleRulesCommand(action, maybeName, client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "approval-runs") {
|
||||
await (await import("./commands/approval-runs.js")).handleApprovalRunsCommand(action, maybeName, client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "analytics") {
|
||||
await (await import("./commands/analytics.js")).handleAnalyticsCommand(action, maybeName, client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "report") {
|
||||
await (await import("./commands/report.js")).handleReportCommand(action, client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "simulation") {
|
||||
await (await import("./commands/simulation.js")).handleSimulationCommand(action, maybeName, client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "deploy") {
|
||||
await (await import("./commands/deploy.js")).handleDeployCommand(action, maybeName, args.command[3], client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "hose-ebot") {
|
||||
await (await import("./commands/hose-ebot.js")).handleHoseEbotCommand(action, maybeName, client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "preference" || area === "preferences") {
|
||||
await (await import("./commands/preference.js")).handlePreferenceCommand(action, maybeName, args.command[3], args.command[4], client, corp, args);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown command: ${args.command.join(" ")}. Run 'seal-use help' for available commands.`);
|
||||
throw usageError(`Unknown command: ${args.command.join(" ")}. Run 'seal-use help' for available commands.`);
|
||||
}
|
||||
+3
-2
@@ -3,6 +3,7 @@
|
||||
* reach the CLI intact. Lives in its own module because both the MCP server and the HTTP routes
|
||||
* need it; importing it from the server entry would make the CLI graph circular.
|
||||
*/
|
||||
import { usageError } from "../core/errors.js";
|
||||
export function tokenizeCommand(command: string): string[] {
|
||||
const tokens: string[] = [];
|
||||
let token = "";
|
||||
@@ -53,8 +54,8 @@ export function tokenizeCommand(command: string): string[] {
|
||||
tokenStarted = true;
|
||||
}
|
||||
|
||||
if (escaped) throw new Error("Invalid command: trailing escape");
|
||||
if (quote) throw new Error("Invalid command: unterminated quote");
|
||||
if (escaped) throw usageError("Invalid command: trailing escape");
|
||||
if (quote) throw usageError("Invalid command: unterminated quote");
|
||||
if (tokenStarted) tokens.push(token);
|
||||
return tokens;
|
||||
}
|
||||
|
||||
+18
-4
@@ -5,6 +5,7 @@ import { clearSealSession, getSealSession, setSealSession } from "./token-store.
|
||||
import { SealEnterpriseConfig, SealSession } from "./types.js";
|
||||
|
||||
const memoryCache = new Map<string, SealSession>();
|
||||
const pendingSessions = new Map<string, Promise<SealSession>>();
|
||||
|
||||
function isExpired(session: SealSession, refreshTtl: number): boolean {
|
||||
return Date.now() >= session.expiresAt - refreshTtl * 1000;
|
||||
@@ -32,10 +33,15 @@ export async function getSealSessionForCorp(corp: CorpConfig): Promise<SealSessi
|
||||
return stored;
|
||||
}
|
||||
|
||||
const next = await refreshSealSession(corp);
|
||||
memoryCache.set(corp.id, next);
|
||||
setSealSession(corp.id, next);
|
||||
return next;
|
||||
const pending = pendingSessions.get(corp.id);
|
||||
if (pending) return pending;
|
||||
const request = refreshSealSession(corp).then((next) => {
|
||||
memoryCache.set(corp.id, next);
|
||||
setSealSession(corp.id, next);
|
||||
return next;
|
||||
}).finally(() => pendingSessions.delete(corp.id));
|
||||
pendingSessions.set(corp.id, request);
|
||||
return request;
|
||||
}
|
||||
|
||||
export async function resolveSealEnterpriseConfig(
|
||||
@@ -48,3 +54,11 @@ export function clearSealToken(corpId: string): void {
|
||||
memoryCache.delete(corpId);
|
||||
clearSealSession(corpId);
|
||||
}
|
||||
|
||||
/** Reuse a concurrent refresh rather than invalidating a newer session on a late 401. */
|
||||
export async function recoverSealSessionForCorp(corp: CorpConfig, rejectedToken: string): Promise<SealSession> {
|
||||
const current = await getSealSessionForCorp(corp);
|
||||
if (current.token !== rejectedToken) return current;
|
||||
clearSealToken(corp.id);
|
||||
return getSealSessionForCorp(corp);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { afterEach, describe, expect, test } from "bun:test";
|
||||
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { chmodSync, mkdtempSync, rmSync, statSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import {
|
||||
@@ -80,6 +80,17 @@ describe("token-store", () => {
|
||||
expect(getSealSession("corp-1")).toBeUndefined();
|
||||
});
|
||||
|
||||
test.skipIf(process.platform === "win32")("tightens an existing token store without losing other corp caches", () => {
|
||||
const path = makeTempStore();
|
||||
const cache = { openapi: { token: "fixture-token", expiresAt: Date.now() + 3600000 } };
|
||||
setHoseAuthCache("other", cache);
|
||||
chmodSync(path, 0o644);
|
||||
setHoseAuthCache("target", cache);
|
||||
expect(statSync(path).mode & 0o777).toBe(0o600);
|
||||
expect(getHoseAuthCache("other")).toEqual(cache);
|
||||
expect(getHoseAuthCache("target")).toEqual(cache);
|
||||
});
|
||||
|
||||
test("sets, retrieves, and clears hose auth cache", () => {
|
||||
makeTempStore();
|
||||
const hoseCache = {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { writeSecureFile } from "../secure-file.js";
|
||||
import { SEAL_CONFIG_DIR } from "../paths.js";
|
||||
import {
|
||||
CorpTokenCache,
|
||||
@@ -41,8 +42,7 @@ function readStore(): TokenStore {
|
||||
|
||||
function writeStore(store: TokenStore): void {
|
||||
const path = resolveWriteStorePath();
|
||||
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
|
||||
writeFileSync(path, JSON.stringify(store, null, 2), { mode: 0o600 });
|
||||
writeSecureFile(path, JSON.stringify(store, null, 2));
|
||||
}
|
||||
|
||||
export function getSealSession(corpId: string): SealSession | undefined {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { afterEach, describe, expect, test } from "bun:test";
|
||||
import { existsSync, mkdirSync, mkdtempSync, rmSync, utimesSync, writeFileSync } from "node:fs";
|
||||
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, utimesSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { saveCorpConfig } from "./repository.js";
|
||||
import {
|
||||
findCorpConfigFile,
|
||||
getLastCorpConfigLoadIssues,
|
||||
@@ -118,6 +119,61 @@ describe("loadCorpConfigs", () => {
|
||||
expect(corps.map((corp) => corp.id).sort()).toEqual(["test-corp", "user-corp"].sort());
|
||||
});
|
||||
|
||||
test("updates the same user override that reads select", () => {
|
||||
delete process.env.SEAL_USE_ENTERPRISES_DIR;
|
||||
delete process.env.SEAL_HOME_ENTERPRISES_DIR;
|
||||
const testDir = makeTempDir();
|
||||
const userDir = makeTempDir();
|
||||
process.env.SEAL_USE_USER_ENTERPRISES_DIR = userDir;
|
||||
process.env.SEAL_USE_CONFIG_FILE = join(makeTempDir(), "config.json");
|
||||
saveGlobalConfig({ testEnterprisesDir: testDir });
|
||||
const testPath = join(testDir, "corp.json");
|
||||
const userPath = join(userDir, "corp.json");
|
||||
writeCorpConfig(testPath, "duplicate", "Test copy");
|
||||
writeCorpConfig(userPath, "duplicate", "User copy");
|
||||
|
||||
expect(loadCorpConfigs()[0]?.name).toBe("User copy");
|
||||
expect(findCorpConfigFile("duplicate")).toBe(userPath);
|
||||
updateCorpConfig("duplicate", { name: "Renamed" });
|
||||
expect(loadCorpConfigs()[0]?.name).toBe("Renamed");
|
||||
expect(JSON.parse(readFileSync(testPath, "utf8")).name).toBe("Test copy");
|
||||
});
|
||||
|
||||
test("same-directory duplicates and invalid shadows use the selected valid file", () => {
|
||||
const dir = makeTempDir();
|
||||
process.env.SEAL_USE_ENTERPRISES_DIR = dir;
|
||||
writeCorpConfig(join(dir, "a.json"), "duplicate", "First");
|
||||
const selected = join(dir, "b.json");
|
||||
writeCorpConfig(selected, "duplicate", "Second");
|
||||
writeFileSync(join(dir, "z-invalid.json"), JSON.stringify({ id: "duplicate" }));
|
||||
expect(findCorpConfigFile("duplicate")).toBe(selected);
|
||||
updateCorpConfig("duplicate", { name: "Updated" });
|
||||
expect(loadCorpConfigs()[0]?.name).toBe("Updated");
|
||||
expect(JSON.parse(readFileSync(join(dir, "a.json"), "utf8")).name).toBe("First");
|
||||
});
|
||||
|
||||
test.skipIf(process.platform === "win32")("credential updates and overwrites tighten existing files", () => {
|
||||
const dir = makeTempDir();
|
||||
process.env.SEAL_USE_ENTERPRISES_DIR = dir;
|
||||
const path = join(dir, "alpha.json");
|
||||
writeCorpConfig(path, "alpha", "Alpha");
|
||||
chmodSync(path, 0o644);
|
||||
const config = updateCorpConfig("alpha", { name: "Updated" });
|
||||
expect(statSync(path).mode & 0o777).toBe(0o600);
|
||||
chmodSync(path, 0o644);
|
||||
saveCorpConfig(config, { overwrite: true });
|
||||
expect(statSync(path).mode & 0o777).toBe(0o600);
|
||||
const globalPath = join(dir, "global-config");
|
||||
process.env.SEAL_USE_CONFIG_FILE = globalPath;
|
||||
writeFileSync(globalPath, "{}");
|
||||
chmodSync(globalPath, 0o644);
|
||||
saveGlobalConfig({ stateful: false });
|
||||
expect(statSync(globalPath).mode & 0o777).toBe(0o600);
|
||||
const migratedDir = makeTempDir();
|
||||
syncLegacyEnterprisesDir(migratedDir, dir);
|
||||
expect(statSync(join(migratedDir, "alpha.json")).mode & 0o777).toBe(0o600);
|
||||
});
|
||||
|
||||
test("defaults global config to stateless", () => {
|
||||
process.env.SEAL_USE_CONFIG_FILE = join(makeTempDir(), "config.json");
|
||||
|
||||
|
||||
+15
-28
@@ -1,8 +1,10 @@
|
||||
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
||||
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { dirname, join } from "node:path";
|
||||
import { join } from "node:path";
|
||||
import { CorpConfig, CorpConfigSchema, GlobalConfig, GlobalConfigInput, GlobalConfigSchema } from "./types.js";
|
||||
|
||||
import { writeSecureFile } from "../secure-file.js";
|
||||
|
||||
const CONFIG_ENV = "SEAL_USE_ENTERPRISES_DIR";
|
||||
const LEGACY_CONFIG_ENV = "SEAL_HOME_ENTERPRISES_DIR";
|
||||
const USER_DIR_ENV = "SEAL_USE_USER_ENTERPRISES_DIR";
|
||||
@@ -39,13 +41,13 @@ export function syncLegacyEnterprisesDir(
|
||||
const primaryPath = join(primaryDir, file);
|
||||
|
||||
if (!existsSync(primaryPath)) {
|
||||
copyFileSync(legacyPath, primaryPath);
|
||||
writeSecureFile(primaryPath, readFileSync(legacyPath));
|
||||
copied.push(file);
|
||||
} else {
|
||||
const legacyMtime = statSync(legacyPath).mtimeMs;
|
||||
const primaryMtime = statSync(primaryPath).mtimeMs;
|
||||
if (legacyMtime > primaryMtime) {
|
||||
copyFileSync(legacyPath, primaryPath);
|
||||
writeSecureFile(primaryPath, readFileSync(legacyPath));
|
||||
copied.push(file);
|
||||
}
|
||||
}
|
||||
@@ -103,8 +105,12 @@ export function getLastCorpConfigLoadIssues(): CorpConfigLoadIssue[] {
|
||||
}
|
||||
|
||||
export function loadCorpConfigs(): CorpConfig[] {
|
||||
return loadCorpConfigEntries().map((entry) => entry.config);
|
||||
}
|
||||
|
||||
function loadCorpConfigEntries(): Array<{ config: CorpConfig; path: string }> {
|
||||
const dirs = resolveEnterprisesDirs();
|
||||
const byId = new Map<string, CorpConfig>();
|
||||
const byId = new Map<string, { config: CorpConfig; path: string }>();
|
||||
const issues: CorpConfigLoadIssue[] = [];
|
||||
|
||||
for (const dir of dirs) {
|
||||
@@ -120,7 +126,7 @@ export function loadCorpConfigs(): CorpConfig[] {
|
||||
issues.push({ dir, file, reason: error instanceof Error ? error.message : String(error) });
|
||||
continue;
|
||||
}
|
||||
byId.set(corp.id, corp);
|
||||
byId.set(corp.id, { config: corp, path: fullPath });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,31 +247,12 @@ export function saveGlobalConfig(config: GlobalConfigInput): GlobalConfig {
|
||||
const normalized = GlobalConfigSchema.parse(config);
|
||||
const configured = (process.env[GLOBAL_CONFIG_ENV] ?? process.env[LEGACY_GLOBAL_CONFIG_ENV])?.trim();
|
||||
const file = configured || PRIMARY_GLOBAL_CONFIG_FILE;
|
||||
mkdirSync(dirname(file), { recursive: true, mode: 0o700 });
|
||||
writeFileSync(file, `${JSON.stringify(normalized, null, 2)}\n`, { mode: 0o600 });
|
||||
writeSecureFile(file, `${JSON.stringify(normalized, null, 2)}\n`);
|
||||
return normalized;
|
||||
}
|
||||
|
||||
export function findCorpConfigFile(corpId: string): string | undefined {
|
||||
const dirs = resolveEnterprisesDirs();
|
||||
for (const dir of dirs) {
|
||||
if (!existsSync(dir)) continue;
|
||||
for (const file of readdirSync(dir)
|
||||
.filter((item) => item.endsWith(".json"))
|
||||
.filter((item) => !item.startsWith("example."))) {
|
||||
const fullPath = join(dir, file);
|
||||
try {
|
||||
const content = readFileSync(fullPath, "utf-8");
|
||||
const parsed = JSON.parse(content);
|
||||
if (parsed && typeof parsed === "object" && parsed.id === corpId) {
|
||||
return fullPath;
|
||||
}
|
||||
} catch {
|
||||
// ignore malformed files
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
return loadCorpConfigEntries().find((entry) => entry.config.id === corpId)?.path;
|
||||
}
|
||||
|
||||
export function updateCorpConfig(corpId: string, patch: Partial<CorpConfig>): CorpConfig {
|
||||
@@ -281,6 +268,6 @@ export function updateCorpConfig(corpId: string, patch: Partial<CorpConfig>): Co
|
||||
}
|
||||
}
|
||||
const validated = CorpConfigSchema.parse(merged);
|
||||
writeFileSync(filePath, `${JSON.stringify(validated, null, 2)}\n`, "utf-8");
|
||||
writeSecureFile(filePath, `${JSON.stringify(validated, null, 2)}\n`);
|
||||
return validated;
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { validationError } from "../errors.js";
|
||||
import { CorpConfig, GlobalConfig } from "./types.js";
|
||||
|
||||
export function resolveCorpConfig(
|
||||
@@ -18,23 +19,19 @@ export function resolveCorpConfig(
|
||||
if (caseInsensitive) return caseInsensitive;
|
||||
const byName = corps.find((item) => item.name.toLowerCase() === selectedCorpId.toLowerCase());
|
||||
if (byName) return byName;
|
||||
throw new Error(`No enterprise config found for ${selectedCorpId}`);
|
||||
throw validationError(`No enterprise config found for ${selectedCorpId}`);
|
||||
}
|
||||
|
||||
if (!options.stateful) {
|
||||
throw new Error(
|
||||
"Stateless mode is enabled. Every enterprise command requires --corp <corpId>. " +
|
||||
"Use `seal-use config mode stateful` to enable a default enterprise."
|
||||
);
|
||||
throw validationError("Stateless mode is enabled. Every enterprise command requires --corp <corpId>. " +
|
||||
"Use `seal-use config mode stateful` to enable a default enterprise.");
|
||||
}
|
||||
|
||||
const firstCorp = corps[0];
|
||||
if (firstCorp) return firstCorp;
|
||||
|
||||
throw new Error(
|
||||
"No enterprise config found. Add a non-example JSON file under one of: " +
|
||||
(candidates.length ? candidates.join(", ") : "the configured enterprise directories")
|
||||
);
|
||||
throw validationError("No enterprise config found. Add a non-example JSON file under one of: " +
|
||||
(candidates.length ? candidates.join(", ") : "the configured enterprise directories"));
|
||||
}
|
||||
|
||||
export type CorpContextOptions = Pick<GlobalConfig, "stateful" | "defaultCorpId">;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
||||
import { existsSync } from "node:fs";
|
||||
import { writeSecureFile } from "../secure-file.js";
|
||||
import { join } from "node:path";
|
||||
import { resolveWritableEnterprisesDir } from "./loader.js";
|
||||
import { CorpConfigSchema, type CorpConfig } from "./types.js";
|
||||
@@ -20,13 +21,12 @@ export function saveCorpConfig(
|
||||
): SavedCorpConfig {
|
||||
const config = CorpConfigSchema.parse(input);
|
||||
const enterprisesDir = resolveWritableEnterprisesDir();
|
||||
mkdirSync(enterprisesDir, { recursive: true, mode: 0o700 });
|
||||
const path = join(enterprisesDir, `${safeCorpFileName(config.id)}.json`);
|
||||
|
||||
if (existsSync(path) && options.overwrite !== true) {
|
||||
throw new Error(`Enterprise config already exists: ${path}. Pass "overwrite": true to replace it.`);
|
||||
}
|
||||
|
||||
writeFileSync(path, `${JSON.stringify(config, null, 2)}\n`, { mode: 0o600 });
|
||||
writeSecureFile(path, `${JSON.stringify(config, null, 2)}\n`);
|
||||
return { config, path };
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
// Re-export from domain layer — this file is the legacy entry point.
|
||||
// tenant-diagnose inherently depends on domains/seal/api, so it now lives there.
|
||||
export {
|
||||
type TenantHealthCheck,
|
||||
type TenantDoctorDiagnosis,
|
||||
diagnoseTenantContract,
|
||||
formatTenantDoctorDashboard
|
||||
} from "../../domains/seal/doctor/tenant-diagnose.js";
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
import file0 from "../../skills/seal-use/SKILL.md" with { type: "text" };
|
||||
import file1 from "../../skills/seal-use/agents/openai.yaml" with { type: "text" };
|
||||
const file2 = "iVBORw0KGgoAAAANSUhEUgAADVgAAAdwCAYAAACUWcTmAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAANWKADAAQAAAABAAAHcAAAAAD4n9OGAABAAElEQVR4AeydB4AdVfX/z246pNAD0hK6dOki0rsU+dMJJVIFRYoUFUFAQUCqgHSkxx8gTRCpFkB6CU06SQi9BEhC+u7/fu7b83J3dt7bt33f5nuStzNz5947M583c+fOvPO9p6Y+mMlEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREYA4kUDsHHrMOWQREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAQigd7jxo8TChEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYIwkogtUc+bXroEVABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABERABCBQUx9MKERABERABERABERABERABERABERABERABERABERABERABERABESgqwiMHz/eBgwY0FWb13ZFQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQATmcAKKYDWHnwA6fBEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYkwlIYDUnf/s6dhEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYwwlIYDWHnwA6fBEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYkwlIYDUnf/s6dhEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYwwlIYDWHnwA6fBEQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQAREQARGYkwn0npMPXscuAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAj2RwP8+n26vfjbd3vpyho2fPN0+mjLTJs+qs/qaOhvYp8YWGtDLFh/U25YZ3NdWnr+/rTDvgJ6IQcckAhURqKkPVlFOZRIBERABERABERABERABERABERABERABERABERABERABERABERCBDiAwfvx4GzBAP9p2AFpVKQIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiMIcR+GhSnT347lT713tT7eOpM4OYqj5+LEzNEFdZ+MyKU5Zr4jLp9fat/r1ss28NtM0WG2KLzN1nDiOnw53TCUhgNaefATp+ERABERABERABERABERABERABERABERABERABERABERABEehiAhJYdfEXoM2LgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAiIgAhUPYFJ08z+7+Updsc7U8OxFARURKqyIKAqCKnqbVYQUdU2CK7iOiuIr4oirLBcgxArfHZZcrDttcwCNnefXlXPRgcgApUQkMCqEkrKIwIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIiIAIi0GEEJLDqMLSqWAREQAREQAREQAREQAREQAREQAREQAREQAREQAREYA4g8MR7M+2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j2SFwOumtz6zg749lOztbqlQygVSCIuYL2cIqDwPoirepfsy5ZgnLRv5qlydXbUu73cAjqka9h1mCMSw1kbdamv5uPEW/pHAqoXAlF0EREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEREAEuppA+oNwR0WZ6upj7Enbf+ONN+yUU06Jh3Tsscfa6quv3pMOLx7Lhx9+aMcff3yc33vvvW3LLbfMPcZbbrnF7rjjjrjuF7/4ha2yyiq5+dLEyZMn24QJE2zhhRe23r1720svvWTnn39+zPLLX/7SlllmmTR77jyORb/61a/iuv3339++973v5eZLE99++2076aSTbNlll7UtttiiojJp+WqZHz16dBQ84XziNnPmTPv00099sUVTHLMGDx6cW2bcuHHRAWSzzTazHXfc0eaZZ56Y7/HHH7eLLroozh933HG21FJL2Zlnnmm77LJLm6+Xb775xr766qvc/ckmzjvvvNFJLZveluWzzz7b3nrzTVty2DDjfG2JTZs2ze677z7bZpttGonSvvzyy4od5bLb4zqqJqHnxxNmWcHZK3skLV/u16fG5huUL2B5cPRUO+LPn9tu6wy0Line truncated
|
||||
const file3 = "iVBORw0KGgoAAAANSUhEUgAADVoAAAdqCAYAAAAy4TUmAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAANWqADAAQAAAABAAAHagAAAAAG88xiAABAAElEQVR4AeydB2AcxfX/nyT3TrNNTJFNDdgYML2EYnoNfzoG4wCBAKF3CAQcejM19E4wAULnRwBDQiimGGPTm3HBxqYa3OQi6f7zmdM7za32TifpJN9J79mr2Z22s9/dnZ3de9/5liSciZkhYAgYAoaAIWAIGAKGgCFgCBgChoAhYAgYAoaAIWAIGAKGgCFgCBgChoAhsJQRmD59unTu3Hkpt8J2bwgYAoaAIWAItF4ESioqpPTtsVI2fpyUzJopJbNnS8miRa33gO3IJNGxoySWWVYSfftK1ZCNpXrTzSXRqZMhYwgYAoaAIWAIGAKGgCFgCBgChoAhYAgYA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ACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACFFrxPUACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJFDgCVBoVeDfAgRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAoRXfAyRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAgWeAIVWBf4tQAAkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQALRO3fvlNTUVJIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIggQJLgBGtCuyfnidOAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRgEYhIV7MOuCUBEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiCBgkiAEa0K4l+d50wCJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJOBGgEIrNxw8IAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESKIgEKLQqiH91njMJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkIAbAQqt3HDwgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIoCASoNCqIP7Vec4kQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAJuBCi0csPBAxIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIggYJIgEKrgvhX5zmTAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAm4EaDQyg0HD0iABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABAoiAQqtCuJfnedMAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiTgRoBCKzccPCABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiiIBCi0Koh/dZ4zCZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZCAGwEKrdxw8IAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESKAgEqDQqiD+1XnOJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACbgQotHLDwQMSIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIIGCSIBCq4L4V+c5kwAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJuBGg0MoNBw9IgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgAQKIgEKrQriX53nTAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIk4EaAQis3HDwgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIoiASiC+JJ85xJgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgATyAIFlSyVtyWJJjY+XlK3bJP3QYTOoiLPPkugqlSWqVi2JbNRYpEHDPDBYDoEESCC/E4hIV8vvJ8nzIwESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESyDsE0idPlOQxYyRl89agBhVVrYrEtmwpEbffGVR5FiIBEiCBrBCg0Cor1FiHBEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEggdAL/rpfkzz+T5BWrQq+rNWIurSMxHTqKXFAjS/VZiQRIgAT8EaDQyh8d5pEACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACYSHwG+/SUKPHmFpq0ivXiJNm4alLTZCAiRAAhYBCq0sEl626ZoWoS9raxVJ04RIzUhJE3n151T5UyMVFi8eIeVLRkqFs0XOP0fFsaVEyhQXKVdMpEScVZNbEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiiABMIosrLoUWxlkeC2IBJIS0uT5JQUSUlJldTUVMExXunp6eYFJhEREeYVGRkpeEVFRUl0dJTEREeb44LILdA5U2hlIwQBVVKqyMaDIv/sF7mvlkiUCqogtLLMEl6h7IY9adJmRKqcStfUmEiRaBVgxeobT7exMSq+ihUpqSKrS0uL3HmRSM3zND3KIdKy2uOWBEiABEiABEiABEiABEiABHwSWL5cZOkySY2Pl9SNWyRt525JO3zcFI88q5hEVignUedXlahaevPSsIFI/fo+m2IGCZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZw2Av+ul4S2zwTdfXSNCyTyLI2Copa8fIWkJyf7rFtk6FcaKaWGz3xmkEB+IpCcnCJJSUmSpJ8JiKuyYxBdxcbESGxsrMTEqBCGZggULine truncated
|
||||
const file5 = "iVBORw0KGgoAAAANSUhEUgAADVoAAAdyCAYAAADdZLXQAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAANWqADAAQAAAABAAAHcgAAAABWYxAhAABAAElEQVR4AeydB6BO5R/Hf3fbWshOS4QiWipR2ktRirZSoWgPMhLtPciISv0rITOzZJRkhMyQlVW2u8f/933e93nved/7zrtc935/9TrnPPt87jvOec7v+/yistSERgIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIlmEB0CT53njoJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJGAIUWvGNQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkUOIJUGhV4t8CBEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJBC7bfs2ycjIIAkSIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESKLEEGNGqxP7peeIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAKWQFSWmj3glgRIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARKIgFGtCqJf3WeMwmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQgBcBCq28cPCABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEigJBKg0Kok/tV5ziRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAl4EKLTywsEDEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiCBkkiAQquS+FfnOZMACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACXgRoNDKCwcPSIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESiIBCq1K4l+d50wCJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJOBFgEIrLxw8IAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESKIkEKLQqiX91njMJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkIAXAQqtvHDwgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIoCQSoNCqJP7Vec4kQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAJeBCi08sLBAxIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIggZJIgEKrkvhX5zmTAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAl4EaDQygsHD0iABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEoiAQqtSuJfnedMAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiTgRYBCKy8cPCABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiiJBCi0Kol/dZ4zCZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZCAFwEKrbxw8IAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESKAkEogtiSfNcyYBEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEigCBBYvkszfF0rGypWSvmmzZO3dZwYVdewxElu7lsTUry/RTZuJNDmnCAyWQyABEijuBKKy1Ir7SfL8SIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAEig6BrEkTJG30aEnfuCmsQcXUqS3xbdtK1LXXh1WehUiABEggNwQotMoNNdYhARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARKInMBfayXtg/clbenyyOtqjbizG0pc124ip56eq/qsRAIkQALBCFBoFYwO80iABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABPKHwOzZkti7d760VaZvX5EWLfKlLTZCAiRAApYAhVaWhJ9tlqZF6ctubZFMTYjWjPRMkae+y5BfNVJh+fJRUq1itFQ/VuSU41QcW0mkSnmRquVEKiTYmtySAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQQAkkkI8iK0uPYitLgtuSSCAzM1PS0tMlPT1DMjIyBMd4ZWVlmReYREVFmVd0dLTgFRMTI7GxMRIXG2uOSyK3UOdMoZWDEARUqRki6/eI/Llb5Jb6IjEqqILQypoVXqHsuh2Z0vHTDEnJ0tS4aJFYFWDF6xtPt/FxKr6KF6moIquzK4tcf4ZI3RM0PcYl0rLtcUsCJEACJEACJEACJEACJEACAQksWSKyaLFkrFwpGev/lsxt2yVz3yFTPPqYchJdvarEnHKSxNTXm5dzmog0bhywKWaQAAm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AAmQAAmQAAmQAAmQAAmQQHQCFAVG58E1EiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEki0BCgKTLSHjg0nARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIggegEKAqMzoNrJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJJBoCVAUmGgPHRtOAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAtEJUBQYnQfXSIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESCDREqAoMNEeOjacBEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABKIToCgwOg+ukQAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkECiJUBRYKI9dGw4CZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACZAACUQnQFFgdB5cIwESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIIFES4CiwER76NhwEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEohOgKLA6Dy4RgIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAIkQAKJlgBFgYn20LHhJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJBCdAEWB0XlwjQRIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgAQSLQGKAhPtoWPDSYAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESCA6AYoCo/PgGgmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAkkWgIUBSbaQ8eGkwAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkAAJkEB0AhQFRufBNRIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARJItAQ8E23L2XASIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAGXJ3BgfwQ+x4+H+18x33+E5rqlS+2ZM5dHkSIeZcoKfLiQAAkkKAE3s9mcoBWyMhIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIQ5hXLQufPC794xQELjzy5fOo3cPvgIwc+zCIBEogVAYoCY4WLziRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAiRAAjEROHcmdPSosMPHYvKLzPcqUdS7U2eRr4CT/nQjARJwQICiQAdwmEUCJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJEACJBBLAps3B/TvH8symntylKpePQ4FWYQESEBPIGmKAjEjspsQ8lvurcks3N1EuEn0nGfafcWcIpVbtlTu2dKJ19OKfJlE1hQiS0qRykdPhmkSIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIIFYEoirIlBuhrrAWOKmezQCJpMpLBxLhLZgJSLCbFng5GZZ3D08PNy1L09PDy9PT3d392jlk8pK0hEFQvYXGiHO3xPH74p6hYWHmyYKlIsUCMLh7A1T02kRIWY34eXu5incfNw9PIW3l0iFj48omVl8VFAUzCi8PTQFIRcSIAESIAESIAESIAG7BA4dFPsPhZ88HnH+sunaTdPDJ/B0T5PSPXsWj9dzexYqIsqWEqVK2y3ODBIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARI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QQ/5ihDtTKukVoxfENZaFKw/nMPTFsh2i/QFy4L7BRLiRAAiRAAiRAAiTwChIwjR4V8HV308Mn8dl3FNcqGT0qPpWwLAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQgOsSOLA/4uIVx81LVq+BSJESPmHTZzj2DEdVB/Y79mHuK0ggwmR69PjJ06cBZi0O3PNaUDk2gQ1hc89rG8+53sQnCgwJE4sPiy6LxdFbIixMhEPPBwGg5VMgrSiZTUtiQXRANecvLP53zHtPhyM0oEeEcEPYQJObG6SBKItggchGpECLQBCFccJEpjUFocDmDt4QXRaKhf9paS4kQAIkQAIkQAIk8EoRiOjdJ+iPyQm1y6gKFSZUbayHBEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEjAdQhExKThc/P1c/+0vtbgs6cdhwmUOxVjha6z72zJiyEQEhJ6//6D0NDQF7M5bAibw0ZfzOYSdiueCVvdc60N4r2nIWLmbjHzoAgKF5Z5gLUNQuPn5qYFCCyXXXh7aFpAeOLzbDGLrScjAkPMmFdYm0UaQkCIIS0qQMj+NPkgggsi4SY0s6YYFB6Wb4QShCXCLC4/EL9uEbefiC8qiOQ+z+SGzzbBFAmQAAmQAAmQAAkkOQIQ8AX/syRhdwsVJhPC46dBCVstayMBEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEiABEni5BCKOH3fcAJ9PPxGpU8EndOpUx54yFxV6OONHn1eDQGBgECb2ffH7+vjJk+QRfn5+vi9+0/HZYqKJFAit3qNA0W+5mLZfPA3VJvNFnD93RPWzxPNDqD/IG4vnEB6WHZIxAjW1n4VNSIT5
Line truncated
|
||||
import file2 from "../../skills/seal-use/assets/hose-curl-copy-as-curl.png" with { type: "file" };
|
||||
import file3 from "../../skills/seal-use/assets/hose-curl-network-fetch-xhr.png" with { type: "file" };
|
||||
import file4 from "../../skills/seal-use/assets/hose-curl-open-page-check.png" with { type: "file" };
|
||||
import file5 from "../../skills/seal-use/assets/hose-open-platform-app-center.png" with { type: "file" };
|
||||
import file6 from "../../skills/seal-use/assets/hose-open-platform-credentials.png" with { type: "file" };
|
||||
import file7 from "../../skills/seal-use/assets/hose-open-platform-product-config.png" with { type: "file" };
|
||||
import file8 from "../../skills/seal-use/references/approval-attachment-trace.md" with { type: "text" };
|
||||
import file9 from "../../skills/seal-use/references/approval-bad-cases.md" with { type: "text" };
|
||||
import file10 from "../../skills/seal-use/references/approval-run-lightweight.md" with { type: "text" };
|
||||
@@ -46,7 +46,7 @@ export const EMBEDDED_SKILL_TEXT_FILES: Record<string, string> = {
|
||||
"references/webhook-resource-pack.md": file23,
|
||||
};
|
||||
|
||||
export const EMBEDDED_SKILL_ASSET_DATA: Record<string, string> = {
|
||||
export const EMBEDDED_SKILL_ASSET_PATHS: Record<string, string> = {
|
||||
"assets/hose-curl-copy-as-curl.png": file2,
|
||||
"assets/hose-curl-network-fetch-xhr.png": file3,
|
||||
"assets/hose-curl-open-page-check.png": file4,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { existsSync, mkdtempSync, rmSync } from "node:fs";
|
||||
import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import packageJson from "../../package.json" with { type: "json" };
|
||||
@@ -37,6 +37,10 @@ describe("embedded-skill", () => {
|
||||
expect(existsSync(join(tmp, "references", "enterprise-onboarding.md"))).toBe(true);
|
||||
expect(existsSync(join(tmp, "references", "first-time-user.md"))).toBe(true);
|
||||
expect(existsSync(join(tmp, "assets", "hose-curl-copy-as-curl.png"))).toBe(true);
|
||||
expect([...res.files].sort()).toEqual([...EMBEDDED_SKILL_ALL_PATHS].sort());
|
||||
for (const path of EMBEDDED_SKILL_ALL_PATHS) {
|
||||
expect(readFileSync(join(tmp, path))).toEqual(readFileSync(join(import.meta.dir, "../../skills/seal-use", path)));
|
||||
}
|
||||
} finally {
|
||||
rmSync(tmp, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
@@ -3,16 +3,23 @@ import { homedir } from "node:os";
|
||||
import { dirname, join } from "node:path";
|
||||
|
||||
import {
|
||||
EMBEDDED_SKILL_ASSET_DATA,
|
||||
EMBEDDED_SKILL_ASSET_PATHS,
|
||||
EMBEDDED_SKILL_TEXT_FILES
|
||||
} from "./embedded-skill.generated.js";
|
||||
|
||||
export { EMBEDDED_SKILL_ALL_PATHS } from "./embedded-skill.generated.js";
|
||||
|
||||
export const EMBEDDED_SKILL_FILES = EMBEDDED_SKILL_TEXT_FILES;
|
||||
export const EMBEDDED_SKILL_ASSETS: Record<string, Uint8Array> = Object.fromEntries(
|
||||
Object.entries(EMBEDDED_SKILL_ASSET_DATA).map(([relPath, base64]) => [relPath, Buffer.from(base64, "base64")])
|
||||
);
|
||||
// Runtime self-healing imports this module even for `version`. Read asset bytes
|
||||
// only when installation actually asks for them, preserving local startup latency.
|
||||
export const EMBEDDED_SKILL_ASSETS: Record<string, Uint8Array> = {};
|
||||
for (const [relPath, path] of Object.entries(EMBEDDED_SKILL_ASSET_PATHS)) {
|
||||
let bytes: Uint8Array | undefined;
|
||||
Object.defineProperty(EMBEDDED_SKILL_ASSETS, relPath, {
|
||||
enumerable: true,
|
||||
get: () => bytes ??= readFileSync(path)
|
||||
});
|
||||
}
|
||||
|
||||
export function getSkillContent(): string {
|
||||
return EMBEDDED_SKILL_FILES["SKILL.md"] || "";
|
||||
|
||||
@@ -44,44 +44,22 @@ describe("CLI semantic errors", () => {
|
||||
expect(classifyCliError(new Error("Unknown deploy hosecloud action: x"))).toEqual({ exitCode: 2 });
|
||||
});
|
||||
|
||||
test("classifies local config and input-data failures as validation errors (13)", () => {
|
||||
// Chinese-language usage wording: the message names a flag/parameter to supply.
|
||||
expect(
|
||||
classifyCliError(new Error("当前租户存在多个 Webhook 通道 [\"a\" (1)],请通过 --webhook <idOrName> 指定目标通道。"))
|
||||
).toEqual({ exitCode: 13 });
|
||||
expect(classifyCliError(new Error("必须提供 target、recordId 或 sourceDocumentSN 参数。"))).toEqual({ exitCode: 13 });
|
||||
|
||||
// Enterprise selection: well-formed command, incomplete local config.
|
||||
expect(
|
||||
classifyCliError(new Error("Stateless mode is enabled. Every enterprise command requires --corp <corpId>."))
|
||||
).toEqual({ exitCode: 13 });
|
||||
expect(classifyCliError(new Error("No enterprise config found for nope"))).toEqual({ exitCode: 13 });
|
||||
expect(
|
||||
classifyCliError(new Error("rules lint requires an authenticated enterprise. Run 'seal-use corps list' to select one."))
|
||||
).toEqual({ exitCode: 13 });
|
||||
|
||||
// Local file input the caller must fix.
|
||||
expect(classifyCliError(new Error("File not found: /tmp/missing.json"))).toEqual({ exitCode: 13 });
|
||||
expect(
|
||||
classifyCliError(new Error("本地规则文件格式错误: 顶层必须为规则数组或包含 'rules' 数组的对象"))
|
||||
).toEqual({ exitCode: 13 });
|
||||
|
||||
// Structural signals that carry no message prefix.
|
||||
test("classifies structural input failures without matching their wording", () => {
|
||||
expect(classifyCliError(validationError("请选择目标通道"))).toMatchObject({ exitCode: 13 });
|
||||
expect(classifyCliError(new SyntaxError("JSON Parse error: Expected '}'"))).toEqual({ exitCode: 13 });
|
||||
expect(classifyCliError({ issues: [{ path: ["environment"], message: "Invalid option" }] })).toEqual({ exitCode: 13 });
|
||||
});
|
||||
|
||||
test("classifies safety-guard blocks distinctly (14)", () => {
|
||||
expect(
|
||||
classifyCliError(new Error("目标企业「生产目标企业」(prod) 标记为生产正式环境 (production)。"))
|
||||
).toEqual({ exitCode: 14 });
|
||||
expect(classifyCliError(new Error("重放目标企业「T」(t) 的环境为「production」,非测试环境!"))).toEqual({
|
||||
exitCode: 14
|
||||
});
|
||||
expect(classifyCliError(safetyBlocked("blocked by environment guard", "seal-use webhook replay --force"))).toEqual({
|
||||
exitCode: 14,
|
||||
nextAction: "seal-use webhook replay --force"
|
||||
});
|
||||
test("safety guards carry their code independently of user-facing text", () => {
|
||||
expect(classifyCliError(safetyBlocked("blocked by environment guard", "seal-use webhook replay --force")))
|
||||
.toEqual({ exitCode: 14, nextAction: "seal-use webhook replay --force" });
|
||||
expect(classifyCliError(safetyBlocked("换一种中文解释"))).toMatchObject({ exitCode: 14 });
|
||||
});
|
||||
|
||||
test("upstream messages containing validation or safety words stay domain failures", () => {
|
||||
for (const message of ["上游格式错误,请提供工单", "No enterprise config found upstream", "File not found: remote object", "禁止向生产环境传输失败"]) {
|
||||
expect(classifyCliError(new Error(message))).toEqual({ exitCode: 1 });
|
||||
}
|
||||
});
|
||||
|
||||
test("validationError helper carries exit 13 with next action", () => {
|
||||
@@ -54,25 +54,6 @@ export function confirmationRequired(message: string, nextAction: string): CliEr
|
||||
const USAGE_PREFIX =
|
||||
/^(?:Usage:|Unknown (?:[a-z0-9_-]+ )*(?:command|action|subcommand|target)|Invalid (?:number|boolean|command)|--json must|Missing required JSON field|Invalid JSON:)/i;
|
||||
|
||||
// Wording a Chinese-language usage error uses when it names a flag/parameter
|
||||
// the caller must supply, or rejects a value the caller chose. Exit `13`.
|
||||
// Deliberately excludes generic recovery verbs like "请先"/"请重试" so post-write
|
||||
// or upstream failures that offer recovery advice stay at exit `1`.
|
||||
const CN_USAGE =
|
||||
/(?:请通过|请指定|参数提供|需要提供|必须提供|缺少合思凭证|模式需要提供|参数。|为必填项|不能使用|无法用于|必须包含|必须为|顶层必须|格式错误|格式不合法|不支持的|未知的|无效的|请改用|请使用 --|请提供)/;
|
||||
|
||||
// Enterprise-selection failures: the caller must pass --corp or fix config. Exit `13`.
|
||||
const CORP_SELECTION =
|
||||
/^(?:Stateless mode is enabled\.|No enterprise config found|.*requires an authenticated enterprise|.*requires an enterprise\.)/;
|
||||
|
||||
// Local file input problems that are the caller's responsibility to fix. Exit `13`.
|
||||
const LOCAL_FILE_INPUT =
|
||||
/^(?:File not found:|本地规则文件(?: JSON 解析失败|格式错误|包含重复)|未找到本地规则文件|第 \d+ 条规则(?:格式错误|缺少有效的)|ZIP 根目录缺少|起始时间 .* 不能晚于结束时间)/;
|
||||
|
||||
// Safety-guard wording: blocked by target environment, not by input shape. Exit `14`.
|
||||
const SAFETY_GUARD =
|
||||
/(?:标记为生产正式环境|非测试环境|严禁在生产环境|禁止向生产环境)/;
|
||||
|
||||
export function classifyCliError(error: unknown): {
|
||||
exitCode: CliExitCode;
|
||||
nextAction?: string;
|
||||
@@ -89,15 +70,6 @@ export function classifyCliError(error: unknown): {
|
||||
if (USAGE_PREFIX.test(value)) {
|
||||
return { exitCode: 2 };
|
||||
}
|
||||
if (/^Refusing to (?:clear|delete)|without --yes|without confirm=true/i.test(value)) {
|
||||
return { exitCode: 10 };
|
||||
}
|
||||
if (SAFETY_GUARD.test(value)) {
|
||||
return { exitCode: 14 };
|
||||
}
|
||||
if (CN_USAGE.test(value) || CORP_SELECTION.test(value) || LOCAL_FILE_INPUT.test(value)) {
|
||||
return { exitCode: 13 };
|
||||
}
|
||||
// Structural validation: a ZodError carries an `issues` array rather than a
|
||||
// message prefix, so it never matches a text pattern.
|
||||
if (isValidationIssueList(error)) {
|
||||
|
||||
@@ -1,13 +1,109 @@
|
||||
import { afterEach, describe, expect, test } from "bun:test";
|
||||
import { createSealClientForUrl } from "./factory.js";
|
||||
import { mkdtempSync, rmSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { CorpConfigSchema } from "../config/types.js";
|
||||
import { setSealSession, getSealSession } from "../auth/token-store.js";
|
||||
import { clearSealToken } from "../auth/seal.js";
|
||||
import { classifyCliError } from "../errors.js";
|
||||
import { createSealClient, createSealClientForUrl } from "./factory.js";
|
||||
|
||||
const servers: Array<ReturnType<typeof Bun.serve>> = [];
|
||||
const tempDirs: string[] = [];
|
||||
const corpIds: string[] = [];
|
||||
const originalStore = process.env.SEAL_USE_TOKEN_STORE;
|
||||
const originalFetch = globalThis.fetch;
|
||||
|
||||
afterEach(() => {
|
||||
for (const server of servers.splice(0)) server.stop(true);
|
||||
for (const id of corpIds.splice(0)) clearSealToken(id);
|
||||
for (const dir of tempDirs.splice(0)) rmSync(dir, { recursive: true, force: true });
|
||||
if (originalStore === undefined) delete process.env.SEAL_USE_TOKEN_STORE;
|
||||
else process.env.SEAL_USE_TOKEN_STORE = originalStore;
|
||||
globalThis.fetch = originalFetch;
|
||||
});
|
||||
|
||||
function recoveryFixture(sourceType: "hose" | "seal", alwaysUnauthorized = false) {
|
||||
const dir = mkdtempSync(join(tmpdir(), "seal-http-recovery-"));
|
||||
tempDirs.push(dir);
|
||||
process.env.SEAL_USE_TOKEN_STORE = join(dir, "tokens.json");
|
||||
const id = `http-recovery-${crypto.randomUUID()}`;
|
||||
corpIds.push(id);
|
||||
const corp = CorpConfigSchema.parse({
|
||||
id, name: "Recovery fixture",
|
||||
source: sourceType === "hose"
|
||||
? { type: "hose", closeToken: "fixture-close-token", staffId: "fixture-staff", corpId: id, sealUrl: "https://fixture.invalid" }
|
||||
: { type: "seal", token: "fixed-token", sealUrl: "https://fixture.invalid" }
|
||||
});
|
||||
setSealSession(id, {
|
||||
token: "stale-token", expiresAt: Date.now() + 3600000,
|
||||
enterprise: { provider: sourceType, staffId: "fixture-staff", sealUrl: "https://fixture.invalid" }
|
||||
});
|
||||
const requests: Array<{ method: string; token: string | null }> = [];
|
||||
let refreshes = 0;
|
||||
globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
|
||||
const request = input instanceof Request ? input : new Request(input, init);
|
||||
if (new URL(request.url).pathname === "/api/auth/oauth2/session/oem-hosecloud") {
|
||||
refreshes += 1;
|
||||
// Allow simultaneous failures to join one in-flight refresh.
|
||||
await Promise.resolve();
|
||||
return Response.json({ token: "fresh-token", expiresIn: 3600 });
|
||||
}
|
||||
const token = request.headers.get("Authorization");
|
||||
requests.push({ method: request.method, token });
|
||||
return Response.json({ ok: true }, { status: !alwaysUnauthorized && token === "Bearer fresh-token" ? 200 : 401 });
|
||||
}) as typeof fetch;
|
||||
return { corp, requests, refreshCount: () => refreshes };
|
||||
}
|
||||
|
||||
describe("Seal HTTP client errors", () => {
|
||||
test("a renewable read recovers once and the same client uses the new session afterwards", async () => {
|
||||
const fixture = recoveryFixture("hose");
|
||||
const client = await createSealClient(fixture.corp);
|
||||
expect(await client.get("api/read").json<{ ok: boolean }>()).toEqual({ ok: true });
|
||||
expect(await client.get("api/read-again").json<{ ok: boolean }>()).toEqual({ ok: true });
|
||||
expect(fixture.refreshCount()).toBe(1);
|
||||
expect(fixture.requests.map((request) => request.token)).toEqual([
|
||||
"Bearer stale-token", "Bearer fresh-token", "Bearer fresh-token"
|
||||
]);
|
||||
});
|
||||
|
||||
test("concurrent 401 reads share a refresh", async () => {
|
||||
const fixture = recoveryFixture("hose");
|
||||
const client = await createSealClient(fixture.corp);
|
||||
await Promise.all([client.get("api/one"), client.get("api/two")]);
|
||||
expect(fixture.refreshCount()).toBe(1);
|
||||
});
|
||||
|
||||
test("a second 401 stops, clears the rejected cache, and remains an auth failure", async () => {
|
||||
const fixture = recoveryFixture("hose", true);
|
||||
const client = await createSealClient(fixture.corp);
|
||||
const error = await client.get("api/read").catch((error: unknown) => error);
|
||||
expect(classifyCliError(error)).toEqual({ exitCode: 11 });
|
||||
expect(fixture.refreshCount()).toBe(1);
|
||||
expect(fixture.requests).toHaveLength(2);
|
||||
expect(getSealSession(fixture.corp.id)).toBeUndefined();
|
||||
});
|
||||
|
||||
test("mutations, fixed bearers, and explicit retry opt-out are never replayed", async () => {
|
||||
for (const source of ["hose", "seal"] as const) {
|
||||
const fixture = recoveryFixture(source);
|
||||
const client = await createSealClient(fixture.corp);
|
||||
await expect(client.post("api/write", { json: { value: 1 } })).rejects.toThrow();
|
||||
expect(fixture.requests).toHaveLength(1);
|
||||
expect(fixture.refreshCount()).toBe(0);
|
||||
}
|
||||
const fixture = recoveryFixture("hose");
|
||||
const client = await createSealClient(fixture.corp);
|
||||
await expect(client.get("api/read", { retry: 0 })).rejects.toThrow();
|
||||
expect(fixture.refreshCount()).toBe(0);
|
||||
expect(fixture.requests).toHaveLength(1);
|
||||
const fixed = recoveryFixture("seal");
|
||||
await expect((await createSealClient(fixed.corp)).get("api/read")).rejects.toThrow();
|
||||
expect(fixed.requests).toHaveLength(1);
|
||||
expect(fixed.refreshCount()).toBe(0);
|
||||
});
|
||||
|
||||
test("includes ky's parsed response body after the response stream is consumed", async () => {
|
||||
const server = Bun.serve({
|
||||
port: 0,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import ky, { HTTPError, KyInstance } from "ky";
|
||||
import { CorpConfig } from "../config/types.js";
|
||||
import { clearSealToken, getSealSessionForCorp } from "../auth/seal.js";
|
||||
import { clearSealToken, getSealSessionForCorp, recoverSealSessionForCorp } from "../auth/seal.js";
|
||||
import { resolveSealCustomHeaders } from "./request-headers.js";
|
||||
|
||||
function formatErrorData(data: unknown): string {
|
||||
@@ -40,6 +40,24 @@ export async function createSealClient(corp: CorpConfig): Promise<KyInstance> {
|
||||
Authorization: `Bearer ${session.token}`
|
||||
},
|
||||
hooks: {
|
||||
beforeRequest: [async ({ request }) => {
|
||||
const current = await getSealSessionForCorp(corp);
|
||||
request.headers.set("Authorization", `Bearer ${current.token}`);
|
||||
}],
|
||||
afterResponse: [async ({ request, response, retryCount, options }) => {
|
||||
// Only renewable sessions and safe reads are replayed. A fixed native
|
||||
// bearer cannot be refreshed, and mutation requests must never be replayed here.
|
||||
if (
|
||||
response.status !== 401 || retryCount !== 0 || options.retry.limit === 0 ||
|
||||
corp.source.type !== "hose" || !["GET", "HEAD", "OPTIONS"].includes(request.method)
|
||||
) return;
|
||||
const rejectedToken = request.headers.get("Authorization")?.replace(/^Bearer /, "") ?? "";
|
||||
const refreshed = await recoverSealSessionForCorp(corp, rejectedToken);
|
||||
if (new URL(request.url).origin !== new URL(refreshed.enterprise.sealUrl).origin) return;
|
||||
const headers = new Headers(request.headers);
|
||||
headers.set("Authorization", `Bearer ${refreshed.token}`);
|
||||
return ky.retry({ request: new Request(request, { headers }), delay: 0, code: "SEAL_SESSION_REFRESHED" });
|
||||
}],
|
||||
beforeError: [createBeforeErrorHook(corp.id)]
|
||||
}
|
||||
});
|
||||
|
||||
+4
-4
@@ -2,7 +2,6 @@ import { existsSync, symlinkSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { basename, dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { syncGlobalSkillIfPresent } from "./embedded-skill.js";
|
||||
|
||||
export function isCompiledBinary(execPath = process.execPath, metaUrl = import.meta.url): boolean {
|
||||
if (metaUrl.includes("/$bunfs/") || metaUrl.includes("\\$bunfs\\")) {
|
||||
@@ -42,10 +41,10 @@ export function resolveDefaultLauncher(
|
||||
};
|
||||
}
|
||||
|
||||
export function performRuntimeSelfHealing(): {
|
||||
export async function performRuntimeSelfHealing(): Promise<{
|
||||
binaryHealed?: boolean;
|
||||
skillHealed?: boolean;
|
||||
} {
|
||||
}> {
|
||||
const result: { binaryHealed?: boolean; skillHealed?: boolean } = {};
|
||||
|
||||
// 1. Binary executable alias self-healing
|
||||
@@ -77,7 +76,8 @@ export function performRuntimeSelfHealing(): {
|
||||
try {
|
||||
const legacySkillDir = join(homedir(), ".agents", "skills", "seal-home");
|
||||
if (existsSync(legacySkillDir)) {
|
||||
syncGlobalSkillIfPresent();
|
||||
// Ordinary discovery must not initialize the embedded resource graph.
|
||||
(await import("./embedded-skill.js")).syncGlobalSkillIfPresent();
|
||||
result.skillHealed = true;
|
||||
}
|
||||
} catch {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { closeSync, fchmodSync, mkdirSync, openSync, writeFileSync } from "node:fs"
|
||||
import { dirname } from "node:path"
|
||||
|
||||
/** Tighten an existing credential file before writing any new secret bytes. */
|
||||
export function writeSecureFile(path: string, content: string | Uint8Array): void {
|
||||
mkdirSync(dirname(path), { recursive: true, mode: 0o700 })
|
||||
const fd = openSync(path, "w", 0o600)
|
||||
try {
|
||||
fchmodSync(fd, 0o600)
|
||||
writeFileSync(fd, content)
|
||||
} finally {
|
||||
closeSync(fd)
|
||||
}
|
||||
}
|
||||
Vendored
+6
@@ -22,3 +22,9 @@ declare module "*.svg" {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
|
||||
/** Bun file-loader imports resolve to a source or compiled embedded asset path. */
|
||||
declare module "*.png" {
|
||||
const path: string
|
||||
export default path
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { validationError } from "../../../core/errors.js";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import type { ApprovalRun } from "../types.js";
|
||||
@@ -320,9 +321,7 @@ export async function downloadApprovalRunAttachments(
|
||||
} else if (!options.all) {
|
||||
if (allAttachments.length > 1) {
|
||||
const available = allAttachments.map((a) => a.fileName ?? a.fileId).filter(Boolean).join(", ");
|
||||
throw new Error(
|
||||
`共发现 ${allAttachments.length} 个附件。请使用 --all 下载全部附件,或使用 --name <名称|fileId> 指定下载项。可选附件: ${available}`
|
||||
);
|
||||
throw validationError(`共发现 ${allAttachments.length} 个附件。请使用 --all 下载全部附件,或使用 --name <名称|fileId> 指定下载项。可选附件: ${available}`);
|
||||
}
|
||||
selected = allAttachments;
|
||||
} else {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { validationError } from "../../../core/errors.js";
|
||||
import { existsSync, mkdirSync, statSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { dirname, extname, resolve } from "node:path";
|
||||
@@ -147,9 +148,7 @@ export function resolveExportDateRange(
|
||||
if (hasStart) {
|
||||
const formatted = formatDate(options.startDate);
|
||||
if (!formatted) {
|
||||
throw new Error(
|
||||
`无效的起始时间参数: "${String(options.startDate)}"。请使用 YYYY-MM-DD 或有效时间戳。`
|
||||
);
|
||||
throw validationError(`无效的起始时间参数: "${String(options.startDate)}"。请使用 YYYY-MM-DD 或有效时间戳。`);
|
||||
}
|
||||
startDateStr = formatted;
|
||||
}
|
||||
@@ -157,9 +156,7 @@ export function resolveExportDateRange(
|
||||
if (hasEnd) {
|
||||
const formatted = formatDate(options.endDate);
|
||||
if (!formatted) {
|
||||
throw new Error(
|
||||
`无效的结束时间参数: "${String(options.endDate)}"。请使用 YYYY-MM-DD 或有效时间戳。`
|
||||
);
|
||||
throw validationError(`无效的结束时间参数: "${String(options.endDate)}"。请使用 YYYY-MM-DD 或有效时间戳。`);
|
||||
}
|
||||
endDateStr = formatted;
|
||||
}
|
||||
@@ -198,7 +195,7 @@ export function resolveExportDateRange(
|
||||
const endTs = normalizeTimestamp(endDateStr, true)!;
|
||||
|
||||
if (Number(startTs) > Number(endTs)) {
|
||||
throw new Error(`起始时间 (${startDateStr}) 不能晚于结束时间 (${endDateStr})。`);
|
||||
throw validationError(`起始时间 (${startDateStr}) 不能晚于结束时间 (${endDateStr})。`);
|
||||
}
|
||||
|
||||
// 计算天数跨度
|
||||
@@ -299,9 +296,7 @@ export function resolveOutputFilePath(options: {
|
||||
let p = resolve(options.outputFile);
|
||||
const ext = extname(p).toLowerCase();
|
||||
if (ext && ext !== ".xlsx") {
|
||||
throw new Error(
|
||||
`导出路径错误: 本命令仅支持导出 Excel 工作簿,文件扩展名必须为 .xlsx(当前指定为 "${ext}")。请使用 .xlsx 后缀,例如: ${p.slice(0, -ext.length)}.xlsx`
|
||||
);
|
||||
throw validationError(`导出路径错误: 本命令仅支持导出 Excel 工作簿,文件扩展名必须为 .xlsx(当前指定为 "${ext}")。请使用 .xlsx 后缀,例如: ${p.slice(0, -ext.length)}.xlsx`);
|
||||
}
|
||||
if (!ext) {
|
||||
p = `${p}.xlsx`;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { validationError } from "../../../core/errors.js";
|
||||
import { z } from "zod";
|
||||
import type { KyInstance } from "ky";
|
||||
import * as api from "../api.js";
|
||||
@@ -242,7 +243,7 @@ export const approvalRunsCapabilities = [
|
||||
|
||||
const input = (params.target || params.sourceDocumentSN || params.recordId)?.trim();
|
||||
if (!input) {
|
||||
throw new Error("必须提供 target、recordId 或 sourceDocumentSN 参数。");
|
||||
throw validationError("必须提供 target、recordId 或 sourceDocumentSN 参数。");
|
||||
}
|
||||
|
||||
let sn = input;
|
||||
|
||||
@@ -123,14 +123,14 @@ export const deployCapabilities = [
|
||||
const apiKey = inputParams.apiKey ?? (typeof appKey === "string" ? appKey : undefined);
|
||||
const apiSecret = inputParams.apiSecret ?? (typeof appSecurity === "string" ? appSecurity : undefined);
|
||||
if (!apiKey || !apiSecret) {
|
||||
throw new Error("缺少合思凭证:apiKey (或 appKey) 与 apiSecret (或 appSecurity) 为必填项");
|
||||
throw validationError("缺少合思凭证:apiKey (或 appKey) 与 apiSecret (或 appSecurity) 为必填项");
|
||||
}
|
||||
const params = { ...inputParams, apiKey, apiSecret };
|
||||
let effectiveApiOrigin = params.apiOrigin ?? "production";
|
||||
let effectiveCustomApiUrl = params.customApiUrl;
|
||||
|
||||
if (effectiveApiOrigin === "custom" && !effectiveCustomApiUrl) {
|
||||
throw new Error("自定义合思环境必须提供 customApiUrl");
|
||||
throw validationError("自定义合思环境必须提供 customApiUrl");
|
||||
}
|
||||
if (!dryRun && confirm !== true) {
|
||||
throw confirmationRequired(
|
||||
|
||||
@@ -27,7 +27,7 @@ import { extractApprovalRunAttachments } from "../approval-runs/attachments.js";
|
||||
import type { LocalRuleItem } from "../rules/local.js";
|
||||
import { loadRuleMappingSnapshot } from "../rules/mapping.js";
|
||||
import { formatBeijingIso, normalizeBeijingIso } from "../../../core/config/timestamps.js";
|
||||
import { validationError } from "../../../core/errors.js";
|
||||
import { validationError, usageError } from "../../../core/errors.js";
|
||||
|
||||
export type CapabilityContext = {
|
||||
corp: CorpConfig;
|
||||
@@ -324,7 +324,7 @@ export function buildSimulationBatchParams(input: SimulationBatchCreateInput): R
|
||||
|
||||
if (sourceSystem === "hosecloud") {
|
||||
if (!docSns?.length && input.startTime === undefined) {
|
||||
throw new Error("hosecloud 模式需要提供 flowIds(单号列表)");
|
||||
throw validationError("hosecloud 模式需要提供 flowIds(单号列表)");
|
||||
}
|
||||
Object.assign(params, {
|
||||
dataCollectionMode: "2",
|
||||
@@ -340,11 +340,11 @@ export function buildSimulationBatchParams(input: SimulationBatchCreateInput): R
|
||||
} else if (sourceSystem === "material_pack" || sourceSystem === "material-pack") {
|
||||
const packageIds = input.packageIds ?? (input.packageId ? [input.packageId] : undefined);
|
||||
if (!packageIds?.length) {
|
||||
throw new Error("material_pack 模式需要提供 packageIds(材料包 id)");
|
||||
throw validationError("material_pack 模式需要提供 packageIds(材料包 id)");
|
||||
}
|
||||
const templateId = input.templateId ?? (input.schemaConfig as { id?: string } | undefined)?.id;
|
||||
if (!templateId) {
|
||||
throw new Error("material_pack 模式需要提供 templateId(或 schemaConfig.id)");
|
||||
throw validationError("material_pack 模式需要提供 templateId(或 schemaConfig.id)");
|
||||
}
|
||||
Object.assign(params, {
|
||||
templateId,
|
||||
@@ -1030,7 +1030,7 @@ export function findRuleInDraft(
|
||||
) {
|
||||
const rawTarget = selector.ruleId ?? selector.code ?? selector.runtimeId;
|
||||
if (!rawTarget || !rawTarget.trim()) {
|
||||
throw new Error("Usage: seal-use rules get <code> [--version <number|latest>] [--record-id <recordId>]");
|
||||
throw usageError("Usage: seal-use rules get <code> [--version <number|latest>] [--record-id <recordId>]");
|
||||
}
|
||||
const trimmed = rawTarget.trim();
|
||||
const targetCodeNum = parseRuleCodeNumber(trimmed);
|
||||
@@ -1068,7 +1068,7 @@ export function findRuleInVersion(
|
||||
) {
|
||||
const rawTarget = selector.ruleId ?? selector.code ?? selector.runtimeId;
|
||||
if (!rawTarget || !rawTarget.trim()) {
|
||||
throw new Error("Usage: seal-use rules get <code> [--version <number|latest>] [--record-id <recordId>]");
|
||||
throw usageError("Usage: seal-use rules get <code> [--version <number|latest>] [--record-id <recordId>]");
|
||||
}
|
||||
const trimmed = rawTarget.trim();
|
||||
const targetCodeNum = parseRuleCodeNumber(trimmed);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { validationError } from "../../../core/errors.js";
|
||||
import { z } from "zod";
|
||||
import type { KyInstance } from "ky";
|
||||
import { readFileSync } from "node:fs";
|
||||
@@ -98,7 +99,7 @@ export const simulationCapabilities = [
|
||||
const integrations = await api.listSimulationHosecloudIntegrations(client);
|
||||
signKey = integrations.find((item) => item.signKey)?.signKey;
|
||||
if (!signKey) {
|
||||
throw new Error("未找到合思集成 signKey, 请通过 signKey 参数提供");
|
||||
throw validationError("未找到合思集成 signKey, 请通过 signKey 参数提供");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { z } from "zod";
|
||||
import type { KyInstance } from "ky";
|
||||
import * as api from "../api.js";
|
||||
import { validationError } from "../../../core/errors.js";
|
||||
import { validationError, confirmationRequired } from "../../../core/errors.js";
|
||||
import { loadGlobalConfig, loadCorpConfigs, getEnterprisesDirCandidates } from "../../../core/config/loader.js";
|
||||
import { resolveCorpConfig } from "../../../core/config/manager.js";
|
||||
import { createSealClient } from "../../../core/http/factory.js";
|
||||
@@ -200,7 +200,7 @@ export const webhookCapabilities = [
|
||||
context: CapabilityContext
|
||||
) => {
|
||||
if (!params.confirm && !params.dryRun) {
|
||||
throw new Error("Refusing to delete Webhook integration without confirm=true");
|
||||
throw confirmationRequired("Refusing to delete Webhook integration without confirm=true", "seal-use webhook delete <id> --yes");
|
||||
}
|
||||
const preview = params.dryRun
|
||||
? await api.previewDeleteWebhookIntegration(client, params.selector, context.corp.seal.endpoints.approvalStylePreferences)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { diagnoseTenantContract, formatTenantDoctorDashboard } from "./tenant-diagnose.js";
|
||||
import type { CorpConfig } from "../config/types.js";
|
||||
import type { CorpConfig } from "../../../core/config/types.js";
|
||||
|
||||
function createMockClient(opts: {
|
||||
whoami?: any;
|
||||
@@ -1,3 +1,4 @@
|
||||
import { usageError } from "../../../core/errors.js";
|
||||
import { saveCorpConfig, type SavedCorpConfig } from "../../../core/config/repository.js";
|
||||
import { formatBeijingIso, normalizeBeijingIso } from "../../../core/config/timestamps.js";
|
||||
import {
|
||||
@@ -120,7 +121,7 @@ function saveSealConfig(
|
||||
const tenantId = input.tenantId ?? stringValue(remoteTenant?.id);
|
||||
const tenantName = input.tenantName ?? stringValue(remoteTenant?.name);
|
||||
const id = input.id ?? tenantSlug ?? tenantId;
|
||||
if (!id) throw new Error("Missing required JSON field: id. Seal whoami did not return tenantSlug or tenantId.");
|
||||
if (!id) throw usageError("Missing required JSON field: id. Seal whoami did not return tenantSlug or tenantId.");
|
||||
const expiresAt = auth.expiresAt
|
||||
? normalizeBeijingIso(auth.expiresAt)
|
||||
: formatBeijingIso(Date.now() + auth.expiresIn * 1000);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { validationError } from "../../../core/errors.js";
|
||||
import { readFileSync } from "node:fs"
|
||||
import { webhookHeaders } from "./signature.js"
|
||||
import { buildAttachmentPlans, injectAttachmentPlan } from "./attachments.js"
|
||||
@@ -9,7 +10,7 @@ import type { MaterialPackFilePolicyPatch } from "./policy.js"
|
||||
function webhookInfo(url: string): { baseUrl: string; webhookId: string } {
|
||||
const parsed = new URL(url)
|
||||
const match = parsed.pathname.match(/\/webhook\/([^/]+)/)
|
||||
if (!match) throw new Error("Webhook URL 必须包含 /webhook/{webhookId}/document")
|
||||
if (!match) throw validationError("Webhook URL 必须包含 /webhook/{webhookId}/document")
|
||||
return { baseUrl: `${parsed.protocol}//${parsed.host}`, webhookId: match[1]! }
|
||||
}
|
||||
|
||||
@@ -72,7 +73,7 @@ async function prepare(
|
||||
entries = await readZipEntries(fileBuffer)
|
||||
validatePackEntries(entries, filePolicy)
|
||||
const info = entries.find((entry) => entry.fileName === "信息表.xlsx")
|
||||
if (!info) throw new Error("ZIP 根目录缺少信息表.xlsx")
|
||||
if (!info) throw validationError("ZIP 根目录缺少信息表.xlsx")
|
||||
workbook = await extractZipEntry(fileBuffer, info)
|
||||
}
|
||||
const parsed = await parseMaterialWorkbook(workbook)
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { KyInstance } from "ky";
|
||||
import type { ApprovalRun, WebhookIntegration } from "../types.js";
|
||||
import type { MaterialField } from "../material-pack/types.js";
|
||||
import { webhookHeaders } from "../material-pack/signature.js";
|
||||
import { CliError, confirmationRequired, validationError } from "../../../core/errors.js";
|
||||
import { CliError, confirmationRequired, validationError, usageError } from "../../../core/errors.js";
|
||||
import type { CorpConfig } from "../../../core/config/types.js";
|
||||
import { resolveSealCustomHeaders } from "../../../core/http/request-headers.js";
|
||||
import * as api from "../api.js";
|
||||
@@ -131,7 +131,7 @@ export function extractWebhookInfo(url: string): { baseUrl: string; webhookId: s
|
||||
const parsed = new URL(url);
|
||||
const match = parsed.pathname.match(/\/webhook\/([^/]+)/);
|
||||
if (!match) {
|
||||
throw new Error(`Webhook URL 必须包含 /webhook/{webhookId}/document,收到: ${url}`);
|
||||
throw validationError(`Webhook URL 必须包含 /webhook/{webhookId}/document,收到: ${url}`);
|
||||
}
|
||||
const webhookId = match[1]!;
|
||||
const baseUrl = `${parsed.protocol}//${parsed.host}`;
|
||||
@@ -469,9 +469,7 @@ export async function executeApprovalRunsReplay(
|
||||
}
|
||||
runs = search.records;
|
||||
} else {
|
||||
throw new Error(
|
||||
"Usage: seal-use webhook replay <recordId> [--sn <documentSN>] [--limit <n>] [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>] [--dry-run]"
|
||||
);
|
||||
throw usageError("Usage: seal-use webhook replay <recordId> [--sn <documentSN>] [--limit <n>] [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>] [--dry-run]");
|
||||
}
|
||||
|
||||
const docs = runs.map((run) => ({
|
||||
|
||||
@@ -122,6 +122,15 @@ describe("local report CLI", () => {
|
||||
expect(html).not.toContain("file://");
|
||||
expect(html).not.toContain("cdn.jsdelivr");
|
||||
expect(html).toContain("测试企业");
|
||||
expect(html).toContain('<section class="report-glossary-page">');
|
||||
expect(html).toContain("附录:核心术语与指标定义规范");
|
||||
|
||||
const outNoGlossary = join(dir, "build", "无附录");
|
||||
const resultNoGlossary = await runCli(["report", "render", file, "--out", outNoGlossary, "--format", "html", "--no-glossary", "--chrome", join(dir, "absent")]);
|
||||
expect(resultNoGlossary.exitCode).toBe(0);
|
||||
const htmlNoGlossary = readFileSync(outNoGlossary + ".html", "utf8");
|
||||
expect(htmlNoGlossary).not.toContain('<section class="report-glossary-page">');
|
||||
expect(htmlNoGlossary).not.toContain("附录:核心术语与指标定义规范");
|
||||
});
|
||||
|
||||
test("failed validation prevents rendering and returns issues without creating outputs", async () => {
|
||||
@@ -199,6 +208,7 @@ describe("local report CLI", () => {
|
||||
expect(existsSync(join(packageDir, "报告.md.assets"))).toBe(true);
|
||||
expect(existsSync(join(packageDir, "报告.md.assets", "1-chart.svg"))).toBe(true);
|
||||
expect(existsSync(join(packageDir, "报告.html"))).toBe(true);
|
||||
expect(readFileSync(join(packageDir, "报告.html"), "utf8")).toContain('<section class="report-glossary-page">');
|
||||
});
|
||||
|
||||
test("export packages companion 4x PNGs for vector SVGs when Chrome is available", async () => {
|
||||
|
||||
@@ -14,6 +14,7 @@ export type ReportRenderOptions = {
|
||||
width?: number;
|
||||
chrome?: string;
|
||||
overwrite?: boolean;
|
||||
glossary?: boolean;
|
||||
};
|
||||
|
||||
function inputFile(file: string): string {
|
||||
@@ -101,7 +102,7 @@ export async function renderReportFile(file: string, options: ReportRenderOption
|
||||
const stage = mkdtempSync(join(tmpdir(), "seal-report-render-"))
|
||||
try {
|
||||
const html = join(stage, "report.html")
|
||||
writeFileSync(html, await buildReportHtml(path))
|
||||
writeFileSync(html, await buildReportHtml(path, { glossary: options.glossary !== false }))
|
||||
if (binary) {
|
||||
const profile = join(stage, "browser-profile")
|
||||
mkdirSync(profile, { mode: 0o700 })
|
||||
@@ -132,6 +133,7 @@ export type ReportPackageOptions = {
|
||||
width?: number;
|
||||
chrome?: string;
|
||||
overwrite?: boolean;
|
||||
glossary?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -156,7 +158,8 @@ export async function exportReportPackage(file: string, options: ReportPackageOp
|
||||
format: options.format ?? "all",
|
||||
width: options.width,
|
||||
chrome: options.chrome,
|
||||
overwrite: options.overwrite
|
||||
overwrite: options.overwrite,
|
||||
glossary: options.glossary
|
||||
});
|
||||
|
||||
// 当处于全量或图片导出模式时,为伴生资产目录中的矢量 SVG 自动增补 4x Retina 超高清 PNG 原图
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* 审核报告核心术语与计算口径定义规范(附录解释页)。
|
||||
* 作为 HTML、PDF、长图 PNG 渲染产物末尾的独立解释页面,帮助管理层、审计部门与业务团队统一理解报告指标。
|
||||
* 独立于报告原始 Markdown 之外,由渲染流水线自动追加,无须用户手动编写模板片段。
|
||||
*/
|
||||
|
||||
export const REPORT_GLOSSARY_MARKDOWN = `
|
||||
<!-- section:glossary-appendix -->
|
||||
<section class="report-glossary-page">
|
||||
|
||||
## 附录:核心术语与指标定义规范
|
||||
|
||||
为确保管理层、审计部门与业务团队对报告评估口径达成一致理解,本附录对报告中涉及的专业术语、处理方向、核心量化指标与标识主键进行标准定义。
|
||||
|
||||
### 一、 审批动作与五类复核裁决
|
||||
|
||||
| 概念分类 | 术语名称 | 定义与事实认定标准 | 适用场景与边界说明 |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| **线上审批动作** | **AI 审核建议** | 线上业务流水线中,AI 模型基于企业预设规则给出的自动化判断(\`同意\` / \`驳回\` / \`违规拦截\`)。 | 反映模型当时的线上运行记录,不自动代表事实真理。 |
|
||||
| **线上审批动作** | **人工审批结论** | 业务单据流转中,企业审批人在系统后台实际执行的最终处理结果(\`同意\` / \`驳回\` / \`终止\`)。 | 反映企业实际操作事实,可能包含历史特批、人为疏漏或操作误判。 |
|
||||
| **事后复核裁决** | **\`ai_correct\`<br>AI正确 / 人工失准** | 制度规则明确,单据客观违规或合规,AI 依规判定准确;人工存在漏审、违规放行或误驳回。 | 证明 AI 规则执行严格,人工初审存在风险或操作失准。 |
|
||||
| **事后复核裁决** | **\`human_correct\`<br>人工正确 / AI误判** | AI 因长尾语义理解不全、格式特殊或规则盲区误判;人工按真实业务事实处置正确。 | 明确属于规则或模型缺陷,应纳入规则优化与回归测试样本池。 |
|
||||
| **事后复核裁决** | **\`both_correct\`<br>双方均正确** | 双方基于不同合法口径均成立:AI 严格按线上现行规则校验正确,人工依据线下特批或特有制度豁免放行。 | 需明确评价标准;通常反映线上规则尚未覆盖最新线下特批制度。 |
|
||||
| **事后复核裁决** | **\`both_wrong\`<br>双方均误判** | 双方均未识别出单据的隐蔽违规(如关联方交易违规),或均误读了制度条款导致处理失准。 | 需同时对 AI 规则库与人工审批作业规范进行同步整改。 |
|
||||
| **事后复核裁决** | **\`undecided\`<br>存疑待定** | 因缺失核心原始凭证、有效特批待提供或业务争议,尚无法形成最终定性裁决结论。 | 需后续补充材料;前置门禁允许通过,但在统计分母中保留且不虚增正确分子。 |
|
||||
|
||||
### 二、 审核处理方向与分歧核定
|
||||
|
||||
- **审批处理的两大基本方向(放行 vs 拦截)**:
|
||||
无论各业务系统如何命名单据状态,本质上只有两类处理动作:
|
||||
- **放行(通过)**:包括系统状态中的 \`同意\`、\`通过\`、\`已支付\`、\`审批完成\`、\`APPROVE\` 等,代表认可单据凭证合规并准予进入下一环节。
|
||||
- **拦截(驳回)**:包括系统状态中的 \`驳回\`、\`拒绝\`、\`终止\`、\`作废\`、\`REJECT\` 等,代表发现超标、发票异常、缺少关键附件等问题并予以阻断。
|
||||
|
||||
- **同向一致(AI 与人工意见相同)**:
|
||||
AI 的审核建议与人工审批人的最终处理方向一致(双方都同意放行,或双方都驳回拦截)。在未进行人工逐笔复核时,统计口径默认视为双方判断均合理准确。
|
||||
|
||||
- **人机分歧(AI 与人工意见相左)**:
|
||||
AI 建议与人工处理意见相反(即“AI 建议拦截但人工予以放行”,或“AI 判定合规但人工线下驳回”)。分歧单据是报告评价的核心分析池,必须 100% 逐单核查原始凭证与线下背景,核实到底是 AI 发现了漏网风险,还是 AI 规则存在缺陷误判。
|
||||
|
||||
### 三、 核心量化指标与计算说明
|
||||
|
||||
#### 1. AI 审核准确率 (AI Accuracy)
|
||||
|
||||
衡量 AI 模型依据企业既定规则做出正确判断的比例。
|
||||
|
||||
$$ \\text{AI 审核准确率} = \\frac{\\text{AI 判定正确单数}}{\\text{全量样本单数}} \\times 100\\% $$
|
||||
|
||||
- **分子(正确单数)**:包括复核裁决为 AI 正确(\`ai_correct\`)、双方均正确(\`both_correct\`),以及未进行人工复核但双方处理一致的单据(默认正确)。
|
||||
- **分母(全量样本)**:统计周期内已完结审核的全部有效单据总数。
|
||||
|
||||
#### 2. 人工审核准确率 (Human Accuracy)
|
||||
|
||||
衡量人工审批人在已复核单据中的准确表现(仅在存在人工裁决样本时披露)。
|
||||
|
||||
$$ \\text{人工审核准确率} = \\frac{\\text{人工判定正确单数}}{\\text{已复核样本总量}} \\times 100\\% $$
|
||||
|
||||
- **分子(正确单数)**:包括复核裁决为人工正确(\`human_correct\`)、双方均正确(\`both_correct\`),以及未复核的同向一致单据。
|
||||
- **分母(复核总量)**:已完成事后人工定性复核及同向默认的单据总数。
|
||||
|
||||
#### 3. AI 额外风险拦截 (Risk Interception)
|
||||
|
||||
衡量 AI 作为数字防线,有效防堵企业财务隐患与人为疏漏的能力。
|
||||
|
||||
- **严格认定条件**(三者必须同时满足):
|
||||
1. **AI 建议拦截**(\`aiDecision = reject\`);
|
||||
2. **人工初审放行**(\`humanResult = pass\`);
|
||||
3. **业务复核确认 AI 正确**(\`verdict = ai_correct\`)。
|
||||
- **指标意义**:反映真实防堵的发票违规、超标或凭证不全单据,是评价 AI 上线直接风控收益的核心指标。
|
||||
|
||||
#### 4. 辅助运营指标
|
||||
|
||||
- **自动化审批率 (Automation Rate)**:单据完全由 AI 依规自动放行、无需人工二次介入审批的比例,直接衡量财务人效释放。
|
||||
- **平均审核耗时 (Average Duration)**:单据进入审核流水线至模型输出完整意见的平均耗时(秒),体现审核时效加速。
|
||||
|
||||
### 四、 单据双主键标识规范
|
||||
|
||||
- **审核ID (\`recordId\`)**:单次 AI 审核运行的全局唯一实例主键(如 \`run-xxxx\`)。同一业务单据若多次提交或重跑,每次运行产生唯一的 \`recordId\`。复核裁决与台账关联优先以 \`recordId\` 为绝对主键精确锁定版本。
|
||||
- **单据编号 (\`SN\`)**:业务源系统中的单据业务自然键(如 \`CL202608001\`)。用于业务人员在原业务系统中反向检索原单及沟通核对。当台账缺少 \`recordId\` 时,系统自动回退兼容按 \`SN\` 关联。
|
||||
|
||||
</section>
|
||||
`.trim();
|
||||
@@ -24,7 +24,7 @@ function source(content: string) {
|
||||
describe("native report HTML", () => {
|
||||
test("preserves code escaping and leaves code examples and escaped dollars out of math rendering", async () => {
|
||||
globalThis.fetch = Object.assign(async () => { throw new Error("must not fetch") }, { preconnect: originalFetch.preconnect })
|
||||
const html = await buildReportHtml(source('# Title\n\n```text\n<img src="missing.png">\n$example$\n```\n\n\\$5\n'))
|
||||
const html = await buildReportHtml(source('# Title\n\n```text\n<img src="missing.png">\n$example$\n```\n\n\\$5\n'), { glossary: false })
|
||||
expect(html).toContain("<img")
|
||||
expect(html).toContain("$example$")
|
||||
expect(html).not.toContain("renderMathInElement")
|
||||
@@ -37,7 +37,7 @@ describe("native report HTML", () => {
|
||||
return new Response(url.endsWith("katex.min.css") ? ".katex{src:url(fonts/Mock.woff2)}" : "fixture")
|
||||
}, { preconnect: originalFetch.preconnect })
|
||||
const file = source("# Math\n\n$a_b < c$\n\n$$\\frac{100}{100} = 100\\%$$\n")
|
||||
const html = await buildReportHtml(file)
|
||||
const html = await buildReportHtml(file, { glossary: false })
|
||||
expect(html).toContain("a_b < c")
|
||||
expect(html).not.toContain("<em>")
|
||||
expect(html).toContain("\\displaystyle \\frac{100}{100} = 100\\%")
|
||||
@@ -47,15 +47,47 @@ describe("native report HTML", () => {
|
||||
expect(html).not.toContain("cdn.jsdelivr")
|
||||
expect(calls).toHaveLength(4)
|
||||
globalThis.fetch = Object.assign(async () => { throw new Error("offline cache miss") }, { preconnect: originalFetch.preconnect })
|
||||
expect(await buildReportHtml(file)).toBe(html)
|
||||
expect(await buildReportHtml(file, { glossary: false })).toBe(html)
|
||||
})
|
||||
test("failed formula downloads produce domain errors instead of an incomplete HTML", async () => {
|
||||
globalThis.fetch = Object.assign(async () => new Response("not found", { status: 404 }), { preconnect: originalFetch.preconnect })
|
||||
await expect(buildReportHtml(source("# Math\n\n$x$"))).rejects.toMatchObject({ exitCode: 1 })
|
||||
await expect(buildReportHtml(source("# Math\n\n$x$"), { glossary: false })).rejects.toMatchObject({ exitCode: 1 })
|
||||
})
|
||||
test("percent-encoded literal entity names are decoded only once", async () => {
|
||||
const file = source("# Image\n\n")
|
||||
writeFileSync(join(dirname(file), "&.svg"), '<svg xmlns="http://www.w3.org/2000/svg"></svg>')
|
||||
expect(await buildReportHtml(file)).toContain("data:image/svg+xml;base64,")
|
||||
expect(await buildReportHtml(file, { glossary: false })).toContain("data:image/svg+xml;base64,")
|
||||
})
|
||||
test("appends terms glossary appendix by default and respects glossary: false", async () => {
|
||||
globalThis.fetch = Object.assign(async (input: string | URL | Request) => {
|
||||
const url = String(input)
|
||||
return new Response(url.endsWith("katex.min.css") ? ".katex{src:url(fonts/Mock.woff2)}" : "fixture")
|
||||
}, { preconnect: originalFetch.preconnect })
|
||||
|
||||
const file = source("# Sample Report\n\nSome content\n")
|
||||
const defaultHtml = await buildReportHtml(file)
|
||||
expect(defaultHtml).toContain('<section class="report-glossary-page">')
|
||||
expect(defaultHtml).toContain("附录:核心术语与指标定义规范")
|
||||
expect(defaultHtml).toContain("审批动作与五类复核裁决")
|
||||
expect(defaultHtml).toContain("审核处理方向与分歧核定")
|
||||
expect(defaultHtml).toContain("核心量化指标与计算说明")
|
||||
expect(defaultHtml).toContain("单据双主键标识规范")
|
||||
expect(defaultHtml).toContain("ai_correct")
|
||||
expect(defaultHtml).toContain("recordId")
|
||||
|
||||
const noGlossaryHtml = await buildReportHtml(file, { glossary: false })
|
||||
expect(noGlossaryHtml).not.toContain('<section class="report-glossary-page">')
|
||||
expect(noGlossaryHtml).not.toContain("附录:核心术语与指标定义规范")
|
||||
})
|
||||
test("does not duplicate glossary if already present in markdown", async () => {
|
||||
globalThis.fetch = Object.assign(async (input: string | URL | Request) => {
|
||||
const url = String(input)
|
||||
return new Response(url.endsWith("katex.min.css") ? ".katex{src:url(fonts/Mock.woff2)}" : "fixture")
|
||||
}, { preconnect: originalFetch.preconnect })
|
||||
|
||||
const file = source("# Report\n\n<!-- section:glossary-appendix -->\nExisting glossary")
|
||||
const html = await buildReportHtml(file)
|
||||
const occurrences = html.split("section:glossary-appendix").length - 1
|
||||
expect(occurrences).toBe(1)
|
||||
})
|
||||
})
|
||||
@@ -5,6 +5,7 @@ import { basename, dirname, extname, join, resolve } from "node:path"
|
||||
import { Marked, type TokenizerExtension, type Tokens } from "marked"
|
||||
import { CliError } from "../../../../core/errors.js"
|
||||
import { REPORT_CSS } from "../templates/resources.js"
|
||||
import { REPORT_GLOSSARY_MARKDOWN } from "./glossary.js"
|
||||
|
||||
const katexBase = "https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/"
|
||||
const mimeTypes: Record<string, string> = {
|
||||
@@ -20,7 +21,7 @@ function decodeHtml(text: string) {
|
||||
return text.replace(/&(?:amp|lt|gt|quot|apos|#\d+|#x[\da-f]+);/gi, (entity) => {
|
||||
if (entity.startsWith("&#")) {
|
||||
const number = entity.toLowerCase().startsWith("&#x") ? parseInt(entity.slice(3, -1), 16) : Number(entity.slice(2, -1))
|
||||
return number > 0 && number <= 0x10ffff ? String.fromCodePoint(number) : "�"
|
||||
return number > 0 && number <= 0x10ffff ? String.fromCodePoint(number) : ""
|
||||
}
|
||||
return ({ "&": "&", "<": "<", ">": ">", """: '"', "'": "'" })[entity.toLowerCase()] ?? entity
|
||||
})
|
||||
@@ -63,9 +64,23 @@ async function mathAssets(): Promise<{ styles: string; scripts: string }> {
|
||||
return { styles: `<style>${css}</style>\n`, scripts: scripts.join("\n") }
|
||||
}
|
||||
|
||||
export type BuildReportHtmlOptions = {
|
||||
glossary?: boolean;
|
||||
};
|
||||
|
||||
/** 渲染完整 HTML;标题取自正文 H1,并剥掉可能夹在里面的 HTML 注释。 */
|
||||
export async function buildReportHtml(file: string): Promise<string> {
|
||||
const text = readFileSync(file, "utf8").replace(/\r\n?/g, "\n")
|
||||
export async function buildReportHtml(
|
||||
file: string,
|
||||
options: BuildReportHtmlOptions = {}
|
||||
): Promise<string> {
|
||||
let text = readFileSync(file, "utf8").replace(/\r\n?/g, "\n")
|
||||
const shouldAppendGlossary =
|
||||
options.glossary !== false &&
|
||||
!text.includes("<!-- section:glossary-appendix -->") &&
|
||||
!text.includes("附录:核心术语与指标定义规范")
|
||||
if (shouldAppendGlossary) {
|
||||
text = `${text}\n\n${REPORT_GLOSSARY_MARKDOWN}\n`
|
||||
}
|
||||
let hasMath = false
|
||||
const math: TokenizerExtension = {
|
||||
name: "reportMath", level: "inline", start: (source) => source.indexOf("$"),
|
||||
@@ -80,7 +95,7 @@ export async function buildReportHtml(file: string): Promise<string> {
|
||||
// Tokenize math before Markdown emphasis; escape only the math text, never unescape the full HTML.
|
||||
const markdown = new Marked({ extensions: [{ ...math, renderer(token: Tokens.Generic) {
|
||||
const expression = String(token.text).replace(/(?<!\\)%/g, "\\%")
|
||||
return escapeHtml(`\\(${token.display ? "\\displaystyle " : ""}${expression} \\)`)
|
||||
return escapeHtml(token.display ? `\\[\\displaystyle ${expression} \\]` : `\\(${expression} \\)`)
|
||||
} }] })
|
||||
let body = markdown.parse(text, { async: false })
|
||||
// 本地图片内嵌;marked 已做一次百分号编码,先解码再读取,产物移动后仍可显示。
|
||||
@@ -92,6 +107,6 @@ export async function buildReportHtml(file: string): Promise<string> {
|
||||
})
|
||||
const title = text.match(/^#\s+(.+?)\s*$/m)?.[1]?.replace(/<!--[\s\S]*?-->/g, "").trim() || basename(file, extname(file))
|
||||
const assets = hasMath ? await mathAssets() : { styles: "", scripts: "" }
|
||||
const init = hasMath ? '<script>document.addEventListener("DOMContentLoaded",function(){renderMathInElement(document.body,{delimiters:[{left:"\\\\(",right:"\\\\)",display:false}],throwOnError:false});});</script>' : ""
|
||||
const init = hasMath ? '<script>document.addEventListener("DOMContentLoaded",function(){renderMathInElement(document.body,{delimiters:[{left:"\\\\[",right:"\\\\]",display:true},{left:"\\\\(",right:"\\\\)",display:false}],throwOnError:false});});</script>' : ""
|
||||
return `<!doctype html>\n<html lang="zh-CN">\n<head>\n<meta charset="utf-8">\n<title>${escapeHtml(title)}</title>\n${assets.styles}<style>${REPORT_CSS}</style>\n</head>\n<body>\n${assets.scripts}\n${body}\n${init}\n</body>\n</html>\n`
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "./browser.js";
|
||||
export * from "./html.js";
|
||||
export * from "./png.js";
|
||||
export * from "./glossary.js";
|
||||
@@ -24,10 +24,13 @@ em { color:var(--muted); font-size:14px; }
|
||||
hr { border:0; border-top:1px solid var(--line); margin:32px 0; }
|
||||
a { color:#0969da; }
|
||||
.katex-display { margin:18px 0; }
|
||||
.report-glossary-page { margin-top:48px; padding-top:24px; border-top:2px dashed var(--line); page-break-before:always; break-before:page; }
|
||||
.report-glossary-page h2 { margin-top:0; }
|
||||
@page { size: A4; margin: 14mm 12mm; }
|
||||
@media print {
|
||||
body { max-width:none; padding:0; font-size:12pt; }
|
||||
h2, h3 { page-break-after:avoid; break-after:avoid; }
|
||||
tr, img, blockquote { page-break-inside:avoid; break-inside:avoid; }
|
||||
thead { display:table-header-group; }
|
||||
.report-glossary-page { margin-top:0; padding-top:0; border-top:none; page-break-before:always; break-before:page; }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { validationError } from "../../../core/errors.js";
|
||||
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import type { RuleLintTarget } from "../linter/types.js";
|
||||
@@ -34,7 +35,7 @@ export function parseLocalRulesContent(rawText: string): {
|
||||
try {
|
||||
parsed = JSON.parse(rawText);
|
||||
} catch (err) {
|
||||
throw new Error(`本地规则文件 JSON 解析失败: ${err instanceof Error ? err.message : String(err)}`);
|
||||
throw validationError(`本地规则文件 JSON 解析失败: ${err instanceof Error ? err.message : String(err)}`);
|
||||
}
|
||||
|
||||
if (Array.isArray(parsed)) {
|
||||
@@ -50,7 +51,7 @@ export function parseLocalRulesContent(rawText: string): {
|
||||
const obj = parsed as Record<string, unknown>;
|
||||
const rawRules = Array.isArray(obj.rules) ? obj.rules : undefined;
|
||||
if (!rawRules) {
|
||||
throw new Error("本地规则文件格式错误: 顶层必须为规则数组或包含 'rules' 数组的对象");
|
||||
throw validationError("本地规则文件格式错误: 顶层必须为规则数组或包含 'rules' 数组的对象");
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -65,7 +66,7 @@ export function parseLocalRulesContent(rawText: string): {
|
||||
};
|
||||
}
|
||||
|
||||
throw new Error("本地规则文件格式错误: 顶层必须为规则数组或包含 'rules' 数组的对象");
|
||||
throw validationError("本地规则文件格式错误: 顶层必须为规则数组或包含 'rules' 数组的对象");
|
||||
}
|
||||
|
||||
function parseCodeNumber(value: unknown): number | undefined {
|
||||
@@ -80,7 +81,7 @@ function parseCodeNumber(value: unknown): number | undefined {
|
||||
function normalizeRuleItems(items: unknown[]): LocalRuleItem[] {
|
||||
return items.map((item, idx) => {
|
||||
if (!item || typeof item !== "object") {
|
||||
throw new Error(`第 ${idx + 1} 条规则格式错误: 必须为对象`);
|
||||
throw validationError(`第 ${idx + 1} 条规则格式错误: 必须为对象`);
|
||||
}
|
||||
const r = item as Record<string, unknown>;
|
||||
const description = typeof r.description === "string" ? r.description.trim() : "";
|
||||
@@ -116,7 +117,7 @@ export function loadLocalRulesFile(filePath: string): {
|
||||
} {
|
||||
const resolved = resolve(filePath);
|
||||
if (!existsSync(resolved)) {
|
||||
throw new Error(`未找到本地规则文件: ${filePath} (${resolved})`);
|
||||
throw validationError(`未找到本地规则文件: ${filePath} (${resolved})`);
|
||||
}
|
||||
const content = readFileSync(resolved, "utf8");
|
||||
const parsed = parseLocalRulesContent(content);
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import { z } from "zod";
|
||||
import { runCli } from "./cli/runner.js";
|
||||
import { isReadOnlyCliCommand } from "./cli/read-only.js";
|
||||
import { normalizeCliArgs, tokenizeCommand } from "./cli/tokenize.js";
|
||||
import { classifyCliError } from "./cli/errors.js";
|
||||
import { classifyCliError } from "./core/errors.js";
|
||||
import { VERSION } from "./version.js";
|
||||
import { isCompiledBinary, resolveAppRoot, resolveDefaultLauncher } from "./core/runtime.js";
|
||||
|
||||
|
||||
Reference in new issue
Block a user