@qoder-ai/qmind-cli 5.0.0 → 5.1.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 +6 -0
- package/CHANGELOG.zh-CN.md +6 -0
- package/README.md +12 -1
- package/README.zh-CN.md +12 -1
- package/dist/{data-sources-DItXSL_s.js → data-sources-BMWzGZMy.js} +5 -2
- package/dist/{imports-CSg7ebnN.js → imports-DHdWJ9rK.js} +1 -1
- package/dist/{management-iTQ9-Osc.js → management-D4dfHim9.js} +1 -1
- package/dist/{nezha-B_SP8BvK.js → nezha-DtT7HGFc.js} +1 -1
- package/dist/{notes-BUq1ciGO.js → notes-Cz178zE-.js} +1 -1
- package/dist/qmind.js +228 -52
- package/dist/{shared-evTnu_EB.js → shared-CWO5bxZy.js} +165 -147
- package/dist/{source-upload-DckYHoRo.js → source-upload-GjQToHLv.js} +1 -1
- package/dist/{transfers-C0pXH5Qe.js → transfers-BUZM2vVy.js} +2 -2
- package/dist/{wiki-_a2EAozi.js → wiki-C76wZ3j_.js} +2 -2
- package/dist/{wiki-branches-DViaqEOy.js → wiki-branches-ClpusERr.js} +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ 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
|
+
## 5.1.0
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- 026d4ff: Use `retrieve --image <path>` to search with an image alone or combine it with text in a single notebook or across notebooks. JSON and NDJSON expose inline images from matching results.
|
|
12
|
+
|
|
7
13
|
## 5.0.0
|
|
8
14
|
|
|
9
15
|
### Major Changes
|
package/CHANGELOG.zh-CN.md
CHANGED
package/README.md
CHANGED
|
@@ -189,7 +189,18 @@ qmind retrieve --nb <notebook-id> --unified --score-threshold 0.6 'Deployment pr
|
|
|
189
189
|
qmind retrieve --targets '[{"notebookId":"nb-1","sourceIds":["source-1"]},{"notebookId":"nb-2","sourceIds":["source-2"]}]' --max-results 8 'Deployment process'
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
`--targets` conflicts with `--nb` and `--sources` and supports independent Source filters per notebook. Unified retrieval defaults to maxResults=8 (1..50), with optional topK (1..100); zero selects the workflow default. There may be at most 32 unique targets. Results use the envelope above: read `data.chunks/data.promptContext`. `--score-threshold` accepts 0..1
|
|
192
|
+
`--targets` conflicts with `--nb` and `--sources` and supports independent Source filters per notebook. Unified retrieval defaults to maxResults=8 (1..50), with optional topK (1..100); zero selects the workflow default. There may be at most 32 unique targets. Results use the envelope above: read `data.chunks/data.promptContext`. `--score-threshold` accepts 0..1 for non-OTS retrieval on either path. Zero budgets on the existing path still use server defaults; scripts are not silently migrated.
|
|
193
|
+
|
|
194
|
+
### Search with an image
|
|
195
|
+
|
|
196
|
+
Use `--image <path>` with a single local JPEG, PNG, WebP, BMP, TIFF or GIF file up to 10 MiB. Omit the query for image-only retrieval, or add up to 128 UTF-16 code units of text as a positional query or `--query`. Image queries require OTS retrieval on the server.
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
qmind retrieve --nb nb-1 --image ./diagram.png --format json
|
|
200
|
+
qmind retrieve --targets '[{"notebookId":"nb-1","sourceIds":["source-1"]},{"notebookId":"nb-2"}]' --image ./diagram.png "Find the deployment steps" --format json
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Use `--format json` or `--format ndjson` to read returned image bytes. Direct `--nb` retrieval exposes the data URL in `chunks[].metadata.imageDataUrl` (or `metadata.imageDataUrl` on each NDJSON chunk). With `--unified` or `--targets`, an image hit can contain `data.chunks[].image` with `mimeType` and Base64 `data`.
|
|
193
204
|
|
|
194
205
|
## Scheduled task configuration
|
|
195
206
|
|
package/README.zh-CN.md
CHANGED
|
@@ -189,7 +189,18 @@ qmind retrieve --nb <notebook-id> --unified --score-threshold 0.6 '部署流程'
|
|
|
189
189
|
qmind retrieve --targets '[{"notebookId":"nb-1","sourceIds":["source-1"]},{"notebookId":"nb-2","sourceIds":["source-2"]}]' --max-results 8 '部署流程'
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
`--targets` 不能与 `--nb` 或 `--sources` 组合,每库可独立过滤 Source。统一检索默认 maxResults=8(1..50),topK 可选(1..100),0 表示使用该 workflow 的默认值;最多 32 个唯一目标。结果采用上述结构化 envelope,读取 `data.chunks/data.promptContext`;`--score-threshold`
|
|
192
|
+
`--targets` 不能与 `--nb` 或 `--sources` 组合,每库可独立过滤 Source。统一检索默认 maxResults=8(1..50),topK 可选(1..100),0 表示使用该 workflow 的默认值;最多 32 个唯一目标。结果采用上述结构化 envelope,读取 `data.chunks/data.promptContext`;`--score-threshold` 在两种入口均接受 0..1,由非 OTS 检索引擎执行。旧路径的零预算继续使用服务端默认值,不隐式切换旧脚本。
|
|
193
|
+
|
|
194
|
+
### 图片和图文检索
|
|
195
|
+
|
|
196
|
+
用 `--image <path>` 指定一张不超过 10 MiB 的本地图片,支持 JPEG、PNG、WebP、BMP、TIFF 和 GIF。省略文字时按图检索。图文联合检索可用位置参数或 `--query` 传入最多 128 个 UTF-16 代码单元的文字。含图查询需要服务端启用 OTS 检索。
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
qmind retrieve --nb nb-1 --image ./diagram.png --format json
|
|
200
|
+
qmind retrieve --targets '[{"notebookId":"nb-1","sourceIds":["source-1"]},{"notebookId":"nb-2"}]' --image ./diagram.png "查找部署步骤" --format json
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
使用 `--format json` 或 `--format ndjson` 读取命中图片。直接用 `--nb` 时,图片 data URL 在 `chunks[].metadata.imageDataUrl`,NDJSON 则在每条 chunk 的 `metadata.imageDataUrl`。使用 `--unified` 或 `--targets` 时,命中可能在 `data.chunks[].image` 提供 `mimeType` 和 Base64 `data`。
|
|
193
204
|
|
|
194
205
|
## 定时任务配置
|
|
195
206
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { at as dataSourceListSchema, ct as dataSourceRunsSchema, it as dataSourceConfigurationSchema, lt as dataSourceSchema, m as requiredString, n as call, ot as dataSourcePreviewSchema, p as queryPath, st as dataSourceResourceSchema, x as qmindPath } from "./shared-CWO5bxZy.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region ../sdk/src/operations/data-sources.ts
|
|
4
4
|
function createDataSourceOperations(context) {
|
|
@@ -18,7 +18,10 @@ function createDataSourceOperations(context) {
|
|
|
18
18
|
body: {
|
|
19
19
|
configuration: dataSourceConfigurationSchema.parse(configuration),
|
|
20
20
|
credentials: credentials(secret),
|
|
21
|
-
...parentId ? { parentId } : {}
|
|
21
|
+
...parentId ? { parentId } : {},
|
|
22
|
+
...options?.checkImport ? { checkImport: true } : {},
|
|
23
|
+
...options?.wikiSpaceUrl ? { wikiSpaceUrl: options.wikiSpaceUrl } : {},
|
|
24
|
+
...options?.savedDataSourceId ? { savedDataSourceId: options.savedDataSourceId } : {}
|
|
22
25
|
},
|
|
23
26
|
schema: dataSourcePreviewSchema,
|
|
24
27
|
callOptions: options
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as fullSiteURLImportConfirmationSchema, C as aliDingImportRunItemListSchema, P as importProvidersSchema, _ as assertCapability, a as invalidArgument, d as pagination, j as fullSiteURLImportDiscoverySchema, m as requiredString, n as call, p as queryPath, rt as qmindFullSiteURLImportPageLimit, w as aliDingImportRunSchema, x as qmindPath } from "./shared-CWO5bxZy.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 {
|
|
1
|
+
import { a as invalidArgument, c as optionalRecord, l as optionalString, m as requiredString, n as call, nt as voidResponseSchema, r as compactUndefined, s as optionalBoolean, t as assertNonEmptyPatch, ut as QMindError, x as qmindPath } from "./shared-CWO5bxZy.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 {
|
|
1
|
+
import { b as pathBuilder, ut as QMindError } from "./shared-CWO5bxZy.js";
|
|
2
2
|
//#region ../sdk/src/nezha.ts
|
|
3
3
|
const dashboardPath = pathBuilder("/api/v1");
|
|
4
4
|
const sashPath = pathBuilder("/sash/api/v1");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as optionalRecord, d as pagination, h as requiredText, l as optionalString, m as requiredString, n as call, nt as voidResponseSchema, p as queryPath, r as compactUndefined, t as assertNonEmptyPatch, tt as timestampSchema, x as qmindPath } from "./shared-CWO5bxZy.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,14 +1,14 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { n as nezhaWebOfficePath } from "./nezha-
|
|
3
|
-
import { t as preflightSourceUpload } from "./source-upload-
|
|
1
|
+
import { $ as taskRunListSchema, B as sourceActionAccessSchema, D as chatMessageListSchema, E as cancelQuestionResultSchema, F as notebookListSchema, G as sourcePreviewSchema, H as sourceContentSchema, I as notebookSchema, J as sourceSchema, K as sourceQuotaSchema, L as retrieveNotebooksResultSchema, M as imageUploadTicketSchema, N as imageUrlsSchema, O as chatSessionListSchema, Q as sourceWebOfficeTokenSchema, R as retrieveResultSchema, S as qmindRoutes, T as batchDeleteResultSchema, U as sourceImportResultsSchema, V as sourceChildrenCountsSchema, W as sourceListSchema, Y as sourceUploadCapabilitiesSchema, Z as sourceWebOfficeSessionSchema, _ as assertCapability, a as invalidArgument$1, c as optionalRecord, d as pagination$1, et as taskRunSchema, f as positiveInteger$1, g as stringList, i as httpUrl, k as chatSessionSchema, l as optionalString$1, m as requiredString$1, n as call, nt as voidResponseSchema, o as nonNegativeInteger$1, p as queryPath, q as sourceRawContentSchema, r as compactUndefined, s as optionalBoolean, t as assertNonEmptyPatch, u as optionalTrimmedString, ut as QMindError, v as executeStream, x as qmindPath, z as sharedNotebookListSchema } from "./shared-CWO5bxZy.js";
|
|
2
|
+
import { n as nezhaWebOfficePath } from "./nezha-DtT7HGFc.js";
|
|
3
|
+
import { t as preflightSourceUpload } from "./source-upload-GjQToHLv.js";
|
|
4
4
|
import { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
7
|
-
import { chmod, copyFile, link, lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
7
|
+
import { chmod, copyFile, link, lstat, mkdir, mkdtemp, open, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
8
8
|
import { homedir, tmpdir } from "node:os";
|
|
9
9
|
import lockfile from "proper-lockfile";
|
|
10
|
-
import open from "open";
|
|
11
|
-
import { createReadStream, createWriteStream } from "node:fs";
|
|
10
|
+
import open$1 from "open";
|
|
11
|
+
import { constants, createReadStream, createWriteStream } from "node:fs";
|
|
12
12
|
import { Readable } from "node:stream";
|
|
13
13
|
import { pipeline } from "node:stream/promises";
|
|
14
14
|
import { createParser } from "eventsource-parser";
|
|
@@ -178,6 +178,79 @@ function isQMindRetiredScene(scene) {
|
|
|
178
178
|
return scene === "compilation" || scene === "lint";
|
|
179
179
|
}
|
|
180
180
|
//#endregion
|
|
181
|
+
//#region ../sdk/src/retrieval-image.ts
|
|
182
|
+
const QMIND_RETRIEVAL_IMAGE_MAX_BYTES = 10485760;
|
|
183
|
+
const maxQueryImageBase64Length = 4 * Math.ceil(QMIND_RETRIEVAL_IMAGE_MAX_BYTES / 3);
|
|
184
|
+
const imageFormats = /* @__PURE__ */ new Set([
|
|
185
|
+
"jpeg",
|
|
186
|
+
"png",
|
|
187
|
+
"webp",
|
|
188
|
+
"bmp",
|
|
189
|
+
"tiff",
|
|
190
|
+
"gif"
|
|
191
|
+
]);
|
|
192
|
+
function normalizeImageFormat(value) {
|
|
193
|
+
const format = value.toLowerCase();
|
|
194
|
+
return format === "jpg" ? "jpeg" : format;
|
|
195
|
+
}
|
|
196
|
+
function isBase64(value) {
|
|
197
|
+
return value.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/.test(value);
|
|
198
|
+
}
|
|
199
|
+
/** Check the encoding and size accepted by the retrieval API. Mind validates the image bytes. */
|
|
200
|
+
function qmindRetrievalImageIssue({ imageBase64, imageFormat, query }) {
|
|
201
|
+
if (imageBase64 === void 0) return imageFormat === void 0 ? void 0 : {
|
|
202
|
+
field: "imageFormat",
|
|
203
|
+
message: "imageFormat requires imageBase64"
|
|
204
|
+
};
|
|
205
|
+
if (query !== void 0 && query.length > 128) return {
|
|
206
|
+
field: "query",
|
|
207
|
+
message: `image retrieval query must be at most 128 UTF-16 units`
|
|
208
|
+
};
|
|
209
|
+
let payload = imageBase64;
|
|
210
|
+
const format = imageFormat === void 0 ? void 0 : normalizeImageFormat(imageFormat);
|
|
211
|
+
if (/^data:/i.test(imageBase64)) {
|
|
212
|
+
const header = /^data:image\/([a-zA-Z]{3,4});base64,/.exec(imageBase64);
|
|
213
|
+
const urlFormat = normalizeImageFormat(header?.[1] ?? "");
|
|
214
|
+
if (!header || !imageFormats.has(urlFormat)) return {
|
|
215
|
+
field: "imageBase64",
|
|
216
|
+
message: "invalid image data URL header"
|
|
217
|
+
};
|
|
218
|
+
if (format !== void 0 && format !== urlFormat) return {
|
|
219
|
+
field: "imageFormat",
|
|
220
|
+
message: "imageFormat does not match data URL"
|
|
221
|
+
};
|
|
222
|
+
payload = imageBase64.slice(header[0].length);
|
|
223
|
+
} else if (format === void 0 || !imageFormats.has(format)) return {
|
|
224
|
+
field: "imageFormat",
|
|
225
|
+
message: "raw imageBase64 requires imageFormat (jpeg, jpg, png, webp, bmp, tiff or gif)"
|
|
226
|
+
};
|
|
227
|
+
const tooLarge = {
|
|
228
|
+
field: "imageBase64",
|
|
229
|
+
message: "query image exceeds 10 MiB"
|
|
230
|
+
};
|
|
231
|
+
if (payload.length > maxQueryImageBase64Length) return tooLarge;
|
|
232
|
+
const base64 = payload.replace(/[\r\n]/g, "");
|
|
233
|
+
if (!isBase64(base64)) return {
|
|
234
|
+
field: "imageBase64",
|
|
235
|
+
message: "invalid image base64"
|
|
236
|
+
};
|
|
237
|
+
const padding = base64.endsWith("==") ? 2 : base64.endsWith("=") ? 1 : 0;
|
|
238
|
+
return base64.length / 4 * 3 - padding > 10485760 ? tooLarge : void 0;
|
|
239
|
+
}
|
|
240
|
+
/** Read an inline image from a retrieval hit without resolving URLs or decoding image bytes. */
|
|
241
|
+
function readQMindRetrievalImage(chunk) {
|
|
242
|
+
const url = chunk.metadata?.imageDataUrl;
|
|
243
|
+
if (typeof url !== "string" || url.length > 14e5) return void 0;
|
|
244
|
+
const header = /^data:(image\/(?:jpeg|png|webp));base64,/.exec(url);
|
|
245
|
+
if (!header) return void 0;
|
|
246
|
+
const data = url.slice(header[0].length).replace(/[\r\n]/g, "");
|
|
247
|
+
if (!isBase64(data)) return void 0;
|
|
248
|
+
return {
|
|
249
|
+
mimeType: header[1],
|
|
250
|
+
data
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
//#endregion
|
|
181
254
|
//#region ../sdk/src/operations/agents.ts
|
|
182
255
|
function isRecord$2(value) {
|
|
183
256
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -223,11 +296,24 @@ function billingContext(value) {
|
|
|
223
296
|
});
|
|
224
297
|
}
|
|
225
298
|
function retrieveBody(input) {
|
|
226
|
-
|
|
299
|
+
const fields = optionalRecord(input, "input");
|
|
300
|
+
if (!fields) throw invalidArgument$1("input must be an object", "input");
|
|
301
|
+
if (fields.imageUrl !== void 0 || fields.image_url !== void 0) throw invalidArgument$1("remote image URLs are unsupported", "imageUrl");
|
|
302
|
+
const imageBase64 = input.imageBase64 === void 0 ? void 0 : requiredString$1(input.imageBase64, "imageBase64");
|
|
303
|
+
const imageFormat = optionalTrimmedString(input.imageFormat, "imageFormat");
|
|
304
|
+
const query = imageBase64 ? optionalTrimmedString(input.query, "query") : requiredString$1(input.query, "query");
|
|
305
|
+
const issue = qmindRetrievalImageIssue({
|
|
306
|
+
imageBase64,
|
|
307
|
+
imageFormat: imageBase64 === void 0 ? input.imageFormat : imageFormat,
|
|
308
|
+
query
|
|
309
|
+
});
|
|
310
|
+
if (issue) throw invalidArgument$1(issue.message, issue.field);
|
|
227
311
|
return compactUndefined({
|
|
312
|
+
imageBase64,
|
|
313
|
+
imageFormat,
|
|
228
314
|
billingContext: billingContext(input.billingContext),
|
|
229
315
|
maxResults: nonNegativeInteger$1(input.maxResults, "maxResults"),
|
|
230
|
-
query
|
|
316
|
+
query,
|
|
231
317
|
queryHints: queryHints(input.queryHints),
|
|
232
318
|
scoreThreshold: finiteNumber(input.scoreThreshold, "scoreThreshold"),
|
|
233
319
|
sourceIds: stringList(input.sourceIds ?? [], "sourceIds"),
|
|
@@ -572,7 +658,7 @@ function createAgentOperations(context) {
|
|
|
572
658
|
//#region ../sdk/src/operations/notebooks.ts
|
|
573
659
|
function createNotebookOperations(context) {
|
|
574
660
|
let wikiOperations;
|
|
575
|
-
const loadWiki = () => wikiOperations ??= import("./wiki-branches-
|
|
661
|
+
const loadWiki = () => wikiOperations ??= import("./wiki-branches-ClpusERr.js").then(({ createWikiBranchOperations }) => createWikiBranchOperations(context));
|
|
576
662
|
return {
|
|
577
663
|
async copyFeaturedNotebook(notebookId, options) {
|
|
578
664
|
const notebook = requiredString$1(notebookId, "notebookId");
|
|
@@ -1602,7 +1688,7 @@ const noteOperationNames = [
|
|
|
1602
1688
|
function createLazyDataSourceOperations(context) {
|
|
1603
1689
|
let operations;
|
|
1604
1690
|
const load = () => {
|
|
1605
|
-
operations ??= import("./data-sources-
|
|
1691
|
+
operations ??= import("./data-sources-BMWzGZMy.js").then(({ createDataSourceOperations }) => createDataSourceOperations(context));
|
|
1606
1692
|
return operations;
|
|
1607
1693
|
};
|
|
1608
1694
|
return {
|
|
@@ -1622,7 +1708,7 @@ function createLazyDataSourceOperations(context) {
|
|
|
1622
1708
|
function createLazyTransferOperations(context) {
|
|
1623
1709
|
let operations;
|
|
1624
1710
|
const load = () => {
|
|
1625
|
-
operations ??= import("./transfers-
|
|
1711
|
+
operations ??= import("./transfers-BUZM2vVy.js").then(({ createTransferOperations }) => createTransferOperations(context));
|
|
1626
1712
|
return operations;
|
|
1627
1713
|
};
|
|
1628
1714
|
return {
|
|
@@ -1633,7 +1719,7 @@ function createLazyTransferOperations(context) {
|
|
|
1633
1719
|
function createLazyWikiOperations(context) {
|
|
1634
1720
|
let operations;
|
|
1635
1721
|
const load = () => {
|
|
1636
|
-
operations ??= import("./wiki-
|
|
1722
|
+
operations ??= import("./wiki-C76wZ3j_.js").then(({ createWikiOperations }) => createWikiOperations(context));
|
|
1637
1723
|
return operations;
|
|
1638
1724
|
};
|
|
1639
1725
|
return {
|
|
@@ -1645,7 +1731,7 @@ function createLazyWikiOperations(context) {
|
|
|
1645
1731
|
function createLazyNoteOperations(context) {
|
|
1646
1732
|
let operations;
|
|
1647
1733
|
const load = () => {
|
|
1648
|
-
operations ??= import("./notes-
|
|
1734
|
+
operations ??= import("./notes-Cz178zE-.js").then(({ createNoteOperations }) => createNoteOperations(context));
|
|
1649
1735
|
return operations;
|
|
1650
1736
|
};
|
|
1651
1737
|
return Object.fromEntries(noteOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
|
|
@@ -1653,7 +1739,7 @@ function createLazyNoteOperations(context) {
|
|
|
1653
1739
|
function createLazyImportOperations(context) {
|
|
1654
1740
|
let operations;
|
|
1655
1741
|
const load = () => {
|
|
1656
|
-
operations ??= import("./imports-
|
|
1742
|
+
operations ??= import("./imports-DHdWJ9rK.js").then(({ createImportOperations }) => createImportOperations(context));
|
|
1657
1743
|
return operations;
|
|
1658
1744
|
};
|
|
1659
1745
|
return Object.fromEntries(importOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
|
|
@@ -1661,7 +1747,7 @@ function createLazyImportOperations(context) {
|
|
|
1661
1747
|
function createLazyManagementOperations(context) {
|
|
1662
1748
|
let operations;
|
|
1663
1749
|
const load = () => {
|
|
1664
|
-
operations ??= import("./management-
|
|
1750
|
+
operations ??= import("./management-D4dfHim9.js").then(({ createManagementOperations }) => createManagementOperations(context));
|
|
1665
1751
|
return operations;
|
|
1666
1752
|
};
|
|
1667
1753
|
return Object.fromEntries(managementOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
|
|
@@ -1760,7 +1846,7 @@ function canonicalize(object, seen = /* @__PURE__ */ new Set()) {
|
|
|
1760
1846
|
}
|
|
1761
1847
|
//#endregion
|
|
1762
1848
|
//#region ../agent-core/src/contract.ts
|
|
1763
|
-
const CONTRACT_VERSION = "8.
|
|
1849
|
+
const CONTRACT_VERSION = "8.1.0";
|
|
1764
1850
|
const AGENT_ERROR_CODES = Object.freeze([
|
|
1765
1851
|
"invalid_input",
|
|
1766
1852
|
"selection_required",
|
|
@@ -1811,17 +1897,35 @@ const listNotebooksInputSchema = z.object({
|
|
|
1811
1897
|
cursor: z.string().min(1).max(512).optional()
|
|
1812
1898
|
}).strict();
|
|
1813
1899
|
const retrieveInputSchema = z.object({
|
|
1900
|
+
imageBase64: z.string().trim().min(1).describe("Image data URL or standard Base64. One image, up to 10 MiB before encoding.").optional(),
|
|
1901
|
+
imageFormat: z.string().trim().min(1).describe("Required for raw Base64: jpeg, jpg, png, webp, bmp, tiff or gif.").optional(),
|
|
1814
1902
|
maxResults: z.number().int().min(1).max(50).default(8),
|
|
1815
1903
|
notebookId: opaqueId.optional(),
|
|
1816
1904
|
targets: z.array(z.object({
|
|
1817
1905
|
notebookId: opaqueId,
|
|
1818
1906
|
sourceIds: z.array(opaqueId).min(1).max(100).refine((ids) => new Set(ids).size === ids.length).optional()
|
|
1819
1907
|
}).strict()).min(1).max(32).refine((targets) => new Set(targets.map((target) => target.notebookId)).size === targets.length).optional(),
|
|
1820
|
-
query: z.string().trim().min(1).max(2e3),
|
|
1821
|
-
scoreThreshold: z.number().min(0).max(1).optional(),
|
|
1908
|
+
query: z.string().trim().min(1).max(2e3).describe(`Text query, up to 128 UTF-16 units with an image.`).optional(),
|
|
1909
|
+
scoreThreshold: z.number().min(0).max(1).describe("Minimum score for non-OTS retrieval.").optional(),
|
|
1822
1910
|
sourceIds: z.array(opaqueId).min(1).max(50).refine((values) => new Set(values).size === values.length, { message: "sourceIds must be unique" }).optional(),
|
|
1823
1911
|
topK: z.number().int().min(1).max(100).optional()
|
|
1824
|
-
}).strict().refine((value) => value.notebookId === void 0 || value.targets === void 0, { message: "notebookId and targets are mutually exclusive" }).refine((value) => value.sourceIds === void 0 || value.notebookId !== void 0, { message: "sourceIds requires notebookId; otherwise put sourceIds inside each target" })
|
|
1912
|
+
}).strict().refine((value) => value.notebookId === void 0 || value.targets === void 0, { message: "notebookId and targets are mutually exclusive" }).refine((value) => value.sourceIds === void 0 || value.notebookId !== void 0, { message: "sourceIds requires notebookId; otherwise put sourceIds inside each target" }).superRefine(({ query, imageBase64, imageFormat }, context) => {
|
|
1913
|
+
if (query === void 0 && imageBase64 === void 0 && imageFormat === void 0) context.addIssue({
|
|
1914
|
+
code: "custom",
|
|
1915
|
+
path: ["query"],
|
|
1916
|
+
message: "Provide query or imageBase64"
|
|
1917
|
+
});
|
|
1918
|
+
const issue = qmindRetrievalImageIssue({
|
|
1919
|
+
imageBase64,
|
|
1920
|
+
imageFormat,
|
|
1921
|
+
query
|
|
1922
|
+
});
|
|
1923
|
+
if (issue) context.addIssue({
|
|
1924
|
+
code: "custom",
|
|
1925
|
+
path: [issue.field],
|
|
1926
|
+
message: issue.message
|
|
1927
|
+
});
|
|
1928
|
+
});
|
|
1825
1929
|
const listSourcesInputSchema = z.object({
|
|
1826
1930
|
notebookId: opaqueId,
|
|
1827
1931
|
page,
|
|
@@ -1951,7 +2055,7 @@ const agentToolDefinitions = Object.freeze([
|
|
|
1951
2055
|
},
|
|
1952
2056
|
{
|
|
1953
2057
|
deadlineMs: 6e4,
|
|
1954
|
-
description: `Retrieve globally ranked context from up to 32 QMind notebooks using
|
|
2058
|
+
description: `Retrieve globally ranked context from up to 32 QMind notebooks using text (query), an image (imageBase64), or both. For imageBase64 send an image data URL or raw Base64 with imageFormat; use actual image bytes from an attachment. Discover candidates with list_notebooks; continue with nextCursor as needed and select relevant targets using summary/topics (overview), with title/description as fallback. The server authorizes each target within the current retrieval scope, including configured sharing groups. Do not select or switch organizations. Workspace-linked notebooks are preferred automatically; preference never expands scope. Use notebookId for one notebook or targets [{notebookId, sourceIds?}] for one to 32 notebooks. Omitted selection uses configured defaults; maxResults is the global result limit.`,
|
|
1955
2059
|
id: "qmind.retrieve",
|
|
1956
2060
|
intent: "read",
|
|
1957
2061
|
leaf: "retrieve"
|
|
@@ -2111,6 +2215,7 @@ const canonicalDescriptor = canonicalize(deepFreeze({
|
|
|
2111
2215
|
defaultRetrievalMode: "all?; explicit host opt-in searches each authorized target with concurrency at most 3 and bounded partial results",
|
|
2112
2216
|
defaultNotebookRelationship: "owned|shared|featured|all?; host discovery default independent of notebookPolicy; omitted means owned",
|
|
2113
2217
|
approvedDeletionTargets: "SourceDeletionTarget[1..100]?; host-only, must match fresh targets",
|
|
2218
|
+
includeRetrievalImages: "boolean?; host opt-in to inline images in retrieve results",
|
|
2114
2219
|
notebookPolicy: { selectNotebook: "host callback: excluded|allowed|preferred; request-local; intersects server ACL" },
|
|
2115
2220
|
notebookScope: {
|
|
2116
2221
|
allowedNotebookIds: "uniqueOpaqueId[]",
|
|
@@ -2284,11 +2389,13 @@ const canonicalDescriptor = canonicalize(deepFreeze({
|
|
|
2284
2389
|
defaults: { maxResults: 8 },
|
|
2285
2390
|
id: "qmind.retrieve",
|
|
2286
2391
|
input: {
|
|
2392
|
+
imageBase64: "image data URL or standard Base64?; at most 10 MiB decoded",
|
|
2393
|
+
imageFormat: "jpeg|jpg|png|webp|bmp|tiff|gif?; required for raw Base64",
|
|
2287
2394
|
maxResults: "integer:1..50?",
|
|
2288
2395
|
notebookId: "opaqueId?; exclusive with targets",
|
|
2289
|
-
targets:
|
|
2290
|
-
query:
|
|
2291
|
-
scoreThreshold: "number:0..1
|
|
2396
|
+
targets: `[{notebookId, sourceIds?}][1..32]?; unique notebooks`,
|
|
2397
|
+
query: `string:1..2000?; at most 128 UTF-16 units with an image; at least one of query and imageBase64 is required`,
|
|
2398
|
+
scoreThreshold: "number:0..1?; applies to non-OTS retrieval",
|
|
2292
2399
|
sourceIds: "uniqueOpaqueId[1..50]?",
|
|
2293
2400
|
topK: "integer:1..100?"
|
|
2294
2401
|
},
|
|
@@ -2298,6 +2405,7 @@ const canonicalDescriptor = canonicalize(deepFreeze({
|
|
|
2298
2405
|
chunkId: "opaqueId",
|
|
2299
2406
|
chunkIndex: "integer:0..",
|
|
2300
2407
|
content: "string",
|
|
2408
|
+
image: "{mimeType: image/jpeg|image/png|image/webp, data: Base64}?; bounded inline image",
|
|
2301
2409
|
notebookId: "opaqueId",
|
|
2302
2410
|
notebookTitle: "string",
|
|
2303
2411
|
originUrl: "string?",
|
|
@@ -3173,6 +3281,7 @@ const sourceStatus = /* @__PURE__ */ new Set([
|
|
|
3173
3281
|
"unsupported",
|
|
3174
3282
|
"failed"
|
|
3175
3283
|
]);
|
|
3284
|
+
const maxRetrievalImageChars = 28e5;
|
|
3176
3285
|
/**
|
|
3177
3286
|
* Snapshots and validates host policy at the Core boundary. Invocation context is not model input,
|
|
3178
3287
|
* but it still crosses an adapter seam and must fail closed when malformed.
|
|
@@ -3304,7 +3413,7 @@ async function retrieve(client, input, invocation) {
|
|
|
3304
3413
|
for (let offset = 0; offset < targets.length; offset += batchSize) batches.push(targets.slice(offset, offset + batchSize));
|
|
3305
3414
|
const results = [];
|
|
3306
3415
|
const warnings = [];
|
|
3307
|
-
|
|
3416
|
+
const failedCodes = /* @__PURE__ */ new Set();
|
|
3308
3417
|
const request = async (batch) => {
|
|
3309
3418
|
return client.retrieveNotebooks({
|
|
3310
3419
|
targets: batch.map(({ notebookId, sourceIds }) => ({
|
|
@@ -3313,7 +3422,9 @@ async function retrieve(client, input, invocation) {
|
|
|
3313
3422
|
...notebookSelection(invocation, notebookId) === "preferred" ? { preference: "preferred" } : {}
|
|
3314
3423
|
})),
|
|
3315
3424
|
maxResults: input.maxResults,
|
|
3316
|
-
query: input.query,
|
|
3425
|
+
...input.query === void 0 ? {} : { query: input.query },
|
|
3426
|
+
...input.imageBase64 === void 0 ? {} : { imageBase64: input.imageBase64 },
|
|
3427
|
+
...input.imageFormat === void 0 ? {} : { imageFormat: input.imageFormat },
|
|
3317
3428
|
...input.scoreThreshold === void 0 ? {} : { scoreThreshold: input.scoreThreshold },
|
|
3318
3429
|
...input.topK === void 0 ? {} : { topK: input.topK }
|
|
3319
3430
|
}, callOptions(invocation));
|
|
@@ -3327,8 +3438,9 @@ async function retrieve(client, input, invocation) {
|
|
|
3327
3438
|
settled.forEach((entry, index) => {
|
|
3328
3439
|
if (entry.status === "fulfilled") results.push(entry.value);
|
|
3329
3440
|
else {
|
|
3330
|
-
|
|
3331
|
-
if (
|
|
3441
|
+
const code = errorCode(entry.reason);
|
|
3442
|
+
if (batches.length === 1 || qmindOrganizationPolicyError(entry.reason) || code === "unauthenticated") throw entry.reason;
|
|
3443
|
+
failedCodes.add(code);
|
|
3332
3444
|
for (const target of current[index]) warnings.push({
|
|
3333
3445
|
code: "notebook_search_failed",
|
|
3334
3446
|
notebookId: target.notebookId
|
|
@@ -3336,7 +3448,10 @@ async function retrieve(client, input, invocation) {
|
|
|
3336
3448
|
}
|
|
3337
3449
|
});
|
|
3338
3450
|
}
|
|
3339
|
-
if (results.length === 0)
|
|
3451
|
+
if (results.length === 0) {
|
|
3452
|
+
const [code] = failedCodes;
|
|
3453
|
+
return failure$1(invocation.operationId, failedCodes.size === 1 && (code === "permission_denied" || code === "invalid_input") ? code : "upstream_unavailable", "Notebook retrieval failed.");
|
|
3454
|
+
}
|
|
3340
3455
|
const result = {
|
|
3341
3456
|
chunks: results.flatMap((item) => item.chunks.map((chunk) => {
|
|
3342
3457
|
if (chunkLineRange(chunk.metadata).lineStart !== void 0) return chunk;
|
|
@@ -3353,9 +3468,19 @@ async function retrieve(client, input, invocation) {
|
|
|
3353
3468
|
reranked: results.length === 1 && results[0].reranked
|
|
3354
3469
|
};
|
|
3355
3470
|
const bounded = result.chunks.slice(0, input.maxResults);
|
|
3471
|
+
let remainingImageChars = maxRetrievalImageChars;
|
|
3356
3472
|
return {
|
|
3357
3473
|
data: {
|
|
3358
|
-
chunks: bounded.map(
|
|
3474
|
+
chunks: bounded.map((chunk) => {
|
|
3475
|
+
const data = chunkData(chunk);
|
|
3476
|
+
const image = invocation.includeRetrievalImages === true ? readQMindRetrievalImage(chunk) : void 0;
|
|
3477
|
+
if (image === void 0 || image.data.length > remainingImageChars) return data;
|
|
3478
|
+
remainingImageChars -= image.data.length;
|
|
3479
|
+
return {
|
|
3480
|
+
...data,
|
|
3481
|
+
image
|
|
3482
|
+
};
|
|
3483
|
+
}),
|
|
3359
3484
|
promptContext: chunkPromptContext(bounded),
|
|
3360
3485
|
reranked: result.reranked,
|
|
3361
3486
|
total: result.total
|
|
@@ -3805,6 +3930,7 @@ async function runQMindAgentOperation(dependencies, toolId, input, runtimeSignal
|
|
|
3805
3930
|
...fileSource === void 0 ? {} : { fileSource },
|
|
3806
3931
|
...dependencies.defaultNotebookIds === void 0 ? {} : { defaultNotebookIds: dependencies.defaultNotebookIds },
|
|
3807
3932
|
...operationContext.approvedDeletionTargets === void 0 ? {} : { approvedDeletionTargets: operationContext.approvedDeletionTargets },
|
|
3933
|
+
...operationContext.includeRetrievalImages === true ? { includeRetrievalImages: true } : {},
|
|
3808
3934
|
...operationContext.notebookScope === void 0 ? {} : { notebookScope: operationContext.notebookScope },
|
|
3809
3935
|
operationId,
|
|
3810
3936
|
signal,
|
|
@@ -5393,7 +5519,7 @@ function defaultReporter() {
|
|
|
5393
5519
|
}
|
|
5394
5520
|
function defaultBrowser() {
|
|
5395
5521
|
return Object.freeze({ async open(url) {
|
|
5396
|
-
(await open(url, { wait: false })).unref();
|
|
5522
|
+
(await open$1(url, { wait: false })).unref();
|
|
5397
5523
|
} });
|
|
5398
5524
|
}
|
|
5399
5525
|
async function tlsAuthority(path) {
|
|
@@ -5548,8 +5674,8 @@ function requestsNdjsonOutput(argv) {
|
|
|
5548
5674
|
//#region src/build-info.ts
|
|
5549
5675
|
/** Bundled identity, never inferred from argv, environment, or an endpoint. */
|
|
5550
5676
|
const QMIND_CLI_DISTRIBUTION = "global";
|
|
5551
|
-
const QMIND_CLI_VERSION = "5.
|
|
5552
|
-
const QMIND_CLI_BUILD_TIME = "2026-11-
|
|
5677
|
+
const QMIND_CLI_VERSION = "5.1.0";
|
|
5678
|
+
const QMIND_CLI_BUILD_TIME = "2026-11-23T13:41:36.000Z";
|
|
5553
5679
|
function qmindCliPlatform() {
|
|
5554
5680
|
return process.platform === "win32" ? "windows" : process.platform;
|
|
5555
5681
|
}
|
|
@@ -6307,6 +6433,7 @@ function renderRetrieve(value, format, multiNotebook = false) {
|
|
|
6307
6433
|
agentField(writer, "sourceUri", chunk.sourceUri);
|
|
6308
6434
|
agentField(writer, "score", chunk.score.toFixed(4));
|
|
6309
6435
|
agentField(writer, "tokenCount", chunk.tokenCount);
|
|
6436
|
+
agentField(writer, "imageMimeType", readQMindRetrievalImage(chunk)?.mimeType);
|
|
6310
6437
|
agentText(writer, "content", unescapeText(chunk.content));
|
|
6311
6438
|
});
|
|
6312
6439
|
value.citations.forEach((citation, index) => {
|
|
@@ -6356,6 +6483,8 @@ function renderRetrieve(value, format, multiNotebook = false) {
|
|
|
6356
6483
|
writer.line(`[${index + 1}] chunkId=${chunk.chunkId} sourceId=${chunk.sourceId} sourceTitle=${chunk.sourceTitle} score=${chunk.score.toFixed(4)} tokens=${chunk.tokenCount}`);
|
|
6357
6484
|
if ("notebookId" in chunk && "notebookTitle" in chunk) writer.line(` notebookId: ${oneLine(chunk.notebookId)} notebookTitle: ${oneLine(chunk.notebookTitle)}`);
|
|
6358
6485
|
if (chunk.sourceUri.length > 0) writer.line(` uri: ${chunk.sourceUri}`);
|
|
6486
|
+
const image = readQMindRetrievalImage(chunk);
|
|
6487
|
+
if (image !== void 0) writer.line(` image: ${image.mimeType}`);
|
|
6359
6488
|
if (chunk.content.length > 0) writer.line(` content: ${unescapeText(chunk.content)}`);
|
|
6360
6489
|
writer.line();
|
|
6361
6490
|
});
|
|
@@ -6946,11 +7075,12 @@ async function runCanonicalCommand(context, raw, tool, input) {
|
|
|
6946
7075
|
throw new QMindError("INVALID_ARGUMENT", `Invalid ${tool} arguments: ${fields.join(", ")}`);
|
|
6947
7076
|
}
|
|
6948
7077
|
const host = await hostFor(context, raw);
|
|
7078
|
+
const includeRetrievalImages = tool === "qmind.retrieve" && (raw.format === "json" || raw.format === "ndjson");
|
|
6949
7079
|
const result = await runQMindAgentOperation({
|
|
6950
7080
|
core: createQMindAgentCore(host.client),
|
|
6951
7081
|
createFileSource: (path) => host.createFileSource(path),
|
|
6952
7082
|
auditSink: { accept: () => {} }
|
|
6953
|
-
}, tool, parsed.data);
|
|
7083
|
+
}, tool, parsed.data, void 0, void 0, includeRetrievalImages ? { includeRetrievalImages: true } : void 0);
|
|
6954
7084
|
render(context, raw, {
|
|
6955
7085
|
kind: "json",
|
|
6956
7086
|
value: result
|
|
@@ -7058,6 +7188,44 @@ function registerCanonicalCommands(context, program) {
|
|
|
7058
7188
|
});
|
|
7059
7189
|
}
|
|
7060
7190
|
//#endregion
|
|
7191
|
+
//#region src/retrieval-image.ts
|
|
7192
|
+
async function readRetrievalImage(path) {
|
|
7193
|
+
const extension = extname(path).slice(1).toLowerCase();
|
|
7194
|
+
if (!/^(?:jpe?g|png|webp|bmp|tiff?|gif)$/.test(extension)) throw new QMindError("INVALID_ARGUMENT", "--image requires a JPEG, PNG, WebP, BMP, TIFF or GIF file");
|
|
7195
|
+
const tooLarge = new QMindError("INVALID_ARGUMENT", "--image must be at most 10 MiB");
|
|
7196
|
+
const unreadable = new QMindError("INVALID_ARGUMENT", "--image must be a readable, non-empty local file");
|
|
7197
|
+
const chunks = [];
|
|
7198
|
+
let size = 0;
|
|
7199
|
+
try {
|
|
7200
|
+
const file = await open(path, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
7201
|
+
try {
|
|
7202
|
+
const info = await file.stat();
|
|
7203
|
+
if (!info.isFile() || info.size === 0) throw unreadable;
|
|
7204
|
+
if (info.size > 10485760) throw tooLarge;
|
|
7205
|
+
const stream = file.createReadStream({
|
|
7206
|
+
autoClose: false,
|
|
7207
|
+
end: QMIND_RETRIEVAL_IMAGE_MAX_BYTES
|
|
7208
|
+
});
|
|
7209
|
+
for await (const chunk of stream) {
|
|
7210
|
+
const bytes = chunk;
|
|
7211
|
+
size += bytes.byteLength;
|
|
7212
|
+
chunks.push(bytes);
|
|
7213
|
+
}
|
|
7214
|
+
} finally {
|
|
7215
|
+
await file.close();
|
|
7216
|
+
}
|
|
7217
|
+
} catch (error) {
|
|
7218
|
+
if (error === tooLarge) throw error;
|
|
7219
|
+
throw unreadable;
|
|
7220
|
+
}
|
|
7221
|
+
if (size === 0) throw unreadable;
|
|
7222
|
+
if (size > 10485760) throw tooLarge;
|
|
7223
|
+
return {
|
|
7224
|
+
imageBase64: Buffer.concat(chunks, size).toString("base64"),
|
|
7225
|
+
imageFormat: extension === "tif" ? "tiff" : extension
|
|
7226
|
+
};
|
|
7227
|
+
}
|
|
7228
|
+
//#endregion
|
|
7061
7229
|
//#region src/application.ts
|
|
7062
7230
|
const distribution = CLI_DISTRIBUTIONS[QMIND_CLI_DISTRIBUTION];
|
|
7063
7231
|
function registerCoreCommands(context, program) {
|
|
@@ -7140,30 +7308,34 @@ function registerCoreCommands(context, program) {
|
|
|
7140
7308
|
});
|
|
7141
7309
|
else context.io.stdout("deleted\n");
|
|
7142
7310
|
});
|
|
7143
|
-
withCommon(program.command("retrieve [query]").description("Retrieve context from
|
|
7311
|
+
withCommon(program.command("retrieve [query]").description("Retrieve context from notebooks using text, an image, or both")).option("--nb <ids>", `notebook IDs (required, comma-separated or repeatable, maximum 32)`, collectNotebookIds, []).option("--unified", "use unified retrieval with notebook identity, including for one notebook").addOption(new Option("--targets <json>", "JSON array of {notebookId, sourceIds?}; uses unified retrieval").argParser(parseTargets).conflicts(["nb", "sources"])).option("--score-threshold <number>", "minimum score for non-OTS retrieval (0..1)", scoreThreshold).option("-q, --query <query>", "retrieval query").option("--image <path>", "local query image (JPEG, PNG, WebP, BMP, TIFF or GIF, up to 10 MiB)").option("--sources <ids>", "comma-separated source IDs (single notebook only)", "").option("--top-k <number>", "joint recall candidate limit", integer, 0).option("--max-results <number>", "maximum context results across selected notebooks", integer, 0).action(async (query, raw) => {
|
|
7144
7312
|
const notebookIds = raw.nb;
|
|
7145
7313
|
const [notebookId] = notebookIds;
|
|
7146
7314
|
if (raw.targets === void 0 && notebookId === void 0) throw new QMindError("INVALID_ARGUMENT", "--nb is required");
|
|
7147
7315
|
if (notebookIds.length > 32) throw new QMindError("INVALID_ARGUMENT", `--nb accepts at most 32 distinct notebook IDs`);
|
|
7148
|
-
const
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7316
|
+
const imagePath = stringOption(raw, "image");
|
|
7317
|
+
const text = stringOption(raw, "query") || query;
|
|
7318
|
+
const textQuery = imagePath === void 0 ? requiredString(text, "--query or positional query") : text?.trim() || void 0;
|
|
7319
|
+
if (imagePath !== void 0 && textQuery !== void 0 && textQuery.length > 128) throw new QMindError("INVALID_ARGUMENT", `image retrieval query must be at most 128 UTF-16 units`);
|
|
7320
|
+
const maxResults = numberOption(raw, "maxResults", 0);
|
|
7321
|
+
const topK = numberOption(raw, "topK", 0);
|
|
7322
|
+
const sourceIds = splitCsv(stringOption(raw, "sources"));
|
|
7323
|
+
if (maxResults < 0 || topK < 0) throw new QMindError("INVALID_ARGUMENT", "--top-k and --max-results must be non-negative");
|
|
7324
|
+
if (notebookIds.length > 1 && sourceIds.length > 0) throw new QMindError("INVALID_ARGUMENT", "--sources requires a single notebook");
|
|
7325
|
+
const criteria = {
|
|
7326
|
+
...textQuery === void 0 ? {} : { query: textQuery },
|
|
7327
|
+
...imagePath === void 0 ? {} : await readRetrievalImage(imagePath),
|
|
7153
7328
|
...raw.scoreThreshold === void 0 ? {} : { scoreThreshold: Number(raw.scoreThreshold) }
|
|
7154
7329
|
};
|
|
7155
|
-
if (input.maxResults < 0 || input.topK < 0) throw new QMindError("INVALID_ARGUMENT", "--top-k and --max-results must be non-negative");
|
|
7156
|
-
if (notebookIds.length > 1 && input.sourceIds.length > 0) throw new QMindError("INVALID_ARGUMENT", "--sources requires a single notebook");
|
|
7157
7330
|
if (raw.unified === true || raw.targets !== void 0) {
|
|
7158
7331
|
await runCanonicalCommand(context, raw, "qmind.retrieve", {
|
|
7159
|
-
|
|
7332
|
+
...criteria,
|
|
7160
7333
|
...raw.targets !== void 0 ? { targets: raw.targets } : notebookIds.length === 1 ? {
|
|
7161
7334
|
notebookId,
|
|
7162
|
-
...
|
|
7335
|
+
...sourceIds.length ? { sourceIds } : {}
|
|
7163
7336
|
} : { targets: notebookIds.map((id) => ({ notebookId: id })) },
|
|
7164
|
-
...
|
|
7165
|
-
...
|
|
7166
|
-
...input.scoreThreshold === void 0 ? {} : { scoreThreshold: input.scoreThreshold }
|
|
7337
|
+
...maxResults === 0 ? {} : { maxResults },
|
|
7338
|
+
...topK === 0 ? {} : { topK }
|
|
7167
7339
|
});
|
|
7168
7340
|
return;
|
|
7169
7341
|
}
|
|
@@ -7171,17 +7343,21 @@ function registerCoreCommands(context, program) {
|
|
|
7171
7343
|
if (notebookIds.length === 1 && notebookId !== void 0) {
|
|
7172
7344
|
render(context, raw, {
|
|
7173
7345
|
kind: "retrieve",
|
|
7174
|
-
value: await host.client.retrieve(notebookId,
|
|
7346
|
+
value: await host.client.retrieve(notebookId, {
|
|
7347
|
+
...criteria,
|
|
7348
|
+
maxResults,
|
|
7349
|
+
sourceIds,
|
|
7350
|
+
topK
|
|
7351
|
+
})
|
|
7175
7352
|
});
|
|
7176
7353
|
return;
|
|
7177
7354
|
}
|
|
7178
7355
|
render(context, raw, {
|
|
7179
7356
|
kind: "multiRetrieve",
|
|
7180
7357
|
value: await host.client.retrieveNotebooks({
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
...input.scoreThreshold === void 0 ? {} : { scoreThreshold: input.scoreThreshold },
|
|
7358
|
+
...criteria,
|
|
7359
|
+
maxResults,
|
|
7360
|
+
topK,
|
|
7185
7361
|
targets: notebookIds.map((notebookId) => ({ notebookId }))
|
|
7186
7362
|
})
|
|
7187
7363
|
});
|
|
@@ -7532,7 +7708,7 @@ async function runQMindCli(argv, options = {}) {
|
|
|
7532
7708
|
updater: options.updater ?? createQMindCliUpdater({ identity: {
|
|
7533
7709
|
artifactKind: "npm",
|
|
7534
7710
|
command: distribution.command,
|
|
7535
|
-
currentVersion: "5.
|
|
7711
|
+
currentVersion: "5.1.0",
|
|
7536
7712
|
distribution: distribution.id,
|
|
7537
7713
|
executablePath: process.execPath,
|
|
7538
7714
|
package: distribution.package,
|
|
@@ -22,6 +22,153 @@ var QMindError = class extends Error {
|
|
|
22
22
|
this.upstreamCode = options.upstreamCode;
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
+
const scopeList = z.array(z.string().max(128).regex(/^[a-zA-Z][a-zA-Z0-9_]*(?:[.:][a-zA-Z0-9_]+)+$/)).min(1).max(16).refine((scopes) => new Set(scopes).size === scopes.length);
|
|
26
|
+
const permissionCapabilities = [
|
|
27
|
+
"wiki_spaces",
|
|
28
|
+
"wiki_children",
|
|
29
|
+
"wiki_node",
|
|
30
|
+
"drive_listing",
|
|
31
|
+
"document_read",
|
|
32
|
+
"document_export",
|
|
33
|
+
"file_download",
|
|
34
|
+
"document_media",
|
|
35
|
+
"whiteboard_image",
|
|
36
|
+
"embedded_sheet",
|
|
37
|
+
"embedded_bitable_fields",
|
|
38
|
+
"embedded_bitable_records",
|
|
39
|
+
"linked_document_titles",
|
|
40
|
+
"mentioned_user_lookup",
|
|
41
|
+
"mentioned_user_names"
|
|
42
|
+
];
|
|
43
|
+
function permissionEntries(entry) {
|
|
44
|
+
return z.array(z.unknown()).max(16).transform((values) => {
|
|
45
|
+
const seen = /* @__PURE__ */ new Set();
|
|
46
|
+
return values.flatMap((value) => {
|
|
47
|
+
const parsed = entry.safeParse(value);
|
|
48
|
+
if (!parsed.success || seen.has(parsed.data.capability)) return [];
|
|
49
|
+
seen.add(parsed.data.capability);
|
|
50
|
+
return [parsed.data];
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const permissionGroups = permissionEntries(z.object({
|
|
55
|
+
capability: z.enum(permissionCapabilities),
|
|
56
|
+
anyOfScopes: scopeList
|
|
57
|
+
})).optional().catch(void 0);
|
|
58
|
+
const permissionGrants = permissionEntries(z.object({
|
|
59
|
+
capability: z.enum(permissionCapabilities),
|
|
60
|
+
grantedScopes: scopeList
|
|
61
|
+
})).optional().catch(void 0);
|
|
62
|
+
const dataSourceAppPermissionSchema = z.object({
|
|
63
|
+
requiredScopes: scopeList,
|
|
64
|
+
anyOf: z.boolean(),
|
|
65
|
+
permissionRequirements: permissionGroups,
|
|
66
|
+
permissionWarnings: permissionGroups,
|
|
67
|
+
permissionGrants
|
|
68
|
+
});
|
|
69
|
+
/** 只提取应用权限标识与匹配方式。 */
|
|
70
|
+
function readQMindDataSourceAppPermission(code, details) {
|
|
71
|
+
if (code !== "DataSourceAppPermissionRequired") return void 0;
|
|
72
|
+
const parsed = dataSourceAppPermissionSchema.safeParse(details);
|
|
73
|
+
return parsed.success ? parsed.data : void 0;
|
|
74
|
+
}
|
|
75
|
+
const dataSourceConfigurationSchema = z.object({
|
|
76
|
+
name: z.string().min(1).max(255),
|
|
77
|
+
provider: z.enum([
|
|
78
|
+
"feishu",
|
|
79
|
+
"feishu_drive",
|
|
80
|
+
"dingtalk",
|
|
81
|
+
"dingtalk_mcp"
|
|
82
|
+
]),
|
|
83
|
+
resourceIds: z.array(z.string().min(1)).max(1e3).default([]),
|
|
84
|
+
settings: z.record(z.string(), z.unknown()).default({}),
|
|
85
|
+
schedule: z.string().default(""),
|
|
86
|
+
paused: z.boolean().default(false),
|
|
87
|
+
syncDeletions: z.boolean().default(false)
|
|
88
|
+
});
|
|
89
|
+
const dataSourceSchema = z.object({
|
|
90
|
+
id: z.string().min(1),
|
|
91
|
+
configuration: dataSourceConfigurationSchema,
|
|
92
|
+
credentialsConfigured: z.boolean().default(false),
|
|
93
|
+
lastSyncAt: z.string().nullish()
|
|
94
|
+
});
|
|
95
|
+
const dataSourceResourceSchema = z.object({
|
|
96
|
+
externalId: z.string().min(1),
|
|
97
|
+
name: z.string(),
|
|
98
|
+
type: z.string(),
|
|
99
|
+
url: z.string().default(""),
|
|
100
|
+
parentId: z.string().default(""),
|
|
101
|
+
hasChildren: z.boolean().default(false)
|
|
102
|
+
});
|
|
103
|
+
const dataSourceRunSchema = z.object({
|
|
104
|
+
id: z.string().min(1),
|
|
105
|
+
status: z.enum([
|
|
106
|
+
"queued",
|
|
107
|
+
"running",
|
|
108
|
+
"success",
|
|
109
|
+
"partial",
|
|
110
|
+
"failed",
|
|
111
|
+
"canceled"
|
|
112
|
+
]),
|
|
113
|
+
startedAt: z.string().nullish(),
|
|
114
|
+
finishedAt: z.string().nullish(),
|
|
115
|
+
total: z.number().int().default(0),
|
|
116
|
+
created: z.number().int().default(0),
|
|
117
|
+
updated: z.number().int().default(0),
|
|
118
|
+
deleted: z.number().int().default(0),
|
|
119
|
+
skipped: z.number().int().default(0),
|
|
120
|
+
failed: z.number().int().default(0),
|
|
121
|
+
errorCode: z.string().default(""),
|
|
122
|
+
issuesTruncated: z.boolean().default(false),
|
|
123
|
+
issues: z.array(z.object({
|
|
124
|
+
externalId: z.string(),
|
|
125
|
+
resourceId: z.string(),
|
|
126
|
+
code: z.string(),
|
|
127
|
+
retryState: z.string()
|
|
128
|
+
})).default([])
|
|
129
|
+
});
|
|
130
|
+
const dataSourceListSchema = z.object({
|
|
131
|
+
dataSources: z.array(dataSourceSchema).default([]),
|
|
132
|
+
managedDataSources: z.array(dataSourceSchema).default([]),
|
|
133
|
+
nextAfterId: z.string().default(""),
|
|
134
|
+
dingtalkDocServerId: z.string().nullish().transform((id) => id || void 0),
|
|
135
|
+
availableProviders: z.array(z.string()).default([])
|
|
136
|
+
}).transform(({ managedDataSources, dataSources, ...page }) => ({
|
|
137
|
+
...page,
|
|
138
|
+
dataSources: managedDataSources.length ? [...dataSources, ...managedDataSources].sort((a, b) => a.id.localeCompare(b.id, "en")) : dataSources
|
|
139
|
+
}));
|
|
140
|
+
const dataSourceRunsSchema = z.object({
|
|
141
|
+
runs: z.array(dataSourceRunSchema).default([]),
|
|
142
|
+
nextBeforeStartedAt: z.string().nullish(),
|
|
143
|
+
nextBeforeId: z.string().default("")
|
|
144
|
+
});
|
|
145
|
+
const dataSourcePreviewSchema = z.object({
|
|
146
|
+
importCheck: z.enum([
|
|
147
|
+
"readable",
|
|
148
|
+
"empty",
|
|
149
|
+
"unverified"
|
|
150
|
+
]).optional().catch(void 0),
|
|
151
|
+
resources: z.array(dataSourceResourceSchema).default([]),
|
|
152
|
+
permissionWarnings: permissionGroups,
|
|
153
|
+
permissionGrants
|
|
154
|
+
});
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region ../sdk/src/wiki.ts
|
|
157
|
+
/** 保留 HTTP 错误证据,并以有界状态供宿主选择本地化提示。 */
|
|
158
|
+
var QMindWikiReadError = class extends QMindError {
|
|
159
|
+
wikiState;
|
|
160
|
+
constructor(wikiState, error) {
|
|
161
|
+
super(error.code, error.message, {
|
|
162
|
+
cause: error,
|
|
163
|
+
...error.operation === void 0 ? {} : { operation: error.operation },
|
|
164
|
+
...error.status === void 0 ? {} : { status: error.status },
|
|
165
|
+
...error.upstreamCode === void 0 ? {} : { upstreamCode: error.upstreamCode },
|
|
166
|
+
...error.requestId === void 0 ? {} : { requestId: error.requestId },
|
|
167
|
+
details: error.details
|
|
168
|
+
});
|
|
169
|
+
this.wikiState = wikiState;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
25
172
|
//#endregion
|
|
26
173
|
//#region ../sdk/src/imports.ts
|
|
27
174
|
const qmindFullSiteURLImportPageLimit = 2e3;
|
|
@@ -602,7 +749,7 @@ const notebookCitationSchema = z.preprocess((value) => isRecord$1(value) ? {
|
|
|
602
749
|
} : value, z.object({
|
|
603
750
|
chunkId: z.string().default(""),
|
|
604
751
|
chunkIndex: z.number().int().nonnegative().default(0),
|
|
605
|
-
metadata: z.record(z.string(), z.unknown()).
|
|
752
|
+
metadata: z.record(z.string(), z.unknown()).nullish().transform((value) => value ?? void 0),
|
|
606
753
|
originUrl: z.string().optional(),
|
|
607
754
|
snippet: z.string().default(""),
|
|
608
755
|
sourceId: z.string().default(""),
|
|
@@ -689,7 +836,7 @@ const notebookContextChunkSchema = z.object({
|
|
|
689
836
|
chunkId: z.string().default(""),
|
|
690
837
|
chunkIndex: z.number().int().nonnegative().default(0),
|
|
691
838
|
content: z.string().default(""),
|
|
692
|
-
metadata: z.record(z.string(), z.unknown()).
|
|
839
|
+
metadata: z.record(z.string(), z.unknown()).nullish().transform((value) => value ?? void 0),
|
|
693
840
|
originUrl: z.string().optional(),
|
|
694
841
|
score: z.number().finite().default(0),
|
|
695
842
|
sourceId: z.string().default(""),
|
|
@@ -908,142 +1055,6 @@ const qmindRoutes = {
|
|
|
908
1055
|
return qmindPath("notebooks", notebookId, "wiki-branches");
|
|
909
1056
|
}
|
|
910
1057
|
};
|
|
911
|
-
const scopeList = z.array(z.string().max(128).regex(/^[a-zA-Z][a-zA-Z0-9_]*(?:[.:][a-zA-Z0-9_]+)+$/)).min(1).max(16).refine((scopes) => new Set(scopes).size === scopes.length);
|
|
912
|
-
const permissionCapabilities = [
|
|
913
|
-
"wiki_spaces",
|
|
914
|
-
"wiki_children",
|
|
915
|
-
"wiki_node",
|
|
916
|
-
"drive_listing",
|
|
917
|
-
"document_read",
|
|
918
|
-
"document_export",
|
|
919
|
-
"file_download",
|
|
920
|
-
"document_media",
|
|
921
|
-
"whiteboard_image",
|
|
922
|
-
"embedded_sheet",
|
|
923
|
-
"embedded_bitable_fields",
|
|
924
|
-
"embedded_bitable_records",
|
|
925
|
-
"linked_document_titles",
|
|
926
|
-
"mentioned_user_lookup",
|
|
927
|
-
"mentioned_user_names"
|
|
928
|
-
];
|
|
929
|
-
function permissionEntries(entry) {
|
|
930
|
-
return z.array(z.unknown()).max(16).transform((values) => {
|
|
931
|
-
const seen = /* @__PURE__ */ new Set();
|
|
932
|
-
return values.flatMap((value) => {
|
|
933
|
-
const parsed = entry.safeParse(value);
|
|
934
|
-
if (!parsed.success || seen.has(parsed.data.capability)) return [];
|
|
935
|
-
seen.add(parsed.data.capability);
|
|
936
|
-
return [parsed.data];
|
|
937
|
-
});
|
|
938
|
-
});
|
|
939
|
-
}
|
|
940
|
-
const permissionGroups = permissionEntries(z.object({
|
|
941
|
-
capability: z.enum(permissionCapabilities),
|
|
942
|
-
anyOfScopes: scopeList
|
|
943
|
-
})).optional().catch(void 0);
|
|
944
|
-
const permissionGrants = permissionEntries(z.object({
|
|
945
|
-
capability: z.enum(permissionCapabilities),
|
|
946
|
-
grantedScopes: scopeList
|
|
947
|
-
})).optional().catch(void 0);
|
|
948
|
-
const dataSourceAppPermissionSchema = z.object({
|
|
949
|
-
requiredScopes: scopeList,
|
|
950
|
-
anyOf: z.boolean(),
|
|
951
|
-
permissionRequirements: permissionGroups,
|
|
952
|
-
permissionWarnings: permissionGroups,
|
|
953
|
-
permissionGrants
|
|
954
|
-
});
|
|
955
|
-
/** 只提取应用权限标识与匹配方式。 */
|
|
956
|
-
function readQMindDataSourceAppPermission(code, details) {
|
|
957
|
-
if (code !== "DataSourceAppPermissionRequired") return void 0;
|
|
958
|
-
const parsed = dataSourceAppPermissionSchema.safeParse(details);
|
|
959
|
-
return parsed.success ? parsed.data : void 0;
|
|
960
|
-
}
|
|
961
|
-
const dataSourceConfigurationSchema = z.object({
|
|
962
|
-
name: z.string().min(1).max(255),
|
|
963
|
-
provider: z.enum([
|
|
964
|
-
"feishu",
|
|
965
|
-
"feishu_drive",
|
|
966
|
-
"dingtalk"
|
|
967
|
-
]),
|
|
968
|
-
resourceIds: z.array(z.string().min(1)).max(1e3).default([]),
|
|
969
|
-
settings: z.record(z.string(), z.unknown()).default({}),
|
|
970
|
-
schedule: z.string().default(""),
|
|
971
|
-
paused: z.boolean().default(false),
|
|
972
|
-
syncDeletions: z.boolean().default(false)
|
|
973
|
-
});
|
|
974
|
-
const dataSourceSchema = z.object({
|
|
975
|
-
id: z.string().min(1),
|
|
976
|
-
configuration: dataSourceConfigurationSchema,
|
|
977
|
-
credentialsConfigured: z.boolean().default(false),
|
|
978
|
-
lastSyncAt: z.string().nullish()
|
|
979
|
-
});
|
|
980
|
-
const dataSourceResourceSchema = z.object({
|
|
981
|
-
externalId: z.string().min(1),
|
|
982
|
-
name: z.string(),
|
|
983
|
-
type: z.string(),
|
|
984
|
-
url: z.string().default(""),
|
|
985
|
-
parentId: z.string().default(""),
|
|
986
|
-
hasChildren: z.boolean().default(false)
|
|
987
|
-
});
|
|
988
|
-
const dataSourceRunSchema = z.object({
|
|
989
|
-
id: z.string().min(1),
|
|
990
|
-
status: z.enum([
|
|
991
|
-
"queued",
|
|
992
|
-
"running",
|
|
993
|
-
"success",
|
|
994
|
-
"partial",
|
|
995
|
-
"failed",
|
|
996
|
-
"canceled"
|
|
997
|
-
]),
|
|
998
|
-
startedAt: z.string().nullish(),
|
|
999
|
-
finishedAt: z.string().nullish(),
|
|
1000
|
-
total: z.number().int().default(0),
|
|
1001
|
-
created: z.number().int().default(0),
|
|
1002
|
-
updated: z.number().int().default(0),
|
|
1003
|
-
deleted: z.number().int().default(0),
|
|
1004
|
-
skipped: z.number().int().default(0),
|
|
1005
|
-
failed: z.number().int().default(0),
|
|
1006
|
-
errorCode: z.string().default(""),
|
|
1007
|
-
issuesTruncated: z.boolean().default(false),
|
|
1008
|
-
issues: z.array(z.object({
|
|
1009
|
-
externalId: z.string(),
|
|
1010
|
-
resourceId: z.string(),
|
|
1011
|
-
code: z.string(),
|
|
1012
|
-
retryState: z.string()
|
|
1013
|
-
})).default([])
|
|
1014
|
-
});
|
|
1015
|
-
const dataSourceListSchema = z.object({
|
|
1016
|
-
dataSources: z.array(dataSourceSchema).default([]),
|
|
1017
|
-
nextAfterId: z.string().default(""),
|
|
1018
|
-
availableProviders: z.array(z.string()).default([])
|
|
1019
|
-
});
|
|
1020
|
-
const dataSourceRunsSchema = z.object({
|
|
1021
|
-
runs: z.array(dataSourceRunSchema).default([]),
|
|
1022
|
-
nextBeforeStartedAt: z.string().nullish(),
|
|
1023
|
-
nextBeforeId: z.string().default("")
|
|
1024
|
-
});
|
|
1025
|
-
const dataSourcePreviewSchema = z.object({
|
|
1026
|
-
resources: z.array(dataSourceResourceSchema).default([]),
|
|
1027
|
-
permissionWarnings: permissionGroups,
|
|
1028
|
-
permissionGrants
|
|
1029
|
-
});
|
|
1030
|
-
//#endregion
|
|
1031
|
-
//#region ../sdk/src/wiki.ts
|
|
1032
|
-
/** 保留 HTTP 错误证据,并以有界状态供宿主选择本地化提示。 */
|
|
1033
|
-
var QMindWikiReadError = class extends QMindError {
|
|
1034
|
-
wikiState;
|
|
1035
|
-
constructor(wikiState, error) {
|
|
1036
|
-
super(error.code, error.message, {
|
|
1037
|
-
cause: error,
|
|
1038
|
-
...error.operation === void 0 ? {} : { operation: error.operation },
|
|
1039
|
-
...error.status === void 0 ? {} : { status: error.status },
|
|
1040
|
-
...error.upstreamCode === void 0 ? {} : { upstreamCode: error.upstreamCode },
|
|
1041
|
-
...error.requestId === void 0 ? {} : { requestId: error.requestId },
|
|
1042
|
-
details: error.details
|
|
1043
|
-
});
|
|
1044
|
-
this.wikiState = wikiState;
|
|
1045
|
-
}
|
|
1046
|
-
};
|
|
1047
1058
|
//#endregion
|
|
1048
1059
|
//#region ../sdk/src/execution.ts
|
|
1049
1060
|
const credentialHeaders = /* @__PURE__ */ new Set([
|
|
@@ -1120,12 +1131,19 @@ function httpError(operation, response) {
|
|
|
1120
1131
|
function isAbortLike(cause) {
|
|
1121
1132
|
return isRecord(cause) && (cause.name === "AbortError" && typeof cause.name === "string" || cause.code === "ABORT_ERR");
|
|
1122
1133
|
}
|
|
1123
|
-
function
|
|
1134
|
+
function normalizeTransportError(cause, signal, context = {}) {
|
|
1124
1135
|
if (cause instanceof QMindError) return cause;
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
cause
|
|
1128
|
-
|
|
1136
|
+
if (signal?.aborted || isAbortLike(cause)) return new QMindError("ABORTED", "QMind request was aborted", {
|
|
1137
|
+
...context,
|
|
1138
|
+
cause
|
|
1139
|
+
});
|
|
1140
|
+
if (isRecord(cause) && cause.name === "TimeoutError") return new QMindError("TIMEOUT", "QMind request timed out", {
|
|
1141
|
+
...context,
|
|
1142
|
+
cause
|
|
1143
|
+
});
|
|
1144
|
+
return new QMindError("NETWORK_ERROR", "QMind transport failed", {
|
|
1145
|
+
...context,
|
|
1146
|
+
cause
|
|
1129
1147
|
});
|
|
1130
1148
|
}
|
|
1131
1149
|
function requestWasAborted(request) {
|
|
@@ -1172,7 +1190,7 @@ async function executeUnary(options) {
|
|
|
1172
1190
|
try {
|
|
1173
1191
|
response = await transport.request(request);
|
|
1174
1192
|
} catch (cause) {
|
|
1175
|
-
throw
|
|
1193
|
+
throw normalizeTransportError(cause, request.signal, { operation });
|
|
1176
1194
|
}
|
|
1177
1195
|
if (response.status < 200 || response.status >= 300) throw httpError(operation, response);
|
|
1178
1196
|
const body = response.body;
|
|
@@ -1208,7 +1226,7 @@ async function* executeStream(options) {
|
|
|
1208
1226
|
try {
|
|
1209
1227
|
response = await transport.stream(request);
|
|
1210
1228
|
} catch (cause) {
|
|
1211
|
-
throw
|
|
1229
|
+
throw normalizeTransportError(cause, request.signal, { operation });
|
|
1212
1230
|
}
|
|
1213
1231
|
if (response.kind === "response") {
|
|
1214
1232
|
if (response.status >= 200 && response.status < 300) throw streamContractError(operation, "stream handshake returned no event stream", { status: response.status });
|
|
@@ -1238,7 +1256,7 @@ async function* executeStream(options) {
|
|
|
1238
1256
|
yield event;
|
|
1239
1257
|
}
|
|
1240
1258
|
} catch (cause) {
|
|
1241
|
-
throw
|
|
1259
|
+
throw normalizeTransportError(cause, request.signal, { operation });
|
|
1242
1260
|
}
|
|
1243
1261
|
if (requestWasAborted(request)) throw new QMindError("ABORTED", "QMind request was aborted", { operation });
|
|
1244
1262
|
if (!terminal) throw streamContractError(operation, "stream ended before messageComplete", {
|
|
@@ -1380,4 +1398,4 @@ function call(context, options) {
|
|
|
1380
1398
|
});
|
|
1381
1399
|
}
|
|
1382
1400
|
//#endregion
|
|
1383
|
-
export {
|
|
1401
|
+
export { taskRunListSchema as $, fullSiteURLImportConfirmationSchema as A, sourceActionAccessSchema as B, aliDingImportRunItemListSchema as C, chatMessageListSchema as D, cancelQuestionResultSchema as E, notebookListSchema as F, sourcePreviewSchema as G, sourceContentSchema as H, notebookSchema as I, sourceSchema as J, sourceQuotaSchema as K, retrieveNotebooksResultSchema as L, imageUploadTicketSchema as M, imageUrlsSchema as N, chatSessionListSchema as O, importProvidersSchema as P, sourceWebOfficeTokenSchema as Q, retrieveResultSchema as R, qmindRoutes as S, batchDeleteResultSchema as T, sourceImportResultsSchema as U, sourceChildrenCountsSchema as V, sourceListSchema as W, sourceUploadTicketSchema as X, sourceUploadCapabilitiesSchema as Y, sourceWebOfficeSessionSchema as Z, assertCapability as _, invalidArgument as a, dataSourceListSchema as at, pathBuilder as b, optionalRecord as c, dataSourceRunsSchema as ct, pagination as d, taskRunSchema as et, positiveInteger as f, stringList as g, requiredText as h, httpUrl as i, dataSourceConfigurationSchema as it, fullSiteURLImportDiscoverySchema as j, chatSessionSchema as k, optionalString as l, dataSourceSchema as lt, requiredString as m, call as n, voidResponseSchema as nt, nonNegativeInteger as o, dataSourcePreviewSchema as ot, queryPath as p, sourceRawContentSchema as q, compactUndefined as r, qmindFullSiteURLImportPageLimit as rt, optionalBoolean as s, dataSourceResourceSchema as st, assertNonEmptyPatch as t, timestampSchema as tt, optionalTrimmedString as u, QMindError as ut, executeStream as v, aliDingImportRunSchema as w, qmindPath as x, executeUnary as y, sharedNotebookListSchema as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Y as sourceUploadCapabilitiesSchema, m as requiredString, n as call, x as qmindPath } from "./shared-CWO5bxZy.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 {
|
|
2
|
-
import { t as preflightSourceUpload } from "./source-upload-
|
|
1
|
+
import { J as sourceSchema, M as imageUploadTicketSchema, X as sourceUploadTicketSchema, a as invalidArgument, l as optionalString, m as requiredString, nt as voidResponseSchema, p as queryPath, r as compactUndefined, u as optionalTrimmedString, ut as QMindError, x as qmindPath, y as executeUnary } from "./shared-CWO5bxZy.js";
|
|
2
|
+
import { t as preflightSourceUpload } from "./source-upload-GjQToHLv.js";
|
|
3
3
|
//#region ../sdk/src/workflows.ts
|
|
4
4
|
const QMIND_MULTIPART_UPLOAD_MAX_BYTES = 52428800;
|
|
5
5
|
const QMIND_SOURCE_UPLOAD_MAX_BYTES = 157286400;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as invalidArgument, m as requiredString, n as call, o as nonNegativeInteger, p as queryPath, u as optionalTrimmedString, ut as QMindError } from "./shared-
|
|
2
|
-
import { t as nezhaRepoWikiPath } from "./nezha-
|
|
1
|
+
import { a as invalidArgument, m as requiredString, n as call, o as nonNegativeInteger, p as queryPath, u as optionalTrimmedString, ut as QMindError } from "./shared-CWO5bxZy.js";
|
|
2
|
+
import { t as nezhaRepoWikiPath } from "./nezha-DtT7HGFc.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region ../sdk/src/operations/wiki.ts
|
|
5
5
|
const partSchema = z.number().int().nonnegative();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as qmindRoutes, a as invalidArgument, d as pagination, m as requiredString, n as call, p as queryPath, tt as timestampSchema, u as optionalTrimmedString } from "./shared-CWO5bxZy.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region ../sdk/src/operations/wiki-branches.ts
|
|
4
4
|
function isRecord(value) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qoder-ai/qmind-cli",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "QMind command line interface",
|
|
5
5
|
"bin": {
|
|
6
6
|
"qmind": "bin/cli.js"
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"@types/picomatch": "4.0.3",
|
|
40
40
|
"@types/proper-lockfile": "4.1.4",
|
|
41
41
|
"@types/semver": "7.8.0",
|
|
42
|
-
"@ali/qmind-
|
|
43
|
-
"@ali/qmind-
|
|
44
|
-
"@ali/qmind-sdk": "^2.
|
|
42
|
+
"@ali/qmind-node-host": "^4.0.7",
|
|
43
|
+
"@ali/qmind-agent-core": "^8.1.0",
|
|
44
|
+
"@ali/qmind-sdk": "^2.4.0"
|
|
45
45
|
},
|
|
46
46
|
"license": "UNLICENSED",
|
|
47
|
-
"readme": "# QMind CLI for Qoder Global\n\n[简体中文](./README.zh-CN.md)\n\nThe 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.\n\nPackage: `@qoder-ai/qmind-cli` · command: `qmind`\n\n## Install\n\nNode.js `>=22.19.0` is required.\n\n```sh\nnpm install --global @qoder-ai/qmind-cli\nqmind version\nqmind --help\n```\n\nUpgrade and uninstall through npm. `qmind self-update` only prints the npm upgrade command and never modifies npm-managed files.\n\n```sh\nnpm update --global @qoder-ai/qmind-cli\nnpm uninstall --global @qoder-ai/qmind-cli\n```\n\nThe Native standalone CLI uses the verified Global release channel instead. An installer-managed\nNative executable can check or apply the latest release without Node.js or npm:\n\n```sh\nqmind update --check\nqmind update\n```\n\n`self-update` remains an alias for `update`. The updater rejects channel/URL overrides, downgrades,\nunowned executables, release checksum mismatches, and modified installer bytes. Windows schedules\nreplacement after the running executable exits and records details beside the executable.\n\n## Quick start\n\n```sh\nqmind login\nqmind notebook list\nqmind source list --nb <notebook-id>\nqmind retrieve --nb <notebook-id> \"What must be checked before release?\"\n```\n\nInteractive login opens a browser and stores the session in a local file vault. For CI and agents, prefer an environment variable and structured output:\n\n```sh\nexport QMIND_TOKEN='<token>'\nqmind notebook list --non-interactive --format json\nqmind retrieve --nb <notebook-id> --format agent \"What is the deployment process?\"\n```\n\nDo not put tokens in command arguments, repositories, or logs. Run `qmind logout` to remove the current local session.\n\n### Login without a browser or interactive terminal\n\nCreate a PAT on the [Qoder PAT management page](https://qoder.com/account/integrations), then sign in through standard input (`--non-interactive` is also supported):\n\n```sh\nqmind login --pat-stdin < /path/to/pat-secret\nqmind notebook list --non-interactive --format json\n```\n\nAlternatively, inject `QODER_PROD_PAT` from your secret manager and run `qmind login --non-interactive`. `login --pat <token>` accepts an explicit PAT; prefer stdin or environment variables to keep secrets out of shell history and process arguments. PAT login exchanges a Job Token before saving the PAT, Job Token, and expiry in the current target's file vault. Later commands reuse the cached Job Token and exchange again on expiry or HTTP 401. Business requests use only the Job Token. `logout` removes the current target's local credentials without revoking the remote PAT.\n\nFor CI, inject a PAT and run commands directly without saving it to the vault. This product uses `QODER_PROD_PAT` for production and `QODER_TEST_PAT` for `--env test`, with `QODER_PERSONAL_ACCESS_TOKEN` as a fallback. Global `--env daily` uses only the generic variable. Dedicated PATs are never borrowed across regions or environments. Custom targets do not automatically read these PAT variables; explicitly use `--pat-stdin` or `--token`.\n\nFor browser login, `qmind login --no-browser` prints the authorization URL to open on another machine; it still requires an interactive terminal.\n\n## Commands\n\n| Command | Purpose |\n| ------------------------ | ---------------------------------------- |\n| `login` / `logout` | Sign in or remove local credentials |\n| `notebook` | Manage knowledge bases |\n| `source` | Manage knowledge-base sources |\n| `retrieve` | Retrieve context without invoking an LLM |\n| `rag` | Ask questions using a knowledge base |\n| `task` | Manage task runs |\n| `scheduled-task` | Manage notebook schedule configurations |\n| `upload-folder` / `sync` | Synchronize a local directory |\n| `image` | Obtain image upload or access URLs |\n| `version` | Print version and build information |\n| `update` / `self-update` | Update an installer-managed Native CLI |\n\n`task create` starts manual `condensation` or `source_refresh` runs. Manual refresh covers the entire notebook. Use `scheduled-task create --scene source_binding_sync` to schedule binding sync. Use `task list` and `task get` to inspect historical compilation and lint runs.\n\n`source import-site` imports at the notebook root and supports a sitemap, path filters, and a page limit.\n\nRun `qmind <command> --help` for complete options. Notebook commands with `--format` support `table`, `json`, `agent`, and `ndjson`. Folder sync supports `json` and `text`. 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.\n\n## Multi-notebook retrieval\n\n`retrieve --nb` accepts comma-separated or repeated Notebook IDs, deduplicating up to 32 distinct notebooks:\n\n```sh\nqmind retrieve --nb nb-1,nb-2 \"What is the deployment process?\" --format json\nqmind retrieve --nb nb-1 --nb nb-2 \"What is the deployment process?\" --format agent\n```\n\n- Selection is explicit; the CLI never defaults to all accessible notebooks.\n- Multiple notebooks use one unified retrieval request. The server jointly retrieves and reranks Source chunks; output retains server ranking and each chunk/citation's `notebookId` and `notebookTitle`.\n- `--top-k` controls the joint recall candidate budget per route/query/channel; it is not multiplied by notebook count. `--max-results` limits the final results across all selected notebooks. Zero uses server defaults.\n- `--sources` requires a single notebook. A single deduplicated notebook keeps the existing retrieval endpoint. All retrieval output formats expose chunks and citations without knowledge cards.\n- Multi-notebook JSON returns `{ chunks, citations, promptContext, total, reranked }`. NDJSON emits one `kind: \"chunk\"` record per returned chunk, in server order; zero hits emit no records. Table and agent output also identify each evidence item's notebook.\n- Unified retrieval fails as one request when a target is invalid or inaccessible. The CLI reports the error without retrying notebooks individually or constructing partial-success results. Retrieval results no longer contain a `cards` field.\n\n## Directory synchronization\n\nReview the plan before allowing remote deletions:\n\n```sh\nqmind upload-folder --nb <notebook-id> --dir ./docs --mode if-changed --dry-run\n```\n\nRemoving `--dry-run` enables writes. `--delete` treats the remote source root as a mirror of the local directory and removes extra remote entries. Concurrency must be between `1` and `10`.\n\n## Configuration and authentication\n\nThis package has a fixed Qoder Global identity. Renaming the executable, changing its install path, or setting product-selection environment variables cannot switch products. Production is the default; `--env test` and `--env daily` select supported debug presets. A custom target requires both `--sash` and `--dashboard` and cannot be combined with an explicit `--env`.\n\n**Using CLI 5.x with a custom gateway** On the origin supplied with `--sash`, route `/qmind/api/v1/` to QMind and enable Bearer authentication for CLI requests. Keep both origin arguments and the existing sign-in and token exchange routes. Verify notebook list and create with the same pair of origins. Pin your installed 4.x CLI version while the gateway serves notebooks only under `/sash/api/v1/notebooks`.\n\n```sh\nqmind login --env test\nQMIND_DEBUG_TOKEN='<debug-token>' qmind notebook list --env test --non-interactive --format json\nqmind login --sash http://localhost:8080 --dashboard http://localhost:3000\n```\n\nProduction token priority is `--token > QMIND_TOKEN > selected Qoder PAT variable > current production vault`. Debug token priority is `--token > QMIND_DEBUG_TOKEN > selected Qoder PAT variable > current debug vault`; credentials are never borrowed across targets.\n\nState is stored under `<state-root>/cli/global/<target>/`, where the state root is `QMIND_HOME` or `~/.qmind`. The CLI does not install, load, or access the OS Keyring. Credential files are plaintext JSON, not encrypted storage. On POSIX, partition directories use mode `0700` and files use `0600`; these modes do not represent Windows ACLs. Writes use atomic replacement, file locking, and compare-and-swap protection for refreshes.\n\nAfter upgrading from the legacy unpartitioned store, sign in again. Root-level config/credential files, `~/.qmind-env`, and old Keyring entries are not read, imported, or deleted automatically.\n\nThe shared 3.x Global/CN release is a breaking upgrade from Global 2.x. Upgrade this package with npm, then run `qmind login`; do not copy legacy credentials into the new partition. Existing versions before the shared release describe the Global/shared implementation only and do not imply a historical CN publication.\n\nCommon variables include `QMIND_TOKEN`, `QMIND_DEBUG_TOKEN`, `QMIND_HOME`, `QMIND_CLIENT`, `QMIND_NON_INTERACTIVE`, `QMIND_REQUEST_TIMEOUT_MS`, `QMIND_STREAM_IDLE_TIMEOUT_MS`, and `QMIND_TLS_CA_FILE`. `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` are supported. TLS verification is strict by default, and credentials are not forwarded to signed object-storage URLs.\n\n## Shared notebook discovery and access\n\n```sh\nqmind notebook list --shared --page 1 --page-size 20\nqmind notebook list --shared --format json\nqmind notebook get <notebook-id> --format json\n```\n\nBoth notebook collections support `--page` and `--page-size`. `--shared` cannot be combined with `--filter-client`. Shared results use the same flat `notebooks` output as the ordinary list and preserve the membership `permission`. JSON/NDJSON preserve server-provided `access` (current role, member count and action permissions); Agent output expands these fields. Table lists show role and member count, while details show action permissions. Missing permissions are not inferred and display as `unknown` in tables.\n\n## Commands aligned with Agent tools\n\nCore-backed workflows (`notebook discover`, `source import-url/read/delete-batch`, `mkdir --derive-path`, `mv --to/--to-root`, unified retrieval, and `scheduled-task`) return `{ ok, data/error, meta }` after entering Agent Core, with `meta.operationId` identifying the operation. `--format ndjson` emits one complete result per line; `table` and `agent` also use this JSON result. CLI validation and host/credential failures before Core keep the existing CLI error format: `{ error }` on stdout for JSON/NDJSON, or text on stderr otherwise. Command usage errors and declined confirmations go to stderr. `source list --parent` keeps the existing Source-list output. Exit codes are 0 for success, 1 for partial success/runtime failure/cancellation, and 2 for invalid arguments. A successful write does not mean Source ingestion or a scheduled run has completed.\n\n```sh\n# Select retrieval-eligible owned/shared notebooks; continue with nextCursor when hasMore is true\nqmind notebook discover --relationship all --page-size 20\nqmind notebook discover --relationship all --cursor '<nextCursor>'\n\n# Import a single page; inspect ingestion and content with source get / source read\nqmind source import-url --nb <notebook-id> --url https://example.com/guide\nqmind source list --nb <notebook-id> --parent <directory-id>\nqmind source read <source-id> --nb <notebook-id> --offset 0 --max-chars 20000\n\n# Derive paths from the actual parent and preserve the original basename when moving\nqmind source mkdir --nb <notebook-id> --title guides --parent <directory-id> --derive-path\nqmind source mv <source-id> --nb <notebook-id> --to <directory-id>\nqmind source mv <source-id> --nb <notebook-id> --to-root\n\n# 1..100 distinct IDs; confirm interactively or explicitly pass --force\nqmind source delete-batch <source-id-1> <source-id-2> --nb <notebook-id> --force\n```\n\n`notebook list/get` JSON/NDJSON preserve the server's overview, sourceCount and materialCount. Agent output expands summary/topics; table lists include summaries and Source counts. `discover` supports owned/shared/all and cursors, defaults to all, and lists retrieval-eligible notebooks; use `list` for the management collection. An empty page may still have `hasMore:true`; continue with the same relationship.\n\n`source read` checks ingestion status and returns `content/contentType/truncated/nextOffset`. It still fetches the entire body before slicing, so only output size is bounded. Existing `source content` full-text/download behavior is unchanged. `source list --parent` cannot be combined with `--all`.\n\n`mkdir --derive-path` conflicts with `--path`. `mv --to/--to-root` conflicts with the legacy parent/path/rename/status options and only moves eligible leaf documents within one notebook, preserving the basename. Existing low-level mkdir/mv patch operations remain available.\n\nBatch deletion returns the submitted sourceIds and successCount/failureCount; sourceIds is not a list of successfully deleted IDs. Partial failure exits 1. Reconcile current state before another call; do not guess failed IDs or replay the entire batch.\n\n## Precise and unified retrieval\n\nExisting `retrieve --nb` defaults and output remain unchanged. Explicit `--unified` or `--targets` selects the same unified retrieval workflow used by Agent tools, including notebook identity in single-notebook chunks:\n\n```sh\nqmind retrieve --nb <notebook-id> --unified --score-threshold 0.6 'Deployment process'\nqmind retrieve --targets '[{\"notebookId\":\"nb-1\",\"sourceIds\":[\"source-1\"]},{\"notebookId\":\"nb-2\",\"sourceIds\":[\"source-2\"]}]' --max-results 8 'Deployment process'\n```\n\n`--targets` conflicts with `--nb` and `--sources` and supports independent Source filters per notebook. Unified retrieval defaults to maxResults=8 (1..50), with optional topK (1..100); zero selects the workflow default. There may be at most 32 unique targets. Results use the envelope above: read `data.chunks/data.promptContext`. `--score-threshold` accepts 0..1 and also works on the existing retrieval path. Zero budgets on the existing path still use server defaults; scripts are not silently migrated.\n\n## Scheduled task configuration\n\n```sh\nqmind scheduled-task create --nb <notebook-id> --scene source_refresh --schedule 'CRON_TZ=Asia/Shanghai 0 9 * * *'\nqmind scheduled-task list --nb <notebook-id> --enabled true --page 1 --page-size 20\nqmind scheduled-task update <task-id> --nb <notebook-id> --schedule 'CRON_TZ=Asia/Shanghai 0 10 * * *'\nqmind scheduled-task pause <task-id> --nb <notebook-id>\nqmind scheduled-task resume <task-id> --nb <notebook-id>\nqmind scheduled-task delete <task-id> --nb <notebook-id>\n```\n\n`update --enabled false/true` also pauses/resumes. Creation defaults to enabled with empty config; arbitrary prompt/config inputs are not accepted. Updates only change schedule or enabled. New schedules support condensation, source_refresh and source_binding_sync. Existing compilation and lint schedules can be inspected, paused and deleted. An explicit IANA timezone is required. source_binding_sync is currently a per-notebook singleton with a minimum five-minute interval. `list` supports `--task/--scene/--enabled`, with pageSize at most 20; the backend still reads all configurations for the notebook. Oversized config is marked `configTruncated:true`.\n\nConfiguration is separate from execution: use `task list --scheduled-task <task-id>` for run history. Pausing/deleting does not cancel dispatched runs; resuming an overdue schedule may trigger a run immediately. Execution retains the original creator identity; revoking membership does not guarantee schedules stop automatically.\n\n## Unconfirmed writes\n\nWhen a new command returns `error.code=outcome_unknown` and `retryable:false`, inspect current state before deciding what to do next; do not retry automatically. Existing direct-write commands also distinguish this state in JSON/NDJSON errors and retain the original causeCode/requestId. Unknown outcomes do not prove a request reached the server; a same-name resource does not prove this call created it.\n\n`notebook delete` and `source delete` support JSON/NDJSON success receipts. Single-Source deletion stops if preflight cannot read the Source; only explicit `--force` skips directory confirmation. Default text output remains `deleted`.\n",
|
|
47
|
+
"readme": "# QMind CLI for Qoder Global\n\n[简体中文](./README.zh-CN.md)\n\nThe 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.\n\nPackage: `@qoder-ai/qmind-cli` · command: `qmind`\n\n## Install\n\nNode.js `>=22.19.0` is required.\n\n```sh\nnpm install --global @qoder-ai/qmind-cli\nqmind version\nqmind --help\n```\n\nUpgrade and uninstall through npm. `qmind self-update` only prints the npm upgrade command and never modifies npm-managed files.\n\n```sh\nnpm update --global @qoder-ai/qmind-cli\nnpm uninstall --global @qoder-ai/qmind-cli\n```\n\nThe Native standalone CLI uses the verified Global release channel instead. An installer-managed\nNative executable can check or apply the latest release without Node.js or npm:\n\n```sh\nqmind update --check\nqmind update\n```\n\n`self-update` remains an alias for `update`. The updater rejects channel/URL overrides, downgrades,\nunowned executables, release checksum mismatches, and modified installer bytes. Windows schedules\nreplacement after the running executable exits and records details beside the executable.\n\n## Quick start\n\n```sh\nqmind login\nqmind notebook list\nqmind source list --nb <notebook-id>\nqmind retrieve --nb <notebook-id> \"What must be checked before release?\"\n```\n\nInteractive login opens a browser and stores the session in a local file vault. For CI and agents, prefer an environment variable and structured output:\n\n```sh\nexport QMIND_TOKEN='<token>'\nqmind notebook list --non-interactive --format json\nqmind retrieve --nb <notebook-id> --format agent \"What is the deployment process?\"\n```\n\nDo not put tokens in command arguments, repositories, or logs. Run `qmind logout` to remove the current local session.\n\n### Login without a browser or interactive terminal\n\nCreate a PAT on the [Qoder PAT management page](https://qoder.com/account/integrations), then sign in through standard input (`--non-interactive` is also supported):\n\n```sh\nqmind login --pat-stdin < /path/to/pat-secret\nqmind notebook list --non-interactive --format json\n```\n\nAlternatively, inject `QODER_PROD_PAT` from your secret manager and run `qmind login --non-interactive`. `login --pat <token>` accepts an explicit PAT; prefer stdin or environment variables to keep secrets out of shell history and process arguments. PAT login exchanges a Job Token before saving the PAT, Job Token, and expiry in the current target's file vault. Later commands reuse the cached Job Token and exchange again on expiry or HTTP 401. Business requests use only the Job Token. `logout` removes the current target's local credentials without revoking the remote PAT.\n\nFor CI, inject a PAT and run commands directly without saving it to the vault. This product uses `QODER_PROD_PAT` for production and `QODER_TEST_PAT` for `--env test`, with `QODER_PERSONAL_ACCESS_TOKEN` as a fallback. Global `--env daily` uses only the generic variable. Dedicated PATs are never borrowed across regions or environments. Custom targets do not automatically read these PAT variables; explicitly use `--pat-stdin` or `--token`.\n\nFor browser login, `qmind login --no-browser` prints the authorization URL to open on another machine; it still requires an interactive terminal.\n\n## Commands\n\n| Command | Purpose |\n| ------------------------ | ---------------------------------------- |\n| `login` / `logout` | Sign in or remove local credentials |\n| `notebook` | Manage knowledge bases |\n| `source` | Manage knowledge-base sources |\n| `retrieve` | Retrieve context without invoking an LLM |\n| `rag` | Ask questions using a knowledge base |\n| `task` | Manage task runs |\n| `scheduled-task` | Manage notebook schedule configurations |\n| `upload-folder` / `sync` | Synchronize a local directory |\n| `image` | Obtain image upload or access URLs |\n| `version` | Print version and build information |\n| `update` / `self-update` | Update an installer-managed Native CLI |\n\n`task create` starts manual `condensation` or `source_refresh` runs. Manual refresh covers the entire notebook. Use `scheduled-task create --scene source_binding_sync` to schedule binding sync. Use `task list` and `task get` to inspect historical compilation and lint runs.\n\n`source import-site` imports at the notebook root and supports a sitemap, path filters, and a page limit.\n\nRun `qmind <command> --help` for complete options. Notebook commands with `--format` support `table`, `json`, `agent`, and `ndjson`. Folder sync supports `json` and `text`. 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.\n\n## Multi-notebook retrieval\n\n`retrieve --nb` accepts comma-separated or repeated Notebook IDs, deduplicating up to 32 distinct notebooks:\n\n```sh\nqmind retrieve --nb nb-1,nb-2 \"What is the deployment process?\" --format json\nqmind retrieve --nb nb-1 --nb nb-2 \"What is the deployment process?\" --format agent\n```\n\n- Selection is explicit; the CLI never defaults to all accessible notebooks.\n- Multiple notebooks use one unified retrieval request. The server jointly retrieves and reranks Source chunks; output retains server ranking and each chunk/citation's `notebookId` and `notebookTitle`.\n- `--top-k` controls the joint recall candidate budget per route/query/channel; it is not multiplied by notebook count. `--max-results` limits the final results across all selected notebooks. Zero uses server defaults.\n- `--sources` requires a single notebook. A single deduplicated notebook keeps the existing retrieval endpoint. All retrieval output formats expose chunks and citations without knowledge cards.\n- Multi-notebook JSON returns `{ chunks, citations, promptContext, total, reranked }`. NDJSON emits one `kind: \"chunk\"` record per returned chunk, in server order; zero hits emit no records. Table and agent output also identify each evidence item's notebook.\n- Unified retrieval fails as one request when a target is invalid or inaccessible. The CLI reports the error without retrying notebooks individually or constructing partial-success results. Retrieval results no longer contain a `cards` field.\n\n## Directory synchronization\n\nReview the plan before allowing remote deletions:\n\n```sh\nqmind upload-folder --nb <notebook-id> --dir ./docs --mode if-changed --dry-run\n```\n\nRemoving `--dry-run` enables writes. `--delete` treats the remote source root as a mirror of the local directory and removes extra remote entries. Concurrency must be between `1` and `10`.\n\n## Configuration and authentication\n\nThis package has a fixed Qoder Global identity. Renaming the executable, changing its install path, or setting product-selection environment variables cannot switch products. Production is the default; `--env test` and `--env daily` select supported debug presets. A custom target requires both `--sash` and `--dashboard` and cannot be combined with an explicit `--env`.\n\n**Using CLI 5.x with a custom gateway** On the origin supplied with `--sash`, route `/qmind/api/v1/` to QMind and enable Bearer authentication for CLI requests. Keep both origin arguments and the existing sign-in and token exchange routes. Verify notebook list and create with the same pair of origins. Pin your installed 4.x CLI version while the gateway serves notebooks only under `/sash/api/v1/notebooks`.\n\n```sh\nqmind login --env test\nQMIND_DEBUG_TOKEN='<debug-token>' qmind notebook list --env test --non-interactive --format json\nqmind login --sash http://localhost:8080 --dashboard http://localhost:3000\n```\n\nProduction token priority is `--token > QMIND_TOKEN > selected Qoder PAT variable > current production vault`. Debug token priority is `--token > QMIND_DEBUG_TOKEN > selected Qoder PAT variable > current debug vault`; credentials are never borrowed across targets.\n\nState is stored under `<state-root>/cli/global/<target>/`, where the state root is `QMIND_HOME` or `~/.qmind`. The CLI does not install, load, or access the OS Keyring. Credential files are plaintext JSON, not encrypted storage. On POSIX, partition directories use mode `0700` and files use `0600`; these modes do not represent Windows ACLs. Writes use atomic replacement, file locking, and compare-and-swap protection for refreshes.\n\nAfter upgrading from the legacy unpartitioned store, sign in again. Root-level config/credential files, `~/.qmind-env`, and old Keyring entries are not read, imported, or deleted automatically.\n\nThe shared 3.x Global/CN release is a breaking upgrade from Global 2.x. Upgrade this package with npm, then run `qmind login`; do not copy legacy credentials into the new partition. Existing versions before the shared release describe the Global/shared implementation only and do not imply a historical CN publication.\n\nCommon variables include `QMIND_TOKEN`, `QMIND_DEBUG_TOKEN`, `QMIND_HOME`, `QMIND_CLIENT`, `QMIND_NON_INTERACTIVE`, `QMIND_REQUEST_TIMEOUT_MS`, `QMIND_STREAM_IDLE_TIMEOUT_MS`, and `QMIND_TLS_CA_FILE`. `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` are supported. TLS verification is strict by default, and credentials are not forwarded to signed object-storage URLs.\n\n## Shared notebook discovery and access\n\n```sh\nqmind notebook list --shared --page 1 --page-size 20\nqmind notebook list --shared --format json\nqmind notebook get <notebook-id> --format json\n```\n\nBoth notebook collections support `--page` and `--page-size`. `--shared` cannot be combined with `--filter-client`. Shared results use the same flat `notebooks` output as the ordinary list and preserve the membership `permission`. JSON/NDJSON preserve server-provided `access` (current role, member count and action permissions); Agent output expands these fields. Table lists show role and member count, while details show action permissions. Missing permissions are not inferred and display as `unknown` in tables.\n\n## Commands aligned with Agent tools\n\nCore-backed workflows (`notebook discover`, `source import-url/read/delete-batch`, `mkdir --derive-path`, `mv --to/--to-root`, unified retrieval, and `scheduled-task`) return `{ ok, data/error, meta }` after entering Agent Core, with `meta.operationId` identifying the operation. `--format ndjson` emits one complete result per line; `table` and `agent` also use this JSON result. CLI validation and host/credential failures before Core keep the existing CLI error format: `{ error }` on stdout for JSON/NDJSON, or text on stderr otherwise. Command usage errors and declined confirmations go to stderr. `source list --parent` keeps the existing Source-list output. Exit codes are 0 for success, 1 for partial success/runtime failure/cancellation, and 2 for invalid arguments. A successful write does not mean Source ingestion or a scheduled run has completed.\n\n```sh\n# Select retrieval-eligible owned/shared notebooks; continue with nextCursor when hasMore is true\nqmind notebook discover --relationship all --page-size 20\nqmind notebook discover --relationship all --cursor '<nextCursor>'\n\n# Import a single page; inspect ingestion and content with source get / source read\nqmind source import-url --nb <notebook-id> --url https://example.com/guide\nqmind source list --nb <notebook-id> --parent <directory-id>\nqmind source read <source-id> --nb <notebook-id> --offset 0 --max-chars 20000\n\n# Derive paths from the actual parent and preserve the original basename when moving\nqmind source mkdir --nb <notebook-id> --title guides --parent <directory-id> --derive-path\nqmind source mv <source-id> --nb <notebook-id> --to <directory-id>\nqmind source mv <source-id> --nb <notebook-id> --to-root\n\n# 1..100 distinct IDs; confirm interactively or explicitly pass --force\nqmind source delete-batch <source-id-1> <source-id-2> --nb <notebook-id> --force\n```\n\n`notebook list/get` JSON/NDJSON preserve the server's overview, sourceCount and materialCount. Agent output expands summary/topics; table lists include summaries and Source counts. `discover` supports owned/shared/all and cursors, defaults to all, and lists retrieval-eligible notebooks; use `list` for the management collection. An empty page may still have `hasMore:true`; continue with the same relationship.\n\n`source read` checks ingestion status and returns `content/contentType/truncated/nextOffset`. It still fetches the entire body before slicing, so only output size is bounded. Existing `source content` full-text/download behavior is unchanged. `source list --parent` cannot be combined with `--all`.\n\n`mkdir --derive-path` conflicts with `--path`. `mv --to/--to-root` conflicts with the legacy parent/path/rename/status options and only moves eligible leaf documents within one notebook, preserving the basename. Existing low-level mkdir/mv patch operations remain available.\n\nBatch deletion returns the submitted sourceIds and successCount/failureCount; sourceIds is not a list of successfully deleted IDs. Partial failure exits 1. Reconcile current state before another call; do not guess failed IDs or replay the entire batch.\n\n## Precise and unified retrieval\n\nExisting `retrieve --nb` defaults and output remain unchanged. Explicit `--unified` or `--targets` selects the same unified retrieval workflow used by Agent tools, including notebook identity in single-notebook chunks:\n\n```sh\nqmind retrieve --nb <notebook-id> --unified --score-threshold 0.6 'Deployment process'\nqmind retrieve --targets '[{\"notebookId\":\"nb-1\",\"sourceIds\":[\"source-1\"]},{\"notebookId\":\"nb-2\",\"sourceIds\":[\"source-2\"]}]' --max-results 8 'Deployment process'\n```\n\n`--targets` conflicts with `--nb` and `--sources` and supports independent Source filters per notebook. Unified retrieval defaults to maxResults=8 (1..50), with optional topK (1..100); zero selects the workflow default. There may be at most 32 unique targets. Results use the envelope above: read `data.chunks/data.promptContext`. `--score-threshold` accepts 0..1 for non-OTS retrieval on either path. Zero budgets on the existing path still use server defaults; scripts are not silently migrated.\n\n### Search with an image\n\nUse `--image <path>` with a single local JPEG, PNG, WebP, BMP, TIFF or GIF file up to 10 MiB. Omit the query for image-only retrieval, or add up to 128 UTF-16 code units of text as a positional query or `--query`. Image queries require OTS retrieval on the server.\n\n```bash\nqmind retrieve --nb nb-1 --image ./diagram.png --format json\nqmind retrieve --targets '[{\"notebookId\":\"nb-1\",\"sourceIds\":[\"source-1\"]},{\"notebookId\":\"nb-2\"}]' --image ./diagram.png \"Find the deployment steps\" --format json\n```\n\nUse `--format json` or `--format ndjson` to read returned image bytes. Direct `--nb` retrieval exposes the data URL in `chunks[].metadata.imageDataUrl` (or `metadata.imageDataUrl` on each NDJSON chunk). With `--unified` or `--targets`, an image hit can contain `data.chunks[].image` with `mimeType` and Base64 `data`.\n\n## Scheduled task configuration\n\n```sh\nqmind scheduled-task create --nb <notebook-id> --scene source_refresh --schedule 'CRON_TZ=Asia/Shanghai 0 9 * * *'\nqmind scheduled-task list --nb <notebook-id> --enabled true --page 1 --page-size 20\nqmind scheduled-task update <task-id> --nb <notebook-id> --schedule 'CRON_TZ=Asia/Shanghai 0 10 * * *'\nqmind scheduled-task pause <task-id> --nb <notebook-id>\nqmind scheduled-task resume <task-id> --nb <notebook-id>\nqmind scheduled-task delete <task-id> --nb <notebook-id>\n```\n\n`update --enabled false/true` also pauses/resumes. Creation defaults to enabled with empty config; arbitrary prompt/config inputs are not accepted. Updates only change schedule or enabled. New schedules support condensation, source_refresh and source_binding_sync. Existing compilation and lint schedules can be inspected, paused and deleted. An explicit IANA timezone is required. source_binding_sync is currently a per-notebook singleton with a minimum five-minute interval. `list` supports `--task/--scene/--enabled`, with pageSize at most 20; the backend still reads all configurations for the notebook. Oversized config is marked `configTruncated:true`.\n\nConfiguration is separate from execution: use `task list --scheduled-task <task-id>` for run history. Pausing/deleting does not cancel dispatched runs; resuming an overdue schedule may trigger a run immediately. Execution retains the original creator identity; revoking membership does not guarantee schedules stop automatically.\n\n## Unconfirmed writes\n\nWhen a new command returns `error.code=outcome_unknown` and `retryable:false`, inspect current state before deciding what to do next; do not retry automatically. Existing direct-write commands also distinguish this state in JSON/NDJSON errors and retain the original causeCode/requestId. Unknown outcomes do not prove a request reached the server; a same-name resource does not prove this call created it.\n\n`notebook delete` and `source delete` support JSON/NDJSON success receipts. Single-Source deletion stops if preflight cannot read the Source; only explicit `--force` skips directory confirmation. Default text output remains `deleted`.\n",
|
|
48
48
|
"readmeFilename": "README.md"
|
|
49
49
|
}
|