@gaoding/cli 1.7.1 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/contracts/operations/agent.send/input.schema.json +1 -1
  2. package/contracts/operations/model.get/input.schema.json +6 -0
  3. package/contracts/operations/model.get/output.schema.json +10 -1
  4. package/contracts/operations/tool.call/canvas-input.schema.json +60 -0
  5. package/contracts/operations/tool.call/models/image-edit-smart.schema.json +42 -0
  6. package/contracts/operations/tool.call/models/image-edit-standard.schema.json +33 -0
  7. package/contracts/operations/tool.call/models/image-enhance-smart.schema.json +27 -0
  8. package/contracts/operations/tool.call/models/image-enhance-standard.schema.json +27 -0
  9. package/contracts/operations/tool.call/models/image-expand-smart.schema.json +76 -0
  10. package/contracts/operations/tool.call/models/image-expand-standard.schema.json +61 -0
  11. package/contracts/operations/tool.call/models/image-layers-layout.schema.json +21 -0
  12. package/contracts/operations/tool.call/models/image-layers-smart.schema.json +28 -0
  13. package/contracts/operations/tool.call/models/image-matting-smart.schema.json +37 -0
  14. package/contracts/operations/tool.call/models/image-matting-standard.schema.json +26 -0
  15. package/contracts/operations/tool.call/models/image-ocr.schema.json +21 -0
  16. package/contracts/operations/tool.call/models/image-remove-smart.schema.json +32 -0
  17. package/contracts/operations/tool.call/models/image-remove-standard.schema.json +27 -0
  18. package/contracts/operations/tool.call/models/image-text-edit.schema.json +46 -0
  19. package/contracts/operations/tool.call/models/image-vectorize.schema.json +21 -0
  20. package/contracts/operations/tool.call/models/video-edit-smart.schema.json +76 -0
  21. package/contracts/operations/tool.call/models/video-enhance-smart.schema.json +33 -0
  22. package/contracts/operations/tool.call/models/video-enhance-standard.schema.json +27 -0
  23. package/contracts/operations/tool.call/ocr-payload.schema.json +66 -0
  24. package/contracts/operations/tool.call/output.schema.json +38 -0
  25. package/contracts/operations/tool.call/template-payload.schema.json +96 -0
  26. package/dist/src/bootstrap/create-runtime.js +61 -25
  27. package/dist/src/bootstrap/validators.js +1 -1
  28. package/dist/src/cli/action-binding.js +3 -0
  29. package/dist/src/cli/agent-commands.js +1 -0
  30. package/dist/src/cli/errors.js +43 -10
  31. package/dist/src/cli/model-commands.js +7 -4
  32. package/dist/src/cli/observed-errors.js +13 -5
  33. package/dist/src/cli/task-commands.js +1 -1
  34. package/dist/src/cli/tool-commands.js +3 -1
  35. package/dist/src/contracts/schema.js +4 -1
  36. package/dist/src/features/agent/creative-protocol.js +22 -5
  37. package/dist/src/features/agent/resource-authorizer.js +1 -0
  38. package/dist/src/features/agent/use-cases.js +15 -5
  39. package/dist/src/features/auth/sso-service.js +13 -4
  40. package/dist/src/features/dam/dam-api-adapter.js +1 -0
  41. package/dist/src/features/dam/file-downloader.js +23 -2
  42. package/dist/src/features/task/store.js +8 -4
  43. package/dist/src/features/task/use-cases.js +14 -11
  44. package/dist/src/features/tool/canvas-copy.js +61 -0
  45. package/dist/src/features/tool/canvas-media.js +193 -0
  46. package/dist/src/features/tool/canvas-models.js +109 -0
  47. package/dist/src/features/tool/canvas-pricing.js +81 -0
  48. package/dist/src/features/tool/canvas-recovery.js +68 -0
  49. package/dist/src/features/tool/canvas-results.js +144 -0
  50. package/dist/src/features/tool/canvas-tool-adapter.js +366 -0
  51. package/dist/src/features/tool/canvas-video.js +84 -0
  52. package/dist/src/features/tool/catalog.js +35 -13
  53. package/dist/src/features/tool/dynamic-schema.js +52 -23
  54. package/dist/src/features/tool/matting-billing.js +103 -0
  55. package/dist/src/features/tool/mns-catalog-adapter.js +66 -19
  56. package/dist/src/features/tool/resource-authorizer.js +34 -0
  57. package/dist/src/features/tool/scene-catalog-adapter.js +35 -0
  58. package/dist/src/features/tool/tool-api-adapter.js +24 -5
  59. package/dist/src/features/tool/use-cases.js +28 -3
  60. package/dist/src/features/update/update-service.js +4 -2
  61. package/dist/src/platform/file-lock.js +12 -0
  62. package/dist/src/platform/local-json-file.js +19 -5
  63. package/dist/src/platform/safe-upload-file.js +18 -10
  64. package/dist/src/platform/schema-issues.js +47 -2
  65. package/dist/src/platform/text-output.js +17 -4
  66. package/dist/src/product/config.js +12 -1
  67. package/dist/src/telemetry/failure-summary.js +18 -0
  68. package/package.json +5 -4
  69. package/skills/gd-cli/SKILL.md +2 -0
  70. package/skills/gd-cli/references/creation.md +2 -0
  71. package/skills/gd-cli/references/generation-constraints.md +3 -1
  72. package/skills/gd-cli/references/matting.md +29 -0
  73. package/skills/gd-cli/references/media-tools.md +40 -0
  74. package/skills/gd-cli/references/tool.md +5 -5
