@gaoding/cli 1.8.0 → 1.9.1

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 (95) hide show
  1. package/contracts/operations/agent.send/input.schema.json +1 -1
  2. package/contracts/operations/agent.send/output.schema.json +1 -1
  3. package/contracts/operations/model.get/input.schema.json +6 -0
  4. package/contracts/operations/model.get/output.schema.json +10 -1
  5. package/contracts/operations/tool.call/canvas-input.schema.json +60 -0
  6. package/contracts/operations/tool.call/models/image-edit-smart.schema.json +42 -0
  7. package/contracts/operations/tool.call/models/image-edit-standard.schema.json +33 -0
  8. package/contracts/operations/tool.call/models/image-enhance-smart.schema.json +27 -0
  9. package/contracts/operations/tool.call/models/image-enhance-standard.schema.json +27 -0
  10. package/contracts/operations/tool.call/models/image-expand-smart.schema.json +76 -0
  11. package/contracts/operations/tool.call/models/image-expand-standard.schema.json +61 -0
  12. package/contracts/operations/tool.call/models/image-layers-layout.schema.json +21 -0
  13. package/contracts/operations/tool.call/models/image-layers-smart.schema.json +28 -0
  14. package/contracts/operations/tool.call/models/image-matting-smart.schema.json +37 -0
  15. package/contracts/operations/tool.call/models/image-matting-standard.schema.json +26 -0
  16. package/contracts/operations/tool.call/models/image-ocr.schema.json +21 -0
  17. package/contracts/operations/tool.call/models/image-remove-smart.schema.json +32 -0
  18. package/contracts/operations/tool.call/models/image-remove-standard.schema.json +27 -0
  19. package/contracts/operations/tool.call/models/image-text-edit.schema.json +46 -0
  20. package/contracts/operations/tool.call/models/image-vectorize.schema.json +21 -0
  21. package/contracts/operations/tool.call/models/video-edit-smart.schema.json +76 -0
  22. package/contracts/operations/tool.call/models/video-enhance-smart.schema.json +33 -0
  23. package/contracts/operations/tool.call/models/video-enhance-standard.schema.json +27 -0
  24. package/contracts/operations/tool.call/ocr-payload.schema.json +66 -0
  25. package/contracts/operations/tool.call/output.schema.json +38 -0
  26. package/contracts/operations/tool.call/template-payload.schema.json +96 -0
  27. package/dist/bin/gd-cli.js +31 -24
  28. package/dist/bin/insmind-cli.js +31 -24
  29. package/dist/bin/task-worker.js +4 -1
  30. package/dist/src/analytics/device.js +2 -2
  31. package/dist/src/bootstrap/create-cli.js +7 -0
  32. package/dist/src/bootstrap/create-runtime.js +53 -30
  33. package/dist/src/bootstrap/run-task-worker.js +5 -1
  34. package/dist/src/bootstrap/validators.js +11 -4
  35. package/dist/src/cli/agent-commands.js +1 -0
  36. package/dist/src/cli/dam-commands.js +3 -3
  37. package/dist/src/cli/errors.js +63 -15
  38. package/dist/src/cli/model-commands.js +6 -3
  39. package/dist/src/cli/observed-errors.js +3 -1
  40. package/dist/src/cli/tool-commands.js +2 -0
  41. package/dist/src/contracts/schema.js +4 -1
  42. package/dist/src/features/agent/creative-agent-adapter.js +37 -11
  43. package/dist/src/features/agent/creative-protocol.js +31 -10
  44. package/dist/src/features/agent/creative-stream.js +54 -6
  45. package/dist/src/features/agent/resource-authorizer.js +1 -0
  46. package/dist/src/features/agent/result-reader.js +3 -1
  47. package/dist/src/features/agent/use-cases.js +15 -5
  48. package/dist/src/features/auth/credential-store.js +6 -10
  49. package/dist/src/features/auth/sso-service.js +22 -6
  50. package/dist/src/features/auth/state.js +6 -0
  51. package/dist/src/features/auth/use-cases.js +90 -32
  52. package/dist/src/features/dam/asset-projection.js +10 -1
  53. package/dist/src/features/dam/dam-api-adapter.js +30 -15
  54. package/dist/src/features/dam/input.js +23 -0
  55. package/dist/src/features/dam/use-cases.js +32 -22
  56. package/dist/src/features/task/store.js +5 -5
  57. package/dist/src/features/task/task-background.js +67 -19
  58. package/dist/src/features/task/use-cases.js +38 -9
  59. package/dist/src/features/tool/canvas-copy.js +61 -0
  60. package/dist/src/features/tool/canvas-media.js +248 -0
  61. package/dist/src/features/tool/canvas-models.js +109 -0
  62. package/dist/src/features/tool/canvas-pricing.js +81 -0
  63. package/dist/src/features/tool/canvas-recovery.js +68 -0
  64. package/dist/src/features/tool/canvas-results.js +144 -0
  65. package/dist/src/features/tool/canvas-tool-adapter.js +366 -0
  66. package/dist/src/features/tool/canvas-video.js +84 -0
  67. package/dist/src/features/tool/catalog.js +35 -13
  68. package/dist/src/features/tool/dynamic-schema.js +55 -25
  69. package/dist/src/features/tool/matting-billing.js +115 -0
  70. package/dist/src/features/tool/mns-catalog-adapter.js +66 -19
  71. package/dist/src/features/tool/resource-authorizer.js +34 -0
  72. package/dist/src/features/tool/scene-catalog-adapter.js +35 -0
  73. package/dist/src/features/tool/tool-api-adapter.js +29 -17
  74. package/dist/src/features/tool/use-cases.js +28 -3
  75. package/dist/src/platform/file-lock.js +58 -15
  76. package/dist/src/platform/input-uri.js +105 -0
  77. package/dist/src/platform/local-json-file.js +7 -4
  78. package/dist/src/platform/remote-error-evidence.js +23 -1
  79. package/dist/src/platform/safe-upload-file.js +18 -4
  80. package/dist/src/platform/schema-issues.js +18 -0
  81. package/dist/src/platform/signed-http-transport.js +77 -16
  82. package/dist/src/platform/text-output.js +55 -13
  83. package/dist/src/product/config.js +12 -1
  84. package/dist/src/telemetry/failure-summary.js +53 -2
  85. package/dist/src/telemetry/host-diagnostics.js +95 -0
  86. package/dist/src/telemetry/invocation.js +24 -3
  87. package/dist/src/telemetry/process-errors.js +2 -1
  88. package/dist/src/telemetry/sls-sink.js +66 -18
  89. package/package.json +5 -4
  90. package/skills/gd-cli/SKILL.md +2 -0
  91. package/skills/gd-cli/references/creation.md +2 -0
  92. package/skills/gd-cli/references/generation-constraints.md +3 -1
  93. package/skills/gd-cli/references/matting.md +29 -0
  94. package/skills/gd-cli/references/media-tools.md +40 -0
  95. package/skills/gd-cli/references/tool.md +4 -4
