diff --git a/skills/seal-use/SKILL.md b/skills/seal-use/SKILL.md index a94b206..58dda0c 100644 --- a/skills/seal-use/SKILL.md +++ b/skills/seal-use/SKILL.md @@ -55,7 +55,7 @@ seal-use corps list - First install / zero configuration / “how do I connect my enterprise?” / user supplies app credentials, an assistance link, or F12/Network cURL: read `references/enterprise-onboarding.md`. Ask what material the user already has in plain language, then discover all remaining identifiers automatically. - User-facing Seal tenant assistance link (Seal 协助/Seal 授权/委托): resolve the named enterprise first, then run `seal-use delegation create --corp --note ''`; verify the returned hostname is that tenant's Seal hostname. Always provide BOTH a code block (` ```text ... ``` `) AND a hyperlink. - Packaged customer feedback → approval-rule remediation: read `references/customer-feedback-rule-remediation.md`. Use this route for WeChat messages, screenshots, rejection notifications, document numbers, customer complaints, expected approval behavior, rule-only mitigation, exact diffs, or requests to update and publish a rule version. -- 模拟测试发布闭环: `seal-use simulation create --mode hosecloud --flow-ids ... --corp ` (合思指定单号) 或 `--mode material_pack --package-ids ... --schema-config file.json` (材料包导入), 支持多源系统 `--source-system `, `simulation wait ` 轮询等待完成, `simulation clean ` 清理数据, `simulation specifications` 列出单据模板, `simulation list`/`get`/`batch-records` 查看批次与记录。创建前确认目标环境为测试环境。 +- 模拟测试发布闭环: `seal-use simulation create --mode hosecloud --flow-ids ... --no-wait --corp ` (合思指定单号) 或 `--mode material_pack --package-ids ... --schema-config file.json` (材料包导入), 支持多源系统 `--source-system `, `simulation status ` 单次查询状态, `simulation wait ` 轮询等待完成, `simulation clean ` 清理数据, `simulation specifications` 列出单据模板, `simulation list`/`get`/`batch-records` 查看批次与记录。创建前确认目标环境为测试环境。 - Seal AI 智能审核发布到合思费控: `seal-use deploy hosecloud --corp `; read `references/hose-enterprise-deploy.md`. - 审核决策偏好与思考深度: `seal-use preference get --corp `, `preference decision update --json '...' --corp `, `preference thinking-depth set --default --corp `, `preference thinking-depth policies --corp `. - 审核大盘统计与去重分析: `seal-use approval-runs stats [--since 3months] [--dedupe-by sourceDocumentSN|id] --corp `, `seal-use approval-runs count --corp `. diff --git a/skills/seal-use/references/cli.md b/skills/seal-use/references/cli.md index 3649995..063d928 100644 --- a/skills/seal-use/references/cli.md +++ b/skills/seal-use/references/cli.md @@ -102,9 +102,10 @@ seal-use approval-runs url --corp seal-use approval-runs url --sourceDocumentSN --corp seal-use approval-runs bridge --corp [--sourceDocumentSN ] seal-use simulation batch-records --corp -seal-use simulation create --mode hosecloud --flow-ids "B26017701,B26022501" [--reject-node 财务] [--thinking-depth default|medium|high] [--skip-invoice-generation|--skip-invoice-generation false] --corp +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] --corp seal-use simulation create --mode material_pack --package-ids [--template-id conference_reimbursement_v1] [--schema-config file.json] --corp seal-use simulation create --source-system weaver --request-ids "req-01,req-02" --corp +seal-use simulation status --corp seal-use simulation wait [--timeout 10m] [--poll-interval 2s] --corp seal-use simulation clean --corp seal-use simulation specifications [--integration ] --corp @@ -181,7 +182,8 @@ Approval runs, simulations, and Langfuse bridge: - `seal-use approval-runs search --corp [--query ] [--limit 20]` - `seal-use approval-runs summary --corp [--date YYYY-MM-DD] [--timezone Asia/Shanghai]` - `seal-use approval-runs bridge --corp [--sourceDocumentSN ]` -- `seal-use simulation create --mode hosecloud --flow-ids ... --corp ` +- `seal-use simulation create --mode hosecloud --flow-ids ... --no-wait --corp ` returns immediately with an `asyncTicket` (creation is non-blocking by default for compatibility). +- `seal-use simulation status --corp ` performs one non-blocking status check and returns `QUEUED`/`RUNNING`/`COMPLETED`/`FAILED`-style state plus counters. - `seal-use simulation wait --corp ` - `seal-use simulation clean --corp ` - `seal-use simulation list --corp ` diff --git a/src/cli/commands/simulation.ts b/src/cli/commands/simulation.ts index c553d07..beb6bd0 100644 --- a/src/cli/commands/simulation.ts +++ b/src/cli/commands/simulation.ts @@ -62,6 +62,7 @@ export async function handleSimulationCommand( stringOption(args.options.signKey) ?? stringOption(args.options["sign-key"]) ?? stringOption(args.options.integration); + const noWait = booleanOption(args.options.noWait) ?? booleanOption(args.options["no-wait"]); await runTool( "seal_simulation_batch_create", @@ -91,6 +92,7 @@ export async function handleSimulationCommand( endTime: numberOption(args.options.endTime) ?? numberOption(args.options["end-time"]), status: splitOption(args.options.status), limit: numberOption(args.options.limit), + noWait, rawParams: inputPayload }, outputOptions(args.options) @@ -115,6 +117,19 @@ export async function handleSimulationCommand( return; } + 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 "); + await runTool( + "seal_simulation_batch_status", + client, + corp, + { batchId }, + outputOptions(args.options) + ); + return; + } + 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 "); diff --git a/src/cli/printer.ts b/src/cli/printer.ts index e63f59a..50f39a6 100644 --- a/src/cli/printer.ts +++ b/src/cli/printer.ts @@ -167,9 +167,10 @@ Usage: seal-use approval-runs url --sourceDocumentSN B26022501 [--corp ] seal-use approval-runs bridge [--sourceDocumentSN B26001887] [--corp ] seal-use simulation batch-records [--corp ] - seal-use simulation create --mode hosecloud --flow-ids "B26017701,B26022501" [--reject-node 财务] [--thinking-depth default|medium|high] [--skip-invoice-generation|--skip-invoice-generation false] [--corp ] + 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] [--corp ] seal-use simulation create --mode material_pack --package-ids [--template-id conference_reimbursement_v1] [--schema-config file.json] [--corp ] seal-use simulation create --source-system weaver --request-ids "req-01,req-02" [--corp ] + seal-use simulation status [--corp ] seal-use simulation wait [--timeout 10m] [--poll-interval 2s] [--corp ] seal-use simulation clean [--corp ] seal-use simulation specifications [--integration ] [--corp ] diff --git a/src/domains/seal/simulation.test.ts b/src/domains/seal/simulation.test.ts index 893d93f..c09b648 100644 --- a/src/domains/seal/simulation.test.ts +++ b/src/domains/seal/simulation.test.ts @@ -501,7 +501,12 @@ describe("simulation tool handlers", () => { sourceSystem: "hosecloud" }); expect(postedBody).not.toHaveProperty("limit"); - expect(result).toMatchObject({ batchId: "batch-1", created: true }); + expect(result).toMatchObject({ + batchId: "batch-1", + created: true, + noWait: true, + asyncTicket: "batch-1" + }); }); test("create tool surface exposes mode, flowIds, and rawParams", () => { @@ -509,18 +514,44 @@ describe("simulation tool handlers", () => { const { z } = require("zod") as typeof import("zod"); const schema = z.toJSONSchema(tool!.parameters) as { properties?: Record }; expect(Object.keys(schema.properties ?? {})).toEqual( - expect.arrayContaining(["mode", "flowIds", "rawParams", "schemaConfig", "packageIds"]) + expect.arrayContaining(["mode", "flowIds", "rawParams", "schemaConfig", "packageIds", "noWait"]) ); }); test("includes the simulation management tool set", () => { expect(sealTools.find((item) => item.name === "seal_simulation_batches_list")).toBeDefined(); expect(sealTools.find((item) => item.name === "seal_simulation_batch_get")).toBeDefined(); + expect(sealTools.find((item) => item.name === "seal_simulation_batch_status")).toBeDefined(); expect(sealTools.find((item) => item.name === "seal_simulation_templates_get")).toBeDefined(); expect(sealTools.find((item) => item.name === "seal_simulation_integrations_get")).toBeDefined(); expect(sealTools.find((item) => item.name === "seal_simulation_batch_records_get")).toBeDefined(); expect(sealTools.find((item) => item.name === "seal_simulation_material_package_upload")).toBeDefined(); }); + + test("status tool performs one non-blocking check and exposes the next action", async () => { + const tool = sealTools.find((item) => item.name === "seal_simulation_batch_status"); + expect(tool).toBeDefined(); + + const client = { + get: (url: string) => { + expect(url).toBe("api/v1/simulation/batch/batch-1"); + return { json: async () => ({ data: { ...hosecloudBatchFixture, id: "batch-1" } }) }; + } + } as unknown as KyInstance; + + const handler = tool!.handler as ToolHandler; + const result = await handler(client, { batchId: "batch-1" }, fakeContext()) as Record; + + expect(result).toMatchObject({ + batchId: "batch-1", + status: "SYNCING", + terminal: false, + next: { + status: "seal-use simulation status batch-1", + wait: "seal-use simulation wait batch-1" + } + }); + }); }); describe("simulation response schemas", () => { diff --git a/src/domains/seal/tools.ts b/src/domains/seal/tools.ts index ee66fd1..9be1539 100644 --- a/src/domains/seal/tools.ts +++ b/src/domains/seal/tools.ts @@ -1423,6 +1423,7 @@ export const sealTools = [ packageIds: z.array(z.string()).optional().describe("材料包模式: 材料包 id 列表(来自 material-packages upload 响应)"), templateId: z.string().optional().describe("材料包模板 id, 例如 conference_reimbursement_v1; 缺省取 schemaConfig.id"), schemaConfig: z.record(z.string(), z.unknown()).optional().describe("材料包字段映射(确认参数), 建议使用 material-packages upload 返回的 schemaConfig"), + noWait: z.boolean().optional().describe("创建后立即返回异步票据,不等待批次完成"), rawParams: z.record(z.string(), z.unknown()).optional().describe("预留: 其他取数模式(如时间范围 startTime/endTime)透传参数, 覆盖上述构建结果") }), handler: async ( @@ -1439,6 +1440,7 @@ export const sealTools = [ packageIds?: string[]; templateId?: string; schemaConfig?: Record; + noWait?: boolean; rawParams?: Record; } ) => { @@ -1474,7 +1476,11 @@ export const sealTools = [ return { ...result, created: true, + noWait: params.noWait ?? true, + asyncTicket: result.batchId, next: { + status: `seal-use simulation status ${result.batchId}`, + wait: `seal-use simulation wait ${result.batchId}`, getBatch: "seal-home simulation get ", getRecords: "seal-home simulation batch-records ", listBatches: "seal-home simulation list" @@ -1516,6 +1522,32 @@ export const sealTools = [ }; } }, + { + name: "seal_simulation_batch_status", + description: "单次读取 Seal 模拟批次状态,不阻塞等待;适合根据异步票据轮询", + parameters: z.object({ + batchId: z.string().describe("simulation batch ID") + }), + handler: async (client: KyInstance, params: { batchId: string }) => { + const batch = await api.getSimulationBatch(client, params.batchId); + const status = String(batch.status ?? "UNKNOWN").toUpperCase(); + const terminal = ["COMPLETED", "FAILED", "CANCELLED", "CANCELED"].includes(status); + return { + batchId: params.batchId, + status, + terminal, + totalCount: batch.totalCount, + processedCount: batch.processedCount, + successCount: batch.successCount, + failedCount: batch.failedCount, + createdAt: batch.createdAt, + updatedAt: batch.updatedAt, + next: terminal + ? { getRecords: `seal-use simulation batch-records ${params.batchId}` } + : { status: `seal-use simulation status ${params.batchId}`, wait: `seal-use simulation wait ${params.batchId}` } + }; + } + }, { name: "seal_simulation_templates_get", description: "列出 Seal 模拟测试模板(我的模板,保存常用配置快速复用)",