@insmind/cli 2.1.0 → 2.1.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 -77
  2. package/contracts/operations/dam.folder.list/input.schema.json +0 -1
  3. package/contracts/operations/dam.folder.list/output.schema.json +1 -2
  4. package/contracts/operations/dam.list/input.schema.json +3 -6
  5. package/contracts/operations/dam.list/output.schema.json +1 -2
  6. package/contracts/operations/dam.search/input.schema.json +3 -6
  7. package/contracts/operations/dam.search/output.schema.json +1 -2
  8. package/contracts/operations/tool.call/models/image-edit-smart.schema.json +1 -2
  9. package/contracts/operations/tool.call/models/image-expand-smart.schema.json +1 -2
  10. package/contracts/operations/tool.call/models/image-layers-smart.schema.json +1 -3
  11. package/contracts/operations/tool.call/models/video-edit-smart.schema.json +0 -3
  12. package/contracts/operations/tool.call/ocr-payload.schema.json +4 -5
  13. package/dist/bin/postinstall.js +22 -6
  14. package/dist/bin/task-worker.js +2 -2
  15. package/dist/src/bootstrap/create-cli.js +13 -6
  16. package/dist/src/bootstrap/create-runtime.js +98 -28
  17. package/dist/src/bootstrap/run-task-worker.js +6 -2
  18. package/dist/src/bootstrap/validators.js +1 -1
  19. package/dist/src/cli/action-binding.js +14 -37
  20. package/dist/src/cli/agent-commands.js +11 -11
  21. package/dist/src/cli/auth-commands.js +2 -1
  22. package/dist/src/cli/creation-help.js +9 -0
  23. package/dist/src/cli/dam-commands.js +10 -14
  24. package/dist/src/cli/editor-commands.js +7 -5
  25. package/dist/src/cli/errors.js +81 -22
  26. package/dist/src/cli/host-input.js +64 -5
  27. package/dist/src/cli/model-commands.js +9 -3
  28. package/dist/src/cli/observed-errors.js +7 -3
  29. package/dist/src/cli/org-commands.js +3 -1
  30. package/dist/src/cli/task-commands.js +6 -2
  31. package/dist/src/cli/tool-commands.js +12 -11
  32. package/dist/src/features/agent/creative-agent-adapter.js +6 -2
  33. package/dist/src/features/agent/creative-protocol.js +8 -29
  34. package/dist/src/features/agent/resource-authorizer.js +25 -17
  35. package/dist/src/features/agent/result-reader.js +31 -14
  36. package/dist/src/features/agent/use-cases.js +6 -31
  37. package/dist/src/features/credits/use-cases.js +55 -28
  38. package/dist/src/features/dam/asset-projection.js +3 -6
  39. package/dist/src/features/dam/dam-api-adapter.js +30 -15
  40. package/dist/src/features/dam/repository-catalog.js +30 -21
  41. package/dist/src/features/dam/use-cases.js +12 -7
  42. package/dist/src/features/editor/bridge-client.js +0 -2
  43. package/dist/src/features/editor/public-url.js +1 -36
  44. package/dist/src/features/editor/session.js +3 -2
  45. package/dist/src/features/editor/use-cases.js +27 -2
  46. package/dist/src/features/org/org-service.js +10 -1
  47. package/dist/src/features/org/use-cases.js +18 -4
  48. package/dist/src/features/task/process-owner.js +54 -0
  49. package/dist/src/features/task/store.js +37 -10
  50. package/dist/src/features/task/task-background.js +5 -2
  51. package/dist/src/features/task/use-cases.js +184 -84
  52. package/dist/src/features/tool/argument-paths.js +14 -0
  53. package/dist/src/features/tool/canvas-copy.js +28 -15
  54. package/dist/src/features/tool/canvas-matting.js +123 -0
  55. package/dist/src/features/tool/canvas-media.js +100 -52
  56. package/dist/src/features/tool/canvas-models.js +66 -33
  57. package/dist/src/features/tool/canvas-pricing.js +12 -0
  58. package/dist/src/features/tool/canvas-recovery.js +13 -30
  59. package/dist/src/features/tool/canvas-results.js +79 -87
  60. package/dist/src/features/tool/canvas-tool-adapter.js +134 -157
  61. package/dist/src/features/tool/canvas-video.js +44 -37
  62. package/dist/src/features/tool/dynamic-schema.js +39 -40
  63. package/dist/src/features/tool/ffprobe-executable.js +21 -0
  64. package/dist/src/features/tool/mns-catalog-adapter.js +61 -24
  65. package/dist/src/features/tool/resource-authorizer.js +11 -3
  66. package/dist/src/features/tool/tool-api-adapter.js +73 -82
  67. package/dist/src/features/tool/tool-errors.js +25 -0
  68. package/dist/src/features/tool/tool-output.js +15 -0
  69. package/dist/src/features/tool/use-cases.js +74 -98
  70. package/dist/src/features/update/update-service.js +95 -21
  71. package/dist/src/platform/media-type.js +46 -0
  72. package/dist/src/platform/public-url.js +35 -0
  73. package/dist/src/platform/remote-error-evidence.js +33 -6
  74. package/dist/src/platform/resource-auth-key.js +35 -1
  75. package/dist/src/platform/safe-upload-file.js +36 -41
  76. package/dist/src/platform/signature.js +2 -2
  77. package/dist/src/platform/signed-http-transport.js +4 -1
  78. package/dist/src/platform/url-safety.js +6 -1
  79. package/dist/src/platform/webm-header.js +41 -0
  80. package/dist/src/telemetry/command-route.js +38 -0
  81. package/dist/src/telemetry/command-routes.json +1 -0
  82. package/dist/src/telemetry/failure-summary.js +1 -1
  83. package/dist/src/telemetry/invocation.js +1 -2
  84. package/dist/src/telemetry/process-errors.js +17 -33
  85. package/dist/src/telemetry/sanitize.js +19 -4
  86. package/dist/src/telemetry/sls-sink.js +8 -0
  87. package/package.json +4 -4
  88. package/skills/insmind-cli/SKILL.md +18 -5
  89. package/skills/insmind-cli/references/agent.md +9 -4
  90. package/skills/insmind-cli/references/creation.md +3 -1
  91. package/skills/insmind-cli/references/editor.md +7 -5
  92. package/skills/insmind-cli/references/errors.md +20 -9
  93. package/skills/insmind-cli/references/matting.md +3 -5
  94. package/skills/insmind-cli/references/media-tools.md +10 -4
  95. package/skills/insmind-cli/references/tool.md +9 -15
@@ -1,3 +1,4 @@
1
+ import { canvasModelBindings } from "../features/tool/canvas-models.js";
1
2
  import { createWindAnalytics } from "../analytics/wind.js";
2
3
  import { taskScope } from "../features/task/store.js";
3
4
  import { noticeWriter, sameTerminal } from "../features/update/notice-output.js";
@@ -6,8 +7,10 @@ import { TaskNotFoundError } from "../features/task/use-cases.js";
6
7
  import { homedir } from "node:os";
7
8
  import { createTaskBackgroundLauncher, TaskBackgroundError } from "../features/task/task-background.js";
8
9
  import { createTaskStore } from "../features/task/store.js";
9
- import { createTaskUseCases } from "../features/task/use-cases.js";
10
+ import { createTaskUseCases, taskStartedNotice } from "../features/task/use-cases.js";
10
11
  import { readAgentResult } from "../features/agent/result-reader.js";
