Mirror real create-batch payload captured from staging console

The server derives approvalCode/nodeId/limit/startTime/endTime from the
request; the response params echo is normalized, not the request shape.
- send sourceSystem + thinkingDepthOverride "default" (按偏好设置)
- drop limit and server-derived fields from the request body
- keep material_pack payload free of hosecloud-specific fields

Verification: simulation create against xiezihao staging now succeeds
(200) and batch records appear with taskMode=simulation; 114 tests pass.
This commit is contained in:
gitea committed 2026-08-24 18:16:51 +08:00
1 parent 0e52a295ba
commit 997f1f60ac
7 files changed
+72 -66

No files matched your search

+19 -19
View File
@@ -25492,7 +25492,7 @@ var SimulationBatchParamsSchema = exports_external.object({
skipInvoiceGeneration: exports_external.boolean().optional(),
skipExpenseExtraction: exports_external.boolean().optional(),
disableAttachmentCache: exports_external.boolean().optional(),
thinkingDepthOverride: exports_external.enum(["medium", "high"]).optional(),
thinkingDepthOverride: exports_external.enum(["default", "medium", "high"]).optional(),
startTime: exports_external.number().optional(),
endTime: exports_external.number().optional(),
templateId: exports_external.string().optional(),
@@ -27217,9 +27217,8 @@ var sealTools = [
parameters: exports_external.object({
mode: exports_external.enum(["hosecloud", "material_pack"]).default("hosecloud").describe("来源模式: hosecloud=合思指定单号; material_pack=材料包导入"),
flowIds: exports_external.array(exports_external.string()).max(100).optional().describe("合思模式: 单据流水号列表"),
limit: exports_external.number().int().positive().max(100).optional().describe("指定单号数量, 默认取 flowIds 个数"),
rejectNodeName: exports_external.string().nullable().optional().describe("仅关注特定节点: 节点名称, 不传为 null 表示不限制"),
thinkingDepthOverride: exports_external.enum(["medium", "high"]).nullable().optional().describe("思考深度: medium=标准, high=深度推理, 不传=按偏好设置"),
rejectNodeName: exports_external.string().nullable().optional().describe("仅关注特定节点: 节点名称, 不设为 null 表示不限制"),
thinkingDepthOverride: exports_external.enum(["default", "medium", "high"]).optional().describe("思考深度: default=按偏好设置, medium=标准, high=深度推理"),
skipInvoiceGeneration: exports_external.boolean().optional().describe("跳过发票生成, 默认 true"),
skipExpenseExtraction: exports_external.boolean().optional().describe("跳过费用提取, 默认 true"),
disableAttachmentCache: exports_external.boolean().optional().describe("不使用附件缓存, 默认 false"),
@@ -27243,9 +27242,8 @@ var sealTools = [
const payload = buildSimulationBatchParams({
mode,
flowIds: params.flowIds,
limit: params.limit,
rejectNodeName: params.rejectNodeName,
thinkingDepthOverride: params.thinkingDepthOverride ?? undefined,
thinkingDepthOverride: params.thinkingDepthOverride,
skipInvoiceGeneration: params.skipInvoiceGeneration,
skipExpenseExtraction: params.skipExpenseExtraction,
disableAttachmentCache: params.disableAttachmentCache,
@@ -27567,32 +27565,37 @@ function pickRuleFields(rule, fields) {
}
function buildSimulationBatchParams(input) {
const params = {
approvalCode: input.mode,
nodeId: input.mode,
skipInvoiceGeneration: input.skipInvoiceGeneration ?? true,
skipExpenseExtraction: input.skipExpenseExtraction ?? true
skipExpenseExtraction: input.skipExpenseExtraction ?? true,
thinkingDepthOverride: input.thinkingDepthOverride ?? "default"
};
if (input.mode === "hosecloud") {
if (!input.flowIds?.length) {
throw new Error("hosecloud 模式需要提供 flowIds(单号列表)");
}
Object.assign(params, {
flowIds: input.flowIds,
limit: input.limit ?? input.flowIds.length,
dataCollectionMode: "2",
disableAttachmentCache: input.disableAttachmentCache ?? false
rejectNodeName: input.rejectNodeName ?? null,
skipInvoiceGeneration: input.skipInvoiceGeneration ?? true,
skipExpenseExtraction: input.skipExpenseExtraction ?? true,
disableAttachmentCache: input.disableAttachmentCache ?? false,
thinkingDepthOverride: input.thinkingDepthOverride ?? "default",
sourceSystem: "hosecloud",
flowIds: input.flowIds
});
if (input.signKey)
params.signKey = input.signKey;
if (input.rejectNodeName !== undefined)
params.rejectNodeName = input.rejectNodeName;
} else {
if (!input.packageIds?.length) {
throw new Error("material_pack 模式需要提供 packageIds(材料包 id)");
}
Object.assign(params, {
sourceSystem: "material_pack",
packageIds: input.packageIds,
runMode: "import_and_simulate"
runMode: "import_and_simulate",
skipInvoiceGeneration: input.skipInvoiceGeneration ?? true,
skipExpenseExtraction: input.skipExpenseExtraction ?? true,
thinkingDepthOverride: input.thinkingDepthOverride ?? "default"
});
if (input.templateId)
params.templateId = input.templateId;
@@ -27601,8 +27604,6 @@ function buildSimulationBatchParams(input) {
if (input.schemaConfig !== undefined)
params.schemaConfig = input.schemaConfig;
}
if (input.thinkingDepthOverride)
params.thinkingDepthOverride = input.thinkingDepthOverride;
if (input.rawParams)
Object.assign(params, input.rawParams);
return params;
@@ -29245,7 +29246,6 @@ async function dispatch(argv, runtime) {
await runTool("seal_simulation_batch_create", client, corp, {
mode,
flowIds: splitOption(args.options.flowIds) ?? splitOption(args.options["flow-ids"]),
limit: numberOption(args.options.limit),
rejectNodeName: stringOption(args.options.rejectNode) ?? stringOption(args.options["reject-node"]) ?? null,
thinkingDepthOverride: stringOption(args.options.thinkingDepth) ?? stringOption(args.options["thinking-depth"]),
skipInvoiceGeneration: booleanOption(args.options.skipInvoiceGeneration) ?? booleanOption(args.options["skip-invoice-generation"]),
@@ -30006,7 +30006,7 @@ Usage:
seal-home approval-runs url --sourceDocumentSN B26022501 [--corp <corpId>]
seal-home approval-runs bridge [--sourceDocumentSN B26001887] [--corp <corpId>]
seal-home simulation batch-records <batchId> [--corp <corpId>]
seal-home simulation create --mode hosecloud --flow-ids "B26017701,B26022501" [--limit 2] [--reject-node 财务] [--thinking-depth medium|high] [--skip-invoice-generation|--skip-invoice-generation false] [--corp <corpId>]
seal-home simulation create --mode hosecloud --flow-ids "B26017701,B26022501" [--reject-node 财务] [--thinking-depth default|medium|high] [--skip-invoice-generation|--skip-invoice-generation false] [--corp <corpId>]
seal-home simulation create --mode material_pack --package-ids <materialPackageId> [--package-label 名称] [--template-id conference_reimbursement_v1] [--schema-config file.json] [--corp <corpId>]
seal-home simulation list [--limit 50] [--corp <corpId>]
seal-home simulation get <batchId> [--corp <corpId>]
+1 -1
View File
@@ -62,7 +62,7 @@ seal-home rules clear --corp <corpId> --dry-run
seal-home rules clear --corp <corpId> --yes
seal-home rules get --corp <corpId> --version 16 --code '#0038'
seal-home rules get --corp <corpId> --record-id <recordId> --runtime-id rule-205
seal-home simulation create --corp <corpId> --mode hosecloud --flow-ids "B26017701,B26022501" [--limit 2] [--reject-node 财务] [--thinking-depth medium|high]
seal-home simulation create --corp <corpId> --mode hosecloud --flow-ids "B26017701,B26022501" [--reject-node 财务] [--thinking-depth default|medium|high]
seal-home simulation create --corp <corpId> --mode material_pack --package-ids <materialPackageId> [--schema-config file.json]
seal-home simulation package-upload <材料包.zip> --corp <corpId>
seal-home simulation list --corp <corpId>
+2 -2
View File
@@ -72,7 +72,7 @@ seal-home approval-runs url <recordId> --corp <corpId>
seal-home approval-runs url --sourceDocumentSN <sourceDocumentSN> --corp <corpId>
seal-home approval-runs bridge --corp <corpId> [--sourceDocumentSN <sourceDocumentSN>]
seal-home simulation batch-records <batchId> --corp <corpId>
seal-home simulation create --mode hosecloud --flow-ids "B26017701,B26022501" [--limit 2] [--reject-node 财务] [--thinking-depth medium|high] [--skip-invoice-generation|--skip-invoice-generation false] --corp <corpId>
seal-home simulation create --mode hosecloud --flow-ids "B26017701,B26022501" [--reject-node 财务] [--thinking-depth default|medium|high] [--skip-invoice-generation|--skip-invoice-generation false] --corp <corpId>
seal-home simulation create --mode material_pack --package-ids <materialPackageId> [--package-label 名称] [--template-id conference_reimbursement_v1] [--schema-config file.json] --corp <corpId>
seal-home simulation list [--limit 50] --corp <corpId>
seal-home simulation get <batchId> --corp <corpId>
@@ -247,7 +247,7 @@ seal-home approval-runs bridge --corp <corpId> --sourceDocumentSN <sourceDocumen
```bash
# 合思指定单号: 创建批次(响应只含 batchId)
seal-home simulation create --mode hosecloud --flow-ids "B26017701,B26022501" --limit 2 --reject-node 财务 --thinking-depth medium --skip-invoice-generation --corp <corpId>
seal-home simulation create --mode hosecloud --flow-ids "B26017701,B26022501" --reject-node 财务 --thinking-depth medium --skip-invoice-generation --corp <corpId>
# 材料包导入: 先上传材料包 ZIP(服务端解析并返回 schemaConfig), 再用返回的 id 发起
seal-home simulation package-upload 测试材料包.zip --corp <corpId>
seal-home simulation create --mode material_pack --package-ids <materialPackageId> --package-label 名称 --template-id conference_reimbursement_v1 --schema-config schema.json --corp <corpId>
+1 -2
View File
@@ -733,7 +733,6 @@ async function dispatch(argv: string[], runtime: CliRuntime) {
await runTool("seal_simulation_batch_create", client, corp, {
mode,
flowIds: splitOption(args.options.flowIds) ?? splitOption(args.options["flow-ids"]),
limit: numberOption(args.options.limit),
rejectNodeName: stringOption(args.options.rejectNode) ?? stringOption(args.options["reject-node"]) ?? null,
thinkingDepthOverride: stringOption(args.options.thinkingDepth) ?? stringOption(args.options["thinking-depth"]),
skipInvoiceGeneration: booleanOption(args.options.skipInvoiceGeneration) ?? booleanOption(args.options["skip-invoice-generation"]),
@@ -1621,7 +1620,7 @@ Usage:
seal-home approval-runs url --sourceDocumentSN B26022501 [--corp <corpId>]
seal-home approval-runs bridge [--sourceDocumentSN B26001887] [--corp <corpId>]
seal-home simulation batch-records <batchId> [--corp <corpId>]
seal-home simulation create --mode hosecloud --flow-ids "B26017701,B26022501" [--limit 2] [--reject-node 财务] [--thinking-depth medium|high] [--skip-invoice-generation|--skip-invoice-generation false] [--corp <corpId>]
seal-home simulation create --mode hosecloud --flow-ids "B26017701,B26022501" [--reject-node 财务] [--thinking-depth default|medium|high] [--skip-invoice-generation|--skip-invoice-generation false] [--corp <corpId>]
seal-home simulation create --mode material_pack --package-ids <materialPackageId> [--package-label 名称] [--template-id conference_reimbursement_v1] [--schema-config file.json] [--corp <corpId>]
seal-home simulation list [--limit 50] [--corp <corpId>]
seal-home simulation get <batchId> [--corp <corpId>]
+26 -23
View File
@@ -155,7 +155,7 @@ function fakeContext(): { corp: CorpConfig } {
}
describe("buildSimulationBatchParams", () => {
test("builds hosecloud request payload without mode-irrelevant fields", () => {
test("builds hosecloud request payload matching the captured create-batch body", () => {
const params = buildSimulationBatchParams({
mode: "hosecloud",
flowIds: ["B26017701"],
@@ -163,47 +163,49 @@ describe("buildSimulationBatchParams", () => {
skipExpenseExtraction: true,
disableAttachmentCache: false,
rejectNodeName: null,
thinkingDepthOverride: "medium",
thinkingDepthOverride: "default",
signKey: SIGN_KEY
});
expect(params).toEqual({
approvalCode: "hosecloud",
nodeId: "hosecloud",
dataCollectionMode: "2",
rejectNodeName: null,
skipInvoiceGeneration: true,
skipExpenseExtraction: true,
flowIds: ["B26017701"],
limit: 1,
dataCollectionMode: "2",
disableAttachmentCache: false,
rejectNodeName: null,
signKey: SIGN_KEY,
thinkingDepthOverride: "medium"
thinkingDepthOverride: "default",
sourceSystem: "hosecloud",
flowIds: ["B26017701"],
signKey: SIGN_KEY
});
// 时间范围字段只在对应取数模式下发送
// approvalCode/nodeId/limit/startTime/endTime 由服务端从请求推导,不进请求体
expect(params).not.toHaveProperty("approvalCode");
expect(params).not.toHaveProperty("nodeId");
expect(params).not.toHaveProperty("limit");
expect(params).not.toHaveProperty("startTime");
expect(params).not.toHaveProperty("endTime");
});
test("defaults limit to flowIds length and supports node override", () => {
test("supports node override and deep thinking depth", () => {
const params = buildSimulationBatchParams({
mode: "hosecloud",
flowIds: ["B26010080", "B25011446"],
skipExpenseExtraction: false,
disableAttachmentCache: true,
rejectNodeName: "财务",
thinkingDepthOverride: "high",
signKey: SIGN_KEY
});
expect(params).toMatchObject({
flowIds: ["B26010080", "B25011446"],
limit: 2,
skipInvoiceGeneration: true,
skipExpenseExtraction: false,
disableAttachmentCache: true,
rejectNodeName: "财务"
rejectNodeName: "财务",
thinkingDepthOverride: "high"
});
expect(params.thinkingDepthOverride).toBeUndefined();
expect(params).not.toHaveProperty("limit");
});
test("builds material_pack payload with the confirmed schema config", () => {
@@ -229,22 +231,23 @@ describe("buildSimulationBatchParams", () => {
});
expect(params).toMatchObject({
approvalCode: "material_pack",
nodeId: "material_pack",
sourceSystem: "material_pack",
packageIds: ["019fd15c-13a6-748f-8cdd-73e2da60252a"],
packageLabel: "Hilton测试材料包3-ready-v2-20260805-c6fcc0db",
templateId: "conference_reimbursement_v1",
runMode: "import_and_simulate",
thinkingDepthOverride: "default",
schemaConfig: {
id: "conference_reimbursement_v1",
mainKeyColumn: "会议编号",
attachmentFieldKey: "supporting_files"
}
});
// 合思专属字段不随材料包模式发送
// 合思专属字段不随材料包模式发送; approvalCode/nodeId 由服务端推导
expect(params).not.toHaveProperty("approvalCode");
expect(params).not.toHaveProperty("disableAttachmentCache");
expect(params).not.toHaveProperty("flowIds");
expect(params).not.toHaveProperty("startTime");
expect(params).not.toHaveProperty("dataCollectionMode");
});
test("rawParams can introduce reserved time-range fields", () => {
@@ -412,17 +415,17 @@ describe("simulation tool handlers", () => {
const result = await handler(client, {
mode: "hosecloud",
flowIds: ["B26017701"],
limit: 1,
thinkingDepthOverride: "medium"
thinkingDepthOverride: "default"
}, fakeContext());
expect(assertPosted).toBe(true);
expect(postedBody).toMatchObject({
flowIds: ["B26017701"],
limit: 1,
signKey: SIGN_KEY,
thinkingDepthOverride: "medium"
thinkingDepthOverride: "default",
sourceSystem: "hosecloud"
});
expect(postedBody).not.toHaveProperty("limit");
expect(result).toMatchObject({ batchId: "batch-1", created: true });
});
+22 -18
View File
@@ -1074,9 +1074,8 @@ export const sealTools = [
parameters: z.object({
mode: z.enum(["hosecloud", "material_pack"]).default("hosecloud").describe("来源模式: hosecloud=合思指定单号; material_pack=材料包导入"),
flowIds: z.array(z.string()).max(100).optional().describe("合思模式: 单据流水号列表"),
limit: z.number().int().positive().max(100).optional().describe("指定单号数量, 默认取 flowIds 个数"),
rejectNodeName: z.string().nullable().optional().describe("仅关注特定节点: 节点名称, 不传为 null 表示不限制"),
thinkingDepthOverride: z.enum(["medium", "high"]).nullable().optional().describe("思考深度: medium=标准, high=深度推理, 不传=按偏好设置"),
rejectNodeName: z.string().nullable().optional().describe("仅关注特定节点: 节点名称, 不设为 null 表示不限制"),
thinkingDepthOverride: z.enum(["default", "medium", "high"]).optional().describe("思考深度: default=按偏好设置, medium=标准, high=深度推理"),
skipInvoiceGeneration: z.boolean().optional().describe("跳过发票生成, 默认 true"),
skipExpenseExtraction: z.boolean().optional().describe("跳过费用提取, 默认 true"),
disableAttachmentCache: z.boolean().optional().describe("不使用附件缓存, 默认 false"),
@@ -1092,9 +1091,8 @@ export const sealTools = [
params: {
mode?: "hosecloud" | "material_pack";
flowIds?: string[];
limit?: number;
rejectNodeName?: string | null;
thinkingDepthOverride?: "medium" | "high" | null;
thinkingDepthOverride?: "default" | "medium" | "high";
skipInvoiceGeneration?: boolean;
skipExpenseExtraction?: boolean;
disableAttachmentCache?: boolean;
@@ -1119,9 +1117,8 @@ export const sealTools = [
const payload = buildSimulationBatchParams({
mode,
flowIds: params.flowIds,
limit: params.limit,
rejectNodeName: params.rejectNodeName,
thinkingDepthOverride: params.thinkingDepthOverride ?? undefined,
thinkingDepthOverride: params.thinkingDepthOverride,
skipInvoiceGeneration: params.skipInvoiceGeneration,
skipExpenseExtraction: params.skipExpenseExtraction,
disableAttachmentCache: params.disableAttachmentCache,
@@ -1548,9 +1545,8 @@ function pickRuleFields(rule: ApprovalRule, fields: readonly RuleField[]) {
export type SimulationBatchCreateInput = {
mode: "hosecloud" | "material_pack";
flowIds?: string[];
limit?: number;
rejectNodeName?: string | null;
thinkingDepthOverride?: "medium" | "high";
thinkingDepthOverride?: "default" | "medium" | "high";
skipInvoiceGeneration?: boolean;
skipExpenseExtraction?: boolean;
disableAttachmentCache?: boolean;
@@ -1564,38 +1560,46 @@ export type SimulationBatchCreateInput = {
};
export function buildSimulationBatchParams(input: SimulationBatchCreateInput): Record<string, unknown> {
// 请求体按前端真实载荷建模: approvalCode/nodeId/limit/startTime/endTime 由服务端
// 从 sourceSystem/flowIds 推导,回显 params 是归一化结果,不是请求体本身。
const params: Record<string, unknown> = {
approvalCode: input.mode,
nodeId: input.mode,
skipInvoiceGeneration: input.skipInvoiceGeneration ?? true,
skipExpenseExtraction: input.skipExpenseExtraction ?? true
skipExpenseExtraction: input.skipExpenseExtraction ?? true,
thinkingDepthOverride: input.thinkingDepthOverride ?? "default"
};
if (input.mode === "hosecloud") {
if (!input.flowIds?.length) {
throw new Error("hosecloud 模式需要提供 flowIds(单号列表)");
}
Object.assign(params, {
flowIds: input.flowIds,
limit: input.limit ?? input.flowIds.length,
dataCollectionMode: "2",
disableAttachmentCache: input.disableAttachmentCache ?? false
rejectNodeName: input.rejectNodeName ?? null,
skipInvoiceGeneration: input.skipInvoiceGeneration ?? true,
skipExpenseExtraction: input.skipExpenseExtraction ?? true,
disableAttachmentCache: input.disableAttachmentCache ?? false,
thinkingDepthOverride: input.thinkingDepthOverride ?? "default",
sourceSystem: "hosecloud",
flowIds: input.flowIds
});
if (input.signKey) params.signKey = input.signKey;
if (input.rejectNodeName !== undefined) params.rejectNodeName = input.rejectNodeName;
} else {
if (!input.packageIds?.length) {
throw new Error("material_pack 模式需要提供 packageIds(材料包 id)");
}
Object.assign(params, {
sourceSystem: "material_pack",
packageIds: input.packageIds,
runMode: "import_and_simulate"
runMode: "import_and_simulate",
skipInvoiceGeneration: input.skipInvoiceGeneration ?? true,
skipExpenseExtraction: input.skipExpenseExtraction ?? true,
thinkingDepthOverride: input.thinkingDepthOverride ?? "default"
});
if (input.templateId) params.templateId = input.templateId;
if (input.packageLabel) params.packageLabel = input.packageLabel;
if (input.schemaConfig !== undefined) params.schemaConfig = input.schemaConfig;
}
if (input.thinkingDepthOverride) params.thinkingDepthOverride = input.thinkingDepthOverride;
if (input.rawParams) Object.assign(params, input.rawParams);
return params;
}
+1 -1
View File
@@ -359,7 +359,7 @@ export const SimulationBatchParamsSchema = z.object({
skipInvoiceGeneration: z.boolean().optional(),
skipExpenseExtraction: z.boolean().optional(),
disableAttachmentCache: z.boolean().optional(),
thinkingDepthOverride: z.enum(["medium", "high"]).optional(),
thinkingDepthOverride: z.enum(["default", "medium", "high"]).optional(),
// 预留:合思时间范围等其他取数模式
startTime: z.number().optional(),
endTime: z.number().optional(),