@@ -0,0 +1,76 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "VideoEditSmartInput",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": [
7
+ "model",
8
+ "video",
9
+ "prompt",
10
+ "resolution",
11
+ "audioEnabled"
12
+ ],
13
+ "properties": {
14
+ "model": {
15
+ "type": "string",
16
+ "const": "video-edit-smart"
17
+ },
18
+ "video": {
19
+ "type": "string",
20
+ "format": "uri",
21
+ "description": "待编辑原视频,对应提示词中的视频1。支持 HTTP(S) 或 CLI file:// 素材 URI。"
22
+ },
23
+ "prompt": {
24
+ "type": "string",
25
+ "minLength": 1,
26
+ "pattern": ".*\\S.*",
27
+ "description": "用户 prompt 原文逐字保留,CLI 仅在前面补充素材对应关系。原片为视频1,referenceVideos 从视频2起,referenceImages 从图1起,referenceAudios 从音频1起;各类按数组顺序编号。映射包含原文件名,上传后仍可识别素材角色。"
28
+ },
29
+ "resolution": {
30
+ "type": "string",
31
+ "minLength": 1,
32
+ "pattern": ".*\\S.*"
33
+ },
34
+ "audioEnabled": {
35
+ "type": "string",
36
+ "minLength": 1,
37
+ "pattern": ".*\\S.*"
38
+ },
39
+ "referenceImages": {
40
+ "type": "array",
41
+ "items": {
42
+ "type": "string",
43
+ "format": "uri",
44
+ "description": "单个 HTTP(S) 或 CLI file:// 素材 URI。"
45
+ },
46
+ "minItems": 1,
47
+ "uniqueItems": true,
48
+ "maxItems": 10,
49
+ "description": "额外参考图片,按顺序对应图1、图2等。"
50
+ },
51
+ "referenceVideos": {
52
+ "type": "array",
53
+ "items": {
54
+ "type": "string",
55
+ "format": "uri",
56
+ "description": "单个 HTTP(S) 或 CLI file:// 素材 URI。"
57
+ },
58
+ "minItems": 1,
59
+ "uniqueItems": true,
60
+ "maxItems": 4,
61
+ "description": "额外参考视频,按顺序对应视频2、视频3等;视频1固定为原片。原片与全部参考视频的合计时长不超过15秒。"
62
+ },
63
+ "referenceAudios": {
64
+ "type": "array",
65
+ "items": {
66
+ "type": "string",
67
+ "format": "uri",
68
+ "description": "单个 HTTP(S) 或 CLI file:// 素材 URI。"
69
+ },
70
+ "minItems": 1,
71
+ "uniqueItems": true,
72
+ "maxItems": 5,
73
+ "description": "额外参考音频,按顺序对应音频1、音频2等。"
74
+ }
75
+ }
76
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "VideoEnhanceSmartInput",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": [
7
+ "model",
8
+ "video",
9
+ "prompt",
10
+ "resolution"
11
+ ],
12
+ "properties": {
13
+ "model": {
14
+ "type": "string",
15
+ "const": "video-enhance-smart"
16
+ },
17
+ "video": {
18
+ "type": "string",
19
+ "format": "uri",
20
+ "description": "单个 HTTP(S) 或 CLI file:// 素材 URI。"
21
+ },
22
+ "prompt": {
23
+ "type": "string",
24
+ "minLength": 1,
25
+ "pattern": ".*\\S.*"
26
+ },
27
+ "resolution": {
28
+ "type": "string",
29
+ "minLength": 1,
30
+ "pattern": ".*\\S.*"
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "VideoEnhanceStandardInput",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": [
7
+ "model",
8
+ "video",
9
+ "resolution"
10
+ ],
11
+ "properties": {
12
+ "model": {
13
+ "type": "string",
14
+ "const": "video-enhance-standard"
15
+ },
16
+ "video": {
17
+ "type": "string",
18
+ "format": "uri",
19
+ "description": "单个 HTTP(S) 或 CLI file:// 素材 URI。"
20
+ },
21
+ "resolution": {
22
+ "type": "string",
23
+ "minLength": 1,
24
+ "pattern": ".*\\S.*"
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,66 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "OcrPayload",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": [
7
+ "image",
8
+ "blocks"
9
+ ],
10
+ "properties": {
11
+ "image": {
12
+ "type": "object",
13
+ "additionalProperties": false,
14
+ "required": [
15
+ "uri",
16
+ "width",
17
+ "height"
18
+ ],
19
+ "properties": {
20
+ "uri": {
21
+ "type": "string",
22
+ "format": "uri",
23
+ "description": "单个 HTTP(S) 或 CLI file:// 素材 URI。"
24
+ },
25
+ "width": {
26
+ "type": "integer",
27
+ "minimum": 1
28
+ },
29
+ "height": {
30
+ "type": "integer",
31
+ "minimum": 1
32
+ }
33
+ }
34
+ },
35
+ "blocks": {
36
+ "type": "array",
37
+ "items": {
38
+ "type": "object",
39
+ "additionalProperties": false,
40
+ "required": [
41
+ "bbox",
42
+ "category"
43
+ ],
44
+ "properties": {
45
+ "bbox": {
46
+ "type": "array",
47
+ "minItems": 4,
48
+ "maxItems": 4,
49
+ "items": {
50
+ "type": "number",
51
+ "minimum": 0
52
+ }
53
+ },
54
+ "category": {
55
+ "type": "string",
56
+ "minLength": 1,
57
+ "pattern": ".*\\S.*"
58
+ },
59
+ "text": {
60
+ "type": "string"
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
@@ -19,6 +19,9 @@
19
19
  },
20
20
  {
21
21
  "$ref": "#/$defs/ResourceLink"
22
+ },
23
+ {
24
+ "$ref": "#/$defs/EmbeddedJsonResource"
22
25
  }
23
26
  ]
24
27
  }
@@ -124,6 +127,41 @@
124
127
  "description": "资源的 MIME type。"
125
128
  }
126
129
  }
130
+ },
131
+ "EmbeddedJsonResource": {
132
+ "type": "object",
133
+ "additionalProperties": false,
134
+ "required": [
135
+ "type",
136
+ "resource"
137
+ ],
138
+ "properties": {
139
+ "type": {
140
+ "const": "resource"
141
+ },
142
+ "resource": {
143
+ "type": "object",
144
+ "additionalProperties": false,
145
+ "required": [
146
+ "uri",
147
+ "mimeType",
148
+ "text"
149
+ ],
150
+ "properties": {
151
+ "uri": {
152
+ "type": "string",
153
+ "format": "uri"
154
+ },
155
+ "mimeType": {
156
+ "const": "application/json"
157
+ },
158
+ "text": {
159
+ "type": "string",
160
+ "minLength": 1
161
+ }
162
+ }
163
+ }
164
+ }
127
165
  }
128
166
  }
