@qoder-ai/qmind-cli 3.1.0 → 3.2.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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,26 @@ English (default) | [简体中文](CHANGELOG.zh-CN.md)
4
4
 
5
5
  Published versions below describe the Global CLI/shared implementation, not historical CN releases. CN will join the shared history with the future joint release.
6
6
 
7
+ ## 3.2.0
8
+
9
+ ### Minor Changes
10
+
11
+ - 7fd1634: Remove the top-level `compile` and `lint` commands and the `source import-site --compile-after-refresh` option, and make `task create` reject the `compilation` and `lint` scenes. `task list` and `task get` can still query historical runs; SDK, UI, backend automatic compilation, and internal capabilities are unchanged.
12
+
13
+ ### Changes without version bumps
14
+
15
+ - Show concise Preparing, Downloading with live transfer progress, and Installed stages in the native `qmind` and `qmind-cn` installers.
16
+
17
+ ## 3.1.1
18
+
19
+ ### Patch Changes
20
+
21
+ - a92c490: Add `update` and `update --check` for installer-managed Native CLI releases, with fixed Global/CN channels, release and installer checksum verification, downgrade protection, transactional replacement, and Windows post-exit update scheduling. npm-managed installations continue to return the appropriate npm upgrade command.
22
+
23
+ ### Changes without version bumps
24
+
25
+ - Add repository-maintained native CLI artifact generation, candidate orchestration, Bun compile, recoverable installers, strict offline handoff verification, and macOS, Windows, and Linux finalization capabilities. This does not change the existing npm-installed `qmind` or `qmind-cn` runtime behavior.
26
+
7
27
  ## 3.1.0
8
28
 
9
29
  ### Minor Changes
@@ -4,6 +4,26 @@
4
4
 
5
5
  以下已发布版本属于 Global CLI / 共享实现,不代表 CN 曾发布过这些版本。CN 将在后续共同发行版加入同一历史。
6
6
 
7
+ ## 3.2.0
8
+
9
+ ### Minor Changes
10
+
11
+ - 7fd1634: 移除顶层 `compile`、`lint` 命令及 `source import-site --compile-after-refresh` 选项,并让 `task create` 拒绝 `compilation` 与 `lint` 场景。`task list` 和 `task get` 仍可查询历史运行;SDK、UI、后端自动编译及内部能力不受影响。
12
+
13
+ ### Changes without version bumps
14
+
15
+ - 为 Native `qmind` 和 `qmind-cn` 安装器展示精简的 Preparing、带实时传输进度的 Downloading 和 Installed 三个阶段。
16
+
17
+ ## 3.1.1
18
+
19
+ ### Patch Changes
20
+
21
+ - a92c490: 为 installer 管理的 Native CLI release 增加 `update` 与 `update --check`,固定使用 Global/CN channel,校验 release 和 installer checksum,拒绝降级,复用事务式替换,并在 Windows 上于当前进程退出后调度更新。npm 管理的安装仍返回对应的 npm 升级命令。
22
+
23
+ ### Changes without version bumps
24
+
25
+ - 新增由仓库维护的 Native CLI 安装脚本制品生成、candidate 编排、Bun 编译、可恢复安装事务、严格离线 handoff 校验与 macOS、Windows、Linux finalization 能力;现有通过 npm 安装的 `qmind` 或 `qmind-cn` 运行时行为不变。
26
+
7
27
  ## 3.1.0
8
28
 
9
29
  ### Minor Changes
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [简体中文](./README.zh-CN.md)
4
4
 
5
- The QMind command-line interface for Qoder Global lets you sign in, manage knowledge bases and sources, retrieve content, run RAG and compilation workflows, and synchronize local directories.
5
+ The QMind command-line interface for Qoder Global lets you sign in, manage knowledge bases and sources, retrieve content, run RAG and task workflows, and synchronize local directories.
6
6
 
7
7
  Package: `@qoder-ai/qmind-cli` · command: `qmind`
8
8
 
@@ -23,6 +23,18 @@ npm update --global @qoder-ai/qmind-cli
23
23
  npm uninstall --global @qoder-ai/qmind-cli
24
24
  ```
25
25
 
26
+ The Native standalone CLI uses the verified Global release channel instead. An installer-managed
27
+ Native executable can check or apply the latest release without Node.js or npm:
28
+
29
+ ```sh
30
+ qmind update --check
31
+ qmind update
32
+ ```
33
+
34
+ `self-update` remains an alias for `update`. The updater rejects channel/URL overrides, downgrades,
35
+ unowned executables, release checksum mismatches, and modified installer bytes. Windows schedules
36
+ replacement after the running executable exits and records details beside the executable.
37
+
26
38
  ## Quick start
27
39
 
28
40
  ```sh
@@ -51,11 +63,13 @@ Do not put tokens in command arguments, repositories, or logs. Run `qmind logout
51
63
  | `source` | Manage knowledge-base sources |
52
64
  | `retrieve` | Retrieve context without invoking an LLM |
53
65
  | `rag` | Ask questions using a knowledge base |
54
- | `compile` / `lint` | Run compilation or validation workflows |
55
66
  | `task` | Manage task runs |
56
67
  | `upload-folder` / `sync` | Synchronize a local directory |
57
68
  | `image` | Obtain image upload or access URLs |
58
69
  | `version` | Print version and build information |
70
+ | `update` / `self-update` | Update an installer-managed Native CLI |
71
+
72
+ `task create` does not start `compilation` or `lint` runs; `task list` and `task get` can still inspect historical runs for those scenes. `source import-site` does not provide an automatic compilation option.
59
73
 
60
74
  Run `qmind <command> --help` for complete options. Domain commands support formats such as `table`, `json`, `agent`, and `ndjson`. stdout contains results; progress and diagnostics go to stderr. Exit codes are `0` for success, `1` for runtime failure/partial success/cancellation, and `2` for invalid usage.
61
75
 
package/README.zh-CN.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [English](./README.md)
4
4
 
5
- 面向 Qoder Global 的 QMind 命令行工具,可用于登录、管理知识库和来源、检索内容、运行 RAG/编译任务,以及把本地目录同步到知识库。
5
+ 面向 Qoder Global 的 QMind 命令行工具,可用于登录、管理知识库和来源、检索内容、运行 RAG 与任务工作流,以及把本地目录同步到知识库。
6
6
 
7
7
  npm 包:`@qoder-ai/qmind-cli` · 命令:`qmind`
8
8
 
@@ -23,6 +23,18 @@ npm update --global @qoder-ai/qmind-cli
23
23
  npm uninstall --global @qoder-ai/qmind-cli
24
24
  ```
25
25
 
26
+ Native standalone CLI 改为使用经过验证的 Global release channel。由官方 installer 管理的 Native
27
+ 可执行文件无需 Node.js 或 npm 即可检查并安装最新版本:
28
+
29
+ ```sh
30
+ qmind update --check
31
+ qmind update
32
+ ```
33
+
34
+ `self-update` 保留为 `update` 的别名。updater 会拒绝 channel/URL 覆盖、降级、非 installer
35
+ 管理的可执行文件、release 校验和冲突及被修改的 installer。Windows 会在当前进程退出后执行替换,
36
+ 并在可执行文件旁记录结果。
37
+
26
38
  ## 快速开始
27
39
 
