@insmind/cli 1.5.9 → 1.5.10

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.
@@ -9,6 +9,7 @@ import { AuthorizedAccountContextMissingError, DeviceAuthorizationExpiredError }
9
9
  import { AgentInputError } from "../features/agent/use-cases.js";
10
10
  import { ToolInputError } from "../features/tool/catalog.js";
11
11
  import { ToolTaskFailedError } from "../features/tool/tool-api-adapter.js";
12
+ import { AgentAuditRejectedError } from "../features/agent/creative-protocol.js";
12
13
  import { ObjectStorageUploadError } from "../features/dam/object-storage.js";
13
14
  import { DamAssetNotDownloadableError, DamAssetNotFoundError, DamFolderNotFoundError } from "../features/dam/dam-api-adapter.js";
14
15
  import { DamDownloadError, DamDownloadDestinationExistsError } from "../features/dam/file-downloader.js";
@@ -132,6 +133,15 @@ export function mapCliError(error, options) {
132
133
  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."]);
133
134
  return failure("INSUFFICIENT_CREDITS", "当前组织稿豆不足,无法完成本次创作。", 1, INSUFFICIENT_CREDITS_NEXT_STEPS);
134
135
  }
136
+ if (error instanceof AgentAuditRejectedError) {
137
+ const reason = error.phase === undefined ? "audit_rejected" : `${error.phase}_audit_rejected`;
138
+ const message = error.phase === "input"
139
+ ? text("输入内容未通过审核,本次创作已拒绝。", "The input did not pass content review. This creation was rejected.")
140
+ : error.phase === "output"
141
+ ? text("生成内容未通过审核,无法交付本次结果。", "The generated content did not pass review. This result cannot be delivered.")
142
+ : text("本次创作被内容审核拒绝。", "This creation was rejected by content review.");
143
+ return failure("REMOTE_REQUEST_FAILED", message, 1, [text("请检查并调整创作内容;不要重复提交相同请求。", "Review and adjust the creation content; do not resubmit the same request.")], { reason });
144
+ }
135
145
  if (error instanceof RemoteProtocolError) {
136
146
  return failure("REMOTE_PROTOCOL_INCOMPATIBLE", text("稿定服务返回了当前 CLI 无法安全处理的结果;为避免重复创作,已停止处理。", "The insMind service returned a result this CLI cannot safely process; processing stopped to avoid duplicate creation."), 1, [text(`保留诊断 ID。若已有任务 ID,用 ${command} task get <id> 查询原任务;查询异常不能证明生成失败,不要重新提交。`, `Keep the diagnostic ID. If a Task ID is available, use ${command} task get <id>. A query error does not prove generation failed; do not resubmit.`)]);
137
147
  }
@@ -1,5 +1,15 @@
1
1
  import { RemoteProtocolError } from "../../platform/remote-protocol.js";
2
2
  import { RemoteRequestError } from "../../platform/signed-http-transport.js";
3
+ export class AgentAuditRejectedError extends RemoteRequestError {
4
+ phase;
5
+ constructor(revokedMessageId) {
6
+ const phase = typeof revokedMessageId === "string" ? revokedMessageId === "" ? "input" : "output" : undefined;
7
+ super(undefined, false, { remoteCode: "-1006", remoteBody: '{"code":"-1006"}' }, undefined, phase === "input" ? "AGENT_INPUT_AUDIT_REJECTED" : phase === "output" ? "AGENT_OUTPUT_AUDIT_REJECTED" : "AGENT_AUDIT_REJECTED");
8
+ this.name = "AgentAuditRejectedError";
9
+ this.message = "Agent content review rejected this creation.";
10
+ this.phase = phase;
11
+ }
12
+ }
3
13
  export function buildCreativeRequest(message, ids) {
4
14
  const prompt = [];
5
15
  const textParts = [];
@@ -109,6 +119,17 @@ function fail(diagnosticReason, summary) {
109
119
  throw new RemoteProtocolError(summary === undefined ? {} : { remoteBody: JSON.stringify(summary) }, undefined, diagnosticReason);
110
120
  }
111
121
  export function creativeContextId(messages) {
122
+ // A pre-run refusal is streamed before the user input is persisted. Checking
123
+ // status first prevents an empty messages history from hiding that decision.
124
+ for (const message of messages) {
125
+ const content = contentOf(message);
126
+ if (message.role !== "status" || content?.type !== "status")
127
+ continue;
128
+ const status = record(parseJson(content.text));
129
+ if (status?.code === "-1006" || status?.code === -1006) {
130
+ throw new AgentAuditRejectedError(record(message.extra)?.revoked_message_id);
131
+ }
132
+ }
112
133
  const contextId = messages
113
134
  .map((message) => nonEmptyString(message.thread_id))
114
135
  .find((value) => value !== undefined);
@@ -2,6 +2,7 @@ import { redactSensitiveText } from "../../platform/redact.js";
2
2
  import { TaskStoreError, taskScope } from "./store.js";
3
3
  import { LocalFileError } from "../../platform/local-json-file.js";
4
4
  import { ToolTaskFailedError } from "../tool/tool-api-adapter.js";
5
+ import { AgentAuditRejectedError } from "../agent/creative-protocol.js";
5
6
  export class TaskNotFoundError extends Error {
6
7
  constructor(message) { super(message); this.name = "TaskNotFoundError"; }
7
8
  }
@@ -228,13 +229,16 @@ export function createTaskUseCases(dependencies) {
228
229
  clearInterval(timer);
229
230
  if (record.task.state !== "completed") {
230
231
  const mayBeRunning = dispatched || record.progress.submissionStarted;
231
- const confirmedFailure = error instanceof ToolTaskFailedError;
232
+ const auditRejected = error instanceof AgentAuditRejectedError;
233
+ const confirmedFailure = error instanceof ToolTaskFailedError || auditRejected;
232
234
  record.task.state = confirmedFailure || !mayBeRunning ? "failed" : "unknown";
233
- record.task.note = confirmedFailure
234
- ? text("服务已明确返回本次 Tool 任务失败;具体错误见原命令。", "The service explicitly reported that this Tool task failed. See the original command for the error.")
235
- : mayBeRunning
236
- ? 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.")
237
- : text("CLI 在提交创作前结束;具体错误见原命令。", "The CLI stopped before submitting the creation. See the original command for the error.");
235
+ record.task.note = auditRejected
236
+ ? text("内容未通过审核,本次创作已拒绝;具体错误见原命令。", "Content review rejected this creation. See the original command for the error.")
237
+ : confirmedFailure
238
+ ? text("服务已明确返回本次 Tool 任务失败;具体错误见原命令。", "The service explicitly reported that this Tool task failed. See the original command for the error.")
239
+ : mayBeRunning
240
+ ? 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.")
241
+ : text("CLI 在提交创作前结束;具体错误见原命令。", "The CLI stopped before submitting the creation. See the original command for the error.");
238
242
  }
239
243
  const detail = dependencies.failureNote?.(error);
240
244
  if (detail)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insmind/cli",
3
- "version": "1.5.9",
3
+ "version": "1.5.10",
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": "02995b31afa98a9a6682fec8dc57cd25b709ca61",
50
- "pipelineId": "213097",
51
- "pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/213097"
49
+ "sourceCommit": "8f232cb9bd2962a1581239c76a3731869f83dee3",
50
+ "pipelineId": "213536",
51
+ "pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/213536"
52
52
  }
53
53
  }