@insmind/cli 1.6.0 → 1.7.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.
@@ -97,9 +97,23 @@ export async function executeCli(options) {
97
97
  }
98
98
  const outcome = redact(mapCliError(error, {
99
99
  aborted: isInterruption(error, options.signal),
100
+ operation: options.telemetry.creationContext().operation, failureStage: options.telemetry.failureStage(error),
100
101
  ...(options.product ? { product: options.product } : {})
101
102
  }));
102
- const telemetryError = classifyTelemetryError(error, { aborted: isInterruption(error, options.signal), ...(options.product ? { product: options.product } : {}) });
103
+ // The invocation already carries the task created by this command, even on interruption.
104
+ // Preserve it in the public error as well as progress so hosts can suppress non-JSON diagnostics.
105
+ const { cli_task_id: taskId, operation } = options.telemetry.creationContext();
106
+ if (taskId && outcome.failure && ["agent.send", "tool.call"].includes(operation)) {
107
+ const details = outcome.failure.details;
108
+ outcome.failure.details = { ...details, cli_task_id: taskId, next_steps: [
109
+ ...(details?.next_steps ?? []),
110
+ `${options.product?.commandName ?? "gd-cli"} task get ${taskId}`,
111
+ options.product?.id === "insmind" ? "Keep this task ID; do not automatically resubmit creation."
112
+ : "保留此任务 ID,不要自动重新提交创作。"
113
+ ] };
114
+ }
115
+ const telemetryError = classifyTelemetryError(error, { aborted: isInterruption(error, options.signal),
116
+ operation: options.telemetry.creationContext().operation, failureStage: options.telemetry.failureStage(error), ...(options.product ? { product: options.product } : {}) });
103
117
  const traceId = options.telemetry.selected
104
118
  ? options.telemetry.traceId
105
119
  : undefined;
@@ -97,7 +97,7 @@ export function createProductionRuntime(options = {}) {
97
97
  traceIdFactory: () => randomBytes(16).toString("hex"),
98
98
  spanIdFactory: () => randomBytes(8).toString("hex"),
99
99
  runtime: { os: process.platform, arch: process.arch, nodeMajor: Number.parseInt(process.versions.node, 10) },
100
- classifyError: error => classifyTelemetryError(error, { product }),
100
+ classifyError: error => classifyTelemetryError(error, { product, operation: telemetry.creationContext().operation, failureStage: telemetry.failureStage(error) }),
101
101
  ...(telemetrySink.enqueue ? { onEvent: (event) => telemetrySink.enqueue([event]) } : {})
102
102
  });
103
103
  // Explicit test transport enables SDK tests; test-mode child processes never emit real analytics.
@@ -340,16 +340,15 @@ export function createProductionRuntime(options = {}) {
340
340
  commandName: product.commandName,
341
341
  text,
342
342
  failureNote: error => {
343
- const outcome = mapCliError(error, { aborted: false, product });
344
- const status = error instanceof RemoteRequestError && error.status !== undefined ? ` (HTTP ${error.status})` : "";
345
- return outcome.kind === "failure" ? `${outcome.failure.code}${status}: ${outcome.failure.message}` : "";
343
+ const outcome = mapCliError(error, { aborted: false, product, operation: telemetry.creationContext().operation, failureStage: telemetry.failureStage(error) });
344
+ return outcome.kind === "failure" ? outcome.failure.message : "";
346
345
  },
347
346
  recovery: {
348
347
  authorize: authorizeTaskResult,
349
348
  async agent(progress, state, signal) {
350
349
  if (!progress.contextId || !progress.localMessageId)
351
350
  return {
352
- state: "unknown", note: text("本地记录未取得服务端会话标识;无法确认提交结果,不自动重新生成。", "No service context was recorded. The submission outcome is unknown; do not generate again.")
351
+ state: "unknown", note: text("尚未取得任务结果。", "The task result has not been received.")
353
352
  };
354
353
  await authorizeTaskAccess(state, signal);
355
354
  const snapshot = await readAgentResult(agentTransport, {
@@ -357,14 +356,16 @@ export function createProductionRuntime(options = {}) {
357
356
  credential: state.credential, organizationId: state.organization.id, signal
358
357
  });
359
358
  return { state: "unknown",
360
- note: text(`会话连接为 ${snapshot.connectionState};这不是本次调用的完成凭据。已有内容仅作为消息快照。`, `The context connection is ${snapshot.connectionState}; this does not prove that the run completed. Available content is a message snapshot only.`),
359
+ note: snapshot.partialResult
360
+ ? text("已找到部分内容,尚未取得完整结果。", "Some content was found, but the complete result has not been received.")
361
+ : text("尚未取得任务结果。", "The task result has not been received."),
361
362
  ...(snapshot.partialResult ? { partialResult: await authorizeTaskResult(agentOutputWithBillingUnit(snapshot.partialResult, product.billingUnit), state, signal, true) } : {})
362
363
  };
363
364
  },
364
365
  async tool(progress, state, signal) {
365
366
  if (!progress.remoteTaskId || !progress.toolUsage)
366
367
  return {
367
- state: "unknown", note: text("本地记录未取得可查询的 Tool 回执;不自动重新生成。", "No queryable Tool receipt was recorded; do not generate again.")
368
+ state: "unknown", note: text("尚未取得任务结果。", "The task result has not been received.")
368
369
  };
369
370
  await authorizeTaskAccess(state, signal);
370
371
  const taskId = progress.remoteTaskId;
@@ -372,7 +373,8 @@ export function createProductionRuntime(options = {}) {
372
373
  try {
373
374
  response = await telemetry.stage("task.query", async () => {
374
375
  const result = await queryToolResult(toolTransport, {
375
- taskId, credential: state.credential, organizationId: state.organization.id, signal
376
+ taskId, credential: state.credential, organizationId: state.organization.id, signal,
377
+ onDifyTaskId: id => telemetry.annotate({ dify_task_id: id })
376
378
  });
377
379
  if (result.difyTaskId)
378
380
  telemetry.annotate({ dify_task_id: result.difyTaskId });
@@ -384,10 +386,11 @@ export function createProductionRuntime(options = {}) {
384
386
  catch (error) {
385
387
  if (!(error instanceof ToolTaskFailedError))
386
388
  throw error;
387
- return { state: "failed", note: text(error.message, "The Tool run failed."), failure: error };
389
+ const outcome = mapCliError(error, { aborted: false, product, operation: "task.get", failureStage: "task.query" });
390
+ return { state: "failed", note: outcome.failure?.message ?? text("本次生成未能完成。", "This creation could not be completed."), failure: error };
388
391
  }
389
392
  if (response.state === "pending")
390
- return { state: "running", note: text("原 Tool 查询尚未返回最终结果。", "The original Tool is still processing.") };
393
+ return { state: "running", note: text("任务仍在处理中。", "The task is still processing.") };
391
394
  return { state: "completed", result: await authorizeTaskResult(toolOutputWithBillingUnit({
392
395
  content: response.content, usage: progress.toolUsage
393
396
  }, product.billingUnit), state, signal, true) };
@@ -44,12 +44,12 @@ export async function runTaskWorker(options) {
44
44
  });
45
45
  }
46
46
  catch (error) {
47
- const outcome = redact(mapCliError(error, { aborted: isInterruption(error, signal), product: runtime.product }));
47
+ const outcome = redact(mapCliError(error, { aborted: isInterruption(error, signal), product: runtime.product, operation: job.operation, failureStage: runtime.telemetry.failureStage(error) }));
48
48
  completion = outcome.kind === "interrupted" ? { outcome: "interrupted", error }
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 }), runtime.telemetry.failureStage(error)) });
52
+ diagnostics: taskWorkerDiagnostics(error, classifyTelemetryError(error, { product: runtime.product, operation: job.operation, failureStage: runtime.telemetry.failureStage(error) }), runtime.telemetry.failureStage(error)) });
53
53
  }