129
167
  }
@@ -0,0 +1,96 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "NativeLayerTemplate",
4
+ "description": "分层服务返回的原生模板最低结构;保留扩展字段,不转换为扁平格式。",
5
+ "type": "object",
6
+ "required": [
7
+ "pages"
8
+ ],
9
+ "properties": {
10
+ "pages": {
11
+ "type": "array",
12
+ "minItems": 1,
13
+ "items": {
14
+ "type": "object",
15
+ "required": [
16
+ "elements"
17
+ ],
18
+ "properties": {
19
+ "elements": {
20
+ "type": "array",
21
+ "minItems": 1,
22
+ "items": {
23
+ "$ref": "#/$defs/layout"
24
+ }
25
+ }
26
+ }
27
+ }
28
+ }
29
+ },
30
+ "$defs": {
31
+ "element": {
32
+ "type": "object",
33
+ "required": [
34
+ "type"
35
+ ],
36
+ "properties": {
37
+ "type": {
38
+ "type": "string",
39
+ "minLength": 1
40
+ },
41
+ "elements": {
42
+ "type": "array",
43
+ "items": {
44
+ "$ref": "#/$defs/element"
45
+ }
46
+ },
47
+ "url": {
48
+ "type": "string"
49
+ }
50
+ }
51
+ },
52
+ "layout": {
53
+ "allOf": [
54
+ {
55
+ "$ref": "#/$defs/element"
56
+ },
57
+ {
58
+ "type": "object",
59
+ "required": [
60
+ "width",
61
+ "height",
62
+ "background",
63
+ "elements"
64
+ ],
65
+ "properties": {
66
+ "width": {
67
+ "type": "number",
68
+ "exclusiveMinimum": 0
69
+ },
70
+ "height": {
71
+ "type": "number",
72
+ "exclusiveMinimum": 0
73
+ },
74
+ "background": {
75
+ "type": "object",
76
+ "required": [
77
+ "image"
78
+ ],
79
+ "properties": {
80
+ "image": {
81
+ "type": "object"
82
+ }
83
+ }
84
+ },
85
+ "elements": {
86
+ "type": "array",
87
+ "items": {
88
+ "$ref": "#/$defs/element"
89
+ }
90
+ }
91
+ }
92
+ }
93
+ ]
94
+ }
95
+ }
96
+ }
@@ -7,7 +7,7 @@ import { createTaskBackgroundLauncher } from "../features/task/task-background.j
7
7
  import { createTaskStore } from "../features/task/store.js";