@@ -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";
@@ -48,7 +54,7 @@ import { loadBundledSkills } from "../features/skill/bundled-skills.js";
48
54
  import { createUpdateService } from "../features/update/update-service.js";
49
55
  import { createUpdateNotificationService } from "../features/update/update-notification.js";
50
56
  import { classifyTelemetryError, mapCliError } from "../cli/errors.js";
51
- import { createTelemetryInvocation } from "../telemetry/invocation.js";
57
+ import { createTelemetryInvocation, hostTelemetryContext } from "../telemetry/invocation.js";
52
58
  import { createSlsTelemetrySink } from "../telemetry/sls-sink.js";
53
59
  import { gaodingProduct } from "../product/config.js";
54
60
  import { resolveProductLocale, systemLocale } from "../product/locale.js";
@@ -100,12 +106,7 @@ 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
  });
103
- telemetry.annotate({ installation_owner: installationOwner,
104
- ...(["workbuddy", "qwenwork"].includes(env.CLI_HOST_APPLICATION ?? "")
105
- ? { host_application: env.CLI_HOST_APPLICATION } : {}),
106
- ...(["auth_status", "version_check"].includes(env.CLI_INVOCATION_PURPOSE ?? "")
107
- ? { invocation_purpose: env.CLI_INVOCATION_PURPOSE } : {}),
108
- ...(/^[a-f0-9]{32}$/u.test(env.CLI_HOST_INVOCATION_ID ?? "") ? { host_invocation_id: env.CLI_HOST_INVOCATION_ID } : {}) });
109
+ telemetry.annotate({ installation_owner: installationOwner, ...hostTelemetryContext(env) });
109
110
  // Explicit test transport enables SDK tests; test-mode child processes never emit real analytics.
