@qoder-ai/qmind-cli 5.0.0 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,6 +22,162 @@ 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 dataSourceProviderSchema = z.enum([
76
+ "feishu",
77
+ "feishu_drive",
78
+ "dingtalk",
79
+ "dingtalk_mcp",
80
+ "aliding",
81
+ "aliding_mcp"
82
+ ]);
83
+ const dataSourceConfigurationSchema = z.object({
84
+ name: z.string().min(1).max(255),
85
+ provider: dataSourceProviderSchema,
86
+ resourceIds: z.array(z.string().min(1)).max(1e3).default([]),
87
+ settings: z.record(z.string(), z.unknown()).default({}),
88
+ schedule: z.string().default(""),
89
+ paused: z.boolean().default(false),
90
+ syncDeletions: z.boolean().default(false)
91
+ });
92
+ const dataSourceSchema = z.object({
93
+ id: z.string().min(1),
94
+ configuration: dataSourceConfigurationSchema,
95
+ credentialsConfigured: z.boolean().default(false),
96
+ lastSyncAt: z.string().nullish()
97
+ });
98
+ const dataSourceResourceSchema = z.object({
99
+ externalId: z.string().min(1),
100
+ name: z.string(),
101
+ type: z.string(),
102
+ url: z.string().default(""),
103
+ parentId: z.string().default(""),
104
+ hasChildren: z.boolean().default(false)
105
+ });
106
+ const dataSourceRunSchema = z.object({
107
+ id: z.string().min(1),
108
+ status: z.enum([
109
+ "queued",
110
+ "running",
111
+ "success",
112
+ "partial",
113
+ "failed",
114
+ "canceled"
115
+ ]),
116
+ startedAt: z.string().nullish(),
117
+ finishedAt: z.string().nullish(),
118
+ total: z.number().int().default(0),
119
+ created: z.number().int().default(0),
120
+ updated: z.number().int().default(0),
121
+ deleted: z.number().int().default(0),
122
+ skipped: z.number().int().default(0),
123
+ failed: z.number().int().default(0),
124
+ errorCode: z.string().default(""),
125
+ issuesTruncated: z.boolean().default(false),
126
+ issues: z.array(z.object({
127
+ externalId: z.string(),
128
+ resourceId: z.string(),
129
+ code: z.string(),
130
+ retryState: z.string()
131
+ })).default([])
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));
138
+ const dataSourceListSchema = z.object({
139
+ dataSources: dataSourceListEntriesSchema,
140
+ managedDataSources: dataSourceListEntriesSchema,
141
+ nextAfterId: z.string().default(""),
142
+ dingtalkDocServerId: z.string().nullish().transform((id) => id || void 0),
143
+ alidingDocServerId: z.string().nullish().transform((id) => id || void 0),
144
+ availableProviders: z.array(z.string()).default([])
145
+ }).transform(({ managedDataSources, dataSources, ...page }) => ({
146
+ ...page,
147
+ dataSources: managedDataSources.length ? [...dataSources, ...managedDataSources].sort((a, b) => a.id.localeCompare(b.id, "en")) : dataSources
148
+ }));
149
+ const dataSourceRunsSchema = z.object({
150
+ runs: z.array(dataSourceRunSchema).default([]),
151
+ nextBeforeStartedAt: z.string().nullish(),
152
+ nextBeforeId: z.string().default("")
153
+ });
154
+ const dataSourcePreviewSchema = z.object({
155
+ importCheck: z.enum([
156
+ "readable",
157
+ "empty",
158
+ "unverified"
159
+ ]).optional().catch(void 0),
160
+ resources: z.array(dataSourceResourceSchema).default([]),
161
+ permissionWarnings: permissionGroups,
162
+ permissionGrants
163
+ });
164
+ //#endregion
165
+ //#region ../sdk/src/wiki.ts
166
+ /** 保留 HTTP 错误证据,并以有界状态供宿主选择本地化提示。 */
167
+ var QMindWikiReadError = class extends QMindError {
168
+ wikiState;
169
+ constructor(wikiState, error) {
170
+ super(error.code, error.message, {
171
+ cause: error,
172
+ ...error.operation === void 0 ? {} : { operation: error.operation },
173
+ ...error.status === void 0 ? {} : { status: error.status },
174
+ ...error.upstreamCode === void 0 ? {} : { upstreamCode: error.upstreamCode },
175
+ ...error.requestId === void 0 ? {} : { requestId: error.requestId },
176
+ details: error.details
177
+ });
178
+ this.wikiState = wikiState;
179
+ }
180
+ };
25
181
  //#endregion
