From e716f069edf5ab29b60912c4c404135e7f4a015b Mon Sep 17 00:00:00 2001 From: yunyingk Date: Tue, 25 Aug 2026 15:19:11 +0800 Subject: [PATCH] Release v0.7.1: Add approval-runs list alias, handle EPIPE, and improve summary hints --- .zcode-plugin/plugin.json | 2 +- dist/mcp/server.js | 88 ++++++++++++++++--------------- dist/openapi.json | 2 +- openapi/openapi.yaml | 2 +- package.json | 2 +- skills/seal-home/SKILL.md | 8 +-- src/cli.ts | 21 +++++++- src/cli/commands/approval-runs.ts | 17 +++--- 8 files changed, 84 insertions(+), 58 deletions(-) diff --git a/.zcode-plugin/plugin.json b/.zcode-plugin/plugin.json index ebd7c03..cf2ad6a 100644 --- a/.zcode-plugin/plugin.json +++ b/.zcode-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "seal-home", - "version": "0.7.0", + "version": "0.7.1", "description": "Seal Home tenant operations: approval-run diagnosis, minimal rule remediation, delegation links, Hose/合思 authorization, users, rules, billing, and search.", "author": { "name": "yingqing" diff --git a/dist/mcp/server.js b/dist/mcp/server.js index 2ac2346..8124d90 100644 --- a/dist/mcp/server.js +++ b/dist/mcp/server.js @@ -24943,7 +24943,7 @@ async function createSealClientForToken(corp, token) { // package.json var package_default = { name: "seal-home", - version: "0.7.0", + version: "0.7.1", type: "module", module: "src/server.ts", bin: { @@ -28692,7 +28692,7 @@ function joinOutput(lines) { function redactSensitiveText(value) { return value.replace(/([?&](?:accessToken|token|returnToken)=)[^&\s]+/gi, "$1").replace(/(Bearer\s+)[A-Za-z0-9._~+/=-]+/gi, "$1"); } -function printJson(value, options = {}) { +function printJson2(value, options = {}) { protectLargeOutput(value, options); const json2 = `${JSON.stringify(value, null, 2)} `; @@ -28829,9 +28829,9 @@ function globalConfigSummary(config2 = loadGlobalConfig()) { }; } async function runTool(name, client, corp, params, options = {}) { - printJson(await runToolResult(name, client, corp, params), options); + printJson2(await runToolResult2(name, client, corp, params), options); } -async function runToolResult(name, client, corp, params) { +async function runToolResult2(name, client, corp, params) { const tool = sealTools.find((item) => item.name === name); if (!tool) throw new Error(`Unknown Seal tool: ${name}`); @@ -28843,7 +28843,7 @@ async function runToolResult(name, client, corp, params) { // src/cli/commands/approval-runs.ts async function handleApprovalRunsCommand(action, maybeName, client, corp, args) { if (action === "summary") { - await runTool("seal_approval_runs_summary", client, corp, { + const result = await runToolResult("seal_approval_runs_summary", client, corp, { date: stringOption(args.options.date), timezone: stringOption(args.options.timezone), limit: numberOption(args.options.limit), @@ -28856,10 +28856,14 @@ async function handleApprovalRunsCommand(action, maybeName, client, corp, args) sourceDocumentId: stringOption(args.options.sourceDocumentId), humanResult: stringOption(args.options.humanResult), query: stringOption(args.options.query) - }, outputOptions(args.options)); + }); + if (result?.matched === 0 && result?.total > 0) { + console.error(`提示:在 ${result.date} 未匹配到记录(该企业共有 ${result.total} 条历史记录)。可使用 --date YYYY-MM-DD 指定日期,或运行 seal-home approval-runs list --limit 10 查看最近记录。`); + } + printJson(result, outputOptions(args.options)); return; } - if (action === "search") { + if (action === "search" || action === "list") { await runTool("seal_approval_runs_search", client, corp, { limit: numberOption(args.options.limit), offset: numberOption(args.options.offset), @@ -28960,12 +28964,12 @@ async function handleApprovalRunsCommand(action, maybeName, client, corp, args) // src/cli/commands/auth.ts async function handleAuthCommand(action, corp, args) { if (action === "diagnose") { - printJson(await diagnoseAuth(corp)); + printJson2(await diagnoseAuth(corp)); return; } if (action === "hose-link") { const expiresIn = numberOption(args.options.expire) ?? 7200; - printJson(await getHoseProvisionalAuthLink(corp, expiresIn)); + printJson2(await getHoseProvisionalAuthLink(corp, expiresIn)); return; } throw new Error(`Unknown auth command: ${action ?? ""}. Run 'seal-home help' for available commands.`); @@ -29204,20 +29208,20 @@ async function handleBillingCommand(action, client, corp, args) { // src/cli/commands/config.ts function handleConfigCommand(action, maybeName, args) { if (action === "paths") { - printJson({ + printJson2({ candidates: getEnterprisesDirCandidates(), globalConfigFile: resolveGlobalConfigFile() }); return; } if (action === "get" || action === "status") { - printJson(globalConfigSummary()); + printJson2(globalConfigSummary()); return; } if (action === "mode") { const mode = maybeName ?? stringOption(args.options.mode); if (!mode) { - printJson(globalConfigSummary()); + printJson2(globalConfigSummary()); return; } const stateful = parseStateMode(mode); @@ -29228,7 +29232,7 @@ function handleConfigCommand(action, maybeName, args) { stateful, ...defaultCorpId ? { defaultCorpId } : {} }); - printJson(globalConfigSummary(config2)); + printJson2(globalConfigSummary(config2)); return; } throw new Error(`Unknown config command: ${action ?? ""}. Run 'seal-home help' for available commands.`); @@ -29282,7 +29286,7 @@ async function handleCorpsCommand(action, maybeName, args) { if (corps.length === 0) { console.error("提示:当前未检测到企业配置。你可以使用 seal-home corps add-hose 或 seal-home corps add-seal 添加企业,或运行 seal-home help 查看说明。"); } - printJson(corps.map((item) => ({ + printJson2(corps.map((item) => ({ id: item.id, name: item.name, sourceType: item.source.type, @@ -29293,7 +29297,7 @@ async function handleCorpsCommand(action, maybeName, args) { } if (action === "current") { const corp = selectCorp(stringOption(args.options.corp)); - printJson({ + printJson2({ id: corp.id, name: corp.name, sourceType: corp.source.type, @@ -29311,7 +29315,7 @@ async function handleCorpsCommand(action, maybeName, args) { } const corp = selectCorp(corpId); saveGlobalConfig({ ...globalConfig2, stateful: true, defaultCorpId: corp.id }); - printJson({ + printJson2({ current: true, id: corp.id, name: corp.name @@ -29377,7 +29381,7 @@ async function addHoseCorp(input) { } writeFileSync4(file2, `${JSON.stringify(config2, null, 2)} `, { mode: 384 }); - printJson({ + printJson2({ id, name, corpId, @@ -29439,7 +29443,7 @@ async function addSealCorp(input) { } writeFileSync4(file2, `${JSON.stringify(config2, null, 2)} `, { mode: 384 }); - printJson({ + printJson2({ id, name: config2.name, tenantId, @@ -29541,7 +29545,7 @@ async function handleMcpCommand(action, args) { await startServer(); } function printMcpConfig() { - printJson({ + printJson2({ mcpServers: { "seal-home": { type: "stdio", @@ -29559,7 +29563,7 @@ var openapi_default = { openapi: "3.1.0", info: { title: "seal-home Wrapped API", - version: "0.7.0", + version: "0.7.1", description: `Planned HTTP contract for the seal-home wrapped backend API. These endpoints describe the intended stable API for frontend developers and agents once @@ -32907,7 +32911,7 @@ function getOpenApiSchema() { // src/cli/commands/openapi.ts function handleOpenApiCommand(args) { const schema = getOpenApiSchema(); - printJson(schema, { ...outputOptions(args.options), allowFull: true }); + printJson2(schema, { ...outputOptions(args.options), allowFull: true }); } // src/cli/commands/permissions.ts @@ -32979,9 +32983,9 @@ async function handleRulesCommand(action, maybeName, client, corp, args) { }, outputOptions(args.options)); return; } - const result = await runToolResult("seal_approval_rules_list", client, corp, { limit, offset }); + const result = await runToolResult2("seal_approval_rules_list", client, corp, { limit, offset }); protectLargeRuleListOutput(result, booleanOption(args.options.full) === true); - printJson(result); + printJson2(result); return; } if (action === "clear") { @@ -32990,18 +32994,18 @@ async function handleRulesCommand(action, maybeName, client, corp, args) { if (!confirmed && !dryRun) { throw new Error("Refusing to clear rules without --yes. Use --dry-run to preview."); } - const result = await runToolResult("seal_approval_rules_clear", client, corp, { + const result = await runToolResult2("seal_approval_rules_clear", client, corp, { dryRun, recode: booleanOption(args.options.recode) }); if (!confirmed && dryRun && result && typeof result === "object") { - printJson({ + printJson2({ ...result, nextCommand: `seal-home rules clear --corp ${corp.id} --yes` }, outputOptions(args.options)); return; } - printJson(result, outputOptions(args.options)); + printJson2(result, outputOptions(args.options)); return; } if (action === "versions") { @@ -33204,7 +33208,7 @@ async function handleServiceCommand(action, runtime) { launcher: runtime.launcher }); if (result !== undefined) - printJson(result); + printJson2(result); } // src/cli/commands/simulation.ts @@ -33286,13 +33290,13 @@ import { dirname as dirname3, join as join6 } from "node:path"; // skills/seal-home/SKILL.md var SKILL_default = `--- name: seal-home -description: "v0.7.0: Use when working with Seal Home tenant operations: packaged customer feedback from WeChat or screenshots, target-enterprise discovery, approval-run and Langfuse diagnosis, simulation test batch creation and publishing, minimal approval-rule remediation and publishing, delegation links, Hose/合思 authorization, LLM config, permissions, billing, users, rules, documents, and search." +description: "v0.7.1: Use when working with Seal Home tenant operations: packaged customer feedback from WeChat or screenshots, target-enterprise discovery, approval-run and Langfuse diagnosis, simulation test batch creation and publishing, minimal approval-rule remediation and publishing, delegation links, Hose/合思 authorization, LLM config, permissions, billing, users, rules, documents, and search." metadata: - version: 0.7.0 - short-description: Seal tenant and Hose approval automation (v0.7.0) + version: 0.7.1 + short-description: Seal tenant and Hose approval automation (v0.7.1) --- -# Seal Home (v0.7.0) +# Seal Home (v0.7.1) Use the \`seal_cli\` MCP tool when it is available; pass the command string as its \`command\` argument. If MCP is unavailable, fall back to the global \`seal-home\` CLI. This skill is a routing layer for agents: keep this file short, choose the right command, and read a focused reference only when the task needs detail. @@ -34412,7 +34416,7 @@ function handleSkillCommand(action, maybeName, args) { const customDir = stringOption(args.options.dir) ?? stringOption(args.options.target) ?? maybeName; const targetDir = customDir ? customDir : isLocal ? join7(process.cwd(), ".agents", "skills", "seal-home") : getDefaultGlobalSkillDir(); const result = installSkillFiles(targetDir); - printJson({ + printJson2({ installed: true, targetDir: result.targetDir, fileCount: result.files.length, @@ -34423,7 +34427,7 @@ function handleSkillCommand(action, maybeName, args) { if (action === "status" || action === "get" || !action) { const globalDir = getDefaultGlobalSkillDir(); const localDir = join7(process.cwd(), ".agents", "skills", "seal-home"); - printJson({ + printJson2({ global: { dir: globalDir, installed: existsSync7(join7(globalDir, "SKILL.md")) @@ -34441,7 +34445,7 @@ function handleSkillCommand(action, maybeName, args) { // src/cli/commands/source.ts async function handleSourceCommand(action, corp) { if (action === "config") { - printJson(await resolveLiveSealEnterpriseConfig(corp)); + printJson2(await resolveLiveSealEnterpriseConfig(corp)); return; } throw new Error(`Unknown source command: ${action ?? ""}. Run 'seal-home help' for available commands.`); @@ -34456,7 +34460,7 @@ async function handleToolCommand(action, client, corp, args) { // src/cli/commands/tools.ts function handleToolsListCommand() { - printJson(sealTools.map((tool) => ({ name: tool.name, description: tool.description }))); + printJson2(sealTools.map((tool) => ({ name: tool.name, description: tool.description }))); } // src/cli/commands/update.ts @@ -34486,7 +34490,7 @@ async function handleUpdateCommand(runtime, options = {}) { }; if (!isCompiledBinary()) { if (options.checkOnly) { - printJson({ + printJson2({ updated: false, version: VERSION, mode: "source", @@ -34505,7 +34509,7 @@ async function handleUpdateCommand(runtime, options = {}) { runCommand("bun", ["install"], { cwd: runtime.appRoot }); if (wasRunning2) await runServiceCommand("start", serviceConfig); - printJson({ + printJson2({ updated: true, serviceRestarted: wasRunning2, version: VERSION, @@ -34518,7 +34522,7 @@ async function handleUpdateCommand(runtime, options = {}) { const arch = detectArch(); const release = await fetchGitHubRelease(repo, options.targetVersion); if (!release) { - printJson({ + printJson2({ updated: false, currentVersion: VERSION, mode: "binary", @@ -34530,7 +34534,7 @@ async function handleUpdateCommand(runtime, options = {}) { const isUpgrade = isNewerVersion(latestVersion, VERSION); const shouldUpdate = options.force || Boolean(options.targetVersion) || isUpgrade; if (options.checkOnly) { - printJson({ + printJson2({ updated: false, updateAvailable: isUpgrade, currentVersion: VERSION, @@ -34542,7 +34546,7 @@ async function handleUpdateCommand(runtime, options = {}) { return; } if (!shouldUpdate) { - printJson({ + printJson2({ updated: false, currentVersion: VERSION, latestVersion, @@ -34590,7 +34594,7 @@ async function handleUpdateCommand(runtime, options = {}) { if (wasRunning) await runServiceCommand("start", serviceConfig); const skillSync = syncGlobalSkillIfPresent(); - printJson({ + printJson2({ updated: true, fromVersion: VERSION, toVersion: latestVersion, @@ -34951,7 +34955,7 @@ async function dispatch(argv, runtime) { const args = parseArgs(argv); const [area, action, maybeName] = args.command; if (area === "version" || area === "v" || Boolean(args.options.version) || Boolean(args.options.v) || Boolean(args.options.V)) { - printJson({ + printJson2({ name: "seal-home", version: VERSION }); diff --git a/dist/openapi.json b/dist/openapi.json index 8b48f3f..62a041b 100644 --- a/dist/openapi.json +++ b/dist/openapi.json @@ -2,7 +2,7 @@ "openapi": "3.1.0", "info": { "title": "seal-home Wrapped API", - "version": "0.7.0", + "version": "0.7.1", "description": "Planned HTTP contract for the seal-home wrapped backend API.\n\nThese endpoints describe the intended stable API for frontend developers and agents once\nthe HTTP adapter is implemented.\nThey are not the raw downstream Seal endpoints. seal-home is responsible for enterprise\nselection, source authentication, response compaction, and diagnostics-friendly fields.\n" }, "servers": [ diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 01cefcc..f52cef4 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: seal-home Wrapped API - version: 0.7.0 + version: 0.7.1 description: | Planned HTTP contract for the seal-home wrapped backend API. diff --git a/package.json b/package.json index bfc2e26..0b24d0f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "seal-home", - "version": "0.7.0", + "version": "0.7.1", "type": "module", "module": "src/server.ts", "bin": { diff --git a/skills/seal-home/SKILL.md b/skills/seal-home/SKILL.md index d876165..6cc2dc7 100644 --- a/skills/seal-home/SKILL.md +++ b/skills/seal-home/SKILL.md @@ -1,12 +1,12 @@ --- name: seal-home -description: "v0.7.0: Use when working with Seal Home tenant operations: packaged customer feedback from WeChat or screenshots, target-enterprise discovery, approval-run and Langfuse diagnosis, simulation test batch creation and publishing, minimal approval-rule remediation and publishing, delegation links, Hose/合思 authorization, LLM config, permissions, billing, users, rules, documents, and search." +description: "v0.7.1: Use when working with Seal Home tenant operations: packaged customer feedback from WeChat or screenshots, target-enterprise discovery, approval-run and Langfuse diagnosis, simulation test batch creation and publishing, minimal approval-rule remediation and publishing, delegation links, Hose/合思 authorization, LLM config, permissions, billing, users, rules, documents, and search." metadata: - version: 0.7.0 - short-description: Seal tenant and Hose approval automation (v0.7.0) + version: 0.7.1 + short-description: Seal tenant and Hose approval automation (v0.7.1) --- -# Seal Home (v0.7.0) +# Seal Home (v0.7.1) Use the `seal_cli` MCP tool when it is available; pass the command string as its `command` argument. If MCP is unavailable, fall back to the global `seal-home` CLI. This skill is a routing layer for agents: keep this file short, choose the right command, and read a focused reference only when the task needs detail. diff --git a/src/cli.ts b/src/cli.ts index b5f56da..474e1a1 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -4,6 +4,13 @@ import { fileURLToPath } from "node:url"; import { runCli } from "./cli/runner.js"; import { isCompiledBinary, resolveAppRoot, resolveDefaultLauncher } from "./core/runtime.js"; +process.stdout.on("error", (err: any) => { + if (err?.code === "EPIPE") process.exit(0); +}); +process.stderr.on("error", (err: any) => { + if (err?.code === "EPIPE") process.exit(0); +}); + const entryFile = fileURLToPath(import.meta.url); const isCompiled = isCompiledBinary(); const appRoot = resolveAppRoot(entryFile, isCompiled); @@ -15,6 +22,16 @@ const result = await runCli(Bun.argv.slice(2), { launcher }); -if (result.stdout) process.stdout.write(result.stdout); -if (result.stderr) process.stderr.write(`${result.stderr}${result.stderr.endsWith("\n") ? "" : "\n"}`); +try { + if (result.stdout) process.stdout.write(result.stdout); +} catch (err: any) { + if (err?.code !== "EPIPE") throw err; +} + +try { + if (result.stderr) process.stderr.write(`${result.stderr}${result.stderr.endsWith("\n") ? "" : "\n"}`); +} catch (err: any) { + if (err?.code !== "EPIPE") throw err; +} + process.exitCode = result.exitCode; diff --git a/src/cli/commands/approval-runs.ts b/src/cli/commands/approval-runs.ts index 8cb5959..b23281d 100644 --- a/src/cli/commands/approval-runs.ts +++ b/src/cli/commands/approval-runs.ts @@ -1,8 +1,8 @@ import type { CorpConfig } from "../../core/config/types.js"; import type { createSealClient } from "../../core/http/factory.js"; -import { runTool } from "../helpers.js"; +import { runTool, runToolResult } from "../helpers.js"; import { booleanOption, numberOption, stringOption } from "../parser.js"; -import { outputOptions } from "../printer.js"; +import { outputOptions, printJson } from "../printer.js"; import type { ParsedArgs } from "../types.js"; export async function handleApprovalRunsCommand( @@ -13,7 +13,7 @@ export async function handleApprovalRunsCommand( args: ParsedArgs ) { if (action === "summary") { - await runTool( + const result = await runToolResult( "seal_approval_runs_summary", client, corp, @@ -30,13 +30,18 @@ export async function handleApprovalRunsCommand( sourceDocumentId: stringOption(args.options.sourceDocumentId), humanResult: stringOption(args.options.humanResult), query: stringOption(args.options.query) - }, - outputOptions(args.options) + } ); + if ((result as any)?.matched === 0 && (result as any)?.total > 0) { + console.error( + `提示:在 ${(result as any).date} 未匹配到记录(该企业共有 ${(result as any).total} 条历史记录)。可使用 --date YYYY-MM-DD 指定日期,或运行 seal-home approval-runs list --limit 10 查看最近记录。` + ); + } + printJson(result, outputOptions(args.options)); return; } - if (action === "search") { + if (action === "search" || action === "list") { await runTool( "seal_approval_runs_search", client,