@qoder-ai/qmind-cli 3.1.0 → 3.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.
- package/CHANGELOG.md +10 -0
- package/CHANGELOG.zh-CN.md +10 -0
- package/README.md +13 -0
- package/README.zh-CN.md +25 -12
- package/dist/{bot-gateway-Hzjl50zu.js → bot-gateway-CB6KrV15.js} +1 -1
- package/dist/{cards-DsMbd-g1.js → cards-JaeY0mah.js} +1 -1
- package/dist/{imports-B01ERZgD.js → imports-CHEgKeR5.js} +1 -1
- package/dist/{management-BIYQa9Al.js → management-J4OEjnLA.js} +1 -1
- package/dist/{notes-BvucEfdi.js → notes-CxkxuWdP.js} +1 -1
- package/dist/qmind.js +243 -43
- package/dist/{shared-BkQJzIZF.js → shared-9iPJsfjP.js} +1 -0
- package/dist/{source-upload-DBm1Hyki.js → source-upload-mZ-N52xb.js} +1 -1
- package/dist/{transfers-F1ZLLBdU.js → transfers-BRx_Hrlz.js} +34 -17
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@ 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.1.1
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 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.
|
|
12
|
+
|
|
13
|
+
### Changes without version bumps
|
|
14
|
+
|
|
15
|
+
- 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.
|
|
16
|
+
|
|
7
17
|
## 3.1.0
|
|
8
18
|
|
|
9
19
|
### Minor Changes
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
以下已发布版本属于 Global CLI / 共享实现,不代表 CN 曾发布过这些版本。CN 将在后续共同发行版加入同一历史。
|
|
6
6
|
|
|
7
|
+
## 3.1.1
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- a92c490: 为 installer 管理的 Native CLI release 增加 `update` 与 `update --check`,固定使用 Global/CN channel,校验 release 和 installer checksum,拒绝降级,复用事务式替换,并在 Windows 上于当前进程退出后调度更新。npm 管理的安装仍返回对应的 npm 升级命令。
|
|
12
|
+
|
|
13
|
+
### Changes without version bumps
|
|
14
|
+
|
|
15
|
+
- 新增由仓库维护的 Native CLI 安装脚本制品生成、candidate 编排、Bun 编译、可恢复安装事务、严格离线 handoff 校验与 macOS、Windows、Linux finalization 能力;现有通过 npm 安装的 `qmind` 或 `qmind-cn` 运行时行为不变。
|
|
16
|
+
|
|
7
17
|
## 3.1.0
|
|
8
18
|
|
|
9
19
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -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
|
|
@@ -56,6 +68,7 @@ Do not put tokens in command arguments, repositories, or logs. Run `qmind logout
|
|
|
56
68
|
| `upload-folder` / `sync` | Synchronize a local directory |
|
|
57
69
|
| `image` | Obtain image upload or access URLs |
|
|
58
70
|
| `version` | Print version and build information |
|
|
71
|
+
| `update` / `self-update` | Update an installer-managed Native CLI |
|
|
59
72
|
|
|
60
73
|
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
74
|
|
package/README.zh-CN.md
CHANGED
|
@@ -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,19 @@ 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
|
+
| `compile` / `lint` | 运行编译或检查工作流 |
|
|
67
|
+
| `task` | 管理任务运行 |
|
|
68
|
+
| `upload-folder` / `sync` | 同步本地目录 |
|
|
69
|
+
| `image` | 获取图片上传地址或访问地址 |
|
|
70
|
+
| `version` | 查看版本和构建信息 |
|
|
71
|
+
| `update` / `self-update` | 更新 installer 管理的 Native CLI |
|
|
59
72
|
|
|
60
73
|
使用 `qmind <command> --help` 查看完整参数。领域命令支持 `table`、`json`、`agent`、`ndjson` 等输出格式。stdout 只输出结果,进度与诊断信息输出到 stderr。退出码 `0` 表示成功,`1` 表示运行失败、部分成功或取消,`2` 表示参数错误。
|
|
61
74
|
|
|
@@ -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-
|
|
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-9iPJsfjP.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-
|
|
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-9iPJsfjP.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-
|
|
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-9iPJsfjP.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-
|
|
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-9iPJsfjP.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-
|
|
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-9iPJsfjP.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-
|
|
2
|
-
import { t as preflightSourceUpload } from "./source-upload-
|
|
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-9iPJsfjP.js";
|
|
2
|
+
import { t as preflightSourceUpload } from "./source-upload-mZ-N52xb.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,6 +17,9 @@ 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
25
|
function isRecord$2(value) {
|
|
@@ -539,6 +542,7 @@ function buildSourceTree(sources) {
|
|
|
539
542
|
const parentIds = new Set(sources.filter((source) => sourcesById.has(source.parentSourceId) && !createsSourceCycle(source, sourcesById)).map((source) => source.parentSourceId));
|
|
540
543
|
const nodesById = /* @__PURE__ */ new Map();
|
|
541
544
|
for (const source of sources) nodesById.set(source.id, {
|
|
545
|
+
...source.externalBinding === void 0 ? {} : { externalBinding: source.externalBinding },
|
|
542
546
|
files: [],
|
|
543
547
|
hasChildren: source.hasChildren ?? (source.childrenCount === void 0 ? source.isDir : source.childrenCount > 0),
|
|
544
548
|
id: source.id,
|
|
@@ -1466,7 +1470,7 @@ const botGatewayOperationNames = [
|
|
|
1466
1470
|
function createLazyTransferOperations(context) {
|
|
1467
1471
|
let operations;
|
|
1468
1472
|
const load = () => {
|
|
1469
|
-
operations ??= import("./transfers-
|
|
1473
|
+
operations ??= import("./transfers-BRx_Hrlz.js").then(({ createTransferOperations }) => createTransferOperations(context));
|
|
1470
1474
|
return operations;
|
|
1471
1475
|
};
|
|
1472
1476
|
return {
|
|
@@ -1477,7 +1481,7 @@ function createLazyTransferOperations(context) {
|
|
|
1477
1481
|
function createLazyBotGatewayOperations(context) {
|
|
1478
1482
|
let operations;
|
|
1479
1483
|
const load = () => {
|
|
1480
|
-
operations ??= import("./bot-gateway-
|
|
1484
|
+
operations ??= import("./bot-gateway-CB6KrV15.js").then(({ createBotGatewayOperations }) => createBotGatewayOperations(context));
|
|
1481
1485
|
return operations;
|
|
1482
1486
|
};
|
|
1483
1487
|
return Object.fromEntries(botGatewayOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
|
|
@@ -1485,7 +1489,7 @@ function createLazyBotGatewayOperations(context) {
|
|
|
1485
1489
|
function createLazyNoteOperations(context) {
|
|
1486
1490
|
let operations;
|
|
1487
1491
|
const load = () => {
|
|
1488
|
-
operations ??= import("./notes-
|
|
1492
|
+
operations ??= import("./notes-CxkxuWdP.js").then(({ createNoteOperations }) => createNoteOperations(context));
|
|
1489
1493
|
return operations;
|
|
1490
1494
|
};
|
|
1491
1495
|
return Object.fromEntries(noteOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
|
|
@@ -1493,7 +1497,7 @@ function createLazyNoteOperations(context) {
|
|
|
1493
1497
|
function createLazyCardOperations(context) {
|
|
1494
1498
|
let operations;
|
|
1495
1499
|
const load = () => {
|
|
1496
|
-
operations ??= import("./cards-
|
|
1500
|
+
operations ??= import("./cards-JaeY0mah.js").then(({ createCardOperations }) => createCardOperations(context));
|
|
1497
1501
|
return operations;
|
|
1498
1502
|
};
|
|
1499
1503
|
return Object.fromEntries(cardOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
|
|
@@ -1501,7 +1505,7 @@ function createLazyCardOperations(context) {
|
|
|
1501
1505
|
function createLazyImportOperations(context) {
|
|
1502
1506
|
let operations;
|
|
1503
1507
|
const load = () => {
|
|
1504
|
-
operations ??= import("./imports-
|
|
1508
|
+
operations ??= import("./imports-CHEgKeR5.js").then(({ createImportOperations }) => createImportOperations(context));
|
|
1505
1509
|
return operations;
|
|
1506
1510
|
};
|
|
1507
1511
|
return Object.fromEntries(importOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
|
|
@@ -1509,7 +1513,7 @@ function createLazyImportOperations(context) {
|
|
|
1509
1513
|
function createLazyManagementOperations(context) {
|
|
1510
1514
|
let operations;
|
|
1511
1515
|
const load = () => {
|
|
1512
|
-
operations ??= import("./management-
|
|
1516
|
+
operations ??= import("./management-J4OEjnLA.js").then(({ createManagementOperations }) => createManagementOperations(context));
|
|
1513
1517
|
return operations;
|
|
1514
1518
|
};
|
|
1515
1519
|
return Object.fromEntries(managementOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
|
|
@@ -1579,12 +1583,12 @@ function errorCodeForStatus(status) {
|
|
|
1579
1583
|
if (status >= 400 && status < 500) return "INVALID_ARGUMENT";
|
|
1580
1584
|
return "REMOTE_ERROR";
|
|
1581
1585
|
}
|
|
1582
|
-
function record$
|
|
1586
|
+
function record$2(value) {
|
|
1583
1587
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
1584
1588
|
}
|
|
1585
1589
|
function responseString(response, ...keys) {
|
|
1586
|
-
const body = record$
|
|
1587
|
-
const nestedError = record$
|
|
1590
|
+
const body = record$2(response.body);
|
|
1591
|
+
const nestedError = record$2(body?.error);
|
|
1588
1592
|
for (const source of [body, nestedError]) for (const key of keys) {
|
|
1589
1593
|
const value = source?.[key];
|
|
1590
1594
|
if (typeof value === "string" && value.length > 0) return value;
|
|
@@ -2691,40 +2695,43 @@ function createQMindNodeTransport(options) {
|
|
|
2691
2695
|
const url = requestUrl(origin, request$2);
|
|
2692
2696
|
const attempts = request$2.idempotent ? maxRetries + 1 : 1;
|
|
2693
2697
|
let lastFailure;
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
try {
|
|
2698
|
+
const timeoutMs = request$2.timeoutMs ?? requestTimeoutMs;
|
|
2699
|
+
const deadline = requestDeadline(request$2.signal, timeoutMs);
|
|
2700
|
+
try {
|
|
2701
|
+
for (let attempt = 0; attempt < attempts; attempt += 1) try {
|
|
2698
2702
|
debugRequest(options, request$2, url);
|
|
2699
2703
|
const encoded = encodeBody(request$2, `----qmind-${randomBytes(18).toString("hex")}`);
|
|
2700
2704
|
const response = await request(url, {
|
|
2701
2705
|
...encoded.body === void 0 ? {} : { body: encoded.body },
|
|
2702
|
-
bodyTimeout:
|
|
2706
|
+
bodyTimeout: timeoutMs,
|
|
2703
2707
|
dispatcher: dispatcherFor(request$2),
|
|
2704
2708
|
headers: encoded.headers,
|
|
2705
|
-
headersTimeout:
|
|
2709
|
+
headersTimeout: timeoutMs,
|
|
2706
2710
|
idempotent: request$2.idempotent,
|
|
2707
2711
|
method: request$2.method,
|
|
2708
2712
|
signal: deadline.signal
|
|
2709
2713
|
});
|
|
2710
2714
|
if (attempt + 1 < attempts && RETRYABLE_STATUS.has(response.statusCode)) {
|
|
2711
2715
|
await response.body.dump();
|
|
2712
|
-
await abortableSleep(250 * 2 ** attempt,
|
|
2716
|
+
await abortableSleep(250 * 2 ** attempt, deadline.signal);
|
|
2713
2717
|
continue;
|
|
2714
2718
|
}
|
|
2715
2719
|
return await wireResponse(response);
|
|
2716
2720
|
} catch (cause) {
|
|
2717
2721
|
lastFailure = cause;
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
await abortableSleep(250 * 2 ** attempt,
|
|
2721
|
-
|
|
2722
|
+
if (attempt + 1 >= attempts || request$2.signal?.aborted === true || deadline.timedOut) break;
|
|
2723
|
+
try {
|
|
2724
|
+
await abortableSleep(250 * 2 ** attempt, deadline.signal);
|
|
2725
|
+
} catch (backoffCause) {
|
|
2726
|
+
lastFailure = backoffCause;
|
|
2727
|
+
break;
|
|
2722
2728
|
}
|
|
2723
|
-
|
|
2724
|
-
deadline.dispose();
|
|
2729
|
+
continue;
|
|
2725
2730
|
}
|
|
2731
|
+
throw transportFailure(request$2, lastFailure, deadline.timedOut);
|
|
2732
|
+
} finally {
|
|
2733
|
+
deadline.dispose();
|
|
2726
2734
|
}
|
|
2727
|
-
throw transportFailure(request$2, lastFailure, lastDeadlineExpired);
|
|
2728
2735
|
},
|
|
2729
2736
|
async stream(request$3) {
|
|
2730
2737
|
assertWireRequest(request$3);
|
|
@@ -2969,8 +2976,8 @@ function requestsJsonOutput(argv) {
|
|
|
2969
2976
|
//#region src/build-info.ts
|
|
2970
2977
|
/** Bundled identity, never inferred from argv, environment, or an endpoint. */
|
|
2971
2978
|
const QMIND_CLI_DISTRIBUTION = "global";
|
|
2972
|
-
const QMIND_CLI_VERSION = "3.1.
|
|
2973
|
-
const QMIND_CLI_BUILD_TIME = "2026-09-
|
|
2979
|
+
const QMIND_CLI_VERSION = "3.1.1";
|
|
2980
|
+
const QMIND_CLI_BUILD_TIME = "2026-09-04T10:59:00.000Z";
|
|
2974
2981
|
function qmindCliPlatform() {
|
|
2975
2982
|
return process.platform === "win32" ? "windows" : process.platform;
|
|
2976
2983
|
}
|
|
@@ -2986,6 +2993,7 @@ const CLI_DISTRIBUTIONS = Object.freeze({
|
|
|
2986
2993
|
command: "qmind",
|
|
2987
2994
|
package: "@qoder-ai/qmind-cli",
|
|
2988
2995
|
productId: "qoder",
|
|
2996
|
+
nativePublicRoot: "https://download.qoder.com/qmind-cli",
|
|
2989
2997
|
gitTagSlug: "qmind-cli",
|
|
2990
2998
|
readmeDirectory: ".",
|
|
2991
2999
|
productNames: {
|
|
@@ -2998,6 +3006,7 @@ const CLI_DISTRIBUTIONS = Object.freeze({
|
|
|
2998
3006
|
command: "qmind-cn",
|
|
2999
3007
|
package: "@qodercn-ai/qmind-cli",
|
|
3000
3008
|
productId: "qoder-cn",
|
|
3009
|
+
nativePublicRoot: "https://static.qoder.com.cn/qmind-cli-cn",
|
|
3001
3010
|
gitTagSlug: "qmind-cli-cn",
|
|
3002
3011
|
readmeDirectory: "readmes/cn",
|
|
3003
3012
|
productNames: {
|
|
@@ -3065,7 +3074,7 @@ function validateMapping(value) {
|
|
|
3065
3074
|
}
|
|
3066
3075
|
return result;
|
|
3067
3076
|
}
|
|
3068
|
-
async function sha256(path) {
|
|
3077
|
+
async function sha256$1(path) {
|
|
3069
3078
|
const hash = createHash("sha256");
|
|
3070
3079
|
for await (const chunk of createReadStream(path)) hash.update(chunk);
|
|
3071
3080
|
return hash.digest("hex");
|
|
@@ -3116,7 +3125,7 @@ function createNodeQMindFolderSyncFileSystem() {
|
|
|
3116
3125
|
skipped
|
|
3117
3126
|
};
|
|
3118
3127
|
},
|
|
3119
|
-
sha256,
|
|
3128
|
+
sha256: sha256$1,
|
|
3120
3129
|
async writeMapping(path, mapping) {
|
|
3121
3130
|
await mkdir(dirname(path), { recursive: true });
|
|
3122
3131
|
await writeFile(path, `${JSON.stringify(mapping, null, 2)}\n`, { mode: 384 });
|
|
@@ -3357,7 +3366,7 @@ function parseQMindCliOutputFormat(value) {
|
|
|
3357
3366
|
if (value === "json" || value === "agent" || value === "ndjson") return value;
|
|
3358
3367
|
return "table";
|
|
3359
3368
|
}
|
|
3360
|
-
function record(value) {
|
|
3369
|
+
function record$1(value) {
|
|
3361
3370
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
3362
3371
|
}
|
|
3363
3372
|
function stringValue(value) {
|
|
@@ -3408,12 +3417,12 @@ function timestamp(value) {
|
|
|
3408
3417
|
return (/* @__PURE__ */ new Date(parsed.seconds * 1e3)).toISOString().replace(".000Z", "Z");
|
|
3409
3418
|
}
|
|
3410
3419
|
function optionalMap(value) {
|
|
3411
|
-
const result = record(value);
|
|
3420
|
+
const result = record$1(value);
|
|
3412
3421
|
return Object.keys(result).length === 0 ? void 0 : result;
|
|
3413
3422
|
}
|
|
3414
3423
|
function pagination(value) {
|
|
3415
3424
|
if (value === void 0 || value === null) return "";
|
|
3416
|
-
const page = record(value);
|
|
3425
|
+
const page = record$1(value);
|
|
3417
3426
|
if ([
|
|
3418
3427
|
page.totalSize,
|
|
3419
3428
|
page.currentPage,
|
|
@@ -3423,7 +3432,7 @@ function pagination(value) {
|
|
|
3423
3432
|
return ` (server totalSize=${numberValue(page.totalSize)}, page=${numberValue(page.currentPage)}/${numberValue(page.lastPage)}, pageSize=${numberValue(page.pageSize)})`;
|
|
3424
3433
|
}
|
|
3425
3434
|
function goNotebook(value) {
|
|
3426
|
-
const source = record(value);
|
|
3435
|
+
const source = record$1(value);
|
|
3427
3436
|
const settings = optionalMap(source.settings);
|
|
3428
3437
|
return {
|
|
3429
3438
|
id: stringValue(source.id),
|
|
@@ -3448,7 +3457,7 @@ function goNotebookList(value) {
|
|
|
3448
3457
|
}
|
|
3449
3458
|
function goPage(value) {
|
|
3450
3459
|
if (value === void 0 || value === null) return void 0;
|
|
3451
|
-
const source = record(value);
|
|
3460
|
+
const source = record$1(value);
|
|
3452
3461
|
return {
|
|
3453
3462
|
prevPage: numberValue(source.prevPage),
|
|
3454
3463
|
currentPage: numberValue(source.currentPage),
|
|
@@ -3460,7 +3469,7 @@ function goPage(value) {
|
|
|
3460
3469
|
};
|
|
3461
3470
|
}
|
|
3462
3471
|
function goSource(value) {
|
|
3463
|
-
const source = record(value);
|
|
3472
|
+
const source = record$1(value);
|
|
3464
3473
|
const metadata = optionalMap(source.metadata);
|
|
3465
3474
|
return {
|
|
3466
3475
|
id: stringValue(source.id),
|
|
@@ -4007,6 +4016,182 @@ function createQMindCliStreamRenderer(format) {
|
|
|
4007
4016
|
};
|
|
4008
4017
|
}
|
|
4009
4018
|
//#endregion
|
|
4019
|
+
//#region src/update.ts
|
|
4020
|
+
const execFileAsync = promisify(execFile);
|
|
4021
|
+
const SHA256 = /^[a-f0-9]{64}$/u;
|
|
4022
|
+
const MAX_CHANNEL_BYTES = 65536;
|
|
4023
|
+
const MAX_RELEASE_BYTES = 4194304;
|
|
4024
|
+
const MAX_INSTALLER_BYTES = 1048576;
|
|
4025
|
+
function sha256(bytes) {
|
|
4026
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
4027
|
+
}
|
|
4028
|
+
function record(value, label) {
|
|
4029
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label} is invalid`);
|
|
4030
|
+
return value;
|
|
4031
|
+
}
|
|
4032
|
+
function string(value, label) {
|
|
4033
|
+
if (typeof value !== "string" || value.length === 0) throw new Error(`${label} is invalid`);
|
|
4034
|
+
return value;
|
|
4035
|
+
}
|
|
4036
|
+
async function boundedBytes(fetcher, url, limit, label) {
|
|
4037
|
+
const response = await fetcher(url, {
|
|
4038
|
+
redirect: "error",
|
|
4039
|
+
signal: AbortSignal.timeout(3e4)
|
|
4040
|
+
});
|
|
4041
|
+
if (!response.ok) throw new Error(`${label} request failed with HTTP ${response.status}`);
|
|
4042
|
+
if (response.url.length > 0 && response.url !== url) throw new Error(`${label} redirected`);
|
|
4043
|
+
const declared = Number(response.headers.get("content-length"));
|
|
4044
|
+
if (Number.isFinite(declared) && declared > limit) throw new Error(`${label} is too large`);
|
|
4045
|
+
const bytes = Buffer.from(await response.arrayBuffer());
|
|
4046
|
+
if (bytes.length === 0 || bytes.length > limit) throw new Error(`${label} is too large`);
|
|
4047
|
+
return bytes;
|
|
4048
|
+
}
|
|
4049
|
+
function parseJson(bytes, label) {
|
|
4050
|
+
try {
|
|
4051
|
+
return record(JSON.parse(bytes.toString("utf8")), label);
|
|
4052
|
+
} catch {
|
|
4053
|
+
throw new Error(`${label} is invalid`);
|
|
4054
|
+
}
|
|
4055
|
+
}
|
|
4056
|
+
function channelFrom(bytes, identity) {
|
|
4057
|
+
const channel = parseJson(bytes, "native update channel");
|
|
4058
|
+
const release = record(channel.release, "native update channel release");
|
|
4059
|
+
const version = string(channel.version, "native update channel version");
|
|
4060
|
+
const releaseSha256 = string(release.sha256, "native update release checksum");
|
|
4061
|
+
const releaseKey = string(release.key, "native update release key");
|
|
4062
|
+
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");
|
|
4063
|
+
return {
|
|
4064
|
+
releaseKey,
|
|
4065
|
+
releaseSha256,
|
|
4066
|
+
version
|
|
4067
|
+
};
|
|
4068
|
+
}
|
|
4069
|
+
function installerFrom(bytes, identity, version) {
|
|
4070
|
+
const release = parseJson(bytes, "native update release");
|
|
4071
|
+
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");
|
|
4072
|
+
const selector = identity.platform === "win32" ? "ps1" : "sh";
|
|
4073
|
+
const expectedBasename = `${identity.command}-install-v${version}.${selector}`;
|
|
4074
|
+
const matches = release.artifacts.filter((value) => {
|
|
4075
|
+
const artifact = record(value, "native update artifact");
|
|
4076
|
+
return artifact.role === "script" && artifact.selector === selector && artifact.basename === expectedBasename && Number.isSafeInteger(artifact.size) && typeof artifact.sha256 === "string" && SHA256.test(artifact.sha256);
|
|
4077
|
+
});
|
|
4078
|
+
if (matches.length !== 1) throw new Error("native update installer is missing or ambiguous");
|
|
4079
|
+
const artifact = matches[0];
|
|
4080
|
+
return {
|
|
4081
|
+
basename: expectedBasename,
|
|
4082
|
+
sha256: artifact.sha256,
|
|
4083
|
+
size: artifact.size
|
|
4084
|
+
};
|
|
4085
|
+
}
|
|
4086
|
+
async function executeNativeInstaller(input) {
|
|
4087
|
+
const executableName = input.platform === "win32" ? `${input.command}.exe` : input.command;
|
|
4088
|
+
const actualName = basename(input.executablePath);
|
|
4089
|
+
if (input.platform === "win32" ? actualName.toLowerCase() !== executableName.toLowerCase() : actualName !== executableName) throw new Error("native update requires an installer-managed executable");
|
|
4090
|
+
const installDirectory = dirname(input.executablePath);
|
|
4091
|
+
const temporary = await mkdtemp(join(tmpdir(), `${input.command}-update-`));
|
|
4092
|
+
const extension = input.platform === "win32" ? "ps1" : "sh";
|
|
4093
|
+
const installerPath = join(temporary, `installer.${extension}`);
|
|
4094
|
+
await writeFile(installerPath, input.bytes, { mode: 384 });
|
|
4095
|
+
if (input.platform !== "win32") try {
|
|
4096
|
+
await execFileAsync("/bin/sh", [
|
|
4097
|
+
installerPath,
|
|
4098
|
+
"--artifact-root",
|
|
4099
|
+
input.artifactRoot,
|
|
4100
|
+
"--install-dir",
|
|
4101
|
+
installDirectory
|
|
4102
|
+
], {
|
|
4103
|
+
maxBuffer: 1048576,
|
|
4104
|
+
timeout: 3e5
|
|
4105
|
+
});
|
|
4106
|
+
return { status: "completed" };
|
|
4107
|
+
} finally {
|
|
4108
|
+
await rm(temporary, {
|
|
4109
|
+
force: true,
|
|
4110
|
+
recursive: true
|
|
4111
|
+
});
|
|
4112
|
+
}
|
|
4113
|
+
const wrapperPath = join(temporary, "apply-update.ps1");
|
|
4114
|
+
const logPath = join(installDirectory, `.${input.command}.update.log`);
|
|
4115
|
+
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 });
|
|
4116
|
+
const child = spawn("powershell.exe", [
|
|
4117
|
+
"-NoLogo",
|
|
4118
|
+
"-NoProfile",
|
|
4119
|
+
"-ExecutionPolicy",
|
|
4120
|
+
"Bypass",
|
|
4121
|
+
"-File",
|
|
4122
|
+
wrapperPath,
|
|
4123
|
+
String(process.pid),
|
|
4124
|
+
installerPath,
|
|
4125
|
+
input.artifactRoot,
|
|
4126
|
+
installDirectory,
|
|
4127
|
+
logPath,
|
|
4128
|
+
temporary
|
|
4129
|
+
], {
|
|
4130
|
+
detached: true,
|
|
4131
|
+
stdio: "ignore",
|
|
4132
|
+
windowsHide: true
|
|
4133
|
+
});
|
|
4134
|
+
await new Promise((resolvePromise, reject) => {
|
|
4135
|
+
child.once("spawn", resolvePromise);
|
|
4136
|
+
child.once("error", reject);
|
|
4137
|
+
});
|
|
4138
|
+
child.unref();
|
|
4139
|
+
return {
|
|
4140
|
+
status: "scheduled",
|
|
4141
|
+
logPath
|
|
4142
|
+
};
|
|
4143
|
+
}
|
|
4144
|
+
function createQMindCliUpdater(options) {
|
|
4145
|
+
const { identity } = options;
|
|
4146
|
+
const fetcher = options.fetcher ?? fetch;
|
|
4147
|
+
const executeInstaller = options.executeInstaller ?? executeNativeInstaller;
|
|
4148
|
+
return Object.freeze({ async run({ check }) {
|
|
4149
|
+
if (identity.artifactKind === "npm") return {
|
|
4150
|
+
status: "unsupported",
|
|
4151
|
+
command: `npm update --global ${identity.package}`
|
|
4152
|
+
};
|
|
4153
|
+
const channelUrl = `${identity.publicRoot}/latest/channel`;
|
|
4154
|
+
const channel = channelFrom(await boundedBytes(fetcher, channelUrl, MAX_CHANNEL_BYTES, "native update channel"), identity);
|
|
4155
|
+
const releaseUrl = `${identity.publicRoot}/${channel.releaseKey}`;
|
|
4156
|
+
const releaseBytes = await boundedBytes(fetcher, releaseUrl, MAX_RELEASE_BYTES, "native update release");
|
|
4157
|
+
if (sha256(releaseBytes) !== channel.releaseSha256) throw new Error("native update release checksum mismatch");
|
|
4158
|
+
const installer = installerFrom(releaseBytes, identity, channel.version);
|
|
4159
|
+
const comparison = semver.compare(channel.version, identity.currentVersion);
|
|
4160
|
+
if (comparison < 0) throw new Error("native update channel would downgrade the current version");
|
|
4161
|
+
if (comparison === 0) return {
|
|
4162
|
+
status: "up-to-date",
|
|
4163
|
+
currentVersion: identity.currentVersion,
|
|
4164
|
+
latestVersion: channel.version
|
|
4165
|
+
};
|
|
4166
|
+
if (check) return {
|
|
4167
|
+
status: "available",
|
|
4168
|
+
currentVersion: identity.currentVersion,
|
|
4169
|
+
latestVersion: channel.version
|
|
4170
|
+
};
|
|
4171
|
+
const artifactRoot = `${identity.publicRoot}/releases/${channel.version}`;
|
|
4172
|
+
const installerBytes = await boundedBytes(fetcher, `${artifactRoot}/${installer.basename}`, MAX_INSTALLER_BYTES, "native update installer");
|
|
4173
|
+
if (installerBytes.length !== installer.size || sha256(installerBytes) !== installer.sha256) throw new Error("native update installer checksum mismatch");
|
|
4174
|
+
const execution = await executeInstaller({
|
|
4175
|
+
artifactRoot,
|
|
4176
|
+
bytes: installerBytes,
|
|
4177
|
+
command: identity.command,
|
|
4178
|
+
executablePath: identity.executablePath,
|
|
4179
|
+
platform: identity.platform,
|
|
4180
|
+
version: channel.version
|
|
4181
|
+
});
|
|
4182
|
+
return execution.status === "scheduled" ? {
|
|
4183
|
+
status: "scheduled",
|
|
4184
|
+
currentVersion: identity.currentVersion,
|
|
4185
|
+
latestVersion: channel.version,
|
|
4186
|
+
logPath: execution.logPath ?? join(dirname(identity.executablePath), `.${identity.command}.update.log`)
|
|
4187
|
+
} : {
|
|
4188
|
+
status: "updated",
|
|
4189
|
+
currentVersion: identity.currentVersion,
|
|
4190
|
+
latestVersion: channel.version
|
|
4191
|
+
};
|
|
4192
|
+
} });
|
|
4193
|
+
}
|
|
4194
|
+
//#endregion
|
|
4010
4195
|
//#region src/application.ts
|
|
4011
4196
|
const distribution = CLI_DISTRIBUTIONS[QMIND_CLI_DISTRIBUTION];
|
|
4012
4197
|
function processIO() {
|
|
@@ -4428,13 +4613,18 @@ function registerSyncCommand(context, program) {
|
|
|
4428
4613
|
if (result.exitCode === 1) context.exitCode = 1;
|
|
4429
4614
|
});
|
|
4430
4615
|
}
|
|
4431
|
-
function registerUpdateCommand(program) {
|
|
4432
|
-
program.command("self-update").description("
|
|
4616
|
+
function registerUpdateCommand(context, program) {
|
|
4617
|
+
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
4618
|
"stable",
|
|
4434
4619
|
"beta",
|
|
4435
4620
|
"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
|
-
|
|
4621
|
+
]).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) => {
|
|
4622
|
+
const result = await context.updater.run({ check: raw.check === true });
|
|
4623
|
+
if (result.status === "unsupported") throw new QMindError("UNSUPPORTED_OPERATION", `self-update is unavailable for npm installs; run ${result.command}`);
|
|
4624
|
+
if (result.status === "up-to-date") context.io.stdout(`${distribution.command} ${result.currentVersion} is up to date\n`);
|
|
4625
|
+
else if (result.status === "available") context.io.stdout(`${distribution.command} ${result.latestVersion} is available (current ${result.currentVersion})\n`);
|
|
4626
|
+
else if (result.status === "scheduled") context.io.stdout(`${distribution.command} update to ${result.latestVersion} is scheduled; details: ${result.logPath}\n`);
|
|
4627
|
+
else context.io.stdout(`updated ${distribution.command} from ${result.currentVersion} to ${result.latestVersion}\n`);
|
|
4438
4628
|
});
|
|
4439
4629
|
}
|
|
4440
4630
|
/** Internal parser adapter. Product consumers should call runQMindCli(). */
|
|
@@ -4451,7 +4641,7 @@ function createQMindCliProgram(context) {
|
|
|
4451
4641
|
registerSceneCommands(context, program);
|
|
4452
4642
|
registerTaskCommands(context, program);
|
|
4453
4643
|
registerSyncCommand(context, program);
|
|
4454
|
-
registerUpdateCommand(program);
|
|
4644
|
+
registerUpdateCommand(context, program);
|
|
4455
4645
|
return program;
|
|
4456
4646
|
}
|
|
4457
4647
|
async function runQMindCli(argv, options = {}) {
|
|
@@ -4462,7 +4652,17 @@ async function runQMindCli(argv, options = {}) {
|
|
|
4462
4652
|
host: void 0,
|
|
4463
4653
|
hostFactory: options.hostFactory ?? createQMindCliHost,
|
|
4464
4654
|
hostOptions: options.hostOptions ?? {},
|
|
4465
|
-
io
|
|
4655
|
+
io,
|
|
4656
|
+
updater: options.updater ?? createQMindCliUpdater({ identity: {
|
|
4657
|
+
artifactKind: "npm",
|
|
4658
|
+
command: distribution.command,
|
|
4659
|
+
currentVersion: "3.1.1",
|
|
4660
|
+
distribution: distribution.id,
|
|
4661
|
+
executablePath: process.execPath,
|
|
4662
|
+
package: distribution.package,
|
|
4663
|
+
platform: process.platform,
|
|
4664
|
+
publicRoot: distribution.nativePublicRoot
|
|
4665
|
+
} })
|
|
4466
4666
|
};
|
|
4467
4667
|
const normalized = normalizeLegacyArgv(argv);
|
|
4468
4668
|
const requiresLegacyAction = normalized.length === 0 || normalized.length === 1 && (/* @__PURE__ */ new Set([
|
|
@@ -565,6 +565,7 @@ 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(),
|
|
568
569
|
files: z.array(sourceTreeNodeSchema).default([]),
|
|
569
570
|
hasChildren: z.boolean().optional(),
|
|
570
571
|
id: z.string().min(1),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as sourceUploadCapabilitiesSchema, m as requiredString, n as call } from "./shared-
|
|
1
|
+
import { H as sourceUploadCapabilitiesSchema, m as requiredString, n as call } from "./shared-9iPJsfjP.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-
|
|
2
|
-
import { t as preflightSourceUpload } from "./source-upload-
|
|
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-9iPJsfjP.js";
|
|
2
|
+
import { t as preflightSourceUpload } from "./source-upload-mZ-N52xb.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
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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(
|
|
114
|
+
...requestOptions(operation)
|
|
103
115
|
};
|
|
104
116
|
}
|
|
105
|
-
function signedUploadRequest(ticket, source, progress,
|
|
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(
|
|
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,
|
|
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,
|
|
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,
|
|
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.
|
|
3
|
+
"version": "3.1.1",
|
|
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
|
-
"@
|
|
41
|
-
"@ali/qmind-
|
|
41
|
+
"@types/semver": "7.8.0",
|
|
42
|
+
"@ali/qmind-node-host": "^2.2.34",
|
|
43
|
+
"@ali/qmind-sdk": "^0.15.24"
|
|
42
44
|
},
|
|
43
45
|
"license": "UNLICENSED"
|
|
44
46
|
}
|