@qoder-ai/qmind-cli 5.1.0 → 5.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ 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.2
8
+
9
+ ### Patch Changes
10
+
11
+ - ac64a73: Fix Native CLI installation when the download CDN serves gzip-encoded release files.
12
+
13
+ ## 5.1.1
14
+
15
+ ### Patch Changes
16
+
17
+ - f070ae0: Update the CLI's HTML entity decoder to `entities@9.0.0`.
18
+
7
19
  ## 5.1.0
8
20
 
9
21
  ### Minor Changes
@@ -4,6 +4,18 @@
4
4
 
5
5
  以下已发布版本属于 Global CLI / 共享实现,不代表 CN 曾发布过这些版本。CN 将在后续共同发行版加入同一历史。
6
6
 
7
+ ## 5.1.2
8
+
9
+ ### Patch Changes
10
+
11
+ - ac64a73: 修复下载 CDN 返回 gzip 压缩的发布文件时 Native CLI 安装失败的问题。
12
+
13
+ ## 5.1.1
14
+
15
+ ### Patch Changes
16
+
17
+ - f070ae0: 将 CLI 的 HTML 实体解码依赖升级到 `entities@9.0.0`。
18
+
7
19
  ## 5.1.0
8
20
 
9
21
  ### Minor Changes
@@ -1,4 +1,4 @@
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";
1
+ import { at as dataSourceConfigurationSchema, ct as dataSourceResourceSchema, lt as dataSourceRunsSchema, m as requiredString, n as call, ot as dataSourceListSchema, p as queryPath, st as dataSourcePreviewSchema, ut as dataSourceSchema, x as qmindPath } from "./shared-Cyj1bHGY.js";
2
2
  import { z } from "zod";
3
3
  //#region ../sdk/src/operations/data-sources.ts
