@gaoding/cli 1.6.1 → 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": "@gaoding/cli",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "description": "Gaoding command-line interface for agents and people.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -56,8 +56,8 @@
56
56
  "vitest": "4.1.10"
57
57
  },
58
58
  "gaodingRelease": {
59
- "sourceCommit": "aabd8273b44c48f7226609c37f81d8da1c0265da",
60
- "pipelineId": "225218",
61
- "pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/225218"
59
+ "sourceCommit": "c1f9db85d5bf4c74b6b808bad8119c9c50b50970",
60
+ "pipelineId": "226274",
61
+ "pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/226274"
62
62
  }
63
63
  }
@@ -1,7 +1,7 @@
1
1
  # 登录与组织
2
2
 
3
3
  1. 用 `gd-cli auth status` 检查登录状态;需要机器读取时使用 `--json`。
4
- 2. 未登录时执行 `gd-cli auth login`,按终端提示在浏览器完成授权;无法自动打开浏览器时使用 `--no-browser`。
4
+ 2. 千问办公桌面入口使用 `gd-cli auth init` 自动打开浏览器;打开失败按错误说明处理,不使用手动链接模式。普通 CLI 未登录时执行 `gd-cli auth login`,按终端提示在浏览器完成授权;无法自动打开浏览器时使用 `--no-browser`。
5
5
  3. 用 `gd-cli org list` 查看当前账号可用的组织,用 `gd-cli org current` 查看当前选择。
6
6
  4. 让用户从真实列表中选择,再执行 `gd-cli org switch --org <org-id>`;不要猜组织 ID。
7
7
  5. 用户要求退出或登录状态失效时执行 `gd-cli auth logout`;状态失效后重新登录。
@@ -8,9 +8,13 @@
8
8
  - 退出码 `130` 表示用户中断;立即停止,不自动重试。
9
9
  - `INSUFFICIENT_CREDITS` 表示当前组织稿豆不足;按 `error.details.next_steps` 引导用户前往 https://www.gaoding.art/pricing 购买稿豆,或执行 `gd-cli org switch` 切换到有可用稿豆的组织,处理后再重新发起创作。
10
10
 
11
+ ## 千问办公桌面连接器
12
+
13
+ 千问入口失败时,整个 stderr 是单个 `{code,message}` JSON,退出码含义保持不变。原生 CLI 的错误码、trace_id、任务 ID 和恢复步骤保留在 `message` 中,不读取不存在的 `error.details`。成功警告仍在 stderr。连接器的 `--version` 是上传包版本,底层 npm CLI 版本通过 `gd-cli --help` 查看;底层升级后重新读取 help 和 Schema。桌面登录使用 `gd-cli auth init`,自动打开浏览器失败会结束并报错,不使用 `--no-browser` 或等待聊天里出现授权链接。
14
+
11
15
  ## 创作输出丢失
12
16
 
13
- Agent 或 Tool 请求可能已经提交时,不因结果为空、耗时长或宿主显示执行结束就重新生成。原命令会在 stderr 提示任务 ID;执行会话仍可等待时继续等待,否则查询原调用:
17
+ Agent 或 Tool 请求可能已经提交时,不因结果为空、耗时长或宿主显示执行结束就重新生成。原生 CLI 会在 stderr 提示任务 ID,失败时已知 ID 也保留在错误恢复信息中;执行会话仍可等待时继续等待,否则查询原调用:
14
18
 
15
19
  ```bash
16
20
  gd-cli task list