12
+ import { createToolOutputVerifier, presentToolContent } from "../features/tool/tool-output.js";
13
+ import { RemoteProtocolError } from "../platform/remote-protocol.js";
11
14
  import { queryToolResult, ToolTaskFailedError, ToolTaskCanceledError } from "../features/tool/tool-api-adapter.js";
12
15
  import { randomBytes, randomUUID } from "node:crypto";
13
16
  import { dirname, join } from "node:path";
@@ -189,7 +192,7 @@ export function createProductionRuntime(options = {}) {
189
192
  });
190
193
  const org = createOrgUseCases({
191
194
  store,
192
- org: createOrgService({ transport: orgTransport }),
195
+ org: createOrgService({ transport: orgTransport, onPartial: count => partialWarning("ORG_LIST_PARTIAL", `有 ${count} 条组织记录无法读取,已返回可确认的组织。`, `${count} organization record(s) could not be read.`) }),
193
196
  sso,
194
197
  telemetry,
195
198
  ...(product.exposesOrganizations
@@ -214,6 +217,7 @@ export function createProductionRuntime(options = {}) {
214
217
  });
215
218
  const credits = createCreditsUseCases({
216
219
  transport: creditsTransport,
220
+ onPartial: () => partialWarning("CREDITS_RECORDS_PARTIAL", "部分账单记录或可选字段无法表示,已返回可确认的流水;不要据此推算完整账单。", "Some billing records or optional fields could not be represented. Known records are included; do not infer a complete bill."),
217
221
  billingUnit: product.billingUnit,
218
222
  now
219
223
  });
@@ -227,6 +231,10 @@ export function createProductionRuntime(options = {}) {
227
231
  writeError: io.writeError,
228
232
  product
229
233
  });
234
+ function partialWarning(code, zh, en) {
235
+ telemetry.annotate({ warning_codes: [code] });
236
+ presenter.warning(text(zh, en));
237
+ }
230
238
  const browser = createBrowserOpener();
231
239
  const validators = createContractValidators({
232
240
  organizations: product.exposesOrganizations
@@ -238,8 +246,15 @@ export function createProductionRuntime(options = {}) {
238
246
  ? { invalidModelWarning: (count) => `Ignored ${count} invalid model configuration${count === 1 ? "" : "s"}.` }
239
247
  : {})
240
248
  }) });
241
- const damApi = createDamApiAdapter({ transport: damTransport });
242
- const damRepositories = createDamRepositoryCatalog({ transport: damTransport });
249
+ const damApi = createDamApiAdapter({
250
+ transport: damTransport,
251
+ onPartial: count => partialWarning("DAM_LIST_PARTIAL", `有 ${count} 条素材库记录无法表示,已返回其余记录。`, `${count} unreadable record(s); the other records are included.`),
252
+ onPaginationFallback: () => partialWarning("DAM_PAGINATION_INCOMPLETE", "服务未提供完整分页信息;缺失的总数或结束标记按本页结果推导。", "The service omitted pagination information; a missing total or end marker was inferred from this page.")
253
+ });
254
+ const damRepositories = createDamRepositoryCatalog({ transport: damTransport, onPartial: source => {
255
+ const label = source === "team" ? "团队" : source === "personal" ? "个人" : "企业";
256
+ partialWarning("DAM_REPOSITORIES_PARTIAL", `${label}库来源或其中部分记录无法读取,已列出可确认的资源库。`, `The ${source} repository source was unavailable or incomplete. Known repositories are included.`);
257
+ } });
243
258
  const damOperations = createDamOperationExecutor({
244
259
  now: () => now().getTime(),
245
260
  sleep: async (milliseconds, signal) => {
@@ -292,7 +307,14 @@ export function createProductionRuntime(options = {}) {
292
307
  traceparent: () => telemetry.traceparent(),
293
308
  ...(businessHeaders ? { businessHeaders } : {})
294
309
  }) });
295
- const resourceAuthorizer = createAgentResourceAuthorizer({ authKeys: resourceAuthKeys });
310
+ const onPartialResourceFailure = (error) => {
311
+ if (!(error instanceof RemoteRequestError || error instanceof RemoteProtocolError)
312
+ || !["RESOURCE_AUTH_REQUEST_FAILED", "RESOURCE_AUTH_INVALID_RESPONSE"].includes(error.diagnosticReason ?? ""))
313
+ return false;
314
+ partialWarning("RESOURCE_AUTH_PARTIAL", "部分私有资源链接尚未取得访问授权;已保留原链接及其他可用内容,请使用原任务再次取件,不要重做。", "Some private links could not be authorized. The original links and other content are included. Query the same task; do not resubmit.");
315
+ return true;
316
+ };
317
+ const resourceAuthorizer = createAgentResourceAuthorizer({ authKeys: resourceAuthKeys, onPartialResourceFailure });
296
318
  const accessPolicies = createAccessPolicies({ store, now, refreshCurrentOrganization: org.refreshCurrentOrganization });
297
319
  const authorizeTaskAccess = async (state, signal) => {
298
320
  await telemetry.stage("access", async () => {
@@ -304,24 +326,59 @@ export function createProductionRuntime(options = {}) {
304
326
  }
305
327
  });
306
328
  };