4
4
  function createDataSourceOperations(context) {
@@ -1,4 +1,4 @@
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";
1
+ import { A as fullSiteURLImportConfirmationSchema, C as aliDingImportRunItemListSchema, F as knowledgeImportProvidersSchema, P as importProvidersSchema, _ as assertCapability, a as invalidArgument, d as pagination, dt as QMindError, it as qmindFullSiteURLImportPageLimit, j as fullSiteURLImportDiscoverySchema, m as requiredString, n as call, p as queryPath, w as aliDingImportRunSchema, x as qmindPath } from "./shared-Cyj1bHGY.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;
@@ -50,9 +50,22 @@ function canonicalAliDingUrl(value, scope) {
50
50
  function importRunBody(input, scope) {
51
51
  const requestId = requiredString(input?.requestId, "requestId");
52
52
  if (!requestIdPattern.test(requestId.toLowerCase())) throw invalidArgument("requestId must be a UUID", "requestId");
53
+ const url = canonicalAliDingUrl(input?.url, scope);
54
+ const selection = input.selectedNodeIds;
55
+ if (selection !== void 0 && (!input.documentConnection || !Array.isArray(selection) || !selection.length || selection.length > 256 || selection.some((id) => typeof id !== "string" || !/^[A-Za-z0-9._~-]{1,256}$/.test(id) || id === "." || id === ".."))) throw invalidArgument("Invalid AliDing node selection", "selectedNodeIds");
56
+ if (input.documentConnection === void 0) return {
57
+ requestId,
58
+ url
59
+ };
60
+ if (scope !== "knowledgeBase") throw invalidArgument("OAuth requires a knowledge base", "documentConnection");
53
61
  return {
54
62
  requestId,
55
- url: canonicalAliDingUrl(input?.url, scope)
63
+ url,
64
+ ...selection && { selectedNodeIds: [...new Set(selection)].sort() },
65
+ documentConnection: {
66
+ serverId: requiredString(input.documentConnection?.serverId, "serverId"),
67
+ connectionId: requiredString(input.documentConnection?.connectionId, "connectionId")
68
+ }
56
69
  };
57
70
  }
58
71
  function createImportOperations(context) {
@@ -125,15 +138,27 @@ function createImportOperations(context) {
125
138
  },
126
139
  async listImportProviders(options) {
127
140
  assertCapability(context.capabilities, "imports.discover", "imports.discover");
128
- return call(context, {
141
+ const request = {
129
142
  callOptions: options,
130
143
  capability: "imports.discover",
131
144
  idempotent: true,
132
145
  method: "GET",
133
- operation: "imports.discover",
134
- path: qmindPath("import-sources"),
135
- schema: importProvidersSchema
136
- });
146
+ operation: "imports.discover"
147
+ };
148
+ try {
149
+ return await call(context, {
150
+ ...request,
151
+ path: qmindPath("import-sources"),
152
+ schema: importProvidersSchema
153
+ });
154
+ } catch (error) {
155
+ if (!(error instanceof QMindError) || error.status !== 404) throw error;
156
+ return call(context, {
157
+ ...request,
158
+ path: qmindPath("knowledge-capabilities"),
159
+ schema: knowledgeImportProvidersSchema
160
+ });
161
+ }
137
162
  },
138
163
  async startAliDingKnowledgeBaseImport(notebookId, input, options) {
139
164
  const notebook = requiredString(notebookId, "notebookId");
@@ -146,7 +171,7 @@ function createImportOperations(context) {
146
171
  idempotent: false,
147
172
  method: "POST",
148
173
  operation: "imports.aliDing.createKnowledgeBaseRun",
149
- path: qmindPath("notebooks", notebook, "aliding", "knowledge-base-import-runs"),
174
+ path: qmindPath("notebooks", notebook, "aliding", input.selectedNodeIds ? "selected-import-runs" : "knowledge-base-import-runs"),
150
175
  schema: aliDingImportRunSchema
151
176
  });
152
177
  },
@@ -1,4 +1,4 @@
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";
1
+ import { a as invalidArgument, c as optionalRecord, dt as QMindError, l as optionalString, m as requiredString, n as call, r as compactUndefined, rt as voidResponseSchema, s as optionalBoolean, t as assertNonEmptyPatch, x as qmindPath } from "./shared-Cyj1bHGY.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 { b as pathBuilder, ut as QMindError } from "./shared-CWO5bxZy.js";
1
+ import { b as pathBuilder, dt as QMindError } from "./shared-Cyj1bHGY.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 { 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";
1
+ import { c as optionalRecord, d as pagination, h as requiredText, l as optionalString, m as requiredString, n as call, nt as timestampSchema, p as queryPath, r as compactUndefined, rt as voidResponseSchema, t as assertNonEmptyPatch, x as qmindPath } from "./shared-Cyj1bHGY.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,6 +1,6 @@
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";
1
+ import { $ as sourceWebOfficeTokenSchema, B as sharedNotebookListSchema, D as chatMessageListSchema, E as cancelQuestionResultSchema, G as sourceListSchema, H as sourceChildrenCountsSchema, I as notebookListSchema, J as sourceRawContentSchema, K as sourcePreviewSchema, L as notebookSchema, M as imageUploadTicketSchema, N as imageUrlsSchema, O as chatSessionListSchema, Q as sourceWebOfficeSessionSchema, R as retrieveNotebooksResultSchema, S as qmindRoutes, T as batchDeleteResultSchema, U as sourceContentSchema, V as sourceActionAccessSchema, W as sourceImportResultsSchema, X as sourceUploadCapabilitiesSchema, Y as sourceSchema, _ as assertCapability, a as invalidArgument$1, c as optionalRecord, d as pagination$1, dt as QMindError, et as taskRunListSchema, f as positiveInteger$1, g as stringList, i as httpUrl, k as chatSessionSchema, l as optionalString$1, m as requiredString$1, n as call, o as nonNegativeInteger$1, p as queryPath, q as sourceQuotaSchema, r as compactUndefined, rt as voidResponseSchema, s as optionalBoolean, t as assertNonEmptyPatch, tt as taskRunSchema, u as optionalTrimmedString, v as executeStream, x as qmindPath, z as retrieveResultSchema } from "./shared-Cyj1bHGY.js";
2
+ import { n as nezhaWebOfficePath } from "./nezha-Dgm3_VQA.js";
3
+ import { t as preflightSourceUpload } from "./source-upload-UCVqDJod.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";
@@ -658,7 +658,7 @@ function createAgentOperations(context) {
658
658
  //#region ../sdk/src/operations/notebooks.ts
659
659
  function createNotebookOperations(context) {
660
660
  let wikiOperations;
661
- const loadWiki = () => wikiOperations ??= import("./wiki-branches-ClpusERr.js").then(({ createWikiBranchOperations }) => createWikiBranchOperations(context));
661
+ const loadWiki = () => wikiOperations ??= import("./wiki-branches-DVsfkeIS.js").then(({ createWikiBranchOperations }) => createWikiBranchOperations(context));
662
662
  return {
663
663
  async copyFeaturedNotebook(notebookId, options) {
664
664
  const notebook = requiredString$1(notebookId, "notebookId");
@@ -1688,7 +1688,7 @@ const noteOperationNames = [
1688
1688
  function createLazyDataSourceOperations(context) {
1689
1689
  let operations;
1690
1690
  const load = () => {
1691
- operations ??= import("./data-sources-BMWzGZMy.js").then(({ createDataSourceOperations }) => createDataSourceOperations(context));
1691
+ operations ??= import("./data-sources-BPDVRCNK.js").then(({ createDataSourceOperations }) => createDataSourceOperations(context));
1692
1692
  return operations;
1693
1693
  };
1694
1694
  return {
@@ -1708,7 +1708,7 @@ function createLazyDataSourceOperations(context) {
1708
1708
  function createLazyTransferOperations(context) {
1709
1709
  let operations;
1710
1710
  const load = () => {
1711
- operations ??= import("./transfers-BUZM2vVy.js").then(({ createTransferOperations }) => createTransferOperations(context));
1711
+ operations ??= import("./transfers-BcknzY_J.js").then(({ createTransferOperations }) => createTransferOperations(context));
1712
1712
  return operations;
1713
1713
  };
1714
1714
  return {
@@ -1719,7 +1719,7 @@ function createLazyTransferOperations(context) {
1719
1719
  function createLazyWikiOperations(context) {
1720
1720
  let operations;
1721
1721
  const load = () => {
1722
- operations ??= import("./wiki-C76wZ3j_.js").then(({ createWikiOperations }) => createWikiOperations(context));
1722
+ operations ??= import("./wiki-ZHC_GTBb.js").then(({ createWikiOperations }) => createWikiOperations(context));
1723
1723
  return operations;
1724
1724
  };
1725
1725
  return {
@@ -1731,7 +1731,7 @@ function createLazyWikiOperations(context) {
1731
1731
  function createLazyNoteOperations(context) {
1732
1732
  let operations;
1733
1733
  const load = () => {
1734
- operations ??= import("./notes-Cz178zE-.js").then(({ createNoteOperations }) => createNoteOperations(context));
1734
+ operations ??= import("./notes-3zUdvWqK.js").then(({ createNoteOperations }) => createNoteOperations(context));
1735
1735
  return operations;
1736
1736
  };
1737
1737
  return Object.fromEntries(noteOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
@@ -1739,7 +1739,7 @@ function createLazyNoteOperations(context) {
1739
1739
  function createLazyImportOperations(context) {
1740
1740
  let operations;
1741
1741
  const load = () => {
1742
- operations ??= import("./imports-DHdWJ9rK.js").then(({ createImportOperations }) => createImportOperations(context));
1742
+ operations ??= import("./imports-DkL0FuBt.js").then(({ createImportOperations }) => createImportOperations(context));
1743
1743
  return operations;
1744
1744
  };
1745
1745
  return Object.fromEntries(importOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
@@ -1747,7 +1747,7 @@ function createLazyImportOperations(context) {
1747
1747
  function createLazyManagementOperations(context) {
1748
1748
  let operations;
1749
1749
  const load = () => {
1750
- operations ??= import("./management-D4dfHim9.js").then(({ createManagementOperations }) => createManagementOperations(context));
1750
+ operations ??= import("./management-BV5KWpJ8.js").then(({ createManagementOperations }) => createManagementOperations(context));
1751
1751
  return operations;
1752
1752
  };
1753
1753
  return Object.fromEntries(managementOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
@@ -1896,20 +1896,44 @@ const listNotebooksInputSchema = z.object({
1896
1896
  ]).optional(),
1897
1897
  cursor: z.string().min(1).max(512).optional()
1898
1898
  }).strict();
1899
- const retrieveInputSchema = z.object({
1899
+ const retrieveParametersSchema = z.object({
1900
1900
  imageBase64: z.string().trim().min(1).describe("Image data URL or standard Base64. One image, up to 10 MiB before encoding.").optional(),
1901
1901
  imageFormat: z.string().trim().min(1).describe("Required for raw Base64: jpeg, jpg, png, webp, bmp, tiff or gif.").optional(),
1902
1902
  maxResults: z.number().int().min(1).max(50).default(8),
1903
- notebookId: opaqueId.optional(),
1903
+ notebookId: opaqueId.describe("Select one notebook. Pair with top-level sourceIds to restrict its sources. Choose notebookId or targets.").optional(),
1904
1904
  targets: z.array(z.object({
1905
1905
  notebookId: opaqueId,
1906
- sourceIds: z.array(opaqueId).min(1).max(100).refine((ids) => new Set(ids).size === ids.length).optional()
1907
- }).strict()).min(1).max(32).refine((targets) => new Set(targets.map((target) => target.notebookId)).size === targets.length).optional(),
1906
+ sourceIds: z.array(opaqueId).min(1).max(100).refine((ids) => new Set(ids).size === ids.length).describe("Restrict this target to these source IDs within its notebook.").optional()
1907
+ }).strict()).min(1).max(32).refine((targets) => new Set(targets.map((target) => target.notebookId)).size === targets.length).describe("Select notebooks with one object per notebook, such as [{\"notebookId\":\"nb-1\"}]. Put sourceIds inside each target. Choose targets or top-level notebookId.").optional(),
1908
1908
  query: z.string().trim().min(1).max(2e3).describe(`Text query, up to 128 UTF-16 units with an image.`).optional(),
1909
1909
  scoreThreshold: z.number().min(0).max(1).describe("Minimum score for non-OTS retrieval.").optional(),
1910
- sourceIds: z.array(opaqueId).min(1).max(50).refine((values) => new Set(values).size === values.length, { message: "sourceIds must be unique" }).optional(),
1910
+ sourceIds: z.array(opaqueId).min(1).max(50).refine((values) => new Set(values).size === values.length, { message: "sourceIds must be unique" }).describe("Restrict the notebook selected by top-level notebookId to these source IDs. With targets, put sourceIds inside each target.").optional(),
1911
1911
  topK: z.number().int().min(1).max(100).optional()
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) => {
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" });
1913
+ function localAttachmentRetrieveSchema(options) {
1914
+ const withReference = retrieveParametersSchema.safeExtend({ imageAttachmentRef: z.uuidv4().describe("Current-turn image reference supplied with the attached image by the host.").optional() });
1915
+ const pathField = { imagePath: z.string().min(1).max(4096).describe("Absolute path supplied with the attached local image.").optional() };
1916
+ if (options.reference) return options.path ? withReference.safeExtend(pathField).superRefine(validateAttachmentImage) : withReference.superRefine(validateAttachmentImage);
1917
+ return options.path ? retrieveParametersSchema.safeExtend(pathField).superRefine(validateAttachmentImage) : retrieveParametersSchema.superRefine(validateAttachmentImage);
1918
+ }
1919
+ localAttachmentRetrieveSchema({
1920
+ reference: true,
1921
+ path: false
1922
+ });
1923
+ function validateAttachmentImage(input, context) {
1924
+ if (input.imageAttachmentRef === void 0 && input.imagePath === void 0) return validateRetrievalImage(input, context);
1925
+ if (input.query !== void 0 && input.query.length > 128) context.addIssue({
1926
+ code: "custom",
1927
+ path: ["query"],
1928
+ message: `image retrieval query must be at most 128 UTF-16 units`
1929
+ });
1930
+ if (input.imageBase64 !== void 0 || input.imageFormat !== void 0 || input.imageAttachmentRef !== void 0 && input.imagePath !== void 0) context.addIssue({
1931
+ code: "custom",
1932
+ path: [input.imagePath === void 0 ? "imageAttachmentRef" : "imagePath"],
1933
+ message: "Choose a single image input."
1934
+ });
1935
+ }
1936
+ function validateRetrievalImage({ query, imageBase64, imageFormat }, context) {
1913
1937
  if (query === void 0 && imageBase64 === void 0 && imageFormat === void 0) context.addIssue({
1914
1938
  code: "custom",
1915
1939
  path: ["query"],
@@ -1925,7 +1949,8 @@ const retrieveInputSchema = z.object({
1925
1949
  path: [issue.field],
1926
1950
  message: issue.message
1927
1951
  });
1928
- });
1952
+ }
1953
+ const retrieveInputSchema = retrieveParametersSchema.superRefine(validateRetrievalImage);
1929
1954
  const listSourcesInputSchema = z.object({
1930
1955
  notebookId: opaqueId,
1931
1956
  page,
@@ -2055,7 +2080,15 @@ const agentToolDefinitions = Object.freeze([
2055
2080
  },
2056
2081
  {
2057
2082
  deadlineMs: 6e4,
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.`,
2083
+ description: [
2084
+ "Retrieve globally ranked context from QMind using text (query), an image (imageBase64), or both.",
2085
+ "For explicit selection, choose one form. Single notebook: `{\"query\":\"the question\",\"notebookId\":\"nb-1\"}`. One or more notebooks: `{\"query\":\"the question\",\"targets\":[{\"notebookId\":\"nb-1\"},{\"notebookId\":\"nb-2\"}]}`.",
2086
+ `Pass at most 32 unique notebooks per call. To restrict sources, put sourceIds beside a top-level notebookId or inside each target when using targets.`,
2087
+ "Omitting notebook selection uses configured defaults. maxResults caps the combined results.",
2088
+ "When notebook IDs are unknown, discover candidates with list_notebooks. To continue, pass the returned nextCursor as cursor. Select by summary and topics, with title and description as fallback.",
2089
+ "Search within the current organization and authorized retrieval scope, including configured sharing groups. Workspace links prioritize notebooks within that scope.",
2090
+ "For imageBase64, use the actual attachment bytes as an image data URL or as raw Base64 with imageFormat."
2091
+ ].join(" "),
2059
2092
  id: "qmind.retrieve",
2060
2093
  intent: "read",
2061
2094
  leaf: "retrieve"
@@ -3402,12 +3435,16 @@ function chunkLineRange(metadata) {
3402
3435
  function chunkPromptContext(chunks) {
3403
3436
  return chunks.map((chunk) => `[Notebook: ${chunk.notebookTitle} | NotebookID: ${chunk.notebookId} | Source: ${chunk.sourceTitle} | Chunk: ${chunk.chunkIndex} | SourceID: ${chunk.sourceId} | ChunkID: ${chunk.chunkId} | Score: ${chunk.score.toFixed(3)}]\n${chunk.content}`).join("\n\n---\n\n");
3404
3437
  }
3438
+ function retrievalSelectionError(count, invocation) {
3439
+ if (count === 0 || count > 32 && invocation.defaultRetrievalMode !== "all") return failure$1(invocation.operationId, "selection_required", `Use list_notebooks overview to select one to 32 relevant notebooks.`);
3440
+ }
3405
3441
  async function retrieve(client, input, invocation) {
3406
- const targets = input.targets ?? (input.notebookId === void 0 ? invocation.defaultNotebookIds?.map((notebookId) => ({ notebookId })) : [{
3442
+ const targets = input.targets ?? (input.notebookId === void 0 ? (invocation.defaultNotebookIds ?? []).map((notebookId) => ({ notebookId })) : [{
3407
3443
  notebookId: input.notebookId,
3408
3444
  ...input.sourceIds === void 0 ? {} : { sourceIds: input.sourceIds }
3409
3445
  }]);
3410
- if (targets === void 0 || targets.length === 0 || targets.length > 32 && invocation.defaultRetrievalMode !== "all") return failure$1(invocation.operationId, "selection_required", `Use list_notebooks overview to select one to 32 relevant notebooks.`);
3446
+ const selectionError = retrievalSelectionError(targets.length, invocation);
3447
+ if (selectionError) return selectionError;
3411
3448
  const batches = [];
3412
3449
  const batchSize = invocation.defaultRetrievalMode === "all" ? 1 : 32;
3413
3450
  for (let offset = 0; offset < targets.length; offset += batchSize) batches.push(targets.slice(offset, offset + batchSize));
@@ -3778,9 +3815,26 @@ async function organizeSource(client, tool, input, invocation) {
3778
3815
  function validateQMindAgentInvocation(toolId, input, invocation) {
3779
3816
  const parsed = agentToolInputSchemas[toolId].safeParse(input);
3780
3817
  if (!parsed.success) return failure$1(invocation.operationId, "invalid_input", "The tool input is invalid.");
3818
+ return validateParsedScope(toolId, parsed.data, invocation);
3819
+ }
3820
+ const localAttachmentSchema = localAttachmentRetrieveSchema({
3821
+ reference: true,
3822
+ path: true
3823
+ });
3824
+ function validateAttachmentRetrieval(input, invocation) {
3825
+ const parsed = localAttachmentSchema.safeParse(input);
3826
+ if (!parsed.success || !parsed.data.imageAttachmentRef && !parsed.data.imagePath) return failure$1(invocation.operationId, "invalid_input", "The tool input is invalid.");
3827
+ const targets = targetedNotebookIds("qmind.retrieve", parsed.data, invocation);
3828
+ return validateParsedScope("qmind.retrieve", parsed.data, invocation) ?? retrievalSelectionError(targets?.length ?? 0, invocation) ?? {
3829
+ ok: true,
3830
+ data: parsed.data,
3831
+ meta: { operationId: invocation.operationId }
3832
+ };
3833
+ }
3834
+ function validateParsedScope(toolId, input, invocation) {
3781
3835
  try {
3782
3836
  invocation.assertCurrent?.();
3783
- return enforceNotebookScope(toolId, parsed.data, invocation, scopedNotebookIds(invocation));
3837
+ return enforceNotebookScope(toolId, input, invocation, scopedNotebookIds(invocation));
3784
3838
  } catch {
3785
3839
  return failure$1(invocation.operationId, "permission_denied", "The host context is no longer valid.");
3786
3840
  }
@@ -3873,6 +3927,33 @@ function outcomeFor(result) {
3873
3927
  if (result.error.code === "outcome_unknown") return "outcome_unknown";
3874
3928
  return "failed";
3875
3929
  }
3930
+ async function prepareRetrievalImage(input, invocation, context, signal) {
3931
+ const validated = validateAttachmentRetrieval(input, invocation);
3932
+ if (!validated.ok) return validated;
3933
+ const { imageAttachmentRef, imagePath, ...parameters } = validated.data;
3934
+ try {
3935
+ const read = imagePath !== void 0 ? context.readImagePath : context.readImageAttachment;
3936
+ const locator = imagePath ?? imageAttachmentRef;
3937
+ if (!read || !locator) throw new Error("Image reader unavailable");
3938
+ signal.throwIfAborted();
3939
+ const imageBase64 = await read(locator, signal);
3940
+ signal.throwIfAborted();
3941
+ return {
3942
+ ok: true,
3943
+ data: {
3944
+ ...parameters,
3945
+ imageBase64
3946
+ },
3947
+ meta: { operationId: invocation.operationId }
3948
+ };
3949
+ } catch (error) {
3950
+ const reason = signal.aborted ? signal.reason : error;
3951
+ if (reason instanceof Error && reason.name === "TimeoutError") return failure(invocation.operationId, "timeout", "The image attachment read timed out.");
3952
+ if (signal.aborted) return failure(invocation.operationId, "cancelled", "The image attachment read was cancelled.");
3953
+ if (error instanceof Error && "code" in error && error.code === "FILE_TOO_LARGE") return failure(invocation.operationId, "invalid_input", "Use a smaller image. QMind accepts up to 10 MiB.");
3954
+ return failure(invocation.operationId, "invalid_input", "This image attachment is unavailable for this request. Attach the image again.");
3955
+ }
3956
+ }
3876
3957
  async function runQMindAgentOperation(dependencies, toolId, input, runtimeSignal, perRequestToken, operationContext = {}) {
3877
3958
  const createId = dependencies.createId ?? randomUUID;
3878
3959
  const now = dependencies.now ?? Date.now;
@@ -3903,11 +3984,15 @@ async function runQMindAgentOperation(dependencies, toolId, input, runtimeSignal
3903
3984
  const code = abortCode(signal, timedOut);
3904
3985
  result = failure(operationId, code, code === "timeout" ? "The QMind operation timed out." : "The QMind operation was cancelled.");
3905
3986
  } else {
3906
- const denied = validateQMindAgentInvocation(toolId, input, {
3987
+ const invocation = {
3907
3988
  ...operationContext,
3989
+ defaultRetrievalMode: dependencies.defaultRetrievalMode,
3908
3990
  operationId,
3909
3991
  ...dependencies.defaultNotebookIds === void 0 ? {} : { defaultNotebookIds: dependencies.defaultNotebookIds }
3910
- });
3992
+ };
3993
+ const attachment = toolId === "qmind.retrieve" && input !== null && typeof input === "object" && ("imageAttachmentRef" in input && operationContext.readImageAttachment !== void 0 || "imagePath" in input && operationContext.readImagePath !== void 0) ? await prepareRetrievalImage(input, invocation, operationContext, signal) : void 0;
3994
+ const operationInput = attachment?.ok ? attachment.data : input;
3995
+ const denied = attachment?.ok === false ? attachment : validateQMindAgentInvocation(toolId, operationInput, invocation);
3911
3996
  if (denied) result = denied;
3912
3997
  else {
3913
3998
  let fileSource;
@@ -3922,7 +4007,7 @@ async function runQMindAgentOperation(dependencies, toolId, input, runtimeSignal
3922
4007
  }
3923
4008
  if (requestedPath === void 0 || fileSource !== void 0) try {
3924
4009
  operationContext.assertCurrent?.();
3925
- result = await dependencies.core.invoke(toolId, input, {
4010
+ result = await dependencies.core.invoke(toolId, operationInput, {
3926
4011
  assertCurrent: operationContext.assertCurrent,
3927
4012
  defaultRetrievalMode: dependencies.defaultRetrievalMode,
3928
4013
  ...operationContext.notebookPolicy === void 0 ? {} : { notebookPolicy: operationContext.notebookPolicy },
@@ -5674,8 +5759,8 @@ function requestsNdjsonOutput(argv) {
5674
5759
  //#region src/build-info.ts
5675
5760
  /** Bundled identity, never inferred from argv, environment, or an endpoint. */
5676
5761
  const QMIND_CLI_DISTRIBUTION = "global";
5677
- const QMIND_CLI_VERSION = "5.1.0";
5678
- const QMIND_CLI_BUILD_TIME = "2026-11-23T13:41:36.000Z";
5762
+ const QMIND_CLI_VERSION = "5.1.2";
5763
+ const QMIND_CLI_BUILD_TIME = "2026-11-28T05:52:17.000Z";
5679
5764
  function qmindCliPlatform() {
5680
5765
  return process.platform === "win32" ? "windows" : process.platform;
5681
5766
  }
@@ -7708,7 +7793,7 @@ async function runQMindCli(argv, options = {}) {
7708
7793
  updater: options.updater ?? createQMindCliUpdater({ identity: {
7709
7794
  artifactKind: "npm",
7710
7795
  command: distribution.command,
7711
- currentVersion: "5.1.0",
7796
+ currentVersion: "5.1.2",
7712
7797
  distribution: distribution.id,
7713
7798
  executablePath: process.execPath,
7714
7799
  package: distribution.package,
@@ -72,14 +72,17 @@ function readQMindDataSourceAppPermission(code, details) {
72
72
  const parsed = dataSourceAppPermissionSchema.safeParse(details);
73
73
  return parsed.success ? parsed.data : void 0;
74
74
  }
75
+ const dataSourceProviderSchema = z.enum([
76
+ "feishu",
77
+ "feishu_drive",
78
+ "dingtalk",
79
+ "dingtalk_mcp",
80
+ "aliding",
81
+ "aliding_mcp"
82
+ ]);
75
83
  const dataSourceConfigurationSchema = z.object({
76
84
  name: z.string().min(1).max(255),
77
- provider: z.enum([
78
- "feishu",
79
- "feishu_drive",
80
- "dingtalk",
81
- "dingtalk_mcp"
82
- ]),
85
+ provider: dataSourceProviderSchema,
83
86
  resourceIds: z.array(z.string().min(1)).max(1e3).default([]),
84
87
  settings: z.record(z.string(), z.unknown()).default({}),
85
88
  schedule: z.string().default(""),
@@ -127,11 +130,17 @@ const dataSourceRunSchema = z.object({
127
130
  retryState: z.string()
128
131
  })).default([])
129
132
  });
133
+ const listEntryProviderSchema = z.object({ configuration: z.object({ provider: z.string().min(1) }) });
134
+ const dataSourceListEntriesSchema = z.array(z.unknown()).default([]).transform((rows) => rows.filter((row) => {
135
+ const entry = listEntryProviderSchema.safeParse(row);
136
+ return !entry.success || dataSourceProviderSchema.safeParse(entry.data.configuration.provider).success;
137
+ })).pipe(z.array(dataSourceSchema));
130
138
  const dataSourceListSchema = z.object({
131
- dataSources: z.array(dataSourceSchema).default([]),
132
- managedDataSources: z.array(dataSourceSchema).default([]),
139
+ dataSources: dataSourceListEntriesSchema,
140
+ managedDataSources: dataSourceListEntriesSchema,
133
141
  nextAfterId: z.string().default(""),
134
142
  dingtalkDocServerId: z.string().nullish().transform((id) => id || void 0),
143
+ alidingDocServerId: z.string().nullish().transform((id) => id || void 0),
135
144
  availableProviders: z.array(z.string()).default([])
136
145
  }).transform(({ managedDataSources, dataSources, ...page }) => ({
137
146
  ...page,
@@ -584,7 +593,12 @@ const sourceChildrenCountsSchema = z.object({ counts: z.array(z.preprocess((valu
584
593
  count: z.number().int().nonnegative().default(0),
585
594
  parentId: z.string().default("")
586
595
  }))).nullish().transform((counts) => counts ?? []) }).transform((value) => value.counts);
587
- const importProvidersSchema = z.object({ sources: z.array(z.object({ provider: z.string().default("") })).nullish().transform((sources) => sources ?? []) }).transform((value) => value.sources.filter((source) => source.provider.length > 0));
596
+ const importProviderListSchema = z.array(z.object({
597
+ provider: z.string().default(""),
598
+ docServerId: z.string().optional()
599
+ })).nullish().transform((sources) => (sources ?? []).filter((source) => source.provider.length > 0));
600
+ const importProvidersSchema = z.object({ sources: importProviderListSchema }).transform(({ sources }) => sources);
601
+ const knowledgeImportProvidersSchema = z.object({ importSources: importProviderListSchema }).transform(({ importSources }) => importSources);
588
602
  const aliDingImportRunSchema = z.preprocess((value) => isRecord$1(value) ? {
589
603
  ...value,
590
604
  bindingId: value.bindingId ?? value.binding_id,
@@ -1398,4 +1412,4 @@ function call(context, options) {
1398
1412
  });
1399
1413
  }
1400
1414
  //#endregion
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 };
1415
+ export { sourceWebOfficeTokenSchema as $, fullSiteURLImportConfirmationSchema as A, sharedNotebookListSchema as B, aliDingImportRunItemListSchema as C, chatMessageListSchema as D, cancelQuestionResultSchema as E, knowledgeImportProvidersSchema as F, sourceListSchema as G, sourceChildrenCountsSchema as H, notebookListSchema as I, sourceRawContentSchema as J, sourcePreviewSchema as K, notebookSchema as L, imageUploadTicketSchema as M, imageUrlsSchema as N, chatSessionListSchema as O, importProvidersSchema as P, sourceWebOfficeSessionSchema as Q, retrieveNotebooksResultSchema as R, qmindRoutes as S, batchDeleteResultSchema as T, sourceContentSchema as U, sourceActionAccessSchema as V, sourceImportResultsSchema as W, sourceUploadCapabilitiesSchema as X, sourceSchema as Y, sourceUploadTicketSchema as Z, assertCapability as _, invalidArgument as a, dataSourceConfigurationSchema as at, pathBuilder as b, optionalRecord as c, dataSourceResourceSchema as ct, pagination as d, QMindError as dt, taskRunListSchema as et, positiveInteger as f, stringList as g, requiredText as h, httpUrl as i, qmindFullSiteURLImportPageLimit as it, fullSiteURLImportDiscoverySchema as j, chatSessionSchema as k, optionalString as l, dataSourceRunsSchema as lt, requiredString as m, call as n, timestampSchema as nt, nonNegativeInteger as o, dataSourceListSchema as ot, queryPath as p, sourceQuotaSchema as q, compactUndefined as r, voidResponseSchema as rt, optionalBoolean as s, dataSourcePreviewSchema as st, assertNonEmptyPatch as t, taskRunSchema as tt, optionalTrimmedString as u, dataSourceSchema as ut, executeStream as v, aliDingImportRunSchema as w, qmindPath as x, executeUnary as y, retrieveResultSchema as z };
@@ -1,4 +1,4 @@
1
- import { Y as sourceUploadCapabilitiesSchema, m as requiredString, n as call, x as qmindPath } from "./shared-CWO5bxZy.js";
1
+ import { X as sourceUploadCapabilitiesSchema, m as requiredString, n as call, x as qmindPath } from "./shared-Cyj1bHGY.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 { 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";
1
+ import { M as imageUploadTicketSchema, Y as sourceSchema, Z as sourceUploadTicketSchema, a as invalidArgument, dt as QMindError, l as optionalString, m as requiredString, p as queryPath, r as compactUndefined, rt as voidResponseSchema, u as optionalTrimmedString, x as qmindPath, y as executeUnary } from "./shared-Cyj1bHGY.js";
2
+ import { t as preflightSourceUpload } from "./source-upload-UCVqDJod.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-CWO5bxZy.js";
2
- import { t as nezhaRepoWikiPath } from "./nezha-DtT7HGFc.js";
1
+ import { a as invalidArgument, dt as QMindError, m as requiredString, n as call, o as nonNegativeInteger, p as queryPath, u as optionalTrimmedString } from "./shared-Cyj1bHGY.js";
2
+ import { t as nezhaRepoWikiPath } from "./nezha-Dgm3_VQA.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 { 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";
1
+ import { S as qmindRoutes, a as invalidArgument, d as pagination, m as requiredString, n as call, nt as timestampSchema, p as queryPath, u as optionalTrimmedString } from "./shared-Cyj1bHGY.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.1.0",
3
+ "version": "5.1.2",
4
4
  "description": "QMind command line interface",
5
5
  "bin": {
6
6
  "qmind": "bin/cli.js"
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "commander": "15.0.0",
27
- "entities": "8.1.0",
27
+ "entities": "9.0.0",
28
28
  "eventsource-parser": "4.1.2",
29
29
  "open": "11.0.4",
30
30
  "p-limit": "7.3.3",
@@ -39,9 +39,9 @@
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-node-host": "^4.0.7",
43
- "@ali/qmind-agent-core": "^8.1.0",
44
- "@ali/qmind-sdk": "^2.4.0"
42
+ "@ali/qmind-agent-core": "^8.3.3",
43
+ "@ali/qmind-node-host": "^4.0.12",
44
+ "@ali/qmind-sdk": "^2.6.1"
45
45
  },
46
46
  "license": "UNLICENSED",
47
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",