26
182
  //#region ../sdk/src/imports.ts
27
183
  const qmindFullSiteURLImportPageLimit = 2e3;
@@ -437,7 +593,12 @@ const sourceChildrenCountsSchema = z.object({ counts: z.array(z.preprocess((valu
437
593
  count: z.number().int().nonnegative().default(0),
438
594
  parentId: z.string().default("")
439
595
  }))).nullish().transform((counts) => counts ?? []) }).transform((value) => value.counts);
440
- 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);
441
602
  const aliDingImportRunSchema = z.preprocess((value) => isRecord$1(value) ? {
442
603
  ...value,
443
604
  bindingId: value.bindingId ?? value.binding_id,
@@ -602,7 +763,7 @@ const notebookCitationSchema = z.preprocess((value) => isRecord$1(value) ? {
602
763
  } : value, z.object({
603
764
  chunkId: z.string().default(""),
604
765
  chunkIndex: z.number().int().nonnegative().default(0),
605
- metadata: z.record(z.string(), z.unknown()).optional(),
766
+ metadata: z.record(z.string(), z.unknown()).nullish().transform((value) => value ?? void 0),
606
767
  originUrl: z.string().optional(),
607
768
  snippet: z.string().default(""),
608
769
  sourceId: z.string().default(""),
@@ -689,7 +850,7 @@ const notebookContextChunkSchema = z.object({
689
850
  chunkId: z.string().default(""),
690
851
  chunkIndex: z.number().int().nonnegative().default(0),
691
852
  content: z.string().default(""),
692
- metadata: z.record(z.string(), z.unknown()).optional(),
853
+ metadata: z.record(z.string(), z.unknown()).nullish().transform((value) => value ?? void 0),
693
854
  originUrl: z.string().optional(),
694
855
  score: z.number().finite().default(0),
695
856
  sourceId: z.string().default(""),
@@ -908,142 +1069,6 @@ const qmindRoutes = {
908
1069
  return qmindPath("notebooks", notebookId, "wiki-branches");
909
1070
  }
910
1071
  };
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
1072
  //#endregion
1048
1073
  //#region ../sdk/src/execution.ts
1049
1074
  const credentialHeaders = /* @__PURE__ */ new Set([
@@ -1120,12 +1145,19 @@ function httpError(operation, response) {
1120
1145
  function isAbortLike(cause) {
1121
1146
  return isRecord(cause) && (cause.name === "AbortError" && typeof cause.name === "string" || cause.code === "ABORT_ERR");
1122
1147
  }
1123
- function transportError(operation, request, cause) {
1148
+ function normalizeTransportError(cause, signal, context = {}) {
1124
1149
  if (cause instanceof QMindError) return cause;
1125
- const aborted = request.signal?.aborted === true || isAbortLike(cause);
1126
- return new QMindError(aborted ? "ABORTED" : "NETWORK_ERROR", aborted ? "QMind request was aborted" : "QMind transport failed", {
1127
- cause,
1128
- operation
1150
+ if (signal?.aborted || isAbortLike(cause)) return new QMindError("ABORTED", "QMind request was aborted", {
1151
+ ...context,
1152
+ cause
1153
+ });
1154
+ if (isRecord(cause) && cause.name === "TimeoutError") return new QMindError("TIMEOUT", "QMind request timed out", {
1155
+ ...context,
1156
+ cause
1157
+ });
1158
+ return new QMindError("NETWORK_ERROR", "QMind transport failed", {
1159
+ ...context,
1160
+ cause
1129
1161
  });
1130
1162
  }
1131
1163
  function requestWasAborted(request) {
@@ -1172,7 +1204,7 @@ async function executeUnary(options) {
1172
1204
  try {
1173
1205
  response = await transport.request(request);
1174
1206
  } catch (cause) {
1175
- throw transportError(operation, request, cause);
1207
+ throw normalizeTransportError(cause, request.signal, { operation });
1176
1208
  }
1177
1209
  if (response.status < 200 || response.status >= 300) throw httpError(operation, response);
1178
1210
  const body = response.body;
@@ -1208,7 +1240,7 @@ async function* executeStream(options) {
1208
1240
  try {
1209
1241
  response = await transport.stream(request);
1210
1242
  } catch (cause) {
1211
- throw transportError(operation, request, cause);
1243
+ throw normalizeTransportError(cause, request.signal, { operation });
1212
1244
  }
1213
1245
  if (response.kind === "response") {
1214
1246
  if (response.status >= 200 && response.status < 300) throw streamContractError(operation, "stream handshake returned no event stream", { status: response.status });
@@ -1238,7 +1270,7 @@ async function* executeStream(options) {
1238
1270
  yield event;
1239
1271
  }
1240
1272
  } catch (cause) {
1241
- throw transportError(operation, request, cause);
1273
+ throw normalizeTransportError(cause, request.signal, { operation });
1242
1274
  }
1243
1275
  if (requestWasAborted(request)) throw new QMindError("ABORTED", "QMind request was aborted", { operation });
1244
1276
  if (!terminal) throw streamContractError(operation, "stream ended before messageComplete", {
@@ -1380,4 +1412,4 @@ function call(context, options) {
1380
1412
  });
1381
1413
  }
1382
1414
  //#endregion
1383
- export { sourceRawContentSchema as $, aliDingImportRunSchema as A, importProvidersSchema as B, dataSourceResourceSchema as C, qmindPath as D, pathBuilder as E, chatSessionSchema as F, sharedNotebookListSchema as G, notebookSchema as H, fullSiteURLImportConfirmationSchema as I, sourceContentSchema as J, sourceActionAccessSchema as K, fullSiteURLImportDiscoverySchema as L, cancelQuestionResultSchema as M, chatMessageListSchema as N, qmindRoutes as O, chatSessionListSchema as P, sourceQuotaSchema as Q, imageUploadTicketSchema as R, dataSourcePreviewSchema as S, dataSourceSchema as T, retrieveNotebooksResultSchema as U, notebookListSchema as V, retrieveResultSchema as W, sourceListSchema as X, sourceImportResultsSchema as Y, sourcePreviewSchema as Z, assertCapability as _, invalidArgument as a, taskRunListSchema as at, dataSourceConfigurationSchema as b, optionalRecord as c, voidResponseSchema as ct, pagination as d, sourceSchema as et, positiveInteger as f, stringList as g, requiredText as h, httpUrl as i, sourceWebOfficeTokenSchema as it, batchDeleteResultSchema as j, aliDingImportRunItemListSchema as k, optionalString as l, qmindFullSiteURLImportPageLimit as lt, requiredString as m, call as n, sourceUploadTicketSchema as nt, nonNegativeInteger as o, taskRunSchema as ot, queryPath as p, sourceChildrenCountsSchema as q, compactUndefined as r, sourceWebOfficeSessionSchema as rt, optionalBoolean as s, timestampSchema as st, assertNonEmptyPatch as t, sourceUploadCapabilitiesSchema as tt, optionalTrimmedString as u, QMindError as ut, executeStream as v, dataSourceRunsSchema as w, dataSourceListSchema as x, executeUnary as y, imageUrlsSchema 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 { D as qmindPath, m as requiredString, n as call, tt as sourceUploadCapabilitiesSchema } from "./shared-evTnu_EB.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 { D as qmindPath, R as imageUploadTicketSchema, a as invalidArgument, ct as voidResponseSchema, et as sourceSchema, l as optionalString, m as requiredString, nt as sourceUploadTicketSchema, p as queryPath, r as compactUndefined, u as optionalTrimmedString, ut as QMindError, y as executeUnary } from "./shared-evTnu_EB.js";
2
- import { t as preflightSourceUpload } from "./source-upload-DckYHoRo.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-evTnu_EB.js";
2
- import { t as nezhaRepoWikiPath } from "./nezha-B_SP8BvK.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 { O as qmindRoutes, a as invalidArgument, d as pagination, m as requiredString, n as call, p as queryPath, st as timestampSchema, u as optionalTrimmedString } from "./shared-evTnu_EB.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.0.0",
3
+ "version": "5.1.1",
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,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-agent-core": "^8.0.0",
43
- "@ali/qmind-node-host": "^4.0.0",
44
- "@ali/qmind-sdk": "^2.0.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
- "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
  }