307
- const authorizeTaskResult = async (result, state, signal, alreadyAuthorized = false) => {
329
+ const authorizeTaskResult = async (result, state, signal, source = "stored") => {
308
330
  if ("message" in result)
309
331
  validators.agentSendOutput(result);
310
332
  else
311
333
  validators.toolCallOutput(result);
312
334
  // Bind only if this result actually needs a fresh resource token.
313
- const taskAuthorizer = createAgentResourceAuthorizer({ authKeys: {
335
+ const taskAuthorizer = createAgentResourceAuthorizer({
336
+ onPartialResourceFailure,
337
+ // Re-reading an existing result can repair an expired official link without probing anyone's URLs.
338
+ ...(source !== "upstream" ? { onSignedRefreshFailure(error) {
339
+ if (!(error instanceof RemoteRequestError || error instanceof RemoteProtocolError)
340
+ || !["RESOURCE_AUTH_REQUEST_FAILED", "RESOURCE_AUTH_INVALID_RESPONSE"].includes(error.diagnosticReason ?? ""))
341
+ return false;
342
+ telemetry.annotate({ warning_codes: ["TASK_RESOURCE_REFRESH_UNAVAILABLE"] });
343
+ presenter.warning(text("资源授权暂未更新,已返回原签名链接;如仍无法打开,请稍后用原任务 ID 查询。", "The resource key could not be refreshed. The original signed URL is included; if it cannot be opened, query the same task ID later."));
344
+ return true;
345
+ } } : {}),
346
+ authKeys: {
314
347
  async getAuthKey(access, tokenSignal) {
315
- if (!alreadyAuthorized)
348
+ if (source === "stored")
316
349
  await authorizeTaskAccess(state, tokenSignal);
317
350
  return resourceAuthKeys.getAuthKey(access, tokenSignal);
318
351
  }
319
- } });
352
+ }
353
+ });
320
354
  const access = { credential: state.credential, organizationId: state.organization.id };
321
355
  if ("message" in result)
322
356
  return taskAuthorizer.authorize(result, access, signal);
323
357
  return authorizeToolResources(result, taskAuthorizer, access, signal);
324
358
  };
359
+ const canvasMedia = (access) => createCanvasMedia({ fetch, uploader: transientUploader,
360
+ ...(access ? { filems: { access, authKeys: resourceAuthKeys } } : {}) });
361
+ const onMissingMedia = (kind) => {
362
+ telemetry.annotate({ warning_codes: ["TOOL_EXPECTED_MEDIA_UNIDENTIFIED"] });
363
+ presenter.warning(text(`已交付服务返回的内容,未发现明确标记为${kind === "video" ? "视频" : "图片"}的资源;请按实际内容交付,勿重新提交。`, `The returned content is included. No resource was identified as ${kind}; report what was received and do not resubmit.`));
364
+ };
365
+ const onUnrepresented = () => {
366
+ telemetry.annotate({ warning_codes: ["TOOL_PART_UNREPRESENTABLE"] });
367
+ presenter.warning(text("已返回可表示的内容,另有无法读取的附件。", "The representable content is included; another attachment could not be read."));
368
+ };
369
+ const verifyToolOutput = createToolOutputVerifier(resourceAuthorizer, onMissingMedia);
370
+ const canvasTools = createCanvasToolAdapter({
371
+ transport: toolTransport, recordTransport: damTransport, resourceAuthorizer, telemetry, media: canvasMedia, onMissingMedia, onUnrepresented, english: product.id === "insmind",
372
+ fallback: createToolApiAdapter({ transport: toolTransport, telemetry, onUnrepresented, verifyOutput: verifyToolOutput }),
373
+ standardMatting: createStandardMatting({ transport: toolTransport, recordTransport: damTransport, media: canvasMedia() })
374
+ });
375
+ const taskFailureNote = (error, operation = telemetry.creationContext().operation) => {
376
+ const outcome = mapCliError(error, { aborted: false, product, operation, failureStage: telemetry.failureStage(error) });
377
+ if (outcome.kind !== "failure")
378
+ return "";
379
+ const details = outcome.failure.details;
380
+ return [outcome.failure.message, details?.remote_code, details?.remote_message].filter(Boolean).join(" ");
381
+ };
325
382
  const tasks = createTaskUseCases({
326
383
  telemetry,
327
384
  ...(analytics ? { analytics } : {}),
@@ -335,6 +392,7 @@ export function createProductionRuntime(options = {}) {
335
392
  store: createTaskStore({
336
393
  ...(options.homeDirectory ? { homeDirectory: options.homeDirectory } : {}),
337
394
  stateDirectory: product.stateDirectory,
395
+ onUnreadableRecords: count => partialWarning("TASK_LIST_PARTIAL", `有 ${count} 条本地任务记录无法读取,已列出可读取的记录。`, `${count} local task record(s) could not be read. Readable records are included.`),
338
396
  validateSummary: task => validators.taskListResult({ tasks: [task] }),
339
397
  validate: validators.taskResult
340
398
  }),
@@ -344,12 +402,19 @@ export function createProductionRuntime(options = {}) {
344
402
  warning: message => presenter.warning(message),
345
403
  commandName: product.commandName,
346
404
  text,
347
- failureNote: error => {
348
- const outcome = mapCliError(error, { aborted: false, product, operation: telemetry.creationContext().operation, failureStage: telemetry.failureStage(error) });
349
- return outcome.kind === "failure" ? outcome.failure.message : "";
350
- },
405
+ failureNote: taskFailureNote,
351
406
  recovery: {
352
- authorize: authorizeTaskResult,
407
+ async authorize(result, state, signal, progress) {
408
+ const authorized = await authorizeTaskResult(result, state, signal);
409
+ const tool = progress?.generation?.tool ?? canvasModelBindings.find(binding => binding[1] === progress?.toolPipeline?.model)?.[0];
410
+ if ("content" in authorized && tool && tool !== "image.ocr" && tool !== "image.layers") {
411
+ if (tool.startsWith("video."))
412
+ presentToolContent(authorized.content, "video", onMissingMedia);
413
+ else if (tool.startsWith("image."))
414
+ presentToolContent(authorized.content, "image", onMissingMedia);
415
+ }
416
+ return authorized;
417
+ },
353
418
  async agent(progress, state, signal) {
354
419
  if (!progress.contextId || !progress.localMessageId)
355
420
  return {
@@ -361,14 +426,18 @@ export function createProductionRuntime(options = {}) {
361
426
  credential: state.credential, organizationId: state.organization.id, signal
362
427
  });
363
428
  return { state: "unknown",
429
+ ...(snapshot.usageAmountMissing ? { usageAmountMissing: true } : {}),
364
430
  ...(snapshot.usageModelMissing ? { usageModelMissing: true } : {}),
365
431
  note: snapshot.partialResult
366
432
  ? text("已找到部分内容,尚未取得完整结果。", "Some content was found, but the complete result has not been received.")
367
433
  : text("尚未取得任务结果。", "The task result has not been received."),
368
- ...(snapshot.partialResult ? { partialResult: await authorizeTaskResult(agentOutputWithBillingUnit(snapshot.partialResult, product.billingUnit), state, signal, true) } : {})
434
+ ...(snapshot.partialResult ? { partialResult: await authorizeTaskResult(agentOutputWithBillingUnit(snapshot.partialResult, product.billingUnit), state, signal, "upstream") } : {})
369
435
  };
370
436
  },
371
437
  async tool(progress, state, signal) {
438
+ // Never interpret an unpublished candidate's Run receipt as a Dify task.
439
+ if (Object.hasOwn(progress, "toolRun"))
440
+ return { state: "unknown", note: text("该实验版本任务不支持继续远端查询。请保留原任务记录用于排查,不要重复提交。", "Remote recovery is unavailable for this experimental task. Keep its original record for diagnosis; do not resubmit.") };
372
441
  if (progress.toolPipeline) {
373
442
  const pipeline = progress.toolPipeline;
374
443
  await authorizeTaskAccess(state, signal);
@@ -376,7 +445,7 @@ export function createProductionRuntime(options = {}) {
376
445
  try {
377
446
  recovered = await telemetry.stage("task.query", () => recoverCanvasTool(progress, {
378
447
  access: { credential: state.credential, organizationId: state.organization.id }, signal
379
- }, { transport: toolTransport, media: canvasMedia, english: product.id === "insmind" }));
448
+ }, { transport: toolTransport, onMissingMedia, onUnrepresented, media: canvasMedia({ credential: state.credential, organizationId: state.organization.id }), english: product.id === "insmind" }));
380
449
  }
381
450
  catch (error) {
382
451
  if (!(error instanceof ToolTaskFailedError) && !(error instanceof ToolTaskCanceledError))
@@ -384,17 +453,18 @@ export function createProductionRuntime(options = {}) {
384
453
  const outcome = mapCliError(error, { aborted: false, product, operation: "task.get", failureStage: "task.query" });
385
454
  return { state: "failed", note: outcome.failure?.message ?? text("本次处理未能完成。", "This processing could not be completed."), failure: error };
386
455
  }
456
+ const source = "fromCheckpoint" in recovered && recovered.fromCheckpoint ? "checkpoint" : "upstream";
387
457
  if (recovered.state === "complete" && progress.toolUsage)
388
458
  return { state: "completed", result: await authorizeTaskResult(toolOutputWithBillingUnit({
389
459
  content: recovered.content, usage: progress.toolUsage
390
- }, product.billingUnit), state, signal, true) };
460
+ }, product.billingUnit), state, signal, source) };
391
461
  if (recovered.state === "pending")
392
462
  return { state: "running", note: text("任务仍在处理中。", "The task is still processing.") };
393
463
  const partialContent = recovered.state === "unknown" ? recovered.content : undefined;
394
464
  return { state: "unknown", note: text(`处理停留在 ${pipeline.stage} 阶段,尚未交付完整结果。查询不会重新处理、上传或结算;请保留任务 ID 排查,勿重复提交。`, `Processing reached ${pipeline.stage}; no complete result was delivered. Querying does not process, upload, or settle again. Keep the task ID for diagnosis; do not resubmit.`),
395
465
  ...(partialContent && progress.toolUsage ? { partialResult: await authorizeTaskResult(toolOutputWithBillingUnit({
396
466
  content: partialContent, usage: progress.toolUsage
397
- }, product.billingUnit), state, signal, true) } : {}) };
467
+ }, product.billingUnit), state, signal, source) } : {}) };
398
468
  }