110
111
  const analytics = options.analytics ?? (telemetryEnvironment === "production" || options.windFetch
111
112
  ? createWindAnalytics({ product: product.id, version: options.telemetryVersion ?? primarySkill.version,
@@ -227,12 +228,13 @@ export function createProductionRuntime(options = {}) {
227
228
  const validators = createContractValidators({
228
229
  organizations: product.exposesOrganizations
229
230
  });
230
- const modelCatalog = createMnsCatalogAdapter({
231
- transport: mnsTransport,
232
- ...(product.id === "insmind"
233
- ? { invalidModelWarning: (count) => `Ignored ${count} invalid model configuration${count === 1 ? "" : "s"}.` }
234
- : {})
235
- });
231
+ const modelCatalog = createSceneCatalogAdapter({ transport: toolTransport, english: product.id === "insmind", catalog: createMnsCatalogAdapter({
232
+ english: product.id === "insmind",
233
+ transport: mnsTransport,
234
+ ...(product.id === "insmind"
235
+ ? { invalidModelWarning: (count) => `Ignored ${count} invalid model configuration${count === 1 ? "" : "s"}.` }
236
+ : {})
237
+ }) });
236
238
  const damApi = createDamApiAdapter({ transport: damTransport });
237
239
  const damRepositories = createDamRepositoryCatalog({ transport: damTransport });
238
240
  const damOperations = createDamOperationExecutor({
@@ -300,6 +302,10 @@ export function createProductionRuntime(options = {}) {
300
302
  });
301
303
  };
302
304
  const authorizeTaskResult = async (result, state, signal, alreadyAuthorized = false) => {
305
+ if ("message" in result)
306
+ validators.agentSendOutput(result);
307
+ else
308
+ validators.toolCallOutput(result);
303
309
  // Bind only if this result actually needs a fresh resource token.
304
310
  const taskAuthorizer = createAgentResourceAuthorizer({ authKeys: {
305
311
  async getAuthKey(access, tokenSignal) {
@@ -311,21 +317,7 @@ export function createProductionRuntime(options = {}) {
311
317
  const access = { credential: state.credential, organizationId: state.organization.id };
312
318
  if ("message" in result)
313
319
  return taskAuthorizer.authorize(result, access, signal);
314
- const links = result.content.filter(part => part.type === "resource_link");
315
- if (links.length === 0)
316
- return result;
317
- const parts = links.map(part => ({ url: part.uri, mediaType: part.mimeType ?? "application/octet-stream" }));
318
- const authorized = await taskAuthorizer.authorize({
319
- message: { contextId: "resource-authorization", parts: [parts[0], ...parts.slice(1)] },
320
- usage: { cost: { unit: "gaodou", amount: 0 }, items: [] }
321
- }, access, signal);
322
- let index = 0;
323
- return { ...result, content: result.content.map(part => {
324
- if (part.type !== "resource_link")
325
- return part;
326
- const authorizedPart = authorized.message.parts[index++];
327
- return authorizedPart && "url" in authorizedPart ? { ...part, uri: authorizedPart.url } : part;
328
- }) };
320
+ return authorizeToolResources(result, taskAuthorizer, access, signal);
329
321
  };
330
322
  const tasks = createTaskUseCases({
331
323
  telemetry,
@@ -365,6 +357,7 @@ export function createProductionRuntime(options = {}) {
365
357
  credential: state.credential, organizationId: state.organization.id, signal
366
358
  });
367
359
  return { state: "unknown",
360
+ ...(snapshot.usageModelMissing ? { usageModelMissing: true } : {}),
368
361
  note: snapshot.partialResult
369
362
  ? text("已找到部分内容,尚未取得完整结果。", "Some content was found, but the complete result has not been received.")
370
363
  : text("尚未取得任务结果。", "The task result has not been received."),
@@ -372,6 +365,33 @@ export function createProductionRuntime(options = {}) {
372
365
  };
373
366
  },
374
367
  async tool(progress, state, signal) {
368
+ if (progress.toolPipeline) {
369
+ const pipeline = progress.toolPipeline;
370
+ await authorizeTaskAccess(state, signal);
371
+ let recovered;
372
+ try {
373
+ recovered = await telemetry.stage("task.query", () => recoverCanvasTool(progress, {
374
+ access: { credential: state.credential, organizationId: state.organization.id }, signal
375
+ }, { transport: toolTransport, media: canvasMedia, english: product.id === "insmind" }));
376
+ }
377
+ catch (error) {
378
+ if (!(error instanceof ToolTaskFailedError) && !(error instanceof ToolTaskCanceledError))
379
+ throw error;
380
+ const outcome = mapCliError(error, { aborted: false, product, operation: "task.get", failureStage: "task.query" });
381
+ return { state: "failed", note: outcome.failure?.message ?? text("本次处理未能完成。", "This processing could not be completed."), failure: error };
382
+ }
383
+ if (recovered.state === "complete" && progress.toolUsage)
384
+ return { state: "completed", result: await authorizeTaskResult(toolOutputWithBillingUnit({
385
+ content: recovered.content, usage: progress.toolUsage
386
+ }, product.billingUnit), state, signal, true) };
387
+ if (recovered.state === "pending")
388
+ return { state: "running", note: text("任务仍在处理中。", "The task is still processing.") };
389
+ const partialContent = recovered.state === "unknown" ? recovered.content : undefined;
390
+ 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.`),
391
+ ...(partialContent && progress.toolUsage ? { partialResult: await authorizeTaskResult(toolOutputWithBillingUnit({
392
+ content: partialContent, usage: progress.toolUsage
393
+ }, product.billingUnit), state, signal, true) } : {}) };
394
+ }
375
395
  if (!progress.remoteTaskId || !progress.toolUsage)
376
396
  return {
377
397
  state: "unknown", note: text("尚未取得任务结果。", "The task result has not been received.")
@@ -418,11 +438,14 @@ export function createProductionRuntime(options = {}) {
418
438
  warn: (message) => { presenter.warning(message); },
419
439
  telemetry
420
440
  }), product.billingUnit);
441
+ const canvasMedia = createCanvasMedia({ fetch, uploader: transientUploader });
421
442
  const tool = withToolBillingUnit(createToolUseCases({
422
443
  catalog: modelCatalog,
423
444
  tools: product.tools,
424
445
  ...(product.id === "insmind" ? { modelDescription: "Model machine identifier from model list." } : {}),
425
- execution: createToolApiAdapter({ transport: toolTransport, telemetry }),
446
+ execution: createCanvasToolAdapter({ transport: toolTransport, recordTransport: damTransport, telemetry, media: canvasMedia, english: product.id === "insmind",
447
+ fallback: createToolApiAdapter({ transport: toolTransport, telemetry }),
448
+ standardMatting: createStandardMatting({ transport: toolTransport, recordTransport: damTransport, media: canvasMedia }) }),
426
449
  uploader: transientUploader,
427
450
  warn: (message) => { presenter.warning(message); },
428
451
  telemetry
@@ -49,10 +49,14 @@ export async function runTaskWorker(options) {
49
49
  : { outcome: "failure", error, errorCode: outcome.failure.code, errorMessage: outcome.failure.message };
50
50
  if (outcome.kind === "failure")
51
51
  send({ type: "error", failure: outcome.failure, exitCode: outcome.exitCode,
52
- diagnostics: taskWorkerDiagnostics(error, classifyTelemetryError(error, { product: runtime.product, operation: job.operation, failureStage: runtime.telemetry.failureStage(error) }), runtime.telemetry.failureStage(error)) });
52
+ diagnostics: taskWorkerDiagnostics(error, {
53
+ ...classifyTelemetryError(error, { product: runtime.product, operation: job.operation, failureStage: runtime.telemetry.failureStage(error) }),
54
+ diagnosticSummary: runtime.telemetry.taskFailure(error).diagnostic_summary ?? {}
55
+ }, runtime.telemetry.failureStage(error)) });
53
56
  }
54
57
  finally {
55
58
  await runtime.analytics?.shutdown().catch(() => undefined);
59
+ await runtime.telemetrySink.refreshDiagnostics?.().catch(() => undefined);
56
60
  runtime.telemetry.annotate(runtime.telemetrySink.diagnostics?.() ?? {});
57
61
  await runtime.telemetrySink.send(runtime.telemetry.finish(completion)).catch(() => undefined);
58
62
  }
@@ -1,4 +1,5 @@
1
- import { validationIssues } from "../platform/schema-issues.js";
1
+ import { inputValidationSummary, validationIssues } from "../platform/schema-issues.js";
2
+ import { canonicalizeInputFileUris } from "../platform/input-uri.js";
2
3
  import { Ajv2020 } from "ajv/dist/2020.js";
3
4
  import addFormatsImport, {} from "ajv-formats";
4
5
  import { contractSchema } from "../contracts/schema.js";
@@ -45,9 +46,11 @@ const toolCallOutputSchema = contractSchema("tool.call", "output");
45
46
  const toolListOutputSchema = contractSchema("tool.list", "output");
46
47
  export class InputContractError extends Error {
47
48
  issues;
48
- constructor(issues = []) {
49
+ diagnosticSummary;
50
+ constructor(issues = [], diagnosticSummary = {}) {
49
51
  super(`输入不符合命令契约。${issues.length ? ` ${JSON.stringify(issues)}` : ""}`);
50
52
  this.issues = issues;
53
+ this.diagnosticSummary = diagnosticSummary;
51
54
  this.name = "InputContractError";
52
55
  }
53
56
  }
@@ -168,7 +171,11 @@ export function createContractValidators(options = {}) {
168
171
  const unavailableValidator = Object.assign(() => false, { errors: null, schema: false, schemaEnv: undefined });
169
172
  function assertion(validate, ErrorType) {
170
173
  return (value) => {
171
- if (!validate(value))
172
- throw new ErrorType(validationIssues(validate.errors, value, validate.schema));
174
+ if (ErrorType === InputContractError)
175
+ canonicalizeInputFileUris(value, validate.schema);
176
+ if (!validate(value)) {
177
+ const issues = validationIssues(validate.errors, value, validate.schema);
178
+ throw new ErrorType(issues, inputValidationSummary(issues, value));
179
+ }
173
180
  };
174
181
  }
@@ -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"));
@@ -100,12 +100,12 @@ export function registerDamCommands(program, runtime) {
100
100
  });
101
101
  }, { operation: "dam.tag.list" });
102
102
  const download = leaf(dam.command("download"))
103
- .description(text(runtime.product, "下载一个素材", "Download an asset"))
103
+ .description(text(runtime.product, "下载一个素材的源文件", "Download an asset's source file"))
104
104
  .argument("<asset>", text(runtime.product, "素材 ID", "asset ID"))
105
105
  .option("--repository-id <id>", text(runtime.product, "所属资源库 ID", "repository ID"))
106
- .option("--output-dir <directory>", text(runtime.product, "输出目录", "output directory"))
106
+ .option("--output-dir <directory>", text(runtime.product, "输出目录,默认当前目录", "output directory; defaults to the current directory"))
107
107
  .option("--json", text(runtime.product, "输出 JSON", "output JSON"));
108
- download.addHelpText("after", `\n${text(runtime.product, "只下载一个素材,不支持文件夹;写入本机目录,不覆盖已有同名文件。--json 返回 files 中的路径、字节数与摘要。", "Downloads one asset, not a folder, to a local directory without overwriting same-named files. --json returns paths, byte counts and digests in files.")}\n`);
108
+ download.addHelpText("after", `\n${text(runtime.product, "下载单个素材的源文件,不支持文件夹,也不会自动导出作品。--output-dir 指定目录;已有同名文件时选择其他目录或先处理该文件。--json 返回 files 中的路径、字节数与摘要。", "Downloads one asset's source file; folders and automatic design export are not supported. --output-dir selects a directory. If a same-named file exists, choose another directory or handle the existing file first. --json returns paths, byte counts and digests in files.")}\n`);
109
109
  bindPreparedAction(download, "organization", async (signal) => {
110
110
  signal.throwIfAborted();
111
111
  const options = download.opts();
@@ -4,12 +4,12 @@ import { TaskNotFoundError } from "../features/task/use-cases.js";
4
4
  import { TaskStoreError } from "../features/task/store.js";
5
5
  import { CommanderError } from "commander";
6
6
  import { AuthExpiredError, AuthRequiredError } from "../features/auth/access-policy.js";
7
- import { AuthStateInvalidError, UserIdentityMissingError } from "../features/auth/state.js";
7
+ import { AuthStateInvalidError, AuthStateUnavailableError, UserIdentityMissingError } from "../features/auth/state.js";
8
8
  import { SsoRequestError } from "../features/auth/sso-service.js";
9
9
  import { AuthorizedAccountContextMissingError, BrowserOpenError, DeviceAuthorizationExpiredError } from "../features/auth/use-cases.js";
10
10
  import { AgentInputError } from "../features/agent/use-cases.js";
11
11
  import { ToolInputError } from "../features/tool/catalog.js";
12
- import { ToolTaskFailedError, ToolTaskCanceledError } from "../features/tool/tool-api-adapter.js";
12
+ import { ToolTaskFailedError, ToolTaskCanceledError, ToolInsufficientCreditsError } from "../features/tool/tool-api-adapter.js";
13
13
  import { AgentAuditRejectedError } from "../features/agent/creative-protocol.js";
14
14
  import { isContentReviewRejection } from "../features/task/creation-refusal.js";
15
15
  import { ObjectStorageUploadError } from "../features/dam/object-storage.js";
@@ -68,7 +68,7 @@ export function mapCliError(error, options) {
68
68
  if (!category)
69
69
  return outcome;
70
70
  // Keep precise input corrections and their fields; general failures have a short user message.
71
- if (category === "input" && ["USAGE_ERROR", "INVALID_ACTIONS"].includes(outcome.failure.code))
71
+ if ((category === "input" || category === "input_asset") && ["USAGE_ERROR", "INVALID_ACTIONS"].includes(outcome.failure.code))
72
72
  return outcome;
73
73
  return { ...outcome, failure: { ...outcome.failure, message: observedErrorMessage(category, evidence) } };
74
74
  }
@@ -108,6 +108,8 @@ function mapBaseCliError(error, options) {
108
108
  return failure("AUTH_EXPIRED", "Authentication expired. Sign out and sign in again.", 1, [`${command} auth logout`, `${command} auth login`]);
109
109
  return failure("AUTH_EXPIRED", "登录已过期,请退出后重新登录。", 1, ["gd-cli auth logout", "gd-cli auth login"]);
110
110
  }
111
+ if (error instanceof AuthStateUnavailableError)
112
+ return failure("AUTH_STATE_UNAVAILABLE", text("无法读取或保存本地登录信息。", "Local sign-in information could not be read or saved."), 1, [text("请检查文件访问权限后重试。", "Check file access permissions and try again.")], { reason: "local_io", system_code: systemErrorCode(error) });
111
113
  if (error instanceof AuthStateInvalidError) {
112
114
  if (error.reason === "local_io")
113
115
  return failure("AUTH_STATE_INVALID", text("无法读写本地凭证,当前无法判断登录是否有效。", "Cannot access local credentials; authentication validity is unknown."), 1, [text("恢复凭证文件的访问权限或宿主文件访问能力;不要执行 logout 或删除凭证。", "Restore access to the credential file or host file permissions; do not log out or delete credentials.")], { reason: error.reason, system_code: systemErrorCode(error) });
@@ -147,12 +149,23 @@ function mapBaseCliError(error, options) {
147
149
  const description = descriptions[error.reason];
148
150
  return failure("USAGE_ERROR", description ? text(...description) : text("创作输入不可用,请核对模型与参数。", "Check the model and creation arguments."), 2, [`${command} model list`, text(`使用 ${command} model get <model> 核对模型参数;素材应使用安全的 HTTP(S) URL 或本地 file URL。`, `Use ${command} model get <model> to inspect parameters; assets require safe HTTP(S) URLs or local file URLs.`)], { reason: error.reason, field: error.field, ...(error instanceof ToolInputError ? { issues: error.issues } : {}) });
149
151
  }
150
- if (error instanceof LocalFileInputError)
151
- return failure("USAGE_ERROR", text("本地素材文件不可用于上传。", "The local asset file cannot be uploaded."), 2, [text("检查文件访问权限、文件类型和声明的 mediaType;受保护路径不可上传。", "Check file access, type and declared mediaType; protected paths cannot be uploaded.")], { reason: error.reason, system_code: systemErrorCode(error) });
152
+ if (error instanceof LocalFileInputError) {
153
+ const message = error.reason === "invalid_file_uri"
154
+ ? text("本地文件地址格式不正确。Windows 地址示例:file:///C:/目录/文件。", "Invalid local file URL. Windows example: file:///C:/folder/file.")
155
+ : error.reason === "file_read_failed" && systemErrorCode(error) === "ENOENT"
156
+ ? text("找不到指定的本地文件,请核对完整路径。", "The local file was not found. Check its full path.")
157
+ : error.reason === "media_type_mismatch"
158
+ ? text("素材类型与文件实际格式不一致,请修正 mediaType 或重新选择文件。", "The mediaType does not match the file format. Correct it or select another file.")
159
+ : text("本地素材文件不可用于上传。", "The local asset file cannot be uploaded.");
160
+ return failure("USAGE_ERROR", message, 2, [text("检查文件访问权限、文件类型和声明的 mediaType;受保护路径不可上传。", "Check file access, type and declared mediaType; protected paths cannot be uploaded.")], { reason: error.reason, system_code: systemErrorCode(error) });
161
+ }
152
162
  if (error instanceof CliUsageError && error.reason === "invalid_task_id")
153
163
  return failure("USAGE_ERROR", text("任务编号不正确,请使用本机任务列表中的 taskId。", "Invalid Task ID. Use a taskId from the local task list."), 2, [`${command} task list`, `${command} task get <taskId>`], { reason: error.reason });
154
164
  if (error instanceof DamInputError)
155
165
  return failure("USAGE_ERROR", text("素材管理参数无效,请根据字段和原因核对命令 --help。", "Invalid asset-management argument; check the field and reason against the command's --help."), 2, undefined, { reason: error.reason, field: error.field });
166
+ if (error instanceof CommanderError && error.code === "commander.unknownOption" && options.operation === "dam.download"
167
+ && /unknown option ['"]--output['"]/u.test(error.message))
168
+ return failure("USAGE_ERROR", text("下载目录请使用 --output-dir <directory>。", "Use --output-dir <directory> to choose the download directory."), 2);
156
169
  if (error instanceof OrgUsageError
157
170
  || error instanceof CliUsageError
158
171
  || error instanceof CommanderError) {
@@ -160,8 +173,8 @@ function mapBaseCliError(error, options) {
160
173
  return failure("USAGE_ERROR", "Invalid command or arguments. See --help.", 2);
161
174
  return failure("USAGE_ERROR", "命令或参数无效,请查看 --help。", 2);
162
175
  }
163
- if (options.product?.id !== "insmind" && options.operation === "tool.call" && isInsufficientCreditsError(error)) {
164
- return failure("INSUFFICIENT_CREDITS", "当前可用额度不足,本次生成未能完成。", 1);
176
+ if (error instanceof ToolInsufficientCreditsError || options.product?.id !== "insmind" && options.operation === "tool.call" && isInsufficientCreditsError(error)) {
177
+ return failure("INSUFFICIENT_CREDITS", text("当前可用额度不足,本次生成未能完成。", "Available credits are insufficient; this creation could not complete."), 1);
165
178
  }
166
179
  if (isContentReviewRejection(error, { product: options.product?.id ?? "gaoding", operation: options.operation })) {
167
180
  const phase = error instanceof AgentAuditRejectedError ? error.phase : undefined;
@@ -256,6 +269,8 @@ function mapBaseCliError(error, options) {
256
269
  }
257
270
  return failure(error.code, redactSensitiveText(error.message).slice(0, 1024), 1, ["写入失败时先检查原作品,不直接重复 apply 或 save;按 editor --help 中的对应错误指引处理。"]);
258
271
  }
272
+ if (systemErrorCode(error) === "ECONNRESET")
273
+ return failure("REMOTE_REQUEST_FAILED", text("连接中断,未能完整收到结果。", "The connection closed before the full result was received."), 1);
259
274
  return failure("INTERNAL_ERROR", insmind ? "The CLI encountered an internal error." : "CLI 发生内部错误。", 1);
260
275
  }
261
276
  function isInsufficientCreditsError(error) {
@@ -270,6 +285,13 @@ export function classifyTelemetryError(error, options = {}) {
270
285
  return { outcome: "failure", errorCode: error.code,
271
286
  ...(error.status === undefined ? {} : { httpStatus: error.status }) };
272
287
  const outcome = mapCliError(error, { ...options, aborted: options.aborted === true });
288
+ if (error instanceof DeviceAuthorizationExpiredError && outcome.kind !== "interrupted")
289
+ return {
290
+ outcome: "failure", errorCode: "REMOTE_REQUEST_FAILED",
291
+ diagnosticReason: error.expirationSource === "server_expired" ? "AUTHORIZATION_SERVER_EXPIRED" : "AUTHORIZATION_WAIT_TIMEOUT",
292
+ ...(error.httpStatus === undefined ? {} : { httpStatus: error.httpStatus }),
293
+ ...(error.expirationSource === "server_expired" ? { remoteErrorCode: "expired_token" } : {})
294
+ };
273
295
  if (error instanceof TaskBackgroundError) {
274
296
  const diagnostics = error.diagnostics;
275
297
  return { outcome: outcome.kind === "interrupted" ? "interrupted" : "failure",
@@ -290,24 +312,27 @@ export function classifyTelemetryError(error, options = {}) {
290
312
  }
291
313
  catch { /* No safe summary available. */ }
292
314
  }
315
+ const inputReason = error instanceof LocalFileInputError ? error.reason
316
+ : error instanceof JsonInputError ? `json_${error.reason}`
317
+ : error instanceof InputContractError ? "schema_validation"
318
+ : error instanceof CliUsageError || error instanceof ToolInputError || error instanceof AgentInputError || error instanceof DamInputError ? error.reason
319
+ : error instanceof CommanderError ? error.code : undefined;
320
+ const systemCode = systemErrorCode(error);
293
321
  const diagnosticSummary = safeFailureSummary({
294
322
  ...localFileSummary(error),
295
323
  ...(error instanceof OutputStreamError ? { outputStream: error.outputStream } : {}),
296
324
  ...(remoteError instanceof SsoRequestError ? remoteError.diagnosticSummary : {}),
297
325
  ...(summary && typeof summary === "object" && !Array.isArray(summary) ? summary : {}),
298
- systemCode: systemErrorCode(error),
299
- inputReason: error instanceof LocalFileInputError ? error.reason
300
- : error instanceof JsonInputError ? `json_${error.reason}`
301
- : error instanceof InputContractError ? "schema_validation"
302
- : error instanceof CliUsageError || error instanceof ToolInputError || error instanceof AgentInputError ? error.reason
303
- : error instanceof CommanderError ? error.code : undefined
326
+ ...nestedDiagnosticSummary(error),
327
+ ...(systemCode ? { systemCode } : {}),
328
+ ...(inputReason ? { inputReason } : {})
304
329
  });
305
330
  return {
306
331
  outcome: outcome.kind === "interrupted" ? "interrupted" : "failure",
307
332
  ...(diagnosticSummary ? { diagnosticSummary } : {}),
308
333
  ...(outcome.kind === "failure" ? { errorCode: outcome.failure.code } : {}),
309
- ...((remoteError instanceof RemoteRequestError || remoteError instanceof SsoRequestError) && remoteError.status !== undefined
310
- ? { httpStatus: remoteError.status }
334
+ ...(httpErrorStatus(error) !== undefined
335
+ ? { httpStatus: httpErrorStatus(error) }
311
336
  : {}),
312
337
  ...(remoteError?.remoteCode === undefined
313
338
  ? {}
@@ -323,6 +348,29 @@ export function classifyTelemetryError(error, options = {}) {
323
348
  ? { diagnosticReason: remoteError.diagnosticReason } : {})
324
349
  };
325
350
  }
351
+ function nestedDiagnosticSummary(error) {
352
+ const facts = {};
353
+ const seen = new Set();
354
+ for (let depth = 0; error instanceof Error && depth < 10 && !seen.has(error); depth++, error = error.cause) {
355
+ seen.add(error);
356
+ if (!("diagnosticSummary" in error))
357
+ continue;
358
+ const summary = safeFailureSummary(error.diagnosticSummary);
359
+ for (const [key, value] of Object.entries(summary ?? {}))
360
+ if (!(key in facts))
361
+ facts[key] = value;
362
+ }
363
+ return facts;
364
+ }
365
+ function httpErrorStatus(error) {
366
+ const seen = new Set();
367
+ for (let depth = 0; error instanceof Error && depth < 10 && !seen.has(error); depth++, error = error.cause) {
368
+ seen.add(error);
369
+ if ("status" in error && typeof error.status === "number" && Number.isInteger(error.status) && error.status >= 100 && error.status <= 599)
370
+ return error.status;
371
+ }
372
+ return undefined;
373
+ }
326
374
  function failure(code, message, exitCode, nextSteps, details) {
327
375
  return {
328
376
  kind: "failure",
@@ -6,7 +6,7 @@ export function registerModelCommands(program, runtime) {
6
6
  .description(text(runtime.product, "创作模型", "Creation models"))
7
7
  .helpCommand(false);
8
8
  const list = model.command("list")
9
- .description(text(runtime.product, "列出图片/视频生成模型(不含独立风格)", "List image/video generation models (excluding standalone styles)"))
9
+ .description(text(runtime.product, "列出当前可用的创作与媒体处理模型(不含独立风格)", "List available creation and media-processing models (excluding standalone styles)"))
10
10
  .option("--tool <tool>", text(runtime.product, "按工具筛选", "filter by tool"))
11
11
  .allowExcessArguments(false);
12
12
  jsonOutput(list);
@@ -32,12 +32,14 @@ export function registerModelCommands(program, runtime) {
32
32
  });
33
33
  }, { operation: "model.list" });
34
34
  const get = model.command("get")
35
- .description(text(runtime.product, "查看模型完整信息", "Show complete model information"))
35
+ .description(text(runtime.product, "查看模型完整信息与输入 Schema", "Show complete model information and input Schema"))
36
36
  .argument("<model>", text(runtime.product, "模型机器标识", "model machine identifier"))
37
+ .option("--tool <tool>", text(runtime.product, "指定模型用途上下文", "select the model's tool context"))
37
38
  .allowExcessArguments(false);
38
39
  get.addHelpText("after", [
39
40
  "",
40
41
  text(runtime.product, "只读查询当前身份可用的 Model,输出 JSON;不提交创作。参数、费用和预估耗时来自实时目录。", "Reads a Model available to the current identity as JSON without submitting creation. Parameters, cost and estimated time come from the live catalog."),
42
+ text(runtime.product, "inputSchema 是选定 Tool + Model 的完整 JSON Schema,包含嵌套对象、数组及约束。同一 Model 用于多个 Tool 时请加 --tool;优先按 inputSchema 构造 Tool 输入。", "inputSchema is the complete JSON Schema for the selected Tool + Model, including nested objects, arrays and constraints. Use --tool when a Model supports multiple Tools; construct Tool input from inputSchema."),
41
43
  text(runtime.product, "parameters 是结构化元数据,不是 JSON Schema:遵守 required/type、minimum/maximum/step,SELECT 使用 options[].value 而非 label。", "parameters is structured metadata, not JSON Schema: follow required/type, minimum/maximum/step, and use SELECT options[].value rather than label."),
42
44
  text(runtime.product, "Tool 调用须显式提供所有 required 字段;用户未指定时显式使用返回的 default。model 标识放入调用参数顶层,与模型参数并列。", "Tool calls explicitly supply every required field, using a returned default when the user omitted it. Include the returned model identifier at the top level alongside its parameters."),
43
45
  text(runtime.product, "usageDescription 说明跨字段组合规则。tool call <tool> --schema 根据 model 校验对应必填字段、可用参数和范围;step 及跨字段规则另见本 Model 元数据。Agent 只传显式生成约束,不照搬 Tool 的完整必填参数。", "usageDescription explains cross-field combinations. tool call <tool> --schema validates required fields, allowed parameters and ranges per model; follow this Model's metadata for step and cross-field rules. For Agent, pass explicit generation constraints rather than copying every Tool-required parameter."),
@@ -49,7 +51,8 @@ export function registerModelCommands(program, runtime) {
49
51
  if (typeof modelName !== "string" || modelName.trim() === "")
50
52
  throw new CliUsageError();
51
53
  runtime.telemetry.annotate({ model_id: modelName });
52
- const input = { model: modelName };
54
+ const selectedTool = get.opts().tool;
55
+ const input = { model: modelName, ...(selectedTool === undefined ? {} : { tool: selectedTool }) };
53
56
  await runtime.telemetry.stage("input", async () => {
54
57
  runtime.validators.modelGetInput(input);
55
58
  });
@@ -76,7 +76,7 @@ export function observedErrorCategory(e) {
76
76
  return "unsupported";
77
77
  if (e.code === "SAVE_FAILED")
78
78
  return "save";
79
- if (e.code === "LOCAL_STATE_ERROR")
79
+ if (["LOCAL_STATE_ERROR", "AUTH_STATE_UNAVAILABLE"].includes(e.code))
80
80
  return "local";
81
81
  if (e.code === "UPDATE_FAILED" && e.diagnosticReason === "UPDATE_MANAGED_BY_HOST")
82
82
  return "managed_update";
@@ -112,6 +112,8 @@ export function observedErrorMessage(category, e) {
112
112
  return text("素材下载未完成。", "The asset download did not complete.");
113
113
  if (category === "local" && e.errorType === "LocalFileError")
114
114
  return text("无法读取或保存所需文件。", "A required file could not be read or saved.");
115
+ if (category === "local" && e.code === "AUTH_STATE_UNAVAILABLE")
116
+ return text("无法读取或保存本地登录信息。", "Local sign-in information could not be read or saved.");
115
117
  if (category === "request" && e.operation === "task.get")
116
118
  return text("本次未能读取任务结果。", "The task result could not be retrieved.");
117
119
  return text(messages[category][0], messages[category][1]);
@@ -37,7 +37,9 @@ export function registerToolCommands(program, runtime) {
37
37
  text(runtime.product, "异步任务由本机后台进程继续等待结果;进程终止或关机可能使状态变为 unknown。", "Async work continues in a local background process; termination or shutdown may leave its state unknown."),
38
38
  text(runtime.product, "用 task get <taskId> 查询原任务;completed 时 result 为完整结果,running/unknown 或查询超时不应重新提交。", "Query the same taskId with task get; completed includes result. Do not resubmit on running, unknown, or a query timeout."),
39
39
  text(runtime.product, "默认等待原 Tool 结果;任务 ID 写入 stderr,stdout 保持原 JSON。", "By default, the command waits for the original Tool result; stderr shows the Task ID and stdout keeps the result JSON."),
40
+ text(runtime.product, "媒体 URI 字段支持 HTTP(S) 与本地 file:// URI;CLI 会按调用上传本地素材,可直接用于原图、参考素材和选区。", "Media URI fields accept HTTP(S) and local file:// URIs; the CLI uploads local inputs for the call, including source media, references and masks."),
40
41
  text(runtime.product, `结果未收到时用 ${runtime.product.commandName} task list 找到调用,再用 ${runtime.product.commandName} task get <id> 查询,不重复生成。`, `If output is missing, use ${runtime.product.commandName} task list and ${runtime.product.commandName} task get <id> to recover it without generating again.`),
42
+ text(runtime.product, "完整结果为 {content,usage}。content 项为 text、resource_link(uri/name/mimeType)或 resource(resource.uri/mimeType/text);OCR 的 resource.text 是 JSON。分层返回原生模板 JSON 链接,不是 PSD;视频处理需检查实际音轨。", "Complete results are {content,usage}. Content items are text, resource_link (uri/name/mimeType), or resource (resource.uri/mimeType/text); OCR resource.text contains JSON. Layer decomposition returns a native template JSON link, not PSD; verify actual audio after video processing."),
41
43
  text(runtime.product, "查询返回同一份 usage;Tool usage.cost 为当次目录预估价格。", "Queries return the same usage; Tool usage.cost is the catalog price estimate for that invocation."),
42
44
  ""
43
45
  ].join("\n"));
@@ -1,4 +1,7 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  export function contractSchema(operation, direction) {
3
- return JSON.parse(readFileSync(new URL(`../../../contracts/operations/${operation}/${direction}.schema.json`, import.meta.url), "utf8"));
3
+ return contractDocument(`${operation}/${direction}.schema.json`);
4
+ }
5
+ export function contractDocument(path) {
6
+ return JSON.parse(readFileSync(new URL(`../../../contracts/operations/${path}`, import.meta.url), "utf8"));
4
7
  }
@@ -1,3 +1,4 @@
1
+ import { withResponseDiagnostics } from "../../platform/signed-http-transport.js";
1
2
  import { buildCreativeRequest, creativeContextId, creativeTurnMessages, normalizeCreativeMessages, restoreCreativeResourceUrls } from "./creative-protocol.js";
2
3
  import { parseCreativeStream } from "./creative-stream.js";
3
4
  export function createCreativeAgentAdapter(dependencies) {
@@ -10,30 +11,55 @@ export function createCreativeAgentAdapter(dependencies) {
10
11
  localMessageId: dependencies.idFactory()
11
12
  }
12
13
  : { localMessageId: dependencies.idFactory() };
14
+ const correlation = {
15
+ localMessageId: ids.localMessageId,
16
+ ...("localThreadId" in ids ? { localThreadId: ids.localThreadId } : {}),
17
+ ...(message.contextId ? { agentContextId: message.contextId } : {})
18
+ };
19
+ dependencies.telemetry.annotate({ diagnostic_summary: correlation });
13
20
  await observe?.({ localMessageId: ids.localMessageId, ...(message.contextId ? { contextId: message.contextId } : {}) });
14
- const { streamed, contextId } = await dependencies.telemetry.stage("execute", async () => {
21
+ const { streamed, contextId } = await dependencies.telemetry.stage("execute", () => withResponseDiagnostics(async (onResponse) => {
15
22
  await observe?.({ submissionStarted: true });
23
+ const startedAt = Date.now();
24
+ let httpStatus;
16
25
  const stream = await dependencies.transport.postStream({
17
26
  path: "/ai-agent/v1/thread/completion",
18
27
  ...(observe ? { onDispatch: (dispatchedAt) => observe({ dispatchedAt }) } : {}),
19
28
  body: buildCreativeRequest(message, ids),
20
29
  accept: "text/event-stream",
30
+ onResponse: (status, summary) => { httpStatus = status; onResponse(status, summary); },
21
31
  credential: access.credential,
22
32
  organizationId: access.organizationId,
23
33
  signal
24
34
  });
25
35
  await observe?.({ accepted: true });
26
- const streamed = await parseCreativeStream(stream, signal, observe ? async (contextId) => observe({ contextId }) : undefined);
27
- return { streamed, contextId: creativeContextId(streamed) };
28
- });
29
- return dependencies.telemetry.stage("result", async () => {
30
- const messages = await dependencies.transport.getJson({
31
- path: `/ai-agent/v1/thread/${encodeURIComponent(contextId)}/messages`,
32
- credential: access.credential,
33
- organizationId: access.organizationId,
34
- signal
36
+ const streamed = await parseCreativeStream(stream, signal, async (contextId) => {
37
+ correlation.agentContextId = contextId;
38
+ dependencies.telemetry.annotate({ diagnostic_summary: { agentContextId: contextId } });
39
+ await observe?.({ contextId });
40
+ }, {
41
+ startedAt, ...(httpStatus === undefined ? {} : { httpStatus }),
42
+ onDiagnostics: diagnostic_summary => dependencies.telemetry.annotate({ diagnostic_summary })
35
43
  });
36
- const output = normalizeCreativeMessages(restoreCreativeResourceUrls(creativeTurnMessages(messages, ids.localMessageId), streamed));
44
+ const contextId = creativeContextId(streamed);
45
+ dependencies.telemetry.annotate({ diagnostic_summary: { agentContextId: contextId } });
46
+ return { streamed, contextId };
47
+ }, correlation));
48
+ return dependencies.telemetry.stage("result", async () => {
49
+ const output = await withResponseDiagnostics(async (onResponse) => {
50
+ const messages = await dependencies.transport.getJson({
51
+ path: `/ai-agent/v1/thread/${encodeURIComponent(contextId)}/messages`,
52
+ credential: access.credential,
53
+ organizationId: access.organizationId,
54
+ onResponse,
55
+ signal
56
+ });
57
+ let usageModelMissing = false;
58
+ const normalized = normalizeCreativeMessages(restoreCreativeResourceUrls(creativeTurnMessages(messages, ids.localMessageId), streamed), () => { usageModelMissing = true; });
59
+ if (usageModelMissing)
60
+ await observe?.({ agentUsageModelMissing: true });
61
+ return normalized;
62
+ }, correlation);
37
63
  return dependencies.resourceAuthorizer
38
64
  ? dependencies.resourceAuthorizer.authorize(output, access, signal)
39
65
  : output;