54
54
  finally {
55
55
  await runtime.analytics?.shutdown().catch(() => undefined);
@@ -1,3 +1,4 @@
1
+ import { Option } from "commander";
1
2
  import { bindAction } from "./action-binding.js";
2
3
  import { authStatusViewFor } from "./presenter.js";
3
4
  import { productText as text } from "../product/text.js";
@@ -8,12 +9,15 @@ export function registerAuthCommands(program, runtime) {
8
9
  const login = leaf(auth.command("login"))
9
10
  .description(text(runtime.product, "登录稿定", "Sign in to insMind"))
10
11
  .option("--no-browser", text(runtime.product, "不自动打开浏览器", "do not open a browser automatically"))
12
+ .addOption(new Option("--require-browser", text(runtime.product, "必须成功打开浏览器,否则立即失败;不回退到手动链接", "fail if the browser cannot open; do not fall back to a manual link")).conflicts("browser"))
11
13
  .addHelpText("after", text(runtime.product, "\n登录成功必须包含用户 ID;缺少用户 ID 的旧登录态需重新授权。", "\nSuccessful sign-in requires a user ID. Sign in again if an older local login has no user ID."));
12
14
  bindAction(login, "none", async (_context, signal) => {
13
- const noBrowser = login.opts().browser === false;
14
- runtime.telemetry.annotate({ parameters: { noBrowser } });
15
+ const { browser, requireBrowser } = login.opts();
16
+ const noBrowser = browser === false;
17
+ runtime.telemetry.annotate({ parameters: { noBrowser, ...(requireBrowser ? { requireBrowser: true } : {}) } });
15
18
  const result = await runtime.auth.login({
16
19
  noBrowser,
20
+ ...(requireBrowser ? { requireBrowser: true } : {}),
17
21
  signal,
18
22
  interaction: {
19
23
  showAuthorization: (url) => runtime.presenter.authorization({
@@ -1,3 +1,4 @@
1
+ import { observedErrorCategory, observedErrorMessage } from "./observed-errors.js";
1
2
  import { TaskBackgroundError } from "../features/task/task-background.js";
2
3
  import { TaskNotFoundError } from "../features/task/use-cases.js";
3
4
  import { TaskStoreError } from "../features/task/store.js";
@@ -5,7 +6,7 @@ import { CommanderError } from "commander";
5
6
  import { AuthExpiredError, AuthRequiredError } from "../features/auth/access-policy.js";
6
7
  import { AuthStateInvalidError, UserIdentityMissingError } from "../features/auth/state.js";
7
8
  import { SsoRequestError } from "../features/auth/sso-service.js";
8
- import { AuthorizedAccountContextMissingError, DeviceAuthorizationExpiredError } from "../features/auth/use-cases.js";
9
+ import { AuthorizedAccountContextMissingError, BrowserOpenError, DeviceAuthorizationExpiredError } from "../features/auth/use-cases.js";
9
10
  import { AgentInputError } from "../features/agent/use-cases.js";
10
11
  import { ToolInputError } from "../features/tool/catalog.js";
11
12
  import { ToolTaskFailedError } from "../features/tool/tool-api-adapter.js";
@@ -37,17 +38,37 @@ export class CliUsageError extends Error {
37
38
  }
38
39
  }
39
40
  const INSUFFICIENT_CREDITS_REMOTE_CODE = "12020770";
40
- const INSUFFICIENT_CREDITS_NEXT_STEPS = [
41
- "前往 https://www.gaoding.art/pricing 购买稿豆",
42
- "也可以执行 gd-cli org list,再用 gd-cli org switch --org <org-id> 切换到有可用稿豆的组织",
43
- "处理后重新发起本次创作"
44
- ];
45
41
  export function isHelpOutcome(error) {
46
42
  return error instanceof CommanderError
47
43
  && error.exitCode === 0
48
44
  && (error.code === "commander.helpDisplayed" || error.code === "commander.version");
49
45
  }
50
46
  export function mapCliError(error, options) {
47
+ const outcome = mapBaseCliError(error, options);
48
+ if (outcome.kind === "interrupted")
49
+ return { ...outcome, failure: { code: "INTERRUPTED",
50
+ message: options.product?.id === "insmind" ? "This operation stopped waiting." : "本次操作已停止等待。",
51
+ ...(outcome.failure?.details ? { details: outcome.failure.details } : {}) } };
52
+ if (error instanceof TaskBackgroundError)
53
+ return outcome;
54
+ const remote = remoteCause(error);
55
+ const evidence = {
56
+ product: options.product?.id ?? "gaoding", operation: options.operation, failureStage: options.failureStage,
57
+ code: outcome.failure.code, errorType: error instanceof Error ? error.name : undefined,
58
+ remoteCode: remote?.remoteCode,
59
+ httpStatus: remote instanceof RemoteRequestError || remote instanceof SsoRequestError ? remote.status : undefined,
60
+ diagnosticReason: remote instanceof RemoteRequestError || remote instanceof RemoteProtocolError || remote instanceof ToolTaskFailedError
61
+ ? remote.diagnosticReason : undefined
62
+ };
63
+ const category = observedErrorCategory(evidence);
64
+ if (!category)
65
+ return outcome;
66
+ // Keep precise input corrections and their fields; general failures have a short user message.
67
+ if (category === "input" && ["USAGE_ERROR", "INVALID_ACTIONS"].includes(outcome.failure.code))
68
+ return outcome;
69
+ return { ...outcome, failure: { ...outcome.failure, message: observedErrorMessage(category, evidence) } };
70
+ }
71
+ function mapBaseCliError(error, options) {
51
72
  const insmind = options.product?.id === "insmind";
52
73
  const command = options.product?.commandName ?? "gd-cli";
53
74
  const text = (zh, en) => insmind ? en : zh;
@@ -130,12 +151,10 @@ export function mapCliError(error, options) {
130
151
  return failure("USAGE_ERROR", "Invalid command or arguments. See --help.", 2);
131
152
  return failure("USAGE_ERROR", "命令或参数无效,请查看 --help。", 2);
132
153
  }
133
- if (isInsufficientCreditsError(error)) {
134
- if (insmind)
135
- return failure("INSUFFICIENT_CREDITS", "There are not enough insMind credits to complete this creation.", 1, [`Buy credits at ${options.product.pricingUrl.href}`, "Retry after adding credits."]);
136
- return failure("INSUFFICIENT_CREDITS", "当前组织稿豆不足,无法完成本次创作。", 1, INSUFFICIENT_CREDITS_NEXT_STEPS);
154
+ if (options.product?.id !== "insmind" && options.operation === "tool.call" && isInsufficientCreditsError(error)) {
155
+ return failure("INSUFFICIENT_CREDITS", "当前可用额度不足,本次生成未能完成。", 1);
137
156
  }
138
- if (isContentReviewRejection(error)) {
157
+ if (isContentReviewRejection(error, { product: options.product?.id ?? "gaoding", operation: options.operation })) {
139
158
  const phase = error instanceof AgentAuditRejectedError ? error.phase : undefined;
140
159
  const reason = phase === undefined ? "audit_rejected" : `${phase}_audit_rejected`;
141
160
  const message = phase === "input"
@@ -185,6 +204,8 @@ export function mapCliError(error, options) {
185
204
  return failure("DAM_REPOSITORY_NOT_FOUND", "No accessible asset repository is available for this account.", 1, ["Check asset repository access for this account, then run insmind-cli dam repository list."]);
186
205
  return failure("DAM_REPOSITORY_NOT_FOUND", "当前组织没有可用的 DAM 资源库。", 1, ["gd-cli org list", "gd-cli org switch --org <org-id>"]);
187
206
  }
207
+ if (error instanceof BrowserOpenError)
208
+ return failure("INTERNAL_ERROR", text("无法打开授权浏览器,本次登录已停止。请检查系统默认浏览器与启动权限后重新登录。", "The authorization browser could not open. Login stopped; check the default browser and launch permissions before signing in again."), 1, [`${command} auth login --require-browser`], { reason: "browser_open_failed" });
188
209
  if (error instanceof DeviceAuthorizationExpiredError)
189
210
  return failure("REMOTE_REQUEST_FAILED", text("本次登录授权已过期,请重新开始授权。", "This login authorization expired; start authorization again."), 1, [`${command} auth login`], { reason: "authorization_expired" });
190
211
  if (error instanceof RemoteRequestError
@@ -249,14 +270,7 @@ export function classifyTelemetryError(error, options = {}) {
249
270
  ...(diagnostics?.diagnostic_summary ? { diagnosticSummary: diagnostics.diagnostic_summary } : {}),
250
271
  ...(diagnostics?.diagnostic_reason ? { diagnosticReason: diagnostics.diagnostic_reason } : {}) };
251
272
  }
252
- let remoteError;
253
- for (let cause = error, depth = 0; cause instanceof Error && depth < 10; cause = cause.cause, depth++) {
254
- if (cause instanceof RemoteRequestError || cause instanceof RemoteProtocolError || cause instanceof ToolTaskFailedError
255
- || cause instanceof SsoRequestError || cause instanceof OrganizationBindFailedError) {
256
- remoteError = cause;
257
- break;
258
- }
259
- }
273
+ const remoteError = remoteCause(error);
260
274
  let summary;
261
275
  if ((remoteError instanceof RemoteRequestError || remoteError instanceof RemoteProtocolError)
262
276
  && /^(?:RESPONSE_|AGENT_)/u.test(remoteError.diagnosticReason ?? "")) {
@@ -282,7 +296,7 @@ export function classifyTelemetryError(error, options = {}) {
282
296
  ...(remoteError?.remoteBody === undefined
283
297
  ? {}
284
298
  : { remoteErrorBody: remoteError.remoteBody }),
285
- ...((remoteError instanceof RemoteRequestError || remoteError instanceof RemoteProtocolError) && remoteError.diagnosticReason
299
+ ...((remoteError instanceof RemoteRequestError || remoteError instanceof RemoteProtocolError || remoteError instanceof ToolTaskFailedError) && remoteError.diagnosticReason
286
300
  ? { diagnosticReason: remoteError.diagnosticReason } : {})
287
301
  };
288
302
  }
@@ -304,3 +318,11 @@ function systemErrorCode(error) {
304
318
  }
305
319
  return undefined;
306
320
  }
321
+ function remoteCause(error) {
322
+ for (let depth = 0; error instanceof Error && depth < 10; error = error.cause, depth++) {
323
+ if (error instanceof RemoteRequestError || error instanceof RemoteProtocolError || error instanceof ToolTaskFailedError
324
+ || error instanceof SsoRequestError || error instanceof OrganizationBindFailedError)
325
+ return error;
326
+ }
327
+ return undefined;
328
+ }
@@ -0,0 +1,110 @@
1
+ const messages = {
2
+ credits: ["当前可用额度不足,本次生成未能完成。", "There are not enough available credits to complete this creation."],
3
+ review: ["这次内容未通过审核,请调整描述或参考图片。", "This content did not pass content review. Adjust the description or reference image."],
4
+ session_busy: ["这个会话正在使用中,请稍后再试。", "This conversation is in use. Please try again later."],
5
+ service_busy: ["当前服务繁忙,请稍后再试。", "The service is busy. Please try again later."],
6
+ timeout: ["本次操作等待超时。", "This operation timed out."],
7
+ settings: ["当前生成设置暂不可用,请更换生成设置。", "These generation settings are unavailable. Choose different settings."],
8
+ login: ["请先登录后继续。", "Please sign in to continue."],
9
+ account: ["当前登录信息无法使用。", "Your current sign-in information cannot be used."],
10
+ input_asset: ["无法使用这份素材,请检查文件后重新选择。", "This asset cannot be used. Check the file and select it again."],
11
+ input: ["输入或设置不符合要求,请按提示调整。", "The input or settings are invalid. Adjust them as indicated."],
12
+ upload: ["当前账号无法完成此次上传。", "This account cannot complete this upload."],
13
+ task_missing: ["未找到这个任务,请核对任务编号。", "This task was not found. Check the task ID."],
14
+ asset_missing: ["未找到这份素材,请核对素材信息。", "This asset was not found. Check the asset details."],
15
+ file_exists: ["保存位置已有同名文件,请更换名称或位置。", "A file with this name already exists. Choose another name or location."],
16
+ asset_read: ["未能获取这份素材。", "This asset could not be retrieved."],
17
+ editor: ["暂时无法连接编辑器,请打开作品后再试。", "The editor cannot be reached. Open the design and try again."],
18
+ unsupported: ["当前内容暂不支持这项编辑。", "This content does not support this edit."],
19
+ save: ["保存遇到问题,请在编辑器查看作品。", "There was a problem saving. Check the design in the editor."],
20
+ local: ["无法读取或保存本次操作记录。", "The record for this operation could not be read or saved."],
21
+ update: ["本次更新未完成。", "This update did not complete."],
22
+ output: ["结果未能完整显示。", "The result could not be fully displayed."],
23
+ read: ["暂时无法读取结果。", "The result cannot be read right now."],
24
+ tool: ["本次生成未能完成。", "This creation could not be completed."],
25
+ request: ["本次请求未能完成。", "This request could not be completed."],
26
+ client: ["程序运行遇到问题,本次操作未能完成。", "The app encountered a problem and could not complete this operation."]
27
+ };
28
+ const reviewCodes = new Set(["12020751", "12020752", "12020757", "12020758", "12020760", "12020790"]);
29
+ export function observedErrorCategory(e) {
30
+ const gd = e.product === "gaoding", ins = e.product === "insmind";
31
+ const toolOrQuery = e.operation === "tool.call" || e.operation === "task.get";
32
+ if (e.code === "INSUFFICIENT_CREDITS" || gd && e.operation === "tool.call" && e.remoteCode === "12020770")
33
+ return "credits";
34
+ if (e.errorType === "AgentAuditRejectedError" || e.diagnosticReason === "AGENT_INPUT_AUDIT_REJECTED"
35
+ || gd && (toolOrQuery && reviewCodes.has(e.remoteCode ?? "") || e.operation === "agent.send" && e.remoteCode === "-1006")
36
+ || ins && toolOrQuery && e.remoteCode === "12020760")
37
+ return "review";
38
+ if (gd && e.operation === "agent.send" && e.httpStatus === 409)
39
+ return "session_busy";
40
+ if (gd && e.operation === "agent.send" && e.httpStatus === 429)
41
+ return "service_busy";
42
+ if (gd && e.operation === "auth.login" && e.httpStatus === 504 || e.code === "EDITOR_RPC_TIMEOUT"
43
+ || ins && e.operation === "tool.call" && e.remoteCode === "-31994" && e.diagnosticReason === "IMAGE_AUDIT_TIMEOUT")
44
+ return "timeout";
45
+ if (ins && e.operation === "tool.call" && e.remoteCode === "-31993")
46
+ return "settings";
47
+ if (["AUTH_REQUIRED", "LOGIN_REQUIRED"].includes(e.code) || e.errorType === "DeviceAuthorizationExpiredError")
48
+ return "login";
49
+ if (["AUTH_STATE_INVALID", "ORG_INVALID"].includes(e.code))
50
+ return "account";
51
+ if (e.code === "USAGE_ERROR" && e.errorType === "LocalFileInputError")
52
+ return "input_asset";
53
+ if (["USAGE_ERROR", "INVALID_ACTIONS"].includes(e.code) || gd && e.operation === "dam.rename" && e.remoteCode === "00010014")
54
+ return "input";
55
+ if (gd && e.operation === "dam.upload" && e.remoteCode === "36002105")
56
+ return "upload";
57
+ if (e.code === "TASK_NOT_FOUND" || e.operation === "task.get" && e.remoteCode === "12020704")
58
+ return "task_missing";
59
+ if (e.code === "DAM_ASSET_NOT_FOUND")
60
+ return "asset_missing";
61
+ if (e.code === "DAM_DOWNLOAD_DESTINATION_EXISTS")
62
+ return "file_exists";
63
+ if (["DAM_DOWNLOAD_FAILED", "DAM_ASSET_NOT_DOWNLOADABLE"].includes(e.code)
64
+ || gd && ["dam.download", "dam.get", "dam.list", "dam.search"].includes(e.operation ?? "")
65
+ && e.code === "REMOTE_REQUEST_FAILED" && [403, 404].includes(e.httpStatus ?? 0))
66
+ return "asset_read";
67
+ if (["EDITOR_NOT_CONNECTED", "EDITOR_DISCONNECTED", "EDITOR_NOT_READY", "EDITOR_SESSION_NOT_FOUND"].includes(e.code))
68
+ return "editor";
69
+ if (e.code === "UNSUPPORTED_PAGE_CONTENT")
70
+ return "unsupported";
71
+ if (e.code === "SAVE_FAILED")
72
+ return "save";
73
+ if (e.code === "LOCAL_STATE_ERROR")
74
+ return "local";
75
+ if (e.code === "UPDATE_FAILED")
76
+ return "update";
77
+ if (e.code === "INTERNAL_ERROR" && e.failureStage === "output")
78
+ return "output";
79
+ if (gd && (e.operation === "tool.call" && ["12020700", "12020791", "500"].includes(e.remoteCode ?? "")
80
+ || toolOrQuery && e.remoteCode === "12020780" || e.operation === "dam.upload" && e.remoteCode === "500"))
81
+ return "request";
82
+ if (e.code === "REMOTE_PROTOCOL_INCOMPATIBLE"
83
+ || ["AGENT_CONTEXT_ID_MISSING", "AGENT_USAGE_MODEL_MISSING", "RESPONSE_BODY_ALREADY_USED"].includes(e.diagnosticReason ?? ""))
84
+ return "read";
85
+ if (e.code === "TOOL_TASK_FAILED")
86
+ return "tool";
87
+ if (e.code === "REMOTE_REQUEST_FAILED")
88
+ return "request";
89
+ if (e.code === "INTERNAL_ERROR")
90
+ return "client";
91
+ return undefined;
92
+ }
93
+ export function observedErrorMessage(category, e) {
94
+ const text = (zh, en) => e.product === "insmind" ? en : zh;
95
+ if (category === "timeout" && e.diagnosticReason === "IMAGE_AUDIT_TIMEOUT")
96
+ return text("本次图片检查未能及时完成。", "The image check did not finish in time.");
97
+ if (category === "login" && e.errorType === "DeviceAuthorizationExpiredError")
98
+ return text("本次登录已超时,请重新登录。", "This sign-in timed out. Please sign in again.");
99
+ if (category === "account" && e.code === "ORG_INVALID")
100
+ return text("当前团队不可用,请重新选择团队。", "This team is unavailable. Select another team.");
101
+ if (category === "input" && e.operation === "dam.rename" && e.remoteCode === "00010014")
102
+ return text("名称已存在,请换个名称。", "This name already exists. Choose another name.");
103
+ if (category === "asset_read" && e.code === "DAM_DOWNLOAD_FAILED")
104
+ return text("素材下载未完成。", "The asset download did not complete.");
105
+ if (category === "local" && e.errorType === "LocalFileError")
106
+ return text("无法读取或保存所需文件。", "A required file could not be read or saved.");
107
+ if (category === "request" && e.operation === "task.get")
108
+ return text("本次未能读取任务结果。", "The task result could not be retrieved.");
109
+ return text(messages[category][0], messages[category][1]);
110
+ }
@@ -6,6 +6,12 @@ export class DeviceAuthorizationExpiredError extends Error {
6
6
  this.name = "DeviceAuthorizationExpiredError";
7
7
  }
8
8
  }
9
+ export class BrowserOpenError extends Error {
10
+ constructor(cause) {
11
+ super("Could not open the authorization browser.", { cause });
12
+ this.name = "BrowserOpenError";
13
+ }
14
+ }
9
15
  export class AuthorizedAccountContextMissingError extends Error {
10
16
  constructor() {
11
17
  super("The authorized insMind account did not provide its account context.");
@@ -81,7 +87,11 @@ export function createAuthUseCases(dependencies) {
81
87
  try {
82
88
  await dependencies.telemetry.stage("browser", () => input.interaction.openBrowser(authorizationUrl));
83
89
  }
84
- catch {
90
+ catch (cause) {
91
+ if (isInterruption(cause, input.signal))
92
+ throw input.signal.reason;
93
+ if (input.requireBrowser)
94
+ throw new BrowserOpenError(cause);
85
95
  input.interaction.warn(insmind
86
96
  ? "Could not open the browser. Open the authorization URL manually."
87
97
  : "无法自动打开浏览器,请手动访问授权链接。");
@@ -2,14 +2,18 @@ import { AgentAuditRejectedError } from "../agent/creative-protocol.js";
2
2
  import { ToolTaskFailedError } from "../tool/tool-api-adapter.js";
3
3
  import { RemoteRequestError } from "../../platform/signed-http-transport.js";
4
4
  import { RemoteProtocolError } from "../../platform/remote-protocol.js";
5
- // Explicit CRC_SPAM refusals. Review timeouts and unknown request errors do not
6
- // prove that a dispatched creation stopped, even when they use HTTP 400.
7
- const CONTENT_REVIEW_CODES = new Set([
8
- "12020751", "12020752", "12020753", "12020754", "12020755", "12020756",
9
- "12020757", "12020758", "12020759", "12020760", "12020761"
10
- ]);
11
- export function isContentReviewRejection(error) {
12
- return error instanceof AgentAuditRejectedError
13
- || ((error instanceof RemoteRequestError || error instanceof RemoteProtocolError || error instanceof ToolTaskFailedError)
14
- && error.remoteCode !== undefined && CONTENT_REVIEW_CODES.has(error.remoteCode));
5
+ // Scope numeric codes to the product/entry where they have a confirmed meaning.
6
+ const CONTENT_REVIEW_CODES = new Set(["12020751", "12020752", "12020757", "12020758", "12020760", "12020790"]);
7
+ export function isContentReviewRejection(error, context = {}) {
8
+ if (error instanceof AgentAuditRejectedError)
9
+ return true;
10
+ if (!(error instanceof RemoteRequestError || error instanceof RemoteProtocolError || error instanceof ToolTaskFailedError))
11
+ return false;
12
+ if (error.diagnosticReason === "AGENT_INPUT_AUDIT_REJECTED")
13
+ return true;
14
+ const toolOrQuery = context.operation === "tool.call" || context.operation === "task.get";
15
+ if (context.product === "insmind")
16
+ return toolOrQuery && error.remoteCode === "12020760";
17
+ return toolOrQuery && CONTENT_REVIEW_CODES.has(error.remoteCode ?? "")
18
+ || context.operation === "agent.send" && error.remoteCode === "-1006";
15
19
  }
@@ -70,6 +70,8 @@ export function createTaskStore(options) {
70
70
  }
71
71
  if (previous.task.state === "completed" || (previous.task.state === "failed" && record.task.state !== "completed"))
72
72
  record.task = previous.task;
73
+ if (previous.failureCorrection)
74
+ record.failureCorrection = previous.failureCorrection;
73
75
  if (previous.analytics)
74
76
  record.analytics = { ...record.analytics, ...previous.analytics };
75
77
  if (previous.telemetry)
@@ -120,7 +120,7 @@ export function createTaskUseCases(dependencies) {
120
120
  const { result: _result, partialResult: _partial, ...task } = record.task;
121
121
  if (!record.progress.detached && task.state === "running"
122
122
  && dependencies.now().getTime() - Date.parse(task.updatedAt) >= LEASE_MS) {
123
- return { ...task, state: "unknown", note: text("原 CLI 未继续更新记录;使用 task get 查询,不能据此重新生成。", "The original CLI stopped updating this task. Use task get to check; do not submit again.") };
123
+ return { ...task, state: "unknown", note: text("尚未取得任务结果。", "The task result has not been received.") };
124
124
  }
125
125
  return task;
126
126
  }
@@ -258,26 +258,30 @@ export function createTaskUseCases(dependencies) {
258
258
  }
259
259
  catch (error) {
260
260
  clearInterval(timer);
261
+ const diagnostic = telemetry?.taskFailure(error).diagnostic_reason
262
+ ?? (error instanceof RemoteRequestError ? error.diagnosticReason : undefined);
263
+ const observationOnly = diagnostic === "LOCAL_WAIT_INTERRUPTED" || diagnostic === "TASK_QUERY_FAILED";
261
264
  if (record.task.state !== "completed") {
262
265
  const mayBeRunning = dispatched || record.progress.submissionStarted;
263
- const auditRejected = isContentReviewRejection(error);
264
- const creditsRejected = (error instanceof RemoteRequestError || error instanceof RemoteProtocolError)
266
+ const auditRejected = isContentReviewRejection(error, { product: commandName === "insmind-cli" ? "insmind" : "gaoding", operation: input.operation });
267
+ const creditsRejected = commandName !== "insmind-cli" && input.operation === "tool.call"
268
+ && (error instanceof RemoteRequestError || error instanceof RemoteProtocolError)
265
269
  && error.remoteCode === "12020770";
266
270
  const confirmedFailure = error instanceof ToolTaskFailedError || auditRejected || creditsRejected;
267
- record.task.state = confirmedFailure || !mayBeRunning ? "failed" : "unknown";
268
- record.task.note = auditRejected
269
- ? text("内容未通过审核,本次创作已拒绝;具体错误见原命令。", "Content review rejected this creation. See the original command for the error.")
271
+ record.task.state = observationOnly ? "unknown" : confirmedFailure || !mayBeRunning ? "failed" : "unknown";
272
+ record.task.note = diagnostic === "LOCAL_WAIT_INTERRUPTED"
273
+ ? text("本次操作已停止等待。", "This operation stopped waiting.")
270
274
  : confirmedFailure
271
- ? text("服务已明确拒绝本次创作或返回任务失败;具体错误见原命令。", "The service explicitly rejected this creation or reported task failure. See the original command for the error.")
275
+ ? text("本次生成未能完成。", "This creation could not be completed.")
272
276
  : mayBeRunning
273
- ? text("CLI 未取得完整回执或结果;远端可能仍在执行。查询原任务,不自动重新生成。", "The CLI did not receive a complete receipt or result; the service may still be running. Query this task instead of submitting again.")
274
- : text("CLI 在提交创作前结束;具体错误见原命令。", "The CLI stopped before submitting the creation. See the original command for the error.");
277
+ ? text("尚未取得任务结果。", "The task result has not been received.")
278
+ : text("本次生成尚未开始。", "This creation has not started.");
275
279
  }
276
280
  const detail = dependencies.failureNote?.(error);
277
- if (detail)
278
- record.task.note = [record.task.note, redactSensitiveText(detail)].filter(Boolean).join(" ");
281
+ if (detail && diagnostic !== "LOCAL_WAIT_INTERRUPTED")
282
+ record.task.note = redactSensitiveText(detail);
279
283
  telemetry?.annotate({ result_state: record.task.state });
280
- if (dispatched && record.task.state !== "completed")
284
+ if (dispatched && !observationOnly && record.task.state !== "completed")
281
285
  await fact(scope, record, "failed", dependencies.now().getTime(), error);
282
286
  await stage("task.persist", save).catch(() => undefined);
283
287
  throw error;
@@ -308,9 +312,19 @@ export function createTaskUseCases(dependencies) {
308
312
  signal.throwIfAborted();
309
313
  const scope = taskScope(state);
310
314
  telemetry?.annotate({ cli_task_id: id });
311
- const record = await stage("task.read", () => dependencies.store.read(scope, id));
315
+ let record = await stage("task.read", () => dependencies.store.read(scope, id));
312
316
  if (!record)
313
317
  throw new TaskNotFoundError(text(`当前身份中没有该任务。请执行 ${commandName} task list 查找。`, `No task was found in the current identity context. Use ${commandName} task list to find it.`));
318
+ if (recoverableFalseFailure(record)) {
319
+ record = await stage("task.repair", () => dependencies.store.update(scope, id, stored => {
320
+ const reason = recoverableFalseFailure(stored);
321
+ if (!reason)
322
+ return;
323
+ stored.failureCorrection = { reason, correctedAt: dependencies.now().toISOString(),
324
+ previousRevision: stored.telemetry?.states?.at(-1)?.task_revision };
325
+ stored.task = { ...stored.task, state: "unknown", note: text("尚未取得任务结果。", "The task result has not been received.") };
326
+ }));
327
+ }
314
328
  telemetry?.annotate({ cli_task_id: id, result_state: record.task.state });
315
329
  if (record.task.state === "completed" && record.task.result) {
316
330
  const result = { ...record.task, result: await stage("task.authorize", () => dependencies.recovery.authorize(record.task.result, state, signal)) };
@@ -324,7 +338,7 @@ export function createTaskUseCases(dependencies) {
324
338
  const { note: _note, ...metadata } = task;
325
339
  const result = { ...metadata, ...recovered };
326
340
  if (result.state === "unknown" && task.note) {
327
- result.note = [task.note, recovered.note].filter(Boolean).join(" ");
341
+ result.note = [...new Set([task.note, recovered.note].filter(Boolean))].join(" ");
328
342
  }
329
343
  if (result.state === "completed" && result.result) {
330
344
  await stage("task.validate", async () => { dependencies.validateResult?.(result.result); });
@@ -359,3 +373,16 @@ export function createTaskUseCases(dependencies) {
359
373
  }
360
374
  };
361
375
  }
376
+ function recoverableFalseFailure(record) {
377
+ if (record.task.state !== "failed" || record.task.result)
378
+ return;
379
+ const terminal = record.telemetry?.states?.findLast(event => ["failed", "success", "completed"].includes(event.result_state));
380
+ if (terminal?.result_state !== "failed")
381
+ return;
382
+ if (terminal.diagnostic_reason === "LOCAL_WAIT_INTERRUPTED")
383
+ return "LOCAL_WAIT_INTERRUPTED";
384
+ if (record.task.operation === "tool.call" && (terminal.diagnostic_reason === "TASK_QUERY_FAILED"
385
+ || terminal.failure_stage === "task.query" && terminal.remote_error_code === "12020704"))
386
+ return "TASK_QUERY_FAILED";
387
+ return undefined;
388
+ }
@@ -129,45 +129,45 @@ function normalizeContent(value) {
129
129
  export class ToolTaskFailedError extends Error {
130
130
  remoteCode;
131
131
  remoteBody;
132
+ diagnosticReason;
132
133
  constructor(evidence = {}) {
133
134
  super("稿定工具任务执行失败。");
134
135
  this.name = "ToolTaskFailedError";
135
136
  this.remoteCode = evidence.remoteCode;
136
137
  this.remoteBody = evidence.remoteBody;
138
+ this.diagnosticReason = evidence.diagnosticReason;
137
139
  }
138
140
  }
139
141
  export async function queryToolResult(transport, request) {
140
- return pollResult(await safePost(transport, {
141
- credential: request.credential,
142
- ...(request.organizationId === undefined ? {} : { organizationId: request.organizationId }),
143
- signal: request.signal,
144
- path: "/gdesign/tool/v1/dify/process/batch",
145
- body: { task_ids: [request.taskId] }
146
- }), request.taskId);
142
+ try {
143
+ return pollResult(await safePost(transport, {
144
+ credential: request.credential,
145
+ ...(request.organizationId === undefined ? {} : { organizationId: request.organizationId }),
146
+ signal: request.signal,
147
+ path: "/gdesign/tool/v1/dify/process/batch",
148
+ body: { task_ids: [request.taskId] }
149
+ }), request.taskId, request.onDifyTaskId);
150
+ }
151
+ catch (error) {
152
+ if (isInterruption(error, request.signal))
153
+ throw error;
154
+ const evidence = error instanceof RemoteRequestError || error instanceof RemoteProtocolError
155
+ ? { ...(error.remoteCode === undefined ? {} : { remoteCode: error.remoteCode }),
156
+ ...(error.remoteBody === undefined ? {} : { remoteBody: error.remoteBody }) } : {};
157
+ if (error instanceof RemoteProtocolError)
158
+ throw new RemoteProtocolError(evidence, error, "TASK_QUERY_FAILED");
159
+ throw new RemoteRequestError(error instanceof RemoteRequestError ? error.status : undefined, error instanceof RemoteRequestError && error.transient, evidence, error, "TASK_QUERY_FAILED");
160
+ }
147
161
  }
148
162
  function failedPoll(error, difyTaskId) {
163
+ if (error instanceof RemoteProtocolError)
164
+ throw error;
149
165
  return {
150
166
  state: "failed",
151
167
  error,
152
168
  ...(difyTaskId === undefined ? {} : { difyTaskId })
153
169
  };
154
170
  }
155
- function optionalInnerDifyTaskId(value) {
156
- if (typeof value !== "string" || value.trim() === "")
157
- return undefined;
158
- try {
159
- const parsed = JSON.parse(value);
160
- if (!isRecord(parsed))
161
- return undefined;
162
- const difyTaskId = parsed.dify_task_id;
163
- return typeof difyTaskId === "string" && difyTaskId.trim() !== ""
164
- ? difyTaskId
165
- : undefined;
166
- }
167
- catch {
168
- return undefined;
169
- }
170
- }
171
171
  function isJsonRpcError(value) {
172
172
  if (value.jsonrpc !== "2.0"
173
173
  || Object.prototype.hasOwnProperty.call(value, "result")
@@ -185,7 +185,7 @@ function isJsonRpcError(value) {
185
185
  && typeof value.error.message === "string"
186
186
  && value.error.message.trim() !== "";
187
187
  }
188
- function pollResult(value, taskId) {
188
+ function pollResult(value, taskId, onDifyTaskId) {
189
189
  if (!Array.isArray(value))
190
190
  return protocolFailure(value);
191
191
  const item = value.find((candidate) => isRecord(candidate) && candidate.task_id === taskId);
@@ -195,7 +195,8 @@ function pollResult(value, taskId) {
195
195
  return protocolFailure(item);
196
196
  }
197
197
  if (item.code !== "200") {
198
- return failedPoll(new ToolTaskFailedError(remoteErrorEvidence(item)), optionalInnerDifyTaskId(item.result));
198
+ // This envelope describes the query request, not the original generation.
199
+ throw new RemoteRequestError(undefined, false, remoteErrorEvidence(item), undefined, "TASK_QUERY_FAILED");
199
200
  }
200
201
  if (typeof item.result !== "string" || item.result.trim() === "") {
201
202
  return protocolFailure(item);
@@ -217,6 +218,8 @@ function pollResult(value, taskId) {
217
218
  && (typeof difyTaskId !== "string" || difyTaskId.trim() === "")) {
218
219
  return protocolFailure(inner);
219
220
  }
221
+ if (typeof difyTaskId === "string")
222
+ onDifyTaskId?.(difyTaskId);
220
223
  if (Object.prototype.hasOwnProperty.call(inner, "error")) {
221
224
  return isJsonRpcError(inner)
222
225
  ? failedPoll(new ToolTaskFailedError(remoteErrorEvidence(inner)), difyTaskId)
@@ -339,14 +342,11 @@ export function createToolApiAdapter(dependencies) {
339
342
  let transientFailures = 0;
340
343
  while (true) {
341
344
  signal.throwIfAborted();
342
- let response;
345
+ let poll;
343
346
  try {
344
- response = await safePost(dependencies.transport, {
345
- path: "/gdesign/tool/v1/dify/process/batch",
346
- body: { task_ids: [taskId] },
347
- credential: access.credential,
348
- organizationId: access.organizationId,
349
- signal
347
+ poll = await queryToolResult(dependencies.transport, {
348
+ taskId, credential: access.credential, organizationId: access.organizationId, signal,
349
+ onDifyTaskId: id => dependencies.telemetry.annotate({ dify_task_id: id })
350
350
  });
351
351
  transientFailures = 0;
352
352
  }
@@ -361,7 +361,6 @@ export function createToolApiAdapter(dependencies) {
361
361
  await sleep(transientFailures * 1_000, signal);
362
362
  continue;
363
363
  }
364
- const poll = pollResult(response, taskId);
365
364
  if (poll.difyTaskId !== undefined) {
366
365
  dependencies.telemetry.annotate({ dify_task_id: poll.difyTaskId });
367
366
  }
@@ -4,6 +4,7 @@ const truncationMarker = "[TRUNCATED]";
4
4
  export function remoteErrorEvidence(value) {
5
5
  const normalized = parseJson(value);
6
6
  const remoteCode = topLevelCode(normalized) ?? jsonRpcErrorCode(normalized);
7
+ const diagnosticReason = imageAuditTimeout(normalized, remoteCode);
7
8
  const sanitized = sanitize(normalized);
8
9
  if (sanitized === undefined) {
9
10
  return remoteCode === undefined ? {} : { remoteCode };
@@ -13,7 +14,8 @@ export function remoteErrorEvidence(value) {
13
14
  : `${sanitized.slice(0, maximumLength - truncationMarker.length)}${truncationMarker}`;
14
15
  return {
15
16
  ...(remoteCode === undefined ? {} : { remoteCode }),
16
- remoteBody
17
+ remoteBody,
18
+ ...(diagnosticReason ? { diagnosticReason } : {})
17
19
  };
18
20
  }
19
21
  function parseJson(value) {
@@ -78,3 +80,13 @@ function redactCookieAssignments(value) {
78
80
  function redactCookieAssignment(value) {
79
81
  return value.replace(/\b(cookie)\s*=\s*[^\s,;}&]+/giu, "$1=[REDACTED]");
80
82
  }
83
+ function imageAuditTimeout(value, remoteCode) {
84
+ if (remoteCode !== "-31994" || value === null || typeof value !== "object" || Array.isArray(value))
85
+ return;
86
+ const record = value;
87
+ const error = record.jsonrpc === "2.0" && !Object.hasOwn(record, "result") ? record.error : record;
88
+ if (error && typeof error === "object" && !Array.isArray(error)
89
+ && String(error.code) === "-31994"
90
+ && error.message === "图片审核处理超时,请稍后重试")
91
+ return "IMAGE_AUDIT_TIMEOUT";
92
+ }
@@ -7,6 +7,6 @@ export class RemoteProtocolError extends Error {
7
7
  this.name = "RemoteProtocolError";
8
8
  this.remoteCode = evidence.remoteCode;
9
9
  this.remoteBody = evidence.remoteBody;
10
- this.diagnosticReason = diagnosticReason;
10
+ this.diagnosticReason = diagnosticReason ?? evidence.diagnosticReason;
11
11
  }
12
12
  }
@@ -15,7 +15,7 @@ export class RemoteRequestError extends Error {
15
15
  this.transient = transient;
16
16
  this.remoteCode = evidence.remoteCode;
17
17
  this.remoteBody = evidence.remoteBody;
18
- this.diagnosticReason = diagnosticReason;
18
+ this.diagnosticReason = diagnosticReason ?? evidence.diagnosticReason;
19
19
  }
20
20
  }
21
21
  const TRANSIENT_NETWORK_CODES = new Set([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insmind/cli",
3
- "version": "1.6.0",
3
+ "version": "1.7.1",
4
4
  "description": "insMind command-line interface for agents and people.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -46,8 +46,8 @@
46
46
  "@gaoding/cli": "workspace:*"
47
47
  },
48
48
  "gaodingRelease": {
49
- "sourceCommit": "f696623bd177753f9bbdee5a8cc648e2a2b46f38",
50
- "pipelineId": "224261",
51
- "pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/224261"
49
+ "sourceCommit": "53aa55169df83ca3437874f7d002c741b694be76",
50
+ "pipelineId": "229607",
51
+ "pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/229607"
52
52
  }
53
53
  }
@@ -6,11 +6,11 @@
6
6
  - Exit `1`: runtime, service or state failure. Follow explicit `error.details.next_steps`; if none are provided, stop and report.
7
7
  - Exit `2`: command or argument error. Read the command's `--help` and correct the invocation.
8
8
  - Exit `130`: user interruption. Stop immediately; do not retry automatically.
9
- - `INSUFFICIENT_CREDITS`: follow `error.details.next_steps`, direct the user to https://www.insmind.com/pricing, and submit again only after credits are available. Use `insmind-cli credits` to inspect the balance.
9
+ - `INSUFFICIENT_CREDITS` only means available credits were insufficient for this operation. It does not distinguish account balance, member limits or other charging restrictions. Do not automatically recommend a purchase or treat a balance check or price quote as a guarantee that charging will succeed.
10
10
 
11
11
  ## Missing creation output
12
12
 
13
- If an Agent or Tool request may already have been submitted, empty output, long execution or a host's completed-script message does not justify another creation. The original command prints a Task ID to stderr. Continue waiting if its execution session remains available; otherwise query the original task:
13
+ If an Agent or Tool request may already have been submitted, empty output, long execution or a host's completed-script message does not justify another creation. The original command prints a Task ID to stderr; a known ID is also retained in the final error recovery details. Continue waiting if its execution session remains available; otherwise query the original task:
14
14
 
15
15
  ```bash
16
16
  insmind-cli task list
@@ -24,6 +24,8 @@ Use a known ID directly. Otherwise locate the task by time, operation and input
24
24
  - `unknown`: completion is unconfirmed. Recheck the same ID; explain if it remains unknown. `partialResult` is a message snapshot, not a complete deliverable.
25
25
  - `failed`: report `note` and the original error; do not resubmit automatically.
26
26
 
27
+ A query error, including a task-not-found response, does not mean the original creation failed. Keep the original task ID; do not generate again.
28
+
27
29
  Exit `0` from `task get` means the query succeeded; `state` determines whether the creation completed. Repeated reads of one ID return the same usage, which must not be added again. Do not resume waiting or resubmit after a user interruption.
28
30
 
29
31
  Do not infer internal causes from unknown errors or disclose local credentials, request signatures or sensitive URL query values. If safe recovery steps are absent, preserve the public error code from stderr and explain the failure.