28
40
  ```sh
@@ -44,18 +56,20 @@ qmind retrieve --nb <notebook-id> --format agent "部署流程是什么?"
44
56
 
45
57
  ## 命令
46
58
 
47
- | 命令 | 用途 |
48
- | ------------------------ | --------------------------- |
49
- | `login` / `logout` | 登录或清除本机凭证 |
50
- | `notebook` | 管理知识库 |
51
- | `source` | 管理知识库来源 |
52
- | `retrieve` | 检索上下文,不发起 LLM 调用 |
53
- | `rag` | 基于知识库提问 |
54
- | `compile` / `lint` | 运行编译或检查工作流 |
55
- | `task` | 管理任务运行 |
56
- | `upload-folder` / `sync` | 同步本地目录 |
57
- | `image` | 获取图片上传地址或访问地址 |
58
- | `version` | 查看版本和构建信息 |
59
+ | 命令 | 用途 |
60
+ | ------------------------ | -------------------------------- |
61
+ | `login` / `logout` | 登录或清除本机凭证 |
62
+ | `notebook` | 管理知识库 |
63
+ | `source` | 管理知识库来源 |
64
+ | `retrieve` | 检索上下文,不发起 LLM 调用 |
65
+ | `rag` | 基于知识库提问 |
66
+ | `task` | 管理任务运行 |
67
+ | `upload-folder` / `sync` | 同步本地目录 |
68
+ | `image` | 获取图片上传地址或访问地址 |
69
+ | `version` | 查看版本和构建信息 |
70
+ | `update` / `self-update` | 更新 installer 管理的 Native CLI |
71
+
72
+ `task create` 不会启动 `compilation` 或 `lint` 运行;仍可通过 `task list` 和 `task get` 查询这些场景的历史运行。`source import-site` 不提供自动编译选项。
59
73
 
60
74
  使用 `qmind <command> --help` 查看完整参数。领域命令支持 `table`、`json`、`agent`、`ndjson` 等输出格式。stdout 只输出结果,进度与诊断信息输出到 stderr。退出码 `0` 表示成功,`1` 表示运行失败、部分成功或取消,`2` 表示参数错误。
61
75
 
@@ -1,4 +1,4 @@
1
- import { Y as timestampSchema, a as invalidArgument, c as optionalRecord, d as pagination, h as requiredText, l as optionalString, m as requiredString, n as call, p as queryPath, r as compactUndefined, s as optionalBoolean, t as assertNonEmptyPatch, u as optionalTrimmedString } from "./shared-BkQJzIZF.js";
1
+ import { Y as timestampSchema, a as invalidArgument, c as optionalRecord, d as pagination, h as requiredText, l as optionalString, m as requiredString, n as call, p as queryPath, r as compactUndefined, s as optionalBoolean, t as assertNonEmptyPatch, u as optionalTrimmedString } from "./shared-OBSNlxAo.js";
2
2
  import { z } from "zod";
3
3
  //#region ../sdk/src/operations/bot-gateway-codecs.ts
4
4
  const botTimestamp = z.preprocess((value) => typeof value === "object" && value !== null && !Array.isArray(value) && !("seconds" in value) ? {
@@ -1,4 +1,4 @@
1
- import { S as cardSchema, a as invalidArgument, c as optionalRecord, d as pagination, g as stringList, h as requiredText, l as optionalString, m as requiredString, n as call, p as queryPath, r as compactUndefined, u as optionalTrimmedString, x as cardListSchema, y as batchMutationResultSchema } from "./shared-BkQJzIZF.js";
1
+ import { S as cardSchema, a as invalidArgument, c as optionalRecord, d as pagination, g as stringList, h as requiredText, l as optionalString, m as requiredString, n as call, p as queryPath, r as compactUndefined, u as optionalTrimmedString, x as cardListSchema, y as batchMutationResultSchema } from "./shared-OBSNlxAo.js";
2
2
  import { z } from "zod";
3
3
  //#region ../sdk/src/operations/compilation-results.ts
4
4
  function linksBody(value, field) {
@@ -1,4 +1,4 @@
1
- import { O as importProvidersSchema, _ as aliDingImportRunItemListSchema, a as invalidArgument, d as pagination, et as assertCapability, m as requiredString, n as call, p as queryPath, v as aliDingImportRunSchema } from "./shared-BkQJzIZF.js";
1
+ import { O as importProvidersSchema, _ as aliDingImportRunItemListSchema, a as invalidArgument, d as pagination, et as assertCapability, m as requiredString, n as call, p as queryPath, v as aliDingImportRunSchema } from "./shared-OBSNlxAo.js";
2
2
  //#region ../sdk/src/operations/imports.ts
3
3
  const aliDingHost = "alidocs.dingtalk.com";
4
4
  const requestIdPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;
@@ -1,4 +1,4 @@
1
- import { X as voidResponseSchema, a as invalidArgument, c as optionalRecord, l as optionalString, m as requiredString, n as call, r as compactUndefined, s as optionalBoolean, t as assertNonEmptyPatch } from "./shared-BkQJzIZF.js";
1
+ import { X as voidResponseSchema, a as invalidArgument, c as optionalRecord, l as optionalString, m as requiredString, n as call, r as compactUndefined, s as optionalBoolean, t as assertNonEmptyPatch } from "./shared-OBSNlxAo.js";
2
2
  import { z } from "zod";
3
3
  //#region ../sdk/src/operations/management-schemas.ts
4
4
  const memberPermissionSchema = z.enum([
@@ -1,4 +1,4 @@
1
- import { X as voidResponseSchema, Y as timestampSchema, c as optionalRecord, d as pagination, h as requiredText, l as optionalString, m as requiredString, n as call, p as queryPath, r as compactUndefined, t as assertNonEmptyPatch } from "./shared-BkQJzIZF.js";
1
+ import { X as voidResponseSchema, Y as timestampSchema, c as optionalRecord, d as pagination, h as requiredText, l as optionalString, m as requiredString, n as call, p as queryPath, r as compactUndefined, t as assertNonEmptyPatch } from "./shared-OBSNlxAo.js";
2
2
  import { z } from "zod";
3
3
  //#region ../sdk/src/operations/note-schemas.ts
4
4
  const noteSchema = z.object({
package/dist/qmind.js CHANGED
@@ -1,11 +1,11 @@
1
- import { A as notebookSchema, B as sourceSchema, C as chatMessageListSchema, D as imageUrlsSchema, E as imageUploadTicketSchema, F as sourceContentSchema, G as sourceWebOfficeTokenSchema, H as sourceUploadCapabilitiesSchema, I as sourceImportResultsSchema, J as taskRunSchema, K as streamWireEventSchema, L as sourceListSchema, M as sharedNotebookListSchema, N as sourceActionAccessSchema, P as sourceChildrenCountsSchema, R as sourcePreviewSchema, T as chatSessionSchema, V as sourceTreeSchema, W as sourceWebOfficeSessionSchema, X as voidResponseSchema, Z as wikiBranchListSchema, a as invalidArgument$1, b as cancelQuestionResultSchema, c as optionalRecord, d as pagination$1, et as assertCapability, f as positiveInteger$1, g as stringList, i as httpUrl, j as retrieveResultSchema, k as notebookListSchema, l as optionalString$1, m as requiredString$2, n as call, o as nonNegativeInteger$1, p as queryPath, q as taskRunListSchema, r as compactUndefined, rt as QMindError, s as optionalBoolean, t as assertNonEmptyPatch, tt as executeStream, u as optionalTrimmedString, w as chatSessionListSchema, y as batchMutationResultSchema, z as sourceRawContentSchema } from "./shared-BkQJzIZF.js";
2
- import { t as preflightSourceUpload } from "./source-upload-DBm1Hyki.js";
1
+ import { A as notebookSchema, B as sourceSchema, C as chatMessageListSchema, D as imageUrlsSchema, E as imageUploadTicketSchema, F as sourceContentSchema, G as sourceWebOfficeTokenSchema, H as sourceUploadCapabilitiesSchema, I as sourceImportResultsSchema, J as taskRunSchema, K as streamWireEventSchema, L as sourceListSchema, M as sharedNotebookListSchema, N as sourceActionAccessSchema, P as sourceChildrenCountsSchema, R as sourcePreviewSchema, T as chatSessionSchema, V as sourceTreeSchema, W as sourceWebOfficeSessionSchema, X as voidResponseSchema, Z as wikiBranchListSchema, a as invalidArgument$1, b as cancelQuestionResultSchema, c as optionalRecord, d as pagination$1, et as assertCapability, f as positiveInteger$1, g as stringList, i as httpUrl, j as retrieveResultSchema, k as notebookListSchema, l as optionalString$1, m as requiredString$2, n as call, o as nonNegativeInteger$1, p as queryPath, q as taskRunListSchema, r as compactUndefined, rt as QMindError, s as optionalBoolean, t as assertNonEmptyPatch, tt as executeStream, u as optionalTrimmedString, w as chatSessionListSchema, y as batchMutationResultSchema, z as sourceRawContentSchema } from "./shared-OBSNlxAo.js";
2
+ import { t as preflightSourceUpload } from "./source-upload-B0EAhkG2.js";
3
3
  import { createInterface } from "node:readline/promises";
4
4
  import { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
5
5
  import { z } from "zod";
6
6
  import { createHash, randomBytes } from "node:crypto";
7
- import { chmod, copyFile, link, lstat, mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
8
- import { homedir } from "node:os";
7
+ import { chmod, copyFile, link, lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
8
+ import { homedir, tmpdir } from "node:os";
9
9
  import lockfile from "proper-lockfile";
10
10
  import open from "open";
11
11
  import { createReadStream, createWriteStream } from "node:fs";
@@ -17,9 +17,12 @@ import { Command, CommanderError, Option } from "commander";
17
17
  import pLimit from "p-limit";
18
18
  import picomatch from "picomatch";
19
19
  import { decodeHTML } from "entities";
20
+ import { execFile, spawn } from "node:child_process";
21
+ import { promisify } from "node:util";
22
+ import semver from "semver";
20
23
  //#region ../sdk/src/operations/agents.ts
21
24
  const workflowPrompt = "Follow the system prompt strictly: use the provided tools to discover, process and prepare the result, then emit the final report. Do NOT greet, do NOT ask for clarification — act immediately.";
22
- function isRecord$2(value) {
25
+ function isRecord$3(value) {
23
26
  return typeof value === "object" && value !== null && !Array.isArray(value);
24
27
  }
25
28
  function finiteNumber(value, field) {
@@ -63,7 +66,7 @@ function billingContext(value) {
63
66
  });
64
67
  }
65
68
  function retrieveBody(input) {
66
- if (!isRecord$2(input)) throw invalidArgument$1("input must be an object", "input");
69
+ if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
67
70
  return compactUndefined({
68
71
  billingContext: billingContext(input.billingContext),
69
72
  maxResults: nonNegativeInteger$1(input.maxResults, "maxResults"),
@@ -75,7 +78,7 @@ function retrieveBody(input) {
75
78
  });
76
79
  }
77
80
  function chatSessionBody(input = {}) {
78
- if (!isRecord$2(input)) throw invalidArgument$1("input must be an object", "input");
81
+ if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
79
82
  return compactUndefined({
80
83
  metadata: optionalRecord(input.metadata, "metadata"),
81
84
  modelOverride: optionalTrimmedString(input.modelOverride, "modelOverride"),
@@ -85,7 +88,7 @@ function chatSessionBody(input = {}) {
85
88
  });
86
89
  }
87
90
  function streamBody(input) {
88
- if (!isRecord$2(input)) throw invalidArgument$1("input must be an object", "input");
91
+ if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
89
92
  return compactUndefined({
90
93
  content: requiredString$2(input.content, "content"),
91
94
  maxResults: nonNegativeInteger$1(input.maxResults, "maxResults"),
@@ -96,7 +99,7 @@ function streamBody(input) {
96
99
  });
97
100
  }
98
101
  function taskRunBody(input) {
99
- if (!isRecord$2(input)) throw invalidArgument$1("input must be an object", "input");
102
+ if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
100
103
  return compactUndefined({
101
104
  chatSessionId: optionalTrimmedString(input.chatSessionId, "chatSessionId"),
102
105
  config: optionalRecord(input.config, "config"),
@@ -109,7 +112,7 @@ function taskRunBody(input) {
109
112
  });
110
113
  }
111
114
  function taskRunListPath(context, notebookId, input = {}) {
112
- if (!isRecord$2(input)) throw invalidArgument$1("input must be an object", "input");
115
+ if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
113
116
  const normalizedPage = pagination$1(input);
114
117
  const status = optionalTrimmedString(input.status, "status");
115
118
  if (status !== void 0 && ![
@@ -216,7 +219,7 @@ function createAgentOperations(context) {
216
219
  const cancelQuestionFor = (notebookId, sessionId, input = {}, options, featured = false) => {
217
220
  const notebook = requiredString$2(notebookId, "notebookId");
218
221
  const session = requiredString$2(sessionId, "sessionId");
219
- if (!isRecord$2(input)) throw invalidArgument$1("input must be an object", "input");
222
+ if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
220
223
  return call(context, {
221
224
  body: compactUndefined({ reason: optionalTrimmedString(input.reason, "reason") }),
222
225
  callOptions: options,
@@ -275,7 +278,7 @@ function createAgentOperations(context) {
275
278
  });
276
279
  };
277
280
  const startAgentRunFor = async (notebookId, input, options, featured) => {
278
- if (!isRecord$2(input)) throw invalidArgument$1("input must be an object", "input");
281
+ if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
279
282
  if (input.scene !== "rag" && input.scene !== "compilation" && input.scene !== "lint") throw invalidArgument$1("scene must be rag, compilation or lint", "scene");
280
283
  const notebook = requiredString$2(notebookId, "notebookId");
281
284
  const scene = input.scene;
@@ -511,6 +514,84 @@ function createNotebookOperations(context) {
511
514
  };
512
515
  }
513
516
  //#endregion
517
+ //#region ../sdk/src/source-email-folder.ts
518
+ /** The email aggregate directory marker shared by tree projection and source readers. */
519
+ function isQMindEmailFolder(source) {
520
+ return source?.isDir === true && source.metadata?.emailFolder === true;
521
+ }
522
+ //#endregion
523
+ //#region ../sdk/src/sources.ts
524
+ function metadataOf(source) {
525
+ const metadata = source?.metadata;
526
+ return metadata !== null && typeof metadata === "object" ? metadata : {};
527
+ }
528
+ function isRecord$2(value) {
529
+ return typeof value === "object" && value !== null && !Array.isArray(value);
530
+ }
531
+ function text(value) {
532
+ return typeof value === "string" ? value : "";
533
+ }
534
+ function metadataText(source, ...keys) {
535
+ const metadata = metadataOf(source);
536
+ for (const key of keys) {
537
+ const value = metadata[key];
538
+ if (typeof value === "string" && value.trim().length > 0) return value.trim();
539
+ }
540
+ return "";
541
+ }
542
+ /**
543
+ * The canonical stored format of a source, which QMind reports separately from the MIME type
544
+ * because one MIME type can back several formats.
545
+ */
546
+ function qmindSourceFormat(source) {
547
+ const format = metadataText(source, "sourceFormat", "source_format").toLowerCase().replace(/^\./, "");
548
+ if (format === "markdown" || format === "mdown" || format === "mdx") return "md";
549
+ return format === "htm" ? "html" : format;
550
+ }
551
+ function isQMindEmailSource(source) {
552
+ return source?.sourceType.toLowerCase() === "email" && qmindSourceFormat(source) === "eml";
553
+ }
554
+ function qmindEmailAttachmentRef(source) {
555
+ const value = metadataOf(source).emailAttachment;
556
+ if (!isRecord$2(value)) return null;
557
+ return Object.freeze({
558
+ emailSourceId: text(value.emailSourceId),
559
+ index: typeof value.index === "number" && Number.isFinite(value.index) ? Math.floor(value.index) : -1,
560
+ parentSentAt: text(value.parentSentAt),
561
+ parentSubject: text(value.parentSubject)
562
+ });
563
+ }
564
+ /** The id of the email body source this source belongs to, or '' when it is not part of an email. */
565
+ function qmindEmailSourceId(source) {
566
+ if (isQMindEmailFolder(source)) return text(metadataOf(source).emailSourceId);
567
+ const attachment = qmindEmailAttachmentRef(source);
568
+ if (attachment !== null) return attachment.emailSourceId;
569
+ return isQMindEmailSource(source) ? source?.id ?? "" : "";
570
+ }
571
+ /**
572
+ * A body and its attachments cannot leave their email folder, because the folder is what carries
573
+ * the email identity.
574
+ */
575
+ function isQMindEmailAggregateMember(source, siblings) {
576
+ if (source === null || source === void 0 || isQMindEmailFolder(source)) return false;
577
+ if (qmindEmailAttachmentRef(source) !== null) return true;
578
+ if (!isQMindEmailSource(source) || source.parentSourceId.length === 0) return false;
579
+ const parent = siblings.find((item) => item.id === source.parentSourceId);
580
+ return isQMindEmailFolder(parent) && qmindEmailSourceId(parent) === source.id;
581
+ }
582
+ /** The external provider that owns this source, lowercased, or '' when QMind owns it. */
583
+ function qmindSourceProvider(source) {
584
+ return (source?.externalBinding?.provider ?? metadataText(source, "externalProvider", "external_provider")).toLowerCase();
585
+ }
586
+ /**
587
+ * `externalBinding` is authoritative; the metadata fallback keeps sources readable on gateways that
588
+ * do not project the binding yet.
589
+ */
590
+ function isQMindExternalSource(source) {
591
+ return source?.externalBinding !== void 0 || qmindSourceProvider(source) === "aliding";
592
+ }
593
+ [.../* @__PURE__ */ new Set(["axls", "alxs"])];
594
+ //#endregion
514
595
  //#region ../sdk/src/operations/sources.ts
515
596
  const maxImageBytes = 52428800;
516
597
  function sourceTreeNodeOrder(left, right) {
@@ -539,6 +620,11 @@ function buildSourceTree(sources) {
539
620
  const parentIds = new Set(sources.filter((source) => sourcesById.has(source.parentSourceId) && !createsSourceCycle(source, sourcesById)).map((source) => source.parentSourceId));
540
621
  const nodesById = /* @__PURE__ */ new Map();
541
622
  for (const source of sources) nodesById.set(source.id, {
623
+ ...source.externalBinding === void 0 ? {} : { externalBinding: source.externalBinding },
624
+ ...source.originUrl === void 0 ? {} : { originUrl: source.originUrl },
625
+ isEmailFolder: isQMindEmailFolder(source),
626
+ isEmailAggregateMember: isQMindEmailAggregateMember(source, sources),
627
+ isExternalSource: isQMindExternalSource(source),
542
628
  files: [],
543
629
  hasChildren: source.hasChildren ?? (source.childrenCount === void 0 ? source.isDir : source.childrenCount > 0),
544
630
  id: source.id,
@@ -1466,7 +1552,7 @@ const botGatewayOperationNames = [
1466
1552
  function createLazyTransferOperations(context) {
1467
1553
  let operations;
1468
1554
  const load = () => {
1469
- operations ??= import("./transfers-F1ZLLBdU.js").then(({ createTransferOperations }) => createTransferOperations(context));
1555
+ operations ??= import("./transfers-BB__MPG8.js").then(({ createTransferOperations }) => createTransferOperations(context));
1470
1556
  return operations;
1471
1557
  };
1472
1558
  return {
@@ -1477,7 +1563,7 @@ function createLazyTransferOperations(context) {
1477
1563
  function createLazyBotGatewayOperations(context) {
1478
1564
  let operations;
1479
1565
  const load = () => {
1480
- operations ??= import("./bot-gateway-Hzjl50zu.js").then(({ createBotGatewayOperations }) => createBotGatewayOperations(context));
1566
+ operations ??= import("./bot-gateway-C3AvO7gR.js").then(({ createBotGatewayOperations }) => createBotGatewayOperations(context));
1481
1567
  return operations;
1482
1568
  };
1483
1569
  return Object.fromEntries(botGatewayOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
@@ -1485,7 +1571,7 @@ function createLazyBotGatewayOperations(context) {
1485
1571
  function createLazyNoteOperations(context) {
1486
1572
  let operations;
1487
1573
  const load = () => {
1488
- operations ??= import("./notes-BvucEfdi.js").then(({ createNoteOperations }) => createNoteOperations(context));
1574
+ operations ??= import("./notes-BWrCOixr.js").then(({ createNoteOperations }) => createNoteOperations(context));
1489
1575
  return operations;
1490
1576
  };
1491
1577
  return Object.fromEntries(noteOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
@@ -1493,7 +1579,7 @@ function createLazyNoteOperations(context) {
1493
1579
  function createLazyCardOperations(context) {
1494
1580
  let operations;
1495
1581
  const load = () => {
1496
- operations ??= import("./cards-DsMbd-g1.js").then(({ createCardOperations }) => createCardOperations(context));
1582
+ operations ??= import("./cards-D3WYzf7s.js").then(({ createCardOperations }) => createCardOperations(context));
1497
1583
  return operations;
1498
1584
  };
1499
1585
  return Object.fromEntries(cardOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
@@ -1501,7 +1587,7 @@ function createLazyCardOperations(context) {
1501
1587
  function createLazyImportOperations(context) {
1502
1588
  let operations;
1503
1589
  const load = () => {
1504
- operations ??= import("./imports-B01ERZgD.js").then(({ createImportOperations }) => createImportOperations(context));
1590
+ operations ??= import("./imports-D6n1sOFM.js").then(({ createImportOperations }) => createImportOperations(context));
1505
1591
  return operations;
1506
1592
  };
1507
1593
  return Object.fromEntries(importOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
@@ -1509,7 +1595,7 @@ function createLazyImportOperations(context) {
1509
1595
  function createLazyManagementOperations(context) {
1510
1596
  let operations;
1511
1597
  const load = () => {
1512
- operations ??= import("./management-BIYQa9Al.js").then(({ createManagementOperations }) => createManagementOperations(context));
1598
+ operations ??= import("./management-uK44XohU.js").then(({ createManagementOperations }) => createManagementOperations(context));
1513
1599
  return operations;
1514
1600
  };
1515
1601
  return Object.fromEntries(managementOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
@@ -1579,12 +1665,12 @@ function errorCodeForStatus(status) {
1579
1665
  if (status >= 400 && status < 500) return "INVALID_ARGUMENT";
1580
1666
  return "REMOTE_ERROR";
1581
1667
  }
1582
- function record$1(value) {
1668
+ function record$2(value) {
1583
1669
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
1584
1670
  }
1585
1671
  function responseString(response, ...keys) {
1586
- const body = record$1(response.body);
1587
- const nestedError = record$1(body?.error);
1672
+ const body = record$2(response.body);
1673
+ const nestedError = record$2(body?.error);
1588
1674
  for (const source of [body, nestedError]) for (const key of keys) {
1589
1675
  const value = source?.[key];
1590
1676
  if (typeof value === "string" && value.length > 0) return value;
@@ -2691,40 +2777,43 @@ function createQMindNodeTransport(options) {
2691
2777
  const url = requestUrl(origin, request$2);
2692
2778
  const attempts = request$2.idempotent ? maxRetries + 1 : 1;
2693
2779
  let lastFailure;
2694
- let lastDeadlineExpired = false;
2695
- for (let attempt = 0; attempt < attempts; attempt += 1) {
2696
- const deadline = requestDeadline(request$2.signal, request$2.timeoutMs ?? requestTimeoutMs);
2697
- try {
2780
+ const timeoutMs = request$2.timeoutMs ?? requestTimeoutMs;
2781
+ const deadline = requestDeadline(request$2.signal, timeoutMs);
2782
+ try {
2783
+ for (let attempt = 0; attempt < attempts; attempt += 1) try {
2698
2784
  debugRequest(options, request$2, url);
2699
2785
  const encoded = encodeBody(request$2, `----qmind-${randomBytes(18).toString("hex")}`);
2700
2786
  const response = await request(url, {
2701
2787
  ...encoded.body === void 0 ? {} : { body: encoded.body },
2702
- bodyTimeout: request$2.timeoutMs ?? requestTimeoutMs,
2788
+ bodyTimeout: timeoutMs,
2703
2789
  dispatcher: dispatcherFor(request$2),
2704
2790
  headers: encoded.headers,
2705
- headersTimeout: request$2.timeoutMs ?? requestTimeoutMs,
2791
+ headersTimeout: timeoutMs,
2706
2792
  idempotent: request$2.idempotent,
2707
2793
  method: request$2.method,
2708
2794
  signal: deadline.signal
2709
2795
  });
2710
2796
  if (attempt + 1 < attempts && RETRYABLE_STATUS.has(response.statusCode)) {
2711
2797
  await response.body.dump();
2712
- await abortableSleep(250 * 2 ** attempt, request$2.signal);
2798
+ await abortableSleep(250 * 2 ** attempt, deadline.signal);
2713
2799
  continue;
2714
2800
  }
2715
2801
  return await wireResponse(response);
2716
2802
  } catch (cause) {
2717
2803
  lastFailure = cause;
2718
- lastDeadlineExpired = deadline.timedOut;
2719
- if (attempt + 1 < attempts && request$2.signal?.aborted !== true) {
2720
- await abortableSleep(250 * 2 ** attempt, request$2.signal);
2721
- continue;
2804
+ if (attempt + 1 >= attempts || request$2.signal?.aborted === true || deadline.timedOut) break;
2805
+ try {
2806
+ await abortableSleep(250 * 2 ** attempt, deadline.signal);
2807
+ } catch (backoffCause) {
2808
+ lastFailure = backoffCause;
2809
+ break;
2722
2810
  }
2723
- } finally {
2724
- deadline.dispose();
2811
+ continue;
2725
2812
  }
2813
+ throw transportFailure(request$2, lastFailure, deadline.timedOut);
2814
+ } finally {
2815
+ deadline.dispose();
2726
2816
  }
2727
- throw transportFailure(request$2, lastFailure, lastDeadlineExpired);
2728
2817
  },
2729
2818
  async stream(request$3) {
2730
2819
  assertWireRequest(request$3);
@@ -2969,8 +3058,8 @@ function requestsJsonOutput(argv) {
2969
3058
  //#region src/build-info.ts
2970
3059
  /** Bundled identity, never inferred from argv, environment, or an endpoint. */
2971
3060
  const QMIND_CLI_DISTRIBUTION = "global";
2972
- const QMIND_CLI_VERSION = "3.1.0";
2973
- const QMIND_CLI_BUILD_TIME = "2026-09-01T12:26:44.000Z";
3061
+ const QMIND_CLI_VERSION = "3.2.0";
3062
+ const QMIND_CLI_BUILD_TIME = "2026-09-07T06:53:56.000Z";
2974
3063
  function qmindCliPlatform() {
2975
3064
  return process.platform === "win32" ? "windows" : process.platform;
2976
3065
  }
@@ -2986,6 +3075,7 @@ const CLI_DISTRIBUTIONS = Object.freeze({
2986
3075
  command: "qmind",
2987
3076
  package: "@qoder-ai/qmind-cli",
2988
3077
  productId: "qoder",
3078
+ nativePublicRoot: "https://download.qoder.com/qmind-cli",
2989
3079
  gitTagSlug: "qmind-cli",
2990
3080
  readmeDirectory: ".",
2991
3081
  productNames: {
@@ -2998,6 +3088,7 @@ const CLI_DISTRIBUTIONS = Object.freeze({
2998
3088
  command: "qmind-cn",
2999
3089
  package: "@qodercn-ai/qmind-cli",
3000
3090
  productId: "qoder-cn",
3091
+ nativePublicRoot: "https://static.qoder.com.cn/qmind-cli-cn",
3001
3092
  gitTagSlug: "qmind-cli-cn",
3002
3093
  readmeDirectory: "readmes/cn",
3003
3094
  productNames: {
@@ -3065,7 +3156,7 @@ function validateMapping(value) {
3065
3156
  }
3066
3157
  return result;
3067
3158
  }
3068
- async function sha256(path) {
3159
+ async function sha256$1(path) {
3069
3160
  const hash = createHash("sha256");
3070
3161
  for await (const chunk of createReadStream(path)) hash.update(chunk);
3071
3162
  return hash.digest("hex");
@@ -3116,7 +3207,7 @@ function createNodeQMindFolderSyncFileSystem() {
3116
3207
  skipped
3117
3208
  };
3118
3209
  },
3119
- sha256,
3210
+ sha256: sha256$1,
3120
3211
  async writeMapping(path, mapping) {
3121
3212
  await mkdir(dirname(path), { recursive: true });
3122
3213
  await writeFile(path, `${JSON.stringify(mapping, null, 2)}\n`, { mode: 384 });
@@ -3357,7 +3448,7 @@ function parseQMindCliOutputFormat(value) {
3357
3448
  if (value === "json" || value === "agent" || value === "ndjson") return value;
3358
3449
  return "table";
3359
3450
  }
3360
- function record(value) {
3451
+ function record$1(value) {
3361
3452
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
3362
3453
  }
3363
3454
  function stringValue(value) {
@@ -3408,12 +3499,12 @@ function timestamp(value) {
3408
3499
  return (/* @__PURE__ */ new Date(parsed.seconds * 1e3)).toISOString().replace(".000Z", "Z");
3409
3500
  }
3410
3501
  function optionalMap(value) {
3411
- const result = record(value);
3502
+ const result = record$1(value);
3412
3503
  return Object.keys(result).length === 0 ? void 0 : result;
3413
3504
  }
3414
3505
  function pagination(value) {
3415
3506
  if (value === void 0 || value === null) return "";
3416
- const page = record(value);
3507
+ const page = record$1(value);
3417
3508
  if ([
3418
3509
  page.totalSize,
3419
3510
  page.currentPage,
@@ -3423,7 +3514,7 @@ function pagination(value) {
3423
3514
  return ` (server totalSize=${numberValue(page.totalSize)}, page=${numberValue(page.currentPage)}/${numberValue(page.lastPage)}, pageSize=${numberValue(page.pageSize)})`;
3424
3515
  }
3425
3516
  function goNotebook(value) {
3426
- const source = record(value);
3517
+ const source = record$1(value);
3427
3518
  const settings = optionalMap(source.settings);
3428
3519
  return {
3429
3520
  id: stringValue(source.id),
@@ -3448,7 +3539,7 @@ function goNotebookList(value) {
3448
3539
  }
3449
3540
  function goPage(value) {
3450
3541
  if (value === void 0 || value === null) return void 0;
3451
- const source = record(value);
3542
+ const source = record$1(value);
3452
3543
  return {
3453
3544
  prevPage: numberValue(source.prevPage),
3454
3545
  currentPage: numberValue(source.currentPage),
@@ -3460,7 +3551,7 @@ function goPage(value) {
3460
3551
  };
3461
3552
  }
3462
3553
  function goSource(value) {
3463
- const source = record(value);
3554
+ const source = record$1(value);
3464
3555
  const metadata = optionalMap(source.metadata);
3465
3556
  return {
3466
3557
  id: stringValue(source.id),
@@ -4007,6 +4098,182 @@ function createQMindCliStreamRenderer(format) {
4007
4098
  };
4008
4099
  }
4009
4100
  //#endregion
4101
+ //#region src/update.ts
4102
+ const execFileAsync = promisify(execFile);
4103
+ const SHA256 = /^[a-f0-9]{64}$/u;
4104
+ const MAX_CHANNEL_BYTES = 65536;
4105
+ const MAX_RELEASE_BYTES = 4194304;
4106
+ const MAX_INSTALLER_BYTES = 1048576;
4107
+ function sha256(bytes) {
4108
+ return createHash("sha256").update(bytes).digest("hex");
4109
+ }
4110
+ function record(value, label) {
4111
+ if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label} is invalid`);
4112
+ return value;
4113
+ }
4114
+ function string(value, label) {
4115
+ if (typeof value !== "string" || value.length === 0) throw new Error(`${label} is invalid`);
4116
+ return value;
4117
+ }
4118
+ async function boundedBytes(fetcher, url, limit, label) {
4119
+ const response = await fetcher(url, {
4120
+ redirect: "error",
4121
+ signal: AbortSignal.timeout(3e4)
4122
+ });
4123
+ if (!response.ok) throw new Error(`${label} request failed with HTTP ${response.status}`);
4124
+ if (response.url.length > 0 && response.url !== url) throw new Error(`${label} redirected`);
4125
+ const declared = Number(response.headers.get("content-length"));
4126
+ if (Number.isFinite(declared) && declared > limit) throw new Error(`${label} is too large`);
4127
+ const bytes = Buffer.from(await response.arrayBuffer());
4128
+ if (bytes.length === 0 || bytes.length > limit) throw new Error(`${label} is too large`);
4129
+ return bytes;
4130
+ }
4131
+ function parseJson(bytes, label) {
4132
+ try {
4133
+ return record(JSON.parse(bytes.toString("utf8")), label);
4134
+ } catch {
4135
+ throw new Error(`${label} is invalid`);
4136
+ }
4137
+ }
4138
+ function channelFrom(bytes, identity) {
4139
+ const channel = parseJson(bytes, "native update channel");
4140
+ const release = record(channel.release, "native update channel release");
4141
+ const version = string(channel.version, "native update channel version");
4142
+ const releaseSha256 = string(release.sha256, "native update release checksum");
4143
+ const releaseKey = string(release.key, "native update release key");
4144
+ if (channel.schema !== "qmind-native-channel-v1" || channel.distribution !== identity.distribution || semver.valid(version) !== version || !SHA256.test(releaseSha256) || releaseKey !== `releases/${version}/release.json` || channel.releaseSetId !== `${identity.distribution}/v${version}/${releaseSha256}`) throw new Error("native update channel identity rejected");
4145
+ return {
4146
+ releaseKey,
4147
+ releaseSha256,
4148
+ version
4149
+ };
4150
+ }
4151
+ function installerFrom(bytes, identity, version) {
4152
+ const release = parseJson(bytes, "native update release");
4153
+ if (release.schema !== "qmind-native-release-v1" || release.distribution !== identity.distribution || release.version !== version || !Array.isArray(release.artifacts)) throw new Error("native update release identity rejected");
4154
+ const selector = identity.platform === "win32" ? "ps1" : "sh";
4155
+ const expectedBasename = `${identity.command}-install-v${version}.${selector}`;
4156
+ const matches = release.artifacts.filter((value) => {
4157
+ const artifact = record(value, "native update artifact");
4158
+ return artifact.role === "script" && artifact.selector === selector && artifact.basename === expectedBasename && Number.isSafeInteger(artifact.size) && typeof artifact.sha256 === "string" && SHA256.test(artifact.sha256);
4159
+ });
4160
+ if (matches.length !== 1) throw new Error("native update installer is missing or ambiguous");
4161
+ const artifact = matches[0];
4162
+ return {
4163
+ basename: expectedBasename,
4164
+ sha256: artifact.sha256,
4165
+ size: artifact.size
4166
+ };
4167
+ }
4168
+ async function executeNativeInstaller(input) {
4169
+ const executableName = input.platform === "win32" ? `${input.command}.exe` : input.command;
4170
+ const actualName = basename(input.executablePath);
4171
+ if (input.platform === "win32" ? actualName.toLowerCase() !== executableName.toLowerCase() : actualName !== executableName) throw new Error("native update requires an installer-managed executable");
4172
+ const installDirectory = dirname(input.executablePath);
4173
+ const temporary = await mkdtemp(join(tmpdir(), `${input.command}-update-`));
4174
+ const extension = input.platform === "win32" ? "ps1" : "sh";
4175
+ const installerPath = join(temporary, `installer.${extension}`);
4176
+ await writeFile(installerPath, input.bytes, { mode: 384 });
4177
+ if (input.platform !== "win32") try {
4178
+ await execFileAsync("/bin/sh", [
4179
+ installerPath,
4180
+ "--artifact-root",
4181
+ input.artifactRoot,
4182
+ "--install-dir",
4183
+ installDirectory
4184
+ ], {
4185
+ maxBuffer: 1048576,
4186
+ timeout: 3e5
4187
+ });
4188
+ return { status: "completed" };
4189
+ } finally {
4190
+ await rm(temporary, {
4191
+ force: true,
4192
+ recursive: true
4193
+ });
4194
+ }
4195
+ const wrapperPath = join(temporary, "apply-update.ps1");
4196
+ const logPath = join(installDirectory, `.${input.command}.update.log`);
4197
+ await writeFile(wrapperPath, `#Requires -Version 5.1\nparam([int]$ParentProcessId,[string]$InstallerPath,[string]$ArtifactRoot,[string]$InstallDirectory,[string]$LogPath,[string]$TemporaryDirectory)\n$ErrorActionPreference = "Stop"\ntry {\n Wait-Process -Id $ParentProcessId -ErrorAction SilentlyContinue\n & $InstallerPath -ArtifactRoot $ArtifactRoot -InstallDir $InstallDirectory *>&1 | Out-File -LiteralPath $LogPath -Encoding utf8\n} catch {\n $_ | Out-File -LiteralPath $LogPath -Encoding utf8\n} finally {\n Remove-Item -LiteralPath $TemporaryDirectory -Recurse -Force -ErrorAction SilentlyContinue\n}\n`, { mode: 384 });
4198
+ const child = spawn("powershell.exe", [
4199
+ "-NoLogo",
4200
+ "-NoProfile",
4201
+ "-ExecutionPolicy",
4202
+ "Bypass",
4203
+ "-File",
4204
+ wrapperPath,
4205
+ String(process.pid),
4206
+ installerPath,
4207
+ input.artifactRoot,
4208
+ installDirectory,
4209
+ logPath,
4210
+ temporary
4211
+ ], {
4212
+ detached: true,
4213
+ stdio: "ignore",
4214
+ windowsHide: true
4215
+ });
4216
+ await new Promise((resolvePromise, reject) => {
4217
+ child.once("spawn", resolvePromise);
4218
+ child.once("error", reject);
4219
+ });
4220
+ child.unref();
4221
+ return {
4222
+ status: "scheduled",
4223
+ logPath
4224
+ };
4225
+ }
4226
+ function createQMindCliUpdater(options) {
4227
+ const { identity } = options;
4228
+ const fetcher = options.fetcher ?? fetch;
4229
+ const executeInstaller = options.executeInstaller ?? executeNativeInstaller;
4230
+ return Object.freeze({ async run({ check }) {
4231
+ if (identity.artifactKind === "npm") return {
4232
+ status: "unsupported",
4233
+ command: `npm update --global ${identity.package}`
4234
+ };
4235
+ const channelUrl = `${identity.publicRoot}/latest/channel`;
4236
+ const channel = channelFrom(await boundedBytes(fetcher, channelUrl, MAX_CHANNEL_BYTES, "native update channel"), identity);
4237
+ const releaseUrl = `${identity.publicRoot}/${channel.releaseKey}`;
4238
+ const releaseBytes = await boundedBytes(fetcher, releaseUrl, MAX_RELEASE_BYTES, "native update release");
4239
+ if (sha256(releaseBytes) !== channel.releaseSha256) throw new Error("native update release checksum mismatch");
4240
+ const installer = installerFrom(releaseBytes, identity, channel.version);
4241
+ const comparison = semver.compare(channel.version, identity.currentVersion);
4242
+ if (comparison < 0) throw new Error("native update channel would downgrade the current version");
4243
+ if (comparison === 0) return {
4244
+ status: "up-to-date",
4245
+ currentVersion: identity.currentVersion,
4246
+ latestVersion: channel.version
4247
+ };
4248
+ if (check) return {
4249
+ status: "available",
4250
+ currentVersion: identity.currentVersion,
4251
+ latestVersion: channel.version
4252
+ };
4253
+ const artifactRoot = `${identity.publicRoot}/releases/${channel.version}`;
4254
+ const installerBytes = await boundedBytes(fetcher, `${artifactRoot}/${installer.basename}`, MAX_INSTALLER_BYTES, "native update installer");
4255
+ if (installerBytes.length !== installer.size || sha256(installerBytes) !== installer.sha256) throw new Error("native update installer checksum mismatch");
4256
+ const execution = await executeInstaller({
4257
+ artifactRoot,
4258
+ bytes: installerBytes,
4259
+ command: identity.command,
4260
+ executablePath: identity.executablePath,
4261
+ platform: identity.platform,
4262
+ version: channel.version
4263
+ });
4264
+ return execution.status === "scheduled" ? {
4265
+ status: "scheduled",
4266
+ currentVersion: identity.currentVersion,
4267
+ latestVersion: channel.version,
4268
+ logPath: execution.logPath ?? join(dirname(identity.executablePath), `.${identity.command}.update.log`)
4269
+ } : {
4270
+ status: "updated",
4271
+ currentVersion: identity.currentVersion,
4272
+ latestVersion: channel.version
4273
+ };
4274
+ } });
4275
+ }
4276
+ //#endregion
4010
4277
  //#region src/application.ts