8
8
  import { createTaskUseCases } from "../features/task/use-cases.js";
9
9
  import { readAgentResult } from "../features/agent/result-reader.js";
10
- import { queryToolResult, ToolTaskFailedError } from "../features/tool/tool-api-adapter.js";
10
+ import { queryToolResult, ToolTaskFailedError, ToolTaskCanceledError } from "../features/tool/tool-api-adapter.js";
11
11
  import { randomBytes, randomUUID } from "node:crypto";
12
12
  import { dirname, join } from "node:path";
13
13
  import { setTimeout as delay } from "node:timers/promises";
@@ -32,8 +32,14 @@ import { createEditorSessionStateStore } from "../features/editor/session-state.
32
32
  import { createEditorUseCases } from "../features/editor/use-cases.js";
33
33
  import { createObjectStorageUploader } from "../features/dam/object-storage.js";
34
34
  import { createAgentUseCases } from "../features/agent/use-cases.js";
35
+ import { createSceneCatalogAdapter } from "../features/tool/scene-catalog-adapter.js";
35
36
  import { createMnsCatalogAdapter } from "../features/tool/mns-catalog-adapter.js";
36
37
  import { createToolApiAdapter } from "../features/tool/tool-api-adapter.js";
38
+ import { createCanvasToolAdapter } from "../features/tool/canvas-tool-adapter.js";
39
+ import { recoverCanvasTool } from "../features/tool/canvas-recovery.js";
40
+ import { authorizeToolResources } from "../features/tool/resource-authorizer.js";
41
+ import { createCanvasMedia } from "../features/tool/canvas-media.js";
42
+ import { createStandardMatting } from "../features/tool/matting-billing.js";
37
43
  import { createToolUseCases } from "../features/tool/use-cases.js";