399
469
  if (!progress.remoteTaskId || !progress.toolUsage)
400
470
  return {
@@ -406,7 +476,7 @@ export function createProductionRuntime(options = {}) {
406
476
  try {
407
477
  response = await telemetry.stage("task.query", async () => {
408
478
  const result = await queryToolResult(toolTransport, {
409
- taskId, credential: state.credential, organizationId: state.organization.id, signal,
479
+ taskId, credential: state.credential, organizationId: state.organization.id, signal, onUnrepresented,
410
480
  onDifyTaskId: id => telemetry.annotate({ dify_task_id: id })
411
481
  });
412
482
  if (result.difyTaskId)
@@ -425,8 +495,8 @@ export function createProductionRuntime(options = {}) {
425
495
  if (response.state === "pending")
426
496
  return { state: "running", note: text("任务仍在处理中。", "The task is still processing.") };
427
497
  return { state: "completed", result: await authorizeTaskResult(toolOutputWithBillingUnit({
428
- content: response.content, usage: progress.toolUsage
429
- }, product.billingUnit), state, signal, true) };
498
+ content: await verifyToolOutput(response.content, progress.generation?.tool === "video.generate" ? "video" : "image", { access: { credential: state.credential, organizationId: state.organization.id }, signal }), usage: progress.toolUsage
499
+ }, product.billingUnit), state, signal, "upstream") };
430
500
  }
431
501
  }
432
502
  });
@@ -440,19 +510,17 @@ export function createProductionRuntime(options = {}) {
440
510
  }),
441
511
  telemetry
442
512
  }), product.billingUnit);
443
- const canvasMedia = createCanvasMedia({ fetch, uploader: transientUploader });
444
513
  const tool = withToolBillingUnit(createToolUseCases({
445
514
  catalog: modelCatalog,
446
515
  tools: product.tools,
447
516
  ...(product.id === "insmind" ? { modelDescription: "Model machine identifier from model list." } : {}),
448
- execution: createCanvasToolAdapter({ transport: toolTransport, recordTransport: damTransport, telemetry, media: canvasMedia, english: product.id === "insmind",
449
- fallback: createToolApiAdapter({ transport: toolTransport, telemetry }),
450
- standardMatting: createStandardMatting({ transport: toolTransport, recordTransport: damTransport, media: canvasMedia }) }),
517
+ execution: canvasTools,
451
518
  uploader: transientUploader,
452
519
  warn: (message) => { presenter.warning(message); },
453
520
  telemetry
454
521
  }), product.billingUnit);