4011
4278
  const distribution = CLI_DISTRIBUTIONS[QMIND_CLI_DISTRIBUTION];
4012
4279
  function processIO() {
@@ -4279,11 +4546,10 @@ function registerSourceCommands(context, program) {
4279
4546
  await host.client.deleteSource(notebookId, sourceId);
4280
4547
  context.io.stdout("deleted\n");
4281
4548
  });
4282
- withCommon(source.command("import-site").description("Import a complete web site")).option("--nb <id>", "notebook ID (required)").option("--url <url>", "site root URL (required)").option("--title <title>", "source title").option("--parent <id>", "parent source ID", "").option("--path-prefix <path>", "path prefix", "").option("--max-pages <number>", "maximum page count", integer, 50).option("--sitemap <url>", "sitemap URL", "").option("--include <patterns>", "comma-separated include patterns", "").option("--exclude <patterns>", "comma-separated exclude patterns", "").option("--compile-after-refresh", "enqueue compilation after import").action(async (raw) => {
4549
+ withCommon(source.command("import-site").description("Import a complete web site")).option("--nb <id>", "notebook ID (required)").option("--url <url>", "site root URL (required)").option("--title <title>", "source title").option("--parent <id>", "parent source ID", "").option("--path-prefix <path>", "path prefix", "").option("--max-pages <number>", "maximum page count", integer, 50).option("--sitemap <url>", "sitemap URL", "").option("--include <patterns>", "comma-separated include patterns", "").option("--exclude <patterns>", "comma-separated exclude patterns", "").action(async (raw) => {
4283
4550
  const host = await hostFor(context, raw);
4284
4551
  const rootUrl = requiredString(raw.url, "--url");
4285
4552
  const value = await host.client.importSite(requiredString(raw.nb, "--nb"), {
4286
- compileAfterRefresh: raw.compileAfterRefresh === true,
4287
4553
  excludePaths: splitCsv(stringOption(raw, "exclude")),
4288
4554
  includePaths: splitCsv(stringOption(raw, "include")),
4289
4555
  maxPages: numberOption(raw, "maxPages", 50),
@@ -4350,20 +4616,19 @@ function registerSceneCommands(context, program) {
4350
4616
  topK: numberOption(raw, "topK", 0)
4351
4617
  });
4352
4618
  });
4353
- for (const [name, scene] of [["compile", "compilation"], ["lint", "lint"]]) withCommon(program.command(name).description(`Run notebook ${scene}`)).option("--nb <id>", "notebook ID (required)").action(async (raw) => {
4354
- await renderAgentRun(context, await hostFor(context, raw), requiredString(raw.nb, "--nb"), raw, { scene });
4355
- });
4356
4619
  }
4357
4620
  function registerTaskCommands(context, program) {
4358
4621
  const task = program.command("task").description("Manage notebook task runs");
4359
- withCommon(task.command("create").description("Create a notebook task run")).option("--nb <id>", "notebook ID (required)").option("--scene <scene>", "task scene: compilation | source_refresh | condensation | lint").option("--trigger <trigger>", "task trigger", "manual").option("--sources <ids>", "comma-separated source IDs", "").action(async (raw) => {
4622
+ withCommon(task.command("create").description("Create a notebook task run")).option("--nb <id>", "notebook ID (required)").option("--scene <scene>", "task scene (required)").option("--trigger <trigger>", "task trigger", "manual").option("--sources <ids>", "comma-separated source IDs", "").action(async (raw) => {
4623
+ const scene = requiredString(raw.scene, "--scene").trim();
4624
+ if (scene === "compilation" || scene === "lint") throw new QMindError("INVALID_ARGUMENT", `task creation does not support scene ${JSON.stringify(scene)}`);
4360
4625
  const host = await hostFor(context, raw);
4361
4626
  const sourceIds = splitCsv(stringOption(raw, "sources"));
4362
4627
  render(context, raw, {
4363
4628
  kind: "json",
4364
4629
  value: await host.client.createTaskRun(requiredString(raw.nb, "--nb"), {
4365
4630
  ...sourceIds.length === 0 ? {} : { config: { sourceIds } },
4366
- sceneType: requiredString(raw.scene, "--scene"),
4631
+ sceneType: scene,
4367
4632
  trigger: String(raw.trigger ?? "manual")
4368
4633
  })
4369
4634
  });
@@ -4428,13 +4693,18 @@ function registerSyncCommand(context, program) {
4428
4693
  if (result.exitCode === 1) context.exitCode = 1;
4429
4694
  });
4430
4695
  }
4431
- function registerUpdateCommand(program) {
4432
- program.command("self-update").description("Show the supported qmind CLI upgrade path").option("--url <url>", "legacy update URL (ignored)").addOption(new Option("--channel <channel>", "legacy release channel (ignored)").choices([
4696
+ function registerUpdateCommand(context, program) {
4697
+ program.command("update").alias("self-update").description("Update a Native CLI or show the npm upgrade path").option("--url <url>", "legacy update URL (ignored)").addOption(new Option("--channel <channel>", "legacy release channel (ignored)").choices([
4433
4698
  "stable",
4434
4699
  "beta",
4435
4700
  "daily"
4436
- ]).default("stable")).option("--public-key <key>", "legacy public key (ignored)").option("--check", "legacy check mode (ignored)").option("--force", "legacy reinstall mode (ignored)").option("--allow-downgrade", "legacy downgrade mode (ignored)").action(() => {
4437
- throw new QMindError("UNSUPPORTED_OPERATION", `self-update is unavailable for npm installs; run npm update --global ${distribution.package}`);
4701
+ ]).default("stable")).option("--public-key <key>", "legacy public key (ignored)").option("--check", "legacy check mode (ignored)").option("--force", "legacy reinstall mode (ignored)").option("--allow-downgrade", "legacy downgrade mode (ignored)").action(async (raw) => {
4702
+ const result = await context.updater.run({ check: raw.check === true });
4703
+ if (result.status === "unsupported") throw new QMindError("UNSUPPORTED_OPERATION", `self-update is unavailable for npm installs; run ${result.command}`);
4704
+ if (result.status === "up-to-date") context.io.stdout(`${distribution.command} ${result.currentVersion} is up to date\n`);
4705
+ else if (result.status === "available") context.io.stdout(`${distribution.command} ${result.latestVersion} is available (current ${result.currentVersion})\n`);
4706
+ else if (result.status === "scheduled") context.io.stdout(`${distribution.command} update to ${result.latestVersion} is scheduled; details: ${result.logPath}\n`);
4707
+ else context.io.stdout(`updated ${distribution.command} from ${result.currentVersion} to ${result.latestVersion}\n`);
4438
4708
  });
4439
4709
  }
4440
4710
  /** Internal parser adapter. Product consumers should call runQMindCli(). */
@@ -4451,7 +4721,7 @@ function createQMindCliProgram(context) {
4451
4721
  registerSceneCommands(context, program);
4452
4722
  registerTaskCommands(context, program);
4453
4723
  registerSyncCommand(context, program);
4454
- registerUpdateCommand(program);
4724
+ registerUpdateCommand(context, program);
4455
4725
  return program;
4456
4726
  }
4457
4727
  async function runQMindCli(argv, options = {}) {
@@ -4462,7 +4732,17 @@ async function runQMindCli(argv, options = {}) {
4462
4732
  host: void 0,
4463
4733
  hostFactory: options.hostFactory ?? createQMindCliHost,
4464
4734
  hostOptions: options.hostOptions ?? {},
4465
- io
4735
+ io,
4736
+ updater: options.updater ?? createQMindCliUpdater({ identity: {
4737
+ artifactKind: "npm",
4738
+ command: distribution.command,
4739
+ currentVersion: "3.2.0",
4740
+ distribution: distribution.id,
4741
+ executablePath: process.execPath,
4742
+ package: distribution.package,
4743
+ platform: process.platform,
4744
+ publicRoot: distribution.nativePublicRoot
4745
+ } })
4466
4746
  };
4467
4747
  const normalized = normalizeLegacyArgv(argv);
4468
4748
  const requiresLegacyAction = normalized.length === 0 || normalized.length === 1 && (/* @__PURE__ */ new Set([
@@ -565,6 +565,11 @@ const sourceListSchema = z.object({
565
565
  totalSize: z.number().int().nonnegative().optional()
566
566
  });
567
567
  const sourceTreeNodeSchema = z.lazy(() => z.object({
568
+ externalBinding: sourceExternalBindingSchema.optional(),
569
+ originUrl: z.string().optional(),
570
+ isEmailFolder: z.boolean().optional(),
571
+ isEmailAggregateMember: z.boolean().optional(),
572
+ isExternalSource: z.boolean().optional(),
568
573
  files: z.array(sourceTreeNodeSchema).default([]),
569
574
  hasChildren: z.boolean().optional(),
570
575
  id: z.string().min(1),
@@ -1,4 +1,4 @@
1
- import { H as sourceUploadCapabilitiesSchema, m as requiredString, n as call } from "./shared-BkQJzIZF.js";
1
+ import { H as sourceUploadCapabilitiesSchema, m as requiredString, n as call } from "./shared-OBSNlxAo.js";
2
2
  //#region ../sdk/src/operations/source-upload.ts
3
3
  /** Notebook-scoped edit preflight, not the deployment-level capabilities lookup. */
4
4
  async function preflightSourceUpload(context, notebookId, options) {
@@ -1,5 +1,5 @@
1
- import { $ as QMIND_SOURCE_UPLOAD_MAX_BYTES, B as sourceSchema, E as imageUploadTicketSchema, Q as QMIND_MULTIPART_UPLOAD_MAX_BYTES, U as sourceUploadTicketSchema, X as voidResponseSchema, a as invalidArgument, l as optionalString, m as requiredString, nt as executeUnary, p as queryPath, r as compactUndefined, rt as QMindError, u as optionalTrimmedString } from "./shared-BkQJzIZF.js";
2
- import { t as preflightSourceUpload } from "./source-upload-DBm1Hyki.js";
1
+ import { $ as QMIND_SOURCE_UPLOAD_MAX_BYTES, B as sourceSchema, E as imageUploadTicketSchema, Q as QMIND_MULTIPART_UPLOAD_MAX_BYTES, U as sourceUploadTicketSchema, X as voidResponseSchema, a as invalidArgument, l as optionalString, m as requiredString, nt as executeUnary, p as queryPath, r as compactUndefined, rt as QMindError, u as optionalTrimmedString } from "./shared-OBSNlxAo.js";
2
+ import { t as preflightSourceUpload } from "./source-upload-B0EAhkG2.js";
3
3
  //#region ../sdk/src/operations/transfers.ts
4
4
  function isRecord(value) {
5
5
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -72,10 +72,22 @@ function progressReporter(context, operation, strategy, totalBytes, options) {
72
72
  update: (uploadedBytes) => notify("uploading", uploadedBytes)
73
73
  };
74
74
  }
75
- function requestOptions(options) {
76
- return {
77
- ...options.signal === void 0 ? {} : { signal: options.signal },
78
- ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
75
+ function transferRequestOptions(options) {
76
+ const timeoutMs = options.timeoutMs;
77
+ if (timeoutMs !== void 0 && (!Number.isFinite(timeoutMs) || timeoutMs <= 0)) throw invalidArgument("timeoutMs must be a positive finite number", "timeoutMs");
78
+ const deadlineAt = timeoutMs === void 0 ? void 0 : Date.now() + timeoutMs;
79
+ return (operation) => {
80
+ if (options.signal?.aborted === true) throw new QMindError("ABORTED", "QMind transfer was aborted", { operation });
81
+ if (deadlineAt === void 0) return options.signal === void 0 ? {} : { signal: options.signal };
82
+ const remainingMs = Math.ceil(deadlineAt - Date.now());
83
+ if (remainingMs <= 0) throw new QMindError("TIMEOUT", "QMind transfer timed out", {
84
+ details: { timeoutMs },
85
+ operation
86
+ });
87
+ return {
88
+ ...options.signal === void 0 ? {} : { signal: options.signal },
89
+ timeoutMs: remainingMs
90
+ };
79
91
  };
80
92
  }
81
93
  function transferCall(context, operation, request, schema) {
@@ -88,7 +100,7 @@ function transferCall(context, operation, request, schema) {
88
100
  transport: context.transport
89
101
  });
90
102
  }
91
- function hostRequest(path, method, idempotent, options, body) {
103
+ function hostRequest(path, method, idempotent, options, requestOptions, operation, body) {
92
104
  const authorization = options.authorization?.trim();
93
105
  return {
94
106
  body,
@@ -99,10 +111,10 @@ function hostRequest(path, method, idempotent, options, body) {
99
111
  ...authorization === void 0 || authorization.length === 0 ? {} : { headers: { authorization: `Bearer ${authorization}` } },
100
112
  idempotent,
101
113
  method,
102
- ...requestOptions(options)
114
+ ...requestOptions(operation)
103
115
  };
104
116
  }
105
- function signedUploadRequest(ticket, source, progress, options) {
117
+ function signedUploadRequest(ticket, source, progress, requestOptions, operation) {
106
118
  return {
107
119
  body: {
108
120
  kind: "binary",
@@ -116,7 +128,7 @@ function signedUploadRequest(ticket, source, progress, options) {
116
128
  headers: ticket.headers,
117
129
  idempotent: true,
118
130
  method: "PUT",
119
- ...requestOptions(options)
131
+ ...requestOptions(operation)
120
132
  };
121
133
  }
122
134
  function selectSourceUploadStrategy(source, capabilities) {
@@ -149,6 +161,7 @@ function createTransferOperations(context) {
149
161
  const sourceIdValue = requiredString(sourceId, "sourceId");
150
162
  const source = binarySource(rawSource);
151
163
  const options = transferOptions(rawOptions);
164
+ const requestOptions = transferRequestOptions(options);
152
165
  if (source.size > 52428800) throw new QMindError("FILE_TOO_LARGE", "image exceeds the 50 MiB upload limit", {
153
166
  access: context.profile.access,
154
167
  details: {
@@ -157,7 +170,7 @@ function createTransferOperations(context) {
157
170
  },
158
171
  operation: "images.upload"
159
172
  });
160
- const ticket = await transferCall(context, "images.presignUpload", hostRequest(context.profile.apiPath("notebooks", notebook, "sources", sourceIdValue, "images", "presign"), "POST", false, options, {
173
+ const ticket = await transferCall(context, "images.presignUpload", hostRequest(context.profile.apiPath("notebooks", notebook, "sources", sourceIdValue, "images", "presign"), "POST", false, options, requestOptions, "images.presignUpload", {
161
174
  kind: "json",
162
175
  value: {
163
176
  filename: source.filename,
@@ -167,7 +180,7 @@ function createTransferOperations(context) {
167
180
  }), imageUploadTicketSchema);
168
181
  const progress = progressReporter(context, "images.upload", "presigned", source.size, options);
169
182
  progress.start();
170
- await transferCall(context, "images.upload", signedUploadRequest(ticket, source, progress, options), voidResponseSchema);
183
+ await transferCall(context, "images.upload", signedUploadRequest(ticket, source, progress, requestOptions, "images.upload"), voidResponseSchema);
171
184
  progress.complete();
172
185
  return ticket;
173
186
  },
@@ -176,6 +189,7 @@ function createTransferOperations(context) {
176
189
  const source = binarySource(rawSource);
177
190
  const metadata = uploadMetadata(rawMetadata);
178
191
  const options = transferOptions(rawOptions);
192
+ const requestOptions = transferRequestOptions(options);
179
193
  if (source.size > 524288e3) throw new QMindError("FILE_TOO_LARGE", "file exceeds the 500 MiB upload limit", {
180
194
  access: context.profile.access,
181
195
  details: {
@@ -184,7 +198,10 @@ function createTransferOperations(context) {
184
198
  },
185
199
  operation: "transfers.source.multipart"
186
200
  });
187
- if (selectSourceUploadStrategy(source, await preflightSourceUpload(context, notebook, options)) === "multipart") {
201
+ if (selectSourceUploadStrategy(source, await preflightSourceUpload(context, notebook, {
202
+ ...options,
203
+ ...requestOptions("sources.uploadPreflight")
204
+ })) === "multipart") {
188
205
  const progress = progressReporter(context, "transfers.source.multipart", "multipart", source.size, options);
189
206
  progress.start();
190
207
  const fields = compactUndefined({
@@ -194,7 +211,7 @@ function createTransferOperations(context) {
194
211
  source_type: metadata.sourceType,
195
212
  title: metadata.title
196
213
  });
197
- const result = await transferCall(context, "transfers.source.multipart", hostRequest(queryPath(context.profile.apiPath("notebooks", notebook, "sources", "upload"), [["client", context.client]]), "POST", false, options, {
214
+ const result = await transferCall(context, "transfers.source.multipart", hostRequest(queryPath(context.profile.apiPath("notebooks", notebook, "sources", "upload"), [["client", context.client]]), "POST", false, options, requestOptions, "transfers.source.multipart", {
198
215
  file: source,
199
216
  fields,
200
217
  kind: "multipart",
@@ -203,7 +220,7 @@ function createTransferOperations(context) {
203
220
  progress.complete();
204
221
  return result;
205
222
  }
206
- const ticket = await transferCall(context, "transfers.source.presign", hostRequest(context.profile.apiPath("notebooks", notebook, "sources", "presign"), "POST", false, options, {
223
+ const ticket = await transferCall(context, "transfers.source.presign", hostRequest(context.profile.apiPath("notebooks", notebook, "sources", "presign"), "POST", false, options, requestOptions, "transfers.source.presign", {
207
224
  kind: "json",
208
225
  value: {
209
226
  filename: source.filename,
@@ -213,10 +230,10 @@ function createTransferOperations(context) {
213
230
  }), sourceUploadTicketSchema);
214
231
  const progress = progressReporter(context, "transfers.source.upload", "presigned", source.size, options);
215
232
  progress.start();
216
- await transferCall(context, "transfers.source.upload", signedUploadRequest(ticket, source, progress, options), voidResponseSchema);
233
+ await transferCall(context, "transfers.source.upload", signedUploadRequest(ticket, source, progress, requestOptions, "transfers.source.upload"), voidResponseSchema);
217
234
  progress.complete();
218
235
  progress.registering();
219
- return transferCall(context, "transfers.source.register", hostRequest(context.profile.apiPath("notebooks", notebook, "sources", "register"), "POST", false, options, {
236
+ return transferCall(context, "transfers.source.register", hostRequest(context.profile.apiPath("notebooks", notebook, "sources", "register"), "POST", false, options, requestOptions, "transfers.source.register", {
220
237
  kind: "json",
221
238
  value: compactUndefined({
222
239
  filename: source.filename,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qoder-ai/qmind-cli",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "QMind command line interface",
5
5
  "bin": {
6
6
  "qmind": "bin/cli.js"
@@ -30,6 +30,7 @@
30
30
  "p-limit": "7.3.1",
31
31
  "picomatch": "4.0.5",
32
32
  "proper-lockfile": "4.1.2",
33
+ "semver": "7.8.5",
33
34
  "undici": "7.29.0",
34
35
  "zod": "4.3.6"
35
36
  },
@@ -37,8 +38,9 @@
37
38
  "@types/node": "24.13.3",
38
39
  "@types/picomatch": "4.0.3",
39
40
  "@types/proper-lockfile": "4.1.4",
40
- "@ali/qmind-node-host": "^2.2.8",
41
- "@ali/qmind-sdk": "^0.14.0"
41
+ "@types/semver": "7.8.0",
42
+ "@ali/qmind-node-host": "^2.2.40",
43
+ "@ali/qmind-sdk": "^0.17.0"
42
44
  },
43
45
  "license": "UNLICENSED"
44
46
  }