38
44
  import { createOrgUseCases } from "../features/org/use-cases.js";
39
45
  import { createOrgService } from "../features/org/org-service.js";
@@ -100,6 +106,12 @@ export function createProductionRuntime(options = {}) {
100
106
  classifyError: error => classifyTelemetryError(error, { product, operation: telemetry.creationContext().operation, failureStage: telemetry.failureStage(error) }),
101
107
  ...(telemetrySink.enqueue ? { onEvent: (event) => telemetrySink.enqueue([event]) } : {})
102
108
  });
109
+ telemetry.annotate({ installation_owner: installationOwner,
110
+ ...(["workbuddy", "qwenwork"].includes(env.CLI_HOST_APPLICATION ?? "")
111
+ ? { host_application: env.CLI_HOST_APPLICATION } : {}),
112
+ ...(["auth_status", "version_check"].includes(env.CLI_INVOCATION_PURPOSE ?? "")
113
+ ? { invocation_purpose: env.CLI_INVOCATION_PURPOSE } : {}),
114
+ ...(/^[a-f0-9]{32}$/u.test(env.CLI_HOST_INVOCATION_ID ?? "") ? { host_invocation_id: env.CLI_HOST_INVOCATION_ID } : {}) });
103
115
  // Explicit test transport enables SDK tests; test-mode child processes never emit real analytics.