455
522
  const editor = createEditorUseCases({
523
+ onPartial: count => partialWarning("EDITOR_SNAPSHOT_PARTIAL", `有 ${count} 个元素无法表示,已返回其余元素。`, `${count} unsupported element(s); the other elements are included.`),
456
524
  session: createEditorSession({
457
525
  store: createEditorSessionStateStore({
458
526
  ...(options.homeDirectory === undefined
@@ -533,11 +601,13 @@ export function createProductionRuntime(options = {}) {
533
601
  telemetryEnvironment, telemetryVersion: options.telemetryVersion ?? primarySkill.version, origin: telemetry.creationContext(),
534
602
  telemetryTrackingUrl: String(options.telemetryTrackingUrl ?? product.telemetryUrl),
535
603
  locale: locale.locale, endpoints: Object.fromEntries(Object.entries(endpoints).map(([key, value]) => [key, String(value)]))
536
- }, signal, task => {
604
+ }, signal, (task, creationTraceId) => {
537
605
  startedId = task.taskId;
606
+ if (creationTraceId)
607
+ telemetry.annotate({ creation_trace_id: creationTraceId });
538
608
  telemetry.annotate({ cli_task_id: task.taskId, execution_mode: "async", result_state: task.state });
539
- presenter.notice(text(`任务 ID: ${task.taskId};结果未收到时执行 ${product.commandName} task get ${task.taskId}`, `Task ID: ${task.taskId}; retrieve missing output with ${product.commandName} task get ${task.taskId}`));
540
- });
609
+ presenter.notice(taskStartedNotice(task.taskId, product.commandName, "async", text));
610
+ }, facts => telemetry.annotate(facts));
541
611
  }
542
612
  catch (error) {
543
613
  if (startedId)
@@ -8,7 +8,9 @@ export async function runTaskWorker(options) {
8
8
  const { job, signal, send } = options;
9
9
  runtime.telemetry.useSignal(signal);
10
10
  runtime.telemetry.select({ operation: job.operation, mode: () => "execute" });
11
- runtime.telemetry.annotate({ ...(job.origin ? { creation_trace_id: job.origin.trace_id, host_application: job.origin.host_application ?? "unknown" } : {}), account_id: job.state.account?.id, organization_id: job.state.organization.id,
11
+ runtime.telemetry.annotate({ ...(job.origin ? { host_application: job.origin.host_application ?? "unknown" } : {}),
12
+ ...(job.origin ? { creation_trace_id: job.origin.trace_id } : {}),
13
+ account_id: job.state.account?.id, organization_id: job.state.organization.id,
12
14
  parameters: { ...job.input }, execution_mode: "async" });
13
15
  let completion = { outcome: "success" };
14
16
  let started = false;
@@ -21,6 +23,7 @@ export async function runTaskWorker(options) {
21
23
  runtime.validators.toolCallInput(job.input);
22
24
  await runtime.tasks.track({
23
25
  state: job.state,
26
+ signal,
24
27
  operation: job.operation,
25
28
  label: job.label,
26
29
  executionMode: "async",
@@ -32,7 +35,8 @@ export async function runTaskWorker(options) {
32
35
  }
33
36
  if ((progress.accepted || progress.remoteTaskId) && !accepted) {
34
37
  accepted = true;
35
- send({ type: "accepted", task });
38
+ send({ type: "accepted", task,
39
+ ...(job.operation === "tool.call" ? { execution_protocol: progress.toolPipeline?.protocol ?? "dify" } : {}) });
36
40
  }
37
41
  },
38
42
  run: async (observe) => {
@@ -3,7 +3,7 @@ import { canonicalizeInputFileUris } from "../platform/input-uri.js";
3
3
  import { Ajv2020 } from "ajv/dist/2020.js";
4
4
  import addFormatsImport, {} from "ajv-formats";
5
5
  import { agentInputSchema } from "../contracts/creation-input.js";
6
- import { contractSchema } from "../contracts/schema.js";
6
+ import { contractDocument, contractSchema } from "../contracts/schema.js";
7
7
  const agentSendOutputSchema = contractSchema("agent.send", "output");
8
8
  const authStatusSchema = contractSchema("auth.status", "output");
9
9
  const damDeleteInputSchema = contractSchema("dam.delete", "input");
@@ -1,3 +1,4 @@
1
+ import { identifyInvocation } from "../telemetry/command-route.js";
1
2
  import { jsonErrorsRequested } from "../platform/error-output-mode.js";
2
3
  const environments = new WeakMap();
3
4
  const boundPolicies = new WeakMap();
@@ -106,44 +107,20 @@ function annotateAccessContext(telemetry, context) {
106
107
  organization_id: context.state.organization?.id
107
108
  });
108
109
  }
109
- /** Identify the invocation before Commander can read stdin, reject arguments or exit for help. */
110
- export function invocationDefinition(program, argv) {
111
- let command = program;
112
- let unknown = false;
113
- let mode = "execute";
114
- for (let i = 0; i < argv.length; i++) {
115
- const token = argv[i];
116
- if (token === "--")
117
- break;
118
- if (token === "-h" || token === "--help") {
119
- mode = "help";
120
- continue;
121
- }
122
- if (token === "-V" || token === "--version") {
123
- mode = "version";
124
- continue;
125
- }
126
- if (token.startsWith("-")) {
127
- const flag = token.split("=")[0];
128
- const option = [...command.options, ...program.options].find(item => item.long === flag || item.short === flag);
129
- if (option?.long === "--schema" && mode === "execute")
130
- mode = "schema";
131
- if (option?.required && !token.includes("="))
132
- i++;
133
- continue;
134
- }
135
- if (command.commands.length) {
136
- const child = command.commands.find(item => item.name() === token || item.aliases().includes(token));
137
- if (!child) {
138
- unknown = true;
139
- break;
140
- }
141
- command = child;
142
- }
143
- }
110
+ export function commandRoute(command) {
111
+ const definition = commandDefinitions.get(command);
144
112
  const path = commandPath(command).split(" ").slice(1).join(".");
145
- const operation = mode === "version" ? "version" : unknown ? "unknown" : commandDefinitions.get(command)?.operation ?? (path || (mode === "help" ? "help" : "unknown"));
146
- return { operation, mode: () => mode };
113
+ const children = Object.create(null);
114
+ for (const child of command.commands) {
115
+ const route = commandRoute(child);
116
+ for (const name of [child.name(), ...child.aliases()])
117
+ children[name] = route;
118
+ }
119
+ return { operation: definition?.operation ?? (path || "unknown"), action: !!definition,
120
+ options: command.options.map(option => option.flags), children };
121
+ }
122
+ export function invocationDefinition(program, argv) {
123
+ return identifyInvocation(commandRoute(program), argv);
147
124
  }
148
125
  function commandPath(command) {
149
126
  const names = [];
@@ -1,3 +1,4 @@
1
+ import { creationTaskHelp } from "./creation-help.js";
1
2
  import { hostSchema, readHostInput } from "./host-input.js";
2
3
  import { agentInputSchema } from "../contracts/creation-input.js";
3
4
  import { jsonOutput, bindPreparedAction } from "./action-binding.js";
@@ -5,29 +6,28 @@ import { CliUsageError } from "./errors.js";
5
6
  import { productText as text } from "../product/text.js";
6
7
  export function registerAgentCommands(program, runtime) {
7
8
  const agent = program.command("agent")
8
- .description(text(runtime.product, "稿定 Agent", "insMind Agent"))
9
+ .description(text(runtime.product, "业务策划与持续多轮创作", "Business planning and multi-turn creation"))
9
10
  .helpCommand(false);
10
11
  const send = agent.command("send")
11
- .description(text(runtime.product, "发送结构化创作消息并等待最终结果", "Send a structured creation message and wait for its result"))
12
+ .description(text(runtime.product, "发送创作消息,等待本轮回复、成品或补充问题", "Send a creation message and wait for this turn's reply, assets or questions"))
12
13
  .option("--schema", text(runtime.product, "输出输入 Schema", "output the input Schema"))
13
14
  .option("--input <file|->", text(runtime.product, "从文件或标准输入读取 JSON", "read JSON from a file or stdin"))
14
15
  .option("--async", text(runtime.product, "提交后返回 taskId,通过 task get 查询结果", "return taskId after submission; retrieve results with task get"))
15
16
  .allowExcessArguments(false);
16
17
  send.addHelpText("after", [
17
18
  "",
19
+ text(runtime.product, "用于业务策划、多步骤或持续创作;明确的单次媒体处理也可从 tool list 发现。先保存完整 JSON 再用 --input request.json 执行;--input - 必须在同一条 shell 命令中经管道或重定向提供完整 JSON,不交互填参。", "Use for planning, multiple steps or continuing creation; discover atomic media processing with tool list. Save complete JSON before using --input request.json. With --input -, pipe or redirect complete JSON in the same shell command; input is not an interactive form."),
18
20
  text(runtime.product, "完整结果已校验但最终本地记录保存失败时仍返回结果和退出码 0;stderr 警告 task get 可能无法恢复,请保留输出。", "A validated complete result is delivered with exit code 0 even if its final local record cannot be saved; stderr warns that task get may not recover it. Keep the output."),
19
21
  text(runtime.product, "最终错误为 stderr 中的 JSON error 对象;stderr 也可能有进度和警告。中断退出码 130 只表示本地停止等待。", "The final error is a JSON error object on stderr, which may also contain progress and warnings. Exit code 130 means local waiting stopped."),
20
- text(runtime.product, "--async 在服务端受理后输出包含 taskId 和 state 的 JSON;退出码 0 仅表示受理。", "--async returns JSON with taskId and state after acceptance; exit code 0 means accepted only."),
21
- 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."),
22
- text(runtime.product, "Agent 异步由本机后台进程继续执行;进程终止或关机可能使状态变为 unknown。", "Agent async continues in a local background process; termination or shutdown may leave its state unknown."),
23
- text(runtime.product, "中断前台等待不会取消已交接的后台任务;仍用原 taskId 查询。", "Interrupting the foreground wait does not cancel a handed-off task; query the same taskId."),
24
- text(runtime.product, "默认在当前进程等待最终结果,成功后一次输出 JSON。", "By default, the command waits in the current process and returns the final result as one JSON object."),
25
- text(runtime.product, "运行中请继续等待原进程;已提交但结果未知时,不要重复提交。", "Wait for the original process. Do not resubmit a creation whose outcome is unknown."),
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
- 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>.`),
22
+ ...creationTaskHelp(runtime.product),
23
+ text(runtime.product, "本机后台进程终止或关机可能使 Agent 任务变为 unknown。", "If the local background process stops or the machine shuts down, an Agent task may become unknown."),
28
24
  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."),
25
+ text(runtime.product, "completed 表示本轮 Agent 已完整回复,可能是文本、资源或补充/确认问题,并不保证已生成成品。转述实际回复;需要用户回答时询问用户,收到回答后沿用 contextId 发送下一轮。", "completed means the Agent's turn has fully replied with text, assets or clarification/confirmation questions; it does not guarantee a finished asset. Relay the actual reply, ask the user when an answer is needed, then continue with the same contextId."),
26
+ text(runtime.product, "把本轮实际回复或资源连同 usage.cost.amount 的实际消耗一并交付。同步从输出读取,异步从 completed 的 result 读取。返回 0 就报 0,缺失则说明未取得。汇总按不同 taskId,同一任务重复读取只计一次。Tool minimum/maximum 是目录估价。", "Deliver this turn's reply or assets together with the actual charge in usage.cost.amount. Read it from the synchronous output or the completed task's result. Report 0 when present, and unknown when absent. Count each distinct taskId once. Tool minimum/maximum are catalog estimates."),
27
+ text(runtime.product, "结构化问题位于 message.parts[].data.questions;回答时将 message.messageId 写入 data.questionMessageId,answers 保留 question 原文及用户 values,该 data Part 是本轮 parts 唯一一项。普通文本续聊使用 text Part。", "Structured questions are in message.parts[].data.questions. Reply with message.messageId as data.questionMessageId and answers containing the original question and the user's values; this data Part must be the sole Part. Use a text Part for ordinary follow-up conversation."),
29
28
  text(runtime.product, "可用 model 和参数示例见 model list / model get。显式 model 和 arguments 会传给 Agent,编辑模型的已知别名转换为服务字段。文本和素材用独立 Part。", "Discover models and example controls with model list and model get. Explicit model and arguments are sent to the Agent, with known editing aliases mapped to service fields. Supply text and assets as separate Parts."),
30
- text(runtime.product, "usage 仅覆盖本次调用,不包含其他命令调用的消耗。", "usage covers this invocation only, excluding other command invocations."),
29
+ text(runtime.product, "交付服务返回的资源时,原样使用完整 URL 及查询参数;不凭记忆重写、拼接或去掉授权参数。诊断凭证脱敏不改变可交付资源链接。", "Deliver service resources using the complete returned URL and query parameters. Do not reconstruct, splice or strip authorization parameters. Diagnostic credential redaction does not alter delivery links."),
30
+ text(runtime.product, "素材用独立 URL Part;本地文件用 Path(path).resolve().as_uri() 或 pathToFileURL(path).href 生成标准 URI,保留顺序和 metadata.role。--input 的 JSON 文件参数仍使用路径。", "Supply assets as separate URL Parts, preserving order and metadata.role. Generate local URIs with Path(path).resolve().as_uri() or pathToFileURL(path).href. The --input JSON file argument remains a path."),
31
31
  ""
32
32
  ].join("\n"));
33
33
  jsonOutput(send);
@@ -6,6 +6,7 @@ export function registerAuthCommands(program, runtime) {
6
6
  const auth = program.command("auth")
7
7
  .description(text(runtime.product, "登录与本机凭证", "Authentication and local credentials"))
8
8
  .helpCommand(false);
9
+ auth.addHelpText("after", text(runtime.product, "\n管理本机 CLI 登录;不替代 Editor 浏览器登录。status 只读状态,login 等待浏览器授权完成,logout 清除本机共享登录。授权链接不等于登录成功;无需提供或读取 AK/SK、Cookie 等凭证。\n", "\nManages the local CLI identity, separately from Editor browser login. status reads state, login waits for browser authorization, and logout clears the shared local sign-in. An authorization URL is not successful login; do not provide or read credential values.\n"));
9
10
  const login = leaf(auth.command("login"))
10
11
  .description(text(runtime.product, "登录稿定", "Sign in to insMind"))
11
12
  .option("--no-browser", text(runtime.product, "不自动打开浏览器", "do not open a browser automatically"))
@@ -51,7 +52,7 @@ export function registerAuthCommands(program, runtime) {
51
52
  });
52
53
  });
53
54
  }, { operation: "auth.status" });
54
- const logout = leaf(auth.command("logout")).description(text(runtime.product, "退出登录", "Sign out"));
55
+ const logout = leaf(auth.command("logout")).description(text(runtime.product, "退出登录", "Sign out")).addHelpText("after", text(runtime.product, "\n清除本机 CLI 凭证及当前组织选择,会影响复用这份登录的其他入口;不删除云端素材或作品。\n", "\nClears local CLI credentials and the current identity context, affecting other entry points sharing this sign-in. It does not delete cloud assets or works.\n"));
55
56
  bindAction(logout, "none", async () => {
56
57
  await runtime.auth.logout();
57
58
  await runtime.telemetry.stage("output", async () => {
@@ -0,0 +1,9 @@
1
+ import { productText } from "../product/text.js";
2
+ export function creationTaskHelp(product) {
3
+ return [
4
+ productText(product, "现在要结果时默认同步。保留宿主返回的退出状态和进程句柄,进程仍在运行就继续等待原进程,直到 stdout 给出完整结果或命令报错。", "For a result now, use the default synchronous command. Keep the host's exit status and process handle. While it is running, wait on that process for the complete stdout result or an error."),
5
+ productText(product, "失去进程句柄时,用 stderr 提示的 taskId 执行 task get <taskId>。没有 ID 时用 task list 定位原调用。现在要交付且 state=running 时隔数秒继续查原 ID。", "If the process handle is lost, use task get <taskId> with the ID from stderr, or locate the call with task list. For delivery now, keep checking the same ID every few seconds while state is running."),
6
+ productText(product, "用户明确稍后取回时用 --async。受理后立即向用户返回 taskId 和当前 state,本轮到此结束。用户回来时用同一 ID 取结果。退出码 0 在此表示已受理。", "For later pickup, use --async. As soon as it is accepted, return the taskId and current state to the user and end this turn. When they return, retrieve the result with that ID. Exit 0 here means accepted."),
7
+ productText(product, "异步由本机后台进程继续执行。退出前台不会取消已交接的任务。unknown 或查询超时只能说明结果待确认,请查原任务,勿另发创作。", "Async work continues in a local background process. Leaving the foreground does not cancel accepted work. On unknown or a query timeout, check the original task without resubmitting.")
8
+ ];
9
+ }
@@ -11,6 +11,7 @@ export function registerDamCommands(program, runtime) {
11
11
  "",
12
12
  text(runtime.product, "先通过 repository list、folder list、tag list 或资源查询取得真实 ID,再操作;名称、前端 URL 和旧缓存不能代替 ID。", "Discover real IDs with repository list, folder list, tag list or asset queries before acting; names, frontend URLs and old caches are not IDs."),
13
13
  text(runtime.product, "支持的命令以本 help 为准;读取所选子命令的 --help 获取参数、作用范围和输出形式。", "Available commands are listed here; read the selected subcommand's --help for parameters, scope and output mode."),
14
+ text(runtime.product, "资源库 ID 与组织 ID 不同。团队/企业资料显式传查询到的 repository_id;list/search/upload 省略资源库时默认个人库。素材处理使用详情中的资源链接或下载后的本地文件,再从 tool list 发现处理能力。", "Repository IDs differ from organization IDs. Pass a discovered repository_id for team/enterprise assets; list/search/upload default to the personal repository when omitted. To process an asset, use its resource link or downloaded file and discover processing with tool list."),
14
15
  text(runtime.product, "写入结果未确认时先查询实际状态,不重复提交。跨资源库查询、受保护路径上传和永久删除须有用户明确授权。", "Inspect actual state before retrying an unconfirmed write. Cross-repository queries, protected-path uploads and permanent deletion require explicit user authorization."),
15
16
  ""
16
17
  ].join("\n"));
@@ -41,7 +42,7 @@ export function registerDamCommands(program, runtime) {
41
42
  .option("--parent-id <id>", text(runtime.product, "父文件夹 ID", "parent folder ID"))
42
43
  .option("--query <text>", text(runtime.product, "按名称筛选", "filter by name"))
43
44
  .option("--page <n>", text(runtime.product, "页码", "page number"), positiveInteger)
44
- .option("--page-size <1-100>", text(runtime.product, "分页大小", "page size"), pageSize)
45
+ .option("--page-size <number>", text(runtime.product, "分页大小", "page size"), positiveInteger)
45
46
  .option("--json", text(runtime.product, "输出 JSON", "output JSON"));
46
47
  bindPreparedAction(folderList, "organization", async (signal) => {
47
48
  signal.throwIfAborted();
@@ -294,6 +295,7 @@ export function registerDamCommands(program, runtime) {
294
295
  .option("--allow-sensitive-path", text(runtime.product, "明确允许受保护路径", "allow a protected local path"))
295
296
  .option("--wait-analysis", text(runtime.product, "等待素材分析结束", "wait for asset analysis"))
296
297
  .option("--json", text(runtime.product, "输出 JSON", "output JSON"));
298
+ upload.addHelpText("after", text(runtime.product, "\n<file> 是本地文件路径(不是 file URI);路径含空格时按 shell 规则引用。默认上传个人库根目录 0,标题默认取不含扩展名的文件名;团队位置显式传资源库和文件夹 ID。返回素材详情表示已创建;--wait-analysis 额外等待分析,未知写入先查目标位置,不重复上传。\n", "\n<file> is a local path, not a file URI; quote spaces for the shell. Defaults to personal repository root 0 and a title from the filename without its extension. Specify repository/folder IDs for team destinations. Returned asset details confirm creation; --wait-analysis also waits for analysis. Inspect the destination before repeating an unconfirmed upload.\n"));
297
299
  bindPreparedAction(upload, "organization", async (signal) => {
298
300
  signal.throwIfAborted();
299
301
  const options = upload.opts();
@@ -364,9 +366,10 @@ function browseCommand(command, runtime) {
364
366
  .option("--type <type>", text(runtime.product, "素材类型", "asset type"))
365
367
  .option("--asset-format <csv>", text(runtime.product, "文件格式,逗号分隔", "comma-separated file formats"))
366
368
  .option("--tag-ids <csv>", text(runtime.product, "标签 ID,逗号分隔", "comma-separated tag IDs"))
367
- .option("--page-size <1-100>", text(runtime.product, "请求分页大小", "request page size"), pageSize)
368
- .option("--cursor <id>", text(runtime.product, "分页游标", "pagination cursor"))
369
- .option("--json", text(runtime.product, "输出 JSON", "output JSON"));
369
+ .option("--page-size <number>", text(runtime.product, "请求分页大小", "request page size"), positiveInteger)
370
+ .option("--cursor <id>", text(runtime.product, "原样使用上一页 next_cursor,并保持相同筛选", "reuse the previous next_cursor unchanged with the same filters"))
371
+ .option("--json", text(runtime.product, "输出 JSON", "output JSON"))
372
+ .addHelpText("after", text(runtime.product, "\n默认个人资源库,每页 20 条,包含子文件夹;finish=false 时用 next_cursor 继续同范围查询,本页不代表全部结果。空结果不证明其他资源库不存在该素材;按用户指定范围核对资源库和筛选。\n", "\nDefaults to the personal repository, 20 items and inclusion of child folders. When finish=false, continue with next_cursor and unchanged scope; one page is not the entire result. An empty page says nothing about other repositories; check the user's intended repository and filters.\n"));
370
373
  }
371
374
  function browseInput(command) {
372
375
  const options = command.opts();
@@ -388,15 +391,7 @@ function defined(key, value) {
388
391
  return value === undefined ? {} : { [key]: value };
389
392
  }
390
393
  function csv(value) {
391
- return value?.split(",").map((item) => item.trim()).filter((item) => item !== "");
392
- }
393
- function pageSize(value) {
394
- if (!/^\d+$/u.test(value))
395
- throw new CliUsageError();
396
- const parsed = Number(value);
397
- if (!Number.isInteger(parsed) || parsed < 1 || parsed > 100)
398
- throw new CliUsageError();
399
- return parsed;
394
+ return value?.split(",").map((item) => item.trim());
400
395
  }
401
396
  function positiveInteger(value) {
402
397
  if (!/^\d+$/u.test(value))
@@ -424,7 +419,8 @@ function assetListView(value, product) {
424
419
  `${text(product, "资源库", "Repositories")}: ${result.repository_ids.join(", ")}`,
425
420
  `${text(product, "本批 / 总数", "This batch / total")}: ${result.assets.length} / ${result.total}`,
426
421
  result.finish ? text(product, "已到最后一页。", "Last page.")
427
- : text(product, `还有下一页;保留筛选条件,使用 --cursor ${result.next_cursor ?? "<cursor>"} 查询。`, `More results; keep the same filters and query with --cursor ${result.next_cursor ?? "<cursor>"}.`),
422
+ : !result.next_cursor ? text(product, "服务提示还有结果,但未返回可用游标,无法续页。", "More results are indicated, but the service supplied no cursor.")
423
+ : text(product, `还有下一页;保留筛选条件,使用 --cursor ${result.next_cursor ?? "<cursor>"} 查询。`, `More results; keep the same filters and query with --cursor ${result.next_cursor ?? "<cursor>"}.`),
428
424
  ...(result.assets.length ? [text(product, "ID\t标题\t类型\t格式", "ID\tTitle\tType\tFormat"), ...result.assets.map(assetRow)]
429
425
  : [text(product, "暂无素材。", "No assets.")])
430
426
  ].join("\n");
@@ -15,19 +15,20 @@ export function registerEditorCommands(program, runtime) {
15
15
  .helpCommand(false);
16
16
  editor.addHelpText("after", [
17
17
  "",
18
+ text(runtime.product, "对象是已连接作品中的元素。用户提供附件图片/媒体链接并要求改字、分层、矢量化或其他图片处理时,先从 tool list 发现能力;无需为了这些操作新建 Board。", "This group operates elements in a connected work. For attached images or media links needing text replacement, decomposition, vectorization or other processing, discover tool list first; these operations do not require a new Board."),
18
19
  text(runtime.product, "操作一个当前 Session、当前 Page 的直属 Shape 和绑定 Connector;单操作者串行执行。", "Operate one current Session and its Page's direct Shapes and bound Connectors, serially with one operator."),
19
20
  text(runtime.product, "元素类型与字段以 editor apply --schema 为准;Schema 查询无需登录或连接 Editor。", "Discover element types and fields with editor apply --schema; no login or Editor connection is required."),
20
21
  text(runtime.product, "当前不支持嵌套元素、自由/半绑定 Connector、页面或选择修改;UNSUPPORTED_PAGE_CONTENT 时保留原作品并换用空白或专用 Page。", "Nested elements, free/half-bound Connectors, page and selection changes are unsupported. On UNSUPPORTED_PAGE_CONTENT, preserve the work and use a blank or dedicated Page."),
21
- text(runtime.product, "流程:connect → snapshot → apply → snapshot/screenshot 复查 → save → disconnect。apply 不代替 save。", "Workflow: connect → snapshot → apply → review snapshot/screenshot → save → disconnect. Apply does not replace Save."),
22
+ text(runtime.product, "流程:connect → snapshot → apply → snapshot/screenshot 复查 → 按用户授权 save → disconnect。apply 不代替 save。只预览/暂不保存时停在预览;用户要求断开就执行 disconnect,断开不隐含保存。", "Workflow: connect → snapshot → apply → review snapshot/screenshot → save as authorized → disconnect. Apply does not replace Save. For preview-only requests stop at preview; on a request to disconnect, execute disconnect without implicitly saving."),
22
23
  text(runtime.product, "EDITOR_BUSY 时等待原命令结束;写入超时、取消或断连时,先重新连接同一作品并检查真实状态,不直接重试写入。", "On EDITOR_BUSY, wait for the original command. After a write times out, is cancelled or disconnects, reconnect to the same work and inspect its state before deciding what to do."),
23
24
  ""
24
25
  ].join("\n"));
25
26
  const connect = leaf(editor.command("connect"))
26
27
  .description(text(runtime.product, "打开并连接一个 AI+ Editor 作品", "Open and connect to an Editor work"))
27
- .argument("[target]", text(runtime.product, "作品 ID 或完整 URL", "work ID or complete URL"));
28
+ .argument("[target]", text(runtime.product, "已有作品的 ID 或完整 URL;留空会新建线上 Board", "existing work ID or full URL; omitting it creates a new production Board"));
28
29
  connect.addHelpText("after", [
29
30
  "",
30
- text(runtime.product, "省略 target 新建线上 Board;数字按作品 ID 打开;完整 HTTP(S) URL 按该 URL 的环境打开。", "Omit target for a new production Board, use a numeric work ID, or provide a supported insMind production Editor URL."),
31
+ text(runtime.product, "继续已有作品时,传数字作品 ID 或完整 HTTP(S) URL。还没有目标就先向用户索取作品链接或 ID。用户要求新建时才省略 target。", "To continue an existing work, pass its numeric ID or supported insMind production Editor URL. If the target is missing, ask the user for the link or ID. Omit target only when the user requests a new Board."),
31
32
  text(runtime.product, "会打开浏览器并替换旧 Session;浏览器登录、加载、Board 类型、编辑/保存权限与页面内容检查通过后才成功。CLI 登录不能替代浏览器登录。", "Opens the browser and replaces the old Session. Browser login, loading, Board type, edit/save permission and page-content checks must pass. CLI credentials do not replace browser login."),
32
33
  text(runtime.product, "输出 JSON {target},不含连接凭证。连接失败时停止写入,让用户在页面处理登录或权限,再重新连接。", "Returns JSON {target} without connection credentials. On failure, stop writing and let the user resolve browser login or permissions before reconnecting."),
33
34
  text(runtime.product, "页面切换作品会断开 Session;EDITOR_NOT_READY、EDITOR_SESSION_NOT_FOUND 或 EDITOR_NOT_CONNECTED 时确认目标后重连,不轮询旧 Session。", "Switching works disconnects the Session. On EDITOR_NOT_READY, EDITOR_SESSION_NOT_FOUND or EDITOR_NOT_CONNECTED, verify the target and reconnect instead of polling the old Session."),
@@ -46,7 +47,7 @@ export function registerEditorCommands(program, runtime) {
46
47
  });
47
48
  const disconnect = leaf(editor.command("disconnect"))
48
49
  .description(text(runtime.product, "断开当前 Editor 连接", "Disconnect the current Editor"));
49
- disconnect.addHelpText("after", `\n${text(runtime.product, "输出 JSON {disconnected};断开连接不保存作品,需先显式执行 editor save。", "Returns JSON {disconnected}. Disconnecting does not save the work; run editor save explicitly first.")}\n`);
50
+ disconnect.addHelpText("after", `\n${text(runtime.product, "输出 JSON {disconnected},解除当前 CLI 会话连接,不保存作品、不关闭浏览器页面。需要保留修改且已获保存授权时先 save;用户只要求断开或明确不保存时直接断开,并说明未保存状态。", "Returns JSON {disconnected}, ending the CLI session without saving the work or closing its browser page. Save first only when persistence is intended and authorized; if the user requests only disconnection or no save, disconnect and state what remains unsaved.")}\n`);
50
51
  jsonOutput(disconnect);
51
52
  bindAction(disconnect, "none", async (_context, signal) => {
52
53
  writeJson(runtime, await runtime.telemetry.stage("editor.disconnect", () => runtime.editor.disconnect({ signal })));
@@ -70,11 +71,12 @@ export function registerEditorCommands(program, runtime) {
70
71
  apply.addHelpText("after", [
71
72
  "",
72
73
  text(runtime.product, "--schema 与 --input 必须且只能选择一个。Schema 为本地契约,不连接 Editor;执行成功输出 JSON {appliedCount}。", "Choose exactly one of --schema and --input. Schema reads the local contract without connecting to Editor; successful execution returns JSON {appliedCount}."),
74
+ text(runtime.product, "先保存完整 JSON,再用 --input request.json 执行;--input - 必须在同一条 shell 命令中经管道或重定向提供完整 JSON,不交互填参。", "Save complete JSON before using --input request.json. With --input -, pipe or redirect complete JSON in the same shell command; input is not an interactive form."),
73
75
  text(runtime.product, "输入对象包含 host_application 和按序执行的 actions 数组;类型、必填字段与可选值见 --schema。使用简短语义 ID;create ID 必须唯一,Connector 可引用本批次更早创建的 Shape。", "Input is an object with host_application and an ordered actions array; discover types, required fields and choices with --schema. Use short semantic IDs. Create IDs must be unique; a Connector may reference a Shape created earlier in the batch."),
74
76
  text(runtime.product, "update 提交完整元素而非 patch,不改变 id 或 _type。delete 要求 ID 存在;删除 Shape 同时删除绑定的 Connector。", "Update requires the full element, not a patch, without changing id or _type. Delete requires an existing ID; deleting a Shape also deletes its bound Connectors."),
75
77
  text(runtime.product, "Shape 的 x/y 为 Page 左上角坐标,w/h 大于 0;数值必须有限。颜色用 #RRGGBB 或 #RRGGBBAA,仅 stroke 可为 null。Connector 用 fromId/toId 表达有方向的 Shape 关系。", "Shape x/y locate its top-left corner in Page coordinates; w/h must exceed zero and numbers must be finite. Colors use #RRGGBB or #RRGGBBAA; only stroke accepts null. Connector fromId/toId express a directed Shape relationship."),
76
78
  text(runtime.product, "整批先预检,再在可回滚事务中应用;INVALID_ACTIONS 时修正输入,APPLY_FAILED 时读 Snapshot 确认回滚。EDITOR_ROLLBACK_FAILED 时停止 apply/save,只读检查并报告。", "The batch is checked before one rollback-capable transaction. Correct INVALID_ACTIONS; on APPLY_FAILED read a Snapshot to confirm rollback. On EDITOR_ROLLBACK_FAILED, stop apply/save, inspect read-only and report."),
77
- text(runtime.product, "成功不表示已保存或视觉正确;读取新 Snapshot,涉及布局/文字/连线时查看截图,再显式 save。超时、取消或断连后先检查真实状态,不重复提交。", "Success proves neither persistence nor correct rendering. Read a new Snapshot, view a screenshot for layout/text/connectors, then explicitly save. Inspect real state after timeout, cancellation or disconnection instead of resubmitting."),
79
+ text(runtime.product, "成功不表示已保存或视觉正确;读取新 Snapshot,涉及布局/文字/连线时查看截图。只预览时交付截图且不 save;需要持久化并已获授权时再显式 save。超时、取消或断连后先检查真实状态,不重复提交。", "Success proves neither persistence nor correct rendering. Read a new Snapshot and view a screenshot for layout/text/connectors. Deliver preview-only requests without save; explicitly save when persistence is intended and authorized. Inspect real state after timeout, cancellation or disconnection instead of resubmitting."),
78
80
  ""
79
81
  ].join("\n"));
80
82
  jsonOutput(apply);