@insmind/cli 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -99,6 +99,18 @@ export async function executeCli(options) {
99
99
  aborted: isInterruption(error, options.signal),
100
100
  ...(options.product ? { product: options.product } : {})
101
101
  }));
102
+ // The invocation already carries the task created by this command, even on interruption.
103
+ // Preserve it in the public error as well as progress so hosts can suppress non-JSON diagnostics.
104
+ const { cli_task_id: taskId, operation } = options.telemetry.creationContext();
105
+ if (taskId && outcome.failure && ["agent.send", "tool.call"].includes(operation)) {
106
+ const details = outcome.failure.details;
107
+ outcome.failure.details = { ...details, cli_task_id: taskId, next_steps: [
108
+ ...(details?.next_steps ?? []),
109
+ `${options.product?.commandName ?? "gd-cli"} task get ${taskId}`,
110
+ options.product?.id === "insmind" ? "Keep this task ID; do not automatically resubmit creation."
111
+ : "保留此任务 ID,不要自动重新提交创作。"
112
+ ] };
113
+ }
102
114
  const telemetryError = classifyTelemetryError(error, { aborted: isInterruption(error, options.signal), ...(options.product ? { product: options.product } : {}) });
103
115
  const traceId = options.telemetry.selected
104
116
  ? options.telemetry.traceId
@@ -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({
@@ -5,7 +5,7 @@ import { CommanderError } from "commander";
5
5
  import { AuthExpiredError, AuthRequiredError } from "../features/auth/access-policy.js";
6
6
  import { AuthStateInvalidError, UserIdentityMissingError } from "../features/auth/state.js";
7
7
  import { SsoRequestError } from "../features/auth/sso-service.js";
8
- import { AuthorizedAccountContextMissingError, DeviceAuthorizationExpiredError } from "../features/auth/use-cases.js";
8
+ import { AuthorizedAccountContextMissingError, BrowserOpenError, DeviceAuthorizationExpiredError } from "../features/auth/use-cases.js";
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";
@@ -185,6 +185,8 @@ export function mapCliError(error, options) {
185
185
  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
186
  return failure("DAM_REPOSITORY_NOT_FOUND", "当前组织没有可用的 DAM 资源库。", 1, ["gd-cli org list", "gd-cli org switch --org <org-id>"]);
187
187
  }
188
+ if (error instanceof BrowserOpenError)
189
+ 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
190
  if (error instanceof DeviceAuthorizationExpiredError)
189
191
  return failure("REMOTE_REQUEST_FAILED", text("本次登录授权已过期,请重新开始授权。", "This login authorization expired; start authorization again."), 1, [`${command} auth login`], { reason: "authorization_expired" });
190
192
  if (error instanceof RemoteRequestError
@@ -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
  : "无法自动打开浏览器,请手动访问授权链接。");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insmind/cli",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
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": "c1f9db85d5bf4c74b6b808bad8119c9c50b50970",
50
+ "pipelineId": "226274",
51
+ "pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/226274"
52
52
  }
53
53
  }
@@ -10,7 +10,7 @@
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