104
116
  const analytics = options.analytics ?? (telemetryEnvironment === "production" || options.windFetch
105
117
  ? createWindAnalytics({ product: product.id, version: options.telemetryVersion ?? primarySkill.version,
@@ -116,7 +128,7 @@ export function createProductionRuntime(options = {}) {
116
128
  stderrTerminal: process.stderr.isTTY === true
117
129
  };
118
130
  const stdout = createTextOutput(rawIo.stdout);
119
- const stderr = createTextOutput(rawIo.stderr);
131
+ const stderr = createTextOutput(rawIo.stderr, "stderr");
120
132
  const io = {
121
133
  writeOut: stdout.write,
122
134
  writeError: stderr.write,
@@ -221,12 +233,13 @@ export function createProductionRuntime(options = {}) {
221
233
  const validators = createContractValidators({
222
234
  organizations: product.exposesOrganizations
223
235
  });
224
- const modelCatalog = createMnsCatalogAdapter({
225
- transport: mnsTransport,
226
- ...(product.id === "insmind"
227
- ? { invalidModelWarning: (count) => `Ignored ${count} invalid model configuration${count === 1 ? "" : "s"}.` }
228
- : {})
229
- });
236
+ const modelCatalog = createSceneCatalogAdapter({ transport: toolTransport, english: product.id === "insmind", catalog: createMnsCatalogAdapter({
237
+ english: product.id === "insmind",
238
+ transport: mnsTransport,
239
+ ...(product.id === "insmind"
240
+ ? { invalidModelWarning: (count) => `Ignored ${count} invalid model configuration${count === 1 ? "" : "s"}.` }
241
+ : {})
242
+ }) });
230
243
  const damApi = createDamApiAdapter({ transport: damTransport });
231
244
  const damRepositories = createDamRepositoryCatalog({ transport: damTransport });
232
245
  const damOperations = createDamOperationExecutor({
@@ -248,7 +261,10 @@ export function createProductionRuntime(options = {}) {
248
261
  now,
249
262
  telemetry
250
263
  }),
251
- downloader: createDamFileDownloader({ fetch }),
264
+ downloader: createDamFileDownloader({ fetch, warn: code => {
265
+ telemetry.annotate({ warning_codes: [code] });
266
+ presenter.warning(text("临时文件未能清理;已下载的文件可以继续使用。", "Temporary files could not be cleaned up; completed downloads remain available."));
267
+ } }),
252
268
  operations: damOperations,
253
269
  sleep: async (milliseconds, signal) => {
254
270
  await delay(milliseconds, undefined, { signal });
@@ -291,6 +307,10 @@ export function createProductionRuntime(options = {}) {
291
307
  });
292
308
  };
293
309
  const authorizeTaskResult = async (result, state, signal, alreadyAuthorized = false) => {
310
+ if ("message" in result)
311
+ validators.agentSendOutput(result);
312
+ else
313
+ validators.toolCallOutput(result);
294
314
  // Bind only if this result actually needs a fresh resource token.
295
315
  const taskAuthorizer = createAgentResourceAuthorizer({ authKeys: {
296
316
  async getAuthKey(access, tokenSignal) {
@@ -302,21 +322,7 @@ export function createProductionRuntime(options = {}) {
302
322
  const access = { credential: state.credential, organizationId: state.organization.id };
303
323
  if ("message" in result)
304
324
  return taskAuthorizer.authorize(result, access, signal);
305
- const links = result.content.filter(part => part.type === "resource_link");
306
- if (links.length === 0)
307
- return result;
308
- const parts = links.map(part => ({ url: part.uri, mediaType: part.mimeType ?? "application/octet-stream" }));
309
- const authorized = await taskAuthorizer.authorize({
310
- message: { contextId: "resource-authorization", parts: [parts[0], ...parts.slice(1)] },
311
- usage: { cost: { unit: "gaodou", amount: 0 }, items: [] }
312
- }, access, signal);
313
- let index = 0;
314
- return { ...result, content: result.content.map(part => {
315
- if (part.type !== "resource_link")
316
- return part;
317
- const authorizedPart = authorized.message.parts[index++];
318
- return authorizedPart && "url" in authorizedPart ? { ...part, uri: authorizedPart.url } : part;
319
- }) };
325
+ return authorizeToolResources(result, taskAuthorizer, access, signal);
320
326
  };
321
327
  const tasks = createTaskUseCases({
322
328
  telemetry,
@@ -363,6 +369,33 @@ export function createProductionRuntime(options = {}) {
363
369
  };
364
370
  },
365
371
  async tool(progress, state, signal) {
372
+ if (progress.toolPipeline) {
373
+ const pipeline = progress.toolPipeline;
374
+ await authorizeTaskAccess(state, signal);
375
+ let recovered;
376
+ try {
377
+ recovered = await telemetry.stage("task.query", () => recoverCanvasTool(progress, {
378
+ access: { credential: state.credential, organizationId: state.organization.id }, signal
379
+ }, { transport: toolTransport, media: canvasMedia, english: product.id === "insmind" }));
380
+ }
381
+ catch (error) {
382
+ if (!(error instanceof ToolTaskFailedError) && !(error instanceof ToolTaskCanceledError))
383
+ throw error;
384
+ const outcome = mapCliError(error, { aborted: false, product, operation: "task.get", failureStage: "task.query" });
385
+ return { state: "failed", note: outcome.failure?.message ?? text("本次处理未能完成。", "This processing could not be completed."), failure: error };
386
+ }
387
+ if (recovered.state === "complete" && progress.toolUsage)
388
+ return { state: "completed", result: await authorizeTaskResult(toolOutputWithBillingUnit({
389
+ content: recovered.content, usage: progress.toolUsage
390
+ }, product.billingUnit), state, signal, true) };
391
+ if (recovered.state === "pending")
392
+ return { state: "running", note: text("任务仍在处理中。", "The task is still processing.") };
393
+ const partialContent = recovered.state === "unknown" ? recovered.content : undefined;
394
+ return { state: "unknown", note: text(`处理停留在 ${pipeline.stage} 阶段,尚未交付完整结果。查询不会重新处理、上传或结算;请保留任务 ID 排查,勿重复提交。`, `Processing reached ${pipeline.stage}; no complete result was delivered. Querying does not process, upload, or settle again. Keep the task ID for diagnosis; do not resubmit.`),
395
+ ...(partialContent && progress.toolUsage ? { partialResult: await authorizeTaskResult(toolOutputWithBillingUnit({
396
+ content: partialContent, usage: progress.toolUsage
397
+ }, product.billingUnit), state, signal, true) } : {}) };
398
+ }
366
399
  if (!progress.remoteTaskId || !progress.toolUsage)
367
400
  return {
368
401
  state: "unknown", note: text("尚未取得任务结果。", "The task result has not been received.")
@@ -409,11 +442,14 @@ export function createProductionRuntime(options = {}) {
409
442
  warn: (message) => { presenter.warning(message); },
410
443
  telemetry
411
444
  }), product.billingUnit);
445
+ const canvasMedia = createCanvasMedia({ fetch, uploader: transientUploader });
412
446
  const tool = withToolBillingUnit(createToolUseCases({
413
447
  catalog: modelCatalog,
414
448
  tools: product.tools,
415
449
  ...(product.id === "insmind" ? { modelDescription: "Model machine identifier from model list." } : {}),
416
- execution: createToolApiAdapter({ transport: toolTransport, telemetry }),
450
+ execution: createCanvasToolAdapter({ transport: toolTransport, recordTransport: damTransport, telemetry, media: canvasMedia, english: product.id === "insmind",
451
+ fallback: createToolApiAdapter({ transport: toolTransport, telemetry }),
452
+ standardMatting: createStandardMatting({ transport: toolTransport, recordTransport: damTransport, media: canvasMedia }) }),
417
453
  uploader: transientUploader,
418
454
  warn: (message) => { presenter.warning(message); },
419
455
  telemetry
@@ -169,6 +169,6 @@ const unavailableValidator = Object.assign(() => false, { errors: null, schema:
169
169
  function assertion(validate, ErrorType) {
170
170
  return (value) => {
171
171
  if (!validate(value))
172
- throw new ErrorType(validationIssues(validate.errors));
172
+ throw new ErrorType(validationIssues(validate.errors, value, validate.schema));
173
173
  };
174
174
  }
@@ -6,6 +6,9 @@ const selectedCommands = new WeakMap();
6
6
  /** Declare the existing fixed JSON contract alongside the command registration. */
7
7
  export function jsonOutput(command) {
8
8
  jsonCommands.add(command);
9
+ if (!command.options.some(option => option.long === "--json")) {
10
+ command.option("--json", "JSON output (default)");
11
+ }
9
12
  }
10
13
  export function errorUsesJson(program, argv) {
11
14
  if (program.opts().jsonErrors === true)
@@ -26,6 +26,7 @@ export function registerAgentCommands(program, runtime) {
26
26
  text(runtime.product, "默认模式在 stderr 提示任务 ID,stdout 保持原结果 JSON。", "In default mode the Task ID is written to stderr; stdout contains only the original result JSON."),
27
27
  text(runtime.product, `结果未收到时执行 ${runtime.product.commandName} task list 找到原调用,再执行 ${runtime.product.commandName} task get <id> 查询。`, `If output is missing, find the original run with ${runtime.product.commandName} task list, then query ${runtime.product.commandName} task get <id>.`),
28
28
  text(runtime.product, "首次创作省略 JSON 中的 message.contextId;续聊时传入上次结果的 message.contextId。", "Omit message.contextId for the first creation. Continue a conversation using message.contextId from the previous result."),
29
+ text(runtime.product, "Generation Constraints 可选 model 来自 model list;先用 model get 查看控制参数。编辑模型只接受 quality、resolution、audioEnabled、targetLongEdge、maxLayers 中模型实际公开的控制项;prompt、素材与选区要求使用独立 Part,精确几何字段使用 tool call。", "Optional Generation Constraints model comes from model list; inspect controls with model get. Editing models accept only their published quality, resolution, audioEnabled, targetLongEdge or maxLayers controls. Supply prompts, assets and selection instructions as separate Parts; use tool call for exact geometry fields."),
29
30
  text(runtime.product, "usage 仅覆盖本次调用,不包含其他命令调用的消耗。", "usage covers this invocation only, excluding other command invocations."),
30
31
  ""
31
32
  ].join("\n"));